text " plugins { application `maven-publish` id(""com.github.johnrengelman.shadow"") version ""8.1.1"" kotlin(""jvm"") version(""1.9.21"") } val darkanVersion: String = ""1.9.0"" val ktVer: String = ""1.9.21"" application { group = ""rs.darkan"" version = darkanVersion mainClass.set(""com.rs.Launcher"") } java { toolchain.languageVersion = JavaLanguageVersion.of(21) } repositories { mavenLocal() mavenCentral() maven(""https://gitlab.com/api/v4/projects/42379000/packages/maven"") } dependencies { implementation(""rs.darkan:core:1.6.8"") implementation(""org.jetbrains.kotlin:kotlin-stdlib:$ktVer"") implementation(""org.jetbrains.kotlin:kotlin-stdlib-common:$ktVer"") implementation(""org.jetbrains.kotlin:kotlin-scripting-common:$ktVer"") implementation(""org.jetbrains.kotlin:kotlin-scripting-jvm:$ktVer"") implementation(""org.jetbrains.kotlin:kotlin-scripting-jvm-host:$ktVer"") implementation(""org.jetbrains.kotlin:kotlin-main-kts:$ktVer"") implementation(""org.jetbrains.kotlin:kotlin-script-runtime:$ktVer"") implementation(""org.jetbrains.kotlinx:kotlinx-coroutines-core:1.8.0-RC2"") implementation(""org.openjdk.jmh:jmh-core:1.37"") implementation(""com.google.code.gson:gson:2.10.1"") implementation(""com.google.guava:guava:33.0.0-jre"") implementation(""org.mongodb:mongodb-driver-sync:4.11.1"") implementation(""org.mongodb:mongodb-driver-core:4.11.1"") implementation(""io.netty:netty-all:4.1.104.Final"") implementation(""io.undertow:undertow-core:2.3.10.Final"") implementation(""it.unimi.dsi:fastutil:8.5.12"") implementation(""com.trivago:fastutil-concurrent-wrapper:0.2.2"") // TODO: Deprecated. Upstream dead. Replace with unirest implementation(""com.squareup.okhttp3:okhttp:4.12.0"") } tasks.withType { isZip64 = true mergeServiceFiles() } publishing { val ciProjectId: String? = System.getenv(""CI_PROJECT_ID"") val ciJobToken: String? = System.getenv(""CI_JOB_TOKEN"") val ciPipelineId: String? = System.getenv(""CI_PIPELINE_ID"") if (ciProjectId == null || ciJobToken == null || ciPipelineId == null) { println(""Failed to get project id, job token or pipeline id."") return@publishing } publications.create(""library"") { version = ""${darkanVersion}-${ciPipelineId}"" artifact(""build/libs/world-server-${darkanVersion}-all.jar"") } repositories.maven { name = ""GitLab"" url = uri(""https://gitlab.com/api/v4/projects/${ciProjectId}/packages/maven"") credentials(HttpHeaderCredentials::class) { name = ""Job-Token"" value = ciJobToken } authentication.create(""header"", HttpHeaderAuthentication::class) } }" "rootProject.name = ""world-server""" "/* * OpenRS Cache Library * Copyright (c) 2011 Graham and `Discardedx2 * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ package me.kfricilone.vyre.asm.script; /** * Created by Kyle Fricilone on May 10, 2018. */ public enum CS2InstructionType { PUSH_CONSTANT_INT, PUSH_VAR, POP_VAR, PUSH_VARBIT, POP_VARBIT, PUSH_CONSTANT_STRING, BRANCH, BRANCH_NOT, BRANCH_EQUALS, BRANCH_LESS_THAN, BRANCH_GREATER_THAN, BRANCH_LESS_THAN_OR_EQUALS, BRANCH_GREATER_THAN_OR_EQUALS, PUSH_INT_LOCAL, POP_INT_LOCAL, PUSH_STRING_LOCAL, POP_STRING_LOCAL, JOIN_STRING, POP_INT_DISCARD, POP_STRING_DISCARD, GOSUB_WITH_PARAMS, DEFINE_ARRAY, PUSH_ARRAY_INT, POP_ARRAY_INT, SWITCH, PUSH_LONG_CONSTANT, POP_LONG_DISCARD, PUSH_LONG_LOCAL, POP_LONG_LOCAL, LONG_BRANCH_NOT, LONG_BRANCH_EQUALS, LONG_BRANCH_LESS_THAN, LONG_BRANCH_GREATER_THAN, LONG_BRANCH_LESS_THAN_OR_EQUALS, LONG_BRANCH_GREATER_THAN_OR_EQUALS, PUSH_ARRAY_INT_LEAVE_INDEX_ON_STACK, PUSH_ARRAY_INT_AND_INDEX, POP_ARRAY_INT_LEAVE_VALUE_ON_STACK, BRANCH_IF_TRUE, BRANCH_IF_FALSE, CC_CREATE, CC_DELETE, CC_DELETEALL, CC_INVALIDATE, IF_SENDTOFRONT, IF_SENDTOBACK, CC_SENDTOFRONT, CC_SENDTOBACK, IF_RESUME_PAUSEBUTTON, CC_RESUME_PAUSEBUTTON, BASEIDKIT, BASECOLOUR, BASEMATERIAL, SETGENDER, SETOBJ, CC_SETPOSITION, CC_SETSIZE, CC_SETHIDE, CC_SETASPECT, CC_SETNOCLICKTHROUGH, CC_SETSCROLLPOS, CC_SETCOLOUR, CC_SETFILL, CC_SETTRANS, CC_SETLINEWID, CC_SETGRAPHIC, CC_SET2DANGLE, CC_SETTILING, CC_SETMODEL, CC_SETMODELANGLE, CC_SETMODELANIM, CC_SETMODELORTHOG, CC_SETMODELTINT, CC_SETMODELLIGHTING, CC_RESETMODELLIGHTING, CC_SETTEXT, CC_SETTEXTFONT, CC_SETTEXTALIGN, CC_SETTEXTSHADOW, CC_SETTEXTANTIMACRO, CC_SETOUTLINE, CC_SETGRAPHICSHADOW, CC_SETVFLIP, CC_SETHFLIP, CC_SETSCROLLSIZE, CC_SETALPHA, CC_SETMODELZOOM, CC_SETLINEDIRECTION, CC_SETMODELORIGIN, CC_SETMAXLINES, CC_SETPARAM_INT, CC_SETPARAM_STRING, CC_SETRECOL, CC_SETRETEX, CC_SETFONTMONO, CC_SETPARAM, CC_SETCLICKMASK, CC_SETOBJECT, CC_SETNPCHEAD, CC_SETPLAYERHEAD_SELF, CC_SETNPCMODEL, CC_SETPLAYERMODEL, CC_SETOBJECT_NONUM, CC_SETLINKFRIEND, CC_SETLINKFRIENDCHAT, CC_SETLINKPLAYERGROUP, CC_SETLINKACTIVECLANCHANNEL, CC_RESETLINKPLAYER, CC_SETOBJECT_WEARCOL, CC_SETOBJECT_WEARCOL_NONUM, CC_SETPLAYERMODEL_SELF, CC_SETOBJECT_ALWAYSNUM, CC_SETOBJECT_WEARCOL_ALWAYSNUM, CC_SETOP, CC_SETDRAGGABLE, CC_SETDRAGRENDERBEHAVIOUR, CC_SETDRAGDEADZONE, CC_SETDRAGDEADTIME, CC_SETOPBASE, CC_SETTARGETVERB, CC_CLEAROPS, CC_SETTARGETCURSORS, CC_SETOPCURSOR, CC_SETPAUSETEXT, CC_SETTARGETOPCURSOR, CC_SETOPCHAR, CC_SETOPTCHAR, CC_SETOPKEY, CC_SETOPTKEY, CC_SETOPKEYRATE, CC_SETOPTKEYRATE, CC_SETOPKEYIGNOREHELD, CC_SETOPTKEYIGNOREHELD, CC_SETMOUSEOVERCURSOR, CC_SETONCLICK, CC_SETONHOLD, CC_SETONRELEASE, CC_SETONMOUSEOVER, CC_SETONMOUSELEAVE, CC_SETONDRAG, CC_SETONTARGETLEAVE, CC_SETONVARTRANSMIT, CC_SETONTIMER, CC_SETONOP, CC_SETONDRAGCOMPLETE, CC_SETONCLICKREPEAT, CC_SETONMOUSEREPEAT, CC_SETONINVTRANSMIT, CC_SETONSTATTRANSMIT, CC_SETONTARGETENTER, CC_SETONSCROLLWHEEL, CC_SETONCHATTRANSMIT, CC_SETONKEY, CC_SETONGAMEPADBUTTON, CC_SETONGAMEPADBUTTONHELD, CC_SETONGAMEPADAXIS, CC_SETONGAMEPADTRIGGER, CC_SETONFRIENDTRANSMIT, CC_SETONCLANTRANSMIT, CC_SETONMISCTRANSMIT, CC_SETONDIALOGABORT, CC_SETONSUBCHANGE, CC_SETONSTOCKTRANSMIT, CC_SETONCAMFINISHED, CC_SETONRESIZE, CC_SETONVARCTRANSMIT, CC_SETONVARCSTRTRANSMIT, CC_SETONOPT, CC_SETONCLANSETTINGSTRANSMIT, CC_SETONCLANCHANNELTRANSMIT, CC_SETONVARCLANTRANSMIT, CC_SETONPLAYERGROUPTRANSMIT, CC_SETONPLAYERGROUPVARPTRANSMIT, CC_SETONCAMERAUPDATETRANSMIT, CC_CLEARSCRIPTHOOKS, CC_CALLONRESIZE, IF_SETPOSITION, IF_SETSIZE, IF_SETHIDE, IF_SETASPECT, IF_SETNOCLICKTHROUGH, IF_SETSCROLLPOS, IF_SETCOLOUR, IF_SETFILL, IF_SETTRANS, IF_SETLINEWID, IF_SETGRAPHIC, IF_SET2DANGLE, IF_SETTILING, IF_SETMODEL, IF_SETMODELANGLE, IF_SETMODELANIM, IF_SETMODELORTHOG, IF_SETMODELTINT, IF_SETMODELLIGHTING, IF_RESETMODELLIGHTING, IF_SETTEXT, IF_SETTEXTFONT, IF_SETTEXTALIGN, IF_SETTEXTSHADOW, IF_SETTEXTANTIMACRO, IF_SETOUTLINE, IF_SETGRAPHICSHADOW, IF_SETVFLIP, IF_SETHFLIP, IF_SETSCROLLSIZE, IF_SETALPHA, IF_SETMODELZOOM, IF_SETLINEDIRECTION, IF_SETMODELORIGIN, IF_SETMAXLINES, IF_SETPARAM_INT, IF_SETPARAM_STRING, IF_SETRECOL, IF_SETRETEX, IF_SETFONTMONO, IF_SETCLICKMASK, IF_SETOBJECT, IF_SETNPCHEAD, IF_SETPLAYERHEAD_SELF, IF_SETNPCMODEL, IF_SETPLAYERMODEL, IF_SETOBJECT_NONUM, IF_SETLINKFRIEND, IF_SETLINKFRIENDCHAT, IF_SETLINKPLAYERGROUP, IF_SETLINKACTIVECLANCHANNEL, IF_RESETLINKPLAYER, IF_SETOBJECT_WEARCOL, IF_SETOBJECT_WEARCOL_NONUM, IF_SETPLAYERMODEL_SELF, IF_SETOBJECT_ALWAYSNUM, IF_SETOBJECT_WEARCOL_ALWAYSNUM, IF_SETOP, IF_SETDRAGGABLE, IF_SETDRAGRENDERBEHAVIOUR, IF_SETDRAGDEADZONE, IF_SETDRAGDEADTIME, IF_SETOPBASE, IF_SETTARGETVERB, IF_CLEAROPS, IF_SETTARGETCURSORS, IF_SETOPCURSOR, IF_SETPAUSETEXT, IF_SETTARGETOPCURSOR, IF_SETOPCHAR, IF_SETOPTCHAR, IF_SETOPKEY, IF_SETOPTKEY, IF_SETOPKEYRATE, IF_SETOPTKEYRATE, IF_SETOPKEYIGNOREHELD, IF_SETOPTKEYIGNOREHELD, IF_SETMOUSEOVERCURSOR, IF_SETONCLICK, IF_SETONHOLD, IF_SETONRELEASE, IF_SETONMOUSEOVER, IF_SETONMOUSELEAVE, IF_SETONDRAG, IF_SETONTARGETLEAVE, IF_SETONVARTRANSMIT, IF_SETONTIMER, IF_SETONOP, IF_SETONDRAGCOMPLETE, IF_SETONCLICKREPEAT, IF_SETONMOUSEREPEAT, IF_SETONINVTRANSMIT, IF_SETONSTATTRANSMIT, IF_SETONTARGETENTER, IF_SETONSCROLLWHEEL, IF_SETONCHATTRANSMIT, IF_SETONKEY, IF_SETONGAMEPADBUTTON, IF_SETONGAMEPADBUTTONHELD, IF_SETONGAMEPADAXIS, IF_SETONGAMEPADTRIGGER, IF_SETONFRIENDTRANSMIT, IF_SETONCLANTRANSMIT, IF_SETONMISCTRANSMIT, IF_SETONDIALOGABORT, IF_SETONSUBCHANGE, IF_SETONSTOCKTRANSMIT, IF_SETONCAMFINISHED, IF_SETONRESIZE, IF_SETONVARCTRANSMIT, IF_SETONVARCSTRTRANSMIT, IF_SETONOPT, IF_SETONCLANSETTINGSTRANSMIT, IF_SETONCLANCHANNELTRANSMIT, IF_SETONVARCLANTRANSMIT, IF_SETONPLAYERGROUPTRANSMIT, IF_SETONPLAYERGROUPVARPTRANSMIT, IF_SETONCAMERAUPDATETRANSMIT, IF_CLEARSCRIPTHOOKS, IF_CALLONRESIZE, IF_NPC_SETCUSTOMBODYMODEL, CC_NPC_SETCUSTOMBODYMODEL, IF_NPC_SETCUSTOMHEADMODEL, CC_NPC_SETCUSTOMHEADMODEL, IF_NPC_SETCUSTOMRECOL, CC_NPC_SETCUSTOMRECOL, IF_NPC_SETCUSTOMRETEX, CC_NPC_SETCUSTOMRETEX, MES, RETURN, IF_CLOSE, RESUME_COUNTDIALOG, RESUME_NAMEDIALOG, RESUME_STRINGDIALOG, ABORT_DIALOG, OPPLAYER, RESUME_OBJDIALOG, IF_DRAGPICKUP, CC_DRAGPICKUP, IF_OPENSUBCLIENT, IF_CLOSESUBCLIENT, OPPLAYERT, MES_TYPED, SETUP_MESSAGEBOX, RESUME_HSLDIALOG, RESUME_CLANFORUMQFCDIALOG, SOUND_SYNTH, SOUND_SONG, SOUND_JINGLE, SOUND_SYNTH_VOLUME, SOUND_SONG_VOLUME, SOUND_JINGLE_VOLUME, SOUND_VORBIS_VOLUME, SOUND_SPEECH_VOLUME, SOUND_SYNTH_RATE, SOUND_VORBIS_RATE, EMAIL_VALIDATION_SUBMIT_CODE, EMAIL_VALIDATION_CHANGE_ADDRESS, EMAIL_VALIDATION_ADD_NEW_ADDRESS, FRIEND_SETRANK, FRIEND_SETNOTES, FRIEND_ADD, FRIEND_DEL, IGNORE_ADD, IGNORE_DEL, IGNORE_SETNOTES, FC_KICKUSER, FC_JOINCHAT, FC_LEAVECHAT, IGNORE_ADD_TEMP, AFFINEDCLANSETTINGS_ADDBANNED_FROMCHANNEL, AFFINEDCLANSETTINGS_SETMUTED_FROMCHANNEL, ACTIVECLANCHANNEL_KICKUSER, OC_FINDRESTART, CHAT_SETFILTER, CHAT_SENDABUSEREPORT, CHAT_SETMODE, CHAT_SENDPUBLIC, CHAT_SENDPRIVATE, ACTIVECHATPHRASE_PREPARE, ACTIVECHATPHRASE_SEND, ACTIVECHATPHRASE_SENDPRIVATE, ACTIVECHATPHRASE_SETDYNAMICINT, ACTIVECHATPHRASE_SETDYNAMICOBJ, CHATPHRASE_FINDRESTART, WORLDMAP_3DVIEW_ENABLE, WORLDMAP_3DVIEW_DISABLE, WORLDMAP_3DVIEW_SETLODDISTANCE, WORLDMAP_SETCATEGORYPRIORITY, WORLDMAP_3DVIEW_SETTEXTFONT, WORLDMAP_DISABLETEXTSIZE, WORLDMAP_DISABLETYPE, WORLDMAP_3DVIEW_SETLIGHTING, WORLDMAP_SETZOOM, WORLDMAP_SETMAP, WORLDMAP_JUMPTOSOURCECOORD, WORLDMAP_JUMPTODISPLAYCOORD, WORLDMAP_SETMAP_COORD, WORLDMAP_FLASHELEMENT, WORLDMAP_SETMAP_COORD_OVERRIDE, WORLDMAP_DISABLEELEMENTS, WORLDMAP_FLASHELEMENTCATEGORY, WORLDMAP_DISABLEELEMENTCATEGORY, WORLDMAP_DISABLEELEMENT, WORLDMAP_CLOSEMAP, FULLSCREEN_EXIT, SETWINDOWMODE, SETDEFAULTWINDOWMODE, OPENURL, URLENCODE, SPLINE_NEW, SPLINE_ADDPOINT, QUIT, OPENURL_NOLOGIN, WRITECONSOLE, FORMATMINIMENU, DEFAULTMINIMENU, SETDEFAULTCURSORS, SETHARDCODEDOPCURSORS, DOCHEAT, NOTIFY_ACCOUNTCREATED, NOTIFY_ACCOUNTCREATESTARTED, SETSUBMENUMINLENGTH, OPENURL_SHIM, CAM_MOVETO, CAM_LOOKAT, CAM_MOVEALONG, CAM_RESET, CAM_FORCEANGLE, CAM_INC_X, CAM_DEC_X, CAM_INC_Y, CAM_DEC_Y, CAM_SETFOLLOWHEIGHT, CAM_FOLLOWCOORD, CAM_SMOOTHRESET, CAM_REMOVEROOF, CAM2_SETLOOKATMODE, CAM2_SETPOSITIONMODE, CAM2_SETLOOKATACCELERATION, CAM2_SETPOSITIONACCELERATION, CAM2_SETLOOKATMAXSPEED, CAM2_SETPOSITIONMAXSPEED, CAM2_SETDEPTHPLANES, CAM2_SETFIELDOFVIEW, CAM2_SETLOOKATPOINT_POINT, CAM2_SETPOSITIONPOINT_POINT, CAM2_GETPOSITIONPOINT_POINT, CAM2_SETLOOKATENTITY_PLAYER, CAM2_SETLOOKATENTITY_NPC, CAM2_SETPOSITIONENTITY_PLAYER, CAM2_SETPOSITIONENTITY_NPC, CAM2_SETFIELDOFVIEWSCREEN, CAM2_SETPOSITIONSPLINE_SPLINE, CAM2_SETLOOKATSPLINE_SPLINE, CAM2_REMOVEEFFECT, CAM2_REMOVEALLEFFECTS, CAM2_SETLOOKATACCELERATION_AXIS, CAM2_SETPOSITIONACCELERATION_AXIS, CAM2_SETLOOKATMAXSPEED_AXIS, CAM2_SETPOSITIONMAXSPEED_AXIS, CAM2_SETCOLLISIONMODE, CAM2_SETPOSITIONPOINTCOLLISION, CAM2_UPDATEEFFECT_ZTILT, CAM2_SETTRAILDISTANCE, CAM2_SETLINEARMOVEMENTMODE, CAM2_SETSPRINGPROPERTIES, CAM2_SETLOOKATANGULARINTERPOLATION, CAM2_SETPOSITIONANGULARINTERPOLATION, CAM2_SETLOOKATSPRINGPROPERTIES, CAM2_SETPOSITIONSPRINGPROPERTIES, CAM2_ENABLE, CAM2_SETSNAPDISTANCES, CAM2_RESETSNAPDISTANCES, LOGIN_REQUEST, CAM2_SETLOOKATORIENTATION_VECTOR, CAM2_SETLOOKATORIENTATION_XROTATION, CAM2_SETLOOKATORIENTATION_YROTATION, CAM2_SETLOOKATORIENTATION_XMOVEMENT, CAM2_SETLOOKATORIENTATION_ZMOVEMENT, CAM2_SETLOOKATORIENTATION_MAXDISTANCECLAMPING, LOGIN_CONTINUE, LOGIN_RESETREPLY, RESEND_UID_PASSPORT_REQUEST, CREATE_AVAILABLEREQUEST, CREATE_NAME_AVAILABLEREQUEST, CREATE_SUGGEST_NAME_REQUEST, CREATE_CREATEREQUEST, CREATE_CONNECTREQUEST, CREATE_STEP_REACHED, LOBBY_ENTERGAME, LOBBY_ENTERLOBBY, LOBBY_LEAVELOBBY, CREATE_SETUNDER13, LOGIN_CANCEL, LOGIN_REQUEST_SOCIAL_NETWORK, LOBBY_ENTERLOBBY_SOCIAL_NETWORK, DETAIL_BRIGHTNESS, DETAIL_REMOVEROOFS_OPTION, DETAIL_GROUNDDECOR_ON, DETAIL_IDLEANIMS_MANY, DETAIL_FLICKERING_ON, DETAIL_SPOTSHADOWS_ON, DETAIL_HARDSHADOWS, DETAIL_SHADOWQUALITY, DETAIL_LIGHTDETAIL_HIGH, DETAIL_WATERDETAIL_HIGH, DETAIL_FOG_ON, DETAIL_ANTIALIASING, DETAIL_ANTIALIASING_QUALITY, DETAIL_STEREO, DETAIL_SOUNDVOL, DETAIL_MUSICVOL, DETAIL_BGSOUNDVOL, DETAIL_REMOVEROOFS_OPTION_OVERRIDE, DETAIL_PARTICLES, DETAIL_ANTIALIASING_DEFAULT, DETAIL_BUILDAREA, DETAIL_BLOOM, DETAIL_CUSTOMCURSORS, DETAIL_IDLEANIMS, DETAIL_GROUNDBLENDING, DETAIL_TOOLKIT, DETAIL_TOOLKIT_DEFAULT, DETAIL_CPUUSAGE, DETAIL_TEXTURING, DETAIL_MAXSCREENSIZE, DETAIL_SPEECHVOL, DETAIL_LOGINVOL, DETAIL_LOADINGSCREENTYPE, DETAIL_DRAWDISTANCE, DETAIL_SKYDETAIL, DETAIL_ANIMDETAIL, DETAIL_DISKCACHESIZE, VIEWPORT_SETFOV, VIEWPORT_SETZOOM, VIEWPORT_CLAMPFOV, WORLDLIST_SORT, WORLDLIST_AUTOWORLD, WORLDLIST_PINGWORLDS, IF_DEBUG_BUTTON1, IF_DEBUG_BUTTON2, IF_DEBUG_BUTTON3, IF_DEBUG_BUTTON4, IF_DEBUG_BUTTON5, IF_DEBUG_BUTTON6, IF_DEBUG_BUTTON7, IF_DEBUG_BUTTON8, IF_DEBUG_BUTTON9, IF_DEBUG_BUTTON10, IF_DEBUG_TARGET, IF_TRIGGEROP, CC_TRIGGEROP, FORCE_INTERFACE_DRAG, CANCEL_INTERFACE_DRAG, TARGETMODE_ACTIVE, TARGETMODE_CANCEL, AUTOSETUP_SETHIGH, AUTOSETUP_SETMEDIUM, AUTOSETUP_SETLOW, AUTOSETUP_SETMIN, AUTOSETUP_SETCUSTOM, AUTOSETUP_BLACKFLAGLAST, VIDEO_ADVERT_FORCE_REMOVE, VIDEO_ADVERT_ALLOW_SKIP, BUG_REPORT, ARRAY_SORT, CC_FIND, IF_FIND, CC_GETX, CC_GETY, CC_GETWIDTH, CC_GETHEIGHT, CC_GETHIDE, CC_GETLAYER, CC_GETPARENTLAYER, CC_GETCOLOUR, CC_GETSCROLLX, CC_GETSCROLLY, CC_GETTEXT, CC_GETSCROLLWIDTH, CC_GETSCROLLHEIGHT, CC_GETMODELZOOM, CC_GETMODELANGLE_X, CC_GETMODELANGLE_Z, CC_GETMODELANGLE_Y, CC_GETTRANS, CC_GETMODELXOF, CC_GETMODELYOF, CC_GETGRAPHIC, CC_PARAM, CC_GET2DANGLE, CC_GETMODEL, CC_GETFONTGRAPHIC, CC_GETGRAPHICDIMENSIONS, CC_GETFONTMETRICS, CC_GETINVOBJECT, CC_GETINVCOUNT, CC_GETID, CC_GETTARGETMASK, CC_GETOP, CC_GETOPBASE, CC_GETCHARINDEXATPOS, CC_GETCHARPOSATINDEX, IF_GETX, IF_GETY, IF_GETWIDTH, IF_GETHEIGHT, IF_GETHIDE, IF_GETLAYER, IF_GETPARENTLAYER, IF_GETCOLOUR, IF_GETSCROLLX, IF_GETSCROLLY, IF_GETTEXT, IF_GETSCROLLWIDTH, IF_GETSCROLLHEIGHT, IF_GETMODELZOOM, IF_GETMODELANGLE_X, IF_GETMODELANGLE_Z, IF_GETMODELANGLE_Y, IF_GETTRANS, IF_GETMODELXOF, IF_GETMODELYOF, IF_GETGRAPHIC, IF_GET2DANGLE, IF_GETMODEL, IF_GETFONTGRAPHIC, IF_GETGRAPHICDIMENSIONS, IF_GETFONTMETRICS, IF_GETINVOBJECT, IF_GETINVCOUNT, IF_HASSUB, IF_GETNEXTSUBID, IF_HASSUBMODAL, IF_HASSUBOVERLAY, IF_GETTARGETMASK, IF_GETOP, IF_GETOPBASE, IF_GETCHARINDEXATPOS, IF_GETCHARPOSATINDEX, CLIENTCLOCK, INV_GETOBJ, INV_GETNUM, INV_TOTAL, INV_TOTALCAT, INV_SIZE, INV_STOCKBASE, INV_GETVAR, STAT, STAT_BASE, STAT_VISIBLE_XP, STAT_BASE_ACTUAL, STAT_VISIBLE_XP_ACTUAL, FACING_FINE, COORD, COORDX, COORDY, COORDZ, COORD_FINE, COORDX_FINE, COORDY_FINE, COORDZ_FINE, COORDLEVEL_FINE, MOVECOORD_FINE, COORD_GRIDTOFINE, COORD_FINETOGRID, MAP_MEMBERS, MAP_PRELOAD, MAP_LOADEDPERCENT, INVOTHER_GETOBJ, INVOTHER_GETNUM, INVOTHER_TOTAL, INVOTHER_GETVAR, STAFFMODLEVEL, REBOOTTIMER, MAP_WORLD, RUNENERGY_VISIBLE, RUNWEIGHT_VISIBLE, PLAYERMOD, PLAYERMODLEVEL, PLAYERMEMBER, COMLEVEL_ACTIVE, GENDER, MAP_QUICKCHAT, INV_FREESPACE, INV_TOTALPARAM, INV_TOTALPARAM_STACK, MAP_LANG, MOVECOORD, AFFILIATE, PROFILE_CPU, PLAYERDEMO, APPLET_HASFOCUS, FROMBILLING, GET_MOUSEX, GET_MOUSEY, GET_ACTIVE_MINIMENU_ENTRY, GET_SECOND_MINIMENU_ENTRY, GET_MINIMENU_LENGTH, NPC_FIND_ACTIVE_MINIMENU_ENTRY, PLAYER_FIND_ACTIVE_MINIMENU_ENTRY, GET_CURRENTCURSOR, GET_SELFYANGLE, MAP_ISOWNER, GET_MOUSEBUTTONS, SELF_PLAYER_UID, GET_MINIMENU_TARGET, ENUM_STRING, ENUM, ENUM_HASOUTPUT, ENUM_HASOUTPUT_STRING, ENUM_GETOUTPUTCOUNT, ENUM_GETREVERSECOUNT, ENUM_GETREVERSECOUNT_STRING, ENUM_GETREVERSEINDEX, ENUM_GETREVERSEINDEX_STRING, FRIEND_COUNT, FRIEND_GETNAME, FRIEND_GETWORLD, FRIEND_GETRANK, FRIEND_GETNOTES, FRIEND_GETWORLDFLAGS, FRIEND_TEST, FRIEND_GETWORLDNAME, FC_GETCHATDISPLAYNAME, FC_GETCHATCOUNT, FC_GETCHATUSERNAME, FC_GETCHATUSERWORLD, FC_GETCHATUSERRANK, FC_GETCHATMINKICK, FC_GETCHATRANK, IGNORE_COUNT, IGNORE_GETNAME, IGNORE_GETNOTES, IGNORE_TEST, FC_ISSELF, FC_GETCHATOWNERNAME, FC_GETCHATUSERWORLDNAME, FRIEND_PLATFORM, FRIEND_GETSLOTFROMNAME, IGNORE_GETSLOTFROMNAME, PLAYERCOUNTRY, IGNORE_IS_TEMP, FC_GETCHATUSERNAME_UNFILTERED, IGNORE_GETNAME_UNFILTERED, FRIEND_IS_REFERRER, FRIEND_IS_REFERRED, ACTIVECLANSETTINGS_FIND_LISTENED, ACTIVECLANSETTINGS_FIND_AFFINED, ACTIVECLANSETTINGS_GETCLANNAME, ACTIVECLANSETTINGS_GETALLOWUNAFFINED, ACTIVECLANSETTINGS_GETRANKTALK, ACTIVECLANSETTINGS_GETRANKKICK, ACTIVECLANSETTINGS_GETRANKLOOTSHARE, ACTIVECLANSETTINGS_GETCOINSHARE, ACTIVECLANSETTINGS_GETAFFINEDCOUNT, ACTIVECLANSETTINGS_GETAFFINEDDISPLAYNAME, ACTIVECLANSETTINGS_GETAFFINEDRANK, ACTIVECLANSETTINGS_GETAFFINEDMUTED, ACTIVECLANSETTINGS_GETBANNEDCOUNT, ACTIVECLANSETTINGS_GETBANNEDDISPLAYNAME, ACTIVECLANSETTINGS_GETAFFINEDEXTRAINFO, ACTIVECLANSETTINGS_GETCURRENTOWNER_SLOT, ACTIVECLANSETTINGS_GETREPLACEMENTOWNER_SLOT, ACTIVECLANSETTINGS_GETAFFINEDSLOT, ACTIVECLANSETTINGS_GETSORTEDAFFINEDSLOT, ACTIVECLANSETTINGS_GETAFFINEDJOINRUNEDAY, ACTIVECLANCHANNEL_FIND_LISTENED, ACTIVECLANCHANNEL_FIND_AFFINED, ACTIVECLANCHANNEL_GETCLANNAME, ACTIVECLANCHANNEL_GETRANKKICK, ACTIVECLANCHANNEL_GETRANKTALK, ACTIVECLANCHANNEL_GETUSERCOUNT, ACTIVECLANCHANNEL_GETUSERDISPLAYNAME, ACTIVECLANCHANNEL_GETUSERRANK, ACTIVECLANCHANNEL_GETUSERWORLD, ACTIVECLANCHANNEL_GETUSERSLOT, ACTIVECLANCHANNEL_GETSORTEDUSERSLOT, CLANPROFILE_FIND, STOCKMARKET_GETOFFERTYPE, STOCKMARKET_GETOFFERITEM, STOCKMARKET_GETOFFERPRICE, STOCKMARKET_GETOFFERCOUNT, STOCKMARKET_GETOFFERCOMPLETEDCOUNT, STOCKMARKET_GETOFFERCOMPLETEDGOLD, STOCKMARKET_ISOFFEREMPTY, STOCKMARKET_ISOFFERSTABLE, STOCKMARKET_ISOFFERFINISHED, STOCKMARKET_ISOFFERADDING, ADD, SUB, MULTIPLY, DIVIDE, RANDOM, RANDOMINC, INTERPOLATE, ADDPERCENT, SETBIT, CLEARBIT, TESTBIT, MODULO, POW, INVPOW, AND, OR, MIN, MAX, SCALE, RANDOM_SOUND_PITCH, HSVTORGB, NOT, APPEND_NUM, APPEND, APPEND_SIGNNUM, GET_COL_TAG, LOWERCASE, FROMDATE, TEXT_GENDER, TOSTRING, COMPARE, PARAHEIGHT, PARAWIDTH, PARALINE, TEXT_SWITCH, ESCAPE, APPEND_CHAR, CHAR_ISPRINTABLE, CHAR_ISALPHANUMERIC, CHAR_ISALPHA, CHAR_ISNUMERIC, STRING_LENGTH, SUBSTRING, REMOVETAGS, STRING_INDEXOF_CHAR, STRING_INDEXOF_STRING, CHAR_TOLOWERCASE, CHAR_TOUPPERCASE, TOSTRING_LOCALISED, STRINGWIDTH, STRING_DISTANCE, FORMAT_DATETIME_FROM_MINUTES, CLANFORUMQFC_TOSTRING, OC_NAME, OC_OP, OC_IOP, OC_COST, OC_STACKABLE, OC_CATEGORY, OC_HASVAROBJ, OC_CERT, OC_UNCERT, OC_SHARD, OC_UNSHARD, OC_SHARDCOUNT, OC_WEARPOS, OC_WEARPOS2, OC_WEARPOS3, OC_MEMBERS, OC_PARAM, OC_ICURSOR, OC_MULTISTACKSIZE, OC_FIND, OC_FINDNEXT, OC_MINIMENU_COLOUR_OVERRIDDEN, OC_MINIMENU_COLOUR, NPC_PARAM, OBJECT_PARAM, STRUCT_PARAM, SEQ_PARAM, SEQLENGTH, BAS_GETANIM_READY, CHAT_GETFILTER_PUBLIC, CHAT_GETHISTORY_BYTYPEANDLINE, CHAT_GETHISTORY_BYUID, CHAT_GETFILTER_PRIVATE, CHAT_PLAYERNAME, CHAT_GETFILTER_TRADE, CHAT_GETHISTORYLENGTH, CHAT_GETNEXTUID, CHAT_GETPREVUID, CHAT_PLAYERNAME_UNFILTERED, CHATCAT_GETDESC, CHATCAT_GETSUBCATCOUNT, CHATCAT_GETSUBCAT, CHATCAT_GETPHRASECOUNT, CHATCAT_GETPHRASE, CHATPHRASE_GETTEXT, CHATPHRASE_GETAUTORESPONSECOUNT, CHATPHRASE_GETAUTORESPONSE, CHATCAT_GETSUBCATSHORTCUT, CHATCAT_GETPHRASESHORTCUT, CHATCAT_FINDSUBCATBYSHORTCUT, CHATCAT_FINDPHRASEBYSHORTCUT, CHATPHRASE_GETDYNAMICCOMMANDCOUNT, CHATPHRASE_GETDYNAMICCOMMAND, CHATPHRASE_GETDYNAMICCOMMANDPARAM_ENUM, CHATPHRASE_FIND, CHATPHRASE_FINDNEXT, KEYHELD_ALT, KEYHELD_CTRL, KEYHELD_SHIFT, WORLDMAP_3DVIEW_ACTIVE, WORLDMAP_3DVIEW_GETCOORDFINE, WORLDMAP_3DVIEW_GETLODDISTANCE, WORLDMAP_GETCATEGORYPRIORITY, WORLDMAP_3DVIEW_GETTEXTFONT, WORLDMAP_3DVIEW_GETSCREENPOSITION, WORLDMAP_GETDISABLETEXTSIZE, WORLDMAP_GETDISABLETYPE, WORLDMAP_GETZOOM, WORLDMAP_GETMAP, WORLDMAP_GETMAPNAME, WORLDMAP_GETSIZE, WORLDMAP_GETDISPLAYPOSITION, WORLDMAP_GETCONFIGORIGIN, WORLDMAP_GETCONFIGSIZE, WORLDMAP_GETCONFIGBOUNDS, WORLDMAP_LISTELEMENT_START, WORLDMAP_LISTELEMENT_NEXT, WORLDMAP_COORDINMAP, WORLDMAP_GETCONFIGZOOM, WORLDMAP_ISLOADED, WORLDMAP_GETSOURCEPOSITION, WORLDMAP_GETDISPLAYCOORD, WORLDMAP_GETSOURCECOORD, WORLDMAP_GETDISABLEELEMENTS, WORLDMAP_GETDISABLEELEMENTCATEGORY, WORLDMAP_GETDISABLEELEMENT, WORLDMAP_GETCURRENTMAP, WORLDMAP_FINDNEARESTELEMENT, FULLSCREEN_ENTER, FULLSCREEN_MODECOUNT, FULLSCREEN_GETMODE, FULLSCREEN_LASTMODE, GETWINDOWMODE, GETDEFAULTWINDOWMODE, SPLINE_LENGTH, LASTLOGIN, MINIMENUOPEN, GETCLIPBOARD, HAS_HTML5, HAS_NXT, CLIENTTYPE, IS_GAMESCREEN_STATE, CAM_GETANGLE_XA, CAM_GETANGLE_YA, CAM_GETFOLLOWHEIGHT, CAM2_GETCONTROLMODE, CAM2_GETLOOKATMODE, CAM2_GETPOSITIONMODE, CAM2_GETPOSITIONENTITY_ANGLEOFFSETS, CAM2_ADDEFFECT_SHAKE, CAM2_GETPOSITIONENTITY_LOOKATANGLEOFFSETS, CAM2_GETPOSITIONENTITY_LOOKATANGLE, CAM2_GETPOSITIONENTITY_LOOKATDISTANCE, CAM2_ADDEFFECT_ZTILT, CAM2_ISENABLED, CAM2_LEGACYCAM_READY, CAM_MODEISFOLLOWPLAYER, LOGIN_REPLY, LOGIN_HOPTIME, LOGIN_BAN_DURATION, CREATE_REPLY, CREATE_EMAIL_VALIDATE_REPLY, CREATE_NAME_VALIDATE_REPLY, CREATE_SUGGEST_NAME_REPLY, CREATE_CONNECT_REPLY, LOGIN_DISALLOWRESULT, LOBBY_ENTERGAMEREPLY, LOBBY_ENTERLOBBYREPLY, USERFLOWFLAGS, AUTOMATEDTESTFLAGS, CREATE_UNDER13, LOGIN_LAST_TRANSFER_REPLY, LOGIN_INPROGRESS, LOGIN_QUEUE_POSITION, LOGIN_DISALLOWTRIGGER, CREATE_GET_EMAIL, LOGIN_ACCOUNTAPPEAL, DETAILGET_BRIGHTNESS, DETAILGET_REMOVEROOFS_OPTION, DETAILGET_GROUNDDECOR_ON, DETAILGET_IDLEANIMS_MANY, DETAILGET_FLICKERING_ON, DETAILGET_SPOTSHADOWS_ON, DETAILGET_HARDSHADOWS, DETAILGET_SHADOWQUALITY, DETAILGET_LIGHTDETAIL_HIGH, DETAILGET_WATERDETAIL_HIGH, DETAILGET_FOG_ON, DETAILGET_ANTIALIASING, DETAILGET_ANTIALIASING_QUALITY, DETAILGET_STEREO, DETAILGET_SOUNDVOL, DETAILGET_MUSICVOL, DETAILGET_BGSOUNDVOL, DETAILGET_PARTICLES, DETAILGET_ANTIALIASING_DEFAULT, DETAILGET_BUILDAREA, DETAILGET_BLOOM, DETAILGET_CUSTOMCURSORS, DETAILGET_IDLEANIMS, DETAILGET_GROUNDBLENDING, DETAILGET_TOOLKIT, DETAILGET_TOOLKIT_DEFAULT, DETAILGET_CPUUSAGE, DETAILGET_TEXTURING, DETAILGET_PERFORMANCE_METRIC, DETAILGET_MAXSCREENSIZE, DETAILGET_SPEECHVOL, DETAILGET_LOGINVOL, DETAILGET_SAFEMODE, DETAILGET_LOADINGSCREENTYPE, DETAILGET_ORTHOGRAPHIC, DETAILGET_CANCHOOSESAFEMODE, DETAILGET_CHOSESAFEMODE, DETAILGET_SKYDETAIL, DETAILGET_DRAWDISTANCE, DETAILGET_MAXDISKCACHESIZE, DETAILGET_MINDISKCACHESIZE, DETAILGET_RECOMMENDEDDISKCACHESIZE, DETAILGET_DISKCACHESIZE, DETAILGET_ANIMDETAIL, VIEWPORT_GETEFFECTIVESIZE, VIEWPORT_GETZOOM, VIEWPORT_GETFOV, DATE_MINUTES, DATE_RUNEDAY, DATE_RUNEDAY_FROMDATE, DATE_YEAR, DATE_ISLEAPYEAR, DATE_RUNEDAY_TODATE, DATE_MINUTES_FROMRUNEDAY, WORLDLIST_FETCH, WORLDLIST_START, WORLDLIST_NEXT, WORLDLIST_SWITCH, WORLDLIST_SPECIFIC, WORLDLIST_SPECIFIC_THISWORLD, IF_GETTOP, IF_DEBUG_GETOPENIFCOUNT, IF_DEBUG_GETOPENIFID, IF_DEBUG_GETNAME, IF_DEBUG_GETCOMCOUNT, IF_DEBUG_GETCOMNAME, IF_DEBUG_GETSERVERTRIGGERS, OPCOUNT, MEC_TEXT, MEC_SPRITE, MEC_TEXTSIZE, MEC_CATEGORY, MEC_PARAM, USERDETAIL_QUICKCHAT, USERDETAIL_LOBBY_MEMBERSHIP, USERDETAIL_LOBBY_RECOVERYDAY, USERDETAIL_LOBBY_UNREADMESSAGES, USERDETAIL_LOBBY_LASTLOGINDAY, USERDETAIL_LOBBY_LASTLOGINADDRESS, USERDETAIL_LOBBY_EMAILSTATUS, USERDETAIL_LOBBY_CCEXPIRY, USERDETAIL_LOBBY_GRACEEXPIRY, USERDETAIL_LOBBY_DOBREQUESTED, USERDETAIL_DOB, USERDETAIL_LOBBY_MEMBERSSTATS, USERDETAIL_LOBBY_PLAYAGE, USERDETAIL_LOBBY_JCOINS_BALANCE, USERDETAIL_LOBBY_LOYALTY_BALANCE, AUTOSETUP_DOSETUP, AUTOSETUP_GETLEVEL, VIDEO_ADVERT_PLAY, VIDEO_ADVERT_HAS_FINISHED, GET_ENTITY_SAY, GET_DISPLAYNAME_WITHEXTRAS, GET_NPC_NAME, GET_NPC_VISLEVEL, GET_ENTITY_SCREEN_POSITION, IF_GET_GAMESCREEN, IF_SET_GAMESCREEN_ENABLED, GET_ENTITY_OVERLAY_HEIGHT, GET_NPC_STAT, IS_NPC_ACTIVE, IS_NPC_VISIBLE, IS_TARGETED_ENTITY, NPC_TYPE, GET_LOC_SCREEN_POSITION, GET_OBJ_SCREEN_POSITION, GET_LOC_OVERLAY_HEIGHT, GET_OBJ_OVERLAY_HEIGHT, GET_LOC_BOUNDING_BOX, GET_OBJ_BOUNDING_BOX, GET_ENTITY_BOUNDING_BOX, QUEST_GETNAME, QUEST_GETSORTNAME, QUEST_TYPE, QUEST_GETDIFFICULTY, QUEST_GETMEMBERS, QUEST_POINTS, QUEST_QUESTREQ_COUNT, QUEST_QUESTREQ, QUEST_QUESTREQ_MET, QUEST_POINTSREQ, QUEST_POINTSREQ_MET, QUEST_STATREQ_COUNT, QUEST_STATREQ_STAT, QUEST_STATREQ_LEVEL, QUEST_STATREQ_MET, QUEST_VARPREQ_COUNT, QUEST_VARPREQ_DESC, QUEST_VARPREQ_MET, QUEST_VARBITREQ_COUNT, QUEST_VARBITREQ_DESC, QUEST_VARBITREQ_MET, QUEST_ALLREQMET, QUEST_STARTED, QUEST_FINISHED, QUEST_PARAM, MAP_BUILD_COMPLETE, SOUND_SONG_STOP, SOUND_GROUP_START, SOUND_GROUP_STOP, SOUND_VORBIS_VOLUME_RATE_GROUP, SOUND_MIXBUSS_ADD, SOUND_MIXBUSS_SETLEVEL, SOUND_DISTANCEFOCUSFILTER_SETPARAMS, PRELOAD_PERCENT, SHADER_PRELOAD_ALLOW, SHADER_PRELOAD_PERCENT, SHADER_PRELOAD_THROTTLE, CAN_RUN_JAVA_CLIENT, FPS_STATS, RUNJAVASCRIPT, WORLDMAP_JUMPTOSOURCECOORD_INSTANT, WORLDMAP_JUMPTODISPLAYCOORD_INSTANT, WORLDMAP_SETFLASHLOOPS, WORLDMAP_SETFLASHLOOPS_DEFAULT, WORLDMAP_SETFLASHTICS, WORLDMAP_SETFLASHTICS_DEFAULT, WORLDMAP_PERPETUALFLASH, WORLDMAP_STOPCURRENTFLASHES, PLAYER_GROUP_FIND, PLAYER_GROUP_MEMBER_COUNT, PLAYER_GROUP_MEMBER_GET_SAME_WORLD_VAR, PLAYER_GROUP_MEMBER_GET_RANK, PLAYER_GROUP_MEMBER_GET_TEAM, PLAYER_GROUP_MEMBER_GET_LAST_SEEN_NODE_ID, PLAYER_GROUP_MEMBER_GET_STATUS, PLAYER_GROUP_MEMBER_IS_ONLINE, PLAYER_GROUP_MEMBER_IS_MEMBER, PLAYER_GROUP_MEMBER_GET_DISPLAYNAME, PLAYER_GROUP_MEMBER_GET_JOIN_XP, PLAYER_GROUP_MEMBER_IS_OWNER, PLAYER_GROUP_BANNED_COUNT, PLAYER_GROUP_BANNED_GET_DISPLAYNAME, PLAYER_GROUP_GET_DISPLAYNAME, PLAYER_GROUP_GET_MAX_SIZE, PLAYER_GROUP_GET_CREATE_MINS_SINCE_EPOCH, PLAYER_GROUP_GET_CREATE_SECONDS_TO_NOW, PLAYER_GROUP_IS_MEMBERS_ONLY, PLAYER_GROUP_GET_OVERALL_STATUS, PLAYER_GROUP_GET_OWNER_SLOT, TTV_LOGIN, TTV_LOGIN_GETSTATE, TTV_LOGOUT, TTV_LIBRARY_GETSTATE, TTV_LIBRARY_REQUEST, TTV_STREAM_GETSTATE, TTV_STREAM_START, TTV_STREAM_STOP, TTV_STREAM_SETTITLE, TTV_STREAM_GETVIEWERS, TTV_STREAM_GETQUALITY, TTV_STREAM_SETSMOOTHRESIZE, TTV_CHAT_GETSTATE, TTV_CHAT_SENDMESSAGE, TTV_WEBCAM_GETSTATE, TTV_WEBCAM_SUPPORTED, TTV_WEBCAM_GETDEVICE_COUNT, TTV_WEBCAM_GETDEVICE_BYINDEX, TTV_WEBCAM_GETDEVICE_BYUNIQUENAME, TTV_WEBCAM_GETCAP_COUNT, TTV_WEBCAM_GETCAP_BYINDEX, TTV_WEBCAM_GETCAP_BYUNIQUEID, TTV_WEBCAM_START, TTV_WEBCAM_STOP, TTV_WEBCAM_FLIP, TTV_LIVESTREAMS_UPDATE, TTV_LIVESTREAMS_GETSTREAM_START, TTV_LIVESTREAMS_GETSTREAM_NEXT, TTV_SETDEBUGOUPUT, TTV_HASPREREQUISITES, OS_ISMAC, OS_ISWINDOWS, OS_ISLINUX, OS_PHYSICALMEMORYSIZE, GETGRIDCOORDRELATIVETOCAMERA, MOVESCRIPTED, TELEMETRY_GET_GROUP_COUNT, TELEMETRY_GET_GROUP_INDEX, TELEMETRY_GET_GROUP_ID, TELEMETRY_GET_ROW_COUNT, TELEMETRY_GET_ROW_INDEX, TELEMETRY_GET_ROW_ID, TELEMETRY_IS_ROW_PINNED, TELEMETRY_GET_COLUMN_COUNT, TELEMETRY_GET_COLUMN_INDEX, TELEMETRY_GET_COLUMN_ID, TELEMETRY_GET_GRID_VALUE, TELEMETRY_IS_GRID_PROCESSOR_SET, EMOJI_ADD, EMOJI_REMOVE, EMOJI_REMOVEALL, EMOJI_SUBSTITUTE, EMOJI_ENABLE_AUTO_CHATLINE, DB_FIND, DB_FIND_WITH_COUNT, DB_FINDNEXT, DB_GETFIELD, DB_GETFIELDCOUNT, DETAILCANMOD_GROUNDDECOR, DETAILCANMOD_SPOTSHADOWS, DETAILCANMOD_HARDSHADOWS, DETAILCANMOD_SHADOWQUALITY, DETAILCANMOD_WATERDETAIL, DETAILCANMOD_ANTIALIASING, DETAILCANMOD_ANTIALIASING_QUALITY, DETAILCANMOD_PARTICLES, DETAILCANMOD_BUILDAREA, DETAILCANMOD_BLOOM, DETAILCANMOD_GROUNDBLENDING, DETAILCANMOD_TEXTURING, DETAILCANMOD_MAXSCREENSIZE, DETAILCANMOD_FOG, DETAILCANMOD_ORTHOGRAPHIC, DETAILCANMOD_TOOLKIT_DEFAULT, DETAILCANMOD_SKYDETAIL, DETAILCANMOD_ANIMDETAIL, DETAILCANSET_GROUNDDECOR, DETAILCANSET_SPOTSHADOWS, DETAILCANSET_HARDSHADOWS, DETAILCANSET_SHADOWQUALITY, DETAILCANSET_WATERDETAIL, DETAILCANSET_ANTIALIASING, DETAILCANSET_ANTIALIASING_QUALITY, DETAILCANSET_PARTICLES, DETAILCANSET_BUILDAREA, DETAILCANSET_BLOOM, DETAILCANSET_GROUNDBLENDING, DETAILCANSET_TEXTURING, DETAILCANSET_MAXSCREENSIZE, DETAILCANSET_FOG, DETAILCANSET_ORTHOGRAPHIC, DETAILCANSET_TOOLKIT_DEFAULT, DETAILCANSET_SKYDETAIL, DETAILCANSET_ANIMDETAIL, DETAIL_SHADOWS, DETAIL_LIGHTINGQUALITY, DETAIL_ANTIALIASINGMODE, DETAIL_AMBIENTOCCLUSION, DETAIL_REFLECTIONS, DETAIL_VSYNC, DETAILGET_SHADOWS, DETAILGET_LIGHTINGQUALITY, DETAILGET_ANTIALIASINGMODE, DETAILGET_AMBIENTOCCLUSION, DETAILGET_REFLECTIONS, DETAILGET_VSYNC, DETAILCANMOD_SHADOWS, DETAILCANMOD_LIGHTINGQUALITY, DETAILCANMOD_ANTIALIASINGMODE, DETAILCANMOD_AMBIENTOCCLUSION, DETAILCANMOD_REFLECTIONS, DETAILCANMOD_VSYNC, DETAILCANSET_SHADOWS, DETAILCANSET_LIGHTINGQUALITY, DETAILCANSET_ANTIALIASINGMODE, DETAILCANSET_AMBIENTOCCLUSION, DETAILCANSET_REFLECTIONS, DETAILCANSET_VSYNC, AUTOSETUP_SETULTRA; public String getFunction() { return ""_"" + name().toLowerCase(); } }" "onNpcClick(""Man"", options = arrayOf(""Talk-to"")) { e -> e.player.startConversation { npc(e.npc.id, HAPPY_TALKING, ""Hello there, adventurer! What brings you to our town?"") options { //Conditional options example if (e.player.inventory.containsItem(1050, 1)) option(""Ask about the town"") { npc(e.npc.id, HAPPY_TALKING, ""This town is known for its ancient history and beautiful landscapes."") player(HAPPY_TALKING, ""That sounds fascinating!"") npc(e.npc.id, HAPPY_TALKING, ""Feel free to explore and enjoy your stay!"") } option(""Ask about quests"") { npc(e.npc.id, HAPPY_TALKING, ""Oh, there are many adventures to be had here!"") player(HAPPY_TALKING, ""Any specific recommendations?"") npc(e.npc.id, HAPPY_TALKING, ""You should visit the old wizard on the hill for a magical quest."") } option(""Say goodbye"") { player(HAPPY_TALKING, ""Thanks for your time. I must be going now."") npc(e.npc.id, HAPPY_TALKING, ""Safe travels, adventurer!"") } } } }" "val messages = arrayOf( Pair(HAPPY_TALKING, ""I'm fine!""), Pair(CALM_TALK, ""I think we need a new king. The one we've got isn't good.""), Pair(CALM_TALK, ""Not too bad. But I'm quite worried about the goblin population these days.""), Pair(CONFUSED, ""Who are you?..""), Pair(HAPPY_TALKING, ""Hello.""), Pair(NERVOUS, ""I've heard there are many fearsome creatures that dwell underground...""), Pair(WORRIED, ""I'm a little worried. I've heard there are people killing citizens at random."") ) onNpcClick(""Man"", ""Woman"", options = arrayOf(""Talk-to"")) { e -> val (chathead, text) = messages.random() e.player.startConversation { player(HAPPY_TALKING, ""Hello, how's it going?"") npc(e.npc.id, chathead, text) } }" "package com.rs; public final class Launcher { public static void main(String[] args) throws Exception { Logger.setupFormat(); Logger.setLevel(Level.FINE); //FINER for traces JsonFileManager.setGSON(new GsonBuilder() .registerTypeAdapter(Controller.class, new ControllerAdapter()) .registerTypeAdapter(Date.class, new DateAdapter()) .registerTypeAdapter(PacketEncoder.class, new PacketEncoderAdapter()) .registerTypeAdapter(Packet.class, new PacketAdapter()) .registerTypeAdapterFactory(new RecordTypeAdapterFactory()) .disableHtmlEscaping() .setPrettyPrinting() .create()); Settings.loadConfig(); if (!Settings.getConfig().isDebug()) Logger.setLevel(Level.WARNING); long currentTime = System.currentTimeMillis(); Cache.init(Settings.getConfig().getCachePath()); MapXTEAs.loadKeys(); WorldDB DB = new WorldDB(); DB.init(); GameDecoder.loadPacketDecoders(); AsyncTaskExecutor.initExecutors(); PluginManager.loadPlugins(); PluginManager.executeStartupHooks(); try { ServerChannelHandler.init(Settings.getConfig().getWorldInfo().port(), BaseWorldDecoder.class); } catch (Throwable e) { Logger.handle(Launcher.class, ""main"", e); Logger.error(Launcher.class, ""main"", ""Failed to initialize server channel handler. Shutting down...""); System.exit(1); return; } WorldThread.init(); Logger.info(Launcher.class, ""main"", ""Server launched in "" + (System.currentTimeMillis() - currentTime) + "" ms...""); Logger.info(Launcher.class, ""main"", ""Server is listening at "" + InetAddress.getLocalHost().getHostAddress() + "":"" + Settings.getConfig().getWorldInfo().port() + ""...""); Logger.info(Launcher.class, ""main"", ""Player will be directed to ""+Settings.getConfig().getWorldInfo()+""...""); Logger.info(Launcher.class, ""main"", ""Registering world with lobby server...""); Logger.info(Launcher.class, ""main"", Settings.getConfig().getWorldInfo()); new WorldAPI().start(); LobbyCommunicator.post(Boolean.class, Settings.getConfig().getWorldInfo(), ""addworld"", success -> { if (success) Logger.info(Launcher.class, ""main"", ""Registered world with lobby server...""); else Logger.warn(Launcher.class, ""main"", ""Failed to register world with lobby server... You can still login locally but social features will not work properly.""); }); addCleanMemoryTask(); // Runtime.getRuntime().addShutdownHook(new Thread() { // @Override // public void run() { // try { // for (Player player : World.getPlayers()) { // if (player == null || !player.hasStarted()) // continue; // try { // player.getPackets().sendLogout(player, true); // player.realFinish(); // } catch(Throwable e) { // // } // } // PartyRoom.save(); // Launcher.shutdown(); // } catch (Throwable e) { // Logger.handle(this, e); // } // } // }); } private static void addCleanMemoryTask() { AsyncTaskExecutor.schedule(() -> { try { cleanMemory(WorldUtil.getMemUsedPerc() > Settings.HIGH_MEM_USE_THRESHOLD); } catch (Throwable e) { Logger.handle(Launcher.class, ""addCleanMemoryTask"", e); } }, 0, Ticks.fromMinutes(10)); //}, 0, Ticks.fromSeconds(10)); } public static void saveFilesSync() { for (Player player : World.getPlayers()) { if (player == null || !player.hasStarted() || player.hasFinished()) continue; WorldDB.getPlayers().saveSync(player); } WorldPersistentData.save(); } public static void saveFilesAsync() { for (Player player : World.getPlayers()) { if (player == null || !player.hasStarted() || player.hasFinished()) continue; WorldDB.getPlayers().save(player); } WorldPersistentData.save(); } public static void cleanMemory(boolean force) { if (force) { ItemDefinitions.clearItemsDefinitions(); NPCDefinitions.clearNPCDefinitions(); ObjectDefinitions.clearObjectDefinitions(); ChunkManager.clearUnusedMemory(); Logger.debug(Launcher.class, ""cleanMemory"", ""Force cleaning cached data.""); } for (Index index : Cache.STORE.getIndices()) index.resetCachedFiles(); System.gc(); System.gc(); } public static void shutdown() { try { closeServices(); } finally { System.exit(0); } } public static void closeServices() { ServerChannelHandler.shutdown(); AsyncTaskExecutor.shutdown(); } private Launcher() { } public static void executeCommand(String cmd) { executeCommand(null, cmd); } public static void executeCommand(Player player, String cmd) { AsyncTaskExecutor.execute(() -> { try { String line; ProcessBuilder builder = new ProcessBuilder(cmd.split("" "")); Process proc = builder.start(); BufferedReader in = new BufferedReader(new InputStreamReader(proc.getInputStream())); while ((line = in.readLine()) != null) { if (player != null) player.getPackets().sendDevConsoleMessage(line); Logger.debug(Launcher.class, ""executeCommand"", line); } proc.waitFor(); in.close(); } catch (IOException | InterruptedException e) { if (player != null) player.getPackets().sendDevConsoleMessage(""Error: "" + e.getMessage()); Logger.handle(Launcher.class, ""executeCommand"", e); } }); } }" "package com.rs; public final class Settings { private static Settings SETTINGS; private static final Settings DEFAULTS = new Settings(); public static Settings getConfig() { if (SETTINGS == null) loadConfig(); return SETTINGS; } private String serverName; private String ownerName; private String cachePath; private boolean debug = false; private boolean enableJFR = false; private final boolean allowHighMemUseOptimizations; private String mongoUrl; private int mongoPort; private String mongoUser; private String mongoPass; private String mongoDbName; private String lobbyIp; private String lobbyApiKey; private WorldInfo worldInfo; private String loginMessage; private Tile playerStartTile; private Tile playerRespawnTile; private int xpRate; private double dropModifier; private Item[] startItems; private String staffWebhookUrl; public Settings() { serverName = ""Darkan""; ownerName = ""trent""; cachePath = ""../cache/""; debug = false; enableJFR = false; allowHighMemUseOptimizations = false; lobbyIp = ""dev.darkan.org""; mongoUrl = ""localhost""; mongoPort = 27017; mongoUser = """"; mongoPass = """"; mongoDbName = ""darkan-server""; lobbyApiKey = ""TEST_API_KEY""; worldInfo = new WorldInfo(3, ""127.0.0.1"", 43595, ""My Test World"", 1, false, true, true, false, false); loginMessage = """"; playerStartTile = Tile.of(2889, 3528, 0); playerRespawnTile = Tile.of(2887, 3535, 0); xpRate = 1; dropModifier = 1.0; startItems = new Item[] { new Item(1351, 1), new Item(590, 1), new Item(303, 1), new Item(315, 1), new Item(1925, 1), new Item(1931, 1), new Item(2309, 1), new Item(1265, 1), new Item(1205, 1), new Item(1277, 1), new Item(1171, 1), new Item(841, 1), new Item(882, 25), new Item(556, 25), new Item(558, 15), new Item(555, 6), new Item(557, 4), new Item(559, 2), }; staffWebhookUrl = null; } public static final long WORLD_CYCLE_NS = 600000000L; public static final long WORLD_CYCLE_MS = WORLD_CYCLE_NS / 1000000L; public static final int AIR_GUITAR_MUSICS_COUNT = 150; public static final int PLAYERS_LIMIT = 2000; public static final int LOCAL_PLAYERS_LIMIT = 250; public static final int NPCS_LIMIT = 64000; public static final int LOCAL_NPCS_LIMIT = 250; public static final double HIGH_MEM_USE_THRESHOLD = 85.0; public static ArrayList COMMIT_HISTORY = new ArrayList<>(); public static void loadConfig() { Logger.info(Settings.class, ""loadConfig"", ""Loading config...""); try { File rootConfigFile = new File(""./worldConfig.json""); File dataConfigFile = new File(""./data/worldConfig.json""); if (rootConfigFile.exists()) SETTINGS = JsonFileManager.loadJsonFile(rootConfigFile, Settings.class); else if (dataConfigFile.exists()) SETTINGS = JsonFileManager.loadJsonFile(dataConfigFile, Settings.class); else SETTINGS = new Settings(); for (Field f : SETTINGS.getClass().getDeclaredFields()) if (f.get(SETTINGS) == null) f.set(SETTINGS, f.get(DEFAULTS)); JsonFileManager.saveJsonFile(SETTINGS, dataConfigFile); if (rootConfigFile.exists()) rootConfigFile.delete(); } catch (JsonIOException | IOException | IllegalArgumentException | IllegalAccessException e1) { e1.printStackTrace(); System.exit(5); } try { String line; ProcessBuilder builder = new ProcessBuilder(""git"", ""log"", ""-n"", ""1""); Process proc = builder.start(); BufferedReader in = new BufferedReader(new InputStreamReader(proc.getInputStream())); boolean markMsg = false; while ((line = in.readLine()) != null) { if (line.isEmpty()) continue; line = line.replace(""commit "", ""Hash: ""); if (markMsg) { line = ""Message: "" + line.trim(); markMsg = false; } if (line.contains(""Date: "")) markMsg = true; COMMIT_HISTORY.add(line); } proc.waitFor(); in.close(); Logger.info(Settings.class, ""loadConfig"", ""Commit history loaded: "" + COMMIT_HISTORY); } catch (JsonIOException | IOException | InterruptedException e) { Logger.handle(Settings.class, ""loadConfig"", e); } Globals.DEBUG = getConfig().debug; Logger.info(Settings.class, ""loadConfig"", ""Loaded lobby IP: "" + getConfig().lobbyIp); } public static void saveConfig() throws IOException { JsonFileManager.saveJsonFile(SETTINGS, new File(""./worldConfig.json"")); } public String getServerName() { return serverName; } public String getOwnerName() { return ownerName; } public boolean isDebug() { return debug; } public boolean isEnableJFR() { return enableJFR; } public boolean isAllowHighMemUseOptimizations() { return allowHighMemUseOptimizations; } public String getLoginMessage() { return loginMessage; } public void setLoginMessage(String loginMessage) { this.loginMessage = loginMessage; } public Tile getPlayerStartTile() { return Tile.of(playerStartTile != null ? playerStartTile : DEFAULTS.playerStartTile); } public Tile getPlayerRespawnTile() { return Tile.of(playerRespawnTile != null ? playerRespawnTile : DEFAULTS.playerRespawnTile); } public int getXpRate() { return xpRate; } public double getDropModifier() { return dropModifier; } public String getCachePath() { return cachePath != null ? cachePath : DEFAULTS.cachePath; } public static boolean isOwner(String string) { return string.equalsIgnoreCase(SETTINGS.getOwnerName()); } public Item[] getStartItems() { return startItems != null ? startItems : DEFAULTS.startItems; } public WorldInfo getWorldInfo() { return worldInfo != null ? worldInfo : DEFAULTS.worldInfo; } public String getLobbyIp() { return lobbyIp; } public String getLobbyApiKey() { return lobbyApiKey; } public String getMongoDBName() { return mongoDbName; } public String getMongoDb() { String db = ""mongodb://""; if (mongoUser != null && !mongoUser.isEmpty()) db += mongoUser + "":"" + new PercentEscaper("""", false).escape(mongoPass) + ""@""; db += mongoUrl; if (mongoPort > 0) db += "":"" + mongoPort; db += ""/""+mongoDbName+""?retryWrites=true&w=majority""; return db; } public String getStaffWebhookUrl() { return staffWebhookUrl; } public void setJFR(boolean b) { enableJFR = b; } }" "package com.rs.db; public class WorldDB extends DBConnection { private static final PlayerManager PLAYERS = new PlayerManager(); private static final HighscoresManager HIGHSCORES = new HighscoresManager(); private static final GEManager GE = new GEManager(); private static final LogManager LOGS = new LogManager(); public WorldDB() { super(Settings.getConfig().getMongoDb(), Settings.getConfig().getMongoDBName()); Logger.info(WorldDB.class, ""constructor()"", ""Connecting to MongoDB and initializing databases...""); addItemManager(PLAYERS); addItemManager(HIGHSCORES); addItemManager(GE); addItemManager(LOGS); } public static PlayerManager getPlayers() { return PLAYERS; } public static HighscoresManager getHighscores() { return HIGHSCORES; } public static GEManager getGE() { return GE; } public static LogManager getLogs() { return LOGS; } }" "package com.rs.db.collection; public class GEManager extends DBItemManager { public GEManager() { super(""grandexchange""); } @Override public void initCollection() { getDocs().createIndex(Indexes.text(""owner"")); getDocs().createIndex(Indexes.compoundIndex(Indexes.ascending(""itemId""), Indexes.ascending(""completedAmount""))); getDocs().createIndex(Indexes.compoundIndex(Indexes.ascending(""itemId""), Indexes.ascending(""state""))); getDocs().createIndex(Indexes.compoundIndex(Indexes.ascending(""itemId""), Indexes.ascending(""price""))); getDocs().createIndex(Indexes.compoundIndex(Indexes.ascending(""itemId""), Indexes.ascending(""selling""))); } public void get(String username, Consumer> func) { execute(() -> func.accept(getSync(username))); } public void save(Offer offer) { save(offer, null); } public void save(Offer offer, Runnable done) { execute(() -> { saveSync(offer); if (done != null) done.run(); }); } public void saveSync(Offer offers) { getDocs().findOneAndReplace(Filters.and(Filters.eq(""owner"", offers.getOwner()), Filters.eq(""box"", offers.getBox())), Document.parse(JsonFileManager.toJson(offers)), new FindOneAndReplaceOptions().upsert(true)); } public List getSync(String username) { FindIterable offerDocs = getDocs().find(Filters.eq(""owner"", username)); if (offerDocs == null) return null; try { List offers = new ArrayList<>(6); for (Document d : offerDocs) { Offer offer = JsonFileManager.fromJSONString(JsonFileManager.toJson(d), Offer.class); offers.add(offer); } return offers; } catch (JsonIOException | IOException e) { Logger.handle(GEManager.class, ""getSync"", e); return null; } } public void remove(String username, int box, Runnable done) { execute(() -> { removeSync(username, box); if (done != null) done.run(); }); } public void removeSync(String username, int box) { getDocs().findOneAndDelete(Filters.and(Filters.eq(""owner"", username), Filters.eq(""box"", box))); } public List getBestOffersSync(Offer other) { if (other.getState() == State.FINISHED) return null; List result = new ArrayList<>(); FindIterable docs = getDocs().find(Filters.and(Filters.eq(""state"", State.STABLE.toString()), Filters.eq(""itemId"", other.getItemId()), Filters.eq(""selling"", !other.isSelling()), other.isSelling() ? Filters.gte(""price"", other.getPrice()) : Filters.lte(""price"", other.getPrice()))).sort(Sorts.ascending(""price"")); for (Document doc : docs) try { Offer offer = JsonFileManager.fromJSONString(JsonFileManager.toJson(doc), Offer.class); result.add(offer); } catch (JsonIOException | IOException e) { Logger.handleNoRecord(GEManager.class, ""getBestOffersSync"", ""Error converting document: "" + result, e); } return result; } public void getBestOffer(int itemId, boolean sell, Consumer func) { execute(() -> { FindIterable docs = getDocs().find(Filters.and(Filters.eq(""state"", State.STABLE.toString()), Filters.eq(""itemId"", itemId), Filters.eq(""selling"", !sell))).sort(sell ? Sorts.ascending(""price"") : Sorts.descending(""price"")); try { func.accept(JsonFileManager.fromJSONString(JsonFileManager.toJson(docs.first()), Offer.class)); } catch (JsonIOException | IOException e) { func.accept(null); } }); } public void getAllOffersOfType(boolean selling, Consumer> func) { execute(() -> { List result = new ArrayList<>(); FindIterable docs = getDocs().find(Filters.and(Filters.eq(""state"", State.STABLE.toString()), Filters.eq(""selling"", selling))); for (Document doc : docs) try { Offer offer = JsonFileManager.fromJSONString(JsonFileManager.toJson(doc), Offer.class); result.add(offer); } catch (JsonIOException | IOException e) { Logger.handleNoRecord(GEManager.class, ""getAllOffersOfType"", ""Error converting document: "" + result, e); } func.accept(result); }); } }" "package com.rs.db.collection; public class HighscoresManager extends DBItemManager { public HighscoresManager() { super(""highscores""); } @Override public void initCollection() { getDocs().createIndex(Indexes.compoundIndex(Indexes.text(""displayName""), Indexes.text(""username""))); getDocs().createIndex(Indexes.descending(""totalLevel"", ""totalXp"")); } public void save(Player player) { save(player, null); } public void save(Player player, Runnable done) { execute(() -> { saveSync(player); if (done != null) done.run(); }); } public void saveSync(Player player) { if (player.hasRights(Rights.OWNER) || player.hasRights(Rights.DEVELOPER) || player.hasRights(Rights.ADMIN) || player.getSkills().getTotalXp() < 50000) return; try { getDocs().findOneAndReplace(eq(""username"", player.getUsername()), Document.parse(JsonFileManager.toJson(new Highscore(player))), new FindOneAndReplaceOptions().upsert(true)); } catch (Exception e) { Logger.handle(HighscoresManager.class, ""saveSync"", e); } } public void getPlayerAtPosition(int rank, Consumer top) { execute(() -> { try { top.accept(JsonFileManager.fromJSONString(getDocs().find().sort(Sorts.descending(""totalLevel"", ""totalXp"")).skip(rank).limit(1).first().toJson(), Highscore.class)); } catch(Throwable e) { top.accept(null); } }); } }" "package com.rs.db.collection; public class PlayerManager extends DBItemManager { public PlayerManager() { super(""players""); } @Override public void initCollection() { getDocs().createIndex(Indexes.text(""username"")); } public void getByUsername(String username, Consumer func) { execute(() -> func.accept(getSyncUsername(username))); } public void save(Player player) { save(player, null); } public void save(Player account, Runnable done) { execute(() -> { saveSync(account); if (done != null) done.run(); }); } public void saveSync(Player account) { try { getDocs().findOneAndReplace(eq(""username"", account.getUsername()), Document.parse(JsonFileManager.toJson(account)), new FindOneAndReplaceOptions().upsert(true)); } catch(Throwable e) { Logger.handle(PlayerManager.class, ""saveSync"", ""Error saving player: "" + account.getUsername(), e); } } public Player getSyncUsername(String username) { Player loggedIn = World.getPlayerByUsername(username); if (loggedIn != null) return loggedIn; Document accDoc = getDocs().find(eq(""username"", username)).first(); if (accDoc == null) return null; try { return JsonFileManager.fromJSONString(JsonFileManager.toJson(accDoc), Player.class); } catch (JsonIOException | IOException e) { Logger.handle(PlayerManager.class, ""getSyncUsername"", e); return null; } } public boolean usernameExists(String username) { return getSyncUsername(username) == null; } }" "package com.rs.db.collection.logs; public class CommandLog { private final String uuid; private final String player; private final String command; public CommandLog(String player, String command) { this.player = player; this.command = command; this.uuid = UUID.randomUUID().toString(); } @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; CommandLog that = (CommandLog) o; return Objects.equals(uuid, that.uuid) && Objects.equals(player, that.player) && Objects.equals(command, that.command); } @Override public int hashCode() { return Objects.hash(uuid, player, command); } }" "package com.rs.db.collection.logs; public class GELog { private final String uuid; private final String from; private final String to; private final String item; private final int itemId; private final int amount; private final int price; public GELog(Offer offer1, Offer offer2, int amount, int price) { Offer sellOffer = offer1.getOfferType() == GE.OfferType.SELL ? offer1 : offer2; Offer buyOffer = offer2.getOfferType() == GE.OfferType.BUY ? offer2 : offer1; to = buyOffer.getOwner(); item = ItemDefinitions.getDefs(sellOffer.getItemId()).name; itemId = sellOffer.getItemId(); this.amount = amount; this.price = price; this.uuid = UUID.randomUUID().toString(); } @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; GELog geLog = (GELog) o; return itemId == geLog.itemId && amount == geLog.amount && price == geLog.price && Objects.equals(uuid, geLog.uuid) && Objects.equals(from, geLog.from) && Objects.equals(to, geLog.to) && Objects.equals(item, geLog.item); } @Override public int hashCode() { return Objects.hash(from, to, item, itemId, amount, price, uuid); } }" "package com.rs.db.collection.logs; public class GraveLog { private final String uuid; private final String player; private final Tile tile; private final List items; public GraveLog(String player, GraveStone grave) { this.player = player; this.tile = grave.getTile(); items = new ArrayList<>(); for (GroundItem item : grave.getItems()) if (item != null) items.add(new Item(item)); this.uuid = UUID.randomUUID().toString(); } @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; GraveLog graveLog = (GraveLog) o; return Objects.equals(uuid, graveLog.uuid) && Objects.equals(player, graveLog.player) && Objects.equals(tile, graveLog.tile) && Objects.equals(items, graveLog.items); } @Override public int hashCode() { return Objects.hash(uuid, player, tile, items); } }" "package com.rs.db.collection.logs; public class LogEntry { public enum LogType { ERROR, GE, PICKUP, GRAVE, COMMAND, REPORT, TRADE } private final Date date; private final LogType type; private final long hash; private final Object data; public LogEntry(LogType type, long hash, Object data) { this.date = new Date(); this.type = type; this.hash = hash; this.data = data; } public Date getDate() { return date; } public LogType getType() { return type; } public long getHash() { return hash; } public Object getData() { return data; } }" "package com.rs.db.collection.logs; public class LogManager extends DBItemManager { public LogManager() { super(""logs""); } @Override public void initCollection() { getDocs().createIndex(Indexes.text(""type"")); getDocs().createIndex(Indexes.descending(""hash"")); getDocs().createIndex(Indexes.ascending(""date""), new IndexOptions().expireAfter(180L, TimeUnit.DAYS)); } public void save(LogEntry entry) { save(entry, null); } public void save(LogEntry entry, Runnable done) { execute(() -> { saveSync(entry); if (done != null) done.run(); }); } public void saveSync(LogEntry entry) { try { getDocs().findOneAndReplace(eq(""hash"", entry.getHash()), Document.parse(JsonFileManager.toJson(entry)), new FindOneAndReplaceOptions().upsert(true)); } catch(Throwable e) { e.printStackTrace(); } } public void logGE(Offer offer, Offer other, int num, int price) { GELog log = new GELog(offer, other, num, price); save(new LogEntry(LogEntry.LogType.GE, log.hashCode(), log)); } public void logTrade(Player player1, Trade p1Trade, Player p2, Trade p2Trade) { List p1Items = new ArrayList<>(); List p2Items = new ArrayList<>(); for (Item item : p1Trade.getItems().array()) if (item != null) p1Items.add(item); for (Item item : p2Trade.getItems().array()) if (item != null) p2Items.add(item); if (p1Items.size() > 0 || p2Items.size() > 0) { TradeLog log = new TradeLog(player1, p1Items, p2, p2Items); save(new LogEntry(LogEntry.LogType.TRADE, log.hashCode(), log)); } } public void logPickup(Player player, GroundItem item) { PickupLog log = new PickupLog(player, item); save(new LogEntry(LogEntry.LogType.PICKUP, log.hashCode(), log)); } public void logGrave(String player, GraveStone grave) { GraveLog log = new GraveLog(player, grave); save(new LogEntry(LogEntry.LogType.GRAVE, log.hashCode(), log)); } public void logReport(Player reporter, Player reported, ReportsManager.Rule rule) { if (reporter == null || reported == null) return; ReportLog log = new ReportLog(reporter, reported, rule); save(new LogEntry(LogEntry.LogType.REPORT, log.hashCode(), log)); } public void logCommand(String username, String commandStr) { CommandLog log = new CommandLog(username, commandStr); save(new LogEntry(LogEntry.LogType.COMMAND, log.hashCode(), log)); } }" "package com.rs.db.collection.logs; public class PickupLog { private final String uuid; private final String player; private final String itemName; private final Item item; private final Tile tile; private final String owner; public PickupLog(Player player, GroundItem item) { this.player = player.getUsername(); this.tile = item.getTile(); this.item = new Item(item); this.itemName = item.getName(); this.owner = item.getCreatorUsername(); this.uuid = UUID.randomUUID().toString(); } @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; PickupLog pickupLog = (PickupLog) o; return Objects.equals(uuid, pickupLog.uuid) && Objects.equals(player, pickupLog.player) && Objects.equals(itemName, pickupLog.itemName) && Objects.equals(item, pickupLog.item) && Objects.equals(tile, pickupLog.tile) && Objects.equals(owner, pickupLog.owner); } @Override public int hashCode() { return Objects.hash(uuid, player, itemName, item, tile, owner); } }" "package com.rs.db.collection.logs; public class ReportLog { private Object relevantData; public ReportLog(Player reporter, Player reported, Rule rule) { String player = reported.getUsername(); String reporter1 = reporter.getUsername(); } //TODO finish //TODO create hashCode and equals }" "package com.rs.db.collection.logs; public class TradeLog { private final String uuid; private final String player1; private final List p1Items; private final String player2; private final List p2Items; public TradeLog(Player p1, List p1Items, Player p2, List p2Items) { this.player1 = p1.getUsername(); this.p1Items = p1Items; this.player2 = p2.getUsername(); this.p2Items = p2Items; this.uuid = UUID.randomUUID().toString(); } @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; TradeLog tradeLog = (TradeLog) o; return Objects.equals(uuid, tradeLog.uuid) && Objects.equals(player1, tradeLog.player1) && Objects.equals(p1Items, tradeLog.p1Items) && Objects.equals(player2, tradeLog.player2) && Objects.equals(p2Items, tradeLog.p2Items); } @Override public int hashCode() { int result = Objects.hash(uuid, player1, player2, p1Items, p2Items); return result; } }" "package com.rs.db.model; public class Highscore { private final String username; private final String displayName; private final boolean ironman; private final int totalLevel; private final long totalXp; private final int[] xp; public Highscore(Player player) { if (player.getDisplayName() == null) throw new RuntimeException(""No display name found for player: "" + player.getUsername()); username = player.getUsername(); displayName = player.getDisplayName(); ironman = player.isIronMan(); totalLevel = player.getSkills().getTotalLevel(); totalXp = player.getSkills().getTotalXp(); xp = player.getSkills().getXpInt(); } public boolean isIronman() { return ironman; } public int getTotalLevel() { return totalLevel; } public long getTotalXp() { return totalXp; } public int[] getXp() { return xp; } public String getUsername() { return username; } public String getDisplayName() { return displayName; } }" "package com.rs.engine; @PluginEventHandler public class Shop { private static final int MAIN_STOCK_ITEMS_KEY = 0; private static final int MAX_SHOP_ITEMS = 40; private String name; private ShopItem[] mainStock; private int[] defaultQuantity; private ShopItem[] generalStock; private boolean buyOnly; private int currency; private final transient CopyOnWriteArrayList viewingPlayers; public Shop(String name, int money, ShopItem[] shopItems, boolean isGeneralStore, boolean buyOnly) { viewingPlayers = new CopyOnWriteArrayList<>(); this.name = name; currency = money; mainStock = shopItems; defaultQuantity = new int[shopItems.length]; for (int i = 0; i < defaultQuantity.length; i++) defaultQuantity[i] = shopItems[i].getItem().getAmount(); if (isGeneralStore && shopItems.length < MAX_SHOP_ITEMS) generalStock = new ShopItem[MAX_SHOP_ITEMS - shopItems.length]; this.buyOnly = buyOnly; for (ShopItem item : mainStock) { if (item == null) continue; item.init(); } } public static ButtonClickHandler handleInterfaces = new ButtonClickHandler(new Object[] { 449, 1265, 1266, 621 }, e -> { if (e.getInterfaceId() == 449) { if (e.getComponentId() == 1) { Shop shop = e.getPlayer().getTempAttribs().getO(""Shop""); if (shop == null) return; shop.sendInventory(e.getPlayer()); } else if (e.getComponentId() == 21) { Shop shop = e.getPlayer().getTempAttribs().getO(""Shop""); if (shop == null) return; int slot = e.getPlayer().getTempAttribs().getI(""ShopSelectedSlot""); if (slot == -1) return; if (e.getPacket() == ClientPacket.IF_OP1) shop.buy(e.getPlayer(), slot, 1); else if (e.getPacket() == ClientPacket.IF_OP2) shop.buy(e.getPlayer(), slot, 5); else if (e.getPacket() == ClientPacket.IF_OP3) shop.buy(e.getPlayer(), slot, 10); else if (e.getPacket() == ClientPacket.IF_OP4) shop.buy(e.getPlayer(), slot, 50); shop.sendCustomPrices(e.getPlayer()); } } else if (e.getInterfaceId() == 1265) { Shop shop = e.getPlayer().getTempAttribs().getO(""Shop""); if (shop == null) return; int slot = e.getPlayer().getTempAttribs().getI(""ShopSelectedSlot""); boolean isBuying = e.getPlayer().getTempAttribs().getB(""shop_buying""); if (e.getComponentId() == 20) { e.getPlayer().getTempAttribs().setI(""ShopSelectedSlot"", e.getSlotId()); if (e.getPacket() == ClientPacket.IF_OP1) shop.sendInfo(e.getPlayer(), e.getSlotId(), isBuying); else if (e.getPacket() == ClientPacket.IF_OP2) shop.handleShop(e.getPlayer(), e.getSlotId(), 1); else if (e.getPacket() == ClientPacket.IF_OP3) shop.handleShop(e.getPlayer(), e.getSlotId(), 5); else if (e.getPacket() == ClientPacket.IF_OP4) shop.handleShop(e.getPlayer(), e.getSlotId(), 10); else if (e.getPacket() == ClientPacket.IF_OP5) shop.handleShop(e.getPlayer(), e.getSlotId(), 50); else if (e.getPacket() == ClientPacket.IF_OP6) shop.handleShop(e.getPlayer(), e.getSlotId(), 500); else if (e.getPacket() == ClientPacket.IF_OP7) e.getPlayer().sendOptionDialogue(""Really buy out the shop? This could be absurdly expensive."", ops -> { ops.add(""Yes, I am sure."", () -> shop.handleShop(e.getPlayer(), e.getSlotId(), Integer.MAX_VALUE)); ops.add(""Nevermind.""); }); else if (e.getPacket() == ClientPacket.IF_OP10) shop.sendExamine(e.getPlayer(), e.getSlotId()); } else if (e.getComponentId() == 201) { if (slot == -1) return; if (isBuying) shop.buy(e.getPlayer(), slot, e.getPlayer().getTempAttribs().getI(""shopAmt"", 0)); else { shop.sell(e.getPlayer(), slot, e.getPlayer().getTempAttribs().getI(""shopAmt"", 0)); e.getPlayer().getVars().setVar(2563, 0); e.getPlayer().getVars().setVar(2565, 1); // this is to update the tab. } } else if (e.getComponentId() == 208) { e.getPlayer().getTempAttribs().setI(""shopAmt"", Utils.clampI(e.getPlayer().getTempAttribs().getI(""shopAmt"", 0) + 5, 1, 5000)); e.getPlayer().getPackets().setIFText(1265, 67, String.valueOf(e.getPlayer().getTempAttribs().getI(""shopAmt"", 0))); } else if (e.getComponentId() == 15) { e.getPlayer().getTempAttribs().setI(""shopAmt"", Utils.clampI(e.getPlayer().getTempAttribs().getI(""shopAmt"", 0) + 1, 1, 5000)); e.getPlayer().getPackets().setIFText(1265, 67, String.valueOf(e.getPlayer().getTempAttribs().getI(""shopAmt"", 0))); } else if (e.getComponentId() == 214) { e.getPlayer().getTempAttribs().setI(""shopAmt"", Utils.clampI(e.getPlayer().getTempAttribs().getI(""shopAmt"", 0) - 1, 1, 5000)); e.getPlayer().getPackets().setIFText(1265, 67, String.valueOf(e.getPlayer().getTempAttribs().getI(""shopAmt"", 0))); } else if (e.getComponentId() == 217) { e.getPlayer().getTempAttribs().setI(""shopAmt"", Utils.clampI(e.getPlayer().getTempAttribs().getI(""shopAmt"", 0) - 5, 1, 5000)); e.getPlayer().getPackets().setIFText(1265, 67, String.valueOf(e.getPlayer().getTempAttribs().getI(""shopAmt"", 0))); } else if (e.getComponentId() == 220) { e.getPlayer().getTempAttribs().setI(""shopAmt"", 1); e.getPlayer().getPackets().setIFText(1265, 67, String.valueOf(e.getPlayer().getTempAttribs().getI(""shopAmt"", 0))); } else if (e.getComponentId() == 211) { if ((slot == -1) || (shop.getMainStock() == null) || (slot > shop.getMainStock().length - 1) || (shop.getMainStock()[slot] == null)) return; if (e.getPlayer().getInventory().getItems().array()[slot] == null) return; e.getPlayer().getTempAttribs().setI(""shopAmt"", Utils.clampI(isBuying ? shop.getMainStock()[slot].getItem().getAmount() : e.getPlayer().getInventory().getItems().array()[slot].getAmount(), 1, 5000)); e.getPlayer().getPackets().setIFText(1265, 67, String.valueOf(e.getPlayer().getTempAttribs().getI(""shopAmt"", 0))); } else if (e.getComponentId() == 29) { e.getPlayer().getVars().setVar(2561, 93); e.getPlayer().getTempAttribs().removeB(""shop_buying""); e.getPlayer().getTempAttribs().setI(""shopAmt"", 1); } else if (e.getComponentId() == 28) { e.getPlayer().getTempAttribs().setB(""shop_buying"", true); e.getPlayer().getTempAttribs().setI(""shopAmt"", 1); e.getPlayer().getPackets().setIFText(1265, 67, String.valueOf(e.getPlayer().getTempAttribs().getI(""shopAmt"", 0))); } shop.sendCustomPrices(e.getPlayer()); } else if (e.getInterfaceId() == 1266) { if (e.getComponentId() == 0) if (e.getPacket() == ClientPacket.IF_OP6) e.getPlayer().getInventory().sendExamine(e.getSlotId()); else { Shop shop = e.getPlayer().getTempAttribs().getO(""Shop""); if (shop == null) return; e.getPlayer().getVars().setVar(2563, e.getSlotId()); if (e.getPacket() == ClientPacket.IF_OP1) shop.sendValue(e.getPlayer(), e.getSlotId()); else if (e.getPacket() == ClientPacket.IF_OP2) shop.sell(e.getPlayer(), e.getSlotId(), 1); else if (e.getPacket() == ClientPacket.IF_OP3) shop.sell(e.getPlayer(), e.getSlotId(), 5); else if (e.getPacket() == ClientPacket.IF_OP4) shop.sell(e.getPlayer(), e.getSlotId(), 10); else if (e.getPacket() == ClientPacket.IF_OP5) shop.sell(e.getPlayer(), e.getSlotId(), 50); } } else if (e.getInterfaceId() == 621) if (e.getComponentId() == 0) if (e.getPacket() == ClientPacket.IF_OP6) e.getPlayer().getInventory().sendExamine(e.getSlotId()); else { Shop shop = e.getPlayer().getTempAttribs().getO(""Shop""); if (shop == null) return; if (e.getPacket() == ClientPacket.IF_OP1) shop.sendValue(e.getPlayer(), e.getSlotId()); else if (e.getPacket() == ClientPacket.IF_OP2) shop.sell(e.getPlayer(), e.getSlotId(), 1); else if (e.getPacket() == ClientPacket.IF_OP3) shop.sell(e.getPlayer(), e.getSlotId(), 5); else if (e.getPacket() == ClientPacket.IF_OP4) shop.sell(e.getPlayer(), e.getSlotId(), 10); else if (e.getPacket() == ClientPacket.IF_OP5) shop.sell(e.getPlayer(), e.getSlotId(), 50); } }); public boolean isGeneralStore() { return generalStock != null; } public void addPlayer(final Player player) { viewingPlayers.add(player); player.getTempAttribs().setO(""Shop"", this); player.setCloseInterfacesEvent(() -> { viewingPlayers.remove(player); player.getTempAttribs().removeO(""Shop""); }); player.getVars().setVar(118, MAIN_STOCK_ITEMS_KEY); player.getVars().setVar(1496, -1); player.getVars().setVar(532, currency); player.getVars().setVar(2561, -1); player.getVars().setVar(2562, -1); player.getVars().setVar(2563, -1); //player.getVars().setVar(2565, 1); //changes to sell tab player.getVars().syncVarsToClient(); sendStore(player); player.getInterfaceManager().sendInterface(1265); player.getPackets().sendVarc(1876, -1); player.getPackets().setIFEvents(new IFEvents(1265, 20, 0, getStoreSize() * 6).enableRightClickOptions(0,1,2,3,4,5,9)); player.getPackets().setIFEvents(new IFEvents(1265, 26, 0, getStoreSize() * 6) .enableUseOptions(UseFlag.ICOMPONENT) .enableRightClickOptions(0,2,3) .setDepth(4) .enableDrag() .enableDepthFlagIgnoring() .enableUseTargetability()); player.getPackets().setIFText(1265, 85, name); if (isGeneralStore()) player.getPackets().setIFHidden(1265, 52, false); sendInventory(player); player.getTempAttribs().setB(""shop_buying"", true); WorldTasks.delay(1, () -> sendCustomPrices(player)); } public void sendCustomPrices(Player player) { if (!player.getTempAttribs().getB(""shop_buying"")) return; for (int i = 0;i < mainStock.length;i++) { if (mainStock[i] == null) continue; //player.getPackets().setIFSprite(1265, 24, i, 592); if (mainStock[i].getCustomPrice() > 0) player.getPackets().setIFText(1265, 23, i, Utils.kmify(mainStock[i].getCustomPrice())); } } public void sendInventory(Player player) { player.getInterfaceManager().sendInventoryInterface(1266); player.getPackets().sendItems(93, player.getInventory().getItems()); player.getPackets().setIFRightClickOps(1266, 0, 0, 27, 0, 1, 2, 3, 4, 5); player.getPackets().sendInterSetItemsOptionsScript(1266, 0, 93, 4, 7, ""Value"", ""Sell 1"", ""Sell 5"", ""Sell 10"", ""Sell 50"", ""Examine""); } // cid 67 public void buy(Player player, int slotId, int quantity) { if (slotId >= mainStock.length && player.isIronMan()) { player.sendMessage(""You can't buy something another player has sold as an ironman!""); return; } if (slotId >= getStoreSize()) return; ShopItem item = slotId >= mainStock.length ? generalStock[slotId - mainStock.length] : mainStock[slotId]; if (item == null) return; if (item.getItem().getAmount() == 0) { player.sendMessage(""There is no stock of that item at the moment.""); return; } int price = getBuyPrice(item); int amountCoins = currency == 995 ? player.getInventory().getCoinsAsInt() : player.getInventory().getItems().getNumberOf(currency); int maxQuantity = amountCoins / price; int buyQ = Math.min(item.getItem().getAmount(), quantity); boolean enoughCoins = maxQuantity >= buyQ; if (!enoughCoins) { player.sendMessage(""You don't have enough "" + ItemDefinitions.getDefs(currency).name.toLowerCase() + "".""); buyQ = maxQuantity; } else if (quantity > buyQ) player.sendMessage(""The shop has run out of stock.""); if (item.getItem().getDefinitions().isStackable()) { if (player.getInventory().getFreeSlots() < 1) { player.sendMessage(""Not enough space in your inventory.""); return; } } else { int freeSlots = player.getInventory().getFreeSlots(); if (buyQ > freeSlots) { buyQ = freeSlots; player.sendMessage(""Not enough space in your inventory.""); } } if (buyQ != 0) { int totalPrice = price * buyQ; if (currency == 995) player.getInventory().removeCoins(totalPrice); else player.getInventory().deleteItem(currency, totalPrice); if (item.getItem().getId() == 36 && buyQ == 5) player.getInventory().addItem(24170, 1); else player.getInventory().addItem(item.getItem().getId(), buyQ); item.getItem().setAmount(item.getItem().getAmount() - buyQ); if (item.getItem().getAmount() <= 0 && slotId >= mainStock.length) generalStock[slotId - mainStock.length] = null; refreshShop(); sendInventory(player); } } public void restoreItems() { boolean needRefresh = false; for (ShopItem element : mainStock) { if (element == null) continue; if (element.tickRestock()) needRefresh = true; } if (generalStock != null) for (int i = 0; i < generalStock.length; i++) { if (generalStock[i] == null) continue; if (generalStock[i].tickRestock()) needRefresh = true; if (generalStock[i].getItem().getAmount() <= 0) generalStock[i] = null; } if (needRefresh) { refreshShop(); for (Player player : viewingPlayers) WorldTasks.delay(0, () -> sendCustomPrices(player)); } } private boolean addItem(int itemId, int quantity) { for (ShopItem item : mainStock) if (item.getItem().getId() == itemId) { item.getItem().setAmount(item.getItem().getAmount() + quantity); refreshShop(); return true; } if (generalStock != null) { for (ShopItem item : generalStock) { if (item == null) continue; if (item.getItem().getId() == itemId) { item.getItem().setAmount(item.getItem().getAmount() + quantity); refreshShop(); return true; } } for (int i = 0; i < generalStock.length; i++) if (generalStock[i] == null) { generalStock[i] = new ShopItem(itemId, quantity); generalStock[i].setCap(-1); refreshShop(); return true; } } return false; } public void sell(Player player, int slotId, int quantity) { if (buyOnly) { player.sendMessage(""You cannot sell items to this shop.""); return; } if (player.getInventory().getItemsContainerSize() < slotId) return; Item item = player.getInventory().getItem(slotId); if (item == null) return; int originalId = item.getId(); if (item.getDefinitions().isNoted()) item = new Item(item.getDefinitions().getCertId(), item.getAmount()); if (item.getDefinitions().isDestroyItem() || !ItemConstants.isTradeable(item) || item.getId() == currency) { player.sendMessage(""You can't sell this item.""); return; } int dq = getDefaultQuantity(item.getId()); if (dq == -1 && generalStock == null) { player.sendMessage(""You can't sell this item to this shop.""); return; } int numberOff = player.getInventory().getItems().getNumberOf(originalId); if (quantity > numberOff) quantity = numberOff; if (!addItem(item.getId(), quantity)) { player.sendMessage(""Shop is currently full.""); return; } if ((player.getInventory().getNumberOf(currency) + (getSellPrice(item)*quantity)) < 0 || (player.getInventory().getNumberOf(currency)+(getSellPrice(item)*quantity)) > Integer.MAX_VALUE) player.sendMessage(""Looks like we need an eco reset..""); else { player.getInventory().deleteItem(originalId, quantity); if (currency == 995) player.getInventory().addCoins(getSellPrice(item) * quantity); else player.getInventory().addItem(currency, getSellPrice(item) * quantity); } } public void sendValue(Player player, int slotId) { if (player.getInventory().getItemsContainerSize() < slotId) return; Item item = player.getInventory().getItem(slotId); if (item == null) return; if (item.getDefinitions().isNoted()) item = new Item(item.getDefinitions().getCertId(), item.getAmount()); if (item.getDefinitions().isNoted() || !ItemConstants.isTradeable(item) || item.getId() == currency) { player.sendMessage(""You can't sell this item.""); return; } int dq = getDefaultQuantity(item.getId()); if (dq == -1 && generalStock == null) { player.sendMessage(""You can't sell this item to this shop.""); return; } player.sendMessage(item.getDefinitions().getName() + "": shop will buy for: "" + getSellPrice(item) + "" "" + ItemDefinitions.getDefs(currency).getName().toLowerCase() + "". Right-click the item to sell.""); } public int getDefaultQuantity(int itemId) { for (int i = 0; i < mainStock.length; i++) if (mainStock[i].getItem().getId() == itemId) return defaultQuantity[i]; return -1; } public void sendInfo(Player player, int slotId, boolean isBuying) { if (slotId >= getStoreSize()) return; if (isBuying) { ShopItem item = slotId >= mainStock.length ? generalStock[slotId - mainStock.length] : mainStock[slotId]; if (item == null) return; int price = getBuyPrice(item); player.sendMessage(item.getItem().getDefinitions().getName() + "": shop will "" + (isBuying ? ""sell"" : ""buy"") + "" for "" + price + "" "" + ItemDefinitions.getDefs(currency).getName().toLowerCase() + "".""); } else { Item[] stock = player.getInventory().getItems().array(); if (slotId >= stock.length) return; Item item = stock[slotId]; if (item == null) return; int price = getSellPrice(item); player.sendMessage(item.getDefinitions().getName() + "": shop will "" + (isBuying ? ""sell"" : ""buy"") + "" for "" + price + "" "" + ItemDefinitions.getDefs(currency).getName().toLowerCase() + "".""); } } public int getSellPrice(Item item) { int price = item.getDefinitions().getSellPrice(); if (price == 0) price = 1; if (currency == 6529) { EnumDefinitions defs = EnumDefinitions.getEnum(732); if (defs.getIntValue(item.getId()) != -1) return defs.getIntValue(item.getId()); } else if (currency == 995) { EnumDefinitions defs = EnumDefinitions.getEnum(1441); if (defs.getIntValue(item.getId()) != -1) return defs.getIntValue(item.getId()); } return price; } public int getBuyPrice(ShopItem item) { if (item.getCustomPrice() > 0) return item.getCustomPrice(); int price = item.getItem().getDefinitions().getValue(); if (price == 0) price = 1; if (currency == 6529) { EnumDefinitions defs = EnumDefinitions.getEnum(731); if (defs.getIntValue(item.getItem().getId()) != -1) return defs.getIntValue(item.getItem().getId()); return (int) (price * 3.0 / 2.0); } if (currency == 995) { EnumDefinitions defs = EnumDefinitions.getEnum(733); if (defs.getIntValue(item.getItem().getId()) != -1) return defs.getIntValue(item.getItem().getId()); } return price; } public void sendExamine(Player player, int slotId) { if (slotId >= getStoreSize()) return; ShopItem item = slotId >= mainStock.length ? generalStock[slotId - mainStock.length] : mainStock[slotId]; if (item == null) return; player.sendMessage(ItemConfig.get(item.getItem().getId()).getExamine(item.getItem())); } public void refreshShop() { for (Player player : viewingPlayers) { sendStore(player); player.getPackets().setIFEvents(new IFEvents(620, 25, 0, getStoreSize() * 6).enableRightClickOptions(0,1,2,3,4,5,9)); sendCustomPrices(player); } } public int getStoreSize() { return mainStock.length + (generalStock != null ? generalStock.length : 0); } public void sendStore(Player player) { Item[] stock = new Item[mainStock.length + (generalStock != null ? generalStock.length : 0)]; for (int i = 0;i < stock.length;i++) if (i >= mainStock.length) { ShopItem item = generalStock[i - mainStock.length]; if (item == null) continue; stock[i] = item.getItem(); } else { ShopItem item = mainStock[i]; if (item == null) continue; stock[i] = item.getItem(); } player.getPackets().sendItems(MAIN_STOCK_ITEMS_KEY, stock); } // public void sendSellStore(Player player, Item[] inventory) { // Item[] stock = new Item[inventory.length + (generalStock != null ? generalStock.length : 0)]; // System.arraycopy(inventory, 0, stock, 0, inventory.length); // if (generalStock != null) // System.arraycopy(generalStock, 0, stock, inventory.length, generalStock.length); // player.getPackets().sendItems(MAIN_STOCK_ITEMS_KEY, stock); // } /** * Checks if the player is buying an item or selling it. * * @param player * The player * @param slotId * The slot id * @param amount * The amount */ public void handleShop(Player player, int slotId, int amount) { if (player.getTempAttribs().getB(""shop_buying"")) buy(player, slotId, amount); else sell(player, slotId, amount); } public ShopItem[] getMainStock() { return mainStock; } public boolean isBuyOnly() { return buyOnly; } }" "package com.rs.engine.book; @PluginEventHandler public abstract class Book { private static final int INTERFACE = 960; private static final int[] LEFT_COMPONENTS = { 49, 56, 61, 62, 54, 63, 55, 51, 60, 58, 53, 50, 57, 59, 52 }; private static final int[] RIGHT_COMPONENTS = { 33, 39, 36, 44, 37, 46, 40, 42, 34, 35, 38, 43, 47, 45, 41 }; private Player player; private int page; private final String title; private final BookPage[] pages; public Book(String title, BookPage... pages) { this.title = title; this.pages = pages; } public Book(String title, String text) { this.title = title; this.pages = buildPages(text); } public static ButtonClickHandler handleInter = new ButtonClickHandler(INTERFACE, e -> { if (e.getPlayer().getTempAttribs().getO(""currBook"") == null) return; Book book = e.getPlayer().getTempAttribs().getO(""currBook""); if (e.getComponentId() == 72) book.prevPage(); if (e.getComponentId() == 73) book.nextPage(); }); public void open(Player player) { this.player = player; this.player.getTempAttribs().setO(""currBook"", this); this.player.setCloseInterfacesEvent(() -> this.player.getTempAttribs().removeO(""currBook"")); player.getPackets().setIFText(INTERFACE, 69, title); page = 0; update(); } public void update() { player.getInterfaceManager().sendInterface(INTERFACE); if (page == 0) { player.getPackets().setIFHidden(INTERFACE, 72, true); player.getPackets().setIFText(INTERFACE, 70, """"); } else { player.getPackets().setIFHidden(INTERFACE, 72, false); player.getPackets().setIFText(INTERFACE, 70, ""Prev""); } if (page >= pages.length-1) { player.getPackets().setIFHidden(INTERFACE, 73, true); player.getPackets().setIFText(INTERFACE, 71, """"); } else { player.getPackets().setIFHidden(INTERFACE, 73, false); player.getPackets().setIFText(INTERFACE, 71, ""Next""); } for (int line = 0;line < LEFT_COMPONENTS.length;line++) { player.getPackets().setIFText(INTERFACE, LEFT_COMPONENTS[line], pages[page].getLeftLine(line) == null ? """" : pages[page].getLeftLine(line)); player.getPackets().setIFText(INTERFACE, RIGHT_COMPONENTS[line], pages[page].getRightLine(line) == null ? """" : pages[page].getRightLine(line)); } } private BookPage[] buildPages(String text) { List pages = new ArrayList<>(); String[] lines = Utils.splitTextIntoLines(text, 497, IComponentDefinitions.getInterfaceComponent(INTERFACE, RIGHT_COMPONENTS[0]).baseWidth); int i = 0; while (i < lines.length) { String[] leftPageLines = new String[LEFT_COMPONENTS.length]; String[] rightPageLines = new String[RIGHT_COMPONENTS.length]; for (int j = 0; j < LEFT_COMPONENTS.length; j++) { if (i < lines.length) { leftPageLines[j] = lines[i]; i++; } else { break; } } for (int k = 0; k < RIGHT_COMPONENTS.length; k++) { if (i < lines.length) { rightPageLines[k] = lines[i]; i++; } else { break; } } pages.add(new BookPage(leftPageLines, rightPageLines)); } return pages.toArray(BookPage[]::new); } public void nextPage() { if (page >= pages.length-1) return; page++; update(); } public void prevPage() { if (page <= 0) return; page--; update(); } }" "package com.rs.engine.book; public class BookPage { private final String[] left; private final String[] right; public BookPage(String[] left, String[] right) { if (left.length > 15 || right.length > 15) throw new RuntimeException(""Cannot create book page with longer than 15 lines of text.""); this.left = left; this.right = right; } public String getLeftLine(int line) { return line >= left.length ? """" : left[line]; } public String getRightLine(int line) { return line >= right.length ? """" : right[line]; } }" "package com.rs.engine.command; public class Command { private final String usage; private final String description; private final CommandExecution execution; public Command(String usage, String description, CommandExecution execution) { this.description = description; this.execution = execution; this.usage = usage; } public void execute(Player player, String[] args) { execution.run(player, args); } public String getDescription() { return description; } public String getUsage() { return usage; } }" "package com.rs.engine.command; public interface CommandExecution { void run(Player p, String[] args); }" "package com.rs.engine.command; public final class Commands { private static final Map> COMMANDS = new HashMap<>(); private static final Map> UNIQUE_COMMANDS = new HashMap<>(); static { for (Rights r : Rights.values()) { COMMANDS.put(r, new HashMap<>()); UNIQUE_COMMANDS.put(r, new HashSet<>()); } } public static Set getCommands(Rights rights) { return UNIQUE_COMMANDS.get(rights); } public static void add(Rights rights, String usage, String description, CommandExecution execution) { String aliases = usage.contains("" "") ? usage.substring(0, usage.indexOf("" "")) : usage; Command command = new Command(usage, description, execution); UNIQUE_COMMANDS.get(rights).add(command); if (aliases.contains("","")) { String[] aliasesArr = aliases.split("",""); for (String alias : aliasesArr) COMMANDS.get(rights).put(alias, command); } else COMMANDS.get(rights).put(aliases, command); } public static boolean executeCommand(Rights rights, Player player, String name, String[] args) { Command command = COMMANDS.get(rights).get(name); if (command == null) return false; try { command.execute(player, args); } catch (Throwable e) { if (Settings.getConfig().isDebug()) e.printStackTrace(); player.sendMessage(""Error handling command. Proper usage is ::"" + command.getUsage()); } return true; } public static boolean processCommand(Player player, String commandStr, boolean console, boolean clientCommand) { if (commandStr.length() == 0) return false; String[] cmd = commandStr.split("" ""); if ((cmd.length == 0) || (cmd.length == 0)) return false; String[] args = new String[cmd.length - 1]; System.arraycopy(cmd, 1, args, 0, cmd.length - 1); for (int i = Rights.values().length-1;i >= 0;i--) { if (player.getRights().ordinal() < Rights.values()[i].ordinal()) continue; if (executeCommand(Rights.values()[i], player, cmd[0].toLowerCase(), args)) { if (Rights.values()[i] != Rights.PLAYER) WorldDB.getLogs().logCommand(player.getUsername(), commandStr); return true; } } return false; } @SuppressWarnings(""unused"") private static boolean REFACTOR_ALL_THESE_INTO_NEW_SYSTEM(final Player p, String[] casedCmd, String[] args, boolean console, boolean clientCommand) { switch (args[0]) { case ""cc"": p.getTreasureTrailsManager().openReward(Integer.valueOf(args[1])); return true; case ""companim"": if (Integer.valueOf(args[1]) > Utils.getNPCDefinitionsSize()) return true; NPCDefinitions defs = NPCDefinitions.getDefs(Integer.valueOf(args[1])); if (defs == null) return true; p.getPackets().sendDevConsoleMessage(Integer.valueOf(args[1]) + "": "" + defs.getCompatibleAnimations().toString()); p.sendMessage(Integer.valueOf(args[1]) + "": "" + defs.getCompatibleAnimations().toString()); Logger.debug(Commands.class, ""REFACTOR.compAnim"", defs.getCompatibleAnimations().toString()); return true; case ""trenttitle"": String title = ""The Boss""; p.setTitle(title); p.setTitleColor(null); p.setTitleShading(null); return true; case ""dailies"": p.processDailyTasks(); return true; case ""resethouse"": p.sendOptionDialogue(""Delete your house?"", ops -> { ops.add(""Yes"", () -> p.getHouse().reset()); ops.add(""No""); }); return true; case ""resettask"": p.getSlayer().removeTask(); p.updateSlayerTask(); return true; case ""snow"": for (int x = 0; x < 5; x++) for (int y = 0; y < 5; y++) World.spawnObject(new GameObject(3701, ObjectType.SCENERY_INTERACT, 1, p.getX() + (x * 10), p.getY() + (y * 10), 3)); for (int x = 0; x < 5; x++) for (int y = 0; y < 5; y++) World.spawnObject(new GameObject(3701, ObjectType.SCENERY_INTERACT, 1, p.getX() - (x * 10), p.getY() - (y * 10), 3)); for (int x = 0; x < 5; x++) for (int y = 0; y < 5; y++) World.spawnObject(new GameObject(3701, ObjectType.SCENERY_INTERACT, 1, p.getX() + (x * 10), p.getY() - (y * 10), 3)); for (int x = 0; x < 5; x++) for (int y = 0; y < 5; y++) World.spawnObject(new GameObject(3701, ObjectType.SCENERY_INTERACT, 1, p.getX() - (x * 10), p.getY() + (y * 10), 3)); return true; case ""glowme"": p.setNextBodyGlow(new BodyGlow(500, Integer.valueOf(args[1]), Integer.valueOf(args[2]), Integer.valueOf(args[3]), Integer.valueOf(args[4]))); return true; // case ""getaccs"": // ArrayList ips = Utils.getCharactersWithIP(args[1]); // p.getPackets().sendRunScriptReverse(1207, new Object[] { ips.size() }); // p.getInterfaceManager().sendInterface(275); // p.getPackets().setIFText(275, 1, ""Characters with IP: "" + args[1]); // int numa = 10; // for (String ip : ips) { // if (numa > 288) // break; // if (ip == null) // continue; // p.getPackets().setIFText(275, numa, ip); // numa++; // } // return true; case ""script"": p.getPackets().sendRunScript(Integer.valueOf(args[1])); return true; case ""kinship"": int sniper = 1; int berserker = 3; int tactician = 4; int tank = 5; int artisan = 0; int gatherer = 0; int medic = 0; int blitzer = 0; int blaster = 0; int blazer = 0; int desperado = 0; int keenEye = 0; p.getInterfaceManager().sendInterface(993); p.getVars().setVar(1776, (sniper << 28) + (berserker << 24) + (tactician << 20) + (tank << 16)); p.getVars().setVar(1851, (artisan << 28) + (gatherer << 24) + (medic << 20) + (blitzer << 16) + (blaster << 12) + (blazer << 8) + (desperado << 4) + keenEye); return true; case ""loadouts"": StringBuilder loadouts = new StringBuilder(); for (String keys : p.getSavingAttributes().keySet()) if (keys.contains(""loadoutinv"")) loadouts.append(keys.replace(""loadoutinv"", """")).append("", ""); p.sendMessage(loadouts.toString()); return true; case ""resetbrew"": p.getKeldagrimBrewery().reset(); p.getPhasmatysBrewery().reset(); return true; case ""ferment"": p.getKeldagrimBrewery().ferment(); p.getKeldagrimBrewery().updateVars(); p.getPhasmatysBrewery().ferment(); p.getPhasmatysBrewery().updateVars(); return true; case ""proj"": World.sendProjectile(Tile.of(p.getX() + 5, p.getY(), p.getPlane()), Tile.of(p.getX() - 5, p.getY(), p.getPlane()), Integer.valueOf(args[1]), 40, 40, 0, 0.2, 0, 0); return true; case ""house"": p.getHouse().enterMyHouse(); return true; case ""hintgame"": for (Player players : World.getPlayers()) players.getHintIconsManager().addHintIcon(p.getX(), p.getY(), 0, 0, 2, 0, -1, true); return true; case ""endhintgame"": for (Player players : World.getPlayers()) players.getHintIconsManager().removeAll(); return true; case ""dropitem"": World.addGroundItem(new Item(Integer.valueOf(args[1]), 1), Tile.of(p.getX(), p.getY(), p.getPlane())); return true; case ""trolldropitem"": for (Player players : World.getPlayers()) players.getPackets().sendGroundItem(new GroundItem(new Item(Integer.valueOf(args[1]), 1), Tile.of(p.getX(), p.getY(), p.getPlane()), players.getUsername(), GroundItemType.NORMAL)); return true; case ""deathnpcs"": if (Settings.isOwner(p.getUsername().toLowerCase())) for (NPC npc : World.getNPCs()) { if (npc instanceof Familiar || npc instanceof Pet) continue; if (Utils.getDistance(npc.getTile(), p.getTile()) < 9) npc.sendDeath(p); } return true; case ""cutscene"": p.getPackets().sendCutscene(Integer.parseInt(args[1])); return true; } return false; } public static void sendYell(Player player, String message, boolean staffYell) { if (player.getAccount().isMuted()) { player.sendMessage(""You are muted. The mute will be lifted at "" + player.getAccount().getUnmuteDate()); return; } if (staffYell) { World.sendWorldMessage(""[Staff Yell] "" + (player.hasRights(Rights.MOD) ? """" : """") + player.getDisplayName() + "": "" + message + ""."", true); return; } if (message.length() > 100) message = message.substring(0, 100); if (!player.hasRights(Rights.ADMIN)) { String[] invalid = { """", """" }; for (String s : invalid) if (message.contains(s)) { player.sendMessage(""You cannot add additional code to the message.""); return; } if (player.getRights() == Rights.MOD) World.sendWorldMessage(""[Moderator] "" + player.getDisplayName() + "": "" + message + """", false); else World.sendWorldMessage(""[Yell] "" + player.getDisplayName() + "": "" + message + """", false); return; } if (Settings.isOwner(player.getUsername().toLowerCase())) { World.sendWorldMessage(""[Owner/Developer] "" + player.getDisplayName() + "": "" + message + """", false); return; } World.sendWorldMessage(""[Admin] "" + player.getDisplayName() + "": "" + message + """", false); } }" "package com.rs.engine.cutscene; public abstract class Cutscene { private Player player; private int currIndex; private final Map objects = new HashMap<>(); private final List actions = new ArrayList<>(); private int delay; private boolean hideMap; private boolean dialoguePaused; private boolean constructingRegion; private Instance instance; private Tile endTile; public abstract void construct(Player player); public final void stopCutscene() { if (player.getX() != endTile.getX() || player.getY() != endTile.getY() || player.getPlane() != endTile.getPlane()) player.tele(endTile); if (hideMap) player.getPackets().setBlockMinimapState(0); restoreDefaultAspectRatio(); player.getPackets().sendResetCamera(); player.setLargeSceneView(false); player.resetReceivedHits(); player.getPoison().reset(); player.unlock(); deleteObjects(); if (instance != null) instance.destroy(); player.getTempAttribs().removeB(""CUTSCENE_INTERFACE_CLOSE_DISABLED""); } public final void startCutscene() { if (hideMap) player.getPackets().setBlockMinimapState(2); player.setLargeSceneView(true); player.lock(); player.stopAll(true, false); player.getTempAttribs().setB(""CUTSCENE_INTERFACE_CLOSE_DISABLED"", true); } public void constructArea(final Tile returnTile, final int baseChunkX, final int baseChunkY, final int widthChunks, final int heightChunks, final boolean copyNpcs) { constructingRegion = true; Instance old = instance; instance = Instance.of(returnTile, widthChunks, heightChunks, copyNpcs); instance.copyMapAllPlanes(baseChunkX, baseChunkY).thenAccept(e -> { instance.teleportTo(player); constructingRegion = false; if (old != null) old.destroy(); }); } public Player getPlayer() { return player; } public void setPlayer(Player player) { this.player = player; } public final void logout() { stopCutscene(); } public final boolean process() { if (dialoguePaused) return true; if (delay > 0) { delay--; return true; } while(true) { if (constructingRegion) return true; if (currIndex == actions.size()) { stopCutscene(); return false; } else if (currIndex == 0) startCutscene(); CutsceneAction action = actions.get(currIndex++); action.process(player, objects); int delay = action.getDelay(); if (delay == -1) continue; this.delay = delay; return true; } } public void deleteObjects() { for (Object object : objects.values()) deleteObject(object); } public void deleteObject(Object object) { if (object instanceof NPC n && !n.persistsBeyondCutscene()) n.finish(); } public final void createObjectMap() { endTile = Tile.of(player.getTile()); objects.put(""cutscene"", this); } public int getX(int x) { Instance instance = this.instance; if (instance == null) instance = player.getInstancedArea(); return instance != null && instance.isCreated() ? instance.getLocalX(x) : x; } public int getY(int y) { Instance instance = this.instance; if (instance == null) instance = player.getInstancedArea(); return instance != null && instance.isCreated() ? instance.getLocalY(y) : y; } public int getLocalX(int x) { return x > 0xFF ? (x - MapUtils.decode(Structure.CHUNK, player.getSceneBaseChunkId())[0] * 8) : x; } public int getLocalY(int y) { return y > 0xFF ? (y - MapUtils.decode(Structure.CHUNK, player.getSceneBaseChunkId())[1] * 8) : y; } public boolean isHideMap() { return hideMap; } public void hideMinimap() { hideMinimap(true); } public void hideMinimap(boolean hide) { this.hideMap = hide; } public void setEndTile(Tile tile) { this.endTile = tile; } public Tile getEndTile() { return endTile; } public void camPos(int x, int y, int height, int delay) { actions.add(new PosCameraAction(x, y, height, delay)); } public void camLook(int x, int y, int height, int delay) { actions.add(new LookCameraAction(x, y, height, delay)); } public void camPos(int x, int y, int height, int speed1, int speed2, int delay) { actions.add(new PosCameraAction(x, y, height, speed1, speed2, delay)); } public void camLook(int x, int y, int height, int speed1, int speed2, int delay) { actions.add(new LookCameraAction(x, y, height, speed1, speed2, delay)); } public void camPos(int x, int y, int height) { camPos(x, y, height, -1); } public void camLook(int x, int y, int height) { camLook(x, y, height, -1); } public void camPos(int x, int y, int height, int speed1, int speed2) { camPos(x, y, height, speed1, speed2, -1); } public void camLook(int x, int y, int height, int speed1, int speed2) { camLook(x, y, height, speed1, speed2, -1); } public void camShake(int slotId, int v1, int v2, int v3, int v4, int delay) { action(delay, () -> player.getPackets().sendCameraShake(slotId, v1, v2, v3, v4)); } public void camShake(int slotId, int v1, int v2, int v3, int v4) { camShake(slotId, v1, v2, v3, v4, -1); } public void camShakeReset(int delay) { action(delay, () -> player.getPackets().sendStopCameraShake()); } public void camShakeReset() { camShakeReset(-1); } public void camPosReset(int delay) { action(delay, () -> player.getPackets().sendResetCamera()); } public void camPosResetSoft(int delay) { action(delay, () -> player.getPackets().sendResetCameraSoft()); } public void camPosReset() { camPosReset(-1); } public void camPosResetSoft() { camPosResetSoft(-1); } public void dialogue(Dialogue dialogue, int delay) { actions.add(new DialogueAction(dialogue, delay, false)); } public void dialogue(Dialogue dialogue) { dialogue(dialogue, -1); } public void dialogue(Dialogue dialogue, boolean pause) { if (pause) dialogue.addNext(() -> dialoguePaused = false); actions.add(new DialogueAction(dialogue, pause ? 1 : -1, pause)); } public void dynamicRegion(Tile returnTile, int baseX, int baseY, int widthChunks, int heightChunks, boolean copyNpcs) { actions.add(new ConstructMapAction(returnTile, baseX, baseY, widthChunks, heightChunks, copyNpcs)); } public void dynamicRegion(Tile returnTile, int baseX, int baseY, int widthChunks, int heightChunks) { dynamicRegion(returnTile, baseX, baseY, widthChunks, heightChunks, false); } public void fadeIn(int delay) { action(delay, () -> player.getInterfaceManager().fadeIn()); } public void fadeOut(int delay) { action(delay, () -> player.getInterfaceManager().fadeOut()); } public void fadeOutQuickly(int delay) { action(delay, () -> player.getInterfaceManager().removeInterface(115)); } public void fadeInBG(int delay) { action(delay, () -> player.getInterfaceManager().fadeInBG()); } public void fadeOutBG(int delay) { action(delay, () -> player.getInterfaceManager().fadeOutBG()); } public void music(int id, int delay) { action(delay, () -> player.musicTrack(id, 5)); } public void music(int id) { music(id, -1); } public void musicEffect(int id, int delay) { actions.add(new PlayerMusicEffectAction(id, delay)); } public void musicEffect(int id) { musicEffect(id, -1); } public NPC getNPC(String key) { if (key == null) return null; if (objects.get(key) != null) return (NPC) objects.get(key); return null; } public void npcCreate(String key, int npcId, int x, int y, int z, int delay, Consumer configureNpc) { actions.add(new CreateNPCAction(key, npcId, x, y, z, delay, configureNpc)); } public void npcCreate(String key, int npcId, int x, int y, int z, int delay) { npcCreate(key, npcId, x, y, z, delay, null); } public void npcCreate(String key, int npcId, int x, int y, int z, Consumer configureNpc) { npcCreate(key, npcId, x, y, z, -1, configureNpc); } public void npcCreate(String key, int npcId, int x, int y, int z) { npcCreate(key, npcId, x, y, z, -1); } public void npcCreate(String key, int npcId, Tile tile, Consumer configureNpc) { npcCreate(key, npcId, tile.getX(), tile.getY(), tile.getPlane(), -1, configureNpc); } public void npcCreate(String key, int npcId, Tile tile) { npcCreate(key, npcId, tile.getX(), tile.getY(), tile.getPlane(), -1); } public void npcCreate(String key, int npcId, Tile tile, int delay, Consumer configureNpc) { npcCreate(key, npcId, tile.getX(), tile.getY(), tile.getPlane(), delay, configureNpc); } public void npcCreate(String key, int npcId, Tile tile, int delay) { npcCreate(key, npcId, tile.getX(), tile.getY(), tile.getPlane(), delay); } public void npcDestroy(String key, int delay) { actions.add(new DestroyCachedObjectAction(key, delay)); } public void npcDestroy(String key) { npcDestroy(key, -1); } public void npcFaceTile(String key, int x, int y, int delay) { actions.add(new NPCFaceTileAction(key, x, y, delay)); } public void npcFaceTile(String key, int x, int y) { npcFaceTile(key, x, y, -1); } public void npcFaceTile(String key, Tile tile) { npcFaceTile(key, tile, -1); } public void npcFaceTile(String key, Tile tile, int delay) { actions.add(new NPCFaceTileAction(key, tile.getX(), tile.getY(), delay)); } public void npcSpotAnim(String key, SpotAnim anim, int delay) { actions.add(new NPCSpotAnimAction(key, anim, delay)); } public void npcSpotAnim(String key, SpotAnim anim) { npcSpotAnim(key, anim, -1); } public void npcSpotAnim(String key, int anim) { npcSpotAnim(key, new SpotAnim(anim), -1); } public void npcSpotAnim(String key, int anim, int delay) { actions.add(new NPCSpotAnimAction(key, new SpotAnim(anim), delay)); } public void npcAnim(String key, Animation anim, int delay) { actions.add(new NPCAnimationAction(key, anim, delay)); } public void npcSync(String key, int anim, int spotAnim, int delay) { actions.add(new NPCAnimationAction(key, new Animation(anim), -1)); actions.add(new NPCSpotAnimAction(key, new SpotAnim(spotAnim), delay)); } public void npcSync(String key, int anim, int spotAnim) { npcSync(key, anim, spotAnim, -1); } public void npcAnim(String key, Animation anim) { npcAnim(key, anim, -1); } public void npcAnim(String key, int id) { npcAnim(key, new Animation(id)); } public void npcAnim(String key, int id, int delay) { npcAnim(key, new Animation(id), delay); } public void npcTransform(String key, int id, int delay) { actions.add(new NPCTransformAction(key, id, delay)); } public void npcTransform(String key, int id) { npcTransform(key, id, 0); } public void npcTalk(String key, String message, int delay) { actions.add(new NPCForceTalkAction(key, message, delay)); } public void npcTalk(String key, String message) { npcTalk(key, message, -1); } public void npcMove(String key, int x, int y, int z, MoveType type, int delay) { actions.add(new MoveNPCAction(key, x, y, z, type, delay)); } public void npcMove(String key, int x, int y, int z, MoveType type) { npcMove(key, x, y, z, type, -1); } public void npcMove(String key, int x, int y, MoveType type, int delay) { npcMove(key, x, y, player.getPlane(), type, delay); } public void npcMove(String key, int x, int y, MoveType type) { npcMove(key, x, y, player.getPlane(), type, -1); } public void npcMove(String key, Tile tile, MoveType type) { npcMove(key, tile.getX(), tile.getY(), player.getPlane(), type, -1); } public void npcMove(String key, Tile tile, MoveType type, int delay) { npcMove(key, tile.getX(), tile.getY(), player.getPlane(), type, delay); } public void npcWalk(String key, int x, int y, int delay) { npcMove(key, x, y, player.getPlane(), MoveType.WALK, delay); } public void npcWalk(String key, int x, int y) { npcMove(key, x, y, player.getPlane(), MoveType.WALK, -1); } public void playerMove(int x, int y, int z, MoveType type, int delay) { actions.add(new MovePlayerAction(x, y, z, type, delay)); } public void playerMove(int x, int y, int z, MoveType type) { playerMove(x, y, z, type, -1); } public void playerMove(int x, int y, MoveType type, int delay) { playerMove(x, y, player.getPlane(), type, delay); } public void playerMove(int x, int y, MoveType type) { playerMove(x, y, player.getPlane(), type, -1); } public void playerMove(Tile tile, MoveType type) { playerMove(tile.getX(), tile.getY(), tile.getPlane(), type, -1); } public void playerMove(Tile tile, MoveType type, int delay) { playerMove(tile.getX(), tile.getY(), tile.getPlane(), type, delay); } public void playerFaceTile(int x, int y, int delay) { actions.add(new PlayerFaceTileAction(x, y, delay)); } public void playerFaceTile(int x, int y) { playerFaceTile(x, y, -1); } public void playerAnim(Animation anim, int delay) { actions.add(new PlayerAnimationAction(anim, delay)); } public void playerAnim(Animation anim) { playerAnim(anim, -1); } public void playerSpotAnim(SpotAnim anim, int delay) { actions.add(new PlayerGraphicAction(anim, delay)); } public void playerSpotAnim(SpotAnim anim) { playerSpotAnim(anim, -1); } public void playerTalk(String message, int delay) { actions.add(new PlayerForceTalkAction(message, delay)); } public void playerTalk(String message) { playerTalk(message, -1); } public void playerFaceEntity(String key, int delay) { actions.add(new PlayerFaceEntityAction(key, delay)); } public void playerFaceEntity(String key) { playerFaceEntity(key, -1); } public void action(int delay, Runnable runnable) { actions.add(new CutsceneCodeAction(runnable, delay)); } public void action(Runnable runnable) { action(-1, runnable); } public void delay(int delay) { actions.add(new DelayAction(delay)); } public void setDialoguePause(boolean paused) { this.dialoguePaused = paused; } public void projectile(int delay, Tile from, Tile to, int graphicId, int startHeight, int endHeight, int startTime, double speed, int angle, int slope, Consumer task) { action(delay, () -> World.sendProjectile(Tile.of(getX(from.getX()), getY(from.getY()), from.getPlane()), Tile.of(getX(to.getX()), getY(to.getY()), to.getPlane()), graphicId, startHeight, endHeight, startTime, speed, angle, task)); } public void projectile(int delay, Tile from, Tile to, int graphicId, int startHeight, int endHeight, int startTime, double speed, int angle, int slope) { action(delay, () -> World.sendProjectile(Tile.of(getX(from.getX()), getY(from.getY()), from.getPlane()), Tile.of(getX(to.getX()), getY(to.getY()), to.getPlane()), graphicId, startHeight, endHeight, startTime, speed, angle, slope)); } public void projectile(Tile from, Tile to, int graphicId, int startHeight, int endHeight, int startTime, double speed, int angle, int slope, Consumer task) { projectile(-1, from, to, graphicId, startHeight, endHeight, startTime, speed, angle, slope, task); } public void projectile(Tile from, Tile to, int graphicId, int startHeight, int endHeight, int startTime, double speed, int angle, int slope) { projectile(-1, from, to, graphicId, startHeight, endHeight, startTime, speed, angle, slope); } public void npcFaceNPC(String key, String targetKey, int delay) { action(delay, () -> getNPC(key).setNextFaceEntity(getNPC(targetKey))); } public void npcFaceNPC(String key, String targetKey) { npcFaceNPC(key, targetKey, -1); } public void playerFaceDir(Direction dir, int delay) { action(delay, () -> player.setNextFaceTile(player.transform(dir.dx, dir.dy))); } public void playerFaceDir(Direction dir) { playerFaceDir(dir, -1); } public void npcFaceDir(String key, Direction dir, int delay) { action(delay, () -> getNPC(key).setNextFaceTile(getNPC(key).transform(dir.dx, dir.dy))); } public void npcFaceDir(String key, Direction dir) { npcFaceDir(key, dir, -1); } public void spawnObj(int id, int rotation, int x, int y, int z) { action(() -> World.spawnObject(new GameObject(id, ObjectDefinitions.getDefs(id).types[0], rotation, Tile.of(getX(x), getY(y), z)))); } public void lowerAspectRatio() { player.getVars().setVar(1241, 1); } public void restoreDefaultAspectRatio() { player.getVars().setVar(1241, 3); } public Instance getInstance() { return instance; } public void returnPlayerFromInstance() { action(() -> { if (instance != null) player.tele(getInstance().getReturnTo()); }); } }" "package com.rs.engine.cutscene @DslMarker annotation class CutsceneDsl @CutsceneDsl open class CutsceneBuilder { private var cutscene = object: Cutscene() { override fun construct(player: Player?) { } } internal open fun build(): Cutscene = cutscene } fun Player.playCutscene(block: CutsceneBuilder.() -> Unit) { playCutscene(CutsceneBuilder().apply(block).build()) }" "package com.rs.engine.cutscene; public class ExampleCutscene extends Cutscene { @Override public void construct(Player player) { fadeIn(5); dynamicRegion(player.getTile(), 178, 554, 4, 4); playerMove(15, 20, 0, MoveType.TELE); spawnObj(67500, 0, 14, 23, 0); npcCreate(""meme"", 50, 14, 20, 0, 0); fadeOut(5); action(5, () -> getNPC(""meme"").transformIntoNPC(13447)); delay(20); } }" "package com.rs.engine.cutscene.actions; public class ConstructMapAction extends CutsceneAction { private final Tile returnTile; private final int baseChunkX; private final int baseChunkY; private final int widthChunks; private final int heightChunks; private final boolean copyNpcs; public ConstructMapAction(Tile returnTile, int baseChunkX, int baseChunkY, int widthChunks, int heightChunks, boolean copyNpcs) { super(null, 1); this.returnTile = returnTile; this.baseChunkX = baseChunkX; this.baseChunkY = baseChunkY; this.widthChunks = widthChunks; this.heightChunks = heightChunks; this.copyNpcs = copyNpcs; } @Override public void process(Player player, Map objects) { Cutscene scene = (Cutscene) objects.get(""cutscene""); scene.constructArea(returnTile, baseChunkX, baseChunkY, widthChunks, heightChunks, copyNpcs); } }" "package com.rs.engine.cutscene.actions; public class CreateNPCAction extends CutsceneAction { private final int id; private final int x; private final int y; private final int plane; private final Consumer configureNpc; public CreateNPCAction(String key, int id, int x, int y, int plane, int actionDelay, Consumer configureNpc) { super(key, actionDelay); this.id = id; this.x = x; this.y = y; this.plane = plane; this.configureNpc = configureNpc; } @Override public void process(Player player, Map objects) { Cutscene scene = (Cutscene) objects.get(""cutscene""); if (objects.get(getObjectKey()) != null) scene.deleteObject(objects.get(getObjectKey())); NPC npc = World.spawnNPC(id, Tile.of(scene.getX(x), scene.getY(y), plane), -1, true, true); objects.put(getObjectKey(), npc); npc.setRandomWalk(false); if (configureNpc != null) configureNpc.accept(npc); } }" "package com.rs.engine.cutscene.actions; public abstract class CutsceneAction { private final String objectKey; private final int delay; public CutsceneAction(String objectKey, int delay) { this.objectKey = objectKey; this.delay = delay; } public abstract void process(Player player, Map objects); public String getObjectKey() { return objectKey; } public int getDelay() { return delay; } }" "package com.rs.engine.cutscene.actions; public class CutsceneCodeAction extends CutsceneAction { private final Runnable runnable; public CutsceneCodeAction(Runnable runnable, int actionDelay) { super(null, actionDelay); this.runnable = runnable; } @Override public void process(Player player, Map objects) { runnable.run(); } }" "package com.rs.engine.cutscene.actions; public class DelayAction extends CutsceneAction { public DelayAction(int delay) { super(null, delay); } @Override public void process(Player player, Map objects) { } }" "package com.rs.engine.cutscene.actions; public class DestroyCachedObjectAction extends CutsceneAction { public DestroyCachedObjectAction(String objectKey, int actionDelay) { super(objectKey, actionDelay); } @Override public void process(Player player, Map objects) { Cutscene scene = (Cutscene) objects.get(""cutscene""); scene.deleteObject(objects.get(getObjectKey())); } }" "package com.rs.engine.cutscene.actions; public class DialogueAction extends CutsceneAction { private final Dialogue dialogue; private final boolean pause; public DialogueAction(Dialogue dialogue, int delay, boolean pause) { super(null, delay); this.dialogue = dialogue; this.pause = pause; } @Override public void process(Player player, Map objects) { if (pause) ((Cutscene) objects.get(""cutscene"")).setDialoguePause(true); player.startConversation(dialogue); } }" "package com.rs.engine.cutscene.actions; public final class InterfaceAction extends CutsceneAction { private final int interfaceId; private final int delay; public InterfaceAction(int interfaceId, int actionDelay) { super(null, actionDelay); this.interfaceId = interfaceId; delay = actionDelay; } @Override public void process(final Player player, Map objects) { player.getInterfaceManager().sendInterface(interfaceId); WorldTasks.schedule(delay, () -> player.getInterfaceManager().removeCentralInterface()); } }" "package com.rs.engine.cutscene.actions; public class LookCameraAction extends CutsceneAction { private final int viewLocalX; private final int viewLocalY; private final int viewZ; private final int speedToExactDestination; private final int speedOnRoutePath; public LookCameraAction(int viewLocalX, int viewLocalY, int viewZ, int speedToExactDestination, int speedOnRoutePath, int actionDelay) { super(null, actionDelay); this.viewLocalX = viewLocalX; this.viewLocalY = viewLocalY; this.viewZ = viewZ; this.speedToExactDestination = speedToExactDestination; this.speedOnRoutePath = speedOnRoutePath; } public LookCameraAction(int viewLocalX, int viewLocalY, int viewZ, int actionDelay) { this(viewLocalX, viewLocalY, viewZ, -1, -1, actionDelay); } @Override public void process(Player player, Map objects) { Cutscene scene = (Cutscene) objects.get(""cutscene""); player.getPackets().sendCameraLook(Tile.of(scene.getX(viewLocalX), scene.getY(viewLocalY), 0), viewZ, speedToExactDestination, speedOnRoutePath); } }" "package com.rs.engine.cutscene.actions; public class MoveNPCAction extends CutsceneAction { private final int x; private final int y; private final int plane; private final MoveType movementType; public MoveNPCAction(String key, int x, int y, boolean run, int actionDelay) { this(key, x, y, 0, run ? MoveType.RUN : MoveType.WALK, actionDelay); } public MoveNPCAction(String key, int x, int y, int plane, MoveType movementType, int actionDelay) { super(key, actionDelay); this.x = x; this.y = y; this.plane = plane; this.movementType = movementType; } @Override public void process(Player player, Map objects) { NPC npc = (NPC) objects.get(getObjectKey()); Cutscene scene = (Cutscene) objects.get(""cutscene""); if (movementType == MoveType.TELE) { npc.tele(Tile.of(scene.getX(x), scene.getY(y), plane)); return; } npc.setRun(movementType == MoveType.RUN); npc.addWalkSteps(scene.getX(x), scene.getY(y), 25, false); } }" "package com.rs.engine.cutscene.actions; public class MovePlayerAction extends CutsceneAction { private final int x; private final int y; private final int plane; private final MoveType movementType; public MovePlayerAction(int x, int y, int plane, MoveType movementType, int actionDelay) { super(null, actionDelay); this.x = x; this.y = y; this.plane = plane; this.movementType = movementType; } @Override public void process(Player player, Map objects) { Cutscene scene = (Cutscene) objects.get(""cutscene""); if (movementType == MoveType.TELE) { player.tele(Tile.of(scene.getX(x), scene.getY(y), plane)); return; } player.setRun(movementType == MoveType.RUN); player.addWalkSteps(scene.getX(x), scene.getY(y), 25, false); } }" "package com.rs.engine.cutscene.actions; public class NPCAnimationAction extends CutsceneAction { private final Animation anim; public NPCAnimationAction(String key, Animation anim, int actionDelay) { super(key, actionDelay); this.anim = anim; } @Override public void process(Player player, Map objects) { NPC npc = (NPC) objects.get(getObjectKey()); npc.setNextAnimation(anim); } }" "package com.rs.engine.cutscene.actions; public class NPCFaceTileAction extends CutsceneAction { private final int x; private final int y; public NPCFaceTileAction(String key, int x, int y, int actionDelay) { super(key, actionDelay); this.x = x; this.y = y; } @Override public void process(Player player, Map objects) { Cutscene scene = (Cutscene) objects.get(""cutscene"");; NPC npc = (NPC) objects.get(getObjectKey()); npc.setNextFaceTile(Tile.of(scene.getX(x), scene.getY(y), npc.getPlane())); } }" "package com.rs.engine.cutscene.actions; public class NPCForceTalkAction extends CutsceneAction { private final String text; public NPCForceTalkAction(String key, String text, int actionDelay) { super(key, actionDelay); this.text = text; } @Override public void process(Player player, Map objects) { NPC npc = (NPC) objects.get(getObjectKey()); npc.setNextForceTalk(new ForceTalk(text)); } }" "package com.rs.engine.cutscene.actions; public class NPCSpotAnimAction extends CutsceneAction { private final SpotAnim gfx; public NPCSpotAnimAction(String key, SpotAnim gfx, int actionDelay) { super(key, actionDelay); this.gfx = gfx; } @Override public void process(Player player, Map objects) { NPC npc = (NPC) objects.get(getObjectKey()); npc.setNextSpotAnim(gfx); } }" "package com.rs.engine.cutscene.actions; public class NPCTransformAction extends CutsceneAction { private final int id; public NPCTransformAction(String key, int id, int actionDelay) { super(key, actionDelay); this.id = id; } @Override public void process(Player player, Map objects) { NPC npc = (NPC) objects.get(getObjectKey()); npc.transformIntoNPC(id); } }" "package com.rs.engine.cutscene.actions; public class PlayerAnimationAction extends CutsceneAction { private final Animation anim; public PlayerAnimationAction(Animation anim, int actionDelay) { super(null, actionDelay); this.anim = anim; } @Override public void process(Player player, Map objects) { player.setNextAnimation(anim); } }" "package com.rs.engine.cutscene.actions; public class PlayerFaceEntityAction extends CutsceneAction { public PlayerFaceEntityAction(String key, int actionDelay) { super(key, actionDelay); } @Override public void process(Player player, Map objects) { NPC npc = (NPC) objects.get(getObjectKey()); player.faceEntity(npc); } }" "package com.rs.engine.cutscene.actions; public class PlayerFaceTileAction extends CutsceneAction { private final int x; private final int y; public PlayerFaceTileAction(int x, int y, int actionDelay) { super(null, actionDelay); this.x = x; this.y = y; } @Override public void process(Player player, Map objects) { Cutscene scene = (Cutscene) objects.get(""cutscene""); player.setNextFaceTile(Tile.of(scene.getX(x), scene.getY(y), player.getPlane())); } }" "package com.rs.engine.cutscene.actions; public class PlayerForceTalkAction extends CutsceneAction { private final String text; public PlayerForceTalkAction(String text, int actionDelay) { super(null, actionDelay); this.text = text; } @Override public void process(Player player, Map objects) { player.setNextForceTalk(new ForceTalk(text)); } }" "package com.rs.engine.cutscene.actions; public class PlayerGraphicAction extends CutsceneAction { private final SpotAnim gfx; public PlayerGraphicAction(SpotAnim gfx, int actionDelay) { super(null, actionDelay); this.gfx = gfx; } @Override public void process(Player player, Map objects) { player.setNextSpotAnim(gfx); } }" "package com.rs.engine.cutscene.actions; public class PlayerMusicEffectAction extends CutsceneAction { private final int id; public PlayerMusicEffectAction(int id, int actionDelay) { super(null, actionDelay); this.id = id; } @Override public void process(Player player, Map objects) { player.jingle(id); } }" "package com.rs.engine.cutscene.actions; public class PlayerTransformAction extends CutsceneAction { private final int npcId; public PlayerTransformAction(int npcId, int actionDelay) { super(null, actionDelay); this.npcId = npcId; } @Override public void process(Player player, Map objects) { player.getAppearance().transformIntoNPC(npcId); } }" "package com.rs.engine.cutscene.actions; public class PlayMusicAction extends CutsceneAction { private final int id; private final int delay; private final int volume; public PlayMusicAction(int id, int delay, int volume, int actionDelay) { super(null, actionDelay); this.id = id; this.delay = delay; this.volume = volume; } public PlayMusicAction(int id, int delay, int actionDelay) { super(null, actionDelay); this.id = id; this.delay = delay; this.volume = 255; } public PlayMusicAction(int id, int actionDelay) { super(null, actionDelay); this.id = id; this.delay = 5; this.volume = 255; } @Override public void process(Player player, Map objects) { player.musicTrack(id, delay, volume); } }" "package com.rs.engine.cutscene.actions; public class PosCameraAction extends CutsceneAction { private final int moveLocalX; private final int moveLocalY; private final int moveZ; private final int speed; private final int speed2; public PosCameraAction(int moveLocalX, int moveLocalY, int moveZ, int speed, int speed2, int actionDelay) { super(null, actionDelay); this.moveLocalX = moveLocalX; this.moveLocalY = moveLocalY; this.moveZ = moveZ; this.speed = speed; this.speed2 = speed2; } public PosCameraAction(int moveLocalX, int moveLocalY, int moveZ, int actionDelay) { this(moveLocalX, moveLocalY, moveZ, -1, -1, actionDelay); } @Override public void process(Player player, Map objects) { Cutscene scene = (Cutscene) objects.get(""cutscene""); player.getPackets().sendCameraPos(Tile.of(scene.getX(moveLocalX), scene.getY(moveLocalY), 0), moveZ, speed, speed2); } }" "package com.rs.engine.dialogue; public class Conversation { public static String DEFAULT_OPTIONS_TITLE = ""Choose an option""; private final HashMap markedStages; private Dialogue firstDialogue; protected Player player; protected Dialogue current; protected int npcId; private boolean created = false; public Conversation(Dialogue current) { this(null, current); } public Conversation(Player player) { this(player, null); } public Conversation(Player player, Dialogue current) { this.player = player; this.current = current; this.firstDialogue = current; this.markedStages = new HashMap<>(); } public Conversation(Statement statement) { this(null, new Dialogue(statement)); } public Dialogue create(String stageName, Dialogue dialogue) { markedStages.put(stageName, dialogue); return dialogue; } public Dialogue createStage(String stageName, Statement statement) { Dialogue dialogue = new Dialogue(statement); markedStages.put(stageName, dialogue); return dialogue; } public void create(String stageName) { created = true; setFirst(getStage(stageName).getHead()); } public boolean create() { try { created = true; if (current != null) { setFirst(firstDialogue); return true; } return false; } catch(Exception e) { throw new RuntimeException(""Error creating dialogue: "" + getClass().getSimpleName() + "" - "" + e.getMessage()); } } public Dialogue getCurrent() { return current; } public Dialogue getStart() { try { return current.getHead(); } catch(Exception e) { throw new RuntimeException(""Error creating dialogue: "" + getClass().getSimpleName() + "" - "" + e.getMessage()); } } public void setFirst(Dialogue dialogue) { current = dialogue; } public Dialogue getStage(String stageName) { return markedStages.get(stageName); } public Dialogue addNext(String stageName, Dialogue dialogue) { if (firstDialogue == null) firstDialogue = dialogue; if (markedStages == null) throw new RuntimeException(""Do not call builder functions outside the constructor.""); if (stageName != null) markedStages.put(stageName, dialogue); if (current == null) current = dialogue; else current = current.addNext(dialogue); return current; } public Dialogue addNext(Dialogue dialogue) { return addNext(null, dialogue); } public Dialogue addNext(Runnable event) { return addNext(new Dialogue(event)); } public Dialogue addNext(String stageName, Statement statement) { if (markedStages == null) throw new RuntimeException(""Do not call builder functions outside the constructor.""); Dialogue dialogue = new Dialogue(statement); if (firstDialogue == null) firstDialogue = dialogue; if (stageName != null) markedStages.put(stageName, dialogue); if (current == null) current = dialogue; else current = current.addNext(dialogue); return current; } public Dialogue addNext(Statement statement) { return addNext(null, statement); } public Dialogue addPlayer(HeadE expression, String text) { return addNext(new PlayerStatement(expression, text)); } public Dialogue addPlayer(HeadE expression, String text, Runnable extraFunctionality) { return addNext(new Dialogue(new PlayerStatement(expression, text), extraFunctionality)); } public Dialogue addOption(String title, String... options) { return addNext(new OptionStatement(title, options)); } public Dialogue addOptions(Options options) { return addOptions(null, options); } public Dialogue addNext(Statement statement, Dialogue... options) { return addNext(null, statement, options); } public Dialogue addOptions(Consumer create) { Options options = new Options() { @Override public void create() { create.accept(this); } }; return addOptions(null, options); } public Dialogue addOptions(String title, Consumer create) { Options options = new Options() { @Override public void create() { create.accept(this); } }; return addOptions(title, options); } public Dialogue addOptions(Conversation conversation, String stageName, Consumer create) { Options options = new Options(stageName, conversation) { @Override public void create() { create.accept(this); } }; return addOptions(DEFAULT_OPTIONS_TITLE, options); } public Dialogue addOptions(String stageName, String title, Consumer create) { Options options = new Options(stageName, this) { @Override public void create() { create.accept(this); } }; return addOptions(title, options); } public Dialogue addNext(String name, Statement statement, Dialogue... options) { Dialogue option = addNext(name, statement); for (Dialogue option2 : options) option.addNext(option2); return option; } public Dialogue addNext(Statement statement, Runnable... events) { return addNext(null, statement, events); } public Dialogue addNext(String name, Statement statement, Runnable... events) { Dialogue option = addNext(name, statement); for (Runnable event : events) option.addNext(event); return option; } public Dialogue addNext(String markedStage) { return addNext(markedStages.get(markedStage)); } public Dialogue addOptions(String title, Options options) { if (options.getOptions().size() <= 1) { for (String opName : options.getOptions().keySet()) { Option op = options.getOptions().get(opName); if (op.show() && op.getDialogue() != null) { Dialogue next = addNext(op.getDialogue()); if (options.getConv() != null) options.getConv().addStage(options.getStageName(), next); return next; } } return null; } if (options.getOptions().size() <= 5) { List ops = new ArrayList<>(); for (String opName : options.getOptions().keySet()) { Option o = options.getOptions().get(opName); if (o.show()) ops.add(opName); } Dialogue op = new Dialogue(new OptionStatement(title, ops.stream().toArray(String[] ::new))); for (String opName : options.getOptions().keySet()) { Option o = options.getOptions().get(opName); if (o.show() && o.getDialogue() != null) op.addNext(o.getDialogue()); } if (options.getConv() != null) options.getConv().addStage(options.getStageName(), op); return addNext(op); } String[] ops = new String[options.getOptions().keySet().size()]; options.getOptions().keySet().toArray(ops); String[] baseOptions = new String[5]; System.arraycopy(ops, 0, baseOptions, 0, 4); baseOptions[4] = ""More options...""; Dialogue baseOption = new Dialogue(new OptionStatement(title, baseOptions)); Dialogue currPage = baseOption; for (int i = 0;i < ops.length;i++) { Option op = options.getOptions().get(ops[i]); if (op.show() && op.getDialogue() != null) { currPage.addNext(op.getDialogue()); if (i >= 3 && ((i+1) % 4) == 0) { String[] nextOps = new String[Utils.clampI(ops.length-i, 0, 5)]; for (int j = 1;j < 5;j++) { if (i+j >= ops.length) continue; nextOps[j-1] = ops[i+j]; } nextOps[nextOps.length-1] = ""More options...""; Dialogue nextPage = new Dialogue(new OptionStatement(title, nextOps)); currPage.addNext(nextPage); currPage = nextPage; } } } currPage.addNext(baseOption); if (options.getConv() != null) options.getConv().addStage(options.getStageName(), baseOption); return addNext(baseOption); } public Dialogue addItem(int itemId, String text) { return addNext(new ItemStatement(itemId, text)); } public Dialogue addItem(int itemId, String text, Runnable extraFunctionality) { return addNext(new Dialogue(new ItemStatement(itemId, text), extraFunctionality)); } public Dialogue addNPC(int npcId, HeadE expression, String text) { this.npcId = npcId; return addNext(new NPCStatement(npcId, expression, text)); } public Dialogue addNPC(int npcId, HeadE expression, String text, Runnable extraFunctionality) { this.npcId = npcId; return addNext(new Dialogue(new NPCStatement(npcId, expression, text), extraFunctionality)); } public Dialogue addNPC(HeadE expression, String text) { return addNext(new NPCStatement(npcId, expression, text)); } public Dialogue addNPC(HeadE expression, String text, Runnable extraFunctionality) { return addNext(new Dialogue(new NPCStatement(npcId, expression, text), extraFunctionality)); } public Dialogue addNPC(NPC npc, HeadE expression, String text) { return addNext(new NPCStatement(npc.getCustomName(), npc.getId(), expression, text)); } public Dialogue addNPC(NPC npc, HeadE expression, String text, Runnable extraFunctionality) { return addNext(new Dialogue(new NPCStatement(npc.getCustomName(), npc.getId(), expression, text), extraFunctionality)); } public Dialogue addQuestStart(Quest quest) { return addNext(new QuestStartStatement(quest)); } public Dialogue addSimple(String... text) { return addNext(new SimpleStatement(text)); } public Dialogue addSimple(String text, Runnable extraFunctionality) { return addNext(new Dialogue(new SimpleStatement(text), extraFunctionality)); } public void start() { if (current == null) return; current.run(player); } public void process(int interfaceId, int componentId) { process(current.getStatement() != null ? current.getStatement().getOptionId(componentId) : 0); } public void process(int opIndex) { if (current != null) { current.close(player); if (current.getVoiceEffect() > -1) player.getPackets().resetSounds(); } current = current.getNext(opIndex); if (current == null) { player.endConversation(); return; } if (current instanceof StageSelectDialogue d) { if (d.getFunc() != null) d.getFunc().run(); if (d.getStages() != null) current = d.getStages().get(d.getStageName()); else current = d.getDirectNextReference(); } if (player.getInterfaceManager().containsChatBoxInter()) player.getInterfaceManager().closeChatBoxInterface(); current.run(player); } public void setPlayer(Player player) { this.player = player; } public void addStage(String stageName, Dialogue dialogue) { markedStages.put(stageName, dialogue); } @Override public String toString() { Set visited = new HashSet<>(); StringBuilder str = new StringBuilder(); Dialogue head = current; Dialogue curr = current; while(curr != null) { visited.add(curr); str.append(curr).append(""\n""); curr = curr.getNext(0); if (visited.contains(curr)) break; } curr = head; str.append(created); return str.toString(); } public boolean isCreated() { return created; } public HashMap getStages() { return markedStages; } }" "package com.rs.engine.dialogue; public class Dialogue { private Dialogue prev; private ArrayList next = new ArrayList<>(); private Runnable event; private Statement statement; private int voiceEffectId = -1; private boolean started = true; public Dialogue(Statement statement, Runnable extraFunctionality) { this.statement = statement; event = extraFunctionality; } public Dialogue(Statement statement) { this(statement, () -> { }); } public Dialogue(Runnable event) { this(null, event); } public Dialogue() { this(null, () -> { }); started = false; } public Dialogue(Dialogue dialogue) { prev = dialogue.prev; next = dialogue.next; event = dialogue.event; statement = dialogue.statement; started = dialogue.started; } public void clearChildren() { started = false; event = null; statement = null; next.clear(); } public Dialogue setFunc(Runnable consumer) { event = consumer; return this; } public Runnable getFunc() { return event; } public Dialogue addGotoStage(String stageName, Map stages) { return addNext(new StageSelectDialogue(stageName, stages)); } public Dialogue addGotoStage(String stageName, Conversation conversation) { return addNext(new StageSelectDialogue(stageName, conversation.getStages())); } public Dialogue addGotoStage(Dialogue directNextReference) { return addNext(new StageSelectDialogue(directNextReference)); } public Dialogue addStatementWithOptions(Statement statement, Dialogue... options) { Dialogue option = addNext(statement); for (Dialogue option2 : options) option.addNext(option2); return option; } public Dialogue addStatementWithActions(Statement statement, Runnable... events) { Dialogue option = addNext(statement); for (Runnable event2 : events) option.addNext(event2); return option; } public Dialogue addPlayer(HeadE expression, String text) { return addNext(new PlayerStatement(expression, text)); } public Dialogue addPlayer(HeadE expression, String text, Runnable extraFunctionality) { return addNext(new Dialogue(new PlayerStatement(expression, text), extraFunctionality)); } public Dialogue addOption(String title, String... options) { return addNext(new OptionStatement(title, options)); } public Dialogue addNPC(int npcId, HeadE expression, String text) { return addNext(new NPCStatement(npcId, expression, text)); } public Dialogue addNPC(int npcId, HeadE expression, String text, Runnable extraFunctionality) { return addNext(new Dialogue(new NPCStatement(npcId, expression, text), extraFunctionality)); } public Dialogue addNPC(NPC npc, HeadE expression, String text) { return addNext(new NPCStatement(npc.getCustomName(), npc.getId(), expression, text)); } public Dialogue addNPC(NPC npc, HeadE expression, String text, Runnable extraFunctionality) { return addNext(new Dialogue(new NPCStatement(npc.getCustomName(), npc.getId(), expression, text), extraFunctionality)); } public Dialogue addItem(int itemId, String text) { return addNext(new ItemStatement(itemId, text)); } public Dialogue addItem(int itemId, String text, Runnable extraFunctionality) { return addNext(new Dialogue(new ItemStatement(itemId, text), extraFunctionality)); } public Dialogue addSimple(String... text) { return addNext(new SimpleStatement(text)); } public Dialogue addSimple(String text, Runnable extraFunctionality) { return addNext(new Dialogue(new SimpleStatement(text), extraFunctionality)); } public Dialogue addItemToInv(Player player, Item item, String text) { return addNext(new ItemStatement(item.getId(), text)).setFunc(() -> player.getInventory().addItem(item)); } public Dialogue addQuestStart(Quest quest) { return addNext(new QuestStartStatement(quest)); } public Dialogue addMakeX(int[] itemIds, int maxAmt) { return addNext(new MakeXStatement(itemIds, maxAmt)); } public Dialogue addMakeX(int itemId, int maxAmt) { return addMakeX(new int[] { itemId }, maxAmt); } public Dialogue addMakeX(int[] itemIds) { return addMakeX(itemIds, 60); } public Dialogue addMakeX(int itemId) { return addMakeX(new int[] { itemId }, 60); } public Dialogue addOptions(Consumer create) { Options options = new Options() { @Override public void create() { create.accept(this); } }; return addOptions(null, options); } public Dialogue addOptions(Options options) { return addOptions(null, options); } public Dialogue addOptions(String title, Consumer create) { Options options = new Options() { @Override public void create() { create.accept(this); } }; return addOptions(title, options); } public Dialogue addOptions(Conversation conversation, String stageName, Consumer create) { Options options = new Options(stageName, conversation) { @Override public void create() { create.accept(this); } }; return addOptions(Conversation.DEFAULT_OPTIONS_TITLE, options); } public Dialogue addOptions(String stageName, Conversation conv, String title, Consumer create) { Options options = new Options(stageName, conv) { @Override public void create() { create.accept(this); } }; return addOptions(title, options); } public Dialogue addOptions(String title, Options options) { if (options.getOptions().size() <= 1) { for (String opName : options.getOptions().keySet()) { Option op = options.getOptions().get(opName); if (op.show() && op.getDialogue() != null) return addNext(op.getDialogue()); } if (options.getConv() != null) options.getConv().addStage(options.getStageName(), getNext(0)); } else if (options.getOptions().size() <= 5) { List ops = new ArrayList<>(); for (String opName : options.getOptions().keySet()) { Option o = options.getOptions().get(opName); if (o.show()) ops.add(opName); } Dialogue op = new Dialogue(new OptionStatement(title, ops.stream().toArray(String[] ::new))); for (String opName : options.getOptions().keySet()) { Option o = options.getOptions().get(opName); if (o.show() && o.getDialogue() != null) op.addNext(o.getDialogue()); } if (options.getConv() != null) options.getConv().addStage(options.getStageName(), op); return addNext(op); } else { String[] ops = new String[options.getOptions().keySet().size()]; options.getOptions().keySet().toArray(ops); String[] baseOptions = new String[5]; System.arraycopy(ops, 0, baseOptions, 0, 4); baseOptions[4] = ""More options...""; Dialogue baseOption = new Dialogue(new OptionStatement(title, baseOptions)); Dialogue currPage = baseOption; for (int i = 0;i < ops.length;i++) { Option op = options.getOptions().get(ops[i]); if (op.show() && op.getDialogue() != null) { currPage.addNext(op.getDialogue()); if (i >= 3 && ((i+1) % 4) == 0) { String[] nextOps = new String[Utils.clampI(ops.length-i, 0, 5)]; for (int j = 1;j < 5;j++) { if (i+j >= ops.length) continue; nextOps[j-1] = ops[i+j]; } nextOps[nextOps.length-1] = ""More options...""; Dialogue nextPage = new Dialogue(new OptionStatement(title, nextOps)); currPage.addNext(nextPage); currPage = nextPage; } } } currPage.addNext(baseOption); if (options.getConv() != null) options.getConv().addStage(options.getStageName(), baseOption); return addNext(baseOption); } return this; } public Dialogue addNext(Statement statement) { if (!started) { this.statement = statement; started = true; return this; } Dialogue nextD = new Dialogue(statement); if (nextD.getPrev() == null) nextD.setPrev(this); next.add(nextD); return nextD; } public Dialogue addNextIf(BooleanSupplier condition, Dialogue dialogue) { if (condition.getAsBoolean()) { addNext(dialogue.getHead()); return dialogue; } return this; } public Dialogue addNextIf(BooleanSupplier condition, Runnable event) { if (condition.getAsBoolean()) return addNext(event); return this; } public Dialogue addNext(Dialogue dialogue) { if (!started) { if (dialogue instanceof StageSelectDialogue) return dialogue; statement = dialogue.statement; event = dialogue.event; next = dialogue.next; started = true; return this; } if (dialogue.getPrev() == null) dialogue.setPrev(this); else { Dialogue copy = new Dialogue(this); dialogue.setPrev(copy); } next.add(dialogue); return dialogue; } public Dialogue addNext(Runnable event) { Dialogue dialogue = new Dialogue(); dialogue.statement = null; dialogue.event = event; return addNext(dialogue); } public Dialogue addNPC(int npcId, HeadE expression, String text, String nameOverride) { return addNext(new Dialogue(new NPCStatement(nameOverride, npcId, expression, text))); } public Dialogue addNPC(int npcId, HeadE expression, String text, String nameOverride, Runnable extraFunctionality) { return addNext(new Dialogue(new NPCStatement(nameOverride, npcId, expression, text), extraFunctionality)); } public Dialogue addStop() { return addNext(new Dialogue()); } public Dialogue finish() { return getHead(); } public Dialogue getHead() { if (prev == null) return this; Set visited = new HashSet<>(); Dialogue curr = this; while(curr.getPrev() != null) { if (visited.contains(curr)) break; visited.add(curr); curr = curr.getPrev(); } return curr; } public Dialogue getNext(int choice) { if (next.size() > 0 && choice < next.size()) return next.get(choice); return null; } public void run(Player player) { if (event != null) event.run(); if (statement != null) statement.send(player); if (voiceEffectId != -1) player.voiceEffect(voiceEffectId, false); } public Dialogue getPrev() { return prev; } public void setPrev(Dialogue prev) { this.prev = prev; } public Statement getStatement() { return statement; } @Override public String toString() { StringBuilder str = new StringBuilder(""[Dialogue] { stmt: "" + statement + "" next: [ ""); for (Dialogue d : next) { if (d == null) continue; str.append(d.getClass().getSimpleName()).append(""("").append(d.getStatement()).append("")\n\t""); } str.append("" ] }""); return str.toString(); } public Dialogue cutPrev() { Dialogue isolated = new Dialogue(); isolated.addNext(this); isolated.prev = null; return isolated; } public Dialogue setStage(String stageName, Conversation conversation) { Dialogue copy = new Dialogue(this); copy.prev = null; conversation.addStage(stageName, copy); return this; } public void close(Player player) { if (statement != null) statement.close(player); } public int getVoiceEffect() { return voiceEffectId; } public Dialogue voiceEffect(int voiceId) { this.voiceEffectId = voiceId; return this; } }" "package com.rs.engine.dialogue @DslMarker annotation class DialogueDsl @DialogueDsl open class DialogueBuilder(val stages: MutableMap = mutableMapOf()) { private var dialogue = Dialogue() private var pendingLabel: String? = null val start = dialogue fun player(expression: HeadE, text: String, extraFunctionality: Runnable? = null) { dialogue = dialogue.addPlayer(expression, text, extraFunctionality) applyPendingLabel() } fun npc(id: Int, expression: HeadE, text: String, extraFunctionality: Runnable? = null) { dialogue = dialogue.addNPC(id, expression, text, extraFunctionality) applyPendingLabel() } fun item(itemId: Int, text: String, extraFunctionality: Runnable? = null) { dialogue = dialogue.addItem(itemId, text, extraFunctionality) applyPendingLabel() } fun simple(vararg text: String, extraFunctionality: Runnable? = null) { dialogue = if (extraFunctionality != null) { dialogue.addSimple(text.first(), extraFunctionality) } else { dialogue.addSimple(*text) } applyPendingLabel() } fun exec(extraFunctionality: Runnable) { dialogue = dialogue.addNext(extraFunctionality) applyPendingLabel() } fun addItemToInv(player: Player, item: Item, text: String) { dialogue = dialogue.addItemToInv(player, item, text) applyPendingLabel() } fun questStart(quest: Quest) { dialogue = dialogue.addQuestStart(quest) applyPendingLabel() } fun options(title: String? = null, setup: OptionsBuilder.() -> Unit) { dialogue = dialogue.addOptions(title) { options -> OptionsBuilder(stages).apply(setup).applyToOptions(options) } applyPendingLabel() } fun makeX(itemId: Int, maxAmt: Int = 60) { dialogue = dialogue.addMakeX(itemId, maxAmt) applyPendingLabel() } fun makeX(itemIds: IntArray, maxAmt: Int = 60) { dialogue = dialogue.addMakeX(itemIds, maxAmt) applyPendingLabel() } fun label(stageName: String) { pendingLabel = stageName } fun goto(stageName: String, conversation: Conversation? = null) { dialogue = if (conversation != null) dialogue.addGotoStage(stageName, conversation) else dialogue.addGotoStage(stageName, stages) } fun statementWithOptions(statement: Statement, vararg options: DialogueBuilder.() -> Unit) { val optionDialogues = options.map { DialogueBuilder(stages).apply(it).build() } dialogue = dialogue.addStatementWithOptions(statement, *optionDialogues.toTypedArray()) applyPendingLabel() } fun statementWithActions(statement: Statement, vararg events: Runnable) { dialogue = dialogue.addStatementWithActions(statement, *events) applyPendingLabel() } fun item(itemId: Int, text: String) { dialogue = dialogue.addItem(itemId, text) applyPendingLabel() } fun simple(text: String) { dialogue = dialogue.addSimple(text) applyPendingLabel() } fun npc(npc: NPC, expression: HeadE, text: String, extraFunctionality: Runnable? = null) { dialogue = dialogue.addNPC(npc, expression, text, extraFunctionality) applyPendingLabel() } fun makeX(itemId: Int) { dialogue = dialogue.addMakeX(itemId) applyPendingLabel() } fun makeX(itemIds: IntArray) { dialogue = dialogue.addMakeX(itemIds) applyPendingLabel() } fun nextIf(condition: BooleanSupplier, dialogueSetup: DialogueBuilder.() -> Unit) { val nextDialogue = DialogueBuilder(stages).apply(dialogueSetup).build() dialogue = dialogue.addNextIf(condition, nextDialogue) applyPendingLabel() } fun stop() { dialogue = dialogue.addStop() } fun setStage(stageName: String, conversation: Conversation) { dialogue = dialogue.setStage(stageName, conversation) } fun voiceEffect(voiceId: Int) { dialogue = dialogue.voiceEffect(voiceId) } private fun applyPendingLabel() { if (pendingLabel != null) { stages[pendingLabel!!] = dialogue pendingLabel = null } } internal open fun build(): Dialogue = start } @DialogueDsl class OptionsBuilder(val stages: MutableMap) { private sealed class OptionOperation { data class BuilderOp(val name: String, val setup: OptionBuilder.() -> Unit) : OptionOperation() data class ExecOp(val name: String, val exec: Runnable) : OptionOperation() } private val operations = mutableListOf() fun op(name: String, setup: OptionBuilder.() -> Unit = {}) { operations.add(OptionOperation.BuilderOp(name, setup)) } fun opExec(name: String, exec: Runnable) { operations.add(OptionOperation.ExecOp(name, exec)) } fun applyToOptions(options: Options) { operations.forEach { operation -> when (operation) { is OptionOperation.BuilderOp -> { val builder = OptionBuilder(stages).apply(operation.setup) options.add(operation.name, builder.build()) } is OptionOperation.ExecOp -> { options.add(operation.name, operation.exec) } } } } } @DialogueDsl class OptionBuilder(stages: MutableMap) : DialogueBuilder(stages) fun dialogue(block: DialogueBuilder.() -> Unit): Dialogue { val builder = DialogueBuilder() builder.block() return builder.build() } fun Player.startConversation(block: DialogueBuilder.() -> Unit) { startConversation(DialogueBuilder().apply(block).build()) }" "package com.rs.engine.dialogue; public enum HeadE { NONE(-1), AMAZED_MILD(9742), AMAZED(9746), MORTIFIED_JAW_DROP(9750), MORTIFIED(9753), SAD_MILD_LOOK_DOWN(9757), SAD_MILD(9760), SAD_SNIFFLE(9761), SAD(9764), SAD_CRYING(9765), SAD_EXTREME(9768), UPSET(9770), UPSET_SNIFFLE(9772), SCARED(9773), WORRIED(9775), TERRIFIED(9777), FRUSTRATED(9781), VERY_FRUSTRATED(9785), ANGRY(9789), BUMPY_RIDE(9793), SLEEPING(9802), NOTHING_LISTENING(9804), CALM(9806), NO_EXPRESSION(9809), CALM_TALK(9810), CONFUSED(9811), SHAKING_HEAD(9814), SKEPTICAL_HEAD_SHAKE(9827), SKEPTICAL(9830), ROLL_EYES(9831), SKEPTICAL_THINKING(9834), DRUNK(9835), NERVOUS(9836), SECRETIVE(9838), CHUCKLE(9840), LAUGH(9841), EVIL_LAUGH(9842), CHEERFUL(9843), TALKING_ALOT(9845), CHEERFUL_EXPOSITION(9847), HAPPY_TALKING(9850), FOGGY_STORYTELLING(9851), FOGGY_STORYTELLING_2(9852), EYES_CLOSED_NERVOUS(9877), DIZZY(9878), DRUNK_ANGRY(12648), LOSING_IT_LAUGHING(12649), SAD_VERY_SNIFFLE(12650), T_CALM_TALK(12936), T_ANGRY(12940), T_VERY_SAD(12944), T_SAD(12948), T_HAPPY_TALK(12952), T_CONFUSED(12957), T_CONFUSED_DENIAL(12961), T_LAUGH(12964), T_SCARED(12968), T_ANGRY_NO(12973), T_SURPRISED(12977), CAT_CALM_TALK(9178), CAT_CHEERFUL(9179), CAT_EXPLAIN(9180), CAT_SHOOK(9181), CAT_SHOUTING(9185), CAT_SLOW_TALK(9187), CAT_CALM_TALK2(9189), CAT_SURPRISED(9190), CAT_HAPPY(9192), CAT_PURRING(9202), CAT_DISAPPOINTED(9225), CAT_CRAZY(10522), CAT_DISAPPOINTED2(11536), CAT_LAUGH(1518), CAT_SAD(6552), CAT_INTELLIGENT_CALM(6553), OLD_CHAT(590), CHILD_FRUSTRATED(7168), CHILD_DOWN(7169), CHILD_RECALLING(7170), CHILD_EVIL_LAUGH(7171), CHILD_HAPPY_TALK(7172), CHILD_CALM_TALK(7173), CHILD_LAUGH(7175), CHILD_THINKING(7176), CHILD_SAD(7177), CHILD_SCARED(7178), CHILD_SECRETIVE(7179), CHILD_AWE(7180), CHILD_ANGRY(8814), CHILD_ANGRY_HEADSHAKE(8815), CHILD_UNSURE(8824), CHILD_CRYING(9683), CHILD_GRETA_THUNBERG(9684), CHILD_TANTRUM(7181), PENG_TALK(5661), PENG_EXPLAIN(5662), PENG_HAPPY(5663), PENG_SAD(5665), SPIDER_NONE(11605), SPIDER_EXCLAIM(11606), SPIDER_CALM(11607), SPIDER_SAD(11607), //Kalphites 6243-6246 possibly //More bug faces 7630-7639 //8380-8387 //8475-8478 ; private final int emoteId; private HeadE(int emoteId) { this.emoteId = emoteId; } public int getEmoteId() { return emoteId; } }" "package com.rs.engine.dialogue; public class Option { private final Dialogue dialogue; private final Supplier constraint; public Option(Supplier constraint, Dialogue dialogue) { this.constraint = constraint; this.dialogue = dialogue; } public Option(Dialogue dialogue) { this(null, dialogue); } public Dialogue getDialogue() { return dialogue; } public Supplier getConstraint() { return constraint; } public boolean show() { return constraint == null ? true : constraint.get(); } }" "package com.rs.engine.dialogue; public abstract class Options { private final Map options = new LinkedHashMap<>(); //LinkedHashMap O(1) but allows ordered keys private String stageName; private Conversation conv; public Options() { create(); } public Options(String stageName, Conversation conv) { this.conv = conv; this.stageName = stageName; create(); } public abstract void create(); public void option(String name, Dialogue dialogue) { options.put(name, new Option(dialogue.getHead())); } public void option(String name, Runnable consumer) { options.put(name, new Option(new Dialogue(null, consumer))); } public void option(Supplier constraint, String name, Dialogue dialogue) { options.put(name, new Option(constraint, dialogue.getHead())); } public void option(String name) { options.put(name, new Option(null)); } public void add(String name, Dialogue dialogue) { options.put(name, new Option(dialogue.getHead())); } public void add(String name, Runnable consumer) { options.put(name, new Option(new Dialogue(null, consumer))); } public void add(Supplier constraint, String name, Dialogue dialogue) { options.put(name, new Option(constraint, dialogue.getHead())); } public Dialogue add(String name) { Dialogue dial = new Dialogue(); options.put(name, new Option(dial)); return dial; } public void empty(String name) { options.put(name, new Option(null)); } public Map getOptions() { return options; } public String getStageName() { return stageName; } public Conversation getConv() { return conv; } }" "package com.rs.engine.dialogue.impl; public class MakeXActionD extends Dialogue { private final List options = new ArrayList<>(); public MakeXActionD addOption(MakeXItem option) { clearChildren(); options.add(option); MakeXItem[] opArr = new MakeXItem[options.size()]; options.toArray(opArr); addStatementWithOptions(new MakeXStatement(opArr, 28), opArr); return this; } public boolean isEmpty() { return options.isEmpty(); } }" "package com.rs.engine.dialogue.impl; public class MakeXItem extends Dialogue { private final int itemId; public MakeXItem(Player player, Item[] materials, Item[] products, double xp, int anim, int req, int skill, int delay) { itemId = products[0].getId(); setFunc(() -> { int quantity = MakeXStatement.getQuantity(player); for (Item mat : materials) { int newQ = player.getInventory().getNumberOf(mat.getId()) / mat.getAmount(); if (newQ < quantity) quantity = newQ; } player.getActionManager().setAction(new CreateAction(new Item[][] { materials }, new Item[][] { products }, new double [] { xp }, new int[] { anim }, new int[] { req }, skill, delay, 0).setQuantity(quantity)); }); } public MakeXItem(Player player, Item material, Item product, double xp, int anim, int req, int skill, int delay) { this(player, new Item[] { material }, new Item[] { product }, xp, anim, req, skill, delay); } public int getItemId() { return itemId; } }" "package com.rs.engine.dialogue.statements; public class DestroyItemStatement implements Statement { private final Item item; private final String message; public DestroyItemStatement(Item item, String message) { this.item = item; this.message = message; } @Override public void send(Player player) { player.getInterfaceManager().sendChatBoxInterface(1183); player.getPackets().setIFText(1183, 7, item.getName()); if (message != null) player.getPackets().setIFText(1183, 12, message); player.getPackets().setIFItem(1183, 13, item.getId(), 1); } @Override public int getOptionId(int componentId) { return componentId == 9 ? 0 : 1; } @Override public void close(Player player) { } }" "package com.rs.engine.dialogue.statements; public class ItemStatement implements Statement { private final int itemId; private int zoom = 500; private final String[] text; public ItemStatement(int itemId, String... text) { this.itemId = itemId; this.text = text; } public ItemStatement(int itemId, int zoom, String... text) { this.itemId = itemId; this.text = text; this.zoom = zoom; } @Override public void send(Player player) { StringBuilder text = new StringBuilder(); for (String s : this.text) text.append(s).append(""
""); player.getInterfaceManager().sendChatBoxInterface(1189); player.getPackets().sendRunScript(3449, itemId, zoom); player.getPackets().setIFText(1189, 4, text.toString()); } @Override public int getOptionId(int componentId) { return 0; } @Override public void close(Player player) { } }" "package com.rs.engine.dialogue.statements; public class LampXPSelectStatement implements Statement { private final Lamp lamp; public LampXPSelectStatement(Lamp lamp) { this.lamp = lamp; } @Override public void send(Player player) { if (lamp.getId() == 12628) lamp.setXp(500); player.getTempAttribs().setO(""lampInstance"", lamp); player.getVars().setVar(738, 1); //has house player.getVars().setVarBit(2187, 1); player.getInterfaceManager().sendInterface(1263); player.getPackets().sendVarcString(358, ""What skill would you like XP in?""); sendSelectedSkill(player); player.getPackets().sendVarc(1797, 0); player.getPackets().sendVarc(1798, lamp.getReq()); //level required to use lamp player.getPackets().sendVarc(1799, getVarCValueForLamp(lamp.getId())); for (int i = 13; i < 38; i++) player.getPackets().setIFRightClickOps(1263, i, -1, 0, 0); player.getPackets().setIFEvents(new IFEvents(1263, 39, 1, 26).enableContinueButton()); } @Override public int getOptionId(int componentId) { return switch(componentId) { case 39 -> 0; default -> 1; }; } private static void sendSelectedSkill(Player player) { if (player.getTempAttribs().getO(""lampInstance"") == null) return; Lamp lamp = player.getTempAttribs().getO(""lampInstance""); EnumDefinitions map = EnumDefinitions.getEnum(681); if (lamp.getSelectedSkill() == map.getDefaultIntValue()) { player.getPackets().sendVarc(1796, map.getDefaultIntValue()); return; } long key = map.getKeyForValue(lamp.getSelectedSkill()); player.getPackets().sendVarc(1796, (int) key); } private int getVarCValueForLamp(int id) { return switch (id) { case 4447 ->//Shield of Arrav 23713; default -> id; }; } @Override public void close(Player player) { player.closeInterfaces(); } }" "package com.rs.engine.dialogue.statements; public class LegacyItemStatement implements Statement { private final int[] itemIds; private final String title; private final String[] text; public LegacyItemStatement(int item, String title, String... text) { itemIds = new int[] { item }; this.title = title; this.text = text; } public LegacyItemStatement(int item1, int item2, String title, String... text) { itemIds = new int[] { item1, item2 }; this.title = title; this.text = text; } @Override public void send(Player player) { int interfaceId = itemIds.length > 1 ? 131 : 519; StringBuilder text = new StringBuilder(); text.append(title).append(""
""); for (String s : this.text) text.append(s).append(""
""); player.getInterfaceManager().sendChatBoxInterface(interfaceId); player.getPackets().setIFText(interfaceId, 1, text.toString()); player.getPackets().setIFItem(interfaceId, 0, itemIds[0], 1); if (itemIds.length > 1) player.getPackets().setIFItem(interfaceId, 2, itemIds[1], 1); } @Override public int getOptionId(int componentId) { return 0; } @Override public void close(Player player) { } }" "package com.rs.engine.dialogue.statements; @PluginEventHandler public class MakeXStatement implements Statement { public enum MakeXType { MAKE, MAKE_SET, COOK, ROAST, OFFER, SELL, BAKE, CUT, DEPOSIT, MAKE_INTERVAL, TELEPORT, SELECT, MAKE_SET_INTERVAL, TAKE, RETURN, HEAT, ADD } private final MakeXType type; private int maxQuantity = -50; private final String question; private final int[] items; private final String[] options; public MakeXStatement(MakeXType type, int maxQuantity, String question, int[] items, String[] options) { this.type = type; this.maxQuantity = maxQuantity; this.question = question; this.items = items; this.options = options; } public MakeXStatement(MakeXItem[] items, int maxQuantity) { this(MakeXType.MAKE, maxQuantity, ""How many would you like to make?"", Arrays.stream(items).mapToInt(MakeXItem::getItemId).toArray(), null); } public MakeXStatement(MakeXType type, String question, int[] items, int maxQuantity) { this(type, maxQuantity, question, items, null); } public MakeXStatement(MakeXType type, int[] items, int maxQuantity) { this(type, maxQuantity, ""How many would you like to make?"", items, null); } public MakeXStatement(MakeXType type, int[] items, String[] options) { this(type, -50, ""Select an item."", items, options); } public MakeXStatement(MakeXType type, int[] items) { this(type, -50, ""Select an item."", items, null); } public MakeXStatement(String question, int[] items, int maxQuantity) { this(MakeXType.MAKE, maxQuantity, question, items, null); } public MakeXStatement(int[] items, int maxQuantity) { this(MakeXType.MAKE, maxQuantity, ""How many would you like to make?"", items, null); } public MakeXStatement(int[] items, String[] options) { this(MakeXType.SELECT, -50, ""Select an item."", items, options); } public MakeXStatement(int[] items) { this(MakeXType.SELECT, -50, ""Select an item."", items, null); } @Override public void send(Player player) { player.getPackets().setIFRightClickOps(916, 8, -1, 0, 0); player.getPackets().setIFText(916, 6, question); player.getPackets().sendVarc(754, type.ordinal()); for (int i = 0; i < 10; i++) { if (i >= items.length) { player.getPackets().sendVarc(i >= 6 ? (1139 + i - 6) : 755 + i, -1); continue; } player.getPackets().sendVarc(i >= 6 ? (1139 + i - 6) : 755 + i, items[i]); player.getPackets().sendVarcString(i >= 6 ? (280 + i - 6) : 132 + i, options != null ? options[i] : ItemDefinitions.getDefs(items[i]).getName()); } setMaxQuantity(player, maxQuantity); setQuantity(player, maxQuantity); player.getInterfaceManager().sendChatBoxInterface(905); player.getInterfaceManager().sendSubSpecific(true, 905, 4, 916); } public static ButtonClickHandler handleSetQuantityButtons = new ButtonClickHandler(916, e -> { if (e.getComponentId() == 10) setQuantity(e.getPlayer(), 1, true); else if (e.getComponentId() == 11) setQuantity(e.getPlayer(), 5, true); else if (e.getComponentId() == 12) setQuantity(e.getPlayer(), 10, true); else if (e.getComponentId() == 8) setQuantity(e.getPlayer(), getMaxQuantity(e.getPlayer()), true); else if (e.getComponentId() == 24) setQuantity(e.getPlayer(), getQuantity(e.getPlayer()) + 1, true); else if (e.getComponentId() == 25) setQuantity(e.getPlayer(), getQuantity(e.getPlayer()) - 1, true); }); @Override public int getOptionId(int componentId) { if (componentId < 14) return 0; if (componentId == 26) return 7; if (componentId >= 21) return componentId - 13; return componentId - 14; } public static void setMaxQuantity(Player player, int maxQuantity) { player.getVars().setVarBit(8094, maxQuantity); } public static void setQuantity(Player player, int quantity) { setQuantity(player, quantity, true); } public static void setQuantity(Player player, int quantity, boolean refresh) { int maxQuantity = getMaxQuantity(player); if (quantity > maxQuantity) quantity = maxQuantity; else if (quantity < 0) quantity = 0; if (refresh) player.getVars().setVarBit(8095, quantity); } public static int getMaxQuantity(Player player) { return player.getVars().getVarBit(8094); } public static int getQuantity(Player player) { if (player.getVars().getVarBit(8094) <= 0) return 60; return player.getVars().getVarBit(8095); } @Override public void close(Player player) { } }" "package com.rs.engine.dialogue.statements; public class NPCStatement implements Statement { private final String nameOverride; private final int npcId; private final HeadE emote; private final String[] texts; public NPCStatement(String nameOverride, int npcId, HeadE emote, String... texts) { this.nameOverride = nameOverride; this.npcId = npcId; this.emote = emote; this.texts = texts; } public NPCStatement(int npcId, HeadE emote, String... texts) { this(null, npcId, emote, texts); } @Override public void send(Player player) { StringBuilder builder = new StringBuilder(); for (String text2 : texts) builder.append("" "").append(text2); String text = builder.toString(); player.getInterfaceManager().sendChatBoxInterface(1184); player.getPackets().setIFText(1184, 17, nameOverride != null ? nameOverride : NPCDefinitions.getDefs(npcId, player.getVars()).getName()); player.getPackets().setIFText(1184, 13, text); player.getPackets().setIFNPCHead(1184, 11, npcId); if (emote != null && emote.getEmoteId() != -1) player.getPackets().setIFAnimation(emote.getEmoteId(), 1184, 11); } @Override public int getOptionId(int componentId) { return 0; } @Override public void close(Player player) { } }" "package com.rs.engine.dialogue.statements; public class OptionStatement implements Statement { private final String title; private final String[] options; public OptionStatement(String title, String... options) { this.title = title; if (options.length > 5) throw new InvalidParameterException(""The max options length is 5.""); this.options = options; } @Override public void send(Player player) { String[] optionArray = new String[5]; for (int i = 0; i < 5; i++) optionArray[i] = """"; int ptr = 0; for (String s : options) if (s != null) optionArray[ptr++] = s; player.getInterfaceManager().sendChatBoxInterface(1188); player.getPackets().setIFText(1188, 20, title != null ? title : ""Select an Option""); player.getPackets().sendRunScriptReverse(5589, optionArray[4], optionArray[3], optionArray[2], optionArray[1], optionArray[0], options.length); } @Override public int getOptionId(int componentId) { return componentId == 11 ? 0 : componentId-12; } @Override public void close(Player player) { } }" "package com.rs.engine.dialogue.statements; public class PlayerStatement implements Statement { private final HeadE emote; private final String[] texts; public PlayerStatement(HeadE emote, String... texts) { this.emote = emote; this.texts = texts; } @Override public void send(Player player) { StringBuilder builder = new StringBuilder(); for (String text2 : texts) builder.append("" "").append(text2); String text = builder.toString(); player.getInterfaceManager().sendChatBoxInterface(1191); player.getPackets().setIFText(1191, 8, player.getDisplayName()); player.getPackets().setIFText(1191, 17, text); player.getPackets().setIFPlayerHead(1191, 15); if (emote != null && emote.getEmoteId() != -1) player.getPackets().setIFAnimation(emote.getEmoteId(), 1191, 15); } @Override public int getOptionId(int componentId) { return 0; } @Override public void close(Player player) { } }" "package com.rs.engine.dialogue.statements; public class QuestStartStatement implements Statement { private final Quest quest; public QuestStartStatement(Quest quest) { this.quest = quest; } @Override public void send(Player player) { quest.openQuestInfo(player, true); } @Override public int getOptionId(int componentId) { return switch(componentId) { case 46 -> 0; default -> 1; }; } @Override public void close(Player player) { if (player.getInterfaceManager().containsScreenInter()) player.getInterfaceManager().removeCentralInterface(); } }" "package com.rs.engine.dialogue.statements; public class SimpleStatement implements Statement { private final String[] texts; public SimpleStatement(String... texts) { this.texts = texts; } @Override public void send(Player player) { StringBuilder builder = new StringBuilder(); for (int line = 0; line < texts.length; line++) builder.append(line == 0 ? """" : ""
"").append(texts[line]); String text = builder.toString(); player.getInterfaceManager().sendChatBoxInterface(1186); player.getPackets().setIFText(1186, 1, text); } @Override public int getOptionId(int componentId) { return 0; } @Override public void close(Player player) { } }" "package com.rs.engine.dialogue.statements; public interface Statement { void send(Player player); int getOptionId(int componentId); void close(Player player); }" "package com.rs.engine.miniquest; public enum Miniquest { ENTER_THE_ABYSS(""Enter the Abyss"", new Quest[]{Quest.RUNE_MYSTERIES}, null, null, null), KNIGHTS_WAVE_TRAINING_GROUNDS(""Knights Waves Training Grounds"", new Quest[]{Quest.KINGS_RANSOM}, null, null, null), TROLL_WARZONE(""Troll Warzone Tutorial"", null, null, null, null), WITCHES_POTION(""Witch's Potion"", null, null, null, null), HUNT_FOR_SUROK(""The Hunt for Surok"", new Quest[]{Quest.WHAT_LIES_BELOW}, null, Map.of(Skills.MINING, 42, Skills.PRAYER, 43), null), FROM_TINY_ACORNS(""From Tiny Acorns"", new Quest[] { Quest.BUYERS_AND_CELLARS }, null, Map.of(Skills.THIEVING, 24), null), LOST_HER_MARBLES(""Lost Her Marbles"", null, new Miniquest[] { Miniquest.FROM_TINY_ACORNS }, Map.of(Skills.THIEVING, 41), null), A_GUILD_OF_OUR_OWN(""A Guild of Our Own"", null, new Miniquest[] { Miniquest.LOST_HER_MARBLES }, Map.of(Skills.THIEVING, 62, Skills.HERBLORE, 46, Skills.AGILITY, 40), null), BAR_CRAWL(""Alfred Grimhand's Barcrawl"", null, null, null, null) ; static { initializeHandlers(); } public static void initializeHandlers() { try { List> classes = Utils.getClassesWithAnnotation(""com.rs"", MiniquestHandler.class); for (Class clazz : classes) { MiniquestHandler handler = clazz.getAnnotation(MiniquestHandler.class); if (handler == null || clazz.getSuperclass() != MiniquestOutline.class) continue; handler.miniquest().handler = (MiniquestOutline) clazz.getConstructor().newInstance(); } } catch (ClassNotFoundException | IOException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException e) { e.printStackTrace(); } } private final String name; private final Quest[] questPreReqs; private final Miniquest[] miniquestPreReqs; private final Map skillReqs; private MiniquestOutline handler; Miniquest(String name, Quest[] questPreReqs, Miniquest[] miniquestPreReqs, Map skillReqs, Function canStart) { this.name = name; this.questPreReqs = questPreReqs; this.miniquestPreReqs = miniquestPreReqs; this.skillReqs = skillReqs; } public boolean isImplemented() { return handler != null; } public MiniquestOutline getHandler() { return handler; } public boolean meetsReqs(Player player) { return meetsReqs(player, null, false); } public boolean meetsReqs(Player player, String actionStr, boolean outputReqs) { boolean meetsRequirements = true; if (questPreReqs != null) { for (Quest preReq : questPreReqs) { if (!player.isQuestComplete(preReq, actionStr)) { if (outputReqs) player.sendMessage(""You need to complete "" + preReq.getDefs().name + "" first.""); meetsRequirements = false; } } } if (miniquestPreReqs != null) { for (Miniquest preReq : miniquestPreReqs) { if (!player.isMiniquestComplete(preReq, actionStr, outputReqs)) { if (outputReqs) player.sendMessage(""You need to complete "" + preReq.getName() + "" first.""); meetsRequirements = false; } } } if (skillReqs != null) { for (int skillId : skillReqs.keySet()) { if (player.getSkills().getLevelForXp(skillId) < skillReqs.get(skillId)) { if (actionStr != null) player.sendMessage(""You need a "" + Skills.SKILL_NAME[skillId] + "" level of "" + skillReqs.get(skillId) + "".""); meetsRequirements = false; } } } if (!meetsRequirements && actionStr != null) if (outputReqs) player.sendMessage(""You must meet the requirements for the miniquest: "" + getName() + "" "" + actionStr); return meetsRequirements; } public String getName() { return name; } }" "package com.rs.engine.miniquest; @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.TYPE) public @interface MiniquestHandler { Miniquest miniquest(); String startText(); String itemsText(); String combatText(); String rewardsText(); int completedStage(); }" "package com.rs.engine.miniquest; @PluginEventHandler public class MiniquestManager { private transient Player player; private final Map questStages; private final Map questAttribs; public MiniquestManager() { questStages = new HashMap<>(); questAttribs = new HashMap<>(); } public int getStage(Miniquest quest) { if (questStages.get(quest) == null) return 0; return questStages.get(quest); } public void setStage(Miniquest quest, int stage) { setStage(quest, stage, true); } public void setStage(Miniquest quest, int stage, boolean updateJournal) { if (!quest.isImplemented()) return; questStages.put(quest, stage); if (updateJournal) sendStage(quest); } public void complete(Miniquest quest) { if (!quest.isImplemented()) return; if (!isComplete(quest)) { setStage(quest, quest.getHandler().getCompletedStage()); clearQuestAttributes(quest); quest.getHandler().complete(player); sendStage(quest); } } public void reset(Miniquest quest) { if (!quest.isImplemented()) return; clearQuestAttributes(quest); setStage(quest, 0); } private void clearQuestAttributes(Miniquest quest) { questAttribs.remove(quest); } public GenericAttribMap getAttribs(Miniquest quest) { GenericAttribMap map = questAttribs.computeIfAbsent(quest, k -> new GenericAttribMap()); return map; } public boolean completedAll() { for (Miniquest quest : Miniquest.values()) { if (!quest.isImplemented()) continue; if (!isComplete(quest)) return false; } return true; } public boolean isComplete(Miniquest quest, String actionForUnimplemented, boolean outputReqs) { if (!quest.isImplemented()) return quest.meetsReqs(player, actionForUnimplemented, outputReqs); if (getStage(quest) == quest.getHandler().getCompletedStage()) return true; if (actionForUnimplemented != null) if (outputReqs) player.sendMessage(""You must have completed "" + quest.getName() + "" "" + actionForUnimplemented); return false; } public boolean isComplete(Miniquest quest) { return isComplete(quest, null, false); } public boolean isComplete(Miniquest quest, boolean outputReqs) { return isComplete(quest, null, outputReqs); } public void updateAllStages() { for (Miniquest quest : Miniquest.values()) sendStage(quest); } public void sendStage(Miniquest quest) { if (quest.getHandler() != null) quest.getHandler().updateStage(player); } public Player getPlayer() { return player; } public void setPlayer(Player player) { this.player = player; } }" "package com.rs.engine.miniquest; public abstract class MiniquestOutline { public final Miniquest getMiniquest() { return getClass().getAnnotation(MiniquestHandler.class).miniquest(); } public final int getCompletedStage() { return getClass().getAnnotation(MiniquestHandler.class).completedStage(); } public abstract List getJournalLines(Player player, int stage); public abstract void complete(Player player); public abstract void updateStage(Player player); public final String getStartLocationDescription() { return getClass().getAnnotation(MiniquestHandler.class).startText(); } public final String getRequiredItemsString() { return getClass().getAnnotation(MiniquestHandler.class).itemsText(); } public final String getCombatInformationString() { return getClass().getAnnotation(MiniquestHandler.class).combatText(); } public final String getRewardsString() { return getClass().getAnnotation(MiniquestHandler.class).rewardsText(); } public final void sendQuestCompleteInterface(Player player, int itemId) { int jingleNum = Utils.random(0, 4); if(jingleNum == 3) jingleNum = 318; else jingleNum+=152; player.jingle(jingleNum); player.getPackets().sendVarcString(359, getRewardsString()); player.getInterfaceManager().sendInterface(1244); player.getPackets().setIFItem(1244, 24, itemId, 1); player.getPackets().setIFText(1244, 25, ""You have completed ""+getMiniquest().getName()+""!""); } }" "package com.rs.engine.pathfinder /** * @author Kris | 16/03/2022 */ @Suppress(""MemberVisibilityCanBePrivate"") @JvmInline public value class AbsoluteCoords(public val packedCoord: Int) { public constructor( x: Int, y: Int, z: Int, ) : this((y and 0x3FFF) or ((x and 0x3FFF) shl 14) or ((z and 0x3) shl 28)) public val x: Int get() = (packedCoord shr 14) and 0x3FFF public val y: Int get() = packedCoord and 0x3FFF public val z: Int get() = (packedCoord shr 28) and 0x3 /** * Converts these absolute coords to the zone coords in which these absolute coords are. */ public fun toZoneCoords(): ZoneCoords = ZoneCoords(x shr 3, y shr 3, z) override fun toString(): String = ""AbsoluteCoords($x, $y, $z)"" }" "package com.rs.engine.pathfinder enum class Direction(@JvmField val id: Int, @JvmField val dx: Int, @JvmField val dy: Int) { NORTH(0, 0, 1), NORTHEAST(1, 1, 1), EAST(2, 1, 0), SOUTHEAST(3, 1, -1), SOUTH(4, 0, -1), SOUTHWEST(5, -1, -1), WEST(6, -1, 0), NORTHWEST(7, -1, 1); val angle: Int get() = Utils.getAngleTo(dx, dy) val isDiagonal: Boolean get() = dx != 0 && dy != 0 companion object { @JvmStatic fun random(): Direction { return entries[Utils.random(entries.size)] } @JvmStatic fun getById(id: Int): Direction { return when (id) { 0 -> NORTH 1 -> NORTHEAST 2 -> EAST 3 -> SOUTHEAST 4 -> SOUTH 5 -> SOUTHWEST 6 -> WEST 7 -> NORTHWEST else -> SOUTH } } @JvmStatic fun rotateClockwise(dir: Direction, rotation: Int): Direction { return getById((dir.id + rotation) and 0x7) } @JvmStatic fun fromAngle(angle: Int): Direction? { val delta = Utils.getDirection(angle) ?: return SOUTH return forDelta(delta[0].toInt(), delta[1].toInt()) } @JvmStatic fun forDelta(dx: Int, dy: Int): Direction? { if (dy >= 1 && dx >= 1) return NORTHEAST if (dy <= -1 && dx >= 1) return SOUTHEAST return if (dy <= -1 && dx <= -1) SOUTHWEST else if (dy >= 1 && dx <= -1) NORTHWEST else if (dy >= 1) NORTH else if (dx >= 1) EAST else if (dy <= -1) SOUTH else if (dx <= -1) WEST else null } @JvmStatic fun getAngleTo(dir: Direction): Int { return ((atan2(-dir.dx.toDouble(), -dir.dy.toDouble()) * 2607.5945876176133).toInt()) and 0x3fff } fun getFaceDirection(faceTile: Tile, player: Player): Direction { if (player.x < faceTile.x) return EAST if (player.x > faceTile.x) return WEST return if (player.y < faceTile.y) NORTH else if (player.y > faceTile.y) SOUTH else NORTH } @JvmStatic fun getDirectionTo(entity: Entity, target: Any): Direction? { val from = entity.middleTileAsVector val to = if (target is Entity) target.middleTileAsVector else Vec2(target as Tile) val sub = to.sub(from) sub.norm() val delta = sub.toTile() return forDelta(delta.x, delta.y) } } }" "package com.rs.engine.pathfinder object DumbRouteFinder { @JvmStatic fun addDumbPathfinderSteps(entity: Entity, target: Any, collision: CollisionStrategy): Boolean { return addDumbPathfinderSteps(entity, target, 25, collision) } @JvmStatic fun addDumbPathfinderSteps(entity: Entity, target: Any, maxSize: Int, collision: CollisionStrategy): Boolean { val tiles = find(entity, target, maxSize, collision) if (tiles.size > 0) { var last = Tile.of(entity.tile) //World.sendSpotAnim(null, new SpotAnim(2000), last); for (t in tiles) { //World.sendSpotAnim(null, new SpotAnim(2000), t); entity.addWalkStep(t.x, t.y, last.x, last.y, true) last = t } return true } return false } private fun find(origin: Any, target: Any, maxSize: Int, collision: CollisionStrategy): Deque { val originTile = WorldUtil.targetToTile(origin) val targetTile = WorldUtil.targetToTile(target) val size = if (origin is Entity) origin.size else 1 var real = Tile.of(originTile) var curr = if (origin is Entity) origin.middleTile else Tile.of(originTile) val targ = if (target is Entity) target.middleTile else Tile.of(targetTile) val positions: Deque = ArrayDeque(maxSize) val step = StepValidator(WorldCollision.allFlags) while (true) { val from = Tile.of(curr) if (curr.x < targ.x && curr.y < targ.y) { if (step.canTravel(real.plane, real.x, real.y, 1, 1, size, 0, collision)) { real = add(positions, real.transform(1, 1)) curr = curr.transform(1, 1) } else if (step.canTravel(real.plane, real.x, real.y, 1, 0, size, 0, collision)) { real = add(positions, real.transform(1, 0)) curr = curr.transform(1, 0) } else if (step.canTravel(real.plane, real.x, real.y, 0, 1, size, 0, collision)) { real = add(positions, real.transform(0, 1)) curr = curr.transform(0, 1) } } else if (curr.x > targ.x && curr.y > targ.y) { if (step.canTravel(real.plane, real.x, real.y, -1, -1, size, 0, collision)) { real = add(positions, real.transform(-1, -1)) curr = curr.transform(-1, -1) } else if (step.canTravel(real.plane, real.x, real.y, -1, 0, size, 0, collision)) { real = add(positions, real.transform(-1, 0)) curr = curr.transform(-1, 0) } else if (step.canTravel(real.plane, real.x, real.y, 0, -1, size, 0, collision)) { real = add(positions, real.transform(0, -1)) curr = curr.transform(0, -1) } } else if (curr.x < targ.x && curr.y > targ.y) { if (step.canTravel(real.plane, real.x, real.y, 1, -1, size, 0, collision)) { real = add(positions, real.transform(1, -1)) curr = curr.transform(1, -1) } else if (step.canTravel(real.plane, real.x, real.y, 1, 0, size, 0, collision)) { real = add(positions, real.transform(1, 0)) curr = curr.transform(1, 0) } else if (step.canTravel(real.plane, real.x, real.y, 0, -1, size, 0, collision)) { real = add(positions, real.transform(0, -1)) curr = curr.transform(0, -1) } } else if (curr.x > targ.x && curr.y < targ.y) { if (step.canTravel(real.plane, real.x, real.y, -1, 1, size, 0, collision)) { real = add(positions, real.transform(-1, 1)) curr = curr.transform(-1, 1) } else if (step.canTravel(real.plane, real.x, real.y, -1, 0, size, 0, collision)) { real = add(positions, real.transform(-1, 0)) curr = curr.transform(-1, 0) } else if (step.canTravel(real.plane, real.x, real.y, 0, 1, size, 0, collision)) { real = add(positions, real.transform(0, 1)) curr = curr.transform(0, 1) } } else if (curr.x < targ.x) { if (step.canTravel(real.plane, real.x, real.y, 1, 0, size, 0, collision)) { real = add(positions, real.transform(1, 0)) curr = curr.transform(1, 0) } } else if (curr.x > targ.x) { if (step.canTravel(real.plane, real.x, real.y, -1, 0, size, 0, collision)) { real = add(positions, real.transform(-1, 0)) curr = curr.transform(-1, 0) } } else if (curr.y < targ.y) { if (step.canTravel(real.plane, real.x, real.y, 0, 1, size, 0, collision)) { real = add(positions, real.transform(0, 1)) curr = curr.transform(0, 1) } } else if (curr.y > targ.y) if (step.canTravel(real.plane, real.x, real.y, 0, -1, size, 0, collision)) { real = add(positions, real.transform(0, -1)) curr = curr.transform(0, -1) } if (curr.matches(from)) break } return positions } private fun add(positions: Deque, att: Tile): Tile { positions.add(att) return att } }" "/* * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, this * list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ""AS IS"" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ @file:Suppress(""MemberVisibilityCanBePrivate"", ""DuplicatedCode"") package com.rs.engine.pathfinder public class LineValidator( public val searchMapSize: Int = DEFAULT_SEARCH_MAP_SIZE, private val flags: Array, ) { public fun hasLineOfSight( srcX: Int, srcY: Int, z: Int, destX: Int, destY: Int, srcSize: Int = 1, destWidth: Int = 0, destHeight: Int = 0 ): Boolean { val route = rayCast( srcX, srcY, z, destX, destY, srcSize, destWidth, destHeight, SIGHT_BLOCKED_WEST, SIGHT_BLOCKED_EAST, SIGHT_BLOCKED_SOUTH, SIGHT_BLOCKED_NORTH, true ) return route.success } public fun hasLineOfWalk( srcX: Int, srcY: Int, z: Int, destX: Int, destY: Int, srcSize: Int = 1, destWidth: Int = 0, destHeight: Int = 0 ): Boolean { val route = rayCast( srcX, srcY, z, destX, destY, srcSize, destWidth, destHeight, WALK_BLOCKED_WEST, WALK_BLOCKED_EAST, WALK_BLOCKED_SOUTH, WALK_BLOCKED_NORTH, false ) return route.success } private fun rayCast( srcX: Int, srcY: Int, z: Int, destX: Int, destY: Int, srcSize: Int = 1, destWidth: Int = 0, destHeight: Int = 0, flagWest: Int, flagEast: Int, flagSouth: Int, flagNorth: Int, los: Boolean, ): Route { val halfMap = searchMapSize / 2 val baseX = srcX - halfMap val baseY = srcY - halfMap val localSrcX = srcX - baseX val localSrcY = srcY - baseY val localDestX = destX - baseX val localDestY = destY - baseY val startX = coordinate(localSrcX, localDestX, srcSize) val startY = coordinate(localSrcY, localDestY, srcSize) if (los && flags.isFlagged(baseX, baseY, startX, startY, z, CollisionFlag.OBJECT)) { return FAILED_ROUTE } val endX = coordinate(localDestX, localSrcX, destWidth) val endY = coordinate(localDestY, localSrcY, destHeight) if (startX == endX && startY == endY) return SUCCESSFUL_ROUTE val deltaX = endX - startX val deltaY = endY - startY val travelEast = deltaX >= 0 val travelNorth = deltaY >= 0 var xFlags = if (travelEast) flagWest else flagEast var yFlags = if (travelNorth) flagSouth else flagNorth if (abs(deltaX) > abs(deltaY)) { val offsetX = if (travelEast) 1 else -1 val offsetY = if (travelNorth) 0 else -1 var scaledY = scaleUp(startY) + HALF_TILE + offsetY val tangent = scaleUp(deltaY) / abs(deltaX) var currX = startX while (currX != endX) { currX += offsetX val currY = scaleDown(scaledY) if (los && currX == endX && currY == endY) xFlags = xFlags and LAST_TILE_EXCLUDED_FLAGS.inv() if (flags.isFlagged(baseX, baseY, currX, currY, z, xFlags)) { return FAILED_ROUTE } scaledY += tangent val nextY = scaleDown(scaledY) if (los && currX == endX && nextY == endY) yFlags = yFlags and LAST_TILE_EXCLUDED_FLAGS.inv() if (nextY != currY && flags.isFlagged(baseX, baseY, currX, nextY, z, yFlags)) { return FAILED_ROUTE } } } else { val offsetX = if (travelEast) 0 else -1 val offsetY = if (travelNorth) 1 else -1 var scaledX = scaleUp(startX) + HALF_TILE + offsetX val tangent = scaleUp(deltaX) / abs(deltaY) var currY = startY while (currY != endY) { currY += offsetY val currX = scaleDown(scaledX) if (los && currX == endX && currY == endY) yFlags = yFlags and LAST_TILE_EXCLUDED_FLAGS.inv() if (flags.isFlagged(baseX, baseY, currX, currY, z, yFlags)) { return FAILED_ROUTE } scaledX += tangent val nextX = scaleDown(scaledX) if (los && nextX == endX && currY == endY) xFlags = xFlags and LAST_TILE_EXCLUDED_FLAGS.inv() if (nextX != currX && flags.isFlagged(baseX, baseY, nextX, currY, z, xFlags)) { return FAILED_ROUTE } } } return SUCCESSFUL_ROUTE } private fun coordinate(a: Int, b: Int, size: Int): Int { return when { a >= b -> a a + size - 1 <= b -> a + size - 1 else -> b } } private fun Array.isFlagged( baseX: Int, baseY: Int, x: Int, y: Int, z: Int, flags: Int ): Boolean { return (this[baseX, baseY, x, y, z] and flags) != 0 } @Suppress(""NOTHING_TO_INLINE"") private inline operator fun Array.get( baseX: Int, baseY: Int, localX: Int, localY: Int, z: Int ): Int { val x = baseX + localX val y = baseY + localY val zone = this[getZoneIndex(x, y, z)] ?: return -1 return zone[getIndexInZone(x, y)] } @Suppress(""NOTHING_TO_INLINE"") private inline operator fun IntArray.get(x: Int, y: Int): Int { val index = (y * searchMapSize) + x return this[index] } private companion object { private val FAILED_ROUTE = Route(ArrayDeque(), alternative = false, success = false) private val SUCCESSFUL_ROUTE = Route(ArrayDeque(), alternative = false, success = true) private const val LAST_TILE_EXCLUDED_FLAGS = OBJECT_PROJECTILE_BLOCKER or BLOCK_PLAYERS private const val SIGHT_BLOCKED_NORTH = OBJECT_PROJECTILE_BLOCKER .or(WALL_NORTH_PROJECTILE_BLOCKER) .or(BLOCK_PLAYERS) private const val SIGHT_BLOCKED_EAST = OBJECT_PROJECTILE_BLOCKER .or(WALL_EAST_PROJECTILE_BLOCKER) .or(BLOCK_PLAYERS) private const val SIGHT_BLOCKED_SOUTH = OBJECT_PROJECTILE_BLOCKER .or(WALL_SOUTH_PROJECTILE_BLOCKER) .or(BLOCK_PLAYERS) private const val SIGHT_BLOCKED_WEST = OBJECT_PROJECTILE_BLOCKER .or(WALL_WEST_PROJECTILE_BLOCKER) .or(BLOCK_PLAYERS) private const val WALK_BLOCKED_NORTH = CollisionFlag.WALL_NORTH .or(CollisionFlag.OBJECT) .or(CollisionFlag.FLOOR_DECORATION) .or(CollisionFlag.FLOOR) .or(BLOCK_PLAYERS) private const val WALK_BLOCKED_EAST = CollisionFlag.WALL_EAST .or(CollisionFlag.OBJECT) .or(CollisionFlag.FLOOR_DECORATION) .or(CollisionFlag.FLOOR) .or(BLOCK_PLAYERS) private const val WALK_BLOCKED_SOUTH = CollisionFlag.WALL_SOUTH .or(CollisionFlag.OBJECT) .or(CollisionFlag.FLOOR_DECORATION) .or(CollisionFlag.FLOOR) .or(BLOCK_PLAYERS) private const val WALK_BLOCKED_WEST = CollisionFlag.WALL_WEST .or(CollisionFlag.OBJECT) .or(CollisionFlag.FLOOR_DECORATION) .or(CollisionFlag.FLOOR) .or(BLOCK_PLAYERS) private const val SCALE = 16 private val HALF_TILE = scaleUp(tiles = 1) / 2 private fun scaleUp(tiles: Int) = tiles shl SCALE private fun scaleDown(tiles: Int) = tiles ushr SCALE } }" "@file:Suppress(""MemberVisibilityCanBePrivate"") package com.rs.engine.pathfinder public data class Route( public val coords: ArrayDeque, public val alternative: Boolean, public val success: Boolean ) : List by coords { public val failed: Boolean get() = !success } @JvmInline public value class RouteCoordinates(public val packed: Int) { public val x: Int get() = packed and 0xFFFF public val y: Int get() = (packed shr 16) and 0xFFFF public constructor(x: Int, y: Int) : this( (x and 0xFFFF) or ((y and 0xFFFF) shl 16) ) public fun translate(xOffset: Int, yOffset: Int): RouteCoordinates { return RouteCoordinates( x = x + xOffset, y = y + yOffset ) } public fun translateX(offset: Int): RouteCoordinates = translate(offset, 0) public fun translateY(offset: Int): RouteCoordinates = translate(0, offset) override fun toString(): String { return ""${javaClass.simpleName}{x=$x, y=$y}"" } } public data class JavaRouteCoordinates(public val x: Int, public val y: Int) { public companion object { @JvmStatic fun of(coords: RouteCoordinates): JavaRouteCoordinates { return JavaRouteCoordinates(coords.x, coords.y) } @JvmStatic public fun of(coords: List): List { return coords.map { of(it) } } /** * RouteCoordinates helper function to avoid memory-creation * with [JavaRouteCoordinates.of]. */ @JvmStatic public fun getX(coords: RouteCoordinates): Int { return coords.x } /** * RouteCoordinates helper function to avoid memory-creation * with [JavaRouteCoordinates.of]. */ @JvmStatic public fun getY(coords: RouteCoordinates): Int { return coords.y } /** * RouteCoordinates helper function to avoid memory-creation * with [JavaRouteCoordinates.of]. */ @JvmStatic public fun translate(coords: RouteCoordinates, xOffset: Int, yOffset: Int): RouteCoordinates { return coords.translate(xOffset, yOffset) } /** * RouteCoordinates helper function to avoid memory-creation * with [JavaRouteCoordinates.of]. */ @JvmStatic public fun translateX(coords: RouteCoordinates, offset: Int): RouteCoordinates { return coords.translateX(offset) } /** * RouteCoordinates helper function to avoid memory-creation * with [JavaRouteCoordinates.of]. */ @JvmStatic public fun translateY(coords: RouteCoordinates, offset: Int): RouteCoordinates { return coords.translateY(offset) } } }" "package com.rs.engine.pathfinder class RouteEvent(private val target: Any, private val onReachedEvent: Runnable, private val onNearestEvent: (() -> Boolean)?) { constructor(target: Any, event: Runnable): this(target, event, null) //F-U java //TODO add optimized boolean for stationary targets that doesn't recalculate the path to check status each time fun processEvent(entity: Entity): Boolean { if (!simpleCheck(entity)) { cantReachThat(entity as? Player) return true } val route = routeEntityTo(entity, target) if (route.failed || route.size <= 0) { if (route.failed) cantReachThat(entity as? Player) if (route.size <= 0) { (entity as? Player)?.session?.writeToQueue(MinimapFlag()) if (route.alternative) { return onNearestEvent?.invoke() ?: run { cantReachThat(entity as? Player) return true } } onReachedEvent.run() } return true } if (entity.hasEffect(Effect.FREEZE) || (target is Entity && target.hasWalkSteps() && WorldUtil.collides(entity, target))) return false entity.resetWalkSteps() addSteps(entity, route, true) return false } private fun simpleCheck(entity: Entity): Boolean { return when(target) { is Entity -> entity.plane == target.plane && !target.hasFinished() is GameObject -> entity.plane == target.plane && World.getObject(target.tile, target.type) != null is GroundItem -> entity.plane == target.tile.plane && ChunkManager.getChunk(target.tile.chunkId).itemExists(target) is Tile -> entity.plane == target.plane else -> throw RuntimeException(""$target is not instanceof any reachable entity."") } } val cantReachThat = { player: Player? -> player?.let { it.sendMessage(""You can't reach that."") it.session.writeToQueue(MinimapFlag()) } } }" "@file:Suppress(""DuplicatedCode"") package com.rs.engine.pathfinder private const val DEFAULT_RESET_ON_SEARCH = true internal const val DEFAULT_SEARCH_MAP_SIZE = 128 private const val DEFAULT_RING_BUFFER_SIZE = 4096 private const val DEFAULT_DISTANCE_VALUE = 999 // Default is 99_999_999 but it is unnecessary and we bitpack private const val DEFAULT_SRC_DIRECTION_VALUE = 99 private const val MAX_ALTERNATIVE_ROUTE_LOWEST_COST = 1000 private const val MAX_ALTERNATIVE_ROUTE_SEEK_RANGE = 100 private const val MAX_ALTERNATIVE_ROUTE_DISTANCE_FROM_DESTINATION = 10 private const val DEFAULT_MOVE_NEAR_FLAG = true private const val DEFAULT_ROUTE_BLOCKER_FLAGS = false private const val INITIAL_DEQUE_SIZE = 25 private const val DEFAULT_SRC_SIZE = 1 private const val DEFAULT_DEST_WIDTH = 1 private const val DEFAULT_DEST_HEIGHT = 1 private const val DEFAULT_MAX_TURNS = 25 private const val DEFAULT_OBJ_ROT = 10 private const val DEFAULT_OBJ_SHAPE = -1 private const val DEFAULT_ACCESS_BITMASK = 0 public class PathFinder( private val resetOnSearch: Boolean = DEFAULT_RESET_ON_SEARCH, private val searchMapSize: Int = DEFAULT_SEARCH_MAP_SIZE, private val ringBufferSize: Int = DEFAULT_RING_BUFFER_SIZE, private val graphInfo: IntArray = IntArray(searchMapSize * searchMapSize), private val validLocalCoords: IntArray = IntArray(ringBufferSize), private var bufReaderIndex: Int = 0, private var bufWriterIndex: Int = 0, private var currLocalX: Int = 0, private var currLocalY: Int = 0, private val useRouteBlockerFlags: Boolean = DEFAULT_ROUTE_BLOCKER_FLAGS, private val flags: Array, private val moveNear: Boolean = DEFAULT_MOVE_NEAR_FLAG, private val initialDequeSize: Int = INITIAL_DEQUE_SIZE, ) { public fun findPath( srcX: Int, srcY: Int, destX: Int, destY: Int, z: Int, srcSize: Int = DEFAULT_SRC_SIZE, destWidth: Int = DEFAULT_DEST_WIDTH, destHeight: Int = DEFAULT_DEST_HEIGHT, objRot: Int = DEFAULT_OBJ_ROT, objShape: Int = DEFAULT_OBJ_SHAPE, accessBitMask: Int = DEFAULT_ACCESS_BITMASK, maxTurns: Int = DEFAULT_MAX_TURNS, collision: CollisionStrategy = CollisionStrategyType.NORMAL.strategy, reachStrategy: ReachStrategy = DefaultReachStrategy ): Route { if (resetOnSearch) { reset() } val baseX = srcX - (searchMapSize / 2) val baseY = srcY - (searchMapSize / 2) val localSrcX = srcX - baseX val localSrcY = srcY - baseY val localDestX = destX - baseX val localDestY = destY - baseY setNextValidLocalCoords(localSrcX, localSrcY, DEFAULT_SRC_DIRECTION_VALUE, 0) val pathFound = if (useRouteBlockerFlags) { when (srcSize) { 1 -> findPath1RouteBlocker( baseX, baseY, z, localDestX, localDestY, destWidth, destHeight, srcSize, objRot, objShape, accessBitMask, collision, reachStrategy ) 2 -> findPath2RouteBlocker( baseX, baseY, z, localDestX, localDestY, destWidth, destHeight, srcSize, objRot, objShape, accessBitMask, collision, reachStrategy ) else -> findPathNRouteBlocker( baseX, baseY, z, localDestX, localDestY, destWidth, destHeight, srcSize, objRot, objShape, accessBitMask, collision, reachStrategy ) } } else { when (srcSize) { 1 -> findPath1( baseX, baseY, z, localDestX, localDestY, destWidth, destHeight, srcSize, objRot, objShape, accessBitMask, collision, reachStrategy ) 2 -> findPath2( baseX, baseY, z, localDestX, localDestY, destWidth, destHeight, srcSize, objRot, objShape, accessBitMask, collision, reachStrategy ) else -> findPathN( baseX, baseY, z, localDestX, localDestY, destWidth, destHeight, srcSize, objRot, objShape, accessBitMask, collision, reachStrategy ) } } if (!pathFound) { if (!moveNear) { return FAILED_ROUTE } else if (!findClosestApproachPoint(localDestX, localDestY, destWidth, destHeight)) { return FAILED_ROUTE } } val coordinates = ArrayDeque(initialDequeSize) var nextDir = getDirection(currLocalX, currLocalY) var currDir = -1 var turns = 0 for (i in 0 until searchMapSize * searchMapSize) { if (currLocalX == localSrcX && currLocalY == localSrcY) break if (currDir != nextDir) { turns++ if (coordinates.size >= maxTurns) coordinates.removeLast() val coords = RouteCoordinates(currLocalX + baseX, currLocalY + baseY) coordinates.addFirst(coords) currDir = nextDir } if ((currDir and DirectionFlag.EAST) != 0) { currLocalX++ } else if ((currDir and DirectionFlag.WEST) != 0) { currLocalX-- } if ((currDir and DirectionFlag.NORTH) != 0) { currLocalY++ } else if ((currDir and DirectionFlag.SOUTH) != 0) { currLocalY-- } nextDir = getDirection(currLocalX, currLocalY) } return Route(coordinates, alternative = !pathFound, success = true) } private fun findPath1( baseX: Int, baseY: Int, z: Int, localDestX: Int, localDestY: Int, destWidth: Int, destHeight: Int, srcSize: Int, objRot: Int, objShape: Int, accessBitMask: Int, collision: CollisionStrategy, reachStrategy: ReachStrategy ): Boolean { var x: Int var y: Int var clipFlag: Int var dirFlag: Int val relativeSearchSize = searchMapSize - 1 val validCoords = validLocalCoords val flags = flags while (bufWriterIndex != bufReaderIndex) { val coord = validCoords[bufReaderIndex] currLocalX = coord ushr 16 currLocalY = coord and 0xFFFF bufReaderIndex = (bufReaderIndex + 1) and (ringBufferSize - 1) if (reachStrategy.reached( flags, currLocalX + baseX, currLocalY + baseY, z, localDestX + baseX, localDestY + baseY, destWidth, destHeight, srcSize, objRot, objShape, accessBitMask, ) ) { return true } val nextDistance = getDistance(currLocalX, currLocalY) + 1 /* east to west */ x = currLocalX - 1 y = currLocalY clipFlag = CollisionFlag.BLOCK_WEST dirFlag = DirectionFlag.EAST if (currLocalX > 0 && getDirection(x, y) == 0 && collision.canMove( flags[baseX, baseY, x, y, z], clipFlag ) ) { setNextValidLocalCoords(x, y, dirFlag, nextDistance) } /* west to east */ x = currLocalX + 1 y = currLocalY clipFlag = CollisionFlag.BLOCK_EAST dirFlag = DirectionFlag.WEST if (currLocalX < relativeSearchSize && getDirection(x, y) == 0 && collision.canMove(flags[baseX, baseY, x, y, z], clipFlag) ) { setNextValidLocalCoords(x, y, dirFlag, nextDistance) } /* north to south */ x = currLocalX y = currLocalY - 1 clipFlag = CollisionFlag.BLOCK_SOUTH dirFlag = DirectionFlag.NORTH if (currLocalY > 0 && getDirection(x, y) == 0 && collision.canMove( flags[baseX, baseY, x, y, z], clipFlag ) ) { setNextValidLocalCoords(x, y, dirFlag, nextDistance) } /* south to north */ x = currLocalX y = currLocalY + 1 clipFlag = CollisionFlag.BLOCK_NORTH dirFlag = DirectionFlag.SOUTH if (currLocalY < relativeSearchSize && getDirection(x, y) == 0 && collision.canMove(flags[baseX, baseY, x, y, z], clipFlag) ) { setNextValidLocalCoords(x, y, dirFlag, nextDistance) } /* north-east to south-west */ x = currLocalX - 1 y = currLocalY - 1 dirFlag = DirectionFlag.NORTH_EAST if (currLocalX > 0 && currLocalY > 0 && getDirection(x, y) == 0 && collision.canMove(flags[baseX, baseY, x, y, z], CollisionFlag.BLOCK_SOUTH_WEST) && collision.canMove( flags[baseX, baseY, x, currLocalY, z], CollisionFlag.BLOCK_WEST ) && collision.canMove(flags[baseX, baseY, currLocalX, y, z], CollisionFlag.BLOCK_SOUTH) ) { setNextValidLocalCoords(x, y, dirFlag, nextDistance) } /* north-west to south-east */ x = currLocalX + 1 y = currLocalY - 1 dirFlag = DirectionFlag.NORTH_WEST if (currLocalX < relativeSearchSize && currLocalY > 0 && getDirection(x, y) == 0 && collision.canMove(flags[baseX, baseY, x, y, z], CollisionFlag.BLOCK_SOUTH_EAST) && collision.canMove( flags[baseX, baseY, x, currLocalY, z], CollisionFlag.BLOCK_EAST ) && collision.canMove(flags[baseX, baseY, currLocalX, y, z], CollisionFlag.BLOCK_SOUTH) ) { setNextValidLocalCoords(x, y, dirFlag, nextDistance) } /* south-east to north-west */ x = currLocalX - 1 y = currLocalY + 1 dirFlag = DirectionFlag.SOUTH_EAST if (currLocalX > 0 && currLocalY < relativeSearchSize && getDirection(x, y) == 0 && collision.canMove(flags[baseX, baseY, x, y, z], CollisionFlag.BLOCK_NORTH_WEST) && collision.canMove( flags[baseX, baseY, x, currLocalY, z], CollisionFlag.BLOCK_WEST ) && collision.canMove(flags[baseX, baseY, currLocalX, y, z], CollisionFlag.BLOCK_NORTH) ) { setNextValidLocalCoords(x, y, dirFlag, nextDistance) } /* south-west to north-east */ x = currLocalX + 1 y = currLocalY + 1 dirFlag = DirectionFlag.SOUTH_WEST if (currLocalX < relativeSearchSize && currLocalY < relativeSearchSize && getDirection(x, y) == 0 && collision.canMove(flags[baseX, baseY, x, y, z], CollisionFlag.BLOCK_NORTH_EAST) && collision.canMove( flags[baseX, baseY, x, currLocalY, z], CollisionFlag.BLOCK_EAST ) && collision.canMove(flags[baseX, baseY, currLocalX, y, z], CollisionFlag.BLOCK_NORTH) ) { setNextValidLocalCoords(x, y, dirFlag, nextDistance) } } return false } private fun findPath2( baseX: Int, baseY: Int, z: Int, localDestX: Int, localDestY: Int, destWidth: Int, destHeight: Int, srcSize: Int, objRot: Int, objShape: Int, accessBitMask: Int, collision: CollisionStrategy, reachStrategy: ReachStrategy ): Boolean { var x: Int var y: Int var dirFlag: Int val relativeSearchSize = searchMapSize - 2 val validCoords = validLocalCoords val flags = flags while (bufWriterIndex != bufReaderIndex) { val coord = validCoords[bufReaderIndex] currLocalX = coord ushr 16 currLocalY = coord and 0xFFFF bufReaderIndex = (bufReaderIndex + 1) and (ringBufferSize - 1) if (reachStrategy.reached( flags, currLocalX + baseX, currLocalY + baseY, z, localDestX + baseX, localDestY + baseY, destWidth, destHeight, srcSize, objRot, objShape, accessBitMask, ) ) { return true } val nextDistance = getDistance(currLocalX, currLocalY) + 1 /* east to west */ x = currLocalX - 1 y = currLocalY dirFlag = DirectionFlag.EAST if (currLocalX > 0 && getDirection(x, y) == 0 && collision.canMove(flags[baseX, baseY, x, y, z], CollisionFlag.BLOCK_SOUTH_WEST) && collision.canMove( flags[baseX, baseY, x, currLocalY + 1, z], CollisionFlag.BLOCK_NORTH_WEST ) ) { setNextValidLocalCoords(x, y, dirFlag, nextDistance) } /* west to east */ x = currLocalX + 1 y = currLocalY dirFlag = DirectionFlag.WEST if (currLocalX < relativeSearchSize && getDirection(x, y) == 0 && collision.canMove( flags[baseX, baseY, currLocalX + 2, y, z], CollisionFlag.BLOCK_SOUTH_EAST ) && collision.canMove( flags[baseX, baseY, currLocalX + 2, currLocalY + 1, z], CollisionFlag.BLOCK_NORTH_EAST ) ) { setNextValidLocalCoords(x, y, dirFlag, nextDistance) } /* north to south */ x = currLocalX y = currLocalY - 1 dirFlag = DirectionFlag.NORTH if (currLocalY > 0 && getDirection(x, y) == 0 && collision.canMove(flags[baseX, baseY, x, y, z], CollisionFlag.BLOCK_SOUTH_WEST) && collision.canMove( flags[baseX, baseY, currLocalX + 1, y, z], CollisionFlag.BLOCK_SOUTH_EAST ) ) { setNextValidLocalCoords(x, y, dirFlag, nextDistance) } /* south to north */ x = currLocalX y = currLocalY + 1 dirFlag = DirectionFlag.SOUTH if (currLocalY < relativeSearchSize && getDirection(x, y) == 0 && collision.canMove( flags[baseX, baseY, x, currLocalY + 2, z], CollisionFlag.BLOCK_NORTH_WEST ) && collision.canMove( flags[baseX, baseY, currLocalX + 1, currLocalY + 2, z], CollisionFlag.BLOCK_NORTH_EAST ) ) { setNextValidLocalCoords(x, y, dirFlag, nextDistance) } /* north-east to south-west */ x = currLocalX - 1 y = currLocalY - 1 dirFlag = DirectionFlag.NORTH_EAST if (currLocalX > 0 && currLocalY > 0 && getDirection(x, y) == 0 && collision.canMove( flags[baseX, baseY, x, currLocalY, z], CollisionFlag.BLOCK_NORTH_AND_SOUTH_EAST ) && collision.canMove(flags[baseX, baseY, x, y, z], CollisionFlag.BLOCK_SOUTH_WEST) && collision.canMove( flags[baseX, baseY, currLocalX, y, z], CollisionFlag.BLOCK_NORTH_EAST_AND_WEST ) ) { setNextValidLocalCoords(x, y, dirFlag, nextDistance) } /* north-west to south-east */ x = currLocalX + 1 y = currLocalY - 1 dirFlag = DirectionFlag.NORTH_WEST if (currLocalX < relativeSearchSize && currLocalY > 0 && getDirection(x, y) == 0 && collision.canMove( flags[baseX, baseY, x, y, z], CollisionFlag.BLOCK_NORTH_EAST_AND_WEST ) && collision.canMove( flags[baseX, baseY, currLocalX + 2, y, z], CollisionFlag.BLOCK_SOUTH_EAST ) && collision.canMove( flags[baseX, baseY, currLocalX + 2, currLocalY, z], CollisionFlag.BLOCK_NORTH_AND_SOUTH_WEST ) ) { setNextValidLocalCoords(x, y, dirFlag, nextDistance) } /* south-east to north-west */ x = currLocalX - 1 y = currLocalY + 1 dirFlag = DirectionFlag.SOUTH_EAST if (currLocalX > 0 && currLocalY < relativeSearchSize && getDirection(x, y) == 0 && collision.canMove( flags[baseX, baseY, x, y, z], CollisionFlag.BLOCK_NORTH_AND_SOUTH_EAST ) && collision.canMove( flags[baseX, baseY, x, currLocalY + 2, z], CollisionFlag.BLOCK_NORTH_WEST ) && collision.canMove( flags[baseX, baseY, currLocalX, currLocalY + 2, z], CollisionFlag.BLOCK_SOUTH_EAST_AND_WEST ) ) { setNextValidLocalCoords(x, y, dirFlag, nextDistance) } /* south-west to north-east */ x = currLocalX + 1 y = currLocalY + 1 dirFlag = DirectionFlag.SOUTH_WEST if (currLocalX < relativeSearchSize && currLocalY < relativeSearchSize && getDirection(x, y) == 0 && collision.canMove( flags[baseX, baseY, x, currLocalY + 2, z], CollisionFlag.BLOCK_SOUTH_EAST_AND_WEST ) && collision.canMove( flags[baseX, baseY, currLocalX + 2, currLocalY + 2, z], CollisionFlag.BLOCK_NORTH_EAST ) && collision.canMove( flags[baseX, baseY, currLocalX + 2, y, z], CollisionFlag.BLOCK_NORTH_AND_SOUTH_WEST ) ) { setNextValidLocalCoords(x, y, dirFlag, nextDistance) } } return false } private fun findPathN( baseX: Int, baseY: Int, z: Int, localDestX: Int, localDestY: Int, destWidth: Int, destHeight: Int, srcSize: Int, objRot: Int, objShape: Int, accessBitMask: Int, collision: CollisionStrategy, reachStrategy: ReachStrategy ): Boolean { var x: Int var y: Int var dirFlag: Int val relativeSearchSize = searchMapSize - srcSize val validCoords = validLocalCoords val flags = flags while (bufWriterIndex != bufReaderIndex) { val coord = validCoords[bufReaderIndex] currLocalX = coord ushr 16 currLocalY = coord and 0xFFFF bufReaderIndex = (bufReaderIndex + 1) and (ringBufferSize - 1) if (reachStrategy.reached( flags, currLocalX + baseX, currLocalY + baseY, z, localDestX + baseX, localDestY + baseY, destWidth, destHeight, srcSize, objRot, objShape, accessBitMask, ) ) { return true } val nextDistance = getDistance(currLocalX, currLocalY) + 1 /* east to west */ x = currLocalX - 1 y = currLocalY dirFlag = DirectionFlag.EAST if (currLocalX > 0 && getDirection(x, y) == 0 && collision.canMove(flags[baseX, baseY, x, y, z], CollisionFlag.BLOCK_SOUTH_WEST) && collision.canMove( flags[baseX, baseY, x, currLocalY + srcSize - 1, z], CollisionFlag.BLOCK_NORTH_WEST ) ) { val clipFlag = CollisionFlag.BLOCK_NORTH_AND_SOUTH_EAST val blocked = (1 until srcSize - 1).any { !collision.canMove( flags[baseX, baseY, x, currLocalY + it, z], clipFlag ) } if (!blocked) { setNextValidLocalCoords(x, y, dirFlag, nextDistance) } } /* west to east */ x = currLocalX + 1 y = currLocalY dirFlag = DirectionFlag.WEST if (currLocalX < relativeSearchSize && getDirection(x, y) == 0 && collision.canMove( flags[baseX, baseY, currLocalX + srcSize, y, z], CollisionFlag.BLOCK_SOUTH_EAST ) && collision.canMove( flags[baseX, baseY, currLocalX + srcSize, currLocalY + srcSize - 1, z], CollisionFlag.BLOCK_NORTH_EAST ) ) { val clipFlag = CollisionFlag.BLOCK_NORTH_AND_SOUTH_WEST val blocked = (1 until srcSize - 1).any { !collision.canMove(flags[baseX, baseY, currLocalX + srcSize, currLocalY + it, z], clipFlag) } if (!blocked) { setNextValidLocalCoords(x, y, dirFlag, nextDistance) } } /* north to south */ x = currLocalX y = currLocalY - 1 dirFlag = DirectionFlag.NORTH if (currLocalY > 0 && getDirection(x, y) == 0 && collision.canMove(flags[baseX, baseY, x, y, z], CollisionFlag.BLOCK_SOUTH_WEST) && collision.canMove( flags[baseX, baseY, currLocalX + srcSize - 1, y, z], CollisionFlag.BLOCK_SOUTH_EAST ) ) { val clipFlag = CollisionFlag.BLOCK_NORTH_EAST_AND_WEST val blocked = (1 until srcSize - 1).any { !collision.canMove( flags[baseX, baseY, currLocalX + it, y, z], clipFlag ) } if (!blocked) { setNextValidLocalCoords(x, y, dirFlag, nextDistance) } } /* south to north */ x = currLocalX y = currLocalY + 1 dirFlag = DirectionFlag.SOUTH if (currLocalY < relativeSearchSize && getDirection(x, y) == 0 && collision.canMove( flags[baseX, baseY, x, currLocalY + srcSize, z], CollisionFlag.BLOCK_NORTH_WEST ) && collision.canMove( flags[baseX, baseY, currLocalX + srcSize - 1, currLocalY + srcSize, z], CollisionFlag.BLOCK_NORTH_EAST ) ) { val clipFlag = CollisionFlag.BLOCK_SOUTH_EAST_AND_WEST val blocked = (1 until srcSize - 1).any { !collision.canMove( flags[baseX, baseY, x + it, currLocalY + srcSize, z], clipFlag ) } if (!blocked) { setNextValidLocalCoords(x, y, dirFlag, nextDistance) } } /* north-east to south-west */ x = currLocalX - 1 y = currLocalY - 1 dirFlag = DirectionFlag.NORTH_EAST if (currLocalX > 0 && currLocalY > 0 && getDirection(x, y) == 0 && collision.canMove(flags[baseX, baseY, x, y, z], CollisionFlag.BLOCK_SOUTH_WEST) ) { val clipFlag1 = CollisionFlag.BLOCK_NORTH_AND_SOUTH_EAST val clipFlag2 = CollisionFlag.BLOCK_NORTH_EAST_AND_WEST val blocked = (1 until srcSize).any { !collision.canMove(flags[baseX, baseY, x, currLocalY + it - 1, z], clipFlag1) || !collision.canMove(flags[baseX, baseY, currLocalX + it - 1, y, z], clipFlag2) } if (!blocked) { setNextValidLocalCoords(x, y, dirFlag, nextDistance) } } /* north-west to south-east */ x = currLocalX + 1 y = currLocalY - 1 dirFlag = DirectionFlag.NORTH_WEST if (currLocalX < relativeSearchSize && currLocalY > 0 && getDirection(x, y) == 0 && collision.canMove( flags[baseX, baseY, currLocalX + srcSize, y, z], CollisionFlag.BLOCK_SOUTH_EAST ) ) { val clipFlag1 = CollisionFlag.BLOCK_NORTH_AND_SOUTH_WEST val clipFlag2 = CollisionFlag.BLOCK_NORTH_EAST_AND_WEST val blocked = (1 until srcSize).any { !collision.canMove(flags[baseX, baseY, currLocalX + srcSize, currLocalY + it - 1, z], clipFlag1) || !collision.canMove(flags[baseX, baseY, currLocalX + it, y, z], clipFlag2) } if (!blocked) { setNextValidLocalCoords(x, y, dirFlag, nextDistance) } } /* south-east to north-west */ x = currLocalX - 1 y = currLocalY + 1 dirFlag = DirectionFlag.SOUTH_EAST if (currLocalX > 0 && currLocalY < relativeSearchSize && getDirection(x, y) == 0 && collision.canMove( flags[baseX, baseY, x, currLocalY + srcSize, z], CollisionFlag.BLOCK_NORTH_WEST ) ) { val clipFlag1 = CollisionFlag.BLOCK_NORTH_AND_SOUTH_EAST val clipFlag2 = CollisionFlag.BLOCK_SOUTH_EAST_AND_WEST val blocked = (1 until srcSize).any { !collision.canMove(flags[baseX, baseY, x, currLocalY + it, z], clipFlag1) || !collision.canMove(flags[baseX, baseY, currLocalX + it - 1, currLocalY + srcSize, z], clipFlag2) } if (!blocked) { setNextValidLocalCoords(x, y, dirFlag, nextDistance) } } /* south-west to north-east */ x = currLocalX + 1 y = currLocalY + 1 dirFlag = DirectionFlag.SOUTH_WEST if (currLocalX < relativeSearchSize && currLocalY < relativeSearchSize && getDirection(x, y) == 0 && collision.canMove( flags[baseX, baseY, currLocalX + srcSize, currLocalY + srcSize, z], CollisionFlag.BLOCK_NORTH_EAST ) ) { val clipFlag1 = CollisionFlag.BLOCK_SOUTH_EAST_AND_WEST val clipFlag2 = CollisionFlag.BLOCK_NORTH_AND_SOUTH_WEST val blocked = (1 until srcSize).any { !collision.canMove(flags[baseX, baseY, currLocalX + it, currLocalY + srcSize, z], clipFlag1) || !collision.canMove(flags[baseX, baseY, currLocalX + srcSize, currLocalY + it, z], clipFlag2) } if (!blocked) { setNextValidLocalCoords(x, y, dirFlag, nextDistance) } } } return false } private fun findPath1RouteBlocker( baseX: Int, baseY: Int, z: Int, localDestX: Int, localDestY: Int, destWidth: Int, destHeight: Int, srcSize: Int, objRot: Int, objShape: Int, accessBitMask: Int, collision: CollisionStrategy, reachStrategy: ReachStrategy ): Boolean { var x: Int var y: Int var clipFlag: Int var dirFlag: Int val relativeSearchSize = searchMapSize - 1 val validCoords = validLocalCoords val flags = flags while (bufWriterIndex != bufReaderIndex) { val coord = validCoords[bufReaderIndex] currLocalX = coord ushr 16 currLocalY = coord and 0xFFFF bufReaderIndex = (bufReaderIndex + 1) and (ringBufferSize - 1) if (reachStrategy.reached( flags, currLocalX + baseX, currLocalY + baseY, z, localDestX + baseX, localDestY + baseY, destWidth, destHeight, srcSize, objRot, objShape, accessBitMask, ) ) { return true } val nextDistance = getDistance(currLocalX, currLocalY) + 1 /* east to west */ x = currLocalX - 1 y = currLocalY clipFlag = CollisionFlag.BLOCK_WEST_ROUTE_BLOCKER dirFlag = DirectionFlag.EAST if (currLocalX > 0 && getDirection(x, y) == 0 && collision.canMove( flags[baseX, baseY, x, y, z], clipFlag ) ) { setNextValidLocalCoords(x, y, dirFlag, nextDistance) } /* west to east */ x = currLocalX + 1 y = currLocalY clipFlag = CollisionFlag.BLOCK_EAST_ROUTE_BLOCKER dirFlag = DirectionFlag.WEST if (currLocalX < relativeSearchSize && getDirection(x, y) == 0 && collision.canMove(flags[baseX, baseY, x, y, z], clipFlag) ) { setNextValidLocalCoords(x, y, dirFlag, nextDistance) } /* north to south */ x = currLocalX y = currLocalY - 1 clipFlag = CollisionFlag.BLOCK_SOUTH_ROUTE_BLOCKER dirFlag = DirectionFlag.NORTH if (currLocalY > 0 && getDirection(x, y) == 0 && collision.canMove( flags[baseX, baseY, x, y, z], clipFlag ) ) { setNextValidLocalCoords(x, y, dirFlag, nextDistance) } /* south to north */ x = currLocalX y = currLocalY + 1 clipFlag = CollisionFlag.BLOCK_NORTH_ROUTE_BLOCKER dirFlag = DirectionFlag.SOUTH if (currLocalY < relativeSearchSize && getDirection(x, y) == 0 && collision.canMove(flags[baseX, baseY, x, y, z], clipFlag) ) { setNextValidLocalCoords(x, y, dirFlag, nextDistance) } /* north-east to south-west */ x = currLocalX - 1 y = currLocalY - 1 dirFlag = DirectionFlag.NORTH_EAST if (currLocalX > 0 && currLocalY > 0 && getDirection(x, y) == 0 && collision.canMove( flags[baseX, baseY, x, y, z], CollisionFlag.BLOCK_SOUTH_WEST_ROUTE_BLOCKER ) && collision.canMove( flags[baseX, baseY, x, currLocalY, z], CollisionFlag.BLOCK_WEST_ROUTE_BLOCKER ) && collision.canMove( flags[baseX, baseY, currLocalX, y, z], CollisionFlag.BLOCK_SOUTH_ROUTE_BLOCKER ) ) { setNextValidLocalCoords(x, y, dirFlag, nextDistance) } /* north-west to south-east */ x = currLocalX + 1 y = currLocalY - 1 dirFlag = DirectionFlag.NORTH_WEST if (currLocalX < relativeSearchSize && currLocalY > 0 && getDirection(x, y) == 0 && collision.canMove( flags[baseX, baseY, x, y, z], CollisionFlag.BLOCK_SOUTH_EAST_ROUTE_BLOCKER ) && collision.canMove( flags[baseX, baseY, x, currLocalY, z], CollisionFlag.BLOCK_EAST_ROUTE_BLOCKER ) && collision.canMove( flags[baseX, baseY, currLocalX, y, z], CollisionFlag.BLOCK_SOUTH_ROUTE_BLOCKER ) ) { setNextValidLocalCoords(x, y, dirFlag, nextDistance) } /* south-east to north-west */ x = currLocalX - 1 y = currLocalY + 1 dirFlag = DirectionFlag.SOUTH_EAST if (currLocalX > 0 && currLocalY < relativeSearchSize && getDirection(x, y) == 0 && collision.canMove( flags[baseX, baseY, x, y, z], CollisionFlag.BLOCK_NORTH_WEST_ROUTE_BLOCKER ) && collision.canMove( flags[baseX, baseY, x, currLocalY, z], CollisionFlag.BLOCK_WEST_ROUTE_BLOCKER ) && collision.canMove( flags[baseX, baseY, currLocalX, y, z], CollisionFlag.BLOCK_NORTH_ROUTE_BLOCKER ) ) { setNextValidLocalCoords(x, y, dirFlag, nextDistance) } /* south-west to north-east */ x = currLocalX + 1 y = currLocalY + 1 dirFlag = DirectionFlag.SOUTH_WEST if (currLocalX < relativeSearchSize && currLocalY < relativeSearchSize && getDirection(x, y) == 0 && collision.canMove( flags[baseX, baseY, x, y, z], CollisionFlag.BLOCK_NORTH_EAST_ROUTE_BLOCKER ) && collision.canMove( flags[baseX, baseY, x, currLocalY, z], CollisionFlag.BLOCK_EAST_ROUTE_BLOCKER ) && collision.canMove( flags[baseX, baseY, currLocalX, y, z], CollisionFlag.BLOCK_NORTH_ROUTE_BLOCKER ) ) { setNextValidLocalCoords(x, y, dirFlag, nextDistance) } } return false } private fun findPath2RouteBlocker( baseX: Int, baseY: Int, z: Int, localDestX: Int, localDestY: Int, destWidth: Int, destHeight: Int, srcSize: Int, objRot: Int, objShape: Int, accessBitMask: Int, collision: CollisionStrategy, reachStrategy: ReachStrategy ): Boolean { var x: Int var y: Int var dirFlag: Int val relativeSearchSize = searchMapSize - 2 val validCoords = validLocalCoords val flags = flags while (bufWriterIndex != bufReaderIndex) { val coord = validCoords[bufReaderIndex] currLocalX = coord ushr 16 currLocalY = coord and 0xFFFF bufReaderIndex = (bufReaderIndex + 1) and (ringBufferSize - 1) if (reachStrategy.reached( flags, currLocalX + baseX, currLocalY + baseY, z, localDestX + baseX, localDestY + baseY, destWidth, destHeight, srcSize, objRot, objShape, accessBitMask, ) ) { return true } val nextDistance = getDistance(currLocalX, currLocalY) + 1 /* east to west */ x = currLocalX - 1 y = currLocalY dirFlag = DirectionFlag.EAST if (currLocalX > 0 && getDirection(x, y) == 0 && collision.canMove( flags[baseX, baseY, x, y, z], CollisionFlag.BLOCK_SOUTH_WEST_ROUTE_BLOCKER ) && collision.canMove( flags[baseX, baseY, x, currLocalY + 1, z], CollisionFlag.BLOCK_NORTH_WEST_ROUTE_BLOCKER ) ) { setNextValidLocalCoords(x, y, dirFlag, nextDistance) } /* west to east */ x = currLocalX + 1 y = currLocalY dirFlag = DirectionFlag.WEST if (currLocalX < relativeSearchSize && getDirection(x, y) == 0 && collision.canMove( flags[baseX, baseY, currLocalX + 2, y, z], CollisionFlag.BLOCK_SOUTH_EAST_ROUTE_BLOCKER ) && collision.canMove( flags[baseX, baseY, currLocalX + 2, currLocalY + 1, z], CollisionFlag.BLOCK_NORTH_EAST_ROUTE_BLOCKER ) ) { setNextValidLocalCoords(x, y, dirFlag, nextDistance) } /* north to south */ x = currLocalX y = currLocalY - 1 dirFlag = DirectionFlag.NORTH if (currLocalY > 0 && getDirection(x, y) == 0 && collision.canMove( flags[baseX, baseY, x, y, z], CollisionFlag.BLOCK_SOUTH_WEST_ROUTE_BLOCKER ) && collision.canMove( flags[baseX, baseY, currLocalX + 1, y, z], CollisionFlag.BLOCK_SOUTH_EAST_ROUTE_BLOCKER ) ) { setNextValidLocalCoords(x, y, dirFlag, nextDistance) } /* south to north */ x = currLocalX y = currLocalY + 1 dirFlag = DirectionFlag.SOUTH if (currLocalY < relativeSearchSize && getDirection(x, y) == 0 && collision.canMove( flags[baseX, baseY, x, currLocalY + 2, z], CollisionFlag.BLOCK_NORTH_WEST_ROUTE_BLOCKER ) && collision.canMove( flags[baseX, baseY, currLocalX + 1, currLocalY + 2, z], CollisionFlag.BLOCK_NORTH_EAST_ROUTE_BLOCKER ) ) { setNextValidLocalCoords(x, y, dirFlag, nextDistance) } /* north-east to south-west */ x = currLocalX - 1 y = currLocalY - 1 dirFlag = DirectionFlag.NORTH_EAST if (currLocalX > 0 && currLocalY > 0 && getDirection(x, y) == 0 && collision.canMove( flags[baseX, baseY, x, currLocalY, z], CollisionFlag.BLOCK_NORTH_AND_SOUTH_EAST_ROUTE_BLOCKER ) && collision.canMove( flags[baseX, baseY, x, y, z], CollisionFlag.BLOCK_SOUTH_WEST_ROUTE_BLOCKER ) && collision.canMove( flags[baseX, baseY, currLocalX, y, z], CollisionFlag.BLOCK_NORTH_EAST_AND_WEST_ROUTE_BLOCKER ) ) { setNextValidLocalCoords(x, y, dirFlag, nextDistance) } /* north-west to south-east */ x = currLocalX + 1 y = currLocalY - 1 dirFlag = DirectionFlag.NORTH_WEST if (currLocalX < relativeSearchSize && currLocalY > 0 && getDirection(x, y) == 0 && collision.canMove( flags[baseX, baseY, x, y, z], CollisionFlag.BLOCK_NORTH_EAST_AND_WEST_ROUTE_BLOCKER ) && collision.canMove( flags[baseX, baseY, currLocalX + 2, y, z], CollisionFlag.BLOCK_SOUTH_EAST_ROUTE_BLOCKER ) && collision.canMove( flags[baseX, baseY, currLocalX + 2, currLocalY, z], CollisionFlag.BLOCK_NORTH_AND_SOUTH_WEST_ROUTE_BLOCKER ) ) { setNextValidLocalCoords(x, y, dirFlag, nextDistance) } /* south-east to north-west */ x = currLocalX - 1 y = currLocalY + 1 dirFlag = DirectionFlag.SOUTH_EAST if (currLocalX > 0 && currLocalY < relativeSearchSize && getDirection(x, y) == 0 && collision.canMove( flags[baseX, baseY, x, y, z], CollisionFlag.BLOCK_NORTH_AND_SOUTH_EAST_ROUTE_BLOCKER ) && collision.canMove( flags[baseX, baseY, x, currLocalY + 2, z], CollisionFlag.BLOCK_NORTH_WEST_ROUTE_BLOCKER ) && collision.canMove( flags[baseX, baseY, currLocalX, currLocalY + 2, z], CollisionFlag.BLOCK_SOUTH_EAST_AND_WEST_ROUTE_BLOCKER ) ) { setNextValidLocalCoords(x, y, dirFlag, nextDistance) } /* south-west to north-east */ x = currLocalX + 1 y = currLocalY + 1 dirFlag = DirectionFlag.SOUTH_WEST if (currLocalX < relativeSearchSize && currLocalY < relativeSearchSize && getDirection(x, y) == 0 && collision.canMove( flags[baseX, baseY, x, currLocalY + 2, z], CollisionFlag.BLOCK_SOUTH_EAST_AND_WEST_ROUTE_BLOCKER ) && collision.canMove( flags[baseX, baseY, currLocalX + 2, currLocalY + 2, z], CollisionFlag.BLOCK_NORTH_EAST_ROUTE_BLOCKER ) && collision.canMove( flags[baseX, baseY, currLocalX + 2, y, z], CollisionFlag.BLOCK_NORTH_AND_SOUTH_WEST_ROUTE_BLOCKER ) ) { setNextValidLocalCoords(x, y, dirFlag, nextDistance) } } return false } private fun findPathNRouteBlocker( baseX: Int, baseY: Int, z: Int, localDestX: Int, localDestY: Int, destWidth: Int, destHeight: Int, srcSize: Int, objRot: Int, objShape: Int, accessBitMask: Int, collision: CollisionStrategy, reachStrategy: ReachStrategy ): Boolean { var x: Int var y: Int var dirFlag: Int val relativeSearchSize = searchMapSize - srcSize val validCoords = validLocalCoords val flags = flags while (bufWriterIndex != bufReaderIndex) { val coord = validCoords[bufReaderIndex] currLocalX = coord ushr 16 currLocalY = coord and 0xFFFF bufReaderIndex = (bufReaderIndex + 1) and (ringBufferSize - 1) if (reachStrategy.reached( flags, currLocalX + baseX, currLocalY + baseY, z, localDestX + baseX, localDestY + baseY, destWidth, destHeight, srcSize, objRot, objShape, accessBitMask, ) ) { return true } val nextDistance = getDistance(currLocalX, currLocalY) + 1 /* east to west */ x = currLocalX - 1 y = currLocalY dirFlag = DirectionFlag.EAST if (currLocalX > 0 && getDirection(x, y) == 0 && collision.canMove( flags[baseX, baseY, x, y, z], CollisionFlag.BLOCK_SOUTH_WEST_ROUTE_BLOCKER ) && collision.canMove( flags[baseX, baseY, x, currLocalY + srcSize - 1, z], CollisionFlag.BLOCK_NORTH_WEST_ROUTE_BLOCKER ) ) { val clipFlag = CollisionFlag.BLOCK_NORTH_AND_SOUTH_EAST_ROUTE_BLOCKER val blocked = (1 until srcSize - 1).any { !collision.canMove( flags[baseX, baseY, x, currLocalY + it, z], clipFlag ) } if (!blocked) { setNextValidLocalCoords(x, y, dirFlag, nextDistance) } } /* west to east */ x = currLocalX + 1 y = currLocalY dirFlag = DirectionFlag.WEST if (currLocalX < relativeSearchSize && getDirection(x, y) == 0 && collision.canMove( flags[baseX, baseY, currLocalX + srcSize, y, z], CollisionFlag.BLOCK_SOUTH_EAST_ROUTE_BLOCKER ) && collision.canMove( flags[baseX, baseY, currLocalX + srcSize, currLocalY + srcSize - 1, z], CollisionFlag.BLOCK_NORTH_EAST_ROUTE_BLOCKER ) ) { val clipFlag = CollisionFlag.BLOCK_NORTH_AND_SOUTH_WEST_ROUTE_BLOCKER val blocked = (1 until srcSize - 1).any { !collision.canMove(flags[baseX, baseY, currLocalX + srcSize, currLocalY + it, z], clipFlag) } if (!blocked) { setNextValidLocalCoords(x, y, dirFlag, nextDistance) } } /* north to south */ x = currLocalX y = currLocalY - 1 dirFlag = DirectionFlag.NORTH if (currLocalY > 0 && getDirection(x, y) == 0 && collision.canMove( flags[baseX, baseY, x, y, z], CollisionFlag.BLOCK_SOUTH_WEST_ROUTE_BLOCKER ) && collision.canMove( flags[baseX, baseY, currLocalX + srcSize - 1, y, z], CollisionFlag.BLOCK_SOUTH_EAST_ROUTE_BLOCKER ) ) { val clipFlag = CollisionFlag.BLOCK_NORTH_EAST_AND_WEST_ROUTE_BLOCKER val blocked = (1 until srcSize - 1).any { !collision.canMove( flags[baseX, baseY, currLocalX + it, y, z], clipFlag ) } if (!blocked) { setNextValidLocalCoords(x, y, dirFlag, nextDistance) } } /* south to north */ x = currLocalX y = currLocalY + 1 dirFlag = DirectionFlag.SOUTH if (currLocalY < relativeSearchSize && getDirection(x, y) == 0 && collision.canMove( flags[baseX, baseY, x, currLocalY + srcSize, z], CollisionFlag.BLOCK_NORTH_WEST_ROUTE_BLOCKER ) && collision.canMove( flags[baseX, baseY, currLocalX + srcSize - 1, currLocalY + srcSize, z], CollisionFlag.BLOCK_NORTH_EAST_ROUTE_BLOCKER ) ) { val clipFlag = CollisionFlag.BLOCK_SOUTH_EAST_AND_WEST_ROUTE_BLOCKER val blocked = (1 until srcSize - 1).any { !collision.canMove( flags[baseX, baseY, x + it, currLocalY + srcSize, z], clipFlag ) } if (!blocked) { setNextValidLocalCoords(x, y, dirFlag, nextDistance) } } /* north-east to south-west */ x = currLocalX - 1 y = currLocalY - 1 dirFlag = DirectionFlag.NORTH_EAST if (currLocalX > 0 && currLocalY > 0 && getDirection(x, y) == 0 && collision.canMove( flags[baseX, baseY, x, y, z], CollisionFlag.BLOCK_SOUTH_WEST_ROUTE_BLOCKER ) ) { val clipFlag1 = CollisionFlag.BLOCK_NORTH_AND_SOUTH_EAST_ROUTE_BLOCKER val clipFlag2 = CollisionFlag.BLOCK_NORTH_EAST_AND_WEST_ROUTE_BLOCKER val blocked = (1 until srcSize).any { !collision.canMove(flags[baseX, baseY, x, currLocalY + it - 1, z], clipFlag1) || !collision.canMove(flags[baseX, baseY, currLocalX + it - 1, y, z], clipFlag2) } if (!blocked) { setNextValidLocalCoords(x, y, dirFlag, nextDistance) } } /* north-west to south-east */ x = currLocalX + 1 y = currLocalY - 1 dirFlag = DirectionFlag.NORTH_WEST if (currLocalX < relativeSearchSize && currLocalY > 0 && getDirection(x, y) == 0 && collision.canMove( flags[baseX, baseY, currLocalX + srcSize, y, z], CollisionFlag.BLOCK_SOUTH_EAST_ROUTE_BLOCKER ) ) { val clipFlag1 = CollisionFlag.BLOCK_NORTH_AND_SOUTH_WEST_ROUTE_BLOCKER val clipFlag2 = CollisionFlag.BLOCK_NORTH_EAST_AND_WEST_ROUTE_BLOCKER val blocked = (1 until srcSize).any { !collision.canMove(flags[baseX, baseY, currLocalX + srcSize, currLocalY + it - 1, z], clipFlag1) || !collision.canMove(flags[baseX, baseY, currLocalX + it, y, z], clipFlag2) } if (!blocked) { setNextValidLocalCoords(x, y, dirFlag, nextDistance) } } /* south-east to north-west */ x = currLocalX - 1 y = currLocalY + 1 dirFlag = DirectionFlag.SOUTH_EAST if (currLocalX > 0 && currLocalY < relativeSearchSize && getDirection(x, y) == 0 && collision.canMove( flags[baseX, baseY, x, currLocalY + srcSize, z], CollisionFlag.BLOCK_NORTH_WEST_ROUTE_BLOCKER ) ) { val clipFlag1 = CollisionFlag.BLOCK_NORTH_AND_SOUTH_EAST_ROUTE_BLOCKER val clipFlag2 = CollisionFlag.BLOCK_SOUTH_EAST_AND_WEST_ROUTE_BLOCKER val blocked = (1 until srcSize).any { !collision.canMove(flags[baseX, baseY, x, currLocalY + it, z], clipFlag1) || !collision.canMove(flags[baseX, baseY, currLocalX + it - 1, currLocalY + srcSize, z], clipFlag2) } if (!blocked) { setNextValidLocalCoords(x, y, dirFlag, nextDistance) } } /* south-west to north-east */ x = currLocalX + 1 y = currLocalY + 1 dirFlag = DirectionFlag.SOUTH_WEST if (currLocalX < relativeSearchSize && currLocalY < relativeSearchSize && getDirection(x, y) == 0 && collision.canMove( flags[baseX, baseY, currLocalX + srcSize, currLocalY + srcSize, z], CollisionFlag.BLOCK_NORTH_EAST_ROUTE_BLOCKER ) ) { val clipFlag1 = CollisionFlag.BLOCK_SOUTH_EAST_AND_WEST_ROUTE_BLOCKER val clipFlag2 = CollisionFlag.BLOCK_NORTH_AND_SOUTH_WEST_ROUTE_BLOCKER val blocked = (1 until srcSize).any { !collision.canMove(flags[baseX, baseY, currLocalX + it, currLocalY + srcSize, z], clipFlag1) || !collision.canMove(flags[baseX, baseY, currLocalX + srcSize, currLocalY + it, z], clipFlag2) } if (!blocked) { setNextValidLocalCoords(x, y, dirFlag, nextDistance) } } } return false } private fun findClosestApproachPoint( localDestX: Int, localDestY: Int, width: Int, length: Int, ): Boolean { var lowestCost = MAX_ALTERNATIVE_ROUTE_LOWEST_COST var maxAlternativePath = MAX_ALTERNATIVE_ROUTE_SEEK_RANGE val alternativeRouteRange = MAX_ALTERNATIVE_ROUTE_DISTANCE_FROM_DESTINATION val radiusX = localDestX - alternativeRouteRange..localDestX + alternativeRouteRange val radiusY = localDestY - alternativeRouteRange..localDestY + alternativeRouteRange val range = 0 until searchMapSize for (x in radiusX) { for (y in radiusY) { if (x !in range || y !in range || getDistance(x, y) >= MAX_ALTERNATIVE_ROUTE_SEEK_RANGE ) { continue } val dx = if (x < localDestX) { localDestX - x } else if (x > localDestX + width - 1) { x - (width + localDestX - 1) } else { 0 } val dy = if (y < localDestY) { localDestY - y } else if (y > localDestY + length - 1) { y - (localDestY + length - 1) } else { 0 } val cost = dx * dx + dy * dy if (cost < lowestCost || (cost == lowestCost && maxAlternativePath > getDistance(x, y))) { currLocalX = x currLocalY = y lowestCost = cost maxAlternativePath = getDistance(x, y) } } } return lowestCost != MAX_ALTERNATIVE_ROUTE_LOWEST_COST } private fun reset() { graphInfo.fill(DEFAULT_DISTANCE_VALUE shl 7) bufReaderIndex = 0 bufWriterIndex = 0 } private fun setNextValidLocalCoords(localX: Int, localY: Int, direction: Int, distance: Int) { val pathIndex = (localY * searchMapSize) + localX val bitpacked = direction or (distance shl 7) graphInfo[pathIndex] = bitpacked validLocalCoords[bufWriterIndex] = (localX shl 16) or localY bufWriterIndex = (bufWriterIndex + 1) and (ringBufferSize - 1) } @Suppress(""NOTHING_TO_INLINE"") private inline fun getDistance(localX: Int, localY: Int): Int { val pathIndex = (localY * searchMapSize) + localX return graphInfo[pathIndex] ushr 7 } @Suppress(""NOTHING_TO_INLINE"") private inline fun getDirection(localX: Int, localY: Int): Int { val pathIndex = (localY * searchMapSize) + localX return graphInfo[pathIndex] and 0x7F } @Suppress(""NOTHING_TO_INLINE"") private inline operator fun IntArray.get(localX: Int, localY: Int): Int { val index = (localY * searchMapSize) + localX return this[index] } @Suppress(""NOTHING_TO_INLINE"") private inline operator fun Array.get(baseX: Int, baseY: Int, localX: Int, localY: Int, z: Int): Int { val x = baseX + localX val y = baseY + localY val zone = this[getZoneIndex(x, y, z)] ?: return -1 return zone[getIndexInZone(x, y)] } private companion object { private val FAILED_ROUTE = Route(ArrayDeque(), alternative = false, success = false) } } @Suppress(""NOTHING_TO_INLINE"") internal inline fun getZoneIndex(x: Int, y: Int, z: Int): Int { return (y shr 3) or ((x shr 3) shl 11) or (z shl 22) } @Suppress(""NOTHING_TO_INLINE"") internal inline fun getIndexInZone(x: Int, y: Int): Int { return (x and 0x7) or ((y and 0x7) shl 3) } fun routeEntityToObject(entity: Entity, obj: GameObject, maxTurns: Int = DEFAULT_MAX_TURNS): Route { return PathFinder(flags = WorldCollision.allFlags, useRouteBlockerFlags = true) .findPath( entity.x, entity.y, obj.x, obj.y, entity.plane, collision = entity.collisionStrategy, srcSize = entity.size, destWidth = if (obj.rotation == 0 || obj.rotation == 2) obj.definitions.getSizeX() else obj.definitions.getSizeY(), destHeight = if (obj.rotation == 0 || obj.rotation == 2) obj.definitions.getSizeY() else obj.definitions.getSizeX(), objRot = obj.rotation, objShape = if (obj.routeType == RouteType.WALK_ONTO) -1 else obj.type.id, accessBitMask = if (obj.rotation != 0) ((obj.definitions.accessBlockFlag shl obj.rotation) and 0xF) + (obj.definitions.accessBlockFlag shr (4 - obj.rotation)) else obj.definitions.accessBlockFlag, maxTurns = maxTurns ) } fun routeEntityToEntity(entity: Entity, target: Entity, maxTurns: Int = DEFAULT_MAX_TURNS): Route { return PathFinder(flags = WorldCollision.allFlags, useRouteBlockerFlags = true) .findPath( entity.x, entity.y, target.x, target.y, entity.plane, collision = entity.collisionStrategy, objShape = -2, srcSize = entity.size, destWidth = target.size, destHeight = target.size, maxTurns = maxTurns ) } fun routeEntityToTile(entity: Entity, tile: Tile, maxTurns: Int = DEFAULT_MAX_TURNS): Route { return PathFinder(flags = WorldCollision.allFlags, useRouteBlockerFlags = true) .findPath(entity.x, entity.y, tile.x, tile.y, entity.plane, collision = entity.collisionStrategy, srcSize = entity.size, maxTurns = maxTurns) } fun routeEntityWalkRequest(entity: Entity, request: Walk, maxTurns: Int = DEFAULT_MAX_TURNS): Route { return PathFinder(flags = WorldCollision.allFlags, useRouteBlockerFlags = true) .findPath(entity.x, entity.y, request.x, request.y, entity.plane, collision = entity.collisionStrategy, srcSize = entity.size, maxTurns = maxTurns) } fun routeEntityTo(entity: Entity, target: Any, maxTurns: Int = DEFAULT_MAX_TURNS): Route { return when(target) { is Entity -> routeEntityToEntity(entity, target, maxTurns) is GameObject -> routeEntityToObject(entity, target, maxTurns) is GroundItem -> routeEntityToTile(entity, target.tile, maxTurns) is Tile -> routeEntityToTile(entity, target, maxTurns) else -> throw IllegalStateException(""Unexpected value: $target"") } } fun walkRoute(entity: Entity, route: Route, forceSteps: Boolean): Boolean { if (!route.success) return false if (entity is Player) entity.stopAll() entity.resetWalkSteps() addSteps(entity, route, forceSteps) return true } fun addSteps(entity: Entity, route: Route, forceSteps: Boolean, maxSteps: Int = -1) { var lastStep: RouteCoordinates? = null for (coord in route.coords) { if (!entity.addWalkSteps(coord.x, coord.y, maxSteps, true, forceSteps)) break lastStep = coord } if (lastStep != null && entity is Player) { val tile = Tile.of(lastStep.x, lastStep.y, entity.plane) entity.session.writeToQueue(MinimapFlag(tile.getXInScene(entity.getSceneBaseChunkId()), tile.getYInScene(entity.getSceneBaseChunkId()))) } }" "package com.rs.engine.pathfinder /** * @author Kris | 16/03/2022 */ public class StepValidator(private val flags: Array) { public fun canTravel( level: Int, x: Int, y: Int, offsetX: Int, offsetY: Int, size: Int = 1, extraFlag: Int, collision: CollisionStrategy = CollisionStrategyType.NORMAL.strategy, ): Boolean { val blocked = when { offsetX == 0 && offsetY == -1 -> isBlockedSouth(flags, level, x, y, size, extraFlag, collision) offsetX == 0 && offsetY == 1 -> isBlockedNorth(flags, level, x, y, size, extraFlag, collision) offsetX == -1 && offsetY == 0 -> isBlockedWest(flags, level, x, y, size, extraFlag, collision) offsetX == 1 && offsetY == 0 -> isBlockedEast(flags, level, x, y, size, extraFlag, collision) offsetX == -1 && offsetY == -1 -> isBlockedSouthWest(flags, level, x, y, size, extraFlag, collision) offsetX == -1 && offsetY == 1 -> isBlockedNorthWest(flags, level, x, y, size, extraFlag, collision) offsetX == 1 && offsetY == -1 -> isBlockedSouthEast(flags, level, x, y, size, extraFlag, collision) offsetX == 1 && offsetY == 1 -> isBlockedNorthEast(flags, level, x, y, size, extraFlag, collision) else -> error(""Invalid offsets: $offsetX, $offsetY"") } return !blocked } @Suppress(""NOTHING_TO_INLINE"") private inline operator fun Array.get(x: Int, y: Int, level: Int): Int { val zone = this[getZoneIndex(x, y, level)] ?: return -1 return zone[getIndexInZone(x, y)] } private fun isBlockedSouth( flags: Array, level: Int, x: Int, y: Int, size: Int, extraFlag: Int, collision: CollisionStrategy ): Boolean { return when (size) { 1 -> !collision.canMove(flags[x, y - 1, level], BLOCK_SOUTH or extraFlag) 2 -> !collision.canMove(flags[x, y - 1, level], BLOCK_SOUTH_WEST or extraFlag) || !collision.canMove(flags[x + 1, y - 1, level], BLOCK_SOUTH_EAST or extraFlag) else -> { if ( !collision.canMove(flags[x, y - 1, level], BLOCK_SOUTH_WEST or extraFlag) || !collision.canMove(flags[x + size - 1, y - 1, level], BLOCK_SOUTH_EAST or extraFlag) ) { return true } for (midX in x + 1 until x + size - 1) { if (!collision.canMove( flags[midX, y - 1, level], BLOCK_NORTH_EAST_AND_WEST or extraFlag ) ) { return true } } return false } } } private fun isBlockedNorth( flags: Array, level: Int, x: Int, y: Int, size: Int, extraFlag: Int, collision: CollisionStrategy ): Boolean { return when (size) { 1 -> !collision.canMove(flags[x, y + 1, level], BLOCK_NORTH or extraFlag) 2 -> !collision.canMove(flags[x, y + 2, level], BLOCK_NORTH_WEST or extraFlag) || !collision.canMove(flags[x + 1, y + 2, level], BLOCK_NORTH_EAST or extraFlag) else -> { if ( !collision.canMove(flags[x, y + size, level], BLOCK_NORTH_WEST or extraFlag) || !collision.canMove( flags[x + size - 1, y + size, level], BLOCK_NORTH_EAST or extraFlag ) ) { return true } for (midX in x + 1 until x + size - 1) { if (!collision.canMove( flags[midX, y + size, level], BLOCK_SOUTH_EAST_AND_WEST or extraFlag ) ) { return true } } return false } } } private fun isBlockedWest( flags: Array, level: Int, x: Int, y: Int, size: Int, extraFlag: Int, collision: CollisionStrategy ): Boolean { return when (size) { 1 -> !collision.canMove(flags[x - 1, y, level], BLOCK_WEST or extraFlag) 2 -> !collision.canMove(flags[x - 1, y, level], BLOCK_SOUTH_WEST or extraFlag) || !collision.canMove(flags[x - 1, y + 1, level], BLOCK_NORTH_WEST or extraFlag) else -> { if ( !collision.canMove(flags[x - 1, y, level], BLOCK_SOUTH_WEST or extraFlag) || !collision.canMove(flags[x - 1, y + size - 1, level], BLOCK_NORTH_WEST or extraFlag) ) { return true } for (midY in y + 1 until y + size - 1) { if (!collision.canMove( flags[x - 1, midY, level], BLOCK_NORTH_AND_SOUTH_EAST or extraFlag ) ) { return true } } return false } } } private fun isBlockedEast( flags: Array, level: Int, x: Int, y: Int, size: Int, extraFlag: Int, collision: CollisionStrategy ): Boolean { return when (size) { 1 -> !collision.canMove(flags[x + 1, y, level], BLOCK_EAST or extraFlag) 2 -> !collision.canMove(flags[x + 2, y, level], BLOCK_SOUTH_EAST or extraFlag) || !collision.canMove(flags[x + 2, y + 1, level], BLOCK_NORTH_EAST or extraFlag) else -> { if ( !collision.canMove(flags[x + size, y, level], BLOCK_SOUTH_EAST or extraFlag) || !collision.canMove( flags[x + size, y + size - 1, level], BLOCK_NORTH_EAST or extraFlag ) ) { return true } for (midY in y + 1 until y + size - 1) { if (!collision.canMove( flags[x + size, midY, level], BLOCK_NORTH_AND_SOUTH_WEST or extraFlag ) ) { return true } } return false } } } private fun isBlockedSouthWest( flags: Array, level: Int, x: Int, y: Int, size: Int, extraFlag: Int, collision: CollisionStrategy ): Boolean { return when (size) { 1 -> !collision.canMove(flags[x - 1, y - 1, level], BLOCK_SOUTH_WEST or extraFlag) || !collision.canMove(flags[x - 1, y, level], BLOCK_WEST or extraFlag) || !collision.canMove(flags[x, y - 1, level], BLOCK_SOUTH or extraFlag) 2 -> !collision.canMove(flags[x - 1, y, level], BLOCK_NORTH_AND_SOUTH_EAST or extraFlag) || !collision.canMove(flags[x - 1, y - 1, level], BLOCK_SOUTH_WEST or extraFlag) || !collision.canMove(flags[x, y - 1, level], BLOCK_NORTH_EAST_AND_WEST or extraFlag) else -> { if (!collision.canMove(flags[x - 1, y - 1, level], BLOCK_SOUTH_WEST or extraFlag)) { return true } for (mid in 1 until size) { if ( !collision.canMove( flags[x - 1, y + mid - 1, level], BLOCK_NORTH_AND_SOUTH_EAST or extraFlag ) || !collision.canMove( flags[x + mid - 1, y - 1, level], BLOCK_NORTH_EAST_AND_WEST or extraFlag ) ) { return true } } return false } } } private fun isBlockedNorthWest( flags: Array, level: Int, x: Int, y: Int, size: Int, extraFlag: Int, collision: CollisionStrategy ): Boolean { return when (size) { 1 -> !collision.canMove(flags[x - 1, y + 1, level], BLOCK_NORTH_WEST or extraFlag) || !collision.canMove(flags[x - 1, y, level], BLOCK_WEST or extraFlag) || !collision.canMove(flags[x, y + 1, level], BLOCK_NORTH or extraFlag) 2 -> !collision.canMove(flags[x - 1, y + 1, level], BLOCK_NORTH_AND_SOUTH_EAST or extraFlag) || !collision.canMove(flags[x - 1, y + 2, level], BLOCK_NORTH_WEST or extraFlag) || !collision.canMove(flags[x, y + 2, level], BLOCK_SOUTH_EAST_AND_WEST or extraFlag) else -> { if (!collision.canMove(flags[x - 1, y + size, level], BLOCK_NORTH_WEST or extraFlag)) { return true } for (mid in 1 until size) { if ( !collision.canMove( flags[x - 1, y + mid, level], BLOCK_NORTH_AND_SOUTH_EAST or extraFlag ) || !collision.canMove( flags[x + mid - 1, y + size, level], BLOCK_SOUTH_EAST_AND_WEST or extraFlag ) ) { return true } } return false } } } private fun isBlockedSouthEast( flags: Array, level: Int, x: Int, y: Int, size: Int, extraFlag: Int, collision: CollisionStrategy ): Boolean { return when (size) { 1 -> !collision.canMove(flags[x + 1, y - 1, level], BLOCK_SOUTH_EAST or extraFlag) || !collision.canMove(flags[x + 1, y, level], BLOCK_EAST or extraFlag) || !collision.canMove(flags[x, y - 1, level], BLOCK_SOUTH or extraFlag) 2 -> !collision.canMove(flags[x + 1, y - 1, level], BLOCK_NORTH_EAST_AND_WEST or extraFlag) || !collision.canMove(flags[x + 2, y - 1, level], BLOCK_SOUTH_EAST or extraFlag) || !collision.canMove(flags[x + 2, y, level], BLOCK_NORTH_AND_SOUTH_WEST or extraFlag) else -> { if (!collision.canMove( flags[x + size, y - 1, level], BLOCK_SOUTH_EAST or extraFlag ) ) return true for (mid in 1 until size) { if ( !collision.canMove( flags[x + size, y + mid - 1, level], BLOCK_NORTH_AND_SOUTH_WEST or extraFlag ) || !collision.canMove( flags[x + mid, y - 1, level], BLOCK_NORTH_EAST_AND_WEST or extraFlag ) ) { return true } } return false } } } private fun isBlockedNorthEast( flags: Array, level: Int, x: Int, y: Int, size: Int, extraFlag: Int, collision: CollisionStrategy ): Boolean { return when (size) { 1 -> !collision.canMove(flags[x + 1, y + 1, level], BLOCK_NORTH_EAST or extraFlag) || !collision.canMove(flags[x + 1, y, level], BLOCK_EAST or extraFlag) || !collision.canMove(flags[x, y + 1, level], BLOCK_NORTH or extraFlag) 2 -> !collision.canMove(flags[x + 1, y + 2, level], BLOCK_SOUTH_EAST_AND_WEST or extraFlag) || !collision.canMove(flags[x + 2, y + 2, level], BLOCK_NORTH_EAST or extraFlag) || !collision.canMove(flags[x + 2, y + 1, level], BLOCK_NORTH_AND_SOUTH_WEST or extraFlag) else -> { if (!collision.canMove(flags[x + size, y + size, level], BLOCK_NORTH_EAST or extraFlag)) { return true } for (mid in 1 until size) { if ( !collision.canMove( flags[x + mid, y + size, level], BLOCK_SOUTH_EAST_AND_WEST or extraFlag ) || !collision.canMove( flags[x + size, y + mid, level], BLOCK_NORTH_AND_SOUTH_WEST or extraFlag ) ) { return true } } return false } } } }" "package com.rs.engine.pathfinder class WalkStep(@JvmField val dir: Direction, @JvmField val x: Int, @JvmField val y: Int, private var clip: Boolean) { fun checkClip(): Boolean { return clip } fun setCheckClip(clip: Boolean) { this.clip = clip } override fun toString(): String { return ""[$x, $y, $dir, $clip]"" } }" "package com.rs.engine.pathfinder object WorldCollision { private const val CHUNK_SIZE = 2048 //2048 chunk size = max capacity 16384x16384 tiles val allFlags: Array = arrayOfNulls(CHUNK_SIZE * CHUNK_SIZE * 4) private val LOCK = Any() @JvmStatic fun clipNPC(npc: NPC) { if (!npc.blocksOtherNpcs()) return val lastTile = if (npc.lastTile == null) npc.tile else npc.lastTile fillNPCClip(lastTile, npc.size, false) if (!npc.hasFinished()) fillNPCClip(npc.tile, npc.size, true) } @JvmStatic fun fillNPCClip(tile: Tile, size: Int, blocks: Boolean) { for (x in 0 until size) for (y in 0 until size) { val local = tile.transform(x, y) if (blocks) addClipNPC(local) else removeClipNPC(local) } } @JvmStatic fun getClipNPC(tile: Tile): Boolean { return ClipFlag.flagged(getFlags(tile), ClipFlag.BW_NPC) } @JvmStatic fun checkNPCClip(npc: NPC, dir: Direction): Boolean { val size = npc.size val toX = npc.x + dir.dx val toY = npc.y + dir.dy val eastMostX = npc.x + (size - 1) val northMostY = npc.y + (size - 1) for (x in toX until (toX + size)) for (y in toY until (toY + size)) { if (x >= npc.x && x <= eastMostX && y >= npc.y && y <= northMostY) /* stepping within itself, allow it */ continue if (getClipNPC(Tile.of(x, y, npc.plane))) return false } return true } @JvmStatic fun clearChunk(chunkCollisionHash: Int) { synchronized(LOCK) { allFlags[chunkCollisionHash] = null } } @JvmStatic fun removeFlag(tile: Tile, vararg flags: ClipFlag) { var flag = 0 for (f in flags) flag = flag or f.flag removeFlag(tile, flag) } @JvmStatic fun addFlag(tile: Tile, vararg flags: ClipFlag) { var flag = 0 for (f in flags) flag = flag or f.flag addFlag(tile, flag) } @JvmStatic fun setFlags(tile: Tile, vararg flags: ClipFlag) { var flag = 0 for (f in flags) flag = flag or f.flag setFlags(tile, flag) } @JvmStatic fun addBlockedTile(tile: Tile) { addFlag(tile, ClipFlag.PFBW_FLOOR) } @JvmStatic fun removeBlockedTile(tile: Tile) { removeFlag(tile, ClipFlag.PFBW_FLOOR) } @JvmStatic fun addBlockWalkAndProj(tile: Tile) { addFlag(tile, ClipFlag.PFBW_GROUND_DECO) } @JvmStatic fun removeBlockWalkAndProj(tile: Tile) { removeFlag(tile, ClipFlag.PFBW_GROUND_DECO) } @JvmStatic fun addClipNPC(tile: Tile) { addFlag(tile, ClipFlag.BW_NPC) } @JvmStatic fun removeClipNPC(tile: Tile) { removeFlag(tile, ClipFlag.BW_NPC) } @JvmStatic fun addClipPlayer(tile: Tile) { addFlag(tile, ClipFlag.BW_PLAYER) } @JvmStatic fun removeClipPlayer(tile: Tile) { removeFlag(tile, ClipFlag.BW_PLAYER) } @JvmStatic fun addObject(tile: Tile, sizeX: Int, sizeY: Int, blocksProjectiles: Boolean, pathfinder: Boolean) { var flag = ClipFlag.BW_FULL.flag if (blocksProjectiles) flag = flag or ClipFlag.BP_FULL.flag if (pathfinder) flag = flag or ClipFlag.PF_FULL.flag for (tileX in tile.x() until tile.x() + sizeX) for (tileY in tile.y() until tile.y() + sizeY) addFlag(Tile.of(tileX, tileY, tile.plane().toInt()), flag) } @JvmStatic fun removeObject(tile: Tile, sizeX: Int, sizeY: Int, blocksProjectiles: Boolean, pathfinder: Boolean) { var flag = ClipFlag.BW_FULL.flag if (blocksProjectiles) flag = flag or ClipFlag.BP_FULL.flag if (pathfinder) flag = flag or ClipFlag.PF_FULL.flag for (tileX in tile.x() until tile.x() + sizeX) for (tileY in tile.y() until tile.y() + sizeY) removeFlag(Tile.of(tileX, tileY, tile.plane().toInt()), flag) } @JvmStatic fun addWall(tile: Tile, type: ObjectType?, rotation: Int, blocksProjectiles: Boolean, pathfinder: Boolean) { when (type) { ObjectType.WALL_STRAIGHT -> { when (rotation) { 0 -> { addFlag(tile, ClipFlag.blockWest(true, blocksProjectiles, pathfinder)) addFlag(tile.transform(-1, 0, 0), ClipFlag.blockEast(true, blocksProjectiles, pathfinder)) } 1 -> { addFlag(tile, ClipFlag.blockNorth(true, blocksProjectiles, pathfinder)) addFlag(tile.transform(0, 1, 0), ClipFlag.blockSouth(true, blocksProjectiles, pathfinder)) } 2 -> { addFlag(tile, ClipFlag.blockEast(true, blocksProjectiles, pathfinder)) addFlag(tile.transform(1, 0, 0), ClipFlag.blockWest(true, blocksProjectiles, pathfinder)) } 3 -> { addFlag(tile, ClipFlag.blockSouth(true, blocksProjectiles, pathfinder)) addFlag(tile.transform(0, -1, 0), ClipFlag.blockNorth(true, blocksProjectiles, pathfinder)) } } } ObjectType.WALL_DIAGONAL_CORNER, ObjectType.WALL_STRAIGHT_CORNER -> { when (rotation) { 0 -> { addFlag(tile, ClipFlag.blockNorthWest(true, blocksProjectiles, pathfinder)) addFlag(tile.transform(-1, 1, 0), ClipFlag.blockSouthEast(true, blocksProjectiles, pathfinder)) } 1 -> { addFlag(tile, ClipFlag.blockNorthEast(true, blocksProjectiles, pathfinder)) addFlag(tile.transform(1, 1, 0), ClipFlag.blockSouthWest(true, blocksProjectiles, pathfinder)) } 2 -> { addFlag(tile, ClipFlag.blockSouthEast(true, blocksProjectiles, pathfinder)) addFlag(tile.transform(1, -1, 0), ClipFlag.blockNorthWest(true, blocksProjectiles, pathfinder)) } 3 -> { addFlag(tile, ClipFlag.blockSouthWest(true, blocksProjectiles, pathfinder)) addFlag(tile.transform(-1, -1, 0), ClipFlag.blockNorthEast(true, blocksProjectiles, pathfinder)) } } } ObjectType.WALL_WHOLE_CORNER -> { when (rotation) { 0 -> { addFlag(tile, ClipFlag.blockNorth(true, blocksProjectiles, pathfinder) or ClipFlag.blockWest(true, blocksProjectiles, pathfinder)) addFlag(tile.transform(-1, 0, 0), ClipFlag.blockEast(true, blocksProjectiles, pathfinder)) addFlag(tile.transform(0, 1, 0), ClipFlag.blockSouth(true, blocksProjectiles, pathfinder)) } 1 -> { addFlag(tile, ClipFlag.blockNorth(true, blocksProjectiles, pathfinder) or ClipFlag.blockEast(true, blocksProjectiles, pathfinder)) addFlag(tile.transform(0, 1, 0), ClipFlag.blockSouth(true, blocksProjectiles, pathfinder)) addFlag(tile.transform(1, 0, 0), ClipFlag.blockWest(true, blocksProjectiles, pathfinder)) } 2 -> { addFlag(tile, ClipFlag.blockEast(true, blocksProjectiles, pathfinder) or ClipFlag.blockSouth(true, blocksProjectiles, pathfinder)) addFlag(tile.transform(1, 0, 0), ClipFlag.blockWest(true, blocksProjectiles, pathfinder)) addFlag(tile.transform(0, -1, 0), ClipFlag.blockNorth(true, blocksProjectiles, pathfinder)) } 3 -> { addFlag(tile, ClipFlag.blockSouth(true, blocksProjectiles, pathfinder) or ClipFlag.blockWest(true, blocksProjectiles, pathfinder)) addFlag(tile.transform(0, -1, 0), ClipFlag.blockNorth(true, blocksProjectiles, pathfinder)) addFlag(tile.transform(-1, 0, 0), ClipFlag.blockEast(true, blocksProjectiles, pathfinder)) } } } else -> {} } } @JvmStatic fun removeWall(tile: Tile, type: ObjectType?, rotation: Int, blocksProjectiles: Boolean, pathfinder: Boolean) { when (type) { ObjectType.WALL_STRAIGHT -> { when (rotation) { 0 -> { removeFlag(tile, ClipFlag.blockWest(true, blocksProjectiles, pathfinder)) removeFlag(tile.transform(-1, 0, 0), ClipFlag.blockEast(true, blocksProjectiles, pathfinder)) } 1 -> { removeFlag(tile, ClipFlag.blockNorth(true, blocksProjectiles, pathfinder)) removeFlag(tile.transform(0, 1, 0), ClipFlag.blockSouth(true, blocksProjectiles, pathfinder)) } 2 -> { removeFlag(tile, ClipFlag.blockEast(true, blocksProjectiles, pathfinder)) removeFlag(tile.transform(1, 0, 0), ClipFlag.blockWest(true, blocksProjectiles, pathfinder)) } 3 -> { removeFlag(tile, ClipFlag.blockSouth(true, blocksProjectiles, pathfinder)) removeFlag(tile.transform(0, -1, 0), ClipFlag.blockNorth(true, blocksProjectiles, pathfinder)) } } } ObjectType.WALL_DIAGONAL_CORNER, ObjectType.WALL_STRAIGHT_CORNER -> { when (rotation) { 0 -> { removeFlag(tile, ClipFlag.blockNorthWest(true, blocksProjectiles, pathfinder)) removeFlag(tile.transform(-1, 1, 0), ClipFlag.blockSouthEast(true, blocksProjectiles, pathfinder)) } 1 -> { removeFlag(tile, ClipFlag.blockNorthEast(true, blocksProjectiles, pathfinder)) removeFlag(tile.transform(1, 1, 0), ClipFlag.blockSouthWest(true, blocksProjectiles, pathfinder)) } 2 -> { removeFlag(tile, ClipFlag.blockSouthEast(true, blocksProjectiles, pathfinder)) removeFlag(tile.transform(1, -1, 0), ClipFlag.blockNorthWest(true, blocksProjectiles, pathfinder)) } 3 -> { removeFlag(tile, ClipFlag.blockSouthWest(true, blocksProjectiles, pathfinder)) removeFlag(tile.transform(-1, -1, 0), ClipFlag.blockNorthEast(true, blocksProjectiles, pathfinder)) } } } ObjectType.WALL_WHOLE_CORNER -> { when (rotation) { 0 -> { removeFlag(tile, ClipFlag.blockNorth(true, blocksProjectiles, pathfinder) or ClipFlag.blockWest(true, blocksProjectiles, pathfinder)) removeFlag(tile.transform(-1, 0, 0), ClipFlag.blockEast(true, blocksProjectiles, pathfinder)) removeFlag(tile.transform(0, 1, 0), ClipFlag.blockSouth(true, blocksProjectiles, pathfinder)) } 1 -> { removeFlag(tile, ClipFlag.blockNorth(true, blocksProjectiles, pathfinder) or ClipFlag.blockEast(true, blocksProjectiles, pathfinder)) removeFlag(tile.transform(0, 1, 0), ClipFlag.blockSouth(true, blocksProjectiles, pathfinder)) removeFlag(tile.transform(1, 0, 0), ClipFlag.blockWest(true, blocksProjectiles, pathfinder)) } 2 -> { removeFlag(tile, ClipFlag.blockEast(true, blocksProjectiles, pathfinder) or ClipFlag.blockSouth(true, blocksProjectiles, pathfinder)) removeFlag(tile.transform(1, 0, 0), ClipFlag.blockWest(true, blocksProjectiles, pathfinder)) removeFlag(tile.transform(0, -1, 0), ClipFlag.blockNorth(true, blocksProjectiles, pathfinder)) } 3 -> { removeFlag(tile, ClipFlag.blockSouth(true, blocksProjectiles, pathfinder) or ClipFlag.blockWest(true, blocksProjectiles, pathfinder)) removeFlag(tile.transform(0, -1, 0), ClipFlag.blockNorth(true, blocksProjectiles, pathfinder)) removeFlag(tile.transform(-1, 0, 0), ClipFlag.blockEast(true, blocksProjectiles, pathfinder)) } } } else -> {} } } @JvmStatic fun getFlags(tile: Tile): Int { synchronized(LOCK) { val chunkId = tile.chunkId if (allFlags[chunkId] == null) return -1 return allFlags[chunkId]!![tile.xInChunk or (tile.yInChunk shl 3)] } } @JvmStatic fun getFlags(x: Int, y: Int, plane: Int): Int { synchronized(LOCK) { val chunkId = MapUtils.encode(MapUtils.Structure.CHUNK, x shr 3, y shr 3, plane) if (allFlags[chunkId] == null) return -1 return allFlags[chunkId]!![x and 7 or ((y and 7) shl 3)] } } @JvmStatic fun addFlag(tile: Tile, flag: Int) { synchronized(LOCK) { val chunkId = tile.chunkId if (allFlags[chunkId] == null) allFlags[chunkId] = IntArray(64) allFlags[chunkId]!![tile.xInChunk or (tile.yInChunk shl 3)] = allFlags[chunkId]!![tile.xInChunk or (tile.yInChunk shl 3)] or flag } } @JvmStatic fun removeFlag(tile: Tile, flag: Int) { synchronized(LOCK) { val chunkId = tile.chunkId if (allFlags[chunkId] == null) allFlags[chunkId] = IntArray(64) allFlags[chunkId]!![tile.xInChunk or (tile.yInChunk shl 3)] = allFlags[chunkId]!![tile.xInChunk or (tile.yInChunk shl 3)] and flag.inv() } } @JvmStatic fun setFlags(tile: Tile, flag: Int) { synchronized(LOCK) { val chunkId = tile.chunkId if (allFlags[chunkId] == null) allFlags[chunkId] = IntArray(64) allFlags[chunkId]!![tile.xInChunk or (tile.yInChunk shl 3)] = flag } } @JvmStatic fun clip(obj: GameObject) { if (obj.getId() == -1) return val type: ObjectType = obj.type val rotation: Int = obj.rotation val defs: ObjectDefinitions = ObjectDefinitions.getDefs(obj.id) if (defs.getClipType() == 0) return when (type) { ObjectType.WALL_STRAIGHT, ObjectType.WALL_DIAGONAL_CORNER, ObjectType.WALL_WHOLE_CORNER, ObjectType.WALL_STRAIGHT_CORNER -> addWall(obj.tile, type, rotation, defs.blocks(), !defs.ignoresPathfinder) ObjectType.WALL_INTERACT, ObjectType.SCENERY_INTERACT, ObjectType.GROUND_INTERACT, ObjectType.STRAIGHT_SLOPE_ROOF, ObjectType.DIAGONAL_SLOPE_ROOF, ObjectType.DIAGONAL_SLOPE_CONNECT_ROOF, ObjectType.STRAIGHT_SLOPE_CORNER_CONNECT_ROOF, ObjectType.STRAIGHT_SLOPE_CORNER_ROOF, ObjectType.STRAIGHT_FLAT_ROOF, ObjectType.STRAIGHT_BOTTOM_EDGE_ROOF, ObjectType.DIAGONAL_BOTTOM_EDGE_CONNECT_ROOF, ObjectType.STRAIGHT_BOTTOM_EDGE_CONNECT_ROOF, ObjectType.STRAIGHT_BOTTOM_EDGE_CONNECT_CORNER_ROOF -> { val sizeX: Int val sizeY: Int if (rotation != 1 && rotation != 3) { sizeX = defs.getSizeX() sizeY = defs.getSizeY() } else { sizeX = defs.getSizeY() sizeY = defs.getSizeX() } addObject(obj.tile, sizeX, sizeY, defs.blocks(), !defs.ignoresPathfinder) } ObjectType.GROUND_DECORATION -> if (defs.clipType == 1) addBlockWalkAndProj(obj.tile) else -> {} } } @JvmStatic fun unclip(tile: Tile) { setFlags(tile, 0) } @JvmStatic fun unclip(obj: GameObject) { if (obj.id == -1) // dont clip or noclip with id -1 return val type: ObjectType = obj.type val rotation: Int = obj.rotation val defs: ObjectDefinitions = ObjectDefinitions.getDefs(obj.id) if (defs.getClipType() == 0) return when (type) { ObjectType.WALL_STRAIGHT, ObjectType.WALL_DIAGONAL_CORNER, ObjectType.WALL_WHOLE_CORNER, ObjectType.WALL_STRAIGHT_CORNER -> removeWall(obj.getTile(), type, rotation, defs.blocks(), !defs.ignoresPathfinder) ObjectType.WALL_INTERACT, ObjectType.SCENERY_INTERACT, ObjectType.GROUND_INTERACT, ObjectType.STRAIGHT_SLOPE_ROOF, ObjectType.DIAGONAL_SLOPE_ROOF, ObjectType.DIAGONAL_SLOPE_CONNECT_ROOF, ObjectType.STRAIGHT_SLOPE_CORNER_CONNECT_ROOF, ObjectType.STRAIGHT_SLOPE_CORNER_ROOF, ObjectType.STRAIGHT_FLAT_ROOF, ObjectType.STRAIGHT_BOTTOM_EDGE_ROOF, ObjectType.DIAGONAL_BOTTOM_EDGE_CONNECT_ROOF, ObjectType.STRAIGHT_BOTTOM_EDGE_CONNECT_ROOF, ObjectType.STRAIGHT_BOTTOM_EDGE_CONNECT_CORNER_ROOF -> { val sizeX: Int val sizeY: Int if (rotation == 1 || rotation == 3) { sizeX = defs.getSizeY() sizeY = defs.getSizeX() } else { sizeX = defs.getSizeX() sizeY = defs.getSizeY() } removeObject(obj.tile, sizeX, sizeY, defs.blocks(), !defs.ignoresPathfinder) } ObjectType.GROUND_DECORATION -> if (defs.clipType == 1) removeBlockWalkAndProj(obj.tile) else -> {} } } }" "package com.rs.engine.pathfinder /** * @author Kris | 16/03/2022 */ @JvmInline public value class ZoneCoords(public val packedCoords: Int) { public constructor( x: Int, y: Int, z: Int, ) : this((x and 0x7FF) or ((y and 0x7FF) shl 11) or ((z and 0x3) shl 22)) public val x: Int get() = packedCoords and 0x7FF public val y: Int get() = (packedCoords shr 11) and 0x7FF public val z: Int get() = (packedCoords shr 22) and 0x3 /** * Converts these zone coordinates to the absolute coordinates of the south-western * tile of this zone. */ public fun toAbsoluteCoords(): AbsoluteCoords = AbsoluteCoords(x shl 3, y shl 3, z) override fun toString(): String = ""ZoneCoords($x, $y, $z)"" }" "package com.rs.engine.pathfinder /** * @author Kris | 16/03/2022 * * A class to hold all the flags for every tile in the game. * The flags are placed into a two-dimensional array, where the outer array * returns the flags array for a given zone(1 x 8 x 8 flags total). * This is done for memory reasons, as it is rather expensive to allocate a * 16384 x 16384 x 4 size int array all in one go(it would also require over a * gigabyte of memory). * * Without any flags, this object initializes as a size 16,777,216 array of * int arrays, all of which are null. This consumes roughly ~67mb of memory to * initialize. */ @Suppress(""NOTHING_TO_INLINE"") public class ZoneFlags { /** * A two-dimensional array to carry all the flags of the game, including instances. */ public val flags: Array = arrayOfNulls(TOTAL_ZONES) /** * Destroys the flags array for the zone at [zoneCoords]. */ public inline fun alloc(zoneCoords: ZoneCoords): IntArray { val packed = zoneCoords.packedCoords val current = flags[packed] if (current != null) return current val new = IntArray(ZONE_SIZE) flags[packed] = new return new } /** * Destroys the flags array for the zone at [zoneCoords]. * It should be noted that [zoneCoords] are not absolute. * To convert from absolute coordinates to zone coordinates, divide the x and y values * each by 8(the size of one zone). * Example: * Converting absolute coordinates [3251, 9422, 1] to [zoneCoords] produces [406, 1177, 1]. */ public inline fun destroy(zoneCoords: ZoneCoords) { flags[zoneCoords.packedCoords] = null } /** * Gets the flag at the absolute coordinates [x, y, z], returning the [default] if the zone is not allocated. */ public inline operator fun get(x: Int, y: Int, z: Int, default: Int = -1): Int { val zoneCoords = ZoneCoords(x shr 3, y shr 3, z) val array = flags[zoneCoords.packedCoords] ?: return default return array[zoneLocal(x, y)] } /** * Sets the flag at the absolute coordinates [x, y, z] to [flag]. */ public inline operator fun set(x: Int, y: Int, z: Int, flag: Int) { alloc(ZoneCoords(x shr 3, y shr 3, z))[zoneLocal(x, y)] = flag } /** * Adds the [flag] bits to the existing flag at the absolute coordinates [x, y, z]. */ public inline fun add(x: Int, y: Int, z: Int, flag: Int) { val flags = alloc(ZoneCoords(x shr 3, y shr 3, z)) val index = zoneLocal(x, y) val cur = flags[index] flags[index] = cur or flag } /** * Removes the [flag] bits from the existing flag at the absolute coordinates [x, y, z]. */ public inline fun remove(x: Int, y: Int, z: Int, flag: Int) { val flags = alloc(ZoneCoords(x shr 3, y shr 3, z)) val index = zoneLocal(x, y) val cur = flags[index] flags[index] = cur and flag.inv() } /** * Gets the flag at the absolute coordinates, returning the [default] if the zone is not allocated. */ public inline operator fun get(absoluteCoords: AbsoluteCoords, default: Int = -1): Int { return get(absoluteCoords.x, absoluteCoords.y, absoluteCoords.z, default) } /** * Sets the flag at the absolute coordinates to [flag]. */ public inline operator fun set(absoluteCoords: AbsoluteCoords, flag: Int) { set(absoluteCoords.x, absoluteCoords.y, absoluteCoords.z, flag) } /** * Adds the [flag] bits to the existing flag at the absolute coordinates. */ public inline fun add(absoluteCoords: AbsoluteCoords, flag: Int) { add(absoluteCoords.x, absoluteCoords.y, absoluteCoords.z, flag) } /** * Removes the [flag] bits from the existing flag at the absolute coordinates. */ public inline fun remove(absoluteCoords: AbsoluteCoords, flag: Int) { remove(absoluteCoords.x, absoluteCoords.y, absoluteCoords.z, flag) } public inline fun zoneLocal(x: Int, y: Int): Int = (x and 0x7) or ((y and 0x7) shl 3) public companion object { public const val TOTAL_ZONES: Int = 2048 * 2048 * 4 public const val ZONE_SIZE: Int = 8 * 8 } }" "package com.rs.engine.pathfinder.bound /** * @author Kris | 12/09/2021 */ public object RectangleBoundaryUtils { public fun collides( srcX: Int, srcY: Int, destX: Int, destY: Int, srcWidth: Int, srcHeight: Int, destWidth: Int, destHeight: Int ): Boolean = if (srcX >= destX + destWidth || srcX + srcWidth <= destX) { false } else { srcY < destY + destHeight && destY < srcHeight + srcY } internal fun reachRectangle1( flags: Array, x: Int, y: Int, z: Int, accessBitMask: Int, destX: Int, destY: Int, destWidth: Int, destHeight: Int ): Boolean { val east = destX + destWidth - 1 val north = destY + destHeight - 1 if (x == destX - 1 && y >= destY && y <= north && (flags[x, y, z] and CollisionFlag.WALL_EAST) == 0 && (accessBitMask and AccessBitFlag.BLOCK_WEST) == 0 ) return true if (x == east + 1 && y >= destY && y <= north && (flags[x, y, z] and CollisionFlag.WALL_WEST) == 0 && (accessBitMask and AccessBitFlag.BLOCK_EAST) == 0 ) return true if (y + 1 == destY && x >= destX && x <= east && (flags[x, y, z] and CollisionFlag.WALL_NORTH) == 0 && (accessBitMask and AccessBitFlag.BLOCK_SOUTH) == 0 ) return true return y == north + 1 && x >= destX && x <= east && (flags[x, y, z] and CollisionFlag.WALL_SOUTH) == 0 && (accessBitMask and AccessBitFlag.BLOCK_NORTH) == 0 } internal fun reachRectangleN( flags: Array, x: Int, y: Int, z: Int, accessBitMask: Int, destX: Int, destY: Int, srcWidth: Int, srcHeight: Int, destWidth: Int, destHeight: Int ): Boolean { val srcEast = x + srcWidth val srcNorth = srcHeight + y val destEast = destWidth + destX val destNorth = destHeight + destY if (destEast == x && (accessBitMask and AccessBitFlag.BLOCK_EAST) == 0) { val fromY = max(y, destY) val toY = min(srcNorth, destNorth) for (sideY in fromY until toY) { if (flags[destEast - 1, sideY, z] and CollisionFlag.WALL_EAST == 0) { return true } } } else if (srcEast == destX && (accessBitMask and AccessBitFlag.BLOCK_WEST) == 0) { val fromY = max(y, destY) val toY = min(srcNorth, destNorth) for (sideY in fromY until toY) { if (flags[destX, sideY, z] and CollisionFlag.WALL_WEST == 0) { return true } } } else if (y == destNorth && (accessBitMask and AccessBitFlag.BLOCK_NORTH) == 0) { val fromX = max(x, destX) val toX = min(srcEast, destEast) for (sideX in fromX until toX) { if (flags[sideX, destNorth - 1, z] and CollisionFlag.WALL_NORTH == 0) { return true } } } else if (destY == srcNorth && (accessBitMask and AccessBitFlag.BLOCK_SOUTH) == 0) { val fromX = max(x, destX) val toX = min(srcEast, destEast) for (sideX in fromX until toX) { if (flags[sideX, destY, z] and CollisionFlag.WALL_SOUTH == 0) { return true } } } return false } @Suppress(""NOTHING_TO_INLINE"") private inline operator fun Array.get( x: Int, y: Int, z: Int ): Int { val zone = this[getZoneIndex(x, y, z)] ?: return -1 return zone[getIndexInZone(x, y)] } }" "package com.rs.engine.pathfinder.bound internal fun reachRectangle( flags: Array, x: Int, y: Int, z: Int, accessBitMask: Int, destX: Int, destY: Int, srcSize: Int, destWidth: Int, destHeight: Int ): Boolean = when { srcSize > 1 -> { RectangleBoundaryUtils .collides(x, y, destX, destY, srcSize, srcSize, destWidth, destHeight) || RectangleBoundaryUtils.reachRectangleN( flags, x, y, z, accessBitMask, destX, destY, srcSize, srcSize, destWidth, destHeight ) } else -> RectangleBoundaryUtils .collides(x, y, destX, destY, srcSize, srcSize, destWidth, destHeight) || RectangleBoundaryUtils.reachRectangle1( flags, x, y, z, accessBitMask, destX, destY, destWidth, destHeight ) }" "package com.rs.engine.pathfinder.bound /** * @author Kris | 12/09/2021 */ internal fun reachExclusiveRectangle( flags: Array, x: Int, y: Int, z: Int, accessBitMask: Int, destX: Int, destY: Int, srcSize: Int, destWidth: Int, destHeight: Int ): Boolean = when { srcSize > 1 -> { if (RectangleBoundaryUtils.collides(x, y, destX, destY, srcSize, srcSize, destWidth, destHeight)) false else RectangleBoundaryUtils.reachRectangleN( flags, x, y, z, accessBitMask, destX, destY, srcSize, srcSize, destWidth, destHeight ) } else -> { if (RectangleBoundaryUtils.collides(x, y, destX, destY, srcSize, srcSize, destWidth, destHeight)) false else RectangleBoundaryUtils.reachRectangle1( flags, x, y, z, accessBitMask, destX, destY, destWidth, destHeight ) } }" "@file:Suppress(""DuplicatedCode"") package com.rs.engine.pathfinder.bound internal fun reachWall( flags: Array, x: Int, y: Int, z: Int, destX: Int, destY: Int, srcSize: Int, shape: Int, rot: Int ): Boolean = when { srcSize == 1 && x == destX && y == destY -> true srcSize != 1 && destX >= x && srcSize + x - 1 >= destX && destY >= y && srcSize + y - 1 >= destY -> true srcSize == 1 -> reachWall1( flags, x, y, z, destX, destY, shape, rot ) else -> reachWallN( flags, x, y, z, destX, destY, srcSize, shape, rot ) } private fun reachWall1( flags: Array, x: Int, y: Int, z: Int, destX: Int, destY: Int, shape: Int, rot: Int ): Boolean { when (shape) { 0 -> { when (rot) { 0 -> { if (x == destX - 1 && y == destY) { return true } if (x == destX && y == destY + 1 && (flags[x, y, z] and CollisionFlag.BLOCK_NORTH) == 0 ) return true if (x == destX && y == destY - 1 && (flags[x, y, z] and CollisionFlag.BLOCK_SOUTH) == 0 ) return true } 1 -> { if (x == destX && y == destY + 1) { return true } if (x == destX - 1 && y == destY && (flags[x, y, z] and CollisionFlag.BLOCK_WEST) == 0 ) return true if (x == destX + 1 && y == destY && (flags[x, y, z] and CollisionFlag.BLOCK_EAST) == 0 ) return true } 2 -> { if (x == destX + 1 && y == destY) { return true } if (x == destX && y == destY + 1 && (flags[x, y, z] and CollisionFlag.BLOCK_NORTH) == 0 ) return true if (x == destX && y == destY - 1 && (flags[x, y, z] and CollisionFlag.BLOCK_SOUTH) == 0 ) return true } 3 -> { if (x == destX && y == destY - 1) { return true } if (x == destX - 1 && y == destY && (flags[x, y, z] and CollisionFlag.BLOCK_WEST) == 0 ) return true if (x == destX + 1 && y == destY && (flags[x, y, z] and CollisionFlag.BLOCK_EAST) == 0 ) return true } } } 2 -> { when (rot) { 0 -> { if (x == destX - 1 && y == destY) { return true } if (x == destX && y == destY + 1) { return true } if (x == destX + 1 && y == destY && (flags[x, y, z] and CollisionFlag.BLOCK_EAST) == 0 ) return true if (x == destX && y == destY - 1 && (flags[x, y, z] and CollisionFlag.BLOCK_SOUTH) == 0 ) return true } 1 -> { if (x == destX - 1 && y == destY && (flags[x, y, z] and CollisionFlag.BLOCK_WEST) == 0 ) return true if (x == destX && y == destY + 1) { return true } if (x == destX + 1 && y == destY) { return true } if (x == destX && y == destY - 1 && (flags[x, y, z] and CollisionFlag.BLOCK_SOUTH) == 0 ) return true } 2 -> { if (x == destX - 1 && y == destY && (flags[x, y, z] and CollisionFlag.BLOCK_WEST) == 0 ) return true if (x == destX && y == destY + 1 && (flags[x, y, z] and CollisionFlag.BLOCK_NORTH) == 0 ) return true if (x == destX + 1 && y == destY) { return true } if (x == destX && y == destY - 1) { return true } } 3 -> { if (x == destX - 1 && y == destY) { return true } if (x == destX && y == destY + 1 && (flags[x, y, z] and CollisionFlag.BLOCK_NORTH) == 0 ) return true if (x == destX + 1 && y == destY && (flags[x, y, z] and CollisionFlag.BLOCK_EAST) == 0 ) return true if (x == destX && y == destY - 1) { return true } } } } 9 -> { if (x == destX && y == destY + 1 && (flags[x, y, z] and CollisionFlag.WALL_SOUTH) == 0 ) return true if (x == destX && y == destY - 1 && (flags[x, y, z] and CollisionFlag.WALL_NORTH) == 0 ) return true if (x == destX - 1 && y == destY && (flags[x, y, z] and CollisionFlag.WALL_EAST) == 0 ) return true return x == destX + 1 && y == destY && (flags[x, y, z] and CollisionFlag.WALL_WEST) == 0 } } return false } private fun reachWallN( flags: Array, x: Int, y: Int, z: Int, destX: Int, destY: Int, srcSize: Int, shape: Int, rot: Int ): Boolean { val east = x + srcSize - 1 val north = y + srcSize - 1 when (shape) { 0 -> { when (rot) { 0 -> { if (x == destX - srcSize && y <= destY && north >= destY) { return true } if (destX in x..east && y == destY + 1 && (flags[destX, y, z] and CollisionFlag.BLOCK_NORTH) == 0 ) return true if (destX in x..east && y == destY - srcSize && (flags[destX, north, z] and CollisionFlag.BLOCK_SOUTH) == 0 ) return true } 1 -> { if (destX in x..east && y == destY + 1) { return true } if (x == destX - srcSize && y <= destY && north >= destY && (flags[east, destY, z] and CollisionFlag.BLOCK_WEST) == 0 ) return true if (x == destX + 1 && y <= destY && north >= destY && (flags[x, destY, z] and CollisionFlag.BLOCK_EAST) == 0 ) return true } 2 -> { if (x == destX + 1 && y <= destY && north >= destY) { return true } if (destX in x..east && y == destY + 1 && (flags[destX, y, z] and CollisionFlag.BLOCK_NORTH) == 0 ) return true if (destX in x..east && y == destY - srcSize && (flags[destX, north, z] and CollisionFlag.BLOCK_SOUTH) == 0 ) return true } 3 -> { if (destX in x..east && y == destY - srcSize) { return true } if (x == destX - srcSize && y <= destY && north >= destY && (flags[east, destY, z] and CollisionFlag.BLOCK_WEST) == 0 ) return true if (x == destX + 1 && y <= destY && north >= destY && (flags[x, destY, z] and CollisionFlag.BLOCK_EAST) == 0 ) return true } } } 2 -> { when (rot) { 0 -> { if (x == destX - srcSize && y <= destY && north >= destY) { return true } if (destX in x..east && y == destY + 1) { return true } if (x == destX + 1 && y <= destY && north >= destY && (flags[x, destY, z] and CollisionFlag.BLOCK_EAST) == 0 ) return true if (destX in x..east && y == destY - srcSize && (flags[destX, north, z] and CollisionFlag.BLOCK_SOUTH) == 0 ) return true } 1 -> { if (x == destX - srcSize && y <= destY && north >= destY && (flags[east, destY, z] and CollisionFlag.BLOCK_WEST) == 0 ) return true if (destX in x..east && y == destY + 1) { return true } if (x == destX + 1 && y <= destY && north >= destY) { return true } if (destX in x..east && y == destY - srcSize && (flags[destX, north, z] and CollisionFlag.BLOCK_SOUTH) == 0 ) return true } 2 -> { if (x == destX - srcSize && y <= destY && north >= destY && (flags[east, destY, z] and CollisionFlag.BLOCK_WEST) == 0 ) return true if (destX in x..east && y == destY + 1 && (flags[destX, y, z] and CollisionFlag.BLOCK_NORTH) == 0 ) return true if (x == destX + 1 && y <= destY && north >= destY) { return true } if (destX in x..east && y == destY - srcSize) { return true } } 3 -> { if (x == destX - srcSize && y <= destY && north >= destY) { return true } if (destX in x..east && y == destY + 1 && (flags[destX, y, z] and CollisionFlag.BLOCK_NORTH) == 0 ) return true if (x == destX + 1 && y <= destY && north >= destY && (flags[x, destY, z] and CollisionFlag.BLOCK_EAST) == 0 ) return true if (destX in x..east && y == destY - srcSize) { return true } } } } 9 -> { if (destX in x..east && y == destY + 1 && (flags[destX, y, z] and CollisionFlag.BLOCK_NORTH) == 0 ) return true if (destX in x..east && y == destY - srcSize && (flags[destX, north, z] and CollisionFlag.BLOCK_SOUTH) == 0 ) return true if (x == destX - srcSize && y <= destY && north >= destY && (flags[east, destY, z] and CollisionFlag.BLOCK_WEST) == 0 ) return true return x == destX + 1 && y <= destY && north >= destY && (flags[x, destY, z] and CollisionFlag.BLOCK_EAST) == 0 } } return false } @Suppress(""NOTHING_TO_INLINE"") private inline operator fun Array.get( x: Int, y: Int, z: Int ): Int { val zone = this[getZoneIndex(x, y, z)] ?: return -1 return zone[getIndexInZone(x, y)] }" "@file:Suppress(""DuplicatedCode"") package com.rs.engine.pathfinder.bound internal fun reachWallDeco( flags: Array, x: Int, y: Int, z: Int, destX: Int, destY: Int, srcSize: Int, shape: Int, rot: Int ): Boolean = when { srcSize == 1 && x == destX && destY == y -> true srcSize != 1 && destX >= x && srcSize + x - 1 >= destX && destY >= y && srcSize + y - 1 >= destY -> true srcSize == 1 -> reachWallDeco1( flags, x, y, z, destX, destY, shape, rot ) else -> reachWallDecoN( flags, x, y, z, destX, destY, srcSize, shape, rot ) } private fun reachWallDeco1( flags: Array, x: Int, y: Int, z: Int, destX: Int, destY: Int, shape: Int, rot: Int ): Boolean { if (shape in 6..7) { when (rot.alteredRotation(shape)) { 0 -> { if (x == destX + 1 && y == destY && (flags[x, y, z] and CollisionFlag.WALL_WEST) == 0 ) return true if (x == destX && y == destY - 1 && (flags[x, y, z] and CollisionFlag.WALL_NORTH) == 0 ) return true } 1 -> { if (x == destX - 1 && y == destY && (flags[x, y, z] and CollisionFlag.WALL_EAST) == 0 ) return true if (x == destX && y == destY - 1 && (flags[x, y, z] and CollisionFlag.WALL_NORTH) == 0 ) return true } 2 -> { if (x == destX - 1 && y == destY && (flags[x, y, z] and CollisionFlag.WALL_EAST) == 0 ) return true if (x == destX && y == destY + 1 && (flags[x, y, z] and CollisionFlag.WALL_SOUTH) == 0 ) return true } 3 -> { if (x == destX + 1 && y == destY && (flags[x, y, z] and CollisionFlag.WALL_WEST) == 0 ) return true if (x == destX && y == destY + 1 && (flags[x, y, z] and CollisionFlag.WALL_SOUTH) == 0 ) return true } } } else if (shape == 8) { if (x == destX && y == destY + 1 && (flags[x, y, z] and CollisionFlag.WALL_SOUTH) == 0 ) return true if (x == destX && y == destY - 1 && (flags[x, y, z] and CollisionFlag.WALL_NORTH) == 0 ) return true if (x == destX - 1 && y == destY && (flags[x, y, z] and CollisionFlag.WALL_EAST) == 0 ) return true return x == destX + 1 && y == destY && (flags[x, y, z] and CollisionFlag.WALL_WEST) == 0 } return false } private fun reachWallDecoN( flags: Array, x: Int, y: Int, z: Int, destX: Int, destY: Int, srcSize: Int, shape: Int, rot: Int ): Boolean { val east = x + srcSize - 1 val north = y + srcSize - 1 if (shape in 6..7) { when (rot.alteredRotation(shape)) { 0 -> { if (x == destX + 1 && y <= destY && north >= destY && (flags[x, destY, z] and CollisionFlag.WALL_WEST) == 0 ) return true if (x <= destX && y == destY - srcSize && east >= destX && (flags[destX, north, z] and CollisionFlag.WALL_NORTH) == 0 ) return true } 1 -> { if (x == destX - srcSize && y <= destY && north >= destY && (flags[east, destY, z] and CollisionFlag.WALL_EAST) == 0 ) return true if (x <= destX && y == destY - srcSize && east >= destX && (flags[destX, north, z] and CollisionFlag.WALL_NORTH) == 0 ) return true } 2 -> { if (x == destX - srcSize && y <= destY && north >= destY && (flags[east, destY, z] and CollisionFlag.WALL_EAST) == 0 ) return true if (x <= destX && y == destY + 1 && east >= destX && (flags[destX, y, z] and CollisionFlag.WALL_SOUTH) == 0 ) return true } 3 -> { if (x == destX + 1 && y <= destY && north >= destY && (flags[x, destY, z] and CollisionFlag.WALL_WEST) == 0 ) return true if (x <= destX && y == destY + 1 && east >= destX && (flags[destX, y, z] and CollisionFlag.WALL_SOUTH) == 0 ) return true } } } else if (shape == 8) { if (x <= destX && y == destY + 1 && east >= destX && (flags[destX, y, z] and CollisionFlag.WALL_SOUTH) == 0 ) return true if (x <= destX && y == destY - srcSize && east >= destX && (flags[destX, north, z] and CollisionFlag.WALL_NORTH) == 0 ) return true if (x == destX - srcSize && y <= destY && north >= destY && (flags[east, destY, z] and CollisionFlag.WALL_EAST) == 0 ) return true return x == destX + 1 && y <= destY && north >= destY && (flags[x, destY, z] and CollisionFlag.WALL_WEST) == 0 } return false } private fun Int.alteredRotation(shape: Int): Int { return if (shape == 7) (this + 2) and 0x3 else this } @Suppress(""NOTHING_TO_INLINE"") private inline operator fun Array.get( x: Int, y: Int, z: Int ): Int { val zone = this[getZoneIndex(x, y, z)] ?: return -1 return zone[getIndexInZone(x, y)] }" "@file:Suppress(""unused"") package com.rs.engine.pathfinder.collision enum class CollisionStrategyType(val strategy: CollisionStrategy) { NORMAL(NormalBlockFlagCollision()), WATER(BlockedFlagCollision()), FLY(LineOfSightBlockFlagCollision()), INDOOR(IndoorsFlagCollision()), OUTDOOR(OutdoorsFlagCollision()) }" "package com.rs.engine.pathfinder.collision public interface CollisionStrategy { public fun canMove(tileFlag: Int, blockFlag: Int): Boolean } public class NormalBlockFlagCollision : CollisionStrategy { override fun canMove(tileFlag: Int, blockFlag: Int): Boolean { return (tileFlag and blockFlag) == 0 } } public class IndoorsFlagCollision : CollisionStrategy { override fun canMove(tileFlag: Int, blockFlag: Int): Boolean { return (tileFlag and blockFlag) == 0 && (tileFlag and CollisionFlag.ROOF) != 0 } } public class OutdoorsFlagCollision : CollisionStrategy { override fun canMove(tileFlag: Int, blockFlag: Int): Boolean { return (tileFlag and (blockFlag or CollisionFlag.ROOF)) == 0 } } public class BlockedFlagCollision() : CollisionStrategy { override fun canMove(tileFlag: Int, blockFlag: Int): Boolean { val flag = blockFlag and CollisionFlag.FLOOR.inv() return (tileFlag and flag) == 0 && (tileFlag and CollisionFlag.FLOOR) != 0 } } public class LineOfSightBlockFlagCollision : CollisionStrategy { override fun canMove(tileFlag: Int, blockFlag: Int): Boolean { val movementFlags = (blockFlag and BLOCK_MOVEMENT) shl 9 val routeFlags = (blockFlag and BLOCK_ROUTE) shr 13 val finalBlockFlag = movementFlags or routeFlags return (tileFlag and finalBlockFlag) == 0 } private companion object { private const val BLOCK_MOVEMENT = CollisionFlag.WALL_NORTH_WEST or CollisionFlag.WALL_NORTH or CollisionFlag.WALL_NORTH_EAST or CollisionFlag.WALL_EAST or CollisionFlag.WALL_SOUTH_EAST or CollisionFlag.WALL_SOUTH or CollisionFlag.WALL_SOUTH_WEST or CollisionFlag.WALL_WEST or CollisionFlag.OBJECT private const val BLOCK_ROUTE = CollisionFlag.WALL_NORTH_WEST_ROUTE_BLOCKER or CollisionFlag.WALL_NORTH_ROUTE_BLOCKER or CollisionFlag.WALL_NORTH_EAST_ROUTE_BLOCKER or CollisionFlag.WALL_EAST_ROUTE_BLOCKER or CollisionFlag.WALL_SOUTH_EAST_ROUTE_BLOCKER or CollisionFlag.WALL_SOUTH_ROUTE_BLOCKER or CollisionFlag.WALL_SOUTH_WEST_ROUTE_BLOCKER or CollisionFlag.WALL_WEST_ROUTE_BLOCKER or CollisionFlag.OBJECT_ROUTE_BLOCKER } }" "package com.rs.engine.pathfinder.flag /** * @author Kris | 15/01/2022 */ public object AccessBitFlag { public const val BLOCK_NORTH: Int = 0x1 public const val BLOCK_EAST: Int = 0x2 public const val BLOCK_SOUTH: Int = 0x4 public const val BLOCK_WEST: Int = 0x8 }" "@file:Suppress(""MemberVisibilityCanBePrivate"", ""unused"") package com.rs.engine.pathfinder.flag public object CollisionFlag { public const val WALL_NORTH_WEST: Int = 0x1 public const val WALL_NORTH: Int = 0x2 public const val WALL_NORTH_EAST: Int = 0x4 public const val WALL_EAST: Int = 0x8 public const val WALL_SOUTH_EAST: Int = 0x10 public const val WALL_SOUTH: Int = 0x20 public const val WALL_SOUTH_WEST: Int = 0x40 public const val WALL_WEST: Int = 0x80 public const val OBJECT: Int = 0x100 public const val WALL_NORTH_WEST_PROJECTILE_BLOCKER: Int = 0x200 public const val WALL_NORTH_PROJECTILE_BLOCKER: Int = 0x400 public const val WALL_NORTH_EAST_PROJECTILE_BLOCKER: Int = 0x800 public const val WALL_EAST_PROJECTILE_BLOCKER: Int = 0x1000 public const val WALL_SOUTH_EAST_PROJECTILE_BLOCKER: Int = 0x2000 public const val WALL_SOUTH_PROJECTILE_BLOCKER: Int = 0x4000 public const val WALL_SOUTH_WEST_PROJECTILE_BLOCKER: Int = 0x8000 public const val WALL_WEST_PROJECTILE_BLOCKER: Int = 0x10000 public const val OBJECT_PROJECTILE_BLOCKER: Int = 0x20000 public const val FLOOR_DECORATION: Int = 0x40000 /** * Custom flag dedicated to blocking NPCs. */ public const val BLOCK_NPCS: Int = 0x80000 /** * Custom flag dedicated to blocking players, projectiles as well as NPCs. * An example of a monster to set this flag is Brawler. Note that it is unclear if this flag * prevents NPCs, as there is a separate flag option for it. * This flag is similar to the one above, except it's strictly for NPCs. */ public const val BLOCK_PLAYERS: Int = 0x100000 public const val FLOOR: Int = 0x200000 public const val WALL_NORTH_WEST_ROUTE_BLOCKER: Int = 0x400000 public const val WALL_NORTH_ROUTE_BLOCKER: Int = 0x800000 public const val WALL_NORTH_EAST_ROUTE_BLOCKER: Int = 0x1000000 public const val WALL_EAST_ROUTE_BLOCKER: Int = 0x2000000 public const val WALL_SOUTH_EAST_ROUTE_BLOCKER: Int = 0x4000000 public const val WALL_SOUTH_ROUTE_BLOCKER: Int = 0x8000000 public const val WALL_SOUTH_WEST_ROUTE_BLOCKER: Int = 0x10000000 public const val WALL_WEST_ROUTE_BLOCKER: Int = 0x20000000 public const val OBJECT_ROUTE_BLOCKER: Int = 0x40000000 /** * Roof flag, used to bind NPCs to not leave the buildings they spawn in. This is a custom flag. */ public const val ROOF: Int = 0x80000000.toInt() /* A shorthand combination of both the floor flags. */ private const val FLOOR_BLOCKED = FLOOR or FLOOR_DECORATION /* Mixed masks of the above flags */ public const val BLOCK_WEST: Int = WALL_EAST or OBJECT or FLOOR_BLOCKED public const val BLOCK_EAST: Int = WALL_WEST or OBJECT or FLOOR_BLOCKED public const val BLOCK_SOUTH: Int = WALL_NORTH or OBJECT or FLOOR_BLOCKED public const val BLOCK_NORTH: Int = WALL_SOUTH or OBJECT or FLOOR_BLOCKED public const val BLOCK_SOUTH_WEST: Int = WALL_NORTH or WALL_NORTH_EAST or WALL_EAST or OBJECT or FLOOR_BLOCKED public const val BLOCK_SOUTH_EAST: Int = WALL_NORTH_WEST or WALL_NORTH or WALL_WEST or OBJECT or FLOOR_BLOCKED public const val BLOCK_NORTH_WEST: Int = WALL_EAST or WALL_SOUTH_EAST or WALL_SOUTH or OBJECT or FLOOR_BLOCKED public const val BLOCK_NORTH_EAST: Int = WALL_SOUTH or WALL_SOUTH_WEST or WALL_WEST or OBJECT or FLOOR_BLOCKED public const val BLOCK_NORTH_AND_SOUTH_EAST: Int = WALL_NORTH or WALL_NORTH_EAST or WALL_EAST or WALL_SOUTH_EAST or WALL_SOUTH or OBJECT or FLOOR_BLOCKED public const val BLOCK_NORTH_AND_SOUTH_WEST: Int = WALL_NORTH_WEST or WALL_NORTH or WALL_SOUTH or WALL_SOUTH_WEST or WALL_WEST or OBJECT or FLOOR_BLOCKED public const val BLOCK_NORTH_EAST_AND_WEST: Int = WALL_NORTH_WEST or WALL_NORTH or WALL_NORTH_EAST or WALL_EAST or WALL_WEST or OBJECT or FLOOR_BLOCKED public const val BLOCK_SOUTH_EAST_AND_WEST: Int = WALL_EAST or WALL_SOUTH_EAST or WALL_SOUTH or WALL_SOUTH_WEST or WALL_WEST or OBJECT or FLOOR_BLOCKED /* Route blocker flags. These are used in ~550+ clients to generate paths through bankers and such. */ public const val BLOCK_WEST_ROUTE_BLOCKER: Int = WALL_EAST_ROUTE_BLOCKER or OBJECT_ROUTE_BLOCKER or FLOOR_BLOCKED public const val BLOCK_EAST_ROUTE_BLOCKER: Int = WALL_WEST_ROUTE_BLOCKER or OBJECT_ROUTE_BLOCKER or FLOOR_BLOCKED public const val BLOCK_SOUTH_ROUTE_BLOCKER: Int = WALL_NORTH_ROUTE_BLOCKER or OBJECT_ROUTE_BLOCKER or FLOOR_BLOCKED public const val BLOCK_NORTH_ROUTE_BLOCKER: Int = WALL_SOUTH_ROUTE_BLOCKER or OBJECT_ROUTE_BLOCKER or FLOOR_BLOCKED public const val BLOCK_SOUTH_WEST_ROUTE_BLOCKER: Int = WALL_NORTH_ROUTE_BLOCKER or WALL_NORTH_EAST_ROUTE_BLOCKER or WALL_EAST_ROUTE_BLOCKER or OBJECT_ROUTE_BLOCKER or FLOOR_BLOCKED public const val BLOCK_SOUTH_EAST_ROUTE_BLOCKER: Int = WALL_NORTH_WEST_ROUTE_BLOCKER or WALL_NORTH_ROUTE_BLOCKER or WALL_WEST_ROUTE_BLOCKER or OBJECT_ROUTE_BLOCKER or FLOOR_BLOCKED public const val BLOCK_NORTH_WEST_ROUTE_BLOCKER: Int = WALL_EAST_ROUTE_BLOCKER or WALL_SOUTH_EAST_ROUTE_BLOCKER or WALL_SOUTH_ROUTE_BLOCKER or OBJECT_ROUTE_BLOCKER or FLOOR_BLOCKED public const val BLOCK_NORTH_EAST_ROUTE_BLOCKER: Int = WALL_SOUTH_ROUTE_BLOCKER or WALL_SOUTH_WEST_ROUTE_BLOCKER or WALL_WEST_ROUTE_BLOCKER or OBJECT_ROUTE_BLOCKER or FLOOR_BLOCKED public const val BLOCK_NORTH_AND_SOUTH_EAST_ROUTE_BLOCKER: Int = WALL_NORTH_ROUTE_BLOCKER or WALL_NORTH_EAST_ROUTE_BLOCKER or WALL_EAST_ROUTE_BLOCKER or WALL_SOUTH_EAST_ROUTE_BLOCKER or WALL_SOUTH_ROUTE_BLOCKER or OBJECT_ROUTE_BLOCKER or FLOOR_BLOCKED public const val BLOCK_NORTH_AND_SOUTH_WEST_ROUTE_BLOCKER: Int = WALL_NORTH_WEST_ROUTE_BLOCKER or WALL_NORTH_ROUTE_BLOCKER or WALL_SOUTH_ROUTE_BLOCKER or WALL_SOUTH_WEST_ROUTE_BLOCKER or WALL_WEST_ROUTE_BLOCKER or OBJECT_ROUTE_BLOCKER or FLOOR_BLOCKED public const val BLOCK_NORTH_EAST_AND_WEST_ROUTE_BLOCKER: Int = WALL_NORTH_WEST_ROUTE_BLOCKER or WALL_NORTH_ROUTE_BLOCKER or WALL_NORTH_EAST_ROUTE_BLOCKER or WALL_EAST_ROUTE_BLOCKER or WALL_WEST_ROUTE_BLOCKER or OBJECT_ROUTE_BLOCKER or FLOOR_BLOCKED public const val BLOCK_SOUTH_EAST_AND_WEST_ROUTE_BLOCKER: Int = WALL_EAST_ROUTE_BLOCKER or WALL_SOUTH_EAST_ROUTE_BLOCKER or WALL_SOUTH_ROUTE_BLOCKER or WALL_SOUTH_WEST_ROUTE_BLOCKER or WALL_WEST_ROUTE_BLOCKER or OBJECT_ROUTE_BLOCKER or FLOOR_BLOCKED }" "package com.rs.engine.pathfinder.flag public object DirectionFlag { public const val NORTH: Int = 0x1 public const val EAST: Int = 0x2 public const val SOUTH: Int = 0x4 public const val WEST: Int = 0x8 public const val SOUTH_WEST: Int = WEST or SOUTH public const val NORTH_WEST: Int = WEST or NORTH public const val SOUTH_EAST: Int = EAST or SOUTH public const val NORTH_EAST: Int = EAST or NORTH }" "package com.rs.engine.pathfinder.reach private const val WALL_STRATEGY = 0 private const val WALL_DECO_STRATEGY = 1 private const val RECTANGLE_STRATEGY = 2 private const val NO_STRATEGY = 3 private const val RECTANGLE_EXCLUSIVE_STRATEGY = 4 public object DefaultReachStrategy : ReachStrategy { override fun reached( flags: Array, x: Int, y: Int, z: Int, destX: Int, destY: Int, destWidth: Int, destHeight: Int, srcSize: Int, rotation: Int, shape: Int, accessBitMask: Int, ): Boolean { val exitStrategy = shape.exitStrategy if (exitStrategy != RECTANGLE_EXCLUSIVE_STRATEGY && x == destX && y == destY) { return true } return when (exitStrategy) { WALL_STRATEGY -> reachWall( flags, x, y, z, destX, destY, srcSize, shape, rotation ) WALL_DECO_STRATEGY -> reachWallDeco( flags, x, y, z, destX, destY, srcSize, shape, rotation ) RECTANGLE_STRATEGY -> reachRectangle( flags, x, y, z, accessBitMask, destX, destY, srcSize, destWidth, destHeight ) RECTANGLE_EXCLUSIVE_STRATEGY -> reachExclusiveRectangle( flags, x, y, z, accessBitMask, destX, destY, srcSize, destWidth, destHeight ) else -> false } } private val Int.exitStrategy: Int get() = when { this == -2 -> RECTANGLE_EXCLUSIVE_STRATEGY this == -1 -> NO_STRATEGY this in 0..3 || this == 9 -> WALL_STRATEGY this < 9 -> WALL_DECO_STRATEGY this in 10..11 || this == 22 -> RECTANGLE_STRATEGY else -> NO_STRATEGY } }" "package com.rs.engine.pathfinder.reach public interface ReachStrategy { public fun reached( flags: Array, x: Int, y: Int, z: Int, destX: Int, destY: Int, destWidth: Int, destHeight: Int, srcSize: Int, rotation: Int, shape: Int, accessBitMask: Int, ): Boolean }" "package com.rs.engine.quest; public enum Quest { COOKS_ASSISTANT(6, 1), DEMON_SLAYER(51, 2), DORICS_QUEST(99, 3), DRAGON_SLAYER(66, 4), ERNEST_CHICKEN(15, 5), GOBLIN_DIPLOMACY(137, 6), IMP_CATCHER(72, 7), KNIGHTS_SWORD(152, 8), PIRATES_TREASURE(60, 9), PRINCE_ALI_RESCUE(64, 10), RESTLESS_GHOST(27, 11), PRISONER_OF_GLOUPHRIE(186, 12), RUNE_MYSTERIES(55, 13), KING_OF_DWARVES(185, 14), SHIELD_OF_ARRAV(63, 15), VAMPYRE_SLAYER(132, 16), GUNNARS_GROUND(179, 17), ANIMAL_MAGNETISM(43, 18), BETWEEN_A_ROCK(57, 19), BIG_CHOMPY_BIRD_HUNTING(102, 20), BIOHAZARD(128, 21), CABIN_FEVER(0, 22), CLOCK_TOWER(44, 23), CONTACT(158, 24), ZOGRE_FLESH_EATERS(104, 25), CREATURE_OF_FENKENSTRAIN(92, 26), DARKNESS_OF_HALLOWVALE(26, 27), DEATH_TO_DORGESHUUN(13, 28), DEATH_PLATEAU(140, 29), DESERT_TREASURE(135, 30), DEVIOUS_MINDS(123, 31), DIG_SITE(69, 32), DRUIDIC_RITUAL(111, 33), DWARF_CANNON(34, 34), EADGARS_RUSE(75, 35), EAGLES_PEAK(149, 36), ELEMENTAL_WORKSHOP_I(8, 37), ELEMENTAL_WORKSHOP_II(94, 38), ENAKHRAS_LAMENT(97, 39), ENLIGHTENED_JOURNEY(107, 40), EYES_OF_GLOUPHRIE(143, 41), FAIRY_TALE_I_GROWING_PAINS(73, 42), FAIRY_TALE_II_CURE_A_QUEEN(154, 43), FAMILY_CREST(116, 44), THE_FEUD(136, 45), FIGHT_ARENA(106, 46), FISHING_CONTEST(76, 47), FORGETTABLE_TALE_OF_A_DRUNKEN_DWARF(98, 48), FREMENNIK_TRIALS(50, 49), WATERFALL_QUEST(93, 50), GARDEN_OF_TRANQUILITY(118, 51), GERTRUDES_CAT(138, 52), GHOSTS_AHOY(82, 53), GIANT_DWARF(134, 54), THE_GOLEM(3, 55), GRAND_TREE(65, 56), HAND_IN_SAND(150, 57), HAUNTED_MINE(120, 58), HAZEEL_CULT(125, 59), HEROES_QUEST(38, 60), HOLY_GRAIL(112, 61), HORROR_FROM_DEEP(105, 62), ICTHLARINS_LITTLE_HELPER(141, 63), IN_AID_OF_MYREQUE(21, 64), IN_SEARCH_OF_MYREQUE(19, 65), JUNGLE_POTION(59, 66), LEGENDS_QUEST(119, 67), LOST_CITY(42, 68), LOST_TRIBE(37, 69), LUNAR_DIPLOMACY(24, 70), MAKING_HISTORY(124, 71), MERLINS_CRYSTAL(108, 72), MONKEY_MADNESS(130, 73), MONKS_FRIEND(147, 74), MOUNTAIN_DAUGHTER(151, 75), MOURNINGS_ENDS_PART_I(156, 76), MOURNINGS_ENDS_PART_II(129, 77), MURDER_MYSTERY(28, 78), MY_ARMS_BIG_ADVENTURE(22, 79), NATURE_SPIRIT(133, 80), OBSERVATORY_QUEST(54, 81), ONE_SMALL_FAVOUR(146, 82), PLAGUE_CITY(58, 83), PRIEST_IN_PERIL(9, 84), RAG_AND_BONE_MAN(68, 85), RAT_CATCHERS(67, 86), RECIPE_FOR_DISASTER(30, 87), RECRUITMENT_DRIVE(62, 88), REGICIDE(100, 89), ROVING_ELVES(110, 90), ROYAL_TROUBLE(127, 91), A_RUM_DEAL(101, 92), SCORPION_CATCHER(2, 93), SEA_SLUG(121, 94), SLUG_MENACE(12, 95), SHADES_OF_MORTTON(10, 96), SHADOW_OF_STORM(71, 97), SHEEP_HERDER(39, 98), SHILO_VILLAGE(70, 99), A_SOULS_BANE(36, 100), SPIRITS_OF_ELID(46, 101), SWAN_SONG(48, 102), TAI_BWO_WANNAI_TRIO(89, 103), A_TAIL_OF_TWO_CATS(45, 104), TEARS_OF_GUTHIX(81, 105), TEMPLE_OF_IKOV(126, 106), THRONE_OF_MISCELLANIA(157, 107), TOURIST_TRAP(113, 108), WITCHS_HOUSE(7, 109), TREE_GNOME_VILLAGE(78, 110), TRIBAL_TOTEM(40, 111), TROLL_ROMANCE(90, 112), TROLL_STRONGHOLD(85, 113), UNDERGROUND_PASS(31, 114), WANTED(103, 115), WATCHTOWER(16, 116), COLD_WAR(145, 117), FREMENNIK_ISLES(148, 118), TOWER_OF_LIFE(1, 119), GREAT_BRAIN_ROBBERY(88, 120), WHAT_LIES_BELOW(144, 121), OLAFS_QUEST(153, 122), ANOTHER_SLICE_OF_HAM(155, 123), DREAM_MENTOR(79, 124), GRIM_TALES(32, 125), KINGS_RANSOM(61, 126), PATH_OF_GLOUPHRIE(5, 127), BACK_TO_MY_ROOTS(49, 128), LAND_OF_GOBLINS(91, 129), DEALING_WITH_SCABARAS(25, 130), WOLF_WHISTLE(52, 131), AS_A_FIRST_RESORT(41, 132), CATAPULT_CONSTRUCTION(23, 133), KENNITHS_CONCERNS(96, 134), LEGACY_OF_SEERGAZE(47, 135), PERILS_OF_ICE_MOUNTAIN(109, 136), TOKTZKETDILL(139, 137), SMOKING_KILLS(80, 138), ROCKING_OUT(4, 139), SPIRIT_OF_SUMMER(14, 140), MEETING_HISTORY(142, 141), ALL_FIRED_UP(29, 142), SUMMERS_END(95, 143), DEFENDER_OF_VARROCK(56, 144), WHILE_GUTHIX_SLEEPS(86, 145), IN_PYRE_NEED(87, 146), MYTHS_OF_WHITE_LANDS(74, 148), GLORIOUS_MEMORIES(115, 149), TALE_OF_MUSPAH(18, 150), HUNT_FOR_RED_RAKTUBER(122, 151), CHOSEN_COMMANDER(114, 152), SWEPT_AWAY(20, 153), FUR_N_SEEK(33, 154), MISSING_MY_MUMMY(77, 155), CURSE_OF_ARRAV(117, 156), TEMPLE_AT_SENNTISTEN(168, 157), FAIRY_TALE_III_BATTLE_AT_ORKS_RIFT(175, 158), BLACK_KNIGHTS_FORTRESS(53, 159), FORGIVENESS_OF_A_CHAOS_DWARF(35, 160), WITHIN_LIGHT(167, 161), NOMADS_REQUIEM(170, 162), BLOOD_RUNS_DEEP(169, 163), RUNE_MECHANICS(171, 165), BUYERS_AND_CELLARS(174, 167), LOVE_STORY(11, 168), BLOOD_PACT(172, 170), QUIET_BEFORE_SWARM(177, 171), ELEMENTAL_WORKSHOP_III(176, 172), A_VOID_DANCE(83, 173), VOID_STARES_BACK(180, 174), RITUAL_OF_MAHJARRAT(194, 176), CARNILLEAN_RISING(203, 178), DO_NO_EVIL(183, 179), ELEMENTAL_WORKSHOP_IV(187, 180), A_CLOCKWORK_SYRINGE(188, 181), DEADLIEST_CATCH(191, 182), SALT_IN_WOUND(192, 183), BRANCHES_OF_DARKMEYER(193, 184), ONE_PIERCING_NOTE(196, 187), LET_THEM_EAT_PIE(200, 188), ELDER_KILN(201, 190), FIREMAKERS_CURSE(199, 191), SONG_FROM_DEPTHS(202, 192) ; private static final HashMap QUESTS_BY_ID = new HashMap<>(); private static final HashMap QUESTS_BY_SLOTID = new HashMap<>(); static { for (Quest quest : Quest.values()) { QUESTS_BY_ID.put(quest.id, quest); QUESTS_BY_SLOTID.put(quest.slotId, quest); } initializeHandlers(); } public static void initializeHandlers() { try { List> classes = Utils.getClassesWithAnnotation(""com.rs"", QuestHandler.class); for (Class clazz : classes) { QuestHandler handler = clazz.getAnnotation(QuestHandler.class); if (handler == null || clazz.getSuperclass() != QuestOutline.class) continue; handler.quest().handler = (QuestOutline) clazz.getConstructor().newInstance(); } } catch (ClassNotFoundException | IOException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException e) { e.printStackTrace(); } } public static Quest forId(int id) { return QUESTS_BY_ID.get(id); } public static Quest forSlot(int id) { return QUESTS_BY_SLOTID.get(id); } private final int id; private final int slotId; private QuestOutline handler; private Quest(int id, int slotId) { this(id, slotId, null); } private Quest(int id, int slotId, QuestOutline handler) { this.id = id; this.slotId = slotId; this.handler = handler; } public int getId() { return id; } public boolean isImplemented() { return handler != null; } public QuestOutline getHandler() { return handler; } public boolean meetsReqs(Player player) { return meetsReqs(player, null); } public boolean meetsReqs(Player player, String actionStr) { boolean meetsRequirements = true; for (Quest quest : getDefs().getExtraInfo().getPreReqs()) { if (!player.isQuestComplete(quest)) { if (actionStr != null && quest.isImplemented()) player.sendMessage(""You must have completed "" + quest.getDefs().name + "".""); meetsRequirements = false; } } for (int skillId : getDefs().getExtraInfo().getPreReqSkillReqs().keySet()) { if (player.getSkills().getLevelForXp(skillId) < getDefs().getExtraInfo().getPreReqSkillReqs().get(skillId)) { if (actionStr != null) player.sendMessage(""You need a "" + Skills.SKILL_NAME[skillId] + "" level of "" + getDefs().getExtraInfo().getPreReqSkillReqs().get(skillId)+"".""); meetsRequirements = false; } } if (!meetsRequirements && actionStr != null) player.sendMessage(""You must meet the requirements for "" + getDefs().name + "" "" + actionStr); return meetsRequirements; } public String getQuestPointRewardLine() { int qp = getDefs().questpointReward; return qp+"" Quest point""+(qp > 1 ? ""s"" : """")+""
""; } public int getStructId() { return EnumDefinitions.getEnum(2252).getIntValue(slotId); } public StructDefinitions getStruct() { return StructDefinitions.getStruct(getStructId()); } public void openQuestInfo(Player player, boolean promptStart) { player.getPackets().sendVarc(699, getStructId()); player.getInterfaceManager().sendInterface(1243); if (promptStart) { player.getPackets().setIFHidden(1243, 45, false); player.getPackets().setIFHidden(1243, 57, true); player.getPackets().setIFHidden(1243, 56, true); player.getPackets().setIFEvents(new IFEvents(1243, 46, -1, -1).enableContinueButton()); player.getPackets().setIFEvents(new IFEvents(1243, 51, -1, -1).enableContinueButton()); } else player.getPackets().setIFHidden(1243, 58, false); String reqStr = getRequirementsString(player); player.getPackets().sendVarcString(359, reqStr); if (!isImplemented() || !getDefs().getExtraInfo().usesNewInterface()) { WorldTasks.schedule(0, () -> { int questState = player.isQuestStarted(this) ? 1 : 0; int height = 0; String startPointDesc = getStartLocationDescription(player); player.getPackets().sendRunScript(4249, 81461265, 81461266, 81461267, -1, -1, questState, height, """" + ""Start point:"" + """", startPointDesc); height += Utils.getIFStringHeightAbs(startPointDesc, 495, 374); player.getPackets().sendRunScript(4249, 81461268, 81461269, 81461270, -1, -1, questState, height, """" + ""Requirements:"" + """", reqStr); height += Utils.getIFStringHeightAbs(reqStr, 495, 357); String requiredItemsStr = getRequiredItemsString(); player.getPackets().sendRunScript(4249, 81461271, 81461272, 81461273, 81461274, 81461279, questState, height, """" + ""Required items:"" + """", requiredItemsStr); height += Utils.getIFStringHeightAbs(requiredItemsStr, 495, 351); String combatStuffStr = getCombatInformationString(); player.getPackets().sendRunScript(4249, 81461280, 81461281, 81461282, -1, -1, questState, height, """" + ""Combat:"" + """", combatStuffStr); height += Utils.getIFStringHeightAbs(combatStuffStr, 495, 393); String rewardsStr = getRewardsString(); player.getPackets().sendRunScript(4249, 81461283, 81461284, 81461285, 81461286, 81461291, questState, height, """" + ""Rewards:"" + """", rewardsStr); height += Utils.getIFStringHeightAbs(rewardsStr, 495, 388); player.getPackets().sendRunScript(5510, -1, 81461264, height, 0); player.getPackets().sendRunScript(31, 81461292, 81461264, 5666, 5663, 5664, 5665, 5686, 5685); }); } else player.getPackets().sendVarcString(359, reqStr); } private String getStartLocationDescription(Player player) { QuestOutline handler = getHandler(); if (handler == null) return ""This quest is not yet implemented. Unimplemented quests will automatically complete upon all requirements being met for them.

"" + ""You currently have "" + (player.isQuestComplete(this) ? ""COMPLETED"" : ""NOT COMPLETED"") + "" this quest.
""; return getHandler().getStartLocationDescription() + (Settings.getConfig().isDebug() ? (""
["" + getDefs().getExtraInfo().getStartLocation().getX() + "", "" + getDefs().getExtraInfo().getStartLocation().getY() + "", "" + getDefs().getExtraInfo().getStartLocation().getPlane() + ""]"") : """"); } private String getRequiredItemsString() { QuestOutline handler = getHandler(); if (handler == null) return ""None.""; return getHandler().getRequiredItemsString(); } private String getCombatInformationString() { QuestOutline handler = getHandler(); if (handler == null) return ""None.""; return getHandler().getCombatInformationString(); } private String getRewardsString() { QuestOutline handler = getHandler(); if (handler == null) return getQuestPointRewardLine().replace(""
"", """"); return getQuestPointRewardLine()+getHandler().getRewardsString(); } public String getRequirementsString(Player player) { StringBuilder lines = new StringBuilder(); QuestInformation info = getDefs().getExtraInfo(); if (info.getPreReqs().size() > 0) { for (Quest preReq : info.getPreReqs()) lines.append(Utils.strikeThroughIf(preReq.getDefs().getExtraInfo().getName(), () -> player.isQuestComplete(preReq))).append(""
""); } if (info.getSkillReq().size() > 0) { for (int skillId : info.getSkillReq().keySet()) { if (info.getSkillReq().get(skillId) == 0) continue; lines.append(Utils.strikeThroughIf(info.getSkillReq().get(skillId) + "" "" + Skills.SKILL_NAME[skillId], () -> player.getSkills().getLevelForXp(skillId) >= info.getSkillReq().get(skillId))).append(""
""); } } if (info.getQpReq() > 0) lines.append(info.getQpReq()).append("" quest points
""); return lines.toString().isEmpty() ? ""None."" : lines.toString(); } public QuestDefinitions getDefs() { return QuestDefinitions.getQuestDefinitions(id); } }" "package com.rs.engine.quest; @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.TYPE) public @interface QuestHandler { Quest quest(); String startText(); String itemsText(); String combatText(); String rewardsText(); int completedStage(); }" "package com.rs.engine.quest; @PluginEventHandler public class QuestManager { public static int MAX_QUESTPOINTS = 0; public static ButtonClickHandler handleQuestTabButtons = new ButtonClickHandler(190, e -> { if (e.getComponentId() == 38) e.getPlayer().getQuestManager().setSort(e.getSlotId()); else if (e.getComponentId() == 3) e.getPlayer().getQuestManager().toggleFilter(); else if (e.getComponentId() == 7) e.getPlayer().getQuestManager().toggleHideDone(); else if (e.getComponentId() == 15) { Quest quest = Quest.forSlot(e.getSlotId()); e.getPlayer().getQuestManager().showQuestDetailInterface(quest); } }); private transient Player player; private int sort; private boolean filter; private boolean hideDone; private final Map questStages; private final Map questAttribs; public QuestManager() { questStages = new HashMap<>(); questAttribs = new HashMap<>(); } public void showQuestDetailInterface(Quest quest) { if (quest != null) { if (!player.isQuestStarted(quest) || player.isQuestComplete(quest)) { quest.openQuestInfo(player, false); return; } QuestInformation info = quest.getDefs().getExtraInfo(); ArrayList journalLines = new ArrayList<>(); if (player.getQuestManager().getStage(quest) > 0) { for (int i = 0; i < player.getQuestManager().getStage(quest); i++) { for (String line : quest.getHandler().getJournalLines(player, i)) { for (String subLine : Utils.splitTextIntoLines(line, IComponentDefinitions.getInterfaceComponent(275, 10).fontId, 380)) journalLines.add("""" + subLine); } } } for (String line : quest.getHandler().getJournalLines(player, player.getQuestManager().getStage(quest))) journalLines.addAll(Arrays.asList(Utils.splitTextIntoLines(line, IComponentDefinitions.getInterfaceComponent(275, 10).fontId, 380))); player.getInterfaceManager().sendInterface(275); player.getPackets().sendRunScriptReverse(1207, journalLines.size()); player.getPackets().setIFText(275, 1, info.getName()); for (int i = 10; i < 289; i++) player.getPackets().setIFText(275, i, ((i - 10) >= journalLines.size() ? "" "" : journalLines.get(i - 10))); } } public void unlockQuestTabOptions() { player.getPackets().setIFRightClickOps(190, 15, 0, 201, 0, 1, 2, 3); player.getPackets().setIFEvents(new IFEvents(190, 38, 0, 3).enableRightClickOption(0)); player.getPackets().sendVarc(234, 0); updateOptions(); } public int getStage(Quest quest) { if (questStages.get(quest.getId()) == null) return 0; return questStages.get(quest.getId()); } public void setStage(Quest quest, int stage) { if (!quest.isImplemented()) return; questStages.put(quest.getId(), stage); sendQuestStage(quest); } public void completeQuest(Quest quest) { if (!quest.isImplemented()) return; if (!isComplete(quest)) { setStage(quest, quest.getHandler().getCompletedStage()); clearQuestAttributes(quest); quest.getHandler().complete(player); sendQuestStage(quest); sendQuestPoints(); } } public void resetQuest(Quest quest) { if (!quest.isImplemented()) return; clearQuestAttributes(quest); setStage(quest, 0); } private void clearQuestAttributes(Quest quest) { questAttribs.remove(quest.getId()); } public GenericAttribMap getAttribs(Quest quest) { GenericAttribMap map = questAttribs.computeIfAbsent(quest.getId(), k -> new GenericAttribMap()); return map; } public boolean completedAllQuests() { for (Quest quest : Quest.values()) { if (!quest.isImplemented()) continue; if (!isComplete(quest)) return false; } return true; } public boolean isComplete(Quest quest, String actionForUnimplemented) { if (!quest.isImplemented()) return quest.meetsReqs(player, actionForUnimplemented); if (getStage(quest) == quest.getHandler().getCompletedStage()) return true; if (actionForUnimplemented != null) player.sendMessage(""You must have completed "" + quest.getDefs().name + "" "" + actionForUnimplemented); return false; } public boolean isComplete(Quest quest) { return isComplete(quest, null); } public int getQuestPoints() { int points = 0; for (Quest quest : Quest.values()) { if (quest == null || !quest.isImplemented()) continue; if (isComplete(quest)) points += quest.getDefs().questpointReward; } return points; } public void sendQuestPoints() { player.getVars().setVar(101, getQuestPoints()); player.getVars().setVar(904, MAX_QUESTPOINTS); } public void updateAllQuestStages() { for (Quest quest : Quest.values()) sendQuestStage(quest); } public void sendQuestStage(Quest quest) { if (!quest.isImplemented() || isComplete(quest)) quest.getDefs().sendCompleted(player); else if (getStage(quest) > 0) quest.getDefs().sendStarted(player); if (quest.isImplemented()) quest.getHandler().updateStage(player, getStage(quest)); } public Player getPlayer() { return player; } public void setPlayer(Player player) { this.player = player; if (MAX_QUESTPOINTS == 0) for (Quest quest : Quest.values()) if (quest.isImplemented()) MAX_QUESTPOINTS += quest.getDefs().questpointReward; } public void updateOptions() { //4538 = free/members toggle which is first? player.getVars().setVarBit(4536, sort); player.getVars().setVarBit(4537, filter ? 0 : 1); player.getVars().setVarBit(7264, hideDone ? 0 : 1); player.getVars().syncVarsToClient(); player.getPackets().sendRunScript(2160, 0); } public void setSort(int sort) { this.sort = sort; updateOptions(); } public void toggleFilter() { filter = !filter; updateOptions(); } public void toggleHideDone() { hideDone = !hideDone; updateOptions(); } }" "package com.rs.engine.quest; public abstract class QuestOutline { public final Quest getQuest() { return getClass().getAnnotation(QuestHandler.class).quest(); } public final int getCompletedStage() { return getClass().getAnnotation(QuestHandler.class).completedStage(); }; public abstract List getJournalLines(Player player, int stage); public abstract void complete(Player player); public final String getStartLocationDescription() { return getClass().getAnnotation(QuestHandler.class).startText(); } public final String getRequiredItemsString() { return getClass().getAnnotation(QuestHandler.class).itemsText(); } public final String getCombatInformationString() { return getClass().getAnnotation(QuestHandler.class).combatText(); } public final String getRewardsString() { return getClass().getAnnotation(QuestHandler.class).rewardsText(); } public void updateStage(Player player, int stage) { } public final void sendQuestCompleteInterface(Player player, int itemId) { int jingleNum = Utils.random(0, 4); if(jingleNum == 3) jingleNum = 318; else jingleNum+=152; player.jingle(jingleNum); player.getPackets().sendVarcString(359, getRewardsString()); player.getInterfaceManager().sendInterface(1244); player.getPackets().setIFItem(1244, 24, itemId, 1); player.getPackets().setIFText(1244, 25, ""You have completed ""+getQuest().getDefs().name+""!""); } }" "package com.rs.engine.quest.data; /** * @author Trenton * Necking myself knowing that all of this was in the cache. * Regretting hours of finding varbits by looping for all the quests. */ public class QuestDefinitions { public enum Type { NORMAL, HOLIDAY; } public enum Difficulty { NOVICE, INTERMEDIATE, EXPERIENCED, MASTER, GRANDMASTER, SPECIAL; } public int id; public String name; public String sortName; public boolean members; public int[] _questPrerequisiteIds; public int[][] _levelRequirements; private QuestInformation extraInfo; public int[][] varbitValues; public int[][] varValues; public Type type = Type.NORMAL; public int questpointRequirement; public int questpointReward; public Difficulty difficulty = Difficulty.NOVICE; public HashMap params; public int graphicId; public int[] anIntArray2601; public static final HashMap QUESTS = new HashMap<>(); private static final HashMap QUESTS_NAME = new HashMap<>(); public static void main(String[] args) throws IOException { // Cache.init(); // for (int i = 0;i < Cache.STORE.getIndex(IndexType.CONFIG).getValidFilesCount(ArchiveType.QUESTS.getId());i++) { // QuestDefinitions def = new QuestDefinitions(i); // //Logger.debug(def.name.toUpperCase().replace("" "", ""_"").replaceAll(""[^A-Za-z0-9_]"", """") + ""("" + i + ""),""); // if (i == 0) // Logger.debug(def); // } } public QuestDefinitions(int id) { this.id = id; decode(new InputStream(Cache.STORE.getIndex(IndexType.CONFIG).getFile(ArchiveType.QUESTS.getId(), id))); } public static void init() { QUESTS.clear(); QUESTS_NAME.clear(); for (int i = 0;i < Cache.STORE.getIndex(IndexType.CONFIG).getValidFilesCount(ArchiveType.QUESTS.getId());i++) { QuestDefinitions def = new QuestDefinitions(i); if (def != null) { QUESTS.put(i, def); QUESTS_NAME.put(def.name, def); } } /* * Fix invalid values */ QuestDefinitions quest; //buyers cellars quest = QUESTS.get(174); quest.varbitValues[0][0] = 7793; quest.varbitValues[0][2] = 30; //shield of arrav quest = QUESTS.get(63); quest.varValues[1][1] = 1; //underground pass quest = QUESTS.get(31); quest.varValues[0][1] = 1; //as a first resort quest = QUESTS.get(41); quest.varbitValues[0][1] = 10; //death plat quest = QUESTS.get(140); quest.varValues = null; quest.varbitValues = new int[][] { new int[] { 10761, 1, 65 } }; //workshop I quest = QUESTS.get(8); quest.varValues[0][1] = (1 << 1); quest.varValues[0][2] = (1 << 20); //fur n seek quest = QUESTS.get(33); quest.varbitValues[0][1] = 2; //tai bwo wannai quest = QUESTS.get(89); quest.varValues[0][1] = 3; //muspah quest = QUESTS.get(18); quest.varbitValues[0][1] = 10; //deadliest catch quest = QUESTS.get(191); quest.varbitValues[0][2] = 50; //workshop IV quest = QUESTS.get(187); quest.varbitValues[0][2] = 9; //forgiveness of a chaos dwarf quest = QUESTS.get(35); quest.varbitValues[0][2] = 90; //waterfall quest quest = QUESTS.get(93); quest.varValues[0][2] = 10; //perils of ice mountain quest = QUESTS.get(109); quest.varbitValues[0][2] = 150; //regicide quest = QUESTS.get(100); quest.varValues[0][2] = 15; //rocking out quest = QUESTS.get(4); quest.varbitValues[0][2] = 100; //spirit of summer quest = QUESTS.get(14); quest.varbitValues[0][2] = 100; //Black knights fortress, wrong qp, for some reason it was 0 quest = QUESTS.get(53); quest.questpointReward = 3; } public static QuestDefinitions getQuestDefinitions(int id) { return QUESTS.get(id); } public static QuestDefinitions getQuestDefinitions(String name) { return QUESTS_NAME.get(name); } public void sendStarted(Player player) { if (varValues != null) for (int[] varValue : varValues) player.getVars().setVar(varValue[0], varValue[1]); if (varbitValues != null) for (int[] varbitValue : varbitValues) player.getVars().setVarBit(varbitValue[0], varbitValue[1]); } public void sendCompleted(Player player) { if (varValues != null) for (int[] varValue : varValues) player.getVars().setVar(varValue[0], varValue[2]); if (varbitValues != null) for (int[] varbitValue : varbitValues) player.getVars().setVarBit(varbitValue[0], varbitValue[2]); } public void decode(InputStream buffer) { while (buffer.getRemaining() > 0) { int opcode = buffer.readUnsignedByte(); if (opcode == 0) break; if (1 == opcode) name = buffer.readJagString(); else if (2 == opcode) sortName = buffer.readJagString(); else if (3 == opcode) { int i_3_ = buffer.readUnsignedByte(); varValues = new int[i_3_][3]; for (int i_4_ = 0; i_4_ < i_3_; i_4_++) { varValues[i_4_][0] = buffer.readUnsignedShort(); varValues[i_4_][1] = buffer.readInt(); varValues[i_4_][2] = buffer.readInt(); } } else if (opcode == 4) { int i_5_ = buffer.readUnsignedByte(); varbitValues = new int[i_5_][3]; for (int i_6_ = 0; i_6_ < i_5_; i_6_++) { varbitValues[i_6_][0] = buffer.readUnsignedShort(); varbitValues[i_6_][1] = buffer.readInt(); varbitValues[i_6_][2] = buffer.readInt(); } } else if (5 == opcode) buffer.readShort(); else if (6 == opcode) type = Type.values()[buffer.readUnsignedByte()]; else if (7 == opcode) { int diff = buffer.readUnsignedByte(); if (diff == 250) difficulty = Difficulty.SPECIAL; else difficulty = Difficulty.values()[diff]; } else if (opcode == 8) members = true; else if (opcode == 9) questpointReward = buffer.readUnsignedByte(); else if (opcode == 10) { int i_7_ = buffer.readUnsignedByte(); anIntArray2601 = new int[i_7_]; for (int i_8_ = 0; i_8_ < i_7_; i_8_++) anIntArray2601[i_8_] = buffer.readInt(); } else if (12 == opcode) buffer.readInt(); else if (opcode == 13) { int i_9_ = buffer.readUnsignedByte(); _questPrerequisiteIds = new int[i_9_]; for (int i_10_ = 0; i_10_ < i_9_; i_10_++) _questPrerequisiteIds[i_10_] = buffer.readUnsignedShort(); } else if (opcode == 14) { int i_11_ = buffer.readUnsignedByte(); _levelRequirements = new int[i_11_][2]; for (int i_12_ = 0; i_12_ < i_11_; i_12_++) { _levelRequirements[i_12_][0] = buffer.readUnsignedByte(); _levelRequirements[i_12_][1] = buffer.readUnsignedByte(); } } else if (opcode == 15) questpointRequirement = buffer.readUnsignedShort(); else if (opcode == 17) graphicId = buffer.readBigSmart(); else if (18 == opcode) { int i_13_ = buffer.readUnsignedByte(); int[] varpRequirements = new int[i_13_]; int[] minVarpValue = new int[i_13_]; int[] maxVarpValue = new int[i_13_]; /* * LITERAL JUNK NULL FOR EVERY QUEST */ String[] varpRequirementNames = new String[i_13_]; for (int i_14_ = 0; i_14_ < i_13_; i_14_++) { varpRequirements[i_14_] = buffer.readInt(); minVarpValue[i_14_] = buffer.readInt(); maxVarpValue[i_14_] = buffer.readInt(); varpRequirementNames[i_14_] = buffer.readString(); } } else if (19 == opcode) { int i_15_ = buffer.readUnsignedByte(); int[] varBitRequirements = new int[i_15_]; int[] minVarBitValue = new int[i_15_]; int[] maxVarBitValue = new int[i_15_]; String[] varbitRequirementNames = new String[i_15_]; for (int i_16_ = 0; i_16_ < i_15_; i_16_++) { varBitRequirements[i_16_] = buffer.readInt(); minVarBitValue[i_16_] = buffer.readInt(); maxVarBitValue[i_16_] = buffer.readInt(); varbitRequirementNames[i_16_] = buffer.readString(); } } else if (249 == opcode) { int count = buffer.readUnsignedByte(); if (null == params) params = new HashMap<>(count); for (int index = 0; index < count; index++) { boolean stringVal = (buffer.readUnsignedByte()) == 1; int key = buffer.read24BitInt(); Object value; if (stringVal) value = buffer.readString(); else value = buffer.readInt(); params.put(key, value); } } else Logger.error(QuestDefinitions.class, ""decode"", ""Error unrecognized quest config code: {"" + opcode + ""}""); } } @Override public String toString() { StringBuilder result = new StringBuilder(); String newLine = System.getProperty(""line.separator""); result.append(this.getClass().getName()); result.append("" {""); result.append(newLine); // determine fields declared in this class only (no fields of // superclass) Field[] fields = this.getClass().getDeclaredFields(); // print field names paired with their values for (Field field : fields) { if (Modifier.isStatic(field.getModifiers())) continue; result.append("" ""); try { result.append(field.getType().getCanonicalName()).append("" "").append(field.getName()).append("": ""); result.append(Utils.getFieldValue(this, field)); } catch (Throwable ex) { Logger.handleNoRecord(QuestDefinitions.class, ""toString"", ""Error getting field info:"" + field, ex); } result.append(newLine); } result.append(""}""); return result.toString(); } public QuestInformation getExtraInfo() { return extraInfo; } public void setExtraInfo(QuestInformation extraInfo) { this.extraInfo = extraInfo; } }" "package com.rs.engine.quest.data; public class QuestInformation { private final int id; private final String name; private int startNpc; private Tile startLocation; private final Set preReqs = new HashSet<>(); private final Map skillReqs = new HashMap<>(); private final Map preReqSkillReqs = new HashMap<>(); private int qpReq; private final int slotId; private boolean usesNewInterface; public QuestInformation(int id, String name, int slotId) { this.id = id; this.name = name; this.slotId = slotId; } public int getId() { return id; } public int getStartNpc() { return startNpc; } public void setStartNpc(int startNpc) { this.startNpc = startNpc; } public void setUsesNewInterface(boolean usesNewInterface) { this.usesNewInterface = usesNewInterface; } public boolean usesNewInterface() { return usesNewInterface; } public Tile getStartLocation() { return startLocation; } public void setStartLocation(Tile startLocation) { this.startLocation = startLocation; } public Set getPreReqs() { return preReqs; } public void addPreReq(Quest quest) { preReqs.add(quest); } public Map getSkillReq() { return skillReqs; } public void addSkillReq(int skillId, int level) { if (skillReqs.get(skillId) == null || level > skillReqs.get(skillId)) skillReqs.put(skillId, level); } public int getQpReq() { return qpReq; } public void setQpReq(int qpReq) { this.qpReq = qpReq; } public String getName() { return name; } public int getSlotId() { return slotId; } public Map getPreReqSkillReqs() { return preReqSkillReqs; } public void addPreReqSkillReq(int skillId, int level) { if (preReqSkillReqs.get(skillId) == null || level > preReqSkillReqs.get(skillId)) preReqSkillReqs.put(skillId, level); } }" "package com.rs.engine.quest.data; public class QuestInformationParser { public static final long JOURNAL_SLOTID = 847; public static final long STARTLOC_PRE_HASH = 854; public static final long STARTLOC_HASH = 850; public static final long STEP2_LOC_HASH = 851; public static final long MEMBERS = 856; public static final long NAME = 845; public static final long NAME_SORT = 846; public static final long START_NPC = 691; public static final long REQUIRED_ITEMS = 949; public static final long REWARDS = 951; public static final long ENEMIES_TO_DEFEAT = 950; public static final long START_HINT = 948; public static final long DIFFICULTY = 848; public static final long USES_NEW_INTERFACE = 694; public static final long QUESTPOINT_REQ = 895; public static final long QUEST_REQ_START = 859; public static final long QUEST_REQ_END = 870; public static final long REQ_SKILL_START = 871; public static final long REQ_LEVEL_START = 872; public static final long REQ_SKILL_END = 883; public static final long REQ_LEVEL_END = 884; public static HashMap QUESTS_ID = new HashMap<>(); public static HashMap QUESTS_NAME = new HashMap<>(); public static HashMap QUESTS_SLOTID = new HashMap<>(); public static void init() { EnumDefinitions questEnum = EnumDefinitions.getEnum(2252); for (long i : questEnum.getValues().keySet()) { Quest quest = Quest.forSlot((int) i); if (questEnum.getIntValue(i) != -1) { StructDefinitions detail = StructDefinitions.getStruct(questEnum.getIntValue(i)); HashMap map = detail.getValues(); QuestInformation qi = new QuestInformation((int) i, (String) map.get(NAME), (Integer) map.get(JOURNAL_SLOTID)); if (map.get(START_NPC) != null) qi.setStartNpc((Integer) map.get(START_NPC)); else qi.setStartNpc(-1); if (map.get(QUESTPOINT_REQ) != null) qi.setQpReq((Integer) map.get(QUESTPOINT_REQ)); else qi.setQpReq(0); if (map.get(STARTLOC_HASH) != null) qi.setStartLocation(Tile.of((Integer) map.get(STARTLOC_HASH))); if (map.get(QUEST_REQ_START) != null) { int numReqs = 0; for (long q = QUEST_REQ_START;q <= QUEST_REQ_END;q++) if (map.get(q) != null) numReqs++; int[] reqs = new int[numReqs]; for (int q = 0;q < reqs.length;q++) { reqs[q] = (int) map.get(QUEST_REQ_START+q); qi.addPreReq(Quest.forSlot((int) map.get(QUEST_REQ_START+q))); } } if (map.get(REQ_SKILL_START) != null) { int numReqs = 0; for (long q = REQ_SKILL_START;q <= REQ_SKILL_END;q += 2) if (map.get(q) != null) numReqs++; int[][] reqs = new int[numReqs][2]; for (int q = 0;q < reqs.length;q++) { reqs[q][0] = (int) map.get(REQ_SKILL_START+(q* 2L)); reqs[q][1] = (int) map.get(REQ_LEVEL_START+(q* 2L)); qi.addSkillReq(reqs[q][0], reqs[q][1]); qi.addPreReqSkillReq(reqs[q][0], reqs[q][1]); } } if (map.get(USES_NEW_INTERFACE) != null && (int) map.get(USES_NEW_INTERFACE) == 1) qi.setUsesNewInterface(true); QUESTS_ID.put((int) i, qi); QUESTS_SLOTID.put(qi.getSlotId(), qi); QUESTS_NAME.put(qi.getName(), qi); QuestDefinitions.getQuestDefinitions(quest.getId()).setExtraInfo(qi); } } for (QuestInformation info : QUESTS_ID.values()) for (Quest quest : new HashSet<>(info.getPreReqs())) addPreReqs(info, quest); Quest.VOID_STARES_BACK.getDefs().getExtraInfo().addSkillReq(Skills.DEFENSE, 25); } public static void addPreReqs(QuestInformation info, Quest quest) { for (Quest q : new HashSet<>(quest.getDefs().getExtraInfo().getPreReqs())) addPreReqs(info, q); for (Quest preReq : new HashSet<>(quest.getDefs().getExtraInfo().getPreReqs())) info.addPreReq(preReq); for (int skill : quest.getDefs().getExtraInfo().getSkillReq().keySet()) info.addPreReqSkillReq(skill, quest.getDefs().getExtraInfo().getSkillReq().get(skill)); } }" "package com.rs.engine.thread; public final class AsyncTaskExecutor { public static volatile boolean SHUTDOWN; private static ScheduledExecutorService WORLD_THREAD_EXECUTOR; private static ScheduledExecutorService ASYNC_VTHREAD_EXECUTOR; private static final List> PENDING_FUTURES = new ObjectArrayList<>(); public static void initExecutors() { Logger.info(AsyncTaskExecutor.class, ""startThreads"", ""Initializing world threads...""); WORLD_THREAD_EXECUTOR = Executors.newSingleThreadScheduledExecutor(new WorldThreadFactory()); ASYNC_VTHREAD_EXECUTOR = Executors.newScheduledThreadPool(16, Thread.ofVirtual().factory()); } public static void execute(Runnable command) { synchronized(PENDING_FUTURES) { Future future = ASYNC_VTHREAD_EXECUTOR.submit(new CatchExceptionRunnable(command)); PENDING_FUTURES.add(future); List> finished = new ArrayList<>(); for (Future f : PENDING_FUTURES) if (f.isDone()) finished.add(f); for (Future f : finished) PENDING_FUTURES.remove(f); } } public static void executeWorldThreadSafe(String methodName, CompletableFuture future, int timeoutSeconds, ThrowableRunnable operation) { AtomicBoolean completed = new AtomicBoolean(false); final int maxTicks = Ticks.fromSeconds(timeoutSeconds); AsyncTaskExecutor.execute(() -> { try { operation.run(); } catch (Throwable e) { Logger.handle(AsyncTaskExecutor.class, ""executeWorldThreadSafe:"" + methodName, e); } finally { completed.set(true); } }); WorldTasks.scheduleTimer(0, 0, tick -> { if (completed.get()) { future.complete(true); return false; } if (tick >= maxTicks) { future.completeExceptionally(new TimeoutException(""Operation timed out."")); return false; } return true; }); } @FunctionalInterface public interface ThrowableRunnable { void run() throws Throwable; } public static void schedule(Runnable command, int delay) { ASYNC_VTHREAD_EXECUTOR.schedule(new CatchExceptionRunnable(command), delay*Settings.WORLD_CYCLE_MS, TimeUnit.MILLISECONDS); } public static void schedule(Runnable command, int startDelay, int delay) { ASYNC_VTHREAD_EXECUTOR.scheduleWithFixedDelay(new CatchExceptionRunnable(command), startDelay*Settings.WORLD_CYCLE_MS, delay*Settings.WORLD_CYCLE_MS, TimeUnit.MILLISECONDS); } public static boolean pendingTasks() { synchronized(PENDING_FUTURES) { List> finished = new ArrayList<>(); for (Future f : PENDING_FUTURES) if (f.isDone()) finished.add(f); for (Future f : finished) PENDING_FUTURES.remove(f); boolean allDone = true; for(Future future : PENDING_FUTURES) if (!future.isDone()) allDone = false; return !allDone; } } public static void shutdown() { ASYNC_VTHREAD_EXECUTOR.shutdown(); SHUTDOWN = true; } public static ScheduledExecutorService getWorldThreadExecutor() { return WORLD_THREAD_EXECUTOR; } }" "package com.rs.engine.thread; public final class WorldThread extends Thread { public static long START_CYCLE; public static volatile long WORLD_CYCLE; private static long LOWEST_TICK = 50000; private static long TICKS; private static long TOTAL_TIME = 0; private static long HIGHEST_TICK = 0; protected WorldThread() { setPriority(Thread.MAX_PRIORITY); setName(""World Thread""); setUncaughtExceptionHandler((th, ex) -> Logger.handle(WorldThread.class, ""uncaughtExceptionHandler"", ex)); } public static void init() { WORLD_CYCLE = START_CYCLE = System.currentTimeMillis() / 600L; AsyncTaskExecutor.getWorldThreadExecutor().execute(new WorldThread()); } public static Set NAMES = new HashSet<>(); @Override public void run() { Configuration config = null; if (Settings.getConfig().isEnableJFR()) { try { config = Configuration.create(Paths.get(""./darkan.jfc"")); } catch (IOException | ParseException e) { Logger.handle(WorldThread.class, ""run"", e); throw new RuntimeException(e); } if (config == null) { RuntimeException e = new RuntimeException(""Unable to load darkan flight recorder template.""); Logger.handle(WorldThread.class, ""run"", e); throw e; } } Logger.debug(WorldThread.class, ""run"", ""WorldThread initialized...""); while(true) { long startTime = System.currentTimeMillis(); Recording tickRecording = Settings.getConfig().isEnableJFR() ? new Recording(config) : null; try { if (Settings.getConfig().isEnableJFR()) { Timer timerJFR = new Timer().start(); tickRecording.start(); Logger.trace(WorldThread.class, ""tick"", ""JFR recording() - "" + timerJFR.stop()); } Timer timerChunk = new Timer().start(); ChunkManager.processChunks(); Logger.trace(WorldThread.class, ""tick"", ""processChunks() - "" + timerChunk.stop()); Timer timerTask = new Timer().start(); WorldTasks.processTasks(); Logger.trace(WorldThread.class, ""tick"", ""processTasks() - "" + timerTask.stop()); OwnedObject.processAll(); Timer timerNpcProcTasks = new Timer().start(); for (NPC npc : World.getNPCs()) { try { if (npc == null || npc.hasFinished()) continue; npc.processTasks(); } catch (Throwable e) { Logger.handle(WorldThread.class, ""run:npcProcessEntityTasks"", ""Error processing NPC: "" + (npc == null ? ""NULL NPC"" : npc.getId()), e); } } Logger.trace(WorldThread.class, ""tick"", ""npcProcessEntityTasks() - "" + timerNpcProcTasks.stop()); Timer timerPlayerProcTasks = new Timer().start(); for (Player player : World.getPlayers()) { try { player.processTasks(); } catch (Throwable e) { Logger.handle(WorldThread.class, ""run:playerProcessEntityTasks"", ""Error processing player: "" + (player == null ? ""NULL PLAYER"" : player.getUsername()), e); } } Logger.trace(WorldThread.class, ""tick"", ""playerProcessEntityTasks() - "" + timerPlayerProcTasks.stop()); NAMES.clear(); Timer timerNpcProc = new Timer().start(); for (NPC npc : World.getNPCs()) { try { if (npc == null || npc.hasFinished()) continue; npc.processEntity(); } catch (Throwable e) { Logger.handle(WorldThread.class, ""run:npcProcessEntity"", ""Error processing NPC: "" + (npc == null ? ""NULL NPC"" : npc.getId()), e); } } Logger.trace(WorldThread.class, ""tick"", ""npcProcessEntity() - "" + timerNpcProc.stop()); Timer timerPlayerProc = new Timer().start(); for (Player player : World.getPlayers()) { try { if (player != null && player.getTempAttribs().getB(""realFinished"")) player.realFinish(); if (player == null || !player.hasStarted() || player.hasFinished()) continue; if (NAMES.contains(player.getUsername())) player.logout(false); else NAMES.add(player.getUsername()); player.processEntity(); } catch (Throwable e) { Logger.handle(WorldThread.class, ""run:playerProcessEntity"", ""Error processing player: "" + (player == null ? ""NULL PLAYER"" : player.getUsername()), e); } } Logger.trace(WorldThread.class, ""tick"", ""playerProcessEntity() - "" + timerPlayerProc.stop()); Timer timerNpcMove = new Timer().start(); for (NPC npc : World.getNPCs()) { if (npc == null || npc.hasFinished()) continue; try { npc.processMovement(); } catch (Throwable e) { Logger.handle(WorldThread.class, ""processNPCMovement"", e); } } Logger.trace(WorldThread.class, ""tick"", ""processNPCMovement() - "" + timerNpcMove.stop()); Timer timerPlayerMove = new Timer().start(); for (Player player : World.getPlayers()) { if (player == null || !player.hasStarted() || player.hasFinished()) continue; try { player.processMovement(); } catch (Throwable e) { Logger.handle(WorldThread.class, ""processPlayerMovement"", e); } } Logger.trace(WorldThread.class, ""tick"", ""processPlayerMovement() - "" + timerPlayerMove.stop()); Timer timerEntityUpdate = new Timer().start(); for (Player player : World.getPlayers()) { if (player == null || !player.hasStarted() || player.hasFinished()) continue; try { player.getPackets().sendLocalPlayersUpdate(); player.getPackets().sendLocalNPCsUpdate(); player.postSync(); } catch (Throwable e) { Logger.handle(WorldThread.class, ""processPlayersPostSync"", e); } } Logger.trace(WorldThread.class, ""tick"", ""processPlayersPostSync() - "" + timerEntityUpdate.stop()); Timer timerUpdateZones = new Timer().start(); ChunkManager.processUpdateZones(); Logger.trace(WorldThread.class, ""tick"", ""processUpdateZones() - "" + timerUpdateZones.stop()); Timer timerFlushPackets = new Timer().start(); for (Player player : World.getPlayers()) { if (player == null || !player.hasStarted() || player.hasFinished()) continue; player.getSession().flush(); } Logger.trace(WorldThread.class, ""tick"", ""flushPlayerPackets() - "" + timerFlushPackets.stop()); for (Player player : World.getPlayers()) { if (player == null || !player.hasStarted() || player.hasFinished()) continue; player.resetMasks(); } for (NPC npc : World.getNPCs()) { if (npc == null || npc.hasFinished()) continue; npc.resetMasks(); } World.processEntityLists(); long time = (System.currentTimeMillis() - startTime); Logger.trace(WorldThread.class, ""tick"", ""Tick finished - Mem: "" + (Utils.formatDouble(WorldUtil.getMemUsedPerc())) + ""% - "" + time + ""ms - Players online: "" + World.getPlayers().size()); Telemetry.queueTelemetryTick(time); if (time > HIGHEST_TICK) HIGHEST_TICK = time; if (time < LOWEST_TICK) LOWEST_TICK = time; TICKS++; TOTAL_TIME += time; long AVERAGE_TICK = TOTAL_TIME / TICKS; if (time > 300L && Settings.getConfig().getStaffWebhookUrl() != null) { if (Settings.getConfig().isEnableJFR()) tickRecording.stop(); StringBuilder content = new StringBuilder(); content.append(""__**Tick concern**__\n""); content.append(""__**World Data**__\n""); content.append(""```\n""); content.append(""World: "").append(Settings.getConfig().getServerName()).append(""("").append(Settings.getConfig().getWorldInfo().number()).append(""@"").append(Settings.getConfig().getLobbyIp()).append("")\n""); content.append(""Uptime: "").append(Utils.ticksToTime(WORLD_CYCLE - START_CYCLE)).append(""\n""); content.append(""Players loaded: "").append(Utils.formatNumber(World.getPlayers().size())).append(""\n""); content.append(""NPCs loaded: "").append(Utils.formatNumber(World.getNPCs().size())).append(""\n""); content.append(""Reserved dynamic regions: "").append(Utils.formatNumber(InstanceBuilder.getReservedRegionCount())).append(""\n""); content.append(""Active world task count: "").append(Utils.formatNumber(WorldTasks.getSize())).append(""\n""); content.append(""```\n""); content.append(""__**Tick Time: "").append(time).append(""ms (min: "").append(Utils.formatLong(LOWEST_TICK)).append(""ms avg: "").append(Utils.formatLong(AVERAGE_TICK)).append(""ms max: "").append(Utils.formatLong(HIGHEST_TICK)).append(""ms)**__\n""); content.append(""```\n""); content.append(""Chunk: "").append(timerChunk.getFormattedTime()).append(""\n""); content.append(""Task: "").append(timerTask.getFormattedTime()).append(""\n""); content.append(""Update zone: "").append(timerUpdateZones.getFormattedTime()).append(""\n""); content.append(""Player proc: "").append(timerPlayerProc.getFormattedTime()).append(""\n""); content.append(""NPC proc: "").append(timerNpcProc.getFormattedTime()).append(""\n""); content.append(""Player move: "").append(timerPlayerMove.getFormattedTime()).append(""\n""); content.append(""NPC move: "").append(timerNpcMove.getFormattedTime()).append(""\n""); content.append(""Entity update: "").append(timerEntityUpdate.getFormattedTime()).append(""\n""); content.append(""Flush: "").append(timerFlushPackets.getFormattedTime()).append(""\n""); content.append(""```\n""); content.append(""__**JVM Stats:**__\n""); content.append(""```\n""); /** * Memory and CPU usage stats */ MemoryMXBean memoryMXBean = ManagementFactory.getMemoryMXBean(); MemoryUsage heapMemoryUsage = memoryMXBean.getHeapMemoryUsage(); MemoryUsage nonHeapMemoryUsage = memoryMXBean.getNonHeapMemoryUsage(); long jvmHeapUsed = heapMemoryUsage.getUsed() / 1048576L; // in MB long jvmNonHeapUsed = nonHeapMemoryUsage.getUsed() / 1048576L; // in MB long jvmTotalUsed = jvmHeapUsed + jvmNonHeapUsed; long jvmMaxMemory = (heapMemoryUsage.getMax() + nonHeapMemoryUsage.getMax()) / 1048576L; // in MB double jvmMemUsedPerc = ((double) jvmTotalUsed / jvmMaxMemory) * 100.0; content.append(""Total JVM memory usage: "").append(Utils.formatLong(jvmTotalUsed)).append(""mb/"").append(Utils.formatLong(jvmMaxMemory)).append(""mb ("").append(Utils.formatDouble(jvmMemUsedPerc)).append(""%)\n""); content.append(""```\n""); MultipartBody.Builder builder = new MultipartBody.Builder() .setType(MultipartBody.FORM) .addFormDataPart(""content"", content.toString()); if (Settings.getConfig().isEnableJFR()) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); assert tickRecording != null; try (InputStream is = tickRecording.getStream(null, null)) { byte[] buffer = new byte[1024]; int len; while ((len = is.read(buffer)) > -1) { baos.write(buffer, 0, len); } baos.flush(); } builder.addFormDataPart(""file"", ""tickRecord.jfr"", RequestBody.create(baos.toByteArray(), MediaType.parse(""application/octet-stream""))); } APIUtil.request(Boolean.class, new Request.Builder() .url(Settings.getConfig().getStaffWebhookUrl()) .post(builder.build()) .build(), null); //APIUtil.post(Boolean.class, JsonFileManager.getGson().fromJson(jsonPayload, Object.class), Settings.getConfig().getStaffWebhookUrl(), """", null); } } catch (Throwable e) { Logger.handle(WorldThread.class, ""tick"", e); } long endTime = System.currentTimeMillis(); long timeToSleep = Math.max(600 - (endTime - startTime), 0); try { if (timeToSleep > 0) Thread.sleep(timeToSleep); } catch (InterruptedException e) { } WORLD_CYCLE++; } } }" "package com.rs.engine.thread; public class WorldThreadFactory implements ThreadFactory { private static final AtomicInteger poolNumber = new AtomicInteger(1); private final ThreadGroup group; private final AtomicInteger threadNumber = new AtomicInteger(1); private final String namePrefix; public WorldThreadFactory() { group = Thread.currentThread().getThreadGroup(); namePrefix = ""World Pool-"" + poolNumber.getAndIncrement() + ""-thread-""; } @Override public Thread newThread(@NotNull Runnable r) { Thread t = new Thread(group, r, namePrefix + threadNumber.getAndIncrement(), 0); if (t.isDaemon()) t.setDaemon(false); if (t.getPriority() != Thread.MAX_PRIORITY) t.setPriority(Thread.MAX_PRIORITY); return t; } }" "package com.rs.game; @PluginEventHandler public final class World { public static int SYSTEM_UPDATE_DELAY = -1; public static long SYSTEM_UPDATE_START; private static final EntityList PLAYERS = new EntityList<>(Settings.PLAYERS_LIMIT); private static final Map PLAYER_MAP_USERNAME = new ConcurrentHashMap<>(); private static final Map PLAYER_MAP_DISPLAYNAME = new ConcurrentHashMap<>(); private static final EntityList NPCS = new EntityList<>(Settings.NPCS_LIMIT); private static final Map GAMEOBJECT_ROUTE_TYPE_MAPPINGS = new Int2ObjectOpenHashMap<>(); @ServerStartupEvent public static void addSaveFilesTask() { AsyncTaskExecutor.schedule(Launcher::saveFilesAsync, 0, Ticks.fromSeconds(30)); } public static void addPlayer(Player player) { PLAYERS.add(player); PLAYER_MAP_USERNAME.put(player.getUsername(), player); PLAYER_MAP_DISPLAYNAME.put(player.getDisplayName(), player); if (player.getSession() != null && !player.getUsername().contains(""cli_bot"")) AccountLimiter.add(player.getSession().getIP()); } public static void removePlayer(Player player) { PLAYERS.remove(player); PLAYER_MAP_USERNAME.remove(player.getUsername(), player); PLAYER_MAP_DISPLAYNAME.remove(player.getDisplayName(), player); } public static void addNPC(NPC npc) { if (!NPCS.contains(npc)) NPCS.add(npc); } public static void removeNPC(NPC npc) { NPCS.remove(npc); } public static NPC spawnNPC(int id, Tile tile, Direction direction, boolean permaDeath, boolean withFunction, String customName) { NPC n = null; if (withFunction) { Object fObj = PluginManager.getObj(new NPCInstanceEvent(id, tile, permaDeath)); if (fObj != null) n = (NPC) fObj; else n = new NPC(id, tile, direction, permaDeath); } else n = new NPC(id, tile, direction, permaDeath); if (n != null) n.setPermName(customName); return n; } public static NPC spawnNPC(int id, Tile tile, boolean permaDeath, boolean withFunction, String customName) { return spawnNPC(id, tile, Direction.SOUTH, permaDeath, withFunction, null); } public static NPC spawnNPC(int id, Tile tile, int mapAreaNameHash, boolean canBeAttackFromOutOfArea, boolean permaDeath, boolean withFunction) { return spawnNPC(id, tile, permaDeath, withFunction, null); } public static NPC spawnNPC(int id, Tile tile, int mapAreaNameHash, boolean canBeAttackFromOutOfArea, boolean permaDeath) { return spawnNPC(id, tile, mapAreaNameHash, canBeAttackFromOutOfArea, permaDeath, true); } public static NPC spawnNPC(int id, Tile tile, int mapAreaNameHash, boolean canBeAttackFromOutOfArea) { return spawnNPC(id, tile, mapAreaNameHash, canBeAttackFromOutOfArea, false, true); } public static boolean canLightFire(int plane, int x, int y) { return !ClipFlag.flagged(getClipFlags(plane, x, y), ClipFlag.UNDER_ROOF) && (getClipFlags(plane, x, y) & 2097152) == 0 && getObjectWithSlot(Tile.of(x, y, plane), 2) == null; } public static boolean floorAndWallsFree(int plane, int x, int y, int size) { return floorAndWallsFree(Tile.of(x, y, plane), size); } public static boolean floorAndWallsFree(Tile tile, int size) { for (int x = 0; x < size; x++) for (int y = 0; y < size; y++) if (!floorFree(tile.transform(x, y)) || !wallsFree(tile.transform(x, y))) return false; return true; } public static boolean floorFree(Tile tile, int size) { for (int x = 0; x < size; x++) for (int y = 0; y < size; y++) if (!floorFree(tile.transform(x, y))) return false; return true; } public static boolean floorFree(int plane, int x, int y, int size) { return floorFree(Tile.of(x, y, plane), size); } public static boolean floorFree(Tile tile) { return !ClipFlag.flagged(getClipFlags(tile), ClipFlag.PFBW_FLOOR, ClipFlag.PFBW_GROUND_DECO, ClipFlag.BW_FULL); } public static boolean floorFree(int plane, int x, int y) { return floorFree(Tile.of(x, y, plane)); } public static boolean wallsFree(Tile tile) { return !ClipFlag.flagged(getClipFlags(tile), ClipFlag.BW_NE, ClipFlag.BW_NW, ClipFlag.BW_SE, ClipFlag.BW_SW, ClipFlag.BW_E, ClipFlag.BW_N, ClipFlag.BW_S, ClipFlag.BW_W); } public static boolean wallsFree(int plane, int x, int y) { return wallsFree(Tile.of(x, y, plane)); } public static int getClipFlags(int plane, int x, int y) { return WorldCollision.getFlags(Tile.of(x, y, plane)); } public static int getClipFlags(Tile tile) { return WorldCollision.getFlags(tile); } public static boolean hasLineOfSight(Tile src, int srcSize, Tile dst, int dstSize) { if (src.getPlane() != dst.getPlane()) return false; return new LineValidator(RouteFinderKt.DEFAULT_SEARCH_MAP_SIZE, WorldCollision.INSTANCE.getAllFlags()).hasLineOfSight(src.x(), src.y(), src.plane(), dst.x(), dst.y(), srcSize, dstSize, dstSize); } public static boolean checkMeleeStep(Object from, int fromSize, Object to, int toSize) { Tile fromTile = WorldUtil.targetToTile(from); Tile toTile = WorldUtil.targetToTile(to); if (fromTile.getPlane() != toTile.getPlane()) return false; return DefaultReachStrategy.INSTANCE.reached(WorldCollision.INSTANCE.getAllFlags(), fromTile.x(), fromTile.y(), fromTile.plane(), toTile.x(), toTile.y(), toSize, toSize, fromSize, 0, 22, 0); } public static boolean containsPlayer(String username) { for (Player p2 : PLAYERS) { if (p2 == null) continue; if (p2.getUsername().equals(username)) return true; } return false; } public static Tile getFreeTile(Tile center, int distance) { Tile tile = center; for (int i = 0; i < 10; i++) { tile = Tile.of(center, distance); if (World.floorAndWallsFree(tile, 1)) return tile; } return center; } public static Player getPlayerByUsername(String username) { return PLAYER_MAP_USERNAME.get(username); } public static Player getPlayerByDisplay(String displayName) { return PLAYER_MAP_DISPLAYNAME.get(Utils.formatPlayerNameForDisplay(displayName)); } public static void forceGetPlayerByDisplay(String displayName, Consumer result) { displayName = Utils.formatPlayerNameForDisplay(displayName); Player player = getPlayerByDisplay(displayName); if (player != null) { result.accept(player); return; } WorldDB.getPlayers().getByUsername(Utils.formatPlayerNameForProtocol(displayName), result::accept); } public static EntityList getPlayers() { return PLAYERS; } public static EntityList getNPCs() { return NPCS; } private World() { } public static long getTicksTillUpdate() { if (SYSTEM_UPDATE_START == 0) return -1; return (SYSTEM_UPDATE_DELAY - (World.getServerTicks() - SYSTEM_UPDATE_START)); } public static void safeShutdown(int delay) { if (SYSTEM_UPDATE_START != 0) return; SYSTEM_UPDATE_START = World.getServerTicks(); SYSTEM_UPDATE_DELAY = delay; for (Player player : World.getPlayers()) { if (player == null || !player.hasStarted() || player.hasFinished()) continue; player.getPackets().sendSystemUpdate(delay); } WorldTasks.schedule(delay, () -> { try { for (Player player : World.getPlayers()) { if (player == null || !player.hasStarted()) continue; player.getPackets().sendLogout(true); player.realFinish(); WorldDB.getPlayers().saveSync(player); } WorldPersistentData.save(); Launcher.shutdown(); } catch (Throwable e) { Logger.handle(World.class, ""safeShutdown"", e); } }); } public static WorldPersistentData getData() { return WorldPersistentData.get(); } public static boolean isSpawnedObject(GameObject object) { return ChunkManager.getChunk(object.getTile().getChunkId()).getSpawnedObjects().contains(object); } public static void spawnObject(GameObject object) { ChunkManager.getChunk(object.getTile().getChunkId()).spawnObject(object, true); } public static void spawnObject(GameObject object, boolean clip) { ChunkManager.getChunk(object.getTile().getChunkId()).spawnObject(object, clip); } public static void unclipTile(Tile tile) { WorldCollision.unclip(tile); } public static void removeObject(GameObject object) { ChunkManager.getChunk(object.getTile().getChunkId()).removeObject(object); } public static void spawnObjectTemporary(final GameObject object, int ticks, boolean clip) { spawnObject(object, clip); WorldTasks.schedule(Utils.clampI(ticks - 1, 0, Integer.MAX_VALUE), () -> { try { if (!World.isSpawnedObject(object)) return; removeObject(object); } catch (Throwable e) { Logger.handle(World.class, ""spawnObjectTemporary"", e); } }); } public static void spawnObjectTemporary(final GameObject object, int ticks) { spawnObjectTemporary(object, ticks, true); } public static boolean removeObjectTemporary(final GameObject object, int ticks) { if (object == null) return false; removeObject(object); WorldTasks.schedule(new Task() { @Override public void run() { try { spawnObject(object); } catch (Throwable e) { Logger.handle(World.class, ""removeObjectTemporary"", e); } } }, Utils.clampI(ticks, 0, Integer.MAX_VALUE)); return true; } public static void spawnTempGroundObject(final GameObject object, final int replaceId, int ticks) { spawnObject(object); WorldTasks.schedule(new Task() { @Override public void run() { try { removeObject(object); addGroundItem(new Item(replaceId), object.getTile(), null, false, 180); } catch (Throwable e) { Logger.handle(World.class, ""spawnTempGroundObject"", e); } } }, Utils.clampI(ticks - 1, 0, Integer.MAX_VALUE)); } public static void allPlayers(Consumer func) { synchronized (PLAYERS) { for (Player p : World.getPlayers()) func.accept(p); } } public static List getSpawnedObjectsInChunkRange(int chunkId, int chunkRadius) { List objects = new ArrayList<>(); Set chunkIds = getChunkRadius(chunkId, chunkRadius); for (int chunk : chunkIds) { for (GameObject obj : ChunkManager.getChunk(chunk).getSpawnedObjects()) { if (obj == null) continue; objects.add(obj); } } return objects; } public static List getAllObjectsInChunkRange(int chunkId, int chunkRadius) { List objects = new ArrayList<>(); Set chunkIds = getChunkRadius(chunkId, chunkRadius); for (int chunk : chunkIds) { for (GameObject obj : ChunkManager.getChunk(chunk).getAllObjects()) { if (obj == null) continue; objects.add(obj); } } return objects; } public static List getBaseObjectsInChunkRange(int chunkId, int chunkRadius) { List objects = new ArrayList<>(); Set chunkIds = getChunkRadius(chunkId, chunkRadius); for (int chunk : chunkIds) { for (GameObject obj : ChunkManager.getChunk(chunk).getBaseObjects()) { if (obj == null) continue; objects.add(obj); } } return objects; } public static List getNPCsInChunkRange(int chunkId, int chunkRadius) { List npcs = new ArrayList<>(); Set chunkIds = getChunkRadius(chunkId, chunkRadius); for (int chunk : chunkIds) { for (int pid : ChunkManager.getChunk(chunk).getNPCsIndexes()) { NPC npc = World.getNPCs().get(pid); if (npc == null || npc.hasFinished()) continue; npcs.add(npc); } } return npcs; } public static List getPlayersInChunkRange(int chunkId, int chunkRadius) { List players = new ArrayList<>(); Set chunkIds = getChunkRadius(chunkId, chunkRadius); for (int chunk : chunkIds) { for (int pid : ChunkManager.getChunk(chunk).getPlayerIndexes()) { Player player = World.getPlayers().get(pid); if (player == null || !player.hasStarted() || player.hasFinished()) continue; players.add(player); } } return players; } public static List getPlayersInChunks(int... chunkIds) { List players = new ArrayList<>(); for (int chunk : chunkIds) { for (int pid : ChunkManager.getChunk(chunk).getPlayerIndexes()) { Player player = World.getPlayers().get(pid); if (player == null || !player.hasStarted() || player.hasFinished()) continue; players.add(player); } } return players; } public static List getAllGroundItemsInChunkRange(int chunkId, int chunkRadius) { List objects = new ArrayList<>(); Set chunkIds = getChunkRadius(chunkId, chunkRadius); for (int chunk : chunkIds) { for (GroundItem obj : ChunkManager.getChunk(chunk).getAllGroundItems()) { if (obj == null) continue; objects.add(obj); } } return objects; } public static Set getChunkRadius(int chunkId, int radius) { Set chunksXYLoop = new IntOpenHashSet(); for (int cx = -radius * Chunk.X_INC; cx <= radius * Chunk.X_INC; cx += Chunk.X_INC) for (int cy = -radius; cy <= radius; cy++) chunksXYLoop.add(chunkId + cx + cy); return chunksXYLoop; } public static Set mapRegionIdsToChunks(Set mapRegionsIds) { Set chunkIds = new IntOpenHashSet(); for (int regionId : mapRegionsIds) { int[] rCoords = MapUtils.decode(Structure.REGION, regionId); int cX = rCoords[0] << 3, cY = rCoords[1] << 3; for (int plane = 0;plane < 4;plane++) for (int x = 0;x < 8;x++) for (int y = 0;y < 8;y++) chunkIds.add(MapUtils.encode(Structure.CHUNK, cX+x, cY+y, plane)); } return chunkIds; } public static Set mapRegionIdsToChunks(Set mapRegionsIds, int plane) { Set chunkIds = new IntOpenHashSet(); for (int regionId : mapRegionsIds) { int[] rCoords = MapUtils.decode(Structure.REGION, regionId); int cX = rCoords[0] << 3, cY = rCoords[1] << 3; for (int x = 0;x < 8;x++) for (int y = 0;y < 8;y++) chunkIds.add(MapUtils.encode(Structure.CHUNK, cX+x, cY+y, plane)); } return chunkIds; } public static Set regionIdToChunkSet(int regionId) { Set chunkIds = new IntOpenHashSet(); int[] rCoords = MapUtils.decode(Structure.REGION, regionId); int cX = rCoords[0] << 3, cY = rCoords[1] << 3; for (int plane = 0;plane < 4;plane++) for (int x = 0;x < 8;x++) for (int y = 0;y < 8;y++) chunkIds.add(MapUtils.encode(Structure.CHUNK, cX+x, cY+y, plane)); return chunkIds; } public static void refreshObject(GameObject object) { ChunkManager.getChunk(object.getTile().getChunkId()).addChunkUpdate(new AddObject(object.getTile().getChunkLocalHash(), object)); } public static GameObject getObject(Tile tile) { return ChunkManager.getChunk(tile.getChunkId()).getObject(tile); } public static GameObject[] getBaseObjects(Tile tile) { return ChunkManager.getChunk(tile.getChunkId()).getBaseObjects(tile); } public static GameObject getSpawnedObject(Tile tile) { return ChunkManager.getChunk(tile.getChunkId()).getSpawnedObject(tile); } public static GameObject getObject(Tile tile, ObjectType type) { return ChunkManager.getChunk(tile.getChunkId()).getObject(tile, type); } public static void setObjectRouteType(int id, GameObject.RouteType routeType) { GAMEOBJECT_ROUTE_TYPE_MAPPINGS.put(id, routeType); } public static GameObject.RouteType getRouteType(int id) { GameObject.RouteType type = GAMEOBJECT_ROUTE_TYPE_MAPPINGS.get(id); return type != null ? type : GameObject.RouteType.NORMAL; } public enum DropMethod { NORMAL, TURN_UNTRADEABLES_TO_COINS } public static GroundItem addGroundItem(Item item, Tile tile) { return addGroundItem(item, tile, null, false, -1, DropMethod.NORMAL, -1); } public static GroundItem addGroundItem(Item item, Tile tile, Player owner) { return addGroundItem(item, tile, owner, true, 60); } public static GroundItem addGroundItem(Item item, Tile tile, Player owner, boolean invisible, int hiddenSecs) { return addGroundItem(item, tile, owner, invisible, hiddenSecs, DropMethod.NORMAL, 150); } public static GroundItem addGroundItem(Item item, Tile tile, Player owner, boolean invisible, int hiddenSecs, DropMethod type) { return addGroundItem(item, tile, owner, invisible, hiddenSecs, type, 150); } @Deprecated public static void addGroundItemForever(Item item, Tile tile, int respawnTicks) { GroundItem groundItem = new GroundItem(item, tile, GroundItemType.FOREVER).setRespawnTicks(respawnTicks); if (groundItem.getId() == -1) return; ChunkManager.getChunk(tile.getChunkId()).addGroundItem(groundItem); } public static GroundItem addGroundItem(Item item, Tile tile, Player owner, boolean invisible, int hiddenTime, DropMethod type, int deleteTime) { if ((item.getId() == -1) || (owner != null && owner.getRights() == Rights.ADMIN)) return null; if (type != DropMethod.NORMAL) if (type == DropMethod.TURN_UNTRADEABLES_TO_COINS && !ItemConstants.isTradeable(item)) { int price = item.getDefinitions().getValue(); if (price <= 0) return null; item.setId(995); item.setAmount(price); } final GroundItem floorItem = new GroundItem(item, tile, owner == null ? null : owner.getUsername(), invisible ? GroundItemType.INVISIBLE : GroundItemType.NORMAL); if (floorItem.getAmount() > 1 && !item.getDefinitions().isStackable() && floorItem.getMetaData() == null) for (int i = 0; i < floorItem.getAmount(); i++) { Item oneItem = new Item(item.getId(), 1); GroundItem newItem = new GroundItem(oneItem, tile, owner == null ? null : owner.getUsername(), invisible ? GroundItemType.INVISIBLE : GroundItemType.NORMAL); finalizeGroundItem(newItem, tile, owner, hiddenTime, type, deleteTime); } else finalizeGroundItem(floorItem, tile, owner, hiddenTime, type, deleteTime); return floorItem; } private static void finalizeGroundItem(GroundItem item, Tile tile, Player owner, int hiddenSeconds, DropMethod type, int lifeSeconds) { if ((item.getId() == -1) || (owner != null && owner.getRights() == Rights.ADMIN)) return; if (ChunkManager.getChunk(tile.getChunkId()).addGroundItem(item)) { if (lifeSeconds != -1) item.setDeleteTime(Ticks.fromSeconds(lifeSeconds + hiddenSeconds)); if (item.isInvisible()) if (hiddenSeconds != -1) item.setPrivateTime(Ticks.fromSeconds(hiddenSeconds)); } } public static boolean removeGroundItem(GroundItem groundItem) { return ChunkManager.getChunk(groundItem.getTile().getChunkId()).deleteGroundItem(groundItem); } public static boolean removeGroundItem(Player player, GroundItem floorItem) { return removeGroundItem(player, floorItem, true); } public static boolean removeGroundItem(Player player, GroundItem groundItem, boolean add) { if (groundItem.getId() == -1) return false; Chunk chunk = ChunkManager.getChunk(groundItem.getTile().getChunkId()); if (!chunk.itemExists(groundItem)) return false; if (player.isIronMan() && groundItem.getSourceId() != 0 && groundItem.getSourceId() != player.getUuid()) { player.sendMessage(""You may not pick up other players items as an ironman.""); return false; } if (add && !player.getInventory().hasRoomFor(groundItem)) { player.sendMessage(""Not enough space in your inventory.""); return false; } if (chunk.deleteGroundItem(groundItem)) { if (add) { if (!player.getInventory().addItem(new Item(groundItem.getId(), groundItem.getAmount(), groundItem.getMetaData()))) return false; if (groundItem.getSourceId() != 0 && groundItem.getSourceId() != player.getUuid()) WorldDB.getLogs().logPickup(player, groundItem); } if (groundItem.isRespawn()) WorldTasks.schedule(groundItem.getRespawnTicks(), () -> { try { addGroundItemForever(groundItem, groundItem.getTile(), groundItem.getRespawnTicks()); } catch (Throwable e) { Logger.handle(World.class, ""removeGroundItem"", e); } }); return true; } return false; } public static void sendObjectAnimation(GameObject object, Animation animation) { if (object == null) return; ChunkManager.getChunk(object.getTile().getChunkId()).addObjectAnim(object, animation); } public static void sendObjectAnimation(GameObject object, int animation) { sendObjectAnimation(object, new Animation(animation)); } public static void sendSpotAnim(Tile tile, SpotAnim anim) { ChunkManager.getChunk(tile.getChunkId()).addSpotAnim(tile, anim); } public static void sendSpotAnim(Tile tile, int anim) { ChunkManager.getChunk(tile.getChunkId()).addSpotAnim(tile, new SpotAnim(anim)); } public static WorldProjectile sendProjectile(Object from, Object to, int graphicId, int angle, int delay, double speed) { return sendProjectile(from, to, graphicId, angle, delay, speed, null); } public static WorldProjectile sendProjectile(Object from, Object to, int graphicId, int angle, int delay, double speed, Consumer task) { return sendProjectile(from, to, graphicId, 28, 28, delay, speed, angle, task); } public static WorldProjectile sendProjectile(Object from, Object to, int graphicId, int angle, double speed) { return sendProjectile(from, to, graphicId, angle, speed, null); } public static WorldProjectile sendProjectile(Object from, Object to, int graphicId, int angle, double speed, Consumer task) { return sendProjectile(from, to, graphicId, 28, 28, 0, speed, angle, task); } public static WorldProjectile sendProjectile(Object from, Object to, int graphicId, int startHeight, int endHeight, int startTime, double speed, int angle, int slope) { return sendProjectile(from, to, graphicId, startHeight, endHeight, startTime, speed, angle, null); } public static WorldProjectile sendProjectile(Object from, Object to, int graphicId, int startHeight, int endHeight, int startTime, double speed, int angle, Consumer task) { Tile fromTile = switch(from) { case Tile t -> t; case Entity e -> e.getMiddleTile(); case GameObject g -> g.getTile(); default -> throw new IllegalArgumentException(""Unexpected target type: "" + from); }; Tile toTile = switch(to) { case Tile t -> t; case Entity e -> e.getMiddleTile(); case GameObject g -> g.getTile(); default -> throw new IllegalArgumentException(""Unexpected target type: "" + to); }; if (speed > 20.0) speed = speed / 50.0; int fromSizeX, fromSizeY; if (from instanceof Entity e) else if (from instanceof GameObject go) { ObjectDefinitions defs = go.getDefinitions(); } else int toSizeX, toSizeY; if (to instanceof Entity e) toSizeX = toSizeY = e.getSize(); else if (to instanceof GameObject go) { ObjectDefinitions defs = go.getDefinitions(); toSizeX = defs.getSizeX(); toSizeY = defs.getSizeY(); } else toSizeX = toSizeY = 1; int slope = fromSizeX * 32; WorldProjectile projectile = new WorldProjectile(fromTile, to, graphicId, startHeight, endHeight, startTime, startTime + (speed == -1 ? Utils.getProjectileTimeSoulsplit(fromTile, fromSizeX, fromSizeY, toTile, toSizeX, toSizeY) : Utils.getProjectileTimeNew(fromTile, fromSizeX, fromSizeY, toTile, toSizeX, toSizeY, speed)), slope, angle, task); if (graphicId != -1) { int chunkId = switch(from) { case Tile t -> t.getChunkId(); case Entity e -> e.getMiddleTile().getChunkId(); case GameObject g -> g.getTile().getChunkId(); default -> -1; }; if (chunkId == -1) throw new RuntimeException(""Invalid source target. Accepts Tiles and Entities.""); ChunkManager.getChunk(chunkId).addProjectile(projectile); } return projectile; } public static boolean isMultiArea(Tile tile) { int chunkId = MapUtils.encode(Structure.CHUNK, tile.getChunkX(), tile.getChunkY()); return Areas.withinArea(""multi"", chunkId); } public static boolean isPvpArea(Player player) { return WildernessController.isAtWild(player.getTile()); } public static void jingle(Tile source, int jingleId, int delay) { sound(source, jingleId, delay, SoundType.JINGLE); } public static void jingle(Tile source, int jingleId) { sound(source, jingleId, 0, SoundType.JINGLE); } public static void musicTrack(Tile source, int trackId, int delay, int volume) { sound(source, trackId, delay, SoundType.MUSIC).volume(volume); } public static void musicTrack(Tile source, int trackId, int delay) { sound(source, trackId, delay, SoundType.MUSIC); } public static void musicTrack(Tile source, int trackId) { musicTrack(source, trackId, 100); } public static Sound sound(Tile tile, Sound sound) { ChunkManager.getChunk(tile.getChunkId()).addSound(tile, sound); return sound; } public static Sound sound(Tile source, int soundId, int delay, SoundType type) { return sound(source, new Sound(soundId, delay, type)); } public static void soundEffect(Tile source, int soundId, int delay) { sound(source, soundId, delay, SoundType.EFFECT).radius(10); } public static void soundEffect(Tile source, int soundId) { soundEffect(source, soundId, 0); } public static void voiceEffect(Tile source, int voiceId, int delay) { sound(source, voiceId, delay, SoundType.VOICE); } public static void voiceEffect(Tile source, int voiceId) { voiceEffect(source, voiceId, 0); } public static GameObject getClosestObject(int objectId, Tile tile) { for (int dist = 0;dist < 16;dist++) for (int x = -dist;x < dist;x++) for (int y = -dist; y < dist;y++) { GameObject object = World.getObject(tile.transform(x, y)); if (object != null && object.getId() == objectId) return object; } return null; } public static GameObject getClosestObject(ObjectType type, Tile tile) { for (int dist = 0;dist < 16;dist++) for (int x = -dist;x < dist;x++) for (int y = -dist; y < dist;y++) { GameObject object = World.getObject(tile.transform(x, y), type); if (object != null && object.getType() == type) return object; } return null; } public static GameObject getClosestObject(ObjectType type, int objectId, Tile tile) { for (int dist = 0;dist < 16;dist++) for (int x = -dist;x < dist;x++) for (int y = -dist; y < dist;y++) { GameObject object = World.getObject(tile.transform(x, y), type); if (object != null && object.getId() == objectId) return object; } return null; } public static GameObject getClosestObject(String name, Tile tile) { for (int dist = 0;dist < 16;dist++) for (int x = -dist;x < dist;x++) for (int y = -dist; y < dist;y++) { GameObject object = World.getObject(tile.transform(x, y)); if (object != null && object.getDefinitions().getName().equals(name)) return object; } return null; } public static GameObject getClosestObject(String name, Tile tile, int range) { GameObject closest = null; double closestDist = 1000; for (int dist = 0;dist < range;dist++) for (int x = -dist;x < dist;x++) for (int y = -dist; y < dist;y++) { GameObject object = World.getObject(tile.transform(x, y)); if (object != null && object.getDefinitions().getName().equals(name)) { double newDist = Utils.getDistance(object.getCoordFace(), tile); if (newDist < closestDist) { closest = object; closestDist = newDist; } } } return closest; } public static GameObject getObjectWithType(Tile tile, ObjectType type) { return ChunkManager.getChunk(tile.getChunkId()).getObjectWithType(tile, type); } public static GameObject getObjectWithSlot(Tile tile, int slot) { return ChunkManager.getChunk(tile.getChunkId()).getObjectWithSlot(tile, slot); } public static boolean containsObjectWithId(Tile tile, int id) { return ChunkManager.getChunk(tile.getChunkId()).containsObjectWithId(tile, id); } public static GameObject getObjectWithId(Tile tile, int id) { return ChunkManager.getChunk(tile.getChunkId()).getObjectWithId(tile, id); } public static void sendWorldMessage(String message, boolean forStaff) { for (Player p : World.getPlayers()) { if (p == null || !p.isRunning() || p.isYellOff() || (forStaff && !p.hasRights(Rights.MOD))) continue; p.sendMessage(message); } } /** * Please someone refactor this. This is beyond disgusting and definitely can be done better. */ public static Tile findAdjacentFreeTile(Tile tile, Direction... blacklistedDirections) { StepValidator step = new StepValidator(WorldCollision.INSTANCE.getAllFlags()); List unchecked = new ArrayList<>(Arrays.asList(Direction.values())); if (blacklistedDirections != null) { for (Direction dir : blacklistedDirections) unchecked.remove(dir); } while(!unchecked.isEmpty()) { Direction curr = unchecked.get(Utils.random(unchecked.size())); if (step.canTravel(tile.plane(), tile.x(), tile.y(), curr.dx, curr.dy, 1, 0, CollisionStrategyType.NORMAL.getStrategy())) return tile.transform(curr.dx, curr.dy); unchecked.remove(curr); } return null; } public static boolean checkWalkStep(Tile tile, Direction dir, int size) { StepValidator step = new StepValidator(WorldCollision.INSTANCE.getAllFlags()); return step.canTravel(tile.plane(), tile.x(), tile.y(), dir.dx, dir.dy, size, 0, CollisionStrategyType.NORMAL.getStrategy()); } public static boolean checkWalkStep(Tile tile, Tile toTile, int size) { Direction dir = Direction.forDelta(toTile.x() - tile.x(), toTile.y() - tile.y()); if (dir == null) return false; StepValidator step = new StepValidator(WorldCollision.INSTANCE.getAllFlags()); return step.canTravel(tile.plane(), tile.x(), tile.y(), dir.dx, dir.dy, size, 0, CollisionStrategyType.NORMAL.getStrategy()); } public static Tile findAdjacentFreeTile(Tile tile) { return findAdjacentFreeTile(tile, (Direction) null); } public static Tile findAdjacentFreeSpace(Tile tile, Direction... blacklistedDirections) { return findAdjacentFreeTile(tile, blacklistedDirections); } /** * Please someone refactor this. This is beyond disgusting and definitely can be done better. */ public static Tile findAdjacentFreeSpace(Tile tile, int size) { if (size == 1) return findAdjacentFreeTile(tile); StepValidator step = new StepValidator(WorldCollision.INSTANCE.getAllFlags()); List unchecked = new ArrayList<>(List.of(Direction.NORTH, Direction.SOUTH, Direction.EAST, Direction.WEST)); Tile finalTile = null; while(!unchecked.isEmpty()) { boolean failed = false; Direction curr = unchecked.get(Utils.random(unchecked.size())); Direction offset = Direction.forDelta(curr.dx != 0 ? 0 : curr.dy, curr.dy != 0 ? 0 : curr.dx); Tile startTile = tile.transform(0, 0); for (int i = 0;i <= size;i++) { for (int row = 0; row < size; row++) { Tile from = startTile.transform(offset.dx * row, offset.dy * row).transform(curr.dx * i, curr.dy * i); // if (Settings.getConfig().isDebug()) { // World.sendSpotAnim(null, new SpotAnim(switch (curr) { // case NORTH -> 2000; // case SOUTH -> 2001; // case EAST -> 2017; // default -> 1999; // }), from); // } if (!step.canTravel(tile.plane(), tile.x(), tile.y(), curr.dx, curr.dy, 1, 0, CollisionStrategyType.NORMAL.getStrategy()) || (size > 1 && row < (size-1) && !step.canTravel(tile.plane(), tile.x(), tile.y(), offset.dx, offset.dy, 1, 0, CollisionStrategyType.NORMAL.getStrategy()))) { failed = true; break; } } } if (!failed) { finalTile = startTile.transform(curr.dx, curr.dy); if (curr.dx < 0 || curr.dy < 0) finalTile = finalTile.transform(-size+1, -size+1); // if (Settings.getConfig().isDebug()) // World.sendSpotAnim(null, new SpotAnim(2679), finalTile); break; } unchecked.remove(curr); } return finalTile; } public static Tile findClosestAdjacentFreeTile(Tile tile, int dist) { //Checks outward - Northeast for (int x = 0; x <= dist; x++) for (int y = 0; y <= dist; y++) if (World.floorFree(tile.getPlane(), tile.getX() + x, tile.getY() + y)) return tile.transform(x, y, 0); //Checks outward - Southeast for (int x = 0; x <= dist; x++) for (int y = 0; y >= -dist; y--) if (World.floorFree(tile.getPlane(), tile.getX() + x, tile.getY() + y)) return tile.transform(x, y, 0); //Checks outward - Southwest for (int x = 0; x >= -dist; x--) for (int y = 0; y >= -dist; y--) if (World.floorFree(tile.getPlane(), tile.getX() + x, tile.getY() + y)) return tile.transform(x, y, 0); //Checks outward - Northwest for (int x = 0; x >= -dist; x--) for (int y = 0; y <= dist; y++) if (World.floorFree(tile.getPlane(), tile.getX() + x, tile.getY() + y)) return tile.transform(x, y, 0); return tile.transform(0, 0, 0); } public static long getServerTicks() { return WorldThread.WORLD_CYCLE; } public static List getSurroundingBaseObjects(GameObject obj, int radius) { ArrayList objects = new ArrayList<>(); for (GameObject object : ChunkManager.getChunk(obj.getTile().getChunkId()).getBaseObjects()) { if (object == null || object.getDefinitions() == null) continue; if (Utils.getDistance(obj.getTile(), object.getTile()) <= radius) objects.add(object); } return objects; } public static void broadcastLoot(String message) { sendWorldMessage("""" + message, false); } public static void processEntityLists() { PLAYERS.processPostTick(); NPCS.processPostTick(); } }" "package com.rs.game.content; public class AchievementTitles { public static String[] gamebreakerVariations = { "" the Gamebreaker"", "" the Gamebreaker"", "" the Gamebreaker"", "" the Gamebreaker"", "" the Gamebreaker"", "" thE gAmEbrEAkEr"", "" the Gaembreaker"", "" the Gamebreakr""}; public enum TitleReward { GAMEBREAKER(""DD0000"", ""the Gamebreaker"", ""Gamebreaking bugs found"", 1, false), WEEDER(""00FF00"", ""Weeder"", ""Weeds raked"", 1420, false), DEDICATED(""SFFCC00"", ""Dedicated"", ""Unique days logged in"", 20, false), PARTIER(""S00FFCC"", ""Partier"", ""Party balloons popped"", 500, false), VOTER(""SFFCC00"", ""Voter"", ""Voted"", 25, false), ALCHEMIST(""SFFCC00"", ""Alchemist"", ""Items alched"", 5000, false), GLUTTON(""SFFCC00"", ""Glutton"", ""Food eaten"", 10000, false), COWKILLER(""SFFFFFF"", ""C0wK1ll3r"", ""Cow"", 2500, true), IMPISH(""DD0000"", ""Impish"", ""Imp"", 1000, true), ABYSSAL(""990000"", ""The Abyssal"", ""Abyssal demon"", 1000, true), UNDERTAKER(""006600"", ""Undertaker"", ""%Zombie"", 2500, true), ZAROS(""6600CC"", ""Zaros Zerger"", ""Nex"", 25, true), CORPOREAL(""S666666"", ""Corporeal"", ""Corporeal Beast"", 50, true), BANDOS(""006600"", ""Bandos Basher"", ""General Graardor"", 100, true), SARADOMIN(""3333FF"", ""Saradomin Slayer"", ""Commander Zilyana"", 100, true), ZAMORAK(""CC0000"", ""Zamorak Zapper"", ""K'ril Tsutsaroth"", 100, true), ARMADYL(""9999FF"", ""Armadyl Assassin"", ""Kree'arra"", 100, true), REVENANT(""S666666"", ""Revenant"", ""%Revenant"", 1000, true), CHAOSELE(""CC00CC"", ""ChAoTiC"", ""Chaos Elemental"", 250, true), GLACYTE(""S33CCFF"", ""Glacyte"", ""Glacor"", 500, true), MILLIONS(""SFFD11A"", ""Millionare"", ""Coins drops earned"", 1000000, false), SOUL_REAPER(""939393"", ""Soul Reaper"", ""Health soulsplitted back"", 100000, false), GARBAGE_CAN(""3BB03B"", ""Garbage Can"", ""Deaths"", 50, false), ACTUAL_DUMPHEAP(""3BB03B"", ""Actual Dumpheap"", ""Deaths"", 500, false), YORICK(""7C7C01"", ""Harrowing"", ""Barrows chests looted"", 75, false), EXPLORER(""73A93F"", ""Explorer"", ""Easy clues completed"", 100, false), ENIGMATOLOGIST(""73A93F"", ""Enigmatologist"", ""Medium clues completed"", 100, false), GLOBETROTTER(""73A93F"", ""Globetrotter"", ""Hard clues completed"", 100, false), CLUE_MANIAC(""73A93F"", ""Clue Maniac"", ""Elite clues completed"", 100, false), MUDDY(""794c13"", ""Muddy"", ""Muddy chests opened"", 200, false), ; private final String color; private final String title; private final String req; private final int number; private final boolean npcKills; TitleReward(String color, String title, String req, int number, boolean npcKills) { this.color = color; this.title = title; this.req = req; this.number = number; this.npcKills = npcKills; } public boolean isNpcKills() { return npcKills; } public String getColor() { return color; } public String getTitle() { return title; } public String getReq() { return req; } public int getNumber() { return number; } public void handleActivate(Player player) { if (hasRequirements(player)) { player.setTitle(title); if (!color.startsWith(""S"")) player.setTitleColor(color); else { player.setTitleColor(color.replace(""S"", """")); player.setTitleShading(""000000""); } if (isUsingGamebreakerTitle(player)) { player.setTitle(gamebreakerVariations[Utils.random(gamebreakerVariations.length)]); player.setTitleAfter(true); } player.sendMessage(""You have set your title to ""+getShadeColor(color)+title+"".""); player.getAppearance().generateAppearanceData(); } else player.sendMessage(""You don't meet the requirements for this title.""); } public boolean hasRequirements(Player player) { if (npcKills) { return player.getNumberKilled(req) >= number; } else return player.getCounterValue(req) >= number; } } public static String getShadeColor(String color) { if (!color.startsWith(""S"")) return """"; return """"; } public static void openInterface(Player player) { int[] names = { 30, 32, 34, 36, 38, 49, 51, 53, 55, 57, 59, 62, 64, 66, 68, 70, 72, 74, 76, 190, 79, 81, 83, 85, 88, 90, 92, 94, 97, 99, 101, 104, 106, 108, 110, 115, 117, 119, 121, 123, 125, 131, 127, 129, 2, 173, 175, 177, 182, 184, 186, 188 }; player.getTempAttribs().removeB(""RemoteFarm""); player.getInterfaceManager().sendInterface(1082); player.getPackets().setIFHidden(1082, 158, true); player.getPackets().setIFText(1082, 41, ""Titles""); player.getPackets().setIFText(1082, 42, ""Requirements""); player.getPackets().setIFText(1082, 11, ""Welcome to the title shop. Click a title to activate it or check requirements.
Clear your title by right clicking Xuan and selecting the Clear Title option.""); for (int i = 0; i < names.length; i++) { if (i > TitleReward.values().length-1) { player.getPackets().setIFText(1082, names[i], """"); player.getPackets().setIFText(1082, names[i] + 1, """"); continue; } TitleReward title = TitleReward.values()[i]; if (title != null) { player.getPackets().setIFText(1082, names[i], getShadeColor(title.getColor())+title.getTitle()+""""); player.getPackets().setIFText(1082, names[i] + 1, (title.hasRequirements(player) ? """" : """")+(title.isNpcKills() ? player.getNumberKilled(title.getReq()) : player.getCounterValue(title.getReq()))+""/""+title.getNumber()+"" ""+title.getReq().replace(""%"", """")+"" ""+(title.isNpcKills() ? ""kills"" : """")); } else { player.getPackets().setIFText(1082, names[i], """"); player.getPackets().setIFText(1082, names[i] + 1, """"); } } } public static void handleButtons(Player player, int componentId) { int[] names = { 30, 32, 34, 36, 38, 49, 51, 53, 55, 57, 59, 62, 64, 66, 68, 70, 72, 74, 76, 190, 79, 81, 83, 85, 88, 90, 92, 94, 97, 99, 101, 104, 106, 108, 110, 115, 117, 119, 121, 123, 125, 131, 127, 129, 2, 173, 175, 177, 182, 184, 186, 188 }; for (int i = 0; i < names.length; i++) if ((names[i]+1) == componentId) if (i < TitleReward.values().length && TitleReward.values()[i] != null) TitleReward.values()[i].handleActivate(player); } public static LoginHandler login = new LoginHandler(e -> { if (isUsingGamebreakerTitle(e.getPlayer())) { e.getPlayer().setTitle(gamebreakerVariations[Utils.random(gamebreakerVariations.length)]); e.getPlayer().getAppearance().generateAppearanceData(); e.getPlayer().setTitleAfter(true); } }); public static boolean isUsingGamebreakerTitle(Player p) { if (p.getTitle() == null) return false; for (String variation : gamebreakerVariations) if (variation != null && variation.contains(p.getTitle())) return true; return false; } }" "package com.rs.game.content; @PluginEventHandler public class AncientEffigies { public static final int[] SKILL_1 = { Constants.AGILITY, Constants.CONSTRUCTION, Constants.COOKING, Constants.FISHING, Constants.FLETCHING, Constants.HERBLORE, Constants.MINING, Constants.SUMMONING }; public static final int[] SKILL_2 = { Constants.CRAFTING, Constants.THIEVING, Constants.FIREMAKING, Constants.FARMING, Constants.WOODCUTTING, Constants.HUNTER, Constants.SMITHING, Constants.RUNECRAFTING }; public static final int STARVED_ANCIENT_EFFIGY = 18778, NOURISHED_ANCIENT_EFFIGY = 18779, SATED_ANCIENT_EFFIGY = 18780, GORGED_ANCIENT_EFFIGY = 18781, DRAGONKIN_LAMP = 18782; public static ItemClickHandler handleEffigies = new ItemClickHandler(new Object[] { SATED_ANCIENT_EFFIGY, GORGED_ANCIENT_EFFIGY, NOURISHED_ANCIENT_EFFIGY, STARVED_ANCIENT_EFFIGY }, e -> { int type = -1; if(e.getItem().getMetaData(""effigyType"") != null) { type = e.getItem().getMetaDataI(""effigyType""); if (((int) (double) type) >= SKILL_1.length) { type = Utils.getRandomInclusive(7); e.getPlayer().getInventory().replace(e.getItem(), new Item(e.getItem().getId(), e.getItem().getAmount()).addMetaData(""effigyType"", type)); } } if (e.getItem().getMetaData(""effigyType"") == null) { type = Utils.getRandomInclusive(7); e.getPlayer().getInventory().replace(e.getItem(), new Item(e.getItem().getId(), e.getItem().getAmount()).addMetaData(""effigyType"", type)); } if (type == -1) return; final int skill1 = SKILL_1[type]; final int skill2 = SKILL_2[type]; e.getPlayer().startConversation(new Dialogue() .addSimple(""As you inspect the ancient effigy you begin to feel a strange sensation of the relic searching your mind, drawing on your knowledge."") .addSimple(""Images from your experiences of "" + getMessage(skill1) + "" fill your mind."") .addOptions(""Which images do you wish to focus on?"", new Options() { @Override public void create() { if(e.getPlayer().getSkills().getLevel(skill1) < getRequiredLevel(e.getItem().getId())) option(Constants.SKILL_NAME[skill1], new Dialogue() .addSimple(""The images in your mind fade; the ancient effigy seems to desire knowledge of experiences you have not yet had."", () -> { e.getPlayer().sendMessage(""You require at least level "" + getRequiredLevel(e.getItem().getId()) + "" "" + Constants.SKILL_NAME[skill1] + "" to investigate the ancient effigy further.""); e.getPlayer().setNextAnimation(new Animation(4067)); }) ); else option(Constants.SKILL_NAME[skill1], new Dialogue() .addSimple(""As you focus on your memories, you can almost hear a voice in the back of your mind whispering to you..."") .addSimple(""The ancient effigy glows briefly; it seems changed somehow and no longer responds to the same memories as before."", ()->{ e.getPlayer().getSkills().addXpLamp(skill1, getExp(e.getItem().getId())); e.getPlayer().sendMessage(""You have gained "" + getExp(e.getItem().getId()) + "" "" + Constants.SKILL_NAME[skill1] + "" experience!""); effigyInvestigation(e.getPlayer(), e.getItem()); }) .addSimple(""A sudden bolt of inspiration flashes through your mind, revealing new insight into your experiences!"") ); if(e.getPlayer().getSkills().getLevel(skill2) < getRequiredLevel(e.getItem().getId())) option(Constants.SKILL_NAME[skill2], new Dialogue() .addSimple(""The images in your mind fade; the ancient effigy seems to desire knowledge of experiences you have not yet had."", () -> { e.getPlayer().sendMessage(""You require at least level "" + getRequiredLevel(e.getItem().getId()) + Constants.SKILL_NAME[skill2] + "" to investigate the ancient effigy further.""); e.getPlayer().setNextAnimation(new Animation(4067)); }) ); else option(Constants.SKILL_NAME[skill2], new Dialogue() .addSimple(""As you focus on your memories, you can almost hear a voice in the back of your mind whispering to you..."") .addSimple(""The ancient effigy glows briefly; it seems changed somehow and no longer responds to the same memories as before."", ()->{ e.getPlayer().getSkills().addXpLamp(skill2, getExp(e.getItem().getId())); e.getPlayer().sendMessage(""You have gained "" + getExp(e.getItem().getId()) + "" "" + Constants.SKILL_NAME[skill2] + "" experience!""); effigyInvestigation(e.getPlayer(), e.getItem()); }) .addSimple(""A sudden bolt of inspiration flashes through your mind, revealing new insight into your experiences!"") ); } })); }); public static int getRequiredLevel(int id) { return switch (id) { case STARVED_ANCIENT_EFFIGY -> 91; case NOURISHED_ANCIENT_EFFIGY -> 93; case SATED_ANCIENT_EFFIGY -> 95; case GORGED_ANCIENT_EFFIGY -> 97; default -> -1; }; } public static String getMessage(int skill) { return switch (skill) { case Constants.AGILITY -> ""deftness and precision""; case Constants.CONSTRUCTION -> ""buildings and security""; case Constants.COOKING -> ""fire and preparation""; case Constants.FISHING -> ""life and cultivation""; case Constants.FLETCHING -> ""lumber and woodworking""; case Constants.HERBLORE -> ""flora and fuana""; case Constants.MINING -> ""metalwork and minerals""; case Constants.SUMMONING -> ""binding essence and spirits""; default -> null; }; } public static int getExp(int itemId) { return switch (itemId) { case STARVED_ANCIENT_EFFIGY -> 15000; case NOURISHED_ANCIENT_EFFIGY -> 20000; case SATED_ANCIENT_EFFIGY -> 25000; case GORGED_ANCIENT_EFFIGY -> 30000; default -> -1; }; } public static void effigyInvestigation(Player player, Item item) { Inventory inv = player.getInventory(); if (item.getId() == STARVED_ANCIENT_EFFIGY) inv.replace(item, new Item(NOURISHED_ANCIENT_EFFIGY, 1).addMetaData(""effigyType"", Utils.random(7)+1.0)); else if (item.getId() == NOURISHED_ANCIENT_EFFIGY) inv.replace(item, new Item(SATED_ANCIENT_EFFIGY, 1).addMetaData(""effigyType"", Utils.random(7)+1.0)); else if (item.getId() == SATED_ANCIENT_EFFIGY) inv.replace(item, new Item(GORGED_ANCIENT_EFFIGY, 1).addMetaData(""effigyType"", Utils.random(7)+1.0)); else if (item.getId() == GORGED_ANCIENT_EFFIGY) { player.incrementCount(""Ancient Effigies opened""); inv.replace(item, new Item(DRAGONKIN_LAMP, 1)); } player.setNextAnimation(new Animation(item.getId() == GORGED_ANCIENT_EFFIGY ? 14177 : 4068)); if (item.getId() == GORGED_ANCIENT_EFFIGY) player.setNextSpotAnim(new SpotAnim(2692)); } }" "package com.rs.game.content; @PluginEventHandler public class Dicing { public static ItemClickHandler handleRoll = new ItemClickHandler(new Object[] { IntStream.range(15086, 15100).toArray() }, new String[] { ""Drop"" }, e -> handleRoll(e.getPlayer(), e.getItem().getId(), true)); public static void handleRoll(final Player player, int itemId, boolean friends) { if (friends) switch (itemId) { case 15086: friendsRoll(player, itemId, 2072, 1, 6); break; case 15088: friendsRoll(player, itemId, 2074, 1, 12); break; case 15090: friendsRoll(player, itemId, 2071, 1, 8); break; case 15092: friendsRoll(player, itemId, 2070, 1, 10); break; case 15094: friendsRoll(player, itemId, 2073, 1, 12); break; case 15096: friendsRoll(player, itemId, 2068, 1, 20); break; case 15098: friendsRoll(player, itemId, 2075, 1, 100); break; case 15100: friendsRoll(player, itemId, 2069, 1, 4); break; } else switch (itemId) { case 15086: privateRoll(player, itemId, 2072, 1, 6); break; case 15088: privateRoll(player, itemId, 2074, 1, 12); break; case 15090: privateRoll(player, itemId, 2071, 1, 8); break; case 15092: privateRoll(player, itemId, 2070, 1, 10); break; case 15094: privateRoll(player, itemId, 2073, 1, 12); break; case 15096: privateRoll(player, itemId, 2068, 1, 20); break; case 15098: privateRoll(player, itemId, 2075, 1, 100); break; case 15100: privateRoll(player, itemId, 2069, 1, 4); break; } } public static void privateRoll(final Player player, final int itemId, int graphic, final int lowest, final int highest) { player.sendMessage(""Rolling..."", true); player.getInventory().deleteItem(itemId, 1); player.setNextAnimation(new Animation(11900)); player.setNextSpotAnim(new SpotAnim(graphic)); WorldTasks.schedule(new Task() { @Override public void run() { player.getInventory().addItem(itemId, 1); player.sendMessage(""You rolled "" + getRandom(lowest, highest) + "" on "" + diceText(itemId) + "" die."", true); } }, 1); } //TODO public static void friendsRoll(final Player player, final int itemId, int graphic, final int lowest, final int highest) { // if (player.getAccount().getSocial().getCurrentFriendsChat() == null) { // player.sendMessage(""You need to be in a friend chat to use this option.""); // return; // } // player.lock(2); // player.sendMessage(""Rolling...""); // player.getInventory().deleteItem(itemId, 1); // player.setNextAnimation(new Animation(11900)); // player.setNextSpotAnim(new SpotAnim(graphic)); // WorldTasks.schedule(1, () -> { // player.getInventory().addItem(itemId, 1); // player.sendDiceMessage(player, ""Friends Chat channel-mate "" + player.getDisplayName() + "" rolled "" + getRandom(lowest, highest) + "" on "" + diceText(itemId) + "" die.""); // }); } public static int getRandom(int lowest, int highest) { Random r = new Random(); if (lowest > highest) return -1; long range = (long) highest - (long) lowest + 1; long fraction = (long) (range * r.nextDouble()); int numberRolled = (int) (fraction + lowest); return numberRolled; } public static String diceText(int id) { return switch (id) { case 15086 -> ""a six-sided""; case 15088 -> ""two six-sided""; case 15090 -> ""an eight-sided""; case 15092 -> ""a ten-sided""; case 15094 -> ""a twelve-sided""; case 15096 -> ""a a twenty-sided""; case 15098 -> ""the percentile""; case 15100 -> ""a four-sided""; default -> """"; }; } public static int getGraphic(int id) { return 0; } }" "package com.rs.game.content @ServerStartupEvent fun mapDrops() { onNpcDrop(null, Bone.values().filter { bone -> !listOf(Bone.ACCURSED_ASHES, Bone.IMPIOUS_ASHES, Bone.INFERNAL_ASHES).contains(bone) }.map { it.id }.toTypedArray()) { e -> if (bonecrush(e.player, e.item)) e.deleteItem() } onNpcDrop(null, HerbicideSetting.values().map { it.herb.herbId }.toTypedArray()) { e -> if (herbicide(e.player, e.item)) { e.deleteItem() return@onNpcDrop } if (e.player.familiarPouch === Pouch.MACAW && e.player.familiar.inventory.freeSlot() > 0) { e.player.sendMessage(""Your macaw picks up the "" + e.item.name.lowercase(Locale.getDefault()) + "" from the ground."", true) e.player.familiar.inventory.add(Item(e.item.id, e.item.amount)) e.deleteItem() } } onNpcDrop(null, arrayOf(12158, 12159, 12160, 12161, 12162, 12163, 12168)) { e -> if ((e.player.equipment.containsOneItem(25350) || e.player.inventory.containsItem(25350, 1)) && e.player.inventory.hasRoomFor(e.item)) { e.player.inventory.addItem(Item(e.item)) e.deleteItem() } } onNpcDrop(null, arrayOf(995)) { e -> if (e.player.equipment.containsOneItem(25351) || e.player.inventory.containsItem(25351, 1)) { e.player.inventory.addCoins(e.item.amount) e.deleteItem() } } } fun herbicide(player: Player, item: Item): Boolean { if (!player.inventory.containsItem(19675, 1)) return false val setting = HerbicideSetting.forGrimy(item.id) if (setting == null || !player.herbicideSettings.contains(setting)) return false if (player.skills.getLevel(Constants.HERBLORE) >= setting.herb.level) { player.skills.addXp(Constants.HERBLORE, setting.herb.experience * 2) return true } return false } fun bonecrush(player: Player, item: Item): Boolean { if (!player.inventory.containsItem(18337, 1)) return false val bone = Bone.forId(item.id) if (bone != null && bone != Bone.ACCURSED_ASHES && bone != Bone.IMPIOUS_ASHES && bone != Bone.INFERNAL_ASHES) { player.skills.addXp(Constants.PRAYER, bone.experience) Burying.handleNecklaces(player, bone.id) return true } return false }" "package com.rs.game.content; @PluginEventHandler public class DwarfMultiCannon extends OwnedObject { public static final int[][] CANNON_PIECES = { { 6, 8, 10, 12 }, { 20494, 20495, 20496, 20497 }, { 20498, 20499, 20500, 20501 } }; private static final int[][] CANNON_OBJECTS = { { 7, 8, 9, 6 }, { 29398, 29401, 29402, 29406 }, { 29403, 29404, 29405, 29408 } }; private static final int[] CANNON_EMOTES = { 303, 305, 307, 289, 184, 182, 178, 291 }; private final int type; private int balls = 0; private int decay = 0; private Direction spinRot = Direction.NORTH; private enum BannedArea { ABYSS(12108, 12109), ANCIENT_CAVERN(6995, 6994, 6738, 6482), AL_KHARID_PALACE(13105), BLACK_GUARD(""It is not permitted to set up a cannon this close to the Dwarf Black Guard."", 11830, 11829, 12085, 12086), DWARVEN_MINE(11929, 12185, 12184), ENCHANTED_VALLEY(12102), ENTRANA(11060, 11316), FREM_SLAYER_DUNG(""The air is too dank for you to set up a cannon here."", 11164, 10908, 10907), FELDIP_HILLS(10029), GRAND_EXCHANGE(""The Grand Exchange staff prefer not to have heavy artillery operated around their premises."", 12598), KILLERWATT_PLANE(""The electricity bursting through this plane would render the cannon useless."", 10577), TARNS_LAIR(""This temple is ancient and would probably collapse if you started firing a cannon."", 12615, 12616), MORT_MYRE_SWAMP(13621, 13877, 14133, 13620, 13876, 13619, 13875, 13874, 13618, 13363, 14131, 14130), OURIANA_ALTAR(13131), SLAYER_TOWER(13623), REVENANT_CAVE(12446), WARRIORS_GUILD(11319), WYVERN_CAVE(12181), KALPHITE_QUEEN(13972), KING_BLACK_DRAGON(9033); private final static Map MAP = new HashMap<>(); static { for (BannedArea area : values()) { for (int regionId : area.regionIds) MAP.put(regionId, area); } } private final String message; private final int[] regionIds; BannedArea(String message, int... regionIds) { this.message = message == null ? ""It is not permitted to set up a cannon here."" : message; this.regionIds = regionIds; } BannedArea(int... regionIds) { this(null, regionIds); } } public DwarfMultiCannon(Player player, Tile tile, int type) { super(player, CANNON_OBJECTS[type][0], ObjectType.SCENERY_INTERACT, 0, tile); this.type = type; } public static ItemClickHandler handlePlace = new ItemClickHandler(new Object[] { 6, 20494, 20498 }, new String[] { ""Set-up"" }, e -> setUp(e.getPlayer(), e.getItem().getId() == 6 ? 0 : e.getItem().getId() == 20494 ? 1 : 2)); public static boolean canFreelyReplace(Player player) { return player.getPlacedCannon() > 0 && OwnedObject.getNumOwned(player, DwarfMultiCannon.class) == 0; } public static void setUp(Player player, int type) { if (!player.isQuestComplete(Quest.DWARF_CANNON)) { player.sendMessage(""You have no idea how to operate this machine.""); return; } if (OwnedObject.getNumOwned(player, DwarfMultiCannon.class) > 0) { player.sendMessage(""You already have a cannon placed.""); return; } Controller controller = player.getControllerManager().getController(); if (controller != null && !(controller instanceof WildernessController)) { player.sendMessage(""You can't place your cannon here.""); return; } BannedArea area = BannedArea.MAP.get(player.getRegionId()); if (area != null) { player.sendMessage(area.message); return; } int count = 0; for (int item : CANNON_PIECES[type]) { if (!player.getInventory().containsItem(item, 1)) break; count++; } if (count < 4) { player.sendMessage(""You don't have all your cannon parts.""); return; } Tile pos = player.transform(-2, -3, 0); if (!World.floorAndWallsFree(pos, 3) || World.getObject(pos, ObjectType.SCENERY_INTERACT) != null) { player.sendMessage(""There isn't enough space to set up here.""); return; } player.lock(); player.setNextFaceTile(pos); DwarfMultiCannon cannon = new DwarfMultiCannon(player, pos, type); WorldTasks.scheduleTimer(0, 0, stage -> { player.anim(827); if (stage == 0) { player.sendMessage(""You place the cannon base on the ground.""); cannon.createNoReplace(); player.getInventory().deleteItem(CANNON_PIECES[type][0], 1); } else if (stage == 2) { player.sendMessage(""You add the stand.""); cannon.setId(CANNON_OBJECTS[type][1]); player.getInventory().deleteItem(CANNON_PIECES[type][1], 1); } else if (stage == 4) { player.sendMessage(""You add the barrels.""); cannon.setId(CANNON_OBJECTS[type][2]); player.getInventory().deleteItem(CANNON_PIECES[type][2], 1); } else if (stage == 6) { player.sendMessage(""You add the furnace.""); cannon.setId(CANNON_OBJECTS[type][3]); player.getInventory().deleteItem(CANNON_PIECES[type][3], 1); player.setPlacedCannon(type+1); } else if (stage == 8) { player.unlock(); return false; } return true; }); } public static ObjectClickHandler handleOptions = new ObjectClickHandler(new Object[] { ""Dwarf multicannon"", ""Gold dwarf multicannon"", ""Royale dwarf multicannon"" }, e -> { if (e.getObject() instanceof DwarfMultiCannon cannon) { if (e.getOption().equals(""Fire"")) cannon.fire(e.getPlayer()); else if (e.getOption().equals(""Pick-up"")) cannon.pickUp(e.getPlayer(), e.getObject()); } }); public int getMaxBalls() { return switch(type) { case 2 -> 100; case 1 -> 50; default -> 30; }; } public void fire(Player player) { if (!ownedBy(player)) { player.sendMessage(""This is not your cannon.""); return; } if (balls < 30) { int amount = player.getInventory().getAmountOf(2); if (amount == 0) player.sendMessage(""You need to load your cannon with cannon balls before firing it!""); else { int add = 30 - balls; if (amount > add) amount = add; balls += amount; player.getInventory().deleteItem(2, amount); player.sendMessage(""You load the cannon with "" + amount + "" cannon balls.""); } } else player.sendMessage(""Your cannon is full.""); } public void pickUp(Player player, GameObject object) { if (!ownedBy(player)) { player.sendMessage(""This is not your cannon.""); return; } int space = balls > 0 && !player.getInventory().containsItem(2, 1) ? 5 : 4; if (player.getInventory().getFreeSlots() < space) { player.sendMessage(""You need at least "" + space + "" inventory spaces to pick up your cannon.""); return; } player.sendMessage(""You pick up the cannon. It's really heavy.""); for (int i = 0; i < CANNON_PIECES[type].length; i++) player.getInventory().addItem(CANNON_PIECES[type][i], 1); if (balls > 0) { player.getInventory().addItem(2, balls); balls = 0; } player.setPlacedCannon(0); destroy(); } @Override public void tick(Player owner) { if (owner == null) { decay++; if (decay >= 200) destroy(); return; } if (id != CANNON_OBJECTS[type][3] || balls == 0) return; if (spinRot.ordinal() + 1 == Direction.values().length) spinRot = Direction.NORTH; else spinRot = Direction.values()[spinRot.ordinal() + 1]; World.sendObjectAnimation(this, new Animation(CANNON_EMOTES[spinRot.ordinal()])); Tile cannonTile = this.tile.transform(1, 1, 0); for (NPC npc : World.getNPCsInChunkRange(cannonTile.getChunkId(), 2)) { if (npc == owner.getFamiliar() || npc.isDead() || !npc.getDefinitions().hasAttackOption() || !owner.getControllerManager().canHit(npc)) continue; if (!npc.lineOfSightTo(cannonTile, false) || (!owner.isAtMultiArea() && owner.inCombat() && owner.getAttackedBy() != npc)) continue; if (!owner.isAtMultiArea() && npc.getAttackedBy() != owner && npc.inCombat()) continue; if (npc.withinDistance(cannonTile, 10) && getDirectionTo(npc) == spinRot) { Hit hit = PlayerCombatKt.calculateHit(owner, npc, 0, 300, owner.getEquipment().getWeaponId(), owner.getCombatDefinitions().getAttackStyle(), PlayerCombatKt.isRanging(owner), true, 1.0); WorldProjectile proj = World.sendProjectile(Tile.of(getX() + 1, getY() + 1, getPlane()), npc, 53, 38, 38, 30, 1, 0, 0); WorldTasks.schedule(proj.getTaskDelay(), () -> npc.applyHit(new Hit(owner, hit.getDamage(), HitLook.CANNON_DAMAGE))); owner.getSkills().addXp(Constants.RANGE, (double) hit.getDamage() / 5); balls--; npc.setTarget(owner); npc.setAttackedBy(owner); break; } } } public Direction getDirectionTo(Entity entity) { Vec2 to = entity.getMiddleTileAsVector(); Vec2 from = new Vec2(tile.transform(1, 1, 0)); Vec2 sub = to.sub(from); sub.norm(); Tile delta = sub.toTile(); return Direction.forDelta(delta.getX(), delta.getY()); } }" "package com.rs.game.content; public enum Effect { SKULL { @Override public void apply(Entity entity) { if (entity instanceof Player player) player.getAppearance().generateAppearanceData(); } @Override public void expire(Entity entity) { if (entity instanceof Player player) player.getAppearance().generateAppearanceData(); } }, ANTIPOISON(""poison immunity"") { @Override public void apply(Entity player) { player.getPoison().reset(); } }, STUN, FREEZE, FREEZE_BLOCK, MIASMIC_SLOWDOWN, MIASMIC_BLOCK, TELEBLOCK(""teleblock""), DOUBLE_XP(""double xp"", false), ANTIFIRE(""antifire""), SUPER_ANTIFIRE(""super-antifire""), PRAYER_RENEWAL(""prayer renewal"") { @Override public void tick(Entity entity, long tickNumber) { if (entity instanceof Player player) if (!player.getPrayer().hasFullPoints()) { player.getPrayer().restorePrayer(((player.getSkills().getLevelForXp(Constants.PRAYER) * 4.3 / 600.0)) + 0.2); if (tickNumber % 25 == 0) player.setNextSpotAnim(new SpotAnim(1295)); } } }, BARON_SHARK() { @Override public void tick(Entity entity, long tick) { if (tick % 2 == 0) { entity.heal(10); } } }, STAFF_OF_LIGHT_SPEC(""staff of light protection"", true), JUJU_MINING(""juju mining potion"", false), JUJU_MINE_BANK, JUJU_WOODCUTTING(""juju woodcutting potion"", false), JUJU_WC_BANK, JUJU_FARMING(""juju farming potion"", false), JUJU_FISHING(""juju fishing potion"", false), SCENTLESS(""scentless potion"", false), JUJU_HUNTER(""juju hunter potion"", false), SARA_BLESSING(""Saradomin's blessing"", false), GUTHIX_GIFT(""Guthix's gift"", false), ZAMMY_FAVOR(""Zamorak's favour"", false), REV_IMMUNE(""immunity to revenants"", false), REV_AGGRO_IMMUNE(""revenant aggression immunity"", false), CHARGED(""god charge"", false), DUNG_HS_SCROLL_BOOST(""hoardstalker boost"", true), AGGRESSION_POTION(""aggression potion"", false), OVERLOAD_PVP_REDUCTION(true), MELEE_IMMUNE(true), BONFIRE(""bonfire boost"", false) { @Override public void apply(Entity entity) { if (entity instanceof Player player) player.getEquipment().refreshConfigs(false); } @Override public void expire(Entity entity) { if (entity instanceof Player player) player.getEquipment().refreshConfigs(false); } }, BLOOD_NECKLACE(""blood necklace"") { @Override public boolean sendWarnings() { return false; } @Override public void tick(Entity entity, long tick) { if(entity instanceof Player player && player.getDungManager().isInsideDungeon()) { List npcs = player.queryNearbyNPCsByTileRange(1, npc -> !npc.isDead() && npc.withinDistance(player, 1) && npc.getDefinitions().hasAttackOption() && player.getControllerManager().canHit(npc) && npc.getTarget() instanceof Player); for (NPC npc : npcs) if (tick % Ticks.fromSeconds(10) == 0) { int dmg = 40 * player.getSkills().getCombatLevelWithSummoning() / 138; npc.applyHit(new Hit(player, dmg, Hit.HitLook.TRUE_DAMAGE)); player.heal(dmg); } } } }, EXCALIBUR_HEAL() { @Override public void tick(Entity entity, long tick) { if (tick % 7 == 0) { entity.heal(40); entity.spotAnim(1507); } } }, OVERLOAD(""overload"") { @Override public void apply(Entity entity) { if (entity instanceof Player player) Potions.applyOverLoadEffect(player); } @Override public void tick(Entity entity, long tick) { if (tick % 25 == 0 && entity instanceof Player player) Potions.applyOverLoadEffect(player); } @Override public void expire(Entity entity) { if (entity instanceof Player player) { if (!player.isDead()) { int actualLevel = player.getSkills().getLevel(Constants.ATTACK); int realLevel = player.getSkills().getLevelForXp(Constants.ATTACK); if (actualLevel > realLevel) player.getSkills().set(Constants.ATTACK, realLevel); actualLevel = player.getSkills().getLevel(Constants.STRENGTH); realLevel = player.getSkills().getLevelForXp(Constants.STRENGTH); if (actualLevel > realLevel) player.getSkills().set(Constants.STRENGTH, realLevel); actualLevel = player.getSkills().getLevel(Constants.DEFENSE); realLevel = player.getSkills().getLevelForXp(Constants.DEFENSE); if (actualLevel > realLevel) player.getSkills().set(Constants.DEFENSE, realLevel); actualLevel = player.getSkills().getLevel(Constants.MAGIC); realLevel = player.getSkills().getLevelForXp(Constants.MAGIC); if (actualLevel > realLevel) player.getSkills().set(Constants.MAGIC, realLevel); actualLevel = player.getSkills().getLevel(Constants.RANGE); realLevel = player.getSkills().getLevelForXp(Constants.RANGE); if (actualLevel > realLevel) player.getSkills().set(Constants.RANGE, realLevel); player.heal(500); } player.soundEffect(2607, false); player.sendMessage(""The effects of overload have worn off and you feel normal again.""); } } }, OOG_BANDOS_POOL(""Bandos pool"") { }, OOG_SALTWATER_POOL(""saltwater spring"") { @Override public void apply(Entity entity) { if (entity instanceof Player player) player.restoreRunEnergy(player.getSkills().getLevel(Skills.AGILITY)); } @Override public void tick(Entity entity, long tick) { if (tick % Ticks.fromSeconds(3) == 0 && entity instanceof Player player) player.restoreRunEnergy(player.getSkills().getLevel(Skills.AGILITY)); } }, OOG_THERMAL_POOL(""thermal bath"") { @Override public void apply(Entity entity) { if (entity instanceof Player player) { player.refreshHitPoints(); player.addEffect(Effect.ANTIPOISON, Ticks.fromMinutes(15)); } } @Override public void expire(Entity entity) { if (entity instanceof Player player) player.refreshHitPoints(); } }, FARMERS_AFFINITY(""farmer's affinity""), SHOOTING_STAR_MINING_BUFF(""star sprite's power"", false), EVIL_TREE_WOODCUTTING_BUFF(""evil tree magic"", false); private final String name; Effect(String name, boolean removeOnDeath) { this.name = name; } Effect(String name) { this(name, true); } Effect(boolean removeOnDeath) { this(null, removeOnDeath); } Effect() { this(null, true); } public boolean isRemoveOnDeath() { boolean removeOnDeath = true; return removeOnDeath; } public void apply(Entity player) { } public void tick(Entity player, long tickNumber) { } public void expire(Entity player) { } public boolean sendWarnings() { return name != null; } public String get30SecWarning() { return ""Your "" + name + "" is going to run out in 30 seconds!""; } public String getExpiryMessage() { return ""Your "" + name + "" has run out!""; } }" "package com.rs.game.content; @PluginEventHandler public class EquipAndRemoveItems { public static ItemClickHandler handle = new ItemClickHandler(new String[] { ""Wear"", ""Remove"", ""Wield"" }, e -> { switch(e.getOption()) { case ""Remove"": Equipment.remove(e.getPlayer(), Equipment.getItemSlot(e.getItem().getId())); break; case ""Wear"": case ""Wield"": if (e.getPlayer().isEquipDisabled()) return; Equipment.sendWear(e.getPlayer(), e.getSlotId(), e.getItem().getId()); break; } }); public static ItemEquipHandler handleElementalGear = new ItemEquipHandler(new Object[] { 9733, 9729, 18693, 20440, 20442, 18699, 18697, 18695, 20444, 20446, 20458, 20460, 20462, 20464, 20466, 20448, 20450, 20452, 20456, 20454, 2890, 9731, 18691, 20436, 20438 }, e -> { if (e.equip()) { switch(e.getItem().getId()) { //helms case 9733 -> e.getPlayer().spotAnim(810, 0, 96); case 9729 -> e.getPlayer().spotAnim(811, 0, 96); case 18693 -> e.getPlayer().spotAnim(2686, 0, 96); //case 20440 -> e.getPlayer().spotAnim(cosmic, 0, 96); //case 20442 -> e.getPlayer().spotAnim(chaos, 0, 96); //bodies case 18699 -> e.getPlayer().spotAnim(2679, 0, 96); case 18697 -> e.getPlayer().spotAnim(2678, 0, 96); case 18695 -> e.getPlayer().spotAnim(2677, 0, 96); case 20444 -> e.getPlayer().spotAnim(1532, 0, 96); case 20446 -> e.getPlayer().spotAnim(1531, 0, 96); //gloves case 20458 -> e.getPlayer().spotAnim(699, 0, 96); case 20460 -> e.getPlayer().spotAnim(700, 0, 96); case 20462 -> e.getPlayer().spotAnim(65, 0, 96); case 20464 -> e.getPlayer().spotAnim(487, 0, 96); case 20466 -> e.getPlayer().spotAnim(66, 0, 96); //boots case 20448 -> e.getPlayer().spotAnim(63, 0, 96); case 20450 -> e.getPlayer().spotAnim(64, 0, 96); case 20452 -> e.getPlayer().spotAnim(59, 0, 96); case 20456 -> e.getPlayer().spotAnim(61, 0, 96); case 20454 -> e.getPlayer().spotAnim(62, 0, 96); //shields case 2890 -> e.getPlayer().spotAnim(244, 0, 96); case 9731 -> e.getPlayer().spotAnim(809, 0, 96); case 18691 -> e.getPlayer().spotAnim(2683, 0, 96); case 20436 -> e.getPlayer().spotAnim(2023, 0, 96); case 20438 -> e.getPlayer().spotAnim(2022, 0, 96); } } }); public static ItemEquipHandler handleBloodNecklace = new ItemEquipHandler(new Object[] { 15834, 17291 }, e -> { if(e.equip()) e.getPlayer().addEffect(Effect.BLOOD_NECKLACE, Integer.MAX_VALUE); if(e.dequip()) e.getPlayer().removeEffect(Effect.BLOOD_NECKLACE); } ); }" "package com.rs.game.content; @PluginEventHandler public class ItemConstants { public static int[] CHARM_IDS = { 12158, 12159, 12160, 12163 }; public enum ItemDegrade { AHRIM_HELM(4708, 4856, 4860, Ticks.fromHours(10), 60000), AHRIM_WEAP(4710, 4862, 4866, Ticks.fromHours(10), 100000), AHRIM_TOP(4712, 4868, 4872, Ticks.fromHours(10), 90000), AHRIM_LEGS(4714, 4874, 4878, Ticks.fromHours(10), 80000), DHAROK_HELM(4716, 4880, 4884, Ticks.fromHours(10), 60000), DHAROK_WEAP(4718, 4886, 4890, Ticks.fromHours(10), 100000), DHAROK_TOP(4720, 4892, 4896, Ticks.fromHours(10), 90000), DHAROK_LEG(4722, 4898, 4902, Ticks.fromHours(10), 80000), GUTHAN_HELM(4724, 4904, 4908, Ticks.fromHours(10), 60000), GUTHAN_WEAP(4726, 4910, 4914, Ticks.fromHours(10), 100000), GUTHAN_TOP(4728, 4916, 4920, Ticks.fromHours(10), 90000), GUTHAN_LEG(4730, 4922, 4926, Ticks.fromHours(10), 80000), KARIL_HELM(4732, 4928, 4932, Ticks.fromHours(10), 60000), KARIL_WEAP(4734, 4934, 4938, Ticks.fromHours(10), 100000), KARIL_TOP(4736, 4940, 4944, Ticks.fromHours(10), 90000), KARIL_LEG(4738, 4946, 4950, Ticks.fromHours(10), 80000), TORAG_HELM(4745, 4952, 4956, Ticks.fromHours(10), 60000), TORAG_WEAP(4747, 4958, 4962, Ticks.fromHours(10), 100000), TORAG_TOP(4749, 4964, 4968, Ticks.fromHours(10), 90000), TORAG_LEG(4751, 4970, 4974, Ticks.fromHours(10), 80000), VERAC_HELM(4753, 4976, 4980, Ticks.fromHours(10), 60000), VERAC_WEAP(4755, 4982, 4986, Ticks.fromHours(10), 100000), VERAC_TOP(4757, 4988, 4992, Ticks.fromHours(10), 90000), VERAC_LEG(4759, 4994, 4998, Ticks.fromHours(10), 80000), AKRISAE_HELM(21736, 21738, 21742, Ticks.fromHours(10), 60000), AKRISAE_WEAP(21744, 21746, 21750, Ticks.fromHours(10), 100000), AKRISAE_TOP(21752, 21754, 21758, Ticks.fromHours(10), 90000), AKRISAE_LEG(21760, 21762, 21766, Ticks.fromHours(10), 80000), ZURIELS_TOP(13858, 13860, -1, Ticks.fromHours(1), -1), ZURIELS_BOTTOM(13861, 13863, -1, Ticks.fromHours(1), -1), ZURIELS_HOOD(13858, 13860, -1, Ticks.fromHours(1), -1), ZURIELS_STAFF(13867, 13869, -1, Ticks.fromHours(1), -1), MORRIGANS_TOP(13870, 13872, -1, Ticks.fromHours(1), -1), MORRIGANS_BOTTOM(13873, 13875, -1, Ticks.fromHours(1), -1), MORRIGANS_HOOD(13876, 13878, -1, Ticks.fromHours(1), -1), STATIUS_TOP(13884, 13886, -1, Ticks.fromHours(1), -1), STATIUS_BOTTOM(13890, 13892, -1, Ticks.fromHours(1), -1), STATIUS_HELM(13896, 13898, -1, Ticks.fromHours(1), -1), STATIUS_HAMMER(13902, 13904, -1, Ticks.fromHours(1), -1), VESTAS_TOP(13887, 13889, -1, Ticks.fromHours(1), -1), VESTAS_BOTTOM(13893, 13895, -1, Ticks.fromHours(1), -1), VESTAS_LONGSWORD(13899, 13901, -1, Ticks.fromHours(1), -1), VESTAS_SPEAR(13905, 13907, -1, Ticks.fromHours(1), -1), C_ZURIELS_TOP(13932, 13934, -1, Ticks.fromMinutes(15), -1), C_ZURIELS_BOTTOM(13935, 13937, -1, Ticks.fromMinutes(15), -1), C_ZURIELS_HOOD(13938, 13940, -1, Ticks.fromMinutes(15), -1), C_ZURIELS_STAFF(13941, 13943, -1, Ticks.fromMinutes(15), -1), C_MORRIGANS_TOP(13944, 13946, -1, Ticks.fromMinutes(15), -1), C_MORRIGANS_BOTTOM(13947, 13949, -1, Ticks.fromMinutes(15), -1), C_MORRIGANS_HOOD(13950, 13952, -1, Ticks.fromMinutes(15), -1), C_STATIUS_TOP(13908, 13910, -1, Ticks.fromMinutes(15), -1), C_STATIUS_BOTTOM(13914, 13916, -1, Ticks.fromMinutes(15), -1), C_STATIUS_HELM(13920, 13922, -1, Ticks.fromMinutes(15), -1), C_STATIUS_HAMMER(13926, 13928, -1, Ticks.fromMinutes(15), -1), C_VESTAS_TOP(13911, 13913, -1, Ticks.fromMinutes(15), -1), C_VESTAS_BOTTOM(13917, 13919, -1, Ticks.fromMinutes(15), -1), C_VESTAS_LONGSWORD(13923, 13925, -1, Ticks.fromMinutes(15), -1), C_VESTAS_SPEAR(13929, 13931, -1, Ticks.fromMinutes(15), -1), C_DRAG_CHAIN(13958, 13960, -1, Ticks.fromMinutes(30), -1), C_DRAG_HELM(13961, 13963, -1, Ticks.fromMinutes(30), -1), C_DRAG_SQ_S(13964, 13966, -1, Ticks.fromMinutes(30), -1), C_DRAG_SKIRT(13967, 13969, -1, Ticks.fromMinutes(30), -1), C_DRAG_LEGS(13970, 13972, -1, Ticks.fromMinutes(30), -1), C_DRAG_BAXE(13973, 13975, -1, Ticks.fromMinutes(30), -1), C_DRAG_DAG(13976, 13978, -1, Ticks.fromMinutes(30), -1), C_DRAG_SCIM(13979, 13981, -1, Ticks.fromMinutes(30), -1), C_DRAG_LONG(13982, 13984, -1, Ticks.fromMinutes(30), -1), C_DRAG_MACE(13985, 13987, -1, Ticks.fromMinutes(30), -1), C_DRAG_SPEAR(13988, 13990, -1, Ticks.fromMinutes(30), -1), GOLIATH_B(22358, 22358, -1, Ticks.fromHours(10), -1), GOLIATH_W(22359, 22359, -1, Ticks.fromHours(10), -1), GOLIATH_Y(22360, 22360, -1, Ticks.fromHours(10), -1), GOLIATH_R(22361, 22361, -1, Ticks.fromHours(10), -1), SWIFT_B(22362, 22362, -1, Ticks.fromHours(10), -1), SWIFT_W(22363, 22363, -1, Ticks.fromHours(10), -1), SWIFT_Y(22364, 22364, -1, Ticks.fromHours(10), -1), SWIFT_R(22365, 22365, -1, Ticks.fromHours(10), -1), SPELLCASTER_B(22366, 22366, -1, Ticks.fromHours(10), -1), SPELLCASTER_W(22367, 22367, -1, Ticks.fromHours(10), -1), SPELLCASTER_Y(22368, 22368, -1, Ticks.fromHours(10), -1), SPELLCASTER_R(22369, 22369, -1, Ticks.fromHours(10), -1), BATTLE_HOOD(12866, -1, 12871, Ticks.fromHours(6), -1), BATTLE_RTOP(12873, -1, 12878, Ticks.fromHours(6), -1), BATTLE_RBOT(12880, -1, 12885, Ticks.fromHours(6), -1), DMAGE_HOOD(12887, -1, 12892, Ticks.fromHours(6), -1), DMAGE_RTOP(12894, -1, 12899, Ticks.fromHours(6), -1), DMAGE_RBOT(12901, -1, 12906, Ticks.fromHours(6), -1), COMBAT_HOOD(12964, -1, 12969, Ticks.fromHours(6), -1), COMBAT_RTOP(12971, -1, 12976, Ticks.fromHours(6), -1), COMBAT_RBOT(12978, -1, 12983, Ticks.fromHours(6), -1), ADDY_SPIKE(12908, -1, 12913, Ticks.fromHours(6), -1), ADDY_ZERK(12915, -1, 12920, Ticks.fromHours(6), -1), RUNE_SPIKE(12922, -1, 12927, Ticks.fromHours(6), -1), RUNE_ZERK(12929, -1, 12934, Ticks.fromHours(6), -1), GREEN_COIF(12936, -1, 12941, Ticks.fromHours(6), -1), BLUE_COIF(12943, -1, 12948, Ticks.fromHours(6), -1), RED_COIF(12950, -1, 12955, Ticks.fromHours(6), -1), BLACK_COIF(12957, -1, 12962, Ticks.fromHours(6), -1), ROYAL_COIF(24388, -1, 24393, Ticks.fromHours(6), -1), CHAOTIC_RAPIER(18349, -1, 18350, Ticks.fromHours(10), 2000000), CHAOTIC_LONGSWORD(18351, -1, 18352, Ticks.fromHours(10), 2000000), CHAOTIC_MAUL(18353, -1, 18354, Ticks.fromHours(10), 2000000), CHAOTIC_STAFF(18355, -1, 18356, Ticks.fromHours(10), 2000000), CHAOTIC_CROSSBOW(18357, -1, 18358, Ticks.fromHours(10), 2000000), CHAOTIC_KITESHIELD(18359, -1, 18360, Ticks.fromHours(10), 2000000), EAGLE_KITESHIELD(18361, -1, 18362, Ticks.fromHours(10), 2000000), FARSEER_KITESHIELD(18363, -1, 18364, Ticks.fromHours(10), 2000000), GRAVITE_RAPIER(18365, -1, 18366, Ticks.fromHours(5), 1000000), GRAVITE_LONGSWORD(18367, -1, 18368, Ticks.fromHours(5), 1000000), GRAVITE_2H(18369, -1, 18370, Ticks.fromHours(5), 1000000), GRAVITE_STAFF(18371, -1, 18372, Ticks.fromHours(5), 1000000), GRAVITE_SHORTBOW(18373, -1, 18374, Ticks.fromHours(5), 1000000), FUNGAL_VISOR(22458, 22460, 22452, Ticks.fromHours(10), -1), FUNGAL_PONCHO(22466, 22468, 22456, Ticks.fromHours(10), -1), FUNGAL_LEGGINGS(22462, 22464, 22454, Ticks.fromHours(10), -1), GRIFOLIC_VISOR(22470, 22472, 22452, Ticks.fromHours(10), -1), GRIFOLIC_PONCHO(22478, 22480, 22456, Ticks.fromHours(10), -1), GRIFOLIC_LEGGINGS(22474, 22476, 22454, Ticks.fromHours(10), -1), GANODERMIC_VISOR(22482, 22484, 22452, Ticks.fromHours(10), -1), GANODERMIC_PONCHO(22490, 22492, 22456, Ticks.fromHours(10), -1), GANODERMIC_LEGGINGS(22486, 22488, 22454, Ticks.fromHours(10), -1), CRYSTAL_BOW_NEW(4212, 4214, 4215, Ticks.fromHours(1), -1), CRYSTAL_BOW_FULL(4214, 4214, 4215, Ticks.fromHours(1), -1), //not certain how, but edge case to cover if someone got a fresh ""full"" bow without meta data instead of a new bow. CRYSTAL_BOW_NINE(4215, 4215, 4216, Ticks.fromHours(1), -1), CRYSTAL_BOW_EIGHT(4216, 4216, 4217, Ticks.fromHours(1), -1), CRYSTAL_BOW_SEVEN(4217, 4217, 4218, Ticks.fromHours(1), -1), CRYSTAL_BOW_SIX(4218, 4218, 4219, Ticks.fromHours(1), -1), CRYSTAL_BOW_FIVE(4219, 4219, 4220, Ticks.fromHours(1), -1), CRYSTAL_BOW_FOUR(4220, 4220, 4221, Ticks.fromHours(1), -1), CRYSTAL_BOW_THREE(4221, 4221, 4222, Ticks.fromHours(1), -1), CRYSTAL_BOW_TWO(4222, 4222, 4223, Ticks.fromHours(1), -1), CRYSTAL_BOW_ONE(4223, 4223, 4207, Ticks.fromHours(1), -1), CRYSTAL_SHIELD_NEW(4224, 4225, 4226, Ticks.fromHours(1), -1), CRYSTAL_SHIELD_FULL(4225, 4225, 4226, Ticks.fromHours(1), -1), //not certain how, but edge case to cover if someone got a fresh ""full"" shield without meta data instead of a new bow. CRYSTAL_SHIELD_NINE(4226, 4226, 4227, Ticks.fromHours(1), -1), CRYSTAL_SHIELD_EIGHT(4227, 4227, 4228, Ticks.fromHours(1), -1), CRYSTAL_SHIELD_SEVEN(4228, 4228, 4229, Ticks.fromHours(1), -1), CRYSTAL_SHIELD_SIX(4229, 4229, 4230, Ticks.fromHours(1), -1), CRYSTAL_SHIELD_FIVE(4230, 4230, 4231, Ticks.fromHours(1), -1), CRYSTAL_SHIELD_FOUR(4231, 4231, 4232, Ticks.fromHours(1), -1), CRYSTAL_SHIELD_THREE(4232, 4232, 4233, Ticks.fromHours(1), -1), CRYSTAL_SHIELD_TWO(4233, 4233, 4234, Ticks.fromHours(1), -1), CRYSTAL_SHIELD_ONE(4234, 4234, 4207, Ticks.fromHours(1), -1), ROYAL_CROSSBOW(24338, 24338, 24339, Ticks.fromHours(10), -1), TORVA_HELM(20135, 20137, 20138, Ticks.fromHours(10), 500000), TORVA_PLATE(20139, 20141, 20142, Ticks.fromHours(10), 2000000), TORVA_LEGS(20143, 20145, 20146, Ticks.fromHours(10), 1000000), TORVA_GLOVES(24977, 24978, 24979, Ticks.fromHours(10), 200000), TORVA_BOOTS(24983, 24984, 24985, Ticks.fromHours(10), 100000), PERNIX_HELM(20147, 20149, 20150, Ticks.fromHours(10), 500000), PERNIX_PLATE(20151, 20153, 20154, Ticks.fromHours(10), 2000000), PERNIX_LEGS(20155, 20157, 20158, Ticks.fromHours(10), 1000000), PERNIX_GLOVES(24974, 24975, 24976, Ticks.fromHours(10), 200000), PERNIX_BOOTS(24989, 24990, 24991, Ticks.fromHours(10), 100000), VIRTUS_HELM(20159, 20161, 20162, Ticks.fromHours(10), 500000), VIRTUS_TOP(20163, 20165, 20166, Ticks.fromHours(10), 2000000), VIRTUS_LEGS(20167, 20169, 20170, Ticks.fromHours(10), 1000000), VIRTUS_GLOVES(24980, 24981, 24982, Ticks.fromHours(10), 200000), VIRTUS_BOOTS(24986, 24987, 24988, Ticks.fromHours(10), 100000), ZARYTE_BOW(20171, 20173, 20174, Ticks.fromHours(10), 2000000); private final int itemId; private final int degradedId; private final int brokenId; private final int defaultCharges; private final int cost; private static final Map BROKEN = new HashMap<>(); private static final Map DEGRADE = new HashMap<>(); private static final Map REPAIRED = new HashMap<>(); static { for (ItemDegrade item : ItemDegrade.values()) { if (item.getBrokenId() != -1) BROKEN.put(item.getBrokenId(), item); if (item.getDegradedId() != -1) DEGRADE.put(item.getDegradedId(), item); else DEGRADE.put(item.getItemId(), item); REPAIRED.put(item.getItemId(), item); } } public static ItemDegrade forId(int itemId) { ItemDegrade deg = BROKEN.get(itemId); if (deg == null) deg = DEGRADE.get(itemId); if (deg == null) deg = REPAIRED.get(itemId); if (deg == null) deg = BROKEN.get(itemId); return deg; } public static ItemDegrade forBrokenId(int itemId) { return BROKEN.get(itemId); } public static ItemDegrade forDegradedId(int itemId) { return DEGRADE.get(itemId); } public static ItemDegrade forNewId(int itemId) { return REPAIRED.get(itemId); } ItemDegrade(int itemId, int degradedId, int brokenId, int defaultCharges, int repairCost) { this.itemId = itemId; this.degradedId = degradedId; this.brokenId = brokenId; this.defaultCharges = defaultCharges; cost = repairCost; } public int getItemId() { return itemId; } public int getDegradedId() { return degradedId; } public int getDefaultCharges() { return defaultCharges; } public int getBrokenId() { return brokenId; } public int getCost(Item item) { if (forBrokenId(item.getId()) != null) return cost; return cost - ((int) (cost * (((double) item.getMetaDataI(""combatCharges"", 0)) / ((double) defaultCharges)))); } public int getRepairStandCost(Player player) { return cost * (1-(player.getSkills().getLevel(Constants.SMITHING)/200)); } } public static ItemClickHandler handleGenericCheckCharges = new ItemClickHandler(new String[] { ""Check-charges"", ""Check state"", ""Check-state"" }, e -> { if (e.getItem().getMetaData(""combatCharges"") != null) e.getPlayer().sendMessage(""It looks like it will last another "" + Utils.ticksToTime(e.getItem().getMetaDataI(""combatCharges""))); else e.getPlayer().sendMessage(""It looks brand new.""); }); public static void handleRepairs(Player player, Item item, final boolean stand, final int slot) { if (item.getId() >= 18349 && item.getId() <= 18374) { player.sendMessage(""This item cannot be repaired here. You should speak with the rewards trader in Damonheim.""); return; } if (item.getId() == 20120) { if (item.getMetaData(""frozenKeyCharges"") != null && item.getMetaDataI(""frozenKeyCharges"") < 100) player.sendOptionDialogue(""Would you like to add a charge to your frozen key? It will cost 50,000 coins."", ops -> { ops.add(""Yes please."", () -> { if (player.getInventory().hasCoins(50000)) { if (player.getInventory().getItem(slot) == null || player.getInventory().getItem(slot).getId() != item.getId()) return; player.getInventory().removeCoins(50000); player.getInventory().getItems().set(slot, new Item(20120, 1).addMetaData(""frozenKeyCharges"", item.getMetaDataI(""frozenKeyCharges"") + 1)); } else player.sendMessage(""You don't have enough money to add a charge.""); }); ops.add(""No, that's too much.""); }); return; } ItemDegrade details = ItemDegrade.forId(item.getId()); if (details == null || details.cost == -1) { if (item.getId() == 4207 || (item.getId() >= 4212 && item.getId() <= 4234)) { player.sendMessage(""This item cannot be repaired here, try speaking with Arianwyn in the hunting grounds near Lletya.""); return; } player.sendMessage(""This item cannot be repaired or is already fully repaired.""); } else player.startConversation(new RepairStandD(player, details, item, stand, slot)); } public static boolean canWear(Item item, Player player) { if (player.hasRights(Rights.ADMIN)) return true; if (item.getId() == 9813 || item.getId() == 10662) if (!player.getQuestManager().completedAllQuests()) { player.sendMessage(""You need to have completed all quests to wear this.""); return false; } Quest quest = Quest.forSlot(item.getDefinitions().getWieldQuestReq()); if (quest != null) { if (!player.isQuestComplete(quest, ""to wear this."")) return false; } HashMap requiriments = item.getDefinitions().getWearingSkillRequiriments(); boolean hasRequirements = true; if (requiriments != null) for (int skillId : requiriments.keySet()) { if (skillId > 24 || skillId < 0) continue; int level = requiriments.get(skillId); if (level < 0 || level > 120) continue; if (player.getSkills().getLevelForXp(skillId) < level) { if (hasRequirements) if (player.getSession() != null) player.sendMessage(""You are not high enough level to use this item.""); hasRequirements = false; String name = Constants.SKILL_NAME[skillId].toLowerCase(); if (player.getSession() != null) player.sendMessage(""You need to have a"" + (name.startsWith(""a"") ? ""n"" : """") + "" "" + name + "" level of "" + level + "".""); } } SetReward reward = SetReward.forId(item.getId()); if ((reward != null && !reward.hasRequirements(player, item.getId())) || !hasRequirements) return false; if (item.getDefinitions().getName().contains(""Max cape"") || item.getDefinitions().getName().contains(""Max hood"")) if (!player.getSkills().isMaxed(false)) return false; if ((item.getId() == 20769 || item.getId() == 20770 || item.getId() == 20771 || item.getId() == 20772)) if (!player.checkCompRequirements(item.getId() == 20771 || item.getId() == 20772)) return false; String itemName = item.getName(); if (itemName.contains(""goliath gloves"") || itemName.contains(""spellcaster glove"") || itemName.contains(""swift glove"")) if (player.getDominionTower().getKilledBossesCount() < 50 && !Settings.getConfig().isDebug()) { player.sendMessage(""You need to have kill at least 50 bosses in the dominion tower to wear these gloves.""); return true; } return true; } public static boolean isDungItem(int itemId) { if (itemId < 15750) return false; //General dung items, dung pouches, dung only kinship rings return (itemId >= 15750 && itemId <= 18329) || (itemId >= 18511 && itemId <= 18570) || (itemId >= 18817 && itemId <= 18829); } public static boolean isHouseOnlyItem(int itemId) { return itemId >= 7671 && itemId <= 7755; } public static boolean isTradeable(Item item) { if (item.getMetaData() != null) return false; switch(item.getId()) { //tradeable non-exchangeable item exceptions case 995: case 1706: case 1707: case 1708: case 1709: case 1710: case 1711: case 20653: case 20654: case 20655: case 20656: case 20657: case 20658: case 11173: case 11174: case 759: return true; } if ((!item.getDefinitions().isStackable() && item.getDefinitions().getCertId() == -1) || item.getDefinitions().isDestroyItem() || item.getDefinitions().isLended()) return false; return item.getDefinitions().canExchange(); } }" "package com.rs.game.content; @PluginEventHandler public final class Notes { private final List notes; private transient Player player; public Notes() { notes = new ArrayList<>(30); } public void setPlayer(Player player) { this.player = player; } public static ButtonClickHandler handleButtons = new ButtonClickHandler(34, e -> { switch (e.getComponentId()) { case 35, 37, 39, 41 -> { e.getPlayer().getNotes().colour((e.getComponentId() - 35) / 2); e.getPlayer().getPackets().setIFHidden(34, 16, true); } case 3 -> e.getPlayer().sendInputLongText(""Add note:"", text -> e.getPlayer().getNotes().add(text)); case 9 -> { switch (e.getPacket()) { case IF_OP1 -> { if (e.getPlayer().getNotes().getCurrentNote() == e.getSlotId()) e.getPlayer().getNotes().removeCurrentNote(); else e.getPlayer().getNotes().setCurrentNote(e.getSlotId()); } case IF_OP2 -> e.getPlayer().sendInputLongText(""Edit note:"", text -> { e.getPlayer().getNotes().setCurrentNote(e.getSlotId()); e.getPlayer().getNotes().edit(text); }); case IF_OP3 -> { e.getPlayer().getNotes().setCurrentNote(e.getSlotId()); e.getPlayer().getPackets().setIFHidden(34, 16, false); } case IF_OP4 -> e.getPlayer().getNotes().delete(e.getSlotId()); default -> {} } } case 11 -> { switch (e.getPacket()) { case IF_OP1 -> e.getPlayer().getNotes().delete(); case IF_OP2 -> e.getPlayer().getNotes().deleteAll(); default -> {} } break; } } }); public void init() { player.getPackets().setIFEvents(new IFEvents(34, 9, 0, 30) .enableRightClickOptions(0,1,2,3) .setDepth(2) .enableDrag()); player.getPackets().setIFHidden(34, 3, false); player.getPackets().setIFHidden(34, 44, false); player.getVars().setVar(1437, 1); // unlocks add notes player.getVars().setVar(1439, -1); refresh(); } private void refresh() { for (int i = 0; i < 30; i++) player.getPackets().sendVarcString(149 + i, notes.size() <= i ? """" : notes.get(i).text); player.getVars().setVar(1440, getPrimaryColour(this)); player.getVars().setVar(1441, getSecondaryColour(this)); } public int getCurrentNote() { return player.getTempAttribs().getI(""CURRENT_NOTE""); } public void setCurrentNote(int id) { if (id >= 30) return; player.getTempAttribs().setI(""CURRENT_NOTE"", id); player.getVars().setVar(1439, id); } public void removeCurrentNote() { player.getTempAttribs().removeI(""CURRENT_NOTE""); player.getVars().setVar(1439, -1); } public boolean add(String text) { if (notes.size() >= 30) { player.sendMessage(""You may only have 30 notes!""); return false; } if (text.length() > 50) { player.sendMessage(""You can only enter notes up to 50 characters!""); return false; } player.getPackets().sendVarcString(149 + notes.size(), text); setCurrentNote(notes.size()); return notes.add(new Note(text)); } public boolean edit(String text) { if (text.length() > 50) { player.sendMessage(""You can only enter notes up to 50 characters!""); return false; } int id = getCurrentNote(); if (id == -1 || notes.size() <= id) return false; notes.get(id).setText(text); player.getPackets().sendVarcString(149 + id, text); return true; } public boolean colour(int colour) { int id = getCurrentNote(); if (id == -1 || notes.size() <= id) return false; notes.get(id).setColour(colour); if (id < 16) player.getVars().setVar(1440, getPrimaryColour(this)); else player.getVars().setVar(1441, getSecondaryColour(this)); return true; } public void switchNotes(int from, int to) { if (notes.size() <= from || notes.size() <= to) return; notes.set(to, notes.set(from, notes.get(to))); refresh(); } public void delete() { delete(getCurrentNote()); } public void delete(int id) { if (id == -1 || notes.size() <= id) return; notes.remove(id); removeCurrentNote(); refresh(); } public void deleteAll() { notes.clear(); removeCurrentNote(); refresh(); } /** * Gets the primary colour of the notes. * * @param notes * The notes. * @return */ public static int getPrimaryColour(Notes notes) { int color = 0; for (int i = 0; i < 16; i++) { if (notes.notes.size() <= i) break; color += colourize(notes.notes.get(i).colour, i); } return color; } /** * Gets the secondary colour of the notes. * * @param notes * The notes. * @return */ public static int getSecondaryColour(Notes notes) { int color = 0; for (int i = 0; i < 14; i++) { if (notes.notes.size() - 16 <= i) break; color += colourize(notes.notes.get(i + 16).colour, i); } return color; } public static int colourize(int colour, int noteId) { return (int) (Math.pow(4, noteId) * colour); } public List getNotes() { return notes; } public static final class Note { private String text; private int colour; public Note(String text) { this.text = text; } public String getText() { return text; } public int getColour() { return colour; } public void setText(String text) { this.text = text; } public void setColour(int colour) { this.colour = colour; } } }" "package com.rs.game.content; @PluginEventHandler public final class PlayerLook { public static void openCharacterCustomizing(Player player) { player.getInterfaceManager().setTopInterface(1028, false); player.getPackets().setIFRightClickOps(1028, 65, 0, 11, 0); player.getPackets().setIFRightClickOps(1028, 128, 0, 50, 0); player.getPackets().setIFRightClickOps(1028, 132, 0, 250, 0); player.getVars().setVarBit(8093, player.getAppearance().isMale() ? 0 : 1); } public static ButtonClickHandler handleCharacterCustomizingButtons = new ButtonClickHandler(1028, e -> { if (e.getComponentId() == 138) { // confirm e.getPlayer().getInterfaceManager().setDefaultTopInterface(); e.getPlayer().getTempAttribs().removeI(""SelectWearDesignD""); e.getPlayer().getTempAttribs().removeI(""ViewWearDesign""); e.getPlayer().getTempAttribs().removeI(""ViewWearDesignD""); e.getPlayer().getAppearance().generateAppearanceData(); } else if (e.getComponentId() >= 68 && e.getComponentId() <= 74) { e.getPlayer().getTempAttribs().setI(""ViewWearDesign"", (e.getComponentId() - 68)); e.getPlayer().getTempAttribs().setI(""ViewWearDesignD"", 0); setDesign(e.getPlayer(), e.getComponentId() - 68, 0); } else if (e.getComponentId() >= 103 && e.getComponentId() <= 105) { int index = e.getPlayer().getTempAttribs().getI(""ViewWearDesign""); e.getPlayer().getTempAttribs().setI(""ViewWearDesignD"", (e.getComponentId() - 103)); setDesign(e.getPlayer(), index, e.getComponentId() - 103); } else if (e.getComponentId() == 62 || e.getComponentId() == 63) setGender(e.getPlayer(), e.getComponentId() == 62); else if (e.getComponentId() == 65) setSkin(e.getPlayer(), e.getSlotId()); else if (e.getComponentId() >= 116 && e.getComponentId() <= 121) e.getPlayer().getTempAttribs().setI(""SelectWearDesignD"", (e.getComponentId() - 116)); else if (e.getComponentId() == 128) { int index = e.getPlayer().getTempAttribs().getI(""SelectWearDesignD""); if (index == 1) { boolean male = e.getPlayer().getAppearance().isMale(); int map1 = EnumDefinitions.getEnum(male ? 3304 : 3302).getIntValue(e.getSlotId()); if (map1 == 0) return; StructDefinitions map = StructDefinitions.getStruct(map1); e.getPlayer().getAppearance().setHairStyle(map.getIntValue(788)); if (!male) e.getPlayer().getAppearance().setBeardStyle(e.getPlayer().getAppearance().getHairStyle()); } else if (index == 2) { e.getPlayer().getAppearance().setTopStyle(EnumDefinitions.getEnum(e.getPlayer().getAppearance().isMale() ? 3287 : 1591).getIntValue(e.getSlotId())); e.getPlayer().getAppearance().generateAppearanceData(); } else if (index == 3) e.getPlayer().getAppearance().setLegsStyle(EnumDefinitions.getEnum(e.getPlayer().getAppearance().isMale() ? 3289 : 1607).getIntValue(e.getSlotId())); else if (index == 4) e.getPlayer().getAppearance().setBootsStyle(EnumDefinitions.getEnum(e.getPlayer().getAppearance().isMale() ? 1136 : 1137).getIntValue(e.getSlotId())); else if (e.getPlayer().getAppearance().isMale()) e.getPlayer().getAppearance().setBeardStyle(EnumDefinitions.getEnum(3307).getIntValue(e.getSlotId())); e.getPlayer().getAppearance().generateAppearanceData(); } else if (e.getComponentId() == 132) { int index = e.getPlayer().getTempAttribs().getI(""SelectWearDesignD""); if (index == 0) setSkin(e.getPlayer(), e.getSlotId()); else if (index == 1 || index == 5) e.getPlayer().getAppearance().setHairColor(EnumDefinitions.getEnum(2345).getIntValue(e.getSlotId())); else if (index == 2) e.getPlayer().getAppearance().setTopColor(EnumDefinitions.getEnum(3283).getIntValue(e.getSlotId())); else if (index == 3) e.getPlayer().getAppearance().setLegsColor(EnumDefinitions.getEnum(3283).getIntValue(e.getSlotId())); else e.getPlayer().getAppearance().setBootsColor(EnumDefinitions.getEnum(3297).getIntValue(e.getSlotId())); } e.getPlayer().getAppearance().generateAppearanceData(); }); public static void setGender(Player player, boolean male) { if (male == player.getAppearance().isMale()) return; if (!male) player.getAppearance().female(); else player.getAppearance().male(); int index1 = player.getTempAttribs().getI(""ViewWearDesign""); int index2 = player.getTempAttribs().getI(""ViewWearDesignD""); setDesign(player, index1 != -1 ? index1 : 0, index2 != -1 ? index2 : 0); player.getAppearance().generateAppearanceData(); player.getVars().setVarBit(8093, male ? 0 : 1); } public static void setSkin(Player player, int index) { player.getAppearance().setSkinColor(EnumDefinitions.getEnum(748).getIntValue(index)); player.getAppearance().generateAppearanceData(); } public static void setSkinCustom(Player player, int index) { player.getAppearance().setSkinColor(index); player.getAppearance().generateAppearanceData(); } public static void setDesign(Player player, int index1, int index2) { int map1 = EnumDefinitions.getEnum(3278).getIntValue(index1); if (map1 == 0) return; boolean male = player.getAppearance().isMale(); int map2Id = StructDefinitions.getStruct(map1).getIntValue((male ? 1169 : 1175) + index2); if (map2Id == 0) return; StructDefinitions map = StructDefinitions.getStruct(map2Id); for (int i = 1182; i <= 1186; i++) { int value = map.getIntValue(i); if (value == -1) continue; player.getAppearance().setLook(i - 1180, value); } for (int i = 1187; i <= 1190; i++) { int value = map.getIntValue(i); if (value == -1) continue; player.getAppearance().setColor(i - 1186, value); } if (!player.getAppearance().isMale()) player.getAppearance().setBeardStyle(player.getAppearance().getHairStyle()); player.getAppearance().generateAppearanceData(); } public static ButtonClickHandler handleMageMakeOverButtons = new ButtonClickHandler(900, e -> { if (e.getComponentId() == 14 || e.getComponentId() == 16 || e.getComponentId() == 15 || e.getComponentId() == 17) e.getPlayer().getTempAttribs().setB(""MageMakeOverGender"", e.getComponentId() == 14 || e.getComponentId() == 16); else if (e.getComponentId() >= 20 && e.getComponentId() <= 31) { int skin; if (e.getComponentId() == 31) skin = 11; else if (e.getComponentId() == 30) skin = 10; else if (e.getComponentId() == 20) skin = 9; else if (e.getComponentId() == 21) skin = 8; else if (e.getComponentId() == 22) skin = 7; else if (e.getComponentId() == 29) skin = 6; else if (e.getComponentId() == 28) skin = 5; else if (e.getComponentId() == 27) skin = 4; else if (e.getComponentId() == 26) skin = 3; else if (e.getComponentId() == 25) skin = 2; else if (e.getComponentId() == 24) skin = 1; else skin = 0; e.getPlayer().getTempAttribs().setI(""MageMakeOverSkin"", skin); } else if (e.getComponentId() == 33) { boolean male = e.getPlayer().getTempAttribs().removeB(""MageMakeOverGender""); int skin = e.getPlayer().getTempAttribs().removeI(""MageMakeOverSkin""); e.getPlayer().closeInterfaces(); if (male == e.getPlayer().getAppearance().isMale() && skin == e.getPlayer().getAppearance().getSkinColor()) e.getPlayer().startConversation(new Dialogue().addNPC(e.getPlayer().getAppearance().isMale() ? 599 : 2676, HeadE.CALM_TALK, ""That is no different from what you already have. I guess I shouldn't charge you if I'm not changing anything."")); else { e.getPlayer().startConversation(new Dialogue().addNPC(e.getPlayer().getAppearance().isMale() ? 599 : 2676, HeadE.CALM_TALK, ""Whew! That was lucky."")); if (e.getPlayer().getAppearance().isMale() != male) { if (e.getPlayer().getEquipment().wearingArmour()) { e.getPlayer().simpleDialogue(""You cannot have armor on while changing your gender.""); return; } if (male) e.getPlayer().getAppearance().resetAppearance(); else e.getPlayer().getAppearance().female(); } e.getPlayer().getAppearance().setSkinColor(skin); e.getPlayer().getAppearance().generateAppearanceData(); } } }); public static ButtonClickHandler handleHairdresserSalonButtons = new ButtonClickHandler(309, e -> { if (e.getComponentId() == 6) e.getPlayer().getTempAttribs().setB(""hairSaloon"", true); else if (e.getComponentId() == 7) e.getPlayer().getTempAttribs().setB(""hairSaloon"", false); else if (e.getComponentId() == 18) e.getPlayer().closeInterfaces(); else if (e.getComponentId() == 10) { boolean hairSalon = e.getPlayer().getTempAttribs().getB(""hairSaloon""); if (hairSalon) { int value = (int) EnumDefinitions.getEnum(e.getPlayer().getAppearance().isMale() ? 2339 : 2342).getKeyForValue(e.getSlotId() / 2); if (value == -1) return; e.getPlayer().getAppearance().setHairStyle(value); } else if (e.getPlayer().getAppearance().isMale()) { int value = EnumDefinitions.getEnum(703).getIntValue(e.getSlotId() / 2); if (value == -1) return; e.getPlayer().getAppearance().setBeardStyle(value); } } else if (e.getComponentId() == 16) { int value = EnumDefinitions.getEnum(2345).getIntValue(e.getSlotId() / 2); if (value == -1) return; e.getPlayer().getAppearance().setHairColor(value); } }); public static void openMageMakeOver(Player player) { player.getInterfaceManager().sendInterface(900); player.getPackets().setIFText(900, 33, ""Confirm""); player.getVars().setVarBit(6098, player.getAppearance().isMale() ? 0 : 1); player.getVars().setVarBit(6099, player.getAppearance().getSkinColor()); player.getTempAttribs().setB(""MageMakeOverGender"", player.getAppearance().isMale()); player.getTempAttribs().setI(""MageMakeOverSkin"", player.getAppearance().getSkinColor()); } public static ButtonClickHandler handleThessaliasMakeOverButtons = new ButtonClickHandler(729, e -> { if (e.getComponentId()== 6) e.getPlayer().getTempAttribs().setI(""ThessaliasMakeOver"", 0); else if (e.getComponentId() == 7) { if (EnumDefinitions.getEnum(e.getPlayer().getAppearance().isMale() ? 690 : 1591).getKeyForValue(e.getPlayer().getAppearance().getTopStyle()) >= 32) e.getPlayer().getTempAttribs().setI(""ThessaliasMakeOver"", 1); else e.getPlayer().sendMessage(""You can't select different arms to go with that top.""); } else if (e.getComponentId() == 8) { if (EnumDefinitions.getEnum(e.getPlayer().getAppearance().isMale() ? 690 : 1591).getKeyForValue(e.getPlayer().getAppearance().getTopStyle()) >= 32) e.getPlayer().getTempAttribs().setI(""ThessaliasMakeOver"", 2); else e.getPlayer().sendMessage(""You can't select different wrists to go with that top.""); } else if (e.getComponentId() == 9) e.getPlayer().getTempAttribs().setI(""ThessaliasMakeOver"", 3); else if (e.getComponentId() == 19) e.getPlayer().closeInterfaces(); else if (e.getComponentId() == 12) { // set part int stage = e.getPlayer().getTempAttribs().getI(""ThessaliasMakeOver""); if (stage == 0) e.getPlayer().getAppearance().setTopStyle(EnumDefinitions.getEnum(e.getPlayer().getAppearance().isMale() ? 690 : 1591).getIntValue(e.getSlotId() / 2)); else if (stage == 1) // arms e.getPlayer().getAppearance().setArmsStyle(EnumDefinitions.getEnum(e.getPlayer().getAppearance().isMale() ? 711 : 693).getIntValue(e.getSlotId() / 2)); else if (stage == 2) // wrists e.getPlayer().getAppearance().setWristsStyle(EnumDefinitions.getEnum(e.getPlayer().getAppearance().isMale() ? 749 : 751).getIntValue(e.getSlotId() / 2)); else e.getPlayer().getAppearance().setLegsStyle(EnumDefinitions.getEnum(e.getPlayer().getAppearance().isMale() ? 1586 : 1607).getIntValue(e.getSlotId() / 2)); } else if (e.getComponentId() == 17) {// color int stage = e.getPlayer().getTempAttribs().getI(""ThessaliasMakeOver""); if (stage == 0 || stage == 1) e.getPlayer().getAppearance().setTopColor(EnumDefinitions.getEnum(3282).getIntValue(e.getSlotId() / 2)); else if (stage == 3) e.getPlayer().getAppearance().setLegsColor(EnumDefinitions.getEnum(3284).getIntValue(e.getSlotId() / 2)); } e.getPlayer().getAppearance().generateAppearanceData(); }); public static void openThessaliasMakeOver(final Player player) { if (player.getEquipment().wearingArmour()) { player.npcDialogue(548, HeadE.CALM_TALK, ""You're not able to try on my clothes with all that armour. Take it off and then speak to me again.""); return; } player.setNextAnimation(new Animation(11623)); player.getInterfaceManager().sendInterface(729); player.getPackets().setIFText(729, 21, ""Free!""); player.getTempAttribs().setI(""ThessaliasMakeOver"", 0); player.getPackets().setIFRightClickOps(729, 12, 0, 100, 0); player.getPackets().setIFRightClickOps(729, 17, 0, EnumDefinitions.getEnum(3282).getSize() * 2, 0); player.setCloseInterfacesEvent(() -> { player.npcDialogue(548, HeadE.CALM_TALK, ""A marvellous choice. You look splendid!""); player.setNextAnimation(new Animation(-1)); player.getAppearance().generateAppearanceData(); player.getTempAttribs().removeI(""ThessaliasMakeOver""); }); } public static void openHairdresserSalon(final Player player) { if (player.getEquipment().getHatId() != -1) { player.npcDialogue(598, HeadE.CALM_TALK, ""I'm afraid I can't see your head at the moment. Please remove your headgear first.""); return; } if (player.getEquipment().getWeaponId() != -1 || player.getEquipment().getShieldId() != -1) { player.npcDialogue(598, HeadE.CALM_TALK, ""I don't feel comfortable cutting hair when you are wielding something. Please remove what you are holding first.""); return; } player.setNextAnimation(new Animation(11623)); player.getInterfaceManager().sendInterface(309); player.getPackets().setIFRightClickOps(309, 10, 0, EnumDefinitions.getEnum(player.getAppearance().isMale() ? 2339 : 2342).getSize() * 2, 0); player.getPackets().setIFRightClickOps(309, 16, 0, EnumDefinitions.getEnum(2345).getSize() * 2, 0); player.getPackets().setIFText(309, 20, ""Free!""); player.getTempAttribs().setB(""hairSaloon"", true); player.setCloseInterfacesEvent(() -> { player.npcDialogue(598, HeadE.CALM_TALK, ""An excellent choice, "" + (player.getAppearance().isMale() ? ""sir"" : ""madam"") + "".""); player.setNextAnimation(new Animation(-1)); player.getAppearance().generateAppearanceData(); player.getTempAttribs().removeB(""hairSaloon""); }); } public static void openYrsaShop(final Player player) { if (player.getEquipment().getBootsId() != -1) { player.npcDialogue(1301, HeadE.CALM_TALK, ""I don't feel comfortable helping you try on new boots when you are wearing some already. Please remove your boots first.""); return; } player.setNextAnimation(new Animation(11623)); player.getInterfaceManager().sendInterface(728); player.getPackets().setIFText(728, 16, ""Free""); player.getTempAttribs().setI(""YrsaBoot"", 0); player.getPackets().setIFRightClickOps(728, 12, 0, 500, 0); player.getPackets().setIFRightClickOps(728, 7, 0, EnumDefinitions.getEnum(3297).getSize() * 2, 0); player.setCloseInterfacesEvent(() -> { player.npcDialogue(1301, HeadE.CHEERFUL, ""Hey, They look great!""); player.setNextAnimation(new Animation(-1)); player.getAppearance().generateAppearanceData(); player.getTempAttribs().removeI(""YrsaBoot""); }); } public static ButtonClickHandler handleYrsaShoes = new ButtonClickHandler(728, e -> { if (e.getComponentId() == 14) e.getPlayer().closeInterfaces(); else if (e.getComponentId() == 12) {// setting the colors. e.getPlayer().getAppearance().setBootsColor(EnumDefinitions.getEnum(3297).getIntValue(e.getSlotId() / 2)); e.getPlayer().getAppearance().generateAppearanceData(); } else if (e.getComponentId() == 7) {// /boot style e.getPlayer().getAppearance().setBootsStyle(EnumDefinitions.getEnum(e.getPlayer().getAppearance().isMale() ? 3290 : 3293).getIntValue(e.getSlotId() / 2)); e.getPlayer().getAppearance().generateAppearanceData(); } }); private PlayerLook() { } }" "package com.rs.game.content; @PluginEventHandler public class Potions { public static final int VIAL = 229; public static final int FLASK = 23191; public static final int JUJU_VIAL = 19996; public static final int BEER_GLASS = 1919; public static final int EMPTY_KEG = 5769; private static final int EMPTY_CUP = 4244; private static final int BOWL = 1923; private static final int EMPTY_JUG = 1935; public enum Potion { CUP_OF_TEA(1980, new int[] { 712, 1978, 4242, 4243, 4245, 4246, 4838, 7730, 7731, 7733, 7734, 7736, 7737 }, p -> { p.heal(30); p.getSkills().adjustStat(3, 0, Constants.ATTACK); p.setNextForceTalk(new ForceTalk(""Aaah, nothing like a nice cuppa tea!"")); }), CUP_OF_TEA_CLAY(7728, 7730, p -> p.getSkills().adjustStat(1, 0, Constants.CONSTRUCTION)), CUP_OF_TEA_CLAY_MILK(7728, 7731, p -> p.getSkills().adjustStat(1, 0, Constants.CONSTRUCTION)), CUP_OF_TEA_PORCELAIN(7732, 7733, p -> p.getSkills().adjustStat(2, 0, Constants.CONSTRUCTION)), CUP_OF_TEA_PORCELAIN_MILK(7732, 7734, p -> p.getSkills().adjustStat(2, 0, Constants.CONSTRUCTION)), CUP_OF_TEA_GOLD(7735, 7736, p -> p.getSkills().adjustStat(3, 0, Constants.CONSTRUCTION)), CUP_OF_TEA_GOLD_MILK(7735, 7737, p -> p.getSkills().adjustStat(3, 0, Constants.CONSTRUCTION)), NETTLE_TEA_CUP(EMPTY_CUP, 4245, p -> { p.restoreRunEnergy(5); p.heal(30); }), NETTLE_TEA_CUP_MILK(EMPTY_CUP, 4246, p -> { p.restoreRunEnergy(5); p.heal(30); }), NETTLE_TEA_BOWL(BOWL, 4239, p -> { p.restoreRunEnergy(5); p.heal(30); }), NETTLE_TEA_BOWL_MILK(BOWL, 4240, p -> { p.restoreRunEnergy(5); p.heal(30); }), NETTLE_WATER(BOWL, 4237, p -> p.heal(10)), ATTACK_POTION(VIAL, new int[] { 2428, 121, 123, 125 }, p -> p.getSkills().adjustStat(3, 0.1, Constants.ATTACK)), ATTACK_FLASK(-1, new int[] { 23195, 23197, 23199, 23201, 23203, 23205 }, p -> p.getSkills().adjustStat(3, 0.1, Constants.ATTACK)), ATTACK_MIX(VIAL, new int[] { 11429, 11431 }, p -> { p.getSkills().adjustStat(3, 0.1, Constants.ATTACK); p.heal(30); }), STRENGTH_POTION(VIAL, new int[] { 113, 115, 117, 119 }, p -> p.getSkills().adjustStat(3, 0.1, Constants.STRENGTH)), STRENGTH_FLASK(-1, new int[] { 23207, 23209, 23211, 23213, 23215, 23217 }, p -> p.getSkills().adjustStat(3, 0.1, Constants.STRENGTH)), STRENGTH_MIX(VIAL, new int[] { 11443, 11441 }, p -> { p.getSkills().adjustStat(3, 0.1, Constants.STRENGTH); p.heal(30); }), DEFENCE_POTION(VIAL, new int[] { 2432, 133, 135, 137 }, p -> p.getSkills().adjustStat(3, 0.1, Constants.DEFENSE)), DEFENCE_FLASK(-1, new int[] { 23231, 23233, 23235, 23237, 23239, 23241 }, p -> p.getSkills().adjustStat(3, 0.1, Constants.DEFENSE)), DEFENCE_MIX(VIAL, new int[] { 11457, 11459 }, p -> { p.getSkills().adjustStat(3, 0.1, Constants.DEFENSE); p.heal(30); }), COMBAT_POTION(VIAL, new int[] { 9739, 9741, 9743, 9745 }, p -> p.getSkills().adjustStat(3, 0.1, Constants.ATTACK, Constants.STRENGTH, Constants.DEFENSE)), COMBAT_FLASK(-1, new int[] { 23447, 23449, 23451, 23453, 23455, 23457 }, p -> p.getSkills().adjustStat(3, 0.1, Constants.ATTACK, Constants.STRENGTH, Constants.DEFENSE)), COMBAT_MIX(VIAL, new int[] { 11445, 11447 }, p -> { p.getSkills().adjustStat(3, 0.1, Constants.ATTACK, Constants.STRENGTH, Constants.DEFENSE); p.heal(30); }), SUPER_ATTACK(VIAL, new int[] { 2436, 145, 147, 149 }, p -> p.getSkills().adjustStat(5, 0.15, Constants.ATTACK)), SUPER_ATTACK_FLASK(-1, new int[] { 23255, 23257, 23259, 23261, 23263, 23265 }, p -> p.getSkills().adjustStat(5, 0.15, Constants.ATTACK)), CW_SUPER_ATTACK_POTION(-1, new int[] { 18715, 18716, 18717, 18718 }, p -> { p.getSkills().adjustStat(5, 0.15, Constants.ATTACK, Constants.STRENGTH, Constants.DEFENSE); p.getSkills().adjustStat(4, 0.10, Constants.RANGE); p.getSkills().adjustStat(5, 0, Constants.MAGIC); }), SUPER_ATTACK_MIX(VIAL, new int[] { 11469, 11471 }, p -> { p.getSkills().adjustStat(5, 0.15, Constants.ATTACK); p.heal(30); }), SUPER_STRENGTH(VIAL, new int[] { 2440, 157, 159, 161 }, p -> p.getSkills().adjustStat(5, 0.15, Constants.STRENGTH)), SUPER_STRENGTH_FLASK(-1, new int[] { 23279, 23281, 23283, 23285, 23287, 23289 }, p -> p.getSkills().adjustStat(5, 0.15, Constants.STRENGTH)), CW_SUPER_STRENGTH_POTION(-1, new int[] { 18719, 18720, 18721, 18722 }, p -> p.getSkills().adjustStat(5, 0.15, Constants.STRENGTH)), SUPER_STRENGTH_MIX(VIAL, new int[] { 11485, 11487 }, p -> { p.getSkills().adjustStat(5, 0.15, Constants.STRENGTH); p.heal(30); }), SUPER_DEFENCE(VIAL, new int[] { 2442, 163, 165, 167 }, p -> p.getSkills().adjustStat(5, 0.15, Constants.DEFENSE)), SUPER_DEFENCE_FLASK(-1, new int[] { 23291, 23293, 23295, 23297, 23299, 23301 }, p -> p.getSkills().adjustStat(5, 0.15, Constants.DEFENSE)), CW_SUPER_DEFENCE_POTION(-1, new int[] { 18723, 18724, 18725, 18726 }, p -> p.getSkills().adjustStat(5, 0.15, Constants.DEFENSE)), SUPER_DEFENCE_MIX(VIAL, new int[] { 11497, 11499 }, p -> { p.getSkills().adjustStat(5, 0.15, Constants.DEFENSE); p.heal(30); }), RANGING_POTION(VIAL, new int[] { 2444, 169, 171, 173 }, p -> p.getSkills().adjustStat(4, 0.10, Constants.RANGE)), RANGING_FLASK(-1, new int[] { 23303, 23305, 23307, 23309, 23311, 23313 }, p -> p.getSkills().adjustStat(4, 0.10, Constants.RANGE)), CW_SUPER_RANGING_POTION(-1, new int[] { 18731, 18732, 18733, 18734 }, p -> p.getSkills().adjustStat(4, 0.10, Constants.RANGE)), RANGING_MIX(VIAL, new int[] { 11509, 11511 }, p -> { p.getSkills().adjustStat(4, 0.10, Constants.RANGE); p.heal(30); }), MAGIC_POTION(VIAL, new int[] { 3040, 3042, 3044, 3046 }, p -> p.getSkills().adjustStat(5, 0, Constants.MAGIC)), MAGIC_FLASK(-1, new int[] { 23423, 23425, 23427, 23429, 23431, 23433 }, p -> p.getSkills().adjustStat(5, 0, Constants.MAGIC)), CW_SUPER_MAGIC_POTION(-1, new int[] { 18735, 18736, 18737, 18738 }, p -> p.getSkills().adjustStat(5, 0, Constants.MAGIC)), MAGIC_MIX(VIAL, new int[] { 11513, 11515 }, p -> { p.getSkills().adjustStat(5, 0, Constants.MAGIC); p.heal(30); }), RESTORE_POTION(VIAL, new int[] { 2430, 127, 129, 131 }, p -> p.getSkills().adjustStat(10, 0.3, false, Constants.ATTACK, Constants.STRENGTH, Constants.DEFENSE, Constants.RANGE, Constants.MAGIC)), RESTORE_FLASK(-1, new int[] { 23219, 23221, 23223, 23225, 23227, 23229 }, p -> p.getSkills().adjustStat(10, 0.3, false, Constants.ATTACK, Constants.STRENGTH, Constants.DEFENSE, Constants.RANGE, Constants.MAGIC)), RESTORE_MIX(VIAL, new int[] { 11449, 11451 }, p -> { p.getSkills().adjustStat(10, 0.3, false, Constants.ATTACK, Constants.STRENGTH, Constants.DEFENSE, Constants.RANGE, Constants.MAGIC); p.heal(30); }), PRAYER_POTION(VIAL, new int[] { 2434, 139, 141, 143 }, p -> p.getPrayer().restorePrayer(((int) (Math.floor(p.getSkills().getLevelForXp(Constants.PRAYER) * 2.5) + 70)))), PRAYER_FLASK(-1, new int[] { 23243, 23245, 23247, 23249, 23251, 23253 }, p -> p.getPrayer().restorePrayer(((int) (Math.floor(p.getSkills().getLevelForXp(Constants.PRAYER) * 2.5) + 70)))), PRAYER_MIX(VIAL, new int[] { 11465, 11467 }, p -> { p.getPrayer().restorePrayer(((int) (Math.floor(p.getSkills().getLevelForXp(Constants.PRAYER) * 2.5) + 70))); p.heal(30); }), SUPER_RESTORE(VIAL, new int[] { 3024, 3026, 3028, 3030 }, p -> { p.getSkills().adjustStat(true, 8, 0.25, false, Utils.range(0, Skills.SIZE-1)); p.getPrayer().restorePrayer(((int) (p.getSkills().getLevelForXp(Constants.PRAYER) * 0.33 * 10))); }), SUPER_RESTORE_FLASK(-1, new int[] { 23399, 23401, 23403, 23405, 23407, 23409 }, p -> { p.getSkills().adjustStat(true, 8, 0.25, false, Utils.range(0, Skills.SIZE-1)); p.getPrayer().restorePrayer(((int) (p.getSkills().getLevelForXp(Constants.PRAYER) * 0.33 * 10))); }), DOM_SUPER_RESTORE(-1, new int[] { 22379, 22380 }, p -> { p.getSkills().adjustStat(true, 8, 0.25, false, Utils.range(0, Skills.SIZE-1)); p.getPrayer().restorePrayer(((int) (p.getSkills().getLevelForXp(Constants.PRAYER) * 0.33 * 10))); }), SUPER_RESTORE_MIX(VIAL, new int[] { 11493, 11495 }, p -> { p.getSkills().adjustStat(true, 8, 0.25, false, Utils.range(0, Skills.SIZE-1)); p.getPrayer().restorePrayer(((int) (p.getSkills().getLevelForXp(Constants.PRAYER) * 0.33 * 10))); p.heal(30); }), PRAYER_RENEWAL(VIAL, new int[] { 21630, 21632, 21634, 21636 }, p -> p.addEffect(Effect.PRAYER_RENEWAL, 500)), PRAYER_RENEWAL_FLASK(-1, new int[] { 23609, 23611, 23613, 23615, 23617, 23619 }, p -> p.addEffect(Effect.PRAYER_RENEWAL, 500)), ANTIPOISON(VIAL, new int[] { 2446, 175, 177, 179 }, p -> p.addEffect(Effect.ANTIPOISON, Ticks.fromSeconds(90))), ANTIPOISON_FLASK(-1, new int[] { 23315, 23317, 23319, 23321, 23323, 23325 }, p -> p.addEffect(Effect.ANTIPOISON, Ticks.fromSeconds(90))), ANTIPOISON_MIX(VIAL, new int[] { 11433, 11435 }, p -> { p.addEffect(Effect.ANTIPOISON, Ticks.fromSeconds(90)); p.heal(30); }), SUPER_ANTIPOISON(VIAL, new int[] { 2448, 181, 183, 185 }, p -> p.addEffect(Effect.ANTIPOISON, Ticks.fromMinutes(6))), SUPER_ANTIPOISON_FLASK(-1, new int[] { 23327, 23329, 23331, 23333, 23335, 23337 }, p -> p.addEffect(Effect.ANTIPOISON, Ticks.fromMinutes(6))), DOM_SUPER_ANTIPOISON(-1, new int[] { 22377, 22378 }, p -> p.addEffect(Effect.ANTIPOISON, Ticks.fromMinutes(6))), ANTI_P_SUPERMIX(VIAL, new int[] { 11473, 11475 }, p -> { p.addEffect(Effect.ANTIPOISON, Ticks.fromMinutes(6)); p.heal(30); }), ANTIPOISONP(VIAL, new int[] { 5943, 5945, 5947, 5949 }, p -> p.addEffect(Effect.ANTIPOISON, Ticks.fromMinutes(9))), ANTIPOISONP_FLASK(-1, new int[] { 23579, 23581, 23583, 23585, 23587, 23589 }, p -> p.addEffect(Effect.ANTIPOISON, Ticks.fromMinutes(9))), ANTIDOTEP_MIX(VIAL, new int[] { 11501, 11503 }, p -> { p.addEffect(Effect.ANTIPOISON, Ticks.fromMinutes(9)); p.heal(30); }), ANTIPOISONPP(VIAL, new int[] { 5952, 5954, 5956, 5958 }, p -> p.addEffect(Effect.ANTIPOISON, Ticks.fromMinutes(12))), ANTIPOISONPP_FLASK(-1, new int[] { 23591, 23593, 23595, 23597, 23599, 23601 }, p -> p.addEffect(Effect.ANTIPOISON, Ticks.fromMinutes(12))), RELICYMS_BALM(VIAL, new int[] { 4842, 4844, 4846, 4848 }, p -> { /*TODO*/ }), RELICYMS_BALM_FLASK(-1, new int[] { 23537, 23539, 23541, 23543, 23545, 23547 }, p -> { /*TODO*/ }), RELICYMS_MIX(VIAL, new int[] { 11437, 11439 }, p -> { //TODO p.heal(30); }), ZAMORAK_BREW(VIAL, new int[] { 2450, 189, 191, 193 }, p -> { p.getSkills().adjustStat(2, 0.2, Constants.ATTACK); p.getSkills().adjustStat(2, 0.12, Constants.STRENGTH); p.getSkills().adjustStat(-2, -0.1, Constants.DEFENSE); p.applyHit(new Hit(null, (int) (p.getHitpoints()*0.12), HitLook.TRUE_DAMAGE)); }), ZAMORAK_BREW_FLASK(-1, new int[] { 23339, 23341, 23343, 23345, 23347, 23349 }), ZAMORAK_MIX(VIAL, new int[] { 11521, 11523 }, p -> p.heal(30)), ANTIFIRE(VIAL, new int[] { 2452, 2454, 2456, 2458 }, p -> p.addEffect(Effect.ANTIFIRE, Ticks.fromMinutes(6))), ANTIFIRE_FLASK(-1, new int[] { 23363, 23365, 23367, 23369, 23371, 23373 }, p -> p.addEffect(Effect.ANTIFIRE, Ticks.fromMinutes(6))), ANTIFIRE_MIX(VIAL, new int[] { 11505, 11507 }, p -> { p.addEffect(Effect.ANTIFIRE, Ticks.fromMinutes(6)); p.heal(30); }), ENERGY_POTION(VIAL, new int[] { 3008, 3010, 3012, 3014 }, p -> p.restoreRunEnergy(20)), ENERGY_FLASK(-1, new int[] { 23375, 23377, 23379, 23381, 23383, 23385 }, p -> p.restoreRunEnergy(20)), ENERGY_MIX(VIAL, new int[] { 11453, 11455 }, p -> { p.restoreRunEnergy(20); p.heal(30); }), SUPER_ENERGY(VIAL, new int[] { 3016, 3018, 3020, 3022 }, p -> p.restoreRunEnergy(40)), SUPER_ENERGY_FLASK(-1, new int[] { 23387, 23389, 23391, 23393, 23395, 23397 }, p -> p.restoreRunEnergy(40)), CW_SUPER_ENERGY_POTION(-1, new int[] { 18727, 18728, 18729, 18730 }, p -> p.restoreRunEnergy(40)), SUPER_ENERGY_MIX(VIAL, new int[] { 11481, 11483 }, p -> { p.restoreRunEnergy(40); p.heal(30); }), GUTHIX_REST(VIAL, new int[] { 4417, 4419, 4421, 4423 }, p -> { p.restoreRunEnergy(5); p.heal(50, 50); p.getPoison().lowerPoisonDamage(10); }), SARADOMIN_BREW(VIAL, new int[] { 6685, 6687, 6689, 6691 }, p -> { int hpChange = (int) (p.getMaxHitpoints() * 0.15); p.heal(hpChange + 20, hpChange); p.getSkills().adjustStat(2, 0.2, Constants.DEFENSE); p.getSkills().adjustStat(-2, -0.1, Constants.ATTACK, Constants.STRENGTH, Constants.MAGIC, Constants.RANGE); }), SARADOMIN_BREW_FLASK(-1, new int[] { 23351, 23353, 23355, 23357, 23359, 23361 }, p -> { int hpChange = (int) (p.getMaxHitpoints() * 0.15); p.heal(hpChange + 20, hpChange); p.getSkills().adjustStat(2, 0.2, Constants.DEFENSE); p.getSkills().adjustStat(-2, -0.1, Constants.ATTACK, Constants.STRENGTH, Constants.MAGIC, Constants.RANGE); }), DOM_SARADOMIN_BREW(-1, new int[] { 22373, 22374 }, p -> { int hpChange = (int) (p.getMaxHitpoints() * 0.15); p.heal(hpChange + 20, hpChange); p.getSkills().adjustStat(2, 0.2, Constants.DEFENSE); p.getSkills().adjustStat(-2, -0.1, Constants.ATTACK, Constants.STRENGTH, Constants.MAGIC, Constants.RANGE); }), MAGIC_ESSENCE(VIAL, new int[] { 9021, 9022, 9023, 9024 }, p -> p.getSkills().adjustStat(4, 0, Constants.MAGIC)), MAGIC_ESSENCE_FLASK(-1, new int[] { 23633, 23634, 23635, 23636, 23637, 23638 }, p -> p.getSkills().adjustStat(4, 0, Constants.MAGIC)), MAGIC_ESSENCE_MIX(VIAL, new int[] { 11489, 11491 }, p -> { p.getSkills().adjustStat(4, 0, Constants.MAGIC); p.heal(30); }), AGILITY_POTION(VIAL, new int[] { 3032, 3034, 3036, 3038 }, p -> p.getSkills().adjustStat(3, 0, Constants.AGILITY)), AGILITY_FLASK(-1, new int[] { 23411, 23413, 23415, 23417, 23419, 23421 }, p -> p.getSkills().adjustStat(3, 0, Constants.AGILITY)), AGILITY_MIX(VIAL, new int[] { 11461, 11463 }, p -> { p.getSkills().adjustStat(3, 0, Constants.AGILITY); p.heal(30); }), FISHING_POTION(VIAL, new int[] { 2438, 151, 153, 155 }, p -> p.getSkills().adjustStat(3, 0, Constants.FISHING)), FISHING_FLASK(-1, new int[] { 23267, 23269, 23271, 23273, 23275, 23277 }, p -> p.getSkills().adjustStat(3, 0, Constants.FISHING)), FISHING_MIX(VIAL, new int[] { 11477, 11479 }, p -> { p.getSkills().adjustStat(3, 0, Constants.FISHING); p.heal(30); }), HUNTER_POTION(VIAL, new int[] { 9998, 10000, 10002, 10004 }, p -> p.getSkills().adjustStat(3, 0, Constants.HUNTER)), HUNTER_FLASK(-1, new int[] { 23435, 23437, 23439, 23441, 23443, 23445 }, p -> p.getSkills().adjustStat(3, 0, Constants.HUNTER)), HUNTING_MIX(VIAL, new int[] { 11517, 11519 }, p -> { p.getSkills().adjustStat(3, 0, Constants.HUNTER); p.heal(30); }), CRAFTING_POTION(VIAL, new int[] { 14838, 14840, 14842, 14844 }, p -> p.getSkills().adjustStat(3, 0, Constants.CRAFTING)), CRAFTING_FLASK(-1, new int[] { 23459, 23461, 23463, 23465, 23467, 23469 }, p -> p.getSkills().adjustStat(3, 0, Constants.CRAFTING)), FLETCHING_POTION(VIAL, new int[] { 14846, 14848, 14850, 14852 }, p -> p.getSkills().adjustStat(3, 0, Constants.FLETCHING)), FLETCHING_FLASK(-1, new int[] { 23471, 23473, 23475, 23477, 23479, 23481 }, p -> p.getSkills().adjustStat(3, 0, Constants.FLETCHING)), SANFEW_SERUM(VIAL, new int[] { 10925, 10927, 10929, 10931 }, p -> { p.getSkills().adjustStat(8, 0.25, false, Utils.range(0, Skills.SIZE-1)); p.getPrayer().restorePrayer(((int) (p.getSkills().getLevelForXp(Constants.PRAYER) * 0.33 * 10))); p.addEffect(Effect.ANTIPOISON, Ticks.fromMinutes(6)); }), SANFEW_SERUM_FLASK(-1, new int[] { 23567, 23569, 23571, 23573, 23575, 23577 }, p -> { p.getSkills().adjustStat(8, 0.25, false, Utils.range(0, Skills.SIZE-1)); p.getPrayer().restorePrayer(((int) (p.getSkills().getLevelForXp(Constants.PRAYER) * 0.33 * 10))); p.addEffect(Effect.ANTIPOISON, Ticks.fromMinutes(6)); }), SUMMONING_POTION(VIAL, new int[] { 12140, 12142, 12144, 12146 }, p -> { p.getSkills().adjustStat(7, 0.25, false, Constants.SUMMONING); Familiar familiar = p.getFamiliar(); if (familiar != null) familiar.restoreSpecialAttack(15); }), SUMMONING_FLASK(-1, new int[] { 23621, 23623, 23625, 23627, 23629, 23631 }, p -> { p.getSkills().adjustStat(7, 0.25, false, Constants.SUMMONING); Familiar familiar = p.getFamiliar(); if (familiar != null) familiar.restoreSpecialAttack(15); }), RECOVER_SPECIAL(VIAL, new int[] { 15300, 15301, 15302, 15303 }, true, p -> { p.getTempAttribs().setL(""recSpecPot"", World.getServerTicks()); p.getCombatDefinitions().restoreSpecialAttack(25); }) { @Override public boolean canDrink(Player player) { if (World.getServerTicks() - player.getTempAttribs().getL(""recSpecPot"") < 50) { player.sendMessage(""You may only use this pot every 30 seconds.""); return false; } return true; } }, RECOVER_SPECIAL_FLASK(-1, new int[] { 23483, 23484, 23485, 23486, 23487, 23488 }, true, p -> { p.getTempAttribs().setL(""recSpecPot"", World.getServerTicks()); p.getCombatDefinitions().restoreSpecialAttack(25); }) { @Override public boolean canDrink(Player player) { if (World.getServerTicks() - player.getTempAttribs().getL(""recSpecPot"") < 50) { player.sendMessage(""You may only use this pot every 30 seconds.""); return false; } return true; } }, SUPER_ANTIFIRE(VIAL, new int[] { 15304, 15305, 15306, 15307 }, true, p -> p.addEffect(Effect.SUPER_ANTIFIRE, Ticks.fromMinutes(6))), SUPER_ANTIFIRE_FLASK(-1, new int[] { 23489, 23490, 23491, 23492, 23493, 23494 }, true, p -> p.addEffect(Effect.SUPER_ANTIFIRE, Ticks.fromMinutes(6))), EXTREME_ATTACK(VIAL, new int[] { 15308, 15309, 15310, 15311 }, true, p -> p.getSkills().adjustStat(5, 0.22, Constants.ATTACK)), EXTREME_ATTACK_FLASK(-1, new int[] { 23495, 23496, 23497, 23498, 23499, 23500 }, true, p -> p.getSkills().adjustStat(5, 0.22, Constants.ATTACK)), EXTREME_STRENGTH(VIAL, new int[] { 15312, 15313, 15314, 15315 }, true, p -> p.getSkills().adjustStat(5, 0.22, Constants.STRENGTH)), EXTREME_STRENGTH_FLASK(-1, new int[] { 23501, 23502, 23503, 23504, 23505, 23506 }, true, p -> p.getSkills().adjustStat(5, 0.22, Constants.STRENGTH)), EXTREME_DEFENCE(VIAL, new int[] { 15316, 15317, 15318, 15319 }, true, p -> p.getSkills().adjustStat(5, 0.22, Constants.DEFENSE)), EXTREME_DEFENCE_FLASK(-1, new int[] { 23507, 23508, 23509, 23510, 23511, 23512 }, true, p -> p.getSkills().adjustStat(5, 0.22, Constants.DEFENSE)), EXTREME_MAGIC(VIAL, new int[] { 15320, 15321, 15322, 15323 }, true, p -> p.getSkills().adjustStat(7, 0, Constants.MAGIC)), EXTREME_MAGIC_FLASK(-1, new int[] { 23513, 23514, 23515, 23516, 23517, 23518 }, true, p -> p.getSkills().adjustStat(7, 0, Constants.MAGIC)), EXTREME_RANGING(VIAL, new int[] { 15324, 15325, 15326, 15327 }, true, p -> p.getSkills().adjustStat(4, 0.2, Constants.RANGE)), EXTREME_RANGING_FLASK(-1, new int[] { 23519, 23520, 23521, 23522, 23523, 23524 }, true, p -> p.getSkills().adjustStat(4, 0.2, Constants.RANGE)), SUPER_PRAYER(VIAL, new int[] { 15328, 15329, 15330, 15331 }, p -> p.getPrayer().restorePrayer(((int) (70 + (p.getSkills().getLevelForXp(Constants.PRAYER) * 3.43))))), SUPER_PRAYER_FLASK(-1, new int[] { 23525, 23526, 23527, 23528, 23529, 23530 }, p -> p.getPrayer().restorePrayer(((int) (70 + (p.getSkills().getLevelForXp(Constants.PRAYER) * 3.43))))), DOM_SUPER_PRAYER(-1, new int[] { 22375, 22376 }, p -> p.getPrayer().restorePrayer(((int) (70 + (p.getSkills().getLevelForXp(Constants.PRAYER) * 3.43))))), OVERLOAD(VIAL, new int[] { 15332, 15333, 15334, 15335 }, true, p -> { p.addEffect(Effect.OVERLOAD, 500); WorldTasks.scheduleLooping(new Task() { int count = 4; @Override public void run() { if (count == 0) stop(); p.setNextAnimation(new Animation(3170)); p.setNextSpotAnim(new SpotAnim(560)); p.applyHit(new Hit(p, 100, HitLook.TRUE_DAMAGE, 0)); count--; } }, 0, 2); }) { @Override public boolean canDrink(Player player) { if (player.hasEffect(Effect.OVERLOAD)) { player.sendMessage(""You are already under the effects of an overload potion.""); return false; } if (player.getHitpoints() <= 500) { player.sendMessage(""You need more than 500 life points to survive the power of overload.""); return false; } return true; } }, OVERLOAD_FLASK(-1, new int[] { 23531, 23532, 23533, 23534, 23535, 23536 }, true, p -> { p.addEffect(Effect.OVERLOAD, 500); WorldTasks.scheduleLooping(new Task() { int count = 4; @Override public void run() { if (count == 0) stop(); p.setNextAnimation(new Animation(3170)); p.setNextSpotAnim(new SpotAnim(560)); p.applyHit(new Hit(p, 100, HitLook.TRUE_DAMAGE, 0)); count--; } }, 0, 2); }) { @Override public boolean canDrink(Player player) { if (player.hasEffect(Effect.OVERLOAD)) { player.sendMessage(""You are already under the effects of an overload potion.""); return false; } if (player.getHitpoints() <= 500) { player.sendMessage(""You need more than 500 life points to survive the power of overload.""); return false; } return true; } }, JUJU_MINING_POTION(JUJU_VIAL, new int[] { 20003, 20004, 20005, 20006 }, p -> p.addEffect(Effect.JUJU_MINING, 500)), JUJU_MINING_FLASK(-1, new int[] { 23131, 23132, 23133, 23134, 23135, 23136 }, p -> p.addEffect(Effect.JUJU_MINING, 500)), JUJU_COOKING_POTION(JUJU_VIAL, new int[] { 20007, 20008, 20009, 20010 }), JUJU_COOKING_FLASK(-1, new int[] { 23137, 23138, 23139, 23140, 23141, 23142 }), JUJU_FARMING_POTION(JUJU_VIAL, new int[] { 20011, 20012, 20013, 20014 }, p -> p.addEffect(Effect.JUJU_FARMING, 500)), JUJU_FARMING_FLASK(-1, new int[] { 23143, 23144, 23145, 23146, 23147, 23148 }, p -> p.addEffect(Effect.JUJU_FARMING, 500)), JUJU_WOODCUTTING_POTION(JUJU_VIAL, new int[] { 20015, 20016, 20017, 20018 }, p -> p.addEffect(Effect.JUJU_WOODCUTTING, 500)), JUJU_WOODCUTTING_FLASK(-1, new int[] { 23149, 23150, 23151, 23152, 23153, 23154 }, p -> p.addEffect(Effect.JUJU_WOODCUTTING, 500)), JUJU_FISHING_POTION(JUJU_VIAL, new int[] { 20019, 20020, 20021, 20022 }, p -> p.addEffect(Effect.JUJU_FISHING, 500)), JUJU_FISHING_FLASK(-1, new int[] { 23155, 23156, 23157, 23158, 23159, 23160 }, p -> p.addEffect(Effect.JUJU_FISHING, 500)), JUJU_HUNTER_POTION(JUJU_VIAL, new int[] { 20023, 20024, 20025, 20026 }), JUJU_HUNTER_FLASK(-1, new int[] { 23161, 23162, 23163, 23164, 23165, 23166 }), SCENTLESS_POTION(JUJU_VIAL, new int[] { 20027, 20028, 20029, 20030 }, p -> p.addEffect(Effect.SCENTLESS, 500)), SCENTLESS_FLASK(-1, new int[] { 23167, 23168, 23169, 23170, 23171, 23172 }, p -> p.addEffect(Effect.SCENTLESS, 500)), SARADOMINS_BLESSING(JUJU_VIAL, new int[] { 20031, 20032, 20033, 20034 }, p -> p.addEffect(Effect.SARA_BLESSING, 500)), SARADOMINS_BLESSING_FLASK(-1, new int[] { 23173, 23174, 23175, 23176, 23177, 23178 }, p -> p.addEffect(Effect.SARA_BLESSING, 500)), GUTHIXS_GIFT(JUJU_VIAL, new int[] { 20035, 20036, 20037, 20038 }, p -> p.addEffect(Effect.GUTHIX_GIFT, 500)), GUTHIXS_GIFT_FLASK(-1, new int[] { 23179, 23180, 23181, 23182, 23183, 23184 }, p -> p.addEffect(Effect.GUTHIX_GIFT, 500)), ZAMORAKS_FAVOUR(JUJU_VIAL, new int[] { 20039, 20040, 20041, 20042 }, p -> p.addEffect(Effect.ZAMMY_FAVOR, 500)), ZAMORAKS_FAVOUR_FLASK(-1, new int[] { 23185, 23186, 23187, 23188, 23189, 23190 }, p -> p.addEffect(Effect.ZAMMY_FAVOR, 500)), WEAK_MAGIC_POTION(17490, 17556, p -> p.getSkills().adjustStat(4, 0.1, Constants.MAGIC)), WEAK_RANGED_POTION(17490, 17558, p -> p.getSkills().adjustStat(4, 0.1, Constants.RANGE)), WEAK_MELEE_POTION(17490, 17560, p -> p.getSkills().adjustStat(4, 0.1, Constants.ATTACK, Constants.STRENGTH)), WEAK_DEFENCE_POTION(17490, 17562, p -> p.getSkills().adjustStat(4, 0.1, Constants.DEFENSE)), WEAK_GATHERERS_POTION(17490, 17574, p -> p.getSkills().adjustStat(3, 0.02, Constants.WOODCUTTING, Constants.MINING, Constants.FISHING)), WEAK_ARTISANS_POTION(17490, 17576, p -> p.getSkills().adjustStat(3, 0.02, Constants.SMITHING, Constants.CRAFTING, Constants.FLETCHING, Constants.CONSTRUCTION, Constants.FIREMAKING)), WEAK_NATURALISTS_POTION(17490, 17578, p -> p.getSkills().adjustStat(3, 0.02, Constants.COOKING, Constants.FARMING, Constants.HERBLORE, Constants.RUNECRAFTING)), WEAK_SURVIVALISTS_POTION(17490, 17580, p -> p.getSkills().adjustStat(3, 0.02, Constants.AGILITY, Constants.HUNTER, Constants.THIEVING, Constants.SLAYER)), MAGIC_POTION_D(17490, 17582, p -> p.getSkills().adjustStat(5, 0.14, Constants.MAGIC)), RANGED_POTION(17490, 17584, p -> p.getSkills().adjustStat(5, 0.14, Constants.RANGE)), MELEE_POTION(17490, 17586, p -> p.getSkills().adjustStat(5, 0.14, Constants.ATTACK, Constants.STRENGTH)), DEFENCE_POTION_D(17490, 17588, p -> p.getSkills().adjustStat(5, 0.14, Constants.DEFENSE)), GATHERERS_POTION(17490, 17598, p -> p.getSkills().adjustStat(4, 0.04, Constants.WOODCUTTING, Constants.MINING, Constants.FISHING)), ARTISANS_POTION(17490, 17600, p -> p.getSkills().adjustStat(4, 0.04, Constants.SMITHING, Constants.CRAFTING, Constants.FLETCHING, Constants.CONSTRUCTION, Constants.FIREMAKING)), NATURALISTS_POTION(17490, 17602, p -> p.getSkills().adjustStat(4, 0.04, Constants.COOKING, Constants.FARMING, Constants.HERBLORE, Constants.RUNECRAFTING)), SURVIVALISTS_POTION(17490, 17604, p -> p.getSkills().adjustStat(4, 0.04, Constants.AGILITY, Constants.HUNTER, Constants.THIEVING, Constants.SLAYER)), STRONG_MAGIC_POTION(17490, 17606, p -> p.getSkills().adjustStat(6, 0.2, Constants.MAGIC)), STRONG_RANGED_POTION(17490, 17608, p -> p.getSkills().adjustStat(6, 0.2, Constants.RANGE)), STRONG_MELEE_POTION(17490, 17610, p -> p.getSkills().adjustStat(6, 0.2, Constants.ATTACK, Constants.STRENGTH)), STRONG_DEFENCE_POTION(17490, 17612, p -> p.getSkills().adjustStat(6, 0.2, Constants.DEFENSE)), STRONG_GATHERERS_POTION(17490, 17622, p -> p.getSkills().adjustStat(6, 0.06, Constants.WOODCUTTING, Constants.MINING, Constants.FISHING)), STRONG_ARTISANS_POTION(17490, 17624, p -> p.getSkills().adjustStat(6, 0.06, Constants.SMITHING, Constants.CRAFTING, Constants.FLETCHING, Constants.CONSTRUCTION, Constants.FIREMAKING)), STRONG_NATURALISTS_POTION(17490, 17626, p -> p.getSkills().adjustStat(6, 0.06, Constants.COOKING, Constants.FARMING, Constants.HERBLORE, Constants.RUNECRAFTING)), STRONG_SURVIVALISTS_POTION(17490, 17628, p -> p.getSkills().adjustStat(6, 0.06, Constants.AGILITY, Constants.HUNTER, Constants.THIEVING, Constants.SLAYER)), WEAK_STAT_RESTORE_POTION(17490, 17564, p -> p.getSkills().adjustStat(5, 0.12, false, Skills.allExcept(Constants.PRAYER, Constants.SUMMONING))), STAT_RESTORE_POTION(17490, 17590, p -> p.getSkills().adjustStat(7, 0.17, false, Skills.allExcept(Constants.PRAYER, Constants.SUMMONING))), STRONG_STAT_RESTORE_POTION(17490, 17614, p -> p.getSkills().adjustStat(10, 0.24, false, Skills.allExcept(Constants.PRAYER, Constants.SUMMONING))), WEAK_CURE_POTION(17490, 17568, p -> { p.addEffect(Effect.ANTIPOISON, Ticks.fromMinutes(5)); p.addEffect(Effect.ANTIFIRE, Ticks.fromMinutes(5)); }), CURE_POTION(17490, 17592, p -> { p.addEffect(Effect.ANTIPOISON, Ticks.fromMinutes(10)); p.addEffect(Effect.ANTIFIRE, Ticks.fromMinutes(10)); }), STRONG_CURE_POTION(17490, 17616, p -> { p.addEffect(Effect.ANTIPOISON, Ticks.fromMinutes(20)); p.addEffect(Effect.SUPER_ANTIFIRE, Ticks.fromMinutes(20)); }), WEAK_REJUVENATION_POTION(17490, 17570, p -> { p.getSkills().adjustStat(5, 0.10, false, Constants.SUMMONING); p.getPrayer().restorePrayer(((int) ((double) p.getSkills().getLevelForXp(Constants.PRAYER) + 50))); }), REJUVENATION_POTION(17490, 17594, p -> { p.getSkills().adjustStat(7, 0.15, false, Constants.SUMMONING); p.getPrayer().restorePrayer(((int) (Math.floor(p.getSkills().getLevelForXp(Constants.PRAYER) * 1.5) + 70))); }), STRONG_REJUVENATION_POTION(17490, 17618, p -> { p.getSkills().adjustStat(10, 0.22, false, Constants.SUMMONING); p.getPrayer().restorePrayer(((int) (Math.floor(p.getSkills().getLevelForXp(Constants.PRAYER) * 2.2) + 100))); }), POISON_CHALICE(2026, 197, p -> { //TODO }), STRANGE_FRUIT(-1, 464, p -> p.restoreRunEnergy(30)), GORAJIAN_MUSHROOM(-1, 22446, p -> { p.heal((int) (p.getMaxHitpoints()*0.1)); p.getTempAttribs().setB(""gorajMush"", true); }), KARAMJAN_RUM(-1, 431, p -> { p.getSkills().adjustStat(-4, 0, Constants.ATTACK); p.getSkills().adjustStat(-5, 0, Constants.STRENGTH); p.heal(50); }), BANDITS_BREW(BEER_GLASS, 4627, p -> { p.getSkills().adjustStat(1, 0, Constants.ATTACK, Constants.THIEVING); p.getSkills().adjustStat(-1, 0, Constants.STRENGTH); p.getSkills().adjustStat(-6, 0, Constants.DEFENSE); p.heal(10); }), GROG(BEER_GLASS, 1915, p -> { p.getSkills().adjustStat(3, 0, Constants.STRENGTH); p.getSkills().adjustStat(-6, 0, Constants.ATTACK); p.heal(30); }), BEER(BEER_GLASS, 1917, p -> { p.getSkills().adjustStat(0, 0.04, Constants.STRENGTH); p.getSkills().adjustStat(0, -0.07, Constants.ATTACK); p.heal(10); }), BEER_FREM(3805, 3803, p -> { p.getSkills().adjustStat(0, 0.04, Constants.STRENGTH); p.getSkills().adjustStat(0, -0.07, Constants.ATTACK); p.heal(10); }), BEER_POH(BEER_GLASS, 7740, p -> { p.getSkills().adjustStat(0, 0.04, Constants.STRENGTH); p.getSkills().adjustStat(0, -0.07, Constants.ATTACK); p.heal(10); }), ASGARNIAN_ALE(BEER_GLASS, 1905, p -> { p.getSkills().adjustStat(-2, 0, Constants.STRENGTH); p.getSkills().adjustStat(4, 0, Constants.ATTACK); p.heal(20); }), ASGARNIAN_ALE_POH(BEER_GLASS, 7744, p -> { p.getSkills().adjustStat(-2, 0, Constants.STRENGTH); p.getSkills().adjustStat(4, 0, Constants.ATTACK); p.heal(20); }), ASGARNIAN_ALE_KEG(EMPTY_KEG, new int[] { 5779, 5781, 5783, 5785 }, p -> { p.getSkills().adjustStat(-2, 0, Constants.STRENGTH); p.getSkills().adjustStat(4, 0, Constants.ATTACK); p.heal(20); }), ASGARNIAN_ALE_M(BEER_GLASS, 5739, p -> { p.getSkills().adjustStat(-3, 0, Constants.STRENGTH); p.getSkills().adjustStat(6, 0, Constants.ATTACK); p.heal(20); }), ASGARNIAN_ALE_M_KEG(EMPTY_KEG, new int[] { 5859, 5861, 5863, 5865 }, p -> { p.getSkills().adjustStat(-3, 0, Constants.STRENGTH); p.getSkills().adjustStat(6, 0, Constants.ATTACK); p.heal(20); }), MIND_BOMB(BEER_GLASS, 1907, p -> { p.getSkills().adjustStat(p.getSkills().getLevelForXp(Constants.MAGIC) >= 50 ? 3 : 2, 0, Constants.MAGIC); p.getSkills().adjustStat(-3, 0, Constants.ATTACK); p.getSkills().adjustStat(-4, 0, Constants.STRENGTH, Constants.DEFENSE); }), MIND_BOMB_KEG(EMPTY_KEG, new int[] { 5795, 5797, 5799, 5801 }, p -> { p.getSkills().adjustStat(p.getSkills().getLevelForXp(Constants.MAGIC) >= 50 ? 3 : 2, 0, Constants.MAGIC); p.getSkills().adjustStat(-3, 0, Constants.ATTACK); p.getSkills().adjustStat(-4, 0, Constants.STRENGTH, Constants.DEFENSE); }), MIND_BOMB_M(BEER_GLASS, 5741, p -> { p.getSkills().adjustStat(p.getSkills().getLevelForXp(Constants.MAGIC) >= 50 ? 4 : 3, 0, Constants.MAGIC); p.getSkills().adjustStat(-5, 0, Constants.ATTACK, Constants.STRENGTH, Constants.DEFENSE); p.heal(10); }), MIND_BOMB_M_KEG(EMPTY_KEG, new int[] { 5875, 5877, 5879, 5881 }, p -> { p.getSkills().adjustStat(p.getSkills().getLevelForXp(Constants.MAGIC) >= 50 ? 4 : 3, 0, Constants.MAGIC); p.getSkills().adjustStat(-5, 0, Constants.ATTACK, Constants.STRENGTH, Constants.DEFENSE); p.heal(10); }), GREENMANS_ALE(BEER_GLASS, 1909, p -> { p.getSkills().adjustStat(1, 0, Constants.HERBLORE); p.getSkills().adjustStat(-3, 0, Constants.ATTACK, Constants.STRENGTH, Constants.DEFENSE); p.heal(10); }), GREENMANS_ALE_POH(BEER_GLASS, 7746, p -> { p.getSkills().adjustStat(1, 0, Constants.HERBLORE); p.getSkills().adjustStat(-3, 0, Constants.ATTACK, Constants.STRENGTH, Constants.DEFENSE); p.heal(10); }), GREENMANS_ALE_KEG(EMPTY_KEG, new int[] { 5787, 5789, 5791, 5793 }, p -> { p.getSkills().adjustStat(1, 0, Constants.HERBLORE); p.getSkills().adjustStat(-3, 0, Constants.ATTACK, Constants.STRENGTH, Constants.DEFENSE); p.heal(10); }), GREENMANS_ALE_M(BEER_GLASS, 5743, p -> { p.getSkills().adjustStat(2, 0, Constants.HERBLORE); p.getSkills().adjustStat(-2, 0, Constants.ATTACK, Constants.STRENGTH, Constants.DEFENSE); p.heal(10); }), GREENMANS_ALE_M_KEG(EMPTY_KEG, new int[] { 5867, 5869, 5871, 5873 }, p -> { p.getSkills().adjustStat(2, 0, Constants.HERBLORE); p.getSkills().adjustStat(-2, 0, Constants.ATTACK, Constants.STRENGTH, Constants.DEFENSE); p.heal(10); }), DRAGON_BITTER(BEER_GLASS, 1911, p -> { p.getSkills().adjustStat(2, 0, Constants.STRENGTH); p.getSkills().adjustStat(-6, 0, Constants.ATTACK); p.heal(10); }), DRAGON_BITTER_POH(BEER_GLASS, 7748, p -> { p.getSkills().adjustStat(2, 0, Constants.STRENGTH); p.getSkills().adjustStat(-6, 0, Constants.ATTACK); p.heal(10); }), DRAGON_BITTER_KEG(EMPTY_KEG, new int[] { 5803, 5805, 5807, 5809 }, p -> { p.getSkills().adjustStat(2, 0, Constants.STRENGTH); p.getSkills().adjustStat(-6, 0, Constants.ATTACK); p.heal(10); }), DRAGON_BITTER_M(BEER_GLASS, 5745, p -> { p.getSkills().adjustStat(2, 0, Constants.STRENGTH); p.getSkills().adjustStat(-4, 0, Constants.ATTACK); p.heal(20); }), DRAGON_BITTER_M_KEG(EMPTY_KEG, new int[] { 5883, 5885, 5887, 5889 }, p -> { p.getSkills().adjustStat(2, 0, Constants.STRENGTH); p.getSkills().adjustStat(-4, 0, Constants.ATTACK); p.heal(20); }), DWARVEN_STOUT(BEER_GLASS, 1913, p -> { p.getSkills().adjustStat(1, 0, Constants.MINING, Constants.SMITHING); p.getSkills().adjustStat(-3, 0, Constants.ATTACK, Constants.STRENGTH); p.heal(10); }), DWARVEN_STOUT_KEG(EMPTY_KEG, new int[] { 5771, 5773, 5775, 5777 }, p -> { p.getSkills().adjustStat(1, 0, Constants.MINING, Constants.SMITHING); p.getSkills().adjustStat(-3, 0, Constants.ATTACK, Constants.STRENGTH); p.heal(10); }), DWARVEN_STOUT_M(BEER_GLASS, 5747, p -> { p.getSkills().adjustStat(2, 0, Constants.MINING, Constants.SMITHING); p.getSkills().adjustStat(-7, 0, Constants.ATTACK, Constants.STRENGTH, Constants.DEFENSE); p.heal(10); }), DWARVEN_STOUT_M_KEG(EMPTY_KEG, new int[] { 5851, 5853, 5855, 5857 }, p -> { p.getSkills().adjustStat(2, 0, Constants.MINING, Constants.SMITHING); p.getSkills().adjustStat(-7, 0, Constants.ATTACK, Constants.STRENGTH, Constants.DEFENSE); p.heal(10); }), MOONLIGHT_MEAD(BEER_GLASS, 2955, p -> p.heal(40)), MOONLIGHT_MEAD_POH(BEER_GLASS, 7750, p -> p.heal(40)), MOONLIGHT_MEAD_KEG(EMPTY_KEG, new int[] { 5811, 5813, 5815, 5817 }, p -> p.heal(40)), MOONLIGHT_MEAD_M(BEER_GLASS, 5749, p -> p.heal(60)), MOONLIGHT_MEAD_M_KEG(EMPTY_KEG, new int[] { 5891, 5893, 5895, 5897 }, p -> p.heal(60)), AXEMANS_FOLLY(BEER_GLASS, 5751, p -> { p.getSkills().adjustStat(1, 0, Constants.WOODCUTTING); p.getSkills().adjustStat(-3, 0, Constants.ATTACK, Constants.STRENGTH); p.heal(10); }), AXEMANS_FOLLY_KEG(EMPTY_KEG, new int[] { 5819, 5821, 5823, 5825 }, p -> { p.getSkills().adjustStat(1, 0, Constants.WOODCUTTING); p.getSkills().adjustStat(-3, 0, Constants.ATTACK, Constants.STRENGTH); p.heal(10); }), AXEMANS_FOLLY_M(BEER_GLASS, 5753, p -> { p.getSkills().adjustStat(2, 0, Constants.WOODCUTTING); p.getSkills().adjustStat(-4, 0, Constants.ATTACK, Constants.STRENGTH); p.heal(20); }), AXEMANS_FOLLY_M_KEG(EMPTY_KEG, new int[] { 5899, 5901, 5903, 5905 }, p -> { p.getSkills().adjustStat(2, 0, Constants.WOODCUTTING); p.getSkills().adjustStat(-4, 0, Constants.ATTACK, Constants.STRENGTH); p.heal(20); }), CHEFS_DELIGHT(BEER_GLASS, 5755, p -> { p.getSkills().adjustStat(1, 0.05, Constants.COOKING); p.getSkills().adjustStat(-3, 0, Constants.ATTACK, Constants.STRENGTH); p.heal(10); }), CHEFS_DELIGHT_POH(BEER_GLASS, 7754, p -> { p.getSkills().adjustStat(1, 0.05, Constants.COOKING); p.getSkills().adjustStat(-3, 0, Constants.ATTACK, Constants.STRENGTH); p.heal(10); }), CHEFS_DELIGHT_KEG(EMPTY_KEG, new int[] { 5827, 5829, 5831, 5833 }, p -> { p.getSkills().adjustStat(1, 0.05, Constants.COOKING); p.getSkills().adjustStat(-3, 0, Constants.ATTACK, Constants.STRENGTH); p.heal(10); }), CHEFS_DELIGHT_M(BEER_GLASS, 5757, p -> { p.getSkills().adjustStat(2, 0.05, Constants.COOKING); p.getSkills().adjustStat(-3, 0, Constants.ATTACK, Constants.STRENGTH); p.heal(20); }), CHEFS_DELIGHT_M_KEG(EMPTY_KEG, new int[] { 5907, 5909, 5911, 5913 }, p -> { p.getSkills().adjustStat(2, 0.05, Constants.COOKING); p.getSkills().adjustStat(-3, 0, Constants.ATTACK, Constants.STRENGTH); p.heal(20); }), SLAYERS_RESPITE(BEER_GLASS, 5759, p -> { p.getSkills().adjustStat(2, 0, Constants.SLAYER); p.getSkills().adjustStat(-2, 0, Constants.ATTACK, Constants.STRENGTH); p.heal(10); }), SLAYERS_RESPITE_KEG(EMPTY_KEG, new int[] { 5835, 5837, 5839, 5841 }, p -> { p.getSkills().adjustStat(2, 0, Constants.SLAYER); p.getSkills().adjustStat(-2, 0, Constants.ATTACK, Constants.STRENGTH); p.heal(10); }), SLAYERS_RESPITE_M(BEER_GLASS, 5761, p -> { p.getSkills().adjustStat(4, 0, Constants.SLAYER); p.getSkills().adjustStat(-2, 0, Constants.ATTACK, Constants.STRENGTH); p.heal(10); }), SLAYERS_RESPITE_M_KEG(EMPTY_KEG, new int[] { 5915, 5917, 5919, 5921 }, p -> { p.getSkills().adjustStat(4, 0, Constants.SLAYER); p.getSkills().adjustStat(-2, 0, Constants.ATTACK, Constants.STRENGTH); p.heal(10); }), CIDER(BEER_GLASS, 5763, p -> { p.getSkills().adjustStat(1, 0, Constants.FARMING); p.getSkills().adjustStat(-2, 0, Constants.ATTACK, Constants.STRENGTH); p.heal(20); }), CIDER_POH(BEER_GLASS, 7752, p -> { p.getSkills().adjustStat(1, 0, Constants.FARMING); p.getSkills().adjustStat(-2, 0, Constants.ATTACK, Constants.STRENGTH); p.heal(20); }), CIDER_KEG(EMPTY_KEG, new int[] { 5843, 5845, 5847, 5849 }, p -> { p.getSkills().adjustStat(1, 0, Constants.FARMING); p.getSkills().adjustStat(-2, 0, Constants.ATTACK, Constants.STRENGTH); p.heal(20); }), CIDER_M(BEER_GLASS, 5765, p -> { p.getSkills().adjustStat(2, 0, Constants.FARMING); p.getSkills().adjustStat(-2, 0, Constants.ATTACK, Constants.STRENGTH); p.heal(20); }), CIDER_M_KEG(EMPTY_KEG, new int[] { 5923, 5925, 5927, 5929 }, p -> { p.getSkills().adjustStat(2, 0, Constants.FARMING); p.getSkills().adjustStat(-2, 0, Constants.ATTACK, Constants.STRENGTH); p.heal(20); }), SERUM_207(VIAL, new int[] { 3408, 3410, 3412, 3414 }), SERUM_208(VIAL, new int[] { 3416, 3417, 3418, 3419 }), OLIVE_OIL(VIAL, new int[] { 3422, 3424, 3426, 3428 }), SACRED_OIL(VIAL, new int[] { 3430, 3432, 3434, 3436 }), JUG_OF_BAD_WINE(EMPTY_JUG, 1991, p -> p.getSkills().lowerStat(Constants.ATTACK, 3)), JUG_OF_WINE(EMPTY_JUG, 1993, p -> { p.heal(110, 0); p.getSkills().lowerStat(Constants.ATTACK, 2); }), ; public static final Map POTS = new HashMap<>(); static { for (Potion pot : Potion.values()) for (int id : pot.ids) POTS.put(id, pot); } public static Potion forId(int itemId) { return POTS.get(itemId); } private final int emptyId; private final Consumer effect; private final int[] ids; private boolean isOP; Potion(int emptyId, int[] ids, boolean isOP, Consumer effect) { this.emptyId = emptyId; this.ids = ids; this.effect = effect; } Potion(int emptyId, int[] ids, Consumer effect) { this(emptyId, ids, false, effect); } Potion(int emptyId, int id, Consumer effect) { this(emptyId, new int[] { id }, false, effect); } Potion(int emptyId, int[] ids) { this(emptyId, ids, null); } public boolean canDrink(Player player) { return true; } private void drink(Player player, int itemId, int slot) { if (player.getInventory().getItem(slot) == null || player.getInventory().getItem(slot).getId() != itemId || !player.canPot() || !player.getControllerManager().canPot(this)) return; if (effect == null) { player.sendMessage(""You wouldn't want to drink that.""); return; } if (isOP && player.getControllerManager().getController() instanceof WildernessController) { player.sendMessage(""You cannot drink this potion here.""); return; } if (canDrink(player)) { int idIdx = -1; for (int i = 0;i < ids.length-1;i++) if (ids[i] == itemId) { idIdx = i; break; } int newId = idIdx == -1 ? emptyId : ids[idIdx+1]; player.getInventory().getItems().set(slot, newId == -1 ? null : new Item(newId, 1)); player.getInventory().refresh(slot); player.addPotionDelay(2); effect.accept(player); player.setNextAnimation(new Animation(829)); player.soundEffect(4580, false); player.sendMessage(""You drink some of your "" + ItemDefinitions.getDefs(itemId).name.toLowerCase().replace("" (1)"", """").replace("" (2)"", """").replace("" (3)"", """").replace("" (4)"", """").replace("" (5)"", """").replace("" (6)"", """") + ""."", true); } } public Consumer getEffect() { return effect; } public int[] getIds() { return ids; } public int getMaxDoses() { return ids.length; } public int getIdForDoses(int doses) { return ids[ids.length-doses]; } public boolean isVial() { return emptyId == VIAL || emptyId == JUJU_VIAL; } public boolean isFlask() { return emptyId == FLASK; } } public static ItemClickHandler clickOps = new ItemClickHandler(Potion.POTS.keySet().toArray(), new String[] { ""Drink"", ""Empty"" }, e -> { Potion pot = Potion.forId(e.getItem().getId()); if (pot == null) return; if (e.getOption().equals(""Drink"")) pot.drink(e.getPlayer(), e.getItem().getId(), e.getItem().getSlot()); else if (e.getOption().equals(""Empty"") && pot.emptyId != -1) { e.getItem().setId(pot.emptyId); e.getPlayer().getInventory().refresh(e.getItem().getSlot()); } }); public static int getDoses(Potion pot, Item item) { for (int i = pot.ids.length - 1; i >= 0; i--) if (pot.ids[i] == item.getId()) return pot.ids.length - i; return 0; } public static ItemOnItemHandler mixPotions = new ItemOnItemHandler(Potion.POTS.keySet().stream().mapToInt(i->i).toArray(), e -> { Item fromItem = e.getItem1(); Item toItem = e.getItem2(); int fromSlot = fromItem.getSlot(); int toSlot = toItem.getSlot(); if (fromItem.getId() == VIAL || toItem.getId() == VIAL) { Potion pot = Potion.forId(fromItem.getId() == VIAL ? toItem.getId() : fromItem.getId()); if (pot == null || pot.emptyId == -1) return; int doses = getDoses(pot, fromItem.getId() == VIAL ? toItem : fromItem); if (doses == 1) { e.getPlayer().getInventory().switchItem(fromSlot, toSlot); e.getPlayer().sendMessage(""You combine the potions."", true); return; } int vialDoses = doses / 2; doses -= vialDoses; e.getPlayer().getInventory().getItems().set(fromItem.getId() == VIAL ? toSlot : fromSlot, new Item(pot.getIdForDoses(doses), 1)); e.getPlayer().getInventory().getItems().set(fromItem.getId() == VIAL ? fromSlot : toSlot, new Item(pot.getIdForDoses(vialDoses), 1)); e.getPlayer().getInventory().refresh(fromSlot); e.getPlayer().getInventory().refresh(toSlot); e.getPlayer().sendMessage(""You split the potion between the two vials."", true); return; } Potion pot = Potion.forId(fromItem.getId()); if (pot == null) return; int doses2 = getDoses(pot, toItem); if (doses2 == 0 || doses2 == pot.getMaxDoses()) return; int doses1 = getDoses(pot, fromItem); doses2 += doses1; doses1 = doses2 > pot.getMaxDoses() ? doses2 - pot.getMaxDoses() : 0; doses2 -= doses1; if (doses1 == 0 && pot.emptyId == -1) e.getPlayer().getInventory().deleteItem(fromSlot, fromItem); else { e.getPlayer().getInventory().getItems().set(fromSlot, new Item(doses1 > 0 ? pot.getIdForDoses(doses1) : pot.emptyId, 1)); e.getPlayer().getInventory().refresh(fromSlot); } e.getPlayer().getInventory().getItems().set(toSlot, new Item(pot.getIdForDoses(doses2), 1)); e.getPlayer().getInventory().refresh(toSlot); e.getPlayer().sendMessage(""You pour from one container into the other"" + (pot.emptyId == -1 && doses1 == 0 ? "" and the flask shatters to pieces."" : ""."")); }); public static void checkOverloads(Player player) { boolean changed = false; int level = player.getSkills().getLevelForXp(Constants.ATTACK); int maxLevel = (int) (level + 5 + (level * 0.15)); if (maxLevel < player.getSkills().getLevel(Constants.ATTACK)) { player.getSkills().set(Constants.ATTACK, maxLevel); changed = true; } level = player.getSkills().getLevelForXp(Constants.STRENGTH); maxLevel = (int) (level + 5 + (level * 0.15)); if (maxLevel < player.getSkills().getLevel(Constants.STRENGTH)) { player.getSkills().set(Constants.STRENGTH, maxLevel); changed = true; } level = player.getSkills().getLevelForXp(Constants.DEFENSE); maxLevel = (int) (level + 5 + (level * 0.15)); if (maxLevel < player.getSkills().getLevel(Constants.DEFENSE)) { player.getSkills().set(Constants.DEFENSE, maxLevel); changed = true; } level = player.getSkills().getLevelForXp(Constants.RANGE); maxLevel = (int) (level + 5 + (level * 0.1)); if (maxLevel < player.getSkills().getLevel(Constants.RANGE)) { player.getSkills().set(Constants.RANGE, maxLevel); changed = true; } level = player.getSkills().getLevelForXp(Constants.MAGIC); maxLevel = level + 5; if (maxLevel < player.getSkills().getLevel(Constants.MAGIC)) { player.getSkills().set(Constants.MAGIC, maxLevel); changed = true; } if (changed) player.sendMessage(""Your extreme potion bonus has been reduced.""); } public static void applyOverLoadEffect(Player player) { if (player.hasEffect(Effect.OVERLOAD_PVP_REDUCTION)) { int actualLevel = player.getSkills().getLevel(Constants.ATTACK); int realLevel = player.getSkills().getLevelForXp(Constants.ATTACK); int level = actualLevel > realLevel ? realLevel : actualLevel; player.getSkills().set(Constants.ATTACK, (int) (level + 5 + (realLevel * 0.15))); actualLevel = player.getSkills().getLevel(Constants.STRENGTH); realLevel = player.getSkills().getLevelForXp(Constants.STRENGTH); level = actualLevel > realLevel ? realLevel : actualLevel; player.getSkills().set(Constants.STRENGTH, (int) (level + 5 + (realLevel * 0.15))); actualLevel = player.getSkills().getLevel(Constants.DEFENSE); realLevel = player.getSkills().getLevelForXp(Constants.DEFENSE); level = actualLevel > realLevel ? realLevel : actualLevel; player.getSkills().set(Constants.DEFENSE, (int) (level + 5 + (realLevel * 0.15))); actualLevel = player.getSkills().getLevel(Constants.MAGIC); realLevel = player.getSkills().getLevelForXp(Constants.MAGIC); level = actualLevel > realLevel ? realLevel : actualLevel; player.getSkills().set(Constants.MAGIC, level + 5); actualLevel = player.getSkills().getLevel(Constants.RANGE); realLevel = player.getSkills().getLevelForXp(Constants.RANGE); level = actualLevel > realLevel ? realLevel : actualLevel; player.getSkills().set(Constants.RANGE, (int) (level + 5 + (realLevel * 0.1))); } else { int actualLevel = player.getSkills().getLevel(Constants.ATTACK); int realLevel = player.getSkills().getLevelForXp(Constants.ATTACK); int level = actualLevel > realLevel ? realLevel : actualLevel; player.getSkills().set(Constants.ATTACK, (int) (level + 5 + (realLevel * 0.22))); actualLevel = player.getSkills().getLevel(Constants.STRENGTH); realLevel = player.getSkills().getLevelForXp(Constants.STRENGTH); level = actualLevel > realLevel ? realLevel : actualLevel; player.getSkills().set(Constants.STRENGTH, (int) (level + 5 + (realLevel * 0.22))); actualLevel = player.getSkills().getLevel(Constants.DEFENSE); realLevel = player.getSkills().getLevelForXp(Constants.DEFENSE); level = actualLevel > realLevel ? realLevel : actualLevel; player.getSkills().set(Constants.DEFENSE, (int) (level + 5 + (realLevel * 0.22))); actualLevel = player.getSkills().getLevel(Constants.MAGIC); realLevel = player.getSkills().getLevelForXp(Constants.MAGIC); level = actualLevel > realLevel ? realLevel : actualLevel; player.getSkills().set(Constants.MAGIC, level + 7); actualLevel = player.getSkills().getLevel(Constants.RANGE); realLevel = player.getSkills().getLevelForXp(Constants.RANGE); level = actualLevel > realLevel ? realLevel : actualLevel; player.getSkills().set(Constants.RANGE, (int) (level + 4 + (Math.floor(realLevel / 5.2)))); } } }" "package com.rs.game.content; @PluginEventHandler public class SkillCapeCustomizer { public static void resetSkillCapes(Player player) { player.setMaxedCapeCustomized(Arrays.copyOf(ItemDefinitions.getDefs(20767).originalModelColors, 4)); player.setCompletionistCapeCustomized(Arrays.copyOf(ItemDefinitions.getDefs(20769).originalModelColors, 4)); } public static void startCustomizing(Player player, int itemId) { int[] colors = itemId == 20767 ? player.getMaxedCapeCustomized() : player.getCompletionistCapeCustomized(); player.getTempAttribs().setO(""scCustomColorArr"", colors); player.getInterfaceManager().sendInterface(20); for (int i = 0; i < 4; i++) player.getVars().setVarBit(9254 + i, colors[i]); player.getPackets().setIFModel(20, 55, player.getAppearance().isMale() ? ItemDefinitions.getDefs(itemId).getMaleWornModelId1() : ItemDefinitions.getDefs(itemId).getFemaleWornModelId1()); } public static void customizeSlot(Player player, int part) { int[] colors = player.getTempAttribs().getO(""scCustomColorArr""); if (colors == null) { player.closeInterfaces(); return; } player.getInterfaceManager().sendInterface(19); player.getVars().setVar(2174, colors[part]); player.sendInputHSL(colorId -> { colors[part] = colorId; player.getVars().setVarBit(9254 + part, colorId); player.getInterfaceManager().sendInterface(20); }); } public static ButtonClickHandler handleSkillCapeCustomizer = new ButtonClickHandler(20, e -> { int[] colors = e.getPlayer().getTempAttribs().getO(""scCustomColorArr""); if (colors == null) { e.getPlayer().closeInterfaces(); return; } switch(e.getComponentId()) { case 58 -> { int[] orig = Arrays.copyOf(ItemDefinitions.getDefs(20767).originalModelColors, 4); System.arraycopy(orig, 0, colors, 0, orig.length); for (int i = 0; i < 4; i++) e.getPlayer().getVars().setVarBit(9254 + i, colors[i]); } case 34 -> customizeSlot(e.getPlayer(), 0); case 71 -> customizeSlot(e.getPlayer(), 1); case 83 -> customizeSlot(e.getPlayer(), 2); case 95 -> customizeSlot(e.getPlayer(), 3); case 114, 142 -> { e.getPlayer().getAppearance().generateAppearanceData(); e.getPlayer().closeInterfaces(); } } }); }" "package com.rs.game.content; public enum Skillcapes { Attack(9747, 9748, 9749, 25324, ""a master in the fine art of attacking""), Defence(9753, 9754, 9755, 25326, ""a master in the fine art of defence""), Strength(9750, 9751, 9752, 25325, ""as strong as is possible""), Constitution(9768, 9769, 9770, 25332, ""as resilient as is possible""), Ranging(9756, 9757, 9758, 25327, ""a master in the fine art of ranging""), Prayer(9759, 9760, 9761, 25328, ""as devoted to prayer as possible""), Magic(9762, 9763, 9764, 25329, ""as powerful a wizard as I""), Cooking(9801, 9802, 9803, 25344, ""a master in the culinary arts""), Woodcutting(9807, 9808, 9809, 25346, ""a master woodsman""), Fletching(9783, 9784, 9785, 25337, ""a master in the fine art of fletching""), Fishing(9798, 9799, 9800, 25343, ""a master fisherman""), Firemaking(9804, 9805, 9806, 25345, ""a master of fire""), Crafting(9780, 9781, 9782, 25336, ""a master craftsman""), Smithing(9795, 9796, 9797, 25342, ""a master blacksmith""), Mining(9792, 9793, 9794, 25341, ""a master miner""), Herblore(9774, 9775, 9776, 25334, ""a master herbalist""), Agility(9771, 9772, 9773, 25333, ""as agile as possible""), Thieving(9777, 9778, 9779, 25335, ""a master thief""), Slayer(9786, 9787, 9788, 25338, ""an incredible student""), Farming(9810, 9811, 9812, 25347, ""a master farmer""), Runecrafting(9765, 9766, 9767, 25330, ""a master runecrafter""), Hunter(9948, 9949, 9950, 25339, ""a master hunter""), Construction(9789, 9790, 9791, 25331, ""a master home builder""), Summoning(12169, 12170, 12171, 25348, ""a master summoner""), Dungeoneering(18508, 18509, 18510, 19709, ""a master dungeon delver""); public final int untrimmed, trimmed, hood, master; public final String verb; Skillcapes(int untrimmed, int trimmed, int hood, int master, String verb) { this.untrimmed = untrimmed; this.trimmed = trimmed; this.hood = hood; this.verb = verb; this.master = master; } private Dialogue getGiveCapeDialogue(Player player, int npcId, boolean masterCape) { if (!player.getInventory().hasCoins(masterCape ? 120000 : 99000)) return new Dialogue(new PlayerStatement(HeadE.SAD_MILD, ""But, unfortunately, I was mistaken."")).addNext(new NPCStatement(npcId, HeadE.NO_EXPRESSION, ""Well, come back and see me when you do."")).finish(); return new Dialogue(new NPCStatement(npcId, HeadE.CHEERFUL, ordinal() == Constants.FIREMAKING ? ""I'm sure you'll look hot in that cape."" : ""Excellent! Wear that cape with pride my friend.""), () -> { player.getInventory().removeCoins(masterCape ? 120000 : 99000); if (!masterCape) player.getInventory().addItem(hood, 1); player.getInventory().addItem(masterCape ? master : player.getSkills().checkMulti99s() ? trimmed : untrimmed, 1); }); } public Dialogue getOffer99CapeDialogue(Player player, int npcId) { Dialogue start = new Dialogue() .addNPC(npcId, HeadE.CHEERFUL, ""Ah, this is a Skillcape of "" + name() + "". I have mastered the art of "" + name().toLowerCase() + "" and wear it proudly to show others."") .addPlayer(HeadE.SKEPTICAL, ""Hmm, interesting.""); if (player.getSkills().getLevelForXp(ordinal()) >= 99) start.addNPC(npcId, HeadE.NO_EXPRESSION, ""Ah, but I see you are already ""+verb+"", perhaps you have come to me to purchase a Skillcape of ""+name()+"", and thus join the elite few who have mastered this exacting skill?"") .addOptions(""Choose an option"", new Options() { @Override public void create() { option(""Yes, I'd like to buy one please."", new Dialogue() .addNPC(npcId, HeadE.NO_EXPRESSION, ""Most certainly; unfortunately being such a prestigious item, they are appropriately expensive. I'm afraid I must ask you for 99,000 gold."") .addOptions(""Choose an option:"", new Options() { @Override public void create() { option(""99,000 coins? That's much too expensive."", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""99,000 coins? That's much too expensive."") .addNPC(npcId, HeadE.CALM_TALK, ""..."") ); option(""I think I have the money right here, actually."", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""I think I have the money right here, actually."") .addNext(getGiveCapeDialogue(player, npcId, false)) ); } })); if (player.getSkills().is120(Skillcapes.this.ordinal())) option(""I've mastered this skill. Is there anything else?"", new Dialogue() .addNPC(npcId, HeadE.AMAZED, ""I've been saving this master cape for someone truly "" + verb + "". Is that really you?"") .addPlayer(HeadE.CONFUSED, ""I think so. I mean I really have mastered everything there is to know."") .addNPC(npcId, HeadE.AMAZED, ""I can see that! I would be glad to offer you this cape."") .addOption(""Buy a master cape for 120,000 coins?"", ""Yes, please."", ""No, thanks."") .addNext(getGiveCapeDialogue(player, npcId, true))); option(""Nevermind."", new Dialogue() .addNPC(npcId, HeadE.NO_EXPRESSION, ""No problem; there are many other adventurers who would love the opportunity to purchase such a prestigious item! You can find me here if you change your mind."")); } }); else start.addOptions(""Choose an option:"", new Options() { @Override public void create() { option(""Please tell me more about skillcapes."", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Please tell me more about skillcapes."") .addNPC(npcId, HeadE.CALM_TALK, ""Of course. Skillcapes are a symbol of achievement. Only people who have mastered a skill and "" + ""reached level 99 can get their hands on them and gain the benefits they carry."") ); option(""Bye."", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Bye."") .addNPC(npcId, HeadE.CALM_TALK, ""Bye."") ); } }); return start.finish(); } }" "package com.rs.game.content; public enum Statuettes { BROKEN_STATUE_HEADDRESS(14892, 5000), THIRD_AGE_CARAFE(14891, 10000), BRONZED_DRAGON_CLAW(14890, 20000), ANCIENT_PSALTERY_BRIDGE(14889, 30000), SARADOMIN_AMPHORA(14888, 40000), BANDOS_SCRIMSHAW(14887, 50000), SARADOMIN_CARVING(14886, 75000), ZAMORAK_MEDALLION(14885, 100000), ARMADYL_TOTEM(14884, 150000), GUTHIXIAN_BRAZIER(14883, 200000), RUBY_CHALICE(14882, 250000), BANDOS_STATUETTE(14881, 300000), SARADOMIN_STATUETTE(14880, 400000), ZAMORAK_STATUETTE(14879, 500000), ARMADYL_STATUETTE(14878, 750000), SEREN_STATUETTE(14877, 1000000), ANCIENT_STATUETTE(14876, 5000000); final int itemId; final int value; Statuettes(int itemId, int value) { this.itemId = itemId; this.value = value; } public int getItemId() { return itemId; } public int getNotedId() { return itemId + 17; } public int getValue() { return value; } public static int getTotalValue(Player player) { int value = 0; for(Item item : player.getInventory().getItems().array()) { if (item == null) continue; Statuettes statuette = null; for (Statuettes stat : Statuettes.values()) if (stat.getItemId() == item.getId() || stat.getNotedId() == item.getId()) statuette = stat; if (statuette != null) value += statuette.getValue()*item.getAmount(); } return value; } public static void exchangeStatuettes(Player player) { int total = getTotalValue(player); if (total > 0) player.sendOptionDialogue(""Would you like to exchange all of your statuettes for ""+Utils.formatNumber(total)+"" coins?"", ops -> { ops.add(""Yes"", () -> { for(Item item : player.getInventory().getItems().array()) { if (item == null) continue; Statuettes statuette = null; for (Statuettes stat : Statuettes.values()) if (stat.getItemId() == item.getId() || stat.getNotedId() == item.getId()) statuette = stat; if (statuette != null) { player.getInventory().deleteItem(item.getId(), item.getAmount()); player.getInventory().addCoins(statuette.getValue()*item.getAmount()); } } }); ops.add(""No""); }); else player.sendMessage(""You don't have any statuettes to hand in.""); } }" "package com.rs.game.content; @PluginEventHandler public class Toolbelt { public enum Tools { //General PICKAXE(10259, 1265), HAMMER(10260, 2347), CHISEL(10247, 1755), HATCHET(10261, 1351), KNIFE(10244, 946), TINDERBOX(10262, 590), SAW(10264, 8794), PESTLE_AND_MORTAR(10275, 233), MACHETE(10278, 975), WATCH(10280, 2575), CHART(10281, 2576), SHEARS(10245, 1735), NOOSE_WAND(10283, 10150), //Fishing CRAYFISH_CAGE(10253, 13431), FISHING_ROD(10254, 307), SMALL_FISHING_NET(10258, 303), BIG_FISHING_NET(10277, 305), FLY_FISHING_ROD(10255, 309), HARPOON(10256, 311), LOBSTER_POT(10257, 301), BARBARIAN_ROD(10279, 11323), //Crafting NEEDLE(10250, 1733), GLASSBLOWING_PIPE(10268, 1785), AMULET_MOULD(10246, 1595), BRACELET_MOULD(10267, 11065), NECKLACE_MOULD(10249, 1597), RING_MOULD(10251, 1592), TIARA_MOULD(10252, 5523), AMMO_MOULD(10265, 4), BOLT_MOULD(10266, 9434), HOLY_MOULD(10248, 1599), UNHOLY_MOULD(10270, 1594), SICKLE_MOULD(10269, 2976), CHAIN_LINK_MOULD(10282, 13153), //Farming RAKE(10273, 5341), SEED_DIBBER(10271, 5343), SPADE(10276, 952), GARDENING_TROWEL(10272, 5325), SECATEURS(10274, 5329), //Dungeoneering DUNG_PICKAXE(4293, 16295, 16297, 16299, 16301, 16303, 16305, 16307, 16309, 16311, 16313, 16315), DUNG_HATCHET(11047, 16361, 16363, 16365, 16367, 16369, 16371, 16373, 16375, 16377, 16379, 16381), DUNG_KNIFE(11051, 17754), DUNG_HAMMER(11048, 17883), DUNG_CHISEL(11053, 17444), DUNG_FLY_FISHING_ROD(11050, 17794), DUNG_NEEDLE(11052, 17446), DUNG_TINDERBOX(11049, 17678); private static final HashMap MAP = new HashMap<>(); static { for (Tools tool : Tools.values()) for (int itemId : tool.itemIds) MAP.put(itemId, tool); } public static Tools forId(int itemId) { return MAP.get(itemId); } private final int varpBit; private final int[] itemIds; public void sendUnlocked(Player player, int value) { player.getVars().setVarBit(varpBit, value); } Tools(int varpBit, int... itemIds) { this.varpBit = varpBit; this.itemIds = itemIds; } public int getValue(int itemId) { for (int i = 0;i < itemIds.length;i++) if (itemIds[i] == itemId) return i+1; return 0; } public boolean contains(int value, int itemId) { int index = value-1; if (index < 0) return false; for (int i = 0;i <= index;i++) if (itemIds[i] == itemId) return true; return false; } } public static ItemClickHandler handleToolbeltOps = new ItemClickHandler(new String[] { ""Add-to-toolbelt"", ""Carve"", ""Light"", ""Grind"", ""Powder"", ""Squeeze"", ""Craft"", ""Fletch"", ""Gut"" }, e -> { switch(e.getOption()) { case ""Add-to-toolbelt"": if (e.getPlayer().addToolbelt(e.getItem().getId())) { e.getPlayer().getInventory().deleteItem(e.getItem().getId(), 1); refreshToolbelt(e.getPlayer()); } break; case ""Light"": InventoryOptionsHandler.handleItemOnItem(e.getPlayer(), new Item(Tools.TINDERBOX.itemIds[0], 1), e.getItem(), -1, e.getSlotId()); break; case ""Grind"": case ""Powder"": case ""Squeeze"": InventoryOptionsHandler.handleItemOnItem(e.getPlayer(), new Item(Tools.PESTLE_AND_MORTAR.itemIds[0], 1), e.getItem(), -1, e.getSlotId()); break; case ""Craft"": case ""Carve"": if (InventoryOptionsHandler.handleItemOnItem(e.getPlayer(), new Item(Tools.KNIFE.itemIds[0], 1), e.getItem(), -1, e.getSlotId()) || InventoryOptionsHandler.handleItemOnItem(e.getPlayer(), new Item(Tools.CHISEL.itemIds[0], 1), e.getItem(), -1, e.getSlotId())) return; if (InventoryOptionsHandler.handleItemOnItem(e.getPlayer(), new Item(Tools.NEEDLE.itemIds[0], 1), e.getItem(), -1, e.getSlotId())) return; else if (InventoryOptionsHandler.handleItemOnItem(e.getPlayer(), new Item(Tools.GLASSBLOWING_PIPE.itemIds[0], 1), e.getItem(), -1, e.getSlotId())) return; else if (InventoryOptionsHandler.handleItemOnItem(e.getPlayer(), new Item(Tools.DUNG_NEEDLE.itemIds[0], 1), e.getItem(), -1, e.getSlotId())) return; else if (InventoryOptionsHandler.handleItemOnItem(e.getPlayer(), new Item(Tools.DUNG_KNIFE.itemIds[0], 1), e.getItem(), -1, e.getSlotId())) return; else if (InventoryOptionsHandler.handleItemOnItem(e.getPlayer(), new Item(Tools.DUNG_CHISEL.itemIds[0], 1), e.getItem(), -1, e.getSlotId())) return; break; case ""Fletch"": if (InventoryOptionsHandler.handleItemOnItem(e.getPlayer(), new Item(Tools.DUNG_KNIFE.itemIds[0], 1), e.getItem(), -1, e.getSlotId())) return; if (InventoryOptionsHandler.handleItemOnItem(e.getPlayer(), new Item(Tools.DUNG_CHISEL.itemIds[0], 1), e.getItem(), -1, e.getSlotId())) return; if (InventoryOptionsHandler.handleItemOnItem(e.getPlayer(), new Item(Tools.KNIFE.itemIds[0], 1), e.getItem(), -1, e.getSlotId())) return; else if (InventoryOptionsHandler.handleItemOnItem(e.getPlayer(), new Item(Tools.CHISEL.itemIds[0], 1), e.getItem(), -1, e.getSlotId())) return; break; case ""Gut"": InventoryOptionsHandler.handleItemOnItem(e.getPlayer(), new Item(Tools.KNIFE.itemIds[0], 1), e.getItem(), -1, e.getSlotId()); break; } }); public static void refreshToolbelt(Player player) { if (player.getToolbelt() == null) return; for (Tools tool : player.getToolbelt().keySet()) tool.sendUnlocked(player, player.getToolValue(tool)); } }" "package com.rs.game.content @ServerStartupEvent fun mapTrophyBones() { onItemAddedToBank(24444) { e -> e.player.sendMessage(""No boneception today."") e.cancel() } onItemOnObject(arrayOf(""Bank booth"", ""Bank"", ""Bank chest"", ""Bank table"", ""Counter"", ""Shantay chest"", ""Darkmeyer Treasury""), arrayOf(24444)) { e -> e.apply { if (!getObject().getDefinitions(player).containsOption(""Bank"") && !getObject().getDefinitions(player).containsOption(""Use"")) { player.sendMessage(""This isn't a proper bank."") return@onItemOnObject } player.inventory.items.set(item.slot, null) player.inventory.refresh(item.slot) val items = gsonTreeMapToItemContainer(item.getMetaDataO(""trophyBoneItems"")) if (items == null) { player.sendMessage(""Your trophy bones don't contain anything."") return@onItemOnObject } LootInterface.open((item.getMetaDataO(""trophyBoneOriginator"") ?: ""Unknown"") + ""'s Corpse"", e.player, items) } } }" "package com.rs.game.content.achievements; public enum Achievement { THE_ESSENCE_OF_MAGIC_0(0), YOINK_1(1), SILKY_SMOOTH_2(2), PREACHING_TO_THE_INFECTED_3(3), PLAYING_THE_WAITING_GAME_4(4), GONE_FISHING_5(5), BOOT_CAMP_6(6), A_CAT_IS_FOR_LIFE_7(7), CREATOR_AND_DESTROYER_8(8), RED_REVOLUTION_9(9), GOING_ON_A_SUMMER_HOLIDAY_10(10), BREAKING_AND_ENTERING_11(11), PPPPICK_UP_SOME_PRIZES_12(12), A_GIFT_FROM_KHAZARD_13(13), PARTY_POOPER_14(14), VIAL_DEEDS_15(15), STAR_SEEKER_16(16), DUKES_OF_KHAZARD_17(17), DONT_EAT_THE_POINTY_BIT_18(18), BARGAIN_HUNTER_19(19), ARE_YOU_BEING_SERVED_20(20), NO_TIME_TO_LOSE_21(21), THEYRE_LONG_AND_POINTY_22(22), A_VISIT_TO_CHARLIE_23(23), I_WONDER_WHAT_THIS_DOES_24(24), SANDYS_SECRET_GETAWAY_25(25), I_KNOW_A_SHORTCUT_26(26), VOLATILE_VALUABLES_27(27), WHAT_A_MELON_28(28), WHO_WANTS_TO_WATCH_THE_WATCHTOWER_29(29), ARRIVING_IN_STYLE_30(30), BY_THE_BUCKETLOAD_31(31), MEETING_HISTORY_AGAIN_32(32), FEARLESS_FISHING_33(33), WATER_LOGGED_34(34), GREEN_FINGERS_35(35), A_NATURAL_THIEF_36(36), THE_COAL_TRAIN_37(37), ARE_YOU_CHICKEN_38(38), BRACE_YOURSELF_39(39), SHADOW_BOXING_40(40), JUST_LIKE_THAT_41(41), NICE_VIEW_42(42), YOURE_THE_DIRTY_RASCAL_43(43), OURANIA_MANIA_44(44), NOT_ON_MY_WATCH_45(45), IT_JUST_CROAKED_46(46), GET_YOUR_STINKING_HANDS_OFF_ME_47(47), VINEDETTA_48(48), LIVING_ON_A_PRAYER_49(49), ARDOUGNE_EXPRESS_50(50), MONKEY_BUSINESS_51(51), ITS_MY_NEWT_52(52), A_TASTE_OF_THE_EXOTIC_53(53), BLOOD_BANK_WITHDRAWAL_54(54), ARTILLERY_STRIKE_55(55), CATCHING_SOME_RAYS_56(56), ABYSSAL_VALET_57(57), YOU_COULD_JUST_KNOCK_58(58), HONESTLY_ITS_NOT_A_PURSE_59(59), ALMOST_MADE_IN_ARDOUGNE_60(60), A_GRAVE_CONSIDERATION_61(61), DOOM_62(62), SHRIMPIN_AINT_EASY_63(63), MASTER_OF_ALL_I_SURVEY_64(64), RAISE_THE_ROOF_65(65), HAIL_TO_THE_DUKE_BABY_66(66), WINDOW_SHOPPING_67(67), GRINDING_MY_GEARS_68(68), SAGE_ADVICE_69(69), TINKLE_THE_IVORIES_70(70), PASSING_OUT_71(71), THE_RULES_OF_ENGAGEMENT_72(72), TAKE_YOUR_PICK_73(73), RING_MY_BELL_74(74), IN_THE_COUNTYARD_75(75), TOWER_POWER_76(76), BEWARE_OF_PIGZILLA_77(77), WAIT_THATS_NOT_A_SHEEP_78(78), THE_FRUIT_OF_THE_SEA_79(79), CLAY_MORE_80(80), JUST_ADD_WATER_81(81), VERY_POTTER_82(82), HOTPOT_83(83), AND_IT_WAS_THIS_BIG_84(84), DRAAAAAIIIIIINS_85(85), BELTER_OF_A_SMELTER_86(86), COME_IN_HERE_AND_SAY_THAT_87(87), SLIPPERY_WHEN_WET_88(88), KLEPTOLDMANIA_89(89), EYE_ON_THE_PRIZE_90(90), I_CANT_HEAR_DEAD_PEOPLE_91(91), NOWT_TOOL_LOOK_AT_92(92), YOU_DOITY_RAT_93(93), IT_WAS_DEAD_ALREADY_94(94), CAMPING_TRIP_95(95), RATATOUILLE_96(96), WHAT_IS_THIS_PLACE_97(97), MONEY_DOWN_THE_DRAYN_98(98), ARTISAN_CRAFTING_99(99), BLESS_IS_MORE_100(100), MORGAN_THE_MERRIER_101(101), IRON_ON_102(102), EVERYBODY_LOVES_COAL_103(103), A_MEAL_FIT_FOR_A_DUKE_104(104), LOVELY_WITH_A_SQUEEZE_OF_LEMON_105(105), WEEPING_WILLOW_106(106), ALWAYS_BE_PREPARED_107(107), STEEL_JUSTICE_108(108), EASE_OF_ACCESS_109(109), WILLOW_THE_WISP_OF_SMOKE_110(110), WHERES_THE_BEEF_111(111), HI_HO_SILVER_112(112), ONE_DAY_YOU_SHALL_BE_A_FORK_113(113), MADE_TO_ORDER_114(114), AMULET_OF_WEEDSPEAK_115(115), THE_GOOD_STUFF_116(116), SIR_MITT_117(117), FAMILY_VALUES_118(118), SNIFFING_OUT_THE_MOLE_119(119), CHINCHOMPA_POWERED_120(120), FILL_YER_BUCKET_121(121), ELEMENTARY_MEDICINE_122(122), ITS_NOT_WABBIT_SEASON_123(123), STAND_AND_DELIVER_124(124), MAKING_MY_MIND_UP_125(125), GOING_ALONG_WITH_THE_FRO_126(126), MUDSKIP_THE_LIGHT_FANTASTIC_127(127), DISARM_AND_EMBARK_128(128), CHAIN_STORE_129(129), FRUIT_OF_THE_LOOM_130(130), IS_IT_SO_HARD_TO_WALK_ROUND_131(131), THESE_ARENT_THE_COINS_YOURE_LOOKING_FOR_132(132), CLIMBING_THE_WALLS_133(133), ITS_NOTHING_PERSONAL_134(134), ICE_THE_ICY_135(135), BLINDED_WITH_SCIENCE_136(136), THEY_HAVE_FAMILIES_TO_FEED_137(137), STOIC_SWEETCORN_GUARDIAN_138(138), DO_THEY_COME_IN_OTHER_COLOURS_139(139), FUN_FOR_THE_WHOLE_FAMILY_140(140), LOOK_SPIFFY_FOR_TIFFY_141(141), IT_MATCHES_MY_EYES_142(142), CHILD_OF_SARADOMIN_143(143), MASS_PRODUCTION_144(144), IT_SPOILED_MY_VIEW_145(145), THE_STONEMASONS_146(146), I_HEARD_YOU_LIKE_MUDSKIPS_147(147), THE_MOGRE_MASH_148(148), WHY_OH_WYVERN_149(149), BANNED_FOR_LIFE_150(150), A_KNIGHT_IN_THE_DARKNESS_151(151), BRING_THE_ANTIPOISONS_152(152), WHY_WONT_YOU_DIE_153(153), KING_CONIFER_154(154), ASSAULTED_GOODIES_155(155), OXYMORON_INCARNATE_156(156), WHY_DID_THE_LOBSTER_BLUSH_157(157), HUNTING_THE_HUNTER_158(158), PEER_OFF_THE_PIER_159(159), A_FAMILIAR_FEELING_160(160), ENDANGERED_SPECIES_161(161), FREMENNIK_HISTORY_101_162(162), COOL_STORY_BRO_163(163), WHOS_A_GOOD_BOY_164(164), ONLY_TAKES_A_LITTLE_VIAL_165(165), YOU_KNOW_YOU_WANT_IT_166(166), FAIRY_MOUNTAINEERING_167(167), YOU_REALLY_DONT_NEED_ANY_MORE_SHOES_168(168), BIG_GAME_HUNTER_169(169), YAK_ATTACK_170(170), FREMMENTAL_171(171), GRAND_THEFT_FISH_172(172), DEFEATING_DEADLY_DAGANNOTHS_173(173), DRESS_TO_IMPRESS_174(174), THE_GRACEFUL_BARBARIAN_175(175), RUNES_ON_THE_MOON_176(176), PYRE_AT_WILL_177(177), FISH_FINGERS_178(178), EASY_AS_PIE_179(179), HOW_TO_MAIM_YOUR_DRAGON_180(180), A_PERIODIC_TABLE_181(181), FIVE_A_DAY_182(182), IM_LICHEN_THIS_183(183), GOLDEN_SHORES_184(184), PUT_TO_PORT_IN_PORT_SARIM_185(185), AVAST_ARDOUGNE_186(186), SHOW_THAT_YOU_CAIRN_187(187), FRUITY_CATCH_188(188), BEACHCOMBER_189(189), TZHAAR_WARS_190(190), ITS_A_JUNGLE_OGRE_191(191), JUST_THE_TICKET_192(192), BACK_CRANDOOR_193(193), DUNGEONS_AND_DRAGONS_194(194), HORSELESS_CARRIAGE_195(195), THEY_LIKE_ME_THEY_REALLY_LIKE_ME_196(196), ARACHNOPHAGIA_197(197), ROMANCING_THE_STONE_198(198), IM_A_LUMBERJACK_AND_IM_OKAY_199(199), I_SLEEP_ALL_NIGHT_AND_I_WORK_ALL_DAY_200(200), TO_CATCH_A_KARAMBWAN_201(201), THATS_NOT_A_KNIFE_202(202), FALLING_WITH_STYLE_203(203), SCOURGE_OF_SCURVY_204(204), HUNTERS_OF_THE_HORNED_GRAAHK_205(205), THE_ROOTS_OF_ALL_EVIL_206(206), HOTFOOTING_IT_207(207), STAIRWAY_TO_HAVEN_208(208), THANK_YOU_MADAM_209(209), SHIPPING_OUT_FROM_THE_SHIPYARD_210(210), FLAWLESS_VICTORY_211(211), PLAY_DEAD_DOGGY_212(212), ID_BE_KHARAZI_TO_EAT_THIS_213(213), AT_ONE_WITH_NATURE_214(214), DROP_IT_LIKE_ITS_HOT_215(215), DEADWING_216(216), QUICK_AS_A_SHOT_217(217), A_PALM_FOR_EACH_FINGER_218(218), YES_MY_MASTER_219(219), CAN_OPENER_220(220), REFLAX_ACTIONS_221(221), WHY_222(222), JUTE_ALORS_223(223), STIR_GALAHAD_224(224), LA_MORTE_DARTHUR_225(225), ANOTHER_STRING_TO_YOUR_BOW_226(226), BUNCH_OF_FLOURS_227(227), HAPPY_HOUR_228(228), SINCLAIR_SWIRLING_229(229), GRAND_CANDLE_230(230), A_SEERING_LIGHT_231(231), MACK_ROLLED_232(232), FLEEING_THE_SCENE_233(233), ITS_A_SLIGHTLY_MAGICAL_STICK_234(234), KING_COAL_235(235), MASTERING_THE_ELEMENTS_236(236), ITS_ONLY_A_MODEL_237(237), ARCH_ARCHER_238(238), WHAT_NO_CUDDLY_TOY_239(239), I_CAN_SEER_MY_HOUSE_FROM_HERE_240(240), FAMILIAR_FIRE_FAMILIARITY_241(241), AT_LEAST_IT_DOESNT_NEED_WALKING_242(242), ALL_YOUR_BASS_243(243), SNIPER_TRAINING_244(244), AT_HOME_ON_THE_RANGE_245(245), SEE_YEW_AT_FIVE_246(246), THE_SHORT_OF_IT_247(247), PRAYER_OF_ATTORNEY_248(248), BEWARE_OF_THE_DOG_249(249), TWISTED_FIRE_STARTER_250(250), ALCHAHOLIC_251(251), ISLAND_HOPPER_252(252), GONNA_NEED_A_BIGGER_BOAT_253(253), GONNA_NEED_A_BIGGER_RANGE_254(254), WATER_PALAVER_255(255), STRIKE_A_POSE_256(256), ESSENTIAL_FACILITATOR_257(257), DOING_THE_IRONING_258(258), PLANK_YOU_VERY_MUCH_259(259), MAKING_LEARNING_FUN_260(260), JUMPINGOFF_POINT_261(261), LUMBERING_AROUND_262(262), READ_ALL_ABOUT_IT_263(263), DOG_AND_BONE_264(264), POT_STOP_265(265), ON_THE_RAGGED_EDGE_266(266), RELOCATION_RELOCATION_RELOCATION_267(267), IT_BELONGS_IN_A_MUSEUM_268(268), JOURNEY_TO_THE_CENTRE_OF_THE_EARTH_ALTAR_269(269), JACKANORY_270(270), LIMEY_271(271), SHERPAS_DELIGHT_272(272), KING_OF_THE_CASTLE_273(273), STICK_THE_KNIFE_IN_274(274), DOUBLESTRENGTH_WEAKSAUCE_275(275), CHAMPION_276(276), WHAT_LIES_BELOW_277(277), WITH_A_TENFOOT_POLE_278(278), CANT_MAKE_AN_OMELETTE_279(279), POINT_OF_ENTREE_280(280), UNLOCKING_YOUR_EMOTIONS_281(281), A_LICK_OF_PAINT_282(282), FOR_FAST_TRANSACTIONS_283(283), YOU_WOULDNT_LIKE_ME_WHEN_IM_ANGRY_284(284), RETURN_TO_SENNTISTEN_285(285), PROMISED_THE_EARTH_286(286), ROYALE_WITH_THIEVE_287(287), LIKE_A_VARROCKET_288(288), CHALLENGE_VANNAKA_289(289), FLATPACK_BACKPACK_290(290), MASTER_SCRUMPER_291(291), ENGAGE_292(292), FASTER_PUSSYCAT_KILL_KILL_293(293), DIAL_V_FOR_VARROCK_294(294), THE_BODY_SHOP_295(295), BURNING_BUSH_296(296), BUT_IT_WONT_WARP_YOU_ANYWHERE_297(297), LIGHTEN_UP_298(298), PUT_YOUR_SMITHING_HAT_ON_299(299), KUDOS_ON_THE_KUDOS_300(300), WHO_ATE_ALL_THE_PIE_301(301), BATTLE_OF_THE_ELEMENTS_302(302), INTERSCEPTRE_303(303), CHANGING_ROOMS_304(304), KEEPING_TABS_ON_VARROCK_305(305), HANDMEDOWNS_306(306), WAKAWAKAWAKA_307(307), LIVING_ON_THE_EDGE_308(308), WHEN_THIS_CAVERNS_ROCKIN_309(309), YOUD_BEST_COME_ACOOKIN_310(310), CONCENTRATION_IS_KEY_311(311), I_SWEAR_I_HEARD_IT_SCREAM_312(312), IVE_CHANGED_MY_MIND_313(313), A_STRING_AND_A_FLARE_314(314), ALTARED_STATE_315(315), JAWS_BREAKER_316(316), LIMBER_LUMBER_JUMPER_317(317), ASTRONOMICAL_318(318), FIRST_STRYKE_319(319), LEAP_OF_FAITH_320(320), NO_SMOKE_WITHOUT_PYRE_321(321), THIS_HASTA_WORK_322(322), POTTING_WITH_OTTO_323(323), AT_ONE_PLUS_FIFTYFIVE_WITH_NATURE_324(324), THE_POWER_OF_LAVA_325(325), BOXING_CLEVER_326(326), ITS_A_SNAP_327(327), CRUNCHY_COATING_328(328), WALKIES_329(329), TREAD_CAREFULLY_330(330), TEN_IN_A_ROW_331(331), ITS_A_TRAP_NO_WAIT_ITS_A_PIE_332(332), MAKE_A_BOLT_FOR_IT_333(333), THE_LONG_OF_IT_334(334), PLENTYPOTIONENTIARY_335(335), MOON_RAKER_336(336), STICK_A_BORK_IN_HIM_HES_DONE_337(337), NOMADNESS_338(338), DOUBLE_JOINTED_339(339), IT_ALL_ADZE_UP_340(340), MIND_YOUR_BACK_341(341), RED_RED_PIES_OF_SUMMER_342(342), SPLITTING_HEADACHE_343(343), A_BOLT_FROM_THE_BLUE_344(344), A_TON_OF_EARTH_345(345), THE_BLOOD_PACT_346(346), THE_RESTLESS_GHOST_347(347), COOKS_ASSISTANT_348(348), RUNE_MYSTERIES_349(349), MYTHS_OF_THE_WHITE_LANDS_350(350), A_BODY_IN_THE_SEWERS_351(351), BUILDING_UP_STRENGTH_352(352), HAVE_YOUR_CAKE_AND_EAT_IT_353(353), BLAST_AND_HELLFIRE_354(354), GODS_GIVE_ME_STRENGTH_355(355), NOT_WAVING_BUT_DROWNING_356(356), ARE_YEW_AS_FIRED_UP_AS_I_AM_357(357), HEAVY_METAL_358(358), BAR_ONE_359(359), CUTTING_EDGE_TECHNOLOGY_360(360), ARMED_AND_DANGEROUS_361(361), A_WORLD_IN_MICROCOSM_362(362), ON_THE_RUN_363(363), ARENT_THEY_SUPPOSED_TO_BE_TWINS_365(365), SHELLFISH_ROASTING_ON_AN_OPEN_FIRE_366(366), HANDY_DANDY_367(367), ON_YOUR_WAY_368(368), YOU_CAN_BANK_ON_US_369(369), HANG_ON_TO_SOMETHING_370(370), JUST_CANT_GET_THE_STAFF_371(371), THERES_NO_PLACE_LIKE_HOME_372(372), COME_AND_HAVE_A_GO_373(373), REACH_OUT_AND_TOUCH_SOMEONE_374(374), THREE_ROUNDS_RAPID_MEN_375(375), DEATH_FROM_ABOVE_376(376), FLOUR_POWER_377(377), A_LABOUR_OF_LOAF_378(378), OM_NOM_NOM_NOM_379(379), ON_THE_LEVEL_380(380), SO_THATS_WHAT_ESS_STANDS_FOR_381(381), AIR_CRAFT_382(382), GREASING_THE_WHEELS_OF_COMMERCE_383(383), MUST_BE_FUNNY_IN_A_RICH_MANS_WORLD_384(384), PUT_YOUR_HANDS_TOGETHER_FOR_385(385), PRAYER_POINT_POWER_387(387), NOT_WHAT_WE_MEAN_BY_IRONY_388(388), ALLS_FERROUS_IN_LOVE_AND_WAR_389(389), AM_I_A_BLADEMASTER_YET_390(390), FIRST_BLOOD_391(391), TEMPER_TEMPER_392(392), STEEL_YOURSELF_FOR_COMBAT_393(393), AMMO_AMMO_AMMO_394(394), TAKE_A_BOW_395(395), DONT_BURY_THIS_ONE_396(396), MACE_INVADERS_397(397), CAPITAL_PROTECTION_WHAT_398(398), HACK_AND_SMASH_399(399), MADE_FOR_WALKING_400(400), DID_ANYONE_BRING_ANY_TOAST_401(401), ITS_NOT_A_RED_ONE_402(402), NOT_SO_CONFUSING_AFTER_ALL_403(403), ABSOLUTELY_ENCHANTING_404(404), HEART_OF_OAK_405(405), GET_THE_POINT_406(406), BERRY_TASTY_407(407), DISHWATER_408(408), CANT_TOUCH_THIS_409(409), SCORE_THREE_SCORE_410(410), FLEDGELING_ADVENTURER_411(411), ADVENTURERS_LOG_412(412), LOGARHYTHM_413(413), BOVINE_INTERVENTION_414(414), TAN_YOUR_HIDE_415(415), HANDICRAFTS_416(416), AXELL_GREASE_417(417), URNING_A_LIVING_418(418), TALK_TO_EXPLORER_JACK_419(419), GRAB_THE_CASH_420(420), INTERVENTION_421(421), ESCORT_DUTY_422(422), SKILLS_423(423), TOOLING_UP_424(424), HOW_TO_TRAIN_AND_LEVEL_425(425), COMMERCE_BREAK_426(426), REST_UP_427(427), TOTALLY_LIVID_428(428), CASTLES_IN_THE_SKY_429(429), A_WIZARD_DID_IT_430(430), FACELESS_AND_READY_431(431), CITADELEMENTARY_432(432), SHEAR_CONVENIENCE_433(433), WATCHTOWER_434(434), COLD_WAR_435(435), THE_HAND_IN_THE_SAND_436(436), HUNT_FOR_RED_RAKTUBER_437(437), TEMPLE_OF_IKOV_438(438), TOWER_OF_LIFE_439(439), DRUIDIC_RITUAL_440(440), DEATH_PLATEAU_441(441), WOLF_WHISTLE_442(442), BUYERS_AND_CELLARS_443(443), MURDER_MYSTERY_444(444), TROLL_STRONGHOLD_445(445), TROLL_ROMANCE_446(446), MY_ARMS_BIG_ADVENTURE_447(447), HEROES_QUEST_448(448), EADGARS_RUSE_449(449), GRIM_TALES_450(450), LET_THEM_EAT_PIE_451(451), THE_GOLEM_452(452), THE_FEUD_453(453), SPIRITS_OF_THE_ELID_454(454), TOURIST_TRAP_455(455), MISSING_MY_MUMMY_456(456), SMOKING_KILLS_457(457), SHADOW_OF_THE_STORM_458(458), ONE_PIERCING_NOTE_459(459), CHOSEN_COMMANDER_460(460), CATAPULT_CONSTRUCTION_461(461), FISHING_CONTEST_462(462), SLUG_MENACE_463(463), BIG_CHOMPY_BIRD_HUNTING_464(464), MOUNTAIN_DAUGHTER_465(465), HORROR_FROM_THE_DEEP_466(466), FREMENNIK_TRIALS_467(467), FREMENNIK_ISLES_468(468), ROYAL_TROUBLE_469(469), LUNAR_DIPLOMACY_470(470), THE_GRAND_TREE_471(471), PATH_OF_GLOUPHRIE_472(472), EYES_OF_GLOUPHRIE_473(473), TRIBAL_TOTEM_474(474), TAI_BWO_WANNAI_TRIO_475(475), SHILO_VILLAGE_476(476), ONE_SMALL_FAVOUR_477(477), THE_GIANT_DWARF_478(478), FORGETTABLE_TALE_OF_A_DRUNKEN_DWARF_479(479), THE_LOST_TRIBE_480(480), ANIMAL_MAGNETISM_481(481), DEATH_TO_THE_DORGESHUUN_482(482), LAND_OF_THE_GOBLINS_483(483), RUNE_MECHANICS_484(484), LOST_CITY_485(485), HAUNTED_MINE_486(486), GHOSTS_AHOY_487(487), IN_SEARCH_OF_THE_MYREQUE_488(488), IN_AID_OF_THE_MYREQUE_489(489), DARKNESS_OF_HALLOWVALE_490(490), LEGACY_OF_SEERGAZE_491(491), CABIN_FEVER_492(492), CREATURE_OF_FENKENSTRAIN_493(493), SHADES_OF_MORTTON_494(494), THE_GREAT_BRAIN_ROBBERY_495(495), RUM_DEAL_496(496), SWAN_SONG_497(497), ELEMENTAL_WORKSHOP_I_498(498), ELEMENTAL_WORKSHOP_II_499(499), ELEMENTAL_WORKSHOP_III_500(500), ELEMENTAL_WORKSHOP_IV_501(501), GUNNARS_GROUND_502(502), THE_DIG_SITE_503(503), GARDEN_OF_TRANQUILITY_504(504), SPIRIT_OF_SUMMER_505(505), ENLIGHTENED_JOURNEY_506(506), FAMILY_CREST_507(507), CURSE_OF_ARRAV_508(508), PERILS_OF_ICE_MOUNTAIN_509(509), A_SOULS_BANE_510(510), ANOTHER_SLICE_OF_HAM_511(511), HOLY_GRAIL_512(512), QUIET_BEFORE_THE_SWARM_513(513), TOKTZKETDILL_514(514), UNDERGROUND_PASS_515(515), TALE_OF_THE_MUSPAH_516(516), ENAKHRAS_LAMENT_517(517), BLACK_KNIGHTS_FORTRESS_518(518), PRIEST_IN_PERIL_519(519), WHAT_LIES_BELOW_520(520), RECIPE_FOR_DISASTER_PART_1_521(521), OLAFS_QUEST_522(522), SCORPION_CATCHER_523(523), SUMMERS_END_524(524), EAGLES_PEAK_525(525), GLORIOUS_MEMORIES_526(526), SEA_SLUG_527(527), ALL_FIRED_UP_528(528), FUR_N_SEEK_529(529), TEARS_OF_GUTHIX_530(530), RENDEZVOUS_531(531), BRING_HIM_DOWN_532(532), WERE_DONE_HERE_533(533), REPORTING_IN_534(534), FIRE_IN_THE_TROLL_535(535), MISSION_ACCOMPLISHED_536(536), PROBLEM_OFFICER_537(537), TAKE_YOUR_PICK_538(538), FINE_FINE_AXE_539(539), ARE_YOU_IN_RUBBLE_540(540), JACK_OF_SOME_TRADES_541(541), ARM_THE_MILITIA_542(542), A_FARMER_IN_THE_MAKING_543(543), DIBS_ON_THE_FIRST_BATCH_544(544), THE_CIRCLE_OF_LIFE_545(545), TWO_IN_THE_BUSH_546(546), FISHERMANS_FRIENDS_547(547), FEED_THE_REFUGEES_548(548), A_POCKET_OR_TWO_549(549), THE_RED_MIST_DESCENDS_550(550), THESE_ARENT_OVEN_GLOVES_551(551), A_NEW_THREAT_552(552), NO_STONE_UNTURNED_553(553), MISSION_COMPLETE_554(554), ALL_FELL_DOWN_555(555), POCKET_WOLF_556(556), HEEL_BOY_557(557), LIKE_A_HOUSE_ON_FIRE_559(559), ONE_THING_AFTER_ANOTHER_560(560), MY_AXE_IS_MY_BUDDY_561(561), ON_THE_STRAIGHT_AND_ARROW_562(562), SUPER_TUBER_563(563), BOWS_ARE_FOR_VIOLENCE_564(564), OUT_OF_WATER_565(565), GUAM_FLY_WITH_ME_566(566), A_FRESH_BATCH_567(567), BOTTOMS_UP_568(568), HAMMER_THE_ANVIL_569(569), MIND_OUT_OF_MATTER_570(570), WICKED_571(571), WALKING_IN_THE_AIR_ALTAR_572(572), THERES_NO_PLACE_LIKE_BURTHORPE_573(573), LAPPING_IT_UP_574(574), ARISE_HERO_575(575), MAKE_THEM_FEEL_SPECIAL_576(576), HEIMWARD_BOUND_577(577), PARTY_ON_DUDES_578(578), RAIDERS_OF_THE_FROST_DARK_579(579), UNREAL_ESTATE_MAN_580(580), ROOM_TO_MANOEUVRE_581(581), ABOUT_TO_DROP_THE_HAMMER_582(582), BANK_ON_IT_583(583), STOP_THEM_IN_THEIR_TRACKS_584(584), MACHINERY_OF_WAR_585(585), HELLS_KITCHEN_586(586), THE_WAR_PROFITEERS_587(587), THE_CORRUPTED_DEPTHS_588(588), THE_SPIRIT_MASTERS_589(589), WATERY_GRAVE_590(590), THE_HAND_OF_GUTHIX_591(591), RETURN_TO_THE_FRONT_592(592), TROLL_WARZONE_593(593), LAPPING_IT_UP_594(594), AGILITREE_595(595), DART_TIME_596(596), HOWLED_ON_TIGHT_597(597), PYRAMEDAL_598(598), MOTHERLAND_ON_YOUR_FEET_599(599), BARBARELY_A_CHALLENGE_600(600), A_POCKET_OR_TWO_601(601), HAVE_YOUR_VEGGIES_602(602), FARMER_PICKING_603(603), KEEP_YOUR_HAMS_OFF_ME_604(604), SMOOTH_AS_SILK_605(605), STOP_WINEING_606(606), SPRING_TIME_607(607), YOU_DONT_LOOK_SO_TOUGH_NOW_608(608), SEEDING_FROM_THE_RICH_GIVING_TO_THE_POOR_609(609), THE_PLUNDER_MUST_GO_ON_610(610), FURRRRR_611(611), DEEP_POCKETS_612(612), STEALING_FROM_A_MASTER_613(613), FIGHT_THE_SYSTEM_614(614), SOMETHING_FISHY_615(615), BETRAYING_YOUR_HERITAGE_616(616), RIGHT_FROM_UNDER_HIS_BEARD_617(617), BAKERS_DELIGHT_618(618), SUPER_CLAY_LAND_619(619), THE_ART_OF_THIEVING_620(620), TEA_OCLOCK_621(621), FROM_TINY_ACORNS_622(622), LOST_HER_MARBLES_623(623), LIGHTNING_FINGERS_624(624), ON_THE_STRAIGHT_AN_ARROW_625(625), BOWS_ARE_FOR_VIOLENCE_626(626), AT_CROSS_PURPOSES_627(627), BOLTED_ON_628(628), ITS_A_LONG_SHOT_629(629), ON_YOUR_METTLE_630(630), FLETCHING_IN_THE_DARK_631(631), RECURVE_OAK_632(632), FROM_MIGHTY_OAKS_633(633), NERVES_OF_STEEL_ARROWHEADS_OF_STEEL_634(634), SHORTWILLOW_635(635), WILLIOWM_TELL_636(636), STRIKE_WHILE_THE_IRON_IS_POINTY_637(637), LONGWILLOW_638(638), ADVANCED_MUNITIONS_MYTH_OR_REAL_639(639), LOCKED_AND_LOADED_OR_LOCKED_AND_BOLTED_640(640), HIGHLY_POLISHED_641(641), FLIGHTS_OF_FANCINESS_642(642), TIN_MAN_643(643), LETS_MAKE_TRACKS_644(644), IRON_MAN_645(645), DEEP_ECHOING_BANGS_646(646), SMELTING_STEEL_648(648), THE_STUFF_MEN_ARE_MADE_OF_649(649), MITHRIL_SMITHRIL_650(650), FULL_SMELTING_JACKET_651(651), HAMMERED_ONE_TOO_MANY_TIMES_652(652), THIN_METAL_CONTAINER_653(653), SIGHT_SERUM_654(654), POISON_SCHMOISON_655(655), THE_HANGOVER_CURE_656(656), ROID_RAGE_657(657), BACK_TO_YOUR_OLD_SELF_658(658), NATURES_SCALES_659(659), SPICED_POTIONS_660(660), GIVES_YOU_WINGS_661(661), MIXED_LIKE_A_TANK_662(662), TROUBLE_STIRRING_IN_THE_DEPTHS_663(663), I_LIKE_TO_MOVE_IT_MOVE_IT_664(664), THE_GREENMANS_POTION_665(665), RAISE_YOUR_GLASSES_FOR_THE_GODS_666(666), CREATIONISTS_ELIXIR_667(667), CRAFTSMANS_FRIEND_668(668), TRUE_HIT_669(669), EFFECTIVE_STORAGE_670(670), HOWLING_BACKPACK_671(671), WALKING_DREAD_672(672), CLICKEDY_CLICK_673(673), STICKY_SPIKE_674(674), SIDESTEPPING_ROCKS_675(675), FEEDING_ON_THE_SOUL_676(676), SANDY_SLUG_677(677), SPIRIT_STING_678(678), THEY_GROW_SO_FAST_679(679), MENTALLY_HOT_680(680), LOOK_WHO_HAD_A_SHOWER_681(681), BUGGING_YOUR_SOUL_682(682), WHATS_THAT_SMELL_FOLLOWING_ME_683(683), AND_THEN_THERE_WAS_NOTHING_684(684), COUNT_BATULA_685(685), BADGER_BADGER_MUSHROOM_686(686), TREE_EATER_687(687), VOIDED_WARRANTY_688(688), MY_LITTLE_PONYTAUR_689(689), BUG_LEATHER_THE_FINEST_690(690), BLUE_PIRATES_691(691), I_KNEW_VEGGIES_WERENT_ANY_GOOD_692(692), MIXANDMATCH_693(693), IRON_HIDE_694(694), SOUL_BOMB_695(695), CLAY_MORE_696(696), BRONZE_DUST_697(697), THIS_ONES_MINE_698(698), DIGGING_DEEP_701(701), ITS_A_BIT_OF_IRONY_702(702), THIS_ONES_MINE_TOO_703(703), THE_SILVER_AGE_704(704), SENT_TO_THE_SLAG_HEAP_706(706), IN_THE_FACE_707(707), SOFT_AND_HEAVY_708(708), SWIFT_PICK_709(709), PRIZED_FOR_THEIR_RARITY_710(710), ARENT_THEY_SUPPOSED_TO_BE_TWINS_711(711), DID_ANYONE_BRING_ANY_TOAST_712(712), FISH_FLINGERS_713(713), SHRIMPIN_AINT_EASY_714(714), SCALES_715(715), KARAMBA_716(716), HERRING_AID_717(717), SUBTERRANEAN_PONDS_718(718), BORN_TO_BE_IN_PIZZA_719(719), FISH_GUTS_720(720), SEA_MACARONI_721(721), BIG_CATCHES_722(722), TROUTZERS_723(723), BIG_CATCH_724(724), THE_MOST_DANGEROUS_FISH_IN_THE_RIVER_725(725), SLUGGISH_SWIMMER_726(726), SALMON_HELAS_727(727), CAN_YOU_CARRY_A_TUNA_728(728), TOO_MANY_TUNA_729(729), DOUBLE_FISH_ALL_THE_WAY_730(730), THEY_LIKE_THE_DARK_731(731), MR_PINCER_732(732), FISHBONES_733(733), LIKE_A_BASS_734(734), THATS_BARBARIC_735(735), COWMOUFLAGE_736(736), MR_POTTER_737(737), ERNIES_CONTAINERS_738(738), GRANNYS_HEIRLOOM_740(740), UNDERWATER_PRESSURE_741(741), ASH_TRAY_742(742), GODLY_JEWELLERY_743(743), HUNDRED_ANCIENT_BARK_744(744), HAMMERED_IT_TOO_HARD_745(745), CHECK_MA_BLING_746(746), PLATEFUL_OF_NUMBERS_747(747), GOT_CEREAL_748(748), LIGHT_FOOD_ONLY_749(749), WATER_MAKES_FISH_GO_SOFT_750(750), YOU_WOOD_WOULDNT_YOU_751(751), SYMBOLIC_FAITH_752(752), DONT_PICK_ON_ME_753(753), THE_IRONY_754(754), GREEN_HOUSE_755(755), FASHION_BUSINESS_756(756), DEEPBLUE_GOLD_757(757), EVERY_GIRL_WANTS_ONE_759(759), BAD_LUCK_CHARM_760(760), THE_COLOUR_OF_GREED_761(761), TOUGH_COOKIE_762(762), DUST_COLLECTOR_763(763), SOME_PREFER_SPIKY_HAIR_764(764), FIRE_RED_765(765), WITHSTANDS_OVER_9000_DEGREES_766(766), FOOD_SCRAPS_767(767), SCALE_COLLECTOR_769(769), WHAT_A_STUD_770(770), WOMENS_BEST_FRIENDS_771(771), WONDER_IF_IT_FITS_A_WHOLE_TREE_772(772), STEELCOATED_LEGS_773(773), SLIDING_AROUND_774(774), SAFE_GATE_KEEPER_775(775), MAD_CRIB_776(776), FORMED_IN_TRIPLICATE_777(777), QUAD_ADDAGE_778(778), V_ROOM_779(779), CAN_WE_HEX_IT_YES_WE_CAN_780(780), A_NOVEL_CON_SEPT_781(781), PLENTY_OF_ROOM_782(782), LOTS_OF_ROOM_783(783), V_ROOM_V_ROOM_784(784), SO_MUCH_ROOM_785(785), DOZEN_THAT_SEEM_LIKE_ENOUGH_787(787), UNLUCKY_FOR_SOME_788(788), ZOUNDS_ROOM_789(789), A_FARMERS_LIFE_790(790), FEELING_JUST_VINE_791(791), ITS_NOT_A_FOX_GLOVE_792(792), NO_NEED_TO_CRY_ABOUT_IT_793(793), AN_OFFERING_TO_BRASSICA_PRIME_794(794), IF_YOU_PLANT_IT_THEY_WILL_GUAM_795(795), ITS_A_BERRY_AND_ITS_RED_796(796), BETTER_KNOWN_THAN_LESSWILDCRESS_797(797), GOING_ON_THE_LAMB_798(798), CHUNKIEST_SALSA_EVER_799(799), TILLING_MARREN_GROUND_801(801), ITS_GOING_TO_BE_OAK_802(802), COME_MISTER_TARROMIN_803(803), AND_BY_CORN_I_MEAN_TOTALLY_SWEET_804(804), IS_THERE_A_FAIRY_RING_CODE_FOR_HARRA_LAND_805(805), KEEP_THE_DOCTOR_AWAY_806(806), FROM_FALLOW_TO_WILLOW_807(807), CREAM_OF_THE_CROP_808(808), A_PIRATES_FAVOURITE_HERB_809(809), HOW_DO_YOU_STOP_SPELLING_BANANANANANA_810(810), WHY_DID_THE_GHOST_FARMER_FLUSH_811(811), SHOULDNT_HAVE_PARKED_YOUR_FLAX_HERE_ANYWAY_812(812), ORANGE_YOU_GLAD_YOURE_FARMING_813(813), FAVOURING_CURRY_814(814), IRIT_INNIT_815(815), DANCING_AROUND_THE_MAPLE_816(816), BLAZING_A_TURAEL_817(817), I_MAZCHNA_FOR_A_TASK_818(818), MAINTAINING_THAT_EDGE_819(819), CHAELDAR_TO_BE_DIFFERENT_820(820), THIS_IS_SOUL_WARS_821(821), SUMONA_DO_AVE_EM_822(822), THIN_AS_AIR_823(823), SNOW_WHITE_825(825), HUNTING_FOR_GOLD_828(828), I_AM_WEASEL_829(829), THIS_COPPER_IS_MINE_830(830), BIG_GAME_HUNTING_831(831), WHY_SO_TWITCHY_832(832), DEVILS_SPAWN_833(833), HARVESTING_RUBIES_834(834), WAGGA_WAGGA_835(835), COOL_BUG_BRO_837(837), MINIATURE_DEVILS_838(838), THE_THIRD_KNIGHTS_ORDER_840(840), COWARD_841(841), BLACK_MAGIC_843(843), PENGUINS_844(844), I_WONDER_IF_ITLL_SPROUT_845(845), EVERY_DAY_IM_GRINDIN_846(846), HOMEGROWN_PRIEST_847(847), MONKS_DEVOTION_848(848), SCORCHING_REJUVENATION_849(849), THE_BIGGER_THE_BETTER_850(850), FIRE_BONES_851(851), SO_FRESH_ITLL_BLOW_YOUR_MIND_852(852), GOES_WELL_WITH_ANY_DISH_853(853), GNOME_CUISINE_854(854), CANT_GET_ANY_FISHIER_855(855), BLOODSHOT_EYES_856(856), WATCH_OUT_FOR_THE_FLU_857(857), BREWED_TO_PERFECTION_858(858), NO_MORE_LEAPING_FOR_YOU_859(859), CARNIVOROUS_REX_860(860), TRUE_NORSE_FOOD_861(861), ANTI_CAVALRY_FOOD_862(862), SERVES_314_PEOPLE_863(863), SWAMPS_FINEST_MEATS_864(864), UGLY_AND_PINK_865(865), ONE_FOR_THE_TROOPS_866(866), COVERED_IN_SLIME_867(867), MUD_FIGHT_868(868), HUNDRED_DOLPHINFREE_869(869), THE_PIE_OF_TEMPTATION_870(870), MASTER_CHEF_871(871), PUTTING_A_FARM_IN_THE_OVEN_872(872), MAMMA_MIA_873(873), MASTER_BARTENDER_874(874), THATS_A_MORAY_875(875), SLIPPERY_SOAP_876(876), MELTS_LIKE_A_CHARM_877(877), A_SHRIMPS_BIG_BROTHER_878(878), ITS_YOUR_BIRTHDAY_879(879), HOT_HOT_HOT_880(880), GNOMISH_TAKEAWAY_881(881), DEEP_IN_TUNE_882(882), DONT_BRING_A_PAN_TO_A_SWORD_FIGHT_883(883), ADDING_MEAT_TO_THE_BONES_884(884), FISHERMANS_FRIEND_885(885), BERRY_TASTY_886(886), ARACHNOPHAGIA_887(887), ITS_NOT_A_RED_ONE_888(888), AIR_CRAFT_889(889), MIND_OUT_OF_MATTER_890(890), TERRAIN_UP_THE_RULEBOOK_891(891), FIRE_IN_THE_WHOLE_892(892), WOULD_YOU_HOLD_IT_AGAINST_ME_893(893), BY_WHICH_WE_MEAN_AWESOME_894(894), ORDER_UP_SOME_CHAOS_895(895), MAKING_YOURSELF_PLANE_896(896), DONT_DENY_YOUR_RUNES_897(897), GUILD_BY_ASSOCIATION_898(898), LOGARHYTHM_899(899), ENJOY_A_PYRE_TOO_900(900), OAKEY_SMOKEY_901(901), YOU_WILLOW_IT_TO_YOUR_TINDERBOX_902(902), TAKE_A_BOW_903(903), NOT_VERY_CONSTRUCTIVE_904(904), TROLL_HARDER_905(905), VERSATILE_FIGHTER_906(906), ALL_TROLLS_MUST_DIE_907(907), SWAMPED_908(908), THEYRE_ALL_A_QUIVER_909(909), ALL_ABOARD_THE_MAGE_TRAIN_910(910), GF_911(911), NOW_YOURE_CONTENDING_WITH_PORTALS_912(912), FLAGGED_FOR_DEATH_913(913), YOU_CLAN_WIN_THIS_914(914), ASSAULT_AND_BATTERY_915(915), LIKE_THE_FIST_OF_A_BALANCED_GOD_916(916), ADVENTURERS_LOG_917(917), CRACKS_ME_UP_918(918), DEEP_ROOTS_919(919), OAKLAND_920(920), DONT_DROP_IT_921(921), CRY_ME_A_RIVER_922(922), A_TICK_AND_A_TOCK_923(923), BARKING_POTTERY_924(924), MAPLE_SYRUP_925(925), KEENER_AXE_926(926), A_LONG_LONG_TIME_AGO_927(927), THREES_COMPANY_928(928), CHAOTIC_GROVE_929(929), ONE_TO_RULE_THEM_ALL_930(930), DIG_DEEPER_931(931), THE_GIANTS_LAIR_932(932), VENGEANCE_933(933), THE_DEVILS_PLAYGROUND_934(934), EDEN_935(935), PARTYING_TIL_6_936(936), A_FIERY_JAIL_937(937), THE_GUILDS_DEEPEST_SECRETS_938(938), ADDED_VALUE_939(939), SPIRITUAL_HEALING_940(940), TODAYS_SPECIAL_941(941), RAIDERS_OF_THE_FROST_DARK_942(942), MASTERS_TOP_TIPS_943(943), CHISELLIN_CONCHIOLIN_944(944), ITS_ONLY_WAFER_THIN_945(945), DISLIKEANTHROPE_946(946), CRANIUS_LUPUS_947(947), LAB_CLEANUP_ASSISTANT_948(948), FORTIFIED_SPIRIT_949(949), STRUCK_AGHAST_950(950), BLOOMING_MARVELLOUS_951(951), TEARS_OF_GUTHIX_3000(3000), ONLY_GOING_FORWARD_WE_CANT_FIND_REVERSE_952(952), CONQUEST_3001(3001), IF_IT_BLEEDS_953(953), PENGUIN_HUNTING_3002(3002), WURT_A_BUNDLE_954(954), EVIL_TREE_3003(3003), ADMYRE_THE_GOODS_955(955), SHOOTING_STAR_3004(3004), CHARTER_A_COURSE_956(956), IMPETUOUS_IMPULSES_3005(3005), TRAVELLING_ON_THE_SLIME_TRAIL_957(957), VINESWEEPER_3006(3006), THE_YEAST_THEY_CAN_DO_958(958), BALTHAZARS_BIG_TOP_BONANZA_3007(3007), POLTERHEIST_959(959), DEFEAT_BORK_3008(3008), FLAMTAER_WILL_GET_YOU_EVERYWHERE_960(960), ALL_FIRED_UP_3009(3009), WHO_YOU_GONNA_RING_961(961), SKELETAL_HORROR_3010(3010), BARKING_UP_THE_WRONG_TREE_962(962), CHAMPIONS_CHALLENGE_3011(3011), GATE_SPECTREATIONS_963(963), GREAT_ORB_PROJECT_3012(3012), READY_TREK_964(964), PEST_CONTROL_3013(3013), DONT_STOP_ME_IF_I_START_TO_RAMBLE_965(965), CASTLE_WARS_3014(3014), PLENTY_MORT_WHERE_THAT_CAME_FROM_966(966), COURT_CASES_3015(3015), IZZY_WIZZY_LETS_GET_LIZZY_967(967), TAI_BWO_WANNAI_CLEANUP_3016(3016), FINDING_YOUR_BALANCE_968(968), FIGHT_CAVES_3017(3017), THE_BEER_INNSPECTRE_969(969), FIGHT_PITS_3018(3018), BRAIN_BENDING_970(970), BRIMHAVEN_AGILITY_ARENA_3019(3019), I_WONDER_HOW_FAR_IT_GHOST_971(971), BARBARIAN_ASSAULT_3020(3020), OBVIOUS_FORGERY_972(972), BLAST_FURNACE_3021(3021), THE_HIGHER_THE_BADDER_973(973), SHADES_OF_MORTTON_3022(3022), FUN_GUY_BUT_BITTER_974(974), BARROWS_3023(3023), DETARNATION_975(975), PYRAMID_PLUNDER_3024(3024), SHADESHATTERING_KABLOOM_976(976), SORCERESS_GARDEN_3025(3025), THEYLL_JUST_THROW_IT_AWAY_AGAIN_977(977), MAGE_TRAINING_ARENA_3026(3026), TIME_SALVER_978(978), DUEL_ARENA_3027(3027), HUGE_SUCCESS_979(979), FIST_OF_GUTHIX_3028(3028), I_BROUGHT_YOUR_STUFF_BACK_980(980), STEALING_CREATION_3029(3029), JUST_ONE_MORE_KEY_981(981), SOUL_WARS_3030(3030), RAISING_THE_STAKES_982(982), CLAN_WARS_3031(3031), TREKKIN_AINT_EASY_983(983), GNOME_RESTAURANT_3032(3032), BETTER_THAN_CURSING_THE_DARKNESS_984(984), MOBILISING_ARMIES_3033(3033), RUNECRAFT_CARRIER_985(985), WARRIORS_GUILD_3034(3034), WHIP_IT_GOOD_986(986), AS_YOU_MIGHT_EXPECT_987(987), THOROUGHLY_AGHAST_988(988), AS_GOOD_AS_RENEW_989(989), FREMENNIK_EXPORT_990(990), NOT_SUCH_A_ROTTEN_IDEA_991(991), SET_IT_ON_FIYR_992(992), BROS_BEFORE_BARROWS_993(993), ON_WINGS_OF_BLING_994(994), OPEN_SESAME_995(995), OPEN_MARKET_996(996), BEACHHEAD_998(998), AT_A_CROSSROADS_999(999), COMING_LIKE_A_GHOST_TOWN_1000(1000), FOLLOW_THAT_STAR_1001(1001), SETTING_SAIL_1003(1003), FIND_ENLIGHTENMENT_1004(1004), RITE_OF_PASSAGE_1005(1005), WELCOME_TO_BARTERTOWN_1006(1006), MAGICAL_MYSTERY_TOUR_1007(1007), CATACOMBAT_1008(1008), HOOKED_ON_FINIX_WORKED_FOR_ME_1009(1009), RAISING_THE_STOKES_1010(1010), TROLL_HARDER_1012(1012), SONG_FROM_THE_DEPTHS_1013(1013), _1120(1120), TALK_TO_SIR_VANT_3500(3500), ASSIST_SIR_VANT_3501(3501), GATHER_THE_SQUIRES_GEAR_3502(3502), EQUIP_YOURSELF_3503(3503), KILL_THE_GOBLIN_3504(3504), FIND_OUT_SIR_VANTS_PLAN_3505(3505), CHECK_YOUR_QUEST_JOURNAL_3506(3506), CLIMB_THE_WALL_3507(3507), CHECK_YOUR_WORLD_MAP_3508(3508), REALIGN_YOUR_MINIMAP_3509(3509), PUT_THE_DRAGON_TO_SLEEP_3510(3510), TALK_TO_SIR_VANT_AGAIN_3511(3511), SABOTAGE_3512(3512), RETURN_THE_SQUIRES_GEAR_3513(3513), DISCOVER_AN_EXIT_3514(3514), CUTTING_A_PATH_3515(3515), BREAKING_THROUGH_3516(3516), SKILL_IN_WOODCUTTING_3517(3517), SKILL_IN_MINING_3518(3518), TO_FREEDOM_3519(3519), INTRODUCINGEXPLORER_JACK_3520(3520), THE_JOURNEY_BEGINS_3521(3521), ROTATE_YOUR_CAMERA_3522(3522), MAKE_A_RAMP_3523(3523), DEFEAT_THE_RANGER_3525(3525), DEFEAT_THE_MAGE_3526(3526), DEFEAT_THE_WARRIOR_3527(3527), RESCUE_THE_MAIDEN_3528(3528), PREPARE_TO_CAST_3529(3529), LUMBRIDGE_SET_TASKS_BEGINNER_4000(4000), LUMBRIDGE_SET_TASKS_EASY_4001(4001), LUMBRIDGE_SET_TASKS_MEDIUM_4002(4002), LUMBRIDGE_SET_TASKS_HARD_4003(4003), ARDOUGNE_SET_TASKS_EASY_4004(4004), ARDOUGNE_SET_TASKS_MEDIUM_4005(4005), ARDOUGNE_SET_TASKS_HARD_4006(4006), ARDOUGNE_SET_TASKS_ELITE_4007(4007), FALADOR_SET_TASKS_EASY_4008(4008), FALADOR_SET_TASKS_MEDIUM_4009(4009), FALADOR_SET_TASKS_HARD_4010(4010), FALADOR_SET_TASKS_ELITE_4011(4011), FREMENNIK_SET_TASKS_EASY_4012(4012), FREMENNIK_SET_TASKS_MEDIUM_4013(4013), FREMENNIK_SET_TASKS_HARD_4014(4014), FREMENNIK_SET_TASKS_ELITE_4015(4015), KARAMJA_SET_TASKS_EASY_4016(4016), KARAMJA_SET_TASKS_MEDIUM_4017(4017), KARAMJA_SET_TASKS_HARD_4018(4018), KARAMJA_SET_TASKS_ELITE_4019(4019), SEERS_VILLAGE_SET_TASKS_EASY_4020(4020), SEERS_VILLAGE_SET_TASKS_MEDIUM_4021(4021), SEERS_VILLAGE_SET_TASKS_HARD_4022(4022), SEERS_VILLAGE_SET_TASKS_ELITE_4023(4023), VARROCK_SET_TASKS_EASY_4024(4024), VARROCK_SET_TASKS_MEDIUM_4025(4025), VARROCK_SET_TASKS_HARD_4026(4026), VARROCK_SET_TASKS_ELITE_4027(4027), MORYTANIA_SET_TASKS_EASY_4028(4028), MORYTANIA_SET_TASKS_MEDIUM_4029(4029), MORYTANIA_SET_TASKS_HARD_4030(4030), MORYTANIA_SET_TASKS_ELITE_4031(4031), NO_TASK_AVAILABLE_4091(4091), NO_TASK_AVAILABLE_4092(4092), NO_NAME_TASK_PLACEHOLDER_4094(4094), NO_PINNED_TASK_4095(4095); private static final Map MAP = new HashMap<>(); static { for (Achievement a : Achievement.values()) MAP.put(a.id, a); } public static Achievement forId(int id) { return MAP.get(id); } private final int id; private Achievement(int id) { this.id = id; } public int getId() { return id; } public AchievementDef getDefs() { return AchievementDef.getDefs(id); } }" "package com.rs.game.content.achievements; @PluginEventHandler public class AchievementDef { private static final Map CACHE = new HashMap<>(); private static final Map>> TASK_SETS = new HashMap<>(); private static final Map>> TASK_SET_LEVEL_REQS = new HashMap<>(); public enum Area { //0=3000, 1=346, 2=426, 3=115, 4=221, 5=0, 6=182, 7=152, 8=531, 9=944, 10=995, 11=4091, 12=4091, 13=4091, 14=4091, 15=4091, 16=4091, 17=4091, 18=4091, 19=4091, 20=4091, 60=3522, 62=4091, 63=4090 MINIGAMES(0), LUMBRIDGE(1), VARROCK(2), FALADOR(3), SEERS(4), ARDOUGNE(5), KARAMJA(6), FREMENNIK(7), BURTHORPE(8), MORYTANIA(9), LODESTONES(10), DESERT(11), ISLANDS(12), FELDIP(13), TIRANNWN(14), GNOME(15), WILDERNESS(16), KELDAGRIM(17), DORGESH_KAAN(18), OUTER_PLANES(19), PISCATORIS(20), SIR_VANT_TUTORIAL(60), UNNAMED1(61), DAMONHEIM(62), ELSEWHERE(63); private final int id; Area(int id) { this.id = id; } public static Area forId(int id) { for (Area a : Area.values()) if (a.id == id) return a; return null; } } public enum Difficulty { NONE, BEGINNER, EASY, MEDIUM, HARD, ELITE; } private final int id; private final int next; private final String name; private final Difficulty difficulty; private final Area area; private final Area taskSet; private final Map skillReqs; private static final int TASK_SET = 1293; private static final int AREA = 1267; private static final int DIFFICULTY = 1272; private static final int NAME = 1266; private static final int ID = 1268; private static final int NEXT_ID = 1269; private static final int REQUIREMENTS_START = 1294; private static final int REQUIREMENTS_END = 1312; public AchievementDef(int id, StructDefinitions struct) { this.id = struct.getIntValue(ID); next = struct.getIntValue(NEXT_ID); name = struct.getStringValue(NAME); difficulty = Difficulty.values()[struct.getIntValue(DIFFICULTY)]; area = Area.forId(struct.getIntValue(AREA)); taskSet = Area.forId(struct.getIntValue(TASK_SET, 63)); skillReqs = new HashMap<>(); Set quests = new HashSet<>(); for (int i = REQUIREMENTS_START;i <= REQUIREMENTS_END;i += 2) if (struct.getIntValue(i, -1) != -1 && struct.getIntValue(i+1, -1) != -1) if (struct.getIntValue(i, -1) >= 1 && struct.getIntValue(i, -1) <= 25) addSkillReq(toRealSkillId(struct.getIntValue(i, -1)), struct.getIntValue(i+1, -1)); else if (struct.getIntValue(i, -1) == 61) { quests.add(Quest.forSlot(struct.getIntValue(i+1, -1))); for (int skillId : Quest.forSlot(struct.getIntValue(i+1, -1)).getDefs().getExtraInfo().getPreReqSkillReqs().keySet()) addSkillReq(skillId, Quest.forSlot(struct.getIntValue(i+1, -1)).getDefs().getExtraInfo().getPreReqSkillReqs().get(skillId)); } } public static boolean meetsRequirements(Player player, Area area, Difficulty difficulty) { return meetsRequirements(player, area, difficulty, true); } public static boolean meetsRequirements(Player player, Area area, Difficulty difficulty, boolean print) { boolean meetsRequirements = true; for (int skillId : TASK_SET_LEVEL_REQS.get(area).get(difficulty).keySet()) if (player.getSkills().getLevelForXp(skillId) < TASK_SET_LEVEL_REQS.get(area).get(difficulty).get(skillId)) { if (print) player.sendMessage(""You need a "" + Constants.SKILL_NAME[skillId] + "" level of "" + TASK_SET_LEVEL_REQS.get(area).get(difficulty).get(skillId)+"".""); meetsRequirements = false; } return meetsRequirements; } public void addSkillReq(int skill, int level) { if (skillReqs.get(skill) == null || level > skillReqs.get(skill)) skillReqs.put(skill, level); } public Area getTaskSet() { return taskSet; } @ServerStartupEvent(Priority.FILE_IO) public static void init() { QuestDefinitions.init(); QuestInformationParser.init(); EnumDefinitions list = EnumDefinitions.getEnum(3483); for (long id : list.getValues().keySet()) { StructDefinitions details = StructDefinitions.getStruct((int) list.getValue(id)); AchievementDef cheevo = new AchievementDef((int) id, details); CACHE.put(cheevo.id, cheevo); if (cheevo.difficulty != Difficulty.NONE && cheevo.taskSet != Area.ELSEWHERE && cheevo.taskSet != Area.LODESTONES) { Map> areaMap = TASK_SETS.get(cheevo.taskSet); if (areaMap == null) areaMap = new HashMap<>(); Set taskSet = areaMap.get(cheevo.difficulty); if (taskSet == null) taskSet = new HashSet<>(); taskSet.add(cheevo); areaMap.put(cheevo.difficulty, taskSet); TASK_SETS.put(cheevo.taskSet, areaMap); Map> diffMap = TASK_SET_LEVEL_REQS.get(cheevo.taskSet); if (diffMap == null) diffMap = new HashMap<>(); Map levelReqs = diffMap.get(cheevo.difficulty); if (levelReqs == null) levelReqs = new HashMap<>(); for (int skillId : cheevo.skillReqs.keySet()) if (levelReqs.get(skillId) == null || cheevo.skillReqs.get(skillId) > levelReqs.get(skillId)) levelReqs.put(skillId, cheevo.skillReqs.get(skillId)); diffMap.put(cheevo.difficulty, levelReqs); TASK_SET_LEVEL_REQS.put(cheevo.taskSet, diffMap); } } for (Area area : TASK_SET_LEVEL_REQS.keySet()) for (Difficulty realDiff : TASK_SET_LEVEL_REQS.get(area).keySet()) { Map reqs = TASK_SET_LEVEL_REQS.get(area).get(realDiff); if (reqs == null) continue; for (Difficulty diff : Difficulty.values()) { if (diff == realDiff) break; Map oldReq = TASK_SET_LEVEL_REQS.get(area).get(diff); if (oldReq == null) continue; for (int skillId : oldReq.keySet()) if (reqs.get(skillId) == null || oldReq.get(skillId) > reqs.get(skillId)) reqs.put(skillId, oldReq.get(skillId)); } } } public int getId() { return id; } public String getName() { return name; } public Difficulty getDifficulty() { return difficulty; } public Area getArea() { return area; } private static int toRealSkillId(int skillId) { return switch(skillId) { case 1 -> 0; case 2 -> 2; case 3 -> 4; case 4 -> 6; case 5 -> 1; case 6 -> 3; case 7 -> 5; case 8 -> 16; case 9 -> 15; case 10 -> 17; case 11 -> 12; case 12 -> 20; case 13 -> 14; case 14 -> 13; case 15 -> 10; case 16 -> 7; case 17 -> 11; case 18 -> 8; case 19 -> 9; case 20 -> 18; case 21 -> 19; case 22 -> 22; case 23 -> 21; case 24 -> 23; case 25 -> 24; default -> 0; }; } @Override public String toString() { return ""{""+id+"", \""""+name+""\"", "" + difficulty.name()+""}""; } public int getNext() { return next; } public static AchievementDef getDefs(int id) { return CACHE.get(id); } }" "package com.rs.game.content.achievements; @PluginEventHandler public class AchievementInterface { //3483 enum for list of achievements public static void init(Player player) { player.getVars().setVarBit(8575, 1); //task set player.getVars().setVarBit(8582, 1); //task set player.getVars().setVarBit(8581, -1); //refresh?.. player.getPackets().sendVarc(1423, 0); //completed in set player.getPackets().sendVarc(1424, 0); //total in set player.getVars().setVarBit(8601, 533); //total completed overall 534 unlocks taskmaster for (int i = 0;i < 6;i++) player.getVars().setVarBit(8587+i, 4095); player.getPackets().setIFHidden(1056, 117, true); } public static void openInterface(Player player) { player.getInterfaceManager().sendInterface(917); player.getPackets().setIFRightClickOps(917, 67, 0, 532, 0, 1); player.getPackets().setIFRightClickOps(917, 147, 0, 10, 0); } public static ButtonClickHandler handleTabButtons = new ButtonClickHandler(1056, e -> { switch (e.getComponentId()) { case 173: openInterface(e.getPlayer()); break; default: e.getPlayer().sendMessage(""Unhandled Achievement Tab button: "" + e.getComponentId() + "", "" + e.getSlotId()); break; } }); public static ButtonClickHandler handleInterfaceButtons = new ButtonClickHandler(917, e -> { switch (e.getComponentId()) { case 147: e.getPlayer().getVars().setVarBit(8582, e.getSlotId()); e.getPlayer().getVars().setVarBit(8581, 0); break; case 160: case 161: e.getPlayer().getVars().setVarBit(8579, e.getComponentId() == 160 ? 0 : 1); break; case 162: case 163: e.getPlayer().getVars().setVarBit(8580, e.getComponentId() == 162 ? 0 : 1); break; default: e.getPlayer().sendMessage(""Unhandled Achievement Interface button: "" + e.getComponentId() + "", "" + e.getSlotId()); break; } }); }" "package com.rs.game.content.achievements; public class AchievementReqsMisc { public static String script_3223(VarManager player, int achivementId, int reqIndex) { // int int2; String str0; str0 = """"; // int2 = 0; // switch (achivementId) { // case 147: // case 23: // case 294: // case 167: // case 249: // if (reqIndex == 1) { // str0 = ""You must have access to the fairy ring network to complete this Task.""; // if (player.getVars().getVarBit(2328) == 1) { // int2 = 1; // } // } // break; // case 49: // if (reqIndex == 1) { // str0 = ""You must unlock 500 music tracks in order to perform the Air Guitar emote.""; // if (player.getVars().getVarBit(4394) == 1) { // int2 = 1; // } // } // break; // case 59: // if (reqIndex == 2) { // str0 = ""You must also have completed the Abyss miniquest.""; // if (player.getVars().getVar(492) >= 4) { // int2 = 1; // } // } // break; // case 107: // if (reqIndex == 1) { // str0 = ""You must have progressed to a certain point in the Dragon Slayer quest.""; // if (player.getVars().getVar(176) >= 2 && player.getVars().getVarBit(3746) == 0 || player.getVars().getVar(176) >= 10) { // int2 = 1; // } // } // break; // case 178: // if (reqIndex == 1) { // str0 = ""You must begin the relevant section of Otto Godblessed's barbarian training.""; // if (player.getVars().getVarBit(3757) > 0) { // int2 = 1; // } // } // break; // case 180: // if (reqIndex == 1) { // str0 = ""You must begin the relevant section of Otto Godblessed's barbarian training.""; // if (player.getVars().getVarBit(3764) > 0) { // int2 = 1; // } // } // break; // case 177: // if (reqIndex == 1) { // str0 = ""You must begin the relevant section of Otto Godblessed's barbarian training.""; // if (player.getVars().getVarBit(3764) > 0) { // int2 = 1; // } // } // break; // case 316: // if (reqIndex == 1) { // str0 = ""You must begin the relevant section of Otto Godblessed's barbarian training.""; // if (player.getVars().getVarBit(3757) > 0) { // int2 = 1; // } // } // break; // case 321: // if (reqIndex == 1) { // str0 = ""You must begin the relevant section of Otto Godblessed's barbarian training.""; // if (player.getVars().getVarBit(3764) > 0) { // int2 = 1; // } // } // break; // case 322: // if (reqIndex == 1) { // str0 = ""You must begin the relevant section of Otto Godblessed's barbarian training.""; // if (player.getVars().getVarBit(3763) > 0) { // int2 = 1; // } // } // break; // case 323: // if (reqIndex == 1) { // str0 = ""You must begin the relevant section of Otto Godblessed's barbarian training.""; // if (player.getVars().getVarBit(3761) > 0) { // int2 = 1; // } // } // break; // case 175: // if (reqIndex == 1) { // str0 = ""You must complete the Bar Crawl miniquest.""; // if (player.getVars().getVar(76) >= 6 || player.getVars().getVarBit(3378) == 1) { // int2 = 1; // } // } // break; // case 331: // case 219: // if (reqIndex == 2) { // str0 = ""You must have a total combat level of at least 100 to accept an assignment in Shilo Village.""; // if (script_1432() >= 100) { // int2 = 1; // } // } // break; // case 248: // if (reqIndex == 1) { // str0 = ""You must have completed the Knight Waves in Camelot.""; // if (player.getVars().getVarBit(3909) == 8) { // int2 = 1; // } // } // break; // case 3011: // case 276: // if (reqIndex == 1) { // str0 = ""You require 33 Quest Points to enter the Champions' Guild.""; // if (player.getVars().getVar(101) >= 33) { // int2 = 1; // } // } // break; // case 281: // if (reqIndex == 1) { // str0 = ""You must unlock all four emotes by completing levels of the Stronghold of Security.""; // if (player.getVars().getVarBit(2309) == 1 && player.getVars().getVarBit(2310) == 1 && player.getVars().getVarBit(2311) == 1 && player.getVars().getVarBit(2312) == 1) { // int2 = 1; // } // } // break; // case 285: // if (reqIndex == 1) { // str0 = ""You must learn the secret of the Senntisten necklace.""; // if (player.getVars().getVarBit(3639) == 1) { // int2 = 1; // } // } // break; // case 289: // if (reqIndex == 1) { // str0 = ""You must have a total combat level of at least 40 to accept an assignment from Vannaka.""; // if (script_1432() >= 40) { // int2 = 1; // } // } // break; // case 300: // if (reqIndex == 1) { // str0 = ""Completing quests will increase your access to Kudos with the Varrock Museum.""; // if (script_4035() >= 153) { // int2 = 1; // } // } // break; // case 3000: // if (reqIndex == 2) { // if (getMinute() >= player.getVars().getVar(451)) { // int2 = 1; // } // str0 = ""You may gather the Tears of Guthix once every week.""; // } else if (reqIndex == 3) { // if (player.getVars().getVar(101) >= player.getVars().getVarBit(456) || script_4218() <= 0) { // int2 = 1; // } // str0 = ""You must have gained a Quest Point or 100,000 total experience to enter Juna's cavern.""; // } // break; // case 3013: // case 3001: // if (reqIndex == 1) { // str0 = ""You must have a total combat level of at least 40 to fight for the Void Knights.""; // if (getMyCombat() >= 40) { // int2 = 1; // } // } // break; // case 3002: // if (reqIndex == 1) { // str0 = ""You must have Larry or Chuck explain the purpose of penguin spying.""; // if (player.getVars().getVarBit(5277) == 1) { // int2 = 1; // } // } else if (reqIndex == 2) { // str0 = ""You must have spied on fewer than ten penguins already this week.""; // if (player.getVars().getVarBit(5276) < 10) { // int2 = 1; // } // } else if (reqIndex == 3) { // str0 = ""You may spy on penguins if your total Penguin Points are less than the maximum of fifty.""; // if (player.getVars().getVarBit(5275) < 50) { // int2 = 1; // } // } // break; // case 12: // if (reqIndex == 1) { // str0 = ""You must have Larry or Chuck explain the purpose of Penguin Hide and Seek.""; // if (player.getVars().getVarBit(5277) == 1) { // int2 = 1; // } // } // break; // case 3003: // if (reqIndex == 1) { // str0 = ""You may not chop down more than two evil trees per day.""; // if (player.getVars().getVarBit(1545) < 2) { // int2 = 1; // } // } // break; // case 3007: // if (reqIndex == 1) { // str0 = ""You may attempt the Agility, Magic and Ranged performances after a week has passed since your last show.""; // if (player.getVars().getVarBit(5251) == 0 || player.getVars().getVarBit(5252) == 0 || player.getVars().getVarBit(5253) == 0) { // int2 = 1; // } // } // break; // case 3008: // if (reqIndex == 2) { // str0 = ""You must wait at least a day since you last faced Bork.""; // if (player.getVars().getVar(1199) != getCurrentDaysSinceLaunch()) { // int2 = 1; // } // } // break; // case 3010: // if (reqIndex == 2) { // str0 = ""At least a week must pass since you last faced the Skeletal Horror.""; // if (getMinute() > player.getVars().getVarBit(6305)) { // int2 = 1; // } // } // break; // case 3012: // if (reqIndex == 1) { // str0 = ""You require 50 Runecrafting to enter the Runecrafters' Guild.""; // if (getSkillActualLvl(20) >= 50) { // int2 = 1; // } // } // break; // case 3015: // if (reqIndex == 2) { // str0 = ""You must have at least 65 Attack or Defence in order to take on a case.""; // if (getSkillActualLvl(0) >= 65 || getSkillActualLvl(1) >= 65) { // int2 = 1; // } // } // break; // case 3031: // if (reqIndex == 1) { // str0 = ""You must have a total combat level of at least 48 to fight in the Clan Wars.""; // if (script_1432() >= 48) { // int2 = 1; // } // } // break; // case 3034: // if (reqIndex == 1) { // str0 = ""To enter the Warriors' Guild your Attack or Strength level must be 99, or your combined Attack and Strength levels must total 130 or more.""; // if (getSkillActualLvl(2) + getSkillActualLvl(0) >= 130 || getSkillActualLvl(0) >= 99 || getSkillActualLvl(2) >= 99) { // int2 = 1; // } // } // break; // default: // str0 = """"; // int2 = 0; // break; // } // if (int2 == 1) { // str0 = concat("""", str0); // } return str0; } }" "package com.rs.game.content.achievements; @PluginEventHandler public class AchievementSetRewards { private static final Tile ARDY_FARM = Tile.of(2664, 3375, 0); private static final Tile KANDARIN_MONASTERY = Tile.of(2607, 3222, 0); public static NPCDropHandler handleNotingDagBones = new NPCDropHandler(new Object[] { 2881, 2882, 2883 }, new Object[] { 6729 }, e -> { if (e.getPlayer().getEquipment().getBootsId() == 19766) e.getItem().setId(e.getItem().getDefinitions().getCertId()); else if (DropCleanersKt.bonecrush(e.getPlayer(), e.getItem())) e.deleteItem(); }); public static ItemClickHandler handleArdougneCloak = new ItemClickHandler(new Object[] { 15345, 15347, 15349, 19748, 20767, 20769, 20771 }, new String[] { ""Teleports"", ""Teleport"", ""Kandarin Monastery"", ""Summoning-restore"", ""Ardougne Farm"", ""Customise"", ""Features"" }, e -> { if (e.getOption().equals(""Teleports"") || e.getOption().equals(""Features"")) { e.getPlayer().sendOptionDialogue(""Where would you like to go?"", ops -> { ops.add(""Ardougne Farm"", () -> { if (e.getPlayer().getDailyB(""ardyCloakFarmTele"") && (e.getItem().getId() == 15345 || e.getItem().getId() == 15347 || e.getItem().getId() == 15349)) { e.getPlayer().sendMessage(""You already used your teleport for today.""); return; } Magic.sendTeleportSpell(e.getPlayer(), 4454, 12438, 761, 762, 0, 0, ARDY_FARM, 4, true, TeleType.ITEM, () -> e.getPlayer().setDailyB(""ardyCloakFarmTele"", true)); }); ops.add(""Kandarin Monastery"", () -> Magic.sendTeleportSpell(e.getPlayer(), 12441, 12442, 2172, 2173, 0, 0, KANDARIN_MONASTERY, 3, true, TeleType.ITEM, null)); ops.add(""Nowhere.""); }); } else if (e.getOption().contains(""Kandarin Monastery"") || e.getOption().equals(""Teleport"")) Magic.sendTeleportSpell(e.getPlayer(), 12441, 12442, 2172, 2173, 0, 0, KANDARIN_MONASTERY, 3, true, TeleType.ITEM, null); else if (e.getOption().contains(""Ardougne Farm"")) { if (e.getPlayer().getDailyB(""ardyCloakFarmTele"") && (e.getItem().getId() == 15345 || e.getItem().getId() == 15347 || e.getItem().getId() == 15349)) { e.getPlayer().sendMessage(""You already used your teleport for today.""); return; } Magic.sendTeleportSpell(e.getPlayer(), 4454, 12438, 761, 762, 0, 0, ARDY_FARM, 4, true, TeleType.ITEM, () -> e.getPlayer().setDailyB(""ardyCloakFarmTele"", true)); } else if (e.getOption().equals(""Summoning-restore"")) { if (e.getPlayer().getDailyB(""ardyCloakSumm"")) { e.getPlayer().sendMessage(""You've already restored your summoning points today.""); return; } e.getPlayer().getSkills().set(Constants.SUMMONING, e.getPlayer().getSkills().getLevelForXp(Constants.SUMMONING)); e.getPlayer().setDailyB(""ardyCloakSumm"", true); e.getPlayer().setNextSpotAnim(new SpotAnim(7)); e.getPlayer().sendMessage(""You restore your summoning points.""); } else if (e.getOption().equals(""Customise"")) SkillCapeCustomizer.startCustomizing(e.getPlayer(), e.getItem().getId()); }); public static ItemClickHandler handleExplorersRing = new ItemClickHandler(new Object[] { 13560, 13561, 13562, 19760 }, new String[] { ""Cabbage-port"", ""Run-replenish"", ""Low-alchemy"", ""Low-Alchemy"", ""High-Alchemy"", ""Superheat"", ""Alchemy-or-superheat"" }, e -> { switch(e.getOption()) { case ""Cabbage-port"": Magic.sendTeleportSpell(e.getPlayer(), 9984, 9986, 1731, 1732, 0, 0, Tile.of(3053, 3291, 0), 4, true, TeleType.ITEM, null); break; case ""Run-replenish"": if ((e.getItem().getId() == 13560 && e.getPlayer().getDailyI(""eRingRunRep"") >= 1) || (e.getItem().getId() == 13561 && e.getPlayer().getDailyI(""eRingRunRep"") >= 2)) { e.getPlayer().sendMessage(""You've already used up your run replenishes today.""); return; } if (e.getPlayer().getDailyI(""eRingRunRep"") >= 3) { e.getPlayer().sendMessage(""You've already used up your run replenishes today.""); return; } e.getPlayer().incDailyI(""eRingRunRep""); e.getPlayer().setNextAnimation(new Animation(9988)); e.getPlayer().setNextSpotAnim(new SpotAnim(1733)); e.getPlayer().restoreRunEnergy(50); e.getPlayer().soundEffect(5035, true); e.getPlayer().sendMessage(""The ring replenishes your run energy.""); break; case ""Low-alchemy"": case ""Low-Alchemy"": openERingInter(e.getPlayer(), 0); break; case ""High-alchemy"": case ""High-Alchemy"": openERingInter(e.getPlayer(), 1); break; case ""Superheat"": openERingInter(e.getPlayer(), 2); break; case ""Alchemy-or-superheat"": e.getPlayer().sendOptionDialogue(""What would you like to do?"", ops -> { ops.add(""Low-alchemy"", () -> openERingInter(e.getPlayer(), 0)); ops.add(""High-alchemy"", () -> openERingInter(e.getPlayer(), 1)); ops.add(""Superheat"", () -> openERingInter(e.getPlayer(), 2)); }); break; } }); private static void openERingInter(Player player, int type) { player.getTempAttribs().setI(""eRingInterType"", type); String action = type == 0 ? ""Low-alchemy"" : type == 1 ? ""High-alchemy"" : ""Superheat""; player.getPackets().setIFText(12, 11, action); player.getPackets().sendInterSetItemsOptionsScript(12, 13, 93, 7, 4, action); player.getPackets().setIFRightClickOps(12, 13, 0, 27, 0); player.getInterfaceManager().sendInterface(12); } public static ButtonClickHandler handleAlchs = new ButtonClickHandler(12, e -> { Item item = e.getPlayer().getInventory().getItem(e.getSlotId()); if (item == null) return; switch (e.getPlayer().getTempAttribs().getI(""eRingInterType"", 0)) { case 0: if (e.getPlayer().getDailyI(""eRingLowAlchs"") >= 30) { e.getPlayer().sendMessage(""You have used up all your low alchemy charges for the day.""); return; } if (Alchemy.handleAlchemy(e.getPlayer(), item, true, false)) e.getPlayer().incDailyI(""eRingLowAlchs""); break; case 1: if (e.getPlayer().getDailyI(""eRingHighAlchs"") >= 15) { e.getPlayer().sendMessage(""You have used up all your high alchemy charges for the day.""); return; } if (Alchemy.handleAlchemy(e.getPlayer(), item, false, false)) e.getPlayer().incDailyI(""eRingHighAlchs""); break; case 2: if (e.getPlayer().getDailyI(""eRingSuperheats"") >= 27) { e.getPlayer().sendMessage(""You have used up all your superheat charges for the day.""); return; } if (Alchemy.handleSuperheat(e.getPlayer(), item, false)) e.getPlayer().incDailyI(""eRingSuperheats""); break; } }); public static ItemEquipHandler handleKaramjaGloveLadderUnlock = new ItemEquipHandler(new Object[] { 11140, 19754 }, e -> e.getPlayer().getVars().setVarBit(3610, e.equip() ? 1 : 0)); public static ObjectClickHandler handleUndergroundGem = new ObjectClickHandler(new Object[] { 23584, 23586 }, e -> { if (e.getObjectId() == 23584) e.getPlayer().useLadder(Tile.of(2825, 2997, 0)); else e.getPlayer().useLadder(Tile.of(2838, 9387, 0)); }); public static ItemClickHandler handleKaramjaGlovesTele = new ItemClickHandler(new Object[] { 11140, 19754 }, new String[] { ""Teleport"" }, e -> Magic.sendNormalTeleportSpell(e.getPlayer(), Tile.of(2841, 9387, 0))); public static ObjectClickHandler handleCooksGuildSpecialDoor = new ObjectClickHandler(new Object[] { 26810 }, e -> { if (AchievementDef.meetsRequirements(e.getPlayer(), Area.VARROCK, Difficulty.HARD)) Doors.handleDoor(e.getPlayer(), e.getObject()); else e.getPlayer().sendMessage(""You must have the requirements for the Varrock Hard Achievement Set to enter here.""); }); public static ItemClickHandler handleFaladorShieldOps = new ItemClickHandler(new Object[] { 14577, 14578, 14579, 19749 }, new String[] { ""Prayer-restore"", ""Emote"" }, e -> { if (e.getOption().equals(""Emote"")) switch(e.getItem().getId()) { case 14577: e.getPlayer().setNextAnimation(new Animation(13843)); break; case 14578: e.getPlayer().setNextAnimation(new Animation(13844)); break; case 14579: e.getPlayer().setNextAnimation(new Animation(13845)); e.getPlayer().setNextSpotAnim(new SpotAnim(1965)); break; case 19749: e.getPlayer().setNextAnimation(new Animation(14713)); e.getPlayer().setNextSpotAnim(new SpotAnim(1965)); break; } else if (e.getOption().equals(""Prayer-restore"")) { if (e.getPlayer().getDailyI(""fallyShieldPrayer"") >= (e.getItem().getId() == 19749 ? 2 : 1)) { e.getPlayer().sendMessage(""You've already used up your prayer restores for the day.""); return; } if (e.getPlayer().getPrayer().hasFullPoints()) { e.getPlayer().sendMessage(""You already have full prayer points.""); return; } switch(e.getItem().getId()) { case 14577: e.getPlayer().getPrayer().restorePrayer((e.getPlayer().getSkills().getLevelForXp(Constants.PRAYER) * 10) * 0.25); break; case 14578: e.getPlayer().getPrayer().restorePrayer((e.getPlayer().getSkills().getLevelForXp(Constants.PRAYER) * 10) * 0.5); break; case 14579: case 19749: e.getPlayer().getPrayer().restorePrayer(e.getPlayer().getSkills().getLevelForXp(Constants.PRAYER) * 10); break; } e.getPlayer().incDailyI(""fallyShieldPrayer""); e.getPlayer().setNextSpotAnim(new SpotAnim(1964)); e.getPlayer().sendMessage(""The shield replenishes your prayer points.""); } }); public static ItemClickHandler handleMorytaniaLegs = new ItemClickHandler(new Object[] { 24135, 24136, 24137 }, new String[] { ""Slime Pit Teleport"" }, e -> { int teleLimit = switch(e.getItem().getId()) { case 24135 -> 5; case 24136 -> 10; default -> 20; }; if (e.getOption().equals(""Slime Pit Teleport"")) { if (e.getPlayer().getDailyI(""moryLegSlimeTeles"") >= teleLimit) { e.getPlayer().sendMessage(""You already used your teleports for today.""); return; } Magic.sendTeleportSpell(e.getPlayer(), 8939, 8941, 1678, 1679, 0, 0, Tile.of(3683, 9888, 0), 3, false, TeleType.ITEM, () -> e.getPlayer().incDailyI(""moryLegSlimeTeles"")); } }); public static ItemClickHandler handleFremmyBoots = new ItemClickHandler(new Object[] { 14571, 14572, 14573, 19766 }, new String[] { ""Operate"", ""Contact the Fossegrimen"", ""Free lyre teleport"" }, e -> { switch(e.getOption()) { case ""Operate"" -> e.getPlayer().sendOptionDialogue(ops -> { ops.add(""Contact the Fossegrimen"", () -> Rellekka.rechargeLyre(e.getPlayer())); ops.add(""Free lyre teleport"", () -> e.getPlayer().startConversation(Rellekka.getLyreTeleOptions(e.getPlayer(), null, true))); }); case ""Free lyre teleport"" -> e.getPlayer().startConversation(Rellekka.getLyreTeleOptions(e.getPlayer(), null, true)); case ""Contact the Fossegrimen"" -> Rellekka.rechargeLyre(e.getPlayer()); } }); }" "package com.rs.game.content.achievements class AchievementSystemD(p: Player, npcId: Int, reward: SetReward) { init { p.startConversation { label(""initialOptions"") options(""What would you like to say?"") { op(""Tell me about the Achievement System."") { player(HeadE.CHEERFUL, ""Tell me about the Achievement System."") npc(npcId, HeadE.CHEERFUL_EXPOSITION, ""Very well: the Achievement System is a collection of deeds you may wish to complete while adventuring around the world."") npc(npcId, HeadE.CHEERFUL_EXPOSITION, ""You can earn special rewards for completing certain achievements; at the very least, each is worth a cash bounty from Explorer Jack in Lumbridge."") npc(npcId, HeadE.CHEERFUL_EXPOSITION, ""Some also give items that will help complete other achievements, any many count as progress towards the set for the area they're in."") goto(""initialOptions"") } op(""Am I eligible for any rewards?"") { if (reward.hasRequirements(p, reward.itemIds[0], false)) { options(""Which item would you like to claim?"") { for (itemId in reward.itemIds) { op(ItemDefinitions.getDefs(itemId).name) { if (reward.hasRequirements(p, itemId, false)) { player(HeadE.CONFUSED, ""Could I claim ${Utils.addArticle(ItemDefinitions.getDefs(itemId).name)}?"") npc(npcId, HeadE.CHEERFUL, ""Of course, you've earned it!"") item(itemId, ""You've been handed ${Utils.addArticle(ItemDefinitions.getDefs(itemId).name)}."") { p.inventory.addItem(itemId) } } else { options { op(""What requirements do I need?"") { if (!reward.hasRequirements(p, itemId)) { npc(npcId, HeadE.SAD, ""You do not yet meet the requirements for ${Utils.addArticle(ItemDefinitions.getDefs(itemId).name)}. They have been listed in your chat box."") } } } } options { op(""Farewell."") } } } } } else { npc(npcId, HeadE.SHAKING_HEAD, ""Unfortunately not. The requirements for claiming the first tier will be listed in your chat box."") { reward.hasRequirements(p, reward.itemIds[0]) } } } op(""Sorry, I was just leaving."") { player(HeadE.CALM, ""Sorry, I was just leaving."") } } } } }" "package com.rs.game.content.achievements; public enum SetReward { KARAMJA_GLOVES(Area.KARAMJA, new Difficulty[] { Difficulty.EASY, Difficulty.MEDIUM, Difficulty.HARD, Difficulty.ELITE }, new int[] { 11136, 11138, 11140, 19754 }), VARROCK_ARMOR(Area.VARROCK, new Difficulty[] { Difficulty.EASY, Difficulty.MEDIUM, Difficulty.HARD, Difficulty.ELITE }, new int[] { 11756, 11757, 11758, 19757 }), EXPLORERS_RING(Area.LUMBRIDGE, new Difficulty[] { Difficulty.BEGINNER, Difficulty.EASY, Difficulty.MEDIUM, Difficulty.HARD }, new int[] { 13560, 13561, 13562, 19760 }), FREMENNIK_BOOTS(Area.FREMENNIK, new Difficulty[] { Difficulty.EASY, Difficulty.MEDIUM, Difficulty.HARD, Difficulty.ELITE }, new int[] { 14571, 14572, 14573, 19766 }), FALADOR_SHIELD(Area.FALADOR, new Difficulty[] { Difficulty.EASY, Difficulty.MEDIUM, Difficulty.HARD, Difficulty.ELITE }, new int[] { 14577, 14578, 14579, 19749 }), SEERS_HEADBAND(Area.SEERS, new Difficulty[] { Difficulty.EASY, Difficulty.MEDIUM, Difficulty.HARD, Difficulty.ELITE }, new int[] { 14631, 14662, 14663, 19763 }), ARDOUGNE_CLOAK(Area.ARDOUGNE, new Difficulty[] { Difficulty.EASY, Difficulty.MEDIUM, Difficulty.HARD, Difficulty.ELITE }, new int[] { 15345, 15347, 15349, 19748 }), MORYTANIA_LEGS(Area.MORYTANIA, new Difficulty[] { Difficulty.EASY, Difficulty.MEDIUM, Difficulty.HARD, Difficulty.ELITE }, new int[] { 24134, 24135, 24136, 24137 }); private final Area area; private final Difficulty[] diffs; private final int[] itemIds; private static final Map REWARDS = new HashMap<>(); private static final Map AREAS = new HashMap<>(); static { for (SetReward rew : SetReward.values()) { for (int id : rew.itemIds) REWARDS.put(id, rew); AREAS.put(rew.area, rew); } } public static SetReward forId(int id) { return REWARDS.get(id); } public static SetReward forArea(Area area) { return AREAS.get(area); } private SetReward(Area area, Difficulty[] diffs, int[] itemIds) { this.area = area; this.diffs = diffs; this.itemIds = itemIds; } public int[] getItemIds() { return itemIds; } public boolean hasRequirements(Player player, Area area, Difficulty difficulty) { return hasRequirements(player, area, difficulty, true); } public boolean hasRequirements(Player player, Area area, Difficulty difficulty, boolean print) { return AchievementDef.meetsRequirements(player, area, difficulty, print); } public boolean hasRequirements(Player player, int itemId) { for (int i = 0;i < diffs.length;i++) { if (itemIds[i] != itemId) continue; if (!AchievementDef.meetsRequirements(player, area, diffs[i])) return false; } return true; } public boolean hasRequirements(Player player, int itemId, boolean print) { for (int i = 0;i < diffs.length;i++) { if (itemIds[i] != itemId) continue; if (!AchievementDef.meetsRequirements(player, area, diffs[i], print)) return false; } return true; } }" "package com.rs.game.content.bosses; public class ChaosElementalCombat extends CombatScript { @Override public Object[] getKeys() { return new Object[] { ""Chaos Elemental"" }; } @Override public int attack(NPC npc, final Entity target) { int atk = Utils.random(100); npc.setNextAnimation(new Animation(npc.getCombatDefinitions().getAttackEmote())); if (atk <= 10) { World.sendProjectile(npc, target, 2966, 30, 30, 45, 30, 15, 0); WorldTasks.schedule(new Task() { @Override public void run() { for (int i = 0;i < 6;i++) { Direction dir = Direction.random(); if (World.floorFree(target.getPlane(), target.getX() + dir.dx *i, target.getY() + dir.dy *i, target.getSize())) { target.tele(Tile.of(target.getX() + dir.dx *i, target.getY() + dir.dy *i, target.getPlane())); break; } } } }, Utils.getDistanceI(npc.getTile(), target.getTile())/3); } else if (atk <= 18) { World.sendProjectile(npc, target, 310, 30, 30, 45, 30, 15, 0); if (target instanceof Player player) WorldTasks.schedule(new Task() { @Override public void run() { int num = player.getInventory().getFreeSlots(); if (num > 0) { if (player.getEquipment().getWeaponId() != -1) Equipment.remove(player, Equipment.WEAPON, false); if (num <= 1) { player.getAppearance().generateAppearanceData(); return; } int i = -1; while (i < Equipment.SIZE && player.getInventory().hasFreeSlots()) { i++; if (i == 3) continue; if (player.getInventory().getFreeSlots() <= 0) break; Equipment.remove(player, i, false); } player.getAppearance().generateAppearanceData(); } } }, Utils.getDistanceI(npc.getTile(), target.getTile())/3); } else { int damage = getMaxHit(npc, 300, AttackStyle.MAGE, target); Hit hit = getMagicHit(npc, damage); int rand = Utils.random(3); if (rand == 0) { damage = getMaxHit(npc, 300, AttackStyle.RANGE, target); hit = getRangeHit(npc, damage); } else if (rand == 1) { damage = getMaxHit(npc, 300, AttackStyle.MELEE, target); hit = getMeleeHit(npc, damage); } World.sendProjectile(npc, target, 1279, 30, 30, 45, 30, 15, 0); delayHit(npc, Utils.getDistanceI(npc.getTile(), target.getTile())/3, target, hit); } return 4; } }" "package com.rs.game.content.bosses; public class EvilChickenCombat extends CombatScript { @Override public Object[] getKeys() { return new Object[] { ""Evil Chicken"" }; } @Override public int attack(final NPC npc, final Entity target) { final NPCCombatDefinitions defs = npc.getCombatDefinitions(); npc.setNextAnimation(new Animation(defs.getAttackEmote())); switch (Utils.getRandomInclusive(5)) { case 0: npc.setNextForceTalk(new ForceTalk(""Bwuk"")); break; case 1: npc.setNextForceTalk(new ForceTalk(""Bwuk bwuk bwuk"")); break; case 2: if (target instanceof Player player) npc.setNextForceTalk(new ForceTalk(""Flee from me, "" + player.getDisplayName())); break; case 3: if (target instanceof Player player) npc.setNextForceTalk(new ForceTalk(""Begone, "" + player.getDisplayName())); break; case 4: npc.setNextForceTalk(new ForceTalk(""Bwaaaauuuuk bwuk bwuk"")); break; case 5: npc.setNextForceTalk(new ForceTalk(""MUAHAHAHAHAAA!"")); break; } target.setNextSpotAnim(new SpotAnim(337)); delayHit(npc, 0, target, getMagicHit(npc, getMaxHit(npc, defs.getMaxHit(), AttackStyle.MAGE, target))); return npc.getAttackSpeed(); } }" "package com.rs.game.content.bosses; @PluginEventHandler public class GiantMole extends NPC { private static final Tile[] COORDS = { Tile.of(1737, 5228, 0), Tile.of(1751, 5233, 0), Tile.of(1778, 5237, 0), Tile.of(1736, 5227, 0), Tile.of(1780, 5152, 0), Tile.of(1758, 5162, 0), Tile.of(1745, 5169, 0), Tile.of(1760, 5183, 0) }; public GiantMole(int id, Tile tile, boolean spawned) { super(id, tile, spawned); } @Override public void handlePostHit(Hit hit) { if (getHPPerc() > 5.0 && getHPPerc() < 50.0 && Utils.random(4) == 0) move(hit); super.handlePostHit(hit); } private double getHPPerc() { return ((double) getHitpoints() / (double) getMaxHitpoints()) * 100.0; } public void move(Hit hit) { setNextAnimation(new Animation(3314)); setCantInteract(true); getCombat().removeTarget(); Entity source = hit.getSource(); final Player player = source == null ? null : (Player) (source instanceof Player ? source : null); if (player != null) player.getInterfaceManager().sendOverlay(226); final Tile middle = getMiddleTile(); WorldTasks.schedule(new Task() { @Override public void run() { if (player != null) player.getInterfaceManager().removeOverlay(); setCantInteract(false); if (isDead()) return; World.sendSpotAnim(middle, new SpotAnim(572)); World.sendSpotAnim(Tile.of(middle.getX(), middle.getY() - 1, middle.getPlane()), new SpotAnim(571)); World.sendSpotAnim(Tile.of(middle.getX(), middle.getY() + 1, middle.getPlane()), new SpotAnim(571)); World.sendSpotAnim(Tile.of(middle.getX() - 1, middle.getY() - 1, middle.getPlane()), new SpotAnim(571)); World.sendSpotAnim(Tile.of(middle.getX() - 1, middle.getY() + 1, middle.getPlane()), new SpotAnim(571)); World.sendSpotAnim(Tile.of(middle.getX() + 1, middle.getY() - 1, middle.getPlane()), new SpotAnim(571)); World.sendSpotAnim(Tile.of(middle.getX() + 1, middle.getY() + 1, middle.getPlane()), new SpotAnim(571)); World.sendSpotAnim(Tile.of(middle.getX() - 1, middle.getY(), middle.getPlane()), new SpotAnim(571)); World.sendSpotAnim(Tile.of(middle.getX() + 1, middle.getY(), middle.getPlane()), new SpotAnim(571)); tele(Tile.of(COORDS[Utils.random(COORDS.length)])); setNextAnimation(new Animation(3315)); } }, 2); } public static NPCInstanceHandler toFunc = new NPCInstanceHandler(3340, (npcId, tile) -> new GiantMole(npcId, tile, false)); }" "package com.rs.game.content.bosses; public class MelzarTheMadCombat extends CombatScript { @Override public Object[] getKeys() { return new Object[] { 753 }; } @Override public int attack(NPC npc, Entity target) { if(target instanceof Player) { final NPCCombatDefinitions defs = npc.getCombatDefinitions(); switch(Utils.random(0, 4)) { case 0 -> npc.forceTalk(""Let me drink my tea in peace.""); case 1 -> npc.forceTalk(""Leave me alone I need to feed my pet rock.""); case 2 -> npc.forceTalk(""By the power of custard!""); } switch (Utils.random(0, 3)) { case 0 -> { World.addGroundItem(new Item(1965, 1), Tile.of(target.getX() + Utils.random(0, 2) - 1, target.getY() + Utils.random(0, 2) - 1, target.getPlane()), (Player)target); npc.setNextAnimation(new Animation(Utils.random(0, 2) == 0 ? 423 : 422)); int damage = getMaxHit(npc, defs.getMaxHit(), AttackStyle.MELEE, target); delayHit(npc, 0, target, getMeleeHit(npc, damage)); } case 1 -> { npc.setNextAnimation(new Animation(1163)); npc.setNextSpotAnim(new SpotAnim(102)); WorldTasks.schedule(new Task() { @Override public void run() { WorldProjectile p = World.sendProjectile(npc, target, 103, 80, 30, 40, 5, 5, 0); target.setNextSpotAnim(new SpotAnim(104, 0, 100)); delayHit(npc, p.getTaskDelay(), target, getMagicHit(npc, getMaxHit(npc, defs.getMaxHit() - 2, AttackStyle.MAGE, target))); } }, 2); } case 2 -> { npc.setNextAnimation(new Animation(14209)); npc.setNextSpotAnim(new SpotAnim(2713)); WorldTasks.schedule(new Task() { @Override public void run() { WorldProjectile p = World.sendProjectile(npc, target, 103, 80, 30, 40, 5, 5, 0); target.setNextSpotAnim(new SpotAnim(2727, 0, 100)); delayHit(npc, p.getTaskDelay(), target, getMagicHit(npc, getMaxHit(npc, defs.getMaxHit() - 2, AttackStyle.MAGE, target))); } }, 2); } } } return npc.getAttackSpeed(); } }" "package com.rs.game.content.bosses.corp; @PluginEventHandler public class CorporealBeast extends NPC { private DarkEnergyCore core; public CorporealBeast(int id, Tile tile, boolean spawned) { super(id, tile, spawned); setCapDamage(1000); setLureDelay(3000); setForceAggroDistance(64); setIntelligentRouteFinder(true); setIgnoreDocile(true); } public void spawnDarkEnergyCore() { if (core != null) return; core = new DarkEnergyCore(this); } public void removeDarkEnergyCore() { if (core == null) return; core.finish(); core = null; } @Override public List getPossibleTargets() { List targets = super.getPossibleTargets(); List hittableTargets = new ArrayList<>(); for (Entity t : targets) if (t.getX() > 2972) hittableTargets.add(t); return hittableTargets; } @Override public void handlePreHit(Hit hit) { if (hit.getLook() == HitLook.CANNON_DAMAGE && hit.getDamage() > 80) hit.setDamage(80); if (hit.getSource() instanceof Player player) if (player.getEquipment().getWeaponId() != -1) if (!ItemDefinitions.getDefs(player.getEquipment().getWeaponId()).getName().contains("" spear"")) if (hit.getLook() == HitLook.MELEE_DAMAGE || hit.getLook() == HitLook.RANGE_DAMAGE) hit.setDamage(hit.getDamage() / 2); super.handlePreHit(hit); } @Override public void processNPC() { super.processNPC(); if (isDead()) return; if (getTickCounter() % 3 == 0) { final List possibleTargets = getPossibleTargets(); boolean stomp = false; for (Entity t : possibleTargets) if (WorldUtil.isInRange(this, t, -1)) { stomp = true; t.applyHit(new Hit(this, Utils.random(150, 513), HitLook.TRUE_DAMAGE), 0); } if (stomp) { setNextAnimation(new Animation(10496)); setNextSpotAnim(new SpotAnim(1834)); } } if (getAttackedBy() != null && lineOfSightTo(getAttackedBy(), false)) setAttackedBy(null); int maxhp = getMaxHitpoints(); if (maxhp > getHitpoints() && getPossibleTargets().isEmpty() && getAttackedBy() == null) { resetLevels(); setHitpoints(maxhp); } } @Override public void sendDeath(Entity source) { super.sendDeath(source); if (core != null) core.sendDeath(source); } @Override public double getMagePrayerMultiplier() { return 0.6; } public static NPCInstanceHandler toFunc = new NPCInstanceHandler(8133, (npcId, tile) -> new CorporealBeast(npcId, tile, false)); }" "package com.rs.game.content.bosses.corp; public class CorporealBeastCombat extends CombatScript { @Override public Object[] getKeys() { return new Object[] { 8133 }; } @Override public int attack(final NPC npc, final Entity target) { final NPCCombatDefinitions defs = npc.getCombatDefinitions(); if (Utils.getRandomInclusive(3) == 0 && npc.getHitpoints() < (npc.getMaxHitpoints()/2) && npc instanceof CorporealBeast beast) beast.spawnDarkEnergyCore(); int size = npc.getSize(); final List possibleTargets = npc.getPossibleTargets(); int attackStyle = Utils.getRandomInclusive(4); if (attackStyle == 0 || attackStyle == 1) { // melee int distanceX = target.getX() - npc.getX(); int distanceY = target.getY() - npc.getY(); if ((distanceX <= size) && (distanceX >= -1) && (distanceY <= size) && (distanceY >= -1)) { npc.setNextAnimation(new Animation(attackStyle == 0 ? defs.getAttackEmote() : 10058)); delayHit(npc, 0, target, getMeleeHit(npc, getMaxHit(npc, defs.getMaxHit(), AttackStyle.MELEE, target))); return npc.getAttackSpeed(); } attackStyle = 2 + Utils.getRandomInclusive(2); } if (attackStyle == 2) { // powerfull mage spiky ball npc.setNextAnimation(new Animation(10410)); delayHit(npc, World.sendProjectile(npc, target, 1825, 41, 16, 10, 1, 16, 0).getTaskDelay(), target, getMagicHit(npc, getMaxHit(npc, 650, AttackStyle.MAGE, target))); } else if (attackStyle == 3) { // translucent ball of energy npc.setNextAnimation(new Animation(10410)); int delay = World.sendProjectile(npc, target, 1823, 41, 16, 10, 1, 16, 0).getTaskDelay(); delayHit(npc, delay, target, getMagicHit(npc, getMaxHit(npc, 550, AttackStyle.MAGE, target))); if (target instanceof Player player) WorldTasks.schedule(new Task() { @Override public void run() { int skill = Utils.getRandomInclusive(2); skill = skill == 0 ? Constants.MAGIC : (skill == 1 ? Constants.SUMMONING : Constants.PRAYER); if (skill == Constants.PRAYER) player.getPrayer().drainPrayer(10 + Utils.getRandomInclusive(40)); else { int lvl = player.getSkills().getLevel(skill); lvl -= 1 + Utils.getRandomInclusive(4); player.getSkills().set(skill, lvl < 0 ? 0 : lvl); } player.sendMessage(""Your "" + Constants.SKILL_NAME[skill] + "" has been slighly drained!""); } }, delay); } else if (attackStyle == 4) { npc.setNextAnimation(new Animation(10410)); final Tile tile = Tile.of(target.getTile()); WorldTasks.schedule(new Task() { @Override public void run() { for (int i = 0; i < 6; i++) { final Tile newTile = Tile.of(tile, 3); if (!World.floorAndWallsFree(newTile, 1)) continue; for (Entity t : possibleTargets) { if (Utils.getDistance(newTile.getX(), newTile.getY(), t.getX(), t.getY()) > 1 || !t.lineOfSightTo(newTile, false)) continue; delayHit(npc, 0, t, getMagicHit(npc, getMaxHit(npc, 350, AttackStyle.MAGE, t))); } WorldTasks.schedule(new Task() { @Override public void run() { World.sendSpotAnim(newTile, new SpotAnim(1806)); } }, World.sendProjectile(tile, newTile, 1824, 0, 0, 0, 1, 30, 0).getTaskDelay()); } } }, World.sendProjectile(npc, tile, 1824, 41, 16, 0, 1, 16, 0).getTaskDelay()); } return npc.getAttackSpeed(); } }" "package com.rs.game.content.bosses.corp; @PluginEventHandler public class CorporealBeastController extends Controller { public static ButtonClickHandler handleEnterWarning = new ButtonClickHandler(650, e -> { if (e.getComponentId() == 15) { e.getPlayer().stopAll(); e.getPlayer().tele(Tile.of(2974, 4384, e.getPlayer().getPlane())); e.getPlayer().getControllerManager().startController(new CorporealBeastController()); } else if (e.getComponentId() == 16) e.getPlayer().closeInterfaces(); }); @Override public void start() { } @Override public boolean processObjectClick1(GameObject object) { if (object.getId() == 37929 || object.getId() == 38811) { removeController(); player.stopAll(); player.tele(Tile.of(2970, 4384, player.getPlane())); return false; } return true; } @Override public void onTeleported(TeleType type) { removeController(); } @Override public boolean sendDeath() { WorldTasks.scheduleLooping(new Task() { int loop; @Override public void run() { if (loop == 0) player.setNextAnimation(new Animation(836)); else if (loop == 1) player.sendMessage(""Oh dear, you have died.""); else if (loop == 3) { player.sendPVEItemsOnDeath(null, false); player.reset(); player.tele(Tile.of(Settings.getConfig().getPlayerRespawnTile())); player.setNextAnimation(new Animation(-1)); } else if (loop == 4) { removeController(); player.jingle(90); stop(); } loop++; } }, 0, 1); return false; } @Override public boolean login() { return false; // so doesnt remove script } @Override public boolean logout() { return false; // so doesnt remove script } }" "package com.rs.game.content.bosses.corp; public class CorporealBeastScene extends Cutscene { @Override public void construct(Player player) { camPos(2993, 4378, 1000); camLook(2984, 4383, 5000); dialogue(new Dialogue().addSimple(""You peek through the door.""), true); } }" "package com.rs.game.content.bosses.corp; public class DarkEnergyCore extends NPC { private final CorporealBeast beast; private Entity target; public DarkEnergyCore(CorporealBeast beast) { super(8127, Tile.of(beast.getTile()), true); setForceMultiArea(true); setIgnoreDocile(true); this.beast = beast; changeTarget = 2; } private int changeTarget; private int sapTimer; private int delay; @Override public void processNPC() { if (isDead() || hasFinished()) return; if (delay > 0) { delay--; return; } if (changeTarget > 0) { if (changeTarget == 1) { List possibleTarget = beast.getPossibleTargets(); if (possibleTarget.isEmpty()) { finish(); beast.removeDarkEnergyCore(); return; } target = possibleTarget.get(Utils.getRandomInclusive(possibleTarget.size() - 1)); setHidden(true); delay += World.sendProjectile(this, target.getTile(), 1828, 0, 0, 0, 0.6, 20, proj -> { tele(proj.getDestination()); setHidden(false); }).getTaskDelay(); } changeTarget--; return; } if (target == null || !WorldUtil.isInRange(this, target, 0)) { changeTarget = 5; return; } if (sapTimer-- <= 0) { int damage = Utils.getRandomInclusive(50) + 50; target.applyHit(new Hit(this, Utils.random(1, 131), HitLook.TRUE_DAMAGE)); beast.heal(damage); delay = 2; if (target instanceof Player player) player.sendMessage(""The dark core creature steals some life from you for its master."", true); sapTimer = getPoison().isPoisoned() ? 40 : 0; } delay = 2; } @Override public double getMagePrayerMultiplier() { return 0.6; } @Override public void sendDeath(Entity source) { super.sendDeath(source); beast.removeDarkEnergyCore(); } }" "package com.rs.game.content.bosses.dagkings; @PluginEventHandler public class Spinolyp extends NPC { public Spinolyp(int id, Tile tile) { super(id, tile); setIgnoreDocile(true); setRandomWalk(false); } @Override public boolean canMove(Direction dir) { return false; } @Override public void processNPC() { super.processNPC(); } public static NPCInstanceHandler toFunc = new NPCInstanceHandler(""Spinolyp"", Spinolyp::new); }" "package com.rs.game.content.bosses.dagkings; public class SpinolypCombat extends CombatScript { @Override public Object[] getKeys() { return new Object[] { ""Spinolyp"" }; } @Override public int attack(NPC npc, Entity target) { final NPCCombatDefinitions defs = npc.getCombatDefinitions(); switch (Utils.random(2)) { case 0 -> { npc.setNextAnimation(new Animation(defs.getAttackEmote())); WorldProjectile projectile = World.sendProjectile(npc, target, 2705, 34, 16, 35, 2, 10, 0); Hit hit = getMagicHit(npc, getMaxHit(npc, AttackStyle.RANGE, target)); delayHit(npc, projectile.getTaskDelay(), target, hit, () -> { if (hit.getDamage() > 0 && target instanceof Player p) p.getPrayer().drainPrayer(p.getEquipment().wearingSlot(Equipment.SHIELD, 13744, 23700) ? 0.5 : 1.0); }); } case 1 -> { npc.setNextAnimation(new Animation(defs.getAttackEmote())); WorldProjectile projectile = World.sendProjectile(npc, target, 473, 34, 16, 35, 2, 10, 0); Hit hit = getRangeHit(npc, getMaxHit(npc, AttackStyle.RANGE, target)); delayHit(npc, projectile.getTaskDelay(), target, hit, () -> { if (hit.getDamage() > 0 && Utils.random(10) == 0) target.getPoison().makePoisoned(68); }); } } if (Utils.random(10) == 0) target.getPoison().makePoisoned(68); return npc.getAttackSpeed(); } }" "package com.rs.game.content.bosses.glacor; public class EnduringMinion extends NPC { public Glacor parent; public boolean defeated = false; public EnduringMinion(int id, Tile tile, int mapAreaNameHash, boolean canBeAttackFromOutOfArea, boolean spawned, Glacor parent) { super(id, tile, spawned); this.parent = parent; setForceMultiAttacked(true); } @Override public void processEntity() { super.processEntity(); if (getHitpoints() <= 0 || isDead()) { if (!defeated) World.sendProjectile(this, parent, 634, 34, 16, 30, 35, 16, 15); defeated = true; } } @Override public void handlePreHit(Hit hit) { int distance = (int) Utils.getDistance(parent.getX(), parent.getY(), getX(), getY()); double damageReduction = distance * 0.1; hit.setDamage((int) (hit.getDamage() * damageReduction)); super.handlePreHit(hit); } }" "package com.rs.game.content.bosses.glacor; @PluginEventHandler public class Glacor extends NPC { public enum InheritedType { ENDURING, SAPPING, UNSTABLE; } public enum Stage { FIRST, MINIONS, FINAL; } private boolean minionsSpawned = false; private InheritedType minionType = null; private Stage stage = Stage.FIRST; public UnstableMinion unstable = null; public SappingMinion sapping = null; public EnduringMinion enduring = null; public boolean startedTimer = false; public boolean hasExploded = false; public NPC thisNpc = this; public Player lastAttacked = null; public Glacor(int id, Tile tile, boolean spawned) { super(id, tile, spawned); setForceMultiAttacked(true); } public boolean minionsKilled() { if (minionsSpawned) if (unstable.defeated && sapping.defeated && enduring.defeated) return true; return false; } public void resetNpcs() { if (unstable != null) unstable.finish(); if (sapping != null) sapping.finish(); if (enduring != null) enduring.finish(); setStage(Stage.FIRST); setHitpoints(5000); minionsSpawned = false; minionType = null; setAttackedBy(null); setCapDamage(-1); setMinionType(null); startedTimer = false; hasExploded = false; lastAttacked = null; } public void deathReset() { if (unstable != null) unstable.finish(); if (sapping != null) sapping.finish(); if (enduring != null) enduring.finish(); minionsSpawned = false; minionType = null; setAttackedBy(null); setStage(Stage.FIRST); setCapDamage(-1); setMinionType(null); startedTimer = false; hasExploded = false; lastAttacked = null; } @Override public void handlePreHit(Hit hit) { if (getMinionType() == InheritedType.ENDURING) hit.setDamage((int) (hit.getDamage() * .40)); if (hit.getData(""combatSpell"") != null && hit.getData(""combatSpell"", CombatSpell.class).isFireSpell()) hit.setDamage(hit.getDamage() * 2); if (!isMinionsSpawned() && getHitpoints() < 2500) { spawnMinions(); unstable.setTarget(lastAttacked); sapping.setTarget(lastAttacked); } super.handlePreHit(hit); } @Override public void processEntity() { super.processEntity(); if (stage == Stage.MINIONS && minionsKilled()) { setStage(Stage.FINAL); setCapDamage(-1); } if (lastAttacked != null && (!lastAttacked.withinDistance(getTile(), 40) || lastAttacked.isDead())) { resetNpcs(); return; } if (getMinionType() == null) { if (unstable == null && sapping == null && enduring == null) return; if (unstable.defeated && enduring.defeated && !sapping.defeated) setMinionType(InheritedType.SAPPING); else if (unstable.defeated && !enduring.defeated && sapping.defeated) setMinionType(InheritedType.ENDURING); else if (!unstable.defeated && enduring.defeated && sapping.defeated) setMinionType(InheritedType.UNSTABLE); } if (getMinionType() == InheritedType.UNSTABLE && unstable.defeated) if (!startedTimer && !hasExploded) { getNextHitBars().add(new TimerBar(700)); startedTimer = true; WorldTasks.schedule(new Task() { @Override public void run() { if (thisNpc.getHitpoints() <= 0 || thisNpc.isDead()) return; for (Player player : World.getPlayersInChunkRange(getChunkId(), 1)) if (Utils.getDistance(thisNpc.getX(), thisNpc.getY(), player.getX(), player.getY()) < 3) player.applyHit(new Hit(player, player.getHitpoints() / 2, HitLook.TRUE_DAMAGE)); thisNpc.applyHit(new Hit(thisNpc, (int) (thisNpc.getHitpoints() * 0.80), HitLook.TRUE_DAMAGE)); thisNpc.setNextSpotAnim(new SpotAnim(739)); hasExploded = true; } }, 25); } } @Override public void sendDeath(Entity source) { final NPCCombatDefinitions defs = getCombatDefinitions(); resetWalkSteps(); getCombat().removeTarget(); setNextAnimation(null); deathReset(); WorldTasks.scheduleTimer(loop -> { if (loop == 0) setNextAnimation(new Animation(defs.getDeathEmote())); else if (loop >= defs.getDeathDelay()) { resetNpcs(); drop(); reset(); setLocation(getRespawnTile()); finish(); setRespawnTask(); return false; } return true; }); } @Override public void setRespawnTask() { if (!hasFinished()) { reset(); setLocation(getRespawnTile()); finish(); } final NPC npc = this; WorldTasks.schedule(getCombatDefinitions().getRespawnDelay(), () -> { try { setFinished(false); World.addNPC(npc); npc.setLastChunkId(0); ChunkManager.updateChunks(npc); loadMapRegions(); checkMultiArea(); } catch (Throwable e) { Logger.handle(Glacor.class, ""setRespawnTask"", e); } }); } public void spawnMinions() { setNextAnimation(new Animation(9964)); setNextSpotAnim(new SpotAnim(635)); unstable = new UnstableMinion(14302, Tile.of(getX() + 1, getY() + 1, getPlane()), -1, true, true, this); sapping = new SappingMinion(14303, Tile.of(getX() + 1, getY(), getPlane()), -1, true, true, this); enduring = new EnduringMinion(14304, Tile.of(getX() + 1, getY() - 1, getPlane()), -1, true, true, this); World.sendProjectile(this, unstable, 634, 60, 32, 50, 0.7, 0, 0); World.sendProjectile(this, sapping, 634, 60, 32, 50, 0.7, 0, 0); World.sendProjectile(this, enduring, 634, 60, 32, 50, 0.7, 0, 0); minionsSpawned = true; setStage(Stage.MINIONS); setCapDamage(0); } public InheritedType getMinionType() { return minionType; } public void setMinionType(InheritedType minionType) { this.minionType = minionType; } public boolean isMinionsSpawned() { return minionsSpawned; } public void setMinionsSpawned(boolean minionsSpawned) { this.minionsSpawned = minionsSpawned; } public Stage getStage() { return stage; } public void setStage(Stage stage) { this.stage = stage; } public static NPCInstanceHandler toFunc = new NPCInstanceHandler(14301, (npcId, tile) -> new Glacor(npcId, tile, false)); }" "package com.rs.game.content.bosses.glacor; public class GlacorCombat extends CombatScript { @Override public Object[] getKeys() { return new Object[] { 14301 }; } final int MAGE_PROJECTILE = 634; final int RANGE_PROJECTILE = 962; final int EXPLODE_GFX = 739; final int SPECIAL_PROJECTILE = 2314; int attackType = 0; @Override public int attack(NPC npc, final Entity target) { if (target instanceof NPC) { npc.setNextAnimation(new Animation(9968)); npc.setNextSpotAnim(new SpotAnim(905)); WorldProjectile p = World.sendProjectile(npc, target, SPECIAL_PROJECTILE, 60, 32, 50, 2, 0, 0); final Tile targetPosition = Tile.of(target.getX(), target.getY(), target.getPlane()); WorldTasks.schedule(new Task() { @Override public void run() { if ((target.getX() == targetPosition.getX()) && (target.getY() == targetPosition.getY())) target.applyHit(new Hit(target, 500, HitLook.TRUE_DAMAGE)); World.sendSpotAnim(targetPosition, new SpotAnim(2315)); } }, p.getTaskDelay()); return 0; } if (target instanceof Player player) { final Glacor glacor = (Glacor) npc; glacor.lastAttacked = player; attackType = Utils.random(1, 3); if (glacor.getMinionType() != null && glacor.getMinionType() == InheritedType.SAPPING) player.getPrayer().drainPrayer(50); if (Utils.random(100) < 10) attackType = 3; if (attackType == 1) { npc.setNextAnimation(new Animation(9967)); npc.setNextSpotAnim(new SpotAnim(902)); WorldProjectile p = World.sendProjectile(npc, target, MAGE_PROJECTILE, 60, 32, 50, 2, 0, 0); WorldTasks.schedule(new Task() { @Override public void run() { delayHit(npc, -1, target, getMagicHit(npc, getMaxHit(npc, 255, AttackStyle.MAGE, player))); } }, p.getTaskDelay()); if ((Utils.getRandomInclusive(100) > 80) && !player.hasEffect(Effect.FREEZE)) { player.setNextSpotAnim(new SpotAnim(369)); player.freeze(Ticks.fromSeconds(10)); } } else if (attackType == 2) { npc.setNextAnimation(new Animation(9968)); npc.setNextSpotAnim(new SpotAnim(905)); WorldProjectile p = World.sendProjectile(npc, target, RANGE_PROJECTILE, 60, 32, 50, 2, 0, 0); WorldTasks.schedule(new Task() { @Override public void run() { delayHit(npc, -1, target, getRangeHit(npc, getMaxHit(npc, 255, AttackStyle.RANGE, player))); } }, p.getTaskDelay()); } else if (attackType == 3) { npc.setNextAnimation(new Animation(9955)); npc.setNextSpotAnim(new SpotAnim(905)); WorldProjectile p = World.sendProjectile(npc, target, SPECIAL_PROJECTILE, 60, 32, 50, 1, 0, 0); final Tile targetPosition = Tile.of(player.getX(), player.getY(), player.getPlane()); WorldTasks.schedule(new Task() { @Override public void run() { if ((player.getX() == targetPosition.getX()) && (player.getY() == targetPosition.getY())) player.applyHit(new Hit(player, player.getHitpoints() / 2, HitLook.TRUE_DAMAGE)); World.sendSpotAnim(targetPosition, new SpotAnim(2315)); } }, p.getTaskDelay()); } } return 5; } }" "package com.rs.game.content.bosses.glacor; public class SappingGlacyteCombat extends CombatScript { @Override public Object[] getKeys() { return new Object[] { 14303 }; } @Override public int attack(NPC npc, Entity target) { NPCCombatDefinitions defs = npc.getCombatDefinitions(); int damage = 0; npc.setNextAnimation(new Animation(defs.getAttackEmote())); damage = getMaxHit(npc, defs.getMaxHit(), AttackStyle.MELEE, target); if (target instanceof Player player) player.getPrayer().drainPrayer(20); delayHit(npc, 0, target, getMeleeHit(npc, damage)); return npc.getAttackSpeed(); } }" "package com.rs.game.content.bosses.glacor; public class SappingMinion extends NPC { public Glacor parent; public boolean defeated = false; public SappingMinion(int id, Tile tile, int mapAreaNameHash, boolean canBeAttackFromOutOfArea, boolean spawned, Glacor parent) { super(id, tile, spawned); this.parent = parent; setForceAgressive(true); setForceMultiAttacked(true); } @Override public void processEntity() { super.processEntity(); if (getHitpoints() <= 0 || isDead()) { if (!defeated) World.sendProjectile(this, parent, 634, 34, 16, 30, 35, 16, 15); defeated = true; } } }" "package com.rs.game.content.bosses.glacor; public class UnstableMinion extends NPC { public Glacor parent; public boolean defeated = false; public boolean startedTimer = false; public boolean healing = false; public int gainedHp = 0; final int EXPLODE_GFX = 956; final NPC thisNpc = this; public UnstableMinion(int id, Tile tile, int mapAreaNameHash, boolean canBeAttackFromOutOfArea, boolean spawned, Glacor parent) { super(id, tile, spawned); this.parent = parent; setForceAgressive(true); setForceMultiAttacked(true); } @Override public void processEntity() { super.processEntity(); if ((getHitpoints() < 500) && !isDead() && (getHitpoints() != 0)) this.heal(10); if (!startedTimer && getHitpoints() > 500) { getNextHitBars().add(new TimerBar(700)); startedTimer = true; startExplosionTimer(); startStopMovingTimer(); } if (getHitpoints() <= 0 || isDead()) { if (!defeated) World.sendProjectile(this, parent, 634, 34, 16, 30, 35, 16, 15); defeated = true; } } public void startStopMovingTimer() { WorldTasks.schedule(new Task() { @Override public void run() { if (thisNpc.getHitpoints() <= 0 || thisNpc.isDead()) return; thisNpc.freeze(50000000); } }, 22); WorldTasks.schedule(new Task() { @Override public void run() { if (thisNpc.getHitpoints() <= 0 || thisNpc.isDead()) return; thisNpc.freeze(0); } }, 26); } public void startExplosionTimer() { WorldTasks.schedule(new Task() { @Override public void run() { if (thisNpc.getHitpoints() <= 0 || thisNpc.isDead()) return; for (Player player : queryNearbyPlayersByTileRange(2, player -> !player.isDead())) if (Utils.getDistance(thisNpc.getX(), thisNpc.getY(), player.getX(), player.getY()) < 2) player.applyHit(new Hit(player, player.getHitpoints() / 3, HitLook.TRUE_DAMAGE)); thisNpc.applyHit(new Hit(thisNpc, (int) (thisNpc.getHitpoints() * 0.90), HitLook.TRUE_DAMAGE)); thisNpc.setNextSpotAnim(new SpotAnim(EXPLODE_GFX)); startedTimer = false; } }, 25); } }" "package com.rs.game.content.bosses.godwars; public class GodWarMinion extends NPC { public GodWarMinion(int id, Tile tile, boolean spawned) { super(id, tile, spawned); setIgnoreDocile(true); setForceAgressive(true); setForceAggroDistance(64); setIntelligentRouteFinder(true); } public void respawn() { setFinished(false); World.addNPC(this); setLastChunkId(0); ChunkManager.updateChunks(this); loadMapRegions(); checkMultiArea(); } }" "package com.rs.game.content.bosses.godwars; @PluginEventHandler public class GodwarsController extends Controller { public static int SARADOMIN = 0; public static int ARMADYL = 1; public static int ZAROS = 2; public static int BANDOS = 3; public static int ZAMORAK = 4; private final int[] killcount = new int[5]; private long lastPrayerRecharge; @Override public void process() { updateKillcount(); } @Override public void start() { sendInterfaces(); } @Override public boolean logout() { return false; // so doesnt remove script } @Override public boolean login() { sendInterfaces(); return false; // so doesnt remove script } public static ObjectClickHandler handleZamorakEnter = new ObjectClickHandler(false, new Object[] { 26439 }, e -> e.getPlayer().setRouteEvent(new RouteEvent(Tile.of(e.getObject().getTile()), () -> { if (e.getPlayer().withinDistance(e.getObject().getTile(), 3)) { if (e.getPlayer().getY() < 5334) { if (e.getPlayer().getSkills().getLevel(Constants.HITPOINTS) >= 70) { e.getPlayer().useStairs(6999, Tile.of(2885, 5347, 2), 1, 1); e.getPlayer().getPrayer().drainPrayer(e.getPlayer().getPrayer().getPoints()); e.getPlayer().sendMessage(""You jump over the broken bridge. You feel the power of Zamorak take sap away at your prayer points.""); } else e.getPlayer().sendMessage(""You need a Constitution level of 70 to enter this area.""); } else e.getPlayer().useStairs(6999, Tile.of(2885, 5330, 2), 1, 1); } }))); @Override public boolean processObjectClick1(final GameObject object) { if (object.getId() == 26293) { player.useStairs(828, Tile.of(2916, 3746, 0), 0, 0); player.getControllerManager().forceStop(); return false; } if (object.getId() == 26287 || object.getId() == 26286 || object.getId() == 26288 || object.getId() == 26289) { if (lastPrayerRecharge >= System.currentTimeMillis()) { player.sendMessage(""You must wait a total of 10 minutes before being able to recharge your prayer points.""); return false; } else if (player.inCombat()) { player.sendMessage(""You cannot recharge your prayer while engaged in combat.""); return false; } player.getPrayer().restorePrayer(player.getSkills().getLevelForXp(Constants.PRAYER) * 10); player.setNextAnimation(new Animation(645)); player.sendMessage(""Your prayer points feel rejuvinated.""); lastPrayerRecharge = 600000 + System.currentTimeMillis(); return false; } if (object.getId() == 26444) { if (player.getSkills().getLevel(Constants.AGILITY) >= 70) player.useStairs(828, Tile.of(2914, 5300, 1), 1, 2); else player.sendMessage(""You need an Agility level of 70 to maneuver this obstacle.""); return false; } if (object.getId() == 26445) { if (player.getSkills().getLevel(Constants.AGILITY) >= 70) player.useStairs(828, Tile.of(2920, 5274, 0), 1, 2); else player.sendMessage(""You need an Agility level of 70 to maneuver this obstacle.""); return false; } if (object.getId() == 26427 && player.getX() >= 2908) { if (killcount[SARADOMIN] >= 40) { player.tele(Tile.of(2907, 5265, 0)); killcount[SARADOMIN] -= 40; updateKillcount(); } else player.sendMessage(""This door is locked by Saradomin and requires that you kill 40 of his minions before it is unlocked.""); return false; } if (object.getId() == 26303) { if (player.getSkills().getLevel(Skills.RANGE) >= 70) { boolean withinArmadyl = player.getY() < 5276; final Tile tile = Tile.of(2871, withinArmadyl ? 5279 : 5269, 2); player.lock(); player.getTasks().scheduleTimer(tick -> { switch(tick) { case 1 -> { player.setNextFaceTile(tile); player.setNextAnimation(new Animation(385)); } case 3 -> player.setNextAnimation(new Animation(16635)); case 4 -> { player.getAppearance().setHidden(true); World.sendProjectile(Tile.of(player.getTile()), tile, 605, 18, 18, 20, 0.6, 30, 0).getTaskDelay(); player.forceMove(tile, 0, 180, false, () -> { player.getAppearance().setHidden(false); player.setNextAnimation(new Animation(16672)); player.unlock(); player.resetReceivedHits(); }); return false; } } return true; }); } else player.sendMessage(""You need a Ranged level of 70 to cross this obstacle.""); return false; } if (object.getId() == 26426 && player.getY() <= 5295) { if (killcount[ARMADYL] >= 40) { player.tele(Tile.of(2839, 5296, 2)); killcount[ARMADYL] -= 40; updateKillcount(); } else player.sendMessage(""This door is locked by Armadyl and requires that you kill 40 of his minions before it is unlocked.""); return false; } if (object.getId() == 26428 && player.getY() >= 5332) { if (killcount[ZAMORAK] >= 40) { player.tele(Tile.of(2925, 5331, 2)); killcount[ZAMORAK] -= 40; updateKillcount(); } else player.sendMessage(""This door is locked by Zamorak and requires that you kill 40 of his minions before it is unlocked.""); return false; } if (object.getId() == 26425 && player.getX() <= 2863) { if (killcount[BANDOS] >= 40) { player.tele(Tile.of(2864, 5354, 2)); killcount[BANDOS] -= 40; updateKillcount(); } else player.sendMessage(""This door is locked by Bandos and requires that you kill 40 of his minions before it is unlocked.""); return false; } if (object.getId() == 26384) { if (player.getSkills().getLevel(Constants.STRENGTH) >= 70) { if (player.getInventory().containsItem(2347, 1)) { if (player.getX() == 2851) { player.sendMessage(""You bang on the door with your hammer.""); player.useStairs(11033, Tile.of(2850, 5333, 2), 1, 2); } else if (player.getX() == 2850) { player.sendMessage(""You bang on the door with your hammer.""); player.useStairs(11033, Tile.of(2851, 5333, 2), 1, 2); } } else player.sendMessage(""You need a hammer to be able to hit the gong to request entry.""); } else player.sendMessage(""You need a Strength level of 70 to enter this area.""); return false; } if (object.getId() == 57211) { if (player.getY() == 5279) { Item key = player.getInventory().getItemById(20120); if (key != null && key.getMetaData(""frozenKeyCharges"") != null && key.getMetaDataI(""frozenKeyCharges"") > 1) { player.useStairs(828, Tile.of(2885, 5275, 2), 1, 2); key.addMetaData(""frozenKeyCharges"", key.getMetaDataI(""frozenKeyCharges"")-1); if ((int) key.getMetaData(""frozenKeyCharges"") == 1) player.sendMessage(""Your frozen key breaks. You will have to repair it on a repair stand.""); else player.sendMessage(""A part of your key chips off. It looks like it will still work.""); } else player.sendMessage(""You require a frozen key with enough charges to enter.""); } else player.useStairs(828, Tile.of(2885, 5279, 2), 1, 2); return false; } if (object.getId() == 57260) { player.useStairs(828, Tile.of(2886, 5274, 2), 1, 2); return false; } if (object.getId() == 57254) { player.useStairs(828, Tile.of(2855, 5221, 0), 1, 2); return false; } if (object.getId() == 57234) { if (player.getX() == 2859) player.tele(Tile.of(player.getX() + 3, player.getY(), player.getPlane())); else if (player.getX() == 2862) player.tele(Tile.of(player.getX() - 3, player.getY(), player.getPlane())); return false; } if (object.getId() == 57258) { if (killcount[ZAROS] >= 40 || player.getEquipment().wearingFullCeremonial()) { if (player.getEquipment().wearingFullCeremonial()) player.sendMessage(""The door somehow recognizes your relevance to the area and allows you to pass through.""); player.tele(Tile.of(2900, 5204, 0)); } else player.sendMessage(""This door is locked by the power of Zaros. You will need to kill at least 40 of his followers before the door will open.""); return false; } if (object.getId() == 57225) { final NexArena globalInstance = NexArena.getGlobalInstance(); player.startConversation(new Dialogue().addSimple(""The room beyond this point is a prison! There is no way out other than death or teleport. Only those who endure dangerous encounters should proceed."") .addOption(""There are currently "" + globalInstance.getPlayersCount() + "" people fighting.
Do you wish to join them?"", ""Climb down."", ""Stay here."") .addNext(() -> { player.tele(Tile.of(2911, 5204, 0)); player.getControllerManager().startController(new NexController(globalInstance)); })); return false; } return true; } @Override public boolean processObjectClick2(GameObject object) { if (object.getId() == 26286) Magic.sendNormalTeleportNoType(player, Tile.of(2922, 5345, 2)); else if (object.getId() == 26287) Magic.sendNormalTeleportNoType(player, Tile.of(2912, 5268, 0)); else if (object.getId() == 26288) Magic.sendNormalTeleportNoType(player, Tile.of(2842, 5266, 2)); else if (object.getId() == 26289) Magic.sendNormalTeleportNoType(player, Tile.of(2837, 5355, 2)); return true; } @Override public void sendInterfaces() { player.getInterfaceManager().sendOverlay(601, true); player.getPackets().sendRunScriptReverse(1171); } @Override public boolean sendDeath() { remove(); removeController(); return true; } @Override public void onTeleported(TeleType type) { remove(); removeController(); } @Override public void forceClose() { remove(); } public void updateKillcount() { player.getVars().setVarBit(3938, killcount[SARADOMIN]); player.getVars().setVarBit(3939, killcount[ARMADYL]); player.getVars().setVarBit(8725, killcount[ZAROS]); player.getVars().setVarBit(3941, killcount[BANDOS]); player.getVars().setVarBit(3942, killcount[ZAMORAK]); } public void sendKill(int index) { killcount[index]++; updateKillcount(); } public void remove() { player.getInterfaceManager().removeOverlay(true); player.sendMessage(""The souls of those you have slain leave you as you exit the dungeon.""); } public static boolean isAtGodwars(Tile teleTile) { if (teleTile.getX() >= 2816 && teleTile.getY() >= 5185 && teleTile.getX() <= 2943 && teleTile.getY() <= 5375) return true; return false; } }" "package com.rs.game.content.bosses.godwars.armadyl; @PluginEventHandler public class ArmadylFactionNPC extends NPC { public ArmadylFactionNPC(int id, Tile tile, boolean spawned) { super(id, tile, spawned); setIgnoreDocile(true); setCanAggroNPCs(true); } @Override public boolean canBeAttackedBy(Player player) { if (!PlayerCombatKt.isRanging(player)) { player.sendMessage(""The aviansie is flying too high for you to attack using melee.""); return false; } return true; } @Override public boolean canAggroNPC(NPC npc) { return !(npc instanceof ArmadylFactionNPC); } @Override public boolean canAggroPlayer(Player player) { return !hasGodItem(player); } private boolean hasGodItem(Player player) { for (Item item : player.getEquipment().getItemsCopy()) { if (item == null) continue; String name = item.getDefinitions().getName().toLowerCase(); if (name.contains(""armadyl"") || name.contains(""book of law"") || ZarosFactionNPC.isNexArmour(name) || item.getId() == 19614) return true; } return false; } public static NPCInstanceHandler toAbyssalDemon = new NPCInstanceHandler(new Object[] { 6228, 6229, 6230, 6231, 6232, 6233, 6234, 6235, 6236, 6237, 6238, 6239, 6240, 6241, 6242, 6243, 6244, 6245, 6246 }, (npcId, tile) -> new ArmadylFactionNPC(npcId, tile, false)); }" "package com.rs.game.content.bosses.godwars.armadyl; @PluginEventHandler public class KreeArra extends NPC { private final GodWarMinion[] minions = new GodWarMinion[3]; public KreeArra(int id, Tile tile, boolean spawned) { super(id, tile, spawned); setIntelligentRouteFinder(true); setIgnoreDocile(true); setForceAggroDistance(64); minions[0] = new GodWarMinion(6223, tile.transform(8, 0), spawned); minions[1] = new GodWarMinion(6225, tile.transform(-4, -2), spawned); minions[2] = new GodWarMinion(6227, tile.transform(-2, -4), spawned); } @Override public void onRespawn() { respawnMinions(); } public void respawnMinions() { WorldTasks.schedule(2, () -> { for (GodWarMinion minion : minions) if (minion.hasFinished() || minion.isDead()) minion.respawn(); }); } @Override public boolean canBeAttackedBy(Player player) { if (!PlayerCombatKt.isRanging(player)) { player.sendMessage(""Kree'arra is flying too high for you to attack using melee.""); return false; } return true; } public static NPCInstanceHandler toFunc = new NPCInstanceHandler(6222, (npcId, tile) -> new KreeArra(npcId, tile, false)); }" "package com.rs.game.content.bosses.godwars.armadyl; public class KreeArraCombat extends CombatScript { @Override public Object[] getKeys() { return new Object[] { 6222 }; } @Override public int attack(NPC npc, Entity target) { if (!npc.isUnderCombat()) { npc.setNextAnimation(new Animation(6997)); delayHit(npc, 1, target, getMeleeHit(npc, getMaxHit(npc, 260, AttackStyle.MELEE, target))); return npc.getAttackSpeed(); } npc.setNextAnimation(new Animation(6976)); for (Entity t : npc.getPossibleTargets()) if (Utils.getRandomInclusive(2) == 0) { WorldProjectile p = World.sendProjectile(npc, t, 1198, 60, 32, 50, 1, 0, 0); npc.setNextAnimation(new Animation(6976)); delayHit(npc, p.getTaskDelay(), t, getMagicHit(npc, getMaxHit(npc, 210, AttackStyle.MAGE, t))); t.setNextSpotAnim(new SpotAnim(1196, p.getTaskDelay())); } else { WorldProjectile p = World.sendProjectile(npc, t, 1197, 60, 32, 50, 1, 0, 0); delayHit(npc, p.getTaskDelay(), t, getRangeHit(npc, getMaxHit(npc, 720, AttackStyle.RANGE, t))); WorldTasks.schedule(p.getTaskDelay(), () -> { Direction dir = WorldUtil.getDirectionTo(npc, target); if (dir != null) if (World.checkWalkStep(target.getTile(), dir, target.getSize())) { target.resetWalkSteps(); target.tele(target.transform(dir.dx, dir.dy)); } }); } return npc.getAttackSpeed(); } }" "package com.rs.game.content.bosses.godwars.bandos; @PluginEventHandler public class BandosFactionNPC extends NPC { public BandosFactionNPC(int id, Tile tile, boolean spawned) { super(id, tile, spawned); setIgnoreDocile(true); setCanAggroNPCs(true); } @Override public boolean canAggroNPC(NPC npc) { return !(npc instanceof BandosFactionNPC); } @Override public boolean canAggroPlayer(Player player) { return !hasGodItem(player); } private boolean hasGodItem(Player player) { for (Item item : player.getEquipment().getItemsCopy()) { if (item == null) continue; // shouldn't happen String name = item.getDefinitions().getName().toLowerCase(); if (name.contains(""bandos"") || name.contains(""book of war"") || name.contains(""ancient mace"") || name.contains(""granite mace"") || ZarosFactionNPC.isNexArmour(name) || item.getId() == 19612) return true; } return false; } public static NPCInstanceHandler toFunc = new NPCInstanceHandler(new Object[] { 6268, 6269, 6270, 6271, 6272, 6273, 6274, 6275, 6276, 6277, 6278, 6279, 6280, 6281, 6282, 6283 }, (npcId, tile) -> new BandosFactionNPC(npcId, tile, false)); }" "package com.rs.game.content.bosses.godwars.bandos; @PluginEventHandler public class GeneralGraardor extends NPC { private final GodWarMinion[] minions = new GodWarMinion[3]; public GeneralGraardor(int id, Tile tile, boolean spawned) { super(id, tile, spawned); setForceFollowClose(true); setIntelligentRouteFinder(true); setIgnoreDocile(true); minions[0] = new GodWarMinion(6261, tile.transform(-8, 0), spawned); minions[1] = new GodWarMinion(6263, tile.transform(0, -6), spawned); minions[2] = new GodWarMinion(6265, tile.transform(-4, 4), spawned); } @Override public void onRespawn() { respawnMinions(); } public void respawnMinions() { WorldTasks.schedule(2, () -> { for (GodWarMinion minion : minions) if (minion.hasFinished() || minion.isDead()) minion.respawn(); }); } public static NPCInstanceHandler toFunc = new NPCInstanceHandler(6260, (npcId, tile) -> new GeneralGraardor(npcId, tile, false)); }" "package com.rs.game.content.bosses.godwars.bandos; public class GeneralGraardorCombat extends CombatScript { @Override public Object[] getKeys() { return new Object[] { 6260 }; } @Override public int attack(final NPC npc, final Entity target) { final NPCCombatDefinitions defs = npc.getCombatDefinitions(); if (Utils.getRandomInclusive(4) == 0) switch (Utils.getRandomInclusive(10)) { case 0: npc.setNextForceTalk(new ForceTalk(""Death to our enemies!"")); npc.voiceEffect(target, 3219, true); break; case 1: npc.setNextForceTalk(new ForceTalk(""Brargh!"")); npc.voiceEffect(target, 3209, true); break; case 2: npc.setNextForceTalk(new ForceTalk(""Break their bones!"")); break; case 3: npc.setNextForceTalk(new ForceTalk(""For the glory of Bandos!"")); break; case 4: npc.setNextForceTalk(new ForceTalk(""Split their skulls!"")); npc.voiceEffect(target, 3229, true); break; case 5: npc.setNextForceTalk(new ForceTalk(""We feast on the bones of our enemies tonight!"")); npc.voiceEffect(target, 3206, true); break; case 6: npc.setNextForceTalk(new ForceTalk(""CHAAARGE!"")); npc.voiceEffect(target, 3220, true); break; case 7: npc.setNextForceTalk(new ForceTalk(""Crush them underfoot!"")); npc.voiceEffect(target, 3224, true); break; case 8: npc.setNextForceTalk(new ForceTalk(""All glory to Bandos!"")); npc.voiceEffect(target, 3205, true); break; case 9: npc.setNextForceTalk(new ForceTalk(""GRAAAAAAAAAR!"")); npc.voiceEffect(target, 3207, true); break; case 10: npc.setNextForceTalk(new ForceTalk(""FOR THE GLORY OF THE BIG HIGH WAR GOD!"")); break; } if (Utils.getRandomInclusive(2) == 0) { // range magical attack npc.setNextAnimation(new Animation(7063)); for (Entity t : npc.getPossibleTargets()) { WorldProjectile p = World.sendProjectile(npc, target, 1200, 60, 32, 50, 1, 0, 0); delayHit(npc, p.getTaskDelay(), t, getRangeHit(npc, getMaxHit(npc, 355, AttackStyle.RANGE, t))); } } else { // melee attack npc.setNextAnimation(new Animation(defs.getAttackEmote())); delayHit(npc, 0, target, getMeleeHit(npc, getMaxHit(npc, defs.getMaxHit(), AttackStyle.MELEE, target))); } return npc.getAttackSpeed(); } }" "package com.rs.game.content.bosses.godwars.saradomin; @PluginEventHandler public class CommanderZilyana extends NPC { private final GodWarMinion[] minions = new GodWarMinion[3]; public CommanderZilyana(int id, Tile tile, boolean spawned) { super(id, tile, spawned); setIntelligentRouteFinder(true); setForceFollowClose(true); setIgnoreDocile(true); minions[0] = new GodWarMinion(6248, tile.transform(4, -4), spawned); minions[1] = new GodWarMinion(6250, tile.transform(0, -6), spawned); minions[2] = new GodWarMinion(6252, tile.transform(4, 2), spawned); } @Override public void onRespawn() { respawnMinions(); } public void respawnMinions() { WorldTasks.schedule(2, () -> { for (GodWarMinion minion : minions) if (minion.hasFinished() || minion.isDead()) minion.respawn(); }); } public static NPCInstanceHandler toFunc = new NPCInstanceHandler(6247, (npcId, tile) -> new CommanderZilyana(npcId, tile, false)); }" "package com.rs.game.content.bosses.godwars.saradomin; public class CommanderZilyanaCombat extends CombatScript { @Override public Object[] getKeys() { return new Object[] { 6247 }; } @Override public int attack(final NPC npc, final Entity target) { final NPCCombatDefinitions defs = npc.getCombatDefinitions(); if (Utils.getRandomInclusive(4) == 0) switch (Utils.getRandomInclusive(9)) { case 0: npc.setNextForceTalk(new ForceTalk(""Death to the enemies of the light!"")); npc.voiceEffect(target, 3247, true); break; case 1: npc.setNextForceTalk(new ForceTalk(""Slay the evil ones!"")); npc.voiceEffect(target, 3242, true); break; case 2: npc.setNextForceTalk(new ForceTalk(""Saradomin lend me strength!"")); npc.voiceEffect(target, 3263, true); break; case 3: npc.setNextForceTalk(new ForceTalk(""By the power of Saradomin!"")); npc.voiceEffect(target, 3262, true); break; case 4: npc.setNextForceTalk(new ForceTalk(""May Saradomin be my sword."")); npc.voiceEffect(target, 3251, true); break; case 5: npc.setNextForceTalk(new ForceTalk(""Good will always triumph!"")); npc.voiceEffect(target, 3260, true); break; case 6: npc.setNextForceTalk(new ForceTalk(""Forward! Our allies are with us!"")); npc.voiceEffect(target, 3245, true); break; case 7: npc.setNextForceTalk(new ForceTalk(""Saradomin is with us!"")); npc.voiceEffect(target, 3266, true); break; case 8: npc.setNextForceTalk(new ForceTalk(""In the name of Saradomin!"")); npc.voiceEffect(target, 3250, true); break; case 9: npc.setNextForceTalk(new ForceTalk(""Attack! Find the Godsword!"")); npc.voiceEffect(target, 3258, true); break; } if (Utils.getRandomInclusive(1) == 0) { // mage magical attack npc.setNextAnimation(new Animation(6967)); for (Entity t : npc.getPossibleTargets()) { if (!t.withinDistance(npc.getTile(), 3)) continue; int damage = getMaxHit(npc, defs.getMaxHit(), AttackStyle.MAGE, t); if (damage > 0) { delayHit(npc, 1, t, getMagicHit(npc, damage)); t.setNextSpotAnim(new SpotAnim(1194)); } } } else { // melee attack npc.setNextAnimation(new Animation(defs.getAttackEmote())); delayHit(npc, 0, target, getMeleeHit(npc, getMaxHit(npc, defs.getMaxHit(), AttackStyle.MELEE, target))); } return npc.getAttackSpeed(); } }" "package com.rs.game.content.bosses.godwars.saradomin; @PluginEventHandler public class SaradominFactionNPC extends NPC { public SaradominFactionNPC(int id, Tile tile, boolean spawned) { super(id, tile, spawned); setIgnoreDocile(true); setCanAggroNPCs(true); } @Override public boolean canAggroNPC(NPC npc) { return !(npc instanceof SaradominFactionNPC); } @Override public boolean canAggroPlayer(Player player) { return !hasGodItem(player); } public static boolean hasGodItem(Player player) { for (Item item : player.getEquipment().getItemsCopy()) { if (item == null) continue; // shouldn't happen String name = item.getDefinitions().getName().toLowerCase(); // using else as only one item should count if (name.contains(""saradomin"") || name.contains(""holy symbol"") || name.contains(""holy book"") || name.contains(""monk"") || name.contains(""citharede"") || ZarosFactionNPC.isNexArmour(name) || item.getId() == 3839) return true; } return false; } public static NPCInstanceHandler toFunc = new NPCInstanceHandler(new Object[] { 6254, 6255, 6256, 6257, 6258, 6259 }, (npcId, tile) -> new SaradominFactionNPC(npcId, tile, false)); }" "package com.rs.game.content.bosses.godwars.zamorak; @PluginEventHandler public class KrilTstsaroth extends NPC { private final GodWarMinion[] minions = new GodWarMinion[3]; public KrilTstsaroth(int id, Tile tile, boolean spawned) { super(id, tile, spawned); setIntelligentRouteFinder(true); setIgnoreDocile(true); setForceAggroDistance(64); minions[0] = new GodWarMinion(6204, tile.transform(8, 4), spawned); minions[1] = new GodWarMinion(6206, tile.transform(-6, 6), spawned); minions[2] = new GodWarMinion(6208, tile.transform(-6, -2), spawned); } @Override public void onRespawn() { respawnMinions(); } public void respawnMinions() { WorldTasks.schedule(2, () -> { for (GodWarMinion minion : minions) if (minion.hasFinished() || minion.isDead()) minion.respawn(); }); } public static NPCInstanceHandler toFunc = new NPCInstanceHandler(6203, (npcId, tile) -> new KrilTstsaroth(npcId, tile, false)); }" "package com.rs.game.content.bosses.godwars.zamorak; public class KrilTsutsaroth extends CombatScript { @Override public Object[] getKeys() { return new Object[] { 6203 }; } @Override public int attack(NPC npc, Entity target) { if (Utils.getRandomInclusive(4) == 0) switch (Utils.getRandomInclusive(8)) { case 0: npc.setNextForceTalk(new ForceTalk(""Attack them, you dogs!"")); break; case 1: npc.setNextForceTalk(new ForceTalk(""Forward!"")); break; case 2: npc.setNextForceTalk(new ForceTalk(""Death to Saradomin's dogs!"")); break; case 3: npc.setNextForceTalk(new ForceTalk(""Kill them, you cowards!"")); break; case 4: npc.setNextForceTalk(new ForceTalk(""The Dark One will have their souls!"")); npc.voiceEffect(target, 3229, true); break; case 5: npc.setNextForceTalk(new ForceTalk(""Zamorak curse them!"")); break; case 6: npc.setNextForceTalk(new ForceTalk(""Rend them limb from limb!"")); break; case 7: npc.setNextForceTalk(new ForceTalk(""No retreat!"")); break; case 8: npc.setNextForceTalk(new ForceTalk(""Flay them all!"")); break; } int attackStyle = Utils.getRandomInclusive(2); switch (attackStyle) { case 0:// magic flame attack npc.setNextAnimation(new Animation(14962)); npc.setNextSpotAnim(new SpotAnim(1210)); for (Entity t : npc.getPossibleTargets()) { delayHit(npc, 1, t, getMagicHit(npc, getMaxHit(npc, 300, AttackStyle.MAGE, t))); World.sendProjectile(npc, t, 1211, 41, 16, 41, 35, 16, 0); if (Utils.getRandomInclusive(4) == 0) t.getPoison().makePoisoned(168); } break; case 1:// main attack case 2:// melee attack int damage = 300;// normal for (Entity e : npc.getPossibleTargets()) { if (e instanceof Player player && ((Player) e).getPrayer().isProtectingMelee() && Utils.random(10) == 0) { damage = 497; npc.setNextForceTalk(new ForceTalk(""YARRRRRRR!"")); player.getPrayer().drainPrayer(player.getPrayer().getPoints()/2); player.sendMessage(""K'ril Tsutsaroth slams through your protection prayer, leaving you feeling drained.""); } npc.setNextAnimation(new Animation(damage <= 463 ? 14963 : 14968)); delayHit(npc, 0, e, getMeleeHit(npc, getMaxHit(npc, damage, AttackStyle.MELEE, e))); } break; } return npc.getAttackSpeed(); } }" "package com.rs.game.content.bosses.godwars.zamorak; @PluginEventHandler public class ZamorakFactionNPC extends NPC { public ZamorakFactionNPC(int id, Tile tile, boolean spawned) { super(id, tile, spawned); setIgnoreDocile(true); setCanAggroNPCs(true); } @Override public boolean canAggroNPC(NPC npc) { return !(npc instanceof ZamorakFactionNPC); } @Override public boolean canAggroPlayer(Player player) { return !hasGodItem(player); } public static boolean hasGodItem(Player player) { for (Item item : player.getEquipment().getItemsCopy()) { if (item == null || item.getId() == -1) continue; // shouldn't happen String name = item.getDefinitions().getName().toLowerCase(); if (name.contains(""zamorak"") || name.contains(""unholy"") || ZarosFactionNPC.isNexArmour(name) || item.getId() == 3841) return true; } return false; } public static NPCInstanceHandler toFunc = new NPCInstanceHandler(new Object[] { 6210, 6211, 6212, 6213, 6214, 6215, 6216, 6217, 6218, 6219, 6220, 6221 }, (npcId, tile) -> new ZamorakFactionNPC(npcId, tile, false)); }" "package com.rs.game.content.bosses.godwars.zaros; public class AncientMageCombat extends CombatScript { @Override public Object[] getKeys() { return new Object[] { 13459 }; } @Override public int attack(NPC npc, Entity target) { final NPCCombatDefinitions defs = npc.getCombatDefinitions(); int spellType = Utils.getRandomInclusive(3); Hit hit = getMagicHit(npc, getMaxHit(npc, defs.getMaxHit(), AttackStyle.MAGE, target)); npc.setNextAnimation(new Animation(defs.getAttackEmote())); if (spellType == 0) { World.sendProjectile(npc, target, 386, 18, 18, 50, 50, 0, 0); delayHit(npc, 2, target, hit); } else if (spellType == 1) { World.sendProjectile(npc, target, 380, 18, 18, 50, 50, 0, 0); delayHit(npc, 2, target, hit); } else if (spellType == 2) { World.sendProjectile(npc, target, 374, 18, 18, 50, 50, 0, 0);// blood delayHit(npc, 2, target, hit); npc.heal(hit.getDamage() / 3); } else if (spellType == 3) { World.sendProjectile(npc, target, 362, 18, 18, 50, 50, 0, 0); // ice delayHit(npc, 2, target, hit); if (hit.getDamage() > 0 && !target.hasEffect(Effect.FREEZE)) { target.setNextSpotAnim(new SpotAnim(369)); target.freeze(Ticks.fromSeconds(10)); } } else { World.sendProjectile(npc, target, 386, 18, 18, 50, 50, 0, 0); // ice delayHit(npc, 2, target, hit); } return npc.getAttackSpeed(); } }" "package com.rs.game.content.bosses.godwars.zaros; @PluginEventHandler public final class Nex extends NPC { public enum Phase { SMOKE, SHADOW, BLOOD, ICE, ZAROS } private final NexArena arena; private boolean followTarget; private Phase phase; private int minionStage; private int attackCount = 0; private long ticksLastAttack; private final NPC[] bloodReavers; public Nex(NexArena arena, Tile tile) { super(13447, tile, true); this.arena = arena; setCantInteract(true); setCapDamage(500); setLureDelay(3000); setIntelligentRouteFinder(true); setRun(true); bloodReavers = new NPC[3]; setIgnoreDocile(true); phase = Phase.SMOKE; attackCount = 1; refreshTicksAttacked(); } public static ObjectClickHandler handleIcePrison = new ObjectClickHandler(new Object[] { 57263 }, e -> { if (e.getPlayer().getTempAttribs().getB(""inIcePrison"")) { e.getPlayer().sendMessage(""You can't move!""); return; } e.getPlayer().setNextAnimation(new Animation(PlayerCombatKt.getWeaponAttackEmote(e.getPlayer().getEquipment().getWeaponId(), e.getPlayer().getCombatDefinitions().getAttackStyle()))); e.getPlayer().lock(2); World.removeObject(e.getObject()); }); @Override public void processNPC() { if (phase == Phase.SMOKE && minionStage == 0 && getHitpoints() <= 24000) { setCapDamage(0); setNextForceTalk(new ForceTalk(""Fumus, don't fail me!"")); getCombat().addCombatDelay(1); arena.breakFumusBarrier(); voiceEffect(3321, true); minionStage = 1; } else if (phase == Phase.SHADOW && minionStage == 1 && getHitpoints() <= 18000) { setCapDamage(0); setNextForceTalk(new ForceTalk(""Umbra, don't fail me!"")); getCombat().addCombatDelay(1); arena.breakUmbraBarrier(); voiceEffect(3307, true); minionStage = 2; } else if (phase == Phase.BLOOD && minionStage == 2 && getHitpoints() <= 12000) { setCapDamage(0); setNextForceTalk(new ForceTalk(""Cruor, don't fail me!"")); getCombat().addCombatDelay(1); arena.breakCruorBarrier(); voiceEffect(3298, true); minionStage = 3; } else if (phase == Phase.ICE && minionStage == 3 && getHitpoints() <= 6000) { setCapDamage(0); setNextForceTalk(new ForceTalk(""Glacies, don't fail me!"")); getCombat().addCombatDelay(1); arena.breakGlaciesBarrier(); voiceEffect(3327, true); minionStage = 4; } if (isDead() || isCantInteract()) return; if (!getCombat().process()) { checkAggressivity(); if (getTarget() == null) return; Entity target = getTarget(); int maxDistance = isFollowTarget() ? 0 : 9; if ((!lineOfSightTo(target, isFollowTarget())) || !WorldUtil.isInRange(getX(), getY(), getSize(), target.getX(), target.getY(), target.getSize(), maxDistance)) { resetWalkSteps(); if (!WorldUtil.isInRange(getX(), getY(), getSize(), target.getX(), target.getY(), target.getSize(), 5)) { Tile tile = target.getNearestTeleTile(this); if (tile == null) tile = Tile.of(target.getTile()); if (World.floorAndWallsFree(tile, getSize())) { forceMove(tile, 6985, 0, 30); return; } } else calcFollow(target, 2, true); return; } resetWalkSteps(); } } @Override public void sendDeath(Entity source) { transformIntoNPC(13450); final NPCCombatDefinitions defs = getCombatDefinitions(); WorldTasks.scheduleTimer(tick -> { if (tick == 0) setNextAnimation(new Animation(defs.getDeathEmote())); else if (tick >= defs.getDeathDelay()*2) { //TODO need to redo all npc death timers since they're increment of 2 ticks.. drop(); reset(); finish(); arena.endWar(); return false; } return true; }); setNextForceTalk(new ForceTalk(""Taste my wrath!"")); voiceEffect(3323, true); sendWrath(); } public void sendWrath() { setNextSpotAnim(new SpotAnim(2259)); sendWrathProj(this, Tile.of(getX() + 3, getY() + 3, getPlane()), 0.4); sendWrathProj(this, Tile.of(getX() + 3, getY(), getPlane()), 0.4); sendWrathProj(this, Tile.of(getX() + 3, getY() - 3, getPlane()), 0.4); sendWrathProj(this, Tile.of(getX() - 3, getY() + 3, getPlane()), 0.4); sendWrathProj(this, Tile.of(getX() - 3, getY(), getPlane()), 0.4); sendWrathProj(this, Tile.of(getX() - 3, getY() - 3, getPlane()), 0.4); sendWrathProj(this, Tile.of(getX(), getY() + 3, getPlane()), 0.4); sendWrathProj(this, Tile.of(getX(), getY() - 3, getPlane()), 0.4); sendWrathProj(this, Tile.of(getX() + 2, getY() - 2, getPlane()), 0.4); sendWrathProj(this, Tile.of(getX() - 2, getY() + 2, getPlane()), 0.4); sendWrathProj(this, Tile.of(getX() + 2, getY() + 2, getPlane()), 0.4); sendWrathProj(this, Tile.of(getX() - 2, getY() - 2, getPlane()), 0.4); WorldTasks.schedule(new Task() { @Override public void run() { List possibleTargets = getPossibleTargets(); if (possibleTargets != null) for (Entity entity : possibleTargets) { if (entity == null || entity.isDead() || entity.hasFinished() || !entity.withinDistance(getTile(), 5)) continue; entity.applyHit(new Hit(Nex.this, Utils.getRandomInclusive(600), HitLook.TRUE_DAMAGE)); } } }, 5); } public static void sendWrathProj(Entity nex, Tile tile, double speed) { World.sendProjectile(nex, tile, 2261, 24, 0, 1, speed, 30, p -> World.sendSpotAnim(tile, new SpotAnim(2260))); } public ArrayList calculatePossibleTargets(Tile current, Tile position, boolean northSouth) { ArrayList list = new ArrayList<>(); for (Entity e : getPossibleTargets()) if (e.inArea(current.getX(), current.getY(), position.getX() + (northSouth ? 2 : 0), position.getY() + (!northSouth ? 2 : 0)) || e.inArea(position.getX(), position.getY(), current.getX() + (northSouth ? 2 : 0), current.getY() + (!northSouth ? 2 : 0))) list.add(e); return list; } public void nextPhase() { if (phase == Phase.SMOKE && minionStage == 1) { setCapDamage(500); setNextForceTalk(new ForceTalk(""Darken my shadow!"")); World.sendProjectile(arena.umbra, this, 2244, 18, 18, 60, 30, 0, 0); getCombat().addCombatDelay(1); voiceEffect(3302, true); } else if (phase == Phase.SHADOW && minionStage == 2) { setCapDamage(500); setNextForceTalk(new ForceTalk(""Flood my lungs with blood!"")); World.sendProjectile(arena.cruor, this, 2244, 18, 18, 60, 30, 0, 0); getCombat().addCombatDelay(1); voiceEffect(3306, true); } else if (phase == Phase.BLOOD && minionStage == 3) { setCapDamage(500); killBloodReavers(); setNextForceTalk(new ForceTalk(""Infuse me with the power of ice!"")); World.sendProjectile(arena.glacies, this, 2244, 18, 18, 60, 30, 0, 0); getCombat().addCombatDelay(1); voiceEffect(3303, true); } else if (phase == Phase.ICE && minionStage == 4) { setCapDamage(500); setNextForceTalk(new ForceTalk(""NOW, THE POWER OF ZAROS!"")); setNextAnimation(new Animation(6326)); setNextSpotAnim(new SpotAnim(1204)); getCombat().addCombatDelay(1); heal(6000); voiceEffect(3312, true); } } public void checkPhase() { switch(phase) { case SMOKE: if (minionStage == 1 && (arena.fumus == null || arena.fumus.isDead() || arena.fumus.hasFinished())) setPhase(Phase.SHADOW); break; case SHADOW: if (minionStage == 2 && (arena.umbra == null || arena.umbra.isDead() || arena.umbra.hasFinished())) setPhase(Phase.BLOOD); break; case BLOOD: if (minionStage == 3 && (arena.cruor == null || arena.cruor.isDead() || arena.cruor.hasFinished())) setPhase(Phase.ICE); break; case ICE: if (minionStage == 4 && (arena.glacies == null || arena.glacies.isDead() || arena.glacies.hasFinished())) setPhase(Phase.ZAROS); break; default: break; } } public void switchPrayers() { if (isDead()) return; transformIntoNPC(getId() == 13449 ? 13447 : getId() + 1); } @Override public void handlePreHit(Hit hit) { checkPhase(); if (getTempAttribs().getB(""siphoning"")) hit.setHealHit(); if (getId() == 13449 && hit.getLook() == HitLook.MELEE_DAMAGE) { Entity source = hit.getSource(); if (source != null) { int deflectedDamage = (int) (hit.getDamage() * 0.1); hit.setDamage((int) (hit.getDamage() * source.getMeleePrayerMultiplier())); if (deflectedDamage > 0) source.applyHit(new Hit(this, deflectedDamage, HitLook.REFLECTED_DAMAGE)); } } super.handlePreHit(hit); } @Override public void setNextAnimation(Animation nextAnimation) { if (getTempAttribs().getB(""siphoning"")) return; super.setNextAnimation(nextAnimation); } @Override public void setNextSpotAnim(SpotAnim nextGraphic) { if (getTempAttribs().getB(""siphoning"")) return; super.setNextSpotAnim(nextGraphic); } @Override public double getMagePrayerMultiplier() { return 0.6; } @Override public double getRangePrayerMultiplier() { return 0.6; } @Override public double getMeleePrayerMultiplier() { return 0.6; } @Override public List getPossibleTargets() { return arena.getPossibleTargets(); } public boolean isFollowTarget() { return followTarget; } public void setFollowTarget(boolean followTarget) { this.followTarget = followTarget; } public void setPhase(Phase phase) { this.phase = phase; attackCount = 0; } public NPC[] getBloodReavers() { return bloodReavers; } public void killBloodReavers() { for (int index = 0; index < bloodReavers.length; index++) { if (bloodReavers[index] == null) continue; NPC npc = bloodReavers[index]; bloodReavers[index] = null; if (npc.isDead()) return; heal(npc.getHitpoints()); npc.sendDeath(this); } } public Phase getPhase() { return phase; } public NexArena getArena() { return arena; } public int getAttackCount() { return attackCount; } public void incrementAttack() { refreshTicksAttacked(); attackCount++; } public int performAttack(Entity target, NexAttack attack) { incrementAttack(); return attack.attack(this, target); } public boolean shouldStopMeleeing() { return World.getServerTicks() - ticksLastAttack > 20; } public void refreshTicksAttacked() { ticksLastAttack = World.getServerTicks(); } }" "package com.rs.game.content.bosses.godwars.zaros; public class NexArena { private static final NexArena GLOBAL_INSTANCE = new NexArena(); public static NexArena getGlobalInstance() { return GLOBAL_INSTANCE; } private final List players = Collections.synchronizedList(new ArrayList<>()); public Nex nex; public NexMinion fumus; public NexMinion umbra; public NexMinion cruor; public NexMinion glacies; public int getPlayersCount() { return players.size(); } public void breakFumusBarrier() { if (fumus == null) return; fumus.breakBarrier(); } public void breakUmbraBarrier() { if (umbra == null) return; umbra.breakBarrier(); } public void breakCruorBarrier() { if (cruor == null) return; cruor.breakBarrier(); } public void breakGlaciesBarrier() { if (glacies == null) return; glacies.breakBarrier(); } public void addPlayer(Player player) { if (players.contains(player)) return; players.add(player); startWar(); } public void removePlayer(Player player) { players.remove(player); cancelWar(); } public void deleteNPCS() { if (nex != null) { nex.killBloodReavers(); nex.finish(); nex = null; } if (fumus != null) { fumus.finish(); fumus = null; } if (umbra != null) { umbra.finish(); umbra = null; } if (cruor != null) { cruor.finish(); cruor = null; } if (glacies != null) { glacies.finish(); glacies = null; } } private void cancelWar() { if (getPlayersCount() == 0) deleteNPCS(); } public List getPossibleTargets() { ArrayList possibleTarget = new ArrayList<>(players.size()); for (Player player : players) { if (player == null || player.isDead() || player.hasFinished() || !player.isRunning()) continue; possibleTarget.add(player); } return possibleTarget; } public void moveNextStage() { if (nex == null) return; nex.nextPhase(); } public void endWar() { deleteNPCS(); WorldTasks.schedule(Ticks.fromMinutes(1), () -> { try { startWar(); } catch (Throwable e) { Logger.handle(NexArena.class, ""endWar"", e); } }); } private void startWar() { if (getPlayersCount() >= 1) if (nex == null) { nex = new Nex(this, Tile.of(2924, 5202, 0)); WorldTasks.scheduleLooping(new Task() { private int count = 0; @Override public void run() { if (nex == null) { stop(); return; } if (count == 1) { nex.setNextForceTalk(new ForceTalk(""AT LAST!"")); nex.setNextAnimation(new Animation(6355)); nex.setNextSpotAnim(new SpotAnim(1217)); nex.voiceEffect(3295, true); } else if (count == 3) { fumus = new NexMinion(NexArena.this, 13451, Tile.of(2912, 5216, 0)); fumus.setFaceAngle(Utils.getAngleTo(1, -1)); nex.setNextFaceTile(Tile.of(fumus.getCoordFaceX(fumus.getSize()), fumus.getCoordFaceY(fumus.getSize()), 0)); nex.setNextForceTalk(new ForceTalk(""Fumus!"")); nex.setNextAnimation(new Animation(6987)); World.sendProjectile(fumus, nex, 2244, 18, 18, 60, 30, 0, 0); nex.voiceEffect(3325, true); } else if (count == 5) { umbra = new NexMinion(NexArena.this, 13452, Tile.of(2937, 5216, 0)); umbra.setFaceAngle(Utils.getAngleTo(-1, -1)); nex.setNextFaceTile(Tile.of(umbra.getCoordFaceX(umbra.getSize()), umbra.getCoordFaceY(umbra.getSize()), 0)); nex.setNextForceTalk(new ForceTalk(""Umbra!"")); nex.setNextAnimation(new Animation(6987)); World.sendProjectile(umbra, nex, 2244, 18, 18, 60, 30, 0, 0); nex.voiceEffect(3313, true); } else if (count == 7) { cruor = new NexMinion(NexArena.this, 13453, Tile.of(2937, 5190, 0)); cruor.setFaceAngle(Utils.getAngleTo(-1, 1)); nex.setNextFaceTile(Tile.of(cruor.getCoordFaceX(cruor.getSize()), cruor.getCoordFaceY(cruor.getSize()), 0)); nex.setNextForceTalk(new ForceTalk(""Cruor!"")); nex.setNextAnimation(new Animation(6987)); World.sendProjectile(cruor, nex, 2244, 18, 18, 60, 30, 0, 0); nex.voiceEffect(3299, true); } else if (count == 9) { glacies = new NexMinion(NexArena.this, 13454, Tile.of(2912, 5190, 0)); glacies.setNextFaceTile(Tile.of(glacies.getCoordFaceX(glacies.getSize()), glacies.getCoordFaceY(glacies.getSize()), 0)); glacies.setFaceAngle(Utils.getAngleTo(1, 1)); nex.setNextFaceTile(Tile.of(glacies.getCoordFaceX(glacies.getSize()), glacies.getCoordFaceY(glacies.getSize()), 0)); nex.setNextForceTalk(new ForceTalk(""Glacies!"")); nex.setNextAnimation(new Animation(6987)); World.sendProjectile(glacies, nex, 2244, 18, 18, 60, 30, 0, 0); nex.voiceEffect(3304, true); } else if (count == 11) { nex.setNextForceTalk(new ForceTalk(""Fill my soul with smoke!"")); World.sendProjectile(fumus, nex, 2244, 18, 18, 60, 30, 0, 0); nex.voiceEffect(3310, true); } else if (count == 13) { nex.setCantInteract(false); stop(); return; } count++; } }, 0, 1); } } public List getPlayers() { return players; } }" "package com.rs.game.content.bosses.godwars.zaros; public class NexCombat extends CombatScript { @Override public Object[] getKeys() { return new Object[] { ""Nex"" }; } @Override public int attack(NPC npc, final Entity target) { if (!(npc instanceof Nex nex)) return notNexAttack(npc, target); if (nex.getTempAttribs().getB(""siphoning"")) return 0; switch(nex.getPhase()) { case SMOKE: if (nex.getAttackCount() % 12 == 0) return nex.performAttack(target, Utils.random(4) == 0 ? new Drag() : new NoEscape()); if (nex.getAttackCount() % 6 == 0) return nex.performAttack(target, new Virus()); break; case SHADOW: if (nex.getAttackCount() == 0) return nex.performAttack(target, new EmbraceDarkness()); if (nex.getAttackCount() % 5 == 0) return nex.performAttack(target, new ShadowTraps()); break; case BLOOD: if (nex.getAttackCount() % 8 == 0) return nex.performAttack(target, new Siphon()); if (nex.getAttackCount() % 4 == 0) return nex.performAttack(target, new BloodSacrifice()); break; case ICE: if (nex.getAttackCount() % 8 == 0) return nex.performAttack(target, new ContainThis()); if (nex.getAttackCount() % 4 == 0) return nex.performAttack(target, new IcePrison()); break; default: break; } return autoAttack(nex, target); } public int autoAttack(Nex nex, Entity target) { if (nex.isFollowTarget()) { if (!nex.inMeleeRange(target)) { nex.calcFollow(target, true); if (nex.shouldStopMeleeing()) nex.setFollowTarget(false); return 0; } nex.setFollowTarget(Utils.random(2) == 0); int damage = getMaxHit(nex, 360, AttackStyle.MELEE, target); delayHit(nex, 0, target, getMeleeHit(nex, damage)); nex.setNextAnimation(new Animation(6354)); } else { nex.setFollowTarget(Utils.random(2) == 0); switch (nex.getPhase()) { case SMOKE: nex.setNextAnimation(new Animation(6987)); nex.setNextSpotAnim(new SpotAnim(1214)); for (Entity t : nex.getPossibleTargets()) { int damage = getMaxHit(nex, 250, AttackStyle.MAGE, t); delayHit(nex, World.sendProjectile(nex, t, 306, 41, 16, 41, 1.6, 16, p -> t.setNextSpotAnim(new SpotAnim(471))).getTaskDelay(), t, getMagicHit(nex, damage)); if (damage > 0 && Utils.getRandomInclusive(5) == 0) t.getPoison().makePoisoned(88); } break; case SHADOW: nex.setNextAnimation(new Animation(6987)); for (final Entity t : nex.getPossibleTargets()) { int distance = (int) Utils.getDistance(t.getX(), t.getY(), nex.getX(), nex.getY()); if (distance <= 10) { int damage = 800 - (distance * 800 / 11); delayHit(nex, World.sendProjectile(nex, t, 380, 41, 16, 41, 1.6, 16, p -> t.setNextSpotAnim(new SpotAnim(471))).getTaskDelay(), t, getRangeHit(nex, getMaxHit(nex, damage, AttackStyle.RANGE, t))); } } break; case BLOOD: nex.setNextAnimation(new Animation(6986)); delayHit(nex, World.sendProjectile(nex, target, 374, 41, 16, 41, 1.6, 16, 0).getTaskDelay(), target, getMagicHit(nex, getMaxHit(nex, 250, AttackStyle.MAGE, target))); break; case ICE: nex.setNextAnimation(new Animation(6986)); for (final Entity t : nex.getPossibleTargets()) { int damage = getMaxHit(nex, 250, AttackStyle.MAGE, t); delayHit(nex, World.sendProjectile(nex, t, 362, 41, 16, 41, 35, 16, 0).getTaskDelay(), t, getMagicHit(nex, damage)); if (damage > 0 && Utils.getRandomInclusive(5) == 0) { if (t instanceof Player player) t.freeze(Ticks.fromSeconds(player.getPrayer().isProtectingMage() ? 3 : 18), true); t.setNextSpotAnim(new SpotAnim(369)); } } break; case ZAROS: nex.setNextAnimation(new Animation(6987)); for (Entity t : nex.getPossibleTargets()) { int damage = getMaxHit(nex, 350, AttackStyle.MAGE, t); delayHit(nex, World.sendProjectile(nex, t, 306, 41, 16, 41, 1.6, 16, p -> t.setNextSpotAnim(new SpotAnim(471))).getTaskDelay(), t, getMagicHit(nex, damage)); } break; } } if (nex.getPhase() == Phase.ZAROS && nex.getAttackCount() % 3 == 0) nex.switchPrayers(); nex.incrementAttack(); return nex.getAttackSpeed(); } public int notNexAttack(NPC npc, Entity target) { npc.setNextAnimation(new Animation(6987)); npc.setNextSpotAnim(new SpotAnim(1214)); for (Entity t : npc.getPossibleTargets()) { int damage = getMaxHit(npc, 250, AttackStyle.MAGE, t); delayHit(npc, World.sendProjectile(npc, t, 306, 41, 16, 41, 1.6, 16, p -> t.setNextSpotAnim(new SpotAnim(471))).getTaskDelay(), t, getMagicHit(npc, damage)); if (damage > 0 && Utils.getRandomInclusive(5) == 0) t.getPoison().makePoisoned(88); } return npc.getAttackSpeed(); } }" "package com.rs.game.content.bosses.godwars.zaros; public class NexController extends Controller { private transient NexArena arena; public NexController(NexArena arena) { this.arena = arena; if (arena == null) this.arena = NexArena.getGlobalInstance(); } @Override public void start() { arena.addPlayer(player); sendInterfaces(); } @Override public boolean logout() { arena.removePlayer(player); return false; // so doesnt remove script } @Override public boolean login() { if (arena == null) arena = NexArena.getGlobalInstance(); arena.addPlayer(player); sendInterfaces(); return false; // so doesnt remove script } @Override public void sendInterfaces() { player.getInterfaceManager().setFadingInterface(601); player.getPackets().sendRunScriptReverse(1171); } @Override public boolean sendDeath() { remove(); removeController(); return true; } @Override public void onTeleported(TeleType type) { remove(); removeController(); } @Override public void forceClose() { remove(); } public void remove() { arena.removePlayer(player); player.getInterfaceManager().closeFadingInterface(); } }" "package com.rs.game.content.bosses.godwars.zaros; public class NexCutScene extends Cutscene { private final Tile dir; private final int selected; public NexCutScene(Tile dir, int selected) { this.dir = dir; this.selected = selected; } @Override public void construct(Player player) { int xExtra = 0; int yExtra = 0; if (selected == 0) yExtra -= 7; else if (selected == 2) yExtra += 7; else if (selected == 1) xExtra -= 7; else xExtra += 7; camPos(2925 + xExtra, 5203 + yExtra, 2500, -1); camLook(dir.getX(), dir.getY(), 2500, 3); } }" "package com.rs.game.content.bosses.godwars.zaros; public class NexMinion extends NPC { private final NexArena arena; public NexMinion(NexArena arena, int id, Tile tile) { super(id, tile, true); this.arena = arena; setCantFollowUnderCombat(true); setCapDamage(0); setIgnoreDocile(true); } public void breakBarrier() { setCapDamage(-1); } @Override public boolean ignoreWallsWhenMeleeing() { return true; } @Override public void processNPC() { if (isDead()) return; if (!getCombat().process()) checkAggressivity(); } @Override public void handlePreHit(Hit hit) { super.handlePreHit(hit); if (hit.getLook() != HitLook.RANGE_DAMAGE) hit.setDamage(0); if (getCapDamage() != -1) setNextSpotAnim(new SpotAnim(1549)); } @Override public void sendDeath(Entity source) { super.sendDeath(source); arena.moveNextStage(); } }" "package com.rs.game.content.bosses.godwars.zaros; @PluginEventHandler public class ZarosFactionNPC extends NPC { private static final int CAP_BONUS = 200; private static final Bonus[][] BONUSES = { { Bonus.STAB_DEF, Bonus.SLASH_DEF, Bonus.CRUSH_DEF }, { Bonus.RANGE_DEF }, {}, { Bonus.MAGIC_DEF } }; public ZarosFactionNPC(int id, Tile tile) { super(id, tile); } @Override public List getPossibleTargets() { List targets = getPossibleTargets(true); ArrayList targetsCleaned = new ArrayList<>(); for (Entity t : targets) { if (t instanceof ZarosFactionNPC || t instanceof Familiar || hasSuperiourBonuses(t)) continue; targetsCleaned.add(t); } return targetsCleaned; } private boolean hasSuperiourBonuses(Entity t) { if (!(t instanceof Player player)) return false; for (Bonus bonus : BONUSES[getId() - 13456]) if (player.getCombatDefinitions().getBonus(bonus) >= (bonus == Bonus.RANGE_DEF ? 100 : CAP_BONUS)) return true; return false; } public static boolean isNexArmour(String name) { return name.contains(""pernix"") || name.contains(""torva"") || name.contains(""virtus"") || name.contains(""zaryte""); } public static NPCInstanceHandler toFunc = new NPCInstanceHandler(new Object[] { 13456, 13457, 13458, 13459 }, ZarosFactionNPC::new); }" "package com.rs.game.content.bosses.godwars.zaros.attack; public class BloodSacrifice implements NexAttack { @Override public int attack(Nex nex, Entity target) { if (!(target instanceof Player player)) return 0; nex.setNextForceTalk(new ForceTalk(""I demand a blood sacrifice!"")); nex.voiceEffect(3293, true); player.getAppearance().setGlowRed(true); player.sendMessage(""Nex has marked you as a sacrifice, RUN!""); WorldTasks.schedule(new Task() { @Override public void run() { player.getAppearance().setGlowRed(false); if (Utils.getDistance(nex.getTile(), player.getTile()) < 7) { player.sendMessage(""You didn't make it far enough in time - Nex fires a punishing attack!""); nex.setNextAnimation(new Animation(6987)); for (final Entity t : nex.getPossibleTargets()) World.sendProjectile(nex, t, 374, 41, 16, 41, 35, 16, p -> { nex.heal(t.getHitpoints()); t.applyHit(new Hit(nex, (int) (t.getHitpoints() * 0.1), HitLook.TRUE_DAMAGE)); }); } } }, nex.getAttackSpeed()); return nex.getAttackSpeed() * 2; } }" "package com.rs.game.content.bosses.godwars.zaros.attack; public class ContainThis implements NexAttack { @Override public int attack(Nex nex, Entity target) { nex.setNextForceTalk(new ForceTalk(""Contain this!"")); nex.voiceEffect(target, 3316, true); nex.setNextAnimation(new Animation(6984)); final Tile base = nex.transform(1, 1, 0); nex.resetWalkSteps(); WorldTasks.schedule(new Task() { @Override public void run() { for (int y = 2; y >= -2; y-=2) for (int x = 2; x >= -2; x-=2) { if (x == y) continue; final Tile tile = base.transform(x, y, 0); final GameObject object = new GameObject(57262, ObjectType.SCENERY_INTERACT, 0, tile); if (tile != base && World.floorAndWallsFree(tile, (object.getDefinitions().getSizeX() + object.getDefinitions().getSizeY()) / 2)) { for (Player player : nex.getArena().getPlayers()) if (player.getX() == tile.getX() && player.getY() == tile.getY()) { player.setNextAnimation(new Animation(1113)); player.applyHit(new Hit(nex, Utils.random(200, 350), HitLook.TRUE_DAMAGE)); player.sendMessage(""The icicle spikes you to the spot!""); player.sendMessage(""You've been injured and can't use "" + (player.getPrayer().isCurses() ? ""deflect curses"" : ""protection prayers "") + ""!""); player.resetWalkSteps(); player.setProtectionPrayBlock(12); } World.spawnObjectTemporary(object, Ticks.fromSeconds(7)); } } return; } }, 6); return nex.getAttackSpeed() * 2; } }" "package com.rs.game.content.bosses.godwars.zaros.attack; public class Drag implements NexAttack { @Override public int attack(Nex nex, Entity target) { int distance = 0; Entity settedTarget = null; for (Entity t : nex.getPossibleTargets()) if (t instanceof Player) { int thisDistance = (int) Utils.getDistance(t.getX(), t.getY(), nex.getX(), nex.getY()); if (settedTarget == null || thisDistance > distance) { distance = thisDistance; settedTarget = t; } } if (settedTarget != null) { final Player player = (Player) settedTarget; player.lock(3); player.setNextSpotAnim(new SpotAnim(2767)); player.forceMove(nex.getNearestTeleTile(1), 14386, 0, 60); nex.setNextAnimation(new Animation(6986)); nex.setTarget(player); player.setNextAnimation(new Animation(-1)); WorldTasks.schedule(new Task() { @Override public void run() { player.sendMessage(""You've been injured and you can't use protective prayers!""); player.setProtectionPrayBlock(12); player.sendMessage(""You're stunned.""); } }); } return nex.getAttackSpeed(); } }" "package com.rs.game.content.bosses.godwars.zaros.attack; public class EmbraceDarkness implements NexAttack { @Override public int attack(Nex nex, Entity target) { nex.setNextForceTalk(new ForceTalk(""Embrace darkness!"")); nex.voiceEffect(target, 3322, true); nex.setNextAnimation(new Animation(6355)); nex.setNextSpotAnim(new SpotAnim(1217)); WorldTasks.scheduleLooping(new Task() { @Override public void run() { if (nex.getPhase() != Phase.SHADOW || nex.hasFinished()) { for (Entity entity : nex.getPossibleTargets()) if (entity instanceof Player player) player.getPackets().sendVarc(1435, 255); stop(); return; } if (Utils.getRandomInclusive(2) == 0) for (Entity entity : nex.getPossibleTargets()) if (entity instanceof Player player) { int distance = (int) Utils.getDistance(player.getX(), player.getY(), nex.getX(), nex.getY()); if (distance > 30) distance = 30; player.getPackets().sendVarc(1435, (distance * 255 / 30)); } } }, 0, 0); return nex.getAttackSpeed(); } }" "package com.rs.game.content.bosses.godwars.zaros.attack; public class IcePrison implements NexAttack { @Override public int attack(Nex nex, Entity target) { nex.setNextForceTalk(new ForceTalk(""Die now, in a prison of ice!"")); nex.voiceEffect(target, 3308, true); nex.setNextAnimation(new Animation(6987)); World.sendProjectile(nex, target, 362, 20, 20, 20, 0.45, 10, 0); final Tile base = Tile.of(target.getX(), target.getY(), target.getPlane()); target.getTempAttribs().setB(""inIcePrison"", true); for (int x = -1; x <= 1; x++) for (int y = -1; y <= 1; y++) { final Tile tile = base.transform(x, y, target.getPlane()); final GameObject object = new GameObject(57263, ObjectType.SCENERY_INTERACT, 0, tile); if (!tile.matches(base) && World.floorAndWallsFree(tile, (object.getDefinitions().getSizeX() + object.getDefinitions().getSizeY()) / 2)) World.spawnObject(object); WorldTasks.scheduleLooping(new Task() { boolean remove = false; @Override public void run() { if (remove) { World.removeObject(object); stop(); return; } remove = true; target.getTempAttribs().setB(""inIcePrison"", false); if (target.getX() == tile.getX() && target.getY() == tile.getY()) { if (target instanceof Player) ((Player)target).sendMessage(""The centre of the ice prison freezes you to the bone!""); target.resetWalkSteps(); target.applyHit(new Hit(nex, Utils.random(600, 800), HitLook.TRUE_DAMAGE)); } } }, 8, 0); } return nex.getAttackSpeed() * 2; } }" "package com.rs.game.content.bosses.godwars.zaros.attack; public interface NexAttack { int attack(Nex nex, Entity target); }" "package com.rs.game.content.bosses.godwars.zaros.attack; public class NoEscape implements NexAttack { public static Tile[] NO_ESCAPE_TELEPORTS = { Tile.of(2924, 5213, 0), //north Tile.of(2934, 5202, 0), //east, Tile.of(2924, 5192, 0), //south Tile.of(2913, 5202, 0), }; //west @Override public int attack(Nex nex, Entity target) { nex.setNextForceTalk(new ForceTalk(""There is..."")); nex.voiceEffect(target, 3294, true); nex.setCantInteract(true); nex.getCombat().removeTarget(); final int idx = Utils.random(NO_ESCAPE_TELEPORTS.length); final Tile dir = NO_ESCAPE_TELEPORTS[idx]; final Tile center = Tile.of(2924, 5202, 0); WorldTasks.scheduleLooping(new Task() { private int count; @Override public void run() { if (count == 0) { nex.setNextAnimation(new Animation(6321)); nex.setNextSpotAnim(new SpotAnim(1216)); } else if (count == 1) { nex.tele(dir); nex.setNextForceTalk(new ForceTalk(""NO ESCAPE!"")); nex.voiceEffect(target, 3292, true); nex.forceMove(center, 25, 90); for (Entity entity : nex.calculatePossibleTargets(center, dir, idx == 0 || idx == 2)) if (entity instanceof Player player) { player.getCutsceneManager().play(new NexCutScene(dir, idx)); player.applyHit(new Hit(nex, Utils.getRandomInclusive(650), HitLook.TRUE_DAMAGE)); player.forceMove(player.getTile(), 10070, 0, 30); } } else if (count == 3) nex.tele(center); else if (count == 4) { nex.setTarget(target); nex.setCantInteract(false); stop(); } count++; } }, 0, 1); return nex.getAttackSpeed(); } }" "package com.rs.game.content.bosses.godwars.zaros.attack; public class ShadowTraps implements NexAttack { @Override public int attack(Nex nex, Entity target) { nex.setNextForceTalk(new ForceTalk(""Fear the Shadow!"")); nex.voiceEffect(target, 3314, true); nex.setNextAnimation(new Animation(6984)); nex.setNextSpotAnim(new SpotAnim(1215)); List possibleTargets = nex.getPossibleTargets(); final HashMap tiles = new HashMap<>(); for (Entity t : possibleTargets) { String key = t.getX() + ""_"" + t.getY(); if (!tiles.containsKey(t.getX() + ""_"" + t.getY())) { tiles.put(key, new int[] { t.getX(), t.getY() }); World.spawnObjectTemporary(new GameObject(57261, ObjectType.SCENERY_INTERACT, 0, t.getX(), t.getY(), 0), 4); } } WorldTasks.scheduleLooping(new Task() { private boolean firstCall; @Override public void run() { if (!firstCall) { List possibleTargets = nex.getPossibleTargets(); for (int[] tile : tiles.values()) { World.sendSpotAnim(Tile.of(tile[0], tile[1], 0), new SpotAnim(383)); for (Entity t : possibleTargets) if (t.getX() == tile[0] && t.getY() == tile[1]) t.applyHit(new Hit(nex, Utils.getRandomInclusive(400) + 400, HitLook.TRUE_DAMAGE)); } firstCall = true; } else stop(); } }, 3, 3); return nex.getAttackSpeed(); } }" "package com.rs.game.content.bosses.godwars.zaros.attack; public class Siphon implements NexAttack { @Override public int attack(Nex nex, Entity target) { nex.killBloodReavers(); nex.setNextForceTalk(new ForceTalk(""A siphon will solve this!"")); nex.voiceEffect(target, 3317, true); nex.setNextAnimation(new Animation(6948)); nex.setNextSpotAnim(new SpotAnim(1201)); nex.getTempAttribs().setB(""siphoning"", true); int reaverSize = NPCDefinitions.getDefs(13458).size; int respawnedBloodReaverCount = 0; for (int i = 0; i < 3; i++) { Tile tile = nex.getNearestTeleTile(reaverSize); if (tile != null) nex.getBloodReavers()[respawnedBloodReaverCount++] = new NPC(13458, tile, true); } WorldTasks.schedule(6, () -> nex.getTempAttribs().setB(""siphoning"", false)); return nex.getAttackSpeed(); } }" "package com.rs.game.content.bosses.godwars.zaros.attack; public class Virus implements NexAttack { @Override public int attack(Nex nex, Entity target) { nex.setNextForceTalk(new ForceTalk(""Let the virus flow through you."")); nex.voiceEffect(target, 3296, true); nex.setNextAnimation(new Animation(6987)); sendVirus(nex, new ArrayList<>(), nex.getPossibleTargets(), target); return nex.getAttackSpeed(); } public void sendVirus(Nex nex, List hitedEntitys, List possibleTargets, Entity infected) { for (Entity t : possibleTargets) { if (hitedEntitys.contains(t)) continue; if (Utils.getDistance(t.getX(), t.getY(), infected.getX(), infected.getY()) <= 1) { t.setNextForceTalk(new ForceTalk(""*Cough*"")); t.applyHit(new Hit(nex, Utils.getRandomInclusive(100), HitLook.TRUE_DAMAGE)); hitedEntitys.add(t); sendVirus(nex, hitedEntitys, possibleTargets, infected); } } } }" "package com.rs.game.content.bosses.kalphitequeen class KalphiteQueen(id: Int, tile: Tile, spawned: Boolean) : NPC(id, tile, spawned) { init { isIgnoreNPCClipping = true lureDelay = 0 isForceAgressive = true isIgnoreDocile = true } override fun sendDeath(source: Entity) { resetWalkSteps() combat.removeTarget() anim(-1) isCantInteract = true schedule { anim(combatDefinitions.deathEmote) wait(combatDefinitions.deathDelay) if (id == 1158) { transformIntoNPC(1160) sync(6270, 1055) schedule { reset() isCantInteract = false } } else { drop() reset() setLocation(respawnTile) finish() if (!isSpawned) setRespawnTask() transformIntoNPC(1158) } } } } @ServerStartupEvent fun mapKalphiteQueen() { instantiateNpc(1158, 1160) { id, tile -> KalphiteQueen(id, tile, false)} npcCombat(1158, 1160) { npc, target -> if (target.inMeleeRange(npc) && random(2) == 0) return@npcCombat getDefaultCombat().apply(npc, target) npc.anim(if (npc.id == 1158) 6240 else 6234) if (random(2) == 0) { //range sendProjectile(npc, target, 288, 30, 15, 1.8) { delayHit(npc, 0, target, getRangeHit(npc, getMaxHit(npc, npc.combatDefinitions.maxHit, NPCCombatDefinitions.AttackStyle.RANGE, target, 10000.0))) if (target is Player) target.prayer.drainPrayer(10.0) } return@npcCombat npc.attackSpeed } //mage npc.spotAnim(if (npc.id == 1158) 278 else 279) projectileBounce(npc, target, mutableSetOf(target), 280, 281, 1.8) { nextTarget -> delayHit(npc, 0, nextTarget, getMagicHit(npc, getMaxHit(npc, npc.maxHit, NPCCombatDefinitions.AttackStyle.MAGE, nextTarget, 10000.0))) } return@npcCombat npc.attackSpeed } }" "package com.rs.game.content.bosses.kingblackdrag; @PluginEventHandler public class KingBlackDragon extends NPC { public KingBlackDragon(int id, Tile tile, boolean spawned) { super(id, tile, spawned); setLureDelay(3000); setIntelligentRouteFinder(true); setIgnoreDocile(true); } public static boolean atKBD(Tile tile) { if ((tile.getX() >= 2250 && tile.getX() <= 2292) && (tile.getY() >= 4675 && tile.getY() <= 4710)) return true; return false; } public static NPCInstanceHandler toFunc = new NPCInstanceHandler(new Object[] { 50, 2642 }, (npcId, tile) -> new KingBlackDragon(npcId, tile, false)); }" "package com.rs.game.content.bosses.kingblackdrag; public class KingBlackDragonCombat extends CombatScript { @Override public Object[] getKeys() { return new Object[] { 50 }; } @Override public int attack(final NPC npc, final Entity target) { final NPCCombatDefinitions defs = npc.getCombatDefinitions(); int attackStyle = Utils.getRandomInclusive(5); int size = npc.getSize(); if (attackStyle == 0) { int distanceX = target.getX() - npc.getX(); int distanceY = target.getY() - npc.getY(); if ((distanceX <= size) && (distanceX >= -1) && (distanceY <= size) && (distanceY >= -1)) { delayHit(npc, 0, target, getMeleeHit(npc, getMaxHit(npc, defs.getMaxHit(), AttackStyle.MELEE, target))); npc.setNextAnimation(new Animation(defs.getAttackEmote())); return npc.getAttackSpeed(); } attackStyle = Utils.getRandomInclusive(4) + 1; } if (attackStyle == 1 || attackStyle == 2) { int damage = Utils.getRandomInclusive(650); final Player player = target instanceof Player p ? p : null; npc.soundEffect(3750, true); int protection = PlayerCombatKt.getAntifireLevel(player, true); if (protection == 1) damage = Utils.getRandomInclusive(150); if (protection == 2) damage = 0; delayHit(npc, 2, target, getRegularHit(npc, damage)); World.sendProjectile(npc, target, 393, 34, 16, 30, 35, 16, 0); npc.setNextAnimation(new Animation(81)); } else if (attackStyle == 3) { int damage = Utils.getRandomInclusive(650); final Player player = target instanceof Player p ? p : null; npc.soundEffect(587, true); int protection = PlayerCombatKt.getAntifireLevel(player, true); if (protection == 1) damage = getMaxHit(npc, 164, AttackStyle.MAGE, target); if (protection == 2) damage = getMaxHit(npc, 100, AttackStyle.MAGE, target); if (Utils.getRandomInclusive(2) == 0) target.getPoison().makePoisoned(80); delayHit(npc, 2, target, getRegularHit(npc, damage)); World.sendProjectile(npc, target, 394, 34, 16, 30, 35, 16, 0); npc.setNextAnimation(new Animation(81)); } else if (attackStyle == 4) { int damage = Utils.getRandomInclusive(650); final Player player = target instanceof Player p ? p : null; npc.soundEffect(586, true); int protection = PlayerCombatKt.getAntifireLevel(player, true); if (protection == 1) damage = getMaxHit(npc, 164, AttackStyle.MAGE, target); if (protection == 2) damage = getMaxHit(npc, 100, AttackStyle.MAGE, target); if (Utils.getRandomInclusive(2) == 0) target.freeze(Ticks.fromSeconds(15)); delayHit(npc, 2, target, getRegularHit(npc, damage)); World.sendProjectile(npc, target, 395, 34, 16, 30, 35, 16, 0); npc.setNextAnimation(new Animation(81)); } else { int damage = Utils.getRandomInclusive(650); final Player player = target instanceof Player p ? p : null; npc.soundEffect(584, true); int protection = PlayerCombatKt.getAntifireLevel(player, true); if (protection == 1) damage = getMaxHit(npc, 164, AttackStyle.MAGE, target); if (protection == 2) damage = getMaxHit(npc, 100, AttackStyle.MAGE, target); delayHit(npc, 2, target, getRegularHit(npc, damage)); World.sendProjectile(npc, target, 396, 34, 16, 30, 35, 16, 0); npc.setNextAnimation(new Animation(81)); } return npc.getAttackSpeed(); } }" "package com.rs.game.content.bosses.nomad; public class FakeNomad extends NPC { private final Nomad nomad; public FakeNomad(Tile tile, Nomad nomad) { super(8529, tile, true); this.nomad = nomad; setForceMultiArea(true); } @Override public void handlePreHit(Hit hit) { nomad.destroyCopy(this); } }" "package com.rs.game.content.bosses.nomad; public class FakeNomadCombat extends CombatScript { @Override public Object[] getKeys() { return new Object[] { 8529 }; } @Override public int attack(final NPC npc, final Entity target) { npc.setNextAnimation(new Animation(12697)); boolean hit = getMaxHit(npc, 50, AttackStyle.MAGE, target) != 0; delayHit(npc, 2, target, getRegularHit(npc, hit ? 50 : 0)); World.sendProjectile(npc, target, 1657, 30, 30, 75, 25, 0, 0); if (hit) WorldTasks.schedule(new Task() { @Override public void run() { target.setNextSpotAnim(new SpotAnim(2278, 0, 100)); } }, 1); return npc.getAttackSpeed(); } }" "package com.rs.game.content.bosses.nomad; @PluginEventHandler public class FlameVortex extends NPC { private long explodeTime; public FlameVortex(Tile tile) { this(9441, tile, true); } public FlameVortex(int id, Tile tile, boolean spawned) { super(id, tile, spawned); explodeTime = System.currentTimeMillis() + 60000; setNextAnimation(new Animation(12720)); } @Override public void processNPC() { if (explodeTime == -1) return; Player target = getTargetToCheck(); if (target != null && ((target.getX() == getX() && target.getY() == getY()) || (target.getNextRunDirection() != null && target.getX() - target.getNextRunDirection().dx == getX() && target.getY() - target.getNextRunDirection().dy == getY()))) explode(target, 400); else if (explodeTime < System.currentTimeMillis()) explode(target != null && withinDistance(target, 1) ? target : null, Utils.random(400, 701)); } public void explode(final Player target, final int damage) { explodeTime = -1; final NPC npc = this; WorldTasks.scheduleLooping(new Task() { private boolean secondLoop; @Override public void run() { if (!secondLoop) { setNextAnimation(new Animation(12722)); if (target != null) { target.applyHit(new Hit(npc, damage, HitLook.TRUE_DAMAGE)); target.setRunEnergy(0); target.setNextForceTalk(new ForceTalk(""Aiiiiiieeeee!"")); } secondLoop = true; } else { finish(); stop(); } } }, 0, 0); } public Player getTargetToCheck() { for (Player player : queryNearbyPlayersByTileRange(0, player -> true)) return player; return null; } public static NPCInstanceHandler toFunc = new NPCInstanceHandler(9441, (npcId, tile) -> new FlameVortex(npcId, tile, false)); }" "package com.rs.game.content.bosses.nomad; @PluginEventHandler public class Nomad extends NPC { private int nextMove; private long nextMovePerform; private Tile throneTile; private ArrayList copies; private boolean healed; private int notAttacked; private Player target; public Nomad(int id, Tile tile, boolean spawned) { super(id, tile, spawned); setForceMultiArea(true); setRun(true); setCapDamage(750); setForceAggroDistance(5); setNextMovePerform(); setRandomWalk(true); } public void setTarget(Player player) { target = player; super.setTarget(player); } public void setNextMovePerform() { nextMovePerform = System.currentTimeMillis() + Utils.random(20000, 30000); } public boolean isMeleeMode() { return nextMove == -1; } public void setMeleeMode() { nextMove = -1; setForceFollowClose(true); } @Override public void reset() { notAttacked = 0; if (nextMove == -1) { nextMove = 0; setForceFollowClose(false); } healed = false; if (copies != null) destroyCopies(); setNextMovePerform(); super.reset(); } @Override public void sendDeath(Entity source) { if (throneTile != null) { target.lock(); target.getVars().setVarBit(6962, 0); target.npcDialogue(getId(), HeadE.ANGRY, ""You...
You have doomed this world.""); target.voiceEffect(8260, false); WorldTasks.schedule(new Task() { @Override public void run() { FadingScreen.fade(target, () -> { target.getControllerManager().forceStop(); target.unlock(); }); } }, getAttackSpeed() + 1); } super.sendDeath(source); } @Override public void processNPC() { Entity target = getCombat().getTarget(); if (target instanceof Player && !lineOfSightTo(target, false)) { notAttacked++; if (notAttacked == 10) { if (copies != null) { destroyCopies(); notAttacked = 0; return; } final Player player = (Player) target; setNextForceTalk(new ForceTalk(""Face me!"")); player.voiceEffect(7992, false); } else if (notAttacked == 20) { final Player player = (Player) target; setNextForceTalk(new ForceTalk(""Coward."")); player.voiceEffect(8055, false); reset(); setNextFaceEntity(null); sendTeleport(getThroneTile()); } } else if (target instanceof Familiar && this.target != null) super.setTarget(this.target); else notAttacked = 0; super.processNPC(); } // 0 mines // 1 wrath // 2 multiplies // 3 k0 move public int getNextMove() { if (nextMove == 4) nextMove = 0; return nextMove++; } public void sendTeleport(final Tile tile) { setNextAnimation(new Animation(12729)); setNextSpotAnim(new SpotAnim(1576)); WorldTasks.schedule(new Task() { @Override public void run() { tele(tile); setNextAnimation(new Animation(12730)); setNextSpotAnim(new SpotAnim(1577)); setFaceAngle(6); } }, 3); } public boolean useSpecialSpecialMove() { return System.currentTimeMillis() > nextMovePerform; } public void setNextMove(int nextMove) { this.nextMove = nextMove; } public Tile getThroneTile() { /* * if no throne returns middle of area */ return throneTile == null ? Tile.of((getRegionX() << 6) + 32, (getRegionY() << 6) + 32, getPlane()) : throneTile; } public void setThroneTile(Tile throneTile) { this.throneTile = throneTile; } public void createCopies(final Player target) { setNextAnimation(new Animation(12729)); setNextSpotAnim(new SpotAnim(1576)); final int thisIndex = Utils.random(4); final Nomad thisNpc = this; WorldTasks.schedule(new Task() { @Override public void run() { copies = new ArrayList<>(); transformIntoNPC(8529); for (int i = 0; i < 4; i++) { NPC n; if (thisIndex == i) { n = thisNpc; tele(getCopySpot(i)); } else { n = new FakeNomad(getCopySpot(i), thisNpc); copies.add(n); } n.setCantFollowUnderCombat(true); n.setNextAnimation(new Animation(12730)); n.setNextSpotAnim(new SpotAnim(1577)); n.setTarget(target); } } }, 3); } public Tile getCopySpot(int index) { Tile throneTile = getThroneTile(); return switch (index) { case 0 -> throneTile; case 1 -> throneTile.transform(-3, -3, 0); case 2 -> throneTile.transform(3, -3, 0); default -> throneTile.transform(0, -6, 0); }; } public void destroyCopy(NPC copy) { copy.finish(); if (copies == null) return; copies.remove(copy); if (copies.isEmpty()) destroyCopies(); } public void destroyCopies() { transformIntoNPC(8528); setCantFollowUnderCombat(false); setNextMovePerform(); if (copies == null) return; for (NPC n : copies) n.finish(); copies = null; } @Override public void handlePreHit(Hit hit) { if (getId() == 8529) destroyCopies(); super.handlePreHit(hit); } public boolean isHealed() { return healed; } public void setHealed(boolean healed) { this.healed = healed; } public static NPCInstanceHandler toFunc = new NPCInstanceHandler(new Object[] { 8528, 8529, 8530, 8531, 8532 }, (npcId, tile) -> new Nomad(npcId, tile, false)); }" "package com.rs.game.content.bosses.nomad; public class NomadCombat extends CombatScript { @Override public Object[] getKeys() { return new Object[] { 8528 }; } private void spawnFlameVortex(Tile tile) { if (!World.floorAndWallsFree(tile, 1)) return; new FlameVortex(tile); } @Override public int attack(final NPC npc, final Entity target) { final Nomad nomad = (Nomad) npc; if (target instanceof Player player) if (!nomad.isMeleeMode() && nomad.getHitpoints() < nomad.getMaxHitpoints() * 0.25) { if (!nomad.isHealed()) { nomad.setNextAnimation(new Animation(12700)); nomad.heal(2500); nomad.setHealed(true); player.npcDialogue(nomad.getId(), HeadE.ANGRY, ""You're thougher than I thought, time to even things up!""); player.voiceEffect(8019, false); return npc.getAttackSpeed(); } nomad.setMeleeMode(); player.npcDialogue(nomad.getId(), HeadE.ANGRY, ""Enough! THIS..ENDS..NOW!""); player.voiceEffect(7964, false); } if (nomad.isMeleeMode()) { int distanceX = target.getX() - npc.getX(); int distanceY = target.getY() - npc.getY(); int size = npc.getSize(); if (distanceX > size || distanceX < -1 || distanceY > size || distanceY < -1) return 0; npc.setNextAnimation(new Animation(12696)); delayHit(npc, 0, target, getRegularHit(npc, getMaxHit(npc, 322, AttackStyle.MELEE, target))); return 2; } if (target instanceof Player player && nomad.useSpecialSpecialMove()) switch (nomad.getNextMove()) { case 0: nomad.setNextMovePerform(); npc.setNextAnimation(new Animation(12701)); player.npcDialogue(nomad.getId(), HeadE.ANGRY, ""Let's make things interesting!""); player.voiceEffect(8039, false); final Tile middle = Tile.of(player.getTile()); WorldTasks.scheduleLooping(new Task() { int count; @Override public void run() { switch (count) { case 0: spawnFlameVortex(middle.transform(2, 2, 0)); break; case 1: spawnFlameVortex(middle.transform(2, 0, 0)); break; case 2: spawnFlameVortex(middle.transform(2, -2, 0)); break; case 3: spawnFlameVortex(middle.transform(-2, -2, 0)); break; case 4: spawnFlameVortex(middle.transform(-2, 0, 0)); break; case 5: spawnFlameVortex(middle.transform(-2, 2, 0)); break; case 6: spawnFlameVortex(middle.transform(3, 1, 0)); break; case 7: spawnFlameVortex(middle.transform(3, -1, 0)); break; case 8: spawnFlameVortex(middle.transform(1, -3, 0)); break; case 9: spawnFlameVortex(middle.transform(-1, -3, 0)); break; case 10: spawnFlameVortex(middle.transform(-3, -1, 0)); break; case 11: spawnFlameVortex(middle.transform(-3, 1, 0)); break; case 12: stop(); break; } count++; } }, 0, 0); break; case 1: nomad.setCantFollowUnderCombat(true); Tile throne = nomad.getThroneTile(); if (nomad.getX() != throne.getX() || nomad.getY() != throne.getY()) nomad.sendTeleport(nomad.getThroneTile()); WorldTasks.scheduleLooping(new Task() { private boolean secondLoop; @Override public void run() { if (!secondLoop) { npc.setNextAnimation(new Animation(12698)); npc.setNextSpotAnim(new SpotAnim(2281)); player.npcDialogue(nomad.getId(), HeadE.ANGRY, ""You cannot hide from my wrath!""); player.voiceEffect(7960, false); secondLoop = true; } else { if (npc.lineOfSightTo(target, false)) { delayHit(npc, 2, target, getRegularHit(npc, 750)); World.sendProjectile(npc, target, 1658, 30, 30, 75, 25, 0, 0); } nomad.setCantFollowUnderCombat(false); nomad.setNextMovePerform(); stop(); } } }, 7, 10); return 25; case 2: player.npcDialogue(nomad.getId(), HeadE.ANGRY, ""Let's see how well you senses serve you!""); player.getActionManager().forceStop(); nomad.createCopies(player); return 7; case 3: nomad.setCantFollowUnderCombat(true); throne = nomad.getThroneTile(); nomad.sendTeleport(nomad.getThroneTile()); Magic.sendObjectTeleportSpell(player, false, throne.transform(1, -3, 0)); player.lock(); WorldTasks.scheduleLooping(new Task() { private boolean secondLoop; @Override public void run() { if (!secondLoop) { npc.setNextAnimation(new Animation(12699)); npc.setNextSpotAnim(new SpotAnim(2280)); player.freeze(Ticks.fromSeconds(17)); player.npcDialogue(nomad.getId(), HeadE.ANGRY, ""Let's see how much punishment you can take!""); player.voiceEffect(8001, false); player.setNextFaceTile(Tile.of(player.getX(), player.getY() + 1, 0)); player.setNextSpotAnim(new SpotAnim(369)); player.unlock(); secondLoop = true; } else { delayHit(npc, 2, target, getRegularHit(npc, player.getMaxHitpoints() - 1)); World.sendProjectile(npc, target, 2280, 30, 30, 5, 25, 0, 0); nomad.setCantFollowUnderCombat(false); nomad.setNextMovePerform(); stop(); } } }, 7, 23); return 40; } else { npc.setNextAnimation(new Animation(12697)); int damage = getMaxHit(npc, 322, AttackStyle.MAGE, target); delayHit(npc, 2, target, getRegularHit(npc, damage)); if (damage == 0) WorldTasks.schedule(new Task() { @Override public void run() { target.setNextSpotAnim(new SpotAnim(85, 0, 100)); } }, 1); World.sendProjectile(npc, target, 1657, 30, 30, 75, 25, 0, 0); } return npc.getAttackSpeed(); } }" "package com.rs.game.content.bosses.pestqueen; /** * * @author Tyler * */ public class PestQueen extends NPC { public Attack currentAttack; public PestQueen(int id, Tile tile, int mapAreaNameHash, boolean canBeAttackFromOutOfArea) { super(id, tile); setHitpoints(20000); setCombatLevel(599); currentAttack = new MeleeAttack(); } @Override public void processNPC() { } }" "package com.rs.game.content.bosses.pestqueen.attack; public interface Attack { /** * Process the attack. * * @param queen * The {@code PestQueen} instance. * @param target * The {@code Entity} instance. */ public void processAttack(PestQueen queen, Entity target); public Animation getAttackAnimation(); public int getMaxHit(); public boolean canAttack(PestQueen queen, Entity target); }" "package com.rs.game.content.bosses.pestqueen.attack.impl; public class MagicAttack implements Attack { @Override public void processAttack(PestQueen queen, Entity target) { queen.setNextFaceEntity(target); queen.setNextAnimation(getAttackAnimation()); int hit = Utils.random(0, getMaxHit());// TODO make the combat rolls // actually accurate using npc // bonuses target.applyHit(new Hit(queen, hit, hit == 0 ? HitLook.MISSED : HitLook.MAGIC_DAMAGE)); } @Override public Animation getAttackAnimation() { return new Animation(14792); } @Override public int getMaxHit() { return 200; } @Override public boolean canAttack(PestQueen queen, Entity target) { return true; } }" "package com.rs.game.content.bosses.pestqueen.attack.impl; public class MeleeAttack implements Attack { @Override public void processAttack(PestQueen queen, Entity target) { queen.setNextFaceEntity(target); queen.setNextAnimation(getAttackAnimation()); int hit = Utils.random(0, getMaxHit());// TODO make the combat rolls // actually accurate using npc // bonuses target.applyHit(new Hit(queen, hit, hit == 0 ? HitLook.MISSED : HitLook.MELEE_DAMAGE)); } @Override public Animation getAttackAnimation() { return new Animation(14801); } @Override public int getMaxHit() { return 200; } @Override public boolean canAttack(PestQueen queen, Entity target) { return true; } }" "package com.rs.game.content.bosses.qbd; @PluginEventHandler public final class QueenBlackDragonController extends Controller { public static final Tile OUTSIDE = Settings.getConfig().getPlayerRespawnTile(); private static final int[][][] PLATFORM_STEPS = { { { 88, 86 }, { 88, 87 }, { 88, 88 }, { 88, 89 }, { 88, 90 }, { 88, 91 }, { 89, 91 }, { 89, 90 }, { 89, 89 }, { 89, 88 }, { 89, 87 }, { 89, 86 }, { 90, 86 }, { 90, 87 }, { 90, 88 }, { 90, 89 }, { 90, 90 }, { 90, 91 }, { 91, 91 }, { 91, 90 }, { 91, 89 }, { 91, 88 }, { 91, 87 }, { 92, 87 }, { 92, 88 }, { 92, 89 }, { 92, 90 }, { 92, 91 }, { 93, 91 }, { 93, 90 }, { 93, 89 }, { 93, 88 }, { 94, 88 }, { 94, 89 }, { 94, 90 }, { 94, 91 }, { 95, 91 }, { 95, 90 }, { 95, 89 }, { 96, 89 }, { 96, 90 }, { 96, 91 }, { 97, 91 }, { 97, 90 }, { 98, 90 }, { 98, 91 }, { 99, 91 } }, { { 106, 91 }, { 106, 90 }, { 106, 89 }, { 106, 88 }, { 106, 87 }, { 106, 86 }, { 105, 86 }, { 105, 87 }, { 105, 88 }, { 105, 89 }, { 105, 90 }, { 105, 91 }, { 104, 91 }, { 104, 90 }, { 104, 89 }, { 104, 88 }, { 104, 87 }, { 104, 86 }, { 103, 87 }, { 103, 88 }, { 103, 89 }, { 103, 90 }, { 103, 91 }, { 102, 91 }, { 102, 90 }, { 102, 89 }, { 102, 88 }, { 102, 87 }, { 101, 88 }, { 101, 89 }, { 101, 90 }, { 101, 91 }, { 100, 91 }, { 100, 90 }, { 100, 89 }, { 100, 88 }, { 99, 88 }, { 99, 89 }, { 99, 90 }, { 98, 89 } }, { { 99, 90 }, { 100, 90 }, { 100, 89 }, { 99, 89 }, { 98, 89 }, { 97, 89 }, { 95, 88 }, { 96, 88 }, { 97, 88 }, { 98, 88 }, { 99, 88 }, { 99, 87 }, { 98, 87 }, { 97, 87 }, { 96, 87 }, { 96, 86 }, { 97, 86 }, { 98, 86 } } }; private int platformStand; private transient QueenBlackDragon npc; private Instance bossRegion; private Tile bossBase; private Instance rewardRegion; private Tile rewardBase; public static ObjectClickHandler entrance = new ObjectClickHandler(new Object[] { 70812 }, e -> { if (e.getOption().equals(""Investigate"")) { e.getPlayer().startConversation(new Dialogue() .addSimple(""You will be sent to the heart of this cave complex - alone. There is no way out other than victory, teleportation, or death. Only those who can endure dangerous counters (level 110 or more) should proceed."") .addOptions(ops -> { ops.add(""Proceed."", () -> enterPortal(e.getPlayer())); ops.add(""Step away from the portal.""); })); } else if (e.getOption().equals(""Pass through"")) enterPortal(e.getPlayer()); }); private static void enterPortal(Player player) { if (player.getSkills().getLevelForXp(Constants.SUMMONING) < 60) { player.sendMessage(""You need a Summoning level of 60 to go through this portal.""); return; } player.lock(); player.getControllerManager().startController(new QueenBlackDragonController()); player.setNextAnimation(new Animation(16752)); } @Override public void start() { player.lock(); bossRegion = Instance.of(OUTSIDE, 8, 8); bossRegion.copyMapAllPlanes(176, 792).thenAccept(e -> { bossBase = bossRegion.getTileBase().transform(0, 0, 1); player.fadeScreen(() -> { player.resetReceivedHits(); npc = new QueenBlackDragon(player, bossBase.transform(31, 37, 0), bossBase); player.tele(bossBase.transform(33, 28, 0)); player.setLargeSceneView(true); player.setForceMultiArea(true); player.unlock(); player.getPackets().sendVarc(184, 150); player.getPackets().sendVarc(1924, 0); player.getPackets().sendVarc(1925, 0); player.getInterfaceManager().sendSub(Sub.FULL_GAMESPACE_BG, 1285); player.getMusicsManager().playSongAndUnlock(1119); // AWOKEN }); }); } @Override public boolean processObjectClick1(GameObject object) { if (npc == null) return true; if (object.getId() == 70790) { if (npc.getPhase() < 5) return true; player.lock(); player.fadeScreen(() -> { player.resetReceivedHits(); player.sendMessage(""You descend the stairs that appeared when you defeated the Queen Black Dragon.""); player.getPackets().sendVarc(184, -1); npc.finish(); rewardRegion = Instance.of(OUTSIDE, 8, 8); rewardRegion.copyMapAllPlanes(160, 760).thenAccept(e -> { player.resetReceivedHits(); rewardBase = rewardRegion.getTileBase().transform(0, 0, 0); player.tele(rewardBase.transform(31, 36, 0)); player.setForceNextMapLoadRefresh(true); player.loadMapRegions(); player.getInterfaceManager().removeSub(Sub.FULL_GAMESPACE_BG); player.unlock(); }); }); return false; } if (object.getId() == 70813) { Magic.sendObjectTeleportSpell(player, true, Tile.of(2994, 3233, 0)); return false; } if (object.getId() == 70814) { player.sendMessage(""The gate is locked.""); return false; } if (object.getId() == 70815) { player.startConversation(new Dialogue() .addSimple(""This strange device is covered in indecipherable script. It opens for you, displaying only a small sample of the objects it contains."") .addNext(() -> npc.openRewardChest(true))); return false; } if (object.getId() == 70817) { npc.openRewardChest(false); return false; } if (object.getId() == npc.getActiveArtifact().getId()) { player.getMusicsManager().playSongAndUnlock(1118); // QUEEN BLACK DRAGON npc.setSpawningWorms(false); npc.setNextAttack(20); npc.setActiveArtifact(new GameObject(object.getId() + 1, ObjectType.SCENERY_INTERACT, 0, object.getTile())); npc.setHitpoints(npc.getMaxHitpoints()); npc.setCantInteract(false); npc.setPhase(npc.getPhase() + 1); World.spawnObject(npc.getActiveArtifact()); switch (object.getId()) { case 70777: player.getPackets().sendVarc(1924, 2); World.spawnObject(new GameObject(70843, ObjectType.SCENERY_INTERACT, 0, bossBase.transform(24, 21, -1))); break; case 70780: player.getPackets().sendVarc(1924, 4); World.spawnObject(new GameObject(70845, ObjectType.SCENERY_INTERACT, 0, bossBase.transform(24, 21, -1))); break; case 70783: player.getPackets().sendVarc(1924, 6); World.spawnObject(new GameObject(70847, ObjectType.SCENERY_INTERACT, 0, bossBase.transform(24, 21, -1))); break; case 70786: player.getPackets().sendVarc(1924, 8); player.getPackets().sendRemoveObject(new GameObject(70849, ObjectType.SCENERY_INTERACT, 0, bossBase.transform(24, 21, -1))); World.removeObject(new GameObject(70778, ObjectType.SCENERY_INTERACT, 0, bossBase.transform(33, 31, 0))); World.removeObject(new GameObject(70776, ObjectType.SCENERY_INTERACT, 0, bossBase.transform(33, 31, 0))); World.spawnObject(new GameObject(70790, ObjectType.SCENERY_INTERACT, 0, bossBase.transform(31, 29, 0))); World.spawnObject(new GameObject(70775, ObjectType.SCENERY_INTERACT, 0, bossBase.transform(31, 29, -1))); World.spawnObject(new GameObject(70849, ObjectType.SCENERY_INTERACT, 0, bossBase.transform(24, 21, -1))); World.spawnObject(new GameObject(70837, ObjectType.SCENERY_INTERACT, 0, bossBase.transform(22, 24, -1))); World.spawnObject(new GameObject(70840, ObjectType.SCENERY_INTERACT, 0, bossBase.transform(34, 24, -1))); World.spawnObject(new GameObject(70822, ObjectType.SCENERY_INTERACT, 0, bossBase.transform(21, 35, -1))); World.spawnObject(new GameObject(70818, ObjectType.SCENERY_INTERACT, 0, bossBase.transform(39, 35, -1))); break; } return false; } return true; } @Override public void process() { if (npc == null) return; if (player.getY() < bossBase.getY() + 28) { if (npc.hasFinished()) return; if (platformStand++ == 6) { player.sendMessage(""You are damaged for standing too long on the raw magical platforms.""); player.applyHit(new Hit(npc, 200, HitLook.TRUE_DAMAGE)); platformStand = 0; } } else platformStand = 0; } @Override public boolean checkWalkStep(int lastX, int lastY, int nextX, int nextY) { if (npc != null && nextY < bossBase.getY() + 28) { if (npc.getPhase() > 1) { for (int[] step : PLATFORM_STEPS[0]) if (bossBase.getX() + (step[0] - 64) == nextX && bossBase.getY() + (step[1] - 64) == nextY) return true; if (npc.getPhase() > 2) { for (int[] step : PLATFORM_STEPS[1]) if (bossBase.getX() + (step[0] - 64) == nextX && bossBase.getY() + (step[1] - 64) == nextY) return true; if (npc.getPhase() > 3) for (int[] step : PLATFORM_STEPS[2]) if (bossBase.getX() + (step[0] - 64) == nextX && bossBase.getY() + (step[1] - 64) == nextY) return true; } } return false; } return true; } @Override public void onTeleported(TeleType type) { end(0); } @Override public boolean sendDeath() { player.lock(7); player.stopAll(); WorldTasks.scheduleLooping(new Task() { int loop; @Override public void run() { if (loop == 0) player.setNextAnimation(new Animation(836)); else if (loop == 1) player.sendMessage(""Oh dear, you have died.""); else if (loop == 3) { end(0); player.getControllerManager().startController(new DeathOfficeController(OUTSIDE, player.hasSkull())); } else if (loop == 4) { player.jingle(90); stop(); } loop++; } }, 0, 1); return false; } @Override public boolean logout() { end(1); return false; } @Override public void forceClose() { end(0); } private void end(int type) { player.setForceMultiArea(false); player.setLargeSceneView(false); if (type == 0) { player.getInterfaceManager().removeSub(Sub.FULL_GAMESPACE_BG); player.getPackets().sendVarc(184, -1); } else player.setTile(OUTSIDE); removeController(); if (npc != null) for (Item item : npc.getRewards().toArray()) player.getBank().addItem(item, true); bossRegion.destroy(); if (rewardRegion != null) rewardRegion.destroy(); } public Tile getBase() { return bossBase; } public QueenBlackDragon getNpc() { return npc; } }" "package com.rs.game.content.bosses.qbd.npcs; /** * Handles the Queen Black Dragon's change armour ""attack"". * * @author Emperor * */ public final class ChangeArmour implements QueenAttack { @Override public int attack(final QueenBlackDragon npc, Player victim) { npc.switchState(Utils.random(2) < 1 ? QueenState.CRYSTAL_ARMOUR : QueenState.HARDEN); WorldTasks.schedule(new Task() { @Override public void run() { npc.switchState(QueenState.DEFAULT); } }, 40); npc.getTempAttribs().setI(""_last_armour_change"", npc.getTicks() + Utils.random(41, 100)); return Utils.random(4, 10); } @Override public boolean canAttack(QueenBlackDragon npc, Player victim) { return npc.getTempAttribs().getI(""_last_armour_change"") < npc.getTicks(); } }" "package com.rs.game.content.bosses.qbd.npcs; public final class FireBreathAttack implements QueenAttack { private static final Animation ANIMATION = new Animation(16721); private static final SpotAnim GRAPHIC = new SpotAnim(3143); @Override public int attack(final QueenBlackDragon npc, final Player victim) { npc.setNextAnimation(ANIMATION); npc.setNextSpotAnim(GRAPHIC); npc.getTasks().schedule(new Task() { @Override public void run() { super.stop(); int hit = 0; int protection = PlayerCombatKt.getAntifireLevel(victim, true); if (protection == 1) hit = Utils.random(350, 400); else if (protection == 2) hit = Utils.random(150, 200); else hit = Utils.random(400, 710); victim.setNextAnimation(new Animation(PlayerCombatKt.getDefenceEmote(victim))); victim.applyHit(new Hit(npc, hit, HitLook.TRUE_DAMAGE)); } }, 1); return Utils.random(4, 15); } @Override public boolean canAttack(QueenBlackDragon npc, Player victim) { return true; } }" "package com.rs.game.content.bosses.qbd.npcs; /** * Represents the Queen Black Dragon's fire wall attack. * * @author Emperor * */ public final class FireWallAttack implements QueenAttack { /** * The wall graphic ids. */ private static final int[] WALL_GRAPHIC_IDS = { 3158, 3159, 3160 }; /** * The animation. */ private static final Animation ANIMATION = new Animation(16746); @Override public int attack(final QueenBlackDragon npc, final Player victim) { int waves = npc.getPhase(); if (waves > 3) waves = 3; npc.setNextAnimation(ANIMATION); final List wallIds = new ArrayList<>(); for (int id : WALL_GRAPHIC_IDS) wallIds.add(id); Collections.shuffle(wallIds); victim.sendMessage(""The Queen Black Dragon takes a huge breath.""); final int wallCount = waves; npc.getTasks().schedule(new Task() { @Override public void run() { for (int i = 0; i < wallCount; i++) { final int wallId = wallIds.get(i); npc.getTasks().schedule(new Task() { @Override public void run() { for (int j = 0; j < 2; j++) { final boolean second = j == 1; WorldTasks.scheduleLooping(new Task() { int y = 37 + (second ? 1 : 0); @Override public void run() { if (npc == null || npc.getPhase() >= 5 || npc.hasFinished() || !npc.withinDistance(victim.getTile()) || npc.isDead()) return; if (!((wallId == 3158 && victim.getX() == npc.getBase().getX() + 28) || (wallId == 3159 && victim.getX() == npc.getBase().getX() + 37) || (wallId == 3160 && victim.getX() == npc.getBase().getX() + 32))) if (victim.getY() == npc.getBase().getY() + y) { int hit; int protection = PlayerCombatKt.getAntifireLevel(victim, true); if (protection == 1) hit = Utils.random(350, 360); else if (protection == 2) hit = Utils.random(200, 210); else hit = Utils.random(500, 510); victim.applyHit(new Hit(npc, hit, HitLook.TRUE_DAMAGE)); } if (--y == 19) stop(); } }, 0, 0); } victim.getPackets().sendProjectile(new WorldProjectile(npc.getBase().transform(33, 38, 0), npc.getBase().transform(33, 19, 0), wallId, 0, 0, 18, 600, 0, 0, null)); } }, (i * 7) + 1); } } }, 1); npc.getTempAttribs().setI(""fire_wall_tick_"", npc.getTicks() + Utils.random((waves * 7) + 5, 60)); return 8 + (waves * 2); } @Override public boolean canAttack(QueenBlackDragon npc, Player victim) { int tick = npc.getTempAttribs().getI(""fire_wall_tick_""); return tick == -1 || tick < npc.getTicks(); } }" "package com.rs.game.content.bosses.qbd.npcs; /** * Handles the Queen Black Dragon's melee attack. * * @author Emperor * */ public final class MeleeAttack implements QueenAttack { /** * The default melee animation. */ private static final Animation DEFAULT = new Animation(16717); /** * The east melee animation. */ private static final Animation EAST = new Animation(16744); /** * The west melee animation. */ private static final Animation WEST = new Animation(16743); @Override public int attack(final QueenBlackDragon npc, final Player victim) { if (victim.getX() < npc.getBase().getX() + 31) npc.setNextAnimation(WEST); else if (victim.getX() > npc.getBase().getX() + 35) npc.setNextAnimation(EAST); else npc.setNextAnimation(DEFAULT); CombatScript.delayHit(npc, 1, victim, CombatScript.getMeleeHit(npc, CombatScript.getMaxHit(npc, 360, Bonus.SLASH_ATT, AttackStyle.MELEE, victim))); return Utils.random(4, 15); } @Override public boolean canAttack(QueenBlackDragon npc, Player victim) { return victim.getY() > npc.getBase().getY() + 32; } }" "package com.rs.game.content.bosses.qbd.npcs; /** * Represents an attack from the Queen Black Dragon. * * @author Emperor * */ public interface QueenAttack { /** * Starts the attack. * * @param npc * The NPC. * @param victim * The victim. * @return The next attack value. */ int attack(QueenBlackDragon npc, Player victim); /** * Checks if the QBD can use this attack. * * @param npc * The QBD. * @param victim * The player. * @return {@code True} if so. */ boolean canAttack(QueenBlackDragon npc, Player victim); }" "package com.rs.game.content.bosses.qbd.npcs; /** * Represents the Queen Black Dragon. * * @author Emperor * */ public final class QueenBlackDragon extends NPC { private static final QueenAttack[] PHASE_1_ATTACKS = { new FireBreathAttack(), new MeleeAttack(), new RangeAttack(), new FireWallAttack() }; private static final QueenAttack[] PHASE_2_ATTACKS = { new FireBreathAttack(), new MeleeAttack(), new RangeAttack(), new FireWallAttack(), new ChangeArmour(), new SoulSummonAttack() }; private static final QueenAttack[] PHASE_3_ATTACKS = { new FireBreathAttack(), new MeleeAttack(), new RangeAttack(), new FireWallAttack(), new ChangeArmour(), new SoulSummonAttack(), new SoulSiphonAttack() }; private static final QueenAttack[] PHASE_4_ATTACKS = { new FireBreathAttack(), new TimeStopAttack(), new MeleeAttack(), new SuperFireAttack(), new RangeAttack(), new FireWallAttack(), new SuperFireAttack(), new ChangeArmour(), new SoulSummonAttack(), new SoulSiphonAttack(), new TimeStopAttack() }; /** * The waking up animation. */ private static final Animation WAKE_UP_ANIMATION = new Animation(16714); /** * The sleeping animation. */ private static final Animation SLEEP_ANIMATION = new Animation(16742); /** * The player. */ private transient final Player attacker; /** * The queen state. */ private QueenState state = QueenState.SLEEPING; /** * The amount of ticks passed. */ private int ticks; /** * The next attack tick count. */ private int nextAttack; /** * The current attacks. */ private QueenAttack[] attacks; /** * The current phase. */ private int phase; /** * The region base location. */ private final Tile base; /** * The list of tortured souls. */ private final List souls = new ArrayList<>(); /** * The list of worms. */ private final List worms = new ArrayList<>(); /** * If the Queen Black Dragon is spawning worms. */ private boolean spawningWorms; /** * The current active artifact. */ private GameObject activeArtifact; /** * The rewards container. */ private final ItemsContainer rewards = new ItemsContainer<>(10, true); /** * The last amount of hitpoints. */ private int lastHitpoints = -1; /** * Constructs a new {@code QueenBlackDragon} {@code Object}. * * @param attacker * The player. * @param tile * The world tile to set the queen on. * @param base * The dynamic region's base location. */ public QueenBlackDragon(Player attacker, Tile tile, Tile base) { super(15509, tile, true); super.setForceMultiArea(true); super.setCantFollowUnderCombat(true); setCantInteract(true); this.base = base; this.attacker = attacker; nextAttack = 40; setHitpoints(getMaxHitpoints()); activeArtifact = new GameObject(70776, ObjectType.SCENERY_INTERACT, 0, base.transform(33, 31, 0)); setPhase(1); setCapDamage(1000); setIgnoreDocile(true); } @Override public boolean ignoreWallsWhenMeleeing() { return true; } @Override public void setHitpoints(int hitpoints) { super.setHitpoints(hitpoints); if (attacker == null) return; if (lastHitpoints != hitpoints) { attacker.getPackets().sendVarc(1923, getMaxHitpoints() - hitpoints); lastHitpoints = hitpoints; } } @Override public void sendDeath(Entity source) { switch (phase) { case 1: attacker.getPackets().sendVarc(1924, 1); activeArtifact = new GameObject(70777, ObjectType.SCENERY_INTERACT, 0, base.transform(33, 31, 0)); attacker.sendMessage(""The Queen Black Dragon's concentration wavers; the first artefact is now unguarded.""); break; case 2: attacker.getPackets().sendVarc(1924, 3); World.spawnObject(new GameObject(70844, ObjectType.SCENERY_INTERACT, 0, base.transform(24, 21, -1))); activeArtifact = new GameObject(70780, ObjectType.SCENERY_INTERACT, 0, base.transform(24, 21, 0)); attacker.sendMessage(""The Queen Black Dragon's concentration wavers; the second artefact is now""); attacker.sendMessage(""unguarded.""); break; case 3: attacker.getPackets().sendVarc(1924, 5); World.spawnObject(new GameObject(70846, ObjectType.SCENERY_INTERACT, 0, base.transform(24, 21, -1))); activeArtifact = new GameObject(70783, ObjectType.SCENERY_INTERACT, 0, base.transform(42, 21, 0)); attacker.sendMessage(""The Queen Black Dragon's concentration wavers; the third artefact is now""); attacker.sendMessage(""unguarded.""); break; case 4: attacker.getPackets().sendVarc(1924, 7); World.spawnObject(new GameObject(70848, ObjectType.SCENERY_INTERACT, 0, base.transform(24, 21, -1))); activeArtifact = new GameObject(70786, ObjectType.SCENERY_INTERACT, 0, base.transform(33, 21, 0)); attacker.sendMessage(""The Queen Black Dragon's concentration wavers; the last artefact is now unguarded.""); break; } if (phase <= 4) World.spawnObject(activeArtifact); setCantInteract(true); if (phase < 5) { setSpawningWorms(true); return; } switchState(QueenState.DEFAULT); // TODO: Back to sleep roar } @Override public int getMaxHitpoints() { return 7500; } @Override public void processNPC() { if (ticks > 5 && !attacker.isHasNearbyInstancedChunks()) { finish(); return; } if (ticks == -20) { switchState(QueenState.DEFAULT); switchState(QueenState.SLEEPING); setNextAnimation(SLEEP_ANIMATION); } else if (ticks >= -19 && ticks <= -10) { setNextAnimation(SLEEP_ANIMATION); } else if (ticks == -1) return; ticks++; if (spawningWorms) { if ((ticks % 16) == 0) spawnWorm(); return; } if (ticks == 5) super.setNextAnimation(WAKE_UP_ANIMATION); else if (ticks == 30) { setCantInteract(false); switchState(QueenState.DEFAULT); } else if (ticks == nextAttack) { QueenAttack attack; while (!(attack = attacks[Utils.random(attacks.length)]).canAttack(this, attacker)) ; setNextAttack(attack.attack(this, attacker)); } } @Override public void finish() { for (TorturedSoul s : souls) s.finish(); for (NPC worm : worms) worm.finish(); super.finish(); } /** * Spawns a grotworm. */ public void spawnWorm() { setNextAnimation(new Animation(16747)); attacker.sendMessage(""Worms burrow through her rotting flesh.""); final Tile destination = base.transform(28 + Utils.random(12), 28 + Utils.random(6), 0); WorldProjectile p = World.sendProjectile(this, destination, 3141, 128, 0, 60, 1.5, 5, 3); getTasks().schedule(new Task() { @Override public void run() { if (getPhase() > 4) return; getTasks().schedule(new Task() { @Override public void run() { if (getPhase() > 4) return; NPC worm = new NPC(15464, destination, true); worms.add(worm); worm.setForceMultiArea(true); worm.getCombat().setTarget(attacker); } }, p.getTaskDelay()-1); attacker.getPackets().sendSpotAnim(new SpotAnim(3142), destination); } }, 0); } @Override public int getFaceAngle() { return 0; } /** * Gets the attacker. * * @return The attacker. */ public Player getAttacker() { return attacker; } /** * Gets the state. * * @return The state. */ public QueenState getState() { return state; } /** * Switches the queen state. * * @param state * The state. */ public void switchState(QueenState state) { this.state = state; if (state.getMessage() != null) { String[] messages = state.getMessage().split(""(nl)""); for (String message : messages) attacker.sendMessage(message.replace(""("", """").replace("")"", """")); } super.transformIntoNPC(state.getNpcId()); setCapDamage(1000); switch (state) { case DEFAULT: World.spawnObject(new GameObject(70822, ObjectType.SCENERY_INTERACT, 0, base.transform(21, 35, -1))); World.spawnObject(new GameObject(70818, ObjectType.SCENERY_INTERACT, 0, base.transform(39, 35, -1))); break; case HARDEN: World.spawnObject(new GameObject(70824, ObjectType.SCENERY_INTERACT, 0, base.transform(21, 35, -1))); World.spawnObject(new GameObject(70820, ObjectType.SCENERY_INTERACT, 0, base.transform(39, 35, -1))); break; case CRYSTAL_ARMOUR: World.spawnObject(new GameObject(70823, ObjectType.SCENERY_INTERACT, 0, base.transform(21, 35, -1))); World.spawnObject(new GameObject(70819, ObjectType.SCENERY_INTERACT, 0, base.transform(39, 35, -1))); break; default: World.spawnObject(new GameObject(70822, ObjectType.SCENERY_INTERACT, 0, base.transform(21, 35, -1))); World.spawnObject(new GameObject(70818, ObjectType.SCENERY_INTERACT, 0, base.transform(39, 35, -1))); break; } } /** * Opens the reward chest. * * @param replace * If the chest should be replaced with an opened one. */ public void openRewardChest(boolean replace) { LootInterface.open(""Queen Black Dragon Spoils"", attacker, rewards); for (Item item : rewards.array()) { if (item == null) continue; if (yellDrop(item.getId())) World.broadcastLoot(attacker.getDisplayName() + "" has just received a "" + item.getName() + "" drop from the Queen Black Dragon!""); attacker.incrementCount(item.getName() + "" drops earned"", item.getAmount()); } if (replace) World.spawnObject(new GameObject(70817, ObjectType.SCENERY_INTERACT, 0, base.transform(30, 28, -1))); } /** * Sets the state. * * @param state * The state to set. */ public void setState(QueenState state) { this.state = state; } /** * Gets the nextAttack. * * @return The nextAttack. */ public int getNextAttack() { return nextAttack; } /** * Sets the nextAttack value (current ticks + the given amount). * * @param nextAttack * The amount. */ public void setNextAttack(int nextAttack) { this.nextAttack = ticks + nextAttack; } /** * Gets the phase. * * @return The phase. */ public int getPhase() { return phase; } /** * Sets the phase. * * @param phase * The phase to set. */ public void setPhase(int phase) { this.phase = phase; switch (phase) { case 1: attacks = PHASE_1_ATTACKS; break; case 2: attacks = PHASE_2_ATTACKS; break; case 3: attacks = PHASE_3_ATTACKS; break; case 4: attacks = PHASE_4_ATTACKS; break; case 5: case 6: setCantInteract(true); for (TorturedSoul soul : souls) soul.finish(); for (NPC worm : worms) worm.finish(); ticks = -22; prepareRewards(); World.removeObject(World.getObject(base.transform(22, 24, -1), ObjectType.SCENERY_INTERACT)); World.removeObject(World.getObject(base.transform(34, 24, -1), ObjectType.SCENERY_INTERACT)); attacker.sendMessage(""The enchantment is restored! The Queen Black Dragon falls back into her cursed""); attacker.sendMessage(""slumber.""); attacker.sendNPCKill(""Queen Black Dragon""); if (attacker.hasSlayerTask() && attacker.getSlayer().isOnTaskAgainst(this)) attacker.getSlayer().sendKill(attacker, this); break; } } public static List genDrop(Player attacker) { List drops = new ArrayList<>(); Utils.add(drops, DropTable.calculateDrops(attacker, DropSets.getDropSet(""QBDMain""))); Utils.add(drops, DropTable.calculateDrops(attacker, DropSets.getDropSet(""QBDSupply""))); if (Utils.random(128) == 0) { Utils.add(drops, DropTable.calculateDrops(attacker, DropSets.getDropSet(""rdt_standard""))); Utils.add(drops, DropTable.calculateDrops(attacker, DropSets.getDropSet(""rdt_standard""))); } return drops; } /** * Prepares the rewards. */ public void prepareRewards() { if (rewards.getUsedSlots() == 0) rewards.addAll(genDrop(attacker)); } /** * Gets the base. * * @return The base. */ public Tile getBase() { return base; } /** * Gets the amount of ticks. * * @return The amount of ticks. */ public int getTicks() { return ticks; } /** * Gets the souls. * * @return The souls. */ public List getSouls() { return souls; } /** * Gets the spawningWorms. * * @return The spawningWorms. */ public boolean isSpawningWorms() { return spawningWorms; } /** * Sets the spawningWorms. * * @param spawningWorms * The spawningWorms to set. */ public void setSpawningWorms(boolean spawningWorms) { if (!spawningWorms) setNextAnimation(new Animation(16748)); this.spawningWorms = spawningWorms; } /** * Gets the worms. * * @return The worms. */ public List getWorms() { return worms; } /** * Gets the activeArtifact. * * @return The activeArtifact. */ public GameObject getActiveArtifact() { return activeArtifact; } /** * Sets the activeArtifact. * * @param activeArtifact * The activeArtifact to set. */ public void setActiveArtifact(GameObject activeArtifact) { this.activeArtifact = activeArtifact; } /** * Gets the rewards. * * @return The rewards. */ public ItemsContainer getRewards() { return rewards; } }" "package com.rs.game.content.bosses.qbd.npcs; /** * Represents the Queen Black Dragon's states. * * @author Emperor * */ public enum QueenState { /** * The queen is asleep. */ SLEEPING(15509, null), /** * The default, attackable Qeeun Black Dragon. */ DEFAULT(15454, null), /** * The crystal armour state (weak to physical attacks, strong against * magic). */ CRYSTAL_ARMOUR(15506, ""The Queen Black Dragon takes the consistency of crystal; she is more resistant to(nl)magic, but weaker to physical damage.""), /** * The hardened state (weak to magic attacks, strong against melee/range). */ HARDEN(15507, ""The Queen Black Dragon hardens her carapace; she is more resistant to physical(nl)damage, but more vulerable to magic.""); /** * The NPC id. */ private final int npcId; /** * The message to be send to the player. */ private final String message; /** * Constructs a new {@code QueenState} {@code Object}. * * @param npcId * The NPC id. * @param message * The message to send. */ private QueenState(int npcId, String message) { this.npcId = npcId; this.message = message; } /** * Gets the npcId. * * @return The npcId. */ public int getNpcId() { return npcId; } /** * Gets the message. * * @return The message. */ public String getMessage() { return message; } }" "package com.rs.game.content.bosses.qbd.npcs; /** * Handles the Queen Black Dragon's range attack. * * @author Emperor * */ public final class RangeAttack implements QueenAttack { /** * The animation. */ private static final Animation ANIMATION = new Animation(16718); @Override public int attack(final QueenBlackDragon npc, final Player victim) { npc.setNextAnimation(ANIMATION); CombatScript.delayHit(npc, 1, victim, CombatScript.getMeleeHit(npc, CombatScript.getMaxHit(npc, 360, AttackStyle.RANGE, victim))); return Utils.random(4, 15); } @Override public boolean canAttack(QueenBlackDragon npc, Player victim) { return true; } }" "package com.rs.game.content.bosses.qbd.npcs; /** * The Queen Black Dragon's soul siphon attack. * * @author Emperor * */ public final class SoulSiphonAttack implements QueenAttack { /** * The siphon graphics. */ private static final SpotAnim SIPHON_GRAPHIC = new SpotAnim(3148); @Override public int attack(final QueenBlackDragon npc, Player victim) { npc.getSouls().removeIf(Entity::isDead); if (npc.getSouls().isEmpty()) return 1; victim.sendMessage(""The Queen Black Dragon starts to siphon the energy of her mages.""); WorldTasks.scheduleLooping(new Task() { @Override public void run() { for (Iterator it = npc.getSouls().iterator(); it.hasNext();) { TorturedSoul soul = it.next(); if (soul.isDead()) { it.remove(); continue; } soul.setNextSpotAnim(SIPHON_GRAPHIC); soul.applyHit(new Hit(npc, 20, HitLook.TRUE_DAMAGE)); npc.getNextHits().add(new Hit(npc, 40, HitLook.HEALED_DAMAGE)); npc.heal(40); } if (npc.getSouls().isEmpty()) { stop(); npc.getTempAttribs().setI(""_last_soul_summon"", npc.getTicks() + Utils.random(120) + 125); } } }, 0, 0); npc.getTempAttribs().setI(""_last_soul_summon"", npc.getTicks() + 999); npc.getTempAttribs().setI(""_soul_siphon_atk"", npc.getTicks() + 50 + Utils.random(40)); return Utils.random(5, 10); } @Override public boolean canAttack(QueenBlackDragon npc, Player victim) { int tick = npc.getTempAttribs().getI(""_soul_siphon_atk""); return tick == -1 || tick < npc.getTicks(); } }" "package com.rs.game.content.bosses.qbd.npcs; /** * Handles the summoning of the tortured souls. * * @author Emperor * */ public final class SoulSummonAttack implements QueenAttack { /** * The spawn offset locations. */ private static final int[][] SPAWN_LOCATIONS = { { 31, 35 }, { 33, 35 }, { 34, 33 }, { 31, 29 } }; @Override public int attack(QueenBlackDragon npc, Player victim) { npc.getSouls().removeIf(Entity::isDead); npc.getTempAttribs().setI(""_last_soul_summon"", npc.getTicks() + Utils.random(41, 100)); int count = npc.getPhase() - 1; if (count == 3) count = 4; if (npc.getSouls().size() < count) { victim.sendMessage( (count - npc.getSouls().size()) < 2 ? ""The Queen Black Dragon summons one of her captive, tortured souls."" : ""The Queen Black Dragon summons several of her captive, tortured souls.""); for (int i = npc.getSouls().size(); i < count; i++) npc.getSouls().add(new TorturedSoul(npc, victim, npc.getBase().transform(SPAWN_LOCATIONS[i][0], SPAWN_LOCATIONS[i][1], 0))); } for (int i = 0; i < count; i++) { if (i >= npc.getSouls().size()) break; TorturedSoul s = npc.getSouls().get(i); if (s == null || s.isDead()) continue; s.specialAttack(npc.getBase().transform(SPAWN_LOCATIONS[i][0], SPAWN_LOCATIONS[i][1], 0)); } return Utils.random(4, 15); } @Override public boolean canAttack(QueenBlackDragon npc, Player victim) { int last = npc.getTempAttribs().getI(""_last_soul_summon""); return last == -1 || last < npc.getTicks(); } }" "package com.rs.game.content.bosses.qbd.npcs; /** * Handles the super dragonfire attack. * * @author Emperor * */ public final class SuperFireAttack implements QueenAttack { /** * The animation. */ private static final Animation ANIMATION = new Animation(16745); /** * The graphics. */ private static final SpotAnim GRAPHIC = new SpotAnim(3152); @Override public int attack(final QueenBlackDragon npc, final Player victim) { npc.setNextAnimation(ANIMATION); npc.setNextSpotAnim(GRAPHIC); victim.sendMessage(""The Queen Black Dragon gathers her strength to breath extremely hot flames.""); if (Utils.getDistance(npc.getBase().transform(33, 31, 0), victim.getTile()) <= 4) victim.getTempAttribs().setB(""canBrandish"", true); npc.getTasks().scheduleLooping(new Task() { int count = 0; @Override public void run() { int hit; int protection = PlayerCombatKt.getAntifireLevel(victim, true); if (protection == 1) hit = Utils.random(380, 450); else if (protection == 2) hit = Utils.random(300, 310); else hit = Utils.random(500, 800); int distance = (int) Utils.getDistance(npc.getBase().transform(33, 31, 0), victim.getTile()); if (distance <= 4) victim.getTempAttribs().setB(""canBrandish"", true); hit /= (distance / 3) + 1; victim.setNextAnimation(new Animation(PlayerCombatKt.getDefenceEmote(victim))); victim.applyHit(new Hit(npc, hit, HitLook.TRUE_DAMAGE)); if (++count == 3) { victim.getTempAttribs().setB(""canBrandish"", false); stop(); } } }, 4, 1); return Utils.random(8, 15); } @Override public boolean canAttack(QueenBlackDragon npc, Player victim) { return true; } }" "package com.rs.game.content.bosses.qbd.npcs; /** * Handles the Queen Black Dragon's time stop attack. * * @author Emperor * */ public final class TimeStopAttack implements QueenAttack { /** * The messages the soul says. */ private static final ForceTalk[] MESSAGES = { new ForceTalk(""Kill me, mortal... quickly! HURRY! BEFORE THE SPELL IS COMPLETE!""), new ForceTalk(""Time is short!""), new ForceTalk(""She is pouring her energy into me... hurry!""), new ForceTalk(""The spell is nearly complete!"") }; @Override public int attack(final QueenBlackDragon npc, final Player victim) { npc.getSouls().removeIf(Entity::isDead); if (npc.getSouls().isEmpty()) return 1; final TorturedSoul soul = npc.getSouls().get(Utils.random(npc.getSouls().size())); soul.tele(Utils.random(2) == 0 ? npc.getBase().transform(24, 28, 0) : npc.getBase().transform(42, 28, 0)); soul.setNextSpotAnim(TorturedSoul.TELEPORT_GRAPHIC); soul.setNextAnimation(TorturedSoul.TELEPORT_ANIMATION); soul.setLocked(true); WorldTasks.scheduleLooping(new Task() { int stage = -1; @Override public void run() { stage++; if (stage == 8) { stop(); npc.getTempAttribs().setI(""_time_stop_atk"", npc.getTicks() + Utils.random(50) + 40); for (TorturedSoul s : npc.getSouls()) s.setLocked(false); for (NPC worm : npc.getWorms()) worm.setLocked(false); victim.unlock(); victim.getPackets().sendVarc(1925, 0); return; } if (stage == 4) { for (TorturedSoul s : npc.getSouls()) s.setLocked(true); for (NPC worm : npc.getWorms()) worm.setLocked(true); victim.lock(); soul.setLocked(false); victim.getPackets().sendVarc(1925, 1); victim.sendMessage(""The tortured soul has stopped time for everyone except himself and the Queen Black""); victim.sendMessage(""Dragon.""); return; } if (stage > 3) return; if (soul.isDead()) { stop(); return; } soul.setNextForceTalk(MESSAGES[stage]); } }, 3, 3); npc.getTempAttribs().setI(""_time_stop_atk"", 9999999); return Utils.random(5, 10); } @Override public boolean canAttack(QueenBlackDragon npc, Player victim) { if (npc.getSouls().isEmpty()) return false; return npc.getTempAttribs().getI(""_time_stop_atk"") < npc.getTicks(); } }" "package com.rs.game.content.bosses.qbd.npcs; /** * Represents a Tortured soul. * * @author Emperor * */ public final class TorturedSoul extends NPC { /** * The messages the NPC can say. */ private static final ForceTalk[] FORCE_MESSAGES = { new ForceTalk(""NO MORE! RELEASE ME, MY QUEEN! I BEG YOU!""), new ForceTalk(""We lost our free will long ago...""), new ForceTalk(""How long has it been since I was taken...""), new ForceTalk(""The cycle is never ending, mortal..."") }; /** * The teleport graphic. */ static final SpotAnim TELEPORT_GRAPHIC = new SpotAnim(3147); /** * The teleport animation. */ static final Animation TELEPORT_ANIMATION = new Animation(16861); /** * The special attack graphic. */ private static final SpotAnim SPECIAL_GRAPHIC = new SpotAnim(3146); /** * The special attack graphic. */ private static final SpotAnim SPECIAL_ATT_GFX_ = new SpotAnim(3145); /** * The special attack animation. */ private static final Animation SPECIAL_ATT_ANIM_ = new Animation(16864); /** * The queen black dragon reference. */ private final QueenBlackDragon dragon; /** * The player victim. */ private final Player victim; /** * Constructs a new {@code TorturedSoul} {@code Object}. * * @param dragon * The queen black dragon reference. * @param victim * The player victim. * @param spawn * The spawn location. */ public TorturedSoul(QueenBlackDragon dragon, Player victim, Tile spawn) { super(15510, spawn, false); super.setHitpoints(500); super.getCombatDefinitions().setHitpoints(500); super.setForceMultiArea(true); this.dragon = dragon; this.victim = victim; super.setRandomWalk(false); super.getCombat().setTarget(victim); } @Override public void sendDeath(Entity source) { final NPCCombatDefinitions defs = getCombatDefinitions(); resetWalkSteps(); getCombat().removeTarget(); setNextAnimation(null); WorldTasks.scheduleTimer(loop -> { if (loop == 0) setNextAnimation(new Animation(defs.getDeathEmote())); else if (loop >= defs.getDeathDelay()) { finish(); return false; } return true; }); } /** * Sends the special attack. */ public void specialAttack(Tile teleport) { super.getCombat().addCombatDelay(10); super.tele(teleport); super.setNextSpotAnim(TELEPORT_GRAPHIC); super.setNextAnimation(TELEPORT_ANIMATION); super.getCombat().reset(); WorldTasks.schedule(new Task() { @Override public void run() { stop(); int diffX = getX() - victim.getX(), diffY = getY() - victim.getY(); if (diffX < 0) diffX = -diffX; if (diffY < 0) diffY = -diffY; int offsetX = 0, offsetY = 0; if (diffX > diffY) offsetX = getX() - victim.getX() < 0 ? -1 : 1; else offsetY = getY() - victim.getY() < 0 ? -1 : 1; if (victim.transform(offsetX, offsetY, 0).matches(getTile())) { offsetX = -offsetX; offsetY = -offsetY; } final int currentX = offsetX + victim.getX(); final int currentY = offsetY + victim.getY(); setNextForceTalk(FORCE_MESSAGES[Utils.random(FORCE_MESSAGES.length)]); setNextSpotAnim(SPECIAL_ATT_GFX_); setNextAnimation(SPECIAL_ATT_ANIM_); getCombat().setTarget(victim); getTasks().scheduleLooping(new Task() { int x = currentX, y = currentY; @Override public void run() { Tile current = Tile.of(x, y, 1); victim.getPackets().sendSpotAnim(SPECIAL_GRAPHIC, current); Entity target = null; for (TorturedSoul soul : dragon.getSouls()) if (soul.matches(current)) { target = soul; break; } if (target == null) for (NPC worm : dragon.getWorms()) if (worm.matches(current)) { target = worm; break; } if (target == null && victim.matches(current)) target = victim; if (target != null) { stop(); target.applyHit(new Hit(dragon, Utils.random(200, 260), HitLook.TRUE_DAMAGE)); return; } if (x > victim.getX()) x--; else if (x < victim.getX()) x++; if (y > victim.getY()) y--; else if (y < victim.getY()) y++; } }, 0, 0); } }, 1); } }" "package com.rs.game.content.bosses.tormenteddemon; @PluginEventHandler public final class TormentedDemon extends NPC { private int shieldTimer; private int prayer; private int combatStyleTimer; private int[] damageTaken = new int[3]; private int combatStyle; public TormentedDemon(int id, Tile tile, boolean spawned) { super(id, tile, spawned); shieldTimer = 0; switchPrayers(0); combatStyleTimer = Utils.random(28); combatStyle = Utils.random(3); } public void switchPrayers(int type) { transformIntoNPC(8349 + type); prayer = type; damageTaken[type] = 0; } @Override public void processNPC() { super.processNPC(); if (isDead()) return; if (shieldTimer > 0) shieldTimer--; combatStyleTimer--; if (combatStyleTimer <= 0) { combatStyleTimer = 28; combatStyle++; if (combatStyle == 3) combatStyle = 0; sendRandomProjectile(); } } @Override public void handlePreHit(final Hit hit) { super.handlePreHit(hit); if (hit.getSource() instanceof Player player) { if (player.getEquipment().getWeaponId() == 6746 && hit.getLook() == HitLook.MELEE_DAMAGE && hit.getDamage() > 0) { shieldTimer = 100; player.sendMessage(""The demon is temporarily weakened by your weapon.""); } } if (shieldTimer <= 0) { hit.setDamage((int) (hit.getDamage() * 0.25)); setNextSpotAnim(new SpotAnim(1885)); } if (hit.getLook() == HitLook.MELEE_DAMAGE) { if (prayer == 0) hit.setDamage(0); damageTaken[0] += hit.getDamage() == 0 ? 20 : hit.getDamage(); if (damageTaken[0] >= 310) switchPrayers(0); } else if (hit.getLook() == HitLook.MAGIC_DAMAGE) { if (prayer == 1) hit.setDamage(0); damageTaken[1] += hit.getDamage() == 0 ? 20 : hit.getDamage(); if (damageTaken[1] >= 310) switchPrayers(1); } else if (hit.getLook() == HitLook.RANGE_DAMAGE) { if (prayer == 2) hit.setDamage(0); damageTaken[2] += hit.getDamage() == 0 ? 20 : hit.getDamage(); if (damageTaken[2] >= 310) switchPrayers(2); } } @Override public void sendDeath(Entity source) { final NPCCombatDefinitions defs = getCombatDefinitions(); resetWalkSteps(); getCombat().removeTarget(); setNextAnimation(null); shieldTimer = 0; combatStyle = 0; damageTaken = new int[3]; prayer = 0; WorldTasks.scheduleTimer(loop -> { if (loop == 0) setNextAnimation(new Animation(defs.getDeathEmote())); else if (loop >= defs.getDeathDelay()) { drop(); reset(); setLocation(getRespawnTile()); finish(); setRespawnTask(); return false; } return true; }); } private void sendRandomProjectile() { Tile tile = Tile.of(getX() + Utils.random(7), getY() + Utils.random(7), getPlane()); for (Player player : queryNearbyPlayersByTileRange(7, player -> !player.isDead() && player.withinDistance(getTile(), 7))) { tile = Tile.of(player.getTile(), 2); break; } Tile finalTile = tile; setNextAnimation(new Animation(10917)); World.sendProjectile(this, tile, 1884, 100, 16, 40, 0.6, 16, p -> { World.sendSpotAnim(finalTile, new SpotAnim(1883)); for (Player player : queryNearbyPlayersByTileRange(7, player -> !player.isDead() && player.withinDistance(finalTile, 1))) { player.sendMessage(""The demon's magical attack splashes on you.""); player.applyHit(new Hit(this, 281, HitLook.MAGIC_DAMAGE, 1)); } }); } @Override public void setRespawnTask() { if (!hasFinished()) { reset(); setLocation(getRespawnTile()); finish(); } final NPC npc = this; WorldTasks.schedule(getCombatDefinitions().getRespawnDelay(), () -> { try { switchPrayers(0); setFinished(false); World.addNPC(npc); npc.setLastChunkId(0); ChunkManager.updateChunks(npc); loadMapRegions(); checkMultiArea(); shieldTimer = 0; } catch (Throwable e) { Logger.handle(TormentedDemon.class, ""setRespawnTask"", e); } }); } public static boolean atTD(Tile tile) { if ((tile.getX() >= 2560 && tile.getX() <= 2630) && (tile.getY() >= 5710 && tile.getY() <= 5753)) return true; return false; } public int getCombatStyleTimer() { return combatStyleTimer; } public int getCombatStyle() { return combatStyle; } public static NPCInstanceHandler toFunc = new NPCInstanceHandler(new Object[] { 8349, 8350, 8351 }, (npcId, tile) -> new TormentedDemon(npcId, tile, false)); }" "package com.rs.game.content.bosses.tormenteddemon; public class TormentedDemonCombat extends CombatScript { @Override public Object[] getKeys() { return new Object[] { ""Tormented demon"" }; } @Override public int attack(NPC npc, Entity target) { TormentedDemon torm = null; if (npc instanceof TormentedDemon td) torm = td; if (torm == null) return 0; int hit = 0; int attackStyle = torm.getCombatStyle(); if (torm.getCombatStyleTimer() >= 23) return 0; switch (attackStyle) { case 0: if (!npc.inMeleeRange(target) || !npc.lineOfSightTo(target, true)) { npc.calcFollow(target, false); return 0; } hit = getMaxHit(npc, 189, AttackStyle.MELEE, target); npc.setNextAnimation(new Animation(10922)); npc.setNextSpotAnim(new SpotAnim(1886)); delayHit(npc, 1, target, getMeleeHit(npc, hit)); return 7; case 1: hit = getMaxHit(npc, 270, AttackStyle.MAGE, target); npc.setNextAnimation(new Animation(10918)); npc.setNextSpotAnim(new SpotAnim(1883, 0, 96 << 16)); delayHit(npc, World.sendProjectile(npc, target, 1884, 34, 16, 30, 35, 16, 0).getTaskDelay(), target, getMagicHit(npc, hit)); break; case 2: hit = getMaxHit(npc, 270, AttackStyle.RANGE, target); npc.setNextAnimation(new Animation(10919)); npc.setNextSpotAnim(new SpotAnim(1888)); delayHit(npc, World.sendProjectile(npc, target, 1887, 34, 16, 30, 35, 16, 0).getTaskDelay(), target, getRangeHit(npc, hit)); break; } return 7; } }" "package com.rs.game.content.clans; @PluginEventHandler public class ClansManager { private static final Map CACHED_CLANS = new ConcurrentHashMap<>(); public static Clan getClan(String name) { if (name == null) return null; if (CACHED_CLANS.get(name) == null) { try { LobbyCommunicator.getClan(name, clan -> { if (clan == null || clan.getName() == null) { Logger.error(ClansManager.class, ""getClan"", ""Clan returned from lobby server was null "" + name); return; } CACHED_CLANS.put(name, clan); }); } catch(Throwable e) { Logger.error(ClansManager.class, ""getClan"", ""Error communicating with clan service. "" + name); } return null; } return CACHED_CLANS.get(name); } public static void getClan(String name, Consumer cb) { if (name == null) return; if (CACHED_CLANS.get(name) == null) { try { LobbyCommunicator.getClan(name, clan -> { if (clan == null || clan.getName() == null) { Logger.error(ClansManager.class, ""getClan"", ""Clan returned from lobby server was null "" + name); cb.accept(null); return; } CACHED_CLANS.put(name, clan); cb.accept(clan); }); } catch(Throwable e) { cb.accept(null); Logger.error(ClansManager.class, ""getClan"", ""Error communicating with clan service: "" + name); } } else cb.accept(CACHED_CLANS.get(name)); } public static void syncClanFromLobby(Clan clan) { if (clan == null || clan.getName() == null) { Logger.error(ClansManager.class, ""syncClanFromLobby"", ""Clan returned from lobby server was null""); return; } CACHED_CLANS.put(clan.getName(), clan); for (String username : clan.getMembers().keySet()) { Player player = World.getPlayerByUsername(username); if (player == null || player.hasFinished() || !player.hasStarted()) continue; player.getAppearance().generateAppearanceData(); for (int key : clan.getVars().keySet()) player.getPackets().setClanVar(key, clan.getVar(key)); if (player.getInterfaceManager().topOpen(1096)) WorldTasks.delay(0, () -> player.getPackets().sendRunScript(4295)); } } public static void syncClanToLobby(Clan clan) { syncClanToLobby(clan, null); } public static void syncClanToLobby(Clan clan, Runnable done) { LobbyCommunicator.updateClan(clan, res -> { if (res == null) { if (done != null) done.run(); return; } CACHED_CLANS.put(res.getName(), res); if (done != null) done.run(); }); } public static void clanMotto(Player player) { player.startConversation(new Dialogue(new Statement() { @Override public void send(Player player) { player.sendInputLongText(""Enter clan motto:"", motto -> player.getClan().setMotto(motto)); player.getInterfaceManager().sendChatBoxInterface(1103); } @Override public int getOptionId(int componentId) { return 0; } @Override public void close(Player player) { } })); } public static void create(Player player, String name) { player.sendOptionDialogue(""The name "" + name + "" is available. Create the clan?"", ops -> { ops.add(""Yes, create "" + name + ""."", () -> LobbyCommunicator.forwardPacket(player, new ClanCreate(name), cb -> { })); ops.add(""No, I want to pick another name.""); }); } public static void promptName(Player player) { player.sendInputName(""Which name would you like for your clan?"", name -> { if (player.getTempAttribs().getB(""ccCreateLock"")) { player.simpleDialogue(""Your previous request to create a clan is still in progress... Please wait or relog.""); return; } player.getTempAttribs().setB(""ccCreateLock"", true); LobbyCommunicator.forwardPacket(player, new ClanCheckName(name, false), cb -> player.getTempAttribs().removeB(""ccCreateLock"")); }); } public static ButtonClickHandler handleClanChatButtons = new ButtonClickHandler(1110, e -> { if (e.getPlayer().hasRights(Rights.DEVELOPER)) e.getPlayer().sendMessage(""handleClanChatButtons: "" + e.getComponentId() + "" - "" + e.getSlotId() + "" - "" + e.getPacket()); switch(e.getComponentId()) { case 82 -> { if (e.getPlayer().getSocial().isConnectedToClan() && e.getPlayer().getSocial().getClanName() != null) leaveChannel(e.getPlayer(), false); else joinChannel(e.getPlayer(), null); } case 91 -> { if (e.getPlayer().getSocial().getGuestedClanChat() != null) leaveChannel(e.getPlayer(), true); else e.getPlayer().sendInputName(""Which clan chat would you like to join?"", ""Please enter the name of the clan whose Clan chat you wish to join as a guest.

To talk as a guest, start your
line
of chat with ///"", name -> joinChannel(e.getPlayer(), name)); } case 59 -> e.getPlayer().getPackets().sendRunScript(4443, -1); case 95 -> e.getPlayer().sendInputName(""Which player would you like to ban?"", name -> banPlayer(e.getPlayer(), name)); case 78 -> openSettings(e.getPlayer()); case 75 -> openClanDetails(e.getPlayer(), null, e.getPlayer().getClan()); case 109 -> leaveClan(e.getPlayer()); case 11 -> unban(e.getPlayer(), e.getSlotId()); case 99 -> e.getPlayer().sendInputName(""Which player would you like to unban?"", name -> unban(e.getPlayer(), Utils.formatPlayerNameForDisplay(name))); } }); public static ButtonClickHandler handleClanFlagButtons = new ButtonClickHandler(1089, e -> { if (e.getPlayer().getClan() == null) return; switch(e.getComponentId()) { case 30 -> e.getPlayer().getTempAttribs().setI(""clanflagselection"", e.getSlotId()); case 26 -> { int flag = e.getPlayer().getTempAttribs().removeI(""clanflagselection"", -1); e.getPlayer().stopAll(); if (flag != -1) { if (!e.getPlayer().getClan().hasPermissions(e.getPlayer().getUsername(), ClanRank.ADMIN)) return; e.getPlayer().getClan().setSetting(ClanSetting.NATIONAL_FLAG, flag); syncClanToLobby(e.getPlayer().getClan(), () -> e.getPlayer().sendMessage(""Clan settings saved."")); } } } }); public static ButtonClickHandler handleClanSettingsButtonsMain = new ButtonClickHandler(1096, e -> { if (e.getPlayer().hasRights(Rights.DEVELOPER)) e.getPlayer().sendMessage(""handleClanSettingsButtonsMain: "" + e.getComponentId() + "" - "" + e.getSlotId() + "" - "" + e.getPacket()); switch(e.getComponentId()) { case 41 -> viewClanmateDetails(e.getPlayer(), e.getSlotId()); case 94 -> setClanSetting(e.getPlayer(), ClanSetting.GUESTS_CAN_ENTER_CC, (int) e.getPlayer().getClan().getSetting(ClanSetting.GUESTS_CAN_ENTER_CC) == 0 ? 1 : 0); case 95 -> setClanSetting(e.getPlayer(), ClanSetting.GUESTS_CAN_TALK_CC, (int) e.getPlayer().getClan().getSetting(ClanSetting.GUESTS_CAN_TALK_CC) == 0 ? 1 : 0); case 96 -> { boolean set = ((int) e.getPlayer().getClan().getSetting(ClanSetting.IS_RECRUITING)) == 1; setClanSetting(e.getPlayer(), ClanSetting.IS_RECRUITING, set ? 0 : 1); syncClanToLobby(e.getPlayer().getClan()); } case 97 -> { boolean set = ((int) e.getPlayer().getClan().getSetting(ClanSetting.USES_CLANTIMEZONE)) == 1; setClanSetting(e.getPlayer(), ClanSetting.USES_CLANTIMEZONE, set ? 0 : 1); syncClanToLobby(e.getPlayer().getClan()); } case 113 -> showClanSettingsClanMates(e.getPlayer()); case 120 -> showClanSettingsSettings(e.getPlayer()); case 124 -> openClanMotifInterface(e.getPlayer()); case 131 -> openClanMottoInterface(e.getPlayer()); case 160 -> openKeywordEditor(e.getPlayer()); case 222 -> { if (!canEditSettings(e.getPlayer())) return; setVar(e.getPlayer().getClan(), 2811, Utils.clampI(e.getSlotId(), 0, 4)); //signpost permissions } case 207 -> setClanSetting(e.getPlayer(), ClanSetting.GUEST_CITADEL_ACCESS, Utils.clampI(e.getSlotId(), 0, 3)); case 240 -> setClanSetting(e.getPlayer(), ClanSetting.GAME_TIME, -720 + e.getSlotId() * 10); case 290 -> setClanSetting(e.getPlayer(), ClanSetting.HOME_WORLD, Utils.clampI(e.getSlotId(), 0, 200)); case 297 -> openForumThreadInterface(e.getPlayer()); case 346 -> openNationalFlagInterface(e.getPlayer()); case 386 -> showClanSettingsPermissions(e.getPlayer()); case 489 -> selectPermissionTab(e.getPlayer(), 1); case 498 -> selectPermissionTab(e.getPlayer(), 2); case 506 -> selectPermissionTab(e.getPlayer(), 3); case 514 -> selectPermissionTab(e.getPlayer(), 4); case 522 -> selectPermissionTab(e.getPlayer(), 5); case 262 -> e.getPlayer().getTempAttribs().setI(""editClanMateJob"", e.getSlotId()); case 276 -> e.getPlayer().getTempAttribs().setI(""editClanMateRank"", e.getSlotId()); case 309 -> kick(e.getPlayer()); case 318 -> saveClanmateDetails(e.getPlayer()); case 366 -> e.getPlayer().getPackets().sendVarc(1516, e.getSlotId()); case 558 -> { ClanRank rank = e.getPlayer().getTempAttribs().getO(""permissionRankEditing""); if (rank == null) { e.getPlayer().sendMessage(""Please select a rank before setting the chat ranking.""); return; } e.getPlayer().getClan().setCcChatRank(rank); } case 570 -> { ClanRank rank = e.getPlayer().getTempAttribs().getO(""permissionRankEditing""); if (rank == null) { e.getPlayer().sendMessage(""Please select a rank before setting the kick ranking.""); return; } e.getPlayer().getClan().setCcKickRank(rank); } case 534, 547, 752, 739, 483, 659, 581, 592, 648, 684, 671, 793, 696, 603, 614, 782, 625, 815, 720, 708, 804 -> togglePermissionSetting(e.getPlayer(), e.getComponentId()); default -> { if (e.getComponentId() >= 395 && e.getComponentId() <= 475) { int selectedRank = (e.getComponentId() - 395) / 8; if (selectedRank == 10) selectedRank = 125; else if (selectedRank > 5) selectedRank = 100 + selectedRank - 6; selectPermissionRank(e.getPlayer(), ClanRank.forId(selectedRank)); } } } }); public static ButtonClickHandler handleMotifButtons = new ButtonClickHandler(1105, e -> { if (e.getPlayer().hasRights(Rights.DEVELOPER)) e.getPlayer().sendMessage(""handleMotifButtons: "" + e.getComponentId() + "" - "" + e.getSlotId() + "" - "" + e.getPacket()); if (e.getComponentId() == 63 || e.getComponentId() == 66) ClansManager.setClanMotifTextureInterface(e.getPlayer(), e.getComponentId() == 66, e.getSlotId()); if (e.getComponentId() == 35) ClansManager.openSetMotifColor(e.getPlayer(), 0); else if (e.getComponentId() == 80) ClansManager.openSetMotifColor(e.getPlayer(), 1); else if (e.getComponentId() == 92) ClansManager.openSetMotifColor(e.getPlayer(), 2); else if (e.getComponentId() == 104) ClansManager.openSetMotifColor(e.getPlayer(), 3); else if (e.getComponentId() == 120) { syncClanToLobby(e.getPlayer().getClan()); e.getPlayer().stopAll(); } }); private static final BiMap KEYWORD_INDICES = HashBiMap.create(10); static { KEYWORD_INDICES.put(ClanSetting.KEYWORD0_CATEGORY, 9155); KEYWORD_INDICES.put(ClanSetting.KEYWORD0_INDEX, 9156); KEYWORD_INDICES.put(ClanSetting.KEYWORD1_CATEGORY, 9157); KEYWORD_INDICES.put(ClanSetting.KEYWORD1_INDEX, 9158); KEYWORD_INDICES.put(ClanSetting.KEYWORD2_CATEGORY, 9159); KEYWORD_INDICES.put(ClanSetting.KEYWORD2_INDEX, 9160); KEYWORD_INDICES.put(ClanSetting.KEYWORD3_CATEGORY, 9161); KEYWORD_INDICES.put(ClanSetting.KEYWORD3_INDEX, 9162); KEYWORD_INDICES.put(ClanSetting.KEYWORD4_CATEGORY, 9163); KEYWORD_INDICES.put(ClanSetting.KEYWORD4_INDEX, 9164); KEYWORD_INDICES.put(ClanSetting.KEYWORD5_CATEGORY, 9165); KEYWORD_INDICES.put(ClanSetting.KEYWORD5_INDEX, 9166); KEYWORD_INDICES.put(ClanSetting.KEYWORD6_CATEGORY, 9167); KEYWORD_INDICES.put(ClanSetting.KEYWORD6_INDEX, 9168); KEYWORD_INDICES.put(ClanSetting.KEYWORD7_CATEGORY, 9169); KEYWORD_INDICES.put(ClanSetting.KEYWORD7_INDEX, 9170); KEYWORD_INDICES.put(ClanSetting.KEYWORD8_CATEGORY, 9171); KEYWORD_INDICES.put(ClanSetting.KEYWORD8_INDEX, 9172); KEYWORD_INDICES.put(ClanSetting.KEYWORD9_CATEGORY, 9173); KEYWORD_INDICES.put(ClanSetting.KEYWORD9_INDEX, 9174); } public static ButtonClickHandler handleKeywordButtons = new ButtonClickHandler(1097, e -> { if (e.getPlayer().hasRights(Rights.DEVELOPER)) e.getPlayer().sendMessage(""handleKeywordButtons: "" + e.getComponentId() + "" - "" + e.getSlotId() + "" - "" + e.getPacket()); switch(e.getComponentId()) { case 193 -> e.getPlayer().getVars().setVar(2136, e.getSlotId()); case 207 -> { int enumId = EnumDefinitions.getEnum(3703).getIntValue(e.getPlayer().getVars().getVar(2136)); if (enumId == -1) { e.getPlayer().getTempAttribs().removeI(""keywordTempVal""); return; } EnumDefinitions infoDef = EnumDefinitions.getEnum(enumId); if (infoDef.getStringValue(e.getSlotId()) != null && !infoDef.getStringValue(e.getSlotId()).equals(""null"")) e.getPlayer().getTempAttribs().setI(""keywordTempVal"", e.getSlotId()); else e.getPlayer().getTempAttribs().removeI(""keywordTempVal""); } case 15 -> { int category = e.getPlayer().getVars().getVar(2136); if (category <= 0) return; int index = e.getPlayer().getTempAttribs().getI(""keywordTempVal""); for (ClanSetting setting : KEYWORD_INDICES.keySet()) { if (setting.name().contains(""INDEX"")) continue; int varbit = KEYWORD_INDICES.get(setting); if (e.getPlayer().getVars().getVarBit(varbit) <= 0) { e.getPlayer().getVars().setVarBit(varbit, category); e.getPlayer().getVars().setVarBit(varbit+1, index); break; } } } case 160, 171, 172, 173, 174, 175, 176, 177, 178, 179 -> { int index = e.getComponentId() == 160 ? 0 : e.getComponentId() - 170; int baseVar = 9155 + (index * 2); e.getPlayer().getVars().setVarBit(baseVar, 0); e.getPlayer().getVars().setVarBit(baseVar+1, 0); } case 42 -> { for (ClanSetting setting : KEYWORD_INDICES.keySet()) setClanSetting(e.getPlayer(), setting, e.getPlayer().getVars().getVarBit(KEYWORD_INDICES.get(setting))); e.getPlayer().stopAll(); syncClanToLobby(e.getPlayer().getClan()); } } }); public static ButtonClickHandler handleCloseButton = new ButtonClickHandler(1079, e -> e.getPlayer().closeInterfaces()); public static ButtonClickHandler handleInviteInter = new ButtonClickHandler(1095, e -> { if (e.getComponentId() == 33) { Player inviter = e.getPlayer().getTempAttribs().removeO(""clanInviter""); if (inviter == null) { e.getPlayer().sendMessage(""There is a pending request to join a clan submitted to the clan service. Relog or try again later.""); return; } if (inviter.hasStarted() && !inviter.hasFinished()) { LobbyCommunicator.forwardPacket(inviter, new ClanAddMember(e.getPlayer().getUsername()), success -> { if (!success) e.getPlayer().sendMessage(""There was an error communicating with the clan service.""); }); } e.getPlayer().closeInterfaces(); } }); public static InterfaceOnPlayerHandler handleInvite = new InterfaceOnPlayerHandler(false, new int[] { 1110 }, e -> { if (e.getComponentId() == 87) { if (e.getTarget().getSocial().getClanName() != null) { e.getPlayer().sendMessage(e.getTarget().getDisplayName() + "" is already in a clan.""); return; } e.getPlayer().sendMessage(""Sending clan invite to "" + e.getTarget().getDisplayName() + "".""); e.getTarget().getPackets().sendClanInviteMessage(e.getPlayer()); } }); public static void viewClanmateDetails(Player player, int index) { if (player.getClan() == null) return; if (index >= player.getClan().getMembers().keySet().size()) { player.sendMessage(""This is a placeholder character to unlock all clan features without needing 5 players.""); return; } String username = new ArrayList<>(player.getClan().getMembers().keySet()).get(index); MemberData member = player.getClan().getMembers().get(username); if (member == null) return; LobbyCommunicator.getAccount(username, acc -> { if (acc == null) { player.sendMessage(""Error finding player profile for target character.""); return; } viewClanmateDetails(player, acc.getDisplayName(), member); player.getTempAttribs().removeI(""editClanMateRank""); player.getTempAttribs().removeI(""editClanMateJob""); if (player.getClan().hasPermissions(player.getUsername(), ClanRank.ADMIN)) player.getTempAttribs().setO(""editClanMate"", username); }); player.getTempAttribs().removeI(""editClanMateRank""); player.getTempAttribs().removeI(""editClanMateJob""); if (player.getClan().hasPermissions(player.getUsername(), ClanRank.ADMIN)) player.getTempAttribs().setO(""editClanMate"", username); } protected static void togglePermissionSetting(Player player, int componentId) { ClanRank rank = player.getTempAttribs().getO(""permissionRankEditing""); if (rank == null) { player.sendMessage(""Please select a rank to edit before editing permissions.""); return; } String settingName = switch(componentId) { case 534 -> ""PERMISSION_LOCK_KEEP""; case 547 -> ""PERMISSION_LOCK_CITADEL""; case 739 -> ""PERMISSION_ENTER_KEEP""; case 752 -> ""PERMISSION_ENTER_CITADEL""; case 483 -> ""PERMISSION_INVITE""; case 659 -> ""PERMISSION_LEAD_CLANWARS""; case 581 -> ""PERMISSION_SIGNPOST""; case 592 -> ""PERMISSION_NOTICEBOARD""; case 648 -> ""PERMISSION_START_BATTLE""; case 671 -> ""PERMISSION_CALL_VOTE""; case 684 -> ""PERMISSION_BEGIN_MEETING""; case 793 -> ""PERMISSION_THEATER""; case 696 -> ""PERMISSION_PARTY_ROOM""; case 603 -> ""PERMISSION_CITADEL_UPGRADE""; case 614 -> ""PERMISSION_CITADEL_DOWNGRADE""; case 625 -> ""PERMISSION_EDIT_BATTLEFIELD""; case 782 -> ""PERMISSION_CITADEL_LANGUAGE""; case 815 -> ""PERMISSION_CHECK_RESOURCES""; case 720 -> ""PERMISSION_BUILD_TIME""; case 804 -> ""PERMISSION_LOCK_PLOTS""; case 708 -> ""PERMISSION_RESOURCE_GATHER""; default -> null; }; if (settingName == null) { player.sendMessage(""Unknown clan setting for component: "" + componentId); return; } ClanSetting setting = null; for (ClanSetting s : ClanSetting.values()) { if (s.name().equals(rank.name() + ""_"" + settingName)) { setting = s; break; } } if (setting == null) { player.sendMessage(""Cannot edit permission "" + settingName + "" for rank "" + rank + "".""); return; } player.getClan().setSetting(setting, (int) player.getClan().getSetting(setting) == 1 ? 0 : 1); } public static void viewClanmateDetails(Player player, String username, MemberData member) { player.getPackets().sendVarc(1500, member.getRank().getIconId()); player.getPackets().sendVarc(1501, member.getJob()); player.getPackets().sendVarc(1564, 0); player.getPackets().sendVarc(1565, member.isBanFromKeep() ? 1 : 0); player.getPackets().sendVarc(1566, member.isBanFromCitadel() ? 1 : 0); player.getPackets().sendVarc(1567, member.isBanFromIsland() ? 1 : 0); player.getPackets().sendVarc(1568, member.firstWeek() ? 1 : 0); player.getPackets().sendVarcString(347, username); player.getPackets().sendRunScriptBlank(4319); } private static void saveClanmateDetails(Player player) { int jobId = player.getTempAttribs().getI(""editClanMateJob"", -1); int rankId = player.getTempAttribs().getI(""editClanMateRank"", -1); String editingUser = player.getTempAttribs().getO(""editClanMate""); ClanRank currRank = player.getClan().getRank(editingUser); ClanRank newRank = ClanRank.forId(rankId); ClanRank playerRank = player.getClan().getRank(player.getUsername()); if (!player.getClan().hasPermissions(player.getUsername(), ClanRank.ADMIN)) { player.sendMessage(""Only clan admins can edit ranks and jobs.""); return; } if (newRank == ClanRank.NONE || newRank == ClanRank.OWNER) return; if (newRank != currRank) { if (currRank.ordinal() >= playerRank.ordinal()) { player.sendMessage(""You can only edit the rank of players with lesser rank than you.""); return; } if (newRank.ordinal() > playerRank.ordinal()) { player.sendMessage(""You cannot promote someone to a rank higher than your own.""); return; } } if (currRank == ClanRank.OWNER && newRank != ClanRank.OWNER) { String deputyOwner = null; for (String memberName : player.getClan().getMembers().keySet()) { if (player.getClan().getMembers().get(memberName).getRank() == ClanRank.DEPUTY_OWNER) { deputyOwner = memberName; break; } } if (deputyOwner == null) { if (player != null) player.sendMessage(""You are currently the clan owner, you must at least have one deputy owner in the clan to demote yourself.""); return; } player.getClan().setClanLeaderUsername(deputyOwner); player.getClan().getMembers().get(deputyOwner).setRank(ClanRank.OWNER); } player.getClan().getMembers().get(editingUser).setRank(newRank); if (jobId != -1 && EnumDefinitions.getEnum(3720).getStringValue(jobId) != null) player.getClan().getMembers().get(editingUser).setJob(jobId); syncClanToLobby(player.getClan()); } private static void kick(Player player) { String editingUser = player.getTempAttribs().getO(""editClanMate""); player.sendOptionDialogue(""Are you sure you would like to kick this player from the clan?"", ops -> { ops.add(""Yes, I am sure I want to kick them."", () -> LobbyCommunicator.forwardPacket(player, new ClanKickMember(editingUser), res -> { if (!res) player.sendMessage(""Failed to send kick request to social server.""); })); ops.add(""Nevermind""); }); } private static void banPlayer(Player player, String name) { // TODO Auto-generated method stub } private static void unban(Player player, String displayName) { // TODO Auto-generated method stub } private static void unban(Player player, int slotId) { // TODO Auto-generated method stub } public static void unlockBanList(Player player) { player.getPackets().setIFRightClickOps(1110, 11, 0, 100, 0); } private static void joinChannel(Player player, String guestClanName) { if (guestClanName == null && player.getSocial().getClanName() == null) { createClan(player); return; } if (player.getTempAttribs().getB(""ccJoinLock"")) { player.sendMessage(""Please wait...""); return; } player.getTempAttribs().setB(""ccJoinLock"", true); LobbyCommunicator.forwardPacket(player, new CCJoin(guestClanName), cb -> player.getTempAttribs().removeB(""ccJoinLock"")); } private static void createClan(Player player) { player.startConversation(new Conversation(new Dialogue(new SimpleStatement(""You are not currently in a clan. Would you like to create one?""))) .addOption(""Create a clan?"", ""Yes"", ""Not right now."") .addNext(() -> promptName(player))); } private static void leaveChannel(Player player, boolean guest) { if (player.getTempAttribs().getB(""ccLeaveLock"")) { player.sendMessage(""Please wait...""); return; } player.getTempAttribs().setB(""ccLeaveLock"", true); LobbyCommunicator.forwardPacket(player, new CCLeave(guest), cb -> player.getTempAttribs().removeB(""ccLeaveLock"")); } private static void leaveClan(Player player) { if (player.getSocial().getClanName() == null) { player.sendMessage(""You aren't in a clan.""); return; } if (player.getTempAttribs().getB(""ccLeaveLock"")) { player.sendMessage(""Please wait...""); return; } player.sendOptionDialogue(""Are you sure you want to leave your clan?"", conf1 -> { conf1.add(""I am sure I want to leave the clan."").addOptions(""Are you ABSOLUTELY sure you want to leave?"", conf2 -> { conf2.add(""Yes, I am absolutely sure I want to leave my clan."", () -> { player.getTempAttribs().setB(""ccLeaveLock"", true); LobbyCommunicator.forwardPacket(player, new ClanLeave(), cb -> player.getTempAttribs().removeB(""ccLeaveLock"")); }); conf2.add(""No, I've changed my mind.""); }); conf1.add(""Nevermind.""); }); } private static void openSettings(Player player) { if (player.getClan() == null) { player.sendMessage(""You must be in a clan to do that.""); return; } player.getInterfaceManager().sendInterface(1096); if (player.getClan().hasPermissions(player.getUsername(), ClanRank.ADMIN)) player.setCloseInterfacesEvent(() -> syncClanToLobby(player.getClan(), () -> player.sendMessage(""Saved clan details successfully.""))); showClanSettingsClanMates(player); selectPermissionTab(player, 1); player.getPackets().setIFRightClickOps(1096, 240, 0, 144, 0); // unlocks timezone setting player.getPackets().setIFRightClickOps(1096, 290, 0, 200, 0); // unlocks worldid setting player.getPackets().setIFRightClickOps(1096, 41, 0, Clan.MAX_MEMBERS, 0); // unlocks clanmates player.getPackets().setIFRightClickOps(1096, 276, 0, 125, 0); // set member rank player.getPackets().setIFRightClickOps(1096, 262, 0, 500, 0); // set member profession player.getPackets().setIFRightClickOps(1096, 366, 0, 127, 0); // unlocks rank filters player.getPackets().setIFRightClickOps(1096, 222, 0, 4, 0); // unlocks signpost permissions player.getPackets().setIFRightClickOps(1096, 207, 0, 3, 0); // unlocks guest access to citadel settings } private static void selectPermissionRank(Player player, ClanRank rank) { Clan clan = player.getClan(); if (clan == null || rank == null) return; player.getTempAttribs().setO(""permissionRankEditing"", rank); player.getPackets().sendRunScript(5130); player.getPackets().sendVarc(1569, rank.getIconId()); for (ClanPermission perm : ClanPermission.values()) player.getPackets().sendVarc(perm.getVarc(), perm.hasPermission(clan, rank) ? 1 : 0); } private static void selectPermissionTab(Player player, int tab) { player.getPackets().sendRunScript(5136, tab); player.getPackets().setIFHidden(1096, 26, true); for (int i = 16;i <= 20;i++) player.getPackets().setIFHidden(1096, i, tab != i - 15); } private static void showClanSettingsClanMates(Player player) { player.getPackets().setIFHidden(1096, 85, true); player.getPackets().setIFHidden(1096, 385, true); player.getPackets().sendRunScript(4298); } private static void showClanSettingsSettings(Player player) { player.getPackets().setIFHidden(1096, 85, true); player.getPackets().setIFHidden(1096, 385, true); player.getPackets().sendRunScript(4296); } private static void showClanSettingsPermissions(Player player) { player.getPackets().setIFHidden(1096, 85, false); player.getPackets().setIFHidden(1096, 385, false); } public static void openClanInvite(Player player, Player inviter, Clan clan) { if (clan == null || clan.getUpdateBlock() == null) { player.sendMessage(""Error loading clan update block.""); return; } player.getSession().write(new ClanSettingsFull(clan.getUpdateBlock(), true)); player.getInterfaceManager().sendInterface(1095); player.getTempAttribs().setO(""clanInviter"", inviter); player.setCloseInterfacesEvent(() -> player.getTempAttribs().removeO(""clanInviter"")); } public static void openClanDetails(Player player, Player vexPlanter, Clan clan) { if (clan == null || clan.getUpdateBlock() == null) { player.sendMessage(""Error loading clan update block.""); return; } player.getSession().write(new ClanSettingsFull(clan.getUpdateBlock(), true)); player.getInterfaceManager().sendInterface(1107); if (vexPlanter != null) { player.getPackets().setIFText(1107, 92, vexPlanter.getDisplayName()); //player.getPackets().sendRunScript(4423); } else //player.getPackets().sendRunScript(4422); player.getPackets().sendRunScript(4413); } public static void openNationalFlagInterface(Player player) { if (player.getClan() == null) return; if (!player.getClan().hasPermissions(player.getUsername(), ClanRank.ADMIN)) { player.sendMessage(""Only clan admins can edit the clan settings.""); return; } player.stopAll(); player.getInterfaceManager().sendInterface(1089); player.getPackets().setIFRightClickOps(1089, 30, 0, 241, 0); player.setCloseInterfacesEvent(() -> openSettings(player)); } public static void openKeywordEditor(Player player) { if (player.getClan() == null) return; if (!player.getClan().hasPermissions(player.getUsername(), ClanRank.ADMIN)) { player.sendMessage(""Only clan admins can edit the clan settings.""); return; } player.stopAll(); player.getTempAttribs().removeI(""keywordTempVal""); player.getVars().setVar(2136, 0); for (int var : KEYWORD_INDICES.inverse().keySet()) player.getVars().setVarBit(var, (int) player.getClan().getSetting(KEYWORD_INDICES.inverse().get(var))); player.getInterfaceManager().sendInterface(1097); player.getPackets().setIFRightClickOps(1097, 193, 0, 100, 0); player.getPackets().setIFRightClickOps(1097, 207, 0, 100, 0); player.setCloseInterfacesEvent(() -> openSettings(player)); } public static void openForumThreadInterface(Player player) { if (player.getClan() == null) return; if (!player.getClan().hasPermissions(player.getUsername(), ClanRank.ADMIN)) return; player.getInterfaceManager().sendChatBoxInterface(1100); player.sendInputForumQFC(qfc -> { player.getInterfaceManager().closeChatBoxInterface(); long val = -1; try { val = Long.valueOf(qfc, 36); } catch(NumberFormatException e) { player.sendMessage(""Please enter a valid formatted code.""); return; } if (setClanSetting(player, ClanSetting.FORUM_QFC, val)) syncClanToLobby(player.getClan(), () -> {}); }); } public static void openClanMottoInterface(Player player) { Clan clan = player.getClan(); if (clan == null) return; if (!clan.hasPermissions(player.getUsername(), ClanRank.ADMIN)) return; player.stopAll(); player.sendInputLongText(""Please enter your desired clan motto:"", motto -> { if (setClanSetting(player, ClanSetting.MOTTO, motto)) syncClanToLobby(player.getClan(), () -> {}); }); } public static void openClanMotifInterface(Player player) { player.stopAll(); player.getInterfaceManager().sendInterface(1105); player.getPackets().sendRunScript(4400, 72417446); player.getPackets().setIFRightClickOps(1105, 66, 0, 116, 0); // top player.getPackets().setIFRightClickOps(1105, 63, 0, 116, 0); // button player.getVars().setVarBit(9086, player.getClan().getMotifTopIcon()); player.getVars().setVarBit(9087, player.getClan().getMotifBottomIcon()); for (int i = 0; i < player.getClan().getMotifColors().length; i++) player.getVars().setVar(2094 + i, player.getClan().getMotifColors()[i]); player.setCloseInterfacesEvent(() -> openSettings(player)); } public static void openSetMotifColor(Player player, int part) { player.getInterfaceManager().sendInterface(1106); player.sendInputHSL(color -> { player.getClan().setMotifColor(part, color); syncClanToLobby(player.getClan(), () -> player.sendMessage(""Saved clan details successfully."")); openClanMotifInterface(player); }); } public static void setClanMotifTextureInterface(Player player, boolean top, int slot) { if (slot > 116) return; setClanMotifTexture(player, top, slot); } public static void setClanMotifTexture(Player player, boolean top, int slot) { if (!player.getClan().hasPermissions(player.getUsername(), ClanRank.ADMIN)) return; if (top) setClanSetting(player, ClanSetting.MOTIF_TOP_ICON, slot+1); else setClanSetting(player, ClanSetting.MOTIF_BOTTOM_ICON, slot+1); player.getVars().setVarBit(9086, player.getClan().getMotifTopIcon()); player.getVars().setVarBit(9087, player.getClan().getMotifBottomIcon()); } public static void setVar(Clan clan, int id, Object value) { clan.setVar(id, value); syncClanToLobby(clan, () -> {}); } public static void setVar(Clan clan, ClanVar var, Object value) { clan.setVar(var, value); syncClanToLobby(clan, () -> {}); } public static boolean setClanSetting(Player player, ClanSetting setting, Object value) { if (!canEditSettings(player)) return false; if (player.getClan().getSetting(setting) == value) return false; player.getClan().setSetting(setting, value); return true; } public static boolean canEditSettings(Player player) { if (player.getClan() == null) { player.sendMessage(""Error getting clan info to edit.""); return false; } if (!player.getClan().hasPermissions(player.getUsername(), ClanRank.ADMIN)) { player.sendMessage(""Only clan administrators can edit clan settings.""); return false; } return true; } public static int[] generateColorGradient(Clan clan, int length, boolean hasTextures) { RSColor primary = RSColor.fromHSL((int) clan.getSetting(ClanSetting.MOTIF_PRIMARY_COLOR)); RSColor secondary = RSColor.fromHSL((int) clan.getSetting(ClanSetting.MOTIF_SECONDARY_COLOR)); int[] colors = new int[length]; if (hasTextures) { colors[0] = (int) clan.getSetting(ClanSetting.MOTIF_TOP_COLOR); colors[1] = (int) clan.getSetting(ClanSetting.MOTIF_BOTTOM_COLOR); } int offset = hasTextures ? 2 : 0; int luminanceAdjustor = 40 / (colors.length - offset); int sizeDiff = (colors.length - offset) / 2; boolean initedPrimary = false, initedSecondary = false; for (int i = colors.length-1;i >= offset;i--) { if (sizeDiff-- > 0) { colors[i] = secondary.adjustLuminance(initedSecondary ? luminanceAdjustor : 0).getValue(); initedSecondary = true; } else { colors[i] = primary.adjustLuminance(initedPrimary ? luminanceAdjustor : 0).getValue(); initedPrimary = true; } } return colors; } public static void clanifyObject(Clan clan, GameObject object) { if (object.getDefinitions().modifiedColors == null) return; boolean hasTextures = object.getDefinitions().modifiedTextures != null; int[] colors = generateColorGradient(clan, object.getDefinitions().modifiedColors.length, hasTextures); ObjectMeshModifier modifier = object.modifyMesh().addColors(colors); if (hasTextures) modifier.addTextures(clan.getMotifTextures()); object.refresh(); } public static NPCBodyMeshModifier clanifyNPC(Clan clan, NPC npc) { if (npc.getDefinitions().modifiedColors == null) return null; boolean hasTextures = npc.getDefinitions().modifiedTextures != null; int[] colors = generateColorGradient(clan, npc.getDefinitions().modifiedColors.length, hasTextures); NPCBodyMeshModifier modifier = npc.modifyMesh().addColors(colors); if (hasTextures) modifier.addTextures(clan.getMotifTextures()); return modifier; } }" "package com.rs.game.content.clans; @PluginEventHandler public class ClanVexillum extends OwnedNPC { private static final Map CLAN_VEXES = new ConcurrentHashMap<>(); private final Clan clan; private int hint = -1; /* * anim skeleton 3606 = clan teleports */ private ClanVexillum(Player owner, Tile tile, Clan clan) { super(owner, 13634, tile, false); this.clan = clan; setAutoDespawnAtDistance(false); setIgnoreNPCClipping(true); setHidden(true); CLAN_VEXES.put(clan.getName(), this); } public static NPCClickHandler interact = new NPCClickHandler(new Object[] { 13634 }, e -> { if (!(e.getNPC() instanceof ClanVexillum vex)) { e.getNPC().finish(); return; } e.getNPC().resetDirection(); if (e.getOption().equals(""Remove"")) { if (vex.getOwner() != e.getPlayer()) { e.getPlayer().sendMessage(""This isn't your vexillum to remove.""); return; } e.getPlayer().anim(8177); vex.finish(); } else { ClansManager.openClanDetails(e.getPlayer(), vex.getOwner(), vex.clan); } }); public static ItemClickHandler vexOps = new ItemClickHandler(new Object[] { 20709 }, new String[] { ""Teleport"", ""Place"", ""Recall"", ""Find"" }, e -> { if (e.getOption().equals(""Teleport"")) Magic.sendTeleportSpell(e.getPlayer(), 7389, 7312, 537, 538, 0, 0, Tile.of(2960, 3285, 0), 4, true, TeleType.ITEM, null); else if (e.getOption().equals(""Place"")) create(e.getPlayer(), true); else if (e.getOption().equals(""Recall"")) { if (e.getPlayer().getClan() == null) { e.getPlayer().sendMessage(""Could not find a vexillum to recall.""); return; } ClanVexillum vex = CLAN_VEXES.get(e.getPlayer().getClan().getName()); if (vex == null) { e.getPlayer().sendMessage(""Could not find a vexillum to recall.""); return; } if (vex.getOwner() != e.getPlayer()) { e.getPlayer().sendMessage(""This isn't your vexillum to remove.""); return; } vex.finish(); } else if (e.getOption().equals(""Find"")) { if (e.getPlayer().getClan() == null) { e.getPlayer().sendMessage(""Could not find your vexillum.""); return; } ClanVexillum vex = CLAN_VEXES.get(e.getPlayer().getClan().getName()); if (vex == null) { e.getPlayer().sendMessage(""Could not find your vexillum.""); return; } vex.hint = e.getPlayer().getHintIconsManager().addHintIcon(vex, 0, -1, false); } }); public static ObjectClickHandler plantStand = new ObjectClickHandler(new Object[] { ""Vexillum stand"" }, e -> create(e.getPlayer(), false)); public static void create(Player player, boolean checkClip) { Clan clan = player.getClan(); if (clan == null) { player.sendMessage(""You must be in a clan to place a vexillum.""); return; } if (CLAN_VEXES.get(clan.getName()) != null) { player.sendMessage(CLAN_VEXES.get(clan.getName()).getOwner().getDisplayName() + "" has already placed a vexillum for your clan.""); return; } if (player.getControllerManager().getController() != null) { player.sendMessage(""You can't place a vexillum here.""); return; } final Tile tile = player.transform(player.getDirection().dx, player.getDirection().dy); if (checkClip && !World.canLightFire(tile.getPlane(), tile.getX(), tile.getY())) { player.sendMessage(""You can't place a vexillum here.""); return; } for (NPC npc : World.getNPCsInChunkRange(player.getChunkId(), 1)) { if (npc == null || npc.hasFinished()) continue; if (npc.withinDistance(tile, npc instanceof ClanVexillum ? 6 : 1)) { player.sendMessage(""You can't place a vexillum this close to ""+(npc instanceof ClanVexillum ? ""another vexillum"" : ""another NPC"") + "".""); return; } } player.anim(8178); player.lock(); ClanVexillum vex = new ClanVexillum(player, tile, clan); WorldTasks.delay(0, () -> { player.unlock(); vex.display(); }); } public void display() { setHidden(false); Direction faceDir = Direction.getDirectionTo(getOwner(), getTile()); if (faceDir == null) faceDir = getOwner().getDirection(); if (faceDir != null) setFaceAngle(faceDir.getAngle()); else setFaceAngle(getOwner().getFaceAngle()); anim(3495); ClansManager.clanifyNPC(clan, this).setModel(0, getOwner().hasRights(Rights.DEVELOPER) ? 64928 : -1); } @Override public void finish() { super.finish(); CLAN_VEXES.remove(clan.getName()); if (hint != -1 && getOwner() != null) getOwner().getHintIconsManager().removeHintIcon(hint); } }" "package com.rs.game.content.clans.clan_camp.npcs; @PluginEventHandler public class Avalani extends Conversation { private static final int npcId = 13827; public static NPCClickHandler Avalani = new NPCClickHandler(new Object[] { npcId }, e -> { if (e.getOption().equalsIgnoreCase(""chat"")) { e.getPlayer().startConversation(new Avalani(e.getPlayer(), e.getNPC())); } }); public Avalani(Player player, NPC npc) { super(player); player.startConversation(new Dialogue() .addPlayer(HeadE.SCARED,""What are you doing with those chickens!"") .addNPC(npcId, HeadE.CALM_TALK, ""It's a ritual dedicated to Armadyl, to bring the portal to bear on the floating islands I have been locating."") .addNPC(npcId, HeadE.EVIL_LAUGH, "" The skies will soon be ours at last! And I'll show those fools at the institute!"") ); } }" "package com.rs.game.content.clans.clan_camp.npcs; @PluginEventHandler public class AvalaniChickens extends NPC { public AvalaniChickens(int id, Tile tile) { super(id, tile); } @Override public void processNPC() { super.processNPC(); if (Utils.random(100) == 0) { setNextAnimation(new Animation(3831)); setNextForceTalk(new ForceTalk(""Fly, my pretty, fly!"")); } } public static NPCInstanceHandler toFunc = new NPCInstanceHandler(new Object[] { 13827 }, AvalaniChickens::new); }" "package com.rs.game.content.clans.clan_camp.npcs; @PluginEventHandler public class CaptainOfTheGuard extends Conversation { private static final int npcId = 13633; private boolean hasClan; private final String title = player.getAppearance().isMale() ? ""sir"" : ""ma'am""; public static NPCClickHandler CaptainOfTheGuard = new NPCClickHandler(new Object[] { npcId }, e -> { String t = e.getPlayer().getAppearance().isMale() ? ""sir"" : ""ma'am""; if (e.getOption().equalsIgnoreCase(""talk-to"")) { e.getPlayer().startConversation(new CaptainOfTheGuard(e.getPlayer())); } if (e.getOption().equalsIgnoreCase(""get-cloak"")) { if(e.getPlayer().getClan() == null){ e.getPlayer().startConversation(new Dialogue() .addNPC(npcId, HeadE.HAPPY_TALKING, ""You must be in a clan to have a clan cloak, "" + t + ""."") ); return; } if (!e.getPlayer().getInventory().hasFreeSlots()){ e.getPlayer().startConversation(new Dialogue() .addNPC(npcId, HeadE.HAPPY_TALKING, ""Unfortunately you do not have enough space for that, "" + t + ""."") ); return; } if(e.getPlayer().getInventory().hasFreeSlots() && e.getPlayer().getInventory().containsItem(20708)) { e.getPlayer().startConversation(new Dialogue() .addNPC(npcId, HeadE.HAPPY_TALKING, ""You can only have one clan cloak, "" + t + "". Those are the rules"") ); } else { e.getPlayer().startConversation(new Dialogue() .addNPC(npcId, HeadE.HAPPY_TALKING, ""Certainly. Here you are.."") ); e.getPlayer().getInventory().addItem(20708); e.getPlayer().sendMessage(""The captain gives you a cloak.""); } } }); public CaptainOfTheGuard(Player player) { super(player); if(player.getClan() != null) hasClan = true; if(!hasClan) player.startConversation(new Dialogue() .addNPC(npcId, HeadE.HAPPY_TALKING, ""Alf A Numerius at your service, "" + title +"". It's my job to give out clan cloaks. If you'd like to know more about clans, talk to the clan scribe."") ); else player.startConversation(new Dialogue() .addNPC(npcId, HeadE.HAPPY_TALKING, ""Need something, "" + title + ""?"") .addOptions(ops -> { ops.add(""I'd like a clan cloak."") .addNext(() -> { if (!player.getInventory().hasFreeSlots()){ player.startConversation(new Dialogue() .addNPC(npcId, HeadE.HAPPY_TALKING, ""Unfortunately you do not have enough space for that, "" + title) ); return; } if(player.getInventory().hasFreeSlots() && player.getInventory().containsItem(20708)) player.startConversation(new Dialogue() .addNPC(npcId, HeadE.HAPPY_TALKING, ""You can only have one clan cloak, "" + title + "". Those are the rules"") ); else { player.startConversation(new Dialogue() .addNPC(npcId, HeadE.HAPPY_TALKING, ""Certainly. Here you are "" + title + ""."") ); player.getInventory().addItem(20708); player.sendMessage(""The captain gives you a cloak.""); } }); ops.add(""Goodbye"") .addNPC(npcId, HeadE.HAPPY_TALKING, ""Goodbye, "" + title + "".""); }) ); } }" "package com.rs.game.content.clans.clan_camp.npcs; @PluginEventHandler public class Scribe extends Conversation { private static final int npcId = 5915; private boolean hasClan; private final int Vexilum = 20709; private final String title = player.getAppearance().isMale() ? ""sir"" : ""ma'am""; public static NPCClickHandler Scribe = new NPCClickHandler(new Object[] { npcId }, e -> { String t = e.getPlayer().getAppearance().isMale() ? ""sir"" : ""ma'am""; if (e.getOption().equalsIgnoreCase(""talk-to"")) { e.getPlayer().startConversation(new Scribe(e.getPlayer())); } if (e.getOption().equalsIgnoreCase(""get-vexillum"")) { if(e.getPlayer().getClan() == null){ e.getPlayer().startConversation(new Dialogue() .addNPC(npcId, HeadE.HAPPY_TALKING, ""You must be in a clan to have a vexillum, "" + t + ""."") ); return; } if (!e.getPlayer().getInventory().hasFreeSlots()){ e.getPlayer().startConversation(new Dialogue() .addNPC(npcId, HeadE.HAPPY_TALKING, ""Unfortunately you do not have enough space for that, "" + t + ""."") ); return; } if(e.getPlayer().getInventory().hasFreeSlots() && e.getPlayer().getInventory().containsItem(20709)) { e.getPlayer().startConversation(new Dialogue() .addNPC(npcId, HeadE.HAPPY_TALKING, ""You can only have one clan vexillum, "" + t + "". Those are the rules"") ); } else { e.getPlayer().startConversation(new Dialogue() .addNPC(npcId, HeadE.HAPPY_TALKING, ""Certainly, "" + t + "". Here you are.."") ); e.getPlayer().getInventory().addItem(20709); e.getPlayer().sendMessage(""The scribe gives you a vexillum.""); } } }); public Scribe(Player player) { super(player); if(player.getClan() != null) hasClan = true; if(!hasClan) player.startConversation(new Dialogue() .addNPC(npcId, HeadE.HAPPY_TALKING, ""Clan scribe Amos Twinly at your service, "" + title +"". I keep a record of all clans, and distribute clan charters to those who wish to start a clan. "") .addNPC(npcId, HeadE.HAPPY_TALKING, ""If you are a member of a clan, I can also provide you with a vexillum - a banner displaying your clan's motif."") .addOptions(clanOps -> { clanOps.add(""I'd like to charter a new clan"") .addNPC(npcId, HeadE.HAPPY_TALKING, ""Splendid news "" + title + "". What would you like your clan to be called?"") .addNext(() -> promptName(player)); clanOps.add(""Goodbye"") .addNPC(npcId, HeadE.HAPPY_TALKING, ""Goodbye""); })); else player.startConversation(new Dialogue() .addNPC(npcId, HeadE.HAPPY_TALKING, ""Need something, "" + title + ""?"") .addOptions(ops -> { ops.add(""I'd like a clan cloak."") .addNext(() -> { if (!player.getInventory().hasFreeSlots()){ player.startConversation(new Dialogue() .addNPC(npcId, HeadE.HAPPY_TALKING, ""Unfortunately you do not have enough space for that, "" + title) ); return; } if(player.getInventory().hasFreeSlots() && player.getInventory().containsItem(20708)) player.startConversation(new Dialogue() .addNPC(npcId, HeadE.HAPPY_TALKING, ""You can only have one clan cloak, "" + title + "". Those are the rules"") ); else { player.startConversation(new Dialogue() .addNPC(npcId, HeadE.HAPPY_TALKING, ""Certainly. Here you are "" + title + ""."") ); player.getInventory().addItem(20708); player.sendMessage(""The scribe gives you a clan cloak.""); } }); ops.add(""Goodbye"") .addNPC(npcId, HeadE.HAPPY_TALKING, ""Goodbye, "" + title + "".""); }) ); } }" "package com.rs.game.content.clans.clan_camp.npcs; @PluginEventHandler public class SergeantAtArms extends Conversation { private static final int npcId = 5914; private boolean hasClan; public static NPCClickHandler SergeantAtArms = new NPCClickHandler(new Object[] { npcId }, e -> { if (e.getOption().equalsIgnoreCase(""talk-to"")) { e.getPlayer().startConversation(new SergeantAtArms(e.getPlayer())); } if (e.getOption().equalsIgnoreCase(""badge"")) { if(e.getPlayer().getClan() != null) e.getPlayer().startConversation(new Dialogue() .addPlayer(HeadE.HAPPY_TALKING,""I need a Rated Clan Wars badge."") .addNext(() -> { if (e.getPlayer().getClan() != null) { e.getPlayer().startConversation(new Dialogue() .addNPC(npcId, HeadE.SHAKING_HEAD, ""You need to be in a clan to get a badge. I can't just give them out to just anyone. Talk to the clan scribe over there. He can help you set up a clan."")); return; } if (e.getPlayer().getClan() != null && e.getPlayer().getInventory().containsItem(20710)) { e.getPlayer().startConversation(new Dialogue() .addNPC(npcId, HeadE.SHAKING_HEAD, ""You've already got a badge. Don't waste my time."")); return; } if (e.getPlayer().getClan() != null && !e.getPlayer().getInventory().containsItem(20710)) { if (e.getPlayer().getInventory().hasFreeSlots()) { e.getPlayer().startConversation(new Dialogue() .addNPC(npcId, HeadE.HAPPY_TALKING, ""Sure, here you go."")); e.getPlayer().getInventory().addItem(20710, 1); e.getPlayer().sendMessage(""The sergeant hands you an RCW badge.""); } else e.getPlayer().startConversation(new Dialogue() .addNPC(npcId, HeadE.SHAKING_HEAD, ""You are carrying enough already."")); } }) ); } }); public SergeantAtArms(Player player) { super(player); if(player.getClan() != null) hasClan = true; player.startConversation(new Dialogue() .addNPC(npcId, HeadE.HAPPY_TALKING, ""Want something?"") .addOptions(ops -> { ops.add(""Who are you?"") .addNPC(npcId, HeadE.CALM, ""I'm the Sergeant-at-Arms. I organise Rated Clan Wars matches."") .addPlayer(HeadE.CALM_TALK, ""You look like you've seen combat."") .addNPC(npcId, HeadE.UPSET_SNIFFLE, ""I was here at the Siege of Falador. A lot of people died. I didn't.""); ops.add(""I'd like to know more about Rated Clan Wars."") .addNPC(npcId, HeadE.HAPPY_TALKING, ""Rated Clan Wars is a pitched battle between two clans. You need to be in a clan to take part, and you need a Rated Clan Wars badge."") .addNext(() -> { if (player.getInventory().containsItem(20712)) { } else { player.startConversation(new Dialogue() .addNPC(npcId, HeadE.CALM_TALK, ""There's a rulebook if you want to know more."") .addOptions(ops1 -> { ops1.add(""Sure, I'd like a copy"") .addNext(() -> { if (player.getInventory().hasFreeSlots()) { player.getInventory().addItem(20712, 1); player.startConversation(new Dialogue() .addNPC(npcId, HeadE.HAPPY_TALKING, ""Sure, here you go."")); } else addNPC(npcId, HeadE.SHAKING_HEAD, ""You are carrying enough already.""); }); ops1.add(""No Thanks""); })); } }); ops.add(""I need a Rated Clan Wars badge."") .addNext(() -> { if (!hasClan) { player.startConversation(new Dialogue() .addNPC(npcId, HeadE.SHAKING_HEAD, ""You need to be in a clan to get a badge. I can't just give them out to just anyone. Talk to the clan scribe over there. He can help you set up a clan."")); return; } if (hasClan && player.getInventory().containsItem(20710)) { player.startConversation(new Dialogue() .addNPC(npcId, HeadE.SHAKING_HEAD, ""You've already got a badge. Don't waste my time."")); return; } if (hasClan && !player.getInventory().containsItem(20710)) { if (player.getInventory().hasFreeSlots()) { player.getInventory().addItem(20710, 1); player.sendMessage(""The sergeant hands you an RCW badge.""); player.startConversation(new Dialogue() .addNPC(npcId, HeadE.HAPPY_TALKING, ""Sure, here you go."")); } else{ player.startConversation(new Dialogue() .addNPC(npcId, HeadE.SHAKING_HEAD, ""You are carrying enough already."")); } } }); ops.add(""No thanks."") .addPlayer(HeadE.CONFUSED, ""No thanks.""); })); } }" "package com.rs.game.content.combat enum class AmmoType( private val itemIds: IntArray, private val projAnim: Int, private val drawbackSpotAnim: Int = -1, private val doubleDrawbackSpotAnim: Int = -1 ) { ICE_ARROWS(intArrayOf(78), 16, 25, 1110), BRONZE_ARROW(intArrayOf(882, 883, 5616, 5622, 22336, 598, 942), 10, 19, 1104), IRON_ARROW(intArrayOf(884, 885, 5617, 5623, 2532, 2533), 9, 18, 1105), STEEL_ARROW(intArrayOf(886, 887, 5618, 5624, 2534, 2535), 11, 20, 1106), MITHRIL_ARROW(intArrayOf(888, 889, 5619, 5625, 2536, 2537), 12, 21, 1107), ADAMANT_ARROW(intArrayOf(890, 891, 5620, 5626, 2538, 2539), 13, 22, 1108), RUNE_ARROW(intArrayOf(892, 893, 5621, 5627, 22337, 2540, 2541), 15, 24, 1109), DRAGON_ARROW(intArrayOf(11212, 11227, 11228, 11229, 11217, 11222), 1120, 1116, 1111), BROAD_ARROW(intArrayOf(4160), 326, 325, 1112), ABYSSALBANE_ARROW(intArrayOf(21655, 21733, 21734, 21735), 12, 21, 1107), DRAGONBANE_ARROW(intArrayOf(21640, 21712, 21713, 21714), 12, 21, 1107), BASILISKBANE_ARROW(intArrayOf(21650, 21719, 21720, 21721), 12, 21, 1107), WALLASALKIBANE_ARROW(intArrayOf(21645, 21726, 21727, 21728), 12, 21, 1107), SARADOMIN_ARROWS(intArrayOf(19152), 99, 96, 125), GUTHIX_ARROWS(intArrayOf(19157), 98, 95, 124), ZAMORAK_ARROWS(intArrayOf(19162), 100, 97, 126), BRONZE_BOLTS(intArrayOf(877, 878, 879, 881, 6061, 6062, 9236), 27, 955), BLURITE_BOLTS(intArrayOf(9139, 9237, 9286, 9293, 9300, 9335), 27, 955), SILVER_BOLTS(intArrayOf(9145, 9292, 9299, 9306), 27, 955), IRON_BOLTS(intArrayOf(9140, 880, 9238, 9287, 9294, 9301), 27, 955), STEEL_BOLTS(intArrayOf(9141, 9239, 9288, 9295, 9302, 9336), 27, 955), BLACK_BOLTS(intArrayOf(13083, 13084, 13085, 13086), 27, 955), MITHRIL_BOLTS(intArrayOf(9142, 9240, 9241, 9289, 9296, 9303, 9337, 9338), 27, 955), ADAMANT_BOLTS(intArrayOf(9143, 9242, 9243, 9290, 9297, 9304, 9339, 9340), 27, 955), RUNITE_BOLTS(intArrayOf(9144, 9244, 9245, 9291, 9298, 9305, 9341, 9342), 27, 955), BROAD_TIPPED_BOLTS(intArrayOf(13280), 27, 955), ABYSSALBANE_BOLT(intArrayOf(21675, 21701, 21702, 21703), 27, 955), DRAGONBANE_BOLT(intArrayOf(21660, 21680, 21681, 21682), 27, 955), BASILISKBANE_BOLT(intArrayOf(21670, 21687, 21688, 21689), 27, 955), WALLASALKIBANE_BOLT(intArrayOf(21665, 21694, 21695, 21696), 27, 955), BAKRIMINEL_BOLTS(intArrayOf(24116), 3023), OGRE_ARROW(intArrayOf(2866), 242, 243), BRONZE_BRUTAL(intArrayOf(4773), 404, 403), IRON_BRUTAL(intArrayOf(4778), 404, 403), STEEL_BRUTAL(intArrayOf(4783), 404, 403), BLACK_BRUTAL(intArrayOf(4788), 404, 403), MITHRIL_BRUTAL(intArrayOf(4793), 404, 403), ADAMANT_BRUTAL(intArrayOf(4798), 404, 403), RUNE_BRUTAL(intArrayOf(4803), 404, 403), GUAM_TAR(intArrayOf(10142), -1, 952), MARRENTILL_TAR(intArrayOf(10143), -1, 952), TARROMIN_TAR(intArrayOf(10144), -1, 952), HARRALANDER_TAR(intArrayOf(10145), -1, 952), BOLT_RACK(intArrayOf(4740), 27, 955), BONE_BOLTS(intArrayOf(8882), 696, 697), TRAINING_ARROWS(intArrayOf(9706), 805, 806), KEBBIT_BOLTS(intArrayOf(10158), 27, 955), LONG_KEBBIT_BOLTS(intArrayOf(10159), 27, 955), PERFORMANCE_ARROW(intArrayOf(13722), 1802, 1801), ARROWS_CLASS_1(intArrayOf(14202), 1877, 1872), ARROWS_CLASS_2(intArrayOf(14203), 1878, 1873), ARROWS_CLASS_3(intArrayOf(14204), 1879, 1874), ARROWS_CLASS_4(intArrayOf(14205), 1880, 1875), ARROWS_CLASS_5(intArrayOf(14206), 1881, 1876), HAND_CANNON_SHOT(intArrayOf(15243), 2143, 2137), NOVITE_ARROWS(intArrayOf(15947, 15958, 15969, 15980, 16427, 16482, 16537, 16592), 2467, 2466), BATHUS_ARROWS(intArrayOf(15948, 15959, 15970, 15981, 16432, 16487, 16542, 16597), 2469, 2468), MARMAROS_ARROWS(intArrayOf(15949, 15960, 15971, 15982, 16437, 16492, 16547, 16602), 2471, 2470), KRATONITE_ARROWS(intArrayOf(15950, 15961, 15972, 15983, 16442, 16497, 16552, 16607), 2473, 2472), FRACTITE_ARROWS(intArrayOf(15951, 15962, 15973, 15984, 16447, 16502, 16557, 16612), 2475, 2474), ZEPHYRIUM_ARROWS(intArrayOf(15952, 15963, 15974, 15985, 16452, 16507, 16562, 16617), 2477, 2476), ARGONITE_ARROWS(intArrayOf(15953, 15964, 15975, 15986, 16457, 16512, 16567, 16622), 2479, 2478), KATAGON_ARROWS(intArrayOf(15954, 15965, 15976, 15987, 16462, 16517, 16572, 16627), 2481, 2480), GORGONITE_ARROWS(intArrayOf(15955, 15966, 15977, 15988, 16467, 16522, 16577, 16632), 2483, 2482), PROMETHIUM_ARROWS(intArrayOf(15956, 15967, 15978, 15989, 16472, 16527, 16582, 16637), 2485, 2484), SAGITTARIAN_ARROWS(intArrayOf(15957, 15968, 15979, 15990, 16477, 16532, 16587, 16642), 2487, 2486), OZANS_KRATONITE_ARROWS(intArrayOf(20858), 2473, 2472), CORAL_BOLTS(intArrayOf(24304), 3172, 3171), ROYAL_BOLTS(intArrayOf(24336), 3173, 3170); fun getProjAnim(itemId: Int): Int { when (this) { NOVITE_ARROWS, BATHUS_ARROWS, MARMAROS_ARROWS, KRATONITE_ARROWS, FRACTITE_ARROWS, ZEPHYRIUM_ARROWS, ARGONITE_ARROWS, KATAGON_ARROWS, GORGONITE_ARROWS, PROMETHIUM_ARROWS, SAGITTARIAN_ARROWS -> { if (ItemDefinitions.getDefs(itemId).name.contains(""(p"")) return projAnim + 20 if (ItemDefinitions.getDefs(itemId).name.contains(""fire"")) return 17 } BRONZE_ARROW, IRON_ARROW, STEEL_ARROW, MITHRIL_ARROW, ADAMANT_ARROW, RUNE_ARROW, DRAGON_ARROW -> if (ItemDefinitions.getDefs(itemId).name.contains(""fire"")) return 17 else -> {} } return projAnim } fun getDrawbackSpotAnim(itemId: Int): Int { when (this) { NOVITE_ARROWS, BATHUS_ARROWS, MARMAROS_ARROWS, KRATONITE_ARROWS, FRACTITE_ARROWS, ZEPHYRIUM_ARROWS, ARGONITE_ARROWS, KATAGON_ARROWS, GORGONITE_ARROWS, PROMETHIUM_ARROWS, SAGITTARIAN_ARROWS -> { if (ItemDefinitions.getDefs(itemId).name.contains(""(p"")) return drawbackSpotAnim + 20 if (ItemDefinitions.getDefs(itemId).name.contains(""fire"")) return 26 } BRONZE_ARROW, IRON_ARROW, STEEL_ARROW, MITHRIL_ARROW, ADAMANT_ARROW, RUNE_ARROW, DRAGON_ARROW -> if (ItemDefinitions.getDefs(itemId).name.contains(""fire"")) return 26 else -> {} } return drawbackSpotAnim } fun getDoubleDrawbackSpotAnim(itemId: Int): Int { when (this) { BRONZE_ARROW, IRON_ARROW, STEEL_ARROW, MITHRIL_ARROW, ADAMANT_ARROW, RUNE_ARROW, DRAGON_ARROW -> if (ItemDefinitions.getDefs(itemId).name.contains(""fire"")) return 1113 else -> {} } return doubleDrawbackSpotAnim } companion object { private val MAP: Map = entries.flatMap { entry -> entry.itemIds.map { itemId -> itemId to entry } }.toMap() @JvmStatic fun forId(itemId: Int): AmmoType? = MAP[itemId] } }" "package com.rs.game.content.combat @ServerStartupEvent fun mapNpcAttackOptions() { onNpcClick(options = arrayOf(""Attack""), checkDistance = false) { e -> e.player.stopAll(true) e.player.interactionManager.setInteraction(PlayerCombatInteraction(e.player, e.npc)) } onNpcClick(2440, 2443, 2446, options = arrayOf(""Destroy""), checkDistance = false) { e -> if (e.npc is DoorSupport) { if (!(e.npc as DoorSupport).canDestroy(e.player)) { e.player.sendMessage(""You cannot see a way to open this door..."") return@onNpcClick } } e.player.stopAll(true) e.player.interactionManager.setInteraction(PlayerCombatInteraction(e.player, e.npc)) } onNpcClick(7891, options = arrayOf(""Attack"")) { e -> e.player.interactionManager.setInteraction(StandardEntityInteraction(e.npc, 0) { if (!e.player.controllerManager.canAttack(e.npc)) return@StandardEntityInteraction e.npc.resetWalkSteps() e.player.faceEntity(e.npc) if (e.player.skills.getLevelForXp(Constants.ATTACK) < 5) { if (e.player.actionManager.actionDelay < 1) { e.player.actionManager.actionDelay = 4 e.player.anim(getWeaponAttackEmote(e.player.equipment.weaponId, e.player.combatDefinitions.getAttackStyle())) e.player.skills.addXp(Constants.ATTACK, 15.0) } } else e.player.sendMessage(""You have nothing more you can learn from this."") }) } }" "package com.rs.game.content.combat class AttackStyle(@JvmField val index: Int, @JvmField val name: String, @JvmField val xpType: XPType, @JvmField val attackType: AttackType) { companion object { private val UNARMED: Map = mapOf( 0 to AttackStyle(0, ""Punch"", XPType.ACCURATE, AttackType.CRUSH), 1 to AttackStyle(1, ""Kick"", XPType.AGGRESSIVE, AttackType.CRUSH), 2 to AttackStyle(2, ""Block"", XPType.DEFENSIVE, AttackType.CRUSH) ) private val ATTACK_STYLES: Map?> = mapOf( 1 to mapOf( 0 to AttackStyle(0, ""Bash"", XPType.ACCURATE, AttackType.CRUSH), 1 to AttackStyle(1, ""Pound"", XPType.AGGRESSIVE, AttackType.CRUSH), 2 to AttackStyle(2, ""Focus"", XPType.DEFENSIVE, AttackType.CRUSH) ), 2 to mapOf( 0 to AttackStyle(0, ""Chop"", XPType.ACCURATE, AttackType.SLASH), 1 to AttackStyle(1, ""Hack"", XPType.AGGRESSIVE, AttackType.SLASH), 2 to AttackStyle(2, ""Smash"", XPType.AGGRESSIVE, AttackType.CRUSH), 3 to AttackStyle(3, ""Block"", XPType.DEFENSIVE, AttackType.SLASH) ), 3 to mapOf( 0 to AttackStyle(0, ""Bash"", XPType.ACCURATE, AttackType.CRUSH), 1 to AttackStyle(1, ""Pound"", XPType.AGGRESSIVE, AttackType.CRUSH), 2 to AttackStyle(2, ""Block"", XPType.DEFENSIVE, AttackType.CRUSH) ), 4 to mapOf( 0 to AttackStyle(0, ""Spike"", XPType.ACCURATE, AttackType.STAB), 1 to AttackStyle(1, ""Impale"", XPType.AGGRESSIVE, AttackType.STAB), 2 to AttackStyle(2, ""Smash"", XPType.AGGRESSIVE, AttackType.CRUSH), 3 to AttackStyle(3, ""Block"", XPType.DEFENSIVE, AttackType.STAB) ), 5 to mapOf( 0 to AttackStyle(0, ""Stab"", XPType.ACCURATE, AttackType.STAB), 1 to AttackStyle(1, ""Lunge"", XPType.AGGRESSIVE, AttackType.STAB), 2 to AttackStyle(2, ""Slash"", XPType.AGGRESSIVE, AttackType.SLASH), 3 to AttackStyle(3, ""Block"", XPType.DEFENSIVE, AttackType.STAB) ), 6 to mapOf( 0 to AttackStyle(0, ""Chop"", XPType.ACCURATE, AttackType.SLASH), 1 to AttackStyle(1, ""Slash"", XPType.AGGRESSIVE, AttackType.SLASH), 2 to AttackStyle(2, ""Lunge"", XPType.CONTROLLED, AttackType.STAB), 3 to AttackStyle(3, ""Block"", XPType.DEFENSIVE, AttackType.SLASH) ), 7 to mapOf( 0 to AttackStyle(0, ""Chop"", XPType.ACCURATE, AttackType.SLASH), 1 to AttackStyle(1, ""Slash"", XPType.AGGRESSIVE, AttackType.SLASH), 2 to AttackStyle(2, ""Smash"", XPType.AGGRESSIVE, AttackType.CRUSH), 3 to AttackStyle(3, ""Block"", XPType.DEFENSIVE, AttackType.SLASH) ), 8 to mapOf( 0 to AttackStyle(0, ""Pound"", XPType.ACCURATE, AttackType.CRUSH), 1 to AttackStyle(1, ""Pummel"", XPType.AGGRESSIVE, AttackType.CRUSH), 2 to AttackStyle(2, ""Spike"", XPType.CONTROLLED, AttackType.STAB), 3 to AttackStyle(3, ""Block"", XPType.DEFENSIVE, AttackType.CRUSH) ), 9 to mapOf( 0 to AttackStyle(0, ""Chop"", XPType.ACCURATE, AttackType.SLASH), 1 to AttackStyle(1, ""Slash"", XPType.AGGRESSIVE, AttackType.SLASH), 2 to AttackStyle(2, ""Lunge"", XPType.CONTROLLED, AttackType.STAB), 3 to AttackStyle(3, ""Block"", XPType.DEFENSIVE, AttackType.SLASH) ), 10 to mapOf( 0 to AttackStyle(0, ""Pound"", XPType.ACCURATE, AttackType.CRUSH), 1 to AttackStyle(1, ""Pummel"", XPType.AGGRESSIVE, AttackType.CRUSH), 2 to AttackStyle(2, ""Block"", XPType.DEFENSIVE, AttackType.CRUSH) ), 11 to mapOf( 0 to AttackStyle(0, ""Flick"", XPType.ACCURATE, AttackType.SLASH), 1 to AttackStyle(1, ""Lash"", XPType.CONTROLLED, AttackType.SLASH), 2 to AttackStyle(2, ""Deflect"", XPType.DEFENSIVE, AttackType.SLASH) ), 12 to mapOf( 0 to AttackStyle(0, ""Pound"", XPType.ACCURATE, AttackType.CRUSH), 1 to AttackStyle(1, ""Pummel"", XPType.AGGRESSIVE, AttackType.CRUSH), 2 to AttackStyle(2, ""Block"", XPType.DEFENSIVE, AttackType.CRUSH) ), 13 to mapOf( 0 to AttackStyle(0, ""Accurate"", XPType.RANGED, AttackType.ACCURATE), 1 to AttackStyle(1, ""Rapid"", XPType.RANGED, AttackType.RAPID), 2 to AttackStyle(2, ""Long range"", XPType.RANGED_DEFENSIVE, AttackType.LONG_RANGE) ), 14 to mapOf( 0 to AttackStyle(0, ""Lunge"", XPType.CONTROLLED, AttackType.STAB), 1 to AttackStyle(1, ""Swipe"", XPType.CONTROLLED, AttackType.SLASH), 2 to AttackStyle(2, ""Pound"", XPType.CONTROLLED, AttackType.CRUSH), 3 to AttackStyle(3, ""Block"", XPType.DEFENSIVE, AttackType.STAB) ), 15 to mapOf( 0 to AttackStyle(0, ""Jab"", XPType.CONTROLLED, AttackType.STAB), 1 to AttackStyle(1, ""Swipe"", XPType.AGGRESSIVE, AttackType.SLASH), 2 to AttackStyle(2, ""Fend"", XPType.DEFENSIVE, AttackType.STAB) ), 16 to mapOf( 0 to AttackStyle(0, ""Accurate"", XPType.RANGED, AttackType.ACCURATE), 1 to AttackStyle(1, ""Rapid"", XPType.RANGED, AttackType.RAPID), 2 to AttackStyle(2, ""Long range"", XPType.RANGED_DEFENSIVE, AttackType.LONG_RANGE) ), 17 to mapOf( 0 to AttackStyle(0, ""Accurate"", XPType.RANGED, AttackType.ACCURATE), 1 to AttackStyle(1, ""Rapid"", XPType.RANGED, AttackType.RAPID), 2 to AttackStyle(2, ""Long range"", XPType.RANGED_DEFENSIVE, AttackType.LONG_RANGE) ), 18 to mapOf( 0 to AttackStyle(0, ""Accurate"", XPType.RANGED, AttackType.ACCURATE), 1 to AttackStyle(1, ""Rapid"", XPType.RANGED, AttackType.RAPID), 2 to AttackStyle(2, ""Long range"", XPType.RANGED_DEFENSIVE, AttackType.LONG_RANGE) ), 19 to mapOf( 0 to AttackStyle(0, ""Short fuse"", XPType.RANGED, AttackType.ACCURATE), 1 to AttackStyle(1, ""Medium fuse"", XPType.RANGED, AttackType.RAPID), 2 to AttackStyle(2, ""Long fuse"", XPType.RANGED, AttackType.LONG_RANGE) ), 20 to mapOf( 0 to AttackStyle(0, ""Aim and fire"", XPType.RANGED, AttackType.ACCURATE), 2 to AttackStyle(2, ""Kick"", XPType.AGGRESSIVE, AttackType.CRUSH) ), 21 to mapOf( 0 to AttackStyle(0, ""Scorch"", XPType.AGGRESSIVE, AttackType.SLASH), 1 to AttackStyle(1, ""Flare"", XPType.RANGED, AttackType.ACCURATE), 2 to AttackStyle(2, ""Blaze"", XPType.MAGIC, AttackType.MAGIC) ), 22 to mapOf( 0 to AttackStyle(0, ""Reap"", XPType.ACCURATE, AttackType.SLASH), 1 to AttackStyle(1, ""Chop"", XPType.AGGRESSIVE, AttackType.STAB), 2 to AttackStyle(2, ""Jab"", XPType.AGGRESSIVE, AttackType.CRUSH), 3 to AttackStyle(3, ""Block"", XPType.DEFENSIVE, AttackType.STAB) ), 23 to mapOf( 0 to AttackStyle(0, ""Slash"", XPType.ACCURATE, AttackType.SLASH), 1 to AttackStyle(1, ""Crush"", XPType.AGGRESSIVE, AttackType.CRUSH), 2 to AttackStyle(2, ""Slash"", XPType.DEFENSIVE, AttackType.SLASH) ), 24 to mapOf( 0 to AttackStyle(0, ""Sling"", XPType.RANGED, AttackType.ACCURATE), 1 to AttackStyle(1, ""Chuck"", XPType.RANGED, AttackType.RAPID), 2 to AttackStyle(2, ""Lob"", XPType.RANGED_DEFENSIVE, AttackType.LONG_RANGE) ), 25 to mapOf( 0 to AttackStyle(0, ""Jab"", XPType.ACCURATE, AttackType.STAB), 1 to AttackStyle(1, ""Swipe"", XPType.AGGRESSIVE, AttackType.SLASH), 2 to AttackStyle(2, ""Fend"", XPType.DEFENSIVE, AttackType.CRUSH) ), 26 to mapOf( 0 to AttackStyle(0, ""Jab"", XPType.ACCURATE, AttackType.STAB), 1 to AttackStyle(1, ""Swipe"", XPType.AGGRESSIVE, AttackType.SLASH), 2 to AttackStyle(2, ""Fend"", XPType.DEFENSIVE, AttackType.CRUSH) ), 27 to mapOf( 0 to AttackStyle(0, ""Hack!"", XPType.CONTROLLED, AttackType.SLASH), 1 to AttackStyle(1, ""Gouge!"", XPType.CONTROLLED, AttackType.STAB), 2 to AttackStyle(2, ""Smash!"", XPType.CONTROLLED, AttackType.CRUSH) ), 28 to mapOf( 0 to AttackStyle(0, ""Accurate"", XPType.MAGIC, AttackType.POLYPORE_ACCURATE), 2 to AttackStyle(2, ""Long range"", XPType.MAGIC, AttackType.POLYPORE_LONGRANGE) ), ) fun getStyles(itemId: Int): Map { val defs = ItemDefinitions.getDefs(itemId) val weaponType = defs.getParamVal(686) return if (ATTACK_STYLES[weaponType] == null) UNARMED else ATTACK_STYLES[weaponType]!! } } }" "package com.rs.game.content.combat enum class AttackType(private val attBonus: Bonus, private val defBonus: Bonus) { STAB(Bonus.STAB_ATT, Bonus.STAB_DEF), SLASH(Bonus.SLASH_ATT, Bonus.SLASH_DEF), CRUSH(Bonus.CRUSH_ATT, Bonus.CRUSH_DEF), ACCURATE(Bonus.RANGE_ATT, Bonus.RANGE_DEF), RAPID(Bonus.RANGE_ATT, Bonus.RANGE_DEF), LONG_RANGE(Bonus.RANGE_ATT, Bonus.RANGE_DEF), POLYPORE_ACCURATE(Bonus.MAGIC_ATT, Bonus.MAGIC_DEF), POLYPORE_LONGRANGE(Bonus.MAGIC_ATT, Bonus.MAGIC_DEF), MAGIC(Bonus.MAGIC_ATT, Bonus.MAGIC_DEF); fun getAttackBonus(player: Player): Int { return player.combatDefinitions.getBonus(attBonus) } fun getDefenseBonus(entity: Entity): Int { if (entity is Player) return entity.combatDefinitions.getBonus(defBonus) return (entity as NPC).getBonus(defBonus) } }" "package com.rs.game.content.combat class CombatDefinitions { enum class Spellbook(@JvmField val interfaceId: Int) { MODERN(192), ANCIENT(193), LUNAR(430), DUNGEONEERING(950) } @Transient private var player: Player? = null @Transient var isUsingSpecialAttack: Boolean = false private set @Transient private lateinit var bonuses: IntArray @Transient var isDungSpellbook: Boolean = false private set private var attackStyle: Byte = 0 private var specialAttackPercentage: Byte = 100 var isAutoRetaliate: Boolean = true private var sortSpellBook: Byte = 0 private var showCombatSpells = true private var showSkillSpells = true private var showMiscSpells = true private var showTeleportSpells = true var isDefensiveCasting: Boolean = false private set private var spellbook: Spellbook? = Spellbook.MODERN var autoCast: CombatSpell? = null private set val spell: CombatSpell? get() { val spell = player!!.tempAttribs.getO(""manualCastSpell"") if (spell != null) return spell return autoCast } fun hasManualCastQueued(): Boolean { return player!!.tempAttribs.getO(""manualCastSpell"") != null } fun setManualCastSpell(spell: CombatSpell?) { player!!.tempAttribs.setO(""manualCastSpell"", spell) } fun clearManualCastSpell() { player!!.tempAttribs.removeO(""manualCastSpell"") } fun resetSpells(removeAutoSpell: Boolean) { clearManualCastSpell() if (removeAutoSpell) { setAutoCastSpell(null) refreshAutoCastSpell() } } fun setAutoCastSpell(spell: CombatSpell?) { autoCast = spell refreshAutoCastSpell() } fun refreshAutoCastSpell() { refreshAttackStyle() player!!.vars.setVar(108, spellAutoCastConfigValue) } private val spellAutoCastConfigValue: Int get() { if (autoCast == null) return 0 when { isDungSpellbook -> return when (autoCast) { CombatSpell.WIND_STRIKE -> 103 CombatSpell.WATER_STRIKE -> 105 CombatSpell.EARTH_STRIKE -> 107 CombatSpell.FIRE_STRIKE -> 109 CombatSpell.WIND_BOLT -> 111 CombatSpell.WATER_BOLT -> 113 CombatSpell.EARTH_BOLT -> 115 CombatSpell.FIRE_BOLT -> 117 CombatSpell.WIND_BLAST -> 119 CombatSpell.WATER_BLAST -> 121 CombatSpell.EARTH_BLAST -> 123 CombatSpell.FIRE_BLAST -> 125 CombatSpell.WIND_WAVE -> 127 CombatSpell.WATER_WAVE -> 129 CombatSpell.EARTH_WAVE -> 131 CombatSpell.FIRE_WAVE -> 133 CombatSpell.WIND_SURGE -> 135 CombatSpell.WATER_SURGE -> 137 CombatSpell.EARTH_SURGE -> 139 CombatSpell.FIRE_SURGE -> 141 else -> 0 } spellbook == Spellbook.MODERN -> return when (autoCast) { CombatSpell.WIND_STRIKE -> 3 CombatSpell.WATER_STRIKE -> 5 CombatSpell.EARTH_STRIKE -> 7 CombatSpell.FIRE_STRIKE -> 9 CombatSpell.WIND_BOLT -> 11 CombatSpell.WATER_BOLT -> 13 CombatSpell.EARTH_BOLT -> 15 CombatSpell.FIRE_BOLT -> 17 CombatSpell.CRUMBLE_UNDEAD -> 35 CombatSpell.WIND_BLAST -> 19 CombatSpell.WATER_BLAST -> 21 CombatSpell.EARTH_BLAST -> 23 CombatSpell.FIRE_BLAST -> 25 CombatSpell.IBAN_BLAST -> 45 CombatSpell.MAGIC_DART -> 37 CombatSpell.SARADOMIN_STRIKE -> 41 CombatSpell.CLAWS_OF_GUTHIX -> 39 CombatSpell.FLAMES_OF_ZAMORAK -> 43 CombatSpell.WIND_WAVE -> 27 CombatSpell.WATER_WAVE -> 29 CombatSpell.EARTH_WAVE -> 31 CombatSpell.FIRE_WAVE -> 33 CombatSpell.WIND_SURGE -> 47 CombatSpell.WATER_SURGE -> 49 CombatSpell.EARTH_SURGE -> 51 CombatSpell.FIRE_SURGE -> 53 CombatSpell.WIND_RUSH -> 143 CombatSpell.STORM_OF_ARMADYL -> 145 else -> 0 } spellbook == Spellbook.ANCIENT -> return when (autoCast) { CombatSpell.SMOKE_RUSH -> 63 CombatSpell.SHADOW_RUSH -> 65 CombatSpell.BLOOD_RUSH -> 67 CombatSpell.ICE_RUSH -> 69 CombatSpell.SMOKE_BURST -> 71 CombatSpell.SHADOW_BURST -> 73 CombatSpell.BLOOD_BURST -> 75 CombatSpell.ICE_BURST -> 77 CombatSpell.SMOKE_BLITZ -> 79 CombatSpell.SHADOW_BLITZ -> 81 CombatSpell.BLOOD_BLITZ -> 83 CombatSpell.ICE_BLITZ -> 85 CombatSpell.SMOKE_BARRAGE -> 87 CombatSpell.SHADOW_BARRAGE -> 89 CombatSpell.BLOOD_BARRAGE -> 91 CombatSpell.ICE_BARRAGE -> 93 CombatSpell.MIASMIC_RUSH -> 95 CombatSpell.MIASMIC_BURST -> 97 CombatSpell.MIASMIC_BLITZ -> 99 CombatSpell.MIASMIC_BARRAGE -> 101 else -> 0 } } return 0 } fun setSpellbook(book: Spellbook) { if (book == Spellbook.LUNAR && !player!!.isQuestComplete( Quest.LUNAR_DIPLOMACY, ""to use the Lunar spellbook."" ) ) return if (book == Spellbook.ANCIENT && !player!!.isQuestComplete( Quest.DESERT_TREASURE, ""to use the Ancient spellbook."" ) ) return if (book == Spellbook.DUNGEONEERING) isDungSpellbook = true else spellbook = book refreshSpellbook() player!!.interfaceManager.sendSubDefault(InterfaceManager.Sub.TAB_MAGIC) } fun getSpellbook(): Spellbook? { if (isDungSpellbook) return Spellbook.DUNGEONEERING return spellbook } fun switchShowCombatSpells() { showCombatSpells = !showCombatSpells refreshSpellbookSettings() } fun switchShowSkillSpells() { showSkillSpells = !showSkillSpells refreshSpellbookSettings() } fun switchShowMiscSpells() { showMiscSpells = !showMiscSpells refreshSpellbookSettings() } fun switchShowTeleportSkillSpells() { showTeleportSpells = !showTeleportSpells refreshSpellbookSettings() } fun switchDefensiveCasting() { isDefensiveCasting = !isDefensiveCasting refreshSpellbookSettings() } fun setSortSpellBook(sortId: Int) { sortSpellBook = sortId.toByte() refreshSpellbookSettings() } fun refreshSpellbookSettings() { player!!.vars.setVarBit(357, spellbook!!.ordinal) player!!.vars.setVarBit(5822, sortSpellBook.toInt()) player!!.vars.setVarBit(5823, sortSpellBook.toInt()) player!!.vars.setVarBit(5824, sortSpellBook.toInt()) player!!.vars.setVarBit(7347, sortSpellBook.toInt()) player!!.vars.setVarBit(6459, if (showCombatSpells) 0 else 1) player!!.vars.setVarBit(6466, if (showCombatSpells) 0 else 1) player!!.vars.setVarBit(6463, if (showCombatSpells) 0 else 1) player!!.vars.setVarBit(7348, if (showCombatSpells) 0 else 1) player!!.vars.setVarBit(6460, if (showSkillSpells) 0 else 1) player!!.vars.setVarBit(7349, if (showSkillSpells) 0 else 1) player!!.vars.setVarBit(6461, if (showMiscSpells) 0 else 1) player!!.vars.setVarBit(6464, if (showMiscSpells) 0 else 1) player!!.vars.setVarBit(7350, if (showMiscSpells) 0 else 1) player!!.vars.setVarBit(6462, if (showTeleportSpells) 0 else 1) player!!.vars.setVarBit(6467, if (showTeleportSpells) 0 else 1) player!!.vars.setVarBit(6465, if (showTeleportSpells) 0 else 1) player!!.vars.setVarBit(7351, if (showTeleportSpells) 0 else 1) player!!.vars.setVarBit(2668, if (isDefensiveCasting) 1 else 0) } fun setPlayer(player: Player?) { this.player = player bonuses = IntArray(18) if (spellbook == null) spellbook = Spellbook.MODERN } fun getBonus(bonus: Bonus): Int { return bonuses[bonus.ordinal] } fun setBonus(bonus: Bonus, `val`: Int) { bonuses[bonus.ordinal] = `val` } fun refreshBonuses() { bonuses = IntArray(18) for (item in player!!.equipment.itemsCopy) { if (item == null) continue for (bonus in Bonus.entries) { if (bonus == Bonus.RANGE_STR && getBonus(Bonus.RANGE_STR) != 0) continue bonuses[bonus.ordinal] += Equipment.getBonus(player, item, bonus) } } } fun resetSpecialAttack() { drainSpec(0) specialAttackPercentage = 100 refreshSpecialAttackPercentage() } fun setSpecialAttack(special: Int) { drainSpec(0) specialAttackPercentage = special.toByte() refreshSpecialAttackPercentage() } fun restoreSpecialAttack() { if (player!!.familiar != null) player!!.familiar.restoreSpecialAttack(15) if (specialAttackPercentage.toInt() == 100) return var toRestore = 10 if (player!!.auraManager.isActivated(AuraManager.Aura.INVIGORATE)) toRestore = 12 else if (player!!.auraManager.isActivated(AuraManager.Aura.GREATER_INVIGORATE)) toRestore = 15 else if (player!!.auraManager.isActivated(AuraManager.Aura.MASTER_INVIGORATE)) toRestore = 17 else if (player!!.auraManager.isActivated(AuraManager.Aura.SUPREME_INVIGORATE)) toRestore = 20 restoreSpecialAttack(toRestore) if (specialAttackPercentage.toInt() == 100 || specialAttackPercentage.toInt() == 50) player!!.sendMessage( ""Your special attack energy is now $specialAttackPercentage%."", true ) } fun restoreSpecialAttack(percentage: Int) { if (specialAttackPercentage >= 100 || player!!.interfaceManager.containsScreenInter()) return specialAttackPercentage = (specialAttackPercentage + if (specialAttackPercentage > (100 - percentage)) 100 - specialAttackPercentage else percentage).toByte() refreshSpecialAttackPercentage() } fun init() { refreshUsingSpecialAttack() refreshSpecialAttackPercentage() refreshAutoRelatie() refreshAttackStyle() refreshSpellbook() } fun refreshSpellbook() { refreshSpellbookSettings() refreshAutoCastSpell() player!!.vars.syncVarsToClient() player!!.packets.sendRunScriptBlank(2057) } fun checkAttackStyle() { if (autoCast == null) setAttackStyle(attackStyle.toInt()) } fun setAttackStyle(style: Int) { var finalStyle = style val styles = AttackStyle.getStyles( player!!.equipment.weaponId ) if (finalStyle < 0) finalStyle = 0 for (i in finalStyle downTo 0) { if (styles[i] != null) { finalStyle = i break } } if (finalStyle != attackStyle.toInt()) { attackStyle = finalStyle.toByte() if (autoCast != null) resetSpells(true) else refreshAttackStyle() } else if (autoCast != null) resetSpells(true) } fun refreshAttackStyle() { player!!.vars.setVar(43, (if (autoCast != null) 4 else attackStyle).toInt()) } fun sendUnlockAttackStylesButtons() { for (componentId in 7..10) player!!.packets.setIFRightClickOps(884, componentId, -1, 0, 0) } fun switchUsingSpecialAttack() { isUsingSpecialAttack = !isUsingSpecialAttack refreshUsingSpecialAttack() } fun drainSpec(amount: Int) { var finalAmount = amount isUsingSpecialAttack = false refreshUsingSpecialAttack() if (player!!.nsv.getB(""infSpecialAttack"")) finalAmount = 0 if (finalAmount > 0) { specialAttackPercentage = (specialAttackPercentage - finalAmount).toByte() refreshSpecialAttackPercentage() } } fun hasRingOfVigour(): Boolean { return player!!.equipment.ringId == 19669 } fun getSpecialAttackPercentage(): Int { return specialAttackPercentage.toInt() } fun refreshUsingSpecialAttack() { player!!.vars.setVar(301, if (isUsingSpecialAttack) 1 else 0) } fun refreshSpecialAttackPercentage() { player!!.vars.setVar(300, specialAttackPercentage * 10) } fun switchAutoRetaliate() { isAutoRetaliate = !isAutoRetaliate refreshAutoRelatie() } fun refreshAutoRelatie() { player!!.vars.setVar(172, if (isAutoRetaliate) 0 else 1) } fun getAttackStyle(): AttackStyle? { val styles = AttackStyle.getStyles( player!!.equipment.weaponId ) var style = attackStyle.toInt() for (i in style downTo 0) { if (styles[i] != null) { style = i break } } if (style != attackStyle.toInt()) setAttackStyle(style) return styles[style] } val attackBonusForStyle: Int get() = getAttackStyle()!!.attackType.getAttackBonus(player!!) fun getDefenseBonusForStyle(style: AttackStyle): Int { return style.attackType.getDefenseBonus(player!!) } fun removeDungeonneringBook() { if (isDungSpellbook) { isDungSpellbook = false player!!.interfaceManager.sendSubDefault(InterfaceManager.Sub.TAB_MAGIC) } } val attackStyleId: Int get() = attackStyle.toInt() }" "package com.rs.game.content.combat enum class CombatSpell( val req: Int, @JvmField val splashXp: Double, protected val baseDamage: Int, protected val castAnim: Animation, protected val castSpotAnim: SpotAnim?, protected val projAnim: Int, @JvmField val hitSpotAnim: SpotAnim, protected val castSound: Int, @JvmField val landSound: Int, @JvmField val splashSound: Int, val runeSet: RuneSet ) { WIND_RUSH(1, 2.7, 10, Animation(10546), SpotAnim(457), 458, SpotAnim(463), 7866, 7867, RuneSet(Rune.AIR, 2)), WIND_STRIKE(1, 5.5, 20, Animation(10546), SpotAnim(457), 458, SpotAnim(464), 220, 221, RuneSet(Rune.AIR, 1, Rune.MIND, 1)), WIND_BOLT(17, 13.5, 90, Animation(10546), SpotAnim(457), 459, SpotAnim(2699), 218, 219, RuneSet(Rune.AIR, 2, Rune.CHAOS, 1)) { override fun getBaseDamage(caster: Entity): Int { return if (caster is Player && caster.equipment.glovesId == 777) 120 else baseDamage } }, WIND_BLAST(41, 25.5, 130, Animation(10546), SpotAnim(457), 460, SpotAnim(2699), 216, 217, RuneSet(Rune.AIR, 3, Rune.DEATH, 1)), WIND_WAVE(62, 36.0, 170, Animation(10546), SpotAnim(457), 461, SpotAnim(2700), 222, 223, RuneSet(Rune.AIR, 5, Rune.BLOOD, 1)), WIND_SURGE(81, 75.0, 220, Animation(10546), SpotAnim(457), 462, SpotAnim(2700), 7866, 7867, RuneSet(Rune.AIR, 7, Rune.BLOOD, 1, Rune.DEATH, 1)), WATER_STRIKE(5, 7.5, 40, Animation(14220), SpotAnim(2701), 2703, SpotAnim(2708), 211, 212, RuneSet(Rune.AIR, 1, Rune.WATER, 1, Rune.MIND, 1)), WATER_BOLT(23, 16.5, 100, Animation(14220), SpotAnim(2701), 2704, SpotAnim(2709), 209, 210, RuneSet(Rune.AIR, 2, Rune.WATER, 2, Rune.CHAOS, 1)) { override fun getBaseDamage(caster: Entity): Int { return if (caster is Player && caster.equipment.glovesId == 777) 130 else baseDamage } }, WATER_BLAST(47, 28.5, 140, Animation(14220), SpotAnim(2701), 2705, SpotAnim(2710), 207, 208, RuneSet(Rune.AIR, 3, Rune.WATER, 3, Rune.DEATH, 1)), WATER_WAVE(65, 37.5, 180, Animation(14220), SpotAnim(2701), 2706, SpotAnim(2711), 213, 214, RuneSet(Rune.AIR, 5, Rune.WATER, 7, Rune.BLOOD, 1)), WATER_SURGE(85, 80.0, 240, Animation(14220), SpotAnim(2701), 2707, SpotAnim(2712), 7834, 7822, RuneSet(Rune.AIR, 7, Rune.WATER, 10, Rune.DEATH, 1, Rune.BLOOD, 1)), EARTH_STRIKE(9, 9.5, 60, Animation(14209), SpotAnim(2713), 2718, SpotAnim(2723), 132, 133, RuneSet(Rune.AIR, 1, Rune.EARTH, 2, Rune.MIND, 1)), EARTH_BOLT(29, 19.5, 110, Animation(14209), SpotAnim(2714), 2719, SpotAnim(2724), 130, 131, RuneSet(Rune.AIR, 2, Rune.EARTH, 3, Rune.CHAOS, 1)) { override fun getBaseDamage(caster: Entity): Int { return if (caster is Player && caster.equipment.glovesId == 777) 140 else baseDamage } }, EARTH_BLAST(53, 31.5, 150, Animation(14209), SpotAnim(2715), 2720, SpotAnim(2725), 128, 129, RuneSet(Rune.AIR, 3, Rune.EARTH, 4, Rune.DEATH, 1)), EARTH_WAVE(70, 40.0, 190, Animation(14209), SpotAnim(2716), 2721, SpotAnim(2726), 134, 135, RuneSet(Rune.AIR, 5, Rune.EARTH, 7, Rune.BLOOD, 1)), EARTH_SURGE(90, 85.0, 260, Animation(14209), SpotAnim(2717), 2722, SpotAnim(2727), 7914, 7919, RuneSet(Rune.AIR, 7, Rune.EARTH, 10, Rune.DEATH, 1, Rune.BLOOD, 1)), FIRE_STRIKE(13, 11.5, 80, Animation(2791), SpotAnim(2728), 2729, SpotAnim(2737), 160, 161, RuneSet(Rune.AIR, 2, Rune.FIRE, 3, Rune.MIND, 1)), FIRE_BOLT(35, 22.5, 120, Animation(2791), SpotAnim(2728), 2731, SpotAnim(2738), 157, 158, RuneSet(Rune.AIR, 3, Rune.FIRE, 4, Rune.CHAOS, 1)) { override fun getBaseDamage(caster: Entity): Int { return if (caster is Player && caster.equipment.glovesId == 777) 150 else baseDamage } }, FIRE_BLAST(59, 34.5, 160, Animation(2791), SpotAnim(2728), 2733, SpotAnim(2739), 155, 156, RuneSet(Rune.AIR, 4, Rune.FIRE, 5, Rune.DEATH, 1)), FIRE_WAVE(75, 42.5, 200, Animation(2791), SpotAnim(2728), 2735, SpotAnim(2740), 162, 163, RuneSet(Rune.AIR, 5, Rune.FIRE, 7, Rune.BLOOD, 1)), FIRE_SURGE(95, 90.0, 280, Animation(2791), SpotAnim(2728), 2735, SpotAnim(2741), 7932, 7933, RuneSet(Rune.AIR, 7, Rune.FIRE, 10, Rune.DEATH, 1, Rune.BLOOD, 1)) { override fun onCast(caster: Entity?, target: Entity?) { World.sendProjectile(caster, target, 2736, -25, 50, 1.0) World.sendProjectile(caster, target, 2736, 25, 50, 1.0) } }, CRUMBLE_UNDEAD(39, 24.5, 150, Animation(724), SpotAnim(145, 0, 96), 146, SpotAnim(147, 0, 96), 122, 124, RuneSet(Rune.AIR, 2, Rune.EARTH, 2, Rune.CHAOS, 1)) { override fun extraReqs(player: Player, target: Entity): Boolean { if (target !is NPC || !target.definitions.isUndead) { player.sendMessage(""This spell only affects skeletons, zombies, ghosts and shades."") return false } return true } }, IBAN_BLAST(50, 30.0, 250, Animation(708), SpotAnim(87, 0, 96), 88, SpotAnim(89, 0, 96), 162, 1341, RuneSet(Rune.DEATH, 1, Rune.FIRE, 5)) { override fun extraReqs(player: Player, target: Entity): Boolean { if (player.equipment.weaponId != 1409) { player.sendMessage(""You need Iban's staff to cast this spell."") return false } return true } }, MAGIC_DART(50, 31.5, 100, Animation(1575), SpotAnim(327, 0, 96), 328, SpotAnim(329, 0, 96), 1718, 174, RuneSet(Rune.MIND, 4, Rune.DEATH, 1)) { override fun extraReqs(player: Player, target: Entity): Boolean { if (!Magic.isSlayerStaff(player.equipment.weaponId)) { player.sendMessage(""You need a Slayer's staff to cast this spell."") return false } if (player.skills.getLevel(Constants.SLAYER) < 55) { player.sendMessage(""You need at least 55 Slayer to cast this spell."") return false } return true } override fun getBaseDamage(caster: Entity): Int { if (caster is Player) return (100.0 + caster.skills.getLevel(Constants.MAGIC).toDouble()).toInt() return 100 } }, SARADOMIN_STRIKE(50, 34.5, 200, Animation(811), null, -1, SpotAnim(76, 0, 96), 1659, -1, RuneSet(Rune.AIR, 4, Rune.FIRE, 1, Rune.BLOOD, 2)) { override fun extraReqs(player: Player, target: Entity): Boolean { if (player.equipment.weaponId != 2415) { player.sendMessage(""You need a Saradomin staff to cast this spell."") return false } return true } override fun getBaseDamage(caster: Entity): Int { if (caster is Player) return if (caster.hasEffect(Effect.CHARGED) && caster.equipment.capeId == 2412) 300 else baseDamage return baseDamage } override fun onHit(caster: Entity, target: Entity, hit: Hit) { if (target is Player) target.prayer.drainPrayer(1.0) } }, CLAWS_OF_GUTHIX(50, 34.5, 200, Animation(811), null, -1, SpotAnim(77, 0, 96), 1653, -1, RuneSet(Rune.AIR, 4, Rune.FIRE, 1, Rune.BLOOD, 2)) { override fun extraReqs(player: Player, target: Entity): Boolean { if (player.equipment.weaponId != 2416) { player.sendMessage(""You need a Guthix staff to cast this spell."") return false } return true } override fun getBaseDamage(caster: Entity): Int { if (caster is Player) return if (caster.hasEffect(Effect.CHARGED) && caster.equipment.capeId == 2413) 300 else baseDamage return baseDamage } override fun onHit(caster: Entity, target: Entity, hit: Hit) { target.lowerStat(Constants.DEFENSE, 0.05, 0.0) } }, FLAMES_OF_ZAMORAK(50, 34.5, 200, Animation(811), null, -1, SpotAnim(78, 0, 96), 1655, -1, RuneSet(Rune.AIR, 4, Rune.FIRE, 1, Rune.BLOOD, 2)) { override fun extraReqs(player: Player, target: Entity): Boolean { if (player.equipment.weaponId != 2417) { player.sendMessage(""You need a Zamorak staff to cast this spell."") return false } return true } override fun getBaseDamage(caster: Entity): Int { if (caster is Player) return if (caster.hasEffect(Effect.CHARGED) && caster.equipment.capeId == 2414) 300 else baseDamage return baseDamage } override fun onHit(caster: Entity, target: Entity, hit: Hit) { target.lowerStat(Constants.MAGIC, 0.05, 0.0) } }, STORM_OF_ARMADYL(77, 70.0, 160, Animation(10546), SpotAnim(457), 1019, SpotAnim(1019), 7866, 7867, RuneSet(Rune.ARMADYL, 1)) { override fun getCombatDelay(caster: Entity): Int { return if (caster is Player && caster.equipment.weaponId == 21777) 3 else 4 } override fun onHit(caster: Entity, target: Entity, hit: Hit) { target.lowerStat(Constants.DEFENSE, 1, 0.0) } override fun getBaseDamage(caster: Entity): Int { if (caster is Player) return baseDamage + (caster.skills.getLevelForXp(Constants.MAGIC) - 77) * 5 return baseDamage } }, CONFUSE(3, 13.0, -1, Animation(711), SpotAnim(102, 0, 96), 103, SpotAnim(104, 0, 96), 119, 121, RuneSet(Rune.BODY, 1, Rune.WATER, 3, Rune.EARTH, 2)) { override fun extraReqs(player: Player, target: Entity): Boolean { if (target is NPC) { if (target.attackLevel < target.combatDefinitions.attackLevel) { player.sendMessage(""That target is already weakened."") return false } } else if (target is Player) if (target.skills.getLevel(Constants.ATTACK) < target.skills.getLevelForXp(Constants.ATTACK)) { player.sendMessage(""That target is already weakened."") return false } return true } override fun onHit(caster: Entity, target: Entity, hit: Hit) { target.lowerStat(Constants.ATTACK, 0.05, 0.95) } }, WEAKEN(11, 21.0, -1, Animation(711), SpotAnim(105, 0, 96), 106, SpotAnim(107, 0, 96), 3011, 3010, RuneSet(Rune.BODY, 1, Rune.WATER, 3, Rune.EARTH, 2)) { override fun extraReqs(player: Player, target: Entity): Boolean { if (target is NPC) { if (target.strengthLevel < target.combatDefinitions.strengthLevel) { player.sendMessage(""That target is already weakened."") return false } } else if (target is Player) if (target.skills.getLevel(Constants.STRENGTH) < target.skills.getLevelForXp(Constants.STRENGTH)) { player.sendMessage(""That target is already weakened."") return false } return true } override fun onHit(caster: Entity, target: Entity, hit: Hit) { target.lowerStat(Constants.STRENGTH, 0.05, 0.95) } }, CURSE(19, 29.0, -1, Animation(711), SpotAnim(108, 0, 96), 109, SpotAnim(110, 0, 96), 127, 126, RuneSet(Rune.BODY, 1, Rune.WATER, 2, Rune.EARTH, 3)) { override fun extraReqs(player: Player, target: Entity): Boolean { if (target is NPC) { if (target.defenseLevel < target.combatDefinitions.defenseLevel) { player.sendMessage(""That target is already weakened."") return false } } else if (target is Player) if (target.skills.getLevel(Constants.DEFENSE) < target.skills.getLevelForXp(Constants.DEFENSE)) { player.sendMessage(""That target is already weakened."") return false } return true } override fun onHit(caster: Entity, target: Entity, hit: Hit) { target.lowerStat(Constants.DEFENSE, 0.05, 0.95) } }, VULNERABILITY(66, 76.0, -1, Animation(711), SpotAnim(167, 0, 96), 168, SpotAnim(169, 0, 96), 3009, 3008, RuneSet(Rune.SOUL, 1, Rune.WATER, 5, Rune.EARTH, 5)) { override fun extraReqs(player: Player, target: Entity): Boolean { if (target is NPC) { if (target.defenseLevel < target.combatDefinitions.defenseLevel) { player.sendMessage(""That target is already weakened."") return false } } else if (target is Player) if (target.skills.getLevel(Constants.DEFENSE) < target.skills.getLevelForXp(Constants.DEFENSE)) { player.sendMessage(""That target is already weakened."") return false } return true } override fun onHit(caster: Entity, target: Entity, hit: Hit) { target.lowerStat(Constants.DEFENSE, 0.1, 0.9) } }, ENFEEBLE(73, 83.0, -1, Animation(711), SpotAnim(170, 0, 96), 171, SpotAnim(172, 0, 96), 148, 150, RuneSet(Rune.SOUL, 1, Rune.WATER, 8, Rune.EARTH, 8)) { override fun extraReqs(player: Player, target: Entity): Boolean { if (target is NPC) { if (target.strengthLevel < target.combatDefinitions.strengthLevel) { player.sendMessage(""That target is already weakened."") return false } } else if (target is Player) if (target.skills.getLevel(Constants.STRENGTH) < target.skills.getLevelForXp(Constants.STRENGTH)) { player.sendMessage(""That target is already weakened."") return false } return true } override fun onHit(caster: Entity, target: Entity, hit: Hit) { target.lowerStat(Constants.STRENGTH, 0.1, 0.9) } }, STUN(80, 90.0, -1, Animation(711), SpotAnim(173, 0, 96), 174, SpotAnim(245, 0, 96), 3004, 3005, RuneSet(Rune.SOUL, 1, Rune.WATER, 12, Rune.EARTH, 12)) { override fun extraReqs(player: Player, target: Entity): Boolean { if (target is NPC) { if (target.attackLevel < target.combatDefinitions.attackLevel) { player.sendMessage(""That target is already weakened."") return false } } else if (target is Player) if (target.skills.getLevel(Constants.ATTACK) < target.skills.getLevelForXp(Constants.ATTACK)) { player.sendMessage(""That target is already weakened."") return false } return true } override fun onHit(caster: Entity, target: Entity, hit: Hit) { target.lowerStat(Constants.ATTACK, 0.1, 0.9) } }, BIND(20, 30.0, 20, Animation(710), SpotAnim(177, 0, 96), 178, SpotAnim(181, 0, 96), 101, 99, RuneSet(Rune.NATURE, 2, Rune.WATER, 3, Rune.EARTH, 3)) { override fun onHit(caster: Entity, target: Entity, hit: Hit) { target.freeze(Ticks.fromSeconds(5), true) } }, SNARE(50, 60.0, 30, Animation(710), SpotAnim(177, 0, 96), 178, SpotAnim(180, 0, 96), 3003, 3002, RuneSet(Rune.NATURE, 3, Rune.WATER, 4, Rune.EARTH, 4)) { override fun onHit(caster: Entity, target: Entity, hit: Hit) { target.freeze(Ticks.fromSeconds(10), true) } }, ENTANGLE(79, 89.0, 50, Animation(710), SpotAnim(177, 0, 96), 178, SpotAnim(179, 0, 96), 151, 153, RuneSet(Rune.NATURE, 4, Rune.WATER, 5, Rune.EARTH, 5)) { override fun onHit(caster: Entity, target: Entity, hit: Hit) { target.freeze(Ticks.fromSeconds(20), true) } }, TELEPORT_BLOCK(85, 80.0, 30, Animation(10503), SpotAnim(1841), 1842, SpotAnim(1843), 202, 203, RuneSet(Rune.CHAOS, 1, Rune.LAW, 1, Rune.DEATH, 1)) { override fun onHit(caster: Entity, target: Entity, hit: Hit) { if (target is Player) { if (target.prayer.isProtectingMage) target.addEffect(Effect.TELEBLOCK, Ticks.fromMinutes(2.5).toLong()) else target.addEffect(Effect.TELEBLOCK, Ticks.fromMinutes(5).toLong()) target.sendMessage(""You have been teleport blocked!"") } } override fun extraReqs(player: Player, target: Entity): Boolean { if (target !is Player) { player.sendMessage(""This spell is only effective against other players."") return false } if (target.hasEffect(Effect.TELEBLOCK)) { player.sendMessage(""That player is already affected by this spell."") return false } return true } }, SMOKE_RUSH(50, 30.0, 130, Animation(1978), null, 384, SpotAnim(385, 0, 96), 183, 185, RuneSet(Rune.DEATH, 2, Rune.CHAOS, 2, Rune.FIRE, 1, Rune.AIR, 1)) { override fun onHit(caster: Entity, target: Entity, hit: Hit) { if (Utils.random(5) == 0) target.poison.makePoisoned(20) } }, SMOKE_BURST(62, 36.0, 170, Animation(1979), null, -1, SpotAnim(389, 0, 96), 183, 182, RuneSet(Rune.DEATH, 2, Rune.CHAOS, 4, Rune.FIRE, 2, Rune.AIR, 2)) { override fun onHit(caster: Entity, target: Entity, hit: Hit) { if (Utils.random(5) == 0) target.poison.makePoisoned(20) } }, SMOKE_BLITZ(74, 42.0, 230, Animation(1978), null, 386, SpotAnim(387, 0, 96), 183, 181, RuneSet(Rune.BLOOD, 2, Rune.DEATH, 2, Rune.FIRE, 2, Rune.AIR, 2)) { override fun onHit(caster: Entity, target: Entity, hit: Hit) { if (Utils.random(5) == 0) target.poison.makePoisoned(40) } }, SMOKE_BARRAGE(86, 48.0, 270, Animation(1979), null, -1, SpotAnim(391, 0, 96), 183, 180, RuneSet(Rune.BLOOD, 2, Rune.DEATH, 4, Rune.FIRE, 4, Rune.AIR, 4)) { override fun onHit(caster: Entity, target: Entity, hit: Hit) { if (Utils.random(5) == 0) target.poison.makePoisoned(40) } }, SHADOW_RUSH(52, 31.0, 140, Animation(1978), null, 378, SpotAnim(379), 178, 179, RuneSet(Rune.SOUL, 1, Rune.DEATH, 2, Rune.CHAOS, 2, Rune.AIR, 1)) { override fun onHit(caster: Entity, target: Entity, hit: Hit) { target.lowerStat(Constants.ATTACK, 0.1, 0.9) } }, SHADOW_BURST(64, 37.0, 180, Animation(1979), null, -1, SpotAnim(382), 178, 177, RuneSet(Rune.SOUL, 2, Rune.DEATH, 2, Rune.CHAOS, 4, Rune.AIR, 1)) { override fun onHit(caster: Entity, target: Entity, hit: Hit) { target.lowerStat(Constants.ATTACK, 0.1, 0.9) } }, SHADOW_BLITZ(76, 43.0, 240, Animation(1978), null, 380, SpotAnim(381), 178, 176, RuneSet(Rune.SOUL, 2, Rune.BLOOD, 2, Rune.DEATH, 2, Rune.AIR, 2)) { override fun onHit(caster: Entity, target: Entity, hit: Hit) { target.lowerStat(Constants.ATTACK, 0.15, 0.85) } }, SHADOW_BARRAGE(88, 48.0, 280, Animation(1979), null, -1, SpotAnim(383), 178, 175, RuneSet(Rune.SOUL, 3, Rune.BLOOD, 2, Rune.DEATH, 4, Rune.AIR, 4)) { override fun onHit(caster: Entity, target: Entity, hit: Hit) { target.lowerStat(Constants.ATTACK, 0.15, 0.85) } }, BLOOD_RUSH(56, 33.0, 150, Animation(1978), null, 374, SpotAnim(373), 106, 110, RuneSet(Rune.BLOOD, 1, Rune.DEATH, 2, Rune.CHAOS, 2)) { override fun onHit(caster: Entity, target: Entity, hit: Hit) { caster.heal((hit.damage * 0.25).toInt()) } }, BLOOD_BURST(68, 39.0, 210, Animation(1979), null, -1, SpotAnim(376), 106, 105, RuneSet(Rune.BLOOD, 2, Rune.DEATH, 2, Rune.CHAOS, 4)) { override fun onHit(caster: Entity, target: Entity, hit: Hit) { caster.heal((hit.damage * 0.25).toInt()) } }, BLOOD_BLITZ(80, 45.0, 250, Animation(1978), null, 374, SpotAnim(375), 106, 104, RuneSet(Rune.BLOOD, 4, Rune.DEATH, 2)) { override fun onHit(caster: Entity, target: Entity, hit: Hit) { caster.heal((hit.damage * 0.25).toInt()) } }, BLOOD_BARRAGE(92, 51.0, 290, Animation(1979), null, -1, SpotAnim(377), 106, 102, RuneSet(Rune.SOUL, 1, Rune.BLOOD, 4, Rune.DEATH, 4)) { override fun onHit(caster: Entity, target: Entity, hit: Hit) { caster.heal((hit.damage * 0.25).toInt()) } }, ICE_RUSH(58, 34.0, 160, Animation(1978), null, 360, SpotAnim(361), 171, 173, RuneSet(Rune.DEATH, 2, Rune.CHAOS, 2, Rune.WATER, 2)) { override fun onHit(caster: Entity, target: Entity, hit: Hit) { target.freeze(Ticks.fromSeconds(5), true) } }, ICE_BURST(70, 40.0, 220, Animation(1979), null, -1, SpotAnim(363), 171, 170, RuneSet(Rune.DEATH, 2, Rune.CHAOS, 4, Rune.WATER, 4)) { override fun onHit(caster: Entity, target: Entity, hit: Hit) { target.freeze(Ticks.fromSeconds(10), true) } }, ICE_BLITZ(82, 46.0, 260, Animation(1978), SpotAnim(366, 0, 96), 362, SpotAnim(367), 171, 169, RuneSet(Rune.BLOOD, 2, Rune.DEATH, 2, Rune.WATER, 3)) { override fun onHit(caster: Entity, target: Entity, hit: Hit) { target.freeze(Ticks.fromSeconds(15), true) } }, ICE_BARRAGE(94, 52.0, 300, Animation(1979), SpotAnim(368, 0, 96), -1, SpotAnim(369), 171, 168, RuneSet(Rune.BLOOD, 2, Rune.DEATH, 4, Rune.WATER, 6)) { override fun onHit(caster: Entity, target: Entity, hit: Hit) { target.freeze(Ticks.fromSeconds(20), true) } }, MIASMIC_RUSH(61, 36.0, 180, Animation(10513), SpotAnim(1845), 1846, SpotAnim(1847), 5368, 5365, RuneSet(Rune.SOUL, 1, Rune.CHAOS, 2, Rune.EARTH, 1)) { override fun extraReqs(player: Player, target: Entity): Boolean { if (player.equipment.weaponId != 13867 && player.equipment.weaponId != 13869 && player.equipment.weaponId != 13941 && player.equipment.weaponId != 13943) { player.sendMessage(""You need a Zuriel's staff to cast this spell."") return false } return true } override fun onHit(caster: Entity, target: Entity, hit: Hit) { if (target is Player) target.refreshMiasmicTimer(Ticks.fromSeconds(12)) } }, MIASMIC_BURST(73, 42.0, 240, Animation(10516), SpotAnim(1848), -1, SpotAnim(1849), 5366, 5372, RuneSet(Rune.SOUL, 2, Rune.CHAOS, 4, Rune.EARTH, 2)) { override fun extraReqs(player: Player, target: Entity): Boolean { if (player.equipment.weaponId != 13867 && player.equipment.weaponId != 13869 && player.equipment.weaponId != 13941 && player.equipment.weaponId != 13943) { player.sendMessage(""You need a Zuriel's staff to cast this spell."") return false } return true } override fun onHit(caster: Entity, target: Entity, hit: Hit) { if (target is Player) target.refreshMiasmicTimer(Ticks.fromSeconds(24)) } }, MIASMIC_BLITZ(85, 48.0, 280, Animation(10524), SpotAnim(1850), 1852, SpotAnim(1851), 5370, 5367, RuneSet(Rune.SOUL, 3, Rune.BLOOD, 2, Rune.EARTH, 1)) { override fun extraReqs(player: Player, target: Entity): Boolean { if (player.equipment.weaponId != 13867 && player.equipment.weaponId != 13869 && player.equipment.weaponId != 13941 && player.equipment.weaponId != 13943) { player.sendMessage(""You need a Zuriel's staff to cast this spell."") return false } return true } override fun onHit(caster: Entity, target: Entity, hit: Hit) { if (target is Player) target.refreshMiasmicTimer(Ticks.fromSeconds(36)) } }, MIASMIC_BARRAGE(97, 54.0, 320, Animation(10518), SpotAnim(1853), -1, SpotAnim(1854), 5371, 5369, RuneSet(Rune.SOUL, 4, Rune.BLOOD, 4, Rune.EARTH, 4)) { override fun extraReqs(player: Player, target: Entity): Boolean { if (player.equipment.weaponId != 13867 && player.equipment.weaponId != 13869 && player.equipment.weaponId != 13941 && player.equipment.weaponId != 13943) { player.sendMessage(""You need a Zuriel's staff to cast this spell."") return false } return true } override fun onHit(caster: Entity, target: Entity, hit: Hit) { if (target is Player) target.refreshMiasmicTimer(Ticks.fromSeconds(48)) } }; constructor( req: Int, splashXp: Double, baseDamage: Int, castAnim: Animation, castSpotAnim: SpotAnim?, projAnim: Int, hitSpotAnim: SpotAnim, castSound: Int, landSound: Int, runes: RuneSet ) : this(req, splashXp, baseDamage, castAnim, castSpotAnim, projAnim, hitSpotAnim, castSound, landSound, -1, runes) private fun getCastAnim(caster: Entity): Animation { return when (this) { EARTH_BLAST, EARTH_BOLT, EARTH_STRIKE, EARTH_SURGE, EARTH_WAVE -> if (caster is Player && caster.equipment.weaponName.lowercase(Locale.getDefault()).contains(""staff"")) Animation(14222) else castAnim WIND_BLAST, WIND_BOLT, WIND_RUSH, WIND_STRIKE, WIND_SURGE, WIND_WAVE -> if (caster is Player && caster.equipment.weaponName.lowercase(Locale.getDefault()).contains(""staff"")) Animation(14221) else castAnim else -> castAnim } } val isFireSpell: Boolean get() = when (this) { FIRE_STRIKE, FIRE_BOLT, FIRE_BLAST, FIRE_WAVE, FIRE_SURGE -> true else -> false } val isWaterSpell: Boolean get() = when (this) { WATER_STRIKE, WATER_BOLT, WATER_BLAST, WATER_WAVE, WATER_SURGE -> true else -> false } val isEarthSpell: Boolean get() = when (this) { EARTH_STRIKE, EARTH_BOLT, EARTH_BLAST, EARTH_WAVE, EARTH_SURGE -> true else -> false } val isAirSpell: Boolean get() = when (this) { WIND_STRIKE, WIND_BOLT, WIND_BLAST, WIND_WAVE, WIND_SURGE -> true else -> false } private fun getCastSpotAnim(caster: Entity): SpotAnim? { return when (this) { WATER_BLAST, WATER_BOLT, WATER_STRIKE, WATER_SURGE, WATER_WAVE -> (if (caster is Player && caster.equipment.weaponName.lowercase(Locale.getDefault()).contains(""staff"")) SpotAnim(2702) else castSpotAnim) else -> castSpotAnim } } open fun getBaseDamage(caster: Entity): Int { return baseDamage } fun cast(caster: Entity, target: Entity?): Int { val castAnim = getCastAnim(caster) val castSpotAnim = getCastSpotAnim(caster) caster.anim(castAnim) if (castSpotAnim != null) caster.spotAnim(castSpotAnim) if (castSound != -1) caster.soundEffect(target, castSound, true) onCast(caster, target) return World.sendProjectile(caster, target, projAnim, if ((castSpotAnim?.height ?: 0) > 50) 20 else 0, 50, 1.0).taskDelay } open fun onCast(caster: Entity?, target: Entity?) {} open fun onHit(caster: Entity, target: Entity, hit: Hit) {} open fun getCombatDelay(caster: Entity): Int { if (caster is Player) if (caster.controllerManager.isIn(DungeonController::class.java) && caster.dungManager.activePerk == KinshipPerk.BLITZER) { val chance: Int = 10 * caster.dungManager.getKinshipTier(KinshipPerk.BLITZER) if (Utils.random(100) < chance) return 3 } return 4 } val isAOE: Boolean get() = when (this) { BLOOD_BARRAGE, BLOOD_BURST, ICE_BARRAGE, ICE_BURST, MIASMIC_BARRAGE, MIASMIC_BURST, SHADOW_BARRAGE, SHADOW_BURST, SMOKE_BARRAGE, SMOKE_BURST -> true else -> false } open fun extraReqs(player: Player, target: Entity): Boolean { return true } fun canCast(player: Player, target: Entity): Boolean { if (player.skills.getLevel(Constants.MAGIC) < req) { player.sendMessage(""You need a magic level of $req to cast this spell."") return false } if (!extraReqs(player, target)) return false return runeSet.meetsRequirements(player) } companion object { private val SPELL_MAP: Map> = mapOf( //Modern spellbook 192 to mapOf( 98 to WIND_RUSH, 25 to WIND_STRIKE, 26 to CONFUSE, 28 to WATER_STRIKE, 30 to EARTH_STRIKE, 31 to WEAKEN, 32 to FIRE_STRIKE, 34 to WIND_BOLT, 35 to CURSE, 36 to BIND, 39 to WATER_BOLT, 42 to EARTH_BOLT, 45 to FIRE_BOLT, 47 to CRUMBLE_UNDEAD, 49 to WIND_BLAST, 52 to WATER_BLAST, 54 to IBAN_BLAST, 55 to SNARE, 56 to MAGIC_DART, 58 to EARTH_BLAST, 63 to FIRE_BLAST, 66 to SARADOMIN_STRIKE, 67 to CLAWS_OF_GUTHIX, 68 to FLAMES_OF_ZAMORAK, 70 to WIND_WAVE, 73 to WATER_WAVE, 75 to VULNERABILITY, 77 to EARTH_WAVE, 78 to ENFEEBLE, 80 to FIRE_WAVE, 99 to STORM_OF_ARMADYL, 81 to ENTANGLE, 82 to STUN, 84 to WIND_SURGE, 86 to TELEPORT_BLOCK, 87 to WATER_SURGE, 89 to EARTH_SURGE, 91 to FIRE_SURGE, ), //Ancient spellbook 193 to mapOf( 28 to SMOKE_RUSH, 32 to SHADOW_RUSH, 24 to BLOOD_RUSH, 20 to ICE_RUSH, 36 to MIASMIC_RUSH, 30 to SMOKE_BURST, 34 to SHADOW_BURST, 26 to BLOOD_BURST, 22 to ICE_BURST, 38 to MIASMIC_BURST, 29 to SMOKE_BLITZ, 33 to SHADOW_BLITZ, 25 to BLOOD_BLITZ, 21 to ICE_BLITZ, 37 to MIASMIC_BLITZ, 31 to SMOKE_BARRAGE, 35 to SHADOW_BARRAGE, 27 to BLOOD_BARRAGE, 23 to ICE_BARRAGE, 39 to MIASMIC_BARRAGE, ), //Lunar spellbook 430 to mapOf(), //Dungeoneering spellbook 950 to mapOf( 25 to WIND_STRIKE, 26 to CONFUSE, 27 to WATER_STRIKE, 28 to EARTH_STRIKE, 29 to WEAKEN, 30 to FIRE_STRIKE, 32 to WIND_BOLT, 33 to CURSE, 34 to BIND, 36 to WATER_BOLT, 37 to EARTH_BOLT, 41 to FIRE_BOLT, 42 to WIND_BLAST, 43 to WATER_BLAST, 44 to SNARE, 45 to EARTH_BLAST, 47 to FIRE_BLAST, 48 to WIND_WAVE, 49 to WATER_WAVE, 50 to VULNERABILITY, 54 to EARTH_WAVE, 56 to ENFEEBLE, 58 to FIRE_WAVE, 59 to ENTANGLE, 60 to STUN, 61 to WIND_SURGE, 62 to WATER_SURGE, 63 to EARTH_SURGE, 67 to FIRE_SURGE, ) ) @JvmStatic fun forId(spellBook: Int, spellId: Int): CombatSpell? { return SPELL_MAP[spellBook]!![spellId] } } }" "package com.rs.game.content.combat class PlayerCombat(@JvmField val target: Entity) : PlayerAction() { override fun start(player: Player): Boolean { player.actionManager.forceStop() player.setNextFaceEntity(target) if (!player.controllerManager.canAttack(target)) return false if (target is Player) { if (!player.isCanPvp || !target.isCanPvp) { player.sendMessage(""You can only attack players in a player-vs-player area."") return false } } if (target is Familiar) { if (target === player.familiar) { player.sendMessage(""You can't attack your own familiar."") return false } if (!target.canAttack(player)) { player.sendMessage(""You can't attack them."") return false } } if (!player.canAttackMulti(target)) return false if (!checkAll(player)) return false if (target is NPC) player.lastNpcInteractedName = target.definitions.name return true } override fun process(player: Player): Boolean { return checkAll(player) } override fun processWithDelay(player: Player): Int { if (target is Player) if ((!target.attackedBy(player.username)) && (!player.attackedBy(target.username))) target.addToAttackedBy(player.username) var multiplier = 1.0 if (player.hasEffect(Effect.MIASMIC_SLOWDOWN)) multiplier = 1.5 if (!player.controllerManager.keepCombating(target)) return -1 addAttackedByDelay(player, target) player.tempAttribs.setO(""combatTarget"", target) val spell = player.combatDefinitions.spell if (player.tempAttribs.getB(""dfsActive"")) { val shield = player.equipment[Equipment.SHIELD] player.setNextFaceEntity(target) if (shield == null || shield.getMetaDataI(""dfsCharges"") < 0) { player.tempAttribs.setB(""dfsActive"", false) player.sendMessage(""Your shield was unable to be activated."") return 3 } player.sync(6696, 1165) val p = World.sendProjectile(player, target, 1166, 32, 32, 50, 2.0, 15, 0) delayMagicHit(target, p.taskDelay, Hit(player, Utils.random(100, 250), HitLook.TRUE_DAMAGE), { target.spotAnim(1167, 0, 96) }, null, null) player.tempAttribs.setB(""dfsActive"", false) player.tempAttribs.setL(""dfsCd"", World.getServerTicks() + 200) shield.addMetaData(""dfsCharges"", shield.getMetaDataI(""dfsCharges"") - 1) player.combatDefinitions.refreshBonuses() return 3 } if (spell == null && usingPolypore(player)) { player.setNextFaceEntity(target) player.sync(15448, 2034) drainCharge(player) val p = World.sendProjectile(player, target, 2035, 60, 32, 50, 2.0, 0, 0) val hit = calculateMagicHit(player, target, (5 * player.skills.getLevel(Constants.MAGIC)) - 180, false) delayMagicHit(target, p.taskDelay, hit, { if (hit.damage > 0) target.spotAnim(2036, 0, 96) else { target.spotAnim(85, 0, 96) player.soundEffect(target, 227, true) } }, null, null) return 4 } if (spell != null) { if (player.combatDefinitions.isUsingSpecialAttack) return execute(SpecialAttack.Type.MAGIC, player, target) val manualCast = player.combatDefinitions.hasManualCastQueued() val gloves = player.equipment.getItem(Equipment.HANDS) if (gloves != null && gloves.definitions.getName().contains(""Spellcaster glove"") && player.equipment.weaponId == -1 && Utils.random(20) == 0) player.tempAttribs.setO(""spellcasterProc"", spell) val delay = mageAttack(player, spell, !manualCast) if (player.nextAnimation != null && player.tempAttribs.getO(""spellcasterProc"") != null) { player.anim(14339) player.tempAttribs.removeO(""spellcasterProc"") } return delay } else if (isRanging(player)) { val weapon = RangedWeapon.forId(player.equipment.weaponId) if (weapon!!.properAmmo(player, true)) return (rangeAttack(player) * multiplier).toInt() player.faceTile(target.tile) return -1 } else return (meleeAttack(player) * multiplier).toInt() } fun mageAttack(player: Player, spell: CombatSpell?, autoCast: Boolean): Int { if (!autoCast) { player.combatDefinitions.resetSpells(false) player.stopAll(false) } if (spell == null) return -1 if (!spell.canCast(player, target)) { if (autoCast) player.combatDefinitions.resetSpells(true) return -1 } when (player.equipment.weaponId) { 15486, 15502, 22207, 22209, 22211, 22213 -> if (Utils.random(8) != 0) spell.runeSet.deleteRunes(player) else player.sendMessage(""Your spell draws its power completely from your weapon."", true) else -> spell.runeSet.deleteRunes(player) } val delay = spell.cast(player, target) val baseDamage = spell.getBaseDamage(player) player.skills.addXp(Constants.MAGIC, spell.splashXp) if (baseDamage < 0) { val hit = calculateMagicHit(player, target, 1000) if (hit.damage > 0) spell.onHit(player, target, hit) target.tasks.schedule(delay) { if (hit.damage > 0) { target.spotAnim(spell.hitSpotAnim) if (spell.landSound != -1) player.soundEffect(target, spell.landSound, true) } else { target.spotAnim(85, 0, 96) if (spell.splashSound != -1) player.soundEffect(target, spell.splashSound, true) else player.soundEffect(target, 227, true) } } } else { val hit = castSpellAtTarget(player, target, spell, delay) if (spell.isAOE && hit) attackTarget(getMultiAttackTargets(player, target, 1, 9, false)) { nextTarget -> castSpellAtTarget(player, nextTarget, spell, delay) return@attackTarget true } } return spell.getCombatDelay(player) } fun castSpellAtTarget(player: Player, target: Entity, spell: CombatSpell, hitDelay: Int): Boolean { val hit = calculateMagicHit(player, target, spell.getBaseDamage(player)) if (spell === CombatSpell.STORM_OF_ARMADYL && hit.damage > 0) { var minHit = (player.skills.getLevel(Constants.MAGIC) - 77) * 5 minHit = (minHit * getMagicBonusBoost(player)).toInt() if (hit.damage < minHit) hit.setDamage(hit.damage + minHit) } hit.setData(""combatSpell"", spell) val sparkle = target.size >= 2 || target.hasEffect(Effect.FREEZE) || target.hasEffect(Effect.FREEZE_BLOCK) delayMagicHit(target, hitDelay, hit, { if (hit.damage > 0) when (spell) { CombatSpell.ICE_RUSH, CombatSpell.ICE_BURST, CombatSpell.ICE_BLITZ, CombatSpell.ICE_BARRAGE -> { if (sparkle) target.spotAnim(1677, 0, 96) else target.spotAnim(spell.hitSpotAnim) if (spell.landSound != -1) player.soundEffect(target, spell.landSound, true) } else -> { target.spotAnim(spell.hitSpotAnim) if (spell.landSound != -1) player.soundEffect(target, spell.landSound, true) } } else { target.spotAnim(85, 0, 96) if (spell.splashSound != -1) player.soundEffect(target, spell.splashSound, true) else player.soundEffect(target, 227, true) } }, { spell.onHit(player, target, hit) }, null) return hit.damage > 0 } private fun rangeAttack(player: Player): Int { val weaponId = player.equipment.weaponId val attackStyle = player.combatDefinitions.getAttackStyle() val weaponConfig = ItemConfig.get(weaponId) var soundId = weaponConfig.getAttackSound(attackStyle!!.index) val weapon = RangedWeapon.forId(weaponId) val ammo = AmmoType.forId(player.equipment.ammoId) var combatDelay = getRangeCombatDelay(weaponId, attackStyle) if (player.combatDefinitions.isUsingSpecialAttack) return execute(SpecialAttack.Type.RANGE, player, target) val p = weapon!!.getProjectile(player, target, combatDelay) when (weapon) { RangedWeapon.DEATHTOUCHED_DART -> { player.anim(weaponConfig.getAttackAnim(0)) target.spotAnim(44) target.resetWalkSteps() if (target is NPC) { target.getTasks().schedule(p.taskDelay) { target.capDamage = -1 target.applyHit(Hit(player, target.getHitpoints(), HitLook.TRUE_DAMAGE)) } dropAmmo(player, target, Equipment.WEAPON, 1) return 8 } else return 0 } RangedWeapon.CHINCHOMPA, RangedWeapon.RED_CHINCHOMPA -> { //TODO validate the logic here attackTarget(getMultiAttackTargets(player, target)) { nextTarget -> val hit = calculateHit(player, nextTarget, weaponId, attackStyle, true, true, 1.0, if (weaponId == 10034) 1.2 else 1.0) player.anim(2779) nextTarget.tasks.schedule(p.taskDelay) { nextTarget.spotAnim(2739, 0, 96 shl 16) } delayHit(nextTarget, p.taskDelay, weaponId, attackStyle, hit) return@attackTarget hit.damage > 0 } dropAmmo(player, target, Equipment.WEAPON, 1) } RangedWeapon.SWAMP_LIZARD, RangedWeapon.ORANGE_SALAMANDER, RangedWeapon.RED_SALAMANDER, RangedWeapon.BLACK_SALAMANDER -> { val hit = when (attackStyle.name) { ""Flare"" -> calculateHit(player, target, weaponId, attackStyle, true).setLook(HitLook.RANGE_DAMAGE) ""Blaze"" -> calculateHit(player, target, weaponId, attackStyle, true).setLook(HitLook.MAGIC_DAMAGE) else -> calculateHit(player, target, weaponId, attackStyle, true).setLook(HitLook.MELEE_DAMAGE) } delayHit(target, p.taskDelay, weaponId, attackStyle, hit) dropAmmo(player, target, Equipment.AMMO, 1) if (attackStyle.name == ""Flare"") combatDelay = 3 } RangedWeapon.CROSSBOW, RangedWeapon.BRONZE_CROSSBOW, RangedWeapon.BLURITE_CROSSBOW, RangedWeapon.IRON_CROSSBOW, RangedWeapon.STEEL_CROSSBOW, RangedWeapon.BLACK_CROSSBOW, RangedWeapon.MITH_CROSSBOW, RangedWeapon.ADAMANT_CROSSBOW, RangedWeapon.RUNE_CROSSBOW, RangedWeapon.ARMADYL_CROSSBOW, RangedWeapon.CHAOTIC_CROSSBOW, RangedWeapon.ZANIKS_CROSSBOW -> { val hit: Hit var specced = false if (player.equipment.ammoId == 9241 && Utils.random(100) <= 55 && !target.poison.isPoisoned) { target.spotAnim(752) target.poison.makePoisoned(50) specced = true } if (player.equipment.ammoId != -1 && Utils.getRandomInclusive(10) == 0) { when (player.equipment.ammoId) { 9237 -> { hit = calculateHit(player, target, weaponId, attackStyle, true) target.spotAnim(755) if (target is Player) target.stopAll() else if (target is NPC) target.target = null soundId = 2914 } 9242 -> { hit = Hit.range(player, (target.hitpoints * 0.2).toInt()) target.spotAnim(754) player.applyHit(Hit(target, if (player.hitpoints > 20) (player.hitpoints * 0.1).toInt() else 1, HitLook.REFLECTED_DAMAGE)) soundId = 2912 } 9243 -> { hit = calculateHit(player, target, weaponId, attackStyle, true, false, 1.0, 1.15) target.spotAnim(758) soundId = 2913 } 9244 -> { hit = calculateHit(player, target, weaponId, attackStyle, true, false, 1.0, if (getAntifireLevel(target, true) > 0) 1.45 else 1.0) target.spotAnim(756) soundId = 2915 } 9245 -> { hit = calculateHit(player, target, weaponId, attackStyle, true, false, 1.0, 1.15) target.spotAnim(753) player.heal((player.maxHitpoints * 0.25).toInt()) soundId = 2917 } else -> hit = calculateHit(player, target, weaponId, attackStyle, true) } specced = true } else { hit = calculateHit(player, target, weaponId, attackStyle, true) checkSwiftGlovesEffect(player, p.taskDelay, attackStyle, weaponId, hit, p) } delayHit(target, p.taskDelay, weaponId, attackStyle, hit) if (specced) player.equipment.removeAmmo(Equipment.AMMO, 1) else dropAmmo(player, target, Equipment.AMMO, 1) } RangedWeapon.ROYAL_CROSSBOW -> { if (target is Player) player.sendMessage(""The Royal crossbow seems unresponsive against this target."", true) else { var stacks = player.tempAttribs.getI(""rcbStacks"", 0) if (World.getServerTicks() < player.tempAttribs.getL(""rcbLockOnTimer"")) stacks++ else { stacks = 1 player.sendMessage(""Your crossbow loses focus on your target."") } if (stacks == 9) player.sendMessage(""Your crossbow locks onto your target."") val lockedOn = stacks >= 9 player.tempAttribs.setI(""rcbStacks"", stacks) player.tempAttribs.setL(""rcbLockOnTimer"", World.getServerTicks() + 28) val hit = calculateHit(player, target, weaponId, attackStyle, true) delayHit(target, p.taskDelay, weaponId, attackStyle, hit, null, { if (weaponId == 24339 || target.isDead || target.hasFinished()) return@delayHit val maxHit = getMaxHit(player, target, weaponId, attackStyle, true, 1.0) val minBleed = (maxHit * (if (lockedOn) 0.25 else 0.20)).toInt() val maxBleed = (minBleed * 0.70).toInt() target.tasks.schedule(14) { delayHit(target, 0, weaponId, attackStyle, Hit.range(player, Utils.random(minBleed, maxBleed))) } target.tasks.schedule(28) { delayHit(target, 0, weaponId, attackStyle, Hit.range(player, Utils.random(minBleed, maxBleed))) } }, null) checkSwiftGlovesEffect(player, p.taskDelay, attackStyle, weaponId, hit, p) } dropAmmo(player, target, Equipment.AMMO, 1) } RangedWeapon.HAND_CANNON -> { if (Utils.getRandomInclusive(player.skills.getLevel(Constants.FIREMAKING) shl 1) == 0) { player.sync(12175, 2140) player.equipment.deleteSlot(Equipment.WEAPON) player.appearance.generateAppearanceData() player.applyHit(Hit(player, Utils.getRandomInclusive(150) + 10, HitLook.TRUE_DAMAGE)) return combatDelay } delayHit(target, p.taskDelay, weaponId, attackStyle, calculateHit(player, target, weaponId, attackStyle, true)) dropAmmo(player, target, Equipment.AMMO, 1) } RangedWeapon.SAGAIE -> { val damageMod = Utils.clampD((Utils.getDistanceI(player.tile, target.middleTile) / getAttackRange(player).toDouble()) * 0.70, 0.01, 1.0) val hit = calculateHit(player, target, weaponId, attackStyle, true, true, 1.0 - (damageMod * 0.95), 1.0 + damageMod) delayHit(target, p.taskDelay, weaponId, attackStyle, hit) checkSwiftGlovesEffect(player, p.taskDelay, attackStyle, weaponId, hit, p) dropAmmo(player, target, Equipment.WEAPON, 1) } RangedWeapon.BOLAS -> { var delay = Ticks.fromSeconds(15) if (target is Player) { val t = target var slashBased = t.equipment.getItem(3) != null val slash = t.combatDefinitions.getBonus(Bonus.SLASH_ATT) for (i in Bonus.STAB_ATT.ordinal..Bonus.RANGE_ATT.ordinal) if (t.combatDefinitions.getBonus(Bonus.entries[i]) > slash) { slashBased = false break } if (t.inventory.containsItem(946, 1) || slashBased) delay /= 2 if (t.prayer.isProtectingRange) delay /= 2 if (delay < Ticks.fromSeconds(5)) delay = Ticks.fromSeconds(5) } if (calculateHit(player, target, weaponId, attackStyle, true).damage > 0) { target.freeze(delay, true) target.tasks.schedule(2) { target.spotAnim(469, 0, 96) } } player.soundEffect(target, soundId, true) player.equipment.removeAmmo(Equipment.WEAPON, 1) } RangedWeapon.DARK_BOW -> { val hit = calculateHit(player, target, weaponId, attackStyle, true) delayHit(target, p.taskDelay, weaponId, attackStyle, hit) checkSwiftGlovesEffect(player, p.taskDelay, attackStyle, weaponId, hit, p) val p2 = World.sendProjectile(player, target, AmmoType.forId(player.equipment.ammoId)!!.getProjAnim(player.equipment.ammoId), 30, 50, 1.0) delayHit(target, p2.taskDelay, weaponId, attackStyle, calculateHit(player, target, weaponId, attackStyle, true)) dropAmmo(player, target, Equipment.AMMO, 2) } else -> { if (weapon.isThrown) { val hit = calculateHit(player, target, weaponId, attackStyle, true) delayHit(target, p.taskDelay, weaponId, attackStyle, hit) checkSwiftGlovesEffect(player, p.taskDelay, attackStyle, weaponId, hit, p) dropAmmo(player, target, Equipment.WEAPON, 1) } else { val hit = calculateHit(player, target, weaponId, attackStyle, true) delayHit(target, p.taskDelay, weaponId, attackStyle, hit) checkSwiftGlovesEffect(player, p.taskDelay, attackStyle, weaponId, hit, p) if (weapon.ammos != null) dropAmmo(player, target) } } } player.anim(weaponConfig.getAttackAnim(attackStyle.index)) val attackSpotAnim = weapon.getAttackSpotAnim(player, ammo) if (attackSpotAnim != null) player.spotAnim(attackSpotAnim) player.soundEffect(target, soundId, true) return combatDelay } private fun checkSwiftGlovesEffect(player: Player, hitDelay: Int, attackStyle: AttackStyle?, weaponId: Int, hit: Hit, p: WorldProjectile) { val gloves = player.equipment.getItem(Equipment.HANDS) if (gloves == null || !gloves.definitions.getName().contains(""Swift glove"")) return if (hit.damage != 0 && hit.damage < ((hit.maxHit / 3) * 2) || Random().nextInt(3) != 0) return player.sendMessage(""You fired an extra shot."") World.sendProjectile(player, target, p.spotAnimId, p.startHeight - 5, p.endHeight - 5, p.startTime, 2.0, if (p.angle - 5 < 0) 0 else p.angle - 5, p.slope) delayHit(target, hitDelay, weaponId, attackStyle, calculateHit(player, target, weaponId, attackStyle, true)) if (hit.damage > (hit.maxHit - 10)) { target.freeze(Ticks.fromSeconds(10), false) target.spotAnim(181, 0, 96) } } @Suppress(""unused"") private fun getRangeHitDelay(player: Player): Int { return if (Utils.getDistance(player.x, player.y, target.x, target.y) >= 5) 2 else 1 } private fun meleeAttack(player: Player): Int { if (player.hasEffect(Effect.FREEZE) && target.size == 1) { val dir = Direction.forDelta(target.x - player.x, target.y - player.y) if (dir != null) when (dir) { Direction.NORTH, Direction.SOUTH, Direction.EAST, Direction.WEST -> {} else -> return 0 } } var weaponId = player.equipment.weaponId val attackStyle = player.combatDefinitions.getAttackStyle() val weaponConfig = ItemConfig.get(weaponId) val combatDelay = getMeleeCombatDelay(weaponId) val soundId = weaponConfig.getAttackSound(attackStyle!!.index) if (weaponId == -1) { val gloves = player.equipment.getItem(Equipment.HANDS) if (gloves != null && gloves.definitions.getName().contains(""Goliath gloves"")) weaponId = -2 } if (player.combatDefinitions.isUsingSpecialAttack) return execute(SpecialAttack.Type.MELEE, player, target) val hit = calculateHit(player, target, weaponId, attackStyle, false) if (weaponId == -2 && hit.damage <= 0) { if (Utils.random(10) == 0) { player.anim(14417) attackTarget(getMultiAttackTargets(player, target, 6, Int.MAX_VALUE, true)) { nextTarget -> nextTarget.freeze(Ticks.fromSeconds(10), true) nextTarget.spotAnim(181, 0, 96) nextTarget.tasks.schedule(1) { nextTarget.applyHit(calculateHit(player, nextTarget, -2, attackStyle, false, false, 1.0, 1.0).setLook(HitLook.TRUE_DAMAGE)) } for (skill in Skills.COMBAT) nextTarget.lowerStat(skill, 7, 0.0) if (nextTarget is Player) nextTarget.sendMessage(""Your stats have been drained!"") return@attackTarget true } return combatDelay } } delayNormalHit(target, weaponId, attackStyle, hit) player.anim(getWeaponAttackEmote(weaponId, attackStyle)) player.soundEffect(target, soundId, true) return combatDelay } override fun stop(player: Player) { player.setNextFaceEntity(null) player.interactionManager.forceStop() player.actionManager.forceStop() player.tempAttribs.removeO(""combatTarget"") } fun checkAll(player: Player): Boolean { if (target.isDead) return false if (!player.canAttackMulti(target) || !target.canAttackMulti(player)) return false if (target is Player) { if (!player.isCanPvp || !target.isCanPvp) return false } else { val n = target as NPC? if (n!!.isCantInteract) return false if (n is Familiar) { if (!n.canAttack(target)) return false } else if (isAttackExeption(player, n)) return false } if (player.hasEffect(Effect.STAFF_OF_LIGHT_SPEC) && !(player.equipment.weaponId == 15486 || player.equipment.weaponId == 22207 || player.equipment.weaponId == 22209 || player.equipment.weaponId == 22211 || player.equipment.weaponId == 22213)) player.removeEffect(Effect.STAFF_OF_LIGHT_SPEC) player.tempAttribs.setO(""last_target"", target) target.tempAttribs.setO(""last_attacker"", player) return true } private fun isAttackExeption(player: Player, n: NPC?): Boolean { return !n!!.canBeAttackedBy(player) } } fun attackTarget(targets: Array, perform: (Entity) -> Boolean) { for (target in targets) { if (!perform(target)) break } } fun addAttackedByDelay(player: Entity, target: Entity) { target.attackedBy = player target.setAttackedByDelay(System.currentTimeMillis() + 8000) // 8seconds } fun getRangeCombatDelay(weaponId: Int, attackStyle: AttackStyle?): Int { var delay = ItemConfig.get(weaponId).attackDelay if (attackStyle!!.attackType == AttackType.RAPID) delay-- else if (attackStyle.attackType == AttackType.LONG_RANGE) delay++ return delay - 1 } fun getMultiAttackTargets(player: Player, target: Entity): Array { return getMultiAttackTargets(player, target, 1, 9) } fun getMultiAttackTargets(player: Player, tile: Tile?, maxDistance: Int, maxAmtTargets: Int): Array { val possibleTargets: MutableList = ArrayList() if (!player.isAtMultiArea) { val target = player.tempAttribs.getO(""last_target"") if (target != null && !target.isDead && !target.hasFinished() && target.withinDistance(tile, maxDistance) && (target !is NPC || target.definitions.hasAttackOption())) possibleTargets.add(target) return possibleTargets.toTypedArray() } for (p2 in player.queryNearbyPlayersByTileRange(maxDistance) { p2: Player -> p2 !== player && !p2.isDead && p2.isCanPvp && p2.isAtMultiArea && p2.withinDistance(tile, maxDistance) && player.controllerManager.canHit(p2) }) { possibleTargets.add(p2) if (possibleTargets.size >= maxAmtTargets) break } if (possibleTargets.size < maxAmtTargets) { for (n in player.queryNearbyNPCsByTileRange(maxDistance) { n: NPC -> n !== player.familiar && !n.isDead && n.definitions.hasAttackOption() && n.isAtMultiArea && n.withinDistance(tile, maxDistance) && player.controllerManager.canHit(n) }) { possibleTargets.add(n) if (possibleTargets.size >= maxAmtTargets) break } } return possibleTargets.toTypedArray() } fun getMultiAttackTargets(player: Player, target: Entity, maxDistance: Int, maxAmtTargets: Int): Array { return getMultiAttackTargets(player, target, maxDistance, maxAmtTargets, true) } fun getMultiAttackTargets(player: Player, target: Entity, maxDistance: Int, maxAmtTargets: Int, includeOriginalTarget: Boolean): Array { val possibleTargets: MutableList = ArrayList() if (!target.isAtMultiArea) return possibleTargets.toTypedArray() for (p2 in target.queryNearbyPlayersByTileRange(maxDistance) { p2: Player -> p2 !== player && !p2.isDead && p2.isCanPvp && p2.isAtMultiArea && p2.withinDistance(target.tile, maxDistance) && player.controllerManager.canHit(p2) }) { possibleTargets.add(p2) if (possibleTargets.size >= maxAmtTargets) break } if (possibleTargets.size < maxAmtTargets) { for (n in target.queryNearbyNPCsByTileRange(maxDistance) { n: NPC -> n !== player.familiar && !n.isDead && n.definitions.hasAttackOption() && n.isAtMultiArea && n.withinDistance(target.tile, maxDistance) && player.controllerManager.canHit(n) }) { possibleTargets.add(n) if (possibleTargets.size >= maxAmtTargets) break } } if (!includeOriginalTarget) possibleTargets.remove(target) return possibleTargets.toTypedArray() } fun getRangeCombatDelay(player: Player): Int { return getRangeCombatDelay(player.equipment.weaponId, player.combatDefinitions.getAttackStyle()) } @JvmOverloads fun dropAmmo(player: Player, target: Entity, slot: Int = Equipment.AMMO, quantity: Int = 1) { if (player.equipment.getItem(slot) == null) return val ammoId = player.equipment.getItem(slot).id when (ammoId) { 15243, 25202, 10033, 10034, 19152, 19157, 19162, 10142, 10143, 10144, 10145 -> { player.equipment.removeAmmo(slot, quantity) //delete 100% of the time return } } when (player.equipment.capeId) { 10498 -> { if (Utils.random(3) != 0) return } 10499, 20068, 20769, 20771, 14641, 14642 -> { if (Utils.random(9) != 0) return } } player.equipment.removeAmmo(slot, quantity) if (Utils.random(5) == 0) //1/5 chance to just break the ammo entirely return World.addGroundItem(Item(ammoId, quantity), Tile.of(target.getCoordFaceX(target.size), target.getCoordFaceY(target.size), target.plane), player) } @JvmOverloads fun calculateMagicHit(player: Player, target: Entity, baseDamage: Int, applyMageLevelBoost: Boolean = true): Hit { val hit = getMagicMaxHit(player, target, baseDamage, applyMageLevelBoost) hit.setDamage(Utils.random(1, hit.damage)) if (hit.damage > 0) if (target is NPC) if (target.id == 9463 && hasFireCape(player)) hit.setDamage(hit.damage + 40) return hit } fun getMagicMaxHit(player: Player, target: Entity, spellBaseDamage: Int, applyMageLevelBoost: Boolean): Hit { var lvl = floor(player.skills.getLevel(Constants.MAGIC) * player.prayer.mageMultiplier) lvl += 8.0 if (fullVoidEquipped(player, 11663, 11674)) lvl *= 1.3 lvl *= player.auraManager.magicAcc val atkBonus = player.combatDefinitions.getBonus(Bonus.MAGIC_ATT).toDouble() var atk = floor(lvl * (atkBonus + 64)) var maxHit = spellBaseDamage if (player.hasSlayerTask()) if (target is NPC && player.slayer.isOnTaskAgainst(target as NPC?)) if (player.equipment.wearingHexcrest() || player.equipment.wearingSlayerHelmet()) atk *= 1.15 val def: Double if (target is Player) { var defLvl = floor(target.skills.getLevel(Constants.DEFENSE) * target.prayer.defenceMultiplier) defLvl += (if (target.combatDefinitions.getAttackStyle()!!.attackType == AttackType.LONG_RANGE || target.combatDefinitions.getAttackStyle()!!.xpType == XPType.DEFENSIVE) 3 else if (target.combatDefinitions.getAttackStyle()!!.xpType == XPType.CONTROLLED) 1 else 0).toDouble() defLvl += 8.0 defLvl *= 0.3 var magLvl = floor(target.skills.getLevel(Constants.MAGIC) * target.prayer.mageMultiplier) magLvl *= 0.7 val totalDefLvl = defLvl + magLvl val defBonus = target.combatDefinitions.getBonus(Bonus.MAGIC_DEF).toDouble() def = floor(totalDefLvl * (defBonus + 64)) } else { val n = target as NPC? if (n!!.name.startsWith(""Vyre"")) if (player.equipment.weaponId == 21580) { atk *= 1.5 maxHit = (maxHit * 1.5).toInt() } else maxHit = 0 if (n.name == ""Turoth"" || n.name == ""Kurask"") if (player.equipment.weaponId != 4170) maxHit = 0 var defLvl = n.magicLevel.toDouble() val defBonus = n.definitions.magicDef.toDouble() defLvl += 8.0 def = floor(defLvl * (defBonus + 64)) } val prob = if (atk > def) (1 - (def + 2) / (2 * (atk + 1))) else (atk / (2 * (def + 1))) if (Settings.getConfig().isDebug && player.nsv.getB(""hitChance"")) player.sendMessage(""Your hit chance: "" + Utils.formatDouble(prob * 100.0) + ""%"") if (prob <= Math.random()) return Hit(player, 0, HitLook.MAGIC_DAMAGE) if (applyMageLevelBoost) { val boostedMageLevelBonus = 1 + ((player.skills.getLevel(Constants.MAGIC) - player.skills.getLevelForXp(Constants.MAGIC)) * 0.03) if (boostedMageLevelBonus > 1) maxHit = (maxHit * boostedMageLevelBonus).toInt() } maxHit = (maxHit * getMagicBonusBoost(player)).toInt() if (player.tempAttribs.getO(""spellcasterProc"") != null) { if (spellBaseDamage > 60) { maxHit = (maxHit * 1.25).toInt() target.lowerStat(Skills.ATTACK, 0.1, 0.9) target.lowerStat(Skills.STRENGTH, 0.1, 0.9) target.lowerStat(Skills.DEFENSE, 0.1, 0.9) if (target is Player) target.sendMessage(""Your melee skills have been drained."") player.sendMessage(""Your spell weakened your enemy."") player.sendMessage(""Your magic surged with extra power."") } } if (player.hasSlayerTask()) if (target is NPC && player.slayer.isOnTaskAgainst(target as NPC?)) if (player.equipment.wearingHexcrest() || player.equipment.wearingSlayerHelmet()) maxHit = (maxHit * 1.15).toInt() val finalMaxHit = maxHit.toDouble().toInt() if (Settings.getConfig().isDebug && player.nsv.getB(""hitChance"")) player.sendMessage(""Your max hit: $finalMaxHit"") return Hit(player, finalMaxHit, HitLook.MAGIC_DAMAGE).setMaxHit(finalMaxHit) } fun getMagicBonusBoost(player: Player): Double { return player.combatDefinitions.getBonus(Bonus.MAGIC_STR) / 100.0 + 1.0 } @JvmOverloads fun calculateHit(player: Player, target: Entity?, weaponId: Int, attackStyle: AttackStyle?, ranging: Boolean, calcDefense: Boolean = true, accuracyModifier: Double = 1.0, damageModifier: Double = 1.0): Hit { return calculateHit(player, target, 1, getMaxHit(player, target, weaponId, attackStyle, ranging, damageModifier), weaponId, attackStyle, ranging, calcDefense, accuracyModifier) } fun calculateHit(player: Player, target: Entity?, ranging: Boolean, calcDefense: Boolean, accuracyModifier: Double, damageModifier: Double): Hit { return calculateHit(player, target, 1, getMaxHit(player, target, player.equipment.weaponId, player.combatDefinitions.getAttackStyle(), ranging, damageModifier), player.equipment.weaponId, player.combatDefinitions.getAttackStyle(), ranging, calcDefense, accuracyModifier) } fun calculateHit(player: Player, target: Entity?, ranging: Boolean): Hit { return calculateHit(player, target, player.equipment.weaponId, player.combatDefinitions.getAttackStyle(), ranging, true, 1.0, 1.0) } fun calculateHit(player: Player, target: Entity?, minHit: Int, maxHit: Int, ranging: Boolean, calcDefense: Boolean, accuracyModifier: Double): Hit { return calculateHit(player, target, minHit, maxHit, player.equipment.weaponId, player.combatDefinitions.getAttackStyle(), ranging, calcDefense, accuracyModifier) } fun calculateHit(player: Player, target: Entity?, minHit: Int, maxHit: Int, weaponId: Int, attackStyle: AttackStyle?, ranging: Boolean, calcDefense: Boolean, accuracyModifier: Double): Hit { var finalMaxHit = maxHit val hit = Hit(player, 0, if (ranging) HitLook.RANGE_DAMAGE else HitLook.MELEE_DAMAGE) var veracsProc = false if (calcDefense) { var atkLvl = floor(player.skills.getLevel(if (ranging) Constants.RANGE else Constants.ATTACK) * (if (ranging) player.prayer.rangeMultiplier else player.prayer.attackMultiplier)) atkLvl += (if (attackStyle!!.attackType == AttackType.ACCURATE || attackStyle.xpType == XPType.ACCURATE) 3 else if (attackStyle.xpType == XPType.CONTROLLED) 1 else 0).toDouble() atkLvl += 8.0 if (fullVoidEquipped(player, *if (ranging) (intArrayOf(11664, 11675)) else (intArrayOf(11665, 11676)))) atkLvl *= 1.1 if (ranging) atkLvl *= player.auraManager.rangeAcc var atkBonus = player.combatDefinitions.attackBonusForStyle.toDouble() if (weaponId == -2) //goliath gloves atkBonus += 82.0 var atk = floor(atkLvl * (atkBonus + 64)) atk *= accuracyModifier if (!ranging && attackStyle.xpType == XPType.ACCURATE && player.dungManager.activePerk == KinshipPerk.TACTICIAN && player.controllerManager.isIn(DungeonController::class.java)) atk = floor(atk * 1.1 + (player.dungManager.getKinshipTier(KinshipPerk.TACTICIAN) * 0.01)) if (player.hasSlayerTask()) if (target is NPC) if (player.slayer.isOnTaskAgainst(target as NPC?)) if (ranging) { if (player.equipment.wearingFocusSight() || player.equipment.wearingSlayerHelmet()) { atk *= (7.0 / 6.0) finalMaxHit = (finalMaxHit * (7.0 / 6.0)).toInt() } } else { if (player.equipment.wearingBlackMask() || player.equipment.wearingSlayerHelmet()) { atk *= (7.0 / 6.0) finalMaxHit = (finalMaxHit * (7.0 / 6.0)).toInt() } if (player.equipment.salveAmulet != -1 && target.definitions.isUndead) when (player.equipment.salveAmulet) { 0 -> { atk *= 1.15 finalMaxHit = (finalMaxHit * 1.15).toInt() } 1 -> { atk *= 1.20 finalMaxHit = (finalMaxHit * 1.20).toInt() } } } var def: Double if (target is Player) { var defLvl = floor(target.skills.getLevel(Constants.DEFENSE) * target.prayer.defenceMultiplier) defLvl += (if (target.combatDefinitions.getAttackStyle()!!.attackType == AttackType.LONG_RANGE || target.combatDefinitions.getAttackStyle()!!.xpType == XPType.DEFENSIVE) 3 else if (target.combatDefinitions.getAttackStyle()!!.xpType == XPType.CONTROLLED) 1 else 0).toDouble() defLvl += 8.0 val defBonus = target.combatDefinitions.getDefenseBonusForStyle(player.combatDefinitions.getAttackStyle()!!).toDouble() def = floor(defLvl * (defBonus + 64)) if (!ranging) if (target.familiarPouch === Pouch.STEEL_TITAN) def *= 1.15 } else { val wId = player.equipment.weaponId val n = target as NPC? if (wId == 15836 || wId == 17295 || wId == 21332) { val mageLvl = Utils.clampI(n!!.magicLevel, 0, 350) val atkMul = (140.0 + floor((3 * mageLvl.toDouble() - 10.0) / 100.0) - floor((0.3 * mageLvl.toDouble() - 100.0).pow(2.0) / 100.0)) / 100.0 atk *= Utils.clampD(atkMul, 1.0, 3.0) val strMul = (250.0 + floor((3 * mageLvl.toDouble() - 14.0) / 100.0) - floor((0.3 * mageLvl.toDouble() - 140.0).pow(2.0) / 100.0)) / 100.0 finalMaxHit = (finalMaxHit * Utils.clampD(strMul, 1.0, 3.0)).toInt() } if (n!!.name.startsWith(""Vyre"")) { if (wId == 21581 || wId == 21582) { atk *= 2.0 finalMaxHit *= 2 } else if (!(wId == 6746 || wId == 2961 || wId == 2963 || wId == 2952 || wId == 2402 || (wId >= 7639 && wId <= 7648) || (wId >= 13117 && wId <= 13146))) finalMaxHit = 0 } if (n.name == ""Turoth"" || n.name == ""Kurask"") { if (!(wId == 4158 || wId == 13290) && !(player.equipment.weaponName.contains(""bow"") && ItemDefinitions.getDefs(player.equipment.ammoId).name.lowercase(Locale.getDefault()).contains(""broad""))) finalMaxHit = 0 } val weapon = RangedWeapon.forId(weaponId) val ammo = AmmoType.forId(player.equipment.ammoId) if (ranging && weapon != null && weapon.ammos != null && weapon.ammos!!.contains(ammo)) { when (ammo) { AmmoType.DRAGONBANE_ARROW, AmmoType.DRAGONBANE_BOLT -> { if (n.name.lowercase(Locale.getDefault()).contains(""dragon"")) { atk *= 1.6 finalMaxHit = (finalMaxHit * 1.6).toInt() } } AmmoType.ABYSSALBANE_ARROW, AmmoType.ABYSSALBANE_BOLT -> { if (n.name.lowercase(Locale.getDefault()).contains(""abyssal"")) { atk *= 1.6 finalMaxHit = (finalMaxHit * 1.6).toInt() } } AmmoType.BASILISKBANE_ARROW, AmmoType.BASILISKBANE_BOLT -> { if (n.name.lowercase(Locale.getDefault()).contains(""basilisk"")) { atk *= 1.6 finalMaxHit = (finalMaxHit * 1.6).toInt() } } AmmoType.WALLASALKIBANE_ARROW, AmmoType.WALLASALKIBANE_BOLT -> { if (n.name.lowercase(Locale.getDefault()).contains(""wallasalki"")) { atk *= 1.6 finalMaxHit = (finalMaxHit * 1.6).toInt() } } else -> {} } } var defLvl = n.defenseLevel.toDouble() val defBonus = player.combatDefinitions.getAttackStyle()!!.attackType.getDefenseBonus(n).toDouble() defLvl += 8.0 def = floor(defLvl * (defBonus + 64)) } if (finalMaxHit != 0 && fullVeracsEquipped(player) && Utils.random(4) == 0) veracsProc = true val prob = if (atk > def) (1 - (def + 2) / (2 * (atk + 1))) else (atk / (2 * (def + 1))) if (Settings.getConfig().isDebug && player.nsv.getB(""hitChance"")) player.sendMessage(""Your hit chance: "" + Utils.formatDouble(prob * 100.0) + ""%"") if (prob <= Math.random() && !veracsProc) return hit.setDamage(0) } if (Settings.getConfig().isDebug && player.nsv.getB(""hitChance"")) player.sendMessage(""Modified max hit: $finalMaxHit"") var finalHit = Utils.random(minHit, finalMaxHit) if (veracsProc) finalHit = (finalHit + 1.0).toInt() if (target is NPC) if (target.id == 9463 && hasFireCape(player)) finalHit += 40 if (player.auraManager.isActivated(Aura.EQUILIBRIUM)) { val perc25MaxHit = (finalMaxHit * 0.25).toInt() finalHit -= perc25MaxHit finalMaxHit -= perc25MaxHit if (finalHit < 0) finalHit = 0 if (finalHit < perc25MaxHit) finalHit += perc25MaxHit } hit.setMaxHit(finalMaxHit) hit.setDamage(finalHit) return hit } fun getMaxHit(player: Player, target: Entity?, ranging: Boolean, damageMultiplier: Double): Int { return getMaxHit(player, target, player.equipment.weaponId, player.combatDefinitions.getAttackStyle(), ranging, damageMultiplier) } fun getMaxHit(player: Player, target: Entity?, weaponId: Int, attackStyle: AttackStyle?, ranging: Boolean, damageMultiplier: Double): Int { if (ranging) { if (target != null && weaponId == 24338 && target is Player) { player.sendMessage(""The royal crossbow feels weak and unresponsive against other players."") return 60 } var lvl = floor(player.skills.getLevel(Constants.RANGE) * player.prayer.rangeMultiplier) lvl += (if (attackStyle!!.attackType == AttackType.ACCURATE) 3 else 0).toDouble() lvl += 8.0 if (fullVoidEquipped(player, 11664, 11675)) lvl = floor(lvl * 1.1) if (attackStyle.attackType == AttackType.RAPID && player.dungManager.activePerk == KinshipPerk.DESPERADO && player.controllerManager.isIn(DungeonController::class.java)) lvl = floor(lvl * 1.1 + (player.dungManager.getKinshipTier(KinshipPerk.DESPERADO) * 0.01)) val str = player.combatDefinitions.getBonus(Bonus.RANGE_STR).toDouble() val baseDamage = 5 + lvl * (str + 64) / 64 val maxHit = floor(baseDamage * damageMultiplier).toInt() if (Settings.getConfig().isDebug && player.nsv.getB(""hitChance"")) player.sendMessage(""Your max hit: $maxHit"") return maxHit } var lvl = floor(player.skills.getLevel(Constants.STRENGTH) * player.prayer.strengthMultiplier) lvl += (if (attackStyle!!.xpType == XPType.AGGRESSIVE) 3 else if (attackStyle.xpType == XPType.CONTROLLED) 1 else 0).toDouble() lvl += 8.0 if (fullVoidEquipped(player, 11665, 11676)) lvl = floor(lvl * 1.1) if (attackStyle.xpType == XPType.AGGRESSIVE && player.dungManager.activePerk == KinshipPerk.BERSERKER && player.controllerManager.isIn(DungeonController::class.java)) lvl = floor(lvl * 1.1 + (player.dungManager.getKinshipTier(KinshipPerk.BERSERKER) * 0.01)) var str = player.combatDefinitions.getBonus(Bonus.MELEE_STR).toDouble() if (weaponId == -2) str += 82.0 var baseDamage = 5 + lvl * (str + 64) / 64 when (weaponId) { 6523, 6525, 6527, 6528 -> if (player.equipment.amuletId == 11128) baseDamage *= 1.2 4718, 4886, 4887, 4888, 4889 -> if (fullDharokEquipped(player)) { val mul = 1.0 + (player.maxHitpoints - player.hitpoints) / 1000.0 * (player.maxHitpoints / 1000.0) baseDamage *= mul } 10581, 10582, 10583, 10584 -> if (target != null && target is NPC) if (target.name.startsWith(""Kalphite"")) baseDamage *= if (Utils.random(51) == 0) 3.0 else 4.0 / 3.0 15403, 22405 -> if (target != null && target is NPC) if (target.name == ""Dagannoth"" || (target.name == ""Wallasalki"") || (target.name == ""Dagannoth Supreme"")) baseDamage *= 2.75 6746 -> if (target != null && target is NPC) if (target.name.lowercase(Locale.getDefault()).contains(""demon"")) baseDamage *= 1.6 else -> {} } //int multiplier = PluginManager.handle() val maxHit = floor(baseDamage * damageMultiplier).toInt() if (Settings.getConfig().isDebug && player.nsv.getB(""hitChance"")) player.sendMessage(""Your max hit: $maxHit"") return maxHit } fun hasFireCape(player: Player): Boolean { val capeId = player.equipment.capeId return capeId == 6570 || capeId == 20769 || capeId == 20771 } fun fullVeracsEquipped(player: Player): Boolean { val helmId = player.equipment.hatId val chestId = player.equipment.chestId val legsId = player.equipment.legsId val weaponId = player.equipment.weaponId if (helmId == -1 || chestId == -1 || legsId == -1 || weaponId == -1) return false return (ItemDefinitions.getDefs(helmId).getName().contains(""Verac's"") && ItemDefinitions.getDefs(chestId).getName().contains(""Verac's"") && ItemDefinitions.getDefs(legsId).getName().contains(""Verac's"") && ItemDefinitions.getDefs(weaponId).getName().contains(""Verac's"")) } fun fullDharokEquipped(player: Player): Boolean { val helmId = player.equipment.hatId val chestId = player.equipment.chestId val legsId = player.equipment.legsId val weaponId = player.equipment.weaponId if (helmId == -1 || chestId == -1 || legsId == -1 || weaponId == -1) return false return (ItemDefinitions.getDefs(helmId).getName().contains(""Dharok's"") && ItemDefinitions.getDefs(chestId).getName().contains(""Dharok's"") && ItemDefinitions.getDefs(legsId).getName().contains(""Dharok's"") && ItemDefinitions.getDefs(weaponId).getName().contains(""Dharok's"")) } fun fullVoidEquipped(player: Player, vararg helmid: Int): Boolean { var hasDeflector = player.equipment.shieldId == 19712 if (player.equipment.glovesId != 8842) { if (!hasDeflector) return false hasDeflector = false } val legsId = player.equipment.legsId val hasLegs = legsId != -1 && (legsId == 8840 || legsId == 19786 || legsId == 19788 || legsId == 19790) if (!hasLegs) { if (!hasDeflector) return false hasDeflector = false } val torsoId = player.equipment.chestId val hasTorso = torsoId != -1 && (torsoId == 8839 || torsoId == 10611 || torsoId == 19785 || torsoId == 19787 || torsoId == 19789) if (!hasTorso && !hasDeflector) return false val helmId = player.equipment.hatId if (helmId == -1) return false var hasHelm = false for (id in helmid) if (helmId == id) { hasHelm = true break } return hasHelm } fun delayNormalHit(target: Entity, hit: Hit) { delayNormalHit(target, if (hit.source is Player) (hit.source as Player).equipment.weaponId else -1, if (hit.source is Player) (hit.source as Player).combatDefinitions.getAttackStyle() else null, hit, null, null, null) } @JvmOverloads fun delayNormalHit(target: Entity, weaponId: Int, attackStyle: AttackStyle?, hit: Hit, afterDelay: Runnable? = null, hitSucc: Runnable? = null, hitFail: Runnable? = null) { delayHit(target, 0, weaponId, attackStyle, hit, afterDelay, hitSucc, hitFail) } fun delayMagicHit(target: Entity, delay: Int, hit: Hit, afterDelay: Runnable?, hitSucc: Runnable?, hitFail: Runnable?) { delayHit(target, delay, -1, null, hit, afterDelay, hitSucc, hitFail) } fun delayHit(target: Entity, delay: Int, hit: Hit) { delayHit(target, delay, if (hit.source is Player) (hit.source as Player).equipment.weaponId else -1, if (hit.source is Player) (hit.source as Player).combatDefinitions.getAttackStyle() else null, hit, null, null, null) } @JvmOverloads fun delayHit(target: Entity, delay: Int, weaponId: Int, attackStyle: AttackStyle?, hit: Hit, afterDelay: Runnable? = null, hitSucc: Runnable? = null, hitFail: Runnable? = null) { val player = hit.source as Player addAttackedByDelay(player, target) target.applyHit(hit, delay) { afterDelay?.run() target.setNextAnimationNoPriority(Animation(getDefenceEmote(target))) if (target is NPC) target.soundEffect(player, target.combatDefinitions.defendSound, true) if (target is Player) { target.closeInterfaces() if (!target.isLocked && target.combatDefinitions.isAutoRetaliate && !target.actionManager.hasSkillWorking() && target.interactionManager.interaction == null && !target.hasWalkSteps()) target.interactionManager.setInteraction(PlayerCombatInteraction(target, player)) } else { val n = target as NPC? if (!n!!.isUnderCombat || n.canBeAutoRetaliated()) n.target = player } } val damage = min(hit.damage.toDouble(), target.hitpoints.toDouble()).toInt() if (hit.maxHit > 0 && (damage >= hit.maxHit * 0.90) && (hit.look == HitLook.MAGIC_DAMAGE || hit.look == HitLook.RANGE_DAMAGE || hit.look == HitLook.MELEE_DAMAGE)) hit.setCriticalMark() if (damage > 0) { hitSucc?.run() } else hitFail?.run() addXp(player, target, attackStyle?.xpType, hit) checkPoison(target, weaponId, hit) } fun checkPoison(target: Entity, weaponId: Int, hit: Hit) { if (hit.look == HitLook.RANGE_DAMAGE || hit.look == HitLook.MELEE_DAMAGE) if (hit.damage > 0) if (hit.look == HitLook.RANGE_DAMAGE) { if (weaponId != -1) { val name = ItemDefinitions.getDefs(weaponId).getName() if (name.contains(""(p++)"")) { if (Utils.getRandomInclusive(8) == 0) target.poison.makePoisoned(48) } else if (name.contains(""(p+)"")) { if (Utils.getRandomInclusive(8) == 0) target.poison.makePoisoned(38) } else if (name.contains(""(p)"")) if (Utils.getRandomInclusive(8) == 0) target.poison.makePoisoned(28) } } else if (weaponId != -1) { val name = ItemDefinitions.getDefs(weaponId).getName() if (name.contains(""(p++)"")) { if (Utils.getRandomInclusive(8) == 0) target.poison.makePoisoned(68) } else if (name.contains(""(p+)"")) { if (Utils.getRandomInclusive(8) == 0) target.poison.makePoisoned(58) } else if (name.contains(""(p)"")) if (Utils.getRandomInclusive(8) == 0) target.poison.makePoisoned(48) } } fun addXpFamiliar(player: Player, target: Entity, xpType: XPType, hit: Hit) { if (hit.look != HitLook.MAGIC_DAMAGE && hit.look != HitLook.RANGE_DAMAGE && hit.look != HitLook.MELEE_DAMAGE) return val combatXp: Double val damage = Utils.clampI(hit.damage, 0, target.hitpoints) val hpXp = (damage / 7.5) if (hpXp > 0) player.skills.addXp(Constants.HITPOINTS, hpXp) when (xpType) { XPType.ACCURATE -> { combatXp = (damage / 2.5) player.skills.addXp(Constants.ATTACK, combatXp) } XPType.AGGRESSIVE -> { combatXp = (damage / 2.5) player.skills.addXp(Constants.STRENGTH, combatXp) } XPType.CONTROLLED -> { combatXp = (damage / 2.5) player.skills.addXp(Constants.ATTACK, combatXp / 3) player.skills.addXp(Constants.STRENGTH, combatXp / 3) player.skills.addXp(Constants.DEFENSE, combatXp / 3) } XPType.DEFENSIVE -> { combatXp = (damage / 2.5) player.skills.addXp(Constants.DEFENSE, combatXp) } XPType.MAGIC -> { combatXp = (damage / 2.5) if (combatXp > 0) player.skills.addXp(Constants.MAGIC, combatXp) } XPType.RANGED, XPType.RANGED_DEFENSIVE -> { combatXp = (damage / 2.5) if (xpType == XPType.RANGED_DEFENSIVE) { player.skills.addXp(Constants.RANGE, combatXp / 2) player.skills.addXp(Constants.DEFENSE, combatXp / 2) } else player.skills.addXp(Constants.RANGE, combatXp) } XPType.PRAYER -> { combatXp = (damage / 10.0) player.skills.addXp(Constants.PRAYER, combatXp) } } } fun addXp(player: Player, target: Entity, xpType: XPType?, hit: Hit) { var combatXp: Double val damage = Utils.clampI(hit.damage, 0, target.hitpoints) when (hit.look) { HitLook.MAGIC_DAMAGE -> { combatXp = (damage / 5.0) if (combatXp > 0) { if (player.combatDefinitions.isDefensiveCasting || (usingPolypore(player) && player.combatDefinitions.getAttackStyle()!!.attackType == AttackType.POLYPORE_LONGRANGE)) { val defenceXp = (damage / 7.5) if (defenceXp > 0.0) { combatXp -= defenceXp player.skills.addXp(Constants.DEFENSE, defenceXp) } } if (combatXp > 0.0) player.skills.addXp(Constants.MAGIC, combatXp) // double hpXp = (hit.getDamage() / 7.5); // if (hpXp > 0) // player.getSkills().addXp(Constants.HITPOINTS, hpXp); } } HitLook.MELEE_DAMAGE -> { combatXp = (damage / 2.5) when (xpType) { XPType.ACCURATE -> player.skills.addXp(Constants.ATTACK, combatXp) XPType.AGGRESSIVE -> player.skills.addXp(Constants.STRENGTH, combatXp) XPType.CONTROLLED -> { player.skills.addXp(Constants.ATTACK, combatXp / 3) player.skills.addXp(Constants.STRENGTH, combatXp / 3) player.skills.addXp(Constants.DEFENSE, combatXp / 3) } XPType.DEFENSIVE -> player.skills.addXp(Constants.DEFENSE, combatXp) else -> {} } } HitLook.RANGE_DAMAGE -> { combatXp = (damage / 2.5) if (xpType == XPType.RANGED_DEFENSIVE) { player.skills.addXp(Constants.RANGE, combatXp / 2) player.skills.addXp(Constants.DEFENSE, combatXp / 2) } else player.skills.addXp(Constants.RANGE, combatXp) } else -> {} } val hpXp = (damage / 7.5) if (hpXp > 0) player.skills.addXp(Constants.HITPOINTS, hpXp) } fun getWeaponAttackEmote(weaponId: Int, attackStyle: AttackStyle?): Int { if (weaponId == -1) return if (attackStyle!!.index == 1) 423 else 422 if (weaponId == -2) return if (attackStyle!!.index == 1) 14307 else 14393 return ItemConfig.get(weaponId).getAttackAnim(attackStyle!!.index) } fun getMeleeCombatDelay(weaponId: Int): Int { if (weaponId != -1) return ItemConfig.get(weaponId).attackDelay return 3 } fun isRanging(player: Player): Boolean { val weaponId = player.equipment.weaponId if (player.tempAttribs.getB(""dfsActive"") || (player.combatDefinitions.spell == null && usingPolypore(player))) return true if (weaponId == -1 && player.combatDefinitions.spell == null) return false return RangedWeapon.forId(weaponId) != null } fun isMeleeing(player: Player): Boolean { return !isRanging(player) && player.combatDefinitions.spell == null } fun getAttackRange(player: Player): Int { if (player.combatDefinitions.spell != null) return 10 if (isRanging(player)) { if (player.tempAttribs.getB(""dfsActive"")) return 8 var atkRange = ItemConfig.get(player.equipment.weaponId).attackRange if (player.combatDefinitions.getAttackStyle()!!.attackType == AttackType.LONG_RANGE) atkRange += 2 return Utils.clampI(atkRange, 0, 10) } return ItemConfig.get(player.equipment.weaponId).attackRange } fun chargeDragonfireShield(target: Entity) { if (target is Player) { val p = target val shield = p.equipment.shieldId if (shield == 11283 || shield == 11284) { if (shield == 11284) { p.equipment.replace(p.equipment.getItem(Equipment.SHIELD), Item(11283, 1).addMetaData(""dfsCharges"", 1)) p.appearance.generateAppearanceData() p.equipment.refresh(Equipment.SHIELD) } val dfs = p.equipment.getItem(Equipment.SHIELD) if (dfs != null) { val charges = dfs.getMetaDataI(""dfsCharges"") if (charges < 50) { p.equipment.getItem(Equipment.SHIELD).addMetaData(""dfsCharges"", charges + 1) p.sync(6695, 1164) p.sendMessage(""Your shield becomes a little stronger as it absorbs the dragonfire."", true) p.soundEffect(3740, true) p.combatDefinitions.refreshBonuses() } } } } } fun getDefenceEmote(target: Entity?): Int { if (target is NPC) return target.combatDefinitions.defenceEmote val p = target as Player? val shieldConfig = ItemConfig.get(p!!.equipment.shieldId) if (shieldConfig != null) { if (shieldConfig.defendAnim > 0) return shieldConfig.defendAnim } val weaponConfig = ItemConfig.get(p.equipment.weaponId) if (weaponConfig != null) { if (weaponConfig.defendAnim > 0) return weaponConfig.defendAnim } return 424 } fun getAntifireLevel(target: Entity?, prayerWorks: Boolean): Int { if (target !is Player) return 0 var protection = 0 if (target.hasEffect(Effect.SUPER_ANTIFIRE)) { target.sendMessage(""Your potion heavily protects you from the dragon's fire."", true) protection = 2 chargeDragonfireShield(target) return protection } val shieldId = target.equipment.shieldId if (shieldId == 1540 || shieldId == 11283 || shieldId == 11284 || shieldId == 16079 || shieldId == 16933) { protection++ target.sendMessage(""Your shield manages to block some of the dragon's breath."", true) } if (if (protection == 0 && prayerWorks) target.prayer.isProtectingMage else false) { target.sendMessage(""Your prayers help resist some of the dragonfire!"", true) protection++ } if (target.hasEffect(Effect.ANTIFIRE)) { target.sendMessage(""Your potion slightly protects you from the heat of the dragon's breath."", true) protection++ } if (protection > 2) protection = 2 if (protection == 0) target.sendMessage(""You are hit by the dragon's fiery breath."", true) chargeDragonfireShield(target) return protection }" "package com.rs.game.content.combat @ServerStartupEvent fun mapPolypore() { onItemClick(22494, 22496, 22497, options = arrayOf(""Check"", ""Clean"")) { e -> when (e.option) { ""Check"" -> { val charges = e.item.getMetaDataI(""polyporeCasts"") if (charges == -1) e.player.sendMessage(""It looks like its got about 3000 casts left."") else e.player.sendMessage(""It looks like its got about $charges casts left."") } ""Clean"" -> e.player.startConversation { simple(""WARNING: You will only be able to recover half of the spores and runes that went into charging the staff."") options(""Do you want to clean the staff?"") { opExec(""Yes, please."") { val staff = e.player.inventory.getItem(e.slotId) if (staff != null) { val toRecover = if (staff.id == 22494) 3000 else e.item.getMetaDataI(""polyporeCasts"") if (toRecover > 0) { staff.id = 22498 e.player.inventory.addItemDrop(Rune.FIRE.id(), (toRecover * 5) / 2) e.player.inventory.addItemDrop(Rune.CHAOS.id(), toRecover / 2) e.player.inventory.addItemDrop(22448, toRecover / 2) e.player.inventory.refresh(e.slotId) } } } op(""No, thanks."") } } } } onItemOnItem(intArrayOf(22448), intArrayOf(22496, 22497, 22498)) { e -> val stick = e.getUsedWith(22448) if (stick.id == 22498) { var canMake = true if (!e.player.inventory.containsItem(22448, 3000)) { e.player.sendMessage(""You need 3,000 polypore spores to create a polypore staff."") canMake = false } if (!e.player.inventory.containsItem(Rune.FIRE.id(), 15000)) { e.player.sendMessage(""You need 15,000 fire runes to create a polypore staff."") canMake = false } if (!e.player.inventory.containsItem(Rune.CHAOS.id(), 3000)) { e.player.sendMessage(""You need 3,000 chaos runes to create a polypore staff."") canMake = false } if (!canMake) return@onItemOnItem e.player.startConversation { simple(""To create a polypore staff you will need 3,000 polypore spores, 3,000 chaos runes and 15,000 fire runes."") options(""Are you sure you want to create the staff?"") { op(""Yes, please."") { item(22494, ""You plant the spores on the stick and they quickly grow with the power of the fire runes."") exec { val staff = e.player.inventory.getItem(stick.slot) if (staff != null) { e.player.sync(15434, 2032) staff.id = 22494 e.player.inventory.deleteItem(Rune.FIRE.id(), 15000) e.player.inventory.deleteItem(Rune.CHAOS.id(), 3000) e.player.inventory.deleteItem(22448, 3000) e.player.inventory.refresh(stick.slot) e.player.skills.addXp(Constants.FARMING, 300.0) } } } op(""No, thanks."") } } } else { val charges = stick.getMetaDataI(""polyporeCasts"") if (charges == -1 || charges >= 3000) { e.player.sendMessage(""This polypore staff is already full."") return@onItemOnItem } val canRecharge = 3000 - charges val maxRecharge = getMaxCharges(e.player, canRecharge) val newCharges = charges + maxRecharge if (maxRecharge <= 0) { e.player.sendMessage(""You need 1 polypore spore, 1 chaos rune, and 5 fire runes per charge."") return@onItemOnItem } e.player.sync(15434, 2032) if (newCharges == 3000) { stick.id = 22494 stick.deleteMetaData() e.player.inventory.refresh(stick.slot) } else stick.addMetaData(""polyporeCasts"", newCharges) e.player.inventory.deleteItem(Rune.FIRE.id(), maxRecharge * 5) e.player.inventory.deleteItem(Rune.CHAOS.id(), maxRecharge) e.player.inventory.deleteItem(22448, maxRecharge) e.player.skills.addXp(Constants.FARMING, maxRecharge * 0.1) e.player.sendMessage(""You charge the staff with $maxRecharge charges. It now has $newCharges"") } } } private fun getMaxCharges(player: Player, currCharges: Int): Int { var max = currCharges val numSpores = player.inventory.getNumberOf(22448) val numFires = player.inventory.getNumberOf(Rune.FIRE.id()) val numChaos = player.inventory.getNumberOf(Rune.CHAOS.id()) if (numSpores < max) max = numSpores if (numChaos < max) max = numChaos if (((numFires / 5.0).toInt()) < max) max = ((numFires / 5.0).toInt()) if (numChaos < max) max = numChaos return max } fun usingPolypore(player: Player): Boolean { val weaponId = player.equipment.weaponId return weaponId == 22494 || weaponId == 22496 || weaponId == 22497 } fun drainCharge(player: Player) { val staff = player.equipment.getItem(Equipment.WEAPON) ?: return if (staff.id == 22494) { staff.id = 22496 staff.addMetaData(""polyporeCasts"", 2999) player.equipment.refresh(Equipment.WEAPON) } else if (staff.id == 22496) { val charges = staff.getMetaDataI(""polyporeCasts"") if (charges <= 1) { staff.deleteMetaData() staff.id = 22498 player.equipment.refresh(Equipment.WEAPON) player.appearance.generateAppearanceData() player.sendMessage(""Your polypore staff has degraded back into a polypore stick!"") } else staff.addMetaData(""polyporeCasts"", charges - 1) } }" "package com.rs.game.content.combat enum class RangedWeapon { CROSSBOW(intArrayOf(767, 837, 11165, 11167), AmmoType.BRONZE_BOLTS), BRONZE_CROSSBOW(intArrayOf(9174), AmmoType.BRONZE_BOLTS), BLURITE_CROSSBOW(intArrayOf(9176), AmmoType.BRONZE_BOLTS, AmmoType.BLURITE_BOLTS), IRON_CROSSBOW( intArrayOf(9177), AmmoType.BRONZE_BOLTS, AmmoType.BLURITE_BOLTS, AmmoType.SILVER_BOLTS, AmmoType.IRON_BOLTS ), STEEL_CROSSBOW( intArrayOf(9179), AmmoType.BRONZE_BOLTS, AmmoType.BLURITE_BOLTS, AmmoType.SILVER_BOLTS, AmmoType.IRON_BOLTS, AmmoType.STEEL_BOLTS ), BLACK_CROSSBOW( intArrayOf(13081), AmmoType.BRONZE_BOLTS, AmmoType.BLURITE_BOLTS, AmmoType.SILVER_BOLTS, AmmoType.IRON_BOLTS, AmmoType.STEEL_BOLTS, AmmoType.BLACK_BOLTS ), MITH_CROSSBOW( intArrayOf(9181), AmmoType.BRONZE_BOLTS, AmmoType.BLURITE_BOLTS, AmmoType.SILVER_BOLTS, AmmoType.IRON_BOLTS, AmmoType.STEEL_BOLTS, AmmoType.BLACK_BOLTS, AmmoType.MITHRIL_BOLTS ), ADAMANT_CROSSBOW( intArrayOf(9183), AmmoType.BRONZE_BOLTS, AmmoType.BLURITE_BOLTS, AmmoType.SILVER_BOLTS, AmmoType.IRON_BOLTS, AmmoType.STEEL_BOLTS, AmmoType.BLACK_BOLTS, AmmoType.MITHRIL_BOLTS, AmmoType.ADAMANT_BOLTS ), RUNE_CROSSBOW( intArrayOf(9185, 13530), AmmoType.BRONZE_BOLTS, AmmoType.BLURITE_BOLTS, AmmoType.SILVER_BOLTS, AmmoType.IRON_BOLTS, AmmoType.STEEL_BOLTS, AmmoType.BLACK_BOLTS, AmmoType.MITHRIL_BOLTS, AmmoType.ADAMANT_BOLTS, AmmoType.RUNITE_BOLTS, AmmoType.BROAD_TIPPED_BOLTS, AmmoType.WALLASALKIBANE_BOLT, AmmoType.ABYSSALBANE_BOLT, AmmoType.BASILISKBANE_BOLT, AmmoType.DRAGONBANE_BOLT, AmmoType.BAKRIMINEL_BOLTS ), ARMADYL_CROSSBOW( intArrayOf(25037, 25039), AmmoType.BRONZE_BOLTS, AmmoType.BLURITE_BOLTS, AmmoType.SILVER_BOLTS, AmmoType.IRON_BOLTS, AmmoType.STEEL_BOLTS, AmmoType.BLACK_BOLTS, AmmoType.MITHRIL_BOLTS, AmmoType.ADAMANT_BOLTS, AmmoType.RUNITE_BOLTS, AmmoType.BROAD_TIPPED_BOLTS, AmmoType.WALLASALKIBANE_BOLT, AmmoType.ABYSSALBANE_BOLT, AmmoType.BASILISKBANE_BOLT, AmmoType.DRAGONBANE_BOLT, AmmoType.BAKRIMINEL_BOLTS ), CHAOTIC_CROSSBOW( intArrayOf(18357), AmmoType.BRONZE_BOLTS, AmmoType.BLURITE_BOLTS, AmmoType.SILVER_BOLTS, AmmoType.IRON_BOLTS, AmmoType.STEEL_BOLTS, AmmoType.BLACK_BOLTS, AmmoType.MITHRIL_BOLTS, AmmoType.ADAMANT_BOLTS, AmmoType.RUNITE_BOLTS, AmmoType.BROAD_TIPPED_BOLTS, AmmoType.WALLASALKIBANE_BOLT, AmmoType.ABYSSALBANE_BOLT, AmmoType.BASILISKBANE_BOLT, AmmoType.DRAGONBANE_BOLT, AmmoType.BAKRIMINEL_BOLTS ), CORAL_CROSSBOW(intArrayOf(24303), AmmoType.CORAL_BOLTS), ROYAL_CROSSBOW(intArrayOf(24338, 24339), AmmoType.ROYAL_BOLTS), DORGESHUUN_CBOW(intArrayOf(8880), AmmoType.BONE_BOLTS), ZANIKS_CROSSBOW( intArrayOf(14684), AmmoType.BONE_BOLTS, AmmoType.BRONZE_BOLTS, AmmoType.SILVER_BOLTS, AmmoType.BLURITE_BOLTS, AmmoType.IRON_BOLTS, AmmoType.STEEL_BOLTS, AmmoType.BLACK_BOLTS, AmmoType.MITHRIL_BOLTS, AmmoType.ADAMANT_BOLTS ), KARILS_CROSSBOW(intArrayOf(4734, 4934, 4935, 4936, 4937), AmmoType.BOLT_RACK), HUNTERS_CROSSBOW(intArrayOf(10156), AmmoType.KEBBIT_BOLTS, AmmoType.LONG_KEBBIT_BOLTS), DOMINION_CROSSBOW(intArrayOf(22348), 27, 955), SHORTBOW(intArrayOf(841, 23818), AmmoType.BRONZE_ARROW, AmmoType.IRON_ARROW), QUICK_BOW(intArrayOf(23043), AmmoType.BRONZE_ARROW, AmmoType.IRON_ARROW), LONGBOW(intArrayOf(839), AmmoType.BRONZE_ARROW, AmmoType.IRON_ARROW), OAK_SHORTBOW(intArrayOf(843), AmmoType.BRONZE_ARROW, AmmoType.IRON_ARROW, AmmoType.STEEL_ARROW), OAK_LONGBOW(intArrayOf(845, 4236), AmmoType.BRONZE_ARROW, AmmoType.IRON_ARROW, AmmoType.STEEL_ARROW), WILLOW_BOW( intArrayOf(849), AmmoType.BRONZE_ARROW, AmmoType.IRON_ARROW, AmmoType.STEEL_ARROW, AmmoType.MITHRIL_ARROW ), WILLOW_LONGBOW( intArrayOf(847), AmmoType.BRONZE_ARROW, AmmoType.IRON_ARROW, AmmoType.STEEL_ARROW, AmmoType.MITHRIL_ARROW ), WILLOW_COMP_BOW( intArrayOf(10280, 13541), AmmoType.BRONZE_ARROW, AmmoType.IRON_ARROW, AmmoType.STEEL_ARROW, AmmoType.MITHRIL_ARROW ), MAPLE_BOW( intArrayOf(853, 13524), AmmoType.BRONZE_ARROW, AmmoType.IRON_ARROW, AmmoType.STEEL_ARROW, AmmoType.MITHRIL_ARROW, AmmoType.ADAMANT_ARROW ), MAPLE_LONGBOW( intArrayOf(851, 13523, 18331), AmmoType.BRONZE_ARROW, AmmoType.IRON_ARROW, AmmoType.STEEL_ARROW, AmmoType.MITHRIL_ARROW, AmmoType.ADAMANT_ARROW ), YEW_BOW( intArrayOf(857, 13526), AmmoType.BRONZE_ARROW, AmmoType.IRON_ARROW, AmmoType.STEEL_ARROW, AmmoType.MITHRIL_ARROW, AmmoType.ADAMANT_ARROW, AmmoType.RUNE_ARROW, AmmoType.ICE_ARROWS ), YEW_LONGBOW( intArrayOf(855), AmmoType.BRONZE_ARROW, AmmoType.IRON_ARROW, AmmoType.STEEL_ARROW, AmmoType.MITHRIL_ARROW, AmmoType.ADAMANT_ARROW, AmmoType.RUNE_ARROW, AmmoType.ICE_ARROWS ), YEW_COMP_BOW( intArrayOf(10282, 13542), AmmoType.BRONZE_ARROW, AmmoType.IRON_ARROW, AmmoType.STEEL_ARROW, AmmoType.MITHRIL_ARROW, AmmoType.ADAMANT_ARROW, AmmoType.RUNE_ARROW, AmmoType.ICE_ARROWS ), MAGIC_BOW( intArrayOf(861, 13528), AmmoType.BRONZE_ARROW, AmmoType.IRON_ARROW, AmmoType.STEEL_ARROW, AmmoType.MITHRIL_ARROW, AmmoType.ADAMANT_ARROW, AmmoType.RUNE_ARROW, AmmoType.BROAD_ARROW, AmmoType.WALLASALKIBANE_ARROW, AmmoType.ABYSSALBANE_ARROW, AmmoType.BASILISKBANE_ARROW, AmmoType.DRAGONBANE_ARROW, AmmoType.SARADOMIN_ARROWS, AmmoType.GUTHIX_ARROWS, AmmoType.ZAMORAK_ARROWS, AmmoType.ICE_ARROWS ), MAGIC_LONGBOW( intArrayOf(859, 13543, 13527, 18332), AmmoType.BRONZE_ARROW, AmmoType.IRON_ARROW, AmmoType.STEEL_ARROW, AmmoType.MITHRIL_ARROW, AmmoType.ADAMANT_ARROW, AmmoType.RUNE_ARROW, AmmoType.BROAD_ARROW, AmmoType.WALLASALKIBANE_ARROW, AmmoType.ABYSSALBANE_ARROW, AmmoType.BASILISKBANE_ARROW, AmmoType.DRAGONBANE_ARROW, AmmoType.SARADOMIN_ARROWS, AmmoType.GUTHIX_ARROWS, AmmoType.ZAMORAK_ARROWS, AmmoType.ICE_ARROWS ), MAGIC_COMP_BOW( intArrayOf(10284, 13543), AmmoType.BRONZE_ARROW, AmmoType.IRON_ARROW, AmmoType.STEEL_ARROW, AmmoType.MITHRIL_ARROW, AmmoType.ADAMANT_ARROW, AmmoType.RUNE_ARROW, AmmoType.BROAD_ARROW, AmmoType.WALLASALKIBANE_ARROW, AmmoType.ABYSSALBANE_ARROW, AmmoType.BASILISKBANE_ARROW, AmmoType.DRAGONBANE_ARROW, AmmoType.SARADOMIN_ARROWS, AmmoType.GUTHIX_ARROWS, AmmoType.ZAMORAK_ARROWS, AmmoType.ICE_ARROWS ), DARK_BOW( intArrayOf(11235, 13405, 15701, 15702, 15703, 15704), AmmoType.BRONZE_ARROW, AmmoType.IRON_ARROW, AmmoType.STEEL_ARROW, AmmoType.MITHRIL_ARROW, AmmoType.ADAMANT_ARROW, AmmoType.RUNE_ARROW, AmmoType.DRAGON_ARROW, AmmoType.WALLASALKIBANE_ARROW, AmmoType.ABYSSALBANE_ARROW, AmmoType.BASILISKBANE_ARROW, AmmoType.DRAGONBANE_ARROW, AmmoType.SARADOMIN_ARROWS, AmmoType.GUTHIX_ARROWS, AmmoType.ZAMORAK_ARROWS, AmmoType.ICE_ARROWS ), SACRED_CLAY_BOW( intArrayOf(14121), AmmoType.BRONZE_ARROW, AmmoType.IRON_ARROW, AmmoType.STEEL_ARROW, AmmoType.MITHRIL_ARROW, AmmoType.ADAMANT_ARROW, AmmoType.RUNE_ARROW, AmmoType.BROAD_ARROW, AmmoType.WALLASALKIBANE_ARROW, AmmoType.ABYSSALBANE_ARROW, AmmoType.BASILISKBANE_ARROW, AmmoType.DRAGONBANE_ARROW, AmmoType.SARADOMIN_ARROWS, AmmoType.GUTHIX_ARROWS, AmmoType.ZAMORAK_ARROWS, AmmoType.ICE_ARROWS ), GRAVITE_SHORTBOW( intArrayOf(18373), AmmoType.BRONZE_ARROW, AmmoType.IRON_ARROW, AmmoType.STEEL_ARROW, AmmoType.MITHRIL_ARROW, AmmoType.ADAMANT_ARROW, AmmoType.RUNE_ARROW, AmmoType.BROAD_ARROW, AmmoType.ICE_ARROWS ), TRAINING_BOW(intArrayOf(9705), AmmoType.TRAINING_ARROWS), SEERCULL( intArrayOf(6724, 13529), AmmoType.BRONZE_ARROW, AmmoType.IRON_ARROW, AmmoType.STEEL_ARROW, AmmoType.MITHRIL_ARROW, AmmoType.ADAMANT_ARROW, AmmoType.RUNE_ARROW, AmmoType.BROAD_ARROW, AmmoType.WALLASALKIBANE_ARROW, AmmoType.ABYSSALBANE_ARROW, AmmoType.BASILISKBANE_ARROW, AmmoType.DRAGONBANE_ARROW, AmmoType.SARADOMIN_ARROWS, AmmoType.GUTHIX_ARROWS, AmmoType.ZAMORAK_ARROWS, AmmoType.ICE_ARROWS ), OGRE_BOW( intArrayOf(2883), AmmoType.OGRE_ARROW, AmmoType.BRONZE_BRUTAL, AmmoType.IRON_BRUTAL, AmmoType.STEEL_BRUTAL, AmmoType.BLACK_BRUTAL, AmmoType.MITHRIL_BRUTAL, AmmoType.ADAMANT_BRUTAL, AmmoType.RUNE_BRUTAL ), COMP_OGRE_BOW( intArrayOf(4827), AmmoType.BRONZE_BRUTAL, AmmoType.IRON_BRUTAL, AmmoType.STEEL_BRUTAL, AmmoType.BLACK_BRUTAL, AmmoType.MITHRIL_BRUTAL, AmmoType.ADAMANT_BRUTAL, AmmoType.RUNE_BRUTAL ), SARADOMIN_BOW(intArrayOf(19143, 19145), AmmoType.SARADOMIN_ARROWS, AmmoType.GUTHIX_ARROWS, AmmoType.ZAMORAK_ARROWS), GUTHIX_BOW(intArrayOf(19146, 19148), AmmoType.SARADOMIN_ARROWS, AmmoType.GUTHIX_ARROWS, AmmoType.ZAMORAK_ARROWS), ZAMORAK_BOW(intArrayOf(19149, 19151), AmmoType.SARADOMIN_ARROWS, AmmoType.GUTHIX_ARROWS, AmmoType.ZAMORAK_ARROWS), DECIMATION(intArrayOf(24456), 1066, 2962), //3191 spec gfx BOOGIE_BOW(intArrayOf(24474), 3196, 3195), CRYSTAL_BOW(intArrayOf(4212, 4214, 4215, 4216, 4217, 4218, 4219, 4220, 4221, 4222, 4223), 249, 250), SLING(intArrayOf(19830, 15597), 32, -1), ZARYTE_BOW(intArrayOf(20171, 20173), 1066, 2962), BRONZE_THROWNAXE(true, intArrayOf(800), 36), IRON_THROWNAXE(true, intArrayOf(801), 35), STEEL_THROWNAXE(true, intArrayOf(802), 37), MITHRIL_THROWNAXE(true, intArrayOf(803), 38), ADAMANT_THROWNAXE(true, intArrayOf(804), 39), RUNE_THROWNAXE(true, intArrayOf(805), 41), BRONZE_DART(true, intArrayOf(806, 812, 5628, 5635), 226, 232), IRON_DART(true, intArrayOf(807, 813, 5629, 5636), 227, 233), STEEL_DART(true, intArrayOf(808, 814, 5630, 5637), 228, 234), BLACK_DART(true, intArrayOf(3093, 3094, 5631, 5638), 34, 273), MITHRIL_DART(true, intArrayOf(809, 815, 5632, 5639), 229, 235), ADAMANT_DART(true, intArrayOf(810, 816, 5633, 5640), 230, 236), RUNE_DART(true, intArrayOf(811, 817, 5634, 5641), 231, 237), DRAGON_DART(true, intArrayOf(11230, 11231, 11233, 11234), 1122, 1123), BLISTERWOOD_STAKE(true, intArrayOf(21581), 732), DEATHTOUCHED_DART(true, intArrayOf(25202), 1122, 1123), BRONZE_JAVELIN(true, intArrayOf(825, 831, 5642, 5648), 200), IRON_JAVELIN(true, intArrayOf(826, 832, 5643, 5649), 201), STEEL_JAVELIN(true, intArrayOf(827, 833, 5644, 5650), 202), MITHRIL_JAVELIN(true, intArrayOf(828, 834, 5645, 5651), 203), ADAMANT_JAVELIN(true, intArrayOf(829, 835, 5646, 5652), 204), RUNE_JAVELIN(true, intArrayOf(830, 836, 5647, 5653), 205), BRONZE_KNIFE(true, intArrayOf(864, 870, 5654, 5661), 212), IRON_KNIFE(true, intArrayOf(863, 871, 5655, 5662), 213), STEEL_KNIFE(true, intArrayOf(865, 872, 5656, 5663), 214), BLACK_KNIFE(true, intArrayOf(869, 5658, 5665), 215), MITHRIL_KNIFE(true, intArrayOf(866, 873, 5657, 5664), 216), ADAMANT_KNIFE(true, intArrayOf(867, 875, 5659, 5666), 217), RUNE_KNIFE(true, intArrayOf(868, 876, 5660, 5667), 218), HOLY_WATER(true, intArrayOf(732), 192, 193), //52/53 white holy water? TOKTZ_XIL_UL(true, intArrayOf(6522), 442), CHINCHOMPA(true, intArrayOf(10033), 908), RED_CHINCHOMPA(true, intArrayOf(10034), 909), SAGAIE(true, intArrayOf(21364), 466), BOLAS(true, intArrayOf(21365), 468), HAND_CANNON(intArrayOf(15241), AmmoType.HAND_CANNON_SHOT), SWAMP_LIZARD(intArrayOf(10149), AmmoType.GUAM_TAR), ORANGE_SALAMANDER(intArrayOf(10146), AmmoType.MARRENTILL_TAR), RED_SALAMANDER(intArrayOf(10147), AmmoType.TARROMIN_TAR), BLACK_SALAMANDER(intArrayOf(10148), AmmoType.HARRALANDER_TAR), PERFORMANCE_SHORTBOW(intArrayOf(13719), AmmoType.PERFORMANCE_ARROW), PERFORMANCE_KNIFE(true, intArrayOf(13720), 212), PERFORMANCE_THROWING_AXE(true, intArrayOf(13721), 36), MORRIGANS_JAVELIN(true, intArrayOf(13879, 13880, 13881, 13882, 13953, 13954, 13955, 13956), 1837), MORRIGANS_THROWING_AXE(true, intArrayOf(13883, 13957), 1839), BOW_CLASS_1(intArrayOf(14192), AmmoType.ARROWS_CLASS_1), BOW_CLASS_2(intArrayOf(14194), AmmoType.ARROWS_CLASS_1, AmmoType.ARROWS_CLASS_2), BOW_CLASS_3(intArrayOf(14196), AmmoType.ARROWS_CLASS_1, AmmoType.ARROWS_CLASS_2, AmmoType.ARROWS_CLASS_3), BOW_CLASS_4( intArrayOf(14198), AmmoType.ARROWS_CLASS_1, AmmoType.ARROWS_CLASS_2, AmmoType.ARROWS_CLASS_3, AmmoType.ARROWS_CLASS_4 ), BOW_CLASS_5( intArrayOf(14200), AmmoType.ARROWS_CLASS_1, AmmoType.ARROWS_CLASS_2, AmmoType.ARROWS_CLASS_3, AmmoType.ARROWS_CLASS_4, AmmoType.ARROWS_CLASS_5 ), TANGLE_GUM_SHORTBOW(intArrayOf(15775, 16867), AmmoType.NOVITE_ARROWS), TANGLE_GUM_LONGBOW(intArrayOf(15903, 16317), AmmoType.NOVITE_ARROWS), SEEPING_ELM_SHORTBOW(intArrayOf(15776, 16869), AmmoType.NOVITE_ARROWS, AmmoType.BATHUS_ARROWS), SEEPING_ELM_LONGBOW(intArrayOf(15904, 16319), AmmoType.NOVITE_ARROWS, AmmoType.BATHUS_ARROWS), BLOOD_SPINDLE_SHORTBOW( intArrayOf(15777, 16871), AmmoType.NOVITE_ARROWS, AmmoType.BATHUS_ARROWS, AmmoType.MARMAROS_ARROWS ), BLOOD_SPINDLE_LONGBOW( intArrayOf(15905, 16321), AmmoType.NOVITE_ARROWS, AmmoType.BATHUS_ARROWS, AmmoType.MARMAROS_ARROWS ), UTUKU_SHORTBOW( intArrayOf(15778, 16873), AmmoType.NOVITE_ARROWS, AmmoType.BATHUS_ARROWS, AmmoType.MARMAROS_ARROWS, AmmoType.KRATONITE_ARROWS ), UTUKU_LONGBOW( intArrayOf(15906, 16323), AmmoType.NOVITE_ARROWS, AmmoType.BATHUS_ARROWS, AmmoType.MARMAROS_ARROWS, AmmoType.KRATONITE_ARROWS ), SPINEBEAM_SHORTBOW( intArrayOf(15779, 16875), AmmoType.NOVITE_ARROWS, AmmoType.BATHUS_ARROWS, AmmoType.MARMAROS_ARROWS, AmmoType.KRATONITE_ARROWS, AmmoType.FRACTITE_ARROWS ), SPINEBEAM_LONGBOW( intArrayOf(15907, 16325), AmmoType.NOVITE_ARROWS, AmmoType.BATHUS_ARROWS, AmmoType.MARMAROS_ARROWS, AmmoType.KRATONITE_ARROWS, AmmoType.FRACTITE_ARROWS ), BOVISTRANGLER_SHORTBOW( intArrayOf(15780, 16877), AmmoType.NOVITE_ARROWS, AmmoType.BATHUS_ARROWS, AmmoType.MARMAROS_ARROWS, AmmoType.KRATONITE_ARROWS, AmmoType.FRACTITE_ARROWS, AmmoType.ZEPHYRIUM_ARROWS ), BOVISTRANGLER_LONGBOW( intArrayOf(15908, 16327), AmmoType.NOVITE_ARROWS, AmmoType.BATHUS_ARROWS, AmmoType.MARMAROS_ARROWS, AmmoType.KRATONITE_ARROWS, AmmoType.FRACTITE_ARROWS, AmmoType.ZEPHYRIUM_ARROWS ), THIGAT_SHORTBOW( intArrayOf(15781, 16879), AmmoType.NOVITE_ARROWS, AmmoType.BATHUS_ARROWS, AmmoType.MARMAROS_ARROWS, AmmoType.KRATONITE_ARROWS, AmmoType.FRACTITE_ARROWS, AmmoType.ZEPHYRIUM_ARROWS, AmmoType.ARGONITE_ARROWS ), THIGAT_LONGBOW( intArrayOf(15909, 16329), AmmoType.NOVITE_ARROWS, AmmoType.BATHUS_ARROWS, AmmoType.MARMAROS_ARROWS, AmmoType.KRATONITE_ARROWS, AmmoType.FRACTITE_ARROWS, AmmoType.ZEPHYRIUM_ARROWS, AmmoType.ARGONITE_ARROWS ), CORPSETHORN_SHORTBOW( intArrayOf(15782, 16881), AmmoType.NOVITE_ARROWS, AmmoType.BATHUS_ARROWS, AmmoType.MARMAROS_ARROWS, AmmoType.KRATONITE_ARROWS, AmmoType.FRACTITE_ARROWS, AmmoType.ZEPHYRIUM_ARROWS, AmmoType.ARGONITE_ARROWS, AmmoType.KATAGON_ARROWS ), CORPSETHORN_LONGBOW( intArrayOf(15910, 16331), AmmoType.NOVITE_ARROWS, AmmoType.BATHUS_ARROWS, AmmoType.MARMAROS_ARROWS, AmmoType.KRATONITE_ARROWS, AmmoType.FRACTITE_ARROWS, AmmoType.ZEPHYRIUM_ARROWS, AmmoType.ARGONITE_ARROWS, AmmoType.KATAGON_ARROWS ), ENTGALLOW_SHORTBOW( intArrayOf(15783, 16883), AmmoType.NOVITE_ARROWS, AmmoType.BATHUS_ARROWS, AmmoType.MARMAROS_ARROWS, AmmoType.KRATONITE_ARROWS, AmmoType.FRACTITE_ARROWS, AmmoType.ZEPHYRIUM_ARROWS, AmmoType.ARGONITE_ARROWS, AmmoType.KATAGON_ARROWS, AmmoType.GORGONITE_ARROWS ), ENTGALLOW_LONGBOW( intArrayOf(15911, 16333), AmmoType.NOVITE_ARROWS, AmmoType.BATHUS_ARROWS, AmmoType.MARMAROS_ARROWS, AmmoType.KRATONITE_ARROWS, AmmoType.FRACTITE_ARROWS, AmmoType.ZEPHYRIUM_ARROWS, AmmoType.ARGONITE_ARROWS, AmmoType.KATAGON_ARROWS, AmmoType.GORGONITE_ARROWS ), GRAVE_CREEPER_SHORTBOW( intArrayOf(15784, 16885), AmmoType.NOVITE_ARROWS, AmmoType.BATHUS_ARROWS, AmmoType.MARMAROS_ARROWS, AmmoType.KRATONITE_ARROWS, AmmoType.FRACTITE_ARROWS, AmmoType.ZEPHYRIUM_ARROWS, AmmoType.ARGONITE_ARROWS, AmmoType.KATAGON_ARROWS, AmmoType.GORGONITE_ARROWS, AmmoType.PROMETHIUM_ARROWS ), GRAVE_CREEPER_LONGBOW( intArrayOf(15912, 16335), AmmoType.NOVITE_ARROWS, AmmoType.BATHUS_ARROWS, AmmoType.MARMAROS_ARROWS, AmmoType.KRATONITE_ARROWS, AmmoType.FRACTITE_ARROWS, AmmoType.ZEPHYRIUM_ARROWS, AmmoType.ARGONITE_ARROWS, AmmoType.KATAGON_ARROWS, AmmoType.GORGONITE_ARROWS, AmmoType.PROMETHIUM_ARROWS ), SAGITTARIAN_SHORTBOW( intArrayOf(15785, 16887), AmmoType.NOVITE_ARROWS, AmmoType.BATHUS_ARROWS, AmmoType.MARMAROS_ARROWS, AmmoType.KRATONITE_ARROWS, AmmoType.FRACTITE_ARROWS, AmmoType.ZEPHYRIUM_ARROWS, AmmoType.ARGONITE_ARROWS, AmmoType.KATAGON_ARROWS, AmmoType.GORGONITE_ARROWS, AmmoType.PROMETHIUM_ARROWS, AmmoType.SAGITTARIAN_ARROWS ), SAGITTARIAN_LONGBOW( intArrayOf(15913, 16337), AmmoType.NOVITE_ARROWS, AmmoType.BATHUS_ARROWS, AmmoType.MARMAROS_ARROWS, AmmoType.KRATONITE_ARROWS, AmmoType.FRACTITE_ARROWS, AmmoType.ZEPHYRIUM_ARROWS, AmmoType.ARGONITE_ARROWS, AmmoType.KATAGON_ARROWS, AmmoType.GORGONITE_ARROWS, AmmoType.PROMETHIUM_ARROWS, AmmoType.SAGITTARIAN_ARROWS ), HEXHUNTER_BOW( intArrayOf(15836, 17295), AmmoType.NOVITE_ARROWS, AmmoType.BATHUS_ARROWS, AmmoType.MARMAROS_ARROWS, AmmoType.KRATONITE_ARROWS, AmmoType.FRACTITE_ARROWS, AmmoType.ZEPHYRIUM_ARROWS, AmmoType.ARGONITE_ARROWS, AmmoType.KATAGON_ARROWS, AmmoType.GORGONITE_ARROWS, AmmoType.PROMETHIUM_ARROWS, AmmoType.SAGITTARIAN_ARROWS ), OZANS_LONGBOW(intArrayOf(20859), AmmoType.OZANS_KRATONITE_ARROWS); var ammos: Set? = null private set var isThrown: Boolean = false private set val ids: IntArray private val projAnim: Int private val drawbackSpotAnim: Int constructor(thrown: Boolean, itemIds: IntArray, projAnim: Int, drawbackSpotAnim: Int = -1) { this.isThrown = thrown this.ids = itemIds this.projAnim = projAnim this.drawbackSpotAnim = drawbackSpotAnim } constructor(itemIds: IntArray, projAnim: Int, drawbackSpotAnim: Int) { this.ids = itemIds this.projAnim = projAnim this.drawbackSpotAnim = drawbackSpotAnim } constructor(itemIds: IntArray, vararg ammos: AmmoType) : this(false, itemIds, -1, -1) { this.ammos = HashSet(listOf(*ammos)) } fun properAmmo(player: Player, print: Boolean): Boolean { if (isThrown || ammos == null) return true val ammo = AmmoType.forId(player.equipment.ammoId) if (ammo == null) { if (print) player.sendMessage(""You have no ammo in your quiver!"") return false } if (!ammos!!.contains(ammo)) { if (print) player.sendMessage(""You cannot use that ammo with this weapon."") return false } return true } fun getAttackSpotAnim(player: Player, ammo: AmmoType?): SpotAnim? { when (this) { DARK_BOW -> { return SpotAnim(ammo!!.getDoubleDrawbackSpotAnim(player.equipment.ammoId), 0, 100) } HAND_CANNON -> { return SpotAnim(ammo!!.getDrawbackSpotAnim(player.equipment.ammoId)) } else -> { if (isThrown || ammos == null) return SpotAnim(drawbackSpotAnim, 0, 100) if (ammo != null) return SpotAnim(ammo.getDrawbackSpotAnim(player.equipment.ammoId), 0, 100) } } return null } fun getProjectile(player: Player, target: Entity?, attackSpeed: Int): WorldProjectile { val speed = 8.0 / (attackSpeed.toDouble()) when (this) { SLING -> return World.sendProjectile(player, target, projAnim, 20, 30, speed) else -> { if (isThrown) return World.sendProjectile(player, target, projAnim, 20, 5 + (attackSpeed * 5), speed) if (ammos == null) return World.sendProjectile(player, target, projAnim, 20, 35, speed) val ammo = AmmoType.forId(player.equipment.ammoId)!! return World.sendProjectile(player, target, ammo.getProjAnim(player.equipment.ammoId), 20, 40, speed) } } } companion object { private val MAP: Map = entries .flatMap { entry -> entry.ids.map { id -> id to entry } } .toMap() @JvmStatic fun forId(itemId: Int): RangedWeapon? = MAP[itemId] } }" "package com.rs.game.content.combat enum class XPType { ACCURATE, AGGRESSIVE, DEFENSIVE, CONTROLLED, RANGED, RANGED_DEFENSIVE, MAGIC, PRAYER }" "package com.rs.game.content.combat.special_attacks @ServerStartupEvent fun handleDFSSpec() { onItemClick(""Dragonfire shield"", options = arrayOf(""Inspect"", ""Activate"", ""Empty"")) { e -> when (e.option) { ""Inspect"" -> { if (e.item.id == 11284) e.player.sendMessage(""The shield is empty and unresponsive."") else e.player.sendMessage(""The shield contains "" + e.item.getMetaDataI(""dfsCharges"") + "" charges."") } ""Activate"" -> { if (e.item.getMetaDataI(""dfsCharges"") > 0) { if (World.getServerTicks() > e.player.tempAttribs.getL(""dfsCd"")) { e.player.tempAttribs.setB(""dfsActive"", !e.player.tempAttribs.getB(""dfsActive"")) e.player.sendMessage(""You have "" + (if (e.player.tempAttribs.getB(""dfsActive"")) ""activated"" else ""deactivated"") + "" the shield."") } else e.player.sendMessage(""The dragonfire shield is still pretty hot from its last activation."") } else e.player.sendMessage(""The shield is empty and unable to be activated."") } ""Empty"" -> { if (e.item.id == 11284 || e.item.getMetaDataI(""dfsCharges"") < 0) e.player.sendMessage(""The shield is already empty."") else e.player.sendOptionDialogue(""Are you sure you would like to empty the "" + e.item.getMetaDataI(""dfsCharges"") + "" charges?"") { ops -> ops.add(""Yes, I understand the shield will lose all its stats."") { e.item.deleteMetaData() e.item.id = 11284 e.player.inventory.refresh() } ops.add(""No, I want to keep them."") } } } } }" "package com.rs.game.content.combat.special_attacks class SpecialAttack(val energyCost: Int, val type: Type? = null, val execute: BiFunction? = null, val instant: Consumer? = null) { enum class Type { MELEE, RANGE, MAGIC } constructor(type: Type?, energyCost: Int, execute: BiFunction) : this(energyCost, type, execute) constructor(energyCost: Int, instant: Consumer) : this(energyCost, null, null, instant) }" "package com.rs.game.content.combat.special_attacks private val specialAttacks: MutableMap = HashMap() @ServerStartupEvent fun mapSpecials() { fun Entity.isValidCombatTarget(player: Player): Boolean { return isAtMultiArea || player.isAtMultiArea || player.attackedBy !== this && player.inCombat() || this.attackedBy !== player && inCombat() } fun Entity.isInvalidMeleeTarget(player: Player): Boolean { return isDead || hasFinished() || !isValidCombatTarget(player) || !player.inMeleeRange(this) } /** * Instant Specials */ //Granite maul/Granite mace addSpec(intArrayOf(4153, 13445, 14681, 14679), SpecialAttack(50) { player -> val target = player.interactionManager.interaction.let { interaction -> if (interaction is PlayerCombatInteraction) interaction.action.target else player.tempAttribs.getO(""last_target"") } if (target.isInvalidMeleeTarget(player)) return@SpecialAttack player.resetWalkSteps() if (player.interactionManager.interaction !is PlayerCombatInteraction || (player.interactionManager.interaction as PlayerCombatInteraction).action.target !== target) { player.interactionManager.setInteraction(PlayerCombatInteraction(player, target)) } player.combatDefinitions.drainSpec(50) val animId = if (player.equipment.weaponId == 4153) 1667 else 10505 player.anim(animId) if (player.equipment.weaponId == 4153) player.spotAnim(340, 0, 96 shl 16) delayNormalHit(target, calculateHit(player, target, false, true, 1.0, 1.0)) player.soundEffect(target, 2715, true) return@SpecialAttack }) //Dragon battleaxe addSpec(intArrayOf(1377, 13472), SpecialAttack(100) { player -> player.sync(1056, 246) player.forceTalk(""Raarrrrrgggggghhhhhhh!"") player.skills.adjustStat(0, -0.1, Skills.ATTACK, Skills.DEFENSE, Skills.RANGE, Skills.MAGIC) player.skills.adjustStat(0, 0.2, Skills.STRENGTH) player.combatDefinitions.drainSpec(100) player.soundEffect(2538, true) }) //Excalibur addSpec(intArrayOf(35, 8280, 14632), SpecialAttack(100) { player -> player.sync(1168, 247) player.forceTalk(""For Camelot!"") val enhanced = player.equipment.weaponId == 14632 player.skills.adjustStat(if (enhanced) 0 else 8, if (enhanced) 0.15 else 0.0, Skills.DEFENSE) player.addEffect(Effect.EXCALIBUR_HEAL, (if (enhanced) 70 else 35).toLong()) player.combatDefinitions.drainSpec(100) player.soundEffect(2539, true) }) //Staff of light addSpec(intArrayOf(15486, 15502, 22207, 22208, 22209, 22210, 22211, 22212, 22213, 22214), SpecialAttack(100) { player -> player.sync(12804, 2319) player.spotAnim(2321) player.addEffect(Effect.STAFF_OF_LIGHT_SPEC, Ticks.fromSeconds(60).toLong()) player.combatDefinitions.drainSpec(100) }) /** * MAGIC WEAPONS */ //Mindspike addSpec(intArrayOf(23044, 23045, 23046, 23047), SpecialAttack(SpecialAttack.Type.MAGIC, 75) { player, target -> delayMagicHit(target, CombatSpell.WIND_RUSH.cast(player, target), Hit.magic(player, 50).setMaxHit(50), { target.spotAnim(CombatSpell.WIND_RUSH.hitSpotAnim) }, null, null) return@SpecialAttack 3 }) //Obliteration addSpec(intArrayOf(24457), SpecialAttack(SpecialAttack.Type.MAGIC, 20) { player, target -> player.sync(16960, 3189) val p = World.sendProjectile(player, target, 3188, 15, 15, 15, 0.6, 0, 0) for (dir in Direction.entries) World.sendProjectile(Tile.of(target.x + (dir.dx * 7), target.y + (dir.dy * 7), target.plane), target, 3188, 15, 15, 15, 0.6, 0, 0) val hit = calculateMagicHit(player, target, 500, true) delayMagicHit(target, p.taskDelay, hit, { target.spotAnim(CombatSpell.WIND_RUSH.hitSpotAnim) }, null, null) return@SpecialAttack 7 }) /** * RANGED WEAPONS */ addSpec(RangedWeapon.QUICK_BOW.ids, SpecialAttack(SpecialAttack.Type.RANGE, 75) { player, target -> player.anim(1074) player.spotAnim(250, 10, 100) val p = World.sendProjectile(player, target, 249, 20, 50, 1.5) val p2 = World.sendProjectile(player, target, 249, 30, 50, 1.5) delayHit(target, p.taskDelay, Hit.range(player, 25).setMaxHit(25)) delayHit(target, p2.taskDelay, Hit.range(player, 25).setMaxHit(25)) return@SpecialAttack getRangeCombatDelay(player) }) addSpec(RangedWeapon.ZAMORAK_BOW.ids, SpecialAttack(SpecialAttack.Type.RANGE, 55) { player, target -> player.sync(426, 97) val p = World.sendProjectile(player, target, 100, 20, 50, 1.5) delayHit(target, p.taskDelay, calculateHit(player, target, true)) dropAmmo(player, target, Equipment.AMMO, 1) return@SpecialAttack getRangeCombatDelay(player) }) addSpec(RangedWeapon.GUTHIX_BOW.ids, SpecialAttack(SpecialAttack.Type.RANGE, 55) { player, target -> player.sync(426, 95) val p = World.sendProjectile(player, target, 98, 20, 50, 1.5) delayHit(target, p.taskDelay, calculateHit(player, target, true)) dropAmmo(player, target, Equipment.AMMO, 1) return@SpecialAttack getRangeCombatDelay(player) }) addSpec(RangedWeapon.SARADOMIN_BOW.ids, SpecialAttack(SpecialAttack.Type.RANGE, 55) { player, target -> player.sync(426, 96) val p = World.sendProjectile(player, target, 99, 20, 50, 1.5) delayHit(target, p.taskDelay, calculateHit(player, target, true)) dropAmmo(player, target, Equipment.AMMO, 1) return@SpecialAttack getRangeCombatDelay(player) }) addSpec(RangedWeapon.RUNE_THROWNAXE.ids, SpecialAttack(SpecialAttack.Type.RANGE, 20) { player, target -> //TODO test this heavily val maxHit = getMaxHit(player, target, true, 1.0) player.anim(9055) val projectile = World.sendProjectile(player, target, 258, 20, 50, 1.0) delayHit(target, projectile.taskDelay, calculateHit(player, target, 1, maxHit, true, true, 1.0)) player.schedule { wait(projectile.taskDelay + 1) var lastTarget = target for (i in 1..5) { val nextTarget = getMultiAttackTargets(player, lastTarget, 4, 10, false).closestOrNull(lastTarget.tile) ?: return@schedule wait(World.sendProjectile(lastTarget, nextTarget, 258, 20, 0, 1.0).taskDelay + 1) nextTarget.applyHit(calculateHit(player, nextTarget, 1, maxHit, true, true, 1.0)) lastTarget = nextTarget } } return@SpecialAttack getRangeCombatDelay(player) }) addSpec(Stream.of(RangedWeapon.MAGIC_BOW.ids, RangedWeapon.MAGIC_LONGBOW.ids, RangedWeapon.MAGIC_COMP_BOW.ids).flatMapToInt(Arrays::stream).toArray(), SpecialAttack(SpecialAttack.Type.RANGE, 55) { player, target -> player.anim(1074) player.spotAnim(250, 10, 100) delayHit(target, World.sendProjectile(player, target, 249, 20, 20, 2.0).taskDelay, calculateHit(player, target, true)) delayHit(target, World.sendProjectile(player, target, 249, 15, 50, 1.6).taskDelay, calculateHit(player, target, true)) dropAmmo(player, target, Equipment.AMMO, 2) player.soundEffect(target, 2545, true) return@SpecialAttack getRangeCombatDelay(player) }) addSpec(RangedWeapon.HAND_CANNON.ids, SpecialAttack(SpecialAttack.Type.RANGE, 50) { player, target -> player.sync(12175, 2138) delayHit(target, World.sendProjectile(player, target, 2143, 0, 50, 1.5).taskDelay, calculateHit(player, target, true)) return@SpecialAttack 1 }) addSpec(RangedWeapon.DORGESHUUN_CBOW.ids, SpecialAttack(SpecialAttack.Type.RANGE, 75) { player, target -> player.anim(ItemConfig.get(RangedWeapon.DORGESHUUN_CBOW.ids[0]).getAttackAnim(0)) RangedWeapon.DORGESHUUN_CBOW.getAttackSpotAnim(player, forId(player.equipment.ammoId)).let { player.spotAnim(it) } val hit = calculateHit(player, target, true, true, 1.0, 1.3) if (hit.damage > 0) target.lowerStat(Skills.DEFENSE, hit.damage / 10, 0.0) delayHit(target, World.sendProjectile(player, target, 698, 20, 50, 1.0).taskDelay, hit) dropAmmo(player, target, Equipment.AMMO, 1) player.soundEffect(target, 1080, true) return@SpecialAttack getRangeCombatDelay(player) }) addSpec(RangedWeapon.DARK_BOW.ids, SpecialAttack(SpecialAttack.Type.RANGE, 65) { player, target -> val ammoId = player.equipment.ammoId player.anim(ItemConfig.get(RangedWeapon.DARK_BOW.ids[0]).getAttackAnim(0)) RangedWeapon.DARK_BOW.getAttackSpotAnim(player, forId(player.equipment.ammoId)).let { player.spotAnim(it) } if (ammoId == 11212) { val hit1 = calculateHit(player, target, true, true, 1.0, 1.5) if (hit1.damage < 80) hit1.setDamage(80) val hit2 = calculateHit(player, target, true, true, 1.0, 1.5) if (hit2.damage < 80) hit2.setDamage(80) delayHit(target, World.sendProjectile(player, target, 1099, 20, 50, 1.0) { _ -> target.spotAnim(1100, 0, 100) }.taskDelay, hit1) delayHit(target, World.sendProjectile(player, target, 1099, 30, 50, 1.5) { _ -> target.spotAnim(1100, 0, 100) }.taskDelay, hit2) player.soundEffect(target, 3736, true) } else { val hit1 = calculateHit(player, target, true, true, 1.0, 1.3) if (hit1.damage < 50) hit1.setDamage(50) val hit2 = calculateHit(player, target, true, true, 1.0, 1.3) if (hit2.damage < 50) hit2.setDamage(50) delayHit(target, World.sendProjectile(player, target, 1101, 20, 50, 1.0).taskDelay, hit1) delayHit(target, World.sendProjectile(player, target, 1101, 30, 50, 1.5).taskDelay, hit2) player.soundEffect(target, 3737, true) } dropAmmo(player, target, Equipment.AMMO, 2) return@SpecialAttack getRangeCombatDelay(player) }) addSpec(RangedWeapon.ZANIKS_CROSSBOW.ids, SpecialAttack(SpecialAttack.Type.RANGE, 50) { player, target -> player.anim(ItemConfig.get(RangedWeapon.ZANIKS_CROSSBOW.ids[0]).getAttackAnim(0)) player.spotAnim(1714) delayHit(target, World.sendProjectile(player, target, 2001, 20, 50, 1.5).taskDelay, Hit.range(player, calculateHit(player, target, true, true, 1.0, 1.0).damage + 30 + Utils.getRandomInclusive(120))) dropAmmo(player, target) return@SpecialAttack getRangeCombatDelay(player) }) addSpec(RangedWeapon.MORRIGANS_JAVELIN.ids, SpecialAttack(SpecialAttack.Type.RANGE, 50) { player, target -> player.sync(10501, 1836) val hit = calculateHit(player, target, true, true, 1.0, 1.0) val proj = World.sendProjectile(player, target, 1837, 20, 50, 1.5) delayHit(target, proj.taskDelay, hit) if (hit.damage > 0) { target.schedule { var damage = hit.damage wait(proj.taskDelay + 2) while(damage > 0) { target.applyHit(Hit.flat(player, if (damage < 50) damage % 50 else 50)) wait(2) damage -= 50 } } } dropAmmo(player, target, Equipment.WEAPON, 1) return@SpecialAttack getRangeCombatDelay(player) }) addSpec(RangedWeapon.MORRIGANS_THROWING_AXE.ids, SpecialAttack(SpecialAttack.Type.RANGE, 50) { player, target -> player.sync(10504, 1838) delayHit(target, World.sendProjectile(player, target, 1839, 20, 50, 1.5).taskDelay, calculateHit(player, target, true, true, 1.0, 1.0)) dropAmmo(player, target, Equipment.WEAPON, 1) return@SpecialAttack getRangeCombatDelay(player) }) addSpec(RangedWeapon.SEERCULL.ids, SpecialAttack(SpecialAttack.Type.RANGE, 100) { player, target -> val hit = calculateHit(player, target, true, true, 1.0, 1.0) player.anim(ItemConfig.get(RangedWeapon.SEERCULL.ids[0]).getAttackAnim(0)) player.spotAnim(472, 0, 100) delayHit(target, World.sendProjectile(player, target, 473, 20, 50, 1.5) { _ -> target.spotAnim(474) }.taskDelay, hit) if (hit.damage > 0) target.lowerStat(Skills.MAGIC, hit.damage / 10, 0.0) dropAmmo(player, target) player.soundEffect(target, 2546, true) return@SpecialAttack getRangeCombatDelay(player) }) addSpec(RangedWeapon.DECIMATION.ids, SpecialAttack(SpecialAttack.Type.RANGE, 20) { player, target -> player.sync(16959, 3192) val p = World.sendProjectile(player, target, 3188, 20, 100, 0.6) { _ -> target.spotAnim(3191) } for (i in 0..3) delayHit(target, p.taskDelay, calculateHit(player, target, true, true, 1.0, 1.0)) return@SpecialAttack 6 }) /** * MELEE WEAPONS */ //Vine whip addSpec(intArrayOf(21371, 21372, 21373, 21374, 21375), SpecialAttack(SpecialAttack.Type.MELEE, 60) { player, target -> val attackStyle = player.combatDefinitions.getAttackStyle() val tile = Tile.of(target.tile) player.sync(11971, 476) player.schedule { for (i in 1..11) { World.sendSpotAnim(tile, SpotAnim(478)) for (entity in getMultiAttackTargets(player, tile, 1, 9)) { val hit = calculateHit(player, entity, 0, getMaxHit(player, target, 21371, attackStyle, false, 0.33), 21371, attackStyle, false, true, 1.25) addXp(player, entity, attackStyle!!.xpType, hit) if (hit.damage > 0 && Utils.getRandomInclusive(8) == 0) target.poison.makePoisoned(48) entity.applyHit(hit) } wait(5) } } return@SpecialAttack getMeleeCombatDelay(player.equipment.weaponId) }) //Abyssal whip addSpec(intArrayOf(4151, 13444, 15441, 15442, 15443, 15444, 23691), SpecialAttack(SpecialAttack.Type.MELEE, 50) { player, target -> player.anim(11971) target.spotAnim(2108, 0, 100) if (target is Player) target.runEnergy = if (target.runEnergy > 25.0) target.runEnergy - 25.0 else 0.0 delayNormalHit(target, calculateHit(player, target, false, true, 1.25, 1.0)) player.soundEffect(target, 2713, true) return@SpecialAttack getMeleeCombatDelay(player.equipment.getWeaponId()) }) //Saradomin sword addSpec(intArrayOf(11730, 13461, 23690), SpecialAttack(SpecialAttack.Type.MELEE, 100) { player, target -> player.sync(11993, 1194) delayNormalHit(target, Hit(player, 50 + Utils.getRandomInclusive(100), HitLook.MELEE_DAMAGE).setMaxHit(150)) delayNormalHit(target, calculateHit(player, target, false, true, 2.0, 1.1)) player.soundEffect(target, 3853, true) return@SpecialAttack getMeleeCombatDelay(player.equipment.weaponId) }) //Dragon spear/Zamorakian spear addSpec(intArrayOf(1249, 1263, 3176, 5716, 5730, 11716, 13454, 13770, 13772, 13774, 13776, 23683), SpecialAttack(SpecialAttack.Type.MELEE, 25) { player, target -> player.anim(12017) player.stopAll() target.spotAnim(80, 5, 60) if (!target.addWalkSteps(target.x - player.x + target.x, target.y - player.y + target.y, 1)) player.setNextFaceEntity(target) target.setNextFaceEntity(player) player.schedule { target.setNextFaceEntity(null) player.setNextFaceEntity(null) } if (target is Player) { target.lock() target.addFoodDelay(3000) target.setDisableEquip(true) target.schedule { wait(5) target.setDisableEquip(false) target.unlock() } } else if (target is NPC) { target.freeze(Ticks.fromSeconds(3), false) player.soundEffect(target, 2544, true) } return@SpecialAttack getMeleeCombatDelay(player.equipment.getWeaponId()); }) //Keenblade addSpec(intArrayOf(23042), SpecialAttack(SpecialAttack.Type.MELEE, 75) { player, target -> player.sync(16067, 2109) delayNormalHit(target, Hit(player, 50, HitLook.MELEE_DAMAGE).setMaxHit(50)) return@SpecialAttack getMeleeCombatDelay(player.equipment.weaponId) }) //Saradomin godsword addSpec(intArrayOf(11698, 13452, 23681), SpecialAttack(SpecialAttack.Type.MELEE, 50) { player, target -> player.sync(12019, 2109) val hit = calculateHit(player, target, false, true, 2.0, 1.1) player.heal(hit.damage / 2) player.prayer.restorePrayer(hit.damage.toDouble() / 4) delayNormalHit(target, hit) return@SpecialAttack getMeleeCombatDelay(player.equipment.weaponId) }) //Bandos godsword addSpec(intArrayOf(11696, 13451, 23680), SpecialAttack(SpecialAttack.Type.MELEE, 50) { player, target -> player.sync(11991, 2114) val hit = calculateHit(player, target, false, true, 2.0, 1.1) delayNormalHit(target, hit) var amountLeft = hit.damage / 10 val skillsToDrain = listOf(Constants.DEFENSE, Constants.STRENGTH, Constants.PRAYER, Constants.ATTACK, Constants.MAGIC, Constants.RANGE) for (skill in skillsToDrain) { amountLeft = target.lowerStat(skill, amountLeft, 0.0) if (amountLeft <= 0) break } return@SpecialAttack getMeleeCombatDelay(player.equipment.weaponId) }) //Ancient mace addSpec(intArrayOf(11061, 22406), SpecialAttack(SpecialAttack.Type.MELEE, 100) { player, target -> player.sync(6147, 1052) val hit = calculateHit(player, target, false, true, 1.0, 1.0) delayNormalHit(target, hit) if (target is Player) target.prayer.drainPrayer(hit.damage.toDouble()) player.soundEffect(target, 3592, true) return@SpecialAttack getMeleeCombatDelay(player.equipment.weaponId) }) //Armadyl godsword addSpec(intArrayOf(11694, 13450, 23679), SpecialAttack(SpecialAttack.Type.MELEE, 50) { player, target -> player.sync(11989, 2113) delayNormalHit(target, calculateHit(player, target, false, true, 2.0, 1.25)) return@SpecialAttack getMeleeCombatDelay(player.equipment.weaponId) }) //Vesta's longsword /** * Its special attack, Feint, inflicts 20% more damage and is harder to defend against while only draining 25% of the special bar, * making it deadly as it can be used four times in a row. When activated, the player thrusts the sword out with an exaggerated motion. * The power and accuracy of this attack made the Longsword the only piece of Ancient Warrior's equipment to retain a high price during * the excessive supply before the Anti-76k measures were put in place, due to its fatal capabilities. Only the non-corrupted version * features this attack. After the sword has been used in combat it will become untradeable. */ addSpec(intArrayOf(13899, 13901), SpecialAttack(SpecialAttack.Type.MELEE, 25) { player, target -> player.anim(10502) delayNormalHit(target, calculateHit(player, target, false, true, 2.0, 1.20)) player.soundEffect(target, 2529, true) return@SpecialAttack getMeleeCombatDelay(player.equipment.weaponId) }) //Statius' warhammer addSpec(intArrayOf(13902, 13904), SpecialAttack(SpecialAttack.Type.MELEE, 35) { player, target -> val hit = calculateHit(player, target, false, true, 1.0, 1.25) player.sync(10505, 1840) delayNormalHit(target, hit) if (hit.damage != 0) target.lowerStat(Skills.DEFENSE, 0.30, 0.0) player.soundEffect(target, 2520, true) return@SpecialAttack getMeleeCombatDelay(player.equipment.weaponId) }) //Vesta's spear addSpec(intArrayOf(13905, 13907), SpecialAttack(SpecialAttack.Type.MELEE, 50) { player, target -> val attackStyle = player.combatDefinitions.getAttackStyle() player.sync(10499, 1835) player.addEffect(Effect.MELEE_IMMUNE, Ticks.fromSeconds(5).toLong()) attackTarget(getMultiAttackTargets(player, target, 1, 20)) { next -> delayHit(next, 1, 13905, attackStyle, calculateHit(player, next, 13905, attackStyle, false, true, 1.0, 1.15)) return@attackTarget true } player.soundEffect(target, 2529, true) return@SpecialAttack getMeleeCombatDelay(player.equipment.weaponId) }) //Dragon 2h sword addSpec(intArrayOf(7158, 13430, 23696), SpecialAttack(SpecialAttack.Type.MELEE, 60) { player, target -> val attackStyle = player.combatDefinitions.getAttackStyle() player.sync(7078, 1225) attackTarget(getMultiAttackTargets(player, target, 1, 20)) { next -> delayHit(next, 1, 7158, attackStyle, calculateHit(player, next, 7158, attackStyle, false, true, 1.0, 1.2)) return@attackTarget true } player.soundEffect(target, 2530, true) return@SpecialAttack getMeleeCombatDelay(player.equipment.weaponId) }) //Korasi's sword addSpec(intArrayOf(18786, 19780, 19784, 22401), SpecialAttack(SpecialAttack.Type.MELEE, 60) { player, target -> player.sync(14788, 1729) var damage = getMaxHit(player, target, false, 1.5).toDouble() var multiplier = Math.random() if (!target.isAtMultiArea && !player.isAtMultiArea && !target.isForceMultiArea && !player.isForceMultiArea) multiplier += 0.5 damage *= multiplier delayNormalHit(target, Hit(player, damage.toInt(), HitLook.MAGIC_DAMAGE).setMaxHit(damage.toInt())) WorldTasks.schedule(0) { target.spotAnim(1730) } player.soundEffect(target, 3853, true) return@SpecialAttack getMeleeCombatDelay(player.equipment.weaponId) }) //Zamorak godsword addSpec(intArrayOf(11700, 13453, 23682), SpecialAttack(SpecialAttack.Type.MELEE, 100) { player, target -> val hit = calculateHit(player, target, false, true, 2.0, 1.1) player.sync(7070, 1221) if (hit.damage != 0 && target.size <= 1) { target.spotAnim(2104) target.freeze(Ticks.fromSeconds(18), false) } delayNormalHit(target, hit) return@SpecialAttack getMeleeCombatDelay(player.equipment.weaponId) }) fun clawSpec(player: Player, target: Entity, multipliers: DoubleArray) { var base = getMaxHit(player, target, false, multipliers[0]).let { calculateHit(player, target, it / 2, it, false, true, 1.0) } val hits = Array(4) { Hit.miss(player) } if (base.damage > 0) { val damageHalved = base.damage / 2 hits[0] = base hits[1] = Hit(player, damageHalved, HitLook.MELEE_DAMAGE) hits[2] = Hit(player, damageHalved / 2, HitLook.MELEE_DAMAGE) hits[3] = Hit(player, damageHalved - (damageHalved / 2), HitLook.MELEE_DAMAGE) } else { sequenceOf(multipliers[1], multipliers[2], multipliers[3]).forEachIndexed { index, multiplier -> base = calculateHit(player, target, false, true, multiplier, multiplier) if (base.damage > 0) { if (index == 2) hits[3] = base else hits.fill(Hit.miss(player), 0, index + 1) return@forEachIndexed } } if (base.damage == 0) hits[3] = Hit(player, Utils.getRandomInclusive(7), HitLook.MELEE_DAMAGE) } hits.forEachIndexed { index, hit -> if (index > 1) delayHit(target, 1, hit) else delayNormalHit(target, hit) } sequenceOf(7464 to 0, 7465 to 25, 7466 to 35, 7467 to 50).forEach { (effect, delay) -> player.soundEffect(target, effect, delay, true) } } //Rune claws addSpec(intArrayOf(3101, 13764), SpecialAttack(SpecialAttack.Type.MELEE, 50) { player, target -> player.anim(10961) clawSpec(player, target, doubleArrayOf(0.75, 0.75, 0.75, 1.25)) return@SpecialAttack getMeleeCombatDelay(player.equipment.weaponId) }) //Dragon claws addSpec(intArrayOf(14484, 14486, 23695), SpecialAttack(SpecialAttack.Type.MELEE, 50) { player, target -> player.sync(10961, 1950) clawSpec(player, target, doubleArrayOf(1.0, 1.0, 1.0, 1.5)) return@SpecialAttack getMeleeCombatDelay(player.equipment.weaponId) }) //Barrelchest anchor addSpec(intArrayOf(10887), SpecialAttack(SpecialAttack.Type.MELEE, 50) { player, target -> player.sync(5870, 1027) val hit = calculateHit(player, target, false, true, 2.0, 1.1) delayNormalHit(target, hit) target.lowerStat(Skills.DEFENSE, hit.damage / 10, 0.0) player.soundEffect(target, 3481, true) return@SpecialAttack getMeleeCombatDelay(player.equipment.weaponId) }) //Dragon longsword addSpec(intArrayOf(1305, 13475), SpecialAttack(SpecialAttack.Type.MELEE, 25) { player, target -> player.sync(12033, 2117) delayNormalHit(target, calculateHit(player, target, false, true, 1.0, 1.25)) player.soundEffect(target, 2529, true) return@SpecialAttack getMeleeCombatDelay(player.equipment.weaponId) }) //Dragon halberd addSpec(intArrayOf(3204, 13478), SpecialAttack(SpecialAttack.Type.MELEE, 30) { player, target -> player.sync(1665, 282) if (target.size > 3) { target.spotAnim(254, 0, 100) target.spotAnim(80) } delayNormalHit(target, calculateHit(player, target, false, true, 1.0, 1.1)) if (target.size > 1) delayHit(target, 1, calculateHit(player, target, false, true, 1.0, 1.1)) player.soundEffect(target, 2533, true) return@SpecialAttack getMeleeCombatDelay(player.equipment.weaponId) }) //Dragon scimitar addSpec(intArrayOf(4587, 13477), SpecialAttack(SpecialAttack.Type.MELEE, 55) { player, target -> player.sync(12031, 2118) val hit = calculateHit(player, target, false, true, 1.25, 1.0) if (target is Player && hit.damage > 0) target.setProtectionPrayBlock(10) delayNormalHit(target, hit) player.soundEffect(target, 2540, true) return@SpecialAttack getMeleeCombatDelay(player.equipment.weaponId) }) //Dragon daggers addSpec(intArrayOf(1215, 1231, 5680, 5698, 13465, 13466, 13467, 13468), SpecialAttack(SpecialAttack.Type.MELEE, 25) { player, target -> player.anim(1062) player.spotAnim(252, 0, 100) delayNormalHit(target, calculateHit(player, target, false, true, 1.15, 1.15)) delayNormalHit(target, calculateHit(player, target, false, true, 1.15, 1.15)) player.soundEffect(target, 2537, true) return@SpecialAttack getMeleeCombatDelay(player.equipment.weaponId) }) //Dragon mace addSpec(intArrayOf(1434, 13479), SpecialAttack(SpecialAttack.Type.MELEE, 25) { player, target -> player.sync(1060, 251) delayNormalHit(target, calculateHit(player, target, false, true, 1.25, 1.5)) player.soundEffect(target, 2541, true) return@SpecialAttack getMeleeCombatDelay(player.equipment.weaponId) }) //Rod of Ivandis, Ivandis flail addSpec(Stream.of(Utils.range(7639, 7648), Utils.range(13117, 13146)).flatMapToInt { array: IntArray? -> Arrays.stream(array) }.toArray(), SpecialAttack(SpecialAttack.Type.MELEE, 1) { player, target -> //TODO lmao player.sync(1060, 251) delayNormalHit(target, calculateHit(player, target, false, true, 1.0, 1.0)) player.soundEffect(target, 2541, true) return@SpecialAttack getMeleeCombatDelay(player.equipment.weaponId) }) //Penance trident addSpec(intArrayOf(15438, 15485), SpecialAttack(SpecialAttack.Type.MELEE, 50) { player, _ -> player.anim(12804) return@SpecialAttack getMeleeCombatDelay(player.equipment.weaponId) }) //Dwarven army axe addSpec(intArrayOf(21340), SpecialAttack(SpecialAttack.Type.MELEE, 100) { player, target -> player.anim(16308) //TODO proper anim delayHit(target, 0, Hit.melee(player, if (target is NPC) 20 else 10)) delayHit(target, 0, Hit.melee(player, if (target is NPC) 40 else 25)) delayHit(target, 0, Hit.melee(player, if (target is NPC) 30 else 20)) return@SpecialAttack getMeleeCombatDelay(player.equipment.weaponId) }) //Darklight addSpec(intArrayOf(6746), SpecialAttack(SpecialAttack.Type.MELEE, 50) { player, target -> val accuracyRoll = calculateHit(player, target, -1, AttackStyle(0, ""stab"", XPType.AGGRESSIVE, AttackType.STAB), false, true, 1.0, 1.0) player.sync(2890, 483) delayHit(target, 0, calculateHit(player, target, false, true, 1.0, 1.0)) if (accuracyRoll.damage > 0) { target.lowerStat(Skills.ATTACK, 0.05, 0.0) target.lowerStat(Skills.STRENGTH, 0.05, 0.0) target.lowerStat(Skills.DEFENSE, 0.05, 0.0) player.soundEffect(target, 225, true) } return@SpecialAttack getMeleeCombatDelay(player.equipment.weaponId) }) //Dragon hatchet addSpec(intArrayOf(6739, 13470), SpecialAttack(SpecialAttack.Type.MELEE, 100) { player, target -> player.sync(2876, 479) val hit = calculateHit(player, target, false, true, 1.0, 1.0) delayHit(target, 0, hit) if (hit.damage > 0) { target.lowerStat(Skills.DEFENSE, hit.damage / 10, 0.0) target.lowerStat(Skills.MAGIC, hit.damage / 10, 0.0) } player.soundEffect(target, 2531, true) return@SpecialAttack getMeleeCombatDelay(player.equipment.weaponId) }) //Dragon pickaxe addSpec(intArrayOf(15259, 15261, 20786), SpecialAttack(SpecialAttack.Type.MELEE, 100) { player, target -> player.sync(2661, 2144) val hit = calculateHit(player, target, false, true, 1.0, 1.0) delayHit(target, 1, hit) if (hit.damage > 0) { target.lowerStat(Skills.ATTACK, 0.05, 0.0) target.lowerStat(Skills.MAGIC, 0.05, 0.0) target.lowerStat(Skills.RANGE, 0.05, 0.0) } return@SpecialAttack getMeleeCombatDelay(player.equipment.weaponId) }) //Bone dagger addSpec(intArrayOf(8872, 8874, 8876, 8878), SpecialAttack(SpecialAttack.Type.MELEE, 75) { player, target -> player.sync(4198, 704) val hit = calculateHit(player, target, false, target.tempAttribs.getO(""last_target"") === player, 1.0, 1.0) delayHit(target, 0, hit) if (hit.damage > 0) target.lowerStat(Skills.DEFENSE, hit.damage / 10, 0.0) player.soundEffect(target, 1084, true) return@SpecialAttack getMeleeCombatDelay(player.equipment.weaponId) }) //Brine sabre, Brackish blade addSpec(intArrayOf(11037, 20671, 20673), SpecialAttack(SpecialAttack.Type.MELEE, 75) { player, target -> player.anim(6118) player.spotAnim(1048, 0, 96) val hit = calculateHit(player, target, false, true, 2.0, 1.0) delayHit(target, 0, hit) if (hit.damage > 0) { player.skills.adjustStat(hit.damage / 40, 0.0, true, Skills.ATTACK) player.skills.adjustStat(hit.damage / 40, 0.0, true, Skills.STRENGTH) player.skills.adjustStat(hit.damage / 40, 0.0, true, Skills.DEFENSE) } return@SpecialAttack getMeleeCombatDelay(player.equipment.weaponId) }) //Annihilation (16964 3193) obtaining //Absorbing essence into it? (16962 43) addSpec(intArrayOf(24455), SpecialAttack(SpecialAttack.Type.MELEE, 20) { player, target -> player.sync(16961, 44) delayNormalHit(target, calculateHit(player, target, false, true, 1.5, 1.5)) return@SpecialAttack 5 }) } fun addSpec(itemIds: IntArray, spec: SpecialAttack) { for (itemId in itemIds) specialAttacks[itemId] = spec } fun addSpec(itemId: Int, spec: SpecialAttack) { specialAttacks[itemId] = spec } fun getSpec(itemId: Int): SpecialAttack? { return specialAttacks[itemId] } fun handleClick(player: Player) { val spec = getSpec(player.equipment.weaponId) if (spec == null) { player.sendMessage(""This weapon has no special attack implemented yet."") return } if (spec.instant != null) { var specAmt = spec.energyCost.toDouble() if (player.combatDefinitions.hasRingOfVigour()) specAmt *= 0.9 if (player.combatDefinitions.getSpecialAttackPercentage() < specAmt) { player.sendMessage(""You don't have enough power left."") player.combatDefinitions.drainSpec(0) return } spec.instant.accept(player) return } player.combatDefinitions.switchUsingSpecialAttack() } fun execute(type: SpecialAttack.Type, player: Player, target: Entity?): Int { val spec = getSpec(player.equipment.weaponId) var cost = spec!!.energyCost.toDouble() if (spec.type != type) { player.combatDefinitions.drainSpec(0) return 3 } if (player.combatDefinitions.hasRingOfVigour()) cost *= 0.9 if (player.combatDefinitions.getSpecialAttackPercentage() < cost) { player.sendMessage(""You don't have enough power left."") player.combatDefinitions.drainSpec(0) return 3 } player.combatDefinitions.drainSpec(cost.toInt()) return spec.execute?.apply(player, target!!) ?: 0 }" "package com.rs.game.content.commands.admin; @PluginEventHandler public class MiscTest { private static final int[] UNIDENTIFIED_ANIMS = { 2057, 12549, 15461, 3024, 2202, 2205, 2200, 2212, 2207, 2211, 2208, 2197, 2195, 15719, 3145, 4122, 3874, 587, 10707, 1107, 2938, 2435, 2438, 2434, 2552, 2449, 2447, 14165, 2976, 2932, 3320, 3911, 5964, 3777, 3727, 2825, 2826, 16254, 16355, 16366, 16363, 16382, 16393, 10371, 1599, 3853, 3452, 3471, 3423, 3348, 2048, 3982, 2149, 6083, 2148, 2788, 11620, 2614, 15138, 12033, 3071, 13691, 2764, 12919, 1409, 6703, 15624, 2450, 1354, 15622, 2378, 9104, 16445, 654, 3032, 3670, 15147, 14175, 9021, 12913, 4471, 1852, 11146, 3266, 1633, 15128, 2343, 15203, 2010, 4223, 9899, 2903, 2326, 1307, 2891, 15139, 1196, 1895, 1485, 2697, 1267, 4611, 1914, 1606, 2094, 2813, 2793, 3182, 12806, 11604, 1317, 2684, 3562, 3308, 1155, 2138, 1855, 1867, 1255, 3093, 9723, 1893, 786, 3458, 3454, 3456, 3455, 3453, 2008, 2007, 2002, 3166, 2767, 11224, 5767, 3092, 1356, 1361, 1006, 948, 3546, 9681, 1492, 646, 1136, 345, 6, 1898, 2159, 120, 1418, 9946, 166, 179, 14844, 3437, 232, 16322, 296, 9502, 1017, 3575, 3574, 3681, 3601, 3588, 3612, 3650, 14289, 3120, 3122, 2998, 3576, 10243, 1870, 3098, 1621, 1620, 3123, 1922, 3037, 1452, 1456, 3474, 3344, 1998, 2000, 2030, 1761, 1410, 2330, 1095, 3189, 2897, 1232, 1213, 1219, 1498, 1279, 1635, 2808, 3987, 3978, 1876, 2571, 1262, 2103, 455, 2711, 3220, 466, 443, 1247, 450, 730, 3229, 463, 458, 456, 2166, 1546, 1562, 3164, 1815, 5013, 4019, 4016, 4029, 4135, 4138, 15080, 4156, 4164, 15113, 15129, 4222, 6689, 4262, 4253, 4281, 4258, 4283, 4285, 4316, 4333, 9164, 4337, 4347, 4352, 4404, 4359, 4364, 4361, 4434, 4576, 4573, 4834, 4553, 7139, 4574, 4592, 7033, 12609, 4600, 4752, 4749, 4822, 4818, 4803, 4796, 4909, 4912, 4892, 14242, 4904, 4908, 4903, 4878, 4907, 4863, 8525, 5015, 5054, 15137, 5421, 5076, 5077, 5053, 5139, 5157, 5154, 5266, 5299, 5307, 14302, 5360, 5354, 5062, 8849, 5420, 2757, 9405, 5599, 5588, 6104, 10355, 9577, 5736, 5733, 6364, 5796, 5812, 5813, 6147, 5861, 5905, 5902, 5904, 5908, 6073, 4219, 6125, 11411, 6121, 6213, 6179, 6169, 4852, 6459, 11608, 6273, 15011, 452, 12217, 6482, 11739, 6427, 6452, 6409, 6530, 6554, 6611, 6599, 6665, 6700, 6636, 6644, 6641, 6640, 14723, 11540, 6851, 12446, 6860, 14174, 6899, 6921, 6920, 9387, 6941, 7024, 16420, 1016, 16421, 16419, 15238, 6981, 7113, 7130, 7136, 7137, 7141, 7135, 7119, 7138, 7114, 7116, 7145, 35, 7233, 7240, 5076, 5077, 5053, 5139, 5157, 5154, 5266, 5299, 5307, 14302, 5360, 5354, 5062, 8849, 5420, 2757, 9405, 5599, 5588, 6104, 10355, 9577, 5736, 5733, 6364, 5796, 5812, 5813, 6147, 5861, 5905, 5902, 5904, 5908, 6073, 4219, 6125, 11411, 6121, 6213, 6179, 6169, 4852, 6459, 11608, 6273, 15011, 452, 12217, 6482, 11739, 6427, 6452, 6409, 6530, 6554, 6611, 6599, 6665, 6700, 6636, 6644, 6641, 6640, 14723, 11540, 6851, 12446, 6860, 14174, 6899, 6921, 6920, 9387, 6941, 7024, 16420, 1016, 16421, 16419, 15238, 6981, 7113, 7130, 7136, 7137, 7141, 7135, 7119, 7138, 7114, 7116, 7145, 35, 7233, 7240, 7253, 7281, 7293, 7278, 7290, 7277, 7296, 7299, 7321, 7348, 7352, 7359, 8806, 8859, 7388, 7489, 9610, 9633, 7538, 8450, 7545, 7551, 8535, 7634, 7652, 8402, 8474, 8466, 8418, 8486, 8434, 8379, 8414, 8430, 8422, 10554, 8426, 8494, 8482, 8490, 8446, 8462, 8470, 8137, 8509, 8662, 8590, 8645, 8625, 486, 11451, 8699, 1221, 1220, 1228, 8711, 8748, 8746, 8747, 8744, 8768, 8803, 8826, 8895, 8884, 10475, 10992, 11568, 11552, 8991, 9018, 10449, 9861, 9056, 9043, 9034, 10121, 15135, 9148, 9147, 9142, 9149, 4294, 12397, 9224, 9319, 9245, 9232, 9238, 9251, 9257, 9269, 15142, 9327, 9328, 9351, 12187, 9384, 9427, 9391, 9389, 9397, 9513, 9574, 9543, 9582, 9982, 9909, 15416, 4856, 12373, 3329, 9854, 13656, 16301, 6830, 10024, 9971, 9972, 9966, 9990, 10079, 12319, 10052, 10047, 10094, 10095, 10220, 10191, 10128, 10127, 10221, 10229, 10331, 10334, 10316, 12191, 10350, 10353, 10373, 10414, 10489, 10445, 10443, 10448, 10430, 14223, 15726, 10559, 10746, 10649, 10702, 10880, 10893, 10827, 10821, 10754, 10894, 10712, 10786, 10790, 10788, 10805, 10809, 10807, 10780, 10784, 10782, 10792, 10811, 10803, 10778, 14633, 10989, 10935, 10932, 10930, 10995, 14713, 11011, 11032, 11056, 11220, 1132, 1715, 1708, 11286, 11284, 11336, 11340, 11350, 11316, 11314, 11305, 11312, 11376, 1742, 11372, 11321, 11298, 11547, 16934, 11561, 11566, 11576, 11590, 11622, 11625, 11644, 11655, 11688, 11716, 11765, 11770, 11766, 884, 11794, 11819, 7527, 15825, 11860, 11862, 11882, 11821, 11933, 13945, 3273, 411, 11959, 3327, 12059, 12115, 12113, 12117, 12137, 12130, 12111, 12167, 12112, 16438, 12225, 12219, 12224, 12924, 12241, 12296, 12600, 12357, 12401, 12400, 12417, 12432, 12421, 12433, 12442, 12503, 12495, 12529, 12554, 12589, 12536, 12550, 1513, 12630, 1548, 12606, 4609, 12636, 4615, 12655, 12733, 9514, 5083, 12781, 12775, 12787, 12814, 12832, 6607, 12836, 12835, 12888, 12887, 16931, 12923, 12265, 13593, 13663, 14808, 13315, 13782, 13643, 13730, 13572, 13563, 13581, 13594, 13559, 13557, 13554, 13566, 13574, 13582, 13721, 13007, 13500, 13353, 14610, 13758, 13763, 13636, 13324, 14798, 13766, 14152, 13817, 13814, 13831, 13839, 13967, 13959, 14083, 14058, 13973, 14086, 15127, 14078, 14007, 14147, 1038, 14116, 14101, 2129, 4874, 14163, 14177, 14206, 14208, 14231, 14273, 14275, 14317, 14355, 14345, 14335, 14349, 14562, 14561, 14556, 14514, 14569, 14414, 14533, 14962, 14401, 14673, 14639, 14645, 14722, 14733, 14748, 14780, 14787, 14941, 14841, 14845, 14886, 14929, 14982, 3302, 3300, 3288, 3290, 15239, 15034, 15063, 15097, 7573, 15103, 15105, 15217, 15187, 15176, 15181, 6292, 6998, 7493, 15261, 7502, 7437, 7436, 7434, 15906, 15317, 15305, 15308, 15275, 15276, 2916, 15304, 16077, 107, 379, 307, 10825, 1478, 4207, 10860, 10824, 10116, 7456, 9573, 12465, 5848, 15353, 10964, 1174, 1291, 12437, 9674, 16875, 1202, 1730, 1786, 2120, 2566, 2231, 15740, 2605, 3413, 3536, 3497, 3052, 3929, 7055, 8644, 7157, 6787, 5684, 8498, 6066, 6575, 6366, 5784, 6786, 4405, 9856, 4729, 9818, 9211, 9700, 9699, 9694, 9503, 9953, 11553, 16501, 12361, 11843, 10731, 10734, 11957, 11235, 16325, 10978, 12666, 12546, 12760, 12901, 12934, 15644, 13686, 13510, 13597, 13956, 13700, 14528, 14306, 16921, 14878, 14955, 15313, 15376, 15330, 15402, 15382, 15429, 15433, 15536, 15560, 15573, 15566, 15576, 15900, 15584, 15592, 15602, 15733, 15702, 15637, 15639, 15658, 15645, 15717, 15716, 16212, 15746, 15754, 15940, 16404, 15994, 15898, 15757, 16062, 15802, 15808, 15937, 16072, 8527, 15943, 8545, 16245, 16410, 16439, 16429, 16370, 16532, 16548, 16533, 16632, 16686, 16647, 16617, 16623, 16620, 16629, 16603, 16671, 16940, 16929, 16870, 16826, 16835, 16855, 16825, 16770, 16767, 16760, 16850, 16864, 16881, 16917, 16894, 16935, 16938, 16973, 16964, 16958, 16978, 16987, 17064, 17010, 17132, 17118, 17159, 17184, 17169, 17155, 17149, 17158, 17168 }; @ServerStartupEvent public static void loadCommands() { // Commands.add(Rights.ADMIN, ""command [args]"", ""Desc"", (p, args) -> { // // }); Commands.add(Rights.DEVELOPER, ""reloadplugins"", ""legit test meme"", (p, args) -> { try { PluginScriptHost.Companion.loadAndExecuteScripts(); p.sendMessage(""Reloaded plugins successfully.""); } catch(Throwable e) { p.sendMessage(""Error compiling plugins.""); } }); Commands.add(Rights.ADMIN, ""shootingstar"", ""spawn a shooting star"", (p, args) -> ShootingStars.spawnStar()); Commands.add(Rights.ADMIN, ""eviltree"", ""spawn an evil tree"", (p, args) -> EvilTreesKt.spawnTree()); Commands.add(Rights.DEVELOPER, ""dumpdrops [npcId]"", ""exports a drop dump file for the specified NPC"", (p, args) -> NPCDropDumper.dumpNPC(args[0])); Commands.add(Rights.DEVELOPER, ""createinstance [chunkX, chunkY, width, height]"", ""create a test instance for getting coordinates and setting up cutscenes"", (p, args) -> p.getControllerManager().startController(new InstancedController(Instance.of(p.getTile(), Integer.parseInt(args[2]), Integer.parseInt(args[3]), false)) { @Override public void onBuildInstance() { getInstance().copyMapAllPlanes(Integer.parseInt(args[0]), Integer.parseInt(args[1])) .thenAccept(b -> player.playCutscene(cs -> getInstance().teleportLocal(player, (Integer.parseInt(args[2]) * 8) / 2, (Integer.parseInt(args[3]) * 8) / 2, 0))); } @Override public void onDestroyInstance() { } })); Commands.add(Rights.DEVELOPER, ""togglejfr"", ""Toggles JFR for the staff webhook tick profiler"", (p, args) -> { Settings.getConfig().setJFR(!Settings.getConfig().isEnableJFR()); p.sendMessage(""JFR is now "" + (Settings.getConfig().isEnableJFR() ? ""enabled."" : ""disabled."")); }); Commands.add(Rights.DEVELOPER, ""clanify"", ""Toggles the ability to clanify objects and npcs by examining them."", (p, args) -> { p.getNSV().setB(""clanifyStuff"", !p.getNSV().getB(""clanifyStuff"")); p.sendMessage(""CLANIFY: "" + p.getNSV().getB(""clanifyStuff"")); }); Commands.add(Rights.DEVELOPER, ""allstopfaceme"", ""Stops all body model rotators."", (p, args) -> { for (Player player : World.getPlayers()) { if (player == null || !player.hasStarted() || player.hasFinished()) continue; player.setBodyModelRotator(null); } for (NPC npc : World.getNPCs()) { if (npc == null || npc.hasFinished()) continue; npc.setBodyModelRotator(null); } }); Commands.add(Rights.DEVELOPER, ""allfaceme"", ""Sets body model rotators for all entities in the server."", (p, args) -> { for (Player player : World.getPlayers()) { if (player == null || !player.hasStarted() || player.hasFinished()) continue; player.setBodyModelRotator(new ModelRotator().addRotator(new Rotation(p).enableAll())); } for (NPC npc : World.getNPCs()) { if (npc == null || npc.hasFinished()) continue; npc.setBodyModelRotator(new ModelRotator().addRotator(new Rotation(p).enableAll())); } }); Commands.add(Rights.DEVELOPER, ""spawnmax"", ""Spawns another max into the world on top of the player."", (p, args) -> World.spawnNPC(3373, Tile.of(p.getTile()), -1, true, true, true)); Commands.add(Rights.DEVELOPER, ""playcs"", ""Plays a cutscene using new cutscene system"", (p, args) -> p.getCutsceneManager().play(new ExampleCutscene())); // Commands.add(Rights.DEVELOPER, ""modeldebug"", ""Spawns a ton of models of a certain color around you."", (p, args) -> { // List meshes = new ArrayList<>(); // int baseCol = RSColor.RGB_to_HSL(238, 213, 54); // for (int i = 0;i < Cache.STORE.getIndex(IndexType.MODELS).getLastArchiveId();i++) { // RSModel model = RSModel.getMesh(i); // if (model.getAvgColor() == 0) // continue; // if (model != null && model.faceCount < 64) // meshes.add(model); // } // meshes.sort((m1, m2) -> { // //if ((m1.vertexCount + m1.faceCount) == (m2.vertexCount + m2.faceCount)) // return Math.abs(m1.getAvgColor()-baseCol) - Math.abs(m2.getAvgColor()-baseCol); // //return (m1.vertexCount + m1.faceCount + Math.abs(m1.getAvgColor()-baseCol)) / 2 - (m2.vertexCount + m2.faceCount + Math.abs(m2.getAvgColor()-baseCol)) / 2; // }); // int count = 0; // int x = 0, y = 0; // for (RSModel model : meshes) { // if (count++ > 100) // break; // if (count % 10 == 0) { // y++; // x = 0; // } // GameObject obj = new GameObject(1, ObjectType.SCENERY_INTERACT, 0, p.transform(x++, y)); // World.spawnObject(obj); // WorldTasks.schedule(15, () -> { // obj.modifyMesh().addModels(model.id, model.id, model.id); // obj.refresh(); // }); // System.out.println(model.id + "" - v"" + model.vertexCount + "" - f"" + model.faceCount + "" - "" + Math.abs(model.getAvgColor()-baseCol)); // } // }); Commands.add(Rights.DEVELOPER, ""bonusxp [amount]"", ""Sets your bonus XP rate."", (p, args) -> { p.setBonusXpRate(Double.valueOf(args[0])); p.sendMessage(""Your bonus XP rates is now: "" + p.getBonusXpRate()); }); Commands.add(Rights.DEVELOPER, ""forcememclean"", ""Forces a mem clean op"", (p, args) -> Launcher.cleanMemory(true)); Commands.add(Rights.DEVELOPER, ""tilefree"", ""Checks if tile is free"", (p, args) -> { for (int x = -10;x < 10;x++) for (int y = -10;y < 10;y++) if (World.floorAndWallsFree(Tile.of(p.getX() + x, p.getY() + y, p.getPlane()), 1)) World.sendSpotAnim(Tile.of(p.getX() + x, p.getY() + y, p.getPlane()), new SpotAnim(2000, 0, 96)); }); Commands.add(Rights.DEVELOPER, ""tutisland"", ""Start tutorial island"", (p, args) -> p.getControllerManager().startController(new TutorialIslandController())); Commands.add(Rights.DEVELOPER, ""qbd"", ""Start qbd"", (p, args) -> p.getControllerManager().startController(new QueenBlackDragonController())); /** * 31 orange glow * 40 fire cape * 54 old hitsplats * 61 sick fire glow * 62 smokey pulsating * 89 colored glow * 361 bright white with bright colored glow * 451 running watery color * 637 ghostlyish mostly transparent * 647 another bright glow with less bloom * 648 breathing texture almost * 649 recolorable ghostly * 654, 656, 658 storm with thunder * 655 subtle dripping recolor * 657 fast pulsating ecto recolor * 676, 677 some colorful wheel * 679 recolorable ghillie suit * 691 another bright bloom glow * 707 transparent with black stars pulsating * 718 explosion bloom particles * 722 sick glow particle swirl recolorable * 811 eye blinding bloom * 824 bright looking lava * 825 recolorable bloom lava * 826 magical psychadelic moving * 831 recolorable upward flowing liquid * 847 sick bright yellow magical * 856 recolorable fast flowing liquid * 870 very bloomy recolorable * 875 bright but low bloom recolorable * 876-878 bright cool bloom * 880 alternate fire cape lava * 906 recolorable dragonhide lookin * 916 eye rape bloom * */ Commands.add(Rights.DEVELOPER, ""drtor [texId]"", ""Set equipment texture override"", (p, args) -> { if (p.getEquipment().get(Equipment.CHEST) != null) p.getEquipment().get(Equipment.CHEST).addMetaData(""drTOr"", Integer.parseInt(args[0])); if (p.getEquipment().get(Equipment.LEGS) != null) p.getEquipment().get(Equipment.LEGS).addMetaData(""drTOr"", Integer.parseInt(args[0])); if (p.getEquipment().get(Equipment.SHIELD) != null) p.getEquipment().get(Equipment.SHIELD).addMetaData(""drTOr"", Integer.parseInt(args[0])); if (p.getEquipment().get(Equipment.HEAD) != null) p.getEquipment().get(Equipment.HEAD).addMetaData(""drTOr"", Integer.parseInt(args[0])); p.getAppearance().generateAppearanceData(); }); Commands.add(Rights.DEVELOPER, ""drcor [r, g, b]"", ""Set equipment color override"", (p, args) -> { if (p.getEquipment().get(Equipment.CHEST) != null) p.getEquipment().get(Equipment.CHEST).addMetaData(""drCOr"", RSColor.RGB_to_HSL(Integer.parseInt(args[0]), Integer.parseInt(args[1]), Integer.parseInt(args[2]))); if (p.getEquipment().get(Equipment.LEGS) != null) p.getEquipment().get(Equipment.LEGS).addMetaData(""drCOr"", RSColor.RGB_to_HSL(Integer.parseInt(args[0]), Integer.parseInt(args[1]), Integer.parseInt(args[2]))); if (p.getEquipment().get(Equipment.SHIELD) != null) p.getEquipment().get(Equipment.SHIELD).addMetaData(""drCOr"", RSColor.RGB_to_HSL(Integer.parseInt(args[0]), Integer.parseInt(args[1]), Integer.parseInt(args[2]))); if (p.getEquipment().get(Equipment.HEAD) != null) p.getEquipment().get(Equipment.HEAD).addMetaData(""drCOr"", RSColor.RGB_to_HSL(Integer.parseInt(args[0]), Integer.parseInt(args[1]), Integer.parseInt(args[2]))); p.getAppearance().generateAppearanceData(); }); Commands.add(Rights.DEVELOPER, ""tileman"", ""Set to tileman mode"", (p, args) -> p.setTileMan(true)); Commands.add(Rights.DEVELOPER, ""players"", ""Lists online players"", (p, args) -> { p.getPackets().setIFText(275, 1, ""Online Players""); int componentId = 10; for (Player player : World.getPlayers()) { p.getPackets().setIFText(275, componentId++, "" ""00FF00""; case 1 -> ""FFFF00""; case 2 -> ""FF0000""; default -> ""FFFFFF""; })+"">"" + player.getDisplayName() + "" logged in for "" + Utils.ticksToTime((double) player.getTimePlayedThisSession()) + """"); } p.getPackets().sendRunScript(1207, componentId - 10); p.getInterfaceManager().sendInterface(275); }); Commands.add(Rights.DEVELOPER, ""names"", ""Sets NPCs names to something."", (p, args) -> { String name = Utils.concat(args); if (name.equals(""null"")) name = null; for (NPC n : World.getNPCs()) if (n != null) n.setPermName(name); }); Commands.add(Rights.DEVELOPER, ""barrowcheat"", ""Loots a full barrows chest."", (p, args) -> { if (p.getControllerManager().isIn(BarrowsController.class)) p.getControllerManager().getController(BarrowsController.class).cheat(); }); Commands.add(Rights.DEVELOPER, ""random"", ""Forces a random event."", (p, args) -> RandomEvents.attemptSpawnRandom(p, true)); Commands.add(Rights.DEVELOPER, ""freezeme [ticks]"", ""Freezes you for specific timeframe."", (p, args) -> p.freeze(Integer.parseInt(args[0]))); Commands.add(Rights.DEVELOPER, ""farm"", ""Force a farming tick."", (p, args) -> p.tickFarming()); Commands.add(Rights.DEVELOPER, ""runespan"", ""Teleports to runespan."", (p, args) -> { p.tele(Tile.of(3995, 6103, 1)); p.getControllerManager().startController(new RunespanController()); }); Commands.add(Rights.DEVELOPER, ""proj [id]"", ""Sends a projectile over the player."", (p, args) -> { p.getTempAttribs().setI(""tempProjCheck"", Integer.parseInt(args[0])); World.sendProjectile(Tile.of(p.getX() + 5, p.getY(), p.getPlane()), Tile.of(p.getX() - 5, p.getY(), p.getPlane()), Integer.parseInt(args[0]), 40, 40, 0, 0.2, 0, 0); }); Commands.add(Rights.DEVELOPER, ""projrot [id next/prev]"", ""Sends a projectile over the player."", (p, args) -> { int projId = p.getTempAttribs().getI(""tempProjCheck"", 0); World.sendProjectile(Tile.of(p.getX() + 5, p.getY(), p.getPlane()), Tile.of(p.getX() - 5, p.getY(), p.getPlane()), projId, 0, 0, 0, 0.2, 0, 0); p.getPackets().sendDevConsoleMessage(""Projectile: "" + projId); if (args[0].equals(""next"")) p.getTempAttribs().setI(""tempProjCheck"", Utils.clampI(projId+1, 0, 5000)); else p.getTempAttribs().setI(""tempProjCheck"", Utils.clampI(projId-1, 0, 5000)); }); Commands.add(Rights.DEVELOPER, ""object [id (type) (rotation)]"", ""Spawns an object south of the player's tile."", (p, args) -> { int rotation = args.length > 2 ? Integer.parseInt(args[2]) : 0; ObjectType type = args.length > 1 ? ObjectType.forId(Integer.parseInt(args[1])) : ObjectDefinitions.getDefs(Integer.parseInt(args[0])).types[0]; if (type == null) type = ObjectDefinitions.getDefs(Integer.parseInt(args[0])).types[0]; World.spawnObject(new GameObject(Integer.parseInt(args[0]), type, rotation, p.getX(), p.getY()-1, p.getPlane())); }); Commands.add(Rights.DEVELOPER, ""objecttmp [id (type) (rotation)]"", ""Spawns an object south of the player's tile for 1 tick."", (p, args) -> { int rotation = args.length > 2 ? Integer.parseInt(args[2]) : 0; ObjectType type = args.length > 1 ? ObjectType.forId(Integer.parseInt(args[1])) : ObjectDefinitions.getDefs(Integer.parseInt(args[0])).types[0]; if (type == null) type = ObjectDefinitions.getDefs(Integer.parseInt(args[0])).types[0]; GameObject before = World.getSpawnedObject(p.transform(0, -1, 0)); if (before != null) WorldTasks.schedule(3, () -> World.spawnObject(before)); World.spawnObjectTemporary(new GameObject(Integer.parseInt(args[0]), type, rotation, p.getX(), p.getY()-1, p.getPlane()), 1); }); Commands.add(Rights.DEVELOPER, ""cutscene [id]"", ""Plays a predefined cutscene"", (p, args) -> p.getPackets().sendCutscene(Integer.parseInt(args[0]))); Commands.add(Rights.DEVELOPER, ""pin"", ""Opens bank pin interface."", (p, args) -> p.getBank().openPin()); Commands.add(Rights.DEVELOPER, ""areaobj [(radius)]"", ""Lists out nearby objects."", (p, args) -> { int radius = args.length > 0 ? Integer.parseInt(args[0]) : 0; List objects = new ArrayList<>(); if (radius == 0) { GameObject[] objs = World.getBaseObjects(p.getTile()); if (objs != null) for (GameObject obj : objs) if (obj != null) objects.add(obj); } else for (int z = -3;z < 3;z++) for (int x = -radius;x < radius;x++) for (int y = -radius;y < radius;y++) { Tile t = p.transform(x, y, z); if (t.getPlane() >= 4 || t.getPlane() < 0) continue; GameObject[] objs = World.getBaseObjects(t); if (objs != null) for (GameObject obj : objs) if (obj != null) objects.add(obj); } for (GameObject o : objects) { Logger.debug(MiscTest.class, ""areaobj"", o); Logger.debug(MiscTest.class, ""areaobj"", ""vb: "" + o.getDefinitions().varpBit); } }); Commands.add(Rights.DEVELOPER, ""npcwalkdir"", ""Spawn npc walking dir."", (player, args) -> { Direction dir = Arrays.stream(Direction.values()).filter(n -> n.name().equalsIgnoreCase(args[0])).findFirst().get(); if (dir == null) return; NPC npc = World.spawnNPC(1, player.getTile(), true, false, null); npc.addWalkSteps(player.getTile().getX() + (dir.dx * 20), player.getTile().getY() + (dir.dy * 20)); }); Commands.add(Rights.DEVELOPER, ""headicon"", ""Set custom headicon."", (player, args) -> { player.getTempAttribs().setI(""customHeadIcon"", Integer.parseInt(args[0])); player.getAppearance().generateAppearanceData(); }); Commands.add(Rights.DEVELOPER, ""skull"", ""Set custom skull."", (player, args) -> { player.setSkullInfiniteDelay(Integer.parseInt(args[0])); player.getAppearance().generateAppearanceData(); }); Commands.add(Rights.DEVELOPER, ""sd"", ""Search for a door pair."", (p, args) -> Doors.searchDoors(Integer.parseInt(args[0]))); Commands.add(Rights.DEVELOPER, ""getapp"", ""Prints out appearance data"", (p, args) -> p.getAppearance().printDebug()); Commands.add(Rights.DEVELOPER, ""vischunks"", ""Toggles the visualization of chunks."", (p, args) -> { p.getNSV().setB(""visChunks"", !p.getNSV().getB(""visChunks"")); p.sendMessage(""Visualizing chunks: "" + p.getNSV().getB(""visChunks"")); }); Commands.add(Rights.DEVELOPER, ""spawntestnpc"", ""Spawns a combat test NPC."", (p, args) -> { NPC n = World.spawnNPC(14256, Tile.of(p.getTile()), -1, true, true); n.setLoadsUpdateZones(); n.setPermName(""Losercien (punching bag)""); n.setHitpoints(Integer.MAX_VALUE / 2); n.getCombatDefinitions().setHitpoints(Integer.MAX_VALUE / 2); n.setForceMultiArea(true); n.setForceMultiAttacked(true); n.anim(10993); }); Commands.add(Rights.ADMIN, ""clearbank,emptybank"", ""Empties the players bank entirely."", (p, args) -> p.sendOptionDialogue(""Clear bank?"", ops -> { ops.add(""Yes"", () -> p.getBank().clear()); ops.add(""No""); })); if (!Settings.getConfig().isDebug()) { Commands.add(Rights.DEVELOPER, ""exec [command to execute]"", ""Executes a command-line command on the remote server."", (p, args) -> Launcher.executeCommand(p, Utils.concat(args))); } Commands.add(Rights.DEVELOPER, ""shop [name]"", ""Opens a shop container of specified id."", (p, args) -> ShopsHandler.openShop(p, args[0])); Commands.add(Rights.DEVELOPER, ""dial [npcId animId]"", ""Dialogue box"", (p, args) -> { p.getInterfaceManager().sendChatBoxInterface(1184); p.getPackets().setIFText(1184, 17, NPCDefinitions.getDefs(Integer.parseInt(args[0])).getName()); p.getPackets().setIFText(1184, 13, ""How dare you!""); p.getPackets().setIFNPCHead(1184, 11, Integer.parseInt(args[0])); //p.getPackets().setIFAngle(1184, 11, 100, 1900, 1000); p.getPackets().setIFAnimation(Integer.parseInt(args[1]), 1184, 11); }); Commands.add(Rights.DEVELOPER, ""dialrot [npcId next/prev/start_num]"", ""Dialogue box"", (p, args) -> { int idx = p.getTempAttribs().getI(""tempDialCheck"", 0); if(args[1].matches(""[0-9]+"")) idx = Integer.parseInt(args[1])+1; int anim = UNIDENTIFIED_ANIMS[idx]; p.getInterfaceManager().sendChatBoxInterface(1184); p.getPackets().setIFText(1184, 17, NPCDefinitions.getDefs(Integer.parseInt(args[0])).getName()); p.getPackets().setIFText(1184, 13, ""DICK!""); p.getPackets().setIFNPCHead(1184, 11, Integer.parseInt(args[0])); //p.getPackets().setIFAngle(1184, 11, 100, 1900, 1000); p.getPackets().setIFAnimation(anim, 1184, 11); p.sendMessage(""Anim: "" + anim); if (args[1].equals(""next"")) p.getTempAttribs().setI(""tempDialCheck"", Utils.clampI(idx+1, 0, UNIDENTIFIED_ANIMS.length-1)); else p.getTempAttribs().setI(""tempDialCheck"", Utils.clampI(idx-1, 0, UNIDENTIFIED_ANIMS.length-1)); p.getPackets().sendDevConsoleMessage(idx + ""/"" + UNIDENTIFIED_ANIMS.length); }); Commands.add(Rights.DEVELOPER, ""icompanim [interfaceId componentId animId]"", ""Plays animation id on interface component."", (p, args) -> { p.getInterfaceManager().sendInterface(Integer.parseInt(args[0])); p.getPackets().setIFAnimation(Integer.parseInt(args[2]), Integer.parseInt(args[0]), Integer.parseInt(args[1])); }); Commands.add(Rights.DEVELOPER, ""icompanimrot [interfaceId componentId next/prev]"", ""Rotates animations on an interface component."", (p, args) -> { int idx = p.getTempAttribs().getI(""tempDialCheck"", 0); int anim = UNIDENTIFIED_ANIMS[idx]; p.getInterfaceManager().sendInterface(Integer.parseInt(args[0])); p.getPackets().setIFAnimation(anim, Integer.parseInt(args[0]), Integer.parseInt(args[1])); p.sendMessage(""Anim: "" + anim); if (args[2].equals(""next"")) p.getTempAttribs().setI(""tempDialCheck"", Utils.clampI(idx+1, 0, UNIDENTIFIED_ANIMS.length-1)); else p.getTempAttribs().setI(""tempDialCheck"", Utils.clampI(idx-1, 0, UNIDENTIFIED_ANIMS.length-1)); p.getPackets().sendDevConsoleMessage(idx + ""/"" + UNIDENTIFIED_ANIMS.length); }); Commands.add(Rights.DEVELOPER, ""setlook [slot id]"", ""Appearance setting"", (p, args) -> { p.getAppearance().setLook(Integer.parseInt(args[0]), Integer.parseInt(args[1])); p.getAppearance().generateAppearanceData(); }); Commands.add(Settings.getConfig().isDebug() ? Rights.PLAYER : Rights.DEVELOPER, ""sound [id]"", ""Plays a sound effect."", (p, args) -> p.soundEffect(Integer.parseInt(args[0]), true)); Commands.add(Settings.getConfig().isDebug() ? Rights.PLAYER : Rights.DEVELOPER, ""tilesound [id]"", ""Plays a tile sound effect."", (p, args) -> World.soundEffect(p.getTile(), Integer.parseInt(args[0]))); Commands.add(Settings.getConfig().isDebug() ? Rights.PLAYER : Rights.DEVELOPER, ""music [id (volume)]"", ""Plays a music track."", (p, args) -> p.getMusicsManager().playSongWithoutUnlocking(Integer.parseInt(args[0]))); Commands.add(Rights.DEVELOPER, ""unusedmusic"", ""Shows unused music."", (p, args) -> { int count = 0; for(int i = 0; i < 1099; i++) if(Music.getSongGenres(i).length == 0) { Song song = Music.getSong(i); count++; if(song == null) Logger.error(MiscTest.class, ""unusedmusic"", ""Error @"" + i); else Logger.debug(MiscTest.class, ""unusedmusic"", i + "" "" + song.getName() + "": "" + song.getHint()); } Logger.debug(MiscTest.class, ""unusedmusic"", ""Total unused: "" + count); Logger.debug(MiscTest.class, ""unusedmusic"", ""Unused is "" + Math.ceil(count/1099.0*100) + ""%""); }); Commands.add(Rights.DEVELOPER, ""nextm"", ""Plays a music track."", (p, args) -> p.getMusicsManager().nextAmbientSong()); Commands.add(Rights.DEVELOPER, ""genre"", ""Shows genre"", (p, args) -> { Genre genre = p.getMusicsManager().getPlayingGenre(); if(genre == null) p.sendMessage(""No genre, remember this updates after an ambient song is played...""); else p.sendMessage(genre.getGenreName()); }); Commands.add(Rights.DEVELOPER, ""script"", ""Runs a clientscript with no arguments."", (p, args) -> p.getPackets().sendRunScriptBlank(Integer.parseInt(args[0]))); Commands.add(Rights.DEVELOPER, ""scriptargs"", ""Runs a clientscript with no arguments."", (p, args) -> { Object[] scriptArgs = new Object[args.length-1]; for (int i = 1;i < args.length;i++) { try { scriptArgs[i - 1] = Integer.parseInt(args[i]); } catch(Throwable e) { scriptArgs[i - 1] = args[i]; } } p.getPackets().sendRunScript(Integer.parseInt(args[0]), scriptArgs); }); Commands.add(Rights.DEVELOPER, ""frogland"", ""Plays frogland to everyone on the server."", (p, args) -> World.allPlayers(target -> { target.getPackets().sendRunScript(1764, 12451857, 12451853, 20, 0); //0 music volume, 1 sound effect volume, 2 ambient sound volume target.musicTrack(409); })); Commands.add(Rights.DEVELOPER, ""musicall [id]"", ""Plays music to everyone on the server."", (p, args) -> World.allPlayers(target -> { target.getPackets().sendRunScript(1764, 12451857, 12451853, 20, 0); //0 music volume, 1 sound effect volume, 2 ambient sound volume target.musicTrack(Integer.parseInt(args[0])); })); Commands.add(Rights.DEVELOPER, ""jingle [id]"", ""plays jingles"", (p, args) -> p.jingle(Integer.parseInt(args[0]))); Commands.add(Rights.DEVELOPER, ""tileflags"", ""Get the tile flags for the tile you're standing on."", (p, args) -> p.sendMessage("""" + ClipFlag.getFlags(WorldCollision.getFlags(p.getTile())))); Commands.add(Rights.DEVELOPER, ""cheev [id]"", ""Sends achievement complete interface."", (p, args) -> p.getInterfaceManager().sendAchievementComplete(Achievement.forId(Integer.parseInt(args[0])))); Commands.add(Rights.ADMIN, ""update,restart [ticks]"", ""Restarts the server after specified number of ticks."", (p, args) -> World.safeShutdown(Integer.parseInt(args[0]))); Commands.add(Rights.DEVELOPER, ""npc [npcId]"", ""Spawns an NPC with specified ID."", (p, args) -> World.spawnNPC(Integer.parseInt(args[0]), Tile.of(p.getTile()), -1, true, true, false)); Commands.add(Rights.DEVELOPER, ""addnpc [npcId]"", ""Spawns an NPC permanently with specified ID."", (p, args) -> { if (!Settings.getConfig().isDebug()) return; if (NPCSpawns.addSpawn(p.getUsername(), Integer.parseInt(args[0]), Tile.of(p.getTile()))) p.sendMessage(""Added spawn.""); }); Commands.add(Rights.DEVELOPER, ""dropitem"", ""Spawns an item on the floor until it is picked up."", (p, args) -> World.addGroundItem(new Item(Integer.parseInt(args[0]), 1), Tile.of(p.getX(), p.getY(), p.getPlane()))); Commands.add(Rights.DEVELOPER, ""addgrounditem,addgitem [itemId respawnTicks]"", ""Spawns a ground item permanently with specified ID."", (p, args) -> { if (!Settings.getConfig().isDebug()) return; if (ItemSpawns.addSpawn(p.getUsername(), Integer.parseInt(args[0]), 1, Integer.parseInt(args[1]), Tile.of(p.getTile()))) p.sendMessage(""Added spawn.""); }); Commands.add(Rights.ADMIN, ""god"", ""Toggles god mode for the player."", (p, args) -> { p.getNSV().setB(""godMode"", !p.getNSV().getB(""godMode"")); p.sendMessage(""GODMODE: "" + p.getNSV().getB(""godMode"")); }); Commands.add(Rights.ADMIN, ""unnullall"", ""Forces the player out of a controller and unlocks them hopefully freeing any stuck-ness."", (p, args) -> { for (Player player : World.getPlayers()) { if (player == null) continue; player.unlock(); player.getControllerManager().forceStop(); if (player.getMoveTile() == null) player.tele(Settings.getConfig().getPlayerRespawnTile()); } }); Commands.add(Rights.ADMIN, ""infspec"", ""Toggles infinite special attack for the player."", (p, args) -> { p.getNSV().setB(""infSpecialAttack"", !p.getNSV().getB(""infSpecialAttack"")); p.sendMessage(""INFINITE SPECIAL ATTACK: "" + p.getNSV().getB(""infSpecialAttack"")); }); Commands.add(Rights.ADMIN, ""infpray"", ""Toggles infinite prayer for the player."", (p, args) -> { p.getNSV().setB(""infPrayer"", !p.getNSV().getB(""infPrayer"")); p.sendMessage(""INFINITE PRAYER: "" + p.getNSV().getB(""infPrayer"")); }); Commands.add(Rights.ADMIN, ""infrun"", ""Toggles infinite run for the player."", (p, args) -> { p.getNSV().setB(""infRun"", !p.getNSV().getB(""infRun"")); p.sendMessage(""INFINITE RUN: "" + p.getNSV().getB(""infRun"")); }); Commands.add(Rights.ADMIN, ""infrunes"", ""Toggles infinite runes for the player."", (p, args) -> { p.getNSV().setB(""infRunes"", !p.getNSV().getB(""infRunes"")); p.sendMessage(""INFINITE RUNES: "" + p.getNSV().getB(""infRunes"")); }); Commands.add(Rights.ADMIN, ""maxbank"", ""Sets all the item counts in the player's bank to 10m."", (p, args) -> { for (Item i : p.getBank().getContainerCopy()) if (i != null) i.setAmount(10500000); }); Commands.add(Rights.ADMIN, ""spellbook [modern/lunar/ancient]"", ""Switches to modern, lunar, or ancient spellbooks."", (p, args) -> { switch(args[0].toLowerCase()) { case ""modern"": case ""normal"": p.getCombatDefinitions().setSpellbook(Spellbook.MODERN); break; case ""ancient"": case ""ancients"": p.getCombatDefinitions().setSpellbook(Spellbook.ANCIENT); break; case ""lunar"": case ""lunars"": p.getCombatDefinitions().setSpellbook(Spellbook.LUNAR); break; case ""dung"": p.getCombatDefinitions().setSpellbook(Spellbook.DUNGEONEERING); break; default: p.sendMessage(""Invalid spellbook. Spellbooks are modern, lunar, ancient, and dung""); break; } }); Commands.add(Rights.ADMIN, ""prayers [normal/curses]"", ""Switches to curses, or normal prayers."", (p, args) -> { switch(args[0].toLowerCase()) { case ""normal"": case ""normals"": p.getPrayer().setPrayerBook(false); break; case ""curses"": case ""ancients"": p.getPrayer().setPrayerBook(true); break; default: p.sendMessage(""Invalid prayer book. Prayer books are normal and curses.""); break; } }); Commands.add(Rights.DEVELOPER, ""reloadlocalmap"", ""Forces your local map to reload"", (p, args) -> { for (GameObject obj : ChunkManager.getChunk(p.getChunkId()).getAllBaseObjects(true)) { p.sendMessage(obj.toString()); } if (ChunkManager.getChunk(p.getChunkId()) instanceof InstancedChunk c) p.sendMessage(c.getOriginalBaseX() + "", "" + c.getOriginalBaseY() + "" - "" + c.getRotation()); p.setForceNextMapLoadRefresh(true); p.loadMapRegions(); }); Commands.add(Rights.DEVELOPER, ""reloadshops"", ""Reloads the shop data file."", (p, args) -> ShopsHandler.reloadShops()); Commands.add(Rights.DEVELOPER, ""reloadcombat"", ""Reloads the NPC combat definitions files."", (p, args) -> { NPCCombatDefinitions.reload(); for (NPC npc : World.getNPCs()) if (npc != null) npc.resetLevels(); }); Commands.add(Rights.DEVELOPER, ""reloaddrops"", ""Reloads the drop table files."", (p, args) -> DropSets.reloadDrops()); Commands.add(Rights.DEVELOPER, ""loginmessage,loginmes [announcement]"", ""Sets the server login announcement."", (p, args) -> { Settings.getConfig().setLoginMessage("""" + Utils.concat(args)); try { Settings.saveConfig(); } catch (IOException e) { p.sendMessage(""Failed to save config""); } p.sendMessage(Settings.getConfig().getLoginMessage()); }); Commands.add(Rights.DEVELOPER, ""coords,getpos,mypos,pos,loc"", ""Gets the coordinates for the tile."", (p, args) -> { p.sendMessage(""Coords: "" + p.getX() + "","" + p.getY() + "","" + p.getPlane() + "", regionId: "" + p.getRegionId() + "", chunkX: "" + p.getChunkX() + "", chunkY: "" + p.getChunkY() + "", hash: "" + p.getTileHash()); p.sendMessage(""ChunkId: "" + p.getChunkId()); if (ChunkManager.getChunk(p.getChunkId()) instanceof InstancedChunk instance) p.sendMessage(""In instanced chunk copied from: "" + instance.getOriginalBaseX() + "", "" + instance.getOriginalBaseY() + "" rotation: "" + instance.getRotation()); p.sendMessage(""JagCoords: "" + p.getPlane() + "",""+p.getRegionX()+"",""+p.getRegionY()+"",""+p.getXInRegion()+"",""+p.getYInRegion()); p.sendMessage(""Local coords: "" + p.getXInRegion() + "" , "" + p.getYInRegion()); p.sendMessage(""16x16: "" +(p.getXInScene(p.getSceneBaseChunkId()) % 16) +"", ""+(p.getYInScene(p.getSceneBaseChunkId()) % 16)); }); Commands.add(Rights.ADMIN, ""search,si,itemid [item name]"", ""Searches for items containing the words searched."", (p, args) -> { p.getPackets().sendDevConsoleMessage(""Searching for items containing: "" + Arrays.toString(args)); for (int i = 0; i < Utils.getItemDefinitionsSize(); i++) { boolean contains = true; for (String arg : args) if (!ItemDefinitions.getDefs(i).getName().toLowerCase().contains(arg.toLowerCase()) || ItemDefinitions.getDefs(i).isLended()) { contains = false; continue; } if (contains) p.getPackets().sendDevConsoleMessage(""Result found: "" + i + "" - "" + ItemDefinitions.getDefs(i).getName() + "" "" + (ItemDefinitions.getDefs(i).isNoted() ? ""(noted)"" : """") + """" + (ItemDefinitions.getDefs(i).isLended() ? ""(lent)"" : """")); } }); Commands.add(Rights.ADMIN, ""item,spawn [itemId (amount)]"", ""Spawns an item with specified id and amount."", (p, args) -> { p.getInventory().addItem(Integer.parseInt(args[0]), args.length >= 2 ? Integer.parseInt(args[1]) : 1); p.stopAll(); }); Commands.add(Rights.ADMIN, ""master,max"", ""Maxes all stats out."", (p, args) -> { for (int skill = 0; skill < 25; skill++) p.getSkills().setXp(skill, 105000000); p.reset(); p.getAppearance().generateAppearanceData(); }); Commands.add(Rights.ADMIN, ""ironman [true/false]"", ""Changes ironman status of the player."", (p, args) -> p.setIronMan(Boolean.valueOf(args[0]))); Commands.add(Rights.DEVELOPER, ""killnpcs"", ""Kills all npcs around the player."", (p, args) -> { for (NPC npc : World.getNPCsInChunkRange(p.getChunkId(), 3)) { if (npc instanceof Familiar || npc instanceof Pet) continue; if (Utils.getDistance(npc.getTile(), p.getTile()) < 9 && npc.getPlane() == p.getPlane()) { for (int i = 0; i < 100; ++i) npc.applyHit(new Hit(p, 10000, HitLook.TRUE_DAMAGE)); } } }); Commands.add(Rights.ADMIN, ""boostlevel [skillId level]"", ""Sets a skill to a specified level."", (p, args) -> { int skill = Integer.parseInt(args[0]); int level = Integer.parseInt(args[1]); p.sendMessage(""Boosting "" + Skills.SKILL_NAME[skill] + "" by "" + level); p.getSkills().set(skill, level); }); Commands.add(Rights.DEVELOPER, ""deathnpcs"", ""Kills all npcs around the player."", (p, args) -> { for (NPC npc : World.getNPCs()) { if (npc instanceof Familiar || npc instanceof Pet) continue; if (Utils.getDistance(npc.getTile(), p.getTile()) < 9 && npc.getPlane() == p.getPlane()) npc.sendDeath(p); } }); Commands.add(Rights.DEVELOPER, ""resetquest [questName]"", ""Resets the specified quest."", (p, args) -> { for (Quest quest : Quest.values()) if (quest.name().toLowerCase().contains(args[0]) && quest.isImplemented()) { p.getQuestManager().resetQuest(quest); p.sendMessage(""Reset quest: "" + quest.name()); return; } for (Miniquest quest : Miniquest.values()) if (quest.name().toLowerCase().contains(args[0]) && quest.isImplemented()) { p.getMiniquestManager().reset(quest); p.sendMessage(""Reset miniquest: "" + quest.name()); return; } }); Commands.add(Rights.DEVELOPER, ""completequest [questName]"", ""Resets the specified quest."", (p, args) -> { for (Quest quest : Quest.values()) if (quest.name().toLowerCase().contains(args[0])) { p.getQuestManager().completeQuest(quest); p.sendMessage(""Completed quest: "" + quest.name()); return; } for (Miniquest quest : Miniquest.values()) if (quest.name().toLowerCase().contains(args[0])) { p.getMiniquestManager().complete(quest); p.sendMessage(""Completed miniquest: "" + quest.name()); return; } }); Commands.add(Rights.DEVELOPER, ""completeallquests"", ""Completes all quests."", (p, args) -> { for (Quest quest : Quest.values()) if (quest.isImplemented()) { p.getQuestManager().completeQuest(quest); p.sendMessage(""Completed quest: "" + quest.name()); } for (Miniquest quest : Miniquest.values()) if (quest.isImplemented()) { p.getMiniquestManager().complete(quest); p.sendMessage(""Completed miniquest: "" + quest.name()); } }); Commands.add(Rights.DEVELOPER, ""resetallquests"", ""Resets all quests."", (p, args) -> { for (Quest quest : Quest.values()) if (quest.isImplemented()) { p.getQuestManager().resetQuest(quest); p.sendMessage(""Reset quest: "" + quest.name()); } for (Miniquest quest : Miniquest.values()) if (quest.isImplemented()) { p.getMiniquestManager().reset(quest); p.sendMessage(""Reset miniquest: "" + quest.name()); } }); Commands.add(Rights.DEVELOPER, ""hinttrail [x y modelId]"", ""Sets a hint trail from the player to the specified location."", (p, args) -> { int x = Integer.parseInt(args[0]); int y = Integer.parseInt(args[1]); int modelId = Integer.parseInt(args[2]); //47868 Route route = RouteFinderKt.routeEntityToTile(p, Tile.of(x, y, p.getPlane()), 25); int[] bufferX = new int[route.size()]; int[] bufferY = new int[route.size()]; int i = 0; for (RouteCoordinates tile : route.getCoords()) { bufferX[i] = tile.getPacked() & 0xFFFF; bufferY[i++] = (tile.getPacked() >> 16) & 0xFFFF; } p.getSession().writeToQueue(new HintTrail(Tile.of(p.getTile()), modelId, bufferX, bufferY, i)); }); Commands.add(Rights.ADMIN, ""maxhit"", ""Displays the player's max hit."", (p, args) -> p.sendMessage(""Max hit: "" + PlayerCombatKt.getMaxHit(p, null, p.getEquipment().getWeaponId(), p.getCombatDefinitions().getAttackStyle(), PlayerCombatKt.isRanging(p), 1.0))); Commands.add(Rights.DEVELOPER, ""searchobj,so [objectId index]"", ""Searches the entire gameworld for an object matching the ID and teleports you to it."", (p, args) -> { List objs = MapSearcher.getObjectsById(Integer.parseInt(args[0])); if (objs.isEmpty()) { p.sendMessage(""Nothing found for "" + args[0]); return; } int i = 0; for (GameObject obj : objs) p.getPackets().sendDevConsoleMessage(i++ + "": "" + obj.toString()); if(args.length == 1) { p.tele(objs.getFirst().getTile()); return; } p.tele(objs.get(Integer.parseInt(args[1])).getTile()); }); Commands.add(Rights.DEVELOPER, ""searchnpc,sn [npcId index]"", ""Searches the entire (loaded) gameworld for an NPC matching the ID and teleports you to it."", (p, args) -> { int i = 0; List npcs = NPCSpawns.getAllSpawns().stream().filter(n -> n.getNPCId() == Integer.parseInt(args[0])).toList(); for(NPCSpawn npc : npcs) p.getPackets().sendDevConsoleMessage(i++ + "": "" + npc.toString()); if (args.length == 1) { p.tele(Tile.of(npcs.getFirst().getTile())); return; } p.tele(npcs.get(Integer.parseInt(args[1])).getTile()); }); Commands.add(Rights.ADMIN, ""hide"", ""Hides the player from other players."", (p, args) -> { p.setTrulyHidden(!p.isTrulyHidden()); p.sendMessage(""Hidden: "" + p.isTrulyHidden()); }); Commands.add(Rights.ADMIN, ""setlevel [skillId level]"", ""Sets a skill to a specified level."", (p, args) -> { int skill = Integer.parseInt(args[0]); int level = Integer.parseInt(args[1]); if (level < 0 || level > (skill == Constants.DUNGEONEERING ? 120 : 99)) { p.sendMessage(""Please choose a valid level.""); return; } if (skill < 0 || skill >= Constants.SKILL_NAME.length) { p.sendMessage(""Please choose a valid skill.""); return; } p.getSkills().set(skill, level); p.getSkills().setXp(skill, Skills.getXPForLevel(level)); p.getAppearance().generateAppearanceData(); p.reset(); p.sendMessage(""Successfully set "" + Constants.SKILL_NAME[skill] + "" to "" + level + "".""); }); Commands.add(Rights.ADMIN, ""unlockdgfloors"", ""Unlocks all dungeoneering floors and complexities."", (p, args) -> { p.getDungManager().setMaxFloor(60); p.getDungManager().setMaxComplexity(6); }); Commands.add(Rights.ADMIN, ""reset"", ""Resets all stats to 1."", (p, args) -> { for (int skill = 0; skill < 25; skill++) p.getSkills().setXp(skill, 0); p.getSkills().init(); }); Commands.add(Rights.DEVELOPER, ""voice, v [id]"", ""Plays voices."", (p, args) -> { p.getSession().write(ServerPacket.RESET_SOUNDS); p.voiceEffect(Integer.parseInt(args[0]), true); }); Commands.add(Rights.DEVELOPER, ""familiarhead"", ""Tests familiar/pet chathead icons"", (p, args) -> { Pouch pouch = Pouch.valueOf(args[0]); if (pouch == null) { p.sendMessage(""Invalid pouch name.""); return; } p.getVars().setVar(448, pouch.getId());// configures familiar type p.getVars().setVar(1174, 0, true); //refresh familiar head p.getVars().setVarBit(4282, Integer.parseInt(args[1])); //refresh familiar emote }); Commands.add(Rights.DEVELOPER, ""playthroughvoices [start finish tick_delay]"", ""Gets player rights"", (p, args) -> { // Voice[] voices = new Voice[3]; // voices[0] = new Voice(""Test1"", new int[]{1, 2, 3}); // voices[1] = new Voice(""Test3"", new int[]{4, 5, 6}); // voices[2] = new Voice(""Test4"", new int[]{7, 8, 9}); // try { // JsonFileManager.saveJsonFile(voices, new File(""developer-information/voice.json"")); // } catch(Exception e) { // Logger.debug(e.getStackTrace()); // } int tickDelay = Integer.parseInt(args[2]); WorldTasks.scheduleLooping(new Task() { int tick; int voiceID = 0; @Override public void run() { if(tick == 0) voiceID = Integer.parseInt(args[0]); if(Voices.voicesMarked.contains(voiceID)) for(int i = voiceID; i < 100_000; i++) { if(!Voices.voicesMarked.contains(voiceID)) break; voiceID++; } if(!Voices.voicesMarked.contains(voiceID)) { p.sendMessage(""Playing voice "" + voiceID); p.voiceEffect(voiceID++, true); } if(voiceID > Integer.parseInt(args[1])) stop(); tick++; } }, 0, tickDelay); }); Commands.add(Rights.ADMIN, ""tele,tp [x y (z)] or [tileHash] or [z,regionX,regionY,localX,localY]"", ""Teleports the player to a coordinate."", (p, args) -> { if (args[0].contains("","")) { args = args[0].split("",""); int plane = Integer.parseInt(args[0]); int x = Integer.parseInt(args[1]) << 6 | Integer.parseInt(args[3]); int y = Integer.parseInt(args[2]) << 6 | Integer.parseInt(args[4]); p.resetWalkSteps(); p.tele(Tile.of(x, y, plane)); } else if (args.length == 1) { p.resetWalkSteps(); p.tele(Tile.of(Integer.parseInt(args[0]))); } else { p.resetWalkSteps(); p.tele(Tile.of(Integer.parseInt(args[0]), Integer.parseInt(args[1]), args.length >= 3 ? Integer.parseInt(args[2]) : p.getPlane())); } }); Commands.add(Rights.ADMIN, ""teler,tpr [regionId]"", ""Teleports the player to a region id."", (p, args) -> { int regionX = (Integer.parseInt(args[0]) >> 8) * 64 + 32; int regionY = (Integer.parseInt(args[0]) & 0xff) * 64 + 32; p.resetWalkSteps(); p.tele(Tile.of(regionX, regionY, 0)); }); Commands.add(Rights.ADMIN, ""telec,tpc [chunkX chunkY]"", ""Teleports the player to chunk coordinates."", (p, args) -> { int chunkX = Integer.parseInt(args[0]) * 8 + 4; int chunkY = Integer.parseInt(args[1]) * 8 + 4; p.resetWalkSteps(); p.tele(Tile.of(chunkX, chunkY, 0)); }); Commands.add(Rights.ADMIN, ""settitle [new title]"", ""Sets player title."", (p, args) -> { StringBuilder title = new StringBuilder(); for (int i = 0; i < args.length; i++) title.append(args[i]).append((i == args.length - 1) ? """" : "" ""); p.setTitle(title.toString()); p.setTitleColor(null); p.setTitleShading(null); p.getAppearance().generateAppearanceData(); }); Commands.add(Rights.ADMIN, ""cleartitle,deltitle,removetitle"", ""Removes player title."", (p, args) -> { p.setTitle(null); p.setTitleColor(null); p.setTitleShading(null); p.getAppearance().generateAppearanceData(); }); Commands.add(Rights.DEVELOPER, ""dropstobank,bankdrops"", ""Will send all drops recieved from monsters directly to the bank."", (p, args) -> p.getNSV().setB(""sendingDropsToBank"", true)); Commands.add(Rights.DEVELOPER, ""spotanim,gfx [id height]"", ""Creates a spot animation on top of the player."", (p, args) -> p.setNextSpotAnim(new SpotAnim(Integer.parseInt(args[0]), 0, args.length == 1 ? 0 : Integer.parseInt(args[1])))); Commands.add(Settings.getConfig().isDebug() ? Rights.PLAYER : Rights.DEVELOPER, ""anim,emote [id]"", ""Animates the player with specified ID."", (p, args) -> { if (Integer.parseInt(args[0]) > Utils.getAnimationDefinitionsSize()) return; p.setNextAnimation(new Animation(Integer.parseInt(args[0]))); }); Commands.add(Settings.getConfig().isDebug() ? Rights.PLAYER : Rights.DEVELOPER, ""sync,animgfx [id]"", ""Animates the player with specified ID and plays a SpotAnim at the same time."", (p, args) -> { if ((Integer.parseInt(args[0]) > Utils.getAnimationDefinitionsSize()) || (Integer.parseInt(args[1]) > Utils.getSpotAnimDefinitionsSize())) return; p.setNextAnimation(new Animation(Integer.parseInt(args[0]))); p.setNextSpotAnim(new SpotAnim(Integer.parseInt(args[1]))); }); Commands.add(Settings.getConfig().isDebug() ? Rights.PLAYER : Rights.DEVELOPER, ""bas,render [id]"", ""Sets the BAS of the player to specified ID."", (p, args) -> p.getAppearance().setBAS(Integer.parseInt(args[0]))); Commands.add(Rights.DEVELOPER, ""camlook [localX localY z (speed1 speed2)]"", ""Points the camera at the specified tile."", (p, args) -> { if(args.length == 3) p.getPackets().sendCameraLook(Integer.parseInt(args[0]), Integer.parseInt(args[1]), Integer.parseInt(args[2])); else if(args.length == 5) p.getPackets().sendCameraLook(Integer.parseInt(args[0]), Integer.parseInt(args[1]), Integer.parseInt(args[2]), Integer.parseInt(args[3]), Integer.parseInt(args[4])); }); Commands.add(Rights.DEVELOPER, ""campos [localX localY z (speed1 speed2)]"", ""Locks the camera to a specified tile."", (p, args) -> { if(args.length == 3) p.getPackets().sendCameraPos(Integer.parseInt(args[0]), Integer.parseInt(args[1]), Integer.parseInt(args[2])); else if(args.length == 5) p.getPackets().sendCameraPos(Integer.parseInt(args[0]), Integer.parseInt(args[1]), Integer.parseInt(args[2]), Integer.parseInt(args[3]), Integer.parseInt(args[4])); }); Commands.add(Rights.DEVELOPER, ""resetcam"", ""Resets the camera back on the player."", (p, args) -> p.getPackets().sendResetCamera()); Commands.add(Rights.ADMIN, ""spec"", ""Restores special attack energy to full."", (p, args) -> p.getCombatDefinitions().resetSpecialAttack()); Commands.add(Rights.ADMIN, ""bank"", ""Opens the bank."", (p, args) -> p.getBank().open()); Commands.add(Rights.ADMIN, ""empty"", ""Empties the player's inventory."", (p, args) -> { p.stopAll(); p.getInventory().reset(); }); Commands.add(Settings.getConfig().isDebug() ? Rights.PLAYER : Rights.ADMIN, ""tonpc,pnpc,npcme [npcId]"", ""Transforms the player into an NPC."", (p, args) -> { if (Integer.parseInt(args[0]) > Utils.getNPCDefinitionsSize()) return; p.getAppearance().transformIntoNPC(Integer.parseInt(args[0])); }); Commands.add(Rights.ADMIN, ""camshake [slot, v1, v2, v3, v4]"", ""Transforms the player into an NPC."", (p, args) -> p.getPackets().sendCameraShake(Integer.parseInt(args[0]), Integer.parseInt(args[1]), Integer.parseInt(args[2]), Integer.parseInt(args[3]), Integer.parseInt(args[4]))); Commands.add(Settings.getConfig().isDebug() ? Rights.PLAYER : Rights.ADMIN, ""inter [interfaceId]"", ""Opens an interface with specific ID."", (p, args) -> p.getInterfaceManager().sendInterface(Integer.parseInt(args[0]))); Commands.add(Rights.DEVELOPER, ""winter [interfaceId componentId]"", ""Sends an interface to the window specified component."", (p, args) -> { if (Integer.parseInt(args[1]) > Utils.getInterfaceDefinitionsComponentsSize(p.resizeable() ? InterfaceManager.RESIZEABLE_TOP : InterfaceManager.FIXED_TOP)) return; if (p.getNSV().getI(""prevWinterCmd"", -1) != -1) p.getInterfaceManager().removeGameWindowSub(p.getNSV().getI(""prevWinterCmd"", -1), p.getNSV().getI(""prevWinterCmd"", -1)); //inter 115 to test well p.getNSV().setI(""prevWinterCmd"", Integer.parseInt(args[1])); p.getInterfaceManager().sendGameWindowSub(Integer.parseInt(args[1]), Integer.parseInt(args[1]), Integer.parseInt(args[0]), true); }); Commands.add(Rights.ADMIN, ""istrings [interfaceId]"", ""Debugs an interface's text components."", (p, args) -> { int interId = Integer.parseInt(args[0]); p.getInterfaceManager().sendInterface(interId); for (int componentId = 0; componentId < Utils.getInterfaceDefinitionsComponentsSize(interId); componentId++) p.getPackets().setIFText(interId, componentId, """"+componentId); }); Commands.add(Rights.DEVELOPER, ""iftext [interfaceId componentId text]"", ""Sets the text of an interface."", (p, args) -> { int interId = Integer.parseInt(args[0]); int compId = Integer.parseInt(args[1]); String val = args[2]; p.getInterfaceManager().sendInterface(interId); p.getPackets().setIFText(interId, compId, val); }); Commands.add(Rights.DEVELOPER, ""ifgraphic [interfaceId componentId graphicId]"", ""Sets the graphic of an interface."", (p, args) -> { int interId = Integer.parseInt(args[0]); int compId = Integer.parseInt(args[1]); int graphicId = Integer.parseInt(args[2]); p.getPackets().setIFGraphic(interId, compId, graphicId); }); Commands.add(Rights.DEVELOPER, ""imodels [interfaceId]"", ""Debugs an interface's models."", (p, args) -> { int interId = Integer.parseInt(args[0]); p.getInterfaceManager().sendInterface(interId); for (int componentId = 0; componentId < Utils.getInterfaceDefinitionsComponentsSize(interId); componentId++) p.getPackets().setIFModel(interId, componentId, 66); }); Commands.add(Rights.DEVELOPER, ""imodel [interfaceId componentId modelId]"", ""Sends a model to an interface"", (p, args) -> { int interId = Integer.parseInt(args[0]); int compId = Integer.parseInt(args[1]); if (compId > Utils.getInterfaceDefinitionsComponentsSize(interId)) { p.sendMessage(""There are "" + Utils.getInterfaceDefinitionsComponentsSize(interId) + "" components. Too high.""); return; } p.getInterfaceManager().sendInterface(interId); p.getPackets().setIFModel(interId, compId, Integer.parseInt(args[2])); }); Commands.add(Settings.getConfig().isDebug() ? Rights.PLAYER : Rights.DEVELOPER, ""companim [npcId]"", ""Prints out animations compatible with the npc id."", (p, args) -> { if (Integer.parseInt(args[0]) > Utils.getNPCDefinitionsSize()) return; NPCDefinitions defs = NPCDefinitions.getDefs(Integer.parseInt(args[0])); if (defs == null) return; p.getPackets().sendDevConsoleMessage(Integer.parseInt(args[0]) + "": "" + defs.getCompatibleAnimations().toString()); p.sendMessage(Integer.parseInt(args[0]) + "": "" + defs.getCompatibleAnimations().toString()); Logger.debug(MiscTest.class, ""companim"", defs.getCompatibleAnimations().toString()); }); Commands.add(Rights.DEVELOPER, ""varcstr [id value]"", ""Sets a varc string value."", (p, args) -> p.getPackets().sendVarcString(Integer.parseInt(args[0]), Utils.concat(args, 1))); Commands.add(Rights.DEVELOPER, ""varcstrloop [startId endId]"", ""Sets a varc string value."", (p, args) -> { for (int i = Integer.parseInt(args[0]); i < Integer.parseInt(args[1]); i++) { if (i >= Cache.STORE.getIndex(IndexType.CONFIG).getValidFilesCount(ArchiveType.VARC_STRING.getId())) break; p.getPackets().sendVarcString(i, ""str""+i); } }); Commands.add(Rights.DEVELOPER, ""varc [id value]"", ""Sets a varc value."", (p, args) -> p.getPackets().sendVarc(Integer.parseInt(args[0]), Integer.parseInt(args[1]))); Commands.add(Rights.DEVELOPER, ""varcloop [startId endId value]"", ""Sets varc value for all varcs between 2 ids."", (p, args) -> { for (int i = Integer.parseInt(args[0]); i < Integer.parseInt(args[1]); i++) { if (i >= Cache.STORE.getIndex(IndexType.CONFIG).getValidFilesCount(ArchiveType.VARC.getId())) break; p.getPackets().sendVarc(i, Integer.parseInt(args[2])); } }); Commands.add(Rights.DEVELOPER, ""var [id value]"", ""Sets a var value."", (p, args) -> p.getVars().setVar(Integer.parseInt(args[0]), Integer.parseInt(args[1]))); Commands.add(Rights.DEVELOPER, ""getvar [id]"", ""Gets a var value."", (p, args) -> p.getPackets().sendDevConsoleMessage(""Var: "" + Integer.parseInt(args[0]) + "" -> "" + p.getVars().getVar(Integer.parseInt(args[0])))); Commands.add(Rights.DEVELOPER, ""varloop [startId endId value]"", ""Sets var value for all vars between 2 ids."", (p, args) -> { for (int i = Integer.parseInt(args[0]); i < Integer.parseInt(args[1]); i++) { if (i >= Cache.STORE.getIndex(IndexType.CONFIG).getValidFilesCount(ArchiveType.VARS.getId())) break; p.getVars().setVar(i, Integer.parseInt(args[2])); } }); Commands.add(Rights.DEVELOPER, ""getvarbit [id]"", ""Gets a varbit value."", (p, args) -> p.getPackets().sendDevConsoleMessage(""Varbit: "" + Integer.parseInt(args[0]) + "" -> "" + p.getVars().getVarBit(Integer.parseInt(args[0])))); Commands.add(Rights.DEVELOPER, ""varbit [id value]"", ""Sets a varbit value."", (p, args) -> p.getVars().setVarBit(Integer.parseInt(args[0]), Integer.parseInt(args[1]))); Commands.add(Rights.DEVELOPER, ""varbitloop [startId endId value]"", ""Sets varbit value for all varbits between 2 ids."", (p, args) -> { for (int i = Integer.parseInt(args[0]); i < Integer.parseInt(args[1]); i++) { if (i >= Utils.getVarbitDefinitionsSize()) break; p.getVars().setVarBit(i, Integer.parseInt(args[2])); } }); Commands.add(Rights.ADMIN, ""resettask"", ""Resets current slayer task."", (p, args) -> { p.getSlayer().removeTask(); p.updateSlayerTask(); }); Commands.add(Rights.DEVELOPER, ""objectanim,oanim [x y (objectType)]"", ""Makes an object play an animation."", (p, args) -> { GameObject object = args.length == 3 ? World.getObject(Tile.of(Integer.parseInt(args[0]), Integer.parseInt(args[1]), p.getPlane())) : World.getObject(Tile.of(Integer.parseInt(args[0]), Integer.parseInt(args[1]), p.getPlane()), ObjectType.forId(Integer.parseInt(args[2]))); if (object == null) { p.getPackets().sendDevConsoleMessage(""No object was found.""); return; } p.getPackets().sendObjectAnimation(object, new Animation(Integer.parseInt(args[args.length == 3 ? 2 : 3]))); }); Commands.add(Rights.DEVELOPER, ""objectanimloop,oanimloop [x y (startId) (endId)]"", ""Loops through object animations."", (p, args) -> { int x = Integer.parseInt(args[0]); int y = Integer.parseInt(args[1]); GameObject o = ChunkManager.getChunk(Tile.of(x, y, p.getPlane()).getChunkId()).getSpawnedObject(Tile.of(x, y, p.getPlane())); if (o == null) { p.getPackets().sendDevConsoleMessage(""Could not find object at [x="" + x + "", y="" + y + "", z="" + p.getPlane() + ""].""); return; } if (!ObjAnimList.inited()) ObjAnimList.init(); final int start = args.length > 2 ? Integer.parseInt(args[2]) : 10; final int end = args.length > 3 ? Integer.parseInt(args[3]) : 20000; p.getTempAttribs().setI(""loopAnim"", start); WorldTasks.scheduleLooping(new Task() { int anim = p.getTempAttribs().getI(""loopAnim""); @Override public void run() { anim = p.getTempAttribs().getI(""loopAnim""); if (anim >= end || p == null || !p.isRunning() || p.hasFinished()) stop(); else { World.sendObjectAnimation(o, new Animation(anim)); p.sendMessage(""Current animation: "" + anim); } for (int i = anim + 1; i < end; i++) { if (ObjAnimList.isUsed(i)) continue; anim = i; p.getTempAttribs().setI(""loopAnim"", anim); break; } return; } }, 0, 2); }); Commands.add(Rights.ADMIN, ""killme"", ""Kills yourself."", (p, args) -> p.applyHit(new Hit(null, p.getHitpoints(), HitLook.TRUE_DAMAGE))); Commands.add(Rights.DEVELOPER, ""killallstaff"", ""Kills all staff members."", (p, args) -> World.allPlayers(other -> { if (other.hasRights(Rights.ADMIN)) other.applyHit(new Hit(null, p.getHitpoints(), HitLook.TRUE_DAMAGE)); })); Commands.add(Rights.DEVELOPER, ""hidec [interfaceId componentId hidden]"", ""show hide comp."", (p, args) -> p.getPackets().setIFHidden(Integer.parseInt(args[0]), Integer.parseInt(args[1]), Boolean.valueOf(args[2]))); Commands.add(Rights.DEVELOPER, ""ifgraphic [interfaceId componentId graphicId]"", ""interface set graphic."", (p, args) -> p.getPackets().setIFGraphic(Integer.parseInt(args[0]), Integer.parseInt(args[1]), Integer.parseInt(args[2]))); Commands.add(Rights.ADMIN, ""checkclient [player name]"", ""Verifies the user's client."", (p, args) -> { Player target = World.getPlayerByDisplay(args[0]); if (target == null) p.sendMessage(""Couldn't find player.""); else target.queueReflectionAnalysis(new ReflectionAnalysis() .addTest(new ReflectionTest(""Client"", ""validates client class"", new ReflectionCheck(""com.Loader"", ""MAJOR_BUILD""), check -> check.getResponse().getCode() == ResponseCode.SUCCESS && check.getResponse().getStringData().equals(""public static final""))) .addTest(new ReflectionTest(""Loader"", ""validates launcher class"", new ReflectionCheck(""com.darkan.Loader"", ""DOWNLOAD_URL""), check -> check.getResponse().getCode() == ResponseCode.SUCCESS && check.getResponse().getStringData().equals(""public static""))) .addTest(new ReflectionTest(""Player rights"", ""validates player rights client sided"", new ReflectionCheck(""com.jagex.client"", ""PLAYER_RIGHTS"", true), check -> check.getResponse().getCode() == ResponseCode.SUCCESS && check.getResponse().getData() == target.getRights().getCrown())) .addTest(new ReflectionTest(""Lobby port method"", ""validates getPort"", new ReflectionCheck(""com.Loader"", ""I"", ""getPort"", new Object[] { Integer.valueOf(1115) }), check -> check.getResponse().getCode() == ResponseCode.NUMBER && check.getResponse().getData() == 43594)) .addTest(new ReflectionTest(""Local checksum method"", ""validates getLocalChecksum"", new ReflectionCheck(""com.darkan.Download"", ""java.lang.String"", ""getLocalChecksum"", new Object[] { }), check -> check.getResponse().getCode() == ResponseCode.STRING && check.getResponse().getStringData().equals(""e4d95327297ffca1698dff85eda6622d""))) .build()); }); Commands.add(Rights.DEVELOPER, ""getip [player name]"", ""Verifies the user's client."", (p, args) -> World.forceGetPlayerByDisplay(Utils.concat(args), target -> { if (target == null) p.sendMessage(""Couldn't find player.""); else { p.sendMessage(""IP addresses for "" + Utils.concat(args)); for (String ip : target.getIpAddresses()) p.sendMessage("""" + ip); } })); Commands.add(Rights.ADMIN, ""copy [player name]"", ""Copies the other player's levels, equipment, and inventory."", (p, args) -> { Player target = World.getPlayerByDisplay(Utils.concat(args)); if (target == null) { p.sendMessage(""Couldn't find player "" + Utils.concat(args) + "".""); return; } Item[] equip = target.getEquipment().getItemsCopy(); for (int i = 0; i < equip.length; i++) { if (equip[i] == null) continue; p.getEquipment().setSlot(i, new Item(equip[i])); } Item[] inv = target.getInventory().getItems().getItemsCopy(); for (int i = 0; i < inv.length; i++) { if (inv[i] == null) continue; p.getInventory().getItems().set(i, new Item(inv[i])); p.getInventory().refresh(i); } for (int i = 0; i < p.getSkills().getLevels().length; i++) { p.getSkills().set(i, target.getSkills().getLevelForXp(i)); p.getSkills().setXp(i, Skills.getXPForLevel(target.getSkills().getLevelForXp(i))); } p.getAppearance().generateAppearanceData(); }); } }" "package com.rs.game.content.commands.admin; @PluginEventHandler public class PlayerModifiers { @ServerStartupEvent public static void load() { Commands.add(Rights.OWNER, ""setdeveloper,givedeveloper [player name]"", ""Will set a player to developer status."", (p, args) -> { Player target = World.getPlayerByDisplay(Utils.concat(args)); if (target != null) { target.setRights(Rights.DEVELOPER); p.sendMessage(""Successfully gave developer to "" + Utils.formatPlayerNameForDisplay(target.getUsername())); } else p.sendMessage(""Couldn't find player.""); }); Commands.add(Rights.OWNER, ""setadmin,giveadmin [player name]"", ""Will set a player to admin status."", (p, args) -> { Player target = World.getPlayerByDisplay(Utils.concat(args)); if (target != null) { target.setRights(Rights.ADMIN); p.sendMessage(""Successfully gave admin to "" + Utils.formatPlayerNameForDisplay(target.getUsername())); } else p.sendMessage(""Couldn't find player.""); }); Commands.add(Rights.DEVELOPER, ""setmod,givemod [player name]"", ""Will set a player to player moderator status."", (p, args) -> { Player target = World.getPlayerByDisplay(Utils.concat(args)); if (target != null) { target.setRights(Rights.MOD); p.sendMessage(""Successfully gave player moderator to "" + Utils.formatPlayerNameForDisplay(target.getUsername())); } else p.sendMessage(""Couldn't find player.""); }); Commands.add(Rights.DEVELOPER, ""demote [player name]"", ""Will demote a player's mod level to normal player status."", (p, args) -> { Player target = World.getPlayerByDisplay(Utils.concat(args)); if (target != null) { target.setRights(Rights.PLAYER); p.sendMessage(""Successfully demoted "" + Utils.formatPlayerNameForDisplay(target.getUsername())); } else p.sendMessage(""Couldn't find player.""); }); Commands.add(Rights.ADMIN, ""teleto [player name]"", ""Teleports the user to another player without exception."", (p, args) -> { Player target = World.getPlayerByDisplay(Utils.concat(args)); if (target == null) p.sendMessage(""Couldn't find player.""); else p.tele(target.getTile()); }); Commands.add(Rights.ADMIN, ""teletome [player name]"", ""Teleports another player to the user without exception."", (p, args) -> { Player target = World.getPlayerByDisplay(Utils.concat(args)); if (target == null) p.sendMessage(""Couldn't find player.""); else target.tele(p.getTile()); }); Commands.add(Rights.ADMIN, ""kick [player name]"", ""Kicks a player from the game. Will force the player's character out of the game no matter what."", (p, args) -> { Player target = World.getPlayerByDisplay(Utils.concat(args)); if (target == null) { p.sendMessage(Utils.formatPlayerNameForDisplay(Utils.concat(args)) + "" is not logged in.""); return; } p.sendMessage(""Successfully kicked "" + Utils.concat(args) + "".""); target.forceLogout(); }); Commands.add(Rights.ADMIN, ""ban [player_name banDurationDays]"", ""Bans a player for specified number of days."", (p, args) -> World.forceGetPlayerByDisplay(args[0], target -> { if (target != null) { target.getAccount().banDays(Integer.valueOf(args[1])); p.sendMessage(""You have banned "" + Utils.formatPlayerNameForDisplay(Utils.concat(args)) + "" for ""+Integer.valueOf(args[1])+"" days.""); LobbyCommunicator.updatePunishments(target); if (target.hasStarted()) target.getSession().getChannel().close(); } else p.sendMessage(""Unable to find player.""); })); Commands.add(Rights.ADMIN, ""permban [player name]"", ""Bans a player permanently."", (p, args) -> World.forceGetPlayerByDisplay(Utils.concat(args), target -> { if (target != null) { target.getAccount().banPerm(); p.sendMessage(""You have permanently banned "" + Utils.formatPlayerNameForDisplay(Utils.concat(args)) + "".""); if (target.hasStarted()) target.forceLogout(); LobbyCommunicator.updatePunishments(target); } else p.sendMessage(""Unable to find player.""); })); Commands.add(Rights.ADMIN, ""mute [player_name muteDurationDays]"", ""Mutes a player for specified number of days."", (p, args) -> World.forceGetPlayerByDisplay(args[0], target -> { if (target != null) { target.getAccount().muteDays(Integer.valueOf(args[1])); p.sendMessage(""You have muted "" + Utils.formatPlayerNameForDisplay(args[0]) + "" for ""+Integer.valueOf(args[1])+"" days.""); LobbyCommunicator.updatePunishments(target); } else p.sendMessage(""Unable to find player.""); })); Commands.add(Rights.ADMIN, ""permmute [player name]"", ""Bans a player permanently."", (p, args) -> World.forceGetPlayerByDisplay(Utils.concat(args), target -> { if (target != null) { target.getAccount().mutePerm(); p.sendMessage(""You have permanently muted "" + Utils.formatPlayerNameForDisplay(Utils.concat(args)) + "".""); LobbyCommunicator.updatePunishments(target); } else p.sendMessage(""Unable to find player.""); })); Commands.add(Rights.ADMIN, ""unban [player name]"", ""Unbans a player."", (p, args) -> World.forceGetPlayerByDisplay(Utils.concat(args), target -> { if (target != null) p.sendMessage(""You have unbanned "" + Utils.formatPlayerNameForDisplay(Utils.concat(args)) + "".""); else p.sendMessage(""Unable to find player.""); })); Commands.add(Rights.ADMIN, ""unmute [player name]"", ""Unmutes a player."", (p, args) -> World.forceGetPlayerByDisplay(Utils.concat(args), target -> { if (target != null) { target.getAccount().unmute(); p.sendMessage(""You have unmuted "" + Utils.formatPlayerNameForDisplay(Utils.concat(args)) + "".""); LobbyCommunicator.updatePunishments(target); } else p.sendMessage(""Unable to find player.""); })); Commands.add(Rights.ADMIN, ""ipban [player name]"", ""Bans a player permanently and blocks their IP from connecting."", (p, args) -> World.forceGetPlayerByDisplay(Utils.concat(args), target -> { if (target != null) p.sendMessage(""You have IP banned "" + Utils.formatPlayerNameForDisplay(Utils.concat(args)) + "".""); else p.sendMessage(""Unable to find player.""); })); Commands.add(Rights.ADMIN, ""unnull,sendhome [player name]"", ""Forces the player out of a controller and unlocks them hopefully freeing any stuck-ness."", (p, args) -> { Player target = World.getPlayerByDisplay(Utils.concat(args)); if (target == null) p.sendMessage(""Couldn't find player "" + Utils.concat(args) + "".""); else { target.unlock(); target.getControllerManager().forceStop(); if (target.getMoveTile() == null) target.tele(Settings.getConfig().getPlayerRespawnTile()); p.sendMessage(""You have unnulled: "" + target.getDisplayName() + "".""); } }); Commands.add(Rights.ADMIN, ""nextclue [player name]"", ""Moves the player on to the next clue step."", (p, args) -> { Player target = World.getPlayerByDisplay(args[0]); if (target == null) p.sendMessage(""Couldn't find player.""); else { target.getTreasureTrailsManager().setNextClue(0, true); target.sendMessage(""Your clue step has been automatically completed.""); p.sendMessage(""Successfully moved them on to the next clue.""); } }); Commands.add(Rights.ADMIN, ""giveitem [player_name itemId (amount)]"", ""Gives the specified player an item."", (p, args) -> { Player target = World.getPlayerByDisplay(args[0]); if (target == null) p.sendMessage(""Couldn't find player.""); else { target.getInventory().addItem(Integer.valueOf(args[1]), args.length > 1 ? Integer.valueOf(args[2]) : 1); p.sendMessage(""Successfully given them the item..""); } }); Commands.add(Rights.ADMIN, ""givedungtokens [player_name amount]"", ""Gives the specified player dungeoneering tokens."", (p, args) -> { Player target = World.getPlayerByDisplay(args[0]); if (target == null) p.sendMessage(""Couldn't find player.""); else { target.getDungManager().addTokens(Integer.valueOf(args[1])); p.sendMessage(""Successfully given them the item..""); } }); Commands.add(Rights.ADMIN, ""setlevelother [player_name skillId level]"", ""Sets another player's skill to a certainl level."", (p, args) -> World.forceGetPlayerByDisplay(args[0], target -> { int skill = Integer.parseInt(args[1]); int level = Integer.parseInt(args[2]); if (level < 0 || level > (skill == Constants.DUNGEONEERING ? 120 : 99)) { p.sendMessage(""Please choose a valid level.""); return; } if (skill < 0 || skill >= Constants.SKILL_NAME.length) { p.sendMessage(""Please choose a valid skill.""); return; } if (target == null) p.sendMessage(""Couldn't find player.""); else { target.getSkills().set(skill, level); target.getSkills().setXp(skill, Skills.getXPForLevel(level)); target.getAppearance().generateAppearanceData(); WorldDB.getPlayers().save(target, () -> p.sendMessage(""Successfully set players level.."")); } })); Commands.add(Rights.ADMIN, ""givegamebreaker [player_name]"", ""Increments targets Gamebreaking bugs found."", (p, args) -> World.forceGetPlayerByDisplay(args[0], target -> { if (target == null) p.sendMessage(""Couldn't find player.""); else { target.incrementCount(""Gamebreaking bugs found""); p.sendMessage(""Successfully incremented gamebreaking bugs found...""); if (target.getCounterValue(""Gamebreaking bugs found"") == 1) World.sendWorldMessage("""" + target.getDisplayName() + "" has been awarded the Gamebreaker title!"", false); WorldDB.getPlayers().save(target, () -> p.sendMessage(""Successfully gave player gamebreaker title.."")); } })); Commands.add(Rights.ADMIN, ""playerquestreset [player_name questName]"", ""Resets the specified quest for the player"", (p, args) -> { Player player = World.getPlayerByDisplay(args[0]); for (Quest quest : Quest.values()) if (quest.name().toLowerCase().contains(args[1])) { player.getQuestManager().setStage(quest, 0); p.sendMessage(""Reset quest: "" + quest.name() + "" for "" + player.getUsername()); player.sendMessage(""Reset quest: "" + quest.name()); return; } }); Commands.add(Rights.ADMIN, ""setgang [player_name gang]"", ""Sets Player Gang"", (p, args) -> World.forceGetPlayerByDisplay(args[0], target -> { ShieldOfArrav.setGang(target, args[1].toLowerCase()); target.sendMessage(""Set "" + target.getDisplayName() + ""'s gang to "" + args[1].toLowerCase()); })); } }" "package com.rs.game.content.commands.debug; @PluginEventHandler public class Debug { private static boolean musicMoveOn = false; public static EnterChunkHandler visChunks = new EnterChunkHandler(e -> { if (!Settings.getConfig().isDebug()) return; if(musicMoveOn && e.getPlayer() != null && e.getPlayer().hasStarted()) e.getPlayer().sendMessage(""Region: "" + e.getPlayer().getRegionId() + "", Chunk: "" + e.getChunkId() + "", Genre: "" + Music.getGenre(e.getPlayer()).getGenreName()); if (e.getEntity() instanceof Player player) if (player.getNSV().getB(""visChunks"") && player.hasStarted()) { player.devisualizeChunk(e.getEntity().getLastChunkId()); player.visualizeChunk(e.getChunkId()); player.sendMessage(""Chunk: "" + e.getChunkId()); } }); @ServerStartupEvent public static void startup() { if (!Settings.getConfig().isDebug()) return; // Commands.add(Rights.PLAYER, ""example [arg1 (optionalArg2)]"", ""This is an example command to replicate."", (p, args) -> { // // }); Commands.add(Rights.ADMIN, ""shapemusic"", ""Starts showing music shape."", (p, args) -> musicMoveOn = !musicMoveOn); Commands.add(Rights.PLAYER, ""coords,getpos,mypos,pos,loc"", ""Gets the coordinates for the tile."", (p, args) -> { p.sendMessage(""Coords: "" + p.getX() + "","" + p.getY() + "","" + p.getPlane() + "", regionId: "" + p.getRegionId() + "", chunkX: "" + p.getChunkX() + "", chunkY: "" + p.getChunkY()); p.sendMessage(""JagCoords: "" + p.getPlane() + "","" + p.getRegionX() + "","" + p.getRegionY() + "","" + p.getXInScene(p.getSceneBaseChunkId()) + "","" + p.getYInScene(p.getSceneBaseChunkId())); Logger.debug(Debug.class, ""coordsCommand"", ""Tile.of("" + p.getX() + "","" + p.getY() + "","" + p.getPlane() +"")""); }); Commands.add(Rights.PLAYER, ""search,si,itemid [item name]"", ""Searches for items containing the words searched."", (p, args) -> { p.getPackets().sendDevConsoleMessage(""Searching for items containing: "" + Arrays.toString(args)); for (int i = 0; i < Utils.getItemDefinitionsSize(); i++) { boolean contains = true; for (String arg : args) if (!ItemDefinitions.getDefs(i).getName().toLowerCase().contains(arg.toLowerCase()) || ItemDefinitions.getDefs(i).isLended()) { contains = false; continue; } if (contains) p.getPackets().sendDevConsoleMessage(""Result found: "" + i + "" - "" + ItemDefinitions.getDefs(i).getName() + "" "" + (ItemDefinitions.getDefs(i).isNoted() ? ""(noted)"" : """") + """" + (ItemDefinitions.getDefs(i).isLended() ? ""(lent)"" : """")); } }); Commands.add(Rights.PLAYER, ""cutscene2 [id]"", ""Starts crate scene."", (p, args) -> { switch (Integer.valueOf(args[0])) { case 0 -> p.playCutscene(new WallyVSDelrithCutscene()); case 1 -> p.getControllerManager().startController(new PlayerVSDelrithController()); case 2 -> p.getControllerManager().startController(new DragonSlayer_BoatScene()); case 3 -> p.getControllerManager().startController(new MerlinsCrystalCrateScene()); } }); Commands.add(Rights.PLAYER, ""getcontroller"", ""Shows current controller"", (p, args) -> p.sendMessage(""Controller -> "" + (p.getControllerManager().getController() == null ? ""does not exist..."" : p.getControllerManager().getController().getClass().getName()))); Commands.add(Rights.PLAYER, ""fightkiln [wave]"", ""Starts Fight kiln at a wave"", (p, args) -> { if(args.length != 1) { p.sendMessage(""Must be one argument.""); return; } if(p.getControllerManager().getController() != null) { p.sendMessage(""You are already in a minigame, dedicated area(controller)!""); return; } if(Integer.valueOf(args[0]) > 37 || Integer.valueOf(args[0]) < 1) { p.sendMessage(""Invalid wave, must be between 1 and 37.""); return; } p.getControllerManager().startController(new FightKilnController(Integer.valueOf(args[0]), true)); }); Commands.add(Rights.PLAYER, ""random"", ""Forces a random event."", (p, args) -> attemptSpawnRandom(p, true)); Commands.add(Rights.PLAYER, ""fightcaves"", ""Marks fight caves as having been completed."", (p, args) -> p.incrementCount(""Fight Caves clears"")); Commands.add(Rights.PLAYER, ""showhitchance"", ""Toggles the display of your hit chance when attacking opponents."", (p, args) -> { p.getNSV().setB(""hitChance"", !p.getNSV().getB(""hitChance"")); p.sendMessage(""Hit chance display: "" + p.getNSV().getB(""hitChance"")); }); Commands.add(Rights.PLAYER, ""item,spawn [itemId (amount)]"", ""Spawns an item with specified id and amount."", (p, args) -> { if (ItemDefinitions.getDefs(Integer.valueOf(args[0])).getName().equals(""null"")) { p.sendMessage(""That item is unused.""); return; } p.getInventory().addItem(Integer.valueOf(args[0]), args.length >= 2 ? Integer.valueOf(args[1]) : 1); p.stopAll(); }); Commands.add(Rights.PLAYER, ""setqstage [questName, stage]"", ""Sets the specified quest's stage."", (p, args) -> { for (Quest quest : Quest.values()) if (quest.name().toLowerCase().contains(args[0]) && quest.isImplemented()) { int stage = Integer.parseInt(args[1]); p.getQuestManager().setStage(quest, stage); p.sendMessage(""Set "" + quest.name() + "" to stage "" + stage); return; } }); Commands.add(Rights.PLAYER, ""setmqstage [miniquestName, stage]"", ""Sets the specified miniquest's stage."", (p, args) -> { for (Miniquest miniquest : Miniquest.values()) if (miniquest.name().toLowerCase().contains(args[0]) && miniquest.isImplemented()) { int stage = Integer.parseInt(args[1]); p.getMiniquestManager().setStage(miniquest, stage); p.sendMessage(""Set "" + miniquest.name() + "" to stage "" + stage); return; } }); Commands.add(Rights.PLAYER, ""resetquest [questName]"", ""Resets the specified quest."", (p, args) -> { for (Quest quest : Quest.values()) if (quest.name().toLowerCase().contains(args[0]) && quest.isImplemented()) { p.getQuestManager().resetQuest(quest); p.sendMessage(""Reset quest: "" + quest.name()); return; } }); Commands.add(Rights.PLAYER, ""resetminiquest [questName]"", ""Resets the specified miniquest."", (p, args) -> { for (Miniquest miniquest : Miniquest.values()) if (miniquest.name().toLowerCase().contains(args[0]) && miniquest.isImplemented()) { p.getMiniquestManager().reset(miniquest); p.sendMessage(""Reset quest: "" + miniquest.name()); return; } }); Commands.add(Rights.PLAYER, ""completequest [questName]"", ""Completes the specified quest."", (p, args) -> { for (Quest quest : Quest.values()) if (quest.name().toLowerCase().contains(args[0])) { p.getQuestManager().completeQuest(quest); p.sendMessage(""Completed quest: "" + quest.name()); return; } }); Commands.add(Rights.PLAYER, ""completeminiquest [miniquestName]"", ""Completes the specified miniquest."", (p, args) -> { for (Miniquest miniquest : Miniquest.values()) if (miniquest.name().toLowerCase().contains(args[0])) { p.getMiniquestManager().complete(miniquest); p.sendMessage(""Completed quest: "" + miniquest.name()); return; } }); Commands.add(Rights.PLAYER, ""completeallquests"", ""Completes all quests."", (p, args) -> { for (Quest quest : Quest.values()) if (quest.isImplemented()) { p.getQuestManager().completeQuest(quest); p.sendMessage(""Completed quest: "" + quest.name()); } }); Commands.add(Rights.PLAYER, ""resetallquests"", ""Resets all quests."", (p, args) -> { for (Quest quest : Quest.values()) if (quest.isImplemented()) { p.getQuestManager().resetQuest(quest); p.sendMessage(""Reset quest: "" + quest.name()); } }); Commands.add(Rights.PLAYER, ""getmqstage [questName]"", ""Gets the specified miniquest stage."", (p, args) -> { for (Miniquest miniquest : Miniquest.values()) if (miniquest.name().toLowerCase().contains(args[0]) && miniquest.isImplemented()) { int stage = p.getMiniquestStage(miniquest); p.sendMessage(miniquest.name() + "" is at stage "" + stage); return; } }); Commands.add(Rights.PLAYER, ""getqstage [questName]"", ""Gets the specified quest stage."", (p, args) -> { for (Quest quest : Quest.values()) if (quest.name().toLowerCase().contains(args[0]) && quest.isImplemented()) { int stage = p.getQuestManager().getStage(quest); p.sendMessage(quest.name() + "" is at stage "" + stage); return; } }); Commands.add(Rights.PLAYER, ""master,max"", ""Maxes all stats out."", (p, args) -> { for (int skill = 0; skill < 25; skill++) p.getSkills().setXp(skill, 105000000); p.reset(); p.getAppearance().generateAppearanceData(); }); Commands.add(Rights.PLAYER, ""setlevel [skillId level]"", ""Sets a skill to a specified level."", (p, args) -> { if (!p.getEquipment().isEmpty()) { p.sendMessage(""Please unequip everything you're wearing first.""); return; } int skill = Integer.parseInt(args[0]); int level = Integer.parseInt(args[1]); if (level < 0 || level > (skill == Constants.DUNGEONEERING ? 120 : 99)) { p.sendMessage(""Please choose a valid level.""); return; } if (skill < 0 || skill >= Constants.SKILL_NAME.length) { p.sendMessage(""Please choose a valid skill.""); return; } p.getSkills().set(skill, level); p.getSkills().setXp(skill, Skills.getXPForLevel(level)); p.getAppearance().generateAppearanceData(); p.reset(); p.sendMessage(""Successfully set "" + Constants.SKILL_NAME[skill] + "" to "" + level + "".""); }); Commands.add(Rights.PLAYER, ""reset"", ""Resets all stats to 1."", (p, args) -> { for (int skill = 0; skill < 25; skill++) p.getSkills().setXp(skill, 0); p.getSkills().init(); }); Commands.add(Rights.PLAYER, ""spec"", ""Restores special attack energy to full."", (p, args) -> p.getCombatDefinitions().resetSpecialAttack()); Commands.add(Rights.PLAYER, ""copy [player name]"", ""Copies the other player's levels, equipment, and inventory."", (p, args) -> { Player target = World.getPlayerByDisplay(Utils.concat(args)); if (target == null) { p.sendMessage(""Couldn't find player "" + Utils.concat(args) + "".""); return; } Item[] equip = target.getEquipment().getItemsCopy(); for (int i = 0; i < equip.length; i++) { if (equip[i] == null) continue; p.getEquipment().setSlot(i, new Item(equip[i])); p.getEquipment().refresh(i); } Item[] inv = target.getInventory().getItems().getItemsCopy(); for (int i = 0; i < inv.length; i++) { if (inv[i] == null) continue; p.getInventory().getItems().set(i, new Item(inv[i])); p.getInventory().refresh(i); } for (int i = 0; i < p.getSkills().getLevels().length; i++) { p.getSkills().set(i, target.getSkills().getLevelForXp(i)); p.getSkills().setXp(i, Skills.getXPForLevel(target.getSkills().getLevelForXp(i))); } p.getAppearance().generateAppearanceData(); }); Commands.add(Rights.PLAYER, ""spellbook [modern/lunar/ancient]"", ""Switches to modern, lunar, or ancient spellbooks."", (p, args) -> { switch (args[0].toLowerCase()) { case ""modern"": case ""normal"": p.getCombatDefinitions().setSpellbook(Spellbook.MODERN); break; case ""ancient"": case ""ancients"": p.getCombatDefinitions().setSpellbook(Spellbook.ANCIENT); break; case ""lunar"": case ""lunars"": p.getCombatDefinitions().setSpellbook(Spellbook.LUNAR); break; default: p.sendMessage(""Invalid spellbook. Spellbooks are modern, lunar, and ancient.""); break; } }); Commands.add(Rights.PLAYER, ""prayers [normal/curses]"", ""Switches to curses, or normal prayers."", (p, args) -> { switch (args[0].toLowerCase()) { case ""normal"": case ""normals"": p.getPrayer().setPrayerBook(false); break; case ""curses"": case ""ancients"": p.getPrayer().setPrayerBook(true); break; default: p.sendMessage(""Invalid prayer book. Prayer books are normal and curses.""); break; } }); Commands.add(Rights.PLAYER, ""maxbank"", ""Sets all the item counts in the player's bank to 10m."", (p, args) -> { for (Item i : p.getBank().getContainerCopy()) if (i != null) i.setAmount(10500000); }); Commands.add(Rights.PLAYER, ""clearbank,emptybank"", ""Empties the players bank entirely."", (p, args) -> p.sendOptionDialogue(""Clear bank?"", ops -> { ops.add(""Yes"", () -> p.getBank().clear()); ops.add(""No""); })); Commands.add(Rights.PLAYER, ""god"", ""Toggles god mode for the player."", (p, args) -> { boolean god = p.getNSV().getB(""godMode""); p.getNSV().setB(""godMode"", !god); p.sendMessage(""GODMODE: "" + !god); }); Commands.add(Rights.PLAYER, ""infrunes"", ""Toggles infinite runes for the player."", (p, args) -> { p.getNSV().setB(""infRunes"", !p.getNSV().getB(""infRunes"")); p.sendMessage(""INFINITE RUNES: "" + p.getNSV().getB(""infRunes"")); }); Commands.add(Rights.PLAYER, ""deletesave [string/ID]"", ""Deletes save attributes"", (p, args) -> p.delete(args[0])); Commands.add(Rights.PLAYER, ""owner"", ""Makes you owner if your username is the owner."", (p, args) -> { if (p.getUsername().equals(Settings.getConfig().getOwnerName())) { p.setRights(Rights.OWNER); p.sendMessage(""You are owner.""); return; } p.sendMessage(""You are not owner.""); }); Commands.add(Rights.PLAYER, ""infspec"", ""Toggles infinite special attack for the player."", (p, args) -> { boolean spec = p.getNSV().getB(""infSpecialAttack""); p.getNSV().setB(""infSpecialAttack"", !spec); p.sendMessage(""INFINITE SPECIAL ATTACK: "" + !spec); }); Commands.add(Rights.PLAYER, ""infpray"", ""Toggles infinite prayer for the player."", (p, args) -> { boolean spec = p.getNSV().getB(""infPrayer""); p.getNSV().setB(""infPrayer"", !spec); p.sendMessage(""INFINITE PRAYER: "" + !spec); }); Commands.add(Rights.PLAYER, ""startdung [floor, seed, difficulty, size, complexity]"", ""Shows dungeon seed"", (p, args) -> { try { int floor = Integer.parseInt(args[0]); long seed = Long.parseLong(args[1]); int difficulty = Integer.parseInt(args[2]); int size = Integer.parseInt(args[3]); int complexity = Integer.parseInt(args[4]); if (!p.getDungManager().isInsideDungeon()) { Logger.debug(Debug.class, ""startdung"", ""floor: "" + args[0]); Logger.debug(Debug.class, ""startdung"", ""seed: "" + args[1]); Logger.debug(Debug.class, ""startdung"", ""difficulty: "" + args[2]); Logger.debug(Debug.class, ""startdung"", ""size: "" + args[3]); Logger.debug(Debug.class, ""startdung"", ""complexity: "" + args[4]); p.getDungManager().getParty().setFloor(floor); p.getDungManager().getParty().setStartingSeed(seed); p.getDungManager().getParty().setDificulty(difficulty); p.getDungManager().getParty().setSize(size); p.getDungManager().getParty().setComplexity(complexity); p.getDungManager().enterDungeon(false); } else p.getPackets().sendGameMessage(""You are already in a dungeon""); } catch (NullPointerException e) { e.printStackTrace(); p.getPackets().sendGameMessage(""You need to be in a party""); } }); Commands.add(Rights.PLAYER, ""droptest"", ""Drops worn equipment and inventory items to the ground if not null, bound, or a ring of kinship."", (p, args) -> { for (Item item : p.getEquipment().getItemsCopy()) { if (item == null || item.getName().contains(""(b)"") || item.getName().contains(""kinship"")) continue; World.addGroundItem(item, Tile.of(p.getTile())); } for (Item item : p.getInventory().getItems().array()) { if (item != null) Logger.debug(Debug.class, ""droptest"", item.getName() + "": "" + item.getAmount()); if (item == null || item.getName().contains(""(b)"") || item.getName().contains(""kinship"")) continue; World.addGroundItem(item, Tile.of(p.getTile())); } }); Commands.add(Rights.PLAYER, ""tele,tp [x y (z)] or [tileHash] or [z,regionX,regionY,localX,localY]"", ""Teleports the player to a coordinate."", (p, args) -> { if (args[0].contains("","")) { args = args[0].split("",""); int plane = Integer.valueOf(args[0]); int x = Integer.valueOf(args[1]) << 6 | Integer.valueOf(args[3]); int y = Integer.valueOf(args[2]) << 6 | Integer.valueOf(args[4]); p.resetWalkSteps(); p.tele(Tile.of(x, y, plane)); } else if (args.length == 1) { p.resetWalkSteps(); p.tele(Tile.of(Integer.valueOf(args[0]))); } else { p.resetWalkSteps(); p.tele(Tile.of(Integer.valueOf(args[0]), Integer.valueOf(args[1]), args.length >= 3 ? Integer.valueOf(args[2]) : p.getPlane())); } }); // case ""load"": // if (!player.getInterfaceManager().containsInterface(762) || (Boolean) // player.getTemporaryAttributes().get(""viewingOtherBank"") != null && (Boolean) // player.getTemporaryAttributes().get(""viewingOtherBank"") == true) { // player.sendMessage(""You must be in your bank screen to do // this.""); // return true; // } // player.loadLoadout(cmd[1]); // return true; // // case ""saveload"": // player.saveLoadout(cmd[1]); // return true; // // case ""delload"": // player.deleteLoadout(cmd[1]); // return true; // // case ""loadouts"": // player.sendLoadoutText(); // return true; } }" "package com.rs.game.content.commands.mod; @PluginEventHandler public class PlayerModifiers { @ServerStartupEvent public static void loadCommands() { Commands.add(Rights.MOD, ""checkbank [player name]"", ""Displays the contents of another player's bank."", (p, args) -> { if (args.length == 0) { p.getBank().openBankOther(p); return; } World.forceGetPlayerByDisplay(Utils.concat(args), target -> { if (target == null) { p.sendMessage(""Could not find player "" + Utils.concat(args) + "".""); return; } p.getBank().openBankOther(target); }); }); Commands.add(Rights.MOD, ""kick [player name]"", ""Kicks a player from the game. Will not kick through combat."", (p, args) -> { Player target = World.getPlayerByDisplay(Utils.concat(args)); if (target == null) { p.sendMessage(Utils.formatPlayerNameForDisplay(Utils.concat(args)) + "" is not logged in.""); return; } p.sendMessage(""Successfully kicked "" + Utils.concat(args) + "".""); target.getSession().getChannel().close(); }); Commands.add(Rights.MOD, ""ban [player name]"", ""Bans a player for 2 days."", (p, args) -> World.forceGetPlayerByDisplay(Utils.concat(args), target -> { if (target != null) { target.getAccount().banDays(2); p.sendMessage(""You have banned "" + Utils.formatPlayerNameForDisplay(Utils.concat(args)) + "" for 2 days.""); LobbyCommunicator.updatePunishments(target); if (target.hasStarted()) target.getSession().getChannel().close(); } else p.sendMessage(""Unable to find player.""); })); Commands.add(Rights.MOD, ""teleto"", ""Teleports the user to another player as long as they aren't in a controller or locked."", (p, args) -> { if (p.isLocked() || p.getControllerManager().getController() != null) { p.sendMessage(""You cannot tele anywhere from here.""); return; } Player target = World.getPlayerByDisplay(Utils.concat(args)); if (target == null) p.sendMessage(""Couldn't find player.""); else { if (target.isLocked() || target.getControllerManager().getController() != null) { p.sendMessage(""You cannot teleport this player.""); return; } p.tele(target.getTile()); } }); Commands.add(Rights.MOD, ""teletome"", ""Teleports another player to the user as long as they aren't in a controller or locked."", (p, args) -> { Player target = World.getPlayerByDisplay(Utils.concat(args)); if (target == null) p.sendMessage(""Couldn't find player.""); else { if (target.isLocked() || target.getControllerManager().getController() != null) { p.sendMessage(""You cannot teleport this player.""); return; } if (target.hasRights(Rights.DEVELOPER)) { p.sendMessage(""Unable to teleport a developer to you.""); return; } target.tele(p.getTile()); } }); Commands.add(Rights.MOD, ""mute [player name]"", ""Mutes a player for 2 days."", (p, args) -> World.forceGetPlayerByDisplay(Utils.concat(args), target -> { if (target != null) { target.getAccount().muteDays(2); p.sendMessage(""You have muted "" + Utils.formatPlayerNameForDisplay(Utils.concat(args)) + "" for 2 days.""); LobbyCommunicator.updatePunishments(target); } else p.sendMessage(""Unable to find player.""); })); Commands.add(Rights.MOD, ""actions [player_name ...]"", ""Displays the last recorded actions the players specified have done."", Recorder::showConcatenatedActions); Commands.add(Rights.MOD, ""watch [player_name ...]"", ""Continuously displays recorded actions for the players specified."", Recorder::watchPlayers); Commands.add(Rights.MOD, ""stopwatch"", ""Stops watching players."", (p, args) -> p.getNSV().setB(""stopWatchActionLoop"", true)); } }" "package com.rs.game.content.commands.normal; @PluginEventHandler public class Normal { @ServerStartupEvent public static void loadCommands() { Commands.add(Rights.PLAYER, ""commandlist,commands"", ""Displays all the commands the player has permission to use."", (p, args) -> { p.getPackets().setIFText(275, 1, ""Commands List""); int componentId = 10; for (int rights = p.getRights().ordinal(); rights >= 0; rights--) { p.getPackets().setIFText(275, componentId++, """" + Utils.formatPlayerNameForDisplay(Rights.values()[rights].name()) + "" Commands""); for (Command c : Commands.getCommands(Rights.values()[rights])) { if (componentId > 288) break; p.getPackets().setIFText(275, componentId++, ""::"" + c.getUsage()); } } p.getPackets().sendRunScript(1207, componentId - 10); p.getInterfaceManager().sendInterface(275); }); Commands.add(Rights.PLAYER, ""drops [npcId/droptablename numberKilled]"", ""Emulates a number of NPC kills and displays the collected loot."", (p, args) -> { int npcId = -1; try { npcId = Integer.valueOf(args[0]); } catch(Throwable e) { } int npcAmount = Integer.valueOf(args[1].replace(""k"", ""000"")); if (npcId != -1 && (npcId < 0 || npcId > Utils.getNPCDefinitionsSize())) return; if ((npcAmount < 0 || npcAmount > 50000) && !p.hasRights(Rights.DEVELOPER)) { p.sendMessage(""You can only see drops for up to 50000 NPCs.""); return; } if (npcId != -1) NPC.displayDropsFor(p, npcId, npcAmount); else DropTable.displayDropsFor(p, args[0], npcAmount); }); Commands.add(Rights.PLAYER, ""buyoffers"", ""Displays all buy offers currently active in the Grand Exchange."", (p, args) -> WorldDB.getGE().getAllOffersOfType(false, offers -> { p.getPackets().sendRunScript(1207, offers.size()); p.getInterfaceManager().sendInterface(275); p.getPackets().setIFText(275, 1, ""Grand Exchange Buy Offers""); int num = 10; for (Offer offer : offers) { if (num > 288) break; p.getPackets().setIFText(275, num, ""["" + Utils.formatPlayerNameForDisplay(offer.getOwner()) + ""]: "" + offer.amountLeft() + "" "" + ItemDefinitions.getDefs(offer.getItemId()).getName() + "" for "" + offer.getPrice() + "" ea""); num++; } })); Commands.add(Rights.PLAYER, ""selloffers"", ""Displays all sell offers currently active in the Grand Exchange."", (p, args) -> WorldDB.getGE().getAllOffersOfType(true, offers -> { p.getPackets().sendRunScript(1207, offers.size()); p.getInterfaceManager().sendInterface(275); p.getPackets().setIFText(275, 1, ""Grand Exchange Sell Offers""); int num = 10; for (Offer offer : offers) { if (num > 288) break; p.getPackets().setIFText(275, num, ""["" + Utils.formatPlayerNameForDisplay(offer.getOwner()) + ""]: "" + offer.amountLeft() + "" "" + ItemDefinitions.getDefs(offer.getItemId()).getName() + "" for "" + offer.getPrice() + "" ea""); num++; } })); Commands.add(Rights.PLAYER, ""searchnpc,searchn,findnpc,getnpcid [npc name]"", ""Displays all NPC ids containing the query searched."", (p, args) -> { p.getPackets().sendDevConsoleMessage(""Searching for npcs containing name: "" + Utils.concat(args)); for (int i = 0; i < Utils.getNPCDefinitionsSize(); i++) if (NPCDefinitions.getDefs(i).getName().toLowerCase().contains(Utils.concat(args).toLowerCase())) p.getPackets().sendDevConsoleMessage(""Result found: "" + i + "" - "" + NPCDefinitions.getDefs(i).getName() + "" ("" + NPCDefinitions.getDefs(i).combatLevel + "")""); }); // Commands.add(Rights.PLAYER, ""yell,shout [text]"", ""Will broadcast your message to the whole server."", (p, args) -> { // Commands.sendYell(p, Utils.fixChatMessage(Utils.concat(args)), false); // }); // // Commands.add(Rights.PLAYER, ""hideyell"", ""Hides yell from your chat box."", (p, args) -> { // p.setYellOff(!p.isYellOff()); // p.sendMessage(""You have turned "" + (p.isYellOff() ? ""off"" : ""on"") + "" yell.""); // }); Commands.add(Rights.PLAYER, ""ping"", ""Checks your ping if you have gotten it recently."", (p, args) -> p.sendMessage(""Ping: "" + p.getNSV().getI(""ping"", -1))); Commands.add(Rights.PLAYER, ""organizetab"", ""Organizes the currently open tab of your bank by item id"", (p, args) -> p.sendOptionDialogue(""Organize tab "" + p.getBank().getCurrentTab() + ""?"", ops -> { ops.add(""Yes, organize it."", () -> p.getBank().sortCurrentTab()); ops.add(""Nevermind.""); })); Commands.add(Rights.PLAYER, ""dunginfo"", ""Shows dungeon seed"", (p, args) -> { try { int floor = p.getDungManager().getParty().getFloor(); long seed = p.getDungManager().getParty().getDungeon().getDungeon().getSeed(); p.getPackets().sendGameMessage(""floor: "" + String.valueOf(floor)); p.getPackets().sendGameMessage(""seed: "" + String.valueOf(seed)); p.getPackets().sendGameMessage(""difficulty: "" + p.getDungManager().getParty().getDificulty()); p.getPackets().sendGameMessage(""size: "" + p.getDungManager().getParty().getSize()); p.getPackets().sendGameMessage(""complexity: "" + p.getDungManager().getParty().getComplexity()); Logger.debug(Normal.class, ""dungInfo"", ""Dungeon Info:""); Logger.debug(Normal.class, ""dungInfo"", ""floor: "" + String.valueOf(floor)); Logger.debug(Normal.class, ""dungInfo"", ""seed: "" + String.valueOf(seed)); Logger.debug(Normal.class, ""dungInfo"", ""difficulty: "" + p.getDungManager().getParty().getDificulty()); Logger.debug(Normal.class, ""dungInfo"", ""size: "" + p.getDungManager().getParty().getSize()); Logger.debug(Normal.class, ""dungInfo"", ""complexity: "" + p.getDungManager().getParty().getComplexity()); } catch (NullPointerException e) { p.getPackets().sendGameMessage(""You need to be in a dungeon""); } }); } }" "package com.rs.game.content.death; public class DeathOfficeController extends InstancedController { public enum Hub { LUMBRIDGE(Tile.of(3222, 3219, 0)), VARROCK(Tile.of(3212, 3422, 0)), EDGEVILLE(Tile.of(3094, 3502, 0)), FALADOR(Tile.of(2965, 3386, 0)), SEERS_VILLAGE(Tile.of(2725, 3491, 0)), ARDOUGNE(Tile.of(2662, 3305, 0)), YANILLE(Tile.of(2605, 3093, 0)), KELDAGRIM(Tile.of(2845, 10210, 0)) { @Override public boolean meetsRequirements(Player player) { return player.isQuestComplete(Quest.GIANT_DWARF); } }, DORGESH_KAAN(Tile.of(2720, 5351, 0)) { @Override public boolean meetsRequirements(Player player) { return player.isQuestComplete(Quest.DEATH_TO_DORGESHUUN); } }, LLETYA(Tile.of(2341, 3171, 0)) { @Override public boolean meetsRequirements(Player player) { return player.isQuestComplete(Quest.ROVING_ELVES); } }, ETCETERIA(Tile.of(2614, 3894, 0)) { @Override public boolean meetsRequirements(Player player) { return player.isQuestComplete(Quest.THRONE_OF_MISCELLANIA); } }, DAEMONHEIM(Tile.of(3450, 3718, 0)), CANIFIS(Tile.of(3496, 3489, 0)) { @Override public boolean meetsRequirements(Player player) { return player.isQuestComplete(Quest.PRIEST_IN_PERIL); } }, TZHAAR_CITY(Tile.of(4651, 5151, 0)), BURTHORPE(Tile.of(2889, 3528, 0)), AL_KHARID(Tile.of(3275, 3166, 0)), DRAYNOR_VILLAGE(Tile.of(3079, 3250, 0)), //Extra unlocked hubs LUMBRIDGE_CASTLE(Tile.of(3222, 3219, 0)), FALADOR_CASTLE(Tile.of(2971, 3343, 0)), CAMELOT(Tile.of(2758, 3486, 0)), SOUL_WARS(Tile.of(1891, 3177, 0)); private final Tile tile; Hub(Tile tile) { this.tile = tile; } public boolean meetsRequirements(Player player) { return true; } } public static List getUnlockedHubs(Player player) { List hubs = new ArrayList<>(); hubs.add(Hub.LUMBRIDGE_CASTLE); if (player.isQuestComplete(Quest.RECRUITMENT_DRIVE)) { player.getVars().setVarBit(668, 1); hubs.add(Hub.FALADOR_CASTLE); } if (player.isMiniquestComplete(Miniquest.KNIGHTS_WAVE_TRAINING_GROUNDS)) { player.getVars().setVarBit(3910, 1); hubs.add(Hub.CAMELOT); } if (player.isQuestComplete(Quest.NOMADS_REQUIEM)) { player.getVars().setVarBit(6982, 1); hubs.add(Hub.SOUL_WARS); } return hubs; } public static Hub getCurrentHub(Player player, Tile tile) { Hub nearestHub = null; int distance = Integer.MAX_VALUE; for (Hub hub : Hub.values()) { if (hub.ordinal() >= Hub.LUMBRIDGE_CASTLE.ordinal()) break; if (!hub.meetsRequirements(player)) continue; int d = (int) Utils.getDistance(hub.tile, tile); if (d < distance) { distance = d; nearestHub = hub; } } return nearestHub; } public static Hub getRespawnHub(Player player) { return getCurrentHub(player, Tile.of(player.getTile())); } private Integer[][] slots; private Hub defaultHub; private Hub currentHub; private List optionalHubs; private final Tile deathTile; private final boolean hadSkull; public DeathOfficeController(Tile deathTile, boolean hadSkull) { super(Instance.of(deathTile, 2, 2).persist().setEntranceOffset(new int[] { 10, 6, 0 })); this.deathTile = Tile.of(deathTile); this.hadSkull = hadSkull; } @Override public void onBuildInstance() { player.lock(); getInstance().copyMapSinglePlane(246, 662).thenAccept(b -> { player.reset(); getInstance().teleportLocal(player, 10, 6, 0); player.setNextAnimation(new Animation(-1)); player.getMusicsManager().playSongAndUnlock(683); player.getPackets().setBlockMinimapState(2); sendInterfaces(); player.unlock(); }); } @Override public void onDestroyInstance() { player.getPackets().setBlockMinimapState(0); player.getInterfaceManager().sendSubDefaults(InterfaceManager.Sub.TAB_COMBAT, InterfaceManager.Sub.TAB_ACHIEVEMENT, InterfaceManager.Sub.TAB_SKILLS, InterfaceManager.Sub.TAB_INVENTORY, InterfaceManager.Sub.TAB_EQUIPMENT, InterfaceManager.Sub.TAB_PRAYER, InterfaceManager.Sub.TAB_MAGIC, InterfaceManager.Sub.TAB_EMOTES); } @Override public boolean canTakeItem(GroundItem item) { return false; } @Override public boolean canEquip(int slotId, int itemId) { return false; } @Override public boolean canPlayerOption1(Player target) { return false; } @Override public boolean canPlayerOption2(Player target) { return false; } @Override public boolean canPlayerOption3(Player target) { return false; } @Override public boolean canPlayerOption4(Player target) { return false; } @Override public void sendInterfaces() { player.getInterfaceManager().removeSubs(Sub.TAB_COMBAT, Sub.TAB_ACHIEVEMENT, Sub.TAB_SKILLS, Sub.TAB_INVENTORY, Sub.TAB_EQUIPMENT, Sub.TAB_PRAYER, Sub.TAB_MAGIC, Sub.TAB_EMOTES); } @Override public boolean processTeleport(Teleport tele) { return tele.type() == TeleType.OBJECT; } @Override public void onTeleported(TeleType type) { player.getControllerManager().forceStop(); } @Override public boolean processObjectClick1(GameObject object) { if (object.getId() == 45803) { getReadyToRespawn(); return false; } return true; } @Override public boolean processButtonClick(int interfaceId, int componentId, int slotId, int slotId2, ClientPacket packet) { if (interfaceId == 18) { if (componentId == 9) { if (packet == ClientPacket.IF_OP1) unprotect(slotId); } else if (componentId == 17) { if (packet == ClientPacket.IF_OP1) protect(slotId2); } else if (componentId == 45) { int index = slotId-1; if (index < 0) { currentHub = defaultHub; player.getVars().setVarBit(9228, 0); return true; } if (index >= optionalHubs.size()) return false; Hub hub = optionalHubs.get(slotId-1); if (hub == null || !hub.meetsRequirements(player)) return false; currentHub = hub; player.getVars().setVarBit(9228, slotId); } return false; } return true; } public void getReadyToRespawn() { slots = GraveStone.getItemSlotsKeptOnDeath(player, false, hadSkull(), player.getPrayer().isProtectingItem()); currentHub = defaultHub = getCurrentHub(player, getDeathTile()); optionalHubs = getUnlockedHubs(player); player.getInterfaceManager().sendInterface(18); if (slots[0].length > 0) { player.getVars().setVarBit(9227, slots[0].length); player.save(""protectSlots"", slots[0].length); sendProtectedItems(); } else { player.getVars().setVarBit(9222, -1); player.getVars().setVarBit(9227, 1); player.save(""protectSlots"", 1); } player.getVars().setVar(105, -1); //unlocks choose respawn location player.getVars().setVarBit(9231, currentHub.ordinal()); player.getPackets().setIFRightClickOps(18, 9, 0, slots[0].length, 0); player.getPackets().setIFRightClickOps(18, 17, 0, 100, 0); player.getPackets().setIFRightClickOps(18, 45, 0, 6, 0); player.setCloseInterfacesEvent(() -> { synchronized (slots) { player.sendPVEItemsOnDeath(null, getDeathTile(), false, slots); } player.setCloseInterfacesEvent(null); player.getPackets().setBlockMinimapState(0); player.getInterfaceManager().sendSubDefaults(InterfaceManager.Sub.TAB_COMBAT, InterfaceManager.Sub.TAB_ACHIEVEMENT, InterfaceManager.Sub.TAB_SKILLS, InterfaceManager.Sub.TAB_INVENTORY, InterfaceManager.Sub.TAB_EQUIPMENT, InterfaceManager.Sub.TAB_PRAYER, InterfaceManager.Sub.TAB_MAGIC, InterfaceManager.Sub.TAB_EMOTES); Magic.sendObjectTeleportSpell(player, true, currentHub.tile); }); } public void sendProtectedItems() { for (int i = 0; i < getProtectSlots(); i++) player.getVars().setVarBit(9222 + i, i >= slots[0].length ? -1 : slots[0][i]); } public void protect(int itemId) { synchronized (slots) { int slot = -1; for (int i = 0; i < slots[1].length; i++) { Item item = slots[1][i] >= 16 ? player.getInventory().getItem(slots[1][i] - 16) : player.getEquipment().getItem(slots[1][i] - 1); if (item == null) continue; if (item.getId() == itemId) { slot = i; break; } } if (slot == -1 || getProtectSlots() <= slots[0].length) return; slots[0] = Arrays.copyOf(slots[0], slots[0].length + 1); slots[0][slots[0].length - 1] = slots[1][slot]; Integer[] lItems = new Integer[slots[1].length - 1]; System.arraycopy(slots[1], 0, lItems, 0, slot); System.arraycopy(slots[1], slot + 1, lItems, slot, lItems.length - slot); slots[1] = lItems; sendProtectedItems(); } } public void unprotect(int slot) { synchronized (slots) { if (slot >= slots[0].length) return; slots[1] = Arrays.copyOf(slots[1], slots[1].length + 1); slots[1][slots[1].length - 1] = slots[0][slot]; Integer[] pItems = new Integer[slots[0].length - 1]; System.arraycopy(slots[0], 0, pItems, 0, slot); System.arraycopy(slots[0], slot + 1, pItems, slot, pItems.length - slot); slots[0] = pItems; sendProtectedItems(); } } public int getProtectSlots() { return player.get(""protectSlots"") != null ? (Integer) player.get(""protectSlots"") : 1; } public Tile getDeathTile() { return deathTile; } public boolean hadSkull() { return hadSkull; } }" "package com.rs.game.content.death; public class GraveStone extends NPC {// 652 - gravestone selection interface private static final int GRAVE_STONE_INTERFACE = 266; private static final Map GRAVESTONES = new HashMap<>(); public static GraveStone getGraveStoneByUsername(String username) { return GRAVESTONES.get(username); } private final String username; private int ticks; private final String inscription; private final List floorItems; private final int graveStone; private boolean blessed; private final int hintIcon; public GraveStone(Player player, Tile deathTile, Item[] items) { super(getNPCId(player.getGraveStone()), deathTile); graveStone = player.getGraveStone(); setFaceAngle(Utils.getAngleTo(0, -1)); anim(graveStone == 1 ? 7396 : 7394); username = player.getUsername(); ticks = getMaximumTicks(graveStone); inscription = getInscription(player.getDisplayName()); floorItems = new ArrayList<>(); for (Item item : items) { GroundItem i = World.addGroundItem(item, deathTile, player, true, -1, DropMethod.NORMAL, -1); if (i != null) floorItems.add(i); } synchronized (GRAVESTONES) { GraveStone oldStone = getGraveStoneByUsername(username); if (oldStone != null) { addLeftTime(false); oldStone.finish(); } GRAVESTONES.put(player.getUsername(), this); } player.getPackets().sendRunScript(2434, ticks); hintIcon = player.getHintIconsManager().addHintIcon(this, 0, -1, true); player.getPackets().sendVarc(623, deathTile.getTileHash()); player.getPackets().sendVarc(624, 0); player.getPackets().sendVarcString(53, ""Your gravestone marker""); player.sendMessage(""Your items have been dropped at your gravestone, where they'll remain until it crumbles. Look at the world map to help find your gravestone.""); player.sendMessage(""It looks like it'll survive another "" + (ticks / 100) + "" minutes.""); } @Override public void processNPC() { ticks--; if (ticks == 0) decrementGrave(-1, ""Your grave has collapsed!""); else if (ticks == 50) decrementGrave(2, ""Your grave is collapsing.""); else if (ticks == 100) decrementGrave(1, ""Your grave is about to collapse.""); } public void addLeftTime(boolean clean) { if (clean) for (GroundItem item : floorItems) { item.setHiddenTime(Ticks.fromSeconds(60)); item.setDeleteTime(Ticks.fromMinutes(3)); } else for (GroundItem item : floorItems) { item.setHiddenTime(ticks + Ticks.fromSeconds(180)); item.setDeleteTime(Ticks.fromMinutes(6)); } } public List getItems() { return floorItems; } @Override public void finish() { synchronized (GRAVESTONES) { GRAVESTONES.remove(username); } Player player = getPlayer(); if (player != null) { player.getPackets().sendRunScriptReverse(2434, 0); player.getHintIconsManager().removeHintIcon(hintIcon); player.getPackets().sendVarc(623, -1); } super.finish(); } private Player getPlayer() { return World.getPlayerByUsername(username); } public void decrementGrave(int stage, String message) { Player player = getPlayer(); if (player != null) { player.sendMessage("""" + message); player.getPackets().sendRunScriptReverse(2434, ticks); } if (stage == -1) { addLeftTime(true); WorldDB.getLogs().logGrave(username, this); finish(); } else transformIntoNPC(getNPCId(graveStone) + stage); } public void sendGraveInscription(Player reader) { reader.getInterfaceManager().sendInterface(GRAVE_STONE_INTERFACE); reader.getVars().setVarBit(4191, graveStone == 0 ? 0 : 1); if (ticks <= 50) // if the grave is almost broken reader.getPackets().setIFText(GRAVE_STONE_INTERFACE, 22, ""The inscription is too unclear to read.""); else if (reader == getPlayer()) reader.getPackets().setIFText(GRAVE_STONE_INTERFACE, 22, ""It looks like it'll survive another "" + (ticks / 100) + "" minutes. Isn't there something a bit odd about reading your own gravestone?""); else reader.getPackets().setIFText(GRAVE_STONE_INTERFACE, 22, inscription); } public void repair(Player blesser, boolean bless) { if (blesser.getSkills().getLevel(Skills.PRAYER) < (bless ? 70 : 2)) { blesser.sendMessage(""You need "" + (bless ? 70 : 2) + "" prayer to "" + (bless ? ""bless"" : ""repair"") + "" a gravestone.""); return; } if (blesser.getUsername().equals(username)) { blesser.sendMessage(""The gods don't seem to approve of people attempting to "" + (bless ? ""bless"" : ""repair"") + "" their own gravestones.""); return; } if (bless && blessed) { blesser.sendMessage(""This gravestone has already been blessed.""); return; } if (!bless && ticks > 100) { blesser.sendMessage(""This gravestone doesn't seem to need repair.""); return; } ticks += bless ? 6000 : 500; // 5minutes, 1hour blessed = true; decrementGrave(0, blesser.getDisplayName() + ""has "" + (bless ? ""blessed"" : ""repaired"") + "" your gravestone. It should survive another "" + (ticks / 100) + "" minutes.""); blesser.sendMessage(""You "" + (bless ? ""bless"" : ""repair"") + "" the grave.""); blesser.lock(2); blesser.setNextAnimation(new Animation(645)); } public void demolish(final Player demolisher) { if (!demolisher.getUsername().equals(username)) { demolisher.sendMessage(""It would be impolite to demolish someone else's gravestone.""); return; } demolisher.sendOptionDialogue(""Are you sure you want to demolish your gravestone?"", ops -> { ops.add(""Yes (You will have 1 more minute to loot before they go public)"", () -> { addLeftTime(true); finish(); demolisher.sendMessage(""It looks like it'll survive another "" + (ticks / 100) + "" minutes. You demolish it anyway.""); }); ops.add(""No, I have some more items to loot.""); }); } public static int getMaximumTicks(int graveStone) { return switch (graveStone) { case 0 -> 500; case 1, 2 -> 600; case 3 -> 800; case 4, 5, 6, 7, 8, 9, 10, 11 -> 1000; case 12 -> 1200; case 13 -> 1500; default -> 500; }; } private String getInscription(String username) { username = Utils.formatPlayerNameForDisplay(username); return switch (graveStone) { case 0, 1 -> ""In memory of "" + username + "",
who died here.""; case 2, 3 -> ""In loving memory of our dear friend "" + username + "",who
died in this place 69 minutes ago.""; case 4, 5 -> ""In your travels, pause awhile to remember "" + username + "",
who passed away at this spot.""; case 6 -> """" + username + "",
an enlightened servant of Saradomin,
perished in this place.""; case 7 -> """" + username + "",
a most bloodthirsty follower of Zamorak,
perished in this place.""; case 8 -> """" + username + "",
who walked with the Balance of Guthix,
perished in this place.""; case 9 -> """" + username + "",
a vicious warrior dedicated to Bandos,
perished in this place.""; case 10 -> """" + username + "",
a follower of the Law of Armadyl,
perished in this place.""; case 11 -> """" + username + "",
servant of the Unknown Power,
perished in this place.""; case 12 -> ""Ye frail mortals who gaze upon this sight, forget not
the fate of "" + username + "", once mighty, now surrendered to the inescapable grasp of destiny.
Requiescat in pace.""; case 13 -> ""Here lies "" + username + "", friend of dwarves. Great in
life, glorious in death. His/Her name lives on in
song and story.""; default -> ""Cabbage""; }; } /* * the final items after swaping slots return keptItems, dropedItems as we * reset inv and equipment all others will just disapear */ public static Item[][] getItemsKeptOnDeath(Player player, Integer[][] slots) { ArrayList droppedItems = new ArrayList<>(); ArrayList keptItems = new ArrayList<>(); for (int i : slots[0]) { // items kept on death Item item = i >= 16 ? new Item(player.getInventory().getItem(i - 16)) : new Item(player.getEquipment().getItem(i - 1)); if (item.getAmount() > 1) { droppedItems.add(new Item(item.getId(), item.getAmount() - 1)); item.setAmount(1); } keptItems.add(item); } for (int i : slots[1]) { // items droped on death Item item = i >= 16 ? player.getInventory().getItem(i - 16) : player.getEquipment().getItem(i - 1); if (item == null) // shouldnt continue; droppedItems.add(item); } for (int i : slots[2]) { // items protected by default Item item = i >= 16 ? player.getInventory().getItem(i - 16) : player.getEquipment().getItem(i - 1); if (item == null) // shouldnt continue; keptItems.add(item); } return new Item[][] { keptItems.toArray(new Item[0]), droppedItems.toArray(new Item[0]) }; } /* * if (item.getAmount() > 1) { item.setAmount(item.getAmount() - 1); * count++; } else containedItems.remove(count); */ /* * return arrays: items kept on death by default, items dropped on death by * default, items protected by default, items lost by default */ public static Integer[][] getItemSlotsKeptOnDeath(final Player player, boolean atWilderness, boolean skulled, boolean protectPrayer) { ArrayList droppedItems = new ArrayList<>(); ArrayList protectedItems = atWilderness ? null : new ArrayList<>(); ArrayList lostItems = new ArrayList<>(); for (int i = 1; i < 44; i++) { Item item = i >= 16 ? player.getInventory().getItem(i - 16) : player.getEquipment().getItem(i - 1); if (item == null) continue; int stageOnDeath = item.getDefinitions().getStageOnDeath(); if (!atWilderness && stageOnDeath == 1) protectedItems.add(i); else if (stageOnDeath == -1) lostItems.add(i); else droppedItems.add(i); } int keptAmount = skulled ? 0 : 3; if (protectPrayer) keptAmount++; if (droppedItems.size() < keptAmount) keptAmount = droppedItems.size(); droppedItems.sort((o1, o2) -> { Item i1 = o1 >= 16 ? player.getInventory().getItem(o1 - 16) : player.getEquipment().getItem(o1 - 1); Item i2 = o2 >= 16 ? player.getInventory().getItem(o2 - 16) : player.getEquipment().getItem(o2 - 1); int price1 = i1 == null ? 0 : i1.getDefinitions().getValue(); int price2 = i2 == null ? 0 : i2.getDefinitions().getValue(); if (price1 > price2) return -1; if (price1 < price2) return 1; return 0; }); Integer[] keptItems = new Integer[keptAmount]; for (int i = 0; i < keptAmount; i++) keptItems[i] = droppedItems.removeFirst(); return new Integer[][] { keptItems, droppedItems.toArray(new Integer[0]), atWilderness ? new Integer[0] : protectedItems.toArray(new Integer[0]), atWilderness ? new Integer[0] : lostItems.toArray(new Integer[0]) }; } public static int getNPCId(int currentGrave) { return EnumDefinitions.getEnum(1098).getIntValue(currentGrave); } }" "package com.rs.game.content.dnds.eviltree const val NURTURES_PER_STAGE = 25 const val CHOPS_PER_STAGE = 250 const val STAGE_NEW = 0 const val STAGE_NURTURED_LARGER = 3 const val STAGE_LAST_NURTURE = 4 const val STAGE_FULLY_GROWN = 5 const val STAGE_CHOPPED_UP_1 = 6 const val STAGE_CHOPPED_UP_2 = 7 const val STAGE_DEAD = 8 const val KINDLING = 14666 var currentTree: EvilTree? = null var LOCATIONS: List = ArrayList(Location.entries.toTypedArray().asList()) var locIterator = Iterators.peekingIterator(LOCATIONS.iterator()) enum class Type(val wcType: TreeType, val wcReq: Int, val wcXp: Double, val farmReq: Int, val farmXp: Double, val fmReq: Int, val fmXp: Double, val healthyObj: Int, val deg1Obj: Int, val deg2Obj: Int, val dyingObj: Int, val deadObj: Int) { NORMAL(TreeType.NORMAL,1, 15.0, 1, 20.0, 1, 20.0, 11434, 11435, 11436, 11925, 14846), OAK(TreeType.OAK,15, 32.4, 7, 45.0, 15, 30.0, 11437, 11438, 11439, 11926, 14847), WILLOW(TreeType.WILLOW,30, 45.7, 15, 66.0, 30, 45.0, 11440, 11441, 11442, 11927, 14848), MAPLE(TreeType.WILLOW,45, 55.8, 22, 121.5, 45, 67.5, 11443, 11444, 11915, 11928, 14849), YEW(TreeType.WILLOW,60, 87.5, 30, 172.5, 60, 101.25, 11916, 11917, 11918, 11929, 14883), MAGIC(TreeType.TEAK,75, 125.0, 37, 311.5, 75, 151.75, 11919, 11920, 11921, 12711, 14884), ELDER(TreeType.MAPLE,85, 162.5, 42, 730.0, 85, 260.5, 11922, 11923, 11924, 12712, 14885) } enum class Location(val tile: Tile, val desc: String) { SEERS(Tile(2703, 3445, 0), ""the south of Seer's Village""), RIMMINGTON(Tile(2982, 3204, 0), ""the east of Rimmington""), FALADOR(Tile(2991, 3407, 0), ""the north of Falador""), TOLNA_RIFT(Tile(3321, 3454, 0), ""Tolna's Rift""), CATHERBY_WEST(Tile(2750, 3422, 0), ""the west of Catherby""), SEERS_BANK(Tile(2708, 3507, 0), ""the Seers Village bank""), LEGENDS_GUILD(Tile(2724, 3331, 0), ""the Legends' Guild""), MOBILISING_ARMIES(Tile(2470, 2838, 0), ""Mobilising Armies""), DRAYNOR(Tile(3098, 3228, 0), ""Draynor Village""), GNOME_STRONGHOLD(Tile(2404, 3433, 0), ""the Gnome Stronghold""), FALADOR_WEST(Tile(2925, 3378, 0), ""the west of Falador""), EDGEVILLE(Tile(3050, 3458, 0), ""Edgeville""), YANILLE_1(Tile(2604, 3119, 0), ""Yanille""), YANILLE_2(Tile(2521, 3104, 0), ""Yanille""), } @ServerStartupEvent fun schedule() { LOCATIONS = LOCATIONS.shuffled() locIterator = Iterators.peekingIterator(LOCATIONS.iterator()) WorldTasks.scheduleNthHourly(2, ::spawnTree) } fun spawnTree() { currentTree?.despawn() val loc = nextLocation() currentTree = EvilTree(Type.entries.random(), loc, loc.tile) currentTree!!.spawn() //World.sendWorldMessage(""A an evil tree has begun to sprout near ${loc.desc}!"", false) } private fun nextLocation(): Location { if (!locIterator.hasNext()) locIterator = Iterators.peekingIterator(LOCATIONS.iterator()) return locIterator.next() } @ServerStartupEvent fun mapEvilTrees() { onObjectClick(*(11391..11395).union(Type.entries.flatMap { listOf(it.healthyObj, it.deg1Obj, it.deg2Obj, it.deadObj) }).toTypedArray()) { (player, obj, option) -> if (obj !is EvilTree) return@onObjectClick when(option) { ""Nurture"" -> obj.nurture(player) ""Chop"" -> obj.chop(player) ""Light fire"" -> obj.lightFire(player) ""Inspect"" -> obj.inspect(player) ""Take-rewards"" -> obj.takeRewards(player) } } onObjectClick(11428) { (player, obj) -> if (obj !is EvilTree.Root) return@onObjectClick player.faceObject(obj) val hatchet = Hatchet.getBest(player) if (hatchet == null) { player.sendMessage(""You do not have a hatchet that you have the woodcutting level to use."") return@onObjectClick } player.repeatAction(3) { player.anim(hatchet.getAnim(TreeType.NORMAL)) player.faceObject(obj) if (!obj.tree.treeType.wcType.rollSuccess(player.auraManager.woodcuttingMul, player.skills.getLevel(Skills.WOODCUTTING), hatchet)) return@repeatAction !obj.killed player.skills.addXp(Skills.WOODCUTTING, obj.tree.treeType.wcXp / 3) player.inventory.addItemDrop(KINDLING, 1) player.incrementCount(""Evil tree kindling chopped"") obj.chopLife() return@repeatAction !obj.killed } } onNpcClick(418, 419) { (player, npc) -> player.startConversation { options { if (player.getDailyI(""evilTreeChippings"") >= 200) { op(""Are there any more rewards I can claim with my extra kindling?"") { player(HeadE.CONFUSED, ""Are there any more rewards I can claim with my extra kindling?"") options { opExec(""[1000 kindling per hour] Buy more leprechaun banking magic time"") { player.sendInputInteger(""How much kindling would you like to spend?"") { num: Int -> player.sendOptionDialogue { conf: Options -> val adjusted = if (num > player.inventory.getNumberOf(KINDLING)) player.inventory.getNumberOf(KINDLING) else num conf.add(""Spend ${Utils.formatNumber(adjusted)} kindling for ${Utils.ticksToTime((adjusted * 6).toDouble())}"") { if (player.inventory.containsItem(KINDLING, adjusted)) { player.inventory.deleteItem(KINDLING, adjusted) player.extendEffect(Effect.EVIL_TREE_WOODCUTTING_BUFF, adjusted * 6L) } } conf.add(""Nevermind. That's too expensive."") } } } op(""Buy lumberjack outfit pieces (2000 kindling each)"") { fun buyLumberjackItem(player: Player, itemId: Int) { if (!player.inventory.containsItem(KINDLING, 2000)) return player.sendMessage(""You don't have enough kindling to buy that."") player.inventory.deleteItem(KINDLING, 2000) player.inventory.addItemDrop(itemId, 1) } options { op(""Lumberjack hat"") { exec { buyLumberjackItem(player, 10941) } } op(""Lumberjack top"") { exec { buyLumberjackItem(player, 10939) } } op(""Lumberjack legs"") { exec { buyLumberjackItem(player, 10940) } } op(""Lumberjack boots"") { exec { buyLumberjackItem(player, 10933) } } } } } } } op(""Hello, there."") { npc(npc, HeadE.CHEERFUL, if (npc.id == 418) ""'Ello, 'ello, legs."" else ""Ain't you noticed the tree yet? Cut it down!"") player(HeadE.CONFUSED, ""Who are you?"") npc(npc, HeadE.CONFUSED, ""Me? Oo's askin'? I ain't nobody but a leprechaun, innit."") player(HeadE.CONFUSED, ""You sound a bit different from other leprechauns..."") npc(npc, HeadE.ANGRY, ""That's bein' on account a' the fact I was raised by imps, innit. Luvverly chaps, imps. Right geezers."") npc(npc, HeadE.CHEERFUL, ""Anyways, if ya gimme a 'and, ${player.genderTerm(""lad"", ""lass"")}, I can return a favour."") if (npc.id == 418) { npc(npc, HeadE.CHEERFUL, ""I come across this wild root on me wanderin', so I reckoned I'd stick about and get you geezers wif long legs to help nurture it."") npc(npc, HeadE.CHEERFUL, ""The wee thing's growin' fast, but ya'd speed up the process if ya gave it some encouragement."") } else { npc(npc, HeadE.CHEERFUL, ""Anyways, I came across this 'ere root on me wanderin', so I got you geezers wif long legs to 'elp me out."") npc(npc, HeadE.WORRIED, ""Now look what I gots on me 'ands. Please, lad!"") } } } } } instantiateNpc(418, 419) { id, tile -> object : NPC(id, tile) { override fun processNPC() { super.processNPC() if (tickCounter % 30 == 0L && id == 419) forceTalk(when(Utils.random(5)) { 0 -> ""It's getting weaker!"" 1 -> ""Don't stop choppin'!"" 2 -> ""It's on its last legs! I mean... roots!"" 3 -> ""You can do it!"" else -> ""The end is nigh!"" }) } } } onLogin { (player) -> player.vars.setVarBit(1542, if (player.getDailyI(""evilTreeChippings"") >= 200) 0 else 1) } } class EvilTree(val treeType: Type, val location: Location, val centerTile: Tile) : GameObject(11391, ObjectType.SCENERY_INTERACT, 0, centerTile) { private var stage = STAGE_NEW private var stageProgress = 0 private var leprechaun: NPC? = null private val roots: MutableMap = EnumMap(Direction::class.java) private var removed = false private val fires = mapOf( Direction.WEST to GameObject(14887, ObjectType.STRAIGHT_INSIDE_WALL_DEC, 2, tile.transform(-2, 0, 0)), Direction.NORTH to GameObject(15253, ObjectType.STRAIGHT_INSIDE_WALL_DEC, 3, tile.transform(0, 2, 0)), Direction.EAST to GameObject(14888, ObjectType.STRAIGHT_INSIDE_WALL_DEC, 0, tile.transform(2, 0, 0)), Direction.SOUTH to GameObject(15254, ObjectType.STRAIGHT_INSIDE_WALL_DEC, 1, tile.transform(0, -2, 0)), Direction.NORTHWEST to GameObject(14889, ObjectType.DIAGONAL_INSIDE_WALL_DEC, 0, tile.transform(-1, 1, 0)), Direction.SOUTHEAST to GameObject(15255, ObjectType.DIAGONAL_INSIDE_WALL_DEC, 2, tile.transform(1, -1, 0)), Direction.NORTHEAST to GameObject(14890, ObjectType.DIAGONAL_INSIDE_WALL_DEC, 1, tile.transform(1, 1, 0)), Direction.SOUTHWEST to GameObject(15491, ObjectType.DIAGONAL_INSIDE_WALL_DEC, 3, tile.transform(-1, -1, 0)), ) class Root(val tree: EvilTree, val dir: Direction, var life: Int = Utils.random(3, 8)) : GameObject(11427, ObjectType.SCENERY_INTERACT, 0, tree.centerTile.transform(dir.dx*2, dir.dy*2)) { var killed = false fun chopLife() { if (life-- <= 0) kill() } override fun process(): Boolean { return !killed } fun kill() { killed = true World.removeObject(this) World.sendSpotAnim(this.tile, 315) tree.roots.remove(dir) } } override fun process(): Boolean { if (removed) return false if (World.getServerTicks() % 10 == 0L) World.getPlayersInChunkRange(tile.chunkId, 4) .filter { !it.tempAttribs.getB(""notified$treeType"") } .forEach { World.sendSpotAnim(it.tile, 314) it.forceTalk(""What was that??"") it.tempAttribs.setB(""notified$treeType"", true) } if (World.getServerTicks() % 2 == 0L) World.getPlayersInChunkRange(tile.chunkId, 1) .filter { player -> player.withinDistance(centerTile, 2) && roots.values.any { player.withinDistance(it.tile, 1) } } .forEach { knockAway(it) } if (World.getServerTicks() % 50 == 0L && stage >= 5 && stage < 8) spawnRandomRoot() return true } fun spawn() { World.spawnObject(this) flagForProcess() fires.values.forEach { World.spawnObject(it) } leprechaun = NPC(418, centerTile.transform(0, 3)) } fun despawn() { leprechaun?.finish() World.removeObject(this) removed = true fires.values.forEach { World.removeObject(it) } roots.values.forEach { it.kill() } } fun spawnRandomRoot() { val freeDirections = Direction.entries.toTypedArray().filter { it !in roots.keys } if (freeDirections.isNotEmpty()) spawnRoot(freeDirections[Utils.random(freeDirections.size)]) } fun spawnRoot(dir: Direction) { val root = Root(this, dir) World.spawnObject(root) roots[dir] = root WorldTasks.schedule(2) { root.setId(11428) } root.flagForProcess() World.getPlayersInChunkRange(tile.chunkId, 1) .filter { it.withinDistance(centerTile, 2) && it.withinDistance(root.tile, 1) } .forEach { knockAway(it) } } fun inspect(player: Player) { fun stageDescText(): String { return when(stage) { 0, 1, 2, 3, 4 -> ""It is currently ${Utils.formatDouble((stageProgress.toDouble() / NURTURES_PER_STAGE.toDouble()) * 100.0)}% to the next stage."" 5, 6, 7 -> ""It is currently ${Utils.formatDouble((stageProgress.toDouble() / CHOPS_PER_STAGE.toDouble()) * 100.0)}% to the next stage."" else -> ""It's dead."" } } player.simpleDialogue(""It's an evil ${treeType.name.lowercase()} tree${if(stage >= STAGE_FULLY_GROWN) """" else "" sapling""}.
${stageDescText()}"") } fun nurture(player: Player) { if (player.skills.getLevel(Skills.FARMING) < treeType.farmReq) { player.sendMessage(""You need a farming level of ${treeType.farmReq} to nurture this tree."") return } player.repeatAction(5) { player.faceTile(this.coordFace) player.anim(3114) player.skills.addXp(Skills.FARMING, treeType.farmXp / 5.0) incProgress() return@repeatAction !removed && stage < 5 } } val ceilNegs: (Float) -> Float = { if (it < 0) ceil(it) - 1 else ceil(it) } fun lightFire(player: Player) { if (player.skills.getLevel(Skills.FIREMAKING) < treeType.fmReq) { player.sendMessage(""You need a firemaking level of ${treeType.fmReq} to burn this tree."") return } if (!player.inventory.containsItem(KINDLING)) { player.sendMessage(""You need some wood chippings to light on fire."") return } val fire = fires[getDirectionFromTree(player)] if (fire == null) { player.sendMessage(""You can't light a fire here."") return } if (player.vars.getVarBit(fire.definitions.varpBit) != 0) { player.sendMessage(""You've already lit a fire here."") return } player.anim(16700) player.skills.addXp(Skills.FIREMAKING, treeType.fmXp) player.inventory.deleteItem(KINDLING, 1) player.vars.setVarBit(fire.definitions.varpBit, 1) } private fun getDirectionFromTree(player: Player): Direction { val sub = player.getMiddleTileAsVector().sub(Vec2(centerTile)) sub.norm() return Direction.forDelta(ceilNegs(sub.x).toInt(), ceilNegs(sub.y).toInt()) ?: Direction.WEST } private fun knockAway(player: Player) { player.stopAll() val moveDir = getDirectionFromTree(player) player.forceMove(player.transform(moveDir.dx, moveDir.dy), Direction.rotateClockwise(moveDir, 4), 10070, 0, 60) } fun chop(player: Player) { if (player.skills.getLevel(Skills.WOODCUTTING) < treeType.wcReq) { player.sendMessage(""You need a woodcutting level of ${treeType.wcReq} to chop this tree."") return } player.actionManager.setAction(object: PlayerAction() { val hatchet = Hatchet.getBest(player) override fun start(player: Player): Boolean { player.actionManager.actionDelay = 3 player.faceObject(this@EvilTree) if (hatchet == null) { player.sendMessage(""You do not have a hatchet that you have the woodcutting level to use."") return false } return true } override fun process(player: Player): Boolean { player.faceObject(this@EvilTree) player.anim(hatchet.getAnim(TreeType.NORMAL)) return !this@EvilTree.removed && this@EvilTree.stage < STAGE_DEAD } override fun processWithDelay(player: Player): Int { if (!treeType.wcType.rollSuccess(player.auraManager.woodcuttingMul, player.skills.getLevel(Skills.WOODCUTTING), hatchet)) return 3 player.skills.addXp(Skills.WOODCUTTING, treeType.wcXp) player.inventory.addItemDrop(KINDLING, 1) player.incrementCount(""Evil tree kindling chopped"") this@EvilTree.incProgress() return 3 } override fun stop(player: Player) { player.anim(-1) } }) } fun takeRewards(player: Player) { if (player.skills.getLevel(Skills.WOODCUTTING) < treeType.wcReq) { player.sendMessage(""You need a woodcutting level of ${treeType.wcReq} to claim rewards from this tree."") return } if (player.getDailyI(""evilTreeChippings"") >= 200) { player.sendMessage(""You have already looted all you can from evil trees today."") return } if (player.inventory.containsItem(KINDLING, 1)) { val toHandIn = minOf(player.inventory.getNumberOf(KINDLING), 200 - player.getDailyI(""evilTreeChippings"")) if (toHandIn <= 0) return player.inventory.deleteItem(KINDLING, toHandIn) val coins = (when(treeType) { Type.OAK -> 652.0 Type.WILLOW -> 2254.0 Type.MAPLE -> 2560.0 Type.YEW -> 4668.0 Type.MAGIC -> 9474.0 Type.ELDER -> 17388.0 else -> 370.0 } * (toHandIn.toDouble() / 200.0)).toInt() val logs = when(treeType) { Type.OAK -> Item(1522, (48.0 * (toHandIn.toDouble() / 200.0)).toInt()) Type.WILLOW -> Item(1520, (452.0 * (toHandIn.toDouble() / 200.0)).toInt()) Type.MAPLE -> Item(1518, (262.0 * (toHandIn.toDouble() / 200.0)).toInt()) Type.YEW -> Item(1516, (34.0 * (toHandIn.toDouble() / 200.0)).toInt()) Type.MAGIC -> Item(1514, (20.0 * (toHandIn.toDouble() / 200.0)).toInt()) Type.ELDER -> when(Utils.random(4)) { 0 -> Item(1514, 36) 1 -> Item(1516, 118) 2 -> Item(8836, 204) else -> Item(6334, 750) } else -> Item(1512, (24.0 * (toHandIn.toDouble() / 200.0)).toInt()) } player.extendEffect(Effect.EVIL_TREE_WOODCUTTING_BUFF, (Ticks.fromMinutes(30).toDouble() * (toHandIn.toDouble() / 200.0)).toLong()) if (coins > 0) player.inventory.addCoins(coins) if (logs.amount > 0) player.inventory.addItemDrop(logs) player.setDailyI(""evilTreeChippings"", player.getDailyI(""evilTreeChippings"", 0) + toHandIn) if (player.getDailyI(""evilTreeChippings"") >= 200) player.vars.setVarBit(1542, 1) } } private fun incProgress() { val threshold = if (stage < STAGE_FULLY_GROWN) NURTURES_PER_STAGE else CHOPS_PER_STAGE if (++stageProgress >= threshold) { incStage() stageProgress = 0 } } private fun incStage() { if (stage >= STAGE_DEAD) return if (++stage == STAGE_NURTURED_LARGER) { World.removeObject(this) id += 1 tile = tile.transform(-1, -1) World.spawnObject(this) World.getPlayersInChunkRange(tile.chunkId, 1) .filter { it.withinDistance(centerTile, 1) } .forEach { knockAway(it) } return } if (stage == STAGE_DEAD) { leprechaun?.transformIntoNPC(418) val varbits = fires.values.map { it.definitions.varpBit } fires.values.forEach { World.removeObject(it) } roots.values.forEach { it.kill() } World.getPlayersInChunkRange(tile.chunkId, 1) .forEach { player -> varbits.forEach { varbit -> player.vars.setVarBit(varbit, 0) } } WorldTasks.schedule(10) { setId(treeType.deadObj) } } if (stage == STAGE_FULLY_GROWN) { leprechaun?.transformIntoNPC(419) Direction.entries.forEach { spawnRoot(it) } } if (stage <= STAGE_LAST_NURTURE) setId(id + 1) else setId(when(stage) { STAGE_FULLY_GROWN -> treeType.healthyObj STAGE_CHOPPED_UP_1 -> treeType.deg1Obj STAGE_CHOPPED_UP_2 -> treeType.deg2Obj else -> treeType.dyingObj }) } } fun handleEvilTreeOps(player: Player, ops: Options, evilTreeHead: Int) { ops.add(""Are there any Evil Trees you can help me find?"") { player.startConversation { player(HeadE.CONFUSED, ""Are there any Evil Trees you can help me find?"") if (currentTree == null) { npc(evilTreeHead, HeadE.CALM_TALK, ""The taint of the evil tree is not currently on the land. There won't be another for a little while."") return@startConversation } npc(evilTreeHead, HeadE.CALM_TALK, ""An evil tree is currently growing near "" + currentTree!!.location.desc + ""! The taint of the next I sense near "" + (if (!locIterator.hasNext()) LOCATIONS.first() else locIterator.peek()).desc + ""."") npc(evilTreeHead, HeadE.CONFUSED, ""Would you like me to teleport you directly there?"") options { opExec(""Yes, please."") { SpiritTree.sendTeleport(player, World.findClosestAdjacentFreeTile(currentTree!!.location.tile, 5)) } op(""Nevermind."") } } } }" "package com.rs.game.content.dnds.shootingstar; @PluginEventHandler public class ShootingStars { public enum Location { AL_KHARID(Tile.of(3286, 3197, 0), ""Al Kharid""), LUMBRIDGE_SWAMP(Tile.of(3217, 3189, 0), ""Lumbridge Swamp""), DRAYNOR(Tile.of(3076, 3278, 0), ""Draynor Village""), RIMMINGTON(Tile.of(2972, 3249, 0), ""Rimmington""), FALADOR(Tile.of(2966, 3379, 0), ""Falador""), DWARVEN_MINE(Tile.of(3017, 3445, 0), ""Ice Mountain""), EDGEVILLE(Tile.of(3045, 3515, 0), ""Edgeville""), CHAMPIONS_GUILD(Tile.of(3167, 3362, 0), ""the Champion's Guild""), GRAND_EXCHANGE(Tile.of(3136, 3456, 0), ""the Grand Exchange""), BARBARIAN_VILLAGE(Tile.of(3064, 3434, 0), ""Barbarian Village""), CATHERBY(Tile.of(2783, 3465, 0), ""Catherby""), RANGING_GUILD(Tile.of(2688, 3443, 0), ""the Ranging Guild""), FISHING_GUILD(Tile.of(2594, 3386, 0), ""the Fishing Guild""), CLOCK_TOWER(Tile.of(2580, 3244, 0), ""the clocktower""), FIGHT_ARENA(Tile.of(2563, 3202, 0), ""the Fight Arena""), YANILLE(Tile.of(2533, 3079, 0), ""Yanille""), CASTLE_WARS(Tile.of(2456, 3104, 0), ""Castle Wars""), MOBILISING_ARMIES(Tile.of(2408, 2853, 0), ""Mobilising Armies""), PHOENIX_LAIR(Tile.of(2285, 3625, 0), ""the Phoenix Lair""), BARBARIAN_ASSAULT(Tile.of(2542, 3559, 0), ""Barbarian Assault""), LEGENDS_GUILD(Tile.of(2742, 3390, 0), ""the Legend's Guild""), KARAMJA_GOLD_MINE(Tile.of(2736, 3222, 0), ""the Brimhaven gold mine""), TAI_BWO_WANNAI_JUNGLE(Tile.of(2835, 3047, 0), ""Tai Bwo Wannai jungle""), MUDSKIPPER_POINT(Tile.of(2996, 3124, 0), ""Mudskipper Point""), KARAMJA_VOLCANO(Tile.of(2824, 3170, 0), ""the Karamja volcano""), VARROCK_SOUTHEAST_MINE(Tile.of(3290, 3352, 0), ""the Varrock south-east mine""), AL_KHARID_MINE(Tile.of(3299, 3276, 0), ""the Al-Kharid mine""), NARDAH(Tile.of(3433, 2915, 0), ""Nardah""), POLLNIVNEACH(Tile.of(3348, 3014, 0), ""Pollnivneach""), FREMENNIK_SLAYER_DUNGEON(Tile.of(2773, 3595, 0), ""the Fremennik Slayer Dungeon""), RELLEKKA(Tile.of(2687, 3691, 0), ""Rellekka""), PARTY_ROOM(Tile.of(3026, 3365, 0), ""the Party Room""), LUMBRIDGE_CASTLE(Tile.of(3209, 3203, 0), ""Lumbridge Castle""), ; public final Tile tile; public final String description; Location(Tile tile, String description) { this.tile = tile; this.description = description; } } private static Star currentStar = null; private static final List LOCATIONS = new ArrayList<>(Arrays.stream(Location.values()).toList()); private static PeekingIterator locIterator = Iterators.peekingIterator(LOCATIONS.iterator()); @ServerStartupEvent public static void schedule() { Collections.shuffle(LOCATIONS); locIterator = Iterators.peekingIterator(LOCATIONS.iterator()); WorldTasks.scheduleNthHourly(2, ShootingStars::spawnStar); } public static void spawnStar() { if (currentStar != null) currentStar.destroy(); currentStar = new Star(Utils.random(0, 9), nextLocation()); } private static Location nextLocation() { if (!locIterator.hasNext()) locIterator = Iterators.peekingIterator(LOCATIONS.iterator()); return locIterator.next(); } public static void viewTelescope(Player player) { player.getInterfaceManager().sendInterface(782); player.startConversation(new Dialogue()); player.simpleDialogue((currentStar != null ? ""A star recently crashed near "" + currentStar.location.description + ""! "" : """") + ""The next star looks like it's going to land near "" + (!locIterator.hasNext() ? LOCATIONS.getFirst() : locIterator.peek()).description + "".""); } public static void addDiscoveredStar(Star star, String displayName) { Map discoveries = World.getData().getAttribs().getO(""shootingStarDiscoveries""); if (discoveries == null) discoveries = new LinkedTreeMap<>(); discoveries.put(Long.toString(star.landingTime), displayName); Map sortedDiscoveries = new LinkedTreeMap<>(); discoveries.entrySet().stream() .sorted((entry1, entry2) -> Long.compare(Long.parseLong(entry2.getKey()), Long.parseLong(entry1.getKey()))) .limit(5) .forEachOrdered(entry -> sortedDiscoveries.put(entry.getKey(), entry.getValue())); World.getData().getAttribs().setO(""shootingStarDiscoveries"", sortedDiscoveries); } public static ObjectClickHandler handleNoticeboard = new ObjectClickHandler(new Object[] { 38669 }, e -> { Map discoveries = World.getData().getAttribs().getO(""shootingStarDiscoveries""); if (discoveries == null) discoveries = new HashMap<>(); int idx = 0; for (String time : discoveries.keySet()) { if (++idx > 5) continue; e.getPlayer().getPackets().setIFText(787, 5 + idx, ""Crashed "" + Utils.ticksToTime(World.getServerTicks() - Long.parseLong(time)).replace(""."", """") + "" ago""); e.getPlayer().getPackets().setIFText(787, 10 + idx, discoveries.get(time)); } e.getPlayer().getInterfaceManager().sendInterface(787); }); public static ObjectClickHandler handleStarClick = new ObjectClickHandler(new Object[] { ""Crashed star"" }, e -> { if (!(e.getObject() instanceof Star star)) { e.getPlayer().sendMessage(""Star is not a real star. Report this to a staff member.""); return; } if (star.getTier() < 1 || star.getTier() > 9) { e.getPlayer().sendMessage(""Invalid star tier "" + star.getTier()); return; } switch(e.getOption()) { case ""Prospect"" -> e.getPlayer().simpleDialogue(""It's a size "" + star.getTier() + "" star. It looks like it has about "" + star.getLife() + ""% of this layer remaining.""); case ""Mine"" -> { if (!star.discovered) { star.discovered = true; e.getPlayer().getSkills().addXp(Skills.MINING, e.getPlayer().getSkills().getLevelForXp(Skills.MINING) * 75); e.getPlayer().simpleDialogue(""Congratulations, you were the first to find this star! You receive "" + Utils.formatNumber(e.getPlayer().getSkills().getLevelForXp(Skills.MINING) * 75) + "" Mining XP as a reward.""); ShootingStars.addDiscoveredStar(star, e.getPlayer().getDisplayName()); return; } e.getPlayer().getActionManager().setAction(new Mining(RockType.valueOf(""CRASHED_STAR_"" + star.getTier()), e.getObject())); } } }); public static NPCClickHandler handleStarSprite = new NPCClickHandler(new Object[] { 8091 }, e -> { e.getNPC().resetDirection(); if (e.getPlayer().getDailyI(""stardustHandedIn"") < 200 && e.getPlayer().getInventory().containsItem(13727, 1)) { int toHandIn = e.getPlayer().getInventory().getNumberOf(13727); int canHandIn = 200 - e.getPlayer().getDailyI(""stardustHandedIn"", 0); if (toHandIn > canHandIn) toHandIn = canHandIn; if (toHandIn <= 0) return; int coins = (int) (50002.0 * ((double) toHandIn / 200.0)); int cosmics = (int) (152.0 * ((double) toHandIn / 200.0)); int astrals = (int) (52.0 * ((double) toHandIn / 200.0)); int gold = (int) (20.0 * ((double) toHandIn / 200.0)); int ticks = (int) (Ticks.fromMinutes(15) * ((double) toHandIn / 200.0)); e.getPlayer().getInventory().deleteItem(13727, toHandIn); e.getPlayer().getInventory().addCoins(coins); e.getPlayer().getInventory().addItemDrop(564, cosmics); e.getPlayer().getInventory().addItemDrop(9075, astrals); e.getPlayer().getInventory().addItemDrop(445, gold); e.getPlayer().addEffect(Effect.SHOOTING_STAR_MINING_BUFF, ticks); e.getPlayer().setDailyI(""stardustHandedIn"", e.getPlayer().getDailyI(""stardustHandedIn"", 0) + toHandIn); e.getPlayer().startConversation(new Dialogue() .addNPC(e.getNPCId(), HeadE.CHEERFUL, ""Thank you for helping me out of here."") .addNPC(e.getNPCId(), HeadE.CHEERFUL, ""I have rewarded you by making it so you can mine extra ore for the next "" + Utils.ticksToTime(ticks)) .addNPC(e.getNPCId(), HeadE.CHEERFUL, ""Also, have "" + cosmics +"" cosmic runes, "" + astrals + "" astral runes, "" + gold + "" gold ore and "" + Utils.formatNumber(coins) + "" coins."")); } else e.getPlayer().startConversation(new Dialogue() .addNPC(e.getNPCId(), HeadE.CHEERFUL, ""Hello, strange creature."") .addOptions(ops -> { ops.add(""What are you? Where did you come from?"") .addPlayer(HeadE.CONFUSED, ""What are you? Where did you come from?"") .addNPC(e.getNPCId(), HeadE.CHEERFUL, ""I'm a star sprite! I was in my star in the sky, when it lost control and crashed into the ground. With half my star sticking in the ground, I became stuck. Fortunately, I was mined out by the kind creatures of your race."") .addOptions(moreOps -> { moreOps.add(""What's a star sprite?"") .addPlayer(HeadE.CONFUSED, ""What's a star sprite?"") .addNPC(e.getNPCId(), HeadE.CHEERFUL, ""We're what makes the stars in the sky shine. I made this star shine when it was in the sky.""); moreOps.add(""What are you going to do without your star?"") .addPlayer(HeadE.CONFUSED, ""What are you going to do without your star?"") .addNPC(e.getNPCId(), HeadE.CHEERFUL, ""Don't worry about me. I'm sure I'll find some good rocks around here and get back up into the sky in no time.""); moreOps.add(""I thought stars were huge balls of burning gas."") .addPlayer(HeadE.CALM_TALK, ""I thought stars were huge balls of burning gas."") .addNPC(e.getNPCId(), HeadE.CHEERFUL, ""Most of them are, but a lot of shooting stars on this plane of the multiverse are rocks with star sprites in them.""); moreOps.add(""Well, I'm glad you're okay."") .addPlayer(HeadE.CHEERFUL, ""Well, I'm glad you're okay."") .addNPC(e.getNPCId(), HeadE.CHEERFUL, ""Thank you.""); }); ops.add(""Hello, strange glowing creature."") .addPlayer(HeadE.CHEERFUL, ""Hello, strange glowing creature."") .addNPC(e.getNPCId(), HeadE.CONFUSED, ""Isn't that funny? One of the things I find odd about you is that you DON'T glow.""); ops.add(""I'm not strange."") .addPlayer(HeadE.CONFUSED, ""I'm not strange."") .addNPC(e.getNPCId(), HeadE.CHEERFUL, ""Hehe. If you say so.""); if (e.getPlayer().getInventory().containsItem(13727)) ops.add(""Are there any more rewards I can redeem for extra dust?"") .addOptions(rewards -> { rewards.add(""[1000 dust per hour] Buy more star sprite mining buff time"", () -> e.getPlayer().sendInputInteger(""How much dust would you like to spend?"", num -> e.getPlayer().sendOptionDialogue(conf -> { final int adjusted = Math.min(num, e.getPlayer().getInventory().getNumberOf(13727)); conf.add(""Spend "" + Utils.formatNumber(adjusted) + "" stardust for "" + Utils.ticksToTime(adjusted*6), () -> { if (e.getPlayer().getInventory().containsItem(13727, adjusted)) { e.getPlayer().getInventory().deleteItem(13727, adjusted); e.getPlayer().extendEffect(Effect.SHOOTING_STAR_MINING_BUFF, adjusted * 6L); } }); conf.add(""Nevermind. That's too expensive.""); }))); rewards.add(""Open stardust shop"", () -> ShopsHandler.openShop(e.getPlayer(), ""stardust_shop"")); }); })); }); }" "package com.rs.game.content.dnds.shootingstar; public class Star extends GameObject { public NPC sprite; public final long landingTime; public final ShootingStars.Location location; public boolean discovered = false; public int life = 0; public boolean minedThisTick = false; public Star(int tier, ShootingStars.Location location) { super(38668-tier, ObjectType.SCENERY_INTERACT, 0, location.tile); this.location = location; this.landingTime = World.getServerTicks(); //World.sendWorldMessage(""A shooting star has crashed near "" + location.description + ""!"", false); World.spawnObject(this); Chunk chunk = ChunkManager.getChunk(getTile().getChunkId(), true); chunk.flagForProcess(this); life = getMaxLife(); ShootingStars.addDiscoveredStar(this, ""Not discovered yet...""); } public int getTier() { return 10-(id-38659); } public void degrade() { if (id >= 38668) { spawnSprite(); setId(38670); return; } setId(id+1); life = getMaxLife(); } public int getMaxLife() { return (int) (2258.2932 * (Math.pow(0.5726, getTier()))); } public String getLife() { return Utils.formatDouble((double) life / (double) getMaxLife() * 100.0); } @Override public boolean process() { if (life <= -1) return false; if (minedThisTick && life > 0) { if (--life <= 0) degrade(); minedThisTick = false; } return true; } private void spawnSprite() { sprite = new NPC(8091, Tile.of(tile)); } public void destroy() { if (sprite != null) sprite.finish(); World.removeObject(this); life = -1; } }" "package com.rs.game.content.holidayevents.christmas; @PluginEventHandler public class ChristmasCracker { private static final DropSet PARTY_HATS = new WeightedSet( new WeightedTable(32, new Drop(1038)), new WeightedTable(28, new Drop(1040)), new WeightedTable(23, new Drop(1048)), new WeightedTable(20, new Drop(1044)), new WeightedTable(15, new Drop(1042)), new WeightedTable(10, new Drop(1046)) ); private static final DropSet CRACKER_SECONDARIES = new WeightedSet( new WeightedTable(11, new Drop(1718)), new WeightedTable(11, new Drop(950)), new WeightedTable(9, new Drop(1635)), new WeightedTable(16, new Drop(1969)), new WeightedTable(15, new Drop(1897)), new WeightedTable(24, new Drop(1973)), new WeightedTable(17, new Drop(2355)), new WeightedTable(15, new Drop(441, 5)), new WeightedTable(5, new Drop(563)), new WeightedTable(5, new Drop(1217)) ); public static ItemOnPlayerHandler popCracker = new ItemOnPlayerHandler(new Object[] { 962 }, e -> { if (e.getTarget().isIronMan()) { e.getPlayer().sendMessage(""They stand alone!""); return; } if (e.getTarget().getInventory().getFreeSlots() <= 2) { e.getPlayer().sendMessage(""The other player does not have enough inventory space to recieve a cracker if they win.""); return; } if (e.getPlayer().getInventory().getFreeSlots() <= 2) { e.getPlayer().sendMessage(""You don't have enough inventory space to do this.""); return; } int random = Utils.random(1000); e.getTarget().setNextFaceTile(e.getPlayer().getTile()); e.getPlayer().setNextAnimation(new Animation(15152)); e.getTarget().setNextAnimation(new Animation(15153)); e.getPlayer().setNextSpotAnim(new SpotAnim(2952)); e.getPlayer().sendMessage(""You use the cracker on "" + e.getTarget().getDisplayName() + ""..""); e.getTarget().sendMessage(e.getPlayer().getDisplayName() + "" has used a christmas cracker on you..""); e.getPlayer().getInventory().deleteItem(962, 1); if (random < 500 || e.getPlayer().isIronMan()) { for (Item rew : DropTable.calculateDrops(PARTY_HATS)) e.getPlayer().getInventory().addItemDrop(rew); for (Item rew : DropTable.calculateDrops(CRACKER_SECONDARIES)) e.getTarget().getInventory().addItemDrop(rew); e.getPlayer().sendMessage(""and you got the reward!"" + (e.getPlayer().isIronMan() ? "" Because you stand alone."" : """")); e.getTarget().sendMessage(""but you didn't get the reward."" + (e.getPlayer().isIronMan() ? "" Because they stand alone."" : """")); } else { for (Item rew : DropTable.calculateDrops(PARTY_HATS)) e.getTarget().getInventory().addItemDrop(rew); for (Item rew : DropTable.calculateDrops(CRACKER_SECONDARIES)) e.getPlayer().getInventory().addItemDrop(rew); e.getTarget().sendMessage(""and you got the reward!""); e.getPlayer().sendMessage(""but you didn't get the reward.""); } }); }" "package com.rs.game.content.holidayevents.christmas; @PluginEventHandler public class LandOfSnow { private static final boolean ACTIVE = false; @ServerStartupEvent public static void initObjects() { if (!ACTIVE) return; Tile center = Tile.of(3212, 3428, 3); for (int x = -10; x < 10; x++) for (int y = -10; y < 10; y++) ObjectSpawns.add(new ObjectSpawn(3701, 10, 1, center.transform(x * 5, y * 5, 0))); ObjectSpawns.add(new ObjectSpawn(12258, 10, 0, Tile.of(3210, 3425, 0), ""Cupboard to Christmas event."")); ObjectSpawns.add(new ObjectSpawn(4483, 10, 0, Tile.of(2648, 5667, 0), ""Bank chest"")); ObjectSpawns.add(new ObjectSpawn(70761, 10, 0, Tile.of(2650, 5666, 0), ""Bonfire"")); ObjectSpawns.add(new ObjectSpawn(4483, 10, 0, Tile.of(2662, 5667, 0), ""Bank chest"")); ObjectSpawns.add(new ObjectSpawn(70761, 10, 0, Tile.of(2660, 5666, 0), ""Bonfire"")); ObjectSpawns.add(new ObjectSpawn(24887, 10, 0, Tile.of(2665, 5661, 0), ""Furnace"")); ObjectSpawns.add(new ObjectSpawn(21273, 10, 0, Tile.of(2645, 5671, 0), ""Arctic pine bottom"")); ObjectSpawns.add(new ObjectSpawn(47759, 10, 0, Tile.of(2644, 5671, 0), ""Arctic pine presents"")); ObjectSpawns.add(new ObjectSpawn(47761, 10, 0, Tile.of(2647, 5671, 0), ""Arctic pine presents"")); ObjectSpawns.add(new ObjectSpawn(21273, 10, 0, Tile.of(2640, 5665, 0), ""Arctic pine bottom"")); ObjectSpawns.add(new ObjectSpawn(47759, 10, 0, Tile.of(2641, 5664, 0), ""Arctic pine presents"")); ObjectSpawns.add(new ObjectSpawn(47761, 10, 0, Tile.of(2640, 5667, 0), ""Arctic pine presents"")); ObjectSpawns.add(new ObjectSpawn(46485, 10, 0, Tile.of(2667, 5670, 0), ""Ice fishing"")); NPCSpawns.add(new NPCSpawn(324, Tile.of(2667, 5670, 0), ""Fishing spot"")); NPCSpawns.add(new NPCSpawn(327, Tile.of(2667, 5670, 0), ""Fishing spot"")); ObjectSpawns.add(new ObjectSpawn(46485, 10, 0, Tile.of(2665, 5670, 0), ""Ice fishing"")); NPCSpawns.add(new NPCSpawn(334, Tile.of(2665, 5670, 0), ""Fishing spot"")); NPCSpawns.add(new NPCSpawn(328, Tile.of(2665, 5670, 0), ""Fishing spot"")); NPCSpawns.add(new NPCSpawn(5080, Tile.of(2666, 5645, 0), ""Carnivorous chinchompa"")); NPCSpawns.add(new NPCSpawn(5080, Tile.of(2667, 5644, 0), ""Carnivorous chinchompa"")); NPCSpawns.add(new NPCSpawn(5080, Tile.of(2664, 5645, 0), ""Carnivorous chinchompa"")); NPCSpawns.add(new NPCSpawn(5080, Tile.of(2665, 5647, 0), ""Carnivorous chinchompa"")); NPCSpawns.add(new NPCSpawn(5080, Tile.of(2670, 5646, 0), ""Carnivorous chinchompa"")); NPCSpawns.add(new NPCSpawn(5080, Tile.of(2672, 5647, 0), ""Carnivorous chinchompa"")); NPCSpawns.add(new NPCSpawn(5080, Tile.of(2673, 5649, 0), ""Carnivorous chinchompa"")); NPCSpawns.add(new NPCSpawn(5080, Tile.of(2671, 5650, 0), ""Carnivorous chinchompa"")); NPCSpawns.add(new NPCSpawn(5080, Tile.of(2671, 5645, 0), ""Carnivorous chinchompa"")); ObjectSpawns.add(new ObjectSpawn(67036, 10, 0, Tile.of(2672, 5679, 0), ""Summoning obelisk"")); NPC n = World.spawnNPC(14256, Tile.of(2658, 5671, 0), -1, true, false); n.setLoadsUpdateZones(); n.setPermName(""Yule-cien""); n.setHitpoints(Integer.MAX_VALUE / 2); n.getCombatDefinitions().setHitpoints(Integer.MAX_VALUE / 2); n.setCapDamage(750); n.setForceMultiArea(true); n.setForceMultiAttacked(true); } public static XPGainHandler handleXPGain = new XPGainHandler(e -> { if (!ACTIVE) return; if (Areas.withinArea(""christmasevent"", e.getPlayer().getChunkId())) { if (e.getPlayer().getBonusXpRate() != 0.10) { e.getPlayer().sendMessage(""You've been granted a 10% experience boost for skilling within the Land of Snow!""); e.getPlayer().setBonusXpRate(0.10); } double chance = e.getXp() / 75000.0; if (Math.random() < chance) { int TRADEABLE_REWARD = 1050; e.getPlayer().sendMessage(""You found a ""+ItemDefinitions.getDefs(TRADEABLE_REWARD).name+"" while skilling!""); if (e.getPlayer().getInventory().hasFreeSlots()) e.getPlayer().getInventory().addItemDrop(TRADEABLE_REWARD, 1); else { e.getPlayer().sendMessage(""as you did not have room in your inventory, it has been added to your bank.""); e.getPlayer().getBank().addItem(new Item(TRADEABLE_REWARD, 1), true); } } } else e.getPlayer().setBonusXpRate(0); }); public static ObjectClickHandler handleCupboard = new ObjectClickHandler(new Object[] { 12258, 47766 }, e -> e.getPlayer().fadeScreen(() -> e.getPlayer().tele(e.getObjectId() == 12258 ? Tile.of(2646, 5659, 0) : Tile.of(3211, 3424, 0)))); public static ObjectClickHandler handleSnowCollect = new ObjectClickHandler(new Object[] { 28296 }, e -> { if (!ACTIVE) return; if (e.getPlayer().getInventory().addItem(11951, e.getPlayer().getInventory().getFreeSlots())) e.getPlayer().setNextAnimation(new Animation(2282)); }); private static int getRandomFood() { return 15428 + Utils.random(4); } public static ObjectClickHandler handleFoodTable = new ObjectClickHandler(new Object[] { 47777, 47778 }, e -> { if (!ACTIVE) return; int food = getRandomFood(); if (e.getPlayer().getInventory().addItem(food, 1)) e.getPlayer().sendMessage(""You take "" + Utils.addArticle(ItemDefinitions.getDefs(food).name.toLowerCase()) + "".""); }); }" "package com.rs.game.content.holidayevents.christmas; @PluginEventHandler public class SnowballInteraction extends PlayerEntityInteraction { public static ItemEquipHandler handleSnowballWield = new ItemEquipHandler(11951, e -> e.getPlayer().setPlayerOption(e.equip() ? ""Pelt"" : ""null"", 8, true)); public static PlayerClickHandler handlePelt = new PlayerClickHandler(false, ""Pelt"", e -> e.getPlayer().getInteractionManager().setInteraction(new SnowballInteraction(e.getTarget()))); public SnowballInteraction(Entity target) { super(target, 7); } @Override public void interact(Player player) { player.setNextFaceTile(target.getTile()); if (player.getInventory().containsItem(11951, 1)) player.getInventory().deleteItem(11951, 1); else { player.getEquipment().deleteItem(player.getEquipment().getWeaponId(), 1); player.getAppearance().generateAppearanceData(); } if (target instanceof Player) player.sendMessage(""You pelt "" + ((Player)target).getDisplayName() + "" with a snowball.""); player.setNextAnimation(new Animation(7530)); player.resetWalkSteps(); WorldTasks.schedule(1, () -> World.sendProjectile(player, target, 861, 6, 10, 0, 1, 20, p -> target.setNextSpotAnim(new SpotAnim(862)))); } @Override public boolean canStart(Player player) { return true; } @Override public boolean checkAll(Player player) { return true; } @Override public void onStop(Player player) { } }" "package com.rs.game.content.holidayevents.christmas; @PluginEventHandler public class Snowglobe { public static ItemClickHandler handle = new ItemClickHandler(new Object[] { 11949 }, e -> { e.getPlayer().setNextAnimation(new Animation(2926)); e.getPlayer().startConversation(new Dialogue().addNext(new Dialogue(() -> { e.getPlayer().getInterfaceManager().sendInterface(659); e.getPlayer().setCloseInterfacesEvent(() -> e.getPlayer().setNextAnimation(new Animation(7538))); })).addNext(new Dialogue(() -> { e.getPlayer().closeInterfaces(); e.getPlayer().setNextAnimation(new Animation(7528)); e.getPlayer().setNextSpotAnim(new SpotAnim(1284)); e.getPlayer().getInventory().addItem(11951, e.getPlayer().getInventory().getFreeSlots()); }))); }); }" "package com.rs.game.content.holidayevents.christmas.christ19; @PluginEventHandler public class Christmas2019 { public static final String STAGE_KEY = ""christ2025""; private static final boolean ACTIVE = false; public enum Imp { WINE(9372, 6928, Location.VARROCK_CASTLE, Location.CAMELOT_CASTLE, Location.ARDOUGNE_CASTLE), YULE_LOG(9373, 6929, Location.LUMBRIDGE_COOK, Location.YANILLE_COOK, Location.COOKING_GUILD), TURKEY(9374, 6930, Location.LUMBRIDGE_CHICKEN, Location.FALADOR_CHICKEN, Location.PHASMATYS_CHICKEN), POTATOES(9375, 6931, Location.LUMBRIDGE_POTATO, Location.DRAYNOR_POTATO, Location.ARDOUGNE_POTATO); private final int npcId; private final int varBit; private final Location[] locs; private static final Map CHUNK_MAP = new HashMap<>(); static { for (Imp i : Imp.values()) for (Location l : i.locs) CHUNK_MAP.put(l.chunkId, i); } public static Imp forChunk(int chunkId) { return CHUNK_MAP.get(chunkId); } private Imp(int npcId, int varBit, Location... locs) { this.npcId = npcId; this.varBit = varBit; this.locs = locs; } public Location randomLoc() { return locs[Utils.random(locs.length)]; } } public enum Location { VARROCK_CASTLE(Tile.of(3202, 3491, 0), ""Him seems to be somewhere in Varrock..""), CAMELOT_CASTLE(Tile.of(2765, 3506, 0), ""Him seems to be somewhere near Seer's Village..""), ARDOUGNE_CASTLE(Tile.of(2571, 3292, 0), ""Him seems to be somewhere in Ardougne..""), LUMBRIDGE_COOK(Tile.of(3211, 3211, 0), ""Him seems to be somewhere near Lumbridge..""), YANILLE_COOK(Tile.of(2564, 3099, 0), ""Him seems to be somewhere near Yanille..""), COOKING_GUILD(Tile.of(3140, 3444, 0), ""Him seems to be somewhere near Varrock..""), LUMBRIDGE_CHICKEN(Tile.of(3236, 3300, 0), ""Him seems to be somewhere near Lumbridge..""), FALADOR_CHICKEN(Tile.of(3020, 3291, 0), ""Him seems to be somewhere near Falador..""), PHASMATYS_CHICKEN(Tile.of(3620, 3522, 0), ""Him seems to be somewhere near Canifis..""), LUMBRIDGE_POTATO(Tile.of(3260, 3307, 0), ""Him seems to be somewhere near Lumbridge..""), DRAYNOR_POTATO(Tile.of(3148, 3283, 0), ""Him seems to be somewhere near Draynor..""), ARDOUGNE_POTATO(Tile.of(2628, 3364, 0), ""Him seems to be somewhere near Ardougne..""); private final Tile loc; private final String hint; private final int chunkId; private Location(Tile loc, String hint) { this.loc = loc; this.hint = hint; chunkId = loc.getChunkId(); } public String getHint() { return hint; } public Imp getImp() { return Imp.forChunk(chunkId); } } @ServerStartupEvent(Priority.FILE_IO) public static void loadSnowyCupboard() { if (!ACTIVE) return; for (Imp i : Imp.values()) for (Location l : i.locs) NPCSpawns.add(new NPCSpawn(i.npcId, l.loc, ""Imp for Christmas event."")); NPCSpawns.add(new NPCSpawn(8540, Tile.of(2655, 5678, 0), ""Queen of Snow"")); NPCSpawns.add(new NPCSpawn(8539, Tile.of(2654, 5679, 0), ""Santa"")); NPCSpawns.add(new NPCSpawn(9386, Tile.of(2652, 5663, 0), ""Partygoer"")); NPCSpawns.add(new NPCSpawn(9389, Tile.of(2658, 5663, 0), ""Partygoer"")); NPCSpawns.add(new NPCSpawn(9392, Tile.of(2655, 5659, 0), ""Partygoer"")); NPCSpawns.add(new NPCSpawn(9386, Tile.of(2662, 5654, 0), ""Partygoer"")); NPCSpawns.add(new NPCSpawn(9389, Tile.of(2649, 5653, 0), ""Partygoer"")); NPCSpawns.add(new NPCSpawn(9392, Tile.of(2655, 5668, 0), ""Partygoer"")); } public static EnterChunkHandler handleChunkEvents = new EnterChunkHandler(e -> { if (!ACTIVE) return; if (e.getEntity() instanceof Player p) { if (p.get(Christmas2019.STAGE_KEY+""loc"") == null) { p.getVars().setVarBit(6928, 1); p.getVars().setVarBit(6929, 1); p.getVars().setVarBit(6930, 1); p.getVars().setVarBit(6931, 1); return; } if (p.getPetManager().getNpcId() == Pets.SNOW_IMP.getBabyNpcId()) { Location loc = Location.values()[p.getI(Christmas2019.STAGE_KEY+""loc"", 0)]; if (e.getChunkId() == loc.chunkId) { if (p.getPet() != null) p.getPet().setNextForceTalk(new ForceTalk(""Der he is!"")); p.getVars().setVarBit(loc.getImp().varBit, 0); } else { if (p.getPet() != null) { int prevDist = p.getTempAttribs().getI(""christ19LocDist""); int currDist = (int) Utils.getDistance(p.getTile(), loc.loc); if (prevDist != 0) if (currDist > prevDist) p.getPet().setNextForceTalk(new ForceTalk(""Yer headin the wrong way, guv!"")); else p.getPet().setNextForceTalk(new ForceTalk(""Yer gettin closer, guv!"")); p.getTempAttribs().setI(""christ19LocDist"", currDist); } p.getVars().setVarBit(6928, 1); p.getVars().setVarBit(6929, 1); p.getVars().setVarBit(6930, 1); p.getVars().setVarBit(6931, 1); } } } }); public static LoginHandler login = new LoginHandler(e -> { if (!ACTIVE) return; e.getPlayer().getVars().setVarBit(6928, 1); e.getPlayer().getVars().setVarBit(6929, 1); e.getPlayer().getVars().setVarBit(6930, 1); e.getPlayer().getVars().setVarBit(6931, 1); if (e.getPlayer().getI(Christmas2019.STAGE_KEY, 0) == 10) e.getPlayer().getVars().setVarBit(6934, 1); }); public static ItemClickHandler handle = new ItemClickHandler(new Object[] { 14599 }, new String[] { ""Summon Imp"" }, e -> e.getPlayer().getPetManager().spawnPet(50001, false)); public static ItemEquipHandler handleUnequipIceAmulet = new ItemEquipHandler(14599, e -> { if (e.dequip() && e.getPlayer().getPetManager().getNpcId() == Pets.SNOW_IMP.getBabyNpcId()) e.getPlayer().getPet().pickup(); }); }" "package com.rs.game.content.holidayevents.christmas.christ19; @PluginEventHandler public class PartygoerD extends Conversation { public static NPCClickHandler handle = new NPCClickHandler(new Object[] { 9386, 9389, 9392 }, e -> e.getPlayer().startConversation(new PartygoerD(e.getPlayer(), e.getNPC()))); public PartygoerD(Player player, NPC npc) { super(player); switch(player.getI(Christmas2019.STAGE_KEY, 0)) { case 10: addPlayer(HeadE.HAPPY_TALKING, ""Merry Christmas!""); addNPC(npc.getId(), HeadE.HAPPY_TALKING, ""Merry Christmas! I'm so glad the feast was able to be saved!""); addPlayer(HeadE.HAPPY_TALKING, ""It was pretty exhausting, but I am pretty happy as well.""); break; default: addPlayer(HeadE.CHEERFUL, ""Merry Christmas!""); addNPC(npc.getId(), HeadE.UPSET_SNIFFLE, ""Merry Christmas..""); addPlayer(HeadE.CONFUSED, ""What's wrong?""); addNPC(npc.getId(), HeadE.UPSET_SNIFFLE, ""Someone stole the food for the feast we were going to have. Santa had really planned it out well.""); addPlayer(HeadE.WORRIED, ""Oh no! I'd better go talk to Santa and see what I can do then!""); break; } create(); } }" "package com.rs.game.content.holidayevents.christmas.christ19; @PluginEventHandler public class ResourceImpD extends Conversation { private static final int IMP_HEAD = 9364; public static NPCClickHandler handleSnowImpTalk = new NPCClickHandler(new Object[] { 9372, 9373, 9374, 9375 }, e -> { String noun = """"; int stage = switch (e.getNPC().getId()) { case 9372 -> { noun = ""wine""; yield 5; } case 9373 -> { noun = ""yule logs""; yield 9; } case 9374 -> { noun = ""turkeys""; yield 7; } case 9375 -> { noun = ""taters""; yield 3; } default -> 0; }; e.getPlayer().startConversation(new ResourceImpD(e.getPlayer(), noun, stage)); }); public ResourceImpD(Player player, String noun, int stage) { super(player); switch(player.getI(Christmas2019.STAGE_KEY, 0)) { case 2: case 4: case 6: case 8: addPlayer(HeadE.ANGRY, ""Hey! Give those ""+noun+"" back!""); addNPC(IMP_HEAD, HeadE.EVIL_LAUGH, ""Tee hee hee! Why should I listen to you?""); addNPC(IMP_HEAD, HeadE.ANGRY, ""Because I'm wif him. Give him da ""+noun+"" back, Snowie's orders!""); addNPC(IMP_HEAD, HeadE.SCARED, ""Oh.. Rasmus.. Sorry, guv. I'll bring da ""+noun+"" back to da feast den.""); addNPC(IMP_HEAD, HeadE.ANGRY, ""You betta! Get moving dis instant!""); addPlayer(HeadE.CHEERFUL, ""Alright, we'll see you there."", () -> { player.save(Christmas2019.STAGE_KEY, stage); player.delete(Christmas2019.STAGE_KEY+""loc""); PluginManager.handle(new EnterChunkEvent(player, player.getChunkId())); }); break; default: addSimple(""You've harassed the imp enough. Talk to Rasmus for the next location.""); break; } create(); } }" "package com.rs.game.content.holidayevents.christmas.christ19; @PluginEventHandler public class Santa2019D extends Conversation { private static final int SNOW_QUEEN = 8539, SANTA = 8540; public static NPCClickHandler handleSantaTalk = new NPCClickHandler(new Object[] { SNOW_QUEEN, SANTA }, e -> e.getPlayer().startConversation(new Santa2019D(e.getPlayer()))); public Santa2019D(Player player) { super(player); switch(player.getI(Christmas2019.STAGE_KEY, 0)) { case 0: addPlayer(HeadE.HAPPY_TALKING, ""Merry Christmas, guys!""); addNPC(SANTA, HeadE.SAD_MILD_LOOK_DOWN, ""Ho ho ho hohhh noooo...""); addPlayer(HeadE.CONFUSED, ""What's the matter? Should I have said 'you two' or 'people' instead?""); addNPC(SANTA, HeadE.SAD_MILD, ""No no.. It's our son, Jack. He's convinced a few of Lumi's imps to steal some key foods for our Christmas feast.""); addNPC(SANTA, HeadE.SAD_MILD, ""I knew banishing him from the Land of Snow was a bit harsh..""); addPlayer(HeadE.SKEPTICAL, ""Oh no! Is there any way I can help out?""); addNPC(SANTA, HeadE.SAD_MILD, ""I'm not sure. Snowie, what do you think? The only one capable of locating the imps would be Rasmus.""); addNPC(SNOW_QUEEN, HeadE.LAUGH, ""Oh dear, you're always so worked up about making every Christmas perfect. My imps are easily locatable. It'll be fine.""); addNPC(SNOW_QUEEN, HeadE.CHEERFUL, player.getDisplayName() + "", I can introduce you to one of my higher up imps, Rasmus. He'll help you find the food pretty quickly.""); addNPC(SNOW_QUEEN, HeadE.CHEERFUL, ""Here's one of my amulets, while you're wearing it, Rasmus will listen to you and help. Snow imps are also very hard to spot without it on. They have ways of avoiding being seen.""); addPlayer(HeadE.CHEERFUL, ""Alright, and how would I go about summoning Rasmus?""); addNPC(SNOW_QUEEN, HeadE.CHEERFUL, ""Just wear the necklace and operate it to summon him to you. Remember, he must be walking with you to be able to show you where the imps are.""); addPlayer(HeadE.CHEERFUL, ""Alright, sounds good. Thanks!"", () -> { player.getInventory().addItemDrop(14599, 1); player.save(Christmas2019.STAGE_KEY, 1); }); break; case 1: case 2: case 3: case 4: case 5: case 6: case 7: case 8: addPlayer(HeadE.CALM_TALK, ""What am I supposed to be doing again?""); addNPC(SNOW_QUEEN, HeadE.CHEERFUL, ""Please help find the food that Jack's imps stole by collaborating with Rasmus. You can speak to him by operating that necklace I gave you.""); if (!player.containsItem(14599)) { addPlayer(HeadE.WORRIED, ""I seem to have lost the amulet you gave me..""); addNPC(SNOW_QUEEN, HeadE.CHEERFUL, ""Oh no worries. I can spin you up a new one right now. Here you go!""); addPlayer(HeadE.CHEERFUL, ""Thanks! Sorry for the inconvenience."", () -> player.getInventory().addItemDrop(14599, 1)); } else addPlayer(HeadE.CHEERFUL, ""Alright, I'll get right on that.""); break; case 9: addPlayer(HeadE.HAPPY_TALKING, ""We did it! We found all the missing items from the feast!""); addNPC(SNOW_QUEEN, HeadE.CHEERFUL, ""Great job! We are so grateful for your help.""); addPlayer(HeadE.HAPPY_TALKING, ""Is there any chance I could get a Christmas gift from you guys as a reward?""); addNPC(SANTA, HeadE.LAUGH, ""Ho ho ho! Of course! Here, pop this with your friends at the feast and have a very Merry Christmas!""); addPlayer(HeadE.CHEERFUL, ""Thank you!""); addItem(962, ""Santa has given you a christmas cracker, allowed you to keep the ice amulet, and has taught you the Snowman Dance emote!""); addNext(() -> { player.save(Christmas2019.STAGE_KEY, 10); player.getVars().setVarBit(6934, 1); player.getInventory().addItemDrop(new Item(962, 1)); player.getInventory().addItemDrop(new Item(11949, 1)); player.addDiangoReclaimItem(11949); player.addDiangoReclaimItem(14599); player.getEmotesManager().unlockEmote(Emote.SNOWMAN_DANCE); }); break; case 10: addPlayer(HeadE.HAPPY_TALKING, ""Merry Christmas, guys!""); addNPC(SANTA, HeadE.LAUGH, ""Merry Christmas! Thank you for helping fix the feast!""); addNPC(SNOW_QUEEN, HeadE.CHEERFUL, ""Yes, Merry Christmas! We appreciate the help!""); addPlayer(HeadE.HAPPY_TALKING, ""It was nothing. All in the spirit of the season!""); break; } create(); } }" "package com.rs.game.content.holidayevents.christmas.christ19; @PluginEventHandler public class SnowImpD extends Conversation { private static final int IMP = 8536, IMP_HEAD = 9364; public static NPCClickHandler handleSnowImpTalk = new NPCClickHandler(new Object[] { IMP }, e -> { if (e.getPlayer().getPet() == e.getNPC()) e.getPlayer().startConversation(new SnowImpD(e.getPlayer())); else e.getPlayer().startConversation(new Conversation(e.getPlayer()).addNPC(IMP_HEAD, HeadE.CONFUSED, ""Whatchu want, guv?"")); }); public SnowImpD(Player player) { super(player); switch(player.getI(Christmas2019.STAGE_KEY, 0)) { case 1: addPlayer(HeadE.CALM_TALK, ""Hey, you're Rasmus right?""); addNPC(IMP_HEAD, HeadE.CHEERFUL, ""Yep, dats me. Heard ya need help findin summa dem rogue imps.""); addPlayer(HeadE.UPSET, ""Yeah, I do. They've stolen some items from the feast!""); addNPC(IMP_HEAD, HeadE.UPSET, ""Ya, it was sum potatoes, turkey, wine, and yule logs! Nasties.""); addPlayer(HeadE.CHEERFUL, ""Do you know where any of them went?""); addNPC(IMP_HEAD, HeadE.CHEERFUL, ""Aight, guv. Gimme a sec.""); addSimple(""The imp closes his eyes briefly and makes a grunting sound.""); addNPC(IMP_HEAD, HeadE.LAUGH, ""I've located da potatoes! Start walkin' and I'll let ya know if ya getting closer!""); addPlayer(HeadE.CHEERFUL, ""Alright, thanks!"", () -> { player.save(Christmas2019.STAGE_KEY, 2); player.save(Christmas2019.STAGE_KEY+""loc"", Imp.POTATOES.randomLoc().ordinal()); }); break; case 3: addPlayer(HeadE.CALM_TALK, ""Hey Rasmus, where's the next location?""); addNPC(IMP_HEAD, HeadE.CHEERFUL, ""Aight, guv. Gimme a sec.""); addSimple(""The imp closes his eyes briefly and makes a grunting sound.""); addNPC(IMP_HEAD, HeadE.LAUGH, ""I've located da wine! Start walkin' and I'll let ya know if ya getting closer!""); addPlayer(HeadE.CHEERFUL, ""Alright, thanks!"", () -> { player.save(Christmas2019.STAGE_KEY, 4); player.save(Christmas2019.STAGE_KEY+""loc"", Imp.WINE.randomLoc().ordinal()); }); break; case 5: addPlayer(HeadE.CALM_TALK, ""Hey Rasmus, where's the next location?""); addNPC(IMP_HEAD, HeadE.CHEERFUL, ""Aight, guv. Gimme a sec.""); addSimple(""The imp closes his eyes briefly and makes a grunting sound.""); addNPC(IMP_HEAD, HeadE.LAUGH, ""I've located da turkeys! Start walkin' and I'll let ya know if ya getting closer!""); addPlayer(HeadE.CHEERFUL, ""Alright, thanks!"", () -> { player.save(Christmas2019.STAGE_KEY, 6); player.save(Christmas2019.STAGE_KEY+""loc"", Imp.TURKEY.randomLoc().ordinal()); }); break; case 7: addPlayer(HeadE.CALM_TALK, ""Hey Rasmus, where's the next location?""); addNPC(IMP_HEAD, HeadE.CHEERFUL, ""Aight, guv. Gimme a sec.""); addSimple(""The imp closes his eyes briefly and makes a grunting sound.""); addNPC(IMP_HEAD, HeadE.LAUGH, ""I've located da yule logs! Start walkin' and I'll let ya know if ya getting closer!""); addPlayer(HeadE.CHEERFUL, ""Alright, thanks!"", () -> { player.save(Christmas2019.STAGE_KEY, 8); player.save(Christmas2019.STAGE_KEY+""loc"", Imp.YULE_LOG.randomLoc().ordinal()); }); break; case 2: case 4: case 6: case 8: Location loc = Location.values()[player.getI(Christmas2019.STAGE_KEY+""loc"", 0)]; addPlayer(HeadE.CONFUSED, ""Any hints as to where to go?""); addNPC(IMP_HEAD, HeadE.CHEERFUL, loc.getHint()); addPlayer(HeadE.CHEERFUL, ""Thanks!""); break; case 9: addPlayer(HeadE.CHEERFUL, ""We found them all!""); addNPC(IMP_HEAD, HeadE.CHEERFUL, ""Yeah we did! Let's head back to Santa and let em know!""); addPlayer(HeadE.CHEERFUL, ""Alright, try to keep up!""); break; case 10: addNPC(IMP_HEAD, HeadE.CHEERFUL, ""'Ello, "" + player.getDisplayName() + ""!""); addPlayer(HeadE.CHEERFUL, ""Hello again Rasmus. Merry Christmas!""); addNPC(IMP_HEAD, HeadE.LAUGH, ""Merry Christmas "" + player.getDisplayName() + "", thanks for bringing me to da feastie!""); addPlayer(HeadE.CHEERFUL, ""No problem! It would't be Christmas without Rasmus, would it?""); addNPC(IMP_HEAD, HeadE.CHEERFUL, ""Certainly not "" + player.getDisplayName() + "".""); break; } create(); } }" "package com.rs.game.content.holidayevents.christmas.christ20; @PluginEventHandler public class Christmas2020 { public static final String STAGE_KEY = ""christ2023""; private static final boolean ACTIVE = false; @ServerStartupEvent(Priority.FILE_IO) public static void load() { if (!ACTIVE) return; NPCSpawns.add(new NPCSpawn(9398, Tile.of(2655, 5678, 0), ""Queen of Snow"")); NPCSpawns.add(new NPCSpawn(9400, Tile.of(2654, 5679, 0), ""Santa"")); } public static LoginHandler login = new LoginHandler(e -> { if (!ACTIVE) return; e.getPlayer().getVars().setVarBit(6934, 1); }); public static ItemClickHandler handleYoyo = new ItemClickHandler(new Object[] { 4079 }, new String[] { ""Play"", ""Loop"", ""Walk"", ""Crazy"" }, e -> { switch(e.getOption()) { case ""Play"": e.getPlayer().setNextAnimation(new Animation(1457)); break; case ""Loop"": e.getPlayer().setNextAnimation(new Animation(1458)); break; case ""Walk"": e.getPlayer().setNextAnimation(new Animation(1459)); break; case ""Crazy"": e.getPlayer().setNextAnimation(new Animation(1460)); break; } }); public static ItemClickHandler handleReinhat = new ItemClickHandler(new Object[] { 10507 }, new String[] { ""Emote"" }, e -> { e.getPlayer().setNextAnimation(new Animation(5059)); e.getPlayer().setNextSpotAnim(new SpotAnim(859)); }); }" "package com.rs.game.content.holidayevents.christmas.christ20; @PluginEventHandler public class Santa2020D extends Conversation { private static final int SNOW_QUEEN = 9398, SANTA = 9400; public static NPCClickHandler handleSantaTalk = new NPCClickHandler(new Object[] { SNOW_QUEEN, SANTA }, e -> e.getPlayer().startConversation(new Santa2020D(e.getPlayer()))); public Santa2020D(Player player) { super(player); switch(player.getI(Christmas2020.STAGE_KEY, 0)) { case 0: addPlayer(HeadE.HAPPY_TALKING, ""Merry Christmas, guys!""); addNPC(SANTA, HeadE.LAUGH, ""Ho ho hohhh! Merry Christmas!""); addPlayer(HeadE.CONFUSED, ""Wait.. you seem relatively jolly this year.""); addNPC(SANTA, HeadE.LAUGH, ""Of course I am! I am Santa Claus, and it is Christmas time!""); addNPC(SNOW_QUEEN, HeadE.CONFUSED, ""Are you okay, "" + player.getDisplayName() + ""? You look like you've slipped and hit your head on the ice.""); addPlayer(HeadE.SKEPTICAL, ""No, I was just expecting something to have gone wrong and it to be all up to me to fix it.""); addNPC(SNOW_QUEEN, HeadE.LAUGH, ""Oh no! Everything has gone rather smoothly this year. Right Nicky?""); addNPC(SANTA, HeadE.CHEERFUL, ""Why yes it has Snowie.""); addPlayer(HeadE.CONFUSED, ""So there's nothing for me to do for you guys?""); addNPC(SANTA, HeadE.LAUGH, ""Ho ho hohhh! You could guess a number between 1-1000 for me if that would make you feel more deserving of your presents this year.""); addPlayer(HeadE.CHEERFUL, ""That's a lot more simple than last year, I guess!""); addNPC(SANTA, HeadE.CHEERFUL, ""Yeah, when Torpid Trent has things he'd rather do. It seems to make our jobs easier."", () -> player.getTempAttribs().setI(""santaRandNum"", Utils.random(1, 1000))); addNext(() -> { player.save(Christmas2020.STAGE_KEY, 1); guessNumber(player); }); break; case 1: addNext(() -> guessNumber(player)); break; case 2: addNPC(SANTA, HeadE.CHEERFUL, ""Good job. Do you feel deserving of your Christmas presents now?""); addPlayer(HeadE.CHEERFUL, ""Good enough for me!""); addItem(1050, ""Santa hands you a yo-yo and one of his hats!""); addNext(() -> { player.save(Christmas2020.STAGE_KEY, 3); player.getInventory().addItemDrop(new Item(962, 1)); player.getInventory().addItemDrop(new Item(4079, 1)); player.addDiangoReclaimItem(4079); player.sendMessage(""You've unlocked the 'Freeze' emote!""); player.getEmotesManager().unlockEmote(Emote.FREEZE); }); break; case 3: addPlayer(HeadE.CHEERFUL, ""Merry Christmas!""); addNPC(SANTA, HeadE.LAUGH, ""Merry Christmas!""); addNPC(SNOW_QUEEN, HeadE.SAD_MILD_LOOK_DOWN, ""*cough*trentslazy*cough*""); addNPC(SANTA, HeadE.LAUGH, ""What was that, Snowie?""); addNPC(SNOW_QUEEN, HeadE.LAUGH, ""Oh, nothing! Merry Christmas!""); break; } create(); } private static void guessNumber(Player player) { if (player.getTempAttribs().getI(""santaRandNum"", -1) == -1) player.getTempAttribs().setI(""santaRandNum"", Utils.random(1, 1000)); player.sendInputInteger(""Guess Santa's number between 1-1000!"", result -> { int answer = player.getTempAttribs().getI(""santaRandNum""); if (result > answer) player.startConversation(new Dialogue() .addNPC(SANTA, HeadE.CHEERFUL, ""That's too high! Try again."") .addNext(() -> guessNumber(player))); else if (result < answer) player.startConversation(new Dialogue() .addNPC(SANTA, HeadE.CHEERFUL, ""That's too low! Try again."") .addNext(() -> guessNumber(player))); else { player.save(Christmas2020.STAGE_KEY, 2); player.startConversation(new Santa2020D(player)); } }); } }" "package com.rs.game.content.holidayevents.easter const val ENABLED = true private var eggsPerChunk = 2 private var regionsToSpawn = IntSet.of(12850, 11828, 12084, 12853, 12597, 12342, 10806, 10547, 13105) @ServerStartupEvent(ServerStartupEvent.Priority.POST_PROCESS) fun startTasks() { if (!ENABLED) return ChunkManager.permanentlyPreloadRegions(regionsToSpawn) WorldTasks.scheduleHalfHourly { spawnEggs() World.sendWorldMessage(""Easter Eggs have spawned in various cities around the world!"", false) } } private fun countEggs(chunkId: Int): Int { var eggsCount = 0 val itemSpawns = ChunkManager.getChunk(chunkId).allGroundItems if (itemSpawns != null && itemSpawns.size > 0) itemSpawns.forEach { spawn -> if (spawn.id == 1961) eggsCount += 1 } return eggsCount } private fun spawnEggs() { for (chunkId in World.mapRegionIdsToChunks(regionsToSpawn, 0)) { val chunk = ChunkManager.getChunk(chunkId) val eggsNeeded = eggsPerChunk - countEggs(chunkId) if (eggsNeeded <= 0) continue for (i in 0 until eggsNeeded) { var x = chunk.baseX + Utils.random(8) var y = chunk.baseY + Utils.random(8) var tile = Tile.of(x, y, 0) var attempts = 0 while (!World.floorAndWallsFree(tile, 1)) { if (attempts++ >= 64) break x = chunk.baseX + Utils.random(8) y = chunk.baseY + Utils.random(8) tile = Tile.of(x, y, 0) } World.addGroundItem(Item(1961), tile) } } }" "package com.rs.game.content.holidayevents.easter.easter21 private const val STAGE_KEY = ""easter2024"" private const val ENABLED = true private const val COG = 14719 private const val PISTON = 14720 private const val CHIMNEY = 14718 private const val CHARLIE = 9686 private const val EASTER_BUNNY = 9687 private const val EASTER_BUNNY_JR = 7411 private val COG_LOCATIONS = arrayOf( Tile.of(2469, 5328, 0), Tile.of(2469, 5321, 0), Tile.of(2454, 5334, 0), Tile.of(2448, 5341, 0) ) private val PISTON_LOCATIONS = arrayOf( Tile.of(2468, 5324, 0), Tile.of(2467, 5319, 0), Tile.of(2454, 5335, 0) ) private val CHIMNEY_LOCATIONS = arrayOf( Tile.of(2469, 5323, 0), Tile.of(2444, 5329, 0), Tile.of(2449, 5343, 0) ) @ServerStartupEvent fun mapEaster2021() { onObjectClick(23117, 30074) { e -> if (e.player.getI(STAGE_KEY) <= 0) { e.player.sendMessage(""You don't see a need to go down there yet!"") return@onObjectClick } e.player.useLadder(if (e.objectId == 23117) Tile.of(2483, 5258, 0) else Tile.of(3212, 3425, 0)) } onObjectClick(30075, 30076) { e -> useBunnyHole(e.player, e.getObject(), e.player.transform(0, if (e.objectId == 30075) 7 else -7)) } onItemClick(12645, options = arrayOf(""Emote"")) { e -> e.player.sync(8903, 1566) } onItemEquip(4565) { e -> e.player.appearance.setBAS(if (e.dequip()) -1 else 594) } onLogin { e -> if (!ENABLED) return@onLogin e.player.nsv.setI(""easterBirdFood"", Utils.random(4)) e.player.nsv.setI(""cogLocation"", Utils.random(COG_LOCATIONS.size)) e.player.nsv.setI(""pistonLocation"", Utils.random(PISTON_LOCATIONS.size)) e.player.nsv.setI(""chimneyLocation"", Utils.random(CHIMNEY_LOCATIONS.size)) e.player.vars.setVarBit(6014, if (e.player.getI(STAGE_KEY) >= 3) 1 else 0) e.player.vars.setVarBit(6016, if (e.player.getI(STAGE_KEY) >= 6) 3 else 0) if (e.player.getI(STAGE_KEY) >= 8) e.player.vars.setVarBit(6014, 85) } onObjectClick(30083) { e -> e.player.inventory.addItem(1929) } onObjectClick(30089, 30090, 30091, 30092) { e -> if (!e.player.inventory.hasFreeSlots()) { e.player.sendMessage(""You don't have enough inventory space."") return@onObjectClick } val food = Item(14714 + (e.objectId - 30089)) e.player.sendMessage(""You grab some "" + food.name + ""."") e.player.inventory.addItem(food) } onItemOnObject(objectNamesOrIds = arrayOf(42731), itemNamesOrIds = arrayOf(1929)) { e -> if (e.player.getI(STAGE_KEY) >= 3) { e.player.sendMessage(""You've already woken the bird up! It doesn't need any more water."") return@onItemOnObject } e.player.inventory.deleteItem(1929, 1) e.player.inventory.addItem(1925, 1) e.player.vars.setVarBit(6027, 1) e.player.sendMessage(""You fill the bird's dish with water."") if (e.player.vars.getVarBit(6026) == e.player.nsv.getI(""easterBirdFood"")) { e.player.sendMessage(""The bird wakes up and begins eating and drinking!"") e.player.save(STAGE_KEY, 3) e.player.vars.setVarBit(6014, 1) WorldTasks.delay(10) { e.player.vars.setVarBit(6026, 0) e.player.vars.setVarBit(6027, 0) } } else e.player.sendMessage(""The bird still needs the correct food it seems."") } onItemOnObject(objectNamesOrIds = arrayOf(42732), itemNamesOrIds = arrayOf(14714, 14715, 14716, 14717)) { e -> if (e.player.getI(STAGE_KEY) >= 3) { e.player.sendMessage(""You've already woken the bird up! It doesn't need any more food."") return@onItemOnObject } val foodId = e.item.id - 14713 e.player.inventory.deleteItem(e.item.id, 1) e.player.vars.setVarBit(6026, foodId) e.player.sendMessage(""You fill the bird's dish with "" + e.item.name + ""."") if (e.player.vars.getVarBit(6027) == 0) { e.player.sendMessage(""The bird still looks thirsty."") return@onItemOnObject } if (e.player.vars.getVarBit(6026) == (e.player.nsv.getI(""easterBirdFood"") + 1)) { e.player.save(STAGE_KEY, 3) e.player.vars.setVarBit(6014, 1) WorldTasks.delay(10) { e.player.vars.setVarBit(6026, 0) e.player.vars.setVarBit(6027, 0) } } else e.player.sendMessage(""That doesn't seem to be the correct food."" + e.player.nsv.getI(""easterBirdFood"")) } onObjectClick(30100, 30101, 30102, 30103, 30104) { e -> if (e.player.getI(STAGE_KEY) < 5) { e.player.sendMessage(""You don't find anything that looks useful to you right now."") return@onObjectClick } if (COG_LOCATIONS[e.player.nsv.getI(""cogLocation"")].matches(e.getObject().tile) && !e.player.inventory.containsItem(COG)) { e.player.inventory.addItem(COG) e.player.startConversation(Conversation(e.player).addItem(COG, ""You find a cog in the crate!"")) return@onObjectClick } if (PISTON_LOCATIONS[e.player.nsv.getI(""pistonLocation"")].matches(e.getObject().tile) && !e.player.inventory.containsItem(PISTON)) { e.player.inventory.addItem(PISTON) e.player.startConversation(Conversation(e.player).addItem(PISTON, ""You find some pistons in the crate!"")) return@onObjectClick } if (CHIMNEY_LOCATIONS[e.player.nsv.getI(""chimneyLocation"")].matches(e.getObject().tile) && !e.player.inventory.containsItem(CHIMNEY)) { e.player.inventory.addItem(CHIMNEY) e.player.startConversation(Conversation(e.player).addItem(CHIMNEY, ""You find a chimney in the crate!"")) return@onObjectClick } e.player.sendMessage(""You find nothing interesting."") } onItemOnObject(objectNamesOrIds = arrayOf(42733), itemNamesOrIds = arrayOf(COG, PISTON, CHIMNEY)) { e -> if (e.player.getI(STAGE_KEY) < 5) { e.player.sendMessage(""It looks really broken."") return@onItemOnObject } when (e.item.id) { COG -> if (e.player.vars.getVarBit(6016) <= 0) { e.player.inventory.deleteItem(e.item) e.player.vars.setVarBit(6016, 1) e.player.sendMessage(""You attach the cog back into place."") } else e.player.sendMessage(""You already have attached the cog."") PISTON -> if (e.player.vars.getVarBit(6016) == 1) { e.player.inventory.deleteItem(e.item) e.player.vars.setVarBit(6016, 2) e.player.sendMessage(""You attach the pistons back into place."") } else e.player.sendMessage(""That part won't fit quite yet."") CHIMNEY -> if (e.player.vars.getVarBit(6016) == 2) { e.player.inventory.deleteItem(e.item) e.player.vars.setVarBit(6016, 4) e.player.sendMessage(""You attach the chimney back into place."") e.player.sendMessage(""You hear the machine whirr as it turns back on."") e.player.save(STAGE_KEY, 6) } else e.player.sendMessage(""That part won't fit quite yet."") else -> {} } } onNpcClick(CHARLIE) { (player) -> player.startConversation { when(player.getI(STAGE_KEY, 0)) { 7 -> { player(HeadE.CONFUSED, ""Hey, are you Charlie?"") npc(CHARLIE, HeadE.CAT_CHEERFUL, ""Yeah, that's me! Can I help you?"") player(HeadE.HAPPY_TALKING, ""Yes, the Easter Bunny sent me to ask you if you had some workers that can help operate his chocolate egg factory."") npc(CHARLIE, HeadE.CAT_CHEERFUL, ""Oh, definitely! We'd love to help out. Is this because of his son being useless again?"") player(HeadE.UPSET, ""Yeah, it is. It's an unfortunate situation."") npc(CHARLIE, HeadE.CAT_CHEERFUL, ""It's fine, we've been picking up his slack for years. We'll head over as quick as we can."") player(HeadE.CHEERFUL, ""Thank you for your help!"") exec { player.save(STAGE_KEY, 8) player.vars.setVarBit(6014, 85) } } 8 -> npc(CHARLIE, HeadE.CAT_CHEERFUL, ""You head on back and let the Easter Bunny know we're coming!"") else -> { player(HeadE.HAPPY_TALKING, ""Hello!"") npc(CHARLIE, HeadE.CAT_CHEERFUL, ""Oh, hello! How's it going?"") player(HeadE.HAPPY_TALKING, ""It's going great, thanks!"") } } } } onNpcClick(EASTER_BUNNY) { (player) -> player.startConversation { when (player.getI(STAGE_KEY, 0)) { 0 -> { player(HeadE.CHEERFUL, ""Hello!"") npc(EASTER_BUNNY, HeadE.CAT_SAD, ""..."") player(HeadE.CONFUSED, ""Hello?"") npc(EASTER_BUNNY, HeadE.CAT_SAD, ""Oh! Hello there. Sorry, I didn't really notice you."") player(HeadE.CHEERFUL, ""It's okay. I just hoped you'd have some chocolate for me."") npc(EASTER_BUNNY, HeadE.CAT_SAD, ""So did I, but it's all gone wrong. I only wanted a bit of a rest. Now no one will get their chocolate goodness."") player(HeadE.MORTIFIED, ""WHAT?"") npc(EASTER_BUNNY, HeadE.CAT_SAD, ""I know, depressing, isn't it?"") player(HeadE.CONFUSED, ""Why? What happened this year?"") npc(EASTER_BUNNY, HeadE.CAT_SAD, ""I'm getting too old for this chocolate delivery job, so I went away on a little holiday, hopping that would refresh me. I left my son in charge of the Egg Plant...and now it's all in pieces because he's so lazy."") player(HeadE.CONFUSED, ""Can I help?"") npc(EASTER_BUNNY, HeadE.CAT_CHEERFUL, ""Oh, would you? I hope I'm not being too much truffle. Er...trouble."") player(HeadE.CHEERFUL, ""Of course, what shall I do?"") npc(EASTER_BUNNY, HeadE.CAT_CHEERFUL, ""You could fix up the Egg Plant so it's working; that would be a start."") player(HeadE.CHEERFUL, ""Okay!"") npc(EASTER_BUNNY, HeadE.CAT_CHEERFUL, ""Now you've agreed to help, you'll need to get through the warrens to the Egg Plant, to speak to that lazy son of mine. For that you need to be bunny-sized!"") player(HeadE.CONFUSED, ""How do I do that?"") npc(EASTER_BUNNY, HeadE.CAT_CHEERFUL, ""You simply go down the rabbit hole. My magic will sort the transformation, though you may feel a little itchy for a couple of weeks afterwards. I'll meet you down there!"") player(HeadE.CHEERFUL, ""Off I go then!"") { player.save(STAGE_KEY, 1) } } 1 -> if (player.y > 5000) { player(HeadE.CHEERFUL, ""Wow it sure is dark down here."") npc(EASTER_BUNNY, HeadE.CAT_CHEERFUL, ""Yeah, 'tis the life of a bunny! Glad you made it down safely."") player(HeadE.CHEERFUL, ""What should I be fixing up first?"") npc(EASTER_BUNNY, HeadE.CAT_CHEERFUL, ""Well the first problem to deal with is the Easter Bird.. He hasn't been laying eggs due to being so hungry and thirsty. There's some food and water to the east of him. You'll have to figure out which food he likes."") player(HeadE.CHEERFUL, ""Alright, I'll get right on that!"") { player.save(STAGE_KEY, 2) } } else npc(EASTER_BUNNY, HeadE.CAT_CHEERFUL, ""Speak to me down in my hole. I'll meet you down there!"") 2 -> { player(HeadE.CHEERFUL, ""What am I supposed to be doing again?"") npc(EASTER_BUNNY, HeadE.CAT_CHEERFUL, ""You should wake up the bird with some food and water. I forget what his favorite food is, though. So you're going to have to figure it out."") } 3 -> { player(HeadE.CHEERFUL, ""I woke up the bird!"") npc(EASTER_BUNNY, HeadE.CAT_CHEERFUL, ""Great work! He should get back to laying the easter eggs again pretty quickly now."") player(HeadE.CHEERFUL, ""Awesome. What should I work on next?"") npc(EASTER_BUNNY, HeadE.CAT_CHEERFUL, ""The incubator seems to be broken. I am not sure where the peices even went. My son probably had something to do with it. You should head over to his room to the west ask him about where they are."") player(HeadE.CHEERFUL, ""Alright, thanks. I'll get going."") { player.save(STAGE_KEY, 4) } } 4, 5 -> { player(HeadE.CHEERFUL, ""What am I supposed to be doing again?"") npc(EASTER_BUNNY, HeadE.CAT_CHEERFUL, ""You should be trying to fix the incubator. Like I said before, I am clueless as to what happened to it. My son in his room to the west would be your best bet."") } 6 -> { player(HeadE.CHEERFUL, ""Alright, the incubator is fixed. Your son is absolutely awful.."") npc(EASTER_BUNNY, HeadE.CAT_CHEERFUL, ""Amazing work! Yes, I know he is quite awful. His mother left early on and he seems to have no respect for me and anyone older than him at all despite how much work I do to raise him!"") player(HeadE.CHEERFUL, ""I'm sorry to hear about that."") npc(EASTER_BUNNY, HeadE.CAT_CHEERFUL, ""It's quite alright, I hope I can get through to him someday."") player(HeadE.CHEERFUL, ""I sure hope so. Is everything done yet?"") npc(EASTER_BUNNY, HeadE.CAT_CHEERFUL, ""Not quite, I need some workers to operate the machines if my son is not going to contribute anything to the season."") player(HeadE.CHEERFUL, ""Where do you think I can find some workers?"") npc(EASTER_BUNNY, HeadE.CAT_CHEERFUL, ""Squirrels! One of my great old friends Charlie lives a little north of Falador and he certainly has some motivated and cheerful workers who'd love to help!"") player(HeadE.SKEPTICAL_THINKING, ""Squirrels? If you say so. I'll head up to Falador and see if I can find Charlie then."") { player.save(STAGE_KEY, 7) } } 7 -> { player(HeadE.CHEERFUL, ""What am I supposed to be doing again?"") npc(EASTER_BUNNY, HeadE.CAT_CHEERFUL, ""I need some workers to operate the machinery! My friend Charlie lives up north of Falador, you should speak to him."") } 8 -> { player(HeadE.HAPPY_TALKING, ""It looks like Charlie's workers made it here pretty quickly! The factory looks like it's up and running now. Is there anything else you need help with?"") npc(EASTER_BUNNY, HeadE.CAT_CHEERFUL, ""Oh how eggciting! I think that should be fine for this year. Thank you so much for your help."") player(HeadE.HAPPY_TALKING, ""No problem, is there any special chocolate you can give me now that everything is fixed?"") npc(EASTER_BUNNY, HeadE.CAT_CHEERFUL, ""Oh of course! I almost forgot. Here's a magical ring for all the trouble you went through!"") player(HeadE.CHEERFUL, ""Thank you!"") item(7927, ""The Easter Bunny hands you a chicken costume and unlocks the Bunny Hop emote for you!"") exec { player.save(STAGE_KEY, 9) intArrayOf(11022, 11021, 11020, 11019).forEach { player.inventory.addItemDrop(Item(it, 1)) player.addDiangoReclaimItem(it) } player.emotesManager.unlockEmote(EmotesManager.Emote.BUNNY_HOP) } } 9 -> { player(HeadE.HAPPY_TALKING, ""Happy Easter!"") npc(EASTER_BUNNY, HeadE.CAT_CHEERFUL, ""Happy Easter to you too! I am very grateful for your help. He is risen!"") player(HeadE.HAPPY_TALKING, ""It was nothing. He is risen, indeed!"") } } } } onNpcClick(EASTER_BUNNY_JR) { (player) -> player.startConversation { when (player.getI(STAGE_KEY, 0)) { 4 -> { player(HeadE.CHEERFUL, ""Hello!"") npc(EASTER_BUNNY_JR, HeadE.CAT_PURRING, ""What do you want?.."") player(HeadE.CHEERFUL, ""I need help fixing the incubator and your father told me you might know what happened to it."") npc(EASTER_BUNNY_JR, HeadE.CAT_SAD, ""Sure whatever.. The incubator exploded and they're somewhere around the factory."") player(HeadE.CONFUSED, ""Can you tell me where they are exactly?.."") npc(EASTER_BUNNY_JR, HeadE.CAT_SAD, ""I don't really care and I don't remember.. All I know is that 3 parts went flying off when it exploded. Leave me alone now, I'm trying to sleep."") player(HeadE.ANGRY, ""That doesn't help much at all!"") npc(EASTER_BUNNY_JR, HeadE.CAT_DISAPPOINTED2, ""Ok boomer."") player(HeadE.ROLL_EYES, ""*What a lazy sack of garbage.*"") { player.save(STAGE_KEY, 5) } } 5 -> { player(HeadE.ANGRY, ""Tell me where the incubator parts are."") npc(EASTER_BUNNY_JR, HeadE.CAT_SAD, ""As I said before, I don't really care and I don't remember.. All I know is that 3 parts went flying off around the factory when it exploded."") } else -> { player(HeadE.CHEERFUL, ""Hello!"") npc(EASTER_BUNNY_JR, HeadE.CAT_PURRING, ""Zzzz..."") } } } } } fun useBunnyHole(player: Player, obj: GameObject, toTile: Tile) { player.lock() player.faceObject(obj) player.schedule { wait(1) player.sync(8901, 1567) wait(12) player.tele(toTile) player.anim(8902) wait(9) player.anim(-1) player.unlock() } } @ServerStartupEvent(ServerStartupEvent.Priority.FILE_IO) fun loadEaster2021Spawns() { if (!ENABLED) return ObjectSpawns.add(ObjectSpawn(23117, 10, 0, Tile.of(3210, 3424, 0), ""Rabbit hole"")) NPCSpawns.add(NPCSpawn(9687, Tile.of(3212, 3425, 0), ""Easter Bunny"")) NPCSpawns.add(NPCSpawn(9687, Tile.of(2463, 5355, 0), ""Easter Bunny"")) NPCSpawns.add(NPCSpawn(7411, Tile.of(2448, 5357, 0), ""Easter Bunny Jr"").setCustomName(""Easter Bunny Jr (Trent with Easter 2024 Event)"")) NPCSpawns.add(NPCSpawn(9686, Tile.of(2969, 3431, 0), ""Charlie the Squirrel"")) NPCSpawns.add(NPCSpawn(3283, Tile.of(2968, 3429, 0), ""Squirrel"")) NPCSpawns.add(NPCSpawn(3284, Tile.of(2970, 3429, 0), ""Squirrel"")) NPCSpawns.add(NPCSpawn(3285, Tile.of(2969, 3428, 0), ""Squirrel"")) NPCSpawns.add(NPCSpawn(3285, Tile.of(2968, 3432, 0), ""Squirrel"")) }" "package com.rs.game.content.holidayevents.easter.easter22; @PluginEventHandler public class Easter2022 { //Event configs public static String STAGE_KEY = ""easter2022""; public static Boolean ENABLED = false; //Rewards public static final int PERMANENT_EGGSTERMINATOR = 24146; public static final int XP_LAMP = 2528; public static final int LOYALTY_POINTS_AWARDED = 2500; public static final int EGG_ON_FACE_MASK = 24149; public static final int CHOCOLATE_EGG_ON_FACE_MASK = 24150; public static final int EASTER_TRACK = 273; //Easter Jigg public static final Emote EASTER_EMOTE = Emote.AROUND_THE_WORLD; //Event Items public static final int EGGSTERMINATOR = 24145; public static final int CHOCOTREAT = 24148; public static final int EVIL_DRUMSTICK = 24147; //Event Objects public static final int RUBBLE = 69753; //Event NPCs public static final int CHOCOCHICK = 15270; public static final int CHICK = 15271; public static final int EVIL_CHICKEN = 15262; public static final int CHOCATRICE = 15259; public static final int EVIL_CHICKEN_MEDIUM = 15263; public static final int CHOCATRICE_MEDIUM = 15260; public static final int EVIL_CHICKEN_LARGE = 15264; public static final int CHOCATRICE_LARGE = 15261; public static EggHunt event; static AtomicLong currentTime = new AtomicLong(Instant.now().getEpochSecond()); static long startDate = 1649548800; //April 10th - 00:00 static long endDate = 1650412800; //April 20th - 00:00 /* * Runescape 2012 Easter event - Chocatrice vs Evil Chicken. * * Rewards - * 1 hunt - xp lamp (skill*10) per hunt completed * 1 hunt - Emote -> Around the World in Eggty Days * 1 hunt - Song -> Easter Jigg * 3 hunts - Permanent eggsterminator unlocked * 3 hunts - drumsticks given to the evil chicken -> Egg on face mask * 3 hunts - chocotreats given to the chocatrice -> Chocolate egg on face mask */ //TODO - TYPO IN ObjectType - STRAIGHT_OUSIDE_WALL_DEC @ServerStartupEvent public static void EasterEvent2022() { if (!ENABLED || currentTime.get() >= endDate) return; int ticksToStart = (Settings.getConfig().isDebug() || currentTime.get() >= startDate) ? 10 : Ticks.fromSeconds((int)(startDate - currentTime.get())); int ticksToEnd = Settings.getConfig().isDebug() ? 3000 : Ticks.fromSeconds((int)(endDate - currentTime.get())); WorldTasks.scheduleTimer(ticksToStart, (interval) -> { if (interval >= ticksToEnd) { World.sendWorldMessage(""News: The Easter event is now over! Thanks for participating!"", false); ENABLED = false; return false; } if (interval == 0) { initEasterSpawns(ticksToEnd); event = new EggHunt(); } return true; }); } public static void initEasterSpawns(int ticksToEnd) { // //Load varrock // Region varrock = World.getRegion(12853, true); // // //Remove default game objects that will be in the way // WorldTasks.schedule(Ticks.fromSeconds(5), () -> { // World.removeObject(varrock.getObject(0,5,39, ObjectType.STRAIGHT_OUSIDE_WALL_DEC)); // World.removeObject(varrock.getObject(0,11,46, ObjectType.STRAIGHT_OUSIDE_WALL_DEC)); // World.removeObject(varrock.getObject(0,14,46, ObjectType.STRAIGHT_OUSIDE_WALL_DEC)); // World.removeObject(varrock.getObject(1,9,24, ObjectType.STRAIGHT_OUSIDE_WALL_DEC)); // }); final NPC Chocatrice = new NPC(15259, Tile.of(3208, 3426, 0)); final NPC EvilChicken = new NPC(15262, Tile.of(3216,3426,0)); Chocatrice.faceSouth(); EvilChicken.faceSouth(); World.addNPC(Chocatrice); World.addNPC(EvilChicken); for (Spawns spawn : Spawns.values()) World.spawnObject(spawn.getEgg()); WorldTasks.schedule(ticksToEnd, () -> { Chocatrice.finish(); EvilChicken.finish(); for (EggHunt.Spawns spawn : EggHunt.Spawns.values()) World.removeObject(spawn.getEgg()); }); World.spawnObjectTemporary(new GameObject(70111, ObjectType.SCENERY_INTERACT, 1, Tile.of(3210,3426,0)), ticksToEnd); //Southwest fountain corner World.spawnObjectTemporary(new GameObject(70111, ObjectType.SCENERY_INTERACT, 2, Tile.of(3210,3430,0)), ticksToEnd); //Northwest fountain corner World.spawnObjectTemporary(new GameObject(70112, ObjectType.SCENERY_INTERACT, 0, Tile.of(3211,3427,1)), ticksToEnd); //Southwest fountain chocolate bar World.spawnObjectTemporary(new GameObject(70112, ObjectType.SCENERY_INTERACT, 1, Tile.of(3211,3429,1)), ticksToEnd); //Northwest fountain chocolate bar World.spawnObjectTemporary(new GameObject(70114, ObjectType.SCENERY_INTERACT, 4, Tile.of(3213,3427,1)), ticksToEnd); //Southeast fountain evil egg World.spawnObjectTemporary(new GameObject(70114, ObjectType.SCENERY_INTERACT, 3, Tile.of(3213,3429,1)), ticksToEnd); //Northeast fountain evil egg World.spawnObjectTemporary(new GameObject(70124, ObjectType.WALL_STRAIGHT, 0, Tile.of(3212,3431,0)), ticksToEnd); //North chocolate egg wall World.spawnObjectTemporary(new GameObject(70125, ObjectType.WALL_STRAIGHT, 1, Tile.of(3210,3429,0)), ticksToEnd); //Northwest chocolate egg wall World.spawnObjectTemporary(new GameObject(70125, ObjectType.WALL_STRAIGHT, 0, Tile.of(3212,3426,0)), ticksToEnd); //South chocolate egg wall World.spawnObjectTemporary(new GameObject(70124, ObjectType.WALL_STRAIGHT, 3, Tile.of(3210,3428,0)), ticksToEnd); //Southwest chocolate egg wall World.spawnObjectTemporary(new GameObject(70127, ObjectType.WALL_STRAIGHT, 2, Tile.of(3213,3431,0)), ticksToEnd); //North evil egg wall World.spawnObjectTemporary(new GameObject(70126, ObjectType.WALL_STRAIGHT, 1, Tile.of(3215,3429,0)), ticksToEnd); //Northeast evil egg wall World.spawnObjectTemporary(new GameObject(70126, ObjectType.WALL_STRAIGHT, 2, Tile.of(3213,3426,0)), ticksToEnd); //South evil egg wall World.spawnObjectTemporary(new GameObject(70127, ObjectType.WALL_STRAIGHT, 3, Tile.of(3215,3428,0)), ticksToEnd); //Southeast evil egg wall World.spawnObjectTemporary(new GameObject(70123, ObjectType.SCENERY_INTERACT, 0, Tile.of(3211,3438,0)), ticksToEnd); //Castle entrance west standing banner World.spawnObjectTemporary(new GameObject(70123, ObjectType.SCENERY_INTERACT, 0, Tile.of(3214,3438,0)), ticksToEnd); //Castle entrance east standing banner World.spawnObjectTemporary(new GameObject(70119, ObjectType.SCENERY_INTERACT, 0, Tile.of(3224,3427,0)), ticksToEnd); //Varrock east path pole World.spawnObjectTemporary(new GameObject(70119, ObjectType.SCENERY_INTERACT, 2, Tile.of(3224,3432,0)), ticksToEnd); //Varrock east path pole World.spawnObjectTemporary(new GameObject(70117, ObjectType.SCENERY_INTERACT, 2, Tile.of(3224,3428,1)), ticksToEnd); //Varrock east path banner World.spawnObjectTemporary(new GameObject(70123, ObjectType.GROUND_INTERACT, 1, Tile.of(3229,3428,0)), ticksToEnd); //Varrock east path standing banner World.spawnObjectTemporary(new GameObject(70116, ObjectType.SCENERY_INTERACT, 1, Tile.of(3208,3410,1)), ticksToEnd); //Varrock south path banner World.spawnObjectTemporary(new GameObject(70116, ObjectType.SCENERY_INTERACT, 0, Tile.of(3200,3427,1)), ticksToEnd); //Varrock west path banner World.spawnObjectTemporary(new GameObject(70119, ObjectType.SCENERY_INTERACT, 0, Tile.of(3200,3426,0)), ticksToEnd); //Varrock west path pole World.spawnObjectTemporary(new GameObject(70123, ObjectType.SCENERY_INTERACT, 3, Tile.of(3205,3431,0)), ticksToEnd); //Zaffs shop standing banner World.spawnObjectTemporary(new GameObject(70122, ObjectType.SCENERY_INTERACT, 2, Tile.of(3205,3433,1)), ticksToEnd); //Zaffs shop hanging banner World.spawnObjectTemporary(new GameObject(70121, ObjectType.SCENERY_INTERACT, 2, Tile.of(3209,3416,1)), ticksToEnd); //Thessalia's shop hanging banner World.spawnObjectTemporary(new GameObject(70123, ObjectType.GROUND_INTERACT, 2, Tile.of(3209,3419,0)), ticksToEnd); //Thessalia's shop standing banner World.spawnObjectTemporary(new GameObject(70123, ObjectType.GROUND_INTERACT, 1, Tile.of(3213,3420,0)), ticksToEnd); //General store standing banner World.spawnObjectTemporary(new GameObject(42651, ObjectType.SCENERY_INTERACT, 0, Tile.of(3222,3435,0)), ticksToEnd); //Random easter eggs World.spawnObjectTemporary(new GameObject(42652, ObjectType.SCENERY_INTERACT, 3, Tile.of(3224,3425,0)), ticksToEnd); //Random easter eggs World.spawnObjectTemporary(new GameObject(42650, ObjectType.SCENERY_INTERACT, 3, Tile.of(3219,3421,0)), ticksToEnd); //Random easter eggs World.spawnObjectTemporary(new GameObject(42650, ObjectType.SCENERY_INTERACT, 0, Tile.of(3223,3421,0)), ticksToEnd); //Random easter eggs World.spawnObjectTemporary(new GameObject(42650, ObjectType.SCENERY_INTERACT, 2, Tile.of(3207,3420,0)), ticksToEnd); //Random easter eggs World.spawnObjectTemporary(new GameObject(42652, ObjectType.SCENERY_INTERACT, 0, Tile.of(3206,3421,0)), ticksToEnd); //Random easter eggs World.spawnObjectTemporary(new GameObject(42651, ObjectType.SCENERY_INTERACT, 0, Tile.of(3200,3442,0)), ticksToEnd); //Random easter eggs World.spawnObjectTemporary(new GameObject(42651, ObjectType.SCENERY_INTERACT, 1, Tile.of(3199,3441,0)), ticksToEnd); //Random easter eggs } }" "package com.rs.game.content.holidayevents.easter.easter22; @PluginEventHandler public class EggHunt { public enum Spawns { BURTHORPE_LODESTONE(new EventEasterEgg(Easter2022.RUBBLE,ObjectType.SCENERY_INTERACT,0,2906,3549,0), ""near Burthorpe Lodestone/South of the Burthorpe castle.""), BURTHORPE_AGILITY(new EventEasterEgg(Easter2022.RUBBLE,ObjectType.SCENERY_INTERACT,0,2920,3569,0), ""in the Burthorpe agility course area.""), // TAVERLEY_MINE(new EventEasterEgg(Easter2022.RUBBLE,ObjectType.SCENERY_INTERACT,0,0,0,0), ""inside the Taverley mine.""), TAVERLEY_GATE(new EventEasterEgg(Easter2022.RUBBLE,ObjectType.SCENERY_INTERACT,0,2932,3461,0), ""in Taverley, near and a bit north of the entrance closest to Falador.""), WHITE_WOLF_MOUNTAIN(new EventEasterEgg(Easter2022.RUBBLE,ObjectType.SCENERY_INTERACT,0,2856,3457,0), ""on the east side of White Wolf Mountain.""), TAVERLEY_DUNGEON(new EventEasterEgg(Easter2022.RUBBLE,ObjectType.SCENERY_INTERACT,0,2884, 9813,0), ""inside Taverley Dungeon.""), WITCHES_HOUSE(new EventEasterEgg(Easter2022.RUBBLE,ObjectType.SCENERY_INTERACT,0,2903,3383,0), ""north of the Witch's House/south of Taverley, near the wheat field.""), DARK_WIZARDS_TOWER(new EventEasterEgg(Easter2022.RUBBLE,ObjectType.SCENERY_INTERACT,0,2895,3351,0), ""Northwest of the Dark Wizards' Tower/south of the Witch's House.""), EXAM_CENTRE(new EventEasterEgg(Easter2022.RUBBLE,ObjectType.SCENERY_INTERACT,0,3326,3336,0), ""west of the Exam Centre.""), // DIG_SITE(new EventEasterEgg(Easter2022.RUBBLE,ObjectType.SCENERY_INTERACT,0,0,0,0), ""west of the Varrock Dig Site.""), SILVAREA(new EventEasterEgg(Easter2022.RUBBLE,ObjectType.SCENERY_INTERACT,0,3339,3482,0), ""in Silvarea, the mountain path between Varrock and Morytania.""), BRIMHAVEN_FISHING(new EventEasterEgg(Easter2022.RUBBLE,ObjectType.SCENERY_INTERACT,0,2776,3175,0), ""in Brimhaven, near the fishing spots in the South.""), MAGE_TRAINING_ARENA(new EventEasterEgg(Easter2022.RUBBLE,ObjectType.SCENERY_INTERACT,0,3348,3291,0), ""a little way in front of the gate leading to the Mage Training Arena.""), CRAFTING_GUILD(new EventEasterEgg(Easter2022.RUBBLE,ObjectType.SCENERY_INTERACT,0,2949,3269,0), ""between the Crafting Guild and the Clan Camp.""), RIMMINGTON(new EventEasterEgg(Easter2022.RUBBLE,ObjectType.SCENERY_INTERACT,0,2939,3197,0), ""south-west area of Rimmington.""), BANANA_PLANTATION(new EventEasterEgg(Easter2022.RUBBLE,ObjectType.SCENERY_INTERACT,0,2917,3159,0), ""in the banana plantation on Musa Point.""), KARAMJA_VOLCANO(new EventEasterEgg(Easter2022.RUBBLE,ObjectType.SCENERY_INTERACT,0,2872,3148,0), ""between Karamja Volcano and Musa Point, near the agility shortcut to the south.""), GAMERS_GROTTO(new EventEasterEgg(Easter2022.RUBBLE,ObjectType.SCENERY_INTERACT,0,2991,3406,0), ""west of Gamers' Grotto (near Falador Lodestone).""), GOBLIN_VILLAGE(new EventEasterEgg(Easter2022.RUBBLE,ObjectType.SCENERY_INTERACT,0,2947,3479,0), ""south of the Goblin Village near Falador.""), CAPTURED_TEMPLE(new EventEasterEgg(Easter2022.RUBBLE,ObjectType.SCENERY_INTERACT,0,2975,3461,0), ""directly between the Captured Temple and Ice Mountain.""), NEDS_HOUSE(new EventEasterEgg(Easter2022.RUBBLE,ObjectType.SCENERY_INTERACT,0,3095,3262,0), ""in Draynor Village (Near Ned's house).""), EAST_DRAYNOR_MANOR(new EventEasterEgg(Easter2022.RUBBLE,ObjectType.SCENERY_INTERACT,0,3160,3338,0), ""east of Draynor Manor, in the place that used to be Gnomecopter Tours.""), WEST_DRAYNOR_MANOR(new EventEasterEgg(Easter2022.RUBBLE,ObjectType.SCENERY_INTERACT,0,3072,3352,0), ""between the walls of Falador and Draynor Manor.""), CHAMPIONS_GUILD(new EventEasterEgg(Easter2022.RUBBLE,ObjectType.SCENERY_INTERACT,0,3236,3344,0), ""in the sheep's pen east of the Champions' Guild.""), // SOUTH_VARROCK(new EventEasterEgg(Easter2022.RUBBLE,ObjectType.SCENERY_INTERACT,0,0,0,0), ""south of Varrock, next to the Stone circle""), GERTRUDES_HOUSE(new EventEasterEgg(Easter2022.RUBBLE,ObjectType.SCENERY_INTERACT,0,3154,3390,0), ""near the Cooks' Guild, south of Gertrude's house.""), BARBARIAN_VILLAGE(new EventEasterEgg(Easter2022.RUBBLE,ObjectType.SCENERY_INTERACT,0,3094,3450,0), ""east of Barbarian Village, near the unicorns.""), WEST_GRANDE_EXCHANGE(new EventEasterEgg(Easter2022.RUBBLE,ObjectType.SCENERY_INTERACT,0,3112,3483,0), ""west of the Grand Exchange, near the Outlaw Camp.""), LUMBRIDGE_CASTLE(new EventEasterEgg(Easter2022.RUBBLE,ObjectType.SCENERY_INTERACT,0,3208,3204,0), ""around Lumbridge Castle.""), LUMBRIDGE_SWAMP(new EventEasterEgg(Easter2022.RUBBLE,ObjectType.SCENERY_INTERACT,0,3206,3143,0), ""west of Lumbridge Swamp mining spot, behind Father Urhney's house.""), EDGEVILLE_MONASTERY(new EventEasterEgg(Easter2022.RUBBLE,ObjectType.SCENERY_INTERACT,0,3036,3488,0), ""west of Edgeville Monastery.""), // ICE_MOUNTAIN(new EventEasterEgg(Easter2022.RUBBLE,ObjectType.SCENERY_INTERACT,0,0,0,0), ""on top of Ice Mountain""), VARROCK_LUMBER_YARD(new EventEasterEgg(Easter2022.RUBBLE,ObjectType.SCENERY_INTERACT,0,3275, 3457,0), ""east of Varrock, near the Saradomin statue South-West of Lumber Yard.""), VARROCK_EAST_STATUE(new EventEasterEgg(Easter2022.RUBBLE,ObjectType.SCENERY_INTERACT,0,3308,3490,0), ""directly in front of Lumber Yard, southern part.""), DAEMONHEIM(new EventEasterEgg(Easter2022.RUBBLE,ObjectType.SCENERY_INTERACT,0,3428, 3743,0), ""around the back of Daemonheim castle.""), FREMENNIK_CAMP_DAEMONHEIM(new EventEasterEgg(Easter2022.RUBBLE,ObjectType.SCENERY_INTERACT,0,3463,3677,0), ""south of the Fremennik Camp on the Daemonheim Peninsula.""), MUDSKIPPER_POINT(new EventEasterEgg(Easter2022.RUBBLE,ObjectType.SCENERY_INTERACT,0,2996,3118,0), ""in the centre of Mudskipper Point.""); private final EventEasterEgg egg; private Spawns(EventEasterEgg egg, String hint) { this.egg = egg; egg.setHint(hint); } public EventEasterEgg getEgg() { return egg; } public static Spawns getSpawnByObject(GameObject o) { for (Spawns spawn : Spawns.values()) { if (spawn.getEgg().getX() == o.getX() && spawn.getEgg().getY() == o.getY() && spawn.getEgg().getPlane() == o.getPlane()) return spawn; } return null; } } private static final int[] varbits = new int[] { 10954, 11014, 11015, 11016, 11017 }; private static final List eggs = new ArrayList<>(); private static int hunt = 0; private static int chocatriceScore = 0; private static int evilChickenScore = 0; private static int timer = 1; private static boolean active = false; public EggHunt() { WorldTasks.scheduleTimer(0, (ticks) -> { if (!Easter2022.ENABLED) return false; timer--; switch (timer) { case 12000 -> start(); case 1000 -> { if (Settings.getConfig().isDebug()) start(); } case 500 -> end(); case 0 -> timer = Settings.getConfig().isDebug() ? 1001 : 12001; } return true; }); } public static LoginHandler resetVars = new LoginHandler(e -> { if (!Easter2022.ENABLED) return; if (e.getPlayer().getI(Easter2022.STAGE_KEY+""CurrentHunt"", 0) != hunt) for (int idx = 0; idx < 5; idx++) e.getPlayer().getVars().saveVarBit(varbits[idx], 0); }); public void start() { active = true; hunt++; while (eggs.size() > 0) eggs.removeFirst(); while (eggs.size() < 5) { Spawns spawn = Spawns.values()[Utils.random(EggHunt.Spawns.values().length)]; if (!eggs.contains(spawn.ordinal())) { eggs.add(spawn.ordinal()); spawn.getEgg().setId(70105 + eggs.size()); Logger.debug(EggHunt.class, ""start"", ""Setting egg ["" + spawn.ordinal() + ""] "" + spawn.getEgg().getX() + "", "" + spawn.getEgg().getY() + "" with a varbit of "" + spawn.getEgg().getDefinitions().varpBit); } } for (Player p : World.getPlayers()) { for (int idx = 0; idx < 5; idx++) p.getVars().saveVarBit(varbits[idx], 0); p.getNSV().removeB(""talkedWithEvilChicken""); p.getNSV().removeB(""talkedWithChocatrice""); } World.sendWorldMessage(""News: A new Easter Egg Hunt has begun! Speak with the Evil Chicken or Chocatrice in Varrock Square to start it."", false); } public void end() { active = false; for (int spawn : eggs) { Spawns.values()[spawn].getEgg().setId(Easter2022.RUBBLE); Spawns.values()[spawn].getEgg().setFound(false); } World.sendWorldMessage(""News: The Easter Egg Hunt has ended! A new one will commence shortly."", false); } public static boolean hasCompletedHunt(Player p) { if (p.getI(Easter2022.STAGE_KEY+""CurrentHunt"", 0) != hunt) return false; for (int idx = 0; idx < 5; idx++) if (p.getVars().getVarBit(varbits[idx]) != 3) return false; return true; } public static int getChocatriceScore() { return chocatriceScore; } public static int getEvilChickenScore() { return evilChickenScore; } public static int getHunt() { return hunt; } public static String getHint() { return Spawns.values()[eggs.getFirst()].getEgg().getHint(); } public static int getTime() { return (int) ((double) timer / 100); } public static String getTimeString() { if (active) return ""The hunt will be ending in "" + (getTime()-5) + ((getTime()-5 > 1) ? "" minutes."" : "" minute.""); else { if (getTime() == 0) return ""The next hunt will be starting in less than a minute.""; return ""The next hunt will be starting in "" + getTime() + ((getTime() > 1) ? "" minutes."" : "" minute.""); } } public static void incrementScore(int attackStyle) { if (attackStyle == 0) evilChickenScore++; else chocatriceScore++; } public static boolean active() { return active; } }" "package com.rs.game.content.holidayevents.easter.easter22; @PluginEventHandler public class EggsterminatorInteraction extends PlayerEntityInteraction { public EggsterminatorInteraction(Entity target) { super(target, 7); } @Override public void interact(Player player) { player.lock(); player.resetWalkSteps(); player.setNextFaceTile(target.getTile()); player.setNextAnimation(new Animation(12174)); player.setNextSpotAnim(new SpotAnim(2138)); int attackStyle = player.getCombatDefinitions().getAttackStyleId(); int delay = World.sendProjectile(player.getTile(), target, (attackStyle == 0 ? 3034 : 3035), 20, 20, 30, 1, 0, 0).getTaskDelay(); WorldTasks.schedule(delay, () -> { if (target instanceof NPC n) { n.sendDeath(player); World.sendSpotAnim(target.getTile(), attackStyle == 0 ? new SpotAnim(3033) : new SpotAnim(3032)); } else if (target instanceof Player p) { World.sendSpotAnim(target.getTile(), attackStyle == 0 ? new SpotAnim(3037) : new SpotAnim(3036)); if ((p.getEquipment().getHatId() == Easter2022.EGG_ON_FACE_MASK || p.getEquipment().getHatId() == Easter2022.CHOCOLATE_EGG_ON_FACE_MASK) && p.getNextAnimation() == null) p.setNextAnimation(new Animation(2107)); } player.unlock(); }); } @Override public boolean canStart(Player player) { return true; } @Override public boolean checkAll(Player player) { return true; } @Override public void onStop(Player player) {} public static PlayerClickHandler handlePlayerSplatter = new PlayerClickHandler(false, ""Splatter"", e -> e.getPlayer().getInteractionManager().setInteraction(new EggsterminatorInteraction(e.getTarget()))); public static NPCClickHandler handleNPCSplatter = new NPCClickHandler(false, new Object[] { Easter2022.CHOCOCHICK, Easter2022.CHICK }, new String[] { ""Splatter"" }, e -> e.getPlayer().getInteractionManager().setInteraction(new EggsterminatorInteraction(e.getNPC()))); public static ItemEquipHandler handleEggsterminatorWield = new ItemEquipHandler(new Object[] { Easter2022.EGGSTERMINATOR, Easter2022.PERMANENT_EGGSTERMINATOR }, e -> { if (e.equip()) { e.getPlayer().setPlayerOption(""Splatter"", 8, true); if (Easter2022.ENABLED) e.getPlayer().sendMessage(""Using the Combat Styles menu, you can choose whether to fire marshmallows (in support of the Chocatrice) or scotch-eggs (in support of the Evil Chicken).""); return; } if (e.getItem().getId() == Easter2022.EGGSTERMINATOR) { e.cancel(); e.getPlayer().sendOptionDialogue(""Destroy the Eggsterminator?"", ops -> { ops.add(""Yes, destroy it."", () -> { e.getPlayer().getEquipment().setNoPluginTrigger(Equipment.WEAPON, null); e.getPlayer().setPlayerOption(""null"", 8, true); e.getPlayer().getEquipment().refresh(Equipment.WEAPON); e.getPlayer().getAppearance().generateAppearanceData(); }); ops.add(""No, keep it.""); }); } else e.getPlayer().setPlayerOption(""null"", 8, true); }); public static LoginHandler removeTempEggsterminator = new LoginHandler(e -> { if (Easter2022.ENABLED) return; if (e.getPlayer().getEquipment().getWeaponId() == Easter2022.EGGSTERMINATOR) { e.getPlayer().getEquipment().deleteItem(Easter2022.EGGSTERMINATOR, 1); e.getPlayer().getEquipment().refresh(Equipment.WEAPON); e.getPlayer().getAppearance().generateAppearanceData(); e.getPlayer().sendMessage(""The Easter event is over and the magic of your Eggsterminator has vanished. You watch as it melts into chocolate.""); } }); }" "package com.rs.game.content.holidayevents.easter.easter22; @PluginEventHandler public class EventEasterEgg extends GameObject { private boolean found = false; private String hint; public EventEasterEgg(int id, ObjectType type, int rotation, int x, int y, int plane) { super(id, type, rotation, x, y, plane); } public void setHint(String loc) { hint = loc; } public String getHint() { return hint; } public void setFound(boolean spotted) { found = spotted; } public boolean getFound() { return found; } private void spotted(Player p) { if (getFound() == false) World.sendWorldMessage("""" + p.getDisplayName() + "" has found an egg "" + getHint(), false); setFound(true); } public static ObjectClickHandler crackEgg = new ObjectClickHandler(false, new Object[] { 70106, 70107, 70108, 70109, 70110 }, e -> { if (!(e.getObject() instanceof EventEasterEgg egg)) return; if (!Easter2022.ENABLED) return; if (e.getOption().equals(""Crack"")) { if (e.getPlayer().getEquipment().getWeaponId() != Easter2022.EGGSTERMINATOR && e.getPlayer().getEquipment().getWeaponId() != Easter2022.PERMANENT_EGGSTERMINATOR) { e.getPlayer().sendMessage(""You need the Eggsterminator to crack open this egg. Speak with the Evil Chicken or the Chocatrice in Varrock Square.""); return; } e.getPlayer().lock(); e.getPlayer().resetWalkSteps(); e.getPlayer().faceObject(e.getObject()); e.getPlayer().setNextAnimation(new Animation(12174)); e.getPlayer().setNextSpotAnim(new SpotAnim(2138)); int attackStyle = e.getPlayer().getCombatDefinitions().getAttackStyleId(); int delay = World.sendProjectile(e.getPlayer().getTile(), Tile.of(e.getObject().getTile()), (attackStyle == 0 ? 3034 : 3035), 20, 10, 30, 1, 0, 0).getTaskDelay(); int npcId = (attackStyle == 0 ? Easter2022.CHICK : Easter2022.CHOCOCHICK); egg.spotted(e.getPlayer()); WorldTasks.scheduleTimer(delay, (tick) -> { switch (tick) { case 0 -> { e.getPlayer().getVars().saveVarBit(e.getObject().getDefinitions().varpBit, (attackStyle == 0 ? 2 : 1)); e.getPlayer().getPackets().sendObjectAnimation(e.getObject(), new Animation(16432)); } case 2 -> { EasterChick npc = new EasterChick(e.getPlayer(), npcId, World.getFreeTile(Tile.of(e.getObject().getX(), e.getObject().getY(), e.getObject().getPlane()), 2), e.getObject().getDefinitions().varpBit); e.getPlayer().startConversation(new Dialogue().addItem(Easter2022.PERMANENT_EGGSTERMINATOR, ""You shatter the egg with the Eggsterminator. A "" + npc.getName().toLowerCase() + "" appears."")); e.getPlayer().sendMessage(""You shatter the egg with the Eggsterminator. A "" + npc.getName().toLowerCase() + "" appears.""); if (e.getPlayer().getI(Easter2022.STAGE_KEY+""CurrentHunt"", 0) != EggHunt.getHunt()) e.getPlayer().save(Easter2022.STAGE_KEY+""CurrentHunt"", EggHunt.getHunt()); e.getPlayer().unlock(); return false; } } return true; }); } }); }" "package com.rs.game.content.holidayevents.easter.easter22.npcs; @PluginEventHandler public class ChocatriceD extends Conversation { public ChocatriceD(Player player) { super(player); if (player.getNSV().getB(""talkedWithEvilChicken"") && !player.getNSV().getB(""talkedWithChocatrice"")) { addNPC(Easter2022.CHOCATRICE, HeadE.NO_EXPRESSION, ""You already spoke to that Evil Chicken! What lies has he told you? Forget them - trust only Chocatrice!""); } else if (!player.getNSV().getB(""talkedWithEvilChicken"") && !player.getNSV().getB(""talkedWithChocatrice"")) { addNPC(Easter2022.CHOCATRICE, HeadE.NO_EXPRESSION, ""Good - you haven't spoken to that Evil Chicken yet. Nasty, lying chicken, that one. "" + ""Think he's better than Chocatrice because he's made of flesh and feathers. You talk with Chocatrice; you trust Chocatrice.""); addPlayer(HeadE.CALM_TALK, ""What are you two doing here?""); } else if (player.getNSV().getB(""talkedWithChocatrice"")) { addNPC(Easter2022.CHOCATRICE, HeadE.NO_EXPRESSION, ""Hello again, "" + player.getDisplayName()); if (EggHunt.hasCompletedHunt(player)) { if (!player.getEmotesManager().unlockedEmote(Easter2022.EASTER_EMOTE)) { player.getEmotesManager().unlockEmote(Easter2022.EASTER_EMOTE); player.sendMessage(""You have unlocked an Easter emote, "" + Easter2022.EASTER_EMOTE.name().toLowerCase().replace(""_"", "" "") + "".""); } if (!player.getMusicsManager().hasMusic(Easter2022.EASTER_TRACK)) { player.getMusicsManager().unlockMusic(Easter2022.EASTER_TRACK); player.sendMessage(""You have unlocked an Easter track, "" + Music.getSong(Easter2022.EASTER_TRACK).getName() + "".""); } addNPC(Easter2022.CHOCATRICE, HeadE.NO_EXPRESSION, ""Well done, soldier, you've found all the eggs this hunt. You're delightfully despicable.""); addNPC(Easter2022.CHOCATRICE, HeadE.NO_EXPRESSION, EggHunt.getTimeString()); } if (player.getCounterValue(Easter2022.STAGE_KEY + ""CompletedHunts"") >= 3 && !player.getDiangoReclaim().contains(Easter2022.PERMANENT_EGGSTERMINATOR)) { addNPC(Easter2022.CHOCATRICE, HeadE.NO_EXPRESSION, ""Good work, you must enjoy smashing those eggs. Seeing you've been so helpfully destructive I can enchant your Eggsterminator so that it will last after Easter. "" + ""Want me to do that for you?""); addOptions(new Options(""unlockPermanent"", ChocatriceD.this) { @Override public void create() { option(""Yes"", new Dialogue() .addNext(() -> { player.addDiangoReclaimItem(Easter2022.PERMANENT_EGGSTERMINATOR); if (player.getEquipment().getWeaponId() == Easter2022.EGGSTERMINATOR) { player.getEquipment().setNoPluginTrigger(Equipment.WEAPON, new Item(Easter2022.PERMANENT_EGGSTERMINATOR)); player.sendMessage(""The Chocatrice enchants your Eggsterminator...""); } }) .addItem(Easter2022.PERMANENT_EGGSTERMINATOR, ""You will now be able to keep the Eggsterminator after the Easter event."") .addGotoStage(""huntOps"", ChocatriceD.this) ); option(""No"", new Dialogue().addGotoStage(""continued"", ChocatriceD.this)); } }); } if (player.getInventory().containsItem(Easter2022.CHOCOTREAT, 3) && !player.getDiangoReclaim().contains(Easter2022.CHOCOLATE_EGG_ON_FACE_MASK)) { addNPC(Easter2022.CHOCATRICE, HeadE.NO_EXPRESSION, ""Excellent! Three delicious chocotreats for me. May I have them?""); addOptions(new Options(""buyMask"", this) { @Override public void create() { option(""Yes"", () -> { player.getInventory().deleteItem(Easter2022.CHOCOTREAT, 3); player.addDiangoReclaimItem(Easter2022.CHOCOLATE_EGG_ON_FACE_MASK); player.getInventory().addItemDrop(Easter2022.CHOCOLATE_EGG_ON_FACE_MASK, 1); addItem(Easter2022.CHOCOLATE_EGG_ON_FACE_MASK, ""You receive the chocolate egg on face mask."") .addGotoStage(""huntOps"", ChocatriceD.this); }); option(""No"", new Dialogue().addGotoStage(""huntOps"", ChocatriceD.this)); } }); } addNext(new StageSelectDialogue(""huntOps"", this.getStages())); } player.getNSV().setB(""talkedWithChocatrice"", true); create(""continued"", addNPC(Easter2022.CHOCATRICE, HeadE.NO_EXPRESSION, ""Chocatrice is hosting this year's Easter hunt. No more annoying bunnies or pesky, nasty little squirrels."")); addPlayer(HeadE.CALM_TALK, ""Shouldn't the Easter bunny be hosting it?""); addNPC(Easter2022.CHOCATRICE, HeadE.NO_EXPRESSION, ""Oh, you not heard? Easter Bunny had an accident. Poor Easter Bunny fell down White Wolf Mountain with a boulder tied to his feet. "" + ""Poor, poor Easter Bunny. So sad. Chocatrice saw the whole thing. Most messy.""); addNPC(Easter2022.CHOCATRICE, HeadE.NO_EXPRESSION, ""Luckily, tragic accident happened after Easter Bunny hid his five giant, magical eggs across Runescape""); if (player.getNSV().getB(""talkedWithEvilChicken"")) { addPlayer(HeadE.CALM_TALK, ""Let me guess. You want me to hunt down these eggs and blow them open with the Eggsterminator""); addNPC(Easter2022.CHOCATRICE, HeadE.NO_EXPRESSION, ""Oh, what has nasty Evil Chicken told you?""); } else { addPlayer(HeadE.CALM_TALK, ""So you want me to find these giant eggs?""); addNPC(Easter2022.CHOCATRICE, HeadE.NO_EXPRESSION, ""Find? Yes. They must be.... cracked... open.""); addPlayer(HeadE.CALM_TALK, ""With a giant teaspoon, right?""); addNPC(Easter2022.CHOCATRICE, HeadE.NO_EXPRESSION, player.getDisplayName() + "", you are funny. Yes, you are... Not teaspoon. With the Eggsterminator.""); addItem(Easter2022.EGGSTERMINATOR, ""The Chocatrice shows you the Eggsterminator.""); } addNPC(Easter2022.CHOCATRICE, HeadE.NO_EXPRESSION, ""Once egg smashed, little chick inside will try to escape. You shoot him down with molten chocolatey marshmallow and turn him into delicious, chocolatey treat.""); addNPC(Easter2022.CHOCATRICE, HeadE.NO_EXPRESSION, ""Now it very important, you don't speak with Evil Chicken. He think we should turn tasty little chicks into drumsticks. Nasty, nasty Evil Chicken. "" + ""They would taste much better as chocolate, don't you agree?""); addOptions(new Options(""takingSides"", this) { @Override public void create() { option(""Chocolate does sound better."", new Dialogue().addNPC(Easter2022.CHOCATRICE, HeadE.NO_EXPRESSION, ""Yes... Delicious, scrummy, tasty chocolate."").addGotoStage(""declareWar"", ChocatriceD.this)); option(""I'm more of a friend chicken kind of "" + (player.getAppearance().isMale() ? ""guy."" : ""gal.""), new Dialogue() .addNPC(Easter2022.CHOCATRICE, HeadE.NO_EXPRESSION, ""No! Why deep-fry when you can smother in chocolate and marshmallow? Death by chocolate!"") .addGotoStage(""declareWar"", ChocatriceD.this)); } }); create(""declareWar"", addNPC(Easter2022.CHOCATRICE, HeadE.NO_EXPRESSION, ""Evil Chicken declares war on poor Chocatrice, says he will turn more chicks into drumsticks than Chocatrice can turn into chocolate. If Evil Chicken wants war, Chocatrice gives it."")); addOptions(new Options(""huntOps"", ChocatriceD.this) { @Override public void create() { if (!player.getInventory().containsItem(Easter2022.EGGSTERMINATOR) && !player.getBank().containsItem(Easter2022.EGGSTERMINATOR, 1) && player.getEquipment().getWeaponId() != Easter2022.EGGSTERMINATOR && !player.getInventory().containsItem(Easter2022.PERMANENT_EGGSTERMINATOR) && !player.getBank().containsItem(Easter2022.PERMANENT_EGGSTERMINATOR, 1) && player.getEquipment().getWeaponId() != Easter2022.PERMANENT_EGGSTERMINATOR) { option(""Start the hunt."", (player.getEquipment().getWeaponId() != -1 || player.getEquipment().getShieldId() != -1) ? new Dialogue() .addNPC(Easter2022.CHOCATRICE, HeadE.NO_EXPRESSION, ""Your hands must be free."") : new Dialogue() .addItem(Easter2022.EGGSTERMINATOR, ""You're handed (or 'winged') the Eggsterminator."") .addNext(() -> { player.getEquipment().setSlot(Equipment.WEAPON, new Item(Easter2022.EGGSTERMINATOR)); player.getAppearance().generateAppearanceData(); }) .addNPC(Easter2022.CHOCATRICE, HeadE.NO_EXPRESSION, ""Hunt down the five eggs scattered across Runescape. Blow them open with the Eggsterminator and splatter the chick that comes from within."") .addSimple(""These eggs can be found around Runescape. You can search for them yourself or with your friends."") //Information can also be found on the Runescape official forums. .addSimple(""Finding all 5 eggs in a single hunt will unlock additional rewards."")); //Some eggs only appear in members parts of the world, so only members gain these additional benefits. } else { option(""How do I hunt the eggs?"", new Dialogue() .addNPC(Easter2022.CHOCATRICE, HeadE.NO_EXPRESSION, ""The Easter Bunny has hidden magical eggs across Runescape. Unfortunate, the Easter Bunny is temporarily...indisposed...and so is unable to perform his duties as huntmaster. "" + ""I am now in charge of the hunt."") .addNPC(Easter2022.EVIL_CHICKEN, HeadE.NO_EXPRESSION, ""No, you aren't. I am!"") .addNPC(Easter2022.CHOCATRICE, HeadE.NO_EXPRESSION, ""Quiet, you."") .addNPC(Easter2022.CHOCATRICE, HeadE.NO_EXPRESSION, ""Every two hours, a new hunt will begin. Hunt down the five eggs, smash them open using the Eggsterminator and then shoot at the chick that emerges with the Eggsterminator. "" + ""This will turn the chick into a tasty treat."")); option(""Can I have a hint?"", (EggHunt.active() ? (player.getVars().getVarBit(10954) == 3 ? new Dialogue() .addNPC(Easter2022.EVIL_CHICKEN, HeadE.NO_EXPRESSION, ""You've already found the egg I have information on."") : new Dialogue() .addNPC(Easter2022.EVIL_CHICKEN, HeadE.NO_EXPRESSION, ""Nasty chicken and I agreed not to help the hunters find any of the eggs, but..."") .addOption(""Listen to the hint?"", ""Yes"", ""No"") .addSimple(""The bird lowers its voice."") .addNPC(Easter2022.CHOCATRICE, HeadE.NO_EXPRESSION, ""One egg can be found "" + EggHunt.getHint())) : new Dialogue() .addNPC(Easter2022.EVIL_CHICKEN, HeadE.NO_EXPRESSION, ""The hunt has ended. "" + EggHunt.getTimeString()))); } option(""Who is winning the egg hunt?"", new Dialogue() .addSimple(""Chocatrice: "" + EggHunt.getChocatriceScore() + ""

vs

"" + ""Evil Chicken: "" + EggHunt.getEvilChickenScore())); option(""Who are you?"", new Dialogue() .addNPC(Easter2022.CHOCATRICE, HeadE.NO_EXPRESSION,""I was born from an egg dipped in chocolate. The others insulted me, even the cockatrices."") .addNPC(Easter2022.CHOCATRICE, HeadE.NO_EXPRESSION,""So I turned them all into chocolate! Now they no longer insult me!"") .addSimple(""You get the impression that this bird is quite mad."")); option(""Talk about rewards."", new Dialogue().addOptions(new Options() { @Override public void create() { option(""Mask rewards"", new Dialogue() .addNPC(Easter2022.CHOCATRICE, HeadE.NO_EXPRESSION, ""If you gather 3 scrumptious chocotreats for me I'll trade them for a chocolate egg on face mask."")); option(""Eggsterminator (permanent)"", new Dialogue() .addNPC(Easter2022.CHOCATRICE, HeadE.NO_EXPRESSION, ""The Eggsterminator will melt after the Easter period as it's made of chocolate. If you find all five eggs in a single hunt, and do this three times "" + ""I'll see if I can go about enchanting it."")); option(""Treats and XP lamps"", new Dialogue() .addNPC(Easter2022.CHOCATRICE, HeadE.NO_EXPRESSION, ""Every time you turn a chocochick into a chocotreat you can either eat it, or keep it. If you gather 3 scrumptious chocotreats for me I'll trade them for a chocolate egg on face mask."") .addItem(Easter2022.XP_LAMP, ""Players will also gain an experience lamp if they find all five eggs in a single hunt."")); option(""Talk about something else."", new Dialogue() .addGotoStage(""huntOps"", ChocatriceD.this)); } })); } }); create(); } public static NPCClickHandler handleChocatrice = new NPCClickHandler(new Object[] { Easter2022.CHOCATRICE, Easter2022.CHOCATRICE_MEDIUM, Easter2022.CHOCATRICE_LARGE }, e -> { if (!Easter2022.ENABLED) return; if (e.getOption().equals(""Talk to"")) { e.getPlayer().startConversation(new ChocatriceD(e.getPlayer())); } }); public static ItemOnNPCHandler handleItemOnChocatrice = new ItemOnNPCHandler(new Object[] { Easter2022.CHOCATRICE, Easter2022.CHOCATRICE_MEDIUM, Easter2022.CHOCATRICE_LARGE }, e -> { if (!Easter2022.ENABLED) return; if (e.getItem().getId() == Easter2022.CHOCOLATE_EGG_ON_FACE_MASK) e.getPlayer().startConversation(new Dialogue().addNPC(Easter2022.CHOCATRICE, HeadE.NO_EXPRESSION, ""In that mask, you look scrumptious. Truly delicious."")); if (e.getItem().getId() == Easter2022.EGG_ON_FACE_MASK) e.getPlayer().startConversation(new Dialogue().addNPC(Easter2022.CHOCATRICE, HeadE.NO_EXPRESSION, ""The eggs used to make that mask aren't even free-ranged. Or so I've heard."")); if (e.getItem().getId() == Easter2022.CHOCOTREAT) e.getPlayer().startConversation(new Dialogue().addNPC(Easter2022.CHOCATRICE, HeadE.NO_EXPRESSION, ""Delicious."")); if (e.getItem().getId() == Easter2022.EVIL_DRUMSTICK) e.getPlayer().startConversation(new Dialogue().addNPC(Easter2022.CHOCATRICE, HeadE.NO_EXPRESSION, ""Keep that fowl leg away from me."")); }); }" "package com.rs.game.content.holidayevents.easter.easter22.npcs; @PluginEventHandler public class EasterChick extends OwnedNPC { public int varbit; public EasterChick(Player player, int id, Tile tile, int varbit) { super(player, id, tile, true); this.varbit = varbit; setRandomWalk(true); setNextAnimation(new Animation(3673)); setAutoDespawnAtDistance(true); } @Override public void processNPC() { super.processNPC(); } @Override public void onDespawnEarly() { finish(); getOwner().getVars().saveVarBit(varbit, 0); } @Override public void sendDeath(final Entity source) { getInteractionManager().forceStop(); resetWalkSteps(); if (source.getAttackedBy() == this) { source.setAttackedBy(null); source.setFindTargetDelay(0); } setNextAnimation(null); PluginManager.handle(new NPCDeathEvent(this, source)); int attackStyle = getOwner().getCombatDefinitions().getAttackStyleId(); setNextAnimation(new Animation(16423)); World.sendSpotAnim(this.getTile(), attackStyle == 0 ? new SpotAnim(3031) : new SpotAnim(3030)); WorldTasks.scheduleTimer(0, (tick) -> { if (tick == 1) finish(); if (tick == 2) { EggHunt.incrementScore(attackStyle); rewardPlayer(attackStyle); return false; } return true; }); } public void rewardPlayer(int attackStyle) { if (!Easter2022.ENABLED) return; Item reward = new Item(attackStyle == 0 ? Easter2022.EVIL_DRUMSTICK : Easter2022.CHOCOTREAT); getOwner().sendMessage(""You turn the "" + getName().toLowerCase() + "" into a "" + reward.getName().toLowerCase() + "" The shattered remains of the egg disappear.""); getOwner().getVars().saveVarBit(varbit, 3); getOwner().getInventory().addItemDrop(reward); if (EggHunt.hasCompletedHunt(getOwner())) { getOwner().loyaltyPoints += Easter2022.LOYALTY_POINTS_AWARDED; getOwner().getInventory().addItem(Easter2022.XP_LAMP); getOwner().sendMessage(""You are rewarded with an XP lamp and "" + Easter2022.LOYALTY_POINTS_AWARDED + "" loyalty points for finding 5 eggs in a single hunt.""); getOwner().incrementCount(Easter2022.STAGE_KEY+""CompletedHunts""); int completedHunts = getOwner().getCounterValue(Easter2022.STAGE_KEY+""CompletedHunts""); if (completedHunts == 3) { getOwner().startConversation(new Dialogue().addItem(Easter2022.PERMANENT_EGGSTERMINATOR,""You have earned a permanent version of the Eggsterminator for finding 5 eggs in 3 hunts. Speak to the Evil Chicken or Chocatrice in Varrock Square to claim it."")); getOwner().sendMessage(""You have earned a permanent version of the Eggsterminator for finding 5 eggs in 3 hunts. Speak to the Evil Chicken or Chocatrice in Varrock Square to claim it.""); } if (completedHunts < 3) { getOwner().startConversation(new Dialogue().addItem(Easter2022.PERMANENT_EGGSTERMINATOR, ""You are "" + completedHunts + ""/3 of the way to claiming a permanent version of the Eggsterminator, for finding 5 eggs this hunt."")); getOwner().sendMessage(""You are "" + completedHunts + ""/3 of the way to claiming a permanent version of the Eggsterminator, for finding 5 eggs this hunt.""); } } } }" "package com.rs.game.content.holidayevents.easter.easter22.npcs; @PluginEventHandler public class EvilChickenD extends Conversation { public EvilChickenD(Player player) { super(player); if (!player.getNSV().getB(""talkedWithEvilChicken"") && player.getNSV().getB(""talkedWithChocatrice"")) { addNPC(Easter2022.EVIL_CHICKEN, HeadE.NO_EXPRESSION, ""You shouldn't have spoken to that Chocatrice. He's *bwaaak* *bwaaak* mad.""); } else if (!player.getNSV().getB(""talkedWithEvilChicken"") && !player.getNSV().getB(""talkedWithChocatrice"")) { addNPC(Easter2022.EVIL_CHICKEN, HeadE.NO_EXPRESSION, ""I'm glad you spoke with me first and not that chocolate bar on legs.""); addPlayer(HeadE.CALM_TALK, ""What are you two doing here?""); } else if (player.getNSV().getB(""talkedWithEvilChicken"")) { addNPC(Easter2022.EVIL_CHICKEN, HeadE.CAT_SHOUTING, ""Report in, soldier. *bwaaak*""); if (EggHunt.hasCompletedHunt(player)) { if (!player.getEmotesManager().unlockedEmote(Easter2022.EASTER_EMOTE)) { player.getEmotesManager().unlockEmote(Easter2022.EASTER_EMOTE); player.sendMessage(""You have unlocked an Easter emote, "" + Easter2022.EASTER_EMOTE.name().toLowerCase().replace(""_"", "" "") + "".""); } if (!player.getMusicsManager().hasMusic(Easter2022.EASTER_TRACK)) { player.getMusicsManager().unlockMusic(Easter2022.EASTER_TRACK); player.sendMessage(""You have unlocked an Easter track, "" + Music.getSong(Easter2022.EASTER_TRACK).getName() + "".""); } addNPC(Easter2022.EVIL_CHICKEN, HeadE.NO_EXPRESSION, ""Well done, soldier, you've found all the eggs this hunt. You're delightfully despicable.""); addNPC(Easter2022.EVIL_CHICKEN, HeadE.NO_EXPRESSION, EggHunt.getTimeString()); } if (player.getCounterValue(Easter2022.STAGE_KEY + ""CompletedHunts"") >= 3 && !player.getDiangoReclaim().contains(Easter2022.PERMANENT_EGGSTERMINATOR)) { addNPC(Easter2022.EVIL_CHICKEN, HeadE.NO_EXPRESSION, ""Good work, you must enjoy smashing those eggs. Seeing you've been so helpfully destructive I can enchant your Eggsterminator so that it will last after Easter. "" + ""Want me to do that for you?""); addOptions(new Options(""unlockPermanent"", EvilChickenD.this) { @Override public void create() { option(""Yes"", new Dialogue() .addNext(() -> { player.addDiangoReclaimItem(Easter2022.PERMANENT_EGGSTERMINATOR); if (player.getEquipment().getWeaponId() == Easter2022.EGGSTERMINATOR) { player.getEquipment().setNoPluginTrigger(Equipment.WEAPON, new Item(Easter2022.PERMANENT_EGGSTERMINATOR)); player.sendMessage(""The Evil Chicken enchants your Eggsterminator...""); } }) .addItem(Easter2022.PERMANENT_EGGSTERMINATOR, ""You will now be able to keep the Eggsterminator after the Easter event."") .addGotoStage(""huntOps"", EvilChickenD.this)); option(""No"", new Dialogue().addGotoStage(""continued"", EvilChickenD.this)); } }); } if (player.getInventory().containsItem(Easter2022.EVIL_DRUMSTICK, 3) && !player.getDiangoReclaim().contains(Easter2022.EGG_ON_FACE_MASK)) { addNPC(Easter2022.EVIL_CHICKEN, HeadE.NO_EXPRESSION, ""You have three succulent drumsticks on you. May I have them?""); addOptions(new Options(""buyMask"", this) { @Override public void create() { option(""Yes"", () -> { player.getInventory().deleteItem(Easter2022.EVIL_DRUMSTICK, 3); player.addDiangoReclaimItem(Easter2022.EGG_ON_FACE_MASK); player.getInventory().addItemDrop(Easter2022.EGG_ON_FACE_MASK, 1); addItem(Easter2022.EGG_ON_FACE_MASK, ""You receive the egg on face mask."").addGotoStage(""huntOps"", EvilChickenD.this); }); option(""No"", new Dialogue().addGotoStage(""huntOps"", EvilChickenD.this)); } }); } addNext(new StageSelectDialogue(""huntOps"", this.getStages())); } player.getNSV().setB(""talkedWithEvilChicken"", true); create(""continued"", addNPC(Easter2022.EVIL_CHICKEN, HeadE.NO_EXPRESSION, ""I'm hosting this year's *bwaaak* Easter hunt. Time to take things in-wing. I'm sick of the incessant, poorly timed *bwaaak* predictable egg jokes you get every single Easter."")); addPlayer(HeadE.CALM_TALK, ""They must be getting old.""); addNPC(Easter2022.EVIL_CHICKEN, HeadE.NO_EXPRESSION, ""Egg-xactly. *bwaaak* *bwaaak* Now, you may have heard that the Easter Bunny is recovering from a terrible accident. "" + ""He mistakenly fell, from quite a height, into a pit of lava. *bwaaak* What a terribly unfortunate accident.""); addNPC(Easter2022.EVIL_CHICKEN, HeadE.NO_EXPRESSION, ""Luckily, his accident occurred after placing the eggs for this year's hunt. Five delicious, giant, magical eggs, scattered around Runescape.""); if (player.getNSV().getB(""talkedWithChocatrice"")) { addPlayer(HeadE.CALM_TALK, ""Let me guess. You want me to hunt down these eggs and blow them open with the Eggsterminator?""); addNPC(Easter2022.EVIL_CHICKEN, HeadE.NO_EXPRESSION, ""So the Chocatrice already told you, did he?""); } else { addPlayer(HeadE.CALM_TALK, ""So you want me to find these giant eggs?""); addNPC(Easter2022.EVIL_CHICKEN, HeadE.NO_EXPRESSION, ""Yes, and blow them open with this.""); addItem(Easter2022.EGGSTERMINATOR, ""The Evil Chicken shows you the Eggsterminator.""); } addNPC(Easter2022.EVIL_CHICKEN, HeadE.NO_EXPRESSION, ""Once the egg is obliterated, a cute little chick will escape...""); addPlayer(HeadE.CHEERFUL, ""Awww...""); addNPC(Easter2022.EVIL_CHICKEN, HeadE.NO_EXPRESSION, ""Deep-fry it with the cannon! *bwaaak* *bwaaak* *bwaaak*""); addOptions(new Options(""takingSides"", this) { @Override public void create() { option(""Certainly!"", new Dialogue() .addNPC(Easter2022.EVIL_CHICKEN, HeadE.NO_EXPRESSION, ""It's crucial that you don't listen to that Chocatrice. He thinks we should turn those chicks into chocolate. Disgusting.... Deep-fried chicken is far more tasty."") .addOptions(new Options() { @Override public void create() { option(""Chocolate does sound better."", new Dialogue() .addNPC(Easter2022.EVIL_CHICKEN, HeadE.NO_EXPRESSION, ""Traitor! *bwaaak*!"") .addGotoStage(""declareWar"", EvilChickenD.this)); option(""I'm more of a friend chicken kind of "" + (player.getAppearance().isMale() ? ""guy."" : ""gal.""), new Dialogue() .addNPC(Easter2022.EVIL_CHICKEN, HeadE.NO_EXPRESSION, ""Yes... Juicy, fried chicken. Delicious!"") .addGotoStage(""declareWar"", EvilChickenD.this)); } })); option(""Why are you deep-frying chickens?"", new Dialogue() .addGotoStage(""declareWar"", EvilChickenD.this)); } }); create(""declareWar"", addNPC(Easter2022.EVIL_CHICKEN, HeadE.NO_EXPRESSION, ""That stupid bird thinks he can turn more chicks into chocolate than I can into drumsticks. If it's war he wants, it's war he'll get."")); addOptions(new Options(""huntOps"", EvilChickenD.this) { @Override public void create() { if (!player.getInventory().containsItem(Easter2022.EGGSTERMINATOR) && !player.getBank().containsItem(Easter2022.EGGSTERMINATOR, 1) && player.getEquipment().getWeaponId() != Easter2022.EGGSTERMINATOR && !player.getInventory().containsItem(Easter2022.PERMANENT_EGGSTERMINATOR) && !player.getBank().containsItem(Easter2022.PERMANENT_EGGSTERMINATOR, 1) && player.getEquipment().getWeaponId() != Easter2022.PERMANENT_EGGSTERMINATOR) { option(""Start the hunt."", (player.getEquipment().getWeaponId() != -1 || player.getEquipment().getShieldId() != -1) ? new Dialogue() .addNPC(Easter2022.EVIL_CHICKEN, HeadE.NO_EXPRESSION, ""Your hands must be free. *bwaaak*"") : new Dialogue() .addItem(Easter2022.EGGSTERMINATOR, ""You're handed (or 'winged') the Eggsterminator."") .addNext(() -> { player.getEquipment().setSlot(Equipment.WEAPON, new Item(Easter2022.EGGSTERMINATOR)); player.getAppearance().generateAppearanceData(); }) .addNPC(Easter2022.EVIL_CHICKEN, HeadE.NO_EXPRESSION, ""Hunt down the five eggs scattered across Runescape. Blow them open with the Eggsterminator and splatter the chick that comes from within."") .addSimple(""These eggs can be found around Runescape. You can search for them yourself or with your friends."") //Information can also be found on the Runescape official forums. .addSimple(""Finding all 5 eggs in a single hunt will unlock additional rewards."")); //Some eggs only appear in members parts of the world, so only members gain these additional benefits. } else { option(""How do I hunt the eggs?"", new Dialogue() .addNPC(Easter2022.EVIL_CHICKEN, HeadE.NO_EXPRESSION, ""The Easter Bunny has hidden magical eggs across Runescape. Unfortunate, the Easter Bunny is temporarily...indisposed...and so is unable to perform his duties as huntmaster. "" + ""I am now in charge of the hunt."") .addNPC(Easter2022.CHOCATRICE, HeadE.NO_EXPRESSION, ""No, you aren't. I'm the huntmaster!"") .addNPC(Easter2022.EVIL_CHICKEN, HeadE.NO_EXPRESSION, ""Quiet, you."") .addNPC(Easter2022.EVIL_CHICKEN, HeadE.NO_EXPRESSION, ""Every two hours, a new hunt will begin. Hunt down the five eggs, smash them open using the Eggsterminator and then shoot at the chick that emerges with the Eggsterminator. "" + ""This will turn the chick into a tasty treat."")); option(""Can I have a hint?"", (EggHunt.active() ? (player.getVars().getVarBit(10954) == 3 ? new Dialogue() .addNPC(Easter2022.EVIL_CHICKEN, HeadE.NO_EXPRESSION, ""You've already found the egg I have information on."") : new Dialogue() .addNPC(Easter2022.EVIL_CHICKEN, HeadE.NO_EXPRESSION, ""Well, the Chocatrice and I have a gentlefowl's agreement not to tell our seekers the locations of any of the eggs. But between you and me..."") .addOption(""Listen to the hint?"", ""Yes"", ""No"") .addSimple(""The chicken lowers its voice."") .addNPC(Easter2022.EVIL_CHICKEN, HeadE.NO_EXPRESSION, ""One egg can be found "" + EggHunt.getHint())) : new Dialogue() .addNPC(Easter2022.EVIL_CHICKEN, HeadE.NO_EXPRESSION, ""The hunt has ended. "" + EggHunt.getTimeString()))); } option(""Who is winning the egg hunt?"", new Dialogue() .addSimple(""Evil Chicken: "" + EggHunt.getEvilChickenScore() + ""

vs

"" + ""Chocatrice: "" + EggHunt.getChocatriceScore())); option(""Who are you?"", new Dialogue() .addNPC(Easter2022.EVIL_CHICKEN, HeadE.NO_EXPRESSION, ""But surely everybody has heard of the Evil Chicken."") .addNPC(Easter2022.EVIL_CHICKEN, HeadE.NO_EXPRESSION, ""Some say I came from the Abyss. Others say I was just a normal chicken, who grew angry at human domination over my species. But do you want to know where I really came from?"") .addSimple(""The Evil Chicken lowers its voice. You lean in."") .addNPC(Easter2022.EVIL_CHICKEN, HeadE.NO_EXPRESSION, ""*Bwaaak* *Bwaaak* *Bwaaak*"") .addSimple(""You get the impression that this chicken is quite mad."")); option(""Talk about rewards."", new Dialogue().addOptions(new Options() { @Override public void create() { option(""Mask rewards"", new Dialogue() .addNPC(Easter2022.EVIL_CHICKEN, HeadE.NO_EXPRESSION, ""Bring me three drumsticks and I'll reward you with an egg on face mask."")); option(""Eggsterminator (permanent)"", new Dialogue() .addNPC(Easter2022.EVIL_CHICKEN, HeadE.NO_EXPRESSION, ""The Eggsterminator will melt after the Easter period as it's made of chocolate. If you find all five eggs in a single hunt, and do this three times "" + ""I'll see if I can go about enchanting it."")); option(""Treats and XP lamps"", new Dialogue() .addNPC(Easter2022.EVIL_CHICKEN, HeadE.NO_EXPRESSION, ""Every time you turn a chick into an evil drumstick you can either eat it, or keep it. If you gather 3 delicious evil drumsticks for me I'll trade them for an egg on face mask."") .addItem(Easter2022.XP_LAMP, ""Players will also gain an experience lamp if they find all five eggs in a single hunt."")); option(""Talk about something else."", new Dialogue() .addGotoStage(""huntOps"", EvilChickenD.this)); } })); } }); create(); } public static NPCClickHandler handleEvilChicken = new NPCClickHandler(new Object[] { Easter2022.EVIL_CHICKEN, Easter2022.EVIL_CHICKEN_MEDIUM, Easter2022.EVIL_CHICKEN_LARGE }, e -> { if (!Easter2022.ENABLED) return; if (e.getOption().equals(""Talk to"")) { e.getPlayer().startConversation(new EvilChickenD(e.getPlayer())); } }); public static ItemOnNPCHandler handleItemOnEvilChicken= new ItemOnNPCHandler(new Object[] { Easter2022.EVIL_CHICKEN, Easter2022.EVIL_CHICKEN_MEDIUM, Easter2022.EVIL_CHICKEN_LARGE }, e -> { if (!Easter2022.ENABLED) return; if (e.getItem().getId() == Easter2022.CHOCOLATE_EGG_ON_FACE_MASK) e.getPlayer().startConversation(new Dialogue().addNPC(Easter2022.EVIL_CHICKEN, HeadE.NO_EXPRESSION, ""That mask is unflattering and makes you look fat."")); if (e.getItem().getId() == Easter2022.EGG_ON_FACE_MASK) e.getPlayer().startConversation(new Dialogue().addNPC(Easter2022.EVIL_CHICKEN, HeadE.NO_EXPRESSION, ""That mask is *entirely* homemade. *bwaaak*"")); if (e.getItem().getId() == Easter2022.CHOCOTREAT) e.getPlayer().startConversation(new Dialogue().addNPC(Easter2022.EVIL_CHICKEN, HeadE.NO_EXPRESSION, ""Eurgh - disgusting! Do you know that chocolate is my one weakness?"")); if (e.getItem().getId() == Easter2022.EVIL_DRUMSTICK) e.getPlayer().startConversation(new Dialogue().addNPC(Easter2022.EVIL_CHICKEN, HeadE.NO_EXPRESSION, ""Tasty."")); }); }" "package com.rs.game.content.holidayevents.halloween; @PluginEventHandler public class PumpkinSpawning { static IntSet regionsToSpawn = IntSet.of(12850, 11828, 12084, 12853, 12597, 12342, 10806, 10547, 13105); static int pumpkinCount = 0; static int pumpkinsPerChunk = 2; @ServerStartupEvent(Priority.POST_PROCESS) public static void initSpawning() { if (!Halloween2007.ENABLED && !Halloween2009.ENABLED) return; ChunkManager.permanentlyPreloadRegions(regionsToSpawn); WorldTasks.scheduleHalfHourly(() -> { try { spawnPumpkins(); World.sendWorldMessage(""Pumpkins have spawned in various cities around the world!"", false); } catch (Throwable e) { Logger.handle(PumpkinSpawning.class, ""initSpawning"", e); } }); } public static int countPumpkins(int chunkId) { pumpkinCount = 0; List itemSpawns = ChunkManager.getChunk(chunkId, true).getAllGroundItems(); if (itemSpawns != null && itemSpawns.size() > 0) itemSpawns.forEach( spawn -> { if (spawn.getId() == 1959) pumpkinCount += 1; }); return pumpkinCount; } public static void spawnPumpkins() { for (int id : World.mapRegionIdsToChunks(regionsToSpawn, 0)) { Chunk r = ChunkManager.getChunk(id, true); int eggsNeeded = pumpkinsPerChunk-countPumpkins(id); for (int i = 0; i < eggsNeeded; i++) { int x = r.getBaseX()+Utils.random(8); int y = r.getBaseY()+Utils.random(8); Tile tile = Tile.of(x, y, 0); int tries = 0; while (!World.floorAndWallsFree(tile, 1) && tries < 5) { x = r.getBaseX()+Utils.random(8); y = r.getBaseY()+Utils.random(8); tile = Tile.of(x, y, 0); tries++; } World.addGroundItem(new Item(1959), Tile.of(x, y, 0)); } } } }" "package com.rs.game.content.holidayevents.halloween.hw07; @PluginEventHandler public class GrimReaper2007D extends Conversation { private static final int[] HWEEN_MASKS = { 1053, 1055, 1057 }; public static NPCClickHandler handleGrimTalk = new NPCClickHandler(new Object[] { 6390 }, e -> { e.getNPC().resetDirection(); e.getPlayer().startConversation(new GrimReaper2007D(e.getPlayer())); }); public GrimReaper2007D(Player player) { super(player); switch(player.getI(Halloween2007.STAGE_KEY, 0)) { case 0: addPlayer(HeadE.SCARED, ""Erm... Excuse me... Could I ask...""); addNPC(8867, HeadE.CALM_TALK, ""Speak, mortal.""); addPlayer(HeadE.SCARED, ""Well, sir, lord, erm, your highness...""); addNPC(8867, HeadE.CALM_TALK, ""I need no title.""); addPlayer(HeadE.SCARED, ""Well, of course. Sorry. I was just wondering, what is this place?""); addNPC(8867, HeadE.CALM_TALK, ""My house. You have found yourself here because I deem it necessary.""); addPlayer(HeadE.CONFUSED, ""You do?""); addNPC(8867, HeadE.CALM_TALK, ""Long have I had a servant performing tasks as instructed. He left my service to pass on into death. Such a role is to be replaced.""); addPlayer(HeadE.CONFUSED, ""I see. So you want me to be your servant?""); addNPC(8867, HeadE.CALM_TALK, ""Eager assumptions shall bring you regret, human. A worthy soul has already been picked for the position. My house is open now as various things need attending to before the transition can take place.""); addPlayer(HeadE.CONFUSED, ""So basically you want me to tidy up some things before your new servant arrives?""); addNPC(8867, HeadE.CALM_TALK, ""Interpret as you will, mortal.""); addOption(""Select an Option"", ""I'll help out, no problem."", ""That doesn't really appeal, I'm off.""); addPlayer(HeadE.CALM_TALK, ""I'll help out, no problem.""); addNPC(8867, HeadE.CALM_TALK, ""Proceeding as instructed is the best way to survive here, human. I can always see you and can speak with you whenever I wish, as this is my domain. Go to the garden for further instructions.""); addPlayer(HeadE.CALM_TALK, ""Always watched. To the garden. Thank you. Much appreciated."", () -> player.save(Halloween2007.STAGE_KEY, 1)); break; case 1: case 2: addPlayer(HeadE.SCARED, ""Hello. Err. Grim. It's me again.""); addNPC(8867, HeadE.CALM_TALK, ""Evidently.""); addPlayer(HeadE.SCARED, ""I am so very sorry, but could you just tell me again what you want me to do?""); addNPC(8867, HeadE.CALM_TALK, ""Repetition should not be necessary here. Go to the garden for further instructions.""); addPlayer(HeadE.SCARED, ""Excellent. Sorry. Thank you. Pardon me.""); break; case 3: addPlayer(HeadE.SCARED, ""Hello. Err. Grim. It's me again.""); addNPC(8867, HeadE.CALM_TALK, ""Evidently.""); addPlayer(HeadE.SCARED, ""I am so very sorry, but could you just tell me again what you want me to do?""); addNPC(8867, HeadE.CALM_TALK, ""Repetition should not be necessary here. You need to get my old servant's skull from the garden and return it to me.""); addPlayer(HeadE.SCARED, ""Excellent. Sorry. Thank you. Pardon me.""); break; case 4: addPlayer(HeadE.SCARED, ""Hello. Err. Grim. It's me again.""); addNPC(8867, HeadE.CALM_TALK, ""Evidently.""); addPlayer(HeadE.SCARED, ""I am so very sorry, but could you just tell me again what you want me to do?""); addNPC(8867, HeadE.CALM_TALK, ""Repetition should not be necessary here. Go to the westernmost room of my home for further instructions.""); addPlayer(HeadE.SCARED, ""Excellent. Sorry. Thank you. Pardon me.""); break; case 5: addPlayer(HeadE.SCARED, ""Hello. Err. Grim. It's me again.""); addNPC(8867, HeadE.CALM_TALK, ""Evidently.""); addPlayer(HeadE.SCARED, ""I am so very sorry, but could you just tell me again what you want me to do?""); addNPC(8867, HeadE.CALM_TALK, ""Repetition should not be necessary here. You need to organize the items in my lounge as pertains to my diary. But remember, share anything you read in that diary with anyone and you will be killed.""); addPlayer(HeadE.SCARED, ""Excellent. Sorry. Thank you. Pardon me.""); break; case 6: addPlayer(HeadE.SCARED, ""Hello. Err. Grim. It's me again.""); addNPC(8867, HeadE.CALM_TALK, ""Evidently.""); addPlayer(HeadE.SCARED, ""I am so very sorry, but could you just tell me again what you want me to do?""); addNPC(8867, HeadE.CALM_TALK, ""Repetition should not be necessary here. Head upstairs for further instructions.""); addPlayer(HeadE.SCARED, ""Excellent. Sorry. Thank you. Pardon me.""); break; case 7: addPlayer(HeadE.SCARED, ""Hello. Err. Grim. It's me again.""); addNPC(8867, HeadE.CALM_TALK, ""Evidently.""); addPlayer(HeadE.SCARED, ""I am so very sorry, but could you just tell me again what you want me to do?""); addNPC(8867, HeadE.CALM_TALK, ""Repetition should not be necessary here. You need to test my agility course for me upstairs.""); addPlayer(HeadE.SCARED, ""Excellent. Sorry. Thank you. Pardon me.""); break; case 8: addPlayer(HeadE.SCARED, ""Hello. Err. Grim. It's me again.""); addNPC(8867, HeadE.CALM_TALK, ""Evidently.""); addPlayer(HeadE.SCARED, ""I am so very sorry, but could you just tell me again what you want me to do?""); addNPC(8867, HeadE.CALM_TALK, ""Repetition should not be necessary here. You need to run the course one more time for me upstairs.""); addPlayer(HeadE.SCARED, ""Excellent. Sorry. Thank you. Pardon me.""); break; case 9: addPlayer(HeadE.CALM_TALK, ""You wished to speak with me?""); addNPC(8867, HeadE.CALM_TALK, ""Correct. You have completed the tasks as ordered, hence your time here is done.""); addPlayer(HeadE.HAPPY_TALKING, ""And I'm still alive. I rock!""); addPlayer(HeadE.CONFUSED, ""So...any chance of a reward for my service?""); addNPC(8867, HeadE.CALM_TALK, ""Hmmm. Mortals and their goal-driven attitude - one thing that shall forever elude my understanding. As you wish, but trouble me no more.""); addPlayer(HeadE.CHEERFUL, ""Thank you!""); addItem(9925, ""The Grim Reaper has given you a jack-o-lantern mask, a skeleton costume, random halloween mask, and you have now unlocked the Living on Borrowed Time emote!""); addNPC(8867, HeadE.CALM_TALK, ""Death will find you one day...""); addNext(() -> { player.save(Halloween2007.STAGE_KEY, 10); player.getInventory().addItemDrop(new Item(9920, 1)); player.getInventory().addItemDrop(new Item(9925, 1)); player.getInventory().addItemDrop(new Item(9924, 1)); player.getInventory().addItemDrop(new Item(9923, 1)); player.getInventory().addItemDrop(new Item(9921, 1)); player.getInventory().addItemDrop(new Item(9922, 1)); player.getInventory().addItemDrop(new Item(HWEEN_MASKS[Utils.random(HWEEN_MASKS.length)])); player.addDiangoReclaimItem(9920); player.addDiangoReclaimItem(9925); player.addDiangoReclaimItem(9924); player.addDiangoReclaimItem(9923); player.addDiangoReclaimItem(9921); player.addDiangoReclaimItem(9922); player.getEmotesManager().unlockEmote(Emote.LIVING_BORROWED_TIME); player.fakeHit(new Hit(player.getHitpoints(), HitLook.TRUE_DAMAGE)); player.sendDeath(null); player.fadeScreen(() -> player.startConversation(new Dialogue().addPlayer(HeadE.CONFUSED, ""Well. That was an experience I will never forget.""))); }); break; } create(); } }" "package com.rs.game.content.holidayevents.halloween.hw07; public class GrimsDiary extends Book { public GrimsDiary() { super(""WitchsDiary of Death"", new BookPage( new String[] { ""My WitchsDiary"", "" by Grim"", """", ""~~~~~~~~~~~~~~~~~~~~"", ""~~~12th Bennath"", ""~~~~~~~~~~~~~~~~~~~~"", ""I had such a busy day"", ""dealing out death today."", ""It's not easy being grim."", ""Realized that Alfonse is"", ""such a good servant. He"", }, new String[] { ""seems to have the house"", ""in full workin gorder. I"", ""shall have to congratulate"", ""him tomorrow. Spent"", ""some well-deserved time"", ""sharpening my scythe -"", ""Alfonse kindly reminded"", ""me to put the sharpener"", ""back in the cabinet. Such"", ""a good chap."", }), new BookPage( new String[] { """", ""~~~~~~~~~~~~~~~~~~~~"", ""~~~13th Bennath"", ""~~~~~~~~~~~~~~~~~~~~"", ""Went to the Wilderness"", ""today. Plenty of foolish"", ""people surrendering their"", ""lives to me without"", ""thought. My back is"", ""killing me from all the"", ""standing around waiting."", }, new String[] { ""Must get that seen too."", ""Got my robe stained"", ""from one victim. Simply"", ""ruined! I decided to"", ""throw them in the"", ""fireplace - will light the"", ""fire soon. Oh, and I must"", ""remember to call mother."", }), new BookPage( new String[] { """", ""~~~~~~~~~~~~~~~~~~~~"", ""~~~14th Bennath"", ""~~~~~~~~~~~~~~~~~~~~"", ""A tragic day. Alfonse and"", ""I were in the garden"", ""looking at the state of the"", ""spider nest. I patted my"", ""trusty servant on the"", ""back in thatnks for all his"", ""hard work. Sadly, my"", ""touch of death killed him"", }, new String[] { ""instantly. Feel quite"", ""guilty."", """", """", """", """", """", """", """", """", }), new BookPage( new String[] { """", ""~~~~~~~~~~~~~~~~~~~~"", ""~~~20th Bennath"", ""~~~~~~~~~~~~~~~~~~~~"", ""House is getting into"", ""quite a state without"", ""Alfonse - things strewn all"", ""over the place. Almost"", ""trod on the eye of my"", ""mentor, eww. I put the"", ""eye back on the shelf so"", ""he can watch over me"", }, new String[] { ""and make sure I stay"", ""true to my teachings."", ""Went into Varrock to"", ""buy some new robes -"", ""people kept running away"", ""in fear, so it was difficult"", ""to find a sale."", """", """", """", }), new BookPage( new String[] { """", ""~~~~~~~~~~~~~~~~~~~~"", ""~~~21st Bennath"", ""~~~~~~~~~~~~~~~~~~~~"", ""Decided to spend a bit of"", ""time tidying today - it"", ""really isn't an easy job."", ""In my activities I found"", ""my old 'Voice of Doom'"", ""potion on the bookcase -"", ""perfect for giving people a"", ""good scare. Oh, I do love"" }, new String[] { ""my job."", """", """", """", ""~~~~~~~~~~~~~~~~~~~~"", ""~~~22nd Bennath"", ""~~~~~~~~~~~~~~~~~~~~"", ""Ordered a new servant"", ""today from the agency"", ""and got a 10% discount"", ""for getting past the"", ""1000th servant mark."" }), new BookPage( new String[] { ""Woo hoo! The agency"", ""send me his Last will and"", ""Testament. Shall have to"", ""sit on that for a while."", """", ""~~~~~~~~~~~~~~~~~~~~"", ""~~~23rd Bennath"", ""~~~~~~~~~~~~~~~~~~~~"", ""Aquired some bones"", ""today. Muncher should"", ""appreciate them as a treat"", }, new String[] { ""the next time he behaves."", ""The problem is there"", ""aren't many barriers he"", ""can't devour, so I decided"", ""to lock the bones up in"", ""the chest."", """", ""~~~~~~~~~~~~~~~~~~~~"", ""~~~21st Bennath"", ""~~~~~~~~~~~~~~~~~~~~"", ""My plan to make undead"" }), new BookPage( new String[] { ""fish is going quite well. I"", ""managed to obtain a"", ""resurrection hourglass"", ""today, so have added that"", ""to the fishtank to finish"", ""off the process. It's so"", ""difficult to have pets when"", ""everything you touch dies"", ""horrifically. I remember"", ""having a rabbit once that"", ""exploded when I fed it a"", }, new String[] { ""carrot!"", """", """", ""~~~~~~~~~~~~~~~~~~~~"", ""~~~25th Bennath"", ""~~~~~~~~~~~~~~~~~~~~"", ""Got back home today to"", ""find Muncher has run"", ""around the house"", ""creating havok - he even"", ""ate the postman! I"" }), new BookPage( new String[] { ""scolded him, so hopefully"", ""he won't do it again"", ""anytime soon. All my"", ""things are in such a"", ""mess. I'm surely going to"", ""have to find someone to"", ""tidy things up before my"", ""new servant arrives."", ""Don't want to seem"", ""totally incapable of looking"", ""after myself."" }, new String[] { }) ); } }" "package com.rs.game.content.holidayevents.halloween.hw07; @PluginEventHandler public class Halloween2007 { public static String STAGE_KEY = ""hw2024""; public static boolean ENABLED = false; public static Tile START_LOCATION = Tile.of(1697, 4814, 0); public static final int GRIM_DIARY = 11780; public static final int GRIM_ROBE = 11781; public static final int GRIM_WILL = 11782; public static final int HUMAN_BONES = 11783; public static final int SERVANT_SKULL = 11784; public static final int HOURGLASS = 11785; public static final int SCYTHE_SHARPENER = 11786; public static final int HUMAN_EYE = 11787; public static final int VOD_POTION = 11788; public static final int[] ALL_ITEMS = { 11780, 11781, 11782, 11783, 11784, 11785, 11786, 11787, 11788 }; private static final Animation GARGOYLE_ANIM = new Animation(7285); private static final Animation WEB_PASS_ANIM = new Animation(7280); private static final Animation WEB_FAIL_ANIM = new Animation(7281); private static final int WEB_PASS_PANIM = 7275; private static final Animation WEB_FAIL_PANIM = new Animation(7276); private static final Animation TAKE_ITEM = new Animation(833); public static int[] DEAD_END_WEBS = { 27955946, 28005096, 27661029, 27775726, 27726573, 27628265 }; public static int[][] SPIDER_PATHS = { { 27906795, 27939561, 27988711, 28005093 }, { 27595495, 27824877, 27759341, 27742955, 27644648, 27710184 }, { 27824877, 27857635, 27759341, 27742955, 27824870, 27759336 }, { 27693798, 27890410, 27710179, 27710184, 27759336 }, { 27890410, 27857635, 27824870 }, { 27808489, 27824877, 27955940, 27923173 }, { 27693798, 27808489, 27710179, 27808496, 27775726, 27710184, 27759336 }, { 27808496, 27775726, 27759341, 27742955, 27955940, 27923173, 27759336 }, }; private static final Map SPRINGBOARD_PAIRS = new HashMap<>(); private static final int[] PITFALL_LOCS = { 26743532, 26743537, 26743539, 26759918, 26776300, 26776301, 26776306, 26792688, 26825456, 26825459, 26841838, 26858224, 26874611, 26890989, 26890993, 26923756, 26923759, 26923761, 26923763 }; private static final Set PITFALLS = new HashSet<>(); static { mapSpringboard(Tile.toInt(1637, 4817, 0), Tile.toInt(1637, 4820, 0)); mapSpringboard(Tile.toInt(1630, 4824, 0), Tile.toInt(1633, 4824, 0)); mapSpringboard(Tile.toInt(1627, 4819, 0), Tile.toInt(1630, 4819, 0)); SPRINGBOARD_PAIRS.put(Tile.toInt(1624, 4822, 0), Tile.toInt(1624, 4828, 0)); for (int pitfall : PITFALL_LOCS) PITFALLS.add(pitfall); } public static boolean isPitfall(int x, int y) { return PITFALLS.contains(Tile.toInt(x, y, 0)); } private static void mapSpringboard(int t1, int t2) { SPRINGBOARD_PAIRS.put(t1, t2); SPRINGBOARD_PAIRS.put(t2, t1); } @ServerStartupEvent(Priority.FILE_IO) public static void loadPortal() { if (ENABLED) ObjectSpawns.add(new ObjectSpawn(31845, 10, 0, Tile.of(3210, 3425, 0), ""Portal to enter Death's House."")); } public static ItemClickHandler handleGrimDiaryRead = new ItemClickHandler(new Object[] { Halloween2007.GRIM_DIARY }, e -> e.getPlayer().openBook(new GrimsDiary())); public static ObjectClickHandler handleEnter = new ObjectClickHandler(new Object[] { 31845 }, e -> { if (!ENABLED) return; if (e.getPlayer().getI(Halloween2007.STAGE_KEY) >= 10) { e.getPlayer().sendMessage(""You've no need to return to the Grim Reaper's house.""); return; } e.getPlayer().startConversation(new Dialogue() .addPlayer(HeadE.SCARED, ""I can't believe I'm doing this.. Oh well, here goes nothing!"") .addNext(new Dialogue(() -> e.getPlayer().getControllerManager().startController(new Halloween2007Controller())))); }); public static ObjectClickHandler handleExit = new ObjectClickHandler(new Object[] { 27254 }, e -> { e.getPlayer().getControllerManager().forceStop(); e.getPlayer().useStairs(Tile.of(3211, 3424, 0)); }); public static ObjectClickHandler handleUpStairs = new ObjectClickHandler(new Object[] { 27242 }, e -> { e.getPlayer().useStairs(Tile.of(1639, 4835, 0)); if (e.getPlayer().resizeable()) e.getPlayer().getPackets().sendRunScript(2582, 2858, 0, 0); //Set bloom to false for upstairs resizeable }); public static ObjectClickHandler handleDownStairs = new ObjectClickHandler(new Object[] { 27243 }, e -> e.getPlayer().useStairs(Tile.of(1703, 4826, 0))); public static ObjectClickHandler handleDoorway1 = new ObjectClickHandler(new Object[] { 27276 }, Tile.of(1705, 4817, 0), e -> { if (e.getPlayer().getI(Halloween2007.STAGE_KEY) >= 1) e.getPlayer().startConversation(new Dialogue() .addNPC(6389, HeadE.CAT_CALM_TALK2, ""We're watching you.."") .addNext(() -> { handlePassGargoyleEntry(e.getPlayer(), e.getObject()); if (e.getPlayer().getI(Halloween2007.STAGE_KEY) == 1) e.getPlayer().save(Halloween2007.STAGE_KEY, 2); })); else handleDenyGargoyleEntry(e.getPlayer(), e.getObject()); }); public static ObjectClickHandler handleSpiderWebs = new ObjectClickHandler(new Object[] { 27266 }, e -> { if (e.getPlayer().getControllerManager().getController() == null) e.getPlayer().getControllerManager().startController(new Halloween2007Controller()); Halloween2007Controller ctrl = (Halloween2007Controller) e.getPlayer().getControllerManager().getController(); if (ctrl.checkWeb(e.getObject().getTile().getTileHash())) passWeb(e.getPlayer(), e.getObject()); else failWeb(e.getPlayer(), e.getObject()); }); public static ObjectClickHandler pickUpSkull = new ObjectClickHandler(new Object[] { 27279 }, e -> { if (e.getPlayer().getControllerManager().getController() == null) e.getPlayer().getControllerManager().startController(new Halloween2007Controller()); Halloween2007Controller ctrl = (Halloween2007Controller) e.getPlayer().getControllerManager().getController(); e.getPlayer().lock(); WorldTasks.scheduleLooping(new Task() { int stage = 0; @Override public void run() { if (stage == 0) e.getPlayer().faceObject(e.getObject()); else if (stage == 1) e.getPlayer().setNextAnimation(new Animation(7270)); else if (stage == 2) e.getPlayer().getInventory().addItem(SERVANT_SKULL, 1); else if (stage == 4) { e.getPlayer().sendMessage(""As you pick up the skull, you feel hear the webs shift.""); ctrl.randomizePath(); e.getPlayer().unlock(); stop(); } stage++; } }, 0, 0); }); public static ObjectClickHandler handleDoorway2 = new ObjectClickHandler(new Object[] { 27276 }, Tile.of(1701, 4832, 0), e -> { if (e.getPlayer().getI(Halloween2007.STAGE_KEY) >= 2) { if (e.getPlayer().getI(Halloween2007.STAGE_KEY) == 2) e.getPlayer().startConversation(new Dialogue() .addNPC(8867, HeadE.CALM_TALK, ""You have found my garden I see."") .addPlayer(HeadE.NERVOUS, ""Woah. You made my jump. How does your voice carry so far?"") .addNPC(8867, HeadE.CALM_TALK, ""That is not of your concern. Whilst in my domain you shall never be far from my gaze."") .addPlayer(HeadE.CONFUSED, ""Okay... So, what exactly do you want me to do out here?"") .addNPC(8867, HeadE.CALM_TALK, ""My last servant died in here. His skull still remains and you must bring it out to prevent my next servant from getting the wrong impression."") .addPlayer(HeadE.NERVOUS, ""And I suppose your servant was killed by some huge man-eating spider?"") .addNPC(8867, HeadE.CALM_TALK, ""That is not your business, mortal. Anyway, the webs you see are from a nest of very small spiders. Some webs you can pass, some you cannot. You will only need to use your bare hands to break through."") .addPlayer(HeadE.NERVOUS, ""Sorry I asked. I'll go find the skull and bring it back out of the garden."") .addNPC(8867, HeadE.CALM_TALK, ""Yes, and do not try teleporting out of the garden with the skull. The skull will remain behind and you'll have to find it again."") .addNext(() -> { handlePassGargoyleEntry(e.getPlayer(), e.getObject()); e.getPlayer().save(Halloween2007.STAGE_KEY, 3); })); else if (e.getPlayer().getI(Halloween2007.STAGE_KEY) == 3 && e.getPlayer().getInventory().containsItem(11784)) e.getPlayer().startConversation(new Dialogue() .addPlayer(HeadE.SAD_SNIFFLE, ""Woah, what'd I do? Oh no. The skull's gone."") .addNPC(8867, HeadE.CALM_TALK, ""Do not concern yourself. I had instructed the gargoyles to take it from you."") .addPlayer(HeadE.SAD_MILD, ""You could have let me know! I almost had a heart attack."") .addNPC(8867, HeadE.CALM_TALK, ""Please proceed to the westernmost room for your next task."") .addPlayer(HeadE.CALM_TALK, ""You don't waste time, do you? So, the room that looks a bit like your lounge? I'm on my way."") .addNext(() -> { e.getPlayer().getInventory().deleteItem(11784, 28); e.getPlayer().save(Halloween2007.STAGE_KEY, 4); handlePassGargoyleEntry(e.getPlayer(), e.getObject()); })); else handlePassGargoyleEntry(e.getPlayer(), e.getObject()); } else handleDenyGargoyleEntry(e.getPlayer(), e.getObject()); }); public static ObjectClickHandler handleNothingObjects = new ObjectClickHandler(new Object[] { 27246, 27247, 27248, 27250, 27260 }, e -> searchItem(e.getPlayer(), -1, ""You find nothing of interest."")); public static ObjectClickHandler handleTable = new ObjectClickHandler(new Object[] { 27245 }, e -> searchItem(e.getPlayer(), GRIM_DIARY, ""You find a diary on the table. This should give some clues as to where items within the room should go."")); public static ObjectClickHandler handleCabinet = new ObjectClickHandler(new Object[] { 27246 }, Tile.of(1687, 4820, 0), e -> searchItem(e.getPlayer(), GRIM_ROBE, ""You found the Grim Reaper's robes."")); public static ObjectClickHandler handleBookcase = new ObjectClickHandler(new Object[] { 27249 }, e -> searchItem(e.getPlayer(), SCYTHE_SHARPENER, ""You found a scythe sharpener."")); public static ObjectClickHandler handleShelf = new ObjectClickHandler(new Object[] { 27261 }, e -> searchItem(e.getPlayer(), HOURGLASS, ""You found an hourglass."")); public static ObjectClickHandler handleChest = new ObjectClickHandler(new Object[] { 27255 }, e -> searchItem(e.getPlayer(), GRIM_WILL, ""You found someone's Last Will and Testament."")); public static ObjectClickHandler handleFireplace = new ObjectClickHandler(new Object[] { 27251 }, e -> searchItem(e.getPlayer(), VOD_POTION, ""You found a 'Voice of Doom' potion."")); public static ItemOnObjectHandler handleSharpenerCabinet = new ItemOnObjectHandler(new Object[] { 27246 }, new Tile[] { Tile.of(1687, 4820, 0) }, e -> { if (e.getPlayer().getControllerManager().getController() == null) e.getPlayer().getControllerManager().startController(new Halloween2007Controller()); Halloween2007Controller ctrl = (Halloween2007Controller) e.getPlayer().getControllerManager().getController(); if (e.getItem().getId() == SCYTHE_SHARPENER) { searchItem(e.getPlayer(), -1, ""You recall the entry in the diary, '...put the sharpener back in the cabinet...' and place the scythe sharpener in the cabinet.""); ctrl.returnItem(SCYTHE_SHARPENER); } else e.getPlayer().startConversation(new Dialogue().addSimple(""You don't recall the diary mentioning that going in there."")); }); public static ItemOnObjectHandler handleVoDBookcase = new ItemOnObjectHandler(new Object[] { 27249 }, null, e -> { if (e.getPlayer().getControllerManager().getController() == null) e.getPlayer().getControllerManager().startController(new Halloween2007Controller()); Halloween2007Controller ctrl = (Halloween2007Controller) e.getPlayer().getControllerManager().getController(); if (e.getItem().getId() == VOD_POTION) { searchItem(e.getPlayer(), -1, ""You recall the entry in the diary, '...I found my old 'Voice of Doom' potion amongst some books...' and place the potion on the bookcase.""); ctrl.returnItem(VOD_POTION); } else e.getPlayer().startConversation(new Dialogue().addSimple(""You don't recall the diary mentioning that going in there."")); }); public static ItemOnObjectHandler handleEyeShelf = new ItemOnObjectHandler(new Object[] { 27261 }, null, e -> { if (e.getPlayer().getControllerManager().getController() == null) e.getPlayer().getControllerManager().startController(new Halloween2007Controller()); Halloween2007Controller ctrl = (Halloween2007Controller) e.getPlayer().getControllerManager().getController(); if (e.getItem().getId() == HUMAN_EYE) { searchItem(e.getPlayer(), -1, ""You recall the entry in the diary, '...I put the eye back on the shelf...' and place the eye on the shelf.""); ctrl.returnItem(HUMAN_EYE); } else e.getPlayer().startConversation(new Dialogue().addSimple(""You don't recall the diary mentioning that going in there."")); }); public static ItemOnObjectHandler handleBonesChest = new ItemOnObjectHandler(new Object[] { 27255 }, null, e -> { if (e.getPlayer().getControllerManager().getController() == null) e.getPlayer().getControllerManager().startController(new Halloween2007Controller()); Halloween2007Controller ctrl = (Halloween2007Controller) e.getPlayer().getControllerManager().getController(); if (e.getItem().getId() == HUMAN_BONES) { searchItem(e.getPlayer(), -1, ""You recall the entry in the diary, '...decided to lock them up in the chest...' and place the bones in the chest.""); ctrl.returnItem(HUMAN_BONES); } else e.getPlayer().startConversation(new Dialogue().addSimple(""You don't recall the diary mentioning that going in there."")); }); public static ItemOnObjectHandler handleRobeFireplace = new ItemOnObjectHandler(new Object[] { 27251 }, null, e -> { if (e.getPlayer().getControllerManager().getController() == null) e.getPlayer().getControllerManager().startController(new Halloween2007Controller()); Halloween2007Controller ctrl = (Halloween2007Controller) e.getPlayer().getControllerManager().getController(); if (e.getItem().getId() == GRIM_ROBE) { searchItem(e.getPlayer(), -1, ""You recall the entry in the diary, '...decided to throw them in the fireplace...' and place the robes in the fireplace.""); ctrl.returnItem(GRIM_ROBE); } else e.getPlayer().startConversation(new Dialogue().addSimple(""You don't recall the diary mentioning that going in there."")); }); public static ObjectClickHandler handleCouch = new ObjectClickHandler(new Object[] { 27252 }, e -> e.getPlayer().sendOptionDialogue(""Where do you want to search?"", ops -> { ops.add(""Under the sofa"", () -> { e.getPlayer().lock(); WorldTasks.scheduleTimer(stage -> { if (stage == 0) e.getPlayer().setNextAnimation(new Animation(7271)); else if (stage == 1) World.sendSpotAnim(e.getPlayer().transform(-1, 0, 0), new SpotAnim(1244, 0, 0, 2)); else if (stage == 4) { e.getPlayer().startConversation(new Dialogue().addPlayer(HeadE.NERVOUS, ""That wasn't such a good idea."")); e.getPlayer().unlock(); return false; } return true; }); }); ops.add(""Under the cushions"", () -> searchItem(e.getPlayer(), HUMAN_EYE, ""You found someone's eye."")); })); public static ItemOnObjectHandler handleWillCouch = new ItemOnObjectHandler(new Object[] { 27252 }, null, e -> { if (e.getPlayer().getControllerManager().getController() == null) e.getPlayer().getControllerManager().startController(new Halloween2007Controller()); Halloween2007Controller ctrl = (Halloween2007Controller) e.getPlayer().getControllerManager().getController(); if (e.getItem().getId() == GRIM_WILL) { searchItem(e.getPlayer(), -1, ""You recall the entry in the diary, '...have to sit on that for a while...' and place the Last Will and Testament under the sofa cushions.""); ctrl.returnItem(GRIM_WILL); } else e.getPlayer().startConversation(new Dialogue().addSimple(""You don't recall the diary mentioning that going in there."")); }); public static ObjectClickHandler handleFishTank = new ObjectClickHandler(new Object[] { 27253 }, e -> e.getPlayer().sendOptionDialogue(""Where do you want to search?"", ops -> { ops.add(""To the left"", () -> { e.getPlayer().lock(); WorldTasks.scheduleTimer(stage -> { if (stage == 0) e.getPlayer().setNextAnimation(new Animation(7271)); else if (stage == 4) { e.getPlayer().startConversation(new Dialogue().addPlayer(HeadE.NERVOUS, ""That wasn't such a good idea."")); e.getPlayer().unlock(); return false; } return true; }); }); ops.add(""To the right"", () -> searchItem(e.getPlayer(), HUMAN_BONES, ""You found some bones. They look decidedly human."")); })); public static ItemOnObjectHandler handleHourglassFishTank = new ItemOnObjectHandler(new Object[] { 27253 }, null, e -> { if (e.getPlayer().getControllerManager().getController() == null) e.getPlayer().getControllerManager().startController(new Halloween2007Controller()); Halloween2007Controller ctrl = (Halloween2007Controller) e.getPlayer().getControllerManager().getController(); if (e.getItem().getId() == HOURGLASS) { searchItem(e.getPlayer(), -1, ""You recall the entry in the diary, '...hourglass today so have added that to the fishtank...' and place the hourglass in the fishtank.""); ctrl.returnItem(HOURGLASS); } else e.getPlayer().startConversation(new Dialogue().addSimple(""You don't recall the diary mentioning that going in there."")); }); public static ObjectClickHandler handleDoorway3 = new ObjectClickHandler(new Object[] { 27276 }, Tile.of(1694, 4820, 0), e -> { if (e.getPlayer().getControllerManager().getController() == null) e.getPlayer().getControllerManager().startController(new Halloween2007Controller()); Halloween2007Controller ctrl = (Halloween2007Controller) e.getPlayer().getControllerManager().getController(); if (e.getPlayer().getI(Halloween2007.STAGE_KEY) >= 4) { if (e.getPlayer().getI(Halloween2007.STAGE_KEY) == 4) e.getPlayer().startConversation(new Dialogue() .addNPC(8867, HeadE.CALM_TALK, ""You made it."") .addPlayer(HeadE.CONFUSED, ""You sound surprised."") .addNPC(8867, HeadE.CALM_TALK, ""You wouldn't be the first, or last, to die in this house."") .addPlayer(HeadE.NO_EXPRESSION, ""I'm so pleased. So, to the task at hand. What should I be doing in here?"") .addNPC(8867, HeadE.CALM_TALK, ""If you search around the room you'll find various items. Put them back where they belong. My diary is on the table - read this for some clues, but tell anyone what you read and you die."") .addPlayer(HeadE.NERVOUS, ""*Gulp* I shall have a look."") .addNext(() -> { handlePassGargoyleEntry(e.getPlayer(), e.getObject()); e.getPlayer().save(Halloween2007.STAGE_KEY, 5); })); else if (e.getPlayer().getI(Halloween2007.STAGE_KEY) == 5) { if (ctrl.isItemsCorrect()) e.getPlayer().startConversation(new Dialogue() .addNPC(8867, HeadE.CALM_TALK, ""Looks like you've returned everything to its proper location."") .addPlayer(HeadE.HAPPY_TALKING, ""Woo hoo!"") .addNPC(8867, HeadE.CALM_TALK, ""You've not finished yet, mortal. Please proceed upstairs and enter the room you find there."") .addPlayer(HeadE.CALM_TALK, ""Upstairs it is."") .addNext(() -> { e.getPlayer().save(Halloween2007.STAGE_KEY, 6); handlePassGargoyleEntry(e.getPlayer(), e.getObject()); })); else { if (e.getPlayer().getX() > e.getObject().getX()) { handlePassGargoyleEntry(e.getPlayer(), e.getObject()); return; } e.getPlayer().sendOptionDialogue(""If you leave, the items will be returned to where you found them. Leave?"", ops -> { ops.add(""Yes"", () -> { ctrl.removeItems(); ctrl.resetReturnedItems(); }); ops.add(""No, I'll finish first.""); }); } } else handlePassGargoyleEntry(e.getPlayer(), e.getObject()); } else handleDenyGargoyleEntry(e.getPlayer(), e.getObject()); }); public static ObjectClickHandler handleDoorway4 = new ObjectClickHandler(new Object[] { 27276 }, Tile.of(1641, 4829, 0), e -> { if (e.getPlayer().getI(Halloween2007.STAGE_KEY) >= 6) { if (e.getPlayer().getI(Halloween2007.STAGE_KEY) == 6) e.getPlayer().startConversation(new Dialogue() .addNPC(8867, HeadE.CALM_TALK, ""The last room."") .addPlayer(HeadE.DIZZY, ""Good job. I'm not sure my heart can take much more."") .addNPC(8867, HeadE.CALM_TALK, ""As you can see, ahead of you is a course of a rather vicious design. I use it to keep my servants on their toes. Test it, please."") .addPlayer(HeadE.NERVOUS, ""Test?"") .addNPC(8867, HeadE.CALM_TALK, ""This course hasn't been used for some time. I wish to make sure it all still works."") .addPlayer(HeadE.NERVOUS, ""You've got to be kidding me."") .addNext(() -> { handlePassGargoyleEntry(e.getPlayer(), e.getObject()); e.getPlayer().save(Halloween2007.STAGE_KEY, 7); })); else handlePassGargoyleEntry(e.getPlayer(), e.getObject()); } else handleDenyGargoyleEntry(e.getPlayer(), e.getObject()); }); public static ObjectClickHandler handleSlide = new ObjectClickHandler(new Object[] { 27218 }, e -> { if (e.getPlayer().getControllerManager().getController() == null) e.getPlayer().getControllerManager().startController(new Halloween2007Controller()); Halloween2007Controller ctrl = (Halloween2007Controller) e.getPlayer().getControllerManager().getController(); e.getPlayer().lock(); WorldTasks.scheduleTimer(stage -> { if (stage == 0) { e.getPlayer().faceObject(e.getObject()); e.getPlayer().addWalkSteps(e.getPlayer().transform(0, -1, 0), 1, false); Tile camTile = Tile.of(1638, 4827, 0); e.getPlayer().getPackets().sendCameraPos(camTile, 2000); e.getPlayer().getPackets().sendCameraLook(e.getPlayer().transform(-2, 0, 0), 2000); } else if (stage == 1) e.getPlayer().setNextAnimation(new Animation(7274)); else if (stage == 9) { e.getPlayer().tele(e.getPlayer().transform(0, -1, 0)); e.getPlayer().forceMove(Tile.of(1642, 4819, 0), 1, 60, () -> { e.getPlayer().getPackets().sendResetCamera(); ctrl.setRodeSlide(true); }); return false; } return true; }); }); public static ObjectClickHandler handleSpringboards = new ObjectClickHandler(new Object[] { 27278 }, e -> { Tile toTile = Tile.of(SPRINGBOARD_PAIRS.get(e.getObject().getTile().getTileHash())); boolean toSlime = e.getObject().getTile().isAt(1624, 4822); e.getPlayer().lock(); WorldTasks.scheduleTimer(stage -> { if (stage == 0) e.getPlayer().addWalkSteps(e.getObject().getTile(), 1, false); else if (stage == 1) { World.sendObjectAnimation(e.getObject(), new Animation(7268)); if (toSlime) { e.getPlayer().getAppearance().setBAS(616); e.getPlayer().blockRun(); } e.getPlayer().forceMove(toTile, toSlime ? 7269 : 7268, 1, 30); return false; } return true; }); }); public static ObjectClickHandler handleExitRamp = new ObjectClickHandler(new Object[] { 27211 }, e -> { e.getPlayer().lock(); WorldTasks.scheduleTimer(stage -> { if (stage == 0) e.getPlayer().faceObject(e.getObject()); else if (stage == 1) { e.getPlayer().forceMove(e.getPlayer().transform(0, 2, 0), 7273, 1, 150, () -> e.getPlayer().unblockRun()); e.getPlayer().getAppearance().setBAS(-1); return false; } return true; }); }); public static ObjectClickHandler handleDoorway5 = new ObjectClickHandler(new Object[] { 27276 }, Tile.of(1645, 4848, 0), e -> { if (e.getPlayer().getControllerManager().getController() == null) e.getPlayer().getControllerManager().startController(new Halloween2007Controller()); Halloween2007Controller ctrl = (Halloween2007Controller) e.getPlayer().getControllerManager().getController(); if (e.getPlayer().getI(Halloween2007.STAGE_KEY) >= 7) if (e.getPlayer().getI(Halloween2007.STAGE_KEY) == 7) { if (!ctrl.isRodeSlide()) { e.getPlayer().startConversation(new Dialogue().addNPC(6389, HeadE.CAT_CALM_TALK2, ""You didn't test the slide!"")); handleDenyGargoyleEntry(e.getPlayer(), e.getObject()); } else handleDenyGargoyleEntry(e.getPlayer(), e.getObject(), () -> { e.getPlayer().tele(Tile.of(1641, 4828, 0)); e.getPlayer().save(Halloween2007.STAGE_KEY, 8); e.getPlayer().startConversation(new Dialogue() .addPlayer(HeadE.CONFUSED, ""Huh? What happened there?"") .addNPC(8867, HeadE.CALM_TALK, ""Again."") .addPlayer(HeadE.CONFUSED, ""What?"") .addNPC(8867, HeadE.CALM_TALK, ""One more time around, just to be sure all is in order."")); }); } else if (!ctrl.isRodeSlide()) { e.getPlayer().startConversation(new Dialogue().addNPC(6389, HeadE.CAT_CALM_TALK2, ""You didn't test the slide!"")); handleDenyGargoyleEntry(e.getPlayer(), e.getObject()); } else handleDenyGargoyleEntry(e.getPlayer(), e.getObject(), () -> { e.getPlayer().tele(Tile.of(1641, 4840, 0)); e.getPlayer().save(Halloween2007.STAGE_KEY, 9); e.getPlayer().startConversation(new Dialogue() .addNPC(8867, HeadE.CALM_TALK, ""That is sufficient."") .addPlayer(HeadE.SLEEPING, ""Phew."") .addNPC(8867, HeadE.CALM_TALK, ""Come and speak with me downstairs."") .addPlayer(HeadE.CHEERFUL, ""I'll be right down."")); }); }); public static void searchItem(Player player, int itemId, String findText) { if (player.getControllerManager().getController() == null) player.getControllerManager().startController(new Halloween2007Controller()); Halloween2007Controller ctrl = (Halloween2007Controller) player.getControllerManager().getController(); player.lock(); WorldTasks.scheduleTimer(stage -> { if (stage == 0) player.setNextAnimation(TAKE_ITEM); else if (stage == 2) { player.unlock(); if (itemId == -1 || player.getInventory().containsItem(itemId) || ctrl.isItemReturned(itemId)) player.startConversation(new Dialogue().addSimple(findText)); else { player.getInventory().addItem(itemId, 1); player.startConversation(new Dialogue().addItem(itemId, findText)); } return false; } return true; }); } public static void handlePassGargoyleEntry(Player player, GameObject object) { boolean horiz = object.getRotation() % 2 != 0; player.passThrough(object.getTile().transform(horiz ? player.getX() > object.getX() ? -1 : 1 : 0, horiz ? 0 : player.getY() > object.getY() ? -1 : 1, 0)); player.sendMessage(""You safely pass the gargoyles' judgement.""); } public static void handleDenyGargoyleEntry(Player player, GameObject object) { handleDenyGargoyleEntry(player, object, null); } public static void handleDenyGargoyleEntry(Player player, GameObject object, Runnable postDeath) { boolean xOff = object.getRotation() % 2 == 0; World.sendObjectAnimation(World.getObject(object.getTile().transform(xOff ? -1 : 0, xOff ? 0 : -1, 0), ObjectType.GROUND_DECORATION), GARGOYLE_ANIM); World.sendObjectAnimation(World.getObject(object.getTile().transform(xOff ? 1 : 0, xOff ? 0 : 1, 0), ObjectType.GROUND_DECORATION), GARGOYLE_ANIM); if (postDeath == null) player.startConversation(new Dialogue() .addNPC(6389, HeadE.CAT_CALM_TALK2, ""Who said you could come in here? See the Grim Reaper if you don't know where to go."") .addPlayer(HeadE.NERVOUS, ""Oops."")); player.lock(); WorldTasks.scheduleLooping(new Task() { int stage = 0; @Override public void run() { if (stage == 0) player.faceObject(object); else if (stage == 2) { int x = 0, y = 0; y = switch (object.getRotation()) { case 0, 1 -> { x = -1; yield -1; } case 2 -> { x = -1; yield 0; } case 3 -> { x = 0; yield -1; } default -> y; }; GameObject lightning = new GameObject(27277, ObjectType.SCENERY_INTERACT, object.getRotation(), object.getTile().transform(x, y, 0)); World.spawnObjectTemporary(lightning, Ticks.fromSeconds(3)); } else if (stage == 3) { player.setNextAnimation(new Animation(3170)); player.setNextSpotAnim(new SpotAnim(560)); player.fakeHit(new Hit(player.getHitpoints(), HitLook.TRUE_DAMAGE)); } else if (stage == 4) { player.unlock(); if (postDeath == null) player.sendDeath(null); else postDeath.run(); stop(); } stage++; } }, 0, 0); } public static void passWeb(Player player, GameObject object) { Tile toTile = object.getRotation() % 2 != 0 ? player.transform(player.getX() >= object.getX() ? -2 : 2, 0, 0) : player.transform(0, player.getY() >= object.getY() ? -2 : 2, 0); player.lock(); WorldTasks.scheduleLooping(new Task() { int stage = 0; @Override public void run() { if (stage == 0) player.faceObject(object); else if (stage == 1) { player.forceMove(toTile, WEB_PASS_PANIM, 1, 120); object.animate(WEB_PASS_ANIM); stop(); } stage++; } }, 0, 0); } public static void failWeb(Player player, GameObject object) { player.lock(); WorldTasks.scheduleLooping(new Task() { int stage = 0; @Override public void run() { if (stage == 0) player.faceObject(object); else if (stage == 1) { player.setNextAnimation(WEB_FAIL_PANIM); object.animate(WEB_FAIL_ANIM); } else if (stage == 8) { player.sendMessage(""You cannot pass through this particular web - try another.""); player.unlock(); stop(); } stage++; } }, 0, 0); } }" "package com.rs.game.content.holidayevents.halloween.hw07; public class Halloween2007Controller extends Controller { private static final int[] DEAD_END_WEBS = { 27955946, 28005096, 27661029, 27775726, 27726573, 27628265 }; private int[] webPath; private Set returnedItems = new HashSet<>(); private boolean rodeSlide; public Halloween2007Controller() { randomizePath(); } @Override public void start() { player.startConversation(new Dialogue().addPlayer(HeadE.CONFUSED, ""Well, I'm still in one peice. A good start.."")); player.tele(Halloween2007.START_LOCATION); } @Override public boolean checkWalkStep(int lastX, int lastY, int nextX, int nextY) { if (Halloween2007.isPitfall(lastX, lastY)) { player.setNextAnimation(new Animation(1950)); player.lock(); WorldTasks.schedule(new Task() { @Override public void run() { player.tele(Tile.of(1698, 4822, 0)); player.setNextAnimation(new Animation(3640)); player.fadeScreen(() -> { player.unlock(); player.startConversation(new Dialogue() .addNPC(8867, HeadE.CALM_TALK, ""That, you will see, was a pitfall trap. You need to walk around them."") .addPlayer(HeadE.ANGRY, ""But I didn't even see the trap!"") .addNPC(8867, HeadE.CALM_TALK, ""Look closely and you should see the joins of the doors on the ground."") .addPlayer(HeadE.SAD, ""Ah, okay. Back upstairs it is, then."")); }); } }, 5); return false; } return true; } @Override public boolean sendDeath() { player.lock(7); player.stopAll(); WorldTasks.scheduleLooping(new Task() { int loop; @Override public void run() { if (loop == 0) player.setNextAnimation(new Animation(836)); else if (loop == 1) player.sendMessage(""Oh dear, you have died.""); else if (loop == 3) { player.tele(player.getI(Halloween2007.STAGE_KEY) < 10 ? Halloween2007.START_LOCATION : Tile.of(3211, 3424, 0)); player.reset(); player.setNextAnimation(new Animation(-1)); } else if (loop == 4) { if (player.getI(Halloween2007.STAGE_KEY) >= 10) player.getControllerManager().forceStop(); player.jingle(90); stop(); } loop++; } }, 0, 1); return false; } @Override public void process() { refreshSkull(); } @Override public boolean login() { return false; } @Override public boolean logout() { return false; } @Override public void onTeleported(TeleType type) { removeItems(); } @Override public void forceClose() { removeItems(); } public void removeItems() { for (int itemId : Halloween2007.ALL_ITEMS) if (player.getInventory().containsItem(itemId)) player.getInventory().deleteItem(itemId, 28); } @Override public boolean processTeleport(Teleport tele) { player.sendMessage(""A mysterious force prevents you from teleporting.""); return false; } public int[] getWebPath() { return webPath; } public void randomizePath() { webPath = getRandomWebPath(); } private static int[] getRandomWebPath() { return Halloween2007.SPIDER_PATHS[Utils.random(Halloween2007.SPIDER_PATHS.length)]; } public void refreshSkull() { player.getVars().setVarBit(4086, player.getI(Halloween2007.STAGE_KEY) >= 4 || player.getInventory().containsItem(Halloween2007.SERVANT_SKULL) ? 1 : 0); } public boolean checkWeb(int tileHash) { for (int check : DEAD_END_WEBS) if (check == tileHash) return true; for (int check : webPath) if (check == tileHash) return true; return false; } public boolean isItemsCorrect() { return returnedItems.size() >= 7; } public boolean isItemReturned(int itemId) { return returnedItems.contains(itemId); } public void resetReturnedItems() { returnedItems = new HashSet<>(); } public void returnItem(int itemId) { player.getInventory().deleteItem(itemId, 1); returnedItems.add(itemId); } public boolean isRodeSlide() { return rodeSlide; } public void setRodeSlide(boolean rodeSlide) { this.rodeSlide = rodeSlide; } }" "package com.rs.game.content.holidayevents.halloween.hw07; @PluginEventHandler public class Muncher07D extends Conversation { private static final Animation FLINCH = new Animation(6563); private static final Animation BITE = new Animation(6565); public Muncher07D(Player player, NPC muncher) { super(player); addPlayer(HeadE.CHEERFUL, ""Here, boy!""); addPlayer(HeadE.TERRIFIED, ""Whoaah!"", () -> { muncher.faceEntity(player); muncher.forceTalk(""Grrrrrr""); muncher.setNextAnimation(FLINCH); }); Dialogue op = addOption(""He looks mad, what would you like to do?"", ""Stroke him""/*, ""Try to entertain him""*/, ""Blow a raspberry at him""); op.addPlayer(HeadE.NERVOUS, ""Okay, touching him seems to be a bad idea."", () -> { player.setNextAnimation(new Animation(7271)); muncher.forceTalk(""Grrrrrr""); muncher.setNextAnimation(FLINCH); }); //op.addPlayer(HeadE.CALM_TALK, ""Entertain""); op.addPlayer(HeadE.LAUGH, ""Hehe. This'll make him think twice!"") .addNext(() -> { player.lock(); WorldTasks.scheduleLooping(new Task() { int stage = 0; @Override public void run() { if (stage == 0) player.faceEntity(muncher); else if (stage == 1) player.setNextAnimation(Emote.RASPBERRY.getAnim()); else if (stage == 3) { muncher.setNextAnimation(BITE); player.fakeHit(new Hit(player.getHitpoints(), HitLook.TRUE_DAMAGE)); } else if (stage == 4) player.sendDeath(null); else if (stage == 11) player.startConversation(new Dialogue().addPlayer(HeadE.SKEPTICAL_THINKING, ""Maybe that wasn't so wise."")); stage++; } }, 0, 0); }); create(); } public static NPCClickHandler handleMuncher = new NPCClickHandler(new Object[] { 2329 }, e -> e.getPlayer().startConversation(new Muncher07D(e.getPlayer(), e.getNPC()))); }" "package com.rs.game.content.holidayevents.halloween.hw09; @PluginEventHandler public class BathtubSpiderD extends Conversation { public static NPCClickHandler handleSpiderTalk = new NPCClickHandler(new Object[] { 8978 }, e -> { e.getNPC().resetDirection(); e.getPlayer().startConversation(new BathtubSpiderD(e.getPlayer())); }); public BathtubSpiderD(Player player) { super(player); switch(player.getI(Halloween2009.STAGE_KEY, 0)) { case 1: addNPC(8979, HeadE.SPIDER_CALM, ""Wot?""); addOptions(new Options(""startOps"", BathtubSpiderD.this) { @Override public void create() { option(""My goodness! A giant, talking spider!"", new Dialogue() .addPlayer(HeadE.AMAZED, ""My goodness! A giant, talking spider!"") .addNPC(8979, HeadE.SPIDER_CALM, ""Guess so."") .addGotoStage(""startOps"", BathtubSpiderD.this)); option(""Shoo! Horrible spider!"", new Dialogue() .addPlayer(HeadE.ANGRY, ""Shoo! Horrible spider!"") .addNPC(8979, HeadE.SPIDER_CALM, ""Nah."") .addGotoStage(""startOps"", BathtubSpiderD.this)); option(""Please move, spider."", new Dialogue() .addPlayer(HeadE.CALM_TALK, ""Please move, spider."") .addNPC(8979, HeadE.SPIDER_CALM, ""Nope."") .addOptions(new Options(""plsMoveOps"", BathtubSpiderD.this) { @Override public void create() { option(""If you don't move, the Grim Reaper will kill you!"", new Dialogue() .addPlayer(HeadE.AMAZED, ""If you don't move, the Grim Reaper will kill you!"") .addNPC(8979, HeadE.SPIDER_CALM, ""Don't think so."") .addGotoStage(""plsMoveOps"", BathtubSpiderD.this)); option(""You don't talk much, do you?"", new Dialogue() .addPlayer(HeadE.CONFUSED, ""You don't talk much, do you?"") .addNPC(8979, HeadE.SPIDER_CALM, ""Nope."") .addGotoStage(""plsMoveOps"", BathtubSpiderD.this)); option(""What are you doing in Grim's bathtub?"", new Dialogue() .addPlayer(HeadE.CONFUSED, ""What are you doing in Grim's bathtub?"") .addNPC(8979, HeadE.SPIDER_CALM, ""Nuthin'."") .addPlayer(HeadE.CONFUSED, ""I mean, why are you here?"") .addNPC(8979, HeadE.SPIDER_CALM, ""Spider Queen."") .addOptions(new Options(""queenOps"", BathtubSpiderD.this) { @Override public void create() { option(""Who is the Spider Queen?"", new Dialogue() .addPlayer(HeadE.CONFUSED, ""Who is the Spider Queen?"") .addNPC(8979, HeadE.SPIDER_CALM, ""Queen of Spiders."") .addGotoStage(""queenOps"", BathtubSpiderD.this)); option(""So, the Spider Queen sent you here?"", new Dialogue() .addPlayer(HeadE.CONFUSED, ""So, the Spider Queen sent you here?"") .addNPC(8979, HeadE.SPIDER_CALM, ""Yup."") .addGotoStage(""queenOps"", BathtubSpiderD.this)); option(""Why would the Spider Queen tell you to sit in Grim's Bath?"", new Dialogue() .addPlayer(HeadE.CONFUSED, ""Why would the Spider Queen tell you to sit in Grim's Bath?"") .addNPC(8979, HeadE.SPIDER_CALM, ""Dunno."") .addGotoStage(""queenOps"", BathtubSpiderD.this)); option(() -> !player.getTempAttribs().getB(""queenKnown""), ""Would you move if the Spider Queen told you to?"", new Dialogue() .addPlayer(HeadE.CONFUSED, ""Would you move if the Spider Queen told you to?"") .addNPC(8979, HeadE.SPIDER_CALM, ""Yup."") .addPlayer(HeadE.UPSET, ""I better report back to the Grim Reaper."", () -> { if (player.getI(Halloween2009.STAGE_KEY) == 1) player.save(Halloween2009.STAGE_KEY, 2); }) .addGotoStage(""queenOps"", BathtubSpiderD.this)); option(""Goodbye.""); } })); option(""Goodbye.""); } })); option(""Goodbye.""); } }); break; default: addNPC(8979, HeadE.SPIDER_CALM, ""Wot?""); break; } create(); } }" "package com.rs.game.content.holidayevents.halloween.hw09; @PluginEventHandler public class GrimReaper2009D extends Conversation { public static NPCClickHandler handleGrimTalk = new NPCClickHandler(new Object[] { 8977 }, e -> { e.getNPC().resetDirection(); e.getPlayer().startConversation(new GrimReaper2009D(e.getPlayer())); }); public GrimReaper2009D(Player player) { super(player); switch(player.getI(Halloween2009.STAGE_KEY, 0)) { case 0: addNPC(8867, HeadE.CALM_TALK, ""Welcome to the house of Death, mortal.""); addOptions(new Options() { @Override public void create() { Dialogue mainline = new Dialogue(); option(""Hello sir, um, Your Highness, um..."", new Dialogue() .addPlayer(HeadE.SCARED, ""Hello sir, um, Your Highness, um..."") .addNPC(8867, HeadE.CALM_TALK, ""I need no title."") .addNext(mainline)); option(""Hey Death, how's it hanging?"", new Dialogue() .addPlayer(HeadE.CHEERFUL, ""Hey Death, how's it hanging?"") .addNPC(8867, HeadE.CALM_TALK, ""I have not seen a good hanging for some time...but there are other ways for people to meet me."") .addNext(mainline)); mainline.addNPC(8867, HeadE.CALM_TALK, ""I have summoned you here because I deem it necessary."") .addNPC(8867, HeadE.CALM_TALK, ""I have a task for you. A task of grave importance. A task that will shake you to your very core."") .addOptions(new Options() { @Override public void create() { option(""What is this task?"", new Dialogue() .addPlayer(HeadE.CONFUSED, ""What is this task?"") .addNPC(8867, HeadE.CALM_TALK, ""There is..."") .addNPC(8867, HeadE.CALM_TALK, ""...a spider in my bathtub."") .addOptions(new Options(""taskResponses"", GrimReaper2009D.this) { @Override public void create() { option(""You're scared of spiders? Ha!"", new Dialogue() .addPlayer(HeadE.LAUGH, ""You're scared of spiders? Ha!"") .addNPC(8867, HeadE.ANGRY, ""Silence mortal!"") .addNPC(8867, HeadE.ANGRY, ""I am the Grim Reaper, the incarnation of Death, and I cannot be frightened. Besides, this spider is enormous."") .addGotoStage(""taskResponses"", GrimReaper2009D.this)); option(""Why don't you kill it?"", new Dialogue() .addPlayer(HeadE.CONFUSED, ""Why don't you kill it?"") .addNPC(8867, HeadE.CALM_TALK, ""I do not wish to kill a creature whose time to die has not come. However, I cannot touch it without killing it. This is why I need you"") .addGotoStage(""taskResponses"", GrimReaper2009D.this)); option(""Don't you have a servant to deal with this?"", new Dialogue() .addPlayer(HeadE.CONFUSED, ""Don't you have a servant to deal with this?"") .addNPC(8867, HeadE.CALM_TALK, ""I have lost too many servants over the years,"") .addNPC(8867, HeadE.CALM_TALK, ""One accidental touch and I must begin recruitment anew. Now I live alone and bring in help only when I need it. Such as now."") .addGotoStage(""taskResponses"", GrimReaper2009D.this)); option(""I'll deal with the spider."", new Dialogue() .addPlayer(HeadE.CALM_TALK, ""I'll deal with the spider."") .addNPC(8867, HeadE.CALM_TALK, ""Good. You will find the bathroom on the upper floor."", () -> player.save(Halloween2009.STAGE_KEY, 1))); option(""I'm not doing your chores!"", new Dialogue() .addPlayer(HeadE.CHUCKLE, ""I'm not doing your chores!"") .addNPC(8867, HeadE.CALM_TALK, ""Then begone, mortal."")); } })); option(""I'm not doing your chores!"", new Dialogue() .addPlayer(HeadE.CHUCKLE, ""I'm not doing your chores!"") .addNPC(8867, HeadE.CALM_TALK, ""Then begone, mortal."")); } }); } }); break; case 1: addPlayer(HeadE.CALM_TALK, ""Hey Grim. I'm back.""); addNPC(8867, HeadE.CALM_TALK, ""Evidently.""); addPlayer(HeadE.CALM_TALK, ""I'm sorry, but could you just tell me again what you want me to do?""); addNPC(8867, HeadE.CALM_TALK, ""Repetition should not be necessary here. Go get that massive spider out of my bathtub.""); addPlayer(HeadE.CALM_TALK, ""Thank you.""); break; case 2: addPlayer(HeadE.CALM_TALK, ""The spider says it was sent by the Spider Queen, and it will only leave if the Spider Queen tells it to.""); addNPC(8867, HeadE.CALM_TALK, ""That is...concerning.""); addNPC(8867, HeadE.CALM_TALK, ""You must meet with the Spider Queen and ask her to remove the spider from my bath. I will open a portal for you.""); addNext(() -> player.save(Halloween2009.STAGE_KEY, 3)); break; case 3: case 4: case 5: addPlayer(HeadE.CALM_TALK, ""Hey Grim. I'm back.""); addNPC(8867, HeadE.CALM_TALK, ""Evidently.""); addPlayer(HeadE.CALM_TALK, ""I'm sorry, but could you just tell me again what you want me to do?""); addNPC(8867, HeadE.CALM_TALK, ""Repetition should not be necessary here. Go through the portal I opened for you and speak with the Spider Queen.""); addPlayer(HeadE.CALM_TALK, ""Thank you.""); break; case 6: addNPC(8867, HeadE.CALM_TALK, ""You have returned, mortal. How went your visit to the Spider Realm?""); addNext(new SpiderStatement(""Ooh! Are you really the Grim Reaper?"")); addNPC(8867, HeadE.CALM_TALK, ""Umm...yes.""); addNext(new SpiderStatement(""Wow! You're all bones and stuff!"")); addNPC(8867, HeadE.CALM_TALK, ""Umm...quite. And who might you be?""); addNext(new SpiderStatement(""Eek!"")); addNPC(8867, HeadE.CALM_TALK, ""I am sorry. I know my appearance can be frightening.""); addNext(new SpiderStatement(""Ha ha ha ha ha ha ha!"")); addNPC(8867, HeadE.CONFUSED, player.getDisplayName()+"", who is this spider?""); addPlayer(HeadE.CALM_TALK, ""This is Eek the Spider.""); addNPC(8867, HeadE.CALM_TALK, ""Ah, I see.""); addNext(new SpiderStatement(""Ha ha ha ha ha ha ha!"")); addNPC(8867, HeadE.CALM_TALK, ""Since you have returned with a companion, can I assume your trip met with some success?""); addNext(new SpiderStatement(""We've got to spin webs in your house. All over it!"")); addPlayer(HeadE.CALM_TALK, ""The Spider Queen will remove the spider from your bath if you let Eek the Spider put webs in your house.""); addNPC(8867, HeadE.CALM_TALK, ""Ah, I see.""); addNPC(8867, HeadE.CALM_TALK, ""She is right. Guthix decrees that my house be full of cobwebs, especially at Hallowe'en.""); addNPC(8867, HeadE.CALM_TALK, ""Very well. You have the freedom of my house. Please spin webs over whatever Eek the Spider wishes.""); addNext(new SpiderStatement(""Hold me in your hand, ""+player.getDisplayName()+""! Then we'll see what we can web up!""), () -> { player.save(Halloween2009.STAGE_KEY, 7); Halloween2009.refreshWebbables(player, player.getEquipment().getWeaponId() == 15353); }); break; case 7: addNPC(8867, HeadE.CALM_TALK, ""Have you finished spinning cobwebs on my furniture?""); addPlayer(HeadE.CALM_TALK, ""Not yet, but we're working on it.""); addNext(new SpiderStatement(""Yeah, we're all over it!"")); break; case 8: addNPC(8867, HeadE.CALM_TALK, ""Have you finished spinning cobwebs on my furniture?""); addNext(new SpiderStatement(""Yes! All done! All done!"")); addNPC(8867, HeadE.CALM_TALK, ""Then please return to the Spider Queen and tell her that you are done here, so that she can tell the spider to move from my bath."", () -> player.save(Halloween2009.STAGE_KEY, 9)); break; case 9: addNPC(8867, HeadE.CALM_TALK, ""Have you spoken with the Queen about getting that spider gone yet?""); addPlayer(HeadE.CALM_TALK, ""Not yet, but I'm on my way.""); break; case 10: addNPC(8867, HeadE.CALM_TALK, ""Tremble, mortal! You have the gratitude...of Death!""); addOptions(new Options() { @Override public void create() { option(""You were scarier before I was running errands for you."", new Dialogue() .addPlayer(HeadE.CONFUSED, ""You were scarier before I was running errands for you."") .addNPC(8867, HeadE.CALM_TALK, ""It matters not whether you are frightened. Some mortals fear death; some do not. They all meet me sooner or later."")); option(""Are you going to leave all these webs up?"", new Dialogue() .addPlayer(HeadE.CONFUSED, ""Are you going to leave all these webs up?"") .addNPC(8867, HeadE.CALM_TALK, ""Once Hallowe'en is done, I will clear some of them away. I will make sure not to offend the Spider Queen again, though."")); option(""I think the Spider Queen was being unreasonable."", new Dialogue() .addPlayer(HeadE.CONFUSED, ""I think the Spider Queen was being unreasonable."") .addNPC(8867, HeadE.CALM_TALK, ""I am not disagreeing with you, but she is a powerful creature and it is wise not to offend her."")); } }); break; } create(); } }" "package com.rs.game.content.holidayevents.halloween.hw09; @PluginEventHandler public class Halloween2009 { public static String STAGE_KEY = ""hw2023""; public static final boolean ENABLED = false; static Tile WEB_RESET_LOC = Tile.of(3936, 5125, 2); public static Tile START_LOCATION = Tile.of(3808, 5135, 0); private static final HashMap> WEBS = new HashMap<>(); private static final Integer[][] PATHS = { { 46711, 46710, 46706, 46712 }, { 46711, 46708, 46705, 46698, 46692, 46695, 46715 }, { 46711, 46709, 46707, 46701, 46700, 46696, 46717 }, { 46711, 46710, 46707, 46701, 46700, 46696, 46693, 46716 }, { 46711, 46708, 46697, 46690, 46692, 46695, 46715 }, { 46711, 46709, 46702, 46691, 46694, 46696, 46693, 46695, 46715 }, { 46711, 46708, 46697, 46690, 46692, 46695, 46693, 46696, 46717 }, { 46711, 46709, 46707, 46701, 46700, 46696, 46717 }, { 46711, 46709, 46702, 46691, 46688, 46689, 46692, 46695, 46699, 46714 } }; static { //South line WEBS.put(46711, new HashSet<>(Arrays.asList(46708, 46709, 46710))); WEBS.put(46710, new HashSet<>(Arrays.asList(46711, 46705, 46706, 46707))); WEBS.put(46706, new HashSet<>(Arrays.asList(46710, 46703, 46712, 46704))); WEBS.put(46712, new HashSet<>(List.of(46706))); //Southeast line WEBS.put(46709, new HashSet<>(Arrays.asList(46702, 46707, 46711))); WEBS.put(46707, new HashSet<>(Arrays.asList(46701, 46704, 46709, 46710))); WEBS.put(46704, new HashSet<>(Arrays.asList(46700, 46706, 46707, 46719))); WEBS.put(46719, new HashSet<>(List.of(46704))); //East line WEBS.put(46702, new HashSet<>(Arrays.asList(46701, 46709, 46691))); WEBS.put(46701, new HashSet<>(Arrays.asList(46702, 46707, 46700, 46694))); WEBS.put(46700, new HashSet<>(Arrays.asList(46701, 46704, 46718, 46696))); WEBS.put(46718, new HashSet<>(List.of(46700))); //Northeast line WEBS.put(46691, new HashSet<>(Arrays.asList(46702, 46694, 46688))); WEBS.put(46694, new HashSet<>(Arrays.asList(46691, 46701, 46696, 46689))); WEBS.put(46696, new HashSet<>(Arrays.asList(46694, 46700, 46717, 46693))); WEBS.put(46717, new HashSet<>(List.of(46696))); //North line WEBS.put(46688, new HashSet<>(Arrays.asList(46691, 46689, 46690))); WEBS.put(46689, new HashSet<>(Arrays.asList(46688, 46694, 46693, 46692))); WEBS.put(46693, new HashSet<>(Arrays.asList(46689, 46696, 46716, 46695))); WEBS.put(46716, new HashSet<>(List.of(46693))); //Northwest line WEBS.put(46690, new HashSet<>(Arrays.asList(46688, 46692, 46697))); WEBS.put(46692, new HashSet<>(Arrays.asList(46689, 46695, 46698, 46690))); WEBS.put(46695, new HashSet<>(Arrays.asList(46693, 46715, 46699, 46692))); WEBS.put(46715, new HashSet<>(List.of(46695))); //West line WEBS.put(46697, new HashSet<>(Arrays.asList(46690, 46698, 46708))); WEBS.put(46698, new HashSet<>(Arrays.asList(46697, 46692, 46699, 46705))); WEBS.put(46699, new HashSet<>(Arrays.asList(46698, 46695, 46714, 46703))); WEBS.put(46714, new HashSet<>(List.of(46699))); //Southwest airline WEBS.put(46708, new HashSet<>(Arrays.asList(46697, 46705, 46711))); WEBS.put(46705, new HashSet<>(Arrays.asList(46708, 46698, 46703, 46710))); WEBS.put(46703, new HashSet<>(Arrays.asList(46705, 46699, 46713, 46706))); WEBS.put(46713, new HashSet<>(List.of(46703))); } @ServerStartupEvent(Priority.FILE_IO) public static void loadPortal() { if (ENABLED) ObjectSpawns.add(new ObjectSpawn(31845, 10, 0, Tile.of(3210, 3425, 0), ""Portal to enter Death's House."")); } public static ItemClickHandler handleEek = new ItemClickHandler(new Object[] { 15353 }, new String[] { ""Hold"", ""Talk-to"", ""Play-with"", ""Dismiss"" }, e -> { switch(e.getOption()) { case ""Hold"": Equipment.sendWear(e.getPlayer(), e.getSlotId(), e.getItem().getId(), true); break; case ""Talk-to"": break; case ""Play-with"": e.getPlayer().setNextAnimation(new Animation(12490)); e.getPlayer().setNextSpotAnim(new SpotAnim(2178)); break; case ""Dismiss"": e.getPlayer().startConversation(new DestroyItem(e.getPlayer(), e.getSlotId(), e.getItem())); break; } }); public static ObjectClickHandler handleWebWalks = new ObjectClickHandler(false, WEBS.keySet().toArray(), e -> { WorldObject curr = World.getClosestObject(""Web"", e.getPlayer().getTile(), 3); if (curr == null) { e.getPlayer().sendMessage(""You aren't in a position to walk towards that web!""); return; } Set possibles = WEBS.get(curr.getId()); if (possibles == null || !possibles.contains(e.getObjectId())) { e.getPlayer().sendMessage(""You aren't in a position to walk towards that web!""); return; } Halloween2009Controller ctrl = e.getPlayer().getControllerManager().getController(Halloween2009Controller.class); if (ctrl == null || ctrl.getPath() == null) { e.getPlayer().sendMessage(""Error occurred while getting path. Moving you to start point.""); e.getPlayer().getControllerManager().startController(new Halloween2009Controller()); return; } boolean failed = !ctrl.getPath().contains(e.getObjectId()); boolean running = e.getPlayer().getRun(); e.getPlayer().lock(); e.getPlayer().setRunHidden(false); Tile from = curr.getCoordFace(); Tile to = e.getObject().getCoordFace(); boolean needStart = !e.getPlayer().matches(from); if (needStart) e.getPlayer().addWalkSteps(curr.getCoordFace(), 2, false); WorldTasks.scheduleLooping(new Task() { boolean started; int failTimer = 3; @Override public void run() { if (failed && failTimer <= 0) { e.getPlayer().sendMessage(""Oops! That didn't seem like the right way!"", true); e.getPlayer().resetWalkSteps(); e.getPlayer().getAppearance().setBAS(-1); e.getPlayer().setNextAnimation(new Animation(12917)); WorldTasks.delay(1, () -> { e.getPlayer().setNextAnimation(new Animation(767)); e.getPlayer().unlock(); e.getPlayer().tele(WEB_RESET_LOC); }); stop(); } if (!started) { started = true; e.getPlayer().getAppearance().setBAS(155); e.getPlayer().addWalkSteps(to, 25, false); } if (e.getPlayer().matches(to)) { e.getPlayer().getAppearance().setBAS(-1); e.getPlayer().setRunHidden(running); e.getPlayer().unlock(); stop(); } failTimer--; } }, needStart ? 1 : 0, 0); }); public static ObjectClickHandler handleEnter = new ObjectClickHandler(new Object[] { 31845 }, e -> { if (!ENABLED) return; e.getPlayer().getControllerManager().startController(new Halloween2009Controller()); }); public static ObjectClickHandler handleGrimStairs = new ObjectClickHandler(new Object[] { 27866, 27870 }, e -> e.getPlayer().useStairs(e.getPlayer().transform(e.getObjectId() == 27866 ? -5 : 5, 0, e.getObjectId() == 27866 ? 1 : -1))); public static ObjectClickHandler spiderPortal = new ObjectClickHandler(new Object[] { 46932 }, e -> { if (e.getPlayer().getI(Halloween2009.STAGE_KEY) >= 6) { e.getPlayer().sendOptionDialogue(""Select an Option"", ops -> { ops.add(""Go to web maze."", () -> { e.getPlayer().setNextAnimation(new Animation(12776)); WorldTasks.delay(1, () -> { e.getPlayer().setNextAnimation(new Animation(12777)); e.getPlayer().tele(Tile.of(3936, 5125, 2)); e.getPlayer().getPackets().sendRunScript(2582, 837, 0, 0); //turn off scenery shadows so people can see the floor... }); }); ops.add(""Go to spider court."", () -> { e.getPlayer().setNextAnimation(new Animation(12776)); WorldTasks.delay(1, () -> { e.getPlayer().setNextAnimation(new Animation(12777)); e.getPlayer().tele(Tile.of(3744, 5287, 0)); e.getPlayer().getPackets().sendRunScript(2582, 837, 0, 0); //turn off scenery shadows so people can see the floor... }); }); }); } else { e.getPlayer().setNextAnimation(new Animation(12776)); WorldTasks.delay(1, () -> { e.getPlayer().setNextAnimation(new Animation(12777)); e.getPlayer().tele(Tile.of(3936, 5125, 2)); e.getPlayer().getPackets().sendRunScript(2582, 837, 0, 0); //turn off scenery shadows so people can see the floor... }); } }); public static ObjectClickHandler spiderPortalExit = new ObjectClickHandler(new Object[] { 46934 }, e -> { e.getPlayer().setNextAnimation(new Animation(12776)); WorldTasks.delay(1, () -> { e.getPlayer().setNextAnimation(new Animation(12777)); e.getPlayer().tele(Tile.of(3805, 5149, 0)); }); }); public static ObjectClickHandler webLaddersDown = new ObjectClickHandler(new Object[] { 46936 }, e -> { if (e.getObject().getTile().isAt(3744, 5288)) { if (e.getPlayer().getI(Halloween2009.STAGE_KEY) >= 6) { e.getPlayer().sendOptionDialogue(""Select an Option"", ops -> { ops.add(""Go down the ladder."", () -> e.getPlayer().useLadder(/*Tile.of(3936, 5372, 2)*/Tile.of(3936, 5150, 2))); ops.add(""Return to the Grim Reaper's House."", () -> e.getPlayer().useLadder(Tile.of(3805, 5149, 0))); }); return; } e.getPlayer().useLadder(/*Tile.of(3936, 5372, 2)*/Tile.of(3936, 5150, 2)); } else e.getPlayer().useLadder(Tile.of(3744, 5276, 0)); }); public static ObjectClickHandler agilCourseLadderDown = new ObjectClickHandler(new Object[] { 46939 }, e -> e.getPlayer().useLadder(Tile.of(3936, 5150, 2))); public static ObjectClickHandler agilCourseLadderUp = new ObjectClickHandler(new Object[] { 46731 }, e -> e.getPlayer().useLadder(/*e.getObject().isAt(3936, 5151) ? Tile.of(3936, 5315, 2) : */Tile.of(3744, 5287, 0))); public static ObjectClickHandler webLaddersUp = new ObjectClickHandler(new Object[] { 46938 }, e -> { if (e.getPlayer().getI(Halloween2009.STAGE_KEY) < 4) { e.getPlayer().startConversation(new Dialogue().addNPC(8976, HeadE.SPIDER_EXCLAIM, ""Halt! Nobody is permitted to see the Spider Queen. Especially not a four-limbed intruder like yourself!"")); return; } e.getPlayer().useLadder(Tile.of(3809, 5277, 0)); }); public static Set getRandomPath() { return new HashSet<>(Arrays.asList(PATHS[Utils.random(PATHS.length)])); } public static ItemEquipHandler handleEekEquip = new ItemEquipHandler(15353, e -> refreshWebbables(e.getPlayer(), e.equip())); public static ObjectClickHandler webbables = new ObjectClickHandler(Arrays.stream(Utils.range(46861, 46924)).boxed().toArray(Integer[]::new), e-> { if (!e.getOption().equals(""Web"")) return; Halloween2009Controller ctrl = e.getPlayer().getControllerManager().getController(Halloween2009Controller.class); if (ctrl == null || ctrl.getWebbedUp() == null) { e.getPlayer().sendMessage(""Error occurred while getting path. Moving you to start point.""); e.getPlayer().getControllerManager().startController(new Halloween2009Controller()); return; } e.getPlayer().lock(); e.getPlayer().setNextAnimation(new Animation(12490)); e.getPlayer().setNextSpotAnim(new SpotAnim(2178)); WorldTasks.delay(2, () -> { e.getPlayer().unlock(); e.getPlayer().setNextAnimation(new Animation(1264)); e.getPlayer().setNextSpotAnim(new SpotAnim(-1)); ctrl.web(e.getObjectId()); }); }); public static void refreshWebbables(Player player, boolean showWebOp) { if (player.getI(Halloween2009.STAGE_KEY) < 7) return; Halloween2009Controller ctrl = player.getControllerManager().getController(Halloween2009Controller.class); if (ctrl == null || ctrl.getWebbedUp() == null) return; for (int i = 46861;i <= 46924;i++) player.getVars().setVarBit(ObjectDefinitions.getDefs(i).varpBit, ctrl.getWebbedUp().contains(i) || player.getI(Halloween2009.STAGE_KEY) > 8 ? 2 : showWebOp ? 1 : 0); } }" "package com.rs.game.content.holidayevents.halloween.hw09; public class Halloween2009Controller extends Controller { private final Set path; private final Set webbedUp; public Halloween2009Controller() { path = Halloween2009.getRandomPath(); webbedUp = new HashSet<>(); } @Override public void start() { player.tele(Halloween2009.START_LOCATION); } @Override public boolean sendDeath() { player.lock(7); player.stopAll(); WorldTasks.scheduleLooping(new Task() { int loop; @Override public void run() { if (loop == 0) player.setNextAnimation(new Animation(836)); else if (loop == 1) player.sendMessage(""Oh dear, you have died.""); else if (loop == 3) { player.tele(player.getI(Halloween2009.STAGE_KEY) < 10 ? Halloween2009.START_LOCATION : Tile.of(3211, 3424, 0)); player.reset(); player.setNextAnimation(new Animation(-1)); } else if (loop == 4) { if (player.getI(Halloween2009.STAGE_KEY) >= 10) player.getControllerManager().forceStop(); player.jingle(90); stop(); } loop++; } }, 0, 1); return false; } @Override public boolean processObjectClick1(GameObject object) { switch(object.getId()) { case 46935: player.sendOptionDialogue(""Are you sure you want to leave? Any maze/webbing progress will be reset!"", ops -> { ops.add(""Yes, I understand."", () -> { player.getControllerManager().forceStop(); player.useStairs(Tile.of(3211, 3424, 0)); }); ops.add(""Nevermind.""); }); break; } return true; } @Override public void process() { if (player.getI(Halloween2009.STAGE_KEY) >= 3) refreshVars(player); } @Override public boolean login() { Halloween2009.refreshWebbables(player, player.getEquipment().getWeaponId() == 15353); return false; } @Override public boolean logout() { return false; } @Override public void onTeleported(TeleType type) { } @Override public void forceClose() { } @Override public boolean processTeleport(Teleport tele) { player.sendMessage(""A mysterious force prevents you from teleporting.""); return false; } private void refreshVars(Player player) { if (player.getI(Halloween2009.STAGE_KEY) >= 10) player.getVars().setVarBit(4883, 50); else if (player.getI(Halloween2009.STAGE_KEY) >= 3) player.getVars().setVarBit(4883, 20); } public Set getPath() { return path; } public void web(int objectId) { webbedUp.add(objectId); Halloween2009.refreshWebbables(player, player.getEquipment().getWeaponId() == 15353); int WEBS_TOTAL = 63; int numLeft = WEBS_TOTAL -webbedUp.size(); if (numLeft > 0) player.sendMessage(""You web up the "" + ObjectDefinitions.getDefs(objectId, player.getVars()).getName().toLowerCase() + "". Only "" + numLeft + "" more to go!""); else { player.save(Halloween2009.STAGE_KEY, 8); player.sendMessage(""That's all of them! Return to the Grim Reaper.""); player.startConversation(new Dialogue().addNext(new SpiderStatement(""That's it! We've done them all! Now we should talk to the scary skeleton guy.""))); } } public Set getWebbedUp() { return webbedUp; } }" "package com.rs.game.content.holidayevents.halloween.hw09; @PluginEventHandler public class SpiderHeraldD extends Conversation { public static NPCClickHandler handleSpiderTalk = new NPCClickHandler(new Object[] { 8976 }, e -> { e.getNPC().resetDirection(); e.getPlayer().startConversation(new SpiderHeraldD(e.getPlayer())); }); public SpiderHeraldD(Player player) { super(player); switch(player.getI(Halloween2009.STAGE_KEY, 0)) { case 3: addNPC(8976, HeadE.SPIDER_CALM, ""Who goes there? Four-limbed intruder! Come no further! State your business!""); addOptions(new Options() { @Override public void create() { option(""I must meet the Queen of Spiders."", new Dialogue() .addPlayer(HeadE.CALM_TALK, ""I must meet the Queen of Spiders."") .addNPC(8976, HeadE.SPIDER_CALM, ""It may be, among your people, that the lowliest may enter the bed-chamber of a monarch; But we spiders are more formal."") .addNPC(8976, HeadE.SPIDER_CALM, ""Tell me, then, have you some patron on whose business you come hither?"") .addPlayer(HeadE.CALM_TALK, ""Death has sent me; the Grim Reaper."") .addNPC(8976, HeadE.SPIDER_EXCLAIM, ""The Grim Reaper! I implore you, grant your pardon for my rudeness! I was told the Queen expected the Dread Lord to send an agent."") .addNPC(8976, HeadE.SPIDER_CALM, ""Do not let my words detain you. You should ascend the ladder."", () -> player.save(Halloween2009.STAGE_KEY, 4))); option(""Wretched spiders! I will crush you!"", new Dialogue() .addPlayer(HeadE.ANGRY, ""Wretched spiders! I will crush you!"") .addNPC(8976, HeadE.SPIDER_CALM, ""What an introduction. I don't think you would stand the slightest chance against us, human."")); } }); break; case 4: addNPC(8976, HeadE.SPIDER_CALM, ""Visitor, you should ascend the ladder.""); break; case 5: addNPC(8976, HeadE.SPIDER_CALM, ""Visitor, you should...""); addNPC(8976, HeadE.SPIDER_NONE, ""...""); addNPC(8976, HeadE.SPIDER_CALM, ""Through vibrations of the web-strands at my feet, below your hearing, or Dread Monarch has informed me that your business is concluded.""); addNPC(8976, HeadE.SPIDER_NONE, ""...""); addNPC(8976, HeadE.SPIDER_CALM, ""And she tells me a companion, a web-spinner, will be needed for your return to the dwelling of our noble friend the Reaper.""); addNPC(8976, HeadE.SPIDER_CALM, ""Who, though?""); addNPC(8976, HeadE.SPIDER_CALM, ""Who, though? Yes! I know the very Emissary I can give you. Small, but most enthusiastic: Eek the Spider will go with you.""); addNext(new SpiderStatement(""Boo!"")); addPlayer(HeadE.HAPPY_TALKING, ""Hello, Eek.""); addNext(new SpiderStatement(""Hello big human!"")); addItem(15353, ""(Eek the Spider jumps into your backpack.)"", () -> { player.save(Halloween2009.STAGE_KEY, 6); player.getInventory().addItem(15353); }); addNext(new SpiderStatement(""Let's go! This'll be fun!"")); break; case 6: case 7: case 8: case 9: if (!player.containsItem(15353)) { addItem(15353, ""(Eek the Spider jumps into your backpack.)"", () -> { player.save(Halloween2009.STAGE_KEY, 6); player.getInventory().addItem(15353); }); addNext(new SpiderStatement(""Let's go! This'll be fun!"")); } else addNPC(8976, HeadE.SPIDER_CALM, ""My sincerest apologies for my rudeness. I hope you found your meeting with our Queen delightful.""); break; default: addNPC(8976, HeadE.SPIDER_CALM, ""Human, let me add my praises to the thanks of our Dread Monarch. You have joined the hallowed canon of heroes of our nation.""); addNPC(8976, HeadE.SPIDER_CALM, ""With stubborn dedication of our brother Incey-Wincey;With the curds and whey that scattered from the tuffet of Miss Muffet;""); addNPC(8976, HeadE.SPIDER_CALM, ""With the weaving of Arachne;With the cunning of Anansi;With these and our other stories your time here will be remembered.""); break; } create(); } }" "package com.rs.game.content.holidayevents.halloween.hw09; @PluginEventHandler public class SpiderQueenD extends Conversation { public static NPCClickHandler handleSpiderTalk = new NPCClickHandler(new Object[] { 8975 }, e -> { e.getNPC().resetDirection(); e.getPlayer().startConversation(new SpiderQueenD(e.getPlayer())); }); public SpiderQueenD(Player player) { super(player); switch(player.getI(Halloween2009.STAGE_KEY, 0)) { case 4: addNPC(8975, HeadE.SPIDER_CALM, ""Who approaches the Spider Queen?""); addPlayer(HeadE.CALM_TALK, ""A messenger of the Grim Reaper.""); addNPC(8975, HeadE.SPIDER_CALM, ""I knew he would not have the courage to meet me himself.""); addNPC(8975, HeadE.SPIDER_CALM, ""But what of the messenger? Who are you?""); addPlayer(HeadE.CALM_TALK, player.getDisplayName()+"", Your Majesty.""); addNPC(8975, HeadE.SPIDER_CALM, ""Good. You show respect, unlike your master.""); addNPC(8975, HeadE.SPIDER_NONE, ""So, ""+player.getDisplayName()+"", servant of the Grim Reaper - what is your master's business with me?""); addPlayer(HeadE.CALM_TALK, ""There's a spider in the Grim Reaper's bathtub.""); addNPC(8975, HeadE.SPIDER_NONE, ""Yes! I know this! I put that spider there. She is a faithful servant and she will not leave until I command it.""); addPlayer(HeadE.CONFUSED, ""Why did you put the spider in Grim's bathtub?""); addNPC(8975, HeadE.SPIDER_EXCLAIM, ""Because he insulted me! At Halloween of all times!""); addPlayer(HeadE.CONFUSED, ""What did he do to insult you?""); addNPC(8975, HeadE.SPIDER_CALM, ""He has cleaned the cobwebs from his house!""); addNPC(8975, HeadE.SPIDER_CALM, ""Since time immemorial, Guthix has declared that the Grim Reaper's role involve a particular aesthetic.""); addNPC(8975, HeadE.SPIDER_CALM, ""The scythe! The hood! The bones! The Grim Reaper must have those things!""); addNPC(8975, HeadE.SPIDER_CALM, ""The decor of his house is similarly prescribed. It must be dark. It must be ominous. It must be spooky.""); addNPC(8975, HeadE.SPIDER_CALM, ""And it must have spider-webs!""); addNPC(8975, HeadE.SPIDER_CALM, ""But the Grim Reaper has cleaned his house and removed all the spider-webs. At Hallowe'en, the most spooky of seasons!""); addNPC(8975, HeadE.SPIDER_CALM, ""I take this as an insult! The bath spider will remain until the Grim Reaper's house is full of its proper cobwebs.""); addPlayer(HeadE.CONFUSED, ""Shall I ask the Grim Reaper to put cobwebs in his house?""); addNPC(8975, HeadE.SPIDER_CALM, ""Do not ask him! Tell him! It is an instruction from the Queen of Spiders herself, and the Grim Reaper will obey it!""); addNPC(8975, HeadE.SPIDER_CALM, ""Go now! But first, speak to my herald. he will give you a companion to help you in this task."", () -> player.save(Halloween2009.STAGE_KEY, 5)); break; case 5: addNPC(8975, HeadE.SPIDER_CALM, ""Go now! But first, speak to my herald. he will give you a companion to help you in this task.""); break; case 6: case 7: case 8: addNPC(8975, HeadE.SPIDER_EXCLAIM, ""What are you doing here, mammal? Have you finished spinning webs in the house of Death already?""); addPlayer(HeadE.SCARED, ""No.. not quite yet.""); addNPC(8975, HeadE.SPIDER_CALM, ""Better get to it then, quickly. You're a worse procrastinator than Trent is when it comes to Hallowe'en.""); break; case 9: addNPC(8975, HeadE.SPIDER_EXCLAIM, ""What are you doing here, mammal? Have you finished spinning webs in the house of Death already?""); addNext(new SpiderStatement(""Y-yes your m-majesty! It's totally spooky!"")); addNPC(8975, HeadE.SPIDER_CALM, ""Good. Thank you, Eek.""); addPlayer(HeadE.CONFUSED, ""Will you tell the bath spider to move now?""); addNPC(8975, HeadE.SPIDER_CALM, ""Of course! Are you suggesting that the Queen of Spiders would not keep her word?""); addPlayer(HeadE.CONFUSED, ""Thank you, is that everything then?""); addNPC(8975, HeadE.SPIDER_CALM, ""Yes! I am satisfied.""); addNPC(8975, HeadE.SPIDER_CALM, ""I have a reward for you, mammal. Never let it be said that the Spider Queen is ungrateful.""); addItem(9924, ""The Spider Queen gives you a spooky skeleton outfit.""); addItem(1053, ""The Spider Queen gives you a few halloween masks.""); addNPC(8975, HeadE.SPIDER_CALM, ""There! Our business is concluded. Eek, return to your web. Mammal, you may return to your world now.""); addNext(new SpiderStatement(""Y-your majesty?"")); addNPC(8975, HeadE.SPIDER_CALM, ""What is it, Eek? Speak up!""); addNext(new SpiderStatement(""Your majesty, I want to go with "" + player.getDisplayName() + ""."")); addNPC(8975, HeadE.SPIDER_CALM, ""You want to go with this mammal?""); addNext(new SpiderStatement(""I want to see the world! See all the human lands and have adventures, and...and maybe I can come back and tell everyone. It'll be fun!"")); addNPC(8975, HeadE.SPIDER_CALM, ""Yes...most amusing.""); addNPC(8975, HeadE.SPIDER_CALM, ""Eek the Spider, I make you my emissary.""); addNPC(8975, HeadE.SPIDER_CALM, ""Mammal, you will protect this spider, or feel my wrath.""); addNPC(8975, HeadE.SPIDER_CALM, ""Now go, both of you.""); addNext(() -> { player.save(Halloween2009.STAGE_KEY, 10); //player.getInventory().addItemDrop(new Item(15352, 1)); player.getInventory().addItemDrop(9921, 1); player.getInventory().addItemDrop(9922, 1); player.getInventory().addItemDrop(9923, 1); player.getInventory().addItemDrop(9924, 1); player.getInventory().addItemDrop(9925, 1); player.getInventory().addItemDrop(1053, 1); player.getInventory().addItemDrop(1055, 1); player.getInventory().addItemDrop(1057, 1); //player.addDiangoReclaimItem(15352); player.addDiangoReclaimItem(9921); player.addDiangoReclaimItem(9922); player.addDiangoReclaimItem(9923); player.addDiangoReclaimItem(9924); player.addDiangoReclaimItem(9925); player.addDiangoReclaimItem(15353); player.getEmotesManager().unlockEmote(Emote.SCARED); player.sendMessage(""You've unlocked the Scared emote!""); player.getEmotesManager().unlockEmote(Emote.PUPPET_MASTER); player.sendMessage(""You've unlocked the Puppet Master emote!""); player.getEmotesManager().unlockEmote(Emote.TRICK); player.sendMessage(""You've unlocked the Trick emote!""); }); break; default: addNPC(8975, HeadE.SPIDER_CALM, ""You will protect Eek, or feel my wrath.""); break; } create(); } }" "package com.rs.game.content.holidayevents.halloween.hw09; public class SpiderStatement implements Statement { private final String[] texts; public SpiderStatement(String... texts) { this.texts = texts; } @Override public void send(Player player) { StringBuilder builder = new StringBuilder(); for (String text2 : texts) builder.append("" "").append(text2); String text = builder.toString(); player.getInterfaceManager().sendChatBoxInterface(1184); player.getPackets().setIFText(1184, 17, NPCDefinitions.getDefs(8985, player.getVars()).getName()); player.getPackets().setIFText(1184, 13, text); player.getPackets().setIFModel(1184, 11, 24613); player.getPackets().setIFAngle(1184, 11, 100, 1900, 500); player.getPackets().setIFAnimation(6247, 1184, 11); } @Override public int getOptionId(int componentId) { return 0; } @Override public void close(Player player) { } }" "package com.rs.game.content.interfacehandlers; @PluginEventHandler public class GameFrame { public static ButtonClickHandler handlePrayerOrb = new ButtonClickHandler(749, e -> { if (e.getComponentId() == 4) if (e.getPacket() == ClientPacket.IF_OP1) // activate e.getPlayer().getPrayer().switchQuickPrayers(); else if (e.getPacket() == ClientPacket.IF_OP2) // switch e.getPlayer().getPrayer().switchSettingQuickPrayer(); }); public static ButtonClickHandler handleRunOrb = new ButtonClickHandler(750, e -> { if (e.getComponentId() == 4) if (e.getPacket() == ClientPacket.IF_OP1) { e.getPlayer().toggleRun(e.getPlayer().isResting() ? false : true); if (e.getPlayer().isResting()) e.getPlayer().stopAll(); } else if (e.getPacket() == ClientPacket.IF_OP2) { if (e.getPlayer().isResting()) { e.getPlayer().stopAll(); return; } if (e.getPlayer().getEmotesManager().isAnimating()) { e.getPlayer().sendMessage(""You can't rest while performing an emote.""); return; } if (e.getPlayer().isLocked()) { e.getPlayer().sendMessage(""You can't rest while performing an action.""); return; } e.getPlayer().stopAll(); e.getPlayer().getActionManager().setAction(new Rest()); } }); public static ButtonClickHandler handleAudioSettingsTab = new ButtonClickHandler(429, e -> { if (e.getComponentId() == 18) e.getPlayer().getInterfaceManager().sendSubDefault(Sub.TAB_SETTINGS); }); public static ButtonClickHandler handleChatSettings = new ButtonClickHandler(982, e -> { if (e.getComponentId() == 5) e.getPlayer().getInterfaceManager().sendSubDefault(Sub.TAB_SETTINGS); else if (e.getComponentId() == 41) e.getPlayer().getVars().saveVar(287, e.getPlayer().getVars().getVar(287) == 0 ? 1 : 0); else if (e.getComponentId() >= 17 && e.getComponentId() <= 36) e.getPlayer().getVars().saveVarBit(3612, e.getComponentId() - 17); else if (e.getComponentId() >= 97 && e.getComponentId() <= 116) e.getPlayer().getVars().saveVarBit(9191, e.getComponentId() - 97); else if (e.getComponentId() >= 49 && e.getComponentId() <= 66) e.getPlayer().getVars().saveVar(287, e.getComponentId() - 48); else if (e.getComponentId() >= 72 && e.getComponentId() <= 91) e.getPlayer().getVars().saveVarBit(9188, e.getComponentId() - 72); }); public static ButtonClickHandler handleSettingsTab = new ButtonClickHandler(261, e -> { if (e.getPlayer().getInterfaceManager().containsInventoryInter()) return; if (e.getComponentId() == 22) { if (e.getPlayer().getInterfaceManager().containsScreenInter()) { e.getPlayer().sendMessage(""Please close the interface you have open before setting your graphic options.""); return; } e.getPlayer().stopAll(); e.getPlayer().getInterfaceManager().sendInterface(742); } else if (e.getComponentId() == 12) e.getPlayer().switchAllowChatEffects(); else if (e.getComponentId() == 13) e.getPlayer().getInterfaceManager().sendSub(Sub.TAB_SETTINGS, 982); else if (e.getComponentId() == 14) e.getPlayer().switchMouseButtons(); else if (e.getComponentId() == 24) // audio options e.getPlayer().getInterfaceManager().sendSub(Sub.TAB_SETTINGS, 429); else if (e.getComponentId() == 16) // house options e.getPlayer().getInterfaceManager().sendSub(Sub.TAB_SETTINGS, 398); }); public static ButtonClickHandler handleChatboxGameBar = new ButtonClickHandler(751, e -> { if (e.getComponentId() == 14) ReportsManager.report(e.getPlayer()); if (e.getComponentId() == 23) { if (e.getPacket() == ClientPacket.IF_OP2) e.getPlayer().setClanStatus(0); else if (e.getPacket() == ClientPacket.IF_OP3) e.getPlayer().setClanStatus(1); else if (e.getPacket() == ClientPacket.IF_OP4) e.getPlayer().setClanStatus(2); } else if (e.getComponentId() == 32) { if (e.getPacket() == ClientPacket.IF_OP2) e.getPlayer().setFilterGame(false); else if (e.getPacket() == ClientPacket.IF_OP4) e.getPlayer().setFilterGame(true); } else if (e.getComponentId() == 0) { if (e.getPacket() == ClientPacket.IF_OP2) { e.getPlayer().getSocial().setFcStatus(0); LobbyCommunicator.updateSocial(e.getPlayer()); } else if (e.getPacket() == ClientPacket.IF_OP3) { e.getPlayer().getSocial().setFcStatus(1); LobbyCommunicator.updateSocial(e.getPlayer()); } else if (e.getPacket() == ClientPacket.IF_OP4) { e.getPlayer().getSocial().setFcStatus(2); LobbyCommunicator.updateSocial(e.getPlayer()); } } else if (e.getComponentId() == 23) { if (e.getPacket() == ClientPacket.IF_OP2) e.getPlayer().setClanStatus(0); else if (e.getPacket() == ClientPacket.IF_OP3) e.getPlayer().setClanStatus(1); else if (e.getPacket() == ClientPacket.IF_OP4) e.getPlayer().setClanStatus(2); } else if (e.getComponentId() == 17) if (e.getPacket() == ClientPacket.IF_OP2) e.getPlayer().setAssistStatus(0); else if (e.getPacket() == ClientPacket.IF_OP3) e.getPlayer().setAssistStatus(1); else if (e.getPacket() == ClientPacket.IF_OP4) e.getPlayer().setAssistStatus(2); else if (e.getPacket() == ClientPacket.IF_OP6) { // ASSIST XP Earned/Time } }); public static ButtonClickHandler handleWorldMap = new ButtonClickHandler(755, e -> { if (e.getComponentId() == 44) { e.getPlayer().getInterfaceManager().setWindowsPane(e.getPlayer().resizeable() ? 746 : 548); e.getPlayer().setNextAnimation(new Animation(-1)); } else if (e.getComponentId() == 42) { e.getPlayer().getHintIconsManager().removeAll(); //TODO find hintIcon index e.getPlayer().getVars().setVar(1159, 1); } }); public static ButtonClickHandler handleButtons = new ButtonClickHandler(new Object[] { InterfaceManager.FIXED_TOP, InterfaceManager.RESIZEABLE_TOP }, e -> { if ((e.getInterfaceId() == 548 && e.getComponentId() == 167) || (e.getInterfaceId() == 746 && e.getComponentId() == 208)) { if (e.getPlayer().getControllerManager().isIn(DungeonController.class)) return; switch(e.getPacket()) { case IF_OP1 -> e.getPlayer().getPackets().sendRunScript(5557, 1); case IF_OP2 -> e.getPlayer().sendInputInteger(""How much would you like to withdraw?"", num -> e.getPlayer().getInventory().coinPouchToInventory(num)); case IF_OP3 -> e.getPlayer().sendMessage(""Your pouch contains "" + NumberFormat.getNumberInstance(Locale.US).format(e.getPlayer().getInventory().getCoins()) + "" coins.""); case IF_OP4 -> { if (e.getPlayer().getInterfaceManager().containsScreenInter() || e.getPlayer().inCombat(10000) || e.getPlayer().hasBeenHit(10000)) { e.getPlayer().sendMessage(""Please finish what you're doing before opening the price checker.""); return; } e.getPlayer().stopAll(); PriceChecker.openPriceCheck(e.getPlayer()); } default -> e.getPlayer().sendMessage(""Unknown coin pouch option.""); } return; } if ((e.getInterfaceId() == 548 && e.getComponentId() == 157) || (e.getInterfaceId() == 746 && e.getComponentId() == 200)) { if (e.getPacket() == ClientPacket.IF_OP2) { e.getPlayer().getHintIconsManager().removeAll(); e.getPlayer().getVars().setVar(1159, 1); return; } if (e.getPlayer().getInterfaceManager().containsScreenInter() || e.getPlayer().getInterfaceManager().containsInventoryInter() || e.getPlayer().inCombat(10000)) { e.getPlayer().sendMessage(""Please finish what you're doing before opening the world map.""); return; } e.getPlayer().getInterfaceManager().setTopInterface(755, false); e.getPlayer().setNextAnimation(new Animation(840)); int posHash = e.getPlayer().getX() << 14 | e.getPlayer().getY(); e.getPlayer().getPackets().sendVarc(622, posHash); // map open center pos e.getPlayer().getPackets().sendVarc(674, posHash); // player position } else if ((e.getInterfaceId() == 548 && e.getComponentId() == 35) || (e.getInterfaceId() == 746 && e.getComponentId() == 55)) { if (e.getPacket() == ClientPacket.IF_OP1) e.getPlayer().getSkills().switchXPDisplay(); else if (e.getPacket() == ClientPacket.IF_OP2) e.getPlayer().getSkills().switchXPPopup(); else if (e.getPacket() == ClientPacket.IF_OP3) { if (e.getPlayer().getInterfaceManager().containsScreenInter() || e.getPlayer().getInterfaceManager().containsInventoryInter() || e.getPlayer().inCombat(10000)) { e.getPlayer().sendMessage(""Please finish what you're doing before opening the XP counter customizer.""); return; } e.getPlayer().getSkills().setupXPCounter(); } } else if ((e.getInterfaceId() == 746 && e.getComponentId() == 207) || (e.getInterfaceId() == 548 && e.getComponentId() == 159)) if (e.getPacket() == ClientPacket.IF_OP4) { if (e.getPlayer().getInterfaceManager().containsScreenInter()) { e.getPlayer().sendMessage(""Please finish what you're doing before opening the price checker.""); return; } e.getPlayer().stopAll(); PriceChecker.openPriceCheck(e.getPlayer()); } }); public static ButtonClickHandler handleAudioOptionsClose = new ButtonClickHandler(743, e -> { if (e.getComponentId() == 20) e.getPlayer().stopAll(); }); public static ButtonClickHandler handleGraphicsSettingsClose = new ButtonClickHandler(742, e -> { if (e.getComponentId() == 46) e.getPlayer().stopAll(); }); }" "package com.rs.game.content.interfacehandlers; @PluginEventHandler public class ItemsKeptOnDeath { public static ButtonClickHandler handleSwapWildy = new ButtonClickHandler(17, e -> { if (e.getComponentId() == 28) sendItemsKeptOnDeath(e.getPlayer(), !e.getPlayer().getTempAttribs().getB(""wildy"")); }); public static void openItemsKeptOnDeath(Player player) { player.getInterfaceManager().sendInterface(17); sendItemsKeptOnDeath(player, false); } public static void sendItemsKeptOnDeath(Player player, boolean wilderness) { boolean skulled = player.hasSkull(); Integer[][] slots = GraveStone.getItemSlotsKeptOnDeath(player, wilderness, skulled, player.getPrayer().isProtectingItem()); Item[][] items = GraveStone.getItemsKeptOnDeath(player, slots); long riskedWealth = 0; long carriedWealth = 0; for (Item item : items[1]) carriedWealth = riskedWealth += (long) item.getDefinitions().getValue() * item.getAmount(); for (Item item : items[0]) carriedWealth += (long) item.getDefinitions().getValue() * item.getAmount(); if (slots[0].length > 0) { for (int i = 0; i < slots[0].length; i++) player.getVars().setVarBit(9222 + i, slots[0][i]); player.getVars().setVarBit(9227, slots[0].length); player.save(""protectSlots"", slots[0].length); } else { player.getVars().setVarBit(9222, -1); player.getVars().setVarBit(9227, 1); player.save(""protectSlots"", 1); } player.getVars().setVarBit(9226, wilderness ? 1 : 0); player.getTempAttribs().setB(""wildy"", wilderness ? true : false); player.getVars().setVarBit(9229, skulled ? 1 : 0); StringBuilder text = new StringBuilder(); text.append(""The number of items kept on"").append(""
"").append(""death is normally 3."").append(""
"").append(""
"").append(""
""); if (wilderness) text.append(""Your gravestone will not"").append(""
"").append(""appear.""); else { int time = GraveStone.getMaximumTicks(player.getGraveStone()); int seconds = (int) (time * 0.6); int minutes = seconds / 60; seconds -= minutes * 60; text.append(""Gravestone:"").append(""
"").append(EnumDefinitions.getEnum(1099).getStringValue(player.getGraveStone())).append(""
"").append(""
"").append(""Initial duration:"").append(""
"").append(minutes).append("":"").append(seconds < 10 ? ""0"" : """").append(seconds).append(""
""); } text.append(""
"").append(""
"").append(""Carried wealth:"").append(""
"").append(carriedWealth > Integer.MAX_VALUE ? ""Too high!"" : Utils.getFormattedNumber((int) carriedWealth)).append(""
"").append(""
"").append(""Risked wealth:"").append(""
"").append(riskedWealth > Integer.MAX_VALUE ? ""Too high!"" : Utils.getFormattedNumber((int) riskedWealth)).append(""
"").append(""
""); if (wilderness) text.append(""Your hub will be set to:"").append(""
"").append(""Edgeville.""); else text.append(""Current hub: "").append(EnumDefinitions.getEnum(3792).getStringValue(DeathOfficeController.getCurrentHub(player, player.getTile()).ordinal())); player.getPackets().sendVarcString(352, text.toString()); } }" "package com.rs.game.content.interfacehandlers; @PluginEventHandler public class Logout { public static ButtonClickHandler handle = new ButtonClickHandler(182, e -> { if (e.getPlayer().getInterfaceManager().containsInventoryInter()) return; if (e.getComponentId() == 6 || e.getComponentId() == 13) if (!e.getPlayer().hasFinished()) e.getPlayer().logout(e.getComponentId() == 6); }); }" "package com.rs.game.content.interfacehandlers; @PluginEventHandler public class TransformationRing { public static ItemClickHandler handleItemOption = new ItemClickHandler(new Object[] { ""Ring of stone"", ""Easter ring"", ""Bone brooch"" }, new String[] { ""Wear"" }, e -> { if (e.getPlayer().inCombat(10000) || e.getPlayer().hasBeenHit(10000)) { e.getPlayer().sendMessage(""You wouldn't want to use that right now.""); return; } if (e.getItem().getName().equals(""Ring of stone"")) transformInto(e.getPlayer(), 2626); else if (e.getItem().getName().equals(""Easter ring"")) transformInto(e.getPlayer(), 3689 + Utils.random(5)); else if (e.getItem().getName().equals(""Bone brooch"")) { e.getPlayer().stopAll(true, true, true); e.getPlayer().lock(); e.getPlayer().setNextAnimation(new Animation(14870)); e.getPlayer().setNextSpotAnim(new SpotAnim(2838)); WorldTasks.schedule(new Task() { @Override public void run() { transformInto(e.getPlayer(), 12373); } }, 1); } }); public static ButtonClickHandler handleDeactivationButton = new ButtonClickHandler(375, e -> { if (e.getComponentId() == 3) deactivateTransformation(e.getPlayer()); }); public static void transformInto(Player player, int npcId) { player.stopAll(true, true, true); player.lock(); player.getAppearance().transformIntoNPC(npcId); player.getInterfaceManager().sendSub(Sub.TAB_INVENTORY, 375); player.getTempAttribs().setB(""TransformationRing"", true); } public static void deactivateTransformation(Player player) { player.getTempAttribs().removeB(""TransformationRing""); player.unlock(); player.setNextAnimation(new Animation(14884)); player.getAppearance().transformIntoNPC(-1); player.getInterfaceManager().sendSubDefault(Sub.TAB_INVENTORY); } public static void triggerDeactivation(Player player) { if (player.getTempAttribs().getB(""TransformationRing"")) deactivateTransformation(player); } }" "package com.rs.game.content.items; @PluginEventHandler public class DwarvenRockCakes { public static ItemClickHandler handleRockCakeClick = new ItemClickHandler(new Object[] { 7509, 7510 }, new String[] { ""Eat"" }, e -> { if (e.getItem().getId() == 7509 && e.getPlayer().getHitpoints() > 20) { Hit h = new Hit(20, HitLook.TRUE_DAMAGE); e.getPlayer().removeHitpoints(h); e.getPlayer().fakeHit(h); e.getPlayer().forceTalk(""Ow! Ow! That's hot!""); } else if (e.getItem().getId() == 7510 && e.getPlayer().getHitpoints() > 100) { Hit h = new Hit(100, HitLook.TRUE_DAMAGE); e.getPlayer().removeHitpoints(h); e.getPlayer().fakeHit(h); e.getPlayer().forceTalk(""Ow! I nearly broke a tooth!""); } }); }" "package com.rs.game.content.items; @PluginEventHandler public enum ItemPack { VIAL_OF_WATER(15363, new Item(228, 50)), SHARDS(15262, new Item(12183, 5000)), BAKRIMNEL_BOLTS(24133, new Item(24127, 50)), BASKEET(15366, new Item(5377, 50)), SACK(15367, new Item(5419, 50)), EYE_OF_NEWT(15364, new Item(222, 50)), BIRD_MEAT(15365, new Item(9979, 50)), JUJU_VIAL(20047, new Item(19995, 50)), VIAL(15362, new Item(230, 50)); private static final Map MAP = new HashMap<>(); static { for (ItemPack pack : ItemPack.values()) MAP.put(pack.itemId, pack); } private final int itemId; private final Item contents; private ItemPack(int itemId, Item contents) { this.itemId = itemId; this.contents = contents; } public static ItemPack forId(int itemId) { return MAP.get(itemId); } public int getItemId() { return itemId; } public Item getContents() { return contents; } public static final ItemClickHandler onClick = new ItemClickHandler(ItemPack.MAP.keySet().toArray(), e -> { ItemPack pack = ItemPack.forId(e.getItem().getId()); if (pack != null) { if (e.getOption().equals(""Open"")) pack.open(e.getPlayer()); if (e.getOption().equals(""Open-All"")) pack.openAll(e.getPlayer()); } }); public void open(Player player) { if (player.getInventory().containsItem(itemId, 1)) if (player.getInventory().addItem(contents)) player.getInventory().deleteItem(itemId, 1); } public void openAll(Player player) { int count = player.getInventory().getNumberOf(itemId); if (player.getInventory().containsItem(itemId, count)) { player.getInventory().deleteItem(itemId, count); player.getInventory().addItem(new Item(contents.getId(), contents.getAmount() * count)); } } }" "package com.rs.game.content.items; public class Lamp { private final int slot; private final int id; private final int req; private int selectedSkill; private double xp; public Lamp(int id, int slot, int req) { this.slot = slot; this.id = id; this.req = req; } public int getSlot() { return slot; } public int getId() { return id; } public int getReq() { return req; } public int getSelectedSkill() { return selectedSkill; } public void setSelectedSkill(int selectedSkill) { this.selectedSkill = selectedSkill; } public double getXp() { return xp; } public void setXp(double xp) { this.xp = xp; } }" "package com.rs.game.content.items; @PluginEventHandler public class Lamps { public static final int LAMP_SMALL = 0; public static final int LAMP_MEDIUM = 1; public static final int LAMP_BIG = 2; public static final int LAMP_HUGE = 3; public static final int[] SELECTABLE_XP_LAMPS = { 23713, 23714, 23715, 23716, 12628, 18782, 20960 }; public static final int[] SELECTABLE_XP_LAMPS_TYPES = { LAMP_SMALL, LAMP_MEDIUM, LAMP_BIG, LAMP_HUGE, LAMP_SMALL, LAMP_SMALL, LAMP_SMALL }; public static final int[][] SKILL_LAMPS = { { 23717, 23718, 23719, 23720 }, { 23725, 23726, 23727, 23728 }, { 23721, 23722, 23723, 23724 }, { 23753, 23754, 23755, 23756 }, { 23729, 23730, 23731, 23732 }, { 23737, 23738, 23739, 23740 }, { 23733, 23734, 23735, 23736 }, { 23798, 23799, 23800, 23801 }, { 23806, 23807, 23808, 23809 }, { 23774, 23775, 23776, 23777 }, { 23794, 23795, 23796, 23797 }, { 23802, 23803, 23804, 23805 }, { 23769, 23770, 23771, 23773 }, { 23790, 23791, 23792, 23793 }, { 23786, 23787, 23788, 23789 }, { 23761, 23762, 23763, 23764 }, { 23757, 23758, 23759, 23760 }, { 23765, 23766, 23767, 23768 }, { 23778, 23779, 23780, 23781 }, { 23810, 23811, 23812, 23813 }, { 23741, 23742, 23743, 23744 }, { 23782, 23783, 23784, 23785 }, { 23745, 23746, 23747, 23748 }, { 23814, 23815, 23816, 23817 }, { 23749, 23750, 23751, 23752 } }; public static final int[] OTHER_SELECTABLE_LAMPS = { 2528, 4447, 24151 }; // 2528:random event genie lamp, 4447: Shield Of Arrav Lamp private static final int[] DIALOGUE_INTERFACE_CS2 = { Skills.ATTACK, Skills.MAGIC, Skills.MINING, Skills.WOODCUTTING, Skills.AGILITY, Skills.FLETCHING, Skills.THIEVING, Skills.STRENGTH, Skills.RANGE, Skills.SMITHING, Skills.FIREMAKING, Skills.HERBLORE, Skills.SLAYER, Skills.CONSTRUCTION, Skills.DEFENSE, Skills.PRAYER, Skills.FISHING, Skills.CRAFTING, Skills.FARMING, Skills.HUNTER, Skills.SUMMONING, Skills.HITPOINTS, Skills.DUNGEONEERING, Skills.COOKING, Skills.RUNECRAFTING }; private static final double[] BASE_LAMPS_XP = { 62.5, 69, 77, 85, 94, 104, 115, 127, 139, 154, 170, 188, 206, 229, 252, 262, 274, 285, 298, 310, 325, 337, 352, 367.5, 384, 399, 405, 414, 453, 473, 514, 528, 536, 551, 583, 609, 635, 662, 692, 721, 752, 785, 818, 854, 890, 929, 971, 1013, 1055, 1101, 1149, 1200, 1250, 1305, 1362, 1422, 1485, 1542, 1617, 1685, 1758, 1836, 1912, 2004.5, 2085, 2172, 2269, 2379, 2471, 2593, 2693, 2810, 2947, 3082, 3214, 3339, 3496, 3648, 3793, 3980, 4166, 4348, 4522, 4762, 4919, 5150, 5376, 5593, 5923, 6122, 6452, 6615, 6929, 7236, 7533, 8065, 8348, 8602 }; public static void processLampClick(Player player, int slot, int id) { if (isSelectable(id)) openSelectableInterface(player, slot, id); else if (isSkillLamp(id)) openSkillDialog(player, slot, id); else if (isOtherSelectableLamp(id)) openSelectableInterface(player, slot, id); } private static void sendSelectedSkill(Player player) { if (player.getTempAttribs().getO(""lampInstance"") == null) return; Lamp lamp = player.getTempAttribs().getO(""lampInstance""); EnumDefinitions map = EnumDefinitions.getEnum(681); if (lamp.getSelectedSkill() == map.getDefaultIntValue()) { player.getPackets().sendVarc(1796, map.getDefaultIntValue()); return; } long key = map.getKeyForValue(lamp.getSelectedSkill()); player.getPackets().sendVarc(1796, (int) key); } private static int getLampsLevelReq(int id) { return switch (id) { case 4447 ->// Shield of Arrav 20; default -> 1; }; } public static void openSelectableInterface(Player player, int slot, int id) { Lamp lamp = new Lamp(id, slot, getLampsLevelReq(id)); Dialogue lampD = new Dialogue().addNext(new LampXPSelectStatement(lamp)); lampD.addNext(() -> { if (!player.getInventory().containsItem(lamp.getId(), 1)) { player.getTempAttribs().removeO(""lampInstance""); player.closeInterfaces(); return; } int lvl = player.getSkills().getLevelForXp(lamp.getSelectedSkill()); if (lvl < lamp.getReq())// makes unmet req skill xp unclickable return; player.getInventory().deleteItem(slot, new Item(lamp.getId(), 1)); double xpAmt = lamp.getXp() != 0 ? lamp.getXp() : getExp(player.getSkills().getLevelForXp(lamp.getSelectedSkill()), selectableLampType(lamp.getId())); if (lamp.getId() == 18782) { if (lvl < 30) xpAmt = (EnumDefinitions.getEnum(716).getIntValueAtIndex(lvl) - EnumDefinitions.getEnum(716).getIntValueAtIndex(lvl - 1)); else xpAmt = (Math.pow(lvl, 3) - 2 * Math.pow(lvl, 2) + 100 * lvl) / 20.0; } else if (lamp.getId() == 20960) xpAmt = (lvl * lvl) - (2 * lvl) + 100; else if (lamp.getId() == 2528 || lamp.getId() == 24151) xpAmt = player.getSkills().getLevelForXp(lamp.getSelectedSkill()) * 10; else if (lamp.getId() == 4447) xpAmt = 1000; double exp = player.getSkills().addXpLamp(lamp.getSelectedSkill(), xpAmt); player.sendMessage(""You have been awarded "" + Utils.getFormattedNumber(exp, ',') + "" XP in "" + Skills.SKILL_NAME[lamp.getSelectedSkill()] + ""!""); player.getTempAttribs().removeO(""lampInstance""); }); lampD.addNext(() -> player.getTempAttribs().removeO(""lampInstance"")); player.startConversation(lampD); player.setCloseInterfacesEvent(() -> player.getTempAttribs().removeO(""lampInstance"")); } public static ButtonClickHandler handleButtons = new ButtonClickHandler(1263, e -> { if (e.getPlayer().getTempAttribs().getO(""lampInstance"") == null) { e.getPlayer().closeInterfaces(); return; } Lamp lamp = e.getPlayer().getTempAttribs().getO(""lampInstance""); if (e.getComponentId() >= 13 && e.getComponentId() <= 37) { int skill = DIALOGUE_INTERFACE_CS2[e.getComponentId() - 13]; lamp.setSelectedSkill(skill); sendSelectedSkill(e.getPlayer()); } }); private static void openSkillDialog(Player player, final int slot, final int id) { final int type = skillLampType(id); final int skillId = skillLampSkillId(id); player.sendOptionDialogue(""Rub Lamp?"", ops -> { ops.add(""Gain "" + Skills.SKILL_NAME[skillId] + "" experience"", () -> { if (!player.containsItem(id)) return; player.getInventory().deleteItem(slot, new Item(id, 1)); double exp = player.getSkills().addXpLamp(skillId, getExp(player.getSkills().getLevelForXp(skillId), type)); player.simpleDialogue(""Your wish has been granted!"", ""You have been awarded "" + Utils.getFormattedNumber(exp, ',') + "" XP in "" + Skills.SKILL_NAME[skillId] + ""!""); }); ops.add(""Cancel""); }); } private static double getExp(int skillLevel, int lampType) { double xp; if (skillLevel <= BASE_LAMPS_XP.length) xp = BASE_LAMPS_XP[skillLevel - 1]; else xp = BASE_LAMPS_XP[BASE_LAMPS_XP.length - 1]; for (int i = 0; i < lampType; i++) xp *= 2D; return xp; } private static int selectableLampType(int id) { for (int i = 0; i < SELECTABLE_XP_LAMPS.length; i++) if (SELECTABLE_XP_LAMPS[i] == id) return SELECTABLE_XP_LAMPS_TYPES[i]; return -1; } public static boolean isSelectable(int id) { for (int element : SELECTABLE_XP_LAMPS) if (element == id) return true; return false; } private static int skillLampType(int id) { for (int[] skillLamp : SKILL_LAMPS) for (int i = 0; i < skillLamp.length; i++) if (skillLamp[i] == id) return LAMP_SMALL + i; return -1; } private static int skillLampSkillId(int id) { for (int skillId = 0; skillId < SKILL_LAMPS.length; skillId++) for (int i = 0; i < SKILL_LAMPS[skillId].length; i++) if (SKILL_LAMPS[skillId][i] == id) return skillId; return -1; } public static boolean isSkillLamp(int id) { for (int[] element : SKILL_LAMPS) for (int element2 : element) if (element2 == id) return true; return false; } public static boolean isOtherSelectableLamp(int id) { for (int element : OTHER_SELECTABLE_LAMPS) if (element == id) return true; return false; } }" "package com.rs.game.content.items; @PluginEventHandler public class LootInterface { public static ButtonClickHandler handleLootInterfaceButtons = new ButtonClickHandler(1284, e -> { ItemsContainer container = e.getPlayer().getTempAttribs().getO(""lootInterfaceContainer""); if (container == null) { e.getPlayer().getTempAttribs().removeO(""lootInterfaceContainer""); e.getPlayer().closeInterfaces(); e.getPlayer().sendMessage(""Loot interface container was null. Aborting.""); return; } if (e.getComponentId() == 7) { Item item = container.get(e.getSlotId()); if (item == null) return; switch (e.getPacket()) { case IF_OP1 -> { if (e.getPlayer().getInventory().addItem(item)) { container.set(e.getSlotId(), null); e.getPlayer().getPackets().sendUpdateItems(100, container, e.getSlotId()); } } case IF_OP2 -> { if (e.getPlayer().getBank().addItem(item, true)) { container.set(e.getSlotId(), null); e.getPlayer().getPackets().sendUpdateItems(100, container, e.getSlotId()); } } case IF_OP3 -> { container.set(e.getSlotId(), null); e.getPlayer().getPackets().sendUpdateItems(100, container, e.getSlotId()); } case IF_OP4 -> sendExamine(e.getPlayer(), item); } } else if (e.getComponentId() == 8) { for (int slot = 0;slot < container.getSize();slot++) { if (container.get(slot) == null) continue; if (e.getPlayer().getBank().addItem(container.get(slot), true)) container.set(slot, null); } if (!container.isEmpty()) e.getPlayer().getPackets().sendItems(100, container); } else if (e.getComponentId() == 9) { e.getPlayer().sendMessage(""You abandon all the items.""); container.clear(); } else if (e.getComponentId() == 10) { for (int slot = 0;slot < container.getSize();slot++) { if (container.get(slot) == null) continue; if (e.getPlayer().getInventory().addItemDrop(container.get(slot))) container.set(slot, null); } if (!container.isEmpty()) e.getPlayer().getPackets().sendItems(100, container); } if (container.isEmpty()) { e.getPlayer().sendMessage(""You've finished looting everything available.""); e.getPlayer().closeInterfaces(); } }); public static void open(String title, Player player, ItemsContainer container, Runnable onClose) { player.getPackets().setIFText(1284, 28, title); player.getInterfaceManager().sendInterface(1284); player.getPackets().sendInterSetItemsOptionsScript(1284, 7, 100, 7, 4, ""Take"", ""Bank"", ""Discard"", ""Examine""); player.getPackets().setIFRightClickOps(1284, 7, 0, 10, 0, 1, 2, 3); player.getPackets().sendItems(100, container); player.getTempAttribs().setO(""lootInterfaceContainer"", container); player.setCloseInterfacesEvent(() -> { player.getTempAttribs().removeO(""lootInterfaceContainer""); if (onClose != null) onClose.run(); for (Item item : container.toArray()) if (item != null) player.getInventory().addItemDrop(item); }); } public static void open(String title, Player player, ItemsContainer container) { open(title, player, container, null); } public static void sendExamine(Player player, Item item) { ItemDefinitions def = ItemDefinitions.getDefs(item.getId()); player.sendMessage(ItemConfig.get(item.getId()).getExamine(item) + (ItemConstants.isTradeable(item) ? ("" General store: "" + Utils.formatTypicalInteger(item.getDefinitions().getSellPrice()) + "" High Alchemy: "" + Utils.formatTypicalInteger(def.getHighAlchPrice())) : """")); if (item.getMetaData(""combatCharges"") != null) player.sendMessage(""It looks like it will last another "" + Utils.ticksToTime(item.getMetaDataI(""combatCharges""))); else if (item.getMetaData(""brawlerCharges"") != null) player.sendMessage(""These gloves have "" + item.getMetaDataI(""brawlerCharges"") + "" charges left.""); } }" "package com.rs.game.content.items; @PluginEventHandler public class Mindspike { public static ItemClickHandler changeElement = new ItemClickHandler(new Object[] { 23044, 23045, 23046, 23047 }, new String[] { ""Change element"" }, e -> { Dialogue selectElement = new Dialogue(new Statement() { @Override public void send(Player player) { player.getInterfaceManager().sendChatBoxInterface(1235); } @Override public int getOptionId(int componentId) { return switch(componentId) { case 2 -> 0; case 5 -> 1; case 8 -> 2; case 11 -> 3; default -> -1; }; } @Override public void close(Player player) { player.getInterfaceManager().closeChatBoxInterface(); } }); for (int itemId : new int[] { 23044, 23045, 23046, 23047 }) selectElement.addNext(() -> { e.getItem().setId(itemId); e.getPlayer().getInventory().refresh(e.getItem().getSlot()); }); e.getPlayer().startConversation(selectElement); }); }" "package com.rs.game.content.items; @PluginEventHandler public class PharaohSceptre { private static final int[] PHARAOHS_SCEPTRE = new int[] {9050, 9048, 9046, 9044}; private static final Tile JALSAVRAH = Tile.of(1968,4428,2); private static final Tile JALEUSTROPHOS = Tile.of(3340, 2828, 0); private static final Tile JALDRAOCHT = Tile.of(3232, 2895, 0); public static ItemClickHandler handlePharaohsSceptre = new ItemClickHandler(new Object[] { 9050, 9048, 9046, 9044 }, new String[] { ""Teleport"" }, e -> { if (e.getItem().getId() == PHARAOHS_SCEPTRE[0]){ e.getPlayer().sendMessage(""There are no charges remaining.""); } else { e.getPlayer().sendMessage(""Teleporting""); e.getPlayer().sendOptionDialogue(""Where would you like to go?"", ops -> { ops.add(""Jalsavrah"", () -> { Magic.sendTeleportSpell(e.getPlayer(), 12441, 12442, 2172, 2173, 0, 0, JALSAVRAH, 3, true, TeleType.ITEM, null); removeCharge(e.getItem(), e.getPlayer()); }); ops.add(""Jaleustrophos"", () -> { Magic.sendTeleportSpell(e.getPlayer(), 12441, 12442, 2172, 2173, 0, 0, JALEUSTROPHOS, 3, true, TeleType.ITEM, null); removeCharge(e.getItem(), e.getPlayer()); }); ops.add(""Jaldraocht"", () -> { Magic.sendTeleportSpell(e.getPlayer(), 12441, 12442, 2172, 2173, 0, 0, JALDRAOCHT, 3, true, TeleType.ITEM, null); removeCharge(e.getItem(), e.getPlayer()); }); ops.add(""Nowhere.""); }); } }); public static ItemOnItemHandler handleGoldenStatuette = new ItemOnItemHandler(PPArtefact.JEWELLED_GOLDEN.getArtefactId(), PHARAOHS_SCEPTRE, e -> { if(e.getItem2().getId() == PHARAOHS_SCEPTRE[3] || e.getItem2().getId() == PHARAOHS_SCEPTRE[2] || e.getItem2().getId() == PHARAOHS_SCEPTRE[1]) { e.getPlayer().sendMessage(""Your scepter is already charged""); } else { Item chargedSceptre = new Item(PHARAOHS_SCEPTRE[3]); Item GoldenStatuette = new Item(PPArtefact.JEWELLED_GOLDEN.getArtefactId()); int SceptreSlot = e.getItem2().getSlot(); e.getPlayer().getInventory().removeItems(GoldenStatuette); e.getPlayer().getInventory().getItems().set(SceptreSlot, chargedSceptre); e.getPlayer().getInventory().refresh(); e.getPlayer().sendMessage(""You recharge your sceptre with a jewelled golden statuette.""); } }); public static void removeCharge(Item item, Player player) { item.setId(item.getId()+2); player.getInventory().refresh(); } }" "package com.rs.game.content.items; @PluginEventHandler public class PVPRewards { public static ItemClickHandler handleBrags = new ItemClickHandler(new Object[] { 20795, 20796, 20797, 20798, 20799, 20800, 20801, 20802, 20803, 20804, 20805, 20806, }, new String[] { ""Brag"" }, e -> { switch (e.getItem().getId()) { case 20795 -> { e.getPlayer().setNextAnimation(new Animation(512)); e.getPlayer().setNextSpotAnim(new SpotAnim(91)); } case 20796 -> { e.getPlayer().setNextAnimation(new Animation(513)); e.getPlayer().setNextSpotAnim(new SpotAnim(91)); } case 20797 -> { e.getPlayer().setNextAnimation(new Animation(530)); e.getPlayer().setNextSpotAnim(new SpotAnim(91)); } case 20798 -> { e.getPlayer().setNextAnimation(new Animation(531)); e.getPlayer().setNextSpotAnim(new SpotAnim(92)); } case 20799 -> { e.getPlayer().setNextAnimation(new Animation(532)); e.getPlayer().setNextSpotAnim(new SpotAnim(92)); } case 20800 -> { e.getPlayer().setNextAnimation(new Animation(533)); e.getPlayer().setNextSpotAnim(new SpotAnim(92)); } case 20801 -> { e.getPlayer().setNextAnimation(new Animation(534)); e.getPlayer().setNextSpotAnim(new SpotAnim(121)); } case 20802 -> { e.getPlayer().setNextAnimation(new Animation(534)); e.getPlayer().setNextSpotAnim(new SpotAnim(121)); } case 20803 -> { e.getPlayer().setNextAnimation(new Animation(412)); e.getPlayer().setNextSpotAnim(new SpotAnim(121)); } case 20804 -> { e.getPlayer().setNextAnimation(new Animation(412)); e.getPlayer().setNextSpotAnim(new SpotAnim(121)); } case 20805 -> { e.getPlayer().setNextAnimation(new Animation(361)); e.getPlayer().setNextSpotAnim(new SpotAnim(122)); } case 20806 -> { e.getPlayer().setNextAnimation(new Animation(361)); e.getPlayer().setNextSpotAnim(new SpotAnim(122)); } } }); }" "package com.rs.game.content.items; public class ResourceLocators { /** * interface: 844 */ }" "package com.rs.game.content.items; @PluginEventHandler public class RoyalCrossbow { public static ItemClickHandler handleRCB = new ItemClickHandler(new Object[] { 24337, 24338, 24339 }, new String[] { ""Split"", ""Brandish"" }, e -> { Player player = e.getPlayer(); switch (e.getOption()) { case ""Split"" -> { if (player.getInventory().getFreeSlots() < 4) { player.sendMessage(""You don't have enough inventory space.""); return; } player.sendOptionDialogue(""Would you like to undo Thurgo's hard work and retrieve the parts back?"", ops -> { ops.add(""Yes, please."", () -> { player.getInventory().deleteItem(e.getItem().getId(), 1); player.getInventory().addItemDrop(24303, 1); player.getInventory().addItemDrop(24340, 1); player.getInventory().addItemDrop(24342, 1); player.getInventory().addItemDrop(24344, 1); player.getInventory().addItemDrop(24346, 1); player.sendMessage(""You disassemble the crossbow.""); }); ops.add(""No, thanks.""); }); } case ""Brandish"" -> { if (!player.getControllerManager().isIn(QueenBlackDragonController.class)) { player.sendMessage(""There isn't even close to enough heat here. Perhaps the Queen Black Dragon's breath would be hot enough.""); return; } if (!player.getTempAttribs().getB(""canBrandish"")) { player.sendMessage(""It doesn't seem like a good time to be doing that!""); return; } player.anim(16870); player.lock(5); WorldTasks.delay(4, player::resetReceivedHits); player.sendMessage(""You brandish the crossbow and it absorbs the dragon's extremely hot fire.""); e.getItem().setId(24338); e.getItem().deleteMetaData(); player.getEquipment().refresh(Equipment.WEAPON); player.getInventory().refresh(); } } }); }" "package com.rs.game.content.items; @PluginEventHandler public class Spade { public static ItemClickHandler digSpade = new ItemClickHandler(new Object[] { 952 }, new String[] { ""Dig"" }, e -> dig(e.getPlayer())); public static void dig(final Player player) { player.resetWalkSteps(); player.setNextAnimation(new Animation(830)); player.lock(); WorldTasks.schedule(() -> { player.unlock(); if (player.getTreasureTrailsManager().useDig(false) || BarrowsController.digIntoGrave(player)) return; if (player.getX() == 3005 && player.getY() == 3376 || player.getX() == 2999 && player.getY() == 3375 || player.getX() == 2996 && player.getY() == 3377 || player.getX() == 2989 && player.getY() == 3378 || player.getX() == 2987 && player.getY() == 3387 || player.getX() == 2984 && player.getY() == 3387) { // mole player.tele(Tile.of(1752, 5137, 0)); player.sendMessage(""You seem to have dropped down into a network of mole tunnels.""); return; } if (Utils.getDistance(player.getTile(), Tile.of(2749, 3734, 0)) < 3) { player.useStairs(-1, Tile.of(2690, 10124, 0), 0, 1); return; } //Pirate's Treasure if(player.getQuestManager().getStage(Quest.PIRATES_TREASURE) == PiratesTreasure.GET_TREASURE) PiratesTreasure.findTreasure(player); player.sendMessage(""You find nothing.""); }); } }" "package com.rs.game.content.items; @PluginEventHandler public class StaffPotato { private enum Command { GOD(""Toggle God"", p -> { p.setNextAnimation(new Animation(361)); p.setNextSpotAnim(new SpotAnim(122)); p.getNSV().setB(""godMode"", !p.getNSV().getB(""godMode"")); p.sendMessage(""GODMODE: "" + p.getNSV().getB(""godMode"")); }), INF_PRAY(""Toggle Infinite Prayer"", p -> { p.setNextAnimation(new Animation(412)); p.setNextSpotAnim(new SpotAnim(121)); p.getNSV().setB(""infPrayer"", !p.getNSV().getB(""infPrayer"")); p.sendMessage(""INFINITE PRAYER: "" + p.getNSV().getB(""infPrayer"")); }), INF_SPEC(""Toggle Infinite Spec"", p -> { p.getNSV().setB(""infSpecialAttack"", !p.getNSV().getB(""infSpecialAttack"")); p.sendMessage(""INFINITE SPECIAL ATTACK: "" + p.getNSV().getB(""infSpecialAttack"")); }), INF_RUN(""Toggle Infinite Run"", p -> { p.getNSV().setB(""infRun"", !p.getNSV().getB(""infRun"")); p.sendMessage(""INFINITE RUN: "" + p.getNSV().getB(""infRun"")); }), INF_RUNES(""Toggle Infinite Runes"", p -> { p.getNSV().setB(""infRunes"", !p.getNSV().getB(""infRunes"")); p.sendMessage(""INFINITE RUNES: "" + p.getNSV().getB(""infRunes"")); }), INVISIBILITY(""Toggle Invisibility"", p -> { p.getAppearance().setHidden(!p.getAppearance().isHidden()); p.sendMessage(""HIDDEN: "" + p.getAppearance().isHidden()); }), BANK_DROPS(""Send drops directly to bank until logout"", p -> p.getNSV().setB(""sendingDropsToBank"", true)), RESET_TASK(""Reset slayer task"", p -> { p.getSlayer().removeTask(); p.updateSlayerTask(); }), BANK(""Bank"", p -> p.getBank().open()), MAGE_BOOK(""Magic book"", p -> p.startConversation(new Dialogue().addOptions(o2 -> { o2.add(""Modern"", () -> p.getCombatDefinitions().setSpellbook(Spellbook.MODERN)); o2.add(""Ancient"", () -> p.getCombatDefinitions().setSpellbook(Spellbook.ANCIENT)); o2.add(""Lunar"", () -> p.getCombatDefinitions().setSpellbook(Spellbook.LUNAR)); o2.add(""Dungeoneering"", () -> p.getCombatDefinitions().setSpellbook(Spellbook.DUNGEONEERING)); }))), PRAY_BOOK(""Prayer book"", p -> p.startConversation(new Dialogue().addOptions(o2 -> { o2.add(""Modern"", () -> p.getPrayer().setPrayerBook(false)); o2.add(""Ancient curses"", () -> p.getPrayer().setPrayerBook(true)); }))), LOOT_BARROWS(""Loot a barrows chest"", p -> { if (p.getControllerManager().isIn(BarrowsController.class)) p.getControllerManager().getController(BarrowsController.class).cheat(); else p.sendMessage(""You're not at barrows.""); }), CLUES_TO_CASKETS(""Turn clue scroll boxes to caskets"", p -> { for (Item item : p.getInventory().getItems().array()) { if (item == null) continue; for (int i = 0;i < TreasureTrailsManager.SCROLL_BOXES.length;i++) { if (item.getId() == TreasureTrailsManager.SCROLL_BOXES[i]) item.setId(TreasureTrailsManager.CASKETS[i]); } p.getInventory().refresh(); } }), INSTA_FARM(""Instant grow all farm patches"", p -> { for (int i = 0;i < 200;i++) p.tickFarming(); }), NEVER_LOG(""Neverlog"", p -> p.getNSV().setB(""idleLogImmune"", true)), AGGRO_POT(""Aggro pot toggle"", p -> { if (p.hasEffect(Effect.AGGRESSION_POTION)) p.removeEffect(Effect.AGGRESSION_POTION); else p.addEffect(Effect.AGGRESSION_POTION, Ticks.fromHours(10)); p.sendMessage(""Aggression potion: "" + p.hasEffect(Effect.AGGRESSION_POTION)); }), NO_RANDOMS(""Stop randoms for session"", p -> p.getNSV().setL(""lastRandom"", World.getServerTicks() + Ticks.fromHours(300))); private final String name; private final Consumer action; Command(String name, Consumer action) { this.name = name; this.action = action; } } @SuppressWarnings(""deprecation"") public static ItemClickHandler handle = new ItemClickHandler(new Object[] { 5733 }, new String[] { ""Eat"", ""Heal"", ""CM-Tool"", ""Commands"", ""Drop"" }, e -> { switch(e.getOption()) { case ""Drop"" -> e.getPlayer().sendOptionDialogue(""Drop it? It will be destroyed."", ops -> { ops.add(""Yes, drop it."", () -> e.getPlayer().getInventory().deleteItem(e.getItem())); ops.add(""Nevermind.""); }); case ""Eat"" -> { if (!e.getPlayer().canEat()) return; e.getPlayer().incrementCount(""Food eaten""); e.getPlayer().setNextAnimation(Foods.EAT_ANIM); e.getPlayer().addFoodDelay(3); e.getPlayer().getActionManager().setActionDelay(e.getPlayer().getActionManager().getActionDelay() + 3); e.getPlayer().heal(280, 100); e.getPlayer().addEffect(Effect.OVERLOAD, Ticks.fromHours(10)); e.getPlayer().addEffect(Effect.BONFIRE, Ticks.fromHours(10)); e.getPlayer().addEffect(Effect.ANTIPOISON, Ticks.fromHours(10)); e.getPlayer().addEffect(Effect.SUPER_ANTIFIRE, Ticks.fromHours(10)); e.getPlayer().addEffect(Effect.JUJU_MINE_BANK, Ticks.fromHours(10)); e.getPlayer().addEffect(Effect.JUJU_WC_BANK, Ticks.fromHours(10)); e.getPlayer().addEffect(Effect.JUJU_FARMING, Ticks.fromHours(10)); e.getPlayer().addEffect(Effect.JUJU_HUNTER, Ticks.fromHours(10)); e.getPlayer().addEffect(Effect.JUJU_FISHING, Ticks.fromHours(10)); e.getPlayer().addEffect(Effect.REV_IMMUNE, Ticks.fromHours(10)); Potion.RECOVER_SPECIAL.getEffect().accept(e.getPlayer()); Potion.SUPER_RESTORE.getEffect().accept(e.getPlayer()); Potion.SUPER_ENERGY.getEffect().accept(e.getPlayer()); Potion.SUMMONING_POTION.getEffect().accept(e.getPlayer()); Potion.STRONG_ARTISANS_POTION.getEffect().accept(e.getPlayer()); Potion.STRONG_GATHERERS_POTION.getEffect().accept(e.getPlayer()); Potion.STRONG_NATURALISTS_POTION.getEffect().accept(e.getPlayer()); Potion.STRONG_SURVIVALISTS_POTION.getEffect().accept(e.getPlayer()); } case ""Heal"" -> { Command command = e.getPlayer().getNSV().getO(""lastPotatoCommand""); if (command != null) command.action.accept(e.getPlayer()); } case ""Commands"" -> e.getPlayer().startConversation(new Dialogue().addOptions(o1 -> { for (Command command : Command.values()) o1.add(command.name, () -> { command.action.accept(e.getPlayer()); e.getPlayer().getNSV().setO(""lastPotatoCommand"", command); }); })); case ""CM-Tool"" -> e.getPlayer().sendOptionDialogue(""What would you like to do?"", op -> { SimpleImmutableEntry lastLoc = e.getPlayer().getNSV().getO(""savedPotatoLoc""); if (lastLoc != null) op.add(""Teleport to saved location."", () -> { Magic.sendNormalTeleportSpell(e.getPlayer(), lastLoc.getKey(), () -> { if (lastLoc.getValue() != null) { e.getPlayer().getControllerManager().setController(lastLoc.getValue()); e.getPlayer().getControllerManager().sendInterfaces(); } }); }); op.add(""Save current location."", () -> { e.getPlayer().getNSV().setO(""savedPotatoLoc"", new SimpleImmutableEntry(Tile.of(e.getPlayer().getTile()), e.getPlayer().getControllerManager().getController())); e.getPlayer().sendMessage(""Location saved.""); }); }); } }); public static ItemClickHandler rub = new ItemClickHandler(new Object[] { 25357 }, new String[] { ""Rub"" }, e -> { boolean set = !e.getPlayer().getNSV().getB(""godMode""); e.getPlayer().getNSV().setB(""godMode"", set); e.getPlayer().getNSV().setB(""infSpecialAttack"", set); e.getPlayer().getNSV().setB(""infPrayer"", set); e.getPlayer().getNSV().setB(""infRun"", set); e.getPlayer().getNSV().setB(""infRunes"", set); e.getPlayer().anim(set ? 529 : 528); }); }" "package com.rs.game.content.items; @PluginEventHandler public class ToadLegs { public static ItemClickHandler pullLegs = new ItemClickHandler(new Object[] { 2150 }, e -> { e.getPlayer().getInventory().deleteItem(2150, 1); e.getPlayer().getInventory().addItem(2152, 1); e.getPlayer().sendMessage(""You pull the legs off the toad. At least they'll grow back...""); }); }" "package com.rs.game.content.items.combinations; @PluginEventHandler public class CombinationItems { private enum Combineable { CAP_AND_GOGGLES(9472, 9945, 9946), AMULET_OF_FURY_OR(6585, 19333, 19335), DRAGON_FULL_HELM_OR(11335, 19346, 19336), DRAGON_PLATEBODY_OR(14479, 19350, 19337), DRAGON_PLATELEGS_OR(4087, 19348, 19338), DRAGON_PLATESKIRT_OR(4585, 19348, 19339), DRAGON_SQUARE_SHIELD_OR(1187, 19352, 19340), DRAGON_FULL_HELM_SP(11335, 19354, 19341), DRAGON_PLATEBODY_SP(14479, 19358, 19342), DRAGON_PLATELEGS_SP(4087, 19356, 19343), DRAGON_PLATESKIRT_SP(4585, 19356, 19344), DRAGON_SQ_SHIELD_SP(1187, 19360, 19345), ABYSSAL_VINE_WHIP(4151, 21369, 21371), ABYSSAL_VINE_WHIP_YELLOW(15441, 21369, 21372), ABYSSAL_VINE_WHIP_BLUE(15442, 21369, 21373), ABYSSAL_VINE_WHIP_WHITE(15443, 21369, 21374), ABYSSAL_VINE_WHIP_GREEN(15444, 21369, 21375), DRAGONBONE_MAGE_HAT(6918, 24352, 24354), DRAGONBONE_MAGE_TOP(6916, 24352, 24355), DRAGONBONE_MAGE_BOTTOMS(6924, 24352, 24356), DRAGONBONE_MAGE_GLOVES(6922, 24352, 24357), DRAGONBONE_MAGE_BOOTS(6920, 24352, 24358), DRAGONBONE_FULL_HELM(11335, 24352, 24359), DRAGONBONE_PLATEBODY(14479, 24352, 24360), DRAGONBONE_GLOVES(13006, 24352, 24361), DRAGONBONE_BOOTS(11732, 24352, 24362), DRAGONBONE_PLATELEGS(4087, 24352, 24363), DRAGONBONE_PLATESKIRT(4585, 24352, 24364), DRAGON_KITESHIELD_OR(24365, 25312, 25320), DRAGON_KITESHIELD_SP(24365, 25314, 25321), ARMADYL_GODSWORD(11702, 11690, 11694), BANDOS_GODSWORD(11704, 11690, 11696), SARADOMIN_GODSWORD(11706, 11690, 11698), ZAMORAK_GODSWORD(11708, 11690, 11700), MAPLE_LONGBOW_SIGHTED(851, 18330, 18331), MAGIC_LONGBOW_SIGHTED(859, 18330, 18332), SKULL_SCEPTRE_SKULL(9007, 9008, 9009), SKULL_SCEPTRE_SCEPTRE(9010, 9011, 9012), SKULL_SCEPTRE_SKULL_SCEPTRE(9012, 9009, 9013), CRYSTAL_KEY(985, 987, 989); private static final Map BY_PRODUCT = new HashMap<>(); private static final Map BY_COMPONENT = new HashMap<>(); static { for (Combineable c : Combineable.values()) { BY_PRODUCT.put(c.resultId, c); BY_COMPONENT.put((c.item1 << 16) + c.item2, c); } } private final int item1; private final int item2; private final int resultId; Combineable(int item1, int item2, int resultId) { this.item1 = item1; this.item2 = item2; this.resultId = resultId; } } public static ItemOnItemHandler combine = new ItemOnItemHandler(true, Combineable.BY_COMPONENT.keySet().toArray(), e -> { Combineable combineable = Combineable.BY_COMPONENT.get((e.getItem1().getId() << 16) + e.getItem2().getId()); if (combineable == null) combineable = Combineable.BY_COMPONENT.get((e.getItem2().getId() << 16) + e.getItem1().getId()); if (combineable == null) return; e.getPlayer().getInventory().deleteItem(e.getItem1()); e.getPlayer().getInventory().deleteItem(e.getItem2()); e.getPlayer().getInventory().addItem(combineable.resultId, 1); }); public static ItemClickHandler split = new ItemClickHandler(Combineable.BY_PRODUCT.keySet().stream().filter(prod -> ItemDefinitions.getDefs(prod).containsOption(""Split"") || ItemDefinitions.getDefs(prod).containsOption(""Dismantle"")).toArray(), new String[] { ""Split"", ""Dismantle"" }, e -> { Combineable combineable = Combineable.BY_PRODUCT.get(e.getItem().getId()); if (combineable == null) return; if (!e.getPlayer().getInventory().hasFreeSlots()) { e.getPlayer().sendMessage(""You don't have enough inventory space.""); return; } e.getPlayer().getInventory().deleteItem(e.getItem()); e.getPlayer().getInventory().addItem(combineable.item1, 1); e.getPlayer().getInventory().addItem(combineable.item2, 1); }); /** * if (itemUsed == 21358 && usedWith == 21359 || usedWith == 21358 && itemUsed == 21359) { * if (player.getInventory().containsItem(21359, 2) && player.getSkills().getLevel(Constants.FLETCHING) >= 72) { * player.getInventory().deleteItem(21358, 1); * player.getInventory().deleteItem(21359, 2); // BOLAS * player.getInventory().addItem(21365, 1); * player.getSkills().addXp(Constants.FLETCHING, 25); * } else * player.sendMessage(""You need 2 excressence, 1 mutated vine, and 72 fletching to create bolas.""); * return true;* } * //spotanim 450 sagie */ }" "package com.rs.game.content.items.liquid_containers; @PluginEventHandler public class ClayWetting { private static final int CLAY = 434; private static final int SOFT_CLAY = 1761; private static final int JUG = 1937; private static final int BOWL = 1921; private static final int BUCKET = 1929; public static ItemOnItemHandler clayWet = new ItemOnItemHandler(CLAY, new int[] { JUG, BOWL, BUCKET }, e -> e.getPlayer().startConversation(new Dialogue() .addMakeX(SOFT_CLAY, e.getPlayer().getInventory().getAmountOf(CLAY)) .addNext(() -> e.getPlayer().repeatAction(0, tick -> { if (tick >= MakeXStatement.getQuantity(e.getPlayer())) return false; Item water = e.getPlayer().getInventory().findItemByIds(JUG, BOWL, BUCKET); Item clay = e.getPlayer().getInventory().findItemByIds(CLAY); if (water == null || clay == null) return false; Filler filler = Filler.forFull(water.getId()); if (filler == null) return false; clay.setId(SOFT_CLAY); water.setId(filler.getEmptyItem().getId()); e.getPlayer().getInventory().refresh(); return true; })))); }" "package com.rs.game.content.items.liquid_containers; @PluginEventHandler public class Empty { public static ItemClickHandler handleGenericEmpty = new ItemClickHandler(new String[] { ""Empty"" }, e -> { Filler fillable = Filler.forFull(e.getItem().getId()); if (fillable == null) return; e.getItem().setId(fillable.getEmptyItem().getId()); e.getPlayer().getInventory().refresh(e.getSlotId()); }); public static ItemClickHandler potEmpty = new ItemClickHandler(new Object[] { 1933, 7468, 7811, 14816}, new String[] { ""Empty"" }, e -> { e.getItem().setId(1931); e.getPlayer().getInventory().refresh(e.getItem().getSlot()); }); public static ItemClickHandler teaPotBrownEmpty = new ItemClickHandler(new Object[] { 7692, 7694, 7696, 7698, 7700 }, new String[] { ""Empty"" }, e -> { e.getItem().setId(7702); e.getPlayer().getInventory().refresh(e.getItem().getSlot()); }); public static ItemClickHandler teaPotWhiteEmpty = new ItemClickHandler(new Object[] { 7704, 7706, 7708, 7710, 7712 }, new String[] { ""Empty"" }, e -> { e.getItem().setId(7714); e.getPlayer().getInventory().refresh(e.getItem().getSlot()); }); public static ItemClickHandler teaPotGoldEmpty = new ItemClickHandler(new Object[] { 7716, 7718, 7720, 7722, 7724 }, new String[] { ""Empty"" }, e -> { e.getItem().setId(7726); e.getPlayer().getInventory().refresh(e.getItem().getSlot()); }); }" "package com.rs.game.content.items.liquid_containers; @PluginEventHandler public class FillAction extends PlayerAction { private int amount; private final Animation FILLING = new Animation(883); private final Filler fill; public static ItemOnObjectHandler handleFilling = new ItemOnObjectHandler(new Object[] { ""Waterpump"", ""Water pump"", ""Fountain"", ""Sink"", ""Well"", ""Pump"" }, Arrays.stream(Filler.values()).map(filler -> filler.getEmptyItem().getId()).toArray(), e -> { Player player = e.getPlayer(); Filler fill = FillAction.isFillable(e.getItem()); if (fill != null) player.startConversation(new Dialogue() .addNext(new MakeXStatement( new int[] { fill.getFilledItem().getId() }, player.getInventory().getAmountOf(fill.getEmptyItem().getId()))) .addNext(() -> player.getActionManager().setAction(new FillAction(MakeXStatement.getQuantity(player), fill)))); }); public enum Filler { //Empty Item, Full Item VIAL(new Item(229, 1), new Item(227, 1)), CLAY(new Item(434, 1), new Item(1761, 1)), BOWL(new Item(1923, 1), new Item(1921, 1)), BUCKET(new Item(1925, 1), new Item(1929, 1)), VASE(new Item(3734, 1), new Item(3735, 1)), JUJU_VIAL(new Item(19996, 1), new Item(19994, 1)), JUG(new Item(1935, 1), new Item(1937, 1)), WATERING_CAN(new Item(5331, 1), new Item(5340, 1)), WATERING_CAN1(new Item(5333, 1), new Item(5340, 1)), WATERING_CAN2(new Item(5334, 1), new Item(5340, 1)), WATERING_CAN3(new Item(5335, 1), new Item(5340, 1)), WATERING_CAN4(new Item(5336, 1), new Item(5340, 1)), WATERING_CAN5(new Item(5337, 1), new Item(5340, 1)), WATERING_CAN6(new Item(5338, 1), new Item(5340, 1)), WATERING_CAN7(new Item(5339, 1), new Item(5340, 1)), KETTLE(new Item(7688, 1), new Item(7690, 1)); private static final Map EMPTY = new HashMap<>(); private static final Map FULL = new HashMap<>(); public static Filler forEmpty(int itemId) { return EMPTY.get(itemId); } public static Filler forFull(int itemId) { return FULL.get(itemId); } static { for (Filler ingredient : Filler.values()) { EMPTY.put(ingredient.getEmptyItem().getId(), ingredient); FULL.put(ingredient.getFilledItem().getId(), ingredient); } } private final Item empty; private final Item filled; Filler(Item empty, Item filled) { this.empty = empty; this.filled = filled; } public Item getEmptyItem() { return empty; } public Item getFilledItem() { return filled; } } public static Filler isFillable(Item item) { return Filler.forEmpty((short) item.getId()); } public FillAction(int amount, Filler fil) { this.amount = amount; this.fill = fil; } @Override public boolean start(Player player) { player.sendMessage(""You start filling!"", true); return true; } @Override public boolean process(Player player) { return player.getInventory().containsItem(fill.getEmptyItem().getId(), 1); } @Override public int processWithDelay(Player player) { amount--; player.setNextAnimation(FILLING); player.getInventory().deleteItem(fill.getEmptyItem().getId(), 1); player.getInventory().addItem(fill.getFilledItem().getId(), 1); if (amount > 0) return 1; return -1; } @Override public void stop(Player player) { } }" "package com.rs.game.content.items.liquid_containers; @PluginEventHandler public class NettleTea { private static final int nettleTea = 4239; private static final int emptyPorcelainCup = 4244; private static final int cupOfNettleTea = 4245; private static final int emptyBowl = 1923; private static final int milkBucket = 1927; private static final int milkyNettleTea = 4246; private static final int emptyBucket = 1925; public static ItemOnItemHandler handleNettleTeaBowl = new ItemOnItemHandler(nettleTea, emptyPorcelainCup, e -> { if (!e.getPlayer().getInventory().containsItem(nettleTea, 1) && !e.getPlayer().getInventory().containsItem(emptyPorcelainCup, 1)) return; e.getItem1().setId(cupOfNettleTea); e.getItem2().setId(emptyBowl); e.getPlayer().getInventory().refresh(); }); public static ItemOnItemHandler handleMilkyNettleTea = new ItemOnItemHandler(cupOfNettleTea, milkBucket, e -> { if (!e.getPlayer().getInventory().containsItem(nettleTea, 1) && !e.getPlayer().getInventory().containsItem(milkBucket, 1)) return; e.getItem1().setId(milkyNettleTea); e.getItem2().setId(emptyBucket); e.getPlayer().getInventory().refresh(); }); }" "package com.rs.game.content.minigames val MINIGAME_SUPPLIES = arrayOf(12850, 12851, 4049, 4050, 18715, 18716, 18717, 18718, 22373, 22374, 22375, 22376, 22379, 22380) fun giveFoodAndPotions(player: Player) { checkAndDeleteFoodAndPotions(player) player.inventory.addItem(12850, 10000) player.inventory.addItem(12851, 10000) player.inventory.addItem(18715, 1) player.inventory.addItem(22373, 2) player.inventory.addItem(22379, 2) player.inventory.addItem(22375, 1) player.inventory.addItem(4049, player.inventory.freeSlots) } fun checkAndDeleteFoodAndPotions(player: Player) { player.inventory.items.array().forEach { item -> if (item != null && isMinigameSupply(item.id)) player.inventory.deleteItem(item) } } fun isMinigameSupply(id: Int): Boolean { return MINIGAME_SUPPLIES.any { it == id } }" "package com.rs.game.content.minigames.agilityarena; public final class BrimhavenAgilityController extends Controller { private static final List players = new ArrayList<>(); private static PlayingGame currentGame; private static BladesManager bladesManager; private static void removePlayer(Player player) { synchronized (players) { players.remove(player); if (player.getSize() == 0) cancelGame(); } player.getHintIconsManager().removeUnsavedHintIcon(); if (player.getTempAttribs().removeI(""BrimhavenAgility"") != -1) player.getVars().setVarBit(4456, 0); player.getInterfaceManager().removeOverlay(); } private void addPlayer(Player player) { synchronized (players) { players.add(player); if (players.size() == 1) startGame(); else PlayingGame.addIcon(player); } sendInterfaces(); } private static void startGame() { WorldTasks.scheduleLooping(currentGame = new PlayingGame(), 0, Ticks.fromMinutes(1)); WorldTasks.scheduleLooping(bladesManager = new BladesManager(), 9, 9); } private static void cancelGame() { currentGame.stop(); bladesManager.stop(); PlayingGame.taggedDispenser = null; currentGame = null; bladesManager = null; } private static class BladesManager extends Task { @Override public void run() { } } private static class PlayingGame extends Task { private static Tile taggedDispenser; private static Tile getNextDispenser() { while (true) { Tile tile = Tile.of(2761 + 11 * Utils.random(5), 9546 + 11 * Utils.random(5), 3); if (!(tile.getX() == 2805 && tile.getY() == 9590) && !(taggedDispenser != null && tile.equals(taggedDispenser))) return tile; } } private static void addIcon(Player player) { if (player.getTempAttribs().getI(""BrimhavenAgility"") == -1) { player.getTempAttribs().removeI(""BrimhavenAgility""); player.getVars().setVarBit(4456, 0); } else player.getTempAttribs().setI(""BrimhavenAgility"", -1); if (taggedDispenser == null) return; player.getHintIconsManager().addHintIcon(taggedDispenser.getX(), taggedDispenser.getY(), taggedDispenser.getPlane(), 65, 2, 0, -1, false); } @Override public void run() { // selects dispenser try { taggedDispenser = getNextDispenser(); synchronized (players) { for (Player player : players) addIcon(player); } } catch (Throwable e) { Logger.handle(PlayingGame.class, ""run"", e); } } } @Override public boolean processObjectClick1(final GameObject object) { if (object.getId() == 3581 || object.getId() == 3608) { if (PlayingGame.taggedDispenser == null || PlayingGame.taggedDispenser.getTileHash() != object.getTile().getTileHash()) return false; int stage = player.getTempAttribs().getI(""BrimhavenAgility""); if (stage == -1) { player.getTempAttribs().setI(""BrimhavenAgility"", 0); player.getVars().setVarBit(4456, 1); player.sendMessage(""You get tickets by tagging more than one pillar in a row. Tag the next pillar!""); } else if (stage == 0) player.sendMessage(""You have already tagged this pillar, wait until the arrow moves again.""); else { if (!player.getInventory().hasFreeSlots() && !player.getInventory().containsOneItem(2996)) { player.sendMessage(""Not enough space in your inventory.""); return false; } player.getTempAttribs().setI(""BrimhavenAgility"", 0); player.getInventory().addItem(2996, 1); } return false; } return true; } @Override public void start() { addPlayer(player); } @Override public boolean logout() { removePlayer(player); return false; } @Override public boolean login() { addPlayer(player); return false; // so doesnt remove script } @Override public void onTeleported(TeleType type) { removePlayer(player); removeController(); } @Override public void forceClose() { removePlayer(player); } @Override public boolean sendDeath() { removePlayer(player); removeController(); return true; } @Override public void sendInterfaces() { player.getInterfaceManager().sendOverlay(5); } }" "package com.rs.game.content.minigames.barrows; public final class BarrowsController extends Controller { private transient BarrowsBrother target; private transient BarrowsPuzzle puzzle; private boolean solvedPuzzle; public int removeDarkness; public int[] varBits = new int[20]; private static enum Hills { AHRIM_HILL(Tile.of(3564, 3287, 0), Tile.of(3557, 9703, 3)), DHAROK_HILL(Tile.of(3573, 3296, 0), Tile.of(3556, 9718, 3)), GUTHAN_HILL(Tile.of(3574, 3279, 0), Tile.of(3534, 9704, 3)), KARIL_HILL(Tile.of(3563, 3276, 0), Tile.of(3546, 9684, 3)), TORAG_HILL(Tile.of(3553, 3281, 0), Tile.of(3568, 9683, 3)), VERAC_HILL(Tile.of(3556, 3296, 0), Tile.of(3578, 9706, 3)); private final Tile outBound; private final Tile inside; private Hills(Tile outBound, Tile in) { this.outBound = outBound; inside = in; } } public static boolean digIntoGrave(final Player player) { for (Hills hill : Hills.values()) if (player.getPlane() == hill.outBound.getPlane() && player.getX() >= hill.outBound.getX() && player.getY() >= hill.outBound.getY() && player.getX() <= hill.outBound.getX() + 3 && player.getY() <= hill.outBound.getY() + 3) { player.useStairs(-1, hill.inside, 1, 2, ""You've broken into a crypt.""); WorldTasks.schedule(new Task() { @Override public void run() { player.getControllerManager().startController(new BarrowsController()); } }); return true; } return false; } @Override public boolean canAttack(Entity target) { if (target instanceof BarrowsBrother && target != this.target) { player.sendMessage(""This isn't your target.""); return false; } return true; } private void exit(Tile outside) { player.tele(outside); leave(false); } private void leave(boolean logout) { if (target != null) target.finish(); // target also calls removing hint icon at remove if (!logout) { player.getPackets().setBlockMinimapState(0); // unblacks minimap if (player.getHiddenBrother() == -1) player.getPackets().sendStopCameraShake(); else player.getInterfaceManager().removeOverlay(); removeController(); } } @Override public boolean sendDeath() { leave(false); return true; } @Override public void onTeleported(TeleType type) { leave(false); } public int getRandomBrother() { List bros = new ArrayList<>(); for (int i = 0; i < Hills.values().length; i++) { if (player.getKilledBarrowBrothers()[i] || player.getHiddenBrother() == i) continue; bros.add(i); } if (bros.isEmpty()) return -1; return bros.get(Utils.random(bros.size())); } private static final Drop[] AHRIM = { new Drop(4708, 1), new Drop(4710, 1), new Drop(4712, 1), new Drop(4714, 1) }; private static final Drop[] DHAROK = { new Drop(4716, 1), new Drop(4718, 1), new Drop(4720, 1), new Drop(4722, 1) }; private static final Drop[] GUTHAN = { new Drop(4724, 1), new Drop(4726, 1), new Drop(4728, 1), new Drop(4730, 1) }; private static final Drop[] KARIL = { new Drop(4732, 1), new Drop(4734, 1), new Drop(4736, 1), new Drop(4738, 1) }; private static final Drop[] TORAG = { new Drop(4745, 1), new Drop(4747, 1), new Drop(4749, 1), new Drop(4751, 1) }; private static final Drop[] VERAC = { new Drop(4753, 1), new Drop(4755, 1), new Drop(4757, 1), new Drop(4759, 1) }; private static final Drop[] AKRISAE = { new Drop(21736, 1), new Drop(21744, 1), new Drop(21752, 1), new Drop(21760, 1) }; private static final Drop[][] BROTHERS_LOOT = { AHRIM, DHAROK, GUTHAN, KARIL, TORAG, VERAC, AKRISAE }; public static Item[] getSimulatedDrop(int brothersKilled, int points) { ItemsContainer container = new ItemsContainer<>(points, false); if (points > 1012) points = 1012; List equipment = new ArrayList<>(); for (int i = 0;i < BROTHERS_LOOT.length-1;i++) equipment.addAll(Arrays.asList(BROTHERS_LOOT[i])); int rolls = Utils.clampI(brothersKilled+1, 1, 7); int equipmentChance = Utils.clampI(450 - (58 * brothersKilled), 73, 450); for (int i = 0;i < rolls;i++) { if (rollAdd(container, DropTable.calculateDrops(new DropSet(new DropTable(1, equipmentChance, equipment)))) || (points >= 381 && rollAdd(container, DropTable.calculateDrops(new DropSet(new DropTable(125, 1012, new Drop(558, 253, 336))))))) continue; if ((points >= 506 && rollAdd(container, DropTable.calculateDrops(new DropSet(new DropTable(125, 1012, new Drop(562, 112, 139)))))) || (points >= 631 && rollAdd(container, DropTable.calculateDrops(new DropSet(new DropTable(125, 1012, new Drop(560, 70, 83))))))) continue; if (points >= 756 && rollAdd(container, DropTable.calculateDrops(new DropSet(new DropTable(125, 1012, new Drop(565, 37, 43)))))) continue; if (points >= 881 && rollAdd(container, DropTable.calculateDrops(new DropSet(new DropTable(125, 1012, new Drop(4740, 35, 40)))))) continue; if (points >= 1006 && rollAdd(container, DropTable.calculateDrops(new DropSet(new DropTable(6, 1012, new Drop(985, 1), new Drop(987, 1)))))) continue; if (points >= 1012 && rollAdd(container, DropTable.calculateDrops(new DropSet(new DropTable(6, 1012, new Drop(1149, 1)))))) continue; rollAdd(container, DropTable.calculateDrops(new DropSet(new DropTable(995, 1, points)))); } for (Item i : container.array()) { if (i == null) continue; if (i.getId() >= 554 && i.getId() <= 566) i.setAmount(i.getAmount() * 2); } return container.getItemsNoNull(); } private static boolean rollAdd(ItemsContainer container, Item[] drops) { if (drops.length <= 0) return false; container.addAll(drops); return true; } public Item[] getRewards() { int points = 0; int brothersKilled = 0; ItemsContainer container = new ItemsContainer<>(20, false); List equipment = new ArrayList<>(); for (int i = 0;i < player.getKilledBarrowBrothers().length;i++) if (player.getKilledBarrowBrothers()[i]) { equipment.addAll(Arrays.asList(BROTHERS_LOOT[i])); brothersKilled++; points += 110; } points += player.getBarrowsKillCount() * 73; if (points > 1012) points = 1012; int rolls = Utils.clampI(brothersKilled+1, 1, 7); int equipmentChance = Utils.clampI(450 - (58 * brothersKilled), 73, 450); for (int i = 0;i < rolls;i++) { if ((player.getKilledBarrowBrothers()[i] && rollAdd(container, DropTable.calculateDrops(player, new DropSet(new DropTable(1, equipmentChance, equipment))))) || (points >= 381 && rollAdd(container, DropTable.calculateDrops(player, new DropSet(new DropTable(125, 1012, new Drop(558, 253, 336))))))) continue; if ((points >= 506 && rollAdd(container, DropTable.calculateDrops(player, new DropSet(new DropTable(125, 1012, new Drop(562, 112, 139)))))) || (points >= 631 && rollAdd(container, DropTable.calculateDrops(player, new DropSet(new DropTable(125, 1012, new Drop(560, 70, 83))))))) continue; if (points >= 756 && rollAdd(container, DropTable.calculateDrops(player, new DropSet(new DropTable(125, 1012, new Drop(565, 37, 43)))))) continue; if (points >= 881 && rollAdd(container, DropTable.calculateDrops(player, new DropSet(new DropTable(125, 1012, new Drop(4740, 35, 40)))))) continue; if (points >= 1006 && rollAdd(container, DropTable.calculateDrops(player, new DropSet(new DropTable(6, 1012, new Drop(985, 1), new Drop(987, 1)))))) continue; if (points >= 1012 && rollAdd(container, DropTable.calculateDrops(player, new DropSet(new DropTable(6, 1012, new Drop(1149, 1)))))) continue; rollAdd(container, DropTable.calculateDrops(player, new DropSet(new DropTable(995, 1, points)))); } if (SetReward.MORYTANIA_LEGS.hasRequirements(player, Area.MORYTANIA, Difficulty.HARD, false)) for (Item i : container.array()) { if (i == null) continue; if (i.getId() >= 554 && i.getId() <= 566) i.setAmount(i.getAmount() * 2); } player.sendMessage(""Your drop potential this chest was "" + Utils.formatNumber(points) + ""/1,012.""); return container.getItemsNoNull(); } public void sendReward() { Item[] rewards = getRewards(); if (rewards == null || rewards.length <= 0) return; for (Item item : rewards) { if (NPC.yellDrop(item.getId())) World.sendWorldMessage("""" + player.getDisplayName() + "" has just recieved "" + item.getName() + "" as drop from Barrows!"", false); player.incrementCount(ItemDefinitions.getDefs(item.getId()).getName()+"" drops earned"", item.getAmount()); } ItemsContainer container = new ItemsContainer<>(rewards.length, false); container.addAll(rewards); LootInterface.open(""Barrows Chest"", player, container); } @Override public boolean processButtonClick(int interfaceId, int componentId, int slotId, int slotId2, ClientPacket packet) { if (interfaceId == 25) { if (puzzle == null) return false; if (puzzle.isCorrect(componentId)) { solvedPuzzle = true; player.sendMessage(""You hear the mechanisms in the door click as they unlock.""); player.closeInterfaces(); } else { player.sendMessage(""That was incorrect! You hear a rumbling around you.""); player.closeInterfaces(); } return false; } return true; } @Override public boolean processObjectClick1(GameObject object) { if (object.getId() >= 6702 && object.getId() <= 6707) { Tile out = Hills.values()[object.getId() - 6702].outBound; exit(Tile.of(out.getX() + 1, out.getY() + 1, out.getPlane())); return false; } if (object.getId() >= 6709 && object.getId() <= 6712) { player.useLadder(Tile.of(3565, 3288, 0)); leave(false); } else if (object.getId() == 10284) { if (player.getHiddenBrother() == -1) { player.sendMessage(""You found nothing.""); return false; } if (!player.getKilledBarrowBrothers()[player.getHiddenBrother()]) sendTarget(2025 + player.getHiddenBrother(), Tile.of(player.getTile())); if (object.getDefinitions(player).getOption(1).equals(""Search"")) { player.incrementCount(""Barrows chests looted""); sendReward(); player.getPackets().sendCameraShake(3, 12, 25, 12, 25); player.getInterfaceManager().removeOverlay(); player.resetBarrows(); player.getVars().setVarBit(1394, 0); } else player.getVars().setVarBit(1394, 1); return false; } else if (object.getId() >= 6716 && object.getId() <= 6750) { switch(object.getId()) { case 6720: case 6724: case 6725: case 6727: case 6739: case 6743: case 6744: case 6746: if (!solvedPuzzle) { puzzle = new BarrowsPuzzle().display(player); return false; } break; default: break; } Doors.handleDoubleDoor(player, object); removeDarkness = (removeDarkness == 1 ? 0 : 1); player.getVars().setVar(1270, removeDarkness); if (Utils.random(10) == 0) WorldTasks.schedule(new Task() { @Override public void run() { if (player.getHiddenBrother() != -1) { int brother = getRandomBrother(); if (brother != -1) sendTarget(2025 + brother, Tile.of(player.getTile())); } } }, 0); return false; } else { int sarcoId = getSarcophagusId(object.getId()); if (sarcoId != -1) { if (sarcoId == player.getHiddenBrother()) player.startConversation(new Dialogue() .addSimple(""You've found a hidden tunnel, do you want to enter?"") .addOption(""Select an Option"", ""Yes, I'm fearless."", ""No way, that looks scary!"") .addNext(() -> { int spawn = Utils.random(4); ArrayList currentPath = BarrowsPath.generateBarrowsPath(spawn); BarrowsPath.updatePathDoors(player, currentPath); BarrowsPath.setSpawn(player, spawn); }).finish()); else if (target != null || player.getKilledBarrowBrothers()[sarcoId]) player.sendMessage(""You found nothing.""); else sendTarget(2025 + sarcoId, Tile.of(player.getTile())); return false; } } return true; } public int getSarcophagusId(int objectId) { return switch (objectId) { case 66017 -> 0; case 63177 -> 1; case 66020 -> 2; case 66018 -> 3; case 66019 -> 4; case 66016 -> 5; default -> -1; }; } public void targetDied() { player.getHintIconsManager().removeUnsavedHintIcon(); setBrotherSlained(target.getId() < 14297 ? target.getId() - 2025 : 6); target = null; } public void cheat() { setBrotherSlained(0); setBrotherSlained(1); setBrotherSlained(2); setBrotherSlained(3); setBrotherSlained(4); setBrotherSlained(5); player.setBarrowsKillCount(6); player.sendNPCKill(""Ahrim the Blighted""); player.sendNPCKill(""Dharok the Wretched""); player.sendNPCKill(""Guthan the Infested""); player.sendNPCKill(""Karil the Tainted""); player.sendNPCKill(""Torag the Corrupted""); player.sendNPCKill(""Verac the Defiled""); player.incrementCount(""Barrows chests looted""); sendReward(); player.resetBarrows(); player.getVars().setVarBit(1394, 0); } public void targetFinishedWithoutDie() { player.getHintIconsManager().removeUnsavedHintIcon(); target = null; } public void setBrotherSlained(int index) { player.getKilledBarrowBrothers()[index] = true; sendBrotherSlain(index, true); } public void sendTarget(int id, Tile tile) { if (target != null) target.disappear(); target = new BarrowsBrother(id, tile, this); target.setForceMultiArea(true); target.setTarget(player); target.setNextForceTalk(new ForceTalk(""You dare disturb my rest!"")); player.getHintIconsManager().addHintIcon(target, 1, -1, false); } public BarrowsController() { } private int headComponentId; private int timer; public int getAndIncreaseHeadIndex() { int head = player.getTempAttribs().removeI(""BarrowsHead""); if (head == -1 || head == player.getKilledBarrowBrothers().length - 1) head = 0; player.getTempAttribs().setI(""BarrowsHead"", head + 1); return player.getKilledBarrowBrothers()[head] ? head : -1; } @Override public void process() { if (timer > 0) { timer--; return; } if (headComponentId == 0) { if (player.getHiddenBrother() == -1) { player.applyHit(new Hit(player, Utils.random(50) + 1, HitLook.TRUE_DAMAGE)); resetHeadTimer(); return; } int headIndex = getAndIncreaseHeadIndex(); if (headIndex == -1) { resetHeadTimer(); return; } headComponentId = 9 + Utils.random(2); player.getPackets().setIFItem(24, headComponentId, 4761 + headIndex, 0); player.getPackets().setIFAnimation(9810, 24, headComponentId); double activeLevel = player.getPrayer().getPoints(); if (activeLevel > 0) { double level = player.getSkills().getLevelForXp(Constants.PRAYER) * 10; player.getPrayer().drainPrayer(level / 6.0); } timer = 3; } else { player.getPackets().setIFItem(24, headComponentId, -1, 0); headComponentId = 0; resetHeadTimer(); } } public void resetHeadTimer() { timer = 20 + Utils.random(6); } @Override public void sendInterfaces() { if (player.getHiddenBrother() != -1) player.getInterfaceManager().sendOverlay(24); } public void loadData() { resetHeadTimer(); for (int i = 0; i < player.getKilledBarrowBrothers().length; i++) sendBrotherSlain(i, player.getKilledBarrowBrothers()[i]); sendCreaturesSlainCount(player.getBarrowsKillCount()); player.getPackets().setBlockMinimapState(2); // blacks minimap } public void sendBrotherSlain(int index, boolean slain) { player.getVars().setVarBit(457 + index, slain ? 1 : 0); } public void sendCreaturesSlainCount(int count) { player.getVars().setVarBit(464, count+player.getKilledBarrowBrothersCount()); } public void savePathVars() { removeDarkness = player.getVars().getVar(1270); for (int i = 0; i<20; i++) varBits[i] = player.getVars().getVarBit(465+i); } public void loadPathVars() { player.getVars().setVar(1270, removeDarkness); if (varBits != null && (varBits.length == 20)) for (int i = 0; i<20; i++) player.getVars().setVarBit(465+i, varBits[i]); } public void resetPathVars() { varBits = new int[20]; } @Override public void start() { if (player.getHiddenBrother() == -1) player.setHiddenBrother(Utils.random(Hills.values().length)); loadData(); sendInterfaces(); } @Override public boolean login() { if (player.getHiddenBrother() == -1) player.getPackets().sendCameraShake(3, 12, 25, 12, 25); loadData(); sendInterfaces(); loadPathVars(); return false; } @Override public boolean logout() { leave(true); savePathVars(); return false; } @Override public void forceClose() { leave(true); } }" "package com.rs.game.content.minigames.barrows; public class BarrowsPath { private static BarrowsRoom[] corners; private static BarrowsRoom treasure; public final static int NORTHWEST_ROPE = 465, NORTHEAST_ROPE = 466, SOUTHWEST_ROPE = 467, SOUTHEAST_ROPE = 468; public static Object[][] DOORS = { {""NORTHWEST"", ""NORTHEAST"", 469}, {""NORTHWEST"", ""SOUTHWEST"", 470}, {""NORTHWEST"", ""WESTEDGE"", 471}, {""NORTHWEST"", ""NORTHEDGE"", 472}, {""NORTHEDGE"", ""CHEST"", 473}, {""NORTHEAST"", ""NORTHEDGE"", 474}, {""NORTHEAST"", ""EASTEEDGE"", 475}, {""NORTHEAST"", ""SOUTHEAST"", 476}, {""WESTEDGE"", ""CHEST"", 477}, {""EASTEDGE"", ""CHEST"", 478}, {""SOUTHWEST"", ""WESTEDGE"", 479}, {""SOUTHEDGE"", ""CHEST"", 480}, {""SOUTHEAST"", ""EASTEDGE"", 481}, {""SOUTHWEST"", ""SOUTHEDGE"", 482}, {""SOUTHEAST"", ""SOUTHEDGE"", 483}, {""SOUTHWEST"", ""SOUTHEAST"", 484}}; private static final java.util.Random random = new java.util.Random(System.currentTimeMillis()); public static void init() { BarrowsRoom topleft = new BarrowsRoom(RoomType.CORNER, ""NORTHWEST""); BarrowsRoom topright = new BarrowsRoom(RoomType.CORNER, ""NORTHEAST""); BarrowsRoom botleft = new BarrowsRoom(RoomType.CORNER, ""SOUTHWEST""); BarrowsRoom botright = new BarrowsRoom(RoomType.CORNER, ""SOUTHEAST""); BarrowsRoom topedge = new BarrowsRoom(RoomType.EDGE, ""NORTHEDGE""); BarrowsRoom leftedge = new BarrowsRoom(RoomType.EDGE, ""WESTEDGE""); BarrowsRoom rightedge = new BarrowsRoom(RoomType.EDGE, ""EASTEDGE""); BarrowsRoom botedge = new BarrowsRoom(RoomType.EDGE, ""SOUTHEDGE""); BarrowsRoom treasure = new BarrowsRoom(RoomType.TREASURE, ""CHEST""); topleft.addLink(topright); topleft.addLink(botleft); topleft.addLink(topedge); topleft.addLink(leftedge); topright.addLink(botright); topright.addLink(topedge); topright.addLink(rightedge); botright.addLink(botleft); botright.addLink(rightedge); botright.addLink(botedge); botleft.addLink(leftedge); botleft.addLink(botedge); treasure.addLink(topedge); treasure.addLink(rightedge); treasure.addLink(leftedge); treasure.addLink(botedge); corners = new BarrowsRoom[] { topleft, topright, botleft, botright }; BarrowsPath.treasure = treasure; } public static ArrayList generateBarrowsPath(int startIndex) { init(); ArrayList links = new ArrayList<>(); BarrowsRoom start = corners[startIndex]; ArrayList paths = start.getLinks(); paths.get(random.nextInt(4)).setState(RoomStatus.OPEN); for (Link l : paths) { links.add(l); l.setState(RoomStatus.CLOSED); } for (Link l : paths) { BarrowsRoom o = l.getOther(start); if (o.getType() == RoomType.EDGE) for (Link ll : o.getLinks()) { if (links.contains(ll)) continue; links.add(ll); if (ll.getOther(o).getType() == RoomType.CORNER) ll.setState(RoomStatus.OPEN); } } for (Link l : paths) { BarrowsRoom o = l.getOther(start); if (o.getType() == RoomType.CORNER) { ArrayList toCheck = new ArrayList<>(); for (Link ll : o.getLinks()) { if (links.contains(ll)) continue; links.add(ll); toCheck.add(ll); } for (Link l2 : toCheck) { BarrowsRoom o2 = l2.getOther(o); if (o2.getType() == RoomType.EDGE) for (Link lll : o2.getLinks()) { if (links.contains(lll)) continue; links.add(lll); if (lll.getOther(o2).getType() == RoomType.CORNER) lll.setState(RoomStatus.OPEN); } } toCheck.get(random.nextInt(2)).setState(RoomStatus.OPEN); for (Link s : toCheck) s.setState(RoomStatus.CLOSED); } } treasure.getLinks().get(random.nextInt(4)).setState(RoomStatus.OPEN); for (Link l : treasure.getLinks()) l.setState(RoomStatus.CLOSED); return links; } public static void updatePathDoors(Player p, ArrayList path) { for (Link l : path) for (Object[] element : DOORS) { String roomA = l.getRoomA().getName(); String roomB = l.getRoomB().getName(); if ((roomA == element[0] || roomA == element[1]) && (roomB == element[0] || roomB == element[1])) if (l.getState() == RoomStatus.OPEN) p.getVars().setVarBit((int)element[2], 0); else p.getVars().setVarBit((int)element[2], 1); } } public static void setSpawn(Player p, int spawn) { for (int i=0; i<4; i++) p.getVars().setVarBit((465+i),(i == spawn ? 1 : 0)); switch (spawn) { case 0: p.tele(Tile.of(3535, 9712, 0)); break; case 1: p.tele(Tile.of(3567, 9712, 0)); break; case 2: p.tele(Tile.of(3535, 9678, 0)); break; case 3: p.tele(Tile.of(3569, 9678, 0)); break; } } }" "package com.rs.game.content.minigames.barrows; @PluginEventHandler public class BarrowsPuzzle { private static final int BARROWS_PUZZLE_INTERFACE = 25; private static final int SEQUENCE_CHILD_START = 6; private static final int[] OPTIONS_COMPS = { 2, 3, 5 }; private final BarrowsPuzzleType puzzle; private final int[] shuffledOptions; public BarrowsPuzzle() { puzzle = BarrowsPuzzleType.values()[Utils.random(BarrowsPuzzleType.values().length)]; shuffledOptions = Utils.shuffleIntArray(puzzle.getOptions()); } public BarrowsPuzzle display(Player player) { for (int i = 0; i < 3; i++) { int sequenceModel = puzzle.getSequenceModel(i); player.getPackets().setIFModel(BARROWS_PUZZLE_INTERFACE, SEQUENCE_CHILD_START + i, sequenceModel); int optionModel = shuffledOptions[i]; player.getPackets().setIFModel(BARROWS_PUZZLE_INTERFACE, OPTIONS_COMPS[i], optionModel); } player.getInterfaceManager().sendInterface(BARROWS_PUZZLE_INTERFACE); return this; } public boolean isCorrect(int componentId) { int idx = 0; for (int i = 0;i < OPTIONS_COMPS.length;i++) if (OPTIONS_COMPS[i] == componentId) { idx = i; break; } return shuffledOptions[idx] == puzzle.getAnswer(); } }" "package com.rs.game.content.minigames.barrows; public enum BarrowsPuzzleType { ARROWS(6713, new int[] { 6716, 6717, 6718 }, new int[] { 6713, 6714, 6715 }), SQUARES(6719, new int[] { 6722, 6723, 6724 }, new int[] { 6719, 6720, 6721 }), SQUARES_OFFSET(6725, new int[] { 6728, 6729, 6730 }, new int[] { 6725, 6726, 6727 }), SHAPES(6731, new int[] { 6734, 6735, 6736 }, new int[] { 6731, 6732, 6733 }); private final int answer; private final int[] sequence; private final int[] options; private BarrowsPuzzleType(int answer, int[] sequence, int[] options) { this.answer = answer; this.sequence = sequence; this.options = options; } public int getAnswer() { return answer; } public int getSequenceModel(int index) { return sequence[index]; } public int[] getSequence() { return sequence; } public int[] getOptions() { return options; } }" "package com.rs.game.content.minigames.barrows; public class BarrowsRoom { public enum RoomType { CORNER, EDGE, TREASURE; } protected ArrayList links; private final RoomType type; private final String name; public BarrowsRoom(RoomType type, String name) { this.name = name; this.type = type; links = new ArrayList<>(); } public String getName() { return name; } public RoomType getType() { return type; } public ArrayList getLinks() { return links; } public void addLink(BarrowsRoom roomB) { Link roomLink = new Link(this, roomB); links.add(roomLink); roomB.links.add(roomLink); } }" "package com.rs.game.content.minigames.barrows; public class Link { public enum RoomStatus { CLOSED, OPEN, UNDETERMINED; } private final BarrowsRoom roomA; private final BarrowsRoom roomB; private RoomStatus state; public Link(BarrowsRoom a, BarrowsRoom b) { roomA = a; roomB = b; state = RoomStatus.UNDETERMINED; } public BarrowsRoom getOther(BarrowsRoom current) { return (current == roomA ? roomB : roomA); } public BarrowsRoom getRoomA() { return roomA; } public BarrowsRoom getRoomB() { return roomB; } public RoomStatus getState() { return state; } public void setState(RoomStatus state) { if (this.state == RoomStatus.UNDETERMINED) this.state = state; } @Override public String toString() { return ""Room "" + roomA.getName() + "" to Room "" + roomB.getName() + "" = "" + getState(); } }" "package com.rs.game.content.minigames.barrows.npcs; public class AhrimCombat extends CombatScript { @Override public Object[] getKeys() { return new Object[] { 2025 }; } @Override public int attack(NPC npc, Entity target) { final NPCCombatDefinitions defs = npc.getCombatDefinitions(); npc.setNextAnimation(new Animation(defs.getAttackEmote())); int damage = getMaxHit(npc, defs.getMaxHit(), AttackStyle.MAGE, target); if (damage != 0 && target instanceof Player player && Utils.random(3) == 0) { target.setNextSpotAnim(new SpotAnim(400, 0, 100)); int currentLevel = player.getSkills().getLevel(Constants.STRENGTH); player.getSkills().set(Constants.STRENGTH, currentLevel < 5 ? 0 : currentLevel - 5); } World.sendProjectile(npc, target, defs.getAttackProjectile(), 41, 16, 41, 35, 16, 0); npc.setNextSpotAnim(new SpotAnim(defs.getAttackGfx())); delayHit(npc, 2, target, getMagicHit(npc, damage)); return npc.getAttackSpeed(); } }" "package com.rs.game.content.minigames.barrows.npcs; public class BarrowsBrother extends OwnedNPC { private BarrowsController barrows; public BarrowsBrother(int id, Tile tile, BarrowsController barrows) { super(barrows.getPlayer(), id, tile, false); this.barrows = barrows; setIntelligentRouteFinder(true); } @Override public void sendDeath(Entity source) { if (barrows != null) { barrows.targetDied(); barrows = null; } super.sendDeath(source); } @Override public double getMeleePrayerMultiplier() { return getId() != 2030 ? 0 : Utils.random(3) == 0 ? 1 : 0; } @Override public void handlePreHitOut(Entity target, Hit hit) { super.handlePreHitOut(target, hit); if (getId() == 2027 && hit.getDamage() > 0 && Utils.random(4) == 0) { target.setNextSpotAnim(new SpotAnim(398)); heal(hit.getDamage()); } } public void disappear() { barrows = null; finish(); } @Override public void finish() { if (hasFinished()) return; if (barrows != null) { barrows.targetFinishedWithoutDie(); barrows = null; } super.finish(); } @Override public List getPossibleTargets() { List owners = new ArrayList<>(); Player owner = getOwner(); if (owner != null) owners.add(owner); return owners; } }" "package com.rs.game.content.minigames.barrows.npcs; public class DharokCombat extends CombatScript { @Override public Object[] getKeys() { return new Object[] { 2026 }; } @Override public int attack(NPC npc, Entity target) { final NPCCombatDefinitions defs = npc.getCombatDefinitions(); npc.setNextAnimation(new Animation(defs.getAttackEmote())); int damage = getMaxHit(npc, defs.getMaxHit(), AttackStyle.MELEE, target); if (damage != 0) { double perc = 1 - ((double) npc.getHitpoints() / npc.getMaxHitpoints()); damage += perc * 380; } delayHit(npc, 0, target, getMeleeHit(npc, damage)); return npc.getAttackSpeed(); } }" "package com.rs.game.content.minigames.barrows.npcs; public class GuthanCombat extends CombatScript { @Override public Object[] getKeys() { return new Object[] { 2027 }; } @Override public int attack(NPC npc, Entity target) { final NPCCombatDefinitions defs = npc.getCombatDefinitions(); npc.setNextAnimation(new Animation(defs.getAttackEmote())); delayHit(npc, 0, target, getMeleeHit(npc, getMaxHit(npc, defs.getMaxHit(), AttackStyle.MELEE, target))); return npc.getAttackSpeed(); } }" "package com.rs.game.content.minigames.barrows.npcs; public class KarilCombat extends CombatScript { @Override public Object[] getKeys() { return new Object[] { 2028 }; } @Override public int attack(NPC npc, Entity target) { final NPCCombatDefinitions defs = npc.getCombatDefinitions(); npc.setNextAnimation(new Animation(defs.getAttackEmote())); int damage = getMaxHit(npc, defs.getMaxHit(), AttackStyle.RANGE, target); if (damage != 0 && target instanceof Player player && Utils.random(3) == 0) { target.setNextSpotAnim(new SpotAnim(401, 0, 100)); int drain = (int) (player.getSkills().getLevelForXp(Constants.AGILITY) * 0.2); int currentLevel = player.getSkills().getLevel(Constants.AGILITY); player.getSkills().set(Constants.AGILITY, currentLevel < drain ? 0 : currentLevel - drain); } World.sendProjectile(npc, target, defs.getAttackProjectile(), 41, 16, 41, 35, 16, 0); delayHit(npc, 2, target, getRangeHit(npc, damage)); return npc.getAttackSpeed(); } }" "package com.rs.game.content.minigames.barrows.npcs; public class ToragCombat extends CombatScript { @Override public Object[] getKeys() { return new Object[] { 2029 }; } @Override public int attack(NPC npc, Entity target) { final NPCCombatDefinitions defs = npc.getCombatDefinitions(); npc.setNextAnimation(new Animation(defs.getAttackEmote())); int damage = getMaxHit(npc, defs.getMaxHit(), AttackStyle.MELEE, target); if (damage != 0 && target instanceof Player player && Utils.random(3) == 0) { target.setNextSpotAnim(new SpotAnim(399)); player.setRunEnergy(player.getRunEnergy() > 4 ? player.getRunEnergy() - 4 : 0); } delayHit(npc, 0, target, getMeleeHit(npc, damage)); return npc.getAttackSpeed(); } }" "package com.rs.game.content.minigames.castlewars; public class BarricadeCombat extends CombatScript { @Override public Object[] getKeys() { // TODO Auto-generated method stub return new Object[] { ""Barricade"" }; } /* * empty */ @Override public int attack(NPC npc, Entity target) { return 0; } }" "package com.rs.game.content.minigames.castlewars; public class CastleWarBarricade extends NPC { private final int team; public CastleWarBarricade(int team, Tile tile) { super(1532, tile, true); setCantFollowUnderCombat(true); this.team = team; } @Override public void processNPC() { if (isDead()) return; cancelFaceEntityNoCheck(); if (getId() == 1533 && Utils.getRandomInclusive(20) == 0) sendDeath(this); } public void litFire() { transformIntoNPC(1533); sendDeath(this); } public void explode() { // TODO gfx sendDeath(this); } @Override public void sendDeath(Entity killer) { resetWalkSteps(); getCombat().removeTarget(); if (getId() != 1533) { setNextAnimation(null); reset(); setLocation(getRespawnTile()); finish(); } else super.sendDeath(killer); CastleWars.removeBarricade(team, this); } }" "package com.rs.game.content.minigames.castlewars; @PluginEventHandler public final class CastleWars { public static final int CW_TICKET = 4067; public static final int SARADOMIN = 0; public static final int ZAMORAK = 1; private static final int GUTHIX = 2; @SuppressWarnings(""unchecked"") private static final List[] waiting = new List[2]; @SuppressWarnings(""unchecked"") private static final List[] playing = new List[2]; private static final int[] seasonWins = new int[2]; public static final Tile LOBBY = Tile.of(2442, 3090, 0), SARA_WAITING = Tile.of(2381, 9489, 0), ZAMO_WAITING = Tile.of(2421, 9523, 0), SARA_BASE = Tile.of(2426, 3076, 1), ZAMO_BASE = Tile.of(2373, 3131, 1); private static PlayingGame playingGame; static { init(); } public static void init() { for (int i = 0; i < waiting.length; i++) waiting[i] = Collections.synchronizedList(new LinkedList<>()); for (int i = 0; i < playing.length; i++) playing[i] = Collections.synchronizedList(new LinkedList<>()); } public static void viewScoreBoard(Player player) { player.getInterfaceManager().sendChatBoxInterface(55); player.getPackets().setIFText(55, 1, ""Saradomin: "" + seasonWins[SARADOMIN]); player.getPackets().setIFText(55, 2, ""Zamorak: "" + seasonWins[ZAMORAK]); } public static int getPowerfullestTeam() { int zamorak = waiting[ZAMORAK].size() + playing[ZAMORAK].size(); int saradomin = waiting[SARADOMIN].size() + playing[SARADOMIN].size(); if (saradomin == zamorak) return GUTHIX; if (zamorak > saradomin) return ZAMORAK; return SARADOMIN; } public static void joinPortal(Player player, int team) { if (player.getEquipment().getHatId() != -1 || player.getEquipment().getCapeId() != -1) { player.sendMessage(""You cannot wear hats, capes or helms in the arena.""); return; } for (Item item : player.getInventory().getItems().array()) { if (item == null) continue; if (Food.forId(item.getId()) != null) { player.sendMessage(""You cannot bring food into the arena.""); return; } } int powerfullestTeam = getPowerfullestTeam(); if (team == GUTHIX) team = powerfullestTeam == ZAMORAK ? SARADOMIN : ZAMORAK; else if (team == powerfullestTeam) { if (team == ZAMORAK) player.sendMessage(""The Zamorak team is powerful enough already! Guthix demands balance - join the Saradomin team instead!""); else if (team == SARADOMIN) player.sendMessage(""The Saradomin team is powerful enough already! Guthix demands balance - join the Zamorak team instead!""); return; } player.lock(2); waiting[team].add(player); setCape(player, new Item(team == ZAMORAK ? 4042 : 4041)); setHood(player, new Item(team == ZAMORAK ? 4515 : 4513)); player.getControllerManager().startController(new CastleWarsWaitingController(team)); player.tele(Tile.of(team == ZAMORAK ? ZAMO_WAITING : SARA_WAITING, 1)); player.getMusicsManager().playSongAndUnlock(318); // 5 players to start a game if (playingGame == null && waiting[team].size() >= 5) createPlayingGame(); else refreshTimeLeft(player); // You cannot take non-combat items into the arena } public static void setHood(Player player, Item hood) { player.getEquipment().setSlot(Equipment.HEAD, hood); player.getEquipment().refresh(Equipment.HEAD); player.getAppearance().generateAppearanceData(); } public static void setCape(Player player, Item cape) { player.getEquipment().setSlot(Equipment.CAPE, cape); player.getEquipment().refresh(Equipment.CAPE); player.getAppearance().generateAppearanceData(); } public static void setWeapon(Player player, Item weapon) { player.getEquipment().setSlot(Equipment.WEAPON, weapon); player.getEquipment().refresh(Equipment.WEAPON); player.getAppearance().generateAppearanceData(); } public static void createPlayingGame() { playingGame = new PlayingGame(); WorldTasks.scheduleLooping(playingGame, Ticks.fromMinutes(1), Ticks.fromMinutes(1)); refreshAllPlayersTime(); } public static void destroyPlayingGame() { playingGame.stop(); playingGame = null; refreshAllPlayersTime(); leavePlayersSafely(); } public static void leavePlayersSafely() { leavePlayersSafely(-1); } public static void leavePlayersSafely(final int winner) { for (List element : playing) for (final Player player : element) { player.lock(7); player.stopAll(); } WorldTasks.schedule(new Task() { @Override public void run() { for (int i = 0; i < playing.length; i++) for (Player player : playing[i].toArray(new Player[0])) { forceRemovePlayingPlayer(player); if (winner != -1) if (winner == -2) { player.sendMessage(""You draw.""); player.getInventory().addItem(CW_TICKET, 1); } else if (winner == i) { player.sendMessage(""You won.""); player.getInventory().addItem(CW_TICKET, 2); } else player.sendMessage(""You lost.""); } } }, 6); } // unused public static void forceRemoveWaitingPlayer(Player player) { player.getControllerManager().forceStop(); } public static void removeWaitingPlayer(Player player, int team) { waiting[team].remove(player); setCape(player, null); setHood(player, null); player.tele(Tile.of(LOBBY, 2)); if (playingGame != null && waiting[team].size() == 0 && playing[team].size() == 0) destroyPlayingGame(); // cancels if 0 players playing/waiting on any // of the tea } public static void refreshTimeLeft(Player player) { player.getVars().setVar(380, playingGame == null ? 0 : playingGame.minutesLeft - (player.getControllerManager().getController() instanceof CastleWarsPlayingController ? 5 : 0)); } public static void startGame() { for (int i = 0; i < waiting.length; i++) for (Player player : waiting[i].toArray(new Player[0])) joinPlayingGame(player, i); } public static void forceRemovePlayingPlayer(Player player) { player.getControllerManager().forceStop(); } public static void removePlayingPlayer(Player player, int team) { playing[team].remove(player); player.reset(); player.setCanPvp(false); // remove the items setCape(player, null); setHood(player, null); int weaponId = player.getEquipment().getWeaponId(); if (weaponId == 4037 || weaponId == 4039) { CastleWars.setWeapon(player, null); CastleWars.dropFlag(player.getLastTile(), weaponId == 4037 ? CastleWars.SARADOMIN : CastleWars.ZAMORAK); } player.closeInterfaces(); player.getInventory().deleteItem(4049, Integer.MAX_VALUE); // bandages player.getInventory().deleteItem(4053, Integer.MAX_VALUE); // barricades player.getHintIconsManager().removeUnsavedHintIcon(); player.getMusicsManager().reset(); player.tele(Tile.of(LOBBY, 2)); if (playingGame != null && waiting[team].size() == 0 && playing[team].size() == 0) destroyPlayingGame(); // cancels if 0 players playing/waiting on any // of the tea } public static void joinPlayingGame(Player player, int team) { playingGame.refresh(player); waiting[team].remove(player); player.getControllerManager().removeControllerWithoutCheck(); player.getInterfaceManager().removeOverlay(); playing[team].add(player); player.setCanPvp(true); player.getControllerManager().startController(new CastleWarsPlayingController(team)); player.tele(Tile.of(team == ZAMORAK ? ZAMO_BASE : SARA_BASE, 1)); } public static void endGame(int winner) { if (winner != -2) seasonWins[winner]++; leavePlayersSafely(winner); } public static void refreshAllPlayersTime() { for (List element : waiting) for (Player player : element) refreshTimeLeft(player); for (int i = 0; i < playing.length; i++) for (Player player : playing[i]) { player.getMusicsManager().playSongAndUnlock(i == ZAMORAK ? 845 : 314); refreshTimeLeft(player); } } public static void refreshAllPlayersPlaying() { for (List element : playing) for (Player player : element) playingGame.refresh(player); } public static void addHintIcon(int team, Player target) { for (Player player : playing[team]) player.getHintIconsManager().addHintIcon(target, 0, -1, false); } public static void removeHintIcon(int team) { for (Player player : playing[team]) player.getHintIconsManager().removeUnsavedHintIcon(); } public static void addScore(Player player, int team, int flagTeam) { if (playingGame == null) return; playingGame.addScore(player, team, flagTeam); } public static void takeFlag(Player player, int team, int flagTeam, GameObject object, boolean droped) { if (playingGame == null) return; playingGame.takeFlag(player, team, flagTeam, object, droped); } public static void dropFlag(Tile tile, int flagTeam) { if (playingGame == null) return; playingGame.dropFlag(tile, flagTeam); } public static void removeBarricade(int team, CastleWarBarricade npc) { if (playingGame == null) return; playingGame.removeBarricade(team, npc); } public static void addBarricade(int team, Player player) { if (playingGame == null) return; playingGame.addBarricade(team, player); } public static boolean isBarricadeAt(Tile tile) { if (playingGame == null) return false; return playingGame.isBarricadeAt(tile); } private static class PlayingGame extends Task { private static final int SAFE = 0, TAKEN = 1, DROPPED = 2; private int minutesLeft; private int[] score; private int[] flagStatus; private int[] barricadesCount; private final LinkedList spawnedObjects = new LinkedList<>(); private final LinkedList barricades = new LinkedList<>(); public PlayingGame() { reset(); } public void reset() { minutesLeft = 5; // temp testing else 5 score = new int[2]; flagStatus = new int[2]; barricadesCount = new int[2]; for (GameObject object : spawnedObjects) World.removeObject(object); spawnedObjects.clear(); for (CastleWarBarricade npc : barricades) npc.finish(); barricades.clear(); } public boolean isBarricadeAt(Tile tile) { for (Iterator it = barricades.iterator(); it.hasNext();) { CastleWarBarricade npc = it.next(); if (npc.isDead() || npc.hasFinished()) { it.remove(); continue; } if (npc.getX() == tile.getX() && npc.getY() == tile.getY() && tile.getPlane() == tile.getPlane()) return true; } return false; } public void addBarricade(int team, Player player) { if (barricadesCount[team] >= 10) { player.sendMessage(""Each team in the activity can have a maximum of 10 barricades set up.""); return; } player.getInventory().deleteItem(new Item(4053, 1)); barricadesCount[team]++; barricades.add(new CastleWarBarricade(team, Tile.of(player.getTile()))); } public void removeBarricade(int team, CastleWarBarricade npc) { barricadesCount[team]--; barricades.remove(npc); } public void takeFlag(Player player, int team, int flagTeam, GameObject object, boolean droped) { if ((!droped && team == flagTeam) || (droped && flagStatus[flagTeam] != DROPPED)) return; if (!droped && flagStatus[flagTeam] != SAFE) return; if (flagTeam != team && (player.getEquipment().getWeaponId() != -1 || player.getEquipment().getShieldId() != -1)) { // TODO no space message player.sendMessage(""You can't take flag while wearing something in your hands.""); return; } if (!droped) { GameObject flagStand = new GameObject(flagTeam == SARADOMIN ? 4377 : 4378, object.getType(), object.getRotation(), object.getX(), object.getY(), object.getPlane()); spawnedObjects.add(flagStand); World.spawnObject(flagStand); } else { spawnedObjects.remove(object); World.removeObject(object); if (flagTeam == team) { makeSafe(flagTeam); return; } } addHintIcon(flagTeam, player); flagStatus[flagTeam] = TAKEN; setWeapon(player, new Item(flagTeam == SARADOMIN ? 4037 : 4039, 1)); refreshAllPlayersPlaying(); } public void addScore(Player player, int team, int flagTeam) { setWeapon(player, null); score[team] += 1; makeSafe(flagTeam); } private void makeSafe(int flagTeam) { GameObject flagStand = null; for (GameObject object : spawnedObjects) if (object.getId() == (flagTeam == SARADOMIN ? 4377 : 4378)) { flagStand = object; break; } if (flagStand == null) return; World.removeObject(flagStand); flagStatus[flagTeam] = SAFE; refreshAllPlayersPlaying(); } public void dropFlag(Tile tile, int flagTeam) { removeHintIcon(flagTeam); GameObject flagDroped = new GameObject(flagTeam == SARADOMIN ? 4900 : 4901, ObjectType.SCENERY_INTERACT, 0, tile.getX(), tile.getY(), tile.getPlane()); spawnedObjects.add(flagDroped); World.spawnObject(flagDroped); flagStatus[flagTeam] = DROPPED; refreshAllPlayersPlaying(); } public void refresh(Player player) { player.getVars().setVarBit(143, flagStatus[SARADOMIN]); player.getVars().setVarBit(145, score[SARADOMIN]); player.getVars().setVarBit(153, flagStatus[ZAMORAK]); player.getVars().setVarBit(155, score[ZAMORAK]); } @Override public void run() { minutesLeft--; if (minutesLeft == 5) { endGame(score[SARADOMIN] == score[ZAMORAK] ? -2 : score[SARADOMIN] > score[ZAMORAK] ? SARADOMIN : ZAMORAK); reset(); } else if (minutesLeft == 0) { minutesLeft = 25; startGame(); } else if (minutesLeft > 6) // adds ppl waiting on lobby startGame(); refreshAllPlayersTime(); } } public static void handleInterfaces(Player player, int interfaceId, int componentId) { if (interfaceId == 55) if (componentId == 9) player.closeInterfaces(); } public static ObjectClickHandler handleScoreboard = new ObjectClickHandler(new Object[] { 4484 }, e -> CastleWars.viewScoreBoard(e.getPlayer())); public static ObjectClickHandler handleJoinZamorak = new ObjectClickHandler(new Object[] { 4388 }, e -> joinPortal(e.getPlayer(), ZAMORAK)); public static ObjectClickHandler handleJoinGuthix = new ObjectClickHandler(new Object[] { 4408 }, e -> joinPortal(e.getPlayer(), GUTHIX)); public static ObjectClickHandler handleJoinSaradomin = new ObjectClickHandler(new Object[] { 4387 }, e -> joinPortal(e.getPlayer(), SARADOMIN)); public static List[] getPlaying() { return playing; } }" "package com.rs.game.content.minigames.castlewars; public class CastleWarsPlayingController extends Controller { private final int team; public CastleWarsPlayingController(int team) { this.team = team; } @Override public void start() { sendInterfaces(); } @Override public boolean canMove(Direction dir) { Tile toTile = Tile.of(player.getX() + dir.dx, player.getY() + dir.dy, player.getPlane()); return !CastleWars.isBarricadeAt(toTile); } @Override public boolean processNPCClick2(NPC n) { if (n.getId() == 1532 && n instanceof CastleWarBarricade barricade) { if (!player.getInventory().containsItem(590, 1)) { player.sendMessage(""You do not have the required items to light this.""); return false; } barricade.litFire(); return false; } return true; } /* * return process normaly */ @Override public boolean processButtonClick(int interfaceId, int componentId, int slotId, int slotId2, ClientPacket packet) { if (interfaceId == 387) { if (componentId == 9 || componentId == 6) { player.sendMessage(""You can't remove your team's colours.""); return false; } if (componentId == 15) { int weaponId = player.getEquipment().getWeaponId(); if (weaponId == 4037 || weaponId == 4039) { player.sendMessage(""You can't remove enemy's flag.""); return false; } } } else if (interfaceId == Inventory.INVENTORY_INTERFACE) { Item item = player.getInventory().getItem(slotId); if (item != null) { if (item.getId() == 4053) { if (player.getX() == 2422 && player.getY() == 3076 || player.getX() == 2426 && player.getY() == 3080 || player.getX() == 2423 && player.getY() == 3076 || player.getX() == 2426 && player.getY() == 3081 || player.getX() == 2373 && player.getY() == 3127 || player.getX() == 2373 && player.getY() == 3126 || player.getX() == 2376 && player.getY() == 3131 || player.getX() == 2377 && player.getY() == 3131 || !CastleWars.isBarricadeAt(player.getTile())) { player.sendMessage(""You cannot place a barracade here!""); return false; } CastleWars.addBarricade(team, player); return false; } if (item.getId() == 4049 || item.getId() == 4050 || item.getId() == 12853 || item.getId() == 14640 || item.getId() == 14648) { doBandageEffect(item); return false; } } } return true; } @Override public boolean canDropItem(Item item) { if (item.getDefinitions().getName().toLowerCase().contains(""flag"")) { player.sendMessage(""You cannot just drop the flag!""); return false; } return true; } private void doBandageEffect(Item item) { int gloves = player.getEquipment().getGlovesId(); player.heal((int) (player.getMaxHitpoints() * (gloves >= 11079 && gloves <= 11084 ? 0.15 : 0.10))); int restoredEnergy = (int) (player.getRunEnergy() * 1.3); player.setRunEnergy(restoredEnergy > 100 ? 100 : restoredEnergy); player.getInventory().deleteItem(item); } @Override public boolean canEquip(int slotId, int itemId) { if (slotId == Equipment.CAPE || slotId == Equipment.HEAD) { player.sendMessage(""You can't remove your team's colours.""); return false; } if (slotId == Equipment.WEAPON || slotId == Equipment.SHIELD) { int weaponId = player.getEquipment().getWeaponId(); if (weaponId == 4037 || weaponId == 4039) { player.sendMessage(""You can't remove enemy's flag.""); return false; } } return true; } @Override public boolean canAttack(Entity target) { if (target instanceof Player) { if (canHit(target)) return true; player.sendMessage(""You can't attack your team.""); return false; } return true; } @Override public boolean processItemOnNPC(NPC npc, Item item) { if (npc.getId() == 1532 && npc instanceof CastleWarBarricade barricade) { if (item.getId() == 590) { barricade.litFire(); return false; } if (item.getId() == 4045) { player.getInventory().deleteItem(item); barricade.explode(); return false; } } return true; } @Override public boolean canHit(Entity target) { if (target instanceof NPC) return true; Player p2 = (Player) target; if (p2.getEquipment().getCapeId() == player.getEquipment().getCapeId()) return false; return true; } // You can't leave just like that! public void leave() { player.getInterfaceManager().removeOverlay(); CastleWars.removePlayingPlayer(player, team); } @Override public void sendInterfaces() { player.getInterfaceManager().sendOverlay(58); } @Override public boolean sendDeath() { WorldTasks.scheduleLooping(new Task() { int loop; @Override public void run() { if (loop == 0) player.setNextAnimation(new Animation(836)); else if (loop == 1) player.sendMessage(""Oh dear, you have died.""); else if (loop == 3) { int weaponId = player.getEquipment().getWeaponId(); if (weaponId == 4037 || weaponId == 4039) { CastleWars.setWeapon(player, null); CastleWars.dropFlag(player.getTile(), weaponId == 4037 ? CastleWars.SARADOMIN : CastleWars.ZAMORAK); } else { Player killer = player.getMostDamageReceivedSourcePlayer(); if (killer != null) killer.increaseKillCount(player); } player.reset(); player.tele(Tile.of(team == CastleWars.ZAMORAK ? CastleWars.ZAMO_BASE : CastleWars.SARA_BASE, 1)); player.setNextAnimation(new Animation(-1)); } else if (loop == 4) { player.jingle(90); stop(); } loop++; } }, 0, 1); return false; } @Override public boolean logout() { player.setTile(Tile.of(CastleWars.LOBBY, 2)); return true; } @Override public boolean processTeleport(Teleport tele) { player.simpleDialogue(""You can't leave just like that!""); return false; } @Override public boolean processObjectClick1(GameObject object) { int id = object.getId(); if (id == 4406 || id == 4407) { removeController(); leave(); return false; } if ((id == 4469 && team == CastleWars.SARADOMIN) || (id == 4470 && team == CastleWars.ZAMORAK)) { passBarrier(object); return false; } if (id == 4377 || id == 4378) { // no flag anymore if (id == 4377 && team == CastleWars.SARADOMIN) { if (player.getEquipment().getWeaponId() == 4039) { CastleWars.addScore(player, team, CastleWars.ZAMORAK); return false; } } else if (id == 4378 && team == CastleWars.ZAMORAK) if (player.getEquipment().getWeaponId() == 4037) { CastleWars.addScore(player, team, CastleWars.SARADOMIN); return false; } player.sendMessage(""You need to bring a flag back here!""); return false; } else if (id == 4902 || id == 4903) { // take flag if (id == 4902 && team == CastleWars.SARADOMIN) { if (player.getEquipment().getWeaponId() == 4039) { CastleWars.addScore(player, team, CastleWars.ZAMORAK); return false; } player.sendMessage(""Saradomin won't let you take his flag!""); } else if (id == 4903 && team == CastleWars.ZAMORAK) { if (player.getEquipment().getWeaponId() == 4037) { CastleWars.addScore(player, team, CastleWars.SARADOMIN); return false; } player.sendMessage(""Zamorak won't let you take his flag!""); } else // take flag CastleWars.takeFlag(player, team, id == 4902 ? CastleWars.SARADOMIN : CastleWars.ZAMORAK, object, false); return false; } else if (id == 4900 || id == 4901) { // take dropped flag CastleWars.takeFlag(player, team, id == 4900 ? CastleWars.SARADOMIN : CastleWars.ZAMORAK, object, true); return false; } else if (id == 36579 || id == 36586) { player.getInventory().addItem(new Item(4049)); return false; } else if (id == 36575 || id == 36582) { player.getInventory().addItem(new Item(4053)); return false; } else if (id == 36577 || id == 36584) { player.getInventory().addItem(new Item(4045)); return false; // under earth from basess } else if (id == 4411) {// stepping stone if (object.getX() == player.getX() && object.getY() == player.getY()) return false; player.lock(2); player.setNextAnimation(new Animation(741)); player.addWalkSteps(object.getX(), object.getY(), -1, false); } else if (id == 36693) { player.useStairs(827, Tile.of(2430, 9483, 0), 1, 2); return false; } else if (id == 36694) { player.useStairs(827, Tile.of(2369, 9524, 0), 1, 2); return false; } else if (id == 36645) { player.useStairs(828, Tile.of(2430, 3081, 0), 1, 2); return false; } else if (id == 36646) { player.useStairs(828, Tile.of(2369, 3126, 0), 1, 2); return false; } else if (id == 4415) { if (object.getX() == 2417 && object.getY() == 3075 && object.getPlane() == 1) player.useStairs(-1, Tile.of(2417, 3078, 0), 0, 1); else if (object.getX() == 2419 && object.getY() == 3080 && object.getPlane() == 1) player.useStairs(-1, Tile.of(2419, 3077, 0), 0, 1); else if (object.getX() == 2430 && object.getY() == 3081 && object.getPlane() == 2) player.useStairs(-1, Tile.of(2427, 3081, 1), 0, 1); else if (object.getX() == 2425 && object.getY() == 3074 && object.getPlane() == 3) player.useStairs(-1, Tile.of(2425, 3077, 2), 0, 1); else if (object.getX() == 2380 && object.getY() == 3127 && object.getPlane() == 1) player.useStairs(-1, Tile.of(2380, 3130, 0), 0, 1); else if (object.getX() == 2382 && object.getY() == 3132 && object.getPlane() == 1) player.useStairs(-1, Tile.of(2382, 3129, 0), 0, 1); else if (object.getX() == 2369 && object.getY() == 3126 && object.getPlane() == 2) player.useStairs(-1, Tile.of(2372, 3126, 1), 0, 1); else if (object.getX() == 2374 && object.getY() == 3133 && object.getPlane() == 3) player.useStairs(-1, Tile.of(2374, 3130, 2), 0, 1); return false; } else if (id == 36481) { player.useStairs(-1, Tile.of(2417, 3075, 0), 0, 1); return false; } else if (id == 36495 && object.getPlane() == 0) { player.useStairs(-1, Tile.of(2420, 3080, 1), 0, 1); return false; } else if (id == 36480 && object.getPlane() == 1) { player.useStairs(-1, Tile.of(2430, 3080, 2), 0, 1); return false; } else if (id == 36484 && object.getPlane() == 2) { player.useStairs(-1, Tile.of(2426, 3074, 3), 0, 1); return false; } else if (id == 36532 && object.getPlane() == 0) { player.useStairs(-1, Tile.of(2379, 3127, 1), 0, 1); return false; } else if (id == 36540) { player.useStairs(-1, Tile.of(2383, 3132, 0), 0, 1); return false; } else if (id == 36521 && object.getPlane() == 1) { player.useStairs(-1, Tile.of(2369, 3127, 2), 0, 1); return false; } else if (id == 36523 && object.getPlane() == 2) { player.useStairs(-1, Tile.of(2373, 3133, 3), 0, 1); return false; } else if (id == 36644) { if (object.getY() == 9508) player.useStairs(828, Tile.of(2400, 3106, 0), 1, 2); else if (object.getY() == 9499) player.useStairs(828, Tile.of(2399, 3100, 0), 1, 2); player.freeze(0); return false; } else if (id == 36691) { if (object.getY() == 3099) player.useStairs(827, Tile.of(2399, 9500, 0), 1, 2); else if (object.getY() == 3108) player.useStairs(827, Tile.of(2400, 9507, 0), 1, 2); player.freeze(0); return false; }/* * else if (id == 4438) player.getActionManager().setSkill(new * Mining(object, RockDefinitions.SMALLER_ROCKS)); else if (id == 4437) * player.getActionManager().setSkill(new Mining(object, * RockDefinitions.ROCKS )); */ else if (id == 4448) { for (List players : CastleWars.getPlaying()) for (Player player : players) if (player.withinDistance(object.getTile(), 1)) player.applyHit(new Hit(player, player.getHitpoints(), HitLook.TRUE_DAMAGE)); World.spawnObject(new GameObject(4437, object.getType(), object.getRotation(), object.getX(), object.getY(), object.getPlane())); } return true; } @Override public boolean processObjectClick2(GameObject object) { int id = object.getId(); if (id == 36579 || id == 36586) { player.getInventory().addItem(new Item(4049, 5)); return false; } if (id == 36575 || id == 36582) { player.getInventory().addItem(new Item(4053, 5)); return false; } if (id == 36577 || id == 36584) { player.getInventory().addItem(new Item(4045, 5)); return false; } return true; } public void passBarrier(GameObject object) { if (object.getRotation() == 0 || object.getRotation() == 2) { if (player.getY() != object.getY()) return; player.lock(2); player.addWalkSteps(object.getX() == player.getX() ? object.getX() + (object.getRotation() == 0 ? -1 : +1) : object.getX(), object.getY(), -1, false); } else if (object.getRotation() == 1 || object.getRotation() == 3) { if (player.getX() != object.getX()) return; player.lock(2); player.addWalkSteps(object.getX(), object.getY() == player.getY() ? object.getY() + (object.getRotation() == 3 ? -1 : +1) : object.getY(), -1, false); } } @Override public void onTeleported(TeleType type) { removeController(); leave(); } @Override public void forceClose() { leave(); } }" "package com.rs.game.content.minigames.castlewars; public class CastleWarsWaitingController extends Controller { private final int team; public CastleWarsWaitingController(int team) { this.team = team; } @Override public void start() { sendInterfaces(); } // You can't leave just like that! public void leave() { player.getInterfaceManager().removeOverlay(); CastleWars.removeWaitingPlayer(player, team); } @Override public void sendInterfaces() { player.getInterfaceManager().sendOverlay(57); } @Override public boolean processButtonClick(int interfaceId, int componentId, int slotId, int slotId2, ClientPacket packet) { if (interfaceId == 387) if (componentId == 9 || componentId == 6) { player.sendMessage(""You can't remove your team's colours.""); return false; } return true; } @Override public boolean canEquip(int slotId, int itemId) { if (slotId == Equipment.CAPE || slotId == Equipment.HEAD) { player.sendMessage(""You can't remove your team's colours.""); return false; } return true; } @Override public boolean sendDeath() { removeController(); leave(); return true; } @Override public boolean logout() { player.setTile(Tile.of(CastleWars.LOBBY, 2)); return true; } @Override public boolean processTeleport(Teleport tele) { player.simpleDialogue(""You can't leave just like that!""); return false; } @Override public boolean processObjectClick1(GameObject object) { int id = object.getId(); if (id == 4389 || id == 4390) { removeController(); leave(); return false; } return true; } @Override public void onTeleported(TeleType type) { removeController(); leave(); } @Override public void forceClose() { leave(); } }" "package com.rs.game.content.minigames.clanwars; @PluginEventHandler public final class FFAController extends Controller { public static ObjectClickHandler handleFFAPortals = new ObjectClickHandler(new Object[] { 38698, 38699 }, e -> WorldTasks.delay(0, () -> { e.getPlayer().getVars().setVarBit(5279, e.getObjectId() == 38699 ? 1 : 0); if (e.getPlayer().getVars().getVarBit(5294 + e.getPlayer().getVars().getVarBit(5279)) == 1) { e.getPlayer().tele(Tile.of(e.getPlayer().getVars().getVarBit(5279) == 1 ? 3007 : 2815, 5511, 0)); e.getPlayer().getControllerManager().startController(new FFAController(e.getPlayer().getVars().getVarBit(5279) == 1)); return; } e.getPlayer().getInterfaceManager().sendInterface(793); })); public static ButtonClickHandler confirmOp = new ButtonClickHandler(793, e -> { switch(e.getComponentId()) { case 9 -> e.getPlayer().getVars().setVarBit(5294 + e.getPlayer().getVars().getVarBit(5279), e.getPlayer().getVars().getVarBit(5294 + e.getPlayer().getVars().getVarBit(5279)) == 1 ? 0 : 1); case 14 -> e.getPlayer().closeInterfaces(); case 15 -> { if (e.getPlayer().getVars().getVarBit(5294 + e.getPlayer().getVars().getVarBit(5279)) == 1) e.getPlayer().getVars().saveVarBit(5294 + e.getPlayer().getVars().getVarBit(5279), 1); e.getPlayer().closeInterfaces(); e.getPlayer().tele(Tile.of(e.getPlayer().getVars().getVarBit(5279) == 1 ? 3007 : 2815, 5511, 0)); e.getPlayer().getControllerManager().startController(new FFAController(e.getPlayer().getVars().getVarBit(5279) == 1)); } } }); private transient boolean wasInArea; private final boolean dangerous; public FFAController(boolean dangerous) { this.dangerous = dangerous; } @Override public void start() { if (dangerous) { Potions.checkOverloads(player); player.addEffect(Effect.OVERLOAD_PVP_REDUCTION, Integer.MAX_VALUE); } sendInterfaces(); } @Override public void sendInterfaces() { player.getInterfaceManager().sendOverlay(789); } @Override public boolean sendDeath() { player.lock(8); player.stopAll(); WorldTasks.scheduleTimer(loop -> { if (loop == 0) player.setNextAnimation(new Animation(836)); else if (loop == 1) player.sendMessage(""Oh dear, you have died.""); else if (loop == 3) { Player killer = player.getMostDamageReceivedSourcePlayer(); if (killer != null) { killer.removeDamage(player); killer.increaseKillCount(player); } if (dangerous) { player.sendPVPItemsOnDeath(killer); player.getEquipment().init(); player.getInventory().init(); } player.reset(); player.tele(Tile.of(2993, 9679, 0)); remove(true); player.setNextAnimation(new Animation(-1)); } else if (loop == 4) { player.jingle(90); return false; } return true; }); return false; } @Override public void onTeleported(TeleType type) { remove(true); } @Override public void forceClose() { remove(false); } private void remove(boolean needRemove) { MinigameUtilKt.checkAndDeleteFoodAndPotions(player); if (needRemove) removeController(); if (wasInArea) player.setCanPvp(false); player.getInterfaceManager().removeOverlay(); player.removeEffect(Effect.OVERLOAD_PVP_REDUCTION); } @Override public boolean processObjectClick1(GameObject object) { switch (object.getId()) { case 38700 -> { remove(true); player.useStairs(-1, Tile.of(2993, 9679, 0), 0, 1); return false; } case 42023 -> MinigameUtilKt.giveFoodAndPotions(player); } return true; } @Override public void moved() { boolean inArea = inPvpArea(player); if (inArea && !wasInArea) { player.setCanPvp(true); wasInArea = true; } else if (!inArea && wasInArea) { player.setCanPvp(false); wasInArea = false; } } @Override public boolean canDepositItem(Item item) { player.sendMessage(""You can't bank items here.""); return false; } @Override public boolean canAttack(Entity target) { if (canHit(target)) return true; return false; } @Override public boolean canHit(Entity target) { return true; } private boolean inPvpArea(Player player) { return player.getY() >= 5512; } @Override public boolean logout() { return false; } @Override public boolean login() { start(); moved(); return false; } }" "package com.rs.game.content.minigames.creations; /** * @author mgi125, the almighty */ public class GameArea { public static int[] NONE = { -1, -1 }; public static int[] BASE = { 240, 712 }; public static int[] EMPTY = { 241, 715 }; public static int[] RESERVED_1 = { 240, 713 }; public static int[] RESERVED_2 = { 241, 712 }; public static int[] RESERVED_3 = { 241, 713 }; public static int[] KILN = { 240, 714 }; public static int[] ALTAR = { 241, 714 }; public static int[] FOG = { 240, 715 }; public static int[] RIFT = { 240, 716 }; public static int[] WALL = { 241, 716 }; public static int[] ROCK = { 242, 716 }; public static int[] SKILL_ROCK = { 247, 715 }; public static int[] SKILL_POOL = { 247, 714 }; public static int[] SKILL_SWARM = { 247, 713 }; public static int[] SKILL_TREE = { 247, 712 }; /** * Contains area flags. 0-3 bits - type 4-7 bits - tier (if any) 8-9 bits - * rotation 10-18 bits - degradation 19-20 bits - wall team 21-23 bits - wall * tier 24-29 bits - wall status Types: 0 - reserved, don't use 1 - base 2 - * empty 3 - rift 4 - wall 5 - fog 6 - large rock 7 - altar 8 - kiln 9 - rock 10 * - tree 11 - pool 12 - swarm */ private final int[][] flags; /** * Contains base positions. */ private Instance region; public GameArea(int size) { flags = new int[size][size]; } /** * Calculate's new random area. */ public void calculate() { for (int[] flag : flags) Arrays.fill(flag, 2); // fill with empty area set(0, 0, 1, 0, 0); // blue base set(0, 1, 0, 0, 0); // reserved space for blue base set(1, 0, 0, 1, 0); // reserved space for blue base set(1, 1, 0, 2, 0); // reserved space for blue base set(flags.length - 1, flags.length - 1, 1, 0, 2); // red base set(flags.length - 1, flags.length - 2, 0, 0, 2); // reserved space for // red base set(flags.length - 2, flags.length - 1, 0, 1, 2); // reserved space for // red base set(flags.length - 2, flags.length - 2, 0, 2, 2); // reserved space for // red base setWallTeam(0, 0, 1); // flag blue base to blue team setWallTeam(flags.length - 1, flags.length - 1, 2); // flag red base to // red team int total = flags.length * flags.length; int skillPlots = (int) (total * 0.3F); int obstacles = (int) (total * 0.2F); while (skillPlots-- > 0) setRandom(100, 0, 0, flags.length, flags.length, Utils.random(4) + 9, skillPlots == 0 ? 5 : Utils.random(5), Utils.random(4), 60); while (obstacles-- > 0) { int type = Utils.random(5) + 3; int rotation = type == 5 ? 3 : Utils.random(4); if (!setRandom(100, 0, 0, flags.length, flags.length, type, 0, rotation)) Logger.debug(GameArea.class, ""calculate"", ""Failed""); } // ensure that at least one kiln per team is created. int kilnsBlue = Utils.random(2) + 1; int kilnsRed = Utils.random(2) + 1; while (kilnsBlue-- > 0) setRandom(100, 0, 0, flags.length / 2, flags.length / 2, 8, 0, Utils.random(4)); while (kilnsRed-- > 0) setRandom(100, flags.length / 2, flags.length / 2, flags.length, flags.length, 8, 0, Utils.random(4)); } /** * Create's dynamic maps using the info from the calculate() method. */ public void create(Runnable callback) { if (region != null) throw new RuntimeException(""Area already created.""); region = Instance.of(Helper.EXIT, flags.length, flags.length); region.requestChunkBound().thenAccept(e -> { List> futures = new ObjectArrayList<>(); for (int x = 0; x < flags.length; x++) { for (int y = 0; y < flags.length; y++) { int type = getType(x, y); int rot = getRotation(x, y); int tier = getTier(x, y); int[] copy; switch (type) { case 0: // base pad space if (tier == 0) copy = RESERVED_1; else if (tier == 1) copy = RESERVED_2; else if (tier == 2) copy = RESERVED_3; else copy = EMPTY; break; case 1: copy = BASE; break; case 2: copy = EMPTY; break; case 3: copy = RIFT; break; case 4: copy = WALL; break; case 5: copy = FOG; break; case 6: copy = ROCK; break; case 7: copy = ALTAR; break; case 8: copy = KILN; break; case 9: copy = SKILL_ROCK; break; case 10: copy = SKILL_TREE; break; case 11: copy = SKILL_POOL; break; case 12: copy = SKILL_SWARM; break; default: copy = EMPTY; break; } if (type >= 9 && type <= 12 && tier > 0) { int[] r = new int[2]; r[0] = copy[0] - tier; r[1] = copy[1]; copy = r; } else if (type >= 9 && type <= 12 && tier <= 0) copy = EMPTY; final int fx = x, fy = y, fcopyx = copy[0], fcopyy = copy[1]; futures.add(region.copyChunk(fx, fy, 0, fcopyx, fcopyy, 0, rot)); } } CompletableFuture.allOf(futures.toArray(new CompletableFuture[0])).thenRun(() -> { World.spawnObject(new GameObject(Helper.BLUE_DOOR_1, ObjectType.WALL_STRAIGHT, 1, getMinX() + Helper.BLUE_DOOR_P1[0], getMinY() + Helper.BLUE_DOOR_P1[1], 0)); World.spawnObject(new GameObject(Helper.BLUE_DOOR_2, ObjectType.WALL_STRAIGHT, 1, getMinX() + Helper.BLUE_DOOR_P2[0], getMinY() + Helper.BLUE_DOOR_P2[1], 0)); World.spawnObject(new GameObject(Helper.BLUE_DOOR_1, ObjectType.WALL_STRAIGHT, 2, getMinX() + Helper.BLUE_DOOR_P3[0], getMinY() + Helper.BLUE_DOOR_P3[1], 0)); World.spawnObject(new GameObject(Helper.BLUE_DOOR_2, ObjectType.WALL_STRAIGHT, 2, getMinX() + Helper.BLUE_DOOR_P4[0], getMinY() + Helper.BLUE_DOOR_P4[1], 0)); World.spawnObject(new GameObject(Helper.RED_DOOR_1, ObjectType.WALL_STRAIGHT, 3, getMinX() + ((flags.length - 1) * 8) + Helper.RED_DOOR_P1[0], getMinY() + ((flags.length - 1) * 8) + Helper.RED_DOOR_P1[1], 0)); World.spawnObject(new GameObject(Helper.RED_DOOR_2, ObjectType.WALL_STRAIGHT, 3, getMinX() + ((flags.length - 1) * 8) + Helper.RED_DOOR_P2[0], getMinY() + ((flags.length - 1) * 8) + Helper.RED_DOOR_P2[1], 0)); World.spawnObject(new GameObject(Helper.RED_DOOR_1, ObjectType.WALL_STRAIGHT, 0, getMinX() + ((flags.length - 1) * 8) + Helper.RED_DOOR_P3[0], getMinY() + ((flags.length - 1) * 8) + Helper.RED_DOOR_P3[1], 0)); World.spawnObject(new GameObject(Helper.RED_DOOR_2, ObjectType.WALL_STRAIGHT, 0, getMinX() + ((flags.length - 1) * 8) + Helper.RED_DOOR_P4[0], getMinY() + ((flags.length - 1) * 8) + Helper.RED_DOOR_P4[1], 0)); int managerBlue = Helper.MANAGER_NPCS[Utils.random(Helper.MANAGER_NPCS.length)]; int managerRed = Helper.MANAGER_NPCS[Utils.random(Helper.MANAGER_NPCS.length)]; World.spawnNPC(managerBlue, Tile.of(getMinX() + Helper.BLUE_MANAGER_P[0], getMinY() + Helper.BLUE_MANAGER_P[1], 0), -1, false, true).setRandomWalk(false); World.spawnNPC(managerRed, Tile.of(getMinX() + ((flags.length - 1) * 8) + Helper.RED_MANAGER_P[0], getMinY() + ((flags.length - 1) * 8) + Helper.RED_MANAGER_P[1], 0), -1, false, true).setRandomWalk(false); callback.run(); }); }); } /** * Destroy's dynamic maps that were created using create() method. */ public void destroy() { if (region == null) throw new RuntimeException(""Area already destroyed.""); region.destroy(); region = null; } private boolean setRandom(int attempts, int minX, int minY, int maxX, int maxY, int type, int tier, int rotation) { return setRandom(attempts, minX, minY, maxX, maxY, type, tier, rotation, 0); } private boolean setRandom(int attempts, int minX, int minY, int maxX, int maxY, int type, int tier, int rotation, int degradation) { while (attempts-- > 1) { int x = minX + Utils.random(maxX - minX); int y = minY + Utils.random(maxY - minY); if (getType(x, y) == 2) { set(x, y, type, tier, rotation); setDegradation(x, y, degradation); return true; } } for (int x = minX; x < maxX; x++) for (int y = minY; y < maxY; y++) if (getType(x, y) == 2) { set(x, y, type, tier, rotation); setDegradation(x, y, degradation); return true; } return false; } public void set(int x, int y, int type, int tier, int rotation) { flags[x][y] = (type | (tier << 4) | (rotation << 8)); } public void setDegradation(int x, int y, int deg) { flags[x][y] &= ~(0x1FF << 10); flags[x][y] |= deg << 10; } public void setWallTeam(int x, int y, int team) { flags[x][y] &= ~(0x3 << 19); flags[x][y] |= team << 19; } public void setWallTier(int x, int y, int tier) { flags[x][y] &= ~(0x7 << 21); flags[x][y] |= tier << 21; } public void setWallStatus(int x, int y, int status) { flags[x][y] &= ~(0x3F << 24); flags[x][y] |= status << 24; } public int getType(int x, int y) { return flags[x][y] & 0xF; } public int getTier(int x, int y) { return (flags[x][y]) >> 4 & 0xF; } public int getRotation(int x, int y) { return (flags[x][y] >> 8) & 0x3; } public int getDegradation(int x, int y) { return (flags[x][y] >> 10) & 0x1FF; } public int getWallTeam(int x, int y) { return (flags[x][y] >> 19) & 0x3; } public int getWallTier(int x, int y) { return (flags[x][y] >> 21) & 0x7; } public int getWallStatus(int x, int y) { return (flags[x][y] >> 24) & 0x3F; } public int getSize() { return flags.length; } public int getMinX() { return region.getBaseX(); } public int getMinY() { return region.getBaseY(); } public int getMaxX() { return region.getBaseX() + (flags.length << 3); } public int getMaxY() { return region.getBaseY() + (flags.length << 3); } public int[][] getFlags() { return flags; } }" "package com.rs.game.content.minigames.creations; /** * @author mgi125, the almighty */ public class Helper { public static final int[] CLASS_ITEMS_BASE = { 14132, 14122, 14142, 14152, 14172, 14162, 14367, 14357, 14347, 14411, 14401, 14391, 14337, 14327, 14317, 14297, 14287, 14307, 14192, 14202, 12850, 12851, 14422, 14377, 14421, -1, -1, 14215, 14225, 14235, 14245, 14255, 14265, 14275, 14285 }; public static final int[] SACRED_CLAY = { 14182, 14184, 14186, 14188, 14190 }; public static final long DURATION = 20 * 60 * 1000; public static final long PENALTY_DURATION = 10 * 60 * 1000; public static final Tile EXIT = Tile.of(2968, 9710, 0); public static final int[] BASE_ENTRANCE_BLUE = { 4, 5 }; public static final int[] BASE_ENTRANCE_RED = { 4, 2 }; public static final int[][] PLOT_ENTRANCES = { { 2, 2 }, { 2, 3 }, { 2, 4 }, { 3, 2 }, { 3, 4 }, { 4, 2 }, { 4, 4 }, { 5, 2 }, { 5, 3 }, { 5, 4 } }; public static final int[] PLOT_OBJECT_BASE = { 3, 3 }; public static final int KILN = 39546; public static final int KILN_CONFIG_BASE = 583; public static final int KILN_SCRIPT_BASE = 1910; public static final int KILN_CLAY_COMP_BASE = 98; public static final int BLUE_DOOR_1 = 39766; public static final int BLUE_DOOR_2 = 39768; public static final int RED_DOOR_1 = 39767; public static final int RED_DOOR_2 = 39769; public static final int[] BLUE_DOOR_P1 = { 3, 7 }; public static final int[] BLUE_DOOR_P2 = { 4, 7 }; public static final int[] BLUE_DOOR_P3 = { 7, 4 }; public static final int[] BLUE_DOOR_P4 = { 7, 3 }; public static final int[] RED_DOOR_P1 = { 4, 0 }; public static final int[] RED_DOOR_P2 = { 3, 0 }; public static final int[] RED_DOOR_P3 = { 0, 3 }; public static final int[] RED_DOOR_P4 = { 0, 4 }; public static final int[] MANAGER_NPCS = { 8234, 8235, 8236, 8238 }; public static final int[] BLUE_MANAGER_P = { 4, 2 }; public static final int[] RED_MANAGER_P = { 3, 5 }; public static final int[] BARRIER_MIN = { 1, 1 }; public static final int[] BARRIER_MAX = { 6, 6 }; public static final int[] BARRIER_ITEMS = { 14172, 14174, 14176, 14178, 14180 }; public static final int EMPTY_BARRIER1 = 39615; public static final int EMPTY_BARRIER2 = 39616; public static final int EMPTY_BARRIER3 = 39617; public static final int[][] BLUE_BARRIER_WALLS = { { 39770, 39772, 39774, 39776 }, { 39782, 39784, 39786, 39788 }, { 39794, 39796, 39798, 39800 }, { 39806, 39808, 39810, 39812 }, { 39818, 39820, 39822, 39824 } }; public static final int[][] RED_BARRIER_WALLS = { { 39771, 39773, 39775, 39777 }, { 39783, 39785, 39787, 39789 }, { 39795, 39797, 39799, 39801 }, { 39807, 39809, 39811, 39813 }, { 39819, 39821, 39823, 39825 } }; public static final int[][] BLUE_BARRIER_GATES = { { 39778, 39780 }, { 3990, 39792 }, { 39802, 39804 }, { 39814, 39816 }, { 39826, 39828 } }; public static final int[][] RED_BARRIER_GATES = { { 39779, 39781 }, { 3991, 39793 }, { 39803, 39805 }, { 39815, 39817 }, { 39827, 39829 } }; public static final int[][] ROCK_SPOTS = { { 39548, 39548, 39549 }, { 39550, 39554, 39558 }, { 39551, 39555, 39559 }, { 39552, 39556, 39560 }, { 39553, 39557, 39561 } }; public static final int[][] POOL_SPOTS = { { 39548, 39548, 39549 }, { 39565, 39569, 39573 }, { 39564, 39568, 39572 }, { 39563, 39567, 39571 }, { 39562, 39566, 39570 } }; public static final int[][] SWARM_SPOTS = { { 39548, 39548, 39549 }, { 39577, 39581, 39585 }, { 39576, 39580, 39584 }, { 39575, 39579, 39583 }, { 39574, 39578, 39582 } }; public static final int[][] TREE_SPOTS = { { 39548, 39548, 39549 }, { 39589, 39593, 39597 }, { 39588, 39592, 39596 }, { 39587, 39591, 39595 }, { 39586, 39590, 39594 } }; public static final int[] TOOL_TIERS = { 20, 51, 65, 101, 151 }; public static final int[] OBJECT_TIERS = { 10, 90, 125, 175, 241 }; public static final int BLUE_CAPE = 14387; public static final int RED_CAPE = 14389; public static final int PRAYER_ALTAR = 39547; public static void sendHome(Player player) { reset(player); player.useStairs(-1, Helper.EXIT, 0, 1); player.setCanPvp(false); player.setForceMultiArea(false); player.getAppearance().setHidden(false); player.sendDefaultPlayersOptions(); player.getInterfaceManager().removeOverlay(false); player.getControllerManager().removeControllerWithoutCheck(); } public static void reset(Player player) { player.stopAll(); player.getEquipment().reset(); player.getInventory().reset(); if (player.getFamiliar() != null) player.getFamiliar().sendDeath(player); player.setFamiliar(null); player.getAppearance().transformIntoNPC(-1); player.getAppearance().setHidden(false); player.getAppearance().generateAppearanceData(); player.reset(); } public static void spawn(StealingCreationGameController game, Player player, boolean team) { int size = game.getArea().getSize(); int[] base = findNearestBase(game.getArea(), player, team); int[] entrance; if ((base[0] == 0 && base[1] == 0) || (base[0] == (size - 1) && base[1] == (size - 1))) entrance = team ? BASE_ENTRANCE_RED : BASE_ENTRANCE_BLUE; else entrance = PLOT_ENTRANCES[Utils.random(PLOT_ENTRANCES.length)]; Tile tile = Tile.of(game.getArea().getMinX() + (base[0] * 8) + entrance[0], game.getArea().getMinY() + (base[1] * 8) + entrance[1], 0); // System.err.println(""x:"" + tile.getX() + "", y:"" + tile.getY() + "", z:"" // + tile.getPlane()); player.reset(); player.setCanPvp(true); player.setPlayerOption(""Follow"", 2); player.setPlayerOption(""Give to"", 4); player.setPlayerOption(""Pickpocket"", 5); player.setForceMultiArea(true); player.useStairs(-1, tile, 0, 1); // player will unlock itself 600ms // after teleing player.getMusicsManager().playSongAndUnlock(578); } public static int[] findNearestBase(GameArea area, Player player, boolean team) { int[] base = new int[2]; double dist = Double.MAX_VALUE; int pX = player.getChunkX() - (area.getMinX() >> 3); int pY = player.getChunkY() - (area.getMinY() >> 3); for (int size = area.getSize(), x = 0; x < size; x++) for (int y = 0; y < size; y++) if (area.getWallTeam(x, y) == (team ? 2 : 1)) { int xDelta = pX - x; int yDelta = pY - y; double d = Math.sqrt(xDelta * xDelta + yDelta * yDelta); if (d < dist) { dist = d; base[0] = x; base[1] = y; } } return base; } public static boolean withinSafeArea(Player player, GameArea area, boolean team) { Tile tile = getNearestRespawnPoint(player, area, team); int flagX = tile.getChunkX() - (area.getMinX() >> 3); int flagY = tile.getChunkY() - (area.getMinY() >> 3); if (area.getType(flagX, flagY) == 1) { if (team) { if (Helper.withinArea(player, area, flagX, flagY, new int[] { 2, 2 }, 3)) return true; } else if (Helper.withinArea(player, area, flagX, flagY, new int[] { 1, 1 }, 5)) return true; } else if (Helper.withinArea(player, area, flagX, flagY, new int[] { 2, 2 })) return true; return false; } public static Tile getNearestRespawnPoint(Player player, GameArea area, boolean team) { List o = World.getSpawnedObjectsInChunkRange(player.getChunkId(), 8); //TODO bug test if (o != null) { for (int[] gateIDS : (team ? Helper.RED_BARRIER_GATES : Helper.BLUE_BARRIER_GATES)) { for (int id : gateIDS) { for (GameObject object : o) { if (object == null || object.getId() != id) continue; return object.getTile(); } } } } int size = area.getSize(); int[] base = findNearestBase(area, player, team); int[] entrance; if ((base[0] == 0 && base[1] == 0) || (base[0] == (size - 1) && base[1] == (size - 1))) entrance = team ? BASE_ENTRANCE_RED : BASE_ENTRANCE_BLUE; else entrance = PLOT_ENTRANCES[Utils.random(PLOT_ENTRANCES.length)]; Tile tile = Tile.of(area.getMinX() + (base[0] * 8) + entrance[0], area.getMinY() + (base[1] * 8) + entrance[1], 0); return tile; } public static int getItemIndex(String name) { if (name.contains(""rune"") || name.contains(""staff"")) return 7; if (name.contains(""potion"")) return 9; if (name.contains(""food"")) return 10; else if (name.contains(""scroll"") || name.contains(""pouch"")) return 11; else if (name.contains(""barrier"")) return 1; else if (name.contains(""hatchet"") || name.contains(""pickaxe"") || name.contains(""butterfly net"") || name.contains(""harpoon"")) return 2; else if (name.contains(""robe"") || name.contains(""hat"")) return 8; else if (name.contains(""leather body"") || name.contains(""coif"") || name.contains(""chaps"")) return 6; else if (name.contains(""dagger"") || name.contains(""warhammer"") || name.contains(""scimitar"")) return 3; else if (name.contains(""helm"") || name.contains(""plate"")) return 4; else if (name.contains(""bow"") || name.contains(""arrow"")) return 5; else if (name.contains(""clay"")) return 0; return -1; } public static int getRequestedKilnSkill(int indexedId) { if (indexedId >= 0 && indexedId <= 1 || indexedId >= 6 && indexedId <= 8 || indexedId >= 15 && indexedId <= 17) return Constants.SMITHING; if (indexedId >= 2 && indexedId <= 3 || indexedId >= 9 && indexedId <= 14 || indexedId >= 18 && indexedId <= 19 || indexedId == 23) return Constants.CRAFTING; if (indexedId == 4) return Constants.CONSTRUCTION; else if (indexedId == 5) return Constants.COOKING; else if (indexedId >= 20 && indexedId <= 21) return Constants.RUNECRAFTING; else if (indexedId >= 22 && indexedId <= 24) return Constants.SUMMONING; else if (indexedId >= 25 && indexedId <= 32) return Constants.HERBLORE; return 1; } public static boolean checkSkillRequriments(Player player, int requestedSkill, int index) { int level = getLevelForIndex(index); if (player.getSkills().getLevel(requestedSkill) < level) { player.sendMessage(""You dont have the requried "" + Constants.SKILL_NAME[requestedSkill] + "" level for that quality of clay.""); return false; } return true; } private static int getLevelForIndex(int index) { int level = 0; for (int i = 0; i < index; i++) { if (i == index) return level; level += 20; } return level; } public static boolean proccessKilnItems(Player player, int componentId, int index, int itemId, int amount) { int clayId = SACRED_CLAY[index]; if (amount - player.getInventory().getFreeSlots() > 0) amount = amount - player.getInventory().getFreeSlots(); if (amount > 0 && player.getInventory().containsItem(clayId, amount)) { player.getInventory().deleteItem(itemId, amount); player.getInventory().addItem(new Item(CLASS_ITEMS_BASE[componentId - 37] + ((componentId == 57 || componentId == 58 || componentId == 61) ? 0 : componentId == 56 ? index : componentId >= 64 ? (-index * 2) : (index * 2)), (componentId >= 56 && componentId <= 58 ? 15 * (index + 1) : componentId == 61 ? index + 1 : 1) * amount)); return true; } player.sendMessage(""You have no clay to proccess.""); return false; } public static void giveCape(Player player, boolean team) { player.getEquipment().setSlot(Equipment.CAPE, new Item(team ? RED_CAPE : BLUE_CAPE)); player.getEquipment().refresh(Equipment.CAPE); player.getAppearance().generateAppearanceData(); } public static boolean withinArea(Player player, GameArea area, int flagX, int flagY, int[] range, int distance) { int minX = area.getMinX() + (flagX << 3) + Helper.BARRIER_MIN[0] + range[0]; int minY = area.getMinY() + (flagY << 3) + Helper.BARRIER_MIN[1] + range[1]; return player.withinDistance(Tile.of(minX, minY, player.getPlane()), distance); } public static boolean withinArea(Player player, GameArea area, int flagX, int flagY, int[] range) { return withinArea(player, area, flagX, flagY, range, 2); } public static boolean withinArea2(Player player, GameArea area, int flagX, int flagY, int[] range) { int minX = area.getMinX() + (flagX << 3) + range[0]; int minY = area.getMinY() + (flagY << 3) + range[1]; int maxX = area.getMinX() + (flagX << 3) + range[2]; int maxY = area.getMinY() + (flagY << 3) + range[3]; if (player.withinDistance(Tile.of(minX, minY, player.getPlane()), 3)) return player.inArea(minX, minY, maxX, maxY) || player.getX() >= minX && player.getX() <= maxX && player.getY() >= minY && player.getY() <= maxY; return false; } public static boolean setWalkToGate(GameObject gate, Player player) { if (player.getX() == gate.getX() && player.getY() == gate.getY()) return true; if (gate.getRotation() == 0) { if (player.getX() == (gate.getX() - 1) && player.getY() == gate.getY()) return true; return player.addWalkSteps(gate.getX(), gate.getY()) || player.addWalkSteps(gate.getX() - 1, gate.getY()); } if (gate.getRotation() == 1) if (player.getX() == gate.getX() && player.getY() == (gate.getY() + 1)) return true; else return player.addWalkSteps(gate.getX(), gate.getY()) || player.addWalkSteps(gate.getX(), gate.getY() + 1); if (gate.getRotation() == 2) if (player.getX() == (gate.getX() + 1) && player.getY() == gate.getY()) return true; else return player.addWalkSteps(gate.getX(), gate.getY()) || player.addWalkSteps(gate.getX() + 1, gate.getY()); else if (gate.getRotation() == 3) if (player.getX() == gate.getX() && player.getY() == (gate.getY() - 1)) return true; else return player.addWalkSteps(gate.getX(), gate.getY()) || player.addWalkSteps(gate.getX(), gate.getY() - 1); else return false; } public static boolean isAtGate(GameObject gate, Player player) { if (player.getX() == gate.getX() && player.getY() == gate.getY()) return true; if (gate.getRotation() == 0) return player.getX() == (gate.getX() - 1) && player.getY() == gate.getY(); if (gate.getRotation() == 1) return player.getX() == gate.getX() && player.getY() == (gate.getY() + 1); if (gate.getRotation() == 2) return player.getX() == (gate.getX() + 1) && player.getY() == gate.getY(); else if (gate.getRotation() == 3) return player.getX() == gate.getX() && player.getY() == (gate.getY() - 1); else return false; } public static Tile getFaceTile(GameObject gate, Player player) { if (player.getX() != gate.getX() || player.getY() != gate.getY()) return Tile.of(gate.getX(), gate.getY(), gate.getPlane()); if (gate.getRotation() == 0) return Tile.of(gate.getX() - 1, gate.getY(), gate.getPlane()); if (gate.getRotation() == 1) return Tile.of(gate.getX(), gate.getY() + 1, gate.getPlane()); if (gate.getRotation() == 2) return Tile.of(gate.getX() + 1, gate.getY(), gate.getPlane()); else if (gate.getRotation() == 3) return Tile.of(gate.getX(), gate.getY() - 1, gate.getPlane()); else return null; } public static Direction getFaceDirection(Tile faceTile, Player player) { if (player.getX() < faceTile.getX()) return Direction.EAST; if (player.getX() > faceTile.getX()) return Direction.WEST; if (player.getY() < faceTile.getY()) return Direction.NORTH; else if (player.getY() > faceTile.getY()) return Direction.SOUTH; else return Direction.NORTH; } public static void displayClayStatus(GameArea area, Player player) { player.getInterfaceManager().sendInterface(806); int basic = 0; int[] fishing = new int[4]; int[] mining = new int[4]; int[] woodcuting = new int[4]; int[] hunter = new int[4]; int size = area.getSize(); for (int x = 0; x < size; x++) for (int y = 0; y < size; y++) { int type = area.getType(x, y); int tier = area.getTier(x, y); int degradation = area.getDegradation(x, y); if (degradation > 0 && type >= 9 && type <= 12 && tier > 0 && tier < 6) if (tier == 1) basic++; else if (type == 9) mining[tier - 2]++; else if (type == 10) woodcuting[tier - 2]++; else if (type == 11) fishing[tier - 2]++; else if (type == 12) hunter[tier - 2]++; } player.getPackets().sendVarc(564, basic); for (int i = 0; i < fishing.length; i++) player.getPackets().sendVarc(565 + i, fishing[i]); for (int i = 0; i < mining.length; i++) player.getPackets().sendVarc(569 + i, mining[i]); for (int i = 0; i < woodcuting.length; i++) player.getPackets().sendVarc(573 + i, woodcuting[i]); for (int i = 0; i < hunter.length; i++) player.getPackets().sendVarc(577 + i, hunter[i]); } public static int calculateReward(Score personal, int winner) { int total = personal.total((personal.getTeam() ? 2 : 1) == winner); int reward = 0; if (total < 20000) reward = total / 1000; else if (total < 22000) reward = 20; else if (total < 26000) reward = 21; else if (total < 34000) reward = 22; else if (total < 50000) reward = 23; else if (total < 82000) reward = 24; else if (total < 146000) reward = 25; else reward = 26; return reward; } public static void awardPoints(Player player, Score personal, int winner) { int points = calculateReward(personal, winner); player.scPoints += points; player.incrementCount(""Stealing Creation points earned"", points); player.incrementCount(""Stealing creation games played""); player.sendMessage(""You earn: "" + points + "" reward point"" + (points != 1 ? ""s"" : """") + "".""); } public static void displayScores(Player player, boolean redTeam, Score personal, List total, int winner) { player.getInterfaceManager().sendInterface(810); if (personal == null) return; int blueTotal = Score.totalXP(total, false, winner == 1); int redTotal = Score.totalXP(total, true, winner == 2); player.getPackets().sendVarc(588, personal.getTeam() ? 2 : 1); player.getPackets().sendVarc(589, winner); player.getPackets().sendVarc(598, redTeam ? redTotal : blueTotal); // your team player.getPackets().sendVarc(597, redTeam ? blueTotal : redTotal); // enemy team // personal player.getPackets().sendVarc(590, personal.getGathering()); player.getPackets().sendVarc(591, personal.getProcessing()); player.getPackets().sendVarc(592, (personal.getDepositing() - personal.getWithdrawing()) * 2); player.getPackets().sendVarc(593, personal.getDamaging()); player.getPackets().sendVarc(594, personal.getKilled()); player.getPackets().sendVarc(595, personal.getDied()); player.getPackets().sendVarc(596, personal.total((personal.getTeam() ? 2 : 1) == winner)); // -------- // awards Score mostProcessed = Score.mostProcessed(total); Score mostGathered = Score.mostGathered(total); Score mostDeposited = Score.mostDeposited(total); Score mostDamage = Score.mostDamaged(total); Score mostKills = Score.mostKills(total); Score mostDeaths = Score.mostDeaths(total); Score highestP = Score.highestTotal(total, winner); Score lowestP = Score.lowestTotal(total, winner); if (mostProcessed == null || mostGathered == null || mostDeposited == null || mostDamage == null || mostKills == null || mostDeaths == null || highestP == null || lowestP == null) return; player.getPackets().sendVarcString(45, mostGathered.getName()); player.getPackets().sendVarc(608, mostGathered.getTeam() ? 2 : 1); player.getPackets().sendVarc(600, mostGathered.getGathering()); player.getPackets().sendVarcString(44, mostProcessed.getName()); player.getPackets().sendVarc(607, mostProcessed.getTeam() ? 2 : 1); player.getPackets().sendVarc(599, mostProcessed.getProcessing()); player.getPackets().sendVarcString(49, mostDeposited.getName()); player.getPackets().sendVarc(612, mostDeposited.getTeam() ? 2 : 1); player.getPackets().sendVarc(604, (mostDeposited.getDepositing() - mostDeposited.getWithdrawing()) * 2); player.getPackets().sendVarcString(48, mostDamage.getName()); player.getPackets().sendVarc(611, mostDamage.getTeam() ? 2 : 1); player.getPackets().sendVarc(603, mostDamage.getDamaging()); player.getPackets().sendVarcString(46, mostKills.getName()); player.getPackets().sendVarc(609, mostKills.getTeam() ? 2 : 1); player.getPackets().sendVarc(601, mostKills.getKilled()); player.getPackets().sendVarcString(47, mostDeaths.getName()); player.getPackets().sendVarc(610, mostDeaths.getTeam() ? 2 : 1); player.getPackets().sendVarc(602, mostDeaths.getDied()); player.getPackets().sendVarcString(50, highestP.getName()); player.getPackets().sendVarc(613, highestP.getTeam() ? 2 : 1); player.getPackets().sendVarc(605, highestP.total((highestP.getTeam() ? 2 : 1) == winner)); player.getPackets().sendVarcString(51, lowestP.getName()); player.getPackets().sendVarc(614, lowestP.getTeam() ? 2 : 1); player.getPackets().sendVarc(606, lowestP.total((lowestP.getTeam() ? 2 : 1) == winner)); // -------- player.sendMessage(""Team 1's score(blue team): "" + blueTotal + "" - Team 2's score(red team): "" + redTotal); if (winner != 0 && winner == (personal.getTeam() ? 2 : 1)) player.sendMessage(""Your team, Team "" + (personal.getTeam() ? 2 : 1) + "", is victorious! You gain a 10% bonus to your score!""); else if (winner != 0 && winner != (personal.getTeam() ? 2 : 1)) player.sendMessage(""Your team, Team "" + (personal.getTeam() ? 2 : 1) + "", is defeated! Team "" + (personal.getTeam() ? 1 : 2) + "" is victorious!""); else if (winner == 0) player.sendMessage(""Your team, Team "" + (personal.getTeam() ? 2 : 1) + "", ties with Team "" + (personal.getTeam() ? 1 : 2) + ""!""); // TODO // get // original // rs // message // for // tie player.sendMessage(""YOUR TOTAL SCORE: "" + personal.total((personal.getTeam() ? 2 : 1) == winner) + "" points.""); } public static void displayKiln(final Player player) { if (!player.getInventory().containsOneItem(SACRED_CLAY)) { player.sendMessage(""You try using the processing point, but quickly realize that you have no sacred clay with you.""); return; } player.getInterfaceManager().sendInterface(813); player.getPackets().sendRunScriptReverse(KILN_SCRIPT_BASE); // + tabID int quality = 0; qualityLoop: for (int i = 4; i >= 0; i--) if (player.getInventory().containsOneItem(SACRED_CLAY[i])) { quality = i; break qualityLoop; } player.getTempAttribs().setI(""sc_kiln_quality"", quality); player.getTempAttribs().setL(""in_kiln"", System.currentTimeMillis() + 10000); player.setCloseInterfacesEvent(() -> player.getTempAttribs().removeL(""in_kiln"")); refreshKiln(player); } public static void refreshKiln(Player player) { int quality = player.getTempAttribs().getI(""sc_kiln_quality"") != -1 ? player.getTempAttribs().getI(""sc_kiln_quality"") : 4; for (int i = 0; i < 5; i++) { player.getPackets().sendVarc(KILN_CONFIG_BASE + i, player.getInventory().getAmountOf(SACRED_CLAY[i])); player.getPackets().setIFHidden(813, Helper.KILN_CLAY_COMP_BASE + (i * 2), quality != i); } } }" "package com.rs.game.content.minigames.creations; public class Score { /** * Name of the player that this score belongs to. (stored here so if player goes * offline it's still possible to show name in highscores interface) */ private final String name; /** * Team of the player. */ private final boolean team; /** * Gathering score. */ private int gathering; /** * Processing score. */ private int processing; /** * Depositing score. */ private int depositing; /** * Withdrawing score. */ private int withdrawing; /** * Damaging score. */ private int damaging; /** * Amount of players killed. */ private int killed; /** * Amount of deaths. */ private int died; public Score(String name, boolean team) { this.name = name; this.team = team; } public void updateGathering(int delta) { gathering += delta; } public void updateProcessing(int delta) { processing += delta; } public void updateDepositing(int delta) { depositing += delta; } public void updateWithdrawing(int delta) { withdrawing += delta; } public void updateDamaging(int delta) { damaging += delta; } public void updateKilled(int delta) { killed += delta; } public void updateDied(int delta) { died += delta; } /** * Calculate's base total score (excludes kill/death calculation). */ public int total(boolean winBoost) { int tot = gathering + processing + ((depositing - withdrawing) * 2) + damaging; if (winBoost) tot = (int) (tot * 1.1D); return tot; } public String getName() { return name; } public boolean getTeam() { return team; } public int getGathering() { return gathering; } public int getProcessing() { return processing; } public int getDepositing() { return depositing; } public int getWithdrawing() { return withdrawing; } public int getDamaging() { return damaging; } public int getKilled() { return killed; } public int getDied() { return died; } public static int totalXP(List scores, boolean team, boolean winner) { int total = 0; for (Score score : scores) if (score.getTeam() == team) total += score.total(winner); return total; } public static Score highestTotal(List scores, int winnerTeam) { Score highest = null; int highests = Integer.MIN_VALUE; for (Score score : scores) { int total = score.total((score.getTeam() ? 2 : 1) == winnerTeam); if (highest == null || total > highests) { highest = score; highests = total; } } return highest; } public static Score lowestTotal(List scores, int winnerTeam) { Score lowest = null; int lowests = Integer.MAX_VALUE; for (Score score : scores) { int total = score.total((score.getTeam() ? 2 : 1) == winnerTeam); if (lowest == null || total < lowests) { lowest = score; lowests = total; } } return lowest; } public static Score mostKills(List scores) { Score most = null; int mosts = Integer.MIN_VALUE; for (Score score : scores) { int s = score.getKilled(); if (most == null || s > mosts) { most = score; mosts = s; } } return most; } public static Score mostDeaths(List scores) { Score most = null; int mosts = Integer.MIN_VALUE; for (Score score : scores) { int s = score.getDied(); if (most == null || s > mosts) { most = score; mosts = s; } } return most; } public static Score mostGathered(List scores) { Score most = null; int mosts = Integer.MIN_VALUE; for (Score score : scores) { int s = score.getGathering(); if (most == null || s > mosts) { most = score; mosts = s; } } return most; } public static Score mostProcessed(List scores) { Score most = null; int mosts = Integer.MIN_VALUE; for (Score score : scores) { int s = score.getProcessing(); if (most == null || s > mosts) { most = score; mosts = s; } } return most; } public static Score mostDeposited(List scores) { Score most = null; int mosts = Integer.MIN_VALUE; for (Score score : scores) { int s = (score.getDepositing() - score.getWithdrawing()) * 2; if (most == null || s > mosts) { most = score; mosts = s; } } return most; } public static Score mostDamaged(List scores) { Score most = null; int mosts = Integer.MIN_VALUE; for (Score score : scores) { int s = score.getDamaging(); if (most == null || s > mosts) { most = score; mosts = s; } } return most; } }" "package com.rs.game.content.minigames.creations; public class StealingCreationClay extends Conversation { public StealingCreationClay(Player player) { super(player); addOptions(""Select a class."", ops -> { for (int i = 0;i < 5;i++) ops.add(""Class "" + (i + 1)); //TODO 14182 + (i*2) }); } }" "package com.rs.game.content.minigames.creations; public class StealingCreationController extends Controller { private final transient StealingCreationGameController game; private final boolean team; public StealingCreationController(StealingCreationGameController game, boolean team) { this.game = game; this.team = team; } @Override public void start() { sendInterfaces(); } @Override public boolean logout() { player.setTile(Helper.EXIT); Helper.reset(player); return true; } @Override public boolean login() { getPlayer().sendMessage(""How did you manage to remain here eh? REPORTED!!""); return true; } @Override public void sendInterfaces() { player.getInterfaceManager().sendOverlay(809, false); player.getPackets().sendVarc(558, (int) ((game.getEndTime() - System.currentTimeMillis()) / 600)); // sync player.getVars().setVarBit(5493, getTeam() ? 2 : 1); } public void sendScore(Score score) { player.getVars().setVar(1332, score.getGathering()); player.getVars().setVar(1333, score.getDepositing()); player.getVars().setVar(1334, score.getProcessing()); player.getVars().setVar(1335, score.getWithdrawing()); player.getVars().setVar(1337, score.getDamaging()); } @Override public void moved() { GameArea area = game.getArea(); if (area.getFlags() != null) { int flagX = player.getChunkX() - (area.getMinX() >> 3); int flagY = player.getChunkY() - (area.getMinY() >> 3); if (flagX >= 8 || flagY >= 8 || flagX < 0 || flagY < 0) return; if (area.getType(flagX, flagY) == 5) { if (Helper.withinArea2(player, area, flagX, flagY, new int[] { 1, 1, 4, 4 })) { if (!player.getAppearance().isNPC()) { player.getAppearance().transformIntoNPC(1957); player.getAppearance().setHidden(true); player.setRunHidden(false); player.getNextHits().clear(); } } else resetFOG(); } else resetFOG(); } } private void resetFOG() { if (player.getAppearance().isNPC()) { player.getAppearance().transformIntoNPC(-1); player.getAppearance().setHidden(false); if (!player.getRun()) WorldTasks.schedule(new Task() { @Override public void run() { player.setRunHidden(true); } }); } } @Override public void process() { if (game == null || (getPlayer().getX() < game.getArea().getMinX() || getPlayer().getX() > game.getArea().getMaxX() || player.getY() < game.getArea().getMinY() || player.getY() > game.getArea().getMaxY())) { getPlayer().sendMessage(""An error has occured, please submit bug report.""); player.getControllerManager().forceStop(); return; } } @Override public boolean canEquip(int slot, int item) { if (slot == Equipment.CAPE) { player.sendMessage(""You can't remove your team's colours.""); return false; } return true; } @Override public boolean canHit(Entity target) { if (target instanceof Player other) { if (other.getEquipment().getCapeId() == player.getEquipment().getCapeId() || Helper.withinSafeArea(other, game.getArea(), !getTeam())) return false; } else if (target instanceof Familiar familiar) { Player owner = familiar.getOwner(); if (owner.getEquipment().getCapeId() == player.getEquipment().getCapeId()) return false; } return true; } @Override public boolean canAttack(Entity target) { if (target instanceof Player other) { if (other.getEquipment().getCapeId() == player.getEquipment().getCapeId()) { player.sendMessage(""You cannot attack player's on the same team!""); return false; } if (target.getTempAttribs().getL(""in_kiln"") >= System.currentTimeMillis()) { player.sendMessage(""The power of the creation kiln is protecting the player.""); return false; } } else if (target instanceof Familiar familiar) { Player owner = familiar.getOwner(); if (owner.getEquipment().getCapeId() == player.getEquipment().getCapeId()) { player.sendMessage(""You cannot attack a familiar on the same side as you!""); return false; } } return true; } @Override public boolean processItemOnPlayer(Player target, Item item, int slot) { if (player.withinDistance(target.getTile(), 3)) { if (target.isDead() || player.isDead()) return false; if (target.getEquipment().getCapeId() != player.getEquipment().getCapeId()) { player.sendMessage(""You cannot give an item to a player on the opposite team!""); return false; // } else if (!target.isAcceptingAid()) { // player.sendMessage(""That player currently does not want your aid.""); // return false; } if (target.getInventory().addItem(item)) { player.getInventory().deleteItem(item); target.sendMessage(Utils.formatPlayerNameForDisplay(player.getDisplayName()) + "" has given you an item.""); return false; } else { player.sendMessage(Utils.formatPlayerNameForDisplay(player.getDisplayName()) + "" has insufficient room in their inventory.""); return false; } } return false; } @Override public boolean processItemOnObject(GameObject object, Item item) { if (object.getId() == 39533) { game.sendItemToBase(player, item, getTeam(), false, false); return true; } return true; } @Override public boolean processNPCClick1(NPC n) { for (int element : Helper.MANAGER_NPCS) if (n.getId() == element) { n.setNextFaceEntity(player); player.startConversation(new StealingCreationManagerD(player, getGame(), n)); return false; } return true; } @Override public boolean processNPCClick2(NPC n) { for (int element : Helper.MANAGER_NPCS) if (n.getId() == element) { n.setNextFaceEntity(player); Helper.displayClayStatus(game.getArea(), player); return false; } return true; } @Override public boolean canPlayerOption2(Player target) { return false; } @Override public boolean processTeleport(Teleport tele) { if (tele.type() != TeleType.OBJECT) { player.simpleDialogue(""You can't leave just like that!""); return false; } return true; } @Override public boolean canPlayerOption4(Player target) { if (target.getEquipment().getCapeId() != player.getEquipment().getCapeId()) { player.sendMessage(""You cannot give an item to a player on the opposite team!""); return false; } // else if (!target.isAcceptingAid()) { // player.sendMessage(""That player currently does not want your aid.""); // return false; // } return true; } @Override public void onTeleported(TeleType type) { player.getControllerManager().forceStop(); } @Override public boolean canPlayerOption3(final Player target) { final int thievingLevel = player.getSkills().getLevel(Constants.THIEVING); if ((player.getTempAttribs().getL(""PICKPOCK_DELAY"") + 1500 > System.currentTimeMillis()) || Helper.withinSafeArea(target, game.getArea(), !getTeam()) || Helper.withinSafeArea(player, game.getArea(), getTeam())) return false; if (player.getAttackedBy() != null && player.inCombat()) { player.sendMessage(""You can't do this while you're under combat.""); return false; } else if (target.getEquipment().getCapeId() == player.getEquipment().getCapeId()) { player.sendMessage(""You cannot pickpocket player that is on the same team!""); return false; } else if (target.getTempAttribs().getL(""in_kiln"") >= System.currentTimeMillis()) { player.sendMessage(""The power of the creation kiln is protecting the player.""); return false; } else if (target.getSkills().getLevel(Constants.THIEVING) - thievingLevel >= 20) { player.sendMessage(""You need a theiving level of at least "" + (target.getSkills().getLevel(Constants.THIEVING) - 20) + "" to pickpocket "" + Utils.formatPlayerNameForDisplay(target.getDisplayName() + ""."")); return false; } else if (target.getInventory().getFreeSlots() == 28) { player.sendMessage(Utils.formatPlayerNameForDisplay(target.getDisplayName() + "" appears to have nothing in his pockets."")); return false; } else if (player.getInventory().getFreeSlots() == 0) { player.sendMessage(""You don't have enough space in your inventory to steal from your target.""); return false; } else if (target.isDead()) { player.sendMessage(""Too late.""); return false; } player.setRouteEvent(new RouteEvent(target, () -> { player.setNextFaceEntity(target); player.setNextAnimation(new Animation(881)); player.sendMessage(""You attempt to pickpocket from "" + Utils.formatPlayerNameForDisplay(target.getDisplayName()) + ""'s pockets.""); player.sendMessage(""You pick "" + Utils.formatPlayerNameForDisplay(target.getDisplayName()) + ""'s pocket.""); player.getTempAttribs().setL(""PICKPOCK_DELAY"", System.currentTimeMillis()); int level = Utils.getRandomInclusive(thievingLevel); double ratio = (double) level / (Utils.random(target.getSkills().getLevel(Constants.THIEVING)) + 6); if (!(Math.round(ratio * thievingLevel) > target.getSkills().getLevel(Constants.THIEVING))) player.sendMessage(""You fail to pickpocket "" + Utils.formatPlayerNameForDisplay(target.getDisplayName()) + "".""); else { Item caughtItem = getCalculatedItem(target); itemLoop: for (int i = 0; i < 100; i++) { if (caughtItem != null) { if (player.getInventory().addItem(caughtItem)) target.getInventory().deleteItem(caughtItem); break itemLoop; } caughtItem = getCalculatedItem(target); } player.sendMessage(""You sucessfully pickpocket an item from "" + Utils.formatPlayerNameForDisplay(target.getDisplayName()) + ""'s pockets!""); } })); return false; } public Item getCalculatedItem(Player target) { return target.getInventory().getItem(Utils.random(target.getInventory().getItemsContainerSize())); } @Override public boolean keepCombating(Entity target) { if (target instanceof Player other) { if (other.getAppearance().isNPC()) { player.sendMessage(""Your target is nowhere to be found.""); return false; } if (Helper.withinSafeArea(other, game.getArea(), !getTeam()) || Helper.withinSafeArea(player, game.getArea(), getTeam())) return false; } if (player.getAppearance().isNPC()) { player.sendMessage(""You cannot attack while you are hidden.""); return false; } return true; } @Override public void trackXP(int skillId, int addedXp) { if (skillId == 3) { Score score = game.getScore(player); if (score == null) return; score.updateDamaging((int) (addedXp * 7.2148148148148148148148148148148)); sendScore(score); } } @Override public boolean canTakeItem(GroundItem item) { Score score = game.getScore(player); String name = item.getName().toLowerCase(); int nameIndex = name.indexOf(""(class""); int clayQuality = 1; if (nameIndex != -1) clayQuality = name.contains(""potion"") ? 1 : Integer.parseInt(name.substring(nameIndex).replace(""(class "", """").replace("")"", """")); int pointsSubtracted = 2 * (((item.getDefinitions().isStackable() ? 1 : 15) * clayQuality) * item.getAmount()); if (score.getWithdrawing() - pointsSubtracted <= -3000) { player.sendMessage(""You cannot take this amount of items as your score is too low.""); return false; } if (!item.isPrivate()) { score.updateWithdrawing(pointsSubtracted); sendScore(score); } return true; } @Override public boolean processButtonClick(int interfaceId, int componentId, int slotId, int slotId2, ClientPacket packet) { if (interfaceId == 813) { if (componentId >= 37 && componentId <= 71) processKilnExchange(componentId, packet); else if (componentId >= 99 && componentId <= 107) { int index = (componentId - 99) / 2; if (player.getInventory().containsItem(Helper.SACRED_CLAY[index], 1)) { player.getTempAttribs().setI(""sc_kiln_quality"", index); Helper.refreshKiln(player); } } return true; } if (interfaceId == 387) { if (packet == ClientPacket.IF_OP1 && componentId == 9) { player.sendMessage(""You can't remove your team's colours.""); return false; } } else if (interfaceId == Inventory.INVENTORY_INTERFACE) { Item item = player.getInventory().getItem(slotId); if (item != null) { String itemName = item.getName().toLowerCase(); if (itemName.contains(""food (class"")) { doFoodEffect(item, Integer.parseInt(item.getName().substring(item.getName().indexOf(""(class"")).replace(""(class "", """").replace("")"", """"))); return false; } if (itemName.contains(""potion ("") || itemName.contains(""super"")) { boolean superPotion = itemName.contains(""super""); int index = 0; for (String name : Constants.SKILL_NAME) { int doses = Integer.parseInt(itemName.substring(itemName.indexOf(""("")).replace(""("", """").replace("")"", """")); String skill = superPotion ? item.getName().toLowerCase().replace(""super "", """").replace("" ("" + doses + "")"", """") : item.getName().toLowerCase().replace("" potion ("" + doses + "")"", """"); if (!name.toLowerCase().equals(skill)) { index++; continue; } player.sendMessage(""You drink a dose of the "" + item.getName().toLowerCase().replace(""("" + doses + "")"", """") + "".""); if (doses == 1) { player.getInventory().deleteItem(item); player.sendMessage(""The glass shatters as you drink the last dose of the potion.""); } else { player.getInventory().getItems().set(slotId, new Item(item.getId() + 2, 1)); player.getInventory().refresh(slotId); } int actualLevel = player.getSkills().getLevel(index); int realLevel = player.getSkills().getLevelForXp(index); if (!skill.equals(""prayer"")) { int level = actualLevel > realLevel ? realLevel : actualLevel; player.getSkills().set(index, level + (superPotion ? 7 : 4)); } else player.getPrayer().restorePrayer((int) (Math.floor(player.getSkills().getLevelForXp(Constants.PRAYER) * .5 + (superPotion ? 250 : 200)))); player.setNextAnimation(new Animation(829)); player.soundEffect(4580, false); } return false; } } } return true; } private void doFoodEffect(Item item, int itemTier) { if (!player.canEat()) return; player.setNextAnimation(new Animation(829)); player.addFoodDelay(1800); player.sendMessage(""You eat the food.""); int hp = player.getHitpoints(); player.heal(40 * itemTier); if (player.getHitpoints() > hp) player.sendMessage(""It heals some health.""); player.getActionManager().setActionDelay(player.getActionManager().getActionDelay() + 3); player.getInventory().deleteItem(item); } @Override public boolean processObjectClick1(final GameObject object) { final GameArea area = game.getArea(); final int flagX = player.getChunkX() - (area.getMinX() >> 3); final int flagY = player.getChunkY() - (area.getMinY() >> 3); boolean isEnemySCGate = false; boolean isEnemySCWall = false; gateLoop: for (int[] wallIDS : (getTeam() ? Helper.BLUE_BARRIER_GATES : Helper.RED_BARRIER_GATES)) for (int id : wallIDS) if (object.getId() == id) { isEnemySCGate = true; break gateLoop; } wallLoop: for (int[] wallIDS : (getTeam() ? Helper.BLUE_BARRIER_WALLS : Helper.RED_BARRIER_WALLS)) for (int id : wallIDS) if (object.getId() == id) { isEnemySCWall = true; break wallLoop; } if (object.getId() == Helper.KILN) { Helper.displayKiln(player); return false; } if (object.getId() == 39533) { for (Item item : player.getInventory().getItems().array()) { if (item == null) continue; game.sendItemToBase(player, item, getTeam(), false, true); } return false; } if ((!getTeam() && (object.getId() == Helper.BLUE_DOOR_1 || object.getId() == Helper.BLUE_DOOR_2)) || (getTeam() && (object.getId() == Helper.RED_DOOR_1 || object.getId() == Helper.RED_DOOR_2))) { passWall(player, object, getTeam()); return false; } else if (isEnemySCGate || isEnemySCWall) { final int x = object.getTile().getChunkX() - (game.getArea().getMinX() >> 3); final int y = object.getTile().getChunkY() - (game.getArea().getMinY() >> 3); final int weaponId = player.getEquipment().getWeaponId(); AttackStyle attackStyle = player.getCombatDefinitions().getAttackStyle(); final int combatDelay = PlayerCombatKt.getMeleeCombatDelay(weaponId); if (player.getActionManager().getAction() != null || player.getActionManager().getActionDelay() > 0) return false; player.getActionManager().addActionDelay(combatDelay); player.setNextAnimation(new Animation(PlayerCombatKt.getWeaponAttackEmote(weaponId, attackStyle))); WorldTasks.schedule(new Task() { @Override public void run() { game.damageBarrier(x, y); } }); return false; } else if (object.getId() == Helper.PRAYER_ALTAR) { boolean runEnergy = Utils.getRandomInclusive(1) == 0; if (runEnergy) player.setRunEnergy(100); return !runEnergy; } else if (object.getId() >= 39534 && object.getId() <= 39545) { player.getTempAttribs().setO(""sc_object"", object); if (object.getId() == 39541) player.startConversation(new StealingCreationMagic(player)); else if (object.getId() == 39539) player.startConversation(new StealingCreationRange(player)); else if (object.getId() == 39534) player.startConversation(new StealingCreationClay(player)); return false; } else if (object.getId() == 39602 || object.getId() == 39613 || object.getId() == 39612 || object.getId() == 39611) { boolean isWall = object.getId() == 39613 || object.getId() == 39612 || object.getId() == 39611; if (isWall) if (player.getSkills().getLevel(Constants.AGILITY) < 60) { player.sendMessage(""You need to have an Agility level of 60 to clim over the wall.""); return false; } int rotation = object.getRotation(); int xExtra = 0, yExtra = 0, totalDistance = isWall ? 2 : 3; Direction direction = Direction.NORTH; int DX = object.getX() - player.getX(); int DY = object.getY() - player.getY(); if (!isWall && (rotation == 1 || rotation == 3) || isWall && (rotation == 0 || rotation == 2)) { if (DX >= 0) { xExtra += totalDistance; direction = Direction.EAST; } else if (DX < 0) { xExtra -= totalDistance; direction = Direction.WEST; } } else if (DY >= 0) { yExtra += totalDistance; direction = Direction.NORTH; } else if (DY < 0) { yExtra -= totalDistance; direction = Direction.SOUTH; } final Tile toTile = Tile.of(player.getX() + xExtra, player.getY() + yExtra, player.getPlane()); final Direction finalDir = direction; player.forceMove(toTile, object.getId() == 39602 ? 6132 : 10590, 5, 60, () -> player.setFaceAngle(WorldUtil.getAngleTo(finalDir))); } else { final String name = object.getDefinitions().getName().toLowerCase(); final int clayQuality = Integer.parseInt(name.substring(name.indexOf(""(class"")).replace(""(class "", """").replace("")"", """")) - 1; final CreationChunks skill = CreationChunks.valueOf(name.replace("" (class "" + (clayQuality + 1) + "")"", """").toUpperCase()); player.getActionManager().setAction(new PlayerAction() { Item bestItem; int itemTier; @Override public boolean start(Player player) { if (name.contains((""empty""))) return false; else if (player.getSkills().getLevel(skill.getRequestedSkill()) < clayQuality * 20) { player.sendMessage(""You need a "" + Constants.SKILL_NAME[skill.getRequestedSkill()] + "" level of "" + clayQuality * 20 + "" to collect this level of clay.""); return false; } itemLoop: for (int index = 4; index >= 0; index--) { int baseItem = skill.getBaseItem(); if (baseItem == -1) break itemLoop; Item bestItem = new Item(baseItem + (index * 2), 1); if (player.getEquipment().getWeaponId() == bestItem.getId() || player.getInventory().containsItem(bestItem.getId(), bestItem.getAmount())) if (player.getSkills().getLevel(skill.getRequestedSkill()) >= index * 20) { this.bestItem = bestItem; itemTier = index; break itemLoop; } } setActionDelay(player, getActionDelay()); return true; } @Override public boolean process(Player player) { if (game.isEmpty(flagX, flagY) || player.getInventory().getFreeSlots() == 0) return false; player.setNextAnimation(bestItem != null ? new Animation(skill.getBaseAnimation() + itemTier) : new Animation(10602)); player.setNextFaceTile(object.getTile()); // player.getInventory().addItem(new Item(Helper.SACRED_CLAY[clayQuality], 1)); return true; } @Override public int processWithDelay(Player player) { Score score = game.getScore(player); // if (score == null) // return -1; if (Utils.getRandomInclusive(clayQuality + 1) == 0) game.useSkillPlot(flagX, flagY); player.getInventory().addItem(new Item(Helper.SACRED_CLAY[clayQuality], 1)); if (score != null) { score.updateGathering(15 * (clayQuality + 1)); sendScore(score); } return getActionDelay(); } private int getActionDelay() { if (clayQuality == 0) return 2; int baseTime = Helper.OBJECT_TIERS[clayQuality]; int mineTimer = baseTime - player.getSkills().getLevel(skill.getRequestedSkill()) - (bestItem == null ? 1 : Helper.TOOL_TIERS[itemTier]); if (mineTimer < 2) mineTimer = 2; return mineTimer; } @Override public void stop(Player player) { setActionDelay(player, 3); } }); } return false; } enum CreationChunks { FRAGMENTS(10602, -1, Constants.HUNTER), TREE(10603, 14132, Constants.WOODCUTTING), ROCK(10608, 14122, Constants.MINING), POOL(10613, 14142, Constants.FISHING), SWARM(10618, 14152, Constants.HUNTER); private final int baseAnimation; private final int baseItem; private final int skillRequested; private CreationChunks(int baseAnimation, int baseItem, int skillRequested) { this.baseAnimation = baseAnimation; this.baseItem = baseItem; this.skillRequested = skillRequested; } public int getBaseAnimation() { return baseAnimation; } public int getBaseItem() { return baseItem; } public int getRequestedSkill() { return skillRequested; } } @Override public boolean processObjectClick2(GameObject object) { boolean isFriendlySCGate = false; gateLoop: for (int[] gateIDS : (getTeam() ? Helper.RED_BARRIER_GATES : Helper.BLUE_BARRIER_GATES)) for (int id : gateIDS) if (object.getId() == id) { isFriendlySCGate = true; break gateLoop; } if (object.getId() == Helper.EMPTY_BARRIER1 || object.getId() == Helper.EMPTY_BARRIER2 || object.getId() == Helper.EMPTY_BARRIER3) { boolean redTeam = getTeam(); int tier = -1; for (int i = 4; i >= 0; i--) if (player.getInventory().containsItem(Helper.BARRIER_ITEMS[i], 4)) { tier = i; break; } if (tier == -1) { player.sendMessage(""You don't have enough barrier items to build.""); return false; } final int t = tier; final int x = object.getTile().getChunkX() - (game.getArea().getMinX() >> 3); final int y = object.getTile().getChunkY() - (game.getArea().getMinY() >> 3); for (Player otherPlayer : redTeam ? game.getBlueTeam() : game.getRedTeam()) { if (otherPlayer == null || !otherPlayer.withinDistance(object.getTile(), 6)) continue; if (Helper.withinArea(otherPlayer, game.getArea(), x, y, new int[] { 2, 2 })) { player.sendMessage(""You cannot build a barrier while players from the other team are near the pallet.""); return false; } otherPlayer.resetWalkSteps(); otherPlayer.lock(3); } player.lock(2); WorldTasks.scheduleLooping(new Task() { private int step = 0; @Override public void run() { if (step == 0) { player.setNextAnimation(new Animation(10589)); step++; } else if (step == 1) { if (player.getInventory().containsItem(new Item(Helper.BARRIER_ITEMS[t], 4)) && !game.buildBarrier(getTeam(), t + 1, x, y)) { player.getInventory().removeItems(new Item(Helper.BARRIER_ITEMS[t], 4)); player.getInventory().addItem(new Item(Helper.BARRIER_ITEMS[t], 4)); } player.unlock(); stop(); } } }, 0, 0); return false; } if (isFriendlySCGate) { passWall(player, object, getTeam()); return false; } return true; } @Override public boolean processObjectClick3(GameObject object) { boolean isFriendlySCGate = false; boolean isFriendlySCWall = false; gateLoop: for (int[] gateIDS : (getTeam() ? Helper.RED_BARRIER_GATES : Helper.BLUE_BARRIER_GATES)) for (int id : gateIDS) if (object.getId() == id) { isFriendlySCGate = true; break gateLoop; } wallLoop: for (int[] gateIDS : (getTeam() ? Helper.RED_BARRIER_WALLS : Helper.BLUE_BARRIER_WALLS)) for (int id : gateIDS) if (object.getId() == id) { isFriendlySCWall = true; break wallLoop; } if (isFriendlySCGate || isFriendlySCWall) { final int x = object.getTile().getChunkX() - (game.getArea().getMinX() >> 3); final int y = object.getTile().getChunkY() - (game.getArea().getMinY() >> 3); synchronized (game.getLock()) { final int team = game.getArea().getWallTeam(x, y); final int tier = game.getArea().getWallTier(x, y); final int health = game.getArea().getWallStatus(x, y); if (team != (getTeam() ? 2 : 1)) return false; if (health <= 0 || health >= (tier * 4)) { player.sendMessage(""This barrier doesn't need any repairing.""); return false; } if (!player.getInventory().containsItem(Helper.BARRIER_ITEMS[tier - 1], 1)) { player.sendMessage(""You don't have enough barriers of required type to repair this barrier.""); return false; } player.lock(2); WorldTasks.scheduleLooping(new Task() { private int step = 0; @Override public void run() { if (step == 0) { player.setNextAnimation(new Animation(10589)); step++; } else if (step == 1) { if (player.getInventory().containsItem(new Item(Helper.BARRIER_ITEMS[tier - 1], 1)) && !game.repairBarrier(x, y)) { player.getInventory().removeItems(new Item(Helper.BARRIER_ITEMS[tier - 1], 1)); player.getInventory().addItem(new Item(Helper.BARRIER_ITEMS[tier - 1], 1)); } player.unlock(); stop(); } } }, 0, 0); } return false; } return true; } public static void passWall(Player player, GameObject object, final boolean red) { if (player.hasEffect(Effect.FREEZE)) { player.sendMessage(""A mysterious force prevents you from moving.""); return; } player.lock(3); if (!Helper.setWalkToGate(object, player)) player.unlock(); final Player p = player; final GameObject o = object; WorldTasks.scheduleLooping(new Task() { private int step = 0; @Override public void run() { if (step == 0 && !Helper.isAtGate(o, p)) { if (!p.hasWalkSteps() && p.getNextWalkDirection() == null) { // unstuck stop(); p.unlock(); } return; } if (step == 0) { Tile faceTile = Helper.getFaceTile(o, p); p.sendMessage(""You pass through the barrier.""); p.tele(faceTile); p.forceMove(faceTile, 10584, 5, 30); p.setNextSpotAnim(new SpotAnim(red ? 1871 : 1870)); step++; } else if (step == 1) { stop(); p.unlock(); } } }, 0, 0); } @Override public boolean sendDeath() { WorldTasks.scheduleLooping(new Task() { int loop; @Override public void run() { if (loop == 0) player.setNextAnimation(new Animation(836)); else if (loop == 1) { if (player.getFamiliar() != null) player.getFamiliar().sendDeath(player); } else if (loop == 3) { Score score = game.getScore(player); Player killer = player.getMostDamageReceivedSourcePlayer(); if (killer != null) { Score killerScore = game.getScore(killer); if (killerScore != null) killerScore.updateKilled(1); killer.removeDamage(player); if (killerScore != null) killer.sendMessage(""You have killed "" + player.getDisplayName() + "", you now have "" + killerScore.getKilled() + "" kills.""); player.sendMessage(""You have been killed by "" + killer.getDisplayName()); } player.getEquipment().deleteSlot(Equipment.CAPE); player.sendPVEItemsOnDeath(killer, true); player.tele(Helper.getNearestRespawnPoint(player, game.getArea(), getTeam())); player.stopAll(); player.reset(); if (score != null) { score.updateDied(1); sendScore(score); } player.setNextAnimation(new Animation(-1)); } else if (loop == 4) { Helper.giveCape(player, getTeam()); player.jingle(90); player.resetWalkSteps(); stop(); } loop++; } }, 0, 1); return false; } public void processKilnExchange(int componentId, ClientPacket packet) { int quality = player.getTempAttribs().getI(""sc_kiln_quality"", 0); int clayId = Helper.SACRED_CLAY[quality]; int amount = 0; if (packet == ClientPacket.IF_OP1) amount = 1; else if (packet == ClientPacket.IF_OP2) amount = 5; else if (packet == ClientPacket.IF_OP3) { player.getTempAttribs().setI(""sc_component"", componentId); player.getTempAttribs().setB(""kilnX"", true); player.getPackets().sendRunScriptReverse(108, ""Enter Amount:""); } else if (packet == ClientPacket.IF_OP4) amount = player.getInventory().getAmountOf(clayId); else amount = player.getTempAttribs().getI(""sc_amount_making""); if (Helper.checkSkillRequriments(player, Helper.getRequestedKilnSkill(componentId - 37), quality)) if ((amount != 0 && Helper.proccessKilnItems(player, componentId, quality, clayId, amount))) { Score score = game.getScore(player); if (score == null) return; score.updateProcessing(15 * quality); sendScore(score); return; } } @Override public void forceClose() { if (game != null) game.remove(player); else Helper.sendHome(player); } public StealingCreationGameController getGame() { return game; } public boolean getTeam() { return team; } }" "package com.rs.game.content.minigames.creations; /** * Instance of a single stealing creation game. * * @author mgi125, the almighty */ public class StealingCreationGameController { /** * Contains game area. */ private final GameArea area; /** * Contains game logic lock object. */ private final Object logicLock = new Object(); /** * Contains players in blue team. */ private final transient List blueTeam; /** * Contains player in red team. */ private final transient List redTeam; /** * Contains scores. */ private final Map scores; /** * Time when this game ends. */ private long endTime; /** * Contains game state. 0 - Not started 1 - Starting 2 - Running 3 - Ending 4 - * Ended */ private volatile int state; /** * Barriers degradation tick. */ private int degradationTick; public StealingCreationGameController(int areaSize, List blue, List red) { blueTeam = blue; redTeam = red; lockPeople(-1); scores = new HashMap<>(); for (Player player : blueTeam) scores.put(player, new Score(player.getDisplayName(), false)); for (Player player : redTeam) scores.put(player, new Score(player.getDisplayName(), true)); area = new GameArea(areaSize); area.calculate(); start(); } /* * 0 not running 1 creating 2 game started */ /** * Run's the game logic. */ public void run() { if (state == 2) { // stage 2 means runnning game if (System.currentTimeMillis() >= endTime) { stop(); return; } synchronized (logicLock) { if (++degradationTick == 32) { playMusic(); degradationTick = 0; int size = area.getSize(); for (int x = 0; x < size; x++) for (int y = 0; y < size; y++) damageBarrier(x, y); } } } } public void playMusic() { for (Player player : blueTeam) player.getMusicsManager().playSongAndUnlock(578); for (Player player : redTeam) player.getMusicsManager().playSongAndUnlock(578); } /** * Remove's given player from game. */ public void remove(Player player) { if (state != 2) // must be in state 2 to be removed during game lol return; synchronized (logicLock) { if (blueTeam.contains(player)) blueTeam.remove(player); else if (redTeam.contains(player)) redTeam.remove(player); player.getTempAttribs().setL(""SC_PENALTY"", System.currentTimeMillis() + Helper.PENALTY_DURATION); Helper.sendHome(player); // no players on a team so game ends sooner no? ye if (redTeam.size() == 0 || blueTeam.size() == 0) stop(); } } /** * Tries to build barrier at given tile. */ public boolean buildBarrier(boolean team, int tier, int x, int y) { synchronized (logicLock) { if (area.getWallTeam(x, y) != 0) return false; displayWall(team, tier, x, y, 0); area.setWallTeam(x, y, team ? 2 : 1); area.setWallTier(x, y, tier); area.setWallStatus(x, y, tier * 4); return true; } } /** * Tries to repair barrier at given tile. */ public boolean repairBarrier(int x, int y) { synchronized (logicLock) { if (area.getWallTeam(x, y) == 0) return false; int tier = area.getWallTier(x, y); int health = area.getWallStatus(x, y); if (health <= 0 && health >= (tier * 4)) return false; int newHealth = health + 4; if (newHealth >= (tier * 4)) newHealth = tier * 4; int newDamage = (int) (4D - (4D * (newHealth / (tier * 4D)))); area.setWallStatus(x, y, newHealth); displayWall(area.getWallTeam(x, y) == 2 ? true : false, tier, x, y, newDamage); return true; } } /** * Tries to damage barrier at given tile. */ public boolean damageBarrier(int x, int y) { synchronized (logicLock) { if (area.getWallTeam(x, y) == 0) return false; int health = area.getWallStatus(x, y); if (health <= 0) return false; int tier = area.getWallTier(x, y); int oldDamage = (int) (4D - (4D * (health / (tier * 4D)))); int newHealth = health - 1; if (newHealth > 1) { int newDamage = (int) (4D - (4D * (newHealth / (tier * 4D)))); area.setWallStatus(x, y, newHealth); if (oldDamage != newDamage) displayWall(area.getWallTeam(x, y) == 2 ? true : false, tier, x, y, newDamage); } else { area.setWallTeam(x, y, 0); area.setWallTier(x, y, 0); area.setWallStatus(x, y, 0); displayWall(false, 0, x, y, 0); } return true; } } /** * Use's skill plot and degrades it. */ public boolean useSkillPlot(int x, int y) { synchronized (logicLock) { int type = area.getType(x, y); int tier = area.getTier(x, y); int degradation = area.getDegradation(x, y); if (type < 9 || type > 12 || tier < 1 || tier > 5 || degradation < 1) return false; int newDegradation = degradation - 1; int newLook = newDegradation > 30 ? 0 : (newDegradation > 0 ? 1 : 2); area.setDegradation(x, y, newDegradation); updateSkillPlot(x, y, newLook); return true; } } public boolean isEmpty(int x, int y) { return area.getDegradation(x, y) == 0; } public void updateSkillPlot(int x, int y, int look) { synchronized (logicLock) { int minX = area.getMinX() + (x << 3) + Helper.BARRIER_MIN[0]; int minY = area.getMinY() + (y << 3) + Helper.BARRIER_MIN[1]; int type = area.getType(x, y); int tier = area.getTier(x, y); if (type < 9 || type > 12 || tier < 1 || tier > 5) return; int[] objects = (type == 9 ? Helper.ROCK_SPOTS : (type == 10 ? Helper.TREE_SPOTS : (type == 11 ? Helper.POOL_SPOTS : Helper.SWARM_SPOTS)))[tier - 1]; int startX = minX + Helper.PLOT_OBJECT_BASE[0]; int startY = minY + Helper.PLOT_OBJECT_BASE[1]; for (int testX = startX - 1; testX < (startX + 2); testX++) for (int testY = startY - 1; testY < (startY + 2); testY++) for (int a = 0; a < objects.length; a++) { GameObject obj = World.getObjectWithId(Tile.of(testX, testY, 0), objects[a]); if (obj != null) { if (a != look) World.spawnObject(new GameObject(objects[look], obj.getType(), obj.getRotation(), obj.getTile())); return; } } } } public void displayWall(boolean team, int tier, int x, int y, int damage) { synchronized (logicLock) { int minX = area.getMinX() + (x << 3) + Helper.BARRIER_MIN[0]; int minY = area.getMinY() + (y << 3) + Helper.BARRIER_MIN[1]; int maxX = area.getMinX() + (x << 3) + Helper.BARRIER_MAX[0]; int maxY = area.getMinY() + (y << 3) + Helper.BARRIER_MAX[1]; if (tier == 0) { World.spawnObject(new GameObject(Helper.EMPTY_BARRIER1, ObjectType.WALL_DIAGONAL_CORNER, 1, Tile.of(minX, minY, 0))); World.spawnObject(new GameObject(Helper.EMPTY_BARRIER1, ObjectType.WALL_DIAGONAL_CORNER, 2, Tile.of(minX, maxY, 0))); World.spawnObject(new GameObject(Helper.EMPTY_BARRIER1, ObjectType.WALL_DIAGONAL_CORNER, 3, Tile.of(maxX, maxY, 0))); World.spawnObject(new GameObject(Helper.EMPTY_BARRIER1, ObjectType.WALL_DIAGONAL_CORNER, 0, Tile.of(maxX, minY, 0))); for (x = minX + 1; x <= maxX - 1; x++) { World.spawnObject(new GameObject(Helper.EMPTY_BARRIER1, ObjectType.WALL_STRAIGHT, 1, Tile.of(x, minY, 0))); World.spawnObject(new GameObject(Helper.EMPTY_BARRIER1, ObjectType.WALL_STRAIGHT, 3, Tile.of(x, maxY, 0))); } for (y = minY + 1; y <= maxY - 1; y++) { World.spawnObject(new GameObject(Helper.EMPTY_BARRIER1, ObjectType.WALL_STRAIGHT, 2, Tile.of(minX, y, 0))); World.spawnObject(new GameObject(Helper.EMPTY_BARRIER1, ObjectType.WALL_STRAIGHT, 0, Tile.of(maxX, y, 0))); } } else { int wallID = team ? Helper.RED_BARRIER_WALLS[tier - 1][damage] : Helper.BLUE_BARRIER_WALLS[tier - 1][damage]; int gate1ID = team ? Helper.RED_BARRIER_GATES[tier - 1][0] : Helper.BLUE_BARRIER_GATES[tier - 1][0]; int gate2ID = team ? Helper.RED_BARRIER_GATES[tier - 1][1] : Helper.BLUE_BARRIER_GATES[tier - 1][1]; World.spawnObject(new GameObject(wallID, ObjectType.WALL_STRAIGHT, 2, Tile.of(minX, minY + 1, 0))); World.spawnObject(new GameObject(wallID, ObjectType.WALL_STRAIGHT, 2, Tile.of(minX, minY + 4, 0))); World.spawnObject(new GameObject(wallID, ObjectType.WALL_STRAIGHT, 0, Tile.of(maxX, minY + 1, 0))); World.spawnObject(new GameObject(wallID, ObjectType.WALL_STRAIGHT, 0, Tile.of(maxX, minY + 4, 0))); World.spawnObject(new GameObject(wallID, ObjectType.WALL_STRAIGHT, 1, Tile.of(minX + 1, minY, 0))); World.spawnObject(new GameObject(wallID, ObjectType.WALL_STRAIGHT, 1, Tile.of(minX + 4, minY, 0))); World.spawnObject(new GameObject(wallID, ObjectType.WALL_STRAIGHT, 3, Tile.of(minX + 1, maxY, 0))); World.spawnObject(new GameObject(wallID, ObjectType.WALL_STRAIGHT, 3, Tile.of(minX + 4, maxY, 0))); // corners World.spawnObject(new GameObject(wallID, ObjectType.WALL_DIAGONAL_CORNER, 1, Tile.of(minX, minY, 0))); World.spawnObject(new GameObject(wallID, ObjectType.WALL_DIAGONAL_CORNER, 2, Tile.of(minX, maxY, 0))); World.spawnObject(new GameObject(wallID, ObjectType.WALL_DIAGONAL_CORNER, 0, Tile.of(maxX, minY, 0))); World.spawnObject(new GameObject(wallID, ObjectType.WALL_DIAGONAL_CORNER, 3, Tile.of(maxX, maxY, 0))); // -------- // gates // west World.spawnObject(new GameObject(gate1ID, ObjectType.WALL_STRAIGHT, 2, Tile.of(minX, minY + 3, 0))); World.spawnObject(new GameObject(gate2ID, ObjectType.WALL_STRAIGHT, 2, Tile.of(minX, minY + 2, 0))); // east World.spawnObject(new GameObject(gate2ID, ObjectType.WALL_STRAIGHT, 0, Tile.of(maxX, minY + 3, 0))); World.spawnObject(new GameObject(gate1ID, ObjectType.WALL_STRAIGHT, 0, Tile.of(maxX, minY + 2, 0))); // south World.spawnObject(new GameObject(gate1ID, ObjectType.WALL_STRAIGHT, 1, Tile.of(minX + 2, minY, 0))); World.spawnObject(new GameObject(gate2ID, ObjectType.WALL_STRAIGHT, 1, Tile.of(minX + 3, minY, 0))); // north World.spawnObject(new GameObject(gate2ID, ObjectType.WALL_STRAIGHT, 3, Tile.of(minX + 2, maxY, 0))); World.spawnObject(new GameObject(gate1ID, ObjectType.WALL_STRAIGHT, 3, Tile.of(minX + 3, maxY, 0))); // -------- } } } /** * Update's given player score. */ public void updateScore(Player player, int dGathering, int dProcessing, int dDepositing, int dWithdrawing, int dDamaging, int dKills, int dDeaths) { synchronized (logicLock) { Score score = scores.get(player); if (score == null) return; score.updateGathering(dGathering); score.updateProcessing(dProcessing); score.updateDepositing(dDepositing); score.updateWithdrawing(dWithdrawing); score.updateDamaging(dDamaging); score.updateKilled(dKills); score.updateDied(dDeaths); Controller controller = player.getControllerManager().getController(); if (controller instanceof StealingCreationController ctrl) ctrl.sendScore(score); } } public void sendItemToBase(Player player, Item item, boolean team, boolean BOB, boolean clicked) { Score score = getScore(player); if (score == null) return; int size = getArea().getSize(); int[] base = Helper.findNearestBase(getArea(), player, team); int[] entrance; if ((base[0] == 0 && base[1] == 0) || (base[0] == (size - 1) && base[1] == (size - 1))) entrance = team ? Helper.BASE_ENTRANCE_RED : Helper.BASE_ENTRANCE_BLUE; else entrance = Helper.PLOT_ENTRANCES[Utils.random(Helper.PLOT_ENTRANCES.length)]; String name = item.getName().toLowerCase(); int index = Helper.getItemIndex(name); if (clicked && index == 2 || index == -1) return; Tile tile = Tile.of(getArea().getMinX() + (base[0] * 8) + entrance[0], getArea().getMinY() + (base[1] * 8) + entrance[1], 0); for (GameObject object : World.getAllObjectsInChunkRange(tile.getChunkId(), 5)) { if (object == null || object.getId() != 39534 + index || !object.getTile().withinDistance(tile, 30)) continue; int nameIndex = name.indexOf(""(class""); int clayQuality = 1; if (nameIndex != -1) clayQuality = index == 9 ? 1 : Integer.parseInt(name.substring(nameIndex).replace(""(class "", """").replace("")"", """")); score.updateDepositing(((item.getDefinitions().isStackable() ? 1 : 30) * clayQuality) * item.getAmount()); if (BOB) player.getFamiliar().removeItem(item); else player.getInventory().deleteItem(item); World.addGroundItem(item, object.getTile()); Controller controller = player.getControllerManager().getController(); if (controller instanceof StealingCreationController ctrl) ctrl.sendScore(score); break; } } /** * Happens when game starts. */ public void gameStartup() { synchronized (logicLock) { state = 2; final StealingCreationGameController game = this; for (final Player player : blueTeam) { Helper.spawn(this, player, false); WorldTasks.schedule(new Task() { @Override public void run() { player.getControllerManager().startController(new StealingCreationController(game, false)); Helper.giveCape(player, false); } }, 1); } for (final Player player : redTeam) { Helper.spawn(this, player, true); WorldTasks.schedule(new Task() { @Override public void run() { player.getControllerManager().startController(new StealingCreationController(game, true)); Helper.giveCape(player, true); } }, 1); } } } /** * Happens when game ends. */ public void gameShutdown() { synchronized (logicLock) { final ArrayList allScores = new ArrayList<>(scores.values()); int totalBlue = Score.totalXP(allScores, false, false); int totalRed = Score.totalXP(allScores, true, false); final int winner = totalBlue > totalRed ? 1 : (totalBlue == totalRed ? 0 : 2); lockPeople(7); WorldTasks.schedule(new Task() { @Override public void run() { for (Player player : blueTeam) { Score personal = getScore(player); Helper.sendHome(player); Helper.displayScores(player, false, personal, allScores, winner); Helper.awardPoints(player, personal, winner); } for (Player player : redTeam) { Score personal = getScore(player); Helper.sendHome(player); Helper.displayScores(player, true, personal, allScores, winner); Helper.awardPoints(player, personal, winner); } WorldTasks.schedule(2, () -> { try { area.destroy(); } catch (Throwable e) { Logger.handle(StealingCreationGameController.class, ""gameShutdown"", e); } }); } }, 6); } } public void lockPeople(int time) { for (Player player : blueTeam) { player.lock(time); player.stopAll(); } for (Player player : redTeam) { player.lock(time); player.stopAll(); } } /** * Start's game, should be called on SLOW executor. */ public synchronized void start() { if (state != 0) throw new RuntimeException(""Game already running!""); state = 1; // so it wont start again while creating area rofl area.create(() -> { endTime = System.currentTimeMillis() + Helper.DURATION; gameStartup(); }); } /** * Stop's game, should be called on SLOW executor. */ public synchronized void stop() { if (state == 0) throw new RuntimeException(""Game not running!""); StealingCreationManager.removeGame(this); gameShutdown(); state = 0; } public Score getScore(Player player) { for (Entry entry : scores.entrySet()) { Player entryPlayer = entry.getKey(); if (entryPlayer.getIndex() == player.getIndex()) return entry.getValue(); } return null; } public GameArea getArea() { return area; } public int getState() { return state; } public long getEndTime() { return endTime; } public Object getLock() { return logicLock; } public List getBlueTeam() { return blueTeam; } public List getRedTeam() { return redTeam; } }" "package com.rs.game.content.minigames.creations; public class StealingCreationLobby { private static final int[] TOTAL_SKILL_IDS = { Constants.WOODCUTTING, Constants.MINING, Constants.FISHING, Constants.HUNTER, Constants.COOKING, Constants.HERBLORE, Constants.CRAFTING, Constants.SMITHING, Constants.FLETCHING, Constants.RUNECRAFTING, Constants.CONSTRUCTION }; private static final int[] TOTAL_COMBAT_IDS = { Constants.ATTACK, Constants.STRENGTH, Constants.DEFENSE, Constants.HITPOINTS, Constants.RANGE, Constants.MAGIC, Constants.PRAYER, Constants.SUMMONING }; private static List redTeam, blueTeam; private static LobbyTimer lobbyTask; static { reset(); } private static class LobbyTimer extends Task { public int minutes; public LobbyTimer() { minutes = 2; } @Override public void run() { minutes--; if (minutes == 0) { passToGame(); // cancel since all players left removeTask(); return; } updateInterfaces(); } public int getMinutes() { return minutes; } private void passToGame() { // should be safe right? StealingCreationManager.createGame(8, blueTeam, redTeam); reset(); } } public static void reset() { redTeam = new ArrayList<>(); blueTeam = new ArrayList<>(); } private static boolean hasRequiredPlayers() { if (redTeam.size() >= 1 && blueTeam.size() >= 1) return true; return false; } public static boolean enterTeamLobby(Player player, boolean onRedTeam) { if (!canEnter(player, onRedTeam)) return false; if (onRedTeam) { if (!redTeam.contains(player)) redTeam.add(player); } else if (!blueTeam.contains(player)) blueTeam.add(player); if (hasRequiredPlayers() && lobbyTask == null)// saves performance WorldTasks.scheduleLooping(lobbyTask = new LobbyTimer(), Ticks.fromMinutes(1), Ticks.fromMinutes(1)); player.getControllerManager().startController(new StealingCreationLobbyController()); updateInterfaces(); return true; } public static void removePlayer(Player player) { if (redTeam.contains(player)) redTeam.remove(player); else if (blueTeam.contains(player)) blueTeam.remove(player); if (!hasRequiredPlayers()) removeTask(); player.getInterfaceManager().removeOverlay(false); player.getControllerManager().removeControllerWithoutCheck(); updateInterfaces(); } public static void removeTask() { if (lobbyTask == null) return; lobbyTask.stop(); lobbyTask = null; } public static void updateInterfaces() { for (Player player : redTeam) updateTeamInterface(player, true); for (Player player : blueTeam) updateTeamInterface(player, false); } public static void updateTeamInterface(Player player, boolean inRedTeam) { int skillTotal = getTotalLevel(TOTAL_SKILL_IDS, inRedTeam); int combatTotal = getTotalLevel(TOTAL_COMBAT_IDS, inRedTeam); int otherSkillTotal = getTotalLevel(TOTAL_SKILL_IDS, !inRedTeam); int otherCombatTotal = getTotalLevel(TOTAL_COMBAT_IDS, !inRedTeam); if (lobbyTask != null) { player.getPackets().setIFHidden(804, 2, true); player.getPackets().setIFText(804, 1, ""Game Start : "" + lobbyTask.getMinutes() + "" mins""); } else { player.getPackets().setIFHidden(804, 2, false); int players = 5 - (inRedTeam ? redTeam.size() : blueTeam.size()); player.getPackets().setIFText(804, 34, String.valueOf(players < 0 ? 0 : players)); players = 5 - (inRedTeam ? blueTeam.size() : redTeam.size()); player.getPackets().setIFText(804, 33, String.valueOf(players < 0 ? 0 : players)); } player.getPackets().setIFText(804, 4, """" + skillTotal); player.getPackets().setIFText(804, 5, """" + combatTotal); player.getPackets().setIFText(804, 6, """" + otherCombatTotal); player.getPackets().setIFText(804, 7, """" + otherSkillTotal); } private static boolean canEnter(Player player, boolean inRedTeam) { int skillTotal = getTotalLevel(TOTAL_SKILL_IDS, inRedTeam); int combatTotal = getTotalLevel(TOTAL_COMBAT_IDS, inRedTeam); int otherSkillTotal = getTotalLevel(TOTAL_SKILL_IDS, !inRedTeam); int otherCombatTotal = getTotalLevel(TOTAL_COMBAT_IDS, !inRedTeam); if ((skillTotal + combatTotal) > (otherSkillTotal + otherCombatTotal)) { player.sendMessage(""This team is too strong for you to join at present.""); return false; } if (player.getEquipment().wearingArmour() || player.getInventory().getFreeSlots() != 28 || player.getFamiliar() != null || player.getPet() != null) { player.sendMessage(""You may not take any items into Stealing Creation. You can use the nearby bank deposit bank to empty your inventory and storn wore items.""); return false; // } else if (player.getMoneyPouch().getCoinsAmount() != 0) { // player.sendMessage(""The mystics sneer at your greed, as you // try to smuggle coins in.""); // player.sendMessage(""Deposite your money pouch's coins at the // local deposite box near you.""); // return false; } if (player.getTempAttribs().getL(""SC_PENALTY"") >= System.currentTimeMillis()) { player.simpleDialogue(""You have betrayed the mystics and must wait "" + (int) (player.getTempAttribs().getL(""SC_PENALTY"") / 60000) + ""minutes.""); return false; } return true; } private static int getTotalLevel(int[] ids, boolean inRedTeam) { int skillTotal = 0; for (Player player : inRedTeam ? redTeam : blueTeam) { if (player == null) continue; for (int skillRequested : ids) skillTotal += player.getSkills().getLevel(skillRequested); } return skillTotal; } public static List getRedTeam() { return redTeam; } public static List getBlueTeam() { return blueTeam; } }" "package com.rs.game.content.minigames.creations; public class StealingCreationLobbyController extends Controller { @Override public void start() { sendInterfaces(); } @Override public void sendInterfaces() { player.getInterfaceManager().sendOverlay(804, false); StealingCreationLobby.updateTeamInterface(player, false); } @Override public boolean canTakeItem(GroundItem item) { return false; } @Override public boolean processObjectClick1(GameObject object) { if (object.getId() == 39508 || object.getId() == 39509) { player.getControllerManager().forceStop(); climbOverStile(player, object, false); return false; } return true; } public static void climbOverStile(final Player player, final GameObject object, final boolean enterance) { player.lock(3); if (enterance) { if (!StealingCreationLobby.enterTeamLobby(player, object.getId() == 39509)) return; } else StealingCreationLobby.removePlayer(player); player.forceMove(Tile.of(enterance ? object.getX() : object.getX() + 2, object.getY(), object.getPlane()), 1560, 5, 60); } @Override public boolean processTeleport(Teleport tele) { if (tele.type() != TeleType.OBJECT) { player.simpleDialogue(""A magical force prevents you from teleporting from the arena.""); return false; } return true; } @Override public void onTeleported(TeleType type) { StealingCreationLobby.removePlayer(player); } @Override public void forceClose() { player.getInterfaceManager().removeOverlay(); StealingCreationLobby.removePlayer(player); } @Override public boolean logout() { StealingCreationLobby.removePlayer(player); player.tele(Helper.EXIT); return true; } @Override public boolean login() { StealingCreationLobby.removePlayer(player); player.tele(Helper.EXIT); return true; } }" "package com.rs.game.content.minigames.creations; public class StealingCreationMagic extends Conversation { public StealingCreationMagic(Player player) { super(player); addOptions(""Select a magical weapon."", ops -> { ops.add(""Magic staff"").addOptions(staves -> { for (int i = 0;i < 5;i++) staves.add(""Class "" + (i + 1)); //TODO 14377 + (i*2) }); ops.add(""Elemental rune"", () -> player.sendInputInteger(""How many do you want to request?"", num -> { /* TODO 12850 */})); ops.add(""Catalytic rune"", () -> player.sendInputInteger(""How many do you want to request?"", num -> { /* TODO 12851 */})); }); } }" "package com.rs.game.content.minigames.creations; public class StealingCreationManager { private static final List running = new CopyOnWriteArrayList<>(); private static Task watcher; public synchronized static void createGame(int size, List blueTeam, List redTeam) { running.add(new StealingCreationGameController(size, blueTeam, redTeam)); if (watcher == null) WorldTasks.scheduleLooping(watcher = new Task() { @Override public void run() { try { processWatcher(); } catch (Throwable e) { Logger.handle(StealingCreationManager.class, ""createGame"", e); } } }, 0, 1); } /** * Processes watcher thread. */ private static void processWatcher() { for (StealingCreationGameController game : running) game.run(); } public static void removeGame(StealingCreationGameController game) { running.remove(game); if (running.size() == 0) { watcher.stop(); watcher = null; } } }" "package com.rs.game.content.minigames.creations; public class StealingCreationManagerD extends Conversation { public StealingCreationManagerD(Player player, StealingCreationGameController game, NPC npc) { super(player); player.heal(player.getMaxHitpoints()); player.getPoison().reset(); addNPC(npc.getId(), HeadE.ANGRY, Utils.random(3) == 0 ? ""It's close. It could be anyone's game."" : ""Get a move on! Gather some clay before the other team takes it all!""); addOptions(ops -> { ops.add(""Show me the remaining clay."", () -> Helper.displayClayStatus(game.getArea(), player)); ops.add(""I want to quit!"") .addNPC(npc.getId(), HeadE.CONFUSED, ""Are you sure you want to quit? You will not score any points if you leave."") .addOption(""Are you sure you want to quit?"", ""Yes, I want to quit."", ""No, I want to stay."") .addNext(() -> player.getControllerManager().forceStop()); ops.add(""Nevermind.""); }); } }" "package com.rs.game.content.minigames.creations; public class StealingCreationRange extends Conversation { public StealingCreationRange(Player player) { super(player); addOptions(""Select a range weapon."", ops -> { ops.add(""Bow"").addOptions(staves -> { for (int i = 0;i < 5;i++) staves.add(""Class "" + (i + 1)); //TODO 14192 + (i*2) }); ops.add(""Arrows"").addOptions(staves -> { for (int i = 0;i < 5;i++) staves.add(""Class "" + (i + 1), () -> player.sendInputInteger(""How many do you want to request?"", num -> { /* TODO 14202 + i */})); }); }); } }" "package com.rs.game.content.minigames.creations; @PluginEventHandler public class StealingCreationShop { private static final int[] POINTS_COST = { 20, 20, 30, 28, 24, 26, 200 }; private static final int[] DEFAULT_PRODUCTS = { 14098, 14106, 14094, 14095, 14096, 14097, 21527 }; public static void openInterface(final Player player) { refresh(player); player.getInterfaceManager().sendInterface(1128); player.getPackets().sendRunScriptBlank(5248); player.getPackets().setIFHidden(1128, 330, true); player.getPackets().setIFText(1128, 13, """" + player.scPoints); player.setCloseInterfacesEvent(() -> resetSelection(player)); } public static ButtonClickHandler handleButtons = new ButtonClickHandler(1128, e -> { int index = -1; if (e.getComponentId() == 98 || e.getComponentId() == 4) index = 0; else if (e.getComponentId() == 128 || e.getComponentId() == 106) index = 1; else if (e.getComponentId() == 144 || e.getComponentId() == 166) index = 2; else if (e.getComponentId() == 203 || e.getComponentId() == 181) index = 3; else if (e.getComponentId() == 240 || e.getComponentId() == 218) index = 4; else if (e.getComponentId() == 277 || e.getComponentId() == 255) index = 5; else if (e.getComponentId() == 292 || e.getComponentId() == 314) index = 6; if (index != -1) select(e.getPlayer(), index); purchase(e.getPlayer()); }); public static void select(Player player, int index) { boolean[] selectedList = player.getTempAttribs().getO(""sc_shop_selected""); if (selectedList == null) selectedList = new boolean[7]; if (selectedList[index]) selectedList[index] = false; else selectedList[index] = true; player.getTempAttribs().setO(""sc_shop_selected"", selectedList); } private static void resetSelection(Player player) { player.getTempAttribs().removeO(""sc_shop_selected""); } public static void purchase(Player player) { boolean[] requestedList = player.getTempAttribs().getO(""sc_shop_selected""); if (requestedList == null) { player.sendMessage(""You have nothing selected to purchase / re-charge""); return; } int totalCost = 0; for (int index = 0; index < requestedList.length; index++) if (requestedList[index]) totalCost += POINTS_COST[index]; if (player.scPoints < totalCost) { player.sendMessage(""You don't have enough points.""); resetSelection(player); return; } if (player.getInventory().getFreeSlots() < requestedList.length) { player.sendMessage(""You don't have enough space for the requested items.""); resetSelection(player); return; } for (int index = 0; index < requestedList.length; index++) if (requestedList[index]) player.getInventory().addItem(new Item(DEFAULT_PRODUCTS[index])); player.scPoints -= totalCost; refresh(player); } private static void refresh(Player player) { player.getVars().setVarBit(5505, player.scPoints); } }" "package com.rs.game.content.minigames.crucible; @PluginEventHandler public class Crucible { //1291 = teleport interface //1292 = warning interface //1294-1295 = crucible help interface //1296 = overlay //1297 = rewards //1298 = bounty fee payment //591 classic BH interface public static ObjectClickHandler entrance = new ObjectClickHandler(new Object[]{67052}, e -> e.getPlayer().sendOptionDialogue(""Which Bounty Hunter mode would you like to enter as?"", ops -> { ops.add(""Safe (No items lost on death)"", () -> { e.getPlayer().tele(CrucibleController.getRespawnTile()); e.getPlayer().getControllerManager().startController(new CrucibleController(false)); }); ops.add(""Dangerous (All but one item lost on death)"", () -> { e.getPlayer().tele(CrucibleController.getRespawnTile()); e.getPlayer().getControllerManager().startController(new CrucibleController(true)); }); ops.add(""Nevermind""); })); public static ObjectClickHandler rewardHatch = new ObjectClickHandler(new Object[]{67051}, e -> { switch (e.getOption()) { case ""Knock"" -> e.getPlayer().sendOptionDialogue(ops -> { ops.add(""Help"", () -> e.getPlayer().getInterfaceManager().sendInterface(1295)); ops.add(""Rewards"", () -> e.getPlayer().getInterfaceManager().sendInterface(1297)); }); case ""Knock for rewards"" -> e.getPlayer().getInterfaceManager().sendInterface(1297); } }); public static ObjectClickHandler stairs = new ObjectClickHandler(new Object[]{67050, 67053}, e -> { switch (e.getObjectId()) { case 67050 -> e.getPlayer().useStairs(-1, Tile.of(3359, 6110, 0), 1, 2); case 67053 -> e.getPlayer().useStairs(-1, Tile.of(3120, 3519, 0), 1, 2); } }); public static ButtonClickHandler handleFissureTravel = new ButtonClickHandler(1291, e -> { int fissureIndex = e.getComponentId() - 4; if (fissureIndex < 0 || fissureIndex >= Fissure.values().length) return; useFissure(e.getPlayer(), Fissure.values()[fissureIndex]); }); private static final Set SAFE_PLAYERS = ObjectSets.synchronize(new ObjectOpenHashSet<>()); private static final Set DANGEROUS_PLAYERS = ObjectSets.synchronize(new ObjectOpenHashSet<>()); private static final Map BH_TARGETS = Object2ObjectMaps.synchronize(new Object2ObjectOpenHashMap<>()); public static void add(Player player, boolean dangerous) { if (dangerous) DANGEROUS_PLAYERS.add(player); else SAFE_PLAYERS.add(player); } public static void remove(Player player, boolean dangerous) { if (dangerous) { DANGEROUS_PLAYERS.remove(player); for (Player pt : DANGEROUS_PLAYERS) updateParticipants(pt, true); } else { SAFE_PLAYERS.remove(player); for (Player pt : SAFE_PLAYERS) updateParticipants(pt, false); } } public static void updateInterface(Player player, CrucibleController controller) { updateRank(player, controller.rank); updateRankPoints(player, controller.points, 0); updateParticipants(player, controller.dangerous); } private static void updateParticipants(Player player, boolean dangerous) { StringBuilder participants = new StringBuilder(); participants.append(dangerous ? ""Dangerous"" : ""Safe"").append("" Participants:
""); for (Player participant : dangerous ? DANGEROUS_PLAYERS : SAFE_PLAYERS) participants.append(participant.getDisplayName()).append(""
""); player.getPackets().setIFText(1296, 0, participants.toString()); } /** * -1 = none * 0 = lowest rank (6) * 1 = rank 5 * 2 = rank 4 * 3 = rank 3 * 4 = rank 2 * 5 = rank 1 * 6 = supreme champion * 7 = temporarily invulnerable */ private static void updateRank(Player player, int tier) { player.getPackets().sendRunScript(6284, tier); } /** * Positive values add points * 0 or lower values remove all points */ public static void updateRankPoints(Player player, int currPoints, int amountToAddOrRemove) { if (amountToAddOrRemove != 0) player.getPackets().sendRunScript(6288, amountToAddOrRemove); player.getPackets().setIFText(1296, 27, Utils.formatNumber(currPoints)); } public static void useFissure(Player player, GameObject object, boolean fast, boolean fastBank) { Fissure fissure = Fissure.forLocation(object.getTile()); if (fissure == null) { player.sendMessage(""Invalid fissure location.""); return; } if (!fast && !fastBank) { player.getInterfaceManager().sendInterface(1291); player.getPackets().sendRunScript(6271, fissure.ordinal() + 1); return; } List shuffled = Arrays.stream(Fissure.values()).filter(f -> f != fissure && ((fastBank && f.name().contains(""BANK"")) || (!fastBank && !f.name().contains(""BANK"")))).collect(Collectors.toList()); Collections.shuffle(shuffled); Optional randomFissure = shuffled.stream().findFirst(); if (shuffled.stream().findFirst().isPresent()) useFissure(player, randomFissure.get()); } public static void useFissure(Player player, Fissure fissure) { player.tele(World.getFreeTile(fissure.location, 2)); player.closeInterfaces(); } }" "package com.rs.game.content.minigames.crucible; public class CrucibleController extends Controller { private static final MapUtils.Area[] SAFE_ZONES = new MapUtils.Area[] { MapUtils.getArea(3314,6136,3322,6149), MapUtils.getArea(3258,6196,3269,6203), MapUtils.getArea(3204,6139,3212,6149), MapUtils.getArea(3255,6084,3266,6093) }; private transient boolean wasInArea; public final boolean dangerous; public int rank = 0; public int points = 0; public CrucibleController(boolean dangerous) { this.dangerous = dangerous; this.rank = dangerous ? -1 : 0; } @Override public void start() { if (dangerous) { Potions.checkOverloads(player); player.addEffect(Effect.OVERLOAD_PVP_REDUCTION, Integer.MAX_VALUE); player.setSkullInfiniteDelay(7); } sendInterfaces(); Crucible.add(player, dangerous); } @Override public void sendInterfaces() { player.getInterfaceManager().sendOverlay(1296); Crucible.updateInterface(player, this); } @Override public boolean sendDeath() { player.lock(8); player.stopAll(); WorldTasks.scheduleTimer(loop -> { if (loop == 0) player.setNextAnimation(new Animation(836)); else if (loop == 1) player.sendMessage(""Oh dear, you have died.""); else if (loop == 4) { Player killer = player.getMostDamageReceivedSourcePlayer(); if (killer != null) { killer.removeDamage(player); killer.increaseKillCount(player); } if (dangerous) { player.sendPVPItemsOnDeath(killer); player.getEquipment().init(); player.getInventory().init(); } player.reset(); player.tele(getRespawnTile()); player.setNextAnimation(new Animation(-1)); if (dangerous) { Potions.checkOverloads(player); player.addEffect(Effect.OVERLOAD_PVP_REDUCTION, Integer.MAX_VALUE); player.setSkullInfiniteDelay(7); } } else if (loop == 5) { player.jingle(90); return false; } return true; }); return false; } @Override public boolean canDepositItem(Item item) { if (MinigameUtilKt.isMinigameSupply(item.getId())) { player.getInventory().deleteItem(item); return false; } return true; } @Override public boolean processTeleport(Teleport tele) { player.sendMessage(""A mysterious force prevents you from teleporting.""); return false; } @Override public void forceClose() { MinigameUtilKt.checkAndDeleteFoodAndPotions(player); remove(false); } private void remove(boolean needRemove) { MinigameUtilKt.checkAndDeleteFoodAndPotions(player); if (needRemove) removeController(); if (wasInArea) player.setCanPvp(false); player.getInterfaceManager().removeOverlay(); player.removeSkull(); player.removeEffect(Effect.OVERLOAD_PVP_REDUCTION); Crucible.remove(player, dangerous); } @Override public boolean processObjectClick1(GameObject object) { switch (object.getId()) { //Quick travel on the fissure case 72923, 72924, 72925, 72926, 72927, 72928, 72929, 72930, 72931, 72932, 72933, 72934, 72935 -> { Crucible.useFissure(player, object, true, false); return false; } case 72936 -> { player.sendOptionDialogue(""What would you like to do?"", ops -> { ops.add(""I'd like to open my bank please."", () -> player.getBank().open()); if (!dangerous) ops.add(""Kit me out with some food and potions please."", () -> MinigameUtilKt.giveFoodAndPotions(player)); ops.add(""Nevermind.""); }); return false; } case 72922 -> { remove(true); player.useStairs(-1, Tile.of(3355, 6119, 0), 0, 1); return false; } } return true; } @Override public boolean processObjectClick2(GameObject object) { switch (object.getId()) { //Select location fissure case 72923, 72924, 72925, 72926, 72927, 72928, 72929, 72930, 72931, 72932, 72933, 72934, 72935 -> { Crucible.useFissure(player, object, false, false); return false; } } return true; } @Override public boolean processObjectClick3(GameObject object) { switch (object.getId()) { //Go-bank fissure case 72927, 72928, 72929, 72930, 72931, 72932, 72933, 72934, 72935 -> { Crucible.useFissure(player, object, true, true); return false; } } return true; } @Override public void moved() { boolean inArea = !inSafeArea(player); if (inArea && !wasInArea) { player.setCanPvp(true); wasInArea = true; } else if (!inArea && wasInArea) { player.setCanPvp(false); wasInArea = false; } } public static Tile getRespawnTile() { return SAFE_ZONES[Utils.random(SAFE_ZONES.length)].getRandomTile(1); } @Override public boolean canAttack(Entity target) { if (canHit(target)) return true; return false; } @Override public boolean canHit(Entity target) { if (target instanceof Player p) { if (p.getControllerManager().getController() != null && p.getControllerManager().getController() instanceof CrucibleController controller) { if ((dangerous && !controller.dangerous) || (controller.dangerous && !dangerous)) { player.sendMessage(""That player isn't in "" + (dangerous ? ""dangerous"" : ""safe"") + "" mode with you.""); return false; } } } return true; } private boolean inSafeArea(Player player) { for (MapUtils.Area area : SAFE_ZONES) if (area.within(player.getTile())) return true; return false; } @Override public boolean logout() { return false; } @Override public boolean login() { start(); moved(); return false; } }" "package com.rs.game.content.minigames.crucible; public enum Fissure { WEST_BANK(Tile.of(3210, 6146, 0)), NORTH_BANK(Tile.of(3267, 6198, 0)), EAST_BANK(Tile.of(3317, 6139, 0)), SOUTH_BANK(Tile.of(3263, 6090, 0)), CENTER(Tile.of(3264, 6131, 0)), SOUTHEAST(Tile.of(3292, 6117, 0)), EAST(Tile.of(3278, 6152, 0)), NORTHEAST(Tile.of(3287, 6174, 0)), NORTH(Tile.of(3259, 6184, 0)), NORTHWEST(Tile.of(3248, 6156, 0)), WEST(Tile.of(3228, 6143, 0)), SOUTHWEST(Tile.of(3225, 6114, 0)), SOUTH(Tile.of(3257, 6101, 0)); public final Tile location; private static final Map LOC_MAP = new HashMap<>(); static { for (Fissure fissure : Fissure.values()) LOC_MAP.put(fissure.location.getTileHash(), fissure); } Fissure(Tile location) { this.location = location; } public static Fissure forLocation(Tile location) { return LOC_MAP.get(location.getTileHash()); } }" "package com.rs.game.content.minigames.domtower; @PluginEventHandler public final class DominionTower { public static final int CLIMBER = 0, ENDURANCE = 1, MAX_FACTOR = 10000000; private transient Player player; private transient Instance region; private int nextBossIndex; private int progress; private int dominionFactor; private long totalScore; private boolean talkedWithFace; private int killedBossesCount; private int maxFloorEndurance; private int maxFloorClimber; private static final int[] NORMAL_ARENA = { 456, 768 }, NOMAD_ARENA = { 456, 776 }; static Item[] commonRewards = { new Item(995, 1000), new Item(386, 10), new Item(380, 10), new Item(374, 10), new Item(398, 10), new Item(441, 10), new Item(560, 10), new Item(565, 10) }; static Item[] mediumRewards = { new Item(22358), new Item(22366), new Item(22362) }; public void setPlayer(Player player) { this.player = player; } public DominionTower() { nextBossIndex = -1; } public boolean hasRequiriments() { return player.getSkills().getCombatLevelWithSummoning() >= 110; } public void openSpectate() { player.getInterfaceManager().sendInterface(1157); } public void growFace() { player.voiceEffect(7913, false); player.simpleDialogue(""The face on the wall groans and scowls at you. Perhaps you should"", ""talk to it first.""); } public void openModes() { if (!hasRequiriments()) { player.startConversation(new Dialogue().addSimple(""You don't have the requirements to play this content, but you can spectate some of the matches"" + "" taking place if you would like."", () -> player.getDominionTower().openSpectate())); return; } if (!talkedWithFace) { growFace(); return; } if (progress == 256) { player.simpleDialogue(""You have some dominion factor which you must exchange before"", ""starting another match.""); player.sendMessage(""You can't go back into the arena, you must go to the next floor on entrance.""); return; } player.getInterfaceManager().sendInterface(1164); player.getPackets().setIFText(1164, 27, progress == 0 ? ""Ready for a new match"" : ""Floor progress: "" + progress); } public static ButtonClickHandler handleButtons = new ButtonClickHandler(new Object[] { 1163, 1164, 1168, 1170, 1173 }, e -> { if (e.getInterfaceId() == 1164) { if (e.getComponentId() == 26) e.getPlayer().getDominionTower().openClimberMode(); else if (e.getComponentId() == 28) e.getPlayer().getDominionTower().openEnduranceMode(); else if (e.getComponentId() == 29) e.getPlayer().getDominionTower().openSpecialMode(); else if (e.getComponentId() == 30) e.getPlayer().getDominionTower().openFreeStyleMode(); else if (e.getComponentId() == 31) e.getPlayer().getDominionTower().openSpectate(); } else if (e.getInterfaceId() == 1163) { if (e.getComponentId() == 89) e.getPlayer().closeInterfaces(); } else if (e.getInterfaceId() == 1168) { if (e.getComponentId() == 254) e.getPlayer().closeInterfaces(); } else if (e.getInterfaceId() == 1170) { if (e.getComponentId() == 85) e.getPlayer().closeInterfaces(); } else if (e.getInterfaceId() == 1173) if (e.getComponentId() == 58) e.getPlayer().closeInterfaces(); else if (e.getComponentId() == 59) e.getPlayer().getDominionTower().startEnduranceMode(); }); private static final int[] MUSICS = { 1015, 1022, 1018, 1016, 1021 }; public static final class Boss { private final String name; private final String text; private final int[] ids; private final boolean forceMulti; private final Item item; private final int voice; private final int[] arena; public Boss(String name, String text, int... ids) { this(name, text, -1, false, null, NORMAL_ARENA, ids); } public Boss(String name, String text, int voice, boolean forceMulti, Item item, int[] arena, int... ids) { this.name = name; this.text = text; this.forceMulti = forceMulti; this.ids = ids; this.item = item; this.voice = voice; this.arena = arena; } public boolean isForceMulti() { return forceMulti; } public String getName() { return name; } } private static final Boss[] BOSSES = { new Boss(""Elvarg"", ""Grrrr"", 14548), new Boss(""Delrith"", ""Grrrr"", -1, false, new Item(2402, 1), NORMAL_ARENA, 14578), new Boss(""Evil Chicken"", ""Bwak bwak bwak"", 3375), new Boss(""The Black Knight Titan"", ""Kill kill kill!"", 14436), new Boss(""Bouncer"", ""Grrr"", 14483), // custom bosses new Boss(""Jad"", ""Roarrrrrrrrrrrrrrrrrrrrrrrrrr"", 2745), new Boss(""Kalphite Queen"", null, 1158), new Boss(""King Black Dragon"", ""Grrrr"", 50), new Boss(""Nomad"", ""You don't stand a chance!"", 7985, true, null, NOMAD_ARENA, 8528) }; private void startEnduranceMode() { if (progress == 256) { player.simpleDialogue(""You have some dominion factor which you must exchange before"", ""starting another match.""); player.sendMessage(""You can't go back into the arena, you must go to the next floor on entrance.""); return; } createArena(ENDURANCE); } public void createArena(final int mode) { player.closeInterfaces(); player.lock(); Instance old = region; region = Instance.of(Tile.of(3744, 6425, 0), 8, 8); region.copyMapAllPlanes(BOSSES[getNextBossIndex()].arena[0], BOSSES[getNextBossIndex()].arena[1]).thenAccept(e -> { teleportToArena(mode); player.unlock(); if (old != null) old.destroy(); }); } private void teleportToArena(int mode) { player.faceTile(Tile.of(getBaseX() + 11, getBaseY() + 29, 0)); player.getControllerManager().startController(new DomTowerController(mode)); player.unlock(); player.tele(Tile.of(getBaseX() + 10, getBaseY() + 29, 2)); player.getMusicsManager().playSongAndUnlock(MUSICS[Utils.getRandomInclusive(MUSICS.length - 1)]); } public String getStartFightText(int message) { return switch (message) { case 0 -> ""Kick my ass!""; case 1 -> ""Please don't hit my face""; case 2 -> ""Argh!""; default -> ""Bring it on!""; }; } public int getNextBossIndex() { if (nextBossIndex < 0 || nextBossIndex >= BOSSES.length) selectBoss(); return nextBossIndex; } public void startFight(final NPC[] bosses) { for (NPC boss : bosses) { boss.setCantInteract(true); boss.faceTile(Tile.of(boss.getX() - 1, boss.getY(), 0)); } player.lock(); player.tele(Tile.of(getBaseX() + 25, getBaseY() + 32, 2)); player.faceTile(Tile.of(getBaseX() + 26, getBaseY() + 32, 0)); final int index = getNextBossIndex(); WorldTasks.scheduleTimer(0, 1, (count) -> { if (count == 0) { player.getInterfaceManager().sendOverlay(1172); player.getPackets().setIFHidden(1172, 2, true); player.getPackets().setIFHidden(1172, 7, true); player.getPackets().setIFText(1172, 4, player.getDisplayName()); player.getVars().setVar(1241, 1); player.getPackets().sendCameraPos(player.getSceneX(getBaseX() + 25), player.getSceneY(getBaseY() + 38), 1800); player.getPackets().sendCameraLook(player.getSceneX(getBaseX() + 25), player.getSceneY(getBaseY() + 29), 800); player.getPackets().sendCameraPos(player.getSceneX(getBaseX() + 32), player.getSceneY(getBaseY() + 38), 1800, 6, 6); } else if (count == 1) player.forceTalk(getStartFightText(Utils.getRandomInclusive(1))); else if (count == 3) { player.getPackets().setIFHidden(1172, 2, false); player.getPackets().setIFHidden(1172, 5, true); player.getPackets().setIFText(1172, 6, BOSSES[index].name); player.getVars().setVar(1241, 0); player.getPackets().sendCameraPos(player.getSceneX(getBaseX() + 35), player.getSceneY(getBaseY() + 37), 1800); player.getPackets().sendCameraLook(player.getSceneX(getBaseX() + 35), player.getSceneY(getBaseY() + 28), 800); player.getPackets().sendCameraPos(player.getSceneX(getBaseX() + 42), player.getSceneY(getBaseY() + 37), 1800, 6, 6); } else if (count == 4) { if (BOSSES[index].text != null) bosses[0].forceTalk(BOSSES[index].text); if (BOSSES[index].voice != -1) player.voiceEffect(BOSSES[index].voice, false); } else if (count == 6) { player.getControllerManager().sendInterfaces(); player.getInterfaceManager().sendInterface(1172); player.getPackets().setIFHidden(1172, 2, true); player.getPackets().setIFHidden(1172, 5, true); player.getPackets().setIFText(1172, 8, ""Fight!""); player.getPackets().setIFHidden(1172, 10, true); player.getPackets().sendCameraLook(player.getSceneX(getBaseX() + 32), player.getSceneY(getBaseY() + 36), 0); player.getPackets().sendCameraPos(player.getSceneX(getBaseX() + 32), player.getSceneY(getBaseY() + 16), 5000); player.voiceEffect(7882, false); } else if (count == 8) { if (nextBossIndex != -1 && BOSSES[index].item != null) World.addGroundItem(BOSSES[index].item, Tile.of(getBaseX() + 26, getBaseY() + 33, 2)); player.closeInterfaces(); player.getPackets().sendResetCamera(); for (NPC boss : bosses) { boss.setCantInteract(false); boss.setTarget(player); } player.unlock(); return false; } return true; }); } public void removeItem() { if (nextBossIndex == -1) return; if (BOSSES[nextBossIndex].item != null) { player.getInventory().deleteItem(BOSSES[nextBossIndex].item.getId(), BOSSES[nextBossIndex].item.getAmount()); player.getEquipment().deleteItem(BOSSES[nextBossIndex].item.getId(), BOSSES[nextBossIndex].item.getAmount()); player.getAppearance().generateAppearanceData(); } } public void loss(final int mode) { /* * if(mapBaseCoords == null) { //died on logout * player.tele(Tile.of(3744, 6425, 0)); * player.getControllerManager().removeControllerWithoutCheck(); return; } */ removeItem(); nextBossIndex = -1; player.lock(); player.tele(Tile.of(getBaseX() + 35, getBaseY() + 31, 2)); player.faceTile(Tile.of(player.getX() + 1, player.getY(), 0)); WorldTasks.scheduleTimer(0, 1, (count) -> { if (count == 0) { player.anim(836); player.getInterfaceManager().removeOverlay(); player.getInterfaceManager().sendInterface(1172); player.getPackets().setIFHidden(1172, 2, true); player.getPackets().setIFHidden(1172, 5, true); player.getPackets().setIFText(1172, 8, ""Unlucky, you lost!""); player.getPackets().setIFText(1172, 10, ""You leave with a dominion factor of: "" + dominionFactor); player.getPackets().sendCameraPos(player.getSceneX(getBaseX() + 35), player.getSceneY(getBaseY() + 37), 2500); player.getPackets().sendCameraLook(player.getSceneX(getBaseX() + 35), player.getSceneY(getBaseY() + 28), 800); player.getPackets().sendCameraPos(player.getSceneX(getBaseX() + 42), player.getSceneY(getBaseY() + 37), 2500, 6, 6); player.voiceEffect(7874, false); } else if (count == 4) { player.setForceMultiArea(false); player.reset(); player.anim(-1); player.closeInterfaces(); player.getPackets().sendResetCamera(); player.unlock(); destroyArena(false, mode); return false; } return true; }); } public void win(int mode) { removeItem(); int factor = getBossesTotalLevel() * (mode == CLIMBER ? 100 : 10); progress++; if (mode == CLIMBER) { if (progress > maxFloorClimber) maxFloorClimber = progress; } else if (mode == ENDURANCE) if (progress > maxFloorEndurance) maxFloorEndurance = progress; killedBossesCount++; dominionFactor += factor; totalScore += factor; if (dominionFactor > MAX_FACTOR) { dominionFactor = MAX_FACTOR; player.sendMessage(""You've reached the maximum Dominion Factor you can get so you should spend it!""); } nextBossIndex = -1; player.lock(); player.tele(Tile.of(getBaseX() + 35, getBaseY() + 31, 2)); player.faceTile(Tile.of(getBaseX() + 36, getBaseY() + 31, 0)); WorldTasks.scheduleTimer(0, 1, (count) -> { if (count == 0) { player.getInterfaceManager().removeOverlay(); player.getInterfaceManager().sendInterface(1172); player.getPackets().setIFHidden(1172, 2, true); player.getPackets().setIFHidden(1172, 5, true); player.getPackets().setIFText(1172, 8, ""Yeah! You won!""); player.getPackets().setIFText(1172, 10, ""You now have a dominion factor of: "" + dominionFactor); player.getPackets().sendCameraPos(player.getSceneX(getBaseX() + 35), player.getSceneY(getBaseY() + 37), 2500); player.getPackets().sendCameraLook(player.getSceneX(getBaseX() + 35), player.getSceneY(getBaseY() + 28), 800); player.getPackets().sendCameraPos(player.getSceneX(getBaseX() + 42), player.getSceneY(getBaseY() + 37), 2500, 6, 6); player.voiceEffect(7897, false); } else if (count == 4) { player.reset(); player.closeInterfaces(); player.getPackets().sendResetCamera(); player.unlock(); return false; } return true; }); } /* * 4928 15936 */ /* * 4960, 15968 */ public void destroyArena(final boolean logout, int mode) { Tile tile = Tile.of(3744, 6425, 0); if (logout) player.setTile(tile); else { player.getControllerManager().removeControllerWithoutCheck(); player.lock(); player.tele(tile); if (mode == ENDURANCE) progress = 0; } region.destroy().thenAccept(e -> { if (!logout) { region = null; player.unlock(); } }); } public NPC[] createBosses() { NPC[] bosses = new NPC[BOSSES[getNextBossIndex()].ids.length]; for (int i = 0; i < BOSSES[getNextBossIndex()].ids.length; i++) bosses[i] = World.spawnNPC(BOSSES[getNextBossIndex()].ids[i], Tile.of(getBaseX() + 37 + (i * 2), getBaseY() + 31, 2), -1, true, true); return bosses; } public int getBaseX() { return region.getBaseX(); } public int getBaseY() { return region.getBaseY(); } public void selectBoss() { if (nextBossIndex < 0 || nextBossIndex >= BOSSES.length) nextBossIndex = Utils.random(BOSSES.length); } public void openClimberMode() { player.sendMessage(""Only endurance mode is currently working.""); // player.getInterfaceManager().sendScreenInterface(96, 1163); // selectBoss(); // player.getPackets().sendIComponentText(1163, 32, ""0""); // you leave // with } public void openEnduranceMode() { selectBoss(); player.getInterfaceManager().setFullscreenInterface(96, 1173); player.getPackets().setIFText(1173, 25, BOSSES[getNextBossIndex()].name); // current player.getPackets().setIFText(1173, 38, String.valueOf(progress + 1)); // current player.getPackets().setIFText(1173, 52, ""None. Good luck!""); // current player.getPackets().setIFText(1173, 29, String.valueOf(dominionFactor)); // current player.getPackets().setIFText(1173, 31, dominionFactor == MAX_FACTOR ? """" : String.valueOf(getBossesTotalLevel() * 10)); // on // win player.getPackets().setIFText(1173, 33, String.valueOf(dominionFactor)); // on // death } public int getBossesTotalLevel() { int level = 0; for (int id : BOSSES[getNextBossIndex()].ids) level = +NPCDefinitions.getDefs(id).combatLevel; return level; } public void openSpecialMode() { player.sendMessage(""Only endurance mode is currently working.""); // player.getInterfaceManager().sendScreenInterface(96, 1170); } public void openFreeStyleMode() { player.sendMessage(""Only endurance mode is currently working.""); // player.getInterfaceManager().sendScreenInterface(96, 1168); } public void talkToFace() { talkToFace(false); } public void talkToFace(boolean fromDialogue) { if (!hasRequiriments()) { player.simpleDialogue(""You need at least level 110 combat to use this tower.""); return; } if (!talkedWithFace) player.startConversation(new StrangeFace(player)); else { if (!fromDialogue) player.voiceEffect(7893, false); player.getInterfaceManager().sendInterface(1160); } } public void openRewards() { if (!talkedWithFace) { talkToFace(); return; } player.voiceEffect(7893, false); player.getInterfaceManager().sendInterface(1156); } public void openRewardsChest() { if (!talkedWithFace) { growFace(); return; } if (dominionFactor == 0) { player.sendMessage(""You have no dominion factor to claim anything with..""); return; } progress = 0; giveRewards(dominionFactor); player.sendMessage(""You have "" + player.getDominionTower().getKilledBossesCount() + "" boss kills.""); player.sendMessage(""500 are required to obtain dominion gloves (swifts, goliaths, spellcasters).""); dominionFactor = 0; } public void giveRewards(int dominionFactor) { Item[] rewards; int random = Utils.getRandomInclusive(100); if (random < 15 && player.getDominionTower().getKilledBossesCount() >= 500) rewards = new Item[] { commonRewards[Utils.getRandomInclusive(commonRewards.length - 1)], commonRewards[Utils.getRandomInclusive(commonRewards.length - 1)], commonRewards[Utils.getRandomInclusive(commonRewards.length - 1)], mediumRewards[Utils.getRandomInclusive(mediumRewards.length - 1)] }; else rewards = new Item[] { commonRewards[Utils.getRandomInclusive(commonRewards.length - 1)], commonRewards[Utils.getRandomInclusive(commonRewards.length - 1)], commonRewards[Utils.getRandomInclusive(commonRewards.length - 1)] }; for (Item item : rewards) if(player.getInventory().hasFreeSlots()) player.getInventory().addItem(item); else if(player.getBank().hasBankSpace()) { player.getBank().addItem(item, false); player.sendMessage(""Your reward have been sent to your bank.""); } else { World.addGroundItem(item, player.getTile(), player); player.sendMessage(""You don't have bank space, so your reward has been dropped on the ground.""); } player.getInterfaceManager().sendInterface(1171); player.getPackets().sendInterSetItemsOptionsScript(1171, 7, 100, 8, 3, ""Take"", ""Convert"", ""Discard"", ""Examine""); player.getPackets().setIFRightClickOps(1171, 7, 0, 10, 0, 1, 2, 3); player.getPackets().sendItems(100, rewards); } public void openBankChest() { if (!talkedWithFace) { growFace(); return; } player.getBank().open(); } public boolean isTalkedWithFace() { return talkedWithFace; } public void setTalkedWithFace(boolean talkedWithFace) { this.talkedWithFace = talkedWithFace; } public int getProgress() { return progress; } public long getTotalScore() { return totalScore; } public int getDominionFactor() { return dominionFactor; } public Boss getNextBoss() { return BOSSES[getNextBossIndex()]; } public int getMaxFloorClimber() { return maxFloorClimber; } public int getMaxFloorEndurance() { return maxFloorEndurance; } public int getKilledBossesCount() { return killedBossesCount; } public void setKilledBossesCount(int count) { killedBossesCount = count; } }" "package com.rs.game.content.minigames.domtower; public class DomTowerController extends Controller { private final transient int mode; public DomTowerController(int mode) { this.mode = mode; } @Override public void start() { } public int getMode() { return mode; } private transient NPC[] bosses; private int onArena; @Override public boolean processObjectClick1(GameObject object) { if (object.getId() == 62682 || object.getId() == 62683 || object.getId() == 62690) { player.getDominionTower().destroyArena(false, getMode()); return false; } if (object.getId() == 62684 || object.getId() == 62685) { if (bosses == null && onArena == 0) { bosses = player.getDominionTower().createBosses(); onArena = 1; if (bosses.length > 1 || player.getDominionTower().getNextBoss().isForceMulti()) { player.setForceMultiArea(true); for (NPC n : bosses) n.setForceMultiArea(true); } player.getDominionTower().startFight(bosses); } return false; } if (object.getId() == 62686 || object.getId() == 62687) { if (bosses == null && onArena == 1) { onArena = 2; player.lock(2); player.stopAll(); player.addWalkSteps(player.getX() + 1, player.getY(), 1, false); player.setForceMultiArea(false); return false; } } else if (object.getId() == 62691) { if (getMode() == DominionTower.ENDURANCE) { player.sendMessage(""You can't bank on endurance mode.""); return false; } player.getBank().open(); return false; } else if (object.getId() == 62689) { if (player.getDominionTower().getProgress() == 0) { player.getDominionTower().openModes(); return false; } if (getMode() == DominionTower.ENDURANCE) player.getDominionTower().openEnduranceMode(); else player.getDominionTower().openClimberMode(); return false; } return true; } public int getPlayerHPPercentage() { return player.getHitpoints() * 100 / player.getMaxHitpoints(); } public int getBossesHPPercentage() { int totalHp = 0; int totalMaxHp = 0; for (NPC n : bosses) { totalHp += n.getHitpoints(); totalMaxHp += n.getMaxHitpoints(); } return totalHp * 100 / totalMaxHp; } private int playerHp, bossHp; @Override public boolean sendDeath() { if (bosses != null) for (NPC n : bosses) n.finish(); bosses = null; player.getDominionTower().loss(getMode()); return false; } @Override public void process() { if (bosses != null) { if (bossesDead()) { bosses = null; player.getDominionTower().win(getMode()); return; } int playerHp = getPlayerHPPercentage(); int bossHp = getBossesHPPercentage(); if (bossHp != this.bossHp) { this.bossHp = bossHp; player.getPackets().sendVarc(1672, bossHp); } if (playerHp != this.playerHp) { this.playerHp = playerHp; player.getPackets().sendVarc(1673, playerHp); } } } public boolean bossesDead() { for (NPC n : bosses) if (!n.hasFinished()) return false; return true; } @Override public void sendInterfaces() { if (bosses != null) { player.getInterfaceManager().sendOverlay(1159); player.getPackets().setIFHidden(1159, 14, true); player.getPackets().setIFText(1159, 32, getMode() == DominionTower.CLIMBER ? ""Climber"" : ""Endurance"" + "". Floor "" + (player.getDominionTower().getProgress() + 1)); player.getPackets().setIFText(1159, 40, player.getDisplayName()); player.getPackets().setIFText(1159, 41, player.getDominionTower().getNextBoss().getName()); } } @Override public void onTeleported(TeleType type) { if (type != TeleType.OBJECT) player.getDominionTower().destroyArena(false, getMode()); } @Override public boolean login() { if (player.isDead()) return true; player.getDominionTower().selectBoss(); player.getDominionTower().createArena(getMode()); return false; } @Override public boolean logout() { player.getDominionTower().destroyArena(true, getMode()); return false; } }" "package com.rs.game.content.minigames.domtower; public class DreadNip extends NPC { public static final String[] DREADNIP_MESSAGES = { ""Your dreadnip couldn't attack so it left."", ""The dreadnip gave up as you were too far away."", ""Your dreadnip served its purpose and fled."" }; private final Player owner; private int ticks; public DreadNip(Player owner, int id, Tile tile, int mapAreaNameHash, boolean canBeAttackFromOutOfArea) { super(id, tile); this.owner = owner; } @Override public void processNPC() { super.processNPC(); if (owner == null || owner.hasFinished()) { finish(-1); return; } if (getCombat().getTarget() == null || getCombat().getTarget().isDead()) { finish(0); return; } if (Utils.getDistance(owner.getTile(), getTile()) >= 10) { finish(1); return; } else if (ticks++ == 33) { finish(2); return; } } private void finish(int index) { if (index != -1) { owner.sendMessage(DREADNIP_MESSAGES[index]); owner.getTempAttribs().removeB(""hasDN""); } this.finish(); } public Player getOwner() { return owner; } public int getTicks() { return ticks; } }" "package com.rs.game.content.minigames.domtower; public class DreadNipCombat extends CombatScript { private final String[] DREADNIP_ATTACK_MESSAGE = { ""Your dreadnip stunned its target!"", ""Your dreadnip poisened its target!"" }; @Override public Object[] getKeys() { return new Object[] { 14416 }; } @Override public int attack(NPC npc, Entity target) { DreadNip dreadNip = (DreadNip) npc; if (dreadNip.getTicks() <= 3) return 0; npc.setNextAnimation(new Animation(-1)); int attackStyle = Utils.random(2); switch (attackStyle) { case 0: break; case 1: int tickDelay = 5 + Utils.getRandomInclusive(3); target.freeze(tickDelay); if (target instanceof Player player) player.getActionManager().addActionDelay(tickDelay); else { NPC npcTarget = (NPC) target; npcTarget.getCombat().setCombatDelay(npcTarget.getCombat().getCombatDelay() + tickDelay); } break; case 2: target.getPoison().makePoisoned(108); break; } if (attackStyle != 0) dreadNip.getOwner().sendMessage(DREADNIP_ATTACK_MESSAGE[attackStyle - 1]); delayHit(npc, 0, target, new Hit(npc, getMaxHit(npc, 550, AttackStyle.MELEE, target), HitLook.TRUE_DAMAGE)); return 5; } }" "package com.rs.game.content.minigames.domtower; public class DTPreview extends Cutscene { @Override public void construct(Player player) { camLook(3386, 3104, 1000, 6, 6, -1); camPos(3395, 3104, 5000, 7, 8, 5); camLook(3390, 3115, 6000, 6, 6, -1); camPos(3395, 3115, 6000, 7, 8, 5); camLook(3380, 3125, 6000, 6, 6, -1); camPos(3380, 3125, 6000, 7, 6, 5); camLook(3375, 3125, 6000, 6, 6, -1); camPos(3375, 3125, 6000, 7, 6, 5); camLook(3370, 3125, 6000, 6, 6, -1); camPos(3370, 3125, 6000, 7, 6, 5); camLook(3358, 3120, 5500, 6, 6, -1); camPos(3358, 3125, 5500, 7, 6, 5); camLook(3358, 3095, 4000, 6, 6, -1); camPos(3358, 3095, 4000, 7, 8, 5); camLook(3374, 3084, 2500, 6, 6, -1); camPos(3374, 3084, 2500, 7, 8, 5); camLook(3374, 3097, 2300, 9, 9, -1); camPos(3374, 3097, 2300, 7, 8, 5); } }" "package com.rs.game.content.minigames.domtower; public class StrangeFace extends Conversation { public StrangeFace(Player player) { super(player); addPlayer(HeadE.SKEPTICAL_HEAD_SHAKE, ""Hello?""); addSimple(""Hello."").voiceEffect(7890); addPlayer(HeadE.AMAZED, ""Woah!"", () -> player.getPackets().resetSounds()); addSimple(""It is intriguing that you took so before coming to me. Fearful, traveller?"").voiceEffect(7895); addPlayer(HeadE.SKEPTICAL_THINKING, ""Should I be?"", () -> player.getPackets().resetSounds()); addSimple(""It is my duty inform you that many warriors fight here, and they all succumb to defeat eventually. If that instills terror in you, walk away now."").voiceEffect(7881); addPlayer(HeadE.HAPPY_TALKING, ""There are monsters in the tower?"", () -> player.getPackets().resetSounds()); addSimple(""If that is the terminology you would use, yes. Through the powers \""bestowed upon me by my creator, I can generate opponents for you\"", \""based on your memories of them. Men and women have fought here\"", \""for generations."").voiceEffect(7908); addPlayer(HeadE.HAPPY_TALKING, ""Impressive. So you control the tower?"", () -> player.getPackets().resetSounds()); addSimple(""The Tower is I, and I have control of the tower. I see what happens, in any corner of any floor. I am always watching."").voiceEffect(7909); addSimple(""So you believe yourself a mighty warrior?"", () -> { player.getPackets().resetSounds(); //player.voiceEffect(7907);//Need to find a way to reset sounds when starting options... }); addOptions(""Choose an option:"", (ops) -> { ops.add(""Only the greatest warrior that ever lived!"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Only the greatest warrior that ever lived!"") .addSimple(""Intriguing. Such belief in your own abilities..."").voiceEffect(7906) .addPlayer(HeadE.HAPPY_TALKING, ""What?"") .addSimple(""Your confidence may have a foundation, but judgment will come in battle."").voiceEffect(7896) .addPlayer(HeadE.HAPPY_TALKING, ""You mentioned that you were created by someone, but why?"", () -> player.getPackets().resetSounds()) .addSimple(""My purpose...must never stop..."").voiceEffect(7902) .addPlayer(HeadE.HAPPY_TALKING, ""Sorry? Are you alright?"") .addSimple(""You must fight in the tower, warrior. Demonstrate your ability to others and learn."").voiceEffect(7879) .addPlayer(HeadE.HAPPY_TALKING, ""I'd thought that, as a guide, you'd be a little more welcoming."", () -> player.getPackets().resetSounds()) .addSimple(""You will find I am welcoming enough."").voiceEffect(7911) .addSimple(""Now, I can offer you more guidance; or, if you overflow with confidence, you can figure out yourself. I am the tower, I am ever-present, so come to me if you change your mind."", () -> { player.getPackets().resetSounds(); //player.voiceEffect(7872);//Need a way to reset sounds on option player.getDominionTower().setTalkedWithFace(true); }) .addOptions(""Receive further instruction?"", (ops1) -> { ops1.add(""Yes."") .addNext(() -> player.getDominionTower().talkToFace(true)); ops1.add(""No."") .addSimple(""Your choice. Come back if you change your mind."", () -> { //player.voiceEffect(7878); //Need a way to reset sounds on dialogue exit }); }) ); ops.add(""I'm pretty handy with a weapon."") .addPlayer(HeadE.HAPPY_TALKING, ""I'm pretty handy with a weapon."") .addSimple(""Intriguing. I sense humility in you..."").voiceEffect(7887) .addPlayer(HeadE.HAPPY_TALKING, ""What?"", () -> player.getPackets().resetSounds()); }); create(); } }" "package com.rs.game.content.minigames.duel; @PluginEventHandler public class DuelArenaController extends Controller { private transient Player target; private final boolean ifFriendly; private boolean isDueling; private final Item[] FUN_WEAPONS = { new Item(4566) }; private final Tile[] LOBBY_TELEPORTS = { Tile.of(3367, 3275, 0), Tile.of(3360, 3275, 0), Tile.of(3358, 3270, 0), Tile.of(3363, 3268, 0), Tile.of(3370, 3268, 0), Tile.of(3367, 3267, 0), Tile.of(3376, 3275, 0), Tile.of(3377, 3271, 0), Tile.of(3375, 3269, 0), Tile.of(3381, 3277, 0) }; public DuelArenaController(Player target, boolean friendly) { this.target = target; ifFriendly = friendly; } public static ObjectClickHandler handleWallLeans = new ObjectClickHandler(new Object[] { 3077, 3079, 3082, 3083, 19418, 19422, 27693, 27694, 27695, 27697, 37718, 37719, 37720, 37721, 37722, 37723 }, e -> e.getPlayer().sendMessage(""I wouldn't want to fall in."")); @Override public void start() { openDuelScreen(target, ifFriendly); } private void openDuelScreen(Player target, boolean ifFriendly) { if (!ifFriendly) { sendOptions(player); player.getLastDuelRules().getStake().clear(); } player.getTempAttribs().setB(""acceptedDuel"", false); player.getPackets().sendItems(134, false, player.getLastDuelRules().getStake()); player.getPackets().sendItems(134, true, player.getLastDuelRules().getStake()); player.getPackets().setIFText(ifFriendly ? 637 : 631, ifFriendly ? 16 : 38, "" "" + Utils.formatPlayerNameForDisplay(target.getUsername())); player.getPackets().setIFText(ifFriendly ? 637 : 631, ifFriendly ? 18 : 40, """" + (target.getSkills().getCombatLevel())); player.getVars().setVar(286, 0); player.getTempAttribs().setB(""firstScreen"", true); player.getInterfaceManager().sendInterface(ifFriendly ? 637 : 631); refreshScreenMessage(true, ifFriendly); player.setCloseInterfacesEvent(() -> closeDuelInteraction(true, DuelStage.DECLINED)); } private void accept(boolean firstStage) { if (!hasTarget()) return; boolean accepted = player.getTempAttribs().getB(""acceptedDuel""); boolean targetAccepted = target.getTempAttribs().getB(""acceptedDuel""); DuelRules rules = player.getLastDuelRules(); if (!rules.canAccept(player.getLastDuelRules().getStake())) return; if (accepted && targetAccepted) { if (firstStage) { if (nextStage()) ((DuelArenaController) target.getControllerManager().getController()).nextStage(); } else { player.setCloseInterfacesEvent(null); player.closeInterfaces(); closeDuelInteraction(true, DuelStage.DONE); } return; } player.getTempAttribs().setB(""acceptedDuel"", true); refreshScreenMessages(firstStage, ifFriendly); } protected void closeDuelInteraction(boolean started, DuelStage duelStage) { Player oldTarget = target; if (duelStage != DuelStage.DONE) { target = null; WorldTasks.schedule(new Task() { @Override public void run() { player.getControllerManager().startController(new DuelController()); } }); player.getInventory().getItems().addAll(player.getLastDuelRules().getStake()); player.getInventory().init(); player.getLastDuelRules().getStake().clear(); } else { removeEquipment(); player.reset(); beginBattle(started); } Controller controller = oldTarget.getControllerManager().getController(); if (controller == null) return; DuelArenaController targetConfiguration = (DuelArenaController) controller; if (controller instanceof DuelArenaController) if (targetConfiguration.hasTarget()) { oldTarget.setCloseInterfacesEvent(null); oldTarget.closeInterfaces(); if (duelStage != DuelStage.DONE) player.getControllerManager().removeControllerWithoutCheck(); if (started) targetConfiguration.closeDuelInteraction(false, duelStage); if (duelStage == DuelStage.DONE) player.sendMessage(""Your battle will begin shortly.""); else if (duelStage == DuelStage.SECOND) player.sendMessage(""Please check if these settings are correct.""); else if (duelStage == DuelStage.DECLINED) oldTarget.sendMessage(""Other player declined the duel!""); else if (duelStage == DuelStage.DECLINED) { oldTarget.sendMessage(""You do not have enough space to continue!""); oldTarget.sendMessage(""Other player does not have enough space to continue!""); } } } public void addItem(int slot, int amount) { if (!hasTarget() || player.isIronMan() || player.getRights() == Rights.ADMIN) return; Item item = player.getInventory().getItem(slot); if (item == null) return; if (!ItemConstants.isTradeable(item)) { player.sendMessage(""That item cannot be staked!""); return; } if (player.getLastDuelRules().getStake().getUsedSlots() > 8) { player.sendMessage(""There is enough items.""); return; } Item[] itemsBefore = player.getLastDuelRules().getStake().getItemsCopy(); int maxAmount = player.getInventory().getItems().getNumberOf(item); if (amount < maxAmount) item = new Item(item.getId(), amount); else item = new Item(item.getId(), maxAmount); player.getLastDuelRules().getStake().add(item); player.getInventory().deleteItem(slot, item); refreshItems(itemsBefore); cancelAccepted(); } public void removeItem(final int slot, int amount) { if (!hasTarget()) return; Item item = player.getLastDuelRules().getStake().get(slot); if (item == null) return; int maxAmount = player.getLastDuelRules().getStake().getNumberOf(item); if (amount < maxAmount) item = new Item(item.getId(), amount); else item = new Item(item.getId(), maxAmount); player.getLastDuelRules().getStake().remove(slot, item); player.getInventory().addItem(item); Item[] itemsBefore = player.getLastDuelRules().getStake().getItemsCopy(); refreshItems(itemsBefore); cancelAccepted(); } private void refreshItems(Item[] itemsBefore) { int[] changedSlots = new int[itemsBefore.length]; int count = 0; for (int index = 0; index < itemsBefore.length; index++) { Item item = player.getLastDuelRules().getStake().array()[index]; if (item != null) if (itemsBefore[index] != item) changedSlots[count++] = index; } int[] finalChangedSlots = new int[count]; System.arraycopy(changedSlots, 0, finalChangedSlots, 0, count); refresh(finalChangedSlots); } private void refresh(int... slots) { player.getPackets().sendUpdateItems(134, player.getLastDuelRules().getStake(), 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17); target.getPackets().sendUpdateItems(134, true, player.getLastDuelRules().getStake().array(), 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17); } public void cancelAccepted() { boolean canceled = false; if (player.getTempAttribs().getB(""acceptedDuel"")) { player.getTempAttribs().setB(""acceptedDuel"", false); canceled = true; } if (target.getTempAttribs().getB(""acceptedDuel"")) { target.getTempAttribs().setB(""acceptedDuel"", false); canceled = true; } if (canceled) refreshScreenMessages(canceled, ifFriendly); } private void openConfirmationScreen(boolean ifFriendly) { player.getInterfaceManager().sendInterface(ifFriendly ? 639 : 626); refreshScreenMessage(false, ifFriendly); } private void refreshScreenMessages(boolean firstStage, boolean ifFriendly) { refreshScreenMessage(firstStage, ifFriendly); ((DuelArenaController) target.getControllerManager().getController()).refreshScreenMessage(firstStage, ifFriendly); } private void refreshScreenMessage(boolean firstStage, boolean ifFriendly) { player.getPackets().setIFText(firstStage ? (ifFriendly ? 637 : 631) : (ifFriendly ? 639 : 626), firstStage ? (ifFriendly ? 20 : 41) : (ifFriendly ? 23 : 35), """" + getAcceptMessage(firstStage)); } private String getAcceptMessage(boolean firstStage) { if (target.getTempAttribs().getB(""acceptedDuel"")) return ""Other player has accepted.""; if (player.getTempAttribs().getB(""acceptedDuel"")) return ""Waiting for other player...""; return firstStage ? """" : ""Please look over the agreements to the duel.""; } public boolean nextStage() { if (!hasTarget()) return false; if (player.getInventory().getItems().getUsedSlots() + target.getLastDuelRules().getStake().getUsedSlots() > 28) { player.setCloseInterfacesEvent(null); player.closeInterfaces(); closeDuelInteraction(true, DuelStage.NO_SPACE); return false; } player.getTempAttribs().setB(""acceptedDuel"", false); openConfirmationScreen(false); player.getInterfaceManager().removeInventoryInterface(); return true; } private void sendOptions(Player player) { player.getInterfaceManager().sendInventoryInterface(628); player.getPackets().setIFRightClickOps(628, 0, 0, 27, 0, 1, 2, 3, 4, 5); player.getPackets().sendInterSetItemsOptionsScript(628, 0, 93, 4, 7, ""Stake-1"", ""Stake-5"", ""Stake-10"", ""Stake-X"", ""Stake-All"", ""Examine""); player.getPackets().setIFRightClickOps(631, 47, 0, 27, 0, 1, 2, 3, 4, 5); player.getPackets().sendInterSetItemsOptionsScript(631, 0, 120, 4, 7, ""Remove-1"", ""Remove-5"", ""Remove-10"", ""Stake-X"", ""Remove-All"", ""Examine""); } public void endDuel(Player victor, Player loser) { endDuel(victor, loser, true); } public void endDuel(final Player victor, final Player loser, boolean removeLoserController) { if (isDueling) { for (Item item : player.getLastDuelRules().getStake().array()) { if (item == null) continue; victor.getInventory().addItem(item); } for (Item item : target.getLastDuelRules().getStake().array()) { if (item == null) continue; victor.getInventory().addItem(item); } isDueling = false; } if (loser.getControllerManager().getController() != null && removeLoserController) loser.getControllerManager().removeControllerWithoutCheck(); loser.setCanPvp(false); loser.getHintIconsManager().removeUnsavedHintIcon(); loser.reset(); loser.closeInterfaces(); if (victor.getControllerManager().getController() != null) victor.getControllerManager().removeControllerWithoutCheck(); victor.setCanPvp(false); victor.getHintIconsManager().removeUnsavedHintIcon(); victor.reset(); victor.closeInterfaces(); startEndingTeleport(victor); startEndingTeleport(loser); loser.sendMessage(""Oh dear, it seems you have lost to "" + victor.getDisplayName() + "".""); victor.sendMessage(""Congratulations! You easily defeated "" + loser.getDisplayName() + "".""); WorldTasks.schedule(new Task() { @Override public void run() { victor.getControllerManager().startController(new DuelController()); loser.getControllerManager().startController(new DuelController()); } }, 2); } private void startEndingTeleport(Player player) { Tile tile = LOBBY_TELEPORTS[Utils.random(LOBBY_TELEPORTS.length)]; Tile teleTile = tile; for (int trycount = 0; trycount < 10; trycount++) { teleTile = Tile.of(tile, 2); if (World.floorAndWallsFree(teleTile, player.getSize())) break; teleTile = tile; } player.tele(teleTile); } private void removeEquipment() { int slot = 0; for (int i = 10; i < 23; i++) { if (i == 14) if (player.getEquipment().hasTwoHandedWeapon()) Equipment.remove(target, 3); if (player.getLastDuelRules().getRule(i)) { slot = i - 10; Equipment.remove(player, slot); } } } private void beginBattle(boolean started) { if (started) { Tile[] teleports = getPossibleTiles(); int random = Utils.getRandomInclusive(1); player.tele(random == 0 ? teleports[0] : teleports[1]); target.tele(random == 0 ? teleports[1] : teleports[0]); } player.stopAll(); player.lock(2); // fixes mass click steps player.reset(); isDueling = true; player.getTempAttribs().setB(""startedDuel"", true); player.getTempAttribs().setB(""canFight"", false); player.setCanPvp(true); player.getHintIconsManager().addHintIcon(target, 1, -1, false); WorldTasks.scheduleLooping(new Task() { int count = 3; @Override public void run() { if (count > 0) player.setNextForceTalk(new ForceTalk("""" + count)); if (count == 0) { player.getTempAttribs().setB(""canFight"", true); player.setNextForceTalk(new ForceTalk(""FIGHT!"")); stop(); } count--; } }, 0, 2); } @Override public boolean canEat(Food food) { if (player.getLastDuelRules().getRule(4) && isDueling) { player.sendMessage(""You cannot eat during this duel."", true); return false; } return true; } @Override public boolean canPot(Potion pot) { if (player.getLastDuelRules().getRule(3) && isDueling) { player.sendMessage(""You cannot drink during this duel."", true); return false; } return true; } @Override public boolean canMove(Direction dir) { if (player.getLastDuelRules().getRule(25) && isDueling) { player.sendMessage(""You cannot move during this duel!"", true); return false; } return true; } @Override public boolean canSummonFamiliar() { if (player.getLastDuelRules().getRule(24) && isDueling) return true; player.sendMessage(""Summoning has been disabled during this duel!""); return false; } @Override public boolean processTeleport(Teleport tele) { if (tele.type() != TeleType.OBJECT) { player.simpleDialogue(""A magical force prevents you from teleporting from the arena.""); return false; } return true; } @Override public void onTeleported(TeleType type) { if (type != TeleType.BYPASS_HOOKS) return; } @Override public boolean processObjectClick1(GameObject object) { player.sendOptionDialogue(""Forfeit Duel?"", ops -> { ops.add(""Yes."", () -> { if (!player.getLastDuelRules().getRule(7)) endDuel(player.getLastDuelRules().getTarget(), player); else player.simpleDialogue(""You can't forfeit during this duel.""); }); ops.add(""No.""); }); return true; } @Override public boolean sendDeath() { endDuel(target, player); player.lock(7); WorldTasks.scheduleLooping(new Task() { int loop; @Override public void run() { player.stopAll(); if (loop == 0) player.setNextAnimation(new Animation(836)); else if (loop == 1) player.sendMessage(""Oh dear, you have died.""); else if (loop == 3) { player.setNextAnimation(new Animation(-1)); stop(); } loop++; } }, 0, 1); return false; } @Override public boolean login() { startEndingTeleport(player); removeController(); return true; } @Override public boolean logout() { if (isDueling) endDuel(target, player, false); else closeDuelInteraction(true, DuelStage.DECLINED); return isDueling ? true : false; } @Override public boolean keepCombating(Entity victim) { DuelRules rules = player.getLastDuelRules(); boolean isRanging = PlayerCombatKt.isRanging(player); if (!player.getTempAttribs().getB(""canFight"")) { player.sendMessage(""The duel hasn't started yet."", true); return false; } if (target != victim) return false; if (player.getCombatDefinitions().getSpell() != null && rules.getRule(2) && isDueling) { player.sendMessage(""You cannot use Magic in this duel!"", true); return false; } if (isRanging && rules.getRule(0) && isDueling) { player.sendMessage(""You cannot use Range in this duel!"", true); return false; } if (!isRanging && rules.getRule(1) && player.getCombatDefinitions().getSpell() == null && isDueling) { player.sendMessage(""You cannot use Melee in this duel!"", true); return false; } else for (Item item : FUN_WEAPONS) if (rules.getRule(8) && !player.getInventory().containsItem(item.getId(), item.getAmount())) { player.sendMessage(""You can only use fun weapons in this duel!""); return false; } return true; } @Override public boolean canEquip(int slotId, int itemId) { DuelRules rules = player.getLastDuelRules(); if (isDueling) if (rules.getRule(10 + slotId) || (slotId == 3 && player.getEquipment().hasTwoHandedWeapon() && rules.getRule(15))) { player.sendMessage(""You can't equip "" + ItemDefinitions.getDefs(itemId).getName().toLowerCase() + "" during this duel.""); return false; } return true; } private Tile[] getPossibleTiles() { final int arenaChoice = Utils.getRandomInclusive(2); Tile[] locations = new Tile[2]; int[] arenaBoundariesX = { 3337, 3367, 3336 }; int[] arenaBoundariesY = { 3246, 3227, 3208 }; int[] maxOffsetX = { 14, 14, 16 }; int[] maxOffsetY = { 10, 10, 10 }; //Obstacles enabled if (player.getLastDuelRules().getRule(6)) { arenaBoundariesX = new int[]{ 3336, 3367, 3367 }; arenaBoundariesY = new int[]{ 3227, 3246, 3208 }; maxOffsetX = new int[]{ 14, 14, 16 }; maxOffsetY = new int[]{ 10, 10, 10 }; } int finalX = arenaBoundariesX[arenaChoice] + Utils.getRandomInclusive(maxOffsetX[arenaChoice]); int finalY = arenaBoundariesY[arenaChoice] + Utils.getRandomInclusive(maxOffsetY[arenaChoice]); locations[0] = (Tile.of(finalX, finalY, 0)); if (player.getLastDuelRules().getRule(25)) { int direction = Utils.getRandomInclusive(1); if (direction == 0) finalX--; else finalY++; } else { finalX = arenaBoundariesX[arenaChoice] + Utils.getRandomInclusive(maxOffsetX[arenaChoice]); finalY = arenaBoundariesY[arenaChoice] + Utils.getRandomInclusive(maxOffsetY[arenaChoice]); } locations[1] = (Tile.of(finalX, finalY, 0)); return locations; } @Override public boolean processButtonClick(int interfaceId, int componentId, int slotId, int slotId2, ClientPacket packet) { synchronized (this) { synchronized (target.getControllerManager().getController()) { DuelRules rules = player.getLastDuelRules(); switch (interfaceId) { case 271: if (rules.getRule(5) && isDueling) { player.sendMessage(""You can't use prayers in this duel.""); return false; } return true; case 193: case 430: case 192: if (rules.getRule(2) && isDueling) return false; return true; case 884: if (componentId == 4) if (rules.getRule(9) && isDueling) { player.sendMessage(""You can't use special attacks in this duel.""); return false; } return true; case 631: switch (componentId) { case 56: // no range rules.setRules(0); return false; case 57: // no melee rules.setRules(1); return false; case 58: // no magic rules.setRules(2); return false; case 59: // fun wep rules.setRules(8); return false; case 60: // no forfiet rules.setRules(7); return false; case 61: // no drinks rules.setRules(3); return false; case 62: // no food rules.setRules(4); return false; case 63: // no prayer rules.setRules(5); return false; case 64: // no movement rules.setRules(25); if (rules.getRule(6)) { rules.setRule(6, false); player.sendMessage(""You can't have obstacles without movement.""); } return false; case 65: // obstacles rules.setRules(6); if (rules.getRule(25)) { rules.setRule(25, false); player.sendMessage(""You can't have obstacles without movement.""); } return false; case 66: // enable summoning rules.setRules(24); return false; case 67:// no spec rules.setRules(9); return false; case 21:// no helm rules.setRules(10); return false; case 22:// no cape rules.setRules(11); return false; case 23:// no ammy rules.setRules(12); return false; case 31:// arrows rules.setRules(23); return false; case 24:// weapon rules.setRules(13); return false; case 25:// body rules.setRules(14); return false; case 26:// shield rules.setRules(15); return false; case 27:// legs rules.setRules(17); return false; case 28:// ring rules.setRules(19); return false; case 29: // bots rules.setRules(20); return false; case 30: // gloves rules.setRules(22); return false; case 107: closeDuelInteraction(true, DuelStage.DECLINED); return false; case 46: accept(true); return false; case 47: switch (packet) { case IF_OP1: removeItem(slotId, 1); return false; case IF_OP2: removeItem(slotId, 5); return false; case IF_OP3: removeItem(slotId, 10); return false; case IF_OP4: Item item = player.getInventory().getItems().get(slotId); if (item == null) return false; removeItem(slotId, player.getLastDuelRules().getStake().getNumberOf(item)); return false; case IF_OP5: player.getInventory().sendExamine(slotId); return false; case IF_OP7: player.getInventory().sendExamine(slotId); return false; default: break; } return false; } case 628: switch (packet) { case IF_OP1: // addItem(slotId, 1); return false; case IF_OP2: // addItem(slotId, 5); return false; case IF_OP3: // addItem(slotId, 10); return false; case IF_OP4: Item item = player.getInventory().getItems().get(slotId); if (item == null) return false; // addItem(slotId, // player.getInventory().getItems().getNumberOf(item)); return false; case IF_OP5: player.getInventory().sendExamine(slotId); return false; case IF_OP7: player.getInventory().sendExamine(slotId); return false; default: break; } case 626: switch (componentId) { case 43: accept(false); return false; } case 637: // friendly switch (componentId) { case 25: // no range rules.setRules(0); return false; case 26: // no melee rules.setRules(1); return false; case 27: // no magic rules.setRules(2); return false; case 28: // fun wep rules.setRules(8); return false; case 29: // no forfiet rules.setRules(7); return false; case 30: // no drinks rules.setRules(3); return false; case 31: // no food rules.setRules(4); return false; case 32: // no prayer rules.setRules(5); return false; case 33: // no movement rules.setRules(25); if (rules.getRule(6)) { rules.setRule(6, false); player.sendMessage(""You can't have movement without obstacles.""); } return false; case 34: // obstacles rules.setRules(6); if (rules.getRule(25)) { rules.setRule(25, false); player.sendMessage(""You can't have obstacles without movement.""); } return false; case 35: // enable summoning rules.setRules(24); return false; case 36:// no spec rules.setRules(9); return false; case 43:// no helm rules.setRules(10); return false; case 44:// no cape rules.setRules(11); return false; case 45:// no ammy rules.setRules(12); return false; case 53:// arrows rules.setRules(23); return false; case 46:// weapon rules.setRules(13); return false; case 47:// body rules.setRules(14); return false; case 48:// shield rules.setRules(15); return false; case 49:// legs rules.setRules(17); return false; case 50:// ring rules.setRules(19); return false; case 51: // bots rules.setRules(20); return false; case 52: // gloves rules.setRules(22); return false; case 86: closeDuelInteraction(true, DuelStage.DECLINED); return false; case 21: accept(true); return false; } case 639: switch (componentId) { case 25: accept(false); return false; } } } } return true; } public boolean isDueling() { return isDueling; } public boolean hasTarget() { return target != null; } public Entity getTarget() { if (hasTarget()) return target; return null; } enum DuelStage { DECLINED, NO_SPACE, SECOND, DONE } }" "package com.rs.game.content.minigames.duel; @PluginEventHandler public class DuelController extends Controller { public static ButtonClickHandler handleDuelRequest = new ButtonClickHandler(640, e -> { if (e.getComponentId() == 18 || e.getComponentId() == 22) { e.getPlayer().getTempAttribs().setB(""WillDuelFriendly"", true); e.getPlayer().getVars().setVar(283, 67108864); } else if (e.getComponentId() == 19 || e.getComponentId() == 21) { e.getPlayer().getTempAttribs().setB(""WillDuelFriendly"", false); e.getPlayer().getVars().setVar(283, 134217728); } else if (e.getComponentId() == 20) challenge(e.getPlayer()); }); @Override public void start() { sendInterfaces(); player.getAppearance().generateAppearanceData(); player.setPlayerOption(""Challenge"", 1); moved(); } @Override public boolean login() { start(); return false; } @Override public boolean logout() { return false; } @Override public void forceClose() { remove(); } @Override public boolean processTeleport(Teleport tele) { return true; } @Override public void onTeleported(TeleType type) { removeController(); remove(); } @Override public void moved() { if (!isAtDuelArena(player.getTile())) { removeController(); remove(); } } @Override public boolean canPlayerOption1(final Player target) { player.stopAll(); if (target.getInterfaceManager().containsScreenInter()) { player.sendMessage(""The other player is busy.""); return false; } if (target.getTempAttribs().getO(""DuelChallenged"") == player) { player.getControllerManager().removeControllerWithoutCheck(); target.getControllerManager().removeControllerWithoutCheck(); target.getTempAttribs().removeO(""DuelChallenged""); player.setLastDuelRules(new DuelRules(player, target)); target.setLastDuelRules(new DuelRules(target, player)); player.getControllerManager().startController(new DuelArenaController(target, target.getTempAttribs().getB(""DuelFriendly""))); target.getControllerManager().startController(new DuelArenaController(player, target.getTempAttribs().removeB(""DuelFriendly""))); return false; } player.getTempAttribs().setO(""DuelTarget"", target); player.getInterfaceManager().sendInterface(640); player.getTempAttribs().setB(""WillDuelFriendly"", true); player.getVars().setVar(283, 67108864); return false; } public static void challenge(Player player) { player.closeInterfaces(); Player target = player.getTempAttribs().getO(""DuelTarget""); if (target == null || target.hasFinished() || !target.withinDistance(player.getTile(), 14) || !(target.getControllerManager().getController() instanceof DuelController)) { player.sendMessage(""Unable to find "" + (target == null ? ""your target"" : target.getDisplayName())); return; } player.getTempAttribs().setO(""DuelChallenged"", target); player.getTempAttribs().setB(""DuelFriendly"", player.getTempAttribs().getB(""WillDuelFriendly"")); player.sendMessage(""Sending "" + target.getDisplayName() + "" a request...""); target.getPackets().sendDuelChallengeRequestMessage(player, player.getTempAttribs().getB(""WillDuelFriendly"")); } public void remove() { player.getInterfaceManager().removeOverlay(); player.getAppearance().generateAppearanceData(); player.setPlayerOption(""null"", 1); } @Override public void sendInterfaces() { if (isAtDuelArena(player.getTile())) player.getInterfaceManager().sendOverlay(638); } public static boolean isAtDuelArena(Tile player) { return (player.getX() >= 3355 && player.getX() <= 3360 && player.getY() >= 3267 && player.getY() <= 3279) || (player.getX() >= 3355 && player.getX() <= 3379 && player.getY() >= 3272 && player.getY() <= 3279) || (player.getX() >= 3374 && player.getX() <= 3379 && player.getY() >= 3267 && player.getY() <= 3271); } }" "package com.rs.game.content.minigames.duel; public class DuelRules { private final Player player; private final Player target; public boolean[] duelRules = new boolean[26]; private final ItemsContainer stake; public DuelRules(Player player, Player target) { this.player = player; this.target = target; stake = new ItemsContainer<>(28, false); } public boolean canAccept(ItemsContainer stake) { if (getRule(0) && getRule(1) && getRule(2)) { player.sendMessage(""You have to be able to use atleast one combat style in a duel."", true); return false; } int count = 0; Item item; for (int i = 10; i < 24; i++) { int slot = i - 10; if (getRule(i) && (item = player.getEquipment().getItem(slot)) != null) if (i == 23) {// arrows if (!(item.getDefinitions().isStackable() && player.getInventory().getItems().containsOne(item))) count++; } else count++; } int freeSlots = player.getInventory().getItems().freeSlots() - count; if (freeSlots < 0) { player.sendMessage(""You do not have enough inventory space to remove all the equipment.""); getTarget().sendMessage(""Your opponent does not have enough space to remove all the equipment.""); return false; } for (int i = 0; i < stake.getSize(); i++) if (stake.get(i) != null) freeSlots--; if (freeSlots < 0) { player.sendMessage(""You do not have enough room in your inventory for this stake.""); getTarget().sendMessage(""Your opponent does not have enough room in his inventory for this stake.""); return false; } return true; } public void setRules(int ruleId) { setRules(ruleId, true); } public void setRules(int ruleId, boolean updated) { if (!getRule(ruleId)) setRule(ruleId, true); else if (getRule(ruleId)) setRule(ruleId, false); if (updated) { DuelRules rules = getTarget().getLastDuelRules(); if (rules == null) return; rules.setRules(ruleId, false); } setConfigs(); } public void setConfigs() { int value = 0; int ruleId = 16; for (int i = 0; i < duelRules.length; i++) { if (getRule(i)) { if (i == 7) // forfiet value += 5; if (i == 25) // no movement value += 6; value += ruleId; } ruleId += ruleId; } player.getVars().setVar(286, value); } public boolean setRule(int ruleId, boolean value) { return duelRules[ruleId] = value; } public boolean getRule(int ruleId) { return duelRules[ruleId]; } public ItemsContainer getStake() { return stake; } public Player getTarget() { return target; } }" "package com.rs.game.content.minigames.ectofuntus; public class EctoBones extends PlayerAction { public EctoBones(int itemId) { this.itemId = itemId; } int itemId; int step = 0; @Override public boolean start(Player player) { step = 0; return true; } @Override public boolean process(Player player) { if (step == -1) return false; return true; } @Override public int processWithDelay(Player player) { switch (step) { case 0: if (!Ectofuntus.hopper(player, itemId)) step = -1; else step++; return 2; case 1: if (!Ectofuntus.grinder(player)) step = -1; else step++; return 2; case 2: if (!Ectofuntus.bin(player)) step = -1; else step = 0; return 2; default: stop(player); } return 4; } @Override public void stop(Player player) { } }" "package com.rs.game.content.minigames.ectofuntus; @PluginEventHandler public class Ectofuntus { public static final int EMPTY_POT = 1931; public static final int EMPTY_BUCKET = 1925; public static final int ECTO_TOKEN = 4278; public static final int BUCKET_OF_SLIME = 4286; public static final int ECTOPHIAL = 4251; public static ObjectClickHandler handleEntrance = new ObjectClickHandler(new Object[]{5268}, e -> e.getPlayer().useLadder(Tile.of(3669, 9888, 3))); public static ObjectClickHandler handleExit = new ObjectClickHandler(new Object[]{5264}, e -> e.getPlayer().useLadder(Tile.of(3654, 3519, 0))); public static ObjectClickHandler handleShortcuts = new ObjectClickHandler(new Object[]{9307, 9308}, e -> { switch (e.getObjectId()) { case 9307: if (!Agility.hasLevel(e.getPlayer(), 53)) return; e.getPlayer().useLadder(Tile.of(3670, 9888, 3)); return; case 9308: if (!Agility.hasLevel(e.getPlayer(), 53)) return; e.getPlayer().useLadder(Tile.of(3671, 9888, 2)); return; } }); public static ObjectClickHandler handleStairs = new ObjectClickHandler(new Object[]{5262, 5263}, e -> { switch (e.getObjectId()) { case 5262: if (e.getPlayer().getPlane() == 2) e.getPlayer().tele(Tile.of(3692, 9888, 3)); if (e.getPlayer().getPlane() == 1) e.getPlayer().tele(Tile.of(3671, 9888, 2)); if (e.getPlayer().getPlane() == 0) e.getPlayer().tele(Tile.of(3687, 9888, 1)); return; case 5263: if (e.getPlayer().getPlane() == 3) e.getPlayer().tele(Tile.of(3688, 9888, 2)); if (e.getPlayer().getPlane() == 2) e.getPlayer().tele(Tile.of(3675, 9887, 1)); if (e.getPlayer().getPlane() == 1) e.getPlayer().tele(Tile.of(3683, 9888, 0)); return; } }); public static ObjectClickHandler handleWorship = new ObjectClickHandler(new Object[]{5282}, e -> { if (!e.getPlayer().getInventory().containsItem(BUCKET_OF_SLIME, 1)) { e.getPlayer().sendMessage(""You need a bucket of slime before you can worship the ectofuntus.""); return; } for (Item item : e.getPlayer().getInventory().getItems().array()) { if (item == null) continue; BoneMeal bone = BoneMeal.forMealId(item.getId()); if (bone != null) { Burying.Bone boneData = Burying.Bone.forId(bone.getBoneId()); if (boneData == null) { e.getPlayer().sendMessage(""Error bone not added.. Please post the bone you tried to add on the forums.""); return; } e.getPlayer().incrementCount(ItemDefinitions.getDefs(bone.getBoneId()).getName() + "" offered at ectofuntus""); e.getPlayer().setNextAnimation(new Animation(1651)); e.getPlayer().getInventory().deleteItem(bone.getBoneMealId(), 1); if (!bone.name().contains(""ASHES"")) e.getPlayer().getInventory().addItem(EMPTY_POT, 1); e.getPlayer().getInventory().deleteItem(BUCKET_OF_SLIME, 1); e.getPlayer().getInventory().addItem(EMPTY_BUCKET, 1); e.getPlayer().getSkills().addXp(Constants.PRAYER, boneData.getExperience() * 4); e.getPlayer().unclaimedEctoTokens += 5; return; } } }); public static ObjectClickHandler handleGrinder = new ObjectClickHandler(new Object[]{11163}, e -> grinder(e.getPlayer())); public static ObjectClickHandler handleBin = new ObjectClickHandler(new Object[]{11164}, e -> bin(e.getPlayer())); public static void sendEctophialTeleport(Player player, Tile tile) { Magic.sendTeleportSpell(player, 8939, 8941, 1678, 1679, 0, 0, tile, 3, true, TeleType.MAGIC, () -> player.soundEffect(4580, true), null); } public static boolean handleItemOnObject(Player player, int itemId, int objectId) { ObjectDefinitions objectDefs = ObjectDefinitions.getDefs(objectId); ItemDefinitions itemDefs = ItemDefinitions.getDefs(itemId); if (itemId == EMPTY_BUCKET && objectDefs.getName().equals(""Pool of Slime"")) { player.getActionManager().setAction(new SlimeBucketFill()); return true; } if (itemDefs.getName().toLowerCase().contains(""bone"") && objectId == 11162) { player.getActionManager().setAction(new EctoBones(itemId)); return true; } return false; } public static boolean hopper(Player player, int itemId) { if (player.boneType != -1 && player.boneType != 0) { player.sendMessage(""You already have some bones in the hopper.""); return false; } if (!player.getInventory().containsItem(itemId, 1)) return false; BoneMeal meal = BoneMeal.forBoneId(itemId); if (meal != null) { player.boneType = meal.getBoneId(); player.sendMessage(""You put the bones in the hopper."", true); player.setNextAnimation(new Animation(1649)); player.getInventory().deleteItem(meal.getBoneId(), 1); return true; } player.boneType = -1; return false; } public static boolean grinder(Player player) { if (player.boneType != -1 && !player.bonesGrinded) { player.sendMessage(""You turn the grinder, some crushed bones fall into the bin."", true); player.setNextAnimation(new Animation(1648)); player.bonesGrinded = true; return true; } player.setNextAnimation(new Animation(1648)); return false; } public static boolean bin(Player player) { if (player.boneType == -1) { player.sendMessage(""You need to put some bones in the hopper and grind them first.""); return false; } if (!player.bonesGrinded) { player.sendMessage(""You need to grind the bones by turning the grinder first.""); return false; } if (player.boneType != -1 && player.bonesGrinded) { BoneMeal meal = BoneMeal.forBoneId(player.boneType); if (meal != null) { player.sendMessage(""You fill an empty pot with bones."", true); player.setNextAnimation(new Animation(1650)); player.getInventory().deleteItem(EMPTY_POT, 1); player.getInventory().addItem(meal.getBoneMealId(), 1); player.boneType = -1; player.bonesGrinded = false; return true; } player.boneType = -1; } return false; } public static enum BoneMeal { BONES(526, 4255), BAT_BONES(530, 4256), BIG_BONES(532, 4257), BABY_DRAGON_BONES(534, 4260), DRAGON_BONES(536, 4261), DAGANNOTH_BONES(6729, 6728), WYVERN_BONES(6812, 6810), OURG_BONES(4834, 4855), OURG_BONES_2(14793, 4855), FROST_BONES(18832, 18834), IMPIOUS_ASHES(20264, 20264), ACCURSED_ASHES(20266, 20266), INFERNAL_ASHES(20268, 20268); private static final Map bonemeals = new HashMap<>(); private static final Map bones = new HashMap<>(); static { for (final BoneMeal bonemeal : BoneMeal.values()) bonemeals.put(bonemeal.boneId, bonemeal); for (final BoneMeal bonemeal : BoneMeal.values()) bones.put(bonemeal.boneMealId, bonemeal); } private final int boneId; private final int boneMealId; private BoneMeal(int boneId, int boneMealId) { this.boneId = boneId; this.boneMealId = boneMealId; } public static BoneMeal forBoneId(int itemId) { return bonemeals.get(itemId); } public static BoneMeal forMealId(int itemId) { return bones.get(itemId); } public int getBoneId() { return boneId; } public int getBoneMealId() { return boneMealId; } } }" "package com.rs.game.content.minigames.ectofuntus; public class SlimeBucketFill extends PlayerAction { public SlimeBucketFill() { } @Override public boolean start(Player player) { return true; } @Override public boolean process(Player player) { if (player.getInventory().containsItem(Ectofuntus.EMPTY_BUCKET, 1)) return true; return false; } @Override public int processWithDelay(Player player) { if (fillBucket(player)) return 1; return 1; } @Override public void stop(Player player) { } public boolean fillBucket(Player player) { if (player.getInventory().containsItem(Ectofuntus.EMPTY_BUCKET, 1)) { player.setNextAnimation(new Animation(4471)); player.getInventory().deleteItem(Ectofuntus.EMPTY_BUCKET, 1); player.soundEffect(1132, true); player.getInventory().addItem(Ectofuntus.BUCKET_OF_SLIME, 1); return true; } return false; } }" "package com.rs.game.content.minigames.fightcaves; public class FightCavesController extends Controller { public static final Tile OUTSIDE = Tile.of(4610, 5130, 0); private static final int THHAAR_MEJ_JAL = 2617; private static final int[] MUSICS = { 1088, 1082, 1086 }; public void playMusic() { player.getMusicsManager().playSongAndUnlock(selectedMusic); } private static final int[][] WAVES = { { 2734 }, { 2734, 2734 }, { 2736 }, { 2736, 2734 }, { 2736, 2734, 2734 }, { 2736, 2736 }, { 2739 }, { 2739, 2734 }, { 2739, 2734, 2734 }, { 2739, 2736 }, { 2739, 2736, 2734 }, { 2739, 2736, 2734, 2734 }, { 2739, 2736, 2736 }, { 2739, 2739 }, { 2741 }, { 2741, 2734 }, { 2741, 2734, 2734 }, { 2741, 2736 }, { 2741, 2736, 2734 }, { 2741, 2736, 2734, 2734 }, { 2741, 2736, 2736 }, { 2741, 2739 }, { 2741, 2739, 2734 }, { 2741, 2739, 2734, 2734 }, { 2741, 2739, 2736 }, { 2741, 2739, 2736, 2734 }, { 2741, 2739, 2736, 2734, 2734 }, { 2741, 2739, 2736, 2736 }, { 2741, 2739, 2739 }, { 2741, 2741 }, { 2743 }, { 2743, 2734 }, { 2743, 2734, 2734 }, { 2743, 2736 }, { 2743, 2736, 2734 }, { 2743, 2736, 2734, 2734 }, { 2743, 2736, 2736 }, { 2743, 2739 }, { 2743, 2739, 2734 }, { 2743, 2739, 2734, 2734 }, { 2743, 2739, 2736 }, { 2743, 2739, 2736, 2734 }, { 2743, 2739, 2736, 2734, 2734 }, { 2743, 2739, 2736, 2736 }, { 2743, 2739, 2739 }, { 2743, 2741 }, { 2743, 2741, 2734 }, { 2743, 2741, 2734, 2734 }, { 2743, 2741, 2736 }, { 2743, 2741, 2736, 2734 }, { 2743, 2741, 2736, 2734, 2734 }, { 2743, 2741, 2736, 2736 }, { 2743, 2741, 2739 }, { 2743, 2741, 2739, 2734 }, { 2743, 2741, 2739, 2734, 2734 }, { 2743, 2741, 2739, 2736 }, { 2743, 2741, 2739, 2736, 2734 }, { 2743, 2741, 2739, 2736, 2734, 2734 }, { 2743, 2741, 2739, 2736, 2736 }, { 2743, 2741, 2739, 2739 }, { 2743, 2741, 2741 }, { 2743, 2743 }, { 2745 } }; private transient Instance region; private transient Tile center; private transient Stages stage; public transient boolean spawned; private transient boolean logoutAtEnd; private int wave; private boolean login; public int selectedMusic; public FightCavesController(int wave) { this.wave = wave; } public static void enterFightCaves(Player player) { if (player.getFamiliar() != null || player.getPet() != null || Summoning.hasPouch(player) || Pets.hasPet(player)) { player.npcDialogue(THHAAR_MEJ_JAL, HeadE.T_CALM_TALK, ""No Kimit-Zil in the pits! This is a fight for YOU, not your friends!""); return; } player.getControllerManager().startController(new FightCavesController(1)); } private static enum Stages { LOADING, RUNNING, DESTROYING } @Override public void start() { loadCave(false); } @Override public boolean processButtonClick(int interfaceId, int componentId, int slotId, int slotId2, ClientPacket packet) { if (stage != Stages.RUNNING) return false; if (interfaceId == 182 && (componentId == 6 || componentId == 13)) { if (!logoutAtEnd) { logoutAtEnd = true; player.sendMessage(""You will be logged out automatically at the end of this wave.""); player.sendMessage(""If you log out sooner, you will have to repeat this wave.""); } else player.forceLogout(); return false; } return true; } /** * return process normaly */ @Override public boolean processObjectClick1(GameObject object) { if (object.getId() == 9357) { if (stage != Stages.RUNNING) return false; exitCave(1); return false; } return true; } /* * return false so wont remove script */ @Override public boolean login() { loadCave(true); return false; } public void loadCave(final boolean login) { this.login = login; stage = Stages.LOADING; player.lock(); // locks player region = Instance.of(OUTSIDE, 8, 8); region.copyMapAllPlanes(552, 640).thenAccept(e -> { selectedMusic = MUSICS[Utils.random(MUSICS.length)]; player.tele(!login ? getTile(46, 61) : getTile(32, 32)); stage = Stages.RUNNING; WorldTasks.delay(1, () -> { if (!login) { Tile walkTo = getTile(32, 32); player.addWalkSteps(walkTo.getX(), walkTo.getY()); } center = Tile.of(getTile(32, 32)); player.npcDialogue(THHAAR_MEJ_JAL, HeadE.T_CALM_TALK, ""You're on your own now, JalYt.
Prepare to fight for your life!""); player.setForceMultiArea(true); playMusic(); player.unlock(); // unlocks player if (!login) { WorldTasks.schedule(new Task() { @Override public void run() { if (stage != Stages.RUNNING) return; try { startWave(); } catch (Throwable t) { Logger.handle(FightCavesController.class, ""loadCave"", t); } } }, Ticks.fromSeconds(30)); } }); }); } public Tile getSpawnTile() { return switch (Utils.random(5)) { case 0 -> getTile(11, 16); case 1 -> getTile(51, 25); case 2 -> getTile(10, 50); case 3 -> getTile(46, 49); default -> getTile(32, 30); }; } @Override public void moved() { if (stage != Stages.RUNNING || !login) return; login = false; setWaveEvent(); } public void startWave() { int currentWave = getCurrentWave(); if (currentWave > WAVES.length) { win(); return; } player.getInterfaceManager().sendOverlay(316); player.getVars().setVar(639, currentWave); player.getVars().setVarBit(1549, currentWave); if (stage != Stages.RUNNING) return; for (int id : WAVES[currentWave - 1]) if (id == 2736) new TzKekCaves(id, getSpawnTile()); else if (id == 2745) new TzTok_Jad(id, getSpawnTile(), this); else new FightCavesNPC(id, getSpawnTile()); spawned = true; } public void spawnHealers() { if (stage != Stages.RUNNING) return; for (int i = 0; i < 4; i++) new FightCavesNPC(2746, getSpawnTile()); } public void win() { if (stage != Stages.RUNNING) return; exitCave(4); } public void nextWave() { playMusic(); setCurrentWave(getCurrentWave() + 1); if (logoutAtEnd) { player.forceLogout(); return; } setWaveEvent(); } public void setWaveEvent() { if (getCurrentWave() == 63) player.npcDialogue(THHAAR_MEJ_JAL, HeadE.T_CALM_TALK, ""Look out, here comes TzTok-Jad!""); WorldTasks.schedule(new Task() { @Override public void run() { try { if (stage != Stages.RUNNING) return; startWave(); } catch (Throwable e) { Logger.handle(FightCavesController.class, ""setWaveEvent"", e); } } }, 1); } @Override public void process() { if (spawned) { if (World.getServerTicks() % Ticks.fromSeconds(10) == 0) { if (World.getNPCsInChunkRange(center.getChunkId(), 5).isEmpty()) { spawned = false; nextWave(); } } } } @Override public boolean sendDeath() { player.safeDeath(Tile.of(OUTSIDE, 2), ""You have been defeated!"", p -> exitCave(1)); return false; } @Override public void onTeleported(TeleType type) { exitCave(2); } @Override public boolean processTeleport(Teleport tele) { player.sendMessage(""A mysterious force prevents you from teleporting.""); return false; } /* * logout or not. if didnt logout means lost, 0 logout, 1, normal, 2 tele */ public void exitCave(int type) { stage = Stages.DESTROYING; Tile outside = Tile.of(OUTSIDE, 2); // radomizes alil if (type == 0 || type == 2) player.setTile(outside); else { player.setForceMultiArea(false); player.getInterfaceManager().removeOverlay(); if (type == 1 || type == 4) { player.tele(outside); if (type == 4) { player.incrementCount(""Fight Caves clears""); player.refreshFightKilnEntrance(); player.reset(); player.npcDialogue(THHAAR_MEJ_JAL, HeadE.T_CALM_TALK, ""You even defeated Tz Tok-Jad, I am most impressed! Please accept this gift as a reward.""); player.sendMessage(""You were victorious!!""); for (Player p : World.getPlayers()) { if (p == null || p.hasFinished()) continue; p.sendMessage("""" + player.getDisplayName() + "" has just completed the fight caves!"", true); } if (!player.getInventory().addItem(6570, 1)) { World.addGroundItem(new Item(6570, 1), Tile.of(player.getTile()), player, true, 180); World.addGroundItem(new Item(6529, 16064), Tile.of(player.getTile()), player, true, 180); } else if (!player.getInventory().addItem(6529, 16064)) World.addGroundItem(new Item(6529, 16064), Tile.of(player.getTile()), player, true, 180); } else if (getCurrentWave() == 1) player.npcDialogue(THHAAR_MEJ_JAL, HeadE.T_CALM_TALK, ""Well I suppose you tried... better luck next time.""); else { int tokkul = getCurrentWave() * 8032 / WAVES.length; if (!player.getInventory().addItem(6529, tokkul)) World.addGroundItem(new Item(6529, tokkul), Tile.of(player.getTile()), player, true, 180); player.npcDialogue(THHAAR_MEJ_JAL, HeadE.T_CALM_TALK, ""Well done in the cave, here, take TokKul as reward.""); // TODO tokens } } removeController(); } region.destroy(); } public Tile getTile(int mapX, int mapY) { return region.getLocalTile(mapX, mapY); } @Override public boolean logout() { if (stage != Stages.RUNNING) return false; exitCave(0); return false; } public int getCurrentWave() { return wave; } public void setCurrentWave(int wave) { this.wave = wave; } @Override public void forceClose() { /* * shouldnt happen */ if (stage != Stages.RUNNING) return; exitCave(2); } }" "package com.rs.game.content.minigames.fightcaves.npcs; public class FightCavesNPC extends NPC { public FightCavesNPC(int id, Tile tile) { super(id, tile, true); setForceMultiArea(true); setIgnoreDocile(true); setNoDistanceCheck(true); } @Override public void sendDeath(Entity source) { setNextSpotAnim(new SpotAnim(2924 + getSize())); super.sendDeath(source); } @Override public List getPossibleTargets() { return queryNearbyPlayersByTileRangeAsEntityList(64, player -> !player.isDead()); } }" "package com.rs.game.content.minigames.fightcaves.npcs; public class JadCombat extends CombatScript { @Override public Object[] getKeys() { return new Object[] { 2745, 15208 }; } @Override public int attack(final NPC npc, final Entity target) { final NPCCombatDefinitions defs = npc.getCombatDefinitions(); int attackStyle = Utils.random(3); if (attackStyle == 2) { if (npc.inMeleeRange(target)) { npc.setNextAnimation(new Animation(defs.getAttackEmote())); delayHit(npc, 1, target, getMeleeHit(npc, getMaxHit(npc, defs.getMaxHit(), AttackStyle.MELEE, target))); return npc.getAttackSpeed(); } attackStyle = Utils.random(2); } if (attackStyle == 1) { // range npc.setNextAnimation(new Animation(16202)); npc.setNextSpotAnim(new SpotAnim(2994)); WorldTasks.schedule(new Task() { @Override public void run() { WorldTasks.schedule(new Task() { @Override public void run() { target.setNextSpotAnim(new SpotAnim(3000)); } }, 0); delayHit(npc, 2, target, getRangeHit(npc, getMaxHit(npc, defs.getMaxHit() - 2, AttackStyle.RANGE, target))); } }, 2); } else { npc.setNextAnimation(new Animation(16195)); npc.setNextSpotAnim(new SpotAnim(2995)); WorldTasks.schedule(new Task() { @Override public void run() { WorldProjectile p = World.sendProjectile(npc, target, 2996, 80, 30, 40, 5, 5, 0); target.setNextSpotAnim(new SpotAnim(2741, 0, 100)); delayHit(npc, p.getTaskDelay(), target, getMagicHit(npc, getMaxHit(npc, defs.getMaxHit() - 2, AttackStyle.MAGE, target))); } }, 2); } return 8; } }" "package com.rs.game.content.minigames.fightcaves.npcs; public class KetZekCombat extends CombatScript { @Override public Object[] getKeys() { return new Object[] { ""Ket-Zek"", 15207 }; }// anims: DeathEmote: 9257 DefEmote: 9253 AttackAnim: 9252 gfxs: healing: // 444 - healer @Override public int attack(final NPC npc, final Entity target) { final NPCCombatDefinitions defs = npc.getCombatDefinitions(); int distanceX = target.getX() - npc.getX(); int distanceY = target.getY() - npc.getY(); int size = npc.getSize(); int hit = 0; if (distanceX > size || distanceX < -1 || distanceY > size || distanceY < -1) { commenceMagicAttack(npc, target); return npc.getAttackSpeed(); } int attackStyle = Utils.getRandomInclusive(1); switch (attackStyle) { case 0: hit = getMaxHit(npc, defs.getMaxHit(), AttackStyle.MELEE, target); npc.setNextAnimation(new Animation(defs.getAttackEmote())); delayHit(npc, 0, target, getMeleeHit(npc, hit)); break; case 1: commenceMagicAttack(npc, target); break; } return npc.getAttackSpeed(); } private void commenceMagicAttack(final NPC npc, final Entity target) { int hit = getMaxHit(npc, npc.getCombatDefinitions().getMaxHit() - 50, AttackStyle.MAGE, target); npc.setNextAnimation(new Animation(16136)); // npc.setNextGraphics(new Graphics(1622, 0, 96 << 16)); World.sendProjectile(npc, target, 2984, 34, 16, 30, 2, 16, 0); delayHit(npc, 2, target, getMagicHit(npc, hit)); WorldTasks.schedule(new Task() { @Override public void run() { target.setNextSpotAnim(new SpotAnim(2983, 0, 96 << 16)); } }, 2); } }" "package com.rs.game.content.minigames.fightcaves.npcs; public class TzKekCaves extends FightCavesNPC { public TzKekCaves(int id, Tile tile) { super(id, tile); } @Override public void sendDeath(Entity source) { final NPCCombatDefinitions defs = getCombatDefinitions(); resetWalkSteps(); getCombat().removeTarget(); setNextAnimation(null); Tile tile = Tile.of(getTile()); WorldTasks.scheduleTimer(loop -> { if (loop == 0) { setNextAnimation(new Animation(defs.getDeathEmote())); setNextSpotAnim(new SpotAnim(2924 + getSize())); } else if (loop >= defs.getDeathDelay()) { reset(); new FightCavesNPC(2738, tile); Tile finTile = tile; if (World.floorAndWallsFree(getPlane(), tile.getX() + 1, tile.getY(), 1)) finTile = tile.transform(1, 0, 0); else if (World.floorAndWallsFree(getPlane(), tile.getX() - 1, tile.getY(), 1)) finTile = tile.transform(-1, 0, 0); else if (World.floorAndWallsFree(getPlane(), tile.getX(), tile.getY() - 1, 1)) finTile = tile.transform(0, -1, 0); else if (World.floorAndWallsFree(getPlane(), tile.getX(), tile.getY() + 1, 1)) finTile = tile.transform(0, 1, 0); new FightCavesNPC(2738, finTile); finish(); return false; } return true; }); } @Override public void removeHitpoints(Hit hit) { super.removeHitpoints(hit); if (hit.getLook() != HitLook.MELEE_DAMAGE || hit.getSource() == null) return; hit.getSource().applyHit(new Hit(this, 10, HitLook.TRUE_DAMAGE)); } }" "package com.rs.game.content.minigames.fightcaves.npcs; public class TzKihCombat extends CombatScript { @Override public Object[] getKeys() { return new Object[] { ""Tz-Kih"" }; } @Override public int attack(NPC npc, Entity target) {// yoa final NPCCombatDefinitions defs = npc.getCombatDefinitions(); int damage = 0; npc.setNextAnimation(new Animation(defs.getAttackEmote())); damage = getMaxHit(npc, defs.getMaxHit(), AttackStyle.MELEE, target); if (target instanceof Player player) player.getPrayer().drainPrayer(damage + 10); delayHit(npc, 0, target, getMeleeHit(npc, damage)); return npc.getAttackSpeed(); } }" "package com.rs.game.content.minigames.fightcaves.npcs; public class TzTok_Jad extends FightCavesNPC { private boolean spawnedMinions; private final FightCavesController controller; public TzTok_Jad(int id, Tile tile, FightCavesController controller) { super(id, tile); this.controller = controller; setNoDistanceCheck(true); } @Override public void processNPC() { super.processNPC(); if (!spawnedMinions && getHitpoints() < getMaxHitpoints() / 2) { spawnedMinions = true; controller.spawnHealers(); } } @Override public void sendDeath(Entity source) { final NPCCombatDefinitions defs = getCombatDefinitions(); resetWalkSteps(); getCombat().removeTarget(); setNextAnimation(null); WorldTasks.scheduleTimer(loop -> { if (loop == 0) { setNextAnimation(new Animation(defs.getDeathEmote())); setNextSpotAnim(new SpotAnim(2924 + getSize())); } else if (loop >= defs.getDeathDelay()) { reset(); finish(); if (source instanceof Player p) p.sendNPCKill(getDefinitions().getName(p.getVars())); controller.win(); return false; } return true; }); } }" "package com.rs.game.content.minigames.fightcaves.npcs; public class YtMejKotCombat extends CombatScript { @Override public Object[] getKeys() { return new Object[] { ""Yt-MejKot"" }; } @Override public int attack(NPC npc, Entity target) { final NPCCombatDefinitions defs = npc.getCombatDefinitions(); npc.setNextAnimation(new Animation(defs.getAttackEmote())); delayHit(npc, 0, target, getMeleeHit(npc, getMaxHit(npc, defs.getMaxHit(), defs.getAttackStyle(), target))); if (npc.getHitpoints() < npc.getMaxHitpoints() / 2) if (npc.getTempAttribs().removeB(""Heal"")) { npc.setNextSpotAnim(new SpotAnim(2980, 0, 100)); npc.queryNearbyNPCsByTileRange(4, n -> { if (n == null || n.isDead() || n.hasFinished()) return false; n.heal(100); return true; }); } else npc.getTempAttribs().setB(""Heal"", Boolean.TRUE); return npc.getAttackSpeed(); } }" "package com.rs.game.content.minigames.fightkiln; /** * T70+ * Copy this: https://www.youtube.com/watch?v=gY0CwX27Css&t=1340s&ab_channel=Smokey9112Films */ public class FightKilnController extends Controller { public static final Tile OUTSIDE = Tile.of(4744, 5172, 0); private static final int TOKHAAR_HOK = 15195, TOKHAAR_HOK_SCENE = 15200; private static final int[] MUSICS = { 1088, 1082, 1086 }; public void playMusic() { player.getMusicsManager().playSongAndUnlock(selectedMusic); } @Override public Genre getGenre() { return Music.getGenreByName(""Tzhaar City""); } @Override public boolean playAmbientOnControllerRegionEnter() { return false; } @Override public boolean playAmbientStrictlyBackgroundMusic() { return true; } /* * 0 - south east 1 - south west 2 - north west 3 - north east TokHaar-Hur - * 15201 TokHaar-Xil - 15202 TokHaar-Mej - 15203 TokHaar-Ket - 15204 * TokHaar-Tok-Xil - 15205 TokHaar-Yt-Mejkot - 15206 TokHaar-Ket-Zek - 15207 * TokHaar-Jad - 15208 TokHaar-Ket-Dill - 15213 */ private final int Hur = 15201; private final int Xil = 15202; private final int Mej = 15203; private final int Ket = 15204; private final int Tok_Xil = 15205; private final int Yt_Mejkot = 15206; private final int Ket_Zek = 15207; private final int Jad = 15208; private final int Ket_Dill = 15213; private final int[][] WAVES = { { Hur, Hur, Xil, Xil, Tok_Xil }, // 1 { Hur, Xil, Xil, Tok_Xil, Tok_Xil }, // 2 { Tok_Xil, Xil, Tok_Xil, Tok_Xil, Hur }, // 3 { Tok_Xil, Tok_Xil, Tok_Xil, Mej, Mej }, // 4 { Xil, Tok_Xil, Tok_Xil, Ket_Dill, Tok_Xil }, // 5 { Xil, Tok_Xil, Tok_Xil, Mej, Mej }, // 6 { Mej, Tok_Xil, Tok_Xil, Tok_Xil, Xil, Tok_Xil }, // 7 { Ket_Zek, Tok_Xil, Tok_Xil }, // 8 { Tok_Xil, Tok_Xil, Tok_Xil, Tok_Xil, Tok_Xil, Tok_Xil }, // 9 { Tok_Xil, Jad }, // 10 { Mej, Mej, Mej, Mej }, // 11 { Mej, Tok_Xil, Tok_Xil, Mej }, // 12 { Ket_Zek, Hur, Mej }, // 13 { Ket_Zek, Ket_Zek, Mej, Mej }, // 14 { Ket_Zek, Ket_Zek, Tok_Xil }, // 15 { Ket_Zek, Ket_Zek, Tok_Xil, Mej, Mej }, // 16 { Ket_Zek, Ket_Zek, Tok_Xil, Yt_Mejkot, Mej }, // 17 { Ket_Zek, Ket_Zek, Tok_Xil, Yt_Mejkot, Tok_Xil, Mej }, // 18 { Mej, Mej, Mej, Mej, Mej, Mej, Mej, Ket_Dill, Mej}, // 19 { Ket_Zek, Jad }, // 20 { Hur, Hur, Hur, Hur, Hur, Hur, Hur, Hur, Hur, Hur, Hur, Hur }, // 21 { Hur, Hur, Ket, Ket, Yt_Mejkot }, // 22 { Hur, Hur, Ket, Yt_Mejkot, Yt_Mejkot }, // 23 { Yt_Mejkot, Yt_Mejkot, Tok_Xil, Yt_Mejkot, Yt_Mejkot }, // 24 { Yt_Mejkot, Yt_Mejkot, Tok_Xil, Tok_Xil, Ket_Zek }, // 25 { Yt_Mejkot, Yt_Mejkot, Tok_Xil, Ket_Zek, Ket_Zek }, // 26 { Ket, Ket, Tok_Xil, Ket_Zek, Yt_Mejkot, Yt_Mejkot }, // 27 { Ket_Dill, Ket_Dill, Ket_Zek, Ket_Dill, Ket_Dill, Ket_Dill, Ket_Dill }, // 28 { Yt_Mejkot, Yt_Mejkot, Yt_Mejkot, Yt_Mejkot, Yt_Mejkot, Yt_Mejkot }, // 29 { Yt_Mejkot, Jad, Yt_Mejkot, Yt_Mejkot }, // 30 { Tok_Xil, Tok_Xil, Tok_Xil, Tok_Xil }, // 31 { Yt_Mejkot, Yt_Mejkot, Yt_Mejkot, Yt_Mejkot }, // 32 { Ket_Zek, Ket_Zek, Ket_Zek, Ket_Zek }, // 33 { Jad, Tok_Xil, Yt_Mejkot }, // 34 { Ket_Zek, Tok_Xil, Yt_Mejkot, Jad }, // 35 { Jad, Jad } // 36 }; private transient Instance region; private transient Stages stage; private transient NPC tokHaarHok; private transient HarAken harAken; private transient int aliveNPCSCount; private boolean logoutAtEnd; private boolean login; public int selectedMusic; private int wave; private final boolean debug; public FightKilnController(int wave) { this.wave = wave; this.debug = false; } public FightKilnController(int wave, boolean debug) { this.wave = wave; this.debug = true; } public static void enterFightKiln(Player player, boolean quickEnter) { if (player.getCounterValue(""Fight Caves clears"") <= 0) { player.sendMessage(""You need to have cleared the Fight Caves to enter the Kiln.""); return; } if (player.getInventory().containsOneItem(23653, 23654, 23655, 23656, 23657, 23658)) return; Familiar familiar = player.getFamiliar(); if (familiar != null && (familiar.containsOneItem(23653, 23654, 23655, 23656, 23657, 23658) || familiar.isFinished())) return; if (!quickEnter) player.startConversation(new Dialogue() .addSimple(""You journey directly to the Kiln."") .addNext(()->{ player.lock(); player.getControllerManager().startController(new FightKilnController(0)); }) ); else player.getControllerManager().startController(new FightKilnController(1)); } private enum Stages { LOADING, RUNNING, DESTROYING } @Override public void start() { loadCave(debug); } @Override public boolean processButtonClick(int interfaceId, int componentId, int slotId, int slotId2, ClientPacket packet) { if (stage != Stages.RUNNING) return false; if (interfaceId == 182 && (componentId == 6 || componentId == 13)) { if (!logoutAtEnd) { logoutAtEnd = true; player.sendMessage(""You will be logged out automatically at the end of this wave.""); player.sendMessage(""If you log out sooner, you will have to repeat this wave.""); } else player.forceLogout(); return false; } return true; } /** * return process normaly */ @Override public boolean processObjectClick1(GameObject object) { if (object.getId() == 68111) { if (stage != Stages.RUNNING) return false; exitCave(1); return false; } return true; } /* * return false so wont remove script */ @Override public boolean login() { logoutAtEnd = false; loadCave(true); return false; } public int[] getMap() { int wave = getCurrentWave(); if (wave < 11) return new int[] { 504, 632 }; if (wave < 21) return new int[] { 512, 632 }; if (wave < 31) return new int[] { 520, 632 }; if (wave < 34) return new int[] { 528, 632 }; return new int[] { 536, 632 }; } protected Dialogue getStartDialogue() { return new Dialogue() .addNPC(TOKHAAR_HOK, HeadE.T_CALM_TALK, ""Let us talk..."") .addOptions(ops -> { ops.add(""Let's fight."") .addNPC(TOKHAAR_HOK, HeadE.T_CONFUSED, ""Do you have any questions on the rules of our engagement?"") .addOptions(ops2 -> { ops2.add(""No, let's just fight."") .addPlayer(HeadE.CALM_TALK, ""No, let's just fight."") .addNext(() -> { removeTokHaarTok(); nextWave(); }); ops2.add(""What do I get if I beat you?""); //TODO ops2.add(""What are the rules?""); //TODO }); ops.add(""I'd like to speak more about you and your kind.""); //TODO }); } public void loadCave(final boolean login) { stage = Stages.LOADING; player.lock(); // locks player player.setLargeSceneView(true); int currentWave = getCurrentWave(); Runnable event = () -> { // selects a music selectedMusic = MUSICS[Utils.random(MUSICS.length)]; playMusic(); player.setForceMultiArea(true); player.stopAll(); if (currentWave == 0) { // SCENE 0 player.getInventory().removeItems(new Item(23653, Integer.MAX_VALUE), new Item(23654, Integer.MAX_VALUE), new Item(23655, Integer.MAX_VALUE), new Item(23656, Integer.MAX_VALUE), new Item(23657, Integer.MAX_VALUE), new Item(23658, Integer.MAX_VALUE)); player.tele(getTile(31, 51)); tokHaarHok = new NPC(TOKHAAR_HOK, getTile(30, 36), true); tokHaarHok.setFaceAngle(Utils.getAngleTo(0, 1)); // 1delay because player cant walk while teleing :p, // + possible issues avoid WorldTasks.scheduleLooping(new Task() { int count = 0; boolean run; @Override public void run() { if (count == 0) { Tile lookTo = getTile(29, 39); player.getPackets().sendCameraLook(player.getSceneX(lookTo.getX()), player.getSceneY(lookTo.getY()), 3500); Tile posTile = getTile(27, 30); player.getPackets().sendCameraPos(player.getSceneX(posTile.getX()), player.getSceneY(posTile.getY()), 3500); run = player.getRun(); player.setRun(false); Tile walkTo = getTile(31, 39); player.addWalkSteps(walkTo.getX(), walkTo.getY(), -1, false); } else if (count == 1) player.getPackets().sendResetCamera(); else if (count == 2) { player.startConversation(getStartDialogue()); player.setRun(run); stage = Stages.RUNNING; player.unlock(); // unlocks player stop(); } count++; } }, 1, 6); } else if (currentWave == 38) { // SCENE 7, WIN player.tele(getTile(38, 25)); player.setNextFaceTile(getTile(38, 26)); tokHaarHok = new NPC(TOKHAAR_HOK_SCENE, getTile(37, 30), true); tokHaarHok.setFaceAngle(Utils.getAngleTo(0, -1)); player.getPackets().setBlockMinimapState(2); player.getVars().setVar(1241, 1); WorldTasks.schedule(new Task() { @Override public void run() { Tile lookTo = getTile(40, 28); player.getPackets().sendCameraLook(player.getSceneX(lookTo.getX()), player.getSceneY(lookTo.getY()), 2200); Tile posTile = getTile(29, 28); player.getPackets().sendCameraPos(player.getSceneX(posTile.getX()), player.getSceneY(posTile.getY()), 2500); HarAken harAken = new HarAken(15211, getTile(45, 26), FightKilnController.this); harAken.spawn(); harAken.sendDeath(player); WorldTasks.schedule(Ticks.fromSeconds(5), () -> player.startConversation(new Conversation(player) { { addNPC(TOKHAAR_HOK_SCENE, HeadE.T_SURPRISED, ""You are a Tokhaar... born in a human's body. Truly, we have not seen such skill from anyone out of our kiln.""); addNPC(TOKHAAR_HOK_SCENE, HeadE.T_CALM_TALK, ""You have done very well. To mark your triumph, accept a trophy from our home.""); addOptions(""rewardSelect"", ""Choose your reward:"", ops -> { ops.add(""The TokHaar-Kal"") .addItem(23659, ""The TokHaar-Kal is a powerful cape that will let others see that you have mastered the Fight Kiln. In addition to this, it provides several stat boosts including 8+ strength."") .addOptions(""Accept the TokHaar-Kal?"", conf -> { conf.add(""Yes."") .addNPC(TOKHAAR_HOK_SCENE, HeadE.T_CALM_TALK, ""Let us test our strength again...soon..."", () -> player.getTempAttribs().setI(""FightKilnReward"", 0)) .addNPC(TOKHAAR_HOK_SCENE, HeadE.T_CALM_TALK, ""Now,leave...before the lava consumes you."") .addNext(FightKilnController.this::removeScene); conf.add(""No."").addGotoStage(""rewardSelect"", this); }); ops.add(""An uncut onyx"") .addItem(6571, ""Onyx is a precious and rare gem that can be crafted into one of several powerful objects, including the coveted Amulet of Fury."") .addOptions(""Accept the uncut onyx?"", conf -> { conf.add(""Yes."") .addNPC(TOKHAAR_HOK_SCENE, HeadE.T_CALM_TALK, ""Let us test our strength again...soon..."", () -> player.getTempAttribs().setI(""FightKilnReward"", 1)) .addNPC(TOKHAAR_HOK_SCENE, HeadE.T_CALM_TALK, ""Now,leave...before the lava consumes you."") .addNext(FightKilnController.this::removeScene); conf.add(""No."").addGotoStage(""rewardSelect"", this); }); }); create(); } })); } }, 1); } else if (currentWave == 37) { // SCENE 6 player.tele(getTile(38, 25)); player.setNextFaceTile(getTile(38, 26)); tokHaarHok = new NPC(TOKHAAR_HOK_SCENE, getTile(37, 30), true); tokHaarHok.setFaceAngle(Utils.getAngleTo(0, -1)); player.getPackets().setBlockMinimapState(2); player.getVars().setVar(1241, 1); WorldTasks.schedule(1, () -> { Tile lookTo = getTile(40, 28); player.getPackets().sendCameraLook(player.getSceneX(lookTo.getX()), player.getSceneY(lookTo.getY()), 2200); Tile posTile = getTile(29, 28); player.getPackets().sendCameraPos(player.getSceneX(posTile.getX()), player.getSceneY(posTile.getY()), 2500); player.setFinishConversationEvent(() -> { unlockPlayer(); hideHarAken(); WorldTasks.schedule(5, this::removeScene); }); player.startConversation(new Dialogue() .addNPC(TOKHAAR_HOK_SCENE, HeadE.T_CALM_TALK, ""We have thrown many waves at you... You have handled yourself like a true Tokhaar. You have earned our respect."") .addNPC(TOKHAAR_HOK_SCENE, HeadE.T_CALM_TALK, "" Take this cape as a symbol of our -"", this::showHarAken) .addNPC(TOKHAAR_HOK_SCENE, HeadE.T_SURPRISED, ""Ah - yes, there is one final challenge..."")); }); } else if (currentWave == 34) { // SCENE 5 teleportPlayerToMiddle(); player.getPackets().setBlockMinimapState(2); player.getVars().setVar(1241, 1); WorldTasks.scheduleLooping(new Task() { int count = 0; @Override public void run() { if (count == 0) { Tile lookTo = getTile(32, 41); player.getPackets().sendCameraLook(player.getSceneX(lookTo.getX()), player.getSceneY(lookTo.getY()), 1000); Tile posTile = getTile(32, 38); player.getPackets().sendCameraPos(player.getSceneX(posTile.getX()), player.getSceneY(posTile.getY()), 1200); } else if (count == 6) { Tile lookTo = getTile(64, 30); player.getPackets().sendCameraLook(player.getSceneX(lookTo.getX()), player.getSceneY(lookTo.getY()), 3000); Tile posTile = getTile(42, 36); player.getPackets().sendCameraPos(player.getSceneX(posTile.getX()), player.getSceneY(posTile.getY()), 3000); player.tele(getTile(33, 39)); player.setNextFaceTile(getTile(32, 39)); } else if (count == 12) { stop(); tokHaarHok = new NPC(TOKHAAR_HOK_SCENE, getTile(28, 38), true); tokHaarHok.setFaceAngle(Utils.getAngleTo(1, 0)); Tile lookTo = getTile(30, 38); player.getPackets().sendCameraLook(player.getSceneX(lookTo.getX()), player.getSceneY(lookTo.getY()), 2500); Tile posTile = getTile(30, 30); player.getPackets().sendCameraPos(player.getSceneX(posTile.getX()), player.getSceneY(posTile.getY()), 3000); player.setFinishConversationEvent(() -> removeScene()); player.startConversation(new Dialogue() .addNPC(TOKHAAR_HOK_SCENE, HeadE.T_LAUGH, ""Amazing! We haven't had such fun in such a long time. But now, the real challenge begins..."") .addPlayer(HeadE.CONFUSED, ""The real challenge?"") .addNPC(TOKHAAR_HOK_SCENE, HeadE.T_CALM_TALK, ""Many creatures have entered the kiln over the ages. We remember their shapes."")); } count++; } }, 1, 0); } else if (currentWave == 31) { // SCENE 4 player.tele(getTile(21, 21)); player.setNextFaceTile(getTile(20, 20)); player.getPackets().setBlockMinimapState(2); player.getVars().setVar(1241, 1); WorldTasks.schedule(1, () -> { Tile lookTo = getTile(20, 17); player.getPackets().sendCameraLook(player.getSceneX(lookTo.getX()), player.getSceneY(lookTo.getY()), 2500); Tile posTile = getTile(25, 26); player.getPackets().sendCameraPos(player.getSceneX(posTile.getX()), player.getSceneY(posTile.getY()), 3000); player.setFinishConversationEvent(this::removeScene); player.startConversation(new Dialogue() .addNPC(TOKHAAR_HOK_SCENE, HeadE.T_CALM_TALK, ""Hurry, "" + player.getDisplayName() + ""... Kill my brothers before the lava consumes you."")); }); } else if (currentWave == 21) { // SCENE 3 tokHaarHok = new NPC(TOKHAAR_HOK_SCENE, getTile(30, 43), true); tokHaarHok.setFaceAngle(Utils.getAngleTo(0, -1)); teleportPlayerToMiddle(); player.getPackets().setBlockMinimapState(2); player.getVars().setVar(1241, 1); WorldTasks.schedule(1, () -> { Tile lookTo = getTile(31, 43); player.getPackets().sendCameraLook(player.getSceneX(lookTo.getX()), player.getSceneY(lookTo.getY()), 2500); Tile posTile = getTile(31, 34); player.getPackets().sendCameraPos(player.getSceneX(posTile.getX()), player.getSceneY(posTile.getY()), 4000); player.setFinishConversationEvent(this::removeScene); player.startConversation(new Dialogue() .addNPC(TOKHAAR_HOK_SCENE, HeadE.T_CALM_TALK, ""You must be carved from a rock impervious to magic... You are quite the worthy foe."") .addNPC(TOKHAAR_HOK_SCENE, HeadE.T_CALM_TALK, ""Ah, the platform is crumbling. Be quick little one - our Ket are coming."")); }); } else if (currentWave == 11) { // SCENE 2 tokHaarHok = new NPC(TOKHAAR_HOK_SCENE, getTile(45, 45), true); tokHaarHok.setFaceAngle(Utils.getAngleTo(-1, -1)); teleportPlayerToMiddle(); player.getPackets().setBlockMinimapState(2); player.getVars().setVar(1241, 1); WorldTasks.schedule(1, () -> { Tile lookTo = getTile(45, 45); player.getPackets().sendCameraLook(player.getSceneX(lookTo.getX()), player.getSceneY(lookTo.getY()), 1000); Tile posTile = getTile(38, 37); player.getPackets().sendCameraPos(player.getSceneX(posTile.getX()), player.getSceneY(posTile.getY()), 3000); player.setFinishConversationEvent(this::removeScene); player.startConversation(new Dialogue() .addNPC(TOKHAAR_HOK_SCENE, HeadE.T_CALM_TALK, ""Well fought, "" + player.getDisplayName() + "". You are ferocious, but you must fight faster... The lava is rising."") .addNext(() -> { player.getInterfaceManager().closeChatBoxInterface(); player.getPackets().sendCameraLook(player.getSceneX(getTile(37, 50).getX()), player.getSceneY(getTile(37, 50).getY()), 1000); player.getPackets().sendCameraPos(player.getSceneX(getTile(37, 45).getX()), player.getSceneY(getTile(37, 45).getY()), 3000); WorldTasks.schedule(5, () -> player.startConversation(new Dialogue() .addNPC(TOKHAAR_HOK_SCENE, HeadE.T_CALM_TALK, ""Our Mej wish to test you...""))); })); }); } else if (currentWave == 1) { // SCENE 1 player.getInventory().removeItems(new Item(23653, Integer.MAX_VALUE), new Item(23654, Integer.MAX_VALUE), new Item(23655, Integer.MAX_VALUE), new Item(23656, Integer.MAX_VALUE), new Item(23657, Integer.MAX_VALUE), new Item(23658, Integer.MAX_VALUE)); tokHaarHok = new NPC(TOKHAAR_HOK_SCENE, getTile(30, 36), true); tokHaarHok.setFaceAngle(Utils.getAngleTo(0, 1)); player.tele(getTile(31, 39)); player.getPackets().setBlockMinimapState(2); player.getVars().setVar(1241, 1); player.setNextFaceTile(tokHaarHok.getMiddleTile()); WorldTasks.schedule(1, () -> { Tile lookTo = getTile(31, 40); player.getPackets().sendCameraLook(player.getSceneX(lookTo.getX()), player.getSceneY(lookTo.getY()), 1000); Tile posTile = getTile(31, 50); player.getPackets().sendCameraPos(player.getSceneX(posTile.getX()), player.getSceneY(posTile.getY()), 3000); player.setFinishConversationEvent(this::removeScene); player.startConversation(new Dialogue() .addNPC(TOKHAAR_HOK_SCENE, HeadE.T_CALM_TALK, ""So...you accept our challenge. Let our sport be glorious. Xil - attack!"")); stage = Stages.RUNNING; player.unlock(); }); } else if (login) { // LOGIN during FightKilnController.this.login = login; WorldTasks.schedule(new Task() { @Override public void run() { stage = Stages.RUNNING; teleportPlayerToMiddle(); player.unlock(); } }, 1); } }; // finds empty map bounds if (region == null) { region = Instance.of(OUTSIDE, 8, 8); region.copyMapAllPlanes(getMap()[0], getMap()[1]).thenAccept(e -> { event.run(); player.setForceNextMapLoadRefresh(true); player.loadMapRegions(); }); } else if (!login && (currentWave == 11 || currentWave == 21 || currentWave == 31 || currentWave == 34)) region.copyMapAllPlanes(getMap()[0], getMap()[1]).thenAccept(e -> { player.setForceNextMapLoadRefresh(true); player.loadMapRegions(); event.run(); }); else player.fadeScreen(event); } public Tile getMaxTile() { if (getCurrentWave() < 11) return getTile(49, 49); if (getCurrentWave() < 21) return getTile(47, 47); if (getCurrentWave() < 31) return getTile(45, 45); if (getCurrentWave() < 34) return getTile(43, 43); return getTile(41, 41); } public Tile getMinTile() { if (getCurrentWave() < 11) return getTile(14, 14); if (getCurrentWave() < 21) return getTile(16, 16); if (getCurrentWave() < 31) return getTile(18, 18); if (getCurrentWave() < 34) return getTile(20, 20); return getTile(22, 22); } /* * 20, 20 min X, min Y 42 42 maxX, maxY */ /* * 0 - north 1 - south 2 - east 3 - west */ public Tile getTentacleTile() { int corner = Utils.random(4); int position = Utils.random(5); while (corner != 0 && position == 2) position = Utils.random(5); return switch (corner) { case 0 -> // north getTile(21 + (position * 5), 42); case 1 -> // south getTile(21 + (position * 5), 20); case 2 -> // east getTile(42, 21 + (position * 5)); // west default -> getTile(20, 21 + (position * 5)); }; } static final String[] COMPASS = new String[] { ""SE"", ""SW"", ""NW"", ""NE"" }; private Tile getTileOfSide(String side, int size) { switch(side.toUpperCase()) { case ""SE"": // South East Tile maxTile = getMaxTile(); Tile minTile = getMinTile(); return Tile.of(maxTile.getX() - 1 - size, minTile.getY() + 2, 1); case ""SW"": // South West return getMinTile().transform(2, 2, 0); case ""NW"": // North West maxTile = getMaxTile(); minTile = getMinTile(); return Tile.of(minTile.getX() + 2, maxTile.getY() - 1 - size, 1); case ""NE"": // North East default: return getMaxTile().transform(-1 - size, -1 - size, 0); } } public Tile getSpawnTile(int npcId, int waveIndex) { return getTileOfSide(COMPASS[waveIndex % 4], NPCDefinitions.getDefs(npcId).size); } @Override public void moved() { if (stage != Stages.RUNNING || !login) return; login = false; setWaveEvent(); } public void startWave() { if (stage != Stages.RUNNING) return; int currentWave = getCurrentWave(); player.getInterfaceManager().removeOverlay();//Spawns every wave now player.getInterfaceManager().sendOverlay(316); player.getVars().setVar(639, currentWave); if(currentWave == 37) WorldTasks.delay(1, ()->{ player.getPackets().setIFText(316, 5, ""Har-Aken"");//Says Har-Aken now }); if (currentWave > WAVES.length) { if (currentWave == 37) aliveNPCSCount = 1; return; } if (currentWave == 0) { exitCave(1); return; } aliveNPCSCount = WAVES[currentWave - 1].length; for (int i = 0; i < WAVES[currentWave - 1].length; i += 4) { final int next = i; WorldTasks.schedule(new Task() { @Override public void run() { try { if (stage != Stages.RUNNING) return; spawn(next); } catch (Throwable e) { Logger.handle(FightKilnController.class, ""startWave"", e); } } }, (next / 4) * Ticks.fromSeconds(4)); } } public void spawn(int index) { int currentWave = getCurrentWave(); for (int i = index; i < (index + 4 > WAVES[currentWave - 1].length ? WAVES[currentWave - 1].length : index + 4); i++) { int npcId = WAVES[currentWave - 1][i]; if (npcId == 15213) new TokHaarKetDill(npcId, getSpawnTile(npcId, i), this); else new FightKilnNPC(npcId, getSpawnTile(npcId, i), this); } } private int[] getLavaCrystal() { return switch (getCurrentWave()) { case 1, 13, 25 -> new int[]{23653}; case 3, 15, 27 -> new int[]{23654}; case 5, 18, 29 -> new int[]{23655}; case 7, 19, 31 -> new int[]{23656}; case 9, 21 -> new int[]{23657}; case 11, 23 -> new int[]{23658}; case 35 -> new int[]{23657, 23658}; default -> null; }; } public void checkCrystal() { if (stage != Stages.RUNNING) return; if (aliveNPCSCount == 1) { int[] crystals = getLavaCrystal(); if (crystals != null) for (int crystal : crystals) World.addGroundItem(new Item(crystal), getTile(32, 32)); } } public void removeNPC() { if (stage != Stages.RUNNING) return; aliveNPCSCount--; if (aliveNPCSCount == 0) nextWave(); } public void win() { if (stage != Stages.RUNNING) return; exitCave(4); } public void unlockPlayer() { stage = Stages.RUNNING; player.unlock(); // unlocks player } public void removeScene() { FadingScreen.fade(player, () -> { if (stage != Stages.RUNNING) unlockPlayer(); removeTokHaarTok(); player.getPackets().sendResetCamera(); player.getPackets().setBlockMinimapState(0); player.getVars().setVar(1241, 3); if (getCurrentWave() == 38) { int reward = player.getTempAttribs().getI(""FightKilnReward""); if (reward != -1) { win(); for (Player p : World.getPlayers()) { if (p == null || p.hasFinished()) continue; p.sendMessage("""" + player.getDisplayName() + "" has just completed the fight kiln!"", true); } } } else { teleportPlayerToMiddle(); setWaveEvent(); } }); } public void teleportPlayerToMiddle() { player.tele(getTile(31, 32)); } public void removeTokHaarTok() { if (tokHaarHok != null) tokHaarHok.finish(); } public void nextWave() { if (stage != Stages.RUNNING) return; playMusic(); int nextWave = getCurrentWave() + 1; setCurrentWave(nextWave); if (logoutAtEnd) { player.forceLogout(); return; } if (nextWave == 1 || nextWave == 11 || nextWave == 21 || nextWave == 31 || nextWave == 34 || nextWave == 37 || nextWave == 38) { harAken = null; player.stopAll(); loadCave(false); return; } setWaveEvent(); } public void setWaveEvent() { WorldTasks.schedule(new Task() { @Override public void run() { try { if (stage != Stages.RUNNING) return; startWave(); } catch (Throwable e) { Logger.handle(FightKilnController.class, ""setWaveEvent"", e); } } }, Ticks.fromSeconds(6)); } @Override public boolean sendDeath() { player.lock(7); player.stopAll(); WorldTasks.scheduleLooping(new Task() { int loop; @Override public void run() { if (loop == 0) player.setNextAnimation(new Animation(836)); else if (loop == 1) player.sendMessage(""You have been defeated!""); else if (loop == 3) { player.reset(); exitCave(1); player.setNextAnimation(new Animation(-1)); } else if (loop == 4) { player.jingle(90); stop(); } loop++; } }, 0, 1); return false; } @Override public void onTeleported(TeleType type) { exitCave(2); } /* * logout or not. if didnt logout means lost, 0 logout, 1, normal, 2 tele */ public void exitCave(int type) { stage = Stages.DESTROYING; Tile outside = Tile.of(OUTSIDE, 2); // radomizes alil if (type == 0) { player.setTile(outside); if (getCurrentWave() == 0) // leaves if didnt start removeController(); } else if (type == 2) { player.setTile(outside); removeController(); } else { player.setForceMultiArea(false); player.getInterfaceManager().removeOverlay(); if (type == 1 || type == 4) { player.tele(outside); if (type == 4) { player.incrementCount(""Fight Kiln clears""); player.sendMessage(""You were victorious!!""); int reward = player.getTempAttribs().getI(""FightKilnReward""); int itemId = reward != -1 && reward == 1 ? 6571 : 23659; if (!player.getInventory().addItem(itemId, 1)) World.addGroundItem(new Item(itemId, 1), Tile.of(player.getTile()), player, true, 180); player.reset(); } } player.getInventory().removeItems(new Item(23653, Integer.MAX_VALUE), new Item(23654, Integer.MAX_VALUE), new Item(23655, Integer.MAX_VALUE), new Item(23656, Integer.MAX_VALUE), new Item(23657, Integer.MAX_VALUE), new Item(23658, Integer.MAX_VALUE)); removeCrystalEffects(); removeController(); } region.destroy(); } private void removeCrystalEffects() { player.setInvulnerable(false); player.getSkills().restoreSkills(); player.setHpBoostMultiplier(0); player.getEquipment().refreshConfigs(false); player.getTempAttribs().removeB(""FightKilnCrystal""); } /* * gets worldtile inside the map */ public Tile getTile(int mapX, int mapY) { return region.getLocalTile(mapX, mapY).transform(0, 0, 1); } /* * return false so wont remove script */ @Override public boolean logout() { /* * only can happen if dungeon is loading and system update happens */ if (stage != Stages.RUNNING) return false; exitCave(0); return false; } public int getCurrentWave() { return wave; } public void setCurrentWave(int wave) { this.wave = wave; } @Override public void forceClose() { /* * shouldnt happen */ if (stage != Stages.RUNNING) return; exitCave(2); player.setLargeSceneView(false); } public void showHarAken() { if (harAken == null) { harAken = new HarAken(15211, getTile(45, 26), this); harAken.setFaceAngle(Utils.getAngleTo(-1, -1)); } else { if (stage != Stages.RUNNING) return; switch (Utils.random(3)) { case 0: harAken.setTile(getTile(29, 17)); harAken.setFaceAngle(Utils.getAngleTo(0, 1)); break; case 1: harAken.setTile(getTile(17, 30)); harAken.setFaceAngle(Utils.getAngleTo(1, 0)); break; case 2: harAken.setTile(getTile(42, 30)); harAken.setFaceAngle(Utils.getAngleTo(-1, 0)); break; } harAken.spawn(); // TODO set worldtile } harAken.setCantInteract(false); harAken.setNextAnimation(new Animation(16232)); } public static void useCrystal(final Player player, int id) { if (!(player.getControllerManager().getController() instanceof FightKilnController) || player.getTempAttribs().getB(""FightKilnCrystal"")) return; player.getInventory().deleteItem(new Item(id, 1)); switch (id) { case 23653: // invulnerability player.sendMessage("">The power of this crystal makes you invulnerable.""); player.getTempAttribs().setB(""FightKilnCrystal"", true); player.setInvulnerable(true); WorldTasks.schedule(Ticks.fromSeconds(15), () -> { try { player.getTempAttribs().removeB(""FightKilnCrystal""); player.sendMessage(""The power of the crystal dwindles and you're vulnerable once more.""); player.setInvulnerable(false); } catch (Throwable e) { Logger.handle(FightKilnController.class, ""useCrystal"", e); } }); break; case 23654: // RESTORATION player.heal(player.getMaxHitpoints()); player.getPrayer().restorePrayer(player.getSkills().getLevelForXp(Constants.PRAYER) * 10); player.sendMessage(""The power of this crystal heals you fully.""); break; case 23655: // MAGIC boostCrystal(player, Constants.MAGIC); break; case 23656: // RANGED boostCrystal(player, Constants.RANGE); break; case 23657: // STRENGTH boostCrystal(player, Constants.STRENGTH); break; case 23658: // CONSTITUTION player.getTempAttribs().setB(""FightKilnCrystal"", true); player.setHpBoostMultiplier(0.5); player.getEquipment().refreshConfigs(false); player.heal(player.getSkills().getLevelForXp(Constants.HITPOINTS) * 5); player.sendMessage(""The power of this crystal improves your Constitution.""); WorldTasks.schedule(Ticks.fromSeconds(210), () -> { try { player.getTempAttribs().removeB(""FightKilnCrystal""); player.sendMessage(""The power of the crystal dwindles and your constitution prowess returns to normal.""); player.setHpBoostMultiplier(0); player.getEquipment().refreshConfigs(false); } catch (Throwable e) { Logger.handle(FightKilnController.class, ""useCrystal"", e); } }); break; } } private static void boostCrystal(final Player player, final int skill) { player.getTempAttribs().setB(""FightKilnCrystal"", true); if (skill == Constants.RANGE) player.sendMessage(""The power of the crystal improves your Ranged prowess, at the expense of your Defence, Strength and Magical ability.""); else if (skill == Constants.MAGIC) player.sendMessage(""The power of the crystal improves your Magic prowess, at the expense of your Defence, Strength and Ranged ability.""); else if (skill == Constants.STRENGTH) player.sendMessage(""The power of the crystal improves your Strength prowess, at the expense of your Defence, Ranged and Magical ability.""); WorldTasks.scheduleTimer(timer -> { if (timer >= Ticks.fromMinutes(3.5) || !(player.getControllerManager().getController() instanceof FightKilnController)) { player.getTempAttribs().removeB(""FightKilnCrystal""); player.sendMessage(""The power of the crystal dwindles and your "" + Constants.SKILL_NAME[skill] + "" prowess returns to normal.""); player.getSkills().set(Constants.DEFENSE, player.getSkills().getLevelForXp(Constants.DEFENSE)); player.getSkills().set(Constants.STRENGTH, player.getSkills().getLevelForXp(Constants.STRENGTH)); player.getSkills().set(Constants.RANGE, player.getSkills().getLevelForXp(Constants.RANGE)); player.getSkills().set(Constants.MAGIC, player.getSkills().getLevelForXp(Constants.MAGIC)); return false; } for (int i = 1; i < 7; i++) { if (i == skill || i == 3 || i == 5) continue; player.getSkills().set(i, player.getSkills().getLevelForXp(i) / 2); } player.getSkills().set(skill, (int) (player.getSkills().getLevelForXp(skill) * 1.5)); return true; }); } @Override public boolean processNPCClick1(NPC npc) { if (npc.getId() == 15195 && getCurrentWave() == 0) { player.startConversation(getStartDialogue()); return false; } return true; } @Override public void process() { if (harAken != null) harAken.process(); } public void hideHarAken() { if (stage != Stages.RUNNING) return; if (harAken == null) showHarAken(); harAken.resetTimer(); harAken.setCantInteract(true); harAken.setNextAnimation(new Animation(16234)); WorldTasks.schedule(new Task() { @Override public void run() { try { if (stage != Stages.RUNNING) return; harAken.finish(); } catch (Throwable e) { Logger.handle(FightKilnController.class, ""hideHarAken"", e); } } }, Ticks.fromSeconds(3)); } }" "package com.rs.game.content.minigames.fightkiln.npcs; public class FightKilnNPC extends NPC { private final FightKilnController controller; public FightKilnNPC(int id, Tile tile, FightKilnController controller) { super(id, tile, true); setForceMultiArea(true); setNoDistanceCheck(true); setIgnoreDocile(true); setForceAgressive(true); this.controller = controller; } private int getDeathGfx() { return switch (getId()) { case 15201 -> 2926; case 15202 -> 2927; case 15203 -> 2957; case 15213, 15214, 15204 -> 2928; case 15205 -> 2959; case 15206, 15207 -> 2929; case 15208, 15211, 15212 -> 2973; default -> 2926; }; } @Override public void sendDeath(Entity source) { final NPCCombatDefinitions defs = getCombatDefinitions(); resetWalkSteps(); getCombat().removeTarget(); setNextAnimation(null); controller.checkCrystal(); setNextSpotAnim(new SpotAnim(getDeathGfx())); WorldTasks.scheduleTimer(loop -> { if (loop == 0) setNextAnimation(new Animation(defs.getDeathEmote())); else if (loop >= defs.getDeathDelay()) { reset(); finish(); controller.removeNPC(); return false; } return true; }); } @Override public List getPossibleTargets() { return queryNearbyPlayersByTileRangeAsEntityList(64, player -> !player.isDead()); } @Override public double getMagePrayerMultiplier() { return 0.1; } @Override public double getRangePrayerMultiplier() { return 0.1; } @Override public double getMeleePrayerMultiplier() { return 0.1; } }" "package com.rs.game.content.minigames.fightkiln.npcs; public class HarAken extends NPC { private static final int TENTACLE_CAP = 25; private long time; private long spawnTentacleTime; private boolean underLava; private final List tentacles; private final FightKilnController controller; public void resetTimer() { underLava = !underLava; if (time == 0) spawnTentacleTime = System.currentTimeMillis() + 9000; if(tentacles.size() == TENTACLE_CAP) spawnTentacleTime = System.currentTimeMillis() + 25000; time = System.currentTimeMillis() + (underLava ? 43000 : 31000); } @Override public boolean ignoreWallsWhenMeleeing() { return true; } @Override public boolean canMove(Direction dir) { return false; } public HarAken(int id, Tile tile, FightKilnController controller) { super(id, tile, true); setForceMultiArea(true); this.controller = controller; tentacles = new ArrayList<>(); setCantFollowUnderCombat(true); } @Override public void sendDeath(Entity source) { setNextSpotAnim(new SpotAnim(2924 + getSize())); if (time != 0) { removeTentacles(); controller.removeNPC(); time = 0; } super.sendDeath(source); } @Override public void processNPC() { if (isDead()) return; cancelFaceEntityNoCheck(); } public void process() { if (isDead()) return; if (time != 0) { if (time < System.currentTimeMillis()) if (underLava) { controller.showHarAken(); resetTimer(); } else controller.hideHarAken(); if (tentacles.size() < TENTACLE_CAP && spawnTentacleTime < System.currentTimeMillis()) spawnTentacle(); } } public void spawnTentacle() { tentacles.add(new HarAkenTentacle(Utils.random(2) == 0 ? 15209 : 15210, controller.getTentacleTile(), this)); spawnTentacleTime = System.currentTimeMillis() + Utils.random(18000, 23000); } public void removeTentacles() { for (HarAkenTentacle t : tentacles) t.finish(); tentacles.clear(); } public void removeTentacle(HarAkenTentacle tentacle) { tentacles.remove(tentacle); } }" "package com.rs.game.content.minigames.fightkiln.npcs; public class HarAkenTentacle extends NPC { private final HarAken aken; public HarAkenTentacle(int id, Tile tile, HarAken aken) { super(id, tile, true); setForceMultiArea(true); setCantFollowUnderCombat(true); setForceAgressive(true); setNextAnimation(new Animation(id == 15209 ? 16238 : 16241)); freeze(10000000); this.aken = aken; } @Override public void sendDeath(Entity source) { aken.removeTentacle(this); super.sendDeath(source); } @Override public boolean ignoreWallsWhenMeleeing() { return true; } @Override public List getPossibleTargets() { return queryNearbyPlayersByTileRangeAsEntityList(30, player -> !player.isDead()); } @Override public double getMagePrayerMultiplier() { return 0.1; } @Override public double getRangePrayerMultiplier() { return 0.1; } @Override public double getMeleePrayerMultiplier() { return 0.1; } }" "package com.rs.game.content.minigames.fightkiln.npcs; public class HarAkenTentacleCombat extends CombatScript { @Override public Object[] getKeys() { return new Object[] { 15209, 15210 }; } @Override public int attack(NPC npc, Entity target) { final NPCCombatDefinitions defs = npc.getCombatDefinitions(); int distanceX = target.getX() - npc.getX(); int distanceY = target.getY() - npc.getY(); int size = npc.getSize(); int attackStyle = Utils.random(2); if (attackStyle == 0 && (distanceX > size || distanceX < -1 || distanceY > size || distanceY < -1)) attackStyle = 1; switch (attackStyle) { case 0: npc.setNextAnimation(new Animation(defs.getAttackEmote())); delayHit(npc, 0, target, getMeleeHit(npc, getMaxHit(npc, defs.getMaxHit() - 36, AttackStyle.MELEE, target))); break; case 1: npc.setNextAnimation(new Animation(npc.getId() == 15209 ? 16253 : 16242)); WorldProjectile p = World.sendProjectile(npc, target, npc.getId() == 15209 ? 3004 : 2922, 140, 35, 80, 1.0, 16, 0); if (npc.getId() == 15209) delayHit(npc, p.getTaskDelay(), target, getRangeHit(npc, getMaxHit(npc, defs.getMaxHit(), AttackStyle.RANGE, target))); else delayHit(npc, p.getTaskDelay(), target, getMagicHit(npc, getMaxHit(npc, defs.getMaxHit(), AttackStyle.MAGE, target))); break; } return npc.getAttackSpeed(); } }" "package com.rs.game.content.minigames.fightkiln.npcs; public class TokHaarKetDill extends FightKilnNPC { private int receivedHits; public TokHaarKetDill(int id, Tile tile, FightKilnController controller) { super(id, tile, controller); } @Override public void handlePreHit(final Hit hit) { if (hit.getLook() != HitLook.MELEE_DAMAGE && hit.getLook() != HitLook.RANGE_DAMAGE && hit.getLook() != HitLook.MAGIC_DAMAGE) return; if (receivedHits != -1) { Entity source = hit.getSource(); if (source == null || !(source instanceof Player playerSource)) return; hit.setDamage(0); int weaponId = playerSource.getEquipment().getWeaponId(); if (weaponId == 1275 || weaponId == 13661 || weaponId == 15259) { receivedHits++; if ((weaponId == 1275 && receivedHits >= 5) || ((weaponId == 13661 || weaponId == 15259) && receivedHits >= 3)) { receivedHits = -1; transformIntoNPC(getId() + 1); playerSource.sendMessage(""Your pickaxe breaks the TokHaar-Ket-Dill's thick armour!""); } else playerSource.sendMessage(""Your pickaxe slowy cracks its way through the TokHaar-Ket-Dill's armour.""); } } } }" "package com.rs.game.content.minigames.fightkiln.npcs; public class TokHaarKetDillCombat extends CombatScript { @Override public Object[] getKeys() { return new Object[] { ""TokHaar-Ket-Dill"" }; } @Override public int attack(NPC npc, Entity target) { NPCCombatDefinitions defs = npc.getCombatDefinitions(); if (Utils.random(6) == 0) { delayHit(npc, 0, target, getRegularHit(npc, Utils.random(defs.getMaxHit() + 1))); target.setNextSpotAnim(new SpotAnim(2999)); if (target instanceof Player player) player.sendMessage(""The TokHaar-Ket-Dill slams it's tail to the ground.""); } else delayHit(npc, 0, target, getMeleeHit(npc, getMaxHit(npc, defs.getMaxHit(), defs.getAttackStyle(), target))); npc.setNextAnimation(new Animation(defs.getAttackEmote())); return npc.getAttackSpeed(); } }" "package com.rs.game.content.minigames.fightkiln.npcs; public class TokHaarMej extends CombatScript { @Override public Object[] getKeys() { return new Object[] { 15203 }; } @Override public int attack(NPC npc, Entity target) { final NPCCombatDefinitions defs = npc.getCombatDefinitions(); int distanceX = target.getX() - npc.getX(); int distanceY = target.getY() - npc.getY(); int size = npc.getSize(); int hit = 0; int attackStyle = Utils.random(2); if (attackStyle == 0 && (distanceX > size || distanceX < -1 || distanceY > size || distanceY < -1)) attackStyle = 1; switch (attackStyle) { case 0: hit = getMaxHit(npc, defs.getMaxHit() - 36, AttackStyle.MELEE, target); npc.setNextAnimation(new Animation(defs.getAttackEmote())); delayHit(npc, 0, target, getMeleeHit(npc, hit)); break; case 1: hit = getMaxHit(npc, defs.getMaxHit(), AttackStyle.MAGE, target); npc.setNextAnimation(new Animation(16122)); World.sendProjectile(npc, target, 2991, 34, 16, 30, 35, 16, 0); delayHit(npc, 2, target, getMagicHit(npc, hit)); break; } return npc.getAttackSpeed(); } }" "package com.rs.game.content.minigames.fightkiln.npcs; public class TokXilCombat extends CombatScript { @Override public Object[] getKeys() { return new Object[] { ""Tok-Xil"", 15205, 3592 }; } @Override public int attack(NPC npc, Entity target) { final NPCCombatDefinitions defs = npc.getCombatDefinitions(); int distanceX = target.getX() - npc.getX(); int distanceY = target.getY() - npc.getY(); int size = npc.getSize(); int hit = 0; int attackStyle = Utils.random(2); if (attackStyle == 0 && (distanceX > size || distanceX < -1 || distanceY > size || distanceY < -1)) attackStyle = 1; switch (attackStyle) { case 0: hit = getMaxHit(npc, defs.getMaxHit() - 36, AttackStyle.MELEE, target); npc.setNextAnimation(new Animation(defs.getAttackEmote())); delayHit(npc, 0, target, getMeleeHit(npc, hit)); break; case 1: hit = getMaxHit(npc, defs.getMaxHit(), AttackStyle.RANGE, target); npc.setNextAnimation(new Animation(16132)); World.sendProjectile(npc, target, 2993, 34, 16, 30, 2, 16, 0); delayHit(npc, 2, target, getRangeHit(npc, hit)); break; } return npc.getAttackSpeed(); } }" "package com.rs.game.content.minigames.fightpits; @PluginEventHandler public final class FightPits { private static final int THHAAR_MEJ_KAH = 2618; private static final List lobby = new ArrayList<>(); public static final List arena = new ArrayList<>(); public static final Object lock = new Object(); private static GameTask gameTask; private static boolean startedGame; public static String currentChampion; private static final Tile[] GAME_TELEPORTS = { Tile.of(4577, 5086, 0), Tile.of(4571, 5083, 0), Tile.of(4564, 5086, 0), Tile.of(4564, 5097, 0), Tile.of(4571, 5101, 0), Tile.of(4578, 5097, 0) }; public static ButtonClickHandler handleFightPitsViewingOrbButtons = new ButtonClickHandler(374, e -> { if (e.getComponentId() >= 5 && e.getComponentId() <= 9) e.getPlayer().tele(Tile.of(FightPitsViewingOrb.ORB_TELEPORTS[e.getComponentId() - 5])); else if (e.getComponentId() == 15) e.getPlayer().stopAll(); }); private static class GameTask extends Task { private int minutes; private List spawns; @Override public void run() { try { synchronized (lock) { if (!startedGame) { startedGame = true; passPlayersToArena(); } else { if (minutes == 0) for (Player player : arena) player.npcDialogue(THHAAR_MEJ_KAH, HeadE.T_CALM_TALK, ""FIGHT!""); else if (minutes == 5) { // spawn tz-kih // spawns spawns = new ArrayList<>(); for (int i = 0; i < 10; i++) spawns.add(new FightPitsNPC(2734, Tile.of(GAME_TELEPORTS[Utils.random(GAME_TELEPORTS.length)], 3))); } else if (minutes == 6) for (int i = 0; i < 10; i++) spawns.add(new TzKekPits(2736, Tile.of(GAME_TELEPORTS[Utils.random(GAME_TELEPORTS.length)], 3))); else if (minutes == 7) for (int i = 0; i < 10; i++) spawns.add(new FightPitsNPC(2739, Tile.of(GAME_TELEPORTS[Utils.random(GAME_TELEPORTS.length)], 3))); else if (minutes == 10) // alot hits appears on players WorldTasks.scheduleLooping(new Task() { @Override public void run() { if (!startedGame) { stop(); return; } for (Player player : arena) player.applyHit(new Hit(player, 150, HitLook.TRUE_DAMAGE)); } }, 0, 0); minutes++; } } } catch (Throwable e) { Logger.handle(GameTask.class, ""run"", e); } } public void removeNPCs() { if (spawns == null) return; for (NPC n : spawns) n.finish(); } } /* * because of the lvl 22s */ public static void addNPC(NPC n) { synchronized (lock) { if (gameTask == null || gameTask.spawns == null) return; gameTask.spawns.add(n); } } public static boolean canFight() { synchronized (lock) { if (gameTask == null) return false; return gameTask.minutes > 0; } } public static void passPlayersToArena() { for (Iterator it = lobby.iterator(); it.hasNext();) { Player player = it.next(); player.stopAll(); player.getControllerManager().removeControllerWithoutCheck(); enterArena(player); it.remove(); } refreshFoes(); } public static void refreshFoes() { int foes = arena.size() - 1; for (Player player : arena) player.getVars().setVar(560, foes); } public static void enterArena(Player player) { player.lock(5); player.getControllerManager().startController(new FightPitsController()); player.tele(Tile.of(GAME_TELEPORTS[Utils.random(GAME_TELEPORTS.length)], 3)); player.npcDialogue(THHAAR_MEJ_KAH, HeadE.T_CALM_TALK, ""Please wait for the signal before fight.""); player.setCanPvp(true); player.setCantTrade(true); arena.add(player); } /* * 0 - logout, 1 - walk, 2 - dead, 3 - teled */ public static void leaveArena(Player player, int type) { synchronized (lock) { arena.remove(player); player.reset(); player.getControllerManager().removeControllerWithoutCheck(); if (type != 3) player.getControllerManager().startController(new FightPitsLobbyController()); if (type == 0) player.setLocation(4592, 5073, 0); else { if (type != 3) lobby.add(player); player.setCanPvp(false); player.setCantTrade(false); player.getInterfaceManager().removeOverlay(); if (player.hasSkull() && player.getSkullId() == 1) {// if has // champion // skull player.removeSkull(); player.npcDialogue(THHAAR_MEJ_KAH, HeadE.T_CALM_TALK, ""Well done in the pit, here take TokKul as reward.""); int tokkul = (lobby.size() + arena.size()) * 100; if (!player.getInventory().addItem(6529, tokkul) && type == 1) World.addGroundItem(new Item(6529, tokkul), Tile.of(4585, 5076, 0), player, true, 180); } if (type == 1) { player.lock(5); player.addWalkSteps(4585, 5076, 5, false); } else if (type == 2) player.tele(Tile.of(Tile.of(4592, 5073, 0), 2)); } refreshFoes(); checkPlayersAmmount(); if (startedGame && arena.size() <= 1) endGame(); } } public static void enterLobby(Player player, boolean login) { synchronized (lock) { if (!login) { player.lock(5); player.addWalkSteps(4595, 5066, 5, false); player.getControllerManager().startController(new FightPitsLobbyController()); } lobby.add(player); checkPlayersAmmount(); } } /* * 0 - logout, 1 normal, 2 death/tele */ public static void leaveLobby(Player player, int type) { synchronized (lock) { if (type != 0) { if (type == 1) { player.lock(5); player.addWalkSteps(4597, 5064, 5, false); } player.getControllerManager().removeControllerWithoutCheck(); } lobby.remove(player); checkPlayersAmmount(); } } public static void checkPlayersAmmount() { if (gameTask == null) { if (lobby.size() + arena.size() >= 2) // 2players in startGame(false); } else if (lobby.size() + arena.size() < 2) cancelGame(); } public static void startGame(boolean end) { if (end) { gameTask.stop(); gameTask.removeNPCs(); setChampion(); startedGame = false; } gameTask = new GameTask(); WorldTasks.scheduleLooping(gameTask, end ? Ticks.fromSeconds(60) : Ticks.fromSeconds(10), Ticks.fromSeconds(60)); } public static void cancelGame() { gameTask.stop(); gameTask.removeNPCs(); gameTask = null; if (startedGame) setChampion(); startedGame = false; } public static void setChampion() { if (arena.isEmpty()) return; Player champion = arena.getFirst(); currentChampion = champion.getDisplayName(); champion.getPackets().setIFText(373, 10, ""Current Champion: JaLYt-Ket-"" + currentChampion); champion.setFightPitsSkull(); champion.incrementCount(""Fight Pits victories""); champion.npcDialogue(THHAAR_MEJ_KAH, HeadE.T_CALM_TALK, ""Well done, you were the last person in the pit and won that fight! The next round will start soon, wait for my signal before fighting.""); } public static void endGame() { startGame(true); } }" "package com.rs.game.content.minigames.fightpits; public class FightPitsController extends Controller { @Override public void start() { sendInterfaces(); } @Override public boolean processObjectClick1(GameObject object) { if (object.getId() == 68222) { FightPits.leaveArena(player, 1); return false; } return true; } // fuck it dont dare touching here again or dragonkk(me) kills u irl :D btw // nice code it keeps nulling, fixed @Override public boolean logout() { FightPits.leaveArena(player, 0); return false; } @Override public boolean processTeleport(Teleport tele) { player.sendMessage(""You can't teleport out of the arena!""); return false; } @Override public void onTeleported(TeleType type) { FightPits.leaveArena(player, 3); // teled out somehow, impossible usualy } @Override public boolean login() { // shouldnt happen removeController(); FightPits.leaveArena(player, 2); return false; } @Override public void forceClose() { FightPits.leaveArena(player, 3); } @Override public boolean canAttack(Entity target) { if (target instanceof Player) { if (canHit(target)) return true; player.sendMessage(""You're not allowed to attack yet!""); return false; } return true; } @Override public boolean canHit(Entity target) { return FightPits.canFight(); } @Override public boolean sendDeath() { player.lock(7); player.stopAll(); WorldTasks.scheduleLooping(new Task() { int loop; @Override public void run() { if (loop == 0) player.setNextAnimation(new Animation(836)); else if (loop == 1) player.sendMessage(""You have been defeated!""); else if (loop == 3) { player.reset(); FightPits.leaveArena(player, 2); player.setNextAnimation(new Animation(-1)); } else if (loop == 4) { player.jingle(90); stop(); } loop++; } }, 0, 1); return false; } @Override public void sendInterfaces() { player.getInterfaceManager().sendOverlay(373); if (FightPits.currentChampion != null) player.getPackets().setIFText(373, 10, ""Current Champion: JaLYt-Ket-"" + FightPits.currentChampion); } }" "package com.rs.game.content.minigames.fightpits; public class FightPitsLobbyController extends Controller { @Override public void start() { } @Override public boolean login() { FightPits.enterLobby(player, true); return false; } @Override public void onTeleported(TeleType type) { FightPits.leaveLobby(player, 2); } @Override public boolean processObjectClick1(GameObject object) { if (object.getId() == 68223) { FightPits.leaveLobby(player, 1); return false; } if (object.getId() == 68222) { player.sendMessage(""The heat prevents you passing through.""); return false; } if (object.getId() == 68220) { player.getActionManager().setAction(new FightPitsViewingOrb()); return false; } return true; } @Override public boolean sendDeath() { FightPits.leaveLobby(player, 2); return true; } @Override public boolean logout() { FightPits.leaveLobby(player, 0); return false; } @Override public void forceClose() { FightPits.leaveLobby(player, 2); } }" "package com.rs.game.content.minigames.fightpits; public class FightPitsNPC extends NPC { public FightPitsNPC(int id, Tile tile) { super(id, tile, true); setForceMultiArea(true); setNoDistanceCheck(true); } @Override public void sendDeath(Entity source) { setNextSpotAnim(new SpotAnim(2924 + getSize())); super.sendDeath(source); } @Override public List getPossibleTargets() { ArrayList possibleTarget = new ArrayList<>(); possibleTarget.addAll(FightPits.arena); return possibleTarget; } }" "package com.rs.game.content.minigames.fightpits; public class FightPitsViewingOrb extends PlayerAction { public static final Tile[] ORB_TELEPORTS = { Tile.of(4571, 5092, 0), Tile.of(4571, 5107, 0), Tile.of(4590, 5092, 0), Tile.of(4571, 5077, 0), Tile.of(4557, 5092, 0) }; private Tile tile; @Override public boolean start(Player player) { if (!process(player)) return false; tile = Tile.of(player.getTile()); player.getAppearance().switchHidden(); player.getPackets().setBlockMinimapState(5); player.tele(ORB_TELEPORTS[0]); player.getInterfaceManager().sendInventoryInterface(374); return true; } @Override public boolean process(Player player) { if (player.getPoison().isPoisoned()) { player.sendMessage(""You can't use orb while you're poisoned.""); return false; } if (player.getFamiliar() != null) { player.sendMessage(""You can't use orb with a familiar.""); return false; } return true; } @Override public int processWithDelay(Player player) { return 0; } @Override public void stop(final Player player) { player.lock(2); player.getInterfaceManager().removeInventoryInterface(); player.getAppearance().switchHidden(); player.getPackets().setBlockMinimapState(0); player.tele(tile); } }" "package com.rs.game.content.minigames.fightpits; public class TzKekPits extends FightPitsNPC { public TzKekPits(int id, Tile tile) { super(id, tile); } @Override public void sendDeath(Entity source) { final NPCCombatDefinitions defs = getCombatDefinitions(); resetWalkSteps(); getCombat().removeTarget(); setNextAnimation(null); Tile tile = Tile.of(getTile()); WorldTasks.scheduleTimer(loop -> { if (loop == 0) { setNextAnimation(new Animation(defs.getDeathEmote())); setNextSpotAnim(new SpotAnim(2924 + getSize())); } else if (loop >= defs.getDeathDelay()) { reset(); FightPits.addNPC(new FightPitsNPC(2738, tile)); Tile finTile = tile; if (World.floorAndWallsFree(getPlane(), tile.getX() + 1, tile.getY(), 1)) finTile = tile.transform(1, 0, 0); else if (World.floorAndWallsFree(getPlane(), tile.getX() - 1, tile.getY(), 1)) finTile = tile.transform(-1, 0, 0); else if (World.floorAndWallsFree(getPlane(), tile.getX(), tile.getY() - 1, 1)) finTile = tile.transform(0, -1, 0); else if (World.floorAndWallsFree(getPlane(), tile.getX(), tile.getY() + 1, 1)) finTile = tile.transform(0, 1, 0); FightPits.addNPC(new FightPitsNPC(2738, finTile)); finish(); return false; } return true; }); } @Override public void removeHitpoints(Hit hit) { super.removeHitpoints(hit); if (hit.getLook() != HitLook.MELEE_DAMAGE || hit.getSource() == null) return; hit.getSource().applyHit(new Hit(this, 10, HitLook.TRUE_DAMAGE)); } }" "package com.rs.game.content.minigames.herblorehabitat; @PluginEventHandler public enum HabitatFeature { Boneyard(7, 56, 75), Abandoned_house(3, 57, 71), Thermal_vent(4, 59, 72), Tall_grass(2, 62, 70), Pond(1, 65, 68), Standing_stones(5, 70, 73), Dark_pit(6, 80, 74); private static final Map BUTTON_MAP = new HashMap<>(); static { for (HabitatFeature h : HabitatFeature.values()) BUTTON_MAP.put(h.button, h); } public static HabitatFeature forButton(int buttonId) { return BUTTON_MAP.get(buttonId); } public final int val; public final int level; public final int button; private HabitatFeature(int val, int level, int button) { this.val = val; this.level = level; this.button = button; } public static final LoginHandler updateFeature = new LoginHandler(e -> e.getPlayer().setHabitatFeature(e.getPlayer().getHabitatFeature())); public static final ObjectClickHandler handleFeatureBuild = new ObjectClickHandler(new Object[] { 56803 }, e -> e.getPlayer().getInterfaceManager().sendInterface(459)); public static final ButtonClickHandler handleFeature = new ButtonClickHandler(459, e -> { if (e.getComponentId() >= 68 && e.getComponentId() <= 75) { HabitatFeature toBuild = HabitatFeature.forButton(e.getComponentId()); if (toBuild == null) e.getPlayer().setHabitatFeature(null); else { if (e.getPlayer().getSkills().getLevel(Constants.CONSTRUCTION) < toBuild.level) { e.getPlayer().sendMessage(""You need a Construction level of "" + toBuild.level + "" to build a "" + toBuild.name() + "".""); return; } e.getPlayer().setHabitatFeature(toBuild); } World.sendSpotAnim(Tile.of(2952, 2908, 0), new SpotAnim(1605)); e.getPlayer().closeInterfaces(); } }); public static final ItemClickHandler handleWitchdoctorTele = new ItemClickHandler(new Object[] { 20046 }, new String[] { ""Teleport"" }, e -> Magic.sendTeleportSpell(e.getPlayer(), 7082, 7084, 1229, 1229, 1, 0, Tile.of(2952, 2933, 0), 4, true, TeleType.ITEM, null)); }" "package com.rs.game.content.minigames.herblorehabitat; @PluginEventHandler public class HerbloreHabitat { //inter 72 jadinko methods @ServerStartupEvent public static void initUpdateTask() { WorldTasks.scheduleLooping(25, 25, () -> { for (Player player : World.getPlayersInChunkRange(Tile.of(2959, 2915, 0).getChunkId(), 5)) { if (player.hasStarted() && !player.hasFinished()) { JadinkoType.updateGroup(player, JadinkoType.COMMON); JadinkoType.updateGroup(player, JadinkoType.IGNEOUS, JadinkoType.AQUATIC); JadinkoType.updateGroup(player, JadinkoType.CANNIBAL, JadinkoType.CARRION); JadinkoType.updateGroup(player, JadinkoType.AMPHIBIOUS, JadinkoType.DRACONIC); JadinkoType.updateGroup(player, JadinkoType.SARADOMIN, JadinkoType.GUTHIX, JadinkoType.ZAMORAK); } } }); } }" "package com.rs.game.content.minigames.herblorehabitat; public enum JadinkoType { COMMON(13108, 8415, 1, false, null, ProduceType.Torstol, null, null), SHADOW(-1, -1, -1, false, HabitatFeature.Abandoned_house, ProduceType.Red_blossom, ProduceType.Torstol, ProduceType.Torstol), IGNEOUS(13132, 8435, 2, false, HabitatFeature.Thermal_vent, ProduceType.Blue_blossom, ProduceType.Lergberry, ProduceType.Orange), CANNIBAL(13144, 8445, 2, true, HabitatFeature.Tall_grass, ProduceType.Green_blossom, ProduceType.Kalferberry, ProduceType.Torstol), AQUATIC(13132, 8435, 1, true, HabitatFeature.Pond, ProduceType.Red_blossom, ProduceType.Kalferberry, ProduceType.Apple), AMPHIBIOUS(13120, 8425, 1, false, HabitatFeature.Pond, ProduceType.Blue_blossom, ProduceType.Lergberry, ProduceType.Torstol), CARRION(13144, 8445, 1, false, HabitatFeature.Boneyard, ProduceType.Green_blossom, ProduceType.Kalferberry, ProduceType.Torstol), DISEASED(-1, -1, -1, false, HabitatFeature.Boneyard, ProduceType.Green_blossom, ProduceType.Torstol, ProduceType.Banana), CAMOUFLAGED(-1, -1, -1, true, HabitatFeature.Standing_stones, ProduceType.Green_blossom, ProduceType.Lergberry, ProduceType.Torstol), DRACONIC(13120, 8425, 2, true, HabitatFeature.Dark_pit, ProduceType.Red_blossom, ProduceType.Lergberry, ProduceType.Torstol), SARADOMIN(13156, 8452, 1, true, HabitatFeature.Pond, ProduceType.Blue_blossom, ProduceType.Lergberry, ProduceType.Torstol), GUTHIX(13156, 8452, 2, true, HabitatFeature.Tall_grass, ProduceType.Green_blossom, ProduceType.Lergberry, ProduceType.Torstol), ZAMORAK(13156, 8452, 3, true, HabitatFeature.Dark_pit, ProduceType.Red_blossom, ProduceType.Kalferberry, ProduceType.Torstol); private final int npcId; private final int varbit; private final int varbitValue; private final boolean juju; private final HabitatFeature feature; private final ProduceType blossom; private final ProduceType bush; private final ProduceType tree; private JadinkoType(int npcId, int varbit, int varbitValue, boolean juju, HabitatFeature feature, ProduceType blossom, ProduceType bush, ProduceType tree) { this.npcId = npcId; this.varbit = varbit; this.varbitValue = varbitValue; this.juju = juju; this.feature = feature; this.blossom = blossom; this.bush = bush; this.tree = tree; } public int getNpcId() { return npcId; } public int getVarbit() { return varbit; } public int getVarbitValue() { return varbitValue; } public boolean shouldSend(Player player) { if (juju && !player.hasEffect(Effect.JUJU_HUNTER)) return false; if (feature == null) { if (player.getHabitatFeature() == null) return false; } else if (player.getHabitatFeature() != feature) return false; if (!checkProduce(player, blossom, PatchLocation.Herblore_Habitat_flower) || !checkProduce(player, bush, PatchLocation.Herblore_Habitat_bush) || !checkProduce(player, tree, PatchLocation.Herblore_Habitat_fruit_tree)) return false; return true; } private static boolean checkProduce(Player player, ProduceType type, PatchLocation location) { if (type == null) return true; if (type == ProduceType.Torstol) { if (player.isGrowing(location, null)) return false; } else if (!player.isGrowing(location, type)) return false; return true; } public static void updateGroup(Player player, JadinkoType... types) { boolean rendered = false; for (JadinkoType type : types) if (type.shouldSend(player)) { player.getVars().setVarBit(type.varbit, type.varbitValue); rendered = true; } if (!rendered) player.getVars().setVarBit(types[0].varbit, 0); } }" "package com.rs.game.content.minigames.mage_training_arena; @PluginEventHandler public class MageTrainingArena { //Mage Training Arena public static ObjectClickHandler handlemagetrainladderup = new ObjectClickHandler(new Object[] { 10775 }, e -> e.getPlayer().tele(Tile.of(3357, 3307, 1))); public static ObjectClickHandler handlemagetrainladderdown = new ObjectClickHandler(new Object[] { 10776 }, e -> e.getPlayer().tele(Tile.of(3360, 3306, 0))); public static ObjectClickHandler handlemagetrainladderup2 = new ObjectClickHandler(new Object[] { 10771 }, e -> e.getPlayer().tele(Tile.of(3369, 3307, 1))); public static ObjectClickHandler handlemagetrainladderdown2 = new ObjectClickHandler(new Object[] { 10773 }, e -> e.getPlayer().tele(Tile.of(3367, 3306, 0))); public static ObjectClickHandler handlerunemechanicup = new ObjectClickHandler(new Object[] { 528 }, e -> e.getPlayer().tele(Tile.of(3358, 3305, 0))); public static ObjectClickHandler handlerunemechanicdown = new ObjectClickHandler(new Object[] { 527 }, e -> e.getPlayer().tele(Tile.of(3619, 4814, 0))); }" "package com.rs.game.content.minigames.partyroom; public class Balloon extends GameObject { private Item item; private boolean popped = false; public Balloon(int id, int rotation, int x, int y, int plane) { super(id, ObjectType.SCENERY_INTERACT, rotation, x, y, plane); } public Item getItem() { return item; } public Balloon setItem(Item item) { this.item = item; return this; } public void handlePop(final Player player) { if (!popped) { player.setNextAnimation(new Animation(794)); popped = true; player.lock(); World.removeObject(this); final GameObject poppedBalloon = new GameObject(getId() + 8, ObjectType.SCENERY_INTERACT, this.getRotation(), getX(), getY(), getPlane()); World.spawnObject(poppedBalloon); player.incrementCount(""Party balloons popped""); WorldTasks.schedule(new Task() { @Override public void run() { if (item != null) World.addGroundItem(item, Tile.of(getX(), getY(), getPlane()), player, true, 60, DropMethod.NORMAL); World.removeObject(poppedBalloon); player.unlock(); } }, 1); } } }" "package com.rs.game.content.minigames.partyroom; @PluginEventHandler public class PartyRoom { public static final int CHEST_INTERFACE = 647; public static final int INVENTORY_INTERFACE = 648; public static boolean isDancing = false; public static boolean isDropping = false; public static int timer = -1; private static final int[] BALLOON_IDS = { 115, 116, 117, 118, 119, 120, 121, 122 }; private static final String[] SONG = { ""We're the knights of the party room"", ""We dance round and round like a loon"", ""Quite often we like to sing"", ""Unfortunately we make a din"", ""We're the knights of the party room"", ""Do you like our helmet plumes?"", ""Everyone's happy now we can move"", ""Like a party animal in the groove"" }; @ServerStartupEvent public static void scheduleTimers() { WorldTasks.scheduleLooping(2, 2, () -> { try { if (PartyRoom.isDropping && PartyRoom.timer > 0) { if (PartyRoom.getTimeLeft() % 5 == 0) PartyRoom.yellNpcs(); PartyRoom.timer--; if (PartyRoom.timer <= 0) PartyRoom.spawnBalloons(); } } catch (Throwable e) { Logger.handle(World.class, ""processPartyRoom"", e); } }); } public static void openChest(Player player) { if (!player.getBank().checkPin()) return; if (player.partyDeposit == null) player.partyDeposit = new ItemsContainer<>(8, false); player.getInterfaceManager().sendInterface(CHEST_INTERFACE); player.getInterfaceManager().sendInventoryInterface(INVENTORY_INTERFACE); player.getPackets().sendInterSetItemsOptionsScript(INVENTORY_INTERFACE, 0, 93, 4, 7, ""Deposit"", ""Deposit-5"", ""Deposit-10"", ""Deposit-All"", ""Deposit-X""); player.getPackets().setIFEvents(new IFEvents(INVENTORY_INTERFACE, 0, 0, 27).enableRightClickOptions(0,1,2,3,4,5,6,9)); player.getPackets().sendInterSetItemsOptionsScript(CHEST_INTERFACE, 23, 529, 6, 36, ""Value""); player.getPackets().sendInterSetItemsOptionsScript(CHEST_INTERFACE, 24, 91, 6, 36, ""Value""); player.getPackets().sendInterSetItemsOptionsScript(CHEST_INTERFACE, 25, 92, 8, 1, ""Withdraw""); player.getPackets().setIFEvents(new IFEvents(CHEST_INTERFACE, 23, 0, 215).enableRightClickOptions(0,1,2,3,4,5,9)); player.getPackets().setIFEvents(new IFEvents(CHEST_INTERFACE, 24, 0, 215).enableRightClickOptions(0,9)); player.getPackets().setIFEvents(new IFEvents(CHEST_INTERFACE, 25, 0, 7).enableRightClickOptions(0,9)); player.getPackets().setIFHidden(CHEST_INTERFACE, 26, true); refreshItems(player); player.setCloseInterfacesEvent(() -> { for (Item item : player.partyDeposit.array()) if (item != null) player.getInventory().addItem(item); player.partyDeposit.clear(); }); } public static void purchase(Player player, boolean balloons) { if (balloons) { if (isDropping) { player.sendMessage(""Please wait for the previous party to end.""); return; } for (Item item : World.getData().getPartyRoomStorage().array()) { if (item == null) continue; if (World.getData().getPartyRoomDrop().freeSlots() <= 0) break; World.getData().getPartyRoomDrop().add(item); World.getData().getPartyRoomStorage().remove(item); } if (World.getData().getPartyRoomDrop().getUsedSlots() < 5) { player.sendMessage(""Please deposit 5 or more items into the chest before starting.""); return; } startBalloonTimer(); } else if (!isDancing) startDancingKnights(); } public static void startDancingKnights() { isDancing = true; final NPC[] npcs = new NPC[6]; for (int i = 0; i < 6; i++) { npcs[i] = new NPC(660, Tile.of(3043 + i, 3378, 0)); npcs[i].setFaceAngle(0); } WorldTasks.scheduleLooping(new Task() { int loop; @Override public void run() { if (loop < SONG.length) npcs[2].setNextForceTalk(new ForceTalk(SONG[loop])); else { for (int i = 0; i < 6; i++) npcs[i].finish(); isDancing = false; stop(); } loop++; } }, 0, 3); } public static int getTimeLeft() { return (timer * 600) / 1000; } public static int getRandomBalloon() { return BALLOON_IDS[Utils.random(BALLOON_IDS.length)]; } public static Item getNextItem() { ArrayList items = new ArrayList<>(); for (Item item : World.getData().getPartyRoomDrop().array()) if (item != null) items.add(item); if (items.isEmpty()) return null; Item item = items.get(Utils.random(items.size())); World.getData().getPartyRoomDrop().remove(item); return item; } public static ObjectClickHandler handleLever = new ObjectClickHandler(false, new Object[] { 26194 }, e -> e.getPlayer().setRouteEvent(new RouteEvent(Tile.of(e.getObject().getTile()), () -> e.getPlayer().sendOptionDialogue(ops -> { ops.add(""Balloon Bonanza (1000 coins)."", () -> purchase(e.getPlayer(), true)); ops.add(""Nightly Dance (500 coins)."", () -> purchase(e.getPlayer(), false)); ops.add(""No action.""); })))); public static ObjectClickHandler handleBalloons = new ObjectClickHandler(new Object[] { 115, 116, 117, 118, 119, 120, 121, 122 }, e -> { if (e.getObject() instanceof Balloon balloon) { if (e.getPlayer().isIronMan()) { e.getPlayer().sendMessage(""You can't pop a party balloon as an ironman.""); if (balloon.getItem() != null) e.getPlayer().sendMessage(""You would have gotten "" + balloon.getItem().getDefinitions().getName() + "" though.""); return; } balloon.handlePop(e.getPlayer()); } else { e.getPlayer().setNextAnimation(new Animation(794)); e.getPlayer().lock(); World.removeObject(e.getObject()); final GameObject poppedBalloon = new GameObject(e.getObject().getId() + 8, ObjectType.SCENERY_INTERACT, e.getObject().getRotation(), e.getObject().getX(), e.getObject().getY(), e.getObject().getPlane()); World.spawnObject(poppedBalloon); WorldTasks.schedule(new Task() { @Override public void run() { World.removeObject(poppedBalloon); e.getPlayer().unlock(); } }, 1); } }); public static void spawnBalloons() { ArrayList balloons = new ArrayList<>(); for (int x = 3038; x < 3054; x++) for (int y = 3373; y < 3384; y++) { if (x <= 3049 && x >= 3042 && y == 3378) continue; if (World.floorAndWallsFree(0, x, y, 1) && World.getObject(Tile.of(x, y, 0)) == null) balloons.add(new Balloon(getRandomBalloon(), 0, x, y, 0)); } Collections.shuffle(balloons); for (Balloon balloon : balloons) if (balloon != null) World.spawnObjectTemporary(balloon.setItem(getNextItem()), Ticks.fromMinutes(2)); WorldTasks.schedule(Ticks.fromMinutes(2), () -> { try { isDropping = false; timer = -1; } catch (Throwable e) { Logger.handle(PartyRoom.class, ""spawnBalloons"", e); } }); } public static void startBalloonTimer() { isDropping = true; timer = 200; } public static void yellNpcs() { for (NPC npc : World.getNPCs()) { if (!npc.getDefinitions().getName().toLowerCase().contains(""banker"") && !npc.getDefinitions().getName().toLowerCase().contains(""party"")) continue; npc.setNextForceTalk(new ForceTalk(""There is a drop party worth "" + Utils.formatLong(getTotalCoins()) + "" coins starting in "" + getTimeLeft() + "" seconds!"")); } } public static void refreshItems(Player player) { player.getPackets().sendItems(529, World.getData().getPartyRoomStorage()); player.getPackets().sendItems(91, World.getData().getPartyRoomDrop()); player.getPackets().sendItems(92, player.partyDeposit); } public static void addToChest(Player player) { for (Item item : player.partyDeposit.array()) if (item != null) { if (World.getData().getPartyRoomStorage().freeSlots() <= 0) { player.sendMessage(""There was not enough room in the chest for all those items.""); return; } player.partyDeposit.remove(item); World.getData().getPartyRoomStorage().add(item); } refreshItems(player); } public static void addDeposit(Player player, Item item, int amount) { if (!ItemConstants.isTradeable(item)) { player.sendMessage(""You can't deposit that.""); return; } if (player.getRights() == Rights.ADMIN) { player.sendMessage(""Administrators cannot add items to this chest.""); return; } if (player.getInventory().getAmountOf(item.getId()) < amount) amount = player.getInventory().getAmountOf(item.getId()); if (player.getInventory().containsItem(item.getId(), amount)) { if (player.partyDeposit.freeSlots() <= 0) { player.sendMessage(""Please deposit or withdraw some items before putting more in.""); return; } if (!item.getDefinitions().isStackable() && player.partyDeposit.freeSlots() < amount) amount = player.partyDeposit.freeSlots(); player.partyDeposit.add(new Item(item.getId(), amount)); player.getInventory().deleteItem(item.getId(), amount); } refreshItems(player); } public static void removeDeposit(Player player, int slot) { Item item = player.partyDeposit.get(slot); if (item == null) return; if (player.partyDeposit.contains(item)) { if (!player.getInventory().addItem(item)) { player.sendMessage(""You don't have enough space in your inventory.""); return; } player.partyDeposit.remove(new Item(item.getId(), item.getAmount())); } refreshItems(player); } public static ButtonClickHandler handleButtons = new ButtonClickHandler(new Object[] { CHEST_INTERFACE, INVENTORY_INTERFACE }, e -> { if (e.getInterfaceId() == CHEST_INTERFACE) { if (e.getComponentId() == 25) { Item item = e.getPlayer().partyDeposit.get(e.getSlotId()); if (item == null) return; if (e.getPacket() == ClientPacket.IF_OP1) removeDeposit(e.getPlayer(), e.getSlotId()); else e.getPlayer().sendMessage(ItemConfig.get(item.getId()).getExamine(item)); } else if (e.getComponentId() == 21) addToChest(e.getPlayer()); else if (e.getComponentId() == 23) { Item item = World.getData().getPartyRoomStorage().get(e.getSlotId()); if (item == null) return; if (e.getPacket() == ClientPacket.IF_OP1) e.getPlayer().sendMessage(""Item valued at: "" + item.getDefinitions().getValue()); else e.getPlayer().sendMessage(ItemConfig.get(item.getId()).getExamine(item)); } } else if (e.getInterfaceId() == INVENTORY_INTERFACE) { final Item item = e.getPlayer().getInventory().getItem(e.getSlotId()); if (item == null) return; switch (e.getPacket()) { case IF_OP1: addDeposit(e.getPlayer(), item, 1); break; case IF_OP2: addDeposit(e.getPlayer(), item, 5); break; case IF_OP3: addDeposit(e.getPlayer(), item, 10); break; case IF_OP4: addDeposit(e.getPlayer(), item, e.getPlayer().getInventory().getAmountOf(item.getId())); break; case IF_OP5: e.getPlayer().sendInputInteger(""How many would you like to deposit?"", amount -> addDeposit(e.getPlayer(), item, amount)); break; case IF_OP10: e.getPlayer().sendMessage(ItemConfig.get(item.getId()).getExamine(item)); break; default: break; } } }); public static long getTotalCoins() { long total = 0; for (Item item : World.getData().getPartyRoomDrop().array()) if (item != null) total += (long) item.getDefinitions().getValue() * item.getAmount(); return total; } }" "package com.rs.game.content.minigames.pest; @PluginEventHandler public class CommendationExchange { private static final int INTERFACE = 1011; public static void openExchangeShop(Player player) { player.getInterfaceManager().sendInterface(INTERFACE); player.getVars().setVar(1875, 1250); refreshPoints(player); } public static NPCClickHandler tyrKorasiBuy = new NPCClickHandler(new Object[] { 11681 }, e -> { if (!e.getPlayer().isQuestComplete(Quest.VOID_STARES_BACK, ""to buy Korasi's sword"")) return; e.getPlayer().sendOptionDialogue(""Would you like to buy Korasi's sword for 200,000 coins?"", ops -> { ops.add(""Yes, that sounds like a fair price."", () -> { if (e.getPlayer().getInventory().getCoinsAsInt() < 200_000) { e.getPlayer().sendMessage(""You don't have enough money for that.""); return; } e.getPlayer().getInventory().removeCoins(200_000); e.getPlayer().getInventory().addItemDrop(19784, 1); }); ops.add(""Nevermind.""); }); }); public static ItemOnNPCHandler handleEliteUpgrade = new ItemOnNPCHandler(new Object[] { 11681 }, e -> { if (e.getItem().getId() == 10611 || e.getItem().getId() == 8840 || e.getItem().getId() == 8839) { if (!e.getPlayer().isQuestComplete(Quest.VOID_STARES_BACK, ""to upgrade void knight armor"")) return; if (e.getPlayer().getPestPoints() < 100) { e.getPlayer().sendMessage(""You need 100 Void Knight Commendations to upgrade void knight armor.""); return; } e.getPlayer().sendOptionDialogue(""Upgrade this piece to elite for 100 commendations?"", ops -> { ops.add(""Yes, upgrade my armor."", () -> { if (e.getPlayer().getPestPoints() >= 100) { e.getPlayer().setPestPoints(e.getPlayer().getPestPoints()-100); e.getItem().setId(e.getItem().getId() == 8840 ? 19786 : 19785); e.getPlayer().getInventory().refresh(e.getItem().getSlot()); } }); ops.add(""Nevermind.""); }); } }); public static NPCClickHandler handleVoidExchange = new NPCClickHandler(new Object[] { 12195, ""Void Knight"" }, new String[] { ""Exchange"" }, e -> openExchangeShop(e.getPlayer())); private static void refreshPoints(Player player) { player.getVars().setVarBit(2086, player.getPestPoints()); } public static void confirmBuy(Player player) { player.getPackets().setIFHidden(INTERFACE, 71, true); Reward reward = player.getTempAttribs().removeO(""pcShopBuy""); if (reward == null) return; int currentPoints = player.getPestPoints(); if (!player.hasRights(Rights.DEVELOPER) && currentPoints - reward.cost < 0) { player.sendMessage(""You don't have enough Commendations remaining to complete this exchange.""); return; } player.setPestPoints(currentPoints - reward.cost); refreshPoints(player); reward.give.run(); } public static void buy(Player player, String reward, int cost, Runnable give) { player.getPackets().setIFText(1011, 380, ""Are you sure you wish to exchange ""+cost+"" Commendations in return for a ""+reward+""?""); player.getPackets().setIFHidden(INTERFACE, 71, false); player.getTempAttribs().setO(""pcShopBuy"", new Reward(cost, give)); } private record Reward(int cost, Runnable give) { } static final int[] COMPS = {15, 196, 208, 220, 232, 244, 256, 268, 280}; static final int[] VOIDS = {11665, 11664, 11663, 10611, 8840, 8842, 8841, 19712, 11666}; static final int[] COSTS = {200, 200, 200, 250, 250, 150, 250, 150, 10}; public static void buySkillXp(Player player, int skillId, int componentId) { if (player.getSkills().getLevelForXp(skillId) < 25) { player.sendMessage(""You need 25 "" + Skills.SKILL_NAME[skillId] + "" to purchase experience.""); return; } double multiplier = switch(skillId) { case Skills.PRAYER -> 18.0; case Skills.MAGIC, Skills.RANGE -> 32.0; default -> 35.0; }; double baseXp = (player.getSkills().getLevelForXp(skillId) * player.getSkills().getLevelForXp(skillId)) / 600.0; final double xp = Math.floor(baseXp * multiplier) * getXpCost(componentId); buy(player, Utils.formatNumber((int) xp) + "" "" + Skills.SKILL_NAME[skillId] + "" XP"", getXpCost(componentId), () -> player.getSkills().addXp(skillId, xp)); } private static int getXpCost(int componentId) { return switch(componentId) { case 68, 100, 116, 132, 148, 164, 180 -> 1; case 86, 102, 118, 134, 150, 166, 182 -> 10; case 88, 104, 120, 136, 152, 168, 184 -> 100; default -> 1; }; } public static ButtonClickHandler handleButtonOptions = new ButtonClickHandler(1011, e -> { switch(e.getComponentId()) { case 15, 196, 208, 220, 232, 244, 256, 268, 280 -> { if (!e.getPlayer().getSkills().hasRequirements(Constants.ATTACK, 42, Constants.STRENGTH, 42, Constants.DEFENSE, 42, Constants.HITPOINTS, 42, Constants.RANGE, 42, Constants.MAGIC, 42, Constants.PRAYER, 22)) { e.getPlayer().sendMessage(""You need level 42 Attack, Strength, Defence, Constitution, Ranged, Magic, and 22 Prayer in to purchase void equipment.""); return; } int search = -1; for (int i = 0;i < COMPS.length;i++) if (COMPS[i] == e.getComponentId()) search = i; final int slot = search; buy(e.getPlayer(), ItemDefinitions.getDefs(VOIDS[slot]).name, COSTS[slot], () -> e.getPlayer().getInventory().addItemDrop(VOIDS[slot], 1)); } case 68, 86, 88 -> buySkillXp(e.getPlayer(), Skills.ATTACK, e.getComponentId()); case 100, 102, 104 -> buySkillXp(e.getPlayer(), Skills.STRENGTH, e.getComponentId()); case 116, 118, 120 -> buySkillXp(e.getPlayer(), Skills.DEFENSE, e.getComponentId()); case 132, 134, 136 -> buySkillXp(e.getPlayer(), Skills.HITPOINTS, e.getComponentId()); case 148, 150, 152 -> buySkillXp(e.getPlayer(), Skills.RANGE, e.getComponentId()); case 164, 166, 168 -> buySkillXp(e.getPlayer(), Skills.MAGIC, e.getComponentId()); case 180, 182, 184 -> buySkillXp(e.getPlayer(), Skills.PRAYER, e.getComponentId()); case 291 -> { if (e.getPlayer().getSkills().getLevelForXp(Constants.HERBLORE) < 25) { e.getPlayer().sendMessage(""You need an Herblore level of 25 in order to purchase an herblore pack.""); return; } buy(e.getPlayer(), ""herb pack"", 30, () -> { for (int i = 0;i < 5;i++) { Item[] herb = DropTable.calculateDrops(e.getPlayer(), DropSets.getDropSet(""herb"")); if (herb.length <= 0) continue; e.getPlayer().getInventory().addItemDrop(herb[0].getId()+1, 1); } }); } case 302 -> { if (e.getPlayer().getSkills().getLevelForXp(Constants.MINING) < 25) { e.getPlayer().sendMessage(""You need an Mining level of 25 in order to purchase a mineral pack.""); return; } buy(e.getPlayer(), ""mineral pack"", 15, () -> { e.getPlayer().getInventory().addItem(441, Utils.random(20), true); e.getPlayer().getInventory().addItem(454, Utils.random(30), true); }); } case 313 -> { if (e.getPlayer().getSkills().getLevelForXp(Constants.FARMING) < 25) { e.getPlayer().sendMessage(""You need an Farming level of 25 in order to purchase a seed pack.""); return; } buy(e.getPlayer(), ""seed pack"", 15, () -> { for (int i = 0;i < 6;i++) for (Item rew : DropTable.calculateDrops(e.getPlayer(), DropSets.getDropSet(""nest_shit_seed""))) e.getPlayer().getInventory().addItemDrop(rew); }); } case 324, 326, 328 -> e.getPlayer().sendInputInteger(""How many would you like to buy?"", amt -> buy(e.getPlayer(), Utils.formatNumber(amt) + "" spinner charms"", amt*2, () -> e.getPlayer().getInventory().addItemDrop(12166, amt))); case 339, 341, 343 -> e.getPlayer().sendInputInteger(""How many would you like to buy?"", amt -> buy(e.getPlayer(), Utils.formatNumber(amt) + "" torcher charms"", amt*2, () -> e.getPlayer().getInventory().addItemDrop(12167, amt))); case 354, 356, 358 -> e.getPlayer().sendInputInteger(""How many would you like to buy?"", amt -> buy(e.getPlayer(), Utils.formatNumber(amt) + "" ravager charms"", amt*2, () -> e.getPlayer().getInventory().addItemDrop(12164, amt))); case 369, 371, 373 -> e.getPlayer().sendInputInteger(""How many would you like to buy?"", amt -> buy(e.getPlayer(), Utils.formatNumber(amt) + "" shifter charms"", amt*2, () -> e.getPlayer().getInventory().addItemDrop(12165, amt))); case 383 -> confirmBuy(e.getPlayer()); case 385 -> { e.getPlayer().getPackets().setIFHidden(INTERFACE, 71, true); e.getPlayer().getTempAttribs().removeO(""pcShopBuy""); } case 20, 73 -> { //experience e.getPlayer().getPackets().setIFHidden(INTERFACE, 70, true); e.getPlayer().getPackets().setIFHidden(INTERFACE, 69, true); } case 24, 31 -> { //consumables e.getPlayer().getPackets().setIFHidden(INTERFACE, 70, false); e.getPlayer().getPackets().setIFHidden(INTERFACE, 69, true); } case 29, 75 -> { //equipment e.getPlayer().getPackets().setIFHidden(INTERFACE, 70, true); e.getPlayer().getPackets().setIFHidden(INTERFACE, 69, false); } default -> e.getPlayer().sendMessage(""Component: "" + e.getComponentId()); } }); }" "package com.rs.game.content.minigames.pest; public class Lander { public static Lander[] landers = new Lander[3]; private static final int AUTO_GAME = Settings.getConfig().isDebug() ? 2 : 15; private static final int TIME = 30; private final List lobby = Collections.synchronizedList(new LinkedList<>()); private LobbyTimer timer; private final LanderRequirement landerRequirement; public Lander(LanderRequirement landerRequirement) { this.landerRequirement = landerRequirement; } public class LobbyTimer extends Task { private int seconds = TIME; @Override public void run() { if ((seconds == 0 && lobby.size() >= 5) || lobby.size() >= AUTO_GAME) passPlayersToGame(); else if (seconds == 0) seconds = TIME; else if (lobby.size() == 0) { stop(); return; } seconds--; if (seconds % 30 == 0) refreshLanderInterface(); } public int getMinutes() { return seconds / 60; } } private void passPlayersToGame() { final List playerList = new LinkedList<>(Collections.synchronizedList(lobby)); lobby.clear(); if (playerList.size() > AUTO_GAME) for (int index = AUTO_GAME; index < playerList.size(); index++) { Player player = playerList.get(index); if (player == null) { playerList.remove(index); continue; } player.sendMessage(""You have received priority over other players.""); playerList.remove(index); lobby.add(player); } new PestControl(playerList, PestData.valueOf(landerRequirement.name())).create(); } public void enterLander(Player player) { if (lobby.size() == 0) WorldTasks.scheduleLooping(timer = new LobbyTimer(), 2, 2); player.getControllerManager().startController(new PestControlLobbyController(landerRequirement.getId())); add(player); player.useStairs(-1, landerRequirement.getTile(), 1, 2, ""You board the lander.""); } public void exitLander(Player player) { player.useStairs(-1, landerRequirement.getExitTile(), 1, 2, ""You leave the lander.""); remove(player); } public void add(Player player) { lobby.add(player); refreshLanderInterface(); } private void refreshLanderInterface() { for (Player teamPlayer : lobby) teamPlayer.getControllerManager().getController().sendInterfaces(); } public void remove(Player player) { lobby.remove(player); refreshLanderInterface(); } public List getPlayers() { return lobby; } public static enum LanderRequirement { NOVICE(0, 40, Tile.of(2661, 2639, 0), Tile.of(2657, 2639, 0)), INTERMEDIATE(1, 70, Tile.of(2641, 2644, 0), Tile.of(2644, 2644, 0)), VETERAN(2, 100, Tile.of(2635, 2653, 0), Tile.of(2638, 2653, 0)); private static final Map landers = new HashMap<>(); public static LanderRequirement forId(int id) { return landers.get(id); } static { for (LanderRequirement lander : LanderRequirement.values()) landers.put(lander.getId(), lander); } final int id; final int requirement; int reward; int[] pests; final Tile tile; final Tile exit; private LanderRequirement(int id, int requirement, Tile tile, Tile exit) { this.id = id; this.requirement = requirement; this.tile = tile; this.exit = exit; } public int getId() { return id; } public int getRequirement() { return requirement; } public Tile getTile() { return tile; } public Tile getExitTile() { return exit; } } public static Lander[] getLanders() { return landers; } public LanderRequirement getLanderRequirement() { return landerRequirement; } static { for (int i = 0; i < landers.length; i++) landers[i] = new Lander(LanderRequirement.forId(i)); } @Override public String toString() { return landerRequirement.name().toLowerCase(); } public static boolean canEnter(Player player, int landerIndex) { Lander lander = landers[landerIndex]; if (player.getSkills().getCombatLevelWithSummoning() < lander.getLanderRequirement().requirement) { player.simpleDialogue(""You need a combat level of "" + lander.getLanderRequirement().getRequirement() + "" or more to enter in boat.""); return false; } if (player.getPet() != null || player.getFamiliar() != null) { player.sendMessage(""You can't take a follower into the lander, there isn't enough room!""); return false; } lander.enterLander(player); return true; } public LobbyTimer getTimer() { return timer; } }" "package com.rs.game.content.minigames.pest; public class LanderD extends Conversation { public LanderD(Player player) { super(player); addSimple(""Are you sure you would like to leave the lander?""); addOptions(""Are you sure you would like to leave the lander?"", ops -> { ops.add(""Yes, get me out of here!"", () -> player.getControllerManager().forceStop()); ops.add(""No, I want to stay.""); }); } }" "package com.rs.game.content.minigames.pest; public class PestControl { private final static int[][] PORTAL_LOCATIONS = { { 4, 56, 45, 21, 32 }, { 31, 28, 10, 9, 32 } }; private final static int[] KNIGHT_IDS = { 3782, 3784, 3785 }; private Instance region; private final int[] pestCounts = new int[5]; private final List team; private final List brawlers = new LinkedList<>(); private final PestPortal[] portals = new PestPortal[4]; private PestPortal knight; private final PestData data; private byte portalCount = 5; private class PestGameTimer extends Task { int seconds = 1200; @Override public void run() { try { updateTime(seconds / 60); if (seconds == 0 || canFinish()) { endGame(); stop(); return; } if (seconds % 10 == 0) sendPortalInterfaces(); seconds--; } catch (Exception e) { Logger.handle(PestGameTimer.class, ""run"", e); } } } public PestControl(List team, PestData data) { this.team = Collections.synchronizedList(team); this.data = data; } public PestControl create() { region = Instance.of(Lander.LanderRequirement.VETERAN.exit, 8, 8); region.copyMapAllPlanes(328, 320).thenAccept(e -> { sendBeginningWave(); unlockPortal(); for (Player player : team) { player.getControllerManager().removeControllerWithoutCheck(); player.useStairs(-1, getTile(35 - Utils.random(4), 54 - (Utils.random(3))), 1, 2); player.getControllerManager().startController(new PestControlGameController(this)); } WorldTasks.scheduleLooping(new PestGameTimer(), 2, 2); }); return this; } private void sendBeginningWave() { knight = new PestPortal(KNIGHT_IDS[Utils.random(KNIGHT_IDS.length)], true, getTile(32, 32), this); knight.unlock(); for (int index = 0; index < portals.length; index++) { PestPortal portal = portals[index] = new PestPortal(6146 + index, true, getTile(PORTAL_LOCATIONS[0][index], PORTAL_LOCATIONS[1][index]), this); portal.setHitpoints(data.ordinal() == 0 ? 2000 : 2500); } } public boolean createPestNPC(int index) { if (region == null || pestCounts[index] >= (index == 4 ? 4 : (portals[index] != null && portals[index].isLocked()) ? 5 : 15)) return false; pestCounts[index]++; Tile baseTile = getTile(PORTAL_LOCATIONS[0][index], PORTAL_LOCATIONS[1][index]); Tile teleTile = baseTile; int npcId = index == 4 ? data.getShifters()[Utils.random(data.getShifters().length)] : data.getPests()[Utils.random(data.getPests().length)]; NPCDefinitions defs = NPCDefinitions.getDefs(npcId); for (int trycount = 0; trycount < 10; trycount++) { teleTile = Tile.of(baseTile, 5); if (World.floorAndWallsFree(teleTile, defs.size)) break; teleTile = baseTile; } String name = defs.getName().toLowerCase(); if (name.contains(""shifter"")) new Shifter(npcId, teleTile, -1, true, true, index, this); else if (name.contains(""splatter"")) new Splatter(npcId, teleTile, -1, true, true, index, this); else if (name.contains(""spinner"")) new Spinner(npcId, teleTile, -1, true, true, index, this); else if (name.contains(""brawler"")) brawlers.add(new PestMonsters(npcId, teleTile, -1, true, true, index, this)); else new PestMonsters(npcId, teleTile, -1, true, true, index, this); return true; } public void endGame() { final List team = new LinkedList<>(this.team); this.team.clear(); for (final Player player : team) { final int knightZeal = (int) ((PestControlGameController) player.getControllerManager().getController()).getPoints(); player.getControllerManager().forceStop(); WorldTasks.schedule(new Task() { @Override public void run() { sendFinalReward(player, knightZeal); } }, 1); } region.destroy(); region = null; } private void sendFinalReward(Player player, int knightZeal) { if (knight.isDead()) player.simpleDialogue(""You failed to protect the void knight and have not been awarded any points.""); else if (knightZeal < 750) player.simpleDialogue(""The knights notice your lack of zeal in that battle and have not presented you with any points.""); else { int coinsAmount = player.getSkills().getCombatLevel() * 100; int pointsAmount = data.getReward(); player.simpleDialogue(""Congratulations! You have successfully kept the lander safe and have been awarded: "" + coinsAmount + "" gold coins and "" + pointsAmount + "" commendation points.""); player.getInventory().addCoins(coinsAmount); player.setPestPoints(player.getPestPoints() + pointsAmount); } } private void sendPortalInterfaces() { for (Player player : team) { for (int i = 13; i < 17; i++) { PestPortal npc = portals[i - 13]; if (npc != null) player.getPackets().setIFText(408, i, npc.getHitpoints() + """"); } player.getPackets().setIFText(408, 1, """" + knight.getHitpoints()); } } public void unlockPortal() { if (portalCount == 0) return; if (portalCount == 1) { portalCount--; return; } final int index = Utils.random(portals.length); if (portals[index] == null || portals[index].isDead()) unlockPortal(); else { portalCount--; WorldTasks.schedule(new Task() { @Override public void run() { portals[index].unlock(); } }, 30); } } public boolean isBrawlerAt(Tile tile) { for (Iterator it = brawlers.iterator(); it.hasNext();) { NPC npc = it.next(); if (npc.isDead() || npc.hasFinished()) { it.remove(); continue; } if (npc.getX() == tile.getX() && npc.getY() == tile.getY() && tile.getPlane() == tile.getPlane()) return true; } return false; } private void updateTime(int minutes) { for (Player player : team) player.getPackets().setIFText(408, 0, minutes + "" min""); } public void sendTeamMessage(String message) { for (Player player : team) player.sendMessage(message, true); } private boolean canFinish() { if (knight == null || knight.isDead()) return true; return portalCount == 0; } public Tile getTile(int mapX, int mapY) { if (region == null) return null; return region.getLocalTile(mapX, mapY); } public PestPortal[] getPortals() { return portals; } public List getPlayers() { return team; } public NPC getKnight() { return knight; } public enum PestData { NOVICE(new int[] { /* Shifters */3732, 3733, 3734, 3735, /* Ravagers */3742, 3743, 3744, /* Brawler */3772, 3773, /* Splatter */3727, 3728, 3729, /* Spinner */3747, 3748, 3749, /* Torcher */3752, 3753, 3754, 3755, /* Defiler */3762, 3763, 3764, 3765 }, new int[] { 3732, 3733, 3734, 3735 }, 3), INTERMEDIATE(new int[] { /* Shifters */3734, 3735, 3736, 3737, 3738, 3739/* Ravagers */, 3744, 3743, 3745, /* Brawler */3773, 3775, 3776, /* Splatter */3728, 3729, 3730, /* Spinner */3748, 3749, 3750, 3751, /* Torcher */3754, 3755, 3756, 3757, 3758, 3759, /* Defiler */3764, 3765, 3766, 3768, 3769 }, new int[] { 3734, 3735, 3736, 3737, 3738, 3739 }, 5), VETERAN(new int[] { /* Shifters */3736, 3737, 3738, 3739, 3740, 3741 /* Ravagers */, 3744, 3745, 3746, /* Brawler */3776, 3774,/* Splatter */3729, 3730, 3731, /* Spinner */3749, 3750, 3751, /* Torcher */3758, 3759, 3760, 3761,/* Defiler */ 3770, 3771 }, new int[] { 3736, 3737, 3738, 3739, 3740, 3741 }, 7); private final int[] pests; private final int[] shifters; private final int reward; private PestData(int[] pests, int[] shifters, int reward) { this.pests = pests; this.shifters = shifters; this.reward = reward; } public int[] getShifters() { return shifters; } public int[] getPests() { return pests; } public int getReward() { return reward; } } public int[] getPestCounts() { return pestCounts; } public PestData getPestData() { return data; } public int getPortalCount() { return portalCount; } }" "package com.rs.game.content.minigames.pest; public class PestControlGameController extends Controller { private final transient PestControl control; private double points; @Override public boolean playAmbientOnControllerRegionEnter() { return false; } @Override public boolean playAmbientStrictlyBackgroundMusic() { return true; } public PestControlGameController(PestControl control) { this.control = control; } @Override public void start() { setPoints(0.0D); sendInterfaces(); player.setForceMultiArea(true); player.getMusicsManager().playSongAndUnlock(588); } @Override public void sendInterfaces() { updatePestPoints(); player.getInterfaceManager().sendOverlay(408); } private void updatePestPoints() { boolean isGreen = getPoints() > 750; player.getPackets().setIFText(408, 11, (isGreen ? """" : """") + (int) getPoints() + """"); } @Override public void forceClose() { if (control != null) { if (control.getPortalCount() != 0) if (control.getPlayers().contains(player)) control.getPlayers().remove(player); player.useStairs(-1, Lander.getLanders()[control.getPestData().ordinal()].getLanderRequirement().getExitTile(), 1, 2); } else player.useStairs(-1, Tile.of(2657, 2639, 0), 1, 2); player.setForceMultiArea(false); player.getInterfaceManager().removeOverlay(); player.reset(); } @Override public void onTeleported(TeleType teleType) { player.getControllerManager().forceStop(); } @Override public boolean processTeleport(Teleport tele) { if (tele.type() != TeleType.OBJECT) { player.simpleDialogue(""You can't leave the pest control area like this.""); return false; } return true; } @Override public boolean canMove(Direction dir) { Tile toTile = Tile.of(player.getX() + dir.dx, player.getY() + dir.dy, player.getPlane()); return !control.isBrawlerAt(toTile); } @Override public boolean login() { return true; } @Override public boolean logout() { if (control != null) control.getPlayers().remove(player); return false; } @Override public boolean canSummonFamiliar() { player.sendMessage(""You feel it's best to keep your Familiar away during this game.""); return false; } @Override public boolean sendDeath() { WorldTasks.scheduleLooping(new Task() { int loop; @Override public void run() { if (loop == 0) player.setNextAnimation(new Animation(836)); else if (loop == 1) player.sendMessage(""Oh dear, you have died.""); else if (loop == 3) { player.reset(); Tile tile = control.getTile(35 - Utils.random(4), 54 - (Utils.random(3))); player.tele(tile == null ? Tile.of(2658, 2660, 0) : tile); player.setNextAnimation(new Animation(-1)); } else if (loop == 4) { player.jingle(90); stop(); } loop++; } }, 0, 1); return false; } @Override public void processOutgoingHit(final Hit hit, Entity target) { setPoints(getPoints() + hit.getDamage()); updatePestPoints(); } public double getPoints() { return points; } public void setPoints(double points) { this.points = points; } }" "package com.rs.game.content.minigames.pest; public final class PestControlLobbyController extends Controller { private final int landerId; public PestControlLobbyController(int landerId) { this.landerId = landerId; } @Override public void start() { } @Override public void sendInterfaces() { player.getPackets().setIFText(407, 3, Utils.fixChatMessage(Lander.getLanders()[landerId].toString())); int minutesLeft = (Lander.getLanders()[landerId].getTimer().getMinutes()); player.getPackets().setIFText(407, 13, ""Next Departure: "" + minutesLeft + "" minutes "" + (!(minutesLeft % 2 == 0) ? "" 30 seconds"" : """")); player.getPackets().setIFText(407, 14, ""Player's Ready: "" + Lander.getLanders()[landerId].getPlayers().size()); player.getPackets().setIFText(407, 16, ""Commendations: "" + player.getPestPoints()); player.getInterfaceManager().sendOverlay(407); } @Override public void onTeleported(TeleType teleType) { player.getControllerManager().forceStop(); } @Override public boolean processTeleport(Teleport tele) { if (tele.type() != TeleType.OBJECT) player.getControllerManager().forceStop(); return true; } @Override public void forceClose() { player.getInterfaceManager().removeOverlay(); Lander.getLanders()[landerId].exitLander(player); } @Override public boolean logout() { Lander.getLanders()[landerId].remove(player);// to stop the timer in the // lander and prevent // future errors return false; } @Override public boolean canSummonFamiliar() { player.sendMessage(""You feel it's best to keep your Familiar away during this game.""); return false; } @Override public boolean processObjectClick1(GameObject object) { return switch (object.getId()) { case 14314, 25629, 25630 -> { player.startConversation(new LanderD(player)); yield true; } default -> true; }; } }" "package com.rs.game.content.minigames.pest.npcs; public class PestMonsters extends NPC { protected PestControl manager; protected int portalIndex; public PestMonsters(int id, Tile tile, int mapAreaNameHash, boolean canBeAttackFromOutOfArea, boolean spawned, int index, PestControl manager) { super(id, tile, spawned); this.manager = manager; portalIndex = index; setForceMultiArea(true); setForceAgressive(true); setIgnoreDocile(true); setForceAggroDistance(70); } @Override public void processNPC() { super.processNPC(); if (!getCombat().hasTarget()) checkAggressivity(); } @Override public List getPossibleTargets() { ArrayList possibleTarget = new ArrayList<>(); possibleTarget.addAll(queryNearbyPlayersByTileRange(10, player -> !player.isDead() && player.withinDistance(getTile(), 10))); if (possibleTarget.isEmpty() || Utils.random(3) == 0) { possibleTarget.clear(); possibleTarget.add(manager.getKnight()); } return possibleTarget; } @Override public void sendDeath(Entity source) { super.sendDeath(source); manager.getPestCounts()[portalIndex]--; } }" "package com.rs.game.content.minigames.pest.npcs; public class PestPortal extends NPC { boolean isLocked; PestControl control; int ticks; public PestPortal(int id, boolean canbeAttackedOutOfArea, Tile tile, PestControl control) { super(id, tile, true); this.control = control; setCantFollowUnderCombat(true); setForceMultiArea(true); setCapDamage(400); isLocked = true; } @Override public boolean isLocked() { return isLocked; } @Override public boolean ignoreWallsWhenMeleeing() { return true; } public void unlock() { if (getId() >= 6146) { transformIntoNPC(getId() - 4); control.sendTeamMessage(getStringForId() + "" portal shield has been dropped!""); } isLocked = false; } private String getStringForId() { return switch (getId()) { case 6142 -> ""The purple, western""; case 6143 -> ""The blue, eastern""; case 6144 -> ""The yellow, south-eastern""; case 6145 -> ""The red, south-western""; default -> ""THIS SHOULDN'T EVER HAPPEN.""; }; } private int getIndexForId() { return switch (getId()) { case 6146, 6142 -> 0; case 6147, 6143 -> 1; case 6148, 6144 -> 2; case 6149, 6145 -> 3; case 3782, 3784, 3785 -> 4; default -> -1; }; } @Override public void processNPC() { super.processNPC(); ticks++; if (ticks % 15 == 0) if (control.createPestNPC(getIndexForId())) if (Utils.random(5) == 0) // double spawn xD control.createPestNPC(getIndexForId()); if (isDead() || isLocked) return; cancelFaceEntityNoCheck(); } @Override public void sendDeath(Entity source) { final NPCCombatDefinitions defs = getCombatDefinitions(); resetWalkSteps(); setNextAnimation(null); WorldTasks.scheduleTimer(loop -> { if (loop == 0) setNextAnimation(new Animation(defs.getDeathEmote())); else if (loop >= defs.getDeathDelay()) { if (getIndexForId() != 4) { control.unlockPortal(); control.getKnight().heal(500); } finish(); return false; } return true; }); } }" "package com.rs.game.content.minigames.pest.npcs; public class Ravager extends PestMonsters { boolean destroyingObject = false; public Ravager(int id, Tile tile, int mapAreaNameHash, boolean canBeAttackFromOutOfArea, boolean spawned, int index, PestControl manager) { super(id, tile, -1, false, false, index, manager); } @Override public void processNPC() { super.processNPC(); } }" "package com.rs.game.content.minigames.pest.npcs; public class Shifter extends PestMonsters { public Shifter(int id, Tile tile, int mapAreaNameHash, boolean canBeAttackFromOutOfArea, boolean spawned, int index, PestControl manager) { super(id, tile, mapAreaNameHash, canBeAttackFromOutOfArea, spawned, index, manager); } @Override public void processNPC() { super.processNPC(); Entity target = this.getPossibleTargets().getFirst(); if (getCombat().process() && !this.withinDistance(target.getTile(), 10) || Utils.random(15) == 0) teleportSpinner(target.getTile()); } private void teleportSpinner(Tile tile) { // def 3902, death 3903 tele(Tile.of(tile)); setNextAnimation(new Animation(3904)); WorldTasks.schedule(new Task() { @Override public void run() { setNextSpotAnim(new SpotAnim(654));// 1502 } }); } }" "package com.rs.game.content.minigames.pest.npcs; public class ShifterCombat extends CombatScript { @Override public Object[] getKeys() { return new Object[] { 3732, 3733, 3734, 3735, 3736, 3737, 3738, 3739, 3740, 3741 }; } @Override public int attack(NPC npc, Entity target) { NPCCombatDefinitions def = npc.getCombatDefinitions(); npc.setNextAnimation(new Animation(def.getAttackEmote())); delayHit(npc, 0, target, getMeleeHit(npc, getMaxHit(npc, npc.getCombatDefinitions().getMaxHit(), npc.getAttackStyle(), target))); return npc.getAttackSpeed(); } }" "package com.rs.game.content.minigames.pest.npcs; public class Spinner extends PestMonsters { private byte healTicks; public Spinner(int id, Tile tile, int mapAreaNameHash, boolean canBeAttackFromOutOfArea, boolean spawned, int index, PestControl manager) { super(id, tile, mapAreaNameHash, canBeAttackFromOutOfArea, spawned, index, manager); } @Override public void processNPC() { PestPortal portal = manager.getPortals()[portalIndex]; if (portal.isDead()) { explode(); return; } if (!portal.isLocked) { healTicks++; if (!withinDistance(portal.getTile(), 1)) this.addWalkSteps(portal.getX(), portal.getY()); else if (healTicks % 6 == 0) healPortal(portal); } } private void healPortal(final PestPortal portal) { setNextFaceEntity(portal); WorldTasks.schedule(new Task() { @Override public void run() { setNextAnimation(new Animation(3911)); setNextSpotAnim(new SpotAnim(658, 0, 96 << 16)); if (portal.getHitpoints() != 0) portal.heal((portal.getMaxHitpoints() / portal.getHitpoints()) * 45); healTicks = 0; /* Saves memory in the long run. Meh */ } }); } private void explode() { final NPC npc = this; WorldTasks.schedule(new Task() { @Override public void run() { for (Player player : manager.getPlayers()) { if (!withinDistance(player, 7)) continue; player.getPoison().makePoisoned(50); player.applyHit(new Hit(npc, 50, HitLook.TRUE_DAMAGE)); npc.reset(); npc.finish(); } } }, 1); } }" "package com.rs.game.content.minigames.pest.npcs; public class Splatter extends PestMonsters { public Splatter(int id, Tile tile, int mapAreaNameHash, boolean canBeAttackFromOutOfArea, boolean spawned, int index, PestControl manager) { super(id, tile, mapAreaNameHash, canBeAttackFromOutOfArea, spawned, index, manager); } @Override public void processNPC() { super.processNPC(); } private void sendExplosion() { final Splatter splatter = this; setNextAnimation(new Animation(3888)); WorldTasks.schedule(new Task() { @Override public void run() { setNextAnimation(new Animation(3889)); setNextSpotAnim(new SpotAnim(649 + (getId() - 3727))); WorldTasks.schedule(new Task() { @Override public void run() { finish(); for (Entity e : getPossibleTargets()) if (e.withinDistance(splatter.getTile(), 2)) e.applyHit(new Hit(splatter, Utils.getRandomInclusive(400), HitLook.TRUE_DAMAGE)); } }); } }); } @Override public void sendDeath(Entity source) { final NPCCombatDefinitions defs = getCombatDefinitions(); resetWalkSteps(); getCombat().removeTarget(); setNextAnimation(null); WorldTasks.scheduleTimer(loop -> { if (loop == 0) sendExplosion(); else if (loop >= defs.getDeathDelay()) { reset(); return false; } return true; }); } }" "package com.rs.game.content.minigames.pyramidplunder; @PluginEventHandler public class MummyNPC { private static final int[] ARTEFACT_IDS = { PPArtefact.IVORY_COMB.getArtefactId(), PPArtefact.POTTERY_SCARAB.getArtefactId(), PPArtefact.POTTERY_STATUETTE.getArtefactId(), PPArtefact.STONE_SEAL.getArtefactId(), PPArtefact.STONE_SCARAB.getArtefactId(), PPArtefact.STONE_STATUETTE.getArtefactId(), PPArtefact.GOLD_SEAL.getArtefactId(), PPArtefact.GOLD_SCARAB.getArtefactId(), PPArtefact.GOLD_STATUETTE.getArtefactId() }; private static final int MUMMYID = 4476; private static final int[] PHARAOHS_SCEPTRE = new int[] { 9050, 9048, 9046, 9044 }; public static ItemOnNPCHandler handleSceptreOnGuardianMummy = new ItemOnNPCHandler(new Object[] { 4476 }, e -> { if(e.getItem().getName().contains(""Pharaoh's sceptre"")) MummyRecharge(e.getPlayer()); }); private static boolean playerHasArtefacts(Player player) { for (int artefactId : ARTEFACT_IDS) { if (player.getInventory().containsItem(artefactId)) { return true; } } return false; } private static boolean playerHasSceptre(Player player) { for (int sceptreID : PHARAOHS_SCEPTRE) { if (player.getInventory().containsItem(sceptreID)) { return true; } } return false; } public static NPCClickHandler handleDialogue = new NPCClickHandler(new Object[]{ MUMMYID }, e -> { Player player = e.getPlayer(); if (e.getOption().equalsIgnoreCase(""start-minigame"")) { player.getControllerManager().startController(new PyramidPlunderController()); return; } if (e.getOption().equalsIgnoreCase(""talk-to"")) player.startConversation(new Conversation(player) { { addNPC(MUMMYID, HeadE.CHILD_FRUSTRATED, ""*sigh* Not another one.""); addPlayer(HeadE.CALM_TALK, ""Another what?""); addNPC(MUMMYID, HeadE.CHILD_FRUSTRATED, ""Another 'archaeologist'. I'm not going to let you plunder my master's tomb you know.""); addPlayer(HeadE.HAPPY_TALKING, ""That's a shame. Have you got anything else I could do while I'm here?""); addNPC(MUMMYID, HeadE.CHILD_FRUSTRATED, ""If it will keep you out of mischief I suppose I could set something up for you... I have a few rooms "" + ""full of some things you humans might consider valuable, do you want to give it a go?""); addOptions((""What would you like to say?""), option -> { option.add(""Play Pyramid Plunder?"", new Dialogue() .addOptions((""What would you like to say?""), option2 -> { option2.add(""That sounds like fun; what do I do?"") .addPlayer(HeadE.HAPPY_TALKING, ""That sounds like fun; what do I do?"") .addNPC(MUMMYID, HeadE.CHILD_FRUSTRATED, ""You have five minutes to explore the treasure rooms and collect as many artefacts as "" + ""you can. The artefacts are in the urns, chests and sarcophagi found in each room."") .addNPC(MUMMYID, HeadE.CHILD_FRUSTRATED, ""There are eight treasure rooms, each subsequent room requires higher thieving skills to"" + "" both enter the room and thieve from the urns and other containers"") .addNPC(MUMMYID, HeadE.CHILD_FRUSTRATED, ""The rewards also become more lucrative the further into the tomb you go. You will also have"" + "" to deactivate a trap in order to enter the main part of each room. "") .addNPC(MUMMYID, HeadE.CHILD_FRUSTRATED, ""When you want to move onto the next room you need to find the correct door first. "" + ""There are four possible exits... you must open the door before finding out whether it is the exit or not."") .addNPC(MUMMYID, HeadE.CHILD_FRUSTRATED, ""Opening the doors require picking their locks. Having a lockpick will make this easier."") .addNPC(MUMMYID, HeadE.CHILD_FRUSTRATED, ""Do you want to do it?"") .addOptions((""Sure""), option3 -> { option3.add(""I am ready to give it a go now."") .addNext(() -> player.getControllerManager().startController(new PyramidPlunderController())); option3.add(""Not right now."", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Not right now."") .addNPC(MUMMYID, HeadE.CHILD_FRUSTRATED, ""Well, get out of here then."") ); }); option2.add(""I know what I'm doing, so let's get on with it."", new Dialogue() .addNext(() -> player.getControllerManager().startController(new PyramidPlunderController()))); option2.add(""Not right now."", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Not right now."") .addNPC(MUMMYID, HeadE.CHILD_FRUSTRATED, ""Well, get out of here then."") ); })); if(playerHasSceptre(player)) option.add(""I want to charge my sceptre"", new Dialogue() .addNext(() -> MummyRecharge(e.getPlayer())) ); if(playerHasArtefacts(player)) option.add(""I want to note my artefacts"", new Dialogue() .addNext(() -> { for (int artefactId : ARTEFACT_IDS) { int count = player.getInventory().getNumberOf(artefactId); if (count > 0) { player.getInventory().removeItems(new Item(artefactId, count)); player.getInventory().addItem(new Item(artefactId + 1, count)); } } })); option.add(""Not right now."", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Not right now."") .addNPC(MUMMYID, HeadE.CHILD_FRUSTRATED, ""Well, get out of here then."") ); }); } }); }); public static void MummyRecharge(Player player) { player.startConversation(new Conversation(player) { { if (player.getInventory().containsOneItem(PHARAOHS_SCEPTRE[3],PHARAOHS_SCEPTRE[2],PHARAOHS_SCEPTRE[1])) { addNPC(MUMMYID, HeadE.CHILD_FRUSTRATED, ""I'm not waisting the King's magic on a charged sceptre""); } else { addPlayer(HeadE.CALM_TALK, ""I want to charge my sceptre.""); addNPC(MUMMYID, HeadE.CHILD_ANGRY_HEADSHAKE, ""You shouldn't have that thing in the first place, thief!""); addPlayer(HeadE.SKEPTICAL, ""Hmm... If I give you back some of the artefacts I've taken from the tomb, will you recharge the sceptre for me?""); addNPC(MUMMYID, HeadE.CHILD_ANGRY, ""*sigh* Oh alright, but this is such a waste of the King's magic...""); addOptions(""What artefact would you like to use?"", option -> { option.add(""Gold artefacts?"", new Dialogue() .addPlayer(HeadE.CALM, ""I'd like to use some gold artefacts"") .addNext(() -> rechargeSceptreWithArtefacts(player, Arrays.asList( new ArtefactInfo(PPArtefact.NOTED_GOLD_SEAL.getArtefactId(), 6, ""gold""), new ArtefactInfo(PPArtefact.NOTED_GOLD_SCARAB.getArtefactId(), 6, ""gold""), new ArtefactInfo(PPArtefact.NOTED_GOLD_STATUETTE.getArtefactId(), 6, ""gold""), new ArtefactInfo(PPArtefact.GOLD_SEAL.getArtefactId(), 6, ""gold""), new ArtefactInfo(PPArtefact.GOLD_SCARAB.getArtefactId(), 6, ""gold""), new ArtefactInfo(PPArtefact.GOLD_STATUETTE.getArtefactId(), 6, ""gold"") ) )) ); option.add(""Stone artefacts?"", new Dialogue() .addPlayer(HeadE.CALM, ""I'd like to use some stone artefacts"") .addNext(() -> rechargeSceptreWithArtefacts(player, Arrays.asList( new ArtefactInfo(PPArtefact.NOTED_STONE_SEAL.getArtefactId(), 12, ""stone""), new ArtefactInfo(PPArtefact.NOTED_STONE_SCARAB.getArtefactId(), 12, ""stone""), new ArtefactInfo(PPArtefact.NOTED_STONE_STATUETTE.getArtefactId(), 12, ""stone""), new ArtefactInfo(PPArtefact.STONE_SEAL.getArtefactId(), 12, ""stone""), new ArtefactInfo(PPArtefact.STONE_SCARAB.getArtefactId(), 12, ""stone""), new ArtefactInfo(PPArtefact.STONE_STATUETTE.getArtefactId(), 12, ""stone"") ) )) ); option.add(""Pottery or ivory artefacts?"", new Dialogue() .addPlayer(HeadE.CALM, ""I'd like to use some pottery or ivory artefacts"") .addNext(() -> rechargeSceptreWithArtefacts(player, Arrays.asList( new ArtefactInfo(PPArtefact.NOTED_IVORY_COMB.getArtefactId(), 24, ""ivory or pottery""), new ArtefactInfo(PPArtefact.NOTED_POTTERY_SCARAB.getArtefactId(), 24, ""ivory or pottery""), new ArtefactInfo(PPArtefact.NOTED_POTTERY_STATUETTE.getArtefactId(), 24, ""ivory or pottery""), new ArtefactInfo(PPArtefact.IVORY_COMB.getArtefactId(), 24, ""ivory or pottery""), new ArtefactInfo(PPArtefact.POTTERY_SCARAB.getArtefactId(), 24, ""ivory or pottery""), new ArtefactInfo(PPArtefact.POTTERY_STATUETTE.getArtefactId(), 24, ""ivory or pottery"") ) )) ); option.add(""Jewelled artefacts?"", new Dialogue() .addPlayer(HeadE.CALM, ""I'd like to use a jewelled artefact"") .addNext(() -> rechargeSceptreWithJewelledArtefact(player, PPArtefact.JEWELLED_GOLDEN.getArtefactId() )) ); }); } } }); } private static void rechargeSceptreWithArtefacts(Player player, List artefacts) { boolean hasRequiredArtefacts = false; int finalArtefactID = 0; int finalCount =0; for (ArtefactInfo artefactInfo : artefacts) { int itemId = artefactInfo.getItemId(); int requiredCount = artefactInfo.getRequiredCount(); if (player.getInventory().containsItem(itemId, requiredCount)) { hasRequiredArtefacts = true; finalArtefactID = itemId; finalCount = requiredCount; break; } } if (hasRequiredArtefacts) { if (finalArtefactID == PPArtefact.JEWELLED_GOLDEN.getArtefactId()) { rechargeSceptreWithJewelledArtefact(player, finalArtefactID); } else { exchangeSceptre(player, finalArtefactID, finalCount); player.sendMessage(""You recharge your sceptre with "" + ArtefactInfo.artefactType + "" artefacts.""); } } else { int finalRequired = switch (ArtefactInfo.artefactType) { case ""ivory or pottery"" -> 24; case ""stone"" -> 12; case ""gold"" -> 6; case ""jewelled"" -> 1; default -> 0; }; player.startConversation(new Conversation(player) { { addNPC(MUMMYID, HeadE.CHILD_FRUSTRATED, ""You need to have "" + finalRequired + "" of the same "" + ArtefactInfo.artefactType + "" artefacts to recharge your sceptre.""); } }); } } private static void rechargeSceptreWithJewelledArtefact(Player player, int jewelledArtefactId) { if (player.getInventory().containsItem(jewelledArtefactId, 1)) { exchangeSceptre(player, jewelledArtefactId, 1); player.sendMessage(""You recharge your sceptre with a jewelled golden statuette.""); } else { player.startConversation(new Conversation(player) { { addNPC(MUMMYID, HeadE.CHILD_FRUSTRATED, ""You don't have a jewelled golden statuette.""); } }); } } private static void exchangeSceptre(Player player, int artefactID, int count) { player.getInventory().removeItems(new Item(PHARAOHS_SCEPTRE[0]), new Item(PHARAOHS_SCEPTRE[1]), new Item(PHARAOHS_SCEPTRE[2])); player.getInventory().removeItems(new Item(artefactID, count)); player.getInventory().addItem(new Item(PHARAOHS_SCEPTRE[3])); player.getInventory().refresh(); } private static class ArtefactInfo { private final int itemId; private final int requiredCount; private static String artefactType = """"; public ArtefactInfo(int itemId, int requiredCount, String artefactType) { this.itemId = itemId; this.requiredCount = requiredCount; this.artefactType = artefactType; } public int getItemId() { return itemId; } public int getRequiredCount() { return requiredCount; } public String getArtefactType() { return artefactType; } } }" "package com.rs.game.content.minigames.pyramidplunder; @PluginEventHandler public class OuterPyramidHandler {//OuterPyramidHandler plunder is all in one region. static Tile[] MUMMY_LOCATIONS = {Tile.of(1934, 4458, 2), Tile.of(1968, 4428, 2), Tile.of(1934, 4428, 3), Tile.of(1968, 4458, 3)}; static Set MUMMY_CHUNKS = new HashSet<>(Arrays.asList(3952992, 4034880, 3952960, 4034912)); static int MUMMY_ROOM = 0; @ServerStartupEvent public static void init() { WorldTasks.scheduleLooping(0, 600, () -> MUMMY_ROOM = Utils.randomInclusive(0, 3)); } public static ObjectClickHandler handleOuterPyramidDoors = new ObjectClickHandler(new Object[] { 16543, 16544, 16545, 16546 }, e -> { Player p = e.getPlayer(); Tile[] tiles = MUMMY_LOCATIONS; if(e.getObjectId() == 16543) enterMummyRoom(p, tiles[0]); else if(e.getObjectId() == 16544) enterMummyRoom(p, tiles[1]); else if(e.getObjectId() == 16545) enterMummyRoom(p, tiles[2]); else if(e.getObjectId() == 16546) enterMummyRoom(p, tiles[3]); }); private static void enterMummyRoom(Player p, Tile tile) { p.lock(5); WorldTasks.scheduleLooping(new Task() { int tick; @Override public void run() { if(tick == 0) p.getInterfaceManager().setFadingInterface(115); if(tick == 2) { p.faceNorth(); p.tele(Tile.of(tile.getX(), tile.getY() - 8, tile.getPlane())); } if(tick == 3) p.getInterfaceManager().setFadingInterface(170); tick++; } }, 0, 1); } public static ObjectClickHandler handlePyramidExits = new ObjectClickHandler(new Object[] { 16459 }, e -> { Player p = e.getPlayer(); Tile[] tiles = MUMMY_LOCATIONS; if(p.withinDistance(tiles[0])) exitMummyRoom(p, Tile.of(3288, 2801, 0), 0); else if(p.withinDistance(tiles[1])) exitMummyRoom(p, Tile.of(3295, 2795, 0), 1); else if(p.withinDistance(tiles[2])) exitMummyRoom(p, Tile.of(3289, 2788, 0), 2); else if(p.withinDistance(tiles[3])) exitMummyRoom(p, Tile.of(3282, 2794, 0), 3); }); private static void exitMummyRoom(Player p, Tile tile, int dir) { p.lock(4); WorldTasks.scheduleLooping(new Task() { int tick; @Override public void run() { if(tick == 0) p.getInterfaceManager().setFadingInterface(115); if(tick == 2) { if(dir ==0) p.faceNorth(); if(dir ==1) p.faceEast(); if(dir ==2) p.faceSouth(); if(dir ==3) p.faceWest(); p.tele(tile); } if(tick == 3) p.getInterfaceManager().setFadingInterface(170); tick++; } }, 0, 1); } public static EnterChunkHandler handleMummySpawn = new EnterChunkHandler(e -> { Player p = e.getPlayer(); if(MUMMY_CHUNKS.contains(e.getChunkId())) { if(p == null) return; moveMummy(p); } }); private static void moveMummy(Player p) { for(NPC npc : World.getNPCsInChunkRange(p.getChunkId(), 2))//If mummy is correct dont do anything if(npc.getId() == 4476) if(npc.withinDistance(MUMMY_LOCATIONS[MUMMY_ROOM], 5)) return; for(NPC npc : World.getNPCsInChunkRange(p.getChunkId(), 2))//else finish if(npc.getId() == 4476) npc.tele(MUMMY_LOCATIONS[MUMMY_ROOM]); } }" "package com.rs.game.content.minigames.pyramidplunder; public enum PPArtefact { IVORY_COMB(9026, 50), POTTERY_SCARAB(9032, 75), POTTERY_STATUETTE(9036, 100), STONE_SEAL(9042, 150), STONE_SCARAB(9030, 175), STONE_STATUETTE(9038, 200), GOLD_SEAL(9040, 750), GOLD_SCARAB(9028, 1000), GOLD_STATUETTE(9034, 1250), JEWELLED_GOLDEN(20661, 7500), JEWELLED_DIAMOND(21570, 12500), NOTED_IVORY_COMB(9027, 50), NOTED_POTTERY_SCARAB(9033, 75), NOTED_POTTERY_STATUETTE(9037, 100), NOTED_STONE_SEAL(9043, 150), NOTED_STONE_SCARAB(9031, 175), NOTED_STONE_STATUETTE(9039, 200), NOTED_GOLD_SEAL(9041, 750), NOTED_GOLD_SCARAB(9029, 1000), NOTED_GOLD_STATUETTE(9035, 1250 ); private static final Map MAP = new HashMap<>(); static { for (PPArtefact p : PPArtefact.values()) MAP.put(p.id, p); } public static PPArtefact forId(int id) { return MAP.get(id); } private final int id; private final int tradeInValue; private PPArtefact(int id, int tradeInValue) { this.id = id; this.tradeInValue = tradeInValue; } public int getArtefactId() { return id; } public int getTradeInValue() { return tradeInValue; } }" "package com.rs.game.content.minigames.pyramidplunder; @PluginEventHandler public class PyramidPlunder { public static final Tile EXIT_TILE = Tile.of(3288, 2801, 0); public static final Integer[] DOORS = { 16539, 16540, 16541, 16542 }; private static final int PHARAOHS_SCEPTRE = 9044; private static final int SCEPTRE_OF_THE_GODS = 21536; private static final int[] BLACK_IBIS = { 21532, 21533, 21534, 21535 }; public static ObjectClickHandler handlePyramidExits = new ObjectClickHandler(new Object[] { 16458 }, e -> { PyramidPlunderController ctrl = e.getPlayer().getControllerManager().getController(PyramidPlunderController.class); if (ctrl == null) { e.getPlayer().tele(EXIT_TILE); e.getPlayer().sendMessage(""No idea how you got in here. But get out bad boy.""); return; } e.getPlayer().startConversation(new Dialogue().addOptions(""Would you like to exit?"", new Options() { @Override public void create() { option(""Yes"", new Dialogue().addNext(ctrl::exitMinigame)); option(""No"", new Dialogue()); } })); }); public static ObjectClickHandler handlePlunderUrns = new ObjectClickHandler(new Object[] { 16518, 16519, 16520, 16521, 16522, 16523, 16524, 16525, 16526, 16527, 16528, 16529, 16530, 16531, 16532 }, e -> { PyramidPlunderController ctrl = e.getPlayer().getControllerManager().getController(PyramidPlunderController.class); if (ctrl == null) { e.getPlayer().tele(EXIT_TILE); e.getPlayer().sendMessage(""No idea how you got in here. But get out bad boy.""); return; } e.getPlayer().lock(); int varbitValue = e.getPlayer().getVars().getVarBit(e.getObject().getDefinitions().varpBit); if (varbitValue == 1) { e.getPlayer().unlock(); e.getPlayer().sendMessage(""The urn is empty.""); return; } switch(e.getOption()) { case ""Check for Snakes"" -> { e.getPlayer().unlock(); e.getPlayer().getSkills().addXp(Constants.THIEVING, getRoomBaseXP(ctrl.getCurrentRoom())); ctrl.updateObject(e.getObject(), 2); return; } case ""Charm Snake"" -> { e.getPlayer().unlock(); if (e.getPlayer().getInventory().containsItem(4605, 1)) { e.getPlayer().setNextAnimation(new Animation(1877)); ctrl.updateObject(e.getObject(), 3); } else e.getPlayer().sendMessage(""You need a snake charm flute for that!""); } case ""Search"" -> WorldTasks.scheduleTimer(i -> { switch(i) { case 1 -> { e.getPlayer().faceObject(e.getObject()); e.getPlayer().setNextAnimation(new Animation(4340)); } case 3 -> { if (rollUrnSuccess(e.getPlayer(), ctrl.getCurrentRoom(), varbitValue)) { e.getPlayer().setNextAnimation(new Animation(4342)); e.getPlayer().getSkills().addXp(Constants.THIEVING, getRoomBaseXP(ctrl.getCurrentRoom())* (varbitValue == 0 ? 3 : 2)); ctrl.updateObject(e.getObject(), 1); loot(e.getPlayer(), ""pp_urn"", ctrl.getCurrentRoom()); } else { e.getPlayer().setNextAnimation(new Animation(4341)); e.getPlayer().applyHit(new Hit(e.getPlayer().getSkills().getLevel(Constants.HITPOINTS) / 5, Hit.HitLook.TRUE_DAMAGE)); e.getPlayer().getPoison().makePoisoned(30); e.getPlayer().forceTalk(""Ow!""); } } case 5 -> { e.getPlayer().unlock(); e.getPlayer().processReceivedHits(); return false; } } return true; }); } }); public static ObjectClickHandler handleGrandChest = new ObjectClickHandler(new Object[] { 16537 }, e -> { PyramidPlunderController ctrl = e.getPlayer().getControllerManager().getController(PyramidPlunderController.class); if (ctrl == null) { e.getPlayer().tele(EXIT_TILE); e.getPlayer().sendMessage(""No idea how you got in here. But get out bad boy.""); return; } if(Utils.randomInclusive(0, 4) == 1) { OwnedNPC swarm = new OwnedNPC(e.getPlayer(), 2001, Tile.of(e.getPlayer().getTile()), false); swarm.setTarget(e.getPlayer()); } ctrl.updateObject(e.getObject(), 1); e.getPlayer().getSkills().addXp(Constants.THIEVING, getRoomBaseXP(ctrl.getCurrentRoom()) * 2); loot(e.getPlayer(), ""pp_sarcophagus"", ctrl.getCurrentRoom()); }); public static ObjectClickHandler handleSarcophagus = new ObjectClickHandler(new Object[] { 16547 }, e -> { PyramidPlunderController ctrl = e.getPlayer().getControllerManager().getController(PyramidPlunderController.class); if (ctrl == null) { e.getPlayer().tele(EXIT_TILE); e.getPlayer().sendMessage(""No idea how you got in here. But get out bad boy.""); return; } int lvlReq = (ctrl.getCurrentRoom()+1) * 10 + 1; if (e.getPlayer().getSkills().getLevel(Constants.STRENGTH) < lvlReq) { e.getPlayer().sendMessage(""You need "" + lvlReq + "" strength...""); return; } if (e.getOption().equals(""Open"")) { e.getPlayer().lock(); boolean success = rollSarcophagusSuccess(e.getPlayer(), ctrl.getCurrentRoom()); WorldTasks.scheduleTimer(i -> { switch(i) { case 0 -> e.getPlayer().faceObject(e.getObject()); case 1 -> e.getPlayer().setNextAnimation(new Animation(success ? 4345 : 4344)); case 3 -> ctrl.updateObject(e.getObject(), success ? 1 : 0); case 6 -> { if (success) { if (Utils.randomInclusive(0, 4) == 1) { OwnedNPC mummy = new OwnedNPC(e.getPlayer(), 2015, Tile.of(e.getPlayer().getTile()), false); mummy.setTarget(e.getPlayer()); } e.getPlayer().getSkills().addXp(Constants.STRENGTH, getRoomBaseXP(ctrl.getCurrentRoom())); ctrl.updateObject(e.getObject(), 2); loot(e.getPlayer(), ""pp_sarcophagus"", ctrl.getCurrentRoom()); } else { e.getPlayer().applyHit(new Hit(e.getPlayer().getSkills().getLevel(Constants.HITPOINTS) / 5, Hit.HitLook.TRUE_DAMAGE)); e.getPlayer().forceTalk(""Ow!""); } } case 8 -> { e.getPlayer().unlock(); return false; } } return true; }); } }); public static ObjectClickHandler handleEngravedSarcophagus = new ObjectClickHandler(new Object[] { 59795 }, e -> { PyramidPlunderController ctrl = e.getPlayer().getControllerManager().getController(PyramidPlunderController.class); if (ctrl == null) { e.getPlayer().tele(EXIT_TILE); e.getPlayer().sendMessage(""No idea how you got in here. But get out bad boy.""); return; } if (e.getOption().equals(""Open"")) { if (Utils.randomInclusive(0, 4) == 1) { OwnedNPC mummy = new OwnedNPC(e.getPlayer(), 2015, Tile.of(e.getPlayer().getTile()), false); mummy.setTarget(e.getPlayer()); } ctrl.updateObject(e.getObject(), 1); e.getPlayer().getSkills().addXp(Skills.RUNECRAFTING, getRoomBaseXP(ctrl.getCurrentRoom())); loot(e.getPlayer(), ""pp_sarcophagus_engraved"", ctrl.getCurrentRoom()); } else if (e.getOption().equals(""Search"")) { e.getPlayer().sendMessage(""The sarcophagus has already been looted.""); } }); public static ObjectClickHandler handlePyramidTombDoors = new ObjectClickHandler((Object[]) DOORS, e -> { PyramidPlunderController ctrl = e.getPlayer().getControllerManager().getController(PyramidPlunderController.class); if (ctrl == null) { e.getPlayer().tele(EXIT_TILE); e.getPlayer().sendMessage(""No idea how you got in here. But get out bad boy.""); return; } if (e.getOption().equals(""Pick-lock"")) { e.getPlayer().lock(); WorldTasks.scheduleTimer(i -> { switch(i) { case 1 -> { e.getPlayer().faceObject(e.getObject()); e.getPlayer().setNextAnimation(new Animation(832)); } case 3 -> { if (Utils.skillSuccess(e.getPlayer().getSkills().getLevel(Skills.THIEVING), e.getPlayer().getInventory().containsOneItem(1523, 11682) ? 1.3 : 1.0, 190, 190)) { e.getPlayer().getSkills().addXp(Constants.THIEVING, getRoomBaseXP(ctrl.getCurrentRoom()) * 2); ctrl.updateObject(e.getObject(), 1); } else { e.getPlayer().sendMessage(""You fail to pick the lock.""); e.getPlayer().unlock(); return false; } } case 5 -> { if (e.getObjectId() == ctrl.getCorrectDoor()) ctrl.nextRoom(); else e.getPlayer().sendMessage(""The door leads nowhere.""); } case 6 -> { e.getPlayer().unlock(); return false; } } return true; }); } else if (e.getOption().equals(""Enter"")) { if (e.getObjectId() == ctrl.getCorrectDoor()) { ctrl.nextRoom(); return; } else e.getPlayer().sendMessage(""You've already checked this door and found it's not the right way.""); } }); private static int getRoomBaseXP(int roomId) { return switch(roomId) { case 1 -> 20; case 2 -> 30; case 3 -> 50; case 4 -> 70; case 5 -> 100; case 6 -> 150; case 7 -> 225; case 8 -> 275; default -> 0; }; } private static boolean rollUrnSuccess(Player player, int room, int varbitValue) { double boost = player.getAuraManager().getThievingMul(); if (varbitValue == 2) boost += 0.15; else if (varbitValue == 3) boost += 0.40; int chance1 = switch(room) { case 1 -> 73; case 2 -> 55; case 3 -> 32; case 4 -> -21; case 5 -> -72; case 6 -> -150; case 7 -> -300; default -> -900; }; int chance99 = switch(room) { case 1 -> 213; case 2 -> 207; case 3 -> 203; case 4 -> 197; case 5 -> 193; case 6 -> 187; case 7 -> 183; default -> 177; }; return Utils.skillSuccess(player.getSkills().getLevel(Constants.THIEVING), boost, chance1, chance99, varbitValue != 0 ? 235 : 213); } private static boolean rollSarcophagusSuccess(Player player, int room) { int chance1 = switch(room) { case 1 -> 62; case 2 -> 30; case 3 -> 20; case 4 -> 0; case 5 -> -50; case 6 -> -90; case 7 -> -120; default -> -200; }; int chance99 = switch(room) { case 1 -> 256; case 2 -> 226; case 3 -> 196; case 4 -> 166; case 5 -> 136; case 6 -> 106; case 7 -> 76; default -> 46; }; return Utils.skillSuccess(player.getSkills().getLevel(Constants.STRENGTH), 1.0, chance1, chance99, 188); } private static boolean loot(Player player, String lootTable, int room) { String thingLooted = ""urns""; if (lootTable.contains(""chest"")) thingLooted = ""grand chests""; else if (lootTable.contains(""sarcophagus"")) thingLooted = ""sarcophagi""; else if (lootTable.contains(""engraved"")) thingLooted = ""engraved sarcophagi""; player.incrementCount(""Pyramid Plunder "" + thingLooted + "" looted"", 1); if (rollForBlackIbis(player)) return false; if (lootTable.contains(""sarcophagus"")) { int chance = switch(room) { case 1 -> 3500; case 2 -> 2250; case 3 -> 1250; case 4 -> 750; default -> 650; }; if (Utils.random(chance * (player.getEquipment().wearingRingOfWealth() ? 0.97 : 1)) == 0) { player.getInventory().addItemDrop(PHARAOHS_SCEPTRE, 1); World.broadcastLoot(player.getDisplayName() + "" has just received a Pharaoh's sceptre from Pyramid Plunder!""); return true; } } if (!player.containsItem(SCEPTRE_OF_THE_GODS) && lootTable.contains(""engraved"")) { if (Utils.random(650 * (player.getEquipment().wearingRingOfWealth() ? 0.97 : 1)) == 0) { player.getInventory().addItemDrop(new Item(SCEPTRE_OF_THE_GODS).addMetaData(""teleCharges"", 10)); World.broadcastLoot(player.getDisplayName() + "" has just received a Sceptre of the Gods from Pyramid Plunder!""); return true; } } Item[] drops = DropTable.calculateDrops(DropSets.getDropSet(lootTable + room)); for (Item item : drops) { if (item == null) continue; player.getInventory().addItemDrop(item); } return false; } public static boolean rollForBlackIbis(Player player) { if (player.containsItem(BLACK_IBIS[3])) return false; int rate = player.getEquipment().getWeaponId() == SCEPTRE_OF_THE_GODS ? 1150 : 2300; if (player.getEquipment().wearingRingOfWealth()) rate *= 0.97; if (Utils.random(rate) == 0) { int drop = -1; for (int peices : BLACK_IBIS) { if (!player.containsItem(peices)) { drop = peices; break; } } player.getInventory().addItemDrop(drop, 1); World.broadcastLoot(player.getDisplayName() + "" has just received a peice of Black Ibis from Pyramid Plunder!""); return true; } return false; } public static ObjectClickHandler handleSpearTrap = new ObjectClickHandler(new Object[] { 16517 }, e -> { PyramidPlunderController ctrl = e.getPlayer().getControllerManager().getController(PyramidPlunderController.class); if (ctrl == null) { e.getPlayer().tele(EXIT_TILE); e.getPlayer().sendMessage(""No idea how you got in here. But get out bad boy.""); return; } int lvlReq = (ctrl.getCurrentRoom()+1) * 10 + 1; if (e.getPlayer().getSkills().getLevel(Constants.THIEVING) < lvlReq) { e.getPlayer().sendMessage(""You need a thieving level of "" + lvlReq + "" or higher...""); return; } passTrap(e); }); /** * Use nearby tiles surrounding the trap object to choose a direction for the far tiles. * Both near and far point in the same directions per index N, E, S, W * If a nearby tile is a trap that is the direction we must go as a player... * @param e */ private static void passTrap(ObjectClickEvent e) { Tile[] nearbyTiles = { e.getObject().getTile().transform(0, 1), e.getObject().getTile().transform(1, 0), e.getObject().getTile().transform(0, -1), e.getObject().getTile().transform(-1, 0) }; Tile[] farTiles = { e.getPlayer().transform(0, 3), e.getPlayer().transform(3, 0), e.getPlayer().transform(0, -3), e.getPlayer().transform(-3, 0) }; int tileIdx = 0; for(Tile nearbyTile : nearbyTiles) { GameObject obj2 = World.getObject(nearbyTile, ObjectType.SCENERY_INTERACT); if (obj2 != null && obj2.getId() == 16517) break; tileIdx++; } final Tile toTile = farTiles[tileIdx]; e.getPlayer().lock(); boolean hasRun = e.getPlayer().getRun(); WorldTasks.scheduleTimer(i -> { switch(i) { case 1 -> { e.getPlayer().faceObject(e.getObject()); e.getPlayer().setNextAnimation(new Animation(832)); } case 3 -> { e.getPlayer().setRun(false); e.getPlayer().addWalkSteps(toTile, 4, false); } case 5 -> { e.getPlayer().setRun(hasRun); e.getPlayer().getSkills().addXp(Skills.THIEVING, 10); } case 6 -> { e.getPlayer().unlock(); return false; } } return true; }); } final static Tile[] rightHandSpearTraps = { Tile.of(1927, 4473, 0), Tile.of(1928, 4473, 0), Tile.of(1930, 4452, 0), Tile.of(1930, 4453, 0), Tile.of(1955, 4474, 0), Tile.of(1954, 4474, 0), Tile.of(1961, 4444, 0), Tile.of(1961, 4445, 0), Tile.of(1927, 4428, 0), Tile.of(1926, 4428, 0), Tile.of(1944, 4425, 0), Tile.of(1945, 4425, 0), Tile.of(1974, 4424, 0), Tile.of(1975, 4424, 0) }; final static Tile[] leftHandSpearTraps = { Tile.of(1927, 4472, 0), Tile.of(1928, 4472, 0), Tile.of(1931, 4452, 0), Tile.of(1931, 4453, 0), Tile.of(1955, 4473, 0), Tile.of(1954, 4473, 0), Tile.of(1962, 4444, 0), Tile.of(1962, 4445, 0), Tile.of(1927, 4427, 0), Tile.of(1926, 4427, 0), Tile.of(1944, 4424, 0), Tile.of(1945, 4424, 0), Tile.of(1974, 4423, 0), Tile.of(1975, 4423, 0) }; public static PlayerStepHandler handleRightHandSpearTraps = new PlayerStepHandler(rightHandSpearTraps, e -> { if(e.getPlayer().isLocked()) return; Direction rightHandTrap = Direction.rotateClockwise(e.getStep().dir, 2);//90 degree turn activateTrap(e, rightHandTrap); hitPlayer(e); }); public static PlayerStepHandler handleLeftHandSpearTraps = new PlayerStepHandler(leftHandSpearTraps, e -> { if(e.getPlayer().isLocked()) return; Direction leftHandTrap = Direction.rotateClockwise(e.getStep().dir, 6);//270 degree turn activateTrap(e, leftHandTrap); hitPlayer(e); }); private static void activateTrap(PlayerStepEvent e, Direction trapDir) { Tile trapTile = e.getTile(); for(GameObject obj : ChunkManager.getChunk(trapTile.getChunkId()).getBaseObjects()) if(obj.getId() == 16517) { if(trapTile.matches(obj.getTile()) || (obj.getX() - trapDir.dx == trapTile.getX() && obj.getY() - trapDir.dy == trapTile.getY())) { obj.animate(new Animation(463)); break; } } } private static void hitPlayer(PlayerStepEvent e) { Player p = e.getPlayer(); p.applyHit(new Hit(30, Hit.HitLook.POISON_DAMAGE)); p.getPoison().makePoisoned(20); Direction oppositeDir = Direction.rotateClockwise(e.getStep().dir, 4);//180 degree turn int dX = oppositeDir.dx; int dY = oppositeDir.dy; p.forceMove(Tile.of(e.getTile().getX() + dX, e.getTile().getY() + dY, e.getTile().getPlane()), 1832, 25, 45, () -> p.forceTalk(""Ouch!"")); } }" "package com.rs.game.content.minigames.pyramidplunder; public class PyramidPlunderController extends Controller { final static int PLUNDER_INTERFACE = 428; private int tick = 500; private int currentRoom = 0; private int correctDoor = 0; private final List checkedDoors = new ArrayList<>(); private final Map varbits = new HashMap<>(); @Override public void start() { player.getInterfaceManager().sendOverlay(PLUNDER_INTERFACE); updatePlunderInterface(); nextRoom(); } @Override public void process() { if (tick == 0) { kickPlayer(); tick = -1; return; } if (!player.hasRights(Rights.ADMIN)) tick--; if (tick % 5 == 0) updatePlunderInterface(); } private void updatePlunderInterface() { player.getVars().setVar(822, (currentRoom + 1) * 10 + 1); player.getVars().setVarBit(2377, currentRoom); player.getVars().setVarBit(2375, 500-tick); } private void kickPlayer() { player.lock(); player.startConversation(new Dialogue() .addNPC(4476, HeadE.CHILD_FRUSTRATED, ""You've had your five minutes of plundering! Now be off with you!"")); WorldTasks.scheduleTimer(i -> { if (i == 1) player.getInterfaceManager().setFadingInterface(115); if (i == 3) exitMinigame(); if (i == 6) { player.getInterfaceManager().setFadingInterface(170); player.unlock(); return false; } return true; }); } @Override public boolean login() { player.getInterfaceManager().sendOverlay(PLUNDER_INTERFACE); for (Integer vb : varbits.keySet()) player.getVars().setVarBit(vb, varbits.get(vb)); updatePlunderInterface(); return false; } @Override public boolean logout() { return false; } @Override public boolean sendDeath() { forceClose(); return true; } @Override public void onTeleported(TeleType type) { forceClose(); } @Override public void forceClose() { player.getInterfaceManager().removeOverlay(); removeController(); } public void exitMinigame() { player.tele(PyramidPlunder.EXIT_TILE); forceClose(); } public void nextRoom() { switch(currentRoom) { case 0 -> player.tele(Tile.of(1927, 4477, 0)); case 1 -> player.tele(Tile.of(1977, 4471, 0)); case 2 -> player.tele(Tile.of(1954, 4477, 0)); case 3 -> player.tele(Tile.of(1927, 4453, 0)); case 4 -> player.tele(Tile.of(1965, 4444, 0)); case 5 -> player.tele(Tile.of(1927, 4424, 0)); case 6 -> player.tele(Tile.of(1943, 4421, 0)); case 7 -> player.tele(Tile.of(1974, 4420, 0)); case 8 -> player.startConversation(new Dialogue() .addSimple(""Opening this door will cause you to leave the pyramid."") .addOptions(""Would you like to exit?"", new Options() { @Override public void create() { option(""Yes"", new Dialogue().addNext(() -> exitMinigame())); option(""No"", new Dialogue()); } })); } if (currentRoom < 8) { correctDoor = PyramidPlunder.DOORS[Utils.random(PyramidPlunder.DOORS.length)]; varbits.clear(); checkedDoors.clear(); for(int i = 2346; i <= 2363; i++) player.getVars().setVarBit(i, 0); for(int i = 2366; i <= 2369; i++) player.getVars().setVarBit(i, 0); player.getVars().setVarBit(3422, 0); currentRoom++; } } public void updateObject(GameObject object, int value) { varbits.put(object.getDefinitions().varpBit, value); player.getVars().setVarBit(object.getDefinitions().varpBit, value); } public void setCurrentRoom(int room) { this.currentRoom = room; } public int getCurrentRoom() { return this.currentRoom; } public int getCorrectDoor() { return correctDoor; } }" "// This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option.add) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see . // // Copyright (C) 2021 Trenton Kress // This file is part of project: Darkan // package com.rs.game.content.minigames.pyramidplunder; @PluginEventHandler public class SimonTempleton extends Conversation { private static final int npcId = 3123; private static final int[] ARTEFACT_IDS = { PPArtefact.IVORY_COMB.getArtefactId(), PPArtefact.POTTERY_SCARAB.getArtefactId(), PPArtefact.POTTERY_STATUETTE.getArtefactId(), PPArtefact.STONE_SEAL.getArtefactId(), PPArtefact.STONE_SCARAB.getArtefactId(), PPArtefact.STONE_STATUETTE.getArtefactId(), PPArtefact.GOLD_SEAL.getArtefactId(), PPArtefact.GOLD_SCARAB.getArtefactId(), PPArtefact.GOLD_STATUETTE.getArtefactId(), PPArtefact.JEWELLED_GOLDEN.getArtefactId(), PPArtefact.JEWELLED_DIAMOND.getArtefactId(), PPArtefact.NOTED_IVORY_COMB.getArtefactId(), PPArtefact.NOTED_POTTERY_SCARAB.getArtefactId(), PPArtefact.NOTED_POTTERY_STATUETTE.getArtefactId(), PPArtefact.NOTED_STONE_SEAL.getArtefactId(), PPArtefact.NOTED_STONE_SCARAB.getArtefactId(), PPArtefact.NOTED_STONE_STATUETTE.getArtefactId(), PPArtefact.NOTED_GOLD_SEAL.getArtefactId(), PPArtefact.NOTED_GOLD_SCARAB.getArtefactId(), PPArtefact.NOTED_GOLD_STATUETTE.getArtefactId(), }; private boolean playerHasArtefacts(Player player) { for (int artefactId : ARTEFACT_IDS) { if (player.getInventory().containsItem(artefactId)) { return true; } } return false; } public static NPCClickHandler SimonTempletonD = new NPCClickHandler(new Object[]{ npcId }, new String[] { ""Talk-to"" }, e -> e.getPlayer().startConversation(new SimonTempleton(e.getPlayer()))); public SimonTempleton(Player player) { super(player); if (player.getInventory().containsItem(6970)) { addNext(new PlayerStatement(HeadE.CHEERFUL, ""I have a pyramid top I can sell you!"")); addNext(new Dialogue(new NPCStatement(npcId, HeadE.CHEERFUL, ""Excellent job mate! Here's your money.""), () -> { int totalMoney = player.getInventory().getAmountOf(6970) * 10000; player.getInventory().deleteItem(6970, Integer.MAX_VALUE); player.getInventory().addCoins(totalMoney); })); return; } if (playerHasArtefacts(player)) { addNext(new Dialogue() .addPlayer(HeadE.CHEERFUL, ""I have some interesting artefacts I'd like you to look at."")) .addNPC(npcId, HeadE.HAPPY_TALKING, ""Bonzer! Let's have a Butcher's mate."") .addNPC(npcId, HeadE.HAPPY_TALKING, ""Do you want to flog the lot of 'em?"") .addOptions((""Would you like to sell all your artefacts?""), option -> { option.add(""Yes, show me the money."", new Dialogue() .addNext(() -> { addPlayer(HeadE.HAPPY_TALKING, ""Yes, show me the money!""); for (int artefactId : ARTEFACT_IDS) { int count = player.getInventory().getNumberOf(artefactId); if (count > 0) { int tradeInValue = PPArtefact.forId(artefactId).getTradeInValue(); player.getInventory().removeItems(new Item(artefactId, count)); player.getInventory().addCoins(count * tradeInValue); player.sendMessage(""Simon buys "" + count + "" artefacts from you for "" + count * tradeInValue + "" coins.""); } } })); option.add(""No, let me think about it."", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""No, let me think about it."") .addNPC(npcId, HeadE.HAPPY_TALKING, ""No probs mate. Just give me the items you want to sell and we can do them one by one."") ); }); } else { addNext(new PlayerStatement(HeadE.CHEERFUL, ""Hi, what do you do here?"")); addNext(new NPCStatement(npcId, HeadE.CHEERFUL, ""I'll buy any special artefacts you find here in the desert. If you happen to find any pyramid tops, I'll buy them for 10,000 gold each."")); addNext(new PlayerStatement(HeadE.CHEERFUL, ""Great, I'll be sure to come back if I find any."")); } } public static ItemOnNPCHandler handleSimonTempletonArtefacts = new ItemOnNPCHandler(new Object[]{ npcId }, e -> { String itemName = e.getItem().getName(); switch (itemName.toUpperCase()) { case ""IVORY COMB"", ""POTTERY SCARAB"", ""POTTERY STATUETTE"", ""STONE SEAL"", ""STONE SCARAB"", ""STONE STATUETTE"", ""GOLD SEAL"", ""GOLD SCARAB"", ""GOLD STATUETTE"", ""JEWELLED GOLDEN STATUETTE"", ""JEWELLED DIAMOND STATUETTE"" -> { Item item = e.getItem(); PPArtefact artifact = PPArtefact.forId(item.getId()); saleD(e.getPlayer(), item, artifact.getTradeInValue(), item.getName().toLowerCase()); } default -> e.getPlayer().startConversation(new Dialogue() .addNPC(npcId, HeadE.SHAKING_HEAD, ""I don't want to buy that mate."") ); } }); public static void saleD(Player player,Item item, int value, String name) { player.startConversation(new Dialogue() .addNPC(npcId, HeadE.HAPPY_TALKING, ""You wanna sell that "" + name + "" mate?"") .addNPC(npcId, HeadE.HAPPY_TALKING, ""I'll give you "" + value + "" for it."") .addOptions((""Would you like to sell all your "" + name + "" artefact?""), option -> { option.add(""Yes, show me the money."", new Dialogue() .addNPC(npcId, HeadE.HAPPY_TALKING, ""Cheers Mate!"") .addNext(() -> { player.getInventory().removeItems(new Item(item.getId(), 1)); player.getInventory().addCoins(value); player.sendMessage(""Simon buys the "" + name + "" artefact from you for "" + value + "" coins."" ); }) ); option.add(""No, I think I'll keep it."", new Dialogue() .addPlayer(HeadE.SHAKING_HEAD, ""No, I think I'll keep it."") ); })); } }" "package com.rs.game.content.minigames.shadesofmortton; @PluginEventHandler public class Shade extends NPC { private final int baseId; private int attack; public Shade(int id, Tile tile) { super(id, tile); baseId = id; setForceAggroDistance(15); setCollisionStrategyType(CollisionStrategyType.FLY); setNoDistanceCheck(true); attack = 0; } public static NPCInstanceHandler toFunc = new NPCInstanceHandler(new Object[] { 1240, 1241, 1243, 1244, 1245, 1246, 1247, 1248, 1249, 1250 }, Shade::new); @Override public void onRespawn() { transformIntoNPC(baseId); } @Override public void sendDeath(Entity source) { super.sendDeath(source); if (source instanceof Player player) ShadesOfMortton.addSanctity(player, 2.0); } @Override public void processNPC() { super.processNPC(); if (isDead() || hasFinished()) return; if (!inCombat(10000) && getRegionId() == 13875 && ShadesOfMortton.getRepairState() > 0) { if (withinArea(3503, 3313, 3509, 3319)) { if (getId() == baseId) { transformIntoNPC(baseId+1); setNextAnimation(new Animation(1288)); } else { resetWalkSteps(); if (attack-- <= 0) { attack = 5; faceTile(Tile.of(3506, 3316, 0)); setNextAnimation(new Animation(1284)); TempleWall wall = ShadesOfMortton.getRandomWall(); if (wall != null) wall.decreaseProgress(); } } return; } if (Utils.random(10) == 0) calcFollow(Tile.of(Tile.of(3506, 3316, 0), 4), false); } if (getId() == baseId && inCombat(10000)) { transformIntoNPC(baseId + 1); setNextAnimation(new Animation(1288)); } else if (getId() != baseId && !inCombat(10000)) { transformIntoNPC(baseId); resetHP(); } } }" "package com.rs.game.content.minigames.shadesofmortton; @PluginEventHandler public class ShadeCatacombs { public static ObjectClickHandler handleEntrance = new ObjectClickHandler(new Object[] { 31294, 34947 }, e -> { if (e.getObjectId() == 31294 && !e.getPlayer().getInventory().containsOneItem(Utils.range(3450, 3469)) && !e.getPlayer().getInventory().containsItem(21511)) { e.getPlayer().sendMessage(""The door seems securely locked.""); return; } e.getPlayer().useStairs(e.getObjectId() == 31294 ? Tile.of(3493, 9725, 0) : Tile.of(3484, 3321, 0)); }); public static ObjectClickHandler handleDoors = new ObjectClickHandler(new Object[] { 4106, 4107, 4108, 4109 }, e -> { switch(e.getObjectId()) { case 4106: if (!e.getPlayer().getInventory().containsOneItem(Utils.range(3450, 3469)) && !e.getPlayer().getInventory().containsItem(21511)) { e.getPlayer().sendMessage(""The door seems securely locked.""); return; } Doors.handleDoor(e.getPlayer(), e.getObject()); break; case 4107: if (!e.getPlayer().getInventory().containsOneItem(Utils.range(3455, 3469)) && !e.getPlayer().getInventory().containsItem(21511)) { e.getPlayer().sendMessage(""The door seems securely locked.""); return; } Doors.handleDoor(e.getPlayer(), e.getObject()); break; case 4108: if (!e.getPlayer().getInventory().containsOneItem(Utils.range(3460, 3469)) && !e.getPlayer().getInventory().containsItem(21511)) { e.getPlayer().sendMessage(""The door seems securely locked.""); return; } Doors.handleDoor(e.getPlayer(), e.getObject()); break; case 4109: if (!e.getPlayer().getInventory().containsOneItem(Utils.range(3465, 3469)) && !e.getPlayer().getInventory().containsItem(21511)) { e.getPlayer().sendMessage(""The door seems securely locked.""); return; } Doors.handleDoor(e.getPlayer(), e.getObject()); break; } }); public static ObjectClickHandler handleChestClick = new ObjectClickHandler(new Object[] { 4111, 4112, 4113, 4114, 4115, 4116, 4117, 4118, 4119, 4120, 4121, 4122, 4123, 4124, 4125, 4126, 4127, 4128, 4129, 4130, 59731 }, e -> e.getPlayer().sendMessage(""The chest is locked."")); public static ItemOnObjectHandler handleChests = new ItemOnObjectHandler(new Object[] { 4111, 4112, 4113, 4114, 4115, 4116, 4117, 4118, 4119, 4120, 4121, 4122, 4123, 4124, 4125, 4126, 4127, 4128, 4129, 4130, 59731 }, null, e -> { ShadeChest chest = ShadeChest.forId(e.getObjectId()); chest.open(e.getPlayer(), e.getObject(), e.getItem().getId()); }); }" "package com.rs.game.content.minigames.shadesofmortton; public enum ShadeChest { BRONZE(Utils.range(4111, 4115), new int[] { 4131, 10607, 10608, 10609, 10610 }, Utils.range(3450, 3454), ""shade_bronze_chest""), STEEL(Utils.range(4116, 4120), Utils.range(10611, 10615), Utils.range(3455, 3459), ""shade_steel_chest""), BLACK(Utils.range(4121, 4125), Utils.range(10616, 10620), Utils.range(3460, 3464), ""shade_black_chest""), SILVER(Utils.range(4126, 4130), Utils.range(10621, 10625), Utils.range(3465, 3469), ""shade_silver_chest""), GOLD(new int[] { 59731 }, new int[] { 59732 }, new int[] { 21511 }, ""shade_gold_chest""); private static final Map OBJECT_MAP = new HashMap<>(); static { for (ShadeChest chest : ShadeChest.values()) for (int id : chest.objectIds) OBJECT_MAP.put(id, chest); } public static ShadeChest forId(int objectId) { return OBJECT_MAP.get(objectId); } private final int[] objectIds; private final Map opened = new HashMap<>(); private final int[] keyIds; private final String dropSet; private ShadeChest(int[] objectIds, int[] openedIds, int[] keyIds, String dropSet) { this.objectIds = objectIds; for (int i = 0;i < objectIds.length;i++) opened.put(objectIds[i], openedIds[i]); this.keyIds = keyIds; this.dropSet = dropSet; } public void open(Player player, GameObject object, int key) { int keyIndex = -1; for (int i = 0;i < keyIds.length;i++) if (keyIds[i] == key) { keyIndex = i; break; } if (keyIndex == -1) { player.sendMessage(""The chest stays remarkably tight.""); return; } player.getInventory().deleteItem(key, 1); player.setNextAnimation(new Animation(536)); player.lock(2); object.setIdTemporary(opened.get(object.getId()), 1); for (Item item : DropSets.getDropSet(dropSet).createDropList().genDrop(player, 1.0 - (keyIndex * 0.05))) player.getInventory().addItemDrop(item); } }" "package com.rs.game.content.minigames.shadesofmortton; @PluginEventHandler public class ShadesOfMortton { private static final Map WALLS = new ConcurrentHashMap<>(); private static int REPAIR_STATE = 0; public static int getRepairState() { return REPAIR_STATE; } public static TempleWall getWall(GameObject obj) { TempleWall wall = WALLS.get(obj.getTile().getTileHash()); if (wall == null) wall = new TempleWall(obj); return wall; } public static TempleWall getRandomWall() { if (WALLS.isEmpty()) return null; return WALLS.get(WALLS.keySet().toArray()[Utils.random(WALLS.size())]); } public static void addWall(TempleWall wall) { WALLS.put(wall.getTile().getTileHash(), wall); World.spawnObject(wall); } public static void deleteWall(TempleWall wall) { WALLS.remove(wall.getTile().getTileHash()); World.removeObject(wall); } @ServerStartupEvent public static void initUpdateTask() { WorldTasks.scheduleLooping(Ticks.fromSeconds(30), Ticks.fromSeconds(30), () -> { updateRepairState(); for (Player player : World.getPlayersInChunkRange(Tile.of(3497, 3298, 0).getChunkId(), 4)) { if (!player.hasStarted() || player.hasFinished()) continue; removeSanctity(player, 1); } GameObject altar = World.getObject(Tile.of(3506, 3316, 0)); if (REPAIR_STATE >= 99) { if (altar != null && altar.getId() == 4092) { World.spawnObject(new GameObject(altar).setId(4091)); World.sendSpotAnim(altar.getTile(), new SpotAnim(1605)); } else if (altar != null && altar.getId() == 4090 && Utils.random(2) == 0) { altar.setId(4091); World.sendSpotAnim(altar.getTile(), new SpotAnim(1605)); } } else if (altar != null && altar.getId() != 4092) { World.removeObject(altar); World.sendSpotAnim(altar.getTile(), new SpotAnim(1605)); } }); } protected static void updateRepairState() { int totalRepair = 0; for (TempleWall wall : WALLS.values()) totalRepair += wall.getRepairPerc(); REPAIR_STATE = (int) ((totalRepair / 1500.0) * 100.0); } protected static void updateVars(Player player) { player.getVars().setVar(343, REPAIR_STATE); player.getVars().setVar(344, player.getI(""shadeResources"", 0)); player.getVars().setVar(345, (int) Math.ceil(player.getTempAttribs().getD(""shadeSanctity""))); } public static void addSanctity(Player player, double amount) { player.getTempAttribs().setD(""shadeSanctity"", Utils.clampD(player.getTempAttribs().getD(""shadeSanctity"") + amount, 0, 100)); updateVars(player); } public static void addResources(Player player, int amount) { player.save(""shadeResources"", Utils.clampI(player.getI(""shadeResources"", 0) + amount, 0, 100)); updateVars(player); } public static void removeSanctity(Player player, double amount) { player.getTempAttribs().setD(""shadeSanctity"", Utils.clampD(player.getTempAttribs().getD(""shadeSanctity"") - amount, 0, 100)); updateVars(player); } public static void removeResources(Player player, int amount) { player.save(""shadeResources"", Utils.clampI(player.getI(""shadeResources"", 0) - amount, 0, 100)); updateVars(player); } public static EnterChunkHandler handleTempleChunks = new EnterChunkHandler(e -> { if (!(e.getEntity() instanceof Player)) return; boolean wasIn = e.getEntity().getTempAttribs().getB(""inShadeTemple""); if (wasIn) { if (!Areas.withinArea(""shades_temple"", e.getChunkId())) { Player player = e.getPlayer(); if (player != null && player.hasStarted()) { player.getInterfaceManager().removeOverlay(); e.getEntity().getTempAttribs().setB(""inShadeTemple"", false); updateVars(player); } } } else if (Areas.withinArea(""shades_temple"", e.getChunkId())) { Player player = e.getPlayer(); if (player != null && player.hasStarted()) { player.getInterfaceManager().sendOverlay(328); e.getEntity().getTempAttribs().setB(""inShadeTemple"", true); updateVars(player); } } }); public static ItemOnObjectHandler handleOilOnAltar = new ItemOnObjectHandler(new Object[] { 4090 }, null, e -> { if (e.getPlayer().getTempAttribs().getD(""shadeSanctity"") < 10) { e.getPlayer().sendMessage(""You need more sanctity to bless an item.""); return; } switch(e.getItem().getId()) { //olive oils case 3422: e.getItem().setId(3430); removeSanctity(e.getPlayer(), 3.6); break; case 3424: e.getItem().setId(3432); removeSanctity(e.getPlayer(), 2.7); break; case 3426: e.getItem().setId(3434); removeSanctity(e.getPlayer(), 1.8); break; case 3428: e.getItem().setId(3436); removeSanctity(e.getPlayer(), 0.9); break; //serums case 3408: e.getItem().setId(3416); removeSanctity(e.getPlayer(), 3.6); break; case 3410: e.getItem().setId(3417); removeSanctity(e.getPlayer(), 2.7); break; case 3412: e.getItem().setId(3418); removeSanctity(e.getPlayer(), 1.8); break; case 3414: e.getItem().setId(3419); removeSanctity(e.getPlayer(), 0.9); break; } updateVars(e.getPlayer()); e.getPlayer().getInventory().refresh(e.getItem().getSlot()); }); public static ObjectClickHandler handleLightAltar = new ObjectClickHandler(new Object[] { 4091 }, e -> { if (e.getPlayer().getTempAttribs().getD(""shadeSanctity"") < 10) { e.getPlayer().sendMessage(""You don't have enough sanctity to light the altar!""); return; } if (!e.getPlayer().getInventory().containsItem(590)) { e.getPlayer().sendMessage(""You need a tinderbox to do that.""); return; } GameObject altar = World.getObject(Tile.of(3506, 3316, 0)); if (altar.getId() == 4091) { altar.setId(4090); e.getPlayer().setNextAnimation(new Animation(3687)); e.getPlayer().getSkills().addXp(Constants.FIREMAKING, 100); } }); public static ObjectClickHandler handleWallRepairs = new ObjectClickHandler(new Object[] { 4068, 4069, 4070, 4071, 4072, 4073, 4074, 4075, 4076, 4077, 4078, 4079, 4080, 4081, 4082, 4083, 4084, 4085, 4086, 4087, 4088, 4089 }, e -> e.getPlayer().getActionManager().setAction(new PlayerAction() { @Override public boolean start(Player player) { player.getActionManager().setActionDelay(4); return true; } @Override public boolean process(Player player) { boolean inside = player.getX() >= 3505 && player.getX() <= 3507 && player.getY() >= 3315 && player.getY() <= 3317; int anim = player.getInventory().containsItem(3678) ? inside ? 8861 : 8890 : inside ? 8865 : 8888; if (getWall(e.getObject()).getRepairPerc() > 50) anim = player.getInventory().containsItem(3678) ? 8950 : 8893; player.setNextAnimation(new Animation(anim)); return true; } @Override public int processWithDelay(Player player) { player.faceTile(e.getObject().getTile()); if (player.getI(""shadeResources"", 0) <= 95 && player.getInventory().containsItem(8837) && player.getInventory().containsItem(3420) && player.getInventory().containsItem(1941, 5)) { player.getInventory().deleteItem(8837, 1); player.getInventory().deleteItem(3420, 1); player.getInventory().deleteItem(1941, 5); addResources(player, 5); } if (player.getI(""shadeResources"", 0) <= 0) { player.sendMessage(""You have run out of resources!""); return -1; } if (Utils.random(player.getInventory().containsItem(3678) ? 2 : 6) != 0) { player.getSkills().addXp(Constants.CRAFTING, Utils.random(5, 9)); return 4; } TempleWall wall = WALLS.get(e.getObject().getTile().getTileHash()); if (wall == null) wall = new TempleWall(e.getObject()); wall.increaseProgress(); removeResources(player, 1); addSanctity(player, 5); player.getSkills().addXp(Constants.CRAFTING, Utils.random(20, 35)); return 4; } @Override public void stop(Player player) { player.setNextAnimation(new Animation(-1)); } })); public static ItemOnItemHandler handleNecromancerKits = new ItemOnItemHandler(new int[] { 21489 }, new int[] { 14497, 14499, 14501 }, e -> { if (e.getPlayer().getSkills().getLevel(Constants.CRAFTING) < 85) { e.getPlayer().sendMessage(""You need a Crafting level of 85 to attach the necromancer kit.""); return; } if (!e.getPlayer().getInventory().containsItem(3470, 10)) { e.getPlayer().sendMessage(""You need 10 fine cloth to attach the necromancer kit.""); return; } switch(e.getUsedWith(21489).getId()) { case 14497: e.getUsedWith(21489).setId(21477); break; case 14499: e.getUsedWith(21489).setId(21478); break; case 14501: e.getUsedWith(21489).setId(21479); break; } e.getPlayer().getInventory().deleteItem(21489, 1); e.getPlayer().getInventory().deleteItem(3470, 10); e.getPlayer().getSkills().addXp(Constants.CRAFTING, 150); e.getPlayer().getInventory().refresh(); }); public static ItemClickHandler handleRemoveNecromancerKits = new ItemClickHandler(new Object[] { 21477, 21478, 21479 }, new String[] { ""Remove-kit"" }, e -> { if (!e.getPlayer().getInventory().hasFreeSlots()) { e.getPlayer().sendMessage(""You don't have enough inventory space!""); return; } e.getPlayer().sendOptionDialogue(""Would you like to remove the kit? You will not recover the fine cloth."", ops -> { ops.add(""Yes"", () -> { switch(e.getItem().getId()) { case 21477: e.getItem().setId(14497); break; case 21478: e.getItem().setId(14499); break; case 21479: e.getItem().setId(14501); break; } e.getPlayer().getInventory().addItemDrop(21489, 1); e.getPlayer().getInventory().refresh(); }); ops.add(""Nevermind""); }); }); public static ItemOnItemHandler handleShadeSkulls = new ItemOnItemHandler(21488, new int[] { 1381, 1383, 1385, 1387, 1393, 1395, 1397, 1399, 1401, 1403, 1405, 1407, 3053, 3054, 6562, 6563, 11736, 11738 }, e -> { if (e.getPlayer().getSkills().getLevel(Constants.CRAFTING) < 85) { e.getPlayer().sendMessage(""You need a Crafting level of 85 to attach the skull.""); return; } switch(e.getUsedWith(21488).getId()) { case 1381: //Skeletal staff of air e.getUsedWith(21488).setId(21490); break; case 1383: //Skeletal staff of water e.getUsedWith(21488).setId(21491); break; case 1385: //Skeletal staff of earth e.getUsedWith(21488).setId(21492); break; case 1387: //Skeletal staff of fire e.getUsedWith(21488).setId(21493); break; case 1393: //Skeletal battlestaff of fire e.getUsedWith(21488).setId(21494); break; case 1395: //Skeletal battlestaff of water e.getUsedWith(21488).setId(21495); break; case 1397: //Skeletal battlestaff of air e.getUsedWith(21488).setId(21496); break; case 1399: //Skeletal battlestaff of earth e.getUsedWith(21488).setId(21497); break; case 1401: //Necromancer's fire staff e.getUsedWith(21488).setId(21498); break; case 1403: //Necromancer's water staff e.getUsedWith(21488).setId(21499); break; case 1405: //Necromancer's air staff e.getUsedWith(21488).setId(21500); break; case 1407: //Necromancer's earth staff e.getUsedWith(21488).setId(21501); break; case 3053: //Skeletal lava battlestaff e.getUsedWith(21488).setId(21502); break; case 3054: //Necromancer's lava staff e.getUsedWith(21488).setId(21503); break; case 6562: //Skeletal mud battlestaff e.getUsedWith(21488).setId(21504); break; case 6563: //Necromancer's mud staff e.getUsedWith(21488).setId(21505); break; case 11736: //Skeletal steam battlestaff e.getUsedWith(21488).setId(21506); break; case 11738: //Necromancer's steam staff e.getUsedWith(21488).setId(21507); break; } e.getPlayer().getInventory().deleteItem(21488, 1); e.getPlayer().getInventory().refresh(); }); public static ItemClickHandler handleRemoveShadeSkulls = new ItemClickHandler(new Object[] { Utils.range(21490, 21507) }, new String[] { ""Remove-skull"" }, e -> { if (!e.getPlayer().getInventory().hasFreeSlots()) { e.getPlayer().sendMessage(""You don't have enough inventory space!""); return; } e.getPlayer().sendOptionDialogue(""Would you like to remove the skull?"", ops -> { ops.add(""Yes"", () -> { switch(e.getItem().getId()) { case 21490: //Skeletal staff of air e.getItem().setId(1381); break; case 21491: //Skeletal staff of water e.getItem().setId(1383); break; case 21492: //Skeletal staff of earth e.getItem().setId(1385); break; case 21493: //Skeletal staff of fire e.getItem().setId(1387); break; case 21494: //Skeletal battlestaff of fire e.getItem().setId(1393); break; case 21495: //Skeletal battlestaff of water e.getItem().setId(1395); break; case 21496: //Skeletal battlestaff of air e.getItem().setId(1397); break; case 21497: //Skeletal battlestaff of earth e.getItem().setId(1399); break; case 21498: //Necromancer's fire staff e.getItem().setId(1401); break; case 21499: //Necromancer's water staff e.getItem().setId(1403); break; case 21500: //Necromancer's air staff e.getItem().setId(1405); break; case 21501: //Necromancer's earth staff e.getItem().setId(1407); break; case 21502: //Skeletal lava battlestaff e.getItem().setId(3053); break; case 21503: //Necromancer's lava staff e.getItem().setId(3054); break; case 21504: //Skeletal mud battlestaff e.getItem().setId(6562); break; case 21505: //Necromancer's mud staff e.getItem().setId(6563); break; case 21506: //Skeletal steam battlestaff e.getItem().setId(11736); break; case 21507: //Necromancer's steam staff e.getItem().setId(11738); break; } e.getPlayer().getInventory().addItemDrop(21488, 1); e.getPlayer().getInventory().refresh(); }); ops.add(""Nevermind""); }); }); }" "package com.rs.game.content.minigames.shadesofmortton; public class TempleWall extends GameObject { private final int baseId; private int buildProgress; public TempleWall(GameObject object) { super(object); baseId = id; buildProgress = 5; ShadesOfMortton.addWall(this); } public void increaseProgress() { buildProgress += 4; update(); } public void decreaseProgress() { buildProgress--; if (buildProgress <= 0) { destroy(); return; } update(); } public void destroy() { ShadesOfMortton.deleteWall(this); } public void update() { setId(baseId + Utils.clampI(buildProgress / 10, 0, 10)); } public int getRepairPerc() { return Utils.clampI(buildProgress, 0, 100); } }" "package com.rs.game.content.minigames.sorcgarden; @PluginEventHandler public class Elemental extends NPC { private boolean beingTeleported = false; private static final Tile[][] tiles = { { Tile.of(2908, 5460, 0), Tile.of(2898, 5460, 0) }, { Tile.of(2900, 5448, 0), Tile.of(2900, 5455, 0) }, { Tile.of(2905, 5449, 0), Tile.of(2899, 5449, 0) }, { Tile.of(2903, 5451, 0), Tile.of(2903, 5455, 0), Tile.of(2905, 5455, 0), Tile.of(2905, 5451, 0) }, { Tile.of(2903, 5457, 0), Tile.of(2917, 5457, 0) }, { Tile.of(2908, 5455, 0), Tile.of(2917, 5455, 0) }, { Tile.of(2922, 5471, 0), Tile.of(2922, 5459, 0) }, { Tile.of(2924, 5463, 0), Tile.of(2928, 5463, 0), Tile.of(2928, 5461, 0), Tile.of(2924, 5461, 0) }, { Tile.of(2924, 5461, 0), Tile.of(2926, 5461, 0), Tile.of(2926, 5458, 0), Tile.of(2924, 5458, 0) }, { Tile.of(2928, 5458, 0), Tile.of(2928, 5460, 0), Tile.of(2934, 5460, 0), Tile.of(2934, 5458, 0) }, { Tile.of(2931, 5477, 0), Tile.of(2931, 5470, 0) }, { Tile.of(2935, 5469, 0), Tile.of(2928, 5469, 0) }, { Tile.of(2925, 5464, 0), Tile.of(2925, 5475, 0) }, { Tile.of(2931, 5477, 0), Tile.of(2931, 5470, 0) }, { Tile.of(2907, 5488, 0), Tile.of(2907, 5482, 0) }, { Tile.of(2907, 5490, 0), Tile.of(2907, 5495, 0) }, { Tile.of(2910, 5493, 0), Tile.of(2910, 5487, 0) }, { Tile.of(2918, 5483, 0), Tile.of(2918, 5485, 0), Tile.of(2915, 5485, 0), Tile.of(2915, 5483, 0), Tile.of(2912, 5483, 0), Tile.of(2912, 5485, 0), Tile.of(2915, 5485, 0), Tile.of(2915, 5483, 0) }, { Tile.of(2921, 5486, 0), Tile.of(2923, 5486, 0), Tile.of(2923, 5490, 0), Tile.of(2923, 5486, 0) }, { Tile.of(2921, 5491, 0), Tile.of(2923, 5491, 0), Tile.of(2923, 5495, 0), Tile.of(2921, 5495, 0) }, { Tile.of(2899, 5466, 0), Tile.of(2899, 5468, 0), Tile.of(2897, 5468, 0), Tile.of(2897, 5466, 0), Tile.of(2897, 5468, 0), Tile.of(2899, 5468, 0) }, { Tile.of(2897, 5470, 0), Tile.of(2891, 5470, 0) }, { Tile.of(2897, 5471, 0), Tile.of(2899, 5471, 0), Tile.of(2899, 5478, 0), Tile.of(2897, 5478, 0) }, { Tile.of(2896, 5483, 0), Tile.of(2900, 5483, 0), Tile.of(2900, 5480, 0), Tile.of(2897, 5480, 0), Tile.of(2896, 5482, 0) }, { Tile.of(2896, 5483, 0), Tile.of(2896, 5481, 0), Tile.of(2891, 5481, 0), Tile.of(2891, 5483, 0) }, { Tile.of(2889, 5485, 0), Tile.of(2900, 5485, 0) } }; /** * * @param id * NPC id * @param tile * Tile * @param spawned * false */ public Elemental(int id, Tile tile, boolean spawned) { super(id, tile, spawned); setCantFollowUnderCombat(true); setCantInteract(true); } @Override public List getPossibleTargets() { return queryNearbyPlayersByTileRangeAsEntityList(7, player -> !player.isDead() && !player.getAppearance().isHidden() && !player.isLocked() && lineOfSightTo(player, false)); } private int steps; @Override public void processNPC() { if (!beingTeleported) for (Entity t : getPossibleTargets()) { if (withinDistance(t.getTile(), 2) && Utils.getAngleTo(t.getX() - getX(), t.getY() - getY()) == getFaceAngle()) { final Player player = (Player) t; setNextAnimation(new Animation(5803)); player.setNextSpotAnim(new SpotAnim(110, 0, 100)); player.stopAll(); player.lock(); player.sendMessage(""You've been spotted by an elemental and teleported out of its garden.""); FadingScreen.fade(player, () -> { player.tele(SorceressGardenController.inAutumnGarden(player.getTile()) ? Tile.of(2913, 5467, 0) : (SorceressGardenController.inSpringGarden(player.getTile()) ? Tile.of(2916, 5473, 0) : (SorceressGardenController.inSummerGarden(player.getTile()) ? Tile.of(2910, 5476, 0) : Tile.of(2906, 5470, 0)))); player.lock(1); beingTeleported = false; }); break; } } int index = getId() - 5533; if (!isForceWalking()) { if (steps >= tiles[index].length) steps = 0; setForceWalk(tiles[index][steps]); if (withinDistance(tiles[index][steps], 0)) steps++; } super.processNPC(); } public static NPCInstanceHandler toFunc = new NPCInstanceHandler(new Object[] { 5533, 5534, 5535, 5536, 5537, 5538, 5539, 5540, 5541, 5542, 5543, 5544, 5545, 5546, 5547, 5548, 5549, 5550, 5551, 5552, 5553, 5554, 5555, 5556, 5557, 5558 }, (npcId, tile) -> new Elemental(npcId, tile, false)); }" "package com.rs.game.content.minigames.sorcgarden; public class SorceressGardenController extends Controller { private static final Tile MIDDLE = Tile.of(2916, 5475, 0); public enum Gate { WINTER(21709, 1, Tile.of(2902, 5470, 0), Tile.of(2903, 5470, 0), 231), SPRING(21753, 25, Tile.of(2921, 5473, 0), Tile.of(2920, 5473, 0), 228), AUTUMN(21731, 45, Tile.of(2913, 5462, 0), Tile.of(2913, 5463, 0), 229), SUMMER(21687, 65, Tile.of(2910, 5481, 0), Tile.of(2910, 5480, 0), 230); private final int objectId; private final int levelReq; private final int musicId; private final Tile inside; private final Tile outside; private static final Map Gates = new HashMap<>(); private Gate(int objectId, int lvlReq, Tile inside, Tile outside, int musicId) { this.objectId = objectId; levelReq = lvlReq; this.inside = inside; this.outside = outside; this.musicId = musicId; } static { for (Gate gate : Gate.values()) Gates.put(gate.getObjectId(), gate); } /** * * @param player * the Player * @param objectId * Object id * @param lvlReq * Level required for entrance * @param toTile * Where the player will be spawned */ public static void handleGates(Player player, int objectId, int lvlReq, Tile toTile, int musicId) { if (lvlReq > player.getSkills().getLevelForXp(Constants.THIEVING)) { player.simpleDialogue(""You need "" + lvlReq + "" thieving level to pick this gate.""); return; } player.useStairs(-1, toTile, 0, 1); player.getMusicsManager().playSongAndUnlock(musicId); } public static Gate forId(int id) { return Gates.get(id); } public int getObjectId() { return objectId; } public int getLeveLReq() { return levelReq; } public Tile getInsideTile() { return inside; } public Tile getOutsideTile() { return outside; } } @Override public void onTeleported(TeleType type) { removeController(); } public static void teleportToSorceressGardenNPC(NPC npc, final Player player) { npc.setNextForceTalk(new ForceTalk(""Senventior Disthinte Molesko!"")); SorceressGardenController.teleportToSocreressGarden(player, false); } public static void teleportToSocreressGarden(final Player player, boolean broomstick) { if (player.getControllerManager().getController() instanceof SorceressGardenController) { player.sendMessage(""You can't teleport to the Sorceress's Garden whilst you're in the Sorceress's Garden!""); return; } boolean teleport; if (!broomstick) Magic.sendNormalTeleportSpell(player, 0, 0, MIDDLE, () -> player.getControllerManager().startController(new SorceressGardenController())); else Magic.sendTeleportSpell(player, 10538, 10537, -1, -1, 0, 0, MIDDLE, 4, true, TeleType.MAGIC, () -> player.getControllerManager().startController(new SorceressGardenController())); } @Override public void start() { } @Override public boolean login() { return false; } @Override public boolean logout() { return false; } @Override public boolean sendDeath() { removeController(); return true; } @Override public boolean processObjectClick1(GameObject object) { if (object.getId() == 21764) { player.lock(); player.setNextAnimation(new Animation(5796)); WorldTasks.schedule(new Task() { @Override public void run() { player.unlock(); Magic.sendNormalTeleportSpell(player, 0, 0, Tile.of(3321, 3141, 0)); } }, 1); return false; } if (object.getId() == 21768) { player.setNextAnimation(new Animation(2280)); player.getInventory().addItem(SqirkFruit.AUTUMM.getFruitId(), 1); player.getSkills().addXp(Constants.FARMING, 50); teleMiddle(); } else if (object.getId() == 21769) { player.setNextAnimation(new Animation(2280)); player.getInventory().addItem(SqirkFruit.WINTER.getFruitId(), 1); player.getSkills().addXp(Constants.FARMING, 30); teleMiddle(); return false; } else if (object.getId() == 21766) { player.setNextAnimation(new Animation(2280)); player.getInventory().addItem(SqirkFruit.SUMMER.getFruitId(), 1); player.getSkills().addXp(Constants.FARMING, 60); teleMiddle(); return false; } else if (object.getId() == 21767) { player.setNextAnimation(new Animation(2280)); player.getInventory().addItem(SqirkFruit.SPRING.getFruitId(), 1); player.getSkills().addXp(Constants.FARMING, 40); teleMiddle(); return false; } else if (object.getDefinitions().getName().toLowerCase().contains(""gate"")) { final Gate gate = Gate.forId(object.getId()); if (gate != null) { Gate.handleGates(player, gate.getObjectId(), gate.getLeveLReq(), inGardens(player.getTile()) ? gate.getOutsideTile() : gate.getInsideTile(), gate.musicId); return false; } } else if (object.getDefinitions().getName().toLowerCase().equals(""herbs"")) { player.setNextAnimation(new Animation(827)); Herbs.values(); List herbs = HerbCleaning.getHerbs(); player.getInventory().addItem(herbs.get(Utils.random(herbs.size())).getHerbId(), 1); player.getInventory().addItem(herbs.get(Utils.random(herbs.size())).getHerbId(), 1); player.getSkills().addXp(Constants.FARMING, SorceressGardenController.inAutumnGarden(player.getTile()) ? 50 : (SorceressGardenController.inSpringGarden(player.getTile()) ? 40 : (SorceressGardenController.inSummerGarden(player.getTile()) ? 60 : 30))); teleMiddle(); return false; } return true; } public void teleMiddle() { player.lock(); player.sendMessage(""An elemental force enamating from the garden teleports you away.""); FadingScreen.fade(player, () -> { player.tele(Tile.of(2913, 5467, 0)); player.lock(3); }); } /** * Checks if the player is in any garden */ public static boolean inGarden(Tile tile) { return ((tile.getX() >= 2880 && tile.getX() <= 2943) && (tile.getY() >= 5440 && tile.getY() <= 5503)); } public static boolean inGardens(Tile tile) { return inWinterGarden(tile) || inAutumnGarden(tile) || inSpringGarden(tile) || inSummerGarden(tile); } /** * Checks if the player is at Winter Garden or not */ public static boolean inWinterGarden(Tile tile) { return ((tile.getX() >= 2886 && tile.getX() <= 2902) && (tile.getY() >= 5464 && tile.getY() <= 5487)); } /** * Checks if the player is at Spring Garden or not */ public static boolean inSummerGarden(Tile tile) { return ((tile.getX() >= 2904 && tile.getX() <= 2927) && (tile.getY() >= 5481 && tile.getY() <= 5497)); } /** * Checks if the player is at Summer Garden or not */ public static boolean inSpringGarden(Tile tile) { return ((tile.getX() >= 2921 && tile.getX() <= 2937) && (tile.getY() >= 5456 && tile.getY() <= 5479)); } /** * Checks if the player is at Autumn Garden or not */ public static boolean inAutumnGarden(Tile tile) { return ((tile.getX() >= 2896 && tile.getX() <= 2919) && (tile.getY() >= 5446 && tile.getY() <= 5462)); } }" "package com.rs.game.content.minigames.sorcgarden; @PluginEventHandler public class SorceressGardenNPCs { public static NPCClickHandler handleNpcs = new NPCClickHandler(new Object[] { 5532, 5563 }, e -> { if (e.getNPCId() == 5563) { e.getPlayer().startConversation(new Dialogue() .addPlayer(HeadE.CHEERFUL, ""Hey kitty!"") .addNPC(5563, HeadE.CAT_SURPRISED, ""Hiss!"")); } else if (e.getNPCId() == 5532) { e.getPlayer().startConversation(new Dialogue() .addPlayer(HeadE.CONFUSED, ""Hey apprentice, do you want to try out your teleport skills again?"") .addNPC(5532, HeadE.CHEERFUL, ""Okay, here goes - and remember, to return just drink from the fountain."") .addNext(() -> SorceressGardenController.teleportToSorceressGardenNPC(e.getNPC(), e.getPlayer()))); } }); }" "package com.rs.game.content.minigames.sorcgarden; @PluginEventHandler public class SqirkFruitSqueeze extends Conversation { public static final int BEER_GLASS = 1919; public static enum SqirkFruit { WINTER(10847, 5, 10851), SPRING(10844, 4, 10848), AUTUMM(10846, 3, 10850), SUMMER(10845, 2, 10849); private final int fruitId; private final int amtRequired; private final int resultId; private SqirkFruit(int fruitId, int amtRequired, int resultId) { this.fruitId = fruitId; this.amtRequired = amtRequired; this.resultId = resultId; } public int getFruitId() { return fruitId; } } public SqirkFruitSqueeze(Player player, SqirkFruit fruit) { super(player); if (!player.getInventory().containsItem(BEER_GLASS, 1)) addItem(BEER_GLASS, ""I should get an empty beer glass to hold the juice before I squeeze the fruit.""); else if (!player.getInventory().containsItem(233, 1)) addItem(BEER_GLASS, ""I should get a pestle and mortal before I squeeze the fruit.""); else if (!player.getInventory().containsItem(fruit.fruitId, fruit.amtRequired)) addPlayer(HeadE.CONFUSED, ""I think I should wait until I have enough fruit to make a full glass.""); else { player.getInventory().deleteItem(fruit.fruitId, fruit.amtRequired); player.getInventory().deleteItem(BEER_GLASS, 1); player.getInventory().addItem(fruit.resultId, 1); player.getSkills().addXp(Constants.HERBLORE, 5); addItem(fruit.resultId, ""You squeeze "" + fruit.amtRequired + "" sq'irks into an empty glass.""); } } public static ItemOnItemHandler handleSquirks = new ItemOnItemHandler(new int[] { 233 }, new int[] { 10844, 10845, 10846, 10847 }, e -> { SqirkFruit fruit = null; for (SqirkFruit f : SqirkFruit.values()) if (f.getFruitId() == e.getUsedWith(233).getId()) fruit = f; e.getPlayer().startConversation(new SqirkFruitSqueeze(e.getPlayer(), fruit)); }); }" "package com.rs.game.content.minigames.soulwars const val LOBBY_OVERLAY = 837 const val INGAME_OVERLAY = 836 const val GAME_ACTIVE_VARC = 632 const val PLAYERS_NEEDED_BLUE_VARC = 633 const val PLAYERS_NEEDED_RED_VARC = 634 const val LOBBY_MINUTES_PASSED_VARC = 635 const val GAME_MINUTES_PASSED_VARC = 636 const val BLUE_TEAM_SIZE_VARC = 637 const val RED_TEAM_SIZE_VARC = 638 const val BLUE_AVATAR_HEALTH_VARC = 639 const val RED_AVATAR_HEALTH_VARC = 640 const val BLUE_AVATAR_LEVEL_VARC = 641 const val RED_AVATAR_LEVEL_VARC = 642 const val BLUE_AVATAR_DEATH_VARC = 643 const val RED_AVATAR_DEATH_VARC = 644 const val MID_CLAIM_VARC = 645 //0-30 0 being blue owned 30 being red owned const val MID_CLAIM_BAR_COMP = 47 const val EAST_CLAIM_VARC = 647 //0-30 0 being blue owned 30 being red owned const val EAST_CLAIM_BAR_COMP = 49 const val WEST_CLAIM_VARC = 649 //0-30 0 being blue owned 30 being red owned const val WEST_CLAIM_BAR_COMP = 50 const val PLAYER_ACTIVITY_BAR_VAR = 1380 //0-1000 const val BONES = 14638 const val SOUL_FRAGMENT = 14646 const val RED_CAPE = 14641 const val BLUE_CAPE = 14642 const val PLAYER_MINIMUM = 4 const val TICKS_BETWEEN_GAMES = 300 val RED_AVATAR_DANGER_CHUNKS = setOf(504215, 502167, 502166, 504214, 504213, 502165) val BLUE_AVATAR_DANGER_CHUNKS = setOf(463248, 461200, 461201, 463249, 463250, 461202) val BLUE_EXIT_AREA = Area(MapUtils.Structure.TILE, 1885, 3166, 3, 7) val RED_EXIT_AREA = Area(MapUtils.Structure.TILE, 1893, 3166, 3, 7) val BLUE_RESPAWN_AREA = Area(MapUtils.Structure.TILE, 1817, 3222, 5, 6) val RED_RESPAWN_AREA = Area(MapUtils.Structure.TILE, 1952, 3236, 5, 6) val EAST_RESPAWN_AREA = Area(MapUtils.Structure.TILE, 1932, 3244, 2, 1) val WEST_RESPAWN_AREA = Area(MapUtils.Structure.TILE, 1841, 3218, 2, 1) val MID_CAP_ZONE = Area(MapUtils.Structure.TILE, 1879, 3224, 15, 15) val MID_CAP_CHUNKS = intArrayOf(481684, 479636, 479635, 481683, 483731, 483732) val EAST_GRAVEYARD_CAP_ZONE = Area(MapUtils.Structure.TILE, 1928, 3240, 10, 10) val EAST_CAP_CHUNKS = intArrayOf(493973, 493974, 496022, 496021) val WEST_GRAVEYARD_CAP_ZONE = Area(MapUtils.Structure.TILE, 1837, 3213, 10, 10) val WEST_CAP_CHUNKS = intArrayOf(471442, 469394, 469393, 471441) val LOBBY_PLAYERS: ObjectSet = ObjectSets.synchronize(ObjectOpenHashSet()) val INGAME_PLAYERS: ObjectSet = ObjectSets.synchronize(ObjectOpenHashSet()) var ACTIVE_GAME: SoulWars? = null var LOBBY_TICKS = 0 @ServerStartupEvent fun mapSoulwars() { onObjectClick(42219) { (player) -> player.useStairs(-1, Tile.of(1886, 3178, 0), 0, 1) } onObjectClick(42220) { (player) -> player.useStairs(-1, Tile.of(3082, 3475, 0), 0, 1) } onObjectClick(42029) { (player) -> when { player.x < 1880 -> { player.passThrough(Tile.of(1880, 3162, 0)) player.controllerManager.forceStop() } player.equipment.get(Equipment.CAPE) != null || player.inventory.items.array().any { it?.definitions?.equipSlot == Equipment.CAPE } -> player.sendMessage(""You cannot enter the lobby with a cape."") else -> { player.passThrough(Tile.of(1879, 3162, 0)) player.controllerManager.startController(SoulWarsLobbyController()) } } } onObjectClick(42031) { (player) -> player.tele(Tile.of(1875, 3162, 0)) player.controllerManager.startController(SoulWarsLobbyController()) } onItemClick(BONES, options = arrayOf(""Bury"")) { (player, item) -> val ctrl = player.controllerManager.getController(SoulWarsGameController::class.java) if (ctrl != null) { if (ctrl.game?.bury(player, ctrl.redTeam) == true) { ctrl.activity += 100 player.inventory.deleteItem(item) player.anim(827) } } } onItemEquip(RED_CAPE, BLUE_CAPE) { e -> e.apply { if (dequip()) { if (!player.controllerManager.isIn(SoulWarsGameController::class.java)) { player.equipment.setNoPluginTrigger(Equipment.CAPE, null) player.equipment.refresh(Equipment.CAPE) player.appearance.generateAppearanceData() } cancel() } } } onChunkEnter { (entity, chunkId) -> (entity as? Player)?.let { player -> fun setBarsVisibility(mid: Boolean, east: Boolean, west: Boolean) { player.packets.apply { setIFHidden(INGAME_OVERLAY, MID_CLAIM_BAR_COMP, !mid) setIFHidden(INGAME_OVERLAY, EAST_CLAIM_BAR_COMP, !east) setIFHidden(INGAME_OVERLAY, WEST_CLAIM_BAR_COMP, !west) } } when { MID_CAP_CHUNKS.contains(chunkId) -> setBarsVisibility(mid = true, east = false, west = false) EAST_CAP_CHUNKS.contains(chunkId) -> setBarsVisibility(mid = false, east = true, west = false) WEST_CAP_CHUNKS.contains(chunkId) -> setBarsVisibility(mid = false, east = false, west = true) } } } WorldTasks.scheduleTimer(0, 0) { _ -> processSoulwars() return@scheduleTimer true } } fun processSoulwars() { ACTIVE_GAME?.tick() LOBBY_TICKS++ if (LOBBY_TICKS % TICKS_BETWEEN_GAMES == 0) { attemptStartGame() LOBBY_TICKS = 0 } if (LOBBY_TICKS % 5 == 0) { for (player in LOBBY_PLAYERS) updateLobbyVars(player) for (player in INGAME_PLAYERS) updateIngameVars(player) } } fun updateLobbyVars(player: Player) { player.packets.apply { sendVarc(GAME_ACTIVE_VARC, if (ACTIVE_GAME == null) 0 else 1) sendVarc(PLAYERS_NEEDED_BLUE_VARC, ACTIVE_GAME?.redTeam?.size ?: (LOBBY_PLAYERS.count() + (10 - PLAYER_MINIMUM))) sendVarc(PLAYERS_NEEDED_RED_VARC, ACTIVE_GAME?.redTeam?.size ?: (LOBBY_PLAYERS.count() + (10 - PLAYER_MINIMUM))) sendVarc(BLUE_TEAM_SIZE_VARC, ACTIVE_GAME?.blueTeam?.size ?: (LOBBY_PLAYERS.count() + (10 - PLAYER_MINIMUM))) sendVarc(RED_TEAM_SIZE_VARC, ACTIVE_GAME?.redTeam?.size ?: (LOBBY_PLAYERS.count() + (10 - PLAYER_MINIMUM))) sendVarc(LOBBY_MINUTES_PASSED_VARC, LOBBY_TICKS / 100) sendVarc(GAME_MINUTES_PASSED_VARC, ACTIVE_GAME?.ticks?.div(100) ?: 0) } } fun updateIngameVars(player: Player) { updateLobbyVars(player) player.packets.apply { sendVarc(RED_AVATAR_HEALTH_VARC, ACTIVE_GAME?.redAvatar?.getHealthVarc() ?: 0) sendVarc(RED_AVATAR_LEVEL_VARC, ACTIVE_GAME?.redAvatar?.level ?: 0) sendVarc(RED_AVATAR_DEATH_VARC, ACTIVE_GAME?.redDeaths ?: 0) sendVarc(BLUE_AVATAR_HEALTH_VARC, ACTIVE_GAME?.blueAvatar?.getHealthVarc() ?: 0) sendVarc(BLUE_AVATAR_LEVEL_VARC, ACTIVE_GAME?.blueAvatar?.level ?: 0) sendVarc(BLUE_AVATAR_DEATH_VARC, ACTIVE_GAME?.blueDeaths ?: 0) sendVarc(MID_CLAIM_VARC, ACTIVE_GAME?.midCapVal ?: 15) sendVarc(EAST_CLAIM_VARC, ACTIVE_GAME?.eastCapVal ?: 15) sendVarc(WEST_CLAIM_VARC, ACTIVE_GAME?.westCapVal ?: 15) } } fun attemptStartGame() { if (ACTIVE_GAME != null) return if (LOBBY_PLAYERS.count() >= PLAYER_MINIMUM) ACTIVE_GAME = SoulWars() } class SoulAvatar(private val redTeam: Boolean, val game: SoulWars, var level: Int = 100) : NPC(if (redTeam) 8596 else 8597, if (redTeam) Tile.of(1965, 3249, 0) else Tile.of(1805, 3208, 0)) { init { capDamage = 700 } override fun sendDeath(source: Entity?) { super.sendDeath(source) level = 100 if (redTeam) game.redDeaths++ else game.blueDeaths++ } override fun handlePreHit(hit: Hit?) { super.handlePreHit(hit) val player = hit?.source as? Player ?: return if (player.skills.getLevelForXp(Skills.SLAYER) < level) hit.damage = 0 } override fun canBeAttackedBy(player: Player): Boolean { return if (redTeam) game.blueTeam.contains(player) else game.redTeam.contains(player) } override fun getPossibleTargets(): MutableList { return if (redTeam) game.blueTeam.filter { RED_AVATAR_DANGER_CHUNKS.contains(it.chunkId) }.toMutableList() else game.redTeam.filter { BLUE_AVATAR_DANGER_CHUNKS.contains(it.chunkId) }.toMutableList() } fun getHealthVarc(): Int { return takeUnless { it.isDead || it.hasFinished() } ?.hitpoints ?.let { ceil(it.toDouble() * 100.0 / 15000.0).toInt() } ?: 0 } } class SoulWars { val redTeam: ObjectSet = ObjectSets.synchronize(ObjectOpenHashSet()) val blueTeam: ObjectSet = ObjectSets.synchronize(ObjectOpenHashSet()) var redAvatar = SoulAvatar(true, this) var blueAvatar = SoulAvatar(false, this) var redDeaths = 0 var blueDeaths = 0 var midCapVal = 15 var eastCapVal = 15 var westCapVal = 15 var ticks = 0 init { val sortedPlayers = LOBBY_PLAYERS.toList().sortedBy { it.skills.combatLevel } var redTotalCombatLevel = 0 var blueTotalCombatLevel = 0 for (player in sortedPlayers) { if (redTotalCombatLevel <= blueTotalCombatLevel) { player.controllerManager.startController(SoulWarsGameController(true, this)) redTeam.add(player) redTotalCombatLevel += player.skills.combatLevel } else { player.controllerManager.startController(SoulWarsGameController(false, this)) blueTeam.add(player) blueTotalCombatLevel += player.skills.combatLevel } LOBBY_PLAYERS.remove(player) } } private fun getObelisk(): GameObject { return World.getObjectWithType(Tile.of(1886, 3231, 0), ObjectType.SCENERY_INTERACT) } private fun getEastBarrier(): GameObject { return World.getObjectWithType(Tile.of(1933, 3243, 0), ObjectType.WALL_STRAIGHT) } private fun getWestBarrier(): GameObject { return World.getObjectWithType(Tile.of(1842, 3220, 0), ObjectType.WALL_STRAIGHT) } fun closestRespawnPoint(redTeam: Boolean, tile: Tile): Tile { val possibleTiles = ArrayList() possibleTiles.add(if (redTeam) RED_RESPAWN_AREA.randomTile else BLUE_RESPAWN_AREA.randomTile) if (if (redTeam) eastCapVal >= 25 else eastCapVal <= 5) possibleTiles.add(EAST_RESPAWN_AREA.randomTile) if (if (redTeam) westCapVal >= 25 else westCapVal <= 5) possibleTiles.add(WEST_RESPAWN_AREA.randomTile) return possibleTiles.minByOrNull { Utils.getDistance(it, tile) }!! } fun bury(player: Player, redTeam: Boolean): Boolean { val avatar = if (redTeam) redAvatar else blueAvatar if (avatar.isDead || avatar.hasFinished()) return false if (avatar.level >= 100) { player.sendMessage(""Your avatar is already a high enough level."") return false } avatar.level++ return true } fun tick() { if (++ticks >= Ticks.fromMinutes(20)) return endGame() if (ticks % 5 == 0) { listOf(EAST_CAP_CHUNKS to EAST_GRAVEYARD_CAP_ZONE, MID_CAP_CHUNKS to MID_CAP_ZONE, WEST_CAP_CHUNKS to WEST_GRAVEYARD_CAP_ZONE).forEach { (chunks, zone) -> val side = World.getPlayersInChunks(*chunks).count { it.isCanPvp && zone.within(it.tile) && redTeam.contains(it) } - World.getPlayersInChunks(*chunks).count { it.isCanPvp && zone.within(it.tile) && blueTeam.contains(it) } when (zone) { EAST_GRAVEYARD_CAP_ZONE -> eastCapVal = Utils.clampI(eastCapVal + side.sign, 0, 30) MID_CAP_ZONE -> midCapVal = Utils.clampI(midCapVal + side.sign, 0, 30) WEST_GRAVEYARD_CAP_ZONE -> westCapVal = Utils.clampI(westCapVal + side.sign, 0, 30) } } updateObjectTeam(getObelisk(), 42012, 42011, 42010, midCapVal)?.let { color -> INGAME_PLAYERS.forEach { it.sendMessage(""The $color team has taken control of the soul obelisk."") } } updateObjectTeam(getEastBarrier(), 42016, 42013, 42019, eastCapVal)?.let { color -> INGAME_PLAYERS.forEach { it.sendMessage(""The $color team has taken control of the eastern graveyard."") } } updateObjectTeam(getWestBarrier(), 42017, 42014, 42020, westCapVal)?.let { color -> INGAME_PLAYERS.forEach { it.sendMessage(""The $color team has taken control of the western graveyard."") } } } } private fun updateObjectTeam(obj: GameObject, redId: Int, blueId: Int, neutralId: Int, capVal: Int): String? { val newId = when { capVal >= 25 -> redId capVal <= 5 -> blueId else -> neutralId } if (obj.id != newId) { obj.setId(newId) return if (newId == redId) ""red"" else ""blue"" } return null } private fun endGame() { val winningTeam = if (redDeaths == blueDeaths) if (blueAvatar.hitpoints == redAvatar.hitpoints) null else if (blueAvatar.hitpoints > redAvatar.hitpoints) blueTeam else redTeam else if (redDeaths > blueDeaths) blueTeam else redTeam arrayOf(blueAvatar, redAvatar).forEach { avatar -> avatar.finish() avatar.cancelRespawnTask() } arrayOf(redTeam to RED_EXIT_AREA, blueTeam to BLUE_EXIT_AREA).forEach { (team, exitArea) -> team.forEach { player -> player.tele(exitArea.randomTile) player.controllerManager.forceStop() val zeal = if (winningTeam == team) 3 else 1 player.soulWarsZeal += zeal player.incrementCount(""Soul Wars Zeal earned"", zeal) when (zeal) { 1 -> player.sendMessage(""Your team lost. You are awarded 1 Zeal. You now have ${Utils.formatNumber(player.soulWarsZeal)} Zeal."") 2 -> player.sendMessage(""The game was a draw. You are awarded 2 Zeal. You now have ${Utils.formatNumber(player.soulWarsZeal)} Zeal."") 3 -> player.sendMessage(""Your team won. You are awarded 3 Zeal. You now have ${Utils.formatNumber(player.soulWarsZeal)} Zeal."") } } } ACTIVE_GAME = null } } class SoulWarsLobbyController : Controller() { override fun start() { player.interfaceManager.sendOverlay(LOBBY_OVERLAY) LOBBY_PLAYERS.add(player) updateLobbyVars(player) } override fun login(): Boolean { player.tele(Tile.of(1880, 3162, 0)) player.controllerManager.forceStop() return true } override fun processTeleport(tele: Teleport): Boolean { return false } override fun logout(): Boolean { LOBBY_PLAYERS.remove(player) player.tele(Tile.of(1880, 3162, 0)) player.tile = Tile.of(1880, 3162, 0) return false } override fun onRemove() { LOBBY_PLAYERS.remove(player) player.interfaceManager.removeOverlay() } } class SoulWarsGameController(val redTeam: Boolean, @Transient val game: SoulWars?) : Controller() { @Transient var activity: Int = 1000 override fun processObjectClick1(obj: GameObject): Boolean { fun checkPositionAndPassThrough(check: Boolean, deltaX: Int, deltaY: Int) { if (check) { player.sendMessage(""Onward! You have no reason to go back inside."") return } player.passThrough(obj.tile.transform(deltaX, deltaY, 0)) player.isCanPvp = true } when (obj.id) { 42021, 42022 -> player.sendOptionDialogue { it.add(""Yes, leave. (You won't receive any rewards for doing so)"") { player.controllerManager.forceStop() } it.add(""Nevermind."") } 42023, 42024 -> giveFoodAndPotions(player) 42015 -> checkPositionAndPassThrough(player.x < obj.x, -1, 0) 42018 -> checkPositionAndPassThrough(player.x >= obj.x, 0, 0) in arrayOf(42016, 42013, 42019) -> checkPositionAndPassThrough(player.y > obj.y, 0, -1) in arrayOf(42017, 42014, 42020) -> checkPositionAndPassThrough(player.y >= obj.y, 0, 0) } return false } override fun processItemOnObject(obj: GameObject, item: Item): Boolean { if (item.id == SOUL_FRAGMENT && (obj.id == 42010 || obj.id == 42011 || obj.id == 42012)) { val isCorrectTeamControl = (redTeam && obj.id == 42012) || (!redTeam && obj.id == 42011) if (!isCorrectTeamControl) { player.sendMessage(""The obelisk is unresponsive as your team is not in control of it."") return false } val avatarLevel = (if (redTeam) game?.blueAvatar else game?.redAvatar)?.level ?: -1 val numToUse = min(item.amount, avatarLevel) if (numToUse <= 0) { player.sendMessage(""Your opponent's avatar cannot be weakened any further."") return false } player.inventory.deleteItem(SOUL_FRAGMENT, numToUse) if (redTeam) game?.blueAvatar?.let { avatar -> avatar.level -= numToUse } else game?.redAvatar?.let { avatar -> avatar.level -= numToUse } } return false } override fun sendDeath(): Boolean { player.lock(8) player.stopAll() WorldTasks.scheduleTimer { loop: Int -> when (loop) { 0 -> player.anim(836) 1 -> player.sendMessage(""Oh dear, you have died."") 4 -> { val killer = player.mostDamageReceivedSourcePlayer if (killer != null) { killer.removeDamage(player) killer.increaseKillCount(player) } val soulFrags = player.inventory.getItemById(SOUL_FRAGMENT) if (soulFrags != null) { World.addGroundItem(soulFrags, Tile.of(player.tile)) player.inventory.deleteItem(soulFrags) } World.addGroundItem(Item(BONES, 1), Tile.of(player.tile)) player.reset() player.tele(game?.closestRespawnPoint(redTeam, player.tile) ?: player.tile) player.isCanPvp = false player.anim(-1) activity = 1000 } 5 -> { player.jingle(90) return@scheduleTimer false } } true } return false } override fun process() { if (player.inCombat()) activity = Utils.clampI(activity + 10, 0, 1000) else activity -= 2 player.vars.setVar(PLAYER_ACTIVITY_BAR_VAR, activity) if (activity <= 0) { player.tele(RED_EXIT_AREA.randomTile) player.controllerManager.forceStop() } } override fun start() { player.interfaceManager.sendOverlay(INGAME_OVERLAY) INGAME_PLAYERS.add(player) updateIngameVars(player) player.tele(if (redTeam) RED_RESPAWN_AREA.randomTile else BLUE_RESPAWN_AREA.randomTile) player.equipment.setNoPluginTrigger(Equipment.CAPE, Item(if (redTeam) RED_CAPE else BLUE_CAPE, 1)) player.equipment.refresh(Equipment.CAPE) player.appearance.generateAppearanceData() player.isCanPvp = false player.startConversation { npc(8528, HeadE.EVIL_LAUGH, ""The time is now! Crush their souls!"") } } override fun canAttack(target: Entity): Boolean { if (target is NPC) return true return if (redTeam) game?.blueTeam?.contains(target) ?: false else game?.redTeam?.contains(target) ?: false } override fun login(): Boolean { clearMinigameValues(player) player.tele(Tile.of(1886, 3172, 0)) player.controllerManager.forceStop() return false } override fun canDepositItem(item: Item?): Boolean { player.sendMessage(""You can't bank items here."") return false } override fun processTeleport(tele: Teleport): Boolean { return false } override fun logout(): Boolean { clearMinigameValues(player) INGAME_PLAYERS.remove(player) if (redTeam) game?.redTeam?.remove(player) else game?.blueTeam?.remove(player) player.tele(Tile.of(1886, 3172, 0)) player.tile = Tile.of(1886, 3172, 0) return false } override fun onRemove() { clearMinigameValues(player) player.inventory.items.array().map { if (it != null && (it.id == BONES || it.id == SOUL_FRAGMENT)) player.inventory.deleteItem(it) } INGAME_PLAYERS.remove(player) player.interfaceManager.removeOverlay() if (redTeam) game?.redTeam?.remove(player) else game?.blueTeam?.remove(player) } } fun clearMinigameValues(player: Player) { player.isCanPvp = false checkAndDeleteFoodAndPotions(player) player.inventory.deleteItem(BONES, 28) player.inventory.deleteItem(SOUL_FRAGMENT, Integer.MAX_VALUE) player.equipment.setNoPluginTrigger(Equipment.CAPE, null) player.equipment.refresh(Equipment.CAPE) player.appearance.generateAppearanceData() player.reset() } fun getQuickchatVar(varId: Int): Int { return when(varId) { 850 -> ACTIVE_GAME?.blueAvatar?.level ?: 0 851 -> ACTIVE_GAME?.redAvatar?.level ?: 0 866 -> ACTIVE_GAME?.blueAvatar?.getHealthVarc() ?: 0 867 -> ACTIVE_GAME?.redAvatar?.getHealthVarc() ?: 0 else -> 0 } }" "package com.rs.game.content.minigames.soulwars enum class Imbue(val itemId: Int, val imbuedItemId: Int, val zealCost: Int) { GOLD_RING(1635, 15009, 2), SAPPHIRE_RING(1637, 15010, 5), EMERALD_RING(1639, 15011, 6), RUBY_RING(1641, 15012, 10), DIAMOND_RING(1643, 15013, 15), DRAGONSTONE_RING(1645, 15014, 20), LUNAR_RING(9104, 15015, 8), RING_OF_CHAROS(6465, 15016, 4), ONYX_RING(6575, 15017, 25), SEERS_RING(6731, 15018, 25), ARCHERS_RING(6733, 15019, 25), WARRIOR_RING(6735, 15020, 25), BERSERKER_RING(6737, 15220, 25) } val COMP_TO_PET = mapOf( 6 to Triple(7975, 14652, 5), 14 to Triple(7976, 14653, 25), 10 to Triple(7977, 14654, 40), 12 to Triple(7978, 14655, 70), 16 to Triple(7979, 14651, 85), 81 to Triple(6570, 21512, 100) ) val COMP_TO_CHARM = mapOf( 27 to Pair(ItemConstants.CHARM_IDS[0], 4), 26 to Pair(ItemConstants.CHARM_IDS[1], 5), 25 to Pair(ItemConstants.CHARM_IDS[2], 12), 24 to Pair(ItemConstants.CHARM_IDS[3], 30) ) val COMP_TO_SKILL = mapOf( 37 to Skills.ATTACK, 35 to Skills.STRENGTH, 34 to Skills.DEFENSE, 33 to Skills.HITPOINTS, 36 to Skills.RANGE, 39 to Skills.MAGIC, 38 to Skills.PRAYER, 32 to Skills.SLAYER ) @ServerStartupEvent fun mapRewardsPlugins() { onNpcClick(8527, 8525, options = arrayOf(""Rewards"")) { (player) -> player.interfaceManager.sendInterface(276) player.vars.setVarBit(5827, player.soulWarsZeal) } onButtonClick(276) { (player, _, componentId, _, _, packet) -> when(packet) { ClientPacket.IF_OP1 -> { when (componentId) { 32, 33, 34, 35, 36, 37, 38, 39 -> COMP_TO_SKILL[componentId]?.let { player.sendMessage(""You will receive ${Utils.formatNumber(getXpPerZeal(player.skills.getLevelForXp(it), it))} ${Skills.SKILL_NAME[it]} experience per Zeal exchanged."") } 24, 25, 26, 27 -> COMP_TO_CHARM[componentId]?.let { (charmId, cost) -> player.sendMessage(""You need $cost Zeal to buy ${getCharmAmount(player, charmId)} ${ItemDefinitions.getDefs(charmId).name.lowercase()}s."") } 6, 14, 10, 12, 16, 81 -> COMP_TO_PET[componentId]?.let { (item, petId, cost) -> player.sendMessage(""You need a ${ItemDefinitions.getDefs(item).name.lowercase()} and $cost Zeal to buy a ${ItemDefinitions.getDefs(petId).name}."") } 8 -> player.sendMessage(""You need 2 Zeal to gamble."") else -> player.sendMessage(""soulrewardcomp: $componentId - $packet"") } return@onButtonClick } ClientPacket.IF_OP2, ClientPacket.IF_OP3, ClientPacket.IF_OP4 -> { when (componentId) { 32, 33, 34, 35, 36, 37, 38, 39 -> COMP_TO_SKILL[componentId]?.let { buyXp(player, it, packet) } 24, 25, 26, 27 -> COMP_TO_CHARM[componentId]?.let { (charmId, cost) -> if (player.soulWarsZeal < cost) { player.sendMessage(""You need $cost Zeal to buy ${getCharmAmount(player, charmId)} ${ItemDefinitions.getDefs(charmId).name.lowercase()}s."") return@onButtonClick } player.soulWarsZeal -= cost player.inventory.addItemDrop(charmId, getCharmAmount(player, charmId)) } 6, 14, 10, 12, 16, 81 -> { COMP_TO_PET[componentId]?.let { (item, petId, cost) -> if (player.soulWarsZeal < cost || !player.inventory.containsItem(item)) { player.sendMessage(""You need a ${ItemDefinitions.getDefs(item).name.lowercase()} and $cost Zeal to buy a ${ItemDefinitions.getDefs(petId).name}."") return@onButtonClick } player.soulWarsZeal -= cost player.inventory.deleteItem(item, 1) player.inventory.addItemDrop(petId, 1) } } 8 -> { if (player.soulWarsZeal < 2) { player.sendMessage(""You need 2 Zeal to gamble."") return@onButtonClick } player.soulWarsZeal -= 2 DropTable.calculateDrops(player, DropSets.getDropSet(""sw_gamble"")).forEach { player.inventory.addItemDrop(it) } if (Utils.random(50) == 0) { player.npcDialogue(8526, HeadE.CHEERFUL, ""Oi, guv! I'm feeling generous so I've conscripted one of my friends to gather charms for you."") player.inventory.addItemDrop(25350, 1) } } else -> player.sendMessage(""soulrewardcomp: $componentId - $packet"") } } else -> {} } player.vars.setVarBit(5827, player.soulWarsZeal) } onItemOnNpc(8527, 8525) { e -> e.apply { if (!Imbue.entries.any { e.item.id == it.itemId || e.item.id == it.imbuedItemId }) { player.startConversation { npc(npc.id, HeadE.CALM_TALK, ""I can't imbue that. Bring me a ring to imbue. I can also un-imbue a ring for you if you bring me an imbued ring."") } return@onItemOnNpc } val imbue = Imbue.entries.first { e.item.id == it.itemId || e.item.id == it.imbuedItemId } if (imbue.imbuedItemId == e.item.id) { player.startConversation { npc(npc.id, HeadE.CALM_TALK, ""Are you sure you'd like me to remove your enchantment? You won't be refunded any Zeal for this process."") options { opExec(""Yes, please restore my ring to its original state."") { item.id = imbue.itemId player.inventory.refresh(item.slot) } op(""Nevermind."") } } } if (imbue.itemId == e.item.id) { player.startConversation { npc(npc.id, HeadE.CALM_TALK, ""I can imbue that ring for you for "" + imbue.zealCost + "" Zeal. Is that alright with you?"") options { opExec(""Yes, please imbue my ring."") { if (player.soulWarsZeal >= imbue.zealCost) { player.soulWarsZeal -= imbue.zealCost item.id = imbue.imbuedItemId player.inventory.refresh(item.slot) } else player.npcDialogue(npc.id, HeadE.CALM_TALK, ""You don't have enough Zeal."") } op(""Nevermind."") } } } } } } fun buyXp(player: Player, skillId: Int, packet: ClientPacket) { val zealCost = when(packet) { ClientPacket.IF_OP3 -> 10 ClientPacket.IF_OP4 -> 100 else -> 1 } if (player.soulWarsZeal < zealCost) { player.sendMessage(""You don't have enough Zeal."") return } player.soulWarsZeal -= zealCost player.skills.addXp(skillId, getXpPerZeal(player.skills.getLevelForXp(skillId), skillId).toDouble() * zealCost) } fun getXpPerZeal(level: Int, skillId: Int): Int { return when(skillId) { Skills.ATTACK, Skills.STRENGTH, Skills.DEFENSE, Skills.HITPOINTS -> floor(min(1.0, (level*level) / 600.0)).toInt() * 525 Skills.RANGE, Skills.MAGIC -> floor(min(1.0, (level*level) / 600.0)).toInt() * 480 Skills.PRAYER -> floor(min(1.0, (level*level) / 600.0)).toInt() * 270 Skills.SLAYER -> floor(min(1.0, (level*level) / 349.0)).toInt() * 45 else -> 1 } } fun getCharmAmount(player: Player, charmId: Int): Int { return when(charmId) { ItemConstants.CHARM_IDS[0] -> linearInterp(3.0, 6.0, 138.0, 52.0, player.skills.combatLevelWithSummoning.toDouble()) ItemConstants.CHARM_IDS[1], ItemConstants.CHARM_IDS[2] -> linearInterp(3.0, 4.0, 138.0, 34.0, player.skills.combatLevelWithSummoning.toDouble()) ItemConstants.CHARM_IDS[3] -> linearInterp(3.0, 5.0, 138.0, 45.0, player.skills.combatLevelWithSummoning.toDouble()) else -> 1 }.toInt() } fun linearInterp(x1: Double, y1: Double, x2: Double, y2: Double, x: Double): Double { if (x1 == x2) throw IllegalArgumentException(""x1 and x2 cannot be the same value"") return ((y2 - y1) / (x2 - x1)) * (x - x1) + y1 }" "package com.rs.game.content.minigames.trawler; @PluginEventHandler public class FishingTrawler { /* TODO: Proper contribution meter based on wiki info TODO: Full contribution meter provides additional 50% fish */ private static FishingTrawler instance; public static final Area NO_WATER_SHIP = MapUtils.getArea(Tile.of(1885, 4824, 0), Tile.of(1892, 4826, 0)); public static final Area WATER_SHIP = MapUtils.getArea(Tile.of(2013, 4824, 0), Tile.of(2020, 4826, 0)); private static final Area CRASHED_SHIP = MapUtils.getArea(Tile.of(1950, 4824, 0), Tile.of(1956, 4826, 0)); public static Area SHORE = MapUtils.getArea(Tile.of(2670, 3221, 0), Tile.of(2675, 3223, 0)); private static final Tile END_TILE = Tile.of(2666, 3160, 0); private static final String[] MONTY_MESSAGES = { ""Let's get this net full with fishies!"", ""Blistering barnacles!"", ""The water is coming in, matey!"", ""Land lubbers!"", ""That's the stuff, fill those holes!"", ""We'll all end up in a watery grave!"", ""My mother could bail better than that!"" }; private static final String[] CRASHED_MONTY_MESSAGES = { ""You'll need all of your strength..."", ""Keep your head above water, shipmate!"", ""Arrrgh! We've sunk!"", ""No fishes for you today!"", ""You'll be joining Davey Jones!"" }; private static final int REPAIRED_LEAK = 2168; public static final int LEAK = 2167; private static final int REWARDS_INTERFACE = 367; private static final int REWARDS_CONTAINER = 18; private static final int REWARDS_KEY = 102; public static final int SWAMP_PASTE = 1941; private final List lobby; private final List game; private final List leaks; private final List montys; private NPC crashedMonty; protected final HashMap activity; private final List activityWarned; private boolean running; private boolean shutdown; protected boolean ripped; protected boolean waterShip; private int time; private int nextCheer; private int nextCry; private boolean secondMessage; private int totalCaught; protected int waterLevel; public FishingTrawler() { lobby = new ArrayList<>(); game = new ArrayList<>(); leaks = new ArrayList<>(); montys = new ArrayList<>(); activity = new HashMap<>(); activityWarned = new ArrayList<>(); time = Ticks.fromMinutes(1); spawnRepairedLeaks(); spawnMontys(); } public void tick() { time--; if(nextCheer > 0) nextCheer--; if(nextCry > 0) nextCry--; if(!secondMessage && Utils.random(10) == 5) { String random = CRASHED_MONTY_MESSAGES[Utils.random(CRASHED_MONTY_MESSAGES.length)]; crashedMonty.setNextForceTalk(new ForceTalk(random)); if(random.contains(""strength"")) { secondMessage = true; WorldTasks.delay(2, () -> { secondMessage = false; crashedMonty.setNextForceTalk(new ForceTalk(""...to make it back to shore."")); }); } } if(!running && lobby.size() == 0) { time = Ticks.fromMinutes(1); return; } if (World.SYSTEM_UPDATE_DELAY > 0 && !shutdown) { shutdown = true; end(); //force those on boat off //stop people getting back on } if (time == 0) { if (running) { end(); return; } start(); } if (running) { tickGame(); return; } if (time == Ticks.fromSeconds(30)) sendLobbyMessage(""Trawler will leave in 30 seconds.""); if (time == Ticks.fromSeconds(20)) sendLobbyMessage(""Trawler will leave in 20 seconds.""); if (time == Ticks.fromSeconds(10)) sendLobbyMessage(""Trawler will leave in 10 seconds.""); } public void tickGame() { if(game.size() == 0) { end(); return; } if(time % 10 == 0 && Utils.random(5) == 2) sendRandomMontyMessage(); if(Utils.random(10) == 1) leak(); if(!ripped && time % 10 == 0 && Utils.random(15) == 2) ripNet(); if(!ripped && time % 10 == 0 && Utils.random(15) == 2) totalCaught++; int waterLevel = this.waterLevel; if(leaks.size() > 0 && time % 5 == 0) waterLevel += leaks.size(); if(leaks.size() > 3 && nextCry == 0) { montys.forEach(npc -> npc.setNextAnimation(new Animation(860))); nextCry = 20; } if(waterLevel >= 30 && this.waterLevel < 30 && !waterShip) switchToWaterShip(); if(waterLevel >= 180) crash(); this.waterLevel = waterLevel; game.forEach(this::refreshInterface); for(Iterator it = game.iterator(); it.hasNext();) { Player player = it.next(); int activity = this.activity.get(player.getUsername()); activity -= 3; if(activity <= 0) { crash(player); it.remove(); continue; } if(activity < 300 && !activityWarned.contains(player.getUsername())) { activityWarned.add(player.getUsername()); player.sendMessage(""Warning: Your activity bar is getting low! Help out in the trawler to refill it!""); } this.activity.put(player.getUsername(), activity); } } public void start() { time = Ticks.fromMinutes(12); totalCaught = 0; ripped = false; waterShip = false; waterLevel = 0; running = true; for(final Player player : lobby) { FadingScreen.fade(player, 2, () -> { player.tele(NO_WATER_SHIP.getRandomTile()); player.getInterfaceManager().sendOverlay(15); player.getInterfaceManager().sendInterface(368); game.forEach(this::refreshInterface); }); player.getControllerManager().startController(new FishingTrawlerGameController()); game.add(player); activity.put(player.getUsername(), 1000); } lobby.clear(); } public void end() { if (!shutdown) sendLobbyMessage(""Trawler will leave in 1 minute.""); else { String message = ""The trawler minigame has been ended as a system update is pending. Please come back after the update.""; sendLobbyMessage(message); sendGameMessage(message); } time = Ticks.fromMinutes(1); running = false; int fishCaught = game.size() == 0 ? 0 : totalCaught / game.size(); for(GameObject leak : leaks) World.removeObject(leak); for (final Player player : game) { player.getInterfaceManager().removeOverlay(); player.tele(END_TILE); player.getControllerManager().forceStop(); player.sendMessage(""Murphy turns the boat towards shore.""); ItemsContainer items = Rewards.generateRewards(player.getSkills().getLevel(Skills.FISHING), fishCaught); for(Item item : items.array()) { if(item == null) continue; if(player.getTrawlerRewards() == null) player.setTrawlerRewards(new ItemsContainer<>(28, true)); player.getTrawlerRewards().add(item); } } game.clear(); leaks.clear(); activity.clear(); activityWarned.clear(); } public void crash() { time = Ticks.fromMinutes(1); running = false; leaks.forEach(World::removeObject); game.forEach(this::crash); leaks.clear(); game.clear(); } public void crash(Player player) { player.getInterfaceManager().removeOverlay(); player.tele(CRASHED_SHIP.getRandomTile()); player.getControllerManager().forceStop(); player.getControllerManager().startController(new FishingTrawlerCrashedController()); Equipment.remove(player, Equipment.WEAPON); Equipment.remove(player, Equipment.SHIELD); player.getAppearance().setBAS(152); } public void leak() { if(leaks.size() == 16) return; Area shipArea = onWaterShip() ? WATER_SHIP : NO_WATER_SHIP; while(true) { int y = Utils.random(2) == 1 ? shipArea.getY() - 1 : shipArea.getY() + 2; int x = shipArea.getX() + Utils.random(8); Tile tile = Tile.of(x, y, 0); int rotation = tile.getY() == shipArea.getY()-1 || tile.getY() == shipArea.getY()-1 ? 3 : 1; GameObject object = World.getSpawnedObject(tile); if(object != null && object.getId() == LEAK) continue; GameObject leak = new GameObject(LEAK, ObjectType.SCENERY_INTERACT, rotation, tile); World.spawnObject(leak); leaks.add(leak); break; } } public void ripNet() { ripped = true; sendGameMessage(""The net has ripped!""); sendMontyMessage(""Arrh! Check that net!""); } public void refreshInterface(Player player) { player.getVars().setVar(1436, activity.get(player.getUsername())); player.getPackets().sendVarc(817, waterLevel); player.getPackets().sendVarc(818, ripped ? 1 :0); player.getPackets().sendVarc(819, totalCaught*2); player.getPackets().sendVarc(820, time / 100); } public boolean onWaterShip() { return waterShip; } public void switchToWaterShip() { waterShip = true; game.forEach(player -> player.tele(player.transform(128, 0))); List tiles = new ArrayList<>(); for(GameObject leak : leaks) { tiles.add(Tile.of(leak.getTile()).transform(128, 0)); World.removeObject(leak); } leaks.clear(); for(Tile tile : tiles) { int rotation = tile.getY() == WATER_SHIP.getY()-1 || tile.getY() == WATER_SHIP.getY()-1 ? 3 : 1; GameObject leak = new GameObject(LEAK, ObjectType.SCENERY_INTERACT, rotation, tile); World.spawnObject(leak); leaks.add(leak); } } public void cheerMonty() { if(nextCheer > 0) return; montys.forEach(npc -> npc.setNextAnimation(new Animation(862))); nextCheer = 20; } public void repairLeak(GameObject object) { leaks.remove(object); World.removeObject(object); int rotation = object.getY() == NO_WATER_SHIP.getY()-1 || object.getY() == WATER_SHIP.getY()-1 ? 3 : 1; World.spawnObject(new GameObject(REPAIRED_LEAK, ObjectType.SCENERY_INTERACT, rotation, Tile.of(object.getTile()))); } public void spawnRepairedLeaks() { for(int x = 0; x < 8; x++) { Tile[] tiles = { Tile.of(NO_WATER_SHIP.getX()+x, NO_WATER_SHIP.getY()-1, 0), Tile.of(NO_WATER_SHIP.getX()+x, NO_WATER_SHIP.getY()+2, 0), Tile.of(WATER_SHIP.getX()+x, WATER_SHIP.getY()-1, 0), Tile.of(WATER_SHIP.getX()+x, WATER_SHIP.getY()+2, 0) }; for(Tile tile : tiles) { int rotation = tile.getY() == NO_WATER_SHIP.getY()-1 || tile.getY() == WATER_SHIP.getY()-1 ? 3 : 1; World.spawnObject(new GameObject(REPAIRED_LEAK, ObjectType.SCENERY_INTERACT, rotation, tile)); } } } public void spawnMontys() { montys.add(new NPC(463, Tile.of(1887, 4825, 0), false)); montys.add(new NPC(463, Tile.of(2015, 4825, 0), false)); crashedMonty = new NPC(463, Tile.of(1947, 4827, 0), false); } public void sendGameMessage(String message) { game.forEach(player -> player.sendMessage(message)); } public void sendLobbyMessage(String message) { lobby.forEach(player -> player.sendMessage(message)); } public void sendMontyMessage(String message) { montys.forEach(monty -> monty.setNextForceTalk(new ForceTalk(message))); } public void sendRandomMontyMessage() { String message; if(ripped) message = ""Arrh! Check that net!""; else if(waterLevel > 20 && waterLevel < 30) message = ""You'll need to start bailing soon!""; else message = MONTY_MESSAGES[Utils.random(MONTY_MESSAGES.length)]; sendMontyMessage(message); } public boolean isRipped() { return ripped; } public void setRipped(boolean ripped) { this.ripped = ripped; } public boolean isWaterShip() { return waterShip; } public int getWaterLevel() { return waterLevel; } public void setWaterLevel(int waterLevel) { this.waterLevel = waterLevel; } public void setTime(int time) { this.time = time; } public void setFishCaught(int fishCaught) { this.totalCaught = fishCaught; } public HashMap getActivity() { return activity; } public void addActivity(Player player, int inc) { if(!activity.containsKey(player.getUsername())) return; int activity = this.activity.get(player.getUsername()); activity += inc; if(activity >= 1000) activity = 1000; this.activity.put(player.getUsername(), activity); } public boolean isTrawlerMonty(NPC npc) { return montys.stream().anyMatch(n -> n.getIndex() == npc.getIndex()); } public void removeLobbyPlayer(Player player) { lobby.remove(player); } public void removeGamePlayer(Player player) { game.remove(player); } public static ObjectClickHandler barrelClick = new ObjectClickHandler(true, new Object[] { 2159, 2160 }, e -> { if(e.getObjectId() == 2160) { e.getPlayer().startConversation(new Dialogue(new SimpleStatement(""I can't get a grip on it!""))); return; } e.getPlayer().startConversation(new Dialogue(new SimpleStatement(""You climb onto the floating barrel and begin to kick your way to the shore.""))); FadingScreen.fade(e.getPlayer(), 2, () -> { e.getPlayer().sendMessage(""You make it to the shore tired and weary.""); e.getPlayer().applyHit(new Hit(20, Hit.HitLook.TRUE_DAMAGE)); e.getPlayer().tele(SHORE.getRandomTile()); e.getPlayer().getControllerManager().forceStop(); e.getPlayer().getAppearance().setBAS(-1); e.getPlayer().endConversation(); }); }); public static ButtonClickHandler rewardsInterfaceHandler = new ButtonClickHandler(367, e -> { Item item = e.getPlayer().getTrawlerRewards().get(e.getSlotId()); if(item == null) return; if(item.getId() != e.getSlotId2()) { Logger.error(FishingTrawler.class, ""rewardsInterfaceHandler"", ""Trawler item ""+item.getId()+"" does not match ""+e.getSlotId2()); return; } int amount = e.getPacket() == ClientPacket.IF_OP1 ? 1 : -1; if(e.getPacket() == ClientPacket.IF_OP3) { e.getPlayer().getTrawlerRewards().set(e.getSlotId(), null); e.getPlayer().getPackets().sendItems(REWARDS_KEY, e.getPlayer().getTrawlerRewards().array()); return; } e.getPlayer().getTrawlerRewards().set(e.getSlotId(), amount == -1 ? null : new Item(item.getId(), item.getAmount() - 1)); e.getPlayer().getPackets().sendItems(REWARDS_KEY, e.getPlayer().getTrawlerRewards().array()); e.getPlayer().getInventory().addItem(item.getId(), amount == -1 ? item.getAmount() : amount); }); public static ObjectClickHandler rewardsNetClick = new ObjectClickHandler(new Object[] { 2166 }, e -> { if(e.getPlayer().getTrawlerRewards() == null || e.getPlayer().getTrawlerRewards().isEmpty()) { e.getPlayer().playerDialogue(HeadE.CONFUSED, ""I better not steal other people's fish!""); return; } IFEvents params = new IFEvents(REWARDS_INTERFACE, REWARDS_CONTAINER, 0, 27) .enableRightClickOptions(0, 1, 2, 3) .enableDrag(); e.getPlayer().getInterfaceManager().sendInterface(REWARDS_INTERFACE); e.getPlayer().getPackets().sendItems(REWARDS_KEY, e.getPlayer().getTrawlerRewards()); e.getPlayer().getPackets().setIFEvents(params); e.getPlayer().getPackets().sendInterSetItemsOptionsScript(REWARDS_INTERFACE, REWARDS_CONTAINER, REWARDS_KEY, 4, 7, ""Withdraw-1"", ""Withdraw-all"", ""Discard-all"", ""Examine""); e.getPlayer().setCloseInterfacesEvent(() -> { for(final Item item : e.getPlayer().getTrawlerRewards().array()) { if(item == null) continue; World.addGroundItem(item, Tile.of(e.getPlayer().getTile()), e.getPlayer(), false, 180); } e.getPlayer().getTrawlerRewards().clear(); }); }); public static ObjectClickHandler gangplankClick = new ObjectClickHandler(true, new Object[]{ 2178, 2179 }, e -> { if (e.getPlayer().getPlane() == 1) { e.getPlayer().lock(); instance.lobby.remove(e.getPlayer()); e.getPlayer().getControllerManager().forceStop(); e.getPlayer().tele(Tile.of(2674, 3170, 0)); WorldTasks.scheduleLooping(new Task() { private boolean tick; private boolean run; @Override public void run() { if(!tick) { run = e.getPlayer().getRun(); e.getPlayer().setRunHidden(false); e.getPlayer().addWalkSteps(Tile.of(2676, 3170, 0), 10, false); tick = true; return; } stop(); e.getPlayer().setRunHidden(run); e.getPlayer().unlock(); } }, 0, 1); } else { if(e.getPlayer().getSkills().getLevelForXp(Skills.FISHING) < 15) { e.getPlayer().startConversation(new Dialogue(new SimpleStatement(""You need at least 15 fishing to be able to go out on the ship with Murphy.""))); return; } e.getPlayer().lock(); Tile toTile = Tile.of(2674, 3170, 0); boolean run = e.getPlayer().getRun(); e.getPlayer().setRunHidden(false); e.getPlayer().addWalkSteps(toTile, 20, false); WorldTasks.scheduleLooping(new Task() { private boolean tick; @Override public void run() { if(!tick) { instance.lobby.add(e.getPlayer()); e.getPlayer().getControllerManager().startController(new FishingTrawlerLobbyController()); e.getPlayer().tele(Tile.of(2673, 3170, 1)); e.getPlayer().setRunHidden(run); e.getPlayer().unlock(); if(!instance.running) { e.getPlayer().startConversation(new Dialogue(new SimpleStatement(""Trawler will leave in 1 minute."", ""If you have a team get them on board now!""))); e.getPlayer().sendMessage(""Trawler will leave in 1 minute.""); } else { e.getPlayer().startConversation(new Dialogue(new SimpleStatement(""There is already someone on a fishing trip!"", ""Try back in a few minutes.""))); e.getPlayer().sendMessage(""There is already someone on a fishing trip!""); e.getPlayer().sendMessage(""Try back in a few minutes.""); } tick = true; return; } e.getPlayer().addWalkSteps(Tile.of(2672, 3170, 1), 10, true); stop(); } }, 2, 0); } }); @ServerStartupEvent public static void init() { instance = new FishingTrawler(); WorldTasks.scheduleLooping(1, 0, () -> instance.tick()); } public static FishingTrawler getInstance() { return instance; } }" "package com.rs.game.content.minigames.trawler; public class FishingTrawlerCrashedController extends Controller { @Override public void start() { } @Override public void onTeleported(TeleType type) { player.getAppearance().setBAS(-1); player.getControllerManager().forceStop(); } @Override public boolean login() { player.getAppearance().setBAS(152); return false; } public boolean logout() { return false; } }" "package com.rs.game.content.minigames.trawler; @PluginEventHandler public class FishingTrawlerGameController extends Controller { @Override public void start() { } @Override public boolean processTeleport(Teleport tele) { sendMessage(); return false; } public void sendMessage() { player.getPackets().sendPlayerMessage(0, 0xFF0000, ""You're too far away from shore to teleport!""); } @Override public boolean login() { FishingTrawler.getInstance().removeGamePlayer(player); player.tele(FishingTrawler.SHORE.getRandomTile()); return true; } @Override public boolean logout() { FishingTrawler.getInstance().removeGamePlayer(player); player.setLocation(FishingTrawler.SHORE.getRandomTile()); return true; } @Override public boolean processObjectClick1(GameObject object) { FishingTrawler trawler = FishingTrawler.getInstance(); if(object.getId() == 255) player.sendMessage(""It seems the winch is jammed - I can't move it.""); else if(object.getId() == 2174 || object.getId() == 2175) { Tile tile; if(object.getId() == 2174) tile = object.getY() == 4826 ? Tile.of(1883, 4826, 1) : Tile.of(1894, 4824, 1); else tile = object.getY() == 4826 ? Tile.of(1885, 4826, 0) : Tile.of(1892, 4824, 0); if(trawler.isWaterShip()) tile = tile.transform(128, 0); player.useLadder(tile); return true; } else if(object.getId() == 2164 || object.getId() == 2165) { player.setNextAnimation(new Animation(537)); if(!trawler.isRipped()) { player.sendMessage(""The net is not damaged.""); return true; } if(!player.getInventory().containsItem(954)) { player.sendMessage(""You'll need some rope to fix it.""); return true; } player.getInventory().deleteItem(954, 1); trawler.setRipped(false); trawler.addActivity(player, 200); } return false; } public static ObjectClickHandler fillLeak = new ObjectClickHandler(false, new Object[] { FishingTrawler.LEAK }, e -> { e.getPlayer().resetWalkSteps(); MapUtils.Area area = FishingTrawler.getInstance().isWaterShip() ? FishingTrawler.WATER_SHIP : FishingTrawler.NO_WATER_SHIP; Tile tile; if(e.getObject().getY() == area.getY()-1) tile = e.getObject().getTile().transform(0, 1); else tile = e.getObject().getTile().transform(0, 0); e.getPlayer().addWalkSteps(tile, 25, false); e.getPlayer().setRouteEvent(new RouteEvent(tile, () -> { e.getPlayer().lock(1); e.getPlayer().setNextFaceTile(Tile.of(e.getObject().getTile())); if(!e.getPlayer().getInventory().containsItem(FishingTrawler.SWAMP_PASTE)) { e.getPlayer().sendMessage(""You'll need some swamp paste to fill that.""); return; } e.getPlayer().setNextAnimation(new Animation(827)); FishingTrawler.getInstance().addActivity(e.getPlayer(), 50); FishingTrawler.getInstance().cheerMonty(); FishingTrawler.getInstance().repairLeak(e.getObject()); e.getPlayer().getInventory().deleteItem(new Item(FishingTrawler.SWAMP_PASTE, 1)); })); }); public static ItemClickHandler emptyBailingBucketClick = new ItemClickHandler(new Object[] { 585 }, new String[] { ""Empty"" }, e -> { Controller controller = e.getPlayer().getControllerManager().getController(); String message; if(controller instanceof FishingTrawlerGameController) message = ""You tip the water over the side.""; else message = ""You tip the water out of the bucket.""; e.getPlayer().sendMessage(message); e.getPlayer().getInventory().getItems().set(e.getItem().getSlot(), new Item(583, 1)); e.getPlayer().getInventory().refresh(e.getItem().getSlot()); FishingTrawler.getInstance().addActivity(e.getPlayer(), 20); e.getPlayer().setNextAnimation(new Animation(827)); e.getPlayer().lock(1); }); public static ItemClickHandler bailingBucketClick = new ItemClickHandler(new Object[] { 583 }, new String[] { ""Bail-with"" }, e -> { Controller controller = e.getPlayer().getControllerManager().getController(); if(!(controller instanceof FishingTrawlerGameController)) { e.getPlayer().sendMessage(""I don't really need to bail yet.""); return; } FishingTrawler trawler = FishingTrawler.getInstance(); if(!trawler.isWaterShip()) { e.getPlayer().sendMessage(""I don't really need to bail yet.""); return; } trawler.setWaterLevel(trawler.getWaterLevel() - 1); if(trawler.getWaterLevel() < 0) trawler.setWaterLevel(0); int activity = trawler.getActivity().get(e.getPlayer().getUsername()) + 100; if(activity > 1000) activity = 1000; trawler.getActivity().put(e.getPlayer().getUsername(), activity); e.getPlayer().sendMessage(""You fill the bucket with water.""); e.getPlayer().getInventory().getItems().set(e.getItem().getSlot(), new Item(585, 1)); e.getPlayer().getInventory().refresh(e.getItem().getSlot()); FishingTrawler.getInstance().addActivity(e.getPlayer(), 20); e.getPlayer().setNextAnimation(new Animation(832)); e.getPlayer().lock(1); }); }" "package com.rs.game.content.minigames.trawler; public class FishingTrawlerLobbyController extends Controller { @Override public void start() { } public boolean login() { leaveLobby(); player.tele(Tile.of(2676, 3170, 0)); return true; } @Override public boolean logout() { leaveLobby(); player.setLocation(Tile.of(2676, 3170, 0)); return true; } @Override public void onTeleported(TeleType type) { leaveLobby(); } public void leaveLobby() { FishingTrawler.getInstance().removeLobbyPlayer(player); } }" "package com.rs.game.content.minigames.trawler; public class MontyConversation extends Conversation { public MontyConversation(Player player) { super(player); buildDialogue(); //TODO - ""Go diving"" option or something } public void buildDialogue() { addNext(new PlayerStatement(HeadE.CHEERFUL, ""Hello again, Murphy."")); addNext(new NPCStatement(463, HeadE.CHEERFUL, ""Good day to you land lover. Fancy hitting the high seas again?"")); addNext(""montyS"", new OptionStatement(""Select an Option"", ""No thanks, I still feel ill from last time."", ""We keep sinking! Can you give me some advice?"", ""Yes, let's do it!"")); getStage(""montyS"") .addNext(new PlayerStatement(HeadE.CHEERFUL, ""No thanks, I still feel ill from last time."")) .addNext(new NPCStatement(463, HeadE.CALM, ""Hah! ...Softy."")); getStage(""montyS"") .addNext(new PlayerStatement(HeadE.CALM, ""We keep sinking! Can you give me some advice?"")) .addNext(new NPCStatement(463, HeadE.CALM, ""Aye aye matey! We'll soon get you ship shape!"")) .addNext(new NPCStatement(463, HeadE.CALM, ""You need a Fishing level of 15 or above to catch any fish on the trawler."")) .addNext(new NPCStatement(463, HeadE.CALM, ""On occasions the net rips, so you'll need some rope to repair it."")) .addNext(new NPCStatement(463, HeadE.CALM, ""Repairing the net is difficult in the harsh conditions so you'll find it easier with a higher Crafting level."")) .addNext(new PlayerStatement(HeadE.CALM, ""Ah yes, got it."")) .addNext(new NPCStatement(463, HeadE.CALM, ""There's also a slight problem with leaks."")) .addNext(new PlayerStatement(HeadE.AMAZED, ""Don't say!"")) .addNext(new NPCStatement(463, HeadE.CALM, ""Nothing some swamp paste won't fix..."")) .addNext(new PlayerStatement(HeadE.CHEERFUL, ""Right so I need lots of swamp paste and plenty of rope. Thanks Murphy!"")) .addNext(new NPCStatement(463, HeadE.CALM, ""If all else fails use a bailing bucket!"")); getStage(""montyS"") .addNext(new PlayerStatement(HeadE.CHEERFUL, ""Yes, let's do it!"")) .addNext(new NPCStatement(463, HeadE.CALM, ""Aye aye! Meet me on board the trawler. I just need to get a few things together."")); create(); } }" "package com.rs.game.content.minigames.trawler; public class MontyGameConversation extends Conversation { public MontyGameConversation(Player player) { super(player); buildDialogue(); } public void buildDialogue() { FishingTrawler trawler = FishingTrawler.getInstance(); addNext(new NPCStatement(463, HeadE.CALM, ""Woooahh sailor!"")); addOptions(""Select an Option"", new Options() { @Override public void create() { option(""I've had enough, take me back."", new Dialogue() .addNext(new PlayerStatement(HeadE.CALM, ""I've had enough, take me back."")) .addNext(new NPCStatement(463, HeadE.CALM, ""Hah! The soft landlubbers have lost their sea legs, eh?"")) .addNext(new PlayerStatement(HeadE.CALM, ""Something like that."")) .addNext(new NPCStatement(463, HeadE.CALM, ""We're too far out now, it'd be dangerous."")) .addOptions(""Select an Option"", new Options() { @Override public void create() { option(""I insist Murphy, take me back."", new Dialogue() .addNext(new PlayerStatement(HeadE.CALM, ""I insist Murphy, take me back."")) .addNext(new NPCStatement(463, HeadE.CALM, ""Ok, ok, I'll try, but don't say I didn't warn you.."")) .addNext(new SimpleStatement(""Murphy attempts to sharply turn the large ship."")) .addNext(new NPCStatement(463, HeadE.CALM, ""Save yourself! We're going down!"")) .addNext(() -> trawler.crash(player)) ); option(""Okay then Murphy, just keep us afloat."", new Dialogue() .addNext(new PlayerStatement(HeadE.CALM, ""Okay then Murphy, just keep us afloat."")) .addNext(new NPCStatement(463, HeadE.CALM, ""That's the attitude sailor... Aaaaargh!"")) ); } }) ); String[] messages = Utils.random(2) == 1 ? new String[] { ""It's a fierce sea today, traveller!"", ""You'd best hold on tight."" } : new String[] { ""Get those fishies!"" }; option(""How are you doing, Murphy?"", new Dialogue() .addNext(new PlayerStatement(HeadE.CALM, ""How are you doing, Murphy?"")) .addNext(new NPCStatement(463, HeadE.CALM, messages)) ); } }); } }" "package com.rs.game.content.minigames.trawler; public class Rewards { private enum Rate { LOWEST(11, 1), LOW(28, 10), MEDIUM(63, 43), HIGH(150, 201); private final int low, high; Rate(int low, int high) { this.low = low; this.high = high; } } public static ItemsContainer generateRewards(int level, int amount) { ItemsContainer rewards = new ItemsContainer<>(20, true); DropTable[] tables = new DropTable[Rate.values().length]; for (int i = 0;i < Rate.values().length;i++) { double perc = (double)level / 99.0D; int chance = Utils.clampI((int)((double)Rate.values()[i].low + ((double)Rate.values()[i].high - (double)Rate.values()[i].low) * perc), 0, 256); tables[i] = new DropTable(chance, 256, getFishIdAtTier(level, i), 1); } DropList list = new DropList(tables); for (int i = 0;i < amount;i++) rewards.addAll(list.genDrop()); return rewards; } private static final int[] FISH_ORDER = { Fish.SHRIMP.getFishId(), Fish.SHRIMP.getFishId(), Fish.SARDINES.getFishId(), Fish.ANCHOVIES.getFishId(), Fish.OYSTER.getFishId(), Fish.TUNA.getFishId(), Fish.LOBSTER.getFishId(), Fish.SWORDFISH.getFishId(), Fish.SHARK.getFishId(), 395, 389 }; public static int getFishIdAtTier(int level, int tier) { if (level >= 81) return FISH_ORDER[7 + tier]; if (level >= 79) return FISH_ORDER[6 + tier]; if (level >= 76) return FISH_ORDER[5 + tier]; if (level >= 50) return FISH_ORDER[4 + tier]; if (level >= 40) return FISH_ORDER[3 + tier]; if (level >= 35) return FISH_ORDER[2 + tier]; if (level >= 16) return FISH_ORDER[1 + tier]; return FISH_ORDER[tier]; } }" "package com.rs.game.content.minigames.treasuretrails; public class ClueNPC extends OwnedNPC { public ClueNPC(Player target, int id, Tile tile) { super(target, id, tile, false); } @Override public void onDespawnEarly() { getOwner().getTreasureTrailsManager().setPhase(0); } @Override public void drop() { getOwner().getTreasureTrailsManager().setPhase(2); } }" "package com.rs.game.content.minigames.treasuretrails; @PluginEventHandler public class TreasureTrailsManager { //VARC 1323 = bitpacked location for arrow pointy clue interface 996 private static final int EASY = 0, MEDIUM = 1, HARD = 2, ELITE = 3; public static final int SOURCE_DIG = 0, SOURCE_EMOTE = 1, SOURCE_NPC = 2, SOURCE_PUZZLENPC = 3, SOURCE_OBJECT = 4; public static final int[] SCROLL_BOXES = { 19005, 19065, 18937, 19041 }; public static final int[] CLUE_SCROLLS = { 2677, 2801, 2722, 19043 }; public static final int[] CASKETS = { 2714, 2802, 2724, 19039 }; public static final int[] PUZZLES = { 2798, 3565, 3576, 19042 }; public static final int[] BASE_PIECES = { 2749, 3619, 3643, 18841 }; public static final String[] LEVEL = { ""Easy"", ""Medium"", ""Hard"", ""Elite"" }; private static final int PUZZLE_SIZE = 25; private Clue currentClue; private transient int cluePhase; private transient Player player; private transient List pieces; public static ButtonClickHandler handlePuzzleButtons = new ButtonClickHandler(363, e -> { if (e.getComponentId() == 4) e.getPlayer().getTreasureTrailsManager().movePuzzlePeice(e.getSlotId()); }); public static ButtonClickHandler handleSextantButtons = new ButtonClickHandler(365, e -> e.getPlayer().getTreasureTrailsManager().handleSextant(e.getComponentId())); public void setPlayer(Player player) { this.player = player; } public int getPhase() { return cluePhase; } public void setPhase(int phase) { cluePhase = phase; } private int generateClueSize(int level) { return switch (level) { case EASY -> 1 + Utils.random(3); case MEDIUM -> 2 + Utils.random(3); case HARD -> 3 + Utils.random(4); case ELITE -> 3 + Utils.random(3); default -> 1; }; } private ClueDetails generateClueDetails(int dificulty) { while (true) { ClueDetails detail = ClueDetails.values()[Utils.random(ClueDetails.values().length)]; if (detail.level > dificulty) continue; /* * int difference = dificulty - detail.level; if (difference == 0) * return detail; else if (difference == 1 && Utils.random(2) == 0) * return detail; else if (difference == 2 && Utils.random(4) == 0) * return detail; else if (difference == 3 && Utils.random(8) == 0) * return detail; */ return detail; // else we get same clues all time o.o // continue; } } public static int getScrollLevel(int id) { for (int i = 0; i < CLUE_SCROLLS.length; i++) if (CLUE_SCROLLS[i] == id) return i; return -1; } private int getScrollboxLevel(int id) { for (int i = 0; i < SCROLL_BOXES.length; i++) if (SCROLL_BOXES[i] == id) return i; return -1; } private int getCasketLevel(int id) { for (int i = 0; i < CASKETS.length; i++) if (CASKETS[i] == id) return i; return -1; } public void setNextClue(int source, boolean meerkat) { int lastPhase = (currentClue.details.type == COORDINATE && currentClue.dificulty >= HARD) ? 2 : (currentClue.details.type == EMOTE ? 5 : 0); if (cluePhase == lastPhase) { cluePhase = 0; pieces = null; if (source == SOURCE_DIG) { if (!currentClue.isLast()) { currentClue.count--; currentClue.details = generateClueDetails(currentClue.dificulty); player.sendMessage(""You've found another clue!""); player.startConversation(new Dialogue().addItem(CLUE_SCROLLS[currentClue.dificulty], ""You've found another clue!"")); } else { player.getInventory().deleteItem(CLUE_SCROLLS[currentClue.dificulty], 1); player.getInventory().addItemDrop(CASKETS[currentClue.dificulty], 1); player.sendMessage(""Well done! You've completed the Treasure Trail.""); currentClue = null; } } else if (source == SOURCE_NPC || source == SOURCE_PUZZLENPC) { if (!currentClue.isLast()) { currentClue.count--; int id = currentClue.details.ids[0]; currentClue.details = generateClueDetails(currentClue.dificulty); if (id == 2812) player.startConversation(new Dialogue().addItem(CLUE_SCROLLS[currentClue.dificulty], ""Grrrrow!"")); else player.startConversation(new Dialogue().addItem(CLUE_SCROLLS[currentClue.dificulty], NPCDefinitions.getDefs(id).getName() + "" has given you another clue scroll."")); } else { player.getInventory().deleteItem(CLUE_SCROLLS[currentClue.dificulty], 1); player.getInventory().addItemDrop(CASKETS[currentClue.dificulty], 1); player.sendMessage(""Well done! You've completed the Treasure Trail.""); currentClue = null; } } else if (source == SOURCE_EMOTE) { if (!currentClue.isLast()) { currentClue.count--; currentClue.details = generateClueDetails(currentClue.dificulty); player.sendMessage(""You've been given another clue!""); player.startConversation(new Dialogue().addItem(CLUE_SCROLLS[currentClue.dificulty], ""You've been given another clue!"")); } else { player.getInventory().deleteItem(CLUE_SCROLLS[currentClue.dificulty], 1); player.getInventory().addItemDrop(CASKETS[currentClue.dificulty], 1); player.sendMessage(""Well done! You've completed the Treasure Trail.""); currentClue = null; } } else if (source == SOURCE_OBJECT) { if (!currentClue.isLast()) { currentClue.count--; currentClue.details = generateClueDetails(currentClue.dificulty); player.sendMessage(""You've found another clue!""); player.startConversation(new Dialogue().addItem(CLUE_SCROLLS[currentClue.dificulty], ""You've found another clue!"")); } else { player.getInventory().deleteItem(CLUE_SCROLLS[currentClue.dificulty], 1); player.getInventory().addItemDrop(CASKETS[currentClue.dificulty], 1); player.sendMessage(""Well done! You've completed the Treasure Trail.""); currentClue = null; } } else throw new RuntimeException(""UNKNOWN_SOURCE:"" + source); } else if (cluePhase == 0 && (currentClue.details.type == COORDINATE || currentClue.details.type == EMOTE) && currentClue.dificulty >= HARD) { // spawn combat npc if (!meerkat) { boolean inWilderness = player.getControllerManager().getController() instanceof WildernessController; boolean isCoordinateClue = currentClue.details.type == COORDINATE; Tile tile = player.getNearestTeleTile(1); if (tile == null) tile = Tile.of(player.getTile()); final ClueNPC npc = new ClueNPC(player, inWilderness ? isCoordinateClue ? 1007 : 5144 : isCoordinateClue ? 1264 : 5145, tile); npc.setNextSpotAnim(new SpotAnim(74)); WorldTasks.schedule(() -> { npc.setTarget(player); npc.setNextForceTalk(new ForceTalk(npc.getId() == 1007 ? ""For Zamorak!"" : npc.getId() == 1264 ? ""For Saradomin!"" : ""I expect you to die!"")); }); } cluePhase = meerkat ? 2 : 1; } else if (((cluePhase == 0 && currentClue.dificulty < HARD) || (cluePhase == 2 && currentClue.dificulty >= HARD)) && currentClue.details.type == EMOTE) { final NPC npc = new Ugi(player, 5141, player.getNearestTeleTile(1)); npc.setNextSpotAnim(new SpotAnim(74)); WorldTasks.schedule(() -> npc.faceEntity(player)); cluePhase = ((Emote[]) currentClue.details.parameters[0]).length == 1 ? 4 : 3; } else if (cluePhase == 3) cluePhase = 4; // for emotes } public static boolean isScroll(int id) { return getScrollLevel(id) != -1; } public void resetCurrentClue() { currentClue = null; } public boolean hasClueScrollItem() { for (int scroll : CLUE_SCROLLS) if (player.containsItem(scroll)) return true; return false; } public void setCurrentClue(int level) { currentClue = new Clue(generateClueDetails(level), generateClueSize(level), level); } public void SelectAClue(int level, int index) { ClueDetails detail = ClueDetails.values()[index]; currentClue = new Clue(detail, generateClueSize(level), level); } public boolean useItem(Item item, int slot) { int level = getScrollboxLevel(item.getId()); if (level != -1) { if (hasClueScrollItem()) { player.sendMessage(""You should finish the clue you already have first.""); return true; } resetCurrentClue(); player.getInventory().deleteItem(SCROLL_BOXES[level], 1); player.getInventory().addItem(CLUE_SCROLLS[level], 1); player.startConversation(new Dialogue().addItem(CLUE_SCROLLS[level], ""You've found another clue!"")); return true; } level = getCasketLevel(item.getId()); if (level != -1) { player.getInventory().deleteItem(item.getId(), 1); openReward(level); return true; } level = getScrollLevel(item.getId()); if (level != -1) { if (currentClue == null) setCurrentClue(level); if (currentClue.details.type == SIMPLE || currentClue.details.type == ANAGRAM) { player.getInterfaceManager().sendInterface(345); int offset = (8 - currentClue.details.parameters.length) / 2; for (int i = 0; i < 8; i++) player.getPackets().setIFText(345, i + 1, """"); for (int i = currentClue.details.type == EMOTE ? 2 : 0; i < currentClue.details.parameters.length; i++) player.getPackets().setIFText(345, i + 1 + offset, """" + (String) currentClue.details.parameters[i] + """"); } else if (currentClue.details.type == EMOTE) { player.getInterfaceManager().sendInterface(345); for (int i = 0; i < 8; i++) player.getPackets().setIFText(345, i + 1, """"); for (int i = 2; i < currentClue.details.parameters.length; i++) player.getPackets().setIFText(345, i, """" + (String) currentClue.details.parameters[i] + """"); } else if (currentClue.details.type == MAP) player.getInterfaceManager().sendInterface((int) currentClue.details.parameters[0]); else if (currentClue.details.type == COORDINATE) { player.getInterfaceManager().sendInterface(345); for (int i = 0; i < 8; i++) player.getPackets().setIFText(345, i + 1, """"); player.getPackets().setIFText(345, 4, ((Integer) currentClue.details.parameters[0] <= 9 ? ""0"" : """") + currentClue.details.parameters[0] + "" degrees, "" + ((Integer) currentClue.details.parameters[1] <= 9 ? ""0"" : """") + currentClue.details.parameters[1] + "" minutes "" + ((Integer) currentClue.details.parameters[2] == NORTH ? ""north"" : ""south"")); player.getPackets().setIFText(345, 5, ((Integer) currentClue.details.parameters[3] <= 9 ? ""0"" : """") + currentClue.details.parameters[3] + "" degrees, "" + ((Integer) currentClue.details.parameters[4] <= 9 ? ""0"" : """") + currentClue.details.parameters[4] + "" minutes "" + ((Integer) currentClue.details.parameters[5] == WEST ? ""west"" : ""east"")); } return true; } return false; } private boolean hasCurrentClue() { if (!player.getInventory().containsOneItem(CLUE_SCROLLS[currentClue.dificulty])) return false; return true; } public void useEmote(Emote emote) { if ((currentClue == null) || (currentClue.details.type != EMOTE)) return; if (!hasCurrentClue()) return; else if (!player.withinDistance(Tile.of(currentClue.details.getId()), 8)) { player.sendMessage(""Hint: "" + Tile.of(currentClue.details.getId()).toString()); return; } else if (emote != ((Emote[]) currentClue.details.parameters[0])[cluePhase == 3 ? 1 : 0]) return; Item[] requiredItems = (Item[]) currentClue.details.parameters[1]; if (requiredItems.length > 0) for (Item item : requiredItems) { int slot = item.getId() == 20922 ? Equipment.RING : item.getDefinitions().getEquipSlot(); Item requestedItem = player.getEquipment().getItem(slot); if (requestedItem == null) return; if (slot == Equipment.RING && item.getId() == 20922) { if (!player.getEquipment().containsOneItem(2552, 2554, 2556, 2558, 2560, 2562, 2564, 2566)) return; } else if (requestedItem.getId() != item.getId()) return; } setNextClue(SOURCE_EMOTE, false); } public boolean useDig(boolean meerkat) { if (currentClue == null) return false; if ((currentClue.details.type == SIMPLE || currentClue.details.type == MAP) && currentClue.details.idType == TILE) { if (!hasCurrentClue()) return false; Tile tile = Tile.of(currentClue.details.getId()); if (!player.withinDistance(tile, currentClue.details.type == MAP ? meerkat ? 12 : 6 : meerkat ? 32 : 16)) return false; setNextClue(SOURCE_DIG, meerkat); return true; } if (currentClue.details.type == COORDINATE /*&& hasSextantItems()*/) { if (!hasCurrentClue()) return false; Tile t = getTile((Integer) currentClue.details.parameters[0], (Integer) currentClue.details.parameters[1], (Integer) currentClue.details.parameters[2], (Integer) currentClue.details.parameters[3], (Integer) currentClue.details.parameters[4], (Integer) currentClue.details.parameters[5]); if (!player.withinDistance(t, meerkat ? 12 : 6)) // setted distance cuz the getTile // method may miss 3-5 tiles on rs return false; setNextClue(SOURCE_DIG, meerkat); return true; } return false; } public boolean useObject(GameObject object) { if ((currentClue == null) || currentClue.details.idType != OBJECT || !currentClue.details.isId(object.getId())) return false; if ((currentClue.details.type != SIMPLE && currentClue.details.type != MAP) || !hasCurrentClue()) return false; setNextClue(SOURCE_OBJECT, false); return true; } public boolean useNPC(final NPC npc) { if ((currentClue == null) || currentClue.details.idType != NPC || !currentClue.details.isId(npc.getId())) return false; if ((currentClue.details.type != SIMPLE && currentClue.details.type != ANAGRAM) || !hasCurrentClue()) return false; if (currentClue.details.type == ANAGRAM && currentClue.dificulty >= HARD && !player.containsOneItem(PUZZLES)) { int puzzle_id = currentClue.dificulty == ELITE ? PUZZLES[3] : PUZZLES[Utils.random(PUZZLES.length - 1)]; player.startConversation(new Dialogue() .addNPC(currentClue.details.getId(), HeadE.CALM_TALK, ""I have a puzzle for you!"") .addItem(puzzle_id, npc.getName() + "" has given you a puzzle box!"", ()-> player.getInventory().addItem(puzzle_id, 1)) ); return true; } if (currentClue.details.type == ANAGRAM && currentClue.dificulty >= HARD && !hasCompletedPuzzle()) { player.startConversation(new Dialogue() .addNPC(currentClue.details.getId(), HeadE.CALM_TALK, ""That doesn't look right."") ); return true; } if ((currentClue.details.type != ANAGRAM) || (currentClue.dificulty < HARD)) { player.startConversation(new Dialogue() .addNPC(currentClue.details.getId(), HeadE.CALM_TALK, ""Congratulations! You have come to right place."", ()-> setNextClue(SOURCE_NPC, false)) ); return true; } player.startConversation(new Dialogue() .addNPC(currentClue.details.getId(), HeadE.CALM_TALK, ""Good job!"", ()->{ for (int id : PUZZLES) player.getInventory().deleteItem(id, 1); setNextClue(SOURCE_PUZZLENPC, false); }) ); return true; } public void openPuzzle(int itemId) { if (currentClue == null) return; if (currentClue.details.type == ANAGRAM) if (currentClue.dificulty != HARD && currentClue.dificulty != ELITE) return; int base = BASE_PIECES[getBasePiece(itemId)]; if (pieces == null) { pieces = new ArrayList<>(PUZZLE_SIZE); for (int index = 0; index < PUZZLE_SIZE - 1; index++) pieces.add(new Item(base + index, 1)); pieces.add(new Item(-1, 1)); player.getPackets().sendItems(207, pieces.toArray(new Item[0])); pieces.clear(); int[] mix = createMix(); for (int element : mix) if (element != -1) pieces.add(new Item(base + element, 1)); else pieces.add(new Item(-1, 1)); } player.getPackets().setIFRightClickOps(363, 4, 0, 25, 0); player.getPackets().sendItems(140, pieces.toArray(new Item[0])); player.getInterfaceManager().sendInterface(363); } public void movePuzzlePeice(int index) { int[] directSlots = { index - 1, index + 1, index + 5, index - 5 }; for (int slot : directSlots) { if (slot >= PUZZLE_SIZE || slot < 0) continue; Item emptyPeice = pieces.get(slot); if (emptyPeice.getId() == -1) { pieces.set(slot, pieces.get(index)); pieces.set(index, emptyPeice); } } player.getPackets().sendItems(140, pieces.toArray(new Item[0])); } private int getBasePiece(int requestedId) { for (int index = 0; index < PUZZLES.length; index++) if (PUZZLES[index] == requestedId) return index; return -1; } private boolean hasCompletedPuzzle() { if (pieces == null) return false; main: for (int id : PUZZLES) { int base = BASE_PIECES[getBasePiece(id)]; for (int index = 0; index < PUZZLE_SIZE - 1; index++) if (index + base != pieces.get(index).getId()) continue main; return true; } return false; } public static Item[] generateRewards(Player player, int level) { ArrayList rewards = new ArrayList<>(); if (level == EASY) for (int i = 0;i < Utils.randomInclusive(2, 4);i++) Utils.add(rewards, DropTable.calculateDrops(player, DropSets.getDropSet(""easy_casket""))); else if (level == MEDIUM) for (int i = 0;i < Utils.randomInclusive(3, 5);i++) Utils.add(rewards, DropTable.calculateDrops(player, DropSets.getDropSet(""medium_casket""))); else if (level == HARD) for (int i = 0;i < Utils.randomInclusive(4, 6);i++) Utils.add(rewards, DropTable.calculateDrops(player, DropSets.getDropSet(""hard_casket""))); else if (level == ELITE) for (int i = 0;i < Utils.randomInclusive(4, 6);i++) Utils.add(rewards, DropTable.calculateDrops(player, DropSets.getDropSet(""elite_casket""))); Item[] rewArr = new Item[rewards.size()]; for (int i = 0;i < rewArr.length;i++) rewArr[i] = rewards.get(i); return rewArr; } public void openReward(int level) { player.getInterfaceManager().sendInterface(364); player.getPackets().sendInterSetItemsOptionsScript(364, 4, 141, 3, 4, ""Examine""); final Item[] rewards = generateRewards(player, level); player.jingle(193); player.getPackets().setIFRightClickOps(364, 4, 0, rewards.length, 0); player.incrementCount(LEVEL[level] + "" clues completed""); boolean banked = false; for (Item item : rewards) { if (player.getInventory().hasRoomFor(item)) player.getInventory().addItemDrop(item); else { if (item.getDefinitions().isNoted()) item.setId(item.getDefinitions().certId); player.getBank().addItem(item, true); banked = true; } if ((item.getId() >= 10330 && item.getId() <= 10353) || (item.getId() >= 19308 && item.getId() <= 19322)) World.sendWorldMessage("""" + player.getDisplayName() + "" has just recieved a "" + item.getDefinitions().getName() + "" drop from a clue scroll!"", false); } if (banked) player.sendMessage(""As you had no space in your inventory, the items were sent to your bank."", true); player.getPackets().sendItems(141, rewards); } public boolean hasSextantItems() { return player.getInventory().containsItem(2575, 1) && player.getInventory().containsItem(2576, 1) && player.getInventory().containsItem(2574, 1); } public void handleSextant(int componentId) { if (currentClue == null || currentClue.details.type != COORDINATE) { player.sendMessage(""It seems the telescope is not operational at the moment.""); return; } if (componentId == 12) { int[] location = getCoordinates(player.getTile()); player.sendMessage(""The sextant displays:""); player.sendMessage((location[0] <= 9 ? ""0"" : """") + location[0] + "" degrees, "" + (location[1] <= 9 ? ""0"" : """") + location[1] + "" minutes "" + (location[2] == NORTH ? ""north"" : ""south"")); player.sendMessage((location[3] <= 9 ? ""0"" : """") + location[3] + "" degrees, "" + (location[4] <= 9 ? ""0"" : """") + location[4] + "" minutes "" + (location[5] == WEST ? ""west"" : ""east"")); } } public void useSextant() { if (!hasSextantItems()) { player.sendMessage(""You also need a watch and a chart to use the sextant!""); return; } player.getInterfaceManager().sendInterface(365); } public static Tile getTile(int degreeY, int minY, int dirY, int degreeX, int minX, int dirX) { double offsetY = degreeY * 60 / 1.875 + minY / 1.875; double offsetX = degreeX * 60 / 1.875 + minX / 1.875; return Tile.of(2440 + (dirX == EAST ? (int) offsetX : (int) -offsetX), 3162 + (dirY == NORTH ? (int) offsetY : (int) -offsetY), 0); } private int[] getCoordinates(Tile tile) { int dirX = tile.getX() > 2440 ? EAST : WEST; int dirY = tile.getY() > 3162 ? NORTH : SOUTH; int x = dirX == EAST ? (tile.getX() - 2440) : (2440 - tile.getX()); int y = dirY == NORTH ? (tile.getY() - 3162) : (3162 - tile.getY()); int minX = (int) (x * 1.875); int minY = (int) (y * 1.875); int degreeX = minX / 60; int degreeY = minY / 60; minX -= degreeX * 60; minY -= degreeY * 60; return new int[] { degreeY, minY, dirY, degreeX, minX, dirX }; } private static int[] createMix() { int[] mix = new int[25]; for (int i = 0; i < mix.length; i++) mix[i] = i - 1; shuffle(mix); // http://www.cs.bham.ac.uk/~mdr/teaching/modules04/java2/TilesSolvability.html int inversions = 0; for (int i = 0; i < mix.length - 1; i++) { if (mix[i] == -1) continue; for (int j = i; j < mix.length; j++) if (mix[j] > mix[i]) inversions++; } // If the grid width is odd, then the number of inversions in a solvable // situation is even. if ((inversions & 1) != 0) return createMix(); // could just simply swap last 2 pieces but need // to make sure they arn't blank return mix; } private static void shuffle(int[] mix) { for (int i = mix.length - 1; i > 0; i--) { int index = Utils.random(i + 1); int tmp = mix[index]; mix[index] = mix[i]; mix[i] = tmp; } } private static final int COORDINATE = 0, EMOTE = 1, MAP = 2, SIMPLE = 3, ANAGRAM = 5, UNUSED = -1; private static final int TILE = 0, OBJECT = 1, NPC = 2; private static final int NORTH = 0, SOUTH = 1, WEST = 2, EAST = 3; public static final String[] UGIS_QUOTES = { ""Always bring a banana to a party."", ""Once, I was a poor man, but then I found a party hat."", ""There were three goblins in a bar, which one left first?"", ""Would you like to buy a pewter spoon?"", ""In the end, only the three-legged survive."", ""I heard that the tall man fears only strong winds."", ""In Canifis the men are known for eating much spam."", ""I am the egg man, are you one of the egg men?"", ""The sudden appearance of a deaf squirrel is most puzzling, Comrade."", ""I believe that it is very rainy in Varrock."", ""The slowest of fishermen catch the swiftest of fish."", ""It is quite easy being green."", ""Don't forget to find the jade monkey."", }; public static final String UGI_BADREQS = ""I do not believe we have any business, Comrade""; public static enum ClueDetails { SIMPLE_A_1(EASY, SIMPLE, OBJECT, 34585, ""A crate found in the tower of"", ""a church is your next location.""), SIMPLE_D_1(MEDIUM, SIMPLE, OBJECT, 24911, ""A town with a different sort of"", ""night-life is your destination."", ""Search for some crates"", ""in one of the houses.""), SIMPLE_G_1(EASY, SIMPLE, TILE, 40275377, ""Dig near some giant mushrooms behind"", ""the Grand Tree.""), SIMPLE_L_1(EASY, SIMPLE, OBJECT, 37011, ""Go to the village being"", ""attacked by trolls, search the"", ""drawers in one of the houses.""), SIMPLE_N_1(MEDIUM, SIMPLE, OBJECT, 10159, ""North of the best monkey restaurant on"", ""Karamja, look for the centre of the"", ""triangle of boats and search there.""), SIMPLE_O_1(EASY, SIMPLE, NPC, 376, ""One of the sailors in Port Sarim is your"", ""next destination.""), SIMPLE_S_1(EASY, SIMPLE, OBJECT, 66875, ""Search a barrel near the Combat."", ""Skill SlayerMasterD at the combat"", ""training area, in Burthorpe.""), SIMPLE_S_2(EASY, SIMPLE, OBJECT, 66875, ""Search a barrel outside the Pick"", ""and Lute inn, in Taverley.""), SIMPLE_S_3(EASY, SIMPLE, OBJECT, 66875, ""Search a barrel outside the mill,"", ""in Taverley.""), SIMPLE_S_4(EASY, SIMPLE, OBJECT, 40093, ""Search chests found in the"", ""upstairs of shops in Port Sarim.""), SIMPLE_S_5(EASY, SIMPLE, OBJECT, 48998, ""Search for a crate in a building in"", ""Hemenster.""), SIMPLE_S_6(EASY, SIMPLE, OBJECT, 46266, ""Search for a crate in Varrock"", ""Palace.""), SIMPLE_S_7(EASY, SIMPLE, OBJECT, 25775, ""Search for a crate on the ground"", ""floor of a house in Seers' Village.""), SIMPLE_S_8(EASY, SIMPLE, OBJECT, 11745, ""Search in the basement of the"", ""Artisan Dwarves' workshop in"", ""Falador.""), SIMPLE_S_9(EASY, SIMPLE, OBJECT, 46239, ""Search the boxes in one of the"", ""tents in Al Kharid.""), SIMPLE_S_10(EASY, SIMPLE, OBJECT, 46237, ""Search the boxes in the Goblin"", ""house near Lumbridge.""), SIMPLE_S_11(EASY, SIMPLE, OBJECT, 46236, ""Search the boxes in the house"", ""near the South entrance of"", ""Varrock.""), SIMPLE_S_12(EASY, SIMPLE, OBJECT, 34586, ""Search the crate just outside"", ""the Armour shop in east"", ""Ardougne.""), SIMPLE_S_13(EASY, SIMPLE, OBJECT, 46238, ""Search the crates in the"", ""northernmost house in Al Kharid.""), SIMPLE_S_14(EASY, SIMPLE, OBJECT, 11745, ""Search the crates of Falador's"", ""general store.""), SIMPLE_S_15(EASY, SIMPLE, OBJECT, 37010, ""Search the chest in the Duke of"", ""Lumbridge's bedroom.""), SIMPLE_S_16(EASY, SIMPLE, OBJECT, 25593, ""Search the chest in the left-hand"", ""tower of Camelot castle.""), SIMPLE_S_17(EASY, SIMPLE, OBJECT, 30928, ""Search the chests in the"", ""Dwarven Mine.""), SIMPLE_S_18(EASY, SIMPLE, OBJECT, 35470, ""Search the chests in Al"", ""Kharid palace.""), SIMPLE_S_19(EASY, SIMPLE, OBJECT, 21806, ""Search the crate in the left-hand "", ""tower of Lumbridge castle.""), SIMPLE_S_20(EASY, SIMPLE, OBJECT, 46270, ""Search the crate near a cart in"", ""Port Khazard.""), SIMPLE_S_21(EASY, SIMPLE, OBJECT, 24202, ""Search the crates in a house in"", ""Yanille that has a piano.""), SIMPLE_S_23(EASY, SIMPLE, OBJECT, 24911, ""Search the crates in Canifis.""), SIMPLE_S_24(EASY, SIMPLE, OBJECT, 47560, ""Search the crates in Draynor"", ""Manor.""), SIMPLE_S_25(EASY, SIMPLE, OBJECT, 34585, ""Search the crates in East"", ""Ardougne's general store.""), SIMPLE_S_26(EASY, SIMPLE, OBJECT, 46269, ""Search the crates in Horvik's"", ""armoury.""), SIMPLE_S_27(EASY, SIMPLE, OBJECT, 11600, ""Search the crates in"", ""Gunnarsgrunn (Barbarian Village)"", ""helmet shop.""), SIMPLE_S_28(EASY, SIMPLE, OBJECT, 34585, ""Search the crates in the guard"", ""house of the northern gate of"", ""East Ardougne.""), SIMPLE_S_29(EASY, SIMPLE, OBJECT, 46238, ""Search the crates in the"", ""northernmost house in Al Kharid.""), SIMPLE_S_30(EASY, SIMPLE, OBJECT, 40021, ""Search the crates in the Port"", ""Sarim fishing shop.""), SIMPLE_S_31(EASY, SIMPLE, OBJECT, 34586, ""Search the crates in the shed"", ""just north of east Ardougne.""), SIMPLE_S_32(EASY, SIMPLE, OBJECT, 46269, ""Search the crates near a cart in"", ""Varrock.""), SIMPLE_S_33(EASY, SIMPLE, OBJECT, 24294, ""Search the drawers above"", ""Varrock's shops.""), SIMPLE_S_34(EASY, SIMPLE, OBJECT, 34482, ""Search the drawers found"", ""upstairs in the houses of East"", ""Ardougne.""), SIMPLE_S_35(EASY, SIMPLE, OBJECT, 2631, ""Search the drawers in a house in"", ""Draynor Village.""), SIMPLE_S_36(EASY, SIMPLE, OBJECT, 348, ""Search the drawers in Falador's"", ""chainmail shop.""), SIMPLE_S_37(EASY, SIMPLE, OBJECT, 33931, ""Search the drawers in Catherby's"", ""Archery Shop.""), SIMPLE_S_38(EASY, SIMPLE, OBJECT, 24294, ""Search the drawers in one of"", ""Gertrude's bedrooms.""), SIMPLE_S_39(EASY, SIMPLE, OBJECT, 350, ""Search the drawers in the ground"", ""floor of a shop in Yanille.""), SIMPLE_S_40(EASY, SIMPLE, OBJECT, 33931, ""Search the drawers in the"", ""upstairs of a house in Catherby.""), SIMPLE_S_41(EASY, SIMPLE, OBJECT, 24294, ""Search the drawers upstairs in"", ""the bank to the East of Varrock.""), SIMPLE_S_42(EASY, SIMPLE, OBJECT, 37011, ""Search the drawers of houses in"", ""Burthorpe.""), SIMPLE_S_43(EASY, SIMPLE, OBJECT, 34482, ""Search the drawers on the first"", ""floor of a building overlooking"", ""Ardougne market.""), SIMPLE_S_44(EASY, SIMPLE, OBJECT, 348, ""Search the drawers upstairs in"", ""Falador's shield shop.""), SIMPLE_S_45(EASY, SIMPLE, OBJECT, 11745, ""Search the crates upstairs of"", ""houses in eastern part of"", ""Falador.""), SIMPLE_S_47(MEDIUM, SIMPLE, OBJECT, 348, ""Search the upstairs drawers of a"", ""house in a village were pirates"", ""are known to have a good time.""), SIMPLE_S_48(EASY, SIMPLE, OBJECT, 375, ""Search through chests found in"", ""the upstairs of houses in eastern"", ""Falador.""), SIMPLE_S_50(EASY, SIMPLE, OBJECT, 71943, ""Search through some drawers in "", ""the upstairs of a house in"", ""Rimmington.""), SIMPLE_S_51(EASY, SIMPLE, OBJECT, 25766, ""Search upstairs in the houses of"", ""Seers' Village for some drawers.""), SIMPLE_S_52(EASY, SIMPLE, NPC, 969, ""Someone watching the fights in"", ""the duel arena is your next"", ""destination.""), SIMPLE_S_53(MEDIUM, SIMPLE, NPC, 635, ""Speak to a referee.""), SIMPLE_S_54(EASY, SIMPLE, NPC, 563, ""Speak to Arhein in Catherby.""), SIMPLE_S_55(MEDIUM, SIMPLE, NPC, 171, ""Speak to Brimstail.""), SIMPLE_S_56(EASY, SIMPLE, NPC, 806, ""Speak to Donovan the Family"", ""Handyman.""), SIMPLE_S_57(EASY, SIMPLE, NPC, 284, ""Speak to Doric who lives north of"", ""Falador.""), SIMPLE_S_58(EASY, SIMPLE, NPC, 2824, ""Speak to Ellis in Al Kharid.""), SIMPLE_S_59(EASY, SIMPLE, NPC, 586, ""Speak to Gaius in Burthorpe.""), SIMPLE_S_60(MEDIUM, SIMPLE, NPC, 510, ""Speak to Hajedy.""), SIMPLE_S_61(EASY, SIMPLE, NPC, 0, ""Speak to Hans.""), SIMPLE_S_62(MEDIUM, SIMPLE, NPC, 669, ""Speak to Hazelmere.""), SIMPLE_S_63(EASY, SIMPLE, NPC, 918, ""Speak to Ned in Draynor Village.""), SIMPLE_S_64(EASY, SIMPLE, NPC, 1042, ""Speak to Roavar.""), SIMPLE_S_65(EASY, SIMPLE, NPC, 241, ""Speak to Sir Kay in Camelot"", ""Castle.""), SIMPLE_S_66(EASY, SIMPLE, NPC, 733, ""Speak to the bartender of the"", ""Blue Moon Inn in Varrock.""), SIMPLE_S_67(EASY, SIMPLE, NPC, 809, ""Speak to the staff of Sinclair"", ""Mansion.""), SIMPLE_S_68(EASY, SIMPLE, NPC, 1054, ""Speak to Ulizius.""), SIMPLE_T_1(EASY, SIMPLE, NPC, 734, ""Talk to the bartender of the Rusty"", ""Anchor in Port Sarim.""), SIMPLE_T_2(EASY, SIMPLE, NPC, 606, ""Talk to the Squire in the White"", ""Knights' castle in Falador.""), SIMPLE_T_3(EASY, SIMPLE, NPC, 541, ""Talk to Zeke in Al Kharid.""), SIMPLE_T_4(MEDIUM, SIMPLE, TILE, 54988211, ""The treasure is buried in a small"", ""building full of bones. Here is a hint: "", ""it's not near a graveyard.""), COORDINATE_00_1(HARD, COORDINATE, TILE, UNUSED, 0, 0, NORTH, 7, 13, WEST), COORDINATE_00_2(MEDIUM, COORDINATE, TILE, UNUSED, 0, 5, SOUTH, 1, 13, EAST), COORDINATE_00_3(MEDIUM, COORDINATE, TILE, UNUSED, 0, 13, SOUTH, 13, 58, EAST), COORDINATE_00_4(MEDIUM, COORDINATE, TILE, UNUSED, 0, 18, SOUTH, 9, 28, EAST), COORDINATE_00_5(MEDIUM, COORDINATE, TILE, UNUSED, 0, 20, SOUTH, 23, 15, EAST), COORDINATE_00_6(MEDIUM, COORDINATE, TILE, UNUSED, 0, 30, NORTH, 24, 16, EAST), COORDINATE_00_7(MEDIUM, COORDINATE, TILE, UNUSED, 0, 31, SOUTH, 17, 43, EAST), COORDINATE_00_8(MEDIUM, COORDINATE, TILE, UNUSED, 1, 18, SOUTH, 14, 15, EAST), COORDINATE_00_9(MEDIUM, COORDINATE, TILE, UNUSED, 1, 24, NORTH, 8, 5, WEST), COORDINATE_00_10(MEDIUM, COORDINATE, TILE, UNUSED, 1, 26, NORTH, 8, 1, EAST), COORDINATE_00_11(MEDIUM, COORDINATE, TILE, UNUSED, 1, 35, SOUTH, 7, 28, EAST), COORDINATE_00_12(MEDIUM, COORDINATE, TILE, UNUSED, 2, 46, NORTH, 29, 11, EAST), COORDINATE_00_13(MEDIUM, COORDINATE, TILE, UNUSED, 2, 48, NORTH, 22, 30, EAST), COORDINATE_00_14(MEDIUM, COORDINATE, TILE, UNUSED, 2, 50, NORTH, 6, 20, EAST), COORDINATE_00_15(MEDIUM, COORDINATE, TILE, UNUSED, 3, 35, SOUTH, 13, 35, EAST), COORDINATE_00_16(HARD, COORDINATE, TILE, UNUSED, 3, 45, SOUTH, 22, 45, EAST), COORDINATE_00_17(MEDIUM, COORDINATE, TILE, UNUSED, 4, 0, SOUTH, 12, 46, EAST), COORDINATE_00_18(HARD, COORDINATE, TILE, UNUSED, 4, 3, SOUTH, 3, 11, EAST), COORDINATE_00_19(HARD, COORDINATE, TILE, UNUSED, 4, 5, SOUTH, 4, 24, EAST), COORDINATE_00_20(MEDIUM, COORDINATE, TILE, UNUSED, 4, 13, NORTH, 12, 45, EAST), COORDINATE_00_21(HARD, COORDINATE, TILE, UNUSED, 4, 16, SOUTH, 16, 16, EAST), COORDINATE_00_22(HARD, COORDINATE, TILE, UNUSED, 4, 41, NORTH, 3, 9, WEST), COORDINATE_00_23(MEDIUM, COORDINATE, TILE, UNUSED, 5, 20, SOUTH, 4, 28, EAST), COORDINATE_00_24(HARD, COORDINATE, TILE, UNUSED, 5, 37, NORTH, 31, 15, EAST), COORDINATE_00_25(MEDIUM, COORDINATE, TILE, UNUSED, 5, 43, NORTH, 23, 5, EAST), COORDINATE_00_26(HARD, COORDINATE, TILE, UNUSED, 5, 50, SOUTH, 10, 5, EAST), COORDINATE_00_27(HARD, COORDINATE, TILE, UNUSED, 6, 0, SOUTH, 21, 48, EAST), COORDINATE_00_28(HARD, COORDINATE, TILE, UNUSED, 6, 11, SOUTH, 15, 7, EAST), COORDINATE_00_29(MEDIUM, COORDINATE, TILE, UNUSED, 6, 31, NORTH, 1, 46, WEST), COORDINATE_00_30(MEDIUM, COORDINATE, TILE, UNUSED, 7, 5, NORTH, 30, 56, EAST), COORDINATE_00_31(MEDIUM, COORDINATE, TILE, UNUSED, 7, 33, NORTH, 15, 0, EAST), COORDINATE_00_32(HARD, COORDINATE, TILE, UNUSED, 7, 43, SOUTH, 12, 26, EAST), COORDINATE_00_33(HARD, COORDINATE, TILE, UNUSED, 8, 3, NORTH, 31, 16, EAST), COORDINATE_00_34(HARD, COORDINATE, TILE, UNUSED, 8, 5, SOUTH, 15, 56, EAST), COORDINATE_00_35(HARD, COORDINATE, TILE, UNUSED, 8, 26, SOUTH, 10, 28, EAST), COORDINATE_00_36(MEDIUM, COORDINATE, TILE, UNUSED, 8, 33, NORTH, 1, 39, WEST), COORDINATE_00_37(MEDIUM, COORDINATE, TILE, UNUSED, 9, 33, NORTH, 2, 15, EAST), COORDINATE_00_38(MEDIUM, COORDINATE, TILE, UNUSED, 9, 48, NORTH, 17, 39, EAST), COORDINATE_00_39(MEDIUM, COORDINATE, TILE, UNUSED, 11, 3, NORTH, 31, 20, EAST), COORDINATE_00_40(MEDIUM, COORDINATE, TILE, UNUSED, 11, 5, NORTH, 0, 45, WEST), COORDINATE_00_41(MEDIUM, COORDINATE, TILE, UNUSED, 11, 41, NORTH, 14, 58, EAST), COORDINATE_00_42(HARD, COORDINATE, TILE, UNUSED, 12, 48, NORTH, 20, 20, EAST), COORDINATE_00_43(HARD, COORDINATE, TILE, UNUSED, 13, 46, NORTH, 21, 1, EAST), COORDINATE_00_44(MEDIUM, COORDINATE, TILE, UNUSED, 14, 54, NORTH, 9, 13, EAST), COORDINATE_00_45(HARD, COORDINATE, TILE, UNUSED, 15, 48, NORTH, 13, 52, EAST), COORDINATE_00_46(HARD, COORDINATE, TILE, UNUSED, 16, 3, NORTH, 14, 7, EAST), COORDINATE_00_47(HARD, COORDINATE, TILE, UNUSED, 16, 20, NORTH, 12, 45, EAST), COORDINATE_00_48(HARD, COORDINATE, TILE, UNUSED, 16, 35, NORTH, 27, 1, EAST), COORDINATE_00_49(HARD, COORDINATE, TILE, UNUSED, 16, 43, NORTH, 19, 11, EAST), COORDINATE_00_50(HARD, COORDINATE, TILE, UNUSED, 17, 50, NORTH, 8, 30, EAST), COORDINATE_00_51(HARD, COORDINATE, TILE, UNUSED, 18, 3, NORTH, 25, 16, EAST), COORDINATE_00_52(HARD, COORDINATE, TILE, UNUSED, 18, 22, NORTH, 16, 33, EAST), COORDINATE_00_53(HARD, COORDINATE, TILE, UNUSED, 19, 43, NORTH, 25, 7, EAST), COORDINATE_00_54(HARD, COORDINATE, TILE, UNUSED, 20, 5, NORTH, 21, 52, EAST), COORDINATE_00_55(HARD, COORDINATE, TILE, UNUSED, 20, 7, NORTH, 18, 33, EAST), COORDINATE_00_56(HARD, COORDINATE, TILE, UNUSED, 20, 33, NORTH, 15, 48, EAST), COORDINATE_00_57(HARD, COORDINATE, TILE, UNUSED, 21, 24, NORTH, 17, 54, EAST), COORDINATE_00_58(MEDIUM, COORDINATE, TILE, UNUSED, 22, 30, NORTH, 3, 1, EAST), COORDINATE_00_59(HARD, COORDINATE, TILE, UNUSED, 22, 35, NORTH, 19, 18, EAST), COORDINATE_00_60(HARD, COORDINATE, TILE, UNUSED, 22, 45, NORTH, 26, 33, EAST), COORDINATE_00_61(HARD, COORDINATE, TILE, UNUSED, 24, 24, NORTH, 26, 24, EAST), COORDINATE_00_62(HARD, COORDINATE, TILE, UNUSED, 24, 56, NORTH, 22, 28, EAST), COORDINATE_00_63(HARD, COORDINATE, TILE, UNUSED, 24, 58, NORTH, 18, 43, EAST), COORDINATE_00_64(HARD, COORDINATE, TILE, UNUSED, 25, 3, NORTH, 17, 5, EAST), COORDINATE_00_65(HARD, COORDINATE, TILE, UNUSED, 25, 3, NORTH, 23, 24, EAST), ANAGRAM_A_1(HARD, ANAGRAM, NPC, 589, ""A Zen "", ""She""), ANAGRAM_A_2(HARD, ANAGRAM, NPC, 2812, ""Ace"", ""Match"", ""Elm""), ANAGRAM_A_3(MEDIUM, ANAGRAM, NPC, 962, ""Aha Jar""), ANAGRAM_A_4(HARD, ANAGRAM, NPC, 4594, ""An Paint"", ""Tonic""), ANAGRAM_A_5(MEDIUM, ANAGRAM, NPC, 696, ""Arc O"", ""Line""), ANAGRAM_A_6(HARD, ANAGRAM, NPC, 746, ""Are Col"") // , // ANAGRAM_A_7(MEDIUM, // ANAGRAM, // NPC, // 3827, // ""Arr! // So // I"", // ""am // a"", // ""crust"", // ""and?"") , ANAGRAM_B_1(MEDIUM, ANAGRAM, NPC, 171, ""Bail Trims""), ANAGRAM_B_2(HARD, ANAGRAM, NPC, 471, ""By Look""), ANAGRAM_B_3(MEDIUM, ANAGRAM, NPC, new int[] { 15095, 15097 }, ""Boast B""), ANAGRAM_C_1(HARD, ANAGRAM, NPC, 2802, ""C on game"", ""hoc""), ANAGRAM_D_1(HARD, ANAGRAM, NPC, 1294, ""Dt Run B""), ANAGRAM_E_1(HARD, ANAGRAM, NPC, 28, ""Eek Zero Op""), ANAGRAM_E_2(MEDIUM, ANAGRAM, NPC, 550, ""El Ow""), ANAGRAM_E_3(HARD, ANAGRAM, NPC, 720, ""Err Cure It""), ANAGRAM_G_1(MEDIUM, ANAGRAM, NPC, 469, ""Goblin Kern""), ANAGRAM_G_2(MEDIUM, ANAGRAM, NPC, 2520, ""Got A Boy""), ANAGRAM_G_3(HARD, ANAGRAM, NPC, 2039, ""Gulag Run""), ANAGRAM_H_1(MEDIUM, ANAGRAM, NPC, 379, ""Halt Us""), ANAGRAM_H_2(HARD, ANAGRAM, NPC, 2142, ""He Do Pose. It is"", ""Cultrrl, Mk?""), ANAGRAM_I_1(MEDIUM, ANAGRAM, NPC, 1011, ""Icy Fe""), ANAGRAM_I_2(HARD, ANAGRAM, NPC, 3044, ""I Eat Its"", ""Chart"", ""Hints Do"", ""U""), ANAGRAM_I_3(HARD, ANAGRAM, NPC, 4431, ""I Faffy"", ""Run""), ANAGRAM_L_1(HARD, ANAGRAM, NPC, 9173, ""Land Doomd""), ANAGRAM_L_2(HARD, ANAGRAM, NPC, 648, ""Lark In Dog""), ANAGRAM_M_1(HARD, ANAGRAM, NPC, 2812, ""Me Am The"", ""Calc""), ANAGRAM_M_2(MEDIUM, ANAGRAM, NPC, 676, ""Me if""), ANAGRAM_N_1(MEDIUM, ANAGRAM, NPC, 714, ""Nod med""), ANAGRAM_O_1(MEDIUM, ANAGRAM, NPC, 437, ""O Birdz A Zany"", ""En Pc""), ANAGRAM_O_2(HARD, ANAGRAM, NPC, 278, ""Ok Co""), ANAGRAM_O_3(HARD, ANAGRAM, NPC, 460, ""Or Zinc Fumes"", ""Ward""), ANAGRAM_P_1(MEDIUM, ANAGRAM, NPC, 659, ""Peaty Pert""), ANAGRAM_P_2(HARD, ANAGRAM, NPC, 4585, ""Profs Lose Wrong Pie""), ANAGRAM_R_1(HARD, ANAGRAM, NPC, 543, ""R Ak Mi""), ANAGRAM_R_2(HARD, ANAGRAM, NPC, 4650, ""Red Art Tans""), ANAGRAM_S_1(HARD, ANAGRAM, NPC, 1359, ""Sequin"", ""Dirge""), ANAGRAM_S_2(MEDIUM, ANAGRAM, NPC, 0, ""Hans""), ANAGRAM_S_3(MEDIUM, ANAGRAM, NPC, new int[] { 15095, 15097 }, ""Stab"", ""Ob""), ANAGRAM_T_1(HARD, ANAGRAM, NPC, 2812, ""Them Cal Came""), MAP_1(EASY, MAP, OBJECT, 46331, 361), MAP_2(EASY, MAP, OBJECT, 24202, 355), MAP_3(HARD, MAP, OBJECT, 46331, 359), MAP_4(EASY, MAP, OBJECT, 18506, 358), MAP_5(EASY, MAP, OBJECT, 2620, 350), MAP_6(EASY, MAP, TILE, 40209568, 342), MAP_7(EASY, MAP, TILE, 50941008, 356), MAP_8(EASY, MAP, TILE, 42798490, 354), MAP_9(EASY, MAP, TILE, 41520921, 340), MAP_10(EASY, MAP, TILE, 40783082, 357), MAP_11(EASY, MAP, TILE, 42863621, 353), MAP_12(EASY, MAP, TILE, 43437216, 360), MAP_13(EASY, MAP, TILE, 44354915, 349), MAP_14(EASY, MAP, TILE, 49859911, 351), MAP_15(EASY, MAP, TILE, 51907877, 346), MAP_16(EASY, MAP, TILE, 48729430, 337), MAP_17(EASY, MAP, TILE, 53890349, 347), MAP_18(EASY, MAP, TILE, 43797996, 344), MAP_19(EASY, MAP, TILE, 47615201, 352), MAP_20(EASY, MAP, TILE, 44633354, 339), MAP_21(HARD, MAP, TILE, 49499975, 338), MAP_22(EASY, MAP, TILE, 42241549, 343), MAP_23(EASY, MAP, TILE, 50711705, 348), MAP_24(EASY, MAP, TILE, 56282305, 341), MAP_25(EASY, MAP, TILE, 47893642, 362), EMOTE_B_1( MEDIUM, EMOTE, TILE, 45829116, new Emote[] { Emote.BECKON, Emote.CLAP }, new Item[] { new Item(20922, 1), new Item(1099, 1), new Item(1143, 1) }, ""Beckon in Tai Bwo Wannai."", ""Clap before you talk to me."", "" Equip green dragonhide chaps,"", ""a ring of duelling, and a mithril med helm.""), EMOTE_B_2( MEDIUM, EMOTE, TILE, 55184739, new Emote[] { Emote.BECKON, Emote.BOW }, new Item[] { new Item(3339, 1), new Item(6328, 1), new Item(1267, 1) }, ""Beckon in the Digsite, near"", ""the eastern winch."", "" Bow or curtsy before you talk to me."", ""Equip a pointed red and black snelm,"", ""snakeskin boots, and an iron pickaxe.""), EMOTE_B_3( HARD, EMOTE, TILE, 46730121, new Emote[] { Emote.BLOW_KISS }, new Item[] { new Item(3385, 1), new Item(7170, 1), new Item(1127, 1) }, ""Blow a kiss between the tables"", ""in Shilo Village bank."", ""Beware of double agents!"", ""Equip a splitbark helmet, mud pie"", ""and rune platebody.""), EMOTE_B_4( EASY, EMOTE, TILE, 42732751, new Emote[] { Emote.RASPBERRY }, new Item[] { new Item(1133, 1), new Item(1075, 1), new Item(7170, 1) }, ""Blow a raspberry at the monkey"", ""cage in Ardougne Zoo."", ""Equip a studded body,"", ""bronze platelegs and a mud pie.""), EMOTE_B_5( HARD, EMOTE, TILE, 42372446, new Emote[] { Emote.RASPBERRY }, new Item[] { new Item(2890, 1), new Item(2493, 1), new Item(1347, 1) }, ""Blow a raspberry in"", ""the Fishing Guild bank."", ""Beware of double agents!"", ""Equip an elemental shield, blue "", ""dragonhide chaps, and a rune warhammer.""), EMOTE_B_6( EASY, EMOTE, TILE, 45272394, new Emote[] { Emote.RASPBERRY }, new Item[] { new Item(1169, 1), new Item(1115, 1), new Item(1059, 1) }, ""Blow raspberries outside"", ""the entrance to Keep Le Faye."", ""Equip a coif, an iron platebody"", ""and leather gloves.""), EMOTE_B_7( HARD, EMOTE, TILE, 577982012, new Emote[] { Emote.BOW }, new Item[] { new Item(2499, 1), new Item(2487, 1) }, ""Bow or curtsy at the"", ""top of the lighthouse."", ""Beware of double agents!"", ""Equip a blue dragonhide body,"", ""blue dragonhide vambraces"", ""and no jewellery.""), EMOTE_B_8(EASY, EMOTE, TILE, 55200971, new Emote[] { Emote.BOW }, new Item[] { new Item(1101, 1), new Item(1095, 1), new Item(1169, 1) }, ""Bow or curtsy in the lobby"", ""of the Duel Arena."", ""Equip an iron chainbody,"", ""leather chaps and a coif.""), EMOTE_B_9( EASY, EMOTE, TILE, 44715285, new Emote[] { Emote.BOW }, new Item[] { new Item(1067, 1), new Item(1696, 1), new Item(845, 1) }, ""Bow or curtsy outside"", ""the entrance to the Legends' Guild."", ""Equip iron platelegs,"", ""an emerald amulet and oak longbow.""), EMOTE_C_1(EASY, EMOTE, TILE, 36164446, new Emote[] { Emote.CHEER }, new Item[] {}, ""Cheer at the Burthrope Games Room."", ""Have nothing equipped at all when you do.""), EMOTE_C_2(EASY, EMOTE, TILE, 47648172, new Emote[] { Emote.CHEER }, new Item[] { new Item(5527, 1), new Item(1307, 1), new Item(1692, 1) }, ""Cheer at the druids circle,"", ""equip an Air tiara, a bronze 2h sword,"", ""and Gold amulet.""), EMOTE_C_3(EASY, EMOTE, TILE, 49941668, new Emote[] { Emote.CHEER }, new Item[] { new Item(1169, 1), new Item(1083, 1), new Item(1656, 1) }, ""Cheer for the monks at Port Sarim."", ""Equip a coif, steel plateskirt"", ""and a sapphire necklace.""), EMOTE_C_4( MEDIUM, EMOTE, TILE, 41799140, new Emote[] { Emote.CHEER, Emote.HEADBANG }, new Item[] { new Item(1119, 1), new Item(853, 1), new Item(4119, 1) }, ""Cheer in the Barbarian Agility Arena."", ""Headbang before you talk to me."", ""Equip a steel platebody, maple, "", ""shortbow and bronze boots.""), EMOTE_C_5( MEDIUM, EMOTE, TILE, 41422128, new Emote[] { Emote.CHEER, Emote.ANGRY }, new Item[] { new Item(1135, 1), new Item(1099, 1), new Item(1177, 1) }, ""Cheer in the Ogre pen"", ""in the Training Camp."", ""Show you are angry before you talk"", ""to me. Equip a Green Dragonhide Body, "", ""green dragonhide chaps"", ""and a steel sq shield.""), EMOTE_C_6(EASY, EMOTE, TILE, 55086348, new Emote[] { Emote.CLAP }, new Item[] { new Item(1698, 1), new Item(2464, 1), new Item(1059, 1) }, ""Clap in the main exam room"", ""in the Exam Centre."", ""Equip a ruby amulet, blue flowers"", ""and leather gloves.""), EMOTE_C_7(EASY, EMOTE, TILE, 51022956, new Emote[] { Emote.CLAP }, new Item[] { new Item(1137, 1), new Item(1639, 1), new Item(1059, 1) }, ""Clap on the causeway to"", ""the Wizard's Tower."", "" Equip an Iron helm, emerald ring"", ""and leather gloves.""), EMOTE_C_8( EASY, EMOTE, TILE, 579980602, new Emote[] { Emote.CLAP }, new Item[] { new Item(1639, 1), new Item(1119, 1), new Item(5525, 1) }, ""Clap on the top level of the mill,"", ""north of east Ardougne."", ""Equip an Emerald ring,"", ""Steel platebody and an uncharged tiara.""), EMOTE_C_9( MEDIUM, EMOTE, TILE, 46255474, new Emote[] { Emote.CRY, Emote.BOW }, new Item[] { new Item(3329, 1), new Item(1131, 1), new Item(2961, 1) }, ""Cry in Catherby archery shop."", ""Bow or curtsy before you talk to me."", ""Equip a round red and black snelm,"", ""a hardleather body and an unblessed"", ""silver sickle.""), EMOTE_C_10( MEDIUM, EMOTE, TILE, 577424732, new Emote[] { Emote.CRY, Emote.NO }, new Item[] { new Item(1099, 1), new Item(1193, 1), new Item(2568, 1) }, ""Cry on the platform of"", ""the south-west tree of the"", ""Gnome Agility Arena. Indicate 'no'"", ""before talking to me,"", ""equip green d'hide chaps, a steel"", ""kiteshield, and a ring of forging.""), EMOTE_D_1( MEDIUM, EMOTE, TILE, 54152242, new Emote[] { Emote.JIG, Emote.BOW }, new Item[] { new Item(3333, 1), new Item(1381, 1) }, ""Dance a jig under Shantay's Awning."", ""Bow or curtsy before you talk to me."", ""Equip a pointed blue snail"", ""helmet and an air staff.""), EMOTE_D_2( HARD, EMOTE, TILE, 53971677, new Emote[] { Emote.DANCE }, new Item[] { new Item(2570, 1), new Item(1704, 1), new Item(1317, 1) }, ""Dance at the cat-doored"", ""pyramid in Sophanem."", ""Beware of double agents!"", ""Equip a ring of life,"", ""an uncharged amulet of glory,"", ""and an adamant 2h sword.""), EMOTE_D_3(EASY, EMOTE, TILE, 50957536, new Emote[] { Emote.DANCE }, new Item[] { new Item(1101, 1), new Item(1637, 1), new Item(839, 1) }, ""Dance at the crossroads"", ""north of Draynor,"", ""equip an iron chainbody,"", ""a sapphire ring and a longbow. ""), EMOTE_D_4( MEDIUM, EMOTE, TILE, 57281956, new Emote[] { Emote.DANCE, Emote.BOW }, new Item[] { new Item(4551, 1), new Item(1071, 1), new Item(1309, 1) }, ""Dance in the centre of Canifis."", ""Bow or curtsy before you talk to me."", ""Equip a spiny helm,"", ""mithril platelegs, and an"", ""iron two-handed sword.""), EMOTE_D_5(EASY, EMOTE, TILE, 49892657, new Emote[] { Emote.DANCE }, new Item[] { new Item(1157, 1), new Item(1119, 1), new Item(1081, 1) }, ""Dance in the Party Room."", ""Equip a steel full helm,"", ""steel platebody and, "", ""iron plateskirt.""), EMOTE_D_6(EASY, EMOTE, TILE, 52481120, new Emote[] { Emote.DANCE }, new Item[] { new Item(1205, 1), new Item(1153, 1), new Item(1635, 1) }, ""Dance in the shack"", ""in Lumbridge Swamp."", ""Equip a bronze dagger,"", ""iron full helm and"", ""a gold ring.""), EMOTE_H_1(EASY, EMOTE, TILE, 54086900, new Emote[] { Emote.HEADBANG }, new Item[] { new Item(1059, 1), new Item(1061, 1) }, ""Headbang in the mine"", ""north of Al-kharid."", ""Equip Leather Gloves"", ""and Leather Boots.""), EMOTE_J_1( EASY, EMOTE, TILE, 42831162, new Emote[] { Emote.JIG }, new Item[] { new Item(1694, 1), new Item(1639, 1), new Item(1103, 1) }, ""Dance a jig by the"", ""entrance to the Fishing Guild,"", ""equip a sapphire amulet,"", ""an emerald ring "", ""and a bronze chainbody.""), EMOTE_J_2( MEDIUM, EMOTE, TILE, 54152242, new Emote[] { Emote.JIG, Emote.BOW }, new Item[] { new Item(3333, 1), new Item(1381, 1) }, ""Dance a jig"", ""under Shantay's Awning."", ""Bow or curtsy before you talk to me."", ""Equip a pointed blue"", ""snail helmet, air staff.""), EMOTE_J_3(EASY, EMOTE, TILE, 45206898, new Emote[] { Emote.JUMP_FOR_JOY }, new Item[] { new Item(4121, 1), new Item(1724, 1), new Item(1353, 1) }, ""Jump for joy"", ""at the beehives."", ""Equip iron boots, unholy symbol,"", ""and a steel hatchet.""), EMOTE_J_4( MEDIUM, EMOTE, TILE, 42781716, new Emote[] { Emote.JUMP_FOR_JOY, Emote.JIG }, new Item[] { new Item(9177, 1), new Item(1145, 1), new Item(6324, 1) }, ""Jump for joy in Yanille Bank."", ""Dance a jig before you talk to me."", ""Equip an iron crossbow,"", ""adamant medium helmet"", ""and snakeskin chaps.""), EMOTE_L_1( EASY, EMOTE, TILE, 44912080, new Emote[] { Emote.LAUGH }, new Item[] { new Item(1167, 1), new Item(1725, 1), new Item(1323, 1) }, ""Laugh at the crossroads"", ""south of Sinclair Mansion."", ""Equip a leather cowl,"", ""amulet of strength"", ""and iron scimitar.""), EMOTE_L_2( HARD, EMOTE, TILE, 45780567, new Emote[] { Emote.LAUGH }, new Item[] { new Item(1163, 1), new Item(2493, 1), new Item(1393, 1) }, ""Laugh in the Jokul's tent"", ""in the mountain camp."", ""Beware of double agents!"", ""Equip a rune full helm, blue"", ""d'hide chaps and a fire battlestaff.""), EMOTE_P_1(HARD, EMOTE, TILE, 59231649, new Emote[] { Emote.PANIC }, new Item[] {}, ""Panic in the heart of"", ""the Haunted Woods."", ""Beware of double agents!"", ""Have no items equipped when you do.""), EMOTE_P_2(EASY, EMOTE, TILE, 55250348, new Emote[] { Emote.PANIC }, new Item[] { new Item(1075, 1), new Item(1269, 1), new Item(1141, 1) }, ""Panic in the limestone mine."", ""Equip bronze platelegs,"", ""steel pickaxe"", ""and steel helm.""), EMOTE_P_3( HARD, EMOTE, TILE, 46615979, new Emote[] { Emote.PANIC }, new Item[] { new Item(1071, 1), new Item(2570, 1), new Item(1359, 1) }, ""Panic by the pilot"", ""on White Wolf Mountain."", ""Beware of double agents!"", ""Equip mithril platelegs,"", ""a ring of life,"", ""and a rune hatchet.""), EMOTE_P_4(EASY, EMOTE, TILE, 43846754, new Emote[] { Emote.PANIC }, new Item[] {}, ""Panic on the pier where you"", ""catch the Fishing Trawler."", ""Have nothing equipped at all"", ""when you do."") // , // EMOTE_P_5(EASY, // EMOTE, // TILE,57413112, // new // int[] // {20, // 7}, // new // Item[] // {new // Item(1085, // 1), // new // Item(851, // 1)}, // ""Panic // by // the // mausoleum"", // ""in // Morytania. // "", // "" // Wave // before // you // speak // to // me."", // ""Equip // a // mithril // plateskirt,"", // ""a // maple // longbow // and // no // boots."") , EMOTE_S_1( HARD, EMOTE, TILE, 47844442, new Emote[] { Emote.SALUTE }, new Item[] { new Item(1643, 1), new Item(1731, 1) }, ""Salute in the banana plantation."", ""Beware of double agents!"", ""Equip a diamond ring,"", ""amulet of power"", ""and nothing on your chest and legs.""), EMOTE_S_2(EASY, EMOTE, TILE, 48745637, new Emote[] { Emote.SHRUG }, new Item[] { new Item(1654, 1), new Item(1635, 1), new Item(1237, 1) }, ""Shrug in the mine near Rimmington,"", ""Equip a gold necklace,"", ""a gold ring and a bronze spear.""), EMOTE_S_3( HARD, EMOTE, TILE, 53087770, new Emote[] { Emote.SHRUG }, new Item[] { new Item(1075, 1), new Item(1115, 1), new Item(2487, 1) }, ""Shrug in the Zamorak temple"", ""found in the Eastern Wilderness."", ""Beware of double agents!"", ""Equip bronze platelegs,"", ""an iron platebody,"", ""and blue d'hide vambraces.""), EMOTE_T_1(EASY, EMOTE, TILE, 51776739, new Emote[] { Emote.THINK }, new Item[] { new Item(1656, 1), new Item(843, 1) }, ""Think in the middle of the"", ""wheat field by the Lumbridge mill."", ""Equip a sapphire necklace"", ""and an oak shortbow. "") // , // EMOTE_T_2(MEDIUM,EMOTE, // TILE, // -1, // new // int[] // {6,16}, // new // Item[] // {new // Item(1109,1), // new // Item(1099,1), // new // Item(1698,1)}, // ""Think // under // the // lens // in // the // Observatory."", // ""Twirl // before // you // talk // to // me."", // ""Equip // a // mithril // chainbody,"", // ""green // dragonhide // chaps"", // ""and // ruby // amulet. // "") , EMOTE_T_3( EASY, EMOTE, TILE, 48794823, new Emote[] { Emote.TWIRL }, new Item[] { new Item(1637, 1), new Item(2466, 1), new Item(1095, 1) }, ""Twirl at the crossroads"", ""north of Rimmington."", ""Equip a Sapphire ring,"", ""yellow flowers"", ""and leather chaps.""), EMOTE_T_4( EASY, EMOTE, TILE, 50629897, new Emote[] { Emote.TWIRL }, new Item[] { new Item(1115, 1), new Item(1097, 1), new Item(1155, 1) }, ""Twirl in Draynor Manor"", ""by the fountain."", ""Equip an iron platebody,"", ""studded chaps"", ""and a bronze full helm. ""), EMOTE_T_5( MEDIUM, EMOTE, TILE, 50892125, new Emote[] { Emote.TWIRL, Emote.SALUTE }, new Item[] { new Item(1349, 1), new Item(1193, 1), new Item(1159, 1) }, ""Twirl on the bridge"", ""by Gunnarsgrunn (or Barbarian Village)."", ""Salute before you talk to me."", ""Equip an iron hatchet,"", ""steel kiteshield"", ""and mithril full helm.""), EMOTE_W_1(EASY, EMOTE, TILE, 49138733, new Emote[] { Emote.WAVE }, new Item[] { new Item(1635, 1), new Item(1095, 1), new Item(1424, 1) }, ""Wave on Mudskipper Point."", ""Equip a gold ring,"", ""leather chaps and a steel mace. ""), EMOTE_W_2( EASY, EMOTE, TILE, 54168995, new Emote[] { Emote.WAVE }, new Item[] { new Item(1095, 1), new Item(1351, 1), new Item(1131, 1) }, ""Wave along the south"", ""fence of the lumberyard."", ""Equip leather chaps,"", ""bronze hatchet"", ""and a hardleather body. ""), EMOTE_Y_1( MEDIUM, EMOTE, TILE, 40012822, new Emote[] { Emote.YAWN, Emote.SHRUG }, new Item[] { new Item(1698, 1), new Item(1329, 1), new Item(1175, 1) }, ""Yawn in the Castle Wars lobby."", ""Shrug before you talk to me."", ""Equip a ruby amulet,"", ""mithril scimitar"", ""and an iron sq shield. ""), EMOTE_Y_2(EASY, EMOTE, TILE, 50482355, new Emote[] { Emote.YAWN }, new Item[] { new Item(1191, 1), new Item(1295, 1), new Item(1097, 1) }, ""Yawn in Draynor Marketplace."", ""Equip an iron kiteshield,"", ""steel longsword"", ""and studded leather chaps.""), EMOTE_Y_3(EASY, EMOTE, TILE, 52596135, new Emote[] { Emote.YAWN }, new Item[] { new Item(1718, 1), new Item(1063, 1), new Item(1335, 1) }, ""Yawn in Varrock Palace library."", ""Equip a holy symbol,"", ""leather vambraces"", ""and an iron warhammer.""), EMOTE_Y_4( HARD, EMOTE, TILE, 49581685, new Emote[] { Emote.YAWN }, new Item[] { new Item(1175, 1), new Item(2487, 1), new Item(1267, 1) }, ""Yawn in the rogues' general store."", ""Beware of double agents!"", ""Equip an iron square shield,"", ""blue dragonhide vambraces,"", ""and an iron pickaxe."") ; public final int level; public final int type; public final int idType; public final int[] ids; public final Object[] parameters; private ClueDetails(int level, int type, int idType, int[] ids, Object... parameters) { this.level = level; this.type = type; this.idType = idType; this.ids = ids; this.parameters = parameters; } private ClueDetails(int level, int type, int idType, int id, Object... parameters) { this.level = level; this.type = type; this.idType = idType; ids = new int[] { id }; this.parameters = parameters; } public boolean isId(int id) { for (int i : ids) if (id == i) return true; return false; } public int getId() { return ids[0]; } } private static class Clue { private ClueDetails details; private int count; private final int dificulty; public Clue(ClueDetails details, int count, int dificulty) { this.details = details; this.count = count; this.dificulty = dificulty; } private boolean isLast() { return count == 0; } } }" "package com.rs.game.content.minigames.treasuretrails; public class Ugi extends OwnedNPC { public Ugi(Player target, int id, Tile tile) { super(target, id, tile, false); } @Override public void onDespawnEarly() { getOwner().getTreasureTrailsManager().setPhase(0); } }" "package com.rs.game.content.minigames.treasuretrails; @PluginEventHandler public class UgiDialogue extends Conversation { public static NPCClickHandler talk = new NPCClickHandler(new Object[] { 5141 }, e -> { if (e.getNPC() instanceof Ugi ugi) e.getPlayer().startConversation(new UgiDialogue(e.getPlayer(), ugi)); }); public UgiDialogue(Player player, Ugi ugi) { super(player); if (ugi.getOwner() == player && player.getTreasureTrailsManager().getPhase() == 4) { addNPC(ugi.getId(), HeadE.CHEERFUL, TreasureTrailsManager.UGIS_QUOTES[Utils.random(TreasureTrailsManager.UGIS_QUOTES.length)]); addPlayer(HeadE.CONFUSED, ""What?""); addNext(() -> { ugi.finish(); player.getTreasureTrailsManager().setPhase(5); player.getTreasureTrailsManager().setNextClue(TreasureTrailsManager.SOURCE_EMOTE, false); }); } else addNPC(ugi.getId(), HeadE.CONFUSED, TreasureTrailsManager.UGI_BADREQS); create(); } }" "package com.rs.game.content.minigames.trollinvasion; @PluginEventHandler public class CaptainJute extends Conversation { public static NPCClickHandler handleOps = new NPCClickHandler(new Object[] { 13697 }, e -> { switch(e.getOption()) { case ""Talk-to"" -> e.getPlayer().startConversation(new CaptainJute(e.getPlayer(), e.getNPC())); case ""Start-repairing"" -> e.getPlayer().startConversation(new Dialogue().addNPC(13697, HeadE.FRUSTRATED, ""I'll be in charge of the Troll Invasion defenses once it's implemented!"")); case ""Start-fighting"" -> e.getPlayer().startConversation(new Dialogue().addNPC(13697, HeadE.FRUSTRATED, ""I'll be in charge of the Troll Invasion defenses once it's implemented!"")); case ""Rewards"" -> e.getPlayer().startConversation(new Dialogue().addNPC(13697, HeadE.FRUSTRATED, ""I'll be in charge of the Troll Invasion defenses once it's implemented!"")); } }); public CaptainJute(Player player, NPC npc) { super(player); if (!player.getMiniquestManager().isComplete(Miniquest.TROLL_WARZONE)) { addNext(TrollWarzone.getCaptainJuteDialogue(player, npc)); create(); return; } addNPC(npc, HeadE.HAPPY_TALKING, ""I will be in charge of the Troll Invasion defenses once the minigame gets implemented.""); } }" "package com.rs.game.content.minigames.varrockmuseum; public class VarrockMuseum { /** * Interfaces: * Kudos - 532 * Trivia - 533/534 */ }" "package com.rs.game.content.minigames.vinesweeper; public class Vinesweeper { /** * Interfaces: 684-690 */ }" "package com.rs.game.content.minigames.wguild; public class AnimatedArmor extends OwnedNPC { private final transient Player player; public AnimatedArmor(Player player, int id, Tile tile) { super(player, id, tile, false); this.player = player; } public int[] getDroppedItems() { int index = getId() - 4278; int[] droppedItems = WarriorsGuild.ARMOUR_SETS[index]; return droppedItems; } @Override public void finish() { if (hasFinished()) return; super.finish(); if (player != null) { player.getTempAttribs().removeB(""animator_spawned""); player.setWarriorPoints(3, WarriorsGuild.ARMOR_POINTS[getId() - 4278]); if (!isDead()) for (int item : getDroppedItems()) { if (item == -1) continue; player.getInventory().addItemDrop(item, 1); } } } }" "package com.rs.game.content.minigames.wguild; public class KamfreendaDefender extends Conversation { public KamfreendaDefender(Player player) { super(player); int NPC = 4289; if (WarriorsGuild.getBestDefender(player) == 8844) addNPC(NPC, HeadE.CALM_TALK, ""It seems that you do not have a defender.""); if (WarriorsGuild.getBestDefender(player) != 8844) addNPC(NPC, HeadE.CALM_TALK, ""Ah, I see that you have one of the defenders already! Well done.""); addNPC(NPC, HeadE.CALM_TALK, ""I'll release some cyclopses that might drop the next defender for you. Have fun in there.""); addNPC(NPC, HeadE.CALM_TALK, ""Oh, and be careful; the cyclopses will occasionally summon a cyclossus. They are rather mean and can only be hurt with a rune or dragon defender.""); addNext(()-> player.getInterfaceManager().sendInterface(1058)); create(); } }" "package com.rs.game.content.minigames.wguild; public class WarriorsGuild extends Controller { public transient static WarriorTimer timer; public transient static int killedCyclopses; public transient static int amountOfPlayers; public static void init() { if (timer == null) WorldTasks.scheduleLooping(WarriorsGuild.timer = new WarriorTimer(), 1, 1); } public static class WarriorTimer extends Task { private int ticks; private double lastDummy; public byte projectileType; @Override public void run() { ticks++; if (ticks % 14 == 0) { switchDummyAction(); lastDummy += 0.000000001D; World.sendObjectAnimation(CATAPULT, new Animation(4164)); projectileType = (byte) Utils.random(4); World.sendProjectile(CATAPULT_PROJECTILE_BASE, CATAPULT_TARGET, 679 + projectileType, 85, 15, 15, 0.2, 15, 0); } } private void switchDummyAction() { int index = Utils.random(DUMMY_LOCATIONS.length); World.spawnObjectTemporary(new GameObject(Utils.random(15624, 15630), ObjectType.SCENERY_INTERACT, DUMMY_ROTATIONS[index], DUMMY_LOCATIONS[index]), 10); } } public static final int[] ARMOR_POINTS = { 5, 10, 15, 20, 50, 60, 80 }; public static final int[][] ARMOUR_SETS = { { 1155, 1117, 1075 }, { 1153, 1115, 1067 }, { 1157, 1119, 1069 }, { 1165, 1125, 1077 }, { 1159, 1121, 1071 }, { 1161, 1123, 1073 }, { 1163, 1127, 1079 } }; private static final String[] ARMOUR_TYPE = { ""Bronze"", ""Iron"", ""Steel"", ""Black"", ""Mithril"", ""Adamant"", ""Rune"" }; private static final Tile[] DUMMY_LOCATIONS = { Tile.of(2860, 3549, 0), Tile.of(2860, 3547, 0), Tile.of(2859, 3545, 0), Tile.of(2857, 3545, 0), Tile.of(2855, 3546, 0), Tile.of(2855, 3548, 0), Tile.of(2856, 3550, 0), Tile.of(2858, 3550, 0) }; private static final int[] DUMMY_ROTATIONS = { 1, 1, 2, 2, 3, 3, 0, 0 }; private static final Tile CATAPULT_TARGET = Tile.of(2842, 3541, 1); private static final NPC CATAPULT_PROJECTILE_BASE = new NPC(1957, Tile.of(2842, 3550, 1)); private static final Animation[] DEFENSIVE_ANIMATIONS = { new Animation(4169), new Animation(4168), new Animation(4171), new Animation(4170) }; private static final GameObject CATAPULT = new GameObject(15616, ObjectType.SCENERY_INTERACT, 0, 2840, 3548, 1); private static final Tile SHOTPUT_FACE_18LB = Tile.of(2876, 3549, 1), SHOTPUT_FACE_22LB = Tile.of(2876, 3543, 1); public static final int[] DEFENDERS = { 20072, 8850, 8849, 8848, 8847, 8846, 8845, 8844 }; public static final Tile CYCLOPS_LOBBY = Tile.of(2843, 3535, 2); public static final int STRENGTH = 0, DEFENCE = 1, ATTACK = 2, COMBAT = 3, BARRELS = 4, ALL = 5; private transient byte defensiveStyle; private transient double lastDummy; private transient byte kegCount; private transient int kegTicks; public boolean inCyclopse; private int cyclopseOption; public static boolean canEnter(Player player) { if (player.getSkills().getLevelForXp(Constants.STRENGTH) + player.getSkills().getLevelForXp(Constants.ATTACK) < 130) { player.sendMessage(""You need atleast your attack level + strength level to be above 130 to enter this door.""); return false; } player.getControllerManager().startController(new WarriorsGuild()); player.getMusicsManager().playSpecificAmbientSong(634, true); return true; } @Override public void start() { if (amountOfPlayers == 0) init(); sendInterfaces(); amountOfPlayers++; } @Override public boolean canAttack(Entity target) { if (target instanceof AnimatedArmor npc) if (player != npc.getCombat().getTarget()) return false; return true; } @Override public void sendInterfaces() { if (inCatapultArea(player) && player.getEquipment().getShieldId() == 8856) sendShieldInterfaces(); player.getInterfaceManager().sendOverlay(1057); for (int i = 0; i < player.getWarriorPoints().length; i++) player.refreshWarriorPoints(i); } @Override public void process() { if (player.withinDistance(CATAPULT_TARGET, 0)) { if (timer.ticks % 14 == 0) WorldTasks.schedule(new Task() { @Override public void run() { if (!player.withinDistance(CATAPULT_TARGET, 0)) return; if (defensiveStyle == timer.projectileType) { player.getSkills().addXp(Constants.DEFENSE, 15); player.setWarriorPoints(DEFENCE, 5); player.setNextAnimation(DEFENSIVE_ANIMATIONS[timer.projectileType]); player.sendMessage(""You deflect the incomming attack.""); } else { player.sendMessage(""You fail to deflect the incomming attack.""); player.applyHit(new Hit(player, Utils.random(10, 50), HitLook.TRUE_DAMAGE)); } } }, 12); } else if (kegCount >= 1) { if (kegCount == 5) kegTicks++; if (timer.ticks % 15 == 0) player.setRunEnergy(player.getRunEnergy() - 9); player.drainRunEnergy(1); if ((player.getRunEnergy() / 2.0) <= Math.random() || player.hasWalkSteps() && player.getRun()) { loseBalance(); return; } } else if (cyclopseOption != -1 && inCyclopse) if (timer.ticks % 96 == 0) if (cyclopseOption == ALL) for (int index = 0; index < player.getWarriorPoints().length; index++) player.setWarriorPoints(index, -3); else player.setWarriorPoints(cyclopseOption, -10); } @Override public boolean processNPCClick1(NPC npc) { if (npc.getId() == 4290) player.startConversation(new Shanomi(player)); else if (npc.getId() == 4287) player.startConversation(new Conversation(new Dialogue(new NPCStatement(4287, HeadE.HAPPY_TALKING, player.getInventory().containsItem(8856, 1) ? ""You already have a shield. Good luck!"" : ""Good luck in there!""), () -> { if (!player.getInventory().containsItem(8856, 1)) player.getInventory().addItem(8856, 1); }))); return true; } @Override public boolean processObjectClick1(GameObject object) { if (object.getId() >= 15624 && object.getId() <= 15630) { if (lastDummy == timer.lastDummy) { player.sendMessage(""You have already tagged a dummy.""); return false; } submitDummyHit(object); return false; } if (object.getId() == 15656) { player.getInterfaceManager().sendInterface(412); return false; } if (object.getId() == 66604) { player.getInterfaceManager().sendInterface(410); return false; } else if (object.getId() == 15664 || object.getId() == 15665) { if (player.getTempAttribs().getB(""thrown_delay"")) { int random = Utils.random(3); player.npcDialogue(4300, HeadE.CALM_TALK, random == 0 ? ""Just a moment, I dropped my hanky."" : random == 1 ? ""Pace yourself."" : ""Sorry, I'm not ready yet.""); return false; } else if (!hasEmptyHands()) { player.simpleDialogue(""You must have both your hands free in order to throw a shotput.""); return false; } player.startConversation(new ShotputD(player, object.getId() == 15664)); return false; } else if (object.getId() == 15647 || object.getId() == 15641 || object.getId() == 15644) { player.lock(2); boolean inLobby = player.getY() == object.getY(); if (object.getId() == 15647) if (!inLobby) if (player.getEquipment().getShieldId() == 8856) { Equipment.remove(player, Equipment.SHIELD); closeShieldInterfaces(); } player.addWalkSteps(object.getX(), inLobby ? object.getY() + (object.getId() == 15647 ? 1 : -1) : object.getY(), 1, false); return false; } else if (object.getId() == 15658 || object.getId() == 15660 || object.getId() == 15653 || object.getId() == 66758 && object.getX() == 2861 && object.getY() == 3538 && object.getPlane() == 1) { if (World.isSpawnedObject(object)) return false; if (object.getId() == 15653) player.getControllerManager().forceStop(); else if (object.getId() == 66758 && player.getX() == object.getX()) resetKegBalance(); player.lock(2); player.addWalkSteps(player.getX() == object.getX() ? object.getX() + (object.getId() == 66758 ? -1 : 1) : object.getX(), object.getY(), 1, false); return false; } else if (object.getId() >= 15669 && object.getId() <= 15673) { if (hasEmptyHands() && (player.getEquipment().getHatId() == -1 || kegCount >= 1)) balanceKeg(object); else if (kegCount == 0) player.simpleDialogue(""You must have both your hands and head free to balance kegs.""); return false; } else if (object.getId() == 66599 || object.getId() == 66601) { player.setNextFaceTile(CYCLOPS_LOBBY); boolean withinArea = player.getX() == object.getX(); if (!withinArea) { Doors.handleDoubleDoor(player, object); inCyclopse = false; } else player.startConversation(new KamfreendaDefender(player)); return false; } else if (object.getId() == 56887) { player.simpleDialogue(""Kamfreena reports that "" + killedCyclopses + "" cyclopes have been slain in the guild today. She hopes that warriors will step up and kill more!""); return false; } return true; } @Override public boolean processItemOnObject(final GameObject object, final Item item) { if (object.getId() == 15621) { if (player.getTempAttribs().getB(""animator_spawned"")) { player.sendMessage(""You are already in combat with an animation.""); return false; } int realIndex = getIndex(item.getId()); if (realIndex == -1) return false; for (int armor : ARMOUR_SETS[realIndex]) player.getInventory().deleteItem(armor, 1); player.setNextAnimation(new Animation(827)); player.lock(); final int finalIndex = realIndex; WorldTasks.scheduleLooping(new Task() { int ticks; @Override public void run() { ticks++; if (ticks == 0) player.faceObject(object); else if (ticks == 1) player.simpleDialogue(""The animator hums, something appears to be working.""); else if (ticks == 2) { player.simpleDialogue(""You stand back.""); player.addWalkSteps(player.getX(), player.getY() + 3); } else if (ticks == 3) { player.faceObject(object); player.endConversation(); } else if (ticks == 5) { AnimatedArmor npc = new AnimatedArmor(player, 4278 + finalIndex, object.getTile()); npc.setRun(false); npc.setNextForceTalk(new ForceTalk(""IM ALIVE!"")); npc.setNextAnimation(new Animation(4166)); npc.addWalkSteps(player.getX(), player.getY() + 2); player.getTempAttribs().setB(""animator_spawned"", true); npc.getCombat().setTarget(player); player.unlock(); player.getHintIconsManager().addHintIcon(npc, 0, -1, false); } else if (ticks == 6) { stop(); return; } } }, 1, 1); return false; } return true; } private int getIndex(int checkedId) { for (int i = 0; i < ARMOUR_SETS.length; i++) for (int j = 0; j < ARMOUR_SETS[i].length; j++) if (ARMOUR_SETS[i][j] == checkedId) { for (int k = 0; k < 3; k++) if (!player.getInventory().containsItem(ARMOUR_SETS[i][k], 1)) { player.sendMessage(""You need a full set of "" + ARMOUR_TYPE[i] + "" to use the animator.""); return -1; } return i; } return -1; } private void submitDummyHit(final GameObject object) { player.setNextAnimation(new Animation(PlayerCombatKt.getWeaponAttackEmote(player.getEquipment().getWeaponId(), player.getCombatDefinitions().getAttackStyle()))); WorldTasks.schedule(new Task() { @Override public void run() { if (isProperHit(object)) { player.lock(2); player.getSkills().addXp(Constants.ATTACK, 15); player.setWarriorPoints(ATTACK, 5); player.sendMessage(""You whack the dummy sucessfully!""); lastDummy = timer.lastDummy; } else { player.lock(5); player.applyHit(new Hit(player, 10, HitLook.TRUE_DAMAGE)); player.setNextAnimation(new Animation(424)); player.setNextSpotAnim(new SpotAnim(80, 5, 60)); player.sendMessage(""You whack the dummy whistle using the wrong attack style.""); } } }); } private boolean isProperHit(GameObject object) { AttackStyle style = player.getCombatDefinitions().getAttackStyle(); if (object.getId() == 15624) return style.xpType == XPType.ACCURATE; if (object.getId() == 15625) return style.attackType == AttackType.SLASH; if (object.getId() == 15626) return style.xpType == XPType.AGGRESSIVE; else if (object.getId() == 15627) return style.xpType == XPType.CONTROLLED; else if (object.getId() == 15628) return style.attackType == AttackType.CRUSH; else if (object.getId() == 15629) return style.attackType == AttackType.STAB; else if (object.getId() == 15630) return style.xpType == XPType.DEFENSIVE; return false; } @Override public boolean processButtonClick(int interfaceId, int componentId, int slotId, int slotId2, ClientPacket packet) { if (interfaceId == 411) { if (componentId == 13) defensiveStyle = 0; else if (componentId == 22) defensiveStyle = 1; else if (componentId == 31) defensiveStyle = 2; else if (componentId == 40) defensiveStyle = 3; } else if (interfaceId == 1058) { if (componentId == 22) { cyclopseOption = BARRELS; player.getVars().setVarBit(8668, 5); } else if (componentId == 23) { cyclopseOption = STRENGTH; player.getVars().setVarBit(8668, 3); } else if (componentId == 24) { cyclopseOption = COMBAT; player.getVars().setVarBit(8668, 4); } else if (componentId == 26) { cyclopseOption = DEFENCE; player.getVars().setVarBit(8668, 2); } else if (componentId == 25) { cyclopseOption = ATTACK; player.getVars().setVarBit(8668, 1); } else if (componentId == 3) cyclopseOption = ALL; else if (componentId == 22) { player.getVars().setVarBit(8668, 0); cyclopseOption = -1; } if (componentId == 44) { boolean failure = false; if (cyclopseOption == -1) { player.sendMessage(""You must select an option before proceeding to the cyclopes room.""); return false; } if (cyclopseOption == ALL) { for (int i = 0; i < player.getWarriorPoints().length; i++) if (player.getWarriorPoints()[i] < 30) { failure = true; break; } } else if (player.getWarriorPoints()[cyclopseOption] < 200) failure = true; if (failure) { player.sendMessage(""You don't have enough points to complete this option.""); return false; } if (World.getSpawnedObject(Tile.of(2846, 3535, 2)) != null) return false; Doors.handleDoubleDoor(player, World.getObject(Tile.of(2846, 3535, 2))); player.closeInterfaces(); inCyclopse = true; } } else if (interfaceId == 387 && kegCount >= 1) { if (componentId == 6) { player.sendMessage(""You can't remove the kegs off your head.""); return false; } } else if (interfaceId == 750 && kegCount >= 1) { if (componentId == 4) { player.sendMessage(""You cannot do this action while balancing the kegs on your head.""); return false; } } else if (interfaceId == 271 || interfaceId == 749 && componentId == 4) if (player.getPrayer().isCurses()) { player.sendMessage(""Harllaak frowns upon using curses in the Warrior's Guild.""); return false; } return true; } @Override public boolean canEquip(int slot, int itemId) { if (itemId == 8856) { if (!inCatapultArea(player)) { player.sendMessage(""You need to be near the target before you can equip this.""); return false; } sendShieldInterfaces(); } else if (slot == Equipment.HEAD && kegCount >= 1) return false; return true; } private void closeShieldInterfaces() { player.getInterfaceManager().sendSubDefaults(Sub.ALL_GAME_TABS); } private void sendShieldInterfaces() { player.getInterfaceManager().sendSub(Sub.TAB_QUEST, 411); player.getInterfaceManager().removeSubs(Sub.TAB_COMBAT, Sub.TAB_ACHIEVEMENT, Sub.TAB_SKILLS, Sub.TAB_PRAYER, Sub.TAB_MAGIC, Sub.TAB_EMOTES); player.getInterfaceManager().openTab(Sub.TAB_QUEST); } public static boolean inCatapultArea(Player player) { return player.withinArea(2837, 3538, 2847, 3552) && player.getPlane() == 1; } private boolean hasEmptyHands() { return player.getEquipment().getGlovesId() == -1 && player.getEquipment().getWeaponId() == -1 && player.getEquipment().getShieldId() == -1; } @Override public boolean login() { start(); return false; } @Override public boolean logout() { resetKegBalance(); amountOfPlayers--; return false; } @Override public void onTeleported(TeleType teleType) { player.getControllerManager().forceStop(); } @Override public void forceClose() { resetKegBalance(); inCyclopse = false; cyclopseOption = -1; player.getInterfaceManager().removeOverlay(false); amountOfPlayers--; } public void prepareShotput(final byte stage, final boolean is18LB) { player.lock(7); player.setNextFaceTile(is18LB ? SHOTPUT_FACE_18LB : SHOTPUT_FACE_22LB); if (stage == 0 || stage == 2) player.sendMessage(""You take a deep breath and prepare yourself.""); else if (stage == 1) player.sendMessage(""You take a step and throw the shot as hard as you can.""); if (((double) player.getSkills().getLevel(Constants.STRENGTH) / 100) > Math.random()) { player.sendMessage(""You fumble and drop the shot onto your toe. Ow!""); player.applyHit(new Hit(player, 10, HitLook.TRUE_DAMAGE)); player.unlock(); return; } WorldTasks.scheduleLooping(new Task() { int ticks; @Override public void run() { ticks++; int distance = Utils.random(1, (player.getSkills().getLevel(Constants.STRENGTH) / 10) + (is18LB ? 5 : 3)); if (ticks == 3) { Tile tile = Tile.of(player.getX() + distance, player.getY(), 1); World.sendProjectile(player, tile, 690, 50, 0, 30, 1, 15, 0); } else if (ticks == ((distance / 2) + 4)) { player.getSkills().addXp(Constants.STRENGTH, distance); player.getTempAttribs().setB(""thrown_delay"", true); } else if (ticks >= ((distance / 2) + 5)) { int random = Utils.random(3); if (random == 0) player.sendMessage(""The shot is perfectly thrown and gently drops to the floor.""); else if (random == 1) player.sendMessage(""The shot drops to the floor.""); else player.sendMessage(""The shot falls from the air like a brick, landing with a sickening thud.""); int base = random == 0 ? distance * 7 : random == 1 ? distance * 4 : distance; player.setWarriorPoints(STRENGTH, base + Utils.random(2)); player.getTempAttribs().removeB(""thrown_delay""); stop(); return; } } }, 0, 0); } private void balanceKeg(final GameObject object) { player.lock(4); player.setNextAnimation(new Animation(4180)); WorldTasks.schedule(new Task() { @Override public void run() { if (kegCount == 0) player.getAppearance().setBAS(2671); kegCount++; player.getVars().setVarBit(object.getDefinitions().varpBit, 1); player.getEquipment().setSlot(Equipment.HEAD, new Item(8859 + kegCount)); player.getEquipment().refresh(Equipment.HEAD); player.getAppearance().generateAppearanceData(); } }, 2); } private void loseBalance() { player.setNextSpotAnim(new SpotAnim(689 - kegCount)); player.lock(2); player.applyHit(new Hit(null, Utils.random(20, 40), HitLook.TRUE_DAMAGE)); player.sendMessage(""You lose balance and the kegs fall onto your head.""); player.setNextForceTalk(new ForceTalk(""Ouch!"")); if (kegCount != 1) { player.getSkills().addXp(Constants.STRENGTH, 10 * kegCount); player.setWarriorPoints(BARRELS, (10 * kegCount) + (kegTicks / 2)); } resetKegBalance(); } private void resetKegBalance() { if (kegCount >= 1) { player.getEquipment().setSlot(Equipment.HEAD, null); player.getEquipment().refresh(Equipment.HEAD); player.getAppearance().generateAppearanceData(); player.getAppearance().setBAS(-1); } kegCount = 0; kegTicks = 0; for (int i = 0; i < 6; i++) player.getVars().setVarBit(2252 + i, 0); } public static int getBestDefender(Player player) { for (int index = 0; index < DEFENDERS.length; index++) if (player.getEquipment().getShieldId() == DEFENDERS[index] || player.getInventory().containsItem(DEFENDERS[index], 1)) return DEFENDERS[index - 1 < 0 ? 0 : index - 1]; return DEFENDERS[7]; } }" "package com.rs.game.content.minigames.wguild; @PluginEventHandler public class WGCyclops extends NPC { public WGCyclops(int id, Tile tile) { super(id, tile); } @Override public void drop(Player killer) { super.drop(killer); WarriorsGuild.killedCyclopses++; if (killer.getControllerManager().getController() != null && killer.getControllerManager().getController() instanceof WarriorsGuild wguild) if (wguild.inCyclopse) { if (Utils.random(50) == 0) sendDrop(killer, new Item(WarriorsGuild.getBestDefender(killer))); } else killer.sendMessage(""Your time has expired and the cyclops will no longer drop defenders.""); } public static NPCInstanceHandler toFunc = new NPCInstanceHandler(new Object[] { 4291, 4292, 6078, 6079, 6080, 6081 }, WGCyclops::new); }" "package com.rs.game.content.miniquests.abyss class AbyssalBook : Book(""Abyssal Research Notes"", BookPage( arrayOf( ""A Compendium of Research"", ""Into Chaotic Space."", """", ""Author Unknown"", """", """", ""The strange dimension that"", ""we have named 'Abyssal Space'"", ""is something of an enigma."", """", ""It was first discovered during"", ""a routine teleportation"", ""experiment that seemingly"", ""went wrong."" ), arrayOf( ""We are still not sure as to"", ""what caused this teleportation"", ""failure, but the discovery of a"", ""previously unknown dimension"", ""led to a flurry of research"", ""from the Zamorakian Magical"", ""Institute (henceforth known"", ""within this document as"", ""the Z.M.I.)."", """", ""Under direct orders to"", ""examine this dimension, I"", ""feel I can accurately state"", ""the following conclusions."" ) ), BookPage( arrayOf( ""Conclusion One"", """", """", ""Abyssal Space is not a"", ""dimension in the way that we"", ""understand the term from"", ""examples such as Zanaris or"", ""Freneskrae."", """", ""Rather, it is the name we"", ""have given the dimension that"", ""exists between other more"", ""developed dimensions - the"", ""'glue' that keeps each"", ""dimension together yet"", ), arrayOf( ""separate, if you will."", """", ""The Abyssal space's existence"", ""at the 'fringe' of reality,"", ""means that it does not"", ""conform to the same"", ""guidelines of space and time"", ""as Gielinor does; you may"", ""enter it and then leave it from "", ""an identical spot, yet reappear"", ""many hundreds of miles away at"", ""your target destination (the"", ""'teleportation phenomenon that"", ""we use daily)."" ) ), BookPage( arrayOf( ""From this basic concept, I"", ""have extrapolated that all"", ""teleport magics in fact use"", ""Abyssal Space to make the"", ""passing of a great distances"", ""occur in a very short space"", ""of time, from our perception."", """", ""What is actually happening,"", ""is that the spellcaster is"", ""entering abyssal space, and"", ""then immediately leaving"", ""again, with certain values"", ""as to speed and direction"" ), arrayOf( ""being taken care of in our"", ""spellcasting to allow some"", ""degree of precision in these"", ""teleports."", """", ""More worryingly, it seems"", ""apparent that the barriers"", ""between our dimensional"", ""space and abyssal space have"", ""become somewhat weakened"", ""through excessive use."", ) ), BookPage( arrayOf( ""There have been isolated"", ""reports within the Z.M.I."", ""that creatures not native"", ""to our dimension have"", ""entered Gielinor through"", ""abyssal space, as well as"", ""the teleportation malfunction"", ""that first resulted in our"", ""discovery of this dimension."", """", ""I strongly recommend that"", ""further research is"", ""taken - if the barriers"", ""between these dimensions"", ), arrayOf( ""are sufficiently weakened,"", ""there may exist the"", ""possibility of an alternative"", ""method to proceed with"", ""Operation: Transient without"", ""alerting the other deities"", ""to our plans."" ) ), BookPage( arrayOf( ""Conclusion Two"", """", """", ""When we have accepted"", ""that Abyssal Space is"", ""somewhat of a tesseract"", ""or hypercube with a"", ""direct relation to our"", ""dimension, then the"", ""benefits of exploiting this"", ""resource become more"", ""obvious."" ), arrayOf( ""Certain creatures of the"", ""abyss contain unnecessary"", ""surplus organs that may"", ""be harvested to provide"", ""carrying pouches for"", ""various magically-unstable"", ""objects."", """", ""I ran some experiments"", ""with Sample XJ13 (also"", ""known as 'rune essence')"", ""and managed to place six"", ""parts in a space that would"", ""seemingly only hold one."" ) ), BookPage( arrayOf( ""Continued experimentation"", ""with these stolen samples"", ""showed that moving items"", ""between our dimension and"", ""abyssal space degraded"", ""the use of these pouches,"", ""but a simple"", ""transfiguration spell"", ""when cast within the"", ""abyss upon these pouches"", ""restored their usage back"", ""to the original results."" ), arrayOf( ""Should we ever locate the"", ""source of these 'essences'"", ""that the Wizards Tower"", ""seem to have an endless"", ""supply of, I would"", ""strongly recommend the"", ""harvesting of these"", ""creatures for their organs"", ""so as to maximise the"", ""efficiency of our rune"", ""manufacturing process."", ) ), BookPage( arrayOf( ""Some degree of caution"", ""will be necessary, as the"", ""creatures of the abyss"", ""are seemingly very"", ""aggressive."" ), arrayOf( ""Conclusion Three"", """", """", ""Our first discovery of"", ""Abyssal Space was"", ""somewhat of a fluke - and"", ""a not easily repeatable"", ""fluke at that."", """", ""It proved exceedingly"", ""difficult to find the"", ""correct mystical"", ""resonance for this"" ) ), BookPage( arrayOf( ""dimension, due to my"", ""original believe that Abyssal"", ""space is not a fully"", ""fledged dimension of its"", ""own, so we have had to"", ""resort to unusual"", ""measures to gain"", ""permanent access to this"", ""realm."", """", ""We took a large number"", ""of initiates, and gave them"", ""each supplies to cast a"" ), arrayOf( ""portal spell. We then had"", ""them repeatedly teleport"", ""to various locations,"", ""seeking to replicate the"", ""original error that caused"", ""the first entry into"", ""Abyssal Space."", """", ""Once one of our initiates"", ""had managed to 'fail' his"", ""teleport and appear in"", ""Abyssal Space, he was"", ""then charged with"", ) ), BookPage( arrayOf( ""remaining there and"", ""holding a portal spell open,"", ""so that the more senior"", ""members of the Z.M.I."", ""could gain entry via his"", ""portal."", """", ""This initiate is still there,"", ""and due to the intense"", ""concentration required to"", ""keep the portal open, it is"", ""my recommendation that"", ""we leave him there"", ""holding the bridge open"", ""for us."" ), arrayOf( ""As an initiate, he is"", ""always expendable should"", ""something go wrong, and"", ""the slow passage of time"", ""within Abyssal Space"", ""means we don't need to"", ""worry about feeding him"", ""or anything."", """", ""At the time of writing,"", ""this portal is still active,"", ""and will allow us to"" ) ), BookPage( arrayOf( ""teleport people at will into"", ""Abyssal Space."", """", ""The only downside to this"", ""method of teleportation is"", ""that we are using magic"", ""provided to us by our"", ""Lord Zamorak himself, so"", ""anybody who uses this"", ""teleport will inevitably be"", ""marked by him - or"", ""become 'skulled' as the"", ""common folk put it."" ), arrayOf( ""An interesting side-effect"", ""of this portal, is that"", ""various teleports within"", ""Abyssal Space were"", ""opened up by its casting."", ""These teleports seem to"", ""lead to mysterious"", ""temples dedicated to"", ""various magical elements,"", ""which I believe are"", ""directly related to the"", ""rumours we have"", ""intercepted of the"" ) ), BookPage( arrayOf( ""rediscovery of"", ""RuneCrafting by the"", ""Wizards Tower."", """", ""Sadly, we must conclude"", ""from these temples that"", ""the rumours are indeed"", ""true, and that the"", ""destruction of the"", ""Wizards Tower had been"", ""in vain, as was the"", ""sacrifice of those who died"", ""to try and prevent the"" ), arrayOf( ""meddling Saradominists"", ""from gaining access to"", ""the creation of magical"", ""runes."", """", ""I have detailed my"", ""findings relating to"", ""RuneCrafting in a"", ""separate document, and"", ""passed it on to my"", ""superiors, along with my"", ""recommendations on how"", ""best to thwart their"", ""research further."" ) ), BookPage( arrayOf( ""Until a final decision is"", ""taken, I suggest we make"", ""the best of a bad"", ""situation, and increase"", ""our own rune production"", ""to full manufacturing"", ""capabilities."", """", ""I have already ordered"", ""buyers to purchase as"", ""much Sample XJ13 as"", ""can be bought, and to"", ""hire some mercenaries to"", ""sabotage the research"" ), arrayOf( ""efforts of the Wizards"", ""Tower, or failing that to"", ""provide us some insight"", ""into where their steady"", ""supplies of these essence"", ""are coming from."" ) ), BookPage( arrayOf( ""Until my next report, I"", ""remain as ever a loyal"", ""servant."", """", ""Strength Through Chaos!"" ), arrayOf() ) )" "package com.rs.game.content.miniquests.abyss @ServerStartupEvent fun mapEnterTheAbyss() { onNpcClick(2257) { (player, npc, option) -> when (option) { ""Talk-to"" -> mapMageDialogue(player, npc) ""Trade"" -> ShopsHandler.openShop(player, ""zamorak_mage_shop"") ""Teleport"" -> Abyss.teleport(player, npc) } } onNpcClick(2260) { (player, npc) -> ZamorakMageD(player, npc) } onItemClick(5520, options = arrayOf(""Read"")) { e -> if (e.player.miniquestManager.getStage(Miniquest.ENTER_THE_ABYSS) == EnterTheAbyss.COMPLETED) e.player.openBook(AbyssalBook()) else e.player.sendMessage(""You don't seem to understand what this book is about."") } } @MiniquestHandler( miniquest = Miniquest.ENTER_THE_ABYSS, startText = ""The Mage of Zamorak at the beginning of the above-ground River Lum in the Wilderness (roams levels 4-7)."", itemsText = ""None"", combatText = ""None"", rewardsText = ""1,000 Runecrafting XP
Small pouch
Abyssal book
Access to the Abyss."", completedStage = EnterTheAbyss.COMPLETED ) class EnterTheAbyss : MiniquestOutline() { override fun getJournalLines(player: Player, stage: Int): List { val lines = ArrayList() when (stage) { NOT_STARTED -> { lines.add(""I can start this miniquest by speaking to the Zamorakian mage in the"") lines.add(""wilderness north of Edgeville."") lines.add("""") } MEET_IN_VARROCK -> { lines.add(""I spoke to the Zamorakian mage in the wilderness north of Edgeville."") lines.add(""He told me I should meet him in Varrock."") lines.add("""") } SCRYING_ORB -> { lines.add(""I was given a scrying orb and told to enter the rune essence mines"") lines.add(""via 3 different teleport methods to gather data on the teleport matrix."") lines.add("""") } COMPLETED_SCRYING_ORB -> { lines.add(""I gave the mage the scrying orb and he told me to speak to him after"") lines.add(""he's finished gathering the data from it. I should speak to him again."") lines.add("""") } COMPLETED -> { lines.add("""") lines.add("""") lines.add(""MINIQUEST COMPLETE!"") } else -> lines.add(""Invalid quest stage. Report this to an administrator."") } return lines } override fun complete(player: Player) { player.skills.addXpQuest(Skills.RUNECRAFTING, 1000.0) player.inventory.addItemDrop(5509, 1) player.inventory.addItemDrop(5520, 1) sendQuestCompleteInterface(player, 5509) } override fun updateStage(player: Player) { player.vars.setVar(492, player.miniquestManager.getStage(Miniquest.ENTER_THE_ABYSS)) } companion object { const val NOT_STARTED: Int = 0 const val MEET_IN_VARROCK: Int = 1 const val SCRYING_ORB: Int = 2 const val COMPLETED_SCRYING_ORB: Int = 3 const val COMPLETED: Int = 4 } } fun mapMageDialogue(player: Player, npc: NPC) { val miniquestStage = player.miniquestManager.getStage(Miniquest.ENTER_THE_ABYSS) player.startConversation { when (miniquestStage) { EnterTheAbyss.NOT_STARTED -> { player(HeadE.CONFUSED, ""Hello there, what are you doing here?"") npc(npc, HeadE.SECRETIVE, ""I am researching an interesting phenomenon I call the 'Abyss' and selling runes."") player(HeadE.CONFUSED, ""Where do you get your runes?"") npc(npc, HeadE.FRUSTRATED, ""This is no place to talk! Meet me at the Varrock Chaos Temple!"") { player.miniquestManager.setStage(Miniquest.ENTER_THE_ABYSS, EnterTheAbyss.MEET_IN_VARROCK) } } EnterTheAbyss.MEET_IN_VARROCK, EnterTheAbyss.SCRYING_ORB, EnterTheAbyss.COMPLETED_SCRYING_ORB -> { npc(npc, HeadE.FRUSTRATED, ""This is no place to talk! Meet me at the Varrock Chaos Temple!"") } EnterTheAbyss.COMPLETED -> { npc(npc, HeadE.FRUSTRATED, ""This is no place to talk! If you need help getting out of my sight I can send you to the Abyss?"") } } } }" "package com.rs.game.content.miniquests.abyss class ZamorakMageD(p: Player, npc: NPC) { init { p.startConversation { if (p.miniquestManager.getStage(Miniquest.ENTER_THE_ABYSS) == EnterTheAbyss.NOT_STARTED) { npc(npc, HeadE.FRUSTRATED, ""Ah, you again. What was it you wanted? The Wilderness is hardly the appropriate place for a conversation now, is it?"") } when (p.miniquestManager.getStage(Miniquest.ENTER_THE_ABYSS)) { EnterTheAbyss.SCRYING_ORB -> { npc(npc, HeadE.CONFUSED, ""Well? Have you managed to use my scrying orb to obtain the information yet?"") if (!p.inventory.containsOneItem(5518, 5519)) { player(HeadE.WORRIED, ""Uh... No.... I kind of lost that orb thingy that you gave me..."") npc(npc, HeadE.FRUSTRATED, ""What? Incompetent fool. Take this. And do not make me regret allying myself with you."") { p.inventory.addItemDrop(5519, 1) } return@startConversation } if (p.inventory.containsItem(5518, 1)) { player(HeadE.CHEERFUL, ""Yes I have! I've got it right here!"") npc(npc, HeadE.SKEPTICAL, ""Excellent. Give it here, and I shall examine the findings. Speak to me in a small while."") { p.inventory.deleteItem(5518, 28) p.inventory.deleteItem(5519, 28) p.miniquestManager.setStage(Miniquest.ENTER_THE_ABYSS, EnterTheAbyss.COMPLETED_SCRYING_ORB) } return@startConversation } player(HeadE.WORRIED, ""No... Actually, I had something I wanted to ask you..."") npc(npc, HeadE.FRUSTRATED, ""I assumed the task to be self-explanatory. What is it you wish to know?"") } EnterTheAbyss.COMPLETED_SCRYING_ORB -> { player(HeadE.CONFUSED, ""So... that's my end of the deal upheld. What do I get in return?"") npc(npc, HeadE.CALM_TALK, ""Indeed. A deal is always a deal. I offer you three things as a reward for your efforts on behalf of my Lord Zamorak; The first is knowledge. I offer you my collected research on the abyss. "") npc(npc, HeadE.CALM_TALK, ""I also offer you 1,000 points of experience in RuneCrafting for your trouble. Your second gift is convenience. Here, you may take this pouch I discovered amidst my research."") npc(npc, HeadE.CALM_TALK, ""You will find it to have certain... interesting properties. Your final gift is that of movement. I will from now on offer you a teleport to the abyss whenever you should require it."") player(HeadE.CONFUSED, ""Huh? Abyss? What are you talking about? You told me that you would help me with RuneCrafting!"") npc(npc, HeadE.CALM_TALK, ""And so I have done. Read my research notes, they may enlighten you somewhat."") exec { p.miniquestManager.complete(Miniquest.ENTER_THE_ABYSS) } return@startConversation } } label(""startOptions"") options { when (p.miniquestManager.getStage(Miniquest.ENTER_THE_ABYSS)) { EnterTheAbyss.MEET_IN_VARROCK -> { if (p.isQuestComplete(Quest.RUNE_MYSTERIES)) { op(""Where do you get your runes from?"") { player(HeadE.CONFUSED, ""Where do you get your runes from? No offence, but people around here don't exactly like 'your type'."") npc(npc, HeadE.FRUSTRATED, ""My 'type'? Explain."") player(HeadE.SKEPTICAL_THINKING, ""You know... Scary bearded men in dark clothing with unhealthy obsessions with destruction and stuff."") npc(npc, HeadE.CALM_TALK, ""Hmmm. Well, you may be right, the foolish Saradominists that own this pathetic city don't appreciate loyal Zamorakians, it is true."") player(HeadE.SKEPTICAL, ""So you can't be getting your runes anywhere around here..."") npc(npc, HeadE.SECRETIVE, ""That is correct, stranger. The Zamorakian Brotherhood has a method of manufacturing runes that it keeps a closely guarded secret."") player(HeadE.CHEERFUL, ""Oh, you mean the whole teleporting to the rune essence mine, mining some essence, then using the talismans to locate the Rune Temples, then binding runes there? I know all about it..."") npc(npc, HeadE.AMAZED, ""WHAT? I... but... you... Tell me, this is important: You have access to the rune essence mine? The Saradominist wizards will cast their teleport spell for you?"") player(HeadE.CONFUSED, ""You mean they won't cast it for you?"") npc(npc, HeadE.FRUSTRATED, ""No, not at all. Ever since the Saradominist wizards betrayed us a hundred years ago and blamed us for the destruction of the Wizards' Tower, they have refused to share information with our order."") npc(npc, HeadE.FRUSTRATED, ""We occasionally manage to plunder small samples of rune essence but we have had to make do without a reliable supply. But if they trust you...this changes everything."") player(HeadE.CONFUSED, ""How do you mean?"") npc(npc, HeadE.CALM_TALK, ""For many years there has been a struggle for power on this world."") npc(npc, HeadE.CALM_TALK, ""You may dispute the morality of each side as you wish, but the stalemate that exists between my Lord Zamorak and that pathetic meddling fool Saradomin has meant that our struggles have become more secretive."") npc(npc, HeadE.CALM_TALK, ""We exist in a 'cold war' if you will, each side fearful of letting the other gain too much power, and each side equally fearful of entering into open warfare for fear of bringing our struggles to the attention of... other beings."") player(HeadE.CONFUSED, ""You mean Guthix?"") npc(npc, HeadE.CALM_TALK, ""Indeed. Amongst others. But since the destruction of the first Tower the Saradominist wizards have had exclusive access to the rune essence mine, which has shifted the balance of power dangerously towards one side."") npc(npc, HeadE.CALM_TALK, ""I implore you adventurer, you may or may not agree with my aims, but you cannot allow such a shift in the balance of power to continue."") npc(npc, HeadE.CONFUSED, ""Will you help me and my fellow Zamorakians to access the essence mine? In return I will share with you the research we have gathered."") options(""Help the Zamorakian mage?"") { op(""Yes"") { player(HeadE.CALM_TALK, ""Okay, I'll help you. What can I do?"") npc(npc, HeadE.CALM_TALK, ""All I need from you is the spell that will teleport me to this essence mine. That should be sufficient for the armies of Zamorak to once more begin stockpiling magic for war."") player(HeadE.SKEPTICAL_THINKING, ""Oh. Erm.... I don't actually know that spell."") npc(npc, HeadE.CONFUSED, ""What? Then how do you access this location?"") player(HeadE.CHEERFUL, ""Oh, well, people who do know the spell teleport me there directly. Apparently they wouldn't teach it to me to try and keep the location secret."") npc(npc, HeadE.FRUSTRATED, ""Hmmm. Yes, yes I see. Very well then, you may still assist us in finding this mysterious essence mine."") player(HeadE.CONFUSED, ""How would I do that?"") npc(npc, HeadE.CALM_TALK, ""Here, take this scrying orb. I have cast a standard cypher spell upon it, so that it will absorb mystical energies that it is exposed to."") npc(npc, HeadE.CALM_TALK, ""Bring it with you and teleport to the rune essence location, and it will absorb the mechanics of the spell and allow us to reverse-engineer the magic behind it."") npc(npc, HeadE.CALM_TALK, ""The important part is that you must teleport to the essence location from three entirely separate locations."") npc(npc, HeadE.CALM_TALK, ""More than three may be helpful to us, but we need a minimum of three in order to triangulate the position of this essence mine."") npc(npc, HeadE.CONFUSED, ""Is that all clear, stranger?"") { p.miniquestManager.setStage(Miniquest.ENTER_THE_ABYSS, EnterTheAbyss.SCRYING_ORB) p.inventory.addItemDrop(5519, 1) } player(HeadE.CALM_TALK, ""Yeah, I think so."") npc(npc, HeadE.CALM_TALK, ""Good. If you encounter any difficulties speak to me again."") } op(""No"") { player(HeadE.CALM, ""Sorry, no."") } } } } } EnterTheAbyss.SCRYING_ORB -> { op(""What am I supposed to be doing again?"") { player(HeadE.CONFUSED, ""Please excuse me, I have a very bad short term memory. What exactly am I supposed to be doing again?"") npc(npc, HeadE.FRUSTRATED, ""I am slightly concerned about your capability for this mission, if you cannot even recall such a simple task..."") npc(npc, HeadE.CALM_TALK, ""All I wish for you to do is to teleport to this 'rune essence' location from three different locations while carrying the scrying orb I gave you."") npc(npc, HeadE.CALM_TALK, ""It will collect the data as you teleport, and if you then bring it to me I will be able to use it to further my own investigations."") player(HeadE.CONFUSED, ""So you want me to teleport to the rune essence mine while carrying the scrying ball?"") npc(npc, HeadE.CALM_TALK, ""That is correct."") player(HeadE.CONFUSED, ""And I need to teleport into the essence mine from three different locations?"") npc(npc, HeadE.CALM_TALK, ""That is also correct."") player(HeadE.SKEPTICAL_THINKING, ""Okay... I think I understand that..."") npc(npc, HeadE.CONFUSED, ""That is good to know. Is there something else you need clarifying?"") goto(""startOptions"") } op(""What's in this for me, anyway?"") { player(HeadE.CONFUSED, ""I just want to know one thing: What's in this for me?"") npc(npc, HeadE.LAUGH, ""Well now, I can certainly understand that attitude."") npc(npc, HeadE.CALM_TALK, ""From what you tell me, the Saradominist wizards have given you access to the rune essence mine, but your method of reaching the temples used to bind this essence is random and counter-productive."") npc(npc, HeadE.CALM_TALK, ""I, on the other hand, have information on quickly accessing these temples, yet my methods of procuring essence are time consuming and useless as a means of mass production."") npc(npc, HeadE.CALM_TALK, ""I think you can see for yourself how this may benefit both of us: you allow me the knowledge of finding plentiful essence, and I will in return show you the secret of these temples."") player(HeadE.CALM_TALK, ""Yeah, okay, fair enough."") npc(npc, HeadE.CONFUSED, ""Was there anything else?"") goto(""startOptions"") } op(""You're not going to use this for evil are you?"") { player(HeadE.CONFUSED, ""If I help you with this... I'd just like to keep my conscience clear and know that you're not going to use whatever information I give to you in the pursuit of evil and badness and stuff."") npc( npc, HeadE.SKEPTICAL_THINKING, ""Very well, if it makes you feel any better; I promise you that any knowledge you provide me with, absolutely will not be used in the service of anything more evil than what I was already planning on doing anyway. I hope that sets your conscience at rest."" ) player(HeadE.CONFUSED, ""You know... In a weird way it actually does..."") npc(npc, HeadE.CALM_TALK, ""Excellent. Was there anything else?"") goto(""startOptions"") } } } op(""All hail Zamorak!"") { player(HeadE.CHUCKLE, ""All hail Zamorak! He's the man! If he can't do it, maybe some other guy can!"") npc(npc, HeadE.SECRETIVE, ""...Okay. I appreciate your enthusiasm for Lord Zamorak stranger, but what exactly was it that you wanted?"") goto(""startOptions"") } op(""Nothing, thanks."") { player(HeadE.CALM_TALK, ""I didn't really want anything, thanks. I just like talking to random people I meet around the world."") npc(npc, HeadE.SECRETIVE, ""...I see. Well, in the future, do not waste my time, or you will feel the wrath of Zamorak upon you."") } } } } }" "package com.rs.game.content.miniquests.bar_crawl class BarbarianGuardD(p: Player) { init { p.startConversation { when (p.miniquestManager.getStage(Miniquest.BAR_CRAWL)) { BarCrawl.NOT_STARTED -> { npc(BARBARIAN_GUARD_ID, HeadE.FRUSTRATED, ""Oi, whaddya want?"") options { op(""I want to come through this gate."") { player(HeadE.CONFUSED, ""I want to come through this gate."") npc(BARBARIAN_GUARD_ID, HeadE.FRUSTRATED, ""Barbarians only. Are you a barbarian? You don't look like one."") options { op(""Hmm, yep you've got me there."") { player(HeadE.SAD, ""Hmm, yep you've got me there."") } op(""Looks can be deceiving, I am in fact a barbarian."") { player(HeadE.SECRETIVE, ""Looks can be deceiving, I am in fact a barbarian."") npc(BARBARIAN_GUARD_ID, HeadE.CHEERFUL, ""If you're a barbarian you need to be able to drink like one. We barbarians like a good drink."") exec { if (p.inventory.hasFreeSlots()) { npc(BARBARIAN_GUARD_ID, HeadE.CHEERFUL, ""I have the perfect challenge for you... The Alfred Grimhand Barcrawl! First completed by Alfred Grimhand."") item(BARCRAWL_CARD_ID, ""The guard hands you a Barcrawl card."") { giveNewCard(p) } npc(BARBARIAN_GUARD_ID, HeadE.CHEERFUL, ""Take that card to each of the bars named on it. The bartenders will know what it means. We're kinda well known."") npc(BARBARIAN_GUARD_ID, HeadE.CHEERFUL, ""They'll give you their strongest drink and sign your card. When you've done all that, we'll be happy to let you in."") } else { npc(BARBARIAN_GUARD_ID, HeadE.CHEERFUL, ""I have the perfect challenge for you, but you'll need at least 1 free inventory slot."") } } } } } op(""I want some money."") { player(HeadE.CHEERFUL, ""I want some money."") npc(BARBARIAN_GUARD_ID, HeadE.ANGRY, ""Do I look like a bank to you?"") } } } RECEIVED_CRAWL_CARD -> { npc(BARBARIAN_GUARD_ID, HeadE.CHEERFUL, ""So, how's the Barcrawl coming along?"") exec { if (!hasCard(p)) { if (!p.bank.containsItem(BARCRAWL_CARD_ID) && p.inventory.hasFreeSlots()) { player(HeadE.WORRIED, ""I've lost my barcrawl card..."") npc(BARBARIAN_GUARD_ID, HeadE.CHEERFUL, ""What are you like? You're gonna have to start all over now."") item(BARCRAWL_CARD_ID, ""The guard hands you a Barcrawl card."") { giveNewCard(p) } } else if (!p.inventory.hasFreeSlots()) { npc(BARBARIAN_GUARD_ID, HeadE.CHEERFUL, ""What are you like? You'll need at least 1 free inventory slot before I can give you another."") } else if (p.bank.containsItem(BARCRAWL_CARD_ID)) { player(HeadE.CHEERFUL, ""Not too bad, my barcrawl card is in my bank right now."") npc(BARBARIAN_GUARD_ID, HeadE.LAUGH, ""You need it with you when you are going on a barcrawl."") } } else { if (!allBarsVisited(p)) { player(HeadE.WORRIED, ""I haven't finished it yet."") npc(BARBARIAN_GUARD_ID, HeadE.CHEERFUL, ""Well come back when you have, you lightweight."") } else { player(HeadE.DRUNK, ""I think I just 'bout done them all... but I lost count..."") item(BARCRAWL_CARD_ID, ""You give the card to the barbarian."") npc(BARBARIAN_GUARD_ID, HeadE.CHEERFUL, ""Yep that seems fine, you can come in now. I never learned to read, but you look like you've drunk plenty."") exec { p.inventory.removeAllItems(BARCRAWL_CARD_ID) p.bank.removeItem(BARCRAWL_CARD_ID) p.miniquestManager.complete(Miniquest.BAR_CRAWL) } } } } } COMPLETED -> { npc(BARBARIAN_GUARD_ID, HeadE.CHEERFUL, ""Ello friend."") } } } } private fun giveNewCard(p: Player) { p.inventory.addItem(BARCRAWL_CARD_ID, 1) p.miniquestManager.setStage(Miniquest.BAR_CRAWL, RECEIVED_CRAWL_CARD) resetAllBars(p) } }" "package com.rs.game.content.miniquests.bar_crawl @ServerStartupEvent fun mapBarCrawl() { onNpcClick(BARBARIAN_GUARD_ID) { (player, _, _) -> BarbarianGuardD(player) } onItemClick(BARCRAWL_CARD_ID, options = arrayOf(""Read"")) { e -> if (allBarsVisited(e.player)) { e.player.sendMessage(""You are too drunk to be able to read the barcrawl card."") } else { displayBarcrawlInterface(e.player) } } onObjectClick(2115, 2116) { (player, obj) -> if (!completedBarCrawl(player)) { player.sendMessage(""You should speak to one of the Barbarian guards first, before trying to go through these gates."") return@onObjectClick } Doors.handleDoubleDoor(player, obj) } onLogin { (player) -> if (player.inArea(2546, 3560, 2555, 3573) || player.inArea(2529, 3542, 2552, 3556) || player.inArea(2546, 3542, 2553, 3559) || player.inArea(2545, 9947, 2556, 9956)) { if (!completedBarCrawl(player)) { player.fadeScreen { player.tele(2543, 3569, 0) player.sendMessage(""You are escorted out of the Barbarian Outpost, because you have not yet completed the Alfred Grimhand's Barcrawl miniquest."") } } } } } @MiniquestHandler( miniquest = Miniquest.BAR_CRAWL, startText = ""The Barbarian Guards outside the Barbarian Outpost in Kandarin."", itemsText = ""208 gold coins."", combatText = ""None."", rewardsText = ""Access to the Barbarian Outpost.
Access to the Barbarian Agility Course."", completedStage = BarCrawl.COMPLETED ) class BarCrawl : MiniquestOutline() { companion object { const val BARCRAWL_CARD_ID = 455 const val BARBARIAN_GUARD_ID = 384 const val NOT_STARTED = 0 const val RECEIVED_CRAWL_CARD = 1 const val COMPLETED = 2 @JvmStatic fun hasCard(player: Player): Boolean { return player.inventory.containsItem(BARCRAWL_CARD_ID) } @JvmStatic fun displayBarcrawlInterface(player: Player) { player.packets.setIFText(220, 1, ""The Official Alfred Grimhand Barcrawl!"") for (i in 0 until BarCrawlBars.Bars.entries.size) { val bar = BarCrawlBars.Bars.entries[i] val complete = isBarVisited(player, bar) val text = ((if (complete) ""${bar.barName}"" else ""${bar.barName}"")) player.packets.setIFText(220, 3 + i, text) } player.interfaceManager.sendInterface(220) } } override fun getJournalLines(player: Player, stage: Int): List { val lines = ArrayList() when (stage) { NOT_STARTED -> { lines.add(""I can start this miniquest by speaking to the Barbarian guards"") lines.add(""outside the Barbarian Outpost."") } RECEIVED_CRAWL_CARD -> { lines.add(""The Barbarian Guard said I couldn't enter the Outpost unless"") lines.add(""I completed their challenge - a barcrawl!"") lines.add("""") lines.add(""I must visit each of the bars on my barcrawl card and"") lines.add(""try their strongest drinks."") lines.add("""") lines.add(""Once done, I should let the Barbarian Guard know."") } COMPLETED -> { lines.add("""") lines.add("""") lines.add(""MINIQUEST COMPLETE!"") } else -> lines.add(""Invalid miniquest stage. Report this to an administrator."") } return lines } override fun complete(player: Player) { sendQuestCompleteInterface(player, BARCRAWL_CARD_ID) } override fun updateStage(player: Player) { } interface Effects { fun effect(player: Player) fun message(player: Player, start: Boolean) } object BarCrawlBars { enum class Bars( val barName: String, val price: Int, val effect: Effects, val drinkName: String ) { BLUE_MOON_INN(""Blue Moon Inn (Varrock)"", 50, BlueMoonInnEffect(), ""Uncle Humphrey's Gutrot""), BLURBERRYS_BAR(""Blurberry's Bar (Tree Gnome Stronghold)"", 10, BlurberrysBarEffect(), ""Fire Toad Blast""), DEAD_MANS_CHEST(""Dead Man's Chest (Brimhaven)"", 15, DeadMansChestEffect(), ""Supergrog""), DRAGON_INN(""Dragon Inn (Yanille)"", 12, DragonInnEffect(), ""Fire Brandy""), FLYING_HORSE_INN(""Flying Horse Inn (Ardougne)"", 8, FlyingHorseInnEffect(), ""Heart Stopper""), FORESTERS_ARMS(""Forester's Arms (Seers' Village)"", 18, ForestersArmsEffect(), ""Liverbane Ale""), JOLLY_BOAR_INN(""Jolly Boar Inn (north-east of Varrock)"", 10, JollyBoarInnEffect(), ""Olde Suspiciouse""), KARAMJA_SPIRITS(""Karamja Spirits Bar (Musa Point)"", 7, KaramjaSpiritsEffect(), ""Ape Bite Liqueur""), RISING_SUN(""Rising Sun (Falador)"", 70, RisingSunEffect(), ""Hand of Death Cocktail""), RUSTY_ANCHOR(""Rusty Anchor (Port Sarim)"", 8, RustyAnchorEffect(), ""Black Skull Ale"") } private val visitedBars = mutableMapOf() @JvmStatic fun resetAllBars(player: Player) { player.miniquestManager.getAttribs(Miniquest.BAR_CRAWL).clear() } @JvmStatic fun isBarVisited(player: Player, bars: Bars): Boolean { return player.miniquestManager.getAttribs(Miniquest.BAR_CRAWL).getB(bars.barName) } @JvmStatic fun setBarVisited(player: Player, bars: Bars, visited: Boolean) { visitedBars[bars.barName] = visited player.miniquestManager.getAttribs(Miniquest.BAR_CRAWL).setB(bars.barName, visited) } @JvmStatic fun allBarsVisited(player: Player): Boolean { for (bars in Bars.entries) { if (!isBarVisited(player, bars)) { return false } } return true } fun onBarCrawl(player: Player): Boolean { return player.miniquestManager.getStage(Miniquest.BAR_CRAWL) == RECEIVED_CRAWL_CARD } fun completedBarCrawl(player: Player): Boolean { return player.miniquestManager.getStage(Miniquest.BAR_CRAWL) == COMPLETED } } }" "package com.rs.game.content.miniquests.bar_crawl class BlueMoonInnEffect : BarCrawl.Effects { override fun effect(player: Player) { player.anim(829) player.forceTalk(""Blearrgh!"") player.applyHit(Hit(null, Utils.random(200), Hit.HitLook.TRUE_DAMAGE)) player.skills.lowerStat(Constants.ATTACK, 8) player.skills.lowerStat(Constants.STRENGTH, 7) player.skills.lowerStat(Constants.DEFENSE, 7) player.skills.lowerStat(Constants.SMITHING, 6) } override fun message(player: Player, start: Boolean) { if (!start) { player.sendMessage(""Your insides feel terrible."", ""The bartender signs your card."") setBarVisited(player, BLUE_MOON_INN, true) player.unlock() } else { player.sendMessage(""You buy some ${BLUE_MOON_INN.drinkName}."", ""You drink the ${BLUE_MOON_INN.drinkName}."") player.inventory.removeCoins(BLUE_MOON_INN.price) } } } class BlurberrysBarEffect : BarCrawl.Effects { override fun effect(player: Player) { player.anim(829) player.applyHit(Hit(null, Utils.random(47), Hit.HitLook.TRUE_DAMAGE)) } override fun message(player: Player, start: Boolean) { if (!start) { player.sendMessage(""Blurberry signs your card."") setBarVisited(player, BLURBERRYS_BAR, true) player.unlock() } else { player.sendMessage(""Your mouth and throat burns as you gulp it down."") player.inventory.removeCoins(BLURBERRYS_BAR.price) } } } class DeadMansChestEffect : BarCrawl.Effects { override fun effect(player: Player) { player.anim(829) player.skills.lowerStat(Constants.ATTACK, 8) player.skills.lowerStat(Constants.DEFENSE, 7) player.skills.lowerStat(Constants.HERBLORE, 6) player.skills.lowerStat(Constants.COOKING, 7) player.prayer.drainPrayer(60.0) } override fun message(player: Player, start: Boolean) { if (!start) { player.sendMessage(""You stagger backwards."", ""You think you see 2 bartenders signing 2 barcrawl cards."") setBarVisited(player, DEAD_MANS_CHEST, true) player.unlock() } else { player.sendMessage(""The bartender serves you a glass of strange thick dark liquid."", ""You wince and drink it."") player.inventory.removeCoins(DEAD_MANS_CHEST.price) } } } class DragonInnEffect : BarCrawl.Effects { override fun effect(player: Player) { player.anim(829) player.skills.lowerStat(Constants.ATTACK, 11) player.skills.lowerStat(Constants.DEFENSE, 10) } override fun message(player: Player, start: Boolean) { if (!start) { player.sendMessage(""Your vision blurs and you stagger slightly."", ""You can just about make out the bartender signing your barcrawl card."") setBarVisited(player, DRAGON_INN, true) player.unlock() } else { player.sendMessage(""The bartender hands you a small glass and sets light to the contents."", ""You blow out the flame and drink it."") player.inventory.removeCoins(DRAGON_INN.price) } } } class FlyingHorseInnEffect : BarCrawl.Effects { override fun effect(player: Player) { player.anim(829) val damagePercentage = Utils.random(20, 30) val damage = (player.skills.getLevel(Constants.HITPOINTS) * damagePercentage / 100) player.applyHit(Hit(null, damage, Hit.HitLook.TRUE_DAMAGE)) } override fun message(player: Player, start: Boolean) { if (!start) { player.sendMessage(""You clutch your chest."", ""Through your tears you see the bartender..."", ""signing your barcrawl card."") setBarVisited(player, FLYING_HORSE_INN, true) player.unlock() } else { player.sendMessage(""The bartender hands you a shot of ${FLYING_HORSE_INN.drinkName}."", ""You grimace and drink it."") player.inventory.removeCoins(FLYING_HORSE_INN.price) } } } class ForestersArmsEffect : BarCrawl.Effects { override fun effect(player: Player) { player.anim(829) player.skills.lowerStat(Constants.ATTACK, 8) player.skills.lowerStat(Constants.DEFENSE, 6) player.skills.lowerStat(Constants.FLETCHING, 5) player.skills.lowerStat(Constants.FIREMAKING, 5) player.skills.lowerStat(Constants.WOODCUTTING, 5) player.schedule { player.packets.sendCameraShake(0, 0, 60, 2, 50) wait(Ticks.fromSeconds(Utils.random(4, 8))) player.packets.sendStopCameraShake() player.unlock() } } override fun message(player: Player, start: Boolean) { if (!start) { player.sendMessage(""The room seems to be swaying."", ""The bartender scrawls his signature on your card."") setBarVisited(player, FORESTERS_ARMS, true) } else { player.sendMessage(""The bartender gives you a glass of ${FORESTERS_ARMS.drinkName}."", ""You gulp it down."") player.inventory.removeCoins(FORESTERS_ARMS.price) } } } class JollyBoarInnEffect : BarCrawl.Effects { override fun effect(player: Player) { player.anim(829) player.skills.lowerStat(Constants.ATTACK, 8) player.skills.lowerStat(Constants.DEFENSE, 7) player.skills.lowerStat(Constants.STRENGTH, 6) player.skills.lowerStat(Constants.MINING, 6) player.skills.lowerStat(Constants.CRAFTING, 6) player.skills.lowerStat(Constants.MAGIC, 6) player.applyHit(Hit(null, 100, Hit.HitLook.TRUE_DAMAGE)) } override fun message(player: Player, start: Boolean) { if (!start) { player.sendMessage(""Your head is spinning."", ""The bartender signs your card."") setBarVisited(player, JOLLY_BOAR_INN, true) player.forceTalk(""Thanksh very mush..."") player.unlock() } else { player.sendMessage(""You buy a pint of ${JOLLY_BOAR_INN.drinkName}."", ""You gulp it down."") player.inventory.removeCoins(JOLLY_BOAR_INN.price) } } } class KaramjaSpiritsEffect : BarCrawl.Effects { override fun effect(player: Player) { player.anim(829) player.skills.lowerStat(Constants.ATTACK, 7) player.skills.lowerStat(Constants.DEFENSE, 6) } override fun message(player: Player, start: Boolean) { if (!start) { player.sendMessage(""Zambo signs your card."") setBarVisited(player, KARAMJA_SPIRITS, true) player.forceTalk(""Mmmmm, dat was luverly..."") player.unlock() } else { player.sendMessage(""You buy some ${KARAMJA_SPIRITS.drinkName}."", ""You swirl it around and swallow it."") player.inventory.removeCoins(KARAMJA_SPIRITS.price) } } } class RisingSunEffect : BarCrawl.Effects { override fun effect(player: Player) { player.anim(829) player.skills.lowerStat(Constants.ATTACK, 8) player.skills.lowerStat(Constants.DEFENSE, 6) player.skills.lowerStat(Constants.RANGE, 6) player.skills.lowerStat(Constants.FISHING, 6) player.applyHit(Hit(null, Utils.random(200), Hit.HitLook.TRUE_DAMAGE)) player.schedule { player.packets.sendCameraShake(0, 0, 60, 2, 50) wait(Ticks.fromSeconds(Utils.random(4, 8))) player.packets.sendStopCameraShake() player.unlock() } } override fun message(player: Player, start: Boolean) { if (!start) { player.sendMessage(""The barmaid giggles."", ""The barmaid signs your card."") setBarVisited(player, RISING_SUN, true) } else { player.sendMessage(""You buy a ${RISING_SUN.drinkName}."", ""You drink the cocktail."", ""You stumble around the room."") player.inventory.removeCoins(RISING_SUN.price) } } } class RustyAnchorEffect : BarCrawl.Effects { override fun effect(player: Player) { player.anim(829) } override fun message(player: Player, start: Boolean) { if (!start) { player.sendMessage(""The bartender signs your card."") setBarVisited(player, RUSTY_ANCHOR, true) player.forceTalk(""Hiccup!"") player.unlock() } else { player.sendMessage(""You buy a ${RUSTY_ANCHOR.drinkName}..."", ""Your vision blurs."") player.inventory.removeCoins(RUSTY_ANCHOR.price) } } }" "package com.rs.game.content.miniquests.from_tiny_acorns class DarrenFromTinyAcorns(p: Player, npc: NPC) { init { p.startConversation { when(p.getMiniquestStage(Miniquest.FROM_TINY_ACORNS)) { 0 -> { npc(npc, HAPPY_TALKING, ""Ah, ${p.displayName}! Can I borrow you for a moment?"") npc(npc, HAPPY_TALKING, ""I've got some work in dire need of a hero and you're the best agent I have to take it on!"") npc(npc, HAPPY_TALKING, ""I'll put it to you very directly, ${p.displayName}. It's an expensive business expanding the guild."") npc(npc, HAPPY_TALKING, ""The price of construction work is exorbitant, and if we're to get the premises up to the size of our eventual status deserves we shall be needing more money."") player(CALM_TALK, ""I understand well."") npc(npc, HAPPY_TALKING, ""That's why I've bought a very expensive toy dragon, which is quite nearly completed."") player(CALM_TALK, ""Wait, what?"") npc(npc, HAPPY_TALKING, ""Allow me to explain... There is a master craftsman recently arrived in Varrock, a dwarf by the name of Urist Loric."") npc(npc, HAPPY_TALKING, ""He does clockwork and delicate crafts, and works extensively in precious stones."") npc(npc, HAPPY_TALKING, ""I have commissioned him to construct a red dragon - worth the entirety of our available monies - out of ruby."") player(SKEPTICAL_HEAD_SHAKE, ""This sounds more like madness than adventure at the moment."") npc(npc, HAPPY_TALKING, ""I have no intention of buying it. What I need you to do, my dear "" + p.getPronoun(""fellow"", ""lady"") + "", is steal the dragon from his stall in Varrock."") npc(npc, HAPPY_TALKING, ""You can then be very surprised and dismayed at him and demand my money returned."") player(CALM_TALK, ""Then I bring you the toy and your money, and you fence the toy and double your investment?"") npc(npc, HAPPY_TALKING, ""Double? Ha! I'm having a bad day."") options { op(""Alright, I'll do it."") { player(CALM_TALK, ""Alright, I'll do it."") npc(npc, HAPPY_TALKING, ""I knew I could count on you."") { p.miniquestManager.setStage(Miniquest.FROM_TINY_ACORNS, 1) } } op(""Let me think about it and come back."") { player(CALM_TALK, ""Let me think about it and come back."") npc(npc, HAPPY_TALKING, ""Don't be too long; if he finishes the thing I'll have to take delivery of it."") } } } 1 -> { player(CALM_TALK, ""I'd like to talk about the caper I'm doing for you."") player(CALM_TALK, ""I've not got the baby toy dragon and initial investment back yet, I'm afraid."") npc(npc, HAPPY_TALKING, ""Well, do hop to it, there's a good "" + p.getPronoun(""chap"",""lass"") + "". Time's a ticking!"") player(CALM_TALK, ""Do you have any practical advice for how I should go about this?"") npc(npc, HAPPY_TALKING, ""Practical? My word, no. Robin's your fellow if you want practical matters attended to; I mostly do strategy."") } 2 -> { player(CALM_TALK, ""I'd like to talk about the caper I'm doing for you."") player(CALM_TALK, ""I've got the baby toy dragon but I don't have the initial investment back yet, I'm afraid."") npc(npc, HAPPY_TALKING, ""Excellent! Well, do hop to it, there's a good "" + p.getPronoun(""chap"",""lass"") + "". Time's a ticking!"") } 3 -> { player(CALM_TALK, ""I'd like to talk about the caper I'm doing for you."") exec { val dragonID = 18651 val noteID = 18652 if (!p.inventory.containsItem(dragonID) || !p.inventory.containsItem(noteID)) { player(SHAKING_HEAD, ""I don't have everything I need yet."") npc(npc, TALKING_ALOT, ""As a reminder, I need you to bring me the baby toy dragon and my initial investment."") return@exec } if (p.bank.containsItem(dragonID, 1) || p.bank.containsItem(noteID, 1)) { player(SHAKING_HEAD, ""I have the goods! I'll just need a moment to visit the bank before I hand them over."") return@exec } npc(npc, HAPPY_TALKING, ""I knew you wouldn't let me down! Fairly simple caper, was it?"") player(CALM_TALK, ""Just needed a little finesse, that's all."") npc(npc, HAPPY_TALKING, ""Ah, finesse! Very well done indeed. Some day I hope to show you myself in action; for now, however, I shall be rather busy paying the builders."") exec { p.fadeScreen { p.inventory.deleteItem(18651, 1) p.inventory.deleteItem(18652, 1) p.skills.addXp(Skills.THIEVING, 1000.0) p.tele(Tile.of(3223, 3269, 0)) p.miniquestManager.complete(Miniquest.FROM_TINY_ACORNS) } } } } } } } }" "package com.rs.game.content.miniquests.from_tiny_acorns @ServerStartupEvent fun mapFromTinyAcorns() { onLogin { (player) -> val hasDragon = player.bank.containsItem(18651, 1) || player.inventory.containsItem(18651) if (!player.miniquestManager.isComplete(Miniquest.FROM_TINY_ACORNS) && player.miniquestManager.getStage(Miniquest.FROM_TINY_ACORNS) >= 2 && !hasDragon) { player.miniquestManager.setStage(Miniquest.FROM_TINY_ACORNS, 1) player.vars.setVarBit(7821, 1) } } onItemClick(18649, options = arrayOf(""Put-down"")) { e -> if (!e.player.tile.withinArea(3220, 3427, 3228, 3432)) { e.player.sendMessage(""I should find a suitable spot to put this. Maybe just north of him..."") return@onItemClick } World.addGroundItem(e.item, e.player.tile, e.player) e.player.inventory.deleteItem(e.item) e.player.inventory.refresh() } onObjectClick(51656) { (player, obj) -> val uristDistracted = player.miniquestManager.getAttribs(Miniquest.FROM_TINY_ACORNS).getB(""UristDistracted"") val guardDistracted = player.miniquestManager.getAttribs(Miniquest.FROM_TINY_ACORNS).getB(""GuardDistracted"") val uristID = 11270 val guardID = 11269 if (player.inventory.containsItem(18651)) { player.sendMessage(""You've stolen the Toy Baby Dragon already."") return@onObjectClick } if (uristDistracted && guardDistracted) { player.actionManager.setAction(StealToyDragon(obj)) } else { if (!uristDistracted) { player.startConversation { npc(uristID, CALM_TALK, ""Sorry, "" + player.getPronoun(""lad"", ""miss"") + "", I can't let you pick it up just yet. Still needs its oil and polish before I can call it a finished work, see."") player(SKEPTICAL, ""It looks finished to me."") npc(uristID, SHAKING_HEAD, ""And it'd look finished until the works gummed up or the oil clouded the rubies. Can't let a piece this pricey be a rush job, can I?"") } return@onObjectClick } player.npcDialogue(guardID, ANGRY, ""Oi! Put that back, thief!"") } } } @MiniquestHandler( miniquest = Miniquest.FROM_TINY_ACORNS, startText = ""Speak to Darren Lightfinger in his cellar accessed through a trapdoor north of Lumbridge furnace."", itemsText = ""None"", combatText = ""None"", rewardsText = ""1,000 Thieving XP
Access to the advanced pickpocketing trainer and coshing volunteers in the Thieves' Guild"", completedStage = 5 ) class FromTinyAcorns : MiniquestOutline() { override fun getJournalLines(player: Player, stage: Int): List { val lines = ArrayList() when (stage) { 0 -> { lines.add(""I can start this miniquest by speaking to Darren Lightfinger in"") lines.add(""the Lumbridge Thieves' Guild."") lines.add("""") } 1 -> { lines.add(""I need to pay Urist Loric a visit and steal the dragon."") lines.add(""Maybe Robin will be able to help."") lines.add("""") } 2 -> { lines.add(""I've stolen the dragon."") lines.add(""Now I just need to get Dareen's investment back."") lines.add("""") } 3 -> { lines.add(""Urist agreed to give Darren his money back after loosing the dragon."") lines.add(""I should take the Banker's Note back to Darren."") lines.add("""") } 4 -> lines.add(""MINIQUEST COMPLETE!"") else -> lines.add(""Invalid quest stage. Report this to an administrator."") } return lines } override fun complete(player: Player) { player.skills.addXpQuest(Skills.THIEVING, 1000.0) sendQuestCompleteInterface(player, 18651) } override fun updateStage(player: Player) { player.vars.setVarBit(7821, if (player.miniquestManager.getStage(Miniquest.FROM_TINY_ACORNS) == 1) 1 else 0) } }" "package com.rs.game.content.miniquests.from_tiny_acorns class PickPocketUrist(private val npc: NPC) : PlayerAction() { private var success = false override fun start(player: Player): Boolean { if (checkAll(player)) { success = rollSuccess(player) player.faceEntity(npc) WorldTasks.delay(0) { player.anim(881) } setActionDelay(player, 2) player.lock() return true } return false } override fun process(player: Player): Boolean { return checkAll(player) } override fun processWithDelay(player: Player): Int { if (!success) { player.npcDialogue(npc.id, HeadE.ANGRY, ""Oi! Leave that alone."") } else { player.inventory.addItem(18649, 1) player.sendMessage(""You steal a golden talisman out of Urist's back pocket."") } stop(player) return -1 } override fun stop(player: Player) { player.unlock() player.setNextFaceEntity(null) setActionDelay(player, 1) } fun rollSuccess(player: Player): Boolean { return Utils.skillSuccess(player.skills.getLevel(Constants.THIEVING), player.auraManager.thievingMul, 185, 255) } private fun checkAll(player: Player): Boolean { if (player.isDead || player.hasFinished() || player.hasPendingHits()) return false if (player.attackedBy != null && player.inCombat()) { player.sendMessage(""You can't do this while you're under combat."") return false } return true } }" "package com.rs.game.content.miniquests.from_tiny_acorns class RobinFromTinyAcorns(p: Player, npc: NPC) { init { p.startConversation { options { op(""Talk about the current caper."") { player(CHEERFUL, ""Do you have any advice for me about this Urist fellow?"") exec { if (p.inventory.containsItem(18651)) { npc(npc, LAUGH, ""Well, since you seem to have bamboozled him handly, I'd have a word with Darren about it."") player(CHEERFUL, ""Will do, thanks."") } else { npc(npc, SHAKING_HEAD, ""I don't know anything about him, sorry. He's only just set up shop and I've not been to Varrock in a while. You'll probably want to ask someone who sees him on a more regular basis."") player(SKEPTICAL, ""Hmm."") npc(npc, SCARED, ""Oh, and if you're stealing from his stall, watch out for the guards. They keep a close eye on activity in the marketplace and they're not lenient with shoplifters."") player(SKEPTICAL_THINKING, ""Will do, thanks."") } } } } } } }" "package com.rs.game.content.miniquests.from_tiny_acorns class StealToyDragon(private val obj: GameObject) : PlayerAction() { private var success = false override fun start(player: Player): Boolean { if (checkAll(player)) { success = successful(player) player.faceObject(obj) WorldTasks.delay(0) { player.anim(881) } setActionDelay(player, 2) player.lock() return true } return false } override fun process(player: Player): Boolean { return checkAll(player) } override fun processWithDelay(player: Player): Int { if (!success) { player.sendMessage(""You failed to steal the toy dragon."") } else { if (player.inventory.hasFreeSlots()) { player.inventory.addItem(18651, 1) player.sendMessage(""You take the toy dragon from the stall."") player.vars.setVarBit(7821, 0) player.miniquestManager.setStage(Miniquest.FROM_TINY_ACORNS, 2) } else { player.sendMessage(""You do not have enough space to do that."") } } stop(player) return -1 } override fun stop(player: Player) { player.unlock() player.setNextFaceEntity(null) setActionDelay(player, 1) } fun rollSuccess(player: Player): Boolean { return Utils.skillSuccess(player.skills.getLevel(Constants.THIEVING), player.auraManager.thievingMul + (if (hasArdyCloak(player)) 0.1 else 0.0), 185, 255) } private fun successful(player: Player): Boolean { if (!rollSuccess(player)) return false return true } private fun checkAll(player: Player): Boolean { if (player.isDead || player.hasFinished() || player.hasPendingHits()) return false if (player.attackedBy != null && player.inCombat()) { player.sendMessage(""You can't do this while you're under combat."") return false } return true } }" "package com.rs.game.content.miniquests.huntforsurok; @PluginEventHandler public class ChaosTunnels { public static NPCClickHandler aegis = new NPCClickHandler(new Object[] { 5840 }, e -> e.getPlayer().startConversation(new Dialogue() .addNPC(5840, HeadE.CHEERFUL, ""Hello. Can I help you?"") .addNextIf(() -> e.getPlayer().getMiniquestStage(Miniquest.HUNT_FOR_SUROK) == 2, new Dialogue() .addPlayer(HeadE.FRUSTRATED, ""Where did he go?"") .addNPC(5840, HeadE.CONFUSED, ""Where did who go?"") .addPlayer(HeadE.FRUSTRATED, ""Surok! I saw him come in this way!"") .addNPC(5840, HeadE.AMAZED, ""Oh, Lord Magis? Why yes; he went through the portal here."") .addPlayer(HeadE.CHEERFUL, ""Right! Thanks!"") .addNPC(5840, HeadE.CHEERFUL, ""Was there anything else?"")) .addPlayer(HeadE.CONFUSED, ""Yes. What is this place?"") .addNPC(5840, HeadE.CHEERFUL, ""These are the Dagon'hai tunnels. They radiate with the energy of chaos magic. At the far end of the tunnel, you will find a portal to the Chaos Altar itself, where chaos runes are crafted."") .addOptions(ops -> { ops.add(""Why is the tunnel so short?"") .addPlayer(HeadE.CONFUSED, ""Why is the tunnel so short?"") .addNPC(5840, HeadE.CHEERFUL, ""The nature of chaos magic itself is mysterious and hard to understand."") .addPlayer(HeadE.CONFUSED, ""What do you mean?"") .addNPC(5840, HeadE.CALM_TALK, ""The tunnel is here, and yet it is not here. We also are here, where we should be, yet we are somewhere else. And so, the tunnel goes from one place to another, yet touches neither."") .addPlayer(HeadE.CONFUSED, ""I really don't understand."") .addNPC(5840, HeadE.CHEERFUL, ""I told you you wouldn't. The best way to think of it is that the tunnel is like a gateway that allows you to travel from one place in the world to another in a more safe and convenient way."") .addPlayer(HeadE.CHEERFUL, ""Ok, I think I see. So it is like a magical alternate route?"") .addNPC(5840, HeadE.CHEERFUL, ""Exactly! Well done! And at the end, there is a portal which will transport you to the Chaos Altar."") .addPlayer(HeadE.CHEERFUL, ""Oh, ok.""); ops.add(""Why are there only three of you?"") .addPlayer(HeadE.CONFUSED, ""Why are there only three of you?"") .addNPC(5840, HeadE.CHEERFUL, ""Our order is a secret one and those of us that remain and survive through the ages choose to hide ourselves away."") .addPlayer(HeadE.CONFUSED, ""Where are the rest of you now?"") .addNPC(5840, HeadE.CHEERFUL, ""We have built or found many tunnels such as these. This is not the only one. Rest assured, there are many more of us around.""); ops.add(""Is the Wilderness above us?"") .addPlayer(HeadE.CONFUSED, ""Is the Wilderness above us?"") .addNPC(5840, HeadE.CHEERFUL, ""Yes, I can understand you would expect it to be since the tunnel leads to the Chaos Altar. And yes, the tunnel does not enter the Wilderness, no."") .addNPC(5840, HeadE.CHEERFUL, ""Rest assured, you are safe here and should not come to harm.""); ops.add(""You seem quite nice for a Zamorakian."") .addPlayer(HeadE.CHEERFUL, ""You seem quite nice for a Zamorakian."") .addNPC(5840, HeadE.CALM_TALK, ""History is written by the strong and the influential."") .addPlayer(HeadE.CONFUSED, ""What does that mean?"") .addNPC(5840, HeadE.CHEERFUL, ""It means we cannot always believe what we are told to believe. You would do well to remember that. Especially when thinking about how long it takes to cremate bodies."") .addPlayer(HeadE.CHEERFUL, ""I will! Thank you!""); ops.add(""Thanks for your time."") .addPlayer(HeadE.CHEERFUL, ""Thanks for your time.""); }))); public static NPCClickHandler silasDahcsnu = new NPCClickHandler(new Object[] { 5841 }, e -> e.getPlayer().startConversation(new Dialogue() .addPlayer(HeadE.CHEERFUL, ""Hello there."") .addNPC(5841, HeadE.FRUSTRATED, ""Can't you see that I'm busy here?"") .addPlayer(HeadE.AMAZED, ""Oh. Sorry, you don't look very busy."") .addNPC(5841, HeadE.FRUSTRATED, ""Don't look busy? I've got a lot of important work to do here."") .addPlayer(HeadE.CONFUSED, ""Really? What do you do?"") .addNPC(5841, HeadE.FRUSTRATED, ""That doesn't concern you. What are you doing here anyway?"") .addOptions(ops -> { ops.add(""I'm not actually sure."") .addPlayer(HeadE.SAD_MILD, ""I'm not actually sure."") .addNPC(5841, HeadE.FRUSTRATED, ""Hmph! Well I can tell you what you ARE doing."") .addPlayer(HeadE.CONFUSED, ""What's that?"") .addNPC(5841, HeadE.FRUSTRATED, ""Wasting my time! Now go away! If you must speak to someone, speak to one of the other monks around here!""); ops.add(""I'm on an important quest!"") .addPlayer(HeadE.CHEERFUL, ""I'm on an important quest!"") .addNPC(5841, HeadE.CALM_TALK, ""Really..."") .addPlayer(HeadE.CHEERFUL, ""Yes! Do you want to know what my quest is?"") .addNPC(5841, HeadE.CALM_TALK, ""Let me see...you helped out a trader who in turn asked you to deliver something for him, and then you had to journey to some palace to see someone and they said thanks by sending you somewhere else."") .addPlayer(HeadE.CONFUSED, ""Uhh..."") .addNPC(5841, HeadE.CALM_TALK, ""So, now you've ended up down here, bothering me?"") .addPlayer(HeadE.CONFUSED, ""Uh, yes, that's about right."") .addNPC(5841, HeadE.CALM_TALK, ""Lucky me..."") .addPlayer(HeadE.CONFUSED, ""Sorry about that. I'll leave you alone, then.""); ops.add(""None of your business!"") .addPlayer(HeadE.FRUSTRATED, ""None of your business!"") .addNPC(5841, HeadE.FRUSTRATED, ""Of course it isn't, but you were the one who came here bothering me! So, unless you want something, be off with you!""); ops.add(""I am looking for something."") .addPlayer(HeadE.CONFUSED, ""I am looking for something."") .addNPC(5841, HeadE.CONFUSED, ""What are you looking for exactly?"") .addPlayer(HeadE.CONFUSED, ""The Chaos Altar, I think."") .addNPC(5841, HeadE.FRUSTRATED, ""Hmph! Well, it's just a bit further down. Now if you don't mind, I'm very busy here!""); ops.add(""I'm the leader of the Dagon'hai. Bow before me!"") .addPlayer(HeadE.FRUSTRATED, ""I'm the leader of the Dagon'hai. Bow before me!"") .addNPC(5841, HeadE.CONFUSED, ""You? Leader of the Dagon'hai? Hah! I've never heard of such rubbish! You call yourself a mage?"") .addOptions(mage -> { mage.add(""I'm a very powerful mage!"") .addPlayer(HeadE.FRUSTRATED, ""I'm a very powerful mage!"") .addNPC(5841, HeadE.AMAZED, ""Really?"") .addPlayer(HeadE.FRUSTRATED, ""Yes! Be afraid! Be very afraid! Ha ha ha!"") .addNPC(5841, HeadE.CALM_TALK, ""I see. Well then, let's see how you handle this!"") .addPlayer(HeadE.AMAZED, ""What...?!?!"") //TODO deflect spell based on magic level? //If fail, player jumps and says they can't stop jumping //then CHEERFUL, ""Hah! I knew you were no mage! Let that be a lesson to you! Now, please leave. .addNPC(5841, HeadE.AMAZED, ""So! You are a good mage! You deflected my spell."") .addPlayer(HeadE.CALM_TALK, ""Hah! Yes. I told you so! Now, I have work to be done."") .addNPC(5841, HeadE.CALM_TALK, ""Of course. Goodbye!""); mage.add(""No, you're right. I'm not a mage."") .addPlayer(HeadE.SAD_MILD, ""No, you're right. I'm not a mage."") .addNPC(5841, HeadE.FRUSTRATED, ""I didn't think so! Now go away. As I said, I'm very busy!""); }); }))); public static NPCClickHandler mishkalDorn = new NPCClickHandler(new Object[] { 5839 }, e -> e.getPlayer().startConversation(new Dialogue() .addNPC(5839, HeadE.CALM_TALK, ""You are excused. And you are welcome."") .addPlayer(HeadE.CONFUSED, ""Excuse me...er...thanks."") .addNPC(5839, HeadE.CALM_TALK, ""We are the Order of the Dagon'hai."") .addPlayer(HeadE.CONFUSED, ""Who are you?"") .addNPC(5839, HeadE.CALM_TALK, ""Through my magic, I can see a short way into the future."") .addPlayer(HeadE.CONFUSED, ""How do you seem to know what I'm going to say? ...Er...oh."") .addNPC(5839, HeadE.CALM_TALK, ""These are the Tunnels of Chaos."") .addPlayer(HeadE.CONFUSED, ""What is...uh...aha! I'm not going to ask that. So you got it wrong!"") .addNPC(5839, HeadE.CALM_TALK, ""Indeed. You are very clever."") .addPlayer(HeadE.CHEERFUL, ""So I won!"") .addNPC(5839, HeadE.CALM_TALK, ""Yes."") .addPlayer(HeadE.CONFUSED, ""So, what is this place?"") .addPlayer(HeadE.FRUSTRATED, ""I mean...Argh! How do you do that?"") .addNPC(5839, HeadE.CALM_TALK, ""I can tell that your mind is not suited to the paradoxicalities of precognition."") .addPlayer(HeadE.CONFUSED, ""Why what does what now?"") .addNPC(5839, HeadE.CALM_TALK, ""You get confused very easily."") .addPlayer(HeadE.CALM_TALK, ""I knew that."") .addNPC(5839, HeadE.CALM_TALK, ""Of course you did. Speak to one of my order here. They will be able to explain in a manner more suited to your understanding."") .addNPC(5839, HeadE.CALM_TALK, ""You are welcome, "" + e.getPlayer().getDisplayName() + "". There is a bed around here if you wish."") .addPlayer(HeadE.CHEERFUL, ""Thanks. My name's "" + e.getPlayer().getDisplayName() + "", by the w...uh...okay, I think I need to lie down.""))); public static ObjectClickHandler handleRifts = new ObjectClickHandler(new Object[] { 65203 }, e -> { if (e.getPlayer().inCombat(10000) || e.getPlayer().hasBeenHit(10000)) { e.getPlayer().sendMessage(""You cannot enter the rift while you're under attack.""); return; } if (e.objectAt(3058, 3550)) e.getPlayer().tele(e.getPlayer().transform(125, 1920, 0)); if (e.objectAt(3118, 3570)) e.getPlayer().tele(e.getPlayer().transform(130, 1920, 0)); if (e.objectAt(3129, 3587)) e.getPlayer().tele(e.getPlayer().transform(105, 1972, 0)); if (e.objectAt(3164, 3561)) e.getPlayer().tele(e.getPlayer().transform(128, 1918, 0)); if (e.objectAt(3176, 3585)) e.getPlayer().tele(Tile.of(3290, 5539, 0)); }); public static ObjectClickHandler handleExitRopes = new ObjectClickHandler(new Object[] { 28782 }, e -> { if (e.objectAt(3183, 5470)) e.getPlayer().tele(e.getPlayer().transform(-125, -1920, 0)); if (e.objectAt(3248, 5490)) e.getPlayer().tele(e.getPlayer().transform(-130, -1920, 0)); if (e.objectAt(3234, 5559)) e.getPlayer().tele(e.getPlayer().transform(-105, -1972, 0)); if (e.objectAt(3292, 5479)) e.getPlayer().tele(e.getPlayer().transform(-128, -1918, 0)); if (e.objectAt(3291, 5538)) e.getPlayer().tele(e.getPlayer().transform(-115, -1953, 0)); e.getPlayer().getControllerManager().startController(new WildernessController()); }); @ServerStartupEvent public static void portalRouteTypeWalkOn() { Stream.of(28779, 28888, 29537, 23095).forEach(id -> World.setObjectRouteType(id, GameObject.RouteType.WALK_ONTO)); } public static ObjectClickHandler handleChaosTunnelsPortals = new ObjectClickHandler(new Object[] { 28779, 28888, 29537, 23095 }, e -> { PortalPair portal = PortalPair.forTile(e.getObject().getTile()); if (portal == null) return; portal.travel(e.getPlayer(), e.getObject()); }); public enum PortalPair { _1(Tile.of(3254, 5451, 0), Tile.of(3250, 5448, 0)), _2(Tile.of(3241, 5445, 0), Tile.of(3233, 5445, 0)), _3(Tile.of(3259, 5446, 0), Tile.of(3265, 5491, 0), true), _4(Tile.of(3299, 5484, 0), Tile.of(3303, 5477, 0)), _5(Tile.of(3286, 5470, 0), Tile.of(3285, 5474, 0)), _6(Tile.of(3290, 5463, 0), Tile.of(3302, 5469, 0)), _7(Tile.of(3296, 5455, 0), Tile.of(3299, 5450, 0)), _8(Tile.of(3280, 5501, 0), Tile.of(3285, 5508, 0)), _9(Tile.of(3300, 5514, 0), Tile.of(3297, 5510, 0)), _10(Tile.of(3289, 5533, 0), Tile.of(3288, 5536, 0)), _11(Tile.of(3285, 5527, 0), Tile.of(3282, 5531, 0)), _12(Tile.of(3325, 5518, 0), Tile.of(3323, 5531, 0)), _13(Tile.of(3299, 5533, 0), Tile.of(3297, 5536, 0)), _14(Tile.of(3321, 5554, 0), Tile.of(3315, 5552, 0)), _15(Tile.of(3291, 5555, 0), Tile.of(3285, 5556, 0)), _16(Tile.of(3266, 5552, 0), Tile.of(3262, 5552, 0)), _17(Tile.of(3256, 5561, 0), Tile.of(3253, 5561, 0)), _18(Tile.of(3249, 5546, 0), Tile.of(3252, 5543, 0)), _19(Tile.of(3261, 5536, 0), Tile.of(3268, 5534, 0)), _20(Tile.of(3243, 5526, 0), Tile.of(3241, 5529, 0)), _21(Tile.of(3230, 5547, 0), Tile.of(3226, 5553, 0)), _22(Tile.of(3206, 5553, 0), Tile.of(3204, 5546, 0)), _23(Tile.of(3211, 5533, 0), Tile.of(3214, 5533, 0)), _24(Tile.of(3208, 5527, 0), Tile.of(3211, 5523, 0)), _25(Tile.of(3201, 5531, 0), Tile.of(3197, 5529, 0), true), _26(Tile.of(3202, 5515, 0), Tile.of(3196, 5512, 0), true), _27(Tile.of(3190, 5515, 0), Tile.of(3190, 5519, 0)), _28(Tile.of(3185, 5518, 0), Tile.of(3181, 5517, 0)), _29(Tile.of(3187, 5531, 0), Tile.of(3182, 5530, 0)), _30(Tile.of(3169, 5510, 0), Tile.of(3159, 5501, 0)), _31(Tile.of(3165, 5515, 0), Tile.of(3173, 5530, 0)), _32(Tile.of(3156, 5523, 0), Tile.of(3152, 5520, 0)), _33(Tile.of(3148, 5533, 0), Tile.of(3153, 5537, 0)), _34(Tile.of(3143, 5535, 0), Tile.of(3147, 5541, 0)), _35(Tile.of(3168, 5541, 0), Tile.of(3171, 5542, 0)), _36(Tile.of(3190, 5549, 0), Tile.of(3190, 5554, 0)), _37(Tile.of(3180, 5557, 0), Tile.of(3174, 5558, 0)), _38(Tile.of(3162, 5557, 0), Tile.of(3158, 5561, 0)), _39(Tile.of(3166, 5553, 0), Tile.of(3162, 5545, 0)), _40(Tile.of(3115, 5528, 0), Tile.of(3142, 5545, 0)), _41(Tile.of(3260, 5491, 0), Tile.of(3266, 5446, 0), true), _42(Tile.of(3241, 5469, 0), Tile.of(3233, 5470, 0)), _43(Tile.of(3235, 5457, 0), Tile.of(3229, 5454, 0)), _44(Tile.of(3280, 5460, 0), Tile.of(3273, 5460, 0)), _45(Tile.of(3283, 5448, 0), Tile.of(3287, 5448, 0)), _46(Tile.of(3244, 5495, 0), Tile.of(3239, 5498, 0)), _47(Tile.of(3232, 5501, 0), Tile.of(3238, 5507, 0)), _48(Tile.of(3218, 5497, 0), Tile.of(3222, 5488, 0)), _49(Tile.of(3218, 5478, 0), Tile.of(3215, 5475, 0)), _50(Tile.of(3224, 5479, 0), Tile.of(3222, 5474, 0)), _51(Tile.of(3208, 5471, 0), Tile.of(3210, 5477, 0)), _52(Tile.of(3214, 5456, 0), Tile.of(3212, 5452, 0)), _53(Tile.of(3204, 5445, 0), Tile.of(3197, 5448, 0), true), _54(Tile.of(3189, 5444, 0), Tile.of(3187, 5460, 0)), _55(Tile.of(3192, 5472, 0), Tile.of(3186, 5472, 0)), _56(Tile.of(3185, 5478, 0), Tile.of(3191, 5482, 0)), _57(Tile.of(3171, 5473, 0), Tile.of(3167, 5471, 0)), _58(Tile.of(3171, 5478, 0), Tile.of(3167, 5478, 0)), _59(Tile.of(3168, 5456, 0), Tile.of(3178, 5460, 0)), _60(Tile.of(3191, 5495, 0), Tile.of(3194, 5490, 0)), _61(Tile.of(3141, 5480, 0), Tile.of(3142, 5489, 0)), _62(Tile.of(3142, 5462, 0), Tile.of(3154, 5462, 0)), _63(Tile.of(3143, 5443, 0), Tile.of(3155, 5449, 0)), _64(Tile.of(3307, 5496, 0), Tile.of(3317, 5496, 0)), _65(Tile.of(3318, 5481, 0), Tile.of(3322, 5480, 0)), TUNNELS_OF_CHAOS(Tile.of(3326, 5469, 0), Tile.of(3159, 5208, 0)), CHAOS_ALTAR(Tile.of(3152, 5233, 0), Tile.of(2282, 4837, 0)), BORK(Tile.of(3142, 5545, 0), Tile.of(3115, 5528, 0)); private static final Map MAPPING = new Int2ObjectOpenHashMap<>(); static { for (PortalPair p : PortalPair.values()) { MAPPING.put(p.tile1.getTileHash(), p); MAPPING.put(p.tile2.getTileHash(), p); } } public final Tile tile1; public final Tile tile2; public final boolean surokLocked; PortalPair(Tile tile1, Tile tile2, boolean surokLocked) { this.tile1 = tile1; this.tile2 = tile2; this.surokLocked = surokLocked; } PortalPair(Tile tile1, Tile tile2) { this(tile1, tile2, false); } public static PortalPair forTile(Tile tile) { return MAPPING.get(tile.getTileHash()); } public void travel(Player player, GameObject fromPortal) { if (surokLocked && !player.isMiniquestComplete(Miniquest.HUNT_FOR_SUROK, ""to travel through this portal."", true)) return; if (this == _16 && player.getMiniquestStage(Miniquest.HUNT_FOR_SUROK) == 2) { player.playCutscene(cs -> { cs.setEndTile(Tile.of(3262, 5552, 0)); cs.fadeIn(5); cs.action(() -> player.setMiniquestStage(Miniquest.HUNT_FOR_SUROK, 3)); cs.dynamicRegion(tile1.getTileHash() == fromPortal.getTile().getTileHash() ? tile2 : tile1, 405, 690, 5, 5); cs.npcCreate(""surok"", 7002, 13, 16, 0); cs.npcCreate(""firegiant1"", 110, 10, 16, 0, n -> n.setRandomWalk(false)); cs.npcCreate(""firegiant2"", 110, 15, 17, 0, n -> n.setRandomWalk(false)); cs.playerMove(17, 16, Entity.MoveType.TELE); cs.npcFaceTile(""firegiant1"", 13, 16); cs.npcFaceTile(""firegiant2"", 13, 16); cs.camPos(13, 6, 11338); cs.camLook(13, 16, 0); cs.camPos(13, 6, 3722, 0, 5); cs.fadeOut(5); cs.npcTalk(""surok"", ""Pathetic creatures.""); cs.npcSync(""surok"", 6098, 1009); cs.npcFaceTile(""surok"", 10, 16); cs.delay(1); cs.npcAnim(""surok"", -1); cs.action(() -> World.sendProjectile(cs.getNPC(""surok""), cs.getNPC(""firegiant1""), 1010, 5, 15, 0, 0.8, 10, proj -> { cs.getNPC(""firegiant1"").applyHit(Hit.magic(cs.getNPC(""surok""), cs.getNPC(""firegiant1"").getHitpoints())); cs.getNPC(""firegiant1"").spotAnim(1011); })); cs.delay(5); cs.npcTalk(""firegiant2"", ""Grraaaah!""); cs.npcSync(""surok"", 6098, 1009); cs.npcFaceTile(""surok"", 15, 17); cs.delay(1); cs.npcTalk(""surok"", ""Feel the power of Zamorak!""); cs.npcAnim(""surok"", -1); cs.action(() -> World.sendProjectile(cs.getNPC(""surok""), cs.getNPC(""firegiant2""), 1010, 5, 15, 0, 0.8, 10, proj -> { cs.getNPC(""firegiant2"").applyHit(Hit.magic(cs.getNPC(""surok""), cs.getNPC(""firegiant2"").getHitpoints())); cs.getNPC(""firegiant2"").spotAnim(1011); })); cs.delay(5); cs.npcWalk(""surok"", 18, 8); cs.delay(5); cs.fadeIn(5); cs.returnPlayerFromInstance(); cs.fadeOut(5); }); } if (this == _60 && player.getMiniquestStage(Miniquest.HUNT_FOR_SUROK) == 3) { player.playCutscene(cs -> { cs.setEndTile(Tile.of(3191, 5495, 0)); cs.fadeIn(5); cs.action(() -> player.setMiniquestStage(Miniquest.HUNT_FOR_SUROK, 4)); cs.dynamicRegion(tile1.getTileHash() == fromPortal.getTile().getTileHash() ? tile2 : tile1, 396, 684, 5, 5); cs.npcCreate(""surok"", 7002, 15, 20, 0); cs.playerMove(23, 23, Entity.MoveType.TELE); cs.npcFaceTile(""surok"", 19, 22); cs.camLook(18, 22, 0); cs.camPos(25, 5, 12000); cs.camPos(24, 28, 5125, 0, 20); cs.fadeOut(5); cs.playerMove(19, 22, Entity.MoveType.WALK); cs.delay(3); cs.playerFaceEntity(""surok""); cs.dialogue(new Dialogue() .addPlayer(HeadE.FRUSTRATED, ""Surok! Give yourself up. You can't get away."") .addNPC(7002, HeadE.FRUSTRATED, ""Fool! You are in my lair now. These tunnels belong to my people: the Dagon'hai. Here is where you meet your doom."") .addPlayer(HeadE.FRUSTRATED, ""If you do not come peacefully, I will have to arrest you by force."") .addNPC(7002, HeadE.FRUSTRATED, ""So be it. Let's see how you deal with some of my pets...""), true); cs.npcSync(""surok"", 6098, 1009); cs.delay(1); cs.npcAnim(""surok"", -1); cs.npcCreate(""wolf1"", 95, 17, 20, 0); cs.npcCreate(""wolf2"", 95, 15, 21, 0); cs.npcFaceTile(""wolf1"", 19, 22); cs.npcFaceTile(""wolf2"", 19, 22); cs.npcSync(""wolf1"", 8298, 1315); cs.npcSync(""wolf2"", 8298, 1315); cs.delay(3); cs.npcTalk(""surok"", ""Kill "" + player.getPronoun(""him!"", ""her!"")); cs.playerTalk(""Aargh!""); cs.delay(3); cs.fadeIn(5); cs.returnPlayerFromInstance(); cs.delay(0); cs.action(() -> { new OwnedNPC(player, 95, Tile.of(3188, 5496, 0), false).setTarget(player); new OwnedNPC(player, 95, Tile.of(3188, 5493, 0), false).setTarget(player); }); cs.fadeOut(5); cs.action(player::resetReceivedHits); }); } if (this == BORK) { player.setMiniquestStage(Miniquest.HUNT_FOR_SUROK, 4); if (player.getMiniquestStage(Miniquest.HUNT_FOR_SUROK) < 4) { player.sendMessage(""The portal is unresponsive.""); return; } if (player.getDailyB(""borkKilled"")) { player.sendMessage(""You have already killed Bork today.""); return; } boolean entering = tile1.getTileHash() == fromPortal.getTile().getTileHash(); if (entering) player.getControllerManager().startController(new BorkController(player.getMiniquestStage(Miniquest.HUNT_FOR_SUROK) == 4)); return; } if (this == CHAOS_ALTAR && !RunecraftingAltar.checkItems(player, RunecraftingAltar.Ruins.CHAOS)) { player.sendMessage(""The portal doesn't respond without a tiara or talisman. This must be the Chaos Altar entrance.""); return; } if (this == TUNNELS_OF_CHAOS && player.getMiniquestStage(Miniquest.HUNT_FOR_SUROK) < 2) { player.sendMessage(""The portal is unresponsive.""); return; } player.setNextSpotAnim(new SpotAnim(110, 10, 96)); player.useStairs(-1, tile1.getTileHash() == fromPortal.getTile().getTileHash() ? tile2 : tile1, 2, 3); } } }" "package com.rs.game.content.miniquests.huntforsurok; @MiniquestHandler( miniquest = Miniquest.HUNT_FOR_SUROK, startText = ""Speak to Surok by the statue of Saradomin, east of Varrock."", itemsText = ""Combat equipment to fight a strong level 107 ork who is resistant to range attacks and survive taking multiple hits from different types of monsters."", combatText = ""Bork (level 107)"", rewardsText = ""5,000 Slayer XP
Ability to slay Bork daily (for 1,500 Slayer XP,
Summoning charms, big bones, and gems in the
Chaos Tunnels
Ability to wear Dagon'hai robes"", completedStage = 5 ) @PluginEventHandler public class HuntForSurok extends MiniquestOutline { @Override public List getJournalLines(Player player, int stage) { ArrayList lines = new ArrayList<>(); switch (stage) { case 0 -> { lines.add(""I can start this miniquest by speaking to Surok after mining the""); lines.add(""statue of Saradomin to gain access to the Tunnels of Chaos.""); lines.add(""""); } case 1 -> { lines.add(""I confronted Surok outside the statue and he fled into the""); lines.add(""tunnels beneath.""); lines.add(""""); } case 2 -> { lines.add(""I found Surok fleeing from the Tunnels of Chaos and into a portal""); lines.add(""leading into the Chaos Tunnels.""); lines.add(""""); } case 3 -> { lines.add(""I found Surok again near the fire giants but he fled off to the south.""); lines.add(""""); } case 4 -> { lines.add(""I found Surok again near the skeletons next to the moss giant room but""); lines.add(""he got away again fleeing to the west.""); lines.add(""""); } case 5 -> { lines.add(""I managed to defeat Bork but Surok managed to escape somewhere unknown.""); lines.add(""""); lines.add(""MINIQUEST COMPLETE!""); } default -> lines.add(""Invalid quest stage. Report this to an administrator.""); } return lines; } @Override public void complete(Player player) { player.getSkills().addXpQuest(Skills.SLAYER, 5000); sendQuestCompleteInterface(player, 11014); } @Override public void updateStage(Player player) { if (player.getMiniquestStage(Miniquest.HUNT_FOR_SUROK) >= 1) { player.getVars().saveVarBit(4312, 2); player.getVars().saveVarBit(4314, 2); } if (player.getMiniquestStage(Miniquest.HUNT_FOR_SUROK) >= 2) player.getVars().saveVarBit(4311, 1); } public static ObjectClickHandler handleStairsOutOfStatue = new ObjectClickHandler(new Object[] { 23074 }, e -> e.getPlayer().useStairs(Tile.of(3284, 3467, 0))); public static ObjectClickHandler handleAnnasStatue = new ObjectClickHandler(new Object[] { 23096 }, e -> { switch(e.getOption()) { case ""Excavate"" -> { if (e.getPlayer().getQuestStage(Quest.WHAT_LIES_BELOW) < 4) { e.getPlayer().startConversation(new Dialogue() .addNPC(AnnaJones.ID, HeadE.CALM_TALK, ""Excuse me. I am working on that statue at the moment. Please don't touch it."") .addPlayer(HeadE.AMAZED_MILD, ""You are? But you're just sitting there."") .addNPC(AnnaJones.ID, HeadE.CALM_TALK, ""Yes. I'm on a break."") .addPlayer(HeadE.CONFUSED, ""Oh, I see. When does your break finish?"") .addNPC(AnnaJones.ID, HeadE.CALM_TALK, ""When I decide to start work again. Right now, I'm enjoying sitting on this bench."")); return; } if (!e.getPlayer().getBool(""annaTunnelTalk"")) { e.getPlayer().startConversation(new AnnaJones(e.getPlayer())); return; } if (e.getPlayer().getSkills().getLevelForXp(Skills.MINING) < 42) { e.getPlayer().simpleDialogue(""You need a Mining level of 42 to excavate the statue.""); return; } Pickaxe pick = Pickaxe.getBest(e.getPlayer()); if (pick == null) { e.getPlayer().simpleDialogue(""You need a pickaxe to dig out the statue.""); return; } e.getPlayer().repeatAction(pick.getTicks(), num -> { e.getPlayer().anim(pick.getAnimId()); if (Utils.skillSuccess(e.getPlayer().getSkills().getLevel(Skills.MINING), 16, 100)) { e.getPlayer().anim(-1); e.getPlayer().getVars().saveVarBit(3524, 1); if (e.getPlayer().isQuestComplete(Quest.WHAT_LIES_BELOW)) e.getPlayer().getVars().saveVarBit(4312, 1); e.getPlayer().startConversation(new Dialogue() .addNPC(AnnaJones.ID, HeadE.CHEERFUL, ""You did it! Oh, well done! How exciting!"") .addPlayer(HeadE.CHEERFUL, ""Right, well, I better see what's down there, then."")); return false; } return true; }); } case ""Enter"" -> { if (e.getPlayer().getMiniquestStage(Miniquest.HUNT_FOR_SUROK) == 1) { e.getPlayer().playCutscene(cs -> { cs.setEndTile(Tile.of(3179, 5191, 0)); cs.fadeIn(5); cs.action(() -> e.getPlayer().setMiniquestStage(Miniquest.HUNT_FOR_SUROK, 2)); cs.dynamicRegion(Tile.of(3179, 5191, 0), 393, 649, 5, 5, false); cs.npcCreate(""surok"", 7002, 21, 24, 0); cs.npcCreate(""aegis"", 5840, 14, 19, 0); cs.playerMove(21, 18, Entity.MoveType.TELE); cs.npcFaceDir(""aegis"", Direction.EAST); cs.camPos(27, 19, 7712); cs.camLook(15, 16, 0); cs.camPos(26, 25, 3087, 0, 10); cs.fadeOut(5); cs.npcTalk(""aegis"", ""Goodness me! It's Lord Magis!""); cs.npcWalk(""surok"", 15, 16); cs.delay(4); cs.npcTalk(""surok"", ""I must escape!""); cs.delay(2); cs.npcSpotAnim(""surok"", new SpotAnim(110, 0, 96)); cs.delay(0); cs.npcDestroy(""surok""); cs.delay(5); cs.fadeIn(5); cs.camPosReset(); cs.returnPlayerFromInstance(); cs.fadeOut(5); }); return; } e.getPlayer().useStairs(Tile.of(3179, 5191, 0)); } } }); }" "package com.rs.game.content.miniquests.huntforsurok.bork class Bork(id: Int, tile: Tile, spawned: Boolean) : NPC(id, tile, spawned) { init { lureDelay = 0 setForceAgressive(true) } override fun blocksOtherNpcs(): Boolean = false override fun sendDeath(source: Entity?) { World.getNPCsInChunkRange(source?.chunkId ?: return, 2) .filter { it.id == 7135 } .forEach { it.sendDeath(source) } resetWalkSteps() combat.removeTarget() (source as? Player)?.let { player -> player.resetReceivedHits() player.interfaceManager.sendForegroundInterfaceOverGameWindow(693) WorldTasks.schedule(8) { player.interfaceManager.closeInterfacesOverGameWindow() anim(combatDefinitions.deathEmote) WorldTasks.schedule(4) { drop() reset() setLocation(respawnTile) finish() } } } } override fun drop() { val killer = mostDamageReceivedSourcePlayer ?: return if (killer.getMiniquestStage(Miniquest.HUNT_FOR_SUROK) == 4) { killer.miniquestManager.complete(Miniquest.HUNT_FOR_SUROK) killer.startConversation { player(HeadE.CONFUSED, ""It looks like Surok managed to escape during the fight. I wonder what he is up to now..."") player(HeadE.AMAZED, ""What the-? This power! It must be Zamorak! I can't fight something this strong! I better loot what I can and get out of here!"") } } if (!killer.getDailyB(""borkKilled"")) { val diaryReward = SetReward.VARROCK_ARMOR.hasRequirements(killer, AchievementDef.Area.VARROCK, AchievementDef.Difficulty.HARD, false) val row = killer.equipment.getRingId() != -1 && ItemDefinitions.getDefs(killer.equipment.getRingId()).name.lowercase().contains(""ring of wealth"") killer.setDailyB(""borkKilled"", true) killer.skills.addXp(Skills.SLAYER, if (diaryReward) 3000.0 else 1500.0) val drops = ArrayList().apply { add(Item(532, 1)) add(Item(12159, 2 * (if (diaryReward) 2 else 1) + if (row) 1 else 0)) add(Item(12160, 7 * (if (diaryReward) 2 else 1) + if (row) 3 else 0)) add(Item(12163, 5 * (if (diaryReward) 2 else 1))) add(Item(995, Utils.random(2, 20000) * (if (diaryReward) 2 else 1))) add(Item(1623, if (diaryReward) 2 else 1)) add(Item(1621, (if (diaryReward) 2 else 1) + if (row) 2 else 0)) add(Item(1619, (if (diaryReward) 2 else 1) + if (row) 1 else 0)) } if (Utils.random(64) == 0) sendDrop(killer, Item(18778, 1)) if (Utils.random(32) == 0) sendDrop(killer, Item(TreasureTrailsManager.SCROLL_BOXES[3], 1)) if (Utils.random(16) == 0) sendDrop(killer, Item(TreasureTrailsManager.SCROLL_BOXES[2], 1)) drops.forEach { item -> sendDrop(killer, item) } } } } @ServerStartupEvent fun instantiateAndCombat() { instantiateNpc(""Bork"") { npcId, tile -> Bork(npcId, tile, false) } npcCombat(""Bork"") { npc, target -> val defs = npc.combatDefinitions if (target is Player && npc.hitpoints <= defs.hitpoints * 0.4 && !npc.tempAttribs.getB(""spawnedOrks"")) { npc.forceTalk(""Come to my aid, brothers!"") npc.tempAttribs.setB(""spawnedOrks"", true) target.lock() npc.isCantInteract = true target.playCutscene { cs -> cs.action(2) { target.interfaceManager.sendForegroundInterfaceOverGameWindow(691) } cs.delay(6) cs.action { repeat(3) { World.spawnNPC(7135, Tile.of(npc.tile, 1), -1, true, true).apply { setForceAgressive(true) setForceMultiArea(true) } } target.interfaceManager.closeInterfacesOverGameWindow() target.unlock() target.resetReceivedHits() } } npc.apply { isCantInteract = false forceTalk(""Destroy the intruder, my Legions!"") } return@npcCombat 0 } npc.anim(if ((0..1).random() == 0) defs.attackEmote else 8757) delayHit(npc, 0, target, getMeleeHit(npc, getMaxHit(npc, defs.maxHit, null, target))) npc.attackSpeed } val messages = arrayOf(""For Bork!"", ""Die Human!"", ""To the attack!"", ""All together now!"") npcCombat(""Ork legion"") { npc, target -> npc.anim(npc.combatDefinitions.attackEmote) if ((0..3).random() == 0) npc.forceTalk(messages.random()) delayHit(npc, 0, target, getMeleeHit(npc, npc.combatDefinitions.maxHit)) npc.attackSpeed } }" "package com.rs.game.content.miniquests.huntforsurok.bork; public class BorkController extends InstancedController { private final boolean quest; public BorkController(boolean quest) { super(Instance.of(ChaosTunnels.PortalPair.BORK.tile1, 8, 8).setEntranceOffset(new int[] { 43, 24, 0 })); this.quest = quest; } @Override public void onBuildInstance() { player.lock(); getInstance().copyMapAllPlanes(384, 688).thenAccept(b -> player.playCutscene(cs -> { cs.fadeIn(5); cs.hideMinimap(true); cs.action(() -> { getInstance().teleportLocal(player, 43, 24, 0); player.setForceMultiArea(true); cs.setEndTile(quest ? Tile.of(cs.getX(39), cs.getY(25), 0) : Tile.of(cs.getX(43), cs.getY(24), 0)); }); cs.delay(0); if (quest) { cs.npcCreate(""surok"", 7002, 39, 26, 0); cs.camLook(41, 24, 0); cs.camPos(33, 16, 12324); cs.camPos(29, 28, 3615, 0, 10); cs.fadeOut(5); cs.playerMove(39, 25, Entity.MoveType.WALK); cs.delay(3); cs.npcFaceTile(""surok"", 39, 25); cs.playerFaceTile(39, 26); cs.dialogue(new Dialogue() .addPlayer(HeadE.FRUSTRATED, ""It's a dead end, Surok. There's nowhere left to run."") .addNPC(7002, HeadE.FRUSTRATED, ""You're wrong, "" + player.getDisplayName()+"". I am right where I need to be."") .addPlayer(HeadE.FRUSTRATED, ""What do you mean? You won't escape."") .addNPC(7002, HeadE.FRUSTRATED, ""You cannot stop me, "" + player.getDisplayName() + "". But just in case you try, allow me to introduce you to someone...""), true); cs.npcFaceDir(""surok"", Direction.WEST); cs.npcTalk(""surok"", ""Bork! Kill the meddler!""); cs.delay(1); cs.playerFaceDir(Direction.WEST); cs.delay(2); cs.playerAnim(EmotesManager.Emote.SCARED.getAnim()); cs.delay(3); } cs.action(() -> player.getInterfaceManager().sendForegroundInterfaceOverGameWindow(692)); cs.delay(15); cs.action(() -> player.getInterfaceManager().closeInterfacesOverGameWindow()); cs.camPosReset(); cs.fadeOut(3); cs.hideMinimap(false); cs.action(() -> { World.spawnNPC(7134, Tile.of(cs.getX(27), cs.getY(33), 0), -1, true, true, true).setForceMultiArea(true); player.resetReceivedHits(); player.unlock(); }); })); } @Override public void onDestroyInstance() { player.setForceMultiArea(false); player.unlock(); } @Override public void onTeleported(TeleType type) { player.getControllerManager().forceStop(); } @Override public boolean processObjectClick1(GameObject object) { if (object.getId() == 29537) { player.getControllerManager().forceStop(); player.setNextSpotAnim(new SpotAnim(110, 10, 96)); player.useStairs(-1, getInstance().getReturnTo(), 2, 3); } return true; } }" "package com.rs.game.content.miniquests.huntforsurok.npcs; @PluginEventHandler public class AnnaJones extends Conversation { public static final int ID = 5837; public static NPCClickHandler handle = new NPCClickHandler(new Object[] { ID }, e -> e.getPlayer().startConversation(new AnnaJones(e.getPlayer()))); public AnnaJones(Player player) { super(player); if (player.isQuestComplete(Quest.WHAT_LIES_BELOW) && player.getVars().getVarBit(3524) == 1) { addNPC(ID, HeadE.CHEERFUL, ""It's so exciting!""); addPlayer(HeadE.CONFUSED, ""What is?""); addNPC(ID, HeadE.CHEERFUL, ""Surok is here! He's looking at the tunnel right now! Gosh, isn't this the best thing ever?""); addPlayer(HeadE.AMAZED, ""Surok is out here?""); addNPC(ID, HeadE.CHEERFUL, ""Oh, yes. He's just over there. As soon as he's finished looking at the tunnel, I need to speak with him about getting paid!""); addPlayer(HeadE.AMAZED, ""Oh - perhaps I should speak to him first.""); addNPC(ID, HeadE.CHEERFUL, ""By all means, go ahead.""); addPlayer(HeadE.CHEERFUL, ""Thanks.""); create(); return; } if (player.getQuestStage(Quest.WHAT_LIES_BELOW) >= 4 && !player.getBool(""annaTunnelTalk"")) { addNPC(ID, HeadE.CHEERFUL, ""Ah, hello "" + player.getDisplayName() + ""! Here is a bronze pickaxe."", () -> player.getInventory().addItemDrop(Pickaxe.BRONZE.getItemId(), 1)); addNPC(ID, HeadE.CHEERFUL, ""My employer, Surok Magis, sent word to me that you may come to use the tunnel. You will need something to help you get in there. The pickaxe I've given to you should help.""); addPlayer(HeadE.CHEERFUL, ""Uh, thanks.""); addNPC(ID, HeadE.CHEERFUL, ""Okay, then. The tunnel awaits..."", () -> player.save(""annaTunnelTalk"", true)); } else addNPC(ID, HeadE.CHEERFUL, ""Yes? Can I help you?""); addOptions(this, ""startOps"", ops -> { if (player.getBool(""annaTunnelTalk"")) ops.add(""What tunnel?"") .addPlayer(HeadE.CONFUSED, ""What tunnel?"") .addNPC(ID, HeadE.CALM_TALK, ""Why, the Chaos Tunnel of course! I imagine Surok will have told you of it."") .addPlayer(HeadE.CALM_TALK, ""Oh, I see. Well, what can you tell me about it?"") .addNPC(ID, HeadE.CHEERFUL, ""Well, story and rumor has it that the Dagon'hai built a tunnel here under the statue of Saradomin that would allow them to visit the Chaos Altar without having to go through the Wilderness."") .addPlayer(HeadE.CHEERFUL, ""That's extremely handy!"") .addNPC(ID, HeadE.SAD_MILD, ""Yes, it is. Or, at least, it would be. Unfortunately, I haven't been able to get in there so far."") .addPlayer(HeadE.CONFUSED, ""Why not?"") .addNPC(ID, HeadE.CALM_TALK, ""The tunnel entrance needs to be cleared before anyone can get in there. However, my Mining skill isn't high enough at all to do it myself. Perhaps you could have a go?""); ops.add(""Who are you?"") .addPlayer(HeadE.CONFUSED, ""Who are you?"") .addNPC(ID, HeadE.CHEERFUL, ""Well, now. Do you always go around asking about people like that? It's very rude, you know."") .addPlayer(HeadE.AMAZED, ""Sorry! I didn't mean to pry!"") .addNPC(ID, HeadE.CHEERFUL, ""That's alright. My name is Louisiana Jones, although most people call me Anna. I'm an archaeologist."") .addPlayer(HeadE.CONFUSED, ""Oh. Do you work for the Varrock Museum?"") .addNPC(ID, HeadE.CHEERFUL, ""Hah! No. I used to, but now I prefer to work freelance for independent employers."") .addPlayer(HeadE.CONFUSED, ""I see."") .addGotoStage(""startOps"", this); ops.add(""What are you doing here?"") .addPlayer(HeadE.CONFUSED, ""What are you doing here?"") .addNPC(ID, HeadE.CHEERFUL, ""I'm investigating something for someone."") .addPlayer(HeadE.AMAZED, ""That doesn't really explain anything!"") .addNPC(ID, HeadE.CHEERFUL, ""I never said it would."") .addPlayer(HeadE.CONFUSED, ""So what are you investigating?"") .addNPC(ID, HeadE.CHEERFUL, ""I'm afraid I can't say."") .addPlayer(HeadE.CONFUSED, ""Okay, so who are you investigating it for?"") .addNPC(ID, HeadE.CHEERFUL, ""I'm afraid I can't say that either."") .addPlayer(HeadE.SAD_MILD, ""Okay, so is there anything you CAN say?"") .addNPC(ID, HeadE.CHEERFUL, ""I can say that I can't say anything about what you want me to say!"") .addPlayer(HeadE.CONFUSED, ""Okay, I think you've said enough!"") .addGotoStage(""startOps"", this); ops.add(""Who does this statue represent?"") .addPlayer(HeadE.CONFUSED, ""Who does this statue represent?"") .addNPC(ID, HeadE.CHEERFUL, ""That, my dear, is the statue of the great god Saradomin himself. Stand and admire in awe, for you are in the presence of greatness!"") .addOptions(hailOps -> { hailOps.add(""All hail Saradomin!"") .addPlayer(HeadE.CHEERFUL, ""All hail Saradomin!"") .addNPC(ID, HeadE.CHEERFUL, ""Indeed. Saradomin watches over us all."") .addGotoStage(""startOps"", this); hailOps.add(""...Yay Zamorak...!"") .addPlayer(HeadE.CALM_TALK, ""...Yay Zamorak...!"") .addNPC(ID, HeadE.ANGRY, ""WHAT?!?!"") .addPlayer(HeadE.AMAZED, ""Uh...I said I've lost my anorak!"") .addNPC(ID, HeadE.CALM_TALK, ""I see. I'm afraid I haven't seen it."") .addGotoStage(""startOps"", this); }); ops.add(""Okay, I better go."") .addPlayer(HeadE.CALM_TALK, ""Okay, I'd better go."") .addNPC(ID, HeadE.CHEERFUL, ""Okay, then!""); }); } }" "package com.rs.game.content.miniquests.huntforsurok.npcs; @PluginEventHandler public class SurokHFS { public static final int ID = 7009; public static NPCClickHandler talk = new NPCClickHandler(new Object[] { ID }, e -> { if (e.getPlayer().isQuestComplete(Quest.WHAT_LIES_BELOW)) e.getPlayer().startConversation(new Dialogue() .addNPC(ID, HeadE.FRUSTRATED, e.getPlayer().getDisplayName()+""! The meddling adventurer."") .addPlayer(HeadE.AMAZED, ""Surok! What are you doing here? How did you-"") .addNPC(ID, HeadE.FRUSTRATED, ""Escape from Varrock Palace Library? That cruel imprisonment you left me in?"") .addPlayer(HeadE.AMAZED, ""Well...er...yes."") .addNPC(ID, HeadE.FRUSTRATED, ""Bah! A mere trifle for a powerful mage such as myself. There were plenty of other foolish people to help with my plans and you would do well to stay out of my way."") .addNextIf(() -> !Miniquest.HUNT_FOR_SUROK.meetsReqs(e.getPlayer(), ""to start Hunt for Surok."", true), new Dialogue() .addStop()) .addPlayer(HeadE.FRUSTRATED, ""Stop, Surok! As a member of the Varrock Palace Secret Guard, I arrest you! Again!"") .addNPC(ID, HeadE.FRUSTRATED, ""Ha! I tire of this meaningless drivel. Catch me if you can."") .addNext(() -> e.getPlayer().playCutscene(cs -> { cs.setEndTile(e.getPlayer().getTile()); cs.fadeIn(5); cs.action(() -> e.getPlayer().setMiniquestStage(Miniquest.HUNT_FOR_SUROK, 1)); cs.dynamicRegion(e.getPlayer().getTile(), 408, 431, 5, 5, true); cs.npcCreate(""surok"", 7002, 18, 18, 0); cs.playerMove(19, 16, Entity.MoveType.TELE); cs.npcFaceTile(""surok"", 19, 16); cs.playerFaceTile(18, 18); cs.camPos(19, 3, 8572); cs.camLook(19, 19, 0); cs.camPos(19, 7, 3541, 0, 5); cs.fadeOut(5); cs.npcTalk(""surok"", ""A distraction is needed!""); cs.npcSync(""surok"", 6098, 1009); cs.delay(1); cs.npcAnim(""surok"", -1); cs.action(() -> World.sendProjectile(cs.getNPC(""surok""), cs.getPlayer().transform(2, -3, 0), 1010, 5, 15, 15, 0.4, 10, 10)); cs.delay(1); cs.playerTalk(""Whoah!""); cs.playerAnim(EmotesManager.Emote.CRY.getAnim()); cs.delay(1); cs.npcWalk(""surok"", 19, 19); cs.delay(0); cs.npcFaceTile(""surok"", 19, 20); cs.npcAnim(""surok"", 451); cs.delay(0); cs.npcDestroy(""surok""); cs.delay(2); cs.fadeIn(5); cs.returnPlayerFromInstance(); cs.camPosReset(); cs.fadeOut(5); cs.dialogue(new Dialogue().addPlayer(HeadE.SAD_MILD, ""I'd better get after him before he gets away."")); }))); }); }" "package com.rs.game.content.miniquests.troll_warzone; public class TrollGeneralAttackController extends InstancedController { private static final Tile OUTSIDE = Tile.of(2878, 3573, 0); private transient int stage = 0; private transient NPC ozan, keymans, trollGeneral; public TrollGeneralAttackController() { super(Instance.of(OUTSIDE, 8, 8).persist().setEntranceOffset(new int[]{32, 12, 0})); } @Override public void onBuildInstance() { player.lock(); getInstance().copyMapAllPlanes(272, 544).thenAccept(b -> player.playCutscene(cs -> { cs.fadeIn(5); cs.action(1, () -> getInstance().teleportLocal(player, 32, 12, 0)); cs.action(() -> { player.setForceNextMapLoadRefresh(true); player.loadMapRegions(); cs.setEndTile(Tile.of(cs.getX(32), cs.getY(12), 0)); }); cs.npcCreate(""ozan"", 14983, 33, 28, 0, n -> { n.persistBeyondCutscene(); n.setIgnoreNPCClipping(true); n.setRun(true); ozan = n; }); cs.npcCreate(""keymans"", 14988, 34, 28, 0, n -> { n.persistBeyondCutscene(); n.setIgnoreNPCClipping(true); n.setRun(true); keymans = n; }); cs.npcCreate(""brute"", 14980, 27, 43, 0, n -> { n.setRandomWalk(true); n.persistBeyondCutscene(); }); cs.npcCreate(""chucker"", 14981, 29, 46, 0, n -> { n.setRandomWalk(true); n.persistBeyondCutscene(); }); cs.npcCreate(""shaman"", 14982, 31, 44, 0, n -> { n.setRandomWalk(true); n.persistBeyondCutscene(); }); cs.action(() -> player.getHintIconsManager().addHintIcon(cs.getNPC(""ozan""), 0, -1, false)); cs.fadeOut(5); cs.action(() -> player.unlock()); })); } @Override public void onDestroyInstance() { player.setForceMultiArea(false); } @Override public boolean sendDeath() { player.safeDeath(OUTSIDE); return false; } @Override public boolean processNPCClick1(NPC npc) { npc.faceTile(player.getTile()); player.faceTile(npc.getTile()); switch (npc.getId()) { //Ozan case 14983, 14987 -> { switch (stage) { case 0 -> player.startConversation(new Dialogue() .addNPC(npc, HeadE.CALM_TALK, ""The trolls are bypassing Burthorpe's defenses through this tunnel!

Click the green button below or press the space bar."") .addNPC(npc, HeadE.CALM_TALK, ""You lead, we'll follow."", () -> { stage = 1; ozan.follow(player); keymans.follow(ozan); player.getHintIconsManager().removeAll(); trollGeneral = World.spawnNPC(14991, Tile.of(getInstance().getLocalX(36), getInstance().getLocalY(53), 0), -1, true, true, true); trollGeneral.setRandomWalk(false); trollGeneral.setCantInteract(true); player.getHintIconsManager().addHintIcon(getInstance().getLocalX(37), getInstance().getLocalY(54), 0, 50, 0, 0, -1, false); })); case 1 -> player.startConversation(new Dialogue() .addNPC(npc, HeadE.CALM_TALK, ""I can hear some loud footsteps up ahead. You lead, we'll follow."")); case 2 -> player.startConversation(new Dialogue() .addNPC(npc, HeadE.ANGRY, ""There's no time to talk! Attack!"")); case 3 -> player.startConversation(new Dialogue() .addNPC(npc, HeadE.HAPPY_TALKING, ""Congratulations all around, friends! Now all we need to do is-"") .addNPC(npc, HeadE.CALM, ""..."") .addNPC(npc, HeadE.CONFUSED, ""Hey, did you hear that?"") .addNPC(npc, HeadE.CALM_TALK, ""It came from over there."") .addNext(() -> player.playCutscene(cs -> { cs.fadeIn(5); cs.npcCreate(""babyTroll"", 14846, 28, 48, 0); cs.action(() -> { player.getHintIconsManager().removeUnsavedHintIcon(); ozan.tele(Tile.of(getInstance().getLocalX(36), getInstance().getLocalY(51), 0)); player.tele(Tile.of(getInstance().getLocalX(36), getInstance().getLocalY(48), 0)); }); cs.camPos(36, 51, 1000); cs.camLook(31, 51, 0); cs.fadeOut(5); cs.npcMove(""babyTroll"", 28, 51, MoveType.RUN, 2); cs.camPos(32, 45, 2000, 0, 10, 1); cs.npcMove(""babyTroll"", 30, 51, MoveType.RUN, 3); cs.action(4, () -> { ozan.setRun(false); ozan.addWalkSteps(getInstance().getLocalX(33), getInstance().getLocalY(51)); }); cs.action(1, () -> ozan.faceTile(Tile.of(getInstance().getLocalX(20), getInstance().getLocalY(51), 0))); cs.action(() -> ozan.tele(Tile.of(getInstance().getLocalX(31), getInstance().getLocalY(51), 0))); cs.npcDestroy(""babyTroll""); cs.action(() -> { ozan.transformIntoNPC(14987); ozan.anim(15817); cs.npcDestroy(""babyTroll""); }); cs.delay(23); cs.action(() -> { stage = 4; player.getHintIconsManager().addHintIcon(getInstance().getLocalX(ozan.getXInRegion()), getInstance().getLocalY(ozan.getYInRegion()), 0, 50, 0, 0, -1, false); }); }))); case 4 -> { Dialogue endDialogue = new Dialogue() .addNPC(14846, HeadE.T_CONFUSED, ""Food?"") .addNPC(npc, HeadE.CALM_TALK, ""I'm going to take this little fellow to the training grounds."") .addNPC(npc, HeadE.CALM_TALK, ""Thanks again for your help. You should check in with Captain Jute outside the cave."") .addNext(() -> player.playCutscene(cs -> { cs.action(() -> { ozan.addWalkSteps(ozan.transform(0, -10, 0).getX(), ozan.transform(0, -10, 0).getY()); keymans.addWalkSteps(keymans.transform(0, -10, 0).getX(), keymans.transform(0, -10, 0).getY()); }); cs.fadeIn(5); cs.action(() -> { ozan.finish(); keymans.finish(); }); cs.fadeOut(5); cs.action(() -> { stage = 5; player.getHintIconsManager().removeUnsavedHintIcon(); player.getHintIconsManager().addHintIcon(getInstance().getLocalX(32), getInstance().getLocalY(12), 0, 50, 0, 0, -1, false); }); })).getHead(); player.startConversation(new Dialogue() .addNPC(npc, HeadE.CONFUSED, ""Where did this little guy come from? Do trolls always bring babies along on raids?"") .addOptions(ops -> { ops.add(""Don't we have more important things to worry about?"") .addNPC(npc, HeadE.SAD, ""We can't just leave it here to die."") .addNext(endDialogue); ops.add(""He's so cute!"") .addNPC(npc, HeadE.SAD_MILD, ""Isn't he? He's so wubbly!"") .addNext(endDialogue); ops.add(""We should kill it before it becomes a threat!"") .addNPC(npc, HeadE.SAD, ""I can't just execute a baby even if it is a troll!"") .addNext(endDialogue); })); } } } //Keymans case 14988 -> { switch (stage) { case 0 -> player.startConversation(new Dialogue() .addNPC(npc, HeadE.CONFUSED, ""Ozan, what should we do next?

Click the green button below or press the space bar."")); case 1 -> player.startConversation(new Dialogue() .addNPC(npc, HeadE.AMAZED, ""Whoah! There is something huge up ahead."")); case 2 -> player.startConversation(new Dialogue() .addNPC(npc, HeadE.ANGRY, ""There's no time to talk! Attack!"")); case 3 -> player.startConversation(new Dialogue() .addNPC(npc, HeadE.CONFUSED, ""What should we do next, Ozan?"")); } } } return false; } @Override public boolean processObjectClick1(GameObject object) { if (object.getId() == 66534) { if (stage == 5) { player.getHintIconsManager().removeUnsavedHintIcon(); player.getMiniquestManager().setStage(Miniquest.TROLL_WARZONE, 2); player.tele(OUTSIDE); player.getControllerManager().forceStop(); return false; } player.sendOptionDialogue(""Would you like to leave the tutorial area?"", ops -> { ops.add(""Yes, please."", () -> { player.tele(OUTSIDE); player.getControllerManager().forceStop(); }); ops.add(""No, I'm not done here yet.""); }); return false; } return true; } @Override public boolean canMove(Direction dir) { if (stage == 0 && player.getTile().getXInRegion() >= 32 && player.getTile().getXInRegion() <= 35 && player.getTile().getYInRegion() >= 27 && dir.dy > 0) return false; if (stage == 1 && player.getTile().getYInRegion() >= 49) { player.stopAll(); player.lock(); player.playCutscene(cs -> { cs.action(() -> { ozan.stopAll(); keymans.stopAll(); player.tele(Tile.of(getInstance().getLocalX(34), getInstance().getLocalY(50), 0)); ozan.tele(Tile.of(getInstance().getLocalX(33), getInstance().getLocalY(51), 0)); keymans.tele(Tile.of(getInstance().getLocalX(35), getInstance().getLocalY(49), 0)); }); cs.camPos(33, 45, 2000, 0, 5); cs.camLook(trollGeneral.getXInRegion(), trollGeneral.getYInRegion(), 10, 0, 5); cs.delay(5); cs.action(() -> { trollGeneral.faceTile(player.getTile()); player.faceTile(trollGeneral.getTile()); ozan.faceTile(trollGeneral.getTile()); keymans.faceTile(trollGeneral.getTile()); }); cs.dialogue(new Dialogue() .addNPC(ozan, HeadE.ANGRY, ""The troll general! Bring him down!"") .addNPC(trollGeneral, HeadE.T_ANGRY, ""STUPID HUMANS! TROLLS SMASH YOUR STUPID FACE!""), true); cs.action(() -> { trollGeneral.setForceMultiArea(true); ozan.setForceMultiArea(true); keymans.setForceMultiArea(true); player.setForceMultiArea(true); trollGeneral.setCantInteract(false); trollGeneral.setTarget(player); trollGeneral.addReceivedDamage(player, 5000); ozan.setTarget(trollGeneral); keymans.setTarget(trollGeneral); }); cs.camPosResetSoft(); }); stage = 2; return false; } return true; } @Override public void processNPCDeath(NPC npc) { if (npc.getId() == 14991 && stage == 2) { for (NPC n : World.getNPCsInChunkRange(player.getChunkId(), 3)) { if (n.getId() >= 14980 && n.getId() <= 14982) n.finish(); } World.addGroundItem(new Item(23042), npc.getMiddleTile()); World.addGroundItem(new Item(23031), npc.getMiddleTile()); stage = 3; player.getHintIconsManager().removeAll(); player.getHintIconsManager().addHintIcon(getInstance().getLocalX(ozan.getXInRegion()), getInstance().getLocalY(ozan.getYInRegion()), 0, 50, 0, 0, -1, false); } } }" "package com.rs.game.content.miniquests.troll_warzone; @MiniquestHandler( miniquest = Miniquest.TROLL_WARZONE, startText = ""Speak to Major Nigel Corothers just outside the Warrior's Guild in Burthorpe."", itemsText = ""None"", combatText = ""Must be able to defeat a level 12 Troll General."", rewardsText = ""A baby troll!
110 Cooking XP
110 Mining XP
110 Woodcutting XP
Some teleport tablets
Some combat potions"", completedStage = 6 ) @PluginEventHandler public class TrollWarzone extends MiniquestOutline { //9 - troll general comes down from the mountain //10 - ambushing trolls with archers //11 - intro to burthorpe tutorial //12 - player shoots cannon to close off the troll invasion @Override public List getJournalLines(Player player, int stage) { ArrayList lines = new ArrayList<>(); switch (stage) { case 0 -> { lines.add(""I can start this miniquest by speaking to Major Nigel Corothers in""); lines.add(""northern Burthorpe.""); lines.add(""""); } case 4 -> { lines.add(""""); lines.add(""""); lines.add(""MINIQUEST COMPLETE!""); } default -> lines.add(""Invalid quest stage. Report this to an administrator.""); } return lines; } @Override public void complete(Player player) { player.getSkills().addXpQuest(Skills.COOKING, 110); player.getSkills().addXpQuest(Skills.MINING, 110); player.getSkills().addXpQuest(Skills.WOODCUTTING, 110); player.getInventory().addItemDrop(23030, 1); player.getInventory().addItemDrop(8007, 5); player.getInventory().addItemDrop(8009, 5); player.getInventory().addItemDrop(2429, 5); player.getInventory().addItemDrop(114, 5); player.getInventory().addItemDrop(2433, 5); player.getInventory().addItemDrop(2435, 5); sendQuestCompleteInterface(player, 23030); } @Override public void updateStage(Player player) { if (player.getMiniquestManager().getStage(Miniquest.TROLL_WARZONE) >= 5) player.getVars().setVarBit(10683, player.getMiniquestManager().getStage(Miniquest.TROLL_WARZONE)); //varbit 10683 updates corporal keymans to claim the baby troll } public static ObjectClickHandler handleTrollCaveEnterExit = new ObjectClickHandler(new Object[] { 66533, 66534 }, e -> { switch(e.getObjectId()) { case 66533 -> { if (e.getPlayer().getMiniquestManager().getStage(Miniquest.TROLL_WARZONE) < 1) { e.getPlayer().simpleDialogue(""You should speak with Major Nigel Corothers before going in here. He's only just south of here.""); return; } if (e.getPlayer().getMiniquestManager().getStage(Miniquest.TROLL_WARZONE) == 1) { e.getPlayer().sendOptionDialogue(""Would you like to continue the Troll Warzone miniquest?"", ops -> { ops.add(""Yes."", () -> e.getPlayer().getControllerManager().startController(new TrollGeneralAttackController())); ops.add(""Not right now.""); }); return; } e.getPlayer().useStairs(-1, Tile.of(2208, 4364, 0), 0, 1); } case 66534 -> e.getPlayer().useStairs(-1, Tile.of(2878, 3573, 0), 0, 1); } }); public static Dialogue getCaptainJuteDialogue(Player player, NPC npc) { Dialogue dialogue = new Dialogue(); switch(player.getMiniquestManager().getStage(Miniquest.TROLL_WARZONE)) { case 0 -> dialogue.addNPC(npc, HeadE.FRUSTRATED, ""The trolls are overrunning us! Major Nigel has been trying to find recruits.""); case 1 -> dialogue.addNPC(npc, HeadE.FRUSTRATED, ""Get back in the cave over there to help Ozan and Keymans!""); case 2 -> dialogue.addNPC(npc, HeadE.CALM_TALK, ""Ozan tells me that you defeated one of the troll generals."") .addNPC(npc, HeadE.CALM_TALK, ""The trolls are getting into that cave through a back entrance high on Death Plateau. If we try to collapse this end, we could collapse the whole castle with it!"") .addNPC(npc, HeadE.CALM_TALK, ""Death Plateau itself is too dangerous to assault. I need you to get to the top of the castle and direct cannon fire onto that back entrance!"") .addOptions(ops -> { ops.add(""I'll do it right away!"", () -> player.getMiniquestManager().setStage(Miniquest.TROLL_WARZONE, 3)); ops.add(""I want to kill more trolls!""); }); case 3 -> dialogue.addNPC(npc, HeadE.CALM_TALK, ""What are you waiting for? Get up on top of the castle and fire a cannon into that cavern back entrance!""); default -> dialogue.addNPC(npc, HeadE.CALM_TALK, ""Excellent work bringing down the cavern entrance. You should go check in with Corothers.""); } return dialogue; } public static ObjectClickHandler handleCannonFire = new ObjectClickHandler(new Object[] { 66981 }, e -> { if (e.getPlayer().getMiniquestManager().getStage(Miniquest.TROLL_WARZONE) == 3) { e.getPlayer().getMiniquestManager().setStage(Miniquest.TROLL_WARZONE, 4); e.getPlayer().playPacketCutscene(12, () -> e.getPlayer().playerDialogue(HeadE.HAPPY_TALKING, ""That just about does it. I should check in with Corothers."")); return; } if (e.getPlayer().getMiniquestManager().getStage(Miniquest.TROLL_WARZONE) < 3) e.getPlayer().sendMessage(""You haven't been given approval to fire off any cannons here.""); else e.getPlayer().sendMessage(""I've collapsed the entrance with the cannon. I should check in with Corothers.""); }); }" "package com.rs.game.content.miniquests.troll_warzone.npcs; @PluginEventHandler public class CorporalKeymans { //13445 public static NPCClickHandler handleOps = new NPCClickHandler(new Object[] { 14994 }, e -> { switch(e.getOption()) { case ""Talk-to"" -> { if (!e.getPlayer().getMiniquestManager().isComplete(Miniquest.TROLL_WARZONE) && e.getPlayer().getMiniquestManager().getStage(Miniquest.TROLL_WARZONE) >= 5) { e.getPlayer().startConversation(new Dialogue() .addNPC(14994, HeadE.CALM_TALK, ""Ozan dumped that baby troll on me. I don't know what to do with him."") .addPlayer(HeadE.HAPPY_TALKING, ""I could look after him."") .addNext(() -> e.getPlayer().getMiniquestManager().complete(Miniquest.TROLL_WARZONE))); return; } if (e.getPlayer().containsItem(23030) || (e.getPlayer().getPet() != null && e.getPlayer().getPet().getId() == Pets.TROLL_BABY.getBabyNpcId())) e.getPlayer().npcDialogue(e.getNPC(), HeadE.CALM_TALK, ""Thanks for all your help in the cave""); else e.getPlayer().startConversation(new Dialogue() .addNPC(e.getNPCId(), HeadE.FRUSTRATED, ""I found this little guy wandering around up here. Thought you might want him back. Try not to lose him again."") .addItemToInv(e.getPlayer(), new Item(23030), ""You reclaim the baby troll."")); } } }); }" "package com.rs.game.content.miniquests.troll_warzone.npcs; @PluginEventHandler public class MajorNigel extends Conversation { public static NPCClickHandler handleOps = new NPCClickHandler(new Object[] { 14850 }, e -> { switch(e.getOption()) { case ""Talk-to"" -> e.getPlayer().startConversation(new MajorNigel(e.getPlayer(), e.getNPC())); case ""Get-recommendation"" -> e.getPlayer().startConversation(new Dialogue().addNPC(14850, HeadE.FRUSTRATED, ""If you're looking to train combat, soldier, I'd recommend ridding the local area of as many trolls as possible. Or there are some cows to the south."")); } }); public MajorNigel(Player player, NPC npc) { super(player); switch(player.getMiniquestManager().getStage(Miniquest.TROLL_WARZONE)) { case 0 -> addOptions(""Would you like to start the Troll Warzone miniquest?"", ops -> { ops.add(""Yes."", () -> { player.playPacketCutscene(11, () -> player.getControllerManager().startController(new TrollGeneralAttackController())); player.getMiniquestManager().setStage(Miniquest.TROLL_WARZONE, 1); }); ops.add(""Not right now.""); }); case 1 -> addNPC(npc, HeadE.FRUSTRATED, ""You need to get back up to the cave to the north and assist in stopping the trolls!""); case 2, 3 -> addNPC(npc, HeadE.FRUSTRATED, ""Excellent work in holding back the trolls in the cave. Captain Jute up north said he wanted to talk to you.""); case 4 -> { addNPC(npc, HeadE.FRUSTRATED, ""So you've thwarted the recent attack by defeating the general. Good work. Looks like the trolls have let up their attacks for now."").voiceEffect(12434); addNPC(npc, HeadE.FRUSTRATED, ""Here in Burthorpe we've been hit pretty hard. Taverly, the town to the south, has been sending us aid and they're in bad shape too."").voiceEffect(11121); addNPC(npc, HeadE.FRUSTRATED, ""What we need to do now is recover in time for the next attack. I need you to work your way around Burthorpe and Taverly lending your help where you can."").voiceEffect(12488); addNPC(npc, HeadE.FRUSTRATED, ""We have a lot of experts here, helping with the war effort. Check in with them to see what you can do."").voiceEffect(11208); addPlayer(HeadE.CHEERFUL, ""I'm on it.""); addNext(() -> player.getMiniquestManager().setStage(Miniquest.TROLL_WARZONE, 5)); } case 5 -> addNPC(npc, HeadE.FRUSTRATED, ""Go check in with Keymans. He said he has something for you.""); default -> addNPC(npc, HeadE.FRUSTRATED, ""Burthorpe is still under dire threat. We need every hero we can get in top shape."").voiceEffect(12443); } } }" "package com.rs.game.content.miniquests.troll_warzone.npcs; public class TrollGeneralCombat extends CombatScript { @Override public Object[] getKeys() { return new Object[] { 14991, 14992 }; } @Override public int attack(NPC npc, Entity target) { if (npc.inMeleeRange(target)) { npc.anim(1932); delayHit(npc, 1, target, getMeleeHit(npc, getMaxHit(npc, 2, NPCCombatDefinitions.AttackStyle.MELEE, target))); } else { npc.sync(1933, 262); delayHit(npc, World.sendProjectile(npc, target, 295, 34, 16, 60, 2.0, 16, 0).getTaskDelay(), target, getRangeHit(npc, getMaxHit(npc, 2, NPCCombatDefinitions.AttackStyle.RANGE, target))); } return npc.getAttackSpeed(); } }" "package com.rs.game.content.miniquests.witches_potion class HettyD(p: Player, npc: NPC) { init { when(p.getMiniquestStage(Miniquest.WITCHES_POTION)) { WitchesPotion.NOT_STARTED -> { mapNotStarted(p, npc) } WitchesPotion.NEED_INGREDIENTS -> { mapNeedIngredients(p, npc) } WitchesPotion.HANDED_IN_INGREDIENTS -> { mapHandedInIngredients(p, npc) } WitchesPotion.COMPLETED -> { mapCompleted(p, npc) } } } private fun mapNotStarted(p: Player, npc: NPC) { p.startConversation { label(""startOfNotStarted"") npc(npc, CONFUSED, ""What could you want with an old woman like me?"") options { op(""You look like a witch."") { player(CHEERFUL, ""You look like a witch."") npc(npc, WORRIED, ""Yes, I suppose I'm not being very subtle about it. I fear I may get a visit from the witch hungers of Falador before long."") goto(""startOfNotStarted"") } op(""Nothing, thanks."") { player(CALM, ""Nothing, thanks"") } op(""I'm looking for work."") { player(CHEERFUL, ""I'm looking for work."") npc(npc, SECRETIVE, ""Hmmm... Perhaps you could do something that would help both of us."") npc(npc, SECRETIVE, ""Would you like to become more proficient in the dark arts?"") options { op(""No, I have my principles and honour."") { player(FRUSTRATED, ""No, I have my principles and honour."") npc(npc, LAUGH, ""Suit yourself, but you're missing out."") } op(""What, you mean improve my magic?"") { player(LAUGH, ""What, you mean improve my magic?"") simple(""The witch sighs."") npc(npc, FRUSTRATED, ""Yes, improve your magic... Do you have no sense of drama?"") options { op(""Yes, I'd like to improve my magic."") { player(CHEERFUL, ""Yes, I'd like to improve my magic."") simple(""The witch sighs."") exec { mapStartMiniquest(p, npc) } } op(""No, I'm not interested."") { player(CALM, ""No, I'm not interested."") npc(npc, LAUGH, ""Many aren't, at first."") simple(""The witch smiles mysteriously."") npc(npc, LAUGH, ""But I think you'll be drawn back to this place."") } op(""Show me the mysteries of the dark arts..."") { exec { mapStartMiniquest(p, npc) } } } } } } } } } private fun mapStartMiniquest(p: Player, npc: NPC) { p.startConversation { npc(npc, HAPPY_TALKING, ""OK, I'm going to make a potion to help bring out your darker self. You will need certain ingredients."") { p.miniquestManager.setStage(Miniquest.WITCHES_POTION, WitchesPotion.NEED_INGREDIENTS) } label(""startOptions"") options { op(""What do I need?"") { player(CHEERFUL, ""What do I need?"") npc(npc, CHEERFUL, ""You need an eye of newt, a rat's tail, an onion... Oh, and a piece of burnt meat."") goto(""startOptions"") } op(""Where can I find a rat's tail?"") { player(CONFUSED, ""Where can I find a rat's tail?"") npc(npc, LAUGH, ""On a rat! There are lots of rodents around here; try killing one."") goto(""startOptions"") } op(""Where can I find burnt meat?"") { player(CONFUSED, ""Where can I find burnt meat?"") npc(npc, CALM, ""Find yourself a piece of meat and cook it twice. It'll burn."") goto(""startOptions"") } op(""Where can I find an onion?"") { player(CONFUSED, ""Where can I find an onion?"") npc(npc, CALM, ""There's a field of onions just north of here. No-one will mind if you borrow a few."") goto(""startOptions"") } op(""Where can I find an eye of newt?"") { player(CONFUSED, ""Where can I find an eye of newt?"") npc(npc, CALM, ""There's a shop in Port Sarim, east of here. You can buy newt eyes there."") goto(""startOptions"") } op(""Okay, I'll be off."") { player(CHEERFUL, ""Okay, I'll be off."") } } } } private fun mapNeedIngredients(p: Player, npc: NPC) { val reqItems = listOf(Item(WitchesPotion.ONION_ID), Item(WitchesPotion.RATS_TAIL_ID), Item(WitchesPotion.EYE_OF_NEWT_ID), Item(WitchesPotion.BURNT_MEAT_ID)) p.startConversation { npc(npc, CHEERFUL, ""So, have you found the things for the potion?"") if (p.inventory.containsItems(reqItems)) { player(CHEERFUL, ""Yes, I have everything!"") npc(npc, CALM, ""Excellent, can I have them then?"") simple(""You pass the ingredients to Hetty and she puts them all into her cauldron. Hetty closes her eyes and begins to chant. The cauldron bubbles mysteriously."") player(CONFUSED, ""Well, is it ready?"") npc(npc, EVIL_LAUGH, ""Ok, now drink from the cauldron."") { p.inventory.removeItems(reqItems) p.miniquestManager.setStage(Miniquest.WITCHES_POTION, WitchesPotion.HANDED_IN_INGREDIENTS) } } else { player(SAD, ""No, not yet."") npc(npc, CALM, ""Well, remember you need to get an eye of newt, a rat's tail, some burnt meat and an onion."") } } } private fun mapHandedInIngredients(p: Player, npc: NPC) { p.startConversation { npc(npc, VERY_FRUSTRATED, ""Well, are you going to drink the potion or not?"") } } private fun mapCompleted(p: Player, npc: NPC) { p.startConversation { npc(npc, HAPPY_TALKING, ""How's your magic coming along?"") player(CHEERFUL, ""I'm practicing and slowly getting better."") npc(npc, CALM, ""Good, good."") } } }" "package com.rs.game.content.miniquests.witches_potion @MiniquestHandler( miniquest = Miniquest.WITCHES_POTION, startText = ""Hetty in her house in Rimmington."", itemsText = ""None."", combatText = ""Level 1 Rat"", rewardsText = ""325 Magic XP"", completedStage = WitchesPotion.COMPLETED ) class WitchesPotion : MiniquestOutline() { companion object { const val ONION_ID = 1957 const val RATS_TAIL_ID = 300 const val EYE_OF_NEWT_ID = 221 const val BURNT_MEAT_ID = 2146 const val NOT_STARTED = 0 const val NEED_INGREDIENTS = 1 const val HANDED_IN_INGREDIENTS = 2 const val COMPLETED = 3 } override fun getJournalLines(p: Player, stage: Int): List { val lines = ArrayList() when (stage) { NOT_STARTED -> { lines.add(""I can start this miniquest by talking to Hetty in"") lines.add(""her house in Rimmington."") } NEED_INGREDIENTS -> { lines.add(""Hetty has said that in order for her to make"") lines.add(""me a potion to help bring out my darker"") lines.add(""self, I must bring her the following ingredients:"") lines.add("""") lines.add(""1 rat's tail"") lines.add(""1 burnt meat"") lines.add(""1 eye of newt"") lines.add(""1 onion"") } HANDED_IN_INGREDIENTS -> { lines.add(""I have given Hetty all the ingredients she asked for,"") lines.add(""and she has told me to drink from her cauldron."") lines.add("""") lines.add(""If I really want to bring out my darker self"") lines.add(""I should give this potion a try."") lines.add("""") lines.add(""What's the worst that could happen?"") } COMPLETED -> { lines.add("""") lines.add("""") lines.add(""MINIQUEST COMPLETE!"") } else -> lines.add(""Invalid miniquest stage. Report this to an administrator."") } return lines } override fun complete(p: Player) { p.skills.addXpQuest(Skills.MAGIC, 325.0) sendQuestCompleteInterface(p, RATS_TAIL_ID) } override fun updateStage(p: Player) { p.vars.setVar(67, if (p.getMiniquestStage(Miniquest.WITCHES_POTION) == HANDED_IN_INGREDIENTS) 2 else 3) } } @ServerStartupEvent fun mapWitchesPotion() { onNpcClick(307) { (p, npc) -> HettyD(p, npc) } onObjectClick(2024) { (p) -> p.startConversation { simple(""You drink from the cauldron. It tastes horrible!
You feel yourself imbued with power."") exec { p.miniquestManager.complete(Miniquest.WITCHES_POTION) } } } onLogin { (p) -> p.vars.setVar(67, if (p.getMiniquestStage(Miniquest.WITCHES_POTION) == WitchesPotion.HANDED_IN_INGREDIENTS) 2 else 3) } }" "package com.rs.game.content.miniquests.witches_potion @ServerStartupEvent fun mapWitchesPotionRats() { instantiateNpc(""Rat"", ""Giant rat"", ""Sewer rat"", ""Zombie rat"", ""Dungeon Rat"", ""Blessed giant rat"") { npcId, tile -> WitchesPotionRats(npcId, tile) } } class WitchesPotionRats(id: Int, tile: Tile) : NPC(id, tile) { override fun drop() { super.drop() val killer = mostDamageReceivedSourcePlayer ?: return if (killer.getMiniquestStage(Miniquest.WITCHES_POTION) == WitchesPotion.NEED_INGREDIENTS) { sendDrop(killer, Item(300, 1)) } } }" "package com.rs.game.content.pets; public class Incubator { public enum Egg { PEGUIN_EGG(30, 12483, 12481), RAVEN_EGG(50, 11964, 12484), BIRD_EGG_ZAMMY(70, 5076, 12506), BIRD_EGG_SARA(70, 5077, 12503), BIRD_EGG_GUTHIX(70, 5078, 12509), VULTURE_EGG(85, 11965, 12498), CHAMELEON_EGG(90, 12494, 12492), RED_DRAGON_EGG(99, 12477, 12469), BLUE_DRAGON_EGG(99, 12478, 12471), GREEN_DRAGON_EGG(99, 12479, 12473), BLACK_DRAGON_EGG(99, 12480, 12475); private final int summoningLevel; private final int eggId; private final int petId; Egg(int summoningLevel, int eggId, int petId) { this.summoningLevel = summoningLevel; this.eggId = eggId; this.petId = petId; } } public static Egg getEgg(int itemId) { for (Egg egg : Egg.values()) if (egg.eggId == itemId) return egg; return null; } public static boolean useEgg(Player player, int itemId) { Egg egg = getEgg(itemId); if (egg == null) return false; if (player.getSkills().getLevelForXp(Constants.SUMMONING) < egg.summoningLevel) { player.sendMessage(""You need a level of "" + egg.summoningLevel + "" summoning to hatch this egg.""); return true; } player.lock(1); player.setNextAnimation(new Animation(833)); player.getInventory().deleteItem(itemId, 1); player.getInventory().addItem(egg.petId, 1); player.sendMessage(""You put the egg in the incubator and it hatches.""); return true; } }" "package com.rs.game.content.pets; public final class Pet extends NPC { private final Player owner; private final int itemId; private final PetDetails details; private double growthRate; private final Pets pet; public Pet(int id, int itemId, Player owner, Tile tile, PetDetails details) { super(id, tile); this.owner = owner; this.itemId = itemId; this.details = details; pet = Pets.forId(itemId); setIgnoreNPCClipping(true); if (pet == Pets.TROLL_BABY && owner.getPetManager().getTrollBabyName() != null) setName(owner.getPetManager().getTrollBabyName()); if (details != null) { sendMainConfigurations(); sendFollowerDetails(); } } @Override public boolean blocksOtherNpcs() { return false; } @Override public void processNPC() { Familiar.sendLeftClickOption(owner); if (details != null) { if (pet != Pets.TROLL_BABY || pet.getFood().length > 0) { details.updateHunger(0.025); owner.getVars().setVarBit(4286, (int) details.getHunger()); } if (growthRate > 0.000) { details.updateGrowth(growthRate); owner.getVars().setVarBit(4285, (int) details.getGrowth()); if (details.getGrowth() == 100.0) growNextStage(); } } if (!withinDistance(owner, 12)) { call(); return; } if (!getActionManager().hasSkillWorking()) getActionManager().setAction(new EntityFollow(owner)); } public void growNextStage() { if ((details.getStage() == 3) || (pet == null)) return; int npcId = pet.getNpcId(details.getStage() + 1); if (npcId < 1) return; details.setStage(details.getStage() + 1); int itemId = pet.getItemId(details.getStage()); if (pet.getNpcId(details.getStage() + 1) > 0) details.updateGrowth(-100.0); owner.getPetManager().setItemId(itemId); owner.getPetManager().setNpcId(npcId); finish(); Pet newPet = new Pet(npcId, itemId, owner, owner.getTile(), details); newPet.growthRate = growthRate; owner.setPet(newPet); owner.sendMessage(""Your pet has grown larger.""); } public void pickup() { if (itemId > 50000 || owner.getInventory().hasFreeSlots()) { if (itemId < 50000) owner.getInventory().addItem(itemId, 1); owner.setPet(null); owner.getPetManager().setNpcId(-1); owner.getPetManager().setItemId(-1); owner.getPackets().sendRunScript(2471); owner.getInterfaceManager().removeSub(Sub.TAB_FOLLOWER); finish(); } else owner.sendMessage(""You need more inventory slots to pick up your pet.""); } public void call() { Tile teleTile = owner.getNearestTeleTile(this); if (teleTile != null) tele(teleTile); } /** * Baby troll = var 2480 itemId it's eaten */ public void sendMainConfigurations() { owner.getVars().setVar(448, itemId);// configures pet type owner.getVars().setVar(1174, 0); //refresh pet head owner.getVars().setVarBit(4282, 0); //refresh pet emote owner.getPackets().sendVarc(1436, 0); owner.getPackets().setIFHidden(747, 9, false); } public void sendFollowerDetails() { if (details == null || owner == null) return; owner.getVars().setVarBit(4285, (int) details.getGrowth()); owner.getVars().setVarBit(4286, (int) details.getHunger()); owner.getInterfaceManager().sendSub(Sub.TAB_FOLLOWER, 662); owner.getInterfaceManager().openTab(Sub.TAB_FOLLOWER); } public PetDetails getDetails() { return details; } public double getGrowthRate() { return growthRate; } public void setGrowthRate(double growthRate) { this.growthRate = growthRate; } public int getItemId() { return itemId; } }" "package com.rs.game.content.pets; /** * A class containing pet details for a certain pet. * * @author Emperor * */ public final class PetDetails { /** * The hunger rate. */ private double hunger = 0.0; /** * The growth rate. */ private double growth = 0.0; /** * The current stage of the pet (0 - baby, 1 - grown, 2 - overgrown). */ private int stage; /** * Constructs a new {@code PetDetails} {@code Object}. * * @param growth * The growth value. */ public PetDetails(double growth) { this.growth = growth; } /** * Increases the hunger value by the given amount. * * @param amount * The amount. */ public void updateHunger(double amount) { hunger += amount; if (hunger < 0.0) hunger = 0.0; else if (hunger > 100.0) hunger = 100.0; } /** * Increases the growth value by the given amount. * * @param amount * The amount. */ public void updateGrowth(double amount) { growth += amount; if (growth < 0.0) growth = 0.0; else if (growth > 100.0) growth = 100.0; } /** * Gets the hunger. * * @return The hunger. */ public double getHunger() { return hunger; } /** * Gets the growth. * * @return The growth. */ public double getGrowth() { return growth; } /** * Gets the stage. * * @return The stage. */ public int getStage() { return stage; } /** * Sets the stage. * * @param stage * The stage to set. */ public void setStage(int stage) { this.stage = stage; } }" "package com.rs.game.content.pets; /** * The pet manager. * * @author Emperor * */ public final class PetManager { /** * The pet details mapping, sorted by item id. */ private final Map petDetails = new HashMap<>(); /** * The player. */ private transient Player player; /** * The current NPC id. */ private int npcId; /** * The current item id. */ private int itemId; /** * The troll baby's name (if any). */ private String trollBabyName; /** * Constructs a new {@code PetManager} {@code Object}. */ public PetManager() { /* * empty. */ } /** * Spawns a pet. * * @param itemId * The item id. * @param deleteItem * If the item should be removed. * @return {@code True} if we were dealing with a pet item id. */ public boolean spawnPet(int itemId, boolean deleteItem) { Pets pets = Pets.forId(itemId); if (pets == null) return false; if (player.getPet() != null || player.getFamiliar() != null) { player.sendMessage(""You already have a follower.""); return true; } if (!hasRequirements(pets)) return true; int baseItemId = pets.getBabyItemId(); PetDetails details = petDetails.computeIfAbsent(baseItemId, k -> new PetDetails(pets.getGrowthRate() == 0.0 ? 100.0 : 0.0)); int id = pets.getItemId(details.getStage()); if (itemId != id) { player.sendMessage(""This is not the right pet, grow the pet correctly.""); return true; } int npcId = pets.getNpcId(details.getStage()); if (npcId > 0) { Tile spawnTile = player.getNearestTeleTile(NPCDefinitions.getDefs(npcId, player.getVars()).size); if (spawnTile == null) { player.sendMessage(""There's no space to summon your pet.""); return true; } Pet pet = new Pet(npcId, itemId, player, spawnTile, pets.getGrownNpcId() == -1 && pets.getOvergrownNpcId() == -1 ? null : details); this.npcId = npcId; this.itemId = itemId; pet.setGrowthRate(pets.getGrowthRate()); player.setPet(pet); if (deleteItem) { player.setNextAnimation(new Animation(827)); player.getInventory().deleteItem(itemId, 1); } return true; } return true; } /** * Checks if the player has the requirements for the pet. * * @param pet * The pet. * @return {@code True} if so. */ private boolean hasRequirements(Pets pet) { return switch (pet) { default -> true; }; } /** * Initializes the pet manager. */ public void init() { if (npcId > 0 && itemId > 0) spawnPet(itemId, false); } /** * Makes the pet eat. * * @param foodId * The food item id. * @param npc * The pet NPC. */ public void eat(int foodId, Pet npc) { if (npc != player.getPet()) { player.sendMessage(""This isn't your pet!""); return; } Pets pets = Pets.forId(itemId); if (pets == null) return; if (pets == Pets.TROLL_BABY) { if (!ItemConstants.isTradeable(new Item(foodId))) { player.sendMessage(""Your troll baby won't eat this item.""); return; } player.sendOptionDialogue(""Are you sure you want to feed your "" + ItemDefinitions.getDefs(foodId).getName() + "" to the troll?"", ops -> { ops.add(""Yes, I am sure. I know I won't get it back."", () -> { if (!player.getInventory().containsItem(foodId)) return; trollBabyName = ItemDefinitions.getDefs(foodId).getName(); npc.setName(trollBabyName); npc.setNextForceTalk(new ForceTalk(""YUM! Me likes "" + trollBabyName + ""!"")); player.getInventory().deleteItem(foodId, 1); player.sendMessage(""Your pet happily eats the "" + ItemDefinitions.getDefs(foodId).getName() + "".""); }); ops.add(""Nevermind.""); }); return; } for (int food : pets.getFood()) if (food == foodId) { player.getInventory().deleteItem(food, 1); player.sendMessage(""Your pet happily eats the "" + ItemDefinitions.getDefs(food).getName() + "".""); player.setNextAnimation(new Animation(827)); npc.getDetails().updateHunger(-15.0); return; } player.sendMessage(""Nothing interesting happens.""); } /** * Removes the details for this pet. * * @param npcId * The item id of the pet. */ public void removeDetails(int itemId) { Pets pets = Pets.forId(itemId); if (pets == null) return; petDetails.remove(pets.getBabyItemId()); } /** * Gets the player. * * @return The player. */ public Player getPlayer() { return player; } /** * Sets the player. * * @param player * The player to set. */ public void setPlayer(Player player) { this.player = player; } /** * Gets the npcId. * * @return The npcId. */ public int getNpcId() { return npcId; } /** * Sets the npcId. * * @param npcId * The npcId to set. */ public void setNpcId(int npcId) { this.npcId = npcId; } /** * Gets the itemId. * * @return The itemId. */ public int getItemId() { return itemId; } /** * Sets the itemId. * * @param itemId * The itemId to set. */ public void setItemId(int itemId) { this.itemId = itemId; } /** * Gets the trollBabyName. * * @return The trollBabyName. */ public String getTrollBabyName() { return trollBabyName; } /** * Sets the trollBabyName. * * @param trollBabyName * The trollBabyName to set. */ public void setTrollBabyName(String trollBabyName) { this.trollBabyName = trollBabyName; } }" "package com.rs.game.content.pets; /** * An enum containing all the pets and their info. * * @author Emperor * */ public enum Pets { /** * A cat/kitten pet. */ CAT(1555, 1561, 1567, 761, 768, 774, 0.0154320987654321, 0, 321, 363, 341, 15264, 345, 377, 353, 389, 7944, 349, 331, 327, 395, 383, 317, 371, 335, 359, 15264, 15270, 1927), CAT_1(1556, 1562, 1568, 762, 769, 775, 0.0154320987654321, 0, 321, 363, 341, 15264, 345, 377, 353, 389, 7944, 349, 331, 327, 395, 383, 317, 371, 335, 359, 15264, 15270, 1927), CAT_2(1557, 1563, 1569, 763, 770, 776, 0.0154320987654321, 0, 321, 363, 341, 15264, 345, 377, 353, 389, 7944, 349, 331, 327, 395, 383, 317, 371, 335, 359, 15264, 15270, 1927), CAT_3(1558, 1564, 1570, 764, 771, 777, 0.0154320987654321, 0, 321, 363, 341, 15264, 345, 377, 353, 389, 7944, 349, 331, 327, 395, 383, 317, 371, 335, 359, 15264, 15270, 1927), CAT_4(1559, 1565, 1571, 765, 772, 778, 0.0154320987654321, 0, 321, 363, 341, 15264, 345, 377, 353, 389, 7944, 349, 331, 327, 395, 383, 317, 371, 335, 359, 15264, 15270, 1927), CAT_5(1560, 1566, 1572, 766, 773, 779, 0.0154320987654321, 0, 321, 363, 341, 15264, 345, 377, 353, 389, 7944, 349, 331, 327, 395, 383, 317, 371, 335, 359, 15264, 15270, 1927), HELLCAT(7583, 7582, 7581, 3505, 3504, 3503, 0.0154320987654321, 0, 321, 363, 341, 15264, 345, 377, 353, 389, 7944, 349, 331, 327, 395, 383, 317, 371, 335, 359, 15264, 15270, 1927), CAT_7(14089, 14090, 15092, 8217, 8214, 8216, 0.0154320987654321, 0, 321, 363, 341, 15264, 345, 377, 353, 389, 7944, 349, 331, 327, 395, 383, 317, 371, 335, 359, 15264, 15270, 1927), /** * A clockwork cat. */ CLOCKWORK_CAT(7771, 7772, -1, 3598, -1, -1, 0.0, 0), /** * The firemaker's curse pets. */ SEARING_FLAME(22994, -1, -1, 14769, -1, -1, 0.0, 0), GLOWING_EMBER(22993, -1, -1, 14768, -1, -1, 0.0, 0), TWISTED_FIRESTARTER(22995, -1, -1, 14770, -1, -1, 0.0, 0), WARMING_FLAME(22992, -1, -1, 14767, -1, -1, 0.0, 0), /** * Troll baby pet. */ TROLL_BABY(23030, 23030, -1, 14846, -1, -1, 0.0, 0), /** * A bulldog pet. */ BULLDOG(12522, 12523, -1, 6969, 6968, -1, 0.0033333333333333, 4, 2132, 2134, 2136, 2138, 10816, 9986, 9978, 526), BULLDOG_1(12720, 12721, -1, 7259, 7257, -1, 0.0033333333333333, 4, 2132, 2134, 2136, 2138, 10816, 9986, 9978, 526), BULLDOG_2( 12722, 12723, -1, 7260, 7258, -1, 0.0033333333333333, 4, 2132, 2134, 2136, 2138, 10816, 9986, 9978, 526), /** * A dalmation pet. */ DALMATIAN(12518, 12519, -1, 6964, 6965, -1, 0.0033333333333333, 4, 2132, 2134, 2136, 2138, 10816, 9986, 9978, 526), DALMATIAN_1(12712, 12713, -1, 7249, 7250, -1, 0.0033333333333333, 4, 2132, 2134, 2136, 2138, 10816, 9986, 9978, 526), DALMATIAN_2( 12714, 12715, -1, 7251, 7252, -1, 0.0033333333333333, 4, 2132, 2134, 2136, 2138, 10816, 9986, 9978, 526), /** * A greyhound pet. */ GREYHOUND(12514, 12515, -1, 6960, 6961, -1, 0.0033333333333333, 4, 2132, 2134, 2136, 2138, 10816, 9986, 9978, 526), GREYHOUND_1(12704, 12705, -1, 7241, 7242, -1, 0.0033333333333333, 4, 2132, 2134, 2136, 2138, 10816, 9986, 9978, 526), GREYHOUND_2( 12706, 12707, -1, 7243, 7244, -1, 0.0033333333333333, 4, 2132, 2134, 2136, 2138, 10816, 9986, 9978, 526), /** * A labrador pet. */ LABRADOR(12516, 12517, -1, 6962, 6963, -1, 0.0033333333333333, 4, 2132, 2134, 2136, 2138, 10816, 9986, 9978, 526), LABRADOR_1(12708, 12709, -1, 7245, 7246, -1, 0.0033333333333333, 4, 2132, 2134, 2136, 2138, 10816, 9986, 9978, 526), LABRADOR_2( 12710, 12711, -1, 7247, 7248, -1, 0.0033333333333333, 4, 2132, 2134, 2136, 2138, 10816, 9986, 9978, 526), /** * A sheepdog pet. */ SHEEPDOG(12520, 12521, -1, 6966, 6967, -1, 0.0033333333333333, 4, 2132, 2134, 2136, 2138, 10816, 9986, 9978, 526), SHEEPDOG_1(12716, 12717, -1, 7253, 7254, -1, 0.0033333333333333, 4, 2132, 2134, 2136, 2138, 10816, 9986, 9978, 526), SHEEPDOG_2( 12718, 12719, -1, 7255, 7256, -1, 0.0033333333333333, 4, 2132, 2134, 2136, 2138, 10816, 9986, 9978, 526), /** * A terrier pet. */ TERRIER(12512, 12513, -1, 6958, 6859, -1, 0.0033333333333333, 4, 2132, 2134, 2136, 2138, 10816, 9986, 9978, 526), TERRIER_1(12700, 12701, -1, 7237, 7238, -1, 0.0033333333333333, 4, 2132, 2134, 2136, 2138, 10816, 9986, 9978, 526), TERRIER_2( 12702, 12703, -1, 7239, 7240, -1, 0.0033333333333333, 4, 2132, 2134, 2136, 2138, 10816, 9986, 9978, 526), /** * A creeping hand pet. */ CREEPING_HAND(14652, -1, -1, 8619, -1, -1, 0.0033333333333333, 4, 1059), /** * Minitrice pet. */ MINITRICE(14653, -1, -1, 8620, -1, -1, 0.0033333333333333, 4, 225), /** * Baby basilisk pet. */ BABY_BASILISK(14654, -1, -1, 8621, -1, -1, 0.0033333333333333, 4, 221), /** * Baby kurask pet. */ BABY_KURASK(14655, -1, -1, 8622, -1, -1, 0.0033333333333333, 4, 526), /** * Abyssal minion pet. */ ABYSSAL_MINION(14651, -1, -1, 8624, -1, -1, 0.0033333333333333, 4, 592), /** * Rune guardian pets. */ RUNE_GUARDIAN(15626, -1, -1, 9656, -1, -1, 0.0033333333333333, 4), RUNE_GUARDIAN_1(15627, -1, -1, 9657, -1, -1, 0.0033333333333333, 4), RUNE_GUARDIAN_2(15628, -1, -1, 9658, -1, -1, 0.0033333333333333, 4), RUNE_GUARDIAN_3(15629, -1, -1, 9659, -1, -1, 0.0033333333333333, 4), RUNE_GUARDIAN_4(15630, -1, -1, 9660, -1, -1, 0.0033333333333333, 4), RUNE_GUARDIAN_5(15631, -1, -1, 9661, -1, -1, 0.0033333333333333, 4), RUNE_GUARDIAN_6(15632, -1, -1, 9662, -1, -1, 0.0033333333333333, 4), RUNE_GUARDIAN_7( 15633, -1, -1, 9663, -1, -1, 0.0033333333333333, 4), RUNE_GUARDIAN_8(15634, -1, -1, 9664, -1, -1, 0.0033333333333333, 4), RUNE_GUARDIAN_9(15635, -1, -1, 9665, -1, -1, 0.0033333333333333, 4), RUNE_GUARDIAN_10(15636, -1, -1, 9666, -1, -1, 0.0033333333333333, 4), RUNE_GUARDIAN_11(15637, -1, -1, 9667, -1, -1, 0.0033333333333333, 4), RUNE_GUARDIAN_12(15638, -1, -1, 9668, -1, -1, 0.0033333333333333, 4), RUNE_GUARDIAN_13(15639, -1, -1, 9669, -1, -1, 0.0033333333333333, 4), /** * Gecko pet. */ GECKO(12488, 12489, -1, 6915, 6916, -1, 0.005, 10, 12125, 12127), GECKO_1(12738, 12742, -1, 7277, 7281, -1, 0.005, 10, 12125, 12127), GECKO_2(12739, 12743, -1, 7278, 7282, -1, 0.005, 10, 12125, 12127), GECKO_3(12740, 12744, -1, 7279, 7283, -1, 0.005, 10, 12125, 12127), GECKO_4(12741, 12745, -1, 7280, 7284, -1, 0.005, 10, 12125, 12127), /** * The platypus pet. */ PLATYPUS(12551, 12548, -1, 7018, 7015, -1, 0.0046296296296296, 10, 321, 363, 341, 15264, 345, 377, 353, 389, 7944, 349, 331, 327, 395, 383, 317, 371, 335, 359, 15264, 15270, 313, 12129), PLATYPUS_1(12552, 12549, -1, 7019, 7016, -1, 0.0046296296296296, 10, 321, 363, 341, 15264, 345, 377, 353, 389, 7944, 349, 331, 327, 395, 383, 317, 371, 335, 359, 15264, 15270, 313, 12129), PLATYPUS_2(12553, 12550, -1, 7020, 7017, -1, 0.0046296296296296, 10, 321, 363, 341, 15264, 345, 377, 353, 389, 7944, 349, 331, 327, 395, 383, 317, 371, 335, 359, 15264, 15270, 313, 12129), /** * The broav pet. */ BROAV(14533, -1, -1, 8491, -1, -1, 0.0, 23, 2970), /** * The penguin pet. */ PENGUIN(12481, 12482, -1, 6908, 6909, -1, 0.0046296296296296, 30, 321, 363, 341, 15264, 345, 377, 353, 389, 7944, 349, 331, 327, 395, 383, 317, 371, 335, 359, 15264, 15270), PENGUIN_1(12763, 12762, -1, 7313, 7314, -1, 0.0046296296296296, 30, 321, 363, 341, 15264, 345, 377, 353, 389, 7944, 349, 331, 327, 395, 383, 317, 371, 335, 359, 15264, 15270), PENGUIN_2(12765, 12764, -1, 7316, 7317, -1, 0.0046296296296296, 30, 321, 363, 341, 15264, 345, 377, 353, 389, 7944, 349, 331, 327, 395, 383, 317, 371, 335, 359, 15264, 15270), /** * A tooth creature pet. */ TOOTH_CREATURE(18671, 18669, -1, 11411, 11413, -1, 0.075757575757576, 37, 1927, 1977), /** * A giant crab pet. */ GIANT_CRAB(12500, 12501, -1, 6947, 6948, -1, 0.0069444444444444, 40, 321, 363, 341, 15264, 345, 377, 353, 389, 7944, 349, 331, 327, 395, 383, 317, 371, 335, 359, 15264, 15270), GIANT_CRAB_1(12746, 12747, -1, 7293, 7294, -1, 0.0069444444444444, 40, 321, 363, 341, 15264, 345, 377, 353, 389, 7944, 349, 331, 327, 395, 383, 317, 371, 335, 359, 15264, 15270), GIANT_CRAB_2(12748, 12749, -1, 7295, 7296, -1, 0.0069444444444444, 40, 321, 363, 341, 15264, 345, 377, 353, 389, 7944, 349, 331, 327, 395, 383, 317, 371, 335, 359, 15264, 15270), GIANT_CRAB_3(12750, 12751, -1, 7297, 7298, -1, 0.0069444444444444, 40, 321, 363, 341, 15264, 345, 377, 353, 389, 7944, 349, 331, 327, 395, 383, 317, 371, 335, 359, 15264, 15270), GIANT_CRAB_4( 12752, 12753, -1, 7299, 7300, -1, 0.0069444444444444, 40, 321, 363, 341, 15264, 345, 377, 353, 389, 7944, 349, 331, 327, 395, 383, 317, 371, 335, 359, 15264, 15270), /** * A Raven pet. */ RAVEN(12484, 12485, -1, 6911, 6912, -1, 0.00698888, 50, 313, 12129), RAVEN_1(12724, 12725, -1, 7261, 7262, -1, 0.00698888, 50, 313, 12129), RAVEN_2(12726, 12727, -1, 7263, 7264, -1, 0.00698888, 50, 313, 12129), RAVEN_3(12728, 12729, -1, 7265, 7266, -1, 0.00698888, 50, 313, 12129), RAVEN_4(12730, 12731, -1, 7267, 7268, -1, 0.00698888, 50, 313, 12129), RAVEN_5(12732, 12733, -1, 7269, 7270, -1, 0.00698888, 50, 313, 12129), /** * A squirrel pet. */ SQUIRREL(12490, 12491, -1, 6919, 6920, -1, 0.0071225071225071, 60, 12130), SQUIRREL_1(12754, 12755, -1, 7301, 7302, -1, 0.0071225071225071, 60, 12130), SQUIRREL_2(12756, 12757, -1, 7303, 7304, -1, 0.0071225071225071, 60, 12130), SQUIRREL_3( 12758, 12759, -1, 7305, 7306, -1, 0.0071225071225071, 60, 12130), SQUIRREL_4(12760, 12761, -1, 7307, 7308, -1, 0.0071225071225071, 60, 12130), /** * Godbirds. */ SARADOMIN_OWL(12503, 12504, 12505, 6949, 6950, 6951, 0.0069444444444444, 70, 313, 12129), ZAMORAK_HAWK(12506, 12507, 12508, 6952, 6953, 6954, 0.0069444444444444, 70, 313, 12129), GUTHIX_RAPTOR(12509, 12510, 12511, 6955, 6956, 6957, 0.0069444444444444, 70, 313, 12129), /** * Ex-ex parrot */ EX_EX_PARROT(13335, -1, -1, 7844, -1, -1, 0.0, 71, 13379), /** * The phoenix eggling pets. */ CUTE_PHOENIX_EGGLING(14627, -1, -1, 8578, -1, -1, 0.0, 72, 592), MEAN_PHOENIX_EGGLING(14626, -1, -1, 8577, -1, -1, 0.0, 72, 592), /** * A raccoon pet. */ RACCOON(12486, 12487, -1, 6913, 6914, -1, 0.0029444444444444, 80, 321, 363, 341, 15264, 345, 377, 353, 389, 7944, 349, 331, 327, 395, 383, 317, 371, 335, 359, 15264, 15270, 2132, 2134, 2136, 2138, 10816, 9986, 9978), RACCOON_1(12734, 12735, -1, 7271, 7272, -1, 0.0029444444444444, 80, 321, 363, 341, 15264, 345, 377, 353, 389, 7944, 349, 331, 327, 395, 383, 317, 371, 335, 359, 15264, 15270, 2132, 2134, 2136, 2138, 10816, 9986, 9978), RACCOON_2(12736, 12737, -1, 7273, 7274, -1, 0.0029444444444444, 80, 321, 363, 341, 15264, 345, 377, 353, 389, 7944, 349, 331, 327, 395, 383, 317, 371, 335, 359, 15264, 15270, 2132, 2134, 2136, 2138, 10816, 9986, 9978), /** * A sneaker peeper pet. */ SNEAKER_PEEPER(19894, 19895, -1, 13089, 13090, -1, 0.05, 80, 221), /** * A vulture pet. */ VULTURE(12498, 12499, -1, 6945, 6946, -1, 0.0078, 85, 313, 12129), VULTURE_1(12766, 12767, -1, 7319, 7320, -1, 0.0078, 85, 313, 12129), VULTURE_2(12768, 12769, -1, 7321, 7322, -1, 0.0078, 85, 313, 12129), VULTURE_3(12770, 12771, -1, 7323, 7324, -1, 0.0078, 85, 313, 12129), VULTURE_4(12772, 12773, -1, 7325, 7326, -1, 0.0078, 85, 313, 12129), VULTURE_5(12774, 12775, -1, 7327, 7328, -1, 0.0078, 85, 313, 12129), /** * A chameleon pet. */ CHAMELEON(12492, 12493, -1, 6922, 6923, -1, 0.0069444444444444, 90, 12125), /** * A monkey pet. */ MONKEY(12496, 12497, -1, 6942, 6943, -1, 0.0069444444444444, 95, 1963), MONKEY_1(12682, 12683, -1, 7210, 7211, -1, 0.0069444444444444, 95, 1963), MONKEY_2(12684, 12685, -1, 7212, 7213, -1, 0.0069444444444444, 95, 1963), MONKEY_3(12686, 12687, -1, 7214, 7215, -1, 0.0069444444444444, 95, 1963), MONKEY_4(12688, 12689, -1, 7216, 7217, -1, 0.0069444444444444, 95, 1963), MONKEY_5(12690, 12691, -1, 7218, 7219, -1, 0.0069444444444444, 95, 1963), MONKEY_6(12692, 12693, -1, 7220, 7221, -1, 0.0069444444444444, 95, 1963), MONKEY_7(12694, 12695, -1, 7222, 7223, -1, 0.0069444444444444, 95, 1963), MONKEY_8(12696, 12697, -1, 7224, 7225, -1, 0.0069444444444444, 95, 1963), MONKEY_9(12698, 12699, -1, 7226, 7227, -1, 0.0069444444444444, 95, 1963), /** * A baby dragon pet. */ BABY_DRAGON(12469, 12470, -1, 6900, 6901, -1, 0.0052, 99, 2132, 2134, 2136, 2138, 10816, 9986, 9978, 321, 363, 341, 15264, 345, 377, 353, 389, 7944, 349, 331, 327, 395, 383, 317, 371, 335, 359, 15264, 15270), BABY_DRAGON_1(12471, 12472, -1, 6902, 6903, -1, 0.0052, 99, 2132, 2134, 2136, 2138, 10816, 9986, 9978, 321, 363, 341, 15264, 345, 377, 353, 389, 7944, 349, 331, 327, 395, 383, 317, 371, 335, 359, 15264, 15270), BABY_DRAGON_2(12473, 12474, -1, 6904, 6905, -1, 0.0052, 99, 2132, 2134, 2136, 2138, 10816, 9986, 9978, 321, 363, 341, 15264, 345, 377, 353, 389, 7944, 349, 331, 327, 395, 383, 317, 371, 335, 359, 15264, 15270), BABY_DRAGON_3(12475, 12476, -1, 6906, 6907, -1, 0.0052, 99, 2132, 2134, 2136, 2138, 10816, 9986, 9978, 321, 363, 341, 15264, 345, 377, 353, 389, 7944, 349, 331, 327, 395, 383, 317, 371, 335, 359, 15264, 15270), /** * TzRek-Jad pet. */ TZREK_JAD(21512, -1, -1, 3604, -1, -1, 0.0, 99), SNOW_IMP(50001, -1, -1, 8536, -1, -1, 0.0, 1), FREEZY(24512, -1, -1, 15634, -1, -1, 0.0, 99); /** * The baby pets mapping. */ private static final Map babyPets = new HashMap<>(); /** * The grown pets mapping. */ private static final Map grownPets = new HashMap<>(); /** * The overgrown pets mapping. */ private static final Map overgrownPets = new HashMap<>(); /** * Populates the mappings. */ static { for (Pets pet : Pets.values()) { babyPets.put(pet.babyItemId, pet); if (pet.grownItemId > 0) { grownPets.put(pet.grownItemId, pet); if (pet.getOvergrownItemId() > 0) overgrownPets.put(pet.overgrownItemId, pet); } } } /** * Gets the pet object for the item id. * * @param itemId * The item id. * @return The pet object. */ public static Pets forId(int itemId) { Pets pet = babyPets.get(itemId); if (pet == null) { pet = grownPets.get(itemId); if (pet == null) return overgrownPets.get(itemId); return pet; } return pet; } /** * Checks if a player has a pet. * * @param player * The player. * @return {@code True} if so. */ public static boolean hasPet(Player player) { for (int itemId : babyPets.keySet()) if (player.getInventory().containsOneItem(itemId)) return true; for (int itemId : grownPets.keySet()) if (player.getInventory().containsOneItem(itemId)) return true; for (int itemId : overgrownPets.keySet()) if (player.getInventory().containsOneItem(itemId)) return true; return false; } /** * The baby item id. */ private final int babyItemId; /** * The grown pet's item id. */ private final int grownItemId; /** * The overgrown pet's item id. */ private final int overgrownItemId; /** * The baby pet NPC id. */ private final int babyNpcId; /** * The grown pet NPC id. */ private final int grownNpcId; /** * The overgrown pet NPC id. */ private final int overgrownNpcId; /** * The growth rate. */ private final double growthRate; /** * The summoning level required. */ private final int summoningLevel; /** * The food this pet uses. */ private final int[] food; /** * Constructs a new {@code Pets} {@code Object}. * * @param babyItemId * The baby pet item id. * @param grownItemId * The grown pet item id. * @param overgrownItemId * The overgrown item id. * @param babyNpcId * The baby pet npc id. * @param grownNpcId * The grown pet npc id. * @param overgrownNpcId * The overgrown npc id. * @param growthRate * The growth rate (amount to increase growth with every tick). * @param summoningLevel * The summoning level required. * @param food * The food item ids the pet uses. */ Pets(int babyItemId, int grownItemId, int overgrownItemId, int babyNpcId, int grownNpcId, int overgrownNpcId, double growthRate, int summoningLevel, int... food) { this.babyItemId = babyItemId; this.grownItemId = grownItemId; this.overgrownItemId = overgrownItemId; this.babyNpcId = babyNpcId; this.grownNpcId = grownNpcId; this.overgrownNpcId = overgrownNpcId; this.growthRate = growthRate; this.summoningLevel = summoningLevel; this.food = food; } /** * Gets the babyItemId. * * @return The babyItemId. */ public int getBabyItemId() { return babyItemId; } /** * Gets the grownItemId. * * @return The grownItemId. */ public int getGrownItemId() { return grownItemId; } /** * Gets the overgrownItemId. * * @return The overgrownItemId. */ public int getOvergrownItemId() { return overgrownItemId; } /** * Gets the babyNpcId. * * @return The babyNpcId. */ public int getBabyNpcId() { return babyNpcId; } /** * Gets the grownNpcId. * * @return The grownNpcId. */ public int getGrownNpcId() { return grownNpcId; } /** * Gets the overgrownNpcId. * * @return The overgrownNpcId. */ public int getOvergrownNpcId() { return overgrownNpcId; } /** * Gets the growthRate. * * @return The growthRate. */ public double getGrowthRate() { return growthRate; } /** * Gets the summoningLevel. * * @return The summoningLevel. */ public int getSummoningLevel() { return summoningLevel; } /** * Gets the food. * * @return The food. */ public int[] getFood() { return food; } /** * Gets the NPC id for this pet. * * @param stage * The stage of the pet. * @return The NPc id. */ public int getNpcId(int stage) { return switch (stage) { case 0 -> babyNpcId; case 1 -> grownNpcId; case 2 -> overgrownNpcId; default -> 0; }; } /** * Gets the item id for this pet. * * @param stage * The stage of the pet. * @return The item id. */ public int getItemId(int stage) { return switch (stage) { case 0 -> babyItemId; case 1 -> grownItemId; case 2 -> overgrownItemId; default -> 0; }; } }" "package com.rs.game.content.quests @QuestHandler( quest = Quest.COOKS_ASSISTANT, startText = ""Speak to the cook in the kitchen of Lumbridge Castle."", itemsText = ""Empty pot (can be found in flour mill). Empty bucket (can be found near dairy cow)."", combatText = ""None."", rewardsText = ""300 Cooking XP
500 coins
20 sardines
Access to the cook's range"", completedStage = 2 ) @PluginEventHandler class CooksAssistant : QuestOutline() { override fun getJournalLines(player: Player, stage: Int) = when (stage) { 0 -> listOf(""I can start this quest by speaking to the cook in the Lumbridge castle kitchen."") 1 -> listOf(""The cook is having problems baking a cake for the Duke's birthday party. He needs the following 3 items:"", strikeThroughIf(""An egg"") { player.inventory.containsItem(1944, 1) }, strikeThroughIf(""A bucket of milk"") { player.inventory.containsItem(1927, 1) }, strikeThroughIf(""A pot of flour"") { player.inventory.containsItem(1933, 1) } ) 2 -> listOf(""QUEST COMPLETE!"") else -> listOf(""Invalid quest stage. Report this to an administrator."") } override fun complete(player: Player) { player.skills.addXpQuest(Constants.COOKING, 300.0) player.inventory.addCoins(500) player.inventory.addItemDrop(326, 20) sendQuestCompleteInterface(player, 1891) } } @ServerStartupEvent fun mapCooksAssistant() { onNpcClick(278) { (player, n) -> when(player.getQuestStage(Quest.COOKS_ASSISTANT)) { 0 -> player.startConversation { npc(n, HeadE.SAD_MILD, ""What am I to do?"") player(HeadE.CONFUSED, ""What's wrong?"") npc(n, HeadE.UPSET, ""Oh dear, oh dear, I'm in a terrible, terrible mess!"") npc(n, HeadE.UPSET, ""It's the duke's birthday today, and I should be making him a big birthday cake using special ingredients... but I've forgotten to get the ingredients."") npc(n, HeadE.SAD_MILD, ""I'll never get them in time now. He'll sack me!
Whatever will I do?"") npc(n, HeadE.UPSET, ""I have four children and a goat to look after. Would you help me? Please?"") options { op(""Of course. What is it you are looking for?"") { player(HeadE.HAPPY_TALKING, ""Of course. What is it you are looking for?"") npc(n, HeadE.HAPPY_TALKING, ""Oh, thank you, thank you. I must tell you that this is no ordinary cake, though - only the best ingredients will do!"") npc(n, HeadE.HAPPY_TALKING, ""I need an egg, some milk, and a pot of flour."") player(HeadE.CONFUSED, ""Where can I find those, then?"") npc(n, HeadE.CONFUSED, ""That's the problem: I don't exactly know. I usually send my assistant to get them for me but he quit."") player(HeadE.HAPPY_TALKING, ""Well don't worry then, I'll be back with the ingredients soon."") { player.questManager.setStage(Quest.COOKS_ASSISTANT, 1) } } op(""Sorry, I can't help right now."") } } 1 -> player.startConversation { npc(n, HeadE.CONFUSED, ""How are you getting with finding the ingredients?"") if (!player.inventory.containsItems(Item(1933, 1), Item(1944, 1), Item(1927, 1))) { player(HeadE.WORRIED, ""I haven't quite gotten them all yet. I'll be back when I have the rest of them."") return@startConversation } player(HeadE.HAPPY_TALKING, ""I have all of the items right here!"") npc(n, HeadE.HAPPY_TALKING, ""You've brought me everything I need! I am saved! Thank you!"") player(HeadE.CONFUSED, ""So, do I get to go to the Duke's party?"") npc(n, HeadE.CALM_TALK, ""I'm afraid not. Only the big cheeses get to dine with the Duke."") player(HeadE.CALM_TALK, ""Well, maybe one day, I'll be important enough to sit at the Duke's table."") npc(n, HeadE.CALM_TALK, ""Maybe, but I won't be holding my breath."") { player.inventory.removeItems(Item(1933, 1), Item(1944, 1), Item(1927, 1)) player.questManager.completeQuest(Quest.COOKS_ASSISTANT) } } else -> player.npcDialogue(n, HeadE.HAPPY_TALKING, ""Thank you for the help! Feel free to use my range!"") } } }" "package com.rs.game.content.quests; @PluginEventHandler public class DesertTreasure { public static ItemEquipHandler ringOfVisibility = new ItemEquipHandler(4657, e -> { e.getPlayer().setNextBodyGlow(new BodyGlow(1, 0, 0, 0, 128)); e.getPlayer().getVars().setVarBit(393, e.equip() ? 1 : 0); }); }" "package com.rs.game.content.quests; @QuestHandler( quest = Quest.DORICS_QUEST, startText = ""Speak with Doric north of Falador."", itemsText = ""6 clay (not soft clay)
4 copper ores
2 iron ores"", combatText = ""None."", rewardsText = ""1,300 Mining experience
180 coins
The ability to use Doric's anvils"", completedStage = 2 ) @PluginEventHandler public class DoricsQuest extends QuestOutline { private final static int DORIC = 284; private final static int CLAY = 434; private final static int COPPER_ORE = 436; private final static int IRON_ORE = 440; private final static int BRONZE_PICKAXE = 1265; @Override public List getJournalLines(Player player, int stage) { ArrayList lines = new ArrayList<>(); switch(stage) { case 0: lines.add(""I can start this quest by speaking to Doric who is""); lines.add(""North of Falador.""); lines.add(""
""); lines.add(""There aren't any requirements but level 15 Mining will help""); break; case 1: lines.add(""I have spoken to Doric.""); lines.add(""
""); lines.add(""I need to collect some items and bring them to Doric.""); lines.add((player.getInventory().containsItem(CLAY, 6) ? """":"""")+""6 Clay""); lines.add((player.getInventory().containsItem(COPPER_ORE, 4) ? """":"""")+""4 Copper Ore""); lines.add((player.getInventory().containsItem(IRON_ORE, 2) ? """":"""")+""2 Iron Ore""); break; case 2: lines.add(""""); lines.add(""Doric rewarded me for all my hard work""); lines.add(""I can now use Doric's Anvils whenever I want""); lines.add(""QUEST COMPLETE!""); break; default: lines.add(""Invalid quest stage. Report this to an administrator.""); break; } return lines; } @Override public void complete(Player player) { player.getSkills().addXpQuest(Constants.MINING, 1300); player.getInventory().addCoins(180); sendQuestCompleteInterface(player, 1891); } static class DoricD extends Conversation { public DoricD(Player player) { super(player); switch(player.getQuestManager().getStage(Quest.DORICS_QUEST)) { case 0: Dialogue notSkilled = new Dialogue() .addPlayer(HeadE.CALM_TALK, ""But I'm not good enough miner to get iron ore."") .addNPC(DORIC, HeadE.CALM_TALK, ""Oh well, you could practice mining until you can. Can't beat a bit of mining - it's a useful skill Failing that, you might be able to find a more experienced adventurer to buy the iron ore off."").getHead(); Dialogue startQuestOptions = new Dialogue().addOptions(new Options() { @Override public void create() { option(""Yes, I will get you the materials."", new Dialogue() .addPlayer(HeadE.CALM_TALK, ""Yes, I will get you the materials."") .addNPC(DORIC, HeadE.CALM_TALK, ""Clay is what I use more than anything, to make casts. Could you get me 6 clay, 4 copper ore, and 2 iron ore, please? I could pay a little, and let you use my anvils. Take this pickaxe with you just in case you need it."", () -> { player.getInventory().addItemDrop(BRONZE_PICKAXE, 1); player.getQuestManager().setStage(Quest.DORICS_QUEST, 1); }) .addOption(""What would you like to say?"", ""Where can I find those?"", ""Certainly, I'll be right back!"") .addPlayer(HeadE.CALM_TALK, ""Where can I find those?"") .addNPC(DORIC, HeadE.CALM_TALK, ""You'll be able to find all those ores in the rocks just inside the Dwarven Mine. Head east from here and you'll find the entrance in the side of Ice Mountain."") .addNext((player.getSkills().getLevel(Constants.MINING) < 15 ? notSkilled.cutPrev() : new Dialogue().addNPC(DORIC, HeadE.CALM_TALK, ""Off you go then."")))); option(""No, hitting rocks is for the boring people, sorry."", new Dialogue() .addPlayer(HeadE.CALM_TALK, ""No, hitting rocks is for the boring people, sorry."") .addNPC(DORIC, HeadE.CALM_TALK, ""That is your choice. Nice to meet you anyway."")); } }).getHead(); addNPC(DORIC, HeadE.SAD, ""Hello traveller, what brings you to my humble smithy?""); addOptions(new Options() { @Override public void create() { option(""I wanted to use your anvils."", new Dialogue() .addPlayer(HeadE.CALM_TALK, ""I wanted to use your anvils."") .addNPC(DORIC, HeadE.CALM_TALK, ""My anvils get enough work with my own use. I make pickaxes, and it takes a lot of hard work. If you could get me some more materials, then I could let you use them."") .addNext(startQuestOptions.cutPrev())); option(""I want to use your whetstone."", new Dialogue() .addPlayer(HeadE.CALM_TALK, ""I want to use your whetstone."") .addNPC(DORIC, HeadE.CALM_TALK, ""The whetstone is for more advanced smithing, but I could let you use it as well as my anvils if you could get me some more materials."") .addNext(startQuestOptions.cutPrev())); option(""Mind your own business, shortstuff!"", new Dialogue() .addPlayer(HeadE.CALM_TALK, ""Mind your own business, shortstuff!"") .addNPC(DORIC, HeadE.CALM_TALK, ""How nice to meet someone with such pleasant manners. Do come again when you need to shout at someone smaller than you!"")); option(""I was just checking out the landscape."", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""I was just checking out the landscape."") .addNPC(DORIC, HeadE.CALM_TALK, ""Hope you like it. I do enjoy the solitude of my little home. If you get time, please say hi to my friends in the Dwarven Mine."") .addOption(""What would you like to say?"", ""Dwarven Mine?"", ""Will do!"") .addPlayer(HeadE.CALM_TALK, ""Dwarven Mine?"") .addNPC(DORIC, HeadE.CALM_TALK, ""Yep, the entrance is in the side of Ice Mountain just to the east of here. They're a friendly bunch. Stop in at Nurmof's store and buy one of my pickaxes!"")); option(""What do you make here?"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""What do you make here?"") .addNPC(DORIC, HeadE.CALM_TALK, ""I make pickaxes. I am the best maker of pickaxes in the whole of Gielinor."") .addPlayer(HeadE.HAPPY_TALKING, ""Do you have any to sell?"") .addNPC(DORIC, HeadE.CALM_TALK, ""Sorry, but I've got a running order with Nurmof."") .addOption(""What would you like to say?"", ""Who's Nurmof?"", ""Ah, fair enough."") .addPlayer(HeadE.CALM_TALK, ""Who's Nurmof?"") .addNPC(DORIC, HeadE.CALM_TALK, ""Nurmof has a store over in the Dwarven Mine. You can find the entrance on the side of Ice Mountain to the east of here."")); } }); break; case 1: addNPC(DORIC, HeadE.CALM_TALK, ""Have you got my materials yet, traveller?""); if (player.getInventory().containsItems(new int[] { CLAY, COPPER_ORE, IRON_ORE }, new int[] { 6, 4, 2 })) { addPlayer(HeadE.CALM_TALK, ""I have everything you need.""); addNPC(DORIC, HeadE.CALM_TALK, ""Many thanks! Pass them here, please. I can spare you some coins for your trouble, and please use my anvils any time you want.""); addItem(COPPER_ORE, ""You hand the clay, copper, and iron to Doric.""); addNext(() -> { player.getInventory().deleteItem(CLAY, 6); player.getInventory().deleteItem(COPPER_ORE, 4); player.getInventory().deleteItem(IRON_ORE, 2); player.getQuestManager().completeQuest(Quest.DORICS_QUEST); }); } else { addPlayer(HeadE.CALM_TALK, ""Sorry, I don't have them all yet.""); addNPC(DORIC, HeadE.CALM_TALK, ""Not to worry, stick at it. Remember, I need 6 clay, 4 copper ore, and 2 iron ore.""); addPlayer(HeadE.CALM_TALK, ""Where can I find those?""); addNPC(DORIC, HeadE.CALM_TALK, ""You'll be able to find all those ores in the rocks just inside the Dwarven Mine. Head east from here and you'll find the entrance in the side of Ice Mountain.""); } break; case 2: addNPC(DORIC, HeadE.CALM_TALK, ""Hello traveller, how is your metalworking coming along?""); addPlayer(HeadE.CALM_TALK, ""Not too bad, Doric.""); addNPC(DORIC, HeadE.CALM_TALK, ""Good, the love of metal is a thing close to my heart.""); break; } create(); } } public static NPCClickHandler doricHandler = new NPCClickHandler(new Object[] { DORIC }, e -> { if (e.isAtNPC()) if (e.getOption().equalsIgnoreCase(""talk-to"")) e.getPlayer().startConversation(new DoricD(e.getPlayer())); }); public static ObjectClickHandler handleDoricsAnvil = new ObjectClickHandler(new Object[] { 2782, 10641 }, e -> { if (!e.getPlayer().isQuestComplete(Quest.DORICS_QUEST)) e.getPlayer().startConversation(new DoricD(e.getPlayer())); else if (e.getObject().getDefinitions().containsOption(0, ""Smith"")) ForgingInterface.openSmithingInterfaceForHighestBar(e.getPlayer(), e.getObject()); }); }" "package com.rs.game.content.quests; @QuestHandler( quest = Quest.DRUIDIC_RITUAL, startText = ""Talk to Kaqemeex at the stone circle north of Taverley south of the Heroes' Guild."", itemsText = ""Raw bear meat
Raw rat meat
Raw beef
Raw chicken"", combatText = ""Ability to survive some skeletons in the Taverley Dungeon"", rewardsText = ""250 Herblore XP
15 Grimy guam
15 Eye of newt
"", completedStage = 4 ) @PluginEventHandler public class DruidicRitual extends QuestOutline { final static int RAW_BEAR_MEAT = 2136; final static int RAW_RAT_MEAT = 2134; final static int RAW_CHICKEN = 2138; final static int RAW_BEEF = 2132; final static int ENCHANTED_RAW_BEAR_MEAT = 524; final static int ENCHANTED_RAW_RAT_MEAT = 523; final static int ENCHANTED_RAW_CHICKEN = 525; final static int ENCHANTED_RAW_BEEF = 522; @Override public List getJournalLines(Player player, int stage) { ArrayList lines = new ArrayList<>(); switch(stage) { case 0: lines.add(""I can start this quest by speaking to Kaqemeex who is at""); lines.add(""the Druids Circle just North of Taverly.""); lines.add(""""); break; case 1: lines.add(""I must speak to Sanfew south of the monument.""); lines.add(""""); break; case 2: lines.add(""Sanfew told me to get raw rat, chicken, beef and bear meat""); lines.add(""Im to take them to the cauldron of thunder and dip them in.""); lines.add(""Afterwards I should take all four back to Sanfew""); lines.add(""""); lines.add(""I can find the cauldron of thunder in Taverly Dungeon""); lines.add(""It is at the first gate northeast of the dungeon entrance""); lines.add(""""); break; case 3: lines.add(""I must speak to Kaqemeex at the monument""); break; case 4: lines.add(""""); lines.add(""QUEST COMPLETE!""); break; default: lines.add(""Invalid quest stage. Report this to an administrator.""); break; } return lines; } @Override public void complete(Player player) { player.getSkills().addXpQuest(Skills.HERBLORE, 250); player.getInventory().addItem(200, 15); player.getInventory().addItem(222, 15); sendQuestCompleteInterface(player, 195); } public static ItemOnObjectHandler handleCauldron = new ItemOnObjectHandler(new Object[] { 2142 }, new Object[] { RAW_BEEF, RAW_CHICKEN, RAW_BEAR_MEAT, RAW_RAT_MEAT }, e -> { Player player = e.getPlayer(); Item item = e.getItem(); int itemId = item.getId(); if (itemId == RAW_BEAR_MEAT) { if(player.getInventory().containsItem(RAW_BEAR_MEAT) && !player.getInventory().containsItem(ENCHANTED_RAW_BEAR_MEAT)) { player.getInventory().deleteItem(RAW_BEAR_MEAT, 1); player.getInventory().addItem(ENCHANTED_RAW_BEAR_MEAT); return; } if(player.getInventory().containsItem(ENCHANTED_RAW_BEAR_MEAT)) { player.getPackets().sendGameMessage(""Enchanted bear meat is already in your inventory""); return; } } if (itemId == RAW_RAT_MEAT) { if(player.getInventory().containsItem(RAW_RAT_MEAT) && !player.getInventory().containsItem(ENCHANTED_RAW_RAT_MEAT)) { player.getInventory().deleteItem(RAW_RAT_MEAT, 1); player.getInventory().addItem(ENCHANTED_RAW_RAT_MEAT); return; } if(player.getInventory().containsItem(ENCHANTED_RAW_RAT_MEAT)) { player.getPackets().sendGameMessage(""Enchanted rat meat is already in your inventory""); return; } } if (itemId == RAW_CHICKEN) { if(player.getInventory().containsItem(RAW_CHICKEN) && !player.getInventory().containsItem(ENCHANTED_RAW_CHICKEN)) { player.getInventory().deleteItem(RAW_CHICKEN, 1); player.getInventory().addItem(ENCHANTED_RAW_CHICKEN); return; } if(player.getInventory().containsItem(ENCHANTED_RAW_CHICKEN)) { player.getPackets().sendGameMessage(""Enchanted chicken meat is already in your inventory""); return; } } if (itemId == RAW_BEEF) { if(player.getInventory().containsItem(RAW_BEEF) && !player.getInventory().containsItem(ENCHANTED_RAW_BEEF)) { player.getInventory().deleteItem(RAW_BEEF, 1); player.getInventory().addItem(ENCHANTED_RAW_BEEF); return; } if(player.getInventory().containsItem(ENCHANTED_RAW_BEEF)) { player.getPackets().sendGameMessage(""Enchanted beef meat is already in your inventory""); return; } } player.getPackets().sendGameMessage(""There is no reason to put this in the cauldron""); }); }" "package com.rs.game.content.quests; @QuestHandler( quest = Quest.IMP_CATCHER, startText = ""Talk to Wizard Mizgog on the 2nd floor of the Wizards' Tower, south of Draynor Village."", itemsText = ""None."", combatText = ""Must kill many imps"", rewardsText = ""875 Magic XP
An amulet of accuracy
Access to Mizgog's amulet shop"", completedStage = 2 ) @PluginEventHandler public class ImpCatcher extends QuestOutline { private final static int WIZARD_MIZGOG = 706; private final static int RED_BEAD = 1470; private final static int YELLOW_BEAD = 1472; private final static int BLACK_BEAD = 1474; private final static int WHITE_BEAD = 1476; @Override public List getJournalLines(Player player, int stage) { ArrayList lines = new ArrayList<>(); switch(stage) { case 0: lines.add(""I can start this quest by speaking to Wizard Mizgog who is""); lines.add(""in the Wizard's Tower.""); break; case 1: lines.add(""I have spoken to Wizard Mizgog.""); lines.add(""
""); lines.add(""I need to collect some items by killing Imps.""); lines.add((player.getInventory().containsItem(BLACK_BEAD, 1) ? """":"""")+""1 Black Bead.""); lines.add((player.getInventory().containsItem(RED_BEAD, 1) ? """":"""")+""1 Red Bead.""); lines.add((player.getInventory().containsItem(WHITE_BEAD, 1) ? """":"""")+""1 White Bead.""); lines.add((player.getInventory().containsItem(YELLOW_BEAD, 1) ? """":"""")+""1 Yellow Bead.""); break; case 2: lines.add(""""); lines.add(""""); lines.add(""QUEST COMPLETE!""); break; default: lines.add(""Invalid quest stage. Report this to an administrator.""); break; } return lines; } @Override public void complete(Player player) { player.getSkills().addXpQuest(Constants.MAGIC, 875); player.getInventory().addItemDrop(1478, 1); sendQuestCompleteInterface(player, 1891); } static class MizgogD extends Conversation { public MizgogD(Player player) { super(player); switch(player.getQuestManager().getStage(Quest.IMP_CATCHER)) { case 0: addNPC(WIZARD_MIZGOG, HeadE.SAD, ""My beads! Where are my beads?""); addOption(""What would you like to say?"", ""Can I help you?"", ""Goodbye.""); addPlayer(HeadE.CALM_TALK, ""Can I help you?""); addNPC(WIZARD_MIZGOG, HeadE.FRUSTRATED, ""Wizard Grayzag next door decided that he didn't like me for some reason, so he enlisted an army of imps.""); addNPC(WIZARD_MIZGOG, HeadE.FRUSTRATED, "" The imps stole all sorts of things. Most of them were things I don't really care about like eggs, balls of wool, things like that... ""); addNPC(WIZARD_MIZGOG, HeadE.FRUSTRATED, ""But they stole my magic beads! There was a red one, a yellow one, a black one, and a white one. The imps have spread out all over the kingdom by now. Could you get my beads back for me?""); addOption(""Do you want to start a quest?"", ""Accept quest."", ""Not right now.""); addNPC(WIZARD_MIZGOG, HeadE.CALM_TALK, ""The imps will be all over the kingdom by now. You should kill any imps you find and collect any beads that they drop. I need a red one, a yellow one, a black one, and a white one."", () -> player.getQuestManager().setStage(Quest.IMP_CATCHER, 1)); break; case 1: addNPC(WIZARD_MIZGOG, HeadE.SKEPTICAL, ""How are you doing finding my beads?""); addOptions(new Options() { @Override public void create() { if (player.getInventory().containsItems(new int[] { RED_BEAD, YELLOW_BEAD, BLACK_BEAD, WHITE_BEAD }, new int[] { 1, 1, 1, 1 })) option(""I've got all four beads."", new Dialogue().addPlayer(HeadE.CALM_TALK, ""I've got all four beads."") .addNPC(WIZARD_MIZGOG, HeadE.HAPPY_TALKING, ""Thank you! Give them here and I'll check that they really are my beads, before I give you your reward. You'll like it, it's an amulet of accuracy."") .addSimple(""You give four coloured beads to Wizard Mizgog."") .addNext(() -> { player.getInventory().deleteItem(RED_BEAD, 1); player.getInventory().deleteItem(YELLOW_BEAD, 1); player.getInventory().deleteItem(BLACK_BEAD, 1); player.getInventory().deleteItem(WHITE_BEAD, 1); player.getQuestManager().completeQuest(Quest.IMP_CATCHER); })); else option(""I don't have them all yet."", new Dialogue() .addPlayer(HeadE.CALM_TALK, ""I don't have them all yet."") .addNPC(WIZARD_MIZGOG, HeadE.CALM_TALK, ""Come back when you have them all. I've lost a white bead, a red bead, a black bead, and a yellow bead. Go kill some imps!"")); option(""Goodbye.""); } }); break; case 2: addOptions(new Options() { @Override public void create() { option(""Got any more quests?"", new Dialogue() .addPlayer(HeadE.CALM_TALK, ""Got any more quests?"") .addNPC(WIZARD_MIZGOG, HeadE.CALM_TALK, ""No, everything is good with the world today."")); option(""Do you know any interesting spells you could teach me?"", new Dialogue() .addPlayer(HeadE.CALM_TALK, ""Do you know any interesting spells you could teach me?"") .addNPC(WIZARD_MIZGOG, HeadE.CALM_TALK, ""I don't think so, the type of magic I study involves years of meditation and research."")); option(""Have you got another one of those fancy schmancy amulets?"", new Dialogue() .addPlayer(HeadE.CALM_TALK, ""Have you got another one of those fancy schmancy amulets?"") .addNPC(WIZARD_MIZGOG, HeadE.CALM_TALK, ""I have a few spare."") .addNext(() -> ShopsHandler.openShop(player, ""wizard_mizgog"") )); } }); break; } create(); } } public static NPCClickHandler mizgogHandler = new NPCClickHandler(new Object[] { WIZARD_MIZGOG }, e -> { if (e.getOption().equalsIgnoreCase(""talk-to"")) e.getPlayer().startConversation(new MizgogD(e.getPlayer())); else if (e.getOption().equalsIgnoreCase(""trade"") && e.getPlayer().isQuestComplete(Quest.IMP_CATCHER)) ShopsHandler.openShop(e.getPlayer(), ""wizard_mizgog""); else e.getPlayer().startConversation(new MizgogD(e.getPlayer())); }); }" "package com.rs.game.content.quests; @QuestHandler( quest = Quest.RUNE_MYSTERIES, startText = ""Speak to Duke Horacio on the 2nd floor of Lumbridge Castle."", itemsText = ""None."", combatText = ""None."", rewardsText = ""The ability to mine rune essence
An air talisman"", completedStage = 4 ) @PluginEventHandler public class RuneMysteries extends QuestOutline { final static int DUKEHORACIO = 741; final static int SEDRIDOR = 300; final static int AUBURY = 5913; @Override public List getJournalLines(Player player, int stage) { ArrayList lines = new ArrayList<>(); switch (stage) { case 0: lines.add(""I can start this quest by speaking to Duke Horacio""); lines.add(""on the second floor of Lumbridge""); lines.add(""""); break; case 1: lines.add(""Duke Horacio gave me a talisman to be investigated.""); lines.add(""I should take this talisman to Sedridor in the""); lines.add(""Wizard tower basement""); lines.add(""""); break; case 2: lines.add(""Sedridor gave me a research package to be investigated""); lines.add(""I should take this talisman to Aubury in his""); lines.add(""rune shop in Varrock""); lines.add(""""); break; case 3: lines.add(""Aubury gave me research notes to be investigated""); lines.add(""I should take these notes to Sedridor in the""); lines.add(""Wizard tower basement""); lines.add(""""); break; case 4: lines.add(""""); lines.add(""""); lines.add(""QUEST COMPLETE!""); break; default: lines.add(""Invalid quest stage. Report this to an administrator.""); break; } return lines; } @Override public void complete(Player player) { sendQuestCompleteInterface(player, 1438); } public static class DukeHoracioRuneMysteriesD extends Conversation { public DukeHoracioRuneMysteriesD(Player player) { super(player); switch(player.getQuestManager().getStage(Quest.RUNE_MYSTERIES)) { case 0: addPlayer(HeadE.CALM_TALK, ""Have you any quests for me?""); addNPC(DUKEHORACIO, HeadE.CALM_TALK, ""Well, it's not really a quest, but I recently discovered this strange talisman. It's not like "" + ""anything I have seen before.""); addNPC(DUKEHORACIO, HeadE.CALM_TALK, ""Would you take it to the head wizard in the basement of the Wizards' Tower for me? It should not "" + ""take you very long at all and I would be awfully grateful""); addOptions(""Start Rune Mysteries?"", new Options() { @Override public void create() { option(""Sure, i'll do it"", new Dialogue() .addPlayer(HeadE.CALM_TALK, ""Sure, i'll do it"") .addNPC(DUKEHORACIO, HeadE.CALM_TALK, ""Thank you very much, stranger. I am sure the head wizard will reward you for such "" + ""an interesting find."") .addSimple(""The duke hands you a talisman"") .addNext(()->{ player.getInventory().addItem(new Item(15361, 1), true); player.getQuestManager().setStage(Quest.RUNE_MYSTERIES, 1); })); option(""Not right now"", () -> { }); } }); case 1: if(!player.getInventory().containsItem(15361)) { addNPC(DUKEHORACIO, HeadE.CALM_TALK, ""Have you lost the talisman?""); addPlayer(HeadE.SAD, ""Yes...""); addSimple(""The Duke hands you another talisman""); addNext(() -> player.getInventory().addItem(new Item(15361, 1), true)); } else { addNPC(DUKEHORACIO, HeadE.CALM_TALK, ""Take this talisman to wizard's tower""); addPlayer(HeadE.HAPPY_TALKING, ""Of course!""); } break; default: addNPC(DUKEHORACIO, HeadE.CALM_TALK, ""Thank you for your help adventurer!""); addPlayer(HeadE.CALM_TALK, ""No problem""); break; } create(); } } public static NPCClickHandler handleSedridor = new NPCClickHandler(new Object[]{300}, new String[]{""Talk-to""}, e -> e.getPlayer().startConversation(new Conversation(e.getPlayer()) { { addNPC(e.getNPCId(), HeadE.CALM, ""Welcome, adventurer, to the world-renowned Wizard's Tower. How may I help you?""); addOptions(new Options() { @Override public void create() { if (player.getQuestManager().getStage(Quest.RUNE_MYSTERIES) == 1) if (player.getInventory().containsItem(15361)) option("" I'm looking for the head wizard."", new Dialogue() .addNPC(SEDRIDOR, HeadE.CALM_TALK, ""That's me, but why would you be doing that?"") .addPlayer(HeadE.CALM_TALK, ""The Duke of Lumbridge sent me to find him...er, you. I have a weird talisman that the "" + ""Duke found. He said the head wizard would be interested in it."") .addNPC(SEDRIDOR, HeadE.CALM_TALK, ""Did he now? Well, that IS interesting, Hand it over, then, adventurer – let me see what "" + ""all the hubbub is about. Just some crude amulet, I'll wager."") .addPlayer(HeadE.CALM_TALK, ""Okay, here you go."") .addSimple(""You give the talisman to the wizard."") .addNPC(SEDRIDOR, HeadE.AMAZED, ""Wow! This is incredible! Th-this talisman you brought me...it is the last piece of the "" + ""puzzle. Finally!"") .addNPC(SEDRIDOR, HeadE.CALM_TALK, ""I require a specialist to investigate the talisman. Will you take it to him?"") .addOptions(new Options() { @Override public void create() { option(""Yes, certainly"", new Dialogue() .addNPC(SEDRIDOR, HeadE.CALM_TALK, ""Take this package to Varrock, the large city north of Lumbridge. "" + ""Aubury's rune shop is in the south-east quarter. "") .addNPC(SEDRIDOR, HeadE.CALM_TALK, ""He will give you a special item. Bring it back to me and I will "" + ""show you the mystery of runes."") .addSimple(""The head wizard gives you a research package."") .addNPC(SEDRIDOR, HeadE.CALM_TALK, ""Best of luck with your quest"") .addNext(() -> { player.getInventory().deleteItem(15361, 1); player.getInventory().addItem(new Item(290, 1), true); player.getQuestManager().setStage(Quest.RUNE_MYSTERIES, 2); })); option(""No, i'm busy"", () -> { }); } })); else option("" I'm looking for the head wizard."", new Dialogue() .addNPC(SEDRIDOR, HeadE.CALM_TALK, ""That's me, but why would you be doing that?"") .addPlayer(HeadE.CALM_TALK, ""The Duke of Lumbridge sent me to find him...er, you. I have a weird talisman that the "" + ""Duke found. He said the head wizard would be interested in it."") .addNPC(SEDRIDOR, HeadE.CALM_TALK, ""Did he now? Well, that IS interesting, Hand it over, then, adventurer – let me see what "" + ""all the hubbub is about. Just some crude amulet, I'll wager."") .addPlayer(HeadE.CALM_TALK, ""Darn, I don't have it"") .addNPC(SEDRIDOR, HeadE.SKEPTICAL_THINKING, ""..."") .addPlayer(HeadE.NO_EXPRESSION, ""... ..."")); if (player.getQuestManager().getStage(Quest.RUNE_MYSTERIES) == 2) if (!player.getInventory().containsItem(290)) option(""About that package..."", new Dialogue() .addNPC(SEDRIDOR, HeadE.CALM_TALK, ""You lost it?"") .addPlayer(HeadE.SAD, ""Yes..."") .addSimple(""The head wizard gives you a research package."") .addNext(() -> player.getInventory().addItem(new Item(290, 1), true))); if (player.getQuestManager().getStage(Quest.RUNE_MYSTERIES) == 3) if (player.getInventory().containsItem(291)) option(""About Aubury's research notes"", new Dialogue() .addNPC(SEDRIDOR, HeadE.CALM_TALK, ""What did Aubury say?"") .addPlayer(HeadE.SAD, ""He gave me some research notes to pass on to you."") .addSimple(""You give him the notes"") .addNPC(SEDRIDOR, HeadE.CALM_TALK, ""You have been nothing but helpful, adventurer. In return, I can let you "" + ""in on the secret of our research. "") .addNPC(SEDRIDOR, HeadE.CALM_TALK, ""we are developing a way to create runes from raw material"") .addPlayer(HeadE.HAPPY_TALKING, ""Oh neat-o!"") .addNPC(SEDRIDOR, HeadE.CALM_TALK, ""Yes, we are the only ones to know where the materials are"") .addPlayer(HeadE.CALM_TALK, ""Does that mean that you are the only once who know the teleport spell?"") .addNPC(SEDRIDOR, HeadE.CALM_TALK, ""Yes, also, i'm willing to take you there"") .addSimple(""He hands you a air talisman"") .addNext(() -> { player.getInventory().deleteItem(291, 1); player.getInventory().addItem(1438, 1); player.getQuestManager().completeQuest(Quest.RUNE_MYSTERIES); }) ); else option(""About Aubury's research notes"", new Dialogue() .addNPC(SEDRIDOR, HeadE.CALM_TALK, ""What did Aubury say?"") .addPlayer(HeadE.SAD, ""He said to bring research notes but I lost them..."") .addNPC(SEDRIDOR, HeadE.NO_EXPRESSION, ""..."")); option(""What are you doing down here?"", new Dialogue() .addNPC(SEDRIDOR, HeadE.CALM_TALK, ""That is, indeed, a good question. Here in the cellar of the Wizard's Tower "" + ""you find the remains of the old Wizards' Tower,"") .addNPC(SEDRIDOR, HeadE.CALM_TALK, ""destroyed by fire many years past by the treachery of the Zamorakians. "" + ""Many mysteries were lost, which we are trying to rediscover."") .addNPC(SEDRIDOR, HeadE.CALM_TALK, "" By building this tower on the remains of the old, we seek to show the world "" + ""our dedication to the mysteries of magic."") .addNPC(SEDRIDOR, HeadE.CALM_TALK, "" I am here sifting through fragments for knowledge of artefacts of our past."") .addPlayer(HeadE.CALM_TALK, ""Have you found anything useful?"") .addNPC(SEDRIDOR, HeadE.CALM_TALK, "" Ah, that would be telling, adventurer. Anything I have found I cannot speak "" + ""freely of, for fear of the treachery we have already seen once in the past."") .addPlayer(HeadE.CALM_TALK, ""Okay, well, I'll leave you to it"")); option(""Nothing, thanks. I'm just looking around"", () -> { }); } }); create(); } })); public static NPCClickHandler handleAubury= new NPCClickHandler(new Object[] { 5913 }, new String[] { ""Talk-to"", ""Trade"" }, e -> { switch(e.getOption()) { case ""Trade"": ShopsHandler.openShop(e.getPlayer(), ""auburys_rune_shop""); break; case ""Talk-to"": e.getPlayer().startConversation(new Conversation(e.getPlayer()) { { switch(player.getQuestManager().getStage(Quest.RUNE_MYSTERIES)) { case 2: addPlayer(HeadE.SAD, ""I've been sent here with a package for you. It's from Sedridor, the head wizard at the Wizards' Tower.""); addNPC(AUBURY, HeadE.CALM_TALK, "" Really? Surely he can't have...? Please, let me have it.""); if(!player.getInventory().containsItem(290)) { addPlayer(HeadE.CALM_TALK, ""Darn, I don't have it""); addNPC(AUBURY, HeadE.SKEPTICAL_THINKING, ""...""); addPlayer(HeadE.NO_EXPRESSION, ""... ...""); } else { addSimple(""You hand Aubury the research package.""); addNPC(AUBURY, HeadE.CALM_TALK, ""My gratitude, adventurer, for bringing me this research package. Combined with the information "" + ""I have already collated regarding rune essence, I think we have finally unlocked the power to... ""); addNPC(AUBURY, HeadE.CALM_TALK, ""No, I'm getting ahead of myself. Take this summary of my research back to Sedridor in "" + ""the basement of the Wizards' Tower. He will know whether or not to let you in on our little secret.""); addSimple(""Aubury gives you his research notes.""); addNPC(AUBURY, HeadE.CALM_TALK, ""Now, I'm sure I can spare a couple of runes for such a worthy cause as these notes. "" + ""Do you want me to teleport you back?""); addPlayer(HeadE.SAD, ""Yes...""); addOptions(""Teleport to Wizard's Tower?"", new Options() { @Override public void create() { option(""Yes please"", new Dialogue() .addNext(() -> { e.getNPC().setNextForceTalk(new ForceTalk(""Senventior Disthine Molenko!"")); World.sendProjectile(e.getNPC(), e.getPlayer(), 109, 5, 5, 5, 1, 5, 0); WorldTasks.schedule(new Task() { @Override public void run() { e.getPlayer().tele(Tile.of(3113, 3175, 0, 0)); } }, 2); player.getInventory().deleteItem(290, 1); player.getInventory().addItem(new Item(291, 1), true); player.getQuestManager().setStage(Quest.RUNE_MYSTERIES, 3); })); option(""No thanks"", () -> { player.getInventory().deleteItem(290, 1); player.getInventory().addItem(new Item(291, 1), true); player.getQuestManager().setStage(Quest.RUNE_MYSTERIES, 3); }); } }); } break; case 3: if(!player.getInventory().containsItem(291)) { addPlayer(HeadE.CALM_TALK, ""I lost the research notes""); addNPC(AUBURY, HeadE.CALM_TALK, ""I have another""); addPlayer(HeadE.CALM_TALK, ""Thank you!""); } else { addNPC(AUBURY, HeadE.CALM_TALK, ""Please get these research notes to Sedridor at the wizards tower""); addPlayer(HeadE.CALM_TALK, ""Of course!""); } break; default: addNPC(AUBURY, HeadE.CALM_TALK, ""Do you want to buy some runes?""); addOptions(""Do you want to buy some runes?"", new Options() { @Override public void create() { option(""Yes please"", new Dialogue() .addNext(()-> ShopsHandler.openShop(e.getPlayer(), ""auburys_rune_shop""))); option(""No thanks"", () -> { }); if (e.getPlayer().isQuestComplete(Quest.RUNE_MYSTERIES)) { option(""Can you teleport me to the rune essence?"", () -> { if (!e.getPlayer().isQuestComplete(Quest.RUNE_MYSTERIES)) { e.getPlayer().sendMessage(""You have no idea where this mage might take you if you try that.""); return; } RunecraftingAltar.handleEssTele(e.getPlayer(), e.getNPC()); }); } } }); break; } create(); } }); break; } }); }" "package com.rs.game.content.quests.gertrudescat; public class GertrudeD extends Conversation { private static final int GERTRUDE = 780; public GertrudeD(Player player) { super(player); switch(player.getQuestManager().getStage(Quest.GERTRUDES_CAT)) { case 0: addPlayer(HeadE.HAPPY_TALKING, ""Hello, are you ok?""); addNPC(GERTRUDE, HeadE.ANGRY, ""Do I look ok? Those kids drive me crazy.""); addNPC(GERTRUDE, HeadE.SAD_MILD, ""I'm sorry. It's just that I've lost her.""); addPlayer(HeadE.CONFUSED, ""Lost whom?""); addNPC(GERTRUDE, HeadE.SAD_MILD, ""Fluffs, poor Fluffs. She never hurt anyone.""); addPlayer(HeadE.CONFUSED, ""Who's Fluffs?""); addNPC(GERTRUDE, HeadE.SAD_MILD, ""My beloved feline friend, Fluffs. She's been purring by my side for almost a decade. Please, could you go and search for her while I take care of the children?""); addPlayer(HeadE.CONFUSED, ""What's in it for me?""); addNPC(GERTRUDE, HeadE.SAD_MILD, ""I'm sorry, I'm too poor to pay you anything, the best I could offer is a warm meal.""); addNPC(GERTRUDE, HeadE.NO_EXPRESSION, ""So, can you help?""); addPlayer(HeadE.CONFUSED, ""Just a meal? It's not the best offer I've had, but I suppose I can help.""); addNPC(GERTRUDE, HeadE.SAD_MILD, ""I suppose I could give you some nice, yummy chocolate cake; maybe even a kitten too, if you seem like a nice sort.""); addNPC(GERTRUDE, HeadE.CONFUSED, ""Is that something you could be persuaded with?""); addPlayer(HeadE.CONFUSED, ""Well, I suppose I could, though I'd need more details.""); addNPC(GERTRUDE, HeadE.HAPPY_TALKING, ""Really? Thank you so much! I really have no idea where she could be!""); addNPC(GERTRUDE, HeadE.NO_EXPRESSION, ""I think my sons, Shilop and Wilough, saw the cat last. They'll be out in the marketplace.""); addPlayer(HeadE.CONFUSED, ""The marketplace? Which one would that be? It would help to know what they get up to, as well.""); addNPC(GERTRUDE, HeadE.HAPPY_TALKING, ""Really? Well, I generally let them do what they want, so I've no idea exactly what they would be doing. They are good lads, though. I'm sure they are just watching the passers-by in Varrock Marketplace.""); addNPC(GERTRUDE, HeadE.HAPPY_TALKING, ""Oh, to be young and carefree again!""); addPlayer(HeadE.HAPPY_TALKING, ""Alright then, I'll see what I can do. Two young lads in Varrock Marketplace; I can only hope that there's no school trip passing through when I arrive."", () -> player.getQuestManager().setStage(Quest.GERTRUDES_CAT, 1)); break; case 1: addPlayer(HeadE.HAPPY_TALKING, ""Hello Gertrude.""); addNPC(GERTRUDE, HeadE.CONFUSED, ""Have you seen my poor Fluffs?""); addPlayer(HeadE.SAD_MILD, ""I'm afraid not.""); addNPC(GERTRUDE, HeadE.NO_EXPRESSION, ""What about Shilop?""); addPlayer(HeadE.CONFUSED, ""No sign of him either.""); addNPC(GERTRUDE, HeadE.CONFUSED, ""Hmmm, strange; he should be in Varrock Marketplace.""); break; case 2: addPlayer(HeadE.HAPPY_TALKING, ""Hello Gertrude.""); addNPC(GERTRUDE, HeadE.NO_EXPRESSION, ""Hello again, did you manage to find Shilop? I can't keep an eye on him for the life of me.""); addPlayer(HeadE.HAPPY_TALKING, ""He does seem like quite a handful.""); addNPC(GERTRUDE, HeadE.NO_EXPRESSION, ""You have no idea! Did he help at all?""); addPlayer(HeadE.NO_EXPRESSION, ""I think so. I'm just going to look now.""); addNPC(GERTRUDE, HeadE.HAPPY_TALKING, ""Thanks again, adventurer.""); break; case 3: case 4: case 5: case 6: case 7: addPlayer(HeadE.HAPPY_TALKING, ""Hello again.""); addNPC(GERTRUDE, HeadE.NO_EXPRESSION, ""Hello. How's it going? Any luck?""); addPlayer(HeadE.HAPPY_TALKING, ""Yes, I've found Fluffs!""); addNPC(GERTRUDE, HeadE.HAPPY_TALKING, ""Well well, you are clever! Did you bring her back?""); addPlayer(HeadE.CONFUSED, ""Well, that's the thing, she refuses to leave.""); addNPC(GERTRUDE, HeadE.SAD_MILD, ""Oh dear, oh dear! Maybe she's hungry. She loves doogle sardines but I'm all out.""); addPlayer(HeadE.CONFUSED, ""Doogle sardines?""); addNPC(GERTRUDE, HeadE.NO_EXPRESSION, ""Yes, raw sardines seasoned with doogle leaves. Unfortunately, I've used all my doogle leaves but you may find some on the bush out back.""); break; case 8: addPlayer(HeadE.CHEERFUL, ""Hello, Gertrude. Fluffs had run off with her kittens, lost them and I have now returned them to her.""); addNPC(GERTRUDE, HeadE.HAPPY_TALKING, ""Thank you! If you hadn't found her kittens then they would have died out there. I've got some presents for you in thanks for your help.""); addPlayer(HeadE.CHEERFUL, ""That's ok, I like to do my bit.""); addNPC(GERTRUDE, HeadE.HAPPY_TALKING, ""I have no real material possessions but I do have kittens. I've cooked you some food too.""); addPlayer(HeadE.CHEERFUL, ""You're going to give me a kitten? Thanks.""); addNPC(GERTRUDE, HeadE.HAPPY_TALKING, ""I would sell one to my cousin in West Ardougne. I hear there's a rat epidemic there but it's too far for me to travel, what with my boys and all.""); addNPC(GERTRUDE, HeadE.NO_EXPRESSION, ""Oh, by the way, the kitten can live in your backpack but, to ensure it grows, you must take it out, feed it and stroke it often.""); addSimple(""You've been given a cat!"", () -> player.getQuestManager().completeQuest(Quest.GERTRUDES_CAT)); break; default: if (player.containsItem(1555)) addNPC(GERTRUDE, HeadE.HAPPY_TALKING, ""Take good care of that kitten!""); else addNPC(GERTRUDE, HeadE.ANGRY, ""You lost your kitten? It found it wandering around outside my door! Take care of it this time.."", () -> player.getInventory().addItem(1555, 1)); break; } create(); } }" "package com.rs.game.content.quests.gertrudescat; @QuestHandler( quest = Quest.GERTRUDES_CAT, startText = ""Speak to Gertrude in her house west of Varrock."", itemsText = ""Bucket of milk, raw sardine, doogle leaves (can be obtained from behind Gertrude's house), 100 coins."", combatText = ""None."", rewardsText = ""1,525 Cooking XP
Chocolate cake
Bowl of stew
Kitten(!)
Ability to raise cats"", completedStage = 9 ) @PluginEventHandler public class GertrudesCat extends QuestOutline { /** * Defines the journal lines that get displayed when the player opens their quest book * based on the stage the player is on. */ @Override public List getJournalLines(Player player, int stage) { ArrayList lines = new ArrayList<>(); switch(stage) { case 0: lines.add(""I can start this quest by speaking to Gertrude.""); lines.add(""She can be found in a house south of the road""); lines.add(""leading west out of Varrock.""); break; case 1: lines.add(""I need to speak to Gertrude's Sons, Shilop and""); lines.add(""Wilough, in Varrock Marketplace.""); break; case 2: lines.add(""I need to go to Shilop and Wilough's secret""); lines.add(""hideout in the Lumber Yard and find Fluffs, then""); lines.add(""return her to Gertrude. The Lumber Yard is""); lines.add(""very close to the north-east wall outside Varrock.""); lines.add(""I can enter it by squeezing through a broken fence.""); break; case 3: lines.add(""I had a poke around the Lumber Yard by squeezing""); lines.add(""through a broken fence, and found Fluffs up a""); lines.add(""ladder. I now need to return Fluffs to Gertrude.""); lines.add(""I think Fluffs may be hungry or thirsty but I""); lines.add(""am not sure what she wants; perhaps Gertrude can help?""); break; case 4: lines.add(""I found Fluffs and fed her some milk but she still won't come back.""); break; case 5: lines.add(""Fluffs seems to be hungry.""); break; case 6: lines.add(""I fed Fluffs a doogle sardine but she still won't come back.""); break; case 7: if (player.getInventory().containsItem(13236, 1)) lines.add(""I found some kittens! Fluffs might want to see them.""); else lines.add(""I can hear kittens mewing in the area. I should explore more.""); break; case 8: lines.add(""I returned the kittens to Fluffs who then ran away.""); lines.add(""I think I should see Gertrude in her house, west of""); lines.add(""Varrock, and explain what has happened.""); break; case 9: lines.add(""""); lines.add(""""); lines.add(""QUEST COMPLETE!""); break; default: lines.add(""Invalid quest stage. Report this to an administrator.""); break; } return lines; } /** * What to do when the quest gets completed. ""addXpQuest"" must be used here to avoid * bonus XP or other various XP multipliers from processing. */ @Override public void complete(Player player) { player.getSkills().addXpQuest(Constants.COOKING, 1525); player.getInventory().addItem(1555, 1); player.getInventory().addItem(1897, 1); player.getInventory().addItem(2003, 1); sendQuestCompleteInterface(player, 1555); } /** * Updates whether Fluffs is visible to the player or not. In this case: * var 180 = 2 = Fluffs is only visible at the Lumber Yard * var 180 = 5 = Fluffs is only visible in Gertrude's house * * NPC ID: 759 - transforms into with v180: * [0: INVISIBLE], * [1: INVISIBLE], * [2: 7742 (Fluffs)], * [3: 7742 (Fluffs)], * [4: 7742 (Fluffs)], * [5: INVISIBLE], * * NPC ID: 7744 - transforms into with v180: * [0: INVISIBLE], * [1: INVISIBLE], * [2: INVISIBLE], * [3: INVISIBLE], * [4: INVISIBLE], * [5: 7742 (Fluffs)], * [6: 7742 (Fluffs)], * [7: INVISIBLE], * * NPC id 759 is spawned at the Lumber Yard upstairs. * NPC id 7744 is spawned in Gertrude's home. * * @param com.rs.game.model.entity.player.Player to update Fluffs for. */ public static void updateFluffs(Player player) { if (player.getQuestManager().getStage(Quest.GERTRUDES_CAT) >= 2 && player.getQuestManager().getStage(Quest.GERTRUDES_CAT) < 8) player.getVars().setVar(180, 2); else if (player.getQuestManager().getStage(Quest.GERTRUDES_CAT) >= 8 && !player.isQuestComplete(Quest.GERTRUDES_CAT)) player.getVars().setVar(180, 5); } /** * Handles Fluff's Pick-up option. Whether or not Fluffs has this option available and is visible to the player * depending on the vars set above is automatically handled and verified by the server so cheating cannot occur. * * @param The event to handle. */ public static NPCClickHandler handleFluffsOptions = new NPCClickHandler(new Object[] { 759 }, e -> { if (e.getOption().equals(""Pick-up"")) if (e.getPlayer().getQuestManager().getStage(Quest.GERTRUDES_CAT) == 2 || e.getPlayer().getQuestManager().getStage(Quest.GERTRUDES_CAT) == 4) { e.getNPC().setNextAnimation(new Animation(9160)); e.getNPC().setNextForceTalk(new ForceTalk(""Hiss!"")); e.getPlayer().setNextAnimation(new Animation(827)); e.getPlayer().setNextForceTalk(new ForceTalk(""Ouch!"")); e.getPlayer().startConversation(new Conversation(new SimpleStatement(""Fluffs hisses but clearly wants something - "" + (e.getPlayer().getQuestManager().getStage(Quest.GERTRUDES_CAT) == 2 ? ""maybe she is thirsty?"" : ""maybe she is hungry too?"")))); e.getPlayer().getQuestManager().setStage(Quest.GERTRUDES_CAT, e.getPlayer().getQuestManager().getStage(Quest.GERTRUDES_CAT)+1); updateFluffs(e.getPlayer()); } else if (e.getPlayer().getQuestManager().getStage(Quest.GERTRUDES_CAT) == 6) { e.getNPC().setNextAnimation(new Animation(9160)); e.getNPC().setNextForceTalk(new ForceTalk(""Hiss!"")); e.getPlayer().setNextAnimation(new Animation(827)); e.getPlayer().setNextForceTalk(new ForceTalk(""Ouch!"")); e.getPlayer().startConversation(new Conversation(new SimpleStatement(""Fluffs seems afraid to leave. In the Lumber Yard below you can hear kittens mewing.""))); e.getPlayer().getQuestManager().setStage(Quest.GERTRUDES_CAT, e.getPlayer().getQuestManager().getStage(Quest.GERTRUDES_CAT)+1); updateFluffs(e.getPlayer()); } }); /** * Handles when the player clicks on the shaking crates in the Lumber Yard. * @param The event to handle. */ public static NPCClickHandler handleShakingCrate = new NPCClickHandler(new Object[] { 7740 }, e -> { if (e.getPlayer().getQuestManager().getStage(Quest.GERTRUDES_CAT) == 7) { if (e.getPlayer().containsItem(13236)) return; e.getPlayer().startConversation(new Conversation(new Dialogue() .addItem(13236, ""You find three little kittens! You carefully place them in your backpack. This explains why Fluffs is so agitated."", () -> e.getPlayer().getInventory().addItem(13236, 1)))); } }); /** * Handles starting Gertrude's dialogue. * @param The event to handle. */ public static NPCClickHandler handleGertrude = new NPCClickHandler(new Object[] { 780 }, e -> e.getPlayer().startConversation(new GertrudeD(e.getPlayer()))); /** * Handles starting Shilop and Wilough's dialogue. * @param The event to handle. */ public static NPCClickHandler handleShilopWilough = new NPCClickHandler(new Object[] { 781, 783 }, e -> e.getPlayer().startConversation(new ShilopWiloughD(e.getPlayer(), e.getNPC()))); /** * When the player logs in, Fluffs is re-updated to make sure she is still visible. */ public static LoginHandler onLogin = new LoginHandler(e -> updateFluffs(e.getPlayer())); /** * Handles the creation of doogle sardines. * @param The event to handle. */ public static ItemOnItemHandler handleDoogleSardineCreation = new ItemOnItemHandler(327, 1573, e -> e.getPlayer().startConversation(new Conversation(new Dialogue().addSimple(""You rub the doogle leaves over the sardine."", () -> { e.getPlayer().getInventory().deleteItem(327, 1); e.getPlayer().getInventory().deleteItem(1573, 1); e.getPlayer().getInventory().addItem(1552, 1); })))); /** * Handles the various items you must use on Fluffs at the Lumber Yard to get her to trust you. * @param The event to handle. */ public static ItemOnNPCHandler handleItemOnFluffs = new ItemOnNPCHandler(759, e -> { if (e.getItem().getId() == 1927) { if (e.getPlayer().getQuestManager().getStage(Quest.GERTRUDES_CAT) == 3) { e.getPlayer().setNextAnimation(new Animation(827)); e.getPlayer().startConversation(new Conversation(e.getPlayer(), new Dialogue() .addNPC(e.getNPC().getId(), HeadE.CAT_CALM_TALK, ""Mew!"") .addPlayer(HeadE.CHEERFUL, ""Progress at least."") .addSimple(""Fluffs laps up the milk greedily. Then she mews at you again."", () -> { e.getPlayer().getInventory().deleteItem(1927, 1); e.getPlayer().getInventory().addItem(1925, 1); e.getPlayer().getQuestManager().setStage(Quest.GERTRUDES_CAT, 4); updateFluffs(e.getPlayer()); }))); } } else if (e.getItem().getId() == 1552) { if (e.getPlayer().getQuestManager().getStage(Quest.GERTRUDES_CAT) == 5) { e.getPlayer().setNextAnimation(new Animation(827)); e.getPlayer().startConversation(new Conversation(e.getPlayer(), new Dialogue() .addNPC(e.getNPC().getId(), HeadE.CAT_CALM_TALK, ""Mew!"") .addPlayer(HeadE.CHEERFUL, ""Progress at least."") .addSimple(""Fluffs devours the doogle sardine greedily. Then she mews at you again."", () -> { e.getPlayer().getInventory().deleteItem(1552, 1); e.getPlayer().getQuestManager().setStage(Quest.GERTRUDES_CAT, 6); updateFluffs(e.getPlayer()); }))); } } else if (e.getItem().getId() == 13236) if (e.getPlayer().getQuestManager().getStage(Quest.GERTRUDES_CAT) == 7) { e.getPlayer().setNextAnimation(new Animation(827)); // TODO cutscene // https://i.imgur.com/VEkOx0N.jpg // https://i.imgur.com/G6pFoqR.jpg // https://i.imgur.com/3f7cvd2.jpg e.getPlayer().getInventory().deleteItem(13236, 1); e.getPlayer().getQuestManager().setStage(Quest.GERTRUDES_CAT, 8); updateFluffs(e.getPlayer()); } }); }" "package com.rs.game.content.quests.gertrudescat; public class ShilopWiloughD extends Conversation { public ShilopWiloughD(Player player, NPC npc) { super(player); int npcId = npc.getId(); if (player.getQuestManager().getStage(Quest.GERTRUDES_CAT) == 0) { addPlayer(HeadE.NO_EXPRESSION, ""Hello youngster.""); addNPC(npcId, HeadE.CHILD_UNSURE, ""I don't talk to strange old people.""); } else if (player.getQuestManager().getStage(Quest.GERTRUDES_CAT) == 1) { addPlayer(HeadE.NO_EXPRESSION, ""Hello there, I've been looking for you and it's important.""); addNPC(npcId, HeadE.CHILD_CALM_TALK, ""I didn't mean to take it! I just forgot to pay.""); addPlayer(HeadE.CONFUSED, ""What? I'm trying to help your mum find some cat called Fluffs.""); addNPC(npcId, HeadE.CHILD_CALM_TALK, ""Ohh...well, in that case I might be able to help. Fluffs followed me to my super secret hideout, I haven't seen her since. She's probably off eating small creatures somewhere.""); addPlayer(HeadE.CONFUSED, ""Where is this secret hideout? I really need to find that cat for your mum.""); addNPC(npcId, HeadE.CHILD_CALM_TALK, ""If I told you that, it wouldn't be a secret. What if I need to escape from the law? I need a hideout.""); addPlayer(HeadE.NO_EXPRESSION, ""From my limited knowledge of the law, they are not usually involved in manhunts for children.""); addNPC(npcId, HeadE.CHILD_FRUSTRATED, ""Well it's still mine anyway, I need a place to be alone sometimes. Those two little brothers at the house are just such babies.""); addOptions(new Options() { @Override public void create() { option(""Tell me sonny, or I will inform your mum you are a criminal."", new Dialogue() .addPlayer(HeadE.ANGRY, ""Tell me sonny, or I will inform your mum you are a criminal."") .addNPC(npcId, HeadE.CHILD_AWE, ""W..wh..what?! Y..you wouldn't! Anyway, I'll deny it all and she'll be sure to believe me over some wandering killer like you."") .addPlayer(HeadE.ANGRY, ""I'm an upstanding citizen!"") .addNPC(npcId, HeadE.CHILD_EVIL_LAUGH, ""I'm her darling boy and you'd have to forget about her rewarding you. Hop it snitch."") .addSimple(""You decide it's best not to aggravate the repulsive boy any more."")); option(""What will make you tell me?"", new Dialogue() .addPlayer(HeadE.CONFUSED, ""What will make you tell me?"") .addNPC(npcId, HeadE.CHILD_UNSURE, ""Well...now you ask, I am a bit short on cash."") .addPlayer(HeadE.ROLL_EYES, ""How much?"") .addNPC(npcId, HeadE.CHILD_CALM_TALK, ""100 coins should cover it."") .addPlayer(HeadE.FRUSTRATED, ""100 coins! What sort of expensive things do you need that badly?"") .addNPC(npcId, HeadE.CHILD_CALM_TALK, ""Well I don't like chocolate and have you seen how much sweets cost to buy?"") .addPlayer(HeadE.ROLL_EYES, ""Why should I pay you then, can you answer that as easily?"") .addNPC(npcId, HeadE.CHILD_CALM_TALK, ""Obviously you shouldn't pay that much, but I won't help otherwise. I never liked that cat anyway, fussy scratchy thing it is, so what do you say?"") .addOptions(new Options() { @Override public void create() { Dialogue pay = new Dialogue(); if (player.getInventory().hasCoins(100)) pay.addPlayer(HeadE.NO_EXPRESSION, ""Okay then, I'll pay, but I'll want you to tell your mother what a nice person I am."") .addNPC(npcId, HeadE.CHILD_UNSURE, ""What?"") .addPlayer(HeadE.NO_EXPRESSION, ""I'll want you to tell your mother what a nice person I am so she rewards me for this search."") .addNPC(npcId, HeadE.CHILD_CALM_TALK, ""It's a deal."").addItem(997, ""You give the lad 100 coins."", () -> { if (player.getInventory().hasCoins(100)) { player.getInventory().removeCoins(100); player.getQuestManager().setStage(Quest.GERTRUDES_CAT, 2); GertrudesCat.updateFluffs(player); } }).addPlayer(HeadE.NO_EXPRESSION, ""There you go, now where did you see Fluffs?"") .addNPC(npcId, HeadE.CHILD_CALM_TALK, ""I hide out at the lumber mill to the north-east. Just beyond the Jolly Boar Inn. I saw Fluffs running around in there. Well, not so much running as plodding lazily, but you get the idea."") .addPlayer(HeadE.NO_EXPRESSION, ""Anything else?"") .addNPC(npcId, HeadE.CHILD_CALM_TALK, ""Well, technically you are trespassing inside there but no-one seems to care. You'll have to find the broken fence to get in. It will be a bit of a squeeze for a grown up but I'm sure you can manage that.""); else pay.addPlayer(HeadE.NO_EXPRESSION, ""I actually don't have 100 coins with me.."") .addNPC(npcId, HeadE.CHILD_UNSURE, ""Well it looks like someone else is going to have to find the fleabag then.""); option(""I'm not paying you a thing."", new Dialogue() .addPlayer(HeadE.ANGRY, ""I'm not paying you a thing."") .addNPC(npcId, HeadE.CHILD_DOWN, ""Okay then, I'll find another way to make money. You only have yourself to blame if I'm forced into a life of crime."")); option(""Okay then, I'll pay."", pay); } })); option(""Well, never mind. It's Fluffs' loss."", new Dialogue() .addPlayer(HeadE.ROLL_EYES, ""Well, never mind, it's Fluffs' loss."") .addNPC(npcId, HeadE.CHILD_CALM_TALK, ""I'm sure my mum will get over it."")); } }); } else if (player.getQuestManager().getStage(Quest.GERTRUDES_CAT) == 2) { addPlayer(HeadE.NO_EXPRESSION, ""Where did you say you saw Fluffs?""); addNPC(npcId, HeadE.CHILD_CALM_TALK, ""Weren't you listening? I saw the fleabag in the old Lumber Yard north-east of here. Walk past the Jolly Boar inn and you should find it.""); } else { addPlayer(HeadE.CHEERFUL, ""Hello again.""); addNPC(npcId, HeadE.CHILD_ANGRY, ""You think you're tough do you?""); addPlayer(HeadE.SCARED, ""Pardon?""); addNPC(npcId, HeadE.CHILD_ANGRY, ""I can beat anyone up!""); addPlayer(HeadE.ROLL_EYES, ""Really?""); addSimple(""The boy begins to jump around with his fists up. You wonder what sort of desperado he'll grow up to be."", () -> npc.setNextAnimation(new Animation(12447))); } create(); } }" "package com.rs.game.content.quests.blackknightsfortress; @QuestHandler( quest = Quest.BLACK_KNIGHTS_FORTRESS, startText = ""Speak to Sir Amik Varze on the 3rd floor of the White Knights' Castle's western tower in Falador."", itemsText = ""Cabbage
Iron chainbody
Bronze med helm"", combatText = ""Ability to evade level 33 Black Knights"", rewardsText = ""2,500 coins"", completedStage = 4 ) @PluginEventHandler public class BlackKnightsFortress extends QuestOutline { public final static int NOT_STARTED = 0; public final static int STARTED = 1; public final static int HEARD_PLAN = 2; public final static int RUINED_CAULDRON = 3; public final static int QUEST_COMPLETE = 4; // Animations public final static int TOSS_CABBAGE = 9705; public final static int CRY = 860; public final static int LISTEN_GRILL = 4195; public final static int FINISH_LISTEN_GRILL = 4197; public final static int CAULDRON_EXPLOSION_GFX = 773; public final static int CABBAGE_PROJECTILE = 772; // Varbits protected final static int CAULDRON_STATUS_VAR = 2494; // Objects protected final static int GRILL_LISTEN = 2342; protected final static int CAULDRON = 17163; protected final static int CABBAGE_HOLE = 2336; protected final static int FORTRESS_FRONT_DOOR = 2337; protected final static int FORTRESS_MEETING_ROOM_DOOR = 2338; // Black knight fortress chunks protected final static Set FORTRESS_CHUNKS = new HashSet<>(Arrays.asList(6180280, 6163896, 6196656, 6196664)); @Override public List getJournalLines(Player player, int stage) { ArrayList lines = new ArrayList<>(); switch (stage) { case NOT_STARTED: lines.add(""The Black Knights are up to no good. You are ""); lines.add(""hired by the White Knights to spy on them and""); lines.add(""uncover their evil scheme.""); lines.add(""""); lines.add(""Talk to Sir Amik Varze, located on the 3rd floor""); lines.add(""in the western tower of the White Knights' Castle""); lines.add(""in Falador to get started.""); lines.add(""""); break; case STARTED: lines.add(""I should infiltrate the Black Knights fortress and""); lines.add(""find out their plans...""); lines.add(""""); lines.add(""I will need an Iron Chain body & Bronze Med Helm""); lines.add(""equipped to enter...""); lines.add(""""); lines.add(""Perhaps I could listen in through a wall or something""); lines.add(""""); break; case HEARD_PLAN: lines.add(""Oh no! The Black Knights have a witch who can make an""); lines.add(""invincibility potion. I need to find a way to ruin her""); lines.add(""potion...""); lines.add(""""); lines.add(""Maybe I can toss a cabbage through a vent above it?""); lines.add(""""); break; case RUINED_CAULDRON: lines.add(""Aha! I have ruined the witch's plan, Time to report to""); lines.add(""Sir Amik Varze to update him Falador is safe!""); lines.add(""""); break; case QUEST_COMPLETE: lines.add(""""); lines.add(""""); lines.add(""QUEST COMPLETE!""); break; default: lines.add(""Invalid quest stage. Report this to an administrator.""); break; } return lines; } @Override public void complete(Player player) { player.getInventory().addCoins(2500); sendQuestCompleteInterface(player, 9591); } public static EnterChunkHandler handleAgressiveKnights = new EnterChunkHandler(e -> { if (e.getEntity() instanceof Player p && p.hasStarted() && FORTRESS_CHUNKS.contains(e.getChunkId())) { if (p.getQuestManager().getStage(Quest.BLACK_KNIGHTS_FORTRESS) >= STARTED && !p.isQuestComplete(Quest.BLACK_KNIGHTS_FORTRESS)) { for (NPC npc : World.getNPCsInChunkRange(e.getPlayer().getChunkId(), 1)) { if (npc.getName().equalsIgnoreCase(""Black Knight"")) if (npc.lineOfSightTo(p, false)) { npc.setTarget(p); if (Utils.random(0, 5) == 1) npc.forceTalk(""Die intruder!""); } } } } }); public static ObjectClickHandler handleMeetingDoor = new ObjectClickHandler(new Object[] { FORTRESS_MEETING_ROOM_DOOR }, e -> { Player p = e.getPlayer(); if (p.getX() < e.getObject().getX()) p.startConversation(new Conversation(p) { { addNPC(4604, HeadE.SKEPTICAL, ""I wouldn't go in there if I were you. Those Black Knights are in an important meeting. "" + ""They said they'd kill anyone who went in there!""); addOptions(""Select an option"", new Options() { @Override public void create() { option(""Okay, I won't"", new Dialogue().addPlayer(HeadE.SCARED, ""Okay, I won't."")); option(""I don't care: i'm going in anyway"", new Dialogue().addPlayer(HeadE.LAUGH, ""I am going in anyway"").addNext(() -> handleDoor(p, e.getObject()))); } }); addPlayer(HeadE.SKEPTICAL_THINKING, ""I don't know...""); create(); } }); else handleDoor(p, e.getObject()); }); public static ObjectClickHandler handleFrontDoor = new ObjectClickHandler(new Object[] { FORTRESS_FRONT_DOOR }, e -> { Player p = e.getPlayer(); if (p.getY() > e.getObject().getY()) { handleDoor(p, e.getObject()); return; } if (p.getEquipment().getHatId() != 1139 || p.getEquipment().getChestId() != 1101) {//bronze med iron chainbody p.startConversation(new Conversation(p) { { addNPC(4604, HeadE.SKEPTICAL, ""Password?""); addPlayer(HeadE.SKEPTICAL_THINKING, ""I don't know...""); create(); } }); return; } handleDoor(p, e.getObject()); }); public static ObjectClickHandler handleGrill = new ObjectClickHandler(new Object[] { GRILL_LISTEN }, e -> { Player p = e.getPlayer(); if (p.getQuestManager().getStage(Quest.BLACK_KNIGHTS_FORTRESS) != STARTED) return; p.setNextAnimation(new Animation(LISTEN_GRILL)); p.startConversation(new Conversation(p) {//610 black knight, 611 witch { addNPC(610, HeadE.CALM_TALK, ""So... how's the secret weapon coming along?""); addNPC(611, HeadE.HAPPY_TALKING, ""The invincibility potion is almost ready...""); addNPC(611, HeadE.HAPPY_TALKING, ""It's taken me FIVE YEARS, but it's almost ready.""); addNPC(611, HeadE.HAPPY_TALKING, ""Greldo, the goblin here, is just going to fetch the last ingredient for me.""); addNPC(611, HeadE.HAPPY_TALKING, ""It's a special cabbage grown by my cousin Helda, who lives in Draynor Manor.""); addNPC(611, HeadE.HAPPY_TALKING, ""The soil there is slightly magical and it gives the cabbages slight magical properties...""); addNPC(611, HeadE.HAPPY_TALKING, ""...not to mention the trees!""); addNPC(611, HeadE.AMAZED_MILD, ""Now, remember, Greldo, only a Draynor Manor cabbage will do! Don't get lazy and bring any old cabbage. THAT"" + "" would ENITERELY wreck the potion!""); addNPC(612, HeadE.CHILD_CALM_TALK, ""Yeth, mithtreth"");//random goblin addNext(() -> { p.getQuestManager().setStage(Quest.BLACK_KNIGHTS_FORTRESS, HEARD_PLAN); p.setNextAnimation(new Animation(FINISH_LISTEN_GRILL)); }); create(); } }); }); public static ItemOnObjectHandler handleCabbageOnHole = new ItemOnObjectHandler(new Object[] { CABBAGE_HOLE }, new Object[] { 1965 }, e -> { Player p = e.getPlayer(); if (p.getQuestManager().getStage(Quest.BLACK_KNIGHTS_FORTRESS) != HEARD_PLAN) return; GameObject cauldron = World.getObjectWithId(Tile.of(3031, 3507, 0), CAULDRON); Tile tileBeforeCutscene = Tile.of(p.getX(), p.getY(), p.getPlane()); p.lock(); p.getInventory().removeItems(new Item(1965, 1)); WorldTasks.scheduleLooping(new Task() { int tick; final int WITCH_DIALOGUE1 = 10; final int KNIGHT_CAPTAIN_DIALOGUE1 = 12; final int POTION_RUINED = 20; @Override public void run() { if (tick == 0) { p.setNextAnimation(new Animation(TOSS_CABBAGE)); World.sendProjectile(p, Tile.of(p.getX() + 1, p.getY(), p.getPlane()), CABBAGE_PROJECTILE, 40, 0, 2, 0.1, 20, 0); } if (tick == 3) p.getInterfaceManager().setFadingInterface(115); if (tick == 6) { p.tele(cauldron.getTile()); p.getAppearance().transformIntoNPC(264); } if (tick == 7) p.getInterfaceManager().setFadingInterface(170); if (tick == WITCH_DIALOGUE1) p.startConversation(new Conversation(p) { { addNPC(611, HeadE.ANGRY, ""Where has Greldo got to with that magic cabbage!""); addNext(() -> tick++); create(); } }); if (tick == KNIGHT_CAPTAIN_DIALOGUE1) p.startConversation(new Conversation(p) {//610: black knight captain { addNPC(610, HeadE.SKEPTICAL_THINKING, ""What's that noise?""); addNPC(611, HeadE.AMAZED_MILD, ""Hopefully Greldo with that cabbage... yes look here it co....NOOOOOoooo!""); addNext(() -> { for (NPC npc : World.getNPCsInChunkRange(e.getPlayer().getRegionId(), 2)) if (npc.getId() == 611 || npc.getId() == 610) npc.faceObject(cauldron); tick++; }); create(); } }); if (tick == 14) World.sendProjectile(Tile.of(3030, 3507, 0), cauldron, CABBAGE_PROJECTILE, 150, 0, 0, 0.1, 0, proj -> World.sendSpotAnim(Tile.of(p.getX(), p.getY(), p.getPlane()), new SpotAnim(CAULDRON_EXPLOSION_GFX))); if (tick == POTION_RUINED) { p.getVars().setVarBit(CAULDRON_STATUS_VAR, 1); p.startConversation(new Conversation(p) {//610 black knight captain, 611 witch { addNPC(611, HeadE.AMAZED_MILD, ""My potion!""); addNPC(610, HeadE.SCARED, ""Oh boy, this doesn't look good!""); addNPC(4607, HeadE.CAT_CALM_TALK, ""Meow!""); addNext(() -> tick++); for (NPC npc : World.getNPCsInChunkRange(e.getPlayer().getRegionId(), 2)) if (npc.getId() == 611) npc.setNextAnimation(new Animation(CRY)); create(); } }); } if (tick == 22) p.getInterfaceManager().setFadingInterface(115); if (tick == 25) { p.tele(tileBeforeCutscene); p.getAppearance().transformIntoNPC(-1); } if (tick == 26) p.getInterfaceManager().setFadingInterface(170); if (tick == 27) { p.getQuestManager().setStage(Quest.BLACK_KNIGHTS_FORTRESS, RUINED_CAULDRON); p.unlock(); stop(); } if (tick != WITCH_DIALOGUE1 + 1 && tick != KNIGHT_CAPTAIN_DIALOGUE1 + 1 && tick != POTION_RUINED + 1) tick++; } }, 0, 1); }); public static LoginHandler onLogin = new LoginHandler(e -> { if (e.getPlayer().getQuestManager().getStage(Quest.BLACK_KNIGHTS_FORTRESS) >= RUINED_CAULDRON) e.getPlayer().getVars().setVarBit(CAULDRON_STATUS_VAR, 1); }); }" "package com.rs.game.content.quests.blackknightsfortress; @PluginEventHandler public class SirAmikVarzeBlackKnightsFortressD extends Conversation { private final int QUEST_START_CONVO = 0; private final static int SIR_AMIK_VARZE = 608; public SirAmikVarzeBlackKnightsFortressD(Player p) { super(p); switch(p.getQuestManager().getStage(Quest.BLACK_KNIGHTS_FORTRESS)) { case NOT_STARTED -> { addPlayer(HeadE.SKEPTICAL_THINKING, ""Who are you?""); addNPC(SIR_AMIK_VARZE, HeadE.CALM_TALK, ""I am the leader of the White Knights of Falador. Why do you seek my audience?""); addOptions(""Choose an option:"", new Options() { @Override public void create() { if(p.getQuestManager().getQuestPoints() < 12) option(""I seek a quest"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""I seek a quest"") .addNPC(SIR_AMIK_VARZE, HeadE.CALM_TALK, ""Well I do have a task, but it is very dangerous and it's critical to us that no mistakes "" + ""are made"") .addNPC(SIR_AMIK_VARZE, HeadE.CALM_TALK, ""I couldn't possibly let an unexperienced quester like yourself go"") .addSimple(""(You need at least 12 quest points before you may attempt this quest)"")); else option(""I seek a quest"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""I seek a quest"") .addNPC(SIR_AMIK_VARZE, HeadE.SKEPTICAL_THINKING, ""Well, I need some spy work doing. It's quite dangerous"") .addNPC(SIR_AMIK_VARZE, HeadE.CALM_TALK, ""You will need to go into the Black Knight's fortress"") .addOptions(""Choose an option:"", new Options() { @Override public void create() { option(""I laugh in the face of danger"", new Dialogue() .addPlayer(HeadE.LAUGH, ""I laugh in the face of danger"") .addNPC(SIR_AMIK_VARZE, HeadE.CALM_TALK, ""Well that's good. Don't get too overconfident though."") .addNext(() -> p.startConversation(new SirAmikVarzeBlackKnightsFortressD(p, QUEST_START_CONVO).getStart()))); option(""I go and cower in a corner at the first sign of danger"", new Dialogue() .addPlayer(HeadE.SCARED, ""I go and cower in a corner at the first sign of danger"") .addNPC(SIR_AMIK_VARZE, HeadE.CALM_TALK, ""Err..."") .addNPC(SIR_AMIK_VARZE, HeadE.CALM_TALK, ""Well..."") .addNPC(SIR_AMIK_VARZE, HeadE.CALM_TALK, ""Spy work does involve a little hiding in corners I suppose"") .addOptions(""Choose a response"", new Options() { @Override public void create() { option(""Oh I suppose I'll give it a go then"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Oh I suppose I'll give it a go then"") .addNext(() -> p.startConversation(new SirAmikVarzeBlackKnightsFortressD(p, QUEST_START_CONVO).getStart()))); option(""No I'm not convinced"", new Dialogue().addPlayer(HeadE.SCARED, ""No I'm not convinced"")); } })); } })); option(""I don't i'm just looking around"", new Dialogue() .addPlayer(HeadE.SKEPTICAL, ""I don't i'm just looking around"") .addNPC(SIR_AMIK_VARZE, HeadE.CALM_TALK, ""Ok, don't break anything"")); } }); } case STARTED -> { addNPC(SIR_AMIK_VARZE, HeadE.CALM_TALK, ""You should head to the Black Knights Fortress and find out what their secret weapon is...""); addPlayer(HeadE.CALM_TALK, ""Okay, I will do that.""); } case HEARD_PLAN -> { addPlayer(HeadE.AMAZED_MILD, ""I found out their secret weapon!""); addNPC(SIR_AMIK_VARZE, HeadE.CALM_TALK, ""Let's hear it!""); addPlayer(HeadE.SKEPTICAL, ""It is an invincibility potion...""); addNPC(SIR_AMIK_VARZE, HeadE.CALM_TALK, ""Oh no, then we are surely doomed! Can you ruin the potion somehow?""); addPlayer(HeadE.SKEPTICAL, ""I can try!""); addNPC(SIR_AMIK_VARZE, HeadE.CALM_TALK, ""Please do that!""); } case RUINED_CAULDRON -> { addPlayer(HeadE.HAPPY_TALKING, ""I have ruined the Black Knight's invincibility potion. That should put a stop to your problem and an end to their"" + "" little schemes.""); addNPC(SIR_AMIK_VARZE, HeadE.CALM_TALK, ""Yes, we have just recieved a message from the Black Knights saying they withdraw their demands, which seems to confirm your"" + "" story.""); addPlayer(HeadE.CALM_TALK, ""Now I believe there was some talk of a cash reward...""); addNPC(SIR_AMIK_VARZE, HeadE.CALM_TALK, ""Absoluely right. Please accept this reward.""); addNext(()-> p.getQuestManager().completeQuest(Quest.BLACK_KNIGHTS_FORTRESS)); } case QUEST_COMPLETE -> { addNPC(SIR_AMIK_VARZE, HeadE.CALM_TALK, ""Thank you for saving us from the Black Knights!""); addPlayer(HeadE.HAPPY_TALKING, ""Of course!""); } } } public SirAmikVarzeBlackKnightsFortressD(Player p, int convoID) { super(p); switch(convoID) { case QUEST_START_CONVO -> { addNPC(SIR_AMIK_VARZE, HeadE.CALM_TALK, ""You have come along just right actually, all of my knights are known to the black knights already. Subtlety isn't "" + ""exactly our strong point""); addPlayer(HeadE.CALM_TALK, ""So what needs doing?""); addNPC(SIR_AMIK_VARZE, HeadE.CALM_TALK, ""Well the black knights have started making strange threats to us, demanding "" + ""large amounts of money and land""); addNPC(SIR_AMIK_VARZE, HeadE.CALM_TALK, ""And threatening to invade Falador if we don't pay. Now normally this "" + ""wouldn't be a problem but they claim to have a powerful new secret weapon.""); addNPC(SIR_AMIK_VARZE, HeadE.CALM_TALK, ""What I want you to do is to get inside their fortress and find out what "" + ""their secret weapon is and then sabotage it.""); addNPC(SIR_AMIK_VARZE, HeadE.CALM_TALK, ""You will be well paid""); addOptions(""Start Black Knights Fortress?"", new Options() { @Override public void create() { option(""Yes"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""OK I'll give it a try."", ()-> p.getQuestManager().setStage(Quest.BLACK_KNIGHTS_FORTRESS, STARTED))); option(""No"", new Dialogue()); } }); } } } public static NPCClickHandler handleSirAmik = new NPCClickHandler(new Object[] { SIR_AMIK_VARZE }, e -> e.getPlayer().startConversation(new SirAmikVarzeBlackKnightsFortressD(e.getPlayer()).getStart())); }" "package com.rs.game.content.quests.buyersandcellars; @QuestHandler( quest = Quest.BUYERS_AND_CELLARS, startText = ""Speak to Darren Lightfinger in his cellar, accessed through a trapdoor next to a small house just north of the Lumbridge furnace."", itemsText = ""Logs."", combatText = ""None."", rewardsText = ""500 Thieving XP
Access to the Thieves' guild
3 Thieves' Guild pamphlets
Ability to collect Hanky Points
"", completedStage = 9 ) @PluginEventHandler public class BuyersAndCellars extends QuestOutline { @Override public List getJournalLines(Player player, int stage) { List lines = new ArrayList<>(); switch (stage) { case 0 -> { lines.add(""Darren Lightfinger, in his cellar under the house north of""); lines.add(""Lumbridge's forge, has offered to test my pickpocketing skills""); lines.add(""and offer advice.""); lines.add(""""); } case 1 -> { lines.add(""I should practise my thieving technique""); lines.add(""and return to the Thieves' Guild when I am ready.""); lines.add(""""); } case 2 -> { lines.add(""Darren can now tell me his plan.""); lines.add(""""); } case 3 -> { lines.add(""I should go to the grounds of Lumbridge Castle""); lines.add(""and discover the identity of the chalice's owner from Robin.""); lines.add(""""); } case 4 -> { lines.add(""Robin tells me that the chalice has been taken into Lumbridge Swamp by an irritable old man.""); lines.add(""""); } case 5 -> { lines.add(""I need to find a way to divert Father Urhney's attention""); lines.add(""so I can get the key off him.""); lines.add(""Maybe Robin can advise me.""); lines.add(""""); } case 6 -> { lines.add(""If I light a fire outside one of the windows""); lines.add(""of Father Urhney's house.""); lines.add("" it might distract him enough for me to be able to pick his pocket.""); lines.add(""""); } case 7 -> { lines.add(""I acquired Urhney's key.""); lines.add(""Now to steal the chalice from its display case...""); lines.add(""""); } case 8 -> { lines.add(""I have stolen the golden chalice. I should deliver it to Darren.""); lines.add(""""); } case 9 -> { lines.add(""I have given the chalice to Darren Lightfinger,""); lines.add(""Guildmaster of the Thieves' Guild.""); lines.add(""""); } } return lines; } @Override public void complete(Player player) { player.getSkills().addXpQuest(Skills.THIEVING, 500); if(player.getInventory().hasFreeSlots()) player.getInventory().addItem(18646, 3); else { player.getBank().addItem(new Item(18646), false); player.getBank().addItem(new Item(18646), false); player.getBank().addItem(new Item(18646), false); player.sendMessage(""You do not have enough free space so your rewards have been sent to the bank.""); } sendQuestCompleteInterface(player, 18648); } @Override public void updateStage(Player player, int stage) { switch (stage) { case 1, 2 -> { player.getVars().setVarBit(7820, 1); player.getVars().setVarBit(7793, 0); } case 3, 8 -> { player.getVars().setVarBit(7820, 1); player.getVars().setVarBit(7793, 25); } case 4, 5, 6, 7 -> { player.getVars().setVarBit(7820, 1); player.getVars().setVarBit(7793, 10); } } } }" "package com.rs.game.content.quests.buyersandcellars; @PluginEventHandler public class Chalice { public static ObjectClickHandler handleShackDoor = new ObjectClickHandler(new Object[] { 45539, 45540 }, e -> Doors.handleDoor(e.getPlayer(), e.getObject())); public static ObjectClickHandler handleCase = new ObjectClickHandler(new Object[] { 51653 }, e -> { if(e.getPlayer().getQuestStage(Quest.BUYERS_AND_CELLARS) != 7){ e.getPlayer().sendMessage(""The golden chalice is firmly locked inside this sturdy display case.""); } else if(e.getPlayer().getInventory().containsItem(18647)){ e.getPlayer().getInventory().deleteItem(18647,1); e.getPlayer().getInventory().addItem(18648); e.getPlayer().sendMessage(""You quietly unlock the display case and remove the golden chalice from it.""); e.getPlayer().setQuestStage(Quest.BUYERS_AND_CELLARS,8); } else e.getPlayer().sendMessage(""The golden chalice is firmly locked inside this sturdy display case.""); }); }" "package com.rs.game.content.quests.buyersandcellars; @PluginEventHandler public class DodgyFlier { public static ItemClickHandler read = new ItemClickHandler(new Object[] { 18645 }, new String[] { ""Read"" }, e -> { e.getPlayer().sendMessage(""It says to apply at the Lumbridge Guildhouse. Wonder where that is...""); e.getPlayer().getInterfaceManager().sendInterface(220);//Message interface e.getPlayer().getPackets().setIFText(220, 1, ""Darren Lightfinger,""); e.getPlayer().getPackets().setIFText(220, 2, ""Chancellor of the Lumbridge Guild of Thieves,""); e.getPlayer().getPackets().setIFText(220, 3, ""requests your presence at the First Annual Selection of Appointees.""); e.getPlayer().getPackets().setIFText(220, 4, ""If you have ever dreamed of making a name for yourself,""); e.getPlayer().getPackets().setIFText(220, 5,""and making your fortune at the same time,""); e.getPlayer().getPackets().setIFText(220, 6,""now is the best opportunity you will ever have!""); e.getPlayer().getPackets().setIFText(220, 7, ""The world-renowned Lumbridge Guild of Thieves""); e.getPlayer().getPackets().setIFText(220, 8, ""is recruiting new members""); e.getPlayer().getPackets().setIFText(220, 9,""to be shown a new world of profit and derring-do.""); e.getPlayer().getPackets().setIFText(220, 10, ""Commissions, fame and the adulation of your peers""); e.getPlayer().getPackets().setIFText(220, 11,""and of the opposite sex will be your fate""); e.getPlayer().getPackets().setIFText(220, 12, ""as a successful applicant.""); e.getPlayer().getPackets().setIFText(220, 13, ""and your life will never again be the same!""); }); }" "package com.rs.game.content.quests.buyersandcellars.npcs @ServerStartupEvent fun mapDarrenBuyersAndCellars() { onItemOnNpc(11273) { e -> if (e.item.id == 18648) { e.player.startConversation { npc(e.npc, SAD, ""Have you retrieved the chalice?"") player(HAPPY_TALKING, ""I have!"") npc(e.npc, HAPPY_TALKING, ""Fantastic work! I knew I had chosen wisely when I recruited you. Now we can expand the guild and do some proper training around here."") player(SKEPTICAL_HEAD_SHAKE, ""Your buyer is still interested, I hope?"") npc(e.npc, CALM_TALK, ""Yes, of course, why?"") player(CALM_TALK, ""Well, the chalice wasn't where you said it was, nor was the owner; I just wanted to make sure you had something right in all of this."") npc(e.npc, LAUGH, ""Ha! I do appreciate a sense of humor in my members."") player(CALM_TALK, ""It wasn't actually a joke, to be honest."") npc(e.npc, SKEPTICAL_HEAD_SHAKE, ""To be honest? You don't want to be honest; you're a member of the illustrious Thieves' Guild! Now get out there and make me proud... and both of us rich!"") exec { e.player.fadeScreen { e.player.inventory.deleteItem(18648, 1) e.player.tele(Tile.of(3223, 3269, 0)) e.player.vars.saveVarBit(7792, 10) e.player.vars.setVarBit(7793, 0) } e.player.questManager.completeQuest(Quest.BUYERS_AND_CELLARS) } } } } } object DarrenBuyersAndCellars { fun stage2(p: Player, npc: NPC) { p.startConversation { npc(npc, HAPPY_TALKING, ""Greetings, my young recruit! You return!"") player(CALM_TALK, ""Can we get started? I'm ready."") npc(npc, HAPPY_TALKING, ""Excellent! I shall let Robin know he should expect you, then. You know what to do?"") options { op(""Yes."") { player(CALM_TALK, ""Yes."") npc(npc, HAPPY_TALKING, ""Best of luck then."") player(CALM_TALK, ""Thanks."") exec { p.setQuestStage(Quest.BUYERS_AND_CELLARS, 3) } } op(""Remind me again?"") { player(CALM_TALK, ""Remind me again?"") npc(npc, CALM, ""Head over to Lumbridge Castle's courtyard; Robin should have found out the identity of the chalice's owner by then. At that point, you just need to get the key by any means necessary, open the vault and then come back here with the chalice."") player(CALM_TALK, ""Why can't you do this?"") npc(npc, CALM, ""Oh, Robin and I are both too well known; anyone with valuables would be instantly on their guard. No, I'm afraid it will have to be you doing the dirty work this time. Don't worry, you'll get a chance to see me in action some other time!"") } } } } fun preQuest(p: Player, npc: NPC) { p.startConversation { npc(npc, HAPPY_TALKING, ""Ah, come in, come in! I was just about to get started."") label(""options"") options { op(""Don't let me stop you."") { player(CONFUSED, ""Don't let me stop you."") npc(npc, HAPPY_TALKING, ""Ladies and gentlemen of Lumbridge!"") npc(npc, HAPPY_TALKING, ""Tonight, I stand before you to offer you the ultimate in opportunities!"") npc(npc, HAPPY_TALKING, ""I offer you the chance to make your mark on a society rife with imbalance and folly."") npc(npc, HAPPY_TALKING, ""I offer you the chance to redistribute the wealth of our very civilization!"") npc(npc, HAPPY_TALKING, ""I offer you the freedom to live your life without the need to worry whether your rent will be paid this month"") npc(npc, HAPPY_TALKING, ""I offer you the skills to pay your way through the costs everyone must face."") npc(npc, HAPPY_TALKING, ""I offer you vengeance against those who take and take yet give nothing in return."") npc(npc, HAPPY_TALKING, ""I offer you justice at its most fundamental level!"") npc(npc, HAPPY_TALKING, ""Some will say that I am a scofflaw, a thief, a brigand... These people are correct!"") npc(npc, HAPPY_TALKING, ""But if I scoff at the law, it is because the law as we know it is a tool that 'The Man' is using purely to keep us in our place."") npc(npc, HAPPY_TALKING, ""If I thieve, it is from those who have more than they deserve and more than they need."") npc(npc, HAPPY_TALKING, ""And if I am a brigand, it is only by the standards of those whom I, er, brig."") npc(npc, HAPPY_TALKING, ""If you join me I can offer you every opportunity for reward and for fame, or at least infamy."") npc(npc, HAPPY_TALKING, ""Ladies and gentlemen, welcome to your destiny."") npc(npc, HAPPY_TALKING, ""Welcome to the preliminary course, you fine members-in-waiting of the underworld gentry!"") npc(npc, HAPPY_TALKING, ""Here you will discover the techniques, the tricks, the training and the trials that mark your passage into this hidden elite."") npc(npc, HAPPY_TALKING, ""Here you will become the best of the best, joining the ranks of the steely-eyed exploiters of this world's bloated social parasites in a quest for community justice and personal enrichment!"") npc(npc, HAPPY_TALKING, ""You will - Yes, we have a question?"") player(SKEPTICAL_THINKING, ""Is this it? The 'world-renowned' guild is a cellar with two blokes and a straw dummy lurking in it?"") npc(npc, CONFUSED, ""Well..."") player(CONFUSED, ""How long has this guild been in operation?"") npc(npc, CALM, ""..."") player(CONFUSED, ""Yes?"") npc(npc, FRUSTRATED, ""Two weeks."") goto(""options"") } op(""What are you doing down here?"") { player(SKEPTICAL_HEAD_SHAKE, ""What are you doing down here?"") npc(npc,HAPPY_TALKING, ""Why, recruiting! Recruiting agents for a glorious destiny and fantastical missions of derring-do. White suits, classy cocktails, fast carts.. a wealth of rewards await my guild's members!"") npc(npc, SHAKING_HEAD, ""If only I could have convinced Ozan to sign on with us. SSuch a pity.. A master thief like him would have been perfect for my plans."") npc(npc, HAPPY_TALKING, ""Anyway, would you like to stay for the explanation?"") label(""explanationOptions"") options { op(""Do tell."") { player(CONFUSED, ""Don't let me stop you."") npc(npc, HAPPY_TALKING, ""Ladies and gentlemen of Lumbridge!"") npc(npc, HAPPY_TALKING, ""Tonight, I stand before you to offer you the ultimate in opportunities!"") npc(npc, HAPPY_TALKING, ""I offer you the chance to make your mark on a society rife with imbalance and folly."") npc(npc, HAPPY_TALKING, ""I offer you the chance to redistribute the wealth of our very civilization!"") npc(npc, HAPPY_TALKING, ""I offer you the freedom to live your life without the need to worry whether your rent will be paid this month"") npc(npc, HAPPY_TALKING, ""I offer you the skills to pay your way through the costs everyone must face."") npc(npc, HAPPY_TALKING, ""I offer you vengeance against those who take and take yet give nothing in return."") npc(npc, HAPPY_TALKING, ""I offer you justice at its most fundamental level!"") npc(npc, HAPPY_TALKING, ""Some will say that I am a scofflaw, a thief, a brigand... These people are correct!"") npc(npc, HAPPY_TALKING, ""But if I scoff at the law, it is because the law as we know it is a tool that 'The Man' is using purely to keep us in our place."") npc(npc, HAPPY_TALKING, ""If I thieve, it is from those who have more than they deserve and more than they need."") npc(npc, HAPPY_TALKING, ""And if I am a brigand, it is only by the standards of those whom I, er, brig."") npc(npc, HAPPY_TALKING, ""If you join me I can offer you every opportunity for reward and for fame, or at least infamy."") npc(npc, HAPPY_TALKING, ""Ladies and gentlemen, welcome to your destiny."") npc(npc, HAPPY_TALKING, ""Welcome to the preliminary course, you fine members-in-waiting of the underworld gentry!"") npc(npc, HAPPY_TALKING, ""Here you will discover the techniques, the tricks, the training and the trials that mark your passage into this hidden elite."") npc(npc, HAPPY_TALKING, ""Here you will become the best of the best, joining the ranks of the steely-eyed exploiters of this world's bloated social parasites in a quest for community justice and personal enrichment!"") npc(npc, HAPPY_TALKING, ""You will - Yes, we have a question?"") player(SKEPTICAL_THINKING, ""Is this it? The 'world-renowned' guild is a cellar with two blokes and a straw dummy lurking in it?"") npc(npc, CONFUSED, ""Well..."") player(CONFUSED, ""How long has this guild been in operation?"") npc(npc, CALM, ""..."") player(CONFUSED, ""Yes?"") npc(npc, FRUSTRATED, ""Two weeks."") goto(""explanationOptions"") } op(""What is it you need done?"") { player(CALM_TALK, ""And what is it you need done?"") npc(npc, CALM_TALK, ""Here's what we need: Money!"") player(AMAZED_MILD, ""Really? You amaze me."") npc(npc, CALM, ""I know it's hardly the most high-flying goal, but we really need to start somewhere. To be precise, we need to start by expanding this cellar into a headquarters befitting a major player on the global crime stage."") player(SKEPTICAL, ""I take it you have some sort of plan for doing this?"") npc(npc, HAPPY_TALKING, ""Of course I do. In Lumbridge Castle's bank there is a golden chalice of particular workmanship and value. I have found a willing buyer for it, and now it merely remains to collect the item in question."") player(SKEPTICAL, ""From the bank's vault.."") npc(npc, HAPPY_TALKING, ""Correct! And since the vault is not easily breached, we shall need the key from it's owner."") player(CALM_TALK, ""It's owner being?"") npc(npc, HAPPY_TALKING, ""I shall send my right hand man, Robin, to determine that as soon as I may. He shall be around to brief you in the castle ground."") npc(npc, HAPPY_TALKING, ""Then you must merely acquire the key by stealth or by force, open the vault, return the chalice and..."") player(SKEPTICAL_THINKING, ""You seem to be assuming a certain amount here."") npc(npc, HAPPY_TALKING, ""Oh, but of course you'll help! I can offer you the best of training and the greatest of rewards for your assistance.. In fact, Let me have a look at your technique and see what we can do with you."") exec { questStart(Quest.BUYERS_AND_CELLARS) player(CALM_TALK, ""Oh very well!"") { p.setQuestStage(Quest.BUYERS_AND_CELLARS, 1) } npc(npc, HAPPY_TALKING, ""Splendid! Let's get you set up then."") npc(npc, HAPPY_TALKING, ""This is a Mark 1 training dummy."") npc(npc, CALM_TALK, ""It's designed for maximum pocket size and minimum observation skills, which, seeing as it's made of wood, straw, and canvas, was not hard to achieve."") npc(npc, CALM_TALK, ""It will suffice for early training and for testing, but if you have any talent at all it will not be of use to you for long."") npc(npc, CALM, ""Right, I want you to pick the pocket of that dummy as sneakily and delicately as you possibly can."") exec { p.walkToAndExecute(Tile.of(4664, 5903, 0)) { p.actionManager.setAction(PickPocketDummy(GameObject(52316, 1, 4665, 5903, 0))) p.lock() } } } } op(""No, thank you."") { player(SHAKING_HEAD, ""No, thank you."") } } } op(""Sorry, I was just leaving."") { player(CALM, ""Sorry, I was just leaving."") } } } } }" "package com.rs.game.content.quests.buyersandcellars.npcs private const val key = 18647 @ServerStartupEvent fun mapFatherUrhneyBuyersAndCellars() { onNpcClick(458, options = arrayOf(""Pickpocket"")) { (p, npc) -> if (!p.inventory.hasFreeSlots()) { p.sendMessage(""You don't have enough space in your inventory."") } if (!FatherUrhneyBuyersAndCellars.fireIsLit() && p.getQuestStage(Quest.BUYERS_AND_CELLARS) <= 7) { p.sendMessage(""For an old man, he's very alert. You can't get an opportunity to pick his pocket."") } if (FatherUrhneyBuyersAndCellars.fireIsLit() && p.getQuestStage(Quest.BUYERS_AND_CELLARS) == 7) { if (!p.inventory.containsItem(key) && !p.bank.containsItem(key, 1)) { p.faceEntity(npc) WorldTasks.delay(0) { p.anim(881) } p.inventory.addItem(18647) p.sendMessage(""You take advantage of Father Urhney's panic to lift a complex-looking key from his pocket."") p.setQuestStage(Quest.BUYERS_AND_CELLARS, 7) } else { p.sendMessage(""You already have Father Urhney's key."") } } else if (p.getQuestStage(Quest.BUYERS_AND_CELLARS) >= 8) { p.sendMessage(""You've already stolen his key and chalice!"") } } } object FatherUrhneyBuyersAndCellars { private val fireTiles = arrayOf( Tile.of(3205, 3152, 0), Tile.of(3209, 3152, 0), Tile.of(3211, 3150, 0), Tile.of(3211, 3148, 0), Tile.of(3209, 3146, 0), Tile.of(3204, 3146, 0), Tile.of(3202, 3148, 0), Tile.of(3202, 3150, 0) ) fun fireIsLit(): Boolean { return World.getAllObjectsInChunkRange(819593, 5) .filterNotNull() .filter { obj -> obj.definitions?.name == ""Fire"" } .any { obj -> fireTiles.any { fireTile -> fireTile == obj.tile } } } @JvmStatic fun stage4(p: Player, npc: NPC) { p.startConversation { npc(npc, ANGRY, ""Go away! I'm meditating!"") label(""startOptions"") options { op(""Well, that's friendly."") { player(FRUSTRATED, ""Well, that's friendly."") npc(npc, FRUSTRATED, ""I said go away!"") player(CALM_TALK, ""Okay, okay, Sheesh, what a grouch."") } op(""I've come to repossess your house."") { player(CALM_TALK, ""I've come to repossess your house."") npc(npc, SCARED, ""On what grounds?"") options { op(""Repeated failure to make mortgage repayments."") { player(CALM_TALK, ""Repeated failure to make mortgage repayments."") npc(npc, FRUSTRATED, ""What?"") npc(npc, FRUSTRATED, ""But I don't have a mortgage - I built this house myself."") player(CALM, ""Sorry, I must have got the wrong address. All the houses look the same around here."") npc(npc, FRUSTRATED, ""What? What houses? This is the only one. What are you talking about?"") player(CALM, ""Never mind."") goto(""startOptions"") } op(""I don't know, I just wanted this house."") { player(CALM_TALK, ""I don't know, I just wanted this house."") npc(npc, FRUSTRATED, ""Oh, go away and stop wasting my time."") } } } op(""Nice chalice."") { player(CALM_TALK, ""That's a nice chalice."") label(""chaliceOptions"") options { op(""Aren't you afraid it will be taken in lieu of mortgage payments?"") { player(CALM_TALK, ""Aren't you afraid it will be taken in lieu of mortgage payments?"") npc(npc, FRUSTRATED, ""Are you just here to bother me?"") goto(""chaliceOptions"") } op(""The bailiffs are coming! Quick: hide the valuables!"") { player(SCARED, ""The bailiffs are coming! Quick: hide the valuables!"") npc(npc, FRUSTRATED, ""The thoughts I am entertaining about you are worth another three months' mediation, young "" + p.getPronoun(""man"", ""lady"") + ""."") goto(""chaliceOptions"") } op(""Can I have a look at that chalice?"") { player(SKEPTICAL_THINKING, ""Can I have a look at that chalice?"") npc(npc, FRUSTRATED, ""If you must. It's in the display case over there."") player(SKEPTICAL_HEAD_SHAKE, ""I meant...a closer look."") npc(npc, FRUSTRATED, ""It's only a couple of inches from the glass."") player(CALM_TALK, ""Can I hold it?"") npc(npc, ANGRY, ""And get grubby fingermarks over it? I think not."") player(CALM_TALK, ""Hmm. I'll need something more urgent to draw his eye. Perhaps Robin can help"") npc(npc, CALM_TALK, ""What was that?"") player(SKEPTICAL_HEAD_SHAKE, ""Mumble mumble mumble!"") npc(npc, CALM_TALK, ""Quite."") { p.sendMessage(""Perhaps you should ask Robin how best to distract the priest."") p.setQuestStage(Quest.BUYERS_AND_CELLARS, 5) } } op(""Bye, then."") { player(CALM_TALK, ""Bye, then."") npc(npc, FRUSTRATED, ""Bah."") } } } op(""Bye, then."") { player(CALM_TALK, ""Bye, then."") npc(npc, FRUSTRATED, ""Bah."") } } } } @JvmStatic fun stage6(p: Player, npc: NPC) { p.startConversation { npc(npc, ANGRY, ""Go away! I'm meditating!"") label(""startOptions"") options { op(""Well, that's friendly."") { player(FRUSTRATED, ""Well, that's friendly."") npc(npc, FRUSTRATED, ""I said go away!"") player(CALM_TALK, ""Okay, okay, Sheesh, what a grouch."") } op(""I've come to repossess your house."") { player(CALM_TALK, ""I've come to repossess your house."") npc(npc, SCARED, ""On what grounds?"") options { op(""Repeated failure to make mortgage repayments."") { player(CALM_TALK, ""Repeated failure to make mortgage repayments."") npc(npc, FRUSTRATED, ""What?"") npc(npc, FRUSTRATED, ""But I don't have a mortgage - I built this house myself."") player(CALM, ""Sorry, I must have got the wrong address. All the houses look the same around here."") npc(npc, FRUSTRATED, ""What? What houses? This is the only one. What are you talking about?"") player(CALM, ""Never mind."") goto(""startOptions"") } op(""I don't know, I just wanted this house."") { player(CALM_TALK, ""I don't know, I just wanted this house."") npc(npc, FRUSTRATED, ""Oh, go away and stop wasting my time."") } } } if (p.getQuestStage(Quest.BUYERS_AND_CELLARS) == 8) { op(""Nice chalice."") { player(SKEPTICAL_THINKING, ""Nice... um... never mind. Bye!"") } } if (p.getQuestStage(Quest.BUYERS_AND_CELLARS) == 6 || p.getQuestStage(Quest.BUYERS_AND_CELLARS) == 7) { op(""Nice chalice."") { player(CALM_TALK, ""That's a nice chalice."") label(""chaliceOptions"") options { op(""Aren't you afraid it will be taken in lieu of mortgage payments?"") { player(CALM_TALK, ""Aren't you afraid it will be taken in lieu of mortgage payments?"") npc(npc, FRUSTRATED, ""Are you just here to bother me?"") goto(""chaliceOptions"") } op(""The bailiffs are coming! Quick: hide the valuables!"") { player(SCARED, ""The bailiffs are coming! Quick: hide the valuables!"") npc(npc, FRUSTRATED, ""The thoughts I am entertaining about you are worth another three months' mediation, young "" + p.getPronoun(""man"", ""lady"") + ""."") goto(""chaliceOptions"") } op(""Can I have a look at that chalice?"") { player(SKEPTICAL_THINKING, ""Can I have a look at that chalice?"") npc(npc, FRUSTRATED, ""If you must. It's in the display case over there."") player(SKEPTICAL_HEAD_SHAKE, ""I meant...a closer look."") npc(npc, FRUSTRATED, ""It's only a couple of inches from the glass."") player(CALM_TALK, ""Can I hold it?"") npc(npc, ANGRY, ""And get grubby fingermarks over it? I think not."") goto(""chaliceOptions"") } op(""Fire! Fire!"") { player(SCARED, ""Fire! FIRE!"") if (!fireIsLit()) { npc(npc, FRUSTRATED, ""Don't be foolish."") goto(""startOptions"") } else { npc(npc, SCARED, ""Oh, no! My house...that I built with my own two hands!"") player(LAUGH, ""Ha, now's my chance to pick his pocket while he's distracted..."") { p.setQuestStage(Quest.BUYERS_AND_CELLARS, 7) npc.forceTalk(""Accursed kids. Light a fire under my window?! I'll teach them a lesson when I find them..."") } } } } } } op(""Bye, then."") { player(CALM_TALK, ""Bye, then."") npc(npc, FRUSTRATED, ""Bah."") } } } } }" "package com.rs.game.content.quests.buyersandcellars.npcs object RobinCastleKt { fun stage8(p: Player, npc: NPC) { p.startConversation { player(HAPPY_TALKING, ""I stole Father Urhney's chalice!"") if (npc.tile == Tile.of(Tile(4664, 5904, 0))) npc(npc, CALM_TALK, ""You should hand it over to Darren, then."") else npc(npc, CALM_TALK, ""You might want to deliver it to Darren, back at the guild, then."") } } fun stage7(p: Player, npc: NPC) { p.startConversation { player(HAPPY_TALKING, ""I have Father Urhney's key!"") npc(npc, CALM_TALK, ""Then what are you doing here? Nab the chalice from the old man and get back to the guild."") } } fun stage5(p: Player, npc: NPC) { p.startConversation { player(SHAKING_HEAD, ""Father Urhney over in the swamp has the chalice in his hut, but I can't get the key off him."") npc(npc, CALM_TALK, ""You might have to engineer a crisis, then. Don't go setting fire to his house, though! A fire outside his window should do the trick."") player(AMAZED_MILD, ""Is that not highly irresponsible?"") npc(npc, CALM_TALK, ""Normally I'd say yes, but that swamp is so marshy there's little danger of burning his house down and rendering him homeless. There should be some nice damp wood in that swamp."") exec { p.setQuestStage(Quest.BUYERS_AND_CELLARS, 6) } } } fun stage3(p: Player, npc: NPC) { if (npc.tile == Tile.of(4664, 5904, 0)) { someExtraHelp(p, npc) } else p.startConversation { npc(npc, CALM_TALK, ""The purple owl croaks at dawn..."") player(CONFUSED, ""Um, does it?"") npc(npc, CALM_TALK, ""Oh, never mind. I've some information for you."") options { op(""Go ahead."") { player(CALM_TALK, ""Go ahead."") npc(npc, CALM_TALK, ""The chalice is no longer being held by the bank. Seems that the owner withdrew it a couple of days ago and wandered off in the direction of Lumbridge Swamp...a wild-haired old man with a bad temper."") player(CONFUSED, ""Who'd want to live in a swamp?"") npc(npc, CALM_TALK, ""Someone who wants to be left alone, I imagine."") player(CALM_TALK, ""Looks like that's my next stop, anyway."") npc(npc, CALM_TALK, ""No violence, if you please. We're thieves, not muggers, and priests tend to be well in with the gods. Be subtle...if an adventurer can be subtle. See if you can pick his pocket for the key. Good luck."") exec { p.setQuestStage(Quest.BUYERS_AND_CELLARS, 4) } } op(""Not right now."") { player(SHAKING_HEAD, ""Not right now."") } } } } fun someExtraHelp(p: Player, npc: NPC) { p.startConversation { player(CALM_TALK, ""Hello there."") npc(npc, CALM_TALK, ""The Guildmaster wanted me to be on hand in case you needed some more hints on picking pockets. Now, what can I do for you?"") options { op(""I'm always willing to learn."") { player(CALM_TALK, ""I'm always willing to learn."") npc(npc, CALM_TALK, ""When you're on the prowl for pickpocketing targets, it should be fairly obvious who's not paying enough attention to the world around them."") npc(npc, CALM_TALK, ""Just saunter up to them all casual-like, then dip your hand into their wallets as gently and as neatly as you can."") npc(npc, CALM_TALK, ""If you succeed, you'll get some of the contents of their pockets; it not, they'll likely punch you in the face, so be warned."") npc(npc, CALM_TALK, ""It stings, and you'll need a moment to gather your wits."") player(CALM_TALK, ""Thanks, Robin."") npc(npc, CALM_TALK, ""You can use the training dummy if you'd like, but after a while you'll need to switch to real marks if you want to improve."") } op(""I've got it, thanks."") { player(CALM_TALK, ""I’ve got it, thanks."") npc(npc, CALM_TALK, ""You can use the training dummy if you'd like, but after a while you'll need to switch to real marks if you want to improve."") } op(""Any advice for me?"") { player(CALM_TALK, ""Any advice for me? The Guildmaster says you'll be shadowing me on this operation."") npc(npc, CALM_TALK, ""Yes, I'm heading out to the castle shortly to pick up any information that might help you."") player(CALM_TALK, ""Anything I should know?"") npc(npc, CALM_TALK, ""This caper should be simple enough, since your mark won't be on his guard."") npc(npc, CALM_TALK, ""I'll be able to tell you more once I've had a chance to look around, but it should be a matter of finding the chalice's owner, stealing the key, and taking the chalice out of the bank."") player(CALM_TALK, ""See you there, then."") } op(""Bye for now."") { player(CALM_TALK, ""Bye for now."") } } } } fun preQuest(p: Player, npc: NPC) { p.startConversation { player(CALM_TALK, ""Hello there."") npc(npc, CALM_TALK, ""Greetings. I'm Robin, the Guildmaster's assistant. Now, what can I do for you?"") label(""options"") options { op(""That's an appropriate name."") { player(CALM_TALK, ""That's an appropriate name."") npc(npc, CALM_TALK, ""Yes, I've never heard that one before."") npc(npc, CALM_TALK, ""Still, it's not so bad... If I hadn't been mocked for my name as a lad, I might never have decided in a fit of ironic pique to learn how to rob from the rich and give to the poor."") player(CALM_TALK, ""Are you the poor in question?"") npc(npc, CALM_TALK, ""Well, I was."") npc(npc, CALM_TALK, ""Having given myself the goods stolen from several rich people, I'm now of limited but comfortable means."") npc(npc, CALM_TALK, ""Now, what can I do for you?"") goto(""options"") } op(""How long have you known the Guildmaster?"") { player(CALM_TALK, ""How long have you known the Guildmaster?"") npc(npc, CALM_TALK, ""Oh, some time now. We started in business together when he was a con artist, talking people into handing over their hard-earned valuables with lies and vague promises of reward."") npc(npc, SKEPTICAL_HEAD_SHAKE, ""Obviously, that's all behind us now. Now, what can I do for you?"") goto(""options"") } op(""Bye for now."") { player(CALM_TALK, ""Bye for now."") } } } } }" "package com.rs.game.content.quests.clocktower; @PluginEventHandler public class BrotherKojoClockTowerD extends Conversation { private static final int NPC = 223; public BrotherKojoClockTowerD(Player player) { super(player); switch(player.getQuestManager().getStage(Quest.CLOCK_TOWER)) { case NOT_STARTED -> { addPlayer(HeadE.HAPPY_TALKING, ""Hello monk.""); addNPC(NPC, HeadE.CALM_TALK, ""Hello adventurer. My name is Brother Kojo. Do you happen to know the time?""); addPlayer(HeadE.HAPPY_TALKING, ""No, sorry, I don't.""); addNPC(NPC, HeadE.CALM_TALK, ""Exactly! This clock tower has recently broken down, and without it nobody can tell the correct time. I must fix it before the town people become too angry!""); addNPC(NPC, HeadE.CALM_TALK, ""I don't suppose you could assist me in the repairs? I'll pay you for your help.""); addOptions(""Start Clock Tower?"", new Options() { @Override public void create() { option(""Yes"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""OK old monk, what can I do?"", ()-> player.getQuestManager().setStage(Quest.CLOCK_TOWER, REPAIR_CLOCK_TOWER)) .addNPC(NPC, HeadE.CALM_TALK, ""Oh, thank you kind "" + player.getPronoun(""sir"", ""madam"") + ""! In the cellar below, you'll find four cogs. They're too heavy for me, but you should be able to carry them one at a time."") .addNPC(NPC, HeadE.CALM_TALK, ""I know one goes on each floor... but I can't exactly remember which goes where specifically. Oh well, I'm sure you can figure it out fairly easily."") .addPlayer(HeadE.HAPPY_TALKING, ""Well, I'll do my best."") .addNPC(NPC, HeadE.CALM_TALK, ""Thank you again! And remember to be careful, the cellar is full of strange beasts."") ); option(""No"", new Dialogue()); } }); } case REPAIR_CLOCK_TOWER-> { addPlayer(HeadE.HAPPY_TALKING, ""Hello again.""); if(ClockTower.allCogsFinished(player)) { addNPC(NPC, HeadE.CALM_TALK, ""Hello.""); addPlayer(HeadE.HAPPY_TALKING, ""I have replaced all the cogs!""); addNPC(NPC, HeadE.CALM_TALK, ""Really...? Wait, listen! Well done, well done! Yes yes yes, you've done it! You ARE clever!""); addNPC(NPC, HeadE.CALM_TALK, ""The townsfolk will be able to know the correct time now! Thank you so much for all of your help! And as promised, here is your reward!""); addNext(()-> player.getQuestManager().completeQuest(Quest.CLOCK_TOWER)); return; } addNPC(NPC, HeadE.CALM_TALK, ""Oh hello, are you having trouble? The cogs are in four rooms below us. Place one cog on a pole on each of the four tower levels.""); addOptions(""Choose an option:"", new Options() { @Override public void create() { option(""Can I have a hint?"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Can I have a hint?"") .addNPC(NPC, HeadE.CALM_TALK, ""If I knew where the cogs were I wouldn't be asking you. But they are in the basement somewhere."") ); option(""I'll carry on looking."", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""I'll carry on looking."") ); } }); } case QUEST_COMPLETE -> { addPlayer(HeadE.HAPPY_TALKING, ""Hello again Brother Kojo.""); addNPC(NPC, HeadE.CALM_TALK, ""Oh hello there traveller. You've done a grand job with the clock. It's just like new.""); } } } public static NPCClickHandler handleDialogue = new NPCClickHandler(new Object[]{NPC}, e -> e.getPlayer().startConversation(new BrotherKojoClockTowerD(e.getPlayer()).getStart())); }" "package com.rs.game.content.quests.clocktower; @QuestHandler( quest = Quest.CLOCK_TOWER, startText = ""Speak to Brother Kojo in the Clock Tower south of Ardougne."", itemsText = ""Bucket of water or ice gloves"", combatText = ""None."", rewardsText = ""500 coins"", completedStage = ClockTower.QUEST_COMPLETE ) @PluginEventHandler public class ClockTower extends QuestOutline { public final static int NOT_STARTED = 0; public final static int REPAIR_CLOCK_TOWER = 1; public final static int QUEST_COMPLETE = 2; @Override public List getJournalLines(Player player, int stage) { ArrayList lines = new ArrayList<>(); switch (stage) { case NOT_STARTED -> { lines.add(""Help the confused Brother Kojo find the missing cogs and fix his""); lines.add(""Clock Tower. Search the dungeon using brawn and brains to correctly""); lines.add(""place the four cogs.""); lines.add(""""); lines.add(""Talk to Brother Kojo at the Clock Tower, south of Ardougne, to start""); lines.add(""this quest.""); lines.add(""""); } case REPAIR_CLOCK_TOWER -> { lines.add(""I must find all 4 cogs to fix the clocktower. Here are the spindles I""); lines.add(""have fixed:""); for(int id = 20; id <= 23; id++) { String line = ""-"" + new Item(id, 1).getName(); if (player.getQuestManager().getAttribs(Quest.CLOCK_TOWER).getB(new Item(id, 1).getName() + ""Done"")) line = """" + line; lines.add(line); } lines.add(""""); } case QUEST_COMPLETE -> { lines.add(""""); lines.add(""""); lines.add(""QUEST COMPLETE!""); } default -> lines.add(""Invalid quest stage. Report this to an administrator.""); } return lines; } public static boolean allCogsFinished(Player p) { for(int id = 20; id <= 23; id++) if(!p.getQuestManager().getAttribs(Quest.CLOCK_TOWER).getB(new Item(id, 1).getName() + ""Done"")) return false; return true; } @Override public void complete(Player player) { player.sendMessage(""Congratulations! You have completed: 'Clock Tower'.""); player.getInventory().addCoins(500); sendQuestCompleteInterface(player, 6964); } }" "package com.rs.game.content.quests.clocktower; @PluginEventHandler public class ClockTowerDungeon { public static ObjectClickHandler handleGateLever = new ObjectClickHandler(new Object[]{ 37 }, e -> { if(e.getPlayer().getTempAttribs().getB(""ClockTowerGateOpenedRats"") || e.getPlayer().getX() <= 2595) { handleGate(e.getPlayer(), e.getObject()); return; } e.getPlayer().faceWest(); e.getPlayer().startConversation(new Dialogue().addPlayer(HeadE.SKEPTICAL_THINKING, ""Perhaps one of those levers opens this door..."")); e.getPlayer().sendMessage(""The door is shut...""); }); public static ObjectClickHandler handleGateLeverRats = new ObjectClickHandler(new Object[]{ 33 }, Tile.of(2591, 9661, 0), e -> { e.getObject().setIdTemporary(34, Ticks.fromSeconds(20)); e.getPlayer().getTempAttribs().setB(""ClockTowerGateOpenedRats"", true); }); public static ObjectClickHandler handlePoisonedRatDoor = new ObjectClickHandler(new Object[]{ 39 }, e -> { if(e.getPlayer().getX() <= 2578) { handleInPlaceSingleDoor(e.getPlayer(), e.getObject()); return; } if(e.getPlayer().getTempAttribs().getB(""ClockTowerPoisonedRats"")) { handleInPlaceSingleDoor(e.getPlayer(), e.getObject()); e.getPlayer().startConversation(new Dialogue().addSimple(""The death of the rats seemed to shake the door open."")); return; } e.getPlayer().sendMessage(""The door is shut...""); }); public static PickupItemHandler handleBlackCogPickup = new PickupItemHandler(new Object[] { 21 }, Tile.of(2613, 9639, 0), e -> { if(e.getPlayer().getEquipment().getGlovesId() == 1580)//ice gloves return; if(e.getPlayer().getInventory().containsItem(1929, 1)) {//water bucket e.getPlayer().sendMessage(""You cool the cog down in a bucket of water and the water evaporates...""); e.getPlayer().getInventory().replaceItem(1925, 1, e.getPlayer().getInventory().getItems().lookupSlot(1929)); return; } e.getPlayer().startConversation(new Dialogue().addPlayer(HeadE.AMAZED, ""Geez, that is hot!"")); e.getPlayer().sendMessage(""You need something to cool down the cog...""); e.cancelPickup(); }); public static ItemOnObjectHandler handleRatTrap = new ItemOnObjectHandler(new Object[] { 40 }, new Object[] { 24 }, e -> { e.getPlayer().getInventory().removeItems(new Item(24, 1)); e.getPlayer().lock(5); for(NPC npc : World.getNPCsInChunkRange(e.getPlayer().getChunkId(), 1)) if(npc.getId() == 224) { npc.setIgnoreNPCClipping(true); npc.walkToAndExecute(Tile.of(2586, 9655, 0), ()->{ npc.setIgnoreNPCClipping(false); npc.sendDeath(e.getPlayer()); }); } e.getPlayer().getTempAttribs().setB(""ClockTowerPoisonedRats"", true); }); public static ItemOnObjectHandler handleUnusedSpindles = new ItemOnObjectHandler(new Object[] { 25, 26, 27, 28 }, new Object[] { 20, 21, 22, 23 }, e -> e.getPlayer().sendMessage(""The cog doesn't fit..."")); public static ItemOnObjectHandler handleUsedSpindles = new ItemOnObjectHandler(new Object[] { 29, 30, 31, 32 }, new Object[] { 20, 21, 22, 23 }, e -> { if(e.getItem().getId() >= 20 && e.getItem().getId() <= 23) { if(e.getItem().getId() == 23 && e.getObjectId() == 29//red || e.getItem().getId() == 22 && e.getObjectId() == 32//blue || e.getItem().getId() == 21 && e.getObjectId() == 30//black || e.getItem().getId() == 20 && e.getObjectId() == 31) {//white e.getPlayer().getInventory().removeItems(e.getItem()); e.getPlayer().getQuestManager().getAttribs(Quest.CLOCK_TOWER).setB(e.getItem().getName() + ""Done"", true); e.getPlayer().sendMessage(""The cog fits neatly into the spindle...""); return; } e.getPlayer().sendMessage(""The cog doesn't fit...""); return; } e.getPlayer().startConversation(new Dialogue().addPlayer(HeadE.SKEPTICAL_THINKING, ""What use is that?"")); }); }" "package com.rs.game.content.quests.demonslayer; @PluginEventHandler public class CaptainRovinDemonSlayerD extends Conversation { private final int CAPTAIN_ROVIN = 884; public CaptainRovinDemonSlayerD(Player player) { super(player); addNPC(CAPTAIN_ROVIN, HeadE.FRUSTRATED, ""What are you doing up here? Only the palace guards are allowed up here.""); addOptions(""Choose an option:"", new Options() { @Override public void create() { option(""I am one of the palace guards."", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""I am one of the palace guards."") .addNPC(CAPTAIN_ROVIN, HeadE.SKEPTICAL, ""No, you're not! I know all the palace guards."") .addOptions(""Choose an option:"", new Options() { @Override public void create() { option(""I'm a new recruit."", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""I'm a new recruit."") .addNPC(CAPTAIN_ROVIN, HeadE.CALM_TALK, ""I interview all the new recruits. I'd know if you were one of them."") .addPlayer(HeadE.SCARED, ""That blows that story out of the water then."") .addNPC(CAPTAIN_ROVIN, HeadE.ANGRY, ""Get out of my sight."")); option(""I've had extensive plastic surgery."", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""I've had extensive plastic surgery."") .addNPC(CAPTAIN_ROVIN, HeadE.SKEPTICAL, ""What sort of surgery is that? I've never heard of it. Besides, you look reasonably healthy."") .addNPC(CAPTAIN_ROVIN, HeadE.SKEPTICAL, ""Why is this relevant anyway? You still shouldn't be here."")); } })); option(""What about the King?"", new Dialogue() .addPlayer(HeadE.CALM_TALK, ""What about the King?"") .addNPC(CAPTAIN_ROVIN, HeadE.SKEPTICAL_THINKING, ""Well, yes, I suppose we'd let him up. He doesn't generally want to come up here, but if"" + "" he did want to, he could."") .addNPC(CAPTAIN_ROVIN, HeadE.ANGRY, ""Anyway, you're not the King either. So get out of my sight."")); if(!player.isQuestComplete(Quest.DEMON_SLAYER) && player.getQuestManager().getStage(Quest.DEMON_SLAYER) >= DemonSlayer.AFTER_SIR_PRYSIN_INTRO_STAGE && !player.getInventory().containsItem(2400)) option(""Yes I know, but this is important."", new Dialogue() .addPlayer(HeadE.AMAZED_MILD, ""Yes I know, but this is important."") .addNPC(CAPTAIN_ROVIN, HeadE.SKEPTICAL_THINKING, ""Ok, I'm listening. Tell me what's so important."") .addOptions(""Choose an option:"", new Options() { @Override public void create() { option(""There's a demon who wants to invade this city."", new Dialogue() .addPlayer(HeadE.AMAZED, ""There's a demon who wants to invade this city."") .addNPC(CAPTAIN_ROVIN, HeadE.CALM_TALK, ""Is it a powerful demon?"") .addOptions(""Choose an option:"", new Options() { @Override public void create() { option(""Not really."", new Dialogue() .addPlayer(HeadE.CALM, ""Not really."") .addNPC(CAPTAIN_ROVIN, HeadE.CALM_TALK, ""Well, I'm sure the palace guards can deal with it, then. Thanks for the information."")); option(""Yes, very."", new Dialogue() .addPlayer(HeadE.SCARED, ""Yes, very."") .addNPC(CAPTAIN_ROVIN, HeadE.SKEPTICAL_THINKING, ""As good as the palace guards are, I don't know if they're up to taking on "" + ""a very powerful demon."") .addOptions(""Choose an option:"", new Options() { @Override public void create() { option(""Yeah, the palace guards are rubbish!"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Yeah, the palace guards are rubbish!"") .addNPC(CAPTAIN_ROVIN, HeadE.HAPPY_TALKING, ""Yeah, they're--"") .addNPC(CAPTAIN_ROVIN, HeadE.ANGRY, ""Wait! How dare you insult the palace guards? Get out of my sight!"")); option(""It's not them who are going to fight the demon, it's me."", new Dialogue() .addPlayer(HeadE.CALM_TALK, ""It's not them who are going to fight the demon, it's me."") .addNPC(CAPTAIN_ROVIN, HeadE.AMAZED_MILD, ""What, all by yourself? How are you going to do that?"") .addPlayer(HeadE.HAPPY_TALKING, ""I'm going to use the powerful sword Silverlight, which I believe you have one of "" + ""the keys for?"") .addNPC(CAPTAIN_ROVIN, HeadE.SECRETIVE, ""Yes, I do. But why should I give it to you?"") .addNext(()-> player.startConversation(new CaptainRovinDemonSlayerD(player, 0).getStart()))); } })); } })); option(""Erm I forgot."", new Dialogue() .addPlayer(HeadE.SAD_MILD, ""Erm I forgot."") .addNPC(CAPTAIN_ROVIN, HeadE.FRUSTRATED, ""Well it can't be that important then."") .addPlayer(HeadE.AMAZED_MILD, ""How do you know?"") .addNPC(CAPTAIN_ROVIN, HeadE.ANGRY, ""Just go away."")); option(""The castle has just received its ale delivery."", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""The castle has just received its ale delivery."") .addNPC(CAPTAIN_ROVIN, HeadE.LAUGH, ""Now that is important. However I'm the wrong person to speak to about it. Go talk to the "" + ""kitchen staff."")); } })); } }); } public CaptainRovinDemonSlayerD(Player player, int convoID) { super(player); switch(convoID) { case 0: addOptions(""Choose an option"", new Options() { @Override public void create() { option(""Gypsy Aris said I was destined to kill the demon."", new Dialogue() .addPlayer(HeadE.SECRETIVE, ""Gypsy Aris said I was destined to kill the demon."") .addNPC(CAPTAIN_ROVIN, HeadE.SKEPTICAL_HEAD_SHAKE, ""A gypsy? Destiny? I don't believe in that stuff. I got where I am today by hard work, "" + ""not by destiny! Why should I care what that mad old gypsy says?"") .addNext(()-> player.startConversation(new CaptainRovinDemonSlayerD(player, 0).getStart()))); option(""Otherwise the demon will destroy the city!"", new Dialogue() .addPlayer(HeadE.AMAZED, ""Otherwise the demon will destroy the city!"") .addNPC(CAPTAIN_ROVIN, HeadE.ANGRY, "" You can't fool me! How do I know you haven't just made that story up to get my key?"") .addNext(()-> player.startConversation(new CaptainRovinDemonSlayerD(player, 0).getStart()))); option(""Sir Prysin said you would give me the key."", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Sir Prysin said you would give me the key."") .addNPC(CAPTAIN_ROVIN, HeadE.SKEPTICAL_HEAD_SHAKE, ""Oh, he did, did he? Well I don't report to Sir Prysin, I report directly to the king!"") .addNPC(CAPTAIN_ROVIN, HeadE.ANGRY, ""I didn't work my way up through the ranks of the palace guards so I could take orders from an "" + ""ill-bred moron who only has his job because his great- grandfather was a hero with a silly name!"") .addNext(()-> player.startConversation(new CaptainRovinDemonSlayerD(player, 0).getStart()))); option(""Why did he give you one of the keys then?"", new Dialogue() .addPlayer(HeadE.CALM_TALK, ""Why did he give you one of the keys then?"") .addNPC(CAPTAIN_ROVIN, HeadE.HAPPY_TALKING, ""Only because the king ordered him to! The king couldn't get Sir Prysin to part with his "" + ""precious ancestral sword, but he made him lock it up so he couldn't lose it."") .addNPC(CAPTAIN_ROVIN, HeadE.HAPPY_TALKING, ""I got one key and I think some wizard got another. Now what happened to the third one?"") .addPlayer(HeadE.FRUSTRATED, ""Sir Prysin dropped it down a drain!"") .addNPC(CAPTAIN_ROVIN, HeadE.LAUGH, ""Ha ha ha! The idiot!"") .addNPC(CAPTAIN_ROVIN, HeadE.HAPPY_TALKING, ""Okay, I'll give you the key, just so that it's you that kills the demon and not Sir Prysin!"") .addNext(()-> { if(player.getInventory().hasFreeSlots()) { player.getInventory().addItem(2400, 1); player.getPackets().sendGameMessage(""Rovin gives you the key""); } else player.startConversation(new Conversation(player) { { addSimple(""You need an empty space for the key.""); } }); })); } }); break; } } public static NPCClickHandler handleCaptainRovin = new NPCClickHandler(new Object[] { 884 }, e -> e.getPlayer().startConversation(new CaptainRovinDemonSlayerD(e.getPlayer()).getStart())); }" "package com.rs.game.content.quests.demonslayer; @PluginEventHandler public class DelrithBoss extends NPC { Player p; private static final int DELRITH_ID = 879; //Delrith animations static final int STUNNED = 4619; static final int REVIVE = 4620; static final int DIE = 4624; public boolean actuallyDead = false; public DelrithBoss(Tile tile) { super(DELRITH_ID, tile, true); p = World.getPlayersInChunkRange(getChunkId(), 2).getFirst(); } @Override public void sendDeath(Entity source) { setNextAnimation(new Animation(STUNNED)); removeTarget(); WorldTasks.scheduleLooping(new Task() { int tick = 0; final int finalTick = Ticks.fromSeconds(12); boolean conversating = false; @Override public void run() { if(tick == finalTick) setNextAnimation(new Animation(REVIVE)); if(tick == finalTick+1) { resetHP(); setTarget(source); stop(); } if(!conversating && !p.inCombat() && p.withinDistance(Tile.of(getX(), getY(), getPlane()), 2)) { conversating = true; tick = -10; p.faceTile(Tile.of(getX(), getY(), getPlane())); p.startConversation(new EncantationOptionsD(p, DelrithBoss.this).getStart()); } else tick++; } }, 0, 1); } public void die() { if (!p.getControllerManager().isIn(PlayerVSDelrithController.class) || p.isLocked()) return; p.lock(); WorldTasks.scheduleLooping(new Task() { int tick = 0; @Override public void run() { if(tick == 0) { setNextAnimation(new Animation(DIE)); actuallyDead = true; } if(tick == 3) { p.lock(); p.playCutscene(cs -> { cs.setEndTile(Tile.of(3228, 3368, 0)); cs.fadeIn(5); cs.hideMinimap(false); cs.action(() -> { p.getControllerManager().forceStop(); p.tele(Tile.of(3228, 3368, 0)); }); cs.delay(1); cs.fadeOut(5); cs.action(() -> { p.getQuestManager().completeQuest(Quest.DEMON_SLAYER); p.sendMessage(""Congratulations! Quest complete!""); }); }); finish(); stop(); } tick++; } }, 0, 1); } @Override public void handlePreHit(Hit hit) { if (hit.getSource() instanceof Player source) { if (source.getEquipment().getWeaponId() != -1) if (ItemDefinitions.getDefs(source.getEquipment().getWeaponId()).getName().contains(""Silverlight"") || ItemDefinitions.getDefs(source.getEquipment().getWeaponId()).getName().contains(""Darklight"")) super.handlePreHit(hit); else { source.sendMessage(""You need silverlight to damage Delrith.""); hit.setDamage(0); } } } public static NPCInstanceHandler toFunc = new NPCInstanceHandler(DELRITH_ID, (npcId, tile) -> new DelrithBoss(tile)); }" "package com.rs.game.content.quests.demonslayer; @QuestHandler( quest = Quest.DEMON_SLAYER, startText = ""Speak to Aris in the tent on the western side of Varrock Square."", itemsText = ""Bucket of water (can be obtained during the quest)
25 bones (can't be noted, but can be delivered in increments)
1 coin"", combatText = ""The ability to defeat a level 27 demon aided by three level 20 Dark wizards and two level 7 Dark wizards using the Silverlight in melee."", rewardsText = ""Silverlight"", completedStage = 9 ) @PluginEventHandler public class DemonSlayer extends QuestOutline { //stages final static int NOT_STARTED_STAGE = 0; final static int AFTER_GYPSY_ARIS_INTRO_STAGE = 1; final static int AFTER_SIR_PRYSIN_INTRO_STAGE = 2; final static int KEY1_DRAIN_LOCATION_KNOWN_STAGE = 3; final static int KEY2_WIZARD_LOCATION_KNOWN_STAGE = 4; final static int KEY3_ROVIN_LOCATION_KNOWN_STAGE = 5; final static int WIZARD_RITUAL_KNOWN_STAGE = 6; final static int WIZARD_KEY_PREVIOUSLY_RETRIEVED_STAGE = 7; final static int SILVERLIGHT_OBTAINED_STAGE = 8; final static int QUEST_COMPLETE_STAGE = 9; @Override public List getJournalLines(Player player, int stage) { ArrayList lines = new ArrayList<>(); switch (stage) { case NOT_STARTED_STAGE: lines.add(""A mighty demon is being summoned to destroy the city""); lines.add(""of Varrock. You are the one destined to stop him.""); lines.add(""""); lines.add(""I can start this quest by speaking to Gypsy Aris in""); lines.add(""her tent at Varrock square.""); lines.add(""""); lines.add(""I will have to assure her I will try my best to stop""); lines.add(""the demon and complete this quest.""); lines.add(""""); break; case AFTER_GYPSY_ARIS_INTRO_STAGE: lines.add(""Gypsy Aris says Sir Prysin knows where Silverlight""); lines.add(""would be. I can find him in the first floor of Varrock""); lines.add(""castle to the south west.""); lines.add(""""); break; case AFTER_SIR_PRYSIN_INTRO_STAGE: case KEY1_DRAIN_LOCATION_KNOWN_STAGE: case KEY2_WIZARD_LOCATION_KNOWN_STAGE: case KEY3_ROVIN_LOCATION_KNOWN_STAGE: case WIZARD_RITUAL_KNOWN_STAGE: case WIZARD_KEY_PREVIOUSLY_RETRIEVED_STAGE: lines.add(""Sir Prysin says Silverlight was placed in a special""); lines.add(""box. It can only be opened with special keys...""); lines.add(""""); //---Sir Prysin--- if(player.getQuestManager().getAttribs(Quest.DEMON_SLAYER).getB(""KEY1_DRAIN_LOC_KNOWN"")) { lines.add(""Sir Prysin's key is stuck in a drain northeast of the castle""); lines.add(""of Varrock castle. I can use a bucket of water""); lines.add(""to push it into the sewers.""); lines.add(""""); } if(player.getVars().getVarBit(2568) == 1) { lines.add(""The key was pushed into the varrock sewers,""); lines.add(""I just have to find it...""); lines.add(""""); } if(player.getInventory().containsItem(2401)) { lines.add(""I have gotten Sir Prysin's key""); lines.add(""""); } //------ if(player.getQuestManager().getAttribs(Quest.DEMON_SLAYER).getB(""KEY2_WIZARD_LOC_KNOWN"")) { lines.add(""I can speak to Wizard Traiborn in the wizards""); lines.add(""tower to ask about the 2nd key.""); lines.add(""""); } if(player.getQuestManager().getAttribs(Quest.DEMON_SLAYER).getB(""WIZARD_RITUAL_KNOWN"")) { lines.add(""Wizard Traiborn needs 25 unnoted regular bones for""); lines.add(""a ritual to get a silverlight key.""); lines.add(""""); } if(player.getInventory().containsItem(2399)) { lines.add(""I have gotten Wizard Traiborn's key""); lines.add(""""); } if(player.getQuestManager().getAttribs(Quest.DEMON_SLAYER).getB(""KEY3_ROVIN_LOC_KNOWN"")) { lines.add(""I can speak to Roving in the North West tower""); lines.add(""on the 3rd floor for his key.""); lines.add(""""); } if(player.getInventory().containsItem(2400)) { lines.add(""I have gotten Captain Rovin's key""); lines.add(""""); } break; case SILVERLIGHT_OBTAINED_STAGE: lines.add(""I can now fight Delrith at the Dark Wizards altar""); lines.add(""I must bring Silverlight for the scene to occur.""); lines.add(""If I forgot the incantation I can ask Gypsy Aris""); lines.add(""""); break; case QUEST_COMPLETE_STAGE: lines.add(""""); lines.add(""QUEST COMPLETE!""); break; default: lines.add(""Invalid quest stage. Report this to an administrator.""); break; } return lines; } @Override public void complete(Player player) { sendQuestCompleteInterface(player, 2402); } public static ItemOnObjectHandler handleBucketOfWaterOnDrain = new ItemOnObjectHandler(new Object[] { 31759 }, new Object[] { 1929 }, e -> { Player p = e.getPlayer(); if(p.getVars().getVarBit(2568) == 0) { p.getInventory().replace(e.getItem(), new Item(1925, 1)); e.getPlayer().getVars().setVarBit(2568, 1); p.sendMessage(""You pour the liquid down the drain.""); p.playerDialogue(HeadE.WORRIED, ""OK, I think I've washed the key down into the sewer. I'd better go down and get it!""); } }); public static ObjectClickHandler handleDrainSearch = new ObjectClickHandler(new Object[] { 31759 }, e -> { Player p = e.getPlayer(); p.sendMessage(""You peer into the drain.""); if (!p.isQuestComplete(Quest.DEMON_SLAYER) && !p.getInventory().containsItem(2401) && p.getVars().getVarBit(2568) != 1) p.getVars().setVarBit(2568, 0); if (p.getVars().getVarBit(2568) == 0) p.playerDialogue(HeadE.WORRIED, ""It looks like I will need to wash the key down with a bucket of water.""); if (p.getVars().getVarBit(2568) == 1) p.playerDialogue(HeadE.HAPPY_TALKING, ""Okay, time to go in the sewers and get that key...""); if (p.getVars().getVarBit(2568) == 2) p.playerDialogue(HeadE.SKEPTICAL_THINKING, ""Filthy in there...""); }); public static ItemClickHandler handleDarklightQuestRequirement = new ItemClickHandler(new Object[]{6746}, new String[]{""Wield""}, e -> { if (e.getPlayer().isEquipDisabled()) return; if (!e.getPlayer().isQuestComplete(Quest.DEMON_SLAYER)) { e.getPlayer().sendMessage(""You must complete the Demon Slayer quest to use this item...""); return; } Equipment.sendWear(e.getPlayer(), e.getSlotId(), e.getItem().getId()); }); public static ObjectClickHandler handleRustyKey = new ObjectClickHandler(new Object[] { 17431 }, e -> { Player p = e.getPlayer(); p.getInventory().addItem(2401); p.startConversation(new Conversation(p) { { addItem(2401, ""You pick up an old rusty key.""); create(); } }); e.getPlayer().getVars().setVarBit(2568, 2); }); public static EnterChunkHandler handleFinalCutsceneChunk = new EnterChunkHandler(e -> { if (e.getEntity() instanceof Player p && p.hasStarted() && Areas.withinArea(""dark_wizard_altar"", e.getChunkId())) { if(p.getQuestManager().getStage(Quest.DEMON_SLAYER) != SILVERLIGHT_OBTAINED_STAGE || p.getTempAttribs().getB(""FinalDemonSlayerCutscene"") || (!p.getInventory().containsItem(2402) && !p.getEquipment().getWeaponName().equalsIgnoreCase(""Silverlight""))) return; p.getTempAttribs().setB(""FinalDemonSlayerCutscene"", true); p.getControllerManager().startController(new PlayerVSDelrithController()); } }); public static LoginHandler onLogin = new LoginHandler(e -> { if(e.getPlayer().isQuestComplete(Quest.DEMON_SLAYER)) e.getPlayer().getVars().setVarBit(2568, 2); else e.getPlayer().getVars().setVarBit(2568, 0); }); }" "package com.rs.game.content.quests.demonslayer; @PluginEventHandler public class EncantationOptionsD extends Conversation { private final DelrithBoss boss; private int chantCount; private final String[] chantOrder = { ""Aber"", ""Gabindo"", ""Purchai"", ""Camerinthum"", ""Carlem"" }; public EncantationOptionsD(Player player, DelrithBoss boss) { super(player); this.boss = boss; chantCount = 0; addPlayer(HeadE.SKEPTICAL_THINKING, ""Now what was that incantation again?""); addNext(()-> player.startConversation(new EncantationOptionsD(player, boss, chantCount, 0).getStart())); } public EncantationOptionsD(Player player, DelrithBoss boss, int chantCount, int convoID) { super(player); this.player = player; this.boss = boss; this.chantCount = chantCount; switch(convoID) { case 0: chant(); break; default: break; } } private void chant() { addOptions(""Choose an option:"", new Options() { @Override public void create() { option(""Carlem..."", new Dialogue() .addPlayer(HeadE.FRUSTRATED, ""Carlem..."", () -> { player.forceTalk(""Carlem...""); if(chantOrder[chantCount].contains(""Carlem"")) chantCount++; else { chantCount = 0; boss.forceTalk(""Wrong! Ha ha!""); } }) .addNext(()->{ if(chantCount == 5) boss.die(); else player.startConversation(new EncantationOptionsD(player, boss, chantCount, 0).getStart()); })); option(""Aber..."", new Dialogue() .addPlayer(HeadE.FRUSTRATED, ""Aber..."", () -> { player.forceTalk(""Aber...""); if(chantOrder[chantCount].contains(""Aber"")) chantCount++; else { chantCount = 0; boss.forceTalk(""Wrong! Ha ha!""); } }) .addNext(()->{ if(chantCount == 5) boss.die(); else player.startConversation(new EncantationOptionsD(player, boss, chantCount, 0).getStart()); })); option(""Camerinthum..."", new Dialogue() .addPlayer(HeadE.FRUSTRATED, ""Camerinthum..."", () -> { player.forceTalk(""Camerinthum...""); if(chantOrder[chantCount].contains(""Camerinthum"")) chantCount++; else { chantCount = 0; boss.forceTalk(""Wrong! Ha ha!""); } }) .addNext(()->{ if(chantCount == 5) boss.die(); else player.startConversation(new EncantationOptionsD(player, boss, chantCount, 0).getStart()); })); option(""Purchai..."", new Dialogue() .addPlayer(HeadE.FRUSTRATED, ""Purchai..."", () -> { player.forceTalk(""Purchai...""); if(chantOrder[chantCount].contains(""Purchai"")) chantCount++; else { chantCount = 0; boss.forceTalk(""Wrong! Ha ha!""); } }) .addNext(()->{ if(chantCount == 5) boss.die(); else player.startConversation(new EncantationOptionsD(player, boss, chantCount, 0).getStart()); })); option(""Gabindo..."", new Dialogue() .addPlayer(HeadE.FRUSTRATED, ""Gabindo..."", () -> { player.forceTalk(""Gabindo...""); if(chantOrder[chantCount].contains(""Gabindo"")) chantCount++; else { chantCount = 0; boss.forceTalk(""Wrong! Ha ha!""); } }) .addNext(()->{ if(chantCount == 5) boss.die(); else player.startConversation(new EncantationOptionsD(player, boss, chantCount, 0).getStart()); })); } }); } }" "package com.rs.game.content.quests.demonslayer; @PluginEventHandler public class GypsyArisDemonSlayerD extends Conversation { private final int GYPSY_ARIS = 882; public GypsyArisDemonSlayerD(Player player) { super(player); switch (player.getQuestManager().getStage(Quest.DEMON_SLAYER)) { case DemonSlayer.NOT_STARTED_STAGE: if(player.getTempAttribs().getB(""DemonSlayerCutscenePlayed"")) { afterCutsceneConvo(player); break; } addNPC(GYPSY_ARIS, HeadE.CALM_TALK, ""Hello young one.""); addNPC(GYPSY_ARIS, HeadE.CALM_TALK, ""Cross my palm with silver and the future will be revealed to you.""); addOptions(""Cross her palm?"", new Options() { @Override public void create() { option(""Yes."", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Okay, here you go."") .addNPC(GYPSY_ARIS, HeadE.TALKING_ALOT, ""Come closer, and listen carefully to what the future holds for you, as I peer into the "" + ""swirling mists of the crystal ball."") .addNPC(GYPSY_ARIS, HeadE.TALKING_ALOT, ""I can see images forming. I can see you."") .addNPC(GYPSY_ARIS, HeadE.NERVOUS, ""You are holding a very impressive looking sword. I'm sure I recognise that sword..."") .addNPC(GYPSY_ARIS, HeadE.TALKING_ALOT, ""There is a big dark shadow appearing now."") .addNPC(GYPSY_ARIS, HeadE.AMAZED, ""Aaargh!"") .addPlayer(HeadE.SKEPTICAL, ""Are you all right?"") .addNPC(GYPSY_ARIS, HeadE.SCARED, ""It's Delrith! Delrith is coming!"") .addPlayer(HeadE.SKEPTICAL, ""Who's Delrith?"") .addNPC(GYPSY_ARIS, HeadE.TALKING_ALOT, ""Delrith..."") .addNPC(GYPSY_ARIS, HeadE.TALKING_ALOT, ""Delrith is a powerful demon."") .addNPC(GYPSY_ARIS, HeadE.SCARED, ""Oh! I really hope he didn't see me looking at him through my crystal ball!"") .addNPC(GYPSY_ARIS, HeadE.TALKING_ALOT, ""He tried to destroy this city 150 years ago. He was stopped just in time by the great hero Wally."") .addNPC(GYPSY_ARIS, HeadE.TALKING_ALOT, ""Using his magic sword Silverlight, Wally managed to trap the demon in the stone circle just"" + "" south of this city."") .addNPC(GYPSY_ARIS, HeadE.AMAZED, ""Ye gods! Silverlight was the sword you were holding in my vision! You are the one destined to "" + ""stop the demon this time."") .addNext(() -> player.startConversation(new GypsyArisDemonSlayerD(player, 0).getStart()))); option(""No."", new Dialogue() .addPlayer(HeadE.SKEPTICAL, ""No, I don't believe in that stuff"") .addNPC(GYPSY_ARIS, HeadE.CALM_TALK, ""Ok suit yourself."")); } }); break; case DemonSlayer.AFTER_GYPSY_ARIS_INTRO_STAGE: case DemonSlayer.AFTER_SIR_PRYSIN_INTRO_STAGE: case DemonSlayer.KEY1_DRAIN_LOCATION_KNOWN_STAGE: case DemonSlayer.KEY2_WIZARD_LOCATION_KNOWN_STAGE: case DemonSlayer.KEY3_ROVIN_LOCATION_KNOWN_STAGE: case DemonSlayer.SILVERLIGHT_OBTAINED_STAGE: addNPC(GYPSY_ARIS, HeadE.HAPPY_TALKING, ""Greetings. How goes thy quest?""); addPlayer(HeadE.WORRIED, ""I'm still working on it.""); addNPC(GYPSY_ARIS, HeadE.HAPPY_TALKING, ""Well if you need any advice I'm always here, young one.""); afterQuestStartConvo(player); break; case DemonSlayer.QUEST_COMPLETE_STAGE: addNPC(GYPSY_ARIS, HeadE.HAPPY_TALKING, ""Thank you for saving us from that demon.""); break; } } public GypsyArisDemonSlayerD(Player player, int convoID) { super(player); switch(convoID) { case 0: introductoryOptions(player); break; case 1: afterCutsceneConvo(player); break; case 2: afterQuestStartConvo(player); break; } } private void introductoryOptions(Player p) { addOptions(""Choose an option:"", new Options() { @Override public void create() { option(""How am I meant to fight a demon who can destroy cities?"", new Dialogue() .addPlayer(HeadE.SCARED, ""How am I meant to fight a demon who can destroy cities?!"") .addNPC(GYPSY_ARIS, HeadE.TALKING_ALOT, ""If you face Delrith while he is still weak from being summoned, and use the correct weapon, you will "" + ""not find the task too arduous."") .addNPC(GYPSY_ARIS, HeadE.TALKING_ALOT, ""Do not fear. If you follow the path of the great hero Wally, then you are sure to defeat the demon."") .addNext(() -> p.startConversation(new GypsyArisDemonSlayerD(p, 0).getStart()))); option(""Okay, where is he? I'll kill him for you!"", new Dialogue() .addPlayer(HeadE.ANGRY, ""Okay, where is he? I'll kill him for you!"") .addNPC(GYPSY_ARIS, HeadE.HAPPY_TALKING, ""Ah, the overconfidence of the young!"") .addNPC(GYPSY_ARIS, HeadE.HAPPY_TALKING, ""Delrith can't be harmed by ordinary weapons. You must face him using the same weapon that Wally used."") .addNext(() -> p.startConversation(new GypsyArisDemonSlayerD(p, 0).getStart()))); if(p.getTempAttribs().getB(""DemonSlayerCutscenePlayed"")) { option(""What is the magical incantation?"", new Dialogue() .addPlayer(HeadE.WORRIED, ""What is the magical incantation?"") .addNPC(GYPSY_ARIS, HeadE.SKEPTICAL_THINKING, ""Oh yes, let me think a second..."") .addNPC(GYPSY_ARIS, HeadE.HAPPY_TALKING, ""Alright, I think I've got it now, it goes Aber... Gabindo... Purchai... Camerinthum... and Carlem..."" + "" Have you got that?"") .addPlayer(HeadE.HAPPY_TALKING, ""I think so, yes."") .addNext(() -> p.startConversation(new GypsyArisDemonSlayerD(p, 0).getStart()))); option(""Where can I find Silverlight?"", new Dialogue() .addPlayer(HeadE.SKEPTICAL_THINKING, ""Where can I find Silverlight?"") .addNPC(GYPSY_ARIS, HeadE.TALKING_ALOT, ""Silverlight has been passed down through Wally's descendants. I believe it is currently in the"" + "" care of one of the King's knights called Sir Prysin."") .addNPC(GYPSY_ARIS, HeadE.TALKING_ALOT, ""He shouldn't be too hard to find. He lives in the royal palace in this city. Tell him Gypsy "" + ""Aris sent you."") .addNext(() -> p.startConversation(new GypsyArisDemonSlayerD(p, 0).getStart()))); option(""Okay, thanks. I'll do my best to stop the demon."", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Ok thanks. I'll do my best to stop the demon."") .addNPC(GYPSY_ARIS, HeadE.HAPPY_TALKING, ""Good luck, and may Guthix be with you!"") .addNext(()-> p.getQuestManager().setStage(Quest.DEMON_SLAYER, DemonSlayer.AFTER_GYPSY_ARIS_INTRO_STAGE))); } else { option(""Wally doesn't sound like a very heroic name."", new Dialogue() .addPlayer(HeadE.SKEPTICAL, ""Wally doesn't sound a very heroic name."") .addNPC(GYPSY_ARIS, HeadE.CALM_TALK, ""Yes I know. Maybe that is why history doesn't remember him. However he was a very great hero."") .addNPC(GYPSY_ARIS, HeadE.CALM_TALK, ""Who knows how much pain and suffering Delrith would have brought forth without Wally to stop him!"") .addNPC(GYPSY_ARIS, HeadE.CALM_TALK, ""It looks like you are going to need to perform similar heroics."") .addNext(() -> p.startConversation(new GypsyArisDemonSlayerD(p, 0).getStart()))); option(""So how did Wally kill Delrith?"", new Dialogue() .addPlayer(HeadE.AMAZED_MILD, ""So how did Wally kill Delrith?"") .addNext(() -> p.playCutscene(new WallyVSDelrithCutscene()))); } } }); } private void afterCutsceneConvo(Player p) { addNPC(GYPSY_ARIS, HeadE.SCARED, ""Delrith will come forth from the stone circle again.""); addNPC(GYPSY_ARIS, HeadE.SCARED, ""I would imagine an evil sorcerer is already starting on the rituals to summon Delrith as we speak.""); introductoryOptions(p); } private void afterQuestStartConvo(Player p) { addOptions(""Choose an option:"", new Options() { @Override public void create() { option(""What is the magical incantation?"", new Dialogue() .addPlayer(HeadE.CALM_TALK, ""What is the magical incantation?"") .addNPC(GYPSY_ARIS, HeadE.SKEPTICAL_THINKING, ""Oh yes, let me think a second..."") .addNPC(GYPSY_ARIS, HeadE.HAPPY_TALKING, ""Alright, I think I've got it now, it goes Aber... Gabindo... Purchai... Camerinthum... and Carlem..."" + "" Have you got that?"") .addPlayer(HeadE.HAPPY_TALKING, ""I think so, yes."") .addNext(() -> p.startConversation(new GypsyArisDemonSlayerD(p, 2).getStart()))); option(""Where can I find the Silverlight?"", new Dialogue() .addPlayer(HeadE.CALM_TALK, ""Where can I find the Silverlight?"") .addNPC(GYPSY_ARIS, HeadE.TALKING_ALOT, ""Silverlight has been passed down through Wally's descendants. I believe it is currently in the"" + "" care of one of the King's knights called Sir Prysin."") .addNPC(GYPSY_ARIS, HeadE.TALKING_ALOT, ""He shouldn't be too hard to find. He lives in the royal palace in this city. Tell him Gypsy "" + ""Aris sent you."") .addNext(() -> p.startConversation(new GypsyArisDemonSlayerD(p, 2).getStart()))); option(""Stop calling me that!"", new Dialogue() .addPlayer(HeadE.ANGRY, ""Stop calling me that!"") .addNPC(GYPSY_ARIS, HeadE.WORRIED, ""In the scheme of things you are very young."") .addOptions(""Choose an option:"", new Options() { @Override public void create() { option(""Ok but how old are you?"", new Dialogue() .addPlayer(HeadE.ANGRY, ""Ok but how old are you?"") .addNPC(GYPSY_ARIS, HeadE.HAPPY_TALKING, ""Count the number of legs on the stools in the Blue Moon inn, and multiply that "" + ""number by seven."") .addPlayer(HeadE.SKEPTICAL_THINKING, ""Er, yeah, whatever."")); option(""Oh if it's in the scheme of things that's ok."", new Dialogue() .addPlayer(HeadE.CALM_TALK, ""Oh if it's in the scheme of things that's ok."") .addNPC(GYPSY_ARIS, HeadE.HAPPY_TALKING, ""You show wisdom for one so young."")); } })); option(""Well I'd better press on with it."", new Dialogue() .addPlayer(HeadE.CALM_TALK, ""Well I'd better press on with it."") .addNPC(GYPSY_ARIS, HeadE.HAPPY_TALKING, ""See you soon."")); } }); } public static NPCClickHandler handleGypsyAris = new NPCClickHandler(new Object[] { 882 }, e -> e.getPlayer().startConversation(new GypsyArisDemonSlayerD(e.getPlayer()).getStart())); }" "package com.rs.game.content.quests.demonslayer; public class PlayerVSDelrithController extends InstancedController { private static final Tile LOCATION_ON_DEATH = Tile.of(3211, 3382, 0); static final int DELRITH = 879; static final int DARK_WIZARD7 = 8872; static final int DARK_WIZARD20 = 8873; static final int DENATH = 4663; // Wizard spell animations static final int SPELL1 = 707; static final int SPELL2 = 718; static final int SPELL3 = 717; static final int SPELL4 = 711; // Delrith animation static final int RESURRECT = 4623; boolean ambientMusicOn = false; public PlayerVSDelrithController() { super(Instance.of(LOCATION_ON_DEATH, 4, 4).setEntranceOffset(new int[] { 19, 17, 0 })); } @Override public Genre getGenre() { return Music.getGenreByName(""Other Dungeons""); } @Override public boolean playAmbientOnControllerRegionEnter() { return false; } @Override public boolean playAmbientMusic() { return ambientMusicOn; } @Override public void onBuildInstance() { int spawnX = 19, spawnY = 17; int endX = 15, endY = 20; player.lock(); getInstance().copyMapAllPlanes(401, 419).thenAccept(b -> player.playCutscene(cs -> { cs.fadeIn(5); cs.action(() -> { getInstance().teleportLocal(player, spawnX, spawnY, 0); player.musicTrack(195); player.getPackets().setBlockMinimapState(2); player.getAppearance().setHidden(true); player.getAppearance().getAppeareanceData(); cs.setEndTile(Tile.of(cs.getX(endX), cs.getY(endY), 0)); }); cs.delay(1); cs.camPos(spawnX-4, spawnY+6, 2000); cs.camLook(spawnX, spawnY, 50); cs.delay(1); cs.camPos(spawnX, spawnY+6, 2000, 0, 5); cs.npcCreate(""w1"", DARK_WIZARD7, spawnX-1, spawnY+2, 0); cs.npcCreate(""w2"", DARK_WIZARD20, spawnX+2, spawnY+2, 0); cs.npcCreate(""w3"", DARK_WIZARD20, spawnX-1, spawnY-1, 0); cs.npcCreate(""denath"", DENATH, spawnX+2, spawnY-1, 0); cs.action(() -> Stream.of(""w1"", ""w2"", ""w3"", ""denath"").forEach(label -> { if (!label.equals(""denath"")) cs.getNPC(label).persistBeyondCutscene(); cs.getNPC(label).setRandomWalk(false); cs.getNPC(label).faceTile(Tile.of(cs.getX(spawnX), cs.getY(spawnY), 0)); })); cs.fadeOut(3); cs.dialogue(new Dialogue().addNPC(DENATH, HeadE.EVIL_LAUGH, ""Arise, O mighty Delrith! Bring destruction to this soft weak city!"")); cs.action(1, () -> Stream.of(""w1"", ""w2"", ""w3"", ""denath"").forEach(label -> cs.getNPC(label).anim(SPELL1))); cs.action(1, () -> Stream.of(""w1"", ""w2"", ""w3"", ""denath"").forEach(label -> cs.getNPC(label).anim(SPELL2))); cs.dialogue(new Dialogue().addNPC(DARK_WIZARD7, HeadE.EVIL_LAUGH, ""Arise Delrith!"")); cs.action(1, () -> Stream.of(""w1"", ""w2"", ""w3"", ""denath"").forEach(label -> { cs.getNPC(label).anim(SPELL1); cs.getNPC(label).forceTalk(""Arise Delrith!""); })); cs.action(1, () -> Stream.of(""w1"", ""w2"", ""w3"", ""denath"").forEach(label -> cs.getNPC(label).anim(SPELL3))); cs.dialogue(new Dialogue().addSimple(""The wizards cast an evil spell...""), 1); cs.camPos(spawnX, spawnY-4, 1500); cs.camLook(spawnX, spawnY+1, 50); cs.camShake(3, 100, 1, 30, 1); cs.npcCreate(""delrith"", DELRITH, Tile.of(cs.getX(spawnX), cs.getY(spawnY), 0)); cs.npcFaceDir(""delrith"", Direction.SOUTHEAST); cs.npcAnim(""delrith"", RESURRECT); cs.action(() -> { cs.getNPC(""delrith"").persistBeyondCutscene(); cs.getNPC(""delrith"").setRandomWalk(false); }); cs.delay(1); cs.npcTalk(""delrith"", ""RaawRRgh!""); Stream.of(""w1"", ""w2"", ""w3"", ""denath"").forEach(label -> { cs.npcSpotAnim(label, 108); cs.npcAnim(label, SPELL4); }); cs.delay(1); cs.action(() -> player.getVars().setVarBit(2569, 1)); cs.camShake(3, 0, 0, 0, 0); cs.camLook(spawnX, spawnY+10, 250, 0, 1); cs.delay(1); cs.npcWalk(""delrith"", spawnX, spawnY-2); cs.delay(1); cs.camPos(spawnX-4, spawnY+6, 2000); cs.camLook(spawnX, spawnY-1, 50); cs.delay(1); Stream.of(""w1"", ""w2"", ""w3"", ""denath"").forEach(label -> cs.npcFaceNPC(label, ""delrith"")); cs.dialogue(new Dialogue() .addNPC(DENATH, HeadE.EVIL_LAUGH, ""Ha ha ha! At last you are free, my demonic brother! Rest now and then have your revenge on this pitiful city!"") .addNPC(DENATH, HeadE.EVIL_LAUGH, ""We will destroy-""), true); Stream.of(""w1"", ""w2"", ""w3"", ""denath"", ""delrith"").forEach(label -> cs.npcFaceNPC(label, null)); Stream.of(""w1"", ""w2"", ""w3"", ""denath"", ""delrith"").forEach(label -> cs.npcFaceDir(label, Direction.NORTHWEST)); cs.dialogue(new Dialogue() .addNPC(DENATH, HeadE.SCARED, ""Noo! Not Silverlight! Delrith is not ready yet!"") .addNPC(DENATH, HeadE.SCARED, ""I've got to get out of here.""), true); cs.npcFaceNPC(""denath"", null); cs.npcWalk(""denath"", spawnX+13, spawnY-1); cs.playerMove(endX, endY, Entity.MoveType.TELE); cs.delay(2); cs.playerFaceDir(Direction.SOUTHEAST); cs.delay(2); cs.camPosReset(); cs.action(() -> { player.getAppearance().setHidden(false); player.getAppearance().getAppeareanceData(); }); cs.action(() -> { ambientMusicOn = true; player.unlock(); player.setForceMultiArea(true); Stream.of(""w1"", ""w2"", ""w3"").forEach(label -> { cs.getNPC(label).setRandomWalk(true); cs.getNPC(label).setForceMultiArea(true); cs.getNPC(label).setForceAggroDistance(20); cs.getNPC(label).setTarget(player); }); cs.getNPC(""delrith"").setRandomWalk(true); cs.getNPC(""delrith"").setForceMultiArea(true); cs.getNPC(""delrith"").setForceAggroDistance(20); cs.getNPC(""delrith"").setTarget(player); }); })); } @Override public void onDestroyInstance() { player.getPackets().setBlockMinimapState(0); player.setForceMultiArea(false); player.getTempAttribs().setB(""FinalDemonSlayerCutscene"", false); player.unlock(); } @Override public boolean sendDeath() { player.stopAll(); player.reset(); player.sendMessage(""You have been defeated!""); Magic.sendNormalTeleportSpell(player, LOCATION_ON_DEATH); player.getVars().setVarBit(2569, 0); return false; } }" "package com.rs.game.content.quests.demonslayer; @PluginEventHandler public class SirPrysinDemonSlayerD extends Conversation { private final int SIR_PRYSIN = 883; private final int SIR_PRYSIN_W_SWORD = 4657; private final int ASK_ABOUT_SILVERLIGHT = 0; private final int ASK_ABOUT_KEYS_OPTIONS = 1; private final int GIVE_KEYS_DIALOGUE = 2; private final int KEY_LOCATIONS_OPTIONS = 4; private final int SILVERLIGHT_CUTSCENE = 5; public SirPrysinDemonSlayerD(Player player) { super(player); if(player.getQuestManager().getStage(Quest.DEMON_SLAYER) >= DemonSlayer.SILVERLIGHT_OBTAINED_STAGE) { addNPC(SIR_PRYSIN, HeadE.HAPPY_TALKING, ""Hello again!""); addNext(() -> player.startConversation(new SirPrysinDemonSlayerD(player, SILVERLIGHT_CUTSCENE).getStart())); return; } if(player.getQuestManager().getAttribs(Quest.DEMON_SLAYER).getB(""AFTER_PRYSIN_INTRO"")) { if(hasAllKeys(player)) { addNPC(SIR_PRYSIN, HeadE.HAPPY_TALKING, ""Hello again!""); addNext(() -> player.startConversation(new SirPrysinDemonSlayerD(player, SILVERLIGHT_CUTSCENE).getStart())); } else { addNPC(SIR_PRYSIN, HeadE.HAPPY_TALKING, ""Hello again.""); addNext(() -> player.startConversation(new SirPrysinDemonSlayerD(player, KEY_LOCATIONS_OPTIONS).getStart())); } } else { addNPC(SIR_PRYSIN, HeadE.HAPPY_TALKING, ""Hello, who are you?""); addOptions(""Choose an option:"", new Options() { @Override public void create() { option(""I am a mighty adventurer. Who are you?"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""I am a mighty adventurer. Who are you?"") .addNPC(SIR_PRYSIN, HeadE.HAPPY_TALKING, ""I am Sir Prysin. A bold and famous knight of the realm."")); option(""I'm not sure, I was hoping you could tell me."", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""I'm not sure, I was hoping you could tell me."") .addNPC(SIR_PRYSIN, HeadE.SKEPTICAL, ""Well I've never met you before."")); if(player.getQuestManager().getStage(Quest.DEMON_SLAYER) == DemonSlayer.AFTER_GYPSY_ARIS_INTRO_STAGE) option(""Gypsy Aris said I should come and talk to you."", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Gypsy Aris said I should come and talk to you."") .addNPC(SIR_PRYSIN, HeadE.AMAZED_MILD, ""Gypsy Aris? Is she still alive? I remember her from when I was pretty young. Well what do you "" + ""need to talk to me about?"") .addOptions(""Choose an option:"", new Options() { @Override public void create() { option(""I need to find Silverlight."", new Dialogue() .addNext(() -> player.startConversation(new SirPrysinDemonSlayerD(player, ASK_ABOUT_SILVERLIGHT).getStart()))); option(""Yes, she is still alive."", new Dialogue() .addPlayer(HeadE.CALM_TALK, ""Yes she is still alive. She lives right outside the castle!"") .addNPC(SIR_PRYSIN, HeadE.AMAZED_MILD, ""Oh, is that the same gypsy? I would have thought she would have died by now. She was "" + ""pretty old when I was a lad."") .addNPC(SIR_PRYSIN, HeadE.CALM_TALK, ""Anyway, what can I do for you?"") .addNext(() -> player.startConversation(new SirPrysinDemonSlayerD(player, ASK_ABOUT_SILVERLIGHT).getStart()))); } })); } }); } } public SirPrysinDemonSlayerD(Player player, int convoID) { super(player); this.player = player; final int KEY_OPTIONS = 3; switch(convoID) { case ASK_ABOUT_SILVERLIGHT: askAboutSilverlight(player); break; case ASK_ABOUT_KEYS_OPTIONS: askingAboutGivingKeyOptions(player); break; case GIVE_KEYS_DIALOGUE: soGiveKeysDialogue(player); break; case KEY_OPTIONS: askingAboutGivingKeyOptions(player); break; case KEY_LOCATIONS_OPTIONS: keyLocationsOptions(player); break; case SILVERLIGHT_CUTSCENE: silverLightCutscene(player); break; } } private void askAboutSilverlight(Player p) { addPlayer(HeadE.TALKING_ALOT, ""I need to find Silverlight.""); addNPC(SIR_PRYSIN, HeadE.SKEPTICAL, ""What do you need to find that for?""); addPlayer(HeadE.TALKING_ALOT, ""I need it to fight Delrith.""); addNPC(SIR_PRYSIN, HeadE.SKEPTICAL_THINKING, ""Delrith? I thought the world was rid of him, thanks to my great-grandfather.""); addOptions(""Choose an option:"", new Options() { @Override public void create() { option(""Well, the gypsy's crystal ball seems to think otherwise."", new Dialogue() .addPlayer(HeadE.TALKING_ALOT, ""Well, the gypsy's crystal ball seems to think otherwise."") .addNPC(SIR_PRYSIN, HeadE.AMAZED_MILD, ""Well if the ball says so, I'd better help you."") .addNPC(SIR_PRYSIN, HeadE.SKEPTICAL_THINKING, ""The problem is getting Silverlight."") .addPlayer(HeadE.AMAZED_MILD, ""You mean you don't have it?"") .addNPC(SIR_PRYSIN, HeadE.NERVOUS, ""Oh I do have it, but it is so powerful that the king made me put it in a special box which "" + ""needs three different keys to open it. That way it won't fall into the wrong hands."") .addNext(() -> p.startConversation(new SirPrysinDemonSlayerD(p, ASK_ABOUT_KEYS_OPTIONS).getStart()))); option(""He's back and unfortunately I've got to deal with him."", new Dialogue() .addPlayer(HeadE.AMAZED_MILD, ""He's back and unfortunately I've got to deal with him."") .addNPC(SIR_PRYSIN, HeadE.CALM_TALK, ""You don't look up to much. I suppose Silverlight may be good enough to carry you through though."") .addNPC(SIR_PRYSIN, HeadE.CALM_TALK, ""The problem is getting Silverlight."") .addPlayer(HeadE.WORRIED, ""You mean you don't have it?"") .addNPC(SIR_PRYSIN, HeadE.NERVOUS, ""Oh I do have it, but it is so powerful that the king made me put it in a special box which "" + ""needs three different keys to open it. That way it won't fall into the wrong hands."") .addNext(() -> p.startConversation(new SirPrysinDemonSlayerD(p, ASK_ABOUT_KEYS_OPTIONS).getStart()))); } }); } private void soGiveKeysDialogue(Player p) { addNPC(SIR_PRYSIN, HeadE.NERVOUS, ""Um, well, it's not so easy""); addNPC(SIR_PRYSIN, HeadE.NERVOUS, ""I kept one of the keys. I gave the other two to other people for safe keeping.""); addNPC(SIR_PRYSIN, HeadE.NERVOUS, ""One I gave to Rovin, the captain of the palace guard.""); addNPC(SIR_PRYSIN, HeadE.NERVOUS, ""I gave the other to the wizard Traiborn.""); addNext(() -> { p.getQuestManager().getAttribs(Quest.DEMON_SLAYER).setB(""AFTER_PRYSIN_INTRO"", true); p.getQuestManager().setStage(Quest.DEMON_SLAYER, DemonSlayer.AFTER_SIR_PRYSIN_INTRO_STAGE); p.startConversation(new SirPrysinDemonSlayerD(p, KEY_LOCATIONS_OPTIONS).getStart()); }); } private void askingAboutGivingKeyOptions(Player p) { addOptions(""Choose an option"", new Options() { @Override public void create() { option(""So give me the keys!"", new Dialogue() .addPlayer(HeadE.AMAZED_MILD, ""So give me the keys!"") .addNext(() -> p.startConversation(new SirPrysinDemonSlayerD(p, GIVE_KEYS_DIALOGUE).getStart()))); option(""And why is this a problem?"", new Dialogue() .addPlayer(HeadE.FRUSTRATED, ""And why is this a problem?"") .addNext(() -> p.startConversation(new SirPrysinDemonSlayerD(p, GIVE_KEYS_DIALOGUE).getStart()))); } }); } private void keyLocationsOptions(Player p) { addOptions(""Choose an option:"", new Options() { @Override public void create() { option(""Can you give me your key?"", new Dialogue() .addPlayer(HeadE.SECRETIVE, ""Can you give me your key?"") .addNPC(SIR_PRYSIN, HeadE.WORRIED, ""Um.... ah...."") .addNPC(SIR_PRYSIN, HeadE.SAD_MILD_LOOK_DOWN, ""Well there's a problem there as well."") .addNPC(SIR_PRYSIN, HeadE.SAD_MILD_LOOK_DOWN, ""I managed to drop the key in the drain just outside the palace kitchen. "" + ""It is just inside and I can't reach it."", ()-> p.getQuestManager().getAttribs(Quest.DEMON_SLAYER).setB(""KEY1_DRAIN_LOC_KNOWN"", true)) .addNext(()-> p.startConversation(new SirPrysinDemonSlayerD(p, KEY_LOCATIONS_OPTIONS).getStart()))); option(""Where can I find Captain Rovin?"", new Dialogue() .addPlayer(HeadE.CALM_TALK, ""Where can I find Captain Rovin?"") .addNPC(SIR_PRYSIN, HeadE.HAPPY_TALKING, ""Captain Rovin lives at the top of the guards' quarters in the north-west wing of this"" + "" palace."", ()-> p.getQuestManager().getAttribs(Quest.DEMON_SLAYER).setB(""KEY3_ROVIN_LOC_KNOWN"", true)) .addNext(()-> p.startConversation(new SirPrysinDemonSlayerD(p, KEY_LOCATIONS_OPTIONS).getStart()))); option(""Where does the wizard live?"", new Dialogue() .addPlayer(HeadE.CALM_TALK, ""Where does the wizard live?"") .addNPC(SIR_PRYSIN, HeadE.HAPPY_TALKING, ""Wizard Traiborn?"") .addNPC(SIR_PRYSIN, HeadE.HAPPY_TALKING, ""He is one of the wizards who lives in the tower on the little island just off the south coast. "" + ""I believe his quarters are on the third floor of the tower."", ()-> p.getQuestManager().getAttribs(Quest.DEMON_SLAYER).setB(""KEY2_WIZARD_LOC_KNOWN"", true)) .addNext(()-> p.startConversation(new SirPrysinDemonSlayerD(p, KEY_LOCATIONS_OPTIONS).getStart()))); if(p.getQuestManager().getAttribs(Quest.DEMON_SLAYER).getB(""KEY1_DRAIN_LOC_KNOWN"")) option(""So what does the drain lead to?"", new Dialogue() .addPlayer(HeadE.SKEPTICAL_THINKING, ""So what does the drain connect to?"") .addNPC(SIR_PRYSIN, HeadE.CALM_TALK, ""It is the drain for the drainpipe running from the sink in the kitchen down to the palace sewers."") .addNext(()-> p.startConversation(new SirPrysinDemonSlayerD(p, KEY_LOCATIONS_OPTIONS).getStart()))); option(""Farewell."", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Well I'd better go key hunting."") .addNPC(SIR_PRYSIN, HeadE.HAPPY_TALKING, ""Ok, goodbye."")); } }); } private boolean hasAllKeys(Player p) { Inventory inv = p.getInventory(); return inv.containsItem(2400) && inv.containsItem(2399) && inv.containsItem(2401); } private void silverLightCutscene(Player p) { if(p.getInventory().containsItem(2402)) { addNPC(SIR_PRYSIN, HeadE.HAPPY_TALKING, ""Silverlight looks good on you...""); addPlayer(HeadE.HAPPY_TALKING, ""I guess it does""); return; } if(p.getQuestManager().getStage(Quest.DEMON_SLAYER) >= DemonSlayer.SILVERLIGHT_OBTAINED_STAGE) { addPlayer(HeadE.SAD_MILD, ""I lost Silverlight""); if(!p.getInventory().hasFreeSlots()) { addNPC(SIR_PRYSIN, HeadE.HAPPY_TALKING, ""Good thing I found Silverlight again.""); addNPC(SIR_PRYSIN, HeadE.HAPPY_TALKING, ""You will need space in your inventory though.""); addPlayer(HeadE.FRUSTRATED, ""Oh, good thing you found it. I will make room.""); return; } addNPC(SIR_PRYSIN, HeadE.HAPPY_TALKING, ""Good thing I found Silverlight again."", ()-> cutscene(p)); addNPC(SIR_PRYSIN, HeadE.HAPPY_TALKING, ""That sword belonged to my great-grandfather. Make sure you treat it with respect!""); return; } //first time reaching this function without silverlightin inventory addPlayer(HeadE.HAPPY_TALKING, ""I've got all three keys!""); addNPC(SIR_PRYSIN, HeadE.HAPPY_TALKING, ""Excellent! Now I can give you Silverlight."", ()-> cutscene(p)); addNPC(SIR_PRYSIN, HeadE.HAPPY_TALKING, ""That sword belonged to my great-grandfather. Make sure you treat it with respect!""); addNPC(SIR_PRYSIN, HeadE.HAPPY_TALKING, ""Now go kill that demon!""); } private void cutscene(Player p) { for(NPC npc : World.getNPCsInChunkRange(p.getChunkId(), 2)) if(npc.getId() == SIR_PRYSIN) { npc.setHidden(true); NPC dummy = World.spawnNPC(SIR_PRYSIN, Tile.of(3204, 3470, 0), -1, false, true); dummy.setRandomWalk(false); dummy.faceTile(Tile.of(3204, 3469, 0)); WorldTasks.scheduleLooping(new Task() { int tick; Tile playerTile; @Override public void run() { if (tick == 0) { p.lock(); playerTile = p.getTile(); p.tele(Tile.of(3204, 3471, 0)); p.faceEntity(dummy); } else if (tick == 1) { dummy.setNextAnimation(new Animation(2579)); p.getVars().setVarBit(6922, 1); } else if(tick == 2) { dummy.setNextAnimation(new Animation(4611)); p.getVars().setVarBit(6922, 2); } else if(tick == 3) { dummy.setNextAnimation(new Animation(2579)); p.getVars().setVarBit(6922, 0); dummy.transformIntoNPC(SIR_PRYSIN_W_SWORD); } else if(tick == 4) dummy.faceEntity(p); else if(tick == 5) dummy.setNextAnimation(new Animation(15953)); else if(tick == 6) { dummy.transformIntoNPC(SIR_PRYSIN); p.setNextAnimation(new Animation(15952)); p.getInventory().addItem(2402, 1); p.getQuestManager().setStage(Quest.DEMON_SLAYER, DemonSlayer.SILVERLIGHT_OBTAINED_STAGE); p.getInventory().deleteItem(2401, 1); p.getInventory().deleteItem(2399, 1); p.getInventory().deleteItem(2400, 1); } else if(tick == 9) { p.unlock(); p.tele(playerTile); dummy.finish(); npc.setHidden(false); stop(); } tick++; } }, 0, 1); } } public static NPCClickHandler handleSirPrysin = new NPCClickHandler(new Object[] { 883 }, e -> e.getPlayer().startConversation(new SirPrysinDemonSlayerD(e.getPlayer()).getStart())); }" "package com.rs.game.content.quests.demonslayer; //TODO: Check Fight Arena, Dragon Slayer, Vampire Slayer, wally vs delrith cutscene, and the rest of the cutscenes public class WallyVSDelrithCutscene extends Cutscene { @Override public void construct(Player player) { music(-1); fadeIn(0); hideMinimap(); delay(4); dynamicRegion(player.getTile(), 401, 419, 4, 4); action(()-> player.getAppearance().setHidden(true)); playerMove(19, 17, 0, Entity.MoveType.TELE); camShake(1, 0, 10, 5, 10); camPos(19, 17, 1300); camLook(19 + 4, 17 - 4, 50); delay(1); fadeOut(0); music(196); npcCreate(""wally"", 4664, 19 - 1, 17 - 5, player.getPlane()); delay(1); dialogue(new Dialogue() .addNPC(882, HeadE.TALKING_ALOT, ""Wally managed to arrive at the stone circle just as Delrith was summoned by a cult of chaos druids..."") , true); npcMove(""wally"", Tile.of(19, 17 - 2, player.getPlane()), Entity.MoveType.RUN); dialogue(new Dialogue().addNPC(4664, HeadE.TALKING_ALOT, ""Die foul demon!"")); camLook(19, 17 - 4, 0, 4, 4); delay(1); npcAnim(""wally"", new Animation(12311)); delay(1); npcAnim(""wally"", new Animation(2394)); delay(1); npcAnim(""wally"", new Animation(16290)); camLook(19, 17 - 3, 0, 1, 1); camPos(19, 17, 250, 0, 40); delay(2); dialogue(new Dialogue().addNPC(4664, HeadE.TALKING_ALOT, ""Aber, Gabindo, Purchai, Camerinthum, and Carlem""), true); delay(3); fadeIn(0); delay(4); camPos(19 - 2, 17 - 5, 1450); camLook(19, 17 - 2, 600); delay(1); fadeOutQuickly(0); delay(1); npcFaceTile(""wally"", 19 - 1, 17 - 3, 0); npcAnim(""wally"", new Animation(12625)); dialogue(new Dialogue().addNPC(4664, HeadE.TALKING_ALOT, ""I am the greatest demon slayer EVER!""), true); dialogue(new Dialogue() .addNPC(4664, HeadE.TALKING_ALOT, ""By reciting the correct magical incantation, and thrusting Silverlight into Delrith while he was newly "" + ""summoned, Wally was able to imprison Delrith in the stone block in the centre of the circle."") , true); fadeIn(0); delay(4); action(()-> player.getAppearance().setHidden(false)); action(()-> player.tele(getEndTile())); camShakeReset(); delay(1); fadeOut(0); music(125); action(()-> player.getTempAttribs().setB(""DemonSlayerCutscenePlayed"", true)); dialogue(new GypsyArisDemonSlayerD(player, 1).getStart(), false); } }" "package com.rs.game.content.quests.demonslayer; @PluginEventHandler public class WizardTraibornDemonSlayerD extends Conversation { private final int WIZARD_TRAIBORN = 881; private final int ABOUT_SIR_PRYSIN = 0; private final int KEYS_DIALOGUE = 1; private final int KEYS_OPTIONS = 2; private final int HAS_BONES = 3; private final int DOES_NOT_HAVE_BONES = 4; private final int RETRIEVE_KEY_AGAIN = 5; public WizardTraibornDemonSlayerD(Player player) { super(player); addNPC(WIZARD_TRAIBORN, HeadE.HAPPY_TALKING, ""Ello young thingummywut.""); if(!player.isQuestComplete(Quest.DEMON_SLAYER) && player.getQuestManager().getAttribs(Quest.DEMON_SLAYER).getB(""WIZARD_RITUAL_KNOWN"")) if(player.getQuestManager().getAttribs(Quest.DEMON_SLAYER).getB(""WIZARD_KEY_PREVIOUSLY_RETRIEVED"")) { if(!player.getInventory().containsItem(2399)) { addNext(()-> player.startConversation(new WizardTraibornDemonSlayerD(player, RETRIEVE_KEY_AGAIN).getStart())); return; } } else if(player.getInventory().containsItem(526, 25)) { addNext(()-> player.startConversation(new WizardTraibornDemonSlayerD(player, HAS_BONES).getStart())); return; } else { addNext(()-> player.startConversation(new WizardTraibornDemonSlayerD(player, DOES_NOT_HAVE_BONES).getStart())); return; } addOptions(""Choose an option:"", new Options() { @Override public void create() { option(""What's a thingummywut?"", new Dialogue() .addPlayer(HeadE.SKEPTICAL_THINKING, ""What's a thingummywut?"") .addNPC(WIZARD_TRAIBORN, HeadE.WORRIED, ""A thingummywut? Where? Where?"") .addNPC(WIZARD_TRAIBORN, HeadE.WORRIED, ""Those pesky thingummywuts. They get everywhere. They leave a terrible mess too."") .addOptions(""Choose an option:"", new Options() { @Override public void create() { option(""Err you just called me a thingummywut."", new Dialogue() .addPlayer(HeadE.FRUSTRATED, ""Err you just called me thingummywut."") .addNPC(WIZARD_TRAIBORN, HeadE.AMAZED_MILD, ""You're a thingummywut? I've never seen one up close before. They said I was mad!"") .addNPC(WIZARD_TRAIBORN, HeadE.AMAZED_MILD, ""Now you are my proof! There ARE thingummywuts in this tower. Now where can I find a "" + ""cage big enough to keep you?"") .addOptions(""Choose an option:"", new Options() { @Override public void create() { option(""Err I'd better be off really."", new Dialogue() .addPlayer(HeadE.WORRIED, ""Err I'd better be off really."") .addNPC(WIZARD_TRAIBORN, HeadE.CALM_TALK, ""Oh ok, have a good time, and watch out for sheep! They're more cunning than they look."")); option(""They're right, you are mad."", new Dialogue() .addPlayer(HeadE.FRUSTRATED, ""They're right, you are mad."") .addNPC(WIZARD_TRAIBORN, HeadE.SAD_MILD, ""That's a pity. I thought maybe they were winding me up."")); } })); option(""Tell me what they look like and I'll mash 'em."", new Dialogue() .addPlayer(HeadE.ANGRY, ""Tell me what they look like and I'll mash 'em."") .addNPC(WIZARD_TRAIBORN, HeadE.LAUGH, ""Don't be ridiculous. No-one has ever seen one."") .addNPC(WIZARD_TRAIBORN, HeadE.LAUGH, ""They're invisible, or a myth, or a figment of my imagination. Can't remember which right now."")); } })); option(""Teach me to be a mighty and powerful wizard."", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Teach me to be a mighty and powerful wizard."") .addNPC(WIZARD_TRAIBORN, HeadE.HAPPY_TALKING, ""Wizard eh? You don't want any truck with that sort. They're not to be trusted. That's what"" + "" I've heard anyways."") .addOptions(""Choose an option:"", new Options() { @Override public void create() { option(""So aren't you a wizard?"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""So aren't you a wizard?"") .addNPC(WIZARD_TRAIBORN, HeadE.ANGRY, ""How dare you? Of course I'm a wizard. Now don't be so cheeky or I'll turn you into a frog."")); option(""Oh I'd better stop talking to you then."", new Dialogue() .addPlayer(HeadE.AMAZED_MILD, ""Oh I'd better stop talking to you then."") .addNPC(WIZARD_TRAIBORN, HeadE.HAPPY_TALKING, ""Cheerio then. It was nice chatting to you."")); } })); if(!player.isQuestComplete(Quest.DEMON_SLAYER) && player.getQuestManager().getStage(Quest.DEMON_SLAYER) >= DemonSlayer.AFTER_SIR_PRYSIN_INTRO_STAGE && !player.getInventory().containsItem(2399)) option(""I need to get a key given to you by Sir Prysin."", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""I need to get a key given to you by Sir Prysin."") .addNPC(WIZARD_TRAIBORN, HeadE.SKEPTICAL_THINKING, ""Sir Prysin? Who's that? What would I want his key for?"") .addNext(() -> player.startConversation(new WizardTraibornDemonSlayerD(player, ABOUT_SIR_PRYSIN).getStart()))); } }); } public WizardTraibornDemonSlayerD(Player player, int convoID) { super(player); switch(convoID) { case ABOUT_SIR_PRYSIN: aboutSirPrysin(player); break; case KEYS_DIALOGUE: keyDialogue(player); break; case KEYS_OPTIONS: keysOption(player); break; case HAS_BONES: hasBones(player); break; case DOES_NOT_HAVE_BONES: doesNotHaveBones(player); break; case RETRIEVE_KEY_AGAIN: retrieveKeyAgain(player); break; } } private void aboutSirPrysin(Player p) { addOptions(""Choose an option:"", new Options() { @Override public void create() { option(""He told me you were looking after it for him."", new Dialogue() .addPlayer(HeadE.CALM_TALK, ""He told me you were looking after it for him."") .addNPC(WIZARD_TRAIBORN, HeadE.CALM_TALK, ""Oh that's great, if it wouldn't be too much trouble."") .addNext(()-> p.startConversation(new WizardTraibornDemonSlayerD(p, KEYS_OPTIONS).getStart()))); option(""He's one of the King's knights."", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""He's one of the King's knights."") .addNPC(WIZARD_TRAIBORN, HeadE.CALM_TALK, ""Say, I remember one of the King's knights. He had nice shoes..."") .addNPC(WIZARD_TRAIBORN, HeadE.CALM_TALK, ""...and didn't like my homemade spinach rolls. Would you like a spinach roll?"") .addOptions(""Choose an option:"", new Options() { @Override public void create() { option(""Yes please."", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Yes please."") .addSimple(""Traiborn digs around in the pockets of his robes. After a few moments he triumphantly presents you with "" + ""a spinach roll."", ()-> p.getInventory().addItem(new Item(1969, 1), true)) .addPlayer(HeadE.HAPPY_TALKING, ""Thank you very much."") .addNext(()-> p.startConversation(new WizardTraibornDemonSlayerD(p, ABOUT_SIR_PRYSIN).getStart()))); option(""No thanks."", new Dialogue()); } })); option(""Well, have you got any keys knocking around?"", new Dialogue() .addNext(()-> p.startConversation(new WizardTraibornDemonSlayerD(p, KEYS_DIALOGUE).getStart()))); } }); } private void keyDialogue(Player p) { addPlayer(HeadE.HAPPY_TALKING, ""Well, have you got any keys knocking around?""); addNPC(WIZARD_TRAIBORN, HeadE.HAPPY_TALKING, ""Now you come to mention it, yes I do have a key. It's in my special closet of"" + "" valuable stuff. Now how do I get into that?""); addNPC(WIZARD_TRAIBORN, HeadE.HAPPY_TALKING, ""I sealed it using one of my magic rituals. So it would make sense that "" + ""another ritual would open it again.""); addPlayer(HeadE.SKEPTICAL_THINKING, ""So do you know what ritual to use?""); addNPC(WIZARD_TRAIBORN, HeadE.SKEPTICAL_THINKING, ""Let me think a second.""); addNPC(WIZARD_TRAIBORN, HeadE.SKEPTICAL_THINKING, ""Yes a simple drazier style ritual should suffice. Hmm, main problem with that is I'll need 25 sets "" + ""of bones. Now where am I going to get hold of something like that?""); addOptions("""", new Options() { @Override public void create() { option(""Hmm, that's too bad. I really need that key."", new Dialogue() .addPlayer(HeadE.CALM_TALK, ""Hmm, that's too bad. I really need that key."") .addNPC(WIZARD_TRAIBORN, HeadE.CALM_TALK, ""Ah well, sorry I couldn't be any more help."")); option(""I'll get the bones for you."", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""I'll help get the bones for you."") .addNPC(WIZARD_TRAIBORN, HeadE.CALM_TALK, ""Ooh that would be very good of you."") .addPlayer(HeadE.HAPPY_TALKING, ""Okay, I'll speak to you when I've got some bones."", ()-> p.getQuestManager().getAttribs(Quest.DEMON_SLAYER).setB(""WIZARD_RITUAL_KNOWN"", true))); } }); } private void keysOption(Player p) { addOptions(""Choose an option:"", new Options() { @Override public void create() { option(""Err I'd better be off really."", new Dialogue() .addPlayer(HeadE.CALM_TALK, ""Err I'd better be off really."") .addNext(()-> p.startConversation(new WizardTraibornDemonSlayerD(p, ABOUT_SIR_PRYSIN).getStart()))); option(""Well, have you got any keys knocking around?"", new Dialogue() .addNext(()-> p.startConversation(new WizardTraibornDemonSlayerD(p, KEYS_DIALOGUE).getStart()))); } }); } private void hasBones(Player p) { addNPC(WIZARD_TRAIBORN, HeadE.HAPPY_TALKING, ""How are you doing finding bones?""); addPlayer(HeadE.HAPPY_TALKING, ""I have them""); addNPC(WIZARD_TRAIBORN, HeadE.HAPPY_TALKING, ""Give 'em here then.""); addNPC(WIZARD_TRAIBORN, HeadE.HAPPY_TALKING, ""Hurrah! That's all 25 sets of bones.""); addNPC(WIZARD_TRAIBORN, HeadE.HAPPY_TALKING, ""Wings of dark and colour too, Spreading in the morning dew; Locked away I have a key; Return it now, "" + ""please, unto me."", () -> { p.getInventory().deleteItem(526, 25); p.getInventory().addItem(new Item(2399), false); p.getQuestManager().getAttribs(Quest.DEMON_SLAYER).setB(""WIZARD_KEY_PREVIOUSLY_RETRIEVED"", true); }); addPlayer(HeadE.HAPPY_TALKING, ""Thank you very much.""); addNPC(WIZARD_TRAIBORN, HeadE.HAPPY_TALKING, ""Not a problem for a friend of Sir What's-his-face.""); } private void doesNotHaveBones(Player p) { addNPC(WIZARD_TRAIBORN, HeadE.HAPPY_TALKING, ""How are you doing finding bones?""); addPlayer(HeadE.SAD, ""I haven't gotten all of them at the moment.""); addNPC(WIZARD_TRAIBORN, HeadE.HAPPY_TALKING, ""Keep working on it""); } private void retrieveKeyAgain(Player p) { addPlayer(HeadE.SAD, ""I've lost the key you gave to me.""); addNPC(WIZARD_TRAIBORN, HeadE.HAPPY_TALKING, ""Yes I know, it was returned to me. If you want it back you're going to have to collect another 25 sets of "" + ""bones.""); if(p.getInventory().containsItem(526, 25)) { addPlayer(HeadE.HAPPY_TALKING, ""Oh perfect, I have the bones right here""); addNPC(WIZARD_TRAIBORN, HeadE.HAPPY_TALKING, ""Give 'em here then.""); addNPC(WIZARD_TRAIBORN, HeadE.HAPPY_TALKING, ""Hurrah! That's all 25 sets of bones.""); addNPC(WIZARD_TRAIBORN, HeadE.HAPPY_TALKING, ""Wings of dark and colour too, Spreading in the morning dew; Locked away I have a key; Return it now, "" + ""please, unto me."", () -> { for(NPC npc : World.getNPCsInChunkRange(p.getChunkId(), 1)) if(npc.getId() == 881) { npc.setNextAnimation(new Animation(716)); npc.setNextSpotAnim(new SpotAnim(102)); } p.getInventory().deleteItem(526, 25); p.getInventory().addItem(new Item(2399), false); }); addPlayer(HeadE.HAPPY_TALKING, ""Thank you very much.""); } } public static NPCClickHandler handleWizardTraiborn = new NPCClickHandler(new Object[] { 881 }, e -> e.getPlayer().startConversation(new WizardTraibornDemonSlayerD(e.getPlayer()).getStart())); }" "package com.rs.game.content.quests.deviousminds; @PluginEventHandler public class Monk { private static final int MonkDeviousMinds = 3074; public static NPCClickHandler handleMonkDeviousMinds = new NPCClickHandler(new Object[]{ MonkDeviousMinds }, new String[]{""Talk-to""}, e -> e.getPlayer().startConversation(new Dialogue() .addNPC(MonkDeviousMinds, HeadE.CONFUSED,""Excuse me...oh, wait, I thought you were someone else."") .addPlayer(HeadE.CONFUSED,""No problem. Have a good day!"") .addNPC(MonkDeviousMinds, HeadE.CONFUSED,""And yourself.""))); }" "// This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see . // // Copyright � 2021 Trenton Kress // This file is part of project: Darkan // package com.rs.game.content.quests.dragonslayer; public class BoatCutscene extends Cutscene { private static final int TRAVEL_INTERFACE = 299; private static final int BOAT_TO_CRANDOR = 544; @Override public void construct(Player player) { setEndTile(Tile.of(2849, 3239, 0)); fadeInBG(2); hideMinimap(); dynamicRegion(player.getTile(), 256, 688, 8, 8); npcCreate(""ned"", 6084, 18, 13, 1); npcCreate(""jenkins"", 6085, 15, 14, 1); playerMove(18, 12, 1, MoveType.TELE); music(350); action(7, () -> { player.getInterfaceManager().sendBackgroundInterfaceOverGameWindow(516); player.getInterfaceManager().sendForegroundInterfaceOverGameWindow(TRAVEL_INTERFACE); player.getPackets().setIFHidden(TRAVEL_INTERFACE, 44, false); }); action(4, () -> player.getInterfaceManager().sendForegroundInterfaceOverGameWindow(BOAT_TO_CRANDOR)); action(() -> player.getInterfaceManager().closeInterfacesOverGameWindow()); fadeOutBG(-1); playerFaceEntity(""ned""); npcFaceDir(""ned"", Direction.EAST); camShake(1, 0, 8, 5, 8); camPos(28, 14, 0); camLook(21, 13, 0); camPos(26, 13, 600, 0, 4); dialogue(new Dialogue().addNPC(6084, HeadE.HAPPY_TALKING, ""Ah, it's good to feel the salt spray on my face once again!"")); delay(4); camPos(26, 9, 2050, 0, 2); dialogue(new Dialogue() .addNPC(6084, HeadE.HAPPY_TALKING, ""And this is a mighty fine ship. She don't look much but she handles like a dream."") .addPlayer(HeadE.CALM_TALK, ""How much longer until we reach Crandor?"") .addNPC(6084, HeadE.HAPPY_TALKING, ""Not long now! According to the chart, we'd be able to see Crandor if it wasn't for the clouds on the horizon.""), true); dialogue(new Dialogue().addSimple(""Clouds surround the ship."")); music(360); action(1, () -> player.getInterfaceManager().sendBackgroundInterfaceOverGameWindow(543)); camShakeReset(1); action(() -> player.getInterfaceManager().closeInterfacesOverGameWindow()); playerFaceTile(15, 14); npcMove(""jenkins"", 18, 14, MoveType.WALK); dialogue(new Dialogue().addNPC(6085, HeadE.HAPPY_TALKING, ""Looks like there's a storm coming up, cap'n. Soon we won't be able to see anything!""), true); camPos(23, 21, 5000); camLook(14, 14, 0); camPos(18, 21, 5000, 0, 2); delay(3); npcFaceDir(""ned"", Direction.NORTH); playerFaceDir(Direction.NORTH); npcFaceNPC(""ned"", ""jenkins""); dialogue(new Dialogue().addNPC(6084, HeadE.HAPPY_TALKING, ""Oh, well. The weather had been so good up until now.""), true); action(1, () -> player.getInterfaceManager().sendBackgroundInterfaceOverGameWindow(545)); action(1, () -> player.getInterfaceManager().closeInterfacesOverGameWindow()); dialogue(new Dialogue() .addPlayer(HeadE.SCARED, ""Did you see that?"") .addNPC(6084, HeadE.CALM_TALK, ""See what?"") .addPlayer(HeadE.SCARED, ""I thought I saw something above us.""), true); camPos(24, 13, 1150); camLook(18, 13, 0, 0); camPos(24, 19, 0, 1150, 3); delay(1); npcFaceTile(""ned"", 17, 12); npcFaceTile(""jenkins"", 17, 12); playerFaceTile(17, 12); projectile(1, Tile.of(17, 9, 1), Tile.of(17, 12, 1), 1155, 99, 0, 0, 0.5, 0, 0, p -> repeatFireSpotAnim(player, p.getDestination(), 0)); dialogue(new Dialogue().addNPC(6084, HeadE.SCARED, ""It's the dragon!""), true); projectile(1, Tile.of(17, 9, 1), Tile.of(16, 12, 1), 1155, 99, 0, 0, 0.5, 0, 0, p -> repeatFireSpotAnim(player, p.getDestination(), 0)); projectile(1, Tile.of(17, 9, 1), Tile.of(15, 12, 1), 1155, 99, 0, 0, 0.5, 0, 0, p -> repeatFireSpotAnim(player, p.getDestination(), 0)); action(() -> player.getInterfaceManager().sendBackgroundInterfaceOverGameWindow(546)); projectile(2, Tile.of(17, 9, 1), Tile.of(13, 12, 1), 1155, 99, 0, 0, 0.5, 0, 0, p -> repeatFireSpotAnim(player, p.getDestination(), 500)); action(() -> player.getInterfaceManager().closeInterfacesOverGameWindow()); camShake(1, 0, 8, 5, 8); camPos(19, 14, 1200); camLook(17, 14, 700); camPos(26, 14, 1200, 0, 3); npcFaceTile(""ned"", 13, 14); npcFaceTile(""jenkins"", 13, 14); action(() -> player.getInterfaceManager().closeInterfacesOverGameWindow()); projectile(1, Tile.of(13, 11, 1), Tile.of(13, 14, 1), 1155, 99, 0, 0, 0.5, 0, 0, p -> repeatFireSpotAnim(player, p.getDestination(), 500)); projectile(1, Tile.of(15, 11, 1), Tile.of(15, 14, 1), 1155, 99, 0, 0, 0.5, 0, 0, p -> repeatFireSpotAnim(player, p.getDestination(), 0, () -> getNPC(""jenkins"").setNextAnimation(new Animation(2105)))); projectile(1, Tile.of(16, 17, 1), Tile.of(16, 14, 1), 1155, 99, 0, 0, 0.5, 0, 0, p -> repeatFireSpotAnim(player, p.getDestination(), 0, () -> getNPC(""ned"").setNextAnimation(new Animation(4280)))); projectile(1, Tile.of(17, 17, 1), Tile.of(17, 14, 1), 1155, 99, 0, 0, 0.5, 0, 0, p -> repeatFireSpotAnim(player, p.getDestination(), 0, () -> getNPC(""jenkins"").setNextAnimation(new Animation(6649)))); projectile(1, Tile.of(18, 17, 1), Tile.of(18, 14, 1), 1155, 99, 0, 0, 0.5, 0, 0, p -> repeatFireSpotAnim(player, p.getDestination(), 0, () -> getNPC(""jenkins"").setNextAnimation(new Animation(836)))); projectile(1, Tile.of(19, 17, 1), Tile.of(19, 14, 1), 1155, 99, 0, 0, 0.5, 0, 0, p -> repeatFireSpotAnim(player, p.getDestination(), 0)); projectile(1, Tile.of(41, 17, 1), Tile.of(41, 14, 1), 1155, 99, 0, 0, 0.5, 0, 0, p -> repeatFireSpotAnim(player, p.getDestination(), 0)); camPos(34, 14, 1900); camLook(17, 14, 700); camPos(28, 14, 1200, 0, 3); delay(1); dialogue(new Dialogue().addNPC(6084, HeadE.SCARED, ""We're going to sink!""), true); npcFaceTile(""ned"", 18, 12); playerFaceDir(Direction.EAST); dialogue(new Dialogue().addPlayer(HeadE.AMAZED_MILD, ""Look! Land ahead!""), true); delay(1); camPos(20, 14, 1200, 0, 3); playerFaceTile(18, 13); npcFaceDir(""ned"", Direction.EAST); delay(1); dialogue(new Dialogue().addNPC(6084, HeadE.AMAZED, ""We're going to crash!""), true); delay(1); camShake(1, 5, 8, 25, 8); dialogue(new Dialogue().addSimple(""CRASH!"")); delay(2); fadeInBG(3); action(() -> player.getInterfaceManager().sendBackgroundInterfaceOverGameWindow(516)); action(1, () -> player.tele(getEndTile())); playerFaceDir(Direction.NORTH); camShakeReset(); camPosReset(); dialogue(new Dialogue().addSimple(""You are knocked unconcious and later awake on an ash-strewn beach.""), true); delay(1); playerAnim(new Animation(4191)); fadeOutBG(7); action(() -> { player.getInterfaceManager().closeInterfacesOverGameWindow(); player.getQuestManager().getAttribs(Quest.DRAGON_SLAYER).setB(DragonSlayer.FINISHED_BOAT_SCENE_ATTR, true); }); } private void repeatFireSpotAnim(Player player, Tile target, int fireHeight, Runnable extra) { WorldTasks.scheduleTimer(tick -> { if (tick == 0) { World.sendSpotAnim(Tile.of(target.getX(), target.getY(), target.getPlane()), new SpotAnim(1154)); World.sendSpotAnim(Tile.of(target.getX(), target.getY(), target.getPlane()), new SpotAnim(2588)); if (extra != null) extra.run(); } if (tick > 1) World.sendSpotAnim(Tile.of(target.getX(), target.getY(), target.getPlane()), new SpotAnim(453, 0, fireHeight)); if(tick == 80) return false; return true; }); } private void repeatFireSpotAnim(Player player, Tile target, int fireHeight) { repeatFireSpotAnim(player, target, fireHeight, null); } }" "package com.rs.game.content.quests.dragonslayer; @PluginEventHandler public class CabinBoyJenkinsDragonSlayerD extends Conversation { public CabinBoyJenkinsDragonSlayerD(Player player) { super(player); switch(player.getQuestManager().getStage(Quest.DRAGON_SLAYER)) { case NOT_STARTED, TALK_TO_OZIACH, TALK_TO_GUILDMASTER, PREPARE_FOR_CRANDOR -> { if(player.getQuestManager().getAttribs(Quest.DRAGON_SLAYER).getB(OWNS_BOAT_ATTR)) { addNPC(JENKINS, HeadE.CALM_TALK, ""Ahoy! What d'ye think of yer ship then?""); addOptions(""Choose an option:"", new Options() { @Override public void create() { option(""I'd like to inspect her some more."", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""I'd like to inspect her some more."") .addNPC(JENKINS, HeadE.CALM_TALK, ""Aye."")); if(player.getQuestManager().getAttribs(Quest.DRAGON_SLAYER).getB(NED_IS_CAPTAIN_ATTR)) option(""Can you sail this ship to Crandor?"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Can you sail this ship to Crandor?"") .addNPC(JENKINS, HeadE.CALM_TALK, ""Not me, sir! I'm just an 'umble cabin boy. You'll need to talk to Captain Ned."")); else option(""Can you sail this ship to Crandor?"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Can you sail this ship to Crandor?"") .addNPC(JENKINS, HeadE.CALM_TALK, ""Not me, sir! I'm just an 'umble cabin boy. You'll need a proper cap'n."") .addPlayer(HeadE.HAPPY_TALKING, ""Where can I find a captain?"") .addNPC(JENKINS, HeadE.CALM_TALK, ""The cap'ns round 'ere seem to be a mite scared of Crandor. I ask 'em why and they "" + ""just say it was afore my time, but there is one cap'n I reckon might 'elp."") .addNPC(JENKINS, HeadE.CALM_TALK, ""I 'eard there's a retured 'un who lives in Draynor Village who's so desperate to sail again "" + ""'e'd take any job. I can't remember 'is name, but 'e lives in Draynor Village an' makes rope."") ); } }); } else { addNPC(JENKINS, HeadE.CALM_TALK, ""Ahoy! What d'ye think of the ship then?""); addOptions(""Choose an option:"", new Options() { @Override public void create() { option(""I might buy her!"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""I might buy her!"") .addNPC(JENKINS, HeadE.CALM_TALK, ""Great!"")); option(""I'd like to inspect her some more."", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""I'd like to inspect her some more."") .addNPC(JENKINS, HeadE.CALM_TALK, ""Aye."")); option(""Can you sail this ship?"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Can you sail this ship?"") .addNPC(JENKINS, HeadE.CALM_TALK, ""Not me, sir! I'm just an 'umble cabin boy. You'll need a proper cap'n."") ); } }); } } case REPORT_TO_OZIACH, QUEST_COMPLETE -> { addNPC(JENKINS, HeadE.FRUSTRATED, ""You are the worst captain ever! I could have died!""); addPlayer(HeadE.CALM_TALK, ""But you didn't...""); addNPC(JENKINS, HeadE.FRUSTRATED, ""Aye, I didn't.""); addPlayer(HeadE.CALM_TALK, ""Would you take me to Crandor again?""); addNPC(JENKINS, HeadE.FRUSTRATED, ""Now that the dragon is dead I guess I would.""); addPlayer(HeadE.HAPPY_TALKING, ""Great!""); } } } public static NPCClickHandler handleJenkinsDialogue = new NPCClickHandler(new Object[] { 748 }, e -> e.getPlayer().startConversation(new CabinBoyJenkinsDragonSlayerD(e.getPlayer()).getStart())); }" "package com.rs.game.content.quests.dragonslayer; @PluginEventHandler public class CaptainNedDragonSlayerD extends Conversation { /** * Only called in PREPARE_FOR_CRANDOR stage. */ public CaptainNedDragonSlayerD(Player player) { super(player); switch(player.getQuestManager().getStage(Quest.DRAGON_SLAYER)) { case NOT_STARTED, TALK_TO_OZIACH, TALK_TO_GUILDMASTER -> { addNPC(NED, HeadE.CALM_TALK, ""I just came here for a little stroll...""); addPlayer(HeadE.HAPPY_TALKING, ""Oh, well carry on then...""); } case PREPARE_FOR_CRANDOR -> { addNPC(NED, HeadE.CALM_TALK, ""Ah, it's good to be on board a ship again! No matter how long I live on land, a ship will always seem better. "" + ""Are you ready to depart?""); addOptions(""Choose an option:"", new Options() { @Override public void create() { option(""Yes, let's go!"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Yes, let's go!"") .addSimple(""Ship begins to set sail"") .addNext(()-> player.getControllerManager().startController(new DragonSlayer_BoatScene()))); option(""No, I'm not quite ready yet."", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""No, I'm not quite ready yet."") .addNPC(NED, HeadE.CALM_TALK, ""Well, you go do whatever you need to do. I'll wait here for you until you're ready."")); } }); } case REPORT_TO_OZIACH -> { addNPC(NED, HeadE.CALM_TALK, ""Now I see why all of the other captains said I'd be mad to go near Crandor.""); addPlayer(HeadE.HAPPY_TALKING, ""Yea, now that the dragons dead, want to go again?""); addNPC(NED, HeadE.CALM_TALK, ""Ay, anything for the sea!""); } case QUEST_COMPLETE -> { if(player.getQuestManager().getAttribs(Quest.DRAGON_SLAYER).getB(IS_BOAT_FIXED_ATTR)) addNPC(NED, HeadE.CALM_TALK, ""This ship's in a sorry state. You'd better fix up the hole in the hull before we can go anywhere.""); else addNPC(NED, HeadE.CALM_TALK, ""If you want to head to Crandor you better tell Klarense.""); } } } public static NPCClickHandler handleJenkinsDialogue = new NPCClickHandler(new Object[] { CAPTAIN_NED }, e -> e.getPlayer().startConversation(new CaptainNedDragonSlayerD(e.getPlayer()).getStart())); }" "package com.rs.game.content.quests.dragonslayer; @QuestHandler( quest = Quest.DRAGON_SLAYER, startText = ""Talk to the Guildmaster inside the Champions' Guild, south of Varrock."", itemsText = ""An unfired bowl, a wizard's mind bomb, a crayfish cage or lobster pot, a piece of silk, 2,000-12,000 coins (less if you bring Telekenetic Grab runes and a non-melee weapon), 3 regular planks and 90 steel nails."", combatText = ""You will need to defeat a level 63 dragon, a level 56 demon, a level 39 mage, and various lesser foes. 50+ in combat skills and 37+ Prayer are recommended."", rewardsText = ""18,650 Strength XP
18,650 Defense XP
Anti-dragon shield
Access to Crandor, Melzar's Maze, and the dragon crest on herald capes"", completedStage = 5 ) @PluginEventHandler public class DragonSlayer extends QuestOutline { // public final static int public final static int NOT_STARTED = 0; public final static int TALK_TO_OZIACH = 1; public final static int TALK_TO_GUILDMASTER = 2;//ask all dialogue, get key public final static int PREPARE_FOR_CRANDOR = 3;//Melzars maze, chest, wormbrain, then get a boat, then ned. public final static int REPORT_TO_OZIACH = 4; public final static int QUEST_COMPLETE = 5; //Items public final static int MAP_PART1 = 1535; public final static int MAP_PART2 = 1536; public final static int MAP_PART3 = 1537; public final static int CRANDOR_MAP = 1538; public final static int LAW_RUNE = 563; public final static int AIR_RUNE = 556; public final static int HAMMER = 2347; public final static int ANTI_DRAGON_SHIELD = 1540; public final static int STEEL_NAILS = 1539; public final static int PLANKS = 960; public final static int RED_KEY = 1543;//keys public final static int ORANGE_KEY = 1544; public final static int YELLOW_KEY = 1545; public final static int BLUE_KEY = 1546; public final static int MAGENTA_KEY = 1547; public final static int GREEN_KEY = 1548; public final static int ELVARG_HEAD = 11279; public final static int MELZAR_MAZE_KEY = 1542; //Game Objects public final static int MAP_CHEST2 = 2587; //NPCs public final static int WORM_BRAIN = 745; public final static int NED = 918; public final static int CAPTAIN_NED = 6082;//Ned on Lady Lumbridge boat public final static int GUILD_MASTER = 198; public final static int OZIACH = 747; public final static int KLARENSE = 744; public final static int JENKINS = 748; public final static int ORACLE = 746; //Magenta Room public final static int MELZAR_THE_MAD_MEGENTA_KEY = 753; //Green Room public final static int LESSER_DEMON_GREEN_KEY = 4694; //Blue Room public final static int ZOMBIE_BLUE_KEY = 75; //Orange Room public final static int GHOST_ORANGE_KEY = 6094; //Red Room public final static int RAT_RED_KEY = 6088; //Yellow Room public final static int SKELETON_YELLOW_KEY = 6091; //Vars & attribs public final static String NED_IS_CAPTAIN_ATTR = ""NED_IS_CAPTAIN""; public final static int NED_BOAT_VISIBILITY_VAR = 176;//7 for visible public final static int BOAT_HULL_FIXED_VAR = 1837;//1 for fix, 0 for broken //GuildMaster dialogue attributes public final static String STARTED_DIALOGUE_GUILDMASTER_ATTR = ""STARTED_BRIEFING_FROM_GUILDMASTER""; public final static String FINISHED_DIALOGUE_GUILDMASTER_ATTR = ""FINISHED_BRIEFING_FROM_GUILDMASTER""; public final static String KNOWS_MAP_EXISTS_ATTR = ""KNOWS_MAP_EXISTS""; public final static String KNOWS_ABOUT_THALZAR_MAP_ATTR = ""KNOWS_ABOUT_THALZAR""; public final static String KNOWS_ABOUT_LOZAR_MAP_ATTR = ""KNOWS_ABOUT_LOZAR""; public final static String KNOWS_ABOUT_MELZAR_MAP_ATTR = ""KNOWS_ABOUT_MELZAR_MAP""; public final static String KNOWS_ABOUT_SHIP_ATTR = ""KNOWS_ABOUT_SHIP""; public final static String KNOWS_ABOUT_DRAGON_BREATH_ATTR = ""KNOWS_ABOUT_DRAGON_BREATH""; //Other attributes public final static String OWNS_BOAT_ATTR = ""PLAYER_OWNS_BOAT""; public final static String IS_BOAT_FIXED_ATTR = ""IS_BOAT_FIXED""; public final static String BOAT_FIX_NUM_ATTR = ""BOAT_FIX_STAGE""; public final static String ORACLE_DOOR_KNOWLEDGE_ATTR = ""ORACLE_DOOR""; public final static String DOOR_BOWL_ATTR = ""DOOR_BOWL""; public final static String DOOR_BOMB_ATTR = ""DOOR_BOMB""; public final static String DOOR_SILK_ATTR = ""DOOR_SILK""; public final static String DOOR_CAGE_ATTR = ""DOOR_CAGE""; public final static String FINISHED_BOAT_SCENE_ATTR = ""FINISHED_BOAT_SCENE""; public final static String INTRODUCED_ELVARG_ATTR = ""INTRODUCED_ELVARG""; //Other public final static Tile MELZAR_BASEMENT = Tile.of(2933, 9641, 0); public final static Tile MELZAR_MAZE = Tile.of(2931, 3250, 0); private final static int HAMMER_HITTING_REPAIR_ANIM = 3676; @Override public List getJournalLines(Player player, int stage) { ArrayList lines = new ArrayList<>(); switch (stage) { case NOT_STARTED: lines.add(""Prove yourself a true champion. Kill the mighty""); lines.add(""dragon Elvarg of Crandor and earn the right to""); lines.add(""buy and wear the Rune platebody.""); lines.add(""""); lines.add(""Talk to the Guildmaster in the Champions Guild in""); lines.add(""South Varrock. You will need 32 quest points.""); lines.add(""""); break; case TALK_TO_OZIACH: lines.add(""The Guildmaster from the Champion's guild has""); lines.add(""sent me to Oziach in Edgeville to get a quest.""); lines.add(""He also says Oziach can make rune armour,""); lines.add(""""); lines.add(""Maybe I can get a quest and rune armour? I""); lines.add(""should go ask Oziach.""); lines.add(""""); break; case TALK_TO_GUILDMASTER: lines.add(""Oziach says I cannot wield rune platebodies until""); lines.add(""I prove myself by defeating Elvarg, the dragon of""); lines.add(""Crandor.""); lines.add(""""); lines.add(""I should report to the Guildmaster and get more""); lines.add(""information as to how I should prepare.""); lines.add(""""); lines.add(""You will need to complete all the dialogue to unlock""); lines.add(""the rest of the quest. Dialogue below describing where""); lines.add(""the rest of the quest items will be, will be below:""); lines.add(""""); break; case PREPARE_FOR_CRANDOR: lines.add(""The guildmaster says I need:""); lines.add(""---A boat---""); lines.add(""I should go to port sarim and ask around to find a""); lines.add(""Boat that is not being used.""); lines.add(""""); lines.add(""---A boat captain---""); lines.add(""Perhaps Ned can help in Draynor village""); lines.add(""""); lines.add(""---A map to Crandor---""); lines.add(""There are 3 pieces I need to gather.""); lines.add(""1. I need to search Melzars Maze, I better ask the""); lines.add(""Guildmaster for a key""); if (player.getQuestManager().getAttribs(Quest.DRAGON_SLAYER).getB(ORACLE_DOOR_KNOWLEDGE_ATTR)) { lines.add(""2. I need to use a crayfish cage, an unfired bowl,""); lines.add(""Silk, and a Wizard Mind Bomb on a door in the dwarven""); lines.add(""mine. Inside the door I should find a map piece.""); lines.add(""I can get a Wizard Mind Bomb at the Lighthouse store,""); lines.add(""owned by a guy named Jossik.""); } else { lines.add(""2. I should talk to the Oracle at White Wolf Mountain.""); lines.add(""The map piece is somewhere in the dwarven mine.""); } lines.add(""3. I hear one of the prisoners in Port Sarim prison has""); lines.add(""a map piece""); lines.add(""""); break; case REPORT_TO_OZIACH: lines.add(""I have defeated Evlarg! Now I just have to tell Oziach""); lines.add(""""); break; case QUEST_COMPLETE: lines.add(""""); lines.add(""""); lines.add(""QUEST COMPLETE!""); break; default: lines.add(""Invalid quest stage. Report this to an administrator.""); break; } return lines; } public static ItemClickHandler handleClickOnCrandorMap = new ItemClickHandler(new Object[]{CRANDOR_MAP}, new String[]{""Study""}, e -> e.getPlayer().sendMessage(""The map shows a sea path to Crandor..."")); public static ItemClickHandler handleClickOnMapPart = new ItemClickHandler(new Object[]{MAP_PART1, MAP_PART2, MAP_PART3}, new String[]{""Study""}, e -> e.getPlayer().sendMessage(""The map shows part of a sea path to Crandor..."")); public static ItemOnItemHandler createMapFromParts = new ItemOnItemHandler(new int[]{MAP_PART1, MAP_PART2, MAP_PART3}, new int[]{MAP_PART1, MAP_PART2, MAP_PART3}, e -> { if (e.getPlayer().getInventory().containsItem(MAP_PART1, 1)) if (e.getPlayer().getInventory().containsItem(MAP_PART2, 1)) if (e.getPlayer().getInventory().containsItem(MAP_PART3, 1)) { e.getPlayer().getInventory().removeItems(new Item(MAP_PART1, 1), new Item(MAP_PART2, 1), new Item(MAP_PART3, 1)); e.getPlayer().getInventory().addItem(new Item(CRANDOR_MAP, 1), true); } }); public static LoginHandler onLogin = new LoginHandler(e -> { if (e.getPlayer().getQuestManager().getAttribs(Quest.DRAGON_SLAYER).getB(NED_IS_CAPTAIN_ATTR)) e.getPlayer().getVars().setVar(NED_BOAT_VISIBILITY_VAR, 7); if (e.getPlayer().getQuestManager().getAttribs(Quest.DRAGON_SLAYER).getI(BOAT_FIX_NUM_ATTR) >= 3) { e.getPlayer().getVars().setVarBit(BOAT_HULL_FIXED_VAR, 1); e.getPlayer().getQuestManager().getAttribs(Quest.DRAGON_SLAYER).setB(IS_BOAT_FIXED_ATTR, true); } }); public static ObjectClickHandler handleBoatFix = new ObjectClickHandler(new Object[]{25036}, e -> { Player p = e.getPlayer(); if (p.getQuestManager().getAttribs(Quest.DRAGON_SLAYER).getB(OWNS_BOAT_ATTR) || p.isQuestComplete(Quest.DRAGON_SLAYER)) { if (p.getInventory().containsItem(new Item(HAMMER, 1)) || p.containsTool(HAMMER)) { if (p.getQuestManager().getAttribs(Quest.DRAGON_SLAYER).getI(BOAT_FIX_NUM_ATTR) <= 2) if (p.getInventory().containsItem(STEEL_NAILS, 30) && p.getInventory().containsItem(PLANKS, 1)) { p.setNextAnimation(new Animation(HAMMER_HITTING_REPAIR_ANIM)); p.getInventory().removeItems(new Item(STEEL_NAILS, 30), new Item(PLANKS, 1)); p.getQuestManager().getAttribs(Quest.DRAGON_SLAYER).setI(BOAT_FIX_NUM_ATTR, p.getQuestManager().getAttribs(Quest.DRAGON_SLAYER).getI(BOAT_FIX_NUM_ATTR) + 1); if (p.getQuestManager().getAttribs(Quest.DRAGON_SLAYER).getI(BOAT_FIX_NUM_ATTR) >= 3) { p.getVars().setVarBit(BOAT_HULL_FIXED_VAR, 1); p.getQuestManager().getAttribs(Quest.DRAGON_SLAYER).setB(IS_BOAT_FIXED_ATTR, true); p.startConversation(new Conversation(e.getPlayer()) { { addPlayer(HeadE.HAPPY_TALKING, ""There, all done...""); create(); } }); } } else p.startConversation(new Conversation(e.getPlayer()) { { addPlayer(HeadE.HAPPY_TALKING, ""I am going to need a hammer, planks and some steel nails...""); addPlayer(HeadE.HAPPY_TALKING, (90 - p.getQuestManager().getAttribs(Quest.DRAGON_SLAYER).getI(BOAT_FIX_NUM_ATTR) * 30) + "" steel nails and "" + (3 - p.getQuestManager().getAttribs(Quest.DRAGON_SLAYER).getI(BOAT_FIX_NUM_ATTR)) + "" planks.""); create(); } }); } else p.startConversation(new Conversation(e.getPlayer()) { { addPlayer(HeadE.HAPPY_TALKING, ""I am going to need a hammer, planks and some steel nails....""); addPlayer(HeadE.HAPPY_TALKING, (90 - p.getQuestManager().getAttribs(Quest.DRAGON_SLAYER).getI(BOAT_FIX_NUM_ATTR) * 30) + "" steel nails and "" + (3 - p.getQuestManager().getAttribs(Quest.DRAGON_SLAYER).getI(BOAT_FIX_NUM_ATTR)) + "" planks.""); create(); } }); } else p.startConversation(new Conversation(e.getPlayer()) { { addPlayer(HeadE.HAPPY_TALKING, ""This isn't my boat, better not touch it...""); create(); } }); }); public static ObjectClickHandler handleMagicDoor = new ObjectClickHandler(new Object[]{25115}, e -> { Player p = e.getPlayer(); GameObject obj = e.getObject(); GenericAttribMap attr = p.getQuestManager().getAttribs(Quest.DRAGON_SLAYER); if (p.getX() > obj.getX()) { p.startConversation(new Conversation(e.getPlayer()) { { addPlayer(HeadE.SCARED, ""It appears to be locked from the outside, I am trapped!""); create(); } }); return; } if (p.getQuestManager().getStage(Quest.DRAGON_SLAYER) != PREPARE_FOR_CRANDOR) return; if (attr.getB(DOOR_BOMB_ATTR) && attr.getB(DOOR_BOWL_ATTR) && attr.getB(DOOR_SILK_ATTR) && attr.getB(DOOR_CAGE_ATTR)) { obj.animate(new Animation(6636)); WorldTasks.scheduleLooping(new Task() { int tick; @Override public void run() { if (tick == 0) p.lock(); if (tick == 1) p.walkToAndExecute(Tile.of(3050, 9840, 0), () -> { p.faceEast(); tick++; }); if (tick == 2) { p.sendMessage(""The magic door opens...""); obj.animate(new Animation(6636)); } if (tick == 3) p.addWalkSteps(Tile.of(3051, 9840, 0), 3, false); if (tick == 5) obj.animate(new Animation(6637)); if (tick == 7) { p.unlock(); stop(); } if (tick != 1) tick++; } }, 0, 1); } else p.startConversation(new Conversation(e.getPlayer()) { { addPlayer(HeadE.SKEPTICAL_THINKING, ""It appears to be magically locked...""); create(); } }); }); public static ObjectClickHandler handleMagicChest = new ObjectClickHandler(new Object[]{MAP_CHEST2}, e -> { Player p = e.getPlayer(); GameObject obj = e.getObject(); if (p.getQuestManager().getStage(Quest.DRAGON_SLAYER) != PREPARE_FOR_CRANDOR) return; if (p.getInventory().containsItem(MAP_PART3, 1)) { p.startConversation(new Conversation(e.getPlayer()) { { addPlayer(HeadE.SKEPTICAL_THINKING, ""The chest is empty...""); create(); } }); return; } p.startConversation(new Conversation(e.getPlayer()) { { addSimple(""As you open the chest you notice an inscription on the lid.""); addSimple(""Here, I rest the map of my beloved home. To whoever finds it, I beg of you, let it be. I was honour-bound not to destroy the "" + ""map piece, but I have used all of my magical skill to keep it from being recovered.""); addSimple(""But revenge would not benefit me now, and to disturb this beast is to risk bringing its wrath down upon another land. "" + ""This map leads to the lair of the beast that destroyed my home, devoured my family, and burned to a cinder all that I love.""); addSimple(""I cannot stop you from taking this map piece now, but think on this: if you can slay the Dragon of Crandor, you are a "" + ""greater hero than my land ever produced. There is no shame in backing out now.""); addNext(() -> { p.setNextAnimation(new Animation(536)); p.lock(2); GameObject openedChest = new GameObject(obj.getId() + 1, obj.getType(), obj.getRotation(), obj.getX(), obj.getY(), obj.getPlane()); p.faceObject(openedChest); World.spawnObjectTemporary(openedChest, Ticks.fromSeconds(4)); p.getInventory().addItem(new Item(MAP_PART3, 1), true); }); create(); } }); }); static final int SILK = 950; static final int BOMB = 1907; static final int BOWL = 1791; static final int CAGE = 13431; public static ItemOnObjectHandler itemOnMagicDoor = new ItemOnObjectHandler(new Object[]{25115}, new Object[]{SILK, BOMB, BOWL, CAGE, 301}, e -> { Player p = e.getPlayer(); GenericAttribMap attr = p.getQuestManager().getAttribs(Quest.DRAGON_SLAYER); if (e.getItem().getId() == SILK) if (attr.getB(DOOR_SILK_ATTR)) p.sendMessage(""Silk seems to have been used on the door...""); else { attr.setB(DOOR_SILK_ATTR, true); p.getInventory().removeItems(new Item(SILK, 1)); p.sendMessage(""The door consumes the silk...""); } if (e.getItem().getId() == BOMB) if (attr.getB(DOOR_BOMB_ATTR)) p.sendMessage(""A wizard mind bomb seems to have been used on the door...""); else { attr.setB(DOOR_BOMB_ATTR, true); p.getInventory().removeItems(new Item(BOMB, 1)); p.sendMessage(""You pour the wizard mind bomb on the door...""); } if (e.getItem().getId() == BOWL) if (attr.getB(DOOR_BOWL_ATTR)) p.sendMessage(""A bowl seems to have been used on the door...""); else { attr.setB(DOOR_BOWL_ATTR, true); p.getInventory().removeItems(new Item(BOWL, 1)); p.sendMessage(""You place the unfired bowl on the door...""); } if (e.getItem().getId() == CAGE || e.getItem().getId() == 301) if (attr.getB(DOOR_CAGE_ATTR)) p.sendMessage(""The cage seems to have been used on the door...""); else { attr.setB(DOOR_CAGE_ATTR, true); p.getInventory().removeItems(new Item(CAGE, 1)); p.sendMessage(""The door consumes the cage...""); } }); public static void introduceElvarg(Player p) { WorldTasks.scheduleLooping(new Task() { int tick; @Override public void run() { if (tick == 0) { // setup p1 p.lock(); p.getInterfaceManager().setFadingInterface(115); p.getPackets().setBlockMinimapState(2); } if (tick == 3) {// setup p2, move p p.getAppearance().setHidden(true); p.tele(Tile.of(2845, 9636, 0)); } if (tick == 5) {// setup p3, camera p.getPackets().sendCameraPos(p.getXInScene(p.getSceneBaseChunkId()), p.getYInScene(p.getSceneBaseChunkId()), 1300); p.getPackets().sendCameraLook(p.getXInScene(p.getSceneBaseChunkId()) + 4, p.getYInScene(p.getSceneBaseChunkId()) - 4, 50); } if (tick == 6) {// start scene p.getInterfaceManager().setFadingInterface(170); p.getPackets().sendCameraPos(p.getXInScene(p.getSceneBaseChunkId()) + 10, p.getYInScene(p.getSceneBaseChunkId()) + 7, 1400); p.getPackets().sendCameraLook(p.getXInScene(p.getSceneBaseChunkId()) + 10, p.getYInScene(p.getSceneBaseChunkId()) + 12, 1300); p.getPackets().sendCameraPos(p.getXInScene(p.getSceneBaseChunkId()) + 10, p.getYInScene(p.getSceneBaseChunkId()) + 3, 1400, 0, 4); } if (tick == 10) { p.getPackets().sendCameraPos(p.getXInScene(p.getSceneBaseChunkId()) + 14, p.getYInScene(p.getSceneBaseChunkId()) + 9, 3000); p.getPackets().sendCameraLook(p.getXInScene(p.getSceneBaseChunkId()) + 11, p.getYInScene(p.getSceneBaseChunkId()) + 4, 1200); } if (tick == 15) p.getInterfaceManager().setFadingInterface(115); if (tick == 18) { p.tele(Tile.of(2834, 9657, 0)); p.getPackets().sendResetCamera(); } if (tick == 21) {// closing p2 p.getAppearance().setHidden(false); p.getInterfaceManager().setFadingInterface(170); p.getPackets().setBlockMinimapState(0); p.getQuestManager().getAttribs(Quest.DRAGON_SLAYER).setB(INTRODUCED_ELVARG_ATTR, true); p.unlock(); stop(); } tick++; } }, 0, 1); } public static boolean hasHeadAlready(Player player) { return player.getInventory().containsItem(ELVARG_HEAD, 1) || player.getBank().containsItem(ELVARG_HEAD); } @Override public void complete(Player player) { player.getSkills().addXpQuest(Constants.STRENGTH, 18650); player.getSkills().addXpQuest(Constants.DEFENSE, 18650); sendQuestCompleteInterface(player, 11279); } }" "package com.rs.game.content.quests.dragonslayer; public class DragonSlayer_BoatScene extends Controller { Instance instance; Tile startingTile; Tile crandor = Tile.of(2849, 3239, 0); NPC captainNed; NPC cabinboyJenkins; //constants int TRAVEL_INTERFACE = 299; int BOAT_TO_CRANDOR = 544; int HAPPY_TRAVEL_JINGLE = 350; //Custom for this cutscene int CAPTAIN_NED = 6084; int CABIN_BOY_JENKINS = 6085; int ANIM_JENKINS_SHAKE = 2105; int ANIM_NED_FEAR = 4280; int ANIM_JENKINS_FEAR = 6649; int ANIM_JENKINS_DIE = 836; int ANIM_PLAYER_GET_UP = 4191; @Override public boolean playAmbientOnControllerRegionEnter() { return false; } @Override public boolean playAmbientMusic() { return false; } @Override public void start() { startingTile = Tile.of(player.getX(), player.getY(), player.getPlane()); player.getPackets().setBlockMinimapState(2); player.lock(); player.getTempAttribs().setB(""CUTSCENE_INTERFACE_CLOSE_DISABLED"", true); playCutscene(); } private void closeInterfaces() { player.getInterfaceManager().closeFadingInterface(); player.getInterfaceManager().removeCentralInterface(); } private void playCutscene() { instance = Instance.of(crandor, 8, 8); instance.copyMapAllPlanes(256, 688).thenAccept(e -> { captainNed = World.spawnNPC(CAPTAIN_NED, instance.getLocalTile(18, 13, 1), -1, false, true); cabinboyJenkins = World.spawnNPC(CABIN_BOY_JENKINS, instance.getLocalTile(15, 14, 1), -1, false, true); WorldTasks.scheduleLooping(new Task() { int tick = 0; final int PAUSE_FOR_NED1 = 14; final int PAUSE_FOR_PLAYER1 = 15; final int PAUSE_FOR_NED2 = 16; final int PAUSE_FOR_NED3 = 22; final int PAUSE_FOR_PLAYER2 = 25; final int PAUSE_FOR_NED4 = 26; final int PAUSE_FOR_PLAYER3 = 27; final int PAUSE_FOR_NED5 = 42; final int PAUSE_FOR_PLAYER4 = 43; final int PAUSE_FOR_NED6 = 45; final int PAUSE_FOR_PLAYER5 = 52; @Override public void run() { if (tick == 0) { //setup p1 player.getInterfaceManager().setFadingInterface(115); //for interfaces over interfaces do this player.musicTrack(HAPPY_TRAVEL_JINGLE, 5); } if (tick == 3) { player.getInterfaceManager().setFadingInterface(516); player.getPackets().setBlockMinimapState(2); player.getInterfaceManager().sendInterface(TRAVEL_INTERFACE); player.getPackets().setIFHidden(TRAVEL_INTERFACE, 44, false); } if (tick == 9) { player.getInterfaceManager().sendInterface(BOAT_TO_CRANDOR); player.tele(instance.getLocalTile(18, 12, 1)); } if (tick == 11) { player.faceEntity(captainNed); captainNed.setNextFaceTile(Tile.of(captainNed.getX()+1, captainNed.getY(), captainNed.getPlane())); player.getInterfaceManager().setFadingInterface(170); closeInterfaces(); player.getPackets().sendCameraShake(1, 0, 8, 5, 8); player.getPackets().sendCameraPos(Tile.of(instance.getLocalX(28), instance.getLocalY(14), 0), 0); player.getPackets().sendCameraLook(Tile.of(instance.getLocalX(21), instance.getLocalY(13), 0), 0); player.getPackets().sendCameraPos(Tile.of(instance.getLocalX(26), instance.getLocalY(13), 0), 600, 0, 4); player.startConversation(new Conversation(player) { { addNPC(CAPTAIN_NED, HeadE.HAPPY_TALKING, ""Ah, it's good to feel the salt spray on my face once again!""); } }); } if(tick == PAUSE_FOR_NED1) { player.getPackets().sendCameraPos(Tile.of(instance.getLocalX(26), instance.getLocalY(9), 0), 2050, 0, 2); player.startConversation(new Conversation(player) { { addNPC(CAPTAIN_NED, HeadE.HAPPY_TALKING, ""And this is a mighty fine ship. She don't look much but she handles like a dream.""); addNext(() -> tick++); create(); } }); } if(tick == PAUSE_FOR_PLAYER1) player.startConversation(new Conversation(player) { { addPlayer(HeadE.CALM_TALK, ""How much longer until we reach Crandor?""); addNext(()-> tick++); create(); } }); if(tick == PAUSE_FOR_NED2) player.startConversation(new Conversation(player) { { addNPC(CAPTAIN_NED, HeadE.HAPPY_TALKING, ""Not long now! According to the chart, we'd be able to see Crandor if it wasn't for "" + ""the clouds on the horizon.""); addNext(()-> tick++); create(); } }); if(tick == 17) { player.musicTrack(360, 10); //Elvarg's theme player.startConversation(new Conversation(player) { { addSimple(""Clouds surround the ship.""); } }); player.getInterfaceManager().setFadingInterface(543); } if(tick == 18) player.getPackets().sendStopCameraShake(); if(tick == 19) { closeInterfaces(); player.setNextFaceTile(Tile.of(cabinboyJenkins.getX(), cabinboyJenkins.getY(), cabinboyJenkins.getPlane())); cabinboyJenkins.setForceWalk(Tile.of(captainNed.getX(), captainNed.getY()+1, cabinboyJenkins.getPlane())); player.startConversation(new Conversation(player) { { addNPC(CABIN_BOY_JENKINS, HeadE.HAPPY_TALKING, ""Looks like there's a storm coming up, cap'n. Soon we won't be able to see anything!""); } }); player.getPackets().sendCameraPos(Tile.of(instance.getLocalX(23), instance.getLocalY(21), 0), 5000); player.getPackets().sendCameraLook(Tile.of(instance.getLocalX(14), instance.getLocalY(14), 0), 0); player.getPackets().sendCameraPos(Tile.of(instance.getLocalX(18), instance.getLocalY(21), 0), 5000, 0, 2); } if(tick == PAUSE_FOR_NED3) { captainNed.setNextFaceTile(Tile.of(captainNed.getX(), captainNed.getY()+1, captainNed.getPlane())); player.setNextFaceTile(Tile.of(player.getX(), player.getY()+1, player.getPlane())); cabinboyJenkins.faceEntity(captainNed); player.startConversation(new Conversation(player) { { addNPC(CAPTAIN_NED, HeadE.HAPPY_TALKING, ""Oh, well. The weather had been so good up until now."", () -> {}); addNext(()-> tick++); create(); } }); } if(tick == 23) player.getInterfaceManager().setFadingInterface(545); if(tick == 24) closeInterfaces(); if(tick == PAUSE_FOR_PLAYER2) player.startConversation(new Conversation(player) { { addPlayer(HeadE.SCARED, ""Did you see that?""); addNext(()-> tick++); create(); } }); if(tick == PAUSE_FOR_NED4) player.startConversation(new Conversation(player) { { addNPC(CAPTAIN_NED, HeadE.CALM_TALK, ""See what?"", () -> {}); addNext(()-> tick++); create(); } }); if(tick == PAUSE_FOR_PLAYER3) player.startConversation(new Conversation(player) { { addPlayer(HeadE.SCARED, ""I thought I saw something above us.""); addNext(()-> tick++); create(); } }); if(tick == 28) { player.getPackets().sendCameraPos(Tile.of(instance.getLocalX(24), instance.getLocalY(13), 0), 1150); player.getPackets().sendCameraLook(Tile.of(instance.getLocalX(18), instance.getLocalY(13), 0), 0); player.getPackets().sendCameraPos(Tile.of(instance.getLocalX(24), instance.getLocalY(19), 0), 1150, 0, 3); } if(tick == 29) { Tile tile = Tile.of(instance.getLocalX(17), instance.getLocalY(12), 1); captainNed.faceTile(tile); player.faceTile(tile); cabinboyJenkins.faceTile(tile); World.sendProjectile(Tile.of(tile.getX(), tile.getY()-3, tile.getPlane()), tile, 1155, 99, 0, 0, 0.5, 0, proj -> WorldTasks.scheduleLooping(new Task() { int tick; @Override public void run() { if (tick == 0) { World.sendSpotAnim(Tile.of(tile.getX(), tile.getY(), tile.getPlane()), new SpotAnim(1154)); World.sendSpotAnim(Tile.of(tile.getX(), tile.getY(), tile.getPlane()), new SpotAnim(2588)); } if (tick > 1) World.sendSpotAnim(Tile.of(tile.getX(), tile.getY(), tile.getPlane()), new SpotAnim(453)); if(instance.isDestroyed() || tick == 80) stop(); tick++; } }, 0, 1)); } if(tick==30) { player.startConversation(new Conversation(player) { { addNPC(CAPTAIN_NED, HeadE.CALM_TALK, ""It's the dragon!"", () -> {}); create(); } }); Tile tile = Tile.of(instance.getLocalX(16), instance.getLocalY(12), 1); World.sendProjectile(Tile.of(tile.getX(), tile.getY()-3, tile.getPlane()), tile, 1155, 99, 0, 0, 0.5, 0, proj -> WorldTasks.scheduleLooping(new Task() { int tick; @Override public void run() { if (tick == 0) { World.sendSpotAnim(Tile.of(tile.getX(), tile.getY(), tile.getPlane()), new SpotAnim(1154)); World.sendSpotAnim(Tile.of(tile.getX(), tile.getY(), tile.getPlane()), new SpotAnim(2588)); } if (tick > 1) World.sendSpotAnim(Tile.of(tile.getX(), tile.getY(), tile.getPlane()), new SpotAnim(453)); if(instance.isDestroyed() || tick == 80) stop(); tick++; } }, 0, 1)); } if(tick == 31) { Tile tile = Tile.of(instance.getLocalX(15), instance.getLocalY(12), 1); World.sendProjectile(Tile.of(tile.getX(), tile.getY()-3, tile.getPlane()), tile, 1155, 99, 0, 0, 0.5, 0, proj -> WorldTasks.scheduleLooping(new Task() { int tick; @Override public void run() { if (tick == 0) { World.sendSpotAnim(Tile.of(tile.getX(), tile.getY(), tile.getPlane()), new SpotAnim(1154)); World.sendSpotAnim(Tile.of(tile.getX(), tile.getY(), tile.getPlane()), new SpotAnim(2588)); } if (tick > 1) World.sendSpotAnim(Tile.of(tile.getX(), tile.getY(), tile.getPlane()), new SpotAnim(453)); if(instance.isDestroyed() || tick == 80) stop(); tick++; } }, 0, 1)); } if(tick == 32) { player.getInterfaceManager().setFadingInterface(546); Tile tile = Tile.of(instance.getLocalX(13), instance.getLocalY(12), 1); int fireHeight = 500; World.sendProjectile(Tile.of(tile.getX(), tile.getY()-3, tile.getPlane()), tile, 1155, 99, 0, 0, 0.5, 0, proj -> WorldTasks.scheduleLooping(new Task() { int tick; @Override public void run() { if (tick == 0) { World.sendSpotAnim(Tile.of(tile.getX(), tile.getY(), tile.getPlane()), new SpotAnim(1154)); World.sendSpotAnim(Tile.of(tile.getX(), tile.getY(), tile.getPlane()), new SpotAnim(2588)); } if (tick > 1) World.sendSpotAnim(Tile.of(tile.getX(), tile.getY(), tile.getPlane()), new SpotAnim(453, 0, fireHeight)); if(instance.isDestroyed() || tick == 80) stop(); tick++; } }, 0, 1)); } if(tick == 34) { player.getPackets().sendCameraShake(1, 0, 8, 5, 8); player.getPackets().sendCameraPos(Tile.of(instance.getLocalX(19), instance.getLocalY(14), 0), 1200); player.getPackets().sendCameraLook(Tile.of(instance.getLocalX(17), instance.getLocalY(14), 0), 700); player.getPackets().sendCameraPos(Tile.of(instance.getLocalX(26), instance.getLocalY(14), 0), 1200, 0, 3); closeInterfaces(); Tile tile = Tile.of(instance.getLocalX(13), instance.getLocalY(14), 1); captainNed.faceTile(tile); cabinboyJenkins.faceTile(tile); int fireHeight = 500; World.sendProjectile(Tile.of(tile.getX(), tile.getY()+3, tile.getPlane()), tile, 1155, 99, 0, 0, 0.5, 0, proj -> WorldTasks.scheduleLooping(new Task() { int tick; @Override public void run() { if (tick == 0) { World.sendSpotAnim(Tile.of(tile.getX(), tile.getY(), tile.getPlane()), new SpotAnim(1154, fireHeight)); World.sendSpotAnim(Tile.of(tile.getX(), tile.getY(), tile.getPlane()), new SpotAnim(2588, fireHeight)); } if (tick > 1) World.sendSpotAnim(Tile.of(tile.getX(), tile.getY(), tile.getPlane()), new SpotAnim(453, 0, fireHeight)); if(instance.isDestroyed() || tick == 80) stop(); tick++; } }, 0, 1)); } if(tick == 35) { Tile tile = Tile.of(instance.getLocalX(15), instance.getLocalY(14), 1); int fireHeight = 0; World.sendProjectile(Tile.of(tile.getX(), tile.getY()+3, tile.getPlane()), tile, 1155, 99, 0, 0, 0.5, 0, proj -> WorldTasks.scheduleLooping(new Task() { int tick; @Override public void run() { if (tick == 0) { World.sendSpotAnim(Tile.of(tile.getX(), tile.getY(), tile.getPlane()), new SpotAnim(1154, fireHeight)); World.sendSpotAnim(Tile.of(tile.getX(), tile.getY(), tile.getPlane()), new SpotAnim(2588, fireHeight)); cabinboyJenkins.setNextAnimation(new Animation(ANIM_JENKINS_SHAKE)); } if (tick > 1) World.sendSpotAnim(Tile.of(tile.getX(), tile.getY(), tile.getPlane()), new SpotAnim(453, 0, fireHeight)); if(instance.isDestroyed() || tick == 80) stop(); tick++; } }, 0, 1)); } if(tick == 36) { Tile tile = Tile.of(instance.getLocalX(16), instance.getLocalY(14), 1); int fireHeight = 0; World.sendProjectile(Tile.of(tile.getX(), tile.getY()+3, tile.getPlane()), tile, 1155, 99, 0, 0, 0.5, 0, proj -> WorldTasks.scheduleLooping(new Task() { int tick; @Override public void run() { if (tick == 0) { World.sendSpotAnim(Tile.of(tile.getX(), tile.getY(), tile.getPlane()), new SpotAnim(1154, fireHeight)); World.sendSpotAnim(Tile.of(tile.getX(), tile.getY(), tile.getPlane()), new SpotAnim(2588, fireHeight)); captainNed.setNextAnimation(new Animation(ANIM_NED_FEAR)); } if (tick > 1) World.sendSpotAnim(Tile.of(tile.getX(), tile.getY(), tile.getPlane()), new SpotAnim(453, 0, fireHeight)); if(instance.isDestroyed() || tick == 80) stop(); tick++; } }, 0, 1)); } if(tick == 37) { Tile tile = Tile.of(instance.getLocalX(17), instance.getLocalY(14), 1); int fireHeight = 0; World.sendProjectile(Tile.of(tile.getX(), tile.getY()+3, tile.getPlane()), tile, 1155, 99, 0, 0, 0.5, 0, proj -> WorldTasks.scheduleLooping(new Task() { int tick; @Override public void run() { if (tick == 0) { World.sendSpotAnim(Tile.of(tile.getX(), tile.getY(), tile.getPlane()), new SpotAnim(1154, fireHeight)); World.sendSpotAnim(Tile.of(tile.getX(), tile.getY(), tile.getPlane()), new SpotAnim(2588, fireHeight)); cabinboyJenkins.setNextAnimation(new Animation(ANIM_JENKINS_FEAR)); } if (tick > 1) World.sendSpotAnim(Tile.of(tile.getX(), tile.getY(), tile.getPlane()), new SpotAnim(453, 0, fireHeight)); if(instance.isDestroyed() || tick == 80) stop(); tick++; } }, 0, 1)); } if(tick == 38) { Tile tile = Tile.of(instance.getLocalX(18), instance.getLocalY(14), 1); int fireHeight = 0; World.sendProjectile(Tile.of(tile.getX(), tile.getY()+3, tile.getPlane()), tile, 1155, 99, 0, 0, 0.5, 0, proj -> WorldTasks.scheduleLooping(new Task() { int tick; @Override public void run() { if (tick == 0) { cabinboyJenkins.setNextAnimation(new Animation(ANIM_JENKINS_DIE)); World.sendSpotAnim(Tile.of(tile.getX(), tile.getY(), tile.getPlane()), new SpotAnim(1154, fireHeight)); World.sendSpotAnim(Tile.of(tile.getX(), tile.getY(), tile.getPlane()), new SpotAnim(2588, fireHeight)); } if (tick > 1) World.sendSpotAnim(Tile.of(tile.getX(), tile.getY(), tile.getPlane()), new SpotAnim(453, 0, fireHeight)); if(instance.isDestroyed() || tick == 80) stop(); tick++; } }, 0, 1)); } if(tick == 39) { Tile tile = Tile.of(instance.getLocalX(19), instance.getLocalY(14), 1); int fireHeight = 0; World.sendProjectile(Tile.of(tile.getX(), tile.getY()+3, tile.getPlane()), tile, 1155, 99, 0, 0, 0.5, 0, proj -> WorldTasks.scheduleLooping(new Task() { int tick; @Override public void run() { if (tick == 0) { World.sendSpotAnim(Tile.of(tile.getX(), tile.getY(), tile.getPlane()), new SpotAnim(1154, fireHeight)); World.sendSpotAnim(Tile.of(tile.getX(), tile.getY(), tile.getPlane()), new SpotAnim(2588, fireHeight)); } if (tick > 1) World.sendSpotAnim(Tile.of(tile.getX(), tile.getY(), tile.getPlane()), new SpotAnim(453, 0, fireHeight)); if(instance.isDestroyed() || tick == 80) stop(); tick++; } }, 0, 1)); } if(tick == 40) { Tile tile = Tile.of(instance.getLocalX(41), instance.getLocalY(14), 1); int fireHeight = 0; World.sendProjectile(Tile.of(tile.getX(), tile.getY()+3, tile.getPlane()), tile, 1155, 99, 0, 0, 0.5, 0, proj -> WorldTasks.scheduleLooping(new Task() { int tick; @Override public void run() { if (tick == 0) { World.sendSpotAnim(Tile.of(tile.getX(), tile.getY(), tile.getPlane()), new SpotAnim(1154, fireHeight)); World.sendSpotAnim(Tile.of(tile.getX(), tile.getY(), tile.getPlane()), new SpotAnim(2588, fireHeight)); } if (tick > 1) World.sendSpotAnim(Tile.of(tile.getX(), tile.getY(), tile.getPlane()), new SpotAnim(453, 0, fireHeight)); if(instance.isDestroyed() || tick == 80) stop(); tick++; } }, 0, 1)); } if(tick == 41) { player.getPackets().sendCameraPos(Tile.of(instance.getLocalX(34), instance.getLocalY(14), 0), 1900); player.getPackets().sendCameraLook(Tile.of(instance.getLocalX(17), instance.getLocalY(14), 0), 700); player.getPackets().sendCameraPos(Tile.of(instance.getLocalX(28), instance.getLocalY(14), 0), 1200, 0, 3); } if(tick == PAUSE_FOR_NED5) player.startConversation(new Conversation(player) { { addNPC(CAPTAIN_NED, HeadE.CALM_TALK, ""We're going to sink!"", () -> {}); addNext(()->{ captainNed.faceEntity(player); player.setNextFaceTile(Tile.of(player.getX()+1, player.getY(), player.getPlane())); tick++; }); create(); } }); if(tick == PAUSE_FOR_PLAYER4) player.startConversation(new Conversation(player) { { addPlayer(HeadE.SCARED, ""Look! Land ahead!""); addNext(()-> tick++); create(); } }); if(tick == 44) { player.getPackets().sendCameraPos(Tile.of(instance.getLocalX(20), instance.getLocalY(14), 0), 1200, 0, 3); player.faceEntity(captainNed); captainNed.setNextFaceTile(Tile.of(captainNed.getX()+1, captainNed.getY(), captainNed.getPlane())); } if(tick == PAUSE_FOR_NED6) player.startConversation(new Conversation(player) { { addNPC(CAPTAIN_NED, HeadE.CALM_TALK, ""We're going to crash!"", () -> {}); addNext(()-> tick++); create(); } }); if(tick == 46) { player.getPackets().sendCameraShake(1, 5, 8, 25, 8); player.startConversation(new Conversation(player) { { addSimple(""CRASH!""); create(); } }); } if(tick == 48) player.getInterfaceManager().setFadingInterface(115); if(tick == 51) { player.getInterfaceManager().setFadingInterface(516); player.tele(crandor);//crandor } if(tick == PAUSE_FOR_PLAYER5) { player.setNextFaceTile(Tile.of(player.getX(), player.getY()+1, player.getPlane()));//face north player.getPackets().sendStopCameraShake(); player.getPackets().sendResetCamera(); player.startConversation(new Conversation(player) { { addSimple(""You are knocked unconscious and later awake on an ash-shrewn beach.""); addNext(()-> tick++); create(); } }); } if(tick == 53) { player.musicTrack(170, 5);//crandor music player.setNextAnimation(new Animation(ANIM_PLAYER_GET_UP)); player.getInterfaceManager().setFadingInterface(170); } if(tick== 54) { } if (tick == 60) { closeInterfaces(); player.getQuestManager().getAttribs(Quest.DRAGON_SLAYER).setB(DragonSlayer.FINISHED_BOAT_SCENE_ATTR, true); player.getControllerManager().forceStop(); stop(); } if(tick == PAUSE_FOR_NED1 || tick == PAUSE_FOR_NED2 || tick == PAUSE_FOR_NED3 || tick == PAUSE_FOR_NED4 || tick == PAUSE_FOR_NED5 || tick == PAUSE_FOR_NED6 || tick == PAUSE_FOR_PLAYER1 || tick == PAUSE_FOR_PLAYER2 || tick == PAUSE_FOR_PLAYER3 || tick == PAUSE_FOR_PLAYER4 || tick == PAUSE_FOR_PLAYER5) ; else tick++; } }, 0, 1); }); } @Override public boolean sendDeath() { forceClose(); return false; } @Override public boolean login() { player.getTempAttribs().setB(""CUTSCENE_INTERFACE_CLOSE_DISABLED"", false); player.tele(startingTile); forceClose(); return false; } @Override public boolean logout() { removeInstance(); player.unlock(); return false; } @Override public void forceClose() { player.getTempAttribs().setB(""CUTSCENE_INTERFACE_CLOSE_DISABLED"", false); player.getPackets().setBlockMinimapState(0); removeInstance(); player.unlock(); removeController(); } private void removeInstance() { captainNed.finish(); cabinboyJenkins.finish(); instance.destroy(); } }" "package com.rs.game.content.quests.dragonslayer; @PluginEventHandler public class ElvargBoss extends NPC { private static final int ELVARG_ID = 742; private static final int ELVARG_OBJ = 25202; private static final int ELVARG_HEADLESS_OBJ = 25203; private static final int ELVARG_DEATH_ANIM = 14260; private static final int ELVARG_REMOVE_HEAD_ANIM = 6654; private static final int ELVARG_SHOW_OFF_HEAD_ANIM = 6655; public ElvargBoss(Tile tile) { super(ELVARG_ID, tile); } @Override public boolean canBeAttackedBy(Player player) { int dragonSlayerStage = player.getQuestManager().getStage(Quest.DRAGON_SLAYER); if (dragonSlayerStage >= PREPARE_FOR_CRANDOR && dragonSlayerStage <= REPORT_TO_OZIACH && hasHeadAlready(player)) { player.cancelFaceEntityNoCheck(); player.sendMessage(""That's not very nice!""); return false; } return true; } @Override public boolean canAggroPlayer(Player player) { int dragonSlayerStage = player.getQuestManager().getStage(Quest.DRAGON_SLAYER); if (dragonSlayerStage >= PREPARE_FOR_CRANDOR && dragonSlayerStage <= REPORT_TO_OZIACH && hasHeadAlready(player)) { return false; } return true; } @Override public void sendDeath(Entity source) { if(source instanceof Player p) { p.lock(); ElvargBoss elvarg = this; removeTarget(); elvarg.setCantInteract(true); WorldTasks.scheduleLooping(new Task() { int tick = 0; final int WALK_TO_TILE_TICK = 7; Tile animTile; GameObject elvargObj = null; @Override public void run() { if(tick == 0) { elvarg.walkToAndExecute(Tile.of(2854, 9638, 0), () -> { animTile = Tile.of(elvarg.getX() - 1, elvarg.getY() + 1, elvarg.getPlane()); elvarg.setNextFaceTile(Tile.of(getX() - 1, getY() + 1, getPlane())); tick++; }); } if (tick == 2) setNextAnimation(new Animation(ELVARG_DEATH_ANIM)); if(tick == 5) { elvarg.setCantInteract(false); elvarg.setRespawnTask(200); elvargObj = new GameObject(ELVARG_OBJ, ObjectDefinitions.getDefs(ELVARG_HEADLESS_OBJ).types[0], Direction.rotateClockwise(Direction.WEST, 4).id /2, 2854, 9638, 0); World.spawnObject(elvargObj); } if(tick == WALK_TO_TILE_TICK) p.walkToAndExecute(animTile, () -> { p.faceObject(elvargObj); tick++; }); if(tick == 9) p.setNextAnimation(new Animation(ELVARG_REMOVE_HEAD_ANIM)); if(tick == 10) { } if(tick == 11) { World.removeObject(elvargObj); elvargObj = new GameObject(ELVARG_HEADLESS_OBJ, ObjectDefinitions.getDefs(ELVARG_HEADLESS_OBJ).types[0], Direction.rotateClockwise(Direction.WEST, 4).id /2, 2854, 9638, 0); World.spawnObjectTemporary(elvargObj, 150); int dragonSlayerStage = p.getQuestManager().getStage(Quest.DRAGON_SLAYER); if(dragonSlayerStage >= PREPARE_FOR_CRANDOR && dragonSlayerStage <= REPORT_TO_OZIACH && !hasHeadAlready(p)) { p.getInventory().addItem(new Item(ELVARG_HEAD, 1), true); p.getQuestManager().setStage(Quest.DRAGON_SLAYER, REPORT_TO_OZIACH); } p.setNextAnimation(new Animation(ELVARG_SHOW_OFF_HEAD_ANIM)); } if(tick == 13) { p.getPackets().sendResetCamera(); p.unlock(); stop(); } if(tick != WALK_TO_TILE_TICK && tick != 0) tick++; } }, 0, 1); } } public static NPCInstanceHandler toFunc = new NPCInstanceHandler(ELVARG_ID, (npcId, tile) -> new ElvargBoss(tile)); }" "package com.rs.game.content.quests.dragonslayer; @PluginEventHandler public class GuildMasterDragonSlayerD extends Conversation { private final int MAIN_OPTIONS = 0; private final int ROUTE_TO_CRANDOR = 1; private final int WHERE_IS_THALZAR = 2; private final int WHERE_IS_LOZAR = 3; private final int WHERE_IS_MELZAR = 4; private final int BUYING_SHIP = 5; private final int DRAGON_BREATH = 6; public GuildMasterDragonSlayerD(Player p) { super(p); switch(p.getQuestManager().getStage(Quest.DRAGON_SLAYER)) { case NOT_STARTED -> { addPlayer(HeadE.SKEPTICAL_THINKING, ""Can I have a quest?""); addNPC(GUILD_MASTER, HeadE.CALM_TALK, ""Aha! Yes! A mighty and perilous quest fit for the most powerful champions! And, at the end of it, "" + ""you will earn the right to wear the legendary rune platebody!""); addOptions(""Start Dragon Slayer?"", new Options() { @Override public void create() { option(""Yes"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""So, what is this quest?"") .addNPC(GUILD_MASTER, HeadE.CALM_TALK, ""You'll have to speak to Oziach, the maker of rune armour. He sets the quests that "" + ""champions must complete in order to wear it. Oziach lives in a hut by the cliffs to the west of Edgeville. He can be a "" + ""little ... odd ... sometimes, though."", ()-> p.getQuestManager().setStage(Quest.DRAGON_SLAYER, TALK_TO_OZIACH))); option(""No"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""On second thoughts, a mighty and perilous quest fit only for the most powerful champions "" + ""isn't something I want to commit to at the moment. Maybe later."") .addNPC(GUILD_MASTER, HeadE.CALM_TALK, ""Very well. Return when are ready"")); } }); } case TALK_TO_OZIACH -> { addPlayer(HeadE.HAPPY_TALKING, ""Can I have a quest?""); addNPC(GUILD_MASTER, HeadE.CALM_TALK, ""You're already on a quest for me, if I recall correctly. Have you talked to Oziach yet?""); addPlayer(HeadE.HAPPY_TALKING, ""No, not yet.""); addNPC(GUILD_MASTER, HeadE.CALM_TALK, ""Well, he's the only one who can grant you the right to wear rune platemail. He lives in a hut, "" + ""by the cliffs west of Edgeville.""); addPlayer(HeadE.HAPPY_TALKING, ""Okay I'll go and talk to him.""); } case TALK_TO_GUILDMASTER -> { if(!p.getQuestManager().getAttribs(Quest.DRAGON_SLAYER).getB(STARTED_DIALOGUE_GUILDMASTER_ATTR)) { addPlayer(HeadE.HAPPY_TALKING, ""I talked to Oziach ... and he gave me a quest.""); addNPC(GUILD_MASTER, HeadE.CALM_TALK, ""Oh? What did he tell you to do?""); addPlayer(HeadE.HAPPY_TALKING, ""Defeat the dragon of Crandor.""); addNPC(GUILD_MASTER, HeadE.CALM_TALK, ""The dragon of Crandor?""); addPlayer(HeadE.HAPPY_TALKING, ""Um, yes ...""); } addNPC(GUILD_MASTER, HeadE.CALM_TALK, ""Goodness, he hasn't given you an easy job, has he?""); addPlayer(HeadE.HAPPY_TALKING, ""What's so special about this dragon?""); addNPC(GUILD_MASTER, HeadE.CALM_TALK, ""Thirty years ago, Crandor was a thriving community with a great tradition of mages and adventurers. "" + ""Many Crandorians even earned the right to be part of the Champions' Guild! One of their adventurers went too far, however.""); addNPC(GUILD_MASTER, HeadE.CALM_TALK, ""He descended into the volcano in the centre of Crandor and woke the dragon Elvarg. He must have "" + ""fought valiantly against the dragon because they say that, to this day, she has a scar down her side.""); addNPC(GUILD_MASTER, HeadE.CALM_TALK, ""But the dragon still won the fight. She emerged and laid waste to the whole of Crandor with her fire "" + ""breath! Some refugees managed to escape in fishing boats.""); addNPC(GUILD_MASTER, HeadE.CALM_TALK, ""They landed on the coast, north of Rimmington, and set up camp but the dragon followed them and burned "" + ""the camp to the ground. Out of all of the people of Crandor there were only three survivors: a trio of wizards who used magic to escape.""); addNPC(GUILD_MASTER, HeadE.CALM_TALK, ""Their names were Thalzar, Lozar, and Melzar. If you're serious about taking on Elvarg, first you'll need to "" + ""get to Crandor. The island is surrounded by dangerous reefs, so you'll need a ship capable of getting through them and a map to show you the way.""); addNPC(GUILD_MASTER, HeadE.CALM_TALK, ""When you reach Crandor, you'll also need some kind of protection against the dragon's breath.""); addNext(()->{ p.getQuestManager().getAttribs(Quest.DRAGON_SLAYER).setB(STARTED_DIALOGUE_GUILDMASTER_ATTR, true); p.startConversation(new GuildMasterDragonSlayerD(p, MAIN_OPTIONS, MAIN_OPTIONS).getStart()); }); } case PREPARE_FOR_CRANDOR -> { addPlayer(HeadE.HAPPY_TALKING, ""About my quest to kill the dragon..""); addNPC(GUILD_MASTER, HeadE.CALM_TALK, ""If you're serious about taking on Elvarg, first you'll need to get to Crandor. The island is surrounded"" + "" by dangerous reefs, so you'll need a ship capable of getting through them and a map to show you the way.""); addNPC(GUILD_MASTER, HeadE.CALM_TALK, ""When you reach Crandor, you'll also need some kind of protection against the dragon's breath.""); addNext(()-> p.startConversation(new GuildMasterDragonSlayerD(p, MAIN_OPTIONS, MAIN_OPTIONS).getStart())); } case REPORT_TO_OZIACH -> { addPlayer(HeadE.HAPPY_TALKING, ""I killed the dragon!""); addNPC(GUILD_MASTER, HeadE.CALM_TALK, ""Really? That's amazing! You are a true hero. There's no way that Oziach can refuse to sell you rune "" + ""platemail now. You should tell him at once!""); } case QUEST_COMPLETE -> { //Will not talk about Dragon Slayer } } } public GuildMasterDragonSlayerD(Player p, int convoID, int previousID) { super(p); mainOptions(p, previousID); } public GuildMasterDragonSlayerD(Player p, int convoID) { super(p); switch(convoID) { case ROUTE_TO_CRANDOR -> routeToCrandor(p); case WHERE_IS_THALZAR -> whereisThalzarMapPiece(p); case WHERE_IS_LOZAR -> whereisLozarMapPiece(p); case WHERE_IS_MELZAR -> whereisMelzarsMapPiece(p); case BUYING_SHIP -> buyingShip(p); case DRAGON_BREATH -> dragonBreath(p); } } private void mainOptions(Player p, int previous) { if(isFinished(p) && !p.getQuestManager().getAttribs(Quest.DRAGON_SLAYER).getB(FINISHED_DIALOGUE_GUILDMASTER_ATTR)) { p.getQuestManager().getAttribs(Quest.DRAGON_SLAYER).setB(FINISHED_DIALOGUE_GUILDMASTER_ATTR, true); p.getQuestManager().setStage(Quest.DRAGON_SLAYER, PREPARE_FOR_CRANDOR); } addOptions(""Choose an option:"", new Options() { @Override public void create() { if(p.getQuestManager().getAttribs(Quest.DRAGON_SLAYER).getB(KNOWS_MAP_EXISTS_ATTR)) { if(previous != WHERE_IS_THALZAR) option(""Where is Thalzar's map piece?"", new Dialogue() .addNext(()-> p.startConversation(new GuildMasterDragonSlayerD(p, WHERE_IS_THALZAR).getStart()))); if(previous != WHERE_IS_LOZAR) option(""Where is Lozar's map piece?"", new Dialogue() .addNext(()-> p.startConversation(new GuildMasterDragonSlayerD(p, WHERE_IS_LOZAR).getStart()))); if(previous != WHERE_IS_MELZAR) option(""Where is Melzar's map piece?"", new Dialogue() .addNext(()-> p.startConversation(new GuildMasterDragonSlayerD(p, WHERE_IS_MELZAR).getStart()))); } else option(""How can I find the route to Crandor?"", new Dialogue() .addNext(()-> p.startConversation(new GuildMasterDragonSlayerD(p, ROUTE_TO_CRANDOR).getStart()))); if(previous != BUYING_SHIP) option(""Where can I find the right ship?"", new Dialogue() .addNext(()-> p.startConversation(new GuildMasterDragonSlayerD(p, BUYING_SHIP).getStart()))); if(previous != DRAGON_BREATH) option(""How can I protect myself from the dragon's breath?"", new Dialogue() .addNext(()-> p.startConversation(new GuildMasterDragonSlayerD(p, DRAGON_BREATH).getStart()))); if(p.getQuestManager().getAttribs(Quest.DRAGON_SLAYER).getB(FINISHED_DIALOGUE_GUILDMASTER_ATTR)) option(""Okay, I'll get going!"", new Dialogue().addPlayer(HeadE.HAPPY_TALKING, ""Okay, I'll get going!"")); } }); } private boolean isFinished(Player p) { GenericAttribMap attr = p.getQuestManager().getAttribs(Quest.DRAGON_SLAYER); return attr.getB(KNOWS_MAP_EXISTS_ATTR) && attr.getB(KNOWS_ABOUT_THALZAR_MAP_ATTR) && attr.getB(KNOWS_ABOUT_LOZAR_MAP_ATTR) && attr.getB(KNOWS_ABOUT_MELZAR_MAP_ATTR) && attr.getB(KNOWS_ABOUT_SHIP_ATTR) && attr.getB(KNOWS_ABOUT_DRAGON_BREATH_ATTR); } private void routeToCrandor(Player p) { addPlayer(HeadE.HAPPY_TALKING, ""How can I find the route to Crandor?""); addNPC(GUILD_MASTER, HeadE.CALM_TALK, ""Only one map exists that shows the route through the reefs of Crandor. The map was split into three pieces by Melzar, "" + ""Thalzar, and Lozar, the wizards who escaped from the dragon. Each of them took one piece."", ()-> p.getQuestManager().getAttribs(Quest.DRAGON_SLAYER).setB(KNOWS_MAP_EXISTS_ATTR, true)); addNext(()-> p.startConversation(new GuildMasterDragonSlayerD(p, DRAGON_BREATH, ROUTE_TO_CRANDOR).getStart())); } private void whereisThalzarMapPiece(Player p) { addPlayer(HeadE.HAPPY_TALKING, ""Where is Thalzar's map piece?""); addNPC(GUILD_MASTER, HeadE.CALM_TALK, ""Thalzar was the most paranoid of the three wizards. He hid his map piece and took the secret of its location "" + ""to his grave. I don't think you'd be able to find out where it is by ordinary means. "" + ""You'll need to talk to the Oracle on Ice Mountain."", ()-> p.getQuestManager().getAttribs(Quest.DRAGON_SLAYER).setB(KNOWS_ABOUT_THALZAR_MAP_ATTR, true)); addNext(()-> p.startConversation(new GuildMasterDragonSlayerD(p, MAIN_OPTIONS, WHERE_IS_THALZAR).getStart())); } private void whereisLozarMapPiece(Player p) { addPlayer(HeadE.HAPPY_TALKING, ""Where is Lozar's map piece?""); addNPC(GUILD_MASTER, HeadE.CALM_TALK, ""A few weeks ago, I'd have told you to speak to Lozar herself, in her house across the river from Lumbridge. "" + ""Unfortunately, goblin raiders killed her, and stole everything. One of the goblins from the Goblin Village probably has the map piece now."", ()-> p.getQuestManager().getAttribs(Quest.DRAGON_SLAYER).setB(KNOWS_ABOUT_LOZAR_MAP_ATTR, true)); addNext(()-> p.startConversation(new GuildMasterDragonSlayerD(p, MAIN_OPTIONS, WHERE_IS_LOZAR).getStart())); } private void whereisMelzarsMapPiece(Player p) { addPlayer(HeadE.HAPPY_TALKING, ""Where is Melzar's map piece?""); addNPC(GUILD_MASTER, HeadE.CALM_TALK, ""Melzar built a castle on the site of the Crandorian refugee camp, north of Rimmington. He's locked "" + ""himself in there and no one's seen him for years. The inside of his castle is like a maze, and is populated by undead monsters.""); addNPC(GUILD_MASTER, HeadE.CALM_TALK, ""Maybe, if you could get all the way through the maze, you could find his piece of the map. Adventurers "" + ""sometimes go in there to prove themselves, so I can give you this key to Melzar's Maze."", ()->{ if(!p.getInventory().containsItem(MELZAR_MAZE_KEY, 1)) p.getInventory().addItem(new Item(MELZAR_MAZE_KEY, 1), true); p.getQuestManager().getAttribs(Quest.DRAGON_SLAYER).setB(KNOWS_ABOUT_MELZAR_MAP_ATTR, true); }); addNext(()-> p.startConversation(new GuildMasterDragonSlayerD(p, MAIN_OPTIONS, WHERE_IS_MELZAR).getStart())); } private void buyingShip(Player p) { addPlayer(HeadE.HAPPY_TALKING, ""Where can I find the right ship?""); addNPC(GUILD_MASTER, HeadE.CALM_TALK, ""Even if you find the right route, only a ship made to the old crandorian design would be able to navigate "" + ""through the reefs to the island. If there's still one in existence, it's probably in Port Sarim.""); addNPC(GUILD_MASTER, HeadE.CALM_TALK, ""Then, of course, you'll need to find a captain willing to sail to Crandor, and I'm not sure where you'd find "" + ""one of them!"", ()-> p.getQuestManager().getAttribs(Quest.DRAGON_SLAYER).setB(KNOWS_ABOUT_SHIP_ATTR, true)); addNext(()-> p.startConversation(new GuildMasterDragonSlayerD(p, MAIN_OPTIONS, BUYING_SHIP).getStart())); } private void dragonBreath(Player p) { addPlayer(HeadE.HAPPY_TALKING, ""How can I protect myself from the dragon's breath?""); addNPC(GUILD_MASTER, HeadE.CALM_TALK, ""That part shouldn't be too difficult, actually, I believe the Duke of Lumbridge has a special shield in his "" + ""armoury that is enchanted against dragon's breath."", ()-> p.getQuestManager().getAttribs(Quest.DRAGON_SLAYER).setB(KNOWS_ABOUT_DRAGON_BREATH_ATTR, true)); addNext(()-> p.startConversation(new GuildMasterDragonSlayerD(p, MAIN_OPTIONS, DRAGON_BREATH).getStart())); } }" "package com.rs.game.content.quests.dragonslayer; @PluginEventHandler public class KlarenseDragonSlayerD extends Conversation { private final int MAIN_OPTIONS = 0; private final int WHEN_SEAWORTHY = 1; private final int WOULD_YOU_TAKE_ME = 2; private final int WHY_IS_SHE_DAMAGED = 3; private final int ID_LIKE_TO_BUY_HER = 4; public KlarenseDragonSlayerD(Player p) { super(p); switch(p.getQuestManager().getStage(Quest.DRAGON_SLAYER)) { case NOT_STARTED, TALK_TO_OZIACH, TALK_TO_GUILDMASTER -> { addNPC(KLARENSE, HeadE.CALM_TALK, ""The Lady Lumbridge is for sale, in case you are interested.""); addPlayer(HeadE.HAPPY_TALKING, ""Oh this boat?""); addNPC(KLARENSE, HeadE.CALM_TALK, ""Yes, the boat sells with Jenkins The Cabinboy.""); addPlayer(HeadE.CALM_TALK, ""No thank you...""); } case PREPARE_FOR_CRANDOR -> { if(p.getQuestManager().getAttribs(Quest.DRAGON_SLAYER).getB(OWNS_BOAT_ATTR)) { if(p.getQuestManager().getAttribs(Quest.DRAGON_SLAYER).getB(IS_BOAT_FIXED_ATTR)) { addNPC(KLARENSE, HeadE.CALM_TALK, ""Hello, captain! Here to take your new ship for a spin?""); addPlayer(HeadE.HAPPY_TALKING, ""Yes, I will be headed to Crandor soon.""); } else { addNPC(KLARENSE, HeadE.CALM_TALK, ""Hello, captain! Here to inspect your new ship? Just a little work and she'll be seaworthy again.""); addPlayer(HeadE.HAPPY_TALKING, ""So, what needs fixing on the ship?""); addNPC(KLARENSE, HeadE.CALM_TALK, ""Well, the big gaping hole in the hold is the problem. You'll need a few wooden planks hammered in with steel nails to fix it.""); } } else { addNPC(KLARENSE, HeadE.CALM_TALK, ""So, are you interested in buying a ship? Now, I'll be straight with you: She's not quite seaworthy right now,"" + "" but give her a bit of work and she'll be the nippiest ship this side of Port Khazard.""); addNext(() -> p.startConversation(new KlarenseDragonSlayerD(p, MAIN_OPTIONS, MAIN_OPTIONS).getStart())); } } case REPORT_TO_OZIACH -> { addNPC(KLARENSE, HeadE.CALM_TALK, ""It's a miracle, The Lady Lumbridge washed up back over here. It needs repairs in the hull again though.""); addPlayer(HeadE.HAPPY_TALKING, ""Wow, now I can go to Crandor when I please?""); addNPC(KLARENSE, HeadE.CALM_TALK, ""That you may.""); } case QUEST_COMPLETE -> { //Will not talk about Dragon Slayer } } } public KlarenseDragonSlayerD(Player p, int convoID, int previousID) { super(p); mainOptions(p, previousID); } public KlarenseDragonSlayerD(Player p, int convoID) { super(p); switch(convoID) { case WHEN_SEAWORTHY -> whenSeaworthy(p); case WOULD_YOU_TAKE_ME -> wouldYouTakeMe(p); case WHY_IS_SHE_DAMAGED -> whyIsSheDamaged(p); case ID_LIKE_TO_BUY_HER -> idLikeToBuyHer(p); } } private void mainOptions(Player p, int previous) { addOptions(""Choose an option:"", new Options() { @Override public void create() { if(previous!=WHEN_SEAWORTHY) option(""Do you know when she will be seaworthy?"", new Dialogue() .addNext(()-> p.startConversation(new KlarenseDragonSlayerD(p, WHEN_SEAWORTHY).getStart()))); if(previous!=WOULD_YOU_TAKE_ME) option(""Would you take me to Crandor when she's ready?"", new Dialogue() .addNext(()-> p.startConversation(new KlarenseDragonSlayerD(p, WOULD_YOU_TAKE_ME).getStart()))); if(previous!=WHY_IS_SHE_DAMAGED) option(""Why is she damaged?"", new Dialogue() .addNext(()-> p.startConversation(new KlarenseDragonSlayerD(p, WHY_IS_SHE_DAMAGED).getStart()))); if(previous!=ID_LIKE_TO_BUY_HER) option(""I'd like to buy her."", new Dialogue() .addNext(()-> p.startConversation(new KlarenseDragonSlayerD(p, ID_LIKE_TO_BUY_HER).getStart()))); option(""Ah well, never mind"", new Dialogue().addPlayer(HeadE.HAPPY_TALKING, ""Ah well, never mind"")); } }); } private void whenSeaworthy(Player p) { addPlayer(HeadE.HAPPY_TALKING, ""Do you know when she will be seaworthy?""); addNPC(KLARENSE, HeadE.CALM_TALK, ""No, not really. Port Sarim's shipbuilders aren't very efficient so it could be quite a while""); addNext(()-> p.startConversation(new KlarenseDragonSlayerD(p, MAIN_OPTIONS, WHEN_SEAWORTHY).getStart())); } private void wouldYouTakeMe(Player p) { addPlayer(HeadE.HAPPY_TALKING, ""Would you take me to Crandor when she's ready?""); addNPC(KLARENSE, HeadE.CALM_TALK, ""Crandor? You're joking, right?""); addOptions(""Choose an option:"", new Options() { @Override public void create() { option(""Yes. Ha ha ha!"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Yes. Ha ha ha!"") .addNPC(KLARENSE, HeadE.CALM_TALK, ""Crandor's not something we sailors joke about. You can't sail from here to Catherby, or Entrana, or "" + ""Ardougne without going past that accursed island. You can't get to close to it because of the reefs, but you can always see it."") .addNPC(KLARENSE, HeadE.CALM_TALK, ""Sometimes you can see a dark shape in the sky, circling the island. That's when you have to sail "" + ""on as quick as you can and pray it's not hungry. Every year, more ships are lost to that dragon"") .addNext(()-> new KlarenseDragonSlayerD(p, MAIN_OPTIONS, WOULD_YOU_TAKE_ME).getStart())); option(""No. I want to go to Crandor."", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""No. I want to go to Crandor."") .addNPC(KLARENSE, HeadE.CALM_TALK, ""Then you must be crazy. That island is surrounded by reefs that would rip this ship to shreds. "" + ""Even if you found a map, you'd need an experienced captain to stand a chance of getting through and, even if I could get to it,"") .addNPC(KLARENSE, HeadE.CALM_TALK, ""there's no way I'm going any closer to that dragon than I have to. They say it can destroy whole ships with one bite."") .addNext(()-> p.startConversation(new KlarenseDragonSlayerD(p, MAIN_OPTIONS, WOULD_YOU_TAKE_ME).getStart()))); } }); } private void whyIsSheDamaged(Player p) { addPlayer(HeadE.HAPPY_TALKING, ""Why is she damaged?""); addNPC(KLARENSE, HeadE.CALM_TALK, ""Oh, there was not particular accident. It's just years of wear and tear. The Lady Lumbridge is an old crandorian "" + ""fishing ship – the last one of her kind, as far as I know. That kind of ship was always mightily manoeuvrable, but not too tough.""); addNPC(KLARENSE, HeadE.CALM_TALK, ""She happened to be somewhere else when Crandor was destroyed, and she's had several owners since then. Not all of them "" + ""looked after her too well, but once she's patched up, she'll be good as new!""); addNext(()-> p.startConversation(new KlarenseDragonSlayerD(p, MAIN_OPTIONS, WHY_IS_SHE_DAMAGED).getStart())); } private void idLikeToBuyHer(Player p) { addPlayer(HeadE.HAPPY_TALKING, ""I'd like to buy her.""); addNPC(KLARENSE, HeadE.CALM_TALK, ""Of course! I'm sure the work needed to do on it wouldn't be too expensive. How does 2,000 gold sound? I'll "" + ""even throw in my cabin boy, Jenkins, for free! He'll swab the decks and splice the mainsails for you!""); if(p.getInventory().hasCoins(2000)) addOptions(""Buy Lady Lumbridge?"", new Options() { @Override public void create() { option(""Yep, sounds good."", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Yep, sounds good."") .addNPC(KLARENSE, HeadE.CALM_TALK, ""Okey dokey, she's all yours!"", () -> { p.getInventory().removeCoins(2000); p.getQuestManager().getAttribs(Quest.DRAGON_SLAYER).setB(OWNS_BOAT_ATTR, true); })); option(""I'm not paying that much for a broken boat!"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""I'm not paying that much for a broken boat!"") .addNPC(KLARENSE, HeadE.CALM_TALK, ""That fair enough, I suppose."")); } }); else { addPlayer(HeadE.HAPPY_TALKING, ""Darn, I don't have it.""); addNPC(KLARENSE, HeadE.CALM_TALK, ""That's too bad...""); addPlayer(HeadE.SAD, ""It is...""); } } }" "package com.rs.game.content.quests.dragonslayer; @PluginEventHandler public class MelzarsMaze { public final static int FRONT_DOOR = 2595; public static ObjectClickHandler handleMelzarsMazeLadders = new ObjectClickHandler(new Object[] { 1754, 32015, 25038, 25214, 1752, 2605 }, e -> { GameObject obj = e.getObject(); if(obj.getTile().matches(Tile.of(2928, 3258, 0)) || obj.getTile().matches(Tile.of(2925, 3258, 0)) || obj.getTile().matches(Tile.of(2930, 3258, 1)) || obj.getTile().matches(Tile.of(2937, 3247, 1))) return; if(obj.getTile().matches(Tile.of(2934, 3243, 1)) || obj.getTile().matches(Tile.of(2929, 3245, 1)) || obj.getTile().matches(Tile.of(2940, 3240, 1)) || obj.getTile().matches(Tile.of(2937, 3240, 0))) return; //Exits if(obj.getTile().matches(Tile.of(2924, 9650, 0)))//Melzar Mad basement exit ladder to first floor e.getPlayer().useLadder(Tile.of(2923, 3250, 0)); if(obj.getTile().matches(Tile.of(2924, 3250, 0)))//1st floor to Melzar mad exit e.getPlayer().useLadder(Tile.of(2924, 9649, 0)); if(obj.getTile().matches(Tile.of(2939, 3257, 0)))//Front exit to Lesser demon exit ladder e.getPlayer().useLadder(Tile.of(2939, 9656, 0)); if(obj.getTile().matches(Tile.of(2939, 9657, 0)))//Lesser demon exit to front exit e.getPlayer().useLadder(Tile.of(2938, 3257, 0)); if(obj.getTile().matches(Tile.of(2928, 9658, 0)))//Basement exit out e.getPlayer().useLadder(Tile.of(2928, 3259, 0)); if(obj.getTile().matches(Tile.of(2928, 9658, 0)))//Basement exit out e.getPlayer().useLadder(Tile.of(2928, 3259, 0)); if(obj.getTile().matches(Tile.of(2932, 3240, 0)))//Basement exit out e.getPlayer().useLadder(Tile.of(2932, 9641, 0)); }); public static ObjectClickHandler handleFrontDoor = new ObjectClickHandler(new Object[] { FRONT_DOOR }, e -> { Player p = e.getPlayer(); GameObject obj = e.getObject(); if(p.getInventory().containsItem(new Item(MELZAR_MAZE_KEY, 1))) handleDoor(p, obj); else p.startConversation(new Conversation(e.getPlayer()) { { addPlayer(HeadE.CALM_TALK, ""The door seems to need a key...""); create(); } }); }); public static ObjectClickHandler handleExitDoors = new ObjectClickHandler(new Object[] { 2602, 32968 }, e -> { Player p = e.getPlayer(); GameObject obj = e.getObject(); if(p.getX() >= obj.getX()) if(p.getX() >= obj.getX()) { handleDoor(p, obj); return; } p.startConversation(new Conversation(e.getPlayer()) { { addPlayer(HeadE.CALM_TALK, ""The door seems to be locked from the other side...""); create(); } }); }); public static ObjectClickHandler handleColoredDoors = new ObjectClickHandler(new Object[] { 2596,2597,2598,2599,2600,2601 }, e -> { Player p = e.getPlayer(); GameObject obj = e.getObject(); if(obj.getId() == 2596) if(p.getInventory().containsItem(RED_KEY)) { handleDoor(p, obj); return; } if(obj.getId() == 2597) if(p.getInventory().containsItem(ORANGE_KEY)) { handleDoor(p, obj); return; } if(obj.getId() == 2598) if(p.getInventory().containsItem(YELLOW_KEY)) { handleDoor(p, obj); return; } if(obj.getId() == 2599) if(p.getInventory().containsItem(BLUE_KEY)) { handleDoor(p, obj); return; } if(obj.getId() == 2600) if(p.getInventory().containsItem(MAGENTA_KEY)) { handleDoor(p, obj); return; } if(obj.getId() == 2601) if(p.getInventory().containsItem(GREEN_KEY)) { handleDoor(p, obj); return; } p.startConversation(new Conversation(e.getPlayer()) { { addPlayer(HeadE.CALM_TALK, ""The door seems to need a key...""); create(); } }); }); static final int MELZAR_BASEMENT_REGION = 11670; public static NPCDeathHandler handleBlueKeyDrop = new NPCDeathHandler(ZOMBIE_BLUE_KEY, e -> { if(e.getNPC().getRegionId() == MELZAR_BASEMENT_REGION && e.killedByPlayer()) World.addGroundItem(new Item(BLUE_KEY, 1), Tile.of(e.getNPC().getTile()), (Player)e.getKiller()); }); public static NPCDeathHandler handleGreenKeyDrop = new NPCDeathHandler(LESSER_DEMON_GREEN_KEY, e -> { if(e.getNPC().getRegionId() == MELZAR_BASEMENT_REGION && e.killedByPlayer()) World.addGroundItem(new Item(GREEN_KEY, 1), Tile.of(e.getNPC().getTile()), (Player)e.getKiller()); }); public static NPCDeathHandler handleMagentaKeyDrop = new NPCDeathHandler(MELZAR_THE_MAD_MEGENTA_KEY, e -> { if(e.getNPC().getRegionId() == MELZAR_BASEMENT_REGION && e.killedByPlayer()) World.addGroundItem(new Item(MAGENTA_KEY, 1), Tile.of(e.getNPC().getTile()), (Player)e.getKiller()); }); public static ObjectClickHandler handleMapPieceChest = new ObjectClickHandler(new Object[] { 2603, 2604 }, e -> { Player p = e.getPlayer(); GameObject obj = e.getObject(); if(e.getOption().equalsIgnoreCase(""open"")) { p.setNextAnimation(new Animation(536)); p.lock(2); GameObject openedChest = new GameObject(obj.getId() + 1, obj.getType(), obj.getRotation(), obj.getX(), obj.getY(), obj.getPlane()); p.faceObject(openedChest); World.spawnObjectTemporary(openedChest, Ticks.fromMinutes(1)); } if(e.getOption().equalsIgnoreCase(""search"")) if(p.getInventory().containsItem(MAP_PART1)) p.sendMessage(""The chest is empty""); else if(p.getBank().containsItem(MAP_PART1, 1)) { p.startConversation(new Conversation(e.getPlayer()) { { addPlayer(HeadE.HAPPY_TALKING, ""Oh that's right, the map piece is in my bank.""); create(); } }); p.sendMessage(""The chest is empty""); } else p.getInventory().addItem(MAP_PART1, 1); }); }" "package com.rs.game.content.quests.dragonslayer; @PluginEventHandler public class NedDragonSlayerD extends Conversation { /** * Only called in PREPARE_FOR_CRANDOR stage. */ public NedDragonSlayerD(Player p) { super(p); GenericAttribMap attr = p.getQuestManager().getAttribs(Quest.DRAGON_SLAYER); if(attr.getB(NED_IS_CAPTAIN_ATTR)) { addPlayer(HeadE.HAPPY_TALKING, ""Will you take me to Crandor now?""); addNPC(NED, HeadE.CALM_TALK, ""Sure, meet me at Port Sarim.""); return; } addPlayer(HeadE.HAPPY_TALKING, ""You're a sailor? Could you take me to the island of Crandor?""); addNPC(NED, HeadE.CALM_TALK, ""Well, I was a sailor. I've not been able to get work at sea these days though. They say I'm too old. Sorry, where was it "" + ""you said you wanted to go?""); addPlayer(HeadE.HAPPY_TALKING, ""To the island of Crandor.""); addNPC(NED, HeadE.CALM_TALK, ""Crandor? But ... It would be a chance to sail a ship once more. I'd sail anywhere if it was a chance to sail again. ""); addNPC(NED, HeadE.CALM_TALK, ""Then again, no captain in his right mind would sail to that island. Ah, you only live once! I'll do it! So, where's your ship?""); if(attr.getB(OWNS_BOAT_ATTR)) { addPlayer(HeadE.HAPPY_TALKING, ""It's the Lady Lumbridge, in Port Sarim""); addNPC(NED, HeadE.CALM_TALK, ""That old pile of junk? Last I head, she wasn't seaworthy""); if(attr.getB(IS_BOAT_FIXED_ATTR)) { addPlayer(HeadE.HAPPY_TALKING, ""I fixed her up.""); addNPC(NED, HeadE.CALM_TALK, ""You did? Excellent! Just show me the map and we can get ready to go!""); if(p.getInventory().containsItem(new Item(CRANDOR_MAP))) { addPlayer(HeadE.HAPPY_TALKING, ""Here you go.""); addSimple(""You hand the map to Ned."", () -> { attr.setB(NED_IS_CAPTAIN_ATTR, true); p.getInventory().removeItems(new Item(CRANDOR_MAP, 1)); p.getVars().setVar(NED_BOAT_VISIBILITY_VAR, 7); }); addNPC(NED, HeadE.CALM_TALK, ""Excellent! I'll meet you at the ship, then.""); } else if(p.getBank().containsItem(CRANDOR_MAP, 1)) { addPlayer(HeadE.HAPPY_TALKING, ""The map's in the bank. I'll have to go and get it.""); addNPC(NED, HeadE.CALM_TALK, ""You do that then.""); } else { addPlayer(HeadE.HAPPY_TALKING, ""Uh...yeah...about that. I don't actually have a map on me.""); addNPC(NED, HeadE.CALM_TALK, ""You'd better go find it, then. I'm not going to go sailing off without a map to show me where to head!""); } } else { addPlayer(HeadE.CALM_TALK, ""Yea I still need to fix her up""); addNPC(NED, HeadE.CALM_TALK, ""You do that then.""); addPlayer(HeadE.SAD, ""I will....""); } } else { addPlayer(HeadE.HAPPY_TALKING, ""I don't have a boat""); addNPC(NED, HeadE.CALM_TALK, ""Well, that's too bad isn't it?""); addPlayer(HeadE.SAD, ""Yes it is...""); } } }" "package com.rs.game.content.quests.dragonslayer; @PluginEventHandler public class OracleDragonSlayerD extends Conversation { public OracleDragonSlayerD(Player p) { super(p); addPlayer(HeadE.AMAZED_MILD, ""Can you impart your wise knowledge to me, O Oracle?""); switch(p.getQuestManager().getStage(Quest.DRAGON_SLAYER)) { case PREPARE_FOR_CRANDOR -> { addNPC(746, HeadE.CHEERFUL, ""Sure, I see no harm in that.""); addPlayer(HeadE.AMAZED_MILD, ""I seek a piece of the map to the island of Crandor.""); addNPC(746, HeadE.SECRETIVE, ""Really let me think...""); addNPC(746, HeadE.CALM_TALK, ""The map's behind a door below, but entering is rather tough. This is what you need to know: You must "" + ""use the following stuff""); addNPC(746, HeadE.CALM_TALK, ""First, a drink used by a mage. Next, some worm string, changed to sheet. Then, a small crustacean cage. "" + ""Last, a bowl that's not seen heat. Use that stuff on the door..."", () -> p.getQuestManager().getAttribs(Quest.DRAGON_SLAYER).setB(ORACLE_DOOR_KNOWLEDGE_ATTR, true)); addPlayer(HeadE.HAPPY_TALKING, ""Got it, a crayfish cage, an unfired bowl, silk and a wizard mind bomb. I should use all of them on the door.""); } default -> { addNPC(746, HeadE.FRUSTRATED, ""I have none for you adventurer""); addPlayer(HeadE.SAD, ""Okay...""); } } } public static NPCClickHandler handleOracleDialogue = new NPCClickHandler(new Object[] { 746 }, e -> e.getPlayer().startConversation(new OracleDragonSlayerD(e.getPlayer()).getStart())); }" "package com.rs.game.content.quests.dragonslayer; @PluginEventHandler public class OziachDragonSlayerD extends Conversation { private final int DRAGON_SOUNDS_FUN = 0; public OziachDragonSlayerD(Player p) { super(p); switch(p.getQuestManager().getStage(Quest.DRAGON_SLAYER)) { case NOT_STARTED -> { addPlayer(HeadE.HAPPY_TALKING, ""Good day to you.""); addNPC(OZIACH, HeadE.CALM_TALK, ""Aye, 'tis a fair day my friend""); addOptions(""Choose an option:"", new Options() { @Override public void create() { option(""I'm not your friend"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""I'm not your friend."") .addNPC(OZIACH, HeadE.CALM_TALK, ""I'm surprised if you're anyone's friend with those kind of manners."")); option(""Yes, it's a very nice day."", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Yes, it's a very nice day."") .addNPC(OZIACH, HeadE.CALM_TALK, ""Aye, may the gods walk by yer side. Now leave me alone."")); } }); } case TALK_TO_OZIACH -> { addPlayer(HeadE.HAPPY_TALKING, ""Good day to you.""); addNPC(OZIACH, HeadE.CALM_TALK, ""Aye, 'tis a fair day my friend""); addOptions(""Choose an option:"", new Options() { @Override public void create() { option(""About Dragon Slayer?"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Can you sell me a rune platebody?"") .addNPC(OZIACH, HeadE.CALM_TALK, ""So, how does thee know I 'ave some?"") .addOptions(""Choose an option:"", new Options() { @Override public void create() { option(""The Guildmaster of the Champion's Guild told me."", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""The Guildmaster of the Champion's Guild told me."") .addNPC(OZIACH, HeadE.CALM_TALK, ""Yes, I suppose he would, wouldn't he? He's always sending you fancy-pants "" + ""'heroes' up to bother me. Telling me I'll give them a quest or sommat like that. Well, I'm not going to "" + ""let just anyone wear my rune platemail. It's only for heroes. So leave me alone."") .addOptions(""Choose an option:"", new Options() { @Override public void create() { option(""I thought you were going to give me a quest."", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""I thought you were going to give me a quest."") .addNPC(OZIACH, HeadE.CALM_TALK, ""*sigh* All right, I'll give ye a quest. I'll let ye wear my "" + ""rune platemail if ye.. Slay the dragon of Crandor!"") .addNext(()-> p.startConversation(new OziachDragonSlayerD(p, DRAGON_SOUNDS_FUN).getStart()))); option(""That's a pity. I'm not a hero"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""That's a pity. I'm not a hero."") .addNPC(OZIACH, HeadE.CALM_TALK, ""Aye, I ken tell!"")); } })); option(""I am a master detective"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""I am a master detective."") .addNPC(OZIACH, HeadE.CALM_TALK, ""Well, however you found out about it, I'm not going to let just anyone wear my "" + ""rune platemail. It's only for heroes. So leave me alone."") .addOptions(""Choose an option:"", new Options() { @Override public void create() { option(""I thought you were going to give me a quest."", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""I thought you were going to give me a quest."") .addNPC(OZIACH, HeadE.CALM_TALK, ""*sigh* All right, I'll give ye a quest. I'll let ye wear my "" + ""rune platemail if ye.. Slay the dragon of Crandor!"") .addNext(()-> p.startConversation(new OziachDragonSlayerD(p, DRAGON_SOUNDS_FUN).getStart()))); option(""That's a pity. I'm not a hero."", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""That's a pity. I'm not a hero."") .addNPC(OZIACH, HeadE.CALM_TALK, ""Aye, I ken tell!"")); } })); } })); option(""I'm not your friend"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""I'm not your friend."") .addNPC(OZIACH, HeadE.CALM_TALK, ""I'm surprised if you're anyone's friend with those kind of manners."")); option(""Yes, it's a very nice day."", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Yes, it's a very nice day."") .addNPC(OZIACH, HeadE.CALM_TALK, ""Aye, may the gods walk by yer side. Now leave me alone."")); } }); } case TALK_TO_GUILDMASTER, PREPARE_FOR_CRANDOR -> { addPlayer(HeadE.HAPPY_TALKING, ""Good day to you.""); addNPC(OZIACH, HeadE.CALM_TALK, ""Have ye slayed that dragon yet?""); addPlayer(HeadE.HAPPY_TALKING, ""Um... no.""); addNPC(OZIACH, HeadE.CALM_TALK, ""Be off with ye then.""); } case REPORT_TO_OZIACH -> { addPlayer(HeadE.HAPPY_TALKING, ""Good day to you.""); addNPC(OZIACH, HeadE.CALM_TALK, ""Have ye slayed that dragon yet?""); if (p.getInventory().containsItem(ELVARG_HEAD)) { addPlayer(HeadE.HAPPY_TALKING, ""I have its head here.""); } else { addPlayer(HeadE.SAD, ""I'm still working on it. I'll bring its head soon.""); addNPC(OZIACH, HeadE.FRUSTRATED, ""Ye haven't brought its head yet? Come back when ye have it.""); return; } addNPC(OZIACH, HeadE.CALM_TALK, ""You actually did it? I underestimated ye, adventurer. I apologise. Yer a true hero, and I'd be happy to sell "" + ""ye rune platebodies.""); addNext(() -> p.getQuestManager().completeQuest(Quest.DRAGON_SLAYER)); } } } public OziachDragonSlayerD(Player p, int convoID) { super(p); switch(convoID) { case DRAGON_SOUNDS_FUN -> dragonSoundsFun(p); } } private void dragonSoundsFun(Player p) { addOptions(""Choose an option:"", new Options() { @Override public void create() { option(""A dragon, that sounds like fun."", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""A dragon, that sounds like fun."") .addNPC(OZIACH, HeadE.CALM_TALK, ""Hah, yes, you are a typical reckless adventurer, aren't you? Now go kill the dragon and get out"" + "" of my face."") .addPlayer(HeadE.HAPPY_TALKING, ""But how can I defeat the dragon?"") .addNPC(OZIACH, HeadE.CALM_TALK, ""Go talk to the Guildmaster in the Champions' Guild. He'll help ye out if yer so keen on doing a quest. "" + ""I'm not going to be handholding any adventurers."", ()-> p.getQuestManager().setStage(Quest.DRAGON_SLAYER, TALK_TO_GUILDMASTER))); option(""I may be a champion, but I don't think I'm, up to dragon-killing yet."", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""I may be a champion, but I don't think I'm, up to dragon-killing yet."") .addNPC(OZIACH, HeadE.CALM_TALK, ""Yes, I can understand that. Yer a coward."")); } }); } }" "package com.rs.game.content.quests.dragonslayer; @PluginEventHandler public class WormBrainDragonSlayerMob extends Conversation { public WormBrainDragonSlayerMob(Player p) { super(p); addNPC(WORM_BRAIN, HeadE.FRUSTRATED, ""Whut you want?""); switch(p.getQuestManager().getStage(Quest.DRAGON_SLAYER)) { case PREPARE_FOR_CRANDOR -> { if(p.getInventory().containsItem(MAP_PART2, 1)) { addPlayer(HeadE.SKEPTICAL_THINKING, ""Sorry I thought this was a zoo.""); addNPC(745, HeadE.CALM, ""...""); return; } addPlayer(HeadE.CALM_TALK, ""I believe you've got a piece of a map that I need.""); addNPC(745, HeadE.SKEPTICAL_THINKING, ""So? Why should I be giving it to you? What you do for Wormbrain?""); addOptions(""Select an option:"", new Options() { @Override public void create() { option(""I'm not going to do anything for you. Forget it."", new Dialogue() .addPlayer(HeadE.CALM_TALK, ""I'm not going to do anything for you. Forget it."") .addNPC(745, HeadE.ANGRY, ""Be dat way then"")); option(""I'll let you live. I could just kill you."", new Dialogue() .addPlayer(HeadE.CALM_TALK, ""I'll let you live. I could just kill you."") .addNPC(745, HeadE.LAUGH, ""Ha! Me in here and you out dere. You not get map piece."")); option(""I suppose I could pay you for the map piece ... Say, 500 coins?"", new Dialogue() .addPlayer(HeadE.CALM_TALK, ""I suppose I could pay you for the map piece ... Say, 500 coins?"") .addNPC(745, HeadE.FRUSTRATED, ""Me not stooped, it worth at least 10,000 coins!"") .addOptions(""Choose an option:"", new Options() { @Override public void create() { if(p.getInventory().hasCoins(10000)) option(""Aright then, 10,000 it is."", new Dialogue() .addSimple(""You buy the map piece from Wormbrain."", ()->{ p.getInventory().removeCoins(10000); p.getInventory().addItem(MAP_PART2, 1, true); }) .addNPC(WORM_BRAIN, HeadE.HAPPY_TALKING, ""Tank you very much! Now me can bribe da guards, hehehe."")); else option(""Darn, I don't have that."", new Dialogue() .addPlayer(HeadE.SAD, ""Darn, I don't have that."") .addNPC(WORM_BRAIN, HeadE.CALM_TALK, ""No map for you!"")); option(""You must be joking! Forget it"", new Dialogue() .addPlayer(HeadE.CALM_TALK, ""You must be joking! Forget it"") .addNPC(WORM_BRAIN, HeadE.CALM_TALK, ""Fine, you not get map piece"")); } })); option(""Where did you get the map piece from?"", new Dialogue() .addPlayer(HeadE.SKEPTICAL_THINKING, ""Where did you get the map piece from?"") .addNPC(WORM_BRAIN, HeadE.HAPPY_TALKING, ""We rob house of stupid wizard. She very old, not put up much fight at all. Hahaha!"") .addPlayer(HeadE.SECRETIVE, ""Uh ... Hahaha."") .addNPC(WORM_BRAIN, HeadE.CALM_TALK, ""Her house full of pictures of a city on island and old pictures of people. Me not recognise "" + ""island. Me find map piece. Me not know what it is, but it in locked box so me figure it important."") .addNPC(WORM_BRAIN, HeadE.CALM_TALK, ""But, by the time me get box open, other goblins gone. Then me not run fast enough and "" + ""guards catch me. But now you want map piece so must be special! What do for me to get it?"")); } }); break; } default -> { addPlayer(HeadE.SKEPTICAL_THINKING, ""Sorry I thought this was a zoo.""); addNPC(WORM_BRAIN, HeadE.CALM, ""...""); } } } public static NPCClickHandler handleWormBrain = new NPCClickHandler(new Object[] { WORM_BRAIN }, e -> e.getPlayer().startConversation(new WormBrainDragonSlayerMob(e.getPlayer()).getStart())); public static NPCDeathHandler handleWormBrainDrop = new NPCDeathHandler(WORM_BRAIN, e -> { if(e.killedByPlayer()) { Player p = (Player) e.getKiller(); if(p.getQuestManager().getStage(Quest.DRAGON_SLAYER) == PREPARE_FOR_CRANDOR && !p.getInventory().containsItem(MAP_PART2, 1)) World.addGroundItem(new Item(MAP_PART2, 1), Tile.of(e.getNPC().getTile()), (Player) e.getKiller()); } }); public static ObjectClickHandler handleWormBrainJailGate = new ObjectClickHandler(new Object[] { 40184 }, e -> e.getPlayer().sendMessage(""It is firmly shut..."")); public static NPCInteractionDistanceHandler wormbrainDistance = new NPCInteractionDistanceHandler(WORM_BRAIN, (player, npc) -> 1); }" "package com.rs.game.content.quests.dwarfcannon; @PluginEventHandler public class CaptainLawgofD extends Conversation { public static final int CAPTAIN_LAWGOF = 208; public static NPCClickHandler talkToLawgof = new NPCClickHandler(new Object[] { 208 }, e -> e.getPlayer().startConversation(new CaptainLawgofD(e.getPlayer()))); public CaptainLawgofD(Player player) { super(player); switch(player.getQuestManager().getStage(Quest.DWARF_CANNON)) { case 0: addPlayer(HeadE.NO_EXPRESSION, ""Hello.""); addNPC(CAPTAIN_LAWGOF, HeadE.HAPPY_TALKING, ""Guthix be praised, the cavalry has arrived! Hero, how would you like to be made an honorary member of the Black Guard?""); addPlayer(HeadE.NO_EXPRESSION, ""The Black Guard? What's that?""); addNPC(CAPTAIN_LAWGOF, HeadE.HAPPY_TALKING, ""Hawhaw! 'What's that' "" + (player.getAppearance().isMale() ? ""he"" : ""she"") + "" asks, what a sense of humour! The Black Guard is the finest regiment in the dwarven army. Only the best of the best are allowed to join it and then they receive months of rigorous training.""); addNPC(CAPTAIN_LAWGOF, HeadE.HAPPY_TALKING, ""However, we are currently in need of a hero, so for a limited time only I'm offering you, a human, a chance to join this prestigious regiment. What do you say?""); addPlayer(HeadE.NO_EXPRESSION, ""Sure, I'd be honoured to join.""); addNPC(CAPTAIN_LAWGOF, HeadE.HAPPY_TALKING, ""That's the spirit! Now trooper, we have no time to waste - the goblins are attacking from the forests to the South. There are so many of them,""); addNPC(CAPTAIN_LAWGOF, HeadE.HAPPY_TALKING, ""they are overwhelming my men and breaking through our perimeter defences; could you please try to fix the stockade by replacing the broken rails with these new ones?""); addPlayer(HeadE.NO_EXPRESSION, ""Sure, sounds easy enough..."", () -> player.getQuestManager().setStage(Quest.DWARF_CANNON, 1)); case 1: if (DwarfCannon.checkRemainingRepairs(player) > 0) { int amount = DwarfCannon.checkRemainingRepairs(player) - player.getInventory().getNumberOf(DwarfCannon.RAILINGS); if (amount > 0) addSimple(""The Dwarf Captain gives you some railings."", () -> player.getInventory().addItemDrop(DwarfCannon.RAILINGS, DwarfCannon.checkRemainingRepairs(player) - player.getInventory().getNumberOf(DwarfCannon.RAILINGS))); } addNPC(CAPTAIN_LAWGOF, HeadE.HAPPY_TALKING, ""Report back to me once you've fixed the railings.""); addPlayer(HeadE.NO_EXPRESSION, ""Yes Sir, Captain!""); break; case 2: addNPC(CAPTAIN_LAWGOF, HeadE.HAPPY_TALKING, ""Well done, trooper! The goblins seems to have stopped getting in, I think you've done the job!""); addPlayer(HeadE.NO_EXPRESSION, ""Great, I'll be getting on then.""); addNPC(CAPTAIN_LAWGOF, HeadE.ANGRY, ""What? I'll have you jailed for desertion! Besides, I have another commission for you. Just before the goblins over-ran us we lost contact with our watch tower to the South,""); addNPC(CAPTAIN_LAWGOF, HeadE.HAPPY_TALKING, ""that's why the goblins managed to catch us unawares. I'd like you to perform a covert operation into enemy territory, to check up on the guards we have stationed there. They should have reported in by now ...""); addPlayer(HeadE.NO_EXPRESSION, ""Okay, I'll see what I can find out.""); addNPC(CAPTAIN_LAWGOF, HeadE.HAPPY_TALKING, ""Excellent! I have two men there, the dwarf-in-charge is called Gilob, find him and tell him that I'll send him a relief guard just as soon as we mop up these remaining goblins."", () -> { player.getQuestManager().setStage(Quest.DWARF_CANNON, 3); DwarfCannon.updateVars(player); }); break; case 3: addPlayer(HeadE.NO_EXPRESSION, ""Hello.""); addNPC(CAPTAIN_LAWGOF, HeadE.HAPPY_TALKING, ""Have you been to the watch tower yet?""); if (player.getInventory().containsItem(DwarfCannon.DWARF_REMAINS)) { addPlayer(HeadE.NO_EXPRESSION, ""I have some terrible news for you Captain, the goblins over ran the tower, your guards fought well but were overwhelmed.""); addSimple(""You give the Dwarf Captain his subordinate's remains..."", () -> { player.getInventory().deleteItem(DwarfCannon.DWARF_REMAINS, 1); player.getQuestManager().setStage(Quest.DWARF_CANNON, 4); player.getVars().setVar(0, 4); }); addNPC(CAPTAIN_LAWGOF, HeadE.SAD_MILD_LOOK_DOWN, ""I can't believe it, Gilob was the finest lieutenant I had! We'll give him a fitting funeral, but what of his command? His son, Lollk, was with him. Did you find his body too?""); addPlayer(HeadE.NO_EXPRESSION, ""No, there was only one body there. I searched pretty well.""); addNPC(CAPTAIN_LAWGOF, HeadE.HAPPY_TALKING, ""The goblins must have taken him. Please traveler, seek out the goblins' hideout and return the lad to us. They always attack from the South-east, so they must be based down there.""); addPlayer(HeadE.NO_EXPRESSION, ""Okay, I'll see if I can find their hideout.""); } else addPlayer(HeadE.NO_EXPRESSION, ""Not yet.""); break; case 4: case 5: addPlayer(HeadE.NO_EXPRESSION, ""Hello, has Lolk returned yet?""); addNPC(CAPTAIN_LAWGOF, HeadE.HAPPY_TALKING, ""Not yet, please keep searching before it is too late!""); break; case 6: addPlayer(HeadE.NO_EXPRESSION, ""Hello, has Lolk returned yet?""); addNPC(CAPTAIN_LAWGOF, HeadE.HAPPY_TALKING, ""He has, and I thank you from the bottom of my heart - without you he'd be a goblin barbeque!""); addPlayer(HeadE.NO_EXPRESSION, ""Always a pleasure to help.""); addNPC(CAPTAIN_LAWGOF, HeadE.HAPPY_TALKING, ""In that case could I ask one more favour of you... When the goblins attacked us some of them managed to slip past my guards and sabotage our cannon. I don't have anybody who understands how it works, could you have a look at it and see if you could get it working for us, please?""); addPlayer(HeadE.NO_EXPRESSION, ""Okay, I'll see what I can do.""); addNPC(CAPTAIN_LAWGOF, HeadE.HAPPY_TALKING, ""Thank you, take this toolbelt, you'll need it... Report back to me if you manage to fix it."", () -> { player.getInventory().addItemDrop(DwarfCannon.TOOLKIT, 1); player.getQuestManager().setStage(Quest.DWARF_CANNON, 7); }); break; case 7: addPlayer(HeadE.NO_EXPRESSION, ""Hello again.""); addNPC(CAPTAIN_LAWGOF, HeadE.HAPPY_TALKING, ""Hello there trooper, how's things?""); if (!player.getInventory().containsItem(DwarfCannon.TOOLKIT)) { addPlayer(HeadE.NO_EXPRESSION, ""I've lost your tool kit.""); addNPC(CAPTAIN_LAWGOF, HeadE.SHAKING_HEAD, ""Here, take this one.""); player.getInventory().addItemDrop(DwarfCannon.TOOLKIT, 1); } else addPlayer(HeadE.NO_EXPRESSION, ""Still working on it.""); break; case 8: addPlayer(HeadE.NO_EXPRESSION, ""Hello again.""); addNPC(CAPTAIN_LAWGOF, HeadE.HAPPY_TALKING, ""Hello there trooper, how's things?""); addPlayer(HeadE.HAPPY_TALKING, ""Well, I think I've done it, take a look...""); addNPC(CAPTAIN_LAWGOF, HeadE.HAPPY_TALKING, ""That's fantastic, well done!""); addNPC(CAPTAIN_LAWGOF, HeadE.HAPPY_TALKING, ""Well I don't believe it, it seems to be working perfectly! I seem to have underestimated you, trooper!""); addPlayer(HeadE.NO_EXPRESSION, ""Not bad for an adventurer eh?""); addNPC(CAPTAIN_LAWGOF, HeadE.HAPPY_TALKING, ""Not bad at all, your effort is appreciated, my friend. Now, if I could figure what the thing uses as ammo... The Black Guard forgot to send instructions. I know I said that was the last favour, but...""); addPlayer(HeadE.NO_EXPRESSION, ""What now?""); addNPC(CAPTAIN_LAWGOF, HeadE.HAPPY_TALKING, ""I can't leave this post, could you go to the Black Guard base and find out what this thing actually shoots?""); addPlayer(HeadE.NO_EXPRESSION, ""Okay then, just for you!""); addNPC(CAPTAIN_LAWGOF, HeadE.HAPPY_TALKING, ""That's great, we were lucky you came along when you did. The base is located just South of the Ice Mountain. You'll need to speak to Nulodion, the Dwarf Cannon engineer. He's the Weapon Development Chief for the Black Guard, so if anyone knows how to fire this thing, it'll be him.""); addPlayer(HeadE.NO_EXPRESSION, ""Okay, I'll see what I can do."", () -> player.getQuestManager().setStage(Quest.DWARF_CANNON, 9)); break; case 9: addPlayer(HeadE.NO_EXPRESSION, ""Hi.""); addNPC(CAPTAIN_LAWGOF, HeadE.HAPPY_TALKING, ""Hello trooper, any word from the Cannon Engineer?""); if (player.getInventory().containsItem(DwarfCannon.AMMO_MOULD) && player.getInventory().containsItem(DwarfCannon.NULODIONS_NOTES)) addPlayer(HeadE.NO_EXPRESSION, ""Yes, I have spoken to him. He gave me an ammo mould and some notes to give to you..."", () -> { player.getInventory().deleteItem(DwarfCannon.AMMO_MOULD, 1); player.getInventory().deleteItem(DwarfCannon.NULODIONS_NOTES, 1); player.getQuestManager().setStage(Quest.DWARF_CANNON, 10); }); else addPlayer(HeadE.NO_EXPRESSION, ""Not yet.""); break; case 10: addNPC(CAPTAIN_LAWGOF, HeadE.HAPPY_TALKING, ""Aah, of course, we make the ammo! This is great, now we will be able to defend ourselves. I don't know how to thank you...""); addPlayer(HeadE.NO_EXPRESSION, ""You could give me a cannon...""); addNPC(CAPTAIN_LAWGOF, HeadE.HAPPY_TALKING, ""Hah! You'd be lucky, those things are worth a fortune. I'll tell you what though, I'll write to the Cannon Engineer requesting him to sell you one. He controls production of the cannons. He won't be able to give you one, but for the right price, I'm sure he'll sell one to you.""); addPlayer(HeadE.NO_EXPRESSION, ""Hmmm... sounds interesting. I might take you up on that."", () -> player.getQuestManager().completeQuest(Quest.DWARF_CANNON)); } create(); } }" "package com.rs.game.content.quests.dwarfcannon; @QuestHandler( quest = Quest.DWARF_CANNON, startText = ""Talk to Captain Lawgof, south of the Coal Trucks, north-west of the Fishing Guild."", itemsText = ""None."", combatText = ""None."", rewardsText = ""750 Crafting XP
Permission to purchase and use a dwarf multicannon
Ability to smith cannonballs
Ability to add the ammo mould to your tool belt"", completedStage = 11 ) @PluginEventHandler public class DwarfCannon extends QuestOutline { public static final int RAILINGS = 14; public static final int DWARF_REMAINS = 0; public static final int TOOLKIT = 1; public static final int NULODIONS_NOTES = 3; public static final int AMMO_MOULD = 4; @Override public List getJournalLines(Player player, int stage) { ArrayList lines = new ArrayList<>(); switch (stage) { case 0: lines.add(""I can start this quest by speaking to Lawgof the Dwarven""); lines.add(""Captain of the Black Watch. He is defending an area north-""); lines.add(""west of the Fishing Guild against goblin attack.""); break; case 1: lines.add(""I have spoken to Captain Lawgof, he recruited me into the""); lines.add(""Black Guard and asked me to help the dwarves.""); lines.add(""My first task is to fix the broken railings""); lines.add(""in the dwarves defensive parameter.""); break; case 2: lines.add(""I have repaired all the broken railings,""); lines.add(""I should report back to Captain lawgof.""); break; case 3: lines.add(""Captain Lawgof has asked me to check up on his guards at""); lines.add(""the watchtower to the South of his camp.""); if (player.getVars().getVar(0) == 1) { lines.add(""I went to the watchtower where I found the remains of""); lines.add(""Gilob.""); lines.add(""I should take them back to Captain Lawgof.""); } else if (player.getVars().getVar(0) == 2) { lines.add(""I went to the watchtower but no one was there.""); lines.add(""I haven't found Gilob, I wonder what happened to him.""); } break; case 4: lines.add(""I gave the remains to Captain Lawgof.""); lines.add(""He sent me to find the Goblin base, South-east of the camp.""); break; case 5: lines.add(""I found the Goblin's base.""); lines.add(""Next I need to find the Dwarf child, Lollk.""); break; case 6: lines.add(""I have rescued Lollk and sent him back to the Captain.""); lines.add(""I need to speak to Captain Lawgof again.""); break; case 7: lines.add(""Now that Lollk has returned safely to the Dwarves.""); lines.add(""Captain Lawgof requested that I help repair the sabotaged cannon.""); break; case 8: lines.add(""After some tinkering and lucky guess work. I think I have successfully""); lines.add(""repaired the cannon. I should tell Captain Lawgof.""); break; case 9: lines.add(""I have been asked to perform one last favour and retreive the""); lines.add(""instructions for the cannon. The Dwarf Cannon engineer Nulodion""); lines.add(""should be at the Black Guard camp south of ice mountain.""); break; case 10: lines.add(""Nulodion has provided me with an ammo mould and instructions.""); lines.add(""I should return to Captain Lawgof.""); break; case 11: lines.add(""I can now buy a multicannon from Nulodion as a reward.""); lines.add(""""); lines.add(""""); lines.add(""QUEST COMPLETE!""); break; default: lines.add(""Invalid quest stage. Report this to an administrator.""); break; } return lines; } @Override public void complete(Player player) { player.getSkills().addXpQuest(Constants.CRAFTING, 750); sendQuestCompleteInterface(player, 1); } public static LoginHandler login = new LoginHandler(e -> updateVars(e.getPlayer())); public static void updateVars(Player player) { if (player.getQuestManager().getStage(Quest.DWARF_CANNON) == 3 && !player.getInventory().containsItem(DWARF_REMAINS)) player.getVars().setVar(0, 3); else if (player.getQuestManager().getStage(Quest.DWARF_CANNON) >= 8 && !player.isQuestComplete(Quest.DWARF_CANNON)) player.getVars().setVar(0, 8); } public static ButtonClickHandler handleToolkit = new ButtonClickHandler(409, e -> {}); public static ItemOnObjectHandler handleItemOnRailings = new ItemOnObjectHandler(new Object[] { 15590, 15591, 15592, 15593, 15594, 15595 }, new Object[] { 14 }, e -> { if (e.getPlayer().getQuestManager().getStage(Quest.DWARF_CANNON) != 1) return; int varbit = e.getObject().getDefinitions().varpBit; if ((varbit != -1) && (e.getPlayer().getVars().getVarBit(varbit) == 0)) { e.getPlayer().setNextAnimation(new Animation(4190)); if (Utils.random(4) == 0) { e.getPlayer().getVars().saveVarBit(varbit, 1); e.getPlayer().getInventory().deleteItem(14, 1); e.getPlayer().sendMessage(""This railing is now fixed.""); if (checkRemainingRepairs(e.getPlayer()) == 0) e.getPlayer().startConversation(new Dialogue(new PlayerStatement(HeadE.CALM, ""I've fixed all these railings now.""))); e.getPlayer().getQuestManager().setStage(Quest.DWARF_CANNON, 2); } else failedRepair(e.getPlayer()); } else e.getPlayer().sendMessage(""That railing does not need to be repaired.""); }); public static ObjectClickHandler handleRailingClick = new ObjectClickHandler(new Object[] { 15590, 15591, 15592, 15593, 15594, 15595 }, e -> { if (e.getOption().equals(""Inspect"")) if (e.getPlayer().getVars().getVarBit(e.getObject().getDefinitions().varpBit) == 1) e.getPlayer().startConversation(new Dialogue(new SimpleStatement(""That railing does not need to be replaced.""))); else { e.getPlayer().startConversation(new Dialogue(new SimpleStatement(""This railing is broken and needs to be replaced.""))); if (e.getPlayer().getInventory().containsItem(14)) { e.getPlayer().setNextAnimation(new Animation(4190)); if (Utils.random(4) == 0) { e.getPlayer().getVars().saveVarBit(e.getObject().getDefinitions().varpBit, 1); e.getPlayer().getInventory().deleteItem(14, 1); if (checkRemainingRepairs(e.getPlayer()) == 0) e.getPlayer().getQuestManager().setStage(Quest.DWARF_CANNON, 2); } else failedRepair(e.getPlayer()); } } }); public static ObjectClickHandler handleLadderClimbUp = new ObjectClickHandler(new Object[] { 11 }, e -> { e.getPlayer().useLadder(e.getPlayer().transform(0, 0, 1)); updateVars(e.getPlayer()); }); public static ObjectClickHandler handleEnterCaveEntrance = new ObjectClickHandler(new Object[] { 2 }, e -> { e.getPlayer().useStairs(Tile.of(2620, 9796, 0)); if (e.getPlayer().getQuestManager().getStage(Quest.DWARF_CANNON) == 4) e.getPlayer().getQuestManager().setStage(Quest.DWARF_CANNON, 5); }); public static ObjectClickHandler handleClimbMudPile = new ObjectClickHandler(new Object[] { 13 }, e -> e.getPlayer().useStairs(Tile.of(2627, 3391, 0))); public static ObjectClickHandler handleDwarfRemains = new ObjectClickHandler(new Object[] { 0 }, e -> { if (e.getOption().equals(""Take"")) if ((e.getPlayer().getQuestManager().getStage(Quest.DWARF_CANNON) == 3) && !e.getPlayer().getInventory().containsItem(0)) { e.getPlayer().startConversation(new Dialogue(new SimpleStatement(""I had better take these remains.""))); e.getPlayer().getVars().saveVar(0, 0); e.getPlayer().getInventory().addItem(0, 1); } }); public static ObjectClickHandler handleSearchCrate = new ObjectClickHandler(new Object[] { 1 }, e -> { if (e.getOption().equals(""Search"")) if ((e.getPlayer().getQuestManager().getStage(Quest.DWARF_CANNON) == 5)) e.getPlayer().startConversation(new LollkD(e.getPlayer())); }); public static ObjectClickHandler handleCannonRepair = new ObjectClickHandler(new Object[] { 15597 }, e -> { if (e.getOption().equals(""Inspect"")) { if ((e.getPlayer().getQuestManager().getStage(Quest.DWARF_CANNON) == 7)) { if (e.getPlayer().containsItem(TOOLKIT)) { e.getPlayer().getQuestManager().setStage(Quest.DWARF_CANNON, 8); e.getPlayer().sendMessage(""You repair the cannon using the toolkit Lawgof gave you.""); updateVars(e.getPlayer()); } else e.getPlayer().sendMessage(""You need a toolkit to repair the cannon.""); } else e.getPlayer().sendMessage(""It looks pretty broken.""); } else if (e.getOption().equals(""Fire"")) e.getPlayer().sendMessage(""I should leave that up to the mercenaries.""); else if (e.getOption().equals(""Pick-up"")) e.getPlayer().sendMessage(""That isn't your cannon!""); }); public static int checkRemainingRepairs(Player p) { int count = 6; for (int i = 0; i <= 5; i++) if (p.getVars().getVarBit(2240 + i) == 1) count--; return count; } public static void failedRepair(Player p) { String[] chatMessages = { ""You cut your hand on the rusty old railing."", ""You strain your back trying to handle the railings."", ""You accidentally crush your hand in the railing."" }; String[] playerMessages = { ""Ow!"", ""Urrrgh!"", ""Gah!"", ""Oooch!"" }; p.sendMessage(chatMessages[Utils.getRandomInclusive(2)]); p.forceTalk(playerMessages[Utils.getRandomInclusive(3)]); p.applyHit(new Hit(2, HitLook.TRUE_DAMAGE)); } }" "package com.rs.game.content.quests.dwarfcannon; @PluginEventHandler public class GuardD extends Conversation { private static final int GUARD = 206; public static NPCClickHandler talkToLawgof = new NPCClickHandler(new Object[] { GUARD }, e -> e.getPlayer().startConversation(new GuardD(e.getPlayer()))); public GuardD(Player player) { super(player); int currentStage = player.getQuestManager().getStage(Quest.DWARF_CANNON); switch(currentStage) { case 0: addPlayer(HeadE.NO_EXPRESSION, ""Hello.""); addNPC(GUARD, HeadE.ANGRY, ""Don't distract me while I'm on duty! This mine has to be protected!""); addPlayer(HeadE.CONFUSED, ""What's going to attack a mine?""); addNPC(GUARD, HeadE.ANGRY, ""Goblins! They wander everywhere, attacking anyone they think is small enough to be an easy victim. We need more cannons to fight them off properly.""); addPlayer(HeadE.NO_EXPRESSION, ""Cannons? Those sound expensive.""); addNPC(GUARD, HeadE.CALM, ""A new cannon can cost 750,000 coins, and the ammo isn't easy to get, but they can do an enormous amount of damage with each shot. When you've got an important mine like this one to protect, it's worth the expense.""); addPlayer(HeadE.HAPPY_TALKING, ""Thanks for the information.""); addNPC(GUARD, HeadE.CALM, ""You're welcome. Now please let me get on with my guard duties.""); addPlayer(HeadE.NO_EXPRESSION, ""Alright, I'll leave you alone now.""); break; default: addPlayer(HeadE.NERVOUS, ""I should probably leave him to his duties.""); } create(); } }" "package com.rs.game.content.quests.dwarfcannon; public class LollkD extends Conversation { private static final int Lollk = 207; public LollkD(Player player) { super(player); int currentStage = player.getQuestManager().getStage(Quest.DWARF_CANNON); switch(currentStage) { case 5: addNPC(Lollk, HeadE.HAPPY_TALKING, ""Thank the heavens, you saved me! I thought I'd be goblin lunch for sure!""); addPlayer(HeadE.NO_EXPRESSION, ""Are you okay?""); addNPC(Lollk, HeadE.HAPPY_TALKING, ""I think so, I'd better run off home.""); addPlayer(HeadE.NO_EXPRESSION, ""That's right, you get going. I'll catch up.""); addNPC(Lollk, HeadE.HAPPY_TALKING, ""Thanks again, brave adventurer."", () -> { player.sendMessage(""The dwarf child runs off into the caverns.""); player.getQuestManager().setStage(Quest.DWARF_CANNON, 6); }); break; default: addPlayer(HeadE.NERVOUS, ""Hello.""); addNPC(Lollk, HeadE.HAPPY_TALKING, ""Hello.""); } create(); } }" "package com.rs.game.content.quests.dwarfcannon; @PluginEventHandler public class NulodionD extends Conversation { private static final int NULODION = 209; private static final int AMMO_MOULD = 4; private static final int NULODIONS_NOTES = 3; public static NPCClickHandler talkToNulodion = new NPCClickHandler(new Object[] { NULODION }, e -> { if (e.getOption().equals(""Talk-to"")) e.getPlayer().startConversation(new NulodionD(e.getPlayer())); else if (e.getOption().equals(""Trade"")) { if (!e.getPlayer().isQuestComplete(Quest.DWARF_CANNON)) { e.getPlayer().startConversation(new Conversation(new Dialogue().addNPC(NULODION, HeadE.CONFUSED, ""Who are you?""))); return; } ShopsHandler.openShop(e.getPlayer(), ""nulodions_cannon_parts""); } else if (e.getOption().equals(""Replace-cannon"")) if (DwarfMultiCannon.canFreelyReplace(e.getPlayer())) e.getPlayer().startConversation(new Conversation(new Dialogue().addNPC(NULODION, HeadE.HAPPY_TALKING, ""Please try not to lose it next time.."", () -> { for (int item : DwarfMultiCannon.CANNON_PIECES[e.getPlayer().getPlacedCannon()-1]) e.getPlayer().getInventory().addItemDrop(item, 1); e.getPlayer().setPlacedCannon(0); }))); else e.getPlayer().startConversation(new Conversation(new Dialogue().addNPC(NULODION, HeadE.CONFUSED, ""I haven't found any cannons of yours.""))); }); public static ItemClickHandler handleNotes = new ItemClickHandler(new Object[] { NULODIONS_NOTES }, new String[] { ""Read"" }, e -> e.getPlayer().sendMessage(""Ammo for the Dwarf Multi Cannon must be made from steel bars. The bars must be heated in a furnace and used with the ammo mould."")); public NulodionD(Player player) { super(player); if (player.getQuestManager().getStage(Quest.DWARF_CANNON) == 9) { addPlayer(HeadE.NO_EXPRESSION, ""Hello there.""); addNPC(NULODION, HeadE.NO_EXPRESSION, ""Can I help you?""); addPlayer(HeadE.NO_EXPRESSION, ""Captain Lawgof sent me. He's having trouble with his cannon.""); addNPC(NULODION, HeadE.LAUGH, ""Of course, we forgot to send the ammo mould!""); addPlayer(HeadE.NO_EXPRESSION, ""It fires a mould?""); addNPC(NULODION, HeadE.NO_EXPRESSION, ""Don't be silly - the ammo's made by using a mould. Here, take these to him. The instructions explain everything.""); addSimple(""The Cannon Engineer gives you some notes and a mould."", () -> { player.getInventory().addItemDrop(AMMO_MOULD, 1); player.getInventory().addItemDrop(NULODIONS_NOTES, 1); }); addPlayer(HeadE.HAPPY_TALKING, ""That's great, thanks.""); addNPC(NULODION, HeadE.HAPPY_TALKING, ""Thank you, adventurer. The Dwarf Black Guard will remember this.""); } else if (player.isQuestComplete(Quest.DWARF_CANNON) && !player.getInventory().containsItem(AMMO_MOULD) && !player.getBank().containsItem(AMMO_MOULD, 1)) { addPlayer(HeadE.UPSET, ""Hello again.""); addPlayer(HeadE.UPSET, ""I've lost the cannonball mould.""); addNPC(NULODION, HeadE.SHAKING_HEAD, ""Deary me, you are trouble. Here, take this one.""); addItem(AMMO_MOULD, ""The cannon engineer gives you another ammo mould."", () -> player.getInventory().addItemDrop(AMMO_MOULD, 1)); } else { addPlayer(HeadE.NO_EXPRESSION, ""Hello again.""); addNPC(NULODION, HeadE.NO_EXPRESSION, ""Hello.""); } create(); } }" "package com.rs.game.content.quests.ernestthechicken; @QuestHandler( quest = Quest.ERNEST_CHICKEN, startText = ""Talk to Veronica, south of Draynor Manor gates."", itemsText = ""None."", combatText = ""None, but watch out for those trees in the manor grounds."", rewardsText = ""3,000 coins
10 eggs
300 feathers"", completedStage = 5 ) @PluginEventHandler public class ErnestTheChicken extends QuestOutline { public final static int NOT_STARTED = 0; public final static int STARTED = 1; public final static int KNOWS_ABOUT_CHICKEN = 2; public final static int NEEDS_PARTS = 3; public final static int ERNEST_NOT_CHICKEN=4; public final static int QUEST_COMPLETE = 5; //items private final static int PRESSURE_GAUGE = 271; private final static int FISH_FOOD = 272; private final static int POISON = 273; private final static int POISONED_FISH_FOOD = 274; private final static int GRIMY_KEY = 275; private final static int RUBBER_TUBE = 276; private final static int SPADE = 952; @Override public List getJournalLines(Player player, int stage) { ArrayList lines = new ArrayList<>(); switch(stage) { case NOT_STARTED: lines.add(""Veronica is very worried. Her fiancé went into ""); lines.add(""the big spooky manor house to ask for directions.""); lines.add(""An hour later and he's still not out yet.""); lines.add(""""); lines.add(""I can start this quest by speaking to Veronica, south""); lines.add(""of the Draynor mansion's gates.""); lines.add(""""); break; case STARTED: lines.add(""I must investigate the mansion and find Ernest""); lines.add(""Veronica hinted she saw lights on the top floor.""); lines.add(""""); break; case KNOWS_ABOUT_CHICKEN: lines.add(""Ernest has been turned into a chicken!""); lines.add(""""); break; case NEEDS_PARTS: lines.add(""Professor Oddenstein needs machine parts to turn""); lines.add(""Ernest back into a human. I can find all parts inside""); lines.add(""the Draynor estate""); lines.add(""""); break; case ERNEST_NOT_CHICKEN: lines.add(""Ernest is not a chicken anymore. I ought to speak to""); lines.add(""professor Oddenstein to claim my reward""); lines.add(""""); break; case QUEST_COMPLETE: lines.add(""""); lines.add(""""); lines.add(""QUEST COMPLETE!""); break; default: lines.add(""Invalid quest stage. Report this to an administrator.""); break; } return lines; } @Override public void complete(Player player) { player.getInventory().addCoins(3000); player.getInventory().addItem(new Item(1945, 10), true); player.getInventory().addItem(new Item(314, 300), true); sendQuestCompleteInterface(player, 314); } public static ObjectClickHandler handleManorFrontDoor = new ObjectClickHandler(new Object[] { 47424, 47421 }, e -> { Player p = e.getPlayer(); if(p.getY() <= e.getObject().getY()) if(p.getBool(""EverEnteredDraynorManor"")) { handleDoubleDoor(p, e.getObject()); p.sendMessage(""The doors slam shut behind you.""); } else p.startConversation(new Conversation(p) { { addPlayer(HeadE.NERVOUS, ""There's a sign on the door that says...""); addSimple(""Adventurers beware: Going in doesn't mean you'll come out again.""); addOptions(""Enter Draynor Manor?"", new Options() { @Override public void create() { option(""Yes."", new Dialogue() .addNext(()->{ p.save(""EverEnteredDraynorManor"", true); handleDoubleDoor(p, e.getObject()); p.sendMessage(""The doors slam shut behind you.""); })); option(""No."", new Dialogue()); } }); create(); } }); else p.sendMessage(""The doors are firmly closed.""); }); public static ItemOnItemHandler handlePoisonOnFishFood = new ItemOnItemHandler(POISON, new int[] { FISH_FOOD }, e -> { Inventory inv = e.getPlayer().getInventory(); inv.deleteItem(e.getItem1()); inv.deleteItem(e.getItem2()); inv.addItem(POISONED_FISH_FOOD, 1); }); public static ItemOnObjectHandler handleCompostHeapItem = new ItemOnObjectHandler(new Object[] { 152 }, new Object[] { SPADE }, e -> { if(e.getPlayer().getInventory().containsItem(GRIMY_KEY, 1)) { e.getPlayer().sendMessage(""I already have the key""); return; } e.getPlayer().setNextAnimation(new Animation(830)); e.getPlayer().getInventory().addItem(GRIMY_KEY, 1); }); public static ObjectClickHandler handleCompostHeapSearch = new ObjectClickHandler(new Object[] { 152 }, e -> { if(e.getPlayer().getInventory().containsItem(GRIMY_KEY, 1)) { e.getPlayer().sendMessage(""I already have the key""); return; } if(e.getPlayer().getInventory().containsItem(SPADE, 1)) { e.getPlayer().setNextAnimation(new Animation(830)); e.getPlayer().getInventory().addItem(GRIMY_KEY, 1); } else e.getPlayer().sendMessage(""I appear to need a spade.""); }); public static ObjectClickHandler handleFountainSearch = new ObjectClickHandler(new Object[] { 153 }, e -> { Player p = e.getPlayer(); if(p.getInventory().containsItem(PRESSURE_GAUGE, 1)) { p.startConversation(new Conversation(p) {{ addPlayer(HeadE.CALM_TALK, ""I already have the pressure gauge...""); create(); }}); return; } if(p.getTempAttribs().getB(""FountainFishDead"")) p.startConversation(new Conversation(p) { { addPlayer(HeadE.CALM_TALK, ""There seems to be a preassure gauge in here..."", () -> p.getInventory().addItem(PRESSURE_GAUGE, 1)); addPlayer(HeadE.CALM_TALK, ""... and a lot of dead fish.""); create(); } }); else p.startConversation(new Conversation(p) { { addPlayer(HeadE.NERVOUS, ""There appear to be deadly fish in the water...""); create(); } }); }); public static ItemOnObjectHandler handleFountainItem = new ItemOnObjectHandler(new Object[] { 153 }, null, e -> { Player p = e.getPlayer(); if(e.getItem().getId() != POISONED_FISH_FOOD) { p.startConversation(new Conversation(p) {{ addPlayer(HeadE.SKEPTICAL_THINKING, ""What good would that do?""); create(); }}); return; } p.getInventory().deleteItem(POISONED_FISH_FOOD, 1); WorldTasks.scheduleLooping(new Task() { int tick = 0; @Override public void run() { if(tick == 0) p.sendMessage(""You pour the poisoned fish food into the fountain.""); if(tick == 1) p.sendMessage(""The piranhas start eating the food...""); if(tick == 2) { p.sendMessage(""...Then die and float to the surface.""); p.getTempAttribs().setB(""FountainFishDead"", true); stop(); } tick++; } }, 0, 1); }); public static ObjectClickHandler handleRubberTubeDoor = new ObjectClickHandler(new Object[] { 131 }, e -> { if(e.getPlayer().getInventory().containsItem(GRIMY_KEY) || e.getPlayer().getY() <= e.getObject().getY()) handleDoor(e.getPlayer(), e.getObject()); else e.getPlayer().startConversation(new Conversation(e.getPlayer()) {{ addPlayer(HeadE.SKEPTICAL_THINKING, ""It appears to need a key""); create(); }}); }); public static ItemAddedToInventoryHandler handleRubberTubePickup = new ItemAddedToInventoryHandler(RUBBER_TUBE, e -> { Player p = e.getPlayer(); List npcs = World.getNPCsInChunkRange(p.getChunkId(), 1); for(NPC npc : npcs) if(npc.getId() == 3291) npc.setTarget(p); }); public static ObjectClickHandler handleDraynorManorLadders = new ObjectClickHandler(new Object[] { 47574, 47575, 133, 32015 }, e -> { GameObject obj = e.getObject(); if(obj.getTile().matches(Tile.of(3105, 3363, 2)))//To 2nd floor from professor e.getPlayer().useLadder(Tile.of(3105, 3364, 1)); if(obj.getTile().matches(Tile.of(3105, 3363, 1)))//to 3rd floor to professor e.getPlayer().useLadder(Tile.of(3105, 3362, 2)); if(obj.getTile().matches(Tile.of(3092, 3362, 0)))//To basement from 1st floor e.getPlayer().useLadder(Tile.of(3117, 9753, 0)); if(obj.getTile().matches(Tile.of(3117, 9754, 0)))//To 1st floor from basement e.getPlayer().useLadder(Tile.of(3092, 3361, 0)); }); public static LoginHandler onLogin = new LoginHandler(e -> { if(e.getPlayer().getQuestManager().getStage(Quest.ERNEST_CHICKEN) >= ERNEST_NOT_CHICKEN) e.getPlayer().getVars().setVar(32, 3); else e.getPlayer().getVars().setVar(32, 0); }); }" "package com.rs.game.content.quests.ernestthechicken; @PluginEventHandler public class OddensteinErnestChickenD extends Conversation { private static final int ODDENSTEIN = 286; private static final int ERNEST = 287; static int PRESSURE_GAUGE = 271; static int RUBBER_TUBE = 276; static int OIL_CAN = 277; public OddensteinErnestChickenD(Player player) { super(player); switch (player.getQuestManager().getStage(Quest.ERNEST_CHICKEN)) { case ErnestTheChicken.NOT_STARTED: case ErnestTheChicken.STARTED: case ErnestTheChicken.KNOWS_ABOUT_CHICKEN: case ErnestTheChicken.QUEST_COMPLETE: addNPC(ODDENSTEIN, HeadE.HAPPY_TALKING, ""Be careful in here, there's lots of dangerous equipment.""); addOptions(""Choose an option:"", new Options() { @Override public void create() { if(player.getQuestManager().getStage(Quest.ERNEST_CHICKEN) == ErnestTheChicken.STARTED || player.getQuestManager().getStage(Quest.ERNEST_CHICKEN) == ErnestTheChicken.KNOWS_ABOUT_CHICKEN) option(""I'm looking for a guy called Ernest"", new Dialogue() .addPlayer(HeadE.CALM_TALK, ""I'm looking for a guy called Ernest."") .addNPC(ODDENSTEIN, HeadE.HAPPY_TALKING, ""Ah, Ernest - top notch bloke - he's helping me with my experiments."") .addPlayer(HeadE.SKEPTICAL_THINKING, ""So you know where he is?"") .addNPC(ODDENSTEIN, HeadE.HAPPY_TALKING, ""He's that chicken over there."") .addPlayer(HeadE.SKEPTICAL_THINKING, ""Ernest is a chicken? Are you sure?"") .addNPC(ODDENSTEIN, HeadE.HAPPY_TALKING, ""Oh, he isn't normally a chicken, or, at least, he wasn't until he helped me test my"" + "" pouletmorph machine. "") .addNPC(ODDENSTEIN, HeadE.TALKING_ALOT, ""It was originally going to be called a transmutation machine, but after testing it, pouletmorph "" + ""seems more appropriate."", () -> player.getQuestManager().setStage(Quest.ERNEST_CHICKEN, ErnestTheChicken.KNOWS_ABOUT_CHICKEN)) .addOptions(""Choose an option:"", new Options() { @Override public void create() { option(""I'm glad Veronica didn't actually get engaged to a chicken"", new Dialogue() .addNPC(ODDENSTEIN, HeadE.HAPPY_TALKING, ""Who's Veronica?"") .addPlayer(HeadE.ANGRY, ""Ernest's fiancée. She probably doesn't want to marry a chicken."") .addNPC(ODDENSTEIN, HeadE.HAPPY_TALKING, ""Oh, I dunno. She could have free eggs for breakfast every morning"") .addPlayer(HeadE.FRUSTRATED, ""I think you'd better change him back"") .addPlayer(HeadE.ANGRY, ""Change him back this instant!"") .addNPC(ODDENSTEIN, HeadE.NERVOUS, ""Umm... It's not so easy..."") .addNPC(ODDENSTEIN, HeadE.NERVOUS, ""My machine is broken, and the house gremlins have run off with some vital bits."") .addPlayer(HeadE.FRUSTRATED, ""Well I can look for them."") .addNPC(ODDENSTEIN, HeadE.CALM_TALK, ""That would be a help. They'll be somewhere in the manor house or its grounds, "" + ""the gremlins never get further than the entrance gate."") .addNPC(ODDENSTEIN, HeadE.CALM_TALK, ""I'm missing the pressure gauge and a rubber tube. They've also taken my oil "" + ""can, which I'm going to need to get this thing started again."", () -> player.getQuestManager().setStage(Quest.ERNEST_CHICKEN, ErnestTheChicken.NEEDS_PARTS))); option(""Change him back this instant"", new Dialogue() .addPlayer(HeadE.ANGRY, ""Change him back this instant!"") .addNPC(ODDENSTEIN, HeadE.NERVOUS, ""Umm... It's not so easy..."") .addNPC(ODDENSTEIN, HeadE.NERVOUS, ""My machine is broken, and the house gremlins have run off with some vital bits."") .addPlayer(HeadE.FRUSTRATED, ""Well I can look for them."") .addNPC(ODDENSTEIN, HeadE.CALM_TALK, ""That would be a help. They'll be somewhere in the manor house or its grounds, "" + ""the gremlins never get further than the entrance gate."") .addNPC(ODDENSTEIN, HeadE.CALM_TALK, ""I'm missing the pressure gauge and a rubber tube. They've also taken my oil "" + ""can, which I'm going to need to get this thing started again."", () -> player.getQuestManager().setStage(Quest.ERNEST_CHICKEN, ErnestTheChicken.NEEDS_PARTS))); } })); option(""What does this machine do?"", new Dialogue() .addPlayer(HeadE.SKEPTICAL_THINKING, ""What does this machine do?"") .addNPC(ODDENSTEIN, HeadE.NERVOUS, ""Nothing at the moment... It's broken. It's meant to be a transmutation machine."") .addNPC(ODDENSTEIN, HeadE.HAPPY_TALKING, ""It has also spent time as a time travel machine, and a dramatic lightning generator, and a "" + ""thing for generating monsters."")); option(""Is this your house?"", new Dialogue() .addPlayer(HeadE.CALM_TALK, ""Is this your house?"") .addNPC(ODDENSTEIN, HeadE.HAPPY_TALKING, ""No, I'm just one of the tenants. It belongs to the count who lives in the basement."") .addNPC(ODDENSTEIN, HeadE.HAPPY_TALKING, ""Be careful in here, there's lots of dangerous equipment."")); } }); break; case ErnestTheChicken.NEEDS_PARTS: if(player.getInventory().containsItem(OIL_CAN) && player.getInventory().containsItem(PRESSURE_GAUGE) && player.getInventory().containsItem(RUBBER_TUBE)) { addPlayer(HeadE.HAPPY_TALKING, ""I have gotten all your parts!""); addSimple(""You give a rubber tube, a pressure gauge, and a can of oil to the professor.""); addSimple(""Oddenstein starts up the machine.""); addSimple(""The machine hums and shakes."", ()-> { List npcs = World.getNPCsInChunkRange(player.getChunkId(), 1); for(NPC npc : npcs) if(npc.getId() == 3290) npc.transformIntoNPC(287); WorldTasks.schedule(new Task() { @Override public void run() { for(NPC npc : npcs) if(npc.getId() == 287) npc.transformIntoNPC(3290); player.getVars().setVar(32, 3); } }, Ticks.fromSeconds(60)); player.getQuestManager().setStage(Quest.ERNEST_CHICKEN, ErnestTheChicken.ERNEST_NOT_CHICKEN); }); addNPC(ERNEST, HeadE.HAPPY_TALKING, ""Thank you, it was dreadfully irritating being a chicken. How can *cluck* I ever thank you?""); addPlayer(HeadE.HAPPY_TALKING, ""A cash reward is always nice...""); addNPC(ERNEST, HeadE.HAPPY_TALKING, ""Of course, of course. You may as well have these eggs and *cluck* feathers I mysteriously *bwark*"" + "" found in my pockets.""); addNext(()->{ player.getVars().setVar(32, 3); player.getInventory().deleteItem(OIL_CAN, 1); player.getInventory().deleteItem(RUBBER_TUBE, 1); player.getInventory().deleteItem(PRESSURE_GAUGE, 1); player.getQuestManager().completeQuest(Quest.ERNEST_CHICKEN);}); } else { player.getVars().setVar(32, 3); addNPC(ODDENSTEIN, HeadE.HAPPY_TALKING, ""Have you found them yet?""); addPlayer(HeadE.SAD_MILD, ""I'm afraid I don't have all of them yet!""); addNPC(ODDENSTEIN, HeadE.HAPPY_TALKING, ""Remember, I need a rubber tube, a pressure gauge and a can of oil. Then your friend can stop "" + ""being a chicken.""); } break; case ErnestTheChicken.ERNEST_NOT_CHICKEN: addNPC(ODDENSTEIN, HeadE.HAPPY_TALKING, ""Ernest left this for you...""); addNext(()->{ player.getInventory().deleteItem(OIL_CAN, 1); player.getInventory().deleteItem(RUBBER_TUBE, 1); player.getInventory().deleteItem(PRESSURE_GAUGE, 1); player.getQuestManager().completeQuest(Quest.ERNEST_CHICKEN);}); break; } } public static NPCClickHandler handleProfessor = new NPCClickHandler(new Object[] { ODDENSTEIN }, e -> e.getPlayer().startConversation(new OddensteinErnestChickenD(e.getPlayer()).getStart())); }" "package com.rs.game.content.quests.ernestthechicken; @PluginEventHandler public class PuzzleRoom { //Object Ids static int LEVER_A = 146; static int LEVER_B = 147; static int LEVER_C = 148; static int LEVER_D = 149; static int LEVER_E = 150; static int LEVER_F = 151; static int DOOR1 = 144; static int DOOR2 = 2373; static int DOOR3 = 145; static int DOOR4 = 140; static int DOOR5 = 143; static int DOOR6 = 138; static int DOOR7 = 137; static int DOOR8 = 2374; static int DOOR9 = 141; //vars static int LEVER_A_V = 1788; static int LEVER_B_V = 1789; static int LEVER_C_V = 1790; static int LEVER_D_V = 1791; static int LEVER_E_V = 1792; static int LEVER_F_V = 1793; static int DOOR1_V = 1801; static int DOOR2_V = 1796; static int DOOR3_V = 1802; static int DOOR4_V = 1797; static int DOOR5_V = 1800; static int DOOR6_V = 1795; static int DOOR7_V = 1794; static int DOOR8_V = 1799; static int DOOR9_V = 1798; public static ObjectClickHandler handleLevers = new ObjectClickHandler(new Object[] { LEVER_A, LEVER_B, LEVER_C, LEVER_D, LEVER_E, LEVER_F }, e -> { GameObject obj = e.getObject(); VarManager vars = e.getPlayer().getVars(); int id = obj.getId(); //step 1/5, https://runescape.salmoneus.net/runescape-2007/quests/ernest-the-chicken.html if(vars.getVar(LEVER_A_V) == 0 && id == LEVER_A) { vars.setVarBit(LEVER_A_V, 1); if(vars.getVarBit(LEVER_B_V) == 1) { vars.setVarBit(DOOR1_V, 1); vars.setVarBit(DOOR4_V, 1); vars.setVarBit(DOOR5_V, 1); } } if(vars.getVar(LEVER_B_V) == 0 && id == LEVER_B) { vars.setVarBit(LEVER_B_V, 1); if(vars.getVarBit(LEVER_A_V) == 1) { vars.setVarBit(DOOR1_V, 1); vars.setVarBit(DOOR4_V, 1); vars.setVarBit(DOOR5_V, 1); } } //step 3 if(vars.getVar(LEVER_D_V) == 0 && id == LEVER_D) { vars.setVarBit(LEVER_D_V, 1); vars.setVarBit(DOOR2_V, 1); vars.setVarBit(DOOR3_V, 1); //reset A & B vars.setVarBit(LEVER_A_V, 0); vars.setVarBit(LEVER_B_V, 0); vars.setVarBit(DOOR1_V, 0); vars.setVarBit(DOOR4_V, 0); vars.setVarBit(DOOR5_V, 0); } //Step 7//11 if(vars.getVar(LEVER_E_V) == 0 && id == LEVER_E) { vars.setVarBit(LEVER_E_V, 1); if(vars.getVarBit(LEVER_F_V) == 1) { vars.setVarBit(DOOR6_V, 1); vars.setVarBit(DOOR7_V, 1); vars.setVarBit(DOOR1_V, 0); vars.setVarBit(DOOR4_V, 0); vars.setVarBit(DOOR5_V, 0); } if(vars.getVarBit(LEVER_C_V) == 1) vars.setVarBit(DOOR9_V, 1); } if(vars.getVar(LEVER_F_V) == 0 && id == LEVER_F) { vars.setVarBit(LEVER_F_V, 1); if(vars.getVarBit(LEVER_E_V) == 1) { vars.setVarBit(DOOR6_V, 1); vars.setVarBit(DOOR7_V, 1); } } //step 9 if(vars.getVar(LEVER_C_V) == 0 && id == LEVER_C) { vars.setVarBit(LEVER_C_V, 1); vars.setVarBit(LEVER_E_V, 0); vars.setVarBit(DOOR8_V, 1); vars.setVarBit(DOOR2_V, 0); } }); public static ObjectClickHandler handleDoors = new ObjectClickHandler(false, new Object[] { DOOR1, DOOR2, DOOR3, DOOR4, DOOR5, DOOR6, DOOR7, DOOR8, DOOR9 }, e -> e.getPlayer().setRouteEvent(new RouteEvent(e.getObject(), () -> { if (!WorldUtil.isInRange(e.getPlayer().getTile(), e.getObject().getTile(), 2)) return; if(e.getObject().getId() == DOOR1 || e.getObject().getId() == DOOR3 || e.getObject().getId() == DOOR8 || e.getObject().getId() == DOOR5) handlePuzzle2Door(e.getPlayer(), e.getObject(), 2); else handlePuzzleDoor(e.getPlayer(), e.getObject(), 2); }))); private static void handlePuzzleDoor(Player player, GameObject object, int offset) { boolean open = object.getDefinitions(player).containsOption(""Open""); int rotation = object.getRotation(open ? offset : -1 + offset); Tile adjusted = object.getTile(); adjusted = switch (rotation) { case 0 -> adjusted.transform(open ? 0 : 1, 0, 0); case 1 -> adjusted.transform(0, open ? 1 : 0, 0); case 2 -> adjusted.transform(open ? 0 : 0, 1, 0); case 3 -> adjusted.transform(0, open ? 0 : 1, 0); default -> adjusted; }; Door opp = new Door(object.getId(), object.getType(), object.getRotation(open ? 3 : -1), adjusted, object); Tile toTile = object.getTile(); toTile = switch (object.getRotation()) { case 0 -> toTile.transform(player.getX() < object.getX() ? 0 : -1, 0, 0); case 1 -> toTile.transform(0, player.getY() > object.getY() ? 0 : 1, 0); case 2 -> toTile.transform(player.getX() > object.getX() ? 0 : 1, 0, 0); case 3 -> toTile.transform(0, player.getY() < object.getY() ? 0 : -1, 0); default -> toTile; }; World.spawnObjectTemporary(new GameObject(object, 83), 2, true); World.spawnObjectTemporary(opp, 2, true); player.addWalkSteps(toTile, 3, false); } private static void handlePuzzle2Door(Player player, GameObject object, int offset) { boolean open = object.getDefinitions(player).containsOption(""Open""); int rotation = object.getRotation(open ? offset : -1 + offset); Tile adjusted = object.getTile(); adjusted = switch (rotation) { case 0 -> adjusted.transform(open ? 0 : 1, 0, 0); case 1 -> adjusted.transform(-1, open ? 0 : 0, 0); case 2 -> adjusted.transform(open ? 1 : 0, 0, 0); case 3 -> adjusted.transform(0, open ? 0 : 1, 0); default -> adjusted; }; Door opp = new Door(object.getId(), object.getType(), object.getRotation(open ? 3 : -1), adjusted, object); Tile toTile = object.getTile(); toTile = switch (object.getRotation()) { case 0 -> toTile.transform(player.getX() < object.getX() ? 0 : -1, 0, 0); case 1 -> toTile.transform(0, player.getY() > object.getY() ? 0 : 1, 0); case 2 -> toTile.transform(player.getX() > object.getX() ? 0 : 1, 0, 0); case 3 -> toTile.transform(0, player.getY() < object.getY() ? 0 : -1, 0); default -> toTile; }; World.spawnObjectTemporary(new GameObject(object, 83), 2, true); World.spawnObjectTemporary(opp, 2, true); player.addWalkSteps(toTile, 3, false); } public static LoginHandler onLogin = new LoginHandler(e -> { e.getPlayer().getVars().setVarBit(LEVER_A_V, 0); e.getPlayer().getVars().setVarBit(LEVER_B_V, 0); e.getPlayer().getVars().setVarBit(LEVER_C_V, 0); e.getPlayer().getVars().setVarBit(LEVER_D_V, 0); e.getPlayer().getVars().setVarBit(LEVER_E_V, 0); e.getPlayer().getVars().setVarBit(LEVER_F_V, 0); e.getPlayer().getVars().setVarBit(DOOR1_V, 0); e.getPlayer().getVars().setVarBit(DOOR2_V, 0); e.getPlayer().getVars().setVarBit(DOOR3_V, 0); e.getPlayer().getVars().setVarBit(DOOR4_V, 0); e.getPlayer().getVars().setVarBit(DOOR5_V, 0); e.getPlayer().getVars().setVarBit(DOOR6_V, 0); e.getPlayer().getVars().setVarBit(DOOR7_V, 0); e.getPlayer().getVars().setVarBit(DOOR8_V, 0); e.getPlayer().getVars().setVarBit(DOOR9_V, 0); }); }" "package com.rs.game.content.quests.ernestthechicken; @PluginEventHandler public class VeronicaErnestChickenD extends Conversation { private static final int VERONICA = 285; public VeronicaErnestChickenD(Player player) { super(player); switch (player.getQuestManager().getStage(Quest.ERNEST_CHICKEN)) { case ErnestTheChicken.NOT_STARTED: addNPC(VERONICA, HeadE.NERVOUS, ""Can you please help me? I'm in a terrible spot of trouble. My fiance, Ernest, and I came upon this house. ""); addNPC(VERONICA, HeadE.UPSET, ""Seeing as we were a little lost, Ernest decided to go in and ask for directions. That was an hour ago..."" + "" and that house looks spooky.""); addNPC(VERONICA, HeadE.UPSET_SNIFFLE, ""Can you go and see if you can find him for me?""); addOptions(""Start Ernest The Chicken?"", new Options() { @Override public void create() { option(""Accept Quest"", new Dialogue() .addNPC(VERONICA, HeadE.HAPPY_TALKING, ""Thank you, thank you. I'm very grateful."", () -> player.getQuestManager().setStage(Quest.ERNEST_CHICKEN, ErnestTheChicken.STARTED)) .addNPC(VERONICA, HeadE.TALKING_ALOT, ""I think I spotted some lights flashing in one of the top floor windows, so you may want to "" + ""head up there first."")); option(""Not right now"", new Dialogue() .addNPC(VERONICA, HeadE.SAD_MILD, ""Oh. I'm so worried. I hope someone will help me soon."")); } }); break; case ErnestTheChicken.STARTED: addNPC(VERONICA, HeadE.WORRIED, ""Have you found my sweetheart yet?""); addPlayer(HeadE.CALM_TALK, ""No, not yet.""); break; case ErnestTheChicken.KNOWS_ABOUT_CHICKEN: case ErnestTheChicken.NEEDS_PARTS: addNPC(VERONICA, HeadE.WORRIED, ""Have you found my sweetheart yet?""); addPlayer(HeadE.CALM_TALK, ""Yes, he's a chicken.""); addNPC(VERONICA, HeadE.UPSET_SNIFFLE, ""I know he's not exactly brave but I think you're being a bit harsh.""); addPlayer(HeadE.CALM_TALK, ""No no, he's been turned into an actual chicken by a mad scientist.""); addNPC(VERONICA, HeadE.AMAZED, ""Eeeeeek!""); addNPC(VERONICA, HeadE.AMAZED_MILD, ""My poor darling, why must these things happen to us.""); addPlayer(HeadE.CALM_TALK, ""Well I'm doing my best to turn him back.""); addNPC(VERONICA, HeadE.CALM_TALK, ""Well be quick, I'm sure being a chicken can't be good for him.""); break; case ErnestTheChicken.QUEST_COMPLETE: addNPC(VERONICA, HeadE.HAPPY_TALKING, ""Thank you for rescuing Ernest.""); addPlayer(HeadE.HAPPY_TALKING, ""Where is he now?""); addNPC(VERONICA, HeadE.HAPPY_TALKING, ""Oh he went off to talk to some green warty guy. I'm sure he'll be back soon.""); break; } } public static NPCClickHandler handleVeronica = new NPCClickHandler(new Object[] { VERONICA }, e -> e.getPlayer().startConversation(new VeronicaErnestChickenD(e.getPlayer()).getStart())); }" "package com.rs.game.content.quests.eyesofglouphrie; //@QuestHandler( // quest = Quest.EYES_OF_GLOUPHRIE, // startText = ""Talk to Brimstail in his cave west of the Gnome Stronghold bank."", // itemsText = ""1 mud rune, 1 maple log, 1 oak log, 1 bucket of sap (use an empty bucket on an evergreen tree)."", // combatText = ""You will need to defeat 6 evil creatures (1 life point each)."", // rewardsText = ""12,000 Magic XP
"" + // ""2,500 Woodcutting XP
"" + // ""6,000 Runecrafting XP
"" + // ""250 Construction XP
""+ // ""Mysterious small crystal seed
"" + // ""Ability to use crystal singing bowls"", // completedStage = 6 //) @PluginEventHandler public class EyesOfGlouphrie extends QuestOutline { @Override public List getJournalLines(Player player, int stage) { return null; } @Override public void complete(Player player) { } }" "package com.rs.game.content.quests.fairytales const val MARTIN = 3299 const val NUFF = 3303 const val GODFATHER = 3304" "package com.rs.game.content.quests.fairytales.fairytalept1 const val STAGE_UNSTARTED = 0 const val STAGE_COMPLETE = 10 //@QuestHandler( // quest = Quest.FAIRY_TALE_I_GROWING_PAINS, // startText = ""Talk to Martin the Master Gardener in Draynor Village."", // itemsText = ""Dramen staff, secateurs, and three or four items randomly assigned to each player."", // combatText = ""Your farming and combat levels will help defeat a level 68 tanglefoot."", // rewardsText = // ""3,500 Farming XP
"" + // ""2,000 Attack XP
"" + // ""1,000 Magic XP
"" + // ""Magic Secateurs"", // completedStage = STAGE_COMPLETE //) class FairyTalePt1 : QuestOutline() { override fun getJournalLines(player: Player, stage: Int) = when (stage) { STAGE_UNSTARTED -> listOf(""I should talk to Martin the Master Gardener in Draynor Village."") STAGE_COMPLETE -> listOf(""QUEST COMPLETE!"") else -> listOf(""Invalid quest stage. Report this to an administrator."") } override fun complete(player: Player) { player.skills.addXpQuest(Skills.FARMING, 3500.0) player.skills.addXpQuest(Skills.ATTACK, 2000.0) player.skills.addXpQuest(Skills.MAGIC, 1000.0) sendQuestCompleteInterface(player, 7410) } } @ServerStartupEvent fun mapFairyTaleP1() { }" "package com.rs.game.content.quests.familycrest; @PluginEventHandler public class ChronozonBoss extends NPC { boolean hitWater = false; boolean hitEarth = false; boolean hitFire = false; boolean hitAir = false; public ChronozonBoss(int id, Tile tile) { super(id, tile, false); } @Override public void sendDeath(Entity source) { if(canDie()) { hitWater = false; hitEarth = false; hitFire = false; hitAir = false; super.sendDeath(source); } else { forceTalk(""Hahaha, you cannot defeat me!""); setHitpoints(getMaxHitpoints()); } } @Override public void handlePreHit(final Hit hit) { if(hit.getSource() instanceof Player p) { if(!hit.missed() && hit.getData(""combatSpell"") != null) if(!hitFire && hit.getData(""combatSpell"", CombatSpell.class) == CombatSpell.FIRE_BLAST) { p.sendMessage(""Chronozon weakens...""); hitFire = true; } else if(!hitWater && hit.getData(""combatSpell"", CombatSpell.class) == CombatSpell.WATER_BLAST) { p.sendMessage(""Chronozon weakens...""); hitWater = true; } else if(!hitAir && hit.getData(""combatSpell"", CombatSpell.class) == CombatSpell.WIND_BLAST) { p.sendMessage(""Chronozon weakens...""); hitAir = true; } else if(!hitEarth && hit.getData(""combatSpell"", CombatSpell.class) == CombatSpell.EARTH_BLAST) { p.sendMessage(""Chronozon weakens...""); hitEarth = true; } super.handlePreHit(hit); } } private boolean canDie() { return (hitAir && hitEarth && hitFire && hitWater); } public static NPCInstanceHandler toFunc = new NPCInstanceHandler(667, ChronozonBoss::new); public static NPCDeathHandler handleChronozonDeath = new NPCDeathHandler(667, e -> { if(e.getKiller() instanceof Player p) { if(p.getQuestManager().getStage(Quest.FAMILY_CREST) == KILL_CHRONOZON && !p.getInventory().containsItem(JOHNATHAN_CREST)) World.addGroundItem(new Item(JOHNATHAN_CREST, 1), Tile.of(e.getNPC().getTile()), p); } }); }" "package com.rs.game.content.quests.familycrest; @QuestHandler( quest = Quest.FAMILY_CREST, startText = ""Talk to Dimintheis in south-east Varrock, next to the Fancy Dress Shop."", itemsText = ""Cooked shrimp, cooked salmon, cooked tuna, cooked bass, cooked swordfish, 2 cut rubies, antipoison potion. You will likely need a magic weapon to cast Air Blast, Water Blast, Earth Blast, Fire Blast (59 Magic) from the normal spellbook."", combatText = ""You will need to defeat a level 84 demon."", rewardsText = ""Family gauntlets (chaos gauntlets, cooking gauntlets, smelting gauntlets)
Access to the hellhounds in Witchaven Dungeon"", completedStage = 8 ) @PluginEventHandler public class FamilyCrest extends QuestOutline { public final static int NOT_STARTED = 0; public final static int TALK_TO_CALEB = 1; public final static int TALK_TO_GEM_TRADER = 2; public final static int TALK_TO_AVAN = 3; public final static int TALK_TO_BOOT = 4; public final static int GIVE_AVAN_JEWLERY = 5; public final static int TALK_TO_JOHNATHAN = 6; public final static int KILL_CHRONOZON = 7; public final static int QUEST_COMPLETE = 8; //items public final static int PERFECT_RUBY_RING = 773; public final static int PERFECT_RUBY_NECKLACE = 774; public final static int CALEB_CREST = 779; public final static int AVAN_CREST = 780; public final static int JOHNATHAN_CREST = 781; public final static int FAMILY_CREST = 782; public final static int COOKING_GAUNTLETS = 775; public final static int GOLDSMITH_GAUNTLETS = 776; public final static int CHAOS_GAUNTLETS = 777; public final static int FAMILY_GAUNTLETS = 778; @Override public List getJournalLines(Player player, int stage) { ArrayList lines = new ArrayList<>(); switch(stage) { case NOT_STARTED: lines.add(""There is a man in Varrock who needs a bit of help.""); lines.add(""He is of noble heritage, but without his family's""); lines.add(""crest, he can't prove it. Unfortunately, his three""); lines.add(""sons took the crest with them when they left,""); lines.add(""scattering all across RuneScape.""); lines.add(""""); lines.add(""~~~Requirements~~~""); lines.add(""40 Mining""); lines.add(""40 Smithing""); lines.add(""59 Magic""); lines.add(""40 Crafting""); lines.add(""""); break; case TALK_TO_CALEB: lines.add(""Speak to Caleb in Catherby to ask about the family""); lines.add(""crest.""); lines.add(""""); if(player.getQuestManager().getAttribs(Quest.FAMILY_CREST).getB(""CALEB_ASKED"")) { lines.add(""I must get Caleb cooked shrimp, salmon, tuna, bass and""); lines.add(""swordfish to get a piece of the crest.""); lines.add(""""); } break; case TALK_TO_GEM_TRADER: lines.add(""Caleb says Avan is looking for treasure in Al-Kharid. ""); lines.add(""Talk to the gem trader in town to learn more.""); lines.add(""""); break; case TALK_TO_AVAN: lines.add(""Avan is looking for treasure by the mines in north""); lines.add(""Al-Kharid.""); lines.add(""""); break; case TALK_TO_BOOT: lines.add(""Avan says he is looking for the 'perfect' gold. He""); lines.add(""has a solid lead on the ore from a dwarf named Boot""); lines.add(""in the Dwarven Mines of Falador. You must talk to""); lines.add(""Boot to progress.""); lines.add(""""); break; case GIVE_AVAN_JEWLERY: lines.add(""Boot said there is 'perfect' ore in the Witchaven dungeon in""); lines.add(""east Ardougne.""); lines.add(""""); break; case TALK_TO_JOHNATHAN: lines.add(""Now that I have two of three crest pieces I only need""); lines.add(""one more from Johnathon in north east Varrock""); lines.add(""""); break; case KILL_CHRONOZON: lines.add(""Now I just need to kill Chronozon for the last crest piece""); lines.add(""I can find him somewhere in Edgeville dungeon. Look south""); lines.add(""of the earth obelisk.""); lines.add(""""); lines.add(""Afterwards I just need to put the pieces back together and""); lines.add(""return to Dimintheis.""); break; case QUEST_COMPLETE: lines.add(""""); lines.add(""""); lines.add(""QUEST COMPLETE!""); break; default: lines.add(""Invalid quest stage. Report this to an administrator.""); break; } return lines; } public static boolean meetsRequirements(Player p) { Skills skill = p.getSkills(); if(skill.getLevel(Constants.MINING) >= 40) if(skill.getLevel(Constants.SMITHING) >= 40) if(skill.getLevel(Constants.MAGIC) >= 59) if(skill.getLevel(Constants.CRAFTING) >= 40) return true; return false; } public static ItemOnItemHandler createActualCrest = new ItemOnItemHandler(new int[]{CALEB_CREST, AVAN_CREST, JOHNATHAN_CREST}, new int[]{CALEB_CREST, AVAN_CREST, JOHNATHAN_CREST}, e -> { if (e.getPlayer().getInventory().containsItem(CALEB_CREST, 1)) if (e.getPlayer().getInventory().containsItem(AVAN_CREST, 1)) if (e.getPlayer().getInventory().containsItem(JOHNATHAN_CREST, 1)) { e.getPlayer().getInventory().removeItems(new Item(CALEB_CREST, 1), new Item(AVAN_CREST, 1), new Item(JOHNATHAN_CREST, 1)); e.getPlayer().getInventory().addItem(new Item(FAMILY_CREST, 1), true); } }); static final int PERFECT_ORE = 446; static final int PERFECT_BAR = 2365; static final int RUBY = 1603; static final int RING_MOULD = 1592; static final int NECKLACE_MOULD = 1597; public static ItemOnObjectHandler perfectItemsOnFurnace = new ItemOnObjectHandler(new Object[] { ""Furnace"" }, new Object[] { PERFECT_ORE, PERFECT_BAR }, e -> { Player p = e.getPlayer(); if(e.getItem().getId() == PERFECT_ORE) { p.getInventory().replaceItem(PERFECT_BAR, 1, e.getItem().getSlot()); p.setNextAnimation(new Animation(3243)); } if(e.getItem().getId() == PERFECT_BAR) p.startConversation(new Conversation(p) { { addOptions(""Choose an option:"", new Options() { @Override public void create() { if(p.getInventory().containsItem(RING_MOULD, 1, true) && p.getInventory().containsItem(RUBY, 1)) option(""Make perfect ring"", new Dialogue() .addNext(()->{ p.setNextAnimation(new Animation(3243)); p.getInventory().removeItems(new Item(RUBY, 1)); p.getInventory().replaceItem(PERFECT_RUBY_RING, 1, e.getItem().getSlot()); })); else p.sendMessage(""You don't have materials for a perfect ring""); if(p.getInventory().containsItem(NECKLACE_MOULD, 1, true) && p.getInventory().containsItem(RUBY, 1)) option(""Make perfect neck"", new Dialogue() .addNext(()->{ p.setNextAnimation(new Animation(3243)); p.getInventory().removeItems(new Item(RUBY, 1)); p.getInventory().replaceItem(PERFECT_RUBY_NECKLACE, 1, e.getItem().getSlot()); })); else p.sendMessage(""You don't have materials for a perfect necklace""); } }); create(); } }); }); @Override public void complete(Player player) { if(player.getInventory().hasFreeSlots()) player.getInventory().addItem(FAMILY_GAUNTLETS, 1); sendQuestCompleteInterface(player, 778); } public static ItemClickHandler handleFamilyGauntletsQuestRequirement = new ItemClickHandler(new Object[]{775, 776, 777}, new String[]{""Wear""}, e -> { if (e.getPlayer().isEquipDisabled()) return; if (!e.getPlayer().isQuestComplete(Quest.FAMILY_CREST)) { e.getPlayer().sendMessage(""You must complete the Family Crest quest to use this item...""); return; } Equipment.sendWear(e.getPlayer(), e.getSlotId(), e.getItem().getId()); }); }" "package com.rs.game.content.quests.familycrest; /** * Puzzle remake from this picture: https://gyazo.com/305b717ded771ca352b7cb50d51a91b8 */ @PluginEventHandler public class WitchHavenPuzzleFamilyCrest { private static boolean northNorthLeverUp = false; private static boolean northLeverUp = false; private static boolean southLeverUp = false; private static final int TICKS_UP = 400; public static ObjectClickHandler handleNorthDoor = new ObjectClickHandler(new Object[] { 2431 }, e -> { GameObject obj = e.getObject(); if(southLeverUp && !northLeverUp) { handleDoor(e.getPlayer(), obj); return; } e.getPlayer().sendMessage(""Seems locked...""); }); public static ObjectClickHandler handleEastDoor = new ObjectClickHandler(new Object[] { 2430 }, e -> { GameObject obj = e.getObject(); if(northLeverUp && northNorthLeverUp && !southLeverUp) { handleDoor(e.getPlayer(), obj); return; } e.getPlayer().sendMessage(""Seems locked...""); }); public static ObjectClickHandler handleSouthEastDoor = new ObjectClickHandler(new Object[] { 2429 }, e -> { GameObject obj = e.getObject(); if((northLeverUp && !southLeverUp) || (northNorthLeverUp && southLeverUp)) { handleDoor(e.getPlayer(), obj); return; } e.getPlayer().sendMessage(""Seems locked...""); }); public static ObjectClickHandler handleSouthWestDoor = new ObjectClickHandler(new Object[] { 2427 }, e -> { GameObject obj = e.getObject(); if(obj.getY() > e.getPlayer().getY()) handleDoor(e.getPlayer(), obj); else e.getPlayer().sendMessage(""It is locked from the other side...""); }); public static ObjectClickHandler handleNorthNorthLever = new ObjectClickHandler(new Object[] { 2425, 2426 }, e -> {; GameObject obj = e.getObject(); if(e.getObjectId() == 2426) { obj.setId(2425); northNorthLeverUp = false; e.getPlayer().sendMessage(""The lever is now down.""); return; } obj.setIdTemporary(e.getObjectId()+1, TICKS_UP); northNorthLeverUp = true; WorldTasks.schedule(new Task() { @Override public void run() { northNorthLeverUp = false; } }, TICKS_UP); e.getPlayer().sendMessage(""The lever is now up.""); }); public static ObjectClickHandler handleNorthLever = new ObjectClickHandler(new Object[] { 2421, 2422 }, e -> { GameObject obj = e.getObject(); if(e.getObjectId() == 2422) { obj.setId(2421); northLeverUp = false; e.getPlayer().sendMessage(""The lever is now down.""); return; } obj.setIdTemporary(e.getObjectId()+1, TICKS_UP); northLeverUp = true; WorldTasks.schedule(TICKS_UP, () -> northLeverUp = false); e.getPlayer().sendMessage(""The lever is now up.""); }); public static ObjectClickHandler handleSouthLever = new ObjectClickHandler(new Object[] { 2423, 2424 }, e -> { GameObject obj = e.getObject(); if(e.getObjectId() == 2424) { obj.setId(2423); southLeverUp = false; e.getPlayer().sendMessage(""The lever is now down.""); return; } obj.setIdTemporary(e.getObjectId()+1, TICKS_UP); southLeverUp = true; WorldTasks.schedule(TICKS_UP, () -> southLeverUp = false); e.getPlayer().sendMessage(""The lever is now up.""); }); }" "package com.rs.game.content.quests.familycrest.dialogues; @PluginEventHandler public class AvanFamilyCrestD extends Conversation { private static final int NPC = 663; public AvanFamilyCrestD(Player player) { super(player); switch(player.getQuestManager().getStage(Quest.FAMILY_CREST)) { case NOT_STARTED, TALK_TO_CALEB, TALK_TO_GEM_TRADER -> { addNPC(NPC, HeadE.CALM_TALK, ""What? Can't you see I'm busy?""); addPlayer(HeadE.HAPPY_TALKING, ""Well, sooooorry...""); } case TALK_TO_AVAN -> addOptions(""Choose an option:"", new Options() { @Override public void create() { option(""Why are you lurking around a scorpion pit?"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Why are you lurking around a scorpion pit?"") .addNPC(NPC, HeadE.CALM_TALK, ""It's a good place to find gold..."") ); option(""I'm looking for a man... his name is Avan Fitzharmon."", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""I'm looking for a man... his name is Avan Fitzharmon."") .addNPC(NPC, HeadE.CALM_TALK, ""Then you have found him. My name is Avan Fitzharmon."") .addPlayer(HeadE.HAPPY_TALKING, ""You have a part of your family crest. I am on a quest to retrieve all of the fragmented "" + ""pieces and restore the crest."") .addNPC(NPC, HeadE.CALM_TALK, ""Ha! I suppose one of my worthless brothers has sent you on this quest then?"") .addPlayer(HeadE.HAPPY_TALKING, ""No, it was your father who has asked me to do this for him."") .addNPC(NPC, HeadE.CALM_TALK, ""My... my father wishes this? Then that is a different matter. I will let you have my crest shard, "" + ""adventurer, but you must first do something for me."") .addNPC(NPC, HeadE.CALM_TALK, ""There is a certain lady I am trying to impress. As a man of noble birth, I can not give her just any gold trinket to show my devotion."") .addNPC(NPC, HeadE.CALM_TALK, ""What I intend to give her, is a golden ring, embedded with the finest precious red stone available, and a necklace to match this ring"") .addNPC(NPC, HeadE.CALM_TALK, ""The problem however for me, is that not just any old gold will be suitable. I seek only the purest, the most high quality of gold - what I seek, if you will, is perfect gold."") .addNPC(NPC, HeadE.CALM_TALK, ""None of the gold around here is even remotely suitable in terms of quality. I have searched far and wide for the perfect gold I desire"") .addNPC(NPC, HeadE.CALM_TALK, ""but have had no success so in finding it I am afraid. If you can find me my perfect gold, make a ring and necklace from it,"") .addNPC(NPC, HeadE.CALM_TALK, ""and add rubies to them, I will gladly hand over my fragment of the family crest to you."") .addPlayer(HeadE.HAPPY_TALKING, ""Can you give me any help on finding this 'perfect gold'?"") .addNPC(NPC, HeadE.CALM_TALK, ""I thought I had found a solid lead on its whereabouts when I heard of a dwarf who is an expert on gold who goes by the name of 'Boot'."") .addNPC(NPC, HeadE.CALM_TALK, ""Unfortunately he has apparently returned to this home, somewhere in the mountains, and I have no idea how to find him."") .addPlayer(HeadE.HAPPY_TALKING, ""Well, I'll see what I can do"", ()->{ player.getQuestManager().setStage(Quest.FAMILY_CREST, TALK_TO_BOOT); }) ); } }); case TALK_TO_BOOT -> { addNPC(NPC, HeadE.CALM_TALK, ""So how are you doing getting me my perfect gold jewelry?""); addPlayer(HeadE.HAPPY_TALKING, ""I'm still after that 'perfect gold'.""); addNPC(NPC, HeadE.CALM_TALK, ""I know how you feel... for such a long time I have searched and searched for the elusive perfect gold...""); addNPC(NPC, HeadE.CALM_TALK, ""I thought I had gotten a good lead on finding it when I heard talk of a dwarven expert on gold named Boot some time"" + "" back, but unfortunately for me, he has returned to his mountain home, which I cannot find.""); } case GIVE_AVAN_JEWLERY -> { addNPC(NPC, HeadE.CALM_TALK, ""So how are you doing getting me my perfect gold jewelry?""); if(player.getInventory().containsItems(new int[]{PERFECT_RUBY_NECKLACE, PERFECT_RUBY_RING}, new int[]{1, 1})) { addPlayer(HeadE.HAPPY_TALKING, ""I have the ring and necklace right here.""); addSimple(""You show Avan the jewlery""); addNPC(NPC, HeadE.CALM_TALK, ""These... these are exquisite! EXACTLY what I was searching for all of this time! Please, take my crest fragment!""); addSimple(""You exchange the jewlery for the family crest with Avan"", ()->{ player.getInventory().removeItems(new Item(PERFECT_RUBY_RING, 1), new Item(PERFECT_RUBY_NECKLACE)); player.getInventory().addItem(AVAN_CREST, 1); player.getQuestManager().setStage(Quest.FAMILY_CREST, TALK_TO_JOHNATHAN); }); addNPC(NPC, HeadE.CALM_TALK, ""Now, I suppose you will be wanting to find my brother Johnathon who is in possession of the final piece of the family's crest?""); addPlayer(HeadE.HAPPY_TALKING, ""That's correct.""); addNPC(NPC, HeadE.CALM_TALK, ""Well, the last I heard of my brother Johnathon, he was studying the magical arts, and trying to hunt some demon or other out in The Wilderness.""); addNPC(NPC, HeadE.CALM_TALK, ""Unsurprisingly, I do not believe he is doing a particularly good job of things, and spends most of his time recovering from his injuries""); addNPC(NPC, HeadE.CALM_TALK, ""in some tavern or other near the eastern edge of The Wilderness. You'll probably find him still there.""); addPlayer(HeadE.HAPPY_TALKING, ""Thanks Avan.""); } else { addPlayer(HeadE.HAPPY_TALKING, ""I'm still after that 'perfect gold'.""); addNPC(NPC, HeadE.CALM_TALK, ""I know how you feel... for such a long time I have searched and searched for the elusive perfect gold...""); } } case TALK_TO_JOHNATHAN, KILL_CHRONOZON -> { if(!player.getInventory().containsItem(AVAN_CREST, 1) && !player.getInventory().containsItem(FAMILY_CREST)) { if(player.getInventory().hasFreeSlots()) { addNPC(NPC, HeadE.CALM_TALK, ""You lost this.""); addSimple(""Avan gives you back his crest..."", () -> player.getInventory().addItem(AVAN_CREST, 1)); } else { addNPC(NPC, HeadE.CALM_TALK, ""I have my crest if you had room for it""); addPlayer(HeadE.HAPPY_TALKING, ""Okay.""); } return; } addNPC(NPC, HeadE.CALM_TALK, ""Now, I suppose you will be wanting to find my brother Johnathon who is in possession of the final piece of the family's crest?""); addPlayer(HeadE.HAPPY_TALKING, ""That's correct.""); addNPC(NPC, HeadE.CALM_TALK, ""Well, the last I heard of my brother Johnathon, he was studying the magical arts, and trying to hunt some demon or other out in The Wilderness.""); addNPC(NPC, HeadE.CALM_TALK, ""Unsurprisingly, I do not believe he is doing a particularly good job of things, and spends most of his time recovering from his injuries""); addNPC(NPC, HeadE.CALM_TALK, ""in some tavern or other near the eastern edge of The Wilderness. You'll probably find him still there.""); addPlayer(HeadE.HAPPY_TALKING, ""Thanks Avan.""); } case QUEST_COMPLETE -> { addNPC(NPC, HeadE.CALM_TALK, ""I have heard word from my father, thank you for helping to restore our family honour""); if(player.getInventory().containsItem(FAMILY_GAUNTLETS, 1)) { addPlayer(HeadE.HAPPY_TALKING, ""Your father said that you could improve these Gauntlets in some way for me""); addNPC(NPC, HeadE.CALM_TALK, ""Yes, I can. In my quest to find the perfect gold I learned a lot; I can make it so when you're wearing these"" + "" you gain more experience when smithing gold.""); addOptions(""Choose an option:"", new Options() { @Override public void create() { option(""That sounds good, improve them for me"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""That sounds good, improve them for me"") .addSimple(""Avan takes out a little hammer"") .addSimple(""He starts pounding on the gauntlets"") .addSimple(""Avan hands the gauntlets to you"", () -> { player.getInventory().removeItems(new Item(FAMILY_GAUNTLETS, 1)); player.getInventory().addItem(GOLDSMITH_GAUNTLETS, 1); }) ); option(""I think I'll check my other options with your brothers"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""I think I'll check my other options with your brothers"") .addNPC(NPC, HeadE.CALM_TALK, ""Ok if you insist on getting help from the likes of them"") ); } }); } else addPlayer(HeadE.HAPPY_TALKING, ""You're welcome!""); } } } public static NPCClickHandler handleDialogue = new NPCClickHandler(new Object[] { NPC }, e -> e.getPlayer().startConversation(new AvanFamilyCrestD(e.getPlayer()).getStart())); }" "package com.rs.game.content.quests.familycrest.dialogues; @PluginEventHandler public class BootFamilyCrestD extends Conversation { private static final int NPC = 665; public BootFamilyCrestD(Player player) { super(player); switch(player.getQuestManager().getStage(Quest.FAMILY_CREST)) { case TALK_TO_BOOT, GIVE_AVAN_JEWLERY -> { addNPC(NPC, HeadE.CALM_TALK, ""Hello tall person""); addPlayer(HeadE.HAPPY_TALKING, ""Hello. I'm in search of very high quality gold""); addNPC(NPC, HeadE.CALM_TALK, ""High quality gold eh? Hmmm... Well, the very best quality gold that I know of can be found in an underground ruin near Witchaven.""); addNPC(NPC, HeadE.CALM_TALK, ""I don't believe it's exactly easy to get to though..."", ()-> player.getQuestManager().setStage(Quest.FAMILY_CREST, GIVE_AVAN_JEWLERY)); } default -> { addNPC(NPC, HeadE.CALM_TALK, ""Hello tall person.""); addOptions(""Choose an option:"", new Options() { @Override public void create() { option(""Hello short person."", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Hello short person."") .addNPC(NPC, HeadE.FRUSTRATED, ""..."") ); option(""Why are you called boot?"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Why are you called boot?"") .addNPC(NPC, HeadE.CALM_TALK, ""I'm called Boot, because when I was very young, I used to sleep, in a large boot."") .addPlayer(HeadE.HAPPY_TALKING, ""Yeah, great, I didn't want your life story."") ); } }); } } } public static NPCClickHandler handleDialogue = new NPCClickHandler(new Object[] { NPC }, e -> e.getPlayer().startConversation(new BootFamilyCrestD(e.getPlayer()).getStart())); }" "package com.rs.game.content.quests.familycrest.dialogues; @PluginEventHandler public class CalebFamilyCrestD extends Conversation { private static final int NPC = 666; private static final int SWORDFISH = 373; private static final int BASS = 365; private static final int TUNA = 361; private static final int SALMON = 329; private static final int SHRIMP = 315; private boolean hasFish() { if(player.getInventory().containsItems(new int[]{SWORDFISH, BASS, TUNA, SALMON, SHRIMP}, new int[]{1, 1, 1, 1, 1})) return true; return false; } private void removeFish() { player.getInventory().removeItems(new Item(SWORDFISH, 1), new Item(BASS, 1), new Item(TUNA, 1), new Item(SALMON, 1), new Item(SHRIMP, 1)); } public CalebFamilyCrestD(Player player) { super(player); switch(player.getQuestManager().getStage(Quest.FAMILY_CREST)) { case NOT_STARTED -> { addNPC(NPC, HeadE.CALM_TALK, ""Who are you? What are you after?""); addPlayer(HeadE.HAPPY_TALKING, ""I see you are a chef... could you cook me anything?""); addNPC(NPC, HeadE.CALM_TALK, ""I would, but I am very busy. I am trying to increase my renown as one of the world's leading chefs by preparing "" + ""a special and unique fish salad.""); } case TALK_TO_CALEB -> { if(player.getQuestManager().getAttribs(Quest.FAMILY_CREST).getB(""CALEB_ASKED"")) { if(hasFish()) { addNPC(NPC, HeadE.CALM_TALK, ""How is the fish collecting going?""); addPlayer(HeadE.HAPPY_TALKING, ""Got them all with me.""); addSimple(""You exchange the fish for Caleb's piece of the crest."", ()-> { removeFish(); player.getInventory().addItem(CALEB_CREST, 1); player.getQuestManager().setStage(Quest.FAMILY_CREST, TALK_TO_GEM_TRADER); }); addPlayer(HeadE.HAPPY_TALKING, ""Uh... what happened to the rest of it?""); addNPC(NPC, HeadE.CALM_TALK, ""Well... my brothers and I had a slight disagreement about it... we all wanted to be the heir of my "" + ""father's lands, and we each ended up with a piece of the crest.""); addNPC(NPC, HeadE.CALM_TALK, ""None of us wanted to give up our rights to our brothers, so we didn't want to give up our pieces of the "" + ""crest, but none of us wanted to face our father by returning to him with an incomplete crest. ""); addNPC(NPC, HeadE.CALM_TALK, ""We each went our separate ways many years past, none of us seeing our father or willing to give up our fragments.""); addPlayer(HeadE.HAPPY_TALKING, ""So do you know where I could find any of your brothers?""); addNPC(NPC, HeadE.CALM_TALK, ""Well, we haven't really kept in touch... what with the dispute over the crest and all... I did hear from"" + "" my brother Avan a while ago though..""); addNPC(NPC, HeadE.CALM_TALK, ""He said he was on some kind of search for treasure, or gold, or something out near Al Kharid somewhere. "" + ""Avan always had expensive tastes, so you might try asking the gem trader for his wherebouts.""); addNPC(NPC, HeadE.CALM_TALK, ""Be warned though. Avan is quite greedy, and you may find he is not prepared to hand over his crest piece "" + ""to you as easily as I have.""); } else { addNPC(NPC, HeadE.CALM_TALK, ""How is the fish collecting going?""); addPlayer(HeadE.HAPPY_TALKING, ""I didn't manage to get them all yet...""); addNPC(NPC, HeadE.CALM_TALK, ""Remember, I want the following cooked fish: Swordfish, Bass, Tuna, Salmon and Shrimp.""); } return; } addNPC(NPC, HeadE.CALM_TALK, ""Who are you? What are you after?""); addPlayer(HeadE.HAPPY_TALKING, ""Are you Caleb Fitzharmon?""); addNPC(NPC, HeadE.CALM_TALK, ""Why... yes I am, but I don't believe I know you... how did you know my name?""); addPlayer(HeadE.HAPPY_TALKING, ""I have been sent by your father. He wishes the Fitzharmon Crest to be restored.""); addNPC(NPC, HeadE.CALM_TALK, ""Ah... well... hmmm... yes... I do have a piece of it anyway...""); addOptions(""Choose an option:"", new Options() { @Override public void create() { option(""Uh... what happened to the rest of it?"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Uh... what happened to the rest of it?"") .addNPC(NPC, HeadE.CALM_TALK, ""Well... my brothers and I had a slight disagreement about it... we all wanted to be heir to "" + ""my fathers' lands, and we each ended up with a piece of the crest."") .addNPC(NPC, HeadE.CALM_TALK, ""None of us wanted to give up our rights to our brothers, so we didn't want to give up our pieces "" + ""of the crest, but none of us wanted to face our father by returning to him with an incomplete crest..."") .addNPC(NPC, HeadE.CALM_TALK, ""We each went our separate ways many years past, none of us seeing our father or willing to give "" + ""up our fragments."") ); option(""So can I have your bit?"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""So can I have your bit?"") .addNPC(NPC, HeadE.CALM_TALK, ""Well, I am the oldest son, so by the rules of chivalry, I am most entitled to be the rightful "" + ""bearer of the crest."") .addPlayer(HeadE.HAPPY_TALKING, ""It's not really much use without the other fragments is it though?"") .addNPC(NPC, HeadE.CALM_TALK, ""Well that is true... perhaps it is time to put my pride aside... I'll tell you what: I'm struggling "" + ""to complete this fish salad of mine"") .addNPC(NPC, HeadE.CALM_TALK, ""so if you will assist me in my search for the ingredients, then I will let you take my piece as "" + ""reward for your assistance."") .addPlayer(HeadE.HAPPY_TALKING, ""So what ingredients are you missing?"") .addNPC(NPC, HeadE.CALM_TALK, ""I require the following cooked fish: Swordfish, Bass, Tuna, Salmon and Shrimp."") .addOptions(""Choose an option:"", new Options() { @Override public void create() { option(""Ok, I will get those"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Ok, I will get those"", ()-> player.getQuestManager().getAttribs(Quest.FAMILY_CREST).setB(""CALEB_ASKED"", true)) .addNPC(NPC, HeadE.CALM_TALK, ""You will? It would help me a lot!"") ); option(""Why don't you just give me the crest?"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Why don't you just give me the crest?"") .addNPC(NPC, HeadE.CALM_TALK, ""It's a valuable family heirloom. I think the least you can do is prove you're worthy of it before I hand it over."") ); } }) ); } }); } case TALK_TO_GEM_TRADER -> { if(!player.getInventory().containsItem(CALEB_CREST, 1) && !player.getInventory().containsItem(FAMILY_CREST)) { if(player.getInventory().hasFreeSlots()) { addNPC(NPC, HeadE.CALM_TALK, ""You lost this.""); addSimple(""Caleb gives you back his crest..."", () -> player.getInventory().addItem(CALEB_CREST, 1)); } else { addNPC(NPC, HeadE.CALM_TALK, ""I have my crest if you had room for it""); addPlayer(HeadE.HAPPY_TALKING, ""Okay.""); } return; } addPlayer(HeadE.HAPPY_TALKING, ""Where did you say I could find Avan again?""); addNPC(NPC, HeadE.CALM_TALK, ""Last I heard he was on some stupid treasure hunt out in the desert somewhere. Your best bet is asking around there.""); addNPC(NPC, HeadE.CALM_TALK, ""Try asking a gem trader.""); addPlayer(HeadE.CALM_TALK, ""Okay.""); } case TALK_TO_AVAN, TALK_TO_BOOT, GIVE_AVAN_JEWLERY, TALK_TO_JOHNATHAN, KILL_CHRONOZON -> { if(!player.getInventory().containsItem(CALEB_CREST, 1)) { if(player.getInventory().hasFreeSlots()) { addNPC(NPC, HeadE.CALM_TALK, ""You lost this.""); addSimple(""Caleb gives you back his crest..."", () -> player.getInventory().addItem(CALEB_CREST, 1)); } else { addNPC(NPC, HeadE.CALM_TALK, ""I have my crest if you had room for it""); addPlayer(HeadE.HAPPY_TALKING, ""Okay.""); } return; } addNPC(NPC, HeadE.CALM_TALK, ""How are you doing getting the crest pieces?""); addPlayer(HeadE.HAPPY_TALKING, ""I am still working on it.""); addNPC(NPC, HeadE.CALM_TALK, ""Then why are you wasting your time here?""); } case QUEST_COMPLETE -> { addNPC(NPC, HeadE.CALM_TALK, ""I hear you brought the completed crest to my father. I must say, that was awfully impressive work.""); if(player.getInventory().containsItem(FAMILY_GAUNTLETS, 1)) { addPlayer(HeadE.HAPPY_TALKING, ""I believe your father mentioned you would be able to improve these gauntlets for me...""); addNPC(NPC, HeadE.CALM_TALK, ""Yes, that is correct. I can slightly alter these gauntlets to allow you some of my skill at preparing seafood by "" + ""making them cooking gauntlets.""); addOptions(""Choose an option:"", new Options() { @Override public void create() { option(""Yes, please do that for me"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Yes, please do that for me."") .addSimple(""Caleb takes the gauntlets from you, pours some herbs and seasonings on them, bakes them on his range "" + ""for a short time, then hands them back to you."", () -> { player.getInventory().removeItems(new Item(FAMILY_GAUNTLETS, 1)); player.getInventory().addItem(COOKING_GAUNTLETS, 1); }) ); option(""I'll see what your brothers have to offer"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""I'll see what your brothers have to offer"") .addNPC(NPC, HeadE.CALM_TALK, ""As you wish. Let me know if you change your mind."") ); } }); } else addPlayer(HeadE.HAPPY_TALKING, ""Thanks!""); } } } public static NPCClickHandler handleDialogue = new NPCClickHandler(new Object[] { NPC }, e -> e.getPlayer().startConversation(new CalebFamilyCrestD(e.getPlayer()).getStart())); }" "package com.rs.game.content.quests.familycrest.dialogues; @PluginEventHandler public class DimintheisFamilyCrestD extends Conversation { private final int QUEST_INQUIRY = 0; private static final int NPC = 664; public DimintheisFamilyCrestD(Player player) { super(player); switch(player.getQuestManager().getStage(Quest.FAMILY_CREST)) { case NOT_STARTED -> { addNPC(NPC, HeadE.CALM_TALK, ""Hello. My name is Dimintheis, of the noble family Fitzharmon.""); addOptions(""Choose an option:"", new Options() { @Override public void create() { option(""Why would a nobleman live in a dump like this?"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Why would a nobleman live in a dump like this?"") .addNPC(NPC, HeadE.CALM_TALK, ""The King has taken my estate from me until such time as I can show my family crest to him."") .addPlayer(HeadE.HAPPY_TALKING, ""Why would he do that?"") .addNPC(NPC, HeadE.CALM_TALK, ""Well, there is a long standing rule of chivalry amongst the Varrockian aristocracy, "" + ""where each noble family is in possession of a unique crest, which signifies the honour and lineage of the family."") .addNPC(NPC, HeadE.CALM_TALK, ""More than this however, it also represents the lawful rights of each family to "" + ""prove their ownership of their wealth and lands. "") .addNPC(NPC, HeadE.CALM_TALK, ""If the family crest is lost, then the family's estate is handed over to the "" + ""current monarch until the crest is restored."") .addNPC(NPC, HeadE.CALM_TALK, ""This dates back to the times when there was much in-fighting amongst the noble "" + ""families and their clans"") .addNPC(NPC, HeadE.CALM_TALK, ""and was introduced as a way of reducing the bloodshed that was devastating the "" + ""ranks of the ruling classes at that time."") .addNPC(NPC, HeadE.CALM_TALK, ""When you captured a rival family's clan, you also captured their lands and wealth."") .addNext(()-> player.startConversation(new DimintheisFamilyCrestD(player, QUEST_INQUIRY).getStart())) ); option(""You're rich then? Can I have some money?"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""You're rich then? Can I have some money?"") .addNPC(NPC, HeadE.CALM_TALK, ""Gah! Lousy beggar! Your sort is what's ruining this great land! Why don't you just go and get a "" + ""job if you need money so badly?"") ); option(""Hi, I am a bold adventurer"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Hi, I am a bold adventurer"") .addNPC(NPC, HeadE.CALM_TALK, ""An adventurer hmmm? How lucky. I may have an adventure for you. I desperately need my family "" + ""crest returning to me. It is of utmost importance."") .addOptions(""Choose an option:"", new Options() { @Override public void create() { option(""Why are you so desperate for it?"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Why are you so desperate for it?"") .addNPC(NPC, HeadE.CALM_TALK, ""Well, there is a long standing rule of chivalry amongst the Varrockian aristocracy, "" + ""where each noble family is in possession of a unique crest, which signifies the honour and lineage of the family."") .addNPC(NPC, HeadE.CALM_TALK, ""More than this however, it also represents the lawful rights of each family to "" + ""prove their ownership of their wealth and lands. "") .addNPC(NPC, HeadE.CALM_TALK, ""If the family crest is lost, then the family's estate is handed over to the "" + ""current monarch until the crest is restored."") .addNPC(NPC, HeadE.CALM_TALK, ""This dates back to the times when there was much in-fighting amongst the noble "" + ""families and their clans"") .addNPC(NPC, HeadE.CALM_TALK, ""and was introduced as a way of reducing the bloodshed that was devastating the "" + ""ranks of the ruling classes at that time."") .addNPC(NPC, HeadE.CALM_TALK, ""When you captured a rival family's clan, you also captured their lands and wealth."") .addNext(()-> player.startConversation(new DimintheisFamilyCrestD(player, QUEST_INQUIRY).getStart())) ); option(""So where is this crest?"", new Dialogue() .addNext(()-> player.startConversation(new DimintheisFamilyCrestD(player, QUEST_INQUIRY).getStart())) ); option(""I'm not interested in that adventure right now"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""I'm not interested in that adventure right now"") .addNPC(NPC, HeadE.CALM_TALK, ""I realise it was a lot to ask of a stranger"") ); } }) ); } }); } case TALK_TO_CALEB, TALK_TO_GEM_TRADER, TALK_TO_AVAN, TALK_TO_BOOT, GIVE_AVAN_JEWLERY, TALK_TO_JOHNATHAN -> { addNPC(NPC, HeadE.CALM_TALK, ""If you find Caleb, or my other sons... please... let them know their father still loves them...""); addPlayer(HeadE.HAPPY_TALKING, ""Okay.""); } case KILL_CHRONOZON -> { if(player.getInventory().containsItem(FAMILY_CREST, 1)) { addPlayer(HeadE.HAPPY_TALKING, ""I have retrieved your crest.""); addNPC(NPC, HeadE.CALM_TALK, ""Adventurer... I can only thank you for your kindness, although the words are insufficient to express the gratitude I feel!""); addNPC(NPC, HeadE.CALM_TALK, ""You are truly a hero in every sense, and perhaps your efforts can begin to patch the wounds that have torn this family apart...""); addNPC(NPC, HeadE.CALM_TALK, ""I know not how I can adequately reward you for your efforts... although I do have these mystical gauntlets, a family heirloom that through some power unknown to me, have always returned to the head of the family whenever lost, or if the owner has died.""); addNPC(NPC, HeadE.CALM_TALK, ""I will pledge these to you, and if you should lose them return to me, and they will be here.""); addNPC(NPC, HeadE.CALM_TALK, ""They can also be granted extra powers. Take them to one of my sons, they should be able to imbue them with a skill for you.""); addNext(()-> { player.getInventory().removeItems(new Item(FAMILY_CREST,1)); player.getQuestManager().completeQuest(Quest.FAMILY_CREST); }); return; } addNPC(NPC, HeadE.CALM_TALK, ""If you find Caleb, or my other sons... please... let them know their father still loves them...""); addPlayer(HeadE.HAPPY_TALKING, ""Okay.""); } case QUEST_COMPLETE -> { addNPC(NPC, HeadE.CALM_TALK, ""Adventurer... I can only thank you for your kindness, although the words are insufficient to express the gratitude I feel!""); addNPC(NPC, HeadE.CALM_TALK, ""You are truly a hero in every sense, and perhaps your efforts can begin to patch the wounds that have torn this family apart...""); if(player.getInventory().containsItem(FAMILY_GAUNTLETS, 1)) { addNPC(NPC, HeadE.CALM_TALK, ""Please, enjoy those gauntlets.""); addPlayer(HeadE.HAPPY_TALKING, ""..""); return; } if(player.getInventory().hasFreeSlots()) { addNPC(NPC, HeadE.CALM_TALK, ""I found the family gauntlets, please take them...""); addSimple(""He hands you the gauntlets."", () -> player.getInventory().addItem(FAMILY_GAUNTLETS, 1)); addPlayer(HeadE.HAPPY_TALKING, ""...""); } else { addNPC(NPC, HeadE.CALM_TALK, ""I found the family gauntlets, if you had room for them...""); addPlayer(HeadE.HAPPY_TALKING, ""...""); } } } } public DimintheisFamilyCrestD(Player p, int id) { super(p); switch(id) { case QUEST_INQUIRY -> { if(meetsRequirements(p)) { addPlayer(HeadE.HAPPY_TALKING, ""So where is this crest?""); addNPC(NPC, HeadE.CALM_TALK, ""Well, my three sons took it with them many years ago when they rode out to fight in the war against the undead "" + ""necromancer and his army in the battle to save Varrock.""); addNPC(NPC, HeadE.CALM_TALK, ""For many years I had assumed them all dead, as I had heard no word from them.""); addNPC(NPC, HeadE.CALM_TALK, ""Recently I heard that my son Caleb is alive and well, trying to earn his fortune as a great fish chef.""); addNPC(NPC, HeadE.CALM_TALK, ""I believe he is staying with a friend who lives just outside the west gates of Varrock.""); addOptions(""Start Family Crest?"", new Options() { @Override public void create() { option(""Yes"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Ok, I will help you"", () -> p.getQuestManager().setStage(Quest.FAMILY_CREST, TALK_TO_CALEB)) .addNPC(NPC, HeadE.CALM_TALK, ""I thank you greatly adventurer!"") .addNPC(NPC, HeadE.CALM_TALK, ""If you find Caleb, or my other sons... please... let them know their father still loves them..."") ); option(""No"", new Dialogue() .addPlayer(HeadE.CALM_TALK, ""I'm not interested in that adventure right now."") .addNPC(NPC, HeadE.SAD, ""I realise it was a lot to ask of a stranger."") ); } }); } else { addSimple(""You do not meet the requirements for Family Crest...""); addSimple(""You need 40 mining, 40 smithing, 59 magic and 40 crafting.""); } } } } public static NPCClickHandler handleDialogue = new NPCClickHandler(new Object[] { NPC }, e -> e.getPlayer().startConversation(new DimintheisFamilyCrestD(e.getPlayer()).getStart())); }" "package com.rs.game.content.quests.familycrest.dialogues; @PluginEventHandler public class GemTraderFamilyCrestD extends Conversation { private static final int NPC = 540; public GemTraderFamilyCrestD(Player player) { super(player); switch(player.getQuestManager().getStage(Quest.FAMILY_CREST)) { case TALK_TO_GEM_TRADER -> { addPlayer(HeadE.HAPPY_TALKING, ""I'm in search of a man named Avan Fitzharmon.""); addNPC(NPC, HeadE.CALM_TALK, ""Fitzharmon, eh? Hmmm... If I'm not mistaken, that's the family name of a member of the Varrockian nobility.""); addNPC(NPC, HeadE.CALM_TALK, ""You know, I HAVE seen someone of that persuasion around here recently... wearing a 'poncey' yellow cape, he was.""); addNPC(NPC, HeadE.CALM_TALK, ""Came in here all la-di-dah, high and mighty, asking for jewellery made from 'perfect gold' - whatever that is - "" + ""like 'normal' gold just isn't good enough for 'little lord fancy pants' there!""); addNPC(NPC, HeadE.CALM_TALK, ""I told him to head to the desert 'cos I know there's gold out there, in them there sand dunes. And if it's "" + ""not up to his lordship's high standards of 'gold perfection', then..."", ()-> player.getQuestManager().setStage(Quest.FAMILY_CREST, TALK_TO_AVAN)); addNPC(NPC, HeadE.CALM_TALK, ""Well, maybe we'll all get lucky and the scorpions will deal with him.""); } default -> { addNPC(NPC, HeadE.CALM_TALK, ""Good day to you, traveller. Would you be interested in buying some gems?""); addOptions(""Choose an option:"", new Options() { @Override public void create() { option(""Yes, please"", new Dialogue() .addNext(()-> ShopsHandler.openShop(player, ""gem_trader"")) ); option(""No, thank you."", new Dialogue()); } }); } } } public static NPCClickHandler handleDialogue = new NPCClickHandler(new Object[] { NPC }, e -> e.getPlayer().startConversation(new GemTraderFamilyCrestD(e.getPlayer()).getStart())); }" "package com.rs.game.content.quests.familycrest.dialogues; @PluginEventHandler public class JohnathonFamilyCrestD extends Conversation { private final int DEMON_INQUIRY = 0; private static final int NPC = 668; public JohnathonFamilyCrestD(Player player) { super(player); switch(player.getQuestManager().getStage(Quest.FAMILY_CREST)) { case TALK_TO_JOHNATHAN -> { if(player.getQuestManager().getAttribs(Quest.FAMILY_CREST).getB(""USED_ANTIPOISEN_ON_JOHN"")) { addNPC(NPC, HeadE.CALM_TALK, ""Ooooh... thank you... Wow! I'm feeling a lot better now! That potion really seems to have done the trick!""); addNPC(NPC, HeadE.CALM_TALK, ""How can I reward you?""); addPlayer(HeadE.HAPPY_TALKING, ""I've come here for your piece of the Fitzharmon family crest.""); addNPC(NPC, HeadE.CALM_TALK, ""You have? Unfortunately I don't have it any more... in my attempts to slay the fiendish Chronozon, the blood demon,""); addNPC(NPC, HeadE.CALM_TALK, ""I lost a lot of equipment in our last battle when he bested me and forced me away from his den. He probably still has it now.""); addNext(()->{ player.getQuestManager().setStage(Quest.FAMILY_CREST, KILL_CHRONOZON); player.startConversation(new JohnathonFamilyCrestD(player, DEMON_INQUIRY).getStart()); }); } else { addPlayer(HeadE.HAPPY_TALKING, ""Greetings. Would you happen to be Johnathon Fitzharmon?""); addNPC(NPC, HeadE.CALM_TALK, ""That... I am...""); addPlayer(HeadE.HAPPY_TALKING, ""I am here to retrieve your fragment of the Fitzharmon family crest.""); addNPC(NPC, HeadE.DIZZY, ""The... poison... it is all... too much... My head... will not... stop spinning...""); addSimple(""Sweat is pouring down Jonathons's face""); addNPC(NPC, HeadE.DIZZY, ""What... what did that spider... DO to me? I... I feel so weak... I can hardly... think at all...""); addSimple(""He appears in need of antipoison""); } } case KILL_CHRONOZON -> { if(player.getInventory().containsItem(JOHNATHAN_CREST, 1)) { addPlayer(HeadE.HAPPY_TALKING, ""I have your piece of the crest!""); addNPC(NPC, HeadE.CALM_TALK, ""Well done! Now return it to my father!""); return; } addPlayer(HeadE.HAPPY_TALKING, ""I'm trying to kill this demon Chronozon that you mentioned...""); addNext(()-> player.startConversation(new JohnathonFamilyCrestD(player, DEMON_INQUIRY).getStart())); } case QUEST_COMPLETE -> { addNPC(NPC, HeadE.CALM_TALK, ""I have heard word from my father, thank you for helping to restore our family honour""); if(player.getInventory().containsItem(FAMILY_GAUNTLETS, 1)) { addPlayer(HeadE.HAPPY_TALKING, ""Your father said that you could improve these Gauntlets in some way for me""); addNPC(NPC, HeadE.CALM_TALK, ""Yes, I can. In my travels I have studied the arcane arts and know a way to empower bolt spells"" + "" with our family gauntlets""); addOptions(""Choose an option:"", new Options() { @Override public void create() { option(""That sounds good, improve them for me"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""That sounds good, improve them for me"") .addSimple(""Johnathan takes out a wand and crumples it into pieces onto the gloves"") .addSimple(""He burns them with a bolt spell onto the gauntlet"") .addSimple(""Johnathan hands the gauntlets to you"", () -> { player.getInventory().removeItems(new Item(FAMILY_GAUNTLETS, 1)); player.getInventory().addItem(CHAOS_GAUNTLETS, 1); }) ); option(""I think I'll check my other options with your brothers"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""I think I'll check my other options with your brothers"") .addNPC(NPC, HeadE.CALM_TALK, ""Ok, give them my regards."") ); } }); } else addPlayer(HeadE.HAPPY_TALKING, ""You're welcome!""); } default -> addNPC(NPC, HeadE.DIZZY, ""I am so very tired... Leave me be... to rest...""); } } public JohnathonFamilyCrestD(Player p, int id) { super(p); final int SECOND = 1; switch(id) { case DEMON_INQUIRY -> addOptions(""Choose an option:"", new Options() { @Override public void create() { option(""So is this Chronozon hard to defeat?"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""So is this Chronozon hard to defeat?"") .addNPC(NPC, HeadE.CALM_TALK, ""Well... you will have to be a skilled Mage to defeat him, and my powers are not good enough"" + "" yet. You will need to hit him once with each of the four elemental spells of death before he will be defeated."") ); option(""Where can I find Chronozon?"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Where can I find Chronozon?"") .addNPC(NPC, HeadE.CALM_TALK, ""The fiend has made his lair in Edgeville Dungeon. When you come in down the ladder in Edgeville, "" + ""follow the corridor north until you reach a room with skeletons. That passageway to the left will lead you to him."") ); option(""So how did you end up getting poisoned?"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""So how did you end up getting poisoned?"") .addNPC(NPC, HeadE.CALM_TALK, ""Those accursed poison spiders that surround the entrance to Chronozon's lair... I must have taken a nip from one of them as I attempted to make my escape."") ); option(""I will be on my way now."", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""I will be on my way now."") .addNPC(NPC, HeadE.CALM_TALK, ""My thanks for the assistance adventurer."") ); } }); case SECOND -> { } } } public static ItemOnNPCHandler itemOnJohn = new ItemOnNPCHandler(true, new Object[] { 668 }, e -> { Player p = e.getPlayer(); if(p.getQuestManager().getStage(Quest.FAMILY_CREST) == TALK_TO_JOHNATHAN) if(e.getItem().getName().contains(""Antipoison"") || e.getItem().getName().contains(""antipoison"")) if(e.getItem().getDefinitions().isNoted()) p.startConversation(new Conversation(p) { { addPlayer(HeadE.HAPPY_TALKING, ""It must be unnoted silly!""); create(); } }); else if(!p.getQuestManager().getAttribs(Quest.FAMILY_CREST).getB(""USED_ANTIPOISEN_ON_JOHN"")) { p.getQuestManager().getAttribs(Quest.FAMILY_CREST).setB(""USED_ANTIPOISEN_ON_JOHN"", true); p.startConversation(new Conversation(p) { { addSimple(""You give Johnathon a small sip of antipoison, not a full dose...""); create(); } }); } }); public static NPCClickHandler handleDialogue = new NPCClickHandler(new Object[] { NPC }, e -> e.getPlayer().startConversation(new JohnathonFamilyCrestD(e.getPlayer()).getStart())); }" "package com.rs.game.content.quests.fightarena; @QuestHandler( quest = Quest.FIGHT_ARENA, startText = ""Talk to Lady Servil, just north-west of the fight arena, which is south of Ardougne."", itemsText = ""Combat gear."", combatText = ""Be able to defeat level 50, 64 and 77 foes."", rewardsText = ""12,175 Attack XP
2,175 Thieving XP
1,000 coins"", completedStage = 4 ) @PluginEventHandler public class FightArena extends QuestOutline { public final static int NOT_STARTED = 0; public final static int FREE_JEREMY = 1; public final static int GET_JAIL_KEYS = 2; public final static int RETURN_TO_LADY_SERVIL = 3; public final static int QUEST_COMPLETE = 4; @Override public List getJournalLines(Player player, int stage) { ArrayList lines = new ArrayList<>(); switch (stage) { case NOT_STARTED -> { lines.add(""The prosperous Servil family have been abducted by the""); lines.add(""infamous General Khazard. He plans to have the family""); lines.add(""battle for his entertainment in the Fight Arena. Can ""); lines.add(""you rescue the Servils before the tyrant has these ""); lines.add(""innocent (not to mention wealthy) civilians slain?""); lines.add(""""); lines.add(""You can start this quest by speaking to Lady Servil,""); lines.add(""South-west of the monastary that is south of Ardougne.""); lines.add(""""); } case FREE_JEREMY -> { lines.add(""Lady Servil's husband and child have been taken captive!""); lines.add(""I should find a way into the fight arena by perhaps wearing""); lines.add(""the soldier's armour.""); lines.add(""""); lines.add(""I should be able to find an armour rack or something around""); lines.add(""here....""); lines.add(""""); } case GET_JAIL_KEYS -> { lines.add(""I need to find a way to open the jail cell. Perhaps one of""); lines.add(""the gaurds has the keys. If I could get him drunk enough...""); lines.add(""""); } case RETURN_TO_LADY_SERVIL -> { lines.add(""I should return to Lady Servil.""); lines.add(""""); } case QUEST_COMPLETE -> { lines.add(""""); lines.add(""""); lines.add(""QUEST COMPLETE!""); } default -> lines.add(""Invalid quest stage. Report this to an administrator.""); } return lines; } public static ItemOnObjectHandler keyOnCell = new ItemOnObjectHandler(new Object[] { 80 }, new Object[] { 76 }, e -> { if (e.getPlayer().getQuestManager().getStage(Quest.FIGHT_ARENA) == GET_JAIL_KEYS) { e.getPlayer().startConversation(new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Jeremy! Look, I have the keys."") .addNPC(265, HeadE.CHILD_UNSURE, ""Wow! Please set me free so we can find my dad. I overheard a guard talking. I think "" + ""they've taken him to the arena."") .addPlayer(HeadE.HAPPY_TALKING, ""Okay, we'd better hurry."") .addNext(()-> e.getPlayer().getControllerManager().startController(new FightArenaFightCutsceneController())) ); } }); public static NPCClickHandler attack = new NPCClickHandler(false, new Object[] {7552}, e -> { e.getPlayer().stopAll(true); e.getPlayer().getInteractionManager().setInteraction(new PlayerCombatInteraction(e.getPlayer(), e.getNPC())); }); public static ObjectClickHandler handleAreanEntrance = new ObjectClickHandler(new Object[] { 82 }, e -> {}); public static ObjectClickHandler handleArmourStand = new ObjectClickHandler(new Object[] { 41498 }, e -> { if(e.getOption().equalsIgnoreCase(""borrow"")) { if(!e.getPlayer().getInventory().containsItem(74) && e.getPlayer().getEquipment().getHatId() != 74) e.getPlayer().getInventory().addItem(74, 1, true); if(!e.getPlayer().getInventory().containsItem(75) && e.getPlayer().getEquipment().getChestId() != 75) e.getPlayer().getInventory().addItem(75, 1, true); } }); public static NPCClickHandler talkKhazardGaurd = new NPCClickHandler(new Object[] { 253 }, e -> e.getPlayer().startConversation(new Dialogue().addNPC(e.getNPCId(), HeadE.EVIL_LAUGH, ""Hail General Khazard!""))); public static LoginHandler onLoginVarbits = new LoginHandler(e -> { if(e.getPlayer().getQuestManager().getStage(Quest.FIGHT_ARENA) > NOT_STARTED) e.getPlayer().getVars().setVarBit(5626, 1); if(e.getPlayer().getQuestManager().getStage(Quest.FIGHT_ARENA) > GET_JAIL_KEYS); e.getPlayer().getVars().setVarBit(6163, 2); if(e.getPlayer().getQuestManager().getStage(Quest.FIGHT_ARENA) <= GET_JAIL_KEYS) e.getPlayer().getVars().setVarBit(6163, 0); }); public static ObjectClickHandler handleJailEntrance = new ObjectClickHandler(new Object[] { 81 }, e -> { if(e.getObject().getRotation() == 2) { if(e.getPlayer().getX() > e.getObject().getX()) { handleDoor(e.getPlayer(), e.getObject()); return; } if(e.getPlayer().getEquipment().getHatId() == 74 && e.getPlayer().getEquipment().getChestId() == 75) { e.getPlayer().startConversation(new Dialogue().addPlayer(HeadE.FRUSTRATED, ""This door appears to be locked."") .addNPC(253, HeadE.CALM_TALK, ""Nice observation, guard. You could have asked to be let in like any normal person."") .addNext(()-> handleDoor(e.getPlayer(), e.getObject())) ); return; } e.getPlayer().startConversation(new Dialogue().addPlayer(HeadE.FRUSTRATED, ""This door appears to be locked."") .addNPC(253, HeadE.CALM_TALK, ""Nice observation"") ); } if(e.getObject().getRotation() == 3) { if(e.getPlayer().getY() < e.getObject().getY()) { handleDoor(e.getPlayer(), e.getObject()); return; } if(e.getPlayer().getEquipment().getHatId() == 74 && e.getPlayer().getEquipment().getChestId() == 75) { e.getPlayer().startConversation(new Dialogue().addPlayer(HeadE.FRUSTRATED, ""This door appears to be locked."") .addNPC(253, HeadE.CALM_TALK, ""Nice observation, guard. You could have asked to be let in like any normal person."") .addNext(()-> handleDoor(e.getPlayer(), e.getObject())) ); return; } e.getPlayer().startConversation(new Dialogue().addPlayer(HeadE.FRUSTRATED, ""This door appears to be locked."") .addNPC(253, HeadE.CALM_TALK, ""Nice observation"") ); } }); @Override public void complete(Player player) { player.getInventory().addCoins(1000); player.getSkills().addXpQuest(Constants.ATTACK, 12_175); player.getSkills().addXpQuest(Constants.THIEVING, 2_175); sendQuestCompleteInterface(player, 75); } }" "package com.rs.game.content.quests.fightarena; public class FightArenaFightCutsceneController extends Controller { public transient Instance instance; List dynamicNPCs = new ArrayList<>(); Tile locationOnFail = Tile.of(2617, 3167, 0); Tile locationOnVictory = Tile.of(2617, 3172, 0); Tile spawn = null; boolean canLeave = false; boolean playerHasDied = false; @Override public void start() { playCutscene(); } @Override public Genre getGenre() { return Music.getGenreByName(""Other Dungeons""); } @Override public boolean playAmbientOnControllerRegionEnter() { return false; } @Override public boolean playAmbientMusic() { return true; } private void playCutscene() { player.lock(); instance = Instance.of(locationOnFail, 10, 10); instance.copyMapAllPlanes(320, 391).thenAccept(e -> { spawn = instance.getLocalTile(57, 39); WorldTasks.scheduleLooping(new Task() { int tick; NPC jeremy; NPC ogre; NPC father; NPC scorpion; NPC bouncer; NPC general_khazard; @Override public void run() { if(playerHasDied || player.getControllerManager().getController() == null || !(player.getControllerManager().getController() instanceof FightArenaFightCutsceneController)) { tick = -1; player.unlock(); stop(); } if (tick == 0) player.getInterfaceManager().setFadingInterface(115); if (tick == 2) {// setup player player.getPackets().setBlockMinimapState(2); player.tele(spawn); } if (tick == 3) { addAllFightArenaNPCs(); for (NPC npc : dynamicNPCs) { if (npc.getId() == 265) jeremy = npc; if(npc.getId() == 7522) ogre = npc; if(npc.getId() == 267) father = npc; if(npc.getId() == 7521) bouncer = npc; } } if (tick == 5) { player.getInterfaceManager().setFadingInterface(170); player.getPackets().setBlockMinimapState(0); } if(tick == 6) player.faceWest(); if(tick == 7) player.setNextAnimation(new Animation(2098)); if(tick == 8) { jeremeysCell(true); jeremy.setRandomWalk(false); jeremy.faceEntity(player); } if(tick == 9) { jeremy.walkToAndExecute(spawn, ()->{ jeremy.faceNorth(); jeremy.forceTalk(""I'll run ahead""); tick++; }); player.walkToAndExecute(instance.getLocalTile(57, 40), () -> player.faceSouth()); } if(tick == 11) { jeremeysCell(false); jeremy.walkToAndExecute(Tile.of(jeremy.getX(), jeremy.getY()-12, jeremy.getPlane()), ()->{}); } if(tick == 13) { general_khazard = new NPC(7551, Tile.of(instance.getLocalX(45), instance.getLocalY(28), 0)); general_khazard.faceWest(); general_khazard.setRandomWalk(false); dynamicNPCs.add(general_khazard); player.getPackets().sendCameraPos(Tile.of(instance.getLocalX(41), instance.getLocalY(35), 0), 1500); player.getPackets().sendCameraLook(Tile.of(instance.getLocalX(44), instance.getLocalY(26), 0), 0); player.faceNorth(); jeremy.faceNorth(); player.tele(Tile.of(instance.getLocalX(43), instance.getLocalY(26), player.getPlane())); jeremy.tele(Tile.of(instance.getLocalX(42), instance.getLocalY(26), 0)); } if(tick == 15) { player.faceEntity(jeremy); jeremy.faceEntity(player); player.startConversation(new Dialogue() .addPlayer(HeadE.SCARED, ""Jeremy, where's your father?"") .addNPC(jeremy.getId(), HeadE.CHILD_UNSURE, ""Quick, help him! That beast will kill him. He's too old to fight."") .addNext(()-> tick = 17) ); } if(tick == 17) { ogre.tele(Tile.of(instance.getLocalX(42), instance.getLocalY(40), 0)); ogre.setRandomWalk(false); ogre.faceEntity(father); father.faceEntity(ogre); father.setLocked(true); father.setHitpoints(9999); ogre.setTarget(father); player.getPackets().sendResetCamera(); player.unlock(); } if(tick == 20) { ogre.forceTalk(""Puny human go splat!""); ogre.setTarget(father); father.setNextAnimation(new Animation(2836)); ogre.setRandomWalk(true); } if(tick == 21) { if(ogre.hasFinished()) tick = 22; } if(tick == 22) { player.lock(); player.startConversation(new Dialogue() .addNPC(7535, HeadE.CALM_TALK, ""You saved both my life and that of my son. I am eternally in your debt, brave traveller."", () ->{ father.faceEntity(player); player.faceEntity(father); }) .addNPC(7551, HeadE.CALM_TALK, ""Haha! Well done, well done. That was rather entertaining. I am the great General Khazard"" + "" and the two men you just \'saved\' are my property."", () -> general_khazard.faceEntity(player)) .addPlayer(HeadE.HAPPY_TALKING, ""They belong to nobody."", ()-> player.faceEntity(general_khazard)) .addNPC(7551, HeadE.CALM_TALK, ""Well, I suppose we could make some arrangement for their freedom."") .addPlayer(HeadE.HAPPY_TALKING, ""What do you mean?"") .addNPC(7551, HeadE.CALM_TALK, ""I'll let them go, but you must stay and fight!"") .addNext(()-> tick = 24) ); } if(tick == 24) { player.getInterfaceManager().setFadingInterface(115); } if(tick == 27) { player.getPackets().setBlockMinimapState(2); scorpion = new NPC(271, Tile.of(instance.getLocalX(45), instance.getLocalY(31), 0), true); dynamicNPCs.add(scorpion); } if(tick == 29) { player.getInterfaceManager().setFadingInterface(170); player.getPackets().setBlockMinimapState(0); scorpion.setTarget(player); player.unlock(); } if(tick == 30) { if(scorpion.hasFinished()) tick = 31; } if(tick == 31) { player.lock(); player.startConversation(new Dialogue() .addNPC(7551, HeadE.EVIL_LAUGH, ""Let's see how you do against this!"") .addNext(()-> tick = 33) ); } if(tick == 33) { player.getInterfaceManager().setFadingInterface(115); } if(tick == 36) { player.getPackets().setBlockMinimapState(2); bouncer.tele(Tile.of(instance.getLocalX(45), instance.getLocalY(34), 0)); } if(tick == 38) { player.getPackets().setBlockMinimapState(0); player.getInterfaceManager().setFadingInterface(170); bouncer.setTarget(player); player.unlock(); } if(tick == 39) { if(bouncer.hasFinished()) tick = 40; } if(tick == 40) { player.lock(); player.startConversation(new Dialogue() .addNPC(7551, HeadE.AMAZED, ""Nooooo! Bouncer! How dare you? For his sake you'll suffer, traveller."" + "" Prepare to meet your maker."", () -> general_khazard.faceEntity(player)) .addPlayer(HeadE.HAPPY_TALKING, ""You agreed to let the Servils go if I stayed to fight."", ()-> player.faceEntity(general_khazard)) .addNPC(7551, HeadE.CALM_TALK, ""Indeed you shall see that I am not cowardly enough to make false promises. They may go."") .addNPC(7551, HeadE.CALM_TALK, ""You, however, have caused me much trouble today. You will remain here so that I may have the pleasure of killing you myself."") .addNPC(jeremy.getId(), HeadE.CHILD_UNSURE, ""No, you don't have to fight him! Come with us, "" + player.getDisplayName() + ""!"", ()-> jeremy.faceEntity(player)) .addNext(()->{ canLeave = true; tick = 42; }) ); } if(tick == 42) { player.getInterfaceManager().setFadingInterface(115); } if(tick == 45) { player.getPackets().setBlockMinimapState(2); dynamicNPCs.add(new NPC(7552, general_khazard.getTile(), true)); general_khazard.finish(); } if(tick == 47) { player.getInterfaceManager().setFadingInterface(170); player.unlock(); player.getPackets().setBlockMinimapState(0); stop(); } if(tick != 9 && tick != 16 && tick != 21 && tick != 23 && tick != 30 && tick != 32 && tick != 39 && tick != 41) tick++; } }, 0, 1); }); } public boolean processObjectClick1(GameObject object) { if(object.getId() == 82 && canLeave) { WorldTasks.scheduleLooping(new Task() { int tick; @Override public void run() { if(tick == 0) { player.getInterfaceManager().setFadingInterface(115); } if (tick == 2) {// setup player player.getPackets().setBlockMinimapState(2); player.tele(locationOnVictory); player.getQuestManager().setStage(Quest.FIGHT_ARENA, FightArena.RETURN_TO_LADY_SERVIL); } if(tick == 5) { player.getInterfaceManager().setFadingInterface(170); player.getPackets().setBlockMinimapState(0); forceClose(); } if(tick == 6) { player.getVars().setVarBit(6163, 2); stop(); } tick++; } }, 0, 1); return true; } player.startConversation(new Dialogue().addPlayer(HeadE.AMAZED, ""I just can't right now!!"")); return false; } public boolean processObjectClick2(GameObject object) { player.startConversation(new Dialogue().addPlayer(HeadE.AMAZED, ""I just can't right now!!"")); return false; } public boolean processObjectClick3(GameObject object) { player.startConversation(new Dialogue().addPlayer(HeadE.AMAZED, ""I just can't right now!!"")); return false; } public boolean processObjectClick4(GameObject object) { player.startConversation(new Dialogue().addPlayer(HeadE.AMAZED, ""I just can't right now!!"")); return false; } @Override public boolean sendDeath() { playerHasDied = true; player.stopAll(); player.reset(); player.sendMessage(""You have been defeated!""); player.tele(locationOnFail); player.getVars().setVarBit(2569, 0); forceClose(); return false; } @Override public boolean login() { player.tele(locationOnFail); forceClose(); return false; } @Override public boolean logout() { removeInstance(); player.unlock(); return false; } @Override public void forceClose() { player.getPackets().setBlockMinimapState(0); player.setForceMultiArea(false); removeInstance(); player.unlock(); removeController(); } private void removeInstance() { if(instance == null) return; removeDynamicNPCs(); instance.destroy(); } private void addAllFightArenaNPCs() { List originalNPCs = World.getNPCsInChunkRange(Tile.of(2595, 3163, 0).getChunkId(), 5); List xDiff = new ArrayList<>(); List yDiff = new ArrayList<>(); for(NPC npc : originalNPCs) { xDiff.add(2617 - npc.getX());//Same spawn X as dynamic but from original Fight Arena yDiff.add(3167 - npc.getY());//Same spawn Y } if(spawn != null) for(int i = 0; i < originalNPCs.size(); i++) { NPC npc = originalNPCs.get(i); dynamicNPCs.add(new NPC(npc.getId(), Tile.of(spawn.getX() - xDiff.get(i), spawn.getY() - yDiff.get(i), npc.getPlane()), true)); } } private void jeremeysCell(boolean open) { GameObject door = World.getClosestObject(80, player.getTile()); if(open) { if(door.getRotation() == 3) return; World.removeObject(door); door.setRotation(3); door.setTile(Tile.of(door.getX() - 1, door.getY(), door.getPlane())); World.spawnObject(door); return; } if(door.getRotation() == 0) return; World.removeObject(door); door.setRotation(0); door.setTile(Tile.of(door.getX()+1, door.getY(), door.getPlane())); World.spawnObject(door);; } private void removeDynamicNPCs() { for(NPC npc : dynamicNPCs) npc.finish(); } @Override public void onTeleported(TeleType type) { forceClose(); } }" "package com.rs.game.content.quests.fightarena.dialogue; @PluginEventHandler public class AngorFightArenaD extends Conversation { private static final int NPC = 259; public AngorFightArenaD(Player player) { super(player); addPlayer(HeadE.HAPPY_TALKING, ""Hello.""); addNPC(NPC, HeadE.CALM_TALK, ""Hi, what can I get you? We have a range of quality brews""); addOptions(""Choose an option:"", new Options() { @Override public void create() { if(player.getInventory().hasCoins(5)) { option(""I'll have a beer, please."", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""I'll have a beer, please."") .addNPC(NPC, HeadE.CALM_TALK, ""That will be 5 coins..."") .addPlayer(HeadE.HAPPY_TALKING, ""Okiedokie"") .addSimple(""He passes you a beer."", ()->{ player.getInventory().removeCoins(5); player.getInventory().addItem(1917, 1); }) ); option("" I'd like a Khali brew please."", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, "" I'd like a Khali brew please."") .addNPC(NPC, HeadE.CALM_TALK, ""That will be 5 coins..."") .addPlayer(HeadE.HAPPY_TALKING, ""Okiedokie"") .addSimple(""He passes you a Khali brew."", ()->{ player.getInventory().removeCoins(5); player.getInventory().addItem(77, 1); }) ); } else { option(""I'll have a beer, please."", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""I'll have a beer, please."") .addNPC(NPC, HeadE.CALM_TALK, ""That will be 5 coins..."") .addSimple(""You don't have enough coins..."") ); option("" I'd like a Khali brew please."", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, "" I'd like a Khali brew please."") .addNPC(NPC, HeadE.CALM_TALK, ""That will be 5 coins..."") .addSimple(""You don't have enough coins..."") ); } option(""Got any news?"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Got any news?"") .addNPC(NPC, HeadE.CALM_TALK, ""Nothing fresh, just a bunch of drunks around here..."") .addPlayer(HeadE.CALM_TALK, ""Umm, thanks."") ); } }); create(); } public static NPCClickHandler handleDialogue = new NPCClickHandler(new Object[]{NPC}, e -> e.getPlayer().startConversation(new AngorFightArenaD(e.getPlayer()))); }" "package com.rs.game.content.quests.fightarena.dialogue; @PluginEventHandler public class JeremyServilFightArenaD extends Conversation { private static final int NPC = 265; public JeremyServilFightArenaD(Player player) { super(player); switch(player.getQuestManager().getStage(Quest.FIGHT_ARENA)) { case NOT_STARTED -> { addNPC(NPC, HeadE.CHILD_CRYING, ""Hello...""); addPlayer(HeadE.HAPPY_TALKING, ""Hello...""); } case FREE_JEREMY -> { addPlayer(HeadE.HAPPY_TALKING, ""Hello.""); addNPC(NPC, HeadE.CHILD_CRYING, ""Please, "" + player.getPronoun(""sir"", ""madam"") + "", don't hurt me.""); addSimple(""You give Sammy a friendly wink.""); addPlayer(HeadE.HAPPY_TALKING, ""Shhh. I am in disguise; I'm here to help you and your father escape, but I need your help. Do you know where "" + ""they keep the keys?""); addNPC(NPC, HeadE.CHILD_CALM_TALK, ""The guard always keeps hold of them.""); addPlayer(HeadE.HAPPY_TALKING, ""Which guard?""); addNPC(NPC, HeadE.CHILD_ANGRY, ""The bald, fat, lazy guard with a goatee. He's the one who usually locks up.""); addPlayer(HeadE.HAPPY_TALKING, ""Right, I'll look for him. Don't lose heart - I'll be back."", ()-> player.getQuestManager().setStage(Quest.FIGHT_ARENA, GET_JAIL_KEYS)); } case GET_JAIL_KEYS -> addNPC(NPC, HeadE.CHILD_CRYING, ""Hurry, I don't know what they are going to do with me next.""); case RETURN_TO_LADY_SERVIL, QUEST_COMPLETE -> { addNPC(7533, HeadE.CHILD_AWE, ""That was amazing "" + this.player.getDisplayName() + ""!""); addPlayer(HeadE.HAPPY_TALKING, ""Yea that was a trip...""); } } create(); } public static NPCClickHandler handleDialogue = new NPCClickHandler(new Object[]{NPC, 7533}, e -> e.getPlayer().startConversation(new JeremyServilFightArenaD(e.getPlayer()))); public static NPCInteractionDistanceHandler jeremyJailDistance = new NPCInteractionDistanceHandler(NPC, (player, npc) -> 2); }" "package com.rs.game.content.quests.fightarena.dialogue; @PluginEventHandler public class JustinServilFightArenaD extends Conversation { private static final int NPC = 7541; public JustinServilFightArenaD(Player player) { super(player); addNPC(NPC, HeadE.HAPPY_TALKING, ""You are one tough fighter, thank you "" + this.player.getDisplayName() + ""!""); } public static NPCClickHandler handleDialogue = new NPCClickHandler(new Object[]{NPC}, e -> e.getPlayer().startConversation(new JustinServilFightArenaD(e.getPlayer()).getStart())); }" "package com.rs.game.content.quests.fightarena.dialogue; @PluginEventHandler public class LadyServilFightArenaD extends Conversation { private static final int NPC = 258; public LadyServilFightArenaD(Player player) { super(player); switch(player.getQuestManager().getStage(Quest.FIGHT_ARENA)) { case NOT_STARTED -> { addPlayer(HeadE.HAPPY_TALKING, ""Hi there. It looks like your cart has broken down. Do you need any help?""); addNPC(NPC, HeadE.SAD_SNIFFLE, ""*sob* Oh I don't care about the cart. *sob* If only Justin were here, he'd fix it. My poor Justin! *sob* "" + ""*sniffle* And Jeremy! *sob* He's only a child.""); addNPC(NPC, HeadE.SAD_CRYING, ""*sob* How could anyone be so inhumane? *wail* My poor boy! *sob* I've got to find them. *sob*""); addPlayer(HeadE.HAPPY_TALKING, ""I hope you can find them too.""); addPlayer(HeadE.HAPPY_TALKING, ""But, umm, can I help you?""); addNPC(NPC, HeadE.SAD_SNIFFLE, ""Would you, please? I'm Lady Servil, and my husband is Sir Servil. We were travelling north with our son "" + ""Jeremy when we were ambushed by General Khazard's men.""); addPlayer(HeadE.SECRETIVE, ""General Khazard?""); addNPC(NPC, HeadE.SAD_MILD_LOOK_DOWN, ""He has been victimising my family ever since we declined to hand over our lands. Now he's kidnapped my husband "" + ""and son to fight in his Fight Arena to the south of here.""); addNPC(NPC, HeadE.SAD_MILD, ""I hate to think what he'll do to them. They're not warriors and won't survive against the creatures of the arena! "" + ""The General is a sick and twisted individual.""); addOptions(""Start Fight Arena?"", new Options() { @Override public void create() { option(""Yes"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""I'll try my best to return your family."", ()->{ player.getQuestManager().setStage(Quest.FIGHT_ARENA, FREE_JEREMY); player.getVars().setVarBit(5626, 1); }) .addNPC(NPC, HeadE.SAD, ""Please do. My family can reward you for your troubles. I'll be waiting here for you"") ); option(""No"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Welp, good look with that!"") .addNPC(NPC, HeadE.SAD_EXTREME, ""*Wails *Sobs"") ); } }); } case FREE_JEREMY, GET_JAIL_KEYS -> { addNPC(NPC, HeadE.CALM_TALK, ""Please find my son and husband!""); addPlayer(HeadE.HAPPY_TALKING, ""I will m'am.""); } case RETURN_TO_LADY_SERVIL -> { addNPC(NPC, HeadE.CALM_TALK, ""You're alive!""); addPlayer(HeadE.HAPPY_TALKING, ""Yes.""); addNPC(NPC, HeadE.CALM_TALK, ""I thought Khazard's men had taken you. My son and husband are safe and sound, as you can see! Without you they "" + ""would certainly be dead.""); addNPC(NPC, HeadE.CALM_TALK, ""I am truly grateful for your service. All I can offer in return is a small amount of material wealth. "" + ""Please take these coins as a sign of my gratitude.""); addNext(()-> player.getQuestManager().completeQuest(Quest.FIGHT_ARENA)); } case QUEST_COMPLETE -> addNPC(NPC, HeadE.CALM_TALK, ""Thank you "" + this.player.getDisplayName() + ""! My family is alive and safe because of you.""); } } public static NPCClickHandler handleDialogue = new NPCClickHandler(new Object[]{NPC}, e -> e.getPlayer().startConversation(new LadyServilFightArenaD(e.getPlayer()).getStart())); }" "package com.rs.game.content.quests.fightarena.dialogue; @PluginEventHandler public class LazyGuardFightArenaD extends Conversation { private static final int NPC = 7550; public LazyGuardFightArenaD(Player player, final NPC npc) { super(player); switch(player.getQuestManager().getStage(Quest.FIGHT_ARENA)) { case NOT_STARTED, FREE_JEREMY -> { addNPC(NPC, HeadE.CALM_TALK, ""Whatchu want?""); addPlayer(HeadE.HAPPY_TALKING, ""Nothing.""); } case GET_JAIL_KEYS -> { if(player.getInventory().containsItem(76)) { addNPC(NPC, HeadE.CALM_TALK, ""Phew, Almost fell asleep there""); addPlayer(HeadE.SECRETIVE, ""Yea, you almost did...""); addNPC(NPC, HeadE.CALM_TALK, ""Blimey I lost my keys too. Looks like I will have to make a new set again.""); addPlayer(HeadE.SECRETIVE, ""Yup, looks like you will...""); return; } if(player.getInventory().containsItem(77)) { addPlayer(HeadE.HAPPY_TALKING, ""Hello again.""); addNPC(NPC, HeadE.CALM_TALK, ""Bored, bored, bored. You'd think suffering and slaughter would be more entertaining. The slaves hardly make any effort to make the fights fun. Selfish, the lot of them""); addPlayer(HeadE.HAPPY_TALKING, ""Do you still fancy a drink? I just happen to have a bottle of the good stuff on me.""); addNPC(NPC, HeadE.CALM_TALK, ""No, no I really shouldn't. Not while I'm on duty.""); addPlayer(HeadE.HAPPY_TALKING, ""Go on... you've worked hard all day. A quick sip will be just enough to keep you going.""); addNPC(NPC, HeadE.CALM_TALK, ""Well, I have had a hard day. Oh, go on.""); addSimple(""You hand a bottle of Khali brew to the guard. He takes a mouthful of the drink.""); addNPC(NPC, HeadE.CALM_TALK, ""Blimey! This stuff is pretty good. It isn't Khali brew, is it?""); addPlayer(HeadE.HAPPY_TALKING, ""No, of course not. Don't worry, it's just a quick pick-me-up. You'll be fine.""); addSimple(""The guard quickly drinks half of the bottle and sways slightly."", () -> { player.lock(9); player.getInventory().deleteItem(77, 1); player.faceTile(Tile.of(2617, 3144, 0)); player.getVars().setVarBit(5627, 1); WorldTasks.scheduleLooping(new Task() { int tick; @Override public void run() { if (tick == 5) npc.setNextAnimation(new Animation(11669)); if (tick == 9) { npc.setNextAnimation(new Animation(11670)); player.getVars().setVarBit(5627, 2); } if(tick == 10) stop(); tick++; } }, 0, 1); }); return; } addPlayer(HeadE.HAPPY_TALKING, ""Long live General Khazard!""); addNPC(NPC, HeadE.CALM_TALK, ""Erm, yes... quite right. Have you come to laugh at the fighting slaves? I used to really enjoy it but, after a "" + ""while, they became quite boring. ""); addNPC(NPC, HeadE.CALM_TALK, ""To be honest, now I've locked them up, all I want is a decent drink. Mind you, too much Khali brew and I fall asleep.""); addPlayer(HeadE.HAPPY_TALKING, ""Hard stuff that Khali brew. Tastes great though, doesn't it?""); addNPC(NPC, HeadE.CALM_TALK, ""Well, yes. Between you and me, I find it hard to turn down a nice cold bottle of Khali brew from the bar""); addNPC(NPC, HeadE.CALM_TALK, ""Mmmm, yes. Ahem! Well, yes, enough chit-chat - back to work, guard.""); addPlayer(HeadE.HAPPY_TALKING, ""Yessir!""); } case QUEST_COMPLETE -> { } } } public static NPCClickHandler handleDialogue = new NPCClickHandler(new Object[]{NPC, 7525, 7526, 7527}, e -> { e.getNPC().faceSouth(); if(e.getOption().equalsIgnoreCase(""Steal-keys"")) { if(e.getPlayer().getInventory().hasFreeSlots()) { e.getPlayer().startConversation(new Dialogue().addSimple(""You grab the keys"")); e.getPlayer().getInventory().addItem(76, 1); e.getPlayer().getVars().setVarBit(5627, 3); return; } e.getPlayer().sendMessage(""You need free space to grab his keys...""); } if(e.getPlayer().getVars().getVarBit(5627) > 0) return; e.getPlayer().startConversation(new LazyGuardFightArenaD(e.getPlayer(), e.getNPC()).getStart()); }); public static NPCInteractionDistanceHandler HandleDistance = new NPCInteractionDistanceHandler(new Object[] { NPC, 7525, 7526, 7527 }, (player, npc) -> 1); }" "package com.rs.game.content.quests.fishingcontest; @PluginEventHandler public class BigDaveFishingContestD extends Conversation { private static final int NPC = 228; public BigDaveFishingContestD(Player player) { super(player); switch(player.getQuestManager().getStage(Quest.FISHING_CONTEST)) { case NOT_STARTED, ENTER_COMPETITION -> { addPlayer(HeadE.HAPPY_TALKING, ""Hi, what are you doing here?""); addNPC(NPC, HeadE.CALM_TALK, ""I am waiting for the fishing contest to start.""); addPlayer(HeadE.HAPPY_TALKING, ""Oh.""); } case DO_ROUNDS -> { addNPC(NPC, HeadE.CALM_TALK, ""Hey there! Always nice to see a fresh face!""); addOptions(""Choose an option:"", new Options() { @Override public void create() { option(""So you're the champ?"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""So you're the champ?"") .addNPC(NPC, HeadE.CALM_TALK, ""That's right! Ain't nobody better at fishing round here than me! That's for sure!"") ); option(""Can I fish here instead of you?"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Can I fish here instead of you?"") .addNPC(NPC, HeadE.CALM_TALK, ""Sorry this is my lucky spot!"") ); option(""Do you have any tips for me?"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Do you have any tips for me?"") .addNPC(NPC, HeadE.CALM_TALK, ""Why would I help you? I wanna stay the best! I'm not givin' away my secrets like old Grandpa "" + ""Jack does!"") .addPlayer(HeadE.HAPPY_TALKING, ""Who's Grampa Jack?"") .addNPC(NPC, HeadE.CALM_TALK, ""You really have no clue do you! He won this competition four years in a row! He lives in the "" + ""house just outside the gate."") ); } }); } case GIVE_TROPHY, QUEST_COMPLETE -> { addNPC(NPC, HeadE.CALM_TALK, ""Congratulations champ!""); addPlayer(HeadE.HAPPY_TALKING, ""Thanks...""); } } } public static NPCClickHandler handleDialogue = new NPCClickHandler(new Object[] { NPC }, e -> e.getPlayer().startConversation(new BigDaveFishingContestD(e.getPlayer()).getStart())); public static NPCClickHandler handleBigDaveSpot = new NPCClickHandler(true, new Object[] { 235 }, e -> { NPC npc = e.getNPC(); if(npc.getRegionId() == 10549) { e.getNPC().resetDirection(); if (e.getPlayer().getQuestManager().getStage(Quest.FISHING_CONTEST) >= GIVE_TROPHY) { e.getPlayer().sendMessage(""Nothing interesting happens...""); return; } e.getPlayer().startConversation(new Conversation(e.getPlayer()) { { addNPC(NPC, HeadE.CALM_TALK, ""Sorry, this is my spot.""); addPlayer(HeadE.HAPPY_TALKING, ""I don't like my spot. Please can I have yours?""); addNPC(NPC, HeadE.CALM_TALK, ""Sorry. Big Dave don't like to lose!""); create(); } }); } }); }" "package com.rs.game.content.quests.fishingcontest; @PluginEventHandler public class BonzoFishingContestD extends Conversation { private static final int NPC = 225; public BonzoFishingContestD(Player player) { super(player); switch(player.getQuestManager().getStage(Quest.FISHING_CONTEST)) { case NOT_STARTED -> { addPlayer(HeadE.HAPPY_TALKING, ""Hi, what are you doing here?""); addNPC(NPC, HeadE.CALM_TALK, ""I am waiting for the fishing contest to start.""); addPlayer(HeadE.HAPPY_TALKING, ""Oh.""); } case ENTER_COMPETITION -> { addNPC(NPC, HeadE.CALM_TALK, ""Roll up, roll up! Enter the great Hemenster Fishing Contest! Only 5gp entrance fee!""); addOptions(""Choose an option:"", new Options() { @Override public void create() { if(player.getInventory().hasCoins(5)) { if(player.getQuestManager().getAttribs(Quest.FISHING_CONTEST).getB(PIPE_HAS_GARLIC)) option(""I'll enter the competition please"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""I'll enter the competition please"") .addNPC(NPC, HeadE.CALM_TALK, ""Marvelous!"") .addNPC(NPC, HeadE.CALM_TALK, ""Ok, we've got all the fishermen! It's time to roll! Ok, nearly everyone is in their place "" + ""already. You fish in the spot by the willow tree, and the Sinister Stranger, you fish by the pipes"", () -> { player.getInventory().removeCoins(5); player.getQuestManager().setStage(Quest.FISHING_CONTEST, DO_ROUNDS); }) .addNPC(3677, HeadE.CALM_TALK, ""Actually, can I take the willow tree!?"") .addNPC(NPC, HeadE.CALM_TALK, ""Sure, "" + player.getDisplayName() + "" you go by the pipes..."") ); else option(""I'll enter the competition please"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""I'll enter the competition please"") .addNPC(NPC, HeadE.CALM_TALK, ""Marvelous!"") .addNPC(NPC, HeadE.CALM_TALK, ""Ok, we've got all the fishermen! It's time to roll! Ok, nearly everyone is in their place "" + ""already. You fish in the spot by the willow tree, and the Sinister Stranger, you fish by the pipes"", () -> { player.getInventory().removeCoins(5); player.getQuestManager().setStage(Quest.FISHING_CONTEST, DO_ROUNDS); }) .addNPC(NPC, HeadE.CALM_TALK, ""Your fishing competition spot is by the willow tree."") ); } else option(""I'll enter the competition please"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""I'll enter the competition please"") .addNPC(NPC, HeadE.CALM_TALK, ""Do you have 5 coins?"") .addPlayer(HeadE.CALM_TALK, ""No I don't."") .addNPC(NPC, HeadE.CALM_TALK, ""No pay, no play."") ); option(""No thanks, I'll just watch the fun."", new Dialogue()); } }); } case DO_ROUNDS -> { if(player.getInventory().containsItem(new Item(338, 1))) {//trophy addNPC(NPC, HeadE.CALM_TALK, ""Okay folks, time's up! Let's see who caught the biggest fish!""); addPlayer(HeadE.HAPPY_TALKING, ""I caught some fish! Here...""); addSimple(""You show your catch""); addNPC(NPC, HeadE.CALM_TALK, ""We have a new winner! The heroic-looking person who was fishing y the pipes has caught the biggest carp "" + ""I've seen since Grandpa Jack used to compete!""); addItem(FISHING_TROPHY, ""You are given the Hemenester fishing trophy!"", ()->{ player.getInventory().removeItems(new Item(338, 1)); player.getInventory().addItem(FISHING_TROPHY, 1); player.getQuestManager().setStage(Quest.FISHING_CONTEST, GIVE_TROPHY); }); } else { addNPC(NPC, HeadE.CALM_TALK, ""So how are you doing so far?""); addSimple(""You look around...""); addPlayer(HeadE.SECRETIVE, ""I think I might be able to find bigger fish...""); } } case GIVE_TROPHY -> { if(player.getInventory().containsItem(new Item(FISHING_TROPHY, 1))) {//trophy addNPC(NPC, HeadE.CALM_TALK, ""Hello champ! So any hints on how to fish?""); addPlayer(HeadE.HAPPY_TALKING, ""I think I'll keep them to myself.""); } else { addNPC(NPC, HeadE.CALM_TALK, ""Hey you lost your trophy""); if(player.getInventory().hasFreeSlots()) addItem(FISHING_TROPHY, ""Bonzo gives you your trophy..."", ()-> player.getInventory().addItem(FISHING_TROPHY, 1)); else addSimple(""You need to make space for your trophy.""); } } case QUEST_COMPLETE -> { addNPC(NPC, HeadE.CALM_TALK, ""Hello champ! So any hints on how to fish?""); addPlayer(HeadE.HAPPY_TALKING, ""I think I'll keep them to myself.""); } } } public static NPCClickHandler handleDialogue = new NPCClickHandler(new Object[] { NPC }, e -> e.getPlayer().startConversation(new BonzoFishingContestD(e.getPlayer()).getStart())); }" "package com.rs.game.content.quests.fishingcontest; @PluginEventHandler public class DwarfBrothersFishingContestD extends Conversation { public DwarfBrothersFishingContestD(Player player, int NPC) { super(player); switch(player.getQuestManager().getStage(Quest.FISHING_CONTEST)) { case NOT_STARTED -> { addNPC(NPC, HeadE.CALM_TALK, ""Hmmmph. What do you want?""); addOptions(""Choose an option:"", new Options() { @Override public void create() { option("" I was wondering what was down that tunnel?"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, "" I was wondering what was down that tunnel?"") .addNPC(NPC, HeadE.CALM_TALK, ""You can't go down there!"") .addOptions(""Choose an option:"", new Options() { @Override public void create() { option(""I didn't want to anyway"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""I didn't want to anyway"") .addNPC(NPC, HeadE.CALM_TALK, ""Good. Because you can't."") .addPlayer(HeadE.HAPPY_TALKING, ""Because I don't want to."") .addNPC(NPC, HeadE.CALM_TALK, ""Because you can't. So that's fine."") .addPlayer(HeadE.HAPPY_TALKING, ""Yes, it is."") .addNPC(NPC, HeadE.CALM_TALK, ""Yes. Fine."") .addPlayer(HeadE.HAPPY_TALKING, ""Absolutely."") .addNPC(NPC, HeadE.CALM_TALK, ""Well then."") ); option(""Why not?"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Why not?"") .addNPC(NPC, HeadE.CALM_TALK, ""This is the home of the Mountain Dwarves. How would you like it if I wanted to "" + ""take a shortcut through your home?"") .addOptions(""Choose an option:"", new Options() { @Override public void create() { option(""Ooh... is this a short cut to somewhere?"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Ooh... is this a short cut to somewhere?"") .addNPC(NPC, HeadE.CALM_TALK, ""Well, it is a lot easier to go this way to get past White "" + ""Wolf Mountain than through those wolf filled passes."") ); option(""Oh, sorry, I hadn't realised it was private."", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Oh, sorry, I hadn't realised it was private."") .addNPC(NPC, HeadE.CALM_TALK, ""Well, it is."") ); if(player.getSkills().getLevel(Constants.FISHING) >= 10) option(""If you were my friend, I wouldn't mind it."", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""If you were my friend, I wouldn't mind it."") .addNPC(NPC, HeadE.CALM_TALK, ""Yes, but I don't even know you."") .addPlayer(HeadE.HAPPY_TALKING, ""Well, let's be friends!"") .addNPC(NPC, HeadE.CALM_TALK, ""I don't make friends easily. People need to earn my trust first."") .addOptions(""Start Fishing Contest?"", new Options() { @Override public void create() { option(""Yes"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""And how am I meant to do that?"") .addNPC(NPC, HeadE.CALM_TALK, ""My, we are the persistent one aren't we? Well,"" + "" there's a certain gold artefact we're after."") .addNPC(NPC, HeadE.CALM_TALK, ""We dwarves are big fans of gold! This artefact "" + ""is the first prize at the Hemenster fishing competition."") .addNPC(NPC, HeadE.CALM_TALK, ""Fortunately we have acquired a pass to enter "" + ""that competition... Unfortunately Dwarves don't make good fishermen."") .addNPC(NPC, HeadE.CALM_TALK, ""Okay, I entrust you with our competition pass."" + "" Don't forget to take some gold with you for the entrance fee."") .addSimple(""You got the Fishing Contest Pass!"", ()-> { player.getQuestManager().setStage(Quest.FISHING_CONTEST, ENTER_COMPETITION); player.getInventory().addItem(FISHING_PASS, 1); }) .addNPC(NPC, HeadE.CALM_TALK, ""Go to Hemenster and do us proud!"") ); option(""No"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""You're a grumpy little man aren't you?"") .addNPC(NPC, HeadE.CALM_TALK, ""Don't you know it."") ); } }) ); else option(""If you were my friend I wouldn't mind it."", new Dialogue() .addSimple(""You need 10 fishing to start Fishing Contest"")); } }) ); option(""I'm bigger than you. Let me by!"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""I'm bigger than you. Let me by!"") .addNPC(NPC, HeadE.CALM_TALK, ""Go away! You're not going to bully your way in HERE!"") ); } }) ); option("" I was just stopping to say hello!"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, "" I was just stopping to say hello!"") .addNPC(NPC, HeadE.CALM_TALK, ""Hello then."") ); option(""Do you have a brother?"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Do you have a brother?"") .addNPC(NPC, HeadE.CALM_TALK, ""What if I do! It's no business of yours."") ); } }); } case ENTER_COMPETITION, DO_ROUNDS -> { if(player.getInventory().containsItem(FISHING_PASS, 1)) { addNPC(NPC, HeadE.CALM_TALK, ""Have you won yet?""); addPlayer(HeadE.HAPPY_TALKING, ""No, it takes preparation to win fishing competitions.""); addNPC(NPC, HeadE.CALM_TALK, ""Maybe that's where we are going wrong when we try fishing?""); addPlayer(HeadE.HAPPY_TALKING, ""Probably.""); addNPC(NPC, HeadE.CALM_TALK, ""Maybe we should talk to that old Jack fella near the competition, everyone seemed to be ranting about him.""); } else { addPlayer(HeadE.HAPPY_TALKING, ""I need another competition pass.""); if(player.getInventory().hasFreeSlots()) addNPC(NPC, HeadE.CALM_TALK, ""Hmm. It's a good job they sent us spares. There you go. Try not to lose that one."", ()-> player.getInventory().addItem(FISHING_PASS, 1)); else addNPC(NPC, HeadE.CALM_TALK, ""You'll need a free inventory slot before I can give you another.""); } } case GIVE_TROPHY -> { if(player.getInventory().containsItem(FISHING_TROPHY, 1)) { addNPC(NPC, HeadE.CALM_TALK, ""Have you won yet?""); addPlayer(HeadE.HAPPY_TALKING, ""Yes I have!""); addNPC(NPC, HeadE.CALM_TALK, ""Well done! That's brilliant! Do you have the trophy with you?""); addPlayer(HeadE.HAPPY_TALKING, ""Yep, I have it right here!""); addNPC(NPC, HeadE.CALM_TALK, ""Oh! It's even more shiny and gold than I thought possible...""); addNPC(NPC, HeadE.CALM_TALK, ""You've done us proud. Thank you "" + player.genderTerm(""lad"", ""lass"") + "", I think we can now trust you enough to let you in...""); addPlayer(HeadE.HAPPY_TALKING, ""In where?""); addNPC(NPC, HeadE.CALM_TALK, ""Why, the tunnel of course! You may now come and go freely, avoiding the wolves and dangers of the cold, high mountain. You could even stop in for a beer or two!""); addPlayer(HeadE.HAPPY_TALKING, ""Excellent. That will come in most handy.""); addNext(()->{ player.getInventory().removeItems(new Item(FISHING_TROPHY, 1)); player.getQuestManager().completeQuest(Quest.FISHING_CONTEST); }); } else { addNPC(NPC, HeadE.CALM_TALK, ""Have you won yet?""); addPlayer(HeadE.HAPPY_TALKING, ""Yes I have!""); addNPC(NPC, HeadE.CALM_TALK, ""Well done! That's brilliant! Do you have the trophy with you?""); addPlayer(HeadE.SAD, ""No...""); addNPC(NPC, HeadE.CALM_TALK, ""What? Go get it!""); addPlayer(HeadE.HAPPY_TALKING, ""I need to talk to Bonzo back at the competition site.""); } } case QUEST_COMPLETE -> { addNPC(NPC, HeadE.CALM_TALK, ""Welcome, oh great Fishing Champion! Feel free to pop by and use our tunnel any time.""); addPlayer(HeadE.HAPPY_TALKING, ""Thank you, I think I'll stop by.""); } } } }" "package com.rs.game.content.quests.fishingcontest; @QuestHandler( quest = Quest.FISHING_CONTEST, startText = ""Talk to Vestri or Austri, near the White Wolf Mountain."", itemsText = ""5 coins, garlic."", combatText = ""None."", rewardsText = ""2,437 Fishing XP
Access to the White Wolf Mountain shortcut"", completedStage = 4 ) @PluginEventHandler public class FishingContest extends QuestOutline { public final static int NOT_STARTED = 0; public final static int ENTER_COMPETITION = 1; public final static int DO_ROUNDS = 2; public final static int GIVE_TROPHY = 3; public final static int QUEST_COMPLETE = 4; public static final int FISHING_PASS = 27; public static final String PIPE_HAS_GARLIC = ""HAS_GARLIC""; @Override public List getJournalLines(Player player, int stage) { ArrayList lines = new ArrayList<>(); switch(stage) { case NOT_STARTED: lines.add(""The mountain dwarves' home would be an ideal way to get""); lines.add(""across White Wolf mountain safely.""); lines.add(""""); lines.add(""However, the Dwarves aren't too fond of strangers. Austri""); lines.add(""and Vestri will let you through the tunnel under the""); lines.add(""mountain, however, if you can bring them a trophy. The""); lines.add(""trophy is the prize for the annual Hemenster Fishing""); lines.add(""competition.""); lines.add(""""); lines.add(""~~Requirements~~""); lines.add(""10 fishing""); lines.add(""""); break; case ENTER_COMPETITION: lines.add(""I can take my fishing contest pass to a small contest""); lines.add(""platform northeast of the fishing guild. There I can""); lines.add(""Show my pass and enter. If I need another pass I can""); lines.add(""get it from the Dwarven borthers in Catherby and""); lines.add(""Taverley.""); lines.add(""""); break; case DO_ROUNDS: lines.add(""The contest has started but it appears I need to find""); lines.add(""a way to get the biggest fish. Perhaps Grandpa Jack""); lines.add(""can help.""); lines.add(""""); break; case GIVE_TROPHY: lines.add(""Now that I have the trophy I can give it to the""); lines.add(""Dwarven brothers...""); lines.add(""""); break; case QUEST_COMPLETE: lines.add(""""); lines.add(""""); lines.add(""QUEST COMPLETE!""); break; default: lines.add(""Invalid quest stage. Report this to an administrator.""); break; } return lines; } public static final int RED_WORM = 25; public static ObjectClickHandler Redvine = new ObjectClickHandler(true, new Object[] { ""Vine"" }, e -> { Player p = e.getPlayer(); GameObject obj = e.getObject(); if(obj.getTile().getRegionId() == 10550) //mcgrubbers wood if(p.getInventory().hasFreeSlots()) { p.setNextAnimation(new Animation(2282));//herb picking anim p.getInventory().addItem(RED_WORM, 1); p.sendMessage(""You get a worm from the vine...""); } }); public static NPCClickHandler handlePlayerFishingSpot = new NPCClickHandler(new Object[] { 233 }, e -> { Player p = e.getPlayer(); NPC npc = e.getNPC(); if(npc.getRegionId() == 10549) { if (p.getQuestManager().getStage(Quest.FISHING_CONTEST) >= GIVE_TROPHY) { p.sendMessage(""Nothing interesting happens...""); return; } e.getNPC().resetDirection(); if(p.getQuestManager().getAttribs(Quest.FISHING_CONTEST).getB(PIPE_HAS_GARLIC)) p.startConversation(new Conversation(p) { {//Sinister stranger addNPC(3677, HeadE.CALM_TALK, ""I think you will find that is my spot.""); addPlayer(HeadE.HAPPY_TALKING, ""Can't you go to another spot?""); addNPC(3677, HeadE.CALM_TALK, ""I can't stand the smell of those pipes...""); create(); } }); else if(p.getQuestManager().getStage(Quest.FISHING_CONTEST) > ENTER_COMPETITION) e.getPlayer().getActionManager().setAction(new Fishing(FishingSpot.SEA_BAIT, e.getNPC())); else p.startConversation(new Conversation(p) { { addNPC(225, HeadE.CALM_TALK, ""Hey, you need to pay to enter the competition first! Only 5 coins for the entrance fee!"");//Bonzo create(); } }); } }); /** * There is a clipflag on the garlic pipe and requires a distance or clip handling function. */ public static ItemOnObjectHandler handlePipeGarlic = new ItemOnObjectHandler(false, new Object[] { 41 }, new Object[] { 1550 }, e -> { Player p = e.getPlayer(); int stage = p.getQuestManager().getStage(Quest.FISHING_CONTEST); p.walkToAndExecute(Tile.of(2638, 3445, 0), () -> { if (stage == ENTER_COMPETITION || stage == DO_ROUNDS) if (p.getQuestManager().getAttribs(Quest.FISHING_CONTEST).getB(PIPE_HAS_GARLIC)) { p.sendMessage(""There is already garlic...""); return; } p.getInventory().removeItems(new Item(1550, 1)); p.getQuestManager().getAttribs(Quest.FISHING_CONTEST).setB(PIPE_HAS_GARLIC, true); p.sendMessage(""You place the garlic in the pipe.""); p.lock(8); WorldTasks.scheduleLooping(new Task() { int tick; NPC stranger; @Override public void run() { if (tick == 0) for (NPC npc : World.getNPCsInChunkRange(p.getChunkId(), 2)) if (npc.getId() == 3677)//vampyre stranger stranger = npc; if (tick == 1) { if (stranger == null) stop(); stranger.forceTalk(""What is that ghastly smell?""); } if (tick == 2) { p.startConversation(new Conversation(p) { { addNPC(3677, HeadE.FRUSTRATED, ""Can I take the spot by the willow tree?""); addPlayer(HeadE.HAPPY_TALKING, ""Sure...""); addNext(p::unlock); create(); } }); stop(); } tick++; } }, 0, 1); }); }); public static final int FISHING_TROPHY = 26; @Override public void complete(Player player) { player.getSkills().addXpQuest(Constants.FISHING, 2437); sendQuestCompleteInterface(player, FISHING_TROPHY); } }" "package com.rs.game.content.quests.fishingcontest; @PluginEventHandler public class GrandpaJackFishingContestD extends Conversation { private static final int NPC = 230; public GrandpaJackFishingContestD(Player player) { super(player); switch(player.getQuestManager().getStage(Quest.FISHING_CONTEST)) { case ENTER_COMPETITION, DO_ROUNDS -> { addNPC(NPC, HeadE.CALM_TALK, ""Hello young ""+ player.getPronoun(""man"", ""lady"") + ""! Come to visit old Grandpa Jack? I can tell ye stories for sure. I used to be the "" + ""best fisherman these parts have seen!""); addOptions(""Choose an option:"", new Options() { @Override public void create() { option(""Tell me a story then"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Tell me a story then"") .addNPC(NPC, HeadE.CALM_TALK, ""Well, when I were a young man we used to take fishing trips over to Catherby: The fishing over "" + ""there -"") .addNPC(NPC, HeadE.CALM_TALK, ""now that was something! Anyway, we decided to do a bit of fishing with our nets, I wasn't having "" + ""the best of days turning up nothing but old boots and bits of seaweed. Then my net suddenly got really heavy! I pulled it up..."") .addNPC(NPC, HeadE.CALM_TALK, ""To my amazement I'd caught this little chest thing! Even more amazing was when I opened it, "" + ""it contained a diamond the size of a radish! That's the best catch I've ever had!"") ); option(""What rod can I use for the competition?"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""What rod can I use for the competition?"") .addNPC(NPC, HeadE.CALM_TALK, ""Why, any old 'fishing rod' would do..."") ); option(""Are you entering the fishing competition?"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Are you entering the fishing competition?"") .addNPC(NPC, HeadE.CALM_TALK, ""Ah... the Hemenster fishing competition... I know all about that... I won that four years "" + ""straight! I'm too old for that lark now though..."") .addOptions(""Choose an option:"", new Options() { @Override public void create() { option("" I don't suppose you could give me any hints?"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, "" I don't suppose you could give me any hints?"") .addNPC(NPC, HeadE.CALM_TALK, ""Well, you sometimes get these really big fish in the water just by the outflow "" + ""pipes. I think they're some kind of carp..."") .addNPC(NPC, HeadE.CALM_TALK, ""Try to get a spot round there. The best sort of bait for them is red vine worms. "" + ""I used to get those from McGrubor's wood, north of here. Just dig around in the red vines up there but be careful of the guard dogs."") .addPlayer(HeadE.HAPPY_TALKING, ""There's this weird creepy guy who says he's not a vampyre using that spot."" + "" He keeps winning too."") .addNPC(NPC, HeadE.CALM_TALK, ""Ahh well, I'm sure you'll find something to put him off. Afer all, there "" + ""must be a kitchen around here with some garlic in it, perhaps in Seers Village or Ardougne."") .addNPC(NPC, HeadE.CALM_TALK, ""If he's pretending to be a vampyre then he can pretend to be scared of garlic!"") .addPlayer(HeadE.HAPPY_TALKING, ""You're right! Thanks Jack!"") ); option(""That's less competition for me then."", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""That's less competition for me then."") .addNPC(NPC, HeadE.CALM_TALK, ""Why you young whippersnapper! If I was twenty years younger I'd show you"" + "" something that's for sure!"") ); } }) ); option(""Sorry, I don't have time now."", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Sorry, I don't have time now."") ); } }); } default -> { addNPC(NPC, HeadE.CALM_TALK, ""Hello young ""+ player.getPronoun(""man"", ""lady"") + ""! Come to visit old Grandpa Jack? I can tell ye stories for sure. I used to be the "" + ""best fisherman these parts have seen!""); addOptions(""Choose an option:"", new Options() { @Override public void create() { option(""Tell me a story then"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Tell me a story then"") .addNPC(NPC, HeadE.CALM_TALK, ""Well, when I were a young man we used to take fishing trips over to Catherby: The fishing over "" + ""there -"") .addNPC(NPC, HeadE.CALM_TALK, ""now that was something! Anyway, we decided to do a bit of fishing with our nets, I wasn't having "" + ""the best of days turning up nothing but old boots and bits of seaweed. Then my net suddenly got really heavy! I pulled it up..."") .addNPC(NPC, HeadE.CALM_TALK, ""To my amazement I'd caught this little chest thing! Even more amazing was when I opened it, "" + ""it contained a diamond the size of a radish! That's the best catch I've ever had!"") ); option(""Sorry, I don't have time now."", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Sorry, I don't have time now."") ); } }); } } } public static NPCClickHandler handleialogue = new NPCClickHandler(new Object[] { NPC }, e -> e.getPlayer().startConversation(new GrandpaJackFishingContestD(e.getPlayer()).getStart())); }" "package com.rs.game.content.quests.fishingcontest; @PluginEventHandler public class JoshuaFishingContestD extends Conversation { private static final int NPC = 229; public JoshuaFishingContestD(Player player) { super(player); switch(player.getQuestManager().getStage(Quest.FISHING_CONTEST)) { case NOT_STARTED, ENTER_COMPETITION -> { addPlayer(HeadE.HAPPY_TALKING, ""Hi, what are you doing here?""); addNPC(NPC, HeadE.CALM_TALK, ""I am waiting for the fishing contest to start.""); addPlayer(HeadE.HAPPY_TALKING, ""Oh.""); } case DO_ROUNDS -> { addNPC(NPC, HeadE.CALM_TALK, ""Yeah? What you want?""); addOptions(""Choose an option:"", new Options() { @Override public void create() { option(""Um... nothing really.."", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Um... nothing really.."") .addNPC(NPC, HeadE.CALM_TALK, ""Quit bugging me then, ""+ player.getPronoun(""dude"", ""doll"") + ""! I got me some fish to "" + ""catch!"") ); option(""Can I fish here instead of you?"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Can I fish here instead of you?"") .addNPC(NPC, HeadE.CALM_TALK, ""Nuh uh dude. Less talk, more fishing!"") ); option(""Do you have any tips for me?"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Do you have any tips for me?"") .addNPC(NPC, HeadE.CALM_TALK, ""Who's Grampa Jack "" + player.getPronoun(""he"", ""she"") + "" says! He won this "" + ""competition four years in a row! He lives "" + ""in the house just outside the gate."") ); } }); } case GIVE_TROPHY, QUEST_COMPLETE -> { addNPC(NPC, HeadE.CALM_TALK, ""Congratulations on the win "" + player.getPronoun(""dude"", ""lady"") + ""!""); addPlayer(HeadE.HAPPY_TALKING, ""Thanks!""); } } } public static NPCClickHandler handleDialogue = new NPCClickHandler(new Object[] { NPC }, e -> e.getPlayer().startConversation(new JoshuaFishingContestD(e.getPlayer()).getStart())); public static NPCClickHandler handleJoshuaSpot = new NPCClickHandler(true, new Object[] { 236 }, e -> { NPC npc = e.getNPC(); if(npc.getRegionId() == 10549) { e.getNPC().resetDirection(); if (e.getPlayer().getQuestManager().getStage(Quest.FISHING_CONTEST) >= GIVE_TROPHY) { e.getPlayer().sendMessage(""Nothing interesting happens...""); return; } e.getPlayer().startConversation(new Conversation(e.getPlayer()) { { addNPC(NPC, HeadE.CALM_TALK, ""Hey dude! This is my spot!""); addPlayer(HeadE.HAPPY_TALKING, ""Um... can I fish here then please?""); addNPC(NPC, HeadE.CALM_TALK, ""No way ""+ e.getPlayer().getPronoun(""man"", ""lady"") + "", I got a good feeling about this spot!""); create(); } }); } }); }" "package com.rs.game.content.quests.fishingcontest; @PluginEventHandler public class MorrisFishingContestD extends Conversation { private static final int NPC = 227; public MorrisFishingContestD(Player player) { super(player); } public static NPCClickHandler handleAustriDialogue = new NPCClickHandler(new Object[] { NPC }, e -> e.getPlayer().startConversation(new MorrisFishingContestD(e.getPlayer()).getStart())); public static ObjectClickHandler handleFishingContestGate = new ObjectClickHandler(true, new Object[] { 47, 48 }, e -> { GameObject obj = e.getObject(); if(e.getPlayer().getQuestManager().getStage(Quest.FISHING_CONTEST) == NOT_STARTED) { e.getPlayer().sendMessage(""You have no reason to enter...""); return; } if(e.getPlayer().getQuestManager().getAttribs(Quest.FISHING_CONTEST).getB(""MORRIS_SAW_TICKET"")) handleGate(e.getPlayer(), obj); else e.getPlayer().startConversation(new Conversation(e.getPlayer()) { { addNPC(NPC, HeadE.CALM_TALK, ""Competition pass please.""); if(e.getPlayer().getInventory().containsItem(FISHING_PASS, 1)) { addItem(FISHING_PASS, ""You show Morris your pass""); addNPC(NPC, HeadE.CALM_TALK, ""Move on through. Talk to Bonzo to enter the competition"", ()-> e.getPlayer().getQuestManager().getAttribs(Quest.FISHING_CONTEST).setB(""MORRIS_SAW_TICKET"", true)); addNext(()-> handleGate(e.getPlayer(), obj)); } else { addPlayer(HeadE.SAD, ""I don't have one...""); addNPC(NPC, HeadE.CALM_TALK, ""...""); } create(); } }); }); }" "package com.rs.game.content.quests.fishingcontest; @PluginEventHandler public class StrangerFishingContestD extends Conversation { private static final int NPC = 3677; public StrangerFishingContestD(Player player) { super(player); switch(player.getQuestManager().getStage(Quest.FISHING_CONTEST)) { case NOT_STARTED -> { addPlayer(HeadE.HAPPY_TALKING, ""Hi, what are you doing here?""); addNPC(NPC, HeadE.CALM_TALK, ""I am waiting for the fishing contest to start.""); addPlayer(HeadE.HAPPY_TALKING, ""Oh.""); } case ENTER_COMPETITION, DO_ROUNDS -> { addNPC(NPC, HeadE.CALM_TALK, ""...""); addOptions(""Choose an option:"", new Options() { @Override public void create() { option(""...?"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""...?"") .addNPC(NPC, HeadE.CALM_TALK, ""..."") .addPlayer(HeadE.HAPPY_TALKING, "".....?"") .addNPC(NPC, HeadE.CALM_TALK, ""....."") ); option(""Who are you?"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Who are you?"") .addNPC(NPC, HeadE.CALM_TALK, ""My name is Vlad. I come from far avay, vere the sun iz not so bright."") .addOptions(""Choose an option:"", new Options() { @Override public void create() { option(""You're a vampyre aren't you?"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""You're a vampyre aren't you?"") .addNPC(NPC, HeadE.CALM_TALK, ""Just because I can't stand ze smell ov garlic und I don't like bright "" + ""sunlight doesn't necessarily mean I'm ein vampyre!"") ); option("" So... you like fishing?"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, "" So... you like fishing?"") .addNPC(NPC, HeadE.CALM_TALK, ""My doctor told me to take up ein velaxing hobby. Vhen I am stressed I tend "" + ""to get ein little... thirsty."") ); option(""Well, good luck with the fishing"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Well, good luck with the fishing"") .addNPC(NPC, HeadE.CALM_TALK, ""Luck haz notsing to do vith it. It is all in ze technique."") ); } }) ); } }); } case GIVE_TROPHY, QUEST_COMPLETE -> { addNPC(NPC, HeadE.CALM_TALK, ""Congratulations, that competition made me thirsty...""); addPlayer(HeadE.CALM_TALK, ""...""); } } } public static NPCClickHandler handleDialogue = new NPCClickHandler(new Object[] { NPC }, e -> e.getPlayer().startConversation(new StrangerFishingContestD(e.getPlayer()).getStart())); public static NPCClickHandler handleStrangerFishingSpot = new NPCClickHandler(new Object[] { 234 }, e -> { NPC npc = e.getNPC(); if(npc.getRegionId() == 10549) { if (e.getPlayer().getQuestManager().getStage(Quest.FISHING_CONTEST) >= GIVE_TROPHY) { e.getPlayer().sendMessage(""Nothing interesting happens...""); return; } e.getNPC().resetDirection(); if(e.getPlayer().getQuestManager().getStage(Quest.FISHING_CONTEST) == DO_ROUNDS && e.getPlayer().getQuestManager().getAttribs(Quest.FISHING_CONTEST).getB(PIPE_HAS_GARLIC)) e.getPlayer().getActionManager().setAction(new Fishing(FishingSpot.GIANT_CARP, e.getNPC())); else if(e.getPlayer().getQuestManager().getAttribs(Quest.FISHING_CONTEST).getB(PIPE_HAS_GARLIC)) e.getPlayer().startConversation(new Conversation(e.getPlayer()) { { addNPC(225, HeadE.CALM_TALK, ""Hey, you need to pay to enter the competition first! Only 5 coins for the entrance fee!"");//Bonzo create(); } }); else e.getPlayer().startConversation(new Conversation(e.getPlayer()) { { addNPC(NPC, HeadE.CALM_TALK, ""I think you will find that is my spot.""); addPlayer(HeadE.HAPPY_TALKING, ""Can't you go to another spot?""); addNPC(NPC, HeadE.CALM_TALK, ""I like this place. I like to savour the aroma coming from these pipes.""); create(); } }); } }); }" "package com.rs.game.content.quests.goblindiplomacy; @QuestHandler( quest = Quest.GOBLIN_DIPLOMACY, startText = ""Go to Goblin Village and talk to General Bentnoze or General Wartface."", itemsText = ""Blue dye (or 2 woad leaves and 5 coins), red dye (or 3 redberries and 5 coins), and yellow dye (or 2 onions and 5 coins)."", combatText = ""None."", rewardsText = ""200 Crafting XP
A gold bar"", completedStage = 4 ) @PluginEventHandler public class GoblinDiplomacy extends QuestOutline { static final int WARTFACE = 4494; static final int BENTNOZE = 4493; static final int ORANGE_GOBLIN_MAIL = 286; static final int BLUE_GOBLIN_MAIL = 287; static final int GOBLIN_MAIL = 288; static final int RED_DYE = 1763; static final int YELLOW_DYE = 1765; static final int BLUE_DYE = 1767; static final int ORANGE_DYE = 1769; @Override public List getJournalLines(Player player, int stage) { ArrayList lines = new ArrayList<>(); switch (stage) { case 0: lines.add(""I can start this quest by speaking to General Bentnoze or""); lines.add(""General Wartface in the Goblin Village north of Falador.""); break; case 1: lines.add(""""); lines.add(""The Goblin generals need orange armor""); lines.add(""I can make orange armor by taking orange dye and using""); lines.add(""it on regular goblin mail.""); lines.add(""""); lines.add(""I can make orange dye by mixing red and yellow dye""); lines.add(""""); lines.add(""I can find goblin mail behind the generals hut""); lines.add(""""); lines.add(""Red dye is made from 3 red berries""); lines.add(""I could pay Aggie 5 coins in Draynor village for it""); lines.add(""""); lines.add(""I can find red berries by Varrock's south east mine""); lines.add(""""); lines.add(""Yellow dye can be made from 2 onions""); lines.add(""I could pay Aggie 5 coins in Draynor village for it""); lines.add(""""); break; case 2: lines.add(""""); lines.add(""The Goblin generals need blue armor""); lines.add(""I can make blue armor by taking blue dye and using""); lines.add(""it on regular goblin mail.""); lines.add(""""); lines.add(""Blue dye can be made from 2 woad leaves""); lines.add(""I could pay Aggie 5 coins in Draynor village for it""); lines.add(""""); lines.add(""I can grow woad leaves from woad seeds or buy them""); lines.add(""from Wyson the gardner in Falador park""); break; case 3: lines.add(""""); lines.add(""The Goblin generals need brown armor...""); lines.add(""That is just regular goblin mail...""); lines.add(""""); break; case 4: lines.add(""""); lines.add(""""); lines.add(""QUEST COMPLETE!""); break; default: lines.add(""Invalid quest stage. Report this to an administrator.""); break; } return lines; } @Override public void complete(Player player) { player.getSkills().addXpQuest(Skills.CRAFTING, 200); sendQuestCompleteInterface(player, 288); } static class GeneralsD extends Conversation { public GeneralsD(Player player, int npcId) { super(player); Options startOptions = new Options() { @Override public void create() { option(""Why are you arguing about the color of your armor?"", new Dialogue().addPlayer(HeadE.CALM_TALK, ""Why are you arguing about the color of your armor?"").addNPC(WARTFACE, HeadE.CHILD_CALM_TALK, ""We decide to celebrate goblin new century"").addNPC(WARTFACE, HeadE.CHILD_CALM_TALK, ""By changing the color of our armor"").addNPC(WARTFACE, HeadE.CHILD_CALM_TALK, ""Light blue get boring after a bit"").addNPC(WARTFACE, HeadE.CHILD_CALM_TALK, ""And we want change"").addNPC(WARTFACE, HeadE.CHILD_CALM_TALK, ""Problem is they want different changed to us"")); option(""Wouldn't you prefer peace?"", new Dialogue().addPlayer(HeadE.CALM_TALK, ""Wouldn't you prefer peace?"").addNPC(WARTFACE, HeadE.CHILD_CALM_TALK, ""Yeah peace is good as long as it's peace wearing green armor"").addNPC(BENTNOZE, HeadE.CHILD_CALM_TALK, ""But green too much like skin!"").addNPC(BENTNOZE, HeadE.CHILD_CALM_TALK, ""Nearly make you look naked!"")); option(""Do you want me to pick enter an armor color for you?"", new Dialogue().addPlayer(HeadE.CALM_TALK, ""Do you want me to pick an armor color for you?"").addPlayer(HeadE.CALM_TALK, ""Different to either green or red"").addNPC(WARTFACE, HeadE.CHILD_CALM_TALK, ""Hmm me dunno what that'd look like"").addNPC(WARTFACE, HeadE.CHILD_CALM_TALK, ""You'd have to bring me some, so us could decide"").addNPC(BENTNOZE, HeadE.CHILD_CALM_TALK, ""Yep bring us orange armor"").addNPC(WARTFACE, HeadE.CHILD_CALM_TALK, ""Yep orange might be good"", () -> player.getQuestManager().setStage(Quest.GOBLIN_DIPLOMACY, 1))); } }; if (player.getQuestManager().getStage(Quest.GOBLIN_DIPLOMACY) == 0) { addNPC(WARTFACE, HeadE.CHILD_CALM_TALK, ""Green armor best""); addNPC(BENTNOZE, HeadE.CHILD_CALM_TALK, ""No no red every time""); addNPC(WARTFACE, HeadE.CHILD_ANGRY, ""Go away human, we busy""); addOptions(startOptions); } if (player.getQuestManager().getStage(Quest.GOBLIN_DIPLOMACY) == 1) { addNPC(WARTFACE, HeadE.CHILD_CALM_TALK, ""Green armor best""); addNPC(BENTNOZE, HeadE.CHILD_ANGRY, ""No no red every time""); addNPC(WARTFACE, HeadE.CHILD_ANGRY, ""Go away human,we busy""); addNPC(WARTFACE, HeadE.CHILD_CALM_TALK, ""Oh it you""); if (player.getInventory().containsItems(new Item(286, 1))) { addPlayer(HeadE.CALM_TALK, ""I have some orange armor""); addSimple(""You give the armor to the goblins""); addNPC(WARTFACE, HeadE.CHILD_CALM_TALK, ""No I don't like that much""); addNPC(BENTNOZE, HeadE.CHILD_CALM_TALK, ""It clashes with my skin color""); addNPC(WARTFACE, HeadE.CHILD_CALM_TALK, ""Try bringing us blue armor"", () -> { player.getInventory().deleteItem(new Item(286, 1)); player.getQuestManager().setStage(Quest.GOBLIN_DIPLOMACY, 2); }); } else { addNPC(WARTFACE, HeadE.CHILD_CALM_TALK, ""Have you got some orange goblin armor yet?""); addPlayer(HeadE.CALM_TALK, ""Err no""); addNPC(WARTFACE, HeadE.CHILD_CALM_TALK, ""Come back when you have some""); } } if (player.getQuestManager().getStage(Quest.GOBLIN_DIPLOMACY) == 2) { addNPC(WARTFACE, HeadE.CHILD_CALM_TALK, ""Green armor best""); addNPC(BENTNOZE, HeadE.CHILD_ANGRY, ""No no red every time""); addNPC(WARTFACE, HeadE.CHILD_ANGRY, ""Go away human,we busy""); addNPC(WARTFACE, HeadE.CHILD_CALM_TALK, ""Oh it you""); if (player.getInventory().containsItems(new Item(287, 1))) { addPlayer(HeadE.CALM_TALK, ""I have some blue armor""); addSimple(""You give the armor to the goblins""); addNPC(WARTFACE, HeadE.CHILD_CALM_TALK, ""No I don't like that much""); addNPC(BENTNOZE, HeadE.CHILD_CALM_TALK, ""It clashes with my skin color""); addNPC(WARTFACE, HeadE.CHILD_CALM_TALK, ""Try bringing us brown armor"", () -> { player.getInventory().deleteItem(new Item(287, 1)); player.getQuestManager().setStage(Quest.GOBLIN_DIPLOMACY, 3); }); } else { addNPC(WARTFACE, HeadE.CHILD_CALM_TALK, ""Have you got some blue goblin armor yet?""); addPlayer(HeadE.CALM_TALK, ""Err no""); addNPC(WARTFACE, HeadE.CHILD_CALM_TALK, ""Come back when you have some""); } } if (player.getQuestManager().getStage(Quest.GOBLIN_DIPLOMACY) == 3) { addNPC(WARTFACE, HeadE.CHILD_CALM_TALK, ""Green armor best""); addNPC(BENTNOZE, HeadE.CHILD_ANGRY, ""No no red every time""); addNPC(WARTFACE, HeadE.CHILD_ANGRY, ""Go away human,we busy""); addNPC(WARTFACE, HeadE.CHILD_CALM_TALK, ""Oh it you""); if (player.getInventory().containsItems(new Item(288, 1))) { addPlayer(HeadE.CALM_TALK, ""I have some brown armor""); addSimple(""You give the armor to the goblins""); addNPC(WARTFACE, HeadE.CHILD_CALM_TALK, ""That color quiet nice. Me can see myself wearing this""); addNPC(BENTNOZE, HeadE.CHILD_CALM_TALK, ""It a deal then. Brown armor it is""); addNPC(WARTFACE, HeadE.CHILD_CALM_TALK, ""Thank you for sorting out our argument. Take this gold bar as reward!""); addNext(() -> { player.getInventory().deleteItem(new Item(288, 1)); player.getInventory().addItem(new Item(2357, 1), true); player.getQuestManager().completeQuest(Quest.GOBLIN_DIPLOMACY); }); } else { addPlayer(HeadE.CALM_TALK, ""Err no""); addNPC(WARTFACE, HeadE.CHILD_ANGRY, ""Come back when you have some""); } } if (player.getQuestManager().getStage(Quest.GOBLIN_DIPLOMACY) == 4) { addNPC(WARTFACE, HeadE.CHILD_CALM_TALK, ""Now you've solved our argument we gotta think of something else to do""); addNPC(BENTNOZE, HeadE.CHILD_CALM_TALK, ""Yep, we bored now""); } create(); } } public static NPCClickHandler talkGoblinGenerals = new NPCClickHandler(new Object[] { 4494, 4493 }, e -> e.getPlayer().startConversation(new GeneralsD(e.getPlayer(), e.getNPC().getId()))); public static ObjectClickHandler handleGoblinVillageLadder = new ObjectClickHandler(new Object[] { 16450, 16556 }, e -> { if (e.getObjectId() == 16450 && e.getPlayer().getPlane() == 0) e.getPlayer().ladder(Tile.of(2953, 3497, 2)); if (e.getObjectId() == 16556 && e.getPlayer().getPlane() == 2) e.getPlayer().ladder(Tile.of(2953, 3497, 0)); }); public static ObjectClickHandler handleGoblinMailChests = new ObjectClickHandler(new Object[] { 16559, 16560, 16561 }, e -> { if(!e.getPlayer().getQuestManager().getAttribs(Quest.GOBLIN_DIPLOMACY).getB(""isGoblinMateCrateBlocked"")) { e.getPlayer().getQuestManager().getAttribs(Quest.GOBLIN_DIPLOMACY).setB(""isGoblinMateCrateBlocked"", true); e.getPlayer().getInventory().addItem(288, 1); e.getPlayer().startConversation(new Dialogue().addItem(288, ""You find goblin mail."")); return; } e.getPlayer().sendMessage(""You search the crate but find nothing.""); }); public static ItemOnItemHandler handleColorGoblinMail = new ItemOnItemHandler(GOBLIN_MAIL, new int[] { ORANGE_DYE, BLUE_DYE }, e -> { if (e.usedWith(ORANGE_DYE, GOBLIN_MAIL)) { e.getPlayer().getInventory().replace(e.getUsedWith(ORANGE_DYE), new Item(ORANGE_GOBLIN_MAIL, 1)); e.getPlayer().getInventory().deleteItem(ORANGE_DYE, 1); } if (e.usedWith(BLUE_DYE, GOBLIN_MAIL)) { e.getPlayer().getInventory().replace(e.getUsedWith(BLUE_DYE), new Item(BLUE_GOBLIN_MAIL, 1)); e.getPlayer().getInventory().deleteItem(BLUE_DYE, 1); } }); public static ItemOnItemHandler handleRedYellowDyes = new ItemOnItemHandler(RED_DYE, new int[] { YELLOW_DYE }, e -> { if (e.usedWith(RED_DYE, YELLOW_DYE)) { e.getPlayer().getInventory().replace(e.getItem2(), new Item(ORANGE_DYE, 1)); e.getPlayer().getInventory().deleteItem(e.getItem1().getSlot(), e.getItem1()); } }); }" "package com.rs.game.content.quests.heroesquest; @PluginEventHandler public class BrimhavenHeroesQuest { public static ObjectClickHandler handleMansionDoor = new ObjectClickHandler(new Object[]{2627}, e -> { if (e.getPlayer().getY() > e.getObject().getY()) handleDoor(e.getPlayer(), e.getObject()); else e.getPlayer().startConversation(new MansionDoorHeroesQuestD(e.getPlayer(), e)); }); public static NPCClickHandler garvTalk = new NPCClickHandler(new Object[] { 788 }, e -> { if (e.getOption().equalsIgnoreCase(""talk-to"")) e.getPlayer().startConversation(new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Hello."") .addNPC(788, HeadE.FRUSTRATED, ""What yer doing 'round here!? Leave, before I really get angry."") ); }); public static ObjectClickHandler handleCandleStickChest = new ObjectClickHandler(new Object[]{37044}, e -> { if (e.getOption().equalsIgnoreCase(""Search"")) if (e.getPlayer().getQuestManager().getStage(Quest.HEROES_QUEST) == HeroesQuest.GET_ITEMS) if (e.getPlayer().getInventory().containsItem(1577, 1)) e.getPlayer().startConversation(new Dialogue().addPlayer(HeadE.SECRETIVE, ""It's empty..."")); else e.getPlayer().getInventory().addItem(1577, 1); }); public static ObjectClickHandler handleBlackArmHideoutDoor = new ObjectClickHandler(new Object[]{2626}, e -> { if (e.getPlayer().getX() >= e.getObject().getX()) { handleDoor(e.getPlayer(), e.getObject()); return; } if (e.getPlayer().isQuestComplete(Quest.HEROES_QUEST) || e.getPlayer().getQuestManager().getAttribs(Quest.HEROES_QUEST).getB(""black_arm_hideout_open"")) { handleDoor(e.getPlayer(), e.getObject()); return; } if (e.getPlayer().getQuestManager().getStage(Quest.HEROES_QUEST) == HeroesQuest.GET_ITEMS && ShieldOfArrav.isBlackArmGang(e.getPlayer())) { e.getPlayer().startConversation(new Dialogue().addNPC(789, HeadE.SECRETIVE, ""Yes, what do you want?"") .addOptions(""Choose an option:"", new Options() { @Override public void create() { option(""Rabbit's Foot."", new Dialogue().addNPC(789, HeadE.CALM_TALK, ""No idea what you are talking about, go away!"")); option(""Four leaved Clover."", new Dialogue() .addPlayer(HeadE.CALM_TALK, ""Four leaved clover"") .addNPC(789, HeadE.HAPPY_TALKING, ""Oh, you're one of the gang are you? Ok, hold up a second, I'll just let you in"" + "" through here."") .addSimple(""You hear the door being unbarred from inside."", () -> e.getPlayer().getQuestManager().getAttribs(Quest.HEROES_QUEST).setB(""black_arm_hideout_open"", true))); option(""Lucky horseshoe"", new Dialogue().addNPC(789, HeadE.CALM_TALK, ""No idea what you are talking about, go away!"")); option(""Black cat"", new Dialogue().addNPC(789, HeadE.CALM_TALK, ""No idea what you are talking about, go away!"")); } })); } else e.getPlayer().sendMessage(""The door won't open""); }); public static NPCClickHandler gruborTalk = new NPCClickHandler(new Object[] { 789 }, e -> { if (e.getOption().equalsIgnoreCase(""talk-to"")) e.getPlayer().startConversation(new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Hello."") .addNPC(789, HeadE.CALM_TALK, ""Hi. I'm a little busy right now. Maybe you should speak to Trobert. He runs things around here."") ); }); public static NPCClickHandler trobertTalk = new NPCClickHandler(new Object[] { 1884 }, e -> { if (e.getOption().equalsIgnoreCase(""talk-to"")) e.getPlayer().startConversation(new TrobertHeroesQuestD(e.getPlayer()).getStart()); }); public static NPCClickHandler handleAlfonseWaiter = new NPCClickHandler(new Object[] { 793 }, e -> { if (e.getOption().equalsIgnoreCase(""talk-to"")) { e.getPlayer().startConversation(new AlfonsoTheWaiterHeroesQuestD(e.getPlayer()).getStart()); } else if (e.getOption().equalsIgnoreCase(""trade"")) ShopsHandler.openShop(e.getPlayer(), ""alfonso_waiter_shop""); }); public static NPCClickHandler handleCharlieCook = new NPCClickHandler(new Object[] { 794 }, e -> { if (e.getOption().equalsIgnoreCase(""talk-to"")) e.getPlayer().startConversation(new CharlieTheCookHeroesQuestD(e.getPlayer()).getStart()); }); public static ObjectClickHandler handleCharliesWall = new ObjectClickHandler(new Object[]{2629}, e -> e.getPlayer().sendMessage(""It is just a wall..."")); }" "package com.rs.game.content.quests.heroesquest; @QuestHandler( quest = Quest.HEROES_QUEST, startText = ""Speak with Achietties at the entrance to the Heroes' Guild in Burthorpe."", itemsText = ""If you are in the Black Arm Gang, you will need a black full helm, black platebody and black platelegs. You will either need a player partner in the Phoenix Gang or a lockpick.
If you are in the Phoenix Gang, you will need a Ranged or Magic weapon and a player partner in the Black Arm Gang. Otherwise, you will need a lockpick and either 1,000 coins or a ring of Charos.
Fishing rod (and possibly bait), harralander potion (unf).
Ice gloves."", combatText = ""You will need to defeat a level 77 enemy."", rewardsText = ""Total of 29,232 XP over twelve skills
Access to the Heroes' Guild"", completedStage = 2 ) @PluginEventHandler public class HeroesQuest extends QuestOutline { public final static int NOT_STARTED = 0; public final static int GET_ITEMS = 1; public final static int QUEST_COMPLETE = 2; @Override public List getJournalLines(Player player, int stage) { ArrayList lines = new ArrayList<>(); switch (stage) { case NOT_STARTED -> { lines.add(""You will first have to prove you are worthy to enter the""); lines.add(""Heroes' Guild. To prove your status as a hero, you will""); lines.add(""need to obtain a number of items. There are many challenges""); lines.add(""standing between you and these items.""); lines.add(""""); lines.add(""~~~Quest Requirements~~~""); lines.add((player.getQuestManager().getQuestPoints() >= 56 ? """" : """") + ""56 Quest Points""); lines.add((player.isQuestComplete(Quest.SHIELD_OF_ARRAV) ? """" : """") + ""Shield Of Arrav""); lines.add((player.isQuestComplete(Quest.LOST_CITY) ? """" : """") + ""Lost City""); lines.add((player.isQuestComplete(Quest.DRAGON_SLAYER) ? """" : """") + ""Dragon Slayer""); lines.add((player.isQuestComplete(Quest.MERLINS_CRYSTAL) ? """" : """") + ""Merlin's Crystal""); lines.add((player.isQuestComplete(Quest.DRUIDIC_RITUAL) ? """" : """") + ""Druidic Ritual""); lines.add(""""); lines.add(""~~~Skill Requirements~~~""); lines.add((player.getSkills().getLevel(Constants.COOKING) >= 53 ? """" : """") + ""53 Cooking""); lines.add((player.getSkills().getLevel(Constants.FISHING) >= 53 ? """" : """") + ""53 Fishing""); lines.add((player.getSkills().getLevel(Constants.HERBLORE) >= 25 ? """" : """") + ""25 Herblore""); lines.add((player.getSkills().getLevel(Constants.DEFENSE) >= 25 ? """" : """") + ""25 Defence""); lines.add((player.getSkills().getLevel(Constants.MINING) >= 50 ? """" : """") + ""50 Mining""); lines.add(""""); if (meetsRequirements(player)) { lines.add(""You meet the requirements for this quest!""); lines.add(""""); } } case GET_ITEMS -> { if (!player.getInventory().containsItem(2149, 1)) { //Lava Eel lines.add(""You need a cooked Lava Eel. Maybe Garrent in""); lines.add(""Port Sarim can help?""); lines.add(""""); } else { lines.add(""You got the cooked Lava Eeel, finally!""); lines.add(""""); } if (!player.getInventory().containsItem(1583, 1)) { lines.add(""You need a fire feather. They can be found""); lines.add(""by killing a fire bird in Entrana. Rumor is""); lines.add(""you need ice gloves from the ice queen under""); lines.add(""White Wolf Mountain.""); lines.add(""""); } else { lines.add(""You finally got the fire feather!""); lines.add(""""); } if (player.getInventory().containsItem(1579, 1)) { lines.add(""Finally, you got the master thieves armband!""); lines.add(""""); } else { if (ShieldOfArrav.hasGang(player)) { if (ShieldOfArrav.isPhoenixGang(player)) { lines.add(""To get the master thieves armband you""); lines.add(""should talk to Straven for a mission...""); } if (ShieldOfArrav.isBlackArmGang(player)) { if(player.getQuestManager().getAttribs(Quest.HEROES_QUEST).getB(""black_arm_trick"")) { lines.add(""The black arm gang has given me a mission to steal Pete's""); lines.add(""candle sticks. I am to sneak in as a guard in black armour""); lines.add(""by giving my paper ID then finding the chest with the sticks.""); } else { lines.add(""To get the master thieves armband you""); lines.add(""should talk to Katrine for a mission...""); } } } else { lines.add(""Error, you don't have a gang, contact an admin!""); } lines.add(""""); } lines.add(""""); } case QUEST_COMPLETE -> { lines.add(""""); lines.add(""""); lines.add(""QUEST COMPLETE!""); } default -> lines.add(""Invalid quest stage. Report this to an administrator.""); } return lines; } public static boolean meetsRequirements(Player p) { QuestManager questManager = p.getQuestManager(); Skills skills = p.getSkills(); boolean[] requirements = new boolean[]{ questManager.getQuestPoints() >= 56, questManager.isComplete(Quest.SHIELD_OF_ARRAV), questManager.isComplete(Quest.LOST_CITY), questManager.isComplete(Quest.DRAGON_SLAYER), questManager.isComplete(Quest.MERLINS_CRYSTAL), questManager.isComplete(Quest.DRUIDIC_RITUAL), skills.getLevel(Constants.COOKING) >= 53, skills.getLevel(Constants.FISHING) >= 53, skills.getLevel(Constants.HERBLORE) >= 25, skills.getLevel(Constants.DEFENSE) >= 25, skills.getLevel(Constants.MINING) >= 50, }; for (boolean hasRequirement : requirements) if (!hasRequirement) return false; return true; } public static ItemAddedToInventoryHandler handleFireFeather = new ItemAddedToInventoryHandler(1583, e -> { Player p = e.getPlayer(); if (p.getEquipment().getGlovesId() == 1580)//ice gloves return; else { e.cancel(); World.addGroundItem(new Item(1583, 1), Tile.of(p.getTile())); p.startConversation(new Dialogue().addSimple(""The feather is too hot to pick up with your bare hands..."")); } }); public static ItemOnItemHandler handleMakeOilyRod = new ItemOnItemHandler(new int[]{1582}, new int[]{307}, e -> { int rod_slot = e.getItem1().getId() == 307 ? e.getItem1().getSlot() : e.getItem2().getSlot(); int oil_slot = e.getItem1().getId() == 1582 ? e.getItem1().getSlot() : e.getItem2().getSlot(); e.getPlayer().getInventory().deleteItem(oil_slot, new Item(1582, 1)); e.getPlayer().getInventory().replaceItem(1585, 1, rod_slot); }); public static ItemOnItemHandler handlePromptHarllander = new ItemOnItemHandler(new int[]{1581}, new int[]{307}, e -> e.getPlayer().startConversation(new Dialogue().addPlayer(HeadE.CALM_TALK, ""I'll need to add unfinished Harralander to the slime before I make it oily...""))); public static ItemClickHandler handleClickBlamishOil = new ItemClickHandler(new Object[] { 1582 }, new String[] { ""Drink"" }, e -> e.getPlayer().sendMessage(""You know... I'd really rather not."")); @Override public void complete(Player player) { Object[][] xpAdded = {{Constants.ATTACK, 3075}, {Constants.DEFENSE, 3075}, {Constants.STRENGTH, 3075}, {Constants.HITPOINTS, 3075}, {Constants.RANGE, 2075}, {Constants.FISHING, 2725}, {Constants.COOKING, 2825}, {Constants.WOODCUTTING, 1575}, {Constants.FIREMAKING, 1575}, {Constants.SMITHING, 2257}, {Constants.MINING, 2575}, {Constants.HERBLORE, 1325}}; for (Object[] objects : xpAdded) { player.sendMessage(""You have gained "" + objects[1] + "" in "" + Skills.SKILL_NAME[(int) objects[0]] + "".""); player.getSkills().addXpQuest((int) objects[0], (int) objects[1]); } sendQuestCompleteInterface(player, 1377); } }" "package com.rs.game.content.quests.heroesquest.dialogues; @PluginEventHandler public class AchiettiesHeroesQuestD extends Conversation { private static final int NPC = 796; public AchiettiesHeroesQuestD(Player player) { super(player); Dialogue itemsOptions = new Dialogue(); itemsOptions.addOptions(""Choose an option:"", new Options() { @Override public void create() { option(""Any hints on getting the thieves armband?"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Any hints on getting the thieves armband?"") .addNPC(NPC, HeadE.CALM_TALK, ""I'm sure you have relevant contacts to find out about that."") .addNext(() -> player.startConversation(new Conversation(itemsOptions)))); option(""Any hints on getting the feather?"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Any hints on getting the feather?"") .addNPC(NPC, HeadE.CALM_TALK, ""Not really - other than Entrana firebirds tend to live on Entrana"") .addNext(() -> player.startConversation(new Conversation(itemsOptions)))); option(""Any hints on getting the eel?"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Any hints on getting the eel?"") .addNPC(NPC, HeadE.CALM_TALK, ""Maybe go and find someone who knows a lot about fishing? (Try Gerrant in Port Sarim...)"") .addNext(() -> player.startConversation(new Conversation(itemsOptions)))); option(""I'll start looking for all those things then"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""I'll start looking for all those things then"") .addNPC(NPC, HeadE.CALM_TALK, ""Good luck with that."")); } }); switch (player.getQuestManager().getStage(Quest.HEROES_QUEST)) { case NOT_STARTED -> { Dialogue startQuest = new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""I'm a hero - may I apply to join?"") .addOptions(""Start Heroes Quest?"", new Options() { @Override public void create() { option(""Yes"", new Dialogue() .addNPC(NPC, HeadE.CALM_TALK, ""Well, you have a lot of quest points, and you have done all of the required quests, "" + ""so you may now begin the tasks to meet the entry requirements for membership in the Heroes' Guild."", () -> player.getQuestManager().setStage(Quest.HEROES_QUEST, 1)) .addNPC(NPC, HeadE.CALM_TALK, ""The three items required for entrance are: An Entranan Firebird feather, a Master "" + ""Thieves' armband, and a cooked Lava Eel."") .addNext(itemsOptions)); option(""No"", new Dialogue()); } }); addNPC(NPC, HeadE.CALM_TALK, ""Greetings. Welcome to the Heroes' Guild.""); addNPC(NPC, HeadE.CALM_TALK, ""Only the greatest heroes of this land may gain entrance to this guild.""); addOptions(""Choose an option:"", new Options() { @Override public void create() { if (HeroesQuest.meetsRequirements(player)) option(""I'm a hero, may I apply to join?"", startQuest); else option(""I'm a hero, may I apply to join?"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""I'm a hero - may I apply to join?"") .addNPC(NPC, HeadE.CALM_TALK, ""You're a hero? I've never heard of YOU. You are required to possess at least 56 quest "" + ""points to file an application."") .addNPC(NPC, HeadE.CALM_TALK, ""Additionally you must have completed the Shield of Arrav, Lost City, Merlin's Crystal "" + ""and Dragon Slayer."") .addNext(() -> player.getQuestManager().showQuestDetailInterface(Quest.HEROES_QUEST)) ); option(""Good for the foremost heroes of the land."", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Good for the foremost heroes of the land."") .addNPC(NPC, HeadE.CALM_TALK, ""Yes. Yes it is."") ); } }); } case GET_ITEMS -> { addNPC(NPC, HeadE.CALM_TALK, ""Greetings. Welcome to the Heroes' Guild. How goes thy quest adventurer?""); if (hasAllItems()) { addPlayer(HeadE.HAPPY_TALKING, ""I have all the required items.""); addNPC(NPC, HeadE.CALM_TALK, ""I see that you have. Well done. Now, to complete the quest, and gain entry to the Heroes' Guild in your"" + "" final task all that you have to do is...""); addPlayer(HeadE.AMAZED, ""W-what? What do you mean? There's MORE?""); addNPC(NPC, HeadE.CALM_TALK, ""I'm sorry, I was just having a little fun with you. Just a little Heroes' Guild humour there. What I really meant was...""); addNPC(NPC, HeadE.CALM_TALK, ""Congratulations! You have completed the Heroes' Guild entry requirements! You will find the door now open for you! Enter, Hero! And take this reward!""); addNext(() -> { player.getQuestManager().completeQuest(Quest.HEROES_QUEST); player.getInventory().removeItems(new Item(2149, 1), new Item(1579, 1), new Item(1583, 1)); }); return; } addPlayer(HeadE.HAPPY_TALKING, ""It's tough. I've not done it yet.""); addNPC(NPC, HeadE.CALM_TALK, ""Remember, the items you need to enter are: An Entranan Firebirds' feather, A Master Thieves armband, and a "" + ""cooked Lava Eel.""); addNext(itemsOptions); } } } public boolean hasAllItems() { return player.getInventory().containsItems(new Item(2149, 1), new Item(1579, 1), new Item(1583, 1)); } public static NPCClickHandler handleAchietties = new NPCClickHandler(new Object[] { 796 }, e -> { if (e.getPlayer().isQuestComplete(Quest.HEROES_QUEST)) { e.getPlayer().startConversation(new Conversation(e.getPlayer()) { final int NPC = e.getNPCId(); { addNPC(NPC, HeadE.CALM_TALK, ""Greetings, welcome to the heroes guild!""); addPlayer(HeadE.HAPPY_TALKING, ""Thank you...""); addNPC(NPC, HeadE.CALM_TALK, ""You're welcome.""); create(); } }); } else { e.getPlayer().startConversation(new AchiettiesHeroesQuestD(e.getPlayer()).getStart()); } }); }" "package com.rs.game.content.quests.heroesquest.dialogues; @PluginEventHandler public class AlfonsoTheWaiterHeroesQuestD extends Conversation { private static final int NPC = 793; public AlfonsoTheWaiterHeroesQuestD(Player player) { super(player); Dialogue shop = new Dialogue() .addNPC(NPC, HeadE.CALM_TALK, ""Welcome to the Shrimp and Parrot. Would you like to order, sir?"") .addNext(() -> ShopsHandler.openShop(player, ""alfonso_waiter_shop"")); switch (player.getQuestManager().getStage(Quest.HEROES_QUEST)) { case GET_ITEMS -> { if (ShieldOfArrav.isPhoenixGang(player)) addNext(new Dialogue() .addNPC(NPC, HeadE.CALM_TALK, ""Welcome to the Shrimp and Parrot. Would you like to order, sir?"") .addPlayer(HeadE.HAPPY_TALKING, ""Do you sell Gherkins?"") .addNPC(NPC, HeadE.CALM_TALK, ""Hmmmm Gherkins eh? Ask Charlie the cook, round the back. He may have some 'gherkins' for you!"") .addSimple(""Alfonse winks at you."") ); else addNext(shop); } default -> addNext(shop); } } }" "package com.rs.game.content.quests.heroesquest.dialogues; @PluginEventHandler public class CharlieTheCookHeroesQuestD extends Conversation { private static final int NPC = 794; public CharlieTheCookHeroesQuestD(Player player) { super(player); switch (player.getQuestManager().getStage(Quest.HEROES_QUEST)) { case GET_ITEMS -> { if (ShieldOfArrav.isPhoenixGang(player)) { addNPC(NPC, HeadE.CALM_TALK, ""Hey! What are you doing back here?""); addPlayer(HeadE.HAPPY_TALKING, ""I'm looking for a gherkin...""); addNPC(NPC, HeadE.CALM_TALK, ""Aaaaaah... a fellow Phoenix! So, tell me compadre... what brings you to sunny Brimhaven?""); addPlayer(HeadE.HAPPY_TALKING, ""I want to steal Scareface Pete's candlesticks.""); addNPC(NPC, HeadE.CALM_TALK, ""Ah yes, of course. The candlesticks. Well, I have to be honest with you compadre, we haven't "" + ""made much progress in that task ourselves so far. We can however offer a little assistance.""); addNPC(NPC, HeadE.CALM_TALK, ""We have our own gaurd in their ranks who is willing to take a bribe."", () -> player.getQuestManager().getAttribs(Quest.HEROES_QUEST).setB(""phoenix_trick"", true)); addPlayer(HeadE.HAPPY_TALKING, ""Okay thanks!""); } } default -> { addPlayer(HeadE.HAPPY_TALKING, ""Hello""); addNPC(NPC, HeadE.CALM_TALK, ""What are you doing back here? You should be back here.""); addPlayer(HeadE.HAPPY_TALKING, ""Okay, I'll leave...""); } } } }" "package com.rs.game.content.quests.heroesquest.dialogues; @PluginEventHandler public class KatrineHeroesQuestD extends Conversation { private static final int NPC = 642; public KatrineHeroesQuestD(Player player) { super(player); Dialogue katrineImpressed = new Dialogue() .addNPC(NPC, HeadE.CALM_TALK, ""I am impressed you got the master thieves' arm band."") .addPlayer(HeadE.HAPPY_TALKING, ""Thanks!""); switch (player.getQuestManager().getStage(Quest.HEROES_QUEST)) { case GET_ITEMS -> { if (player.getQuestManager().getAttribs(Quest.HEROES_QUEST).getB(""got_armband_katrine"")) { if (player.getInventory().containsItem(1579, 1)) addNext(katrineImpressed); else { addPlayer(HeadE.HAPPY_TALKING, ""I have lost my master thief's armband...""); addNPC(NPC, HeadE.CALM_TALK, ""Lucky I 'ave a spare ain't it? Don't lose it again."", () -> player.getInventory().addItem(1579, 1)); } return; } if (player.getInventory().containsItem(1577, 1)) { addPlayer(HeadE.HAPPY_TALKING, ""I have a candlestick now!""); addNPC(NPC, HeadE.CALM_TALK, ""Wow... is... it REALLY it? This really is a FINE bit of thievery. Us thieves have been trying to get hold"" + "" of this one for a while! You wanted to be ranked as a master thief didn't you? Well, I guess this just about ranks as good enough!""); addSimple(""Katrine gives you a master thief armband."", () -> { player.getInventory().removeItems(new Item(1577, 1)); player.getInventory().addItem(1579, 1); player.getQuestManager().getAttribs(Quest.HEROES_QUEST).setB(""got_armband_katrine"", true); }); return; } addPlayer(HeadE.HAPPY_TALKING, ""Hey""); addNPC(NPC, HeadE.CALM_TALK, ""Hey""); addPlayer(HeadE.HAPPY_TALKING, ""Is there any way I can get the rank of master thief?""); addNPC(NPC, HeadE.CALM_TALK, ""Master thief? Ain't we the ambitious one! Well, you're gonna have to do something pretty amazing to earn that rank.""); addPlayer(HeadE.HAPPY_TALKING, ""Anything you can suggest?""); addNPC(NPC, HeadE.CALM_TALK, ""Well, some of the MOST coveted prizes in thiefdom right now are in the pirate town of Brimhaven on Karamja. "" + ""The pirate leader Scarface Pete keeps an extremely valuable candlestick in his Brimhaven mansion. His security is VERY good. ""); addNPC(NPC, HeadE.CALM_TALK, ""We, of course, have gang members in a town like Brimhaven who may be able to help you. Visit our hideout in "" + ""south-east Brimhaven. To get in you will need to tell them the secret password 'Four leaved clover'.""); } case QUEST_COMPLETE -> addNext(katrineImpressed); } } }" "package com.rs.game.content.quests.heroesquest.dialogues; @PluginEventHandler public class MansionDoorHeroesQuestD extends Conversation { private static final int NPC = 788; public MansionDoorHeroesQuestD(Player player, ObjectClickEvent e) { super(player); Dialogue intro = new Dialogue().addNPC(NPC, HeadE.FRUSTRATED, ""Oi! Where do you think you're going pal?""); Dialogue reportDuty = new Dialogue().addPlayer(HeadE.CALM_TALK, ""Hi, I'm Hartigen. I've come to work here."") .addNPC(NPC, HeadE.CALM_TALK, ""I assume you have your I.D. papers then?""); switch (player.getQuestManager().getStage(Quest.HEROES_QUEST)) { case GET_ITEMS -> { if (player.getQuestManager().getAttribs(Quest.HEROES_QUEST).getB(""mansion_open_phoenix"")) { handleDoor(player, e.getObject()); return; } if (player.getQuestManager().getAttribs(Quest.HEROES_QUEST).getB(""mansion_open_black_arm"")) { if (isWearingBlackArmour()) handleDoor(player, e.getObject()); return; } if (player.getQuestManager().getAttribs(Quest.HEROES_QUEST).getB(""black_arm_trick"") && isWearingBlackArmour()) if (player.getInventory().containsItem(1584, 1)) addNext(intro.addNext(() -> player.startConversation(reportDuty .addSimple(""You show the ID papers..."", () -> { player.getInventory().removeItems(new Item(1584, 1)); player.getQuestManager().getAttribs(Quest.HEROES_QUEST).setB(""mansion_open_black_arm"", true); }) .addNPC(NPC, HeadE.CALM_TALK, ""You'd better come in then."")))); else addNext(intro.addNext(() -> player.startConversation(reportDuty .addPlayer(HeadE.SECRETIVE, ""Uh... Yeah. About that...I must have left them in my other suit of armour."") )) ); else if (player.getQuestManager().getAttribs(Quest.HEROES_QUEST).getB(""phoenix_trick"")) if (player.getInventory().hasCoins(1000)) addNext(intro .addPlayer(HeadE.HAPPY_TALKING, ""Can I go in there?"") .addNPC(NPC, HeadE.CALM_TALK, ""No in there is private."") .addPlayer(HeadE.HAPPY_TALKING, ""Are you open to a bribe?"") .addNPC(NPC, HeadE.CALM_TALK, ""On these wages, absolutely It'll cost you 1,000 coin for me to urn a blind eye."") .addPlayer(HeadE.HAPPY_TALKING, ""Sounds good"") .addSimple(""You hand him the coins and he winks at you."", () -> { player.getInventory().removeCoins(1000); player.getQuestManager().getAttribs(Quest.HEROES_QUEST).setB(""mansion_open_phoenix"", true); }) ); else addPlayer(HeadE.HAPPY_TALKING, ""I'll need some money to bribe him...""); } default -> addNext(intro.addPlayer(HeadE.CALM_TALK, ""Nowhere special."")); } } public boolean isWearingBlackArmour() { if (player.getEquipment().getChestId() == 1125 && player.getEquipment().getLegsId() == 1077 && player.getEquipment().getHatId() == 1165) return true; player.sendMessage(""You need to be wearing black armour as a disguise...""); return false; } }" "package com.rs.game.content.quests.heroesquest.dialogues; @PluginEventHandler public class StravenHeroesQuestD extends Conversation { private static final int NPC = 644; public StravenHeroesQuestD(Player player) { super(player); Dialogue impressedStraven = new Dialogue() .addNPC(NPC, HeadE.CALM_TALK, ""Impressive work on getting the master thieves' armband."") .addPlayer(HeadE.HAPPY_TALKING, ""Thanks!""); switch (player.getQuestManager().getStage(Quest.HEROES_QUEST)) { case GET_ITEMS -> { if (player.getQuestManager().getAttribs(Quest.HEROES_QUEST).getB(""got_armband_straven"")) { if (player.getInventory().containsItem(1579, 1)) addNext(impressedStraven); else { addPlayer(HeadE.SAD, ""I lost the armband!""); addNPC(NPC, HeadE.CALM_TALK, ""Oh, don't lose it again""); addSimple(""He hands you another..."", () -> player.getInventory().addItem(1579, 1)); } return; } if (player.getInventory().containsItem(1577, 1)) { addPlayer(HeadE.HAPPY_TALKING, ""I have retrieved a candlestick!""); addNPC(NPC, HeadE.CALM_TALK, ""Hmmm. Not bad, not bad. Let's see it, make sure it's genuine.""); addSimple(""You hand Straven the candlestick.""); addPlayer(HeadE.HAPPY_TALKING, ""So is this enough to get me a Master Thief armband?""); addNPC(NPC, HeadE.CALM_TALK, ""Hmm... I dunno... Aww, go on then. I suppose I'm in a generous mood today.""); addSimple(""Straven hands you a Master Thief armband."", () -> { player.getInventory().removeItems(new Item(1577, 1)); player.getInventory().addItem(1579, 1); player.getQuestManager().getAttribs(Quest.HEROES_QUEST).setB(""got_armband_straven"", true); }); return; } addPlayer(HeadE.HAPPY_TALKING, ""How would I go about getting a Master Thief armband?""); addNPC(NPC, HeadE.CALM_TALK, ""Ooh... tricky stuff. Took me YEARS to get that rank. Well, what some of the more aspiring thieves in our gang are "" + ""working on right now is to steal some very valuable candlesticks from Scarface Pete – the pirate leader on Karamja.""); addNPC(NPC, HeadE.CALM_TALK, ""His security is excellent, and the target very valuable, so that might be enough to get you the rank. Go talk to our"" + "" man Alfonse, the waiter at the Shrimp and Parrot. Use the secret key word 'gherkin' to show you're one of us.""); } case QUEST_COMPLETE -> addNext(impressedStraven); } } }" "package com.rs.game.content.quests.heroesquest.dialogues; @PluginEventHandler public class TrobertHeroesQuestD extends Conversation { private static final int NPC = 1884; public TrobertHeroesQuestD(Player player) { super(player); Dialogue intro = new Dialogue() .addNPC(NPC, HeadE.CALM_TALK, ""Welcome to our Brimhaven headquarters. I'm Trobert and I'm in charge here."") .addPlayer(HeadE.HAPPY_TALKING, ""Pleased to meet you."") .addNPC(NPC, HeadE.CALM_TALK, ""Likewise.""); switch (player.getQuestManager().getStage(Quest.HEROES_QUEST)) { case GET_ITEMS -> { if (ShieldOfArrav.isBlackArmGang(player)) { if (player.getInventory().containsItem(1584, 1)) { addNPC(NPC, HeadE.CALM_TALK, ""Good luck getting those candles..."", () -> player.getQuestManager().getAttribs(Quest.HEROES_QUEST).setB(""black_arm_trick"", true)); addPlayer(HeadE.CALM_TALK, ""Thanks!""); return; } addNext(intro .addPlayer(HeadE.HAPPY_TALKING, ""So can you help me get Scarface Pete's candlesticks?"") .addNPC(NPC, HeadE.CALM_TALK, ""Well, we have made some progress there. We know that one of the only keys to Pete's treasure "" + ""room is carried by Grip, the head guard, so we thought it might be good to get close to him somehow"") .addNPC(NPC, HeadE.CALM_TALK, ""Grip was taking on a new deputy called Hartigen, an Asgarnian Black Knight who was deserting the "" + ""Black Knight Fortress and seeking new employment here on Brimhaven."") .addNPC(NPC, HeadE.CALM_TALK, ""We managed to waylay him on the journey here, and steal his ID papers. Now all we need is to find "" + ""somebody willing to impersonate him and take the deputy role to get that key for us."") .addOptions(""Choose an option:"", new Options() { @Override public void create() { option(""I volunteer to undertake that mission!"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""I volunteer to undertake that mission!"") .addNPC(NPC, HeadE.CALM_TALK, ""Good good. Well, here's the ID papers, take them and introduce yourself to "" + ""the guards at Scarface Pete's mansion, we'll have that treasure in no time."", () -> { player.getInventory().addItem(1584, 1); player.getQuestManager().getAttribs(Quest.HEROES_QUEST).setB(""black_arm_trick"", true); }) ); option(""Well, good luck then."", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Well, good luck then."") .addNPC(NPC, HeadE.CALM_TALK, ""Someone will show up eventually."") ); } }) ); } else addNext(intro); } default -> addNext(intro); } } }" "package com.rs.game.content.quests.heroesquest.icequeenlair; @PluginEventHandler public class IceQueenDungeon { public static ObjectClickHandler handleRockSlide = new ObjectClickHandler(new Object[]{2634}, e -> { if (!e.getPlayer().containsTool(1265) && Pickaxe.getBest(e.getPlayer()) == null) { e.getPlayer().sendMessage(""You do not have a pickaxe...""); return; } if (e.getPlayer().getSkills().getLevel(Constants.MINING) < 50) return; GameObject obj = e.getObject(); int id = e.getObjectId(); boolean hasRun = e.getPlayer().getRun(); if (e.isAtObject()) { if (e.getOption().equalsIgnoreCase(""Investigate"")) e.getPlayer().sendMessage(""It appears to need 50 mining to clear...""); else //Clear rocks WorldTasks.scheduleTimer(i -> { if (i == 0) e.getPlayer().lock(); if (i == 1) e.getPlayer().faceObject(obj); if (i == 2) e.getPlayer().setNextAnimation(new Animation(625)); if (i == 5) obj.setId(472); if (i == 9) obj.setId(473); if (i == 12) obj.setId(474); if (i == 15) { e.getPlayer().setRun(false); if (e.getPlayer().getX() < obj.getX()) e.getPlayer().addWalkSteps(Tile.of(2840, e.getPlayer().getY() - 1, 0), 4, false); else e.getPlayer().addWalkSteps(Tile.of(2837, e.getPlayer().getY() + 1, 0), 4, false); } if (i == 19) { obj.setId(473); e.getPlayer().setRun(hasRun); e.getPlayer().unlock(); } if (i == 20) obj.setId(472); if (i == 21) { obj.setId(id); return false; } return true; }); } }); public static ObjectClickHandler handleIceQueenLairLadders = new ObjectClickHandler(new Object[]{20987, 33184, 100}, e -> { switch (e.getObjectId()) { case 20987 -> e.getPlayer().useLadder(Tile.of(e.getPlayer().getX(), e.getPlayer().getY() + 6400, 0)); case 33184 -> e.getPlayer().useLadder(Tile.of(e.getPlayer().getX(), e.getPlayer().getY() - 6400, 0)); } }); public static NPCInstanceHandler aggroWarriors = new NPCInstanceHandler(145, (npcId, tile) -> { NPC warrior = new NPC(npcId, tile); warrior.setForceAgressive(true); return warrior; }); }" "package com.rs.game.content.quests.holygrail; @PluginEventHandler public class BlackKnightTitan extends NPC { public BlackKnightTitan(int id, Tile tile, boolean permaDeath) { super(id, tile, permaDeath); } @Override public boolean canMove(Direction dir) { return false; } @Override public void sendDeath(final Entity source) { if(source instanceof Player player && player.getEquipment().getWeaponId() == 35) { super.sendDeath(source); player.sendMessage(""Well done, you have defeated the Black Knight Titan!""); boolean isRun = player.getRun(); player.setRunHidden(false); player.addWalkSteps(Tile.of(player.getX() >= 2791 ? 2790 : 2792, 4722, 0), 4, false); WorldTasks.delay(2, () -> player.setRunHidden(isRun)); return; } resetHP(); } @Override public boolean ignoreWallsWhenMeleeing() { return true; } public static NPCInstanceHandler toFunc = new NPCInstanceHandler(221, (npcId, tile) -> new BlackKnightTitan(npcId, tile, false)); public static NPCClickHandler handleDialogue = new NPCClickHandler(new Object[]{221}, new String[]{""Talk-to""}, e -> e.getPlayer().startConversation(new Dialogue() .addNPC(221, HeadE.CHILD_CALM_TALK, ""I am the Black Knight Titan! You must pass through me before you can continue in this realm!"") .addPlayer(HeadE.HAPPY_TALKING, ""Ok, have at ye oh evil knight!"") .addPlayer(HeadE.HAPPY_TALKING, ""Actually I think I'll run away!"") )); }" "package com.rs.game.content.quests.holygrail; @QuestHandler( quest = Quest.HOLY_GRAIL, startText = ""Speak to King Arthur in Camelot."", itemsText = ""Excalibur."", combatText = ""You will need to defeat a level 28 enemy."", rewardsText = ""15,300 Defence XP
11,000 Prayer XP
Access to the Fisher Realm
Ability to use the King Arthur picture in your player-owned house"", completedStage = 7 ) @PluginEventHandler public class HolyGrail extends QuestOutline { public final static int NOT_STARTED = 0; public final static int TALK_TO_MERLIN = 1; public final static int GO_TO_ENTRANA = 2; public final static int GO_TO_MCGRUBOR = 3; public final static int SPEAK_TO_FISHER_KING = 4; public final static int SPEAK_TO_PERCIVAL = 5; public final static int GIVE_AURTHUR_HOLY_GRAIL = 6; public final static int QUEST_COMPLETE = 7; @Override public List getJournalLines(Player player, int stage) { ArrayList lines = new ArrayList<>(); switch (stage) { case NOT_STARTED -> { lines.add(""King Arthur is sending out his knights on a quest for the""); lines.add(""famous Holy Grail. If you are a Knight of the Round Table""); lines.add(""go to King Arthur for further orders.""); lines.add(""""); lines.add(""~~~Quest Requirements~~~""); lines.add((player.isQuestComplete(Quest.MERLINS_CRYSTAL) ? """" : """") + ""Merlin's Crystal""); lines.add(""""); lines.add(""~~~Skill Requirements~~~""); lines.add((player.getSkills().getLevel(Constants.ATTACK) >= 20 ? """" : """") + ""20 Attack(Wield Excalibur)""); lines.add(""""); if (meetsRequirements(player)) { lines.add(""You meet the requirements for this quest!""); lines.add(""""); } else { lines.add(""You do not meet the requirements for this quest!""); lines.add(""""); } } case TALK_TO_MERLIN -> { lines.add(""King Arthur recommended I get more information about the""); lines.add(""Holy Grail from King Arthur.""); lines.add(""""); } case GO_TO_ENTRANA -> { lines.add(""Merlin recommends looking for Entrana, perhaps the High""); lines.add(""Priest of the church can help me?""); lines.add(""""); } case GO_TO_MCGRUBOR -> { lines.add(""I need an artifact of The Fisher Realm. Perhaps Brother""); lines.add(""Galahad can help me get one.""); lines.add(""""); } case SPEAK_TO_FISHER_KING -> { lines.add(""I must get into the castle and speak to the king of The""); lines.add(""Fisher Realm. However I need some type of whistle. I was""); lines.add(""told I can find it in a haunted mansion. However I need""); lines.add(""to have an artifact of the fisher realm for it to""); lines.add(""appear.""); lines.add(""""); lines.add(""Once I have the whistle I need to find a way to get there.""); lines.add(""6 heads point to the location which I must find.""); lines.add(""""); } case SPEAK_TO_PERCIVAL -> { lines.add(""I should find the Fisher King's son, Sir Percival. Sir""); lines.add(""Percival is also a knight of the round table. Perhaps""); lines.add(""King Arthur will know how to get to him?""); lines.add(""""); } case GIVE_AURTHUR_HOLY_GRAIL -> { lines.add(""Legend has it once The Fisher Realm is restored a hero""); lines.add(""can claim the Holy Grail from the castle and after give""); lines.add(""it to King Arthur.""); lines.add(""""); } case QUEST_COMPLETE -> { lines.add(""""); lines.add(""""); lines.add(""QUEST COMPLETE!""); } default -> lines.add(""Invalid quest stage. Report this to an administrator.""); } return lines; } public static boolean meetsRequirements(Player p) { QuestManager questManager = p.getQuestManager(); Skills skills = p.getSkills(); boolean[] requirements = new boolean[]{ questManager.isComplete(Quest.MERLINS_CRYSTAL), skills.getLevel(Constants.ATTACK) >= 20 }; for (boolean hasRequirement : requirements) if (!hasRequirement) return false; return true; } public static NPCClickHandler handleFisherNPCs = new NPCClickHandler(new Object[]{210, 214, 215}, new String[]{""Talk-to""}, e -> { if (e.getNPCId() == 214)// peasent e.getPlayer().startConversation(new Dialogue() .addNPC(214, HeadE.SAD_CRYING, ""Woe is me! Our crops are all failing... how shall I feed myself this winter?"")); if (e.getNPCId() == 215)// paesent e.getPlayer().startConversation(new Dialogue() .addNPC(215, HeadE.HAPPY_TALKING, ""Oh happy day! Suddenly our crops are growing again! It'll be a bumper harvest this year!"")); if (e.getNPCId() == 210)// grail maiden e.getPlayer().startConversation(new Dialogue() .addNPC(210, HeadE.CALM_TALK, ""Welcome to the Grail Castle."")); }); public static PickupItemHandler handleHolyGrail = new PickupItemHandler(new Object[] {19}, Tile.of(2649, 4684, 2), e -> { if(e.getPlayer().isQuestComplete(Quest.HOLY_GRAIL) || e.getPlayer().getInventory().containsItem(19)) e.cancelPickup(); }); public static PlayerStepHandler handleMagicWhistleSpawn = new PlayerStepHandler(Tile.of(3106, 3361, 2), e -> { if(e.getPlayer().getInventory().containsItem(15) && !e.getPlayer().getTempAttribs().getB(""Spawned_Whistle"")) { e.getPlayer().getTempAttribs().setB(""Spawned_Whistle"", true); World.addGroundItem(new Item(16, 1), Tile.of(3107, 3359, 2), e.getPlayer()); World.addGroundItem(new Item(16, 1), Tile.of(3107, 3359, 2), e.getPlayer()); } }); public static ItemClickHandler handleMagicWhisle = new ItemClickHandler(new Object[] { 16 }, new String[] { ""Blow"" }, e -> { if (e.getPlayer().getRegionId() == 11081 || e.getPlayer().getRegionId() == 10569) { Magic.sendNormalTeleportSpell(e.getPlayer(), Tile.of(2757, 3475, 0)); return; } if (e.getPlayer().getTile().withinDistance(Tile.of(2742, 3236, 0), 2)) { if(e.getPlayer().getQuestManager().getStage(Quest.HOLY_GRAIL) >= GIVE_AURTHUR_HOLY_GRAIL) { Magic.sendNormalTeleportSpell(e.getPlayer(), Tile.of(2678, 4713, 0)); return; } Magic.sendNormalTeleportSpell(e.getPlayer(), Tile.of(2803, 4713, 0)); } }); public static ItemClickHandler handleGrailBell = new ItemClickHandler(new Object[] { 17 }, new String[] { ""Ring"" }, e -> { if (e.getPlayer().getTile().withinDistance(Tile.of(2762, 4694, 0), 1)) { e.getPlayer().startConversation(new Dialogue() .addSimple(""Ting-a-ling!"") .addNPC(210, HeadE.CALM_TALK, ""Come in, it is cold out!"") .addNext(() -> e.getPlayer().tele(Tile.of(2762, 4692, 0)))); return; } e.getPlayer().startConversation(new Dialogue().addSimple(""Ting-a-ling!"")); }); public static ItemClickHandler handleMagicGoldFeather = new ItemClickHandler(new Object[] { 18 }, new String[] { ""Blow-on"" }, e -> { if (e.getPlayer().getQuestManager().getStage(Quest.HOLY_GRAIL) != SPEAK_TO_PERCIVAL) { e.getPlayer().sendMessage(""The feather seems like an ordinary feather now...""); return; } Tile playerTile = e.getPlayer().getTile(); Tile percievalTile = Tile.of(2961, 3505, 0); int xDir = percievalTile.getX() - playerTile.getX(); int yDir = percievalTile.getY() - playerTile.getY(); if (xDir == 0 && yDir == 0) e.getPlayer().sendMessage(""The feather points down somewhere near here""); if (xDir == 0 && yDir > 0) e.getPlayer().sendMessage(""The feather points to the north""); if (xDir > 0 && yDir > 0) e.getPlayer().sendMessage(""The feather points to northeast""); if (xDir > 0 && yDir == 0) e.getPlayer().sendMessage(""The feather points to the east""); if (xDir > 0 && yDir < 0) e.getPlayer().sendMessage(""The feather points to the southeast""); if (xDir == 0 && yDir < 0) e.getPlayer().sendMessage(""The feather points to the south""); if (xDir < 0 && yDir < 0) e.getPlayer().sendMessage(""The feather points to the southwest""); if (xDir < 0 && yDir == 0) e.getPlayer().sendMessage(""The feather points to the west""); if (xDir < 0 && yDir > 0) e.getPlayer().sendMessage(""The feather points to the northwest""); }); public static ObjectClickHandler handlePercivalSack = new ObjectClickHandler(new Object[]{ 23 }, e -> { if (e.getPlayer().getQuestManager().getStage(Quest.HOLY_GRAIL) != SPEAK_TO_PERCIVAL) { e.getPlayer().startConversation(new Dialogue().addPlayer(HeadE.CALM_TALK, ""It is just an ordinary sack..."")); return; } if(e.getOption().equalsIgnoreCase(""Prod"")) { e.getPlayer().startConversation(new Dialogue().addSimple(""You hear a muffled groan. The sack wiggles slightly."")); return; } e.getPlayer().startConversation(new Dialogue().addSimple(""You hear muffled noises from the sack. You open the sack."")); if (World.getNPCsInChunkRange(e.getPlayer().getChunkId(), 0).stream().anyMatch(n -> n.getId() == 211 && n instanceof OwnedNPC percival && percival.getOwner() == e.getPlayer())) { e.getPlayer().sendMessage(""Sir percival is already freed.""); return; } OwnedNPC percival = new OwnedNPC(e.getPlayer(), 211, Tile.of(2961, 3504, 0), true); percival.faceEntity(e.getPlayer()); percival.setRandomWalk(false); }); @Override public void complete(Player player) { player.getSkills().addXpQuest(Skills.PRAYER, 11_000); player.getSkills().addXpQuest(Skills.DEFENSE, 15_300); sendQuestCompleteInterface(player, 19); } }" "package com.rs.game.content.quests.holygrail; @PluginEventHandler public class KingPercivalHolyGrailD extends Conversation { private static final int NPC = 212; public KingPercivalHolyGrailD(Player player) { super(player); if(player.getQuestManager().getStage(Quest.HOLY_GRAIL) >= GIVE_AURTHUR_HOLY_GRAIL) { addNPC(NPC, HeadE.TALKING_ALOT, ""You missed all the excitement! I got here and agreed to take over duties as king here, then before my eyes the"" + "" most miraculous changes occurred here... grass and trees were growing outside before our very eyes!""); addNPC(NPC, HeadE.HAPPY_TALKING, ""Thank you very much for showing me the way home.""); return; } addNPC(NPC, HeadE.CALM_TALK, ""Hi""); addPlayer(HeadE.HAPPY_TALKING, ""Hello""); addNPC(NPC, HeadE.CALM_TALK, ""...""); addPlayer(HeadE.HAPPY_TALKING, ""...""); addNPC(NPC, HeadE.CALM_TALK, ""See you later then?""); addPlayer(HeadE.HAPPY_TALKING, ""Yes...""); } public static NPCClickHandler handleDialogue = new NPCClickHandler(new Object[]{NPC}, e -> e.getPlayer().startConversation(new KingPercivalHolyGrailD(e.getPlayer()).getStart())); }" "package com.rs.game.content.quests.holygrail.dialogue; @PluginEventHandler public class EntranaHighPriestHolyGrailD extends Conversation { private static final int NPC = 216; static class CroneDialogue extends Conversation { public CroneDialogue(Player player) { super(player); Dialogue croneQuestions = new Dialogue(); croneQuestions.addOptions(""Choose an option:"", new Options() { @Override public void create() { option(""What are the six heads?"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""What are the six heads?"") .addNPC(217, HeadE.CALM_TALK, ""The six stone heads have appeared just recently in the world. They all face the point of the realm crossing. "") .addNPC(217, HeadE.CALM_TALK, ""Find where two of the heads face, and you should be able to pinpoint where it is."") .addNext(croneQuestions) ); option(""What's a Fisher King?"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""What's a Fisher King?"") .addNPC(217, HeadE.CALM_TALK, ""The Fisher King is the owner and slave of the Grail."") .addNext(croneQuestions) ); option(""What do you mean by the whistle?"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""What do you mean by the whistle?"") .addNPC(217, HeadE.CALM_TALK, ""You don't know about the whistles yet? The whistles are easy. You will need one to get to and from the Fisher King's realm. "") .addNPC(217, HeadE.CALM_TALK, ""They reside in a haunted manor house in Misthalin, though you may not perceive them unless you carry something from the realm of the Fisher King..."") .addNext(croneQuestions) ); option(""Ok, I will go searching."", new Dialogue()); } }); addNext(croneQuestions); } } public EntranaHighPriestHolyGrailD(Player p) { super(p); switch(p.getQuestManager().getStage(Quest.HOLY_GRAIL)) { case GO_TO_ENTRANA, GO_TO_MCGRUBOR -> { addNPC(NPC, HeadE.CALM_TALK, ""Many greetings. Welcome to our fair island.""); addPlayer(HeadE.HAPPY_TALKING, ""Hello. I am in search of the Holy Grail.""); addNPC(NPC, HeadE.CALM_TALK, ""The object of which you speak did once pass through holy Entrana. I know not where it is now however. "" + ""Nor do I really care."", ()->{ for(NPC npc : World.getNPCsInChunkRange(p.getChunkId(), 1)) if(npc.getId() == 217 && npc instanceof OwnedNPC crone && crone.getOwner() == p) return; new OwnedNPC(p, 217, p.getTile(), true); }); addNPC(217, HeadE.CALM_TALK, ""Did you say the Grail? You are a Grail knight, yes? Well you'd better hurry. A Fisher King is in pain.""); addPlayer(HeadE.HAPPY_TALKING, ""Well I would, but I don't know where I am going!""); addNPC(217, HeadE.CALM_TALK, "" Go to where the six heads face, blow the whistle and away you go!"", ()-> p.getQuestManager().setStage(Quest.HOLY_GRAIL, GO_TO_MCGRUBOR)); addNext(()-> p.startConversation(new CroneDialogue(p).getStart())); } default -> addNPC(NPC, HeadE.CALM_TALK, ""Bless you "" + p.getDisplayName() + ""!""); } } public static NPCClickHandler handlePriest = new NPCClickHandler(new Object[]{NPC}, e -> e.getPlayer().startConversation(new EntranaHighPriestHolyGrailD(e.getPlayer()).getStart())); public static NPCClickHandler handleCrone = new NPCClickHandler(new Object[]{217}, e -> e.getPlayer().startConversation(new CroneDialogue(e.getPlayer()).getStart())); }" "package com.rs.game.content.quests.holygrail.dialogue; @PluginEventHandler public class FishermanHolyGrailD extends Conversation { private static final int NPC = 219; public FishermanHolyGrailD(Player player) { super(player); addPlayer(HeadE.HAPPY_TALKING, ""Any idea how to get into the castle?""); addNPC(NPC, HeadE.CALM_TALK, ""Why, that's easy! Just ring one of the bells outside.""); addPlayer(HeadE.HAPPY_TALKING, ""...I didn't see any bells.""); addNPC(NPC, HeadE.CALM_TALK, ""You must be blind then. There's ALWAYS bells there when I go to the castle.""); } public static NPCClickHandler handleDialogue = new NPCClickHandler(new Object[]{NPC}, e -> e.getPlayer().startConversation(new FishermanHolyGrailD(e.getPlayer()).getStart())); }" "package com.rs.game.content.quests.holygrail.dialogue; @PluginEventHandler public class KingArthurHolyGrailD extends Conversation { private static final int NPC = 251; public KingArthurHolyGrailD(Player player) { super(player); switch(player.getQuestManager().getStage(Quest.HOLY_GRAIL)) { case NOT_STARTED -> { addPlayer(HeadE.HAPPY_TALKING, ""Now I am a knight of the round table, do you have any more quests for me?""); addNPC(NPC, HeadE.CALM_TALK, ""Aha! I'm glad you are here! I am sending out various knights on an important quest. I was wondering if you "" + ""too would like to take up this quest?""); if(HolyGrail.meetsRequirements(player)) { addOptions(""Start Holy Grail?"", new Options() { @Override public void create() { option(""Yes."", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Tell me of this quest."") .addNPC(NPC, HeadE.CALM_TALK, ""Well, we recently found out that the Holy Grail has passed into the Runescape world. This is most fortuitous!"") .addNPC(NPC, HeadE.CALM_TALK, ""None of my knights ever did return with it last time. Now we have the opportunity to give it another go, maybe this time we will have more luck!"") .addPlayer(HeadE.HAPPY_TALKING, ""I'd enjoy trying that."") .addNPC(NPC, HeadE.CALM_TALK, ""Go speak to Merlin. He may be able to give a better clue as to where it is now you have freed him from that crystal. "" + ""He has set up his workshop in the room next to the library."", () -> player.getQuestManager().setStage(Quest.HOLY_GRAIL, TALK_TO_MERLIN)) ); option(""No."", new Dialogue()); } }); return; } addNext(()-> player.getQuestManager().showQuestDetailInterface(Quest.HOLY_GRAIL)); } case TALK_TO_MERLIN, GO_TO_ENTRANA -> { addNPC(NPC, HeadE.CALM_TALK, ""How goes thy quest?""); addPlayer(HeadE.HAPPY_TALKING, ""I have made progress, but I have not recovered the Grail yet.""); addNPC(NPC, HeadE.CALM_TALK, ""Well, the Grail IS very elusive, it may take some perseverance. As I said before, speak to Merlin in the workshop by the library.""); } case GO_TO_MCGRUBOR -> { addNPC(NPC, HeadE.CALM_TALK, ""How goes thy quest?""); addPlayer(HeadE.HAPPY_TALKING, ""I have made progress, but I have not recovered the Grail yet.""); addNPC(NPC, HeadE.CALM_TALK, ""My knight, Sir Ghalad, is in Mcgrubor woods. he may have information you need.""); } case SPEAK_TO_FISHER_KING -> { addNPC(NPC, HeadE.CALM_TALK, ""How goes thy quest?""); addPlayer(HeadE.HAPPY_TALKING, ""I have made progress, but I have not recovered the Grail yet.""); addNPC(NPC, HeadE.CALM_TALK, ""This is a good time to seek the Fisher Realm.""); } case SPEAK_TO_PERCIVAL -> { addPlayer(HeadE.HAPPY_TALKING, ""Hello, do you have a knight named Sir Percival?""); addNPC(NPC, HeadE.CALM_TALK, ""Ah yes. I remember young Percival. He rode off on a quest a couple of months ago. We are getting a bit worried, he's not back yet...""); addNPC(NPC, HeadE.CALM_TALK, ""he was going to try and recover the golden boots of Arkaneeses.""); addPlayer(HeadE.HAPPY_TALKING, ""Any idea which way that would be?""); addNPC(NPC, HeadE.CALM_TALK, ""Not exactly. We discovered some magic golden feathers that are said to point the way to the boots... ""); addNPC(NPC, HeadE.CALM_TALK, ""They certainly point somewhere. Just blowing on them gently will supposedly show the way to go.""); addSimple(""King Arthur gives you a feather."", ()-> player.getInventory().addItem(new Item(18, 1), true)); } case GIVE_AURTHUR_HOLY_GRAIL -> { addNPC(NPC, HeadE.CALM_TALK, ""How goes thy quest?""); if(player.getInventory().containsItem(19)) { addPlayer(HeadE.HAPPY_TALKING, ""I have retrieved the Grail!""); addNPC(NPC, HeadE.CALM_TALK, ""Wow! Incredible! You truly are a splendid knight!""); addNext(()->{ player.getInventory().deleteItem(new Item(19, 1)); player.getQuestManager().completeQuest(Quest.HOLY_GRAIL); }); return; } addPlayer(HeadE.HAPPY_TALKING, ""I still need to get the Holy Grail.""); addPlayer(HeadE.HAPPY_TALKING, ""I believe it is somewhere in the Fisher Realm""); addNPC(NPC, HeadE.CALM_TALK, ""Okay, carry on then.""); } case QUEST_COMPLETE -> addNPC(NPC, HeadE.HAPPY_TALKING, ""Thank you for retrieving the Grail! You shall long be remembered as one of the greatest heroes amongst"" + "" the Knights of the Round Table!""); } } }" "package com.rs.game.content.quests.holygrail.dialogue; @PluginEventHandler public class MerlinHolyGrailD extends Conversation { private static final int NPC = 213; public MerlinHolyGrailD(Player player) { super(player); switch(player.getQuestManager().getStage(Quest.HOLY_GRAIL)) { case TALK_TO_MERLIN, GO_TO_ENTRANA, GO_TO_MCGRUBOR -> { addPlayer(HeadE.HAPPY_TALKING, ""Hello. King Arthur has sent me on a quest for the Holy Grail. He thought you could offer some assistance.""); addNPC(NPC, HeadE.CALM_TALK, ""Ah yes... the Holy Grail... That is a powerful artefact indeed. Returning it here would help Camelot a lot."" + "" Due to its nature the Holy Grail is likely to reside in a holy place.""); addPlayer(HeadE.HAPPY_TALKING, ""Any suggestions?""); addNPC(NPC, HeadE.CALM_TALK, ""I believe there is a holy island somewhere not far away... I'm not entirely sure... I spent too long inside that"" + "" crystal! Anyways, go and talk to someone over there. I suppose you could also try speaking to Sir Galahad?""); addNPC(NPC, HeadE.CALM_TALK, ""He returned from the quest many years after everyone else. He seems to know something about it, but he can only "" + ""speak about those experiences cryptically.""); addPlayer(HeadE.HAPPY_TALKING, ""Where can I find Sir Galahad?""); addNPC(NPC, HeadE.CALM_TALK, ""Galahad now lives a life of religious contemplation. He lives somewhere west of McGrubor's Wood I think. Though "" + ""I recommend speaking to someone on the holy island first."",()-> player.getQuestManager().setStage(Quest.HOLY_GRAIL, GO_TO_ENTRANA)); } case SPEAK_TO_FISHER_KING -> { addNPC(NPC, HeadE.CALM_TALK, ""How goes the quest for the Holy Grail?""); addPlayer(HeadE.HAPPY_TALKING, ""I am to find an artifact in Draynor Manor""); addNPC(NPC, HeadE.CALM_TALK, ""I see""); } case SPEAK_TO_PERCIVAL -> { addNPC(NPC, HeadE.CALM_TALK, ""How goes the quest for the Holy Grail?""); addPlayer(HeadE.HAPPY_TALKING, ""I am trying to find the son of the king of The Fisher Realm!""); addNPC(NPC, HeadE.AMAZED, ""That is a task indeed!""); } case GIVE_AURTHUR_HOLY_GRAIL -> { addPlayer(HeadE.HAPPY_TALKING, ""I found the Holy Grail!""); addNPC(NPC, HeadE.AMAZED, ""REALLY!!?""); addPlayer(HeadE.HAPPY_TALKING, ""Yes!""); addNPC(NPC, HeadE.CALM_TALK, ""You really need to give The Holy Grail to King Arthur!""); } case QUEST_COMPLETE -> addNPC(NPC, HeadE.CALM_TALK, ""I am amazed with you adventurer thank you for getting the Holy Grail back to Camelot!""); } } }" "package com.rs.game.content.quests.holygrail.dialogue; @PluginEventHandler public class SirGalahadHolyGrailD extends Conversation { private static final int NPC = 218; public SirGalahadHolyGrailD(Player player) { super(player); addNPC(NPC, HeadE.CALM_TALK, ""Welcome to my home. It's rare for me to have guests! Would you like a cup of tea? I'll just put the kettle on.""); addSimple(""Brother Galahad hangs a kettle over the fire""); switch(player.getQuestManager().getStage(Quest.HOLY_GRAIL)) { case GO_TO_ENTRANA -> { addPlayer(HeadE.HAPPY_TALKING, "" I'm looking for Sir Galahad""); addNPC(NPC, HeadE.CALM_TALK, ""I AM Sir Galahad. Although I've retired as a Knight, and now live as a solitary monk. Also, I prefer to be "" + ""known as Brother rather than Sir now.""); addPlayer(HeadE.HAPPY_TALKING, ""I'm on a quest to find the Holy Grail!""); addNPC(NPC, HeadE.CALM_TALK, ""Ah... the Grail... yes... that did fill me with wonder! Oh, that I could have stayed forever! The atmosphere, the food, the people...""); addPlayer(HeadE.HAPPY_TALKING, ""How can I find it?""); addNPC(NPC, HeadE.CALM_TALK, ""Well, I did not find it through looking - though admittedly I looked long and hard - eventually, it found me.""); addPlayer(HeadE.HAPPY_TALKING, ""Interesting. Though, I don't know where to start asking you questions.""); addNPC(NPC, HeadE.CALM_TALK, ""Ah, well you can always have tea...""); addPlayer(HeadE.SECRETIVE, ""Umm....""); } case GO_TO_MCGRUBOR, SPEAK_TO_FISHER_KING, SPEAK_TO_PERCIVAL, GIVE_AURTHUR_HOLY_GRAIL -> { addPlayer(HeadE.HAPPY_TALKING, "" I'm looking for Sir Galahad""); addNPC(NPC, HeadE.CALM_TALK, ""I AM Sir Galahad. Although I've retired as a Knight, and now live as a solitary monk. Also, I prefer to be "" + ""known as Brother rather than Sir now.""); addPlayer(HeadE.HAPPY_TALKING, ""I'm on a quest to find the Holy Grail!""); addNPC(NPC, HeadE.CALM_TALK, ""Ah... the Grail... yes... that did fill me with wonder! Oh, that I could have stayed forever! The atmosphere, the food, the people...""); addPlayer(HeadE.HAPPY_TALKING, ""Hmm, actually, yes I seek an item from the realm of the Fisher King. Do you have one?""); addNPC(NPC, HeadE.CALM_TALK, ""Funny you should mention that, but when I left there I took a small cloth from the table as a keepsake.""); addPlayer(HeadE.HAPPY_TALKING, ""I don't suppose I could borrow that? It could come in useful on my quest.""); addSimple(""Galahad reluctantly passes you a small cloth."", ()->{ player.getInventory().addItem(new Item(15, 1), true); if(player.getQuestManager().getStage(Quest.HOLY_GRAIL) == GO_TO_MCGRUBOR) player.getQuestManager().setStage(Quest.HOLY_GRAIL, SPEAK_TO_FISHER_KING); }); } default -> addPlayer(HeadE.HAPPY_TALKING, ""No, no thank you, I will be heading out.""); } } public static NPCClickHandler handleDialogue = new NPCClickHandler(new Object[]{NPC}, e -> e.getPlayer().startConversation(new SirGalahadHolyGrailD(e.getPlayer()).getStart())); }" "package com.rs.game.content.quests.holygrail.dialogue; @PluginEventHandler public class SirPercivalHolyGrailD extends Conversation { private static final int NPC = 211; public SirPercivalHolyGrailD(Player player) { super(player); if(player.getQuestManager().getStage(Quest.HOLY_GRAIL) == SPEAK_TO_PERCIVAL) { Dialogue options = new Dialogue(); if(player.getInventory().containsItem(16)) options.addOptions(""Choose an option:"", new Options() { @Override public void create() { option(""How did you end up in a sack?"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""How did you end up in a sack?"") .addNPC(NPC, HeadE.CALM_TALK, ""It's a little embarrassing really. After going on a long and challenging quest to retrieve the boots"" + "" of Arkaneeses, defeating many powerful enemies on the way, I fell into a goblin trap!"") .addNPC(NPC, HeadE.CALM_TALK, ""I've been kept as a slave here for the last 3 months! A day or so ago, "" + ""they decided it was a fun game to put me in this sack; then they forgot about me! I'm now very hungry, and my bones feel very stiff."") .addNext(options) ); option(""Come with me, I shall make you a king."", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Come with me, I shall make you a king."") .addNPC(NPC, HeadE.CALM_TALK, ""What are you talking about? The king of where?"") .addPlayer(HeadE.HAPPY_TALKING, ""Your father is apparently someone called the Fisher King. He is dying and wishes you to be his heir."") .addNPC(NPC, HeadE.CALM_TALK, ""I have been told that before. I have not been able to find the castle again though."") .addPlayer(HeadE.HAPPY_TALKING, ""Well, I do have the means to get us there - a magic whistle!"") .addItem(16, ""You show him the magic whistle and explain where to blow it..."", () -> { player.getInventory().deleteItem(new Item(16, 1)); player.getQuestManager().setStage(Quest.HOLY_GRAIL, GIVE_AURTHUR_HOLY_GRAIL); }) .addNPC(NPC, HeadE.CALM_TALK, ""Ok, I will see you there then!"") ); option(""Your father wishes to speak to you."", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Your father wishes to speak to you."") .addNPC(NPC, HeadE.CALM_TALK, ""My father? You have spoken to him recently?"") .addPlayer(HeadE.HAPPY_TALKING, ""He is dying and wishes you to be his heir"") .addNPC(NPC, HeadE.CALM_TALK, ""I have been told that before. I have not been able to find that castle again though."") .addPlayer(HeadE.HAPPY_TALKING, ""Well, I do have the means to get us there - a magic whistle!"") .addItem(16, ""You show him the magic whistle and explain where to blow it..."", () -> { player.getInventory().deleteItem(new Item(16, 1)); player.getQuestManager().setStage(Quest.HOLY_GRAIL, GIVE_AURTHUR_HOLY_GRAIL); }) .addNPC(NPC, HeadE.CALM_TALK, ""Ok, I will see you there then!"") ); } }); if(!player.getInventory().containsItem(16)) options.addPlayer(HeadE.AMAZED, ""Found you!"") .addNPC(NPC, HeadE.CALM_TALK, ""That you did..."") .addPlayer(HeadE.HAPPY_TALKING, ""I need to give you a whistle..."") .addNPC(NPC, HeadE.CALM_TALK, ""A what?"") .addPlayer(HeadE.HAPPY_TALKING, ""I will be right back, stay here."") .addNPC(NPC, HeadE.CALM_TALK, ""Okay""); addNPC(NPC, HeadE.CALM_TALK, ""Wow, thank you! I could hardly breathe in there!""); addNext(options); return; } addNPC(NPC, HeadE.CALM_TALK, ""Hi""); addPlayer(HeadE.HAPPY_TALKING, ""Hello""); addNPC(NPC, HeadE.CALM_TALK, ""...""); addPlayer(HeadE.HAPPY_TALKING, ""...""); addNPC(NPC, HeadE.CALM_TALK, ""See you later then?""); addPlayer(HeadE.HAPPY_TALKING, ""Yes...""); } public static NPCClickHandler handleDialogue = new NPCClickHandler(new Object[]{NPC}, e -> e.getPlayer().startConversation(new SirPercivalHolyGrailD(e.getPlayer()).getStart())); }" "package com.rs.game.content.quests.holygrail.dialogue; @PluginEventHandler public class TheFisherKingHolyGrailD extends Conversation { private static final int NPC = 220; public TheFisherKingHolyGrailD(Player player) { super(player); switch(player.getQuestManager().getStage(Quest.HOLY_GRAIL)) { case SPEAK_TO_FISHER_KING, SPEAK_TO_PERCIVAL, GIVE_AURTHUR_HOLY_GRAIL -> { addNPC(NPC, HeadE.CALM_TALK, ""Ah! You got inside at last! You spent all that time fumbling around outside. I thought you'd never make it here.""); addOptions(""Choose an option:"", new Options() { @Override public void create() { option(""How did you know what I have been doing?"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""How did you know what I have been doing?"") .addNPC(NPC, HeadE.CALM_TALK, ""Oh, I can see what is happening in my realm. I have sent clues to help you get here, such as the fisherman, and the crone."") .addPlayer(HeadE.HAPPY_TALKING, ""Do you mind if I have a look around?"") .addNPC(NPC, HeadE.CALM_TALK, ""No, not at all. Please, be my guest."") ); option(""I seek the Holy Grail"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""I seek the Holy Grail"") .addNPC(NPC, HeadE.CALM_TALK, ""Ah excellent. A knight come to seek the Holy Grail. Maybe our land can be restored to its"" + "" former glory. At the moment the Grail cannot be removed from the castle."") .addNPC(NPC, HeadE.CALM_TALK, ""Legend has it a questing knight will one day work out how to restore our land; then he will claim the Grail as his prize."") .addPlayer(HeadE.HAPPY_TALKING, ""Any ideas how I can restore the land?"") .addNPC(NPC, HeadE.CALM_TALK, ""None at all."") ); option(""You don't look too well."", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""You don't look too well."") .addNPC(NPC, HeadE.CALM_TALK, ""Nope, I don't feel so good either. I fear my life is running short... Alas, my son and heir is not here. I am waiting for my son to return to this castle."") .addNPC(NPC, HeadE.CALM_TALK, ""If you could find my son, that would be a great weight off my shoulders."") .addPlayer(HeadE.HAPPY_TALKING, ""Who is your son?"") .addNPC(NPC, HeadE.CALM_TALK, ""He is known as Percival. I believe he is a knight of the round table."") .addPlayer(HeadE.HAPPY_TALKING, ""I shall go and see if I can find him."", ()-> player.getQuestManager().setStage(Quest.HOLY_GRAIL, SPEAK_TO_PERCIVAL)) ); } }); } default->{ addNPC(NPC, HeadE.CALM_TALK, ""Hello adventurer!""); addPlayer(HeadE.HAPPY_TALKING, ""Hi...""); } } } public static NPCClickHandler handleDialogue = new NPCClickHandler(new Object[]{NPC}, e -> e.getPlayer().startConversation(new TheFisherKingHolyGrailD(e.getPlayer()).getStart())); }" "package com.rs.game.content.quests.holygrail.dialogue.knightsroundtable; @PluginEventHandler public class SirBedivereHolyGrailD extends Conversation { private static final int NPC = 242; public SirBedivereHolyGrailD(Player player) { super(player); switch(player.getQuestManager().getStage(Quest.HOLY_GRAIL)) { case GO_TO_ENTRANA, GO_TO_MCGRUBOR, SPEAK_TO_FISHER_KING, SPEAK_TO_PERCIVAL, GIVE_AURTHUR_HOLY_GRAIL -> { addNPC(NPC, HeadE.CALM_TALK, ""May I help you? You are looking for the Grail now adventurer?""); addPlayer(HeadE.HAPPY_TALKING, ""Absolutely.""); addNPC(NPC, HeadE.CALM_TALK, ""The best of luck to you! Make the name of Camelot proud, and bring it back to us.""); } case QUEST_COMPLETE -> { addNPC(NPC, HeadE.CALM_TALK, ""You look in good spirits.""); addPlayer(HeadE.TALKING_ALOT, ""Yup""); addNPC(NPC, HeadE.CALM_TALK, ""That Holy Grail...""); addPlayer(HeadE.CALM, ""...""); addNPC(NPC, HeadE.CALM_TALK, ""I am glad you got it! You ought to be in good spirits""); addPlayer(HeadE.HAPPY_TALKING, ""I appreciate that""); } } } }" "package com.rs.game.content.quests.holygrail.dialogue.knightsroundtable; @PluginEventHandler public class SirGawainHolyGrailD extends Conversation { private static final int NPC = 240; public SirGawainHolyGrailD(Player player) { super(player); switch(player.getQuestManager().getStage(Quest.HOLY_GRAIL)) { case NOT_STARTED, TALK_TO_MERLIN -> { addNPC(NPC, HeadE.CALM_TALK, ""Good day to you "" + player.getPronoun(""sir"", ""madam"") + ""!""); addPlayer(HeadE.HAPPY_TALKING, ""Good day!""); } case GO_TO_ENTRANA, GO_TO_MCGRUBOR, SPEAK_TO_FISHER_KING, SPEAK_TO_PERCIVAL, GIVE_AURTHUR_HOLY_GRAIL -> { addNPC(NPC, HeadE.CALM_TALK, ""Good day to you "" + player.getPronoun(""sir"", ""madam"") + ""!""); addPlayer(HeadE.HAPPY_TALKING, ""I seek the Grail in the name of Camelot!""); addNPC(NPC, HeadE.CALM_TALK, ""The Grail? That is truly a noble quest indeed. None but Galahad have come close.""); addPlayer(HeadE.HAPPY_TALKING, ""Galahad? Who is he?""); addNPC(NPC, HeadE.CALM_TALK, ""He used to be one of the Knights of the Round Table, but he mysteriously disappeared many years ago.""); addPlayer(HeadE.HAPPY_TALKING, ""Why would he quit being a Knight?""); addNPC(NPC, HeadE.CALM_TALK, ""That is a good question. I'm afraid I don't have the answer.""); } case QUEST_COMPLETE -> { addNPC(NPC, HeadE.CALM_TALK, ""Getting the Holy Grail was a major victory for us, thank you.""); addPlayer(HeadE.HAPPY_TALKING, ""You are welcome.""); } } } }" "package com.rs.game.content.quests.holygrail.dialogue.knightsroundtable; @PluginEventHandler public class SirKayHolyGrailD extends Conversation { private static final int NPC = 241; public SirKayHolyGrailD(Player player) { super(player); switch(player.getQuestManager().getStage(Quest.HOLY_GRAIL)) { case GO_TO_ENTRANA, GO_TO_MCGRUBOR, SPEAK_TO_FISHER_KING, SPEAK_TO_PERCIVAL, GIVE_AURTHUR_HOLY_GRAIL -> { addNPC(NPC, HeadE.CALM_TALK, ""Good day "" + player.getPronoun(""sir"", ""madam"") + ""! I hear you are questing for the Holy Grail?""); addPlayer(HeadE.HAPPY_TALKING, ""That's right. Any hints?""); addNPC(NPC, HeadE.CALM_TALK, ""Unfortunately not.""); } case QUEST_COMPLETE -> { addNPC(NPC, HeadE.CALM_TALK, ""You got the Holy Grail!""); addPlayer(HeadE.HAPPY_TALKING, ""Yes, I did...""); } } } }" "package com.rs.game.content.quests.holygrail.dialogue.knightsroundtable; @PluginEventHandler public class SirLancelotHolyGrailD extends Conversation { private static final int NPC = 239; public SirLancelotHolyGrailD(Player player) { super(player); switch(player.getQuestManager().getStage(Quest.HOLY_GRAIL)) { case GO_TO_ENTRANA, GO_TO_MCGRUBOR, SPEAK_TO_FISHER_KING, SPEAK_TO_PERCIVAL, GIVE_AURTHUR_HOLY_GRAIL -> { addNPC(NPC, HeadE.CALM_TALK, ""Greetings! I am Sir Lancelot, the greatest Knight in the land! What do you want?""); addPlayer(HeadE.HAPPY_TALKING, ""I am questing for the Holy Grail.""); addNPC(NPC, HeadE.LAUGH, ""The Grail? Ha! Frankly, little man, you're not in that league.""); addPlayer(HeadE.FRUSTRATED, ""Why do you say that?""); addNPC(NPC, HeadE.TALKING_ALOT, ""You got lucky with freeing Merlin but there's no way a puny wannabe like you is going to find the Holy Grail "" + ""where so many others have failed.""); addPlayer(HeadE.CALM_TALK, ""We'll see about that.""); } case QUEST_COMPLETE -> { addNPC(NPC, HeadE.TALKING_ALOT, ""There is no way a wannabe like you got the Holy Grail without help. You lucky knight.""); addPlayer(HeadE.FRUSTRATED, ""I am sure you would have gotten it if you tried...""); addNPC(NPC, HeadE.CALM_TALK, ""Yup...""); } } } }" "package com.rs.game.content.quests.holygrail.dialogue.knightsroundtable; @PluginEventHandler public class SirLucanHolyGrailD extends Conversation { private static final int NPC = 245; public SirLucanHolyGrailD(Player player) { super(player); switch(player.getQuestManager().getStage(Quest.HOLY_GRAIL)) { case GO_TO_ENTRANA, GO_TO_MCGRUBOR, SPEAK_TO_FISHER_KING, SPEAK_TO_PERCIVAL, GIVE_AURTHUR_HOLY_GRAIL -> { addNPC(NPC, HeadE.CALM_TALK, ""Hello there adventurer.""); addPlayer(HeadE.HAPPY_TALKING, ""I seek the Grail of legend!""); addNPC(NPC, HeadE.CALM_TALK, ""I'm afraid I don't have any suggestions.""); addPlayer(HeadE.HAPPY_TALKING, ""Thanks. I'll try and find someone who does.""); } case QUEST_COMPLETE -> { addNPC(NPC, HeadE.CALM_TALK, ""Thank you for getting the Holy Grail!""); addPlayer(HeadE.HAPPY_TALKING, ""You are welcome.""); } } } // public static NPCClickHandler handleDialogue = new NPCClickHandler(new Object[]{NPC}) { // @Override // public void handle(NPCClickEvent e) { // e.getPlayer().startConversation(new SirLucanHolyGrailD(e.getPlayer()).getStart()); // } // }; }" "package com.rs.game.content.quests.holygrail.dialogue.knightsroundtable; @PluginEventHandler public class SirPalomedesHolyGrailD extends Conversation { private static final int NPC = 3787; public SirPalomedesHolyGrailD(Player player) { super(player); switch(player.getQuestManager().getStage(Quest.HOLY_GRAIL)) { case GO_TO_ENTRANA, GO_TO_MCGRUBOR, SPEAK_TO_FISHER_KING, SPEAK_TO_PERCIVAL, GIVE_AURTHUR_HOLY_GRAIL -> { addNPC(NPC, HeadE.CALM_TALK, ""Hello there adventurer, what do you want of me?""); addPlayer(HeadE.HAPPY_TALKING, ""I'd like some advice on finding the Grail.""); addNPC(NPC, HeadE.CALM_TALK, ""Sorry, I cannot help you with that.""); } case QUEST_COMPLETE -> { addNPC(NPC, HeadE.CALM_TALK, ""Amazing job getting the Holy Grail!""); addPlayer(HeadE.HAPPY_TALKING, ""Thank you.""); } } } }" "package com.rs.game.content.quests.holygrail.dialogue.knightsroundtable; @PluginEventHandler public class SirPelleasHolyGrailD extends Conversation { private static final int NPC = 244; public SirPelleasHolyGrailD(Player player) { super(player); switch(player.getQuestManager().getStage(Quest.HOLY_GRAIL)) { case GO_TO_ENTRANA, GO_TO_MCGRUBOR, SPEAK_TO_FISHER_KING, SPEAK_TO_PERCIVAL, GIVE_AURTHUR_HOLY_GRAIL -> { addNPC(NPC, HeadE.CALM_TALK, ""Greetings to the court of King Arthur!""); addPlayer(HeadE.HAPPY_TALKING, ""Any suggestions on finding the Grail?""); addNPC(NPC, HeadE.CALM_TALK, ""My best guess would be some sort of spell. Merlin is our magic expert. Ask him? Although having said that, "" + ""I believe Galahad found its location once.""); addPlayer(HeadE.HAPPY_TALKING, ""Really? Know where I can find him?""); addNPC(NPC, HeadE.CALM_TALK, ""I'm afraid not. He left here many moons ago and I know not where he went.""); } case QUEST_COMPLETE -> { addNPC(NPC, HeadE.CALM_TALK, ""Greetings to the court of King Arthur!""); addPlayer(HeadE.CALM_TALK, ""Sure...""); addNPC(NPC, HeadE.TALKING_ALOT, ""Great job on the Holy Grail too!""); addPlayer(HeadE.HAPPY_TALKING, ""Thanks!""); } } } }" "package com.rs.game.content.quests.holygrail.dialogue.knightsroundtable; @PluginEventHandler public class SirTristamHolyGrailD extends Conversation { private static final int NPC = 243; public SirTristamHolyGrailD(Player player) { super(player); switch(player.getQuestManager().getStage(Quest.HOLY_GRAIL)) { case GO_TO_ENTRANA, GO_TO_MCGRUBOR, SPEAK_TO_FISHER_KING, SPEAK_TO_PERCIVAL, GIVE_AURTHUR_HOLY_GRAIL -> { addNPC(NPC, HeadE.CALM_TALK, ""Hail Arthur, King of the Britons!""); addPlayer(HeadE.HAPPY_TALKING, ""Um... Hello. I am seeking the Grail.""); addNPC(NPC, HeadE.CALM_TALK, ""Good luck with that!""); } case QUEST_COMPLETE -> { addNPC(NPC, HeadE.CALM_TALK, ""Hail Arthur, King of the Britons!""); addNPC(NPC, HeadE.CALM_TALK, ""Oh and good job getting the Holy Grail!""); addPlayer(HeadE.HAPPY_TALKING, ""Thanks.""); } } } }" "package com.rs.game.content.quests.junglepotion; @QuestHandler( quest = Quest.JUNGLE_POTION, startText = ""Speak to Trufitus near Tai Bwo Wannai."", itemsText = ""None."", combatText = ""None."", rewardsText = ""775 Herblore XP"", completedStage = 6 ) @PluginEventHandler public class JunglePotion extends QuestOutline { // Quest Stages public static final int NOT_STARTED = 0; public static final int FIND_SNAKE_WEED = 1; public static final int FIND_ARDRIGAL = 2; public static final int FIND_SITO_FOIL = 3; public static final int FIND_VOLENCIA_MOSS = 4; public static final int FIND_ROGUES_PURSE = 5; public static final int QUEST_COMPLETE = 6; // Items IDs public static final int GRIMY_SNAKE_WEED = 1525; public static final int GRIMY_ARDRIGAL = 1527; public static final int GRIMY_SITO_FOIL = 1529; public static final int GRIMY_VOLENCIA_MOSS = 1531; public static final int GRIMY_ROGUES_PURSE = 1533; @Override public List getJournalLines(Player player, int stage) { ArrayList lines = new ArrayList<>(); // Keeping this commented for future updates // if (stage == QUEST_COMPLETE) { // lines.add(""I collected five jungle herbs for him and he was""); // lines.add(""able to commune with his gods.""); // lines.add(""As a reward he showed me some herblore techniques.""); // return lines; // } if (stage == player.getQuestStage(Quest.JUNGLE_POTION)) { lines.add(""Trufitus Shakaya of the Tai Bwo Wannai village""); lines.add(""needed some jungle herbs in order to make a potion""); lines.add(""to help him commune with his gods.""); return lines; } return lines; } private static final int HERB = 0; // TODO: I am unsure the herb used in the iface @Override public void complete(Player player) { player.getSkills().addXpQuest(Constants.HERBLORE, 775); sendQuestCompleteInterface(player, HERB); } public static ObjectClickHandler handleMarshyVines = new ObjectClickHandler(new Object[] { 2575, 32106 }, (e) -> { Player player = e.getPlayer(); int item; Animation searchAnim; switch (e.getObject().getId()) { case 2575 -> { item = GRIMY_SNAKE_WEED; searchAnim = new Animation(2094); player.sendMessage(""You search the vine...""); } case 32106 -> { item = GRIMY_ROGUES_PURSE; player.sendMessage(""You search the wall...""); player.setNextAnimation(new Animation(2096)); searchAnim = new Animation(2097); } default -> { item = -1; searchAnim = new Animation(-1); } }; player.repeatAction(5, (ticks) -> { if (e.getObject().getId() != 2575 && e.getObject().getId() != 32106) return false; int rand = Utils.random(0, 10); if (rand == 0) { player.getInventory().addItemDrop(item, 1); player.setNextAnimation(new Animation(-1)); player.itemDialogue(item, ""You find a grimy herb.""); e.getObject().setIdTemporary(e.getObject().getId() + 1, Ticks.fromSeconds(90)); return false; } if (ticks > 0) player.setNextAnimation(searchAnim); return true; }); }); public static ObjectClickHandler handlePalmTree = new ObjectClickHandler(new Object[] { 2577, 2579, 2581 }, (e) -> { Player player = e.getPlayer(); // Is actually supposed to reject stage by stage if (!player.isQuestStarted(Quest.JUNGLE_POTION)) { player.sendMessage(""You find nothing of significance...""); return; } if (e.getOption().equals(""Search"")) { int item = switch (e.getObject().getId()) { case 2577 -> GRIMY_ARDRIGAL; case 2579 -> GRIMY_SITO_FOIL; case 2581 -> GRIMY_VOLENCIA_MOSS; default -> -1; }; e.getObject().setIdTemporary(e.getObject().getId() + 1, Ticks.fromSeconds(60)); player.getInventory().addItem(item, 1); player.itemDialogue(item, ""You find a grimy herb.""); } }); }" "package com.rs.game.content.quests.junglepotion; @PluginEventHandler public class TrufitusD { private static int junglePotionStageToGrimyHerb(int stage) { return switch (stage) { case JunglePotion.FIND_SNAKE_WEED -> JunglePotion.GRIMY_SNAKE_WEED; case JunglePotion.FIND_ARDRIGAL -> JunglePotion.GRIMY_ARDRIGAL; case JunglePotion.FIND_SITO_FOIL -> JunglePotion.GRIMY_SITO_FOIL; case JunglePotion.FIND_VOLENCIA_MOSS -> JunglePotion.GRIMY_VOLENCIA_MOSS; case JunglePotion.FIND_ROGUES_PURSE -> JunglePotion.GRIMY_ROGUES_PURSE; default -> -1; // Meme }; } private static int junglePotionStageToCleanHerb(int stage) { int grimyHerb = junglePotionStageToGrimyHerb(stage); if (grimyHerb == -1) return -1; return grimyHerb + 1; } public static NPCClickHandler HandleTrufitus = new NPCClickHandler(new Integer[] { 740 }, new String[] { ""Talk-to"" }, e -> { Player player = e.getPlayer(); NPC npc = e.getNPC(); if (!e.getOption().equals(""Talk-to"")) return; final int questStage = player.getQuestStage(Quest.JUNGLE_POTION); if (questStage == JunglePotion.QUEST_COMPLETE) { player.startConversation(new Dialogue() .addNPC(npc, HeadE.HAPPY_TALKING, ""My greatest respects, bwana.
I have communed with my gods and the future looks good for my people."") .addNPC(npc, HeadE.NERVOUS, ""We are happy now that the gods are not angry with us."") .addNPC(npc, HeadE.CALM_TALK, ""With some blessings, we will be safe here."") .addNPC(npc, HeadE.CALM_TALK, ""You should deliver the good news to bwana Timfraku, chief of Tai Bwo Wannai.
He lives in a raised hut not far from here."") ); return; } if (questStage == JunglePotion.NOT_STARTED) { Dialogue questStart = new Dialogue() .addNPC(npc, HeadE.CALM_TALK, ""I need to make a special brew! A potion that helps me to commune with the gods. For this potion, I need very special herbs, that are only found in the deep jungle."") .addNPC(npc, HeadE.CALM_TALK, ""I can only guide you so far, as the herbs are not easy to find. With some luck, you will find each herb in turn and bring it to me."") .addNPC(npc, HeadE.CALM_TALK, ""I will then give you details of where to find the next herb. In return for this great favour, I will give you training in Herblore."") .addQuestStart(Quest.JUNGLE_POTION) .addNext(() -> player.getQuestManager().setStage(Quest.JUNGLE_POTION, JunglePotion.FIND_SNAKE_WEED)) .addPlayer(HeadE.HAPPY_TALKING, ""It sounds like just the challenge for me.
And it would make a nice break from killing things!"") .addNPC(npc, HeadE.CHEERFUL, ""That is excellent, bwana!"") .addNPC(npc, HeadE.CALM_TALK, ""The first herb that you need to gather is called 'snake weed'.
It grows near vines in an area to the south-west, where the ground turns soft and the water kisses your feet."") ; player.startConversation(new Dialogue() .addNPC(npc, HeadE.HAPPY_TALKING, ""Greetings, bwana!
I am Trufitus Shakaya of the Tai Bwo Wannai village."") .addNPC(npc, HeadE.HAPPY_TALKING, ""Welcome to our humble village."") .addOptions((ops) -> { ops.add(""What does 'bwana' mean?"") .addNPC(npc, HeadE.HAPPY_TALKING, player.getPronoun(""It means 'friend', gracious sir."", ""Gracious lady, it means friend."")) .addNPC(npc, HeadE.CONFUSED, ""And friends come in peace.
I assume that you come in peace?"") .addOptions((ops1) -> { ops1.add(""Yes, of course I do."") .addNPC(npc, HeadE.HAPPY_TALKING, ""Well, that is good news, as I may have a proposition for you."") .addOptions((ops2) -> { ops2.add(""A proposition, eh? Sounds interesting."") .addNPC(npc, HeadE.HAPPY_TALKING, ""I hoped you would think so. My people are afraid to stay in the village. They have returned to the jungle and I need to commune with the gods to see what fate befalls us. You can help me by collecting some herbs that I need."") .addNext(() -> player.startConversation(questStart)); ops2.add(""I am sorry, but I am very busy.""); }) ; ops1.add(""What does a warrior like me know about peace?"") .addNPC(npc, HeadE.CALM_TALK, ""When you grow weary of violence and seek a more enlightened path, please pay me a visit as I may have a proposition for you. For now, I must attend to the plight of my people. Please excuse me."") ; }) ; ops.add(""Tai Bwo Wannai? What does that mean?"") .addNPC(npc, HeadE.CALM_TALK, ""It means 'small clearing in the jungle', but it is now the name of our village."") .addPlayer(HeadE.CONFUSED, ""It's a nice village, but where is everyone?"") .addNPC(npc, HeadE.SAD_MILD_LOOK_DOWN, ""My people are afraid to stay in the village. They have returned to the jungle. I need to commune with the gods to see what fate befalls us."") .addNPC(npc, HeadE.CONFUSED, ""You may be able to help with this."") .addOptions((ops1) -> { ops1.add(""Me? How can I help?"") .addNext(() -> player.startConversation(questStart)); ; ops1.add(""I am sorry, but I am very busy."") .addNPC(npc, HeadE.CALM_TALK, ""Very well, then.
May your journeys bring you much joy."") .addNPC(npc, HeadE.CONFUSED, ""Perhaps you will pass this way again, and then take up my proposal?"") .addNPC(npc, HeadE.HAPPY_TALKING, ""But for now, fare thee well."") ; }) ; ops.add(""It's a nice village, but where is everyone?"") .addNPC(npc, HeadE.SAD_MILD_LOOK_DOWN, ""My people are afraid to stay in the village. They have returned to the jungle. I need to commune with the gods to see what fate befalls us."") .addNPC(npc, HeadE.CONFUSED, ""You may be able to help with this."") .addOptions((ops1) -> { ops1.add(""Me? How can I help?"") .addNext(() -> player.startConversation(questStart)); ops1.add(""I am sorry, but I am very busy."") .addNPC(npc, HeadE.CALM_TALK, ""Very well, then.
May your journeys bring you much joy."") .addNPC(npc, HeadE.CONFUSED, ""Perhaps you will pass this way again, and then take up my proposal?"") .addNPC(npc, HeadE.HAPPY_TALKING, ""But for now, fare thee well."") ; }) ; ops.add(""Goodbye.""); })); return; } Dialogue grimyHerbReject = new Dialogue() .addNPC(npc, HeadE.CONFUSED, ""I don't recognise that grimy herb, bwana.""); if (questStage == JunglePotion.FIND_SNAKE_WEED) { player.startConversation(new Dialogue() .addNPC(npc, HeadE.CONFUSED, ""Greetings, bwana.
Do you have the snake weed?"") .addOptions((ops) -> { ops.add(""Of course!"") .addNext(() -> { if (player.getInventory().containsItem(junglePotionStageToCleanHerb(questStage))) { player.startConversation(new Dialogue() .addItem(junglePotionStageToCleanHerb(questStage), ""You give the snake weed to Trufitus."") .addNext(() -> { player.getInventory().deleteItem((junglePotionStageToCleanHerb(questStage)), 1); player.setQuestStage(Quest.JUNGLE_POTION, player.getQuestStage(Quest.JUNGLE_POTION) + 1); }) .addNPC(npc, HeadE.HAPPY_TALKING, ""Great! You have the snake weed. Many thanks."") .addNPC(npc, HeadE.CALM_TALK, ""The next herb is called 'ardrigal'.
It is related to the palm, and grows in its brother's shady profusion."") .addNPC(npc, HeadE.CALM_TALK, ""To the north-east you will find a small peninsula. It is just after the cliffs come down to meet the sands. That is where you should search for it."")) ; } else if (player.getInventory().containsItem(junglePotionStageToGrimyHerb(questStage))) { player.startConversation(grimyHerbReject); } else { player.startConversation(new Dialogue() .addNPC(npc, HeadE.SAD_MILD_LOOK_DOWN, ""Please don't try to deceive me.
I really need that snake weed if I am to make this potion."")) ; } }) ; ops.add(""What's the clue again?"") .addNPC(npc, HeadE.CALM_TALK, ""The first herb that you need to gather is called 'snake weed'.
It grows near vines in an area to the south-west, where the ground turns soft and the water kisses your feet."") .addNPC(npc, HeadE.CALM_TALK, ""I really need that snake weed if I am to make this potion."") ; ops.add(""Farewell.""); })); return; } if (questStage == JunglePotion.FIND_ARDRIGAL) { player.startConversation(new Dialogue() .addNPC(npc, HeadE.CONFUSED, ""Have you brought the ardrigal herb?"") .addOptions((ops) -> { ops.add(""Of course!"") .addNext(() -> { if (player.getInventory().containsItem(junglePotionStageToCleanHerb(questStage))) { player.startConversation(new Dialogue() .addItem(junglePotionStageToCleanHerb(questStage), ""You give the ardrigal to Trufitus."") .addNext(() -> { player.getInventory().deleteItem((junglePotionStageToCleanHerb(questStage)), 1); player.setQuestStage(Quest.JUNGLE_POTION, player.getQuestStage(Quest.JUNGLE_POTION) + 1); }) .addNPC(npc, HeadE.HAPPY_TALKING, ""Ardrigal! Wonderful.
You are doing well, bwana."") .addNPC(npc, HeadE.CALM_TALK, ""Now I want you to find a herb called 'sito foil', and it grows best where the ground has been blackened by the living flame."")) ; } else if (player.getInventory().containsItem(junglePotionStageToGrimyHerb(questStage))) { player.startConversation(grimyHerbReject); } else { player.startConversation(new Dialogue() .addNPC(npc, HeadE.SAD_MILD_LOOK_DOWN, ""Please don't try to deceive me.
I really need that ardrigal if I am to make this potion."")) ; } }) ; ops.add(""What's the clue again?"") .addNPC(npc, HeadE.CALM_TALK, ""The next herb is called 'ardrigal'.
It is related to the palm, and grows in its brother's shady profusion."") .addNPC(npc, HeadE.CALM_TALK, ""To the north-east you will find a small peninsula. It is just after the cliffs come down to meet the sands. That is where you should search for it."") ; ops.add(""Farewell.""); })); return; } if (questStage == JunglePotion.FIND_SITO_FOIL) { player.startConversation(new Dialogue() .addNPC(npc, HeadE.CONFUSED, ""Hello again, bwana.
Have you been successful in getting the sito foil?"") .addOptions((ops) -> { ops.add(""Of course!"") .addNext(() -> { if (player.getInventory().containsItem(junglePotionStageToCleanHerb(questStage))) { player.startConversation(new Dialogue() .addItem(junglePotionStageToCleanHerb(questStage), ""You give the sito foil to Trufitus."") .addNext(() -> { player.getInventory().deleteItem((junglePotionStageToCleanHerb(questStage)), 1); player.setQuestStage(Quest.JUNGLE_POTION, player.getQuestStage(Quest.JUNGLE_POTION) + 1); }) .addNPC(npc, HeadE.HAPPY_TALKING, ""Well done, bwana.
Just two more herbs to collect."") .addNPC(npc, HeadE.CALM_TALK, ""The next herb is called 'volencia moss'. It clings to rocks for its existence, and is difficult to see, so you must search well for it."") .addNPC(npc, HeadE.CALM_TALK, ""Volencia moss prefers rocks of high metal content and a frequently disturbed environment. There is some, I believe, to the south east of this village."")) ; } else if (player.getInventory().containsItem(junglePotionStageToGrimyHerb(questStage))) { player.startConversation(grimyHerbReject); } else { player.startConversation(new Dialogue() .addNPC(npc, HeadE.SAD_MILD_LOOK_DOWN, ""Please don't try to deceive me.
I really need that sito foil if I am to make this potion."")) ; } }) ; ops.add(""What's the clue again?"") .addNPC(npc, HeadE.CALM_TALK, ""Now I want you to find a herb called 'sito foil', and it grows best where the ground has been blackened by the living flame."") ; ops.add(""Farewell.""); })); return; } if (questStage == JunglePotion.FIND_VOLENCIA_MOSS) { player.startConversation(new Dialogue() .addNPC(npc, HeadE.CONFUSED, ""Greetings, bwana.
Do you have the volencia moss?"") .addOptions((ops) -> { ops.add(""Of course!"") .addNext(() -> { if (player.getInventory().containsItem(junglePotionStageToCleanHerb(questStage))) { player.startConversation(new Dialogue() .addItem(junglePotionStageToCleanHerb(questStage), ""You give the volencia moss to Trufitus."") .addNext(() -> { player.getInventory().deleteItem((junglePotionStageToCleanHerb(questStage)), 1); player.setQuestStage(Quest.JUNGLE_POTION, player.getQuestStage(Quest.JUNGLE_POTION) + 1); }) .addNPC(npc, HeadE.HAPPY_TALKING, ""Ah, volencia moss. Beautiful.
One final herb and the potion will be complete."") .addNPC(npc, HeadE.AMAZED, ""This herb is the most difficult to find, as it inhabits the darkness of the underground."") .addNPC(npc, HeadE.CALM_TALK, ""It is called 'rogue's purse', and is only to be found in pothole caverns in the northern part of this island."") .addNPC(npc, HeadE.CALM_TALK, ""A secret entrance to the pothole caverns is set into the northern cliffs of this land. Take care, bwana, as it may be dangerous."")) ; } else if (player.getInventory().containsItem(junglePotionStageToGrimyHerb(questStage))) { player.startConversation(grimyHerbReject); } else { player.startConversation(new Dialogue() .addNPC(npc, HeadE.SAD_MILD_LOOK_DOWN, ""Please don't try to deceive me.
I really need that volencia moss if I am to make this potion."")) ; } }) ; ops.add(""What's the clue again?"") .addNPC(npc, HeadE.CALM_TALK, ""The next herb is called 'volencia moss'. It clings to rocks for its existence, and is difficult to see, so you must search well for it."") .addNPC(npc, HeadE.CALM_TALK, ""Volencia moss prefers rocks of high metal content and a frequently disturbed environment. There is some, I believe, to the south east of this village."") ; ops.add(""Farewell.""); })); return; } if (questStage == JunglePotion.FIND_ROGUES_PURSE) { player.startConversation(new Dialogue() .addNPC(npc, HeadE.CONFUSED, ""Welcome back.
Have you been successful in getting the rogue's purse, bwana?"") .addOptions((ops) -> { ops.add(""Of course!"") .addNext(() -> { if (player.getInventory().containsItem(junglePotionStageToCleanHerb(questStage))) { player.startConversation(new Dialogue() .addItem(junglePotionStageToCleanHerb(questStage), ""You give the rogue's purse to Trufitus."") .addNext(() -> player.getInventory().deleteItem((junglePotionStageToCleanHerb(questStage)), 1)) .addNPC(npc, HeadE.CALM_TALK, ""Most excellent, bwana! You have returned all the herbs to me."") .addNPC(npc, HeadE.HAPPY_TALKING, ""I can finish the preparations for the potion, and at last divine with the gods.
Many blessings upon you!"") .addNPC(npc, HeadE.CALM_TALK, ""I must now prepare.
Please excuse me while I make the arrangements."") .addNext(() -> player.getQuestManager().completeQuest(Quest.JUNGLE_POTION))) ; } else if (player.getInventory().containsItem(junglePotionStageToGrimyHerb(questStage))) { player.startConversation(grimyHerbReject); } else { player.startConversation(new Dialogue() .addNPC(npc, HeadE.SAD_MILD_LOOK_DOWN, ""Please don't try to deceive me.
I really need that rogue's purse if I am to make this potion."")) ; } }) ; ops.add(""What's the clue again?"") .addNPC(npc, HeadE.AMAZED, ""This herb is the most difficult to find, as it inhabits the darkness of the underground."") .addNPC(npc, HeadE.CALM_TALK, ""It is called 'rogue's purse', and is only to be found in pothole caverns in the northern part of this island."") .addNPC(npc, HeadE.CALM_TALK, ""A secret entrance to the pothole caverns is set into the northern cliffs of this land. Take care, bwana, as it may be dangerous."") ; ops.add(""Farewell.""); })); return; } }); }" "package com.rs.game.content.quests.knightssword; @QuestHandler( quest = Quest.KNIGHTS_SWORD, startText = ""Talk to Squire Asrol located in the White Knights' Castle's courtyard in Falador."", itemsText = ""Redberry pie, 2 iron bars."", combatText = ""You will need to defeat or evade level 54 enemies."", rewardsText = ""12,725 Smithing XP lamp
Ability to smith blurite (members)"", completedStage = 6 ) @PluginEventHandler public class KnightsSword extends QuestOutline { public static final int NOT_STARTED = 0; public static final int TALK_TO_RELDO = 1; public static final int FIND_DWARF = 2; public static final int GET_PICTURE = 3; public static final int GET_MATERIALS = 4; public static final int QUEST_COMPLETE = 6; //NPCs protected static final int RELDO = 647; protected static final int THURGO = 604; protected static final int SIR_VYVIN = 605; protected static final int SQUIRE = 606; //items protected static final int PORTRAIT = 666; protected static final int BLURITE_SWORD = 667; protected static final int BLURITE_ORE = 668; protected static final int IRON_BAR = 2351; protected static final int REDBERRY_PIE = 2325; //objects protected static final int CUPBOARD = 2271; @Override public List getJournalLines(Player player, int stage) { ArrayList lines = new ArrayList<>(); switch(stage) { case NOT_STARTED: lines.add(""Sir Vyvin's squire is in trouble. He has accidentally""); lines.add(""lost Sir Vyvin's ceremonial sword. Help him find a""); lines.add(""replacement without Sir Vyvin findingout.""); lines.add(""""); lines.add(""You can start this quest by talking to the Squire on""); lines.add(""the 1st floor of Falador castle""); lines.add(""""); break; case TALK_TO_RELDO: lines.add(""Reldo may know something about dwarves. You can find""); lines.add(""him at Varrock Castle.""); lines.add(""""); break; case FIND_DWARF: lines.add(""The dwarf is south of Port Sarim, living in a hut.""); lines.add(""Maybe he can help me restore the Knight's Sword? I""); lines.add(""also hear they like redberry pies...""); lines.add(""""); break; case GET_PICTURE: lines.add(""I will need a picture of the sword. Maybe the""); lines.add(""Squire knows where to find one...""); lines.add(""""); if(player.getQuestManager().getAttribs(Quest.KNIGHTS_SWORD).getB(""picture_location_known"")) { lines.add(""The squire says Sir Vyvin keeps an image of his sword ""); lines.add(""in a cupboard in his room on the 3rd floor on the east""); lines.add(""side of the castle. He can't know we are stealing it.""); lines.add(""""); } break; case GET_MATERIALS: lines.add(""I will need 1 blurite ore and 2 iron ingots to make""); lines.add(""the sword. I can get blurite ore from the mine next""); lines.add(""to the dwarf's hut.""); lines.add(""""); if(player.getInventory().containsItem(BLURITE_SWORD)) { lines.add(""Now that you have the sword you can give it to""); lines.add(""the squire...""); lines.add(""""); } break; case QUEST_COMPLETE: lines.add(""""); lines.add(""""); lines.add(""QUEST COMPLETE!""); break; default: lines.add(""Invalid quest stage. Report this to an administrator.""); break; } return lines; } @Override public void complete(Player player) { player.getSkills().addXpQuest(Constants.SMITHING, 12725); sendQuestCompleteInterface(player, BLURITE_SWORD); } public static ObjectClickHandler handleVyvinCupboard = new ObjectClickHandler(new Object[] { 2271, 2272 }, e -> { GameObject obj = e.getObject(); if (e.getOption().equalsIgnoreCase(""open"")) { e.getPlayer().setNextAnimation(new Animation(536)); e.getPlayer().lock(2); GameObject openedChest = new GameObject(obj.getId() + 1, obj.getType(), obj.getRotation(), obj.getX(), obj.getY(), obj.getPlane()); e.getPlayer().faceObject(openedChest); World.spawnObjectTemporary(openedChest, Ticks.fromMinutes(1)); } if (e.getOption().equalsIgnoreCase(""shut"")) { e.getPlayer().setNextAnimation(new Animation(536)); e.getPlayer().lock(2); GameObject openedChest = new GameObject(obj.getId() - 1, obj.getType(), obj.getRotation(), obj.getX(), obj.getY(), obj.getPlane()); e.getPlayer().faceObject(openedChest); World.spawnObjectTemporary(openedChest, Ticks.fromMinutes(1)); } if(e.getOption().equalsIgnoreCase(""search"")) { if(e.getPlayer().getQuestManager().getStage(Quest.KNIGHTS_SWORD) != GET_PICTURE) { e.getPlayer().sendMessage(""There is nothing interesting here...""); return; } for(NPC npc : World.getNPCsInChunkRange(e.getPlayer().getChunkId(), 1)) if(npc.getName().equalsIgnoreCase(""Sir Vyvin"")) if(npc.lineOfSightTo(e.getPlayer(), false)) { e.getPlayer().startConversation(new Conversation(e.getPlayer()) { { addPlayer(HeadE.SKEPTICAL_THINKING, ""Sir Vyvin can see me...""); create(); } }); return; } if(e.getPlayer().getInventory().containsItem(PORTRAIT)) e.getPlayer().sendMessage(""The cupboard is empty...""); else e.getPlayer().getInventory().addItem(new Item(PORTRAIT, 1)); } }); }" "package com.rs.game.content.quests.knightssword; @PluginEventHandler public class ReldoKnightsSwordD extends Conversation { public ReldoKnightsSwordD(Player player) { super(player); addPlayer(HeadE.HAPPY_TALKING, ""What do you know about the Imcando dwarves?""); addNPC(RELDO, HeadE.CALM_TALK, ""The Imcando dwarves, you say?""); addNPC(RELDO, HeadE.CALM_TALK, ""Ah yes... for many hundreds of years they were the world's most skilled smiths. They used secret smithing knowledge "" + ""passed down from generation to generation.""); addNPC(RELDO, HeadE.CALM_TALK, ""Unfortunately, about a century ago, the once thriving race was wiped out during the barbarian invasions of that time.""); addPlayer(HeadE.HAPPY_TALKING, ""So are there any Imcando left at all?""); addNPC(RELDO, HeadE.CALM_TALK, ""I believe a few of them survived, but with the bulk of their population destroyed their numbers have dwindled even further.""); addNPC(RELDO, HeadE.CALM_TALK, ""They tend to keep to themselves, and they tend not to tell people they're descendants of the Imcando, which is why "" + ""people think the tribe is extinct. However...""); addNPC(RELDO, HeadE.CALM_TALK, ""... you could try taking them some redberry pie. They REALLY like redberry pie. I believe I remember a couple living in "" + ""Asgarnia near the cliffs on the Asgarnian southern peninsula."", ()->{ if(player.getQuestManager().getStage(Quest.KNIGHTS_SWORD) == TALK_TO_RELDO) player.getQuestManager().setStage(Quest.KNIGHTS_SWORD, FIND_DWARF); }); } }" "package com.rs.game.content.quests.knightssword; @PluginEventHandler public class SquireKnightsSwordD extends Conversation { public static final int NEW_SWORD_CONVO = 0; public static final int ABUNDANT_WITH_SWORDS_CONVO = 1; public static final int DWARVES_MAKE_ANOTHER_CONVO = 2; public static final int VAGUE_AREA_CONVO = 3; public SquireKnightsSwordD(Player player) { super(player); if(player.getInventory().containsItem(BLURITE_SWORD)) { addNPC(SQUIRE, HeadE.CALM_TALK, ""That's it! That's the sword I need!""); addNPC(SQUIRE, HeadE.CALM_TALK, ""Please let me have it.""); addOptions(""Give the sword?"", new Options() { @Override public void create() { option(""You can have it"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Of course you can have it"") .addSimple(""You give the Squire the Knight's Sword."") .addNext(()-> { player.getInventory().removeItems(new Item(BLURITE_SWORD, 1)); player.getQuestManager().completeQuest(Quest.KNIGHTS_SWORD); }) ); option(""I think I will keep it."", new Dialogue() .addPlayer(HeadE.SKEPTICAL_THINKING, ""No, I think I will keep it"") .addNPC(SQUIRE, HeadE.SAD, ""Darn, what am I to do?"") ); } }); return; } switch (player.getQuestManager().getStage(Quest.KNIGHTS_SWORD)) { case NOT_STARTED -> addOptions(""Choose an option:"", new Options() { @Override public void create() { option(""And how is life as a squire?"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""And how is life as a squire?"") .addNPC(SQUIRE, HeadE.CALM_TALK, ""Well, Sir Vyvin is a good guy to work for, however, I'm in a spot of trouble today. I've gone "" + ""and lost Sir Vyvin's sword!"") .addOptions(""Choose an option:"", new Options() { @Override public void create() { option(""Do you know where you lost it?"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Do you know where you lost it?"") .addNPC(SQUIRE, HeadE.CALM_TALK, ""Well now, if I knew THAT it wouldn't be lost, now would it?"") .addOptions(""Choose an option:"", new Options() { @Override public void create() { option(""Well, do you know the VAGUE AREA you lost it?"", new Dialogue() .addNext(()->{player.startConversation(new SquireKnightsSwordD(player, VAGUE_AREA_CONVO).getStart());})); option(""I can make a new sword if you like..."", new Dialogue() .addNext(()->{player.startConversation(new SquireKnightsSwordD(player, NEW_SWORD_CONVO).getStart());})); option(""Well, the kingdom is fairly abundant with swords..."", new Dialogue() .addNext(()->{player.startConversation(new SquireKnightsSwordD(player, ABUNDANT_WITH_SWORDS_CONVO).getStart());})); } })); option(""I can make a new sword if you like..."", new Dialogue() .addNext(()->{player.startConversation(new SquireKnightsSwordD(player, NEW_SWORD_CONVO).getStart());})); option(""Is he angry?"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Is he angry?"") .addNPC(SQUIRE, HeadE.CALM_TALK, ""He doesn't know yet. I was hoping I could think of something to do before he does find out, But I find myself at a loss."") ); } })); option(""Wouldn't you prefer to be a squire for me?"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Wouldn't you prefer to be a squire for me?"") .addNPC(SQUIRE, HeadE.CALM_TALK, ""No, sorry, I'm loyal to Sir Vyvin."")); } }); case TALK_TO_RELDO -> { addNPC(SQUIRE, HeadE.CALM_TALK, ""So how are you doing getting a sword?""); addPlayer(HeadE.HAPPY_TALKING, ""I'm looking for Reldo to help me.""); addNPC(SQUIRE, HeadE.CALM_TALK, ""Please try and find him quickly... I am scared Sir Vyvin will find out!""); } case FIND_DWARF -> { addNPC(SQUIRE, HeadE.CALM_TALK, ""So how are you doing getting a sword?""); addPlayer(HeadE.HAPPY_TALKING, ""I'm looking for Imcando dwarves to help me.""); addNPC(SQUIRE, HeadE.CALM_TALK, ""Please try and find them quickly... I am scared Sir Vyvin will find out!""); } case GET_PICTURE -> { if(player.getQuestManager().getAttribs(Quest.KNIGHTS_SWORD).getB(""picture_location_known"")) { addNPC(SQUIRE, HeadE.CALM_TALK, ""Did you find the portrait?""); if(player.getInventory().containsItem(PORTRAIT)) { addPlayer(HeadE.HAPPY_TALKING, ""Yes, I just need to take it to the dwarf""); addNPC(SQUIRE, HeadE.CALM_TALK, ""Great!""); } else addPlayer(HeadE.CALM_TALK, ""No, not yet""); return; } addPlayer(HeadE.HAPPY_TALKING, ""I found the dwarf!""); addNPC(SQUIRE, HeadE.AMAZED_MILD, ""You found the dwarf?""); addPlayer(HeadE.HAPPY_TALKING, ""Yes, I found the dwarf...""); addNPC(SQUIRE, HeadE.CALM_TALK, ""So... What happened?""); addPlayer(HeadE.HAPPY_TALKING, ""He needs a picture of the sword to remake it.""); addNPC(SQUIRE, HeadE.SKEPTICAL_THINKING, ""Hmm...""); addNPC(SQUIRE, HeadE.CALM_TALK, ""Well, Sir Vyvin keeps a portrait with him holding it in his cupboard in his room.""); addNPC(SQUIRE, HeadE.CALM_TALK, ""You should get it without him knowing though. Don't let him see you. His room is on the 3rd floor on the east"" + "" side of the castle."", ()-> player.getQuestManager().getAttribs(Quest.KNIGHTS_SWORD).setB(""picture_location_known"", true)); } case GET_MATERIALS -> { addPlayer(HeadE.HAPPY_TALKING, ""I showed the dwarf the portrait. He said he could make it!""); addNPC(SQUIRE, HeadE.CALM_TALK, ""Oh I am glad to hear that!""); } } } public SquireKnightsSwordD(Player player, int convoID) { super(player); switch(convoID) { case NEW_SWORD_CONVO: makeNewSwordConvo(); break; case ABUNDANT_WITH_SWORDS_CONVO: abundantWithSwords(); break; case DWARVES_MAKE_ANOTHER_CONVO: dwarvesMakeAnother(); break; case VAGUE_AREA_CONVO: vagueArea(); break; } } private void makeNewSwordConvo() { addPlayer(HeadE.HAPPY_TALKING, ""I can make a new sword if you like...""); addNPC(SQUIRE, HeadE.CALM_TALK, ""Thanks for the offer. I'd be surprised if you could though.""); addNPC(SQUIRE, HeadE.CALM_TALK, ""The thing is, this sword is a family heirloom. It has been passed down through"" + "" Vyvin's family for five generations! It was originally made by the Imcando dwarves, who were""); addNPC(SQUIRE, HeadE.CALM_TALK, ""a particularly skilled tribe of dwarven smiths. I doubt anyone could make it"" + "" in the style they do.""); addOptions(""Choose an option:"", new Options() { @Override public void create() { option(""So would these dwarves make another one?"", new Dialogue() .addNext(()-> player.startConversation(new SquireKnightsSwordD(player, DWARVES_MAKE_ANOTHER_CONVO).getStart()))); option(""Well I hope you find it soon."", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Well, I hope you find it soon."") .addNPC(SQUIRE, HeadE.CALM_TALK, ""Yes, me too. I'm not looking forward to telling Vyvin I've lost it. "" + ""He's going to want it for the parade next week as well."")); } }); } private void abundantWithSwords() { addPlayer(HeadE.HAPPY_TALKING, ""Well, the kingdom is fairly abundant with swords...""); addNPC(SQUIRE, HeadE.CALM_TALK, ""Yes. You can get bronze swords anywhere. But THIS isn't any old sword.""); addNPC(SQUIRE, HeadE.CALM_TALK, ""The thing is, this sword is a family heirloom. It has been passed down through Vyvin's family for five generations! "" + ""It was originally made by the Imcando dwarves, who were""); addNPC(SQUIRE, HeadE.CALM_TALK, ""a particularly skilled tribe of dwarven smiths. I doubt anyone could make it in the style they do.""); addOptions(""Choose an option:"", new Options() { @Override public void create() { option(""So would these dwarves make another one?"", new Dialogue() .addNext(()-> player.startConversation(new SquireKnightsSwordD(player, DWARVES_MAKE_ANOTHER_CONVO).getStart()))); option(""Well I hope you find it soon."", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Well, I hope you find it soon."") .addNPC(SQUIRE, HeadE.CALM_TALK, ""Yes, me too. I'm not looking forward to telling Vyvin I've lost it. "" + ""He's going to want it for the parade next week as well."")); } }); } private void dwarvesMakeAnother() { addPlayer(HeadE.HAPPY_TALKING, ""So would these dwarves make another one?""); addNPC(SQUIRE, HeadE.CALM_TALK, ""I'm not a hundred percent sure the Imcando tribe exists anymore. "" + ""I should think Reldo, the palace librarian in Varrock, will know; he has done a lot of research "" + ""on the races of Gielinor.""); addNPC(SQUIRE, HeadE.CALM_TALK, ""I don't suppose you could try and track down the Imcando dwarves "" + ""for me? I've got so much work to do...""); addOptions(""Start Knight's Sword?"", new Options() { @Override public void create() { option(""Ok, I'll give it a go."", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Ok, I'll give it a go."", () -> player.getQuestManager().setStage(Quest.KNIGHTS_SWORD, TALK_TO_RELDO)) .addNPC(SQUIRE, HeadE.CALM_TALK, ""Thank you very much! As I say, the best place to "" + ""start should be with Reldo..."")); option(""No, I've got lots of mining work to do."", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""No, I've got lots of mining work to do."") .addNPC(SQUIRE, HeadE.CALM_TALK, ""Oh man... I'm in such trouble..."")); } }); } private void vagueArea() { addPlayer(HeadE.HAPPY_TALKING, ""Well, do you know the VAGUE AREA you lost it in?""); addNPC(SQUIRE, HeadE.CALM_TALK, ""No. I was carrying it for him all the way from where he had it stored"" + "" in Lumbridge. It must have slipped from my pack during the trip, and you know what people are like these days...""); addNPC(SQUIRE, HeadE.CALM_TALK, ""Someone will have just picked it up and kept it for themselves.""); addOptions(""Choose an option:"", new Options() { @Override public void create() { option(""I can make a new sword if you like..."", new Dialogue() .addNext(()-> player.startConversation(new SquireKnightsSwordD(player, NEW_SWORD_CONVO).getStart()))); option(""Well, the kingdom is fairly abundant with swords..."", new Dialogue() .addNext(()-> player.startConversation(new SquireKnightsSwordD(player, ABUNDANT_WITH_SWORDS_CONVO).getStart()))); option(""Well I hope you find it soon."", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Well, I hope you find it soon."") .addNPC(SQUIRE, HeadE.CALM_TALK, ""Yes, me too. I'm not looking forward to telling Vyvin I've lost it. "" + ""He's going to want it for the parade next week as well."")); } }); } }" "package com.rs.game.content.quests.knightssword; @PluginEventHandler public class ThurgoKnightsSwordD extends Conversation { public static final int WANT_PIE = 0; public ThurgoKnightsSwordD(Player player) { super(player); switch (player.getQuestManager().getStage(Quest.KNIGHTS_SWORD)) { case FIND_DWARF -> { if(player.getQuestManager().getAttribs(Quest.KNIGHTS_SWORD).getB(""gave_thurgo_pie"")) { addPlayer(HeadE.HAPPY_TALKING, ""Can you make a special sword for me?""); addNPC(THURGO, HeadE.CALM_TALK, ""Well, after bringing me my favorite food I guess I should give it a go. What sort of sword is it?""); addPlayer(HeadE.HAPPY_TALKING, ""I need you to make a sword for one of Falador's knights. He had one which was passed down through five "" + ""generations, but his squire has lost it.""); addPlayer(HeadE.HAPPY_TALKING, ""So we need an identical one to replace it.""); addNPC(THURGO, HeadE.CALM_TALK, ""A knight's sword eh? Well, I'd need to know exactly how it looked before I could make a new one.""); addNPC(THURGO, HeadE.CALM_TALK, ""All the Faladian knights used to have swords with unique designs according to their position. Could you"" + "" bring me a picture or something?""); addPlayer(HeadE.HAPPY_TALKING, ""I'll go and ask his squire and see if I can find one."", ()-> player.getQuestManager().setStage(Quest.KNIGHTS_SWORD, GET_PICTURE)); return; } if(!player.getInventory().containsItem(REDBERRY_PIE)){ addPlayer(HeadE.HAPPY_TALKING, ""Are you an Imcando dwarf? I need a special sword.""); addNPC(THURGO, HeadE.CALM_TALK, ""I don't talk about that sort of thing anymore. I'm getting old.""); addPlayer(HeadE.HAPPY_TALKING, ""I'll come back another time.""); } else addOptions(""Choose an option:"", new Options() { @Override public void create() { option(""Are you an Imcando dwarf? I need a special sword."", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Are you an Imcando dwarf? I need a special sword."") .addNPC(THURGO, HeadE.CALM_TALK, ""I don't talk about that sort of thing anymore. I'm getting old."") .addOptions(""Choose an option:"", new Options() { @Override public void create() { option(""Would you like a redberry pie?"", new Dialogue() .addNext(()-> player.startConversation(new ThurgoKnightsSwordD(player, WANT_PIE).getStart()))); option(""I'll come back another time."", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""I'll come back another time."")); } })); option(""Would you like a redberry pie?"", new Dialogue() .addNext(()-> player.startConversation(new ThurgoKnightsSwordD(player, WANT_PIE).getStart()))); } }); } case GET_PICTURE -> { addNPC(THURGO, HeadE.CALM_TALK, ""Did you get the picture of the sword?""); if(player.getInventory().containsItem(PORTRAIT)) { addPlayer(HeadE.HAPPY_TALKING, ""Yes, I got it here!""); addNPC(THURGO, HeadE.CALM_TALK, ""Great, let me take a look at it""); addSimple(""Thrugo looks at the portrait...""); addNPC(THURGO, HeadE.CALM_TALK, ""I can make this.""); addPlayer(HeadE.HAPPY_TALKING, ""Really? Great!""); addNPC(THURGO, HeadE.CALM_TALK, ""I am going to need 1 blurite ore and 2 iron bars though""); addPlayer(HeadE.HAPPY_TALKING, ""Awesome I will fetch that.""); addNPC(THURGO, HeadE.CALM_TALK, ""Great.""); addPlayer(HeadE.HAPPY_TALKING, ""But, where do I find blurite ore?""); addNPC(THURGO, HeadE.CALM_TALK, ""Oh there is some underground around here by all the ice.""); addPlayer(HeadE.HAPPY_TALKING, ""Great... I have to go underground?""); addNPC(THURGO, HeadE.CALM_TALK, ""Yep."", ()->{ player.getInventory().removeItems(new Item(PORTRAIT, 1)); player.getQuestManager().setStage(Quest.KNIGHTS_SWORD, GET_MATERIALS); }); } else addPlayer(HeadE.SAD, ""Not yet...""); } case GET_MATERIALS -> { if(player.getInventory().containsItem(BLURITE_SWORD)) { addPlayer(HeadE.HAPPY_TALKING, ""Thank you for the sword!""); addNPC(THURGO, HeadE.CALM_TALK, ""No problem!""); return; } if(player.getQuestManager().getAttribs(Quest.KNIGHTS_SWORD).getB(""made_sword"")) addPlayer(HeadE.SAD, ""I lost the sword! Can I have another?""); addNPC(THURGO, HeadE.CALM_TALK, ""Do you have the materials?""); if(player.getInventory().containsItem(BLURITE_ORE, 1) && player.getInventory().containsItem(IRON_BAR, 2)) { addPlayer(HeadE.HAPPY_TALKING, ""Yes, I have them right here!""); addNPC(THURGO, HeadE.CALM_TALK, ""Great, okay I will get started...""); addSimple(""Thurgo makes you a blurite sword"", () -> { player.getInventory().removeItems(new Item(BLURITE_ORE, 1), new Item(IRON_BAR, 2)); player.getInventory().addItem(new Item(BLURITE_SWORD, 1)); player.getQuestManager().getAttribs(Quest.KNIGHTS_SWORD).setB(""made_sword"", true); }); } else { addPlayer(HeadE.HAPPY_TALKING, ""No, not yet.""); addSimple(""You need 1 blurite ore and 2 iron bars...""); } } case QUEST_COMPLETE -> { addPlayer(HeadE.HAPPY_TALKING, ""Can you make me another of Sir Vyvin's swords?""); addNPC(THURGO, HeadE.CALM_TALK, ""You want that knight's sword again? I suppose you brought me a lovely pie, so I don't mind. I'll need a blurite ore and two iron bars, like before.""); if(player.getInventory().containsItem(BLURITE_ORE, 1) && player.getInventory().containsItem(IRON_BAR, 2)) addSimple(""Thurgo makes you another blurite sword"", ()->{ player.getInventory().removeItems(new Item(BLURITE_ORE, 1), new Item(IRON_BAR, 2)); player.getInventory().addItem(new Item(BLURITE_SWORD, 1)); }); else addSimple(""You need 1 blurite ore and 2 iron bars...""); } } } public ThurgoKnightsSwordD(Player player, int convoID) { super(player); switch(convoID) { case WANT_PIE: wantPie(); break; } } private void wantPie() { addPlayer(HeadE.HAPPY_TALKING, ""Would you like a redberry pie?""); addSimple(""You see Thurgo's eyes light up.""); addNPC(THURGO, HeadE.HAPPY_TALKING, ""I'd never say no to a redberry pie! We Imcando dwarves love them - they're GREAT!""); addSimple(""You hand over the pie.""); addSimple(""Thurgo eats the pie.""); addSimple(""Thurgo pats his stomach.""); addNPC(THURGO, HeadE.HAPPY_TALKING, ""By Guthix! THAT was good pie! Anyone who makes pie like THAT has got to be alright!"", ()->{ player.getInventory().removeItems(new Item(REDBERRY_PIE, 1)); player.getQuestManager().getAttribs(Quest.KNIGHTS_SWORD).setB(""gave_thurgo_pie"", true); }); } }" "package com.rs.game.content.quests.lostcity; @PluginEventHandler public class ArcherLostCityD extends Conversation { public ArcherLostCityD(Player player) { super(player); switch(player.getQuestManager().getStage(Quest.LOST_CITY)) { case NOT_STARTED -> { addPlayer(HeadE.HAPPY_TALKING, ""Why are you guys hanging around here?""); addNPC(ARCHER, HeadE.SKEPTICAL, ""(ahem)... 'Guys'?""); addPlayer(HeadE.HAPPY_TALKING, ""Um... yeah, sorry about that. Why are you all standing around out here?""); addNPC(ARCHER, HeadE.FRUSTRATED, ""Well, that's really none of your business.""); } case TALK_TO_LEPRAUCAN -> { addPlayer(HeadE.HAPPY_TALKING, ""So I hear theres a leprechaun around here who can show me the way to Zanaris?""); addNPC(ARCHER, HeadE.AMAZED_MILD, ""... W-what? How did you...? No. You're wrong. Now go away.""); } case CHOP_DRAMEN_TREE, FIND_ZANARIS, QUEST_COMPLETE -> { addPlayer(HeadE.HAPPY_TALKING, ""So you didn't find the entrance to Zanaris yet, huh?""); addNPC(ARCHER, HeadE.FRUSTRATED, ""Don't tell me a novice like YOU has found it!""); addPlayer(HeadE.AMAZED_MILD, ""Yep. Found it REALLY easily too.""); addNPC(ARCHER, HeadE.FRUSTRATED, ""...I cannot believe that someone like you could find the portal when experienced adventurers such as "" + ""ourselves could not.""); addPlayer(HeadE.FRUSTRATED, ""Believe what you want. Enjoy your little camp fire.""); } } } public static NPCClickHandler handleArcherDialogue = new NPCClickHandler(new Object[] { ARCHER }, e -> e.getPlayer().startConversation(new ArcherLostCityD(e.getPlayer()).getStart())); }" "package com.rs.game.content.quests.lostcity; @PluginEventHandler public class DramenTreeBoss { public static ObjectClickHandler handleDramenTree = new ObjectClickHandler(new Object[] { ""Dramen tree"" }, e -> { GameObject obj = e.getObject(); if(e.getPlayer().getQuestManager().getStage(Quest.LOST_CITY) == LostCity.CHOP_DRAMEN_TREE) { if(!e.getPlayer().inCombat()) { for (NPC npc : World.getNPCsInChunkRange(e.getPlayer().getChunkId(), 4)) if (npc.getId() == TREE_SPIRIT) { npc.forceTalk(""You must defeat me before touching the tree!""); return; } NPC spirit = World.spawnNPC(TREE_SPIRIT, Tile.of(obj.getX(), obj.getY() + 2, obj.getPlane()), -1, false, true); spirit.setTarget(e.getPlayer()); spirit.forceTalk(""You must defeat me before touching the tree!""); } }else if(e.getPlayer().isQuestComplete(Quest.LOST_CITY) || e.getPlayer().getQuestManager().getStage(Quest.LOST_CITY) >= LostCity.FIND_ZANARIS) { if (e.getObject().getDefinitions().containsOption(0, ""Chop down"")) e.getPlayer().getActionManager().setAction(new Woodcutting(e.getObject(), TreeType.DRAMEN) { @Override public void fellTree() { } }); } else e.getPlayer().sendMessage(""The tree seems to have a ominous aura to it. You do not feel like chopping it down.""); }); public static NPCDeathHandler handleTreeSpiritDeath = new NPCDeathHandler(TREE_SPIRIT, e -> { if(e.killedByPlayer() && ((Player)e.getKiller()).getQuestManager().getStage(Quest.LOST_CITY) == LostCity.CHOP_DRAMEN_TREE) ((Player)e.getKiller()).getQuestManager().setStage(Quest.LOST_CITY, LostCity.FIND_ZANARIS); }); }" "package com.rs.game.content.quests.lostcity; @PluginEventHandler public class LeprecaunLostCityD extends Conversation { private final int FORGETTINGTOSAY = 0; public LeprecaunLostCityD(Player p, NPC leprechaun) { super(p); switch(p.getQuestManager().getStage(Quest.LOST_CITY)) { case NOT_STARTED -> { addNPC(LEPRACAUN, HeadE.VERY_FRUSTRATED, ""Ah, yer big elephant! Yer've caught me! What would an elephant like yer be wanting wid ol' Shamus, then?""); addPlayer(HeadE.HAPPY_TALKING, ""I'm not sure.""); addNPC(LEPRACAUN, HeadE.FRUSTRATED, ""Well that's just great, you nuisance!""); } case TALK_TO_LEPRAUCAN -> { addNPC(LEPRACAUN, HeadE.CALM_TALK, ""Ah, yer big elephant! Yer've caught me! What would an elephant like yer be wanting wid ol' Shamus, then?""); addPlayer(HeadE.HAPPY_TALKING, ""I want to find Zanaris.""); addNPC(LEPRACAUN, HeadE.CALM_TALK, ""Zanaris, is it now? Well, well, well... You'll be needing that funny little shed out there in the swamp, so you will.""); addPlayer(HeadE.HAPPY_TALKING, ""Shed? I thought Zanaris was a city.""); addNPC(LEPRACAUN, HeadE.CALM_TALK, ""Aye, that it is!""); addOptions(""Choose an option:"", new Options() { @Override public void create() { option(""How does it fit in a shed, then?"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""How does it fit in a shed, then?"") .addNPC(LEPRACAUN, HeadE.CALM_TALK, ""Ah, yer stupid elephant! The city isn't IN the shed! The doorway to the shed is a portal to "" + ""Zanaris, so it is."") .addPlayer(HeadE.HAPPY_TALKING, ""So, I just walk into the shed and end up in Zanaris?"") .addNext(()-> p.startConversation(new LeprecaunLostCityD(p, leprechaun, FORGETTINGTOSAY).getStart())) ); option(""I've been in that shed and I didn't see a city."", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""I've been in that shed and I didn't see a city."") .addNext(()-> p.startConversation(new LeprecaunLostCityD(p, leprechaun, FORGETTINGTOSAY).getStart())) ); } }); } case CHOP_DRAMEN_TREE -> { addPlayer(HeadE.HAPPY_TALKING, ""I am still looking for Zanaris.""); addNPC(LEPRACAUN, HeadE.CALM_TALK, ""Did yer need a teleport over to Port Sarim?""); addOptions(""Teleport to Port Sarim?"", new Options() { @Override public void create() { option(""Yes, please, a teleport would be useful."", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Yes, please, a teleport would be useful."") .addNPC(LEPRACAUN, HeadE.CALM_TALK, ""Right yer are. Hold on!"") .addNext(()-> { leprechaun.resetWalkSteps(); leprechaun.faceEntity(p); leprechaun.setNextAnimation(new Animation(5488)); leprechaun.forceTalk(""Avach Sarimporto!""); Magic.sendObjectTeleportSpell(p, false, Tile.of(3047, 3236, 0)); })); option(""No thanks, I'll get there on my own"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""No thanks, I'll get there on my own"") .addNPC(LEPRACAUN, HeadE.CALM_TALK, ""Fine, have it yer way. I'm off!"") .addNext(leprechaun::finish)); } }); } case FIND_ZANARIS, QUEST_COMPLETE -> { addNPC(LEPRACAUN, HeadE.CALM_TALK, ""Ah, yer big elephant! Yer've caught me! What would an elephant like yer be wanting wid ol' Shamus, then?""); addOptions(""Choose an option:"", new Options() { @Override public void create() { option(""I'm not sure"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""I'm not sure"") .addNPC(LEPRACAUN, HeadE.CALM_TALK, ""Ha! Look at yer! Look at the stupid elephant who tries to go catching a leprechaun "" + ""when he don't even be knowing what he wants!"") .addNext(() -> { leprechaun.finish(); p.sendMessage(""The leprechaun magically disappears.""); })); option(""How do I get to Zanaris again?"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""How do I get to Zanaris again?"") .addNPC(LEPRACAUN, HeadE.CALM_TALK, ""Yer stupid elephant! I'll tell yer again! Yer need to be entering the shed in the "" + ""middle of the swamp while holding a dramen staff."") .addNPC(LEPRACAUN, HeadE.CALM_TALK, ""Yer can make the dramen staff from a dramen tree branch, and there's a dramen tree on Entrana. "" + ""now leave me alone, yer great elephant."") .addNext(() -> { leprechaun.finish(); p.sendMessage(""The leprechaun magically disappears.""); })); } }); } } } public LeprecaunLostCityD(Player p, NPC leprechaun, int id) { super(p); switch(id) { case FORGETTINGTOSAY -> { addNPC(LEPRACAUN, HeadE.CALM_TALK, ""Oh, was I forgetting to say? Ya need to be carrying a dramen staff to be getting there! Otherwise, yer'll "" + ""just be ending up in the shed.""); addPlayer(HeadE.HAPPY_TALKING, ""Where could I get such a staff?""); addNPC(LEPRACAUN, HeadE.CALM_TALK, ""Dramen staves are crafted from branches of the dramen tree, so they are. I hear there's a dramen tree in a "" + ""cave over on the island of Entrana.""); addNPC(LEPRACAUN, HeadE.CALM_TALK, ""There would probably be a good place for an elephant like yer to look, I reckon. The monks are running a ship "" + ""from Port Sarim to Entrana, so I hear.""); addNPC(LEPRACAUN, HeadE.CALM_TALK, ""Did yer need a teleport over to Port Sarim?""); addOptions(""Teleport to Port Sarim?"", new Options() { @Override public void create() { option(""Yes, please, a teleport would be useful."", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Yes, please, a teleport would be useful."") .addNPC(LEPRACAUN, HeadE.CALM_TALK, ""Right yer are. Hold on!"") .addNext(()-> { p.getQuestManager().setStage(Quest.LOST_CITY, CHOP_DRAMEN_TREE); leprechaun.resetWalkSteps(); leprechaun.faceEntity(p); leprechaun.setNextAnimation(new Animation(5488)); leprechaun.forceTalk(""Avach Sarimporto!""); Magic.sendObjectTeleportSpell(p, false, Tile.of(3047, 3236, 0)); }) ); option(""No thanks, I'll get there on my own"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""No thanks, I'll get there on my own"") .addNPC(LEPRACAUN, HeadE.CALM_TALK, ""Fine, have it yer way. I'm off!"") .addNext(()-> { p.getQuestManager().setStage(Quest.LOST_CITY, CHOP_DRAMEN_TREE); leprechaun.finish(); }) ); } }); } } } public static ObjectClickHandler handleTreeLep = new ObjectClickHandler(true, new Object[] { LEPRACAUN_TREE }, e -> { GameObject obj = e.getObject(); for(NPC npc : World.getNPCsInChunkRange(e.getPlayer().getChunkId(), 1)) if(npc.getId() == LEPRACAUN) return; e.getPlayer().startConversation(new Conversation(e.getPlayer()) { { addNPC(LEPRACAUN, HeadE.FRUSTRATED, ""Hey! Yer big elephant! Don't go choppin' down me house, now!""); addNPC(LEPRACAUN, HeadE.AMAZED_MILD, ""Woah, woah!""); addNPC(LEPRACAUN, HeadE.AMAZED, ""AAAAAAAAAAAAAAHHHH!!!!""); addSimple(""The leprechaun falls down"", () -> { NPC lepracaun = World.spawnNPC(LEPRACAUN, Tile.of(obj.getX(), obj.getY()-1, obj.getPlane()), -1, false, true); WorldTasks.scheduleLooping(new Task() { private int tick; @Override public void run() { if(tick == 1) lepracaun.forceTalk(""Ouch!!""); if(tick == 10) lepracaun.forceTalk(""My aching back...""); if(tick == 30) lepracaun.forceTalk(""Might need to walk this off...""); if(tick == 60) lepracaun.forceTalk(""Oww, that's sore...""); if(tick == 85) { lepracaun.forceTalk(""Welp, better head home...""); lepracaun.walkToAndExecute(Tile.of(obj.getX(), obj.getY()-1, obj.getPlane()), ()->{ lepracaun.forceTalk(""Back up the tree...""); if(!lepracaun.hasFinished()) lepracaun.finish(); }); } if(tick == 90) { if(!lepracaun.hasFinished()) lepracaun.finish(); stop(); } tick++; } }, 0, 1); }); create(); } }); }); public static NPCClickHandler handleLeprecaunDialogue = new NPCClickHandler(new Object[] { LEPRACAUN }, e -> e.getPlayer().startConversation(new LeprecaunLostCityD(e.getPlayer(), e.getNPC()).getStart())); }" "package com.rs.game.content.quests.lostcity; @QuestHandler( quest = Quest.LOST_CITY, startText = ""Talk to warrior adventurer in the Lumbridge Swamp."", itemsText = ""None."", combatText = ""You will need to defeat a level 63 tree spirit."", rewardsText = ""Access to Zanaris
Ability to wield dragon longswords and dragon daggers
Ability to craft cosmic runes
Access to Chaeldar the Slayer master (requires level 75 combat)"", completedStage = 4 ) @PluginEventHandler public class LostCity extends QuestOutline { public final static int NOT_STARTED = 0; public final static int TALK_TO_LEPRAUCAN = 1; public final static int CHOP_DRAMEN_TREE = 2; public final static int FIND_ZANARIS = 3; public final static int QUEST_COMPLETE = 4; //NPCs protected final static int ARCHER = 649; protected final static int WARRIOR = 650; protected final static int MONK = 651; protected final static int WIZARD = 652; protected final static int LEPRACAUN = 654; protected final static int TREE_SPIRIT = 655; //Objects protected final static int LEPRACAUN_TREE = 2409; // protected final static int protected final static int DRAMEN_STAFF = 772; @Override public List getJournalLines(Player player, int stage) { ArrayList lines = new ArrayList<>(); switch(stage) { case NOT_STARTED: lines.add(""Legends tell of a magical lost city hidden in the swamps.""); lines.add(""Many adventurers have tried to find this city, but it is""); lines.add(""proving difficult. Can you unlock the secrets of the city""); lines.add(""of Zanaris?""); lines.add(""""); lines.add(""I can start this quest by talking to a warrior in Lumbridge Swamp.""); lines.add(""You will need to puzzle through the dialogues to start the quest.""); lines.add(""Come back here to see when to look for the dramen branches.""); lines.add(""""); lines.add(""~~Requirements~~""); lines.add(""31 Crafting""); lines.add(""36 Woodcutting""); lines.add(""""); break; case TALK_TO_LEPRAUCAN: lines.add(""The warrior in Lumbridge Swamp said I am to find a leprecaun in the""); lines.add(""area by trying to chop down trees?""); lines.add(""""); break; case CHOP_DRAMEN_TREE: lines.add(""I am to go to Entrana and chop a dramen tree""); lines.add(""""); break; case FIND_ZANARIS: lines.add(""Now that I have a dramen branch I should turn it into a staff and""); lines.add(""head to Lumbridge Swamp where I can find a shed. If I enter it with""); lines.add(""the staff in hand, I should be able to get to Zanaris...""); lines.add(""""); break; case QUEST_COMPLETE: lines.add(""I have found Zanaris!""); lines.add(""""); lines.add(""""); lines.add(""QUEST COMPLETE!""); break; default: lines.add(""Invalid quest stage. Report this to an administrator.""); break; } return lines; } public static ObjectClickHandler handleShedDoor = new ObjectClickHandler(new Object[] { 2406 }, e -> { GameObject obj = e.getObject(); Doors.handleDoor(e.getPlayer(), obj); if(e.getPlayer().getX() <= obj.getX()) if(e.getPlayer().getEquipment().getWeaponId() == DRAMEN_STAFF && e.getPlayer().getQuestManager().getStage(Quest.LOST_CITY) >= FIND_ZANARIS) WorldTasks.scheduleLooping(new Task() { int tick; @Override public void run() { if(tick == 1) { e.getPlayer().sendMessage(""The world starts to shimmer...""); FairyRings.sendTeleport(e.getPlayer(), Tile.of(2452, 4473, 0)); e.getPlayer().lock(4); } if(tick == 4) if(!e.getPlayer().isQuestComplete(Quest.LOST_CITY)) { e.getPlayer().lock(3);//so players dont cancel it out by accident and not see it... e.getPlayer().getQuestManager().completeQuest(Quest.LOST_CITY); } if(tick == 5) stop(); tick++; } }, 0, 1); }); @Override public void complete(Player player) { sendQuestCompleteInterface(player, 772); } }" "package com.rs.game.content.quests.lostcity; @PluginEventHandler public class MonkLostCityD extends Conversation { public MonkLostCityD(Player player) { super(player); switch(player.getQuestManager().getStage(Quest.LOST_CITY)) { case NOT_STARTED -> { addPlayer(HeadE.HAPPY_TALKING, ""Why are all of you standing around here?""); addNPC(MONK, HeadE.FRUSTRATED, ""None of your business. Get lost.""); } case TALK_TO_LEPRAUCAN -> { addPlayer(HeadE.HAPPY_TALKING, ""Have you found the tree with the leprechaun yet?""); addNPC(MONK, HeadE.SKEPTICAL_THINKING, ""No, we've looked for ages but haven't... Hey! Wait a minute! How did you know about that?""); addPlayer(HeadE.HAPPY_TALKING, ""Thanks for the information!""); addNPC(MONK, HeadE.FRUSTRATED, ""...You tricked me. I'm not talking to you anymore.""); } case CHOP_DRAMEN_TREE, FIND_ZANARIS, QUEST_COMPLETE -> addNPC(MONK, HeadE.FRUSTRATED, ""I already told you. I'm not talking to you anymore.""); } } public static NPCClickHandler handleMonkDialogue = new NPCClickHandler(new Object[] { MONK }, e -> e.getPlayer().startConversation(new MonkLostCityD(e.getPlayer()).getStart())); }" "package com.rs.game.content.quests.lostcity; @PluginEventHandler public class WarriorLostCityD extends Conversation { private final int LOOKINGFORZANARIS = 0; private final int LOOKFORLEPRECAUN = 1; public WarriorLostCityD(Player player) { super(player); switch(player.getQuestManager().getStage(Quest.LOST_CITY)) { case NOT_STARTED -> { addNPC(WARRIOR, HeadE.CALM_TALK, ""Hello there, traveler""); addOptions(""Choose an option:"", new Options() { @Override public void create() { option(""Why are you camped out here?"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Why are you camped out here?"") .addNPC(WARRIOR, HeadE.CALM_TALK, ""We're looking for Zanaris...GAH! I mean we're not here for any particular reason at all"") .addNext(()-> player.startConversation(new WarriorLostCityD(player, LOOKINGFORZANARIS).getStart())) ); option(""Do you know any good adventurers I can go on?"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Do you know any good adventurers I can go on?"") .addNPC(WARRIOR, HeadE.CALM_TALK, ""Well, we're on an adventure right now. Mind you, this is OUR adventure and we don't want to"" + "" share it - find your own!"") .addOptions(""Choose an option:"", new Options() { @Override public void create() { option(""Please tell me"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Please tell me?"") .addNPC(WARRIOR, HeadE.CALM_TALK, ""No."") .addPlayer(HeadE.HAPPY_TALKING, ""Please?"") .addNPC(WARRIOR, HeadE.FRUSTRATED, ""No!"") .addPlayer(HeadE.AMAZED_MILD, ""PLEEEEEEEEEEEEEEEEEEEEEEASE???"") .addNPC(WARRIOR, HeadE.VERY_FRUSTRATED, ""NO!"") ); option(""I don't think you've found a good adventure at all!"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""I don't think you've found a good adventure at all!"") .addNPC(WARRIOR, HeadE.CALM_TALK, ""Hah! Adventurers of our caliber don't just hang around in forests for fun, whelp!"") .addPlayer(HeadE.HAPPY_TALKING, ""Oh really? Why are you camped out here?"") .addNPC(WARRIOR, HeadE.CALM_TALK, ""We're looking for Zanaris...GAH! I mean we're not here for any particular reason at all"") .addNext(()-> player.startConversation(new WarriorLostCityD(player, LOOKINGFORZANARIS).getStart())) ); } }) ); } }); } case TALK_TO_LEPRAUCAN -> { addPlayer(HeadE.HAPPY_TALKING, ""So let me get this straight. I need to search the trees around here for a leprechaun. Then, when I find him, "" + ""he will tell me where this 'Zanaris' is?""); addNPC(WARRIOR, HeadE.CALM_TALK, ""What? How did you know that? Uh... I mean, no, no you're very wrong. Very wrong, and not right at all, and "" + ""I definitely didn't tell you about that at all.""); } case CHOP_DRAMEN_TREE, FIND_ZANARIS -> { addPlayer(HeadE.HAPPY_TALKING, ""Have you found anything yet?""); addNPC(WARRIOR, HeadE.CALM_TALK, ""We're still searching for Zanaris... GAH! I mean we're not doing anything here at all.""); addPlayer(HeadE.HAPPY_TALKING, ""I haven't found it yet either.""); } case QUEST_COMPLETE -> { addPlayer(HeadE.HAPPY_TALKING, ""Hey, thanks for all the information. It REALLY helped me out in finding the lost city of Zanaris and all.""); addNPC(WARRIOR, HeadE.SCARED, ""Oh, please don't say that anymore! If the rest of my party knew I'd helped you, they'd probably throw me out and make me walk home by myself! ""); addNPC(WARRIOR, HeadE.HAPPY_TALKING, ""So anyway, what have you found out? Where is the fabled Zanaris? Is it all the legends say it is?""); addPlayer(HeadE.SECRETIVE, ""You know...I think I'll keep that to myself.""); } } } public WarriorLostCityD(Player p, int id) { super(p); switch(id) { case LOOKINGFORZANARIS -> addOptions(""Choose an option:"", new Options() { @Override public void create() { option(""Who's Zanaris?"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Who's Zanaris?"") .addNPC(WARRIOR, HeadE.CALM_TALK, ""Ahahahaha! Zanaris isn't a person! It's a magical hidden city filled with treasures and "" + ""rich... uh, nothing, it's nothing."") .addOptions(""Choose an option:"", new Options() { @Override public void create() { option(""If it's hidden, how are you planning to find it?"", new Dialogue() .addNext(()->{p.startConversation(new WarriorLostCityD(p, LOOKFORLEPRECAUN).getStart());}) ); option(""There's no such thing"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""There's no such thing!"") .addNPC(WARRIOR, HeadE.CALM_TALK, ""When we've found Zanaris, you'll... GAH! I mean, we're not here for any "" + ""particular reason at all."") .addNext(()->{p.startConversation(new WarriorLostCityD(p, LOOKINGFORZANARIS).getStart());}) ); } }) ); option(""What's Zanaris?"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""What's Zanaris?"") .addNPC(WARRIOR, HeadE.CALM_TALK, ""I don't think we want other people competing with us to find it. Forget I said anything."") ); option(""What makes you think it's out here?"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""What makes you think it's out here?"") .addNPC(WARRIOR, HeadE.CALM_TALK, ""Don't you know of the legends that tell of the magical city, hidden in the swam... "" + ""Uh, no, you're right, we're wasting our time here."") .addPlayer(HeadE.HAPPY_TALKING, ""If it's hidden, how are you planning to find it?"") .addNext(()->{p.startConversation(new WarriorLostCityD(p, LOOKFORLEPRECAUN).getStart());}) ); } }); case LOOKFORLEPRECAUN -> { addPlayer(HeadE.HAPPY_TALKING, ""If it's hidden, how are you planning to find it?""); addNPC(WARRIOR, HeadE.CALM_TALK, ""Well, we don't want to tell anyone else about that, because we don't want anyone else sharing in all the "" + ""glory and treasure.""); addOptions(""Choose an option:"", new Options() { @Override public void create() { option(""Please tell me"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Please tell me?"") .addNPC(WARRIOR, HeadE.CALM_TALK, ""No."") .addPlayer(HeadE.HAPPY_TALKING, ""Please?"") .addNPC(WARRIOR, HeadE.FRUSTRATED, ""No!"") .addPlayer(HeadE.AMAZED_MILD, ""PLEEEEEEEEEEEEEEEEEEEEEEASE???"") .addNPC(WARRIOR, HeadE.VERY_FRUSTRATED, ""NO!"")); option(""Looks like you don't know either"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Well, it looks to me like YOU don't know EITHER seeing as you're all just sat around here."") .addNPC(WARRIOR, HeadE.CALM_TALK, ""Of course we know! We just haven't figured out which tree the stupid leprechaun's hiding in "" + ""yet! GAH! I didn't mean to tell you that! Look, just forget I said anything okay?"") .addPlayer(HeadE.HAPPY_TALKING, ""So a leprechaun knows where Zanaris is, eh?"") .addNPC(WARRIOR, HeadE.CALM_TALK, ""Ye... uh, no. No, not at all. And even if he did - which he doesn't - he DEFINETLY ISN'T "" + ""hiding in some tree around here. Nope, definitely not. Honestly."") .addOptions(""Start Lost City?"", new Options() { @Override public void create() { if(p.getSkills().getLevel(Constants.CRAFTING) >= 31 && p.getSkills().getLevel(Constants.WOODCUTTING) >= 36) option(""Yes"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Thanks for the help!"", () -> p.getQuestManager().setStage(Quest.LOST_CITY, TALK_TO_LEPRAUCAN)) .addNPC(WARRIOR, HeadE.CALM_TALK, ""Help, What help? I didn't help! Please don't say I did, I'll get in trouble!"") ); else option(""Yes"", new Dialogue() .addSimple(""You don't have the skill levels to start this quest..."", () ->{ if(p.getSkills().getLevel(Constants.CRAFTING) < 31) p.sendMessage(""You need 31 crafting.""); if(p.getSkills().getLevel(Constants.WOODCUTTING) < 36) p.sendMessage(""You need 36 woodcutting.""); }) ); option(""No"", new Dialogue()); } }) ); } }); } } } public static NPCClickHandler handleWarriorDialogue = new NPCClickHandler(new Object[] { WARRIOR }, e -> e.getPlayer().startConversation(new WarriorLostCityD(e.getPlayer()).getStart())); }" "package com.rs.game.content.quests.lostcity; @PluginEventHandler public class WizardLostCityD extends Conversation { public WizardLostCityD(Player player) { super(player); switch(player.getQuestManager().getStage(Quest.LOST_CITY)) { case NOT_STARTED -> { addPlayer(HeadE.HAPPY_TALKING, ""Why are all of you standing around here?""); addNPC(WIZARD, HeadE.LAUGH, ""Hahaha, you dare talk to a mighty wizard such as myself? I bet you can't even cast Air Strike yet, amateur!""); addPlayer(HeadE.FRUSTRATED, ""...You're an idiot.""); } case TALK_TO_LEPRAUCAN -> { addPlayer(HeadE.HAPPY_TALKING, ""Found that leprechaun yet?""); addNPC(WIZARD, HeadE.LAUGH, ""Hahaha! Go away, amateur! You're not worthy of joining our great group!""); addPlayer(HeadE.FRUSTRATED, ""...Right.""); } case CHOP_DRAMEN_TREE, FIND_ZANARIS, QUEST_COMPLETE -> { addNPC(WIZARD, HeadE.LAUGH, ""Hahaha, you're such an amateur! Go and play with some cabbage, amateur!""); addPlayer(HeadE.SECRETIVE, ""...Right.""); } } } public static NPCClickHandler handleWizardDialogue = new NPCClickHandler(new Object[] { WIZARD }, e -> e.getPlayer().startConversation(new WizardLostCityD(e.getPlayer()).getStart())); }" "package com.rs.game.content.quests.merlinscrystal; @PluginEventHandler public class BeggarMerlinsCrystalD extends Conversation { final static int NPC=252; final static int BREAD = 2309; final static int LADYLAKE=250; public BeggarMerlinsCrystalD(Player player) { super(player); if(player.getQuestManager().getAttribs(Quest.MERLINS_CRYSTAL).getB(""LADY_TEST"")) { if (player.getQuestManager().getAttribs(Quest.MERLINS_CRYSTAL).getB(""KNOWS_BEGGAR"")) { if (player.getInventory().containsItem(BREAD, 1)) { addNPC(NPC, HeadE.CALM_TALK, ""Do you have the bread now?""); addNext(() -> player.startConversation(new BeggarMerlinsCrystalD(player, true).getStart())); } else { addNPC(NPC, HeadE.CALM_TALK, ""Have you got any bread for me yet?""); addPlayer(HeadE.HAPPY_TALKING, ""No, not yet.""); } } else { addNPC(NPC, HeadE.CALM_TALK, ""Please... my family and I are starving... Could you find it in your heart to spare me a simple loaf of bread?""); if(player.getInventory().containsItem(BREAD, 1)) addNext(() -> player.startConversation(new BeggarMerlinsCrystalD(player, true).getStart())); else addPlayer(HeadE.HAPPY_TALKING, ""... except I don't have any bread on me at the moment...""); } } else { addNPC(NPC, HeadE.CALM_TALK, ""Hold on, I am testing someone to see if they are worthy.""); addPlayer(HeadE.HAPPY_TALKING, ""Weird, but okay""); } } public BeggarMerlinsCrystalD(Player p, boolean filler) { super(p); NPC buff = null; for(NPC npc : World.getNPCsInChunkRange(p.getChunkId(), 1)) if(npc.getId() == NPC) buff = npc; NPC beggar = buff; addPlayer(HeadE.HAPPY_TALKING, ""Yes certainly""); addSimple(""You give the beggar some bread""); addNPC(LADYLAKE, HeadE.CALM_TALK, ""Well done. You have passed my test. Here is Excalibur, guard it well."", ()->{ p.getInventory().removeItems(new Item(BREAD, 1)); p.getInventory().addItem(new Item(EXCALIBUR, 1)); p.getQuestManager().setStage(Quest.MERLINS_CRYSTAL, PERFORM_RITUAL); if(beggar != null) { beggar.transformIntoNPC(LADYLAKE); beggar.forceTalk(""Well done!""); beggar.finishAfterTicks(4); } }); } public static NPCClickHandler handleDialogue = new NPCClickHandler(new Object[] { NPC }, e -> e.getPlayer().startConversation(new BeggarMerlinsCrystalD(e.getPlayer()).getStart())); public static PlayerStepHandler handleBeggar = new PlayerStepHandler(Tile.of(3016, 3246, 0), e -> { Player p = e.getPlayer(); if((p.getQuestManager().getStage(Quest.MERLINS_CRYSTAL) != OBTAINING_EXCALIBUR) || !p.getQuestManager().getAttribs(Quest.MERLINS_CRYSTAL).getB(""LADY_TEST"")) return; for(NPC npc : World.getNPCsInChunkRange(p.getChunkId(), 1)) if(npc.getId() == 252) return; OwnedNPC beggar = new OwnedNPC(p, 252, Tile.of(3016, 3247, 0), true); beggar.setNextSpotAnim(new SpotAnim(1605)); beggar.forceTalk(""Hey!""); }); }" "package com.rs.game.content.quests.merlinscrystal; @PluginEventHandler public class KeepLaFayeMerlinsCrystalLoc { public static ObjectClickHandler handleVariousStaircasesUp = new ObjectClickHandler(new Object[] { 25786 }, e -> { GameObject obj = e.getObject(); e.getPlayer().useStairs(-1, Tile.of(e.getPlayer().getX(), obj.getY()+3, e.getPlayer().getPlane() + 1), 0, 1); }); public static ObjectClickHandler handleVariousStaircasesDown = new ObjectClickHandler(new Object[] { 25787 }, e -> { GameObject obj = e.getObject(); e.getPlayer().useStairs(-1, Tile.of(e.getPlayer().getX(), obj.getY()-3, e.getPlayer().getPlane() - 1), 0, 1); }); public static ObjectClickHandler handleCrate = new ObjectClickHandler(new Object[] { 63 }, e -> { if(e.getPlayer().getQuestManager().getStage(Quest.MERLINS_CRYSTAL) == CONFRONT_KEEP_LA_FAYE) e.getPlayer().startConversation(new Conversation(e.getPlayer()) { { addOptions(""Hide in the crate?"", new Options() { @Override public void create() { option(""Yes"", new Dialogue() .addNext(()-> e.getPlayer().getControllerManager().startController(new MerlinsCrystalCrateScene()))); option(""No"", new Dialogue()); } }); addSimple(""Would you like to enter the crate?""); create(); } }); }); public static PlayerStepHandler handleStrongholdFight = new PlayerStepHandler(new Tile[] { Tile.of(2769, 3401, 2), Tile.of(2770, 3401, 2), Tile.of(2771, 3401, 2), Tile.of(2771, 3402, 2), Tile.of(2770, 3402, 2), Tile.of(2769, 3402, 2), Tile.of(2768, 3402, 2), Tile.of(2768, 3401, 2) }, e -> { if(e.getPlayer().getQuestManager().getStage(Quest.MERLINS_CRYSTAL) != CONFRONT_KEEP_LA_FAYE) return; NPC mordred = null; for(NPC npc : World.getNPCsInChunkRange(e.getPlayer().getChunkId(), 1)) if(npc.getId() == 247) { mordred = npc; break; } if(mordred == null || mordred.getTarget() != null || !mordred.canAggroPlayer(e.getPlayer())) return; mordred.forceTalk(""You DARE invade MY stronghold?!?! Have at thee knave!!""); mordred.setTarget(e.getPlayer()); }); public static ObjectClickHandler handleFrontDoor = new ObjectClickHandler(new Object[] { 71, 72 }, e -> { GameObject obj = e.getObject(); e.getPlayer().sendMessage(""The door is securely locked.""); if(e.getPlayer().getX() > obj.getX()) return; e.getPlayer().startConversation(new Conversation(e.getPlayer()) { { addSimple(""You knock at the door. You hear a voice from inside...""); addNPC(490, HeadE.CALM_TALK, ""Yes? What do you want?""); addPlayer(HeadE.HAPPY_TALKING, ""Um...""); addOptions(""Choose an option:"", new Options() { @Override public void create() { option(""Pizza delivery!"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Pizza delivery!"") .addNPC(490, HeadE.CALM_TALK, ""We didn't order any Pizza. Get lost!"") .addSimple(""It looks like you'll have to find another way in..."") ); option(""Ever considered letting Saradomin into your life?"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Have you ever considered letting the glory of Saradomin into your life? I have some pamphlets you may be interested in reading and discussing with me."") .addNPC(490, HeadE.CALM_TALK, ""No. Go away."") .addSimple(""It looks like you'll have to find another way in..."") ); option(""Can I interest you in some double glazing?"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Can I interest you in some double glazing? An old castle like this must get very draughty in the winter..."") .addNPC(490, HeadE.CALM_TALK, ""No. Get out of here before I run you through."") .addSimple(""It looks like you'll have to find another way in..."") ); option(""Would you like to buy some lucky leather?"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Would you like to buy some lucky leather?"") .addNPC(490, HeadE.CALM_TALK, ""No. Go away"") .addSimple(""It looks like you'll have to find another way in..."") ); } }); create(); } }); }); protected final static Set STRONGHOLD_CHUNKS = new HashSet<>(Arrays.asList(5672264, 5688648, 5672256)); public static EnterChunkHandler handleAgressiveKnights = new EnterChunkHandler(e -> { if (e.getEntity() instanceof Player player && player.hasStarted() && STRONGHOLD_CHUNKS.contains(e.getChunkId())) { for (NPC npc : World.getNPCsInChunkRange(e.getPlayer().getChunkId(), 1)) { if (!npc.getName().equalsIgnoreCase(""Renegade Knight"") || !npc.lineOfSightTo(player, false)) continue; npc.setTarget(player); if (Utils.random(0, 5) == 1) npc.forceTalk(""Intruder!""); } } }); }" "package com.rs.game.content.quests.merlinscrystal; @PluginEventHandler public class KingArthurMerlinsCrystalD extends Conversation { private final static int NPC = 251; public KingArthurMerlinsCrystalD(Player player) { super(player); switch(player.getQuestManager().getStage(Quest.MERLINS_CRYSTAL)) { case NOT_STARTED -> { addNPC(NPC, HeadE.CALM_TALK, ""Welcome to my court. I am King Arthur.""); addOptions(""Choose an option:"", new Options() { @Override public void create() { option(""I want to become a knight of the round table!"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""I want to become a knight of the round table!"") .addNPC(NPC, HeadE.CALM_TALK, ""Well, in that case I think you need to go on a quest to prove yourself worthy. "" + ""My knights all appreciate a good quest. Unfortunately, our current quest is to rescue Merlin. "") .addNPC(NPC, HeadE.CALM_TALK, ""Back in England, he got himself trapped in some sort of magical Crystal. We've moved him from "" + ""the cave we found him in and now he's upstairs in his tower."") .addOptions(""Start Merlin's Crystal?"", new Options() { @Override public void create() { option(""Yes"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""I will see what I can do then."", ()-> player.getQuestManager().setStage(Quest.MERLINS_CRYSTAL, TALK_TO_KNIGHTS)) .addNPC(NPC, HeadE.CALM_TALK, ""Talk to my knights if you need any help."") .addNPC(NPC, HeadE.CALM_TALK, ""You will need to find a way into Morgan LeFaye's stronghold."") ); option(""No"", new Dialogue()); } }) ); option(""So what are you doing in Runescape?"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""So what are you doing in Runescape?"") .addNPC(NPC, HeadE.CALM_TALK, ""Well legend says we will return to Britain in its time of greatest need. But that's not for quite a while yet"") .addNPC(NPC, HeadE.CALM_TALK, ""So we've moved the whole outfit here for now. We're passing the time in Runescape!"") ); option(""Thank you very much"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Thank you very much"") ); } }); } case TALK_TO_KNIGHTS, CONFRONT_KEEP_LA_FAYE -> { addNPC(NPC, HeadE.CALM_TALK, ""Talk to my knights about breaking the crystal.""); addPlayer(HeadE.HAPPY_TALKING, ""Okay""); } case THE_BLACK_CANDLE, OBTAINING_EXCALIBUR, PERFORM_RITUAL, BREAK_MERLIN_CRYSTAL -> addNPC(NPC, HeadE.CALM_TALK, ""I am amazed you broke into Morgan La Faye's stronghold!""); case TALK_TO_ARTHUR -> { addPlayer(HeadE.HAPPY_TALKING, ""I have freed Merlin from his crystal!""); addNPC(NPC, HeadE.CALM_TALK, ""Ah. A good job, well done. I dub thee a Knight Of The Round Table. You are now an honorary knight.""); addNext(()-> player.getQuestManager().completeQuest(Quest.MERLINS_CRYSTAL)); } case QUEST_COMPLETE -> { addNPC(NPC, HeadE.CALM_TALK, ""Thank you for freeing Merlin!""); addPlayer(HeadE.HAPPY_TALKING, ""You are welcome.""); } } } }" "package com.rs.game.content.quests.merlinscrystal; @PluginEventHandler public class LadyOfLakeMerlinsCrystalD extends Conversation { final static int NPC=250; public LadyOfLakeMerlinsCrystalD(Player player) { super(player); addNPC(NPC, HeadE.CALM_TALK, ""Good day to you""); addOptions(""Choose an option:"", new Options() { @Override public void create() { option(""Who are you?"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Who are you?"") .addNPC(NPC, HeadE.CALM_TALK, ""I am the Lady of the Lake."") ); if(player.getQuestManager().getStage(Quest.MERLINS_CRYSTAL) == MerlinsCrystal.THE_BLACK_CANDLE) { option(""About Merlin's Crystal"", new Dialogue() .addPlayer(HeadE.AMAZED, ""I should probably get the black candle before the excalibur..."") .addNPC(NPC, HeadE.CALM_TALK, ""What?"") .addPlayer(HeadE.HAPPY_TALKING, ""Oh nothing, just notes to myself..."") ); } if(player.getQuestManager().getStage(Quest.MERLINS_CRYSTAL) == MerlinsCrystal.OBTAINING_EXCALIBUR) option(""I seek the sword Excalibur"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""I seek the sword Excalibur"") .addNPC(NPC, HeadE.CALM_TALK, ""Aye, I have that artefact in my possession. 'Tis very valuable, and not an artefact to be given "" + ""away lightly. I would want to give it away only to the one who is worthy and good."") .addPlayer(HeadE.HAPPY_TALKING, ""And how am I meant to prove that?"") .addNPC(NPC, HeadE.CALM_TALK, ""I shall set a test for you. First I need you to travel to Port Sarim. Then go to the upstairs room of the "" + ""jeweller' shop there."", ()-> player.getQuestManager().getAttribs(Quest.MERLINS_CRYSTAL).setB(""LADY_TEST"", true)) .addPlayer(HeadE.HAPPY_TALKING, ""Okay, that seems easy enough."") ); if(player.getQuestManager().getStage(Quest.MERLINS_CRYSTAL) >= MerlinsCrystal.PERFORM_RITUAL && !player.getInventory().containsItem(EXCALIBUR)) option(""I lost Excalibur..."", new Dialogue() .addPlayer(HeadE.SAD, ""I lost Excalibur..."") .addNPC(NPC, HeadE.CALM_TALK, ""I found it!"") .addPlayer(HeadE.AMAZED, ""Really!?"") .addNPC(NPC, HeadE.FRUSTRATED, ""Yes, please be worthy of it."") .addItem(EXCALIBUR, ""She gives you the sword"", ()-> player.getInventory().addItem(EXCALIBUR, 1))); option(""Good day."", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Good day."") ); } }); } public static NPCClickHandler handleDialogue = new NPCClickHandler(new Object[] { NPC }, e -> e.getPlayer().startConversation(new LadyOfLakeMerlinsCrystalD(e.getPlayer()).getStart())); }" "package com.rs.game.content.quests.merlinscrystal; @QuestHandler( quest = Quest.MERLINS_CRYSTAL, startText = ""Talk to King Arthur in Camelot."", itemsText = ""Bread, a bucket, insect repellent, bat bones."", combatText = ""You will need to defeat a level 23 knight. You might anger a level 70 demon."", rewardsText = ""Excalibur"", completedStage = 8 ) @PluginEventHandler public class MerlinsCrystal extends QuestOutline { public static final int NOT_STARTED = 0; public static final int TALK_TO_KNIGHTS = 1; public static final int CONFRONT_KEEP_LA_FAYE = 2; public static final int THE_BLACK_CANDLE = 3; public static final int OBTAINING_EXCALIBUR = 4; public static final int PERFORM_RITUAL = 5; public static final int BREAK_MERLIN_CRYSTAL = 6; public static final int TALK_TO_ARTHUR = 7; public static final int QUEST_COMPLETE = 8; //item protected static final int EXCALIBUR = 35; protected Tile crate = Tile.of(2778, 9839, 0); @Override public List getJournalLines(Player player, int stage) { ArrayList lines = new ArrayList<>(); switch(stage) { case NOT_STARTED: lines.add(""The wizard Merlin has been trapped in a magical crystal by""); lines.add(""the witch Morgan Le Faye. So far, King Arthur hasn't been ""); lines.add(""able to figure out how to free his mentor from his crystal ""); lines.add(""prison. Can you help?""); lines.add(""""); break; case TALK_TO_KNIGHTS: lines.add(""I must go investigate and talk with the knights of the round""); lines.add(""table to find clues to breaking Merlin's Crystal. Try talking ""); lines.add(""to all the knights, selecting all options. Come back Here to ""); lines.add(""see if you have completed the investigation.""); lines.add(""""); break; case CONFRONT_KEEP_LA_FAYE: lines.add(""The investigation is finished I must Confront Morgan Le Faye""); lines.add(""at their stronghold. Perhaps I can hide in a crate in Catherby""); lines.add(""by the candle makers shop.""); lines.add(""""); break; case THE_BLACK_CANDLE: lines.add(""I need a black candle and bat bones. I believe I can find black""); lines.add(""candles in the general store in Catherby by the ports.""); lines.add(""""); break; case OBTAINING_EXCALIBUR: lines.add(""I can get excalibur by performing a task for The Lady Of The""); lines.add(""Lake in Taverly, south of the summoning shops. She is on the""); lines.add(""peninsula.""); lines.add(""""); break; case PERFORM_RITUAL: lines.add(""I must see the chaos altar's inscription in South Varrock and""); lines.add(""memorize it. Then I must take the bat bones and black candle and""); lines.add(""bind a spirit using the encantation on the chaos altar.""); lines.add(""""); break; case BREAK_MERLIN_CRYSTAL: lines.add(""After the ritual you must smash the crystal with excalibur""); lines.add(""""); break; case TALK_TO_ARTHUR: lines.add(""Talk to Arthur to complete the quest.""); lines.add(""""); break; case QUEST_COMPLETE: lines.add(""""); lines.add(""""); lines.add(""QUEST COMPLETE!""); break; default: lines.add(""Invalid quest stage. Report this to an administrator.""); break; } return lines; } private static void openShop(Player player) { if(player.isQuestComplete(Quest.MERLINS_CRYSTAL)) ShopsHandler.openShop(player, ""candle_with_black_shop""); else ShopsHandler.openShop(player, ""candle_shop""); } public static NPCClickHandler handleCandleMakerDialogue = new NPCClickHandler(new Object[] { 562 }, e -> { if(e.getOption().equalsIgnoreCase(""Talk-to"")) { if (e.getPlayer().getQuestManager().getStage(Quest.MERLINS_CRYSTAL) >= MerlinsCrystal.THE_BLACK_CANDLE && !e.getPlayer().isQuestComplete(Quest.MERLINS_CRYSTAL)) { e.getPlayer().startConversation(new Conversation(e.getPlayer()) { { if (e.getPlayer().getInventory().containsItem(38)) { addNPC(562, HeadE.CALM_TALK, ""Good luck with your candle!""); addPlayer(HeadE.HAPPY_TALKING, ""Thanks!""); } else if (e.getPlayer().getQuestManager().getAttribs(Quest.MERLINS_CRYSTAL).getB(""KNOWS_ABOUT_BLACK_CANDLE"")) { if (e.getPlayer().getInventory().containsItem(30, 1)) { addNPC(562, HeadE.CALM_TALK, ""Do you have the wax?""); addPlayer(HeadE.HAPPY_TALKING, ""Yes""); addSimple(""You exchange the wax with the candle maker for a black candle."", () -> { e.getPlayer().getInventory().removeItems(new Item(30, 1)); e.getPlayer().getInventory().addItem(new Item(38, 1), true); e.getPlayer().getQuestManager().setStage(Quest.MERLINS_CRYSTAL, OBTAINING_EXCALIBUR); }); } else { addNPC(562, HeadE.CALM_TALK, ""Do you have the wax?""); addPlayer(HeadE.HAPPY_TALKING, ""Not yet""); } } else { addNPC(562, HeadE.CALM_TALK, ""Hi! Would you be interested in some of my fine candles?""); addPlayer(HeadE.HAPPY_TALKING, ""Have you got any black candles?""); addNPC(562, HeadE.CALM_TALK, ""BLACK candles??? Hmmm. In the candle making trade, we have a tradition that it's very bad luck"" + "" to make black candles. VERY bad luck.""); addPlayer(HeadE.HAPPY_TALKING, ""I will pay good money for one...""); addNPC(562, HeadE.CALM_TALK, ""I still dunno...Tell you what: I'll supply you with a black candle... IF you can bring me a bucket FULL of wax."", () -> e.getPlayer().getQuestManager().getAttribs(Quest.MERLINS_CRYSTAL).setB(""KNOWS_ABOUT_BLACK_CANDLE"", true)); } create(); } }); } else { e.getPlayer().startConversation(new Conversation(e.getPlayer()) { { addNPC(562, HeadE.CALM_TALK, ""Hi, looking for candles?""); addPlayer(HeadE.HAPPY_TALKING, ""Sure!""); addNext(() -> openShop(e.getPlayer())); create(); } }); } } else if(e.getOption().equalsIgnoreCase(""trade"")) { openShop(e.getPlayer()); } }); final static int LIT_BLACK_CANDLE = 32; final static int UNLIT_BLACK_CANDLE = 38; final static int TINDERBOX = 590; public static ItemClickHandler handleLitCandle = new ItemClickHandler(new Object[] { LIT_BLACK_CANDLE }, new String[] { ""Extinguish"" }, e -> e.getPlayer().getInventory().replaceItem(UNLIT_BLACK_CANDLE, 1, e.getItem().getSlot())); private static final int MERLIN_FREE_VAR = 14; private static final int MERLINS_CRYSTAL_OBJ = 62; public static ObjectClickHandler handleMerlinsCrystal = new ObjectClickHandler(new Object[] { MERLINS_CRYSTAL_OBJ }, e -> { GameObject obj = e.getObject(); if (e.getOption().equalsIgnoreCase(""smash"")) { e.getPlayer().sendMessage(""You attempt to smash the crystal...""); if (e.getPlayer().getQuestManager().getStage(Quest.MERLINS_CRYSTAL) == BREAK_MERLIN_CRYSTAL) if (e.getPlayer().getInventory().containsItem(EXCALIBUR, 1) || e.getPlayer().getEquipment().containsOneItem(EXCALIBUR)) { e.getPlayer().sendMessage(""... and it shatters under the force of Excalibur!""); e.getPlayer().getQuestManager().setStage(Quest.MERLINS_CRYSTAL, TALK_TO_ARTHUR); e.getPlayer().getVars().setVar(14, 7); OwnedNPC merlin = new OwnedNPC(e.getPlayer(), 249, Tile.of(obj.getX(), obj.getY(), obj.getPlane()), true); merlin.setCantInteract(true); merlin.setRandomWalk(false); merlin.finishAfterTicks(5); e.getPlayer().startConversation(new Conversation(e.getPlayer()) { { addNPC(249, HeadE.CALM_TALK, ""Thank you! Thank you! Thank you!""); addNPC(249, HeadE.CALM_TALK, ""It's not fun being trapped in a giant crystal!""); addSimple(""You have set Merlin free. Now talk to King Arthur.""); create(); } }); } else e.getPlayer().startConversation(new Conversation(e.getPlayer()) { { addPlayer(HeadE.HAPPY_TALKING, ""Hmm, looks like I will need excalibur to do this.""); create(); } }); } }); public static PlayerStepHandler handleRitualSpot = new PlayerStepHandler(Tile.of(2780, 3515, 0), e -> { if(e.getPlayer().getQuestManager().getStage(Quest.MERLINS_CRYSTAL) != PERFORM_RITUAL) return; WorldTasks.scheduleLooping(new Task() { int tick; @Override public void run() { if(tick == 1) if(e.getPlayer().getInventory().containsItem(LIT_BLACK_CANDLE, 1)) for (GroundItem item : ChunkManager.getChunk(e.getPlayer().getChunkId()).getAllGroundItems()) if (item.getId() == 530 && item.getTile().matches(Tile.of(2780, 3515, 0))) { e.getPlayer().getControllerManager().startController(new MerlinsCrystalRitualScene()); stop(); } if(tick == 3) if(e.getPlayer().matches(Tile.of(2780, 3515, 0))) tick = 0; if(tick == 5) stop(); tick++; } }, 0, 1); }); public static LoginHandler onLogin = new LoginHandler(e -> { if(e.getPlayer().getQuestManager().getStage(Quest.MERLINS_CRYSTAL) >= TALK_TO_ARTHUR) e.getPlayer().getVars().setVar(MERLIN_FREE_VAR, 7); }); @Override public void complete(Player player) { sendQuestCompleteInterface(player, EXCALIBUR); } }" "package com.rs.game.content.quests.merlinscrystal; public class MerlinsCrystalCrateScene extends Controller { private Instance instance; private Tile locationBeforeCutscene; private Tile insideCrate; private final Tile destination = Tile.of(2779, 3400, 0); @Override public void start() { player.lock(); locationBeforeCutscene = Tile.of(player.getTile()); instance = Instance.of(locationBeforeCutscene, 4, 4); playCutscene(); } @Override public Genre getGenre() { return Music.getGenreByName(""Other Kandarin""); } @Override public boolean playAmbientOnControllerRegionEnter() { return false; } @Override public boolean playAmbientMusic() { return false; } private void playCutscene() { instance.copyMapAllPlanes(347, 1229).thenAccept(e -> { insideCrate = instance.getLocalTile(2, 7); WorldTasks.scheduleLooping(new Task() { int tick; static final int CROUCH_CRATE_ANIM = 14592; @Override public void run() { if (tick == 0) player.getInterfaceManager().setFadingInterface(115); else if (tick == 3) {// setup p2, move player player.musicTrack(-1); player.getPackets().setBlockMinimapState(2); player.tele(insideCrate); } else if (tick == 4) { player.setNextAnimation(new Animation(CROUCH_CRATE_ANIM)); player.getPackets().sendCameraPos(player.getXInScene(player.getSceneBaseChunkId())-3, player.getYInScene(player.getSceneBaseChunkId())-3, 4000); player.getPackets().sendCameraLook(player.getXInScene(player.getSceneBaseChunkId()), player.getYInScene(player.getSceneBaseChunkId()), 200); player.faceTile(Tile.of(player.getX()+1, player.getY()-1, player.getPlane())); } else if (tick == 6) player.getInterfaceManager().setFadingInterface(170); else if (tick == 8) player.startConversation(new Conversation(player) { { addSimple(""You climb inside the crate and wait. And wait...""); addNext(()-> tick++); create(); } }); else if (tick == 13) player.startConversation(new Conversation(player) { { addSimple(""You hear voices outside the crate....""); addSimple(""Is this your crate, Arhein?""); addSimple(""Yeah, I think so. Pack it aboard soon as you can. I'm on a tight schedule for deliveries!""); addSimple(""You feel the crate being lifted.""); addSimple(""Oof. Wow, this is pretty heavy! I never knew candles weighed so much!""); addSimple(""Quit your whining, and stow it in the hold.""); addSimple(""You feel the crate being put down inside the ship. You wait... And wait...""); addNext(()-> tick++); create(); } }); else if(tick == 20) player.startConversation(new Conversation(player) { { addSimple(""Casting off!""); addSimple(""You feel the ship start to move. Feels like you're now out at sea. The ship comes to a stop.""); addSimple(""Unload Mordred's deliveries onto the jetty.""); addSimple(""Aye-aye cap'n!""); addSimple(""You feel the crate being lifted. You can hear someone mumbling outside the crate.""); addSimple(""...stupid Arhein...making me...candles...never weigh THIS much...hurts...union about this!...""); addSimple(""...if...MY ship be different!...stupid Arhein...""); addSimple(""You feel the crate being put down.""); addNext(()-> tick++); create(); } }); else if(tick == 25) player.startConversation(new Conversation(player) { { addOptions(""Climb out the crate?"", new Options() { @Override public void create() { option(""Yes"", new Dialogue() .addNext(()-> tick++)); option(""No"", new Dialogue() .addNext(()-> tick = 22)); } }); addNext(()-> tick++); create(); } }); else if(tick == 27) player.getInterfaceManager().setFadingInterface(115); else if(tick == 30) { player.getPackets().setBlockMinimapState(0); player.tele(destination); player.getPackets().sendResetCamera(); player.setNextAnimation(new Animation(-1)); } else if(tick == 31) player.faceWest(); else if(tick == 33) { player.getInterfaceManager().setFadingInterface(170); removeInstance(); removeController(); player.unlock(); stop(); } if(tick != 8+1 && tick != 13+1 && tick != 20+1 && tick != 25+1) tick++; } }, 0, 1); }); } @Override public boolean login() { forceClose(); return false; } @Override public boolean logout() { removeInstance(); player.unlock(); return false; } @Override public void forceClose() { player.tele(locationBeforeCutscene); removeInstance(); player.unlock(); player.getPackets().setBlockMinimapState(0); removeController(); } private void removeInstance() { instance.destroy(); } }" "package com.rs.game.content.quests.merlinscrystal; public class MerlinsCrystalRitualScene extends Controller { final int THRANTAX_SPIRIT = 238; @Override public void start() { player.lock(); playCutscene(); } private void playCutscene() { boolean hasSpirit = false; for(NPC npc : World.getNPCsInChunkRange(player.getChunkId(), 1)) if (npc.getId() == THRANTAX_SPIRIT) { hasSpirit = true; break; } if(hasSpirit) ; else { OwnedNPC spirit = new OwnedNPC(player, THRANTAX_SPIRIT, Tile.of(2780, 3516, 0), true); player.musicTrack(449); spirit.setNextSpotAnim(new SpotAnim(1605, 0, 0)); spirit.setCantInteract(true); spirit.faceSouth(); spirit.setRandomWalk(false); } player.startConversation(new ThrantaxMerlinsCrystalD(player).getStart()); } @Override public boolean login() { forceClose(); return false; } @Override public boolean logout() { player.unlock(); return false; } @Override public void forceClose() { player.unlock(); } }" "package com.rs.game.content.quests.merlinscrystal; @PluginEventHandler public class MordredMob extends NPC { private final static int MORGAN = 248; public MordredMob(int id, Tile tile) { super(id, tile, false); } @Override public void sendDeath(Entity source) { if(source instanceof Player player) { if(player.getQuestManager().getStage(Quest.MERLINS_CRYSTAL) == MerlinsCrystal.CONFRONT_KEEP_LA_FAYE) { for(NPC npc : World.getNPCsInChunkRange(player.getChunkId(), 1)) if(npc.getId() == MORGAN) return; OwnedNPC morgan = new OwnedNPC(player, MORGAN, Tile.of(2769, 3403, 2), true); morgan.setNextSpotAnim(new SpotAnim(1605, 0, 0)); morgan.forceTalk(""Stop! Spare my son!""); morgan.faceSouth(); morgan.setRandomWalk(false); WorldTasks.schedule(new Task() { @Override public void run() { resetNPC(null); } }, 10); } else super.sendDeath(source); } else super.sendDeath(source); } public void resetNPC(final Entity source) { resetWalkSteps(); removeTarget(); reset(); finish(); if (!isSpawned()) setRespawnTask(10); } @Override public boolean canBeAttackedBy(Player player) { for(NPC npc : World.getNPCsInChunkRange(player.getChunkId(), 1)) if(npc.getId() == MORGAN && npc instanceof OwnedNPC morgan) if(player.getUsername().equalsIgnoreCase(morgan.getOwner().getUsername())) return false; return true; } @Override public boolean canAggroPlayer(Player player) { for(NPC npc : World.getNPCsInChunkRange(player.getChunkId(), 1)) if(npc.getId() == MORGAN && npc instanceof OwnedNPC morgan) if(player.getUsername().equalsIgnoreCase(morgan.getOwner().getUsername())) return false; return true; } public static NPCInstanceHandler toFunc = new NPCInstanceHandler(247, MordredMob::new); }" "package com.rs.game.content.quests.merlinscrystal; @PluginEventHandler public class MorganMerlinsCrystalD extends Conversation { private final static int NPC = 248; public MorganMerlinsCrystalD(Player p) { super(p); if(p.getQuestManager().getStage(Quest.MERLINS_CRYSTAL) == CONFRONT_KEEP_LA_FAYE) { addNPC(NPC, HeadE.CALM_TALK, ""STOP! Please... spare my son""); addPlayer(HeadE.HAPPY_TALKING, ""Tell me how to untrap Merlin and I might.""); addNPC(NPC, HeadE.CALM_TALK, ""You have guessed correctly that I'm responsible for that. I suppose I can live with that fool Merlin "" + ""being loose for the sake of my son.""); addNPC(NPC, HeadE.CALM_TALK, ""Setting him free won't be easy though. You will need to find a magic symbol as close to the crystal as you "" + ""can find. You will then need to drop some bat's bones on the magic symbol while holding a lit black candle.""); addNPC(NPC, HeadE.CALM_TALK, ""This will summon a mighty spirit named Thrantax. You will need to bind him with magic words. Then you will need the "" + ""sword Excalibur with which the spell was bound in order to shatter the crystal.""); addNext(() -> p.startConversation(new MorganMerlinsCrystalD(p, true).getStart())); }else if(p.getQuestManager().getStage(Quest.MERLINS_CRYSTAL) == THE_BLACK_CANDLE) { addNPC(NPC, HeadE.CALM_TALK, ""That's all I know, I swear!""); addPlayer(HeadE.SECRETIVE, ""...""); addNPC(NPC, HeadE.CALM_TALK, ""...""); } else { addNPC(NPC, HeadE.FRUSTRATED, ""What do you want?""); addPlayer(HeadE.CALM_TALK, ""Nothing""); } } public MorganMerlinsCrystalD(Player p, boolean filler) { super(p); addOptions(""Choose an option:"", new Options() { @Override public void create() { option(""So where can I find Excalibur?"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""So where can I find Excalibur?"") .addNPC(NPC, HeadE.CALM_TALK, ""The lady of the lake has it. I don't know if she'll give it to you though, she can be rather temperamental."", ()-> p.getQuestManager().getAttribs(Quest.MERLINS_CRYSTAL).setB(""KNOWS_E"", true)) .addNext(()->{ if(p.getQuestManager().getAttribs(Quest.MERLINS_CRYSTAL).getB(""KNOWS_E"") && p.getQuestManager().getAttribs(Quest.MERLINS_CRYSTAL).getB(""KNOWS_ABOUT_ENC"")) p.getQuestManager().setStage(Quest.MERLINS_CRYSTAL, THE_BLACK_CANDLE); p.startConversation(new MorganMerlinsCrystalD(p, true).getStart()); })); option(""What are the magic words?"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""What are the magic words?"") .addNPC(NPC, HeadE.CALM_TALK, ""You will find the magic words at the base of one of the chaos altars. Which chaos altar I cannot remember."", ()-> p.getQuestManager().getAttribs(Quest.MERLINS_CRYSTAL).setB(""KNOWS_ABOUT_ENC"", true)) .addNext(()->{ if(p.getQuestManager().getAttribs(Quest.MERLINS_CRYSTAL).getB(""KNOWS_E"") && p.getQuestManager().getAttribs(Quest.MERLINS_CRYSTAL).getB(""KNOWS_ABOUT_ENC"")) p.getQuestManager().setStage(Quest.MERLINS_CRYSTAL, THE_BLACK_CANDLE); p.startConversation(new MorganMerlinsCrystalD(p, true).getStart()); })); if(p.getQuestManager().getAttribs(Quest.MERLINS_CRYSTAL).getB(""KNOWS_E"") && p.getQuestManager().getAttribs(Quest.MERLINS_CRYSTAL).getB(""KNOWS_ABOUT_ENC"")) option(""Ok, I will go do all that."", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Ok, I will go do all that."") .addSimple(""Morgan Le Faye vanishes."", ()->{ p.getQuestManager().setStage(Quest.MERLINS_CRYSTAL, THE_BLACK_CANDLE); for(NPC npc : World.getNPCsInChunkRange(p.getChunkId(), 1)) if(npc.getId() == NPC) npc.finish(); }) ); } }); } public static NPCClickHandler handleMorganDialogue = new NPCClickHandler(new Object[] { NPC }, e -> e.getPlayer().startConversation(new MorganMerlinsCrystalD(e.getPlayer()).getStart())); }" "package com.rs.game.content.quests.merlinscrystal; @PluginEventHandler public class ThrantaxMerlinsCrystalD extends Conversation { final int NPC = 238; public ThrantaxMerlinsCrystalD(Player player) { super(player); addSimple(""Suddenly a mighty spirit appears!""); addPlayer(HeadE.HAPPY_TALKING, ""Now what were those magic words again?""); addNext(()-> player.startConversation(new ThrantaxMerlinsCrystalD(player, true).getStart())); } public ThrantaxMerlinsCrystalD(Player player, boolean filler) { super(player); addOptions(""Choose an option:"", new Options() { @Override public void create() { option(""Snarthtrick Candanto Termon"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Snarthtrick... Candanto... Termon!"") .addPlayer(HeadE.HAPPY_TALKING, ""No, that wasn't right"") .addNext(()-> player.startConversation(new ThrantaxMerlinsCrystalD(player, true).getStart()))); option(""Snarthon Candtrick Termanto"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Snarthon... Candtrick... Termanto!"") .addNPC(NPC, HeadE.CALM_TALK, ""GRAAAAAAGH! Thou hast me in thine control. So that I mayst return from whence I am, I must grant "" + ""thee a boon. What dost thou wish of me?"") .addPlayer(HeadE.HAPPY_TALKING, ""I wish to free Merlin from his giant crystal!"") .addNPC(NPC, HeadE.CALM_TALK, ""GRAAAAAAGH! The deed is done. Thou mayst now shatter Merlins' crystal with Excalibur and I can "" + ""once more rest. Begone! And leave me once more in peace."") .addNext(()->{ player.getQuestManager().setStage(Quest.MERLINS_CRYSTAL, BREAK_MERLIN_CRYSTAL); player.getControllerManager().forceStop(); player.unlock(); })); option(""Snarthanto Candon Termtrick"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Snarthanto... Candon... Termtrick!"") .addPlayer(HeadE.HAPPY_TALKING, ""No, that wasn't right"") .addNext(()-> player.startConversation(new ThrantaxMerlinsCrystalD(player, true).getStart()))); } }); } }" "package com.rs.game.content.quests.merlinscrystal.knightsroundtable; @PluginEventHandler public class SirBedivereMerlinsCrystalD extends Conversation { private final static int NPC = 242; public SirBedivereMerlinsCrystalD(Player player) { super(player); switch(player.getQuestManager().getStage(Quest.MERLINS_CRYSTAL)) { case NOT_STARTED -> { addNPC(NPC, HeadE.CALM_TALK, ""May I help you?""); addPlayer(HeadE.HAPPY_TALKING, ""I'm really just looking for a quest...""); addNPC(NPC, HeadE.CALM_TALK, ""Fortune favours us both then adventurer. I suggest you go and speak to King Arthur.""); } case TALK_TO_KNIGHTS, CONFRONT_KEEP_LA_FAYE -> { addPlayer(HeadE.HAPPY_TALKING, ""I don't suppose you have any idea how to break into Mordred's fort do you?""); addNPC(NPC, HeadE.CALM_TALK, ""I am afraid not. Would that we could! Mordred and his cronies have been thorns in our side for far too long already!""); addPlayer(HeadE.HAPPY_TALKING, ""Ok. Thanks. See you later!""); addNPC(NPC, HeadE.CALM_TALK, ""Take care adventurer, Mordred is an evil and powerful foe.""); } case THE_BLACK_CANDLE, OBTAINING_EXCALIBUR, PERFORM_RITUAL, BREAK_MERLIN_CRYSTAL -> { addNPC(NPC, HeadE.CALM_TALK, ""Good luck breaking Merlin free adventurer.""); addPlayer(HeadE.HAPPY_TALKING, ""Thank you.""); } case TALK_TO_ARTHUR, QUEST_COMPLETE -> { addNPC(NPC, HeadE.CALM_TALK, ""You are an excellent knight indeed to have freed Merlin""); addPlayer(HeadE.HAPPY_TALKING, ""Thanks.""); } } } }" "package com.rs.game.content.quests.merlinscrystal.knightsroundtable; @PluginEventHandler public class SirGawainMerlinsCrystalD extends Conversation { private final static int NPC = 240; public SirGawainMerlinsCrystalD(Player player) { super(player); switch(player.getQuestManager().getStage(Quest.MERLINS_CRYSTAL)) { case NOT_STARTED -> { addNPC(NPC, HeadE.CALM_TALK, ""Good day to you!""); addPlayer(HeadE.HAPPY_TALKING, ""Know you of any quests sir knight?""); addNPC(NPC, HeadE.CALM_TALK, ""The king is the man to talk to if you want a quest.""); } case TALK_TO_KNIGHTS, CONFRONT_KEEP_LA_FAYE -> { addNPC(NPC, HeadE.CALM_TALK, ""Good day to you""); addOptions(""Choose an option:"", new Options() { @Override public void create() { option(""Any ideas on how to get Merlin out of that crystal?"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Any ideas on how to get Merlin out of that crystal?"") .addNPC(NPC, HeadE.CALM_TALK, ""I'm a little stumped myself. We've tried opening it with anything and everything!"") ); option(""Do you know how Merlin got trapped?"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Do you know how Merlin got trapped?"") .addNPC(NPC, HeadE.CALM_TALK, ""I would guess this is the work of the evil Morgan Le Faye!"") .addPlayer(HeadE.HAPPY_TALKING, ""And where could I find her?"") .addNPC(NPC, HeadE.CALM_TALK, ""She lives in her stronghold to the south of here, guarded by some renegade knights led by Sir Mordred."") .addPlayer(HeadE.HAPPY_TALKING, ""Any idea how to get into Morgan LeFaye's stronghold?"") .addNPC(NPC, HeadE.CALM_TALK, ""No, you've got me stumped there..."") .addPlayer(HeadE.HAPPY_TALKING, ""Thank you for the information"") ); } }); } case THE_BLACK_CANDLE, OBTAINING_EXCALIBUR, PERFORM_RITUAL, BREAK_MERLIN_CRYSTAL -> { addNPC(NPC, HeadE.AMAZED_MILD, ""You stormed Morgan La Faye's stronghold?!""); addPlayer(HeadE.HAPPY_TALKING, ""Yup.""); } case TALK_TO_ARTHUR, QUEST_COMPLETE -> { addNPC(NPC, HeadE.CALM_TALK, ""I am impressed, excalibur is in good hands.""); addPlayer(HeadE.HAPPY_TALKING, ""...""); } } } }" "package com.rs.game.content.quests.merlinscrystal.knightsroundtable; @PluginEventHandler public class SirKayMerlinsCrystalD extends Conversation { private final static int NPC = 241; public SirKayMerlinsCrystalD(Player player) { super(player); switch(player.getQuestManager().getStage(Quest.MERLINS_CRYSTAL)) { case NOT_STARTED -> { addPlayer(HeadE.HAPPY_TALKING, ""Morning. Know where an adventurer has to go to find a quest around here?""); addNPC(NPC, HeadE.CALM_TALK, ""An adventurer eh? There is no service finer than serving the bountiful King Arthur, and I happen to know"" + "" there's an important quest to fulfill.""); } case TALK_TO_KNIGHTS, CONFRONT_KEEP_LA_FAYE -> { addPlayer(HeadE.HAPPY_TALKING, ""Any ideas on getting into Mordred's fort?""); addNPC(NPC, HeadE.CALM_TALK, ""Mordred... So you think he may be involved with the curse upon Merlin?""); addPlayer(HeadE.HAPPY_TALKING, ""Good a guess as any right?""); addNPC(NPC, HeadE.CALM_TALK, ""I think that you may be onto something there. Unfortunately his fortress is impregnable!""); addPlayer(HeadE.HAPPY_TALKING, ""...I'll figure something out.""); } case THE_BLACK_CANDLE, OBTAINING_EXCALIBUR, PERFORM_RITUAL, BREAK_MERLIN_CRYSTAL -> { addNPC(NPC, HeadE.CALM_TALK, ""Are you figuring out the curse on Merlin?""); addPlayer(HeadE.HAPPY_TALKING, ""Yes, I am looking into it now.""); } case TALK_TO_ARTHUR -> { addNPC(NPC, HeadE.CALM_TALK, ""Thank you for freeing Merlin!""); addPlayer(HeadE.HAPPY_TALKING, ""You're welcome.""); } } } }" "package com.rs.game.content.quests.merlinscrystal.knightsroundtable; @PluginEventHandler public class SirLancelotMerlinsCrystalD extends Conversation { private final static int NPC = 239; public SirLancelotMerlinsCrystalD(Player player) { super(player); switch(player.getQuestManager().getStage(Quest.MERLINS_CRYSTAL)) { case NOT_STARTED -> { addNPC(NPC, HeadE.CALM_TALK, ""Greetings! I am Sir Lancelot, the greatest Knight in the land! What do you want?""); addOptions(""Choose an option:"", new Options() { @Override public void create() { option(""You're a little full of yourself aren't you?"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""You're a little full of yourself aren't you?"") .addNPC(NPC, HeadE.CALM_TALK, ""I have every right to be proud of myself. My prowess in battle in world renowned!"") ); option(""I seek a quest!"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""I seek a quest!"") .addNPC(NPC, HeadE.CALM_TALK, ""Leave questing to the professionals. Such as myself."") ); } }); } case TALK_TO_KNIGHTS, CONFRONT_KEEP_LA_FAYE -> { addNPC(NPC, HeadE.CALM_TALK, ""Greetings! I am Sir Lancelot, the greatest Knight in the land! What do you want?""); addOptions(""Choose an option:"", new Options() { @Override public void create() { option(""I want to get Merlin out of the crystal"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""I want to get Merlin out of the crystal"") .addNPC(NPC, HeadE.CALM_TALK, ""Well, if the Knights of the Round Table can't manage it, I can't see how a commoner "" + ""like you could succeed where we have failed."") ); option(""You're a little full of yourself aren't you?"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""You're a little full of yourself aren't you?"") .addNPC(NPC, HeadE.CALM_TALK, ""I have every right to be proud of myself. My prowess in battle in world renowned!"") ); option(""Any ideas on how to get into Morgan Le Faye's stronghold?"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Any ideas on how to get into Morgan Le Faye's stronghold?"") .addNPC(NPC, HeadE.CALM_TALK, ""That stronghold is built in a strong defensive position. It's on a big rock out into the sea. "") .addNPC(NPC, HeadE.CALM_TALK, ""There are two ways in that I know of, the large heavy front doors, and the sea entrance, "" + ""only penetrable by boat. They take all their deliveries by boat."", ()-> player.getQuestManager().setStage(Quest.MERLINS_CRYSTAL, CONFRONT_KEEP_LA_FAYE)) ); } }); } case THE_BLACK_CANDLE, OBTAINING_EXCALIBUR, PERFORM_RITUAL, BREAK_MERLIN_CRYSTAL -> { addNPC(NPC, HeadE.CALM_TALK, ""I guess going by boat was the way to go?""); addPlayer(HeadE.HAPPY_TALKING, ""Yes it was...""); } case TALK_TO_ARTHUR, QUEST_COMPLETE -> { addNPC(NPC, HeadE.CALM_TALK, ""Merlin is out of the crystal I hear...""); addPlayer(HeadE.HAPPY_TALKING, ""Yes he is...""); } } } }" "package com.rs.game.content.quests.merlinscrystal.knightsroundtable; @PluginEventHandler public class SirLucanMerlinsCrystalD extends Conversation { private final static int NPC = 245; public SirLucanMerlinsCrystalD(Player player) { super(player); switch(player.getQuestManager().getStage(Quest.MERLINS_CRYSTAL)) { case NOT_STARTED -> { addNPC(NPC, HeadE.CALM_TALK, ""Hello there adventurer.""); addPlayer(HeadE.HAPPY_TALKING, ""I'm looking for a quest...""); addNPC(NPC, HeadE.CALM_TALK, ""Talk to the King then adventurer. He is always looking for men of bravery to aid him in his actions...""); } case TALK_TO_KNIGHTS, CONFRONT_KEEP_LA_FAYE -> { addPlayer(HeadE.HAPPY_TALKING, ""Any suggestions on freeing Merlin?""); addNPC(NPC, HeadE.CALM_TALK, ""I've tried all the weapons I can find, yet none are powerful enough to break his crystal prison... "" + ""Perhaps the mighty Excalibur would be strong enough...""); addPlayer(HeadE.HAPPY_TALKING, ""Excalibur eh? Where would I find that?""); addNPC(NPC, HeadE.CALM_TALK, ""The Lady of the Lake is looking after it I believe... but I know not where she resides currently""); addPlayer(HeadE.HAPPY_TALKING, ""Thanks. I'll try and find someone who does.""); } case THE_BLACK_CANDLE, OBTAINING_EXCALIBUR, PERFORM_RITUAL, BREAK_MERLIN_CRYSTAL -> { addNPC(NPC, HeadE.CALM_TALK, ""Remember the Lady of the Lake has excalibur in southern Taverly.""); addPlayer(HeadE.HAPPY_TALKING, ""Gotcha!""); } case TALK_TO_ARTHUR, QUEST_COMPLETE -> { addNPC(NPC, HeadE.CALM_TALK, ""Excalibur is in good hands!""); addPlayer(HeadE.HAPPY_TALKING, ""...""); } } } }" "package com.rs.game.content.quests.merlinscrystal.knightsroundtable; @PluginEventHandler public class SirPalomedesMerlinsCrystalD extends Conversation { private final static int NPC = 3787; public SirPalomedesMerlinsCrystalD(Player player) { super(player); switch(player.getQuestManager().getStage(Quest.MERLINS_CRYSTAL)) { case NOT_STARTED -> { addNPC(NPC, HeadE.CALM_TALK, ""Hello there adventurer, what do you want of me?""); addPlayer(HeadE.HAPPY_TALKING, ""I'd like some advice on finding a quest.""); addNPC(NPC, HeadE.CALM_TALK, ""I do not know of any myself... but it would perhaps be worth your while asking the King if he has any tasks for you.""); } case TALK_TO_KNIGHTS, CONFRONT_KEEP_LA_FAYE -> { addPlayer(HeadE.HAPPY_TALKING, ""I'd like some advice on breaking into Mordred's fort.""); addNPC(NPC, HeadE.CALM_TALK, ""Sorry, I cannot help you with that.""); } case THE_BLACK_CANDLE, OBTAINING_EXCALIBUR, PERFORM_RITUAL, BREAK_MERLIN_CRYSTAL -> { addNPC(NPC, HeadE.CALM_TALK, ""Sorry I can't help you much more.""); addPlayer(HeadE.HAPPY_TALKING, ""Okay.""); } case TALK_TO_ARTHUR, QUEST_COMPLETE -> { addNPC(NPC, HeadE.CALM_TALK, ""Thanks again for freeing Merlin.""); addPlayer(HeadE.HAPPY_TALKING, ""Of course!""); } } } }" "package com.rs.game.content.quests.merlinscrystal.knightsroundtable; @PluginEventHandler public class SirPelleasMerlinsCrystalD extends Conversation { private final static int NPC = 244; public SirPelleasMerlinsCrystalD(Player player) { super(player); switch(player.getQuestManager().getStage(Quest.MERLINS_CRYSTAL)) { case NOT_STARTED -> { addNPC(NPC, HeadE.CALM_TALK, ""Greetings to the court of King Arthur!""); addPlayer(HeadE.HAPPY_TALKING, ""Hello. I'm looking for a quest. Who should I talk to?""); addNPC(NPC, HeadE.CALM_TALK, ""King Arthur will let you know. I believe he has a quest at the moment.""); } case TALK_TO_KNIGHTS, CONFRONT_KEEP_LA_FAYE -> { addPlayer(HeadE.HAPPY_TALKING, ""Any suggestions on getting into Mordred's fort?""); addNPC(NPC, HeadE.CALM_TALK, ""My best guess would be using magic. Unfortunately Merlin is our magic expert.""); addPlayer(HeadE.HAPPY_TALKING, ""Ok, well, thanks anyway.""); } case THE_BLACK_CANDLE, OBTAINING_EXCALIBUR, PERFORM_RITUAL, BREAK_MERLIN_CRYSTAL -> { addNPC(NPC, HeadE.CALM_TALK, ""Magic or a ritual may be needed to free Merlin.""); addPlayer(HeadE.HAPPY_TALKING, ""Noted""); } case TALK_TO_ARTHUR, QUEST_COMPLETE -> { addNPC(NPC, HeadE.CALM_TALK, ""We have our wizard back, you are worthy of knighthood.""); addPlayer(HeadE.HAPPY_TALKING, ""Thanks...""); } } } }" "package com.rs.game.content.quests.merlinscrystal.knightsroundtable; @PluginEventHandler public class SirTristramMerlinsCrystalD extends Conversation { private final static int NPC = 243; public SirTristramMerlinsCrystalD(Player player) { super(player); switch(player.getQuestManager().getStage(Quest.MERLINS_CRYSTAL)) { case NOT_STARTED -> { addNPC(NPC, HeadE.CALM_TALK, ""Hail Arthur, King of the Britons!""); addPlayer(HeadE.HAPPY_TALKING, ""Um... Hello.I'm looking for adventure! More specifically, some sort of quest.""); addNPC(NPC, HeadE.CALM_TALK, ""... Then hail Arthur, King of the Britons, like I just said.""); addPlayer(HeadE.HAPPY_TALKING, ""Oh. Ok. I thought you just had a weird way of saying hello is all.""); } case TALK_TO_KNIGHTS, CONFRONT_KEEP_LA_FAYE -> { addPlayer(HeadE.HAPPY_TALKING, ""Um...Hello. I need to get into Mordred's Fort...""); addNPC(NPC, HeadE.CALM_TALK, ""Good luck with that!""); } case THE_BLACK_CANDLE, OBTAINING_EXCALIBUR, PERFORM_RITUAL, BREAK_MERLIN_CRYSTAL -> { addNPC(NPC, HeadE.CALM_TALK, ""Good luck adventurer!""); addPlayer(HeadE.HAPPY_TALKING, ""Umm, okay.""); } case TALK_TO_ARTHUR, QUEST_COMPLETE -> { addNPC(NPC, HeadE.CALM_TALK, ""I am surprised you freed Merlin, luck is on your side!""); addPlayer(HeadE.FRUSTRATED, ""Skill more like it.""); } } } }" "package com.rs.game.content.quests.monksfriend; @QuestHandler( quest = Quest.MONKS_FRIEND, startText = ""Speak to Brother Omad at the Monastery south of Ardougne."", itemsText = ""Jug of water, logs (or a hatchet)."", combatText = ""You can choose to defeat two level 21 thieves and a level 25 head thief."", rewardsText = ""2,000 Woodcutting XP
8 law runes"", completedStage = 5 ) @PluginEventHandler public class MonksFriend extends QuestOutline { public final static int NOT_STARTED = 0; public final static int GET_BLANKET = 1; public final static int ASK_ABOUT_PARTY = 2; public final static int HELP_CEDRIC = 3; public final static int RETURN_TO_OMAD = 4; public final static int QUEST_COMPLETE = 5; @Override public List getJournalLines(Player player, int stage) { ArrayList lines = new ArrayList<>(); switch (stage) { case NOT_STARTED -> { lines.add(""A child has had their blanket stolen! Find the thieves'""); lines.add(""den and return the blanket, then help Brother Omad ""); lines.add(""organise the drinks for the child's birthday party.""); lines.add(""""); lines.add(""I can start this quest by speaking to Brother Omad""); lines.add(""in the Monastery south of Ardougne""); lines.add(""""); } case GET_BLANKET -> { lines.add(""I need to find the thief's hideout who took a blanket""); lines.add(""from a poor child. I will need to look around to find it.""); lines.add(""""); } case HELP_CEDRIC -> { lines.add(""Cedric is somewhere outside the Monastary. He needs""); lines.add(""help before returning back to brother Omad.""); lines.add(""""); } case QUEST_COMPLETE -> { lines.add(""""); lines.add(""""); lines.add(""QUEST COMPLETE!""); } default -> lines.add(""Invalid quest stage. Report this to an administrator.""); } return lines; } //It is a circle around a null ladder. A varbit makes it visible. private static final Tile[] ladderTilesInACircle = new Tile[]{ Tile.of(2561, 3220, 0), Tile.of(2560, 3220, 0), Tile.of(2559, 3220, 0), Tile.of(2559, 3221, 0), Tile.of(2559, 3222, 0), Tile.of(2559, 3223, 0), Tile.of(2560, 3223, 0), Tile.of(2560, 3224, 0), Tile.of(2561, 3224, 0), Tile.of(2562, 3224, 0), Tile.of(2562, 3223, 0), Tile.of(2563, 3223, 0), Tile.of(2563, 3222, 0), Tile.of(2563, 3221, 0), Tile.of(2562, 3221, 0), Tile.of(2562, 3220, 0) }; public static PlayerStepHandler handleInvisibleLadder = new PlayerStepHandler(ladderTilesInACircle, e -> { Player p = e.getPlayer(); p.getVars().setVarBit(4833, 1); }); public static ObjectClickHandler handleThiefLadder = new ObjectClickHandler(new Object[]{42, 32015}, e -> { Player p = e.getPlayer(); if (e.getObjectId() == 42) p.useLadder(Tile.of(2561, 9621, 0)); else if (e.getObject().getTile().matches(Tile.of(2561, 9622, 0))) p.useLadder(Tile.of(2560, 3222, 0)); }); @Override public void complete(Player player) { player.getInventory().addItem(563, 8, true); player.getSkills().addXpQuest(Constants.WOODCUTTING, 2000); sendQuestCompleteInterface(player, 563); } }" "package com.rs.game.content.quests.monksfriend.dialogues; @PluginEventHandler public class BrotherCedricMonksFriendD extends Conversation { private static final int NPC = 280; public BrotherCedricMonksFriendD(Player player) { super(player); switch (player.getQuestManager().getStage(Quest.MONKS_FRIEND)) { case HELP_CEDRIC -> { if (player.getQuestManager().getAttribs(Quest.MONKS_FRIEND).getB(""cedric_drank_water"")) { if (player.getInventory().containsItem(1511, 1)) { addNPC(NPC, HeadE.CALM_TALK, ""Now I just need to fix this cart and we can go party.""); addNPC(NPC, HeadE.CALM_TALK, ""Could you help and bring me logs?""); addPlayer(HeadE.HAPPY_TALKING, ""I have some right here...""); addSimple(""You give him the logs"", () -> { player.getInventory().removeItems(new Item(1511, 1)); player.getQuestManager().setStage(Quest.MONKS_FRIEND, RETURN_TO_OMAD); }); addNPC(NPC, HeadE.CALM_TALK, ""Well done! Now I'll fix this cart. You head back to Brother Omad and tell him I'll be there soon.""); addPlayer(HeadE.HAPPY_TALKING, ""Ok! I'll see you later!""); } else { addNPC(NPC, HeadE.CALM_TALK, ""Now I just need to fix this cart and we can go party.""); addNPC(NPC, HeadE.CALM_TALK, ""Do you have some wood?""); addPlayer(HeadE.FRUSTRATED, ""No I'm afraid.""); } return; } if (player.getQuestManager().getAttribs(Quest.MONKS_FRIEND).getB(""cedric_needs_water"")) { if (player.getInventory().containsItem(1937, 1)) { addPlayer(HeadE.HAPPY_TALKING, ""Are you okay?""); addNPC(NPC, HeadE.CALM_TALK, ""Hic up! Oh my head! I need a jug of water.""); addPlayer(HeadE.HAPPY_TALKING, ""Cedric! Here, drink! I have some water.""); addNPC(NPC, HeadE.CALM_TALK, ""Good stuff, my head's spinning!""); addNPC(NPC, HeadE.CALM_TALK, ""Aah! That's better!"", () -> { player.getInventory().removeItems(new Item(1937, 1)); player.getQuestManager().getAttribs(Quest.MONKS_FRIEND).setB(""cedric_drank_water"", true); }); addNPC(NPC, HeadE.CALM_TALK, ""Now I just need to fix this cart and we can go party.""); addNPC(NPC, HeadE.CALM_TALK, ""Can you get me som wood?""); addPlayer(HeadE.FRUSTRATED, ""*Sigh""); } else { addNPC(NPC, HeadE.DRUNK, ""Do you have a jug of *hic water?""); addPlayer(HeadE.FRUSTRATED, ""Umm no...""); } return; } addPlayer(HeadE.CALM_TALK, ""Brother Cedric are you okay?""); addNPC(NPC, HeadE.DRUNK, ""Yeesshhh, I'm very, very drunk..hic..up..""); addPlayer(HeadE.SKEPTICAL_THINKING, ""Brother Omad needs the wine for the party.""); addNPC(NPC, HeadE.DRUNK, ""Oh dear, oh dear, I knew I had to do something!""); addNPC(NPC, HeadE.DRUNK, ""Hic up! Oh my head! I need a jug of water.""); addPlayer(HeadE.FRUSTRATED, ""I'll see if I can get some."", () -> player.getQuestManager().getAttribs(Quest.MONKS_FRIEND).setB(""cedric_needs_water"", true)); addNPC(NPC, HeadE.DRUNK, ""Thanks! *hic*""); } case RETURN_TO_OMAD -> { addPlayer(HeadE.HAPPY_TALKING, ""Hello Cedric.""); addNPC(NPC, HeadE.CALM_TALK, ""Hi, I'm almost done here. Could you tell Omad that I'll be back soon?""); } default -> { addPlayer(HeadE.CALM, ""Hello.""); addNPC(NPC, HeadE.DRUNK, ""Honey, money, woman and wine!""); addPlayer(HeadE.SECRETIVE, ""Are you ok?""); addNPC(NPC, HeadE.DRUNK, ""Yesshh...hic up...beautiful!""); addPlayer(HeadE.CALM_TALK, ""Take care old monk.""); addNPC(NPC, HeadE.DRUNK, ""La..di..da..hic..up!""); } } } }" "package com.rs.game.content.quests.monksfriend.dialogues; @PluginEventHandler public class BrotherOmadMonksFriendD extends Conversation { private static final int NPC = 279; private static final int PARTY_TICK_LENGTH = Ticks.fromSeconds(30); public BrotherOmadMonksFriendD(Player player) { super(player); Dialogue cedricOptions = new Dialogue(); cedricOptions.addOptions(""Choose an option:"", new Options() { @Override public void create() { option(""I've got no time for that, sorry."", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""I've got no time for that, sorry."") .addNPC(NPC, HeadE.CALM_TALK, ""Okay traveler, take care."") ); option(""Where should I look?"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Where should I look?"") .addNPC(NPC, HeadE.CALM_TALK, ""Oh, he won't be far. He might've taken a wrong turn between here and Ardougne."") .addPlayer(HeadE.HAPPY_TALKING, ""Ok, I'll go and find him."", () -> player.getQuestManager().setStage(Quest.MONKS_FRIEND, HELP_CEDRIC)) ); option(""Can I come to the party?"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""' Can I come to the party?"") .addNPC(NPC, HeadE.CALM_TALK, ""Of course, but we need the wine first."") .addNext(() -> player.startConversation(cedricOptions)) ); } }); Dialogue party = new Dialogue().addPlayer(HeadE.HAPPY_TALKING, ""Ooh! What party?"") .addNPC(NPC, HeadE.CALM_TALK, ""Brother Androe's son's birthday party. He's going to be one year old!"") .addPlayer(HeadE.HAPPY_TALKING, ""That's sweet!"") .addNPC(NPC, HeadE.CALM_TALK, ""It's also a great excuse for a drink!"") .addNPC(NPC, HeadE.CALM_TALK, ""We just need Brother Cedric to return with the wine."") .addOptions(""Choose an option:"", new Options() { @Override public void create() { option(""Who's Brother Cedric?"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Who's Brother Cedric?"") .addNPC(NPC, HeadE.CALM_TALK, ""Cedric is a member of the order too. We sent him out three days ago to collect wine. But he didn't return!"") .addNPC(NPC, HeadE.CALM_TALK, ""He most probably got drunk and lost in the forest!"") .addNPC(NPC, HeadE.CALM_TALK, ""I don't suppose you could go look for him?"") .addNext(() -> player.startConversation(cedricOptions)) ); option(""Enjoy it! I'll see you soon!"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Enjoy it! I'll see you soon!"") .addNPC(NPC, HeadE.CALM_TALK, ""Take care traveler"") ); } }); switch (player.getQuestManager().getStage(Quest.MONKS_FRIEND)) { case NOT_STARTED -> { Dialogue start = new Dialogue().addPlayer(HeadE.HAPPY_TALKING, ""Can I help at all?"") .addNPC(NPC, HeadE.CALM_TALK, ""Would you? We won't be able to help you as we are peaceful men but we would be grateful for your help!"") .addPlayer(HeadE.HAPPY_TALKING, ""Do you know where the thieves went?"") .addNPC(NPC, HeadE.CALM_TALK, ""They hide in a secret cave near the battlefield to the west. It's hidden under a ring of stones."") .addNPC(NPC, HeadE.CALM_TALK, ""Please bring back the blanket!"", () -> player.getQuestManager().setStage(Quest.MONKS_FRIEND, GET_BLANKET)); addPlayer(HeadE.HAPPY_TALKING, ""Hello there. What's wrong?""); addNPC(NPC, HeadE.CALM_TALK, ""*yawn* ...oh, hello... yawn* I'm sorry! I'm just so tired! I haven't slept in a week!""); addOptions(""Start Monk's Friend?"", new Options() { @Override public void create() { option(""Yes."", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Why can't you sleep?"") .addNPC(NPC, HeadE.CALM_TALK, ""It's Brother Androe's son, with his constant 'Waaaaaah! Waaaaaaaah!' Androe said it's natural,"" + "" but it's so annoying!"") .addPlayer(HeadE.HAPPY_TALKING, ""I suppose that's what kids do."") .addNPC(NPC, HeadE.CALM_TALK, ""He was fine, up until last week! Thieves broke in! They stole his favourite sleeping blanket!"") .addNPC(NPC, HeadE.CALM_TALK, ""Now he won't rest until it's returned... ...and that means neither can I!"") .addOptions(""Choose an option:"", new Options() { @Override public void create() { option(""Why would they steal a kid's blanket?"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Why would they steal a kid's blanket?"") .addNPC(NPC, HeadE.CALM_TALK, ""Who knows? Young scallywags! You'll find hundreds of people in the marketplace, "" + ""pilfering from the stalls while the owners' backs are turned."") .addNext(() -> player.startConversation(start)) ); option(""Can I help at all?"", new Dialogue() .addNext(() -> player.startConversation(start)) ); } }) ); option(""No"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Sorry, I'm too busy to hear your problems!"") .addNPC(NPC, HeadE.SAD_MILD_LOOK_DOWN, ""Okay..."") ); } }); } case GET_BLANKET -> { addPlayer(HeadE.HAPPY_TALKING, ""Hello.""); addNPC(NPC, HeadE.CALM_TALK, ""*yawn*...oh, hello again...*yawn*""); addNPC(NPC, HeadE.CALM_TALK, ""Please tell me you have the blanket.""); if (player.getInventory().containsItems(new Item(90, 1))) { addPlayer(HeadE.HAPPY_TALKING, ""Yes! I've recovered it from the clutches of the evil thieves!""); addSimple(""You hand the monk the child's blanket."", () -> { player.getInventory().removeItems(new Item(90, 1)); player.getQuestManager().setStage(Quest.MONKS_FRIEND, ASK_ABOUT_PARTY); }); addNPC(NPC, HeadE.CALM_TALK, ""Really, that's excellent, well done! Maybe now I'll be able to get some sleep.""); addOptions(""Choose an option:"", new Options() { @Override public void create() { option(""Is there anything else I can help with?"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Is there anything else I can help with?"") .addNPC(NPC, HeadE.CALM_TALK, ""I'm glad you asked, you see there's this party."") .addNext(() -> player.startConversation(party)) ); option(""Farewell!"", new Dialogue()); } }); } else { addPlayer(HeadE.HAPPY_TALKING, ""I'm afraid not.""); addNPC(NPC, HeadE.CALM_TALK, ""I need some sleep!""); } } case ASK_ABOUT_PARTY -> { addPlayer(HeadE.HAPPY_TALKING, ""Hello, how are you?""); addNPC(NPC, HeadE.CALM_TALK, ""Much better now I'm sleeping well! Now I can organise the party.""); addNext(() -> player.startConversation(party)); } case HELP_CEDRIC -> { addPlayer(HeadE.HAPPY_TALKING, ""Hello brother Omad.""); addNPC(NPC, HeadE.CALM_TALK, ""Hello adventurer, have you found Brother Cedric?""); addPlayer(HeadE.HAPPY_TALKING, ""Not yet.""); addNPC(NPC, HeadE.CALM_TALK, ""Well, keep looking, we need that wine!""); } case RETURN_TO_OMAD -> { addPlayer(HeadE.HAPPY_TALKING, ""Hi Omad, Brother Cedric is on his way!""); addNPC(NPC, HeadE.CALM_TALK, ""Good! Good! Now we can party!""); addNPC(NPC, HeadE.CALM_TALK, ""I have little to repay you with, but I'd like to offer you some rune stones. But first, let's party!""); addNext(() -> partyTime(this.player)); } case QUEST_COMPLETE -> { if (System.currentTimeMillis() - player.getTempAttribs().getL(""last_party_time"") < 1000 * 60 * 30) addNPC(NPC, HeadE.DRUNK, ""Dum dee do la la! *hiccup* That was some party!""); else { addNPC(NPC, HeadE.CALM_TALK, ""Wanna join our party "" + this.player.getPronoun(""brother "", ""sister "") + player.getDisplayName() + ""?""); addOptions(""Join their party?"", new Options() { @Override public void create() { option(""Let's party!"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Let's party!"") .addNext(() -> partyTime(player)) ); option(""No thank you."", new Dialogue()); } }); } } } } /** * Every 4 ticks make a monk dance. Each 4 is 0 1 2 3 0 1 2 3 0 1 2 3 with modulus... * * @param p */ public static void partyTime(Player p) { p.lock(); p.getTempAttribs().setL(""last_party_time"", System.currentTimeMillis()); String[] dancePhrases = new String[]{""Let's boogie!"", ""Get down!"", ""Let's dance!"", ""Party time!"", ""Feel the rhythm!"", ""Watch me go!"", ""Party!"", ""Woop!"", ""Oh my!""}; ArrayList monks = new ArrayList<>(); for (NPC npc : World.getNPCsInChunkRange(p.getChunkId(), 1)) if (npc.getName().equalsIgnoreCase(""Monk"") || npc.getName().equalsIgnoreCase(""Brother Omad"")) monks.add(npc); WorldTasks.scheduleTimer(i -> { if (i % 15 == 3) { p.setNextAnimation(new Animation(818)); p.forceTalk(dancePhrases[Utils.random(0, dancePhrases.length)]); throwBalloons(); } if (i % 4 == 0) { int monkIndex = (i / 4) % monks.size(); monks.get(monkIndex).setLockedForTicks(4); monks.get(monkIndex).setNextAnimation(new Animation(818)); if (Utils.randomInclusive(0, 1) == 0) monks.get(monkIndex).forceTalk(dancePhrases[Utils.random(0, dancePhrases.length)]); } if (i == PARTY_TICK_LENGTH) { p.getQuestManager().completeQuest(Quest.MONKS_FRIEND); p.unlock(); return false; } return true; }); } public static void throwBalloons() { ArrayList balloons = new ArrayList<>(); for (int x = 2601; x < 2612; x++) for (int y = 3205; y < 3222; y++) if (World.getObject(Tile.of(x, y, 0)) == null && (ClipFlag.flagged(World.getClipFlags(0, x, y), ClipFlag.UNDER_ROOF))) if (Utils.randomInclusive(0, 1) == 0) balloons.add(new Balloon(PartyRoom.getRandomBalloon(), 0, x, y, 0)); WorldTasks.scheduleTimer(i -> { if (i == 0) { World.spawnObjectTemporary(balloons.get(i), Ticks.fromSeconds(25)); return true; } i *= 2; i--; if (i >= balloons.size()) return false; World.spawnObjectTemporary(balloons.get(i), Ticks.fromSeconds(25)); i++; if (i >= balloons.size()) return false; World.spawnObjectTemporary(balloons.get(i), Ticks.fromSeconds(25)); return true; }); } }" "package com.rs.game.content.quests.naturespirit enum class BloomResource(val druidPouch: Int, val itemId: Int, val objectIds: Map) { FUNGI_ON_LOG(1, 2970, mapOf(3508 to 3509, 50718 to 50736, 50746 to 50791)), BUDDING_BRANCH(2, 2972, mapOf(3510 to 3511, 50838 to 50853, 50895 to 50907)), GOLDEN_PEAR_BUSH(3, 2974, mapOf(3512 to 3513, 50984 to 51073, 51081 to 51088)); companion object { fun forItem(id: Int): BloomResource? = entries.firstOrNull { it.itemId == id } fun forPickableObject(id: Int): BloomResource? = entries.firstOrNull { it.objectIds.containsValue(id) } fun forEmptyObject(id: Int): BloomResource? = entries.firstOrNull { it.objectIds.containsKey(id) } } } @ServerStartupEvent fun mapBlooming() { onItemClick(2957, 2958, options = arrayOf(""Fill"")) { e -> with(e.player) { if (getQuestStage(Quest.NATURE_SPIRIT) < STAGE_KILL_GHASTS) { sendMessage(""You haven't been taught how to use this yet."") return@onItemClick } var filled = false inventory.items.array().forEach { item -> item?.let { BloomResource.forItem(item.id)?.also { filled = true inventory.deleteItem(item) e.item.amount += it.druidPouch if (e.item.id == 2957) { e.item.id = 2958 e.item.amount-- } } } } if (filled) inventory.refresh() else sendMessage(""You need some blossomed items to add something to the druid pouch."") } } onObjectClick(*BloomResource.entries.flatMap { it.objectIds.values.toList() }.toTypedArray()) { e -> val product = BloomResource.forPickableObject(e.objectId)!! val productName = ItemDefinitions.getDefs(product.itemId).getName().lowercase(Locale.getDefault()) e.player.anim(3659) e.player.lock(1) e.player.tasks.schedule { if (e.player.inventory.addItemDrop(product.itemId, 1)) { e.player.sendMessage(""You pick a $productName."") e.player.incrementCount(""$productName bloomed"", 1) e.getObject().setId(e.getObject().originalId) } } } onItemClick(2963, options = arrayOf(""Bloom"")) { castBloom(it.player, true) } onItemClick(2968, options = arrayOf(""Cast"")) { e -> if (e.player.getQuestStage(Quest.NATURE_SPIRIT) <= STAGE_GET_BLESSED) { e.player.sendMessage(""You need to be blessed before you can cast this."") return@onItemClick } castBloom(e.player, false) e.item.id = 2969 e.player.inventory.refresh(e.item.slot) e.player.questManager.getAttribs(Quest.NATURE_SPIRIT).setB(""castedBloom"", true) } } fun castBloom(player: Player, sickle: Boolean) { if (player.prayer.points < 60) { player.sendMessage(""You need more prayer points to do this."") return } player.prayer.drainPrayer(Utils.random(10.0, 60.0)) player.lock(2) player.anim(if (sickle) 9104 else 9098) for (x in -1..1) for (y in -1..1) { if (x == 0 && y == 0) continue World.sendSpotAnim(player.transform(x, y), SpotAnim(263)) val obj = World.getObject(player.transform(x, y), ObjectType.SCENERY_INTERACT) ?: continue val resource = BloomResource.forEmptyObject(obj.id) ?: continue if (!sickle && resource != BloomResource.FUNGI_ON_LOG) continue resource.objectIds[obj.id]?.let { obj.setIdTemporary(it, Ticks.fromSeconds(30)) } } }" "package com.rs.game.content.quests.naturespirit fun drezelNatureSpiritOptions(player: Player, npc: NPC, options: Options) { if (!Quest.NATURE_SPIRIT.meetsReqs(player)) return when(player.getQuestStage(Quest.NATURE_SPIRIT)) { STAGE_UNSTARTED -> options.add(""Is there anything else interesting to do around here?"") { player.startConversation { player(CONFUSED, ""Is there anything else interesting to do around here?"") npc(DREZEL, CALM_TALK, ""Well, not a great deal... but there is something you could do for me if you're interested. Though it is quite dangerous."") questStart(Quest.NATURE_SPIRIT) player(CONFUSED, ""Well, what is it, I may be able to help?"") npc(DREZEL, CALM_TALK, ""There's a man called Filliman who lives in Mort Myre, I wonder if you could look for him? The swamps of Mort Myre are dangerous, though. They're infested with Ghasts!"") label(""options"") options { op(""Who is this Filliman?"") { player(CONFUSED, ""Who is this Filliman?"") npc(DREZEL, CALM_TALK, ""Filliman Tarlock is his full name and he's a Druid. He lives in Mort Myre much like a hermit, but there's many a traveller who he's helped."") npc(DREZEL, CHEERFUL, ""Most people that come his way tell stories of when they were lost and paths that just seemed to 'open up' before them! I think it was Filliman Tarlock helping out."") goto(""options"") } op(""Where's Mort Myre?"") { player(CONFUSED, ""Where's Mort Myre?"") npc(DREZEL, CALM_TALK, ""Mort Myre is a decayed and dangerous swamp to the south. It was once a beautiful forest but has since become filled with vile emanations from within Morytania."") npc(DREZEL, CALM_TALK, ""The swamp decays everything. We put a fence around it to stop unwary travellers going in. Anyone who dies in the swamp is forever cursed to haunt it as a Ghast. Ghasts attack travellers, turning food to rotten filth."") goto(""options"") } op(""What's a Ghast?"") { player(CONFUSED, ""What's a Ghast?"") npc(DREZEL, CALM_TALK, ""A Ghast is a poor soul who died in Mort Myre. They're undead of a special class, they're untouchable as far as I'm aware!"") npc(DREZEL, CALM_TALK, ""Filliman knew how to tackle them, but I've not heard from him in a long time. Ghasts, when they attack, will devour any food you have. If you have no food, they'll draw their nourishment from you!"") goto(""options"") } op(""Yes, I'll go and look for him."") { player(CHEERFUL, ""Yes, I'll go and look for him."") npc(DREZEL, CONFUSED, ""That's great, but it's very dangerous. Are you sure you want to do this?"") options { op(""Yes I'm sure."") { player(CHEERFUL, ""Yes, I'm sure"") npc(DREZEL, CHEERFUL, ""That's great! Many thanks! Now then, please be aware of the Ghasts, you cannot attack them. Only Filliman knew how to take them on."") npc(DREZEL, CHEERFUL, ""Just run from them if you can. If you start to get lost, try to make your way back to the temple."") item(2327, ""The cleric hands you some food."") npc(DREZEL, CHEERFUL, ""Please take this food to Filliman, he'll probably appreciate a bit of cooked food. He used to live to the South of the swamps. Search for him won't you?"") { player.setQuestStage(Quest.NATURE_SPIRIT, STAGE_FIND_FILLIMAN) player.inventory.addItemDrop(2327, 3) player.inventory.addItemDrop(2323, 3) } player(CHEERFUL, ""I'll do my best, don't worry, if he's in there and he's still alive I'll definitely find him."") npc(DREZEL, CONFUSED, ""I saved a few runes to allow me to travel quickly to Filliman's old camp, however, I was never able to use them, and now of course I cannot leave. If you can return to me and confirm he is safe, I will gladly allow you to use them."") } op(""Sorry, I don't think I can help."") } } op(""Sorry, I don't think I can help."") } } } STAGE_FIND_FILLIMAN -> options.add(""Talk about Nature Spirit"") { player.startConversation { player(CHEERFUL, ""Hello again!"") npc(DREZEL, CONFUSED, ""Have you managed to find Filliman yet?"") player(SAD, ""No, not yet."") npc(DREZEL, WORRIED, ""Please go and look for him, I would appreciate it!"") label(""options"") options { op(""Where should I look for Filliman Tarlock again?"") { player(CONFUSED, ""Where should I look for Filliman Tarlock again?"") npc(DREZEL, CALM_TALK, ""Search to the south of Mort Myre. Remember that he's a druid so he can conceal himself within nature quite well. My guess is that he lives in the southern area of the swamp, though he could be anywhere."") goto(""options"") } op(""Explain to me what a Ghast is again."") { player(CONFUSED, ""Explain to me what a Ghast is again."") npc(DREZEL, CALM_TALK, ""A Ghast is a poor soul who died in Mort Myre. They're undead of a special class, they're untouchable without special druidic items."") npc(DREZEL, CALM_TALK, ""Filliman knew how to tackle them, but I've not heard from him in a long time. Ghasts, when they attack, will devour any food you have. If you have no food, they'll draw their nourishment from you!"") goto(""options"") } op(""What's the story with Mort Myre?"") { player(CONFUSED, ""What's the story with Mort Myre?"") npc(DREZEL, CALM_TALK, ""Mort Myre was once a beautiful forest by the name of Humblethorn until the evil denizens of Morytania descended. Now their evil emanations have putrified and diseased the forest into a decaying swamp of death."") goto(""options"") } op(""What's the story with Filliman Tarlock?"") { player(CONFUSED, ""What's the story with Filliman Tarlock?"") npc(DREZEL, CALM_TALK, ""Filliman is a druid of some considerable power. He helped many people in Morytania escape when the evil descended upon the land. His knowledge of plants and nature was exceptional."") npc(DREZEL, CALM_TALK, ""But one day, he was betrayed by some of the people who he had tried to help. This naturally made him more careful when dealing with strangers again and so, instead of showing himself, he would follow them."") npc(DREZEL, CALM_TALK, ""He would follow them at a distance and make the path clear for them, showing them to the temple and to salvation. Saradomin bless him! He is a good man."") goto(""options"") } op(""Ok, thanks."") { npc(DREZEL, CHEERFUL, ""Many thanks to you, ${player.genderTerm(""brother"", ""sister"")}!"") } } } } STAGE_PROVE_GHOST, STAGE_GAVE_JOURNAL -> options.add(""Talk about Nature Spirit"") { player.startConversation { npc(DREZEL, CHEERFUL, ""Greetings again adventurer. How go your travels in Morytania? Is it as evil as I have heard?"") player(SAD_MILD, ""I've found Filliman and you should prepare for some sad news."") npc(DREZEL, CONFUSED, ""You mean... he's dead?"") player(SAD_MILD, ""Yes, but I am still in the process of helping him with something."") npc(DREZEL, CONFUSED, ""Hmmm, that's very interesting, please do let me know how you get on with it."") } } STAGE_GET_BLESSED -> options.add(""Talk about Nature Spirit"") { player.startConversation { npc(DREZEL, CHEERFUL, ""Greetings again adventurer. How go your travels in Morytania? Is it as evil as I have heard?"") player(CHEERFUL, ""Hello again! I'm helping Filliman, he plans to become a nature spirit. I have a spell to cast but first I need to be blessed. Can you bless me?"") npc(DREZEL, CHEERFUL, ""But you haven't sneezed!"") player(CHEERFUL, ""You're so funny! But can you bless me?"") npc(DREZEL, CHEERFUL, ""Very well my friend, prepare yourself for the blessings of Saradomin. Here we go!"") { npc.anim(811) player.anim(645) npc.forceTalk(""Ashustru, blessidium, adverturasi, fidum!"") World.sendProjectile(npc, player, 268, 15, 15, 0.6) { player.spotAnim(259) } player.setQuestStage(Quest.NATURE_SPIRIT, STAGE_CAST_BLOOM) } npc(DREZEL, CHEERFUL, ""There you go my friend, you're now blessed. It's funny, now I look at you, there seems to be something of the faith about you. It sounds like you should get back to Filliman without delay. Would you like me to use my runes to teleport you?"") options { opExec(""Yes, please."") { npc.anim(811) Magic.sendNormalTeleportSpell(player, Tile.of(3439, 3335, 0)) } op(""No thank you."") { npc(DREZEL, CHEERFUL, ""I will keep them then, unless you manage to find our own way there."") } } } } STAGE_CAST_BLOOM, STAGE_PUZZLING_IT_OUT, STAGE_MEET_IN_GROTTO -> options.add(""Talk about Nature Spirit"") { player.startConversation { npc(DREZEL, CONFUSED, ""How's life been treating you since you got blessed?"") player(CHEERFUL, ""No so bad!"") //Didn't read and take the teleport earlier? Get bent idiot. } } STAGE_BRING_SICKLE -> options.add(""Talk about Nature Spirit"") { player.startConversation { npc(DREZEL, CHEERFUL, ""Greetings again adventurer. How go your travels in Morytania? Is it as evil as I have heard?"") player(CHEERFUL, ""Hi again. Filliman has turned into the Nature Spirit. I now need to get a silver sickle so that I can try and defeat the Ghasts. Do you know where I could get something like that?"") npc(DREZEL, CHEERFUL, ""Well, let me think now. Aha, yes, if you're making something from silver, you'll more than likely need a mould, most crafting shops sell them, you could get one from Al Kharid. You can mine silver from a silver rock, you can find some on the way to Al Kharid."") } } STAGE_KILL_GHASTS -> options.add(""Talk about Nature Spirit"") { player.startConversation { player(CHEERFUL, ""Hiya, I'm a mighty Ghast killer!"") npc(DREZEL, CHEERFUL, ""That's great! How many did Filliman ask you kill?"") player(CHEERFUL, ""He asked me to kill 3!"") npc(DREZEL, CHEERFUL, ""Better kill them then go and tell him, I'll bet he'll be pleased."") } } } } fun fillimanDialogue(player: Player, npc: NPC) { fun checkGhostSpeak(player: Player, builder: DialogueBuilder): Boolean { if (!player.canSpeakWithGhosts()) { builder.npc(FILLIMAN, SAD, ""Ahhrs Ooooooh arhhhhAHhhh."") return false } return true } when(player.getQuestStage(Quest.NATURE_SPIRIT)) { STAGE_FIND_FILLIMAN, STAGE_PROVE_GHOST -> player.startConversation { if (!player.canSpeakWithGhosts()) { npc(FILLIMAN, CONFUSED, ""Cannot wake up... Where am I?"") player(CONFUSED, ""Huh? What's this?"") npc(FILLIMAN, CONFUSED, ""What did I write down now? Put it in the knot hole."") npc(FILLIMAN, SAD, ""Ahhrs Ooooooh arhhhhAHhhh."") player(CONFUSED, ""Huh! Now you're just not making any sense at all! I just cannot understand you!"") return@startConversation } if (player.getQuestStage(Quest.NATURE_SPIRIT) == STAGE_PROVE_GHOST) { player(CHEERFUL, ""Hello again!"") npc(FILLIMAN, SAD, ""Oh, hello there, do you still think I'm dead? It's hard to see how I could be dead when I'm still in the world. I can see everything quite clearly. And nothing of what you say reflects the truth."") if (player.inventory.containsItem(2966)) { item(2966, ""You use the mirror on the spirit of the dead Filliman Tarlock."") player(CALM_TALK, ""Here take a look at this, perhaps you can see that you're utterly transparent now!"") item(2966, ""The spirit of Filliman reaches forwards and takes the mirror."") npc(FILLIMAN, CONFUSED, ""Well, that is the most peculiar thing I've ever experienced. This mirror must somehow be dysfunctional. Strange how well it reflects the stagnant swamp behind me, but there is nothing of my own visage apparent."") player(AMAZED_MILD, ""That's because you're dead! Dead as a door nail... Deader in fact... You bear a remarkable resemblance to wormbait! Err... No offence..."") npc(FILLIMAN, SAD, ""I think you might be right my friend, though I still feel very much alive. It is strange how I still come to be here and yet I've not turned into a Ghast. It must be a sign... Yes a sign... I must try to find out what it means. Now, where did I put my journal?"") if (player.inventory.containsItem(2967)) { item(2967, ""You give the journal to Filliman Tarlock."") player(CONFUSED, ""Here, I found this, maybe you can use it?"") npc(FILLIMAN, CHEERFUL, ""My journal! That should help to collect my thoughts."") item(2967, ""~ The spirit starts leafing through the journal ~
~ He seems quite distant as he regards the pages ~
~ After some time the druid faces you again ~"") npc(FILLIMAN, SAD, ""It's all coming back to me now. It looks like I came to a violent and bitter end but that's not important now. I just have to figure out what I am going to do now?"") exec { player.inventory.deleteItem(2967, 1) player.setQuestStage(Quest.NATURE_SPIRIT, STAGE_GAVE_JOURNAL) } } else { player(CONFUSED, ""Where did you put it?"") npc(FILLIMAN, CONFUSED, ""Well, if I knew that, I wouldn't still be looking for it. However, I do remember something about a knot? Perhaps I was meant to tie a knot or something?"") } } return@startConversation } else { player(CONFUSED, ""Hello?"") npc(FILLIMAN, AMAZED_MILD, ""Oh, I understand you! At last, someone who doesn't just mumble. I understand what you're saying!"") } options { op(""I'm wearing an amulet of ghost speak!"") { player(CHEERFUL, ""I'm wearing an amulet of ghost speak!"") npc(FILLIMAN, SAD, ""Why you poor fellow, have you passed away and you want to send a message back to a loved one?"") player(CONFUSED, ""Err.. Not exactly..."") npc(FILLIMAN, SAD, ""You have come to haunt my dreams until I pass on your message to a dearly loved one. I understand. Pray, tell me who would you like me to pass a message on to?"") player(CONFUSED, ""Ermm, you don't understand... It's just that.."") npc(FILLIMAN, SAD, ""Yes!"") player(CONFUSED, ""Well, please don't be upset or anything... But you're the ghost!"") npc(FILLIMAN, AMAZED_MILD, ""Don't be silly now! That in no way reflects the truth!"") { if (player.getQuestStage(Quest.NATURE_SPIRIT) < STAGE_PROVE_GHOST) player.setQuestStage(Quest.NATURE_SPIRIT, STAGE_PROVE_GHOST) } } op(""How long have you been a ghost?"") { player(CONFUSED, ""How long have you been a ghost?"") npc(FILLIMAN, AMAZED_MILD, ""What?! Don't be preposterous! I'm not a ghost! How could you say something like that?"") player(CONFUSED, ""But it's true, you're a ghost... well, at least that is to say, you're sort of not alive anymore."") npc(FILLIMAN, SAD, ""Don't be silly, I can see you. I can see that tree. If I were dead, I wouldn't be able to see anything. What you say just doesn't reflect the truth. You'll have to try harder to put one over on me!"") { if (player.getQuestStage(Quest.NATURE_SPIRIT) < STAGE_PROVE_GHOST) player.setQuestStage(Quest.NATURE_SPIRIT, STAGE_PROVE_GHOST) } } op(""What's it like being a ghost?"") { player(CONFUSED, ""What's it like being a ghost?"") npc(FILLIMAN, SAD, ""Oh, it's quite.... Oh... Trying to catch me out were you! Anyone can clearly see that I am not a ghost!"") player(CONFUSED, ""But you are a ghost, look at yourself! I can see straight through you! You're as dead as this swamp! Err... No offence or anything..."") npc(FILLIMAN, SAD, ""No I won't take offence because I'm not dead and I'm afraid you'll have to come up with some pretty conclusive proof before I believe it. What a strange dream this is."") { if (player.getQuestStage(Quest.NATURE_SPIRIT) < STAGE_PROVE_GHOST) player.setQuestStage(Quest.NATURE_SPIRIT, STAGE_PROVE_GHOST) } } op(""Ok, thanks."") } } STAGE_GAVE_JOURNAL -> player.startConversation { if (!checkGhostSpeak(player, this)) return@startConversation npc(FILLIMAN, SAD, ""Thanks for the journal, I've been reading it. It looks like I came to a violent and bitter end but that's not really important. I just have to figure out what I am going to do now?"") label(""options"") options { op(""Being dead, what options do you think you have?"") { player(CONFUSED, ""Being dead, what options do you think you have? I'm not trying to be rude or anything, but it's not like you have many options is it? I mean, it's either up or down for you isn't it?"") npc(FILLIMAN, SAD, ""Hmm, well you're a poetic one aren't you. Your material world logic stands you in good stead... If you're standing in the material world..."") goto(""options"") } op(""So, what's your plan?"") { player(CONFUSED, ""So, what's your plan?"") npc(FILLIMAN, CHEERFUL, ""In my former incarnation I was Filliman Tarlock, a great druid of some power. I spent many years in this place, which was once a forest and I would wish to protect it as a nature spirit."") goto(""options"") } op(""Well, good luck with that."") { player(SKEPTICAL, ""Well, good luck with that."") npc(FILLIMAN, SAD, ""Won't you help me to become a nature spirit? I could really use your help!"") goto(""options"") } op(""How can I help?"") { player(CONFUSED, ""How can I help?"") npc(FILLIMAN, CONFUSED, ""Will you help me to become a nature spirit? The directions for becoming one are a bit vague, I need three things but I know how to get one of them. Perhaps you can help collect the rest?"") player(SKEPTICAL, ""I might be interested, what's involved?"") npc(FILLIMAN, SKEPTICAL_THINKING, ""Well, the book says, that I need, and I quote:- 'Something with faith', 'something from nature' and the 'spirit-to-become' freely given'. Hmm, I know how to get something from nature."") player(SKEPTICAL_THINKING, ""Well, that does seem a bit vague."") npc(FILLIMAN, SAD, ""Hmm, it does and I could understand if you didn't want to help. However, if you could perhaps at least get the item from nature, that would be a start. Perhaps we can figure out the rest as we go along."") item(2968, ""The druid produces a small sheet of papyrus with some writing on it."") npc(FILLIMAN, CHEERFUL, ""This spell needs to be cast in the swamp after you have been blessed. I'm afraid you'll need to go to the temple to the North and ask a member of the clergy to bless you."") player(CONFUSED, ""Blessed, what does that do?"") npc(FILLIMAN, CHEERFUL, ""It is required if you're to cast this druid spell. Once you've cast the spell, you should find something from nature. Bring it back to me and then we'll try to figure out the other things we need."") { player.inventory.addItem(2968) player.setQuestStage(Quest.NATURE_SPIRIT, STAGE_GET_BLESSED) } } op(""Ok, thanks."") } } STAGE_GET_BLESSED -> player.startConversation { if (!checkGhostSpeak(player, this)) return@startConversation npc(FILLIMAN, CONFUSED, ""Hello there, have you been blessed yet?"") player(CALM_TALK, ""No, not yet."") npc(FILLIMAN, CHEERFUL, ""Well, hurry up!"") if (!player.containsItem(2968)) { player(CONFUSED, ""Could I have another bloom scroll please?"") npc(FILLIMAN, CALM_TALK, ""Sure, but please look after this one."") item(2968, ""The spirit of Filliman Tarlock gives you another bloom spell."") { player.inventory.addItem(2968) } } } STAGE_CAST_BLOOM -> player.startConversation { if (!checkGhostSpeak(player, this)) return@startConversation if (player.questManager.getAttribs(Quest.NATURE_SPIRIT).getB(""castedBloom"") && player.inventory.containsItem(2970)) { npc(FILLIMAN, CONFUSED, ""Did you manage to get something from nature?"") item(2970, ""You show the fungus to Filliman"") player(CHEERFUL, ""Yes, I have a fungus here that I picked."") npc(FILLIMAN, CHEERFUL, ""Wonderful, the mushroom represents 'something from nature'. Now we need to work out what the other components of the spell are!"") { player.setQuestStage(Quest.NATURE_SPIRIT, STAGE_PUZZLING_IT_OUT) } return@startConversation } player(CONFUSED, ""Hello, I've been blessed but I don't know what to do now."") npc(FILLIMAN, CALM_TALK, ""Well, you need to bring 'something from nature', 'something from faith', and 'something of the spirit-to-become freely given'."") player(CONFUSED, ""Yeah, but what does that mean?"") npc(FILLIMAN, CONFUSED, ""Hmm, it is a conundrum, however, if you use that spell I gave you, you should be able to get from nature. Once you have that, we may be able to puzzle the rest out."") if (!player.containsItem(2968)) { player(CONFUSED, ""Could I have another bloom scroll please?"") npc(FILLIMAN, CALM_TALK, ""Sure, but please look after this one."") item(2968, ""The spirit of Filliman Tarlock gives you another bloom spell."") { player.inventory.addItem(2968) } } } STAGE_PUZZLING_IT_OUT -> player.startConversation { if (!checkGhostSpeak(player, this)) return@startConversation npc(FILLIMAN, CHEERFUL, ""Hello again! I don't suppose you've found out what the other components of the Nature spell are have you?"") label(""options"") options { op(""What are the things that are needed?"") { player(CONFUSED, ""What are the things that are needed again?"") npc(FILLIMAN, CHEERFUL, ""The three things are: 'Something with faith', 'something from nature' and 'something of the spirit-to-become freely given'."") player(CONFUSED, ""Ok, and 'something from nature' is the mushroom from the bloom spell you gave me?"") npc(FILLIMAN, CHEERFUL, ""Yes, that's correct, that seems right to me. The other things we need are 'something with faith' and 'something of the spirit-to-become freely given."") player(CONFUSED, ""Do you have any ideas what those things are?"") npc(FILLIMAN, CHEERFUL, ""I'm sorry my friend, but I do not."") goto(""options"") } op(""What should I do when I have those things?"") { player(CONFUSED, ""What should we do when we have those things?"") npc(FILLIMAN, CHEERFUL, ""Ah yes, I looked this up. It says,.. 'to arrange upon three rocks around the spirit-to-become...'. Then I must cast a spell. As you can see, I've already placed the rocks. I must have planned to do this before I died!"") player(CONFUSED, ""Can we just place the components on any rock?"") npc(FILLIMAN, CHEERFUL, ""Well, the only thing the journal says is that 'something with faith stands south of the spirit-to-become', but I'm so confused now I don't really know what that means. Oh, if only I had all my faculties!"") goto(""options"") } op(""I think I've solved the puzzle!"") { player(CONFUSED, ""I think I've solved the puzzle!"") npc(FILLIMAN, CHEERFUL, ""Oh really.. Have you placed all the items on the stones? Ok, well, lets try!
~ The druid attempts to cast a spell. ~"") exec { npc.anim(811) val fungus = World.getAllGroundItemsInChunkRange(player.chunkId, 1).firstOrNull { it.id == 2970 && it.tile.isAt(3439, 3336, 0) } val spell = World.getAllGroundItemsInChunkRange(player.chunkId, 1).firstOrNull { it.id == 2969 && it.tile.isAt(3441, 3336, 0) } val success = player.tile.isAt(3440, 3335, 0) && (fungus != null || player.questManager.getAttribs(Quest.NATURE_SPIRIT).getB(""placedFungus"")) && (spell != null || player.questManager.getAttribs(Quest.NATURE_SPIRIT).getB(""placedSpell"")) if (success) { fungus.let { World.removeGroundItem(it) } spell.let { World.removeGroundItem(it) } World.sendProjectile(player, npc, 268, 15, 15, 0.6) { player.spotAnim(259) } World.sendProjectile(Tile.of(3439, 3336, 0), npc, 268, 15, 15, 0.6) World.sendProjectile(Tile.of(3441, 3336, 0), npc, 268, 15, 15, 0.6) player.setQuestStage(Quest.NATURE_SPIRIT, STAGE_MEET_IN_GROTTO) player.npcDialogue(FILLIMAN, CHEERFUL, ""Aha, everything seems to be in place! You can come through now into the grotto for the final section of my transformation."") } else player.npcDialogue(FILLIMAN, CONFUSED, ""Hmm, something still doesn't seem right. I think we need something more before we can continue."") } } if (!player.containsItem(2968)) { op(""Could I have another bloom scroll please?"") { player(CONFUSED, ""Could I have another bloom scroll please?"") npc(FILLIMAN, CALM_TALK, ""Sure, but please look after this one."") item(2968, ""The spirit of Filliman Tarlock gives you another bloom spell."") { player.inventory.addItem(2968) } goto(""options"") } } op(""Ok, thanks."") } } STAGE_MEET_IN_GROTTO -> player.startConversation { if (!checkGhostSpeak(player, this)) return@startConversation npc(FILLIMAN, CHEERFUL, ""Well, hello there again, I was just enjoying the grotto. Many thanks for your help, I couldn't have become a Spirit of nature without you."") npc(FILLIMAN, CHEERFUL, ""I must complete the transformation now. Just stand there and watch the show. Apparently it's quite good."") simple(""~The ritual begins~"") { World.sendProjectile(npc.tile.transform(-3, -3), npc.tile, 268, 30, 0, 0.6) World.sendProjectile(npc.tile.transform(3, 3), npc.tile, 268, 30, 0, 0.6) World.sendProjectile(npc.tile.transform(-2, -2), npc.tile, 268, 30, 0, 0.6) World.sendProjectile(npc.tile.transform(2, 2), npc.tile, 268, 30, 0, 0.6) World.sendProjectile(npc.tile.transform(-2, 2), npc.tile, 268, 30, 0, 0.6) World.sendSpotAnim(npc.tile, SpotAnim(259, 50)) player.setQuestStage(Quest.NATURE_SPIRIT, STAGE_BRING_SICKLE) } npc(NATURE_SPIRIT, CHEERFUL, ""Hmmm, good, the transformation is complete. Now, my friend, in return for your assistance, I will help you to kill the Ghasts. First bring to me a silver sickle so that I can bless it for you."") player(CONFUSED, ""A silver sickle? What's that?"") npc(NATURE_SPIRIT, CHEERFUL, ""The sickle is the symbol and weapon of the Druid, you need to construct one of silver so that I can bless it, with its powers you will be able to defeat the Ghasts of Mort Myre."") } STAGE_BRING_SICKLE -> player.startConversation { npc(NATURE_SPIRIT, CONFUSED, ""Have you brought me the silver sickle?"") if (player.inventory.containsOneItem(2961, 2963)) { player(CHEERFUL, ""Yes, here it is. What are you going to do with it?"") npc(NATURE_SPIRIT, CHEERFUL, ""My friend, I will bless it for you and you will then be able to accomplish great things. Now then, I must cast the enchantment. You can bless a new sickle by dipping it in the holy water of the grotto."") { World.sendProjectile(Tile.of(2271, 5341, 0), player, 268, 30, 0, 0.6) World.sendProjectile(Tile.of(2271, 5340, 0), player, 268, 30, 0, 0.6) World.sendProjectile(Tile.of(2272, 5340, 0), player, 268, 30, 0, 0.6) if (player.inventory.containsItem(2961)) { player.inventory.deleteItem(2961, 1) player.inventory.addItem(2963, 1) } } simple(""~ Your sickle has been blessed! You can bless ~
~ a new sickle by dipping it in the grotto waters. ~"") npc(NATURE_SPIRIT, CHEERFUL, ""Now you can go forth and make the swamp bloom. Collect nature's bounty to fill a druids pouch. So armed will the Ghasts be bound to you until, you flee or they are defeated."") npc(NATURE_SPIRIT, CHEERFUL, ""Before I can make this grotto into an Altar of Nature, I need to be sure that the Ghasts will be kept at bay. Go forth into Mort Myre and slay three Ghasts. You'll be releasing their souls from Mort Myre."") item(2957, ""The nature spirit gives you an empty druid pouch."") { player.inventory.addItem(2957) } npc(NATURE_SPIRIT, CHEERFUL, ""You'll need this in order to collect together nature's bounty. When it contains items, it will bind the Ghast to you until you flee or it is defeated."") { player.setQuestStage(Quest.NATURE_SPIRIT, STAGE_KILL_GHASTS) } return@startConversation } player(AMAZED_MILD, ""No sorry, not yet!"") npc(NATURE_SPIRIT, CHEERFUL, ""Well, come to me when you have it."") label(""options"") options { op(""Where would I get a silver sickle?"") { player(CONFUSED, ""Where would I get a silver sickle?"") npc(NATURE_SPIRIT, CHEERFUL, ""You could make one yourself if you're artisan enough. I've heard of a distant sandy place where you can buy the mould that you require, it's similar in many respects to the creating of a holy symbol."") goto(""options"") } op(""What will you do to the silver sickle?"") { player(CONFUSED, ""What will you do to the silver sickle?"") npc(NATURE_SPIRIT, CHEERFUL, ""Why, I will give it my blessings so that the very swamp in which you stand will blossom and bloom!"") goto(""options"") } op(""How can a blessed sickle help me to defeat the Ghasts?"") { player(CONFUSED, ""How can a blessed sickle help me to defeat the Ghasts?"") npc(NATURE_SPIRIT, CHEERFUL, ""My blessings will entice nature to bloom in Mort Myre! And then with nature's harvest you can fill a druids pouch and release the Ghasts from their torment."") goto(""options"") } op(""Ok, thanks."") } } STAGE_KILL_GHASTS -> player.startConversation { npc(NATURE_SPIRIT, CONFUSED, ""Hello again, my friend. Have you defeated three ghasts as I asked you?"") if (player.questManager.getAttribs(Quest.NATURE_SPIRIT).getI(""ghastsKilled"") >= 3) { player(CHEERFUL, ""Yes, I've killed all three and their spirits have been released!"") npc(NATURE_SPIRIT, CHEERFUL, ""Many thanks my friend, you have completed your quest! I can now change this place into a holy sanctuary! And forever will it now be an Altar of Nature!"") npc(NATURE_SPIRIT, CHEERFUL, ""Welcome to my Altar to Nature! Farewell my friend, and keep those ghasts at bay!"") { player.tele(Tile.of(2271, 5334, 1)) player.completeQuest(Quest.NATURE_SPIRIT) } return@startConversation } player(CALM_TALK, ""Not yet."") npc(NATURE_SPIRIT, CHEERFUL, ""Well, when you do, please come to me and I'll reward you!"") options { op(""How do I get to attack the Ghasts?"") { player(CONFUSED, ""How do I get to attack the Ghasts?"") npc(NATURE_SPIRIT, CHEERFUL, ""Go forth and with the sickle make the swamp bloom. Collect natures bounty to fill a druids pouch. So armed will the Ghasts be bound to you until, you flee or they are defeated."") } op(""What's this pouch for?"") { player(CONFUSED, ""What's this pouch for?"") npc(NATURE_SPIRIT, CHEERFUL, ""It is for collecting natures bounty, once it contains the blossomed items of the swamp, it will make the Ghasts appear and you can attack them."") } op(""What can I do with this sickle?"") { player(CONFUSED, ""What can I do with this sickle?"") npc(NATURE_SPIRIT, CHEERFUL, ""You may use it wisely within the area of Mort Myre to affect nature's balance and bring forth a bounty of natures harvest. Once collected into the druid pouch will the Ghast be apparent."") } op(""I've lost my sickle."") { player(SAD, ""I've lost my sickle."") npc(NATURE_SPIRIT, CHEERFUL, ""If you should lose the blessed sickle, simply bring another to my altar of nature and refresh it in the grotto waters."") } op(""Ok, thanks."") } } } }" "package com.rs.game.content.quests.naturespirit val GHASTS = arrayOf(1052, 1053, 14035, 14036, 14037, 14038, 14039, 14040) class Ghast(id: Int, tile: Tile) : NPC(id, tile) { override fun processNPC() { super.processNPC() isForceAgressive = true setCollisionStrategyType(CollisionStrategyType.FLY) } override fun canBeAttackedBy(player: Player): Boolean { return getDefinitions(player).hasAttackOption() } override fun canBeAutoRetaliated(): Boolean { return false } override fun getPossibleTargets(): MutableList { //Can't attack in filliman's grotto zone return super.getPossibleTargets().filter { !intArrayOf(879008, 881056, 881057, 879009).contains(it.chunkId) }.toMutableList() } override fun sendDeath(source: Entity?) { spotAnim(265) if (source != null && source is Player) source.skills.addXp(Skills.PRAYER, 30.0) super.sendDeath(source) } override fun finish() { transformIntoNPC(when (id) { 1053 -> 1052 14038 -> 14035 14039 -> 14036 14040 -> 14037 else -> id }) super.finish() } } @ServerStartupEvent fun mapGhasts() { instantiateNpc(*GHASTS) { id, tile -> Ghast(id, tile) } npcCombat(*GHASTS) { npc, target -> if (npc.definitions.hasAttackOption()) return@npcCombat CombatScriptsHandler.getDefaultCombat().apply(npc, target) if (target is Player) { val pouch = target.inventory.getItemById(2958) if (pouch != null) { npc.anim(npc.combatDefinitions.attackEmote) pouch.amount-- if (pouch.amount <= 0) { pouch.amount = 1 pouch.id = 2957 } target.inventory.refresh() npc.lock() World.sendProjectile(target, npc, 268, 30, 0, 0.4) { npc.unlock() npc.spotAnim(269, 0, 96) npc.transformIntoNPC(when (npc.id) { 1052 -> 1053 14035 -> 14038 14036 -> 14039 14037 -> 14040 else -> npc.id }) } return@npcCombat npc.attackSpeed } if (Utils.random(10) < 3) { val foods = target.inventory.items.array().filter { it != null && Foods.isConsumable(it) } if (foods.isNotEmpty()) { npc.anim(npc.combatDefinitions.attackEmote) val food = foods.random() food.id = 2959 food.amount = 1 target.inventory.refresh() return@npcCombat 15 } else { npc.anim(npc.combatDefinitions.attackEmote) target.applyHit(Hit(npc, Utils.random(10, 30), Hit.HitLook.MELEE_DAMAGE)) return@npcCombat 15 } } else { target.sendMessage(""The ghast misses you."") return@npcCombat 15 } } return@npcCombat CombatScriptsHandler.getDefaultCombat().apply(npc, target) } }" "package com.rs.game.content.quests.naturespirit const val STAGE_UNSTARTED = 0 const val STAGE_FIND_FILLIMAN = 1 const val STAGE_PROVE_GHOST = 2 const val STAGE_GAVE_JOURNAL = 3 const val STAGE_GET_BLESSED = 4 const val STAGE_CAST_BLOOM = 5 const val STAGE_PUZZLING_IT_OUT = 6 const val STAGE_MEET_IN_GROTTO = 7 const val STAGE_BRING_SICKLE = 8 const val STAGE_KILL_GHASTS = 9 const val STAGE_COMPLETE = 10 const val FILLIMAN = 1050 const val NATURE_SPIRIT = 1051 @QuestHandler( quest = Quest.NATURE_SPIRIT, startText = ""Speak to Drezel under the Saradomin temple near the River Salve."", itemsText = ""Silver sickle, Ghostspeak amulet"", combatText = ""You will have to kill a few level 30 ghasts."", rewardsText = ""3,000 Crafting XP
"" + ""2,000 Constitution XP
"" + ""2,000 Defence XP
"" + ""Access to Mort Myre swamp and the Altar of Nature
"" + ""30 Prayer XP each time you kill a ghast"", completedStage = STAGE_COMPLETE ) class NatureSpirit : QuestOutline() { override fun getJournalLines(player: Player, stage: Int) = when (stage) { STAGE_UNSTARTED -> listOf(""I should speak to Drezel under the Saradomin temple!"") STAGE_FIND_FILLIMAN -> listOf(""I need to look for Filliman Tarlock in the Swamps of Mort Myre. I should be wary of the Ghasts."") STAGE_PROVE_GHOST -> listOf(""I think I need to convince this poor fellow Tarlock that he's actually dead!"") STAGE_GAVE_JOURNAL -> listOf(""Filliman might need my help with his plan."") STAGE_GET_BLESSED -> listOf(""Filliman gave me a 'bloom' spell but I need to be blessed at the mausoleum near the temple before I can cast it. I am supposed to collect 'something from nature'."") STAGE_CAST_BLOOM -> listOf(""I need to cast the bloom spell in the swamp to find something from nature."") STAGE_PUZZLING_IT_OUT -> listOf(""I have collected a mort myre fungus from the swamp which seems to be the part from nature. I just need to find 'something with faith' and 'something of the spirit-to-become freely given'."") STAGE_MEET_IN_GROTTO -> listOf(""Filliman asked me to meet him in his grotto."") STAGE_BRING_SICKLE -> listOf(""Filliman has turned into a nature spirit. It was an impressive transformation! Filliman has asked me to bring him a silver sickle."") STAGE_KILL_GHASTS -> listOf(""I need to use the sickle to make the swamp bloom, add the items to the druid pouch, and use it to defeat 3 ghasts!"") STAGE_COMPLETE -> listOf(""QUEST COMPLETE!"") else -> listOf(""Invalid quest stage. Report this to an administrator."") } override fun complete(player: Player) { player.skills.addXpQuest(Skills.CRAFTING, 3000.0) player.skills.addXpQuest(Skills.HITPOINTS, 2000.0) player.skills.addXpQuest(Skills.DEFENSE, 2000.0) sendQuestCompleteInterface(player, 2963) } } @ServerStartupEvent fun mapNatureSpirit() { onObjectClick(3517) { (player, _, op) -> when (op) { ""Search"" -> if (player.getQuestStage(Quest.NATURE_SPIRIT) in STAGE_FIND_FILLIMAN..STAGE_PROVE_GHOST && !player.containsOneItem(2967)) { player.itemDialogue(2967, ""You search the tree. You find a knot and inside of it you discover a small tome. The words on the front are a bit vague, but you make out the words 'Tarlock' and 'journal'."") player.inventory.addItem(2967) } ""Enter"" -> if (player.getQuestStage(Quest.NATURE_SPIRIT) in STAGE_FIND_FILLIMAN..STAGE_PUZZLING_IT_OUT) fillimanDialogue(player, World.getNPCsInChunkRange(player.chunkId, 1).first { it.id == FILLIMAN }) else if (player.getQuestStage(Quest.NATURE_SPIRIT) >= STAGE_MEET_IN_GROTTO) player.useLadder(Tile.of(2271, 5334, if (player.isQuestComplete(Quest.NATURE_SPIRIT)) 1 else 0)) else player.sendMessage(""Nothing interesting happens."") } } onObjectClick(3525, 3526) { (player) -> player.useLadder(Tile.of(3440, 3337, 0)) } onObjectClick(3521) { (player) -> val maxPrayer = player.skills.getLevelForXp(Constants.PRAYER) * 10.0 if (player.prayer.points < maxPrayer) { player.anim(645) player.prayer.restorePrayer(maxPrayer) } } onItemClick(2967, options = arrayOf(""Read"")) { (player) -> player.startConversation { item(2967, ""Most of the writing is pretty uninteresting, but something inside refers to a nature spirit. The requirements for which are,"") item(2967, ""'Something from nature', 'something with faith' and 'something of the spirit-to-become freely given'. It's all pretty vague."") } } onPickupItem(2966, tiles = arrayOf(Tile.of(3437, 3337, 0))) { e -> e.cancelPickup() if (e.player.getQuestStage(Quest.NATURE_SPIRIT) != STAGE_PROVE_GHOST) { e.player.playerDialogue(HeadE.CONFUSED, ""I don't think I have much use for a mirror right now."") return@onPickupItem } if (!e.player.inventory.containsItem(2966)) e.player.inventory.addItemDrop(2966, 1) } onNpcClick(FILLIMAN, NATURE_SPIRIT) { (player, npc) -> fillimanDialogue(player, npc) } instantiateNpc(FILLIMAN) { id, tile -> Filliman(id, tile) } instantiateNpc(NATURE_SPIRIT) { id, tile -> NatureSpiritNpc(id, tile) } onObjectClick(3527, 3528, 3529) { e -> e.player.simpleDialogue(""You search the stone and fine that it has some sort of ${when(e.objectId) { 3527 -> ""nature"" 3528 -> ""faith"" else -> ""spirit"" }} symbol scratched into it."") } onItemOnObject(arrayOf(3521), arrayOf(2961)) { e -> e.player.anim(9104) e.item.id = 2963 e.player.inventory.refresh(e.item.slot) e.player.itemDialogue(2963, ""You dip the sickle into the grotto water and bless it."") } onItemOnObject(arrayOf(3527, 3528, 3529)) { e -> e.player.anim(827) when(e.objectId) { 3527 -> if (e.item.id == 2970) { e.player.inventory.deleteItem(e.item) World.addGroundItem(e.item, e.getObject().tile, e.player, true, Ticks.fromMinutes(10)) e.player.questManager.getAttribs(Quest.NATURE_SPIRIT).setB(""placedFungus"", true) e.player.npcDialogue(FILLIMAN, HeadE.CHEERFUL, ""Great! That seems correct."") return@onItemOnObject } else -> if (e.item.id == 2969) { e.player.inventory.deleteItem(e.item) World.addGroundItem(e.item, e.getObject().tile, e.player, true, Ticks.fromMinutes(10)) e.player.questManager.getAttribs(Quest.NATURE_SPIRIT).setB(""placedSpell"", true) e.player.npcDialogue(FILLIMAN, HeadE.CONFUSED, ""Great! That seems correct."") return@onItemOnObject } } e.player.npcDialogue(FILLIMAN, HeadE.CONFUSED, ""Hmm, that doesn't seem quite right."") } //Bless silver sickle on grotto/altar of nature onItemOnObject(objectNamesOrIds = arrayOf(3520, 3521), itemNamesOrIds = arrayOf(2961)) { e -> if (e.player.getQuestStage(Quest.NATURE_SPIRIT) < STAGE_KILL_GHASTS) { e.player.sendMessage(""You haven't been given permission to use the grotto yet."") return@onItemOnObject } e.item.id = 2963 e.player.inventory.refresh(e.item.slot) } onNpcDeath(""Ghast"") { e -> val killer = e.killer if (killer is Player) { killer.questManager.getAttribs(Quest.NATURE_SPIRIT).incI(""ghastsKilled"") val leftToKill = 3 - killer.questManager.getAttribs(Quest.NATURE_SPIRIT).getI(""ghastsKilled"") if (leftToKill > 0) killer.sendMessage(""That's a ghast down. $leftToKill more to go!"") else if (leftToKill == 0) killer.sendMessage(""That's all 3 ghasts! I better go tell Filliman."") } } } class Filliman(id: Int, tile: Tile) : NPC(id, tile) { override fun withinDistance(player: Player, distance: Int): Boolean { val stage = player.getQuestStage(Quest.NATURE_SPIRIT) if (stage in STAGE_FIND_FILLIMAN..STAGE_PUZZLING_IT_OUT) return super.withinDistance(player, distance) if (stage == STAGE_MEET_IN_GROTTO) return super.withinDistance(player, distance) && setOf(580251, 580250, 582298, 582299).contains(player.chunkId) return false } } class NatureSpiritNpc(id: Int, tile: Tile) : NPC(id, tile) { override fun withinDistance(player: Player, distance: Int) = player.getQuestStage(Quest.NATURE_SPIRIT) >= STAGE_BRING_SICKLE && super.withinDistance(tile, distance) }" "package com.rs.game.content.quests.piratestreasure; @PluginEventHandler public class AngryGardenerNPC extends NPC { public AngryGardenerNPC(int id, Tile tile, boolean spawned) { super(id, tile, spawned); } @Override public void sendDeath(Entity source) { if(source instanceof Player player) player.getQuestManager().getAttribs(Quest.PIRATES_TREASURE).setB(""KILLED_GARDENER"", true); final NPCCombatDefinitions defs = getCombatDefinitions(); resetWalkSteps(); removeTarget(); setNextAnimation(null); PluginManager.handle(new NPCDeathEvent(this, source)); WorldTasks.scheduleTimer(loop -> { if (loop == 0) setNextAnimation(new Animation(defs.getDeathEmote())); else if (loop >= defs.getDeathDelay()) { if (source instanceof Player player) player.getControllerManager().processNPCDeath(AngryGardenerNPC.this); drop(); reset(); finish(); if (!isSpawned()) setRespawnTask(); return false; } return true; }); } public static NPCInstanceHandler toFunc = new NPCInstanceHandler(1217, (npcId, tile) -> new AngryGardenerNPC(npcId, tile, true)); }" "package com.rs.game.content.quests.piratestreasure; @PluginEventHandler public class CustomsOfficerPiratesTreasureD extends Conversation { public CustomsOfficerPiratesTreasureD(Player player) { super(player); addNPC(CUSTOMS_OFFICER, HeadE.CALM_TALK, ""Halt! I am going to need to inspect your items.""); addPlayer(HeadE.WORRIED, ""Can I journey on this ship?""); addNPC(CUSTOMS_OFFICER, HeadE.CALM_TALK, ""You need to be searched before you can board.""); addOptions(""Choose an option:"", new Options() { @Override public void create() { if(player.getInventory().containsItem(RUM)) option(""Search away, I have nothing to hide."", new Dialogue() .addPlayer(HeadE.WORRIED, ""Search away, I have nothing to hide."") .addNPC(CUSTOMS_OFFICER, HeadE.CALM_TALK, ""Aha, trying to smuggle rum are we?"") .addPlayer(HeadE.HAPPY_TALKING, ""Umm... it's for personal use?"") .addSimple(""The customs officer confiscates your rum."", () -> { while(player.getInventory().containsItem(RUM)) player.getInventory().removeItems(new Item(RUM, 1)); }) .addSimple(""You will need to find some way to smuggle it off the island."") ); else option(""Search away, I have nothing to hide."", new Dialogue() .addPlayer(HeadE.WORRIED, ""Search away, I have nothing to hide."") .addNPC(CUSTOMS_OFFICER, HeadE.CALM_TALK, ""Well, you've got some odd stuff, but it's all legal. You can board..."") .addNext(()->{ Object[] attributes = BoatingD.getBoatForShip(CustomsOfficerPiratesTreasureD.this.player, CUSTOMS_OFFICER); TravelMethods.Carrier ship = (TravelMethods.Carrier) attributes[0]; boolean returning = (Boolean) attributes[1]; TravelMethods.sendCarrier(CustomsOfficerPiratesTreasureD.this.player, ship, returning); }) ); option(""You're not putting your hands on my things!"", new Dialogue() .addPlayer(HeadE.ANGRY, ""You're not putting your hands on my things!"") .addNPC(CUSTOMS_OFFICER, HeadE.CALM_TALK, ""You're not getting on this ship then."")); } }); } }" "package com.rs.game.content.quests.piratestreasure; @PluginEventHandler public class LuthasPiratesTreasureD extends Conversation { private static final int UNEMPLOYED = 0; private static final int EMPLOYED = 1; private static final int JOB_FINISHED = 2; public LuthasPiratesTreasureD(Player player) { super(player); switch (player.getQuestManager().getStage(Quest.PIRATES_TREASURE)) { case SMUGGLE_RUM -> { if(player.getQuestManager().getAttribs(Quest.PIRATES_TREASURE).getI(""BANANA_COUNT"") >= 10) player.getQuestManager().getAttribs(Quest.PIRATES_TREASURE).setI(""LUTHAS_EMPLOYMENT"", JOB_FINISHED); if(player.getQuestManager().getAttribs(Quest.PIRATES_TREASURE).getI(""LUTHAS_EMPLOYMENT"") == UNEMPLOYED) { addNPC(LUTHAS, HeadE.CALM_TALK, ""Hello I'm Luthas, I run the banana plantation here""); addOptions(""Choose an option:"", new Options() { @Override public void create() { option(""Could you offer me employment on your plantation?"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Could you offer me employment on your plantation?"") .addNPC(LUTHAS, HeadE.CALM_TALK, ""Yes, I can sort something out. There's a crate ready to be loaded onto the ship. "" + ""You wouldn't believe the demand for bananas from Wydin's shop over in Port Sarim. "") .addNPC(LUTHAS, HeadE.CALM_TALK, ""I think this is the third crate I've shipped him this month.. If you could fill it up with "" + ""bananas, I'll pay you 30 gold."", ()-> player.getQuestManager().getAttribs(Quest.PIRATES_TREASURE).setI(""LUTHAS_EMPLOYMENT"", EMPLOYED)) ); option(""That customs officer is annoying isn't she?"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""That customs officer is annoying isn't she?"") .addNPC(LUTHAS, HeadE.CALM_TALK, ""Well I know her pretty well. She doesn't cause me any trouble any more. She doesn't even "" + ""search my export crates any more. She knows they only contain bananas."") .addPlayer(HeadE.HAPPY_TALKING, ""Really? How interesting. Whereabouts do you send those to?"") .addNPC(LUTHAS, HeadE.CALM_TALK, ""There is a little shop over in Port Sarim that buys them up by the crate. I believe"" + "" it is run by a man called Wydin."")); } }); } else if(player.getQuestManager().getAttribs(Quest.PIRATES_TREASURE).getI(""LUTHAS_EMPLOYMENT"") == EMPLOYED) { addNPC(LUTHAS, HeadE.CALM_TALK, ""Have you completed your task yet?""); addOptions(""Choose an option:"", new Options() { @Override public void create() { option(""What did I have to do again?"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""What did I have to do again?"") .addNPC(LUTHAS, HeadE.CALM_TALK, ""There's a crate ready to be loaded onto the ship. If you could fill it up with bananas, "" + ""I'll pay you 30 gold."") ); option(""No, the crate isn't full yet..."", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""No, the crate isn't full yet..."") .addNPC(LUTHAS, HeadE.CALM_TALK, ""Well come back when it is."") ); option(""So where are these bananas going to be delivered to?"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""So where are these bananas going to be delivered to?"") .addNPC(LUTHAS, HeadE.CALM_TALK, ""I sell them to Wydin who runs a grocery store in Port Sarim."") ); option(""That customs officer is annoying isn't she?"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""That customs officer is annoying isn't she?"") .addNPC(LUTHAS, HeadE.CALM_TALK, ""Well I know her pretty well. She doesn't cause me any trouble any more. She doesn't even "" + ""search my export crates any more. She knows they only contain bananas."") .addPlayer(HeadE.HAPPY_TALKING, ""Really? How interesting. Whereabouts do you send those to?"") .addNPC(LUTHAS, HeadE.CALM_TALK, ""There is a little shop over in Port Sarim that buys them up by the crate. I believe"" + "" it is run by a man called Wydin."")); } }); } else if(player.getQuestManager().getAttribs(Quest.PIRATES_TREASURE).getI(""LUTHAS_EMPLOYMENT"") == JOB_FINISHED) { addPlayer(HeadE.HAPPY_TALKING, ""I've filled a crate with bananas.""); addNPC(LUTHAS, HeadE.CALM_TALK, ""Well done, here's your payment""); addSimple(""Luthas hands you 30 coins."", ()->{ player.getInventory().addCoins(30); player.getQuestManager().getAttribs(Quest.PIRATES_TREASURE).removeI(""BANANA_COUNT""); player.getQuestManager().getAttribs(Quest.PIRATES_TREASURE).removeI(""LUTHAS_EMPLOYMENT""); if(player.getQuestManager().getAttribs(Quest.PIRATES_TREASURE).getB(""RUM_IN_KARAMJA_CRATE"")) { player.sendMessage(""The rum was sent along with the bananas!""); player.getQuestManager().getAttribs(Quest.PIRATES_TREASURE).setB(""RUM_IN_SARIM_CRATE"", true); player.getQuestManager().getAttribs(Quest.PIRATES_TREASURE).removeB(""RUM_IN_KARAMJA_CRATE""); } }); } } default -> { addNPC(LUTHAS, HeadE.CALM_TALK, ""Hi.""); addPlayer(HeadE.HAPPY_TALKING, ""Hi, how are you?""); addNPC(LUTHAS, HeadE.CALM_TALK, ""Great, how about yourself?""); addPlayer(HeadE.HAPPY_TALKING, ""Good...""); addNPC(LUTHAS, HeadE.CALM_TALK, ""Great.""); addPlayer(HeadE.HAPPY_TALKING, ""Great""); addNPC(LUTHAS, HeadE.CALM_TALK, ""...""); addPlayer(HeadE.HAPPY_TALKING, ""...""); } } } public static ObjectClickHandler handleBananaCrate = new ObjectClickHandler(new Object[] { 2072 }, e -> { Player p = e.getPlayer(); if(p.getQuestManager().getAttribs(Quest.PIRATES_TREASURE).getI(""LUTHAS_EMPLOYMENT"") == UNEMPLOYED) return; int bananaCount = p.getQuestManager().getAttribs(Quest.PIRATES_TREASURE).getI(""BANANA_COUNT""); boolean hasRum = p.getQuestManager().getAttribs(Quest.PIRATES_TREASURE).getB(""RUM_IN_KARAMJA_CRATE""); if(e.getOption().equalsIgnoreCase(""search"")) p.sendMessage(""The crate has "" + bananaCount + "" out of 10 bananas "" + (hasRum ? ""and has rum!"" : ""but does not have rum!"")); if(e.getOption().equalsIgnoreCase(""fill"")) { if(p.getInventory().containsItem(RUM, 1)) { p.getInventory().removeItems(new Item(RUM, 1)); p.getQuestManager().getAttribs(Quest.PIRATES_TREASURE).setB(""RUM_IN_KARAMJA_CRATE"", true); p.sendMessage(""You place rum in the crate!""); } while(p.getQuestManager().getAttribs(Quest.PIRATES_TREASURE).getI(""BANANA_COUNT"") < 10) { if(!p.getInventory().containsItem(BANANA, 1)) break; p.getInventory().removeItems(new Item(BANANA, 1)); p.getQuestManager().getAttribs(Quest.PIRATES_TREASURE).setI(""BANANA_COUNT"", p.getQuestManager().getAttribs(Quest.PIRATES_TREASURE).getI(""BANANA_COUNT"")+1); } } }); public static NPCClickHandler handleLuthas = new NPCClickHandler(new Object[] { LUTHAS }, e -> e.getPlayer().startConversation(new LuthasPiratesTreasureD(e.getPlayer()).getStart())); }" "package com.rs.game.content.quests.piratestreasure; @QuestHandler( quest = Quest.PIRATES_TREASURE, startText = ""Speak to Redbeard Frank just south of The Rusty Anchor pub in Port Sarim."", itemsText = ""White apron, 60 coins (or an activated ring of Charos and 30 coins)."", combatText = ""Optionally defeat a level 4 gardener."", rewardsText = ""One-Eyed Hector's treasure casket (containing 450 coins, an emerald and a gold ring)
Ability to work as a menial labourer on a banana plantation (30 coins for each export crate you fill with 10 bananas)"", completedStage = 3 ) @PluginEventHandler public class PiratesTreasure extends QuestOutline { public final static int NOT_STARTED = 0; public final static int SMUGGLE_RUM = 1; public final static int GET_TREASURE = 2; public final static int QUEST_COMPLETE = 3; //items protected final static int SPADE = 952; protected final static int RUM = 431; protected final static int BANANA = 1963; protected final static int PIRATE_MESSAGE = 433; protected final static int CHEST_KEY = 432; protected final static int CASKET = 7956; protected final static int APRON = 1005; //NPCs protected final static int REDBEARD = 375; protected final static int LUTHAS = 379; protected final static int WYDIN = 557; protected final static int ZAMBO = 568; protected final static int HOSTILE_GARDENER = 1217; protected final static int CUSTOMS_OFFICER = 380; //Objects protected final static int BLUE_MOON_INN_CHEST = 2079; @Override public List getJournalLines(Player player, int stage) { ArrayList lines = new ArrayList<>(); switch(stage) { case NOT_STARTED: lines.add(""You can start this quest at Port Sarim. Redbeard Frank""); lines.add(""knows the location of pirate treasure, but he'll only""); lines.add(""part with the knowledge for a bottle of Karamjan rum.""); lines.add(""""); break; case SMUGGLE_RUM: lines.add(""To get the pirate treasure I must first help Redbeard""); lines.add(""Frank by smuggling rum for him from Karamja. There is""); lines.add(""a general store that sells the rum by the banana""); lines.add(""plantation,""); lines.add(""""); break; case GET_TREASURE: lines.add(""Now that Redbeard Frank has his rum he has given me the""); lines.add(""key to a chest on the second floor of the blue moon inn.""); lines.add(""Inside the chest there is word of a map to who knows where?""); lines.add(""""); break; case QUEST_COMPLETE: lines.add(""I have gotten the Pirate's Treasure!""); lines.add(""""); lines.add(""""); lines.add(""QUEST COMPLETE!""); break; default: lines.add(""Invalid quest stage. Report this to an administrator.""); break; } return lines; } public static ObjectClickHandler handleTreasureChest = new ObjectClickHandler(new Object[] {BLUE_MOON_INN_CHEST }, e -> {; GameObject obj = e.getObject(); if(!e.getPlayer().getInventory().containsItem(CHEST_KEY)) return; if(e.getOption().equalsIgnoreCase(""open"")) { e.getPlayer().setNextAnimation(new Animation(536)); e.getPlayer().lock(2); GameObject openedChest = new GameObject(obj.getId() + 1, obj.getType(), obj.getRotation(), obj.getX(), obj.getY(), obj.getPlane()); e.getPlayer().faceObject(openedChest); World.spawnObjectTemporary(openedChest, Ticks.fromMinutes(1)); e.getPlayer().getInventory().addItem(new Item(PIRATE_MESSAGE, 1)); } }); public static void findTreasure(Player player) { if((player.getQuestManager().getStage(Quest.PIRATES_TREASURE) != GET_TREASURE) || !player.getQuestManager().getAttribs(Quest.PIRATES_TREASURE).getB(""TREASURE_LOC_KNOWN"")) return; if(Utils.getDistance(player.getTile(), Tile.of(2999, 3383, 0)) <= 2) { if(player.getQuestManager().getAttribs(Quest.PIRATES_TREASURE).getB(""KILLED_GARDENER"")) { player.getQuestManager().completeQuest(Quest.PIRATES_TREASURE); return; } for(NPC npc : World.getNPCsInChunkRange(player.getChunkId(), 1)) if(npc.getId()== HOSTILE_GARDENER) return; NPC gardener = World.spawnNPC(HOSTILE_GARDENER, Tile.of(player.getTile()), -1, false, true); gardener.setTarget(player); gardener.forceTalk(""First moles, now this!? Take this, vandal!""); } } public static EnterChunkHandler handleBreakRum = new EnterChunkHandler(e -> { if (e.getEntity() instanceof Player player && player.getQuestManager().getStage(Quest.PIRATES_TREASURE) == SMUGGLE_RUM) if (!player.getQuestManager().getAttribs(Quest.PIRATES_TREASURE).getB(""HAS_SMUGGLED_RUM"") && player.getInventory().containsItem(RUM)) if (Utils.getDistance(player.getTile(), Tile.of(2928, 3143, 0)) > 70) { while (player.getInventory().containsItem(RUM, 1)) player.getInventory().removeItems(new Item(RUM, 1)); player.sendMessage(""Your Karamja rum gets broken and spilled.""); } }); public static ItemClickHandler openCasket = new ItemClickHandler(new Object[] { CASKET }, new String[] { ""Open"" }, e -> { e.getPlayer().getInventory().removeItems(new Item(CASKET, 1)); e.getPlayer().getInventory().addItem(new Item(1605, 1), true);//gold ring e.getPlayer().getInventory().addItem(new Item(1635, 1), true);//cut emerald }); public static ItemClickHandler readMessage = new ItemClickHandler(new Object[] { PIRATE_MESSAGE }, new String[] { ""Read"" }, e -> { e.getPlayer().getInterfaceManager().sendInterface(220);//Message interface e.getPlayer().getPackets().setIFText(220, 8, ""Visit the city of the White Knights. In the park,""); e.getPlayer().getPackets().setIFText(220, 9, ""Saradomin points to the X which marks the spot.""); e.getPlayer().getQuestManager().getAttribs(Quest.PIRATES_TREASURE).setB(""TREASURE_LOC_KNOWN"", true); }); public static ObjectClickHandler bananaTreePlantation = new ObjectClickHandler(new Object[] { 2073, 2074, 2075, 2076, 2077, 2078 }, e -> { if (e.getObjectId() == 2078) { e.getPlayer().sendMessage(""There are no bananas left on the tree.""); return; } e.getPlayer().anim(2280); e.getPlayer().getInventory().addItem(BANANA, 1); e.getObject().setIdTemporary(e.getObjectId()+1, Ticks.fromSeconds(30)); }); @Override public void complete(Player player) { player.getInventory().addItem(new Item(CASKET), true); sendQuestCompleteInterface(player, 7956); } }" "package com.rs.game.content.quests.piratestreasure; @PluginEventHandler public class RedbeardFrankPiratesTreasureD extends Conversation { public RedbeardFrankPiratesTreasureD(Player player) { super(player); switch (player.getQuestManager().getStage(Quest.PIRATES_TREASURE)) { case NOT_STARTED -> addOptions(""Choose an option:"", new Options() { @Override public void create() { option(""I'm in search of treasure."", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""I'm in search of treasure."") .addNPC(REDBEARD, HeadE.CALM_TALK, ""Arr, treasure you be after eh? Well I might be able to tell you where to find some... "" + ""For a price..."") .addPlayer(HeadE.HAPPY_TALKING, ""What sort of price?"") .addNPC(REDBEARD, HeadE.CALM_TALK, ""Well for example if you can get me a bottle of rum... Not just any rum mind... I'd like "" + ""some rum made on Karamja Island. There's no rum like Karamja Rum!"") .addOptions(""Start Pirate's Treasure?:"", new Options() { @Override public void create() { option(""Ok, I will bring you some rum"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Ok, I will bring you some rum."", () -> { player.getQuestManager().setStage(Quest.PIRATES_TREASURE, SMUGGLE_RUM); if(player.getInventory().containsItem(RUM, 1)) { while(player.getInventory().containsItem(RUM, 1)) player.getInventory().removeItems(new Item(RUM, 1)); player.sendMessage(""Your Karamja rum gets broken and spilled.""); } }) .addNPC(REDBEARD, HeadE.CALM_TALK, ""Yer a saint, although it'll take a miracle to get it off Karamja."") .addPlayer(HeadE.HAPPY_TALKING, ""What do you mean?"") .addNPC(REDBEARD, HeadE.CALM_TALK, ""The Customs office has been clampin' down on the export of spirits. You seem "" + ""like a resourceful young lad, I'm sure ye'll be able to find a way to slip the stuff past them."") .addPlayer(HeadE.HAPPY_TALKING, ""Well I'll give it a shot."") .addNPC(REDBEARD, HeadE.CALM_TALK, ""Arr, that's the spirit!"")); option(""Not right now"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Not right now."") .addNPC(REDBEARD, HeadE.CALM_TALK, ""Fair enough. I'll still be here and thirsty whenever you feel like helpin' out."")); } })); option(""Arr!"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Arr!"") .addNPC(REDBEARD, HeadE.CALM_TALK, ""Arr!"") .addNext(()->{ player.startConversation(new RedbeardFrankPiratesTreasureD(player).getStart()); })); option(""Do you have anything for trade?"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Do you have anything for trade?"") .addNPC(REDBEARD, HeadE.CALM_TALK, ""Nothin' at the moment, but then again the Customs Agents are on the warpath right now."") .addNext(()->{ player.startConversation(new RedbeardFrankPiratesTreasureD(player).getStart()); })); } }); case SMUGGLE_RUM -> { addNPC(REDBEARD, HeadE.CALM_TALK, ""Arr, Matey! Have ye brought some rum from yer ol' mate Frank?""); if(player.getInventory().containsItem(RUM, 1)) { addPlayer(HeadE.HAPPY_TALKING, ""Yes, I've got some.""); addNPC(REDBEARD, HeadE.CALM_TALK, ""Now a deal's a deal, I'll tell ye about the treasure. I used to serve under a pirate captain called "" + ""One-Eyed Hector. Hector were very successful and became very rich.""); addNPC(REDBEARD, HeadE.CALM_TALK, ""But about a year ago we were boarded by the Customs and Excise Agents. Hector were killed along with "" + ""many of the crew, I were one of the few to escape and I escaped with this.""); addSimple(""Frank happily takes the rum... and... hands you a key."", ()->{ player.getInventory().removeItems(new Item(RUM, 1)); player.getInventory().addItem(new Item(CHEST_KEY, 1)); player.getQuestManager().setStage(Quest.PIRATES_TREASURE, GET_TREASURE); }); addNPC(REDBEARD, HeadE.CALM_TALK, ""This be Hector's key. I believe it opens his chest on his old room in the Blue Moon Inn in Varrock. "" + ""With any luck his treasure will be in there.""); addOptions(""Choose an option:"", new Options() { @Override public void create() { option(""Ok thanks, I'll go and get it"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Ok thanks, I'll go and get it"") ); option(""So why didn't you ever get it?"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""So why didn't you ever get it?"") .addNPC(REDBEARD, HeadE.CALM_TALK, ""I'm not allowed in the Blue Moon Inn. Apparently I'm a drunken trouble maker."")); } }); } else { addPlayer(HeadE.HAPPY_TALKING, ""No, not yet.""); addNPC(REDBEARD, HeadE.CALM_TALK, ""Not surprising, 'tis no easy task to get it off Karamja.""); addPlayer(HeadE.HAPPY_TALKING, ""What do you mean?""); addNPC(REDBEARD, HeadE.CALM_TALK, ""The Customs office has been clampin' down on the export of spirits. You seem like a resourceful young lad, "" + ""I'm sure ye'll be able to find a way to slip the stuff past them.""); addPlayer(HeadE.HAPPY_TALKING, ""Well I'll give it a shot.""); } } case GET_TREASURE -> { if(!player.getInventory().containsItem(CHEST_KEY, 1)) { addPlayer(HeadE.HAPPY_TALKING, ""I lost the chest key!""); addNPC(REDBEARD, HeadE.CALM_TALK, ""Good thing I keep a copy.""); addSimple(""Redbeard hands you another key."", ()-> player.getInventory().addItem(new Item(CHEST_KEY, 1))); return; } addPlayer(HeadE.HAPPY_TALKING, ""Would you like a share of the treasure?""); addNPC(REDBEARD, HeadE.CALM_TALK, ""No lad, you got it fair and square. You enjoy it. It's what Hector would have wanted.""); } } } }" "package com.rs.game.content.quests.piratestreasure; @PluginEventHandler public class WydinPiratesTreasureD extends Conversation { public WydinPiratesTreasureD(Player player) { super(player); int NPC = WYDIN; switch (player.getQuestManager().getStage(Quest.PIRATES_TREASURE)) { case NOT_STARTED -> { addNPC(NPC, HeadE.CALM_TALK, ""Welcome to my food store! Would you like to buy anything?""); addOptions(""Choose an option:"", new Options() { @Override public void create() { option(""Yes please."", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Yes please."") .addNext(()-> ShopsHandler.openShop(WydinPiratesTreasureD.this.player, ""wydins_food_store"")) ); option(""No, thank you."", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""No, thank you."") ); option(""What can you recommend?"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""What can you recommend?"") .addNPC(NPC, HeadE.CALM_TALK, ""We have this really exotic fruit all the way from Karamja. It's called a banana."") .addOptions(""Choose an option:"", new Options() { @Override public void create() { option(""Hmm, I think I'll try one."", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Hmm, I think I'll try one."") .addNPC(NPC, HeadE.CALM_TALK, ""Great. You might as well take a look at the rest of my wares as well."") .addNext(()-> ShopsHandler.openShop(WydinPiratesTreasureD.this.player, ""wydins_food_store"")) ); option(""I don't like the sound of that."", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""I don't like the sound of that."") .addNPC(NPC, HeadE.CALM_TALK, ""Well, it's your choice, but I do recommend them."") ); } }) ); } }); } case SMUGGLE_RUM -> { addPlayer(HeadE.HAPPY_TALKING, ""Can I get a job here?""); addNPC(WYDIN, HeadE.CALM_TALK, ""Well, you're keen, I'll give you that. Okay, I'll give you a go. Have you got your own white apron?""); if(player.getInventory().containsItem(APRON, 1) || player.getEquipment().getChestId() == APRON) { addPlayer(HeadE.HAPPY_TALKING, ""Yes, I have one right here.""); addNPC(WYDIN, HeadE.CALM_TALK, ""Wow - you are well prepared! You're hired. Go through to the back and tidy up for me, please."", ()-> player.getQuestManager().getAttribs(Quest.PIRATES_TREASURE).setB(""WYDIN_EMPLOYMENT"", true)); } else { addPlayer(HeadE.HAPPY_TALKING, ""No, I haven't.""); addNPC(WYDIN, HeadE.CALM_TALK, ""Well, you can't work here unless you have a white apron. Health and safety regulations, you understand.""); addPlayer(HeadE.HAPPY_TALKING, ""Where can I get one of those?""); addNPC(WYDIN, HeadE.CALM_TALK, ""Well, I get all of mine over at the clothing shop in Varrock. They sell them cheap there. Oh, and I'm sure "" + ""that I've seen a spare one over in Gerrant's fish store somewhere. It's the little place just north of here.""); } } case GET_TREASURE, QUEST_COMPLETE -> { addNPC(NPC, HeadE.CALM_TALK, ""Is it nice and tidy round the back now?""); addOptions(""Choose an option:"", new Options() { @Override public void create() { option(""Yes, can I work out front now?"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Yes, can I work out front now?"") .addNPC(NPC, HeadE.CALM_TALK, ""No, I'm the one who works here."") ); option(""Yes, are you going to pay me yet?"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Yes, are you going to pay me yet?"") .addNPC(NPC, HeadE.CALM_TALK, ""Umm... No, not yet."") ); option(""No, it's a complete mess"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""No, it's a complete mess"") .addNPC(NPC, HeadE.CALM_TALK, ""Ah well, it'll give you something to do, won't it."") ); option(""Can I buy something please?"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Can I buy something please?"") .addNPC(NPC, HeadE.CALM_TALK, ""Yes, of course."") .addNext(()-> ShopsHandler.openShop(WydinPiratesTreasureD.this.player, ""wydins_food_store"")) ); } }); } } } public static ObjectClickHandler handleBackRoom = new ObjectClickHandler(new Object[] { 2069 }, e -> { GameObject obj = e.getObject(); if(e.getPlayer().getX() < obj.getX()) { handleDoor(e.getPlayer(), e.getObject()); return; } if(e.getPlayer().getQuestManager().getStage(Quest.PIRATES_TREASURE) == SMUGGLE_RUM) { if(!e.getPlayer().getQuestManager().getAttribs(Quest.PIRATES_TREASURE).getB(""WYDIN_EMPLOYMENT"")) { e.getPlayer().startConversation(new Conversation(e.getPlayer()) { { addNPC(WYDIN, HeadE.CALM_TALK, ""Hey, you are not employed here!""); create(); } }); return; } if(e.getPlayer().getEquipment().getChestId() != APRON) { e.getPlayer().startConversation(new Conversation(e.getPlayer()) { { addNPC(WYDIN, HeadE.CALM_TALK, ""Hey, you need your apron on!""); create(); } }); return; } } handleDoor(e.getPlayer(), e.getObject()); }); public static ObjectClickHandler handleSmuggleCrate = new ObjectClickHandler(new Object[] { 2071 }, e -> { if(e.getPlayer().getQuestManager().getStage(Quest.PIRATES_TREASURE) == SMUGGLE_RUM) if(e.getPlayer().getQuestManager().getAttribs(Quest.PIRATES_TREASURE).getB(""RUM_IN_SARIM_CRATE"")) { e.getPlayer().getInventory().addItem(new Item(RUM, 1), true); e.getPlayer().getQuestManager().getAttribs(Quest.PIRATES_TREASURE).removeB(""RUM_IN_SARIM_CRATE""); e.getPlayer().getQuestManager().getAttribs(Quest.PIRATES_TREASURE).setB(""HAS_SMUGGLED_RUM"", true); } else if(e.getPlayer().getQuestManager().getAttribs(Quest.PIRATES_TREASURE).getB(""RUM_IN_KARAMJA_CRATE"")) e.getPlayer().startConversation(new Conversation(e.getPlayer()) { { addPlayer(HeadE.HAPPY_TALKING, ""Darn, I should probably tell Lathus to send the crate!""); create(); } }); }); public static NPCClickHandler handleWydin = new NPCClickHandler(new Object[] { WYDIN }, e -> { if(e.getOption().equalsIgnoreCase(""talk-to"")) e.getPlayer().startConversation(new WydinPiratesTreasureD(e.getPlayer()).getStart()); else if(e.getOption().equalsIgnoreCase(""trade"")) ShopsHandler.openShop(e.getPlayer(), ""wydins_food_store""); }); }" "package com.rs.game.content.quests.priestinperil; @PluginEventHandler public class Cerberus extends NPC { public Cerberus(int id, Tile tile, boolean permaDeath) { super(id, tile, permaDeath); } @Override public boolean canBeAttackedBy(Player player) { if(player.getQuestManager().getStage(Quest.PRIEST_IN_PERIL) >= 3 || player.getQuestManager().isComplete(Quest.PRIEST_IN_PERIL)) { player.playerDialogue(HeadE.SHAKING_HEAD,""I'd better not make the King mad at me again!""); return false; } return true; } @Override public void handlePreHit(Hit hit) { super.handlePreHit(hit); if (hit.getLook() == Hit.HitLook.MAGIC_DAMAGE) hit.setDamage(0); } @Override public void sendDeath(final Entity source) { if(source instanceof Player player && player.getQuestManager().getStage(Quest.PRIEST_IN_PERIL) == 2) { player.playerDialogue(HeadE.HAPPY_TALKING,""There we go, one dead dog. I should go and tell Drezel.""); player.getQuestManager().setStage(Quest.PRIEST_IN_PERIL, 3); } super.sendDeath(source); } public static NPCInstanceHandler toFunc = new NPCInstanceHandler(new Object[]{ 15255, 7711 }, (npcId, tile) -> new Cerberus(npcId, tile, false)); }" "package com.rs.game.content.quests.priestinperil; @PluginEventHandler public class DrezelInJailD extends Conversation { static final int Drezel = 1047; @ServerStartupEvent public static void addLoSOverride() { Entity.addLOSOverride( Drezel ); } public static NPCClickHandler HandleDrezel = new NPCClickHandler(new Object[] { Drezel }, new String[] { ""Talk-to"" }, e -> e.getPlayer().startConversation(new DrezelInJailD(e.getPlayer()))); public DrezelInJailD(Player player) { super(player); if (player.getQuestManager().getStage(Quest.PRIEST_IN_PERIL) == 4) { player.startConversation(new Dialogue() .addPlayer(HeadE.CALM_TALK, ""Hello."") .addNPC(Drezel, HeadE.CALM_TALK, ""Oh! You do not appear to be one of those Zamorakians who imprisoned me! Who are you and why are you here?"") .addPlayer(HeadE.CALM_TALK, ""My name's "" + player.getDisplayName() + "". King Roald sent me to find out what was going on at the temple. I take it you are Drezel?"") .addNPC(Drezel, HeadE.CALM_TALK, ""That's right! Oh, praise be to Saradomin! All is not yet lost!"") .addNPC(Drezel, HeadE.CALM_TALK, ""I feared that when those Zamorakians attacked this place and imprisoned me up here, Misthalin would be doomed!"") .addNPC(Drezel, HeadE.CALM_TALK, ""If they should manage to desecrate the holy River Salve, we will be defenseless against the vampyres of Morytania!"") .addOptions(ops -> { ops.add(""Why is the river such a good defence?"") .addPlayer(HeadE.CALM_TALK, ""Why is the river such a good defence?"") .addNPC(Drezel, HeadE.CALM_TALK, ""I'm not sure if this is the best time for a history lesson. I suppose I can give you a brief overview though. It might help you understand our next steps."") .addNPC(Drezel, HeadE.CALM_TALK, ""It is said that many years ago, the land that is now Morytania was a peaceful Saradominist kingdom. Alas, all that ended when the vampyres invaded, claiming the land as their own."") .addNPC(Drezel, HeadE.CALM_TALK, ""Morytania wasn't enough for them though. Soon, they set their sights on these lands as well."") .addNPC(Drezel, HeadE.CALM_TALK, ""Misthalin would have quickly fallen to the vampyres, were it not for the bravery of the Seven Priestly Warriors."") .addNPC(Drezel, HeadE.CALM_TALK, ""They led the armies of Misthalin against the vampyres in a great battle that took place right where this temple stands."") .addNPC(Drezel, HeadE.CALM_TALK, ""For ten days and nights they fought, never sleeping, never eating, fueled by their desire to make the world a better place for humans to live."") .addNPC(Drezel, HeadE.CALM_TALK, ""On the eleventh day they were to be joined by reinforcements. However, when those reinforcements arrived, they found the Seven Priestly Warriors and their forces had been slain by the vampyres."") .addNPC(Drezel, HeadE.CALM_TALK, ""Their sacrifice was not in vain though. Before they were defeated, the Seven Priestly Warriors managed to bless the Salve with the holy power of Saradomin."") .addNPC(Drezel, HeadE.CALM_TALK, ""Their blessings remain to this day, ensuring no vampyre can cross the river."") .addNPC(Drezel, HeadE.CALM_TALK, ""The temple here was built soon after. It guards the source of the River Salve, and acts as the only passage between Misthalin and Morytania."") .addNPC(Drezel, HeadE.CALM_TALK, ""Once the temple was complete, the bodies of the Seven Priestly Warriors were laid to rest in tombs of honour in the mausoleum below. On the top of each tomb, a golden gift was placed as a mark of respect."") .addNPC(Drezel, HeadE.CALM_TALK, ""A great statue was also built over the river, so that all who might try and cross into Misthalin would know that these lands are protected by Saradomin himself."") .addPlayer(HeadE.CALM_TALK, ""Okay, I can see how the river protects the border. Where do these Zamorakians fit in though?"") .addNPC(Drezel, HeadE.CALM_TALK, ""Well, as much as it saddens me to say so adventurer, Lord Saradomin's presence has not been felt on the land for many years now."") .addNPC(Drezel, HeadE.CALM_TALK, ""Of course, while we know that he still watches over us, his power here is not as strong as it once was."") .addNPC(Drezel, HeadE.CALM_TALK, ""I fear this group of Zamorakians intends to take advantage of that. If they can somehow pollute the Salve, the blessings on the river might fail."") .addNPC(Drezel, HeadE.CALM_TALK, ""If that happens, there won't be anything to stop an invasion from Morytania."") .addNPC(Drezel, HeadE.CALM_TALK, ""So what do you say adventurer? Will you aid me and all of Misthalin in foiling this Zamorakian plot?"") .addOptions(ops2 -> { ops2.add(""Yes, of course."") .addPlayer(HeadE.CALM_TALK, ""Yes, of course."") .addNPC(Drezel, HeadE.CALM_TALK, ""Thank you, adventurer. There is a well in the mausoleum beneath the temple that provides direct access to the source of the Salve. That will be where the Zamorakians will attempt their sabotage."") .addNPC(Drezel, HeadE.CALM_TALK, ""We need to get to that well. However, the immediate problem is that I'm trapped in this cell."") .addNPC(Drezel, HeadE.CALM_TALK, ""The key must be somewhere nearby. One of the Zamorakians might have it, or they might have hidden it somewhere. That's not the only problem though."") .addPlayer(HeadE.CALM_TALK, ""What else is there?"") .addNPC(Drezel, HeadE.CALM_TALK, ""When the Salve was blessed, a small number of vampyres were left trapped on this side of it. They were heavily weakened, but still posed a dangerous threat."") .addNPC(Drezel, HeadE.CALM_TALK, ""This coffin here contains one of those vampyres. The Zamorakians somehow found it and brought it here with them."") .addPlayer(HeadE.CALM_TALK, ""I see. It doesn't seem to be posing a threat right now though."") .addNPC(Drezel, HeadE.CALM_TALK, ""No, but as those fiendish Zamorakians pointed out to me with delight, as I am the descendant of one of the Seven Priestly Warriors who blessed the river, it will likely recognise the smell of my blood."") .addNPC(Drezel, HeadE.CALM_TALK, ""If I get too close, it will probably wake up and kill me, very slowly and painfully."") .addPlayer(HeadE.CALM_TALK, ""Maybe I could kill it somehow?"") .addNPC(Drezel, HeadE.CALM_TALK, ""No adventurer, you should not risk waking it. Even now, it could pose a huge threat."") .addNPC(Drezel, HeadE.CALM_TALK, ""The priests of old would incapacitate trapped vampyres with the blessings of Saradomin. I suggest you do the same."") .addPlayer(HeadE.CALM_TALK, ""Right. So, I need to find the key to your cell and do something about the vampyre. Got it."") .addNPC(Drezel, HeadE.CALM_TALK, ""Good luck."", () -> player.getQuestManager().setStage(Quest.PRIEST_IN_PERIL, 5)); ops2.add(""No."") .addPlayer(HeadE.CALM_TALK, ""No."") .addNPC(Drezel, HeadE.CALM_TALK, ""Oooooh... I knew it was too good to be true... Then leave me to my fate villain, there's no need to taunt me as well as keeping me imprisoned.""); }); ops.add(""So, what now?"") .addPlayer(HeadE.CALM_TALK, ""So, what now?"") .addNPC(Drezel, HeadE.CALM_TALK, ""Well, let's just say if we cannot undo whatever damage has been done here, the entire land is in grave peril!"") .addNPC(Drezel, HeadE.CALM_TALK, ""So what do you say adventurer? Will you aid me and all of Misthalin in foiling this Zamorakian plot?"") .addOptions(ops2 -> { ops2.add(""Yes, of course."") .addPlayer(HeadE.CALM_TALK, ""Yes, of course."") .addNPC(Drezel, HeadE.CALM_TALK, ""Thank you, adventurer. There is a well in the mausoleum beneath the temple that provides direct access to the source of the Salve. That will be where the Zamorakians will attempt their sabotage."") .addNPC(Drezel, HeadE.CALM_TALK, ""We need to get to that well. However, the immediate problem is that I'm trapped in this cell."") .addNPC(Drezel, HeadE.CALM_TALK, ""The key must be somewhere nearby. One of the Zamorakians might have it, or they might have hidden it somewhere. That's not the only problem though."") .addPlayer(HeadE.CALM_TALK, ""What else is there?"") .addNPC(Drezel, HeadE.CALM_TALK, ""When the Salve was blessed, a small number of vampyres were left trapped on this side of it. They were heavily weakened, but still posed a dangerous threat."") .addNPC(Drezel, HeadE.CALM_TALK, ""This coffin here contains one of those vampyres. The Zamorakians somehow found it and brought it here with them."") .addPlayer(HeadE.CALM_TALK, ""I see. It doesn't seem to be posing a threat right now though."") .addNPC(Drezel, HeadE.CALM_TALK, ""No, but as those fiendish Zamorakians pointed out to me with delight, as I am the descendant of one of the Seven Priestly Warriors who blessed the river, it will likely recognise the smell of my blood."") .addNPC(Drezel, HeadE.CALM_TALK, ""If I get too close, it will probably wake up and kill me, very slowly and painfully."") .addPlayer(HeadE.CALM_TALK, ""Maybe I could kill it somehow?"") .addNPC(Drezel, HeadE.CALM_TALK, ""No adventurer, you should not risk waking it. Even now, it could pose a huge threat."") .addNPC(Drezel, HeadE.CALM_TALK, ""The priests of old would incapacitate trapped vampyres with the blessings of Saradomin. I suggest you do the same."") .addPlayer(HeadE.CALM_TALK, ""Right. So, I need to find the key to your cell and do something about the vampyre. Got it."") .addNPC(Drezel, HeadE.CALM_TALK, ""Good luck."", () -> player.getQuestManager().setStage(Quest.PRIEST_IN_PERIL, 5)); ops2.add(""No."") .addPlayer(HeadE.CALM_TALK, ""No."") .addNPC(Drezel, HeadE.CALM_TALK, ""Oooooh... I knew it was too good to be true... Then leave me to my fate villain, there's no need to taunt me as well as keeping me imprisoned.""); }); }) ); } if (player.getQuestManager().getStage(Quest.PRIEST_IN_PERIL) == 5) { if(player.getInventory().containsItem(2944)){ player.startConversation(new Dialogue() .addNPC(Drezel, HeadE.CALM_TALK, ""How goes it adventurer? Any luck in finding the key to the cell or a way of stopping the vampyre yet?"") .addPlayer(HeadE.CALM_TALK, ""I have this key I took from one of those Zamorakian monks!"") .addNPC(Drezel, HeadE.CALM_TALK, ""Excellent work adventurer! Quickly, try it on the door, and see if it will free me!"") ); return; } if(player.getInventory().containsItem(2945)){ player.startConversation(new Dialogue() .addNPC(Drezel, HeadE.CALM_TALK, ""How goes it adventurer? Any luck in finding the key to the cell or a way of stopping the vampyre yet?"") .addPlayer(HeadE.CALM_TALK, ""I have this key I took from one of the monuments underground."") .addNPC(Drezel, HeadE.CALM_TALK, ""Excellent work adventurer! Quickly, try it on the door, and see if it will free me!"") ); return; } else{ player.startConversation(new Dialogue() .addNPC(Drezel, HeadE.CALM_TALK, ""How goes it adventurer? Any luck in finding the key to the cell or a way of stopping the vampyre yet?"") .addPlayer(HeadE.CALM_TALK, ""No, not yet..."") .addNPC(Drezel, HeadE.CALM_TALK, ""Well don't give up adventurer! That key must be around here somewhere! I know none of those Zamorakians ever got very far from this building!"") .addPlayer(HeadE.CALM_TALK, ""How do you know that?"") .addNPC(Drezel, HeadE.CALM_TALK, ""I could hear them laughing about some gullible fool that they tricked into killing the guard dog at the monument."") .addPlayer(HeadE.CALM_TALK, ""Oh."") .addNPC(Drezel, HeadE.CALM_TALK, ""Honestly, what kind of idiot would go around killing things just because a stranger told them to? What kind of oafish, numb-skulled, dim-witted..."") .addPlayer(HeadE.CALM_TALK, ""Okay, okay, I get the picture!"") .addOptions(ops -> { ops.add(""Could you tell me more about this temple?"") .addPlayer(HeadE.CALM_TALK, ""Could you tell me more about this temple?"") .addNPC(Drezel, HeadE.CALM_TALK, ""It is said that many years ago, the land that is now Morytania was a peaceful Saradominist kingdom. Alas, all that ended when the vampyres invaded, claiming the land as their own."") .addNPC(Drezel, HeadE.CALM_TALK, ""Morytania wasn't enough for them though. Soon, they set their sights on these lands as well."") .addNPC(Drezel, HeadE.CALM_TALK, ""Misthalin would have quickly fallen to the vampyres, were it not for the bravery of the Seven Priestly Warriors."") .addNPC(Drezel, HeadE.CALM_TALK, ""They led the armies of Misthalin against the vampyres in a great battle that took place right where this temple stands."") .addNPC(Drezel, HeadE.CALM_TALK, ""For ten days and nights they fought, never sleeping, never eating, fuelled by their desire to make the world a better place for humans to live."") .addNPC(Drezel, HeadE.CALM_TALK, ""On the eleventh day they were to be joined by reinforcements. However, when those reinforcements arrived, they found the Seven Priestly Warriors and their forces had been slain by the vampyres."") .addNPC(Drezel, HeadE.CALM_TALK, ""Their sacrifice was not in vain though. Before they were defeated, the Seven Priestly Warriors managed to bless the Salve with the holy power of Saradomin."") .addNPC(Drezel, HeadE.CALM_TALK, ""Their blessings remain to this day, ensuring no vampyre can cross the river."") .addNPC(Drezel, HeadE.CALM_TALK, ""The temple here was built soon after. It guards the source of the River Salve, and acts as the only passage between Misthalin and Morytania."") .addNPC(Drezel, HeadE.CALM_TALK, ""Once the temple was complete, the bodies of the Seven Priestly Warriors were laid to rest in tombs of honour in the mausoleum below. On the top of each tomb, a golden gift was placed as a mark of respect."") .addNPC(Drezel, HeadE.CALM_TALK, ""A great statue was also built over the river, so that all who might try and cross into Misthalin would know that these lands are protected by Saradomin himself."") .addPlayer(HeadE.CALM_TALK, ""Thank you for the information. I'll get going.""); ops.add(""I'll get going."") .addPlayer(HeadE.CALM_TALK, ""I'll get going.""); }) ); } } if (player.getQuestManager().getStage(Quest.PRIEST_IN_PERIL) == 6) { player.startConversation(new Dialogue() .addPlayer(HeadE.CALM_TALK, ""The key fit the lock! You're free to leave now!"") .addNPC(Drezel, HeadE.CALM_TALK, ""Excellent work, adventurer! Unfortunately, as you know, I cannot risk waking the vampyre in that coffin."") .addPlayer(HeadE.CALM_TALK, ""Do you have any ideas about dealing with the vampyre?"") .addNPC(Drezel, HeadE.CALM_TALK, ""Well, the water of the Salve should still have enough power to work against the vampyre, even if the Zamorakians have desecrated it."") .addNPC(Drezel, HeadE.CALM_TALK, ""Maybe you should try and get hold of some?"") ); } if (player.getQuestManager().getStage(Quest.PRIEST_IN_PERIL) == 7) { if(player.getInventory().containsItem(2953)){ player.startConversation(new Dialogue() .addPlayer(HeadE.CALM_TALK, ""The key fit the lock! You're free to leave now!"") .addNPC(Drezel, HeadE.CALM_TALK, ""Excellent work, adventurer! Unfortunately, as you know, I cannot risk waking the vampyre in that coffin."") .addPlayer(HeadE.CALM_TALK, ""I have some water from the Salve. It seems to have been desecrated though. Do you think you could bless it for me?"") .addNPC(Drezel, HeadE.CALM_TALK, ""Yes, good thinking adventurer! Give it to me, I will bless it!"", () -> { player.getInventory().replace(2953, 2954); player.getQuestManager().setStage(Quest.PRIEST_IN_PERIL, 8); })); return; } if(player.getInventory().containsItem(2954)) { player.startConversation(new Dialogue() .addPlayer(HeadE.CALM_TALK, ""The key fit the lock! You're free to leave now!"") .addNPC(Drezel, HeadE.CALM_TALK, ""Excellent work, adventurer! Unfortunately, as you know, I cannot risk waking the vampyre in that coffin."") .addPlayer(HeadE.CALM_TALK, ""I have some blessed water from the Salve in this bucket. Do you think it will help against that vampyre?"") .addNPC(Drezel, HeadE.CALM_TALK, ""Yes! Great idea! If his coffin is doused in the blessed water he will be unable to leave it! Use it on his coffin, quickly!"") ); return; } else player.startConversation(new Dialogue() .addPlayer(HeadE.CALM_TALK, ""The key fit the lock! You're free to leave now!"") .addNPC(Drezel, HeadE.CALM_TALK, ""Excellent work, adventurer! Unfortunately, as you know, I cannot risk waking the vampyre in that coffin."") .addPlayer(HeadE.CALM_TALK, ""Do you have any ideas about dealing with the vampyre?"") .addNPC(Drezel, HeadE.CALM_TALK, ""Well, the water of the Salve should still have enough power to work against the vampyre, even if the Zamorakians have desecrated it."") .addNPC(Drezel, HeadE.CALM_TALK, ""Maybe you should try and get hold of some?"") ); } if (player.getQuestManager().getStage(Quest.PRIEST_IN_PERIL) == 8) { if(player.getInventory().containsItem(2953)){ player.startConversation(new Dialogue() .addPlayer(HeadE.CALM_TALK, ""The key fit the lock! You're free to leave now!"") .addNPC(Drezel, HeadE.CALM_TALK, ""Excellent work, adventurer! Unfortunately, as you know, I cannot risk waking the vampyre in that coffin."") .addPlayer(HeadE.CALM_TALK, ""I have some water from the Salve. It seems to have been desecrated though. Do you think you could bless it for me?"") .addNPC(Drezel, HeadE.CALM_TALK, ""Yes, good thinking adventurer! Give it to me, I will bless it!"", () -> { player.getInventory().replace(2953, 2954); player.getQuestManager().setStage(Quest.PRIEST_IN_PERIL, 8); })); return; } if(player.getInventory().containsItem(2954)) { player.startConversation(new Dialogue() .addPlayer(HeadE.CALM_TALK, ""The key fit the lock! You're free to leave now!"") .addNPC(Drezel, HeadE.CALM_TALK, ""Excellent work, adventurer! Unfortunately, as you know, I cannot risk waking the vampyre in that coffin."") .addPlayer(HeadE.CALM_TALK, ""I have some blessed water from the Salve in this bucket. Do you think it will help against that vampyre?"") .addNPC(Drezel, HeadE.CALM_TALK, ""Yes! Great idea! If his coffin is doused in the blessed water he will be unable to leave it! Use it on his coffin, quickly!"") ); return; } else player.startConversation(new Dialogue() .addPlayer(HeadE.CALM_TALK, ""The key fit the lock! You're free to leave now!"") .addNPC(Drezel, HeadE.CALM_TALK, ""Excellent work, adventurer! Unfortunately, as you know, I cannot risk waking the vampyre in that coffin."") .addPlayer(HeadE.CALM_TALK, ""Do you have any ideas about dealing with the vampyre?"") .addNPC(Drezel, HeadE.CALM_TALK, ""Well, the water of the Salve should still have enough power to work against the vampyre, even if the Zamorakians have desecrated it."") .addNPC(Drezel, HeadE.CALM_TALK, ""Maybe you should try and get hold of some?"") ); } if (player.getQuestManager().getStage(Quest.PRIEST_IN_PERIL) == 9) { player.startConversation(new Dialogue() .addPlayer(HeadE.CALM_TALK, ""I poured the blessed water over the coffin. I think that should trap the vampyre in there long enough for you to escape."") .addNPC(Drezel, HeadE.CALM_TALK, ""Excellent work adventurer! I am free at last! Let me ensure that evil vampyre is trapped for good. I will then meet you down in the mausoleum."") .addPlayer(HeadE.CALM_TALK, ""Okay."") ); } } }" "package com.rs.game.content.quests.priestinperil; public class DrezelMausoleumD extends Conversation { public DrezelMausoleumD(Player player) { super(player); int remainingEssence = Utils.clampI(50 - player.getQuestManager().getAttribs(Quest.PRIEST_IN_PERIL).getI(""essence""), 0, 50); if (player.getQuestManager().getStage(Quest.PRIEST_IN_PERIL) == 9) { player.startConversation(new Dialogue() .addNPC(DREZEL, HeadE.CALM_TALK, ""Ah, "" + player.getDisplayName() + "". Glad you made it. Things are worse than I feared down here. I'm not sure if I will be able to repair the damage."") .addPlayer(HeadE.CALM_TALK, ""Why, what's happened?"") .addNPC(DREZEL, HeadE.CALM_TALK, ""Sadly, with the guard dog gone, there was nothing to stop those Zamorakians from entering the mausoleum. From what I can tell, they have used some kind of evil potion to pollute the Salve."") .addNPC(DREZEL, HeadE.CALM_TALK, ""The well here is built right over the source of the river. That means that their potion will spread all the way down the Salve, disrupting the blessings placed upon it."") .addNPC(DREZEL, HeadE.CALM_TALK, ""Before long, there will be nothing to stop the vampyres from invading Misthalin at their leisure."") .addPlayer(HeadE.CALM_TALK, ""What can we do to prevent that?"") .addNPC(DREZEL, HeadE.CALM_TALK, ""This passage is currently the only route between Morytania and Misthalin. The barrier here draws power from the river."") .addNPC(DREZEL, HeadE.CALM_TALK, ""I have managed to reinforce the barrier, but I must continue focussing on it to keep it intact. Although the passage is safe for now, I do not know how long I can keep it that way."") .addNPC(DREZEL, HeadE.CALM_TALK, ""This passage could be the least of our worries soon though. Before long, the vampyres will be able to cross at any point of the river. We won't be able to reinforce all of it."") .addPlayer(HeadE.CALM_TALK, ""Couldn't you bless the river to purify it? Like you did with the water I took from the well?"") .addNPC(DREZEL, HeadE.CALM_TALK, ""No, that would not work. The power I have from Saradomin is not great enough to cleanse an entire river of this foul Zamorakian pollutant."") .addNPC(DREZEL, HeadE.CALM_TALK, ""However, I do have one other idea."") .addPlayer(HeadE.CALM_TALK, ""What's that?"") .addNPC(DREZEL, HeadE.CALM_TALK, ""I believe we might be able to soak up the evil magic that the potion has released into the river."") .addNPC(DREZEL, HeadE.CALM_TALK, ""I'm sure you know of runestones, used by mages to power their spells. The essence used to create these stones absorbs magical potential from runic altars to be released later."") .addPlayer(HeadE.CALM_TALK, ""And you think we could use some rune essence to absorb the magic they've released into the Salve?"") .addNPC(DREZEL, HeadE.CALM_TALK, ""Exactly. If you could bring me fifty essence, I should be able to reverse the damage done. Be quick though. The longer we wait, the worse things will get."", () -> player.getQuestManager().setStage(Quest.PRIEST_IN_PERIL, 10)) ); } if (player.getQuestManager().getStage(Quest.PRIEST_IN_PERIL) == 10) { if (player.getInventory().containsItem(1436) || player.getInventory().containsItem(7936)) { int essence = player.getInventory().getAmountOf(1436); int pureEssence = player.getInventory().getAmountOf(7936); if (remainingEssence == 0) { player.startConversation(new Dialogue() .addNPC(DREZEL, HeadE.CALM_TALK, ""Excellent! That should do it! I will bless these stones and place them within the well. With the river safe, Misthalin should be protected from the vampyres once more!"") .addNPC(DREZEL, HeadE.CALM_TALK, ""Please take this dagger. It has been handed down within my family for generations and is filled with the power of Saradomin."") .addNPC(DREZEL, HeadE.CALM_TALK, ""You will find that it has the ability to prevent werewolves from adopting their wolf form in combat. Hopefully it comes in useful."", () -> player.getQuestManager().setStage(Quest.PRIEST_IN_PERIL, 11)) ); player.getQuestManager().completeQuest(Quest.PRIEST_IN_PERIL); player.sendMessage(""Drezel blesses you, allowing you to pass through the barrier into Morytania.""); return; } if (remainingEssence > 0) { if (essence <= remainingEssence) { player.getInventory().deleteItem(1436, essence); player.getInventory().deleteItem(7936, pureEssence); player.getQuestManager().getAttribs(Quest.PRIEST_IN_PERIL).setI(""essence"", essence + Utils.clampI(player.getQuestManager().getAttribs(Quest.PRIEST_IN_PERIL).getI(""essence""), 0, 50)); player.getQuestManager().getAttribs(Quest.PRIEST_IN_PERIL).setI(""essence"", pureEssence + Utils.clampI(player.getQuestManager().getAttribs(Quest.PRIEST_IN_PERIL).getI(""essence""), 0, 50)); remainingEssence = Utils.clampI(50 - player.getQuestManager().getAttribs(Quest.PRIEST_IN_PERIL).getI(""essence""), 0, 50); player.startConversation(new Dialogue() .addPlayer(HeadE.CALM_TALK, ""I brought you some rune essence."") .addNPC(DREZEL, HeadE.CALM_TALK, ""Quickly, give them to me!"") .addNPC(DREZEL, HeadE.CALM_TALK, ""Thank you. I need "" + remainingEssence + "" more."") ); } else { player.getInventory().deleteItem(1436, remainingEssence); player.getInventory().deleteItem(7936, remainingEssence); player.getQuestManager().getAttribs(Quest.PRIEST_IN_PERIL).setI(""essence"", 50); player.startConversation(new Dialogue() .addPlayer(HeadE.CALM_TALK, ""I brought you some more essence."") .addNPC(DREZEL, HeadE.CALM_TALK, ""Quickly, give them to me!"") .addNPC(DREZEL, HeadE.CALM_TALK, ""Excellent! That should do it! I will bless these stones and place them within the well. With the river safe, Misthalin should be protected from the vampyres once more!"") .addNPC(DREZEL, HeadE.CALM_TALK, ""Please take this dagger. It has been handed down within my family for generations and is filled with the power of Saradomin."") .addNPC(DREZEL, HeadE.CALM_TALK, ""You will find that it has the ability to prevent werewolves from adopting their wolf form in combat. Hopefully it comes in useful."", () -> player.getQuestManager().setStage(Quest.PRIEST_IN_PERIL, 11)) ); player.getQuestManager().completeQuest(Quest.PRIEST_IN_PERIL); player.sendMessage(""Drezel blesses you, allowing you to pass through the barrier into Morytania.""); return; } } if (Utils.clampI(player.getQuestManager().getAttribs(Quest.PRIEST_IN_PERIL).getI(""essence""), 0, 50) > 0) { player.startConversation(new Dialogue() .addPlayer(HeadE.CALM_TALK, ""How much more essence do I need to bring you ?"") .addNPC(DREZEL, HeadE.CALM_TALK, ""I need "" + remainingEssence + "" more."") ); } } else { player.startConversation(new Dialogue() .addPlayer(HeadE.CALM_TALK, ""What am I supposed to do again?"") .addNPC(DREZEL, HeadE.CALM_TALK, ""Bring me fifty rune essence so that I can undo the damage done by those Zamorakians."") ); } } if (player.getQuestManager().isComplete(Quest.PRIEST_IN_PERIL)){ player.startConversation(new Dialogue() .addPlayer(HeadE.CALM_TALK, ""So can I pass through that barrier now?"") .addNPC(DREZEL, HeadE.CALM_TALK, ""Into Morytania? Yes, you can. The barrier will prevent the servants of Zamorak from entering Misthalin, but it is safe for those blessed by Saradomin."") .addNPC(DREZEL, HeadE.CALM_TALK, ""I must warn you though, Morytania is an evil land. The region is filled with creatures and monsters more terrifying than any you'll find on this side of the Salve."") .addNPC(DREZEL, HeadE.CALM_TALK, ""Worst of all are the vampyres, the rulers of Morytania. Be very cautious of their kind. Many are completely immune to human weaponry. Those that aren't, are still very hard to kill."") .addPlayer(HeadE.CALM_TALK, ""I'll be careful. Anything else I should know?"") .addNPC(DREZEL, HeadE.CALM_TALK, ""The first settlement you'll likely come across is Canifis, a town of werewolves. They probably won't attack you unless provoked, but you should still be cautious."") .addNPC(DREZEL, HeadE.CALM_TALK, ""You should keep your Wolfbane dagger to hand. It will prevent them from taking on their wolf form."") .addPlayer(HeadE.CALM_TALK, ""I see. Thanks."") .addNPC(DREZEL, HeadE.CALM_TALK, ""One last thing. While in Morytania, stay alert for any mention of the Myreque."") .addPlayer(HeadE.CALM_TALK, ""The Myreque?"") .addNPC(DREZEL, HeadE.CALM_TALK, ""Yes. They're a band of freedom fighters. They fight to protect the humans trapped in Morytania from the tyranny of the vampyres. Their hope is to one day rid the region of all evil."") .addNPC(DREZEL, HeadE.CALM_TALK, ""Veliaf, the leader of their Mort Myre group, is an old friend. I imagine they'd appreciate the help of someone like you, if you can find them."") .addPlayer(HeadE.CALM_TALK, ""I'll keep an eye out for them."") .addNPC(DREZEL, HeadE.CALM_TALK, ""Right, I think that's everything. Just the blessing itself now. Hold still a moment."") .addNPC(DREZEL, HeadE.CALM_TALK, ""Good luck out there. Stay safe."") ); } create(); } }" "package com.rs.game.content.quests.priestinperil; @PluginEventHandler public class KingRoaldPriestInPerilD extends Conversation { final int KING_ROALD = 648; public KingRoaldPriestInPerilD(Player player) { super(player); if (player.getQuestManager().getStage(Quest.PRIEST_IN_PERIL) == 0) { player.startConversation(new Dialogue() .addPlayer(HeadE.CONFUSED, ""Greetings, your majesty."") .addNPC(KING_ROALD, HeadE.CONFUSED, ""Well hello there. What do you want with the king of Misthalin?"") .addOptions(ops -> { ops.add(""I'm looking for a quest!"") .addPlayer(HeadE.CALM_TALK, ""I'm looking for a quest!"") .addNPC(KING_ROALD, HeadE.CALM_TALK, ""A quest you say? Hmm, what an odd request to make of the king. It's funny you should mention it though, as there is something you can do for me."") .addNPC(KING_ROALD, HeadE.CALM_TALK, ""Are you aware of Paterdomus? It's a temple east of here. It stands on the River Salve and guards the only passage into the deadly lands of Morytania."") .addPlayer(HeadE.CALM_TALK, ""No, I don't think I know it..."") .addNPC(KING_ROALD, HeadE.CALM_TALK, ""Hmm, how strange that you don't. Well anyway, it has been some days since last I heard from Drezel, the priest who lives there."") .addNPC(KING_ROALD, HeadE.CALM_TALK, ""Be a sport and go make sure that nothing untoward has happened to the silly old codger for me, would you?"") .addNext(() -> player.startConversation(new Dialogue() .addQuestStart(Quest.PRIEST_IN_PERIL) .addPlayer(HeadE.CALM_TALK, ""Sure. I don't have anything better to do right now."", () -> player.getQuestManager().setStage(Quest.PRIEST_IN_PERIL, 1)) .addNPC(KING_ROALD, HeadE.CALM_TALK, ""Many thanks adventurer! I would have sent one of my squires but they wanted payment for it!"") )); ops.add(""Nothing."") .addPlayer(HeadE.CALM_TALK, ""Nothing""); })); } if (player.getQuestManager().getStage(Quest.PRIEST_IN_PERIL) == 1) { player.startConversation(new Dialogue() .addPlayer(HeadE.CALM_TALK, ""Greetings, your majesty."") .addNPC(KING_ROALD, HeadE.CALM_TALK, ""You have news of Drezel for me?"") .addOptions(ops4 -> { ops4.add(""Where am I supposed to go again?"") .addPlayer(HeadE.CALM_TALK, ""Where am I supposed to go again?"") .addNPC(KING_ROALD, HeadE.CALM_TALK, ""The temple of Paterdomus where Drezel lives. It is but a short journey east from here. It lies south of the cliffs, at the source of the River Salve."") .addNPC(KING_ROALD, HeadE.CALM_TALK, ""Don't worry, you can't miss it.""); ops4.add(""Do I get a reward for this?"") .addPlayer(HeadE.CALM_TALK, ""Do I get a reward for this?"") .addNPC(KING_ROALD, HeadE.CALM_TALK, ""You will be rewarded in the knowledge that you have done the right thing and assisted the king of Misthalin."") .addPlayer(HeadE.CALM_TALK, ""Soooooo...... that would be a 'no' then?"") .addNPC(KING_ROALD, HeadE.CALM_TALK, ""That is correct.""); ops4.add(""Who's Drezel?"") .addPlayer(HeadE.CALM_TALK, ""Who's Drezel?"") .addNPC(KING_ROALD, HeadE.CALM_TALK, ""Drezel is the priest who lives at Paterdomus, the temple to the east. You're supposed to be making sure that nothing bad has happened to him. Remember?"") .addPlayer(HeadE.CALM_TALK, ""Ooooooooh, THAT Drezel. Yup, I remember.""); ops4.add(""Why do you care about Drezel anyway?"") .addPlayer(HeadE.CALM_TALK, ""Why do you care about Drezel anyway?"") .addNPC(KING_ROALD, HeadE.CALM_TALK, ""Well, that is a slightly impertinent question to ask of your king, but I shall overlook it this time."") .addNPC(KING_ROALD, HeadE.CALM_TALK, ""As you are no doubt aware, this kingdom worships Saradomin, the god of wisdom and order. As such, it is a peaceful place to live and prosper."") .addNPC(KING_ROALD, HeadE.CALM_TALK, ""Paterdomus, the temple where Drezel lives, stands on the eastern border of Misthalin. It guards the only passage into the evil lands of Morytania."") .addPlayer(HeadE.CALM_TALK, ""Evil?"") .addNPC(KING_ROALD, HeadE.CALM_TALK, ""Oh yes. Morytania is a fearful place, filled to the brim with accursed servants of the chaos god Zamorak. All of them are terrible, but none more so than the rulers of the region, the vampyres."") .addNPC(KING_ROALD, HeadE.CALM_TALK, ""Thankfully, the sacred River Salve marks a natural border between Misthalin and Morytania. Together, the river and the temple prevent any invasion by the vampyres."") .addNPC(KING_ROALD, HeadE.CALM_TALK, ""The waters of the river are kept blessed with Saradomin's almighty power. This ensures our defences remain strong, as the vampyres cannot cross such a holy barrier."") .addNPC(KING_ROALD, HeadE.CALM_TALK, ""Drezel is descended from one of the original Saradominist priests who first blessed the river. His job is to ensure nothing happens to the river that might allow the evil of Morytania to invade this land."") .addNPC(KING_ROALD, HeadE.CALM_TALK, ""This is the reason why the lack of communication from him bothers me somewhat, although I am sure nobody would dare to try and attack our kingdom!""); ops4.add(""I'll get going."") .addPlayer(HeadE.HAPPY_TALKING, ""I'll get going.""); }) ); } if (player.getQuestManager().getStage(Quest.PRIEST_IN_PERIL) == 2) { player.startConversation(new Dialogue() .addPlayer(HeadE.CALM_TALK, ""Greetings, your majesty."") .addNPC(KING_ROALD, HeadE.CALM_TALK, ""You have news of Drezel for me?"") .addPlayer(HeadE.CALM_TALK, ""Well... I went to the temple like you asked me to... and I spoke to someone inside..."") .addNPC(KING_ROALD, HeadE.CALM_TALK, ""Ah, well that must have been Drezel then. What did he say?"") .addPlayer(HeadE.CALM_TALK, ""Well... he seemed to be having some kind of trouble. He asked for my help."") .addNPC(KING_ROALD, HeadE.CALM_TALK, ""Well I expect you to offer him your full assistance in whatever he needs."") .addPlayer(HeadE.CALM_TALK, ""Well... okay then."") ); } if (player.getQuestManager().getStage(Quest.PRIEST_IN_PERIL) == 3) { player.startConversation(new Dialogue() .addPlayer(HeadE.CALM_TALK, ""Greetings, your majesty."") .addNPC(KING_ROALD, HeadE.CALM_TALK, ""You have news of Drezel for me?"") .addPlayer(HeadE.CALM_TALK, ""Yes, I spoke to the guys at the temple. They said they were being bothered by a dog in the mausoleum, so I went and killed it for them. No problem."") .addNPC(KING_ROALD, HeadE.CALM_TALK, ""YOU DID WHAT???"") .addPlayer(HeadE.CALM_TALK, ""Uh oh..."") .addNPC(KING_ROALD, HeadE.CALM_TALK, ""Are you a complete imbecile?"") .addPlayer(HeadE.CALM_TALK, ""Maybe?"") .addNPC(KING_ROALD, HeadE.CALM_TALK, ""That mausoleum contain the only passage between Morytania and Misthalin! Not only that, it's built right over the source of the River Salve!"") .addPlayer(HeadE.CALM_TALK, ""Did I make a mistake?"") .addNPC(KING_ROALD, HeadE.CALM_TALK, ""YES YOU DID!!!!! Without that 'dog', there's nothing to stop someone from entering the mausoleum to sabotage the blessings on the river. Thanks to you, all of Misthalin is now at risk!"") .addPlayer(HeadE.CALM_TALK, ""B-but... Drezel told me to..."") .addNPC(KING_ROALD, HeadE.CALM_TALK, ""No, you absolute cretin! Obviously some fiend has done something to Drezel and tricked your feeble intellect into helping them kill that guard dog!"") .addNPC(KING_ROALD, HeadE.CALM_TALK, ""Now you get back there and do whatever is necessary to safeguard the kingdom from attack, or I will see you beheaded for high treason!"") .addPlayer(HeadE.CALM_TALK, ""Y-yes your highness."", () -> player.getQuestManager().setStage(Quest.PRIEST_IN_PERIL, 4)) ); } if (player.getQuestManager().getStage(Quest.PRIEST_IN_PERIL) == 4) { player.startConversation(new Dialogue() .addPlayer(HeadE.CALM_TALK, ""Greetings, your majesty."") .addNPC(KING_ROALD, HeadE.CALM_TALK, ""YOU! Why haven't you ensured the border with Morytania is secure yet?"") .addPlayer(HeadE.CALM_TALK, ""Okay, okay... I'm going, I'm going... There's no need to shout..."") .addNPC(KING_ROALD, HeadE.CALM_TALK, ""NO NEED TO SHOUT???"") .addNPC(KING_ROALD, HeadE.CALM_TALK, ""Listen, and listen well, and see if your puny mind can comprehend this: if the border is not protected, then we are all at the mercy of the vampyres!"") .addNPC(KING_ROALD, HeadE.CALM_TALK, ""I would say that me shouting at you for your incompetence is the LEAST of your worries right now. NOW GO!"") ); } if (player.getQuestManager().getStage(Quest.PRIEST_IN_PERIL) == 5) { player.startConversation(new Dialogue() .addPlayer(HeadE.CALM_TALK, ""Greetings, your majesty."") .addNPC(KING_ROALD, HeadE.CALM_TALK, ""You have news of Drezel for me?"") .addPlayer(HeadE.CALM_TALK, ""I do indeed, sire. He has been imprisoned by some Zamorakian monks."") .addNPC(KING_ROALD, HeadE.CALM_TALK, ""What? This is wholly unacceptable! I order you to do all that you can to free Drezel immediately!"") .addPlayer(HeadE.CALM_TALK, ""I was doing that anyway."") .addNPC(KING_ROALD, HeadE.CALM_TALK, ""Ah, I see. In that case keep up the good work."") ); } if (player.getQuestManager().getStage(Quest.PRIEST_IN_PERIL) == 6) { player.startConversation(new Dialogue() .addPlayer(HeadE.CALM_TALK, ""Greetings, your majesty."") .addNPC(KING_ROALD, HeadE.CALM_TALK, ""Have you freed Drezel yet?"") .addPlayer(HeadE.CALM_TALK, ""Well, I found the key to his cell and unlocked it, but there's a vampyre in there stopping him leaving."") .addNPC(KING_ROALD, HeadE.CALM_TALK, ""A vampyre? Well, I order you to do something about it at once!"") .addPlayer(HeadE.CALM_TALK, ""Yeah, I was planning on doing that anyway."") .addNPC(KING_ROALD, HeadE.CALM_TALK, ""Good work! Always a place for quick thinkers in my kingdom!"") ); } if (player.getQuestManager().getStage(Quest.PRIEST_IN_PERIL) == 7) { player.startConversation(new Dialogue() .addPlayer(HeadE.CALM_TALK, ""Greetings, your majesty."") .addNPC(KING_ROALD, HeadE.CALM_TALK, ""Have you freed Drezel yet?"") .addPlayer(HeadE.CALM_TALK, ""Yes sire."") .addNPC(KING_ROALD, HeadE.CALM_TALK, ""Aha! Good work adventurer! What news of the border defences against Morytania?"") .addPlayer(HeadE.CALM_TALK, ""I, uh, don't know about that..."") .addNPC(KING_ROALD, HeadE.CALM_TALK, ""Well get back and find out at once! This is a matter of national security and if I find out we are vulnerable I will hold you personally responsible!"") .addPlayer(HeadE.CALM_TALK, ""Yes sire."") ); } if (player.getQuestManager().getStage(Quest.PRIEST_IN_PERIL) == 8) { player.startConversation(new Dialogue() .addPlayer(HeadE.CALM_TALK, ""Greetings, your majesty."") .addNPC(KING_ROALD, HeadE.CALM_TALK, ""Have you ensured Misthalin's border is fully secured?"") .addPlayer(HeadE.CALM_TALK, ""Not yet. I'm working on it though."") .addNPC(KING_ROALD, HeadE.CALM_TALK, ""Good, good."") ); } if (player.getQuestManager().getStage(Quest.PRIEST_IN_PERIL) >= 9) { player.startConversation(new Dialogue() .addPlayer(HeadE.CALM_TALK, ""Greetings, your majesty."") .addNPC(KING_ROALD, HeadE.CALM_TALK, ""Have you ensured Misthalin's border is fully secured?"") .addPlayer(HeadE.CALM_TALK, ""Not yet. I'm working on it though."") .addNPC(KING_ROALD, HeadE.CALM_TALK, ""Good, good."") ); } } }" "package com.rs.game.content.quests.priestinperil; @QuestHandler( quest = Quest.PRIEST_IN_PERIL, startText = ""Speak to King Roald in the Varrock Palace."", itemsText = ""50 unnoted rune essence or pure essence and a Bucket."", combatText = ""You will need to defeat a level 30 enemy."", rewardsText = ""1,406 Prayer XP
The Wolfbane Dagger
Access to Morytania."", completedStage = 11 ) @PluginEventHandler public class PriestInPeril extends QuestOutline { public enum Monuments{ N(3494, Tile.of(3423, 9895, 0), 2347,2949, ""Saradomin is the hammer that crushes evil everywhere.""), //Hammer NE(3497, Tile.of(3427,9894,0),2944,2945, ""Saradomin is the key that unlocks the mysteries of life""), //Key E(3495, Tile.of(3428,9890, 0), 314,2950, ""Saradomin is the delicate touch that brushes us with love.""), //Feather SE(3498, Tile.of(3427, 9885, 0), 1970,2946, ""Saradomin is the spark that lights the fire in our hearts.""), //Tinderbox S(3496, Tile.of(3422, 9884, 0), 1733,2951, ""Saradomin is the needle that binds our lives together.""), //Needle W(3493, Tile.of(3416, 9890, 0), 1931,2948, ""Saradomin is the vesel that keeps us safe from harm.""), //Pot NW(3499, Tile.of(3418,9894, 0), 36,2947, ""Saradomin is the light that shines throughout our lives.""); //Candle private final int monumentID; private final Tile tile; private final int itemID; private final int goldenID; private final String message; Monuments(int monumentID, Tile tile, int itemID, int goldenID, String message){ this.monumentID = monumentID; this.tile = tile; this.itemID = itemID; this.goldenID = goldenID; this.message = message; } public static Monuments getMonumentByTile(Tile tile) { for (Monuments monument : Monuments.values()) { if (monument.tile.equals(tile)) { return monument; } } return null; } } private static final int Drezel = 1047; @Override public List getJournalLines(Player player, int stage) { ArrayList lines = new ArrayList<>(); switch(stage) { case 0: lines.add(""I can start this quest by speaking to King Roald""); lines.add(""in the Varrock palace.""); break; case 1: lines.add(""""); lines.add(""I spoke to King Roald who asked me to investigate""); lines.add(""why his friend Priest Drezel has stopped communicating""); lines.add(""with him.""); break; case 2: lines.add(""""); lines.add(""I went to the temple where Drezel lives, but it was""); lines.add(""locked shut. I spoke to Drezel through the locked door.""); lines.add(""He told me that there was an annoying dog below the temple.""); lines.add(""Drezel told me to kill the dog.""); break; case 3: lines.add(""""); lines.add(""I killed the dog easily""); break; case 4: lines.add(""""); lines.add(""When I told Roald what I had done, he was furious!""); lines.add(""The person that told me to kill the dog wasn't Drezel at all!""); break; case 5: lines.add(""""); lines.add(""I returned to the temple and found the real Drezel locked in a cell.""); lines.add(""The cell was guarded by a vampyre!""); break; case 6, 7, 8: break; case 9: lines.add(""""); lines.add(""I used a key from a monument to open the cell door,""); lines.add(""and used Holy Water to trap the vampyre in his coffin.""); break; case 10: lines.add(""""); lines.add(""I followed Drezel to the mausoleum only to fine the Salve contaminated""); lines.add(""and in need of purification.""); break; case 11: lines.add(""""); lines.add(""I brought Drezel fifty rune essences and the contaminats were dissolved""); lines.add(""from the Salve.""); lines.add(""Drezel rewarded me for my help with an ancient Holy Weapon""); break; default: lines.add(""Invalid quest stage. Report this to an administrator.""); break; } return lines; } @Override public void updateStage(Player player, int stage) { if (stage == 2) { player.getVars().setVar(302, 2); } } @Override public void complete(Player player) { player.getSkills().addXpQuest(Constants.PRAYER,1406); player.getInventory().addItem(2952, 1, true); sendQuestCompleteInterface(player, 2952); } public static ObjectClickHandler handleTempleDoor = new ObjectClickHandler(new Object[] { 30707, 30708 }, e -> { if(e.getOption().equalsIgnoreCase(""open"")) if(e.getPlayer().getQuestManager().isComplete(Quest.PRIEST_IN_PERIL) || e.getPlayer().getQuestManager().getStage(Quest.PRIEST_IN_PERIL) >= 4){ handleDoubleDoor(e.getPlayer(), e.getObject()); return; } else { e.getPlayer().simpleDialogue(""The door is securely locked.""); return; } if (e.getPlayer().getQuestManager().getStage(Quest.PRIEST_IN_PERIL) == 0 || e.getPlayer().getQuestManager().getStage(Quest.PRIEST_IN_PERIL) >= 4) { e.getPlayer().sendMessage(""You knock at the door...""); e.getPlayer().sendMessage(""Doesn't seem like anyone's home.""); return; } if (!e.getPlayer().getQuestManager().isComplete(Quest.PRIEST_IN_PERIL) && e.getPlayer().getQuestManager().getStage(Quest.PRIEST_IN_PERIL) >= 1) { e.getPlayer().sendMessage(""You knock at the door...""); e.getPlayer().sendMessage(""You hear a voice from inside.""); new TempleDoorD(e.getPlayer()); } }); public static ObjectClickHandler handleDungeonGate = new ObjectClickHandler(new Object[] { 3444, Tile.of(3405, 9895, 0), }, e -> { if(e.getPlayer().getQuestManager().isComplete(Quest.PRIEST_IN_PERIL) || e.getPlayer().getQuestManager().getStage(Quest.PRIEST_IN_PERIL) >= 3){ handleGate(e.getPlayer(), e.getObject()); } else { e.getPlayer().startConversation(new Dialogue() .addNPC(7711, HeadE.CAT_SHOUTING, ""Grrr..."")); e.getPlayer().sendMessage(""It looks like the dog is protecting the gate.""); } }); public static ObjectClickHandler handleDrezelDungeonGate = new ObjectClickHandler(new Object[] { 3445, Tile.of(3431, 9897, 0), }, e -> { if (e.getPlayer().getQuestManager().isComplete(Quest.PRIEST_IN_PERIL) || e.getPlayer().getQuestManager().getStage(Quest.PRIEST_IN_PERIL) >= 9) { handleGate(e.getPlayer(), e.getObject()); } else e.getPlayer().startConversation(new Dialogue() .addSimple(""The gate is securely locked."") ); }); public static ObjectClickHandler handleHolyBarrier = new ObjectClickHandler(new Object[] { 3443 }, e -> { if(e.getPlayer().getQuestManager().isComplete(Quest.PRIEST_IN_PERIL)) e.getPlayer().ladder(Tile.of(3423, 3484, 0)); else { e.getPlayer().startConversation(new Dialogue() .addNPC(Drezel, HeadE.ANGRY, ""STOP!"") .addPlayer(HeadE.CONFUSED, ""Can't I go through there?"") .addNPC(Drezel, HeadE.ANGRY, ""No, you cannot! It is taking all of my willpower to hold that barrier in place. You must restore the sanctity of the Salve as soon as possible!"") ); } }); public static ObjectClickHandler handleWell = new ObjectClickHandler(new Object[] { 3485 }, Tile.of(3423, 9890, 0), e -> { if(!e.getPlayer().getQuestManager().isComplete(Quest.PRIEST_IN_PERIL)) e.getPlayer().sendMessage(""You look down the well and see the filthy polluted water of the River Salve moving slowly along.""); else e.getPlayer().sendMessage(""You look down the well and see the fresh water of the River Salve moving slowly along.""); }); public static ItemOnObjectHandler handleBucketOnWell = new ItemOnObjectHandler(new Object[] { 3485 }, new Object[] { 1925 }, e -> { int stage = e.getPlayer().getQuestManager().getStage(Quest.PRIEST_IN_PERIL); if (!e.getPlayer().isQuestStarted(Quest.PRIEST_IN_PERIL)) { e.getPlayer().sendMessage(""This water is filthy, I best leave it alone.""); return; } if (stage == 6 || stage == 7 || stage == 8) { e.getPlayer().getInventory().replace(1925, 2953); e.getPlayer().sendMessage(""This water doesn't look particularly holy to me... I think I'd better check with Drezel first.""); e.getPlayer().getQuestManager().setStage(Quest.PRIEST_IN_PERIL, 8); return; } if (stage >= 9 || e.getPlayer().isQuestComplete(Quest.PRIEST_IN_PERIL)) e.getPlayer().getInventory().replace(1925, 1929); }); public static NPCDeathHandler handleMonkKeys = new NPCDeathHandler(new Object[] {1044, 1045, 1046}, e -> { if (e.getKiller() instanceof Player player && (player.getQuestManager().getStage(Quest.PRIEST_IN_PERIL) == 4 || player.getQuestManager().getStage(Quest.PRIEST_IN_PERIL) == 5)) { if(!player.getInventory().containsItem(2945) || !player.getBank().containsItem(2945, 1)) player.getQuestManager().getAttribs(Quest.PRIEST_IN_PERIL).setB(String.valueOf(Monuments.NE), false); if(player.getInventory().containsItem(2945) || player.getBank().containsItem(2945, 1)) return; if(player.getInventory().containsItem(2944) || player.getBank().containsItem(2944, 1)) return; World.addGroundItem(new Item(2944), e.getNPC().getTile(), player); } }); public static ObjectClickHandler handleNorthStair = new ObjectClickHandler(new Object[] { 30725 }, Tile.of(3415, 3491, 1), e -> e.getPlayer().useStairs(827, Tile.of(3414, 3491, 0), 1, 2)); public static ObjectClickHandler handleSouthStair = new ObjectClickHandler(new Object[] { 30723 }, Tile.of(3415, 3486, 1), e -> e.getPlayer().useStairs(827, Tile.of(3414, 3486, 0), 1, 2)); public static ObjectClickHandler HandleCoffin = new ObjectClickHandler( new Object[] { 30728 }, e -> { if (e.getPlayer().getQuestManager().isComplete(Quest.PRIEST_IN_PERIL) || e.getPlayer().getQuestManager().getStage(Quest.PRIEST_IN_PERIL) >= 8) e.getPlayer().sendMessage(""The vampyre should be dealt with. I'd still best not risk it though.""); else e.getPlayer().sendMessage(""It sounds like there's something alive inside it. I don't think it would be a very good idea to open it...""); }); public static ObjectClickHandler handleJailDoor = new ObjectClickHandler(new Object[] { 3463 }, Tile.of(3413,3487,2), e -> { final int Drezel = 1047; if(e.getOption().equalsIgnoreCase(""Talk-through"")) { if (e.getPlayer().getQuestManager().isComplete(Quest.PRIEST_IN_PERIL) || e.getPlayer().getQuestManager().getStage(Quest.PRIEST_IN_PERIL) >= 6) { handleGate(e.getPlayer(), e.getObject()); return; } else new DrezelInJailD(e.getPlayer()); } if(e.getOption().equalsIgnoreCase(""Open"")) { if (e.getPlayer().getQuestManager().isComplete(Quest.PRIEST_IN_PERIL) || e.getPlayer().getQuestManager().getStage(Quest.PRIEST_IN_PERIL) >= 6) { handleGate(e.getPlayer(), e.getObject()); return; } if (e.getPlayer().getInventory().containsItem(2944)) { e.getPlayer().sendMessage(""This key doesn't fit.""); return; } if (e.getPlayer().getInventory().containsItem(2945)) { e.getPlayer().startConversation( new Dialogue() .addNPC(Drezel, HeadE.CALM_TALK, ""Oh! Thank you! You have found the key!"") ); e.getPlayer().getInventory().deleteItem(2945,1); e.getPlayer().getQuestManager().setStage(Quest.PRIEST_IN_PERIL, 7); handleGate(e.getPlayer(), e.getObject()); return; } else new DrezelInJailD(e.getPlayer()); } }); public static ItemOnObjectHandler handleBucketOnCoffin = new ItemOnObjectHandler(new Object[] { 30728 }, new Object[] { 1929, 2953, 2954 }, e -> { if (e.getPlayer().getQuestManager().getStage(Quest.PRIEST_IN_PERIL) == 8) { if (e.getItem().getId() == 1929) { e.getPlayer().sendMessage(""I don't think pouring normal water on the coffin is going to help...""); return; } if (e.getItem().getId() == 2953) { e.getPlayer().sendMessage(""This water doesn't look particularly holy to me... I think I'd better check with Drezel first.""); return; } if (e.getItem().getId() == 2954) { e.getPlayer().sendMessage(""You pour the blessed water over the coffin...""); e.getPlayer().getQuestManager().setStage(Quest.PRIEST_IN_PERIL, 9); e.getPlayer().getInventory().replace(2954, 1925); e.getPlayer().anim(2771); } } }); public static ObjectClickHandler HandleMonuments = new ObjectClickHandler(Arrays.stream(Monuments.values()).map(monuments -> monuments.monumentID).toArray(), e -> { Player player = e.getPlayer(); if (e.getOption().equalsIgnoreCase(""study"")) { player.getInterfaceManager().sendInterface(272); player.getPackets().setIFText(272, 17, Monuments.getMonumentByTile(e.getObject().getTile()).message); if(player.getQuestManager().getAttribs(Quest.PRIEST_IN_PERIL).getB(String.valueOf(Monuments.getMonumentByTile(e.getObject().getTile())))){ player.getPackets().setIFItem(272, 4, Monuments.getMonumentByTile(e.getObject().getTile()).itemID, 1); player.sendMessage(""This monument holds a "" + ItemConfig.get(Monuments.getMonumentByTile(e.getObject().getTile()).itemID).getUidName().replaceAll(""_"", "" "")); } else { player.getPackets().setIFItem(272, 4, Monuments.getMonumentByTile(e.getObject().getTile()).goldenID, 1); player.sendMessage(""This monument holds a "" + ItemConfig.get(Monuments.getMonumentByTile(e.getObject().getTile()).goldenID).getUidName().replaceAll(""_"", "" "")); } } if(e.getOption().equalsIgnoreCase(""take-from"")) { if (player.getQuestManager().getStage(Quest.PRIEST_IN_PERIL) == 5) { if (!player.getQuestManager().getAttribs(Quest.PRIEST_IN_PERIL).getB(String.valueOf(Monuments.getMonumentByTile(e.getObject().getTile())))) { if (player.getInventory().containsItem(Monuments.getMonumentByTile(e.getObject().getTile()).itemID)) { player.getInventory().replace(Monuments.getMonumentByTile(e.getObject().getTile()).itemID, Monuments.getMonumentByTile(e.getObject().getTile()).goldenID); player.sendMessage(""You take the "" + ItemConfig.get(Monuments.getMonumentByTile(e.getObject().getTile()).goldenID).getUidName().replaceAll(""_"", "" "") + "" from the statue leaving your "" + ItemConfig.get(Monuments.getMonumentByTile(e.getObject().getTile()).itemID).getUidName().replaceAll(""_"", "" "") + "" in its place.""); player.getQuestManager().getAttribs(Quest.PRIEST_IN_PERIL).setB(String.valueOf(Monuments.getMonumentByTile(e.getObject().getTile())), true); } else { player.applyHit(new Hit(player, 3, Hit.HitLook.TRUE_DAMAGE)); player.sendMessage(""A holy power prevents you stealing from the monument.""); } } else { if (player.getInventory().containsItem(Monuments.getMonumentByTile(e.getObject().getTile()).goldenID)) { player.getInventory().replace(Monuments.getMonumentByTile(e.getObject().getTile()).goldenID, Monuments.getMonumentByTile(e.getObject().getTile()).itemID); player.sendMessage(""You take the "" + ItemConfig.get(Monuments.getMonumentByTile(e.getObject().getTile()).itemID).getUidName().replaceAll(""_"", "" "") + "" from the statue leaving your "" + ItemConfig.get(Monuments.getMonumentByTile(e.getObject().getTile()).goldenID).getUidName().replaceAll(""_"", "" "") + "" in its place.""); player.getQuestManager().getAttribs(Quest.PRIEST_IN_PERIL).setB(String.valueOf(Monuments.getMonumentByTile(e.getObject().getTile())), false); } else { player.applyHit(new Hit(player, 3, Hit.HitLook.TRUE_DAMAGE)); player.sendMessage(""A holy power prevents you stealing from the monument.""); } } } else { player.applyHit(new Hit(player, 3, Hit.HitLook.TRUE_DAMAGE)); player.sendMessage(""A holy power prevents you stealing from the monument.""); } } }); }" "package com.rs.game.content.quests.priestinperil; @PluginEventHandler public class TempleDoorD extends Conversation { final int MONK = 1045; public TempleDoorD(Player player) { super(player); if (player.getQuestManager().getStage(Quest.PRIEST_IN_PERIL) == 1) { player.startConversation(new Dialogue() .addNPC(MONK, HeadE.CALM_TALK, "" Who are you and what do you want?"", ""Mysterious Voice"") .addPlayer(HeadE.CALM_TALK, ""Ummmm...."") .addOptions(ops -> { ops.add(""Roald sent me to check on Drezel."") .addPlayer(HeadE.CALM_TALK, ""Roald sent me to check on Drezel."") .addNPC(MONK, HeadE.CALM_TALK, ""Psst... Hey... Who's Roald? Who's Drezel?"", ""Mysterious Voice"") .addNPC(MONK, HeadE.CALM_TALK, ""Uh... Isn't Drezel that dude upstairs? Oh, wait, Roald's the king of Misthalin right?"", ""Mysterious Voice #2"") .addNPC(MONK, HeadE.CALM_TALK, ""He is? Aww man..."", ""Mysterious Voice"") .addNPC(MONK, HeadE.CALM_TALK, ""Hey, you deal with this okay."", ""Mysterious Voice"") .addNPC(MONK, HeadE.CALM_TALK, ""He's just coming! Wait a second!"", ""Mysterious Voice"") .addNPC(MONK, HeadE.CALM_TALK, ""Hello, my name is Drevil."", ""Drevil"") .addNPC(MONK, HeadE.CALM_TALK, ""Drezel!"", ""Mysterious Voice"") .addNPC(MONK, HeadE.CALM_TALK, ""I mean Drezel. How can I help?"", ""* Drezel *"") .addPlayer(HeadE.CALM_TALK, ""Well, as I say, the king sent me to make sure everything's okay with you."") .addNPC(MONK, HeadE.CALM_TALK, ""And, uh, what would you do if everything wasn't okay with me?"", ""* Drezel *"") .addPlayer(HeadE.CALM_TALK, ""I'm not sure. Ask you what help you need I suppose."") .addNPC(MONK, HeadE.CALM_TALK, ""Ah, good, well, I don't think..."", ""* Drezel *"") .addNPC(MONK, HeadE.CALM_TALK, ""Psst... Hey... The dog!"", ""Mysterious Voice #2"") .addNPC(MONK, HeadE.CALM_TALK, ""OH! Yes, of course!"", ""* Drezel *"") .addNPC(MONK, HeadE.CALM_TALK, ""Will you do me a favour, adventurer?"", ""* Drezel *"") .addOptions(ops2 ->{ ops2.add(""Sure, I'm a helpful person!"") .addPlayer(HeadE.CALM_TALK, ""Sure. I'm a helpful person!"") .addNPC(MONK, HeadE.CALM_TALK, ""HAHAHAHA! Really? Thanks buddy! You see that mausoleum out there? There's a horrible big dog underneath it that I'd like you to kill for me! It's been really bugging me! Barking all the time and stuff!"", ""* Drezel *"") .addNPC(MONK, HeadE.CALM_TALK, ""Please kill it for me buddy!"", ""* Drezel *"") .addPlayer(HeadE.CALM_TALK, ""Okey-dokey, one dead dog coming up."", () -> player.getQuestManager().setStage(Quest.PRIEST_IN_PERIL, 2)); ops2.add(""Nope. Something about all this is very suspicious..."") .addPlayer(HeadE.CALM_TALK, ""Nope. Something about all this is very suspicious..."") .addNPC(MONK, HeadE.CALM_TALK, ""Get lost then! I have important things to do, as sure as my name is Dibzil."", ""* Dibzil *"") .addNPC(MONK, HeadE.CALM_TALK, ""Drezel!"", ""Mysterious Voice"") .addNPC(MONK, HeadE.CALM_TALK, ""Drezel. Now, go away!"", ""* Drezel *""); }); ops.add(""Hi, I just moved in next door."") .addPlayer(HeadE.CALM_TALK,""Hi, I just moved in next door."") .addPlayer(HeadE.CALM_TALK,""Can I borrow a cup of coffee?"") .addNPC(MONK, HeadE.CALM_TALK, ""What next door? What's coffee? Who ARE you?"", ""Mysterious Voice""); ops.add(""I hear this place is of historic interest."") .addPlayer(HeadE.CALM_TALK,""I hear this place is of historic interest."") .addPlayer(HeadE.CALM_TALK,""Can I come in and have a wander around? Possibly look at some antiques or buy something from your gift shop?"") .addNPC(MONK, HeadE.CALM_TALK, ""Pssst... Hey... Is this place of historic interest?"", ""Mysterious Voice"") .addNPC(MONK, HeadE.CALM_TALK, ""I dunno. I guess it might be. Does it matter?"", ""Mysterious Voice #2"") .addNPC(MONK, HeadE.CALM_TALK, ""I suppose not."", ""Mysterious Voice"") .addNPC(MONK, HeadE.CALM_TALK, ""Clear off! You can't come in!"", ""Mysterious Voice""); ops.add(""The council sent me to check your pipes."") .addPlayer(HeadE.CALM_TALK,""The council sent me to check your pipes."") .addNPC(MONK, HeadE.CALM_TALK, ""They did? Ummm...."", ""Mysterious Voice"") .addNPC(MONK, HeadE.CALM_TALK, ""Psst... Are there any pipes in here, you reckon?"", ""Mysterious Voice"") .addNPC(MONK, HeadE.CALM_TALK, ""I dunno... I don't think so..."", ""Mysterious Voice #2"") .addNPC(MONK, HeadE.CALM_TALK, ""We don't have any thanks! Bye!"", ""Mysterious Voice""); ops.add(""Nothing. Never mind.""); }) ); } if (player.getQuestManager().getStage(Quest.PRIEST_IN_PERIL) == 2) { player.startConversation(new Dialogue() .addNPC(MONK, HeadE.CALM_TALK, ""Hello?"", ""* Drezel *"") .addPlayer(HeadE.CALM_TALK,""What am I supposed to be doing again?"") .addNPC(MONK, HeadE.CALM_TALK, ""Who are you?"", ""* Drezel *"") .addNPC(MONK, HeadE.CALM_TALK, ""SHHHH! It's the adventurer!"", ""Mysterious Voice #2"") .addNPC(MONK, HeadE.CALM_TALK, ""Ah! I want you to go kill the horrible dog in the mausoleum for me! You can use the entrance out there."", ""* Drezel *"") .addNPC(MONK, HeadE.CALM_TALK, ""You'll do this for good old Delzig, won't ya buddy?"", ""* Delzig *"") .addNPC(MONK, HeadE.CALM_TALK, ""Drezel!"", ""Mysterious Voice"") .addNPC(MONK, HeadE.CALM_TALK, ""*cough* for good old Drezel, right buddy?"", ""* Drezel *"") ); } if (player.getQuestManager().getStage(Quest.PRIEST_IN_PERIL) == 3) { player.startConversation(new Dialogue() .addNPC(MONK, HeadE.CALM_TALK, ""You again? What do you want now?"", ""* Drezel *"") .addPlayer(HeadE.CALM_TALK,""I killed that dog for you."") .addNPC(MONK, HeadE.CALM_TALK, ""Really? Hey, that's great!"", ""* Drezel *"") .addNPC(MONK, HeadE.CALM_TALK, ""Yeah thanks a lot buddy!"", ""Mysterious Voice"") .addNPC(MONK, HeadE.CALM_TALK, ""HAHAHAHAHAHA!"", ""Mysterious Voice #2"") .addPlayer(HeadE.CALM_TALK,""What's so funny?"") .addNPC(MONK, HeadE.CALM_TALK, ""Nothing buddy! We're just so grateful!"", ""* Drezel *"") .addNPC(MONK, HeadE.CALM_TALK, ""Yeah, maybe you should go tell the king what a great job you did buddy!"", ""Mysterious Voice #2"") ); } } }" "package com.rs.game.content.quests.princealirescue; @PluginEventHandler public class HassanPrinceAliRescueD extends Conversation { private final static int HASSAN = 923; public HassanPrinceAliRescueD(Player player) { super(player); addNPC(HASSAN, HeadE.HAPPY_TALKING, ""Greetings I am Hassan, Chancellor to the Emir of Al- Kharid.""); addOptions(""Choose an option:"", new Options() { @Override public void create() { if(player.getQuestManager().getStage(Quest.PRINCE_ALI_RESCUE) == PrinceAliRescue.NOT_STARTED) option(""Can I help you? You must need some help here in the desert."", new Dialogue() .addNPC(HASSAN, HeadE.TALKING_ALOT, ""I need the services of someone, yes. If you are interested, see the spymaster, Osman. I manage "" + ""the finances here. Come to me when you need payment."") .addOptions(""Start Prince Ali To The Rescue?"", new Options() { @Override public void create() { option(""Yes."", new Dialogue() .addNPC(HASSAN, HeadE.HAPPY_TALKING, ""Speak to Osman outside the palace, he will give you more details..."", ()-> player.getQuestManager().setStage(Quest.PRINCE_ALI_RESCUE, PrinceAliRescue.STARTED)) .addPlayer(HeadE.HAPPY_TALKING, ""Okay..."")); option(""No."", new Dialogue()); } })); option(""It's just too hot here. How can you stand it?"", new Dialogue() .addNPC(HASSAN, HeadE.HAPPY_TALKING, ""We manage, in our humble way. We are a wealthy town and we have water. It cures many thirsts."")); option(""Do you mind if I just kill your warriors?"", new Dialogue() .addNPC(HASSAN, HeadE.HAPPY_TALKING, ""You are welcome. They are not expensive. We have them here to stop the elite guard being bothered. "" + ""They are a little harder to kill."")); } }); } public static NPCClickHandler handleHassan = new NPCClickHandler(new Object[] { HASSAN }, e -> e.getPlayer().startConversation(new HassanPrinceAliRescueD(e.getPlayer()).getStart())); }" "package com.rs.game.content.quests.princealirescue; @PluginEventHandler public class JoePrinceAliRescueD extends Conversation { private final static int JOE = 916; public JoePrinceAliRescueD(Player player) { super(player); if(player.getQuestManager().getAttribs(Quest.PRINCE_ALI_RESCUE).getB(""Joe_guard_is_drunk"")) { addNPC(JOE, HeadE.DRUNK, ""Halt! Who goes there?""); addPlayer(HeadE.HAPPY_TALKING, ""Hello friend, I am just rescuing the prince, is that ok?""); addNPC(JOE, HeadE.DRUNK, ""Thatsh a funny joke. You are lucky I am shober. Go in peace, friend.""); } else addOptions(""Choose an option:"", new Options() { @Override public void create() { if(player.getInventory().containsItem(BEER, 3)) option(""I have some beer here, fancy one?"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""I have some beer here, fancy one?"") .addNPC(JOE, HeadE.CALM_TALK, ""Ah, that would be lovely, just one now, just to wet my throat."") .addPlayer(HeadE.HAPPY_TALKING, ""Of course, it must be tough being here without a drink."") .addSimple(""You hand a beer to the guard, he drinks it in seconds."") .addNPC(JOE, HeadE.HAPPY_TALKING, ""That was perfect, I can't thank you enough."") .addPlayer(HeadE.SECRETIVE, ""How are you? Still ok? Not too drunk?"") .addPlayer(HeadE.SECRETIVE, ""Would you care for another, my friend?"") .addNPC(JOE, HeadE.CALM_TALK, ""I better not, I don't want to be drunk on duty."") .addPlayer(HeadE.SECRETIVE, ""Here, just keep these for later, I hate to see a thirsty guard."") .addSimple(""You hand two more beers to the guard."") .addSimple(""He takes a sip of one, and then he drinks them both."") .addNPC(JOE, HeadE.DRUNK, ""Franksh, that wash just what I need to shtay on guard. No more beersh, I don't want to get drunk."") .addSimple(""The guard is drunk, and no longer a problem."", () -> { player.getInventory().deleteItem(BEER, 3); player.getQuestManager().getAttribs(Quest.PRINCE_ALI_RESCUE).setB(""Joe_guard_is_drunk"", true); })); option(""Tell me about the life of a guard."", new Dialogue() .addPlayer(HeadE.TALKING_ALOT, ""Tell me about the life of a guard."") .addNPC(JOE, HeadE.CALM_TALK, ""Well, the hours are good....."") .addNPC(JOE, HeadE.FRUSTRATED, "".... But most of those hours are a drag. If only I had spent more time in Knight school when I"" + "" was a young boy. Maybe I wouldn't be here now, scared of Keli."") .addOptions(""Choose an option:"", new Options() { @Override public void create() { option(""Hey, chill out, I won't cause you trouble."", new Dialogue() .addPlayer(HeadE.CALM_TALK, ""Hey, chill out, I won't cause you trouble."") .addPlayer(HeadE.CALM_TALK, ""I was just wondering what you do to relax."") .addNPC(JOE, HeadE.TALKING_ALOT, ""You never relax with these people, but it's a good career for a young man and some "" + ""of the shouting I rather like."") .addNPC(JOE, HeadE.AMAZED, ""RESISTANCE IS USELESS!"", () -> player.getTempAttribs().setB(""JoeTheGuardTalksALot"", true)) .addNext(()-> player.startConversation(new JoePrinceAliRescueD(player)))); option(""What did you want to be when you were a boy?"", new Dialogue() .addPlayer(HeadE.TALKING_ALOT, ""What did you want to be when you were a boy?"") .addNPC(JOE, HeadE.TALKING_ALOT, ""Well, I loved to sit by the lake, with my toes in the water and shoot the fish with my bow and arrow."") .addPlayer(HeadE.TALKING_ALOT, ""That was a strange hobby for a little boy."") .addNPC(JOE, HeadE.TALKING_ALOT, ""It kept us from goblin hunting, which was what most boys did. What are you here for?"") .addNext(()-> player.startConversation(new JoePrinceAliRescueD(player)))); } })); if(player.getTempAttribs().getB(""JoeTheGuardTalksALot"")) { option(""So what do you buy with these great wages?"", new Dialogue() .addPlayer(HeadE.TALKING_ALOT, ""So what do you buy with these great wages?"") .addNPC(JOE, HeadE.TALKING_ALOT, ""Really, after working here, there's only time for a drink or three. All us guards go to the"" + "" same bar and drink ourselves stupid."") .addNPC(JOE, HeadE.TALKING_ALOT, ""It's what I enjoy these days, that fade into unconciousness. I can't resist the sight of a "" + ""really cold beer."") .addNext(()-> player.startConversation(new JoePrinceAliRescueD(player)))); option(""Would you be interested in making a little more money?"", new Dialogue() .addPlayer(HeadE.SECRETIVE, ""Would you be interested in making a little more money?"") .addNPC(JOE, HeadE.ANGRY, ""WHAT?! Are you trying to bribe me? I may not be a great guard, but I am loyal. How DARE you "" + ""try to bribe me!"") .addPlayer(HeadE.SHAKING_HEAD, ""No, no, you got the wrong idea, totally. I just wondered if you wanted some part-time bodyguard work."") .addNPC(JOE, HeadE.CALM_TALK, ""Oh. Sorry. No, I don't need money. As long as you were not offering me a bribe."") .addNext(()-> player.startConversation(new JoePrinceAliRescueD(player)))); } option(""What did you want to be when you were a boy?"", new Dialogue() .addPlayer(HeadE.TALKING_ALOT, ""What did you want to be when you were a boy?"") .addNPC(JOE, HeadE.TALKING_ALOT, ""Well, I loved to sit by the lake, with my toes in the water and shoot the fish with my bow and arrow."") .addPlayer(HeadE.TALKING_ALOT, ""That was a strange hobby for a little boy."") .addNPC(JOE, HeadE.TALKING_ALOT, ""It kept us from goblin hunting, which was what most boys did. What are you here for?"") .addNext(()-> player.startConversation(new JoePrinceAliRescueD(player)))); option(""I had better leave, I don't want trouble."", new Dialogue() .addNPC(JOE, HeadE.HAPPY_TALKING, ""Thanks, I appreciate that. Talking on duty can be punishable by having your mouth stitched up. These are "" + ""tough people, no mistake."")); } }); } public static NPCClickHandler handleJoe = new NPCClickHandler(new Object[] { JOE }, e -> e.getPlayer().startConversation(new JoePrinceAliRescueD(e.getPlayer()).getStart())); }" "package com.rs.game.content.quests.princealirescue; @PluginEventHandler public class LadyKeliPrinceAliRescueD extends Conversation { private final static int LADY_KELI = 919; private final int ORIGINAL_OPTIONS = 0; private final int LATEST_PLAN_OPTIONS = 1; public LadyKeliPrinceAliRescueD(Player player) { super(player); addPlayer(HeadE.HAPPY_TALKING, ""Are you the famous Lady Keli?""); addPlayer(HeadE.HAPPY_TALKING, ""Leader of the toughest gang of mercenary killers around?""); addNPC(LADY_KELI, HeadE.HAPPY_TALKING, ""I am Keli, you have heard of me then""); addNext(()-> player.startConversation(new LadyKeliPrinceAliRescueD(player, ORIGINAL_OPTIONS, true))); } public LadyKeliPrinceAliRescueD(Player player, int convoID, boolean isFirst) { super(player); switch(convoID) { case ORIGINAL_OPTIONS: originalOptions(isFirst); break; case LATEST_PLAN_OPTIONS: latestPlanOptions(isFirst); break; } } private void originalOptions(boolean isFirst) { addOptions(""Choose an option:"", new Options() { @Override public void create() { if(isFirst) option(""Heard of you? You are famous in Gielinor!"", new Dialogue() .addPlayer(HeadE.AMAZED_MILD, ""Heard of you? You are famous in Gielinor!"") .addNPC(LADY_KELI, HeadE.HAPPY_TALKING, ""That's very kind of you to say. Reputations are not easily earned. I have managed to succeed"" + "" where many fail."") .addNext(()-> player.startConversation(new LadyKeliPrinceAliRescueD(player, ORIGINAL_OPTIONS, false)))); option(""I have heard a little, but I think Katrine is tougher."", new Dialogue() .addPlayer(HeadE.CALM_TALK, ""I think Katrine is still tougher."") .addNPC(LADY_KELI, HeadE.FRUSTRATED, ""Well you can think that all you like. I know those blackarm cowards dare not leave the city. "" + ""Out here, I am toughest. You can tell them that! Now get out of my sight, before I call my guards."")); if(!isFirst) { option(""What is your latest plan then?"", new Dialogue() .addPlayer(HeadE.SECRETIVE, ""What is your latest plan then?"") .addPlayer(HeadE.SKEPTICAL_THINKING, ""Of course you need not go into specific details"") .addNPC(LADY_KELI, HeadE.TALKING_ALOT, ""Well, I can tell you, I have a valuable prisoner here in my cells"") .addNPC(LADY_KELI, HeadE.TALKING_ALOT, ""I can expect a high reward to be paid very soon for this guy"") .addNPC(LADY_KELI, HeadE.SECRETIVE, ""I can't tell you who he is, but he is a lot colder now"") .addNext(()-> player.startConversation(new LadyKeliPrinceAliRescueD(player, LATEST_PLAN_OPTIONS, true)))); option(""You must have trained a lot for this work"", new Dialogue() .addPlayer(HeadE.AMAZED_MILD, ""You must have trained a lot for this work"") .addNPC(LADY_KELI, HeadE.TALKING_ALOT, ""I have used a sword since I was a small girl"") .addNPC(LADY_KELI, HeadE.EVIL_LAUGH, ""stabbed three people before I was 6 years old"")); } if(isFirst) option(""I have heard rumours that you kill people."", new Dialogue() .addPlayer(HeadE.SECRETIVE, ""I have heard rumours that you kill people."") .addNPC(LADY_KELI, HeadE.CALM_TALK, ""There's always someone ready to spread rumours. I hear all sort of ridiculous things these days."") .addNPC(LADY_KELI, HeadE.FRUSTRATED, ""I heard a rumour the other day, that some men are wearing skirts"") .addNPC(LADY_KELI, HeadE.VERY_FRUSTRATED, ""If one of my men wore a skirt, he would wish he hadn't"") .addNext(()-> player.startConversation(new LadyKeliPrinceAliRescueD(player, ORIGINAL_OPTIONS, false)))); if(isFirst) option(""No I have never really heard of you."", new Dialogue() .addPlayer(HeadE.CALM_TALK, ""No I have never really heard of you."") .addNPC(LADY_KELI, HeadE.FRUSTRATED, ""You must be new to this land then"") .addNPC(LADY_KELI, HeadE.FRUSTRATED, ""EVERYONE knows of Lady Keli and her prowess with the sword"") .addOptions(""Choose an option:"", new Options() { @Override public void create() { option(""No, still doesn't ring a bell"", new Dialogue() .addPlayer(HeadE.CALM_TALK, ""No, your name still doesn't ring a bell"") .addNPC(LADY_KELI, HeadE.ANGRY, ""Well, you know of me now"") .addNPC(LADY_KELI, HeadE.FRUSTRATED, ""I will ring your bell if you do not show respect"") .addOptions(""Choose an option:"", new Options() { @Override public void create() { option(""I do not show respect to killers and hoodlums"", new Dialogue() .addPlayer(HeadE.FRUSTRATED, ""I do not show respect to killers and hoodlums"") .addNPC(LADY_KELI, HeadE.FRUSTRATED, ""You should, you really should"") .addNPC(LADY_KELI, HeadE.SECRETIVE, ""I am wealthy enough to place a bounty on your head"") .addNPC(LADY_KELI, HeadE.ANGRY, ""Or just remove your head myself"") .addNPC(LADY_KELI, HeadE.VERY_FRUSTRATED, ""Now go, I am busy, too busy to fight a would-be hoodlum"")); option(""You must have trained a lot for this work"", new Dialogue() .addPlayer(HeadE.AMAZED_MILD, ""You must have trained a lot for this work"") .addNPC(LADY_KELI, HeadE.TALKING_ALOT, ""I have used a sword since I was a small girl"") .addNPC(LADY_KELI, HeadE.EVIL_LAUGH, ""stabbed three people before I was 6 years old"")); option(""I should not disturb someone as tough as you, great lady"", new Dialogue() .addPlayer(HeadE.SCARED, ""I should not disturb someone as tough as you"") .addNPC(LADY_KELI, HeadE.CALM_TALK, ""I need to do a lot of work, goodbye"") .addNPC(LADY_KELI, HeadE.CALM_TALK, ""When you get a little tougher, maybe I will give you a job"")); } })); option(""Yes, of course I have heard of you"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Heard of you? You are famous in Gielinor!"") .addNPC(LADY_KELI, HeadE.HAPPY_TALKING, ""That's very kind of you to say. Reputations are not easily earned. I have managed to succeed"" + "" where many fail."") .addNext(()-> player.startConversation(new LadyKeliPrinceAliRescueD(player, ORIGINAL_OPTIONS, false)))); option(""You must have trained a lot for this work"", new Dialogue() .addPlayer(HeadE.AMAZED_MILD, ""You must have trained a lot for this work"") .addNPC(LADY_KELI, HeadE.TALKING_ALOT, ""I have used a sword since I was a small girl"") .addNPC(LADY_KELI, HeadE.EVIL_LAUGH, ""stabbed three people before I was 6 years old"")); option(""I should not disturb someone as tough as you"", new Dialogue() .addPlayer(HeadE.SCARED, ""I should not disturb someone as tough as you"") .addNPC(LADY_KELI, HeadE.CALM_TALK, ""I need to do a lot of work, goodbye"") .addNPC(LADY_KELI, HeadE.CALM_TALK, ""When you get a little tougher, maybe I will give you a job"")); } })); if(!isFirst) option(""I should not disturb someone as tough as you"", new Dialogue() .addPlayer(HeadE.SCARED, ""I should not disturb someone as tough as you"") .addNPC(LADY_KELI, HeadE.CALM_TALK, ""I need to do a lot of work, goodbye"") .addNPC(LADY_KELI, HeadE.CALM_TALK, ""When you get a little tougher, maybe I will give you a job"")); } }); } private void latestPlanOptions(boolean isFirst) { addOptions(""Choose an option:"", new Options() { @Override public void create() { if(isFirst) option(""Ah, I see. You must have been very skillful"", new Dialogue() .addPlayer(HeadE.AMAZED, ""You must have been very skilful"") .addNPC(LADY_KELI, HeadE.HAPPY_TALKING, ""Yes, I did most of the work, we had to grab the Pr..."") .addNPC(LADY_KELI, HeadE.SKEPTICAL_THINKING, ""er, we had to grab him under cover of ten of his bodyguards"") .addNPC(LADY_KELI, HeadE.SECRETIVE, ""It was a stroke of genius"") .addNext(()-> player.startConversation(new LadyKeliPrinceAliRescueD(player, LATEST_PLAN_OPTIONS, false)))); option(""Thats great, are you sure they will pay?"", new Dialogue() .addPlayer(HeadE.CALM_TALK, ""Are you sure they will pay?"") .addNPC(LADY_KELI, HeadE.EVIL_LAUGH, ""They will pay, or we will cut his hair off and send it to them"") .addPlayer(HeadE.HAPPY_TALKING, ""Don't you think that something tougher, maybe cut his finger off would work better?"") .addNPC(LADY_KELI, HeadE.HAPPY_TALKING, ""Thats a good idea. I could use talented people like you"") .addNPC(LADY_KELI, HeadE.SKEPTICAL_THINKING, ""I may call on you if I need work doing"")); option(""Can you be sure they will not try to get him out?"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Can you be sure they will not try to get him out?"") .addNPC(LADY_KELI, HeadE.CALM_TALK, ""There is no way to release him. The only key to the door is on a chain around my neck"") .addNPC(LADY_KELI, HeadE.CALM_TALK, ""And the locksmith who made the lock, died suddenly when he had finished"") .addNPC(LADY_KELI, HeadE.HAPPY_TALKING, ""There is not another key like this in the world"") .addOptions(""Choose an option:"", new Options() { @Override public void create() { option(""Could I see the key please"", new Dialogue() .addPlayer(HeadE.CALM_TALK, ""Could I see the key please, just for a moment"") .addPlayer(HeadE.CALM_TALK, ""It would be something I can tell my grandchildren"") .addPlayer(HeadE.CALM_TALK, ""When you are even more famous than you are now"") .addNPC(LADY_KELI, HeadE.HAPPY_TALKING, ""When you put it that way, I am sure you can see it"") .addNPC(LADY_KELI, HeadE.HAPPY_TALKING, ""You cannot steal the key, it is on an Adamantite chain"") .addNPC(LADY_KELI, HeadE.HAPPY_TALKING, ""I cannot see the harm"") .addSimple(""Keli shows you a small key on a stronglooking chain"") .addOptions(""Choose an option:"", new Options() { @Override public void create() { option(""Could I touch the key for a moment please"", new Dialogue() .addPlayer(HeadE.CALM_TALK, ""Could I touch the key for a moment please"") .addNPC(LADY_KELI, HeadE.CALM_TALK, ""Only for a moment then"") .addNext(() -> player.startConversation(new Conversation(player) { { if(player.getInventory().containsItem(PrinceAliRescue.SOFT_CLAY, 1)) { addSimple(""(You put a piece of your soft clay in your hand)""); addSimple(""(As you touch the key, you take an imprint of it)"", () -> { player.getInventory().deleteItem(PrinceAliRescue.SOFT_CLAY, 1); player.getInventory().addItem(PrinceAliRescue.KEY_PRINT, 1); }); } else addSimple(""You look at the key and give it back""); addPlayer(HeadE.HAPPY_TALKING, ""Thank you so much, you are too kind, o great Keli""); addNPC(LADY_KELI, HeadE.HAPPY_TALKING, ""There, run along now, I am very busy""); create(); } }))); option(""I should not disturb someone as tough as you"", new Dialogue() .addPlayer(HeadE.SCARED, ""I should not disturb someone as tough as you"") .addNPC(LADY_KELI, HeadE.CALM_TALK, ""I need to do a lot of work, goodbye"") .addNPC(LADY_KELI, HeadE.CALM_TALK, ""When you get a little tougher, maybe I will give you a job"")); } })); option(""That is a good way to keep secrets"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""That is a good way to keep secrets"") .addNPC(LADY_KELI, HeadE.SKEPTICAL_HEAD_SHAKE, ""It is the best way I know"") .addNPC(LADY_KELI, HeadE.SECRETIVE, ""Dead men tell no tales"")); option(""I should not disturb someone as tough as you"", new Dialogue() .addPlayer(HeadE.SCARED, ""I should not disturb someone as tough as you"") .addNPC(LADY_KELI, HeadE.CALM_TALK, ""I need to do a lot of work, goodbye"") .addNPC(LADY_KELI, HeadE.CALM_TALK, ""When you get a little tougher, maybe I will give you a job"")); } })); option(""I should not disturb someone as tough as you"", new Dialogue() .addPlayer(HeadE.SCARED, ""I should not disturb someone as tough as you"") .addNPC(LADY_KELI, HeadE.CALM_TALK, ""I need to do a lot of work, goodbye"") .addNPC(LADY_KELI, HeadE.CALM_TALK, ""When you get a little tougher, maybe I will give you a job"")); } }); } public static NPCClickHandler handleLadyKeli = new NPCClickHandler(new Object[] { LADY_KELI }, e -> e.getPlayer().startConversation(new LadyKeliPrinceAliRescueD(e.getPlayer()).getStart())); }" "package com.rs.game.content.quests.princealirescue; @PluginEventHandler public class LeelaPrinceAliRescueD extends Conversation { public final static int LEELA = 915; public LeelaPrinceAliRescueD(Player player) { super(player); if(player.getQuestManager().getStage(Quest.PRINCE_ALI_RESCUE) <= PrinceAliRescue.STARTED) { addPlayer(HeadE.HAPPY_TALKING, ""What are you waiting here for?""); addNPC(LEELA, HeadE.FRUSTRATED, ""That is no concern of yours, adventurer.""); } if(player.getQuestManager().getStage(Quest.PRINCE_ALI_RESCUE) == PrinceAliRescue.GEAR_CHECK) //bronze key complete if(player.getQuestManager().getAttribs(Quest.PRINCE_ALI_RESCUE).getB(""Leela_has_key"") && !player.getInventory().containsItem(PrinceAliRescue.BRONZE_KEY, 1)) { if(player.getQuestManager().getAttribs(Quest.PRINCE_ALI_RESCUE).getB(""Leela_gave_key"")) { addNPC(LEELA, HeadE.CALM_TALK, ""You lost the key?""); addNPC(LEELA, HeadE.CALM_TALK, ""I am going to need 15 coins from you to pay for the bronze.""); if(player.getInventory().hasCoins(15)) addSimple(""Leela gives you a copy of the key to the prince's door."", () -> { player.getInventory().removeCoins(15); player.getInventory().addItem(PrinceAliRescue.BRONZE_KEY, 1); }); else { addNPC(LEELA, HeadE.CALM_TALK, ""Do you have that?""); addPlayer(HeadE.SAD, ""No...""); } } else { addNPC(LEELA, HeadE.CALM_TALK, ""My father sent this key for you. Be careful not to lose it.""); addSimple(""Leela gives you a copy of the key to the prince's door."", () -> { player.getInventory().addItem(PrinceAliRescue.BRONZE_KEY, 1); player.getQuestManager().getAttribs(Quest.PRINCE_ALI_RESCUE).setB(""Leela_gave_key"", true); }); addNPC(LEELA, HeadE.CALM_TALK, ""Don't forget to deal with the guard on the door. He is talkative, try to find a weakness in him.""); } } else if(player.getInventory().containsItem(PrinceAliRescue.KEY_PRINT, 1)) { addNPC(LEELA, HeadE.CALM_TALK, ""You can give the key print and a bronze bar to Osman in Al-kharid.""); addNPC(LEELA, HeadE.CALM_TALK, ""Then come back to me to get the key""); } else if(player.getInventory().containsItem(BEER, 3) && player.getInventory().containsItem(BRONZE_KEY, 1) && player.getInventory().containsItem(PASTE, 1) && player.getInventory().containsItem(BLONDE_WIG, 1) && player.getInventory().containsItem(PINK_SKIRT, 1) && player.getInventory().containsItem(ROPE, 1)) { addNPC(LEELA, HeadE.HAPPY_TALKING, ""You have everything you need to start the breakout.""); addNPC(LEELA, HeadE.HAPPY_TALKING, ""Don't forget the plan""); addNPC(LEELA, HeadE.SECRETIVE, ""Get Joe the guard drunk with 3 beers, tie Lady Keli up with a rope, open the prison with the jail key"" + "", put the disguise on Prince Ali and escape.""); addNPC(LEELA, HeadE.HAPPY_TALKING, ""Got it?""); addPlayer(HeadE.HAPPY_TALKING, ""Got it.""); } else { addPlayer(HeadE.HAPPY_TALKING, ""I am here to help you free the prince.""); addNPC(LEELA, HeadE.CALM_TALK, ""Your employment is known to me. Now, do you know all that we need to make the break?""); addOptions(""Choose an option:"", new Options() { @Override public void create() { option(""I must make a disguise. What do you suggest?"", new Dialogue() .addNPC(LEELA, HeadE.CALM_TALK, ""Only the lady Keli, can wander about outside the jail. The guards will shoot to kill if "" + ""they see the prince out so we need a disguise good enough to fool them at a distance."") .addNPC(LEELA, HeadE.CALM_TALK, ""You need a wig, maybe made from wool. If you find someone who can work with wool ask "" + ""them about it. There's a witch nearby may be able to help you dye it."") .addNPC(LEELA, HeadE.CALM_TALK, ""We will need a skirt like hers, a pink one should be fine."") .addNPC(LEELA, HeadE.CALM_TALK, ""We still need something to colour the Prince's skin lighter. There's a witch close to here. "" + ""She knows about many things. She may know some way to make the skin lighter."") .addNPC(LEELA, HeadE.CALM_TALK, ""You have rope I see, to tie up Keli. That will be the most dangerous part of the plan."")); option(""I need to get the key made."", new Dialogue() .addNPC(LEELA, HeadE.CALM_TALK, ""Yes, that is most important. There is no way you can get the real key. It is on a chain around "" + ""Keli's neck. Almost impossible to steal."") .addNPC(LEELA, HeadE.CALM_TALK, ""Get some soft clay and get her to show you the key somehow. Then take the print, with bronze, to my father."")); option(""What can I do with the guards?"", new Dialogue() .addNPC(LEELA, HeadE.CALM_TALK, ""Most of the guards will be easy. The disguise will get past them. The only guard who will be "" + ""a problem will be the one at the door."") .addNPC(LEELA, HeadE.CALM_TALK, ""We can discuss this more when you have the rest of the escape kit."")); option(""I will go and get the rest of the escape equipment."", new Dialogue() .addNPC(LEELA, HeadE.CALM_TALK, ""Good, I shall await your return with everything."")); } }); } if(player.isQuestComplete(Quest.PRINCE_ALI_RESCUE)) addNPC(LEELA, HeadE.HAPPY_TALKING, ""Thank you, Al-Kharid will forever owe you for your help. I think that if there is ever anything that "" + ""needs to be done, you will be someone they can rely on.""); } public static NPCClickHandler handleLeela = new NPCClickHandler(new Object[] { LEELA }, e -> e.getPlayer().startConversation(new LeelaPrinceAliRescueD(e.getPlayer()).getStart())); }" "package com.rs.game.content.quests.princealirescue; @PluginEventHandler public class OsmanPrinceAliRescueD extends Conversation { public final static int OSMAN = 5282; final int FIRSTTHING = 0; final int SECONDTHING = 1; public OsmanPrinceAliRescueD(Player player) { super(player); if(player.getQuestManager().getStage(Quest.PRINCE_ALI_RESCUE) == PrinceAliRescue.NOT_STARTED) addNPC(OSMAN, HeadE.HAPPY_TALKING, ""I have no reason to trust you regarding these affairs.""); if(player.getQuestManager().getStage(Quest.PRINCE_ALI_RESCUE) == PrinceAliRescue.STARTED) { addPlayer(HeadE.HAPPY_TALKING, ""The chancellor trusts me. I have come for instructions.""); addNPC(OSMAN, HeadE.TALKING_ALOT, ""Our prince is captive by the Lady Keli. We just need to make the rescue. There are two things we need you to do.""); addOptions(""Choose an option:"", new Options() { @Override public void create() { option(""What is the first thing I must do?"", new Dialogue() .addNext(()-> player.startConversation(new OsmanPrinceAliRescueD(player, FIRSTTHING)))); option(""What is the second thing you need?"", new Dialogue() .addNext(()-> player.startConversation(new OsmanPrinceAliRescueD(player, SECONDTHING)))); } }); } if(player.getQuestManager().getStage(Quest.PRINCE_ALI_RESCUE) == PrinceAliRescue.GEAR_CHECK) if(player.getInventory().containsItem(PrinceAliRescue.KEY_PRINT, 1) && player.getInventory().containsItem(PrinceAliRescue.BRONZE_BAR, 1) ) { addNPC(OSMAN, HeadE.HAPPY_TALKING, ""Well done, we can make the key now.""); addSimple(""Osman takes the key imprint and the bronze bar."", () -> { player.getInventory().deleteItem(PrinceAliRescue.KEY_PRINT, 1); player.getInventory().deleteItem(PrinceAliRescue.BRONZE_BAR, 1); player.getQuestManager().getAttribs(Quest.PRINCE_ALI_RESCUE).setB(""Leela_has_key"", true); }); addNPC(OSMAN, HeadE.HAPPY_TALKING, ""Pick the key up from Leela.""); addPlayer(HeadE.HAPPY_TALKING, ""Thank you. I will try to find the other items.""); } else { addPlayer(HeadE.TALKING_ALOT, ""Can you tell me what I still need to get?""); if (player.getQuestManager().getAttribs(Quest.PRINCE_ALI_RESCUE).getB(""Leela_has_key"")) addNPC(OSMAN, HeadE.CALM_TALK, ""Make sure to have the bronze key from Leela.""); else addNPC(OSMAN, HeadE.CALM_TALK, ""A print of the key in soft clay and a bronze bar. Then, collect the key from Leela.""); addNPC(OSMAN, HeadE.CALM_TALK, ""You need to make a blonde wig somehow. Leela may help.""); addNPC(OSMAN, HeadE.CALM_TALK, ""You will need a skirt that looks the same as Keli's""); addNPC(OSMAN, HeadE.CALM_TALK, ""Something to make the prince's skin appear lighter.""); addNPC(OSMAN, HeadE.CALM_TALK, ""A rope with which to tie Keli up.""); addNPC(OSMAN, HeadE.CALM_TALK, ""Once you have everything, go to Leela. She must be ready to get the prince away.""); } if(player.isQuestComplete(Quest.PRINCE_ALI_RESCUE)) addNPC(OSMAN, HeadE.HAPPY_TALKING, ""Well done. A great rescue. I will remember you if I have anything dangerous to do.""); create(); } public OsmanPrinceAliRescueD(Player player, int convoID) { super(player); switch(convoID) { case FIRSTTHING: firsthing(); break; case SECONDTHING: secondthing(); break; } } private void firsthing() { addPlayer(HeadE.SKEPTICAL_THINKING, ""What is the first thing I must do?""); addNPC(OSMAN, HeadE.CALM_TALK, ""The prince is guarded by some stupid guards and a clever woman. The woman is our only way "" + ""to get the prince out. Only she can walk freely about the area.""); addNPC(OSMAN, HeadE.CALM_TALK, ""I think you will need to tie her up. One coil of rope should do for that. Then, disguise the "" + ""prince as her to get him out without suspicion.""); addPlayer(HeadE.SKEPTICAL_THINKING, ""How good must the disguise be?""); addNPC(OSMAN, HeadE.CALM_TALK, ""Only enough to fool the guards at a distance. Get a skirt like hers. Same colour, same style."" + "" We will only have a short time.""); addNPC(OSMAN, HeadE.CALM_TALK, ""Get a blonde wig, too. That is up to you to make or find. Something to colour the skin of the prince.""); addNPC(OSMAN, HeadE.CALM_TALK, ""My daughter and top spy, Leela, can help you. She has sent word that she has discovered where they are keeping the prince.""); addNPC(OSMAN, HeadE.CALM_TALK, ""It's near Draynor Village. She is lurking somewhere near there now.""); addOptions(""Choose an option:"", new Options() { @Override public void create() { option(""Explain the first thing again."", new Dialogue() .addNext(()-> player.startConversation(new OsmanPrinceAliRescueD(player, FIRSTTHING)))); option(""What is the second thing you need?"", new Dialogue() .addNext(()-> player.startConversation(new OsmanPrinceAliRescueD(player, SECONDTHING)))); option(""Okay, I better go find some things."", new Dialogue() .addNPC(OSMAN, HeadE.TALKING_ALOT, ""May good luck travel with you. Don't forget to find Leela. It can't be done without her help."")); } }); create(); } private void secondthing() { addNPC(OSMAN, HeadE.TALKING_ALOT, ""We need the key, or we need a copy made. If you can get some soft clay then you can copy the key...""); addNPC(OSMAN, HeadE.TALKING_ALOT, ""...If you can convince Lady Keli to show it to you for a moment. She is very boastful. It should not be too hard.""); addNPC(OSMAN, HeadE.TALKING_ALOT, ""Bring the imprint to me, with a bar of bronze."", () -> player.getQuestManager().setStage(Quest.PRINCE_ALI_RESCUE, PrinceAliRescue.GEAR_CHECK)); addPlayer(HeadE.HAPPY_TALKING, ""Sounds like a mouthful, okay ill get on it!""); create(); } }" "package com.rs.game.content.quests.princealirescue; @PluginEventHandler public class PrinceAliPrinceAliRescueD extends Conversation { public final static int PRINCE_ALI = 920; public final static int PRINCE_ALI2 = 921; //items public final static int PINK_SKIRT = 1013; public final static int BLONDE_WIG = 2419; public final static int PASTE = 2424; public PrinceAliPrinceAliRescueD(Player player) { super(player); if(player.isQuestComplete(Quest.PRINCE_ALI_RESCUE)) addNPC(PRINCE_ALI, HeadE.CALM_TALK, ""I owe you my life for that escape. You cannot help me this time, they know who you are. Go in peace, "" + ""friend of Al-Kharid.""); else if(player.getInventory().containsItem(PASTE, 1) && player.getInventory().containsItem(BLONDE_WIG, 1) && player.getInventory().containsItem(PINK_SKIRT, 1)){ addPlayer(HeadE.SECRETIVE, ""Prince, I come to rescue you.""); addNPC(PRINCE_ALI, HeadE.HAPPY_TALKING, ""That is very very kind of you, how do I get out?""); addPlayer(HeadE.SECRETIVE, ""With a disguise. I have removed the Lady Keli. She is tied up, but will not stay tied up for long.""); addPlayer(HeadE.SECRETIVE, ""Take this disguise, and this key.""); addSimple(""You hand over the disguise and key over to Prince Ali."", ()-> { player.getInventory().removeItems(new Item(PASTE, 1), new Item(PINK_SKIRT, 1), new Item(BLONDE_WIG, 1)); //TODO update this to new logic what on earth even // for(NPC npc : World.getNPCsInRegion(JAIL_REGION_ID)) // if(npc.getId() == PRINCE_ALI) // WorldTasks.schedule(new WorldTask() {//deletes all ali2s when region is loaded. // int tick; // NPC ali2; // @Override // public void run() { // if(tick == 0) { // npc.setRespawnTask(50); // Tile tile = npc.getTile(); // npc.finish(); // ali2 = World.spawnNPC(PRINCE_ALI2, tile, -1, false, true); // } // if(tick == 10) { // ali2.finish(); // for(NPC npc : World.getNPCsInRegion(JAIL_REGION_ID)) // if(npc.getId() == PRINCE_ALI2) // npc.finish(); // } // if(tick == 11) // stop(); // // if(World.isRegionLoaded(JAIL_REGION_ID)) // tick++; // } // }, 0, 1); }); addNPC(PRINCE_ALI2, HeadE.HAPPY_TALKING, ""Thank you my friend, I must leave you now. My father will pay you well for this.""); addSimple(""The prince has escaped, well done! You are now a friend of Al-Kharid and may pass through the Al-Kharid toll gate for free."", ()-> player.getQuestManager().completeQuest(Quest.PRINCE_ALI_RESCUE)); } else { addNPC(PRINCE_ALI, HeadE.CALM_TALK, ""Hello.""); addPlayer(HeadE.SAD, ""Darn I don't have all I need for the disguise""); } } public static NPCClickHandler handlePrinceAli = new NPCClickHandler(new Object[] { PRINCE_ALI }, e -> e.getPlayer().startConversation(new PrinceAliPrinceAliRescueD(e.getPlayer()).getStart())); }" "package com.rs.game.content.quests.princealirescue; @QuestHandler( quest = Quest.PRINCE_ALI_RESCUE, startText = ""Speak to Hassan in the palace at Al Kharid."", itemsText = ""Soft clay
3 balls of wool
Yellow dye or 2 onions and 5 coins
Redberries
Ashes
Bucket of water or jug of water (obtainable during quest)
Pot of flour
Bronze bar
Pink skirt
3 beers
Rope (can be bought during the quest at Ned for 18 coins or 4 balls of wool)
At least 100 coins"", combatText = ""The ability to get past aggressive combat level 26 jail guards."", rewardsText = ""700 coins
Free passage through the Lumbridge -> Al Kharid toll gate from now on
(Members) Access to the Sorceress's Garden Thieving minigame."", completedStage = 5 ) @PluginEventHandler public class PrinceAliRescue extends QuestOutline { //Quest Stages public final static int NOT_STARTED = 0; public final static int STARTED = 1; public final static int GEAR_CHECK = 2; //items public final static int BEER = 1917; public final static int PINK_SKIRT = 1013; //key stuff public final static int SOFT_CLAY = 1761; public final static int BRONZE_KEY = 2418; public final static int KEY_PRINT = 2423; public final static int BRONZE_BAR = 2349; //wig items public final static int BALL_WOOL = 1759; public final static int WIG = 2421; public final static int BLONDE_WIG = 2419; public final static int YELLOW_DYE = 1765; //Paste items public final static int ASHES = 592; public final static int REDBERRY = 1951; public final static int POT_OF_FLOUR = 1933; public final static int WATER_BUCKET = 1929; public final static int PASTE = 2424; public final static int ROPE = 954; //NPCS public final static int NED = 918; public final static int AGGIE = 922; public final static int HASSAN = 923; public final static int OSMAN = 5282; public final static int LEELA = 915; public final static int LADY_KELI = 919; public final static int JOE = 916; public final static int PRINCE_ALI1 = 920; public final static int PRINCE_ALI2 = 921; //Places public final static int JAIL_REGION_ID = 12338; //Update to new logic @Override public List getJournalLines(Player player, int stage) { ArrayList lines = new ArrayList<>(); switch(stage) { case NOT_STARTED: lines.add(""Prince Ali of Al Kharid has been kidnapped by ""); lines.add(""the scheming Lady Keli. You are hired to stage a rescue mission.""); lines.add(""""); lines.add(""Speak to Chancellor Hassan at the Al-Kharid palace to start""); lines.add(""your mission.""); lines.add(""""); break; case STARTED: lines.add(""The mission has started, I must speak to Osman outside the palace""); lines.add(""to the northwest by the Alkharid Scimitar shop.""); lines.add(""""); break; case GEAR_CHECK: lines.add(""Prince Ali has been taken for randsom! To break""); lines.add(""him out of his prison we are going to need to""); lines.add(""infiltrate the jail and get him out...""); lines.add(""""); lines.add(""For this we will need a skin paste, a yellow wig, some beer,""); lines.add(""the jail cell key and a pink skirt.""); lines.add(""""); lines.add(""For the skin paste I can talk to Aggie the witch in ""); lines.add(""Draynor.""); lines.add(""""); lines.add(""For the yellow wig I can talk to Ned in Draynor.""); lines.add(""""); lines.add(""I remember a pink skirt being sold in Varrock's""); lines.add(""clothing store""); lines.add(""""); lines.add(""For the jail key I will have to be really sneaky and""); lines.add(""get a key print from Lady Keli. Afterward I can get a""); lines.add(""bronze bar turned into a key by talking to Osman""); lines.add(""in Alkharid then pick up the key delivery from Leela.""); lines.add(""""); lines.add(""Before I start the breakout I will need the following items:""); lines.add((player.getInventory().containsItem(BEER, 3) ? """":"""")+""3 beer""); lines.add((player.getInventory().containsItem(ROPE, 1) ? """":"""")+""Rope""); lines.add((player.getInventory().containsItem(BRONZE_KEY, 1) ? """":"""")+""A jail key""); lines.add((player.getInventory().containsItem(BLONDE_WIG, 1) ? """":"""")+""A yellow wig""); lines.add((player.getInventory().containsItem(PASTE, 1) ? """":"""")+""Skin paste""); lines.add((player.getInventory().containsItem(PINK_SKIRT, 1) ? """":"""")+""A pink skirt""); lines.add(""""); lines.add(""Once I gathered all these supplies I should talk to Leela.""); lines.add(""""); break; case 4: lines.add(""""); lines.add(""""); break; case 5: lines.add(""""); lines.add(""""); lines.add(""QUEST COMPLETE!""); break; default: lines.add(""Invalid quest stage. Report this to an administrator.""); break; } return lines; } public static boolean hasAllBreakOutItems(Player p) { return (p.getInventory().containsItem(BEER, 3) && p.getInventory().containsItem(BRONZE_KEY, 1) && p.getInventory().containsItem(PASTE, 1) && p.getInventory().containsItem(BLONDE_WIG, 1) && p.getInventory().containsItem(PINK_SKIRT, 1) && p.getInventory().containsItem(ROPE, 1)); } public static ObjectClickHandler handleJailCellDoor = new ObjectClickHandler(new Object[] { 3436 }, e -> { if(e.getObject().getTile().matches(Tile.of(3128, 3243, 0))) { if (e.getPlayer().getInventory().containsItem(BRONZE_KEY, 1)) handleDoor(e.getPlayer(), e.getObject()); else e.getPlayer().startConversation(new Conversation(e.getPlayer()) { { addPlayer(HeadE.CALM_TALK, ""It appears to need a key...""); } }); return; } if(e.getPlayer().getInventory().containsItem(BRONZE_KEY, 1)) { for(NPC npc : World.getNPCsInChunkRange(e.getPlayer().getChunkId(), 2)) if(npc.getId() == LADY_KELI) { e.getPlayer().sendMessage(""You'd better get rid of Lady Keli before trying to go through there.""); return; } handleDoor(e.getPlayer(), e.getObject()); } else e.getPlayer().startConversation(new Conversation(e.getPlayer()) { { addPlayer(HeadE.CALM_TALK, ""It appears to need a key...""); } }); }); public static ItemOnItemHandler handleRedYellowDyes = new ItemOnItemHandler(YELLOW_DYE, new int[] {WIG}, e -> { if(e.usedWith(WIG, YELLOW_DYE)) { e.getPlayer().getInventory().replace(e.getItem2(), new Item(BLONDE_WIG, 1)); e.getPlayer().getInventory().deleteItem(e.getItem1().getSlot(), e.getItem1()); } }); public static ItemOnNPCHandler handleLadyKeliRope = new ItemOnNPCHandler(LADY_KELI, e -> { if(e.getItem().getId() != ROPE || e.getPlayer().isQuestComplete(Quest.PRINCE_ALI_RESCUE)) return; Player p = e.getPlayer(); if(p.getQuestManager().getAttribs(Quest.PRINCE_ALI_RESCUE).getB(""Joe_guard_is_drunk"") && p.getInventory().containsItem(BRONZE_KEY, 1) && p.getInventory().containsItem(PASTE, 1) && p.getInventory().containsItem(BLONDE_WIG, 1) && p.getInventory().containsItem(PINK_SKIRT, 1) && p.getInventory().containsItem(ROPE, 1)) { p.getInventory().removeItems(new Item(ROPE, 1)); e.getNPC().setRespawnTask(90); e.getNPC().finish(); } else p.startConversation(new Conversation(p) { { addSimple(""You cannot tie Keli up until you have all equipment and disabled the guard!""); create(); } }); }); @Override public void complete(Player player) { player.getInventory().addCoins(700); sendQuestCompleteInterface(player, 6964); } }" "package com.rs.game.content.quests.restlessghost; @QuestHandler( quest = Quest.RESTLESS_GHOST, startText = ""Speak to Father Aereck in the Lumbridge Church, east of Lumbridge Castle."", itemsText = ""Armour to survive a level 7 skeleton warlock attack."", combatText = ""Facing a level 7 skeleton warlock."", rewardsText = ""125 Prayer XP
Five ancient bones that each give 200 Prayer XP"", completedStage = 4 ) @PluginEventHandler public class RestlessGhost extends QuestOutline { public static int SKULL_CONF = 2130; @Override public List getJournalLines(Player player, int stage) { ArrayList lines = new ArrayList<>(); switch(stage) { case 0: lines.add(""I can start this quest by speaking to Father Aereck""); lines.add(""in the lumbridge chapel.""); break; case 1: lines.add(""Aereck told me there is a ghost haunting his graveyard.""); lines.add(""He told me I should speak with Father Urhney about what""); lines.add(""to do next.""); lines.add(""""); lines.add(""I was told he can be found in southern Lumbridge swamp.""); break; case 2: lines.add(""I was given an amulet of ghostspeak by Father Urhney.""); lines.add(""The amulet should let me communicate with the ghost somehow.""); lines.add(""""); lines.add(""I should find the ghost and try to figure out what is""); lines.add(""causing it to haunt the church graveyard.""); break; case 3: lines.add(""I found the ghost and he told me that he has lost his skull.""); lines.add(""""); lines.add(""He said he lost it somewhere near the swamp mines.""); break; case 4: lines.add(""""); lines.add(""""); lines.add(""QUEST COMPLETE!""); break; default: lines.add(""Invalid quest stage. Report this to an administrator.""); break; } return lines; } @Override public void complete(Player player) { player.getSkills().addXpQuest(Constants.PRAYER, 1125); sendQuestCompleteInterface(player, 553); } private static boolean hasSkull(Player player) { if (player.getInventory().containsItem(553, 1) || player.isQuestComplete(Quest.RESTLESS_GHOST)) return true; return false; } private static void refreshSkull(Player player) { player.getVars().setVarBit(SKULL_CONF, hasSkull(player) ? 1 : 0); } public static LoginHandler onLogin = new LoginHandler(e -> refreshSkull(e.getPlayer())); public static ObjectClickHandler handleSkullRock = new ObjectClickHandler(new Object[] { 47713 }, e -> { if (e.getPlayer().getQuestManager().getStage(Quest.RESTLESS_GHOST) == 3) { e.getPlayer().sendMessage(""You take the skull.""); e.getPlayer().getInventory().addItem(553, 1); refreshSkull(e.getPlayer()); } }); public static ObjectClickHandler handleCoffin = new ObjectClickHandler(new Object[] { 2145 }, e -> { if (e.getPlayer().getQuestManager().getStage(Quest.RESTLESS_GHOST) == 2) { e.getPlayer().getQuestManager().setStage(Quest.RESTLESS_GHOST, 3); e.getPlayer().sendMessage(""A ghost appears nearby!""); } }); public static NPCClickHandler talkToNpcs = new NPCClickHandler(new Object[] { 457 }, e -> { if (e.getPlayer().getQuestManager().getStage(Quest.RESTLESS_GHOST) == 3) e.getPlayer().startConversation(new RGhostD(e.getPlayer())); }); }" "package com.rs.game.content.quests.restlessghost; @PluginEventHandler public class RGhost extends NPC { public RGhost(int id, Tile tile) { super(id, tile); } @Override public boolean withinDistance(Player tile, int distance) { return tile.getQuestManager().getStage(Quest.RESTLESS_GHOST) == 3 && super.withinDistance(tile, distance); } public static NPCInstanceHandler toFunc = new NPCInstanceHandler(457, RGhost::new); }" "package com.rs.game.content.quests.restlessghost; public class RGhostD extends Conversation { public RGhostD(Player player) { super(player); int NPC = 457; if(player.getEquipment().getAmuletId() == 552) { addNPC(NPC, HeadE.CALM_TALK, ""Hello mortal.""); if(player.getInventory().containsItem(553, 1)) { addPlayer(HeadE.HAPPY_TALKING, ""I found this skull outside.""); addNPC(NPC, HeadE.CALM_TALK, ""That's it! That's my head! Thank you adventurer.
Finally I can be at peace.""); addPlayer(HeadE.HAPPY_TALKING, ""You're very welcome. Farewell.""); player.getInventory().deleteItem(553, 1); player.getQuestManager().completeQuest(Quest.RESTLESS_GHOST); return; } addPlayer(HeadE.HAPPY_TALKING, ""Hello.""); addNPC(NPC, HeadE.CALM_TALK, ""I seem to have lost my skull. Could you go
find it for me please? I want to be released.
Last I saw it was a bit south of here by the mining site.""); addPlayer(HeadE.HAPPY_TALKING, ""I think I can handle that that.""); return; } addNPC(NPC, HeadE.CALM_TALK, ""Woooo woooo wooo woo!""); create(); } }" "package com.rs.game.content.quests.scorpioncatcher; @PluginEventHandler public class KhazScorp extends NPC { public KhazScorp(int id, Tile tile) { super(id, tile); } @Override public boolean withinDistance(Player p, int distance) { boolean known = switch(getId()) { case ScorpionCatcher.SCORP_1 -> p.getQuestManager().getAttribs(Quest.SCORPION_CATCHER).getB(""scorp1LocKnown""); case ScorpionCatcher.SCORP_2 -> p.getQuestManager().getAttribs(Quest.SCORPION_CATCHER).getB(""scorp2LocKnown""); case ScorpionCatcher.SCORP_3 -> p.getQuestManager().getAttribs(Quest.SCORPION_CATCHER).getB(""scorp3LocKnown""); default -> true; }; return p.getQuestManager().getStage(Quest.SCORPION_CATCHER) == ScorpionCatcher.LOOK_FOR_SCORPIONS && known && !ScorpionCatcher.caughtScorp(p, getId()) && super.withinDistance(p, distance) ; } public static NPCInstanceHandler toFunc = new NPCInstanceHandler(new Object[] { ScorpionCatcher.SCORP_1, ScorpionCatcher.SCORP_2, ScorpionCatcher.SCORP_3 }, KhazScorp::new); }" "package com.rs.game.content.quests.scorpioncatcher; /** * How this is written: Each seer prophecy/premonition allows you to spawn a * scorp in a chunk If you lose the cage you keep the seer prophecy. You can * talk to any Seer in Seer's village to get a prophecy. */ @QuestHandler( quest = Quest.SCORPION_CATCHER, startText = ""Talk to Thormac on the top floor of the Sorcerer's Tower south of Seers' Village, near the Ranging Guild."", itemsText = ""Dusty key (or 70 Agility)."", combatText = ""You will need to defeat a level 39 jailer."", rewardsText = ""6,625 Strength XP
Thormac will upgrade elemental battlestaves to mystic battlestaves for 40,000 coins"", completedStage = 2 ) @PluginEventHandler public class ScorpionCatcher extends QuestOutline { public final static int NOT_STARTED = 0; public final static int LOOK_FOR_SCORPIONS = 1; public final static int QUEST_COMPLETE = 2; public static final int SCORP_1 = 385; public static final int SCORP_2 = 386; public static final int SCORP_3 = 387; public final static int EMPTY_CAGE = 456; public final static int CAUGHT_CAGE_1 = 457; public final static int CAUGHT_CAGE_2 = 458; public final static int CAUGHT_CAGE_3 = 459; @Override public List getJournalLines(Player player, int stage) { ArrayList lines = new ArrayList<>(); switch (stage) { case NOT_STARTED -> { lines.add(""Thormac The Sorcerer has a hobby involving scorpions.""); lines.add(""Unfortunately, three of them have escaped and managed to run""); lines.add(""far away. If you manage to find them all, he may just be able""); lines.add(""to perform an important service for you.""); lines.add(""""); lines.add(""I can start this quest by speaking to Thormac The Sorcerer at the""); lines.add(""top of his tower southwest of Seer's Village""); lines.add(""""); lines.add(""~~~Requirements~~~""); lines.add(""31 prayer""); lines.add(""""); } case LOOK_FOR_SCORPIONS -> { if (player.getQuestManager().getAttribs(Quest.SCORPION_CATCHER).getB(""scorp1LocKnown"")) { lines.add((caughtScorp(player, SCORP_1) ? """" : """") + ""The 1st scorpion is in Taverly Dungeon in a room north of""); lines.add((caughtScorp(player, SCORP_1) ? """" : """") + ""the black demons to the west.""); lines.add(""""); } else { lines.add(""I still need to ask the Seer where the 1st scorpion is.""); } if (player.getQuestManager().getAttribs(Quest.SCORPION_CATCHER).getB(""scorp2LocKnown"")) { lines.add((caughtScorp(player, SCORP_2) ? """" : """") + ""The 2nd scorpion's location is somewhere inside the""); lines.add((caughtScorp(player, SCORP_2) ? """" : """") + ""barbarian agility course.""); lines.add(""""); } else { lines.add(""I still need to ask the Seer where the 2nd scorpion is.""); } if (player.getQuestManager().getAttribs(Quest.SCORPION_CATCHER).getB(""scorp3LocKnown"")) { lines.add((caughtScorp(player, SCORP_3) ? """" : """") + ""The 3rd scorpion's location is somewhere inside the""); lines.add((caughtScorp(player, SCORP_3) ? """" : """") + ""Edgeville monastery.""); lines.add(""""); } else { lines.add(""I still need to ask the Seer where the 3rd scorpion is.""); } } case QUEST_COMPLETE -> { lines.add(""""); lines.add(""""); lines.add(""QUEST COMPLETE!""); } default -> lines.add(""Invalid quest stage. Report this to an administrator.""); } return lines; } public static NPCClickHandler handleScorpCatches = new NPCClickHandler(new Object[] { SCORP_1, SCORP_2, SCORP_3 }, e -> { if (e.getPlayer().getQuestManager().getStage(Quest.SCORPION_CATCHER) != LOOK_FOR_SCORPIONS) return; if (!e.getPlayer().getInventory().containsOneItem(EMPTY_CAGE, CAUGHT_CAGE_1, CAUGHT_CAGE_2, CAUGHT_CAGE_3)) { e.getPlayer().sendMessage(""You're not going to pick that up without something to put it in.""); return; } if (caughtScorp(e.getPlayer(), e.getNPCId())) return; setCaughtScorp(e.getPlayer(), e.getNPCId()); e.getPlayer().getInventory().removeAllItems(EMPTY_CAGE, CAUGHT_CAGE_1, CAUGHT_CAGE_2); e.getPlayer().getInventory().addItem(getCageId(e.getPlayer()), 1); e.getPlayer().sendMessage(""You add the scorpion to the cage.""); }); public static int getCageId(Player player) { return switch(getNumCaught(player)) { case 1 -> CAUGHT_CAGE_1; case 2 -> CAUGHT_CAGE_2; case 3 -> CAUGHT_CAGE_3; default -> EMPTY_CAGE; }; } public static void setCaughtScorp(Player player, int id) { int idx = (id - SCORP_1) + 1; player.getQuestManager().getAttribs(Quest.SCORPION_CATCHER).setB(""scorp""+idx+""Caught"", true); } public static boolean caughtScorp(Player player, int id) { int idx = (id - SCORP_1) + 1; return player.getQuestManager().getAttribs(Quest.SCORPION_CATCHER).getB(""scorp""+idx+""Caught""); } public static int getNumCaught(Player player) { int num = 0; for (int i = 1;i <= 3;i++) if (player.getQuestManager().getAttribs(Quest.SCORPION_CATCHER).getB(""scorp""+i+""Caught"")) num++; return num; } @Override public void complete(Player player) { player.getSkills().addXpQuest(Constants.STRENGTH, 6625); sendQuestCompleteInterface(player, 456); } }" "package com.rs.game.content.quests.scorpioncatcher; @PluginEventHandler public class SeerScorpionCatcherD extends Conversation { private final static int NPC = 388; public SeerScorpionCatcherD(Player player) { super(player); if (!player.getInventory().containsOneItem(ScorpionCatcher.EMPTY_CAGE, ScorpionCatcher.CAUGHT_CAGE_1, ScorpionCatcher.CAUGHT_CAGE_2, ScorpionCatcher.CAUGHT_CAGE_3)) { addNPC(NPC, HeadE.CALM_TALK, ""Thormac has your cage.""); addPlayer(HeadE.FRUSTRATED, ""Oh...""); } else { addNPC(NPC, HeadE.CALM_TALK, ""Many greetings""); addPlayer(HeadE.HAPPY_TALKING, ""Your friend Thormac sent me to speak to you.""); } if (player.getInventory().containsItem(ScorpionCatcher.CAUGHT_CAGE_3, 1)) { addPlayer(HeadE.HAPPY_TALKING, ""I got all the scorpions!""); addNPC(NPC, HeadE.CALM_TALK, ""Great!""); return; } addNPC(NPC, HeadE.CALM_TALK, ""What does the old fellow want?""); addPlayer(HeadE.HAPPY_TALKING, ""He's lost his valuable lesser Kharid scorpions.""); addNPC(NPC, HeadE.CALM_TALK, ""Well you have come to the right place. I am a master of animal detection. Let me look into my looking glass.""); addSimple(""The seer produces a small mirror""); addSimple(""The seer gazes into the mirror""); addSimple(""The seer smoothes his hair with his hand.""); addNPC(NPC, HeadE.CALM_TALK, ""I can see a scorpion that you seek. It resides in a dark place, between a lake and a holy island. There by the "" + ""entrance shall you find it. So close and yet so far."", () -> player.getQuestManager().getAttribs(Quest.SCORPION_CATCHER).setB(""scorp1LocKnown"", true)); addPlayer(HeadE.CONFUSED, ""That was cryptic. Can't you just tell me where it is?""); addNPC(NPC, HeadE.CALM_TALK, ""Where would be the fun in that?""); addPlayer(HeadE.FRUSTRATED, ""Any more scorpions?""); addNPC(NPC, HeadE.CALM_TALK, ""Well, I've checked my looking glass. The second Kharid Scorpion has been spirited away by a brute of a man."" + "" He runs a shop in a village two canoe trips from Lumbridge."", () -> player.getQuestManager().getAttribs(Quest.SCORPION_CATCHER).setB(""scorp2LocKnown"", true)); addNPC(NPC, HeadE.CALM_TALK, ""That's all I can tell you about that scorpion.""); addPlayer(HeadE.FRUSTRATED, ""Any more scorpions?""); addNPC(NPC, HeadE.CALM_TALK, ""It's good that you should ask. I have information on the last scorpion for you. It seems to be in some sort of "" + ""upstairs room. There's some brown clothing lying on a table nearby.""); addPlayer(HeadE.VERY_FRUSTRATED, ""Oh come on now! Brown clothing? That's not a clue!""); addNPC(NPC, HeadE.CALM_TALK, ""Alright alright! The clothing is adorned with a golden four-pointed star. Happy now?""); addPlayer(HeadE.HAPPY_TALKING, ""Not really.""); addNPC(NPC, HeadE.FRUSTRATED, ""Fine! You should go to where monks reside.""); addPlayer(HeadE.HAPPY_TALKING, ""Up a tree?""); addNPC(NPC, HeadE.ANGRY, ""MONKS! NOT MONKEYS!!!!"", () -> player.getQuestManager().getAttribs(Quest.SCORPION_CATCHER).setB(""scorp3LocKnown"", true)); } }" "package com.rs.game.content.quests.scorpioncatcher; @PluginEventHandler public class ThormacScorpionCatcherD extends Conversation { private final static int NPC = 389; public ThormacScorpionCatcherD(Player player) { super(player); switch(player.getQuestManager().getStage(Quest.SCORPION_CATCHER)) { case ScorpionCatcher.NOT_STARTED -> { addNPC(NPC, HeadE.CALM_TALK, ""Hello I am Thormac the Sorcerer, I don't suppose you could be of assistance to me?""); addOptions(""Choose an option:"", new Options() { @Override public void create() { if(player.getSkills().getLevel(Constants.PRAYER) < 31) option(""What do you need assistance with?"", new Dialogue() .addSimple(""You need 31 prayer to start Scorpion Catcher."")); else option(""What do you need assistance with?"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""What do you need assistance with?"") .addNPC(NPC, HeadE.CALM_TALK, ""I've lost my pet scorpions. They're lesser Kharid scorpions, a very rare breed. I left "" + ""their cage door open, now I don't know where they've gone. "") .addNPC(NPC, HeadE.CALM_TALK, ""There's three of them, and they're quick little beasties. They're all over Runescape."") .addPlayer(HeadE.HAPPY_TALKING, ""What's in it for me?"") .addNPC(NPC, HeadE.CALM_TALK, ""Well I suppose I can aid you with my skills as a staff sorcerer. Most battlestaffs around here"" + "" are a bit puny."") .addNPC(NPC, HeadE.SECRETIVE, ""I can beef them up for you a bit."") .addOptions(""Start Scorption Catcher?"", new Options() { @Override public void create() { option(""Yes"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""So how would I go about catching them then?"") .addNPC(NPC, HeadE.CALM_TALK, ""If you go up to the village of Seers, to the North of here, one of them "" + ""will be able to tell you where the scorpions are now."") .addNPC(NPC, HeadE.CALM_TALK, ""Also, I have a scorpion cage here which you can use to catch them in."") .addSimple(""Thormac gives you a cage"", ()->{ player.getQuestManager().setStage(Quest.SCORPION_CATCHER, ScorpionCatcher.LOOK_FOR_SCORPIONS); player.getInventory().addItem(new Item(ScorpionCatcher.EMPTY_CAGE, 1), true); }) ); option(""No"", new Dialogue()); } })); option(""I'm a little busy."", new Dialogue() .addPlayer(HeadE.FRUSTRATED, ""I'm a little busy"") .addNPC(NPC, HeadE.CALM_TALK, ""Okay then."")); } }); } case ScorpionCatcher.LOOK_FOR_SCORPIONS -> { if (ScorpionCatcher.getNumCaught(player) >= 3) { addNPC(NPC, HeadE.CALM_TALK, ""How goes your quest?""); addPlayer(HeadE.HAPPY_TALKING, ""I have retrieved all your scorpions.""); addNPC(NPC, HeadE.CALM_TALK, ""Aha, my little scorpions home at last!""); addNext(() -> { player.getQuestManager().completeQuest(Quest.SCORPION_CATCHER); player.getInventory().removeAllItems(ScorpionCatcher.EMPTY_CAGE, ScorpionCatcher.CAUGHT_CAGE_1, ScorpionCatcher.CAUGHT_CAGE_2, ScorpionCatcher.CAUGHT_CAGE_3); }); } else if (!player.getInventory().containsOneItem(ScorpionCatcher.EMPTY_CAGE, ScorpionCatcher.CAUGHT_CAGE_1, ScorpionCatcher.CAUGHT_CAGE_2, ScorpionCatcher.CAUGHT_CAGE_3)) { addNPC(NPC, HeadE.CALM_TALK, player.getDisplayName() + ""!""); addPlayer(HeadE.HAPPY_TALKING, ""Yes?""); if (player.getInventory().hasFreeSlots()) { addNPC(NPC, HeadE.CALM_TALK, ""Here is the cage, I found it!"", () -> player.getInventory().addItem(ScorpionCatcher.getCageId(player))); addPlayer(HeadE.FRUSTRATED, ""Great...""); } else { addNPC(NPC, HeadE.CALM_TALK, ""I have the cage but you need room for me to give it to you...""); addPlayer(HeadE.HAPPY_TALKING, ""Great!""); } } else { addPlayer(HeadE.HAPPY_TALKING, ""I've not caught all the scorpions yet.""); addNPC(NPC, HeadE.CALM_TALK, ""Well remember to go speak to the Seers, North of here, if you need any help.""); } } } } }" "package com.rs.game.content.quests.shieldofarrav; public class BaraekShieldOfArravD extends Conversation { private final int BARAEK = 547; public BaraekShieldOfArravD(Player p) { super(p); switch(p.getQuestManager().getStage(Quest.SHIELD_OF_ARRAV)) { case ShieldOfArrav.TALK_TO_BARAEK_STAGE: addOptions(""Choose an option: "", new Options() { @Override public void create() { option(""Can you tell me where I can find the Phoenix Gang?"", new Dialogue() .addPlayer(HeadE.SECRETIVE, ""Can you tell me where I can find the Phoenix Gang?"") .addNPC(BARAEK, HeadE.FRUSTRATED, ""Sh sh sh, not so loud! You don't want to get me in trouble!"") .addPlayer(HeadE.SKEPTICAL_THINKING, ""So DO you know where they are?"") .addNPC(BARAEK, HeadE.CALM_TALK,""I may. But I don't want to get into trouble for revealing their hideout."") .addNPC(BARAEK, HeadE.TALKING_ALOT, "" Of course, if I was, say 10 gold coins richer I may happen to be more inclined to take that "" + ""sort of risk..."") .addOptions(""Choose an option: "", new Options() { @Override public void create() { if(p.getInventory().hasCoins(10)) option(""Alright. Have 10 gold coins."", new Dialogue() .addSimple(""You give him 10 coins"", () -> { if (p.getQuestManager().getStage(Quest.SHIELD_OF_ARRAV) == ShieldOfArrav.TALK_TO_BARAEK_STAGE) { p.getInventory().removeCoins(10); ShieldOfArrav.setStage(p, ShieldOfArrav.AFTER_BRIBE_BARAEK_STAGE); } }).addNPC(BARAEK, HeadE.SECRETIVE, ""To get to the gang hideout, enter Varrock through the south gate. Then, if you take the first turn east, "" + ""somewhere along there is an alleyway to the south."") .addNPC(BARAEK, HeadE.SECRETIVE, "" The door at the end of there is the entrance to the Phoenix Gang. They're operating "" + ""there under the name of the VTAM Corporation."") .addNPC(BARAEK, HeadE.SECRETIVE, ""The Phoenixes ain't the types to be messed about."") .addOptions(""Select an option"", new Options() { @Override public void create() { option(""You're really bad at giving directions."", new Dialogue() .addPlayer(HeadE.WORRIED, ""Seriously...I paid 10 gold coins for that? I hope you're a better fur trader than a navigator."") .addNPC(BARAEK, HeadE.CALM_TALK, ""Hey now...the Phoenix Gang make it their business to not be easy to find."") .addNPC(BARAEK, HeadE.CALM_TALK, "" Look, if you get lost, talk to Charlie the tramp near the Varrock south gate. "" + ""He can give you better directions."") .addNext(() -> p.startConversation(new BaraekShieldOfArravD(p).getStart()))); option(""Thanks!"", () -> {}); } })); else option(""I haven't got that much."", new Dialogue() .addPlayer(HeadE.SAD_MILD_LOOK_DOWN, ""I haven't got that much"") .addNPC(BARAEK, HeadE.ANGRY, ""In that case I wouldn't dare tell you anything about the Phoenix Gang."") .addNext(() -> p.startConversation(new BaraekShieldOfArravD(p).getStart()))); option(""Yes. I'd like to be 10 gold coins richer."", new Dialogue() .addNPC(BARAEK, HeadE.FRUSTRATED, ""What? You're meant to bribe me, not the other way around... Oh, forget it!"") .addNext(() -> p.startConversation(new BaraekShieldOfArravD(p).getStart()))); option(""No, I don't like things like bribery."", new Dialogue() .addPlayer(HeadE.SKEPTICAL, ""No, I don't like things like bribery."") .addNPC(BARAEK, HeadE.LAUGH, ""Heh. And you want to deal with the Phoenix Gang? They're involved in much worse than a "" + ""bit of bribery."") .addNext(() -> p.startConversation(new BaraekShieldOfArravD(p).getStart()))); option(""Farewell.""); } })); option(""Farewell""); } }); break; case ShieldOfArrav.AFTER_BRIBE_BARAEK_STAGE: addOptions(""Choose an option:"", new Options() { @Override public void create() { option(""Remind me where I can find the Phoenix Gang."", new Dialogue() .addNPC(BARAEK, HeadE.SECRETIVE, ""To get to the gang hideout, enter Varrock through the south gate. Then, if you take the first "" + ""turn east, somewhere along there is an alleyway to the south."") .addNPC(BARAEK, HeadE.SECRETIVE, "" The door at the end of there is the entrance to the Phoenix Gang. They're operating "" + ""there under the name of the VTAM Corporation."") .addNPC(BARAEK, HeadE.SECRETIVE, ""The Phoenixes ain't the types to be messed about."") .addOptions(""Select an option"", new Options() { @Override public void create() { option(""You're really bad at giving directions."", new Dialogue() .addPlayer(HeadE.WORRIED, ""Seriously...I paid 10 gold coins for that? I hope you're a better fur trader than a navigator."") .addNPC(BARAEK, HeadE.CALM_TALK, ""Hey now...the Phoenix Gang make it their business to not be easy to find."") .addNPC(BARAEK, HeadE.CALM_TALK, "" Look, if you get lost, talk to Charlie the tramp near the Varrock south gate. "" + ""He can give you better directions."") .addNext(() -> p.startConversation(new BaraekShieldOfArravD(p).getStart()))); option(""Thanks!"", () -> {}); } })); option(""Farewell.""); } }); break; default: addNext(() -> p.sendMessage(""Nothing interesting happens."")); break; } } }" "package com.rs.game.content.quests.shieldofarrav; @PluginEventHandler public class BookShieldOfArrav { private final static int BOOKINTERFACE = 937;//interface private final static int LEFTARROWCOMP = 66; private final static int RIGHTARROWCOMP = 67; public static void openBook(Player p) { set1stPage(p); } public static void setTitle(Player p, String title) { p.getPackets().setIFText(BOOKINTERFACE, 43, title); } public static void set1stPage(Player p) { p.getInterfaceManager().sendInterface(BOOKINTERFACE); setTitle(p, ""Shield Of Arrav""); int lineNum = 0; lineNum = setParagraph(p, ""Arrav is probably the best known hero of the 4th Age.Many legends are told of his heroics. One surviving artefact from the 4th Age is a "" + ""fabulous shield"", lineNum); lineNum = setParagraph(p, ""This shield is believed to have once belonged to Arrav and is now indeed known as the Shield of Arrav. For over 150 years it was the prize "" + ""piece in the royal museum of Varrock."", lineNum); lineNum = setParagraph(p, ""However, in the year 143 of the fifth age a gang of thieves called the Phoenix Gang broke into the museum and stole the"", lineNum); showLeftArrow(p, false); showRightArrow(p, true); p.getPackets().setIFText(BOOKINTERFACE, 92, ""Page 2""); } public static void set2ndPage(Player p) { p.getInterfaceManager().sendInterface(BOOKINTERFACE); setTitle(p, ""Shield Of Arrav""); int lineNum = 0; lineNum = setParagraph(p, ""shield in a daring raid."", lineNum); lineNum = setParagraph(p, ""As a result, the current ruler, King Roald, put a 1200 gold bounty (a massive sum in those days) on the return of "" + ""the shield, hoping that one of the culprits would betray his fellows out of greed."", lineNum); lineNum = setParagraph(p, ""This tactic did not work however, and the thieves who stole the shield have since gone on to become the most powerful crime "" + ""gang in Varrock, despite making an enemy of the royal family many years ago."", lineNum); clearRestOfPageLines(p, lineNum); showLeftArrow(p, true); showRightArrow(p, false); p.getPackets().setIFText(BOOKINTERFACE, 91, ""Page 1""); } public static int setParagraph(Player p, String text, int lineNum) { String[] words = text.split("" ""); StringBuilder line = new StringBuilder(); for(int i = 0; i < words.length;) { while ((line + words[i]).length() < 26) { line.append(words[i++]).append("" ""); if(i >= words.length) break; } p.getPackets().setIFText(BOOKINTERFACE, 69 + lineNum, line.toString()); line = new StringBuilder(); lineNum++; } //Beginning of page can't be new paragraph line if(69+lineNum != 80) { p.getPackets().setIFText(BOOKINTERFACE, 69 + lineNum, """"); lineNum++; } return lineNum; } public static void clearRestOfPageLines(Player p, int lineNum) { while(69+lineNum <= 90) p.getPackets().setIFText(BOOKINTERFACE, 69 + lineNum++, """"); } public static void showLeftArrow(Player p, boolean isShown) { p.getPackets().setIFHidden(BOOKINTERFACE, LEFTARROWCOMP, !isShown); p.getPackets().setIFHidden(BOOKINTERFACE, 91, !isShown); } public static void showRightArrow(Player p, boolean isShown) { p.getPackets().setIFHidden(BOOKINTERFACE, RIGHTARROWCOMP, !isShown); p.getPackets().setIFHidden(BOOKINTERFACE, 92, !isShown); } public static ButtonClickHandler handleBookButtons = new ButtonClickHandler(937, e -> { if(e.getComponentId() == 41) e.getPlayer().getTempAttribs().setI(""soaBookPage"", 1); if(e.getComponentId() == 67) e.getPlayer().getTempAttribs().incI(""soaBookPage""); if(e.getComponentId() == 66) e.getPlayer().getTempAttribs().decI(""soaBookPage""); if(e.getPlayer().getTempAttribs().getI(""soaBookPage"") > 2) e.getPlayer().getTempAttribs().setI(""soaBookPage"", 2); if(e.getPlayer().getTempAttribs().getI(""soaBookPage"") == 1) set1stPage(e.getPlayer()); if(e.getPlayer().getTempAttribs().getI(""soaBookPage"") == 2) { set2ndPage(e.getPlayer()); if(e.getPlayer().getQuestManager().getStage(Quest.SHIELD_OF_ARRAV) == ShieldOfArrav.FIND_BOOK_STAGE) ShieldOfArrav.setStage(e.getPlayer(), ShieldOfArrav.BOOK_IS_READ_STAGE); } }); }" "package com.rs.game.content.quests.shieldofarrav; public class CharlieTheTrampArravD extends Conversation { private final int CHARLIE = 641; public CharlieTheTrampArravD(Player p) { super(p); addNPC(CHARLIE, HeadE.HAPPY_TALKING, ""Spare some change, governer?""); if(p.getInventory().hasCoins(10)) conversationOptions(p); else { addPlayer(HeadE.FRUSTRATED, ""I don't have gold""); addNPC(HeadE.SKEPTICAL_HEAD_SHAKE,""That's too bad...""); } } public CharlieTheTrampArravD(Player p, boolean restartingConversation) { super(p); conversationOptions(p); } private void conversationOptions(Player p) { Options bribe = new Options() { @Override public void create() { option(""That sounds fair. (Pay 10 gold.)"", new Dialogue() .addNPC(CHARLIE, HeadE.SECRETIVE, ""The ruthless and notorious Black Arm Gang have their headquarters down the alleyway to the"" + "" west of us."") .addNPC(CHARLIE, HeadE.SECRETIVE, ""Talk to a lady called Katrine. But don't upset her, and tell her I sent you. She's "" + ""pretty dangerous."") .addNext(() -> { p.getInventory().removeCoins(10); ShieldOfArrav.setStage(p, ShieldOfArrav.AFTER_BRIBE_CHARLIE_STAGE); })); option(""10 gold? That's too much. (Pay 5 gold.)"", new Dialogue() .addNPC(CHARLIE, HeadE.HAPPY_TALKING, ""I guess that'll have to do, then."") .addSimple(""You give him 5 gold"", () -> p.getInventory().removeCoins(5)) .addNPC(CHARLIE, HeadE.HAPPY_TALKING, ""Great, thanks."") .addPlayer(HeadE.SECRETIVE, ""So where is the hideout, then?"") .addNPC(CHARLIE, HeadE.LAUGH, ""If you pay me the other 5 gold, I'll tell you."") .addOptions(""Select an option: "", new Options() { @Override public void create() { option(""You thieving gutter-scum! You'd better watch your back!"", new Dialogue() .addPlayer(HeadE.ANGRY, ""You thieving gutter-scum! You'd better watch your back!"") .addNPC(CHARLIE, HeadE.LAUGH, ""Yeah, sure, whatever. You don't frighten me, pal."") .addNext(() -> { if(p.getInventory().hasCoins(10)) p.startConversation(new CharlieTheTrampArravD(p, true).getStart()); })); option(""I guess I don't have a choice. (Pay 5 gold.)"", new Dialogue() .addPlayer(HeadE.VERY_FRUSTRATED, ""I guess I don't have a choice."") .addSimple(""You pay Charlie 5 gold"", () -> { p.getInventory().removeCoins(5); ShieldOfArrav.setStage(p, ShieldOfArrav.AFTER_BRIBE_CHARLIE_STAGE); }) .addNPC(CHARLIE, HeadE.SECRETIVE, ""The ruthless and notorious Black Arm Gang have their headquarters down the alleyway "" + ""to the west of us."") .addNPC(CHARLIE, HeadE.SECRETIVE, ""Talk to a lady called Katrine. But don't upset her, and tell her I sent you. She's "" + ""pretty dangerous."")); option(""Never mind. I'll find it myself."", new Dialogue() .addNPC(CHARLIE, HeadE.HAPPY_TALKING, ""Well, you know where to find me if you get lost!"")); } })); } }; addOptions(""Choose an option:"", new Options() { @Override public void create() { if(ShieldOfArrav.isStageInPlayerSave(p, ShieldOfArrav.AFTER_BRIBE_CHARLIE_STAGE)) { option(""What's in it for me?"", new Dialogue() .addPlayer(HeadE.TALKING_ALOT, ""What's in it for me?"") .addNPC(CHARLIE, HeadE.TALKING_ALOT, ""'What's in it for me?' Whatever happened to charity? Have you no consideration for those "" + ""less fortunate than yourself?"") .addNext(() -> p.startConversation(new CharlieTheTrampArravD(p, true).getStart()))); option(""Do you know where I can find the Black Arm Gang hideout?"", new Dialogue() .addPlayer(HeadE.TALKING_ALOT, ""Do you know where I can find the Black Arm Gang hideout?"") .addNPC(CHARLIE, HeadE.TALKING_ALOT, ""Short memory, eh?"") .addNPC(CHARLIE, HeadE.SECRETIVE, ""The ruthless and notorious Black Arm Gang have their headquarters down the alleyway to the"" + "" west of us."") .addNPC(CHARLIE, HeadE.SECRETIVE, ""Talk to a lady called Katrine. But don't upset her, and tell her I sent you. She's "" + ""pretty dangerous."")); } else if(ShieldOfArrav.isStageInPlayerSave(p, ShieldOfArrav.AFTER_BRIBE_BARAEK_STAGE)) { option(""What's in it for me?"", new Dialogue() .addPlayer(HeadE.TALKING_ALOT, ""What's in it for me?"") .addNPC(CHARLIE, HeadE.TALKING_ALOT, ""I know you're looking for the Black Arm Gang."") .addPlayer(HeadE.SCARED, ""How do you know that?"") .addNPC(CHARLIE, HeadE.SECRETIVE, ""In my current profession, I spend a lot of time on the streets. I hear things, and for a mere 10 gold, "" + ""I'll tell you how to join the Black Arm Gang."") .addOptions(""Select an option:"", bribe)); option(""Do you know where I can find the Black Arm Gang hideout?"", new Dialogue() .addPlayer(HeadE.TALKING_ALOT, ""Do you know where I can find the Black Arm Gang hideout?"") .addNPC(CHARLIE, HeadE.TALKING_ALOT, ""Sure, I know everything there is to know about this city. I'd be happy to tell you for 10 gold."") .addOptions(""Select an option:"", bribe)); option(""I'm looking for the Phoenix Gang hideout."", new Dialogue() .addNPC(CHARLIE, HeadE.CALM_TALK, ""Yeah, I heard you talked to Baraek. It's easy to get lost on the streets of Varrock. Now listen closely... "" + ""To get to the Phoenix hideout, walk east from here. "") .addNPC(CHARLIE, HeadE.CALM_TALK, ""It's the street with the Blue Moon Inn on the corner. Take the first alley leading south off of the road "" + ""and you'll find the hideout at the end of that alley. It's called the VTAM corporation."") .addPlayer(HeadE.CALM_TALK, ""VTAM. Got it."")); } option(""Is there anything down this alleyway?"", new Dialogue() .addPlayer(HeadE.SKEPTICAL_THINKING, ""Is there anything down this alleyway?"") .addNPC(CHARLIE, HeadE.TALKING_ALOT, ""Funny you should mention that...there is actually. The ruthless and notorious criminal gang known "" + ""as the Black Arm Gang have their headquarters down there."") .addPlayer(HeadE.HAPPY_TALKING, ""Thanks for the warning!"")); } }); } }" "package com.rs.game.content.quests.shieldofarrav; public class KatrineShieldOfArravD extends Conversation { private final int KATRINE = 642; public KatrineShieldOfArravD(Player player) { super(player); if(player.getQuestManager().getStage(Quest.SHIELD_OF_ARRAV) < ShieldOfArrav.PROVING_LOYALTY_BLACK_ARM_STAGE) { addPlayer(HeadE.TALKING_ALOT, ""What is this place?""); addNPC(KATRINE, HeadE.FRUSTRATED, ""It's a private business. Can I help you at all?""); introductoryConversations(player); return; } if(!ShieldOfArrav.hasGang(player)) checkAboutCrossbowsConversation(player); else if(ShieldOfArrav.isBlackArmGang(player)) { addPlayer(HeadE.HAPPY_TALKING, ""Hey.""); addNPC(KATRINE, HeadE.HAPPY_TALKING, ""Hey.""); fellowGangMemberDialogue(player); } else if(ShieldOfArrav.isPhoenixGang(player)) { addPlayer(HeadE.TALKING_ALOT, ""What is this place?""); addNPC(KATRINE, HeadE.FRUSTRATED, ""It's a private business Phoenix scum, please leave.""); } } public KatrineShieldOfArravD(Player player, int convoID) { super(player); switch(convoID) { case 0: introductoryConversations(player); break; case 1: fellowGangMemberDialogue(player); break; } } private void fellowGangMemberDialogue(Player p) { addOptions(""Who are all those people in there?"", new Options() { @Override public void create() { option(""Who are all those people in there?"", new Dialogue() .addNPC(KATRINE, HeadE.HAPPY_TALKING, ""They're just various rogues and thieves."") .addPlayer(HeadE.TALKING_ALOT, ""They don't say a lot..."") .addNPC(KATRINE, HeadE.CALM_TALK, ""Nope."") .addNext(() -> p.startConversation(new KatrineShieldOfArravD(p, 1).getStart()))); option(""Teach me to be a top class criminal!"", new Dialogue() .addNPC(KATRINE, HeadE.HAPPY_TALKING, ""Teach yourself"") .addNext(() -> p.startConversation(new KatrineShieldOfArravD(p, 1).getStart()))); option(""Farewell.""); } }); } private void checkAboutCrossbowsConversation(Player p) { addNPC(KATRINE, HeadE.CALM, ""Have you got those crossbows for me yet?""); if(p.getInventory().containsItem(767, 2)) { addPlayer(HeadE.HAPPY_TALKING, ""Yes I have.""); addSimple(""You give the crossbows to Katrine."", () -> { p.getInventory().deleteItem(767, 1); p.getInventory().deleteItem(767, 1); ShieldOfArrav.setStage(p, ShieldOfArrav.JOINED_BLACK_ARM_STAGE); ShieldOfArrav.setGang(p, ""Black""); }); addNPC(HeadE.HAPPY_TALKING, ""You're now a Black Arm Gang member. Feel free to enter any of the rooms of the ganghouse.""); } else if(p.getInventory().containsItem(767, 1)) { addPlayer(HeadE.NERVOUS, ""I have one...""); addNPC(HeadE.HAPPY_TALKING, ""I need two. Come back when you have them.""); } else if(!p.getInventory().containsItem(767)) { addPlayer(HeadE.NERVOUS, ""No, I haven't yet found them. ""); addNPC(HeadE.HAPPY_TALKING, ""I need two crossbows stolen from the Phoenix Gang weapons stash, which if you head east for a bit, is a building "" + ""on the south side of the road. Come back when you got 'em.""); } } private void introductoryConversations(Player p) { addOptions(""Choose an option:"", new Options() { @Override public void create() { if(ShieldOfArrav.isStageInPlayerSave(p, ShieldOfArrav.AFTER_BRIBE_CHARLIE_STAGE)) option(""I've heard you're part of the Black Arm Gang."", new Dialogue() .addPlayer(HeadE.TALKING_ALOT, ""I've heard you're part of the Black Arm Gang."") .addNPC(KATRINE, HeadE.FRUSTRATED, ""Who told you that?"") .addOptions(""Select an option:"", new Options() { @Override public void create() { option(""I'd rather not reveal my sources."", new Dialogue() .addPlayer(HeadE.SECRETIVE, ""I'd rather not reveal my sources."") .addNPC(KATRINE, HeadE.SECRETIVE, ""Yes, I can understand that. So what do you want with us?"") .addOptions(""Select an option:"", joinGang)); option(""It was Charlie, the tramp outside."", new Dialogue() .addPlayer(HeadE.TALKING_ALOT, ""It was Charlie, the tramp outside."") .addNPC(KATRINE, HeadE.FRUSTRATED, ""Is that guy still out there? He's getting to be a nuisance. Remind me to send someone to kill him. "" + ""So now you've found us, what do you want?"") .addOptions(""Choose an option:"", joinGang)); option(""Everyone knows - it's no great secret."", new Dialogue() .addPlayer(HeadE.TALKING_ALOT, ""Everyone knows - it's no great secret."") .addNPC(KATRINE, HeadE.AMAZED_MILD, ""I thought we were safe back here!"") .addPlayer(HeadE.TALKING_ALOT, ""Oh no, not at all... It's so obvious! Even the town guard have caught on..."") .addNPC(KATRINE, HeadE.TALKING_ALOT, ""Wow! We MUST be obvious! I guess they'll be expecting bribes again soon in that case."" + "" Thanks for the information. Is there anything else you want to tell me?"") .addOptions(""Choose an option:"", joinGang)); } })); option(""What sort of business?"", new Dialogue() .addPlayer(HeadE.SKEPTICAL_THINKING, ""What sort of business?"") .addNPC(KATRINE, HeadE.SECRETIVE, ""A small, family business. We give financial advice to other companies."") .addNext(() -> p.startConversation(new KatrineShieldOfArravD(p, 0).getStart()))); option(""I'm looking for fame and riches."", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""I'm looking for fame and riches."") .addNPC(KATRINE, HeadE.FRUSTRATED, ""And you expect to find it up the back streets of Varrock?"") .addNext(() -> p.startConversation(new KatrineShieldOfArravD(p, 0).getStart()))); option(""Farewell."", new Dialogue().addNext(() -> {})); } }); } Options joinGang = new Options() { @Override public void create() { option(""I want to become a member of your gang."", new Dialogue() .addPlayer(HeadE.TALKING_ALOT, ""I want to become a member of your gang."") .addNPC(KATRINE, HeadE.SKEPTICAL_THINKING, ""How unusual. Normally we recruit for our gang by watching local thugs and thieves in action. "") .addNPC(KATRINE, HeadE.SKEPTICAL_THINKING, ""People don't normally waltz in here saying 'hello, can I play'. How can I be sure you can be trusted?"") .addOptions(""Choose an option:"", new Options() { @Override public void create() { option(""Well, you can give me a try can't you?"", new Dialogue() .addPlayer(HeadE.TALKING_ALOT, ""Well, you can give me a try can't you?"") .addNPC(KATRINE, HeadE.TALKING_ALOT, ""I'm not so sure. Thinking about it... I may have a solution actually."") .addNPC(KATRINE, HeadE.TALKING_ALOT, ""Our rival gang - the Phoenix Gang - has a weapons stash a little east of here."") .addNPC(KATRINE, HeadE.TALKING_ALOT, ""We're fresh out of crossbows, so if you could steal a couple of crossbows for us it would be very much"" + "" appreciated. Then I'll be happy to call you a Black Arm."") .addPlayer(HeadE.HAPPY_TALKING, ""Sounds simple enough. Any particular reason you need two of them?"") .addNPC(KATRINE, HeadE.TALKING_ALOT, ""I have an idea for framing a local merchant who is refusing to pay our, very reasonable, 'keep-your-life-pleasant'"" + "" insurance rates."") .addNPC(KATRINE, HeadE.TALKING_ALOT, ""I need two phoenix crossbows: one to kill somebody important with and the other to hide in the merchant's "" + ""house where the local law can find it!"") .addNPC(KATRINE, HeadE.TALKING_ALOT, ""When they find it, they'll suspect him of murdering the target for the Phoenix Gang and, hopefully, "" + ""arrest the whole gang! Leaving us as the only gang of thieves in Varrock! Brilliant, eh?"") .addPlayer(HeadE.SECRETIVE, ""Yeah, brilliant. So who are you planning to murder?"") .addNPC(KATRINE, HeadE.SKEPTICAL, ""I haven't decided yet, but it'll need to be somebody important. Say, why are you being so nosey? "" + ""You aren't with the law, are you?"") .addPlayer(HeadE.SKEPTICAL_HEAD_SHAKE, ""No, no! Just curious."") .addNPC(KATRINE, HeadE.FRUSTRATED, ""You'd better just keep your mouth shut about this plan, or I'll make sure it stays shut for you. "" + ""Now, are you going to go get those crossbows or not?"") .addOptions(""Select an option:"", new Options() { @Override public void create() { option(""No problem. I'll get you two phoenix crossbows."", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""No problem. I'll get you two phoenix crossbows."") .addNPC(KATRINE, HeadE.HAPPY_TALKING, ""Great! You'll find the Phoenix gang's weapon stash just next to a temple, due east of here."") .addPlayer(HeadE.HAPPY_TALKING,""I'll get on it!"") .addNext(() -> ShieldOfArrav.setStage(player, ShieldOfArrav.PROVING_LOYALTY_BLACK_ARM_STAGE))); option(""Sounds a little tricky. Got anything easier?"", new Dialogue() .addPlayer(HeadE.WORRIED, ""Sounds a little tricky. Got anything easier?"") .addNPC(KATRINE, HeadE.LAUGH, ""If you're not up to a little bit of danger I don't think you've got anything to offer our gang."") .addNext(() -> player.startConversation(new KatrineShieldOfArravD(player, 0).getStart()))); } })); option(""Well, people tell me I have an honest face."", new Dialogue() .addNPC(KATRINE, HeadE.SKEPTICAL_HEAD_SHAKE, ""How unusual. Someone honest wanting to join a gang of thieves. Excuse me if I remain "" + ""unconvinced."") .addNext(() -> player.startConversation(new KatrineShieldOfArravD(player, 0).getStart()))); } })); option(""I want some hints for becoming a thief."", new Dialogue() .addPlayer(HeadE.SECRETIVE, ""I want some hints for becoming a thief."") .addNPC(KATRINE, HeadE.WORRIED, ""Well, I'm sorry luv, I'm not giving away any of my secrets. Not to people who ain't Black Arm members anyway."") .addNext(() -> player.startConversation(new KatrineShieldOfArravD(player, 0).getStart()))); option(""I'm looking for the door out of here."", new Dialogue() .addPlayer(HeadE.SCARED, ""I'm looking for the door out of here."") .addSimple(""*Katrine groans"") .addNPC(KATRINE, HeadE.VERY_FRUSTRATED, ""Try... the one you just came in?"") .addNext(() -> player.startConversation(new KatrineShieldOfArravD(player, 0).getStart()))); } }; }" "package com.rs.game.content.quests.shieldofarrav; public class KingRoaldShieldOfArravD extends Conversation { final int KING_ROALD = 648; public KingRoaldShieldOfArravD(Player p) { super(p); if(p.getQuestManager().getStage(Quest.SHIELD_OF_ARRAV) < ShieldOfArrav.HAS_SHIELD_STAGE) { addPlayer(HeadE.WORRIED, ""There is nothing to say...""); return; } if(p.getInventory().containsItem(769)) { addPlayer(HeadE.HAPPY_TALKING, ""Your majesty, I have come to claim the reward for the return of the Shield Of Arrav.""); addItem(769, ""You show the certificate to King Roald""); addNPC(KING_ROALD, HeadE.AMAZED, ""My goodness! My father set a bounty on this shield many years ago!""); addNPC(KING_ROALD, HeadE.AMAZED_MILD, ""I never thought I would live to see the day when someone came forward to claim it.""); addNPC(KING_ROALD, HeadE.TALKING_ALOT, ""1,200 coins was a fortune in my father's day. I hope it serves you well in your adventures.""); addNPC(KING_ROALD, HeadE.HAPPY_TALKING, ""The museum of Varrock shall proudly display the Shield of Arrav once again.""); addNext(() -> { p.getInventory().deleteItem(769, 1); p.getQuestManager().completeQuest(Quest.SHIELD_OF_ARRAV); }); return; } if(p.getQuestManager().getStage(Quest.SHIELD_OF_ARRAV) == ShieldOfArrav.SPOKE_TO_KING_STAGE) { addNPC(KING_ROALD, HeadE.SKEPTICAL, ""Have you gotten the shield authenticated with the museum curator?""); addPlayer(HeadE.SAD_MILD_LOOK_DOWN, ""Not yet...""); return; } if(p.getQuestManager().getStage(Quest.SHIELD_OF_ARRAV) == ShieldOfArrav.HAS_CERTIFICATE_STAGE) { addNPC(KING_ROALD, HeadE.SKEPTICAL, ""How am I supposed to believe just half of a certificate?""); addPlayer(HeadE.SAD, ""Darn, I need to find someone with another half...""); return; } if(p.getInventory().containsItem(763) || p.getInventory().containsItem(765)) { addPlayer(HeadE.HAPPY_TALKING, "" Your majesty, I have recovered the Shield Of Arrav; I would like to claim the reward.""); addNPC(KING_ROALD, HeadE.SKEPTICAL, ""The Shield of Arrav, eh? Yes, I do recall my father, King Roald, put a reward out for that""); addNPC(KING_ROALD, HeadE.SKEPTICAL, ""Very well, If you get the authenticity of the shield verified by the curator at the museum and then return"" + "" here with authentication, I will grant you your reward.""); p.getQuestManager().setStage(Quest.SHIELD_OF_ARRAV, ShieldOfArrav.SPOKE_TO_KING_STAGE); } } }" "package com.rs.game.content.quests.shieldofarrav; @PluginEventHandler public class MuseumCuratorArravD extends Conversation { final int CURATOR = 646; public MuseumCuratorArravD(Player p) { super(p); addPlayer(HeadE.HAPPY_TALKING, ""Hello.""); addNPC(CURATOR, HeadE.CALM_TALK, ""Hi.""); if(player.isQuestComplete(Quest.SHIELD_OF_ARRAV)) { addPlayer(HeadE.HAPPY_TALKING, ""Can I have another half of my certificate?""); addNPC(CURATOR, HeadE.CALM_TALK, ""Sure, though I don't see why you want one...""); addSimple(""He scribbles on a piece of paper and tears it in half.""); addItem(11173, ""He hands you the certificate..."", ()->{ if(!ShieldOfArrav.hasGang(p)) { p.sendMessage(""You should talk to an admin, you don't have a gang!""); return; } if(ShieldOfArrav.isBlackArmGang(p)) p.getInventory().addItem(11173, 1); if(ShieldOfArrav.isPhoenixGang(p)) p.getInventory().addItem(11174, 1); }); return; } if(p.getInventory().containsItem(""Broken shield"") && p.getQuestManager().getStage(Quest.SHIELD_OF_ARRAV) >= ShieldOfArrav.SPOKE_TO_KING_STAGE) tradeShield(p); else { addNPC(CURATOR, HeadE.CALM_TALK, ""Do you have anything for me?""); addPlayer(HeadE.SAD, ""Not currently""); } } public MuseumCuratorArravD(Player p, boolean restartConversation) { super(p); addPlayer(HeadE.HAPPY_TALKING, ""Hello.""); addNPC(CURATOR, HeadE.CALM_TALK, ""Hi.""); if(p.getInventory().containsItem(""Broken shield"") && p.getQuestManager().getStage(Quest.SHIELD_OF_ARRAV) >= ShieldOfArrav.SPOKE_TO_KING_STAGE) tradeShield(p); } private void tradeShield(Player p) { addPlayer(HeadE.CALM_TALK, ""Can you authenticate this item as the Shield Of Arrav?""); addNPC(CURATOR, HeadE.SKEPTICAL, ""Let me have a look at it first.""); addSimple(""The curator peers at the shield""); addNPC(CURATOR, HeadE.AMAZED, ""This is incredible!""); addNPC(CURATOR, HeadE.AMAZED_MILD, ""That shield has been missing for over twenty-five years!""); addNPC(CURATOR, HeadE.CALM, ""Leave the shield here with me and I'll write you out a certificate saying that you have returned the shield, so that you "" + ""can claim your reward from the King.""); addPlayer(HeadE.HAPPY_TALKING, ""Can I have two certificates please?""); addNPC(CURATOR, HeadE.CALM, ""Yes, certainly. Please hand over the shield.""); addSimple(""You hand over the shield half.""); addSimple(""The curator writes out two half-certificates."", () -> { if(p.getInventory().containsItem(763, 1)) { p.getInventory().deleteItem(763, 1); p.getInventory().addItem(11173, 2); ShieldOfArrav.setStage(p, ShieldOfArrav.HAS_CERTIFICATE_STAGE); } if(p.getInventory().containsItem(765, 1)) { p.getInventory().deleteItem(765, 1); p.getInventory().addItem(11174, 2); ShieldOfArrav.setStage(p, ShieldOfArrav.HAS_CERTIFICATE_STAGE); } }); addNPC(CURATOR, HeadE.CALM_TALK, ""Of course, you won't actually be able to claim the reward with only half the reward certificate...""); addPlayer(HeadE.CONFUSED, ""What? I went through a lot of trouble to get that shield piece and now you tell me it was for nothing? That's not very fair!""); addNPC(CURATOR, HeadE.CALM_TALK, ""Well, if you were to get me the other half of the shield, I could give you the other half of the reward certificate.""); if(ShieldOfArrav.isStageInPlayerSave(p, ShieldOfArrav.JOINED_PHOENIX_STAGE)) addNPC(CURATOR, HeadE.CALM_TALK, ""It's rumoured to be in the possession of the infamous Black Arm Gang, beyond that I can't help you.""); if(ShieldOfArrav.isStageInPlayerSave(p, ShieldOfArrav.JOINED_BLACK_ARM_STAGE)) addNPC(CURATOR, HeadE.CALM_TALK, ""It's rumoured to be in the possession of the infamous Phoenix Gang, beyond that I can't help you.""); addPlayer(HeadE.SKEPTICAL, ""Okay, I'll see what I can do.""); } public static ItemOnNPCHandler handleItemOnCurator = new ItemOnNPCHandler(646, e -> { if (e.getItem().getId() == 763 || e.getItem().getId() == 765) e.getPlayer().startConversation(new MuseumCuratorArravD(e.getPlayer(), true).getStart()); }); }" "package com.rs.game.content.quests.shieldofarrav; public class ReldoShieldOfArravD extends Conversation { final int RELDO = 647; public ReldoShieldOfArravD(Player p) { super(p); switch(p.getQuestManager().getStage(Quest.SHIELD_OF_ARRAV)) { case ShieldOfArrav.NOT_STARTED_STAGE: addPlayer(HeadE.SECRETIVE, ""I'm in search of a quest""); addNPC(RELDO, HeadE.SKEPTICAL_THINKING, ""Hmmm, I don't... believe there are any here... let me think actually...""); //options addOption(""Shield Of Arrav"", ""Accept quest"", ""Not right now""); addNPC(RELDO, HeadE.CALM_TALK, "" Ah, yes. I know. If you look in a book called 'The Shield of Arrav', you'll find a quest in there. I'm not "" + ""sure where the book is mind you... but I'm sure it's around here somewhere."") .addNext(() -> ShieldOfArrav.setStage(p, ShieldOfArrav.FIND_BOOK_STAGE)); addPlayer(HeadE.CALM_TALK, ""On second thoughts, I don't want a quest after all."") .addNPC(RELDO, HeadE.CALM_TALK, ""Oh. But you said you're in search of a quest."") .addPlayer(HeadE.CALM_TALK, ""I was. I am. I changed my mind."") .addNPC(RELDO, HeadE.CALM_TALK, ""You perplex me. Well, come back if you change your mind again.""); break; case ShieldOfArrav.FIND_BOOK_STAGE: addPlayer(HeadE.SECRETIVE, ""Where is that book...'The Shield of Arrav'?""); if (p.getInventory().containsItem(757)) { addNPC(RELDO, HeadE.SECRETIVE, ""Did you find the book?""); addPlayer(HeadE.SECRETIVE, ""Yes""); addNPC(RELDO, HeadE.FRUSTRATED, ""Why are you asking me where to find a book you've already found? Have you read it?""); addPlayer(HeadE.SECRETIVE, ""No""); addNPC(RELDO, HeadE.SECRETIVE, ""Try reading it.""); addPlayer(HeadE.SECRETIVE, ""Read 'The Shield of Arrav'. Got it.""); } else addNPC(RELDO, HeadE.SECRETIVE, ""I'm not sure where it is, exactly...but I'm sure it's somewhere around the library.""); break; case ShieldOfArrav.BOOK_IS_READ_STAGE: addPlayer(HeadE.SECRETIVE, ""I've read the book. Do you know where I can find the Phoenix Gang?""); addNPC(RELDO, HeadE.SECRETIVE, ""No, I don't. I think I know someone who might, however. If I were you I would talk to Baraek, the fur trader "" + ""in the market place. I've heard he has connections with the Phoenix Gang.""); addPlayer(HeadE.HAPPY_TALKING, ""Thanks. I'll try that!""); addNext(() -> ShieldOfArrav.setStage(p, ShieldOfArrav.TALK_TO_BARAEK_STAGE)); break; case ShieldOfArrav.TALK_TO_BARAEK_STAGE: addPlayer(HeadE.SECRETIVE, ""Remind me again where I can find the Phoenix Gang?""); addNPC(RELDO, HeadE.SECRETIVE, ""If I were you I would talk to Baraek, the fur trader in the market place. I've heard he has connections with "" + ""the Phoenix Gang.""); break; default: addNPC(RELDO, HeadE.HAPPY_TALKING, ""You seem to have this covered, good luck!""); break; } } }" "package com.rs.game.content.quests.shieldofarrav; @QuestHandler( quest = Quest.SHIELD_OF_ARRAV, startText = ""Talk to Reldo in the Varrock palace library."", itemsText = ""20 coins."", combatText = ""You will need to defeat a level 1 enemy."", rewardsText = ""1,200 coins"", completedStage = 27 ) @PluginEventHandler public class ShieldOfArrav extends QuestOutline { //---Stages--- final static int NOT_STARTED_STAGE = 0; //Starting quest final static int FIND_BOOK_STAGE = 1; final static int BOOK_IS_READ_STAGE = 2; final static int TALK_TO_BARAEK_STAGE = 3; final static int AFTER_BRIBE_BARAEK_STAGE = 4; //Inititiation Phoenix gang final static int PROVING_LOYALTY_PHOENIX_STAGE = 5; //Initiation Black arm gang final static int AFTER_BRIBE_CHARLIE_STAGE = 20; final static int PROVING_LOYALTY_BLACK_ARM_STAGE = 21; //Gang activity final public static int JOINED_PHOENIX_STAGE = 22; //Gang activity final public static int JOINED_BLACK_ARM_STAGE = 23; //King Roald final public static int HAS_SHIELD_STAGE = 24; final public static int SPOKE_TO_KING_STAGE = 25; final public static int HAS_CERTIFICATE_STAGE = 26; final static int QUEST_COMPLETE_STAGE = 27; @Override public List getJournalLines(Player player, int stage) { ArrayList lines = new ArrayList<>(); switch (stage) { case NOT_STARTED_STAGE: lines.add(""Varrockian literature tells of a valuable shield.""); lines.add(""It was stolen long ago from the Museum of Varrock,""); lines.add(""by a gang of professional thieves. See if you can""); lines.add(""track down this shield and return it to the Museum.""); lines.add(""You will need a friend to help you complete this quest.""); lines.add(""""); lines.add(""I can start this quest by speaking to Reldo""); lines.add(""in the Varrock palace library.""); lines.add(""""); break; case FIND_BOOK_STAGE: lines.add(""Look for a book in the bookshelves around Reldo""); lines.add(""You also must read the book then talk to Reldo""); lines.add(""Turn to page 2""); lines.add(""""); break; case BOOK_IS_READ_STAGE: lines.add(""Talk to Reldo""); lines.add(""""); break; case TALK_TO_BARAEK_STAGE: lines.add(""Reldo said I should talk to Baraek about the""); lines.add(""Pheonix gang at central square in Varrock""); lines.add(""""); break; case AFTER_BRIBE_BARAEK_STAGE://good here lines.add(""I have bribed Baraek.""); lines.add(""""); lines.add(""If I wish to join the Phoenix Gang I must""); lines.add(""find their hideout south of the rune shop""); lines.add(""and prove my loyalty to Straven""); lines.add(""""); lines.add(""If I wish to join the Black Arm Gang I can""); lines.add(""speak to Charlie The Tramp to get directions.""); lines.add(""""); break; case AFTER_BRIBE_CHARLIE_STAGE: lines.add(""I have bribed Charlie the Tramp and discovered""); lines.add(""the location of the black arm gang. If I wish to""); lines.add(""join them I must speak to Katrine and prove my""); lines.add(""loyalty.""); lines.add(""""); break; case PROVING_LOYALTY_PHOENIX_STAGE: lines.add(""I have spoken with Straven, a Phoenix gang""); lines.add(""member. To prove my loyalty I must kill""); lines.add(""a Black Arm gang informant, Johnny the Beard ""); lines.add(""at the blue moon inn and retrieve his intelligence""); lines.add(""report then give it to Straven""); lines.add(""""); if (isStageInPlayerSave(player, AFTER_BRIBE_CHARLIE_STAGE)) { lines.add(""If I am feeling doubt Charlie says I can speak""); lines.add(""to Katrine to join the Black Arm Gang""); } else { lines.add(""If I am feeling doubt I can speak to Charlie the""); lines.add(""Tramp to join the Black Arm Gang.""); } lines.add(""""); break; case PROVING_LOYALTY_BLACK_ARM_STAGE: lines.add(""I have spoken with Katrine, a Black Arm Gang""); lines.add(""member. To join the Black Arm Gang I must find""); lines.add(""two Phoenix Gang crossbows and bring them to her.""); lines.add(""""); lines.add(""I need to get into the weapons store room south""); lines.add(""of the rune store. I will need to get a weapon key""); lines.add(""from a player who is a Phoenix gang member.""); lines.add(""""); lines.add(""I can trade players by using quest items on them.""); lines.add(""""); lines.add(""If I am feeling doubt about this gang I can speak""); lines.add(""to Straven to join the Phoenix Gang.""); lines.add(""""); break; case JOINED_PHOENIX_STAGE: if (ShieldOfArrav.isStageInPlayerSave(player, ShieldOfArrav.JOINED_PHOENIX_STAGE)) { lines.add(""You have joined the Phoenix Gang""); lines.add(""I should find the Shield Of Arrav""); lines.add(""at their hideout""); lines.add(""""); } break; case JOINED_BLACK_ARM_STAGE: if (ShieldOfArrav.isStageInPlayerSave(player, ShieldOfArrav.JOINED_BLACK_ARM_STAGE)) { lines.add(""You have joined the Black Arm Gang""); lines.add(""I should find the Shield Of Arrav""); lines.add(""at their hideout""); lines.add(""""); } break; case HAS_SHIELD_STAGE: lines.add(""You should bring the shield half to King Roald""); lines.add(""""); break; case SPOKE_TO_KING_STAGE: lines.add(""I should get the shield authenticated by""); lines.add(""the museum curator.""); lines.add(""""); break; case HAS_CERTIFICATE_STAGE: lines.add(""Somehow I must get the other certificate half""); if (!ShieldOfArrav.hasGang(player)) { lines.add(""You dont' have a gang but the quest is complete""); lines.add(""report this or try to join a gang.""); } if (ShieldOfArrav.isPhoenixGang(player)) { lines.add(""I am part of the Phoenix Gang. Maybe a Black Arm""); lines.add(""member can help?""); lines.add(""""); lines.add(""I can trade players by using quest items on them.""); lines.add(""""); } if (ShieldOfArrav.isBlackArmGang(player)) { lines.add(""I am part of the Black Arm Gang, Maybe a Phoenix""); lines.add(""member can help?""); lines.add(""""); lines.add(""I can trade players by using quest items on them.""); lines.add(""""); } lines.add(""""); break; case QUEST_COMPLETE_STAGE: if (!hasGang(player)) lines.add(""Contact an admin. You appear to not have a gang...""); if (isPhoenixGang(player)) lines.add(""You have joined the Phoenix gang...""); if (isBlackArmGang(player)) lines.add(""You have joined the Black Arm gang...""); lines.add(""""); lines.add(""QUEST COMPLETE!""); break; case 6: case 7: case 8: case 9: case 10: case 11: case 12: case 13: case 14: case 15: case 16: case 17: case 18: case 19: break; default: lines.add(""Invalid quest stage. Report this to an administrator.""); break; } return lines; } public static void saveStageToPlayerSave(Player p, int questStage) { GenericAttribMap questAttr = p.getQuestManager().getAttribs(Quest.SHIELD_OF_ARRAV); switch (questStage) { case NOT_STARTED_STAGE -> questAttr.setB(""NOT_STARTED"", true); case FIND_BOOK_STAGE -> { p.delete(""claimedArravLamp""); questAttr.setB(""FIND_BOOK"", true); } case BOOK_IS_READ_STAGE -> questAttr.setB(""BOOK_IS_READ"", true); case TALK_TO_BARAEK_STAGE -> questAttr.setB(""TALK_TO_BARAEK"", true); case AFTER_BRIBE_BARAEK_STAGE -> questAttr.setB(""AFTER_BRIBE_BARAEK"", true); case PROVING_LOYALTY_PHOENIX_STAGE -> questAttr.setB(""PROVING_LOYALTY_PHOENIX"", true); case AFTER_BRIBE_CHARLIE_STAGE -> questAttr.setB(""AFTER_BRIBE_CHARLIE"", true); case PROVING_LOYALTY_BLACK_ARM_STAGE -> questAttr.setB(""PROVING_LOYALTY_BLACK_ARM"", true); case JOINED_PHOENIX_STAGE -> questAttr.setB(""JOINED_PHOENIX"", true); case JOINED_BLACK_ARM_STAGE -> questAttr.setB(""JOINED_BLACK_ARM"", true); case HAS_SHIELD_STAGE -> questAttr.setB(""HAS_SHIELD"", true); case SPOKE_TO_KING_STAGE -> questAttr.setB(""SPOKE_TO_KING"", true); case HAS_CERTIFICATE_STAGE -> questAttr.setB(""HAS_CERTIFICATE"", true); } } public static boolean isStageInPlayerSave(Player p, int questStage) { GenericAttribMap questAttr = p.getQuestManager().getAttribs(Quest.SHIELD_OF_ARRAV); switch (questStage) { case NOT_STARTED_STAGE -> { return questAttr.getB(""NOT_STARTED""); } case FIND_BOOK_STAGE -> { return questAttr.getB(""FIND_BOOK""); } case BOOK_IS_READ_STAGE -> { return questAttr.getB(""BOOK_IS_READ""); } case TALK_TO_BARAEK_STAGE -> { return questAttr.getB(""TALK_TO_BARAEK""); } case AFTER_BRIBE_BARAEK_STAGE -> { return questAttr.getB(""AFTER_BRIBE_BARAEK""); } case PROVING_LOYALTY_PHOENIX_STAGE -> { return questAttr.getB(""PROVING_LOYALTY_PHOENIX""); } case AFTER_BRIBE_CHARLIE_STAGE -> { return questAttr.getB(""AFTER_BRIBE_CHARLIE""); } case PROVING_LOYALTY_BLACK_ARM_STAGE -> { return questAttr.getB(""PROVING_LOYALTY_BLACK_ARM""); } case JOINED_PHOENIX_STAGE -> { return questAttr.getB(""JOINED_PHOENIX""); } case JOINED_BLACK_ARM_STAGE -> { return questAttr.getB(""JOINED_BLACK_ARM""); } case HAS_SHIELD_STAGE -> { return questAttr.getB(""HAS_SHIELD""); } case SPOKE_TO_KING_STAGE -> { return questAttr.getB(""SPOKE_TO_KING""); } case HAS_CERTIFICATE_STAGE -> { return questAttr.getB(""HAS_CERTIFICATE""); } default -> { return false; } } } public static boolean hasGang(Player p) { if(isPhoenixGang(p)) return true; if(isBlackArmGang(p)) return true; return false; } public static boolean isPhoenixGang(Player p) { return p.getO(""ThievingGang"") != null && ((String)p.getO(""ThievingGang"")).equalsIgnoreCase(""Phoenix""); } public static boolean isBlackArmGang(Player p) { return p.getO(""ThievingGang"") != null && ((String)p.getO(""ThievingGang"")).equalsIgnoreCase(""Black""); } public static void setStage(Player p, int questStage) { p.getQuestManager().setStage(Quest.SHIELD_OF_ARRAV, questStage); saveStageToPlayerSave(p, questStage); } public static void setGang(Player p, String gang) {//""Phoenix"", ""Black"", ""None"" p.save(""ThievingGang"", gang); } @Override public void complete(Player player) { player.getInventory().addCoins(1200); sendQuestCompleteInterface(player, 11164); } public static ObjectClickHandler handleBookShelfClick = new ObjectClickHandler(new Object[]{2402, 6916, 15542, 15543, 15544, 23091, 23092, 23102, 24281, 24282, 31207, 35763}, e -> { Player p = e.getPlayer(); if (e.getObject().getId() == 2402) if (!p.getInventory().containsItem(757)) { p.getInventory().addItem(757, 1); p.getPackets().sendGameMessage(""You found the book, \""Shield Of Arrav\"".""); if (p.getQuestManager().getStage(Quest.SHIELD_OF_ARRAV) == ShieldOfArrav.FIND_BOOK_STAGE) p.startConversation(new Dialogue().addPlayer(HeadE.HAPPY_TALKING, ""Aha, 'The Shield Of Arrav'! Exactly what I was looking for."")); } else p.getPackets().sendGameMessage(""You already found the book, \""Shield Of Arrav\"".""); else { p.getPackets().sendGameMessage(""You search the books...""); p.getPackets().sendGameMessage(""You find nothing of interest to you.""); } }); public static ItemClickHandler handleClickOnArravBook = new ItemClickHandler(new Object[] { 757 }, new String[] { ""Read"" }, e -> BookShieldOfArrav.openBook(e.getPlayer())); public static ItemClickHandler handleClickOnIntelReport = new ItemClickHandler(new Object[] { 761 }, new String[] { ""Read"" }, e -> e.getPlayer().sendMessage(""It seems to have intel on the Phoenix gang"")); public static ObjectClickHandler handlePhoenixGangDoor = new ObjectClickHandler(new Object[]{2397}, e -> { if (e.getObject().getTile().matches(Tile.of(3247, 9779, 0))) { if (e.getOption().equalsIgnoreCase(""open"")) { if (!ShieldOfArrav.isStageInPlayerSave(e.getPlayer(), ShieldOfArrav.JOINED_PHOENIX_STAGE) && e.getPlayer().getY() > e.getObject().getY()) { e.getPlayer().startConversation(new Dialogue().addNPC(644, HeadE.FRUSTRATED, ""Hey! You can't go in there. Only authorised personnel of"" + "" the VTAM Corporation are allowed beyond this point."")); return; } Doors.handleDoor(e.getPlayer(), e.getObject()); } return; } Doors.handleDoor(e.getPlayer(), e.getObject()); }); public static ObjectClickHandler handleBlackArmGangDoor = new ObjectClickHandler(new Object[]{2399}, e -> { if (e.getObject().getTile().matches(Tile.of(3185, 3388, 0))) { if (e.getOption().equalsIgnoreCase(""open"")) { if (!ShieldOfArrav.isStageInPlayerSave(e.getPlayer(), ShieldOfArrav.JOINED_BLACK_ARM_STAGE) && e.getPlayer().getY() < e.getObject().getY()) { e.getPlayer().sendMessage(""The door seems to be locked from the inside.""); return; } Doors.handleDoor(e.getPlayer(), e.getObject()); } return; } Doors.handleDoor(e.getPlayer(), e.getObject()); }); public static ObjectClickHandler handleShieldChest = new ObjectClickHandler(new Object[]{2403, 2404}, e -> { Player p = e.getPlayer(); GameObject obj = e.getObject(); if (!obj.getTile().matches(Tile.of(3235, 9761, 0))) return; if (e.getOption().equalsIgnoreCase(""open"")) { p.setNextAnimation(new Animation(536)); p.lock(2); GameObject openedChest = new GameObject(obj.getId() + 1, obj.getType(), obj.getRotation(), obj.getX(), obj.getY(), obj.getPlane()); p.faceObject(openedChest); World.spawnObjectTemporary(openedChest, Ticks.fromMinutes(1)); } if (e.getOption().equalsIgnoreCase(""search"")) if (p.getInventory().containsItem(765)) p.sendMessage(""The chest is empty""); else if (p.getBank().containsItem(765, 1)) { p.startConversation(new Dialogue().addPlayer(HeadE.HAPPY_TALKING, ""Oh that's right, the right shield half is in my bank."")); p.sendMessage(""The chest is empty""); } else { p.sendMessage(""You get the right half of the shield of Arrav""); p.getInventory().addItem(765, 1); if (p.getQuestManager().getStage(Quest.SHIELD_OF_ARRAV) < HAS_SHIELD_STAGE) { setStage(p, HAS_SHIELD_STAGE); p.startConversation(new Dialogue().addPlayer(HeadE.HAPPY_TALKING, ""I should take this to King Roald"")); } } }); public static ObjectClickHandler handleBlackArmCupboard = new ObjectClickHandler(new Object[]{2400, 2401}, e -> { Player p = e.getPlayer(); GameObject obj = e.getObject(); if (!obj.getTile().matches(Tile.of(3189, 3385, 1))) return; if (e.getOption().equalsIgnoreCase(""open"")) { p.setNextAnimation(new Animation(536)); p.lock(2); GameObject openedChest = new GameObject(obj.getId() + 1, obj.getType(), obj.getRotation(), obj.getX(), obj.getY(), obj.getPlane()); p.faceObject(openedChest); World.spawnObjectTemporary(openedChest, Ticks.fromMinutes(1)); } if (e.getOption().equalsIgnoreCase(""shut"")) { p.setNextAnimation(new Animation(536)); p.lock(2); GameObject openedChest = new GameObject(obj.getId() - 1, obj.getType(), obj.getRotation(), obj.getX(), obj.getY(), obj.getPlane()); p.faceObject(openedChest); World.spawnObjectTemporary(openedChest, Ticks.fromMinutes(1)); } if (e.getOption().equalsIgnoreCase(""search"")) if (p.getInventory().containsItem(763)) p.sendMessage(""The cupboard is empty""); else if (p.getBank().containsItem(763, 1)) { p.startConversation(new Dialogue().addPlayer(HeadE.HAPPY_TALKING, ""Oh that's right, the right shield half is in my bank."")); p.sendMessage(""The cupboard is empty""); } else { p.sendMessage(""You get the left half of the shield of Arrav""); p.getInventory().addItem(763, 1); if (p.getQuestManager().getStage(Quest.SHIELD_OF_ARRAV) < HAS_SHIELD_STAGE) { setStage(p, HAS_SHIELD_STAGE); p.startConversation(new Dialogue().addPlayer(HeadE.HAPPY_TALKING, ""I should take this to King Roald"")); } } }); public static ObjectClickHandler handleWeaponsStoreDoor = new ObjectClickHandler(new Object[]{2398}, e -> { GameObject obj = e.getObject(); if (!obj.getTile().matches(Tile.of(3251, 3386, 0))) return; if (e.getPlayer().getInventory().containsItem(759, 1) || e.getPlayer().getY() < obj.getY()) Doors.handleDoor(e.getPlayer(), e.getObject()); else e.getPlayer().sendMessage(""The door appears to need a key""); }); public static ItemOnItemHandler handleCertificates = new ItemOnItemHandler(11174, new int[]{11173}, e -> { if (e.getPlayer().getQuestManager().getStage(Quest.SHIELD_OF_ARRAV) >= ShieldOfArrav.HAS_CERTIFICATE_STAGE) { e.getPlayer().getInventory().deleteItem(e.getItem1().getId(), 1); e.getPlayer().getInventory().deleteItem(e.getItem2().getId(), 1); e.getPlayer().getInventory().addItem(769, 1); } else e.getPlayer().sendMessage(""You don't know what these papers are for...""); }); public static ItemClickHandler handleClickOnCertificate = new ItemClickHandler(new Object[] { 11173, 11174, 769 }, e -> { if (e.getOption().equalsIgnoreCase(""read"")) e.getPlayer().sendMessage(""This authenticates the Shield Of Arrav""); }); public static PickupItemHandler handlePhoenixBowsPickup = new PickupItemHandler(new Object[] { 767 }, Tile.of(3245, 3385, 1), e -> { List npcs = World.getNPCsInChunkRange(e.getPlayer().getChunkId(), 1); for (NPC npc : npcs) if (npc.getId() == 643) { switch (Utils.random(1, 4)) { case 1: npc.forceTalk(""Get your hands off!""); break; case 2: npc.forceTalk(""Don't touch that!""); break; case 3: npc.forceTalk(""Hey, that's Phoenix Gang property!""); break; } npc.faceEntity(e.getPlayer()); e.cancelPickup(); } }); public static NPCClickHandler handleWeaponsMaster = new NPCClickHandler(new Object[] { 643 }, new String[] { ""Talk-to"" }, e -> e.getPlayer().startConversation(new Conversation(e.getPlayer()) { { addNPC(e.getNPCId(), HeadE.FRUSTRATED, ""I would die before I let anyone take a weapon from here...""); addPlayer(HeadE.NERVOUS, ""Is that so?""); addNPC(e.getNPCId(), HeadE.FRUSTRATED, ""Yes it is.""); addPlayer(HeadE.NERVOUS, ""...""); addNPC(e.getNPCId(), HeadE.NERVOUS, "" . ""); addPlayer(HeadE.NERVOUS, "" . ""); create(); } })); public static ItemOnPlayerHandler giveCerts = new ItemOnPlayerHandler(new Object[] { 759, 11173, 11174 }, e -> { if (e.getItem().getAmount() >= 1) { if (e.getTarget().getInventory().getFreeSlots() >= 1) { e.getPlayer().lock(); e.getPlayer().getInventory().deleteItem(e.getItem().getId(), 1); WorldTasks.delay(0, () -> { e.getPlayer().setNextAnimation(new Animation(881)); e.getTarget().getInventory().addItem(e.getItem().getId(), 1); if (e.getTarget().isIronMan()) e.getPlayer().sendMessage(""They stand alone, but not this once!""); e.getPlayer().unlock(); }); } else { e.getTarget().sendMessage(""You need to make space in your inventory""); e.getPlayer().sendMessage(e.getTarget().getUsername() + "" does not have enough space.""); } } else e.getPlayer().sendMessage(""You need at least 1 of this item to give!""); }); /** * When the player logs in, the Shield Of Arrav display case is updated based on quest completion. * Also if the player does not have a gang upon completion they must be assigned one * --Do this with Minas-- */ // public static LoginHandler onLogin = new LoginHandler() { // @Override // public void handle(LoginEvent e) { // if (e.getPlayer().isQuestComplete(Quest.SHIELD_OF_ARRAV)) // e.getPlayer().getVars().setVarBit(5394, 1); // else // e.getPlayer().getVars().setVarBit(5394, 0); // } // }; }" "package com.rs.game.content.quests.shieldofarrav; public class StravenShieldOfArravD extends Conversation { private final int STRAVEN = 644; public StravenShieldOfArravD(Player p) { super(p); if (p.getQuestManager().getStage(Quest.SHIELD_OF_ARRAV) == ShieldOfArrav.PROVING_LOYALTY_PHOENIX_STAGE) { conversationOptions(p); return; } if (ShieldOfArrav.isPhoenixGang(p)) addNPC(STRAVEN, HeadE.HAPPY_TALKING, ""Greetings, fellow gang member.""); else { addPlayer(HeadE.TALKING_ALOT, ""What's through that door?""); addNPC(STRAVEN, HeadE.FRUSTRATED, ""Hey! You can't go in there. Only authorised personnel of the VTAM Corporation are allowed beyond this point.""); } conversationOptions(p); } public StravenShieldOfArravD(Player p, boolean restartingConversation) { super(p); conversationOptions(p); } private void conversationOptions(Player p) { if (ShieldOfArrav.isStageInPlayerSave(p, ShieldOfArrav.JOINED_BLACK_ARM_STAGE)) { addNPC(STRAVEN, HeadE.SECRETIVE, ""You REALLY shouldn't be in here...""); addPlayer(HeadE.FRUSTRATED, ""I guess not.""); } else if (ShieldOfArrav.isPhoenixGang(p)) addOptions(""Select an option:"", new Options() { @Override public void create() { if (p.getInventory().containsItem(759)) option(""I've heard you've got some cool treasures in this place."", new Dialogue() .addNPC(STRAVEN, HeadE.HAPPY_TALKING, ""Oh yeah, we've all stolen some stuff in our time. Those candlesticks down here, for example,"" + "" were quite a challenge to get out of the palace."") .addPlayer(HeadE.HAPPY_TALKING, ""And the shield of Arrav? I heard you got that!"") .addNPC(STRAVEN, HeadE.TALKING_ALOT, ""Whoa...that's a blast from the past! We stole that years and years ago! We don't even have all the shield any more."") .addNPC(STRAVEN, HeadE.TALKING_ALOT, ""About five years ago we had a massive fight in our gang and the shield got broken in half during that "" + ""fight. "") .addNPC(STRAVEN, HeadE.TALKING_ALOT, ""Shortly after the fight some gang members decided they didn't want to be part of our gang anymore. "" + ""So they split off to form their own gang. The Black Arm Gang."") .addNPC(STRAVEN, HeadE.TALKING_ALOT, ""On their way out they looted what treasures they could from us - which included "" + ""one of the halves of the shield. We've been rivals with the Black Arms ever since."") .addNext(() -> p.startConversation(new StravenShieldOfArravD(p, true).getStart()))); else option(""I lost my weapons store key."", new Dialogue() .addPlayer(HeadE.SAD_MILD_LOOK_DOWN, ""I lost my weapons store key."") .addNPC(STRAVEN, HeadE.SKEPTICAL, ""Indeed you have."") .addSimple(""He hands you another key"", () -> p.getInventory().addItem(759, 1, true))); option(""Any suggestions for where I can go thieving?"", new Dialogue() .addNPC(STRAVEN, HeadE.HAPPY_TALKING, ""You can always try the marketplace in Ardougne. LOTS of opportunity there!"") .addNext(() -> p.startConversation(new StravenShieldOfArravD(p, true).getStart()))); option(""Where's the Black Arm Gang hideout?"", new Dialogue() .addPlayer(HeadE.TALKING_ALOT, ""Where's the Black Arm Gang hideout? I wanna go sabotage 'em!"") .addNPC(STRAVEN, HeadE.AMAZED_MILD, ""That would be a little tricky; their security is pretty good. Not as good as ours, obviously."") .addNPC(STRAVEN, HeadE.AMAZED_MILD, ""But still good. If you really want to go there, it's in the alleyway to the west as you come in the "" + ""south gate."") .addNPC(STRAVEN, HeadE.TALKING_ALOT, ""One of our operatives is often near the alley - a red haired tramp, goes by the name of Charlie. "" + ""He may be able to give you some ideas."") .addPlayer(HeadE.HAPPY_TALKING, ""Thanks for the help!"") .addNext(() -> p.startConversation(new StravenShieldOfArravD(p, true).getStart()))); option(""Farewell.""); } }); else if (ShieldOfArrav.isStageInPlayerSave(p, ShieldOfArrav.PROVING_LOYALTY_PHOENIX_STAGE)) { addNPC(STRAVEN, HeadE.SECRETIVE, ""How's your little mission going?""); if (p.getInventory().containsItem(761)) { addPlayer(HeadE.HAPPY_TALKING, ""I have the intelligence report!""); addNPC(STRAVEN, HeadE.CALM_TALK, ""Let's see it then.""); addSimple(""You hand over the report. The man reads the report.""); addNPC(STRAVEN, HeadE.HAPPY_TALKING, ""Yes. Yes, this is very good. Very well, then! You can join the Phoenix Gang! I am Straven, one of the gang leaders.""); addPlayer(HeadE.HAPPY_TALKING, ""Nice to meet you.""); addNPC(STRAVEN, HeadE.HAPPY_TALKING, ""You now have access to the inner sanctum of our subterranean hideout, and our weapons supply depot round the "" + ""front of this building."", () -> { p.getInventory().deleteItem(761, 1); ShieldOfArrav.setStage(p, ShieldOfArrav.JOINED_PHOENIX_STAGE); ShieldOfArrav.setGang(p, ""Phoenix""); p.getInventory().addItem(759, 1); }); } else if (p.getBank().containsItem(761, 1)) { addPlayer(HeadE.HAPPY_TALKING, ""I have the intelligence report!""); addNPC(HeadE.CALM_TALK, ""Let's see it then.""); addPlayer(HeadE.WORRIED, ""Oh, its in my bank.""); addNPC(HeadE.CALM_TALK, ""I'll wait here.""); } else { addPlayer(HeadE.SAD_MILD_LOOK_DOWN, ""I haven’t managed to find the report yet...""); addNPC(HeadE.SECRETIVE, ""You need to kill Jonny the Beard, who should be in the Blue Moon Inn. ...I would guess. Not being a member of "" + ""the Phoenix Gang and all.""); } } else if (ShieldOfArrav.isStageInPlayerSave(p, ShieldOfArrav.AFTER_BRIBE_BARAEK_STAGE)) addOptions(""Choose an option:"", new Options() { @Override public void create() { option(""I know who you are!"", new Dialogue() .addPlayer(HeadE.AMAZED_MILD, ""I know who you are!"") .addNPC(STRAVEN, HeadE.SKEPTICAL, ""Really. Well? Who are we then?"") .addPlayer(HeadE.TALKING_ALOT, ""This is the headquarters of the Phoenix Gang, the most powerful crime syndicate this city has ever seen!"") .addNPC(STRAVEN, HeadE.ANGRY, ""No, this is a legitimate business run by legitimate businessmen. Supposing we were this 'Phoenix Gang', "" + ""however, what would you want with us?"") .addOptions(""Select an option"", new Options() { @Override public void create() { option(""I'd like to offer you my services."", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""I'd like to offer you my services."") .addNPC(STRAVEN, HeadE.FRUSTRATED, ""You mean you'd like to join the Phoenix Gang? Well, obviously I can't speak for them, "" + ""but the Phoenix Gang doesn't let people join just like that."") .addNPC(STRAVEN, HeadE.FRUSTRATED, ""You can't be too careful, you understand. Generally someone has to prove their loyalty "" + ""before they can join."") .addPlayer(HeadE.SKEPTICAL_THINKING, ""How would I go about doing that?"") .addNPC(STRAVEN, HeadE.FRUSTRATED, ""Obviously, I would have no idea about that. Although having said that, a rival gang of ours, "" + ""er, theirs, called the Black Arm Gang is supposedly meeting a contact from Port Sarim today in the Blue Moon Inn. "") .addNPC(STRAVEN, HeadE.FRUSTRATED, "" The Blue Moon Inn is just by the south entrance to this city, and supposedly the name "" + ""of the contact is Jonny the Beard."") .addNPC(STRAVEN, HeadE.FRUSTRATED, ""OBVIOUSLY I know NOTHING about the dealings of the Phoenix Gang, but I bet if SOMEBODY "" + ""were to kill him and bring back his intelligence report, they would be considered loyal enough to join."") .addPlayer(HeadE.TALKING_ALOT, ""I'll get right on it."") .addNext(() -> ShieldOfArrav.setStage(p, ShieldOfArrav.PROVING_LOYALTY_PHOENIX_STAGE))); option(""I want nothing. I was just making sure you were them."", new Dialogue() .addPlayer(HeadE.SCARED, ""I want nothing. I was just making sure you were them."") .addNPC(STRAVEN, HeadE.ANGRY, ""Well, then get lost and stop wasting my time. ...if you know what's good for you."")); } })); option(""How do I get a job with the VTAM corporation?"", new Dialogue() .addPlayer(HeadE.SECRETIVE, ""How do I get a job with the VTAM corporation?"") .addNPC(STRAVEN, HeadE.CALM_TALK, ""Get a copy of the Varrock Herald. If we have any positions right now, they'll be advertised "" + ""in there."") .addNext(() -> p.startConversation(new StravenShieldOfArravD(p, true).getStart()))); option(""Why not?"", new Dialogue() .addPlayer(HeadE.SECRETIVE, ""Why not?"") .addNPC(STRAVEN, HeadE.SECRETIVE, "" Sorry. That's classified information."") .addNext(() -> p.startConversation(new StravenShieldOfArravD(p, true).getStart()))); option(""Farewell.""); } }); else ; } }" "package com.rs.game.content.quests.templeofikov; @PluginEventHandler public class FireWarrior extends OwnedNPC { public FireWarrior(Player p, int id, Tile tile) { super(p, id, tile, true); } @Override public void sendDeath(Entity source) { super.sendDeath(source); if(source instanceof Player p) p.getQuestManager().getAttribs(Quest.TEMPLE_OF_IKOV).setB(""FireWarriorKilled"", true); } @Override public void handlePreHit(final Hit hit) { super.handlePreHit(hit); if(hit.getSource() instanceof Player p && p.getEquipment().getAmmoId() == 78 && RangedWeapon.forId(p.getEquipment().getWeaponId()).getAmmos().contains(AmmoType.ICE_ARROWS)) return; hit.setDamage(0); } }" "package com.rs.game.content.quests.templeofikov; @PluginEventHandler public class IkovDungeon { public static NPCDeathHandler handlePendant = new NPCDeathHandler(new Object[] { 274, 275 }, e -> { if (e.getKiller() instanceof Player p && p.getQuestManager().isComplete(Quest.TEMPLE_OF_IKOV)) e.getNPC().sendDrop(p, new Item(87)); }); public static ObjectClickHandler handleIkovEmergencyExitLadder = new ObjectClickHandler(new Object[] { 32015 }, Tile.of(2637, 9808, 0), e -> e.getPlayer().useLadder(Tile.of(2637, 3409, 0))); public static ItemOnObjectHandler leverIceDoor = new ItemOnObjectHandler(false, new Object[] { 86 }, new Object[] { 83 }, e -> { e.getPlayer().getInventory().removeItems(new Item(83, 1)); e.getObject().setIdTemporary(e.getObjectId() + 1, Ticks.fromSeconds(30)); }); public static ObjectClickHandler handleIceLever = new ObjectClickHandler(new Object[]{ 87 }, e -> { //e.getObject().setId(36); e.getPlayer().sendMessage(""You pull the lever and hear a click.""); if(e.getPlayer().getQuestManager().getStage(Quest.TEMPLE_OF_IKOV) == TempleOfIkov.HELP_LUCIEN) e.getPlayer().getQuestManager().getAttribs(Quest.TEMPLE_OF_IKOV).setB(""LeverIcePulled"", true); }); public static ObjectClickHandler handleLadderToMcGruborsShed = new ObjectClickHandler(new Object[]{ 32015 }, Tile.of(2659, 9892, 0), e -> e.getPlayer().useLadder(Tile.of(2658, 3492, 0))); public static ObjectClickHandler handleFireWarriorDoorWithFight = new ObjectClickHandler(new Object[]{ 93 }, e -> { if(e.getPlayer().getQuestManager().getAttribs(Quest.TEMPLE_OF_IKOV).getB(""FireWarriorKilled"")) { handleDoor(e.getPlayer(), e.getObject()); return; } for(NPC npc : World.getNPCsInChunkRange(e.getPlayer().getChunkId(), 3)) if(npc instanceof FireWarrior warrior && warrior.getOwner() == e.getPlayer()) return; NPC warrior = new FireWarrior(e.getPlayer(), 277, e.getPlayer().getTile().transform(0, -1)); warrior.faceEntity(e.getPlayer()); warrior.forceTalk(""You will not pass!""); warrior.setRandomWalk(false); }); public static ObjectClickHandler handleArmadylWall = new ObjectClickHandler(new Object[]{1586}, e -> Doors.handleDoor(e.getPlayer(), e.getObject(), -1)); public static PickupItemHandler handleArmaStaffPickup = new PickupItemHandler(new Object[] { 84 }, Tile.of(2638, 9906, 0), e -> { for (NPC npc : World.getNPCsInChunkRange(e.getPlayer().getChunkId(), 3)) if (npc.getName().contains(""Guardian of Armadyl"") && npc.lineOfSightTo(e.getPlayer(), false)) { e.cancelPickup(); e.getPlayer().startConversation(new Dialogue().addSimple(""An Armadyl Guardian glares at you..."")); } }); public static NPCClickHandler handleFireWarriorTalk = new NPCClickHandler(new Object[]{277}, new String[]{""Talk-to""}, e -> { int NPC = e.getNPCId(); e.getPlayer().startConversation(new Dialogue() .addNPC(NPC, HeadE.ANGRY, ""Who dares to enter the Temple of Ikov!"") .addOptions(""Choose an option:"", new Options() { @Override public void create() { option(""A mighty hero!"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""A mighty hero!"") .addNPC(NPC, HeadE.CALM_TALK, ""Pathetic fool! Prepare to die!"") .addNext(()->{ for(NPC npc : World.getNPCsInChunkRange(e.getPlayer().getChunkId(), 3)) if(npc instanceof FireWarrior warrior && warrior.getOwner() == e.getPlayer()) warrior.setTarget(e.getPlayer()); }) ); option(""A humble pilgrim."", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""A humble pilgrim."") .addNPC(NPC, HeadE.CALM_TALK, ""I haven't seen a pilgrim for thousands of years! Temple is closed!"") ); } })); }); public static NPCClickHandler handleGaurdianTalk = new NPCClickHandler(new Object[]{274, 275}, new String[]{""Talk-to""}, e -> { if(e.getPlayer().getEquipment().getAmuletId() == 86) {//Lucien amulet e.getPlayer().startConversation(new Dialogue().addNPC(e.getNPCId(), HeadE.FRUSTRATED, ""Thou art a foul agent of Lucien! Such an agent must die!"")); WorldTasks.delay(3, () -> e.getNPC().setTarget(e.getPlayer())); return; } e.getPlayer().startConversation(new GaurdianArmadylTempleOfIkov(e.getPlayer(), e.getNPC()).getStart()); }); public static ObjectClickHandler handleFireWarriorLever = new ObjectClickHandler(new Object[]{ 91 }, e -> { if(e.getOption().equals(""Search for traps"")) { if(e.getPlayer().getSkills().getLevel(Skills.THIEVING) >= 42) { e.getPlayer().getTempAttribs().setB(""IkovLeverTrapDisabled"", true); e.getPlayer().sendMessage(""You disable to trap...""); return; } e.getPlayer().sendMessage(""This trap requires 42 thieving...""); } if(e.getOption().equals(""Pull"")) { if(e.getPlayer().getTempAttribs().getB(""IkovLeverTrapDisabled"")) { e.getObject().setIdTemporary(36, Ticks.fromSeconds(20)); e.getPlayer().getQuestManager().getAttribs(Quest.TEMPLE_OF_IKOV).setB(""IkovFireWarriorEntranceOpen"", true); return; } e.getPlayer().applyHit(new Hit(20, Hit.HitLook.TRUE_DAMAGE)); e.getPlayer().sendMessage(""You activate a trap!""); } }); public static ObjectClickHandler handleIceArrowChests = new ObjectClickHandler(new Object[]{ 35123 }, e -> { if(e.getOption().equals(""Search"") && e.getPlayer().getTempAttribs().getL(""IkovChest"" + e.getObject().getX()) < World.getServerTicks()) { e.getPlayer().getInventory().addItem(78, Utils.random(0, 6)); e.getPlayer().getTempAttribs().setL(""IkovChest"" + e.getObject().getX(), World.getServerTicks() + (long)Ticks.fromSeconds(30)); } }); public static ObjectClickHandler handleFireWarriorDoorByLever = new ObjectClickHandler(new Object[]{ 92 }, e -> { if(e.getPlayer().getQuestManager().getAttribs(Quest.TEMPLE_OF_IKOV).getB(""IkovFireWarriorEntranceOpen"")) { handleDoor(e.getPlayer(), e.getObject()); return; } e.getPlayer().sendMessage(""The door is firmly locked...""); }); public static ObjectClickHandler handleFearGate = new ObjectClickHandler(new Object[]{ 94, 95 }, e -> { if(e.getPlayer().getEquipment().getAmuletId() == 86 || e.getPlayer().getY() >= e.getObject().getY()) { handleDoubleDoor(e.getPlayer(), e.getObject()); return; } e.getPlayer().faceNorth(); e.getPlayer().startConversation(new Dialogue().addPlayer(HeadE.SCARED, ""Gah!"")); e.getPlayer().sendMessage(""An immense feeling of terror overwhelms you...""); }); public static ObjectClickHandler handleSouthIceGate = new ObjectClickHandler(new Object[]{ 89, 90 }, e -> { if(e.getPlayer().isQuestComplete(Quest.TEMPLE_OF_IKOV) || e.getPlayer().getQuestManager().getAttribs(Quest.TEMPLE_OF_IKOV).getB(""LeverIcePulled"")) { handleDoubleDoor(e.getPlayer(), e.getObject()); return; } e.getPlayer().faceSouth(); e.getPlayer().startConversation(new Dialogue().addPlayer(HeadE.SKEPTICAL_THINKING, ""It seems locked..."")); e.getPlayer().sendMessage(""The door is firmly shut...""); }); public static PlayerStepHandler handleBridge = new PlayerStepHandler(new Tile[] { Tile.of(2650, 9828, 0), Tile.of(2650, 9829, 0), Tile.of(2647, 9828, 0), Tile.of(2647, 9829, 0) }, e -> { Player p = e.getPlayer(); if(p.getTempAttribs().getB(""CrossingIkovBridge"")) return; p.lock(5); p.setRunHidden(false); p.getTempAttribs().setB(""CrossingIkovBridge"", true); WorldTasks.scheduleTimer(i -> { if(i == 1) p.addWalkSteps(Tile.of((e.getTile().getX() == 2650 ? 2647 : 2650), e.getTile().getY(), 0), 4, false); if(i == 2 && p.getWeight() > 0) { p.resetWalkSteps(); p.sendMessage(""The bridge gives way under the weight...""); p.setNextAnimation(new Animation(4280)); p.applyHit(new Hit(20, Hit.HitLook.TRUE_DAMAGE), 1); } if(i == 4 && p.getWeight() > 0) { p.sendMessage(""Good thing the lava was shallow!""); p.tele(Tile.of(2648, 9826, 0)); p.setRunHidden(true); p.getTempAttribs().removeB(""CrossingIkovBridge""); return false; } if(i == 5) { p.setRunHidden(true); p.getTempAttribs().removeB(""CrossingIkovBridge""); return false; } return true; }); }); }" "package com.rs.game.content.quests.templeofikov; @PluginEventHandler public class LucienVarrockMob extends NPC { private static final int NPC = 8347; public LucienVarrockMob(int id, Tile tile) { super(id, tile, false); } @Override public void sendDeath(Entity source) { super.sendDeath(source); if(source instanceof Player p && p.getQuestManager().getStage(Quest.TEMPLE_OF_IKOV) == TempleOfIkov.HELP_LUCIEN) { p.startConversation(new Dialogue().addNPC(NPC, HeadE.FRUSTRATED, ""You have defeated me for now! I shall reappear in the North!"", ()->{ TempleOfIkov.setIkovLucienSide(p, false); WorldTasks.delay(3, () -> p.getQuestManager().completeQuest(Quest.TEMPLE_OF_IKOV)); })); } } @Override public boolean canBeAttackedBy(Player player) { if(player.getEquipment().getAmuletId() == 87)//Armadyl pendant return true; this.faceEntity(player); player.faceEntity(this); WorldTasks.delay(1, () -> this.setNextAnimation(new Animation(805))); player.startConversation(new Dialogue() .addNPC(NPC, HeadE.CALM_TALK, ""You don't want to attack me. I am your friend."") .addSimple(""You decide to not attack Lucien. He is your friend."") ); return false; } public static NPCInstanceHandler toFunc = new NPCInstanceHandler(8347, LucienVarrockMob::new); }" "package com.rs.game.content.quests.templeofikov; @QuestHandler( quest = Quest.TEMPLE_OF_IKOV, startText = ""Speak to Lucien in the Flying Horse Inn, in the north-west of East Ardougne."", itemsText = ""Light source, 20 limpwurt roots."", combatText = ""Be able to defeat a level 77 foe."", rewardsText = ""10,500 Ranged XP
8,000 Fletching XPAccess to the Temple of Ikov"", completedStage = 2 ) @PluginEventHandler public class TempleOfIkov extends QuestOutline { public final static int NOT_STARTED = 0; public final static int HELP_LUCIEN = 1; public final static int QUEST_COMPLETE = 2; @Override public List getJournalLines(Player player, int stage) { ArrayList lines = new ArrayList<>(); switch (stage) { case NOT_STARTED -> { lines.add(""A mysterious stranger called Lucien asks you to go on a mission""); lines.add(""deep under the Temple of Ikov in central Kandarin. He wants you""); lines.add(""to retrieve an artifact known as the Staff of Armadyl. Towards""); lines.add(""the end of the quest you are presented with a choice on how to""); lines.add(""complete the quest.""); lines.add(""""); lines.add(""You can start this quest by talking to Lucien in the north""); lines.add(""northwestern part of East Ardougne in The Flying Horse Inn.""); lines.add(""""); lines.add(""~~~Requirements~~~""); lines.add((player.getSkills().getLevel(Constants.THIEVING) >= 42 ? """" : """") + ""42 Thieving""); lines.add(""""); } case HELP_LUCIEN -> { lines.add(""I must solve the puzzle of the Temple of Ikov dungeon to either""); lines.add(""help Lucien or go against him...""); lines.add(""""); } case QUEST_COMPLETE -> { if(isLucienSide(player)) lines.add(""You chose to help Lucien...""); if(!isLucienSide(player)) lines.add(""You chose to go against Lucien...""); lines.add(""""); lines.add(""QUEST COMPLETE!""); } default -> lines.add(""Invalid quest stage. Report this to an administrator.""); } return lines; } public static void setIkovLucienSide(Player p, boolean isLucienSide) { p.save(""IkovQuestHelpedLucien"", isLucienSide); } public static boolean isLucienSide(Player p) { return p.getBool(""IkovQuestHelpedLucien""); } public static boolean meetsRequirements(Player p) { return p.getSkills().getLevel(Skills.THIEVING) >= 42; } @Override public void complete(Player player) { player.sendMessage(""Congratulations! You have completed: 'Temple of Ikov'.""); player.getSkills().addXpQuest(Constants.RANGE, 10_500); player.getSkills().addXpQuest(Constants.FLETCHING, 8_000); sendQuestCompleteInterface(player, 855); } }" "package com.rs.game.content.quests.templeofikov.dialogues; @PluginEventHandler public class GaurdianArmadylTempleOfIkov extends Conversation { class HandleBaptism extends Conversation { public HandleBaptism(Player player, NPC guardian) { super(player); int NPC = guardian.getId(); addNPC(NPC, HeadE.CALM_TALK, ""Okay, I shall cleanse you with holy water...""); addSimple(""He splashes water on your face..."", ()->{ guardian.setLockedForTicks(4); guardian.faceEntity(player); WorldTasks.delay(1, () -> guardian.setNextAnimation(new Animation(805))); }); addNPC(NPC, HeadE.CALM_TALK, ""You have been cleansed!""); addNPC(NPC, HeadE.CALM_TALK, ""Lucien must not get hold of the staff! He would become too powerful!""); addNPC(NPC, HeadE.CALM_TALK, ""Hast thou come across this foul beast? If you know where he is you can help us defeat him.""); addOptions(""Choose an option:"", new Options() { @Override public void create() { option(""Ok! I'll help!"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Ok! I'll help!"") .addNPC(NPC, HeadE.CALM_TALK, ""So he is close by?"") .addPlayer(HeadE.HAPPY_TALKING, ""Yes!"") .addNPC(NPC, HeadE.CALM_TALK, ""He must be after the staff. Here, take this pendant;"" + "" wear it to show your allegiance to us, then defeat him in combat. I doubt "" + ""you'll kill him, but it should discourage him for a while."") .addItem(87, ""The Gaurdian gives you a pendant..."", ()->{ player.getInventory().addItem(new Item(87, 1), true); player.getQuestManager().getAttribs(Quest.TEMPLE_OF_IKOV).setB(""KnowsGuardianOffer"", true); }) ); option(""No! I shall not turn against my employer!"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""No! I shall not turn against my employer!"") .addNPC(NPC, HeadE.CALM_TALK, ""Fool! You will die for your sins!"", ()-> WorldTasks.delay(3, () -> guardian.setTarget(player))) ); option(""I need to think."", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""I need to think."") .addNPC(NPC, HeadE.CALM_TALK, ""Linger a while and be at peace."") ); } }); } } public GaurdianArmadylTempleOfIkov(Player player, NPC guardian) { super(player); int NPC = guardian.getId(); switch(player.getQuestManager().getStage(Quest.TEMPLE_OF_IKOV)) { default -> { addPlayer(HeadE.HAPPY_TALKING, ""I don't think I belong here""); addNPC(NPC, HeadE.CALM_TALK, ""Perhaps not pilgrim...""); } case HELP_LUCIEN -> { if(player.getQuestManager().getAttribs(Quest.TEMPLE_OF_IKOV).getB(""KnowsGuardianOffer"")) { addNPC(NPC, HeadE.CALM_TALK, ""Have you rid us of Lucien yet?""); addPlayer(HeadE.HAPPY_TALKING, ""Not yet.""); addNPC(NPC, HeadE.CALM_TALK, ""Hurry friend! Time is against us!""); if(player.getInventory().containsItem(87, 1)) return; addPlayer(HeadE.HAPPY_TALKING, ""Oh, and I lost that pendant...""); addNPC(NPC, HeadE.CALM_TALK, ""Okay, I have another.""); addItem(87, ""The Gaurdian gives you a pendant..."", ()-> player.getInventory().addItem(new Item(87, 1), true)); return; } addNPC(NPC, HeadE.CALM_TALK, ""Thou hast ventured deep into the tunnels, you have reached the temple of our master. It is many ages since a pilgrim has come here.""); addOptions(""Choose an option:"", new Options() { @Override public void create() { option(""I seek the Staff of Armadyl."", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""I seek the Staff of Armadyl."") .addNPC(NPC, HeadE.CALM_TALK, ""We are the guardians of the staff, our fathers were guardians and our father's fathers before that. Why dost thou seek it?"") .addOptions(""Choose an option:"", new Options() { @Override public void create() { option(""Lucien will give me a grand reward for it!"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Lucien will give me a grand reward for it!"") .addNPC(NPC, HeadE.CALM_TALK, ""Thou art working for that spawn of evil?! Fool. You must be cleansed to save your soul!"") .addOptions(""Choose an option:"", new Options() { @Override public void create() { option(""How dare you call me a fool?"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""How dare you call me a fool?"") .addNPC(NPC, HeadE.CALM_TALK, ""We must cleanse the temple!"", ()-> WorldTasks.delay(3, () -> guardian.setTarget(player))) ); option(""I just thought of something I must do!"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""I just thought of something I must do!"") .addNPC(NPC, HeadE.CALM_TALK, ""An agent of evil cannot be allowed to leave!"", ()-> WorldTasks.delay(3, () -> guardian.setTarget(player))) ); option(""You're right, it's time for my yearly bath."", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""You're right, it's time for my yearly bath."") .addNext(() -> player.startConversation(new HandleBaptism(player, guardian).getStart())) ); } }) ); option(""Give it to me!"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Give it to me!"") .addNPC(NPC, HeadE.CALM_TALK, ""The staff is sacred! You will not have it!"") ); option(""I collect rare and powerful artefacts."", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""I collect rare and powerful artefacts."") .addNPC(NPC, HeadE.CALM_TALK, ""Your worldy greed has darkened your soul!"") ); } }) ); option(""Out of my way fool!"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Out of my way fool!"") .addNPC(NPC, HeadE.CALM_TALK, ""I may be a fool but I will not step aside!"") .addOptions(""Choose an option:"", new Options() { @Override public void create() { option(""Why not?"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Why not?"") .addNPC(NPC, HeadE.CALM_TALK, ""Only members of our order are allowed to handle the staff."") ); option(""Then you must die!"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Then you must die!"") .addNPC(NPC, HeadE.CALM_TALK, ""So be it!"", ()-> WorldTasks.delay(3, () -> guardian.setTarget(player))) ); option(""You're right, I will go now."", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""You're right, I will go now."") .addNPC(NPC, HeadE.CALM_TALK, ""That is a wise decision. Stay a while and let your soul be cleansed!"") ); } }) ); option(""What are your kind and what are you doing here?"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""What are your kind and what are you doing here?"") .addNPC(NPC, HeadE.CALM_TALK, ""We are the Guardians of Armadyl. We have kept the temple safe for many ages. The evil "" + ""in the dungeons seek what lies here. The Mahjarrat are the worst who seek what is within."") .addOptions(""Choose an option:"", new Options() { @Override public void create() { option(""What is the Armadyl?"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""What is the Armadyl?"") .addNPC(NPC, HeadE.CALM_TALK, ""Armadyl is the god we serve. We have been charged with guarding his sacred arctifacts until he requires them."") .addOptions(""Choose an option:"", new Options() { @Override public void create() { option(""Ah ok, thanks."", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Ah ok, thanks."") .addNPC(NPC, HeadE.CALM_TALK, ""Go in peace."") ); option(""Someone told me there were only three gods."", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Someone told me there were only three gods."") .addNPC(NPC, HeadE.CALM_TALK, ""Saradominists. Bleh. They only acknowledge those three. "" + ""There are at least twenty gods!"") ); } }) ); option(""Who are the Mahjarrat?"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Who are the Mahjarrat?"") .addNPC(NPC, HeadE.CALM_TALK, ""They are ancient and powerful beings of evil! it is said that they once had "" + ""great influence over this plane of existence, and that Zamorak was once of their kind. "") .addNPC(NPC, HeadE.CALM_TALK, ""They are far fewer in number now, but there are still some present in this world. "" + ""One such as Lucien would become nigh unstoppable if he were to possess the Staff of Armadyl"") .addOptions(""Choose an option:"", new Options() { @Override public void create() { option(""Did you say Lucien? It was Lucien that asked me to get the staff!"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Did you say Lucien? It was Lucien that asked me to get the staff!"") .addNPC(NPC, HeadE.CALM_TALK, ""You are a fool to be working for Lucien! Your soul must be cleansed to save you!"") .addPlayer(HeadE.HAPPY_TALKING, ""You're right, it's time for my yearly bath."") .addNext(() -> player.startConversation(new HandleBaptism(player, guardian).getStart())) ); option(""I hope you are doing a good job then!"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""I hope you are doing a good job then!"") .addNPC(NPC, HeadE.CALM_TALK, ""Do not fear! We are devoted to our purpose!"") ); } }) ); option(""Wow! You must be really old!"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Wow! You must be really old!"") .addNPC(NPC, HeadE.CALM_TALK, ""No! I am not old! my family has guarded the staff for many generations."") ); } }) ); } }); } } } }" "package com.rs.game.content.quests.templeofikov.dialogues; @PluginEventHandler public class LucienArdougneTempleOfIkov extends Conversation { private static final int NPC = 8345; class QuestPrompt extends Conversation { public QuestPrompt(Player player) { super(player); if(TempleOfIkov.meetsRequirements(player)) { addOptions(""Start Temple Of Ikov?"", new Options() { @Override public void create() { option(""Yes"", new Dialogue() .addPlayer(HeadE.LAUGH, ""This will probably be easy!"") .addNPC(NPC, HeadE.CALM_TALK, ""It's not as easy as it sounds. The monster can only be killed with a weapon of ice. There are many other dangers."") .addPlayer(HeadE.HAPPY_TALKING, ""I'm up for it!"") .addNPC(NPC, HeadE.CALM_TALK, ""You will need my pendent. Without it you will not be able to enter the Chamber of Fear."") .addItem(86, ""Lucien gives you his pendant"", () -> { player.getQuestManager().setStage(Quest.TEMPLE_OF_IKOV, HELP_LUCIEN); player.getInventory().addItem(new Item(86, 1), true); }) .addNPC(NPC, HeadE.CALM_TALK, ""I cannot stay here much longer. I will be west of the Grand Exchange in Varrock. I have a small holding up there."") ); option(""No"", new Dialogue()); } }); } if(!TempleOfIkov.meetsRequirements(player)) { addNPC(NPC, HeadE.CALM_TALK, ""A laugh you say? You do not seem to have the skill required...""); addNext(addNext(() -> player.getQuestManager().showQuestDetailInterface(Quest.TEMPLE_OF_IKOV))); } } } public LucienArdougneTempleOfIkov(Player player) { super(player); switch(player.getQuestManager().getStage(Quest.TEMPLE_OF_IKOV)) { case NOT_STARTED -> { Dialogue mainOptions = new Dialogue(); mainOptions.addOptions(""Choose an option:"", new Options() { @Override public void create() { option(""Why can't you get it yourself?"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Why can't you get it yourself?"") .addNPC(NPC, HeadE.CALM_TALK, ""The guardians of the Staff of Armadyl fear me! They have set up a magical barrier which even my power cannot overcome!"") .addNext(mainOptions) ); option(""That sounds like a laugh!"", new Dialogue() .addPlayer(HeadE.LAUGH, ""That sounds like a laugh!"") .addNext(() -> player.startConversation(new LucienArdougneTempleOfIkov.QuestPrompt(player).getStart())) ); option(""Oh no! Sounds far too dangerous."", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Oh no! Sounds far too dangerous."") .addNPC(NPC, HeadE.CALM_TALK, ""Wimp! Call yourself a hero?! My daughter is more a hero than you!"") ); option(""What's the reward?!"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""What's the reward?!"") .addNPC(NPC, HeadE.CALM_TALK, ""I see you are the mercenary type."") .addPlayer(HeadE.HAPPY_TALKING, ""It's a living."") .addNPC(NPC, HeadE.CALM_TALK, ""I will reward you well if you bring me the staff."") .addOptions(""Choose an option:"", new Options() { @Override public void create() { option(""That sounds like a laugh!"", new Dialogue() .addPlayer(HeadE.LAUGH, ""That sounds like a laugh!"") .addNext(() -> player.startConversation(new LucienArdougneTempleOfIkov.QuestPrompt(player).getStart())) ); option(""I'll pass this time."", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""I'll pass this time."") .addNPC(NPC, HeadE.FRUSTRATED, ""Hmph."") ); } }) ); } }); addNPC(NPC, HeadE.CALM_TALK, ""I seek a hero to go on an important mission!""); addOptions(""Choose an option:"", new Options() { @Override public void create() { option(""I'm a mighty hero!"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""I'm a mighty hero!"") .addNPC(NPC, HeadE.CALM_TALK, ""I require the Staff of Armadyl. It is in the deserted Temple of Ikov, near Hemenster, north "" + ""east of here. Take care hero! There is a dangerous monster somewhere in the temple!"") .addNext(mainOptions) ); option(""Yep, lots of heroes about these days."", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Yep, lots of heroes about these days."") .addNPC(NPC, HeadE.CALM_TALK, ""Well, if you see any be sure to point them in my direction."") ); } }); } case HELP_LUCIEN -> { addNPC(NPC, HeadE.CALM_TALK, ""I told you not to meet me here again!""); addPlayer(HeadE.HAPPY_TALKING, ""Sorry! Can you remind me of my mission?""); addNPC(NPC, HeadE.CALM_TALK, ""My patience grows thin hero! I need the Staff of Armadyl. It's in the Temple of Ikov, near Hemenster, north east of here.""); addPlayer(HeadE.HAPPY_TALKING, ""Okay great.""); if(player.getInventory().getAmountOf(86) == 0) { addPlayer(HeadE.SCARED, ""Umm...""); addNPC(NPC, HeadE.FRUSTRATED, ""What is it?""); addPlayer(HeadE.SECRETIVE, ""I lost the pendent you gave me...""); addItem(86, ""Lucien does a slight of hand and gives you his pendant"", ()-> player.getInventory().addItem(new Item(86, 1), true)); } } case QUEST_COMPLETE -> { if(TempleOfIkov.isLucienSide(player)) { addNPC(NPC, HeadE.CALM_TALK, ""I told you not to meet me here again!""); addPlayer(HeadE.AMAZED, ""Geez, okay!""); return; } addNPC(NPC, HeadE.CALM_TALK, ""Do not speak to me!""); addPlayer(HeadE.HAPPY_TALKING, ""...""); } } } public static NPCClickHandler handleLucienFromArdougne = new NPCClickHandler(new Object[] {NPC}, e -> e.getPlayer().startConversation(new LucienArdougneTempleOfIkov(e.getPlayer()).getStart())); }" "package com.rs.game.content.quests.templeofikov.dialogues; @PluginEventHandler public class LucienVarrockTempleOfIkov extends Conversation { private static final int NPC = 8347; public LucienVarrockTempleOfIkov(Player player) { super(player); switch(player.getQuestManager().getStage(Quest.TEMPLE_OF_IKOV)) { case NOT_STARTED -> { addNPC(NPC, HeadE.CALM_TALK, ""You shouldn't in here!""); addPlayer(HeadE.HAPPY_TALKING, ""Really?""); addNPC(NPC, HeadE.CALM_TALK, ""Yes...""); } case HELP_LUCIEN -> { addNPC(NPC, HeadE.CALM_TALK, ""Have you got the Staff of Armadyl yet?""); if(player.getInventory().containsItem(84)) { addPlayer(HeadE.HAPPY_TALKING, ""Yes! Here it is.""); addItem(84, ""You show him the Staff of Armadyl""); addNPC(NPC, HeadE.EVIL_LAUGH, ""Muhahahhahahaha! I can feel the power of the staff running through me! I will be more powerful and they "" + ""shall bow down to me! I suppose you want your reward? I shall grant you much power!""); addNext(()->{ player.getQuestManager().completeQuest(Quest.TEMPLE_OF_IKOV); player.getInventory().removeItems(new Item(84, 1)); TempleOfIkov.setIkovLucienSide(player, true); }); return; } addPlayer(HeadE.HAPPY_TALKING, ""Not yet, but i'm getting it!""); } case QUEST_COMPLETE -> { if(TempleOfIkov.isLucienSide(player)) { addNPC(NPC, HeadE.EVIL_LAUGH, ""Muhahahhahahaha! I can feel the power of the staff running through me! I will be more powerful and they shall bow down to me!""); return; } addNPC(NPC, HeadE.FRUSTRATED, ""Gah! I don't have time for this. I'll find someone else to do my bidding.""); } } } public static ObjectClickHandler handleLuciensHouse = new ObjectClickHandler(new Object[] { 102 }, e -> { if(e.getPlayer().getQuestManager().getStage(Quest.TEMPLE_OF_IKOV) > 0) { handleDoor(e.getPlayer(), e.getObject()); return; } e.getPlayer().sendMessage(""The door is locked...""); }); public static NPCClickHandler handleLucianDialogue = new NPCClickHandler(new Object[]{NPC}, new String[]{""Talk-to""}, e -> e.getPlayer().startConversation(new LucienVarrockTempleOfIkov(e.getPlayer()).getStart())); }" "package com.rs.game.content.quests.templeofikov.dialogues; @PluginEventHandler public class WineldaWitchTempleOfIkov extends Conversation { private static final int NPC = 276; public WineldaWitchTempleOfIkov(Player player) { super(player); Dialogue talkAboutSpell = new Dialogue() .addNPC(NPC, HeadE.CALM_TALK, ""I'm knowing some magic trickesses! I could get over easy as that! Don't tell them! They always come! They pester poor Winelda!"") .addPlayer(HeadE.HAPPY_TALKING, ""If you're such a great witch, get me over!"") .addNPC(NPC, HeadE.CALM_TALK, ""See? They pester Winelda!"") .addPlayer(HeadE.HAPPY_TALKING, ""I can do something for you!"") .addNPC(NPC, HeadE.CALM_TALK, ""Good! Don't pester, help! Get Winelda 20 limpwurt roots for my pot. Then we shows them some magic!""); if(player.getInventory().containsItem(225, 20)) talkAboutSpell.addPlayer(HeadE.HAPPY_TALKING, ""Okay, here are your limpwurt roots."") .addNPC(NPC, HeadE.CALM_TALK, ""Ooh, they're well prepared! Hehe!"") .addNPC(NPC, HeadE.CALM_TALK, ""Good! Good! My potion is nearly ready! Bubble, bubble, toil and trouble! Now we shows them ours magic! Hold on tight!"") .addNext(()->{ for(NPC npc : World.getNPCsInChunkRange(player.getChunkId(), 2)) if(npc.getId() == 276) { npc.faceEntity(player); npc.setNextAnimation(new Animation(711)); npc.setNextSpotAnim(new SpotAnim(108)); WorldTasks.delay(1, () -> { Magic.sendNormalTeleportSpell(player, Tile.of(2663, 9878, 0)); player.getInventory().removeItems(new Item(225, 20)); }); } }); else talkAboutSpell.addPlayer(HeadE.HAPPY_TALKING, ""Alright, I'll come back when I've got enough roots.""); addNPC(NPC, HeadE.CALM_TALK, ""Hehe! We see you're in a pickle! Wants to be getting over the nasty lava do we?""); addOptions(""Do you want to go over the lava?"", new Options() { @Override public void create() { option(""Nah, not bothered!"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Nah, not bothered!"") .addNPC(NPC, HeadE.CALM_TALK, ""Hehe! Ye'll come back! They always come back!"") ); option(""Yes we do!"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Yes we do!"") .addNPC(NPC, HeadE.CALM_TALK, ""Mocking us are we? Clever one aren't we?"") .addNext(talkAboutSpell) ); option(""Yes I do!"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Yes I do!"") .addNext(talkAboutSpell) ); } }); } public static NPCClickHandler handleDialogue = new NPCClickHandler(new Object[]{NPC}, e -> e.getPlayer().startConversation(new WineldaWitchTempleOfIkov(e.getPlayer()).getStart())); }" "package com.rs.game.content.quests.treegnomevillage; @QuestHandler( quest = Quest.TREE_GNOME_VILLAGE, startText = ""Talk to King Bolren at the centre of the Tree Gnome Village maze."", itemsText = ""6 normal logs."", combatText = ""You will need to defeat a level 53 enemy and might need to defeat two level 49 enemies."", rewardsText = ""11,450 Attack XP
Access to spirit tree teleportation
Gnome amulet of protection"", completedStage = 7 ) @PluginEventHandler public class TreeGnomeVillage extends QuestOutline { public final static int NOT_STARTED = 0; public final static int TALK_TO_MONTAI_ABOUT_WOOD = 1; public final static int GET_WOOD = 2; public final static int TALK_TO_MONTAI_ABOUT_TRACKERS = 3; public final static int FIRE_BALLISTA = 4; public final static int ORB1 = 5; public final static int KILL_WARLORD = 6; public final static int QUEST_COMPLETE = 7; @Override public List getJournalLines(Player player, int stage) { ArrayList lines = new ArrayList<>(); switch (stage) { case NOT_STARTED -> { lines.add(""The tree gnomes are in trouble. General Khazard's forces are ""); lines.add(""hunting them to extinction. Find your way through the hedge""); lines.add(""maze to the gnomes secret treetop village. Then help the gnomes""); lines.add(""fight Khazard and retrieve the orbs of protection.""); lines.add(""""); } case TALK_TO_MONTAI_ABOUT_WOOD -> { lines.add(""I am to talk to Commander Montai to help the gnomes fight on the""); lines.add(""battlefield.""); lines.add(""""); } case GET_WOOD -> { lines.add(""I should gather wood for Commander Montai and bring them to him.""); lines.add(""""); } case TALK_TO_MONTAI_ABOUT_TRACKERS -> { lines.add(""Now that that's over let's see how else we can help on the""); lines.add(""battlefield by talking to Commander Montai again.""); lines.add(""""); } case FIRE_BALLISTA -> { lines.add(""I need to get 3 coordinates from 3 tracker gnomes. After""); lines.add(""I speak with them I can aim and fire a ballista on the""); lines.add(""battlefield toward the enemy stronghold.""); lines.add(""""); lines.add((player.getQuestManager().getAttribs(Quest.TREE_GNOME_VILLAGE).getB(""tracker1found"") ? """" : """") + ""I have spoken to the 1st tracker""); lines.add((player.getQuestManager().getAttribs(Quest.TREE_GNOME_VILLAGE).getB(""tracker2found"") ? """" : """") + ""I have spoken to the 2nd tracker""); lines.add((player.getQuestManager().getAttribs(Quest.TREE_GNOME_VILLAGE).getB(""tracker3found"") ? """" : """") + ""I have spoken to the 3rd tracker""); lines.add(""""); } case ORB1 -> { lines.add(""Now that the ballista was fired I can force my way""); lines.add(""into the stronghold and steal the orb.""); lines.add(""""); } case KILL_WARLORD -> { lines.add(""A Khazard Warlord has the remaining orbs. I should""); lines.add(""find him, kill him and return them.""); lines.add(""""); } case QUEST_COMPLETE -> { lines.add(""""); lines.add(""""); lines.add(""QUEST COMPLETE!""); } default -> lines.add(""Invalid quest stage. Report this to an administrator.""); } return lines; } public static ObjectClickHandler handleDoorTracker2 = new ObjectClickHandler(new Object[] { 40362, 40361 }, e -> Doors.handleDoor(e.getPlayer(), e.getObject())); public static ObjectClickHandler handleWallBallistaHit = new ObjectClickHandler(new Object[] { 12762 }, e -> { if(e.getPlayer().getQuestManager().getStage(Quest.TREE_GNOME_VILLAGE) == ORB1) { Player p = e.getPlayer(); WorldTasks.scheduleLooping(new Task() { int tick = 0; boolean isPlayerNorth = true; @Override public void run() { if (tick == 0) { if (p.getY() == 3254) { p.lock(2); p.faceSouth(); p.setNextAnimation(new Animation(839)); isPlayerNorth = true; } else if (p.getY() == 3252) { p.lock(2); p.faceNorth(); p.setNextAnimation(new Animation(839)); isPlayerNorth = false; } else stop(); } else if (tick >= 1) { if (isPlayerNorth) p.tele(Tile.of(2509, 3252, 0)); if (!isPlayerNorth) { p.tele(Tile.of(2509, 3254, 0)); for(NPC npc : World.getNPCsInChunkRange(p.getChunkId(), 1)) if(npc.getId() == 478 && npc.getPlane() == 0) {//Khazard Commander npc.forceTalk(""Hey, what are you doing in here?""); npc.setTarget(p); } } stop(); } tick++; } }, 0, 1); return; } e.getPlayer().sendMessage(""The wall is too tough to cross""); }); public static PlayerStepHandler handleCommanderUpstairs = new PlayerStepHandler(new Tile[] { Tile.of(2503, 3254, 1), Tile.of(2504, 3254, 1), Tile.of(2502, 3254, 1) }, e -> { if(e.getPlayer().getQuestManager().getStage(Quest.TREE_GNOME_VILLAGE) == ORB1) for(NPC npc : World.getNPCsInChunkRange(e.getPlayer().getChunkId(), 1)) if(npc.getId() == 478 && npc.getPlane() == 1 && npc.getTarget() != e.getPlayer()) {//Khazard Commander npc.forceTalk(""Hey, get out of here!""); npc.setTarget(e.getPlayer()); } }); public static PlayerStepHandler handleCommanderDownstairs = new PlayerStepHandler(Tile.of(2505, 3256, 0), e -> { if(e.getPlayer().getQuestManager().getStage(Quest.TREE_GNOME_VILLAGE) == ORB1) for(NPC npc : World.getNPCsInChunkRange(e.getPlayer().getChunkId(), 1)) if(npc.getId() == 478 && npc.getPlane() == 0 && npc.getTarget() != e.getPlayer()) {//Khazard Commander npc.forceTalk(""Get out! What are you doing here?!""); npc.setTarget(e.getPlayer()); } }); public static NPCDeathHandler handleWarlordDrop = new NPCDeathHandler(new Object[] { 477 }, e -> { if(e.getKiller() instanceof Player p && p.getQuestManager().getStage(Quest.TREE_GNOME_VILLAGE) == KILL_WARLORD && !p.getInventory().containsItem(588)) World.addGroundItem(new Item(588, 1), Tile.of(e.getNPC().getTile()), p); }); public static ObjectClickHandler handleOrb1Chest = new ObjectClickHandler(new Object[] { 2183 }, e -> { if(e.getPlayer().getQuestManager().getStage(Quest.TREE_GNOME_VILLAGE) == ORB1 && !e.getPlayer().getInventory().containsItem(587)) { WorldTasks.scheduleTimer(tick -> { if(tick == 0) { e.getPlayer().lock(2); e.getPlayer().faceObject(e.getObject()); e.getPlayer().setNextAnimation(new Animation(536)); } if(tick == 1) { e.getObject().setIdTemporary(2182, 2); e.getPlayer().getInventory().addItem(new Item(587, 1)); return false; } return true; }); } }); public static ObjectClickHandler handleBallista = new ObjectClickHandler(new Object[] { 69527 }, e -> { if(e.getPlayer().getQuestManager().getStage(Quest.TREE_GNOME_VILLAGE) == FIRE_BALLISTA && has3TrackerCoordinates(e.getPlayer())) { Dialogue rightCoordinate = new Dialogue().addSimple(""The huge spear flies through the air and screams down directly into the Khazard stronghold. "" + ""A deafening crash echoes over the battlefield as the front entrance is reduced to rubble."", ()-> e.getPlayer().getQuestManager().setStage(Quest.TREE_GNOME_VILLAGE, ORB1)); Dialogue wrongCoordinate = new Dialogue().addSimple(""The huge spear completely misses the Khazard stronghold!""); int coordinate = e.getPlayer().getQuestManager().getAttribs(Quest.TREE_GNOME_VILLAGE).getI(""tracker3coordinate""); e.getPlayer().startConversation(new Dialogue() .addPlayer(HeadE.CALM_TALK, ""That tracker gnome was a bit vague about the x coordinate! What could it be?"") .addOptions(""What is the X coordinate?"", new Options() { @Override public void create() { option(""0001"", new Dialogue() .addNext(coordinate == 1 ? rightCoordinate : wrongCoordinate) ); option(""0002"", new Dialogue() .addNext(coordinate == 2 ? rightCoordinate : wrongCoordinate) ); option(""0003"", new Dialogue() .addNext(coordinate == 3 ? rightCoordinate : wrongCoordinate) ); option(""0004"", new Dialogue() .addNext(coordinate == 4 ? rightCoordinate : wrongCoordinate) ); } }) ); return; } e.getPlayer().startConversation(new Dialogue().addPlayer(HeadE.SECRETIVE, ""I don't know what to do with this ballista..."")); }); private static boolean has3TrackerCoordinates(Player p) { GenericAttribMap attr = p.getQuestManager().getAttribs(Quest.TREE_GNOME_VILLAGE); for(int i = 1; i <= 3; i++) if(!attr.getB(""tracker""+i+""found"")) return false; return true; } @Override public void complete(Player player) { player.getSkills().addXp(Constants.ATTACK, 11450); player.getInventory().addItem(new Item(589, 1), true); sendQuestCompleteInterface(player, 589); } }" "package com.rs.game.content.quests.treegnomevillage.dialogues; @PluginEventHandler public class CommanderMontaiTreeGnomeVillageD extends Conversation { private static final int NPC = 470; public CommanderMontaiTreeGnomeVillageD(Player player) { super(player); switch(player.getQuestManager().getStage(Quest.TREE_GNOME_VILLAGE)) { case NOT_STARTED -> { addPlayer(HeadE.HAPPY_TALKING, ""Hello.""); addNPC(NPC, HeadE.CALM_TALK, ""I can't talk now. Can't you see we're trying to win a battle here? If we can't hold back Khazard's men we're all doomed.""); } case TALK_TO_MONTAI_ABOUT_WOOD -> { addPlayer(HeadE.HAPPY_TALKING, ""Hello.""); addNPC(NPC, HeadE.CALM_TALK, ""Hello traveller, are you here to help or just to watch?""); addPlayer(HeadE.HAPPY_TALKING, ""I've been sent by King Bolren to retrieve the orb of protection.""); addNPC(NPC, HeadE.CALM_TALK, ""Excellent we need all the help we can get.""); addNPC(NPC, HeadE.CALM_TALK, ""I'm commander Montai. The orb is in the Khazard stronghold to the north, but until we weaken their defences we can't get close.""); addPlayer(HeadE.HAPPY_TALKING, ""What can I do?""); addNPC(NPC, HeadE.CALM_TALK, ""Firstly we need to strengthen our own defences. We desperately need wood to make more battlements, once the "" + ""battlements are gone it's all over. Six loads of normal logs should do it.""); addOptions(""Choose an option:"", new Options() { @Override public void create() { option(""Sorry, I no longer want to be involved."", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Sorry, I no longer want to be involved."") ); option(""Ok, I'll gather some wood."", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Ok, I'll gather some wood."") .addNPC(NPC, HeadE.CALM_TALK, ""Please be as quick as you can, I don't know how much longer we can hold out."", ()-> player.getQuestManager().setStage(Quest.TREE_GNOME_VILLAGE, GET_WOOD)) ); } }); } case GET_WOOD -> { addPlayer(HeadE.HAPPY_TALKING, ""Hello.""); addNPC(NPC, HeadE.CALM_TALK, ""Hello again, we're still desperate for wood soldier.""); if(this.player.getInventory().getAmountOf(1511) >= 6) { addPlayer(HeadE.HAPPY_TALKING, ""I have some here""); addNPC(NPC, HeadE.CALM_TALK, ""That's excellent, now we can make more defensive battlements. Give me a moment to organise the troops and then come speak to me. I'll inform you of our next phase of attack."", ()->{ this.player.getInventory().deleteItem(1511, 6); this.player.getQuestManager().setStage(Quest.TREE_GNOME_VILLAGE, TALK_TO_MONTAI_ABOUT_TRACKERS); }); return; } addPlayer(HeadE.HAPPY_TALKING, ""I'll see what I can do.""); addNPC(NPC, HeadE.CALM_TALK, ""Thank you.""); } case TALK_TO_MONTAI_ABOUT_TRACKERS -> { addPlayer(HeadE.HAPPY_TALKING, ""How are you doing Montai?""); addNPC(NPC, HeadE.CALM_TALK, ""We're hanging in there soldier. For the next phase of our attack we need to breach their stronghold.""); addNPC(NPC, HeadE.CALM_TALK, ""The ballista can break through the stronghold wall, and then we can advance and seize back the orb.""); addPlayer(HeadE.HAPPY_TALKING, ""So what's the problem?""); addNPC(NPC, HeadE.CALM_TALK, ""From this distance we can't get an accurate enough shot. We need the correct coordinates of the stronghold for a direct hit. I've sent out three tracker gnomes to gather them.""); addPlayer(HeadE.HAPPY_TALKING, ""Have they returned?""); addNPC(NPC, HeadE.CALM_TALK, ""I'm afraid not, and we're running out of time. I need you to go into the heart of the battlefield, find the trackers, and bring back the coordinates.""); addNPC(NPC, HeadE.CALM_TALK, ""Do you think you can do it?""); addOptions(""Choose an option:"", new Options() { @Override public void create() { option(""No, I've had enough of your battle."", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""No, I've had enough of your battle."") .addNPC(NPC, HeadE.CALM_TALK, ""I understand, this isn't your fight."") ); option(""I'll try my best."", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""I'll try my best."", ()-> player.getQuestManager().setStage(Quest.TREE_GNOME_VILLAGE, FIRE_BALLISTA)) .addNPC(NPC, HeadE.CALM_TALK, ""Thank you, you're braver than most."") .addNPC(NPC, HeadE.CALM_TALK, ""I don't know how long I will be able to hold out. Once you have the coordinates come back and fire "" + ""the ballista right into those monsters."") .addNPC(NPC, HeadE.CALM_TALK, ""If you can retrieve the orb and bring safety back to my people, none of the blood spilled on this "" + ""field will be in vain."") ); } }); } case FIRE_BALLISTA -> { addPlayer(HeadE.HAPPY_TALKING, ""Hello.""); addNPC(NPC, HeadE.CALM_TALK, ""Hello warrior. We need the coordinates for a direct hit from the ballista. Once you have a direct hit you will "" + ""be able to enter the stronghold and retrieve the orb.""); } case ORB1 -> { if(this.player.getInventory().containsItem(587)) { addNPC(NPC, HeadE.AMAZED, ""Oh WOW!""); addPlayer(HeadE.CALM, ""...""); addNPC(NPC, HeadE.SECRETIVE, ""Return the Orb Of Protection to King Bolren, hurry!""); addPlayer(HeadE.SECRETIVE, ""Okay okay""); return; } addPlayer(HeadE.HAPPY_TALKING, ""Hello.""); addNPC(NPC, HeadE.CALM_TALK, ""Hello warrior. We need the coordinates for a direct hit from the ballista. Once you have a direct hit you will "" + ""be able to enter the stronghold and retrieve the orb.""); } case KILL_WARLORD -> { addPlayer(HeadE.HAPPY_TALKING, ""I got the orb of protection.""); addNPC(NPC, HeadE.CALM_TALK, ""Incredible, for a human you really are something.""); addPlayer(HeadE.HAPPY_TALKING, ""Thanks... I think!""); addNPC(NPC, HeadE.CALM_TALK, ""I'll stay here with my troops and try and hold Khazard's men back. You return the orb to the gnome village. Go as quick as you can, the village is still unprotected.""); } case QUEST_COMPLETE -> { addPlayer(HeadE.HAPPY_TALKING, ""Hello Montai, how are you?""); addNPC(NPC, HeadE.CALM_TALK, ""I'm ok, this battle is going to take longer to win than I expected. The Khazard troops won't give up even without the orb.""); addPlayer(HeadE.HAPPY_TALKING, ""Hang in there.""); } } } public static NPCClickHandler handleDialogue = new NPCClickHandler(new Object[]{NPC}, e -> e.getPlayer().startConversation(new CommanderMontaiTreeGnomeVillageD(e.getPlayer()).getStart())); }" "package com.rs.game.content.quests.treegnomevillage.dialogues; @PluginEventHandler public class ElkoyTreeGnomeVillageD extends Conversation { private static final int NPC = 473; public ElkoyTreeGnomeVillageD(Player player) { super(player); Dialogue goThroughMaze = new Dialogue().addOptions(""Choose an option:"", new Options() { @Override public void create() { option(""Yes please"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Yes please"") .addSimple(""Elkoy guides you through the maze."", () -> { player.lock(3); WorldTasks.delay(3, () -> player.startConversation(new Dialogue().addNPC(473, HeadE.HAPPY_TALKING, ""Here we are, "" + (player.getY() > 3177 ? ""feel free to have a look around."" : ""off you go."")))); player.fadeScreen(() -> { player.sendMessage(""Elkoy leads you through the maze...""); player.tele(player.getY() > 3177 ? Tile.of(2515, 3160, 0) : Tile.of(2502, 3193, 0)); }); }) ); option(""No"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""No thanks Elkoy"") .addNPC(NPC, HeadE.CALM_TALK, ""Ok then, take care."") ); } }); switch(player.getQuestManager().getStage(Quest.TREE_GNOME_VILLAGE)) { case NOT_STARTED -> { addPlayer(HeadE.HAPPY_TALKING, ""Hello there.""); addNPC(NPC, HeadE.CALM_TALK, ""Hello, welcome to our maze. I'm Elkoy the tree gnome.""); addPlayer(HeadE.HAPPY_TALKING, ""I haven't heard of your sort""); addNPC(NPC, HeadE.CALM_TALK, ""There's not many of us left. Once you could find tree gnomes anywhere in the world, now we hide in small groups"" + "" to avoid capture.""); addPlayer(HeadE.HAPPY_TALKING, ""Capture by whom?""); addNPC(NPC, HeadE.CALM_TALK, ""Tree gnomes have been hunted for so called 'fun' since as long as I can remember.""); addNPC(NPC, HeadE.CALM_TALK, ""Our main threat nowadays are General Khazard's troops. They know no mercy, but are also very dense. They'll "" + ""never find their way through our maze.""); } case TALK_TO_MONTAI_ABOUT_WOOD, GET_WOOD, TALK_TO_MONTAI_ABOUT_TRACKERS, FIRE_BALLISTA, ORB1, KILL_WARLORD -> { addPlayer(HeadE.HAPPY_TALKING, ""Hello""); addNPC(NPC, HeadE.CALM_TALK, ""We are going to need help with those orbs, otherwise our village is doomed.""); addNPC(NPC, HeadE.CALM_TALK, ""Do you want me to show you through the maze?""); addNext(goThroughMaze); } case QUEST_COMPLETE -> { addPlayer(HeadE.HAPPY_TALKING, ""Hello Elkoy.""); addNPC(NPC, HeadE.CALM_TALK, ""Hi there, I hope life is treating you well. Would you like me to show you the way "" + (player.getY() > 3177 ? ""out of"" : ""into"") + "" the village?""); addNext(goThroughMaze); } } } }" "package com.rs.game.content.quests.treegnomevillage.dialogues; @PluginEventHandler public class KingBolrenTreeGnomeVillageD extends Conversation { private static final int NPC = 469; public KingBolrenTreeGnomeVillageD(Player player) { super(player); switch(player.getQuestManager().getStage(Quest.TREE_GNOME_VILLAGE)) { case NOT_STARTED -> { addPlayer(HeadE.HAPPY_TALKING, ""Hello.""); addNPC(NPC, HeadE.CALM_TALK, ""Well hello stranger. My name's Bolren, I'm the king of the tree gnomes.""); addNPC(NPC, HeadE.CALM_TALK, ""I'm surprised you made it in, maybe I made the maze too easy.""); addPlayer(HeadE.HAPPY_TALKING, ""Maybe.""); addNPC(NPC, HeadE.CALM_TALK, ""I'm afraid I have more serious concerns at the moment. Very serious.""); addOptions(""Choose an option"", new Options() { @Override public void create() { option(""Can I help at all?"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Can I help at all?"") .addNPC(NPC, HeadE.CALM_TALK, ""I'm glad you asked."") .addNPC(NPC, HeadE.CALM_TALK, ""The truth is my people are in grave danger. We have always been protected by the Spirit Tree. "" + ""No creature of dark can harm us while its three orbs are in place."") .addNPC(NPC, HeadE.CALM_TALK, ""We are not a violent race, but we fight when we must. Many gnomes have fallen battling the dark "" + ""forces of Khazard to the North."") .addNPC(NPC, HeadE.CALM_TALK, ""We became desperate, so we took one orb of protection to the battlefield. It was a foolish move."") .addNPC(NPC, HeadE.CALM_TALK, ""Khazard troops seized the orb. Now we are completely defenceless."") .addPlayer(HeadE.HAPPY_TALKING, ""How can I help?"") .addNPC(NPC, HeadE.CALM_TALK, ""You would be a huge benefit on the battlefield. If you would go there and try to retrieve the orb, "" + ""my people and I will be forever grateful."") .addOptions(""Start Tree Gnome Village?"", new Options() { @Override public void create() { option(""Yes"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""I would be glad to help."", ()-> player.getQuestManager().setStage(Quest.TREE_GNOME_VILLAGE, TALK_TO_MONTAI_ABOUT_WOOD)) .addNPC(NPC, HeadE.CALM_TALK, ""Thank you. The battlefield is to the north of the maze. Commander Montai will inform you of their current situation."") .addNPC(NPC, HeadE.CALM_TALK, ""That is if he's still alive."") .addNPC(NPC, HeadE.CALM_TALK, ""My assistant shall guide you out. Good luck friend, try your best to return the orb"") .addSimple(""You are guided out of the maze"", ()->{ KingBolrenTreeGnomeVillageD.this.player.lock(3); WorldTasks.delay(3, () -> KingBolrenTreeGnomeVillageD.this.player.startConversation(new Dialogue().addNPC(473, HeadE.HAPPY_TALKING, ""We're out of the maze now. Please hurry, we must have the orb if we are to survive.""))); KingBolrenTreeGnomeVillageD.this.player.fadeScreen(() -> { KingBolrenTreeGnomeVillageD.this.player.sendMessage(""Elkoy leads you through the maze...""); KingBolrenTreeGnomeVillageD.this.player.tele(KingBolrenTreeGnomeVillageD.this.player.getY() > 3177 ? Tile.of(2515, 3160, 0) : Tile.of(2502, 3193, 0)); }); }) ); option(""No"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""I'm sorry but I won't be involved."") .addNPC(NPC, HeadE.CALM_TALK, ""Ok then, travel safe."") ); } }) ); option(""I'll leave you to it then."", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""I'll leave you to it then."") .addNPC(NPC, HeadE.CALM_TALK, ""Ok, take care."") ); } }); } case TALK_TO_MONTAI_ABOUT_WOOD, GET_WOOD, TALK_TO_MONTAI_ABOUT_TRACKERS, FIRE_BALLISTA -> { addPlayer(HeadE.HAPPY_TALKING, ""Hello Bolren.""); addNPC(NPC, HeadE.CALM_TALK, ""Hello traveller, we must retrieve the orb. It's being held by Khazard troops north of here.""); addPlayer(HeadE.HAPPY_TALKING, ""Yes I will be sure to help.""); addNPC(NPC, HeadE.CALM_TALK, ""Talk to Commander Montai for more information.""); addPlayer(HeadE.HAPPY_TALKING, ""Ok, I'll try my best.""); } case ORB1 -> { if(this.player.getInventory().containsItem(587)) { addPlayer(HeadE.HAPPY_TALKING, ""I have the orb.""); addNPC(NPC, HeadE.SAD_CRYING, ""Oh my... The misery, the horror!""); addPlayer(HeadE.SECRETIVE, ""King Bolren, are you OK?""); addNPC(NPC, HeadE.SAD, ""Thank you traveller, but it's too late. We're all doomed.""); addPlayer(HeadE.CALM_TALK, ""What happened?""); addNPC(NPC, HeadE.SAD_MILD_LOOK_DOWN, ""They came in the night. I don't know how many, but enough.""); addPlayer(HeadE.SECRETIVE, ""Who?""); addNPC(NPC, HeadE.SAD_EXTREME, ""Khazard troops. They slaughtered anyone who got in their way. Women, children, my wife.""); addPlayer(HeadE.SAD, ""I'm sorry.""); addNPC(NPC, HeadE.SAD_SNIFFLE, ""They took the other orbs, now we are defenceless.""); addPlayer(HeadE.SECRETIVE, ""Where did they take them?""); addNPC(NPC, HeadE.SECRETIVE, ""They headed north of the stronghold. A warlord carries the orbs.""); addOptions(""Choose an option:"", new Options() { @Override public void create() { option(""I will go get the orb"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""I will find the warlord and bring back the orbs."") .addNPC(NPC, HeadE.CALM_TALK, ""You are brave, but this task will be tough even for you. I wish you the best of luck. Once again you are our only hope."") .addNPC(NPC, HeadE.CALM_TALK, ""I will safeguard this orb and pray for your safe return. My assistant will guide you out."") .addSimple(""Elkoy guides you out of the maze."", ()->{ KingBolrenTreeGnomeVillageD.this.player.lock(3); KingBolrenTreeGnomeVillageD.this.player.getInventory().deleteItem(587, 1); KingBolrenTreeGnomeVillageD.this.player.getQuestManager().setStage(Quest.TREE_GNOME_VILLAGE, KILL_WARLORD); WorldTasks.delay(3, () -> KingBolrenTreeGnomeVillageD.this.player.startConversation(new Dialogue().addNPC(473, HeadE.HAPPY_TALKING, ""Here we are, "" + (KingBolrenTreeGnomeVillageD.this.player.getY() > 3177 ? ""feel free to have a look around."" : ""off you go."")))); KingBolrenTreeGnomeVillageD.this.player.fadeScreen(() -> { KingBolrenTreeGnomeVillageD.this.player.sendMessage(""Elkoy leads you through the maze...""); KingBolrenTreeGnomeVillageD.this.player.tele(KingBolrenTreeGnomeVillageD.this.player.getY() > 3177 ? Tile.of(2515, 3160, 0) : Tile.of(2502, 3193, 0)); }); }) ); option(""I'm sorry but I can't help."", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""I'm sorry but I can't help."") .addNPC(NPC, HeadE.CALM_TALK, ""I understand, this isn't your battle."") ); } }); return; } addPlayer(HeadE.HAPPY_TALKING, ""Hello Bolren.""); addNPC(NPC, HeadE.CALM_TALK, ""Do you have the orb?""); addPlayer(HeadE.HAPPY_TALKING, ""No, I'm afraid not.""); addNPC(NPC, HeadE.CALM_TALK, ""Please, we must have the orb if we are to survive.""); } case KILL_WARLORD -> { if(this.player.getInventory().containsItem(588)) { addPlayer(HeadE.HAPPY_TALKING, ""Bolren, I have returned.""); addNPC(NPC, HeadE.CALM_TALK, ""You made it back! Do you have the orbs?""); addPlayer(HeadE.HAPPY_TALKING, ""I have them here.""); addNPC(NPC, HeadE.CALM_TALK, ""Hooray, you're amazing. I didn't think it was possible but you've saved us.""); addNPC(NPC, HeadE.CALM_TALK, ""Once the orbs are replaced we will be safe once more.""); addNext(()-> this.player.getQuestManager().completeQuest(Quest.TREE_GNOME_VILLAGE)); /* We must begin the ceremony immediately.""); addPlayer(HeadE.HAPPY_TALKING, ""What does the ceremony involve?""); addNPC(NPC, HeadE.CALM_TALK, ""The spirit tree has looked over us for centuries. Now we must pay our respects.""); addNext(()->{TreeGnomeParty(player);});*/ return; } addPlayer(HeadE.HAPPY_TALKING, ""Hello Bolren.""); addNPC(NPC, HeadE.CALM_TALK, ""The orbs are gone, taken north of the battlefield by a Khazard warlord. We're all doomed.""); } case QUEST_COMPLETE -> { addPlayer(HeadE.HAPPY_TALKING, ""Hello again Bolren.""); addNPC(NPC, HeadE.CALM_TALK, ""Well hello, it's good to see you again.""); if(!this.player.getInventory().containsItem(589)) { addPlayer(HeadE.HAPPY_TALKING, ""I've lost my amulet.""); addNPC(NPC, HeadE.CALM_TALK, ""Oh dear. Here, take another. We truly are indebted to you."", ()-> this.player.getInventory().addItem(new Item(589, 1), true)); } } } } @SuppressWarnings(""unused"") private void treeGnomeParty(Player p) { } public static NPCClickHandler handleDialogue = new NPCClickHandler(new Object[]{NPC}, e -> e.getPlayer().startConversation(new KingBolrenTreeGnomeVillageD(e.getPlayer()).getStart())); }" "package com.rs.game.content.quests.treegnomevillage.dialogues; @PluginEventHandler public class Tracker1TreeGnomeVillageD extends Conversation { private static final int NPC = 481; public Tracker1TreeGnomeVillageD(Player player) { super(player); switch(player.getQuestManager().getStage(Quest.TREE_GNOME_VILLAGE)) { case NOT_STARTED, TALK_TO_MONTAI_ABOUT_WOOD, GET_WOOD, TALK_TO_MONTAI_ABOUT_TRACKERS -> { addPlayer(HeadE.HAPPY_TALKING, ""Hello""); addNPC(NPC, HeadE.CALM_TALK, ""I can't talk now. Can't you see we're trying to win a battle here?""); } case FIRE_BALLISTA -> { addPlayer(HeadE.HAPPY_TALKING, ""Do you know the coordinates of the Khazard stronghold?""); addNPC(NPC, HeadE.CALM_TALK, ""I managed to get one, although it wasn't easy.""); addPlayer(HeadE.HAPPY_TALKING, ""Well done."", ()-> this.player.getQuestManager().getAttribs(Quest.TREE_GNOME_VILLAGE).setB(""tracker1found"", true)); addNPC(NPC, HeadE.CALM_TALK, ""The other two tracker gnomes should have the other coordinates if they're still alive.""); addPlayer(HeadE.HAPPY_TALKING, ""OK, take care.""); } case ORB1, KILL_WARLORD -> { addPlayer(HeadE.HAPPY_TALKING, ""Hello.""); addNPC(NPC, HeadE.CALM_TALK, ""Now we have the orb I'm much better. They won't stand a chance without it.""); } case QUEST_COMPLETE -> { addPlayer(HeadE.HAPPY_TALKING, ""How are you tracker?""); addNPC(NPC, HeadE.CALM_TALK, ""Now we have the orb I'm much better. They won't stand a chance without it.""); } } } public static NPCClickHandler handleDialogue = new NPCClickHandler(new Object[]{NPC}, e -> e.getPlayer().startConversation(new Tracker1TreeGnomeVillageD(e.getPlayer()).getStart())); }" "package com.rs.game.content.quests.treegnomevillage.dialogues; @PluginEventHandler public class Tracker2TreeGnomeVillageD extends Conversation { private static final int NPC = 482; public Tracker2TreeGnomeVillageD(Player player) { super(player); switch(player.getQuestManager().getStage(Quest.TREE_GNOME_VILLAGE)) { case NOT_STARTED, TALK_TO_MONTAI_ABOUT_WOOD, GET_WOOD, TALK_TO_MONTAI_ABOUT_TRACKERS -> { addPlayer(HeadE.HAPPY_TALKING, ""Hello""); addNPC(NPC, HeadE.CALM_TALK, ""I can't talk now. If the guards catch me i'll be dead gnome meat.""); } case FIRE_BALLISTA -> { addPlayer(HeadE.HAPPY_TALKING, ""Are you OK?""); addNPC(NPC, HeadE.CALM_TALK, ""They caught me spying on the stronghold. They beat and tortured me.""); addNPC(NPC, HeadE.CALM_TALK, ""But I didn't crack. I told them nothing. They can't break me!""); addPlayer(HeadE.HAPPY_TALKING, ""I'm sorry little man.""); addNPC(NPC, HeadE.CALM_TALK, ""Don't be. I have the position of the stronghold!""); addPlayer(HeadE.HAPPY_TALKING, ""Well done."", ()-> player.getQuestManager().getAttribs(Quest.TREE_GNOME_VILLAGE).setB(""tracker2found"", true)); addNPC(NPC, HeadE.CALM_TALK, ""Now leave before they find you and all is lost.""); addPlayer(HeadE.HAPPY_TALKING, ""Hang in there.""); addNPC(NPC, HeadE.CALM_TALK, ""Go!""); } case ORB1, KILL_WARLORD -> { addPlayer(HeadE.HAPPY_TALKING, ""Hello.""); addNPC(NPC, HeadE.CALM_TALK, ""Now we have the orb I'm much better. They won't stand a chance without it.""); } case QUEST_COMPLETE -> { addPlayer(HeadE.HAPPY_TALKING, ""How are you tracker?""); addNPC(NPC, HeadE.CALM_TALK, ""Now we have the orb I'm much better. They won't stand a chance without it.""); } } } public static NPCClickHandler handleDialogue = new NPCClickHandler(new Object[]{NPC}, e -> e.getPlayer().startConversation(new Tracker2TreeGnomeVillageD(e.getPlayer()).getStart())); public static NPCInteractionDistanceHandler tracker2Distance = new NPCInteractionDistanceHandler(NPC, (player, npc) -> 1); }" "package com.rs.game.content.quests.treegnomevillage.dialogues; @PluginEventHandler public class Tracker3TreeGnomeVillageD extends Conversation { private static final int NPC = 483; public Tracker3TreeGnomeVillageD(Player player) { super(player); int coordinate = player.getQuestManager().getAttribs(Quest.TREE_GNOME_VILLAGE).getI(""tracker3coordinate""); if(coordinate == 0) { coordinate = Utils.randomInclusive(1, 4); player.getQuestManager().getAttribs(Quest.TREE_GNOME_VILLAGE).setI(""tracker3coordinate"", coordinate); } switch(player.getQuestManager().getStage(Quest.TREE_GNOME_VILLAGE)) { case NOT_STARTED, TALK_TO_MONTAI_ABOUT_WOOD, GET_WOOD, TALK_TO_MONTAI_ABOUT_TRACKERS -> { addPlayer(HeadE.HAPPY_TALKING, ""Hello""); addNPC(NPC, HeadE.CALM_TALK, ""I can't talk now. Can't you see we're trying to win a battle here?""); } case FIRE_BALLISTA -> { addPlayer(HeadE.HAPPY_TALKING, ""Are you OK?""); addNPC(NPC, HeadE.CALM_TALK, ""OK? Who's OK? Not me! Hee hee!""); addPlayer(HeadE.HAPPY_TALKING, ""What's wrong?""); addNPC(NPC, HeadE.CALM_TALK, ""You can't see me, no one can. Monsters, demons, they're all around me!""); addPlayer(HeadE.HAPPY_TALKING, ""What do you mean?""); addNPC(NPC, HeadE.CALM_TALK, ""They're dancing, all of them, hee hee.""); addPlayer(HeadE.HAPPY_TALKING, ""Do you have the coordinate for the Khazard stronghold?""); addNPC(NPC, HeadE.CALM_TALK, ""Who holds the stronghold?""); addPlayer(HeadE.HAPPY_TALKING, ""What?""); if(coordinate == 1) addNPC(NPC, HeadE.CALM_TALK, ""Less than my hands"", ()-> player.getQuestManager().getAttribs(Quest.TREE_GNOME_VILLAGE).setB(""tracker3found"", true)); if(coordinate == 2) addNPC(NPC, HeadE.CALM_TALK, ""More than my head less than my fingers"", ()-> player.getQuestManager().getAttribs(Quest.TREE_GNOME_VILLAGE).setB(""tracker3found"", true)); if(coordinate == 3) addNPC(NPC, HeadE.CALM_TALK, ""More than we but less than our feet"", ()-> player.getQuestManager().getAttribs(Quest.TREE_GNOME_VILLAGE).setB(""tracker3found"", true)); if(coordinate == 4) addNPC(NPC, HeadE.CALM_TALK, ""My legs and your legs"", ()-> player.getQuestManager().getAttribs(Quest.TREE_GNOME_VILLAGE).setB(""tracker3found"", true)); addPlayer(HeadE.HAPPY_TALKING, ""You're mad.""); addNPC(NPC, HeadE.CALM_TALK, ""Dance with me, and Khazard's men are beat.""); addPlayer(HeadE.HAPPY_TALKING, ""I'll pray for you little man.""); addNPC(NPC, HeadE.CALM_TALK, ""All day we pray in the hay, hee hee.""); } case ORB1, KILL_WARLORD -> { addPlayer(HeadE.HAPPY_TALKING, ""Hello.""); addNPC(NPC, HeadE.CALM_TALK, ""Now we have the orb I'm much better. They won't stand a chance without it.""); } case QUEST_COMPLETE -> { addPlayer(HeadE.HAPPY_TALKING, ""How are you tracker?""); addNPC(NPC, HeadE.CALM_TALK, ""Now we have the orb I'm much better. They won't stand a chance without it.""); } } } public static NPCClickHandler handleDialogue = new NPCClickHandler(new Object[]{NPC}, e -> e.getPlayer().startConversation(new Tracker3TreeGnomeVillageD(e.getPlayer()).getStart())); }" "package com.rs.game.content.quests.tribaltotem; @PluginEventHandler public class HoracioTribalTotemD extends Conversation { private static final int NPC = 845; public HoracioTribalTotemD(Player player) { super(player); addNPC(NPC, HeadE.CALM_TALK, ""It's a fine day to be out in a garden, isn't it?""); addOptions(""Choose an option:"", new Options() { @Override public void create() { option(""Yes. It's very nice."", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""es. It's very nice."") .addNPC(NPC, HeadE.CALM_TALK, ""Days like these make me glad to be alive!"") ); option(""So... who are you?"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""So... who are you?"") .addNPC(NPC, HeadE.CALM_TALK, ""My name is Horacio Dobson. I'm a gardener to Lord Handlemort. Take a look around this beautiful "" + ""garden, all of this is my handiwork"") .addOptions(""Choose an option:"", new Options() { @Override public void create() { option(""So... do you garden round the back, too?"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""So... do you garden round the back, too?"") .addNPC(NPC, HeadE.CALM_TALK, ""That I do!"") .addPlayer(HeadE.HAPPY_TALKING, ""Doesn't all of the security around the house get in your way then?"") .addNPC(NPC, HeadE.CALM_TALK, ""Ah. I'm used to all that. I have my keys, the guard dogs know me, and I know the "" + ""combination to the door lock. It's rather easy, it's his middle name."") .addPlayer(HeadE.HAPPY_TALKING, ""Whose middle name?"") .addNPC(NPC, HeadE.CALM_TALK, ""Hum. I probably shouldn't have said that. Forget I mentioned it."") ); option(""Do you need any help?"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Do you need any help?"") .addNPC(NPC, HeadE.CALM_TALK, ""Trying to muscle in on my job, eh? I'm more than happy to do this all by myself!\n"") ); } })); option(""How do I get into the mansion?"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""How do I get into the mansion?"") .addNPC(NPC, HeadE.CALM_TALK, ""It is impossible!"") .addNPC(NPC, HeadE.CALM_TALK, ""Lord Handelmort has the latest of security features in his home..."") .addNPC(NPC, HeadE.CALM_TALK, ""He has a state of the art password lock and trick stairs which dump you into the sewers."") .addNPC(NPC, HeadE.CALM_TALK, ""Yep, there is no getting past that locked door, only me and him know password, it's rather easy,"" + "" it's his middle name"") .addPlayer(HeadE.HAPPY_TALKING, ""Whose middle name?"") .addNPC(NPC, HeadE.AMAZED, ""Hum. I probably shouldn't have said that. Forget I mentioned it."") ); } }); } public static NPCClickHandler handleDialogue = new NPCClickHandler(new Object[] { NPC }, e -> e.getPlayer().startConversation(new HoracioTribalTotemD(e.getPlayer()).getStart())); }" "package com.rs.game.content.quests.tribaltotem; @PluginEventHandler public class KangaiMauTribalTotemD extends Conversation { private static final int NPC = 846; public KangaiMauTribalTotemD(Player player) { super(player); switch(player.getQuestManager().getStage(Quest.TRIBAL_TOTEM)) { case NOT_STARTED -> { addNPC(NPC, HeadE.CALM_TALK, ""Hello. I Kangai Mau of the Rantuki tribe""); addOptions(""Choose an option:"", new Options() { @Override public void create() { option(""And what are you doing here in Brimhaven?"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""And what are you doing here in Brimhaven?"") .addNPC(NPC, HeadE.CALM_TALK, ""I'm looking for someone brave to go on important mission. Someone skilled in thievery and "" + ""sneaking about. I am told I can find such people in Brimhaven."") .addPlayer(HeadE.HAPPY_TALKING, ""Yep. I have heard there are many of that type here."") .addNPC(NPC, HeadE.CALM_TALK, ""Let's hope I find them."") ); if(KangaiMauTribalTotemD.this.player.getSkills().getLevel(Constants.THIEVING) < 21) option(""I'm in search of adventure!"", new Dialogue() .addSimple(""You need 21 thieving to start Tribal Totem.."")); else option(""I'm in search of adventure!"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""I'm in search of adventure!"") .addNPC(NPC, HeadE.CALM_TALK, ""Adventure is something I may be able to give. I need someone to go on a mission to the city of Ardougne. "") .addNPC(NPC, HeadE.CALM_TALK, ""There you will find the house of Lord Handlemort. In his house he has our tribal totem. We need it back."") .addPlayer(HeadE.HAPPY_TALKING, ""Why does he have it?"") .addNPC(NPC, HeadE.CALM_TALK, ""Lord Handlemort is an Ardougnese explorer which means he think he have the right to come to my "" + ""tribal home, steal our stuff and put in his private museum."") .addOptions(""Start Tribal Totem?"", new Options() { @Override public void create() { option(""Yes"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Ok, I will get it back"", ()-> player.getQuestManager().setStage(Quest.TRIBAL_TOTEM, TALK_TO_WIZARD)) .addNPC(NPC, HeadE.CALM_TALK, ""Best of luck with that adventurer."") ); option(""No"", new Dialogue()); } }) ); option(""Who are the Rantuki tribe?"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Who are the Rantuki tribe?"") .addNPC(NPC, HeadE.CALM_TALK, ""A proud and noble tribe of Karamja. But now we are few, as men come from across, steal our "" + ""land, and settle on our hunting grounds."") ); } }); } case TALK_TO_WIZARD, REDIRECT_TELE_STONE -> { addNPC(NPC, HeadE.CALM_TALK, ""Have you got our totem back?""); addPlayer(HeadE.HAPPY_TALKING, ""No, it's not that easy.""); addNPC(NPC, HeadE.CALM_TALK, ""Bah, you no good.""); } case GET_TOTEM -> { if(player.getInventory().containsItem(TOTEM, 1)) { addNPC(NPC, HeadE.CALM_TALK, ""Have you got our totem back?""); addPlayer(HeadE.HAPPY_TALKING, ""Yes I have.""); addNPC(NPC, HeadE.CALM_TALK, ""You have??? Many thanks brave adventurer! Here, have some freshly cooked Karamjan fish, caught specially by my tribe.""); addSimple(""You hand over the Tribal Totem.""); addNext(()->{ player.getInventory().removeItems(new Item(TOTEM, 1)); player.getQuestManager().completeQuest(Quest.TRIBAL_TOTEM); }); } else { addNPC(NPC, HeadE.CALM_TALK, ""Have you got our totem back?""); addPlayer(HeadE.HAPPY_TALKING, ""No, it's not that easy.""); addNPC(NPC, HeadE.CALM_TALK, ""Bah, you no good.""); } } case QUEST_COMPLETE -> { addNPC(NPC, HeadE.CALM_TALK, ""Thank you for helping my tribe!""); addPlayer(HeadE.HAPPY_TALKING, ""You are welcome!""); } } } public static NPCClickHandler handleDialogue = new NPCClickHandler(new Object[] { NPC }, e -> e.getPlayer().startConversation(new KangaiMauTribalTotemD(e.getPlayer()).getStart())); }" "package com.rs.game.content.quests.tribaltotem; public class RealEstateGuideBook extends Book { public RealEstateGuideBook() { super(""Ardougne Estate Guide"", new BookPage( new String[] { ""Introduction"", ""This book is your"", ""city of Ardougne."", ""Ardougne is known as an"", ""exciting modern city"", ""located on the sun drenched"", ""southern coast of Kandarin."", ""It seems to like this"", ""combination a lot!"", """", """", }, new String[] { ""Ardougne: City of Shopping!"", ""Come sample the delights"", ""of the Ardougne market - the"", ""biggest in the known world!"", ""From spices to silk, there"", ""is something here for"", ""everybody! Other popular"", ""shopping destinations in"", ""the area include the Armoury"", ""and the ever popular"", ""Adventurers' supply store."", }), new BookPage( new String[] { ""Ardougne: City of Fun!"", ""If you're looking for"", ""entertainment in Ardougne,"", ""why not pay a visit to"", ""the Ardougne City Zoo?"", ""Or relax with a drink"", ""in the ever popular"", ""Flying Horse Inn?"", """", ""And for the adventurous,"", ""there are always rats"", }, new String[] { ""to be slaughtered in the"", ""expansive and vermin-ridden "", ""sewers. There is truly"", ""something for everybody here! "", """", """", """", """", """", """", """", }), new BookPage( new String[] { ""Ardougne: City of History!"", ""Ardougne is renowned as"", ""an important city of"", ""historical interest. One"", ""historic building is the"", ""magnificent Handelmort"", ""Mansion, currently owned by "", ""Lord Francis Kurt Handelmort."", ""Also of historical interest"", ""is Ardougne Castle in the "", ""East side of the city,"", }, new String[] { ""recently opened to the"", ""public. And of course,"", ""the Holy Order of Paladins"", ""still wander the streets"", ""of Ardougne, and are often"", ""of interest to tourists."", """", ""Further Fields"", ""Ardougne is also of great"", ""interest to the cultural"", ""tourist."", }), new BookPage( new String[] { ""If you want to go further"", ""afield, why not have a"", ""look at the ominous"", ""Pillars of Zanash, the"", ""mysterious marble pillars"", ""located just West of"", ""the city? Or perhaps"", ""the town of Brimhaven, on"", ""the exotic island of"", ""SKaramja? It's only a"", ""short boat trip, with"", }, new String[] { ""regular transport leaving"", ""from Ardougne Harbour at"", ""all times of the day,"", ""all year round."", """", """", """", """", """", """", """", }) ); } }" "package com.rs.game.content.quests.tribaltotem; @PluginEventHandler public class RPDTEmployeeTribalTotemD extends Conversation { private static final int NPC = 843; public RPDTEmployeeTribalTotemD(Player player) { super(player); switch(player.getQuestManager().getStage(Quest.TRIBAL_TOTEM)) { case REDIRECT_TELE_STONE -> { addNPC(NPC, HeadE.CALM_TALK, ""Welcome to R.P.D.T.!""); if(player.getQuestManager().getAttribs(Quest.TRIBAL_TOTEM).getB(""CHANGED_CRATE"")) { addPlayer(HeadE.HAPPY_TALKING, ""So, when are you going to deliver this crate?""); addNPC(NPC, HeadE.CALM_TALK, ""Well...I guess we could do it now..."", ()->{ player.getQuestManager().setStage(Quest.TRIBAL_TOTEM, GET_TOTEM); player.sendMessage(""The crate is delivered to the mansion.""); }); } else addPlayer(HeadE.HAPPY_TALKING, ""Thank you.""); } default -> { addNPC(NPC, HeadE.CALM_TALK, ""Welcome to R.P.D.T.!""); addPlayer(HeadE.HAPPY_TALKING, ""Thank you.""); } } } public static NPCClickHandler handleDialogue = new NPCClickHandler(new Object[] { NPC }, e -> e.getPlayer().startConversation(new RPDTEmployeeTribalTotemD(e.getPlayer()).getStart())); }" "package com.rs.game.content.quests.tribaltotem; @QuestHandler( quest = Quest.TRIBAL_TOTEM, startText = ""Speak to Kangai Mau in Brimhaven."", itemsText = ""None."", combatText = ""None."", rewardsText = ""1,775 Thieving XP
5 swordfish"", completedStage = 4 ) @PluginEventHandler public class TribalTotem extends QuestOutline { public final static int NOT_STARTED = 0; public final static int TALK_TO_WIZARD = 1; public final static int REDIRECT_TELE_STONE = 2; public final static int GET_TOTEM = 3; public final static int QUEST_COMPLETE = 4; //Item public static final int TOTEM = 1857; @Override public List getJournalLines(Player player, int stage) { ArrayList lines = new ArrayList<>(); switch(stage) { case NOT_STARTED: lines.add(""Lord Handelmort of Ardougne is a collector of exotic ""); lines.add(""artefacts. A recent addition to his private collection is""); lines.add(""a strange looking totem from Karamja. The Rantuki Tribe ""); lines.add(""are not happy about the recent disappearance of their totem.""); lines.add(""""); lines.add(""I can start this quest by speaking to Kangai Mau at The""); lines.add(""Shrimp And Parrot Inn.""); lines.add(""""); lines.add(""~~Requirements~~""); lines.add(""21 Thieving""); lines.add(""""); break; case TALK_TO_WIZARD: lines.add(""Lord Handlemort has a mansion in Ardougne, we can poke around""); lines.add(""there. Though I hear Wizard Comperty has a way to teleport""); lines.add(""anywhere based on a stone. I ought to talk to him. He has his""); lines.add(""own building in eastern Ardougne by the marketplace.""); lines.add(""""); break; case REDIRECT_TELE_STONE: lines.add(""The rumor was true, Wizard Comperty has a way to teleport""); lines.add(""anywhere. But I somehow need to get the stone inside his""); lines.add(""mansion. I should check the delivery company RPDT and poke""); lines.add(""around. Maybe I can switch crates or something...""); lines.add(""""); break; case GET_TOTEM: lines.add(""Okay, the stone is in the mansion. Now I just need to tele""); lines.add(""in, get past the theft protection system and take the totem.""); lines.add(""I have deduced from my rumors that Handlemort's middle name is""); lines.add(""the password for the lock.""); lines.add(""""); lines.add(""Maybe I can get his middle name from the real estate agent or""); lines.add(""his paper guides about ardougne, south of the mansion.""); lines.add(""""); break; case QUEST_COMPLETE: lines.add(""""); lines.add(""""); lines.add(""QUEST COMPLETE!""); break; default: lines.add(""Invalid quest stage. Report this to an administrator.""); break; } return lines; } @Override public void complete(Player player) { player.getSkills().addXpQuest(Constants.THIEVING, 1775); player.getInventory().addItem(3144, 5, true);//Karambwan sendQuestCompleteInterface(player, TOTEM); } public static ObjectClickHandler handleFrontDoorMansion = new ObjectClickHandler(new Object[] { 2706 }, e -> { Player p = e.getPlayer(); p.sendMessage(""It is securely locked...""); }); public static ObjectClickHandler handleLockDoorInMansion = new ObjectClickHandler(new Object[] { 2705 }, e -> { Player p = e.getPlayer(); GameObject obj = e.getObject(); if (p.getX() < obj.getX() || p.isQuestComplete(Quest.TRIBAL_TOTEM) || (p.getQuestManager().getAttribs(Quest.TRIBAL_TOTEM).getO(""LOCK_PASS"") != null && ((String) p.getQuestManager().getAttribs(Quest.TRIBAL_TOTEM).getO(""LOCK_PASS"")).equalsIgnoreCase(""KURT""))) { handleDoor(p, obj); return; } p.getQuestManager().getAttribs(Quest.TRIBAL_TOTEM).setO(""LOCK_PASS"", ""AAAA""); p.getInterfaceManager().sendInterface(285);//Door lock tribal totem }); public static ItemClickHandler handleClickOnGuideBook = new ItemClickHandler(new Object[] { 1856 }, new String[] { ""Read"" }, e -> e.getPlayer().openBook(new RealEstateGuideBook())); public static ObjectClickHandler handleTrapStairs = new ObjectClickHandler(new Object[] { 2711 }, e -> { Player p = e.getPlayer(); GameObject obj = e.getObject(); if(e.getOption().equalsIgnoreCase(""climb-up"")) if(p.isQuestComplete(Quest.TRIBAL_TOTEM) || p.getQuestManager().getAttribs(Quest.TRIBAL_TOTEM).getB(""DISARMED_STAIRS"")) p.useStairs(-1, Tile.of(p.getX()-3, obj.getY(), p.getPlane() + 1), 0, 1); else { p.applyHit(new Hit(25, Hit.HitLook.TRUE_DAMAGE)); p.sendMessage(""You activate the trap stairs!""); p.tele(Tile.of(2638, 9721, 0)); } if(e.getOption().equalsIgnoreCase(""investigate"")) if(p.getQuestManager().getAttribs(Quest.TRIBAL_TOTEM).getB(""DISARMED_STAIRS"")) p.sendMessage(""It is already disarmed""); else if(p.getSkills().getLevel(Constants.THIEVING) < 21) p.startConversation(new Conversation(e.getPlayer()) { { addPlayer(HeadE.SAD, ""I can't seem to disarm the trap stairs...""); addSimple(""You need 21 thieving...""); create(); } }); else { p.getQuestManager().getAttribs(Quest.TRIBAL_TOTEM).setB(""DISARMED_STAIRS"", true); p.sendMessage(""You disarm the trap...""); } }); static final int FIRST_LETTER_COMP = 6; static final int SECOND_LETTER_COMP = 7; static final int THIRD_LETTER_COMP = 8; static final int FOURTH_LETTER_COMP = 9; static final String LETTERS = ""ABCDEFGHIJKLMNOPQRSTUVWXYZ""; public static ButtonClickHandler handleLockInterface = new ButtonClickHandler(285, e -> { Player p = e.getPlayer(); switch(e.getComponentId()) { case 18 -> {//Enter pass if(((String)p.getQuestManager().getAttribs(Quest.TRIBAL_TOTEM).getO(""LOCK_PASS"")).equalsIgnoreCase(""KURT"")) { p.sendMessage(""Correct password.""); p.closeInterfaces(); } else p.sendMessage(""Incorrect password.""); } //LEFT case 10 -> { if(p.getTempAttribs().getI(""ttLockCombo1"") > 0) p.getTempAttribs().decI(""ttLockCombo1""); p.getPackets().setIFText(e.getInterfaceId(), FIRST_LETTER_COMP, """"+LETTERS.charAt(p.getTempAttribs().getI(""ttLockCombo1""))); } case 12 -> { if(p.getTempAttribs().getI(""ttLockCombo2"") > 0) p.getTempAttribs().decI(""ttLockCombo2""); p.getPackets().setIFText(e.getInterfaceId(), SECOND_LETTER_COMP, """"+LETTERS.charAt(p.getTempAttribs().getI(""ttLockCombo2""))); } case 14 -> { if(p.getTempAttribs().getI(""ttLockCombo3"") > 0) p.getTempAttribs().decI(""ttLockCombo3""); p.getPackets().setIFText(e.getInterfaceId(), THIRD_LETTER_COMP, """"+LETTERS.charAt(p.getTempAttribs().getI(""ttLockCombo3""))); } case 16 -> { if(p.getTempAttribs().getI(""ttLockCombo4"") > 0) p.getTempAttribs().decI(""ttLockCombo4""); p.getPackets().setIFText(e.getInterfaceId(), FOURTH_LETTER_COMP, """"+LETTERS.charAt(p.getTempAttribs().getI(""ttLockCombo4""))); } //RIGHT case 11 -> { if(p.getTempAttribs().getI(""ttLockCombo1"") < LETTERS.length()-1) p.getTempAttribs().incI(""ttLockCombo1""); p.getPackets().setIFText(e.getInterfaceId(), FIRST_LETTER_COMP, """"+LETTERS.charAt(p.getTempAttribs().getI(""ttLockCombo1""))); } case 13 -> { if(p.getTempAttribs().getI(""ttLockCombo2"") < LETTERS.length()-1) p.getTempAttribs().incI(""ttLockCombo2""); p.getPackets().setIFText(e.getInterfaceId(), SECOND_LETTER_COMP, """"+LETTERS.charAt(p.getTempAttribs().getI(""ttLockCombo2""))); } case 15 -> { if(p.getTempAttribs().getI(""ttLockCombo3"") < LETTERS.length()-1) p.getTempAttribs().incI(""ttLockCombo3""); p.getPackets().setIFText(e.getInterfaceId(), THIRD_LETTER_COMP, """"+LETTERS.charAt(p.getTempAttribs().getI(""ttLockCombo3""))); } case 17 -> { if(p.getTempAttribs().getI(""ttLockCombo4"") < LETTERS.length()-1) p.getTempAttribs().incI(""ttLockCombo4""); p.getPackets().setIFText(e.getInterfaceId(), FOURTH_LETTER_COMP, """"+LETTERS.charAt(p.getTempAttribs().getI(""ttLockCombo4""))); } } String newPass = """"+LETTERS.charAt(p.getTempAttribs().getI(""ttLockCombo1"")) + LETTERS.charAt(p.getTempAttribs().getI(""ttLockCombo2"")) + LETTERS.charAt(p.getTempAttribs().getI(""ttLockCombo3"")) + LETTERS.charAt(p.getTempAttribs().getI(""ttLockCombo4"")); p.getQuestManager().getAttribs(Quest.TRIBAL_TOTEM).setO(""LOCK_PASS"", newPass); }); public static ObjectClickHandler handleMansionTotemChest = new ObjectClickHandler(new Object[] { 2709 }, e -> { Player p = e.getPlayer(); GameObject obj = e.getObject(); if(e.getOption().equalsIgnoreCase(""open"")) { p.setNextAnimation(new Animation(536)); p.lock(2); GameObject openedChest = new GameObject(obj.getId() + 1, obj.getType(), obj.getRotation(), obj.getX(), obj.getY(), obj.getPlane()); p.faceObject(openedChest); World.spawnObjectTemporary(openedChest, Ticks.fromMinutes(1)); if(!p.getInventory().containsItem(TOTEM, 1) && !p.isQuestComplete(Quest.TRIBAL_TOTEM)) { p.startConversation(new Dialogue().addPlayer(HeadE.SECRETIVE, ""This looks like the Totem. Now back to Brimhaven, I gotta"" + "" get this to Kangai Mau..."")); p.getInventory().addItem(new Item(TOTEM, 1)); } else p.sendMessage(""The chest is empty...""); } }); public static ObjectClickHandler handleRPDTCrate = new ObjectClickHandler(new Object[] { 2707 }, e -> { Player p = e.getPlayer(); if(p.getQuestManager().getStage(Quest.TRIBAL_TOTEM) == REDIRECT_TELE_STONE) p.simpleDialogue(""The address label says this crate is headed to Wizard's Tower in Draynor.""); }); public static ObjectClickHandler handleRPDTCrateMansion = new ObjectClickHandler(new Object[] { 2708 }, e -> { Player p = e.getPlayer(); GameObject obj = e.getObject(); if(obj.getTile().matches(Tile.of(2650, 3272, 0))) if(p.getQuestManager().getStage(Quest.TRIBAL_TOTEM) == REDIRECT_TELE_STONE) p.startConversation(new Conversation(e.getPlayer()) { { addSimple(""The address label says this crate is headed to Handlemort's mansion.""); if(p.getInventory().hasFreeSlots()) addSimple(""You take off the label."", ()-> p.getInventory().addItem(1858, 1)); else addSimple(""You need to make room for the label...""); create(); } }); }); public static ItemOnObjectHandler addressLabelOnCrate = new ItemOnObjectHandler(new Object[] { 2707 }, new Object[] { 1858 }, e -> { e.getPlayer().getInventory().removeItems(new Item(1858, 1)); e.getPlayer().getQuestManager().getAttribs(Quest.TRIBAL_TOTEM).setB(""CHANGED_CRATE"", true); e.getPlayer().sendMessage(""You switch the address labels... The stone now goes to the mansion.""); }); }" "package com.rs.game.content.quests.tribaltotem; @PluginEventHandler public class WizardCrompertyTribalTotemD extends Conversation { private static final int NPC = 844; public WizardCrompertyTribalTotemD(Player p, NPC npc) { super(p); switch(p.getQuestManager().getStage(Quest.TRIBAL_TOTEM)) { case GET_TOTEM -> { addPlayer(HeadE.HAPPY_TALKING, ""Can I be teleported please?""); addNPC(NPC, HeadE.CALM_TALK, ""By all means! I'm afraid I can't give you any specifics as to where you will come out however. Presumably "" + ""wherever the other block is located.""); addPlayer(HeadE.HAPPY_TALKING, ""Yes, that sounds good. Teleport me!""); addNPC(NPC, HeadE.CALM_TALK, ""Okey dokey! Ready?""); addNext(()->{ npc.setNextForceTalk(new ForceTalk(""Dipsolum sentento sententi!"")); World.sendProjectile(npc, p, 50, 5, 5, 5, 1, 5, 0); p.lock(3); WorldTasks.schedule(new Task() { @Override public void run() { p.tele(Tile.of(2642, 3321, 0));//Mansion in ardy } }, 2); }); } default -> { addNPC(NPC, HeadE.CALM_TALK, ""Hello Player, I'm Cromperty. Sedridor has told me about you. As a wizard and an inventor, he has aided me in"" + "" my great invention!""); addOptions(""Choose an option:"", new Options() { @Override public void create() { option(""Two jobs? That's got to be tough"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Two jobs? That's got to be tough"") .addNPC(NPC, HeadE.CALM_TALK, ""Not when you combine them it isn't! Invent MAGIC things!"") ); option(""So, what have you invented?"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""So, what have you invented?"") .addNPC(NPC, HeadE.CALM_TALK, ""Ah! My latest invention is my patent pending teleportation block! It emits a low level magical"" + "" signal, that will allow me to locate it anywhere in the world,"") .addNPC(NPC, HeadE.CALM_TALK, ""and teleport anything directly to it! I hope to revolutionize the entire teleportation system! "" + ""Don't you think I'm great? Uh, I mean it's great?"", ()-> { if(p.getQuestManager().getStage(Quest.TRIBAL_TOTEM) == TALK_TO_WIZARD) p.getQuestManager().setStage(Quest.TRIBAL_TOTEM, REDIRECT_TELE_STONE); }) .addNPC(NPC, HeadE.CALM_TALK, ""So... want me to teleport you to it?"") .addOptions(""Teleport?"", new Options() { @Override public void create() { option(""Yes"", new Dialogue() .addNext(()->{ NPC wizard = null; for(NPC npc : World.getNPCsInChunkRange(p.getChunkId(), 1)) if(npc.getId() == NPC) wizard = npc; wizard.setNextForceTalk(new ForceTalk(""Dipsolum sentento sententi!"")); World.sendProjectile(wizard, p, 50, 5, 5, 5, 1, 5, 0); p.lock(3); WorldTasks.schedule(new Task() { @Override public void run() { if(p.getQuestManager().getStage(Quest.TRIBAL_TOTEM) >= GET_TOTEM) p.tele(Tile.of(2642, 3321, 0)); //Mansion in ardy else p.tele(Tile.of(2649, 3271, 0)); //RPDT crates in ardy } }, 2); })); option(""No"", new Dialogue()); } }) ); option(""So where is the other block?"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""So where is the other block?"") .addNPC(NPC, HeadE.CALM_TALK, ""Well...Hmm. I would guess somewhere between here and the Wizards' Tower in Misthalin."") .addNPC(NPC, HeadE.CALM_TALK, ""All I know is that it hasn't got there yet as the wizards there would have contacted me. "" + ""I'm using the RPDT for delivery. They assured me it would be delivered promptly."") .addPlayer(HeadE.HAPPY_TALKING, ""Who are the RPDT?"") .addNPC(NPC, HeadE.CALM_TALK, ""The Runescape Parcel Delivery Team. They come very highly recommended. Their motto is: \""We "" + ""aim to deliver your stuff at some point after you have paid us!\"""", ()-> { if(p.getQuestManager().getStage(Quest.TRIBAL_TOTEM) == TALK_TO_WIZARD) p.getQuestManager().setStage(Quest.TRIBAL_TOTEM, REDIRECT_TELE_STONE); }) ); } }); } } } public static NPCClickHandler handleDialogue = new NPCClickHandler(new Object[] { NPC }, e -> e.getPlayer().startConversation(new WizardCrompertyTribalTotemD(e.getPlayer(), e.getNPC()).getStart())); }" "package com.rs.game.content.quests.vampireslayer; @PluginEventHandler public class CountDraynorBoss extends OwnedNPC { private static final int COUNT_DRAYNOR_ID = 9356; //Vampyre animations static final int STUNNED = 1568; static final int ASLEEP_IN_COFFIN = 3111; static final int AWAKEN = 3322; static final int SPAWN = 3328; static final int DEATH = 12604; //Player animations static final int OPEN_COFFIN = 2991; static final int MISSING_STAKE_IN_COFFIN = 2992; static final int PUSHED_BACK = 3064; static final int ON_FLOOR = 16713; static final int KILL_W_STAKE = 12606; //Coffin ID/animations static final int COFFIN_ID = 162; static final int COFFIN_OPEN = 3112; //Item static final int STAKE = 1549; static final int STAKE_HAMMER = 15417; static final int REGULAR_HAMMER = 2347; static final int GARLIC = 1550; //Count draynor boss music static final int COUNTING_ON_YOU = 717; public boolean actuallyDead = false; public CountDraynorBoss(Player owner, Tile tile) { super(owner, COUNT_DRAYNOR_ID, tile, false); setAutoDespawnAtDistance(false); } @Override public void sendDeath(Entity source) { removeTarget(); setAttackedBy(null); resetHP(); setLocked(true); faceEntity(source); WorldTasks.scheduleLooping(new Task() { int tick = 0; final int finalTick = Ticks.fromSeconds(12); @Override public void run() { if(World.getPlayersInChunkRange(getChunkId(), 2).isEmpty()) finish(); if(tick == 1) setNextAnimation(new Animation(STUNNED)); if(tick == finalTick - 1) setLocked(false); if(tick == finalTick) { setTarget(source); stop(); } tick++; } }, 0, 1); } /** * player in die is seperate from player in the boss. * @param player */ public void die(Player player) { if(getOwner() == null) return; if(player != getOwner()) { player.sendMessage(""This is not your vampyre to kill!""); return; } WorldTasks.scheduleLooping(new Task() { int tick = 0; @Override public void run() { if(tick == 0) { player.setNextAnimation(new Animation(KILL_W_STAKE)); setNextAnimation(new Animation(DEATH)); } if(tick == 5) { finish(); player.getQuestManager().setStage(Quest.VAMPYRE_SLAYER, VampireSlayer.VAMPYRE_KILLED); player.startConversation(new Conversation(player) { { addPlayer(HeadE.CALM_TALK, ""I should tell Morgan that I've killed the vampyre!""); } }); stop(); } tick++; } }, 0, 1); } public static ObjectClickHandler handleCoffin = new ObjectClickHandler(new Object[] { 158, COFFIN_ID}, e -> { Player p = e.getPlayer(); if(p.getQuestManager().getStage(Quest.VAMPYRE_SLAYER) != VampireSlayer.STAKE_RECIEVED) return; if(e.getObject().getId() == COFFIN_ID) { p.startConversation(new Conversation(p) { { addPlayer(HeadE.CALM_TALK, ""Count Draynor isn't here. He'll probably be back soon...""); } }); return; } if(!p.getInventory().containsItem(STAKE, 1) || (!p.getInventory().containsItem(STAKE_HAMMER, 1) && !p.getInventory().containsItem(REGULAR_HAMMER, 1))) { p.startConversation(new Conversation(p) { { addPlayer(HeadE.CALM_TALK, ""I'll need both a stake and stake hammer or hammer, better go get those...""); } }); return; } if(e.getObject().getId() == 158) { World.removeObject(e.getObject()); World.spawnObject(new GameObject(COFFIN_ID, e.getObject().getType(), e.getObject().getRotation(), e.getObject().getTile()), true); } p.save(""live_in_scene"", true); p.lock(); GameObject coffin = World.getObject(e.getObject().getTile(), ObjectType.forId(10)); p.getMusicsManager().playSongAndUnlock(COUNTING_ON_YOU); CountDraynorBoss countDraynor = new CountDraynorBoss(p, Tile.of(coffin.getX()+1, coffin.getY()+1, coffin.getPlane())); countDraynor.setLocked(true); countDraynor.faceTile(Tile.of(coffin.getX()+1, coffin.getY() - 5, coffin.getPlane())); countDraynor.setHidden(true); WorldTasks.schedule(new Task() { @Override public void run() { World.removeObject(coffin); World.spawnObject(new GameObject(158, e.getObject().getType(), e.getObject().getRotation(), e.getObject().getTile()), true); countDraynor.finish(); } }, Ticks.fromMinutes(3)); WorldTasks.scheduleLooping(new Task() { int tick = 0; @Override public void run() { if(tick == 0) p.getInterfaceManager().setFadingInterface(115); if(tick == 3) { p.tele(Tile.of(3079, 9786, 0)); p.getPackets().sendCameraPos(coffin.getTile().getXInScene(p.getSceneBaseChunkId())-4, coffin.getTile().getYInScene(p.getSceneBaseChunkId())-8, 3000); p.getPackets().sendCameraLook(coffin.getTile().getXInScene(p.getSceneBaseChunkId()), coffin.getTile().getYInScene(p.getSceneBaseChunkId()), 300); } if(tick == 4) p.getInterfaceManager().setFadingInterface(170); if(tick == 5) p.faceObject(coffin); if(tick == 6) { p.setNextAnimation(new Animation(OPEN_COFFIN)); p.getPackets().sendObjectAnimation(coffin, new Animation(COFFIN_OPEN)); countDraynor.setHidden(false); countDraynor.setNextAnimation(new Animation(ASLEEP_IN_COFFIN)); } if(tick == 8) { p.getInventory().deleteItem(STAKE, 1); p.setNextAnimation(new Animation(MISSING_STAKE_IN_COFFIN)); countDraynor.setNextAnimation(new Animation(AWAKEN)); countDraynor.setAutoDespawnAtDistance(true); } if(tick == 9) p.forceMove(Tile.of(p.getX()-1, p.getY(), p.getPlane()), Direction.EAST, PUSHED_BACK, 0, 30); if(tick == 10) { p.setNextAnimation(new Animation(ON_FLOOR)); p.getPackets().sendCameraPos(coffin.getTile().getXInScene(p.getSceneBaseChunkId())-4, coffin.getTile().getYInScene(p.getSceneBaseChunkId())-16, 2200, 0, 5); p.getPackets().sendCameraLook(coffin.getTile().getXInScene(p.getSceneBaseChunkId()), coffin.getTile().getYInScene(p.getSceneBaseChunkId())-5, 50, 5, 0); } if(tick == 14) countDraynor.faceTile(Tile.of(countDraynor.getX(), countDraynor.getY()+3, countDraynor.getPlane())); if(tick == 16) { countDraynor.tele(Tile.of(3082, 9776, 0)); countDraynor.setNextAnimation(new Animation(SPAWN)); } if(tick == 19) { countDraynor.setLocked(false); countDraynor.setRandomWalk(true); } if(tick == 20) { countDraynor.setTarget(p); p.faceEntity(countDraynor); } if(tick == 22) { if(p.getInventory().containsItem(GARLIC, 1)) { countDraynor.lowerDefense(5, 0.0); countDraynor.lowerStrength(5, 0.0); p.sendMessage(""The garlic has weakened Count Draynor...""); } p.getPackets().sendResetCamera(); p.unlock(); p.save(""live_in_scene"", false); stop(); } tick++; } }, 0, 1); }); public static LoginHandler onLogin = new LoginHandler(e -> { if(e.getPlayer().getBool(""live_in_scene"")) e.getPlayer().unlock(); }); public static ItemOnNPCHandler hammerOnCountDraynor = new ItemOnNPCHandler(COUNT_DRAYNOR_ID, e -> { if (e.getItem().getId() != STAKE_HAMMER && e.getItem().getId() != REGULAR_HAMMER) return; if ((e.getNPC() instanceof CountDraynorBoss boss) && boss.isLocked()) { boss.die(e.getPlayer()); return; } e.getPlayer().sendMessage(""I must weaken him first""); }); }" "package com.rs.game.content.quests.vampireslayer; @PluginEventHandler public class HarlowVampireSlayerD extends Conversation { final static int HARLOW = 756; static final int STAKE_HAMMER = 15417; static final int STAKE = 1549; static final int BEER = 1917; public HarlowVampireSlayerD(Player player) { super(player); switch (player.getQuestManager().getStage(Quest.VAMPYRE_SLAYER)) { case VampireSlayer.NOT_STARTED: case VampireSlayer.QUEST_COMPLETE: addNPC(HARLOW, HeadE.DRUNK, ""Buy me a drrink pleassh...""); addPlayer(HeadE.FRUSTRATED, ""I think you've had enough.""); break; case VampireSlayer.STARTED: addNPC(HARLOW, HeadE.DRUNK, ""Buy me a drrink pleassh...""); addOptions(""Choose an option:"", new Options() { @Override public void create() { option(""No, you've had enough."", new Dialogue() .addPlayer(HeadE.FRUSTRATED, ""No, you've had enough"")); option(""Morgan needs your help!"", new Dialogue() .addPlayer(HeadE.TALKING_ALOT, ""Morgan needs your help!"") .addNPC(HARLOW, HeadE.DRUNK, ""Morgan you shhay..?"") .addPlayer(HeadE.AMAZED_MILD, ""His village is being terrorised by a vampyre! He told me to ask you about how I can stop it."") .addNPC(HARLOW, HeadE.DRUNK, ""Buy me a beer... then I'll teash you what you need to know..."") .addPlayer(HeadE.FRUSTRATED, ""But this is your friend Morgan we're talking about!"") .addNPC(HARLOW, HeadE.DRUNK, ""Buy ush a drink anyway..."", () -> player.getQuestManager().setStage(Quest.VAMPYRE_SLAYER, VampireSlayer.HARLOW_NEED_DRINK))); } }); break; case VampireSlayer.HARLOW_NEED_DRINK: if(player.getInventory().containsItem(STAKE, 1)) { addNPC(HARLOW, HeadE.CALM_TALK, ""Don't forget to take your stake with you, otherwise he'll just regenerate. Yes, you must have a "" + ""stake to finish it off... I'd give you a stake but you've already got one in your inventory.""); addNPC(HARLOW, HeadE.CALM_TALK, "" You'll need a hammer as well, to drive it in properly, your everyday general store hammer will do. ""); addNPC(HARLOW, HeadE.CALM_TALK, ""One last thing... It's wise to carry garlic with you, vampyres are somewhat weakened if they can smell "" + ""garlic.""); addNPC(HARLOW, HeadE.CALM_TALK, ""Morgan always liked garlic, you should try his house. But remember, a vampyre is still a dangerous foe!""); } else if(player.getInventory().containsItem(BEER, 1)) { addNPC(HARLOW, HeadE.DRUNK, ""Buy me a drrink pleassh...""); addPlayer(HeadE.CALM_TALK, ""Here you go""); addSimple(""You give a beer to Dr Harlow."", () -> player.getInventory().deleteItem(BEER, 1)); addNPC(HARLOW, HeadE.DRUNK, ""Cheersh matey...""); addPlayer(HeadE.HAPPY_TALKING, ""So tell me how to kill vampyres then.""); addNPC(HARLOW, HeadE.DRUNK, ""Yesh Yesh vampyres, I was very good at killing em once...""); addSimple(""Dr Harlow appears to sober up slightly.""); addNPC(HARLOW, HeadE.CALM_TALK, ""Well, you're going to need a stake, otherwise he'll just regenerate. Yes, you must have a stake to "" + ""finish it off... I just happen to have one with me.""); addSimple(""Dr Harlow hands you a stake and hammer."", ()->{ player.getInventory().addItem(STAKE, 1); player.getInventory().addItem(STAKE_HAMMER, 1); player.getQuestManager().setStage(Quest.VAMPYRE_SLAYER, VampireSlayer.STAKE_RECIEVED); }); addNPC(HARLOW, HeadE.CALM_TALK, ""You'll need this hammer as well, to drive it in properly. One last thing...""); addNPC(HARLOW, HeadE.CALM_TALK, ""It's wise to carry garlic with you, vampyres are somewhat weakened if they can smell garlic. Morgan "" + ""always liked garlic, you should try his house. But remember, a vampyre is still a dangerous foe!""); addPlayer(HeadE.HAPPY_TALKING, ""Thank you very much!""); } else { addNPC(HARLOW, HeadE.DRUNK, ""Buy me a drrink pleassh...""); addPlayer(HeadE.HAPPY_TALKING, ""I'll just go and buy one.""); } break; case VampireSlayer.STAKE_RECIEVED: if(player.getInventory().containsItem(STAKE, 1)) { addNPC(HARLOW, HeadE.CALM_TALK, ""Don't forget to take your stake with you, otherwise he'll just regenerate. Yes, you must have a "" + ""stake to finish it off... I'd give you a stake but you've already got one in your inventory.""); addNPC(HARLOW, HeadE.CALM_TALK, "" You'll need a hammer as well, to drive it in properly, your everyday general store hammer will do. ""); addNPC(HARLOW, HeadE.CALM_TALK, ""One last thing... It's wise to carry garlic with you, vampyres are somewhat weakened if they can smell "" + ""garlic.""); addNPC(HARLOW, HeadE.CALM_TALK, ""Morgan always liked garlic, you should try his house. But remember, a vampyre is still a dangerous foe!""); } else if((!player.getInventory().containsItem(STAKE, 1) || !player.getInventory().containsItem(STAKE_HAMMER, 1)) && !player.getInventory().containsItem(BEER, 1)) { addPlayer(HeadE.SAD, ""I lost the stake and hammer you gave me.""); addNPC(HARLOW, HeadE.DRUNK, ""Bring me another beer and i'll give you another stake.""); addPlayer(HeadE.FRUSTRATED, ""Fine!""); } else if(player.getInventory().containsItem(BEER, 1)) { addNPC(HARLOW, HeadE.DRUNK, ""Buy me a drrink pleassh...""); addPlayer(HeadE.CALM_TALK, ""Here you go""); addSimple(""You give a beer to Dr Harlow."", () -> player.getInventory().deleteItem(BEER, 1)); addNPC(HARLOW, HeadE.DRUNK, ""Cheersh matey...""); addPlayer(HeadE.HAPPY_TALKING, ""So tell me how to kill vampyres then.""); addNPC(HARLOW, HeadE.DRUNK, ""Yesh Yesh vampyres, I was very good at killing em once...""); addSimple(""Dr Harlow appears to sober up slightly.""); addNPC(HARLOW, HeadE.CALM_TALK, ""Well, you're going to need a stake, otherwise he'll just regenerate. Yes, you must have a stake to "" + ""finish it off... I just happen to have one with me.""); addSimple(""Dr Harlow hands you a stake and hammer."", ()->{ if(!player.getInventory().containsItem(STAKE)) player.getInventory().addItem(STAKE, 1); if(!player.getInventory().containsItem(STAKE_HAMMER)) player.getInventory().addItem(STAKE_HAMMER, 1); }); addNPC(HARLOW, HeadE.CALM_TALK, ""You'll need a hammer as well, to drive it in properly, your everyday general store hammer will do."" + "" One last thing...""); addNPC(HARLOW, HeadE.CALM_TALK, ""It's wise to carry garlic with you, vampyres are somewhat weakened if they can smell garlic. Morgan "" + ""always liked garlic, you should try his house. But remember, a vampyre is still a dangerous foe!""); } break; } } public static NPCClickHandler handleHarlow = new NPCClickHandler(new Object[] { HARLOW }, e -> e.getPlayer().startConversation(new HarlowVampireSlayerD(e.getPlayer()).getStart())); }" "package com.rs.game.content.quests.vampireslayer; @PluginEventHandler public class MorganVampireSlayerD extends Conversation { final static int MORGAN = 755; public MorganVampireSlayerD(Player player) { super(player); switch (player.getQuestManager().getStage(Quest.VAMPYRE_SLAYER)) { case VampireSlayer.NOT_STARTED: addNPC(MORGAN, HeadE.WORRIED, ""Please please help us, bold adventurer!""); addPlayer(HeadE.SKEPTICAL_THINKING, ""What's the problem?""); addNPC(MORGAN, HeadE.SAD_CRYING, ""Our little village has been dreadfully ravaged by an evil vampyre! He lives in the basement of the manor"" + "" to the north, we need someone to get rid of him once and for all!""); addOptions(""Choose an option:"", new Options() { @Override public void create() { option(""No, vampyres are scary!"", new Dialogue() .addPlayer(HeadE.SCARED, ""No, vampyres are scary!"") .addNPC(MORGAN, HeadE.SAD, ""I don't blame you."")); option(""Ok, I'm up for an adventure."", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Ok, I'm up for an adventure."") .addNPC(MORGAN, HeadE.CALM_TALK, ""I think first you should seek help. I have a friend who is a retired vampyre hunter, "" + ""his name is Dr. Harlow. He may be able to give you some tips. "") .addNPC(MORGAN, HeadE.CALM_TALK, ""He can normally be found in the Blue Moon Inn in Varrock, he's a bit of an old soak "" + ""these days. Mention his old friend Morgan, I'm sure he wouldn't want me killed by a vampyre."") .addPlayer(HeadE.HAPPY_TALKING, ""I'll look him up then."") .addNext(()-> player.getQuestManager().setStage(Quest.VAMPYRE_SLAYER, VampireSlayer.STARTED))); option(""Have you got any tips on killing the vampyre?"", new Dialogue() .addPlayer(HeadE.CALM_TALK, ""Have you got any tips on killing the vampyre?"") .addNPC(MORGAN, HeadE.CALM_TALK, ""I think first you should seek help. I have a friend who is a retired vampyre hunter, "" + ""his name is Dr. Harlow. He may be able to give you some tips. "") .addNPC(MORGAN, HeadE.CALM_TALK, ""He can normally be found in the Blue Moon Inn in Varrock, he's a bit of an old soak "" + ""these days. Mention his old friend Morgan, I'm sure he wouldn't want me killed by a vampyre."") .addPlayer(HeadE.HAPPY_TALKING, ""I'll look him up then."") .addNext(()-> player.getQuestManager().setStage(Quest.VAMPYRE_SLAYER, VampireSlayer.STARTED))); } }); break; case VampireSlayer.STARTED: addNPC(MORGAN, HeadE.CALM_TALK, ""How are you doing with the quest?""); addPlayer(HeadE.CALM_TALK, ""I'm still working on it.""); addNPC(MORGAN, HeadE.SCARED, ""Please hurry! Every day we live in fear that we will be the vampyre's next victim!""); break; case VampireSlayer.STAKE_RECIEVED: if(player.getTempAttribs().getB(""morganHarlowPrompt"")) { addNPC(MORGAN, HeadE.SCARED, ""Please hurry...""); break; } addNPC(MORGAN, HeadE.CALM_TALK, ""Have you talked to Dr. Harlow?""); addPlayer(HeadE.CALM_TALK, ""Yes, I just need a stake & hammer and I am ready to kill the vampyre.""); addNPC(MORGAN, HeadE.SCARED, ""Great, please hurry every day we live in fear we will be the vampyre's next victim!"", ()-> player.getTempAttribs().setB(""morganHarlowPrompt"", true)); break; case VampireSlayer.VAMPYRE_KILLED: addPlayer(HeadE.HAPPY_TALKING, ""I have slain the foul creature!""); addNPC(MORGAN, HeadE.HAPPY_TALKING, ""Thank you, thank you! You will always be a hero in our village!""); addNext(()-> player.getQuestManager().completeQuest(Quest.VAMPYRE_SLAYER)); break; case VampireSlayer.QUEST_COMPLETE: addNPC(MORGAN, HeadE.HAPPY_TALKING, ""Thank you once again for slaying Count Draynor, we are in your debt.""); break; } } public static NPCClickHandler handleMorgan = new NPCClickHandler(new Object[] { MORGAN }, e -> e.getPlayer().startConversation(new MorganVampireSlayerD(e.getPlayer()).getStart())); }" "package com.rs.game.content.quests.vampireslayer; @QuestHandler( quest = Quest.VAMPYRE_SLAYER, startText = ""Talk to Morgan in Draynor Village."", itemsText = ""Beer (or 2 coins to purchase a pint)."", combatText = ""You will need to defeat a level 28 enemy."", rewardsText = ""4,825 Attack XP"", completedStage = 5 ) @PluginEventHandler public class VampireSlayer extends QuestOutline { static final int NOT_STARTED = 0; static final int STARTED = 1; static final int HARLOW_NEED_DRINK = 2; static final int STAKE_RECIEVED = 3; static final int VAMPYRE_KILLED = 4; static final int QUEST_COMPLETE = 5; static final int STAKE = 1549; @Override public List getJournalLines(Player player, int stage) { ArrayList lines = new ArrayList<>(); switch(stage) { case NOT_STARTED: lines.add(""The people of Draynor village live in constant terror. Their numbers""); lines.add(""are dwindling, all due to a foul creature known as a vampyre,""); lines.add(""lurking in the manor to the north.""); lines.add(""""); lines.add(""I can start this quest by speaking to Morgan in Draynor.""); lines.add(""""); break; case STARTED: lines.add(""Morgan says I can get lessons on defeating a vampyre from""); lines.add(""Dr. Harlow at the Blue Moon Inn in south Varrock.""); lines.add(""""); break; case HARLOW_NEED_DRINK: lines.add(""It seems I will have to give in and get Dr. Harlow a beer.""); lines.add(""I should get one from the bartender at the Blue Moon Inn""); lines.add(""""); break; case STAKE_RECIEVED: lines.add(""Dr. Harlow gave me a stake and told me to use it to kill the""); lines.add(""vampyre""); lines.add(""""); lines.add(""To kill the vampyre I need:""); lines.add(""A stake""); lines.add(""A hammer""); lines.add(""Garlic in my inventory (optional)""); lines.add(""""); lines.add(""I can find the vampyre in the Draynor Manor basement.""); lines.add(""""); break; case VAMPYRE_KILLED: lines.add(""I have killed Count Draynor! I should report back to""); lines.add(""Morgan.""); lines.add(""""); break; case QUEST_COMPLETE: lines.add(""""); lines.add(""""); lines.add(""QUEST COMPLETE!""); break; default: lines.add(""Invalid quest stage. Report this to an administrator.""); break; } return lines; } @Override public void complete(Player player) { player.getSkills().addXpQuest(Skills.ATTACK, 4825); sendQuestCompleteInterface(player, STAKE); } public static NPCInteractionDistanceHandler bartenderBlueMoonDistance = new NPCInteractionDistanceHandler(733, (player, npc) -> 5); }" "package com.rs.game.content.quests.waterfallquest; public class AlmeraD extends Conversation { public AlmeraD(Player player) { super(player); int NPC = 304; addOptions(""Choose an option:"", new Options() { @Override public void create() { option(""How is life on the waterfall?"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""How is life on the waterfall?"") .addNPC(NPC, HeadE.CALM_TALK, ""I am worried about my son, but other than that everything is fine."") ); option(""I am looking for a quest."", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""I am looking for a quest."") .addNPC(NPC, HeadE.CALM_TALK, ""I might have one for you. My son Hudon has gone missing on some hunt for treasure in the waterfall."") .addNPC(NPC, HeadE.CALM_TALK, ""Could you please go make sure he is alright for me?"") .addQuestStart(Quest.WATERFALL_QUEST) .addOptions(""Choose an option:"", new Options() { @Override public void create() { option(""Of course."", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Of course I will."", () -> player.getQuestManager().setStage(Quest.WATERFALL_QUEST, 1)) .addNPC(NPC, HeadE.CALM_TALK, ""Thank you so much!"") ); option(""No thanks, I don't have time right now."", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Sorry, but I don't have time right now. Bye."") ); } }) ); } }); } }" "package com.rs.game.content.quests.waterfallquest; public class GolrieD extends Conversation { public GolrieD(Player player) { super(player); int NPC = 306; if(player.getQuestManager().getStage(Quest.WATERFALL_QUEST) == 3) { addPlayer(HeadE.HAPPY_TALKING, ""Hi, I heard you may be able to help me.""); addNPC(NPC, HeadE.CALM_TALK, ""I might have something of use laying around in here somewhere.""); addPlayer(HeadE.CONFUSED, ""Mind if I take a look?""); addNPC(NPC, HeadE.HAPPY_TALKING, ""No, by all means go ahead.""); addPlayer(HeadE.HAPPY_TALKING, ""Could I have this old pebble?""); addNPC(NPC, HeadE.CALM_TALK, ""Sure, it's of no use to me.""); addPlayer(HeadE.HAPPY_TALKING, ""Thank you very much for your time."", ()->{ player.getQuestManager().setStage(Quest.WATERFALL_QUEST, 4); player.getInventory().addItem(294, 1); }); addNPC(NPC, HeadE.HAPPY_TALKING, ""And thanks for saving me from this disgusting hole.""); addPlayer(HeadE.HAPPY_TALKING, ""You're welcome.""); return; } if(player.getQuestManager().getStage(Quest.WATERFALL_QUEST) > 3) { addNPC(NPC, HeadE.CALM_TALK, ""Have you lost Glarial's pebble?""); if(player.getInventory().containsItem(294)) { addPlayer(HeadE.HAPPY_TALKING, ""Nope, just passing by.""); addNPC(NPC, HeadE.CALM_TALK, ""Ah, well take care now!""); return; } addPlayer(HeadE.SAD, ""Yes I have...""); addNPC(NPC, HeadE.HAPPY_TALKING, ""Here. Take this one I just found."", ()-> player.getInventory().addItem(294, 1)); return; } addNPC(NPC, HeadE.CONFUSED, ""What are you doing here?""); addPlayer(HeadE.HAPPY_TALKING, ""No idea...""); } }" "package com.rs.game.content.quests.waterfallquest; public class HudonD extends Conversation { public HudonD(Player player, int hudonId) { super(player); if (player.getQuestManager().getStage(Quest.WATERFALL_QUEST) == 1) { addPlayer(HeadE.TALKING_ALOT, ""Hey Hudon! Your mother is worried about you! Are you doing alright?""); addNPC(hudonId, HeadE.CHILD_UNSURE, ""Who are you and what do you want? You must want my treasure!""); addPlayer(HeadE.TALKING_ALOT, ""Your mother wants you to come home!""); addNPC(hudonId, HeadE.CHILD_ANGRY, ""No! There is too much treasure to be found!""); addPlayer(HeadE.CONFUSED, ""What treasure?""); addNPC(hudonId, HeadE.CHILD_HAPPY_TALK, ""The treasure inside the waterfall!""); addPlayer(HeadE.TALKING_ALOT, ""Can I look for treasure with you?""); addNPC(hudonId, HeadE.CHILD_ANGRY, ""No! You will steal it all!""); addPlayer(HeadE.TALKING_ALOT, ""Very well then.."", () -> player.getQuestManager().setStage(Quest.WATERFALL_QUEST, 2)); } else if (player.getQuestManager().getStage(Quest.WATERFALL_QUEST) > 1) addNPC(hudonId, HeadE.CHILD_ANGRY, ""I already told you! I am not letting you come with me to find the treasure!""); else addNPC(hudonId, HeadE.CHILD_ANGRY, ""Leave me alone! I have treasure to find!""); create(); } }" "package com.rs.game.content.quests.waterfallquest; @QuestHandler( quest = Quest.WATERFALL_QUEST, startText = ""Speak to Almera in her house north-east of the Baxtorian Falls."", itemsText = ""Rope, 6 air runes, 6 earth runes, 6 water runes."", combatText = ""None, but you must be able to survive some attacks from level 44 giant spiders and level 58 skeletons."", rewardsText = ""13,750 Attack XP
13,750 Strength XP
2 gold bars
2 diamonds
40 mithril seeds
Access to the Waterfall Dungeon"", completedStage = 6 ) @PluginEventHandler public class WaterfallQuest extends QuestOutline { @Override public List getJournalLines(Player player, int stage) { ArrayList lines = new ArrayList<>(); switch (stage) { case 0: lines.add(""I can start this quest by speaking with Almera""); lines.add(""by the waterfall south of barbarian assault.""); break; case 1: lines.add(""Almera is worried about her son Hudon. I should find""); lines.add(""him and see what he is up to.""); break; case 2: lines.add(""Hudon mentioned some treasure he is looking for inside the""); lines.add(""waterfall.""); lines.add(""Perhaps I could find some information about this treasure""); lines.add(""somewhere nearby.""); break; case 3: lines.add(""I read that there is a gnome named Golrie that may be able""); lines.add(""to help me unlock the secrets behind the Baxtorian treasure.""); lines.add(""Last he was seen was near Yanille by the Tree Gnome Village.""); break; case 4: lines.add(""I freed Golrie from his prison underneath the Tree Gnome""); lines.add(""Village and found a small pebble that used to belong to""); lines.add(""the elf queen, Glarial.""); lines.add(""Maybe it could grant access to the waterfall somehow.""); break; case 5: lines.add(""I have located the treasure inside the waterfall.""); lines.add(""Now to find a safe way to take the treasure without""); lines.add(""triggering the water trap and being washed outside.""); break; case 6: lines.add(""""); lines.add(""""); lines.add(""QUEST COMPLETE!""); break; default: lines.add(""Invalid quest stage. Report this to an administrator.""); break; } return lines; } @Override public void complete(Player player) { player.getSkills().addXpQuest(Constants.ATTACK, 13750); player.getSkills().addXpQuest(Constants.STRENGTH, 13750); player.getInventory().addItem(299, 40, true); player.getInventory().addItem(1601, 2, true); player.getInventory().addItem(2357, 2, true); sendQuestCompleteInterface(player, 1601); } public static NPCClickHandler handleHudon = new NPCClickHandler(false, new Object[] { ""Hudon"" }, e -> { if (e.getOpNum() == 1) { e.getNPC().resetWalkSteps(); e.getPlayer().resetWalkSteps(); e.getPlayer().faceEntity(e.getNPC()); e.getNPC().faceEntity(e.getPlayer()); e.getPlayer().startConversation(new HudonD(e.getPlayer(), e.getNPC().getId())); } }); public static NPCClickHandler handleAlmera = new NPCClickHandler(new Object[] { 304 }, e -> e.getPlayer().startConversation(new AlmeraD(e.getPlayer()))); public static NPCClickHandler handleGolrie = new NPCClickHandler(new Object[] { 306 }, e -> e.getPlayer().startConversation(new GolrieD(e.getPlayer()))); public static ObjectClickHandler keyCrateSearch = new ObjectClickHandler(new Object[] { 31139 }, Tile.of(2593, 9881, 0), e -> { e.getPlayer().sendMessage(""You search the crate.""); if (e.getPlayer().getInventory().containsItem(293, 1)) e.getPlayer().sendMessage(""You find nothing of interest.""); else { e.getPlayer().getInventory().addItem(293, 1); e.getPlayer().sendMessage(""You find an old key.""); } }); public static ObjectClickHandler ladderGlarialsTomb = new ObjectClickHandler(new Object[] { 1757 }, e -> e.getPlayer().useLadder(e.getPlayer().transform(0, -6400))); public static ObjectClickHandler handleObjects = new ObjectClickHandler(new Object[] { 1987, 1990, 5251, 5250, 10283, 2020, 33047, 33066, 2022, 2014, 37247, 31139, 2002, 1991, 1989 }, e -> { if (e.getObjectId() == 1987) { e.getPlayer().sendMessage(""You board the log raft and crash on a small spit of land.""); e.getPlayer().tele(Tile.of(2512, 3481, 0)); } else if (e.getObjectId() == 1990) { if (e.getPlayer().getQuestManager().getStage(Quest.WATERFALL_QUEST) >= 3 && !e.getPlayer().getInventory().containsItem(298, 1)) { e.getPlayer().sendMessage(""You find a large old key.""); e.getPlayer().getInventory().addItem(298, 1); } else e.getPlayer().sendMessage(""You find nothing interesting.""); } else if (e.getObjectId() == 5251) e.getPlayer().useStairs(828, Tile.of(e.getPlayer().getX(), e.getPlayer().getY() - 6400, 0), 1, 2); else if (e.getObjectId() == 5250) e.getPlayer().useStairs(828, Tile.of(e.getPlayer().getX(), e.getPlayer().getY() + 6400, 0), 1, 2); else if (e.getObjectId() == 10283) { e.getPlayer().sendMessage(""You try to swim down the river but you get swept away and over the waterfall.""); e.getPlayer().tele(Tile.of(2531, 3413, 0)); e.getPlayer().applyHit(new Hit(e.getPlayer(), Utils.random(20, 56), HitLook.TRUE_DAMAGE)); } else if (e.getObjectId() == 2020) { e.getPlayer().sendMessage(""You slip from the tree and fall down the waterfall.""); e.getPlayer().tele(Tile.of(2531, 3413, 0)); e.getPlayer().applyHit(new Hit(e.getPlayer(), Utils.random(20, 56), HitLook.TRUE_DAMAGE)); } else if (e.getObjectId() == 33047) { if (e.getPlayer().getInventory().containsItem(295, 1)) e.getPlayer().sendMessage(""The chest is empty.""); else { e.getPlayer().sendMessage(""You find Glarial's amulet.""); e.getPlayer().getInventory().addItem(295, 1); } } else if (e.getObjectId() == 33066) { if (e.getPlayer().getInventory().containsItem(296, 1)) e.getPlayer().sendMessage(""The tomb is empty.""); else { e.getPlayer().sendMessage(""You find Glarial's urn.""); e.getPlayer().getInventory().addItem(296, 1); } } else if (e.getObjectId() == 2022) { e.getPlayer().sendMessage(""You climb in the barrel and safely land at the bottom of the waterfall.""); e.getPlayer().tele(Tile.of(2531, 3413, 0)); } else if (e.getObjectId() == 2014) { e.getPlayer().sendMessage(""A powerful rush of water floods out of the cave and sweeps you down river.""); e.getPlayer().tele(Tile.of(2531, 3413, 0)); e.getPlayer().applyHit(new Hit(e.getPlayer(), Utils.random(20, 56), HitLook.TRUE_DAMAGE)); } else if (e.getObjectId() == 37247) { if (e.getPlayer().getEquipment().getAmuletId() == 295 || e.getPlayer().getInventory().containsItem(295, 1)) e.getPlayer().tele(Tile.of(2575, 9862, 0)); else { e.getPlayer().sendMessage(""A powerful rush of water floods out of the cave and sweeps you down river.""); e.getPlayer().tele(Tile.of(2531, 3413, 0)); e.getPlayer().applyHit(new Hit(e.getPlayer(), Utils.random(20, 56), HitLook.TRUE_DAMAGE)); } } else if (e.getObjectId() == 2002 || e.getObjectId() == 1991) e.getPlayer().sendMessage(""The door is locked.""); else if (e.getObjectId() == 1989) if (e.getPlayer().getQuestManager().getStage(Quest.WATERFALL_QUEST) >= 2 && !e.getPlayer().getInventory().containsItem(292, 1)) { e.getPlayer().getInventory().addItem(292, 1); e.getPlayer().sendMessage(""You find an old book on the subject of Baxtorian!""); } else e.getPlayer().sendMessage(""You find nothing of interest.""); }); public static ItemOnObjectHandler itemOnObjectClose = new ItemOnObjectHandler(new Object[] { 1991, 1992, 2002, 2004, 2006, 2014, 2020 }, null, e -> { if (e.getItem().getId() == 954 && e.getObject().getId() == 2020) { e.getPlayer().sendMessage(""You carefully climb down the tree using your rope.""); e.getPlayer().tele(Tile.of(2511, 3463, 0)); } else if (e.getItem().getId() == 296 && e.getObject().getId() == 2014 && !e.getPlayer().isQuestComplete(Quest.WATERFALL_QUEST)) { if (e.getPlayer().getQuestManager().getStage(Quest.WATERFALL_QUEST) == 5) { e.getPlayer().getQuestManager().completeQuest(Quest.WATERFALL_QUEST); e.getPlayer().tele(Tile.of(e.getPlayer().getX() - 38, e.getPlayer().getY() + 1, 0)); } else e.getPlayer().sendMessage(""I don't know how you got in here, but you shouldn't be.""); } else if (e.getItem().getId() == 295 && e.getObject().getId() == 2006 && !e.getPlayer().isQuestComplete(Quest.WATERFALL_QUEST)) { if (e.getPlayer().getQuestManager().getAttribs(Quest.WATERFALL_QUEST).getI(""wfWaterRunes"") >= 6 && e.getPlayer().getQuestManager().getAttribs(Quest.WATERFALL_QUEST).getI(""wfAirRunes"") >= 6 && e.getPlayer().getQuestManager().getAttribs(Quest.WATERFALL_QUEST).getI(""wfEarthRunes"") >= 6) { e.getPlayer().tele(Tile.of(e.getPlayer().getX() + 38, e.getPlayer().getY() - 1, 0)); e.getPlayer().sendMessage(""You place the necklace on the statue.""); e.getPlayer().sendMessage(""You hear a loud rumble beneath your feet.""); e.getPlayer().sendMessage(""The ground raises right in front of you!""); e.getPlayer().getInventory().deleteItem(295, 1); e.getPlayer().getQuestManager().setStage(Quest.WATERFALL_QUEST, 5); } else { e.getPlayer().sendMessage(""Water fills the cave and flushes you out and down the river.""); e.getPlayer().tele(Tile.of(2531, 3413, 0)); e.getPlayer().applyHit(new Hit(e.getPlayer(), Utils.random(20, 56), HitLook.TRUE_DAMAGE)); } } else if (e.getItem().getId() == 555 && e.getObject().getId() == 2004) { e.getPlayer().sendMessage(""The rune stone disappears in a puff of smoke.""); e.getPlayer().getInventory().deleteItem(555, 1); e.getPlayer().getQuestManager().getAttribs(Quest.WATERFALL_QUEST).incI(""wfWaterRunes""); } else if (e.getItem().getId() == 556 && e.getObject().getId() == 2004) { e.getPlayer().sendMessage(""The rune stone disappears in a puff of smoke.""); e.getPlayer().getInventory().deleteItem(556, 1); e.getPlayer().getQuestManager().getAttribs(Quest.WATERFALL_QUEST).incI(""wfAirRunes""); } else if (e.getItem().getId() == 557 && e.getObject().getId() == 2004) { e.getPlayer().sendMessage(""The rune stone disappears in a puff of smoke.""); e.getPlayer().getInventory().deleteItem(557, 1); e.getPlayer().getQuestManager().getAttribs(Quest.WATERFALL_QUEST).incI(""wfEarthRunes""); } else if (e.getItem().getId() == 294 && e.getObject().getId() == 1992) { if (e.getPlayer().getQuestManager().getStage(Quest.WATERFALL_QUEST) >= 4) { e.getPlayer().sendMessage(""You place the pebble in the gravestone's small indent.""); e.getPlayer().sendMessage(""It fits perfectly.""); e.getPlayer().sendMessage(""You hear a loud creak.""); e.getPlayer().sendMessage(""The gravestone slides back to reveal a ladder going down.""); e.getPlayer().tele(Tile.of(2556, 3444 + 6400, 0)); } else e.getPlayer().sendMessage(""Nothing interesting happens.""); } else if (e.getItem().getId() == 298 && e.getObject().getId() == 1991) { if (e.getPlayer().getX() == 2515 && e.getPlayer().getY() == 9575) { e.getPlayer().sendMessage(""You unlock the door and go inside.""); e.getPlayer().tele(Tile.of(e.getPlayer().getX(), e.getPlayer().getY() + 1, 0)); } else if (e.getPlayer().getX() == 2515 && e.getPlayer().getY() == 9576) { e.getPlayer().sendMessage(""You unlock the door and go inside.""); e.getPlayer().tele(Tile.of(e.getPlayer().getX(), e.getPlayer().getY() - 1, 0)); } } else if (e.getItem().getId() == 293 && e.getObject().getId() == 2002) { Doors.handleDoor(e.getPlayer(), e.getObject()); e.getPlayer().sendMessage(""You unlock the door and go inside.""); } }); public static ItemOnObjectHandler ropeRock = new ItemOnObjectHandler(false, new Object[] { 1996 }, new Object[] { 954 }, e -> { if (e.getPlayer().getX() == 2512 && e.getPlayer().getY() == 3476) { e.getPlayer().sendMessage(""You throw the rope over the rock and carefully pull yourself safely to land.""); e.getPlayer().tele(Tile.of(2511, 3467, 0)); } else e.getPlayer().sendMessage(""You are too far away to do this.""); }); }" "package com.rs.game.content.quests.waterfallquest.books; @PluginEventHandler public class BookOnBaxtorian extends Book { public BookOnBaxtorian() { super(""Book on Baxtorian"", """""" The Missing Relics Many artefacts of elven history were lost after the Fourth Age, following the departure of the elves from these lands. The greatest loss to our collections of elf history were the hidden treasures of Baxtorian. Some believe these treasures are still unclaimed, but it is more commonly believed that dwarf miners recovered them early in the Fifth Age. Another great loss was Glarial's pebble, a key which allowed her family to visit her tomb. The pebble was taken by a gnome family over a century ago. It is hoped that descendants of that gnome may still have the pebble hidden in their cave under the Tree Gnome Village. The Sonnet of Baxtorian The love between Baxtorian and Glarial was said to have lasted over a century. They lived a peaceful life learning and teaching the laws of nature. When trouble hit their home in the west, Baxtorian left on a great campaign. He returned to find his people slaughtered and his wife taken by the enemy. After years of searching for his love, he finally gave up and returned to the home he had made for Glarial under the Baxtorian Falls. Once he entered, he never returned. Only he and Glarial had the power to enter the waterfall. Since Baxtorian entered, no one else has been able to get in. It's as if the powers of nature still work to protect him. The Power of Nature Glarial and Baxtorian were masters of nature. Trees would grow, hills form and rivers flood on their command. Baxtorian in particular had perfected rune lore. It was said that he could use the stones to control water, earth and air. Ode to Eternity A short piece written by Baxtorian himself. What care I for this mortal coil, where treasures are yet so frail, for it is you that is my life blood, the wine to my holy grail, and if I see the judgement day, when gods fill the air with dust, I'll happily choke on your memory, as my kingdom turns to rust. """"""); } public static ItemClickHandler read = new ItemClickHandler(new Object[] { 292 }, new String[] { ""Read"" }, e -> { if (e.getPlayer().getQuestStage(Quest.WATERFALL_QUEST) == 2) { e.getPlayer().sendMessage(""You read the book and find that a gnome named Golrie may be able to help find a way into the falls.""); e.getPlayer().setQuestStage(Quest.WATERFALL_QUEST, 3); } e.getPlayer().openBook(new BookOnBaxtorian()); }); }" "package com.rs.game.content.quests.whatliesbelow; @PluginEventHandler public class PlayerVsKingFight extends InstancedController { private static final Tile OUTSIDE = Tile.of(3209, 3492, 0); private transient NPC surok, king; public PlayerVsKingFight() { super(Instance.of(OUTSIDE, 4, 4).persist().setEntranceOffset(new int[]{10, 15, 0})); } @Override public void onBuildInstance() { player.lock(); getInstance().copyMapAllPlanes(400, 435).thenAccept(b -> { GameObject table = World.getObject(getInstance().getLocalTile(9, 13)); World.removeObject(table); GameObject moved = new GameObject(table); moved.setTile(getInstance().getLocalTile(10, 16)); World.spawnObject(moved); player.playCutscene(cs -> { cs.dialogue(new Dialogue().addSimple(""The room grows dark and you sense objects moving..."")); cs.fadeIn(5); cs.action(1, () -> getInstance().teleportLocal(player, 10, 15, 0)); cs.action(() -> { player.setForceNextMapLoadRefresh(true); player.loadMapRegions(); cs.setEndTile(Tile.of(cs.getX(10), cs.getY(15), 0)); }); cs.npcCreate(""surok"", 5835, 9, 16, 0, n -> { n.persistBeyondCutscene(); n.setIgnoreNPCClipping(true); surok = n; }); cs.npcCreate(""king"", 5838, 10, 10, 0, n -> { n.persistBeyondCutscene(); n.setIgnoreNPCClipping(true); king = n; }); cs.camPos(10, 6, 2500); cs.camLook(9, 16, 89); cs.delay(1); cs.camPos(10, 6, 2500, 0, 5); cs.camLook(9, 15, 1500, 0, 5); cs.fadeOut(5); cs.npcFaceNPC(""surok"", ""king""); cs.npcFaceDir(""king"", Direction.NORTH); cs.npcTalk(""surok"", ""Annach Narh Hin Dei!""); cs.npcAnim(""surok"", 6098); cs.npcSpotAnim(""surok"", 1009); cs.delay(1); cs.npcAnim(""surok"", -1); cs.action(() -> World.sendProjectile(surok, king, 1010, 5, 15, 15, 0.4, 10, proj -> king.spotAnim(1011))); cs.action(() -> king.forceTalk(""What's going on?"")); cs.camPos(10, 19, 3048, 0, 10); cs.camLook(10, 8, 715, 0, 10); cs.delay(1); cs.action(() -> king.forceTalk(""What's going on?"")); cs.delay(4); cs.action(() -> { king.forceTalk(""I...must...kill..."" + player.getDisplayName() +""!!""); king.setNextAnimation(EmotesManager.Emote.CRY.getAnim()); }); cs.dialogue(new Dialogue().addPlayer(HeadE.WORRIED, ""Uh oh! King Roald looks evil!"")); cs.playerTalk(""Un oh! King Roald looks evil!""); cs.delay(4); cs.action(() -> { player.unlock(); king.setTarget(player); }); }); }); } @Override public void onDestroyInstance() { } @Override public boolean sendDeath() { player.safeDeath(OUTSIDE); return false; } @Override public boolean processNPCClick1(NPC npc) { player.faceTile(npc.getTile()); switch (npc.getId()) { case 5835 -> player.sendMessage(""Surok's eyes are glazed over. he must be concentrating hard on the spell over King Roald.""); } return false; } @Override public boolean processObjectClick1(GameObject object) { if (object.getId() == 15536) { player.sendMessage(""As you touch the door, your hand tingles and the room seems to grow dim. You can hear Surok muttering a spell behind you.""); player.lock(); player.fadeScreen(() -> { player.getControllerManager().forceStop(); player.tele(Tile.of(3214, 3378, 0)); player.resetReceivedHits(); player.unlock(); }); return false; } return true; } public void attemptZaffSummon(Player player) { player.resetWalkSteps(); player.lock(); king.setTarget(null); king.freeze(50); if (king.getHitpoints() >= 20) { player.playCutscene(cs -> { cs.npcCreate(""zaff"", Zaff.ID, player.getNearestTeleTile(1).localizeRegion()); cs.npcSpotAnim(""zaff"", new SpotAnim(110, 0, 96)); cs.delay(4); cs.camPos(player.getXInRegion(), player.getYInRegion() - 7, 400, 0, 5); cs.camLook(player.getXInRegion(), player.getYInRegion(), 87); cs.dialogue(new Dialogue().addNPC(Zaff.ID, HeadE.AMAZED, ""The king's still too strong! We had better get out of here!"")); cs.delay(5); cs.playerSpotAnim(new SpotAnim(110, 0, 96)); cs.delay(1); cs.action(() -> { player.getControllerManager().forceStop(); player.tele(Tile.of(3202, 3432, 0)); }); }); return; } player.playCutscene(cs -> { cs.npcCreate(""zaff"", Zaff.ID, king.getNearestTeleTile(Direction.getDirectionTo(king, player)).localizeRegion()); cs.npcSpotAnim(""zaff"", new SpotAnim(110, 0, 96)); cs.setEndTile(OUTSIDE); cs.action(() -> { player.setQuestStage(Quest.WHAT_LIES_BELOW, 8); cs.getNPC(""zaff"").faceEntity(king); king.faceEntity(cs.getNPC(""zaff""));; }); cs.delay(3); cs.npcSync(""zaff"", 5633, 1006); cs.delay(1); cs.action(() -> World.sendProjectile(cs.getNPC(""zaff""), king, 1007, 5, 15, 15, 0.4, 10, proj -> king.spotAnim(1008))); cs.delay(1); cs.action(() -> { king.anim(6098); king.forceTalk(""Wh...!""); }); cs.delay(2); cs.npcAnim(""zaff"", 1819); cs.npcSpotAnim(""zaff"", new SpotAnim(108, 0, 92)); cs.delay(1); cs.action(() -> World.sendProjectile(cs.getNPC(""zaff""), king, 109, 5, 15, 15, 0.4, 10, proj -> { king.spotAnim(110); king.finishAfterTicks(2); })); cs.delay(3); cs.dialogue(new Dialogue().addNPC(Zaff.ID, HeadE.ANGRY, ""The king's mind has been restored to him and he has been teleported away to safety. Now, to deal with Surok!""), true); cs.action(() -> player.faceTile(surok.getTile())); cs.dialogue(new Dialogue().addNPC(SurokMagis.ID, HeadE.ANGRY, ""No! All is lost! I must escape!""), true); cs.playerFaceEntity(""zaff""); cs.dialogue(new Dialogue().addNPC(Zaff.ID, HeadE.ANGRY, ""You will not escape justice this time, Surok!""), true); cs.delay(2); cs.playerMove(8, 14, Entity.MoveType.WALK); cs.npcWalk(""zaff"", 10, 14); cs.delay(2); cs.camPos(player.getXInRegion(), player.getYInRegion() - 5, 3500, 0, 5); cs.camLook(player.getXInRegion(), player.getYInRegion(), 87, 0, 5); cs.action(() -> { player.faceTile(surok.getTile()); cs.getNPC(""zaff"").faceTile(surok.getTile()); }); cs.delay(2); cs.action(() -> { surok.forceTalk(""Mirra din namus!!""); surok.faceEntity(cs.getNPC(""zaff"")); surok.anim(6098); surok.spotAnim(108, 0, 92); }); cs.delay(1); cs.npcAnim(""zaff"", 1819); cs.npcSpotAnim(""zaff"", new SpotAnim(108, 0, 92)); cs.npcTalk(""zaff"", ""Stop!!""); cs.delay(1); cs.action(() -> surok.anim(-1)); cs.action(() -> World.sendProjectile(cs.getNPC(""zaff""), surok, 109, 5, 15, 15, 0.4, 10, proj -> { surok.spotAnim(345); surok.anim(6098); })); cs.delay(3); cs.dialogue(new Dialogue().addNPC(Zaff.ID, HeadE.FRUSTRATED, ""Your teleport spell has been corrupted, Surok! I have placed a magic block on this room. You will remain here, under guard, in the library from now on.""), true); cs.action(() -> player.faceTile(surok.getTile())); cs.dialogue(new Dialogue().addNPC(SurokMagis.ID, HeadE.FRUSTRATED, ""No! My plans have been ruined! I was so close to success!""), true); cs.action(() -> player.faceTile(cs.getNPC(""zaff"").getTile())); cs.dialogue(new Dialogue().addNPC(Zaff.ID, HeadE.CHEERFUL, ""Thank you for your help, "" + player.getDisplayName() + "". I will put the room back in order and then I must leave. Surok is defeated and will be no more trouble for us. We will guard him more closely from now on!""), true); cs.npcAnim(""zaff"", 1819); cs.npcSpotAnim(""zaff"", new SpotAnim(108, 0, 92)); cs.delay(1); cs.npcSpotAnim(""zaff"", 110); cs.delay(1); cs.npcDestroy(""zaff""); cs.delay(3); cs.dialogue(new Dialogue().addSimple(""The room grows dark again and you sense objects moving..."")); cs.fadeIn(5); cs.action(() -> { player.getControllerManager().forceStop(); player.tele(OUTSIDE); }); cs.fadeOut(5); }); } }" "package com.rs.game.content.quests.whatliesbelow; @QuestHandler( quest = Quest.WHAT_LIES_BELOW, startText = ""Talk to Rat Burgiss south of Varrock."", itemsText = ""Bowl, 15 chaos runes or 15 un-noted pure essence, access to the chaos altar."", combatText = ""You will need to defeat a level 47 enemy and 5 level 32 enemies."", rewardsText = ""8,000 Runecrafting XP
2,000 Defence XP
Beacon ring
Safe access to the chaos tunnels"", completedStage = 9 ) @PluginEventHandler public class WhatLiesBelow extends QuestOutline { /** * inter 250/251 */ @Override public List getJournalLines(Player player, int stage) { List lines = new ArrayList<>(); switch (stage) { case 1 -> { lines.add(""I need to kill outlaws west of Varrock so that I can collect 5 ""); lines.add(""of Rat's Papers. I have to deliver those papers back to Rat in""); lines.add(""a folder he gave me.""); lines.add(""""); } case 2 -> { lines.add(""I need to deliver Rat's letter to Surok Magis in Varrock.""); lines.add(""""); } case 3 -> { lines.add(""Surok destroyed Rat's letter immediately, I should ask him""); lines.add(""what that was all about.""); lines.add(""""); } case 4 -> { lines.add(""Surok told me he was working on a spell to create gold and""); lines.add(""that I could be a part of it!""); lines.add(""""); lines.add(""He gave me a metal wand that I need to charge using 15 chaos""); lines.add(""runes at the chaos altar. He wants me to bring both the""); lines.add(""charged wand, and an empty bowl to him.""); lines.add(""""); } case 5 -> { lines.add(""I gave the items that Surok needed to him and he gave me""); lines.add(""a letter I need to deliver to Rat.""); lines.add(""""); } case 6 -> { lines.add(""Rat uncovered his secret about being a part of the VPSG to me""); lines.add(""and that I could be a part of stopping Surok with them.""); lines.add(""He told me to go speak to Zaff about what to do next.""); lines.add(""""); } case 7 -> { lines.add(""Zaff told me to go arrest Surok. He gave me a beacon ring to""); lines.add(""summon him when Roald is 'all but dead'.""); lines.add(""""); } case 8 -> { lines.add(""I have defeated Surok with Zaff's help and should go report""); lines.add(""back to Rat Burgiss.""); lines.add(""""); } } return lines; } @Override public void complete(Player player) { player.getSkills().addXpQuest(Skills.RUNECRAFTING, 8000); player.getSkills().addXpQuest(Skills.DEFENSE, 2000); sendQuestCompleteInterface(player, 11014); } @Override public void updateStage(Player player, int stage) { if (player.getVars().getVarBit(3524) >= 0 && stage == getCompletedStage()) player.getVars().saveVarBit(4312, 1); if (stage >= 6) player.getVars().setVarBit(4314, 1); if (player.isMiniquestStarted(Miniquest.HUNT_FOR_SUROK)) player.getVars().setVarBit(4314, 2); } public static ItemClickHandler readFolders = new ItemClickHandler(new Object[] { 11003, 11006, 11007, 11008, 11009, 11010, 11011 }, new String[] { ""Read"" }, e -> { switch(e.getItem().getId()) { case 11003 -> e.getPlayer().sendMessage(""The folder is empty at the moment so there is nothing inside to read!""); case 11008, 11006 -> e.getPlayer().simpleDialogue(""The piece of paper appears to contain lots of facts and figures. They look like accounts and lists of items. You're not sure what they all mean.""); case 11007 -> e.getPlayer().sendMessage(""A folder full of pages of facts and figures. You have found all the pages for which Rat was looking. You need to deliver the folder to him now.""); case 11009 -> e.getPlayer().getInterfaceManager().sendInterface(249); case 11010 -> e.getPlayer().getInterfaceManager().sendInterface(250); case 11011 -> e.getPlayer().getInterfaceManager().sendInterface(251); } }); public static NPCDeathHandler outlawDeath = new NPCDeathHandler(new Object[] { ""Outlaw"" }, e -> { if (e.getKiller() instanceof Player player && player.getQuestStage(Quest.WHAT_LIES_BELOW) == 1) World.addGroundItem(new Item(11008, 1), e.getNPC().getTile(), player); }); public static ItemOnItemHandler addPapersToFolder = new ItemOnItemHandler(11008, new int[] { 11003, 11006 }, e -> { Item folder = e.getUsedWith(11008); e.getPlayer().getInventory().deleteItem(11008, 1); if (folder.getId() == 11003) { folder.setId(11006); folder.addMetaData(""wlbPapersAdded"", 1); } else if (folder.incMetaDataI(""wlbPapersAdded"") >= 5) { folder.setId(11007); folder.deleteMetaData(); e.getPlayer().simpleDialogue(""You have added all the pages to the folder that Rat gave to you. You should take this folder back to Rat.""); } else e.getPlayer().sendMessage(""You add the page to the folder that Rat gave to you.
You need to find "" + (5 - folder.getMetaDataI(""wlbPapersAdded"")) + "" more pages.""); e.getPlayer().getInventory().refresh(folder.getSlot()); }); public static ItemOnObjectHandler chargeWand = new ItemOnObjectHandler(new Object[] { 2487 }, new Object[] { 11012 }, e -> { if (e.getPlayer().getInventory().containsItem(562, 15)) { e.getPlayer().sync(6104, 1038); e.getPlayer().delayLock(13, () -> { e.getPlayer().getInventory().deleteItem(562, 15); e.getItem().setId(11013); e.getPlayer().getInventory().refresh(e.getItem().getSlot()); e.getPlayer().simpleDialogue(""The metal wand bursts into life and crackles with arcane power. This is a powerful instrument indeed!""); }); } else e.getPlayer().simpleDialogue(""The wand sparks and glows, but the infusion does not appear to take hold. It looks like you will need more chaos runes to complete the infusion.""); }); public static void addZaffOptions(Player player, Options ops) { switch(player.getQuestStage(Quest.WHAT_LIES_BELOW)) { case 6 -> ops.add(""Rat Burgiss sent me."") .addPlayer(HeadE.CHEERFUL, ""Rat Burgiss sent me!"") .addNPC(Zaff.ID, HeadE.CHEERFUL, ""Ah, yes; You must be "" + player.getDisplayName() + ""! Rat sent word that you would be coming. Everything is prepared. I have created a spell that will remove the mind control from the king."") .addPlayer(HeadE.CONFUSED, ""Okay, so what's the plan?"") .addNPC(Zaff.ID, HeadE.CHEERFUL, ""Listen carefully. For the spell to succeed, the king must be made very weak. If his mind becomes controlled, you will need to fight him until he is all but dead."") .addNPC(Zaff.ID, HeadE.CHEERFUL, ""Then and ONLY then, use your ring to summon me. I will teleport to you and cast the spell that will cure the king."") .addPlayer(HeadE.CONFUSED, ""Why must I summon you? Can't you come with me?"") .addNPC(Zaff.ID, HeadE.SAD_MILD, ""I cannot. I must look after my shop here and I have lots to do. Rest assured, I will come when you summon me."") .addPlayer(HeadE.CHEERFUL, ""Okay, so what do I do now?"") .addNPC(Zaff.ID, HeadE.CHEERFUL, ""Take this beacon ring and some instructions."") .addNPC(Zaff.ID, HeadE.CHEERFUL, ""Once you have read the instructions, it will be time for you to arrest Surok."") .addPlayer(HeadE.AMAZED, ""Won't he be disinclined to acquiesce to that request?"") .addNPC(Zaff.ID, HeadE.CONFUSED, ""Won't he what?"") .addPlayer(HeadE.CONFUSED, ""Won't he refuse?"") .addNPC(Zaff.ID, HeadE.CALM_TALK, ""I very much expect so. It may turn nasty, so be on your guard. I hope we can stop him before he can cast his spell! Make sure you have that ring I gave you."") .addPlayer(HeadE.CHEERFUL, ""Okay, thanks, Zaff!"") .addNPC(Zaff.ID, HeadE.CHEERFUL, ""Rat has told me that you are to be made an honorary member of the VPSG so that you can arrest Surok. If you have any questions about this, ask Rat."") .addNPC(Zaff.ID, HeadE.CHEERFUL, ""One last thing: you must remember that as a part of the VPSG, we must remain secretive at all times. For this reason, I cannot discuss matters such as this unless absolutely necessary."") .addPlayer(HeadE.CHEERFUL, ""Of course! Thanks again!"", () -> { player.setQuestStage(Quest.WHAT_LIES_BELOW, 7); player.getInventory().addItemDrop(11014, 1); player.getInventory().addItemDrop(11011, 1); }); case 7 -> ops.add(""I need to ask you something else."") .addPlayer(HeadE.CALM_TALK, ""I need to ask you something else."") .addNPC(Zaff.ID, HeadE.CONFUSED, ""Go ahead!"") .addOptions(questions -> { questions.add(""What am I doing again?"") .addPlayer(HeadE.CONFUSED, ""What am I doing again?"") .addNPC(Zaff.ID, HeadE.CHEERFUL, ""Make sure you have read the instructions I gave you about the ring. Then, when you are ready, go to Surok and arrest him!"") .addPlayer(HeadE.CHEERFUL, ""Okay, thanks!""); questions.add(""Can I have another ring?"") .addPlayer(HeadE.CONFUSED, ""Can I have another ring?"") .addNextIf(() -> player.containsItem(11014), new Dialogue() .addNPC(Zaff.ID, HeadE.CALM_TALK, ""You have one already."") .addStop()) .addNPC(Zaff.ID, HeadE.CALM_TALK, ""Well, I do happen to have another one here that you can have. Please try and be a bit more careful with this one!"", () -> player.getInventory().addItemDrop(11014, 1)); questions.add(""Can I have the instructions again?"") .addPlayer(HeadE.CONFUSED, ""Can I have the instructions again?"") .addNextIf(() -> player.containsItem(11011), new Dialogue() .addNPC(Zaff.ID, HeadE.CALM_TALK, ""You have one already."") .addStop()) .addNPC(Zaff.ID, HeadE.CALM_TALK, ""Well, I do happen to have another one here that you can have. Please try and be a bit more careful with this one!"", () -> player.getInventory().addItemDrop(11011, 1)); ; }); case 8 -> ops.add(""We did it! We beat Surok!"") .addPlayer(HeadE.CHEERFUL, ""We did it! We beat Surok!"") .addNPC(Zaff.ID, HeadE.CHEERFUL, ""Yes. You have done well, "" + player.getDisplayName() + "". You are to be commended for your actions!"") .addPlayer(HeadE.CHEERFUL, ""It was all in the call of duty!"") .addPlayer(HeadE.CONFUSED, ""What will happen with Surok now?"") .addNPC(Zaff.ID, HeadE.CHEERFUL, ""Well, when I disrupted Surok's spell, he will have been sealed in the library, but we will still need to keep an eye on him, just in case."") .addNPC(Zaff.ID, HeadE.CHEERFUL, ""When you are ready, report back to Rat and he will reward you."") .addPlayer(HeadE.CHEERFUL, ""Okay, I will!"") .addNPC(Zaff.ID, HeadE.SAD_MILD, ""Sadly, however, after this I will not be able to discuss these matters with you again. They are secret and we must be vigilant. The VPSG will prevail!"") .addPlayer(HeadE.CHEERFUL, ""Of course. I understand. Goodbye!""); } } public static ItemClickHandler summonBeaconRing = new ItemClickHandler(new Object[] { 11014 }, new String[] { ""Summon"" }, e -> { PlayerVsKingFight ctrl = e.getPlayer().getControllerManager().getController(PlayerVsKingFight.class); if (ctrl == null) { e.getPlayer().sendMessage(""You don't know how many charges the ring has left. You should probably not use it yet!""); return; } ctrl.attemptZaffSummon(e.getPlayer()); }); }" "package com.rs.game.content.quests.whatliesbelow.books; @PluginEventHandler public class DagonHaiHistory extends Book { public DagonHaiHistory() { super(""The Fall of the Dagon'Hai"", """""" '...In scarred lands and ruined fields, that circle flaming towers high, where cruel and cursed torments yield, the Dark of Man, the Dagon'hai.' 'The Prophecies of Zamorak' ...until the day that the Zamorakian Magi were welcomed among the human numbers. The Zamorakian numbers grew and some moved their order to the city of Varrock. These were the Dagon'hai. The practices of the Dagon'hai were looked darkly upon by the priests of Saradomin within the walls of Varrock and, thus, the Dagon'hai were forced into a hidden war, away from the eyes of the citizens of Varrock. Priests of Saradomin were found dead in darkened streets and crumbling houses. Dagon'hai were cast into cells and tormented through purification. Varrock was torn between the followers of two warring deities. Yet, the people of Varrock did nothing... ...until the tower fell. The famed Wizards' Tower in the south burned for what seemed like an age and the people of Varrock knew they had been misled. They turned upon the Zamorakian mages with murderous intent and the Dagon'hai, even with their skills in dark wizardry, were unable to confront such a vengeance-filled assault against their order, supported in full by the priests of Saradomin. The Dagon'hai were all but decimated. Their numbers were shattered and they hid themselves in the darkest houses in the most dimly lit of streets within the city. Those that survived the exodus delved deeper into the most evil of arcane magic, intent on exacting retribution upon the priests of Saradomin and the people of Varrock. Varrock may have fallen if not for the purest of chances. A young guardsman on patrol in the city happened across a dimly lit house in a corner of the city. Sensing something evil in the air, he cautiously peered through one of the small windows and was aghast to see the High Elders of the Dagon'hai engaged in a sacrificial ritual. Sounding the alarm, the guard called for help and the Dagon'hai, knowing they would be slaughtered, fled into the night. The last remaining Dagon'hai were chased throughout Varrock to the great statue of Saradomin himself. Then, they all but disappeared. Nobody knows what happened to them, but some say they were set upon by creatures from the Wilderness. Others say that they teleported themselves away to a place of safety. A few claimed they saw men disappearing into the earth beneath the statue itself. It was as though the statue of Saradomin had claimed their lives in his name. The Dagon'hai never reappeared in Varrock, yet the people knew that one day they would return to have their revenge. """"""); } public static ObjectClickHandler find = new ObjectClickHandler(new Object[] { 23091 }, new Tile[] { Tile.of(3215, 3494, 0) }, e -> { if (e.getPlayer().getQuestStage(Quest.WHAT_LIES_BELOW) >= 4 && !e.getPlayer().containsItem(11001)) { e.getPlayer().getInventory().addItem(11001, 1); e.getPlayer().sendMessage(""You find a musty old tome.""); } else e.getPlayer().sendMessage(""You find nothing of interest...""); }); public static ItemClickHandler read = new ItemClickHandler(new Object[] { 11001 }, new String[] {""Read""}, e -> new DagonHaiHistory().open(e.getPlayer())); }" "package com.rs.game.content.quests.whatliesbelow.books; @PluginEventHandler public class HistoryOfSinketh extends Book { public HistoryOfSinketh() { super(""The Journal of Sin'Keth Magis"", """""" '...2nd Pentember, Fifth Age, 70 We have worked for days. It is a weary and tiring journey that my brothers and I must take, but we are close to success! Elder Dag'eth has led us well and he has told us that Zamorak will reward us greatly for our service to Him. The priests of Saradomin haunt our very steps and I fear our discovery. Yet, soon will be the hour of our glory. The Dagon'hai will prevail and the city will be ours! We will throw down the vile yoke of Saradomin and the Dagon'hai will be victorious! 9th Pentember, Fifth Age, 70 Today we donned the filthy robes of the Saradomin priests. It was a foul deed and distasteful to my very soul, yet it had to be done. Without the disguise, we would surely have been found out and ruined. We erected a statue of Saradomin himself just outside the city to the east. Our Lord Zamorak must be laughing in the faces of our enemies at such a deception, for this statue holds the key to our success. Beneath the arrogant caricature of this worthless deity lies the entrance to our most sacred work yet: the Tunnel of Chaos. With this tunnel, we are able to traverse to the very source of our power, the Chaos Temple itself. Those foolish followers of Saradomin do not even sense what we have achieved. They have filled the statue with their accursed holy magic, covering even the merest traces of our work beneath. They have granted us the most perfect of disguises. Zamorak be praised! 11th Pentember, Fifth Age 70 Excellent news! I have been chosen by Elder Dag'eth to be the next Hyeraph. I, Sin'keth Magis, will lead our people in the incantation of Zamorak's Will. Surely this means I will become High Elder! I must prove worthy to Lord Zamorak. He will not find me wanting. There is much to do in preparation for the ceremony and I do not have long. 24th Septober, Fifth Age, 70 Disaster! The incantation of Zamorak's Will was discovered by a loathsome watchman, of all people. Zamorak's Blood! The fates are cruel! We could not finish the final rites of the spell. Our work has been undone and we have no time to gather our forces together and hide. We are being followed by the guards and the Priests of Filth are at our heels. We must flee the city! Elder La'nou and Elder Kree'nag were slain whilst protecting the sanctum. Elder Dag'eth will not leave with us. Zamorak take him, he will stand against the hordes that follow us! I am the last of the Elders. The order looks to me now. 27th Septober, Fifth Age, 70 Today, the last of our order entered the Tunnel of Chaos. We will journey to the Chaos Temple and let Zamorak Himself decide our fate. What happened to Elder Dag'eth, I know not. As the city guards closed upon us, I cast an Earth Bolt spell to collapse the entrance of the tunnel in an avalanche of earth and stone, saving us and dooming us in one breath. There is only one place for us to go now... """"""); } public static ObjectClickHandler find = new ObjectClickHandler(new Object[] { 23092 }, new Tile[] { Tile.of(3216, 3494, 0) }, e -> { if (e.getPlayer().getQuestStage(Quest.WHAT_LIES_BELOW) >= 4 && !e.getPlayer().containsItem(11002)) { e.getPlayer().getInventory().addItem(11002, 1); e.getPlayer().sendMessage(""You find an old diary.""); } else e.getPlayer().sendMessage(""You find nothing of interest...""); }); public static ItemClickHandler read = new ItemClickHandler(new Object[] { 11002 }, new String[] {""Read""}, e -> new HistoryOfSinketh().open(e.getPlayer())); }" "package com.rs.game.content.quests.whatliesbelow.npcs; @PluginEventHandler public class KingRoaldBossWLB extends NPC { public KingRoaldBossWLB(Tile tile) { super(5838, tile, true); } @Override public void handlePreHit(Hit hit) { if (hit.getDamage() >= getHitpoints()) hit.setDamage(getHitpoints()-1); } @Override public void processNPC() { super.processNPC(); if (inCombat() && Utils.random(25) == 0) setNextForceTalk(new ForceTalk(Stream.of(""Have at you!"", ""I will smite you, cur!"", ""Take that, knave!"").collect(Collectors.toList()).get(Utils.random(3)))); } @Override public void sendDeath(Entity killer) { setHitpoints(1); } public static NPCInstanceHandler toFunc = new NPCInstanceHandler(new Object[] { 5838}, (npcId, tile) -> new KingRoaldBossWLB(tile)); }" "package com.rs.game.content.quests.whatliesbelow.npcs; @PluginEventHandler public class RatBurgiss extends Conversation { private static final int ID = 5833; public static NPCClickHandler handleRatBurgiss = new NPCClickHandler(new Object[]{ID}, e -> e.getPlayer().startConversation(new RatBurgiss(e.getPlayer()))); public RatBurgiss(Player player) { super(player); addOptions(ops -> { ops.add(""About the Achievement System..."", () -> new AchievementSystemD(player, ID, SetReward.VARROCK_ARMOR)); if (!player.isQuestComplete(Quest.WHAT_LIES_BELOW) && Quest.WHAT_LIES_BELOW.meetsReqs(player)) { ops.add(""Hello there!"") .addPlayer(HeadE.CHEERFUL, ""Hello there!"") .addNext(getWhatLiesBelowDialogue(player).getHead()); } }); create(); } private Dialogue getWhatLiesBelowDialogue(Player player) { return switch (player.getQuestStage(Quest.WHAT_LIES_BELOW)) { case 0 -> { Dialogue startQuestChain = new Dialogue() .addPlayer(HeadE.CHEERFUL, ""Of course! Tell me what you need me to do."") .addNPC(ID, HeadE.CHEERFUL, ""Right, now I heard those outlaws say something about having a small campsite somewhere to the west of the Grand Exchange. They headed off to the north-west of here, taking five pages with them."") .addNPC(ID, HeadE.CHEERFUL, ""Kill the outlaws and get those papers back from them for me. Here's a folder in which you can put the pages. Be careful, though; those outlaws are tough."", () -> { player.getInventory().addItem(11003); player.setQuestStage(Quest.WHAT_LIES_BELOW, 1); }) .addNPC(ID, HeadE.CHEERFUL, ""When you find all 5 pages, put them in the folder and bring them back to me!"") .addPlayer(HeadE.CHEERFUL, ""Don't worry, Ratty! I won't let you down!"") .addNPC(ID, HeadE.SAD_MILD, ""..."") .getHead(); yield new Dialogue().addNPC(ID, HeadE.SAD_MILD, ""Oh, hello. I'm Rat."") .addPlayer(HeadE.CONFUSED, ""You're a what?"") .addNPC(ID, HeadE.SAD_MILD, ""No, no. My name is Rat. Rat Burgiss."") .addPlayer(HeadE.CHEERFUL, ""Ohhhhh, well, what's up, Ratty?"") .addNPC(ID, HeadE.SAD_MILD, ""It's Rat, thank you. And, I uhh...heh...I seem to be in a bit of trouble here, as you can probably see."") .addPlayer(HeadE.CONFUSED, ""Why, what seems to be the matter?"") .addNPC(ID, HeadE.SKEPTICAL, ""Well, I'm a trader by nature and I was on the way to Varrock with my cart here when I was set upon by outlaws! They ransacked my cart and stole some very important papers that I must get back."") .addOptions(ops1 -> { ops1.add(""That's awful! You're lucky to be alive!"") .addPlayer(HeadE.AMAZED, ""That's awful! You're lucky to be alive!"") .addNPC(ID, HeadE.SAD_MILD, ""Yes, I know! I don't know how I survived."") .addPlayer(HeadE.CALM_TALK, ""Maybe you weren't worth killing?"") .addNPC(ID, HeadE.ANGRY, ""..."") .addNPC(ID, HeadE.ANGRY, ""Look, do you want to help me or not?"") .addQuestStart(Quest.WHAT_LIES_BELOW) .addNext(startQuestChain); ops1.add(""The papers were the only valuable thing you had?"") .addPlayer(HeadE.CONFUSED, ""The papers were the only valuable thing you had?"") .addNPC(ID, HeadE.CONFUSED, ""Uh...yes. I guess so."") .addPlayer(HeadE.CONFUSED, ""So you don't sell anything worth having?"") .addNPC(ID, HeadE.CONFUSED, ""Ah! Uhh...no, not really."") .addPlayer(HeadE.CONFUSED, ""You're not much of a trader are you?"") .addNPC(ID, HeadE.ANGRY, ""No...I mean yes... Look, that's beside the point."") .addNPC(ID, HeadE.SAD_MILD, ""Can you help me?"") .addQuestStart(Quest.WHAT_LIES_BELOW) .addNext(startQuestChain); ops1.add(""Shall I get them back for you?"") .addPlayer(HeadE.CONFUSED, ""Shall I get them back for you?"") .addNPC(ID, HeadE.CONFUSED, ""You mean you want to help?"") .addQuestStart(Quest.WHAT_LIES_BELOW) .addNext(startQuestChain); ops1.add(""Oh dear. Well, I hope you get to Varrock okay!"") .addPlayer(HeadE.CALM_TALK, ""Oh dear. Well, I hope you get to Varrock okay!"") .addNPC(ID, HeadE.CONFUSED, ""Uh...so you can't help me?"") .addPlayer(HeadE.CALM_TALK, ""Sorry. I'm a bit busy right now."") .addNPC(ID, HeadE.CONFUSED, ""Don't you want another quest?"") .addPlayer(HeadE.CALM_TALK, ""No thanks. I'm too busy right now."") .addNPC(ID, HeadE.ANGRY, ""Well, fine!"") .addPlayer(HeadE.ANGRY, ""Fine!"") .addNPC(ID, HeadE.ANGRY, ""Good!"") .addPlayer(HeadE.ANGRY, ""Good!!"") .addNPC(ID, HeadE.ANGRY, ""So go then!"") .addPlayer(HeadE.ANGRY, ""I'm going!"") .addNPC(ID, HeadE.ANGRY, ""Go then!"") .addPlayer(HeadE.ANGRY, ""I'm gone!""); }); } case 1 -> { if (player.getInventory().containsItem(11007)) { yield new Dialogue() .addNPC(ID, HeadE.CHEERFUL, ""Ah, hello again."") .addPlayer(HeadE.CHEERFUL, ""I got your pages back!"") .addNPC(ID, HeadE.CHEERFUL, ""Excellent! I knew you could help! Let me take those from you, there."") .addNPC(ID, HeadE.CHEERFUL, ""Now, I liked the way you handled yourself on that last little 'mission' I gave you there, so I'm going to let you in on a little secret!"") .addPlayer(HeadE.CHEERFUL, ""Wait! Wait! Let me guess! You're actually a rich prince in disguise who wants to help poor people like me!?"") .addNPC(ID, HeadE.CONFUSED, ""Uhhh...no. No, that's not it. You know, on second thought, I think I'll keep my secret for now. Look, instead, you can do another job for me."") .addPlayer(HeadE.SAD_MILD, ""All work and no play makes "" + player.getDisplayName() + "" a dull adventurer!"") .addNPC(ID, HeadE.CALM_TALK, ""Yes, well, I'm sure that may be the case. However, what I want you to do is take this letter to someone for me. It's in a different language so, trust me, you won't be able to read it."") .addNPC(ID, HeadE.CALM_TALK, ""Take it to a wizard named Surok Magis who resides in the Varrock Palace Library. I'll see about some sort of reward for your work when I get myself sorted out here."") .addPlayer(HeadE.CHEERFUL, ""Letter. Wizard. Varrock. Got it!"", () -> { player.getInventory().deleteItem(11007, 1); player.getInventory().addItemDrop(11009, 1); player.setQuestStage(Quest.WHAT_LIES_BELOW, 2); }) .addNPC(ID, HeadE.CHEERFUL, ""Yes, good luck then.""); } else yield new Dialogue() .addNPC(ID, HeadE.CHEERFUL, ""Hello again! How are things going?"") .addPlayer(HeadE.CONFUSED, ""I can't remember what I am supposed to do!"") .addNPC(ID, HeadE.CHEERFUL, ""Head north-west from here into the forest west of the Grand Exchange. Find the camp of outlaws and kill them."") .addNPC(ID, HeadE.CHEERFUL, ""Collect the pages of my document for me and put them into the folder I gave you. When the folder contains five pages, bring it to me!"") .addNextIf(() -> !player.containsAnyItems(11003, 11006, 11007), new Dialogue() .addPlayer(HeadE.SAD, ""I lost the folder you gave me. Do you have another one?"") .addNPC(ID, HeadE.CHEERFUL, ""Sure. Here you go. I'll add it to your account."", () -> player.getInventory().addItem(11003)) .addPlayer(HeadE.AMAZED, ""My account? Am I in debt?"") .addNPC(ID, HeadE.CHEERFUL, ""No, it's just the way you're standing."")) .addPlayer(HeadE.CHEERFUL, ""Okay, thanks!""); } case 2 -> new Dialogue() .addNPC(ID, HeadE.CHEERFUL, ""Ah, hello. How is your task going?"") .addNextIf(() -> !player.containsItem(11009), new Dialogue() .addPlayer(HeadE.SAD, ""I think I lost that letter you gave me!"") .addNPC(ID, HeadE.CHEERFUL, ""Goodness me! Not much of a messenger, are you? Here's another one; try not to lose it this time! I've charged the parchment to your account."", () -> player.getInventory().addItem(11009)) .addPlayer(HeadE.CONFUSED, ""Will you take a check?"") .addNPC(ID, HeadE.CHEERFUL, ""No thanks. I prefer tartan."")) .addPlayer(HeadE.CONFUSED, ""What am I doing again?"") .addNPC(ID, HeadE.CALM_TALK, ""Take that letter I gave you to Surok Magis, the wizard found in the Varrock Palace Library."") .addPlayer(HeadE.CHEERFUL, ""Oh yes! It's all flooding back now!"") .addNPC(ID, HeadE.CALM_TALK, ""I see. Well, try not to drown yourself with all that brain usage.""); case 3, 4 -> new Dialogue() .addNPC(ID, HeadE.CHEERFUL, ""Ah, "" + player.getDisplayName() + ""! Good to see you! I heard you got my letter to Surok. Well done!"") .addPlayer(HeadE.CHEERFUL, ""That's right! I did your leg work. Now, how about a reward?"") .addNPC(ID, HeadE.CHEERFUL, ""Yes, of course! I'd be happy to give you a reward, but I have a lot on my mind with...you know...trader...stuff!"") .addPlayer(HeadE.CONFUSED, ""Indeed!""); case 5 -> { Dialogue giveLetter = new Dialogue() .addNextIf(() -> !player.getInventory().containsItem(11010), new Dialogue() .addPlayer(HeadE.SAD_MILD, ""Oh, wait! I've lost the letter! I guess I better go and get another one for you!"") .addStop()) .addNPC(ID, HeadE.SAD_MILD, ""This letter is treasonous! This does indeed confirm my worst fears. It is time I let you into my secret and hopefully this will answer any questions you may have."") .addPlayer(HeadE.CALM_TALK, ""Okay. Go on."") .addNPC(ID, HeadE.CALM_TALK, ""I am not really a trader. I am the Commander of the Varrock Palace Secret Guard. VPSG for short."") .addPlayer(HeadE.CALM_TALK, ""Okay, I had a feeling you weren't a real trader due to the fact that you had nothing to sell! So why the secrecy?"") .addNPC(ID, HeadE.CALM_TALK, ""I'm just getting to that. A short while ago, we received word that Surok had discovered a powerful mind-control spell and intended to use it on King Roald himself!"") .addNPC(ID, HeadE.CALM_TALK, ""He could control the whole kingdom that way!"") .addPlayer(HeadE.AMAZED, ""I think I can believe that. Surok's not the nicest person in Misthalin."") .addNPC(ID, HeadE.CALM_TALK, ""Yes, but until now, the spell has been useless to him as he is currently under guard at the palace and not allowed to leave. He could not get the tools for the spell because if he left the palace, he would be arrested."") .addPlayer(HeadE.SAD_MILD, ""Uh oh! I think I may have helped him by mistake, here. He promised me a big reward if I collected some items for him...but he said it was for a spell to make gold!"") .addNPC(ID, HeadE.CALM_TALK, ""Yes, we heard that somehow Surok had obtained the things he needed but we were not sure how. I thought it might have been you."") .addNPC(ID, HeadE.CALM_TALK, ""However, I assumed you did not know of his plans; that is why you weren't arrested!"") .addPlayer(HeadE.CONFUSED, ""Thank you! How can I help fix this mistake?"") .addNPC(ID, HeadE.CHEERFUL, ""Okay, here's what I need you to do. One of my contacts has devised a spell that he is sure will be able to counteract the effects of the mind-control spell. I need you to visit him."") .addPlayer(HeadE.CHEERFUL, ""Okay, who is it?"") .addNPC(ID, HeadE.CHEERFUL, ""His name is Zaff. He runs a staff shop in Varrock. Go and speak to him and he will tell you what you should do. I will send word to him to let him know that you are coming."") .addPlayer(HeadE.CHEERFUL, ""Yes, sir! I'm on my way!"", () -> { player.getInventory().deleteItem(11010, 1); player.setQuestStage(Quest.WHAT_LIES_BELOW, 6); }) .getHead(); yield new Dialogue() .addNPC(ID, HeadE.CHEERFUL, ""Ah, "" + player.getDisplayName() + ""! You've returned!"") .addOptions(ops -> { ops.add(""Yes! I have a letter for you."") .addPlayer(HeadE.CHEERFUL, ""Yes! I have a letter for you."") .addNPC(ID, HeadE.CONFUSED, ""A letter for me? Let me see."") .addNext(giveLetter); ops.add(""Yes, and you have some explaining to do!"") .addPlayer(HeadE.ANGRY, ""Yes, and you have some explaining to do!"") .addNPC(ID, HeadE.AMAZED, ""Why? Whatever do you mean?"") .addPlayer(HeadE.ANGRY, ""This letter from Surok to you implies that you're involved in a treasonous plot! I should tell the guards about you!"") .addNPC(ID, HeadE.AMAZED, ""I'm sure I don't know what you mean. Let me see the letter, please."") .addNext(giveLetter); ops.add(""What, you're still here?"") .addPlayer(HeadE.AMAZED, ""What, you're still here?"") .addNPC(ID, HeadE.CHEERFUL, ""Yes. I still haven't found someone to help me yet, but I hear you've been very busy yourself!"") .addPlayer(HeadE.CONFUSED, ""You have? Who told you that?"") .addNPC(ID, HeadE.CHEERFUL, ""Oh, I have my sources. Was there anything else?""); }); } case 6, 7 -> new Dialogue() .addNPC(ID, HeadE.CONFUSED, ""Yes, "" + player.getDisplayName() + ""?"") .addOptions(ops -> { ops.add(""What am I doing now?"") .addPlayer(HeadE.CONFUSED, ""What am I doing now?"") .addNPC(ID, HeadE.CHEERFUL, ""You need to go and see Zaff. He can be found at \""Zaff's Staffs\"", the staff shop in Varrock. He will tell you what to do next.""); ops.add(""Do you think we can stop Surok?"") .addPlayer(HeadE.CONFUSED, ""Do you think we can stop Surok?"") .addNPC(ID, HeadE.CALM_TALK, ""Surok is a powerful mage and ruthless too. Who knows what will happen. I am sure that we will prevail, though. Don't worry, "" + player.getDisplayName() + ""! You'll be fine!""); ops.add(""Do you have anything to trade yet?"") .addPlayer(HeadE.CONFUSED, ""Do you have anything to trade yet?"") .addNPC(ID, HeadE.SAD_MILD, ""No, I'm afraid I have nothing in stock, largely due to the fact that I'm not really a trader, as I just mentioned."") .addPlayer(HeadE.CHEERFUL, ""Ah yes, I remember!""); ops.add(""Hey, your cart has no donkey!"") .addPlayer(HeadE.AMAZED, ""Hey, your cart has no donkey!"") .addNPC(ID, HeadE.CHEERFUL, ""Yes, that would be because it's a rickshaw cart."") .addPlayer(HeadE.CHEERFUL, ""Oh. I used to know a guy called Rick Shaw!"") .addNPC(ID, HeadE.CHEERFUL, ""You don't say...!""); }); case 8 -> new Dialogue() .addNPC(ID, HeadE.CONFUSED, ""Well, "" + player.getDisplayName() + "", how did it go?"") .addPlayer(HeadE.CHEERFUL, ""You should have been there! There was this...and Surok was like...and I was...and then the king...and, and...uh...ahem! The mission was accomplished and the king has been saved."") .addNPC(ID, HeadE.CHEERFUL, ""I take it that it went alright, then? That's great news!"") .addNPC(ID, HeadE.CHEERFUL, ""Zaff has already briefed me on the events. We will arrange for Surok to be fed and watched. I think he will not be a problem any more."") .addPlayer(HeadE.CONFUSED, ""You know, one thing bothers me. He's now stuck in the library, but wasn't that the reason we were in this mess in the first place?"") .addNPC(ID, HeadE.CHEERFUL, ""Yes, you are right. But rest assured, we will be watching him much more closely from now on."") .addNPC(ID, HeadE.CHEERFUL, ""You've done very well and have been a credit to the VPSG; perhaps one day there may be a place for you here!"") .addNPC(ID, HeadE.CHEERFUL, ""In the meantime, let me reward you for what you've done. I will be sure to call on you if we ever need help in the future."") .addNext(() -> player.getQuestManager().completeQuest(Quest.WHAT_LIES_BELOW)); case 9 -> new Dialogue() .addNPC(ID, HeadE.CHEERFUL, ""Ah! "" + player.getDisplayName() + ""! You did a fine service to use. You might make a good member of the VPSG one day, with a little training and a bit more muscle!"") .addPlayer(HeadE.CONFUSED, ""So, do you have any more jobs for me to do?"") .addNPC(ID, HeadE.CALM_TALK, ""At the moment, no. Things seem pretty quiet. However, I have heard a rumor about something strange going on in...hmm, no, I think we can handle this one for now."") .addNPC(ID, HeadE.CHEERFUL, ""But, who knows? We may need your assistance again soon. Thank you, "" + player.getDisplayName() + ""."") .addPlayer(HeadE.CHEERFUL, ""Any time, Rat!""); default -> throw new IllegalStateException(""Unexpected value: "" + player.getQuestStage(Quest.WHAT_LIES_BELOW)); }; } }" "package com.rs.game.content.quests.whatliesbelow.npcs; @PluginEventHandler public class SurokMagis extends Conversation { public static final int ID = 5853; public static NPCClickHandler handle = new NPCClickHandler(new Object[]{ID}, e -> e.getPlayer().startConversation(new SurokMagis(e.getPlayer(), e.getNPC()))); public SurokMagis(Player player, NPC npc) { super(player); switch (player.getQuestStage(Quest.WHAT_LIES_BELOW)) { case 0, 1 -> { addPlayer(HeadE.CONFUSED, ""Excuse me?""); addNPC(ID, HeadE.ANGRY, ""What do you want? ...Oh wait. I know! You're probably just like all the others, aren't you? After some fancy spell or potion from me, I bet!""); addPlayer(HeadE.AMAZED, ""What? No! At least, I don't think so. What sort of spells do you have?""); addNPC(ID, HeadE.ANGRY, ""Hah! I knew it! I expect you want my Aphro-Dizzy-Yak spell! Want someone to fall madly in love with you, eh?""); addPlayer(HeadE.CONFUSED, ""That spell sounds very interesting, but I didn't mean to disturb you!""); addNPC(ID, HeadE.CALM_TALK, ""Well, I see that you do have some manners. I'm glad to see that you use them. Now, if it's all the same, I am very busy at the moment. Unless you want something specific, please come back another time.""); addPlayer(HeadE.CHEERFUL, ""Yes, of course. Goodbye!""); } case 2 -> { addNPC(ID, HeadE.ANGRY, ""Hah! Come for my Aphro-Dizzy-Yak spell! Want someone to fall madly in love with you, eh? Not surprised with a face like that, to be honest!""); addPlayer(HeadE.ANGRY, ""I didn't come here to be insulted!""); addNPC(ID, HeadE.AMAZED, ""Really? Well, with ears like that, you do surprise me!""); addPlayer(HeadE.ANGRY, ""No, look. I have a letter for you.""); addNPC(ID, HeadE.CONFUSED, ""Really? Well then, let me see it!""); if (player.getInventory().containsItem(11009)) { addPlayer(HeadE.CHEERFUL, ""Here it is!""); addNext(() -> { player.lock(); player.getInventory().deleteItem(11009, 1); player.setQuestStage(Quest.WHAT_LIES_BELOW, 3); npc.stopAll(); npc.sync(6096, 1037); WorldTasks.delay(3, () -> { player.unlock(); player.startConversation(new SurokMagis(player, npc)); }); }); } else { addPlayer(HeadE.SAD_MILD, ""Oh. I had it here a moment ago. Where is it?""); addNPC(ID, HeadE.CHEERFUL, ""Hah! You've lost it already? You can't get good help these days!""); addPlayer(HeadE.SAD_MILD, ""I'm very sorry! Let me go get another one!""); addNPC(ID, HeadE.CALM_TALK, ""As you must! Now be off with you! I'm busy with studying here!""); } } case 3 -> { addPlayer(HeadE.CONFUSED, ""Why did you destroy the letter?""); addNPC(ID, HeadE.ANGRY, ""Never you mind! It's a secret!""); addPlayer(HeadE.SAD_MILD, ""Yes, there seems to be a lot of them going around at the moment.""); addNPC(ID, HeadE.CALM_TALK, ""Of course. Hmmmm. However, I could let you in on a secret, if you like?""); addOptions(ops -> { ops.add(""Go on then!"") .addPlayer(HeadE.CHEERFUL, ""Go on then!"") .addGotoStage(""theBigSecret"", this); ops.add(""Is it a BIG secret?"") .addPlayer(HeadE.CONFUSED, ""Is it a BIG secret?"") .addNPC(ID, HeadE.CHEERFUL, ""It's a very big secret!"") .addPlayer(HeadE.CHEERFUL, ""Bigger than a house?"") .addNPC(ID, HeadE.CONFUSED, ""Er, yes! It's..."") .addPlayer(HeadE.CHEERFUL, ""Bigger than a volcano?"") .addNPC(ID, HeadE.ANGRY, ""Yes. Look, it's big, alright? Now listen and I'll tell you."") .addGotoStage(""theBigSecret"", this); ops.add(""No thanks."") .addPlayer(HeadE.CALM_TALK, ""No thanks. I have other things to do for now!"") .addNPC(ID, HeadE.CALM_TALK, ""Very well, then. I hope these other matters of 'great' importance outweigh the need to make a LOT of gold. A WHOLE lot of gold. Gold. Yes, gold."") .addPlayer(HeadE.CONFUSED, ""Uh, why are you repeating yourself like that?"") .addNPC(ID, HeadE.CALM_TALK, ""Dramatic effect."") .addPlayer(HeadE.CONFUSED, ""Oh.""); }); addStage(""theBigSecret"", new Dialogue() .addNPC(ID, HeadE.CALM_TALK, ""My secret is this. I have been spending time here in the palace library trying to discover some ancient spells and magics."") .addNPC(ID, HeadE.CALM_TALK, ""In my research, I have uncovered a most astounding spell that will allow me to transform simple clay into solid gold bars!"") .addNPC(ID, HeadE.CALM_TALK, ""Now I am ready to use the spell to create all the gold I...uh...the city wants. I would gladly share this gold with you; I simply need a few more things!"") .addPlayer(HeadE.CONFUSED, ""Okay, what do you need?"") .addNPC(ID, HeadE.CALM_TALK, ""I will only need a couple of items. The first is very simple: an ordinary bowl to use as a casting vessel."") .addNPC(ID, HeadE.CHEERFUL, ""You should be able to find one of these at any local store here in Varrock. I would go myself but I am...uh...busy with my research."") .addNPC(ID, HeadE.CALM_TALK, ""The other item is much harder. I need a metal wand infused with chaos magic."") .addPlayer(HeadE.CONFUSED, ""How would I get something like that?"") .addNPC(ID, HeadE.CALM_TALK, ""Take this metal wand. You will also need 15 chaos runes. When you get to the Chaos Altar, use the wand on the altar itself. This should infuse the runes into the wand."", () -> { player.setQuestStage(Quest.WHAT_LIES_BELOW, 4); player.getInventory().addItemDrop(11002, 1); player.getInventory().addItemDrop(11012, 1); }) .addPlayer(HeadE.AMAZED, ""How on earth do you know about Runecrafting? I thought only a few people knew of it."") .addNPC(ID, HeadE.ANGRY, ""Hah! Don't presume to think that those wizards in their fancy tower are the only people to have heard of Runecrafting! Now pay attention!"") .addNPC(ID, HeadE.CALM_TALK, ""You will need to have the 15 chaos runes in your inventory. Make sure you also have either a chaos talisman or chaos tiara to complete the infusion."") .addPlayer(HeadE.CONFUSED, ""Where can I get a talisman or a tiara?"") .addNPC(ID, HeadE.CALM_TALK, ""I'm afraid I don't know. You will need to search for one."") .addNPC(ID, HeadE.CHEERFUL, ""Bring the infused wand and a bowl back to me and I will make us both rich!"") .addNPC(ID, HeadE.CHEERFUL, ""One more thing, I have uncovered information here in the library which may be of use to you. It tells of a safe route to the Chaos Altar that avoids the Wilderness."") .addPlayer(HeadE.CHEERFUL, ""Great! What is it?"") .addNPC(ID, HeadE.CALM_TALK, ""It is an old tome...a history book of sorts. It's somewhere here in the library. I forget where I left it, but it should be easy enough for you to find."") .addNPC(ID, HeadE.CALM_TALK, ""I have also given you a copy of a diary I...uh...acquired. It may also help you to find that which you seek."") .getHead()); } case 4 -> { boolean hasItems = player.getInventory().containsItems(1923, 11013); if (hasItems) addNPC(ID, HeadE.CONFUSED, ""Well?""); else addNPC(ID, HeadE.CALM_TALK, ""Ah! You're back. Have you found the things I need yet?""); addOptions(ops -> { if (hasItems) ops.add(""I have the things you wanted!"") .addPlayer(HeadE.CHEERFUL, ""I have the things you wanted!"") .addNPC(ID, HeadE.CHEERFUL, ""Excellent! Well done! I knew that you would not let me down."") .addPlayer(HeadE.CONFUSED, ""So...about this gold that you're going to give me?"") .addNPC(ID, HeadE.CHEERFUL, ""All in good time. I must prepare the spell first, and that will take a little time. While I am doing that, please take this letter to Rat, the trader outside the city who sent you here."") .addPlayer(HeadE.CALM_TALK, ""Okay, but I'll be back for my gold."") .addNPC(ID, HeadE.CHEERFUL, ""Yes, yes, yes. Now off you go!"", () -> { player.getInventory().deleteItem(1923, 1); player.getInventory().deleteItem(11013, 1); player.getInventory().addItemDrop(11010, 1); player.setQuestStage(Quest.WHAT_LIES_BELOW, 5); }); if (!hasItems) ops.add(""Remind me what I am doing again?"") .addPlayer(HeadE.CALM_TALK, ""Remind me what I am doing again?"") .addNPC(ID, HeadE.CALM_TALK, ""Take this metal wand. You will also need 15 chaos runes. When you get to the Chaos Altar, use the wand on the altar itself. This should infuse the runes into the wand."", () -> { if (!player.containsAnyItems(11012, 11013)) player.getInventory().addItemDrop(11012, 1); }) .addPlayer(HeadE.AMAZED, ""How on earth do you know about Runecrafting? I thought only a few people knew of it."") .addNPC(ID, HeadE.ANGRY, ""Hah! Don't presume to think that those wizards in their fancy tower are the only people to have heard of Runecrafting! Now pay attention!"") .addNPC(ID, HeadE.CALM_TALK, ""You will need to have the 15 chaos runes in your inventory. Make sure you also have either a chaos talisman or chaos tiara to complete the infusion."") .addPlayer(HeadE.CONFUSED, ""Where can I get a talisman or a tiara?"") .addNPC(ID, HeadE.CALM_TALK, ""I'm afraid I don't know. You will need to search for one."") .addNPC(ID, HeadE.CHEERFUL, ""Bring the infused wand and a bowl back to me and I will make us both rich!""); if (!hasItems) ops.add(""I lost the wand!"") .addPlayer(HeadE.SAD_MILD, ""I lost the wand!"") .addNPC(ID, HeadE.ANGRY, ""Somehow, I knew that would happen so I have made a few spares for just such an occasion."") .addNextIf(() -> player.getInventory().containsItem(11012), new Dialogue() .addNPC(ID, HeadE.CALM_TALK, ""Here you g...hang on! There's still one in your inventory! I just saw it! You don't need two and they're not worth anything...yet! Now get going already; there's not much time!"") .addNext(() -> { })) .addNPC(ID, HeadE.CHEERFUL, ""Here you are. Try not to lose this one!"", () -> { if (!player.containsAnyItems(11012, 11013)) player.getInventory().addItemDrop(11012, 1); }); if (!hasItems) ops.add(""How much gold will I get?"") .addPlayer(HeadE.CONFUSED, ""How much gold will I get?"") .addNPC(ID, HeadE.CALM_TALK, ""Hmmmmm. That all depends on how quickly you get me that infused wand! Work fast and well for me, "" + player.getDisplayName() + "", and I will make you rich, famous and powerful."") .addPlayer(HeadE.CHEERFUL, ""Really? Powerful, eh? How powerful?"") .addNPC(ID, HeadE.CALM_TALK, ""That depends."") .addPlayer(HeadE.CONFUSED, ""Depends on what?"") .addNPC(ID, HeadE.ANGRY, ""On how soon you stop yapping and get me that wand! Now get moving!""); ops.add(""Can I ask about the diary?"") .addPlayer(HeadE.CONFUSED, ""Can I ask about the diary?"") .addNPC(ID, HeadE.CONFUSED, ""Of course. What would you like to know?"") .addOptions(this, ""diaryQuestions"", diaryOps -> { diaryOps.add(""Who is Sin'keth?"") .addPlayer(HeadE.CONFUSED, ""Who is this Sin'keth?"") .addNPC(ID, HeadE.CHEERFUL, ""Sin'keth Magis? From what I have read, it would appear he was a great leader of the Dagon'hai Mages."") .addPlayer(HeadE.CONFUSED, ""The Dagon-what?"") .addNPC(ID, HeadE.ANGRY, ""Hmph! If you read the diary or perused that tome I mentioned, you would know who they are."") .addPlayer(HeadE.CONFUSED, ""Hey, wait! Isn't your last name Magis too? Are you related to him?"") .addNPC(ID, HeadE.ANGRY, ""No. Not at all. Purely coincidence! Now, haven't you got work to do already?"") .addGotoStage(""diaryQuestions"", this); diaryOps.add(""Where did it come from?"") .addPlayer(HeadE.CONFUSED, ""Where did it come from?"") .addNPC(ID, HeadE.ANGRY, ""How I came to have the diary is of no concern to you!"") .addPlayer(HeadE.CALM_TALK, ""Oooo, tetchy!"") .addNPC(ID, HeadE.CALM_TALK, ""I suggest that you concentrate on getting the things I need and stop asking pointless questions!"") .addGotoStage(""diaryQuestions"", this); diaryOps.add(""Where is the safe route?"") .addPlayer(HeadE.CONFUSED, ""Where is the safe route?"") .addNPC(ID, HeadE.CHEERFUL, ""I could tell you, of course; I know more or less exactly where it is. However, that would take all the fun out of this, wouldn't it?"") .addPlayer(HeadE.CALM_TALK, ""No, really! It's okay! You can tell me where it is!"") .addNPC(ID, HeadE.CHEERFUL, ""No, I think you should see if you can find it for yourself. I have given you the diary and, along with the tome around here, you should be able to find that alternate route easily enough on your own!"") .addGotoStage(""diaryQuestions"", this); diaryOps.add(""Can I have another one?"") .addPlayer(HeadE.CONFUSED, ""Can I have another one?"") .addNPC(ID, HeadE.CONFUSED, ""You want another copy of the diary?"") .addPlayer(HeadE.CHEERFUL, ""Yes, I seem to have misplaced the last one."") .addNPC(ID, HeadE.CALM_TALK, ""Fine, but this diary is important you know! It has secrets that you should not share around with just anybody!"", () -> player.getInventory().addItemDrop(11002, 1)) .addGotoStage(""diaryQuestions"", this); diaryOps.add(""Never mind, I forgot the question.""); }); ops.add(""Where is that tome you mentioned again?"") .addPlayer(HeadE.CONFUSED, ""Where is that tome you mentioned, again?"") .addNPC(ID, HeadE.CALM_TALK, ""Like I said, it's lying around here in the library somewhere. It should be easy enough to find.""); }); } case 5 -> { if (!player.containsItem(11010)) { addPlayer(HeadE.ANGRY, ""That letter was treasonous so I destroyed it!""); addNPC(ID, HeadE.CONFUSED, ""Really? You destroyed it?""); addPlayer(HeadE.ANGRY, ""Yes!""); addNPC(ID, HeadE.CALM_TALK, ""You want another one, don't you?""); addPlayer(HeadE.CONFUSED, ""Ah...uh...yes...yes, I do.""); addNPC(ID, HeadE.CALM_TALK, ""Fine. Here you are. And stop all this complaining; it's getting me down."", () -> player.getInventory().addItemDrop(11010, 1)); } else { addPlayer(HeadE.AMAZED, ""This letter is treasonous! I'm going to report you to the king!""); addNPC(ID, HeadE.CHEERFUL, ""Hah! And what would make him believe you? They would think it was a fake! Besides, if you still want the gold I promised, you would do well to deliver that letter for me. Join me and together we can rule Misthalin!""); } addOptions(ops -> { ops.add(""Who are you really?"") .addPlayer(HeadE.CONFUSED, ""Who are you really?"") .addNPC(ID, HeadE.CALM_TALK, ""That is none of your concern! I am Surok Magis and I am more powerful than you can possibly imagine!"") .addPlayer(HeadE.CONFUSED, ""So what's in it for me?"") .addNPC(ID, HeadE.CALM_TALK, ""You get to live. For now."") .addPlayer(HeadE.CALM_TALK, ""Not that I'm complaining about the living part, but I was expecting something of more...er...valuable?"") .addNPC(ID, HeadE.CALM_TALK, ""Ah, yes. The gold. Don't you worry, I am still working on that. Just deliver my letter for me, first. Now be off!"") .addPlayer(HeadE.CALM_TALK, ""Fine. I will deliver the letter, but I will be back soon."") .addNPC(ID, HeadE.CALM_TALK, ""I am sure you will.""); ops.add(""Do I still get the gold?"") .addPlayer(HeadE.CONFUSED, ""Do I still get the gold?"") .addNPC(ID, HeadE.CALM_TALK, ""If that is your only concern, then yes, you do. But I must warn you, my patience with you is wearing thin. So go now and do my bidding."") .addPlayer(HeadE.CALM_TALK, ""Fine. I will deliver the letter, but I will be back soon."") .addNPC(ID, HeadE.CALM_TALK, ""I am sure you will.""); ops.add(""I'll never join you!"") .addPlayer(HeadE.ANGRY, ""I'll never join you!"") .addNPC(ID, HeadE.CALM_TALK, ""My, my! How heroic! Not that it matters. I don't need you for my plans. However, if you want this gold, then you would do well to do as you are told."") .addPlayer(HeadE.CALM_TALK, ""Fine. I will deliver the letter, but I will be back soon."") .addNPC(ID, HeadE.CALM_TALK, ""I am sure you will.""); ops.add(""Nevermind, I forgot the question.""); }); } case 6 -> { addPlayer(HeadE.ANGRY, ""I've been told of your foul plans, Surok! You lied to me about the gold, so I've come to stop you!""); addNPC(ID, HeadE.CHEERFUL, ""Oh really? And what makes you think you have even the slightest chance of doing that?""); addPlayer(HeadE.ANGRY, ""I'll fight you if I have to!""); addNPC(ID, HeadE.ANGRY, ""Enough! You have been of use to me before but now you are wasting my time! Be gone!""); } case 7 -> { addPlayer(HeadE.ANGRY, ""Surok!! Your plans have been uncovered! You are hereby under arrest on the authority of the Varrock Palace Secret Guard!""); if (!player.getInventory().containsItem(11014) && !player.getEquipment().containsOneItem(11014)) { addNPC(ID, HeadE.ANGRY, ""You fool! You are no match for my power! You don't have the means to stop me! Get out of my sight!"", () -> player.tele(Tile.of(3214, 3378, 0))); create(); return; } addNPC(ID, HeadE.ANGRY, ""So! You're with the Secret Guard, eh? I should have known! I knew you had ugly ears from the start...and your nose is too short!""); addPlayer(HeadE.ANGRY, ""Give yourself up, Surok!""); addNPC(ID, HeadE.ANGRY, ""Never! I am Surok Magis, descendant of the High Elder Sin'keth Magis, rightful heir of the Dagon'hai Order! I will have my revenge on those who destroyed my people!""); addPlayer(HeadE.ANGRY, ""The place is surrounded. There is nowhere to run!""); addNPC(ID, HeadE.ANGRY, ""Do you really wish to die so readily? Are you prepared to face your death?""); addOptions(ops -> { ops.add(""Bring it on!"") .addPlayer(HeadE.ANGRY, ""Bring it on!"") .addNPC(ID, HeadE.ANGRY, ""I am a Dagon'hai! I run from nothing. My spell has been completed and it is time for you to meet your end, "" + player.getDisplayName() +""! The king is now under my control!"") .addNext(() -> player.getControllerManager().startController(new PlayerVsKingFight())); ops.add(""Fine! You win this time!"") .addPlayer(HeadE.ANGRY, ""Fine! You win this time!"") .addNPC(ID, HeadE.ANGRY, ""Get out of my sight then!""); }); } case 8 -> { addNPC(ID, HeadE.CALM_TALK, ""You have foiled my plans, "" + player.getDisplayName()+""... I obviously underestimated you.""); addPlayer(HeadE.CALM_TALK, ""Yes. Let this be a lesson to you.""); addNPC(ID, HeadE.AMAZED, ""...""); } } create(); } }" "package com.rs.game.content.quests.witchshouse; @PluginEventHandler public class BoyWitchsHouseD extends Conversation { public BoyWitchsHouseD(Player player) { super(player); switch(player.getQuestManager().getStage(Quest.WITCHS_HOUSE)) { case NOT_STARTED ->{ addPlayer(HeadE.HAPPY_TALKING, ""Hello young man.""); addSimple(""*The boy sobs""); addOptions(""Choose an option:"", new Options() { @Override public void create() { option(""What's the matter?"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""What's the matter?"") .addNPC(BOY, HeadE.CHILD_CRYING, ""I've kicked my ball over that hedge, into that garden! The old lady who lives there is scary... She's locked the "" + ""ball in her wooden shed! Can you get my ball back for me please?"") .addOptions(""Start Witch's House?"", new Options() { @Override public void create() { option(""Yes."", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Ok, I'll see what I can do."", () -> player.getQuestManager().setStage(Quest.WITCHS_HOUSE, FIND_BALL)) .addNPC(BOY, HeadE.CHILD_CALM_TALK, ""Thanks mister!"") ); option(""No."", new Dialogue()); } }) ); option(""Well if you're not going to answer, I'll go."", new Dialogue() .addPlayer(HeadE.FRUSTRATED, ""Well if you're not going to answer, I'll go"") .addSimple(""*The boy sniffs slightly."") ); } }); } case FIND_BALL -> { if(player.getInventory().containsItem(BALL, 1)) { addPlayer(HeadE.HAPPY_TALKING, ""Hi, I have got your ball back. It was MUCH harder than I thought it would be.""); addSimple(""You give the ball back.""); addNPC(BOY, HeadE.CHEERFUL, ""Thank you so much!""); addNext(() -> { player.getInventory().removeItems(new Item(BALL, 1)); player.getQuestManager().completeQuest(Quest.WITCHS_HOUSE); }); } else { addNPC(BOY, HeadE.CHILD_HAPPY_TALK, ""I can't wait to get my ball...""); addPlayer(HeadE.CALM, ""...""); } } case QUEST_COMPLETE -> { addNPC(BOY, HeadE.CHILD_SAD, ""I kicked my ball into the witch's garden again...""); addPlayer(HeadE.FRUSTRATED, ""I am not getting it for you again...""); } } } public static NPCClickHandler handleBoyDialogue = new NPCClickHandler(new Object[] { BOY }, e -> e.getPlayer().startConversation(new BoyWitchsHouseD(e.getPlayer()).getStart())); }" "package com.rs.game.content.quests.witchshouse; public class WitchsDiary extends Book { public WitchsDiary() { super(""Witches' Diary"", new BookPage( new String[] { ""2nd of Pentember"", ""Experiment is growing"", ""larger daily. Making"", ""excellent progress"", ""now. I am currently"", ""feeding it on a mixture"", ""of fungus, tar and clay."", ""It seems to like this"", ""combination a lot!"", """", """", }, new String[] { ""3rd of Pentember"", ""Experiment still going"", ""extremely well. Moved it"", ""to the wooden garden"", ""shed; it does too much"", ""damage to the house! It"", ""is getting very strong"", ""now, but unfortunately"", ""is not too intelligent yet."", ""It has a really mean stare"", ""too!"", }), new BookPage( new String[] { ""4th of Pentember"", ""Sausages for dinner"", ""tonight! Lovely!"", """", ""5th of Pentember"", ""A guy called Professor"", ""Oddenstein installed a"", ""new security system for"", ""me in the basement. He"", ""seems to have a lot of"", ""good security ideas."", }, new String[] { ""6th of Pentember"", ""Don't want people getting "", ""into my back garden to see "", ""the experiment. Professor "", ""Oddenstein is fitting me a "", ""new security system "", ""after his successful "", ""installation in the cellar."", """", """", """", }), new BookPage( new String[] { ""7th of Pentember"", ""That pesky kid keeps"", ""kicking his ball into my "", ""garden. I swear, if he "", ""does it AGAIN, I'm going"", ""to lock his ball away in "", ""the shed."", """", ""8th of Pentember"", ""The security system is "", ""done. By Zamorak! Wow, "", }, new String[] { ""is it contrived! Now, to "", ""open my own back door, "", ""I lure a mouse out of a "", ""hole in the back porch, I "", ""fit a magic curved piece "", ""of metal to the harness "", ""on its back, the mouse "", ""goes back in the hole, and"", "" the door unlocks! The"", ""prof tells me that this is "", ""cutting edge technology!"", }), new BookPage( new String[] { ""As an added precaution I"", ""have hidden the key to "", ""the shed in a secret "", ""compartment of the "", ""fountain in the garden. "", ""No one will ever look "", ""there!"", """", ""9th of Pentember"", ""Still cant think of a good"", "" name for 'The "", }, new String[] { ""Experiment'. Leaning"", "" towards 'Fritz'... Although"", ""am considering Lucy as"", ""it reminds me of my "", ""mother!"", """", """", """", """", """", """", }) ); } }" "package com.rs.game.content.quests.witchshouse; @PluginEventHandler public class WitchSentry extends NPC { public static NPCInstanceHandler toFunc = new NPCInstanceHandler(WITCH, (npcId, tile) -> new WitchSentry(tile)); public WitchSentry(Tile tile) { super(WITCH, tile, true); setRandomWalk(false); WorldTasks.scheduleLooping(new Task() { int tick = 10; Player player; @Override public void run() { if (tick > 3) { for (Player p : World.getPlayersInChunkRange(getChunkId(), 1)) { if (p == null) continue; if (lineOfSightTo(p, false)) { player = p; p.lock(); resetWalkSteps(); faceEntity(p); setNextSpotAnim(new SpotAnim(108)); setNextAnimation(new Animation(711)); forceTalk(""Get out!""); tick = 3; break; } } } if (tick == 1) tick = 10; if (tick == 2) { player.unlock(); Magic.sendObjectTeleportSpell(player, false, Tile.of(2892, 3373, 0)); player = null; tick--; } if (tick == 3) tick--; if (tick == 5) walkToAndExecute(Tile.of(2895, 3363, 0), () -> tick = 10); if (tick == 10) walkToAndExecute(Tile.of(2922, 3363, 0), () -> tick = 5); } }, 0, 1); } @Override public void processEntity() { super.processEntity(); processNPC(); } @Override public boolean lineOfSightTo(Object target, boolean melee) { Tile tile = WorldUtil.targetToTile(target); int targSize = target instanceof Entity ? ((Entity) target).getSize() : 1; if (World.hasLineOfSight(getMiddleTile(), getSize(), target instanceof Entity e ? e.getMiddleTile() : tile, targSize)) { Logger.debug(WitchSentry.class, ""lineOfSightTo"", ""dX:"" + getDirection().dx); if (getDirection().dx == 1) { if (tile.getX() > getX() && checkByConeSightX(tile)) return true; } else if (getDirection().dx == -1 && checkByConeSightX(tile)) if (tile.getX() < getX()) return true; } return false; } public boolean checkByConeSightX(Tile tile) { int xDifference = Math.abs(tile.getX() - getX()); int yDifference = Math.abs(tile.getY() - getY()); if (yDifference <= xDifference)//one for one cone. Multiply difference by 2 for one for two cone. return true; return false; } }" "package com.rs.game.content.quests.witchshouse; @QuestHandler( quest = Quest.WITCHS_HOUSE, startText = ""Talk to Harvey, the crying boy west of Falador."", itemsText = ""Cheese or cheese wheel, leather gloves, some combat equipment and food."", combatText = ""You will need to defeat a shapeshifting enemy with forms up to level 49."", rewardsText = ""6,325 Constitution XP"", completedStage = 2 ) @PluginEventHandler public class WitchsHouse extends QuestOutline { public final static int NOT_STARTED = 0; public final static int FIND_BALL = 1; public final static int QUEST_COMPLETE = 2; //items protected final static int DOOR_KEY = 2409; protected final static int BACKROOM_KEY = 2411; protected final static int MAGNET = 2410; protected final static int WITCH_DIARY = 2408; protected final static int BALL = 2407; //NPCs protected final static int BOY = 895; protected final static int WITCH = 896; protected final static int MOUSE = 901; protected final static int EXPERIMENT1 = 897; protected final static int EXPERIMENT2 = 898; protected final static int EXPERIMENT3 = 899; protected final static int EXPERIMENT4 = 900; @Override public List getJournalLines(Player player, int stage) { ArrayList lines = new ArrayList<>(); switch(stage) { case NOT_STARTED: lines.add(""A young boy who lives in Taverley has kicked his ball into""); lines.add(""the garden of a scary old lady. He asks you to get it back""); lines.add(""for him. This proves more difficult than it first sounds.""); lines.add(""""); break; case FIND_BALL: lines.add(""I need to find this boy's ball. Perhaps the witch left""); lines.add(""clues lying around her house?""); lines.add(""""); lines.add(""*Hint, you may need cheese""); break; case QUEST_COMPLETE: lines.add(""""); lines.add(""""); lines.add(""QUEST COMPLETE!""); break; default: lines.add(""Invalid quest stage. Report this to an administrator.""); break; } return lines; } public static ItemClickHandler handleClickOnWitchDiary = new ItemClickHandler(new Object[] { WITCH_DIARY }, new String[] { ""Read"" }, e -> e.getPlayer().openBook(new WitchsDiary())); public static ObjectClickHandler handlePottedPlant = new ObjectClickHandler(new Object[] { 2867 }, e -> { Player p = e.getPlayer(); if(p.getQuestManager().getStage(Quest.WITCHS_HOUSE) != FIND_BALL) { p.startConversation(new Conversation(e.getPlayer()) { { addSimple(""I have no reason to look under there.""); create(); } }); return; } if(!p.getInventory().containsItem(DOOR_KEY, 1)) { if(!p.getInventory().hasFreeSlots()) { p.sendMessage(""You don't have room...""); return; } p.getInventory().addItem(new Item(DOOR_KEY, 1)); p.sendMessage(""You found a key!""); } }); public static ObjectClickHandler handleFountain = new ObjectClickHandler(new Object[] { 2864 }, e -> { Player p = e.getPlayer(); if(!p.getInventory().containsItem(BACKROOM_KEY, 1)) { if(!p.getInventory().hasFreeSlots()) { p.sendMessage(""You don't have room...""); return; } p.getInventory().addItem(new Item(BACKROOM_KEY, 1)); p.sendMessage(""You found a key!""); } }); public static ObjectClickHandler handleWitchHouseFrontDoor = new ObjectClickHandler(new Object[] { 2861 }, e -> { Player p = e.getPlayer(); GameObject obj = e.getObject(); if(p.getInventory().containsItem(new Item(DOOR_KEY, 1))) handleDoor(p, obj); else p.startConversation(new Conversation(e.getPlayer()) { { addSimple(""It appears to need a key...""); create(); } }); }); public static ObjectClickHandler handleWitchHouseBackRoomDoor = new ObjectClickHandler(new Object[] { 2863 }, e -> { Player p = e.getPlayer(); GameObject obj = e.getObject(); if(p.getInventory().containsItem(new Item(BACKROOM_KEY, 1))) { handleDoor(p, obj); if(!p.getQuestManager().getAttribs(Quest.WITCHS_HOUSE).getB(""KILLED_EXPERIMENT"")) { for (NPC npc : World.getNPCsInChunkRange(e.getPlayer().getChunkId(), 1)) if (npc.getId() == EXPERIMENT1 || npc.getId() == EXPERIMENT2 || npc.getId() == EXPERIMENT3 || npc.getId() == EXPERIMENT4) return; World.spawnNPC(EXPERIMENT1, Tile.of(2927, 3359, 0), -1, false, true); } } else p.startConversation(new Conversation(e.getPlayer()) { { addSimple(""It appears to need a key...""); create(); } }); }); public static NPCDeathHandler handleExperiment1 = new NPCDeathHandler(EXPERIMENT1, e -> { NPC n = World.spawnNPC(EXPERIMENT2, Tile.of(2927, 3363, 0), -1, false, true); n.setTarget(e.getKiller()); }); public static NPCDeathHandler handleExperiment2 = new NPCDeathHandler(EXPERIMENT2, e -> { NPC n = World.spawnNPC(EXPERIMENT3, Tile.of(2927, 3363, 0), -1, false, true); n.setTarget(e.getKiller()); }); public static NPCDeathHandler handleExperiment3 = new NPCDeathHandler(EXPERIMENT3, e -> { NPC n = World.spawnNPC(EXPERIMENT4, Tile.of(2927, 3363, 0), -1, false, true); n.setTarget(e.getKiller()); }); public static NPCDeathHandler handleExperiment4 = new NPCDeathHandler(EXPERIMENT4, e-> { if (e.killedByPlayer()) { Player p = (Player) e.getKiller(); if (p.getQuestManager().getStage(Quest.WITCHS_HOUSE) == FIND_BALL) p.getQuestManager().getAttribs(Quest.WITCHS_HOUSE).setB(""KILLED_EXPERIMENT"", true); } }); public static PickupItemHandler handleBallPickup = new PickupItemHandler(new Object[] { BALL }, Tile.of(2927, 3360, 0), e -> { Player p = e.getPlayer(); if(p.getQuestManager().getStage(Quest.WITCHS_HOUSE) != FIND_BALL) { e.cancelPickup(); p.startConversation(new Dialogue().addSimple(""I better not touch it..."")); return; } if(!p.getQuestManager().getAttribs(Quest.WITCHS_HOUSE).getB(""KILLED_EXPERIMENT"")) { for(NPC npc : World.getNPCsInChunkRange(e.getPlayer().getChunkId(), 1)) if(npc.getId() == EXPERIMENT1 || npc.getId() == EXPERIMENT2 || npc.getId() == EXPERIMENT3 || npc.getId() == EXPERIMENT4) npc.setTarget(p); e.cancelPickup(); p.sendMessage(""The experiment won't let you pick up the ball""); } }); public static PlayerStepHandler handleCheesePrompt = new PlayerStepHandler(Tile.of(2894, 3367, 0), e -> { if (e.getPlayer().getQuestManager().getStage(Quest.WITCHS_HOUSE) == FIND_BALL && e.getPlayer().containsItem(1985)) if (!e.getPlayer().getTempAttribs().getB(""MousePuzzleKnownWitchsHouse"")) { e.getPlayer().sendMessage(""You hear a hungry mouse in this room, must be the cheese...""); e.getPlayer().getTempAttribs().setB(""MousePuzzleKnownWitchsHouse"", true); } }); public static ObjectClickHandler handleWitchHouseMouseDoor = new ObjectClickHandler(new Object[] { 2862 }, e -> { Player p = e.getPlayer(); GameObject obj = e.getObject(); if(p.getQuestManager().getAttribs(Quest.WITCHS_HOUSE).getB(""MOUSE_SOLVED"")) handleDoor(p, obj); else p.startConversation(new Conversation(e.getPlayer()) { { addPlayer(HeadE.CALM_TALK, ""It appears to be locked by some mechanism, perhaps by the mouse hole?""); create(); } }); }); public static ItemOnObjectHandler handleMouseHole = new ItemOnObjectHandler(new Object[] { 2870 }, null, e -> { GameObject obj = e.getObject(); if(e.getPlayer().getQuestManager().getAttribs(Quest.WITCHS_HOUSE).getB(""MOUSE_SOLVED"")) { e.getPlayer().startConversation(new Conversation(e.getPlayer()) { { addPlayer(HeadE.CALM_TALK, ""The door is already unlocked...""); create(); } }); return; } if(e.getItem().getName().equalsIgnoreCase(""Cheese"")) { for(NPC npc : World.getNPCsInChunkRange(e.getPlayer().getChunkId(), 1)) if(npc.getId() == MOUSE) { e.getPlayer().startConversation(new Conversation(e.getPlayer()) { { addPlayer(HeadE.CALM_TALK, ""The mouse is right there...""); create(); } }); return; } e.getPlayer().getInventory().removeItems(new Item(1985, 1)); e.getPlayer().startConversation(new Conversation(e.getPlayer()) { { addSimple(""A mouse exits the hole...""); create(); } }); WorldTasks.scheduleLooping(new Task() { int tick; NPC mouse; @Override public void run() { if(tick == 0 ) mouse = World.spawnNPC(MOUSE, Tile.of(obj.getX()-1, obj.getY(), obj.getPlane()), -1, false, true); if(tick == 30) { if(!mouse.hasFinished()) mouse.finish(); stop(); } tick++; } }, 0, 1); } }); public static ItemOnNPCHandler handleItemOnMouse = new ItemOnNPCHandler(MOUSE, e -> { if(e.getItem().getId() == MAGNET) { e.getPlayer().startConversation(new Conversation(e.getPlayer()) { { addSimple(""You attach the magnet to the mouse's harness. The mouse finishes the cheese and runs back into its hole. You hear some"" + "" odd noises from inside the walls. There is a strange whirring noise from above the door frame.""); create(); } }); e.getNPC().finish(); e.getPlayer().getQuestManager().getAttribs(Quest.WITCHS_HOUSE).setB(""MOUSE_SOLVED"", true); } }); public static ObjectClickHandler handleWitchHouseLadderToBasement = new ObjectClickHandler(new Object[] { 24717, 24718 }, e -> { if(e.getObjectId() == 24718) e.getPlayer().useLadder(Tile.of(2774, 9759, 0)); else e.getPlayer().useLadder(Tile.of(2898, 3376, 0)); }); public static ObjectClickHandler handleWitchHouseElectricGate = new ObjectClickHandler(new Object[] { 2866, 2865 }, e -> { Player p = e.getPlayer(); String itemName = new Item(p.getEquipment().getGlovesId(), 1).getName(); if(p.getEquipment().wearingGloves() || (itemName.contains(""gloves"") && itemName.contains(""Gloves""))) handleDoubleDoor(e.getPlayer(), e.getObject()); else p.startConversation(new Conversation(e.getPlayer()) { { addSimple(""As your bare hands touch the gate you feel a shock"", () -> p.applyHit(new Hit(76, Hit.HitLook.TRUE_DAMAGE))); addPlayer(HeadE.SCARED, ""I will need some gloves to stop the electric current...""); create(); } }); }); public static ObjectClickHandler handleWitchsHouseCupboard = new ObjectClickHandler(new Object[] { 2868, 2869 }, e -> { Player p = e.getPlayer(); GameObject obj = e.getObject(); if(e.getOption().equalsIgnoreCase(""open"")) { p.setNextAnimation(new Animation(536)); p.lock(2); GameObject openedChest = new GameObject(obj.getId() + 1, obj.getType(), obj.getRotation(), obj.getX(), obj.getY(), obj.getPlane()); p.faceObject(openedChest); World.spawnObjectTemporary(openedChest, Ticks.fromMinutes(1)); } if(e.getOption().equalsIgnoreCase(""shut"")) { p.setNextAnimation(new Animation(536)); p.lock(2); GameObject openedChest = new GameObject(obj.getId() - 1, obj.getType(), obj.getRotation(), obj.getX(), obj.getY(), obj.getPlane()); p.faceObject(openedChest); World.spawnObjectTemporary(openedChest, Ticks.fromMinutes(1)); } if(e.getOption().equalsIgnoreCase(""search"")) if(p.getInventory().containsItem(MAGNET, 1)) p.sendMessage(""The cupboard is empty.""); else if(p.getInventory().hasFreeSlots()) p.getInventory().addItem(new Item(MAGNET, 1)); else p.sendMessage(""You need more inventory space.""); }); @Override public void complete(Player player) { player.getSkills().addXpQuest(Constants.HITPOINTS, 6325); sendQuestCompleteInterface(player, BALL); } }" "package com.rs.game.content.quests.wolfwhistle; @PluginEventHandler public class QuestPikkupstix extends Conversation { // npcs final static int PIKKUPSTIX = 6988; // animations static final int ANIMATION_ENCHANT = 15924; // spot animations static final int SPOT_ANIM_ENCHANT = 2814; public QuestPikkupstix(Player p, NPC pikkupstix) { super(p); switch (player.getQuestManager().getStage(Quest.WOLF_WHISTLE)) { case NOT_STARTED -> addPlayer(HeadE.CONFUSED, ""Hello there. I'm "" + player.getDisplayName() + "", the adventurer. Do you have a quest for me?"") .addNPC(PIKKUPSTIX, HeadE.CALM_TALK, ""Well I do have something you could look into, although I don't know if I would call it a quest, as such."") .addNPC(PIKKUPSTIX, HeadE.CALM_TALK, ""But if you do have some time free, could you look into the whereabouts of my two assistants, Scalectrix and Bowloftrix?"") .addPlayer(HeadE.CALM_TALK, ""Why, have they gone missing?"") .addNPC(PIKKUPSTIX, HeadE.SAD, ""Well, they are only slightly late compared to poor Feletrix..."") .addNPC(PIKKUPSTIX, HeadE.SHAKING_HEAD, ""Actually they are quite late, to be honest. I sent them out this morning to gather supplies, and they have not returned. It is a little worrying."") .addNPC(PIKKUPSTIX, HeadE.CALM_TALK, ""They were over by the old dry well in west Taverley opposite of the watermill. Could you take a look for me?"") .addPlayer(HeadE.CHEERFUL_EXPOSITION, ""All right. I am sure they will be fine."") .addPlayer(HeadE.CALM_TALK, ""They are probably just taking their time, or maybe stopped for a chat."") .addNPC(PIKKUPSTIX, HeadE.LAUGH, ""Oh, I do hope so! Thank you my lad!"") .addNext(() -> player.getQuestManager().setStage(Quest.WOLF_WHISTLE, WolfWhistle.FIND_SCALECTRIX)); case FIND_SCALECTRIX -> { } case PIKKUPSTIX_HELP -> // pikkupstix is supposed to offer looping quest dialogue from WOLPERTINGER_MATERIALS here addPlayer(HeadE.MORTIFIED, ""Bowloftrix has been kidnapped by trolls!"") .addNPC(PIKKUPSTIX, HeadE.MORTIFIED, ""Oh no, this is terrible! Is Scalectrix all right?"") .addPlayer(HeadE.CALM_TALK, ""Yes, she is keeping an eye on the trolls by the well. She says there are too many trolls to attack directly."") .addPlayer(HeadE.CALM_TALK, ""She tried scaring them away, but a spirit wolf didn't work. Do you have anything more powerful that could work?"") .addNPC(PIKKUPSTIX, HeadE.CONFUSED, ""I...might well do. But it's risky."") .addNPC(PIKKUPSTIX, HeadE.CALM_TALK, ""Although with you assisting me we might well do it. I sense deep wells of energy within you that you could tap."") .addNPC(PIKKUPSTIX, HeadE.CHEERFUL, ""You might even survive!"") .addPlayer(HeadE.CHEERFUL, ""Well thanks, I..."") .addPlayer(HeadE.MORTIFIED_JAW_DROP, ""...I might what now?"") .addNPC(PIKKUPSTIX, HeadE.CALM_TALK, ""We are going to attempt a momentous feat of summoning! We are going to try and summon...a giant wolpertinger!"") .addPlayer(HeadE.CONFUSED, ""How will that help?"") .addNPC(PIKKUPSTIX, HeadE.CALM_TALK, ""A giant wolpertinger is a legendary spirit creature that can generate an aura of fear so potent that even a hore of trolls will flee in terror at its approach."") .addNPC(PIKKUPSTIX, HeadE.CALM_TALK, ""Usually such a summoning would take a circle of experience druids, but we have to clear out that horde before they attack."") .addNPC(PIKKUPSTIX, HeadE.CALM_TALK, ""We will begin immediately. I need you to bring me a few things."") .addNPC(PIKKUPSTIX, HeadE.CALM_TALK, ""I will need you to bring me my ancient wolf bone amulet, some white hare meat, and an embroidered pouch. I will also need to give you a blessed spirit shard, and a grey charm."") .addNPC(PIKKUPSTIX, HeadE.CALM_TALK, ""The amulet should be with my assistant, Stikklebrix. He took it to White Wolf Mountain, which is the large range to the west of Taverley."") .addNPC(PIKKUPSTIX, HeadE.CALM_TALK, ""The hare meat is available from the pet shop, which is on the bottom floor of the building to the south of here."") .addNPC(PIKKUPSTIX, HeadE.CALM_TALK, ""The pouch is lost somewhere upstairs. I managed to lose it in a rather violent kafuffle."", () -> { player.getQuestManager().setStage(Quest.WOLF_WHISTLE, WolfWhistle.WOLPERTINGER_MATERIALS); player.getVars().setVarBit(10734, 1); }); case WOLPERTINGER_MATERIALS -> { if (WolfWhistle.wolfWhistleObeliskReadyToInfusePouch(p)) { addNPC(PIKKUPSTIX, HeadE.CONFUSED, ""How goes the hunt?"") .addPlayer(HeadE.CHEERFUL_EXPOSITION, ""I have the items all here!"") .addNPC(PIKKUPSTIX, HeadE.CHEERFUL_EXPOSITION, ""I see what I have heard about you is more than true! You've got everything right here!"") .addNPC(PIKKUPSTIX, HeadE.CALM, ""Now, before you go running off, let me do something..."") .addNext(() -> { pikkupstix.setNextAnimation(new Animation(ANIMATION_ENCHANT)); pikkupstix.setNextSpotAnim(new SpotAnim(SPOT_ANIM_ENCHANT)); //pikkupstix.playSound(123, 1); supposed to play a sound player.lock(3); }) .addPlayer(HeadE.CONFUSED, ""What was that about?"") .addNPC(PIKKUPSTIX, HeadE.CALM, ""I have some spirit helpers that sometimes do tasks for me. In this case I just asked them to make sure that these items will all return to me if they get lost or damaged."") .addNPC(PIKKUPSTIX, HeadE.CALM, ""Now, all you have to do is go and infuse them at the obelisk there. You won't have to worry about picking which pouch to make, as you know exactly what to make from these items."") .addPlayer(HeadE.CALM, ""Then what?"") .addNPC(PIKKUPSTIX, HeadE.CALM, ""Well, you should come over here and let me inspect your work. You never know what could go wrong with such a monumental summoning effort like this one!"") .addNext(() -> { player.getQuestManager().setStage(Quest.WOLF_WHISTLE, WolfWhistle.WOLPERTINGER_CREATION); player.getVars().setVarBit(10734, 0); }); } else { addNPC(PIKKUPSTIX, HeadE.CONFUSED, ""How goes the hunt?"") .addPlayer(HeadE.CALM, ""I need to ask about the items I need to make the Giant Wolpertinger pouch."") .addOptions(""Select an Option"", new Options() { @Override public void create() { if (!player.getInventory().containsItem(ANCIENT_WOLF_BONE_AMULET) && !player.getBank().containsItem(ANCIENT_WOLF_BONE_AMULET, 1)) { if (player.getQuestManager().getAttribs(Quest.WOLF_WHISTLE).getB(""ANCIENT_AMULET"")) { option(""Ask about the wolf bone amulet."", new Dialogue() .addNPC(PIKKUPSTIX, HeadE.CALM_TALK, ""No matter. The amulet is enchanted to return to the owner, and in this case that is currently Stikklebrix. So go and search him again."") .addNPC(PIKKUPSTIX, HeadE.FRUSTRATED, ""This time, try and take better care of it!"") ); } else { option(""Ask about the wolf bone amulet."", new Dialogue() .addNPC(PIKKUPSTIX, HeadE.CALM, ""I gave it to my assistant, Stikklebrix, when I sent him over to White Wolf Mountain to bring me some wolf fur. For luck, you know."") .addNPC(PIKKUPSTIX, HeadE.CONFUSED, ""Although now I come to think of it, I haven't seen him in a while...what day is it again? Huh...that means he's been gone about a week. I do hope he's all right."") .addNPC(PIKKUPSTIX, HeadE.CALM, ""Anyway, I'm sure you'll find him in good health. White Wolf Mountain is to the west of here. You will need to cross the river at the bridge to the south-west."") .addNPC(PIKKUPSTIX, HeadE.CALM, ""I'd suggest taking some food. There are vicious wolves there. If you see one, then just run past it if you can."") ); } } if (!player.getInventory().containsItem(WHITE_HARE_MEAT) && !player.getBank().containsItem(WHITE_HARE_MEAT, 1)) { if (player.getQuestManager().getAttribs(Quest.WOLF_WHISTLE).getB(""HARE_MEAT"")) { option(""Ask about the white hare meat."", new Dialogue() .addNPC(PIKKUPSTIX, HeadE.CHEERFUL_EXPOSITION, ""Wonderful, where is it?"") .addPlayer(HeadE.CHEERFUL_EXPOSITION, ""I have no idea!"") .addNPC(PIKKUPSTIX, HeadE.AMAZED, ""Hmm?"") .addPlayer(HeadE.CONFUSED, ""Should I check with the pet shop owner to see if he has some more?"") .addNPC(PIKKUPSTIX, HeadE.CALM_TALK, ""Yes. Yes you should."") ); } else { option(""Ask about the white hare meat."", new Dialogue() .addNPC(PIKKUPSTIX, HeadE.CALM, ""The pet shop owner in town has some. They import it for some of the more pampered pets, although to be honest more of it ends up on the plates of pet owners than in doggy-bowls."") .addNPC(PIKKUPSTIX, HeadE.CALM, ""The pet shop is on the bottom floor of the building to the south of my house."") .addNPC(PIKKUPSTIX, HeadE.NERVOUS, ""I would go and get it myself, but since the bird seed incident we are not on speaking terms."") ); } } if (!player.getInventory().containsItem(EMBROIDERED_POUCH) && !player.getBank().containsItem(EMBROIDERED_POUCH, 1)) { if (player.getQuestManager().getAttribs(Quest.WOLF_WHISTLE).getB(""EMBROIDERED_POUCH"")) { option(""Ask about the embroidered pouch."", new Dialogue() .addNPC(PIKKUPSTIX, HeadE.CONFUSED, ""Where did you lose it? Have you tried looking there for it again?"") ); } else { option(""Ask about the embroidered pouch."", new Dialogue() .addNPC(PIKKUPSTIX, HeadE.SAD_MILD_LOOK_DOWN, ""It's in my room upstairs, somewhere. We lost it when Beezeltrix summoned that smoke devil."") .addPlayer(HeadE.CONFUSED, ""What happened to her?"") .addNPC(PIKKUPSTIX, HeadE.SAD_MILD_LOOK_DOWN, ""Oh it was terrible! Really, true terrible...I've never seen such...carnage and devastation!"") .addNPC(PIKKUPSTIX, HeadE.CALM, ""We have managed to clean up all the glass and soot, but I couldn't find it. Obviously a fresh pair of eyes will do the trick."") .addNPC(PIKKUPSTIX, HeadE.CALM, ""Oh, and if you find a foot up there, do let me know. There's a good chap."") .addPlayer(HeadE.AMAZED, ""A foot? As in a 'foot' foot or a foot of something?"") .addNPC(PIKKUPSTIX, HeadE.LAUGH, ""Never mind! I remember where we found it now."") ); } } if (!player.getInventory().containsItem(RARE_SUMMONING_ITEMS) && !player.getBank().containsItem(RARE_SUMMONING_ITEMS, 1)) { if (player.getQuestManager().getAttribs(Quest.WOLF_WHISTLE).getB(""RARE_ITEMS"")) { option(""Ask about the rare summoning items."", new Dialogue() .addNPC(PIKKUPSTIX, HeadE.CONFUSED, ""Yes."") .addPlayer(HeadE.SECRETIVE, ""Theorectically, HOW rare and HOW unique were they?"") .addNPC(PIKKUPSTIX, HeadE.CALM_TALK, ""Rare and unique enough for me to enchant them to return to me if they were lost."") .addNPC(PIKKUPSTIX, HeadE.FRUSTRATED, ""So, imagine my surprise when I turn around and find them lying on my table."") .addPlayer(HeadE.SECRETIVE, ""Ahaha...funny story..."") .addItem(RARE_SUMMONING_ITEMS, ""Pikkupstix carefully hands you the rare summoning items."", () -> player.getInventory().addItem(RARE_SUMMONING_ITEMS)) .addNPC(PIKKUPSTIX, HeadE.CALM_TALK, ""Save it. Take them back, and try not to drop them this time."") ); } else { option(""Ask for the rare summoning items."", new Dialogue() .addNPC(PIKKUPSTIX, HeadE.CALM, ""Of course. Remember, these are EXTREMELY rare and precious, so I plead that you take good care of them."") .addItem(RARE_SUMMONING_ITEMS, ""Pikkupstix carefully hands you the grey charm and blessed spirit shard."", () -> { player.getInventory().addItem(RARE_SUMMONING_ITEMS); player.getQuestManager().getAttribs(Quest.WOLF_WHISTLE).setB(""RARE_ITEMS"", true); }) .addPlayer(HeadE.LAUGH, ""Well, you know, I'm pretty skilled at holding things. I should be able to keep this safe."") .addNPC(PIKKUPSTIX, HeadE.CALM, ""I hope you're right. These are very valuable relics."") ); } } option(""I think I had better go."", new Dialogue() .addNPC(PIKKUPSTIX, HeadE.CALM, ""Well, best of luck in your hunt."") ); } }); } } case WolfWhistle.WOLPERTINGER_CREATION -> addPlayer(HeadE.CALM_TALK, ""I need to ask you something about the quest..."") .addNPC(PIKKUPSTIX, HeadE.CONFUSED, ""What is it you need?"") .addOptions(new Options() { @Override public void create() { if (!p.getInventory().containsItem(ANCIENT_WOLF_BONE_AMULET) && !p.getBank().containsItem(ANCIENT_WOLF_BONE_AMULET, 1)) { option(""Discuss the quest"", new Dialogue() .addPlayer(HeadE.SAD_MILD_LOOK_DOWN, ""I lost your amulet."") .addNPC(PIKKUPSTIX, HeadE.CALM_TALK, ""I know. The spirits brought it back to me, covered in Guthix knows what kind of muck and slime."") .addNPC(PIKKUPSTIX, HeadE.CALM_TALK, ""I don't know what you were thinking, but try and keep a hold of this one!"", () -> p.getInventory().addItem(ANCIENT_WOLF_BONE_AMULET))); } else if (!p.getInventory().containsItem(WHITE_HARE_MEAT) && !p.getBank().containsItem(WHITE_HARE_MEAT, 1)) { option(""Discuss the quest"", new Dialogue() .addPlayer(HeadE.NERVOUS, ""I put the meat down for a second and it vanished. I think wolves took it."") .addNPC(PIKKUPSTIX, HeadE.CALM_TALK, ""Well it's a good job I enchanted it."") .addNPC(PIKKUPSTIX, HeadE.CALM_TALK, ""Keep better track of it this time."", () -> p.getInventory().addItem(WHITE_HARE_MEAT))); } else if (!p.getInventory().containsItem(EMBROIDERED_POUCH) && !p.getBank().containsItem(EMBROIDERED_POUCH, 1)) { option(""Discuss the quest"", new Dialogue() .addPlayer(HeadE.SECRETIVE, ""Oh hey...you remember that pouch I found?"") .addNPC(PIKKUPSTIX, HeadE.CALM_TALK, ""You mean the one my spirit helpers returned to me because you un-found it?"", () -> p.getInventory().addItem(EMBROIDERED_POUCH)) .addPlayer(HeadE.SAD_MILD_LOOK_DOWN, ""Yeah, that one..."") ); } else if (!p.getInventory().containsItem(RARE_SUMMONING_ITEMS) && !p.getBank().containsItem(RARE_SUMMONING_ITEMS, 1)) { option(""Discuss the quest"", new Dialogue() .addPlayer(HeadE.SECRETIVE, ""That enchantment that you cast on all those valuable items you have me. How effective was it?"") .addNPC(PIKKUPSTIX, HeadE.CALM_TALK, ""Very effective."") .addPlayer(HeadE.SAD_MILD_LOOK_DOWN, ""Uh, well I'd best be going now that I got these back."", () -> p.getInventory().addItem(RARE_SUMMONING_ITEMS))); } else { option(""Discuss the quest"", new Dialogue() .addPlayer(HeadE.CONFUSED, ""What do I need to do again?"") .addNPC(PIKKUPSTIX, HeadE.CALM_TALK, ""Well, you need to take those items over there and infuse them at the obelisk to make them into a giant wolpertinger pouch."") .addNPC(PIKKUPSTIX, HeadE.CONFUSED, ""I think that about covers it. Do you need any more help?"") .addPlayer(HeadE.CALM_TALK, ""Nope, I think I can handle that."") ); } option(""You really seem to have had some problems with your assistants."", new Dialogue() .addNPC(PIKKUPSTIX, HeadE.SAD, ""You are right, it has been pretty hard since the war started."") .addPlayer(HeadE.CONFUSED, ""Well what's happened? Have the trolls been killing them, or has it all been down to accidents?"") .addNPC(PIKKUPSTIX, HeadE.CALM, ""It is a mixture of both, really. To be honest, I have always found that my assistants have had a lot of eagerness and a lot less common sense for self-preservation."") .addNPC(PIKKUPSTIX, HeadE.CONFUSED, ""Now, let me see...You already know about Stikklebrix...who else was there?"") .addNPC(PIKKUPSTIX, HeadE.CALM, ""There was poor Lunatrix, who went mad. He tried to commune with some elder spirits, and they were not happy."") .addNPC(PIKKUPSTIX, HeadE.SAD_MILD_LOOK_DOWN, ""Last I saw of him, he went running out of the door with his pants on his head..."") .addNPC(PIKKUPSTIX, HeadE.CALM, ""Then there was Ashtrix. He managed to cut his own hand off, the poor fool."") .addNPC(PIKKUPSTIX, HeadE.SAD_MILD_LOOK_DOWN, ""It would have been all right, except he then managed to wedge a hacksaw in the stump, and in his delirium wouldn't let anyone help him."") .addNPC(PIKKUPSTIX, HeadE.CALM, ""Then there was Spartrix, who was captured by the Black Knights and taken as a slave."") .addNPC(PIKKUPSTIX, HeadE.SAD_MILD_LOOK_DOWN, ""I hear that he tried to lead a slaved rebellion. Which, while noble in itself, is not really the sort of thing a 5-foot, sickly, bookish druid should do."") .addNPC(PIKKUPSTIX, HeadE.SAD_MILD_LOOK_DOWN, ""Especially when unarmed and facing evil knights in full plate mail."") .addNPC(PIKKUPSTIX, HeadE.CONFUSED, ""Let's see...there was Beezeltrix and the smoke devil; we literally lost Felitrix; those trolls took the twins when they were healing soldiers on the front line..."") .addNPC(PIKKUPSTIX, HeadE.MORTIFIED, ""And the less said about Hastrix, the better!"") .addPlayer(HeadE.AMAZED, ""Wow...you really haven't had much luck with assistants."") .addNPC(PIKKUPSTIX, HeadE.SAD, ""It has been one heck of a busy week, I can tell you."") .addNPC(PIKKUPSTIX, HeadE.CONFUSED, ""Now, is there anything else you need?"") .addNext(() -> p.startConversation(new Pikkupstix(p, pikkupstix, false)))); } }); case WolfWhistle.WOLPERTINGER_POUCH_CHECK -> { if (player.getQuestManager().getAttribs(Quest.WOLF_WHISTLE).getB(""WOLPERTINGER_POUCH"")) { addNPC(PIKKUPSTIX, HeadE.CONFUSED, ""Have you done it? Do you have the pouch?""); } else { addPlayer(HeadE.CALM_TALK, ""I need to ask you something about the quest..."") .addNPC(PIKKUPSTIX, HeadE.CONFUSED, ""What is it you need?"") .addOptions(new Options() { @Override public void create() { // TODO: missing dialogue? } }); } addNPC(PIKKUPSTIX, HeadE.CONFUSED, ""Have you done it? Do you have the pouch?"") .addOptions(new Options() { @Override public void create() { if (player.getInventory().containsItem(GIANT_WOLPERTINGER_POUCH)) { option(""I made the giant wolpertinger pouch!"", new Dialogue() .addNPC(PIKKUPSTIX, HeadE.AMAZED, ""Phenomenal! I knew I sensed great things in your future my assistant. Come, let me see it!"") .addPlayer(HeadE.CALM, ""Here it is."") .addNPC(PIKKUPSTIX, HeadE.AMAZED, ""I had never thought we'd have needed one of these in my lifetime. Well done."") .addNPC(PIKKUPSTIX, HeadE.CALM, ""I think you are ready. Take this to Scalectrix. With her help, you should be able to summon this spirit beast and rout the trolls."") .addPlayer(HeadE.CALM, ""So can't I do this on my own?"") .addNPC(PIKKUPSTIX, HeadE.CALM, ""No, no. The energy needed to summon this beast is too much for just one person. Even with the pair of you it will only last a few moments."") .addNPC(PIKKUPSTIX, HeadE.CALM, ""But Scalectrix is strong too. Between you both you should be able to accomplish this."") .addNext(() -> p.getQuestManager().setStage(Quest.WOLF_WHISTLE, WolfWhistle.SAVE_BOWLOFTRIX))); } else { if (player.getQuestManager().getAttribs(Quest.WOLF_WHISTLE).getB(""WOLPERTINGER_POUCH"")) { option(""I made the giant wolpertinger pouch!"", new Dialogue() .addPlayer(HeadE.SECRETIVE, ""Well, between here and the obelisk I may have sort of managed to lose it..."") .addNPC(PIKKUPSTIX, HeadE.TERRIFIED, ""WHAT? One of the most potent summoning pouches of this era and you LOST it?"") .addNPC(PIKKUPSTIX, HeadE.AMAZED, ""Do you have any idea what this thing could do in the wrong hands? Any idea at all?"") .addNPC(PIKKUPSTIX, HeadE.CALM_TALK, ""You are lucky that I planned for this contingency. The enchantment I put on the items may well work now they have been combined into a pouch."") .addNPC(PIKKUPSTIX, HeadE.CALM_TALK, ""Now, don't lose this one!"", () -> p.getInventory().addItem(GIANT_WOLPERTINGER_POUCH))); } else { addPlayer(HeadE.CALM_TALK, ""I need to ask you something about the quest..."") .addNPC(PIKKUPSTIX, HeadE.CONFUSED, ""What is it you need?"") .addOptions(new Options() { @Override public void create() { option(""Discuss the quest"", new Dialogue() .addPlayer(HeadE.CONFUSED, ""What do I need to do again?"") .addNPC(PIKKUPSTIX, HeadE.CALM, ""well, you need to take those items over there and infuse them at the obelisk to make them into a giant wolpertinger pouch."") .addNPC(PIKKUPSTIX, HeadE.CONFUSED, ""I think that about covers it. Do you need any more help?"") .addPlayer(HeadE.CALM, ""Nope, I think I can handle that."") ); option(""You really seem to have had some problems with your assistants."", new Dialogue() .addNPC(PIKKUPSTIX, HeadE.SAD, ""You are right, it has been pretty hard since the war started."") .addPlayer(HeadE.CONFUSED, ""Well what's happened? Have the trolls been killing them, or has it all been down to accidents?"") .addNPC(PIKKUPSTIX, HeadE.CALM, ""It is a mixture of both, really. To be honest, I have always found that my assistants have had a lot of eagerness and a lot less common sense for self-preservation."") .addNPC(PIKKUPSTIX, HeadE.CONFUSED, ""Now, let me see...You already know about Stikklebrix...who else was there?"") .addNPC(PIKKUPSTIX, HeadE.CALM, ""There was poor Lunatrix, who went mad. He tried to commune with some elder spirits, and they were not happy."") .addNPC(PIKKUPSTIX, HeadE.SAD_MILD_LOOK_DOWN, ""Last I saw of him, he went running out of the door with his pants on his head..."") .addNPC(PIKKUPSTIX, HeadE.CALM, ""Then there was Ashtrix. He managed to cut his own hand off, the poor fool."") .addNPC(PIKKUPSTIX, HeadE.SAD_MILD_LOOK_DOWN, ""It would have been all right, except he then managed to wedge a hacksaw in the stump, and in his delirium wouldn't let anyone help him."") .addNPC(PIKKUPSTIX, HeadE.CALM, ""Then there was Spartrix, who was captured by the Black Knights and taken as a slave."") .addNPC(PIKKUPSTIX, HeadE.SAD_MILD_LOOK_DOWN, ""I hear that he tried to lead a slaved rebellion. Which, while noble in itself, is not really the sort of thing a 5-foot, sickly, bookish druid should do."") .addNPC(PIKKUPSTIX, HeadE.SAD_MILD_LOOK_DOWN, ""Especially when unarmed and facing evil knights in full plate mail."") .addNPC(PIKKUPSTIX, HeadE.CONFUSED, ""Let's see...there was Beezeltrix and the smoke devil; we literally lost Felitrix; those trolls took the twins when they were healing soldiers on the front line..."") .addNPC(PIKKUPSTIX, HeadE.MORTIFIED, ""And the less said about Hastrix, the better!"") .addPlayer(HeadE.AMAZED, ""Wow...you really haven't had much luck with assistants."") .addNPC(PIKKUPSTIX, HeadE.SAD, ""It has been one heck of a busy week, I can tell you."") .addNPC(PIKKUPSTIX, HeadE.CONFUSED, ""Now, is there anything else you need?"") .addNext(() -> p.startConversation(new Pikkupstix(p, pikkupstix, false)))); } }); } } option(""You really seem to have had some problems with your assistants."", new Dialogue() .addNPC(PIKKUPSTIX, HeadE.SAD, ""You are right, it has been pretty hard since the war started."") .addPlayer(HeadE.CONFUSED, ""Well what's happened? Have the trolls been killing them, or has it all been down to accidents?"") .addNPC(PIKKUPSTIX, HeadE.CALM, ""It is a mixture of both, really. To be honest, I have always found that my assistants have had a lot of eagerness and a lot less common sense for self-preservation."") .addNPC(PIKKUPSTIX, HeadE.CONFUSED, ""Now, let me see...You already know about Stikklebrix...who else was there?"") .addNPC(PIKKUPSTIX, HeadE.CALM, ""There was poor Lunatrix, who went mad. He tried to commune with some elder spirits, and they were not happy."") .addNPC(PIKKUPSTIX, HeadE.SAD_MILD_LOOK_DOWN, ""Last I saw of him, he went running out of the door with his pants on his head..."") .addNPC(PIKKUPSTIX, HeadE.CALM, ""Then there was Ashtrix. He managed to cut his own hand off, the poor fool."") .addNPC(PIKKUPSTIX, HeadE.SAD_MILD_LOOK_DOWN, ""It would have been all right, except he then managed to wedge a hacksaw in the stump, and in his delirium wouldn't let anyone help him."") .addNPC(PIKKUPSTIX, HeadE.CALM, ""Then there was Spartrix, who was captured by the Black Knights and taken as a slave."") .addNPC(PIKKUPSTIX, HeadE.SAD_MILD_LOOK_DOWN, ""I hear that he tried to lead a slaved rebellion. Which, while noble in itself, is not really the sort of thing a 5-foot, sickly, bookish druid should do."") .addNPC(PIKKUPSTIX, HeadE.SAD_MILD_LOOK_DOWN, ""Especially when unarmed and facing evil knights in full plate mail."") .addNPC(PIKKUPSTIX, HeadE.CONFUSED, ""Let's see...there was Beezeltrix and the smoke devil; we literally lost Felitrix; those trolls took the twins when they were healing soldiers on the front line..."") .addNPC(PIKKUPSTIX, HeadE.MORTIFIED, ""And the less said about Hastrix, the better!"") .addPlayer(HeadE.AMAZED, ""Wow...you really haven't had much luck with assistants."") .addNPC(PIKKUPSTIX, HeadE.SAD, ""It has been one heck of a busy week, I can tell you."") .addNPC(PIKKUPSTIX, HeadE.CONFUSED, ""Now, is there anything else you need?"") .addNext(() -> p.startConversation(new Pikkupstix(p, pikkupstix, false)))); } }); } case WolfWhistle.SAVE_BOWLOFTRIX -> addNPC(PIKKUPSTIX, HeadE.CONFUSED, ""What are you waiting for? You have to get that pouch to Scalectrix as soon as possible!"") .addOptions(new Options() { @Override public void create() { if (!player.getInventory().containsItem(GIANT_WOLPERTINGER_POUCH) && !player.getBank().containsItem(GIANT_WOLPERTINGER_POUCH, 1)) { option(""Ask where Scalectrix is"", new Dialogue() .addPlayer(HeadE.SECRETIVE, ""Mumblemumble..."") .addNPC(PIKKUPSTIX, HeadE.CONFUSED, ""What is it? I can't hear you."") .addPlayer(HeadE.SECRETIVE, ""Mumblemumble..."") .addNPC(PIKKUPSTIX, HeadE.FRUSTRATED, ""What was that? You LOST the giant wolpertinger pouch?"") .addPlayer(HeadE.SAD_MILD_LOOK_DOWN, ""Mumble?"") .addNPC(PIKKUPSTIX, HeadE.CALM_TALK, ""And you want me to get it back for you?"") .addPlayer(HeadE.SAD_MILD_LOOK_DOWN, ""Mumble..."") .addNPC(PIKKUPSTIX, HeadE.CALM_TALK, ""Now, don't lose this one!"", () -> p.getInventory().addItem(GIANT_WOLPERTINGER_POUCH))); } else { option(""Ask where Scalectrix is"", new Dialogue() .addNPC(PIKKUPSTIX, HeadE.CONFUSED, ""What? You've forgotten that she is over at the old well already?"") .addNPC(PIKKUPSTIX, HeadE.CONFUSED, ""Maybe crafting that pouch took more out of you than I epxected...I wonder if this is a symptom of melty-brain syndrome...yes, that could be it."") .addPlayer(HeadE.AMAZED, ""Melty-brain syndrome? What...why didn't you tell me I could get that?"") .addNPC(PIKKUPSTIX, HeadE.CALM_TALK, ""Well, technically creating a pouch would not cause it. Nobody knows what causes it."") .addNPC(PIKKUPSTIX, HeadE.CALM_TALK, ""You could be walking along, minding your own business, and then the next thing you know your brains are squirting out of your ears and nostrils."") .addNPC(PIKKUPSTIX, HeadE.SAD_MILD_LOOK_DOWN, ""Like what happened to poor old Soltrix..."") .addPlayer(HeadE.SCARED, ""Uh...the old well, right?"") .addNPC(PIKKUPSTIX, HeadE.CONFUSED, ""Hmm? Oh yes, Scalectrix. That's where she is. Is there anything else?"") .addPlayer(HeadE.SCARED, ""Uh, no. Not right now. If you need me I'll be delivering this pouch, and then trying not to shake my head around too much."") .addNPC(PIKKUPSTIX, HeadE.CALM_TALK, ""Good idea. If you do not have MBS then keeping your head steady until your brain congeals is the best plan."") .addNPC(PIKKUPSTIX, HeadE.CONFUSED, ""Anyways, is there anything else I can help you with?"") .addNext(() -> p.startConversation(new Pikkupstix(p, pikkupstix, false)))); } option(""You really seem to have had some problems with your assistants."", new Dialogue() .addNPC(PIKKUPSTIX, HeadE.SAD, ""You are right, it has been pretty hard since the war started."") .addPlayer(HeadE.CONFUSED, ""Well what's happened? Have the trolls been killing them, or has it all been down to accidents?"") .addNPC(PIKKUPSTIX, HeadE.CALM, ""It is a mixture of both, really. To be honest, I have always found that my assistants have had a lot of eagerness and a lot less common sense for self-preservation."") .addNPC(PIKKUPSTIX, HeadE.CONFUSED, ""Now, let me see...You already know about Stikklebrix...who else was there?"") .addNPC(PIKKUPSTIX, HeadE.CALM, ""There was poor Lunatrix, who went mad. He tried to commune with some elder spirits, and they were not happy."") .addNPC(PIKKUPSTIX, HeadE.SAD_MILD_LOOK_DOWN, ""Last I saw of him, he went running out of the door with his pants on his head..."") .addNPC(PIKKUPSTIX, HeadE.CALM, ""Then there was Ashtrix. He managed to cut his own hand off, the poor fool."") .addNPC(PIKKUPSTIX, HeadE.SAD_MILD_LOOK_DOWN, ""It would have been all right, except he then managed to wedge a hacksaw in the stump, and in his delirium wouldn't let anyone help him."") .addNPC(PIKKUPSTIX, HeadE.CALM, ""Then there was Spartrix, who was captured by the Black Knights and taken as a slave."") .addNPC(PIKKUPSTIX, HeadE.SAD_MILD_LOOK_DOWN, ""I hear that he tried to lead a slaved rebellion. Which, while noble in itself, is not really the sort of thing a 5-foot, sickly, bookish druid should do."") .addNPC(PIKKUPSTIX, HeadE.SAD_MILD_LOOK_DOWN, ""Especially when unarmed and facing evil knights in full plate mail."") .addNPC(PIKKUPSTIX, HeadE.CONFUSED, ""Let's see...there was Beezeltrix and the smoke devil; we literally lost Felitrix; those trolls took the twins when they were healing soldiers on the front line..."") .addNPC(PIKKUPSTIX, HeadE.MORTIFIED, ""And the less said about Hastrix, the better!"") .addPlayer(HeadE.AMAZED, ""Wow...you really haven't had much luck with assistants."") .addNPC(PIKKUPSTIX, HeadE.SAD, ""It has been one heck of a busy week, I can tell you."") .addNPC(PIKKUPSTIX, HeadE.CONFUSED, ""Now, is there anything else you need?"") .addNext(() -> p.startConversation(new Pikkupstix(p, pikkupstix, false)))); } }); case WolfWhistle.QUEST_COMPLETE -> addNPC(PIKKUPSTIX, HeadE.CHEERFUL_EXPOSITION, ""Well done! I heard the news! You've saved my assistants from a fate worse than death!"") .addPlayer(HeadE.CHEERFUL_EXPOSITION, ""Yes, that giant wolpertinger really made the difference."") .addPlayer(HeadE.CONFUSED, ""Say, do you have the parts needed to summon it again? I'm sure it would come in handy."") .addNPC(PIKKUPSTIX, HeadE.SAD_MILD_LOOK_DOWN, ""No, I am afraid not. The pieces you used were rare...unique in some cases."") .addNPC(PIKKUPSTIX, HeadE.HAPPY_TALKING, ""But in the end they were all used up for a good cause. And it did take a hero like you to bring it about."") .addPlayer(HeadE.SAD, ""Darn. Oh well, at least Bowloftrix is safe..."") .addPlayer(HeadE.SECRETIVE, ""...for now."") .addNPC(PIKKUPSTIX, HeadE.CONFUSED, ""What was that?"") .addPlayer(HeadE.SECRETIVE, ""Nothing."") .addNPC(PIKKUPSTIX, HeadE.CHEERFUL_EXPOSITION, ""Anyway, once they are rested, I'll be sending those two off to gather some of those highly poisonous weeds that I need for my research."") .addNPC(PIKKUPSTIX, HeadE.CHEERFUL_EXPOSITION, ""They grow in a pretty dangerous place in the wilderness. Tell me, would you like to be my assistant as well?"") .addPlayer(HeadE.TERRIFIED, ""I have to go! Look at the time! My oven is on and I need to feed the cat!"") .addNPC(PIKKUPSTIX, HeadE.CONFUSED, ""Strange...that's what most people say when I ask them that."") .addNPC(PIKKUPSTIX, HeadE.CONFUSED, ""Is there anything else I can help you with?"") .addNext(() -> p.startConversation(new Pikkupstix(p, pikkupstix, false))); default -> p.sendMessage(""Uh oh""); } create(); } public static String getNextOptionTextPikkupstix(Player p) { return switch (p.getQuestManager().getStage(Quest.WOLF_WHISTLE)) { case NOT_STARTED -> ""Do you have a quest for me?""; case WolfWhistle.PIKKUPSTIX_HELP -> ""Bowloftrix has been kidnapped by trolls!""; case WolfWhistle.FIND_SCALECTRIX, WolfWhistle.WOLPERTINGER_MATERIALS, WolfWhistle.WOLPERTINGER_CREATION, WolfWhistle.WOLPERTINGER_POUCH_CHECK, WolfWhistle.SAVE_BOWLOFTRIX, WolfWhistle.QUEST_COMPLETE -> ""I need to ask you something about the quest...""; default -> null; }; } }" "package com.rs.game.content.quests.wolfwhistle; @QuestHandler( quest = Quest.WOLF_WHISTLE, startText = ""Talk to Pikkupstix in his house in Taverley."", itemsText = ""None."", combatText = ""None."", rewardsText = ""276 Summoning XP
275 gold charms"", completedStage = 7 ) @PluginEventHandler public class WolfWhistle extends QuestOutline { // stages public static final int NOT_STARTED = 0; public static final int FIND_SCALECTRIX = 1; public static final int PIKKUPSTIX_HELP = 2; public static final int WOLPERTINGER_MATERIALS = 3; public static final int WOLPERTINGER_CREATION = 4; public static final int WOLPERTINGER_POUCH_CHECK = 5; public static final int SAVE_BOWLOFTRIX = 6; public static final int QUEST_COMPLETE = 7; // animations public static final int POUCH_INFUSION = 725; // item ids public static final int WHITE_HARE_MEAT = 23067; public static final int EMBROIDERED_POUCH = 23068; public static final int RARE_SUMMONING_ITEMS = 23069; public static final int ANCIENT_WOLF_BONE_AMULET = 23066; public static final int GIANT_WOLPERTINGER_POUCH = 23070; public static final int GOLD_CHARM = 12158; // object ids static final int CLUTTERED_DRAWERS = 28641; static final int CLUTTERED_SHELVES = 67496; static final int UNTIDY_SHELVES = 67495; static final int CROWDED_SHELVES = 67497; static final int HEAPED_BOOKS = 67494; static final int DISCARDED_BOOKS = 65849; static final int STIKKLEBRIX_BODY = 67488; // varbit 10734 public static LoginHandler handleLoginVarbit = new LoginHandler(e -> { Player p = e.getPlayer(); if (p.getQuestManager().getStage(Quest.WOLF_WHISTLE) == WolfWhistle.WOLPERTINGER_MATERIALS) { p.getVars().setVarBit(10734, 1); } }); public static ObjectClickHandler handlePikkupstixUpstairs = new ObjectClickHandler(new Object[]{CLUTTERED_DRAWERS, CLUTTERED_SHELVES, UNTIDY_SHELVES, CROWDED_SHELVES, HEAPED_BOOKS, DISCARDED_BOOKS}, e -> { Player p = e.getPlayer(); if (e.getObjectId() == CLUTTERED_DRAWERS) { if (p.getQuestManager().getStage(Quest.WOLF_WHISTLE) == WolfWhistle.WOLPERTINGER_MATERIALS) { if (!p.getInventory().containsItem(EMBROIDERED_POUCH) && !p.getBank().containsItem(EMBROIDERED_POUCH, 1)) { p.startConversation(new Dialogue() .addItem(EMBROIDERED_POUCH, ""You have found the embroidered pouch under some socks in this drawer."", () -> { p.getInventory().addItem(EMBROIDERED_POUCH); p.getQuestManager().getAttribs(Quest.WOLF_WHISTLE).setB(""EMBROIDERED_POUCH"", true); })); return; } } p.sendMessage(MessageType.GAME, ""Despite searching, you cannot find anything.""); } else { p.sendMessage(MessageType.GAME, ""Despite searching, you cannot find anything.""); } }); public static ObjectClickHandler handleStikklebrixDeadBody = new ObjectClickHandler(new Object[]{STIKKLEBRIX_BODY}, e -> { Player p = e.getPlayer(); if (!p.getInventory().containsItem(ANCIENT_WOLF_BONE_AMULET) && !p.getBank().containsItem(ANCIENT_WOLF_BONE_AMULET, 1)) { p.startConversation(new Dialogue() .addItem(ANCIENT_WOLF_BONE_AMULET, ""You take the amulet from the sad remains of Stikklebrix."", () -> { p.getInventory().addItem(ANCIENT_WOLF_BONE_AMULET); p.getQuestManager().getAttribs(Quest.WOLF_WHISTLE).setB(""ANCIENT_AMULET"", true); })); } }); public static void doWolpertingerPouchCreation(Player p, GameObject obelisk) { p.faceObject(obelisk); p.setNextAnimation(new Animation(WolfWhistle.POUCH_INFUSION)); p.startConversation(new Dialogue() .addItem(WolfWhistle.GIANT_WOLPERTINGER_POUCH, ""You craft the giant wolpertinger pouch. It thrums with barely contained power."", () -> { p.getInventory().removeAllItems(WolfWhistle.EMBROIDERED_POUCH, WolfWhistle.RARE_SUMMONING_ITEMS, WolfWhistle.WHITE_HARE_MEAT, WolfWhistle.ANCIENT_WOLF_BONE_AMULET); p.getInventory().addItem(WolfWhistle.GIANT_WOLPERTINGER_POUCH); p.getQuestManager().getAttribs(Quest.WOLF_WHISTLE).setB(""WOLPERTINGER_POUCH"", true); p.getQuestManager().setStage(Quest.WOLF_WHISTLE, WolfWhistle.WOLPERTINGER_POUCH_CHECK); }) .addPlayer(HeadE.AMAZED, ""I should check with Pikkupstix that this is how it is supposed to look."") ); } public static boolean wolfWhistleObeliskReadyToInfusePouch(Player player) { return player.getInventory().containsItem(EMBROIDERED_POUCH) && player.getInventory().containsItem(ANCIENT_WOLF_BONE_AMULET) && player.getInventory().containsItem(WHITE_HARE_MEAT) && player.getInventory().containsItem(RARE_SUMMONING_ITEMS); } @Override public List getJournalLines(Player player, int stage) { ArrayList lines = new ArrayList<>(); switch (stage) { case NOT_STARTED -> { lines.add(""I can begin this quest by talking to Pikkupstix, who lives in""); lines.add(""Taverley.""); lines.add(""""); lines.add(""~~Requirements~~""); lines.add(""None""); lines.add(""""); } case FIND_SCALECTRIX -> { lines.add(""Having spoke to Pikkupstix, I need to find Scalectrix and""); lines.add(""Bowloftrix, who are somewhere near the old dry well in west""); lines.add(""Taverley, opposite the watermill.""); lines.add(""""); } case PIKKUPSTIX_HELP -> { lines.add(""I have found Scalectrix near the old well in Taverley, and she""); lines.add(""has warned me that there is a force of trolls in the well that""); lines.add(""need to be frightened off.""); lines.add(""She has requested I speak to Pikkupstix, as he will likely have""); lines.add(""a solution to the problem.""); lines.add(""""); } case WOLPERTINGER_MATERIALS -> { lines.add(""Pikkupstix has sent me to look for some items to make a giant""); lines.add(""wolpertinger pouch. These are:""); lines.add(""An ancient wolf bone amulet, held by his assistant Stikklebrix""); lines.add(""who is somewhere near White Wolf Mountain. This is a large""); lines.add(""mountain range to the west of Taverley.""); lines.add(""Some white hare meat from the Taverley Pet Shop, which is""); lines.add(""located in the building to the south of Pikkupstix's house.""); lines.add(""He also had some other items for me. These are:""); lines.add(""A precious grey charm.""); lines.add(""A very rare blessed spirit shard.""); lines.add(""""); } case WOLPERTINGER_CREATION -> { lines.add(""I have taken all of the items I was requested to collect and""); lines.add(""brought them to Pikkupstix. He has told me to use them on the""); lines.add(""obelisk to create the pouch.""); lines.add(""""); } case WOLPERTINGER_POUCH_CHECK -> { lines.add(""I have created the giant wolpertinger pouch. I should take it""); lines.add(""to Pikkupstix to make sure it worked correctly.""); lines.add(""""); } case SAVE_BOWLOFTRIX -> { lines.add(""Pikkupstix has told me that the pouch is working correctly. He""); lines.add(""has told me to take it to Scalectrix by the the old well.""); // typo intentional lines.add(""""); } case QUEST_COMPLETE -> { lines.add(""I have saved the druids in Taverley from a surprise attack by""); lines.add(""the trolls.""); lines.add(""""); lines.add(""""); lines.add(""QUEST COMPLETE!""); } default -> lines.add(""Invalid quest stage. Report this to an administrator.""); } return lines; } @Override public void complete(Player player) { player.getInventory().addItem(GOLD_CHARM, 275); player.getInventory().removeAllItems(GIANT_WOLPERTINGER_POUCH); player.getSkills().addXp(Skills.SUMMONING, 276); sendQuestCompleteInterface(player, GIANT_WOLPERTINGER_POUCH); } }" "package com.rs.game.content.quests.wolfwhistle; public class WolfWhistleWellCutscene extends Cutscene { private final static int WOLF_MEAT = 15058; private final static int WOLF_BONES = 15059; private final static int WOLF_MEAT_SCARED = 15060; private final static int WOLF_BONES_SCARED = 15061; private final static int TROLL_FLINTER = 15062; private final static int TROLL_BONE = 15063; private final static int TROLL_CLUB = 15066; private final static int TROLL_BONE_SHIELD = 15067; private final static int TROLL_BONE_SCARED = 15068; private final static int TROLL_SHIELD_BONE_SCARED = 15072; private final static int BOWLOFTRIX_CAULDRON = 67500; private final static int GIANT_WOLPERTINGER = 6990; private final static int SCALECTRIX = 15055; // spot anims private final static int SUMMONING_SPAWN = 1315; private final static int ONE = 2860; private final static int WOLPERTINGER_FEAR_FLASH = 2820; // animations private final static int WOLPERTINGER_FEAR_CAST = 15929; private final static int WOLPERTINGER_DESPAWN = 15930; private final static int WOLPERTINGER_SPAWN = 15932; private final static int TROLL_COWER = 15921; // 1522 private final String[] TROLL_KEYS = new String[]{""t0"", ""t1"", ""t2"", ""t3"", ""t4"", ""t5"", ""t6"", ""t7"", ""t8"", ""t9"", ""t10"", ""t11"", ""t12""}; private final ArrayList whiners = new ArrayList<>(); private boolean playing = false; @Override public void construct(Player player) { playing = true; fadeInBG(4); hideMinimap(); dynamicRegion(player.getTile(), 178, 554, 4, 4); spawnObj(BOWLOFTRIX_CAULDRON, 0, 14, 23, 0); npcCreate(""giantwolpertinger"", GIANT_WOLPERTINGER, 14, 0, 0); npcCreate(""scalectrix"", SCALECTRIX, 13, 8, 0); npcCreate(""wolfmeat"", WOLF_MEAT, 15, 21, 0); npcCreate(""wolfbones"", WOLF_BONES, 13, 21, 0); npcCreate(""trollflinter"", TROLL_FLINTER, 11, 23, 0); npcCreate(""t0"", TROLL_BONE, 16, 18, 0); // 3 with just bone frontline runner npcCreate(""t1"", TROLL_BONE, 10, 27, 0); npcCreate(""t2"", TROLL_BONE, 15, 25, 0); npcCreate(""t3"", TROLL_BONE_SHIELD, 11, 17, 0); // 2 with bone + shield frontline runner npcCreate(""t4"", TROLL_BONE_SHIELD, 11, 21, 0); // runner npcCreate(""t5"", TROLL_CLUB, 16, 17, 0); // 8 with club frontline runner npcCreate(""t6"", TROLL_CLUB, 10, 23, 0); npcCreate(""t7"", TROLL_CLUB, 11, 25, 0); npcCreate(""t8"", TROLL_CLUB, 13, 25, 0); npcCreate(""t9"", TROLL_CLUB, 18, 22, 0); npcCreate(""t10"", TROLL_CLUB, 15, 28, 0); npcCreate(""t11"", TROLL_CLUB, 13, 28, 0); npcCreate(""t12"", TROLL_CLUB, 9, 19, 0); delay(1); playerFaceDir(Direction.NORTH); playerMove(14, 8, 0, Entity.MoveType.TELE); npcFaceDir(""scalectrix"", Direction.NORTH); npcFaceDir(""trollflinter"", Direction.EAST); npcFaceNPC(""giantwolpertinger"", ""wolfbones""); camPosReset(); camPos(14, 18, 2000); camLook(14, 8, 0); delay(1); fadeOutBG(4); playerMove(14, 14, Entity.MoveType.WALK); npcMove(""scalectrix"", 14, 8, Entity.MoveType.WALK); npcMove(""scalectrix"", 14, 13, Entity.MoveType.WALK); npcMove(""scalectrix"", 13, 13, Entity.MoveType.WALK); npcMove(""scalectrix"", 13, 14, Entity.MoveType.WALK); camPos(14, 30, 2000, 0, 20, 2); delay(5); dialogue(new Dialogue() .addNPC(SCALECTRIX, HeadE.CALM_TALK, ""This is it, get ready!"") , true); camPos(18, 13, 2000); camLook(14, 23, 0); dialogue(new Dialogue() .addNPC(WOLF_MEAT, HeadE.T_HAPPY_TALK, ""It's da girly dat had da woof! We gots more druid meat meat 'fore da big fight, lads!"") , true); camPos(16, 21, 2000); camLook(14, 14, 0); dialogue(new Dialogue() .addPlayer(HeadE.ANGRY, ""You want to eat something? Chew on this, you filthy animals!"") .addNPC(SCALECTRIX, HeadE.ANGRY, ""Yes! Feel the true power of the Druids!"") , true); camPos(16, 25, 2000); camLook(13, 14, 0); delay(1); playerSpotAnim(new SpotAnim(1300)); playerAnim(new Animation(7660)); npcSpotAnim(""scalectrix"", new SpotAnim(1300)); npcAnim(""scalectrix"", new Animation(7660)); npcMove(""giantwolpertinger"", 13, 16, Entity.MoveType.TELE); npcSpotAnim(""giantwolpertinger"", new SpotAnim(SUMMONING_SPAWN)); npcAnim(""giantwolpertinger"", new Animation(WOLPERTINGER_SPAWN)); delay(5); camPos(18, 13, 2000); camLook(14, 23, 0); dialogue(new Dialogue() .addNPC(WOLF_BONES, HeadE.T_LAUGH, ""Har har har! A big bunny! Dat's not scary at all!"") , true); camPos(16, 25, 2000); camLook(13, 14, 0); delay(1); npcAnim(""giantwolpertinger"", new Animation(WOLPERTINGER_FEAR_CAST)); npcSpotAnim(""giantwolpertinger"", new SpotAnim(WOLPERTINGER_FEAR_FLASH)); action(() -> { NPC t0 = getNPC(""t0""); NPC t3 = getNPC(""t3""); NPC t5 = getNPC(""t5""); NPC wolfbones = getNPC(""wolfbones""); NPC wolfmeat = getNPC(""wolfmeat""); t0.forceTalk(""Gotta run!""); t3.forceTalk(""Me no like!""); t5.forceTalk(""It too huge!""); WorldTasks.scheduleTimer(tick -> { World.sendSpotAnim(Tile.of(wolfbones.getX(), wolfbones.getY(), wolfbones.getPlane()), new SpotAnim(ONE)); World.sendSpotAnim(Tile.of(wolfmeat.getX(), wolfmeat.getY(), wolfmeat.getPlane()), new SpotAnim(ONE)); World.sendSpotAnim(Tile.of(t0.getX(), t0.getY(), t0.getPlane()), new SpotAnim(ONE)); World.sendSpotAnim(Tile.of(t3.getX(), t3.getY(), t3.getPlane()), new SpotAnim(ONE)); World.sendSpotAnim(Tile.of(t5.getX(), t5.getY(), t5.getPlane()), new SpotAnim(ONE)); return playing; }); }); delay(2); npcMove(""t4"", 8, 20, Entity.MoveType.WALK); // maybe run { Animation cower = new Animation(TROLL_COWER); for (String key : TROLL_KEYS) { npcAnim(key, cower); } } delay(1); for (int i = 1;i < 13;i++) npcTransform(""t""+i, i == 3 || i == 4 ? TROLL_SHIELD_BONE_SCARED : TROLL_BONE_SCARED); action(() -> { for (int i = 1;i < 13;i++) whiners.add(getNPC(""t""+i)); Random random = new Random(); WorldTasks.scheduleTimer(0, 4, tick -> { int[] range = new int[]{-1, -1, -1}; int iter = 0; while (iter != 3) { int rand = random.nextInt(0, whiners.size()); if (rand == range[0] || rand == range[1] || rand == range[2]) continue; range[iter++] = rand; } whiners.get(range[0]).forceTalk(generateRandomWhine()); whiners.get(range[1]).forceTalk(generateRandomWhine()); whiners.get(range[2]).forceTalk(generateRandomWhine()); return playing; }); }); camPos(18, 13, 2000); camLook(14, 23, 0); dialogue(new Dialogue() .addNPC(WOLF_MEAT, HeadE.T_SCARED, ""It scaring me! Why it scaring me?"") .addNPC(WOLF_BONES, HeadE.T_SCARED, ""Leg it! It going to eat us all!"") .addNPC(WOLF_MEAT, HeadE.T_SCARED, ""It messing with Wolf Meat's brains! It in my head! Make it stop!"") .addNPC(WOLF_BONES, HeadE.T_SCARED, ""Wolf Bones need his mummy!"") , true); camPos(14, 18, 2000); camLook(14, 8, 0); camPos(16, 25, 2000); camLook(13, 14, 0); npcTransform(""wolfbones"", WOLF_BONES_SCARED); npcTransform(""wolfmeat"", WOLF_MEAT_SCARED); npcTalk(""wolfbones"", ""I gettin' out of 'ere!""); npcTalk(""wolfmeat"", ""Run! Run fer it!""); dialogue(new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Quick! Let's get Bowloftrix, before they regroup."") , true); npcMove(""wolfbones"", 12, 21, Entity.MoveType.WALK); npcMove(""wolfmeat"", 13, 21, Entity.MoveType.WALK); dialogue(new Dialogue() .addNPC(SCALECTRIX, HeadE.HAPPY_TALKING, ""Yes, the wolpertinger won't last long."") .addNPC(SCALECTRIX, HeadE.AMAZED_MILD, ""In fact, there it goes..."") , true); npcAnim(""giantwolpertinger"", new Animation(WOLPERTINGER_DESPAWN)); delay(8); npcDestroy(""giantwolpertinger""); dialogue(new Dialogue() .addPlayer(HeadE.CALM_TALK, ""Well let's get Bowloftrix and get out."") .addNPC(SCALECTRIX, HeadE.CALM, ""Oh dear...I hope he's all right."") , true); playerMove(14, 19, Entity.MoveType.RUN); npcMove(""scalectrix"", 13, 19, Entity.MoveType.RUN); fadeInBG(0); delay(4); fadeOutBG(0); action(() -> { player.getQuestManager().completeQuest(Quest.WOLF_WHISTLE); playing = false; }); } private String generateRandomWhine() { Random random = new Random(); return switch (random.nextInt(0, 10)) { case 0 -> ""It makin' faces at me!""; case 1 -> ""It bigger den me!""; case 2 -> ""I didn't want to come 'ere anyway!""; case 3 -> ""Get me out of 'ere!""; case 4 -> ""I is scared!""; case 5 -> ""It makin' me brains hurt!""; case 6 -> ""I dun't like it!""; case 7 -> ""Boss! Make it stop!""; case 8 -> ""I dun't wanna!""; case 9 -> ""Bunnies! Big bunnies!""; default -> """"; }; } }" "package com.rs.game.content.randomevents; public class CapnArnav { //coords 1626 5163 0 }" "package com.rs.game.content.randomevents; public class Classroom { //coords 1886 5025 }" "package com.rs.game.content.randomevents @ServerStartupEvent fun handleDrunkenDwarf() { onNpcClick(NPC_ID) { event -> val npc = event.npc as? RandomEventNPC npc?.let { handleNpcClick(event.player, it) } ?: event.player.sendMessage(""Something went wrong..."") } } private fun handleNpcClick(player: Player, npc: RandomEventNPC) { if (npc.owner != player) { player.startConversation(Conversation(Dialogue().addNPC(npc, HeadE.CALM_TALK, ""You're not my matey!""))) } else { if (!npc.claimed) { if (player.inCombat()) { giveItemsAndSetDuration(true, npc, player) return } player.startConversation(Conversation(player) .addNPC(npc, HeadE.HAPPY_TALKING, ""I 'new it were you matey! 'Ere, have some ob the good stuff!"") .addNext { giveItemsAndSetDuration(false, npc, player) } ) } else { player.sendMessage(""Too late!"") } } } private fun giveItemsAndSetDuration(forceTalk: Boolean, npc: RandomEventNPC, player: Player) { if (forceTalk) npc.forceTalk(""'Ere, have some ob the good stuff!"") player.inventory.addItemDrop(1917, 1) player.inventory.addItemDrop(1971, 1) npc.duration = 1 npc.claimed = true } class DrunkenDwarf(owner: Player, tile: Tile) : RandomEventNPC(owner, NPC_ID, tile, DURATION, 2297, false) { companion object { const val NPC_ID = 956 const val ATTACK_DELAY_TICKS = 50 val DURATION = Ticks.fromMinutes(10) val PHRASES = arrayOf( ""'Ere, matey, 'ave some 'o the good stuff."", ""Hey, @player!"", ""Oi, are you der @player!"", ""Dunt ignore your mate, @player!"", ""I've got something for you, @player!"", ""Aww comeon, talk to ickle me @player!"" ) } private var attackDelay = 0 private var phraseIndex = 0 init { run = false isAutoDespawnAtDistance = false setNextFaceEntity(owner) forceTalk(""'Ello der ${owner.displayName}! *hic*"") } override fun processNPC() { val timeElapsed = DURATION - duration super.processNPC() if (duration == 3) { forceTalk(""Aw me is all alone..."") } if (phraseIndex < PHRASES.size && timeElapsed >= 50 && timeElapsed % 50 == 0 && !claimed) { forceTalk(getNextPhrase(owner)) World.soundEffect(tile, 2297) } else { if (timeElapsed >= 350 && !claimed) { initiateAttack(this) } } } private fun getNextPhrase(player: Player): String { val phrase = PHRASES[phraseIndex].replace(""@player"", player.displayName) phraseIndex++ return phrase } private fun initiateAttack(npc: RandomEventNPC) { if (attackDelay <= 0) { if (!owner.inCombat()) { forceTalk(""I hates you ${owner.displayName}!"") if (npc.lineOfSightTo(owner, false)) { owner.soundEffect(npc.combatDefinitions.attackSound, false) npc.anim(npc.combatDefinitions.attackEmote) World.sendProjectile(npc, owner, npc.combatDefinitions.attackProjectile, 12, 32, 0, 0.7, 15, 0) owner.anim(424) owner.applyHit(Hit(npc, Utils.random(200), Hit.HitLook.RANGE_DAMAGE)) attackDelay = ATTACK_DELAY_TICKS } else { finish() } } else { giveItemsAndSetDuration(true, npc, owner) } } if (attackDelay > 0) { if (owner.interfaceManager.containsChatBoxInter() || owner.interfaceManager.containsScreenInter()) return attackDelay-- } } }" "package com.rs.game.content.randomevents @ServerStartupEvent fun handleGenieRandomEvent() { onNpcClick(Genie.NPC_ID) { event -> val npc = event.npc as? Genie ?: return@onNpcClick if (npc.ticks >= Genie.DURATION) return@onNpcClick if (npc.owner != event.player) { event.player.startConversation { npc(npc, HeadE.CALM_TALK, ""This wish is for ${npc.owner.displayName}, not you!"") } return@onNpcClick } handleGenieInteraction(event, npc) } } private fun handleGenieInteraction(e: NPCClickEvent, npc: Genie) { if (e.player.inCombat()) { handleCombatInteraction(e, npc) } else { handleNormalInteraction(e, npc) } } private fun handleCombatInteraction(e: NPCClickEvent, npc: Genie) { val player = e.player if (!npc.claimed) { player.sendMessage(""The genie gives you a lamp!"") player.inventory.addItemDrop(XP_LAMP_ITEM_ID, 1) if (!player.inventory.hasFreeSlots()) { player.sendMessage(""The lamp has been placed on the ground."") } npc.forceTalk(""Hope that satisfies you!"") npc.claimed = true npc.tickCounter = 191 } else { player.sendMessage(""Too late!"") } } fun handleNormalInteraction(e: NPCClickEvent, npc: Genie) { if (!npc.claimed) { e.player.startConversation { npc(Genie.NPC_ID, HeadE.HAPPY_TALKING, ""Ah, so you are there master. I'm so glad you summoned me. Please take this lamp and make your wish!"") exec { e.player.inventory.addItemDrop(XP_LAMP_ITEM_ID, 1) if (!e.player.inventory.hasFreeSlots()) e.player.sendMessage(""The lamp has been placed on the ground."") npc.claimed = true npc.tickCounter = 193 } } } else { e.player.sendMessage(""Too late!"") } } class Genie(owner: Player, tile: Tile) : RandomEventNPC(owner, NPC_ID, tile, DURATION, null, false) { companion object { const val NPC_ID = 3022 const val XP_LAMP_ITEM_ID = 2528 val DURATION = Ticks.fromMinutes(10) } var tickCounter = 0 init { run = false forceTalk(""Hello, Master ${owner.displayName}!"") setNextFaceEntity(owner) isAutoDespawnAtDistance = false } override fun processNPC() { super.processNPC() entityFollow(owner, false, 0) if (!claimed && (owner.interfaceManager.containsChatBoxInter() || owner.interfaceManager.containsScreenInter())) return tickCounter++ handleGenieActions() } private fun handleGenieActions() { when (tickCounter) { in 30..150 step 30 -> continueGenieDialogue() 189 -> forceTalk(""So rude!"") 190 -> handlePlayerIgnore() 194 -> if (claimed) anim(863) 197 -> finish() } } private fun continueGenieDialogue() { anim(863) forceTalk(getGenieDialogue()) } private fun getGenieDialogue(): String { val dialogues = arrayOf(""A wish for "", ""I came from the desert, you know, "", ""Not just anyone gets a wish, "", ""Young "" + (if (owner.appearance.isMale) ""Sir"" else ""Madam"") + "", these things are quite rare!"", ""Last chance, "") val index = tickCounter / 30 - 1 return when { index < dialogues.size - 2 -> ""${dialogues[index]}${owner.displayName}."" index == dialogues.size - 2 -> dialogues[index] else -> ""${dialogues[index]}${owner.displayName}."" } } private fun handlePlayerIgnore() { if (!owner.inCombat()) { anim(3045) owner.spotAnim(80, 5, 60) owner.lock() owner.anim(836) owner.stopAll() owner.fadeScreen { spotAnim(1605) owner.tele(RandomEvents.getRandomTile()) owner.sendMessage(""The genie knocks you out and you wake up somewhere... different."") owner.anim(-1) owner.schedule { wait(2) owner.spotAnim(-1) owner.unlock() } } } } }" "package com.rs.game.content.randomevents abstract class RandomEventNPC( owner: Player, id: Int, tile: Tile, var duration: Int = Ticks.fromMinutes(10), private var startSoundId: Int? = DEFAULT_SOUND, hideFromOtherPlayers: Boolean ) : OwnedNPC(owner, id, tile, hideFromOtherPlayers) { companion object { const val DEFAULT_START_GFX = 86 const val DEFAULT_SOUND = 1930 const val DEFAULT_END_GFX = 1605 } var claimed = false var ticks = 0 init { playSoundAndAnim(startSoundId, DEFAULT_START_GFX) this.run = false this.setNextFaceEntity(owner) this.isAutoDespawnAtDistance = false } override fun processNPC() { if (owner.isDead || !withinDistance(owner, 16)) { finish() return } if (!claimed && (owner.interfaceManager.containsChatBoxInter() || owner.interfaceManager.containsScreenInter())) return ticks++ entityFollow(owner, false, 0) duration-- if (duration == -1) finish() super.processNPC() } override fun finish() { reset() playSoundAndAnim(DEFAULT_SOUND, DEFAULT_END_GFX) owner.interfaceManager.closeChatBoxInterface() super.finish() } private fun playSoundAndAnim(soundId: Int?, spotAnimId: Int?) { val actualSoundId = soundId ?: DEFAULT_SOUND val actualSpotAnimId = spotAnimId ?: DEFAULT_START_GFX owner.soundEffect(owner, actualSoundId, false) World.sendSpotAnim(tile, actualSpotAnimId) } }" "package com.rs.game.content.randomevents object RandomEvents { private val RANDOM_TILES = ArrayList().apply { add(Tile(2966, 3393, 0)) // North entrance of Falador add(Tile(3007, 3322, 0)) // South entrance of Falador add(Tile(3011, 3465, 0)) // Ice Mountain add(Tile(3253, 3421, 1)) // Varrock East Bank add(Tile(3295, 3279, 0)) // Near the Al Kharid Mine add(Tile(3214, 3246, 0)) // Near the Lumbridge general store add(Tile(3211, 9622, 0)) // Lumbridge castle basement add(Tile(2636, 3373, 0)) // North of Ardougne add(Tile(2995, 3341, 3)) // White Knights' Castle add(Tile(2845, 3164, 0)) // Karamja Volcano add(Tile(3110, 3161, 2)) // Wizard's Tower add(Tile(3199, 3217, 2)) // Behind Lumbridge Castle add(Tile(3256, 3485, 1)) // 1st floor of Varrock Church } @JvmStatic fun getRandomTile(): Tile { return RANDOM_TILES[Utils.random(RANDOM_TILES.size)] } @JvmStatic fun attemptSpawnRandom(player: Player) { attemptSpawnRandom(player, false) } @JvmStatic fun attemptSpawnRandom(player: Player, force: Boolean) { if ((!force && (World.getServerTicks() - player.nsv.getL(""lastRandom"") < 3000)) || (player.controllerManager.controller != null && player.controllerManager.controller !is DamonheimController)) { return } val spawnTile = player.getNearestTeleTile(1) player.nsv.setL(""lastRandom"", World.getServerTicks()) val random = Utils.random(0, 100) val genieChance = 5 val drunkenDwarfChance = 45 val sandwichLadyChance = 50 when { random < genieChance -> Genie(player, spawnTile) random < genieChance + drunkenDwarfChance -> DrunkenDwarf(player, spawnTile) random < genieChance + drunkenDwarfChance + sandwichLadyChance -> SandwichLady(player, spawnTile) } } }" "package com.rs.game.content.randomevents @ServerStartupEvent fun handleSandwichLady() { onNpcClick(SandwichLady.NPC_ID) { event -> val npc = event.npc as? SandwichLady ?: return@onNpcClick if (npc.ticks >= SandwichLady.DURATION) return@onNpcClick if (npc.owner != event.player) { event.player.startConversation( Conversation( Dialogue() .addNPC(npc, HeadE.CALM_TALK, ""This is for ${npc.owner.displayName}, not you!"") ) ) return@onNpcClick } if (event.player.inCombat()) { event.player.sendMessage(""The sandwich lady gives you a ${npc.selectedSandwich.description.lowercase(Locale.getDefault())}!"") event.player.inventory.addItemDrop(npc.selectedSandwich.itemId, 1) npc.forceTalk(""Hope that fills you up!"") npc.ticks = SandwichLady.DURATION + 4 return@onNpcClick } event.player.startConversation( Conversation(event.player) .addNPC( npc, HeadE.HAPPY_TALKING, ""You look hungry to me. I tell you what - have a ${npc.selectedSandwich.description.lowercase(Locale.getDefault())} on me."" ) .addNext { event.player.tempAttribs.setO(""sandwichLady"", npc) event.player.packets.setIFText(297, 48, ""Have a ${npc.selectedSandwich.description.lowercase(Locale.getDefault())} for free!"") event.player.interfaceManager.sendInterface(297) } ) } onButtonClick(297) { e -> if (e.componentId in 10..22) { val lady = e.player.tempAttribs.getO(""sandwichLady"") e.player.closeInterfaces() if (lady == null) { e.player.sendMessage(""An error has occurred."") return@onButtonClick } if (e.componentId == lady.selectedSandwich.componentId) { e.player.sendMessage(""The sandwich lady gives you a ${lady.selectedSandwich.description.lowercase(Locale.getDefault())}!"") e.player.inventory.addItemDrop(lady.selectedSandwich.itemId, 1) lady.forceTalk(""Hope that fills you up!"") lady.ticks = SandwichLady.DURATION + 4 } else { e.player.sendMessage(""The sandwich lady knocks you out and you wake up somewhere... different."") lady.forceTalk(""Hey, I didn't say you could have that!"") lady.ticks = SandwichLady.DURATION - 1 } lady.claimed = true } } } class SandwichLady(owner: Player, tile: Tile) : RandomEventNPC(owner, NPC_ID, tile, DURATION, null, false) { companion object { const val NPC_ID = 8629 val DURATION = Ticks.fromMinutes(10) } private val sandwichOptions = listOf( SandwichOption(10, ""Baguette"", 6961), SandwichOption(12, ""Triangle sandwich"", 6962), SandwichOption(14, ""Square sandwich"", 6965), SandwichOption(16, ""Roll"", 6963), SandwichOption(18, ""Meat pie"", 2327), SandwichOption(20, ""Doughnut"", 14665), SandwichOption(22, ""Chocolate bar"", 1973) ) var selectedSandwich = sandwichOptions[Utils.random(sandwichOptions.size)] init { run = true forceTalk(""Sandwich delivery for ${owner.displayName}!"") setNextFaceEntity(owner) isAutoDespawnAtDistance = false } override fun processNPC() { super.processNPC() if (!claimed && (owner.interfaceManager.containsChatBoxInter() || owner.interfaceManager.containsScreenInter())) return when { ticks == DURATION - 3 -> forceTalk(""Take that, ${owner.displayName}!"") ticks == DURATION - 2-> { anim(3045) owner.spotAnim(80, 5, 60) owner.lock() owner.anim(836) owner.stopAll() owner.fadeScreen { owner.move(RandomEvents.getRandomTile()) owner.anim(-1) owner.schedule { wait(2) owner.spotAnim(-1) owner.unlock() } } } ticks == DURATION + 5 -> finish() ticks % 30 == 0 -> forceTalk(randomQuote(owner)) } } private fun randomQuote(player: Player): String = when (Utils.randomInclusive(0, 4)) { 0 -> ""All types of sandwiches, ${player.displayName}."" 1 -> ""Come on ${player.displayName}, I made these specifically!!"" 2 -> ""You better start showing some manners young ${if (player.appearance.isMale) ""man"" else ""lady""}!!"" else -> ""You think I made these just for fun?!!?"" } } data class SandwichOption(val componentId: Int, val description: String, val itemId: Int)" "package com.rs.game.content.skills.agility; @PluginEventHandler public class Agility { static class GunnjornD extends Conversation { public GunnjornD(Player player) { super(player); addPlayer(HeadE.CONFUSED, ""Can I get any rewards?""); if (player.getCounterValue(""Barbarian advanced laps"") >= 250) { addNPC(607, HeadE.HAPPY_TALKING, ""As promised, I'll give you an item you may find useful: an Agile top. You'll find yourself lighter than usual while wearing it.""); addNPC(607, HeadE.HAPPY_TALKING, ""We barbarians are tough folks, as you know, so it'll even keep you safe if you get drawn into combat."", () -> player.getInventory().addItem(14936, 1)); } else addNPC(607, HeadE.HAPPY_TALKING, ""Of course! Once you've completed 250 laps of the advanced course, I have something in mind. You've completed "" + player.getCounterValue(""Barbarian advanced laps"") + "" laps so far.""); create(); } } public static NPCClickHandler handleGunnjorn = new NPCClickHandler(new Object[] { 607 }, e -> e.getPlayer().startConversation(new GunnjornD(e.getPlayer()))); static class GnomeTrainerD extends Conversation { public GnomeTrainerD(Player player) { super(player); addPlayer(HeadE.CONFUSED, ""Can I get any rewards?""); if (player.getCounterValue(""Gnome advanced laps"") >= 250) { addNPC(162, HeadE.HAPPY_TALKING, ""Well, it looks like you've completed our challenge!""); addNPC(162, HeadE.HAPPY_TALKING, ""Take this as a reward: an Agile leg. You'll find yourself much lighter than usual while wearing them.""); addNPC(162, HeadE.HAPPY_TALKING, ""They are made from the toughest material we gnomes could find, so it might even protect you in combat."", () -> player.getInventory().addItem(14938, 1)); addNPC(162, HeadE.HAPPY_TALKING, ""There you go. Enjoy!""); } else addNPC(162, HeadE.HAPPY_TALKING, ""Well, you've still got work to do. Your lap count is "" + player.getCounterValue(""Gnome advanced laps"") + "". It's 250 successful laps for the reward!""); create(); } } public static NPCClickHandler handleGnomeTrainer = new NPCClickHandler(new Object[] { 162 }, e -> e.getPlayer().startConversation(new GnomeTrainerD(e.getPlayer()))); public static boolean hasLevel(Player player, int level) { if (player.getSkills().getLevel(Constants.AGILITY) < level) { player.sendMessage(""You need an agility level of "" + level + "" to use this obstacle."", true); return false; } return true; } public static void swingOnRopeSwing(final Player player, final Tile startTile, final Tile endTile, final GameObject object, final double xp) { player.walkToAndExecute(startTile, () -> { player.faceObject(object); player.setNextAnimation(new Animation(751)); World.sendObjectAnimation(object, new Animation(497)); player.forceMove(endTile, 30, 90, () -> { player.sendMessage(""You skillfully swing across the rope."", true); player.getSkills().addXp(Constants.AGILITY, xp); }); }); } public static void handleObstacle(final Player player, int animationId, int delay, final Tile toTile, final double xp) { player.lock(); WorldTasks.schedule(1, () -> player.setNextAnimation(new Animation(animationId))); WorldTasks.schedule(delay+1, () -> { player.unlockNextTick(); player.tele(toTile); player.setNextAnimation(new Animation(-1)); player.getSkills().addXp(Constants.AGILITY, xp); }); } public static void crossLedge(final Player player, Tile startTile, final Tile endTile, final double xp, final boolean left) { player.lock(2); player.walkToAndExecute(startTile, () -> { WorldTasks.schedule(0, () -> player.faceTile(endTile)); WorldTasks.schedule(1, () -> { player.anim(left ? 752 : 753); player.setBas(left ? 156 : 157); }); WorldTasks.schedule(2, () -> walkToAgility(player, left ? 156 : 157, Direction.forDelta(endTile.getX()-startTile.getX(), endTile.getY()-startTile.getY()), Utils.getDistanceI(startTile, endTile), Utils.getDistanceI(startTile, endTile), xp, left ? 758 : 759)); }); } public static void crossMonkeybars(final Player player, Tile startTile, final Tile endTile, final double xp) { player.lock(5); player.walkToAndExecute(startTile, () -> { player.getTasks().schedule(0, () -> player.faceTile(endTile)); player.getTasks().schedule(1, () -> { player.anim(742); player.setBas(2405); }); player.getTasks().schedule(2, () -> walkToAgility(player, 2405, Direction.forDelta(endTile.getX()-startTile.getX(), endTile.getY()-startTile.getY()), Utils.getDistanceI(startTile, endTile), Utils.getDistanceI(startTile, endTile), xp, 743)); }); } public static void walkToAgility(final Player player, final int renderEmote, final Direction direction, final int distance, final int delay, final int stopAnim) { walkToAgility(player, renderEmote, direction, distance, delay, 0.0, stopAnim); } public static void walkToAgility(final Player player, final int renderEmote, final Direction direction, final int distance, final int delay) { walkToAgility(player, renderEmote, direction, distance, delay, 0.0, -1); } public static void walkToAgility(final Player player, final int renderEmote, final Direction direction, final int distance, final int delay, final double xp) { walkToAgility(player, renderEmote, direction, distance, delay, xp, -1); } public static void walkToAgility(final Player player, final int renderEmote, final Direction direction, final int distance, final int delay, final double xp, final int stopAnim) { if (direction != player.getDirection()) return; player.lock(); boolean running = player.getRun(); player.setRunHidden(false); WorldTasks.schedule(1, () -> { player.setBas(renderEmote); player.addWalkSteps(player.transform(direction.dx *distance, direction.dy *distance), distance,false); }); WorldTasks.schedule(delay+1, () -> { if (xp > 0) player.getSkills().addXp(Constants.AGILITY, xp); if (stopAnim != -1) player.anim(stopAnim); player.setBas(-1); player.unlockNextTick(); player.setRunHidden(running); }); } }" "package com.rs.game.content.skills.agility; public class ApeAtollAgility { public static void ClimbDownTropicalTree(final Player player, final GameObject object) { if (!Agility.hasLevel(player, 48)) return; if (player.getEquipment().getWeaponId() != 4024) { player.getPackets().sendGameMessage(""You need to transform into a ninja monkey to use the ape atoll courses.""); return; } player.forceMove(Tile.of(2769, 2746, 1), 30, 7*30, () -> { player.getSkills().addXp(Constants.AGILITY, 55); player.getAppearance().setBAS(-1); }); } public static void ClimbDownVine(final Player player, GameObject object) { if (!Agility.hasLevel(player, 48)) return; if (player.getEquipment().getWeaponId() != 4024) { player.getPackets().sendGameMessage(""You need to transform into a ninja monkey to use the ape atoll courses.""); return; } player.lock(3); WorldTasks.schedule(1, () -> { player.setNextAnimation(new Animation(1381)); player.tele(Tile.of(player.getX(), player.getY(), 0)); player.getSkills().addXp(Constants.AGILITY, 36); }); } public static void ClimbUpSkullSlope(final Player player, final GameObject object) { if (!Agility.hasLevel(player, 48)) return; if (player.getEquipment().getWeaponId() != 4024) { player.getPackets().sendGameMessage(""You need to transform into a ninja monkey to use the ape atoll courses.""); return; } player.forceMove(Tile.of(2743, 2741, 0), 10, 3*30, () -> { player.getSkills().addXp(Constants.AGILITY, 45); player.getAppearance().setBAS(-1); }); } public static void ClimbUpTropicalTree(final Player player, GameObject object) { if (!Agility.hasLevel(player, 48)) return; if (player.getEquipment().getWeaponId() != 4024) { player.getPackets().sendGameMessage(""You need to transform into a ninja monkey to use the ape atoll courses.""); return; } player.lock(3); WorldTasks.schedule(1, () -> { player.setNextAnimation(new Animation(1382)); player.tele(Tile.of(2752, 2742, 2)); player.getSkills().addXp(Constants.AGILITY, 25); }); } public static void crossMonkeyBars(final Player player, final GameObject object) { if (!Agility.hasLevel(player, 48)) return; if (player.getEquipment().getWeaponId() != 4024) { player.getPackets().sendGameMessage(""You need to transform into a ninja monkey to use the ape atoll courses.""); return; } player.lock(4); player.getAppearance().setBAS(744); player.forceMove(Tile.of(2747, 2741, 2), 10, 4*30, () -> { player.tele(Tile.of(2747, 2741, 0)); player.getSkills().addXp(Constants.AGILITY, 35); player.getAppearance().setBAS(-1); }); } public static void JumpToSteppingStone(final Player player, GameObject object) { if (!Agility.hasLevel(player, 48)) return; if (player.getEquipment().getWeaponId() != 4024) { player.getPackets().sendGameMessage(""You need to transform into a ninja monkey to use the ape atoll courses.""); return; } player.lock(3); final Tile toTile = Tile.of(object.getX(), object.getY(), object.getPlane()); final Tile toTile2 = Tile.of(player.getX() == 2755 ? 2753 : 2755, 2742, object.getPlane()); final Tile WaterTile = Tile.of(2756, 2746, object.getPlane()); final Tile Land = Tile.of(2757, 2746, object.getPlane()); WorldTasks.schedule(new Task() { @Override public void run() { player.setNextAnimation(new Animation(1381)); player.tele(toTile); WorldTasks.schedule(new Task() { @Override public void run() { if (Utils.random(5) == 0) { player.setNextAnimation(new Animation(1381)); player.applyHit(new Hit(player, Utils.random(200), HitLook.TRUE_DAMAGE)); player.getAppearance().setBAS(741); player.forceMove(WaterTile, 10, 90, () -> { player.getAppearance().setBAS(-1); player.tele(Land); }); stop(); } else { player.setNextAnimation(new Animation(1381)); player.tele(toTile2); player.getSkills().addXp(Constants.AGILITY, 15); stop(); } } }, 1); stop(); } }, 1); } public static void swingRope(final Player player, GameObject object) { if (!Agility.hasLevel(player, 48) || (player.getX() == 2756)) return; if (player.getEquipment().getWeaponId() != 4024) { player.getPackets().sendGameMessage(""You need to be a ninja monkey to be able to do this agility.""); return; } player.lock(4); player.setNextAnimation(new Animation(1392)); World.sendObjectAnimation(object, new Animation(497)); player.forceMove(Tile.of(2756, 2731, object.getPlane()), 20, 90, () -> player.getSkills().addXp(Constants.AGILITY, 22)); player.getPackets().sendGameMessage(""You skilfully swing across."", true); } }" "package com.rs.game.content.skills.agility @ServerStartupEvent fun mapBarbarianOutpostAgility() { fun removeStage(player: Player) { player.tempAttribs.removeI(""BarbarianOutpostCourse"") } fun setStage(player: Player, stage: Int) { player.tempAttribs.setI(""BarbarianOutpostCourse"", stage) } fun getStage(player: Player): Int { return player.tempAttribs.getI(""BarbarianOutpostCourse"") } onObjectClick(32015) { e -> if (e.getObject().tile.matches(Tile.of(2547, 9951, 0))) e.player.useLadder(Tile.of(2546, 3551, 0)) } onObjectClick(20210) { e -> if (!Agility.hasLevel(e.player, 35)) return@onObjectClick e.player.forceMove(Tile.of(e.getObject().x, if (e.player.y >= 3561) 3558 else 3561, e.getObject().plane), 10580, 10, 60) { e.player.skills.addXp(Constants.AGILITY, 1.0 / 20.0) } } onObjectClick(43526, checkDistance = false) { e -> val targetTile = if (e.getObject().x == 2552) { Tile.of(2552, 3554, 0) } else { Tile.of(2551, 3554, 0) } e.player.setRouteEvent(RouteEvent(targetTile) { if (!Agility.hasLevel(e.player, 35)) return@RouteEvent e.player.lock() e.player.resetWalkSteps() World.sendObjectAnimation(e.getObject(), Animation(497)) e.player.forceMove(Tile.of(e.getObject().x, 3549, 0), 751, 20, 75) { e.player.sendMessage(""You skillfully swing across."", true) e.player.skills.addXp(Constants.AGILITY, 28.0) setStage(e.player, 0) } }) } onObjectClick(43595, checkDistance = false) { e -> e.player.setRouteEvent(RouteEvent(Tile.of(2551, 3546, 0)) { if (!Agility.hasLevel(e.player, 35)) return@RouteEvent e.player.sendMessage(""You walk carefully across the slippery log..."", true) e.player.forceMove(Tile.of(2541, e.getObject().y, e.getObject().plane), 9908, 20, 12 * 30) { e.player.anim(-1) e.player.skills.addXp(Constants.AGILITY, 20.7) e.player.sendMessage(""... and make it safely to the other side."", true) if (getStage(e.player) == 0) setStage(e.player, 1) } }) } onObjectClick(20211) { e -> if (!Agility.hasLevel(e.player, 35)) return@onObjectClick e.player.sendMessage(""You climb the netting..."", true) e.player.skills.addXp(Constants.AGILITY, 10.2) e.player.useStairs(828, Tile.of((e.getObject().x - 1), e.player.y, 1), 1, 2) if (getStage(e.player) == 1) setStage(e.player, 2) } onObjectClick(2302) { e -> if (!Agility.hasLevel(e.player, 35)) return@onObjectClick val toTile = Tile.of(2532, e.getObject().y, e.getObject().plane) e.player.sendMessage(""You put your foot on the ledge and try to edge across..."", true) e.player.lock() e.player.schedule { e.player.faceObject(e.getObject()) wait(1) e.player.anim(753) e.player.appearance.setBAS(157) wait(1) e.player.addWalkSteps(toTile.x, toTile.y, -1, false) wait(3) e.player.anim(759) e.player.appearance.setBAS(-1) e.player.unlock() e.player.addWalkSteps(2532, 3546) e.player.skills.addXp(Constants.AGILITY, 26.0) e.player.sendMessage(""You skillfully edge across the gap."", true) if (getStage(e.player) == 2) setStage(e.player, 3) } } onObjectClick(1948) { e -> if (!Agility.hasLevel(e.player, 35)) return@onObjectClick if (e.player.x >= e.getObject().x) { e.player.sendMessage(""You cannot climb that from this side."") return@onObjectClick } e.player.lock() e.player.sendMessage(""You climb the low wall..."", true) e.player.forceMove(Tile.of((e.getObject().x + 1), e.getObject().y, e.getObject().plane ), 4853, 30, 60) { e.player.skills.addXp(Constants.AGILITY, 16.2) val stage = getStage(e.player) if (stage == 3) setStage(e.player, 4) else if (stage == 4) { e.player.incrementCount(""Barbarian normal laps"") removeStage(e.player) e.player.skills.addXp(Constants.AGILITY, 56.7) } } } onObjectClick(43533) { e -> if (!Agility.hasLevel(e.player, 90)) return@onObjectClick e.player.lock() e.player.schedule { e.player.faceNorth() wait(1) e.player.anim(10492) wait(6) e.player.tele(e.player.transform(0, 0, 2)) e.player.forceMove(Tile.of(2538, 3545, 2), 10493, 10, 30) { e.player.skills.addXp(Constants.AGILITY, 15.0) } } } onObjectClick(43597, checkDistance = false) { e -> if (!Agility.hasLevel(e.player, 90)) return@onObjectClick e.player.setRouteEvent(RouteEvent(e.getObject().tile) { e.player.lock() e.player.schedule { e.player.faceWest() wait(1) e.player.anim(10023) wait(2) e.player.tele(Tile.of(2536, 3546, 3)) e.player.anim(11794) wait(1) e.player.unlock() e.player.skills.addXp(Constants.AGILITY, 15.0) } }) } onObjectClick(43587, checkDistance = false) { e -> if (!Agility.hasLevel(e.player, 90)) return@onObjectClick e.player.setRouteEvent(RouteEvent(Tile.of(2533, 3547, 3)) { e.player.lock() e.player.schedule { e.player.faceTile(Tile.of(2531, 3554, 3)) wait(1) World.sendObjectAnimation(e.getObject(), Animation(11819)) e.player.forceMove(Tile.of(2532, 3553, 3), 4189, 15, 90) { e.player.skills.addXp(Constants.AGILITY, 15.0) World.sendObjectAnimation(World.getObject(Tile.of(2531, 3554, 3), ObjectType.SCENERY_INTERACT), Animation(7527)) } } }) } onObjectClick(43527) { e -> if (!Agility.hasLevel(e.player, 90)) return@onObjectClick e.player.appearance.setBAS(330) e.player.forceMove(Tile.of(2536, 3553, 3), 16079, 10, 90) { e.player.stopAll() e.player.interfaceManager.removeSubs( InterfaceManager.Sub.TAB_INVENTORY, InterfaceManager.Sub.TAB_MAGIC, InterfaceManager.Sub.TAB_EMOTES, InterfaceManager.Sub.TAB_EQUIPMENT, InterfaceManager.Sub.TAB_PRAYER ) e.player.skills.addXp(Constants.AGILITY, 15.0) e.player.anim(-1) } } onObjectClick(43531) { e -> if (!Agility.hasLevel(e.player, 90)) return@onObjectClick e.player.lock() e.player.anim(2586) e.player.appearance.setBAS(-1) WorldTasks.schedule(object : Task() { override fun run() { e.player.unlockNextTick() e.player.interfaceManager.sendSubDefaults( InterfaceManager.Sub.TAB_INVENTORY, InterfaceManager.Sub.TAB_MAGIC, InterfaceManager.Sub.TAB_EMOTES, InterfaceManager.Sub.TAB_EQUIPMENT, InterfaceManager.Sub.TAB_PRAYER ) e.player.tele(Tile.of(2538, 3553, 2)) e.player.anim(2588) e.player.skills.addXp(Constants.AGILITY, 15.0) stop() } }, 0) } onObjectClick(43532) { e -> if (!Agility.hasLevel(e.player, 90)) return@onObjectClick e.player.lock() e.player.forceMove(Tile.of(2540, e.player.y, 2), 11792, 10, 30) e.player.schedule { e.player.forceMove(Tile.of(2542, e.player.y, 1), 11790, 0, 90) wait(3) e.player.forceMove(Tile.of(2543, e.player.y, 1), 11791, 0, 30) wait(1) e.player.anim(2588) e.player.tele(Tile.of(2543, e.player.y, 0)) e.player.skills.addXp(Constants.AGILITY, 15.0) if (getStage(e.player) == 1) { e.player.incrementCount(""Barbarian advanced laps"") removeStage(e.player) e.player.skills.addXp(Constants.AGILITY, 615.0) } e.player.unlockNextTick() } } }" "package com.rs.game.content.skills.agility; @PluginEventHandler public class BurthorpeAgility { public static ObjectClickHandler handleLogWalk = new ObjectClickHandler(new Object[] { 66894 }, e -> Agility.walkToAgility(e.getPlayer(), 155, Direction.NORTH, 6, 6, 5.5)); public static ObjectClickHandler handleClimb1 = new ObjectClickHandler(new Object[] { 66912 }, e -> Agility.handleObstacle(e.getPlayer(), 15765, 7, Tile.of(2919, 3562, 1), 5.5)); public static ObjectClickHandler handleRopeSwing = new ObjectClickHandler(false, new Object[] { 66904 }, e -> Agility.swingOnRopeSwing(e.getPlayer(), Tile.of(2912, 3562, 1), Tile.of(2916, 3562, 1), e.getObject(), 5.5)); public static ObjectClickHandler handleMonkeyBars = new ObjectClickHandler(false, new Object[] { 66897 }, e -> Agility.crossMonkeybars(e.getPlayer(), Tile.of(2917, 3561, 1), Tile.of(2917, 3554, 1), 5.5)); public static ObjectClickHandler handleShimmy = new ObjectClickHandler(new Object[] { 66909 }, e -> Agility.walkToAgility(e.getPlayer(), 2349, Direction.WEST, 4, 4, 5.5)); public static ObjectClickHandler handleClimb2 = new ObjectClickHandler(new Object[] { 66902 }, e -> Agility.handleObstacle(e.getPlayer(), 15782, 2, Tile.of(2912, 3562, 1), 5.5)); public static ObjectClickHandler handleJumpDown = new ObjectClickHandler(new Object[] { 66910 }, e -> { Agility.handleObstacle(e.getPlayer(), 2588, 1, Tile.of(2916, 3552, 0), 46); e.getPlayer().incrementCount(""Burthorpe laps""); }); }" "package com.rs.game.content.skills.agility; @PluginEventHandler public class GnomeAgility { public static ObjectClickHandler handle = new ObjectClickHandler(false, new Object[] { 43529 }, e -> { if (!Agility.hasLevel(e.getPlayer(), 85)) return; int x = Utils.clampI(e.getObject().getX(), 2485, 2487); e.getPlayer().setRouteEvent(new RouteEvent(Tile.of(x, 3419, 3), () -> { e.getPlayer().lock(); WorldTasks.scheduleTimer(tick -> { switch(tick) { case 0 -> e.getPlayer().faceObject(e.getObject()); case 1 -> e.getPlayer().forceMoveVisually(Tile.of(x, 3421, 3), 11784, 0, 30); case 2 -> { e.getPlayer().tele(Tile.of(x, 3421, 3)); e.getPlayer().forceMoveVisually(Tile.of(x, 3421, 3), Tile.of(x, 3425, 3), 11785, 0, 30); } case 3 -> { e.getPlayer().anim(11789); e.getPlayer().tele(Tile.of(x, 3425, 3)); } case 6 -> e.getPlayer().forceMoveVisually(Tile.of(x, 3429, 3), -1, 20, 60); case 11 -> { e.getPlayer().tele(Tile.of(x, 3429, 3)); e.getPlayer().forceMoveVisually(Tile.of(x, 3429, 3), Tile.of(x, 3432, 3), -1, 20, 60); } case 15 -> { e.getPlayer().tele(Tile.of(x, 3432, 3)); e.getPlayer().getSkills().addXp(Constants.AGILITY, 25); if (getGnomeStage(e.getPlayer()) == 1) setGnomeStage(e.getPlayer(), 2); e.getPlayer().unlock(); return false; } } return true; }); })); }); public static ObjectClickHandler handleBoard = new ObjectClickHandler(false, new Object[] { 69514 }, e -> { if (!Agility.hasLevel(e.getPlayer(), 85)) return; e.getPlayer().setRouteEvent(new RouteEvent(Tile.of(2476, 3418, 3), () -> e.getPlayer().forceMove(Tile.of(2484, 3418, 3), 2922, 25, 90, () -> { e.getPlayer().getSkills().addXp(Constants.AGILITY, 22); if (getGnomeStage(e.getPlayer()) == 0) setGnomeStage(e.getPlayer(), 1); }))); }); public static ObjectClickHandler handleTreeBranch2 = new ObjectClickHandler(new Object[] { 69506 }, e -> { if (!Agility.hasLevel(e.getPlayer(), 85)) return; e.getPlayer().sendMessage(""You climb the tree..."", true); e.getPlayer().useStairs(828, Tile.of(2472, 3419, 3), 1, 2, ""... to the platform above.""); if (getGnomeStage(e.getPlayer()) == 0) setGnomeStage(e.getPlayer(), 1); e.getPlayer().getSkills().addXp(Constants.AGILITY, 19); }); public static ObjectClickHandler handleJumpDown = new ObjectClickHandler(new Object[] { 69389 }, e -> { if (!Agility.hasLevel(e.getPlayer(), 85)) return; e.getPlayer().lock(); WorldTasks.scheduleLooping(new Task() { int tick = 0; @Override public void run() { if (tick == 0) { e.getPlayer().forceMove(Tile.of(2485, 3434, 3), 2923, 25, 60, false); } else if (tick == 3) { e.getPlayer().setNextAnimation(new Animation(2924)); e.getPlayer().tele(Tile.of(2485, 3436, 0)); } else if (tick == 5) { e.getPlayer().unlock(); e.getPlayer().getSkills().addXp(Constants.AGILITY, 25); if (getGnomeStage(e.getPlayer()) == 2) { e.getPlayer().incrementCount(""Gnome advanced laps""); removeGnomeStage(e.getPlayer()); e.getPlayer().getSkills().addXp(Constants.AGILITY, 605); } stop(); } tick++; } }, 0, 0); }); public static ObjectClickHandler handleLogWalk = new ObjectClickHandler(new Object[] { 69526 }, e -> { final boolean running = e.getPlayer().getRun(); e.getPlayer().setRunHidden(false); e.getPlayer().lock(); e.getPlayer().addWalkSteps(2474, 3429, -1, false); e.getPlayer().sendMessage(""You walk carefully across the slippery log..."", true); WorldTasks.scheduleLooping(new Task() { boolean secondloop; @Override public void run() { if (!secondloop) { secondloop = true; e.getPlayer().getAppearance().setBAS(155); } else { e.getPlayer().getAppearance().setBAS(-1); e.getPlayer().setRunHidden(running); setGnomeStage(e.getPlayer(), 0); e.getPlayer().getSkills().addXp(Constants.AGILITY, 7.5); e.getPlayer().sendMessage(""... and make it safely to the other side."", true); e.getPlayer().unlock(); stop(); } } }, 0, 5); }); public static ObjectClickHandler handleObstacleNet = new ObjectClickHandler(new Object[] { 69383 }, e -> { e.getPlayer().sendMessage(""You climb the netting."", true); e.getPlayer().useStairs(828, Tile.of(e.getPlayer().getX(), 3423, 1), 1, 2); WorldTasks.schedule(new Task() { @Override public void run() { if (getGnomeStage(e.getPlayer()) == 0) setGnomeStage(e.getPlayer(), 1); e.getPlayer().getSkills().addXp(Constants.AGILITY, 7.5); } }, 1); }); public static ObjectClickHandler handleTreeBranch = new ObjectClickHandler(new Object[] { 69508 }, e -> { e.getPlayer().sendMessage(""You climb the tree..."", true); e.getPlayer().useStairs(828, Tile.of(2473, 3420, 2), 1, 2, ""... to the platform above.""); WorldTasks.schedule(new Task() { @Override public void run() { if (getGnomeStage(e.getPlayer()) == 1) setGnomeStage(e.getPlayer(), 2); e.getPlayer().getSkills().addXp(Constants.AGILITY, 5); } }, 1); }); public static ObjectClickHandler handleWalkBackRope = new ObjectClickHandler(new Object[] { 4059 }, e -> e.getPlayer().sendMessage(""I would keep moving forward on the course."")); public static ObjectClickHandler handleRope = new ObjectClickHandler(new Object[] { 2312 }, e -> { final boolean running = e.getPlayer().getRun(); e.getPlayer().setRunHidden(false); e.getPlayer().lock(); e.getPlayer().addWalkSteps(2483, 3420, -1, false); WorldTasks.scheduleLooping(new Task() { boolean secondloop; @Override public void run() { if (!secondloop) { secondloop = true; e.getPlayer().getAppearance().setBAS(155); } else { e.getPlayer().getAppearance().setBAS(-1); e.getPlayer().setRunHidden(running); if (getGnomeStage(e.getPlayer()) == 2) setGnomeStage(e.getPlayer(), 3); e.getPlayer().getSkills().addXp(Constants.AGILITY, 7); e.getPlayer().sendMessage(""You passed the obstacle succesfully."", true); stop(); e.getPlayer().unlock(); } } }, 0, 5); }); public static ObjectClickHandler handleTreeBranch3 = new ObjectClickHandler(new Object[] { 69507 }, e -> { e.getPlayer().useStairs(828, Tile.of(2487, 3421, 0), 1, 2, ""You climbed the tree branch succesfully.""); WorldTasks.schedule(new Task() { @Override public void run() { if (getGnomeStage(e.getPlayer()) == 3) setGnomeStage(e.getPlayer(), 4); e.getPlayer().getSkills().addXp(Constants.AGILITY, 5); } }, 1); }); public static ObjectClickHandler handleObstacleNet2 = new ObjectClickHandler(false, new Object[] { 69384 }, e -> e.getPlayer().setRouteEvent(new RouteEvent(Tile.of(Utils.clampI(e.getPlayer().getX(), 2483, 2488), e.getObject().getY()-1, 0), () -> { e.getPlayer().sendMessage(""You climb the netting."", true); e.getPlayer().useStairs(828, Tile.of(e.getPlayer().getX(), e.getObject().getY()+1, 0), 1, 2); WorldTasks.schedule(new Task() { @Override public void run() { if (getGnomeStage(e.getPlayer()) == 4) setGnomeStage(e.getPlayer(), 5); e.getPlayer().getSkills().addXp(Constants.AGILITY, 8); } }, 1); }))); public static ObjectClickHandler handlePipe = new ObjectClickHandler(new Object[] { 69377, 69378 }, e -> { final boolean running = e.getPlayer().getRun(); e.getPlayer().setRunHidden(false); e.getPlayer().lock(8); e.getPlayer().addWalkSteps(e.getObject().getX(), e.getObject().getY() == 3431 ? 3437 : 3430, -1, false); e.getPlayer().sendMessage(""You pulled yourself through the pipes."", true); WorldTasks.scheduleLooping(new Task() { boolean secondloop; @Override public void run() { if (!secondloop) { secondloop = true; e.getPlayer().getAppearance().setBAS(295); } else { e.getPlayer().getAppearance().setBAS(-1); e.getPlayer().setRunHidden(running); e.getPlayer().getSkills().addXp(Constants.AGILITY, 7); if (getGnomeStage(e.getPlayer()) == 5) { e.getPlayer().incrementCount(""Gnome normal laps""); removeGnomeStage(e.getPlayer()); e.getPlayer().getSkills().addXp(Constants.AGILITY, 39.5); } stop(); } } }, 0, 6); }); public static void removeGnomeStage(Player player) { player.getTempAttribs().removeI(""GnomeCourse""); player.getTempAttribs().removeI(""GnomeCourseAdv""); } public static void setGnomeStage(Player player, int stage) { player.getTempAttribs().setI(""GnomeCourse"", stage); player.getTempAttribs().setI(""GnomeCourseAdv"", stage); } public static int getGnomeStageAdv(Player player) { return player.getTempAttribs().getI(""GnomeCourseAdv""); } public static int getGnomeStage(Player player) { return player.getTempAttribs().getI(""GnomeCourse""); } }" "package com.rs.game.content.skills.agility; @PluginEventHandler public class WerewolfAgility { public static class WolfAgilityTrainer extends NPC { public WolfAgilityTrainer(int id, Tile tile) { super(id, tile); if(id == 1661) setRandomWalk(false); } @Override public void processNPC() { super.processNPC(); int option = Utils.random(400); switch (option) { case 0 -> setNextForceTalk(new ForceTalk(""Let the bloodlust take you!!"")); case 1 -> setNextForceTalk(new ForceTalk(""You're the slowest wolf I've ever had the misfortune to witness"")); case 2 -> setNextForceTalk(new ForceTalk(""I never really wanted to be an agility trainer"")); case 3 -> setNextForceTalk(new ForceTalk(""Claws first - think later."")); case 4 -> setNextForceTalk(new ForceTalk(""When you're done there's a human with your name on it!!"")); case 5 -> setNextForceTalk(new ForceTalk(""Get on with it - you need your shiskers plucking!!!!"")); case 6 -> setNextForceTalk(new ForceTalk(""Remember - a slow wolf is a hungry wolf!!"")); case 7 -> setNextForceTalk(new ForceTalk(""It'll be worth it when you hunt!!"")); case 8 -> setNextForceTalk(new ForceTalk(""Let's see those powerful backlegs at work!!"")); case 9 -> setNextForceTalk(new ForceTalk(""Imagine the smell of blood in your nostrils!!!"")); } } } public static NPCInstanceHandler toFunc = new NPCInstanceHandler(new Object[] { ""Agility Trainer"", ""Agility Boss"" }, WolfAgilityTrainer::new); public static NPCClickHandler handleAgilityTrainer = new NPCClickHandler(new Object[]{1664}, e -> { if(e.getPlayer().getInventory().containsItem(4179)) { int stickCount = e.getPlayer().getInventory().getAmountOf(4179); e.getPlayer().getInventory().removeItems(new Item(4179, stickCount)); e.getPlayer().getSkills().addXp(Skills.AGILITY, 380*stickCount); e.getPlayer().incrementCount(""Werewolf agility sticks fetched""); } }); public static ObjectClickHandler handleZipLine = new ObjectClickHandler(false, new Object[] { 5139, 5140, 5141 }, e -> { Tile endTile = Tile.of(3528, 9873, 0); e.getPlayer().walkToAndExecute(Tile.of(3528, 9910, 0), () -> { e.getPlayer().lock(); e.getPlayer().getTasks().scheduleTimer(1, 0, ticks -> { switch(ticks) { default -> { return true; } case 0 -> { e.getPlayer().lock(); e.getPlayer().faceSouth(); List npcs = e.getPlayer().queryNearbyNPCsByTileRange(1, (npc -> npc.getId() == 1663 && npc.withinDistance(e.getPlayer().getTile(), 4))); if(npcs.size() >= 1) { switch(Utils.random(3)) { case 0 -> npcs.getFirst().forceTalk(""Now a true test of teeth...""); case 1 -> npcs.getFirst().forceTalk(""Don't let the spikes or the blood put you off...""); } } return true; } case 1 -> { e.getPlayer().setNextAnimation(new Animation(1601)); return true; } case 2 -> { e.getPlayer().forceTalk(""WAAAAAARRRGGGHHH!!!!!!""); e.getPlayer().forceMove(endTile, 1602, 0, 240, () -> { e.getPlayer().setNextAnimation(new Animation(-1)); e.getPlayer().getSkills().addXp(Skills.AGILITY, 200); e.getPlayer().incrementCount(""Werewolf agility laps completed""); }); return true; } case 11 -> { List npcs = e.getPlayer().queryNearbyNPCsByTileRange(10, (npc -> npc.getId() == 1664)); if(npcs.size() >= 1) switch(Utils.random(3)) { case 0 -> npcs.getFirst().forceTalk(""Remember - no stick, no agility bonus!""); case 1 -> npcs.getFirst().forceTalk(""Don't forget to give me the stick when you're done.""); } return false; } } }); }); }); public static ObjectClickHandler handleStepStones = new ObjectClickHandler(false, new Object[] { 35996 }, e -> { if(!Agility.hasLevel(e.getPlayer(), 60) || e.getPlayer().getTile().getY() > 9880) return; if(e.getObject().getTile().matches(e.getPlayer().getTile())) return; if (!e.getObject().getTile().withinDistance(e.getPlayer().getTile(), 2)) return; if(e.getObject().getTile().isAt(3538, 9875)) { e.getPlayer().walkToAndExecute(Tile.of(3538, 9873, 0), jumpRock(e)); } else jumpRock(e).run(); }); private static Runnable jumpRock(ObjectClickEvent e) { return () -> { if(e.getObject().getTile().isAt(3538, 9875)) yellFetch(e); e.getPlayer().getSkills().addXp(Skills.AGILITY, 10); e.getPlayer().forceMove(e.getObject().getTile(), 741, 0, 25); e.getPlayer().lock(0); }; } private static void yellFetch(ObjectClickEvent e) { List npcs = e.getPlayer().queryNearbyNPCsByTileRange(8, (npc -> npc.getId() == 1661)); if (npcs.size() >= 1) { npcs.getFirst().faceNorth(); npcs.getFirst().forceTalk(""FETCH!!!!!""); WorldTasks.schedule(2, () -> { npcs.getFirst().setNextAnimation(new Animation(6547)); World.sendProjectile(npcs.getFirst(), Tile.of(3540, 9911, 0), 1158, 35, 0, 20, 0.6, 20, p -> World.addGroundItem(new Item(4179), Tile.of(3540, 9911, 0), e.getPlayer())); }); } } public static ObjectClickHandler handleHurdles = new ObjectClickHandler(new Object[] { 5134, 5133, 5135 }, e -> { if(e.getPlayer().getTile().getY() > e.getObject().getY()) return; e.getPlayer().getSkills().addXp(Skills.AGILITY, 20); e.getPlayer().forceMove(Tile.of(e.getObject().getX()+(e.getObjectId() == 5134 ? 0 : 1), e.getObject().getY() + 1, 0), 1603, 0, 45); e.getPlayer().lock(1); }); public static ObjectClickHandler handleObstaclePipes = new ObjectClickHandler(new Object[] { 5152 }, e -> { if(e.getPlayer().getTile().getY() > e.getObject().getY()) return; final Tile toTile = Tile.of(e.getObject().getX(), e.getObject().getY()+4, e.getObject().getPlane()); e.getPlayer().forceMove(toTile, 10580, 0, 60, () -> e.getPlayer().getSkills().addXp(Skills.AGILITY, 15)); }); public static ObjectClickHandler handleRockSlope = new ObjectClickHandler(new Object[] { 5136 }, e -> { if(e.getPlayer().getX() < e.getObject().getX()) return; e.getPlayer().forceMove(Tile.of(e.getObject().getX()-2, e.getObject().getY(), 0), 2049, 30, 60, () -> e.getPlayer().getSkills().addXp(Skills.AGILITY, 25)); }); public static ObjectClickHandler courseExitLadder = new ObjectClickHandler(new Object[] { 5130 }, e -> e.getPlayer().useLadder(Tile.of(3543, 3463, 0))); public static ObjectClickHandler courseEntranceLadder = new ObjectClickHandler(new Object[] { 5132 }, e -> e.getPlayer().useLadder(Tile.of(3549, 9865, 0))); }" "package com.rs.game.content.skills.agility; public class WildernessAgility { public static void gateWalkIn(final Player player, final GameObject object) { if (!Agility.hasLevel(player, 52)) return; if (player.getY() != object.getY()) { player.addWalkSteps(2998, 3916, 0, false); player.lock(2); WorldTasks.schedule(new Task() { @Override public void run() { GateWalkEnd(player, object); } }, 1); } else GateWalkEnd(player, object); } public static void gateWalkOut(final Player player, final GameObject object) { if (player.getY() != object.getY()) { player.addWalkSteps(2998, 3931, 0, false); player.lock(2); WorldTasks.schedule(new Task() { @Override public void run() { GateWalkEnd2(player, object); } }, 1); } else GateWalkEnd2(player, object); } private static void GateWalkEnd(final Player player, GameObject object) { player.sendMessage(""You walk carefully across the path..."", true); player.forceMove(Tile.of(object.getX(), 3931, object.getPlane()), 9908, 5, 16*30, () -> player.sendMessage(""... and make it safely to the other side."", true)); } private static void GateWalkEnd2(final Player player, GameObject object) { player.sendMessage(""You walk carefully across the path..."", true); player.forceMove(Tile.of(object.getX() + 1, 3916, object.getPlane()), 9908, 5, 16*30, () -> player.sendMessage(""... and make it safely to the other side."", true)); } public static void enterObstaclePipe(final Player player, int objectX, int objectY) { if (!Agility.hasLevel(player, 52)) return; final boolean running = player.getRun(); final Tile toTile = Tile.of(objectX, objectY == 3938 ? 3950 : 3937, 0); player.setRunHidden(false); player.lock(7); player.addWalkSteps(objectX, objectY == 3938 ? 3950 : 3937, -1, false); player.sendMessage(""You pulled yourself through the pipes."", true); WorldTasks.scheduleLooping(new Task() { boolean secondloop; @Override public void run() { if (!secondloop) { secondloop = true; player.getAppearance().setBAS(295); } else { player.tele(toTile); player.getAppearance().setBAS(-1); setWildernessStage(player, 0); player.setRunHidden(running); player.getSkills().addXp(Constants.AGILITY, 7); stop(); } } }, 0, 6); } public static void swingOnRopeSwing(final Player player, GameObject object) { if (!Agility.hasLevel(player, 52)) return; if (player.getY() > 3953) { player.sendMessage(""You can't see a good way to jump from here.""); return; } player.lock(); Agility.swingOnRopeSwing(player, player.getTile(), Tile.of(object.getX(), 3958, object.getPlane()), object, 15.5); if (getWildernessStage(player) == 0) setWildernessStage(player, 1); } /* * Stepping Stone Method by Cjay0091 */ public static void crossSteppingPalletes(final Player player, final GameObject object) { if (player.getY() != object.getY()) return; player.lock(); WorldTasks.scheduleLooping(new Task() { int x; @Override public void run() { if (x++ == 6) { player.unlock(); stop(); return; } final Tile toTile = Tile.of(3002 - x, player.getY(), player.getPlane()); player.forceMove(toTile, 741, 5, 30); } }, 2, 1); player.getSkills().addXp(Constants.AGILITY, 20); if (getWildernessStage(player) == 1) setWildernessStage(player, 2); } public static void walkLog(final Player player) { if (player.getX() != 3002 || player.getY() != 3945) player.addWalkSteps(3002, 3945, -1, false); final boolean running = player.getRun(); player.setRunHidden(false); player.lock(); player.addWalkSteps(2994, 3945, -1, false); player.sendMessage(""You walk carefully across the log..."", true); WorldTasks.scheduleLooping(new Task() { boolean secondloop; @Override public void run() { if (!secondloop) { secondloop = true; player.getAppearance().setBAS(155); } else { player.unlock(); player.getAppearance().setBAS(-1); player.setRunHidden(running); player.getSkills().addXp(Constants.AGILITY, 7.5); player.sendMessage(""... and make it safely to the other side."", true); stop(); if (getWildernessStage(player) == 2) setWildernessStage(player, 3); } } }, 0, 6); } public static void climbCliff(final Player player, GameObject object) { if (player.getY() != 3939) return; player.setNextAnimation(new Animation(3378)); final Tile toTile = Tile.of(player.getX(), 3935, 0); player.sendMessage(""You climb up the rock."", true); WorldTasks.schedule(new Task() { @Override public void run() { player.tele(toTile); player.setNextAnimation(new Animation(-1)); player.getAppearance().setBAS(-1); stop(); if (getWildernessStage(player) == 3) { player.incrementCount(""Wilderness laps""); removeWildernessStage(player); player.getSkills().addXp(Constants.AGILITY, 499); } } }, 5); } public static void removeWildernessStage(Player player) { player.getTempAttribs().removeI(""WildernessCourse""); } public static void setWildernessStage(Player player, int stage) { player.getTempAttribs().setI(""WildernessCourse"", stage); } public static int getWildernessStage(Player player) { return player.getTempAttribs().getI(""WildernessCourse""); } }" "package com.rs.game.content.skills.agility.agilitypyramid; @PluginEventHandler public class AgilityPyramidBlock extends NPC { private int timer; private final Tile dangerTile; public AgilityPyramidBlock(int id, Tile tile) { super(id, tile); dangerTile = transform(getId() == 3125 ? 2 : 0, getId() == 3125 ? 0 : 2, 0); } @Override public void processNPC() { if (timer-- <= 0) { for (Player player : World.getPlayersInChunkRange(getChunkId(), 1)) player.getVars().setVarBit(1550, getId() == 3125 ? 1 : 3); forceMoveVisually(dangerTile, 20, 0); timer = 10; } if (timer > 7) for (Player p : getHittablePlayers()) { int dist = 0; if (getId() == 3125) dist = p.getX() - dangerTile.getX(); else dist = p.getY() - dangerTile.getY(); if (dist == 0) dist = 2; p.lock(); p.setNextAnimation(new Animation(3066)); final Tile tile = p.transform(getId() == 3125 ? dist : 0, getId() == 3125 ? 0 : dist, -1); p.forceMove(tile, 10, 30, () -> p.applyHit(new Hit(null, 80, HitLook.TRUE_DAMAGE))); } if (timer == 4) for (Player player : World.getPlayersInChunkRange(getChunkId(), 1)) player.getVars().setVarBit(1550, 0); } public List getHittablePlayers() { List players = new ArrayList<>(); for (Player player : World.getPlayersInChunkRange(getChunkId(), 1)) { if (player.getPlane() != getPlane() || player.isLocked()) continue; if (WorldUtil.collides(player.getTile(), dangerTile, 1, 2)) players.add(player); } return players; } public static NPCInstanceHandler toFunc = new NPCInstanceHandler(new Object[] { 3124, 3125 }, AgilityPyramidBlock::new); }" "package com.rs.game.content.skills.agility.agilitypyramid; public class AgilityPyramidController extends Controller { private boolean grabbedTop; private enum RollingBlock { A(1551, Tile.of(3354, 2841, 1), 1), B(1552, Tile.of(3368, 2849, 2), 2), C(1553, Tile.of(3374, 2835, 1), 3), D(1554, Tile.of(3048, 4699, 2), 3), E(1555, Tile.of(3044, 4699, 3), 2); private final int configId; private final Tile tile; private final int rotation; private RollingBlock(int configId, Tile tile, int rotation) { this.configId = configId; this.tile = tile; this.rotation = rotation; } } @Override public void start() { updateTop(); } @Override public void process() { for (RollingBlock block : RollingBlock.values()) if (WorldUtil.collides(player.getTile(), block.tile, 1, 2) && !player.hasWalkSteps() && !player.isLocked()) { jumpRoller(block, false); //TODO fail calc return; } } @Override public boolean processObjectClick1(GameObject object) { int id = object.getId(); if (id == 10857) { if (!Agility.hasLevel(player, 30)) return false; if (player.getPlane() == 3) player.useStairs(-1, player.transform(-320, 1859, -1), 1, 1); else player.useStairs(-1, player.transform(0, 3, 1), 1, 1); } else if (id == 10858) { if (player.getY() > 4000 && player.getPlane() == 2) player.useStairs(-1, player.transform(320, -1859, 1), 1, 1); else player.useStairs(-1, player.transform(0, -3, -1), 1, 1); } else if (id == 10865) climbOver(object); else if (id == 10859) jumpGap(object); else if (id == 10868 || id == 10867) walkLog(object); else if (object.getDefinitions(player).getFirstOption().equals(""Cross"") && object.getDefinitions(player).getName().equals(""Ledge"")) shimmySideways(object); else if (object.getDefinitions(player).getFirstOption().equals(""Cross"") && object.getDefinitions(player).getName().equals(""Gap"")) { if (object.getType() == ObjectType.STRAIGHT_INSIDE_WALL_DEC) { for (GameObject surr : World.getSurroundingBaseObjects(object, 2)) if (surr.getDefinitions(player).getFirstOption() != null && surr.getDefinitions(player).getFirstOption().equals(""Cross"") && surr.getDefinitions(player).getName().equals(""Gap"") && surr.getType() == ObjectType.SCENERY_INTERACT) shimmyHandholds(new GameObject(surr.getId(), surr.getType(), surr.getRotation(), surr.getX(), surr.getY(), surr.getPlane())); } else shimmyHandholds(object); } else if (id == 10851) { if (!grabbedTop) grabTop(object); } else if (id == 10855 || id == 10856) finishCourse(); else if (id == 16536) climbRocks(player, object); else if (id == 16535) { forceClose(); climbRocks(player, object); } return false; } @Override public boolean processNPCClick1(NPC npc) { if (npc.getId() == 3123) player.startConversation(new SimonTempleton(player)); return false; } @Override public void onTeleported(TeleType type) { removeController(); } @Override public boolean login() { return false; } @Override public boolean logout() { return false; } public boolean failed() { return (player.getSkills().getLevel(Constants.AGILITY) / 75.0) < Math.random(); } private void updateTop() { player.getVars().setVarBit(1556, grabbedTop ? 1 : 0); } public void finishCourse() { if (grabbedTop) { player.tele(Tile.of(3364, 2830, 0)); //player.getSkills().addXp(Constants.AGILITY, 300+(player.getSkills().getLevelForXp(Constants.AGILITY)*8)); //osrs rates? player.getSkills().addXp(Constants.AGILITY, 500); grabbedTop = false; updateTop(); player.incrementCount(""Agility Pyramid laps""); } else player.startConversation(new Conversation(player, new Dialogue(new PlayerStatement(HeadE.CONFUSED, ""I feel like I am forgetting something..."")))); } private void grabTop(GameObject object) { player.setNextFaceTile(player.transform(1, 0, 0)); player.lock(); player.getTasks().schedule(0, () -> player.anim(3063)); player.getTasks().schedule(2, () -> { player.getInventory().addItemDrop(6970, 1); grabbedTop = true; updateTop(); player.startConversation(new Conversation(player, new Dialogue(new ItemStatement(6970, ""You find a pyramid top!"")))); player.unlock(); }); } //3056 fail public void shimmyHandholds(GameObject object) { int startAnim = 3057; //3053 alt int renderEmote = 387; int endAnim = 3058; if (object.getId() == 10883 || object.getId() == 10885 || object.getId() == 10862) { startAnim -= 4; renderEmote -= 1; endAnim = 3055; } else if (failed()) endAnim= 3056; if (object.getRotation() % 2 == 0) shimmy(object.getTile().transform(object.getRotation() == 0 ? 1 : 0, player.getY() < object.getY() ? 4 : -4, 0), startAnim, renderEmote, endAnim, endAnim == 3055 || endAnim == 3056); else shimmy(object.getTile().transform(player.getX() < object.getX() ? 4 : -4, object.getRotation() == 3 ? 1 : 0, 0), startAnim, renderEmote, endAnim, endAnim == 3055 || endAnim == 3056); } //760 761 fail public void shimmySideways(GameObject object) { int startAnim = 752; int renderEmote = 156; int endAnim = 758; boolean failed = failed(); if (object.getId() == 10886 || (object.getId() == 10860 && (object.getTile().isAt(3372, 2839) || object.getTile().isAt(3364, 2851))) || object.getId() == 10888) { startAnim++; renderEmote++; endAnim++; if (failed) endAnim = 761; } else { endAnim = 760; failed = true; } if (object.getRotation() % 2 == 0) shimmy(object.getTile().transform(object.getRotation() == 0 ? 1 : 0, player.getY() < object.getY() ? 4 : -4, 0), startAnim, renderEmote, endAnim, failed); else shimmy(object.getTile().transform(player.getX() < object.getX() ? 4 : -4, object.getRotation() == 3 ? 1 : 0, 0), startAnim, renderEmote, endAnim, failed); } public void shimmy(final Tile toTile, final int startAnim, final int renderEmote, final int endAnim, final boolean fail) { final boolean running = player.getRun(); player.setRunHidden(false); player.lock(); WorldTasks.scheduleLooping(new Task() { int ticks; @Override public void run() { if (ticks == 0) { player.setNextAnimation(new Animation(startAnim)); player.getAppearance().setBAS(renderEmote); } else if (ticks == 1) player.addWalkSteps(toTile.getX(), toTile.getY(), -1, false); else if (ticks == 3 && fail) { player.setNextAnimation(new Animation(endAnim)); player.resetWalkSteps(); } else if (ticks >= 4) { if (fail) { player.tele(World.findClosestAdjacentFreeTile(player.transform(0, 0, -1), 2)); player.applyHit(new Hit(null, 100, HitLook.TRUE_DAMAGE)); } else { player.setNextAnimation(new Animation(endAnim)); player.getSkills().addXp(Constants.AGILITY, 52); } player.getAppearance().setBAS(-1); player.setRunHidden(running); player.unlock(); stop(); } ticks++; } }, 0, 1); } public static void climbRocks(Player player, GameObject object) { if (player.getX() > object.getX()) { final boolean running = player.getRun(); player.setRunHidden(false); player.lock(); player.addWalkSteps(player.transform(-4, 0, 0), -1, false); WorldTasks.scheduleLooping(new Task() { boolean secondloop; @Override public void run() { if (!secondloop) { secondloop = true; player.getAppearance().setBAS(0); } else { player.getAppearance().setBAS(-1); player.setRunHidden(running); player.unlock(); stop(); } } }, 0, 3); } else { final Tile toTile = player.transform(4, 0, 0); player.setNextAnimation(new Animation(740)); player.forceMove(toTile, 20, 120, () -> player.setNextAnimation(new Animation(-1))); } } public void walkLog(GameObject object) { final boolean running = player.getRun(); final Tile toTile; if (object.getRotation() % 2 == 0) toTile = object.getTile().transform(object.getId() == 10867 ? 5 : -5, 0, 0); else toTile = object.getTile().transform(0, object.getId() == 10867 ? 5 : -5, 0); player.setRunHidden(false); player.lock(); player.addWalkSteps(toTile.getX(), toTile.getY(), -1, false); WorldTasks.scheduleLooping(new Task() { boolean secondloop; @Override public void run() { if (!secondloop) { secondloop = true; player.getAppearance().setBAS(155); } else { player.getAppearance().setBAS(-1); player.setRunHidden(running); if (object.getId() == 10868) player.getSkills().addXp(Constants.AGILITY, 56.4); player.unlock(); stop(); } } }, 0, 5); } public void jumpGap(GameObject object) { final Tile toTile; if (object.getRotation() % 2 == 0) toTile = player.transform(0, player.getY() < object.getY() ? 3 : -3, 0); else toTile = player.transform(player.getX() < object.getX() ? 3 : -3, 0, 0); player.lock(); player.setNextAnimation(new Animation(3067)); player.forceMove(toTile, 5, 60, () -> player.getSkills().addXp(Constants.AGILITY, 22)); } public void climbOver(GameObject object) { final Tile toTile; if (failed()) { player.applyHit(new Hit(null, 40, HitLook.TRUE_DAMAGE)); player.setNextForceTalk(new ForceTalk(""Ouch!"")); player.lock(3); return; } if (object.getRotation() % 2 == 0) toTile = player.transform(player.getX() < object.getX() ? 2 : -2, 0, 0); else toTile = player.transform(0, player.getY() < object.getY() ? 2 : -2, 0); player.lock(); player.setNextAnimation(new Animation(1560)); player.forceMove(toTile, 5, 60, () -> player.getSkills().addXp(Constants.AGILITY, 8)); } public void jumpRoller(RollingBlock block, boolean failed) { byte[] dir = Utils.getDirection(player.getFaceAngle()); if (dir[0] != 0 && dir[1] != 0 || failed) { int x = 0, y = 0, z = -1; y = switch (block.rotation) { case 0 -> { x = 0; yield -2; } case 1 -> { x = -2; yield 0; } case 2 -> { x = 0; yield 2; } case 3 -> { x = 2; yield 0; } default -> y; }; if (block == RollingBlock.D) { x = 322; y = -1856; z = 1; } player.lock(); player.getVars().setVarBit(block.configId, 1); player.setNextAnimation(new Animation(3064)); player.forceMove(player.transform(x, y, z), 10, 60, () -> { player.getVars().setVarBit(block.configId, 0); player.applyHit(new Hit(null, 60, HitLook.TRUE_DAMAGE)); }); return; } player.lock(); player.getVars().setVarBit(block.configId, 1); player.setNextAnimation(new Animation(1115)); player.forceMove(player.transform(dir[0]*2, dir[1]*2, 0), 5, 50, () -> { player.getVars().setVarBit(block.configId, 0); player.getSkills().addXp(Constants.AGILITY, 12); }); } }" "package com.rs.game.content.skills.construction; @PluginEventHandler public class EstateAgentDialogue extends Conversation { public static NPCClickHandler handleEstateAgent = new NPCClickHandler(new Object[] { ""Estate agent"" }, e -> e.getPlayer().startConversation(new EstateAgentDialogue(e.getPlayer(), e.getNPCId()))); public EstateAgentDialogue(Player player, int npcId) { super(player); addOptions(""What would you like to do?"", new Options() { @Override public void create() { option(""Open shop"", new Dialogue().addNext(() -> ShopsHandler.openShop(player, ""construction_goods""))); option(""Can I move my house?"", new Dialogue().addOptions(""Which town would you like your house moved to?"", new Options() { @Override public void create() { for (HouseConstants.POHLocation loc : HouseConstants.POHLocation.values()) { if (player.getSkills().getLevelForXp(Skills.CONSTRUCTION) >= loc.getLevelRequired()) option(Utils.formatPlayerNameForDisplay(loc.name()), new Dialogue().addNext(() -> promptHouseLocation(Utils.formatPlayerNameForDisplay(loc.name()), loc, loc.getLevelRequired(), loc.getCost()))); } } })); option(""Ask about changing house styling."", new Dialogue().addOptions(""Which kind of house style would you like?"", new Options() { @Override public void create() { option(""Basic wood - 2,500 coins"", new Dialogue().addNext(() -> promptHouseChange(""basic wood"", 0, 1, 2500))); if (player.getSkills().getLevelForXp(Skills.CONSTRUCTION) >= 10) option(""Basic stone - 10,000 coins"", new Dialogue().addNext(() -> promptHouseChange(""basic stone"", 1, 10, 10000))); if (player.getSkills().getLevelForXp(Skills.CONSTRUCTION) >= 20) option(""Whitewashed stone - 15,000 coins"", new Dialogue().addNext(() -> promptHouseChange(""whitewashed stone"", 2, 20, 15000))); if (player.getSkills().getLevelForXp(Skills.CONSTRUCTION) >= 30) option(""Fremennik-style wood - 25,000 coins"", new Dialogue().addNext(() -> promptHouseChange(""fremennik-style wood"", 3, 30, 20000))); if (player.getSkills().getLevelForXp(Skills.CONSTRUCTION) >= 40) option(""Tropical wood - 50,000 coins"", new Dialogue().addNext(() -> promptHouseChange(""tropical wood"", 4, 40, 50000))); if (player.getSkills().getLevelForXp(Skills.CONSTRUCTION) >= 50) option(""Fancy stone - 100,000 coins"", new Dialogue().addNext(() -> promptHouseChange(""fancy stone"", 5, 50, 100000))); if (player.isQuestComplete(Quest.LOVE_STORY, ""to have a dark stone themed house."")) option(""Dark stone - 500,000 coins"", new Dialogue().addNext(() -> promptHouseChange(""dark stone"", 6, 80, 500000))); } })); option(""What's that cape you are wearing?"", Skillcapes.Construction.getOffer99CapeDialogue(player, npcId)); } }); } public void promptHouseLocation(final String name, final HouseConstants.POHLocation loc, int level, final int cost) { if (player.getSkills().getLevelForXp(Constants.CONSTRUCTION) >= level) { if (player.getInventory().hasCoins(cost)) player.sendOptionDialogue(""Are you sure?"", ops -> { ops.add(""Yes"", () -> { player.getInventory().removeCoins(cost); player.getHouse().setLocation(loc); player.sendMessage(""Your house location been set to ""+name+"".""); }); ops.add(""No, that's too much money.""); }); else { player.sendMessage(""You don't have enough money.""); } } else { player.sendMessage(""You don't have the construction level required.""); } } public void promptHouseChange(final String name, final int look, int level, final int cost) { if (player.getSkills().getLevelForXp(Constants.CONSTRUCTION) >= level) { if (player.getInventory().hasCoins(cost)) player.sendOptionDialogue(""Are you sure?"", ops -> { ops.add(""Yes"", () -> { player.getInventory().removeCoins(cost); player.getHouse().changeLook(look); player.sendMessage(""Your house has been set to ""+name+"".""); }); ops.add(""No, that's too much money.""); }); else { player.sendMessage(""You don't have enough money.""); } } else { player.sendMessage(""You don't have the construction level required.""); } } }" "package com.rs.game.content.skills.construction; @PluginEventHandler public class House { public static int LOGGED_OUT = 0, KICKED = 1, TELEPORTED = 2; private List roomsR; private byte look; private POHLocation location; private boolean buildMode; private boolean arriveInPortal; private Servant servant; private byte paymentStage; private transient Player player; private transient boolean locked; private transient CopyOnWriteArrayList pets; private transient CopyOnWriteArrayList npcs; private transient List players; private transient Instance instance; private transient boolean loaded; private transient boolean challengeMode; private transient ServantNPC servantInstance; private PetHouse petHouse; private byte build; public void setLocation(POHLocation location) { this.location = location; } public POHLocation getLocation() { return location; } private boolean isOwnerInside() { return players.contains(player); } public static ObjectClickHandler handleHousePortals = new ObjectClickHandler(Arrays.stream(POHLocation.values()).map(POHLocation::getObjectId).toArray(), e -> e.getPlayer().startConversation(new Dialogue().addOptions(ops -> { ops.add(""Go to your house."", () -> { e.getPlayer().getHouse().setBuildMode(false); e.getPlayer().getHouse().enterMyHouse(); }); ops.add(""Go to your house (building mode)."", () -> { e.getPlayer().getHouse().kickGuests(); e.getPlayer().getHouse().setBuildMode(true); e.getPlayer().getHouse().enterMyHouse(); }); ops.add(""Go to a friend's house."", () -> { if (e.getPlayer().isIronMan()) { e.getPlayer().sendMessage(""You cannot enter another player's house as an ironman.""); return; } e.getPlayer().sendInputName(""Enter name of the person who's house you'd like to join:"", name -> House.enterHouse(e.getPlayer(), name)); }); ops.add(""Nevermind.""); }))); public static ButtonClickHandler handleHouseOptions = new ButtonClickHandler(398, e -> { if (e.getComponentId() == 19) e.getPlayer().getInterfaceManager().sendSubDefault(Sub.TAB_SETTINGS); else if (e.getComponentId() == 15 || e.getComponentId() == 1) e.getPlayer().getHouse().setBuildMode(e.getComponentId() == 15); else if (e.getComponentId() == 25 || e.getComponentId() == 26) e.getPlayer().getHouse().setArriveInPortal(e.getComponentId() == 25); else if (e.getComponentId() == 27) e.getPlayer().getHouse().expelGuests(); else if (e.getComponentId() == 29) House.leaveHouse(e.getPlayer()); }); public static ButtonClickHandler handleCreateRoom = new ButtonClickHandler(402, e -> { if (e.getComponentId() >= 93 && e.getComponentId() <= 115) e.getPlayer().getHouse().createRoom(e.getComponentId() - 93); }); public static ButtonClickHandler handleBuild = new ButtonClickHandler(new Object[] { 394, 396 }, e -> { if (e.getComponentId() == 11) e.getPlayer().getHouse().build(e.getSlotId()); }); public void expelGuests() { if (!isOwnerInside()) { player.sendMessage(""You can only expel guests when you are in your own house.""); return; } kickGuests(); } public void kickGuests() { if ((players == null) || (players.size() <= 0)) return; for (Player player : new ArrayList<>(players)) { if (isOwner(player)) continue; leaveHouse(player, KICKED); } } public boolean isOwner(Player player) { return this.player.getUsername().equalsIgnoreCase(player.getUsername()); } public void enterMyHouse() { joinHouse(player); } public void openRoomCreationMenu(GameObject door) { int roomX = player.getChunkX() - instance.getBaseChunkX(); // current room int roomY = player.getChunkY() - instance.getBaseChunkY(); // current room int xInChunk = player.getXInChunk(); int yInChunk = player.getYInChunk(); if (xInChunk == 7) roomX += 1; else if (xInChunk == 0) roomX -= 1; else if (yInChunk == 7) roomY += 1; else if (yInChunk == 0) roomY -= 1; openRoomCreationMenu(roomX, roomY, door.getPlane()); } public void removeRoom() { int roomX = player.getChunkX() - instance.getBaseChunkX(); // current room int roomY = player.getChunkY() - instance.getBaseChunkY(); // current room RoomReference room = getRoom(roomX, roomY, player.getPlane()); if (room == null) return; if (room.getZ() != 1) { player.simpleDialogue(""You cannot remove a building that is supporting this room.""); return; } RoomReference above = getRoom(roomX, roomY, 2); RoomReference below = getRoom(roomX, roomY, 0); RoomReference roomTo = above != null && above.getStaircaseSlot() != -1 ? above : below != null && below.getStaircaseSlot() != -1 ? below : null; if (roomTo == null) { player.simpleDialogue(""These stairs do not lead anywhere.""); return; } openRoomCreationMenu(roomTo.getX(), roomTo.getY(), roomTo.getZ()); } /* * door used to calculate where player facing to create */ public void openRoomCreationMenu(int roomX, int roomY, int plane) { if (!buildMode) { player.simpleDialogue(""You can only do that in building mode.""); return; } RoomReference room = getRoom(roomX, roomY, plane); if (room != null) { if (room.plane == 1 && getRoom(roomX, roomY, room.plane + 1) != null) { player.simpleDialogue(""You can't remove a room that is supporting another room.""); return; } if (room.room == Room.THRONE_ROOM && room.plane == 1) { RoomReference bellow = getRoom(roomX, roomY, room.plane - 1); if (bellow != null && bellow.room == Room.OUTBLIETTE) { player.simpleDialogue(""You can't remove a throne room that is supporting a outbliette.""); return; } } if ((room.room == Room.GARDEN || room.room == Room.FORMAL_GARDEN) && getPortalCount() < 2) { if (room == getPortalRoom()) { player.simpleDialogue(""Your house must have at least one exit portal.""); return; } } player.startConversation(new Dialogue(). addOptions(""Do you really want to remove the room?"", ops -> { ops.add(""Yes"") .addOptions(""You can't get anything back? Remove room?"", conf -> { conf.add(""Yes, get rid of my money already!"", () -> player.getHouse().removeRoom(room)); conf.add(""No.""); }); ops.add(""No""); })); } else { if (roomX == 0 || roomY == 0 || roomX == 7 || roomY == 7) { player.simpleDialogue(""You can't create a room here.""); return; } if (plane == 2) { RoomReference r = getRoom(roomX, roomY, 1); if (r == null || (r.room == Room.GARDEN || r.room == Room.FORMAL_GARDEN || r.room == Room.MENAGERIE)) { player.simpleDialogue(""You can't create a room here.""); return; } } for (int index = 0; index < HouseConstants.Room.values().length - 2; index++) { Room refRoom = HouseConstants.Room.values()[index]; if (player.getSkills().getLevel(Constants.CONSTRUCTION) >= refRoom.getLevel() && player.getInventory().hasCoins(refRoom.getPrice())) player.getPackets().setIFText(402, index + (refRoom == HouseConstants.Room.DUNGEON_STAIRS || refRoom == HouseConstants.Room.DUNGEON_PIT ? 69 : refRoom == HouseConstants.Room.TREASURE_ROOM ? 70 : 68), "" "" + refRoom.getPrice() + "" coins""); } player.getInterfaceManager().sendInterface(402); player.getTempAttribs().setO(""CreationRoom"", new int[] { roomX, roomY, plane }); player.setCloseInterfacesEvent(() -> player.getTempAttribs().removeO(""CreationRoom"")); } } public void handleLever(Player player, GameObject object) { if (buildMode || player.isLocked()) return; final int roomX = player.getChunkX() - instance.getBaseChunkX(); // current room final int roomY = player.getChunkY() - instance.getBaseChunkY(); // current room RoomReference room = getRoom(roomX, roomY, player.getPlane()); int trap = room.getTrapObject(); player.setNextAnimation(new Animation(9497)); if (trap == -1 || trap == HObject.FLOORDECORATION.getId()) return; player.lock(7); if (trap == HObject.TRAPDOOR.getId()) player.sendOptionDialogue(""What would you like to do?"", ops -> { ops.add(""Drop into oubliette"", () -> dropPlayers(roomX, roomY, 13681, 13681, 13681, 13681)); ops.add(""Nothing.""); }); else if (trap == HObject.STEELCAGE.getId()) { trapPlayers(roomX, roomY, 13681, 13681, 13681, 13681); player.sendOptionDialogue(""What would you like to do?"", ops -> { ops.add(""Release players"", () -> releasePlayers(roomX, roomY, 13681, 13681, 13681, 13681)); ops.add(""Nothing.""); }); } else if (trap == HObject.LESSERMAGICCAGE.getId()) { trapPlayers(roomX, roomY, 13682); player.sendOptionDialogue(""What would you like to do?"", ops -> { ops.add(""Release players"", () -> releasePlayers(roomX, roomY, 13682)); ops.add(""Drop into oubliette"", () -> dropPlayers(roomX, roomY, 13682)); }); } else if (trap == HObject.GREATERMAGICCAGE.getId()) { trapPlayers(roomX, roomY, 13683); player.sendOptionDialogue(""What would you like to do?"", ops -> { ops.add(""Release players"", () -> releasePlayers(roomX, roomY, 13683)); ops.add(""Drop into oubliette"", () -> dropPlayers(roomX, roomY, 13683)); ops.add(""Kick from house"", () -> kickTrapped(roomX, roomY, 13683)); }); } } public ArrayList getTrappedPlayers(int x, int y) { ArrayList list = new ArrayList<>(); for (Player p : players) if (p != null && p.getControllerManager().getController() instanceof HouseController) if ((p.getX() >= x && p.getX() <= x + 1) && (p.getY() >= y && p.getY() <= y + 1)) list.add(p); return list; } public void kickTrapped(int roomX, int roomY, int... trapIds) { int x = instance.getLocalX(roomX, 3); int y = instance.getLocalY(roomY, 3); for (final Player p : getTrappedPlayers(x, y)) { if (isOwner(p)) { p.setNextForceTalk(new ForceTalk(""Trying to kick the house owner... Pfft.."")); continue; } leaveHouse(p, KICKED); } releasePlayers(roomX, roomY, trapIds); } public void dropPlayers(int roomX, int roomY, int... trapIds) { RoomReference roomTo = getRoom(roomX, roomY, 0); if (roomTo == null || roomTo.getLadderTrapSlot() == -1) { releasePlayers(roomX, roomY, trapIds); return; } int x = instance.getLocalX(roomX, 3); int y = instance.getLocalY(roomY, 3); for (final Player p : getTrappedPlayers(x, y)) { p.lock(10); p.setNextAnimation(new Animation(1950)); WorldTasks.schedule(new Task() { @Override public void run() { p.tele(Tile.of(p.getX(), p.getY(), 0)); p.setNextAnimation(new Animation(3640)); } }, 5); } releasePlayers(roomX, roomY, trapIds); } public void releasePlayers(int roomX, int roomY, int... trapIds) { int x = instance.getLocalX(roomX, 3); int y = instance.getLocalY(roomY, 3); World.removeObject(new GameObject(trapIds[0], ObjectType.SCENERY_INTERACT, 1, Tile.of(x, y, player.getPlane()))); if (trapIds.length > 1) World.removeObject(new GameObject(trapIds[1], ObjectType.SCENERY_INTERACT, 0, Tile.of(x + 1, y, player.getPlane()))); if (trapIds.length > 2) World.removeObject(new GameObject(trapIds[2], ObjectType.SCENERY_INTERACT, 2, Tile.of(x, y + 1, player.getPlane()))); if (trapIds.length > 3) World.removeObject(new GameObject(trapIds[3], ObjectType.SCENERY_INTERACT, 3, Tile.of(x + 1, y + 1, player.getPlane()))); World.removeObject(World.getObjectWithType(Tile.of(x - 1, y + 1, player.getPlane()), ObjectType.WALL_STRAIGHT)); World.removeObject(World.getObjectWithType(Tile.of(x - 1, y, player.getPlane()), ObjectType.WALL_STRAIGHT)); World.removeObject(World.getObjectWithType(Tile.of(x, y + 2, player.getPlane()), ObjectType.WALL_STRAIGHT)); World.removeObject(World.getObjectWithType(Tile.of(x + 1, y + 2, player.getPlane()), ObjectType.WALL_STRAIGHT)); World.removeObject(World.getObjectWithType(Tile.of(x, y - 1, player.getPlane()), ObjectType.WALL_STRAIGHT)); World.removeObject(World.getObjectWithType(Tile.of(x + 1, y - 1, player.getPlane()), ObjectType.WALL_STRAIGHT)); World.removeObject(World.getObjectWithType(Tile.of(x + 2, y, player.getPlane()), ObjectType.WALL_STRAIGHT)); World.removeObject(World.getObjectWithType(Tile.of(x + 2, y + 1, player.getPlane()), ObjectType.WALL_STRAIGHT)); for (Player p : getTrappedPlayers(x, y)) p.resetWalkSteps(); } public void trapPlayers(int roomX, int roomY, int... trapIds) { int x = instance.getLocalX(roomX, 3); int y = instance.getLocalY(roomY, 3); World.spawnObject(new GameObject(trapIds[0], ObjectType.SCENERY_INTERACT, 1, Tile.of(x, y, player.getPlane()))); if (trapIds.length > 1) World.spawnObject(new GameObject(trapIds[1], ObjectType.SCENERY_INTERACT, 0, Tile.of(x + 1, y, player.getPlane()))); if (trapIds.length > 2) World.spawnObject(new GameObject(trapIds[2], ObjectType.SCENERY_INTERACT, 2, Tile.of(x, y + 1, player.getPlane()))); if (trapIds.length > 3) World.spawnObject(new GameObject(trapIds[3], ObjectType.SCENERY_INTERACT, 3, Tile.of(x + 1, y + 1, player.getPlane()))); World.spawnObject(new GameObject(13150, ObjectType.WALL_STRAIGHT, 2, Tile.of(x - 1, y + 1, player.getPlane()))); World.spawnObject(new GameObject(13150, ObjectType.WALL_STRAIGHT, 2, Tile.of(x - 1, y, player.getPlane()))); World.spawnObject(new GameObject(13150, ObjectType.WALL_STRAIGHT, 3, Tile.of(x, y + 2, player.getPlane()))); World.spawnObject(new GameObject(13150, ObjectType.WALL_STRAIGHT, 3, Tile.of(x + 1, y + 2, player.getPlane()))); World.spawnObject(new GameObject(13150, ObjectType.WALL_STRAIGHT, 1, Tile.of(x, y - 1, player.getPlane()))); World.spawnObject(new GameObject(13150, ObjectType.WALL_STRAIGHT, 1, Tile.of(x + 1, y - 1, player.getPlane()))); World.spawnObject(new GameObject(13150, ObjectType.WALL_STRAIGHT, 0, Tile.of(x + 2, y, player.getPlane()))); World.spawnObject(new GameObject(13150, ObjectType.WALL_STRAIGHT, 0, Tile.of(x + 2, y + 1, player.getPlane()))); for (Player p : getTrappedPlayers(x, y)) p.resetWalkSteps(); } public void climbLadder(Player player, GameObject object, boolean up) { if (object == null || instance == null) return; int roomX = object.getTile().getChunkX() - instance.getBaseChunkX(); int roomY = object.getTile().getChunkY() - instance.getBaseChunkY(); RoomReference room = getRoom(roomX, roomY, object.getPlane()); if (room == null) return; if (room.plane == (up ? 2 : 0)) { player.sendMessage(""You are on the "" + (up ? ""highest"" : ""lowest"") + "" possible level so you cannot add a room "" + (up ? ""above"" : ""under"") + "" here.""); return; } RoomReference roomTo = getRoom(roomX, roomY, room.plane + (up ? 1 : -1)); if (roomTo == null) { if (buildMode) { player.startConversation(new Dialogue() .addOptions(""This ""+(up ? ""ladder"" : ""trapdoor"")+"" does not lead anywhere. Do you want to build a room at the "" + (up ? ""top"" : ""bottom"") + ""?"", ops -> { ops.add(""Yes."").addOptions(""Select a room"", conf -> { conf.add((room.getZ() == 1 && !up) ? ""Oubliette"" : ""Throne room"", () -> { Room r = (room.getZ() == 1 && !up) ? Room.OUTBLIETTE : Room.THRONE_ROOM; Builds ladderTrap = (room.getZ() == 1 && !up) ? Builds.OUB_LADDER : Builds.TRAPDOOR; RoomReference newRoom = new RoomReference(r, room.getX(), room.getY(), room.getZ() + (up ? 1 : -1), room.getRotation()); int slot = room.getLadderTrapSlot(); if (slot != -1) { newRoom.addObject(ladderTrap, slot); player.getHouse().createRoom(newRoom); } }); conf.add(""Nevermind.""); }); ops.add(""No.""); })); } else player.sendMessage(""This does not lead anywhere.""); // start dialogue return; } if (roomTo.getLadderTrapSlot() == -1) { player.sendMessage(""This does not lead anywhere.""); return; } int xOff = 0; int yOff = 0; if (roomTo.getRotation() == 0) { yOff = 6; xOff = 2; } else if (roomTo.getRotation() == 1) { yOff = 6; xOff = 5; } else if (roomTo.getRotation() == 2) { yOff = 1; xOff = 5; } else if (roomTo.getRotation() == 3) { yOff = 1; xOff = 2; } player.ladder(Tile.of(instance.getLocalX(roomTo.getX(), xOff), instance.getLocalY(roomTo.getY(), yOff), player.getPlane() + (up ? 1 : -1))); } public Tile getCenterTile(RoomReference rRef) { if (instance == null || rRef == null) return null; return instance.getLocalTile(rRef.x * 8 + 3, rRef.y * 8 + 3); } public int getPaymentStage() { return paymentStage; } public void resetPaymentStage() { paymentStage = 0; } public void incrementPaymentStage() { paymentStage++; } public void climbStaircase(Player player, GameObject object, boolean up) { if (object == null || instance == null) return; int roomX = object.getTile().getChunkX() - instance.getBaseChunkX(); int roomY = object.getTile().getChunkY() - instance.getBaseChunkY(); RoomReference room = getRoom(roomX, roomY, object.getPlane()); if (room == null) return; if (room.plane == (up ? 2 : 0)) { player.sendMessage(""You are on the "" + (up ? ""highest"" : ""lowest"") + "" possible level so you cannot add a room "" + (up ? ""above"" : ""under"") + "" here.""); return; } RoomReference roomTo = getRoom(roomX, roomY, room.plane + (up ? 1 : -1)); if (roomTo == null) { if (buildMode) { player.startConversation(new Dialogue() .addOptions(""These stairs do not lead anywhere. Do you want to build a room at the "" + (up ? ""top"" : ""bottom"") + ""?"", ops -> { ops.add(""Yes."").addOptions(""Select a room"", conf -> { conf.add(""Skill hall"", () -> { RoomReference newRoom = new RoomReference(up ? Room.HALL_SKILL_DOWN : Room.HALL_SKILL, room.getX(), room.getY(), room.getZ() + (up ? 1 : -1), room.getRotation()); int slot = room.getStaircaseSlot(); if (slot != -1) { newRoom.addObject(up ? Builds.STAIRCASE_DOWN : Builds.STAIRCASE, slot); player.getHouse().createRoom(newRoom); } }); conf.add(""Quest hall"", () -> { RoomReference newRoom = new RoomReference(up ? Room.HALL_QUEST_DOWN : Room.HALL_QUEST, room.getX(), room.getY(), room.getZ() + (up ? 1 : -1), room.getRotation()); int slot = room.getStaircaseSlot(); if (slot != -1) { newRoom.addObject(up ? Builds.STAIRCASE_DOWN_1 : Builds.STAIRCASE_1, slot); player.getHouse().createRoom(newRoom); } }); if (room.getZ() == 1 && !up) conf.add(""Dungeon stairs room"", () -> { RoomReference newRoom = new RoomReference(Room.DUNGEON_STAIRS, room.getX(), room.getY(), room.getZ() + (up ? 1 : -1), room.getRotation()); int slot = room.getStaircaseSlot(); if (slot != -1) { newRoom.addObject(Builds.STAIRCASE_2, slot); player.getHouse().createRoom(newRoom); } }); }); ops.add(""No.""); })); } else player.sendMessage(""These stairs do not lead anywhere.""); // start dialogue return; } if (roomTo.getStaircaseSlot() == -1) { player.sendMessage(""These stairs do not lead anywhere.""); return; } player.useStairs(-1, Tile.of(player.getX(), player.getY(), player.getPlane() + (up ? 1 : -1)), 0, 1); } public void removeRoom(RoomReference room) { if (roomsR.remove(room)) { refreshNumberOfRooms(); refreshHouse(); } } public void createRoom(int slot) { Room[] rooms = HouseConstants.Room.values(); if (slot >= rooms.length) return; int[] position = player.getTempAttribs().getO(""CreationRoom""); player.closeInterfaces(); if (position == null) return; Room room = rooms[slot]; if ((room == Room.TREASURE_ROOM || room == Room.DUNGEON_CORRIDOR || room == Room.DUNGEON_JUNCTION || room == Room.DUNGEON_PIT || room == Room.DUNGEON_STAIRS) && position[2] != 0) { player.sendMessage(""That room can only be built underground.""); return; } if (room == Room.THRONE_ROOM) if (position[2] != 1) { player.sendMessage(""This room cannot be built on a second level or underground.""); return; } if (room == Room.OUTBLIETTE) { player.sendMessage(""That room can only be built using a throne room trapdoor.""); return; } if ((room == Room.GARDEN || room == Room.FORMAL_GARDEN || room == Room.MENAGERIE) && position[2] != 1) { player.sendMessage(""That room can only be built on ground.""); return; } if (room == Room.MENAGERIE && hasRoom(Room.MENAGERIE)) { player.sendMessage(""You can only build one menagerie.""); return; } if (room == Room.GAMES_ROOM && hasRoom(Room.GAMES_ROOM)) { player.sendMessage(""You can only build one game room.""); return; } if (room.getLevel() > player.getSkills().getLevel(Constants.CONSTRUCTION)) { player.sendMessage(""You need a Construction level of "" + room.getLevel() + "" to build this room.""); return; } if (player.getInventory().getCoins() < room.getPrice()) { player.sendMessage(""You don't have enough coins to build this room.""); return; } if (roomsR.size() >= getMaxQuantityRooms()) { player.sendMessage(""You have reached the maxium quantity of rooms.""); return; } final RoomReference roomRef = new RoomReference(room, position[0], position[1], position[2], 0); player.setFinishConversationEvent(() -> player.getHouse().previewRoom(roomRef, true)); player.getHouse().previewRoom(roomRef, true); roomRef.setRotation((roomRef.getRotation() + 1) & 0x3); player.getHouse().previewRoom(roomRef, false); player.startConversation(new Conversation(player) { { addOptions(""start"", ""What would you like to do?"", ops -> { ops.add(""Rotate clockwise"", new Dialogue().addGotoStage(""start"", this).setFunc(() -> { player.getHouse().previewRoom(roomRef, true); roomRef.setRotation((roomRef.getRotation() + 1) & 0x3); player.getHouse().previewRoom(roomRef, false); })); ops.add(""Rotate anticlockwise."", new Dialogue().addGotoStage(""start"", this).setFunc(() -> { player.getHouse().previewRoom(roomRef, true); roomRef.setRotation((roomRef.getRotation() - 1) & 0x3); player.getHouse().previewRoom(roomRef, false); })); ops.add(""Build."", () -> player.getHouse().createRoom(roomRef)); ops.empty(""Cancel""); }); } }); } public boolean hasRoom(Room room) { for (RoomReference r : roomsR) if (r.room == room) return true; return false; } private int getMaxQuantityRooms() { int consLvl = player.getSkills().getLevelForXp(Constants.CONSTRUCTION); int maxRoom = 40; if (consLvl >= 38) { maxRoom += (consLvl - 32) / 6; if (consLvl == 99) maxRoom++; } return maxRoom; } public void createRoom(RoomReference room) { if (!player.getInventory().hasCoins(room.room.getPrice())) { player.sendMessage(""You don't have enough coins to build this room.""); return; } player.getInventory().removeCoins(room.room.getPrice()); player.getTempAttribs().setO(""CRef"", room); roomsR.add(room); refreshNumberOfRooms(); refreshHouse(); player.setCloseChatboxInterfaceEvent(null); player.setCloseInterfacesEvent(null); } public void openBuildInterface(GameObject object, final Builds build) { if (!buildMode) { player.simpleDialogue(""You can only do that in building mode.""); return; } int roomX = object.getTile().getChunkX() - instance.getBaseChunkX(); int roomY = object.getTile().getChunkY() - instance.getBaseChunkY(); RoomReference room = getRoom(roomX, roomY, object.getPlane()); if (room == null) return; Item[] itemArray = new Item[build.getPieces().length]; int requirementsValue = 0; for (int index = 0; index < build.getPieces().length; index++) { if ((build == Builds.PORTALS1 || build == Builds.PORTALS2 || build == Builds.PORTALS3) && index > 2) continue; HObject piece = build.getPieces()[index]; itemArray[index] = new Item(piece.getItemId(), 1); if (hasRequirimentsToBuild(false, build, piece)) requirementsValue += Math.pow(2, index + 1); } final int reqVal = requirementsValue; Dialogue buildD = new Dialogue() .addNext(new Statement() { @Override public void send(Player player) { player.getPackets().sendVarc(841, reqVal); player.getPackets().sendItems(398, itemArray); player.getPackets().setIFEvents(new IFEvents(1306, 55, -1, -1).enableContinueButton()); // exit // button for (int i = 0; i < itemArray.length; i++) player.getPackets().setIFEvents(new IFEvents(1306, 8 + 7 * i, 4, 4).enableContinueButton()); // options player.getInterfaceManager().sendInterface(1306); player.getTempAttribs().setO(""OpenedBuild"", build); player.getTempAttribs().setO(""OpenedBuildObject"", object); } @Override public int getOptionId(int componentId) { return componentId == 55 ? Integer.MAX_VALUE : (componentId - 8) / 7; } @Override public void close(Player player) { player.closeInterfaces(); } }); for (int i = 0;i < itemArray.length;i++) { final int index = i; buildD.addNext(() -> player.getHouse().build(index)); } player.startConversation(buildD); } private boolean hasRequirimentsToBuild(boolean warn, Builds build, HObject piece) { int level = player.getSkills().getLevel(Constants.CONSTRUCTION); if (!build.isWater() && player.getInventory().containsOneItem(9625)) level += 3; if (level < piece.getLevel()) { if (warn) player.sendMessage(""Your construction level is too low.""); return false; } if (!player.hasRights(Rights.ADMIN)) { if (!player.getInventory().containsItems(piece.getRequirements(player))) { if (warn) player.sendMessage(""You dont have the right materials.""); return false; } if (build.isWater() ? !hasWaterCan() : (!player.getInventory().containsItem(HouseConstants.HAMMER, 1) || (!player.getInventory().containsItem(HouseConstants.SAW, 1) && !player.getInventory().containsOneItem(9625)))) { if (warn) player.sendMessage(build.isWater() ? ""You will need a watering can with some water in it instead of hammer and saw to build plants."" : ""You will need a hammer and saw to build furniture.""); return false; } } return true; } public void build(int slot) { final Builds build = player.getTempAttribs().getO(""OpenedBuild""); GameObject object = player.getTempAttribs().getO(""OpenedBuildObject""); if (build == null || object == null || build.getPieces().length <= slot) return; int roomX = object.getTile().getChunkX() - instance.getBaseChunkX(); int roomY = object.getTile().getChunkY() - instance.getBaseChunkY(); final RoomReference room = getRoom(roomX, roomY, object.getPlane()); if (room == null) return; final HObject piece = build.getPieces()[slot]; if (!hasRequirimentsToBuild(true, build, piece)) return; final ObjectReference oref = room.addObject(build, slot); player.closeInterfaces(); player.lock(); player.setNextAnimation(new Animation(build.isWater() ? 2293 : 3683)); if (!player.hasRights(Rights.ADMIN)) for (Item item : piece.getRequirements(player)) player.getInventory().deleteItem(item); player.getTempAttribs().removeO(""OpenedBuild""); player.getTempAttribs().removeO(""OpenedBuildObject""); WorldTasks.schedule(new Task() { @Override public void run() { player.getSkills().addXp(Constants.CONSTRUCTION, piece.getXP()); if (build.isWater()) player.getSkills().addXp(Constants.FARMING, piece.getXP()); refreshObject(room, oref, false); player.unlock(); } }, 0); } private void refreshObject(RoomReference rref, ObjectReference oref, boolean remove) { Chunk chunk = ChunkManager.getChunk(this.instance.getChunkId(rref.x, rref.y, rref.plane)); for (int x = 0; x < 8; x++) for (int y = 0; y < 8; y++) { GameObject[] objects = chunk.getBaseObjects(Tile.of(chunk.getBaseX()+x, chunk.getBaseY()+y, rref.plane)); if (objects != null) for (GameObject object : objects) { if (object == null) continue; int slot = oref.build.getIdSlot(object.getId()); if (slot == -1) continue; if (remove) World.spawnObject(object); else { GameObject objectR = new GameObject(object); if (oref.getId(slot) == -1) World.spawnObject(new GameObject(-1, object.getType(), object.getRotation(), object.getTile())); else { objectR.setId(oref.getId(slot)); World.spawnObject(objectR); } } } } } public boolean hasWaterCan() { for (int id = 5333; id <= 5340; id++) if (player.getInventory().containsOneItem(id)) return true; return false; } public void setServantOrdinal(byte ordinal) { if (ordinal == -1) { removeServant(); servant = null; refreshServantVarBit(); return; } refreshServantVarBit(); servant = HouseConstants.Servant.values()[ordinal]; } public boolean hasServant() { return servant != null; } public void refreshServantVarBit() { int bit = servant == null ? 0 : ((servant.ordinal()*2)+1); if (servant != null && servant == Servant.DEMON_BUTLER) bit = 8; player.getVars().setVarBit(2190, bit); } public void openRemoveBuild(GameObject object) { if (!buildMode) { player.simpleDialogue(""You can only do that in building mode.""); return; } if (object.getId() == HouseConstants.HObject.EXIT_PORTAL.getId() && getPortalCount() <= 1) { player.simpleDialogue(""Your house must have at least one exit portal.""); return; } int roomX = object.getTile().getChunkX() - instance.getBaseChunkX(); int roomY = object.getTile().getChunkY() - instance.getBaseChunkY(); RoomReference room = getRoom(roomX, roomY, object.getPlane()); if (room == null) return; ObjectReference ref = room.getObject(object); if (ref != null) { if (ref.build.toString().contains(""STAIRCASE"")) { if (object.getPlane() != 1) { RoomReference above = getRoom(roomX, roomY, 2); RoomReference below = getRoom(roomX, roomY, 0); if ((above != null && above.getStaircaseSlot() != -1) || (below != null && below.getStaircaseSlot() != -1)) player.simpleDialogue(""You cannot remove a building that is supporting this room.""); return; } } player.sendOptionDialogue(""Really remove it?"", ops -> { ops.add(""Yes."", () -> player.getHouse().removeBuild(object)); ops.add(""No.""); }); } } public void removeBuild(final GameObject object) { if (!buildMode) { // imagine u use settings to change while dialogue // open, cheater :p player.simpleDialogue(""You can only do that in building mode.""); return; } int roomX = object.getTile().getChunkX() - instance.getBaseChunkX(); int roomY = object.getTile().getChunkY() - instance.getBaseChunkY(); final RoomReference room = getRoom(roomX, roomY, object.getPlane()); if (room == null) return; final ObjectReference oref = room.removeObject(object); if (oref == null) return; player.lock(); player.setNextAnimation(new Animation(3685)); WorldTasks.schedule(new Task() { @Override public void run() { World.removeObject(object); refreshObject(room, oref, true); player.unlock(); } }); } public boolean isDoor(GameObject object) { return object.getDefinitions().getName().equalsIgnoreCase(""Door hotspot""); } public boolean isBuildMode() { return buildMode; } public boolean isDoorSpace(GameObject object) { return object.getDefinitions().getName().equalsIgnoreCase(""Door space""); } public void switchLock(Player player) { if (!isOwner(player)) { player.sendMessage(""You can only lock your own house.""); return; } locked = !locked; if (locked) player.simpleDialogue(""Your house is now locked to visitors.""); else if (buildMode) player.simpleDialogue(""Visitors will be able to enter your house once you leave building mode.""); else player.simpleDialogue(""You have unlocked your house.""); } public static void enterHouse(Player player, String username) { Player owner = World.getPlayerByDisplay(username); //TODO if (owner == null || !owner.isRunning() /*|| !player.getFriendsIgnores().onlineTo(owner)*/ || owner.getHouse() == null || owner.getHouse().locked) { player.sendMessage(""That player is offline, or has privacy mode enabled.""); return; } if (owner.getHouse().location == null || !player.withinDistance(owner.getHouse().location.getTile(), 16)) { player.sendMessage(""That player's house is at "" + Utils.formatPlayerNameForDisplay(owner.getHouse().location.name()).replace(""Portal"", """") + "".""); return; } owner.getHouse().joinHouse(player); } public boolean joinHouse(final Player player) { player.lock(); if (!isOwner(player)) { // not owner if (!isOwnerInside() || !loaded) { player.sendMessage(""That player is offline, or has privacy mode enabled.""); return false; } if (buildMode) { player.sendMessage(""The owner currently has build mode turned on.""); return false; } } players.add(player); sendStartInterface(player); player.getControllerManager().startController(new HouseController(this)); if (loaded) { teleportPlayer(player); player.getTasks().schedule(4, () -> { player.unlock(); player.getInterfaceManager().setDefaultTopInterface(); teleportServant(); }); } else { createHouse(); } return true; } public static void leaveHouse(Player player) { HouseController controller = player.getControllerManager().getController(HouseController.class); if (controller == null) { player.sendMessage(""You're not in a house.""); return; } player.setCanPvp(false); player.removeHouseOnlyItems(); controller.getHouse().leaveHouse(player, KICKED); } /* * 0 - logout, 1 kicked/tele outside outside, 2 tele somewhere else */ public void leaveHouse(Player player, int type, boolean controllerRemoved) { player.setCanPvp(false); player.removeHouseOnlyItems(); if (!controllerRemoved) player.getControllerManager().removeControllerWithoutCheck(); if (type == LOGGED_OUT) player.setTile(location.getTile()); else if (type == KICKED) player.useStairs(-1, location.getTile(), 0, 1); if (players != null && players.contains(player)) players.remove(player); if (players == null || players.size() == 0) destroyHouse(); if (player.getAppearance().getRenderEmote() != -1) player.getAppearance().setBAS(-1); if (isOwner(player) && servantInstance != null) servantInstance.setFollowing(false); player.getTempAttribs().setB(""inBoxingArena"", false); player.setCanPvp(false); player.setForceMultiArea(false); } public void leaveHouse(Player player, int type) { leaveHouse(player, type, false); } private void removeServant() { if (servantInstance != null) { servantInstance.finish(); servantInstance = null; } } private void addServant() { if (servantInstance == null && servant != null) { servantInstance = new ServantNPC(this); } } public Servant getServant() { return servant; } private void refreshServant() { removeServant(); addServant(); } public void callServant(boolean bellPull) { if (bellPull) { player.setNextAnimation(new Animation(3668)); player.lock(2); } if (servantInstance == null) player.sendMessage(""The house has no servant.""); else { servantInstance.setFollowing(true); servantInstance.tele(World.getFreeTile(player.getTile(), 1)); servantInstance.setNextAnimation(new Animation(858)); player.startConversation(new ServantHouseD(player, servantInstance, true)); } } public ServantNPC getServantInstance() { return servantInstance; } /* * refers to logout */ public void finish() { kickGuests(); // no need to leave house for owner, controller does that itself } public void refreshHouse() { destroyHouse(); loaded = false; sendStartInterface(player); createHouse(); } public boolean isLoaded() { return loaded; } public void sendStartInterface(Player player) { player.lock(); player.getInterfaceManager().setTopInterface(399, false); player.getMusicsManager().playSongAndUnlock(454); player.jingle(22); } public void teleportPlayer(Player player) { teleportPlayer(player, getPortalRoom()); } public void teleportServant() { teleportServant(getPortalRoom()); } public void teleportServant(RoomReference room) { if (room == null) return; if (servantInstance == null) return; servantInstance.resetWalkSteps(); byte rotation = room.rotation; if (rotation == 0) { instance.teleportChunkLocal(servantInstance, room.x, 3, room.y - 1, 3, room.plane); } else { instance.teleportChunkLocal(servantInstance, room.x, 3, room.y, 3 + 1, room.plane); } } public void teleportPlayer(Player player, RoomReference room) { if (room == null) player.sendMessage(""Error, tried teleporting to room that doesn't exist.""); else { byte rotation = room.rotation; if (rotation == 0) { instance.teleportChunkLocal(player, room.x, 3, room.y - 1, 3, room.plane); } else { instance.teleportChunkLocal(player, room.x, 3, room.y, 3 + 1, room.plane); } } } public int getPortalCount() { int count = 0; for (RoomReference room : roomsR) if (room.room == HouseConstants.Room.GARDEN || room.room == HouseConstants.Room.FORMAL_GARDEN) for (ObjectReference o : room.objects) if (o.getPiece() == HouseConstants.HObject.EXIT_PORTAL || o.getPiece() == HouseConstants.HObject.EXITPORTAL) count++; return count; } public RoomReference getMenagerie() { for (RoomReference room : roomsR) if (room.room == HouseConstants.Room.MENAGERIE) for (ObjectReference o : room.objects) if (o.getPiece() == HouseConstants.HObject.OAKPETHOUSE || o.getPiece() == HouseConstants.HObject.TEAKPETHOUSE || o.getPiece() == HouseConstants.HObject.MAHOGANYPETHOUSE || o.getPiece() == HouseConstants.HObject.CONSECRATEDPETHOUSE || o.getPiece() == HouseConstants.HObject.DESECRATEDPETHOUSE || o.getPiece() == HouseConstants.HObject.NATURALPETHOUSE) return room; return null; } public RoomReference getPortalRoom() { for (RoomReference room : roomsR) if (room.room == HouseConstants.Room.GARDEN || room.room == HouseConstants.Room.FORMAL_GARDEN) for (ObjectReference o : room.objects) if (o.getPiece() == HouseConstants.HObject.EXIT_PORTAL || o.getPiece() == HouseConstants.HObject.EXITPORTAL) return room; return null; } public House() { buildMode = true; petHouse = new PetHouse(); roomsR = new ArrayList<>(); location = POHLocation.TAVERLY; addRoom(HouseConstants.Room.GARDEN, 3, 3, 0, 0); getRoom(3, 3, 0).addObject(Builds.CENTREPIECE, 0); } public boolean addRoom(HouseConstants.Room room, int x, int y, int plane, int rotation) { return roomsR.add(new RoomReference(room, x, y, plane, rotation)); } /* * temporary */ public void reset() { build = 1; buildMode = true; roomsR = new ArrayList<>(); addRoom(HouseConstants.Room.GARDEN, 3, 3, 1, 0); getRoom(3, 3, 1).addObject(Builds.CENTREPIECE, 0); } public void init() { if (build == 0) reset(); players = new ArrayList<>(); refreshBuildMode(); refreshArriveInPortal(); refreshNumberOfRooms(); } public void refreshNumberOfRooms() { player.getPackets().sendVarc(944, roomsR.size()); } public void setArriveInPortal(boolean arriveInPortal) { this.arriveInPortal = arriveInPortal; refreshArriveInPortal(); } public boolean arriveOutsideHouse() { return arriveInPortal; } public void refreshArriveInPortal() { player.getVars().setVarBit(6450, arriveInPortal ? 1 : 0); } public void toggleChallengeMode(Player player) { if (isOwner(player)) { if (!challengeMode) setChallengeMode(true); else setChallengeMode(false); } else player.sendMessage(""Only the house owner can toggle challenge mode on or off.""); } public void setBuildMode(boolean buildMode) { if (this.buildMode == buildMode) return; this.buildMode = buildMode; if (loaded) { expelGuests(); if (isOwnerInside()) refreshHouse(); } refreshBuildMode(); } public void refreshBuildMode() { player.getVars().setVarBit(2176, buildMode ? 1 : 0); } public RoomReference getRoom(int x, int y, int plane) { for (RoomReference room : roomsR) if (room.x == x && room.y == y && room.plane == plane) return room; return null; } public RoomReference getRoom(GameObject o) { int roomX = o.getTile().getChunkX() - instance.getBaseChunkX(); int roomY = o.getTile().getChunkY() - instance.getBaseChunkY(); return getRoom(roomX, roomY, o.getPlane()); } public List getRooms() { return roomsR; } public RoomReference getRoom(Room room) { for (RoomReference roomR : roomsR) if (room == roomR.getRoom()) return roomR; return null; } public boolean isSky(int x, int y, int plane) { return buildMode && plane == 2 && getRoom((x / 8) - instance.getBaseChunkX(), (y / 8) - instance.getBaseChunkY(), plane) == null; } public void previewRoom(RoomReference reference, boolean remove) { if (!loaded) { Logger.debug(House.class, ""previewRoom"", ""Preview cancelled.""); return; } int boundX = instance.getLocalX(reference.x, 0); int boundY = instance.getLocalY(reference.y, 0); int realChunkX = reference.room.getChunkX(); int realChunkY = reference.room.getChunkY(); Chunk chunk = ChunkManager.getChunk(MapUtils.encode(Structure.CHUNK, reference.room.getChunkX(), reference.room.getChunkY(), look & 0x3), true); if (reference.plane == 0) for (int x = 0; x < 8; x++) for (int y = 0; y < 8; y++) { GameObject objectR = new GameObject(-1, ObjectType.SCENERY_INTERACT, reference.rotation, boundX + x, boundY + y, reference.plane); if (remove) World.removeObject(objectR); else World.spawnObject(objectR); } for (int x = 0; x < 8; x++) for (int y = 0; y < 8; y++) { GameObject[] objects = chunk.getBaseObjects(Tile.of((realChunkX << 3) + x, (realChunkY << 3) + y, look & 0x3)); if (objects != null) for (GameObject object : objects) { if (object == null) continue; ObjectDefinitions defs = object.getDefinitions(); if (reference.plane == 0 || defs.containsOption(4, ""Build"")) { GameObject objectR = new GameObject(object); int[] coords = InstancedChunk.transform(x, y, reference.rotation, defs.sizeX, defs.sizeY, object.getRotation()); objectR.setTile(Tile.of(boundX + coords[0], boundY + coords[1], reference.plane)); objectR.setRotation((object.getRotation() + reference.rotation) & 0x3); // just a preview. they're not realy there. if (remove) World.removeObject(objectR); else World.spawnObject(objectR); } } } } public void destroyHouse() { loaded = false; if (pets == null) pets = new CopyOnWriteArrayList<>(); if (npcs == null) npcs = new CopyOnWriteArrayList<>(); for (NPC npc : pets) if (npc != null) { npc.finish(); pets.remove(npc); } for (NPC npc : npcs) if (npc != null) { npc.finish(); npcs.remove(npc); } removeServant(); npcs.clear(); pets.clear(); if (instance != null) instance.destroy(); } private static final int[] DOOR_DIR_X = { -1, 0, 1, 1 }; private static final int[] DOOR_DIR_Y = { 0, 1, 0, -1 }; public void createHouse() { challengeMode = false; Object[][][][] data = new Object[4][8][8][]; // sets rooms data for (RoomReference reference : roomsR) data[reference.plane][reference.x][reference.y] = new Object[] { reference.room.getChunkX(), reference.room.getChunkY(), reference.rotation, reference.room.isShowRoof() }; // sets roof data if (!buildMode) for (int x = 1; x < 7; x++) skipY: for (int y = 1; y < 7; y++) for (int plane = 2; plane >= 1; plane--) if (data[plane][x][y] != null) { boolean hasRoof = (boolean) data[plane][x][y][3]; if (hasRoof) { byte rotation = (byte) data[plane][x][y][2]; // TODO find best Roof data[plane + 1][x][y] = new Object[] { HouseConstants.Roof.ROOF1.getChunkX(), HouseConstants.Roof.ROOF1.getChunkY(), rotation, true }; continue skipY; } } if (instance != null && !instance.isDestroyed()) instance.destroy(); instance = Instance.of(getLocation().getTile(), 8, 8); instance.requestChunkBound().thenAccept(e -> { List> regionBuilding = new ObjectArrayList<>(); for (int plane = 0; plane < data.length; plane++) { for (int x = 0; x < data[plane].length; x++) { for (int y = 0; y < data[plane][x].length; y++) { if (data[plane][x][y] != null) regionBuilding.add(instance.copyChunk(x, y, plane, (int) data[plane][x][y][0] + (look >= 4 ? 8 : 0), (int) data[plane][x][y][1], look & 0x3, (byte) data[plane][x][y][2])); else if ((x == 0 || x == 7 || y == 0 || y == 7) && plane == 1) regionBuilding.add(instance.copyChunk(x, y, plane, HouseConstants.BLACK[0], HouseConstants.BLACK[1], 0, 0)); else if (plane == 1) regionBuilding.add(instance.copyChunk(x, y, plane, HouseConstants.LAND[0] + (look >= 4 ? 8 : 0), HouseConstants.LAND[1], look & 0x3, 0)); else if (plane == 0) regionBuilding.add(instance.copyChunk(x, y, plane, HouseConstants.BLACK[0], HouseConstants.BLACK[1], 0, 0)); else regionBuilding.add(instance.clearChunk(x, y, plane)); } } } //Must async wait on these to complete or this task in itself will block the task queue from processing CompletableFuture.allOf(regionBuilding.toArray(new CompletableFuture[0])).thenRun(() -> { for (int chunkId : this.instance.getChunkIds()) { Chunk chunk = ChunkManager.getChunk(chunkId, true); for (GameObject object : chunk.getSpawnedObjects()) chunk.removeObject(object); } for (int chunkId : this.instance.getChunkIds()) { Chunk chunk = ChunkManager.getChunk(chunkId, true); for (GameObject object : chunk.getRemovedObjects().values()) chunk.removeObject(object); } for (RoomReference reference : roomsR) { for (int x = 0; x < 8; x++) for (int y = 0; y < 8; y++) { GameObject[] objects = ChunkManager.getChunk(instance.getChunkId(reference.x, reference.y, reference.plane)).getBaseObjects(x, y); if (objects != null) skip: for (GameObject object : objects) { if (object == null) continue; if (object.getDefinitions().containsOption(4, ""Build"") || (reference.room == Room.MENAGERIE && object.getDefinitions().getName().contains(""space""))) { if (isDoor(object)) { if (!buildMode && object.getPlane() == 2 && getRoom(((object.getX() / 8) - instance.getBaseChunkX()) + DOOR_DIR_X[object.getRotation()], ((object.getY() / 8) - instance.getBaseChunkY()) + DOOR_DIR_Y[object.getRotation()], object.getPlane()) == null) { GameObject objectR = new GameObject(object); objectR.setId(HouseConstants.WALL_IDS[look]); World.spawnObject(objectR); continue; } } else for (ObjectReference o : reference.objects) { int slot = o.build.getIdSlot(object.getId()); if (slot != -1) { GameObject objectR = new GameObject(object); if (o.getId(slot) == -1) World.spawnObject(new GameObject(-1, object.getType(), object.getRotation(), object.getTile())); else if (!spawnNpcs(slot, o, object)) { objectR.setId(o.getId(slot)); World.spawnObject(objectR); } continue skip; } } if (!buildMode) World.removeObject(object); } else if (object.getId() == HouseConstants.WINDOW_SPACE_ID) { object = new GameObject(object); object.setId(HouseConstants.WINDOW_IDS[look]); World.spawnObject(object); } else if (isDoorSpace(object)) World.removeObject(object); } } } if (!buildMode) if (getMenagerie() != null) for (Item item : petHouse.getPets().array()) if (item != null) addPet(item, false); teleportPlayer(player); player.setForceNextMapLoadRefresh(true); player.getTasks().schedule(1, () -> { player.getInterfaceManager().setDefaultTopInterface(); refreshServant(); }); if (player.getTempAttribs().getO(""CRef"") != null && player.getTempAttribs().getO(""CRef"") instanceof RoomReference toRoom) { player.getTempAttribs().removeO(""CRef""); teleportPlayer(player, toRoom); } player.lock(1); loaded = true; }); }); } public boolean containsAnyObject(int... ids) { for (int chunkId : this.instance.getChunkIds()) { Chunk chunk = ChunkManager.getChunk(chunkId, true); List spawnedObjects = chunk.getSpawnedObjects(); for (GameObject wo : spawnedObjects) for (int id : ids) if (wo.getId() == id) return true; } return false; } public void removePet(Item item, boolean update) { if (update && !isOwnerInside()) return; if (!buildMode) if (getMenagerie() != null) { Pets pet = Pets.forId(item.getId()); if (pet == null) return; int npcId = 0; if (pet.getGrownItemId() == item.getId()) npcId = pet.getGrownNpcId(); else npcId = pet.getBabyNpcId(); for (NPC npc : pets) if (npc != null && npc.getId() == npcId) { npc.finish(); pets.remove(npc); break; } } } public void addPet(Item item, boolean update) { if (update && !isOwnerInside()) return; if (!buildMode) if (getMenagerie() != null) { RoomReference men = getMenagerie(); Tile spawn = Tile.of(instance.getLocalX(men.x, 3), instance.getLocalY(men.y, 3), men.plane); Pets pet = Pets.forId(item.getId()); if (pet == null) return; NPC npc = new NPC(1, spawn); if (pet.getGrownItemId() == item.getId()) npc.setNPC(pet.getGrownNpcId()); else npc.setNPC(pet.getBabyNpcId()); pets.add(npc); npc.setRandomWalk(true); } } public boolean spawnNpcs(int slot, ObjectReference oRef, GameObject object) { if (buildMode) return false; if (oRef.getId(slot) == HouseConstants.HObject.ROCNAR.getId() || oRef.build == Builds.PITGUARD || oRef.build == Builds.GUARDIAN || oRef.build == Builds.GUARD2 || oRef.build == Builds.GUARD3 || oRef.build == Builds.GUARD4 || oRef.build == Builds.GUARD5) { if (oRef.getId(slot) == HouseConstants.HObject.DEMON.getId()) { spawnNPC(3593, object); return true; } if (oRef.getId(slot) == HouseConstants.HObject.KALPHITESOLDIER.getId()) { spawnNPC(3589, object); return true; } if (oRef.getId(slot) == HouseConstants.HObject.TOKXIL.getId()) { spawnNPC(3592, object); return true; } else if (oRef.getId(slot) == HouseConstants.HObject.DAGANNOTH.getId()) { spawnNPC(3591, object); return true; } else if (oRef.getId(slot) == HouseConstants.HObject.STEELDRAGON.getId()) { spawnNPC(3590, object); return true; } else if (oRef.getId(slot) == HouseConstants.HObject.SKELETON.getId()) { spawnNPC(3581, object); return true; } else if (oRef.getId(slot) == HouseConstants.HObject.GUARDDOG.getId()) { spawnNPC(3582, object); return true; } else if (oRef.getId(slot) == HouseConstants.HObject.HOBGOBLIN.getId()) { spawnNPC(3583, object); return true; } else if (oRef.getId(slot) == HouseConstants.HObject.BABYREDDRAGON.getId()) { spawnNPC(3588, object); return true; } else if (oRef.getId(slot) == HouseConstants.HObject.HUGESPIDER.getId()) { spawnNPC(3585, object); return true; } else if (oRef.getId(slot) == HouseConstants.HObject.HELLHOUND.getId()) { spawnNPC(3586, object); return true; } else if (oRef.getId(slot) == HouseConstants.HObject.TROLLGUARD.getId()) { spawnNPC(3584, object); return true; } else if (oRef.getId(slot) == HouseConstants.HObject.PITDOG.getId()) { spawnNPC(11585, object); return true; } else if (oRef.getId(slot) == HouseConstants.HObject.PITOGRE.getId()) { spawnNPC(11587, object); return true; } else if (oRef.getId(slot) == HouseConstants.HObject.PITROCKPROTECTER.getId()) { spawnNPC(11589, object); return true; } else if (oRef.getId(slot) == HouseConstants.HObject.PITSCABARITE.getId()) { spawnNPC(11591, object); return true; } else if (oRef.getId(slot) == HouseConstants.HObject.PITBLACKDEMON.getId()) { spawnNPC(11593, object); return true; } else if (oRef.getId(slot) == HouseConstants.HObject.PITIRONDRAGON.getId()) { spawnNPC(11595, object); return true; } else if (oRef.getId(slot) == HouseConstants.HObject.ROCNAR.getId()) { spawnNPC(3594, object); return true; } return false; } return false; } public void spawnNPC(int id, GameObject object) { NPC npc = new NPC(id, Tile.of(object.getX(), object.getY(), object.getPlane())); npcs.add(npc); npc.setRandomWalk(false); npc.setForceMultiArea(true); World.removeObject(object); } public boolean isWindow(int id) { return id == 13830; } public GameObject getWorldObjectForBuild(RoomReference reference, Builds build) { int boundX = instance.getLocalX(reference.x, 0); int boundY = instance.getLocalY(reference.y, 0); for (int x = -1; x < 8; x++) for (int y = -1; y < 8; y++) for (HObject piece : build.getPieces()) { GameObject object = World.getObjectWithId(Tile.of(boundX + x, boundY + y, reference.plane), piece.getId()); if (object != null) return object; } return null; } public GameObject getWorldObject(RoomReference reference, int id) { int boundX = instance.getLocalX(reference.x, 0); int boundY = instance.getLocalY(reference.y, 0); for (int x = -1; x < 8; x++) for (int y = -1; y < 8; y++) { GameObject object = World.getObjectWithId(Tile.of(boundX + x, boundY + y, reference.plane), id); if (object != null) return object; } return null; } public static class ObjectReference { private int slot; private final Builds build; public ObjectReference(Builds build, int slot) { this.build = build; this.slot = slot; } public HObject getPiece() { if (slot > build.getPieces().length - 1) { Logger.error(House.class, ""getPiece"", ""Error getting peice for "" + build.name()); return build.getPieces()[0]; } return build.getPieces()[slot]; } public int getId() { if (slot > build.getPieces().length - 1) { Logger.error(House.class, ""getId"", ""Error getting id for "" + build.name()); return build.getPieces()[0].getId(); } return build.getPieces()[slot].getId(); } public int getSlot() { return slot; } public void setSlot(int slot, GameObject object) { this.slot = slot; object.setId(build.getPieces()[slot].getId()); } public int[] getIds() { if (slot > build.getPieces().length - 1) { Logger.error(House.class, ""getIds"", ""Error getting ids for "" + build.name()); return build.getPieces()[0].getIds(); } return build.getPieces()[slot].getIds(); } public Builds getBuild() { return build; } public int getId(int slot2) { if (slot2 > getIds().length - 1) { Logger.error(House.class, ""getId"", ""Error getting id2 for "" + build.name()); return getIds()[0]; } return getIds()[slot2]; } } public static class RoomReference { public RoomReference(HouseConstants.Room room, int x, int y, int plane, int rotation) { this.room = room; this.x = (byte) x; this.y = (byte) y; this.plane = (byte) plane; this.rotation = (byte) rotation; objects = new ArrayList<>(); } public int getTrapObject() { for (ObjectReference object : objects) if (object.build.toString().contains(""FLOOR"")) return object.getPiece().getId(); return -1; } private final HouseConstants.Room room; private final byte x; private final byte y; private final byte plane; private byte rotation; private final List objects; public int getLadderTrapSlot() { for (ObjectReference object : objects) if (object.build.toString().contains(""OUB_LADDER"") || object.build.toString().contains(""TRAPDOOR"")) return object.slot; return -1; } public int getStaircaseSlot() { for (ObjectReference object : objects) if (object.build.toString().contains(""STAIRCASE"")) return object.slot; return -1; } public boolean isStaircaseDown() { for (ObjectReference object : objects) if (object.build.toString().contains(""STAIRCASE_DOWN"")) return true; return false; } /* * x,y inside the room chunk */ public ObjectReference addObject(Builds build, int slot) { ObjectReference ref = new ObjectReference(build, slot); objects.add(ref); return ref; } public ObjectReference getObject(GameObject object) { for (ObjectReference o : objects) for (int id : o.getIds()) if (object.getId() == id) return o; return null; } public int getHObjectSlot(HObject hObject) { for (ObjectReference o : objects) { if (o == null) continue; if (hObject.getId() == o.getPiece().getId()) return o.getSlot(); } return -1; } public boolean containsHObject(HObject hObject) { return getHObjectSlot(hObject) != -1; } public boolean containsBuild(Builds build) { return getBuildSlot(build) != -1; } public int getBuildSlot(Builds build) { for (ObjectReference o : objects) { if (o == null) continue; if (o.getBuild() == build) return o.getSlot(); } return -1; } public ObjectReference getBuild(Builds build) { for (ObjectReference o : objects) { if (o == null) continue; if (o.getBuild() == build) return o; } return null; } public ObjectReference removeObject(GameObject object) { ObjectReference r = getObject(object); if (r != null) { objects.remove(r); return r; } return null; } public void setRotation(int rotation) { this.rotation = (byte) rotation; } public byte getRotation() { return rotation; } public Room getRoom() { return room; } public int getZ() { return plane; } public int getX() { return x; } public int getY() { return y; } } public void changeLook(int look) { if (look > 6 || look < 0) return; this.look = (byte) look; } public void setPlayer(Player player) { this.player = player; if (petHouse == null) petHouse = new PetHouse(); if (pets == null) pets = new CopyOnWriteArrayList<>(); if (npcs == null) npcs = new CopyOnWriteArrayList<>(); petHouse.setPlayer(player); refreshServantVarBit(); } public Player getPlayer() { return player; } public List getPlayers() { return players; } public PetHouse getPetHouse() { return petHouse; } public void setPetHouse(PetHouse petHouse) { this.petHouse = petHouse; } public boolean isChallengeMode() { return challengeMode; } public void setChallengeMode(boolean challengeMode) { this.challengeMode = challengeMode; for (Player player : players) if (player != null && player.getControllerManager().getController() instanceof HouseController) { player.sendMessage(""The owner has turned "" + (challengeMode ? ""on"" : ""off"") + "" PVP dungeon challenge mode.""); player.sendMessage(""The dungeon is now "" + (challengeMode ? ""open"" : ""closed"") + "" to PVP combat.""); } } }" "package com.rs.game.content.skills.construction; public class HouseConstants { public static final int HAMMER = 2347, SAW = 8794, IRON_BAR = 2351, LIMESTONE_BRICKS = 3420, SOFT_CLAY = 1761, MARBLE_BLOCK = 8786, PLANK = 960, NAILS = 1539, OAK_PLANK = 8778, TEAK_PLANK = 8780, MAHOGANY_PLANK = 8782, BOLT_OF_CLOTH = 8790, STEEL_BAR = 2353, GOLD_LEAF = 8784, MAGIC_STONE = 8788, MOLTEN_GLASS = 1775; public static int WINDOW_SPACE_ID = 13830; public static int[] WINDOW_IDS = { 13099, 13091, 13005, 13112, 13011, 13117, 14354 }; public static int[] WALL_IDS = { 13098, 13090, 13004, 13111, 13011, 13116, 14354 }; public static int[] NAIL_IDS = { 1539, 4819, 4820, 4821, 4822, 4823, 4824 }; public static final int[] BEERS = { 1917, 5763, 1905, 1909, 1911, 5755 }; public static final Builds[] DINNER_BUILDS = { Builds.SHELVES, Builds.LARDER, Builds.KITCHEN_TABLE, Builds.STOVE }; public static final Builds[] TEA_BUILDS = { Builds.SHELVES, Builds.SINK, Builds.LARDER, Builds.KITCHEN_TABLE, Builds.STOVE }; public static final Builds[] DRINKS_BUILDS = { Builds.SHELVES, Builds.BARRELS }; public static final int[] BANKABLE_ITEMS = { PLANK, OAK_PLANK, TEAK_PLANK , MAHOGANY_PLANK, SOFT_CLAY, LIMESTONE_BRICKS, STEEL_BAR, BOLT_OF_CLOTH, GOLD_LEAF, MARBLE_BLOCK, MAGIC_STONE }; public enum Builds { // GARDEN CENTREPIECE(15361, false, HObject.EXIT_PORTAL, HObject.DECORATIVE_ROCK, HObject.POND, HObject.IMP_STATUE, HObject.DUNGEON_ENTRACE), BIG_TREE(15362, true, HObject.BIG_DEATH_TREE, HObject.BIG_NICE_TREE, HObject.BIG_OAK_TREE, HObject.BIG_WILLOW_TREE, HObject.BIG_MAPLE_TREE, HObject.BIG_YEW_TREE, HObject.BIG_MAGIC_TREE), TREE(15363, true, HObject.DEATH_TREE, HObject.NICE_TREE, HObject.OAK_TREE, HObject.WILLOW_TREE, HObject.MAPLE_TREE, HObject.YEW_TREE, HObject.MAGIC_TREE), SMALL_PLANT_1(15366, true, HObject.PLANT, HObject.SMALL_FERN, HObject.FERN), SMALL_PLANT_2(15367, true, HObject.DOCK_LEAF, HObject.THISTLE, HObject.REEDS), BIG_PLANT_1(15364, true, HObject.FERN_B, HObject.BUSH, HObject.TALL_PLANT), BIG_PLANT_2(15365, true, HObject.SHORT_PLANT, HObject.LARGE_LEAF_PLANT, HObject.HUGE_PLANT), // PARLOUR CHAIRS_1(15410, false, HObject.CRUDE_WOODEN_CHAIR, HObject.WOODEN_CHAIR, HObject.ROCKING_CHAIR, HObject.OAK_CHAIR, HObject.OAK_ARMCHAIR, HObject.TEAK_ARMCHAIR, HObject.MAHOGANY_ARMCHAIR), CHAIRS_2(15411, false, HObject.CRUDE_WOODEN_CHAIR, HObject.WOODEN_CHAIR, HObject.ROCKING_CHAIR, HObject.OAK_CHAIR, HObject.OAK_ARMCHAIR, HObject.TEAK_ARMCHAIR, HObject.MAHOGANY_ARMCHAIR), CHAIRS_3(15412, false, HObject.CRUDE_WOODEN_CHAIR, HObject.WOODEN_CHAIR, HObject.ROCKING_CHAIR, HObject.OAK_CHAIR, HObject.OAK_ARMCHAIR, HObject.TEAK_ARMCHAIR, HObject.MAHOGANY_ARMCHAIR), FIREPLACE(15418, false, HObject.CLAY_FIREPLACE, HObject.STONE_FIREPLACE, HObject.MARBLE_FIREPLACE), CURTAINS(15419, false, HObject.TORN_CURTAINS, HObject.CURTAINS, HObject.OPULENT_CURTAINS), BOOKCASE(15416, false, HObject.WOODEN_BOOKCASE, HObject.OAK_BOOKCASE, HObject.MAHOGANY_BOOKCASE), STAIRCASE(15380, false, HObject.OAK_STAIRCASE, HObject.TEAK_STAIRCASE, HObject.SPIRAL_STAIRCASE, HObject.MARBLE_STAIRCASE, HObject.MARBLE_SPIRAL), STAIRCASE_DOWN(15381, false, HObject.OAK_STAIRCASE_DOWN, HObject.TEAK_STAIRCASE_DOWN, HObject.SPIRAL_STAIRCASE, HObject.MARBLE_STAIRCASE_DOWN, HObject.MARBLE_SPIRAL), STAIRCASE_1(15390, false, HObject.OAK_STAIRCASE, HObject.TEAK_STAIRCASE, HObject.SPIRAL_STAIRCASE, HObject.MARBLE_STAIRCASE, HObject.MARBLE_SPIRAL), STAIRCASE_DOWN_1(15391, false, HObject.OAK_STAIRCASE_DOWN, HObject.TEAK_STAIRCASE_DOWN, HObject.SPIRAL_STAIRCASE, HObject.MARBLE_STAIRCASE_DOWN, HObject.MARBLE_SPIRAL), RUG(new int[] { 15415, 15414, 15413 }, false, HObject.BROWN_RUG, HObject.RUG, HObject.OPULENT_RUG), // TODO dungeon stair id STAIRCASE_2(15390, false, HObject.OAK_STAIRCASE, HObject.TEAK_STAIRCASE, HObject.SPIRAL_STAIRCASE, HObject.MARBLE_STAIRCASE, HObject.MARBLE_SPIRAL), // TROPHY ROOM HEAD_TROPHY(15382, false, HObject.CRAWLING_HAND, HObject.COCKATRICE_HEAD, HObject.BASALISK_HEAD, HObject.KURASK, HObject.ABBYSAL_DEMON, HObject.KING_BLACK_DRAGON, HObject.KALPHITE_QUEEN), MOUNTED_FISH(15383, false, HObject.MOUNTED_BASS, HObject.MOUNTED_SWORDFISH, HObject.MOUNTED_SHARK), RUNE_CASE(15386, false, HObject.RUNE_CASE_1, HObject.RUNE_CASE_2), DECORATIVE_ARMOUR(15384, false, HObject.BASIC_DECORATIVE, HObject.DETAILED_DECORATIVE, HObject.INTRICATE_DECORATIVE, HObject.PROFOUND_DECORATIVE), BASIC_ARMOURS(34255, false, HObject.MITHRIL_ARMOUR, HObject.ADAMANT_ARMOUR, HObject.RUNITE_ARMOUR), RUG_3(new int[] { 15379, 15378, 15377 }, false, HObject.RUG, HObject.OPULENT_RUG), // BED ROOM BED(15260, false, HObject.WOODEN_BED, HObject.OAK_BED, HObject.LARGE_OAK_BED, HObject.TEAK_BED, HObject.LARGE_TEAK_BED, HObject.MAHOGANY_BED, HObject.LARGE_MAHOGANY_BED), BEDROOM_FIREPLACE(15267, false, HObject.CLAY_FIREPLACE, HObject.STONE_FIREPLACE, HObject.MARBLE_FIREPLACE), BEDROOM_CURTAINS(15263, false, HObject.TORN_CURTAINS, HObject.CURTAINS, HObject.OPULENT_CURTAINS), DRESSERS(15262, false, HObject.SHAVING_STAND, HObject.OAK_SHAVING_STAND, HObject.OAK_DRESSER, HObject.TEAK_DRESSER, HObject.FANCY_TEAK_DRESSER, HObject.MAHOGANY_DRESSER, HObject.GILDED_DRESSER), CLOCKS(15268, false, HObject.OAK_CLOCK, HObject.TEAK_CLOCK, HObject.GILDED_CLOCK), WARDROBE(15261, false, HObject.SHOE_BOX, HObject.OAK_DRAWERS, HObject.OAK_WARDROBE, HObject.TEAK_DRAWERS, HObject.TEAK_WARDROBE, HObject.MAHOGANY_WARDROBE, HObject.GILDED_WARDROBE), RUG_B(new int[] { 15266, 15265, 15264 }, false, HObject.BROWN_RUG, HObject.RUG, HObject.OPULENT_RUG), //MENAGERIE OBELISK(44911, false, HObject.SMALLOBELISK), FEEDER(44910, false, HObject.OAKPETFEEDER, HObject.TEAKPETFEEDER, HObject.MAHOGANYPETFEEDER), PETHOUSE(44909, false, HObject.OAKPETHOUSE, HObject.TEAKPETHOUSE, HObject.MAHOGANYPETHOUSE, HObject.CONSECRATEDPETHOUSE, HObject.DESECRATEDPETHOUSE, HObject.NATURALPETHOUSE), HABITAT(new int[] {44843, 44844, 44845, 44846, 44847, 44848, 44849, 44850, 44851, 44852, 44853, 44854, 44855, 44856, 44857, 44858, 44859, 44860, 44861, 44862, 44863, 44864, 44865, 44866, 44867, 44868, 44869, 44870, 44871, 44872, 44873, 44874, 44875, 44876, 44877, 44878, 44879, 44880, 44881, 44882, 44883, 44884, 44885, 44886, 44887, 44888, 44889, 44890, 44891, 44892, 44893, 44894, 44895, 44896, 44897, 44898, 44899, 44900, 44901, 44902, 44903, 44904, 44905, 44906, 44907, 44908}, false, HObject.GARDEN_HABITAT, HObject.JUNGLE_HABITAT, HObject.DESERT_HABITAT, HObject.POLAR_HABITAT, HObject.VOLCANIC_HABITAT), //THRONE ROOM THRONE(15426, false, HObject.OAKTHRONE, HObject.TEAKTHRONE, HObject.MAHOGANYTHRONE, HObject.GILDEDTHRONE, HObject.SKELETONTHRONE, HObject.CRYSTALTHRONE, HObject.DEMONICTHRONE), LEVER(15435, false, HObject.OAKLEVER, HObject.TEAKLEVER, HObject.MAHOGANYLEVER), FLOOR(new int[] {15427, 15428, 15429, 15430, 15431, 15432}, false, HObject.FLOORDECORATION, HObject.STEELCAGE, HObject.TRAPDOOR, HObject.LESSERMAGICCAGE, HObject.GREATERMAGICCAGE), SEATING(new int[] {15436, 15437}, false, HObject.CARVEDTEAKBENCH, HObject.MAHOGANYBENCH, HObject.GILDEDBENCH), TRAPDOOR(15438, false, HObject.OAKTRAPDOOR, HObject.TEAKTRAPDOOR, HObject.MAHOGANYTRAPDOOR), //FORMAL GARDEN FENCING(15369, false, HObject.BOUNDARYSTONES, HObject.WOODENFENCE, HObject.STONEWALL, HObject.IRONRAILINGS, HObject.PICKETFENCE, HObject.GARDENFENCE, HObject.MARBLEWALL), HEDGING_FORM(new int[] { 15370, 15371, 15372 }, true, HObject.THORNYHEDGE, HObject.NICEHEDGE, HObject.SMALLBOXHEDGE, HObject.TOPIARYHEDGE, HObject.FANCYHEDGE, HObject.TALLFANCYHEDGE, HObject.TALLBOXHEDGE), CENTREPEICE_FORMAL(15368, false, HObject.EXITPORTAL, HObject.GAZEBO, HObject.DUNGEONENTRANCE, HObject.SMALLFOUNTAIN, HObject.LARGEFOUNTAIN, HObject.POSHFOUNTAIN), SMALL_PLANT1_FORM(15375, true, HObject.SUNFLOWER_S, HObject.MARIGOLDS_S, HObject.ROSES_S), SMALL_PLANT2_FORM(15376, true, HObject.ROSEMARY_S, HObject.DAFFODILS_S, HObject.BLUEBELLS_S), BIG_PLANT1_FORM(15373, true, HObject.SUNFLOWER, HObject.MARIGOLDS, HObject.ROSES), BIG_PLANT2_FORM(15374, true, HObject.ROSEMARY, HObject.DAFFODILS, HObject.BLUEBELLS), // KITCHEN LARDER(15403, false, HObject.WOODEN_LARDER, HObject.OAK_LARDER, HObject.TEAK_LARDER), SINK(15404, false, HObject.PUMP_AND_DRAIN, HObject.PUMP_AND_TUB, HObject.SINK), KITCHEN_TABLE(15405, false, HObject.WOODEN_KITCHEN_TABLE, HObject.OAK_KITCHEN_TABLE, HObject.TEAK_KITCHEN_TABLE), CAT_BLANKET(15402, false, HObject.CAT_BLANKET, HObject.CAT_BASKET, HObject.CUSHIONED_CAT_BASKET), STOVE(15398, false, HObject.FIREPIT, HObject.FIREPIT_WITH_HOOK, HObject.FIREPIT_WITH_POT, HObject.SMALL_OVEN, HObject.LARGE_OVEN, HObject.STEEL_RANGE, HObject.FANCY_RANGE), SHELVES(new int[] {15399, 15400}, false, HObject.WOODEN_SHELVES_1, HObject.WOODEN_SHELVES_2, HObject.WOODEN_SHELVES_3, HObject.OAK_SHELVES_1, HObject.OAK_SHELVES_2, HObject.TEAK_SHELVES_1, HObject.TEAK_SHELVES_2), BARRELS(15401, false, HObject.BEER_BARREL, HObject.CIDER_BARREL, HObject.ASGARNIAN_ALE, HObject.GREENMAN_ALE, HObject.DRAGON_BITTER_ALE, HObject.CHEFS_DELIGHT), // DINING ROOM FIREPLACE_DINING(15301, false, HObject.CLAY_FIREPLACE, HObject.STONE_FIREPLACE, HObject.MARBLE_FIREPLACE), DINING_TABLE(15298, false, HObject.WOOD_DINING, HObject.OAK_DINING, HObject.CARVED_OAK_DINING, HObject.TEAK_DINING, HObject.CARVED_TEAK_DINING, HObject.MAHOGANY_DINING, HObject.OPULENT_TABLE), DINING_CURTAINS(15302, false, HObject.TORN_CURTAINS, HObject.CURTAINS, HObject.OPULENT_CURTAINS), DINING_BENCH(new int[] {15299, 15300}, false, HObject.WOOD_BENCH, HObject.OAK_BENCH, HObject.CARVED_OAK_BENCH, HObject.TEAK_BENCH, HObject.CARVED_TEAK_BENCH, HObject.MAHOGANY_BENCH, HObject.GILDED_BENCH), ROPE_BELL_PULL(15304, false, HObject.ROPE_BELL_PULL, HObject.BELL_PULL, HObject.POSH_BELL_PULL), DECORATION(15303, false, HObject.OAK_DECORATION, HObject.TEAK_DECORATION, HObject.GILDED_DECORATION), // WORKSPACE REPAIR(15448, false, HObject.REPAIR_BENCH, HObject.WHETSTONE, HObject.ARMOUR_STAND), WORKBENCH(15439, false, HObject.WOODEN_WORKBENCH, HObject.OAK_WORKBENCH, HObject.STEEL_FRAMED_WORKBENCH, HObject.BENCH_WITH_VICE, HObject.BENCH_WITH__A_LATHE), CRAFTING(15441, false, HObject.CRAFTING_TABLE, HObject.CRAFTING_TABLE_2, HObject.CRAFTING_TABLE_3, HObject.CRAFTING_TABLE_4), TOOL1(15443, false, HObject.TOOL_STORE_1, HObject.TOOL_STORE_2, HObject.TOOL_STORE_3, HObject.TOOL_STORE_4, HObject.TOOL_STORE_5), TOOL2(15444, false, HObject.TOOL_STORE_1, HObject.TOOL_STORE_2, HObject.TOOL_STORE_3, HObject.TOOL_STORE_4, HObject.TOOL_STORE_5), TOOL3(15445, false, HObject.TOOL_STORE_1, HObject.TOOL_STORE_2, HObject.TOOL_STORE_3, HObject.TOOL_STORE_4, HObject.TOOL_STORE_5), TOOL4(15446, false, HObject.TOOL_STORE_1, HObject.TOOL_STORE_2, HObject.TOOL_STORE_3, HObject.TOOL_STORE_4, HObject.TOOL_STORE_5), TOOL5(15447, false, HObject.TOOL_STORE_1, HObject.TOOL_STORE_2, HObject.TOOL_STORE_3, HObject.TOOL_STORE_4, HObject.TOOL_STORE_5), HERALDRY(15450, false, HObject.PLUMING_STAND, HObject.SHIELD_EASEL, HObject.BANNER_EASEL), // COSTUME ROOM DRESS_BOX(18814, false, HObject.OAKCOSTUMEBOX, HObject.TEAKCOSTUMEBOX, HObject.MAHOGANYCOSTUMEBOX), TOY_BOX(18812, false, HObject.OAKTOYBOX, HObject.TEAKTOYBOX, HObject.MAHOGANYTOYBOX), CAPE_RACK(18810, false, HObject.OAKCAPERACK, HObject.TEAKCAPERACK, HObject.MAHOGANYCAPERACK, HObject.GILDEDCAPERACK, HObject.MARBLECAPERACK, HObject.MAGICALCAPERACK), WARDROBE_COST(18811, false, HObject.OAKMAGICWARDROBE, HObject.CARVEDOAKMAGICWARDROBE, HObject.TEAKMAGICWARDROBE, HObject.CARVEDTEAKMAGICWARDROBE, HObject.MAHOGANYMAGICWARDROBE, HObject.GILDEDMAGICWARDROBE, HObject.MARBLEMAGICWARDROBE), TREASURE_CHEST(18813, false, HObject.OAKTREASURECHEST, HObject.TEAKTREASURECHEST, HObject.MAHOGANYTREASURECHEST), ARMOR_CASE(18815, false, HObject.OAKARMOURCASE, HObject.TEAKARMOURCASE, HObject.MAHOGANYARMOURCASE), //DUNGEON LIGHTING_D(15355, false, HObject.CANDLE, HObject.TORCH, HObject.SKULLTORCH), RUG_D(15379, false, HObject.BROWN_RUG, HObject.RUG, HObject.OPULENT_RUG), // DOOR_D(36672, false, HObject.OAKDOOR, HObject.STEELPLATEDDOOR, HObject.MARBLEDOOR), // DOOR_D2(36675, false, HObject.OAKDOOR, HObject.STEELPLATEDDOOR, HObject.MARBLEDOOR), PITGUARD(36676, false, HObject.PITDOG, HObject.PITOGRE, HObject.PITROCKPROTECTER, HObject.PITSCABARITE, HObject.PITBLACKDEMON, HObject.PITIRONDRAGON), PITTRAP(new int[] {39229, 39230, 39231, 36692}, false, HObject.MINORPITTRAP, HObject.MAGORPITTRAP, HObject.SUPERIORPITTRAP), TRAP(15324, false, HObject.SPIKETRAP, HObject.MANTRAP, HObject.TANGLEVINE, HObject.MARBLETRAP, HObject.TELEPORTTRAP), TRAP2(15325, false, HObject.SPIKETRAP, HObject.MANTRAP, HObject.TANGLEVINE, HObject.MARBLETRAP, HObject.TELEPORTTRAP), GUARD2(15337, false, HObject.SKELETON, HObject.GUARDDOG,HObject.HOBGOBLIN, HObject.BABYREDDRAGON, HObject.HUGESPIDER, HObject.TROLLGUARD, HObject.HELLHOUND), GUARD3(15323, false, HObject.SKELETON, HObject.GUARDDOG,HObject.HOBGOBLIN, HObject.BABYREDDRAGON, HObject.HUGESPIDER, HObject.TROLLGUARD, HObject.HELLHOUND), GUARD4(15336, false, HObject.SKELETON, HObject.GUARDDOG,HObject.HOBGOBLIN, HObject.BABYREDDRAGON, HObject.HUGESPIDER, HObject.TROLLGUARD, HObject.HELLHOUND), GUARD5(15354, false, HObject.SKELETON, HObject.GUARDDOG,HObject.HOBGOBLIN, HObject.BABYREDDRAGON, HObject.HUGESPIDER, HObject.TROLLGUARD, HObject.HELLHOUND), OUB_CAGE(new int[] {15352, 15353}, false, HObject.OAK_CAGE, HObject.OAK_ST_CAGE, HObject.STEEL_CAGE, HObject.SPIKED_CAGE, HObject.BONE_CAGE), OUB_TRAP(new int[] {15347, 15348, 15349, 15350, 15351}, false, HObject.SPIKES, HObject.TENTACLES, HObject.FLAMES, HObject.ROCNAR), OUB_LADDER(15356, false, HObject.OAK_LADDER, HObject.TEAK_LADDER, HObject.MAHOGANY_LADDER), //TREASURE ROOM DECORATIVE2(15331, false, HObject.DECORATIVEBLOOD, HObject.DECORATIVEPIPE, HObject.HANGINGSKELETON), LIGHTING(15330, false, HObject.CANDLE, HObject.TORCH, HObject.SKULLTORCH), TREASURE(15256, false, HObject.WOODENCRATE, HObject.OAKCHEST, HObject.TEAKCHEST, HObject.MAHOGANYCHEST, HObject.MAGICCHEST), GUARDIAN(15257, false, HObject.DEMON, HObject.KALPHITESOLDIER, HObject.TOKXIL, HObject.DAGANNOTH, HObject.STEELDRAGON), DOOR(new int[] {15326, 15327, 15328, 15329}, false, HObject.OAKDOOR, HObject.STEELPLATEDDOOR, HObject.MARBLEDOOR), // GAMES ROOM ELEMENTAL_BALANCE(15345, false, HObject.ELEMENTAL_BALANCE_1, HObject.ELEMENTAL_BALANCE_2, HObject.ELEMENTAL_BALANCE_3), ATTACK_STONE(15344, false, HObject.CLAY_ATTACK_STONE, HObject.LIMESTONE_ATTACK_STONE, HObject.MARBLE_ATTACK_STONE), RANGING_GAME(15346, false, HObject.HOOP_AND_STICK, HObject.DART_BOARD, HObject.ARCHERY_TARGET), GAME(15342, false, HObject.JESTER, HObject.TREASURE_HUNT, HObject.HANGMAN), GAME_CHEST(15343, false, HObject.OAK_PRIZE_CHEST, HObject.TEAK_PRIZE_CHEST, HObject.GILDED_PRIZE_CHEST), // BOXING ROOM DECORATIONS(15297, false, HObject.OAK_DECORATION, HObject.TEAK_DECORATION, HObject.GILDED_DECORATION), WEAPONS_RACK(15296, false, HObject.GLOVE_RACK, HObject.WEAPON_RACK, HObject.EXTRA_WEAPON_RACK), COMBAT_RING(new int[] { 15277, 15278, 15279, 15280, 15281, 15282, 15286, 15287 // ring , 15289, 15290, 15294, 15295 // 2 side , 15288, 15291, 15293, 15292 }, false, HObject.BOXING_RING, HObject.FENCING_RING, HObject.COMBAT_RING), // 0side // QUEST ROOM QUEST_BOOKCASE(15397, false, HObject.WOODEN_BOOKCASE, HObject.OAK_BOOKCASE, HObject.MAHOGANY_BOOKCASE), SWORD(15395, false, HObject.SILVERLIGHT_SWORD, HObject.EXCALIBER_SWORD, HObject.DARKLIGHT_SWORD), MAP(15396, false, HObject.MAP_SMALL, HObject.MAP_MEDIUM, HObject.MAP_LARGE), LANDSCAPE(15393, false, HObject.LUMBRIDGE, HObject.DESERT, HObject.MORTANYIA, HObject.KARAMJA, HObject.ISFADAR), PORTRAIT(15392, false, HObject.KING_ARTHUR, HObject.ELENA, HObject.GIANT_DWARF, HObject.MISCELLENIA), GUILD_TROPHY(15394, false, HObject.ANTIDRAGON_SHIELD, HObject.GLORY, HObject.CAPE_OF_LEGENDS), // STUDY ROOM STUDY_BOOKCASE(15425, false, HObject.WOODEN_BOOKCASE, HObject.OAK_BOOKCASE, HObject.MAHOGANY_BOOKCASE), CHARTS(15423, false, HObject.ALCHEMICAL_CHART, HObject.ASTRONOMICAL_CHART, HObject.INFERNAL), LECTERN_STATUE(48662, false, HObject.LECTURN_STATUE), GLOBE(15421, false, HObject.GLOBE, HObject.ORNAMENTAL_GLOBE, HObject.LUNAR_GLOBE, HObject.CELESTIAL_GLOBE, HObject.ARMILLARY_SPHERE, HObject.SMALL_ORRERY, HObject.LARGE_ORRERY), LECTURN(15420, false, HObject.EAGLE_LECTURN, HObject.DEMON_LECTURN, HObject.TEAK_EAGLE_LECTURN, HObject.TEAK_DEMON_LECTURN, HObject.MAHOGANY_EAGLE_LECTURN, HObject.MAHOGANY_DEMON_LECTURN), CRYSTAL_BALL(15422, false, HObject.CRYSTAL_BALL, HObject.ELEMENTAL_SPHERE, HObject.CRYSTAL_OF_POWER), TELESCOPE(15424, false, HObject.WOODEN_TELESCOPE, HObject.TEAK_TELESCOPE, HObject.MAHOGANY_TELESCOPE), RUG_2(new int[] { 15389, 15388, 15387 }, false, HObject.RUG, HObject.OPULENT_RUG), // PORTAL ROOM PORTALS1(15406, false, HObject.PORTAL_FRAME_TEAK, HObject.PORTAL_FRAME_MAHOGANY, HObject.PORTAL_FRAME_MARBLE, HObject.VARROCK_PORTAL_TEAK, HObject.LUMBRIDGE_PORTAL_TEAK, HObject.FALADOR_PORTAL_TEAK, HObject.CAMELOT_PORTAL_TEAK, HObject.ARDOUGNE_PORTAL_TEAK, HObject.YANILLE_PORTAL_TEAK, HObject.KHARYRLL_PORTAL_TEAK, HObject.VARROCK_PORTAL_MAHOGANY, HObject.LUMBRIDGE_PORTAL_MAHOGANY, HObject.FALADOR_PORTAL_MAHOGANY, HObject.CAMELOT_PORTAL_MAHOGANY, HObject.ARDOUGNE_PORTAL_MAHOGANY, HObject.YANILLE_PORTAL_MAHOGANY, HObject.KHARYRLL_PORTAL_MAHOGANY, HObject.VARROCK_PORTAL_MARBLE, HObject.LUMBRIDGE_PORTAL_MARBLE, HObject.FALADOR_PORTAL_MARBLE, HObject.CAMELOT_PORTAL_MARBLE, HObject.ARDOUGNE_PORTAL_MARBLE, HObject.YANILLE_PORTAL_MARBLE, HObject.KHARYRLL_PORTAL_MARBLE), PORTALS2(15407, false, HObject.PORTAL_FRAME_TEAK, HObject.PORTAL_FRAME_MAHOGANY, HObject.PORTAL_FRAME_MARBLE, HObject.VARROCK_PORTAL_TEAK, HObject.LUMBRIDGE_PORTAL_TEAK, HObject.FALADOR_PORTAL_TEAK, HObject.CAMELOT_PORTAL_TEAK, HObject.ARDOUGNE_PORTAL_TEAK, HObject.YANILLE_PORTAL_TEAK, HObject.KHARYRLL_PORTAL_TEAK, HObject.VARROCK_PORTAL_MAHOGANY, HObject.LUMBRIDGE_PORTAL_MAHOGANY, HObject.FALADOR_PORTAL_MAHOGANY, HObject.CAMELOT_PORTAL_MAHOGANY, HObject.ARDOUGNE_PORTAL_MAHOGANY, HObject.YANILLE_PORTAL_MAHOGANY, HObject.KHARYRLL_PORTAL_MAHOGANY, HObject.VARROCK_PORTAL_MARBLE, HObject.LUMBRIDGE_PORTAL_MARBLE, HObject.FALADOR_PORTAL_MARBLE, HObject.CAMELOT_PORTAL_MARBLE, HObject.ARDOUGNE_PORTAL_MARBLE, HObject.YANILLE_PORTAL_MARBLE, HObject.KHARYRLL_PORTAL_MARBLE), PORTALS3(15408, false, HObject.PORTAL_FRAME_TEAK, HObject.PORTAL_FRAME_MAHOGANY, HObject.PORTAL_FRAME_MARBLE, HObject.VARROCK_PORTAL_TEAK, HObject.LUMBRIDGE_PORTAL_TEAK, HObject.FALADOR_PORTAL_TEAK, HObject.CAMELOT_PORTAL_TEAK, HObject.ARDOUGNE_PORTAL_TEAK, HObject.YANILLE_PORTAL_TEAK, HObject.KHARYRLL_PORTAL_TEAK, HObject.VARROCK_PORTAL_MAHOGANY, HObject.LUMBRIDGE_PORTAL_MAHOGANY, HObject.FALADOR_PORTAL_MAHOGANY, HObject.CAMELOT_PORTAL_MAHOGANY, HObject.ARDOUGNE_PORTAL_MAHOGANY, HObject.YANILLE_PORTAL_MAHOGANY, HObject.KHARYRLL_PORTAL_MAHOGANY, HObject.VARROCK_PORTAL_MARBLE, HObject.LUMBRIDGE_PORTAL_MARBLE, HObject.FALADOR_PORTAL_MARBLE, HObject.CAMELOT_PORTAL_MARBLE, HObject.ARDOUGNE_PORTAL_MARBLE, HObject.YANILLE_PORTAL_MARBLE, HObject.KHARYRLL_PORTAL_MARBLE), FOCUS(15409, false, HObject.TELEPORT_FOCUS, HObject.GREATER_FOCUS, HObject.SCRYING_POOL), // CHAPEL ALTAR(15270, false, HObject.OAK_ALTAR, HObject.TEAK_ALTAR, HObject.CLOTH_ALTAR, HObject.MAHOGANY_ALTAR, HObject.LIMESTONE_ALTAR, HObject.MARBLE_ALTAR, HObject.GUILDED_ALTAR), LAMP(15271, false, HObject.STEEL_TORCHES, HObject.WOODEN_TORCHES, HObject.STEEL_CANDLESTICK, HObject.GOLD_CANDLESTICK, HObject.INSCENCE_BURNER, HObject.MAHOGANY_BURNER, HObject.MARBLE_BURNER), ICON(15269, false, HObject.GUTHIX_SYMBOL, HObject.SARADOMIN_SYMBOL, HObject.ZAMORAK_SYMBOL, HObject.GUTHIX_ICON, HObject.SARADOMIN_ICON, HObject.ZAMORAK_ICON, HObject.ICON_OF_BOB), MUSICAL(15276, false, HObject.WINCHIMES, HObject.BELLS, HObject.ORGAN), RUG_CHAPEL(new int[] { 15274, 15273, 15274 }, false, HObject.BROWN_RUG, HObject.RUG, HObject.OPULENT_RUG), STATUES(15275, false, HObject.SMALL_STATUE, HObject.MEDIUM_STATUE, HObject.LARGE_STATUE), // todo find -1(Zenevivia) WINDOW(new int[] { 13730, 13728, 13732, 13729, 13733, 13731, 7101 }, false, HObject.SHUTTERED_WINDOW, HObject.DECORATIVE_WINDOW, HObject.STAINED_GLASS), ; private final int[] ids; private final boolean water; private final HObject[] pieces; Builds(int id, boolean water, HObject... pieces) { this(new int[] { id }, water, pieces); } Builds(int[] ids, boolean water, HObject... pieces) { this.ids = ids; this.water = water; this.pieces = pieces; } public boolean containsId(int id) { return getIdSlot(id) != -1; } public int getIdSlot(int id) { for (int i = 0; i < ids.length; i++) if (ids[i] == id) return i; return -1; } public int getId() { return ids[0]; } public int getIds() { return ids[0]; } public boolean containsObject(GameObject object) { for (HObject o : getPieces()) for (int id : o.getIds()) if (object.getId() == id) return true; return false; } public HObject[] getPieces() { return pieces; } public boolean isWater() { return water; } } public enum HObject { // GARDEN // CENTREPIECE EXIT_PORTAL(8168, 13405, 1, 100, new Item(IRON_BAR, 10)), DECORATIVE_ROCK(8169, 13406, 5, 100, new Item(LIMESTONE_BRICKS, 5)), POND(8170, 13407, 10, 100, new Item(SOFT_CLAY, 10)), IMP_STATUE(8171, 13408, 15, 150, new Item(LIMESTONE_BRICKS, 5), new Item(SOFT_CLAY, 5)), DUNGEON_ENTRACE(8172, 13409, 70, 500, new Item(MARBLE_BLOCK, 1)), // BIG TREE BIG_DEATH_TREE(8173, 13411, 5, 31, new Item(8417)), BIG_NICE_TREE(8174, 13412, 10, 44, new Item(8419)), BIG_OAK_TREE(8175, 13413, 15, 70, new Item(8421)), BIG_WILLOW_TREE(8176, 13414, 30, 100, new Item(8423)), BIG_MAPLE_TREE(8177, 13415, 45, 122, new Item(8425)), BIG_YEW_TREE(8178, 13416, 60, 141, new Item(8427)), BIG_MAGIC_TREE(8179, 13417, 75, 223, new Item(8429)), // TREE DEATH_TREE(8173, 13418, 5, 31, new Item(8417)), NICE_TREE(8174, 13419, 10, 44, new Item(8419)), OAK_TREE(8175, 13420, 15, 70, new Item(8421)), WILLOW_TREE(8176, 13421, 30, 100, new Item(8423)), MAPLE_TREE(8177, 13423, 45, 122, new Item(8425)), YEW_TREE(8178, 13422, 60, 141, new Item(8427)), MAGIC_TREE(8179, 13424, 75, 223, new Item(8429)), // SMALL PLANT 1 PLANT(8180, 13431, 1, 31, new Item(8431)), SMALL_FERN(8181, 13432, 6, 70, new Item(8433)), FERN(8182, 13433, 12, 100, new Item(8435)), // SMALL PLANT 2 DOCK_LEAF(8183, 13434, 1, 31, new Item(8431)), THISTLE(8184, 13435, 6, 70, new Item(8433)), REEDS(8185, 13436, 12, 100, new Item(8435)), // BIG PLANT 1 FERN_B(8186, 13425, 1, 31, new Item(8431)), BUSH(8187, 13426, 6, 70, new Item(8433)), TALL_PLANT(8188, 13427, 12, 100, new Item(8435)), // BIG PLANT 2 SHORT_PLANT(8189, 13428, 1, 31, new Item(8431)), LARGE_LEAF_PLANT(8190, 13429, 6, 70, new Item(8433)), HUGE_PLANT(8191, 13430, 12, 100, new Item(8435)), // PARLOUR // CHAIRS CRUDE_WOODEN_CHAIR(8309, 13581, 1, 66, new Item(PLANK, 2), new Item(NAILS, 2)), WOODEN_CHAIR(8310, 13582, 8, 96, new Item(PLANK, 3), new Item(NAILS, 3)), ROCKING_CHAIR(8311, 13583, 14, 99, new Item(PLANK, 3), new Item(NAILS, 3)), OAK_CHAIR(8312, 13584, 19, 120, new Item(OAK_PLANK, 2)), OAK_ARMCHAIR(8313, 13585, 26, 180, new Item(OAK_PLANK, 3)), TEAK_ARMCHAIR(8314, 13586, 35, 180, new Item(TEAK_PLANK, 2)), MAHOGANY_ARMCHAIR(8315, 13587, 50, 280, new Item(MAHOGANY_PLANK, 2)), // FIREPLACE CLAY_FIREPLACE(8325, 13609, 3, 30, new Item(SOFT_CLAY, 3)), STONE_FIREPLACE(8326, 13611, 33, 40, new Item(LIMESTONE_BRICKS, 2)), MARBLE_FIREPLACE(8327, 13613, 63, 500, new Item(MARBLE_BLOCK, 1)), // CURTAINS TORN_CURTAINS(8322, 13603, 2, 132, new Item(PLANK, 3), new Item(BOLT_OF_CLOTH, 3), new Item(NAILS, 3)), CURTAINS(8323, 13604, 18, 225, new Item(OAK_PLANK, 3), new Item(BOLT_OF_CLOTH, 3)), OPULENT_CURTAINS(8324, 13605, 40, 315, new Item(TEAK_PLANK, 3), new Item(BOLT_OF_CLOTH, 3)), // BOOKCASES WOODEN_BOOKCASE(8319, 13597, 4, 115, new Item(PLANK, 4), new Item(NAILS, 4)), OAK_BOOKCASE(8320, 13598, 29, 180, new Item(OAK_PLANK, 3)), MAHOGANY_BOOKCASE(8321, 13599, 40, 420, new Item(MAHOGANY_PLANK, 3)), // RUGS BROWN_RUG(8316, new int[] { 13588, 13589, 13590 }, 2, 30, new Item(BOLT_OF_CLOTH, 2)), RUG(8317, new int[] { 13591, 13592, 13593 }, 13, 60, new Item(BOLT_OF_CLOTH, 4)), OPULENT_RUG(8318, new int[] { 13594, 13595, 13596 }, 65, 360, new Item(BOLT_OF_CLOTH, 4), new Item(GOLD_LEAF, 1)), // TROHPY_ROOM // STAIRCASE OAK_STAIRCASE(8249, 13497, 27, 680, new Item(OAK_PLANK, 10), new Item(STEEL_BAR, 4)), OAK_STAIRCASE_DOWN(8249, 13498, 27, 680, new Item(OAK_PLANK, 10), new Item(STEEL_BAR, 4)), TEAK_STAIRCASE(8252, 13499, 48, 980, new Item(TEAK_PLANK, 10), new Item(STEEL_BAR, 4)), TEAK_STAIRCASE_DOWN(8258, 13500, 48, 980, new Item(TEAK_PLANK, 10), new Item(STEEL_BAR, 4)), SPIRAL_STAIRCASE(8258, 13503, 67, 1040, new Item(TEAK_PLANK, 10), new Item(LIMESTONE_BRICKS, 7)), MARBLE_STAIRCASE(8255, 13501, 82, 3200, new Item(MAHOGANY_PLANK, 5), new Item(MARBLE_BLOCK, 5)), MARBLE_STAIRCASE_DOWN(8255, 13502, 82, 3200, new Item(MAHOGANY_PLANK, 5), new Item(MARBLE_BLOCK, 5)), MARBLE_SPIRAL(8259, 13505, 97, 4400, new Item(TEAK_PLANK, 10), new Item(MARBLE_BLOCK, 7)), // HEAD_TROPHY CRAWLING_HAND(8260, 13481, 38, 211, new Item(TEAK_PLANK, 2), new Item(7982)), COCKATRICE_HEAD(8261, 13482, 38, 224, new Item(TEAK_PLANK, 2), new Item(7983)), BASALISK_HEAD(8262, 13483, 38, 243, new Item(TEAK_PLANK, 2), new Item(7984)), KURASK(8263, 13484, 58, 357, new Item(MAHOGANY_PLANK, 2), new Item(7985)), ABBYSAL_DEMON(8264, 13485, 58, 389, new Item(MAHOGANY_PLANK, 2), new Item(7986)), KING_BLACK_DRAGON(8265, 13486, 78, 1103, new Item(MAHOGANY_PLANK, 2), new Item(7987, 1), new Item(GOLD_LEAF, 2)), KALPHITE_QUEEN(8266, 13487, 78, 1103, new Item(MAHOGANY_PLANK, 2), new Item(7988, 1), new Item(GOLD_LEAF, 2)), // FISH_MANTEL MOUNTED_BASS(8267, 13488, 36, 151, new Item(OAK_PLANK, 2), new Item(7990)), MOUNTED_SWORDFISH(8268, 13489, 56, 230, new Item(TEAK_PLANK, 2), new Item(7992)), MOUNTED_SHARK(8269, 13490, 76, 350, new Item(MAHOGANY_PLANK, 2), new Item(7994)), // RUNE CASES RUNE_CASE_1(8276, 13507, 41, 190, new Item(TEAK_PLANK, 2), new Item(MOLTEN_GLASS, 2), new Item(554), new Item(555), new Item(556), new Item(557)), RUNE_CASE_2(8277, 13508, 41, 212, new Item(TEAK_PLANK, 2), new Item(MOLTEN_GLASS, 2), new Item(559), new Item(560), new Item(561), new Item(562)), // DECORATIVE ARMOR BASIC_DECORATIVE(8273, 34256, 28, 135, new Item(OAK_PLANK, 2), new Item(4069), new Item(4071), new Item(4072)), DETAILED_DECORATIVE(8274, 34263, 28, 150, new Item(OAK_PLANK, 2), new Item(4504), new Item(4506), new Item(4507)), INTRICATE_DECORATIVE(8275, 34280, 28, 165, new Item(OAK_PLANK, 2), new Item(4509), new Item(4511), new Item(4512)), PROFOUND_DECORATIVE(18755, 34281, 28, 180, new Item(OAK_PLANK, 2), new Item(18708), new Item(18707), new Item(18709)), // BASIC ARMOR MITHRIL_ARMOUR(8270, 13491, 28, 135, new Item(OAK_PLANK, 2), new Item(1159), new Item(1085), new Item(1121)), ADAMANT_ARMOUR(8271, 13492, 28, 150, new Item(OAK_PLANK, 2), new Item(1161), new Item(1091), new Item(1123)), RUNITE_ARMOUR(8272, 13493, 28, 165, new Item(OAK_PLANK, 2), new Item(1163), new Item(1093), new Item(1127)), //DUNGEON SKELETON(8131, 13366, 70, 223, new Item(995, 50000)), GUARDDOG(8132, 13367, 74, 273, new Item(995, 75000)), HOBGOBLIN(8133, 13368, 78, 316, new Item(995, 100000)), BABYREDDRAGON(8134, 13372, 82, 387, new Item(995 ,150000)), HUGESPIDER(8135, 13370, 86, 447, new Item(995, 200000)), TROLLGUARD(8136, 13369, 90, 1000, new Item(995, 1000000)), HELLHOUND(8137, 2715, 94, 2236, new Item(995, 5000000)), SPIKETRAP(8143, 13356, 72, 223, new Item(995, 50000)), MANTRAP(8144, 13357, 76, 273, new Item(995, 75000)), TANGLEVINE(8145, 13358,80, 316, new Item(995, 100000)), MARBLETRAP(8146, 13359, 84, 387, new Item(995, 150000)), TELEPORTTRAP(8147, 13360, 88, 447, new Item(995, 200000)), MINORPITTRAP(18797, new int[] {39266, 39266, 39266, 39266}, 71, 304, new Item(995, 45000), new Item(554, 500)), MAGORPITTRAP(18798, new int[] {39268, 39268, 39268, 39268}, 83, 1000, new Item(995, 125000), new Item(554, 2500)), SUPERIORPITTRAP(18799, new int[] {39270, 39270, 39270, 39270}, 96, 1100, new Item(995, 850000), new Item(554, 4500)), PITDOG(18791, 39260, 70, 200, new Item(995, 40000)), PITOGRE(18792, 39261, 73, 234, new Item(995, 55000)), PITROCKPROTECTER(18793, 32262, 79, 300, new Item(995, 90000)), PITSCABARITE(18794, 39263, 84, 387, new Item(995, 150000)), PITBLACKDEMON(18795, 39264, 89, 547, new Item(995, 300000)), PITIRONDRAGON(18796, 39265, 97, 2738, new Item(995, 1500000)), SPIKES(8302, new int[] {13334, 13335, 13336, -1, -1}, 65, 623, new Item(995, 50000), new Item(STEEL_BAR, 20)), TENTACLES(8303, new int[] {13331, 13332, 13333, -1, -1}, 71, 326, new Item(995, 100000), new Item(STEEL_BAR, 20)), FLAMES(8304, new int[] {-1, -1, -1, 13337, 13337}, 77, 357, new Item(995, 125000), new Item(STEEL_BAR, 20)), ROCNAR(8305, new int[] {-1, -1, -1, -1, 13373}, 93, 387, new Item(995, 150000), new Item(STEEL_BAR, 20)), OAK_CAGE(8297, new int[] {13313, 13314}, 65, 640, new Item(OAK_PLANK, 10), new Item(STEEL_BAR, 2)), OAK_ST_CAGE(8298, new int[] {13316, 13317}, 70, 800, new Item(OAK_PLANK, 10), new Item(STEEL_BAR, 10)), STEEL_CAGE(8299, new int[] {13319, 13320}, 75, 400, new Item(STEEL_BAR, 20)), SPIKED_CAGE(8300, new int[] {13322, 13323}, 80, 500, new Item(STEEL_BAR, 25)), BONE_CAGE(8301, new int[] {13325, 13326}, 85, 603, new Item(OAK_PLANK, 10), new Item(526, 10)), OAK_LADDER(8306, 13328, 68, 300, new Item(OAK_PLANK, 5)), TEAK_LADDER(8307, 13329, 78, 450, new Item(TEAK_PLANK, 5)), MAHOGANY_LADDER(8308, 13330, 88, 700, new Item(MAHOGANY_PLANK, 5)), //COSTUME ROOM //Treasure chest OAKTREASURECHEST(9839, 18804, 48, 120, new Item(8778, 2)), TEAKTREASURECHEST(9840, 18805, 66, 180, new Item(8780, 2)), MAHOGANYTREASURECHEST(9841, 18806, 84, 240, new Item(8782, 2)), //Armour case OAKARMOURCASE(9826, 18778, 46, 180, new Item(8778, 3)), TEAKARMOURCASE(9827, 18779, 64, 270, new Item(8780, 3)), MAHOGANYARMOURCASE(9828, 18780, 82, 420, new Item(8782, 3)), //Magic wardrobe OAKMAGICWARDROBE(9829, 18784, 42, 240, new Item(8778, 4)), CARVEDOAKMAGICWARDROBE(9830, 18786, 51, 360, new Item(8778, 6)), TEAKMAGICWARDROBE(9831, 18788, 60, 360, new Item(8780, 4)), CARVEDTEAKMAGICWARDROBE(9832, 18790, 69, 540, new Item(8780, 6)), MAHOGANYMAGICWARDROBE(9833, 18792, 78, 560, new Item(8782, 4)), GILDEDMAGICWARDROBE(9834, 18794, 87, 860, new Item(8784, 1), new Item(8782, 4)), MARBLEMAGICWARDROBE(9835, 18796, 96, 500, new Item(8786, 1)), //Cape rack OAKCAPERACK(9817, 18766, 54, 240, new Item(8778, 4)), TEAKCAPERACK(9818, 18767, 63, 360, new Item(8780, 4)), MAHOGANYCAPERACK(9819, 18768, 72, 560, new Item(8782, 4)), GILDEDCAPERACK(9820, 18769, 81, 860, new Item(8782, 4), new Item(8784, 1)), MARBLECAPERACK(9821, 18770, 90, 500, new Item(8786, 1)), MAGICALCAPERACK(9822, 18771, 99, 1000, new Item(8788, 1)), //Toy box OAKTOYBOX(9836, 18798, 50, 120, new Item(8778, 2)), TEAKTOYBOX(9837, 18799, 968, 180, new Item(8780, 2)), MAHOGANYTOYBOX(9838, 18800, 86, 280, new Item(8782, 2)), //Costume box OAKCOSTUMEBOX(9823, 18772, 44, 120, new Item(8778, 2)), TEAKCOSTUMEBOX(9824, 18773, 62, 180, new Item(8780, 2)), MAHOGANYCOSTUMEBOX(9825, 18774, 80, 280, new Item(8782, 2)), //MENAGERIE SMALLOBELISK(15236, 44837, 41, 676, new Item(8786, 1), new Item(12158, 10), new Item(12163, 10), new Item(12160, 10), new Item(12159, 10), new Item(12183, 1000)), OAKPETFEEDER(15233, 44834, 37, 240, new Item(8778, 4)), TEAKPETFEEDER(15234, 44835, 52, 380, new Item(8780, 4)), MAHOGANYPETFEEDER(15235, 44836, 67, 880, new Item(8782, 4), new Item(8784, 1)), OAKPETHOUSE(15227, 44828, 37, 240, new Item(8778, 4)), TEAKPETHOUSE(15228, 44829, 52, 380, new Item(8780, 4)), MAHOGANYPETHOUSE(15229, 44830, 67, 580, new Item(8782, 4)), CONSECRATEDPETHOUSE(15230, 44831, 92, 1580, new Item(8782, 4), new Item(8788, 1)), DESECRATEDPETHOUSE(15231, 44832, 92, 1580, new Item(8782, 4), new Item(8788, 1)), NATURALPETHOUSE(15232, 44833, 92, 1580, new Item(8782, 4), new Item(8788, 1)), GARDEN_HABITAT(15222, new int[] {44561, 44501, 44500, 44501, 44502, 44503, 44504, 44505, 44506, 44507, 44508, 44509, 44510, 44511, 44512, 44513, 44514, 44515, 44516, 44517, 44518, 44519, 44520, 44521, 44522, 44523, 44524, 44525, 44526, 44527, 44528, 44529, 44530, 44531, 44532, 44533, 44534, 44535, 44536, 44537, 44538, 44539, 44540, 44541, 44542, 44543, 44544, 44545, 44546, 44547, 44548, 44549, 44550, 44551, 44552, 44553, 44554, 44555, 44556, 44557, 44558, 44559, 44560, 44561, 44562, 44563}, 37, 201, new Item(8431, 1), new Item(8433, 1), new Item(8435, 1)), JUNGLE_HABITAT(15223, new int[] {44564, 44565, 44566, 44567, 44568, 44569, 44570, 44571, 44572, 44573, 44574, 44575, 44576, 44577, 44578, 44579, 44580, 44581, 44582, 44583, 44584, 44585, 44586, 44587, 44588, 44589, 44590, 44591, 44592, 44593, 44594, 44595, 44596, 44597, 44598, 44599, 44600, 44601, 44602, 44603, 44604, 44605, 44606, 44607, 44608, 44609, 44610, 44611, 44612, 44613, 44614, 44615, 44616, 44617, 44618, 44619, 44620, 44621, 44622, 44623, 44624, 44625, 44626, 44627, 44628, 44629}, 47, 278, new Item(1929, 5), new Item(8435, 3), new Item(8423, 1)), DESERT_HABITAT(15224, new int[] {44630, 44631, 44632, 44633, 44634, 44635, 44636, 44637, 44638, 44639, 44640, 44641, 44642, 44643, 44644, 44645, 44646, 44647, 44648, 44649, 44650, 44651, 44652, 44653, 44654, 44655, 44656, 44657, 44658, 44659, 44660, 44661, 44662, 44663, 44664, 44665, 44666, 44667, 44668, 44669, 44670, 44671, 44672, 44673, 44674, 44675, 44676, 44677, 44678, 44679, 44680, 44681, 44682, 44683, 44684, 44685, 44686, 44687, 44688, 44689, 44690, 44691, 44692, 44693, 44694, 44695}, 57, 238, new Item(1783, 10), new Item(LIMESTONE_BRICKS, 5), new Item(15237, 1)), POLAR_HABITAT(15225, new int[] {44696, 44697, 44698, 44699, 44700, 44701, 44702, 44703, 44704, 44705, 44706, 44707, 44708, 44709, 44710, 44711, 44712, 44713, 44714, 44715, 44716, 44717, 44718, 44719, 44720, 44721, 44722, 44723, 44724, 44725, 44726, 44727, 44728, 44729, 44730, 44731, 44732, 44733, 44734, 44735, 44736, 44737, 44738, 44739, 44740, 44741, 44742, 44743, 44744, 44745, 44746, 44747, 44748, 44749, 44750, 44751, 44752, 44753, 44754, 44755, 44756, 44757, 44758, 44759, 44760, 44761}, 67, 373, new Item(556, 1000), new Item(555, 1000), new Item(15239, 1)), VOLCANIC_HABITAT(15226, new int[] {44762, 44763, 44764, 44765, 44766, 44767, 44768, 44769, 44770, 44771, 44772, 44773, 44774, 44775, 44776, 44777, 44778, 44779, 44780, 44781, 44782, 44783, 44784, 44785, 44786, 44787, 44788, 44789, 44790, 44791, 44792, 44793, 44794, 44795, 44796, 44797, 44798, 44799, 44800, 44801, 44802, 44803, 44804, 44805, 44806, 44807, 44808, 44809, 44810, 44811, 44812, 44813, 44814, 44815, 44816, 44817, 44818, 44819, 44820, 44821, 44822, 44823, 44824, 44825, 44826, 44827}, 77, 1000, new Item(6570, 1)), //THRONE ROOM OAKTHRONE(8357, 13665, 60, 800, new Item(8778, 5), new Item(8786, 1)), TEAKTHRONE(8358, 13666, 67, 1450, new Item(8780, 5), new Item(8786, 2)), MAHOGANYTHRONE(8359, 13667, 74, 2200, new Item(8782, 5), new Item(8786, 3)), GILDEDTHRONE(8360, 13668, 81, 1700, new Item(8782, 5), new Item(8786, 2), new Item(8784, 3)), SKELETONTHRONE(8361, 13669, 88, 7003, new Item(8788, 5), new Item(8786, 4), new Item(964, 2), new Item(526, 5)), CRYSTALTHRONE(8362, 13670, 95, 15000, new Item(8788, 15)), DEMONICTHRONE(8363, 13671, 99, 25000, new Item(8788, 25)), OAKLEVER(8364, 13672, 68, 300, new Item(8778, 5)), TEAKLEVER(8365, 13673, 78, 450, new Item(8780, 5)), MAHOGANYLEVER(8366, 13674, 88, 700, new Item(8782, 5)), FLOORDECORATION(8370, new int[] {13689, 13689, 13689, 13689, 13689, 13689}, 61, 700, new Item(8782, 5)), // Needs to be looked over STEELCAGE(8371, new int[] {13688, 13688, 13688, 13688, 13688, 13688}, 68, 1100, new Item(8782, 5), new Item(2353, 20)), TRAPDOOR(8369, new int[] {13687, 13687, 13687, 13687, 13687, 13687}, 74, 770, new Item(8782, 5), new Item(8792, 10)), // Needs to be looked over LESSERMAGICCAGE(8373, new int[] {13686, 13686, 13686, 13686, 13686, 13686}, 82, 2700, new Item(8782, 5), new Item(8788, 2)), GREATERMAGICCAGE(8374, new int[] {13685, 13685, 13685, 13685, 13685, 13685}, 89, 4700, new Item(8782, 5), new Item(8788, 4)), CARVEDTEAKBENCH(8112, new int[] {13694, 13694}, 44, 360, new Item(8780,4)), MAHOGANYBENCH(8113, new int[] {13695, 13695}, 52, 560, new Item(8782, 4)), GILDEDBENCH(8114, new int[] {13696, 13696}, 61, 1760, new Item(8782, 4), new Item(8784, 4)), OAKTRAPDOOR(8367, 13675, 68, 300, new Item(8778, 5)), TEAKTRAPDOOR(8368, 13676, 78, 450, new Item(8780,5)), MAHOGANYTRAPDOOR(8369, 13677, 88, 700, new Item(8782, 5)), // BEDROOM SEX TIME // BEDS WOODEN_BED(8031, 13148, 20, 117, new Item(PLANK, 3), new Item(NAILS, 3), new Item(BOLT_OF_CLOTH, 2)), OAK_BED(8032, 13149, 30, 210, new Item(OAK_PLANK, 3), new Item(BOLT_OF_CLOTH, 2)), LARGE_OAK_BED(8033, 13150, 34, 330, new Item(OAK_PLANK, 5), new Item(BOLT_OF_CLOTH, 2)), TEAK_BED(8034, 13151, 40, 300, new Item(TEAK_PLANK, 3), new Item(BOLT_OF_CLOTH, 2)), LARGE_TEAK_BED(8035, 13152, 45, 480, new Item(TEAK_PLANK, 5), new Item(BOLT_OF_CLOTH, 2)), MAHOGANY_BED(8036, 13153, 53, 450, new Item(MAHOGANY_PLANK, 3), new Item(BOLT_OF_CLOTH, 2)), LARGE_MAHOGANY_BED(8037, 13154, 60, 1330, new Item(MAHOGANY_PLANK, 5), new Item(BOLT_OF_CLOTH, 2), new Item(GOLD_LEAF, 2)), // DRESSERS SHAVING_STAND(8045, 13162, 21, 30, new Item(PLANK, 1), new Item(NAILS, 1), new Item(MOLTEN_GLASS, 1)), OAK_SHAVING_STAND(8046, 13163, 29, 61, new Item(OAK_PLANK, 1), new Item(MOLTEN_GLASS, 1)), OAK_DRESSER(8047, 13164, 37, 121, new Item(OAK_PLANK, 2), new Item(MOLTEN_GLASS, 1)), TEAK_DRESSER(8048, 13165, 46, 181, new Item(TEAK_PLANK, 2), new Item(MOLTEN_GLASS, 1)), FANCY_TEAK_DRESSER(8049, 13166, 56, 182, new Item(TEAK_PLANK, 2), new Item(MOLTEN_GLASS, 2)), MAHOGANY_DRESSER(8050, 13167, 64, 261, new Item(MAHOGANY_PLANK, 2), new Item(MOLTEN_GLASS, 1)), GILDED_DRESSER(8051, 13168, 74, 582, new Item(MAHOGANY_PLANK, 2), new Item(MOLTEN_GLASS, 2), new Item(GOLD_LEAF, 1)), // CLOCKS OAK_CLOCK(8052, 13169, 25, 142, new Item(OAK_PLANK, 2), new Item(8792)), TEAK_CLOCK(8053, 13170, 25, 142, new Item(TEAK_PLANK, 2), new Item(8792)), GILDED_CLOCK(8054, 13171, 25, 142, new Item(MAHOGANY_PLANK, 2), new Item(8792, 1), new Item(GOLD_LEAF, 1)), // WARDROBE SHOE_BOX(8038, 13155, 20, 58, new Item(PLANK, 2), new Item(NAILS, 2)), OAK_DRAWERS(8039, 13156, 27, 120, new Item(OAK_PLANK, 2)), OAK_WARDROBE(8040, 13157, 39, 180, new Item(OAK_PLANK, 3)), TEAK_DRAWERS(8041, 13158, 51, 180, new Item(TEAK_PLANK, 2)), TEAK_WARDROBE(8042, 13159, 63, 270, new Item(TEAK_PLANK, 3)), MAHOGANY_WARDROBE(8043, 13160, 75, 420, new Item(MAHOGANY_PLANK, 3)), GILDED_WARDROBE(8044, 13161, 87, 720, new Item(MAHOGANY_PLANK, 3), new Item(GOLD_LEAF, 1)), // Portal Room // CENTER PIECE TELEPORT_FOCUS(8331, 13640, 50, 40, new Item(LIMESTONE_BRICKS, 2)), GREATER_FOCUS(8332, 13641, 65, 500, new Item(MARBLE_BLOCK, 1)), SCRYING_POOL(8333, 13639, 80, 2000, new Item(MARBLE_BLOCK, 4)), // PORTALS PORTAL_FRAME_TEAK(8328, 13636, 50, 270, new Item(8780, 3)), VARROCK_PORTAL_TEAK(8328, 13615, 80, 1500, new Item(563, 100), new Item(554, 100), new Item(556, 300)), LUMBRIDGE_PORTAL_TEAK(8328, 13616, 80, 1500, new Item(563, 100), new Item(557, 100), new Item(556, 300)), FALADOR_PORTAL_TEAK(8328, 13617, 80, 1500, new Item(563, 100), new Item(555, 100), new Item(556, 300)), CAMELOT_PORTAL_TEAK(8328, 13618, 80, 1500, new Item(563, 100), new Item(556, 500)), ARDOUGNE_PORTAL_TEAK(8328, 13619, 80, 1500, new Item(563, 200), new Item(555, 200)), YANILLE_PORTAL_TEAK(8328, 13620, 80, 1500, new Item(563, 200), new Item(557, 200)), KHARYRLL_PORTAL_TEAK(8328, 13621, 80, 1500, new Item(563, 200), new Item(565, 200)), PORTAL_FRAME_MAHOGANY(8329, 13637, 65, 420, new Item(8782, 3)), VARROCK_PORTAL_MAHOGANY(8329, 13622, 80, 1500, new Item(563, 100), new Item(554, 100), new Item(556, 300)), LUMBRIDGE_PORTAL_MAHOGANY(8329, 13623, 80, 1500, new Item(563, 100), new Item(557, 100), new Item(556, 300)), FALADOR_PORTAL_MAHOGANY(8329, 13624, 80, 1500, new Item(563, 100), new Item(555, 100), new Item(556, 300)), CAMELOT_PORTAL_MAHOGANY(8329, 13625, 80, 1500, new Item(563, 100), new Item(556, 500)), ARDOUGNE_PORTAL_MAHOGANY(8329, 13626, 80, 1500, new Item(563, 200), new Item(555, 200)), YANILLE_PORTAL_MAHOGANY(8329, 13627, 80, 1500, new Item(563, 200), new Item(557, 200)), KHARYRLL_PORTAL_MAHOGANY(8329, 13628, 80, 1500, new Item(563, 200), new Item(565, 200)), PORTAL_FRAME_MARBLE(8330, 13638, 80, 1500, new Item(8786, 3)), VARROCK_PORTAL_MARBLE(8330, 13629, 80, 1500, new Item(563, 100), new Item(554, 100), new Item(556, 300)), LUMBRIDGE_PORTAL_MARBLE(8330, 13630, 80, 1500, new Item(563, 100), new Item(557, 100), new Item(556, 300)), FALADOR_PORTAL_MARBLE(8330, 13631, 80, 1500, new Item(563, 100), new Item(555, 100), new Item(556, 300)), CAMELOT_PORTAL_MARBLE(8330, 13632, 80, 1500, new Item(563, 100), new Item(556, 500)), ARDOUGNE_PORTAL_MARBLE(8330, 13633, 80, 1500, new Item(563, 200), new Item(555, 200)), YANILLE_PORTAL_MARBLE(8330, 13634, 80, 1500, new Item(563, 200), new Item(557, 200)), KHARYRLL_PORTAL_MARBLE(8330, 13635, 80, 1500, new Item(563, 200), new Item(565, 200)), // KITCHEN // LARDER WOODEN_LARDER(8233, 13565, 9, 228, new Item(PLANK, 8), new Item(NAILS, 8)), OAK_LARDER(8234, 13566, 33, 480, new Item(OAK_PLANK, 8)), TEAK_LARDER(8235, 13567, 43, 750, new Item(TEAK_PLANK, 8), new Item(BOLT_OF_CLOTH, 2)), // SINK PUMP_AND_DRAIN(8230, 13559, 7, 100, new Item(STEEL_BAR, 5)), PUMP_AND_TUB(8231, 13561, 27, 200, new Item(STEEL_BAR, 10)), SINK(8232, 13563, 47, 300, new Item(STEEL_BAR, 15)), // KITCHEN TABLE WOODEN_KITCHEN_TABLE(8246, 13577, 12, 87, new Item(PLANK, 3), new Item(NAILS, 3)), OAK_KITCHEN_TABLE(8247, 13578, 32, 180, new Item(OAK_PLANK, 3)), TEAK_KITCHEN_TABLE(8248, 13579, 52, 270, new Item(TEAK_PLANK, 3)), // CAT BASKET CAT_BLANKET(8236, 13574, 5, 15, new Item(BOLT_OF_CLOTH, 1)), CAT_BASKET(8237, 13575, 19, 58, new Item(PLANK, 2), new Item(NAILS, 2)), CUSHIONED_CAT_BASKET(8238, 13576, 33, 58, new Item(PLANK, 2), new Item(NAILS, 2), new Item(1737, 2)), // STOVE FIREPIT(8216, 13528, 5, 40, new Item(STEEL_BAR, 1), new Item(SOFT_CLAY, 2)), FIREPIT_WITH_HOOK(8217, 13529, 11, 60, new Item(STEEL_BAR, 2), new Item(SOFT_CLAY, 2)), FIREPIT_WITH_POT(8218, 13531, 17, 80, new Item(STEEL_BAR, 3), new Item(SOFT_CLAY, 2)), SMALL_OVEN(8219, 13533, 24, 80, new Item(STEEL_BAR, 4)), LARGE_OVEN(8220, 13536, 29, 100, new Item(STEEL_BAR, 5)), STEEL_RANGE(8221, 13539, 34, 120, new Item(STEEL_BAR, 6)), FANCY_RANGE(8222, 13542, 42, 160, new Item(STEEL_BAR, 8)), // SHELVES WOODEN_SHELVES_1(8223, new int[] {13545, 13545}, 6, 87, new Item(PLANK, 3), new Item(NAILS, 3)), WOODEN_SHELVES_2(8224, new int[] {13546, 13546}, 12, 147, new Item(PLANK, 3), new Item(NAILS, 3), new Item(SOFT_CLAY, 3)), WOODEN_SHELVES_3(8225, new int[] {13547, 13547}, 23, 147, new Item(PLANK, 3), new Item(NAILS, 3), new Item(SOFT_CLAY, 6)), OAK_SHELVES_1(8226, new int[] {13548, 13548}, 34, 240, new Item(OAK_PLANK, 3), new Item(SOFT_CLAY, 6)), OAK_SHELVES_2(8227, new int[] {13549, 13549}, 45, 240, new Item(OAK_PLANK, 3), new Item(SOFT_CLAY, 6)), TEAK_SHELVES_1(8228, new int[] {13550, 13550}, 56, 330, new Item(TEAK_PLANK, 3), new Item(SOFT_CLAY, 6)), TEAK_SHELVES_2(8229, new int[] {13551, 13551}, 67, 930, new Item(TEAK_PLANK, 3), new Item(SOFT_CLAY, 6), new Item(GOLD_LEAF, 2)), // BARRELS BEER_BARREL(8239, 13568, 7, 87, new Item(PLANK, 3), new Item(NAILS, 3)), CIDER_BARREL(8240, 13569, 12, 91, new Item(PLANK, 3), new Item(NAILS, 3), new Item(5763, 8)), ASGARNIAN_ALE(8241, 13570, 18, 184, new Item(OAK_PLANK, 3), new Item(5763, 8)), GREENMAN_ALE(8242, 13571, 26, 184, new Item(OAK_PLANK, 3), new Item(1909, 8)), DRAGON_BITTER_ALE(8243, 13572, 36, 224, new Item(OAK_PLANK, 3), new Item(1911, 8), new Item(STEEL_BAR, 2)), CHEFS_DELIGHT(8243, 13572, 36, 224, new Item(OAK_PLANK, 3), new Item(5755, 8), new Item(STEEL_BAR, 2)), // DINING ROOM // DINING TABLES WOOD_DINING(8115, 13293, 10, 115, new Item(PLANK, 4), new Item(NAILS, 4)), OAK_DINING(8116, 13294, 22, 240, new Item(OAK_PLANK, 4)), CARVED_OAK_DINING(8117, 13295, 31, 360, new Item(OAK_PLANK, 6)), TEAK_DINING(8118, 13296, 38, 360, new Item(TEAK_PLANK, 4)), CARVED_TEAK_DINING(8119, 13297, 45, 600, new Item(TEAK_PLANK, 6), new Item(BOLT_OF_CLOTH, 4)), MAHOGANY_DINING(8120, 13298, 52, 840, new Item(MAHOGANY_PLANK, 6)), OPULENT_TABLE(8121, 13299, 72, 3100, new Item(MAHOGANY_PLANK, 6), new Item(BOLT_OF_CLOTH, 4), new Item(GOLD_LEAF, 2), new Item(MARBLE_BLOCK, 2)), // DINING BENCHES WOOD_BENCH(8108, new int[] {13300, 13300}, 10, 115, new Item(PLANK, 4), new Item(NAILS, 4)), OAK_BENCH(8109, new int[] {13301, 13301}, 22, 240, new Item(OAK_PLANK, 4)), CARVED_OAK_BENCH(8110, new int[] {13302, 13302}, 31, 240, new Item(OAK_PLANK, 4)), TEAK_BENCH(8111, new int[] {13303, 13303}, 38, 360, new Item(TEAK_PLANK, 4)), CARVED_TEAK_BENCH(8112, new int[] {13304, 13304}, 44, 360, new Item(TEAK_PLANK, 4)), MAHOGANY_BENCH(8113, new int[] {13305, 13305}, 52, 560, new Item(MAHOGANY_PLANK, 4)), GILDED_BENCH(8114, new int[] {13306, 13306}, 61, 1760, new Item(MAHOGANY_PLANK, 4), new Item(GOLD_LEAF, 4)), // ROPE PULL ROPE_BELL_PULL(8099, 13307, 26, 64, new Item(OAK_PLANK, 1), new Item(954, 1)), BELL_PULL(8100, 13308, 37, 120, new Item(TEAK_PLANK, 1), new Item(BOLT_OF_CLOTH, 2)), POSH_BELL_PULL(8101, 13309, 60, 420, new Item(TEAK_PLANK, 1), new Item(BOLT_OF_CLOTH, 2), new Item(GOLD_LEAF, 1)), // DECORATION OAK_DECORATION(8102, 13606, 16, 120, new Item(OAK_PLANK, 2)), TEAK_DECORATION(8103, 13607, 36, 180, new Item(TEAK_PLANK, 2)), GILDED_DECORATION(8104, 13608, 56, 1020, new Item(MAHOGANY_PLANK, 3), new Item(GOLD_LEAF, 2)), // WORKSPACE // REPAIR BENCH REPAIR_BENCH(8389, 13713, 15, 120, new Item(OAK_PLANK, 2)), WHETSTONE(8390, 13714, 35, 260, new Item(OAK_PLANK, 4), new Item(LIMESTONE_BRICKS, 1)), ARMOUR_STAND(8391, 13715, 55, 500, new Item(OAK_PLANK, 8), new Item(LIMESTONE_BRICKS, 1)), // HERALDRY PLUMING_STAND(8392, 13716, 16, 120, new Item(OAK_PLANK, 2)), SHIELD_EASEL(8393, 13717, 41, 240, new Item(OAK_PLANK, 4)), BANNER_EASEL(8394, 13718, 66, 510, new Item(OAK_PLANK, 8), new Item(BOLT_OF_CLOTH, 2)), // TOOL MOUNT TOOL_STORE_1(8384, 13699, 15, 120, new Item(OAK_PLANK, 2)), TOOL_STORE_2(8385, 13700, 25, 120, new Item(OAK_PLANK, 4)), TOOL_STORE_3(8386, 13701, 35, 120, new Item(OAK_PLANK, 6)), TOOL_STORE_4(8387, 13702, 44, 120, new Item(OAK_PLANK, 8)), TOOL_STORE_5(8388, 13703, 55, 121, new Item(OAK_PLANK, 10)), // CRAFTING TABLE CRAFTING_TABLE(8380, 13709, 16, 240, new Item(OAK_PLANK, 4)), CRAFTING_TABLE_2(8381, 13710, 25, 1, new Item(MOLTEN_GLASS, 1)), CRAFTING_TABLE_3(8382, 13711, 34, 2, new Item(MOLTEN_GLASS, 2)), CRAFTING_TABLE_4(8383, 13712, 42, 120, new Item(OAK_PLANK, 2)), // WORKBENCH WOODEN_WORKBENCH(8375, 13704, 17, 143, new Item(PLANK, 5), new Item(NAILS, 5)), OAK_WORKBENCH(8376, 13705, 32, 300, new Item(OAK_PLANK, 5)), STEEL_FRAMED_WORKBENCH(8377, 13706, 46, 440, new Item(OAK_PLANK, 6), new Item(STEEL_BAR, 4)), BENCH_WITH_VICE(8378, 13707, 62, 140, new Item(OAK_PLANK, 2), new Item(STEEL_BAR, 1)), BENCH_WITH__A_LATHE(8379, 13708, 77, 140, new Item(OAK_PLANK, 2), new Item(STEEL_BAR, 1)), // GAMES ROOM // COMBAT STONE CLAY_ATTACK_STONE(8153, 13392, 39, 100, new Item(SOFT_CLAY, 10)), LIMESTONE_ATTACK_STONE(8154, 13393, 59, 200, new Item(LIMESTONE_BRICKS, 10)), MARBLE_ATTACK_STONE(8154, 13393, 59, 2000, new Item(MARBLE_BLOCK, 4)), // RANGING GAME HOOP_AND_STICK(8162, 13399, 30, 120, new Item(OAK_PLANK, 2)), DART_BOARD(8163, 13400, 54, 290, new Item(TEAK_PLANK, 3), new Item(STEEL_BAR, 1)), ARCHERY_TARGET(8164, 13402, 81, 600, new Item(TEAK_PLANK, 6), new Item(STEEL_BAR, 3)), // PRIZE CHEST OAK_PRIZE_CHEST(8165, 13385, 34, 240, new Item(OAK_PLANK, 4)), TEAK_PRIZE_CHEST(8166, 13387, 44, 660, new Item(TEAK_PLANK, 4)), GILDED_PRIZE_CHEST(8167, 13389, 44, 860, new Item(MAHOGANY_PLANK, 4), new Item(GOLD_LEAF, 1)), // ELEMENTAL BALANCE ELEMENTAL_BALANCE_1(8156, 13395, 37, 176, new Item(554, 500), new Item(555, 500), new Item(556, 500), new Item(557, 500)), ELEMENTAL_BALANCE_2(8157, 13396, 57, 252, new Item(554, 1000), new Item(555, 1000), new Item(556, 1000), new Item(557, 1000)), ELEMENTAL_BALANCE_3(8158, 13397, 77, 356, new Item(554, 2000), new Item(555, 2000), new Item(556, 2000), new Item(557, 2000)), // GAME SPACE JESTER(8159, 13390, 39, 360, new Item(TEAK_PLANK, 4)), TREASURE_HUNT(8160, 13379, 49, 800, new Item(TEAK_PLANK, 8), new Item(STEEL_BAR, 4)), HANGMAN(8161, 13404, 59, 1200, new Item(TEAK_PLANK, 12), new Item(STEEL_BAR, 6)), // BOXING ROOM // COMBAT RING GLOVE_RACK(8028, 13381, 34, 120, new Item(OAK_PLANK, 2)), WEAPON_RACK(8029, 13382, 44, 180, new Item(TEAK_PLANK, 2)), EXTRA_WEAPON_RACK(8030, 13383, 54, 440, new Item(TEAK_PLANK, 4), new Item(STEEL_BAR, 4)), BOXING_RING(8023, new int[] { 13129, 13129, 13129, 13129, 13129, 13129, 13129, 13129, 13126, 13126, 13126, 13126, 13128, 13128, 13128, 13127 }, 32, 570, new Item(OAK_PLANK, 6), new Item(BOLT_OF_CLOTH, 4)), FENCING_RING(8024, new int[] { 13133, 13133, 13133, 13133, 13133, 13133, 13133, 13133, 13135, 13135, 13135, 13135, 13134, 13134, 13134, 13136 }, 31, 570, new Item(OAK_PLANK, 6), new Item(BOLT_OF_CLOTH, 6)), COMBAT_RING(8025, new int[] { 13137, 13137, 13137, 13137, 13137, 13137, 13137, 13137, 13138, 13138, 13138, 13138, 13139, 13139, 13139, 13140 }, 51, 630, new Item(TEAK_PLANK, 6), new Item(BOLT_OF_CLOTH, 6)), // MAP SPACE MAP_SMALL(8294, 13525, 38, 211, new Item(TEAK_PLANK, 3), new Item(8004, 1)), MAP_MEDIUM(8295, 13526, 58, 451, new Item(MAHOGANY_PLANK, 3), new Item(8005, 1)), MAP_LARGE(8296, 13527, 78, 591, new Item(MAHOGANY_PLANK, 4), new Item(8006, 1)), // SWORD SILVERLIGHT_SWORD(8279, 13519, 42, 187, new Item(TEAK_PLANK, 2), new Item(2402, 1)), EXCALIBER_SWORD(8280, 13521, 42, 194, new Item(TEAK_PLANK, 2), new Item(35, 1)), DARKLIGHT_SWORD(8281, 13520, 42, 202, new Item(TEAK_PLANK, 2), new Item(6746, 1)), // GUILD_TROPHY ANTIDRAGON_SHIELD(8282, 13522, 47, 280, new Item(TEAK_PLANK, 3), new Item(1540, 1)), GLORY(8283, 13523, 47, 290, new Item(TEAK_PLANK, 3), new Item(1704, 1)), CAPE_OF_LEGENDS(8284, 13524, 47, 300, new Item(TEAK_PLANK, 3), new Item(1052, 1)), // PORTRAIT KING_ARTHUR(8285, 13510, 35, 211, new Item(TEAK_PLANK, 2), new Item(7995)), ELENA(8286, 13511, 35, 211, new Item(TEAK_PLANK, 2), new Item(7996)), GIANT_DWARF(8287, 13512, 35, 211, new Item(TEAK_PLANK, 2), new Item(7997)), MISCELLENIA(8288, 13513, 55, 311, new Item(MAHOGANY_PLANK, 2), new Item(7998)), // LANDSCAPE LUMBRIDGE(8289, 13517, 44, 314, new Item(TEAK_PLANK, 3), new Item(8002, 1)), DESERT(8290, 13514, 44, 314, new Item(TEAK_PLANK, 3), new Item(7999, 1)), MORTANYIA(8291, 13518, 44, 314, new Item(TEAK_PLANK, 3), new Item(8003, 1)), KARAMJA(8292, 13516, 65, 464, new Item(MAHOGANY_PLANK, 3), new Item(8001, 1)), ISFADAR(8293, 13515, 65, 464, new Item(MAHOGANY_PLANK, 3), new Item(8000, 1)), //TREASURE ROOM DECORATIVEBLOOD(8125, 13312,72,4,new Item(1763, 4)), DECORATIVEPIPE(8126, 13311, 83, 120, new Item(2353, 6)), HANGINGSKELETON(8127, 13310, 94, 3, new Item(964, 2), new Item(526, 2)), CANDLE(8128, 13342, 72, 243, new Item(8778, 4), new Item(33, 4)), TORCH(8129, 13341, 84, 244, new Item(8778, 4), new Item(594, 4)), SKULLTORCH(8130, 13343, 94, 246, new Item(8778, 4), new Item(594, 4), new Item(964, 4)), WOODENCRATE(8148, 13283, 75, 143, new Item(960, 5), new Item(1539, 5)), OAKCHEST(8149, 13285, 79, 340, new Item(8778, 5), new Item(2353, 2)), TEAKCHEST(8150, 13287, 83, 530, new Item(8780, 5), new Item(2353, 4)), MAHOGANYCHEST(8151, 13289, 87, 1000, new Item(8782, 5), new Item(8784, 1)), MAGICCHEST(8152, 13291, 91, 1000, new Item(8788, 1)), DEMON(8138, 13378, 75, 707, new Item(995, 500000)), KALPHITESOLDIER(8139, 13374, 80, 866, new Item(995, 750000)), TOKXIL(8140, 13377, 85, 2236, new Item(995, 5000000)), DAGANNOTH(8141, 13376, 90, 2738, new Item(995, 7500000)), STEELDRAGON(8142, 13375, 95, 3162, new Item(995, 10000000)), OAKDOOR(8122, new int[] {13344, 13345, 13344, 13345}, 74, 600, new Item(8778, 10)), STEELPLATEDDOOR(8123, new int[] {13346, 13347, 13346, 13347}, 84, 800, new Item(8778, 10), new Item(2353, 10)), MARBLEDOOR(8124, new int[] {13348, 13349, 13348, 13349}, 94, 2000, new Item(8786, 4)), // STUDY ROOM // CHARTS ALCHEMICAL_CHART(8354, 13662, 43, 30, new Item(BOLT_OF_CLOTH, 2)), ASTRONOMICAL_CHART(8355, 13663, 63, 45, new Item(BOLT_OF_CLOTH, 3)), INFERNAL(8356, 13664, 83, 60, new Item(BOLT_OF_CLOTH, 4)), // TELESCOPE WOODEN_TELESCOPE(8348, 13656, 44, 121, new Item(OAK_PLANK, 2), new Item(MOLTEN_GLASS, 1)), TEAK_TELESCOPE(8349, 13657, 64, 181, new Item(TEAK_PLANK, 2), new Item(MOLTEN_GLASS, 1)), MAHOGANY_TELESCOPE(8350, 13658, 84, 580, new Item(MAHOGANY_PLANK, 2), new Item(MOLTEN_GLASS, 1)), // CRYSTAL BALL CRYSTAL_BALL(8351, 13659, 42, 280, new Item(TEAK_PLANK, 3), new Item(567, 1)), ELEMENTAL_SPHERE(8352, 13660, 54, 580, new Item(TEAK_PLANK, 3), new Item(567, 1), new Item(GOLD_LEAF, 1)), CRYSTAL_OF_POWER(8353, 13661, 66, 890, new Item(MAHOGANY_PLANK, 2), new Item(567, 1), new Item(GOLD_LEAF, 2)), // GLOBE GLOBE(8341, 13649, 41, 180, new Item(OAK_PLANK, 3)), ORNAMENTAL_GLOBE(8342, 13650, 50, 270, new Item(TEAK_PLANK, 3)), LUNAR_GLOBE(8343, 13651, 59, 570, new Item(TEAK_PLANK, 3), new Item(GOLD_LEAF, 1)), CELESTIAL_GLOBE(8344, 13652, 68, 570, new Item(TEAK_PLANK, 3), new Item(GOLD_LEAF, 1)), ARMILLARY_SPHERE(8345, 13653, 77, 960, new Item(MAHOGANY_PLANK, 2), new Item(GOLD_LEAF, 2), new Item(STEEL_BAR, 4)), SMALL_ORRERY(8346, 13654, 86, 1320, new Item(MAHOGANY_PLANK, 3), new Item(GOLD_LEAF, 3)), LARGE_ORRERY(8347, 13655, 95, 1420, new Item(MAHOGANY_PLANK, 3), new Item(GOLD_LEAF, 5)), // LECTURNS OAK_LECTURN(8334, 13642, 40, 60, new Item(OAK_PLANK, 1)), EAGLE_LECTURN(8335, 13643, 47, 120, new Item(OAK_PLANK, 2)), DEMON_LECTURN(8336, 13644, 47, 120, new Item(OAK_PLANK, 2)), TEAK_EAGLE_LECTURN(8337, 13645, 57, 180, new Item(TEAK_PLANK, 2)), TEAK_DEMON_LECTURN(8338, 13646, 57, 180, new Item(TEAK_PLANK, 2)), MAHOGANY_EAGLE_LECTURN(8339, 13647, 67, 580, new Item(MAHOGANY_PLANK, 2), new Item(GOLD_LEAF, 1)), MAHOGANY_DEMON_LECTURN(8340, 13648, 67, 580, new Item(MAHOGANY_PLANK, 2), new Item(GOLD_LEAF, 1)), // STATUE I'ma just make it auto-completed LECTURN_STATUE(15521, 48642, 1, 1.5, new Item(MAHOGANY_PLANK, 2), new Item(STEEL_BAR, 10)), //Formal garden //Centrepiece EXITPORTAL(8168, 13405, 1, 100, new Item(2351, 10)), GAZEBO(8192, 13477, 65, 1200, new Item(8782, 8), new Item(2353, 4)), DUNGEONENTRANCE(8172, 13409,70, 500, new Item(8786, 1)), SMALLFOUNTAIN(8193, 13478, 71, 500, new Item(8786, 1)), LARGEFOUNTAIN(8194, 13479, 75, 1000, new Item(8786, 2)), POSHFOUNTAIN(8195, 13480, 81, 1500, new Item(8786, 3)), //Small Plants 1 - Multiple object ids ROSEMARY_S(8210, 13440, 66, 70, new Item(8451, 1)), DAFFODILS_S(8211, 13441, 71, 100, new Item(8453, 1)), BLUEBELLS_S(8212, 13442, 76, 122, new Item(8455, 1)), //Small Plants 2 SUNFLOWER_S(8213, 13446, 66, 70, new Item(8457, 1)), MARIGOLDS_S(8214, 13447, 71, 100, new Item(8459, 1)), ROSES_S(8215, 13448, 76, 122, new Item(8461, 1)), //Big Plants 1 - Multiple object ids ROSEMARY(8210, 13437, 66, 70, new Item(8451, 1)), DAFFODILS(8211, 13438, 71, 100, new Item(8453, 1)), BLUEBELLS(8212, 13439, 76, 122, new Item(8455, 1)), //Big Plants 2 SUNFLOWER(8213, 13443, 66, 70, new Item(8457, 1)), MARIGOLDS(8214, 13444, 71, 100, new Item(8459, 1)), ROSES(8215, 13445, 76, 122, new Item(8461, 1)), //Hedging - Multiple object ids, could be wrong with ones below THORNYHEDGE(8203, new int[] {13456, 13458, 13457}, 56, 70, new Item(8437, 1)), NICEHEDGE(8204, new int[] {13459, 13461, 13460}, 60, 100, new Item(8439, 1)), SMALLBOXHEDGE(8205, new int[] {13462, 13464, 13463}, 64, 122, new Item(8441, 1)), TOPIARYHEDGE(8206, new int[] {13465, 13467, 13466}, 68, 141, new Item(8443, 1)), FANCYHEDGE(8207, new int[] {13468, 13470, 13469}, 72, 158, new Item(8445, 1)), TALLFANCYHEDGE(8208, new int[] {13471, 13473, 13472}, 76, 223, new Item(8447, 1)), TALLBOXHEDGE(8209, new int[] {13474, 13476, 13475}, 80, 316, new Item(8449, 1)), //Fencing BOUNDARYSTONES(8196, 13449, 55, 100, new Item(1761, 10)), WOODENFENCE(8197, 13450, 59, 280, new Item(960, 10)), STONEWALL(8198, 13451, 63, 200, new Item(3420, 10)), IRONRAILINGS(8199, 13452, 67, 220, new Item(2351, 10), new Item(3420, 6)), PICKETFENCE(8200, 13453, 71, 640, new Item(8778, 10), new Item(2353, 2)), GARDENFENCE(8201, 13454, 75, 940, new Item(8780, 10), new Item(2353, 2)), MARBLEWALL(8202, 13455, 79, 4000, new Item(8786, 8)), // COSTUME ROOM // TREASURE CHEST OAK_TREASURE_CHEST(9839, 18804, 48, 120, new Item(OAK_PLANK, 2)), TEAK_TREASURE_CHEST(9840, 18806, 66, 180, new Item(TEAK_PLANK, 2)), MAHOGANY_TREASURE_CHEST(9841, 18808, 84, 280, new Item(MAHOGANY_PLANK, 2)), // ARMOUR CASE OAK_ARMOUR_CASE(9826, 18778, 46, 180, new Item(OAK_PLANK, 3)), TEAK_ARMOUR_CASE(9827, 18780, 64, 270, new Item(TEAK_PLANK, 3)), MAHOGANY_ARMOUR_CASE(9828, 18782, 82, 420, new Item(MAHOGANY_PLANK, 3)), // MAGIC WARDROBE // CHAPEL // ALTAR OAK_ALTAR(8062, 13179, 45, 240, new Item(OAK_PLANK, 4)), TEAK_ALTAR(8063, 13182, 50, 360, new Item(TEAK_PLANK, 4)), CLOTH_ALTAR(8064, 13185, 56, 390, new Item(TEAK_PLANK, 4), new Item(BOLT_OF_CLOTH, 2)), MAHOGANY_ALTAR(8065, 13188, 60, 590, new Item(MAHOGANY_PLANK, 4), new Item(BOLT_OF_CLOTH, 2)), LIMESTONE_ALTAR(8066, 13191, 64, 910, new Item(MAHOGANY_PLANK, 6), new Item(BOLT_OF_CLOTH, 2), new Item(LIMESTONE_BRICKS, 2)), MARBLE_ALTAR(8067, 13194, 70, 1030, new Item(MARBLE_BLOCK, 2), new Item(BOLT_OF_CLOTH, 2)), GUILDED_ALTAR(8068, 13197, 75, 2230, new Item(MARBLE_BLOCK, 2), new Item(BOLT_OF_CLOTH, 2), new Item(GOLD_LEAF, 4)), // LAMPS WOODEN_TORCHES(8069, 13200, 49, 58, new Item(OAK_PLANK, 2), new Item(NAILS, 5)), STEEL_TORCHES(8070, 13202, 45, 80, new Item(STEEL_BAR, 2)), STEEL_CANDLESTICK(8071, 13204, 53, 124, new Item(STEEL_BAR, 6), new Item(36, 6)), GOLD_CANDLESTICK(8072, 13206, 57, 46, new Item(2357, 6), new Item(36, 6)), INSCENCE_BURNER(8073, 13208, 61, 280, new Item(OAK_PLANK, 4), new Item(STEEL_BAR, 2)), MAHOGANY_BURNER(8074, 13210, 65, 600, new Item(MAHOGANY_PLANK, 4), new Item(STEEL_BAR, 2)), MARBLE_BURNER(8075, 13212, 69, 1600, new Item(MARBLE_BLOCK, 2), new Item(STEEL_BAR, 2)), // SYMBOL GUTHIX_SYMBOL(8057, 13174, 48, 120, new Item(OAK_PLANK, 2)), SARADOMIN_SYMBOL(8055, 13172, 48, 120, new Item(OAK_PLANK, 2)), ZAMORAK_SYMBOL(8056, 13173, 48, 120, new Item(OAK_PLANK, 2)), GUTHIX_ICON(8060, 13177, 59, 960, new Item(TEAK_PLANK, 4), new Item(GOLD_LEAF, 2)), SARADOMIN_ICON(8058, 13175, 59, 960, new Item(TEAK_PLANK, 4), new Item(GOLD_LEAF, 2)), ZAMORAK_ICON(8059, 13173, 59, 960, new Item(TEAK_PLANK, 4), new Item(GOLD_LEAF, 2)), ICON_OF_BOB(8061, 13178, 71, 1160, new Item(MAHOGANY_PLANK, 4), new Item(GOLD_LEAF, 2)), // MUSIC WINCHIMES(8079, 13214, 49, 323, new Item(OAK_PLANK, 4), new Item(NAILS, 4), new Item(STEEL_BAR, 4)), BELLS(8080, 13215, 58, 480, new Item(TEAK_PLANK, 4), new Item(STEEL_BAR, 6)), ORGAN(8081, 13216, 69, 680, new Item(MAHOGANY_PLANK, 4), new Item(STEEL_BAR, 6)), // STATUE SMALL_STATUE(8082, 13271, 49, 40, new Item(LIMESTONE_BRICKS, 2)), MEDIUM_STATUE(8083, 13275, 69, 500, new Item(MARBLE_BLOCK, 1)), LARGE_STATUE(8084, 13279, 89, 1500, new Item(MARBLE_BLOCK, 3)), // WINDOWS SHUTTERED_WINDOW(8076, new int[] { 13253, 13226, 13235, 13244, 13217, 13262, 39232 }, 49, 228, new Item(PLANK, 8), new Item(NAILS, 8)), DECORATIVE_WINDOW(8077, new int[] { 13254, 13227, 13236, 13245, 13218, 13263, 39253 }, 69, 4, new Item(MOLTEN_GLASS, 8)), STAINED_GLASS(8078, new int[] { 13255, 13228, 13237, 13246, 13219, 13264, 39254 }, 89, 5, new Item(MOLTEN_GLASS, 16)); private final int itemId, level; private final int[] ids; private final double xp; private final Item[] reqs; HObject(int itemId, int id, int level, double xp, Item... reqs) { this(itemId, new int[] { id }, level, xp, reqs); } HObject(int itemId, int[] ids, int level, double xp, Item... reqs) { this.itemId = itemId; this.ids = ids; this.level = level; this.xp = xp; this.reqs = reqs; } public int getItemId() { return itemId; } public int getId() { return ids[0]; } public int[] getIds() { return ids; } public int getLevel() { return level; } public Item[] getRequirements(Player player) { Item[] item = new Item[reqs.length]; for (int i = 0;i < reqs.length;i++) if (reqs[i].getId() == NAILS) { for (int element : NAIL_IDS) if (player.getInventory().containsItem(element)) item[i] = new Item(element, reqs[i].getAmount()); } else item[i] = reqs[i]; return item; } public double getXP() { return xp; } } public enum Room { PARLOUR(1000, 1, 232, 639, true, InstanceBuilder.EAST, InstanceBuilder.SOUTH, InstanceBuilder.WEST), GARDEN(1000, 1, 232, 633, false, InstanceBuilder.NORTH, InstanceBuilder.EAST, InstanceBuilder.SOUTH, InstanceBuilder.WEST), KITCHEN(5000, 5, 234, 639, true, InstanceBuilder.SOUTH, InstanceBuilder.WEST), DINING_ROOM(5000, 10, 236, 639, true, InstanceBuilder.EAST, InstanceBuilder.SOUTH, InstanceBuilder.WEST), WORKSHOP(10000, 15, 232, 637, true, InstanceBuilder.NORTH, InstanceBuilder.SOUTH), BEDROOM(10000, 20, 238, 639, true, InstanceBuilder.NORTH, InstanceBuilder.WEST), HALL_SKILL(15000, 25, 233, 638, true, InstanceBuilder.NORTH, InstanceBuilder.EAST, InstanceBuilder.SOUTH, InstanceBuilder.WEST), GAMES_ROOM(25000, 30, 237, 636, true, InstanceBuilder.EAST, InstanceBuilder.SOUTH, InstanceBuilder.WEST), COMBAT_ROOM(25000, 32, 235, 636, true, InstanceBuilder.EAST, InstanceBuilder.SOUTH, InstanceBuilder.WEST), HALL_QUEST(25000, 35, 237, 638, true, InstanceBuilder.NORTH, InstanceBuilder.EAST, InstanceBuilder.SOUTH, InstanceBuilder.WEST), MENAGERIE(30000, 37, 239, 634, false, InstanceBuilder.NORTH, InstanceBuilder.EAST, InstanceBuilder.SOUTH, InstanceBuilder.WEST), STUDY(50000, 40, 236, 637, true, InstanceBuilder.EAST, InstanceBuilder.SOUTH, InstanceBuilder.WEST), COSTUME_ROOM(50000, 42, 238, 633, true, InstanceBuilder.NORTH, InstanceBuilder.EAST, InstanceBuilder.SOUTH, InstanceBuilder.WEST), CHAPEL(50000, 45, 234, 637, true, InstanceBuilder.SOUTH, InstanceBuilder.WEST), PORTAL_CHAMBER(100000, 50, 233, 636, true, InstanceBuilder.SOUTH), FORMAL_GARDEN(75000, 55, 234, 633, false, InstanceBuilder.NORTH, InstanceBuilder.EAST, InstanceBuilder.SOUTH, InstanceBuilder.WEST), THRONE_ROOM(150000, 60, 238, 637, true, InstanceBuilder.SOUTH), OUTBLIETTE(150000, 65, 238, 635, false, InstanceBuilder.NORTH, InstanceBuilder.EAST, InstanceBuilder.SOUTH, InstanceBuilder.WEST), DUNGEON_CORRIDOR(7500, 70, 236, 635, false, InstanceBuilder.NORTH, InstanceBuilder.SOUTH), DUNGEON_JUNCTION(7500, 70, 232, 635, false, InstanceBuilder.NORTH, InstanceBuilder.EAST, InstanceBuilder.SOUTH, InstanceBuilder.WEST), DUNGEON_STAIRS(7500, 70, 234, 635, false, InstanceBuilder.NORTH, InstanceBuilder.EAST, InstanceBuilder.SOUTH, InstanceBuilder.WEST), DUNGEON_PIT(10000, 70, 237, 634, false, InstanceBuilder.NORTH, InstanceBuilder.EAST, InstanceBuilder.SOUTH, InstanceBuilder.WEST), TREASURE_ROOM(250000, 75, 239, 636, true, InstanceBuilder.SOUTH), HALL_SKILL_DOWN(15000, 25, 235, 638, true, InstanceBuilder.NORTH, InstanceBuilder.EAST, InstanceBuilder.SOUTH, InstanceBuilder.WEST), HALL_QUEST_DOWN(25000, 35, 239, 638, true, InstanceBuilder.NORTH, InstanceBuilder.EAST, InstanceBuilder.SOUTH, InstanceBuilder.WEST); private final int price; private int level; private final int chunkX, chunkY; private final boolean showRoof; Room(int price, int level, int chunkX, int chunkY, boolean showRoof, int... doorDirs) { this.price = price; this.chunkX = chunkX; this.chunkY = chunkY; this.showRoof = showRoof; // might be useful on future } public int getChunkX() { return chunkX; } public int getChunkY() { return chunkY; } public boolean isShowRoof() { return showRoof; } public int getLevel() { return level; } public int getPrice() { return price; } } public enum Roof { ROOF1(233, 634, InstanceBuilder.NORTH, InstanceBuilder.SOUTH), ROOF2(235, 634, InstanceBuilder.NORTH, InstanceBuilder.EAST, InstanceBuilder.SOUTH), ROOF3(235, 634, InstanceBuilder.NORTH, InstanceBuilder.EAST, InstanceBuilder.SOUTH, InstanceBuilder.NORTH), DUNGEON_ROOF1(235, 632, InstanceBuilder.NORTH, InstanceBuilder.EAST, InstanceBuilder.SOUTH, InstanceBuilder.NORTH); private final int chunkX; private final int chunkY; Roof(int chunkX, int chunkY, int... dirs) { this.chunkX = chunkX; this.chunkY = chunkY; } public int getChunkX() { return chunkX; } public int getChunkY() { return chunkY; } } public enum POHLocation { RIMMINGTON(15478, Tile.of(2953, 3224, 0), 1, 5000), TAVERLY(15477, Tile.of(2882, 3452, 0), 1, 5000), POLLNIVNEACH(15479, Tile.of(3340, 3003, 0), 20, 7500), RELLEKKA(15480, Tile.of(2670, 3631, 0), 30, 10000), BRIMHAVEN(15481, Tile.of(2757, 3178, 0), 40, 15000), YANILLE(15482, Tile.of(2544, 3096, 0), 50, 25000); private final Tile tile; private final int objectId, levelRequired, cost; POHLocation(int objectId, Tile tile, int levelRequired, int cost) { this.objectId = objectId; this.tile = tile; this.levelRequired = levelRequired; this.cost = cost; } public Tile getTile() { return tile; } public int getLevelRequired() { return levelRequired; } public int getCost() { return cost; } public int getObjectId() { return objectId; } } public enum Servant { RICK(4235, 375, 500, 20, 315, false, 6, 100), MAID(4237, 750, 1000, 25, 2003, false, 10, 50), COOK(4239, 2250, 3000, 30, 2301, true, 16, 28), BUTLER(4241, 3750, 5000, 40, 1897, true, 20, 20), DEMON_BUTLER(4243, 7500, 10000, 50, 2011, true, 26, 12); private final int id, hirePrice, bankCost, level, foodId, inventorySize; private final long bankDelay; private final boolean sawmill; Servant(int id, int hirePrice, int bankCost, int level, int foodId, boolean sawmill, int inventorySize, long bankDelay) { this.id = id; this.hirePrice = hirePrice; this.bankCost = bankCost; this.level = level; this.foodId = foodId; this.sawmill = sawmill; this.inventorySize = inventorySize; this.bankDelay = bankDelay; } public int getId() { return id; } public int getHirePrice() { return hirePrice; } public int getBankCost() { return bankCost; } public int getLevel() { return level; } public int getFoodId() { return foodId; } public int getInventorySize() { return inventorySize; } public long getBankDelay() { return bankDelay; } public boolean isSawmill() { return sawmill; } } public static final int[] LAND = { 233, 632 }; // empty dungeon space public static final int[] DUNGEON = /*{ 237, 632 }*/{ 235, 632 }; public static final int[] BLACK = { 237, 632 }; public static final int[] CHAIR_EMOTES = { 4073, 4075, 4079, 4081, 4083, 4085, 4087 }; public static final int[] BENCH_EMOTES = { 4089, 4091, 4093, 4095, 4097, 4099, 4101 }; public static final int[] THRONE_EMOTES = { 4111, 4112, 4113, 4114, 4115, 4116, 4117 }; public static int getSitAnimation(int id) { if (id >= 13581 && id <= 13587) return CHAIR_EMOTES[id-13581]; if (id >= 13300 && id <= 13306) return BENCH_EMOTES[id-13300]; if (id >= 13665 && id <= 13671) return THRONE_EMOTES[id-13665]; else if (id >= 13694 && id <= 13696) { if (id == 13694) return 4097; if (id == 13695) return 4099; if (id == 13696) return 4101; return -1; } else return -1; } }" "package com.rs.game.content.skills.construction; public class HouseController extends Controller { private final transient House house; public HouseController(House house) { this.house = house; } @Override public void start() { player.setForceMultiArea(true); } @Override public boolean sendDeath() { player.lock(7); player.stopAll(); WorldTasks.scheduleLooping(new Task() { int loop; @Override public void run() { player.stopAll(); if (loop == 0) player.anim(836); else if (loop == 1) player.sendMessage(""Oh dear, you have died.""); else if (loop == 3) { player.setNextAnimation(new Animation(-1)); house.teleportPlayer(player); player.reset(); player.setCanPvp(false); stop(); } loop++; } }, 0, 1); return false; } @Override public boolean processNPCClick1(NPC npc) { if (npc instanceof ServantNPC servant) { npc.faceEntity(player); if (!house.isOwner(player)) { player.npcDialogue(npc.getId(), HeadE.CALM_TALK, ""Sorry, I only serve my master.""); return false; } player.startConversation(new ServantHouseD(player, servant, false)); return false; } return true; } @Override public boolean processNPCClick2(NPC npc) { if (npc instanceof ServantNPC servant) { npc.faceEntity(player); if (!house.isOwner(player)) { player.npcDialogue(npc.getId(), HeadE.CALM_TALK, ""The servant ignores your request.""); return false; } player.startConversation(new ServantHouseD(player, servant, true)); return false; } return true; } @Override public boolean processItemOnNPC(NPC npc, Item item) { if (npc instanceof ServantNPC) { npc.faceEntity(player); if (!house.isOwner(player)) { player.npcDialogue(npc.getId(), HeadE.CALM_TALK, ""The servant ignores your request.""); return false; } player.startConversation(new ItemOnServantD(player, npc, item.getId(), house.getServant().isSawmill())); return false; } return false; } /** * return process normaly */ @Override public boolean processObjectClick5(GameObject object) { if (object.getDefinitions().containsOption(4, ""Build"")) { if (!house.isOwner(player)) { player.sendMessage(""You can only do that in your own house.""); return false; } if (house.isDoor(object)) house.openRoomCreationMenu(object); else for (final Builds build : Builds.values()) if (build.containsId(object.getId())) { house.openBuildInterface(object, build); return false; } } else if (object.getDefinitions().containsOption(4, ""Remove"")) { if (!house.isOwner(player)) { player.sendMessage(""You can only do that in your own house.""); return false; } house.openRemoveBuild(object); } return false; } @Override public boolean processObjectClick1(final GameObject object) { if (object.getDefinitions().getOption(1).equalsIgnoreCase(""Pray"") || (object.getDefinitions().getOption(1).equalsIgnoreCase(""Renew-points"") && object.getDefinitions().getName().contains(""obelisk""))) return true; if (object.getId() == HouseConstants.HObject.EXIT_PORTAL.getId()) house.leaveHouse(player, House.KICKED); else if (object.getId() == HouseConstants.HObject.CLAY_FIREPLACE.getId() || object.getId() == HouseConstants.HObject.STONE_FIREPLACE.getId() || object.getId() == HouseConstants.HObject.MARBLE_FIREPLACE.getId()) player.sendMessage(""Use some logs on the fireplace in order to light it.""); else if ((object.getId() >= 13581 && object.getId() <= 13587) || (object.getId() >= 13300 && object.getId() <= 13306) || (object.getId() >= 13665 && object.getId() <= 13671) || (object.getId() >= 13694 && object.getId() <= 13696)) player.getActionManager().setAction(new SitChair(player, object)); else if (house.isOwner(player) && (object.getId() == 13640 || object.getId() == 13641 || object.getId() == 13639)) directPortals(player, object); else if (object.getId() >= 13615 && object.getId() <= 13635) telePlayer(object.getId()); else if (Builds.DRESSERS.containsObject(object)) PlayerLook.openHairdresserSalon(player); else if (Builds.WARDROBE.containsObject(object)) PlayerLook.openThessaliasMakeOver(player); else if (object.getId() == HouseConstants.HObject.GLORY.getId()) ItemTeleports.transportationDialogue(player, 1712); else if (Builds.TELESCOPE.containsObject(object)) ShootingStars.viewTelescope(player); else if (Builds.LARDER.containsObject(object)) handleLarders(object); else if (Builds.SHELVES.containsObject(object)) handleShelves(object); else if (Builds.TOOL1.containsObject(object)) handleTools(object); else if (Builds.WEAPONS_RACK.containsObject(object)) handleWeapons(object); else if (Builds.LEVER.containsObject(object)) handleLever(object); else if (Builds.ROPE_BELL_PULL.containsObject(object)) { if (!house.isOwner(player)) { player.getPackets() .sendGameMessage(""I'd better not do this...""); return false; } house.callServant(true); return false; } else if (Builds.LECTURN.containsObject(object)) { if (house.isBuildMode()) { player.sendMessage(""You cannot do this while in building mode.""); return false; } TabletMaking.openTabInterface(player, object.getId() - 13642); } else if (Builds.BOOKCASE.containsObject(object)) player.sendMessage(""You search the bookcase but find nothing.""); else if (Builds.STAIRCASE.containsObject(object) || Builds.STAIRCASE_DOWN.containsObject(object)) { if (object.getDefinitions().getOption(1).equals(""Climb"")) player.sendOptionDialogue(""Would you like to climb up or down?"", ops -> { ops.add(""Climb up"", () -> house.climbStaircase(player, object, true)); ops.add(""Climb down"", () -> house.climbStaircase(player, object, false)); }); else house.climbStaircase(player, object, object.getDefinitions().getOption(1).equals(""Climb-up"")); } else if (Builds.PETHOUSE.containsObject(object)) { if (house.isOwner(player)) house.getPetHouse().open(); else player.sendMessage(""This isn't your pet house.""); } else if (Builds.OUB_LADDER.containsObject(object) || Builds.TRAPDOOR.containsObject(object)) house.climbLadder(player, object, object.getDefinitions().getOption(1).equals(""Climb"")); else if (Builds.DOOR.containsObject(object) || Builds.OUB_CAGE.containsObject(object)) handleDoor(object); else if (Builds.COMBAT_RING.containsObject(object)) handleCombatRing(object); return false; } private void handleLever(GameObject object) { house.handleLever(player, object); } private void handleWeapons(GameObject object) { if (object.getId() == HObject.GLOVE_RACK.getId()) sendTakeItemsDialogue(7671, 7673); else if (object.getId() == HObject.WEAPON_RACK.getId()) sendTakeItemsDialogue(7671, 7673, 7675, 7676); else if (object.getId() == HObject.EXTRA_WEAPON_RACK.getId()) sendTakeItemsDialogue(7671, 7673, 7675, 7676, 7679); } private void handleLarders(GameObject object) { if (object.getId() == HObject.WOODEN_LARDER.getId()) sendTakeItemsDialogue(7738, 1927); else if (object.getId() == HObject.OAK_LARDER.getId()) sendTakeItemsDialogue(7738, 1927, 1944, 1933); else if (object.getId() == HObject.TEAK_LARDER.getId()) sendTakeItemsDialogue(7738, 1927, 1944, 1933, 6701, 1550, 1957, 1985); } private void handleShelves(GameObject object) { if (object.getId() == HObject.WOODEN_SHELVES_1.getId()) sendTakeItemsDialogue(7688, 7702, 7728); else if (object.getId() == HObject.WOODEN_SHELVES_2.getId()) sendTakeItemsDialogue(7688, 7702, 7728, 7742); else if (object.getId() == HObject.WOODEN_SHELVES_3.getId()) sendTakeItemsDialogue(7688, 7714, 7732, 7742, 1887); else if (object.getId() == HObject.OAK_SHELVES_1.getId()) sendTakeItemsDialogue(7688, 7714, 7732, 7742, 1923); else if (object.getId() == HObject.OAK_SHELVES_2.getId()) sendTakeItemsDialogue(7688, 7714, 7732, 7742, 1923, 1887); else if (object.getId() == HObject.TEAK_SHELVES_1.getId()) sendTakeItemsDialogue(7688, 7726, 7735, 7742, 1923, 2313, 1931); else if (object.getId() == HObject.TEAK_SHELVES_2.getId()) sendTakeItemsDialogue(7688, 7726, 7735, 7742, 1923, 2313, 1931, 1949); } private void handleTools(GameObject object) { if (object.getId() == HObject.TOOL_STORE_1.getId()) sendTakeItemsDialogue(8794, 2347, 1755, 1735); else if (object.getId() == HObject.TOOL_STORE_2.getId()) sendTakeItemsDialogue(1925, 946, 952, 590); else if (object.getId() == HObject.TOOL_STORE_3.getId()) sendTakeItemsDialogue(1757, 1785, 1733); else if (object.getId() == HObject.TOOL_STORE_4.getId()) sendTakeItemsDialogue(1592, 1595, 1597, 1599, 11065, 5523); else if (object.getId() == HObject.TOOL_STORE_5.getId()) sendTakeItemsDialogue(5341, 5343, 5329, 5331, 5325, 952); } private void handleDoor(GameObject object) { Tile target = null; Direction direction = Direction.NORTH; switch (object.getRotation()) { case 0: if (player.getX() < object.getX()) { target = object.getTile().transform(1, 0, 0); direction = Direction.EAST; } else { target = object.getTile().transform(-1, 0, 0); direction = Direction.WEST; } break; case 1: if (player.getY() <= object.getY()) { target = object.getTile().transform(0, 1, 0); direction = Direction.NORTH; } else { target = object.getTile().transform(0, -1, 0); direction = Direction.SOUTH; } break; case 2: if (player.getX() > object.getX()) { target = object.getTile().transform(-1, 0, 0); direction = Direction.WEST; } else { target = object.getTile().transform(1, 0, 0); direction = Direction.EAST; } break; case 3: if (player.getY() >= object.getY()) { target = object.getTile().transform(0, -1, 0); direction = Direction.SOUTH; } else { target = object.getTile().transform(0, 1, 0); direction = Direction.NORTH; } break; } if (target == null) return; player.forceMove(target, 741, 1, 35); } @Override public boolean processButtonClick(int interfaceId, int componentId, int slotId, int slotId2, ClientPacket packet) { if (interfaceId == 400) if (packet == ClientPacket.IF_OP1) TabletMaking.handleTabletCreation(player, componentId, 1); else if (packet == ClientPacket.IF_OP2) TabletMaking.handleTabletCreation(player, componentId, 5); else if (packet == ClientPacket.IF_OP3) TabletMaking.handleTabletCreation(player, componentId, 10); else if (packet == ClientPacket.IF_OP4) player.sendInputInteger(""How many would you like to make?"", (amount) -> TabletMaking.handleTabletCreation(player, componentId, amount)); else if (packet == ClientPacket.IF_OP5) TabletMaking.handleTabletCreation(player, componentId, player.getInventory().getAmountOf(1761)); return true; } private void handleCombatRing(GameObject object) { Tile target = null; Direction direction = Direction.NORTH; switch (object.getRotation()) { case 0: if (player.getX() < object.getX()) { target = object.getTile().transform(1, 0, 0); direction = Direction.EAST; player.getTempAttribs().setB(""inBoxingArena"", false); } else { target = object.getTile().transform(-1, 0, 0); direction = Direction.WEST; player.getTempAttribs().setB(""inBoxingArena"", true); } break; case 1: if (player.getY() <= object.getY()) { target = object.getTile().transform(0, 1, 0); direction = Direction.NORTH; player.getTempAttribs().setB(""inBoxingArena"", true); } else { target = object.getTile().transform(0, -1, 0); direction = Direction.SOUTH; player.getTempAttribs().setB(""inBoxingArena"", false); } break; case 2: if (player.getX() > object.getX()) { target = object.getTile().transform(-1, 0, 0); direction = Direction.WEST; player.getTempAttribs().setB(""inBoxingArena"", false); } else { target = object.getTile().transform(1, 0, 0); direction = Direction.EAST; player.getTempAttribs().setB(""inBoxingArena"", true); } break; case 3: if (player.getY() >= object.getY()) { target = object.getTile().transform(0, -1, 0); direction = Direction.SOUTH; player.getTempAttribs().setB(""inBoxingArena"", true); } else { target = object.getTile().transform(0, 1, 0); direction = Direction.NORTH; player.getTempAttribs().setB(""inBoxingArena"", false); } break; } if (target == null) return; player.forceMove(target, 3688, 1, 30); } @Override public boolean processItemOnObject(GameObject object, Item item) { if (object.getId() == HouseConstants.HObject.CLAY_FIREPLACE.getId() || object.getId() == HouseConstants.HObject.STONE_FIREPLACE.getId() || object.getId() == HouseConstants.HObject.MARBLE_FIREPLACE.getId()) { if (item.getId() != 1511) { player.sendMessage(""Only ordinary logs can be used to light the fireplace.""); return false; } if (!player.getInventory().containsOneItem(590)) { player.sendMessage(""You do not have the required items to light this.""); return false; } player.lock(2); player.anim(3658); player.getSkills().addXp(Constants.FIREMAKING, 40); final GameObject objectR = new GameObject(object); objectR.setId(object.getId() + 1); for (final Player player : house.getPlayers()) player.getPackets().sendRemoveObject(objectR); return false; } if (Builds.SINK.containsObject(object)) { Filler fill = FillAction.isFillable(item); if (fill != null) player.startConversation(new Dialogue() .addNext(new MakeXStatement( new int[] { fill.getFilledItem().getId() }, player.getInventory().getAmountOf(fill.getEmptyItem().getId()))) .addNext(() -> player.getActionManager().setAction(new FillAction(MakeXStatement.getQuantity(player), fill)))); } else if (Builds.STOVE.containsObject(object)) { if (item.getId() == 7690) { player.getInventory().deleteItem(7690, 1); player.getInventory().addItem(7691, 1); player.anim(883); player.sendMessage(""You boil the kettle of water.""); return false; } player.startConversation(new CookingD(player, Cookables.forId(item.getId()), object)); return false; } return true; } @Override public boolean canDropItem(Item item) { if (house.isBuildMode()) { player.sendMessage(""You cannot drop items while in building mode.""); return false; } return true; } @Override public boolean processObjectClick2(GameObject object) { if (object.getId() == HouseConstants.HObject.EXIT_PORTAL.getId()) house.switchLock(player); else if (Builds.STAIRCASE.containsObject(object) || Builds.STAIRCASE_DOWN.containsObject(object)) house.climbStaircase(player, object, true); else if (Builds.LEVER.containsObject(object)) player.sendOptionDialogue(""Would you like to toggle PVP challenge mode?"", ops -> { ops.add(""Yes"", () -> house.toggleChallengeMode(player)); ops.add(""No""); }); return false; } @Override public boolean processObjectClick3(GameObject object) { if (Builds.STAIRCASE.containsObject(object) || Builds.STAIRCASE_DOWN.containsObject(object)) house.climbStaircase(player, object, false); return false; } @Override public boolean processObjectClick4(GameObject object) { if (Builds.STAIRCASE.containsObject(object) || Builds.STAIRCASE_DOWN.containsObject(object)) house.removeRoom(); return false; } @Override public boolean checkWalkStep(int lastX, int lastY, int nextX, int nextY) { return !house.isSky(nextX, nextY, player.getPlane()); } @Override public boolean logout() { player.setTile(house.getLocation().getTile()); player.tele(house.getLocation().getTile()); house.leaveHouse(player, House.LOGGED_OUT); return false; } @Override public boolean login() { removeController(); player.tele(player.getHouse().getLocation().getTile()); return false; } @Override public void onTeleported(TeleType type) { house.leaveHouse(player, House.TELEPORTED); } // shouldnt happen @Override public void forceClose() { player.setTile(house.getLocation().getTile()); player.tele(house.getLocation().getTile()); player.removeHouseOnlyItems(); house.leaveHouse(player, House.TELEPORTED, true); } @Override public void onRemove() { player.removeHouseOnlyItems(); if (house != null) { player.tele(house.getLocation().getTile()); house.leaveHouse(player, House.TELEPORTED, true); } } @Override public void process() { if ((house.isChallengeMode() && player.getPlane() == 0) || player.getTempAttribs().getB(""inBoxingArena"")) { if (!player.isCanPvp()) player.setCanPvp(true); } else if (player.isCanPvp()) player.setCanPvp(false); } public House getHouse() { return house; } public void sendTakeItemsDialogue(final int... itemIds) { player.sendOptionDialogue(""What would you like to take?"", ops -> { for (int itemId : itemIds) ops.add(ItemDefinitions.getDefs(itemId).getName(), () -> player.getInventory().addItem(itemId, 1)); ops.add(""Nevermind.""); }); } public static void directPortals(Player player, GameObject object ) { RoomReference currentRoom = player.getHouse().getRoom(object); if (currentRoom != null) { ObjectReference portal1 = currentRoom.getBuild(Builds.PORTALS1); ObjectReference portal2 = currentRoom.getBuild(Builds.PORTALS2); ObjectReference portal3 = currentRoom.getBuild(Builds.PORTALS3); if (portal1 == null && portal2 == null && portal3 == null) { player.startConversation(new Dialogue().addSimple(""You should build portal frames first."")); return; } Dialogue p1d = getTeleports(player, currentRoom, portal1); Dialogue p2d = getTeleports(player, currentRoom, portal2); Dialogue p3d = getTeleports(player, currentRoom, portal3); Dialogue d = new Dialogue(); d.addOptions(""Redirect which portal?"", new Options() { @Override public void create() { if (portal1 == null) option(""1: No portal frame"", () -> player.sendMessage(""You must build a portal frame before you can redirect this."")); else option(""1: "" + (ObjectDefinitions.getDefs(portal1.getId()).getName().contains(""Portal frame"") ? ""Nowhere"" : ObjectDefinitions.getDefs(portal1.getId()).getName()), p1d); if (portal2 == null) option(""2: No portal frame"", () -> player.sendMessage(""You must build a portal frame before you can redirect this."")); else option(""2: "" + (ObjectDefinitions.getDefs(portal2.getId()).getName().contains(""Portal frame"") ? ""Nowhere"" : ObjectDefinitions.getDefs(portal2.getId()).getName()), p2d); if (portal3 == null) option(""3: No portal frame"", () -> player.sendMessage(""You must build a portal frame before you can redirect this."")); else option(""3: "" + (ObjectDefinitions.getDefs(portal3.getId()).getName().contains(""Portal frame"") ? ""Nowhere"" : ObjectDefinitions.getDefs(portal3.getId()).getName()), p3d); } }); player.startConversation(d); } } public static Dialogue getTeleports(Player player, RoomReference room, ObjectReference portal) { if (portal == null) return null; Dialogue teleportOptions = new Dialogue(); int portalId = portal.getId(); String frameType = getPortalFrameType(portalId); teleportOptions.addOptions(""Direct teleport to"", new Options() { @Override public void create() { switch (frameType) { case ""Teak"": if (portalId != 13615 && !player.getHouse().containsAnyObject(13615, 13622, 13629)) option(""Varrock Teleport"", new Dialogue().addOption(""This will cost 100 teleports to tune"", ""Pay runes"", ""Nevermind"").addNext(() -> { RuneSet requiredRunes = new RuneSet(Rune.AIR, 300, Rune.LAW, 100, Rune.FIRE, 100); if (requiredRunes.meetsPortalRequirements(player)) { requiredRunes.deleteRunes(player); portal.setSlot(3, player.getHouse().getWorldObject(room, portal.getId())); } })); if (portalId != 13616 && !player.getHouse().containsAnyObject(13616, 13623, 13630)) option(""Lumbridge Teleport"", new Dialogue().addOption(""This will cost 100 teleports to tune"", ""Pay runes"", ""Nevermind"").addNext(() -> { RuneSet requiredRunes = new RuneSet(Rune.AIR, 300, Rune.LAW, 100, Rune.EARTH, 100); if (requiredRunes.meetsPortalRequirements(player)) { requiredRunes.deleteRunes(player); portal.setSlot(4, player.getHouse().getWorldObject(room, portal.getId())); } })); if (portalId != 13617 && !player.getHouse().containsAnyObject(13617, 13624, 13631)) option(""Falador Teleport"", new Dialogue().addOption(""This will cost 100 teleports to tune"", ""Pay runes"", ""Nevermind"").addNext(() -> { RuneSet requiredRunes = new RuneSet(Rune.AIR, 300, Rune.LAW, 100, Rune.WATER, 100); if (requiredRunes.meetsPortalRequirements(player)) { requiredRunes.deleteRunes(player); portal.setSlot(5, player.getHouse().getWorldObject(room, portal.getId())); } })); if (portalId != 13618 && !player.getHouse().containsAnyObject(13618, 13625, 13632)) option(""Camelot Teleport"", new Dialogue().addOption(""This will cost 100 teleports to tune"", ""Pay runes"", ""Nevermind"").addNext(() -> { RuneSet requiredRunes = new RuneSet(Rune.AIR, 500, Rune.LAW, 100); if (requiredRunes.meetsPortalRequirements(player)) { requiredRunes.deleteRunes(player); portal.setSlot(6, player.getHouse().getWorldObject(room, portal.getId())); } })); if (portalId != 13619 && !player.getHouse().containsAnyObject(13619, 13626, 13633)) option(""Ardougne Teleport"", new Dialogue().addOption(""This will cost 100 teleports to tune"", ""Pay runes"", ""Nevermind"").addNext(() -> { RuneSet requiredRunes = new RuneSet(Rune.LAW, 200, Rune.WATER, 200); if (!player.isQuestComplete(Quest.PLAGUE_CITY, ""to tune your portal to Ardougne."")) return; if (requiredRunes.meetsPortalRequirements(player)) { requiredRunes.deleteRunes(player); portal.setSlot(7, player.getHouse().getWorldObject(room, portal.getId())); } })); if (portalId != 13620 && !player.getHouse().containsAnyObject(13620, 13627, 13634)) option(""Yanille Teleport"", new Dialogue().addOption(""This will cost 100 teleports to tune"", ""Pay runes"", ""Nevermind"").addNext(() -> { RuneSet requiredRunes = new RuneSet(Rune.LAW, 200, Rune.EARTH, 200); if (!player.isQuestComplete(Quest.WATCHTOWER, ""to tune your portal to Yanille."")) return; if (requiredRunes.meetsPortalRequirements(player)) { requiredRunes.deleteRunes(player); portal.setSlot(8, player.getHouse().getWorldObject(room, portal.getId())); } })); if (portalId != 13621 && !player.getHouse().containsAnyObject(13621, 13628, 13635)) option(""Kharyrll Teleport"", new Dialogue().addOption(""This will cost 100 teleports to tune"", ""Pay runes"", ""Nevermind"").addNext(() -> { RuneSet requiredRunes = new RuneSet(Rune.BLOOD, 100, Rune.LAW, 200); if (!player.isQuestComplete(Quest.DESERT_TREASURE, ""to tune your portal to Kharyrll (Canifis)."")) return; if (requiredRunes.meetsPortalRequirements(player)) { requiredRunes.deleteRunes(player); portal.setSlot(9, player.getHouse().getWorldObject(room, portal.getId())); } })); option(""Nevermind""); break; case ""Mahogany"": if (portalId != 13622 && !player.getHouse().containsAnyObject(13615, 13622, 13629)) option(""Varrock Teleport"", new Dialogue().addOption(""This will cost 100 teleports to tune"", ""Pay runes"", ""Nevermind"").addNext(() -> { RuneSet requiredRunes = new RuneSet(Rune.AIR, 300, Rune.LAW, 100, Rune.FIRE, 100); if (requiredRunes.meetsPortalRequirements(player)) { requiredRunes.deleteRunes(player); portal.setSlot(10, player.getHouse().getWorldObject(room, portal.getId())); } })); if (portalId != 13623 && !player.getHouse().containsAnyObject(13616, 13623, 13630)) option(""Lumbridge Teleport"", new Dialogue().addOption(""This will cost 100 teleports to tune"", ""Pay runes"", ""Nevermind"").addNext(() -> { RuneSet requiredRunes = new RuneSet(Rune.AIR, 300, Rune.LAW, 100, Rune.EARTH, 100); if (requiredRunes.meetsPortalRequirements(player)) { requiredRunes.deleteRunes(player); portal.setSlot(11, player.getHouse().getWorldObject(room, portal.getId())); } })); if (portalId != 13624 && !player.getHouse().containsAnyObject(13617, 13624, 13631)) option(""Falador Teleport"", new Dialogue().addOption(""This will cost 100 teleports to tune"", ""Pay runes"", ""Nevermind"").addNext(() -> { RuneSet requiredRunes = new RuneSet(Rune.AIR, 300, Rune.LAW, 100, Rune.WATER, 100); if (requiredRunes.meetsPortalRequirements(player)) { requiredRunes.deleteRunes(player); portal.setSlot(12, player.getHouse().getWorldObject(room, portal.getId())); } })); if (portalId != 13625 && !player.getHouse().containsAnyObject(13618, 13625, 13632)) option(""Camelot Teleport"", new Dialogue().addOption(""This will cost 100 teleports to tune"", ""Pay runes"", ""Nevermind"").addNext(() -> { RuneSet requiredRunes = new RuneSet(Rune.AIR, 500, Rune.LAW, 100); if (requiredRunes.meetsPortalRequirements(player)) { requiredRunes.deleteRunes(player); portal.setSlot(13, player.getHouse().getWorldObject(room, portal.getId())); } })); if (portalId != 13626 && !player.getHouse().containsAnyObject(13619, 13626, 13633)) option(""Ardougne Teleport"", new Dialogue().addOption(""This will cost 100 teleports to tune"", ""Pay runes"", ""Nevermind"").addNext(() -> { RuneSet requiredRunes = new RuneSet(Rune.LAW, 200, Rune.WATER, 200); if (!player.isQuestComplete(Quest.PLAGUE_CITY, ""to tune your portal to Ardougne."")) return; if (requiredRunes.meetsPortalRequirements(player)) { requiredRunes.deleteRunes(player); portal.setSlot(14, player.getHouse().getWorldObject(room, portal.getId())); } })); if (portalId != 13627 && !player.getHouse().containsAnyObject(13620, 13627, 13634)) option(""Yanille Teleport"", new Dialogue().addOption(""This will cost 100 teleports to tune"", ""Pay runes"", ""Nevermind"").addNext(() -> { RuneSet requiredRunes = new RuneSet(Rune.LAW, 200, Rune.EARTH, 200); if (!player.isQuestComplete(Quest.WATCHTOWER, ""to tune your portal to Yanille."")) return; if (requiredRunes.meetsPortalRequirements(player)) { requiredRunes.deleteRunes(player); portal.setSlot(15, player.getHouse().getWorldObject(room, portal.getId())); } })); if (portalId != 13628 && !player.getHouse().containsAnyObject(13621, 13628, 13635)) option(""Kharyrll Teleport"", new Dialogue().addOption(""This will cost 100 teleports to tune"", ""Pay runes"", ""Nevermind"").addNext(() -> { RuneSet requiredRunes = new RuneSet(Rune.BLOOD, 100, Rune.LAW, 200); if (!player.isQuestComplete(Quest.DESERT_TREASURE, ""to tune your portal to Kharyrll (Canifis)."")) return; if (requiredRunes.meetsPortalRequirements(player)) { requiredRunes.deleteRunes(player); portal.setSlot(16, player.getHouse().getWorldObject(room, portal.getId())); } })); option(""Nevermind""); break; case ""Marble"": if (portalId != 13629 && !player.getHouse().containsAnyObject(13615, 13622, 13629)) option(""Varrock Teleport"", new Dialogue().addOption(""This will cost 100 teleports to tune"", ""Pay runes"", ""Nevermind"").addNext(() -> { RuneSet requiredRunes = new RuneSet(Rune.AIR, 300, Rune.LAW, 100, Rune.FIRE, 100); if (requiredRunes.meetsPortalRequirements(player)) { requiredRunes.deleteRunes(player); portal.setSlot(17, player.getHouse().getWorldObject(room, portal.getId())); } })); if (portalId != 13630 && !player.getHouse().containsAnyObject(13616, 13623, 13630)) option(""Lumbridge Teleport"", new Dialogue().addOption(""This will cost 100 teleports to tune"", ""Pay runes"", ""Nevermind"").addNext(() -> { RuneSet requiredRunes = new RuneSet(Rune.AIR, 300, Rune.LAW, 100, Rune.EARTH, 100); if (requiredRunes.meetsPortalRequirements(player)) { requiredRunes.deleteRunes(player); portal.setSlot(18, player.getHouse().getWorldObject(room, portal.getId())); } })); if (portalId != 13631 && !player.getHouse().containsAnyObject(13617, 13624, 13631)) option(""Falador Teleport"", new Dialogue().addOption(""This will cost 100 teleports to tune"", ""Pay runes"", ""Nevermind"").addNext(() -> { RuneSet requiredRunes = new RuneSet(Rune.AIR, 300, Rune.LAW, 100, Rune.WATER, 100); if (requiredRunes.meetsPortalRequirements(player)) { requiredRunes.deleteRunes(player); portal.setSlot(19, player.getHouse().getWorldObject(room, portal.getId())); } })); if (portalId != 13632 && !player.getHouse().containsAnyObject(13618, 13625, 13632)) option(""Camelot Teleport"", new Dialogue().addOption(""This will cost 100 teleports to tune"", ""Pay runes"", ""Nevermind"").addNext(() -> { RuneSet requiredRunes = new RuneSet(Rune.AIR, 500, Rune.LAW, 100); if (requiredRunes.meetsPortalRequirements(player)) { requiredRunes.deleteRunes(player); portal.setSlot(20, player.getHouse().getWorldObject(room, portal.getId())); } })); if (portalId != 13633 && !player.getHouse().containsAnyObject(13619, 13626, 13633)) option(""Ardougne Teleport"", new Dialogue().addOption(""This will cost 100 teleports to tune"", ""Pay runes"", ""Nevermind"").addNext(() -> { RuneSet requiredRunes = new RuneSet(Rune.LAW, 200, Rune.WATER, 200); if (!player.isQuestComplete(Quest.PLAGUE_CITY, ""to tune your portal to Ardougne."")) return; if (requiredRunes.meetsPortalRequirements(player)) { requiredRunes.deleteRunes(player); portal.setSlot(21, player.getHouse().getWorldObject(room, portal.getId())); } })); if (portalId != 13634 && !player.getHouse().containsAnyObject(13620, 13627, 13634)) option(""Yanille Teleport"", new Dialogue().addOption(""This will cost 100 teleports to tune"", ""Pay runes"", ""Nevermind"").addNext(() -> { RuneSet requiredRunes = new RuneSet(Rune.LAW, 200, Rune.EARTH, 200); if (!player.isQuestComplete(Quest.WATCHTOWER, ""to tune your portal to Yanille."")) return; if (requiredRunes.meetsPortalRequirements(player)) { requiredRunes.deleteRunes(player); portal.setSlot(22, player.getHouse().getWorldObject(room, portal.getId())); } })); if (portalId != 13635 && !player.getHouse().containsAnyObject(13621, 13628, 13635)) option(""Kharyrll Teleport"", new Dialogue().addOption(""This will cost 100 teleports to tune"", ""Pay runes"", ""Nevermind"").addNext(() -> { RuneSet requiredRunes = new RuneSet(Rune.BLOOD, 100, Rune.LAW, 200); if (!player.isQuestComplete(Quest.DESERT_TREASURE, ""to tune your portal to Kharyrll (Canifis)."")) return; if (requiredRunes.meetsPortalRequirements(player)) { requiredRunes.deleteRunes(player); portal.setSlot(23, player.getHouse().getWorldObject(room, portal.getId())); } })); option(""Nevermind""); break; default: Logger.debug(HouseController.class, ""getTeleports"", ""woahhh this might be broken... "" + frameType); } } }); return teleportOptions; } public static String getPortalFrameType(int objectId) { if ((objectId >= 13615 && objectId <= 13621) || objectId == 13636) return ""Teak""; if ((objectId >= 13622 && objectId <= 13628) || objectId == 13637) return ""Mahogany""; if ((objectId >= 13629 && objectId <= 13635) || objectId == 13638) return ""Marble""; return """"; } public void telePlayer(int objectId) { switch (objectId) { case 13615: case 13622: case 13629: Magic.sendNormalTeleportSpell(player, 1, 0, Tile.of(3212, 3424, 0), null, null); //Varrock break; case 13616: case 13623: case 13630: Magic.sendNormalTeleportSpell(player, 1, 0, Tile.of(3222, 3218, 0), null, null); //Lumby break; case 13617: case 13624: case 13631: Magic.sendNormalTeleportSpell(player, 1, 0, Tile.of(2964, 3379, 0), null, null); //Falador break; case 13618: case 13625: case 13632: Magic.sendNormalTeleportSpell(player, 1, 0, Tile.of(2757, 3478, 0), null, null); //Camelot break; case 13619: case 13626: case 13633: Magic.sendNormalTeleportSpell(player, 1, 0, Tile.of(2664, 3305, 0), null, null); //Ardougne break; case 13620: case 13627: case 13634: Magic.sendNormalTeleportSpell(player, 1, 0, Tile.of(2546, 3095, 0), null, null); //Yanille break; case 13621: case 13628: case 13635: Magic.sendNormalTeleportSpell(player, 1, 0, Tile.of(3492, 3471, 0), null, null); //Kharyrll break; default: player.sendMessage(""Uh-oh... This shouldn't have happened (Object: "" + objectId + ""). Please report to staff.""); } } }" "package com.rs.game.content.skills.construction; public class ItemOnServantD extends Conversation { public ItemOnServantD(Player player, NPC npc, int item, boolean isSawmill) { super(player); if (!(npc instanceof ServantNPC servant)) return; boolean proceed = false; for (int bankable : HouseConstants.BANKABLE_ITEMS) { if (item == bankable) { proceed = true; break; } } ItemDefinitions definition = ItemDefinitions.getDefs(item); final int[] plank = SawmillOperator.getPlankForLog(item); if (plank != null || definition.isNoted()) proceed = true; if (!proceed) return; int paymentStage = player.getHouse().getPaymentStage(); if (paymentStage >= 10) { addNPC(servant.getId(), servant.getServantData() == Servant.DEMON_BUTLER ? HeadE.CAT_CALM_TALK2 : HeadE.CALM_TALK, ""Excuse me, but before I can continue working you must pay my fee.""); return; } String name = definition.getName().toLowerCase(); if (definition.isNoted()) { addOptions(""Un-cert this item?"", ops -> { ops.add(""Un-cert "" + name + ""."", () -> setFetchAttributes(RequestType.UNNOTE, item, ""How many would you like to un-note?"")); ops.add(""Fetch another "" + name + ""."", () -> setFetchAttributes(RequestType.WITHDRAW, item, ""How many would you like to retrieve?"")); ops.add(""Bank"", () -> setFetchAttributes(RequestType.DEPOSIT, item, ""How many would you like to bank?"")); ops.add(""Cancel""); }); } else if (isSawmill && plank != null) { addOptions(""Take this to the sawmill?"", ops -> { ops.add(""Take it to the sawmill."", () -> setFetchAttributes(RequestType.SAWMILL, item, ""How many would you like to create?"")); ops.add(""Bank"", () -> setFetchAttributes(RequestType.DEPOSIT, item, ""How many would you like to bank?"")); ops.add(""Cancel""); }); } else { addOptions(""Take this item to the bank?"", ops -> { ops.add(""Fetch another "" + name + ""."", () -> setFetchAttributes(RequestType.WITHDRAW, item, ""How many would you like to retrieve?"")); ops.add(""Bank"", () -> setFetchAttributes(RequestType.DEPOSIT, item, ""How many would you like to bank?"")); ops.add(""Cancel""); }); } create(); } private void setFetchAttributes(RequestType type, int item, String title) { player.sendInputInteger(title, amount -> { if (!player.getHouse().isLoaded() || !player.getHouse().getPlayers().contains(player)) return; player.getHouse().getServantInstance().requestType(item, amount, type); }); } }" "package com.rs.game.content.skills.construction; @PluginEventHandler public class PetHouse { private static final int ITEMS_KEY = 540; private static final int INTERFACE_ID = 879; private static final int INV_INTERFACE_ID = 878; private transient Player player; private final ItemsContainer pets; public PetHouse() { pets = new ItemsContainer<>(72, false); } public static ButtonClickHandler handleInvInterface = new ButtonClickHandler(INV_INTERFACE_ID, e -> { if (e.getComponentId() == 0) if (e.getPacket() == ClientPacket.IF_OP1) e.getPlayer().getHouse().getPetHouse().addItem(e.getSlotId()); else if (e.getPacket() == ClientPacket.IF_OP2) e.getPlayer().getInventory().sendExamine(e.getSlotId()); }); public static ButtonClickHandler handleInterfaceButtons = new ButtonClickHandler(INTERFACE_ID, e -> { if (e.getComponentId() == 13) if (e.getPacket() == ClientPacket.IF_OP1) e.getPlayer().getHouse().getPetHouse().removeItem(e.getSlotId()); }); public void open() { player.getInterfaceManager().sendInterface(INTERFACE_ID); player.getInterfaceManager().sendInventoryInterface(INV_INTERFACE_ID); player.getPackets().setIFRightClickOps(INV_INTERFACE_ID, 0, 0, 27, 0, 1); player.getPackets().sendInterSetItemsOptionsScript(INV_INTERFACE_ID, 0, 93, 4, 7, ""Store"", ""Examine""); player.getPackets().setIFRightClickOps(INTERFACE_ID, 13, 0, ITEMS_KEY, 0, 1); player.getPackets().sendInterSetItemsOptionsScript(INTERFACE_ID, 13, ITEMS_KEY, 12, 6, ""Withdraw"", ""Examine""); refresh(); } public void refresh() { player.getPackets().sendItems(ITEMS_KEY, pets); player.getPackets().sendItems(93, player.getInventory().getItems()); } public void setPlayer(Player player) { this.player = player; } public void removeItem(int slot) { Item item = pets.get(slot); if (item == null) return; item = new Item(item.getId(), 1); int freeSpace = player.getInventory().getFreeSlots(); if (!item.getDefinitions().isStackable()) { if (freeSpace == 0) { player.sendMessage(""Not enough space in your inventory.""); return; } if (freeSpace < item.getAmount()) { item.setAmount(freeSpace); player.sendMessage(""Not enough space in your inventory.""); } } else if (freeSpace == 0 && !player.getInventory().containsItem(item.getId(), 1)) { player.sendMessage(""Not enough space in your inventory.""); return; } player.getHouse().removePet(item, true); pets.remove(slot, item); pets.shift(); player.getInventory().addItem(item); refresh(); } public void addItem(int slot) { int usedSlots = pets.getSize()-pets.freeSlots(); if (usedSlots >= 25 && !player.hasRights(Rights.ADMIN)) { player.sendMessage(""You may only hold up to 25 pets.""); return; } Item item = player.getInventory().getItem(slot); if (item == null) return; if (Pets.forId(item.getId()) == null) { player.sendMessage(""You cannot store this item.""); return; } item = new Item(item.getId(), 1); int freeSpace = pets.getFreeSlots(); if (!item.getDefinitions().isStackable()) { if (freeSpace == 0) { player.sendMessage(""Not enough space in your Familiar Inventory.""); return; } if (freeSpace < item.getAmount()) { item.setAmount(freeSpace); player.sendMessage(""Not enough space in your Familiar Inventory.""); } } else if (freeSpace == 0 && !pets.containsOne(item)) { player.sendMessage(""Not enough space in your Familiar Inventory.""); return; } player.getHouse().addPet(item, true); pets.add(item); pets.shift(); player.getInventory().deleteItem(slot, item); refresh(); } public ItemsContainer getPets() { return pets; } public boolean contains(int itemId) { if (pets.containsOne(new Item(itemId, 1))) return true; return false; } }" "package com.rs.game.content.skills.construction; @PluginEventHandler public class SawmillOperator { public static int[] logs = { 1511, 1521, 6333, 6332 }; public static int[] planks = { 960, 8778, 8780, 8782 }; public static int[] prices = { 100, 250, 500, 1500 }; public static NPCInteractionDistanceHandler sawmillDistance = new NPCInteractionDistanceHandler(4250, (player, npc) -> 1); public static NPCClickHandler handleOps = new NPCClickHandler(new Object[] { 4250 }, e -> { if (e.getOpNum() == 1) e.getPlayer().getInterfaceManager().sendInterface(403); else if (e.getOpNum() == 3) e.getPlayer().getInterfaceManager().sendInterface(403); else if (e.getOpNum() == 4) ShopsHandler.openShop(e.getPlayer(), ""construction_supplies""); }); public static ButtonClickHandler handleSawmillInter = new ButtonClickHandler(403, e -> { if (e.getComponentId() >= 12 && e.getComponentId() <= 15) { final int log = logs[e.getComponentId()-12]; final int pricePer = prices[e.getComponentId()-12]; final int plank = planks[e.getComponentId()-12]; if (e.getPacket() == ClientPacket.IF_OP1) openAreYouSure(e.getPlayer(), log, 1, pricePer, plank); else if (e.getPacket() == ClientPacket.IF_OP2) openAreYouSure(e.getPlayer(), log, 5, pricePer, plank); else if (e.getPacket() == ClientPacket.IF_OP3) openAreYouSure(e.getPlayer(), log, 10, pricePer, plank); else if (e.getPacket() == ClientPacket.IF_OP4) e.getPlayer().sendInputInteger(""How many planks would you like to make?"", (number) -> openAreYouSure(e.getPlayer(), log, number, pricePer, plank)); else if (e.getPacket() == ClientPacket.IF_OP5) openAreYouSure(e.getPlayer(), log, 28, pricePer, plank); } }); public static void openAreYouSure(Player player, final int log, int amount, final int pricePer, final int plank) { if (amount > player.getInventory().getNumberOf(log)) amount = player.getInventory().getNumberOf(log); if (amount == 0) { player.sendMessage(""You don't have any logs to convert.""); return; } final int finalAmount = amount; final int finalPrice = amount*pricePer; player.sendOptionDialogue(""Pay ""+finalPrice+"" gold to make ""+finalAmount+"" planks?"", ops -> { ops.add(""Make ""+finalAmount+"" planks. (""+finalPrice+"" coins)"", () -> { if (!player.getInventory().containsItem(log, finalAmount)) return; if (!player.getInventory().hasCoins(finalPrice)) { player.sendMessage(""You don't have enough money to make the planks.""); return; } player.getInventory().removeCoins(finalPrice); player.getInventory().deleteItem(log, finalAmount); player.getInventory().addItem(plank, finalAmount); }); ops.add(""That's too much money.""); }); } public static int[] getPlankForLog(int item) { for (int i = 0;i < logs.length;i++) if (item == logs[i]) return new int[] { planks[i], prices[i] }; return null; } }" "package com.rs.game.content.skills.construction; public class ServantDialogue extends Conversation { private static final String[] BEGINNING_MESSAGE = { // ""Ah, I visited with her Royal Highness for the Diamond Jubillee, and I liked it so much I never left! However, I find myself without an income. Care to hire me, for only 375 coins?"", ""'Allo mate! Got a job going? Only 375 coins!"", ""Oh! Please hire me sir! I'm very good - well, I'm not bad- and my fee's only 750 coins."", ""You're not aristocracy, but I suppose you'd do. Do you want a good cook for 2250 coins?"", ""Good day, sir! Would sir care to hire a good butler for 3750 coins?"", ""Greetings! I am Alathazdrar, butler to the Demon Lords, and I offer thee my services for a mere 7500 coins!"", }; private static final String[] WHAT_CAN_YOU_DO = { // ""I have some experience cooking, and I'm happy to take items to and from the bank."", ""I'm a great cook, me! I used to work with a rat-catcher, I used to cook for him. There is a dozen different ways you can cook rat!"", ""Well, I can, um. I can cook meals and make tea and everything, and I can even take things to and from the bank for you. I won't make any mistakes this time and everything will be fine!"", ""I, sir, am the finest cook in all Arrow! I can also make good time going to the bank or sawmill."", ""I can fulfill sir's domestic service needs with efficiency and impeccable manners. I hate to boast, but I can say with confidence that no mortal can make trips to the bank or sawmill fast than I!"", ""I have learned my trade under the leash of some of the harshest maters of the Demon Dimensions. I can cook to satisfy the most infernal stomachs, and fly on wings of flame to deposit thine items in the bank in seconds."", }; private static final String[] JOB_HISTORY = { // ""I've worked in the Queen's service almost since I was a lad. A high quality of service expected there, let me tell you!"", ""Well, city warder Bravek once threw a chair at me and yelled at me to get him a hangover cure. So I made it and I think it worked, 'cause then he threw another chair at me and that one hit!"", ""Oh! Oh! I, well I er. It wasn't really my fault, I mean, it was, but not really. I mean, how was I to know that that plate was so valuable? It was just lying around and I don't know art, it just looked like a pretty pattern."", ""I used to be the cook for the old Duke of Lumbridge. Visiting dignataries praised me for my fine banquets! But then someone found a rule that only one family could hold that post. Overnight, I was fired for someone who couldn't even bake cakes without burning them!"", ""From a humble beginning as a dish-washer I have worked my way up through the ranks of domestic service in the households of nobles from Varrock and Ardougne. As a life-long servant I have naturally suppressed my personality."", ""For millennia I have served and waited on the mighty Demon Lords of the infernal Dimensions. I began as a humble footman in the household of Lord Thammaron. Currently, I come to serve the mortal masters in the realms of light."", }; public ServantDialogue(Player player, NPC npc) { super(player); int slot = getSlot(npc.getId()); Servant servant = Servant.values()[slot]; addNPC(npc.getId(), HeadE.CALM_TALK, BEGINNING_MESSAGE[slot]); addOptions(ops -> { ops.add(""What can you do?"") .addPlayer(HeadE.CONFUSED, ""What can you do?"") .addNPC(npc.getId(), HeadE.CALM_TALK, WHAT_CAN_YOU_DO[slot]); ops.add(""Tell me about your previous jobs."") .addPlayer(HeadE.CONFUSED, ""Tell me about your previous jobs."") .addNPC(npc.getId(), HeadE.CALM_TALK, JOB_HISTORY[slot]); ops.add(""You're hired!"", getHireDialogue(servant)); }); } private int getSlot(int npcId) { return (npcId - 4236) / 2; } private Dialogue getHireDialogue(Servant servant) { if (player.getHouse().hasServant()) return new Dialogue().addSimple(""You already have a servant!""); if (player.getSkills().getLevelForXp(Skills.CONSTRUCTION) < servant.getLevel()) return new Dialogue().addSimple(""You need a Construction level of at least "" + servant.getLevel() + "".""); if (player.getInventory().getCoins() < servant.getHirePrice()) return new Dialogue().addSimple(""You do not have enough coins to hire this butler!""); return new Dialogue() .addPlayer(HeadE.CHEERFUL, ""You're hired!"") .addNext(() -> { player.getHouse().setServantOrdinal((byte) servant.ordinal()); player.getInventory().removeCoins(servant.getHirePrice()); }) .addNPC(servant.getId(), HeadE.CHEERFUL, ""Thank you master."") .getHead(); } }" "package com.rs.game.content.skills.construction; public class ServantHouseD extends Conversation { public ServantHouseD(Player player, ServantNPC servant, boolean bankOps) { super(player); servant.setFollowing(true); if (player.getHouse().getPaymentStage() >= 10) { addNPC(servant.getId(), servant.getServantData() == Servant.DEMON_BUTLER ? HeadE.CAT_CALM_TALK2 : HeadE.CALM_TALK, ""Excuse me, but before I can continue working you must pay my fee.""); addOptions(""Would you you like to pay the fee of "" + servant.getServantData().getBankCost() + ""?"", ops -> { ops.add(""Yes."", () -> { int cost = servant.getServantData().getBankCost(); if (!player.getInventory().hasCoins(cost)) { player.npcDialogue(servant.getId(), servant.getServantData() == Servant.DEMON_BUTLER ? HeadE.CAT_CALM_TALK2 : HeadE.UPSET, ""You do not have enough coins to cover up my cost.""); return; } player.getInventory().removeCoins(cost); player.getHouse().resetPaymentStage(); player.npcDialogue(servant.getId(), servant.getServantData() == Servant.DEMON_BUTLER ? HeadE.CAT_CALM_TALK2 : HeadE.CHEERFUL, ""Thank you!""); }); ops.add(""No.""); ops.add(""Fire."", () -> fireServant(player, servant)); }); return; } if (bankOps) { addNext(getBankOptions(player, servant)); return; } addNPC(servant.getId(), servant.getServantData() == Servant.DEMON_BUTLER ? HeadE.CAT_CALM_TALK2 : HeadE.CALM_TALK, ""I am at thy command, my master""); addOptions(ops -> { ops.add(""Go to the bank/sawmill..."") .addNext(getBankOptions(player, servant)); ops.add(""Misc..."") .addOptions(misc -> { misc.add(""Make tea"") .addNPC(servant.getId(), servant.getServantData() == Servant.DEMON_BUTLER ? HeadE.CAT_CALM_TALK2 : HeadE.CALM_TALK, ""Thou shall taste the very tea of the Demon Lords themselves!"") .addNext(() -> servant.makeFood(HouseConstants.TEA_BUILDS)); misc.add(""Serve dinner"") .addNPC(servant.getId(), servant.getServantData() == Servant.DEMON_BUTLER ? HeadE.CAT_CALM_TALK2 : HeadE.CALM_TALK, ""I shall prepare thee a banquet fit for the lords of Pandemonium!"") .addNext(() -> servant.makeFood(HouseConstants.DINNER_BUILDS)); misc.add(""Serve drinks"") .addPlayer(HeadE.CALM_TALK, ""Serve drinks please."") .addNext(() -> servant.makeFood(HouseConstants.TEA_BUILDS)); misc.add(""Greet guests"") .addPlayer(HeadE.CALM_TALK, ""Stay at the entrance and greet guests."") .addNext(() -> { servant.setGreetGuests(true); servant.setFollowing(false); servant.tele(servant.getRespawnTile()); }); }); ops.add(""Stop following me"", () -> servant.setFollowing(false)); ops.add(""You're fired"", () -> fireServant(player, servant)); }); } private Dialogue getBankOptions(Player player, ServantNPC servant) { return new Dialogue().addOptions(ops -> { ops.add(""Take something to the bank""). addNPC(servant.getId(), servant.getServantData() == Servant.DEMON_BUTLER ? HeadE.CAT_CALM_TALK2 : HeadE.CALM_TALK, ""Give any item to me and I shall take it swiftly to the bank where it will be safe from thieves and harm.""); ops.add(""Bring something from the bank"") .addOptions(bank -> { if (servant.getLastBankRetrieve() != null) bank.option(""Fetch another "" + servant.getLastBankRetrieve().getAmount() + "" "" + servant.getLastBankRetrieve().getName().toLowerCase() + ""."", () -> player.getHouse().getServantInstance().requestType(servant.getLastBankRetrieve().getId(), servant.getLastBankRetrieve().getAmount(), RequestType.WITHDRAW)); for (int itemId : HouseConstants.BANKABLE_ITEMS) { bank.option(ItemDefinitions.getDefs(itemId).name, () -> player.sendInputInteger(""How many would you like?"", amount -> { if (!player.getHouse().isLoaded() || !player.getHouse().getPlayers().contains(player)) return; player.getHouse().getServantInstance().requestType(itemId, amount, RequestType.WITHDRAW); })); } }); if (servant.getServantData().isSawmill()) { ops.add(""Take something to the sawmill""). addNPC(servant.getId(), servant.getServantData() == Servant.DEMON_BUTLER ? HeadE.CAT_CALM_TALK2 : HeadE.CALM_TALK, ""Give me some logs and I will return as fast as possible.""); } }); } private void fireServant(Player player, ServantNPC servant) { player.sendOptionDialogue(""Do you really want to fire your servant?"", ops -> { ops.add(""Yes."", () -> { player.playerDialogue(HeadE.CALM_TALK, ""You are dismissed...""); servant.fire(); }); ops.add(""No.""); }); } }" "package com.rs.game.content.skills.construction; public class ServantNPC extends NPC { private final Servant servant; private final Player owner; private final House house; private boolean follow, greetGuests; private Item lastBankRetrieve; private Item lastSawmillSend; public ServantNPC(House house) { super(house.getServant().getId(), house.getPlayer().getTile().transform(0, 0, 0), true); servant = house.getServant(); owner = house.getPlayer(); this.house = house; if (owner.getSkills().getLevel(Constants.CONSTRUCTION) < servant.getLevel()) { house.setServantOrdinal((byte) -1); } } public void fire() { house.setServantOrdinal((byte) -1); } public long getBankDelay() { return servant.getBankDelay(); } public boolean isFollowing() { return follow; } public void setFollowing(boolean follow) { this.follow = follow; if (!follow) setNextFaceEntity(null); } public void makeFood(final Builds[] builds) { if (house == null) return; setFollowing(false); if (house.isBuildMode()) { owner.sendMessage(""Your servant cannot prepare food while in building mode.""); return; } String basicResponse = ""I apologise, but I cannot serve "" + (owner.getAppearance().isMale() ? ""Sir"" : ""Madam"") + "" without""; final RoomReference kitchen = house.getRoom(Room.KITCHEN), diningRoom = house.getRoom(Room.DINING_ROOM); if (kitchen == null) { owner.npcDialogue(getId(), HeadE.CALM_TALK, basicResponse + "" a proper kitchen.""); return; } if (diningRoom == null) { owner.npcDialogue(getId(), HeadE.CALM_TALK, basicResponse + "" a proper dining room.""); return; } for (Builds build : builds) if (!kitchen.containsBuild(build)) { owner.npcDialogue(getId(), HeadE.CALM_TALK, basicResponse + "" a "" + build.toString().toLowerCase() + "".""); return; } if (!diningRoom.containsBuild(HouseConstants.Builds.DINING_TABLE)) { owner.npcDialogue(getId(), HeadE.CALM_TALK, basicResponse + "" a dining table""); return; } final Tile kitchenTile = house.getCenterTile(kitchen); final Tile diningRoomTile = house.getCenterTile(diningRoom); setCantInteract(true); house.incrementPaymentStage(); WorldTasks.scheduleLooping(new Task() { int count = 0, totalCount = 0, index = 0; @Override public void run() { if (!house.isLoaded()) { stop(); return; } count++; if (count == 1) { setNextForceTalk(new ForceTalk(""I shall return in a moment."")); setNextAnimation(new Animation(858)); totalCount = (builds.length * 3) + count; } else if (count == 2) tele(Tile.of(World.getFreeTile(kitchenTile, 2))); else if (totalCount > 0 && index < builds.length) { int calculatedCount = totalCount - count; Builds build = builds[index]; if (calculatedCount % 3 == 0) { setNextAnimation(new Animation(build == Builds.STOVE ? 897 : 3659)); index++; } else if (0 == 0) calcFollow(house.getWorldObjectForBuild(kitchen, build), true); } else if (count == totalCount + 3) tele(World.getFreeTile(diningRoomTile, 2)); else if (count == totalCount + 4 || count == totalCount + 5) { GameObject diningTable = house.getWorldObjectForBuild(diningRoom, Builds.DINING_TABLE); if (count == totalCount + 4) calcFollow(diningTable, true); else { setNextAnimation(new Animation(808)); int rotation = kitchen.getRotation(); for (int x = 0; x < (rotation == 1 || rotation == 3 ? 2 : 4); x++) for (int y = 0; y < (rotation == 1 || rotation == 3 ? 4 : 2); y++) World.addGroundItem(new Item(builds.length == 6 ? 7736 : builds.length == 5 ? house.getServant().getFoodId() : HouseConstants.BEERS[kitchen.getBuildSlot(Builds.BARRELS)]), diningTable.getTile().transform(x, y, 0), null, false, 300); setCantInteract(false); stop(); } } } }, 2, 2); } public enum RequestType { WITHDRAW, SAWMILL, UNNOTE, DEPOSIT } public void requestType(int item, int quantity, final RequestType type) { final Bank bank = owner.getBank(); final ItemDefinitions defs = ItemDefinitions.getDefs(item); int inventorySize = servant.getInventorySize(); if (!bank.containsItem(defs.isNoted() ? defs.getCertId() : item, 1) && type == RequestType.WITHDRAW) { owner.npcDialogue(getId(), servant == Servant.DEMON_BUTLER ? HeadE.CAT_CALM_TALK2 : HeadE.CALM_TALK, ""It appears you do not have this item in your bank.""); return; } if (quantity > inventorySize) { owner.npcDialogue(getId(), servant == Servant.DEMON_BUTLER ? HeadE.CAT_CALM_TALK2 : HeadE.CALM_TALK, ""I'm sorry. I can only hold "" + inventorySize + "" items during a trip.""); return; } transformIntoNPC(1957); if (type == RequestType.SAWMILL || type == RequestType.UNNOTE) { int amountOwned = owner.getInventory().getAmountOf(item); if (quantity > amountOwned) { quantity = amountOwned; if (quantity > inventorySize) quantity = inventorySize; } } final int[] plank = SawmillOperator.getPlankForLog(item); if (plank != null && type == RequestType.SAWMILL) { final int cost = (int) ((plank[1] * 0.7) * quantity); if (!owner.getInventory().hasCoins(cost)) { owner.npcDialogue(getId(), servant == Servant.DEMON_BUTLER ? HeadE.CAT_CALM_TALK2 : HeadE.CALM_TALK, ""You do not have enough coins to cover the costs of the sawmill.""); return; } } if (type == RequestType.WITHDRAW || type == RequestType.SAWMILL || type == RequestType.UNNOTE) { if (type == RequestType.UNNOTE || type == RequestType.WITHDRAW) { int freeSlots = owner.getInventory().getFreeSlots(); if (quantity > freeSlots) quantity = freeSlots; } else if (type == RequestType.SAWMILL) owner.getInventory().removeCoins((int) (quantity * (plank[1] * 0.7))); if (type != RequestType.WITHDRAW) owner.getInventory().deleteItem(item, quantity); } final int completeQuantity = quantity; setCantInteract(true); if (defs.isNoted()) item = defs.getCertId(); final int finalItem = item; WorldTasks.schedule(new Task() { @Override public void run() { transformIntoNPC(servant.getId()); setCantInteract(false); if (!owner.isRunning() || !house.isLoaded() || !house.getPlayers().contains(owner)) { if (type == RequestType.SAWMILL || type == RequestType.UNNOTE) bank.addItem(new Item(finalItem, completeQuantity), false); return; } house.incrementPaymentStage(); if (type == RequestType.WITHDRAW) { if (bank.containsItem(finalItem, completeQuantity)) { bank.withdrawItemDel(finalItem, completeQuantity); owner.getInventory().addItem(finalItem, completeQuantity, true); } } else if (type == RequestType.SAWMILL) owner.getInventory().addItem(plank[0], completeQuantity); else if (type == RequestType.UNNOTE) owner.getInventory().addItem(finalItem, completeQuantity); else for (int i = 0; i < completeQuantity; i++) bank.depositItem(owner.getInventory().getItems().getThisItemSlot(finalItem), completeQuantity, false); owner.npcDialogue(getId(), servant == Servant.DEMON_BUTLER ? HeadE.CAT_CALM_TALK2 : HeadE.CALM_TALK, type == RequestType.DEPOSIT ? ""I have successfully deposited your items into your bank. No longer will the items be at risk from thieves."" : ""I have returned with the items you asked me to retrieve.""); } }, (int) servant.getBankDelay()); } public void call() { Tile teleTile = owner.getNearestTeleTile(this); if (teleTile != null) tele(teleTile); } private void sendFollow() { if (getLastFaceEntity() != owner.getClientIndex()) setNextFaceEntity(owner); int size = getSize(); int targetSize = owner.getSize(); if (WorldUtil.collides(getX(), getY(), size, owner.getX(), owner.getY(), targetSize) && !owner.hasWalkSteps()) { resetWalkSteps(); if (!addWalkSteps(owner.getX() + targetSize, getY())) { resetWalkSteps(); if (!addWalkSteps(owner.getX() - size, getY())) { resetWalkSteps(); if (!addWalkSteps(getX(), owner.getY() + targetSize)) { resetWalkSteps(); if (!addWalkSteps(getX(), owner.getY() - size)) return; } } } return; } resetWalkSteps(); if (!lineOfSightTo(owner, true) || !WorldUtil.isInRange(getX(), getY(), size, owner.getX(), owner.getY(), targetSize, 0)) calcFollow(owner, 2, true); } @Override public void processNPC() { if (greetGuests && !withinDistance(getRespawnTile(), 5)) greetGuests = false; if (!follow) { super.processNPC(); return; } if (!withinDistance(owner, 12)) { call(); return; } sendFollow(); } public boolean isGreetGuests() { return greetGuests; } public void setGreetGuests(boolean greetGuests) { this.greetGuests = greetGuests; } public Servant getServantData() { return servant; } public Item getLastSawmillSend() { return lastSawmillSend; } public void setLastSawmillSend(Item lastSawmillSend) { this.lastSawmillSend = lastSawmillSend; } public Item getLastBankRetrieve() { return lastBankRetrieve; } public void setLastBankRetrieve(Item lastBankRetrieve) { this.lastBankRetrieve = lastBankRetrieve; } }" "package com.rs.game.content.skills.construction; public class SitChair extends PlayerAction { private final Tile originalTile; private final Tile chairTile; private boolean tped; private final int animation; public SitChair(Player player, GameObject object) { animation = HouseConstants.getSitAnimation(object.getId()); originalTile = Tile.of(player.getTile()); chairTile = object.getTile(); Tile face = Tile.of(player.getTile()); if (object.getType() == ObjectType.SCENERY_INTERACT) { if (object.getRotation() == 0) face = face.transform(0, -1, 0); else if (object.getRotation() == 2) face = face.transform(0, 1, 0); else if (object.getRotation() == 3) face = face.transform(1, 0, 0); else if (object.getRotation() == 1) face = face.transform(-1, 0, 0); } else if (object.getType() == ObjectType.GROUND_INTERACT) if (object.getRotation() == 1) face = face.transform(-1, 1, 0); else if (object.getRotation() == 2) face = face.transform(1, 1, 0); else if (object.getRotation() == 0) face = face.transform(-1, -1, 0); else if (object.getRotation() == 3) face = face.transform(1, -1, 0); player.setNextFaceTile(face); } @Override public boolean start(Player player) { setActionDelay(player, 1); return true; } @Override public boolean process(Player player) { return true; } @Override public int processWithDelay(Player player) { if (!tped) { player.tele(chairTile); tped = true; } player.setNextAnimation(new Animation(animation)); return 0; } @Override public void stop(final Player player) { player.lock(1); player.tele(originalTile); player.setNextAnimation(new Animation(-1)); } }" "package com.rs.game.content.skills.construction; public class TabletMaking { public enum Tablet { ONYX_ENCHANT(8021, 87, new RuneSet(Rune.COSMIC, 1, Rune.EARTH, 20, Rune.FIRE, 20), 72.8, 9), LUMBRIDGE_TELEPORT(8008, 31, new RuneSet(Rune.AIR, 3, Rune.EARTH, 1, Rune.LAW, 1), 41, 13), DIAMOND_ENCHANT(8019, 57, new RuneSet(Rune.COSMIC, 1, Rune.EARTH, 10), 50.3, 6), WATCHTOWER_TELEPORT(8012, 58, new RuneSet(Rune.EARTH, 2, Rune.LAW, 2), 68, 16), HOUSE_TELEPORT(8013, 40, new RuneSet(Rune.AIR, 1, Rune.EARTH, 1, Rune.LAW, 1), 30, 14), EMERALD_ENCHANT(8017, 27, new RuneSet(Rune.COSMIC, 1, Rune.AIR, 3), 27.8, 8), SAPPHIRE_ENCHANT(8016, 7, new RuneSet(Rune.COSMIC, 1, Rune.WATER, 1), 13.2, 11), FALADOR_TELEPORT(8009, 37, new RuneSet(Rune.AIR, 3, Rune.WATER, 1, Rune.LAW, 1), 48, 12), ARDOUGNE_TELEPORT(8011, 51, new RuneSet(Rune.WATER, 2, Rune.LAW, 2), 63.5, 2), BONES_TO_BANANAS(8014, 15, new RuneSet(Rune.WATER, 2, Rune.EARTH, 2, Rune.NATURE, 1), 25, 3), DRAGONSTONE_ENCHANT(8020, 68, new RuneSet(Rune.COSMIC, 1, Rune.WATER, 15, Rune.EARTH, 15), 58.5, 7), RUBY_ENCHANT(8018, 49, new RuneSet(Rune.COSMIC, 1, Rune.FIRE, 5), 44.3, 10), VARROCK_TELEPORT(8007, 25, new RuneSet(Rune.AIR, 3, Rune.LAW, 1, Rune.FIRE, 1), 35, 15), CAMELOT_TELEPORT(8010, 45, new RuneSet(Rune.AIR, 5, Rune.LAW, 1), 55.5, 5), BONES_TO_PEACHES(8015, 60, new RuneSet(Rune.WATER, 4, Rune.EARTH, 4, Rune.NATURE, 2), 35.5, 4); private static final Map MAP = new HashMap<>(); static { for (Tablet t : Tablet.values()) MAP.put(t.componentId(), t); } public static Tablet forId(int componentId) { return MAP.get(componentId); } private final int id; private final int levelReq; private final RuneSet runeReq; private final double experience; private final int componentId; private Tablet(int id, int level, RuneSet runes, double experience, int componentId) { this.id = id; levelReq = level; runeReq = runes; this.experience = experience; this.componentId = componentId; } public int id() { return id; } public int levelReq() { return levelReq; } public RuneSet runeReq() { return runeReq; } public double experience() { return experience; } public int componentId() { return componentId; } } private static final int SOFT_CLAY = 1761; private static final int[][] ENABLED_SLOTS = { { 11, 15 }, { 11, 15, 12, 13 }, { 11, 8, 15, 3 }, { 11, 15, 12, 13, 5, 2 }, { 11, 8, 10, 6, 15, 3 }, { 15, 13, 12, 5, 2, 16, 14 }, { 11, 8, 10, 6, 7, 9, 15, 3, 4 } }; public static void openTabInterface(Player player, int index) { player.getPackets().sendVarc(943, index + 1); player.getInterfaceManager().sendInterface(400); player.getTempAttribs().setI(""tablet_index"", index); player.setNextAnimation(new Animation(3652)); } public static void handleTabletCreation(final Player player, int componentId, int amount) { player.closeInterfaces(); final int index = player.getTempAttribs().getI(""tablet_index""); for (int enabledSlot : ENABLED_SLOTS[index]) if (enabledSlot == componentId) { Tablet t = Tablet.forId(componentId); if (player.getSkills().getLevel(Constants.MAGIC) < t.levelReq) { player.sendMessage(""You need a Magic level of "" + t.levelReq + "" in order to create this tablet.""); return; } int realAmount = 0; for (int loop = 0; loop < amount; loop++) { if (!Magic.checkRunes(player, false, t.runeReq)) return; if (!player.getInventory().containsItem(SOFT_CLAY, 1)) { player.sendMessage(""You need some soft clay to craft tablets.""); return; } realAmount++; Magic.checkRunes(player, true, t.runeReq); player.getInventory().deleteItem(SOFT_CLAY, 1); player.getInventory().addItem(new Item(t.id, 1)); } player.getSkills().addXp(Constants.MAGIC, t.experience * realAmount); player.lock(2); player.setNextAnimation(new Animation(3645)); player.getTempAttribs().removeI(""tablet_index""); return; } player.sendMessage(""You cannot create that tablet, please select another.""); } }" "package com.rs.game.content.skills.cooking; public enum Brewable { KELDA_STOUT(new int[] { 6118, 6118 }, null, 17, 6113, 1, 1), DWARVEN_STOUT(new int[] { 1913, 5747 }, new int[] { 5777, 5857 }, 19, 5994, 4, 215), ASGARNIAN_ALE(new int[] { 1905, 5739 }, new int[] { 5785, 5865 }, 24, 5996, 4, 248), GREENMANS_ALE(new int[] { 1909, 5743 }, new int[] { 5793, 5873 }, 29, 255, 4, 281), WIZARD_MIND_BOMB(new int[] { 1907, 5741 }, new int[] { 5801, 5881 }, 34, 5998, 4, 314), DRAGON_BITTER(new int[] { 1911, 5745 }, new int[] { 5809, 5889 }, 39, 6000, 4, 347), MOONLIGHT_MEAD(new int[] { 5763, 5749 }, new int[] { 5817, 5897 }, 44, 6004, 4, 380), AXEMANS_FOLLY(new int[] { 5751, 5753 }, new int[] { 5825, 5905 }, 49, 6043, 1, 413), CHEFS_DELIGHT(new int[] { 5755, 5757 }, new int[] { 5833, 5913 }, 54, 1975, 4, 446), SLAYERS_RESPITE(new int[] { 5759, 5761 }, new int[] { 5841, 5921 }, 59, 6002, 4, 479), CIDER(new int[] { 5763, 5765 }, new int[] { 5849, 5929 }, 14, 5992, 4, 182); private final int[] beerGlassId; private final int[] calquatId; private final int levelRequirement; private final int ingredient; private final int ingredientAmount; private final int xp; private static final Map MAP = new HashMap<>(); public static Brewable forId(int itemId) { return MAP.get(itemId); } static { for (final Brewable brewable : Brewable.values()) MAP.put(brewable.ingredient, brewable); } private Brewable(int[] beerGlassId, int[] calquatId, int levelRequirement, int ingredient, int ingredientAmount, int xp) { this.beerGlassId = beerGlassId; this.calquatId = calquatId; this.levelRequirement = levelRequirement; this.ingredient = ingredient; this.ingredientAmount = ingredientAmount; this.xp = xp; } public int getLevelRequirement() { return levelRequirement; } public int getBeerGlassId(boolean mature) { return beerGlassId[mature ? 1 : 0]; } public int getCalquatId(boolean mature) { return calquatId[mature ? 1 : 0]; } public int getIngredient() { return ingredient; } public int getIngredientAmount() { return ingredientAmount; } public int getXp() { return xp; } public int getVatVal(int stage) { if (this == KELDA_STOUT) return 68 + stage; return (ordinal() * 6) + 4 + stage; } public int getBarrelVal(boolean mature) { if (this == KELDA_STOUT) return 3; return (ordinal() * 8) + (mature ? 128 : 0); } }" "package com.rs.game.content.skills.cooking; @PluginEventHandler public class Brewery { private static final int BUCKET_OF_WATER = 1929; private static final int BARLEY_MALT = 6008; private static final int ALE_YEAST = 5767; private static final int EMPTY_BUCKET = 1925; private static final int THE_STUFF = 8988; private static final int BEER_GLASS = 1919; private static final int CALQUAT_KEG = 5769; private static final Animation ADD_INGREDIENT = new Animation(2292); private static final Animation POUR_WATER = new Animation(2283); private static final Animation CALQUAT_LEVEL = new Animation(2284); private static final Animation BEER_GLASS_LEVEL = new Animation(2285); public static final long BREW_TICKS = Ticks.fromHours(12); private Brewable brew; private int prep; private int fermentStage; private long lastTime; private boolean barrelled; private boolean theStuff; private boolean spoiled; private boolean mature; private final boolean keldagrim; private transient Player player; public Brewery(boolean keldagrim) { this.keldagrim = keldagrim; } public void setPlayer(Player player) { this.player = player; } public static LoginHandler onLogin = new LoginHandler(e -> { e.getPlayer().getKeldagrimBrewery().updateVars(); e.getPlayer().getPhasmatysBrewery().updateVars(); }); public static ObjectClickHandler handleValve = new ObjectClickHandler(new Object[] { 7442, 7443 }, e -> { Brewery brewery = e.getObjectId() == 7442 ? e.getPlayer().getKeldagrimBrewery() : e.getPlayer().getPhasmatysBrewery(); brewery.turnValve(); }); public static ObjectClickHandler handleBarrels = new ObjectClickHandler(new Object[] { 7431, 7432 }, e -> { Brewery brewery = e.getObjectId() == 7431 ? e.getPlayer().getKeldagrimBrewery() : e.getPlayer().getPhasmatysBrewery(); switch(e.getOption()) { case ""Drain"": brewery.reset(); e.getPlayer().sendMessage(""You drain the spoiled drink from the vat.""); break; case ""Level"": brewery.level(); break; } }); public static ItemOnObjectHandler handleVats = new ItemOnObjectHandler(new Object[] { 7494, 7495 }, Stream.concat(Arrays.stream(Brewable.values()).map(Brewable::getIngredient), Stream.of(BUCKET_OF_WATER, BARLEY_MALT, ALE_YEAST, THE_STUFF)).toArray(), e -> { Brewery brewery = e.getObjectId() == 7494 ? e.getPlayer().getKeldagrimBrewery() : e.getPlayer().getPhasmatysBrewery(); switch(e.getItem().getId()) { case BUCKET_OF_WATER: brewery.addWater(); break; case BARLEY_MALT: brewery.addMalt(); break; case ALE_YEAST: brewery.addYeast(); break; case THE_STUFF: brewery.addTheStuff(); break; default: brewery.addSecondary(e.getItem().getId()); break; } brewery.updateVars(); }); public void ferment() { if (isFinished()) return; if (Utils.random(80 + player.getSkills().getLevel(Constants.COOKING)) == 0) spoiled = true; if (Utils.random(5) == 0) fermentStage = Utils.clampI(fermentStage+1, 0, 4); if (Utils.random(200) == 0) fermentStage = 4; } public void process() { if (lastTime <= 0) return; long currTime = System.currentTimeMillis(); long timePassed = currTime - lastTime; if (timePassed > BREW_TICKS) { int cycles = (int) (timePassed / BREW_TICKS); for (int i = 0;i < cycles;i++) ferment(); lastTime = currTime - (timePassed % (cycles * BREW_TICKS)); } updateVars(); } public void addWater() { if (prep != 0) return; if (player.getInventory().containsItem(BUCKET_OF_WATER, 2)) { player.setNextAnimation(POUR_WATER); player.getInventory().deleteItem(BUCKET_OF_WATER, 2); player.getInventory().addItem(EMPTY_BUCKET, 2); prep = 1; } else player.sendMessage(""You need 2 buckets of water to add to the brew.""); } public void addMalt() { if (prep != 1) { player.sendMessage(""Add water first, then malt, then ale yeast.""); return; } if (player.getInventory().containsItem(BARLEY_MALT, 2)) { player.setNextAnimation(ADD_INGREDIENT); player.getInventory().deleteItem(BARLEY_MALT, 2); prep = 2; } else player.sendMessage(""You need two barley malts to add to the brew.""); } public void addSecondary(int itemId) { Brewable brew = Brewable.forId(itemId); if (brew != null) { if (player.getSkills().getLevel(Constants.COOKING) < brew.getLevelRequirement()) { player.sendMessage(""You need a cooking level of "" + brew.getLevelRequirement() + "" to create that brew.""); return; } if (prep == 2) { if (player.getInventory().containsItem(brew.getIngredient(), brew.getIngredientAmount())) { player.getInventory().deleteItem(brew.getIngredient(), brew.getIngredientAmount()); player.setNextAnimation(ADD_INGREDIENT); this.brew = brew; } else player.sendMessage(""You need "" + brew.getIngredientAmount() + "" to create that brew.""); } else player.sendMessage(""You need to have added water and barley malt before adding the ale's ingredients.""); } else player.sendMessage(""Nothing interesting happens.""); } public void addYeast() { if (prep != 2 || brew == null || !player.getInventory().containsItem(ALE_YEAST, 1)) { player.sendMessage(""The brew isn't ready for the yeast yet.""); return; } if (lastTime >= 1) { player.sendMessage(""The brew is already fermenting.""); return; } player.setNextAnimation(ADD_INGREDIENT); player.getInventory().deleteItem(ALE_YEAST, 1); lastTime = System.currentTimeMillis(); player.sendMessage(""The brew begins to ferment.""); } public void addTheStuff() { if (prep != 2 || !player.getInventory().containsItem(THE_STUFF, 1)) { player.sendMessage(""Add water first, then malt, and the ale's ingredients before adding \""the stuff\"".""); return; } if (theStuff) { player.sendMessage(""You've already added \""the stuff\"" to this batch.""); return; } player.setNextAnimation(ADD_INGREDIENT); player.getInventory().deleteItem(THE_STUFF, 1); theStuff = true; } public void turnValve() { if (isFinished() && !barrelled) { barrelled = true; if (Utils.random(100) <= (theStuff ? 75 : 10)) mature = true; updateVars(); } else player.sendMessage(""The brew isn't done fermenting yet.""); } public void level() { if (brew == Brewable.KELDA_STOUT) { if (player.getInventory().containsItem(BEER_GLASS, 1)) { player.getInventory().deleteItem(BEER_GLASS, 1); player.getInventory().addItem(brew.getBeerGlassId(mature), 1); player.setNextAnimation(BEER_GLASS_LEVEL); reset(); } else player.sendMessage(""You need a beer glass to empty the stout into.""); return; } int container = -1; if (player.getInventory().containsItem(BEER_GLASS, 8)) container = BEER_GLASS; if (player.getInventory().containsItem(CALQUAT_KEG, 2)) container = CALQUAT_KEG; if (container == -1) { player.sendMessage(""You need 8 beer glasses or 2 calquat kegs to empty this vat.""); return; } player.incrementCount(brew.name() + "" brewed""); if (mature) player.incrementCount(""Mature "" + brew.name() + "" brewed""); player.getInventory().deleteItem(container, container == BEER_GLASS ? 8 : 2); player.getInventory().addItem(container == BEER_GLASS ? brew.getBeerGlassId(mature) : brew.getCalquatId(mature), container == BEER_GLASS ? 8 : 2); player.getSkills().addXp(Constants.COOKING, brew.getXp()*8); player.setNextAnimation(container == BEER_GLASS ? BEER_GLASS_LEVEL : CALQUAT_LEVEL); reset(); } public void reset() { brew = null; prep = 0; theStuff = false; spoiled = false; mature = false; barrelled = false; fermentStage = 0; lastTime = -1; updateVars(); } public boolean isFinished() { return brew != null && (spoiled || fermentStage >= 4 || (brew == Brewable.KELDA_STOUT && fermentStage >= 3)); } public void updateVars() { if (brew == null) { setBarrel(0); setVat(Utils.clampI(prep, 0, 2)); return; } if (isFinished()) { if (spoiled) { setBarrel(barrelled ? 1 : 0); setVat(barrelled ? 0 : 64); } else { setVat(barrelled ? 0 : brew.getVatVal(fermentStage)); setBarrel(barrelled ? brew.getBarrelVal(mature) : 0); } } else setVat(brew.getVatVal(fermentStage)); } private void setVat(int value) { player.getVars().setVarBit(keldagrim ? 736 : 737, value); } private void setBarrel(int value) { player.getVars().setVarBit(keldagrim ? 738 : 739, value); } }" "package com.rs.game.content.skills.cooking; @PluginEventHandler public class Cooking extends PlayerAction { public static ItemOnObjectHandler foodOnCookingObj = new ItemOnObjectHandler(new Object[] { ""Fire"", ""Range"", ""Campfire"", ""Oven"", ""Cooking range"", ""Sulphur pit"", ""Stove"", ""Clay oven"", ""Clay Oven"", ""Fireplace"" }, Arrays.stream(Cookables.values()).map(item -> item.raw.getId()).toArray(), e -> e.getPlayer().startConversation(new CookingD(e.getPlayer(), Cookables.forId(e.getItem().getId()), e.getObject()))); public enum Cookables { SODA_ASH_1(401, 1781, new int[] {1781}, 1, 0, 1), SODA_ASH_2(7516, 1781, new int[] {1781}, 1, 0, 1), SODA_ASH_3(10978, 1781, new int[] {1781}, 1, 0, 1), NETTLE_TEA(4237, 4239, new int[] {4239}, 1, 0, 61), KARAMBWAN(3142, 3148, new int[] {3144}, 1, 20, 80), POISON_KARAMBWAN(3144, 3146, new int[] {3146}, 1, 20, 1), BURNT_MEAT(2142, 2146, new int[] {2146}, 1, 0, 0), RAW_MEAT(2132, 2146, new int[] {2142, 9436}, 1, 34, 30), RAW_RAT(2134, 2146, new int[] {2142}, 1, 34, 30), RAW_BEAR(2136, 2146, new int[] {2142, 9436}, 1, 34, 30), RAW_WOLF(23058, 2146, new int[] {2142, 9436}, 1, 34, 30), RAW_RABBIT(3226, 7222, new int[] {3228}, 1, 34, 30, false, true), RAW_CHICKEN(2138, 2144, new int[] {2140}, 1, 34, 30), RAW_SHRIMP(317, 7954, new int[] {315}, 1, 34, 30), RAW_ANCHOVIES(321, 323, new int[] {319}, 1, 34, 30), RAW_CRAYFISH(13435, 13437, new int[] {13433}, 1, 34, 30), RAW_MEAT_GHOST(4287, 2146, new int[] {2142}, 1, 34, 30), RAW_CHICKEN_GHOST(4289, 2146, new int[] {2142}, 1, 34, 30), BREAD(2307, 2311, new int[] {2309}, 1, 37, 40), RAW_SARDINE(327, 369, new int[] {325}, 1, 37, 40), RAW_UGTHANKI_MEAT(1859, 2146, new int[] {1861}, 1, 100, 40), RAW_KARAMBWANJI(3150, 592, new int[] {3151}, 1, 28, 10), RAW_HERRING(345, 357, new int[] {347}, 5, 41, 50), RAW_POTATO(1942, 6699, new int[] {6701}, 7, 41, 15), RAW_MACKEREL(353, 357, new int[] {355}, 10, 45, 60), RAW_REDBERRY_PIE(2321, 2329, new int[] {2325}, 10, 45, 78), RAW_BIRD_MEAT(9978, 9982, new int[] {23060}, 11, 99, 62), RAW_BIRD_MEAT2(9984, 9982, new int[] {9980}, 11, 99, 62, false, true), RAW_TROUT(335, 343, new int[] {333}, 15, 49, 70), RAW_COD(341, 343, new int[] {339}, 18, 51, 75), RAW_PIKE(349, 343, new int[] {351}, 20, 53, 75), RAW_MEAT_PIE(2319, 2329, new int[] {2327}, 20, 53, 110), RAW_CRAB_MEAT(7518, 7520, new int[] {7521}, 21, 62, 100), RAW_BEAST_MEAT(9986, 9990, new int[] {9988}, 21, 99, 82.5D, true, false), RAW_SALMON(331, 343, new int[] {329}, 25, 58, 90), RAW_SLIMY_EEL(3379, 3383, new int[] {3381}, 28, 60, 95), SWEETCORN(5986, 5990, new int[] {5988}, 28, 53, 104), RAW_MUD_PIE(7168, 2329, new int[] {7170}, 29, 63, 128), RAW_CHOMPY(2876, 2880, new int[] {2878}, 30, 99, 140, true, true), RAW_TUNA(359, 367, new int[] {361}, 30, 63, 100), RAW_APPLE_PIE(2317, 2329, new int[] {2323}, 30, 63, 130), RAW_FISHCAKE(7529, 7531, new int[] {7530}, 31, 62, 100), RAW_GARDEN_PIE(7176, 2329, new int[] {7178}, 34, 78, 138), RAW_RAINBOW_FISH(10138, 10140, new int[] {10136}, 35, 64, 110), RAW_CAVE_EEL(5001, 5006, new int[] {5003}, 38, 74, 115), RAW_LOBSTER(377, 381, new int[] {379}, 40, 74, 120), RAW_JUBBLY(7566, 7570, new int[] {7568}, 41, 99, 160, true, false), RAW_BASS(363, 367, new int[] {365}, 43, 79, 130), RAW_SWORDFISH(371, 375, new int[] {373}, 45, 86, 140), RAW_FISH_PIE(7186, 2329, new int[] {7188}, 47, 74, 164), RAW_LAVA_EEL(2148, -1, new int[] {2149}, 53, 0, 30), RAW_MONKFISH(7944, 7948, new int[] {7946}, 62, 92, 150), RAW_ADMIRAL_PIE(7196, 2329, new int[] {7198}, 70, 94, 210), RAW_BARON_SHARK(19947, 387, new int[] {19948}, 80, 95, 210), RAW_SHARK(383, 387, new int[] {385}, 80, 100, 210), RAW_SEA_TURTLE(395, 399, new int[] {397}, 82, 100, 211.3D), // HARDENED_STRAIT_ROOT(21349, -1, 21351, 83, 1, 379, false, true), RAW_WILD_PIE(7206, 2329, new int[] {7208}, 85, 100, 240), RAW_CAVEFISH(15264, 15268, new int[] {15266}, 88, 100, 214), RAW_MANTA_RAY(389, 393, new int[] {391}, 91, 100, 216), RAW_ROCKTAIL(15270, 15274, new int[] {15272}, 93, 100, 225), RAW_SUMMER_PIE(7216, 2329, new int[] {7218}, 95, 100, 260), // Dungeoneering CAVE_POTATO(17817, -1, new int[] {18093}, 1, 1, 9), HIEM_CRAB(17797, 18179, new int[] {18159}, 1, 20, 22), RED_EYE(17799, 18181, new int[] {18161}, 10, 30, 41), DUSK_EEL(17801, 18183, new int[] {18163}, 20, 40, 61), GIANT_FLATFISH(17803, 18185, new int[] {18165}, 30, 50, 82), SHORTFINNED_EEL(17805, 18187, new int[] {18167}, 40, 60, 103), WEB_SNIPPER(17807, 18189, new int[] {18169}, 50, 70, 124), BOULDABASS(17809, 18191, new int[] {18171}, 60, 70, 146), SALVE_EEL(17811, 18193, new int[] {18173}, 70, 70, 168), BLUE_CRAB(17813, 18195, new int[] {18175}, 80, 70, 191), CAVE_MORAY(17815, 18197, new int[] {18177}, 90, 70, 215); private final static Map ingredients = new HashMap<>(); public static Cookables forId(int itemId) { return ingredients.get(itemId); } static { for (Cookables ingredient : Cookables.values()) { ingredients.put(ingredient.getRawItem().getId(), ingredient); } } private final Item raw; private final int lvl; private final int burningLvl; private final double xp; private final Item burnt; private final int[] product; private final boolean spitRoast; private final boolean fireOnly; Cookables(Item raw, Item burnt, int[] product, int lvl, int burningLvl, double exp, boolean spitRoast, boolean fireOnly) { this.raw = raw; this.lvl = lvl; this.burningLvl = burningLvl; this.xp = exp; this.burnt = burnt; this.product = product; this.spitRoast = spitRoast; this.fireOnly = fireOnly; } Cookables(Item raw, Item burnt, int[] product, int lvl, int burningLvl, double exp) { this(raw, burnt, product, lvl, burningLvl, exp, false, false); } Cookables(int rawId, int burntId, int[] productId, int lvl, int burningLvl, double exp, boolean spitRoast, boolean fireOnly) { this(new Item(rawId), new Item(burntId), productId, lvl, burningLvl, exp, spitRoast, fireOnly); } Cookables(int rawId, int burntId, int[] productId, int lvl, int burningLvl, double exp) { this(new Item(rawId), new Item(burntId), productId, lvl, burningLvl, exp); } public Item getRawItem() { return raw; } public int getLevel() { return lvl; } public Item getBurntItem() { return burnt; } public int[] getProductItem() { return product; } public double getXp() { return xp; } public int getBurningLvl() { return burningLvl; } public boolean isSpitRoastRequired() { return spitRoast; } public boolean isFireOnly() { return fireOnly; } } private final String productName; private final GameObject gameObject; private final Cookables cookable; private int quantity; private final int option; public Cooking(Player player, int option, GameObject gameObject, Cookables cookable, int quantity) { this.option = option; this.gameObject = gameObject; this.quantity = quantity; this.cookable = cookable; this.productName = new Item(cookable.getProductItem()[option]).getDefinitions().getName().toLowerCase(); } @Override public boolean start(Player player) { if (option >= cookable.getProductItem().length) return false; player.faceObject(gameObject); return true; } @Override public boolean process(Player player) { if (!ChunkManager.getChunk(gameObject.getTile().getChunkId()).objectExists(gameObject)) { return false; } return player.getInventory().containsItem(cookable.getRawItem().getId(), 1); } @Override public int processWithDelay(Player player) { quantity--; player.setNextAnimation(new Animation(gameObject.getDefinitions(player).getName().equals(""Fire"") ? 897 : 896)); if (rollIsBurnt(cookable, player)) { player.getInventory().deleteItem(cookable.getRawItem().getId(), 1); player.getInventory().addItem(cookable.getBurntItem().getId(), cookable.getBurntItem().getAmount()); player.sendMessage(""You accidentally burn the "" + productName.toLowerCase() + ""."", true); } else { player.getInventory().deleteItem(cookable.getRawItem().getId(), 1); player.getInventory().addItem(new Item(cookable.getProductItem()[option]).getId(), new Item(cookable.getProductItem()[option]).getAmount()); if (new Item(cookable.getProductItem()[option]).getId() == 9436) { player.getSkills().addXp(Constants.COOKING, 3); // Sinew only awards 3xp } else { player.getSkills().addXp(Constants.COOKING, cookable.getXp()); } player.sendMessage(""You successfully cook "" + (cookable == Cookables.RAW_SHRIMP || cookable == Cookables.RAW_ANCHOVIES ? ""some"" : ""a"") + "" "" + productName.toLowerCase() + ""."", true); } player.getPackets().sendSound(new Sound(2577, 0, Sound.SoundType.EFFECT)); if (quantity > 0) { return 3; } return -1; } private boolean rollIsBurnt(Cookables cook, Player player) { if (new Item(cook.getProductItem()[option]).getId() == 9436) { return false; // Sinew, from raw meat, cannot be burnt } int level = player.getSkills().getLevel(Constants.COOKING); int burnLevel = cook.getBurningLvl(); if (player.getEquipment().getGlovesId() == 775) { burnLevel -= 6; } if (level >= burnLevel) { return false; } double chance = ((double) level / (double) burnLevel); if (chance < 0.7) { chance = 0.7; } return chance < Math.random(); } @Override public void stop(Player player) { setActionDelay(player, 3); } }" "package com.rs.game.content.skills.cooking; public class CookingCombos { public enum CookingCombo { PIE_SHELL(new Item(2315, 1), 1, new Item[] { new Item(2313, 1), new Item(1953, 1) }), PART_MUD_PIE(new Item[] { new Item(7164, 1), new Item(1925, 1) }, 29, new Item[] { new Item(2315, 1), new Item(6032, 1) }), PART_MUD_PIE2(new Item[] { new Item(7166, 1), new Item(1925, 1) }, 29, new Item[] { new Item(7164, 1), new Item(1929, 1) }), RAW_MUD_PIE(new Item(7168, 1), 29, new Item[] { new Item(7166, 1), new Item(434, 1) }), PART_GARDEN_PIE(new Item(7172, 1), 34, new Item[] { new Item(2315, 1), new Item(1982, 1) }), PART_GARDEN_PIE2(new Item(7174, 1), 34, new Item[] { new Item(7172, 1), new Item(1957, 1) }), RAW_GARDEN_PIE(new Item(7176, 1), 34, new Item[] { new Item(7174, 1), new Item(1965, 1) }), PART_FISH_PIE(new Item(7182, 1), 47, new Item[] { new Item(2315, 1), new Item(333, 1) }), PART_FISH_PIE2(new Item(7184, 1), 47, new Item[] { new Item(7182, 1), new Item(339, 1) }), RAW_FISH_PIE(new Item(7186, 1), 47, new Item[] { new Item(7184, 1), new Item(1942, 1) }), PART_ADMIRAL_PIE(new Item(7192, 1), 70, new Item[] { new Item(2315, 1), new Item(329, 1) }), PART_ADMIRAL_PIE2(new Item(7194, 1), 70, new Item[] { new Item(7192, 1), new Item(361, 1) }), RAW_ADMIRAL_PIE(new Item(7196, 1), 70, new Item[] { new Item(7194, 1), new Item(1942, 1) }), PART_WILD_PIE(new Item(7202, 1), 85, new Item[] { new Item(2315, 1), new Item(2136, 1) }), PART_WILD_PIE2(new Item(7204, 1), 85, new Item[] { new Item(7202, 1), new Item(2876, 1) }), RAW_WILD_PIE(new Item(7206, 1), 85, new Item[] { new Item(7204, 1), new Item(3226, 1) }), PART_SUMMER_PIE(new Item(7212, 1), 95, new Item[] { new Item(2315, 1), new Item(5504, 1) }), PART_SUMMER_PIE2(new Item(7214, 1), 95, new Item[] { new Item(7212, 1), new Item(5982, 1) }), RAW_SUMMER_PIE(new Item(7216, 1), 95, new Item[] { new Item(7214, 1), new Item(1955, 1) }), UNCOOKED_APPLE_PIE(new Item(2317, 1), 30, new Item[] { new Item(2315, 1), new Item(1955, 1) }), UNCOOKED_MEAT_PIE(new Item(2319, 1), 20, new Item[] { new Item(2315, 1), new Item(2140, 1) }), UNCOOKED_BERRY_PIE(new Item(2321, 1), 10, new Item[] { new Item(2315, 1), new Item(1951, 1) }); private final Item[] product; private final int req; private final Item[] materials; private CookingCombo(Item product, int req, Item[] materials) { this.product = new Item[] { product }; this.req = req; this.materials = materials; } private CookingCombo(Item[] product, int req, Item[] materials) { this.product = product; this.req = req; this.materials = materials; } public static CookingCombo forMaterials(Item i1, Item i2) { for (CookingCombo c : CookingCombo.values()) if ((c.materials[0].getId() == i1.getId() || c.materials[1].getId() == i1.getId()) && (c.materials[0].getId() == i2.getId() || c.materials[1].getId() == i2.getId())) return c; return null; } } public static boolean handleCombos(Player player, Item used, Item usedWith) { CookingCombo combo = CookingCombo.forMaterials(used, usedWith); if (combo != null) { if (player.getSkills().getLevel(Constants.COOKING) < combo.req) { player.sendMessage(""You need a cooking level of "" + combo.req + "" to make that.""); return true; } if (!player.getInventory().containsItems(combo.materials)) return true; player.startConversation(new CreateActionD(player, new Item[][] { combo.materials }, new Item[][] { combo.product }, new double[] { 0.0 }, new int[] { -1 }, new int[] { combo.req }, Constants.COOKING, 0)); return true; } return false; } }" "package com.rs.game.content.skills.cooking; public class CookingD extends Conversation { public CookingD(Player player, Cookables cookable, GameObject gameObject) { super(player); generateConversation(player, cookable, gameObject); create(); } private void generateConversation(Player player, Cookables cookable, GameObject gameObject) { String objectName = gameObject.getDefinitions(player).getName().toLowerCase(); boolean isGameObjectFire = objectName.contains(""fire""); if (cookable == null) { if (isGameObjectFire) { addSimple(""You can't cook that on a fire.""); } else if (objectName.contains(""range"")) { addSimple(""You can't cook that on a range.""); } else { addSimple(""You can't cook that.""); } return; } if (cookable.isFireOnly() && !isGameObjectFire) { addSimple(""You may only cook this on a fire.""); return; } if (cookable.isSpitRoastRequired() && gameObject.getId() != 11363) { addSimple(""You may only cook this on an iron spit.""); return; } if (player.getSkills().getLevel(Constants.COOKING) < cookable.getLevel()) { addSimple(""You need a Cooking level of "" + cookable.getLevel() + "" to cook "" + Utils.addArticle(new Item(cookable.getProductItem()[0]).getDefinitions().getName().toLowerCase()) + "".""); return; } Dialogue makeX = addNext(new MakeXStatement(MakeXType.COOK, player.getInventory().getAmountOf(cookable.getRawItem().getId()), ""Choose how many you wish to cook,
then click on the item to begin."", cookable.getProductItem(), null)); for (int i = 0; i < cookable.getProductItem().length; i++) { final int option = i; makeX.addNext(() -> { player.getActionManager().setAction(new Cooking(player, option, gameObject, cookable, MakeXStatement.getQuantity(player))); }); } } }" "package com.rs.game.content.skills.cooking; public class CowMilkingAction extends PlayerAction { public static final int EMPTY_BUCKET = 1925; public CowMilkingAction() { } @Override public boolean start(Player player) { if (!player.getInventory().containsItem(EMPTY_BUCKET, 1)) { player.startConversation(new GrilleGoatsDialogue(player)); return false; } return true; } @Override public boolean process(Player player) { return player.getInventory().hasFreeSlots() && player.getInventory().containsItem(EMPTY_BUCKET, 1); } @Override public int processWithDelay(Player player) { player.setNextAnimation(new Animation(2305)); player.soundEffect(372, true); player.getInventory().deleteItem(new Item(EMPTY_BUCKET, 1)); player.getInventory().addItem(new Item(1927)); player.sendMessage(""You milk the cow.""); return 5; } @Override public void stop(Player player) { setActionDelay(player, 3); } }" "package com.rs.game.content.skills.cooking; @PluginEventHandler public class DairyChurn { private static final Item[][] materials = { { new Item(1927) }, { new Item(1927) }, { new Item(1927) } }; private static final Item[][] products = { { new Item(2130), new Item(3727) }, { new Item(6697), new Item(3727) }, { new Item(1985), new Item(3727) } }; private static final int[] reqs = { 21, 38, 48 }; private static final double[] xp = { 18, 40.5, 64 }; private static final int[] anims = { -1, -1, -1 }; public static ObjectClickHandler handleChurns = new ObjectClickHandler(new Object[] { ""Dairy churn"", ""Dairy Churn"" }, e -> e.getPlayer().startConversation(new CreateActionD(e.getPlayer(), materials, products, xp, anims, reqs, Constants.COOKING, 8))); }" "package com.rs.game.content.skills.cooking; @PluginEventHandler public class DoughMaking { public static int POT_OF_FLOUR = 1933; public static int JUG_OF_WATER = 1937; public static int BOWL_OF_WATER = 1921; public static int BUCKET_OF_WATER = 1929; static class DoughMakeD extends Conversation { public DoughMakeD(Player player) { super(player); int[] items = new int[] { 2307, 1953, 2283, 1863 }; var makeX = addNext(new MakeXStatement(items, getMaxAmount())); for (int itemId : items) makeX.addNext(() -> player.getActionManager().setAction(new DoughMakeAction(itemId))); } public int getAmountOfWaterItems() { return player.getInventory().getAmountOf(JUG_OF_WATER) + player.getInventory().getAmountOf(BOWL_OF_WATER) + player.getInventory().getAmountOf(BUCKET_OF_WATER); } public int getMaxAmount() { int min = player.getInventory().getAmountOf(POT_OF_FLOUR); if (min > getAmountOfWaterItems()) min = getAmountOfWaterItems(); return min; } } static class DoughMakeAction extends PlayerAction { private final int doughId; public DoughMakeAction(int doughId) { this.doughId = doughId; } @Override public boolean start(Player player) { if (!player.getInventory().hasFreeSlots() || !player.getInventory().containsItem(POT_OF_FLOUR, 1) || !player.getInventory().containsItem(POT_OF_FLOUR, 1) || !player.getInventory().containsItem(POT_OF_FLOUR, 1) || !player.getInventory().containsItem(POT_OF_FLOUR, 1)) return false; return true; } @Override public boolean process(Player player) { if (!player.getInventory().hasFreeSlots() || !player.getInventory().containsItem(POT_OF_FLOUR, 1) || !player.getInventory().containsItem(POT_OF_FLOUR, 1) || !player.getInventory().containsItem(POT_OF_FLOUR, 1) || !player.getInventory().containsItem(POT_OF_FLOUR, 1)) return false; return true; } @Override public int processWithDelay(Player player) { if (!player.getInventory().hasFreeSlots()) { player.sendMessage(""You don't have enough inventory space.""); stop(player); } else { if (player.getInventory().containsItem(BOWL_OF_WATER, 1)) { player.getInventory().deleteItem(BOWL_OF_WATER, 1); player.getInventory().addItem(1923, 1); } else if (player.getInventory().containsItem(BUCKET_OF_WATER, 1)) { player.getInventory().deleteItem(BUCKET_OF_WATER, 1); player.getInventory().addItem(1925, 1); } else if (player.getInventory().containsItem(JUG_OF_WATER, 1)) { player.getInventory().deleteItem(JUG_OF_WATER, 1); player.getInventory().addItem(1935, 1); } player.getInventory().deleteItem(POT_OF_FLOUR, 1); player.getInventory().addItem(1931, 1); player.getInventory().addItem(doughId, 1); } return 2; } @Override public void stop(Player player) { } } public static ItemOnItemHandler makeDough = new ItemOnItemHandler(POT_OF_FLOUR, new int[] { BUCKET_OF_WATER, BOWL_OF_WATER, JUG_OF_WATER }, e -> e.getPlayer().startConversation(new DoughMakeD(e.getPlayer()))); }" "package com.rs.game.content.skills.cooking; @PluginEventHandler public class Foods { public static final Animation EAT_ANIM = new Animation(829); public static ItemClickHandler eat = new ItemClickHandler(Food.foods.keySet().toArray(), new String[] { ""Eat"", ""Heal"" }, e -> eat(e.getPlayer(), e.getItem(), e.getSlotId(), null)); public static boolean eat(final Player player, Item item, int slot, Player givenFrom) { Food food = Food.forId(item.getId()); if (food == null) return false; if (!player.canEat() || !player.getControllerManager().canEat(food)) return true; if (food.heal < 0) { player.sendMessage(""I'm not going to eat that!""); return true; } player.sendMessage(""You eat the "" + item.getName().toLowerCase() + ""."", true); player.incrementCount(""Food eaten""); player.setNextAnimation(EAT_ANIM); player.addFoodDelay(food.ids.length > 1 ? 2 : 3); player.getActionManager().setActionDelay(player.getActionManager().getActionDelay() + 3); Item replace = new Item(item.getId(), item.getAmount()); if (replace.getDefinitions().isStackable()) replace.setAmount(replace.getAmount()-1); else replace.setId(food.getReplaceIdFor(item.getId())); player.getInventory().getItems().set(slot, replace.getId() <= 0 || replace.getAmount() <= 0 ? null : replace); player.getInventory().refresh(slot); int hp = player.getHitpoints(); if (ItemConstants.isDungItem(item.getId())) { int healed = food.heal; if (givenFrom != null && givenFrom.getDungManager().getActivePerk() == KinshipPerk.MEDIC) healed *= 1.2 + (givenFrom.getDungManager().getKinshipTier(KinshipPerk.MEDIC) * 0.03); player.applyHit(new Hit(player, healed, HitLook.HEALED_DAMAGE)); } else player.heal(food.heal); if (player.getHitpoints() > hp) player.sendMessage(""It heals some health.""); player.getInventory().refresh(); if (food.effect != null) food.effect.accept(player); player.soundEffect(2393,false); return true; } public static boolean isConsumable(Item item) { Food food = Food.forId(item.getId()); if (food == null) return false; return true; } public enum Food { ACAI(20270, 50), ADMIRAL_PIE(new int[] { 7198, 7200 }, 2313, 80, p -> p.getSkills().adjustStat(5, 0.0, Constants.FISHING)), AMPHIBIOUS_FRUIT(21381, 150), ANCHOVY(319, 10), ANCHOVY_PIZZA(new int[] { 2297, 2299 }, 90), APPLE_PIE(new int[] { 2323, 2335 }, 2313, 70), AQUATIC_FRUIT(21380, 150), BAGUETTE(6961, 60), BAKED_POTATO(6701, 40), BANANA(1963, 20), BANANA_STEW(4016, 110), BARON_SHARK(19948, 200, p -> p.addEffect(Effect.BARON_SHARK, Ticks.fromSeconds(12))), BASS(365, 130), BAT_SHISH(10964, 20), BISCUITS(19467, 20), BLACK_MUSHROOM(4620, 0, p -> p.sendMessage(""Eugh! It tastes horrible, and stains your fingers black."")), BLUE_CRAB(18175, 220), BLUE_SWEETS(4558, 2), BLURBERRY_SPECIAL(2064, 2), BOULDABASS(18171, 170), BREAD(2309, 50), BUTTON_MUSHROOM(13563, 10), CABBAGE(1965, 10, p -> p.sendMessage(""You don't really like it much."", true)), CAMOUFLAGED_FRUIT(21384, 150), CANNIBAL_FRUIT(21379, 150), CARRION_FRUIT(21382, 150), CAVEFISH(15266, 220), CAVE_EEL(5003, 110), CAVE_MORAY(18177, 250), CAVE_NIGHTSHADE(2398, 0, player -> { player.applyHit(new Hit(player, 15, HitLook.POISON_DAMAGE)); player.sendMessage(""Ahhhh! What have I done""); }), CAVIAR(11326, 50), CELEBRATION_CAKE_1(20179, 20), CELEBRATION_CAKE_2(20181, 20), CELEBRATION_CAKE_3(20182, 20), CHEESE(1985, 20), CHEESEPTOM_BATTA(2259, 70), CHEESE_AND_TOMATO_BATTA(9535, 110), CHEESE_WHEEL(18789, 20), CHICKEN(2140, 30), CHILLI_CON_CARNIE(new int[] { 7062 }, 1923, 50), CHILLI_POTATO(7054, 140), CHOCCHIP_CRUNCHIES(2209, 70), CHOCOLATEY_MILK(1977, 40), CHOCOLATE_BAR(1973, 30), CHOCOLATE_BOMB(2185, 150), CHOCOLATE_CAKE(new int[] { 1897, 1899, 1901 }, 50), CAKE(new int[] { 1891, 1893, 1895 }, 40), CHOCOLATE_DROP(14083, 30), CHOCOLATE_EGG_1(12646, 10), CHOCOLATE_EGG(12648, 10), CHOCOLATE_KEBBIT(11026, -1), CHOCOTREAT(24148, 80), CHOC_ICE(6794, 70), CHOC_SATURDAY(2074, 50), CHOMPY(2878, 60), CHOPPED_ONION(new int[] { 1871 }, 1923, 50), CHOPPED_TOMATO(new int[] { 1869 }, 1923, 50), CHOPPED_TUNA(new int[] { 7086 }, 1923, 50), COATED_FROGS_LEGS(10963, 20), COD(339, 180), COMMON_FRUIT(21376, 150), COOKED_CHICKEN(2140, 30), COOKED_CHOMPY(2878, 30), COOKED_CRAB_MEAT_1(7521, 10), COOKED_CRAB_MEAT_2(7523, 10), COOKED_CRAB_MEAT_3(7524, 10), COOKED_CRAB_MEAT_4(7525, 10), COOKED_CRAB_MEAT_5(7526, 10), COOKED_FISHCAKE(7530, 110), COOKED_JUBBLY(7568, 150), COOKED_KARAMBWAN(3144, 180), COOKED_MEAT(2142, 30), COOKED_OOMLIE_WRAP(2343, 140), COOKED_RABBIT(3228, 20), COOKED_SLIMY_EEL(3381, 70), COOKED_SWEETCORN(5988, 0, p -> p.heal((int) Math.round(p.getMaxHitpoints() * 0.10))), COOKED_TURKEY(14540, 30), COOKED_TURKEY_DRUMSTICK(14543, 20), CORONATION_CHICKEN_SANDWICH(24398, 20), CRAB_MEAT(7521, -1), CRAYFISH(13433, 20), CREAM_TEA(24396, 20), CRUMBLY_BITS(24179, 0), CRUNCHY_RUNE_ROCKS(20838, 0), CURRY(new int[] { 2011 }, 1923, 190), DEEP_BLUE_SWEETS(4559, 20), DISEASED_FRUIT(21383, 100), DOUGHNUT(14665, 20), DRACONIC_FRUIT(21385, 100), DRUGGED_MEAT(15277, -1), DUSK_EEL(18163, 70), DWELLBERRIES(2126, 20), EASTER_EGG(1961, 20), EASTER_EGG1(7928, 20), EASTER_EGG2(7929, 20), EASTER_EGG3(7930, 20), EASTER_EGG4(7931, 20), EASTER_EGG5(7932, 20), EASTER_EGG6(7933, 20), EASTER_EGG7(12644, 20), EASTER_EGG8(12643, 20), EASTER_EGG9(1961, 20), EASTER_EGG10(12642, 20), EASTER_EGG11(12641, 20), EASTER_EGG12(12640, 20), EASTER_EGG13(12639, 20), EASTER_EGG14(1961, 20), EASTER_EGG15(1961, 20), EASTER_EGG16(1961, 20), EASTER_EGG17(1961, 20), EASTER_EGG18(1961, 20), EDIBLE_SEAWEED(403, 20), EELSUSHI(10971, 20), EGG_AND_TOMATO(new int[] { 7064 }, 1923, 80), EGG_POTATO(7056, 160), EQUA_LEAVES(2128, 10), EVIL_DRUMSTICK(24147, 10), EVIL_TURNIP(new int[] { 12134, 12136, 12138 }, 60), FAT_SNAIL_MEAT(3373, 80, p -> p.heal(Utils.random(20))), FIELD_RATION(7934, 50), FILLETS(10969, 25), FINGERS(10965, 20), FISHCAKE(7530, 110), FISH_LIKE_THING(6202, -1), FISH_N_CHIPS(24400, 50), FISH_PIE(new int[] { 7188, 7190 }, 2313, p -> p.getSkills().adjustStat(3, 0.0, Constants.FISHING)), FOOD_CLASS_1(14162, 40), FOOD_CLASS_2(14164, 80), FOOD_CLASS_3(14166, 120), FOOD_CLASS_4(14168, 160), FOOD_CLASS_5(1417, 200), FRESH_MONKFISH(7943, 100), FRIED_MUSHROOMS(new int[] { 7082 }, 1923, 50), FRIED_ONIONS(new int[] { 7084 }, 1923, 50), FROGBURGER(10962, 20), FROGSPAWN_GUMBO(10961, 20), FROG_SPAWN(5004, 20), FRUIT_BATTA(2277, 110), FULL_BREAKFAST(24404, 100), FURY_SHARK(20429, 280), GARDEN_PIE(new int[] { 7178, 7180 }, 2313, p -> p.getSkills().adjustStat(3, 0.0, Constants.FARMING)), GIANT_CARP(337, -1), GIANT_FLATFISH(18165, 100), GIANT_FROG_LEGS(4517, 60), GOUT_TUBER(6311, 10, p -> p.restoreRunEnergy(100)), GREEN_GLOOP_SOUP(10960, 20), GREEN_SWEETS(4563, 20), GRUBS_A_LA_MODE(10966, 25), GUTHIX_FRUIT(21387, 200), HALF_WINE_JUG(1989, 87), HEIM_CRAB(18159, 20), HERRING(347, 20), HUMBLE_PIE(18767, -1), IGNEOUS_FRUIT(21378, 150), JANGERBERRIES(247, 20), JUBBLY(7568, 150), JUJU_GUMBO(19949, 320, p -> p.addEffect(Effect.BARON_SHARK, Ticks.fromSeconds(12))), KARAMBWANJI(3151, 30), KEBAB(1971, 0, KEBAB_EFFECT), KING_WORM(2162, 20), LAVA_EEL(2149, 110), LEAN_SNAIL_MEAT(3371, 80), LEMON(2102, 20), LEMON_CHUNKS(2104, 20), LEMON_SLICES(2106, 20), LIME(2120, 20), LIME_CHUNKS(2122, 20), LIME_SLICES(2124, 20), LOACH(10970, 30), LOBSTER(379, 120), LOCUST_MEAT(9052, 20), MACKEREL(355, 60), MAGIC_EGG(11023, 20), MANTA(391, 220), MEAT(2142, 30), MEAT_PIE(new int[] { 2327, 2331 }, 2313, 60), MEAT_PIZZA(new int[] { 2293, 2295 }, 80), MINCED_MEAT(new int[] { 7070 }, 1923, 2), MINT_CAKE(9475, 0, p -> p.restoreRunEnergy(100)), MONKEY_BAR(4014, 90), MONKEY_NUTS(4012, 20), MONKFISH(7946, 160), MUSHROOMS(10968, 25), MUSHROOM_AND_ONIONS(new int[] { 7066 }, 1923, 110), MUSHROOM_AND_ONION_POTATO(7058, 200), NOT_MEAT(20837, 20), ODD_CRUNCHIES(2197, 10), OKTOBERFEST_PRETZEL(19778, 20), ONION(1957, 10, p -> p.sendMessage(""It hurts to see a grown "" + (p.getAppearance().isMale() ? ""man"" : ""woman"") + ""cry."")), ONION_AND_TOMATO(new int[] { 1875 }, 1923, 20), OOMILE(2343, 140), ORANGE(2108, 20), ORANGE_CHUNKS(211, 20), ORANGE_SLICES(2112, 20), PAPAYA(5972, 80, p -> p.restoreRunEnergy(5)), PEACH(6883, 80), PIKE(351, 80), PINEAPPLE_CHUNKS(2116, 20), PINEAPPLE_PIZZA(new int[] { 2301, 2303 }, 110), PINEAPPLE_RING(2118, 20), PINK_SWEETS(4564, 20), PLAIN_PIZZA_FULL(new int[] { 2289, 2291 }, 70), PLANT_BITS(2418, -1), PM_CHEESE_AND_TOMATO_BATTA(2223, 110), PM_CHOCOCHIP_CRUNCHIES(2239, 70), PM_CHOCOLATE_BOMB(2229, 150), PM_FRUIT_BATTA(2225, 110), PM_SPICY_CRUNCHIES(2241, 70), PM_TANGLED_TOAD_LEGS(2231, 150), PM_TOAD_BATTA(2221, 110), PM_TOAD_CRUNCHIES(2243, 80), PM_VEGETABLE_BATTA(2227, 110), PM_WORM_BATTA(2219, 110), PM_WORM_CRUNCHIES(2237, 80), PM_WORM_HOLE(2233, 120), POISONED_CHEESE(6768, -1), POISON_KARAMBWAN(3146, 0, p -> p.applyHit(new Hit(p, 50, HitLook.POISON_DAMAGE))), POORLY_COOKED_BEAST_MEAT(23062, 20), POORLY_COOKED_BIRD_MEAT(23060, 20), POPCORN_BALL(14082, 30), POTATO_WITH_BUTTER(6703, 140), POTATO_WITH_CHEESE(6705, 160), POT_OF_CREAM(2130, 20), PUMPKIN(1959, 20), PUNCH(22329, 20), PURPLE_SWEETS(4561, 0, p -> { p.heal(Utils.random(10, 30)); p.restoreRunEnergy(10); }), PURPLE_SWEETS2(10476, 0, p -> { p.heal(Utils.random(10, 30)); p.restoreRunEnergy(10); }), RABBIT_SANDWICH(23065, 42), RABIT(3228, 50), RAINBOW_FISH(10136, 110), REDBERRY_PIE(new int[] { 2325, 2333 }, 2313, 50), RED_BANANA(7572, 50), RED_EYE(18161, 50), RED_SWEETS(4562, 20), ROASTED_BEAST_MEAT(9988, 42), ROASTED_BIRD_MEAT(9980, 42), ROAST_BEAST_MEAT(9988, 42), ROAST_BIRD_MEAT(998, 60), ROAST_FROG(10967, 50), ROAST_POTATOES(15429, 100), ROAST_RABBIT(7223, 70), ROCKTAIL(15272, 0, p -> p.heal(230, 100)), BANDAGE(4049, 0, p -> p.heal(230, 100)), ROE(11324, 30), ROLL(6963, 20), ROTTEN_APPLE(1984, -1), SALMON(329, 90), SALVE_EEL(18173, 200), SARADOMIN_FRUIT(21386, 200), SARDINE(325, 40), SCORPION_MEAT(22342, 80), SCRAMBLED_EGG(new int[] { 7078 }, 1923, 50), SEASONED_LEGS(2158, 1), SEAWEED_SANDWICH(3168, -1), SEA_MEAT_1(20831, 250), SEA_MEAT_2(24182, 250), SEA_TURTLE(397, 210), SHADOW_FRUIT(21377, 150), SHARK(385, 200), SHORT_FINNED_EEL(18167, 120), SHRIMP(315, 30), SHRUNK_OGLEROOT(11205, 20), SKEWERED_KEBAB(15123, 90), SLICED_BANANA(3162, 20), SLICED_RED_BANANA(7574, 20), SLIMY_EEL(3381, 70), SPICEY_SAUCE(new int[] { 7072 }, 1923, 20), SPICY_CRUNCHIES(2213, 20), SPICY_MINCED_MEAT(9996, 20), SPICY_SAUCE(7072, 20), SPICY_TOADS_LEGS(2156, 20), SPICY_TOMATO(9994, 20), SPICY_WORM(216, 20), SPIDER_ON_SHAFT(6299, 20), SPIDER_ON_STICK(6297, 20), SPINACH_ROLL(1969, 2), SQUARE_SANDWICH(6965, 25), STEAK_AND_KIDNEY_PIE(24402, 50), STEW(new int[] { 2003 }, 1923, 110), STRAWBERRY(5504, 10, p -> p.heal((int) (p.getMaxHitpoints() * 0.06))), STUFFED_SNAKE(7579, 200), SUMMER_PIE_FULL(new int[] { 7218, 7220 }, 2313, 110, p -> { p.getSkills().adjustStat(5, 0.0, Constants.AGILITY); p.restoreRunEnergy(10); }), SUMMER_SQIRKJUICE(10849, 150, p -> p.getSkills().adjustStat(2, 0.1, true, Constants.THIEVING)), SUPER_KEBAB(4608, 0, KEBAB_EFFECT), SWORDFISH(373, 140), TANGLED_TOAD_LEGS(2187, 150), TCHIKI_MONKEY_NUTS(7573, 2), TCHIKI_NUT_PASTE(7575, 2), TEA_FLASK(10859, 20), TENTH_ANNIVERSARY_CAKE(20111, 20), THIN_SNAIL_MEAT(3369, 30), THOK_RUNE(20841, 20), TIGER_SHARK(21521, 100), TOADS_LEGS(2152, 20), TOAD_BATTA(2255, 110), TOAD_CRUNCHIES(2217, 20), TOMATO(1982, 20), TRIANGLE_SANDWICH(6962, 20), TROUT(333, 70), TRUFFLE(12132, 20), TUNA(361, 100), TUNA_AND_CORN(new int[] { 7068 }, 1923, 130), TUNA_POTATO(7060, 220), TURKEY_DRUMSTICK(15428, 20), UGTHANKI_KEBAB_1(1883, 190, p -> p.forceTalk(""Yum!"")), UGTHANKI_KEBAB_2(1885, 190, p -> p.forceTalk(""Yum!"")), UGTHANKI_MEAT(1861, 20), UNFINISHED_BATTA(2261, 20), UNFINISHED_BATTA1(2263, 20), UNFINISHED_BATTA2(2265, 20), UNFINISHED_BATTA3(2267, 20), UNFINISHED_BATTA4(2269, 20), UNFINISHED_BATTA5(2271, 20), UNFINISHED_BATTA6(2273, 20), VEGETABLE_BATTA7(2281, 20), VEG_BALL(2195, 120), WATERMELON_SLICE(5984, 20), WEB_SNIPER(18169, 150), WHITE_PEARL(4485, 20), WHITE_SWEETS(456, 20), WHITE_TREE_FRUIT(6469, 20), WILD_PIE(new int[] { 7208, 7210 }, 2313, 110, p -> { p.getSkills().adjustStat(4, 0.0, Constants.RANGE); p.getSkills().adjustStat(5, 0.0, Constants.SLAYER); }), WORM_BATTA(2253, 110), WORM_CRUNCHIES(2205, 80), WORM_HOLE(2191, 120), WRAPPED_CANDY(14084, 20), YULE_LOG(1543, 20), YULE_LOGS(15430, 20), ZAMORAK_FRUIT(21388, 200); private static final Map foods = new HashMap<>(); static { for (final Food food : Food.values()) for (int id : food.ids) foods.put(id, food); } private final int[] ids; private int container; private final int heal; private Consumer effect; Food(int[] ids, int container, int heal, Consumer effect) { this.ids = ids; this.container = container; this.heal = heal; this.effect = effect; } Food(int[] ids, int heal, Consumer effect) { this(ids, -1, heal, effect); } Food(int id, int heal, Consumer effect) { this(new int[] { id }, -1, heal, effect); } Food(int id, int heal) { this.ids = new int[] { id }; this.heal = heal; } Food(int[] ids, int container, int heal) { this.ids = ids; this.container = container; this.heal = heal; } Food(int[] ids, int heal) { this(ids, -1, heal); } public static Food forId(int itemId) { return foods.get(itemId); } public int getReplaceIdFor(int id) { if (ids.length <= 1) return -1; int index = 0; for (int i = 0;i < ids.length;i++) { if (ids[i] == id) index = i; } index++; if (index >= ids.length) return container <= 0 ? -1 : container; return ids[index]; } } private static final Consumer KEBAB_EFFECT = player -> { int roll = Utils.random(100); if (roll >= 95) { player.sendMessage(""Wow, that was an amazing kebab! You feel really invigorated.""); int healChance = Utils.random(26, 32); int hp = (int) Math.round(player.getMaxHitpoints() * healChance); player.heal(hp); player.getSkills().adjustStat(2, 0.1, true, Constants.ATTACK); player.getSkills().adjustStat(2, 0.1, true, Constants.STRENGTH); player.getSkills().adjustStat(2, 0.1, true, Constants.DEFENSE); } else if (roll >= 90 && roll <= 94) { player.sendMessage(""That tasted very dodgy. You feel very ill. Eating the kebab has done damage to some of your stats.""); player.getSkills().adjustStat(-3, 0.1, true, Constants.ATTACK); player.getSkills().adjustStat(-3, 0.1, true, Constants.STRENGTH); player.getSkills().adjustStat(-3, 0.1, true, Constants.DEFENSE); } else if (roll >= 40 && roll <= 89) { player.sendMessage(""It restores some life points.""); double healChance = Utils.random(7.3, 10.0); int hp = (int) Math.round(player.getMaxHitpoints() * healChance); player.heal(hp); } else if (roll >= 25 && roll <= 39) { player.sendMessage(""That kebab didn't seem to do a lot.""); } else if (roll >= 10 && roll <= 24) { player.sendMessage(""That was a good kebab. You feel a lot better.""); double healChance = Utils.random(14.6, 20.0); int hp = (int) Math.round(player.getMaxHitpoints() * healChance); player.heal(hp); } else if (roll >= 0 && roll <= 9) { int skill = Utils.random(0, 25); player.sendMessage(""That tasted very dodgy. You feel very ill. Eating the kebab has done damage to some of your "" + Constants.SKILL_NAME[skill] + "" stats.""); player.getSkills().adjustStat(-3, 0.1, true, skill); } }; }" "package com.rs.game.content.skills.cooking; public class FruitCutting extends PlayerAction { CuttableFruit fruit; int option; int amount; public enum CuttableFruit { BANANA(1963, 3162), RED_BANANA(7572, 7574), LEMON(2102, 2104, 2106), ORANGE(2108, 2110, 2112), PINEAPPLE(2114, 2116, 2118), LIME(2120, 2122, 2124), WATERMELON(5982, 5984); final int fruitId; final int[] productIds; private static final Map items = new HashMap<>(); public static CuttableFruit forId(int itemId) { return items.get(itemId); } static { for (CuttableFruit ingredient : CuttableFruit.values()) items.put(ingredient.getFruitId(), ingredient); } private CuttableFruit(int fruitId, int... productIds) { this.fruitId = fruitId; this.productIds = productIds; } public int getFruitId() { return fruitId; } public int[] getProductIds() { return productIds; } } public FruitCutting(CuttableFruit fruit, int option, int quantity) { this.fruit = fruit; this.option = option; amount = quantity; } @Override public boolean start(Player player) { return true; } @Override public boolean process(Player player) { if (!player.getInventory().containsItem(fruit.getFruitId(), 1)) return false; return true; } @Override public int processWithDelay(Player player) { if (!player.getInventory().containsItem(fruit.getFruitId(), 1)) { player.sendMessage(""You have run out of fruit to cut.""); return -1; } player.getInventory().deleteItem(fruit.getFruitId(), 1); player.getInventory().addItem(fruit.getProductIds()[option], 1); return 1; } @Override public void stop(Player player) { } }" "package com.rs.game.content.skills.cooking; public class FruitCuttingD extends Conversation { public FruitCuttingD(Player player, CuttableFruit fruit) { super(player); addNext(new MakeXStatement(""Choose how many you wish to cut,
then click on the item to begin."", fruit.getProductIds(), player.getInventory().getItems().getNumberOf(fruit.getFruitId()))); for (int i = 0;i < fruit.getProductIds().length;i++) { final int op = i; addNext(() -> { int quantity = MakeXStatement.getQuantity(player); int invQuantity = player.getInventory().getItems().getNumberOf(fruit.getFruitId()); if (quantity > invQuantity) quantity = invQuantity; player.getActionManager().setAction(new FruitCutting(fruit, op, quantity)); }); } } }" "package com.rs.game.content.skills.cooking; public class PotatoCooking { public static boolean onItemOnItem(ItemOnItemEvent e) { return false; } }" "package com.rs.game.content.skills.cooking; @PluginEventHandler public class TeaMaking { static int[] cupsEmpty = {7728, 7732, 7735}; static int[] cupsFull = {7730, 7733, 7736}; static int[] cupsMilky = {7731, 7734, 7737}; static int[] teaPots = { 7692, 7693, 7694, 7695, 7696, 7697, 7698, 7699, 7704, 7705, 7706, 7707, 7708, 7709, 7710, 7711, 7716, 7717, 7718, 7719, 7720, 7721, 7722, 7723}; public static ItemOnItemHandler milkyTea = new ItemOnItemHandler(1927, cupsFull, e -> { if (e.getItem2().getDefinitions().getName().contains(""Cup of tea"")) for (int i = 0;i < 3;i++) if (e.getItem2().getId() == cupsFull[i]) { e.getPlayer().getInventory().deleteItem(e.getItem1().getId(), 1); e.getPlayer().getInventory().deleteItem(e.getItem2().getId(), 1); e.getPlayer().getInventory().addItem(cupsMilky[i], 1); } }); public static ItemOnItemHandler mixTea = new ItemOnItemHandler(teaPots, cupsEmpty, e -> { if (e.getItem1().getDefinitions().getName().contains(""Pot of tea"")) for (int i = 0; i < 3; i++) if (e.getItem2().getId() == cupsEmpty[i]) { e.getPlayer().getInventory().deleteItem(e.getItem1().getId(), 1); e.getPlayer().getInventory().deleteItem(e.getItem2().getId(), 1); e.getPlayer().getInventory().addItem(cupsFull[i], 1); if (e.getItem1().getDefinitions().getName().contains(""(1)"")) e.getPlayer().getInventory().addItem(e.getItem1().getId() + 4, 1); else e.getPlayer().getInventory().addItem(e.getItem1().getId() + 2, 1); break; } }); public static ItemOnItemHandler clayLeaves = new ItemOnItemHandler(7738, 7702, e -> { e.getPlayer().getInventory().deleteItem(7738, 1); e.getPlayer().getInventory().deleteItem(7702, 1); //Clay leaves into pot e.getPlayer().getInventory().addItem(7700, 1); }); public static ItemOnItemHandler porcelainLeaves = new ItemOnItemHandler(7738, 7714, e -> { e.getPlayer().getInventory().deleteItem(7738, 1); e.getPlayer().getInventory().deleteItem(7714, 1); //Porcelain leaves into pot e.getPlayer().getInventory().addItem(7712, 1); }); public static ItemOnItemHandler gildedLeaves = new ItemOnItemHandler(7738, 7726, e -> { e.getPlayer().getInventory().deleteItem(7738, 1); e.getPlayer().getInventory().deleteItem(7726, 1); //Gilded leaves into pot e.getPlayer().getInventory().addItem(7724, 1); }); public static ItemOnItemHandler clayWater = new ItemOnItemHandler(7691, 7700, e -> { e.getPlayer().getInventory().deleteItem(7691, 1); e.getPlayer().getInventory().deleteItem(7700, 1); //Clay water into pot e.getPlayer().getInventory().addItem(7692, 1); e.getPlayer().getInventory().addItem(7688, 1); }); public static ItemOnItemHandler porcelainWater = new ItemOnItemHandler(7691, 7712, e -> { e.getPlayer().getInventory().deleteItem(7691, 1); e.getPlayer().getInventory().deleteItem(7712, 1); //Porcelain water into pot e.getPlayer().getInventory().addItem(7704, 1); e.getPlayer().getInventory().addItem(7688, 1); }); public static ItemOnItemHandler gildedWater = new ItemOnItemHandler(7691, 7724, e -> { e.getPlayer().getInventory().deleteItem(7691, 1); e.getPlayer().getInventory().deleteItem(7724, 1); //Gilded water into pot e.getPlayer().getInventory().addItem(7716, 1); e.getPlayer().getInventory().addItem(7688, 1); }); }" "package com.rs.game.content.skills.cooking; @PluginEventHandler public class WineMaking extends PlayerAction { private boolean rollBadWine(Player player) { double level = player.getSkills().getLevel(Constants.COOKING); double noFailLevel = 68.0D; if (level >= noFailLevel) { return true; } double chance = Math.max(level / noFailLevel, 0.6D); return chance < Math.random(); } private static final int JUG_OF_WATER = 1937; private static final int GRAPES = 1987; private static final int UNFERMENTED_WINE = 1995; private static final int JUG_OF_WINE = 1993; private static final int JUG_OF_BAD_WINE = 1991; private int amount; public WineMaking(int amount) { this.amount = amount; } @Override public boolean start(Player player) { return true; } @Override public boolean process(Player player) { return true; } @Override public int processWithDelay(Player player) { amount--; if (!player.getInventory().containsItem(GRAPES) || !player.getInventory().containsItem(JUG_OF_WATER)) { return -1; } player.getInventory().deleteItem(GRAPES, 1); player.getInventory().deleteItem(JUG_OF_WATER, 1); if (rollBadWine(player)) { player.getSkills().addXp(Constants.COOKING, 200); player.getInventory().addItem(JUG_OF_WINE); } else { player.getInventory().addItem(JUG_OF_BAD_WINE); } player.sendMessage(""You squeeze the grapes into the jug. The wine begins to ferment.""); int WINE_CREATE_TICKS = 1; return amount > 0 ? WINE_CREATE_TICKS : -1; } @Override public void stop(Player player) {} public static ItemOnItemHandler makeXWine = new ItemOnItemHandler(JUG_OF_WATER, GRAPES, (e) -> e.getPlayer().startConversation(new WineMakingD(e.getPlayer()))); }" "package com.rs.game.content.skills.cooking; public class WineMakingD extends Conversation { private final int JUG_OF_WATER = 1937; private final int GRAPES = 1; public WineMakingD(Player player) { super(player); if (player.getSkills().getLevel(Constants.COOKING) < 35) { addSimple(""You need a cooking level of 35 to make wine.""); } else { addNext(new MakeXStatement( MakeXStatement.MakeXType.MAKE, Math.min(player.getInventory().getAmountOf(1937), player.getInventory().getAmountOf(1987)), ""How many would you like to make?"", new int[] { 1995 }, null)); addNext(() -> player.getActionManager().setAction(new WineMaking(MakeXStatement.getQuantity(player)))); } create(); } }" "package com.rs.game.content.skills.crafting; @PluginEventHandler public class BattlestaffCrafting { private static final Item[][] materials = { { new Item(1391), new Item(571) }, { new Item(1391), new Item(575) }, { new Item(1391), new Item(569) }, { new Item(1391), new Item(573) } }; private static final Item[][] products = { { new Item(1395) }, { new Item(1399) }, { new Item(1393) }, { new Item(1397) } }; private static final int[] reqs = { 54, 58, 62, 66 }; private static final double[] xp = { 100, 112.5, 125, 137.5 }; private static final int[] anims = { 16448, 16447, 16449, 16446 }; public static ItemOnItemHandler craftStaves = new ItemOnItemHandler(1391, new int[] { 569, 571, 573, 575 }, e -> e.getPlayer().startConversation(new CreateActionD(e.getPlayer(), materials, products, xp, anims, reqs, Constants.CRAFTING, 2))); }" "package com.rs.game.content.skills.crafting; @PluginEventHandler public class GemBag { private static final int[] GEMS = new int[] { 1623, 1621, 1619, 1617, 1631 }; public static ItemClickHandler handleClickOnGemBag = new ItemClickHandler(new Object[] { 18338, 25352 }, e -> { switch(e.getOption()) { case ""Inspect"" -> { int total = getTotalGemCount(e.getPlayer()); e.getPlayer().sendMessage(""You have "" + total + "" gem"" + (total > 1 ? ""s"" : """") + "" in your gem bag.""); e.getPlayer().sendMessage(getGemCount(e.getPlayer(), 0) + "" sapphires, "" + getGemCount(e.getPlayer(), 1) + "" emeralds, "" + getGemCount(e.getPlayer(), 2) + "" rubies, "" + getGemCount(e.getPlayer(), 3) + "" diamonds, and "" + getGemCount(e.getPlayer(), 4) + "" dragonstones.""); } case ""Fill"" -> { for (int gemId : GEMS) if (!storeGems(e.getPlayer(), gemId, e.getItem().getId() == 25352)) break; } case ""Withdraw"" -> { if (!e.getPlayer().getInventory().hasFreeSlots()) e.getPlayer().sendMessage(""You do not have enough inventory spaces to do that.""); //TODO cbf since empty works lol } case ""Empty"" -> { if (!e.getPlayer().getInventory().hasFreeSlots()) { e.getPlayer().sendMessage(""You do not have enough inventory spaces to do that.""); return; } ArrayList bagContents = e.getPlayer().getO(""gemBagContents""); if (bagContents == null) return; for (int i = 0;i < GEMS.length;i++) { if (!e.getPlayer().getInventory().hasFreeSlots()) break; if (bagContents.get(i).intValue() < 1) continue; int num = bagContents.get(i).intValue(); if (num > e.getPlayer().getInventory().getFreeSlots()) num = e.getPlayer().getInventory().getFreeSlots(); if (e.getPlayer().getInventory().addItem(new Item(GEMS[i], num), true)) bagContents.set(i, (double) (bagContents.get(i).intValue() - num)); } e.getPlayer().save(""gemBagContents"", bagContents); } } }); public static ItemOnItemHandler handleItemOnGemBag = new ItemOnItemHandler(new int[] { 18338, 25352 }, GEMS, e -> { Item bag = e.getUsedWith(GEMS); Item gem = e.getUsedWith(18338, 25352); if (bag == null) return; storeGems(e.getPlayer(), gem.getId(), bag.getId() == 25352); }); private static boolean storeGems(Player player, int id, boolean upgrade) { ArrayList bagContents = player.getO(""gemBagContents""); if (bagContents == null) bagContents = new ArrayList<>(List.of(0.0, 0.0, 0.0, 0.0, 0.0)); int maxGems = upgrade ? 500 : 100; int current = getTotalGemCount(player); int room = 0; if (current < maxGems) room = maxGems - current; if (room == 0) { player.sendMessage(""Your gem bag is already full.""); return false; } int gemsToStore = player.getInventory().getNumberOf(id); if (gemsToStore > room) gemsToStore = room; int gemIndex = switch (id) { case 1623 -> 0; case 1621 -> 1; case 1619 -> 2; case 1617 -> 3; case 1631 -> 4; default -> -1; }; if (gemIndex == -1) return false; player.getInventory().deleteItem(id, gemsToStore); bagContents.set(gemIndex, bagContents.get(gemIndex) + gemsToStore); player.save(""gemBagContents"", bagContents); return true; } public static ItemOnObjectHandler handleGemBagOnObject = new ItemOnObjectHandler(new Object[] { ""Bank"", ""Deposit Box"", ""Counter"", ""Bank booth"" }, new Object[] { 18338, 25352 }, e -> { if (ObjectDefinitions.getDefs(e.getObject().getId()).getName().contains(""Bank"") || ObjectDefinitions.getDefs(e.getObject().getId()).containsOptionIgnoreCase(""bank"")) { ArrayList bagContents = e.getPlayer().getO(""gemBagContents""); if (bagContents == null) return; int stored = 0; for (int i = 0;i < GEMS.length;i++) { if (bagContents.get(i).intValue() < 1) continue; if (e.getPlayer().getBank().addItem(new Item(GEMS[i], bagContents.get(i).intValue()), true)) { stored += bagContents.get(i); bagContents.set(i, 0.0); } } e.getPlayer().save(""gemBagContents"", bagContents); e.getPlayer().sendMessage(""You store "" + stored + "" gems in the bank.""); } }); public static int getTotalGemCount(Player p) { ArrayList bagContents = p.getO(""gemBagContents""); if (bagContents == null) bagContents = new ArrayList<>(List.of(0.0, 0.0, 0.0, 0.0, 0.0)); int total = 0; for (double count : bagContents) total += count; return total; } public static int getGemCount(Player p, int gemType) { ArrayList bagContents = p.getO(""gemBagContents""); if (bagContents == null) return 0; return bagContents.get(gemType).intValue(); } }" "package com.rs.game.content.skills.crafting; public class GemCutting extends PlayerAction { public enum Gem { OPAL(1625, 1609, 15.0, 1, 886), JADE(1627, 1611, 20, 13, 886), RED_TOPAZ(1629, 1613, 25, 16, 887), SAPPHIRE(1623, 1607, 50, 20, 888), EMERALD(1621, 1605, 67, 27, 889), RUBY(1619, 1603, 85, 34, 887), DIAMOND(1617, 1601, 107.5, 43, 890), DRAGONSTONE(1631, 1615, 137.5, 55, 885), ONYX(6571, 6573, 167.5, 67, 2717), GRAY_SHELL_ROUND(3345, 3327, 35.5, 15, -1), RED_AND_BLACK_SHELL_ROUND(3347, 3329, 35.5, 15, -1), OCHRE_SHELL_ROUND(3349, 3331, 35.5, 15, -1), BLUE_SHELL_ROUND(3351, 3333, 35.5, 15, -1), BROKEN_SHELL_ROUND(3353, 3335, 35.5, 15, -1), GRAY_SHELL_POINTY(3355, 3337, 35.5, 15, -1), RED_AND_BLACK_SHELL_POINTY(3357, 3339, 35.5, 15, -1), OCHRE_SHELL_POINTY(3359, 3341, 35.5, 15, -1), BLUE_SHELL_POINTY(3361, 3343, 35.5, 15, -1), DRAMEN_STAFF(771, 772, 2.0, 31, -1); private final double experience; private final int levelRequired; private final int uncut; private final int cut; private final int emote; private Gem(int uncut, int cut, double experience, int levelRequired, int emote) { this.uncut = uncut; this.cut = cut; this.experience = experience; this.levelRequired = levelRequired; this.emote = emote; } public int getLevelRequired() { return levelRequired; } public double getExperience() { return experience; } public int getUncut() { return uncut; } public int getCut() { return cut; } public int getEmote() { return emote; } } public static boolean isCutting(Player player, Item item1, Item item2) { Item gem = InventoryOptionsHandler.contains(1755, item1, item2); if (gem == null) return false; return isCutting(player, gem.getId()); } private static boolean isCutting(Player player, int gemId) { for (Gem gem : Gem.values()) if (gem.uncut == gemId) { cut(player, gem); return true; } return false; } public static void cut(Player player, Gem gem) { if (player.getInventory().getItems().getNumberOf(new Item(gem.getUncut(), 1)) <= 1) player.getActionManager().setAction(new GemCutting(gem, 1)); else player.startConversation(new Dialogue() .addNext(new MakeXStatement( MakeXStatement.MakeXType.CUT, ""Choose how many you wish to cut,
then click on the item to begin."", new int[] { gem.getUncut() }, player.getInventory().getAmountOf(gem.getUncut()))) .addNext(() -> player.getActionManager().setAction(new GemCutting(gem, MakeXStatement.getQuantity(player))))); } private final Gem gem; private int quantity; public GemCutting(Gem gem, int quantity) { this.gem = gem; this.quantity = quantity; } public boolean checkAll(Player player) { if (player.getSkills().getLevel(Constants.CRAFTING) < gem.getLevelRequired()) { player.simpleDialogue(""You need a crafting level of "" + gem.getLevelRequired() + "" to cut that gem.""); return false; } if (!player.getInventory().containsOneItem(gem.getUncut())) { player.simpleDialogue(""You don't have any "" + ItemDefinitions.getDefs(gem.getUncut()).getName().toLowerCase() + "" to cut.""); return false; } return true; } @Override public boolean start(Player player) { if (checkAll(player)) { setActionDelay(player, 1); player.setNextAnimation(new Animation(gem.getEmote())); return true; } return false; } @Override public boolean process(Player player) { return checkAll(player); } @Override public int processWithDelay(Player player) { player.getInventory().deleteItem(gem.getUncut(), 1); player.getInventory().addItem(gem.getCut(), 1); player.getSkills().addXp(Constants.CRAFTING, gem.getExperience()); player.sendMessage(""You cut the "" + ItemDefinitions.getDefs(gem.getUncut()).getName().toLowerCase() + ""."", true); quantity--; if (quantity <= 0) return -1; player.setNextAnimation(new Animation(gem.getEmote())); return 0; } @Override public void stop(final Player player) { setActionDelay(player, 3); } }" "package com.rs.game.content.skills.crafting; public class GemTipCutting extends PlayerAction { public enum GemTips { OPAL(1609, 1.5, 11, 886, 45), JADE(1611, 2, 26, 886, 9187), RED_TOPAZ(1613, 3, 48, 887, 9188), SAPPHIRE(1607, 4, 56, 888, 9189), EMERALD(1605, 5.5, 58, 889, 9190), RUBY(1603, 6.5, 63, 887, 9191), DIAMOND(1601, 8, 65, 890, 9192), DRAGONSTONE(1615, 10, 71, 885, 9193), ONYX(6573, 25, 73, 2717, 9194); private final double experience; private final int levelRequired; private final int cut; private final int emote; private final int boltTips; private GemTips(int cut, double experience, int levelRequired, int emote, int boltTips) { this.cut = cut; this.experience = experience; this.levelRequired = levelRequired; this.emote = emote; this.boltTips = boltTips; } public int getLevelRequired() { return levelRequired; } public double getExperience() { return experience; } public int getCut() { return cut; } public int getEmote() { return emote; } public int getBoltTips() { return boltTips; } } public static void cut(Player player, GemTips gem) { player.getActionManager().setAction(new GemTipCutting(gem, player.getInventory().getNumberOf(gem.getCut()))); } private final GemTips gem; private int quantity; public GemTipCutting(GemTips gem, int quantity) { this.gem = gem; this.quantity = quantity; } public boolean checkAll(Player player) { if (player.getSkills().getLevel(Constants.FLETCHING) < gem.getLevelRequired()) { player.simpleDialogue(""You need a fletching level of "" + gem.getLevelRequired() + "" to cut that gem.""); return false; } if (!player.getInventory().containsOneItem(gem.getCut())) { player.simpleDialogue(""You don't have any "" + ItemDefinitions.getDefs(gem.getCut()).getName().toLowerCase() + "" to cut.""); return false; } return true; } @Override public boolean start(Player player) { if (checkAll(player)) { setActionDelay(player, 2); player.setNextAnimation(new Animation(gem.getEmote())); return true; } return false; } @Override public boolean process(Player player) { return checkAll(player); } @Override public int processWithDelay(Player player) { player.getInventory().deleteItem(gem.getCut(), 1); player.getInventory().addItem(gem.getBoltTips(), 12); player.getSkills().addXp(Constants.FLETCHING, gem.getExperience()); player.sendMessage(""You cut the "" + ItemDefinitions.getDefs(gem.getCut()).getName().toLowerCase() + ""."", true); quantity--; if (quantity <= 0) return -1; player.setNextAnimation(new Animation(gem.getEmote())); return 2; } @Override public void stop(final Player player) { setActionDelay(player, 3); } }" "package com.rs.game.content.skills.crafting; @PluginEventHandler public class GlassBlowing { public static int MOLTEN_GLASS = 1775; public static int ROBUST_GLASS = 23193; public static int GLASSBLOWING_PIPE = 1785; private static final Item[][] materials = { { new Item(MOLTEN_GLASS) }, { new Item(MOLTEN_GLASS) }, { new Item(MOLTEN_GLASS) }, { new Item(MOLTEN_GLASS) }, { new Item(MOLTEN_GLASS) }, { new Item(MOLTEN_GLASS) }, { new Item(MOLTEN_GLASS) }, { new Item(MOLTEN_GLASS) }, { new Item(ROBUST_GLASS) } }; private static final Item[][] products = { { new Item(1919) }, { new Item(4527) }, { new Item(4522) }, { new Item(229) }, { new Item(6667) }, { new Item(567) }, { new Item(4542) }, { new Item(10980) }, { new Item(23191) } }; private static final int[] reqs = { 1, 4, 12, 33, 42, 46, 49, 87, 89 }; private static final double[] xp = { 17.5, 19, 25, 35, 42.5, 52.5, 55, 70, 100 }; private static final int[] anims = { 884, 884, 884, 884, 884, 884, 884, 884, 884 }; public static ItemOnItemHandler blowGlass = new ItemOnItemHandler(GLASSBLOWING_PIPE, new int[] { MOLTEN_GLASS, ROBUST_GLASS }, e -> e.getPlayer().startConversation(new CreateActionD(e.getPlayer(), materials, products, xp, anims, reqs, Constants.CRAFTING, 2))); }" "package com.rs.game.content.skills.crafting; public class JewelryAction extends PlayerAction { private final Bling bling; private int numberToMake; private final boolean pyrefiend; public JewelryAction(Bling bling, int number, boolean pyrefiend) { this.bling = bling; this.numberToMake = number; this.pyrefiend = pyrefiend; } public boolean checkAll(Player player) { if (bling == null || player == null) return false; if (pyrefiend && (player.getFamiliar() == null || !player.getInventory().containsItem(Scroll.IMMENSE_HEAT.getId()))) return false; if (!player.getInventory().containsItem(bling.getMouldRequired(), 1)) { player.sendMessage(""You need one "" + ItemDefinitions.getDefs(bling.getMouldRequired()).getName().toLowerCase() + "" to make that.""); return false; } if (!player.getInventory().containsItems(bling.getItemsRequired())) { player.sendMessage(""You don't have the items required to make that.""); return false; } if (player.getSkills().getLevel(Constants.CRAFTING) < bling.getLevelRequired()) { player.sendMessage(""You need "" + bling.getLevelRequired() + "" crafting to make that.""); return false; } return true; } @Override public boolean start(Player player) { if (checkAll(player)) return true; return false; } @Override public boolean process(Player player) { if (checkAll(player)) { if (player.getTempAttribs().getO(""jewelryObject"") != null) player.faceObject(player.getTempAttribs().getO(""jewelryObject"")); return true; } return false; } @Override public int processWithDelay(Player player) { numberToMake--; if (!pyrefiend) player.setNextAnimation(new Animation(3243)); player.getSkills().addXp(Constants.CRAFTING, bling.getExperience()); if (pyrefiend) { player.getFamiliar().sync(8082, 1394); player.spotAnim(1463); player.getInventory().deleteItem(Scroll.IMMENSE_HEAT.getId(), 1); } for (Item required : bling.getItemsRequired()) player.getInventory().deleteItem(required.getId(), required.getAmount()); player.getInventory().addItemDrop(bling.getProduct(), 1); player.sendMessage(""You make a "" + ItemDefinitions.getDefs(bling.getProduct()).getName().toLowerCase() + ""."", true); if (numberToMake > 0) return 2; return -1; } @Override public void stop(Player player) { } }" "package com.rs.game.content.skills.crafting const val RING_MOULD = 1592 const val AMULET_MOULD = 1595 const val NECKLACE_MOULD = 1597 const val BRACELET_MOULD = 11065 const val GOLD_BAR = 2357 const val SAPPHIRE = 1607 const val EMERALD = 1605 const val RUBY = 1603 const val DIAMOND = 1601 const val DRAGONSTONE = 1615 const val ONYX = 6573 const val ENCHANTED_GEM = 4155 enum class Bling(val levelRequired: Int, val experience: Double, private val itemsRequired: Array, val product: Int, val buttonId: Int, val nullId: Int) { GOLD_RING(5, 15.0, arrayOf(RING_MOULD, GOLD_BAR), 1635, 82, 1647), SAPP_RING(20, 40.0, arrayOf(RING_MOULD, GOLD_BAR, SAPPHIRE), 1637, 84, 1647), EMER_RING(27, 55.0, arrayOf(RING_MOULD, GOLD_BAR, EMERALD), 1639, 86, 1647), RUBY_RING(34, 70.0, arrayOf(RING_MOULD, GOLD_BAR, RUBY), 1641, 88, 1647), DIAM_RING(43, 85.0, arrayOf(RING_MOULD, GOLD_BAR, DIAMOND), 1643, 90, 1647), DRAG_RING(55, 100.0, arrayOf(RING_MOULD, GOLD_BAR, DRAGONSTONE), 1645, 92, 1647), ONYX_RING(67, 115.0, arrayOf(RING_MOULD, GOLD_BAR, ONYX), 6575, 94, 6564), SLAYER_RING(55, 15.0, arrayOf(RING_MOULD, GOLD_BAR, ENCHANTED_GEM), 13281, 97, 1647), GOLD_NECK(6, 20.0, arrayOf(NECKLACE_MOULD, GOLD_BAR), 1654, 68, 1666), SAPP_NECK(22, 55.0, arrayOf(NECKLACE_MOULD, GOLD_BAR, SAPPHIRE), 1656, 70, 1666), EMER_NECK(29, 60.0, arrayOf(NECKLACE_MOULD, GOLD_BAR, EMERALD), 1658, 72, 1666), RUBY_NECK(40, 75.0, arrayOf(NECKLACE_MOULD, GOLD_BAR, RUBY), 1660, 74, 1666), DIAM_NECK(56, 90.0, arrayOf(NECKLACE_MOULD, GOLD_BAR, DIAMOND), 1662, 76, 1666), DRAG_NECK(72, 105.0, arrayOf(NECKLACE_MOULD, GOLD_BAR, DRAGONSTONE), 1664, 78, 1666), ONYX_NECK(82, 120.0, arrayOf(NECKLACE_MOULD, GOLD_BAR, ONYX), 6577, 80, 6565), GOLD_AMMY(8, 30.0, arrayOf(AMULET_MOULD, GOLD_BAR), 1673, 53, 1685), SAPP_AMMY(24, 65.0, arrayOf(AMULET_MOULD, GOLD_BAR, SAPPHIRE), 1675, 55, 1685), EMER_AMMY(31, 70.0, arrayOf(AMULET_MOULD, GOLD_BAR, EMERALD), 1677, 57, 1685), RUBY_AMMY(50, 85.0, arrayOf(AMULET_MOULD, GOLD_BAR, RUBY), 1679, 59, 1685), DIAM_AMMY(70, 100.0, arrayOf(AMULET_MOULD, GOLD_BAR, DIAMOND), 1681, 61, 1685), DRAG_AMMY(80, 150.0, arrayOf(AMULET_MOULD, GOLD_BAR, DRAGONSTONE), 1683, 63, 1685), ONYX_AMMY(90, 165.0, arrayOf(AMULET_MOULD, GOLD_BAR, ONYX), 6579, 65, 6566), GOLD_BRACE(7, 25.0, arrayOf(BRACELET_MOULD, GOLD_BAR), 11069, 33, 11067), SAPP_BRACE(23, 60.0, arrayOf(BRACELET_MOULD, GOLD_BAR, SAPPHIRE), 11072, 35, 11067), EMER_BRACE(30, 65.0, arrayOf(BRACELET_MOULD, GOLD_BAR, EMERALD), 11076, 37, 11067), RUBY_BRACE(42, 80.0, arrayOf(BRACELET_MOULD, GOLD_BAR, RUBY), 11085, 39, 11067), DIAM_BRACE(58, 95.0, arrayOf(BRACELET_MOULD, GOLD_BAR, DIAMOND), 11092, 41, 11067), DRAG_BRACE(74, 110.0, arrayOf(BRACELET_MOULD, GOLD_BAR, DRAGONSTONE), 11115, 43, 11067), ONYX_BRACE(84, 125.0, arrayOf(BRACELET_MOULD, GOLD_BAR, ONYX), 11130, 45, 11067); companion object { private val rings = values().associateBy { it.buttonId } fun forId(buttonId: Int) = rings[buttonId] } fun getItemsRequired() = itemsRequired.sliceArray(1 until itemsRequired.size).map { Item(it, 1) } fun getMouldRequired() = itemsRequired[0] } @ServerStartupEvent fun mapJewelryCrafting() { fun getNumberToMake(packetId: ClientPacket): Int { return when(packetId) { ClientPacket.IF_OP1 -> 1 ClientPacket.IF_OP2 -> 5 ClientPacket.IF_OP3 -> 28 ClientPacket.IF_OP4 -> -5 else -> 1 } } onButtonClick(446) { e -> val bling = Bling.forId(e.componentId) ?: return@onButtonClick if (bling == Bling.SLAYER_RING && !e.player.hasCraftROS()) { e.player.sendMessage(""You have not unlocked the ability to craft this. Purchase the ability from a slayer master."") return@onButtonClick } when(val numberToMake = getNumberToMake(e.packet)) { -5 -> e.player.sendInputInteger(""How many would you like to make?"") { number -> e.player.actionManager.setAction(JewelryAction(bling, number, e.player.tempAttribs.getB(""immenseHeatCrafting""))) } else -> e.player.actionManager.setAction(JewelryAction(bling, numberToMake, e.player.tempAttribs.getB(""immenseHeatCrafting""))) } e.player.closeInterfaces() } } fun openInterface(player: Player, pyrefiend: Boolean) { player.interfaceManager.sendInterface(446) //Unhide sections listOf(17, 21, 26, 30).forEach { component -> player.packets.setIFHidden(446, component, true) } for (bling in Bling.entries) { if (!player.inventory.containsItem(bling.getMouldRequired(), 1) || !player.inventory.containsItems(bling.getItemsRequired()) || player.skills.getLevel(Constants.CRAFTING) < bling.levelRequired) player.packets.setIFItem(446, bling.buttonId - 1, bling.nullId, 75) else player.packets.setIFItem(446, bling.buttonId - 1, bling.product, 75) } if (pyrefiend) { player.tempAttribs.setB(""immenseHeatCrafting"", true) player.setCloseInterfacesEvent { player.tempAttribs.removeB(""immenseHeatCrafting"") } } }" "package com.rs.game.content.skills.crafting; @PluginEventHandler public class PotteryCrafting { private static final Item[][] UNF_MATS = { { new Item(1761) }, { new Item(1761) }, { new Item(1761) }, { new Item(1761) }, { new Item(1761) }, { new Item(1761) } }; private static final Item[][] UNF_PRODS = { { new Item(1787) }, { new Item(20052) }, { new Item(1789) }, { new Item(1791) }, { new Item(5352) }, { new Item(4438) } }; private static final Item[][] FIRED_PRODS = { { new Item(1931) }, { new Item(20053) }, { new Item(2313) }, { new Item(1923) }, { new Item(5350) }, { new Item(4440) } }; private static final int[] REQS = { 1, 4, 7, 8, 19, 25 }; private static final double[] XP = { 6.25, 11.5, 15, 18, 20, 20 }; public static ObjectClickHandler handleWheels = new ObjectClickHandler(new Object[] { ""Potter's Wheel"", ""Potter's wheel"", ""Pottery Wheel"" }, e -> e.getPlayer().startConversation(new Conversation(e.getPlayer()) .addNext(new MakeXStatement(new int[] { 1931, 20347 }, new String[] { ""Normal Pottery"", ""Skilling Urns"" }), () -> e.getPlayer().startConversation(new CreateActionD(e.getPlayer(), UNF_MATS, UNF_PRODS, XP, 896, REQS, Constants.CRAFTING, 2)), () -> e.getPlayer().startConversation(new CreateUnfUrnD(e.getPlayer()))))); public static ObjectClickHandler handleOvens = new ObjectClickHandler(new Object[] { ""Pottery Oven"", ""Pottery oven"" }, e -> { if (e.getPlayer().containsAnyItems(1787, 20052, 1789, 1791, 5352, 4438)) //TODO move these to generic firing dialogue e.getPlayer().startConversation(new CreateActionD(e.getPlayer(), UNF_PRODS, FIRED_PRODS, XP, 899, REQS, Constants.CRAFTING, 4)); else if (!e.getPlayer().startConversation(new FireUrnD(e.getPlayer()))) e.getPlayer().sendMessage(""You don't have anything to fire.""); }); }" "package com.rs.game.content.skills.crafting; public class SandBucketFill extends PlayerAction { public SandBucketFill() { } @Override public boolean start(Player player) { return true; } @Override public boolean process(Player player) { if (player.getInventory().containsItem(Ectofuntus.EMPTY_BUCKET, 1)) return true; return false; } @Override public int processWithDelay(Player player) { if (fillBucket(player)) return 1; return 1; } @Override public void stop(Player player) { } public boolean fillBucket(Player player) { if (player.getInventory().containsItem(Ectofuntus.EMPTY_BUCKET, 1)) { player.setNextAnimation(new Animation(4471)); player.getInventory().deleteItem(Ectofuntus.EMPTY_BUCKET, 1); player.getInventory().addItem(1783, 1); return true; } return false; } }" "package com.rs.game.content.skills.crafting; @PluginEventHandler public class Silver { public static final int SILVER_BAR = 2355; public enum SilverItems { HOLY_SYMBOL(16, 50, 1599, new Item(1714, 1), 16), UNHOLY_SYMBOL(17, 50, 1594, new Item(1720, 1), 23), SILVER_SICKLE(18, 50, 2976, new Item(2961, 1), 30), LIGHTNING_ROD(20, 50, 4200, new Item(4201, 1), 37), DEMONIC_SIGIL(20, 50, 6747, new Item(6748, 1), 59), SILVER_BOLTS(21, 50, 9434, new Item(9382, 10), 66), TIARA(23, 52.5, 5523, new Item(5525), 44); private static final Map rings = new HashMap<>(); public static SilverItems forId(int buttonId) { return rings.get(buttonId); } static { for (SilverItems ring : SilverItems.values()) rings.put(ring.getButtonId(), ring); } private final int levelRequired; private final double experience; private final int mould; private final int buttonId; private final Item product; private SilverItems(int levelRequired, double experience, int itemsRequired, Item producedBar, int buttonId) { this.levelRequired = levelRequired; this.experience = experience; mould = itemsRequired; product = producedBar; this.buttonId = buttonId; } public int getMouldRequired() { return mould; } public int getLevelRequired() { return levelRequired; } public Item getProduct() { return product; } public double getExperience() { return experience; } public int getButtonId() { return buttonId; } } public static void openSilverInterface(Player player) { player.getInterfaceManager().sendInterface(438); for (SilverItems item : SilverItems.values()) player.getPackets().setIFItem(438, item.getButtonId()+1, item.getProduct().getId(), item.getProduct().getAmount()); } public static ButtonClickHandler handleButtons = new ButtonClickHandler(438, e -> { e.getPlayer().closeInterfaces(); SilverItems silver = SilverItems.forId(e.getComponentId()); int numberToMake = getNumberToMake(e.getPacket()); if (numberToMake == -5) e.getPlayer().sendInputInteger(""How many would you like to make?"", number -> { if (silver != null) e.getPlayer().getActionManager().setAction(new SilverCraftingAction(silver, number)); else if (e.getPlayer().hasRights(Rights.DEVELOPER)) e.getPlayer().sendMessage(""SILVER: component: "" + e.getComponentId() + "" packetId: "" + e.getPacket()); else e.getPlayer().sendMessage(""You are unable to craft this item at the moment.""); }); else if (silver != null) e.getPlayer().getActionManager().setAction(new SilverCraftingAction(silver, numberToMake)); else if (e.getPlayer().hasRights(Rights.DEVELOPER)) e.getPlayer().sendMessage(""SILVER: component: "" + e.getComponentId() + "" packetId: "" + e.getPacket()); else e.getPlayer().sendMessage(""You are unable to craft this item at the moment.""); }); public static int getNumberToMake(ClientPacket packetId) { return switch (packetId) { case IF_OP1 -> 1; case IF_OP2 -> 5; case IF_OP3 -> 28; case IF_OP4 -> -5; default -> 1; }; } }" "package com.rs.game.content.skills.crafting; public class SilverCraftingAction extends PlayerAction { SilverItems itemToMake; int numberToMake; public SilverCraftingAction(SilverItems bling, int number) { itemToMake = bling; numberToMake = number; } public boolean checkAll(Player player) { if (itemToMake == null || player == null) return false; if (itemToMake.getMouldRequired() != -1 && !player.getInventory().containsItem(itemToMake.getMouldRequired(), 1)) { player.sendMessage(""You need one "" + ItemDefinitions.getDefs(itemToMake.getMouldRequired()).getName().toLowerCase() + "" to make that.""); return false; } if (!player.getInventory().containsItem(Silver.SILVER_BAR, 1)) { player.sendMessage(""You don't have the items required to make that.""); return false; } if (player.getSkills().getLevel(Constants.CRAFTING) < itemToMake.getLevelRequired()) { player.sendMessage(""You need "" + itemToMake.getLevelRequired() + "" crafting to make that.""); return false; } return true; } @Override public boolean start(Player player) { if (checkAll(player)) return true; return false; } @Override public boolean process(Player player) { if (checkAll(player)) { if (player.getTempAttribs().getO(""silverObject"") != null) player.faceObject(player.getTempAttribs().getO(""silverObject"")); return true; } return false; } @Override public int processWithDelay(Player player) { numberToMake--; player.setNextAnimation(new Animation(3243)); player.getSkills().addXp(Constants.CRAFTING, itemToMake.getExperience()); player.getInventory().deleteItem(Silver.SILVER_BAR, 1); player.getInventory().addItem(itemToMake.getProduct()); player.sendMessage(""You make a "" + itemToMake.getProduct().getDefinitions().getName().toLowerCase() + ""."", true); if (numberToMake > 0) return 2; return -1; } @Override public void stop(Player player) { } }" "package com.rs.game.content.skills.crafting; @PluginEventHandler public class SnakeskinCrafting { private static final Item[][] materials = { { new Item(6287, 6), new Item(1734) }, { new Item(6287, 8), new Item(1734) }, { new Item(6287, 5), new Item(1734) }, { new Item(6287, 12), new Item(1734) }, { new Item(6287, 15), new Item(1734) } }; private static final Item[][] products = { { new Item(6328) }, { new Item(6330) }, { new Item(6326) }, { new Item(6324) }, { new Item(6322) } }; private static final int[] reqs = { 45, 47, 48, 51, 53 }; private static final double[] xp = { 30, 35, 45, 50, 55 }; private static final int[] anims = { -1, -1, -1, -1, -1 }; public static ItemOnItemHandler craft = new ItemOnItemHandler(6287, 1733, e -> e.getPlayer().startConversation(new CreateActionD(e.getPlayer(), materials, products, xp, anims, reqs, Constants.CRAFTING, 2))); }" "package com.rs.game.content.skills.crafting; @PluginEventHandler public class SpinningWheel { private static final Item[][] materials = { { new Item(1779) }, { new Item(10814) }, { new Item(1737) }, { new Item(9436) }, { new Item(3693) } }; private static final Item[][] products = { { new Item(1777) }, { new Item(954) }, { new Item(1759) }, { new Item(9438) }, { new Item(3694) } }; private static final int[] reqs = { 1, 1, 1, 1, 1 }; private static final double[] xp = { 15, 15, 15, 1, 1 }; private static final int[] anims = { 883, 883, 883, 883, 883 }; public static ObjectClickHandler onClick = new ObjectClickHandler(new Object[] { ""Spinning wheel"" }, e -> { if (e.getOpNum() == ClientPacket.OBJECT_OP2) e.getPlayer().startConversation(new CreateActionD(e.getPlayer(), materials, products, xp, anims, reqs, Constants.CRAFTING, 2)); }); public static ItemOnObjectHandler handleItemOn = new ItemOnObjectHandler(new Object[] { ""Spinning wheel"" }, null, e -> { for (int i = 0; i < materials.length; i++) if (materials[i][0].getId() == e.getItem().getId()) e.getPlayer().startConversation(new CreateActionD(e.getPlayer(), new Item[][] { { materials[i][0] } }, new Item[][] { { products[i][0] } }, new double[] { xp[i] }, new int[] { anims[i] }, Constants.CRAFTING, 2)); }); }" "package com.rs.game.content.skills.crafting; @PluginEventHandler public class Weaving { private static final Item[][] materials = { { new Item(1759, 4) }, { new Item(5931, 4) }, { new Item(5933, 6) }, { new Item(401, 5), new Item(1794) } }; private static final Item[][] products = { { new Item(3224) }, { new Item(5418) }, { new Item(5376) }, { new Item(14859) } }; private static final int[] reqs = { 10, 21, 36, 52 }; private static final double[] xp = { 12, 38, 56, 83 }; private static final int[] anims = { -1, -1, -1, -1 }; public static ObjectClickHandler onClick = new ObjectClickHandler(new Object[] { ""Loom"" }, e -> e.getPlayer().startConversation(new CreateActionD(e.getPlayer(), materials, products, xp, anims, reqs, Constants.CRAFTING, 2))); }" "package com.rs.game.content.skills.crafting.urns; public class CreateUnfUrnD extends Conversation { public CreateUnfUrnD(Player player) { super(player); addNext(new MakeXStatement( new int[] { Urn.DECORATED_MINING.fillId(), Urn.DECORATED_COOKING.fillId(), Urn.DECORATED_FISHING.fillId(), Urn.STRONG_SMELTING.fillId(), Urn.STRONG_WOODCUTTING.fillId(), Urn.INFERNAL.fillId() }, new String[] { ""Mining Urns"", ""Cooking Urns"", ""Fishing Urns"", ""Smelting Urns"", ""Woodcutting Urns"", ""Prayer Urns"" }), new MakeUnfOp(player, Urn.CRACKED_MINING, Urn.FRAGILE_MINING, Urn.MINING, Urn.STRONG_MINING, Urn.DECORATED_MINING), new MakeUnfOp(player, Urn.CRACKED_COOKING, Urn.FRAGILE_COOKING, Urn.COOKING, Urn.STRONG_COOKING, Urn.DECORATED_COOKING), new MakeUnfOp(player, Urn.CRACKED_FISHING, Urn.FRAGILE_FISHING, Urn.FISHING, Urn.STRONG_FISHING, Urn.DECORATED_FISHING), new MakeUnfOp(player, Urn.CRACKED_SMELTING, Urn.FRAGILE_SMELTING, Urn.SMELTING, Urn.STRONG_SMELTING), new MakeUnfOp(player, Urn.CRACKED_WOODCUTTING, Urn.FRAGILE_WOODCUTTING, Urn.WOODCUTTING, Urn.STRONG_WOODCUTTING), new MakeUnfOp(player, Urn.IMPIOUS, Urn.ACCURSED, Urn.INFERNAL)); create(); } }" "package com.rs.game.content.skills.crafting.urns; public class FireUrnD extends Conversation { public FireUrnD(Player player) { super(player); MakeXActionD makeX = new MakeXActionD(); for (Urn urn : Urn.values()) if (player.getInventory().containsItem(urn.unfId())) makeX.addOption(new MakeXItem(player, new Item(urn.unfId()), new Item(urn.nrId()), urn.getFireXp(), 899, urn.getLevel(), Constants.CRAFTING, 2)); if (!makeX.isEmpty()) addNext(makeX); create(); } }" "package com.rs.game.content.skills.crafting.urns; public class MakeUnfOp extends MakeXActionD { public MakeUnfOp(Player player, Urn... urns) { for (Urn urn : urns) addOption(new MakeXItem(player, new Item(1761, 2), new Item(urn.unfId()), urn.getUnfXp(), 899, urn.getLevel(), Constants.CRAFTING, 4)); } }" "package com.rs.game.content.skills.crafting.urns; public enum Urn { CRACKED_SMELTING(20271, new Animation(6384), new Animation(4580), Constants.SMITHING, 4, 200, 14, 23.1), FRAGILE_SMELTING(20277, new Animation(6385), new Animation(6380), Constants.SMITHING, 17, 312.5, 16, 31.8), SMELTING(20283, new Animation(6386), new Animation(6381), Constants.SMITHING, 35, 750, 29, 42), STRONG_SMELTING(20289, new Animation(6387), new Animation(6382), Constants.SMITHING, 49, 1250, 36, 70), CRACKED_WOODCUTTING(20295, new Animation(10279), new Animation(8713), Constants.WOODCUTTING, 4, 800, 15.4, 23.1), FRAGILE_WOODCUTTING(20301, new Animation(10280), new Animation(8727), Constants.WOODCUTTING, 15, 2125, 20, 30), WOODCUTTING(20307, new Animation(10281), new Animation(8729), Constants.WOODCUTTING, 44, 4125, 32, 48), STRONG_WOODCUTTING(20313, new Animation(10828), new Animation(8730), Constants.WOODCUTTING, 61, 8312.5, 38.8, 58.2), CRACKED_FISHING(20319, new Animation(6474), new Animation(6394), Constants.FISHING, 2, 750, 12, 18), FRAGILE_FISHING(20325, new Animation(6475), new Animation(6463), Constants.FISHING, 15, 1750, 20, 30), FISHING(20331, new Animation(6769), new Animation(6471), Constants.FISHING, 41, 2500, 31.2, 46.8), STRONG_FISHING(20337, new Animation(6770), new Animation(6472), Constants.FISHING, 53, 3000, 36, 54), DECORATED_FISHING(20343, new Animation(6789), new Animation(6473), Constants.FISHING, 76, 9500, 48, 72), CRACKED_COOKING(20349, new Animation(8649), new Animation(6794), Constants.COOKING, 2, 2000, 12, 18), FRAGILE_COOKING(20355, new Animation(8651), new Animation(6795), Constants.COOKING, 12, 2750, 16, 24), COOKING(20361, new Animation(8652), new Animation(7126), Constants.COOKING, 36, 4750, 28.6, 42.9), STRONG_COOKING(20367, new Animation(8654), new Animation(7133), Constants.COOKING, 51, 5250, 35, 52.5), DECORATED_COOKING(20373, new Animation(8691), new Animation(8629), Constants.COOKING, 81, 7737.5, 52, 78), CRACKED_MINING(20379, new Animation(11420), new Animation(10829), Constants.MINING, 1, 437.5, 13, 16.8), FRAGILE_MINING(20385, new Animation(11421), new Animation(10830), Constants.MINING, 17, 1000, 20, 31.8), MINING(20391, new Animation(11425), new Animation(10831), Constants.MINING, 32, 1625, 28, 40.8), STRONG_MINING(20397, new Animation(11447), new Animation(10947), Constants.MINING, 48, 2000, 36, 49.2), DECORATED_MINING(20403, new Animation(11448), new Animation(11419), Constants.MINING, 59, 3125, 51, 57), IMPIOUS(20409, new Animation(4567), new Animation(4292), Constants.PRAYER, 2, 100, 12, 18), ACCURSED(20415, new Animation(4569), new Animation(4541), Constants.PRAYER, 26, 312.5, 25, 37.5), INFERNAL(20421, new Animation(4578), new Animation(4542), Constants.PRAYER, 62, 1562.5, 40, 60); public final static Map NR_IDS = new HashMap<>(); public final static Map FILL_IDS = new HashMap<>(); public final static Map FULL_IDS = new HashMap<>(); static { for (Urn urn : Urn.values()) { NR_IDS.put(urn.nrId(), urn); FILL_IDS.put(urn.fillId(), urn); FULL_IDS.put(urn.fullId(), urn); } } public static Urn forNRId(int id) { return NR_IDS.get(id); } public static Urn forFillId(int id) { return FILL_IDS.get(id); } public static Urn forFullId(int id) { return FULL_IDS.get(id); } private final Animation readyAnim, teleAnim; private final int unfId, skillId, level; private final double xpToFill, spinXp, fireXp; Urn(int unfId, Animation readyAnim, Animation teleAnim, int skillId, int level, double xpToFill, double spinXp, double fireXp) { this.unfId = unfId; this.readyAnim = readyAnim; this.teleAnim = teleAnim; this.skillId = skillId; this.level = level; this.xpToFill = xpToFill; this.spinXp = spinXp; this.fireXp = fireXp; } public Animation getReadyAnim() { return readyAnim; } public Animation getTeleAnim() { return teleAnim; } public int getLevel() { return level; } public int unfId() { return unfId; } public int nrId() { return unfId+1; } public int rId() { return unfId+3; } public int fillId() { return unfId+4; } public int fullId() { return unfId+5; } public Rune getRune() { return switch (skillId) { case Constants.COOKING, Constants.SMITHING -> Rune.FIRE; case Constants.FISHING -> Rune.WATER; case Constants.MINING, Constants.WOODCUTTING -> Rune.EARTH; default -> Rune.AIR; }; } public int getSkill() { return skillId; } public double getFillXp() { return xpToFill; } public double getTeleXp() { return switch (this) { case IMPIOUS, ACCURSED, INFERNAL -> xpToFill * 1.20; default -> xpToFill * 0.20; }; } public double getUnfXp() { return spinXp; } public double getFireXp() { return fireXp; } }" "package com.rs.game.content.skills.crafting.urns; @PluginEventHandler public class Urns { public static ItemClickHandler handleTeleportUrns = new ItemClickHandler(Urn.FULL_IDS.keySet().toArray(), new String[] { ""Teleport urn"" }, e -> { Urn urn = Urn.forFullId(e.getItem().getId()); e.getPlayer().getInventory().deleteItem(e.getItem().getId(), 1); e.getPlayer().setNextAnimation(urn.getTeleAnim()); e.getPlayer().getSkills().addXpLamp(urn.getSkill(), urn.getTeleXp()); }); public static ItemClickHandler handleCheckUrns = new ItemClickHandler(Urn.FILL_IDS.keySet().toArray(), new String[] { ""Check level"" }, e -> { Urn urn = Urn.forFillId(e.getItem().getId()); e.getPlayer().sendMessage(""The urn is filled "" + Utils.formatDouble(e.getItem().getMetaDataD(""xp"") / urn.getFillXp() * 100.0) + ""%.""); }); public static ItemOnItemHandler addRune = new ItemOnItemHandler(Urn.NR_IDS.keySet().stream().mapToInt(i->i).toArray(), e -> { Urn u = Urn.forNRId(e.getItem1().getId()); if (u == null) u = Urn.forNRId(e.getItem2().getId()); if (u == null) return; final Urn urn = u; Rune rune = Rune.forId(e.getUsedWith(urn.nrId()).getId()); if (rune == urn.getRune()) e.getPlayer().startConversation(new Conversation(e.getPlayer()) .addNext(new MakeXStatement(new int[] { urn.rId() })) .addNext(() -> { int amount = e.getPlayer().getInventory().getNumberOf(urn.nrId()); if (amount > e.getPlayer().getInventory().getNumberOf(urn.getRune().id())) amount = e.getPlayer().getInventory().getNumberOf(urn.getRune().id()); e.getPlayer().getInventory().deleteItem(urn.nrId(), amount); e.getPlayer().getInventory().deleteItem(urn.getRune().id(), amount); e.getPlayer().getInventory().addItem(urn.rId(), amount); e.getPlayer().getSkills().addXpLamp(urn.getSkill(), amount); e.getPlayer().setNextAnimation(urn.getReadyAnim()); })); else e.getPlayer().sendMessage(""You must use "" + Utils.addArticle(urn.getRune().name().toLowerCase()) + "" rune to activate this urn.""); }); public static XPGainHandler handleUrnXp = new XPGainHandler(e -> { switch(e.getSkillId()) { case Constants.SMITHING: case Constants.WOODCUTTING: case Constants.FISHING: case Constants.COOKING: case Constants.MINING: addXPToUrn(e.getPlayer(), getUrn(e.getPlayer(), e.getSkillId()), e.getXp()); break; } }); public static NPCDropHandler handle = new NPCDropHandler(null, new Object[] { 20264, 20266, 20268 }, e -> { switch(e.getItem().getId()) { case 20264: if (addXPToUrn(e.getPlayer(), getUrn(e.getPlayer(), Urn.IMPIOUS, Urn.ACCURSED, Urn.INFERNAL), 4)) e.deleteItem(); break; case 20266: if (addXPToUrn(e.getPlayer(), getUrn(e.getPlayer(), Urn.ACCURSED, Urn.INFERNAL), 12.5)) e.deleteItem(); break; case 20268: if (addXPToUrn(e.getPlayer(), getUrn(e.getPlayer(), Urn.INFERNAL), 62.5)) e.deleteItem(); break; } }); public static Urn getUrn(Player player, int skillId) { for (Urn urn : Urn.values()) if (urn.getSkill() == skillId && player.getInventory().containsOneItem(urn.rId(), urn.fillId())) return urn; return null; } public static Urn getUrn(Player player, Urn... urns) { for (Urn urn : urns) if (player.getInventory().containsOneItem(urn.rId(), urn.fillId())) return urn; return null; } public static boolean addXPToUrn(Player player, Urn urn, double xp) { if (urn == null) return false; Item item = player.getItemFromInv(urn.fillId()); if (item != null) { double newXp = item.getMetaDataD(""xp"") + xp; if (newXp >= urn.getFillXp()) { newXp = urn.getFillXp(); player.incrementCount(item.getName() + "" filled""); item.setId(urn.fullId()); item.deleteMetaData(); player.getInventory().refresh(); } else item.addMetaData(""xp"", newXp); player.sendMessage(""Your urn is filled "" + Utils.formatDouble(newXp / urn.getFillXp() * 100) + ""%."", true); return true; } item = player.getItemFromInv(urn.rId()); if (item != null) { if (!player.getInventory().hasFreeSlots()) return false; player.getInventory().deleteItem(urn.rId(), 1); Item fUrn = new Item(urn.fillId(), 1); fUrn.addMetaData(""xp"", xp); player.sendMessage(""You start a new urn."", true); player.getInventory().addItem(fUrn); return true; } return false; } }" "package com.rs.game.content.skills.dungeoneering; @PluginEventHandler public class DamonheimController extends Controller { private boolean showingOption; public static ObjectClickHandler handleJumpDownExit = new ObjectClickHandler(new Object[] { 50552 }, e -> { if (e.getPlayer().getControllerManager().getController() instanceof DungeonController) e.getPlayer().getControllerManager().removeControllerWithoutCheck(); e.getPlayer().forceMove(e.getObject().getTile(), 5, 35); e.getPlayer().getPackets().sendVarc(234, 0);// Party Config Interface e.getPlayer().getControllerManager().startController(new DamonheimController()); e.getPlayer().useStairs(13760, Tile.of(3454, 3725, 0), 2, 3); }); @Override public void start() { setInviteOption(true); } @Override public boolean canPlayerOption1(Player target) { player.setNextFaceTile(target.getTile()); player.getDungManager().invite(target.getDisplayName()); return false; } @Override public boolean login() { moved(); DungeonManager.checkRejoin(player); return false; } @Override public void onTeleported(TeleType type) { setInviteOption(false); player.getDungManager().leaveParty(); removeController(); } @Override public boolean sendDeath() { setInviteOption(false); player.getDungManager().leaveParty(); removeController(); return true; } @Override public boolean logout() { return false; // so doesnt remove script } @Override public void forceClose() { setInviteOption(false); } /** * return process normaly */ @Override public boolean processNPCClick1(NPC npc) { if (npc.getId() == 9707) player.getDungManager().leaveParty(); return true; } /** * return process normaly */ @Override public boolean processNPCClick2(NPC npc) { if (npc.getId() == 9707) player.getDungManager().leaveParty(); return true; } @Override public void moved() { if (player.getDungManager().isInsideDungeon()) return; if (!isAtKalaboss(player.getTile())) { setInviteOption(false); player.getDungManager().leaveParty(); removeController(); } else setInviteOption(true); } public static boolean isAtKalaboss(Tile tile) { return tile.getX() >= 3385 && tile.getX() <= 3513 && tile.getY() >= 3605 && tile.getY() <= 3794; } public void setInviteOption(boolean show) { if (show == showingOption) return; showingOption = show; player.setPlayerOption(show ? ""Invite"" : ""null"", 1); } }" "package com.rs.game.content.skills.dungeoneering; public class Door { private final int type, id, level; public Door(int type, int id, int level) { this.type = type; this.id = id; this.level = level; } public Door(int type, int id) { this(type, id, 0); } public Door(int type) { this(type, 0); } public int getType() { return type; } public int getId() { return id; } public int getLevel() { return level; } }" "package com.rs.game.content.skills.dungeoneering; @SuppressWarnings(""unused"") public final class Dungeon { private final int type, complexity, size; private final Room[][] map; private final RoomReference startRoom; private long seed; private int creationCount; private int critCount; private static Dungeon test; public static void main(String[] args) throws IOException { Settings.loadConfig(); Cache.init(Settings.getConfig().getCachePath()); JFrame frame = new JFrame() { @Serial private static final long serialVersionUID = 1L; @Override public void paint(Graphics g) { super.paint(g); if (test != null) test.draw((Graphics2D) g); } }; frame.pack(); frame.setSize(600, 800); frame.setVisible(true); frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); long lastDung = System.currentTimeMillis(); test = new Dungeon(null, 1, 6, DungeonConstants.LARGE_DUNGEON); Logger.debug(Dungeon.class, ""main"", ""Generated dungeon in "" + (System.currentTimeMillis() - lastDung) + ""ms...""); frame.repaint(); } public void draw(Graphics2D g) { g.scale(3, 3); g.setColor(Color.black); g.fillRect(0, 0, 800, 500); g.setFont(new Font(""Arial"", Font.BOLD, 7)); g.setColor(Color.ORANGE); g.drawString(""Orange - Start room"", 23, 210); g.setColor(Color.YELLOW); g.drawString(""Yellow - Non-critical room"", 23, 220); g.setColor(Color.RED); g.drawString(""Red - Critical path"", 23, 230); g.setColor(Color.MAGENTA); g.drawString(""Magenta - Boss Room"", 23, 240); g.setColor(Color.GREEN); g.drawString(""Green - Connections"", 110, 210); g.setColor(Color.GRAY); g.drawString(""Gray - Key Door"", 110, 220); g.setColor(Color.WHITE); g.drawString(""White - Key Item"", 110, 230); for (int y = 0; y < map[0].length; y++) for (int x = 0; x < map.length; x++) if (map[x][y] != null) { g.setColor(Color.YELLOW); if (map[x][y].isCritPath()) g.setColor(Color.RED); g.fillRect(x * 20 + 24, (7 - y) * 20 + 44, 12, 12); if (x == test.getStartRoomReference().getRoomX() && y == test.getStartRoomReference().getRoomY()) { g.setColor(Color.ORANGE); g.fillRect(x * 20 + 27, (7 - y) * 20 + 47, 6, 6); } if (map[x][y].getRoom() instanceof BossRoom) { g.setColor(Color.MAGENTA); g.fillRect(x * 20 + 27, (7 - y) * 20 + 47, 6, 6); } g.setColor(Color.green); if (map[x][y].hasNorthDoor()) g.drawLine(x * 20 + 30, (7 - y) * 20 + 50, x * 20 + 30, ((7 - y) - 1) * 20 + 50); if (map[x][y].hasEastDoor()) g.drawLine(x * 20 + 30, (7 - y) * 20 + 50, (x + 1) * 20 + 30, ((7 - y)) * 20 + 50); if (map[x][y].hasSouthDoor()) g.drawLine(x * 20 + 30, (7 - y) * 20 + 50, x * 20 + 30, ((7 - y) + 1) * 20 + 50); if (map[x][y].hasWestDoor()) g.drawLine(x * 20 + 30, (7 - y) * 20 + 50, (x - 1) * 20 + 30, ((7 - y)) * 20 + 50); } for (int y = 0; y < map[0].length; y++) for (int x = 0; x < map.length; x++) if (map[x][y] != null) { int key = map[x][y].getDropId(); if (key != -1) { g.setFont(new Font(""Arial"", Font.BOLD, 5)); g.setColor(Color.white); g.drawString(formatName(ItemDefinitions.getDefs(key).name), x * 20 + 36, (7 - y) * 20 + 48); } g.setFont(new Font(""Arial"", Font.BOLD, 7)); g.setColor(Color.green); for (int l = 0; l < map[x][y].getRoom().getDoorDirections().length; l++) { int lock0 = 0;// (map[x][y].getDoorTypes()[l] >> 16 & 0xFFFF) - 50208; Door door = map[x][y].getDoor(l); lock0 = door != null && door.getType() == DungeonConstants.KEY_DOOR ? door.getId() : -1; int rotation = (map[x][y].getRoom().getDoorDirections()[l] + map[x][y].getRotation()) & 0x3; if (lock0 >= 0 && lock0 < 64) if (rotation == DungeonConstants.NORTH_DOOR) { g.setFont(new Font(""Arial"", Font.BOLD, 5)); g.setColor(Color.LIGHT_GRAY); g.drawString(formatName(ItemDefinitions.getDefs(KeyDoors.values()[lock0].getKeyId()).name), x * 20 + 27, (7 - y) * 20 + 48); } else if (rotation == DungeonConstants.EAST_DOOR) { g.setFont(new Font(""Arial"", Font.BOLD, 5)); g.setColor(Color.LIGHT_GRAY); g.drawString(formatName(ItemDefinitions.getDefs(KeyDoors.values()[lock0].getKeyId()).name), x * 20 + 31, (7 - y) * 20 + 52); } else if (rotation == DungeonConstants.SOUTH_DOOR) { g.setFont(new Font(""Arial"", Font.BOLD, 5)); g.setColor(Color.LIGHT_GRAY); g.drawString(formatName(ItemDefinitions.getDefs(KeyDoors.values()[lock0].getKeyId()).name), x * 20 + 27, (7 - y) * 20 + 55); } else if (rotation == DungeonConstants.WEST_DOOR) { g.setFont(new Font(""Arial"", Font.BOLD, 5)); g.setColor(Color.LIGHT_GRAY); g.drawString(formatName(ItemDefinitions.getDefs(KeyDoors.values()[lock0].getKeyId()).name), x * 20 + 24, (7 - y) * 20 + 52); } } } } public static String formatName(String key) { char[] arr = key.toUpperCase().toCharArray(); StringBuilder name = new StringBuilder("""" + arr[0]); for (int i = 0; i < arr.length - 1; i++) if (arr[i] == ' ' && arr[i + 1] != 'K') name.append(arr[i + 1]); return name.toString(); } public static String padRight(String s, int n) { return String.format(""%1$-"" + n + ""s"", s); } public Dungeon(DungeonManager manager, int floorId, int complexity, int size) { type = DungeonUtils.getFloorType(floorId); this.complexity = complexity; this.size = size; seed = System.nanoTime(); if(manager.getParty().customSeed) { seed = manager.getParty().getStartingSeed(); manager.getParty().customSeed = false; } // seed = 3022668148508890112L; Random random = new Random(seed); DungeonStructure structure = new DungeonStructure(size, random, complexity); // map structure to matrix dungeon map = new Room[DungeonConstants.DUNGEON_RATIO[size][0]][DungeonConstants.DUNGEON_RATIO[size][1]]; RoomNode base = structure.getBase(); Room[] possibilities; startRoom = new RoomReference(base.x, base.y); List children = base.getChildrenR(); children.add(base); long eligiblePuzzleRooms = children.stream().filter(r -> !r.children.isEmpty() && r.children.stream().allMatch(c -> c.lock == -1)).count(); double puzzleChance = complexity < 6 ? 0 : 0.1 * children.size() / eligiblePuzzleRooms; for (RoomNode node : children) { creationCount++; boolean puzzle = false; if (node == base) possibilities = DungeonUtils.selectPossibleRooms(DungeonConstants.START_ROOMS, complexity, type, base.north(), base.east(), base.south(), base.west()); else if (node.isBoss) possibilities = DungeonUtils.selectPossibleBossRooms(type, complexity, floorId, node.north(), node.east(), node.south(), node.west(), node.rotation()); else if (!node.children.isEmpty() && node.children.stream().allMatch(c -> c.lock == -1) && puzzleChance > random.nextDouble()) { puzzle = true; possibilities = DungeonUtils.selectPossibleRooms(DungeonConstants.PUZZLE_ROOMS, complexity, type, node.north(), node.east(), node.south(), node.west(), node.rotation()); } else possibilities = DungeonUtils.selectPossibleRooms(DungeonConstants.NORMAL_ROOMS, complexity, type, node.north(), node.east(), node.south(), node.west()); map[node.x][node.y] = possibilities[random.nextInt(possibilities.length)]; if (node.isCritPath) { critCount++; map[node.x][node.y].setCritPath(true); } if (node.key != -1) map[node.x][node.y].setDropId(KeyDoors.values()[node.key].getKeyId()); for (int doorDir = 0; doorDir < map[node.x][node.y].getRoom().getDoorDirections().length; doorDir++) { int rotation = (map[node.x][node.y].getRoom().getDoorDirections()[doorDir] + map[node.x][node.y].getRotation()) & 0x3; RoomNode neighbor = structure.getRoom(node.x + Utils.ROTATION_DIR_X[rotation], node.y + Utils.ROTATION_DIR_Y[rotation]); if (neighbor.parent == node) if (puzzle) map[node.x][node.y].setDoor(doorDir, new Door(DungeonConstants.CHALLENGE_DOOR)); else if (neighbor.lock != -1) map[node.x][node.y].setDoor(doorDir, new Door(DungeonConstants.KEY_DOOR, neighbor.lock)); else if (complexity >= 5 && random.nextInt(3) == 0) { int doorIndex = random.nextInt(DungeonConstants.SkillDoors.values().length); SkillDoors sd = DungeonConstants.SkillDoors.values()[doorIndex]; if (sd.getClosedObject(type) == -1) // some frozen skill doors dont exist continue; int level = manager == null ? 1 : neighbor.isCritPath ? (manager.getParty().getMaxLevel(sd.getSkillId()) - random.nextInt(10)) : random.nextInt(sd.getSkillId() == Constants.SUMMONING || sd.getSkillId() == Constants.PRAYER ? 100 : 106); map[node.x][node.y].setDoor(doorDir, new Door(DungeonConstants.SKILL_DOOR, doorIndex, level < 1 ? 1 : level)); } else if (complexity >= 3 && random.nextInt(2) == 0) map[node.x][node.y].setDoor(doorDir, new Door(DungeonConstants.GUARDIAN_DOOR)); } } } public long getSeed() { return seed; } public int getRoomsCount() { return creationCount; } public int getCritCount() { return critCount; } public Room getRoom(RoomReference reference) { if (reference.getRoomX() < 0 || reference.getRoomY() < 0 || map.length <= reference.getRoomX() || map[reference.getRoomX()].length <= reference.getRoomY()) return null; return map[reference.getRoomX()][reference.getRoomY()]; } public int getMapWidth() { return map.length; } public int getMapHeight() { return map[0].length; } public RoomReference getStartRoomReference() { return startRoom; } public int getType() { return type; } public int getComplexity() { return complexity; } public int getSize() { return size; } public Room[][] getMap() { return map; } }" "package com.rs.game.content.skills.dungeoneering; public class DungeonConstants { public static final int[] MIN_CRIT_PATH = { 5, 10, 19 }; public static final int[] MAX_CRIT_PATH = { 7, 13, 23 }; public static final Tile OUTSIDE = Tile.of(3460, 3720, 1); public static final int ROTATIONS_COUNT = 4; public static final int TINDERBOX = 17678; public static final int SMUGGLER = 11226; public static final int[] LADDERS = { 49696, 49698, 49700, 53748, 55484 }; public static final int FLOORS_COUNT = 60; public static final int GROUP_GATESTONE = 18829, GATESTONE = 17489; /* * objects handling */ public static final int[] DUNGEON_DOORS = { 50342, 50343, 50344, 53948, 55762 }; public static final int[] DUNGEON_BOSS_DOORS = { 50350, 50351, 50352, 53950, 55764 }; public static final int[] DUNGEON_GUARDIAN_DOORS = { 50346, 50347, 50348, 53949, 55763 }; /* * novite ores */ public static final int[] MINING_RESOURCES = { 49806, 49786, 49766, 53771, 55514 }; /* * Tangle gum tree */ public static final int[] WOODCUTTING_RESOURCES = { 49745, 49725, 49705, 53751, 55494 }; /* * Salve nettles */ public static final int[] FARMING_RESOURCES = { 49866, 49846, 49826, 53791, 55534 }; public static final int[] THIEF_CHEST_LOCKED = { 49345, 49346, 49347, 54407, 32462 }; public static final int[] THIEF_CHEST_OPEN = { 49348, 49349, 49350, 54408, 32679 }; public static final double[] THIEF_CHEST_XP = { 25.5, 57, 115, 209, 331.5, 485, 661.5, 876, 1118, 1410.5 }; public static final int RUSTY_COINS = 18201, BANANA = 18199; public static final int[] CHARMS = { 18017, 18018, 18019, 18020 }; public static final int[] ARROWS = { 16427, 16432, 16437, 16442, 16447, 16452, 16457, 16462, 16467, 16472, 16477 }; public static final int[] RUNES = { 17780, 17781, 17782, 17783, 17784, 17785, 17786, 17787, 17788, 17789, 17790, 17791, 17792, 17793 }; public static final int RUNE_ESSENCE = 17776, FEATHER = 17796; public static final int[] DUNGEON_KEY_DOORS = { 50353, 50417, 50481, 53884, 55675 }; public enum SkillDoors { RUNED_DOOR(Constants.RUNECRAFTING, new int[] { 50278, 50279, 50280, 53953, 55741 }, 791, 186, -1, -1, -1, -1, ""You imbue the door with the wrong type of rune energy, and it reacts explosively.""), BARRED_DOOR(Constants.STRENGTH, new int[] { 50272, 50273, 50274, 53951, 55739 }, new int[] { 50275, 50276, 50277, 53952, 55740 }, -1, -1, -1, -1, -1, -1, ""You pull a muscle while attempting to move the plank.""), PILE_OF_ROCKS(Constants.MINING, new int[] { 50305, 50306, 50307, 53962, 55750 }, -2, -1, 13559, -1, -1, 2420, ""You fail to mine the obstruction, and are harmed by falling debris.""), FLAMMABLE_DEBRIS(Constants.FIREMAKING, new int[] { 50314, 50315, 50316, 53965, 55753 }, 16700, -1, 13562, 13563, -1, -1, ""The pile of debris fails to ignite. The same cannot be said for your clothes.""), MAGICAL_BARRIER(Constants.MAGIC, new int[] { 50329, 50330, 50331, 53970, 55758 }, 4411, -1, 13551, 13550, -1, -1, ""You fail to dispel the barrier and take a surge of magical energy to the face.""), DARK_SPIRIT(Constants.PRAYER, new int[] { 50332, 50333, 50334, 53971, 55759 }, 645, -1, 13557, 13556, -1, -1, ""The gods snub your prayer, and the dark spirit attacks you.""), WOODEN_BARRICADE(Constants.WOODCUTTING, new int[] { 50317, 50318, 50319, 53966, 55754 }, new int[] { 50320, 50321, 50322, 53967, 55755 }, -3, -1, 13582, -1, -1, -1, ""You swing the axe against the grain and are showered with sharp splinters of wood.""), BROKEN_KEY_DOOR(Constants.SMITHING, new int[] { 50308, 50309, 50310, 53963, 55751 }, new int[] { 50311, 50312, 50313, 53964, 55752 }, 13759, -1, -1, -1, -1, -1, ""You hit your hand with the hammer. Needless to say, the key is still broken.""), BROKEN_PULLEY_DOOR(Constants.CRAFTING, new int[] { 50299, 50300, 50301, 53960, 55748 }, new int[] { 50302, 50303, 50304, 53961, 55749 }, 13547, -1, -1, -1, -1, -1, ""The rope snaps again as you attempt to fix it, and you crush your hands in the mechanism.""), LOCKED_DOOR(Constants.AGILITY, new int[] { -1, 50288, 50289, 53956, 55744 }, new int[] { 50290, 50291, 50292, 53957, 55745 }, 14550, -1, -1, -1, -1, -1, ""You miss the chain, and set off the trap.""), PADLOCKED_DOOR(Constants.THIEVING, new int[] { -1, 50294, 50295, 53958, 55746 }, new int[] { 50296, 50297, 50298, 53959, 55747 }, 14568, -1, -1, -1, 14569, -1, ""You set off a booby trap inside the lock, and fail to pick it.""), RAMOKEE_EXILE(Constants.SUMMONING, new int[] { -1, 50327, 50328, 53969, 55757 }, 725, 1207, -1, -1, -1, -1, ""You fail to dismiss the rogue familiar, and it punches you in anger.""), LIQUID_LOCK_DOOR(Constants.HERBLORE, new int[] { -1, 50336, 50337, 53972, 55760 }, new int[] { 50338, 50339, 50340, 53973, 55761 }, 14568, -1, -1, -1, -1, -1, ""You incorrectly mix the ingredients, making it explode.""), VINE_COVERED_DOOR(Constants.FARMING, new int[] { -1, 50324, 50325, 53968, 55756 }, 2275, -1, 13572, -1, -1, -1, ""You hurt your hands on the vicious thorns covering the vines.""), COLLAPSING_DOORFRAME(Constants.CONSTRUCTION, new int[] { -1, 50282, 50283, 53954, 55742 }, new int[] { 50284, 50285, 50286, 53955, 55743 }, 14566, -1, -1, -1, 14567, -1, ""You dislodge some debris while attempting to fix the door, and it falls on you.""); SkillDoors(int skillId, int[] closedThemeObjects, int openAnim, int openGfx, int openObjectAnim, int failObjectAnim, int failAnim, int failGfx, String failMessage) { this(skillId, closedThemeObjects, null, openAnim, openGfx, openObjectAnim, failObjectAnim, failAnim, failGfx, failMessage); } private final int skillId, openAnim, openGfx, openObjectAnim, failObjectAnim, failAnim, failGfx; private final int[] closedThemeObjects, openThemeObjects; private final String failMessage; /* * set openThemeObjects if u want it to disappear after open */ SkillDoors(int skillId, int[] closedThemeObjects, int[] openThemeObjects, int openAnim, int openGfx, int openObjectAnim, int failObjectAnim, int failAnim, int failGfx, String failMessage) { this.skillId = skillId; this.closedThemeObjects = closedThemeObjects; this.openThemeObjects = openThemeObjects; this.failMessage = failMessage; this.openAnim = openAnim; this.openGfx = openGfx; this.openObjectAnim = openObjectAnim; this.failObjectAnim = failObjectAnim; this.failGfx = failGfx; this.failAnim = failAnim; } public int getSkillId() { return skillId; } public int getFailGfx() { return failGfx; } public int getFailAnim() { return failAnim; } public int getFailObjectAnim() { return failObjectAnim; } public int getOpenObjectAnim() { return openObjectAnim; } public int getOpenAnim() { return openAnim; } public int getOpenGfx() { return openGfx; } public int getClosedObject(int type) { return closedThemeObjects[type]; } public int getOpenObject(int type) { return openThemeObjects == null ? -1 : openThemeObjects[type]; } public String getFailMessage() { return failMessage; } } /* * keydoors only require the unlock objectid and itemid */ public enum KeyDoors { ORANGE_TRIANGLE(0), ORANGE_DIAMOND(1), ORANGE_RECTANGLE(2), ORANGE_PENTAGON(3), ORANGE_CORNER(4), ORANGE_CRESCENT(5), ORANGE_WEDGE(6), ORANGE_SHIELD(7), SILVER_TRIANGLE(8), SILVER_DIAMOND(9), SILVER_RECTANGLE(10), SILVER_PENTAGON(11), SILVER_CORNER(12), SILVER_CRESCENT(13), SILVER_WEDGE(14), SILVER_SHIELD(15), YELLOW_TRIANGLE(16), YELLOW_DIAMOND(17), YELLOW_RECTANGLE(18), YELLOW_PENTAGON(19), YELLOW_CORNER(20), YELLOW_CRESCENT(21), YELLOW_WEDGE(22), YELLOW_SHIELD(23), GREEN_TRIANGLE(24), GREEN_DIAMOND(25), GREEN_RECTANGLE(26), GREEN_PENTAGON(27), GREEN_CORNER(28), GREEN_CRESCENT(29), GREEN_WEDGE(30), GREEN_SHIELD(31), BLUE_TRIANGLE(32), BLUE_DIAMOND(33), BLUE_RECTANGLE(34), BLUE_PENTAGON(35), BLUE_CORNER(36), BLUE_CRESCENT(37), BLUE_WEDGE(38), BLUE_SHIELD(39), PURPLE_TRIANGLE(40), PURPLE_DIAMOND(41), PURPLE_RECTANGLE(42), PURPLE_PENTAGON(43), PURPLE_CORNER(44), PURPLE_CRESCENT(45), PURPLE_WEDGE(46), PURPLE_SHIELD(47), CRIMSON_TRIANGLE(48), CRIMSON_DIAMOND(49), CRIMSON_RECTANGLE(50), CRIMSON_PENTAGON(51), CRIMSON_CORNER(52), CRIMSON_CRESCENT(53), CRIMSON_WEDGE(54), CRIMSON_SHIELD(55), GOLD_TRIANGLE(56), GOLD_DIAMOND(57), GOLD_RECTANGLE(58), GOLD_PENTAGON(59), GOLD_CORNER(60), GOLD_CRESCENT(61), GOLD_WEDGE(62), GOLD_SHIELD(63); private final int index; KeyDoors(int index) { this.index = index; } public int getObjectId() { return getLowestObjectId() + index; } public int getDoorId(int floorType) { return getLowestDoorId(floorType) + index; } public static int getLowestObjectId() { return 50208; } public static int getLowestDoorId(int floorType) { return DUNGEON_KEY_DOORS[floorType]; } public static int getMaxObjectId() { return 50208 + KeyDoors.values().length; } public static int getMaxDoorId(int floorType) { return DUNGEON_KEY_DOORS[floorType] + KeyDoors.values().length; } public int getKeyId() { return getLowestKeyId() + (index * 2); } public static int getLowestKeyId() { return 18202; } public int getIndex() { return index; } } public static final int NORMAL_DOOR = 0, GUARDIAN_DOOR = 1, SKILL_DOOR = 2, CHALLENGE_DOOR = 3, KEY_DOOR = 4; public static final double UNBALANCED_PARTY_PENALTY = 0.4; public static final double[] DUNGEON_SIZE_BONUS = { 0, 0.0792, 0.1583 }; public static final double[] COMPLEXITY_PENALTY_BASE = { 0.32, 0.35, 0.37 }; public static final double MAX_BONUS_ROOM = 0.1267; public static final double[][] DUNGEON_DIFFICULTY_RATIO_BONUS = { { 0 }, { -0.076, 0.0507 }, { -0.152, 0.019, 0.95 }, { -0.228, -0.076, 0.0633, 0.1457 }, { -0.304, -0.1267, 0.0380, 0.114, 0.19 } }; /* * floor types */ public static final int FROZEN_FLOORS = 0, ABANDONED_FLOORS = 1, FURNISHED_FLOORS = 2, OCCULT_FLOORS = 3, WARPED_FLOORS = 4; /* * dungeon sizes */ public static final int SMALL_DUNGEON = 0, MEDIUM_DUNGEON = 1, LARGE_DUNGEON = 2; public static final double[] NPC_COMBAT_LEVEL_COMPLEXITY_MUL = { 0.70, 0.75, 0.80, 0.85, 0.95, 1.0 }; // 4x4, 4x8 and 4x8, 2x1(just boss room for test) public static final int[][] DUNGEON_RATIO = { { 4, 4 }, { 4, 8 }, { 8, 8 }, { 2, 1 } }; /* * door directions */ public static final int EAST_DOOR = 2, WEST_DOOR = 0, NORTH_DOOR = 1, SOUTH_DOOR = 3; public static final int[] START_ROOM_MUSICS = { 822, 797, 765, 884, 935 }; public static final int[][] DANGEROUS_MUSICS = { { 832, 834, 827, 811, 824, 808, 831, 810, 833, 837 }, //frozen { 779, 781, 799, 802, 794, 780, 771, 790, 775, 801 }, //abandoned { 748, 769, 741, 739, 742, 753, 761, 757, 747, 756 }, //furnished { 873, 882, 880, 860, 886, 872, 885, 889, 870, 864 }, //occult floor { 930, 914, 917, 911, 927, 939, 938, 920, 925, 936 }, //warped floor }; public static final int[][] SAFE_MUSICS = { // FROZEN_FLOORS { 804, 805, 806, 807, 809, 812, 813, 814, 812, 813, 814, 821, 822 }, //frozen { 772, 773, 775, 776, 777, 778, 788, 789, 791, 792, 793, 795, 796 }, //abandoned { 740, 744, 745, 749, 750, 751, 752, 754, 755, 758, 760, 762, 764 }, //furnished { 861, 862, 866, 867, 868, 869, 871, 874, 875, 878, 879, 881, 883 }, //occult { 912, 915, 918, 919, 921, 923, 926, 928, 929, 931, 932, 933, 934 } //warped floor }; public static final int[] OTHER_DUNGEONEERING_MUSIC = new int[] { 0, 738, 743, 746, 759, 767, 768, 782, 784, 785, 786, 787, 803, 815, 816, 817, 818, 819, 820, 863, 865, 876, 877, 890, 891, 892, 913, 916, 922, 924, 937, 940, 1089, 1090 }; public enum GuardianMonster { //ALL FLOORS FORGOTTEN_WARRIOR(new int[] { FROZEN_FLOORS, ABANDONED_FLOORS, FURNISHED_FLOORS, OCCULT_FLOORS, WARPED_FLOORS }, Utils.range(10397, 10459), Utils.range(10246, 10308), Utils.range(10843, 10905), Utils.range(10507, 10548)), FORGOTTEN_RANGER(new int[] { FROZEN_FLOORS, ABANDONED_FLOORS, FURNISHED_FLOORS, OCCULT_FLOORS, WARPED_FLOORS }, Utils.range(10320, 10363)), FORGOTTEN_MAGE(new int[] { FROZEN_FLOORS, ABANDONED_FLOORS, FURNISHED_FLOORS, OCCULT_FLOORS, WARPED_FLOORS }, Utils.range(10560, 10603)), MYSTERIOUS_SHADE(new int[] { FROZEN_FLOORS, ABANDONED_FLOORS, FURNISHED_FLOORS, OCCULT_FLOORS, WARPED_FLOORS }, Utils.range(10831, 10842), new int[] { 7398 }), //MIXED FLOORS GIANT_RAT(new int[] { FROZEN_FLOORS, ABANDONED_FLOORS, FURNISHED_FLOORS, OCCULT_FLOORS }, Utils.range(10480, 10486)), DUNGEON_SPIDER(new int[] { ABANDONED_FLOORS, FURNISHED_FLOORS, OCCULT_FLOORS }, Utils.range(10496, 10505), new int[] { 9382 }), SKELETON_MELEE(new int[] { ABANDONED_FLOORS, OCCULT_FLOORS, WARPED_FLOORS }, Utils.range(10629, 10669)), SKELETON_RANGED(new int[] { ABANDONED_FLOORS, OCCULT_FLOORS, WARPED_FLOORS }, Utils.range(10670, 10681)), SKELETON_MAGIC(new int[] { ABANDONED_FLOORS, OCCULT_FLOORS, WARPED_FLOORS }, Utils.range(10682, 10693)), ZOMBIE_MELEE(new int[] { ABANDONED_FLOORS, OCCULT_FLOORS, WARPED_FLOORS }, Utils.range(10364, 10374)), ZOMBIE_RANGED(new int[] { ABANDONED_FLOORS, OCCULT_FLOORS, WARPED_FLOORS }, Utils.range(10375, 10385)), BAT(new int[] { ABANDONED_FLOORS, FURNISHED_FLOORS, OCCULT_FLOORS }, Utils.range(10906, 10909)), GIANT_BAT(new int[] { ABANDONED_FLOORS, FURNISHED_FLOORS, OCCULT_FLOORS }, Utils.range(10910, 10914)), ANIMATED_PICKAXE(new int[] { ABANDONED_FLOORS, WARPED_FLOORS }, Utils.range(10168, 10177)), ANIMATED_BOOK(new int[] { OCCULT_FLOORS, WARPED_FLOORS }, Utils.range(10744, 10753)), LESSER_DEMON(new int[] { OCCULT_FLOORS, WARPED_FLOORS }, Utils.range(10492, 10495)), GREATER_DEMON(new int[] { OCCULT_FLOORS, WARPED_FLOORS }, Utils.range(10718, 10721)), BLACK_DEMON(new int[] { OCCULT_FLOORS, WARPED_FLOORS }, Utils.range(10722, 10725)), //FROZEN ICE_WARRIOR(new int[] { FROZEN_FLOORS }, Utils.range(10225, 10235)), ICE_SPIDER(new int[] { FROZEN_FLOORS }, Utils.range(10157, 10167)), ICE_TROLL(new int[] { FROZEN_FLOORS }, Utils.range(10782, 10790)), ICE_GIANT(new int[] { FROZEN_FLOORS }, Utils.range(10762, 10769)), ICE_ELEMENTAL(new int[] { FROZEN_FLOORS }, Utils.range(10460, 10468)), THROWER_TROLL(new int[] { FROZEN_FLOORS }, Utils.range(10791, 10796)), HYDRA(new int[] { FROZEN_FLOORS }, Utils.range(10610, 10618)), FROST_DRAGON(new int[] { FROZEN_FLOORS }, Utils.range(10770, 10775)), //ABANDONED EARTH_WARRIOR(new int[] { ABANDONED_FLOORS }, Utils.range(10178, 10187)), GREEN_DRAGON(new int[] { ABANDONED_FLOORS }, Utils.range(10604, 10609)), HILL_GIANT(new int[] { ABANDONED_FLOORS }, Utils.range(10706, 10717)), GIANT_SKELETON(new int[] { ABANDONED_FLOORS }, Utils.range(10469, 10479)), HOBGOBLIN(new int[] { ABANDONED_FLOORS }, Utils.range(10236, 10245)), //FURNISHED GUARD_DOG(new int[] { FURNISHED_FLOORS }, Utils.range(10726, 10735)), BRUTE(new int[] { FURNISHED_FLOORS }, Utils.range(10797, 10814)), IRON_DRAGON(new int[] { FURNISHED_FLOORS }, Utils.range(10776, 10781)), //OCCULT RED_DRAGON(new int[] { OCCULT_FLOORS }, Utils.range(10815, 10820)), FIRE_GIANT(new int[] { OCCULT_FLOORS }, Utils.range(10754, 10761)), HELLHOUND(new int[] { OCCULT_FLOORS }, Utils.range(10188, 10195)), NECROMANCER(new int[] { OCCULT_FLOORS }, Utils.range(10196, 10206)), GHOST(new int[] { OCCULT_FLOORS }, Utils.range(10821, 10830)), //WARPED GIANT_RAT_WARP(new int[] { WARPED_FLOORS }, Utils.range(12914, 12920)), GUARD_DOG_WARP(new int[] { WARPED_FLOORS }, Utils.range(12922, 12931)), BRUTE_WARP(new int[] { FURNISHED_FLOORS }, Utils.range(12932, 12940)), BLACK_DRAGON(new int[] { WARPED_FLOORS }, Utils.range(10219, 10224)), REBORN_MAGE(new int[] { WARPED_FLOORS }, Utils.range(12903, 12913)), REBORN_WARRIOR(new int[] { WARPED_FLOORS }, Utils.range(12941, 12951)), ANKOU(new int[] { WARPED_FLOORS }, Utils.range(10736, 10743)); private static final Map MAP = new HashMap<>(); private static final Map> FLOOR_MAP = new HashMap<>(); static { for (GuardianMonster g : GuardianMonster.values()) { for (int floor : g.floors) { Set set = FLOOR_MAP.get(floor); if (set == null) set = new HashSet<>(); set.add(g); FLOOR_MAP.put(floor, set); } for (int id : g.npcIds) MAP.put(id, g); } } private final int[] floors; private final int[] npcIds; GuardianMonster(int[] floors, int[]... npcIds) { this.floors = floors; int totalLen = 0; for (int[] arr : npcIds) totalLen += arr.length; this.npcIds = new int[totalLen]; int i = 0; for (int[] arr : npcIds) for (int id : arr) this.npcIds[i++] = id; } public int[] getNPCIds() { return npcIds; } public static GuardianMonster forId(int npcId) { return MAP.get(npcId); } public static Set forFloor(int floorId) { return FLOOR_MAP.get(floorId); } } public static final int[] HUNTER_CREATURES = new int[] { 11086, 11087, 11088, 11089, 11090, 11091, 11092, 11093, 11094, 11095 }; public static final StartRoom[] START_ROOMS = { // FROZEN_FLOORS new StartRoom(14, 632, EAST_DOOR, WEST_DOOR, NORTH_DOOR, SOUTH_DOOR), new StartRoom(14, 624, SOUTH_DOOR), new StartRoom(14, 626, WEST_DOOR, SOUTH_DOOR), new StartRoom(14, 630, WEST_DOOR, NORTH_DOOR, SOUTH_DOOR) }; public static final NormalRoom[] NORMAL_ROOMS = { new NormalRoom(8, 240, spot(3, 7), SOUTH_DOOR), new NormalRoom(8, 242, spot(3, 12), SOUTH_DOOR, WEST_DOOR), new NormalRoom(8, 244, spot(3, 12), NORTH_DOOR, SOUTH_DOOR), new NormalRoom(8, 246, spot(4, 13), NORTH_DOOR, SOUTH_DOOR, WEST_DOOR), new NormalRoom(8, 248, spot(3, 12), NORTH_DOOR, SOUTH_DOOR, WEST_DOOR, EAST_DOOR), new NormalRoom(8, 256, spot(12, 12), SOUTH_DOOR), new NormalRoom(8, 258, spot(12, 12), SOUTH_DOOR, WEST_DOOR), new NormalRoom(8, 260, spot(11, 6), SOUTH_DOOR, NORTH_DOOR), new NormalRoom(8, 262, spot(12, 6), SOUTH_DOOR, NORTH_DOOR, WEST_DOOR), new NormalRoom(8, 264, spot(12, 12), SOUTH_DOOR, NORTH_DOOR, WEST_DOOR, EAST_DOOR), new NormalRoom(10, 240, spot(3, 3), SOUTH_DOOR), new NormalRoom(10, 242, spot(7, 12), SOUTH_DOOR, WEST_DOOR), new NormalRoom(10, 244, spot(2, 4), NORTH_DOOR, SOUTH_DOOR), new NormalRoom(10, 246, spot(2, 12), NORTH_DOOR, SOUTH_DOOR, WEST_DOOR), new NormalRoom(10, 248, spot(2, 12), NORTH_DOOR, SOUTH_DOOR, WEST_DOOR, EAST_DOOR), new NormalRoom(10, 256, spot(8, 12), SOUTH_DOOR), new NormalRoom(10, 258, spot(12, 2), SOUTH_DOOR, WEST_DOOR), new NormalRoom(10, 260, spot(3, 4), SOUTH_DOOR, NORTH_DOOR), new NormalRoom(10, 262, spot(7, 8), SOUTH_DOOR, NORTH_DOOR, WEST_DOOR), new NormalRoom(10, 264, spot(5, 10), SOUTH_DOOR, NORTH_DOOR, WEST_DOOR, EAST_DOOR), new NormalRoom(12, 240, spot(3, 7), SOUTH_DOOR), new NormalRoom(12, 242, spot(11, 7), SOUTH_DOOR, WEST_DOOR), new NormalRoom(12, 244, spot(3, 12), NORTH_DOOR, SOUTH_DOOR), new NormalRoom(12, 246, spot(10, 7), NORTH_DOOR, SOUTH_DOOR, WEST_DOOR), new NormalRoom(12, 248, spot(10, 7), NORTH_DOOR, SOUTH_DOOR, WEST_DOOR, EAST_DOOR), new NormalRoom(12, 256, spot(9, 7), SOUTH_DOOR), new NormalRoom(12, 258, spot(3, 6), SOUTH_DOOR, WEST_DOOR), new NormalRoom(12, 260, spot(4, 10), SOUTH_DOOR, NORTH_DOOR), new NormalRoom(12, 262, spot(9, 7), SOUTH_DOOR, NORTH_DOOR, WEST_DOOR), new NormalRoom(12, 264, spot(3, 6), SOUTH_DOOR, NORTH_DOOR, WEST_DOOR, EAST_DOOR), new NormalRoom(14, 240, spot(7, 10), SOUTH_DOOR), new NormalRoom(14, 256, spot(4, 13), SOUTH_DOOR), new NormalRoom(14, 258, spot(12, 9), SOUTH_DOOR, WEST_DOOR), new NormalRoom(14, 260, spot(12, 13), SOUTH_DOOR, NORTH_DOOR), new NormalRoom(14, 262, spot(7, 7), SOUTH_DOOR, NORTH_DOOR, WEST_DOOR), new NormalRoom(14, 264, spot(11, 13), SOUTH_DOOR, NORTH_DOOR, WEST_DOOR, EAST_DOOR), new NormalRoom(16, 240, spot(7, 10), SOUTH_DOOR), new NormalRoom(16, 256, spot(4, 12), SOUTH_DOOR), new NormalRoom(16, 258, spot(7, 11), SOUTH_DOOR, WEST_DOOR), new NormalRoom(16, 260, spot(4, 3), SOUTH_DOOR, NORTH_DOOR), new NormalRoom(16, 262, spot(7, 8), SOUTH_DOOR, NORTH_DOOR, WEST_DOOR), new NormalRoom(16, 264, spot(7, 7), SOUTH_DOOR, NORTH_DOOR, WEST_DOOR, EAST_DOOR), new NormalRoom(18, 240, spot(7, 10), SOUTH_DOOR), new NormalRoom(18, 260, spot(5, 12), SOUTH_DOOR, NORTH_DOOR), new NormalRoom(18, 264, spot(3, 12), SOUTH_DOOR, NORTH_DOOR, WEST_DOOR, EAST_DOOR), new NormalRoom(20, 240, spot(9, 13), SOUTH_DOOR), new NormalRoom(20, 258, spot(11, 9), SOUTH_DOOR, WEST_DOOR), new NormalRoom(22, 240, spot(8, 9), SOUTH_DOOR), new NormalRoom(22, 256, spot(7, 10), SOUTH_DOOR), new NormalRoom(22, 258, spot(11, 10), SOUTH_DOOR, WEST_DOOR), new NormalRoom(22, 260, spot(7, 8), SOUTH_DOOR, NORTH_DOOR), new NormalRoom(22, 262, spot(7, 7), SOUTH_DOOR, NORTH_DOOR, WEST_DOOR), new NormalRoom(22, 264, spot(7, 7), SOUTH_DOOR, NORTH_DOOR, WEST_DOOR, EAST_DOOR), new NormalRoom(24, 242, spot(7, 7), SOUTH_DOOR, WEST_DOOR), new NormalRoom(24, 258, spot(12, 10), SOUTH_DOOR, WEST_DOOR), new NormalRoom(24, 264, spot(7, 7), SOUTH_DOOR, NORTH_DOOR, WEST_DOOR, EAST_DOOR), new NormalRoom(26, 242, spot(9, 9), SOUTH_DOOR, WEST_DOOR), new NormalRoom(28, 246, spot(11, 8), NORTH_DOOR, SOUTH_DOOR, WEST_DOOR), new NormalRoom(30, 244, spot(3, 6), NORTH_DOOR, SOUTH_DOOR), new NormalRoom(32, 244, spot(3, 12), NORTH_DOOR, SOUTH_DOOR), new NormalRoom(34, 242, spot(12, 12), SOUTH_DOOR, WEST_DOOR), new NormalRoom(36, 248, spot(2, 13), NORTH_DOOR, SOUTH_DOOR, WEST_DOOR, EAST_DOOR), new NormalRoom(38, 246, spot(12, 10), NORTH_DOOR, SOUTH_DOOR, WEST_DOOR), new NormalRoom(40, 244, spot(3, 12), NORTH_DOOR, SOUTH_DOOR), new NormalRoom(42, 244, spot(7, 7), NORTH_DOOR, SOUTH_DOOR), new NormalRoom(44, 244, spot(7, 7), NORTH_DOOR, SOUTH_DOOR), new NormalRoom(46, 244, spot(7, 7), NORTH_DOOR, SOUTH_DOOR), new NormalRoom(48, 244, spot(7, 7), NORTH_DOOR, SOUTH_DOOR), new NormalRoom(50, 244, spot(7, 7), NORTH_DOOR, SOUTH_DOOR), new NormalRoom(52, 240, spot(7, 11), SOUTH_DOOR), new NormalRoom(54, 240, spot(8, 11), SOUTH_DOOR), new NormalRoom(56, 240, spot(3, 10), SOUTH_DOOR), new NormalRoom(58, 240, spot(3, 12), SOUTH_DOOR), new NormalRoom(60, 240, spot(9, 12), SOUTH_DOOR), new NormalRoom(62, 240, spot(12, 12), SOUTH_DOOR), new NormalRoom(64, 240, spot(2, 12), SOUTH_DOOR), new NormalRoom(66, 240, spot(8, 10), SOUTH_DOOR), new NormalRoom(68, 240, spot(3, 7), SOUTH_DOOR), new NormalRoom(70, 240, spot(8, 12), SOUTH_DOOR), new NormalRoom(72, 240, spot(12, 7), SOUTH_DOOR), new NormalRoom(74, 240, spot(4, 10), SOUTH_DOOR), new NormalRoom(76, 240, spot(8, 7), SOUTH_DOOR), new NormalRoom(78, 240, spot(3, 4), SOUTH_DOOR), new NormalRoom(62, 242, spot(13, 11), SOUTH_DOOR, WEST_DOOR), new NormalRoom(62, 244, spot(2, 3), NORTH_DOOR, SOUTH_DOOR), new NormalRoom(62, 246, spot(13, 11), NORTH_DOOR, SOUTH_DOOR, WEST_DOOR), new NormalRoom(62, 248, spot(2, 3), NORTH_DOOR, SOUTH_DOOR, WEST_DOOR, EAST_DOOR), new NormalRoom(64, 242, spot(7, 12), SOUTH_DOOR, WEST_DOOR), new NormalRoom(64, 244, spot(13, 12), NORTH_DOOR, SOUTH_DOOR), new NormalRoom(64, 246, spot(7, 7), NORTH_DOOR, SOUTH_DOOR, WEST_DOOR), new NormalRoom(64, 248, spot(7, 7), NORTH_DOOR, SOUTH_DOOR, WEST_DOOR, EAST_DOOR), new NormalRoom(66, 242, spot(12, 12), SOUTH_DOOR, WEST_DOOR), new NormalRoom(66, 244, spot(3, 4), NORTH_DOOR, SOUTH_DOOR), new NormalRoom(66, 246, spot(12, 12), NORTH_DOOR, SOUTH_DOOR, WEST_DOOR), new NormalRoom(66, 248, spot(3, 3), NORTH_DOOR, SOUTH_DOOR, WEST_DOOR, EAST_DOOR), new NormalRoom(68, 242, spot(12, 8), SOUTH_DOOR, WEST_DOOR), new NormalRoom(68, 244, spot(5, 8), NORTH_DOOR, SOUTH_DOOR), new NormalRoom(68, 246, spot(5, 8), NORTH_DOOR, SOUTH_DOOR, WEST_DOOR), new NormalRoom(70, 242, spot(11, 10), SOUTH_DOOR, WEST_DOOR), new NormalRoom(70, 244, spot(8, 7), NORTH_DOOR, SOUTH_DOOR), new NormalRoom(70, 246, spot(8, 7), NORTH_DOOR, SOUTH_DOOR, WEST_DOOR), new NormalRoom(72, 242, spot(9, 12), SOUTH_DOOR, WEST_DOOR), new NormalRoom(72, 244, spot(10, 8), NORTH_DOOR, SOUTH_DOOR), new NormalRoom(72, 246, spot(11, 8), NORTH_DOOR, SOUTH_DOOR, WEST_DOOR), new NormalRoom(72, 248, spot(8, 5), NORTH_DOOR, SOUTH_DOOR, WEST_DOOR, EAST_DOOR), new NormalRoom(74, 242, spot(3, 6), SOUTH_DOOR, WEST_DOOR), new NormalRoom(74, 244, spot(7, 5), NORTH_DOOR, SOUTH_DOOR), new NormalRoom(74, 246, spot(3, 7), NORTH_DOOR, SOUTH_DOOR, WEST_DOOR), new NormalRoom(74, 248, spot(2, 6), NORTH_DOOR, SOUTH_DOOR, WEST_DOOR, EAST_DOOR), new NormalRoom(76, 242, spot(11, 9), SOUTH_DOOR, WEST_DOOR), new NormalRoom(76, 244, spot(7, 7), NORTH_DOOR, SOUTH_DOOR), new NormalRoom(76, 246, spot(7, 7), NORTH_DOOR, SOUTH_DOOR, WEST_DOOR), new NormalRoom(76, 248, spot(7, 11), NORTH_DOOR, SOUTH_DOOR, WEST_DOOR, EAST_DOOR), new NormalRoom(78, 242, spot(12, 12), SOUTH_DOOR, WEST_DOOR), new NormalRoom(78, 244, spot(12, 12), NORTH_DOOR, SOUTH_DOOR), new NormalRoom(78, 246, spot(12, 3), NORTH_DOOR, SOUTH_DOOR, WEST_DOOR), new NormalRoom(78, 248, spot(2, 3), NORTH_DOOR, SOUTH_DOOR, WEST_DOOR, EAST_DOOR), }; public enum MapRoomIcon { MAP_1(2791, true, SOUTH_DOOR), MAP_2(2792, true, WEST_DOOR), MAP_3(2793, true, NORTH_DOOR), MAP_4(2794, true, EAST_DOOR), MAP_5(2795, true, WEST_DOOR, SOUTH_DOOR), MAP_6(2796, true, WEST_DOOR, NORTH_DOOR), MAP_7(2797, true, NORTH_DOOR, EAST_DOOR), MAP_8(2798, true, SOUTH_DOOR, EAST_DOOR), MAP_9(2799, true, SOUTH_DOOR, WEST_DOOR, NORTH_DOOR), MAP_10(2800, true, WEST_DOOR, NORTH_DOOR, EAST_DOOR), MAP_11(2801, true, SOUTH_DOOR, NORTH_DOOR, EAST_DOOR), MAP_12(2802, true, SOUTH_DOOR, WEST_DOOR, EAST_DOOR), MAP_13(2803, true, SOUTH_DOOR, NORTH_DOOR, EAST_DOOR, WEST_DOOR), MAP_14(2804, true, SOUTH_DOOR, NORTH_DOOR), MAP_15(2805, true, WEST_DOOR, EAST_DOOR), MAP_16(2787, false, SOUTH_DOOR), MAP_17(2788, false, WEST_DOOR), MAP_18(2789, false, NORTH_DOOR), MAP_19(2790, false, EAST_DOOR); private final int[] doorsDirections; private final int spriteId; private final boolean open; MapRoomIcon(int spriteId, boolean open, int... doorsDirections) { this.doorsDirections = doorsDirections; this.open = open; this.spriteId = spriteId; } public int[] getDoorDirections() { return doorsDirections; } public boolean hasSouthDoor() { return hasDoor(SOUTH_DOOR); } public boolean hasNorthDoor() { return hasDoor(NORTH_DOOR); } public boolean hasWestDoor() { return hasDoor(WEST_DOOR); } public boolean hasEastDoor() { return hasDoor(EAST_DOOR); } public boolean hasDoor(int direction) { for (int dir : doorsDirections) if (dir == direction) return true; return false; } public int getSpriteId() { return spriteId; } public boolean isOpen() { return open; } } public static final int[][] PUZZLE_DOOR_ORDER = { { SOUTH_DOOR, WEST_DOOR }, { SOUTH_DOOR, EAST_DOOR }, { SOUTH_DOOR, NORTH_DOOR }, { SOUTH_DOOR, NORTH_DOOR, WEST_DOOR }, { SOUTH_DOOR, EAST_DOOR, WEST_DOOR }, { SOUTH_DOOR, EAST_DOOR, NORTH_DOOR }, { SOUTH_DOOR, EAST_DOOR, NORTH_DOOR, WEST_DOOR }, }; public static final HandledRoom[] PUZZLE_ROOMS; // TODO: Some dungeoneering puzzle rooms are disabled public enum Puzzle { CRYSTAL_PUZZLE(12, CrystalPuzzleRoom.class, all(spot(13, 5)), false), TOXIN_MAZE(20, ToxinMaze.class, all(spot(7, 8)), false), FLIP_TILES(24, FlipTilesRoom.class, list(spot(1, 3), spot(1, 12), spot(1, 3), spot(14, 11), spot(14, 11), spot(1, 9), spot(1, 3))), FREMENNIK_CAMP(26, FremennikCampRoom.class, list(spot(6, 14), spot(10, 2), spot(14, 6), spot(5, 12), spot(13, 10), spot(3, 5), spot(13, 10))), FISHING_FERRET(32, FishingFerretRoom.class, all(spot(2, 1)), false), LEVERS(38, LeverRoom.class, list(spot(1, 5), spot(10, 14), spot(1, 5), spot(10, 14), spot(1, 5), spot(10, 14), spot(1, 5)), false), SLIDING_STATUES(42, SlidingStatuesRoom.class, all(spot(1, 3)), false), //FLOWER_ROOTS(50, FlowerRootsRoom.class, list(spot(9, 10), spot(6, 7), spot(13, 12), spot(12, 12), spot(3, 6), spot(2, 11), spot(3, 11)), false), POLTERGEIST(52, PoltergeistRoom.class, list(spot(1, 10), spot(2, 10), spot(3, 5), spot(2, 4), spot(13, 4), spot(2, 12), spot(3, 4)), false), UNHAPPY_GHOST(60, UnhappyGhostRoom.class, list(spot(2, 3), spot(3, 5), spot(3, 5), spot(2, 2), spot(3, 3), spot(2, 2), spot(4, 3)), false), RETURN_THE_FLOW(66, ReturnTheFlowRoom.class, list(spot(3, 3), spot(2, 12), spot(2, 2), spot(4, 2), spot(3, 3), spot(2, 2), spot(2, 2))), //COLOURED_RECESS(68, ColouredRecessRoom.class, list(spot(2, 3), spot(2, 3), spot(2, 3), spot(2, 3), spot(2, 3), spot(2, 5), spot(2, 3)), false), //SLIDING_TILES(76, SlidingTilesRoom.class, list(spot(1, 2), spot(13, 7), spot(1, 2), spot(13, 7), spot(1, 2), spot(13, 7), spot(1, 2))) ; private final int chunkX; private final Class clazz; private final boolean allowResources; private final int[][] keys; Puzzle(int chunkX, Class clazz) { this(chunkX, clazz, null); } Puzzle(int chunkX, Class clazz, int[][] key) { this(chunkX, clazz, key, true); } Puzzle(int chunkX, Class clazz, int[][] keys, boolean allowResources) { this.chunkX = chunkX; this.clazz = clazz; this.keys = keys; this.allowResources = allowResources; } public int getChunkX() { return chunkX; } public VisibleRoom newInstance() { try { return clazz.getConstructor().newInstance(); } catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException e) { e.printStackTrace(); System.err.println(""error creating puzzle instance""); return null; } } public boolean isAvailableOnFloorType(int floorType) { //I think constructor args are uglier because some are exclude and some are include if (this == POLTERGEIST && floorType == 0) return false; /*if (this == FLOWER_ROOTS && floorType == 0) { return false; }*/ //if(this == ICY_PRESSURE_PAD && floorType != 0) { //return false; //} return true; } public boolean allowResources() { return allowResources; } public int[] getKeySpot(int i) { if (keys == null || i >= keys.length) return null; return keys[i]; } private static int[][] all(int[] spot) { return new int[][] { spot, spot, spot, spot, spot, spot, spot }; } private static int[][] list(int[]... list) { if (list.length != 7) { System.err.println(""Error in key list "" + Arrays.toString(list)); return null; } return list; } } private static int[] spot(int x, int y) { return new int[] { x, y }; } static { int ptr = 0; PUZZLE_ROOMS = new HandledRoom[Puzzle.values().length * PUZZLE_DOOR_ORDER.length]; for (Puzzle puzzle : Puzzle.values()) // if (Settings.getConfig().isDebug()) // puzzle = Puzzle.TOXIN_MAZE; //FORCE PUZZLE ROOM for (int i = 0; i < PUZZLE_DOOR_ORDER.length; i++) PUZZLE_ROOMS[ptr++] = new HandledPuzzleRoom(i, puzzle); //8 Monolith spot //(4,4),(4,4),(4,4),(4,4),(4,4),(4,4),(4,5) //10 Collapsing room (7, 1) //14 Ghosts (3, 10) in small one, (3, 3) //(1,2),(3,10),(1,3),(1,3),(1,3),(1,3),(3,3) //16 Three statue weapon (Combat triangle statues) (8, 7) + chisel too //18 Follow the leader (Emotes) (7, 6) //22 Frozen: Icy Pressure Pad, // (8, 1), (8, 1), (8, 1), (1, 8), (14, 8), (14, 8), (8, 14) // Aba: Seeker Sentinel, //where no door else entrance? (8, 2) south (13, 7) east (7, 13) // (), (), (), (), (), (), () // Furnished: Sleeping guards, // (8, 10),all // Occcult: Coloured bookcases, // (8, 11), (14, 3), (4, 3), (10, 11), (5, 1), (7, 2), (3, 3) // Warped: Portal maze // (13, 6), all //28 Ten statue weapon (was 2-3 pairs on 1:1 on rs) (7, 8) on chisel //30 Lodestone power //east of crystal? (10, 1) (14, 4) //34 Suspicious grooves (11, 11) usually or opposite side //(5, 12 or 10,12 //36 Agility Maze (4, 2) start always //40 Barrel puzzle (6, 11) barrel part at (7, 11) or (9, 2) //42 Sliding statues (1, 3) //1,3 or 3,1 //44 Hunter ferret (8, 8) key ferret on (7, 8) //ferrets: (8, 7), (8, 7), (7, 7), (8, 7), (7, 8), (8, 7), (8, 7) //keys: (7, 7), (8, 7), (7, 7), (7, 7), (7, 8), (7, 7), (8, 6) //46 Magical Construct (8, 6) //(), (), (), (), (), (), () //48 Enigmatic Hoardstalker (Riddles) (NOT ON FROZEN) (7, 8) //(), (), (), (), (), (), () //54 Keystone bridge (NOT ON FROZEN) //(9, 7), ??, (10,2) crit or (5, 13) bonus, (6, 2), (6, 2), (6, 2), (9, 2) //56 Grapple tightrope //(6, 2), (2, 2), (5, 1), (7, 2), (6, 1), (13, 1), (6, 1) //58 Pondskaters //(2, 2) or (13, 10), (<), (14, 8), (1, 6), (13, 7), (2,2 or 13,7), (13, 2) //60 Unhappy ghost //(2, 3), (3, 5), (3, 5), (2, 2), (3, 3), (2, 2), (4, 3) //62 Broken plank bridge //(6, 1), (6, 1), (6, 1), (6, 1), (7, 2), (6, 1), (6, 1) //64 Statue bridge //(13, 2), (9, 2), (4, 1), (6, 1), (9, 2), (8, 2), (9, 1) //68 Coloured recess //(2, 3), (2, 3), (2, 3), (2, 3), (2, 3), (2, 5), (2, 3) //70 Winch bridge (6, 1), (1, 3), (9, 1), (9, 2), (8, 2), (6, 1), (8, 2) //72 Mercenary leader (combat) (12, 13), (3, 11), (2, 13), (4, 4), (4 , 2), (3, 4), (2, 3) //74 Ramokee familiars (combat) (4, 2), (3, 12), (2, 3), (2, 3), (2, 12), (3, 12), (5, 2) //78 Coloured ferrets (1, 3), (14, 4), (2, 13), (2, 2), (3, 5), (2, 2), (1, 6) } public static final BossRoom[][] BOSS_ROOMS = { // FROZEN_FLOORS { // To'Kash The Blood Chiller new BossRoom((dungeon, reference) -> dungeon.spawnNPC(reference, 10024, 5, 10, false, DungeonConstants.BOSS_NPC), 820, 9, 26, 626), // Plane-freezer Lakhrahnaz new BossRoom((dungeon, reference) -> dungeon.spawnNPC(reference, 9929, 7, 11, false, DungeonConstants.BOSS_NPC), 819, 6, 26, 624), // Luminscent Icefiend new BossRoom((dungeon, reference) -> dungeon.spawnNPC(reference, 9912, 7, 11, false, DungeonConstants.BOSS_NPC), 818, 3, 26, 626), // Icy Bones new BossRoom((dungeon, reference) -> dungeon.spawnNPC(reference, 10040, 7, 11, false, DungeonConstants.BOSS_NPC), 815, 1, 24, 626), // Gluttonous behemoth new BossRoom((dungeon, reference) -> { dungeon.spawnNPC(reference, 9948, 5, 10, false, DungeonConstants.BOSS_NPC); dungeon.spawnObject(reference, 49283, ObjectType.SCENERY_INTERACT, 3, 0, 11); if (dungeon.getParty().getTeam().size() >= 2) dungeon.spawnObject(reference, 49283, ObjectType.SCENERY_INTERACT, 0, 11, 11); }, 817, 1, 28, 624), // Astea Frostweb new BossRoom((dungeon, reference) -> dungeon.spawnNPC(reference, 9965, 8, 12, false, DungeonConstants.BOSS_NPC), 816, 1, 30, 624), }, // ABANDONED BOSSES { //Bal'Lak The Pummeler new BossRoom((dungeon, reference) -> dungeon.spawnNPC(reference, 10128, 6, 8, false, DungeonConstants.BOSS_NPC), 786, 33, 26, 642), //Shadow-forger Ihlakhizan // new BossRoom((dungeon, reference) -> dungeon.spawnNPC(reference, 10143, 6, 6, false, BOSS_NPC), 783, 30, 28, 640), //Unholy cursebearer new BossRoom((dungeon, reference) -> dungeon.spawnNPC(reference, 10111, 6, 8, false, DungeonConstants.BOSS_NPC), 784, 15, 26, 640), //Bulwark beast new BossRoom((dungeon, reference) -> dungeon.spawnNPC(reference, 10073, 5, 10, false, DungeonConstants.BOSS_NPC), 785, 12, 24, 642), //Hobgoblin Geomancer new BossRoom((dungeon, reference) -> dungeon.spawnNPC(reference, 10059, 6, 8, false, DungeonConstants.BOSS_NPC), 787, 12, 24, 640), //Divine Skinweaver new BossRoom((dungeon, reference) -> dungeon.spawnNPC(reference, 10058, 5, 2, false, DungeonConstants.BOSS_NPC), 782, 12, 30, 640) }, // FURNISHED BOSSES { //Night-gazer Khighorahk new BossRoom((dungeon, reference) -> dungeon.spawnNPC(reference, 9725, 6, 6, false, DungeonConstants.BOSS_NPC), 759, 26, 24, 656), //Sagittare new BossRoom((dungeon, reference) -> dungeon.spawnNPC(reference, 9753, 6, 6, false, DungeonConstants.BOSS_NPC), 768, 23, 24, 658), //Lexicus Runewright new BossRoom((dungeon, reference) -> dungeon.spawnNPC(reference, 9842, 8, 7, false, DungeonConstants.BOSS_NPC), 738, 20, 26, 658), //Lakk The Rift Splitter new BossRoom((dungeon, reference) -> dungeon.spawnNPC(reference, 9898, 6, 6, false, DungeonConstants.BOSS_NPC), 767, 18, 28, 656), //Stomp new BossRoom((dungeon, reference) -> dungeon.spawnNPC(reference, 9782, 6, 9, false, DungeonConstants.BOSS_NPC), 743, 18, 30, 656), //Rammernaut new BossRoom((dungeon, reference) -> dungeon.spawnNPC(reference, 9767, 7, 7, false, DungeonConstants.BOSS_NPC), 746, 18, 26, 656) }, // { //Yk'lagoor the thunderous new BossRoom((dungeon, reference) -> dungeon.spawnNPC(reference, 11872, 5, 5, false, DungeonConstants.BOSS_NPC), 890, 45, 26, 672), //Flesh-spoiler Haasghenahk new BossRoom((dungeon, reference) -> dungeon.spawnNPC(reference, 11925, 8, 7, false, DungeonConstants.BOSS_NPC), 892, 42, 24, 674), //Necro Lord new BossRoom((dungeon, reference) -> dungeon.spawnNPC(reference, 11737, 7, 10, false, DungeonConstants.BOSS_NPC), 876, 39, 30, 672), new BossRoom((dungeon, reference) -> dungeon.spawnNPC(reference, 11708, 5, 5, false, DungeonConstants.BOSS_NPC), 891, 36, 28, 672), //Runebound Behemoth new BossRoom((dungeon, reference) -> dungeon.spawnNPC(reference, 11812, 6, 8, false, DungeonConstants.BOSS_NPC), 877, 36, 26, 674), //Skeletal Trio new BossRoom((dungeon, reference) -> { dungeon.spawnNPC(reference, 11940, 5, 6, false, DungeonConstants.BOSS_NPC); dungeon.spawnNPC(reference, 12044, 7, 9, false, DungeonConstants.BOSS_NPC); dungeon.spawnNPC(reference, 11999, 7, 6, false, DungeonConstants.BOSS_NPC); }, 865, 36, 24, 672), }, // //201 5513 0 for blink { // Warmonger // new BossRoom((dungeon, reference) -> dungeon.spawnNPC(reference, 12752, 6, 9, false, DungeonConstants.BOSS_NPC), 924, 57, 24, 690), // World Gorger new BossRoom((dungeon, reference) -> dungeon.spawnNPC(reference, 12478, 5, 6, false, DungeonConstants.BOSS_NPC), 937, 54, 26, 690), // Hope Devourer new BossRoom((dungeon, reference) -> dungeon.spawnNPC(reference, 12886, 8, 6, false, DungeonConstants.BOSS_NPC), 916, 51, 30, 688), // Blink // new BossRoom((dungeon, reference) -> dungeon.spawnNPC(reference, 12865, 5, 6, false, BOSS_NPC), 940, 48, 24, 688), // Dreadnaut new BossRoom((dungeon, reference) -> dungeon.spawnNPC(reference, 12848, 7, 5, false, DungeonConstants.BOSS_NPC), 913, 48, 28, 688), // Warped Gulega new BossRoom((dungeon, reference) -> dungeon.spawnNPC(reference, 12737, 8, 8, false, DungeonConstants.BOSS_NPC), 922, 48, 26, 688), } }; public static boolean isDungeonSong(int musicId) { for(int dung_MusicId : START_ROOM_MUSICS) if(musicId == dung_MusicId) return true; for(int[] floor : DANGEROUS_MUSICS) for(int dung_MusicId : floor) if(musicId == dung_MusicId) return true; for(int[] floor : SAFE_MUSICS) for(int dung_MusicId : floor) if(musicId == dung_MusicId) return true; for(int dung_MusicId : OTHER_DUNGEONEERING_MUSIC) if(musicId == dung_MusicId) return true; return false; } public static final int[][] WALL_BASE_X_Y = { { 14, 1, 0, 14 }, { 1, 1, 14, 0 }, { 1, 1, 0, 14 }, { 1, 14, 14, 0 } }; public static final int SET_RESOURCES_MAX_TRY = 300; public static final int FISH_SPOT_OBJECT_ID = 49922, FISH_SPOT_NPC_ID = 2859; public static final long[] FARMING_CYCLES = { 0, 30000, 60000, Integer.MAX_VALUE }; public static final int FARMING_PATCH_BEGINING = 50040, FARMING_PATCH_END = 50189; public static final int EMPTY_FARMING_PATCH = 50038; public static final int ESSENCE = 17776; public static final int NORMAL_NPC = 0, GUARDIAN_NPC = 1, FISH_SPOT_NPC = 2, BOSS_NPC = 3, FORGOTTEN_WARRIOR = 4, SLAYER_NPC = 5, HUNTER_NPC = 6, PUZZLE_NPC = 7; public static int[] GROUP_GATESTONE_RUNES = { 17792, 3 }; public static final int[][] HOARDSTALKER_ITEMS = { { 17630, 17424, 17682, 17448, 17797 }, { 17632, 17426, 17684, 17450, 17799 }, { 17634, 17428, 17686, 17452, 17801 }, { 17636, 17430, 17688, 17454, 17803 }, { 17638, 17432, 17700, 17456, 17805 }, { 17640, 17434, 17702, 17458, 17807 }, { 17642, 17436, 17704, 17460, 17809 }, { 17644, 17438, 17706, 17462, 17811 }, { 17646, 17440, 17708, 17464, 17813 }, { 17648, 17442, 17710, 17466, 17815 }, }; public static final int[] SLAYER_LEVELS = { 5, 10, 17, 30, 41, 52, 63, 71, 80, 90, 99 }; }" "package com.rs.game.content.skills.dungeoneering; public class DungeonController extends Controller { private final transient DungeonManager dungeon; private Tile gatestone; @SuppressWarnings(""unused"") private int deaths; private int voteStage; private boolean killedBossWithLessThan10HP; private int damageReceived; private int meleeDamage, rangeDamage, mageDamage; private int healedDamage; private boolean showBar; public DungeonController(DungeonManager manager) { dungeon = manager; } @Override public void start() { showDeaths(); refreshDeaths(); player.setForceMultiArea(true); } @Override public Genre getGenre() { return Music.getGenreByName(""Ambient Dungeoneering""); } @Override public boolean playAmbientOnControllerRegionEnter() { return false; } /** * No unlocks, we can play and unlock room music in the Room class in a later commit... */ @Override public boolean playAmbientStrictlyBackgroundMusic() { return true; } public void showDeaths() { player.getInterfaceManager().sendOverlay(945); } public void showBar() { player.getPackets().setIFHidden(945, 2, !showBar); } private void hideBar() { showBar(false, null); } public void showBar(boolean show, String name) { if (showBar == show) return; showBar = show; showBar(); if (show) player.getPackets().sendVarcString(315, name); } public void sendBarPercentage(int percentage) { player.getPackets().sendVarc(1233, percentage * 2); } public void reset() { //deaths = 0; voteStage = 0; gatestone = null; killedBossWithLessThan10HP = false; damageReceived = 0; meleeDamage = 0; rangeDamage = 0; mageDamage = 0; healedDamage = 0; refreshDeaths(); showDeaths(); hideBar(); player.getAppearance().setBAS(-1); } @Override public boolean canMove(Direction dir) { VisibleRoom vr = dungeon.getVisibleRoom(dungeon.getCurrentRoomReference(player.getTile())); Tile to = Tile.of(player.getX() + dir.dx, player.getY() + dir.dy, 0); if(vr != null && !vr.canMove(player, to)) return false; Room room = dungeon.getRoom(dungeon.getCurrentRoomReference(player.getTile())); if (room != null) if (room.getRoom() == DungeonUtils.getBossRoomWithChunk(DungeonConstants.FROZEN_FLOORS, 26, 624)) { if (!player.isCantWalk() && World.getObjectWithType(Tile.of(player.getX() + dir.dx, player.getY() + dir.dy, 0), ObjectType.GROUND_DECORATION) == null) { player.getAppearance().setBAS(1429); player.setRun(true); player.setCantWalk(true); } if (player.isCantWalk()) { Tile nextStep = Tile.of(player.getX() + dir.dx * 2, player.getY() + dir.dy * 2, 0); NPC boss = getNPC(player, ""Plane-freezer Lakhrahnaz""); boolean collides = boss != null && WorldUtil.collides(nextStep.getX(), nextStep.getY(), player.getSize(), boss.getX(), boss.getY(), boss.getSize()); player.resetWalkSteps(); GameObject object = World.getObjectWithType(Tile.of(nextStep.getX(), nextStep.getY(), 0), ObjectType.GROUND_DECORATION); if (collides || ((object != null && (object.getId() == 49331 || object.getId() == 49333)) || !player.addWalkSteps(nextStep.getX(), nextStep.getY(), 1))) { player.setCantWalk(false); player.getAppearance().setBAS(-1); } } } return !dungeon.isAtRewardsScreen(); } public int getHealedDamage() { return healedDamage; } @Override public void processIncomingHit(Hit hit) { if (player.getDungManager().getActivePerk() == KinshipPerk.TANK && player.getEquipment().getShieldId() != -1 && ItemDefinitions.getDefs(player.getEquipment().getShieldId()).name.toLowerCase().contains(""shield"")) { double perc = 0.94 - (player.getDungManager().getKinshipTier(KinshipPerk.TANK) * 0.01); hit.setDamage((int) (hit.getDamage() * perc)); } damageReceived += hit.getDamage(); } @Override public void processOutgoingHit(Hit hit, Entity target) { if (hit.getDamage() <= 0) return; if (hit.getLook() == HitLook.MELEE_DAMAGE) meleeDamage += hit.getDamage(); else if (hit.getLook() == HitLook.RANGE_DAMAGE) { if (player.getDungManager().getActivePerk() == KinshipPerk.KEEN_EYE && player.getCombatDefinitions().getAttackStyle().attackType == AttackType.ACCURATE) { int procChance = (int) (40 + (player.getDungManager().getKinshipTier(KinshipPerk.KEEN_EYE) * 6.5)); if (Utils.random(100) < procChance) if (target instanceof NPC npc) npc.lowerDefense(1, 0.0); } rangeDamage += hit.getDamage(); } else if (hit.getLook() == HitLook.MAGIC_DAMAGE) { mageDamage += hit.getDamage(); if (player.getDungManager().getActivePerk() == KinshipPerk.BLAZER && hit.getData(""combatSpell"") != null) { if ((hit.getData(""blazerBleed"") != null) || (hit.getDamage() < 10)) return; int procChance = 5 * player.getDungManager().getKinshipTier(KinshipPerk.BLAZER); int damage = hit.getDamage() / 10; if (Utils.random(100) < procChance) for (int i = 1;i <= 5;i++) target.getTasks().schedule(2*i, () -> target.applyHit(new Hit(player, damage, HitLook.MAGIC_DAMAGE).setData(""blazerBleed"", true))); } } } public int getDamageReceived() { return damageReceived; } public int getMeleeDamage() { return meleeDamage; } public int getRangeDamage() { return rangeDamage; } public int getMageDamage() { return mageDamage; } public int getDamage() { return meleeDamage + rangeDamage + mageDamage; } @Override public void sendInterfaces() { if (dungeon != null && dungeon.isAtRewardsScreen()) return; showDeaths(); } @Override public void processNPCDeath(NPC npc) { if (npc instanceof DungeonBoss) if (player.getHitpoints() <= 10) killedBossWithLessThan10HP = true; } @Override public boolean sendDeath() { player.lock(8); player.stopAll(); player.jingle(418); if (player.getInventory().containsItem(DungeonConstants.GROUP_GATESTONE, 1)) { Tile tile = Tile.of(player.getTile()); dungeon.setGroupGatestone(Tile.of(player.getTile())); World.addGroundItem(new Item(DungeonConstants.GROUP_GATESTONE), tile); player.getInventory().deleteItem(DungeonConstants.GROUP_GATESTONE, 1); player.sendMessage(""Your group gatestone drops to the floor as you die.""); } if (player.getInventory().containsItem(DungeonConstants.GATESTONE, 1)) { Tile tile = Tile.of(player.getTile()); setGatestone(Tile.of(player.getTile())); World.addGroundItem(new Item(DungeonConstants.GATESTONE), tile); player.getInventory().deleteItem(DungeonConstants.GATESTONE, 1); player.sendMessage(""Your gatestone drops to the floor as you die.""); } WorldTasks.scheduleLooping(new Task() { int loop; @Override public void run() { if (loop == 0) player.setNextAnimation(new Animation(836)); else if (loop == 1) { player.sendMessage(""Oh dear, you are dead!""); if (dungeon != null) for (Player p2 : dungeon.getParty().getTeam()) { if (p2 == player) continue; p2.sendMessage(player.getDisplayName() + "" has died.""); } } else if (loop == 3) { player.resetReceivedHits(); if (dungeon != null && dungeon.getParty().getTeam().contains(player)) { if (dungeon.isAtBossRoom(player.getTile(), 26, 672, true)) { NPC npc = getNPC(player, ""Yk'Lagor the Thunderous""); if (npc != null) npc.setNextForceTalk(new ForceTalk(""Another kill for the Thunderous!"")); //npc.playSoundEffect(1928); } Tile startRoom = dungeon.getHomeTile(); player.tele(startRoom); dungeon.playMusic(player, dungeon.getCurrentRoomReference(startRoom)); increaseDeaths(); player.reset(); } player.setNextAnimation(new Animation(-1)); player.getAppearance().setBAS(-1); hideBar(); } else if (loop == 4) stop(); loop++; } }, 0, 1); return false; } private void refreshDeaths() { player.getVars().setVarBit(7554, getDeaths()); } private void increaseDeaths() { Integer deaths = dungeon.getPartyDeaths().get(player.getUsername()); if (deaths == null) deaths = 0; else if (deaths == 15) return; dungeon.getPartyDeaths().put(player.getUsername(), deaths + 1); refreshDeaths(); } public int getDeaths() { if (dungeon == null) return 0; Integer deaths = dungeon.getPartyDeaths().get(player.getUsername()); return deaths == null ? 0 : deaths;//deaths; } @Override public boolean processTeleport(Teleport tele) { if (tele.type() == TeleType.ITEM) return false; if (tele.type() == TeleType.OBJECT) return true; if (dungeon == null || !player.getCombatDefinitions().isDungSpellbook() || !dungeon.hasStarted() || dungeon.isAtRewardsScreen()) return false; return !(Utils.getDistance(tele.destination(), dungeon.getHomeTile()) > 500); } @Override public boolean canTakeItem(GroundItem item) { for (KeyDoors key : DungeonConstants.KeyDoors.values()) if (item.getId() == key.getKeyId()) { dungeon.setKey(key, true); World.removeGroundItem(player, item, false); return false; } if (item.getId() == DungeonConstants.GROUP_GATESTONE) { dungeon.setGroupGatestone(null); return true; } if (item.getId() == DungeonConstants.GATESTONE) { if (!item.isPrivate()) { World.removeGroundItem(player, item); return false; } if (item.getVisibleToId() != player.getUuid()) { player.sendMessage(""This isn't your gatestone!""); return false; } setGatestone(null); return true; } return true; } private void openSkillDoor(final SkillDoors s, final GameObject object, final Room room, final int floorType) { final int index = room.getDoorIndexByRotation(object.getRotation()); if (index == -1) return; final Door door = room.getDoor(index); if (door == null || door.getType() != DungeonConstants.SKILL_DOOR) return; if (door.getLevel() > (player.getSkills().getLevel(s.getSkillId()) + player.getInvisibleSkillBoost(s.getSkillId()))) { player.sendMessage(""You need a "" + Constants.SKILL_NAME[s.getSkillId()] + "" level of "" + door.getLevel() + "" to remove this "" + object.getDefinitions().getName().toLowerCase() + "".""); return; } int openAnim = -1; if (s.getSkillId() == Constants.FIREMAKING) { if (!player.getInventory().containsOneItem(DungeonConstants.TINDERBOX)) { player.sendMessage(""You need a tinderbox to do this.""); return; } } else if (s.getSkillId() == Constants.MINING) { DungPickaxe defs = DungPickaxe.getBest(player); if (defs == null) { player.sendMessage(""You do not have a pickaxe or do not have the required level to use the pickaxe.""); return; } openAnim = defs.getAnimation().getIds()[0]; } else if (s.getSkillId() == Constants.WOODCUTTING) { DungHatchet defs = DungHatchet.getHatchet(player); if (defs == null) { player.sendMessage(""You do not have a hatchet or do not have the required level to use the hatchet.""); return; } openAnim = defs.getEmoteId(); } final boolean fail = Utils.random(100) <= 10; player.lock(3); if (s.getOpenAnim() != -1) player.setNextAnimation(new Animation(openAnim != -1 ? openAnim : fail && s.getFailAnim() != -1 ? s.getFailAnim() : s.getOpenAnim())); if (s.getOpenGfx() != -1 || s.getFailGfx() != -1) player.setNextSpotAnim(new SpotAnim(fail ? s.getFailGfx() : s.getOpenGfx())); if (s.getOpenObjectAnim() != -1 && !fail) World.sendObjectAnimation(object, new Animation(s.getOpenObjectAnim())); WorldTasks.schedule(new Task() { @Override public void run() { if (s.getFailAnim() == -1) player.setNextAnimation(new Animation(-1)); if (!fail) { if (room.getDoor(index) == null) //means someone else opeenda t same time return; player.getSkills().addXp(s.getSkillId(), door.getLevel() * 5 + 10); room.setDoor(index, null); int openId = s.getOpenObject(floorType); if (openId == -1) World.removeObject(object); else dungeon.setDoor(dungeon.getCurrentRoomReference(object.getTile()), -1, openId, object.getRotation()); } else { player.sendMessage(s.getFailMessage()); player.applyHit(new Hit(player, door.getLevel() * 4, HitLook.TRUE_DAMAGE)); if (room.getDoor(index) == null) //means someone else opeenda t same time return; if (s.getFailObjectAnim() != -1) World.sendObjectAnimation(object, new Animation(s.getFailObjectAnim())); } } }, 2); } @Override public boolean processNPCClick1(final NPC npc) { if (dungeon == null || !dungeon.hasStarted() || dungeon.isAtRewardsScreen()) return false; VisibleRoom vRoom = dungeon.getVisibleRoom(dungeon.getCurrentRoomReference(player.getTile())); if (vRoom == null || !vRoom.processNPCClick1(player, npc)) return false; if (npc.getId() == DungeonConstants.FISH_SPOT_NPC_ID) { player.faceEntity(npc); player.getActionManager().setAction(new DungeoneeringFishing((DungeonFishSpot) npc)); return false; } if (npc.getId() == 10023) { FrozenAdventurer adventurer = (FrozenAdventurer) npc; adventurer.getFrozenPlayer().getAppearance().transformIntoNPC(-1); return false; } if (npc.getId() == DungeonConstants.SMUGGLER) { npc.faceEntity(player); player.startConversation(new Dialogue() .addNPC(DungeonConstants.SMUGGLER, HeadE.CALM_TALK, ""Hail, "" + player.getDisplayName() + "". Need something?"") .addOptions(ops -> { ops.add(""What can you tell me about this place?"") .addPlayer(HeadE.CONFUSED, ""What can you tell me about this place?"") .addNPC(DungeonConstants.SMUGGLER, HeadE.CALM_TALK, ""You know all that I can teach you already, friend, having conquered many floors yourself.""); ops.add(""Who are you?"") .addPlayer(HeadE.CONFUSED, ""Who are you?"") .addNPC(DungeonConstants.SMUGGLER, HeadE.SECRETIVE, ""A friend."") .addPlayer(HeadE.CONFUSED, ""Okay, what are you doing here, friend?"") .addNPC(DungeonConstants.SMUGGLER, HeadE.SECRETIVE, ""I'm here to help out."") .addPlayer(HeadE.CONFUSED, ""With what?"") .addNPC(DungeonConstants.SMUGGLER, HeadE.SECRETIVE, ""Well, let's say you find yourself in need of an adventuring kit, and you've a heavy pile of rusty coins weighing you down. I can help you with both those problems. Savvy?"") .addPlayer(HeadE.AMAZED, ""Ah, so your a trader?"") .addNPC(DungeonConstants.SMUGGLER, HeadE.ANGRY, ""Keep it down, you fool!"") .addNPC(DungeonConstants.SMUGGLER, HeadE.SECRETIVE, ""Yes, I'm a trader. But I'm not supposed to be trading here."") .addNPC(DungeonConstants.SMUGGLER, HeadE.SECRETIVE, ""If you want my goods, you'll learn not to talk about me."") .addPlayer(HeadE.CALM_TALK, ""Right, got you."") .addPlayer(HeadE.CONFUSED, ""Is there anything else you can do for me?"") .addNPC(DungeonConstants.SMUGGLER, HeadE.CALM_TALK, ""Well, there's the job I'm supposed to be doing down here."") .addPlayer(HeadE.CONFUSED, ""Which is?"") .addNPC(DungeonConstants.SMUGGLER, HeadE.CALM_TALK, ""Say you chance upon an object that you know little about. Show it to me, and I'll tell you what it's used for."") .addPlayer(HeadE.CALM_TALK, ""That's good to know."") .addNPC(DungeonConstants.SMUGGLER, HeadE.CALM_TALK, ""I can also offer you knowledge about the behaviour of powerful opponents you might meet in the area. I've spent a long time down here, observing them."") .addPlayer(HeadE.CALM_TALK, ""I'll be sure to come back if I find a particularly strong opponent, then."") .addNPC(DungeonConstants.SMUGGLER, HeadE.CALM_TALK, ""You'd be wise to "" + player.getDisplayName() + ""."") .addPlayer(HeadE.CONFUSED, ""How do you know my name?"") .addNPC(DungeonConstants.SMUGGLER, HeadE.CALM_TALK, ""Nothing gets in or out of Daemonhiem without me knowing about it."") .addPlayer(HeadE.CALM_TALK, ""Fair enough.""); ops.add(""Do I have any rewards to claim?"") .addPlayer(HeadE.CONFUSED, ""Do I have any rewards to claim?"") .addNPC(DungeonConstants.SMUGGLER, HeadE.CALM_TALK, ""I have no rewards for you at the moment.""); ops.add(""I'm here to trade."") .addPlayer(HeadE.CALM_TALK, ""I'm here to trade."") .addNext(() -> DungeonResourceShop.openResourceShop(player, dungeon.getParty().getComplexity())); })); return false; } else if (npc.getId() >= 11076 && npc.getId() <= 11085) { DungeoneeringTraps.removeTrap(player, (MastyxTrap) npc, dungeon); return false; } else if (npc.getId() >= 11096 && npc.getId() <= 11105) { DungeoneeringTraps.skinMastyx(player, npc); return false; } else if (npc instanceof DivineSkinweaver skin) { skin.talkTo(player); return false; } return true; } @Override public boolean processNPCClick2(final NPC npc) { if (dungeon == null || !dungeon.hasStarted() || dungeon.isAtRewardsScreen()) return false; VisibleRoom room = dungeon.getVisibleRoom(dungeon.getCurrentRoomReference(player.getTile())); if ((room == null) || !room.processNPCClick2(player, npc)) return false; if (npc instanceof Familiar familiar) { if (player.getFamiliar() != familiar) { player.sendMessage(""That isn't your familiar.""); return false; } if (familiar.getDefinitions().hasOption(""Take"")) { familiar.takeInventory(); return false; } return true; } if (npc.getDefinitions().hasOption(""Mark"")) { if (!dungeon.getParty().isLeader(player)) { player.sendMessage(""Only your party's leader can mark a target!""); return false; } dungeon.setMark(npc, !player.getHintIconsManager().hasHintIcon(6)); //6th slot return false; } if (npc.getId() == DungeonConstants.SMUGGLER) { DungeonResourceShop.openResourceShop(player, dungeon.getParty().getComplexity()); return false; } return true; } @Override public boolean processNPCClick3(NPC npc) { if (dungeon == null || !dungeon.hasStarted() || dungeon.isAtRewardsScreen()) return false; VisibleRoom room = dungeon.getVisibleRoom(dungeon.getCurrentRoomReference(player.getTile())); return (room != null) && room.processNPCClick3(player, npc); } public static NPC getNPC(Entity entity, int id) { for (NPC npc : World.getNPCsInChunkRange(entity.getChunkId(), 4)) { if (npc.getId() == id) return npc; } return null; } public static NPC getNPC(Entity entity, String name) { for (NPC npc : World.getNPCsInChunkRange(entity.getChunkId(), 4)) { if (npc.getName().equals(name)) return npc; } return null; } @Override public boolean processObjectClick1(final GameObject object) { if (dungeon == null || !dungeon.hasStarted() || dungeon.isAtRewardsScreen()) return false; Room room = dungeon.getRoom(dungeon.getCurrentRoomReference(player.getTile())); VisibleRoom vr = dungeon.getVisibleRoom(dungeon.getCurrentRoomReference(player.getTile())); if (vr == null || !vr.processObjectClick1(player, object)) return false; int floorType = DungeonUtils.getFloorType(dungeon.getParty().getFloor()); for (SkillDoors s : SkillDoors.values()) if (s.getClosedObject(floorType) == object.getId()) { openSkillDoor(s, object, room, floorType); return false; } if (object.getId() >= 54439 && object.getId() <= 54456 && object.getDefinitions().containsOption(0, ""Cleanse"")) { @SuppressWarnings(""deprecation"") NPC boss = dungeon.getTemporaryBoss();//getNPC(player, 11708); if (!(boss instanceof Gravecreeper)) return false; return ((Gravecreeper) boss).cleanseTomb(player, object); } if (object.getId() == 49265) { NPC boss = getNPC(player, ""Night-gazer Khighorahk""); if (boss == null) { player.sendMessage(""You don't need to light anymore.""); return false; } ((NightGazerKhighorahk) boss).lightPillar(player, object); return false; } if (object.getId() >= 49274 && object.getId() <= 49279) { NPC boss = getNPC(player, ""Stomp""); if (boss != null) ((Stomp) boss).chargeLodeStone(player, (object.getId() & 0x1)); return false; } if (object.getId() == 49268) { DungPickaxe defs = DungPickaxe.getBest(player); if (defs == null) { player.sendMessage(""You do not have a pickaxe or do not have the required level to use the pickaxe.""); return false; } player.setNextAnimation(defs.getAnimation()); player.lock(4); WorldTasks.schedule(new Task() { @Override public void run() { player.setNextAnimation(new Animation(-1)); World.removeObject(object); } }, 3); return false; } else if (object.getId() >= 49286 && object.getId() <= 49288) { NPC boss = getNPC(player, 10058); if (boss != null) ((DivineSkinweaver) boss).blockHole(player, object); return false; } else if (object.getId() == 49297) { int value = player.getTempAttribs().getI(""UNHOLY_CURSEBEARER_ROT""); if (value >= 6) { NPC boss = getNPC(player, ""Unholy cursebearer""); if (boss != null) { player.sendMessage(""You restore your combat stats, and the skeletal archmage is healed in the process. The font lessens the effect of the rot within your body.""); player.getTempAttribs().setI(""UNHOLY_CURSEBEARER_ROT"", 1); player.getSkills().restoreSkills(); boss.heal(boss.getMaxHitpoints() / 10); } } else player.sendMessage(""You can't restore your stats yet.""); return false; } else if (object.getId() >= KeyDoors.getLowestObjectId() && object.getId() <= KeyDoors.getMaxObjectId()) { int index = room.getDoorIndexByRotation(object.getRotation()); if (index == -1) return false; Door door = room.getDoor(index); if (door == null || door.getType() != DungeonConstants.KEY_DOOR) return false; KeyDoors key = KeyDoors.values()[door.getId()]; if (!Settings.getConfig().isDebug() && !dungeon.hasKey(key) && !player.getInventory().containsItem(key.getKeyId(), 1)) { player.sendMessage(""You don't have the correct key.""); return false; } player.getInventory().deleteItem(key.getKeyId(), 1); player.lock(1); player.sendMessage(""You unlock the door.""); player.setNextAnimation(new Animation(13798));// unlock key object.animate(13594); dungeon.setKey(key, false); room.setDoor(index, null); World.removeObject(object); return false; } else if (object.getId() == DungeonConstants.DUNGEON_DOORS[floorType] || object.getId() == DungeonConstants.DUNGEON_GUARDIAN_DOORS[floorType] || object.getId() == DungeonConstants.DUNGEON_BOSS_DOORS[floorType] || DungeonUtils.isOpenSkillDoor(object.getId(), floorType) || (object.getId() >= KeyDoors.getLowestDoorId(floorType) && object.getId() <= KeyDoors.getMaxDoorId(floorType)) || (object.getDefinitions().getName().equals(""Door"") && object.getDefinitions().containsOption(0, ""Enter"")) // there's many ids for challenge doors ) { if (object.getId() == DungeonConstants.DUNGEON_BOSS_DOORS[floorType] && player.inCombat()) { player.sendMessage(""This door is too complex to unlock while in combat.""); return false; } Door door = room.getDoorByRotation(object.getRotation()); if (door == null) { openDoor(object); return false; } if (door.getType() == DungeonConstants.GUARDIAN_DOOR) player.sendMessage(""The door won't unlock until all of the guardians in the room have been slain.""); else if (door.getType() == DungeonConstants.KEY_DOOR || door.getType() == DungeonConstants.SKILL_DOOR) player.sendMessage(""The door is locked.""); else if (door.getType() == DungeonConstants.CHALLENGE_DOOR) player.sendMessage(((PuzzleRoom) vr).getLockMessage()); return false; } else if (object.getId() == DungeonConstants.THIEF_CHEST_LOCKED[floorType]) { room = dungeon.getRoom(dungeon.getCurrentRoomReference(player.getTile())); int type = room.getThiefChest(); if (type == -1) return false; int level = type == 0 ? 1 : (type * 10); if (level > player.getSkills().getLevel(Constants.THIEVING)) { player.sendMessage(""You need a "" + Constants.SKILL_NAME[Constants.THIEVING] + "" level of "" + level + "" to open this chest.""); return false; } room.setThiefChest(-1); player.setNextAnimation(new Animation(536)); player.lock(2); GameObject openedChest = new GameObject(object); openedChest.setId(DungeonConstants.THIEF_CHEST_OPEN[floorType]); World.spawnObject(openedChest); player.getInventory().addItemDrop(DungeonConstants.RUSTY_COINS, Utils.random((type + 1) * 10000) + 1); if (Utils.random(2) == 0) player.getInventory().addItemDrop(DungeonConstants.CHARMS[Utils.random(DungeonConstants.CHARMS.length)], Utils.random(5) + 1); if (Utils.random(3) == 0) player.getInventory().addItemDrop(DungeoneeringFarming.getHerbForLevel(level), Utils.random(1) + 1); if (Utils.random(4) == 0) player.getInventory().addItemDrop(DungeonUtils.getArrows(type + 1), Utils.random(100) + 1); if (Utils.random(5) == 0) player.getInventory().addItemDrop(DungeonUtils.getRandomWeapon(type + 1), 1); player.getSkills().addXp(Constants.THIEVING, DungeonConstants.THIEF_CHEST_XP[type]); return false; } else if (object.getId() == DungeonConstants.THIEF_CHEST_OPEN[floorType]) { player.sendMessage(""You already looted this chest.""); return false; } else if (DungeonUtils.isLadder(object.getId(), floorType)) { if (voteStage != 0) { player.sendMessage(""You have already voted to move on.""); return false; } player.startConversation(new DungeonClimbLadder(player, this)); return false; } else if (object.getId() == 53977 || object.getId() == 53978 || object.getId() == 53979) { int type = object.getId() == 53977 ? 0 : object.getId() == 53979 ? 1 : 2; NPC boss = getNPC(player, ""Runebound behemoth""); if (boss != null) ((RuneboundBehemoth) boss).activateArtifact(player, object, type); return false; } String name = object.getDefinitions().getName().toLowerCase(); switch (name) { case ""dungeon exit"": player.startConversation(new DungeonExit(player, this)); return false; case ""water trough"": player.startConversation(new CreateActionD(player, new Item[][] {{ new Item(17490) }}, new Item[][] {{ new Item(17492) }}, null, new int[] { 883 }, -1, 1)); return false; case ""salve nettles"": DungeoneeringFarming.initHarvest(player, Harvest.SALVE_NETTLES, object); return false; case ""wildercress"": DungeoneeringFarming.initHarvest(player, Harvest.WILDERCRESS, object); return false; case ""blightleaf"": DungeoneeringFarming.initHarvest(player, Harvest.BLIGHTLEAF, object); return false; case ""roseblood"": DungeoneeringFarming.initHarvest(player, Harvest.ROSEBLOOD, object); return false; case ""bryll"": DungeoneeringFarming.initHarvest(player, Harvest.BRYLL, object); return false; case ""duskweed"": DungeoneeringFarming.initHarvest(player, Harvest.DUSKWEED, object); return false; case ""soulbell"": DungeoneeringFarming.initHarvest(player, Harvest.SOULBELL, object); return false; case ""ectograss"": DungeoneeringFarming.initHarvest(player, Harvest.ECTOGRASS, object); return false; case ""runeleaf"": DungeoneeringFarming.initHarvest(player, Harvest.RUNELEAF, object); return false; case ""spiritbloom"": DungeoneeringFarming.initHarvest(player, Harvest.SPIRITBLOOM, object); return false; case ""tangle gum tree"": player.getActionManager().setAction(new DungeoneeringWoodcutting(object, DungTree.TANGLE_GUM_VINE)); return false; case ""seeping elm tree"": player.getActionManager().setAction(new DungeoneeringWoodcutting(object, DungTree.SEEPING_ELM_TREE)); return false; case ""blood spindle tree"": player.getActionManager().setAction(new DungeoneeringWoodcutting(object, DungTree.BLOOD_SPINDLE_TREE)); return false; case ""utuku tree"": player.getActionManager().setAction(new DungeoneeringWoodcutting(object, DungTree.UTUKU_TREE)); return false; case ""spinebeam tree"": player.getActionManager().setAction(new DungeoneeringWoodcutting(object, DungTree.SPINEBEAM_TREE)); return false; case ""bovistrangler tree"": player.getActionManager().setAction(new DungeoneeringWoodcutting(object, DungTree.BOVISTRANGLER_TREE)); return false; case ""thigat tree"": player.getActionManager().setAction(new DungeoneeringWoodcutting(object, DungTree.THIGAT_TREE)); return false; case ""corpsethorn tree"": player.getActionManager().setAction(new DungeoneeringWoodcutting(object, DungTree.CORPESTHORN_TREE)); return false; case ""entgallow tree"": player.getActionManager().setAction(new DungeoneeringWoodcutting(object, DungTree.ENTGALLOW_TREE)); return false; case ""grave creeper tree"": player.getActionManager().setAction(new DungeoneeringWoodcutting(object, DungTree.GRAVE_CREEPER_TREE)); return false; case ""novite ore"": player.getActionManager().setAction(new DungeoneeringMining(object, DungeoneeringRocks.NOVITE_ORE)); return false; case ""bathus ore"": player.getActionManager().setAction(new DungeoneeringMining(object, DungeoneeringRocks.BATHUS_ORE)); return false; case ""marmaros ore"": player.getActionManager().setAction(new DungeoneeringMining(object, DungeoneeringRocks.MARMAROS_ORE)); return false; case ""kratonite ore"": player.getActionManager().setAction(new DungeoneeringMining(object, DungeoneeringRocks.KRATONIUM_ORE)); return false; case ""fractite ore"": player.getActionManager().setAction(new DungeoneeringMining(object, DungeoneeringRocks.FRACTITE_ORE)); return false; case ""zephyrium ore"": player.getActionManager().setAction(new DungeoneeringMining(object, DungeoneeringRocks.ZEPHYRIUM_ORE)); return false; case ""argonite ore"": player.getActionManager().setAction(new DungeoneeringMining(object, DungeoneeringRocks.AGRONITE_ORE)); return false; case ""katagon ore"": player.getActionManager().setAction(new DungeoneeringMining(object, DungeoneeringRocks.KATAGON_ORE)); return false; case ""gorgonite ore"": player.getActionManager().setAction(new DungeoneeringMining(object, DungeoneeringRocks.GORGONITE_ORE)); return false; case ""promethium ore"": player.getActionManager().setAction(new DungeoneeringMining(object, DungeoneeringRocks.PROMETHIUM_ORE)); return false; case ""furnace"": DungeoneeringSmithing.openSmelting(player); return false; case ""anvil"": for (int i = 17668;i >= 17650;i -= 2) if (player.containsItem(i)) { DungeoneeringSmithing.openInterface(player, new Item(i)); break; } return false; case ""runecrafting altar"": player.startConversation(new DungeoneeringRCD(player, null)); return false; case ""spinning wheel"": ReqItem[] products = ReqItem.getProducts(Category.DUNG_SPINNING); if (products.length == 0) return false; player.startConversation(new CreationActionD(player, Category.DUNG_SPINNING, products, 883, 2)); return false; case ""summoning obelisk"": Summoning.openInfusionInterface(player, true); if (player.getSkills().getLevel(Constants.SUMMONING) < player.getSkills().getLevelForXp(Constants.SUMMONING)) { player.sendMessage(""You touch the obelisk"", true); player.setNextAnimation(new Animation(8502)); World.sendSpotAnim(object.getTile(), new SpotAnim(1308)); WorldTasks.schedule(2, () -> { player.getSkills().set(Constants.SUMMONING, player.getSkills().getLevelForXp(Constants.SUMMONING)); player.sendMessage(""...and recharge your summoning points."", true); }); } return false; case ""group gatestone portal"": portalGroupStoneTeleport(); return false; case ""sunken pillar"": Blink boss = (Blink) getNPC(player, ""Blink""); if (boss == null) { player.sendMessage(""The mechanism doesn't respond.""); return false; } if (boss.hasActivePillar()) { player.sendMessage(""The mechanism will not respond while the other pillar is raised.""); return false; } for (Entity t : boss.getPossibleTargets()) if (t.matches(object.getTile()) || boss.matches(object.getTile())) { player.sendMessage(""The mechanism cannot be activated while someone is standing there.""); return false; } boss.raisePillar(object); return false; default: return true; } } @Override public boolean processObjectClick2(final GameObject object) { if (dungeon == null || !dungeon.hasStarted() || dungeon.isAtRewardsScreen()) return false; VisibleRoom vr = dungeon.getVisibleRoom(dungeon.getCurrentRoomReference(player.getTile())); if (vr == null || !vr.processObjectClick2(player, object)) return false; if (object.getId() >= DungeonConstants.FARMING_PATCH_BEGINING && object.getId() <= DungeonConstants.FARMING_PATCH_END) { if (object.getDefinitions().containsOption(""Inspect"")) return false; Harvest harvest = Harvest.values()[((object.getId() - 50042) / 3)]; if (harvest == null) return false; DungeoneeringFarming.initHarvest(player, harvest, object); return false; } String name = object.getDefinitions().getName().toLowerCase(); return switch (name) { case ""runecrafting altar"" -> { player.startConversation(new DungeoneeringRCD(player, DungRCSet.ELEMENTAL)); yield false; } case ""summoning obelisk"" -> { if (player.getSkills().getLevel(Constants.SUMMONING) < player.getSkills().getLevelForXp(Constants.SUMMONING)) { player.sendMessage(""You touch the obelisk"", true); player.setNextAnimation(new Animation(8502)); World.sendSpotAnim(object.getTile(), new SpotAnim(1308)); WorldTasks.schedule(2, () -> { player.getSkills().set(Constants.SUMMONING, player.getSkills().getLevelForXp(Constants.SUMMONING)); player.sendMessage(""...and recharge your summoning points."", true); }); } yield false; } default -> true; }; } @Override public boolean processObjectClick3(GameObject object) { if (dungeon == null || !dungeon.hasStarted() || dungeon.isAtRewardsScreen()) return false; VisibleRoom vr = dungeon.getVisibleRoom(dungeon.getCurrentRoomReference(player.getTile())); if (vr == null || !vr.processObjectClick4(player, object)) return false; if (object.getId() >= DungeonConstants.FARMING_PATCH_BEGINING && object.getId() <= DungeonConstants.FARMING_PATCH_END) { DungeoneeringFarming.clearHarvest(player, object); return false; } String name = object.getDefinitions().getName().toLowerCase(); if (name.equals(""runecrafting altar"")) { player.startConversation(new DungeoneeringRCD(player, DungRCSet.COMBAT)); return false; } return true; } @Override public boolean processObjectClick4(final GameObject object) { if (dungeon == null || !dungeon.hasStarted() || dungeon.isAtRewardsScreen() || !dungeon.getVisibleRoom(dungeon.getCurrentRoomReference(player.getTile())).processObjectClick4(player, object)) return false; String name = object.getDefinitions().getName().toLowerCase(); if (name.equals(""runecrafting altar"")) { player.startConversation(new DungeoneeringRCD(player, DungRCSet.OTHER)); return false; } return true; } @Override public boolean processObjectClick5(final GameObject object) { if (dungeon == null || !dungeon.hasStarted() || dungeon.isAtRewardsScreen()) return false; VisibleRoom vr = dungeon.getVisibleRoom(dungeon.getCurrentRoomReference(player.getTile())); if (vr == null || !vr.processObjectClick5(player, object)) return false; String name = object.getDefinitions().getName().toLowerCase(); if (name.equals(""runecrafting altar"")) { player.startConversation(new DungeoneeringRCD(player, DungRCSet.STAVES)); return false; } return true; } public void leaveDungeon() { if (dungeon == null || !dungeon.hasStarted()) return; dungeon.getParty().leaveParty(player, false); } public void voteToMoveOn() { if (dungeon == null || !dungeon.hasStarted() || voteStage != 0) return; voteStage = 1; dungeon.voteToMoveOn(player); } @Override public boolean processItemOnObject(GameObject object, Item item) { if (dungeon == null || !dungeon.hasStarted() || dungeon.isAtRewardsScreen()) return false; VisibleRoom room = dungeon.getVisibleRoom(dungeon.getCurrentRoomReference(player.getTile())); if ((room == null) || !room.handleItemOnObject(player, object, item)) return false; String name = object.getDefinitions().getName().toLowerCase(); switch (name) { case ""farming patch"": DungeoneeringFarming.plantHarvest(item, player, object, dungeon); return true; case ""furnace"": DungeoneeringSmithing.openSmelting(player); return true; case ""anvil"": DungeoneeringSmithing.openInterface(player, item); return true; case ""spinning wheel"": ReqItem[] products = ReqItem.getProducts(Category.DUNG_SPINNING, item.getId()); if (products.length == 0) return false; player.startConversation(new CreationActionD(player, Category.DUNG_SPINNING, item.getId(), 883, 2)); return false; } return true; } @Override public boolean canUseItemOnItem(Item itemUsed, Item usedWith) { if (dungeon == null || !dungeon.hasStarted() || dungeon.isAtRewardsScreen()) return false; if (itemUsed.getId() == 17446 || usedWith.getId() == 17446) { ReqItem[] products = ReqItem.getProducts(Category.DUNG_NEEDLE_CRAFTING, usedWith.getId()); if (products.length == 0) products = ReqItem.getProducts(Category.DUNG_NEEDLE_CRAFTING, itemUsed.getId()); if (products.length == 0) return false; player.startConversation(new CreationActionD(player, Category.DUNG_NEEDLE_CRAFTING, products[0].getMaterials()[0].getId(), -1, 2)); } else if (itemUsed.getId() == 17752 || usedWith.getId() == 17752) { ReqItem[] products = ReqItem.getProducts(Category.DUNG_BOWSTRINGING, usedWith.getId()); if (products.length == 0) products = ReqItem.getProducts(Category.DUNG_BOWSTRINGING, itemUsed.getId()); if (products.length == 0) return false; player.startConversation(new CreationActionD(player, Category.DUNG_BOWSTRINGING, products[0].getMaterials()[0].getId(), -1, 2)); } else if (itemUsed.getId() == 17754 || usedWith.getId() == 17754) { ReqItem[] products = ReqItem.getProducts(Category.DUNG_KNIFE_FLETCHING, usedWith.getId()); if (products.length == 0) products = ReqItem.getProducts(Category.DUNG_KNIFE_FLETCHING, itemUsed.getId()); if (products.length == 0) return false; player.startConversation(new CreationActionD(player, Category.DUNG_KNIFE_FLETCHING, products[0].getMaterials()[0].getId(), -1, 2)); } else if (itemUsed.getId() == 17742 || usedWith.getId() == 17742 || itemUsed.getId() == 17747 || usedWith.getId() == 17747) { ReqItem[] products = ReqItem.getProducts(Category.DUNG_ARROW_COMBINING, usedWith.getId()); if (products.length == 0) products = ReqItem.getProducts(Category.DUNG_ARROW_COMBINING, itemUsed.getId()); if (products.length == 0) return false; player.startConversation(new CreationActionD(player, Category.DUNG_ARROW_COMBINING, products[0].getMaterials()[1].getId(), -1, 1)); } return true; } public void openDoor(GameObject object) { RoomReference roomReference = dungeon.getCurrentRoomReference(player.getTile()); if (dungeon.enterRoom(player, roomReference.getRoomX() + Utils.ROTATION_DIR_X[object.getRotation()], roomReference.getRoomY() + Utils.ROTATION_DIR_Y[object.getRotation()])) hideBar(); } /** * called once teleport is performed */ @Override public void onTeleported(TeleType type) { dungeon.playMusic(player, dungeon.getCurrentRoomReference(player.getTile())); hideBar(); } @Override public boolean keepCombating(Entity target) { if (target instanceof DungeonSlayerNPC npc) if (player.getSkills().getLevel(Constants.SLAYER) < npc.getType().getReq()) { player.sendMessage(""You need a Slayer level of "" + npc.getType().getReq() + "" in order to attack this monster.""); return false; } return true; } /* * return process normaly */ @Override public boolean processButtonClick(int interfaceId, int componentId, int slotId, int slotId2, ClientPacket packet) { if (dungeon == null || !dungeon.hasStarted()) return false; if (dungeon.isAtRewardsScreen()) { if (interfaceId == 933) if (componentId >= 318 && componentId <= 322) if (packet == ClientPacket.IF_OP2) player.startConversation(new DungeonLeave(player, this)); else { if (voteStage == 2) return false; voteStage = 2; dungeon.ready(player); } return false; } if ((interfaceId == 548 && componentId == 157) || (interfaceId == 746 && componentId == 200)) { if (player.getInterfaceManager().containsScreenInter() || player.getInterfaceManager().containsInventoryInter()) { player.sendMessage(""Please finish what you're doing before opening the dungeon map.""); return false; } dungeon.openMap(player); return false; } if (interfaceId == Inventory.INVENTORY_INTERFACE) { Item item = player.getInventory().getItem(slotId); if (item == null || item.getId() != slotId2) return false; if (packet == ClientPacket.IF_OP1) { for (int index = 0; index < DungeoneeringTraps.ITEM_TRAPS.length; index++) if (item.getId() == DungeoneeringTraps.ITEM_TRAPS[index]) { DungeoneeringTraps.placeTrap(player, dungeon, index); return false; } for (int element : PoltergeistRoom.HERBS) if (item.getId() == element) { VisibleRoom room = dungeon.getVisibleRoom(dungeon.getCurrentRoomReference(player.getTile())); if (room == null) return false; if (!(room instanceof PoltergeistRoom)) { player.sendMessage(""You need to be closer to the poltergeist to cleanse this herb.""); return false; } ((PoltergeistRoom) room).consecrateHerbs(player, item.getId()); return false; } } return true; } else if (interfaceId == 934) DungeoneeringSmithing.handleButtons(player, packet, componentId); else if (interfaceId == DungeonResourceShop.RESOURCE_SHOP) { if (componentId == 24) { int quantity = -1; if (packet == ClientPacket.IF_OP2) quantity = 1; else if (packet == ClientPacket.IF_OP3) quantity = 5; else if (packet == ClientPacket.IF_OP4) quantity = 10; else if (packet == ClientPacket.IF_OP5) quantity = 50; DungeonResourceShop.handlePurchaseOptions(player, slotId, quantity); } return false; } else if (interfaceId == DungeonResourceShop.RESOURCE_SHOP_INV) { if (componentId == 0) { int quantity = -1; if (packet == ClientPacket.IF_OP2) quantity = 1; else if (packet == ClientPacket.IF_OP3) quantity = 5; else if (packet == ClientPacket.IF_OP4) quantity = 10; else if (packet == ClientPacket.IF_OP5) quantity = 50; DungeonResourceShop.handleSellOptions(player, slotId, slotId2, quantity); } return false; } else if (interfaceId == 950) { if (componentId == 24) { if (dungeon.getDungeon() == null) return false; if (player.inCombat()) { player.sendMessage(""You cannot do that while in combat.""); return false; } Magic.sendNormalTeleportSpell(player, 0, 0, dungeon.getHomeTile(), null, null); } if (componentId == 2) player.getCombatDefinitions().switchDefensiveCasting(); else if (componentId == 7) player.getCombatDefinitions().switchShowCombatSpells(); else if (componentId == 9) player.getCombatDefinitions().switchShowTeleportSkillSpells(); else if (componentId == 11) player.getCombatDefinitions().switchShowMiscSpells(); else if (componentId == 13) player.getCombatDefinitions().switchShowSkillSpells(); else if (componentId >= 15 & componentId <= 17) player.getCombatDefinitions().setSortSpellBook(componentId - 15); else if (componentId == 39 || componentId == 40) stoneTeleport(componentId == 40); else if (componentId == 38) { if (!player.getInventory().hasFreeSlots()) { player.sendMessage(""You don't have enough inventory space.""); return false; } if (packet == ClientPacket.IF_OP2) { player.getInventory().deleteItem(DungeonConstants.GATESTONE, 1); if (gatestone != null) { GroundItem item = ChunkManager.getChunk(gatestone.getChunkId()).getGroundItem(DungeonConstants.GATESTONE, gatestone, player); if (item == null) return false; World.removeGroundItem(player, item, false); setGatestone(null); } } if (!canCreateGatestone()) return false; player.getInventory().addItem(DungeonConstants.GATESTONE, 1); player.getSkills().addXp(Constants.MAGIC, 43.5); player.setNextAnimation(new Animation(713)); player.setNextSpotAnim(new SpotAnim(113)); } else Magic.processDungSpell(player, componentId, packet); return false; } return true; } @Override public boolean canDropItem(Item item) { if (item.getName().contains(""Ring of kinship"")) { player.simpleDialogue(""You cannot destroy that here.""); return false; } if (item.getDefinitions().isDestroyItem()) return true; Tile currentTile = Tile.of(player.getTile()); player.stopAll(false); player.getInventory().deleteItem(item); if (item.getId() == DungeonConstants.GROUP_GATESTONE) dungeon.setGroupGatestone(currentTile); else if (item.getId() == DungeonConstants.GATESTONE) { setGatestone(currentTile); World.addGroundItem(item, currentTile, player, true, -1, DropMethod.NORMAL, -1); player.sendMessage(""You place the gatestone. You can teleport back to it at any time.""); return false; } World.addGroundItem(item, currentTile); return false; } private void stoneTeleport(boolean group) { Tile tile = group ? dungeon.getGroupGatestone() : gatestone; if (dungeon.isAtBossRoom(player.getTile(), 26, 626, true) || (dungeon.isAtBossRoom(player.getTile(), 26, 672, true) && !YkLagorThunderous.isBehindPillar(player, dungeon, dungeon.getCurrentRoomReference(Tile.of(player.getTile()))))) { player.sendMessage(""You can't teleport here.""); return; } if (tile == null) { // Shouldn't happen for group gatestone player.sendMessage(""You currently do not have an active gatestone.""); return; } if (!group) { GroundItem item = ChunkManager.getChunk(gatestone.getChunkId()).getGroundItem(DungeonConstants.GATESTONE, tile, player); if (item == null) return; World.removeGroundItem(player, item); player.getInventory().deleteItem(item); setGatestone(null); } if (!Magic.checkRunes(player, true, new RuneSet(Rune.LAW, 3))) return; Magic.sendTeleportSpell(player, 13288, 13285, 2516, 2517, group ? 64 : 32, 0, tile, 3, false, TeleType.MAGIC, null); if (!group) { player.setCantWalk(true); player.getEmotesManager().setNextEmoteEnd(3); //prevents dropping etc WorldTasks.schedule(new Task() { @Override public void run() { player.setCantWalk(false); } }, 4); } } private void portalGroupStoneTeleport() { Tile tile = dungeon.getGroupGatestone(); if (tile == null) //cant happen return; Magic.sendTeleportSpell(player, 14279, 13285, 2518, 2517, 1, 0, tile, 1, false, TeleType.OBJECT, null); } private boolean canCreateGatestone() { if (player.getInventory().containsItem(DungeonConstants.GATESTONE, 1)) { player.sendMessage(""You already have a gatestone in your pack. Making another would be pointless.""); return false; } if (gatestone != null) { player.sendMessage(""You already have an active gatestone.""); return false; } if (!Magic.checkSpellLevel(player, 32)) return false; else return Magic.checkRunes(player, true, new RuneSet(Rune.COSMIC, 3)); } public void leaveDungeonPermanently() { int index = dungeon.getParty().getIndex(player); leaveDungeon(); for (Player p2 : dungeon.getParty().getTeam()) p2.getPackets().sendVarc(1397 + index, 2); } @Override public boolean processItemOnPlayer(Player p2, Item item, int slot) { if (Foods.isConsumable(item) && Foods.eat(p2, item, slot, player)) player.getInventory().deleteItem(item.getId(), 1); return true; } @Override public void forceClose() { if (dungeon != null) dungeon.getParty().leaveParty(player, false); else { for (Item item : player.getInventory().getItems().array()) { if (DungManager.isBannedDungItem(item)) player.getInventory().deleteItem(item); } for (Item item : player.getEquipment().getItemsCopy()) { if (DungManager.isBannedDungItem(item)) player.getEquipment().deleteItem(item.getId(), item.getAmount()); } if (player.getInventory().containsItem(15707)) player.getInventory().deleteItem(15707, 27); if (player.getEquipment().containsOneItem(15707)) player.getEquipment().deleteItem(15707, 27); player.getInterfaceManager().removeOverlay(); player.setForceMultiArea(false); if (player.getFamiliar() != null) player.getFamiliar().sendDeath(player); player.setLocation(Tile.of(DungeonConstants.OUTSIDE, 2)); } } @Override public boolean login() { removeController(); player.tele(Tile.of(DungeonConstants.OUTSIDE, 2)); return false; } @Override public boolean logout() { return false; } private void setGatestone(Tile gatestone) { this.gatestone = gatestone; } public boolean isKilledBossWithLessThan10HP() { return killedBossWithLessThan10HP; } }" "package com.rs.game.content.skills.dungeoneering; public class DungeonManager { private static final Map ACTIVE_DUNGEONS = Collections.synchronizedMap(new HashMap<>()); public static final AtomicLong KEY_MAKER = new AtomicLong(); private final DungeonPartyManager party; private Dungeon dungeon; private VisibleRoom[][] visibleMap; private Instance instance; private int stage; //0 - not loaded. 1 - loaded. 2 - new one not loaded, old one loaded(rewards screen) private RewardsTimer rewardsTimer; private DestroyTimer destroyTimer; private long time; private final List keyList; private final List farmingPatches; private String key; private Tile groupGatestone; private final List mastyxTraps; //force saving deaths private final Map partyDeaths; private final boolean tutorialMode; private DungeonBoss temporaryBoss; //must for gravecreeper, cuz... it gets removed from npc list :/ // 7554 public DungeonManager(DungeonPartyManager party) { this.party = party; tutorialMode = party.getMaxComplexity() < 6; load(); keyList = new CopyOnWriteArrayList<>(); farmingPatches = new CopyOnWriteArrayList<>(); mastyxTraps = new CopyOnWriteArrayList<>(); partyDeaths = new ConcurrentHashMap<>(); } public void clearKeyList() { for (Player player : party.getTeam()) { player.getPackets().sendRunScriptReverse(6072); player.getPackets().sendVarc(1875, 0); //forces refresh } } public void setKey(KeyDoors key, boolean add) { if (add) { keyList.add(key); for (Player player : party.getTeam()) player.sendMessage(""Your party found a key: "" + ItemDefinitions.getDefs(key.getKeyId()).getName()); } else { keyList.remove(key); for (Player player : party.getTeam()) player.sendMessage(""Your party used a key: "" + ItemDefinitions.getDefs(key.getKeyId()).getName()); } for (Player player : party.getTeam()) { player.getPackets().sendVarc(1812 + key.getIndex(), add ? 1 : 0); if (key.getIndex() != 64) player.getPackets().sendVarc(1875, keyList.contains(KeyDoors.GOLD_SHIELD) ? 1 : 0); } } public boolean isAtBossRoom(Tile tile) { return isAtBossRoom(tile, -1, -1, false); } public boolean isAtBossRoom(Tile tile, int x, int y, boolean check) { Room room = getRoom(getCurrentRoomReference(tile)); if (room == null || !(room.getRoom() instanceof BossRoom)) return false; if (check) { BossRoom bRoom = (BossRoom) room.getRoom(); return x == bRoom.getChunkX() && y == bRoom.getChunkY(); } return true; } public boolean isBossOpen() { for (VisibleRoom[] element : visibleMap) for (VisibleRoom room : element) { if (room == null || !room.isLoaded()) continue; if (isAtBossRoom(getRoomCenterTile(room.reference))) return true; } return false; } /* * dont use */ public void refreshKeys(Player player) { for (KeyDoors key : keyList) player.getPackets().sendVarc(1812 + key.getIndex(), 1); player.getPackets().sendVarc(1875, keyList.contains(KeyDoors.GOLD_SHIELD) ? 1 : 0); } public boolean hasKey(KeyDoors key) { return keyList.contains(key); } /* * when dung ends to make sure no1 dies lo, well they can die but still.. */ public void clearGuardians() { for (VisibleRoom[] element : visibleMap) for (VisibleRoom element2 : element) if (element2 != null) element2.forceRemoveGuardians(); } public int getVisibleRoomsCount() { int count = 0; for (VisibleRoom[] element : visibleMap) for (VisibleRoom element2 : element) if (element2 != null) count++; return count; } public int getVisibleBonusRoomsCount() { int count = 0; for (int x = 0; x < visibleMap.length; x++) for (int y = 0; y < visibleMap[x].length; y++) if (visibleMap[x][y] != null && !dungeon.getRoom(new RoomReference(x, y)).isCritPath()) count++; return count; } public int getLevelModPerc() { int totalGuardians = 0; int killedGuardians = 0; for (VisibleRoom[] element : visibleMap) for (VisibleRoom element2 : element) if (element2 != null) { totalGuardians += element2.getGuardiansCount(); killedGuardians += element2.getKilledGuardiansCount(); } return totalGuardians == 0 ? 100 : killedGuardians * 100 / totalGuardians; } public boolean enterRoom(Player player, int x, int y) { if (x < 0 || y < 0 || x >= visibleMap.length || y >= visibleMap[0].length) return false; RoomReference roomReference = getCurrentRoomReference(player.getTile()); player.lock(0); if (visibleMap[x][y] == null) { loadRoom(x, y); return false; } if (!visibleMap[x][y].isLoaded()) return false; int xOffset = x - roomReference.getRoomX(); int yOffset = y - roomReference.getRoomY(); player.tele(Tile.of(player.getX() + xOffset * 3, player.getY() + yOffset * 3, 0)); playMusic(player, new RoomReference(x, y)); return true; } public void loadRoom(int x, int y) { loadRoom(new RoomReference(x, y)); } public void loadRoom(final RoomReference reference) { final Room room = dungeon.getRoom(reference); if (room == null) return; VisibleRoom vr; if (room.getRoom() instanceof HandledPuzzleRoom pr) vr = pr.createVisibleRoom(); else vr = new VisibleRoom(); visibleMap[reference.getRoomX()][reference.getRoomY()] = vr; vr.init(this, reference, party.getFloorType(), room.getRoom()); openRoom(room, reference, visibleMap[reference.getRoomX()][reference.getRoomY()]); } public boolean isDestroyed() { return dungeon == null; } public int getBossLevel() { return (int) (party.getAverageCombatLevel() * 1.5); } public void openRoom(final Room room, final RoomReference reference, final VisibleRoom visibleRoom) { int chunkOffX = reference.getRoomX() * 2; int chunkOffY = reference.getRoomY() * 2; instance.copy2x2ChunkSquare(chunkOffX, chunkOffY, room.getChunkX(party.getComplexity()), room.getChunkY(party.getFloorType()), room.getRotation(), new int[] { 0, 1 }).thenAccept(e -> { for (Player player : party.getTeam()) { player.setForceNextMapLoadRefresh(true); player.loadMapRegions(); } if (isDestroyed()) return; room.openRoom(DungeonManager.this, reference); visibleRoom.openRoom(); for (int i = 0; i < room.getRoom().getDoorDirections().length; i++) { Door door = room.getDoor(i); if (door == null) continue; int rotation = (room.getRoom().getDoorDirections()[i] + room.getRotation()) & 0x3; if (door.getType() == DungeonConstants.KEY_DOOR) { KeyDoors keyDoor = KeyDoors.values()[door.getId()]; setDoor(reference, keyDoor.getObjectId(), keyDoor.getDoorId(party.getFloorType()), rotation); } else if (door.getType() == DungeonConstants.GUARDIAN_DOOR) { setDoor(reference, -1, DungeonConstants.DUNGEON_GUARDIAN_DOORS[party.getFloorType()], rotation); if (visibleRoom.roomCleared()) //remove referene since done room.setDoor(i, null); } else if (door.getType() == DungeonConstants.SKILL_DOOR) { SkillDoors skillDoor = SkillDoors.values()[door.getId()]; int type = party.getFloorType(); int closedId = skillDoor.getClosedObject(type); int openId = skillDoor.getOpenObject(type); setDoor(reference, openId == -1 ? closedId : -1, openId != -1 ? closedId : -1, rotation); } } if (room.getRoom().allowResources()) setResources(room, reference, chunkOffX, chunkOffY); if (room.getDropId() != -1) setKey(room, reference); visibleRoom.setLoaded(); }); } public void setDoor(RoomReference reference, int lockObjectId, int doorObjectId, int rotation) { if (lockObjectId != -1) { int[] xy = DungeonManager.translate(1, 7, rotation, 1, 2, 0); World.spawnObject(new GameObject(lockObjectId, ObjectType.SCENERY_INTERACT, rotation, instance.getLocalX(reference.getBaseX() + xy[0]), instance.getLocalY(reference.getBaseY() + xy[1]), 0)); } if (doorObjectId != -1) { int[] xy = DungeonManager.translate(0, 7, rotation, 1, 2, 0); World.spawnObject(new GameObject(doorObjectId, ObjectType.SCENERY_INTERACT, rotation, instance.getLocalX(reference.getBaseX() + xy[0]), instance.getLocalY(reference.getBaseY() + xy[1]), 0)); } } public void setKey(Room room, RoomReference reference) { int[] loc = room.getRoom().getKeySpot(); if (loc != null) { spawnItem(reference, new Item(room.getDropId()), loc[0], loc[1]); return; } spawnItem(reference, new Item(room.getDropId()), 7, 1); } public void setResources(Room room, RoomReference reference, int chunkOffX, int chunkOffY) { if (party.getComplexity() >= 5 && Utils.random(3) == 0) //sets thief chest for (int i = 0; i < DungeonConstants.SET_RESOURCES_MAX_TRY; i++) { int rotation = Utils.random(DungeonConstants.WALL_BASE_X_Y.length); int[] b = DungeonConstants.WALL_BASE_X_Y[rotation]; int x = b[0] + Utils.random(b[2]); int y = b[1] + Utils.random(b[3]); if (((x >= 6 && x <= 8) && b[2] != 0) || ((y >= 6 && y <= 8) && b[3] != 0)) continue; if (!World.floorFree(0, instance.getLocalX(chunkOffX, x), instance.getLocalY(chunkOffY, y)) || !World.floorAndWallsFree(0, instance.getLocalX(chunkOffX, x - Utils.ROTATION_DIR_X[((rotation + 3) & 0x3)]), instance.getLocalY(chunkOffY, y - Utils.ROTATION_DIR_Y[((rotation + 3) & 0x3)]), 1)) continue; room.setThiefChest(Utils.random(10)); World.spawnObject(new GameObject(DungeonConstants.THIEF_CHEST_LOCKED[party.getFloorType()], ObjectType.SCENERY_INTERACT, ((rotation + 3) & 0x3), instance.getLocalX(chunkOffX, x), instance.getLocalY(chunkOffY, y), 0)); Logger.debug(DungeonManager.class, ""setResources"", ""Added chest spot.""); break; } if (party.getComplexity() >= 4 && Utils.random(3) == 0) //sets flower for (int i = 0; i < DungeonConstants.SET_RESOURCES_MAX_TRY; i++) { int rotation = Utils.random(DungeonConstants.WALL_BASE_X_Y.length); int[] b = DungeonConstants.WALL_BASE_X_Y[rotation]; int x = b[0] + Utils.random(b[2]); int y = b[1] + Utils.random(b[3]); if (((x >= 6 && x <= 8) && b[2] != 0) || ((y >= 6 && y <= 8) && b[3] != 0)) continue; if (!World.floorFree(0, instance.getLocalX(chunkOffX, x), instance.getLocalY(chunkOffY, y))) continue; World.spawnObject(new GameObject(DungeonUtils.getFarmingResource(Utils.random(10), party.getFloorType()), ObjectType.SCENERY_INTERACT, rotation, instance.getLocalX(chunkOffX, x), instance.getLocalY(chunkOffY, y), 0)); Logger.debug(DungeonManager.class, ""setResources"", ""Added flower spot.""); break; } if (party.getComplexity() >= 3 && Utils.random(3) == 0) //sets rock for (int i = 0; i < DungeonConstants.SET_RESOURCES_MAX_TRY; i++) { int rotation = Utils.random(DungeonConstants.WALL_BASE_X_Y.length); int[] b = DungeonConstants.WALL_BASE_X_Y[rotation]; int x = b[0] + Utils.random(b[2]); int y = b[1] + Utils.random(b[3]); if (((x >= 6 && x <= 8) && b[2] != 0) || ((y >= 6 && y <= 8) && b[3] != 0)) continue; if (!World.floorFree(0, instance.getLocalX(chunkOffX, x), instance.getLocalY(chunkOffY, y))) continue; World.spawnObject(new GameObject(DungeonUtils.getMiningResource(Utils.random(DungeoneeringMining.DungeoneeringRocks.values().length), party.getFloorType()), ObjectType.SCENERY_INTERACT, rotation, instance.getLocalX(chunkOffX, x), instance.getLocalY(chunkOffY, y), 0)); Logger.debug(DungeonManager.class, ""setResources"", ""Added rock spot.""); break; } if (party.getComplexity() >= 2 && Utils.random(3) == 0) //sets tree for (int i = 0; i < DungeonConstants.SET_RESOURCES_MAX_TRY; i++) { int rotation = Utils.random(DungeonConstants.WALL_BASE_X_Y.length); int[] b = DungeonConstants.WALL_BASE_X_Y[rotation]; int x = b[0] + Utils.random(b[2]); int y = b[1] + Utils.random(b[3]); if (((x >= 6 && x <= 8) && b[2] != 0) || ((y >= 6 && y <= 8) && b[3] != 0)) continue; if (!World.wallsFree(0, instance.getLocalX(chunkOffX, x), instance.getLocalY(chunkOffY, y)) || !World.floorFree(0, instance.getLocalX(chunkOffX, x), instance.getLocalY(chunkOffY, y))) continue; x -= Utils.ROTATION_DIR_X[rotation]; y -= Utils.ROTATION_DIR_Y[rotation]; Logger.debug(DungeonManager.class, ""setResources"", ""Added tree spot""); World.spawnObject(new GameObject(DungeonUtils.getWoodcuttingResource(Utils.random(10), party.getFloorType()), ObjectType.SCENERY_INTERACT, rotation, instance.getLocalX(chunkOffX, x), instance.getLocalY(chunkOffY, y), 0)); break; } if (party.getComplexity() >= 2) { //sets fish spot List fishSpots = new ArrayList<>(); for (int x = 0; x < 16; x++) for (int y = 0; y < 16; y++) { GameObject o = World.getObjectWithType(Tile.of(instance.getLocalX(chunkOffX, x), instance.getLocalY(chunkOffY, y), 0), ObjectType.SCENERY_INTERACT); if (o == null || o.getId() != DungeonConstants.FISH_SPOT_OBJECT_ID) continue; fishSpots.add(new int[] { x, y }); } if (!fishSpots.isEmpty()) { int[] spot = fishSpots.get(Utils.random(fishSpots.size())); spawnNPC(DungeonConstants.FISH_SPOT_NPC_ID, room.getRotation(), Tile.of(instance.getLocalX(chunkOffX, spot[0]), instance.getLocalY(chunkOffY, spot[1]), 0), reference, DungeonConstants.FISH_SPOT_NPC); Logger.debug(DungeonManager.class, ""setResources"", ""Added fish spot""); } } } public Tile getRoomCenterTile(RoomReference reference) { return getRoomBaseTile(reference).transform(8, 8, 0); } public Tile getRoomBaseTile(RoomReference reference) { return Tile.of((instance.getBaseX() + reference.getBaseX()), (instance.getBaseY() + reference.getBaseY()), 0); } public RoomReference getCurrentRoomReference(Tile tile) { return new RoomReference((tile.getChunkX() - instance.getBaseChunkX()) / 2, ((tile.getChunkY() - instance.getBaseChunkY()) / 2)); } public Room getRoom(RoomReference reference) { return dungeon == null ? null : dungeon.getRoom(reference); } public VisibleRoom getVisibleRoom(RoomReference reference) { if (reference.getRoomX() >= visibleMap.length || reference.getRoomY() >= visibleMap[0].length) return null; return visibleMap[reference.getRoomX()][reference.getRoomY()]; } public Tile getHomeTile() { return getRoomCenterTile(dungeon.getStartRoomReference()); } public void telePartyToRoom(RoomReference reference) { Tile tile = getRoomCenterTile(reference); for (Player player : party.getTeam()) { player.tele(tile); playMusic(player, reference); } } public void playMusic(Player player, RoomReference reference) { if (reference.getRoomX() >= visibleMap.length || reference.getRoomY() >= visibleMap[reference.getRoomX()].length) return; player.getMusicsManager().forcePlayMusic(visibleMap[reference.getRoomX()][reference.getRoomY()].getMusicId()); } public void linkPartyToDungeon() { WorldTasks.schedule(new Task() { @Override public void run() { for (Player player : party.getTeam()) { resetItems(player, false, false); player.reset(); sendSettings(player); if (party.getComplexity() >= 5 && party.isLeader(player)) player.getInventory().addItem(new Item(DungeonConstants.GROUP_GATESTONE)); removeMark(player); sendStartItems(player); player.sendMessage(""""); player.sendMessage(""-Welcome to Daemonheim-""); player.sendMessage(""Floor "" + party.getFloor() + "" Complexity "" + party.getComplexity()); String[] sizeNames = { ""Small"", ""Medium"", ""Large"", ""Test"" }; player.sendMessage(""Dungeon Size: "" + """" + sizeNames[party.getSize()]); player.sendMessage(""Party Size:Difficulty "" + party.getTeam().size() + "":"" + party.getDificulty()); if (party.isGuideMode()) player.sendMessage(""Guide Mode ON""); player.sendMessage(""""); player.lock(1); } resetGatestone(); } }); } public void setTableItems(RoomReference room) { addItemToTable(room, new Item(16295)); //novite pickaxe, cuz of boss aswell so 1+ addItemToTable(room, new Item(16933)); //antifire shield if (party.getComplexity() >= 2) { addItemToTable(room, new Item(DungeonConstants.RUSTY_COINS, 5000 + Utils.random(10000))); addItemToTable(room, new Item(17678)); //tinderbox addItemToTable(room, new Item(16361)); //novite hatcher addItemToTable(room, new Item(17794)); //fish rods addItemToTable(room, new Item(16933)); //antifire shield } if (party.getComplexity() >= 3) { //set weap/gear in table int rangeTier = DungeonUtils.getTier(party.getMaxLevel(Constants.RANGE)); if (rangeTier > 8) rangeTier = 8; addItemToTable(room, new Item(DungeonUtils.getArrows(1 + Utils.random(rangeTier)), 90 + Utils.random(30))); //arround 100 arrows, type random up to best u can, limited to tier 8 addItemToTable(room, new Item(DungeonConstants.RUNES[0], 90 + Utils.random(30))); //arround 100 air runes addItemToTable(room, new Item(DungeonConstants.RUNE_ESSENCE, 90 + Utils.random(30))); //arround 100 essence addItemToTable(room, new Item(17754)); //knife addItemToTable(room, new Item(17883)); //hammer if (party.getComplexity() >= 4) addItemToTable(room, new Item(17446)); //needle } for (@SuppressWarnings(""unused"") Player player : party.getTeam()) { for (int i = 0; i < 7 + Utils.random(4); i++) //9 food addItemToTable(room, new Item(DungeonUtils.getFood(1 + Utils.random(8)))); if (party.getComplexity() >= 3) //set weap/gear in table for (int i = 0; i < 1 + Utils.random(3); i++) //1 up to 3 pieces of gear or weap addItemToTable(room, new Item(DungeonUtils.getRandomGear(1 + Utils.random(8)))); //arround 100 essence } } public void addItemToTable(RoomReference room, Item item) { int slot = Utils.random(10); //10 spaces for items if (slot < 6) spawnItem(room, item, 9 + Utils.random(3), 10 + Utils.random(2)); else if (slot < 8) spawnItem(room, item, 10 + Utils.random(2), 14); else spawnItem(room, item, 14, 10 + Utils.random(2)); } public void sendStartItems(Player player) { if (party.getComplexity() == 1) player.simpleDialogue(""Complexity 1"", ""Combat only"", ""Armour and weapons allocated"", ""No shop stock""); else if (party.getComplexity() == 2) player.simpleDialogue(""Complexity 2"", ""+ Fishing, Woodcutting, Firemaking, Cooking"", ""Armour and weapons allocated"", ""Minimal shop stock""); else if (party.getComplexity() == 3) player.simpleDialogue(""Complexity 3"", ""+ Mining, Smithing weapons, Fletching, Runecrafting"", ""Armour allocated"", ""Increased shop stock""); else if (party.getComplexity() == 4) player.simpleDialogue(""Complexity 4"", ""+ Smithing armour, Hunter, Farming textiles, Crafting"", ""Increased shop stock""); else if (party.getComplexity() == 5) player.simpleDialogue(""Complexity 5"", ""All skills included"", ""+ Farming seeds, Herblore, Thieving, Summoning"", ""Complete shop stock"", ""Challenge rooms + skill doors""); if (party.getComplexity() <= 3) { int defenceTier = DungeonUtils.getTier(player.getSkills().getLevelForXp(Constants.DEFENSE)); if (defenceTier > 8) defenceTier = 8; player.getInventory().addItem(new Item(DungeonUtils.getPlatebody(defenceTier))); player.getInventory().addItem(new Item(DungeonUtils.getPlatelegs(defenceTier, player.getAppearance().isMale()))); if (party.getComplexity() <= 2) { int attackTier = DungeonUtils.getTier(player.getSkills().getLevelForXp(Constants.ATTACK)); if (attackTier > 8) attackTier = 8; player.getInventory().addItem(new Item(DungeonUtils.getRapier(defenceTier))); player.getInventory().addItem(new Item(DungeonUtils.getBattleaxe(defenceTier))); } int magicTier = DungeonUtils.getTier(player.getSkills().getLevelForXp(Constants.MAGIC)); if (magicTier > 8) magicTier = 8; player.getInventory().addItem(new Item(DungeonUtils.getRobeTop(Math.min(defenceTier, magicTier)))); player.getInventory().addItem(new Item(DungeonUtils.getRobeBottom(Math.min(defenceTier, magicTier)))); if (party.getComplexity() <= 2) { player.getInventory().addItem(new Item(DungeonConstants.RUNES[0], 90 + Utils.random(30))); player.getInventory().addItem(new Item(DungeonUtils.getStartRunes(player.getSkills().getLevelForXp(Constants.MAGIC)), 90 + Utils.random(30))); player.getInventory().addItem(new Item(DungeonUtils.getElementalStaff(magicTier))); } int rangeTier = DungeonUtils.getTier(player.getSkills().getLevelForXp(Constants.RANGE)); if (rangeTier > 8) rangeTier = 8; player.getInventory().addItem(new Item(DungeonUtils.getLeatherBody(Math.min(defenceTier, rangeTier)))); player.getInventory().addItem(new Item(DungeonUtils.getChaps(Math.min(defenceTier, rangeTier)))); if (party.getComplexity() <= 2) { player.getInventory().addItem(new Item(DungeonUtils.getShortbow(rangeTier))); player.getInventory().addItem(new Item(DungeonUtils.getArrows(rangeTier), 90 + Utils.random(30))); } } } public void sendSettings(Player player) { if (player.getControllerManager().getController() instanceof DungeonController ctrl) ctrl.reset(); else { player.getControllerManager().startController(new DungeonController(DungeonManager.this)); player.setLargeSceneView(true); player.getCombatDefinitions().setSpellbook(Spellbook.DUNGEONEERING); player.getPackets().sendVarc(1725, 11); setWorldMap(player, true); } player.getPackets().sendVarc(234, 3); player.getInterfaceManager().sendSub(Sub.TAB_QUEST, 939); player.getDungManager().refresh(); player.getInventory().deleteItem(new Item(15707, 28)); sendRing(player); sendBindItems(player); wearInventory(player); } public void rejoinParty(Player player) { player.stopAll(); player.lock(2); party.add(player); sendSettings(player); refreshKeys(player); player.tele(getHomeTile()); playMusic(player, dungeon.getStartRoomReference()); } public void sendBindItems(Player player) { Item ammo = player.getDungManager().getBindedAmmo(); if (ammo != null) player.getInventory().addItem(ammo); for (Item item : player.getDungManager().getBindedItems().array()) { if (item == null) continue; player.getInventory().addItem(item); } } public void resetItems(Player player, boolean drop, boolean logout) { if (drop) { for (Item item : player.getEquipment().getItemsCopy()) { if (item == null || item.getName().contains(""(b)"") || item.getName().contains(""kinship"") || !DungManager.isBannedDungItem(item)) continue; World.addGroundItem(item, Tile.of(player.getTile())); } for (Item item : player.getInventory().getItems().array()) { if (item == null || item.getName().contains(""(b)"") || item.getName().contains(""kinship"") || !DungManager.isBannedDungItem(item)) continue; World.addGroundItem(item, Tile.of(player.getTile())); if (hasLoadedNoRewardScreen() & item.getId() == DungeonConstants.GROUP_GATESTONE) setGroupGatestone(Tile.of(player.getTile())); } } for (Item item : player.getInventory().getItems().array()) { if (DungManager.isBannedDungItem(item)) player.getInventory().deleteItem(item); } for (Item item : player.getEquipment().getItemsCopy()) { if (DungManager.isBannedDungItem(item)) player.getEquipment().deleteItem(item.getId(), item.getAmount()); } player.getInventory().addItem(15707, 1); if (!logout) player.getAppearance().generateAppearanceData(); } public void sendRing(Player player) { if (player.getInventory().containsItem(15707, 1)) player.getInventory().deleteItem(15707, 1); if (player.getEquipment().containsOneItem(15707, 1)) player.getEquipment().deleteItem(15707, 1); player.getInventory().addItem(player.getDungManager().getActivePerk() != null ? new Item(player.getDungManager().getActivePerk().getItemId()) : new Item(15707)); } public void wearInventory(Player player) { boolean worn = false; for (int slotId = 0; slotId < 28; slotId++) { Item item = player.getInventory().getItem(slotId); if (item == null) continue; Equipment.sendWear(player, slotId, item.getId()); } if (worn) { player.getAppearance().generateAppearanceData(); player.getInventory().getItems().shift(); player.getInventory().refresh(); } } public int getCombatLevelMonster() { return (int) (party.getAverageCombatLevel() * DungeonConstants.NPC_COMBAT_LEVEL_COMPLEXITY_MUL[party.getComplexity()-1]); } public int getMaxCombatLevelMonster() { return (int) (party.getAverageCombatLevel() * 1.4 * DungeonConstants.NPC_COMBAT_LEVEL_COMPLEXITY_MUL[party.getComplexity()-1]); } public void spawnRandomNPCS(RoomReference reference) { int floorType = party.getFloorType(); int combatTotal = (int) (party.getCombatLevel() * 1.2 * DungeonConstants.NPC_COMBAT_LEVEL_COMPLEXITY_MUL[party.getComplexity()-1]); int maxLevel = getMaxCombatLevelMonster(); int numMonsters = Utils.random(1, 3+party.getTeam().size()); List npcs = DungeonUtils.generateRandomMonsters(floorType, maxLevel, combatTotal, numMonsters); for (int i : npcs) { GuardianMonster m = GuardianMonster.forId(i); NPCDefinitions defs = NPCDefinitions.getDefs(i); spawnNPC(reference, i, 2 + Utils.getRandomInclusive(13-defs.size), 2 + Utils.getRandomInclusive(13-defs.size), true, m.name().contains(""FORGOTTEN_"") ? DungeonConstants.FORGOTTEN_WARRIOR : DungeonConstants.GUARDIAN_NPC); } if (!npcs.isEmpty() && Utils.random(8) == 0) { //slayer creature int creature = DungeonSlayerNPC.getSlayerCreature(party); if (creature != -1) spawnNPC(reference, creature, 2 + Utils.getRandomInclusive(13), 2 + Utils.getRandomInclusive(13), true, DungeonConstants.SLAYER_NPC); } if (Utils.random(4) == 0) spawnNPC(reference, DungeonUtils.getHunterCreature(), 2 + Utils.getRandomInclusive(13), 2 + Utils.getRandomInclusive(13), true, DungeonConstants.HUNTER_NPC); } public int[] getRoomPos(Tile tile) { int chunkX = tile.getX() / 16 * 2; int chunkY = tile.getY() / 16 * 2; int x = tile.getX() - chunkX * 8; int y = tile.getY() - chunkY * 8; Room room = getRoom(getCurrentRoomReference(tile)); if (room == null) return null; return DungeonManager.translate(x, y, (4 - room.getRotation()) & 0x3, 1, 1, 0); } public static int[] translate(int x, int y, int mapRotation, int sizeX, int sizeY, int objectRotation) { int[] coords = new int[2]; if ((objectRotation & 0x1) == 1) { int prevSizeX = sizeX; sizeX = sizeY; sizeY = prevSizeX; } if (mapRotation == 0) { coords[0] = x; coords[1] = y; } else if (mapRotation == 1) { coords[0] = y; coords[1] = 15 - x - (sizeX - 1); } else if (mapRotation == 2) { coords[0] = 15 - x - (sizeX - 1); coords[1] = 15 - y - (sizeY - 1); } else if (mapRotation == 3) { coords[0] = 15 - y - (sizeY - 1); coords[1] = x; } return coords; } public DungeonNPC spawnNPC(RoomReference reference, int id, int x, int y) { return spawnNPC(reference, id, x, y, false, DungeonConstants.NORMAL_NPC); } public DungeonNPC spawnNPC(final RoomReference reference, final int id, int x, int y, boolean check, final int type) { final int rotation = dungeon.getRoom(reference).getRotation(); final int size = NPCDefinitions.getDefs(id).size; int[] coords = translate(x, y, rotation, size, size, 0); Tile tile = instance.getLocalTile((reference.getBaseX()) + coords[0], (reference.getBaseY()) + coords[1]); if (check && !World.floorAndWallsFree(tile, size)) { List tiles = DungeonUtils.getRandomOrderCoords(size); for (Tile t : tiles) { coords = translate(t.getX(), t.getY(), rotation, size, size, 0); tile = instance.getLocalTile((reference.getBaseX()) + coords[0], (reference.getBaseY()) + coords[1]); if (World.floorAndWallsFree(tile, size)) { return spawnNPC(id, rotation, tile, reference, type); } } return spawnNPC(reference, GuardianMonster.FORGOTTEN_WARRIOR.getNPCIds()[0], x, y, true, type); } return spawnNPC(id, rotation, tile, reference, type); } public GameObject spawnObject(RoomReference reference, int id, ObjectType type, int rotation, int x, int y) { if (dungeon == null || dungeon.getRoom(reference) == null) return null; final int mapRotation = dungeon.getRoom(reference).getRotation(); ObjectDefinitions defs = ObjectDefinitions.getDefs(id); int[] coords = translate(x, y, mapRotation, defs.sizeX, defs.sizeY, rotation); GameObject object = new GameObject(id, type, (rotation + mapRotation) & 0x3, instance.getLocalX(reference.getBaseX() + coords[0]), instance.getLocalY(reference.getBaseY() + coords[1]), 0); World.spawnObject(object); return object; } public GameObject spawnObjectForMapRotation(RoomReference reference, int id, ObjectType type, int rotation, int x, int y, int mapRotation) { ObjectDefinitions defs = ObjectDefinitions.getDefs(id); int[] coords = translate(x, y, mapRotation, defs.sizeX, defs.sizeY, rotation); GameObject object = new GameObject(id, type, (rotation + mapRotation) & 0x3, instance.getLocalX(reference.getBaseX() + coords[0]), instance.getLocalY(reference.getBaseY() + coords[1]), 0); World.spawnObject(object); return object; } public GameObject spawnObjectTemporary(RoomReference reference, int id, ObjectType type, int rotation, int x, int y, int ticks) { final int mapRotation = dungeon.getRoom(reference).getRotation(); ObjectDefinitions defs = ObjectDefinitions.getDefs(id); int[] coords = translate(x, y, mapRotation, defs.sizeX, defs.sizeY, rotation); GameObject object = new GameObject(id, type, (rotation + mapRotation) & 0x3, instance.getLocalX(reference.getBaseX() + coords[0]), instance.getLocalY(reference.getBaseY() + coords[1]), 0); World.spawnObjectTemporary(object, ticks); return object; } public void removeObject(RoomReference reference, int id, ObjectType type, int rotation, int x, int y) { final int mapRotation = dungeon.getRoom(reference).getRotation(); ObjectDefinitions defs = ObjectDefinitions.getDefs(id); int[] coords = translate(x, y, mapRotation, defs.sizeX, defs.sizeY, rotation); World.removeObject(new GameObject(id, type, (rotation + mapRotation) & 0x3, instance.getLocalX(reference.getBaseX() + coords[0]), instance.getLocalY(reference.getBaseY() + coords[1]), 0)); } public GameObject getObject(RoomReference reference, int id, int x, int y) { final int mapRotation = dungeon.getRoom(reference).getRotation(); ObjectDefinitions defs = ObjectDefinitions.getDefs(id); int[] coords = translate(x, y, mapRotation, defs.sizeX, defs.sizeY, 0); return World.getObjectWithId(Tile.of(instance.getLocalX(reference.getBaseX() + coords[0]), instance.getLocalY(reference.getBaseY() + coords[1]), 0), id); } public GameObject getObjectWithType(RoomReference reference, int id, ObjectType type, int x, int y) { final int mapRotation = dungeon.getRoom(reference).getRotation(); ObjectDefinitions defs = ObjectDefinitions.getDefs(id); int[] coords = translate(x, y, mapRotation, defs.sizeX, defs.sizeY, 0); return World.getObjectWithType(Tile.of(instance.getLocalX(reference.getBaseX() + coords[0]), instance.getLocalY(reference.getBaseY() + coords[1]), 0), type); } public GameObject getObjectWithType(RoomReference reference, ObjectType type, int x, int y) { Room room = dungeon.getRoom(reference); if(room == null) return null; final int mapRotation = room.getRotation(); int[] coords = translate(x, y, mapRotation, 1, 1, 0); return World.getObjectWithType(Tile.of(instance.getLocalX(reference.getBaseX() + coords[0]), instance.getLocalY(reference.getBaseY() + coords[1]), 0), type); } public Tile getTile(RoomReference reference, int x, int y, int sizeX, int sizeY) { Room room = dungeon.getRoom(reference); if(room == null) return null; final int mapRotation = room.getRotation(); int[] coords = translate(x, y, mapRotation, sizeX, sizeY, 0); return Tile.of(instance.getLocalX(reference.getBaseX() + coords[0]), instance.getLocalY(reference.getBaseY() + coords[1]), 0); } public Tile getTile(RoomReference reference, int x, int y) { return getTile(reference, x, y, 1, 1); } public Tile getRotatedTile(RoomReference reference, int x, int y) { final int mapRotation = dungeon.getRoom(reference).getRotation(); int[] coords = translate(x, y, mapRotation, 1, 1, 0); return Tile.of(instance.getLocalX(reference.getBaseX() + coords[0]), instance.getLocalY(reference.getBaseY() + coords[1]), 0); } public void spawnItem(RoomReference reference, Item item, int x, int y) { final int mapRotation = dungeon.getRoom(reference).getRotation(); int[] coords = translate(x, y, mapRotation, 1, 1, 0); World.addGroundItem(item, Tile.of(instance.getLocalX(reference.getBaseX() + coords[0]), instance.getLocalY(reference.getBaseY() + coords[1]), 0)); } public boolean isFloorFree(RoomReference reference, int x, int y) { final int mapRotation = dungeon.getRoom(reference).getRotation(); int[] coords = translate(x, y, mapRotation, 1, 1, 0); return World.floorFree(0, instance.getLocalX(reference.getBaseX() + coords[0]), instance.getLocalY(reference.getBaseY() + coords[1])); } public Tile getRoomTile(RoomReference reference) { final int mapRotation = dungeon.getRoom(reference).getRotation(); int[] coords = translate(0, 0, mapRotation, 1, 1, 0); return Tile.of(instance.getLocalX(reference.getBaseX() + coords[0]), instance.getLocalY(reference.getBaseY() + coords[1]), 0); } public DungeonNPC spawnNPC(int id, int rotation, Tile tile, RoomReference reference, int type) { DungeonNPC n = null; if (type == DungeonConstants.BOSS_NPC) { if (id == 9965) n = new AsteaFrostweb(tile, this, reference); else if (id == 9948) n = new GluttonousBehemoth(tile, this, reference); else if (id == 9912) n = new LuminscentIcefiend(tile, this, reference); else if (id == 10059) n = new HobgoblinGeomancer(tile, this, reference); else if (id == 10040) n = new IcyBones(tile, this, reference); else if (id == 10024) n = new ToKashBloodChiller(tile, this, reference); else if (id == 10058) n = new DivineSkinweaver(id, tile, this, reference); else if (id >= 10629 && id <= 10693) n = new DungeonSkeletonBoss(id, tile, this, reference); else if (id == 10073) n = new BulwarkBeast(tile, this, reference); else if (id == 9767) n = new Rammernaut(tile, this, reference); else if (id == 9782) n = new Stomp(tile, this, reference); else if (id == 9898) n = new LakkTheRiftSplitter(tile, this, reference); else if (id == 9753) n = new Sagittare(tile, this, reference); else if (id == 9725) n = new NightGazerKhighorahk(tile, this, reference); else if (id == 9842) n = new LexicusRunewright(tile, this, reference); else if (id == 10128) n = new BalLakThePummeler(tile, this, reference); else if (id == 10143) n = new ShadowForgerIhlakhizan(tile, this, reference); else if (id == 11940 || id == 12044 || id == 11999) n = new SkeletalAdventurer(id == 11940 ? SkeletalAdventurer.MELEE : id == 11999 ? SkeletalAdventurer.MAGE : SkeletalAdventurer.RANGE, tile, this, reference); else if (id == 11812) n = new RuneboundBehemoth(tile, this, reference); else if (id == 11708) n = new Gravecreeper(tile, this, reference); else if (id == 11737 || id == 11895) n = new NecroLord(tile, this, reference); else if (id == 11925) n = new FleshspoilerHaasghenahk(tile, this, reference); else if (id == 11872) n = new YkLagorThunderous(tile, this, reference); else if (id == 12737) n = new WarpedGulega(tile, this, reference); else if (id == 12848) n = new Dreadnaut(tile, this, reference); else if (id == 12886) n = new HopeDevourer(tile, this, reference); else if (id == 12478) n = new WorldGorgerShukarhazh(tile, this, reference); else if (id == 12865) n = new Blink(tile, this, reference); else if (id == 12752) n = new KalGerWarmonger(tile, this, reference); else if (id == 10111) n = new UnholyCrossbearer(id, tile, this, reference); else n = new DungeonBoss(id, tile, this, reference); } else if (type == DungeonConstants.GUARDIAN_NPC) { n = new Guardian(id, tile, this, reference); visibleMap[reference.getRoomX()][reference.getRoomY()].addGuardian(n); } else if (type == DungeonConstants.FORGOTTEN_WARRIOR) { n = new ForgottenWarrior(id, tile, this, reference); visibleMap[reference.getRoomX()][reference.getRoomY()].addGuardian(n); } else if (type == DungeonConstants.FISH_SPOT_NPC) n = new DungeonFishSpot(id, tile, this, DungeoneeringFishing.Fish.values()[Utils.random(DungeoneeringFishing.Fish.values().length - 1)]); else if (type == DungeonConstants.SLAYER_NPC) n = new DungeonSlayerNPC(id, tile, this); else if (type == DungeonConstants.HUNTER_NPC) n = new DungeonHunterNPC(id, tile, this); else if (type == DungeonConstants.PUZZLE_NPC) { if (id == PoltergeistRoom.POLTERGEIST_ID) n = new Poltergeist(id, tile, this, reference); } else n = new DungeonNPC(id, tile, this); n.setFaceAngle(Utils.getAngleTo(Utils.ROTATION_DIR_X[(rotation + 3) & 0x3], Utils.ROTATION_DIR_Y[(rotation + 3) & 0x3])); return n; } public int getTargetLevel(int id, boolean boss, double multiplier) { double lvl = boss ? party.getCombatLevel() : party.getAverageCombatLevel(); int randomize = party.getComplexity() * 2 * party.getTeam().size(); lvl -= randomize; lvl += Utils.random(randomize * 2); lvl *= party.getDifficultyRatio(); lvl *= multiplier; lvl *= 1D - ((6D - party.getComplexity()) * 0.07D); if (party.getTeam().size() > 2 && id != 12752 && id != 11872 && id != 11708 && id != 12865) //blink lvl *= 0.7; return (int) (lvl < 1 ? 1 : lvl); } public Map getLevels(boolean boss, int level, int hitpoints) { return NPCCombatDefinitions.generateLevels(level, hitpoints/10, boss ? 120 : 100, boss ? 120 : 100); } public void updateGuardian(RoomReference reference) { if (visibleMap[reference.getRoomX()][reference.getRoomY()].removeGuardians()) { getRoom(reference).removeGuardianDoors(); for (Player player : party.getTeam()) { RoomReference playerReference = getCurrentRoomReference(player.getTile()); if (playerReference.getRoomX() == reference.getRoomX() && playerReference.getRoomY() == reference.getRoomY()) playMusic(player, reference); } } } public void exitDungeon(final Player player, final boolean logout) { resetItems(player, true, logout); party.remove(player, logout); player.stopAll(); player.getControllerManager().removeControllerWithoutCheck(); player.getControllerManager().startController(new DamonheimController()); resetTraps(player); if (player.getFamiliar() != null) player.getFamiliar().sendDeath(player); if (logout) { player.setTile(Tile.of(DungeonConstants.OUTSIDE, 2)); player.tele(Tile.of(DungeonConstants.OUTSIDE, 2)); } else { player.reset(); player.getDungManager().setRejoinKey(null); player.useStairs(-1, Tile.of(DungeonConstants.OUTSIDE, 2), 0, 3); player.getCombatDefinitions().removeDungeonneringBook(); player.getPackets().sendVarc(1725, 1); setWorldMap(player, false); removeMark(player); player.setLargeSceneView(false); player.setForceMultiArea(false); player.getInterfaceManager().removeOverlay(true); player.getMusicsManager().reset(); player.getAppearance().setBAS(-1); } } public void setWorldMap(Player player, boolean dungIcon) { player.getVars().setVarBit(6090, dungIcon ? 1 : 0); } public void endFarming() { for (OwnedObject obj : farmingPatches) obj.destroy(); farmingPatches.clear(); } private void resetTraps(Player player) { for (MastyxTrap trap : mastyxTraps) { if (!trap.getPlayerName().equals(player.getDisplayName())) continue; trap.finish(); } } public void endMastyxTraps() { for (MastyxTrap trap : mastyxTraps) trap.finish(); mastyxTraps.clear(); } public void removeDungeon() { ACTIVE_DUNGEONS.remove(key); } public void destroy() { if (isDestroyed()) return; endRewardsTimer(); endDestroyTimer(); endFarming(); endMastyxTraps(); removeDungeon(); partyDeaths.clear(); for (VisibleRoom[] element : visibleMap) for (VisibleRoom element2 : element) if (element2 != null) element2.destroy(); dungeon = null; instance.destroy(); } public void nextFloor() { //int maxFloor = DungeonUtils.getMaxFloor(party.getDungeoneeringLevel()); if (party.getMaxFloor() > party.getFloor()) party.setFloor(party.getFloor() + 1); if (tutorialMode) { int complexity = party.getComplexity(); if (party.getMaxComplexity() > complexity) party.setComplexity(complexity + 1); } destroy(); load(); } /* 1 = M.V.P. 2 = Leecher 3 = Berserker 4 = Sharpshooter 5 = Battle-mage 6 = Against All Odds 7 = Least Harmful 8 = Nine Lives 9 = Spontaneous Combustion 10 = Crafting Catastrophe 11 = D.I.Y. Disaster 12 = Fishing Folly 13 = Meat-shield 14 = Survivor 15 = Most Deaths 16 = Vengeance is Mine! 17 = Double K.O. 18 = Jack-of-all-trades 19 = Kill Stealer 20 = Knuckle Sandwich 21 = Gatherer 22 = David 23 = Goliath 24 = Master-of-none 25 = Untouchable 26 = Glutton 27 = Master Chef 28 = Party Magician 29 = 'A' for Effort 30 = Culinary Disaster 31 = Uneconomical Alcher 32 = Pickaxe Alcher 33 = Nothing Special 34 = Clever Girl 35 = Handyman 36 = I Can Has Heim Crab 37 = It's a Trap! 38 = Medic! 39 = Rest in Peace 40 = Tele-fail 41 = Too Little, Too Late 42 = Least I Ain't Chicken 43 = The Gate Escape 44 = Balanced! 45 = Ha-Trick! 46 = I Choose You! 47 = Beast Mode 48 = The Chief 49 = WoopWoopWoop! 50 = It's Too Easy! */ public Integer[] getAchievements(Player player) { //TODO List achievements = new ArrayList<>(); DungeonController controller = (DungeonController) player.getControllerManager().getController(); //solo achievements if (controller.isKilledBossWithLessThan10HP()) achievements.add(6); if (controller.getDeaths() == 8) achievements.add(8); else if (controller.getDeaths() == 0) achievements.add(14); if (controller.getDamage() != 0 && controller.getDamageReceived() == 0) achievements.add(25); if (party.getTeam().size() > 1) { //party achievements boolean mostMeleeDmg = true; boolean mostMageDmg = true; boolean mostRangeDmg = true; boolean leastDamage = true; boolean mostDmgReceived = true; boolean mostDeaths = true; boolean mostHealedDmg = true; for (Player teamMate : party.getTeam()) { if (teamMate == player) continue; DungeonController tmController = (DungeonController) teamMate.getControllerManager().getController(); if (tmController.getMeleeDamage() >= controller.getMeleeDamage()) mostMeleeDmg = false; if (tmController.getMageDamage() >= controller.getMageDamage()) mostMageDmg = false; if (tmController.getRangeDamage() >= controller.getRangeDamage()) mostRangeDmg = false; if (controller.getDamage() >= tmController.getDamage()) leastDamage = false; if (controller.getDamageReceived() <= tmController.getDamageReceived()) mostDmgReceived = false; if (controller.getDeaths() <= tmController.getDeaths()) mostDeaths = false; if (controller.getHealedDamage() <= tmController.getHealedDamage()) mostHealedDmg = false; } if (mostMeleeDmg && mostMageDmg && mostRangeDmg) achievements.add(1); if (leastDamage && mostDeaths) //leecher achievements.add(2); if (mostMeleeDmg) achievements.add(3); if (mostRangeDmg) achievements.add(4); if (mostMageDmg) achievements.add(5); if (leastDamage) achievements.add(7); if (mostDmgReceived) achievements.add(13); if (mostDeaths) achievements.add(15); if (mostHealedDmg) achievements.add(38); } if (achievements.isEmpty()) achievements.add(33); return achievements.toArray(new Integer[0]); } public void loadRewards() { stage = 2; for (Player player : party.getTeam()) { for (Item item : player.getInventory().getItems().array()) { if (DungManager.isBannedDungItem(item)) player.getInventory().deleteItem(item); } for (Item item : player.getEquipment().getItemsCopy()) { if (DungManager.isBannedDungItem(item)) player.getEquipment().deleteItem(item.getId(), item.getAmount()); } player.getAppearance().generateAppearanceData(); player.stopAll(); double multiplier = 1; if (!player.resizeable()) player.getInterfaceManager().sendInterface(933); else player.getInterfaceManager().sendOverlay(933, true); player.getPackets().sendRunScriptReverse(2275); //clears interface data from last run for (int i = 0; i < 5; i++) { Player partyPlayer = i >= party.getTeam().size() ? null : party.getTeam().get(i); player.getPackets().sendVarc(1198 + i, partyPlayer != null ? 1 : 0); //sets true that this player exists if (partyPlayer == null) continue; player.getPackets().sendVarcString(310 + i, partyPlayer.getDisplayName()); Integer[] achievements = getAchievements(partyPlayer); for (int i2 = 0; i2 < (Math.min(achievements.length, 6)); i2++) player.getPackets().sendVarc(1203 + (i * 6) + i2, achievements[i2]); } player.getPackets().setIFText(933, 331, Utils.formatTime((World.getServerTicks() - time) * 600)); player.getPackets().sendVarc(1187, party.getFloor()); player.getPackets().sendVarc(1188, party.getSize() + 1); //dungeon size, sets bonus aswell multiplier += DungeonConstants.DUNGEON_SIZE_BONUS[party.getSize()]; player.getPackets().sendVarc(1191, party.getTeam().size() * 10 + party.getDificulty()); //teamsize:dificulty multiplier += DungeonConstants.DUNGEON_DIFFICULTY_RATIO_BONUS[party.getTeam().size() - 1][party.getDificulty() - 1]; int levelMod = 0; if (getVisibleBonusRoomsCount() != 0) //no bonus rooms in c1, would be divide by 0 levelMod = getVisibleBonusRoomsCount() * 10000 / (dungeon.getRoomsCount() - dungeon.getCritCount()); player.getPackets().sendVarc(1195, levelMod); //dungeons rooms opened, sets bonus aswell multiplier += DungeonConstants.MAX_BONUS_ROOM * levelMod / 10000; levelMod = (getLevelModPerc() * 20) - 1000; player.getPackets().sendVarc(1236, levelMod); //sets level mod multiplier += ((double) levelMod) / 10000.0; player.getPackets().sendVarc(1196, party.isGuideMode() ? 1 : 0); //sets guidemode if (party.isGuideMode()) multiplier -= 0.05; player.getPackets().sendVarc(1319, DungeonUtils.getMaxFloor(player.getSkills().getLevelForXp(Constants.DUNGEONEERING))); player.getPackets().sendVarc(1320, party.getComplexity()); if (party.getComplexity() != 6) multiplier -= (DungeonConstants.COMPLEXITY_PENALTY_BASE[party.getSize()] + (5 - party.getComplexity()) * 0.06); double levelDiffPenalty = party.getLevelDiferencePenalty(player);//party.getMaxLevelDiference() > 70 ? DungeonConstants.UNBALANCED_PARTY_PENALTY : 0; player.getPackets().sendVarc(1321, (int) (levelDiffPenalty * 10000)); multiplier -= levelDiffPenalty; Integer deaths = partyDeaths.get(player.getUsername()); double countedDeaths = Math.min(deaths == null ? 0 : deaths, 6); multiplier *= (1.0 - (countedDeaths * 0.1)); //adds FLAT 10% reduction per death, upto 6 //base xp is based on a ton of factors, including opened rooms, resources harvested, ... but this is most imporant one double floorXP = getFloorXP(party.getFloor(), party.getSize(), getVisibleRoomsCount()); boolean tickedOff = player.getDungManager().isTickedOff(party.getFloor()); if (!tickedOff) player.getDungManager().tickOff(party.getFloor()); else { int[] range = DungeonUtils.getFloorThemeRange(party.getFloor()); for (int floor = range[0]; floor <= range[1]; floor++) { if (player.getDungManager().getMaxFloor() < floor) break; if (!player.getDungManager().isTickedOff(floor)) { player.sendMessage(""Since you have previously completed this floor, floor "" + floor + "" was instead ticked-off.""); player.getDungManager().tickOff(floor); floorXP = getFloorXP(floor, party.getSize(), getVisibleRoomsCount()); tickedOff = false; break; } } } double prestigeXP = tickedOff ? 0 : getFloorXP(player.getDungManager().getPrestige(), party.getSize(), getVisibleRoomsCount()); player.getVars().setVarBit(7550, player.getDungManager().getCurrentProgress()); player.getVars().setVarBit(7551, player.getDungManager().getPreviousProgress()); double averageXP = (floorXP + prestigeXP) / 2; multiplier = Math.max(0.1, multiplier); double totalXp = averageXP * multiplier; int tokens = (int) (totalXp / 10.0); player.getPackets().sendVarc(1237, (int) (floorXP * 10)); player.getPackets().sendVarc(1238, (int) (prestigeXP * 10)); player.getPackets().sendVarc(1239, (int) (averageXP * 10)); player.getSkills().addXp(Constants.DUNGEONEERING, totalXp); //force rs xp, cuz we do * xp rate in calcs to make inter show correct xp player.getDungManager().addTokens(tokens); player.getMusicsManager().forcePlayMusic(770); player.incrementCount(""Dungeons completed""); player.incrementCount(DungeonUtils.getFloorTypeName(party.getFloor()) + "" floors completed""); player.incrementCount(DungeonUtils.getSizeName(party.getSize()) + "" floors completed""); if (!tickedOff) { if (DungeonUtils.getMaxFloor(player.getSkills().getLevelForXp(Constants.DUNGEONEERING)) < party.getFloor() + 1) player.sendMessage(""The next floor is not available at your dungeoneering level. Consider resetting your progress to gain best ongoing rate of xp.""); } else { player.sendMessage(""Warning""); player.sendMessage("":""); player.sendMessage(""You have already completed all the available floors of this theme and thus cannot be awarded prestige xp until you reset your progress or switch theme.""); } if (party.getFloor() == player.getDungManager().getMaxFloor() && party.getFloor() < DungeonUtils.getMaxFloor(player.getSkills().getLevelForXp(Constants.DUNGEONEERING))) player.getDungManager().increaseMaxFloor(); if (player.getDungManager().getMaxComplexity() < 6) player.getDungManager().increaseMaxComplexity(); if (player.getFamiliar() != null) player.getFamiliar().sendDeath(player); } clearGuardians(); } public static int getFloorXP(int floor, int size, int roomsOpened) { double baseXP = 0.16*(floor*floor*floor)+0.28*(floor*floor)+76.94*floor+100.0; double roomMod = 1.0; double sizeMod = 1.0; switch(size) { case 0 -> roomMod = roomsOpened / 16.0; case 1 -> { roomMod = roomsOpened / 32.0; sizeMod = 2.0; } case 2 -> { roomMod = roomsOpened / 64.0; sizeMod = 3.5; } } return (int) (baseXP * sizeMod * roomMod); } public static void printXP(int floor, int size, int prestige, int roomsOpened) { int baseXp = getFloorXP(floor, size, roomsOpened); int presXp = getFloorXP(prestige, size, roomsOpened); int avgXp = (baseXp+presXp) / 2; Logger.debug(DungeonManager.class, ""printXP"", ""~~~Experience for floor "" + floor + "" size: "" + size + "" roomsOpened: "" + roomsOpened + ""~~~""); Logger.debug(DungeonManager.class, ""printXP"", ""Base XP: "" + baseXp); Logger.debug(DungeonManager.class, ""printXP"", ""Prestige "" + prestige + "" XP:"" + presXp); Logger.debug(DungeonManager.class, ""printXP"", ""Average XP: "" + avgXp); Logger.debug(DungeonManager.class, ""printXP"", ""Maximum possible XP for floor: "" + ((int) (avgXp * 1.56))); } public void voteToMoveOn(Player player) { //loadRewards(); if (rewardsTimer == null) setRewardsTimer(); rewardsTimer.increaseReadyCount(); } public void ready(Player player) { int index = party.getIndex(player); if (rewardsTimer == null) setRewardsTimer(); rewardsTimer.increaseReadyCount(); for (Player p2 : party.getTeam()) p2.getPackets().sendVarc(1397 + index, 1); } public DungeonPartyManager getParty() { return party; } public void setRewardsTimer() { WorldTasks.scheduleLooping(rewardsTimer = new RewardsTimer(), 1, 9); } public void setDestroyTimer() { WorldTasks.scheduleLooping(destroyTimer = new DestroyTimer(), 1, 9); } public void setMark(Entity target, boolean mark) { if (mark) for (Player player : party.getTeam()) player.getHintIconsManager().addHintIcon(6, target, 0, -1, true); //6th slot else removeMark(); if (target instanceof DungeonNPC npc) npc.setMarked(mark); } public void setGroupGatestone(Tile groupGatestone) { this.groupGatestone = groupGatestone; } public Tile getGroupGatestone() { if (groupGatestone == null) { Player player = party.getGateStonePlayer(); if (player != null) return Tile.of(player.getTile()); } return groupGatestone; } public void resetGatestone() { groupGatestone = null; } public void removeMark() { for (Player player : party.getTeam()) removeMark(player); } public void removeMark(Player player) { player.getHintIconsManager().removeHintIcon(6); } public void endDestroyTimer() { if (destroyTimer != null) { destroyTimer.stop(); destroyTimer = null; } } public void endRewardsTimer() { if (rewardsTimer != null) { rewardsTimer.stop(); rewardsTimer = null; } } private class DestroyTimer extends Task { private long timeLeft; public DestroyTimer() { timeLeft = 600; //10min } @Override public void run() { try { if (timeLeft > 0) { timeLeft -= 5; return; } destroy(); } catch (Throwable e) { Logger.handle(DestroyTimer.class, ""run"", e); } } } private class RewardsTimer extends Task { private long timeLeft; private boolean gaveRewards; public RewardsTimer() { timeLeft = party.getTeam().size() * 60L; } public void increaseReadyCount() { int reduce = (int) (gaveRewards ? ((double) 45 / (double) party.getTeam().size()) : 60); timeLeft = timeLeft > reduce ? timeLeft - reduce : 0; } @Override public void run() { try { if (timeLeft > 0) { for (Player player : party.getTeam()) player.sendMessage(gaveRewards ? (""Time until next dungeon: "" + timeLeft) : (timeLeft + "" seconds until dungeon ends."")); timeLeft -= 5; } else if (!gaveRewards) { gaveRewards = true; timeLeft = 45; loadRewards(); } else nextFloor(); } catch (Throwable e) { Logger.handle(RewardsTimer.class, ""run"", e); } } } public void setDungeon() { key = party.getLeader() + ""_"" + KEY_MAKER.getAndIncrement(); ACTIVE_DUNGEONS.put(key, this); for (Player player : party.getTeam()) { player.getDungManager().setRejoinKey(key); player.getInterfaceManager().removeOverlay(true); player.getInterfaceManager().removeCentralInterface(); } } public static void checkRejoin(Player player) { Object key = player.getDungManager().getRejoinKey(); if (key == null) return; DungeonManager dungeon = ACTIVE_DUNGEONS.get(key); if (dungeon == null || !dungeon.hasLoadedNoRewardScreen()) { player.getDungManager().setRejoinKey(null); return; } dungeon.rejoinParty(player); } public void load() { party.lockParty(); visibleMap = new VisibleRoom[DungeonConstants.DUNGEON_RATIO[party.getSize()][0]][DungeonConstants.DUNGEON_RATIO[party.getSize()][1]]; AsyncTaskExecutor.execute(() -> { try { clearKeyList(); dungeon = new Dungeon(DungeonManager.this, party.getFloor(), party.getComplexity(), party.getSize()); time = World.getServerTicks(); instance = Instance.of(DungeonConstants.OUTSIDE, dungeon.getMapWidth() * 2, dungeon.getMapHeight() * 2); instance.clearMap(new int[1]).thenAccept(e -> { setDungeon(); loadRoom(dungeon.getStartRoomReference()); stage = 1; }); } catch (Throwable e) { Logger.handle(DungeonManager.class, ""load"", e); } }); } public boolean hasStarted() { return stage != 0; } public boolean isAtRewardsScreen() { return stage == 2; } public boolean hasLoadedNoRewardScreen() { return stage == 1; } public void openMap(Player player) { player.getInterfaceManager().sendInterface(942); player.getPackets().sendRunScriptReverse(3277); //clear the map if theres any setted int protocol = party.getSize() == DungeonConstants.LARGE_DUNGEON ? 0 : party.getSize() == DungeonConstants.MEDIUM_DUNGEON ? 2 : 1; for (int x = 0; x < visibleMap.length; x++) for (int y = 0; y < visibleMap[x].length; y++) if (visibleMap[x][y] != null) { //means exists Room room = getRoom(new RoomReference(x, y)); boolean highLight = party.isGuideMode() && room.isCritPath(); player.getPackets().sendRunScriptReverse(3278, protocol, getMapIconSprite(room, highLight), y, x); if (room.getRoom() instanceof StartRoom) player.getPackets().sendRunScriptReverse(3280, protocol, y, x); else if (room.getRoom() instanceof BossRoom) player.getPackets().sendRunScriptReverse(3281, protocol, y, x); if (room.hasNorthDoor() && visibleMap[x][y + 1] == null) { Room unknownR = getRoom(new RoomReference(x, y + 1)); highLight = party.isGuideMode() && unknownR.isCritPath(); player.getPackets().sendRunScriptReverse(3278, protocol, getMapIconSprite(DungeonConstants.SOUTH_DOOR, highLight), y + 1, x); } if (room.hasSouthDoor() && visibleMap[x][y - 1] == null) { Room unknownR = getRoom(new RoomReference(x, y - 1)); highLight = party.isGuideMode() && unknownR.isCritPath(); player.getPackets().sendRunScriptReverse(3278, protocol, getMapIconSprite(DungeonConstants.NORTH_DOOR, highLight), y - 1, x); } if (room.hasEastDoor() && visibleMap[x + 1][y] == null) { Room unknownR = getRoom(new RoomReference(x + 1, y)); highLight = party.isGuideMode() && unknownR.isCritPath(); player.getPackets().sendRunScriptReverse(3278, protocol, getMapIconSprite(DungeonConstants.WEST_DOOR, highLight), y, x + 1); } if (room.hasWestDoor() && visibleMap[x - 1][y] == null) { Room unknownR = getRoom(new RoomReference(x - 1, y)); highLight = party.isGuideMode() && unknownR.isCritPath(); player.getPackets().sendRunScriptReverse(3278, protocol, getMapIconSprite(DungeonConstants.EAST_DOOR, highLight), y, x - 1); } } int index = 1; for (Player p2 : party.getTeam()) { RoomReference reference = getCurrentRoomReference(p2.getTile()); player.getPackets().sendRunScriptReverse(3279, p2.getDisplayName(), protocol, index++, reference.getRoomY(), reference.getRoomX()); } } public int getMapIconSprite(int direction, boolean highLight) { for (MapRoomIcon icon : MapRoomIcon.values()) { if (icon.isOpen()) continue; if (icon.hasDoor(direction)) return icon.getSpriteId() + (highLight ? MapRoomIcon.values().length : 0); } return 2879; } public int getMapIconSprite(Room room, boolean highLight) { for (MapRoomIcon icon : MapRoomIcon.values()) { if (!icon.isOpen()) continue; if (icon.hasNorthDoor() == room.hasNorthDoor() && icon.hasSouthDoor() == room.hasSouthDoor() && icon.hasWestDoor() == room.hasWestDoor() && icon.hasEastDoor() == room.hasEastDoor()) return icon.getSpriteId() + (highLight ? MapRoomIcon.values().length : 0); } return 2878; } public void openStairs(RoomReference reference) { Room room = getRoom(reference); int type = 0; if (room.getRoom().getChunkX() == 26 && room.getRoom().getChunkY() == 640) //unholy cursed type = 1; else if (room.getRoom().getChunkX() == 30 && room.getRoom().getChunkY() == 656) //stomp type = 2; else if ((room.getRoom().getChunkX() == 30 && room.getRoom().getChunkY() == 672) || (room.getRoom().getChunkX() == 24 && room.getRoom().getChunkY() == 690)) //necromancer) type = 3; else if (room.getRoom().getChunkX() == 26 && room.getRoom().getChunkY() == 690) //world-gorger type = 4; else if (room.getRoom().getChunkX() == 24 && room.getRoom().getChunkY() == 688) //blink type = 5; spawnObject(reference, DungeonConstants.LADDERS[party.getFloorType()], ObjectType.SCENERY_INTERACT, (type == 2 || type == 3) ? 0 : 3, type == 4 ? 11 : type == 3 ? 15 : type == 2 ? 14 : 7, type == 5 ? 14 : (type == 3 || type == 2) ? 3 : type == 1 ? 11 : 15); getVisibleRoom(reference).setNoMusic(); for (Player player : party.getTeam()) { if (!isAtBossRoom(player.getTile())) continue; player.jingle(415); playMusic(player, reference); } } public List getFarmingPatches() { return farmingPatches; } public void addMastyxTrap(MastyxTrap mastyxTrap) { mastyxTraps.add(mastyxTrap); } public List getMastyxTraps() { return mastyxTraps; } public void removeMastyxTrap(MastyxTrap mastyxTrap) { mastyxTraps.remove(mastyxTrap); mastyxTrap.finish(); } public void message(RoomReference reference, String message) { for (Player player : party.getTeam()) if (reference.equals(getCurrentRoomReference(player.getTile()))) player.sendMessage(message); } public void showBar(RoomReference reference, String name, int percentage) { for (Player player : party.getTeam()) { RoomReference current = getCurrentRoomReference(player.getTile()); if (reference.getRoomX() == current.getRoomX() && reference.getRoomY() == current.getRoomY() && player.getControllerManager().getController() instanceof DungeonController ctrl) { ctrl.showBar(true, name); ctrl.sendBarPercentage(percentage); } } } public void hideBar(RoomReference reference) { for (Player player : party.getTeam()) { RoomReference current = getCurrentRoomReference(player.getTile()); if (reference.getRoomX() == current.getRoomX() && reference.getRoomY() == current.getRoomY() && player.getControllerManager().getController() instanceof DungeonController ctrl) ctrl.showBar(false, null); } } public Map getPartyDeaths() { return partyDeaths; } /* * Use get npc instead * this being used because gravecreeper gets removed when using special :/ */ @Deprecated public DungeonBoss getTemporaryBoss() { return temporaryBoss; } public void setTemporaryBoss(DungeonBoss temporaryBoss) { this.temporaryBoss = temporaryBoss; } public Dungeon getDungeon() { return dungeon; } }" "package com.rs.game.content.skills.dungeoneering; public final class DungeonPartyManager { private String leader; // username private int floor; private long seed; public boolean customSeed; private int complexity; private int size; private int difficulty; private boolean guideMode; private final CopyOnWriteArrayList team; private DungeonManager dungeon; public DungeonPartyManager() { team = new CopyOnWriteArrayList<>(); } public void setDefaults() { floor = 1; complexity = 6; difficulty = team.size(); guideMode = false; } public void leaveParty(Player player, boolean logout) { if (dungeon != null) dungeon.exitDungeon(player, logout); else { player.setForceMultiArea(false); player.stopAll(); remove(player, logout); } player.getDungManager().refresh(); player.getInterfaceManager().removeOverlay(); } public void remove(Player player, boolean logout) { team.remove(player); player.getDungManager().setParty(null); player.getDungManager().expireInvitation(); player.getDungManager().refreshPartyDetailsComponents(); player.sendMessage(""You leave the party.""); player.getDungManager().refreshNames(); if (dungeon != null && team.isEmpty()) { if (dungeon.hasLoadedNoRewardScreen() && logout) // destroy timer cant exist with a party member on anyway, team must be 0 dungeon.setDestroyTimer(); else dungeon.destroy(); } else for (Player p2 : team) { p2.sendMessage(player.getDisplayName() + "" has left the party.""); if (isLeader(player)) setLeader(p2); refreshPartyDetails(p2); } player.getDungManager().refresh(); } public void refreshPartyDetails(Player player) { player.getDungManager().refreshPartyDetailsComponents(); player.getDungManager().refresh(); } public void add(Player player) { for (Player p2 : team) p2.sendMessage(player.getDisplayName() + "" has joined the party.""); team.add(player); player.getDungManager().setParty(this); if (team.size() == 1) { setLeader(player); if (dungeon != null) dungeon.endDestroyTimer(); } else player.sendMessage(""You join the party.""); player.getDungManager().refresh(); } public boolean isLeader(Player player) { return player.getUsername().equals(leader); } public void setLeader(Player player) { leader = player.getUsername(); if (team.size() > 1) if (!team.getFirst().getUsername().equals(leader)) { Player positionZero = team.getFirst(); team.remove(player); team.set(0, player); team.add(positionZero); } player.sendMessage(""You have been set as the party leader.""); player.getDungManager().refresh(); } public void lockParty() { for (Player player : team) { player.stopAll(); player.lock(); } } public void start() { if (dungeon != null) return; dungeon = new DungeonManager(this); } public long getStartingSeed() { return seed; } /** * Creates a seed for a dungeon to run off of * @param seed starting seed */ public void setStartingSeed(long seed) { customSeed = true; this.seed = seed; } public int getComplexity() { return complexity; } public void setComplexity(int complexity) { this.complexity = complexity; for (Player player : team) player.getDungManager().refreshComplexity(); } public void setSize(int size) { this.size = size; } public void setDificulty(int dificulty) { if (dificulty > team.size()) dificulty = team.size(); difficulty = dificulty; } public int getFloor() { return floor; } public String getLeader() { return leader; } public Player getLeaderPlayer() { for (Player player : team) if (player.getUsername().equals(leader)) return player; return null; } public Player getGateStonePlayer() { for (Player player : team) if (player.getInventory().containsItem(DungeonConstants.GROUP_GATESTONE, 1)) return player; return null; } public void setFloor(int floor) { this.floor = floor; for (Player player : team) player.getDungManager().refresh(); } public int getFloorType() { return DungeonUtils.getFloorType(floor); } public int getDungeoneeringLevel() { int level = 120; for (Player player : team) { int playerLevel = player.getSkills().getLevelForXp(Constants.DUNGEONEERING); if (playerLevel < level) level = playerLevel; } return level; } public double getLevelDiferencePenalty(Player player) { int average = getAverageCombatLevel(); int cb = player.getSkills().getCombatLevelWithSummoning(); double diff = Math.abs(cb - average); return (diff > 50 ? ((diff - 50) * 0.01) : 0); } public int getMaxLevelDifference() { if (team.size() <= 1) return 0; int maxLevel = 0; int minLevel = 138; for (Player player : team) { int level = player.getSkills().getCombatLevelWithSummoning(); if (maxLevel < level) maxLevel = level; if (minLevel > level) minLevel = level; } return Math.abs(maxLevel - minLevel); } public DungeonManager getDungeon() { return dungeon; } public int getMaxFloor() { int floor = 60; for (Player player : team) if (player.getDungManager().getMaxFloor() < floor) floor = player.getDungManager().getMaxFloor(); return floor; } public int getMaxComplexity() { int complexity = 6; for (Player player : team) if (player.getDungManager().getMaxComplexity() < complexity) complexity = player.getDungManager().getMaxComplexity(); return complexity; } public int getCombatLevel() { int level = 0; for (Player player : team) level += player.getSkills().getCombatLevelWithSummoning(); return team.isEmpty() ? 138 : level; } public int getAverageCombatLevel() { if (team.isEmpty()) return 138; int level = 0; for (Player player : team) level += player.getSkills().getCombatLevelWithSummoning(); return level / team.size(); } public int getDefenceLevel() { if (team.isEmpty()) return 99; int level = 0; for (Player player : team) level += player.getSkills().getLevelForXp(Constants.DEFENSE); return level / team.size(); } public double getDifficultyRatio() { if (difficulty > team.size()) return 1; return 0.7 + (((double) difficulty / (double) team.size()) * 0.3); } public int getMaxLevel(int skill) { if (team.isEmpty()) return 1; int level = 0; for (Player player : team) { int lvl = player.getSkills().getLevelForXp(skill); if (lvl > level) level = lvl; } return level; } public int getAttackLevel() { if (team.isEmpty()) return 99; int level = 0; for (Player player : team) level += player.getSkills().getLevelForXp(Constants.ATTACK); return level / team.size(); } public int getMagicLevel() { if (team.isEmpty()) return 99; int level = 0; for (Player player : team) level += player.getSkills().getLevelForXp(Constants.MAGIC); return level / team.size(); } public int getRangeLevel() { if (team.isEmpty()) return 99; int level = 0; for (Player player : team) level += player.getSkills().getLevelForXp(Constants.RANGE); return level / team.size(); } public CopyOnWriteArrayList getTeam() { return team; } public int getSize() { return size; } public int getIndex(Player player) { int index = 0; for (Player p2 : team) { if (p2 == player) return index; index++; } return 0; } public int getDificulty() { if (difficulty > team.size()) difficulty = team.size(); return difficulty; } public boolean isGuideMode() { return guideMode || complexity <= 4; } /* * dont use for dung itself */ public boolean getGuideMode() { return guideMode; } public void setGuideMode(boolean guideMode) { this.guideMode = guideMode; } }" "package com.rs.game.content.skills.dungeoneering; public class DungeonPartyPlayer { private final Player player; private int deaths; public DungeonPartyPlayer(Player player) { this.player = player; } public Player getPlayer() { return player; } public void refreshDeaths() { player.getVars().setVarBit(2365, deaths); //deaths } public void increaseDeaths() { if (deaths == 15) return; deaths++; refreshDeaths(); } }" "package com.rs.game.content.skills.dungeoneering; public class DungeonResourceShop { public static final int RESOURCE_SHOP = 956, RESOURCE_SHOP_INV = 957; private static final int[] CS2MAPS = { 2989, 2991, 2993, 2987 }; public static void openResourceShop(final Player player, int complexity) { if (complexity <= 1) { player.npcDialogue(DungeonConstants.SMUGGLER, HeadE.CALM_TALK, ""Sorry, but I don't have anything to sell.""); return; } player.getPackets().sendVarc(1320, complexity); player.getTempAttribs().setI(""DUNG_COMPLEXITY"", complexity); player.getPackets().setIFRightClickOps(RESOURCE_SHOP, 24, 0, 429, 0, 1, 2, 3, 4); player.getPackets().setIFRightClickOps(RESOURCE_SHOP_INV, 0, 0, 27, 0, 1, 2, 3, 4, 5); player.getPackets().sendInterSetItemsOptionsScript(RESOURCE_SHOP_INV, 0, 93, 4, 7, ""Value"", ""Sell 1"", ""Sell 5"", ""Sell 10"", ""Sell 50"", ""Examine""); player.getInterfaceManager().sendInterface(RESOURCE_SHOP); player.getInterfaceManager().sendInventoryInterface(RESOURCE_SHOP_INV); player.setCloseInterfacesEvent(() -> player.getTempAttribs().removeI(""DUNG_COMPLEXITY"")); } public static void handlePurchaseOptions(Player player, int slotId, int quantity) { int complexity = player.getTempAttribs().getI(""DUNG_COMPLEXITY""); if (complexity <= 1) // not error, just hacking return; int baseMap = CS2MAPS[complexity >= 5 ? 3 : complexity - 2]; int slot = (slotId - 2) / 5; EnumDefinitions map = EnumDefinitions.getEnum(baseMap); if (slot >= map.getSize()) { slot -= map.getSize(); map = EnumDefinitions.getEnum(baseMap + 1); } int item = map.getIntValue(slot); if (item == -1) return; ItemDefinitions def = ItemDefinitions.getDefs(item); int value = (int) (def.getValue() * def.getDungShopValueMultiplier()); if (quantity == -1) { player.sendMessage(def.getName() + "": currently costs "" + value + "" coins.""); return; } int coinsCount = player.getInventory().getAmountOf(DungeonConstants.RUSTY_COINS); int price = value * quantity; if (price > coinsCount) { quantity = coinsCount / value; price = quantity * value; player.sendMessage(""You don't have enough money to buy that!""); } int openSlots = player.getInventory().getFreeSlots(); if (!def.isStackable()) quantity = Math.min(quantity, openSlots); if (quantity == 0) return; if (player.getInventory().addItem(item, quantity)) player.getInventory().deleteItem(new Item(DungeonConstants.RUSTY_COINS, price)); } public static void handleSellOptions(Player player, int slotId, int itemId, int quantity) { Item item = player.getInventory().getItem(slotId); if (item == null || itemId != item.getId()) return; if (item.getDefinitions().name.contains(""key"") || item.getDefinitions().name.contains(""(b)"") || item.getId() == DungeonConstants.RUSTY_COINS || item.getName().toLowerCase().contains(""of kinship"") || item.getName().toLowerCase().contains(""gatestone"")) { player.sendMessage(""You can't sell this item.""); return; } ItemDefinitions def = item.getDefinitions(); int value = (int) ((def.getValue() * def.getDungShopValueMultiplier()) * 0.3D); if (quantity == -1) { player.sendMessage(def.getName() + "": shop will buy for "" + value + "". Right-click the item to sell.""); return; } int itemCount = player.getInventory().getAmountOf(item.getId()); if (quantity > itemCount) quantity = itemCount; int price = value * quantity; player.getInventory().deleteItem(new Item(item.getId(), quantity)); player.getInventory().addItem(DungeonConstants.RUSTY_COINS, price); } }" "package com.rs.game.content.skills.dungeoneering; @PluginEventHandler public class DungeonRewards { public enum HerbicideSetting { GUAM(Herbs.GUAM, 32), MARRENTILL(Herbs.MARRENTILL, 33), TARROMIN(Herbs.TARROMIN, 34), HARRALANDER(Herbs.HARRALANDER, 35), RANARR(Herbs.RANARR, 36), TOADFLAX(Herbs.TOADFLAX, 37), SPIRIT_WEED(Herbs.SPIRIT_WEED, 38), IRIT(Herbs.IRIT, 39), WERGALI(Herbs.WERGALI, 40), AVANTOE(Herbs.AVANTOE, 41), KWUARM(Herbs.KWUARM, 42), SNAPDRAGON(Herbs.SNAPDRAGON, 43), CADANTINE(Herbs.CADANTINE, 44), LANTADYME(Herbs.LANTADYME, 45), DWARF_WEED(Herbs.DWARF_WEED, 46), FELLSTALK(Herbs.FELLSTALK, 47), TORSTOL(Herbs.TORSTOL, 50); private static final Map BY_GRIMY = new HashMap<>(); static { for (HerbicideSetting setting : values()) BY_GRIMY.put(setting.getHerb().getHerbId(), setting); } public static HerbicideSetting forGrimy(int herbId) { return BY_GRIMY.get(herbId); } private final Herbs herb; private final int buttonId; HerbicideSetting(Herbs herb, int buttonId) { this.herb = herb; this.buttonId = buttonId; } public int getButtonId() { return buttonId; } public Herbs getHerb() { return herb; } } public enum DungeonReward { BONECRUSHER(18337, 0, 21, 34000), HERBICIDE(19675, 5, 21, 34000), SCROLL_OF_LIFE(18336, 15, 25, 10000), SCROLL_OF_CLEANSING(19890, 40, 49, 20000), LONGBOW_SIGHT(18330, 45, 45, 10000), AMULET_OF_ZEALOTS(19892, 85, 48, 40000), ANTI_POISON_TOTEM(18340, 110, 60, 44000), SCROLL_OF_EFFICIENCY(19670, 105, 55, 20000), SCROLL_OF_AUGURY(18344, 150, 77, 153000), SCROLL_OF_RIGOUR(18839, 145, 74, 140000), SCROLL_OF_RENEWAL(18343, 125, 65, 107000), MERCENARY_GLOVES(18347, 140, 73, 48500), TOME_OF_FROST(18346, 80, 48, 43000), ARCANE_PULSE_NECKLACE(18333, 20, 30, 6500), GRAVITE_SHORTBOW(18373, 70, 45, 40000), GRAVITE_LONGSWORD(18367, 55, 45, 40000), GRAVITE_RAPIER(18365, 50, 45, 40000), GRAVITE_STAFF(18371, 65, 45, 40000), GRAVITE_2H(18369, 60, 45, 40000), ARCANE_BLAST_NECKLACE(18334, 90, 50, 15500), RING_OF_VIGOUR(19669, 120, 62, 50000), ARCANE_STREAM_NECKLACE(18335, 130, 70, 30500), CHAOTIC_RAPIER(18349, 155, 80, 200000), CHAOTIC_LONGSWORD(18351, 160, 80, 200000), CHAOTIC_MAUL(18353, 165, 80, 200000), CHAOTIC_STAFF(18355, 170, 80, 200000), CHAOTIC_CROSSBOW(18357, 175, 80, 200000), CHAOTIC_KITESHIELD(18359, 180, 80, 200000), EAGLE_EYE_KITESHIELD(18361, 185, 80, 200000), FARSEER_KITESHIELD(18363, 190, 80, 200000), SNEAKERPEEPER(19894, 195, 80, 85000), TWISTED_NECKLACE(19886, 25, 30, 8500), DRAGONTOOTH_NECKLACE(19887, 115, 60, 17000), DEMONHORN_NECKLACE(19888, 200, 90, 35000), GEM_BAG(18338, 10, 25, 2000), SPIRIT_CAPE(19893, 95, 50, 45000), COAL_BAG(18339, 35, 35, 4000); private static final Map rewards = new HashMap<>(); public static DungeonReward forId(int id) { return rewards.get(id); } static { for (DungeonReward monster : DungeonReward.values()) rewards.put(monster.slotId, monster); } private final int id, req, cost, slotId; private final String name; DungeonReward(int id, int slotId, int req, int cost) { this.id = id; this.req = req; this.cost = cost; this.slotId = slotId; this.name = ItemDefinitions.getDefs(id).getName(); } public int getId() { return id; } public String getName() { return name; } public int getCost() { return cost; } public int getSlotId() { return slotId; } public int getRequirement() { return req; } } public static void openRewardsShop(Player player) { player.getInterfaceManager().sendInterface(940); player.getPackets().setIFEvents(new IFEvents(940, 2, 0, 205).enableRightClickOptions(0,1,2,3,4,5,6,9)); refresh(player); } public static void refresh(Player player) { player.getPackets().setIFText(940, 31, """" + player.getDungManager().getTokens()); } public static void openHerbSelection(Player player) { for(HerbicideSetting setting : player.herbicideSettings) player.getPackets().setIFGraphic(1006, setting.getButtonId(), 2548); player.getInterfaceManager().sendInterface(1006); } public static ButtonClickHandler handleHerbicideButtons = new ButtonClickHandler(1006, e -> { HerbicideSetting setting = null; for (HerbicideSetting settings : HerbicideSetting.values()) if (settings.getButtonId() == e.getComponentId()) setting = settings; if (setting != null) if (e.getPlayer().herbicideSettings.contains(setting)) { e.getPlayer().herbicideSettings.remove(setting); e.getPlayer().getPackets().setIFGraphic(1006, setting.getButtonId(), 2549); } else { e.getPlayer().herbicideSettings.add(setting); e.getPlayer().getPackets().setIFGraphic(1006, setting.getButtonId(), 2548); } }); public static ButtonClickHandler handleRewardsInter = new ButtonClickHandler(940, e -> { if (e.getComponentId() == 64 && e.getPacket() == ClientPacket.IF_OP1) { if (e.getPlayer().getTempAttribs().getO(""dungReward"") != null) { DungeonReward reward = e.getPlayer().getTempAttribs().getO(""dungReward""); if (reward != null) { if (e.getPlayer().getSkills().getLevelForXp(Constants.DUNGEONEERING) < reward.getRequirement()) { e.getPlayer().sendMessage(""You need "" + reward.getRequirement() + "" dungeoneering to buy this reward.""); return; } if (e.getPlayer().getDungManager().getTokens() < reward.getCost()) { e.getPlayer().sendMessage(""You need "" + reward.getCost() + "" dungeoneering tokens to buy this reward.""); return; } } else e.getPlayer().sendMessage(""You must choose a reward before trying to buy something.""); e.getPlayer().getPackets().setIFHidden(940, 42, false); } return; } if (e.getComponentId() == 48) { DungeonReward reward = e.getPlayer().getTempAttribs().getO(""dungReward""); if (reward != null && e.getPlayer().getDungManager().getTokens() >= reward.getCost()) if (e.getPlayer().getInventory().hasFreeSlots()) { if (reward.getId() >= 18349 && reward.getId() <= 18374) { Item rew = new Item(reward.getId(), 1); rew.addMetaData(""combatCharges"", 12000); e.getPlayer().getInventory().addItem(rew); } else e.getPlayer().getInventory().addItem(reward.getId(), 1); e.getPlayer().getDungManager().removeTokens(reward.getCost()); } else e.getPlayer().sendMessage(""You don't have enough inventory space.""); refresh(e.getPlayer()); e.getPlayer().getPackets().setIFHidden(940, 42, true); } if (e.getComponentId() == 50) e.getPlayer().getPackets().setIFHidden(940, 42, true); if (e.getComponentId() == 2) { DungeonReward reward = DungeonReward.forId(e.getSlotId()); if (reward == null) { e.getPlayer().getTempAttribs().removeO(""dungReward""); e.getPlayer().sendMessage(""Reward currently not supported. "" + (e.getPlayer().hasRights(Rights.DEVELOPER) ? e.getSlotId() : """")); return; } e.getPlayer().getTempAttribs().setO(""dungReward"", reward); } }); }" "package com.rs.game.content.skills.dungeoneering; public class DungeonStructure { private RoomNode base; private final RoomNode[][] rooms; private List roomList; private final List availableKeys = IntStream.rangeClosed(0, 63).boxed().collect(Collectors.toList()); private final Random random; private final int complexity; private final int size; public DungeonStructure(int size, Random random, int complexity) { this.complexity = complexity; this.size = size; this.random = random; rooms = new RoomNode[DungeonConstants.DUNGEON_RATIO[size][0]][DungeonConstants.DUNGEON_RATIO[size][1]]; Collections.shuffle(availableKeys, random); generate(); } private void generate() { int x = random.nextInt(rooms.length); int y = random.nextInt(rooms[0].length); base = new RoomNode(null, x, y); roomList = new LinkedList<>(); addRoom(base); List queue = new ArrayList<>(); queue.add(new Point(getBase().x - 1, getBase().y)); queue.add(new Point(getBase().x + 1, getBase().y)); queue.add(new Point(getBase().x, getBase().y - 1)); queue.add(new Point(getBase().x, getBase().y + 1)); //Generate full dungeon while (!queue.isEmpty()) { Point next = random(queue); //Ensure the edge is within the dungeon boundary and it doesn't already exist if (next.x < 0 || next.y < 0 || next.x >= rooms.length || next.y >= rooms[0].length || getRoom(next.x, next.y) != null) continue; //Connect this edge to a random neighboring room RoomNode parent = randomParent(next.x, next.y); RoomNode room = new RoomNode(parent, next.x, next.y); addRoom(room); queue.add(new Point(next.x - 1, next.y)); queue.add(new Point(next.x + 1, next.y)); queue.add(new Point(next.x, next.y - 1)); queue.add(new Point(next.x, next.y + 1)); } int maxSize = rooms.length * rooms[0].length; int minSize = (int) (maxSize * 0.8); double multiplier = 1D - ((6D - complexity) * 0.06D); maxSize *= multiplier; minSize *= multiplier; //Create gaps by removing random DE's int remove = rooms.length * rooms[0].length - maxSize + random.nextInt(maxSize - minSize); for (int i = 0; i < remove; i++) removeRoom(shuffledRooms().filter(r -> r.children.isEmpty()).findFirst().get()); RoomNode boss; //Choose crit while (true) { //Sets only have distinct elements so no need to worry about overlapping paths Set critPath = new HashSet<>(); boss = shuffledRooms().filter(r -> r.children.isEmpty()).findFirst().get(); critPath.addAll(boss.pathToBase()); critPath.addAll(shuffledRooms().findAny().get().pathToBase()); critPath.addAll(shuffledRooms().findAny().get().pathToBase()); critPath.addAll(shuffledRooms().findAny().get().pathToBase()); if (random.nextBoolean()) critPath.addAll(shuffledRooms().findAny().get().pathToBase()); if (critPath.size() >= DungeonConstants.MIN_CRIT_PATH[size] && critPath.size() <= DungeonConstants.MAX_CRIT_PATH[size]) { critPath.forEach(r -> r.isCritPath = true); boss.isBoss = true; break; } } //Move the base somewhere randomly on crit, base can't be a straight 2 way though setBase(shuffledRooms().filter(r -> !r.isBoss && r.isCritPath && !(r.west() && r.east() && !r.north() && !r.south()) && !(!r.west() && !r.east() && r.north() && r.south())).findFirst().get()); //Crit DE locks, if we do these first these can't 'fail', and this mathematically ensures crit is actually crit because each branch will lock out another branch rooms().filter(r -> !r.isBoss && r.children.stream().noneMatch(c -> c.isCritPath) && r.isCritPath).forEach(r -> assignKey(r, true)); //Some extra crit locks, to make things more interesting, these may 'fail' to add, but it doesn't matter shuffledRooms().filter(r -> !r.isBoss && r.isCritPath && r.key == -1).limit((size * 2L) +1).forEach(r -> assignKey(r, true)); if (boss.lock == -1) { //Should we force a lock on the boss? RS has a lock about 95% of the time //We could put the key anywhere on crit, because the lock doesn't actually lock out anything at all, and is redundant with keyshare on //Perhaps the lock is to force bosses not to move if you stand under them, i.e. behemoth will stomp you until you move } //Bonus keys can be found anywhere that isn't the boss or has a key already long bonusLockCount = rooms().filter(r -> !r.isCritPath).count() / 4 + random.nextInt((size + 1) * 2); shuffledRooms().filter(r -> !r.isBoss && r.key == -1).limit(bonusLockCount).forEach(r -> assignKey(r, false)); } RoomNode randomParent(int x, int y) { List neighbors = new LinkedList<>(); neighbors.add(getRoom(x - 1, y)); neighbors.add(getRoom(x + 1, y)); neighbors.add(getRoom(x, y - 1)); neighbors.add(getRoom(x, y + 1)); neighbors.removeIf(r -> r == null || r.isBoss); //These are not valid parents return (RoomNode) neighbors.toArray()[random.nextInt(neighbors.size())]; } public RoomNode getBase() { return base; } public void setBase(RoomNode newBase) { if (base == newBase) return; base = newBase; swapTree(newBase); } private void swapTree(RoomNode child) { if (child.parent.parent != null) swapTree(child.parent); child.parent.parent = child; child.parent.children.remove(child); child.children.add(child.parent); child.parent = null; } public RoomNode getRoom(int x, int y) { if (x < 0 || y < 0 || x >= rooms.length || y >= rooms[x].length) return null; return rooms[x][y]; } public void addRoom(RoomNode room) { rooms[room.x][room.y] = room; roomList.add(room); } public void removeRoom(RoomNode r) { r.parent.children.remove(r); roomList.remove(r); rooms[r.x][r.y] = null; } public Stream rooms() { return roomList.stream(); } public Stream shuffledRooms() { Collections.shuffle(roomList, random); return roomList.stream(); } public int getRoomCount() { return roomList.size(); } public void assignKey(RoomNode keyRoom, boolean critLock) { List unrelated = getUnrelatedRooms(keyRoom); List children = keyRoom.getChildrenR(); List candidates = rooms().filter(r -> r.isCritPath == critLock && r.lock == -1).collect(Collectors.toList()); candidates.retainAll(unrelated); candidates.removeAll(children); if (!candidates.isEmpty()) { RoomNode lockRoom = random(candidates); keyRoom.key = availableKeys.removeFirst(); lockRoom.lock = keyRoom.key; } } public List getUnrelatedRooms(RoomNode room) { List reachable = rooms().collect(Collectors.toList()); Queue encounteredLocks = new LinkedList<>(); encounteredLocks.add(room); while ((room = encounteredLocks.poll()) != null) { reachable.remove(room); if (room.lock != -1) { int nextLock = room.lock; encounteredLocks.add(rooms().filter(r -> r.key == nextLock).findFirst().get()); } if (room.parent != null) encounteredLocks.add(room.parent); } return reachable; } T random(List list) { return list.remove(random.nextInt(list.size())); } }" "package com.rs.game.content.skills.dungeoneering; public final class DungeonUtils { public static int getMaxFloor(int level) { return (level + 1) / 2; //return (level / 2) + 1; } public static int getLevel(int floor) { return (floor * 2) - 1; //return (floor - 1) * 2; } public static boolean isBindAmmo(Item item) { if (item.getId() == 19867 || item.getId() == 19868) //runes box return true; for (int id : DungeonConstants.ARROWS) if (item.getId() == id) return true; for (int id : DungeonConstants.RUNES) if (item.getId() == id) return true; return false; } public static int getMaxBindItems(int level) { if (level >= 120) return 5; if (level >= 90) return 4; if (level >= 50) return 3; if (level >= 20) return 2; return 1; } public static int getBindedId(Item item) { String name = item.getName(); for (int i = 15775; i <= 16272; i++) if (ItemDefinitions.getDefs(i).name.replace("" (b)"", """").equals(name)) return i; for (int i = 19865; i <= 19866; i++) if (ItemDefinitions.getDefs(i).name.replace("" (b)"", """").equals(name)) return i; return -1; } public static int getClosestToCombatLevel(int[] npcIds, int target) { List ids = Arrays.stream(npcIds).boxed().collect(Collectors.toList()); Collections.shuffle(ids); return ids.stream() .min(Comparator.comparingInt(i -> Math.abs(NPCDefinitions.getDefs(i).combatLevel - target))) .orElseThrow(() -> new NoSuchElementException(""No suitable combat level found"")); } public static int[] getFloorThemeRange(int floorId) { if (floorId <= 11) return new int[] { 1, 11 }; if (floorId <= 17) return new int[] { 12, 17 }; if (floorId <= 29) return new int[] { 18, 29 }; if (floorId <= 35) return new int[] { 30, 35 }; if (floorId <= 47) return new int[] { 36, 47 }; return new int[] { 48, 60 }; } public static int getFloorType(int floorId) { if (floorId <= 11) return DungeonConstants.FROZEN_FLOORS; if (floorId <= 17) return DungeonConstants.ABANDONED_FLOORS; if (floorId <= 29) return DungeonConstants.FURNISHED_FLOORS; if (floorId <= 35) return DungeonConstants.ABANDONED_FLOORS; if (floorId <= 47) return DungeonConstants.OCCULT_FLOORS; return DungeonConstants.WARPED_FLOORS; } public static String getFloorTypeName(int floorId) { if (floorId <= 11) return ""Frozen""; if (floorId <= 17) return ""Abandoned""; if (floorId <= 29) return ""Furnished""; if (floorId <= 35) return ""Abandoned""; if (floorId <= 47) return ""Occult""; return ""Warped""; } public static String getSizeName(int size) { String[] sizeNames = { ""Small"", ""Medium"", ""Large"", ""Test"" }; return sizeNames[size]; } public static int getSafeMusic(int type) { return DungeonConstants.SAFE_MUSICS[type][Utils.random(DungeonConstants.DANGEROUS_MUSICS[type].length)]; } public static int getDangerousMusic(int type) { return DungeonConstants.DANGEROUS_MUSICS[type][Utils.random(DungeonConstants.DANGEROUS_MUSICS[type].length)]; } public static RoomReference getRandomRoom(Room[][] map) { return new RoomReference(Utils.random(map.length), Utils.random(map[0].length)); } public static int getHunterCreature() { return DungeonConstants.HUNTER_CREATURES[Utils.random(DungeonConstants.HUNTER_CREATURES.length)]; } public static BossRoom getBossRoomWithChunk(int type, int x, int y) { for (BossRoom room : DungeonConstants.BOSS_ROOMS[type]) if (room.getChunkX() == x && room.getChunkY() == y) return room; return null; } public static Room[] selectPossibleBossRooms(int type, int complexity, int floorId, boolean n, boolean e, boolean s, boolean w, int rotation) { ArrayList possiblities = new ArrayList<>(); for (BossRoom handledRoom : DungeonConstants.BOSS_ROOMS[type]) { if (!handledRoom.isComplexity(complexity) || (handledRoom.getMinFloor() > floorId)) continue; Room room = new Room(handledRoom, rotation); if (room.hasNorthDoor() == n && room.hasEastDoor() == e && room.hasSouthDoor() == s && room.hasWestDoor() == w) possiblities.add(room); } //return new Room[] { new Room(DungeonConstants.BOSS_ROOMS[2][4], rotation) }; return possiblities.toArray(new Room[0]); } public static boolean theresDoorTo(RoomReference checkRoom, Room[][] map) { if (checkRoom.getRoomX() < 0 || checkRoom.getRoomX() >= map.length || checkRoom.getRoomY() < 0 || checkRoom.getRoomY() >= map[checkRoom.getRoomX()].length) return false; if (checkRoom.getRoomX() != 0 && map[checkRoom.getRoomX() - 1][checkRoom.getRoomY()] != null && map[checkRoom.getRoomX() - 1][checkRoom.getRoomY()].hasEastDoor()) return true; if (checkRoom.getRoomX() != map.length - 1 && map[checkRoom.getRoomX() + 1][checkRoom.getRoomY()] != null && map[checkRoom.getRoomX() + 1][checkRoom.getRoomY()].hasWestDoor()) return true; if (checkRoom.getRoomY() != 0 && map[checkRoom.getRoomX()][checkRoom.getRoomY() - 1] != null && map[checkRoom.getRoomX()][checkRoom.getRoomY() - 1].hasNorthDoor()) return true; if (checkRoom.getRoomY() != map[checkRoom.getRoomX()].length - 1 && map[checkRoom.getRoomX()][checkRoom.getRoomY() + 1] != null && map[checkRoom.getRoomX()][checkRoom.getRoomY() + 1].hasSouthDoor()) return true; return false; } public static Room[] selectPossibleRooms(HandledRoom[] handledRooms, int complexity, int floorType, boolean n, boolean e, boolean s, boolean w) { ArrayList possiblities = new ArrayList<>(); for (HandledRoom handledRoom : handledRooms) { if (!handledRoom.isAvailableOnFloorType(floorType) || !handledRoom.isComplexity(complexity)) continue; for (int rotation = 0; rotation < DungeonConstants.ROTATIONS_COUNT; rotation++) { Room room = new Room(handledRoom, rotation); if (room.hasNorthDoor() == n && room.hasEastDoor() == e && room.hasSouthDoor() == s && room.hasWestDoor() == w) possiblities.add(room); } } return possiblities.toArray(new Room[0]); } public static Room[] selectPossibleRooms(HandledRoom[] handledRooms, int complexity, int floorType, boolean n, boolean e, boolean s, boolean w, int rotation) { ArrayList possiblities = new ArrayList<>(); for (HandledRoom handledRoom : handledRooms) { if (!handledRoom.isAvailableOnFloorType(floorType) || !handledRoom.isComplexity(complexity)) continue; Room room = new Room(handledRoom, rotation); if (room.hasNorthDoor() == n && room.hasEastDoor() == e && room.hasSouthDoor() == s && room.hasWestDoor() == w) possiblities.add(room); } return possiblities.toArray(new Room[0]); } public static boolean checkDungeonBounds(RoomReference reference, Room[][] map, Room room) { if ((reference.getRoomX() == 0 && room.hasWestDoor()) || (reference.getRoomX() == map.length - 1 && room.hasEastDoor())) return false; if ((reference.getRoomY() == 0 && room.hasSouthDoor()) || (reference.getRoomY() == map[0].length - 1 && room.hasNorthDoor())) return false; return true; } public static boolean isClipped(int objectId) { for (int id : DungeonConstants.DUNGEON_BOSS_DOORS) if (id == objectId) return true; for (int id : DungeonConstants.DUNGEON_DOORS) if (id == objectId) return true; /* for (int id : DungeonConstants.DUNGEON_SKILL_DOORS) if (id == objectId) return true; for (int id : DungeonConstants.THIEF_CHEST_OPEN) if (id == objectId) return true; for (int id : DungeonConstants.THIEF_CHEST_LOCKED) if (id == objectId) return true; if (objectId >= KeyDoors.ORANGE_TRIANGLE.getObjectId() && objectId <= KeyDoors.GOLD_SHIELD.getObjectId()) return true;*/ return false; } public static int getMiningResource(int rockType, int floorType) { return DungeonConstants.MINING_RESOURCES[floorType] + rockType * 2; } public static int getWoodcuttingResource(int treeType, int floorType) { return DungeonConstants.WOODCUTTING_RESOURCES[floorType] + treeType * 2; } public static int getFarmingResource(int flowerType, int floorType) { return DungeonConstants.FARMING_RESOURCES[floorType] + flowerType * 2; } public static int getBattleaxe(int tier) { return 15753 + (tier - 1) * 2; } public static int getGauntlets(int tier) { return 16273 + (tier - 1) * 2; } public static int getPickaxe(int tier) { return 16295 + (tier - 1) * 2; } public static int getBoots(int tier) { return 16339 + (tier - 1) * 2; } public static int getHatchet(int tier) { return 16361 + (tier - 1) * 2; } public static int getLongsword(int tier) { return 16383 + (tier - 1) * 2; } public static int getMaul(int tier) { return 16405 + (tier - 1) * 2; } public static int getArrows(int tier) { return 16427 + (tier - 1) * 5; } public static int getPlatelegs(int tier, boolean male) { return (male ? 16669 : 16647) + (tier - 1) * 2; } public static int getFullHelm(int tier) { return 16691 + (tier - 1) * 2; } public static int getChainbody(int tier) { return 16713 + (tier - 1) * 2; } public static int getDagger(int tier) { return 16757 + (tier - 1) * 2; } public static int getTornBag(int tier) { return 17995 + (tier - 1) * 2; } public static int getOre(int tier) { return 17630 + (tier - 1) * 2; } public static int getBranche(int tier) { return 17682 + (tier - 1) * 2; } public static int getTextile(int tier) { return 17448 + (tier - 1) * 2; } public static int getHerb(int tier) { return 17494 + (tier - 1) * 2; } public static int getSeed(int tier) { return 17823 + (tier - 1); } public static int getRandomGear(int tier) { return switch (Utils.random(29)) { case 0 -> getLongbow(tier); case 1 -> getShortbow(tier); case 2 -> getChaps(tier); case 3 -> getLeatherBoots(tier); case 4 -> getVambrances(tier); case 5 -> getLeatherBody(tier); case 6 -> getCoif(tier); case 7 -> getRobeTop(tier); case 8 -> getElementalStaff(tier); case 9 -> getBasicStaff(tier); case 10 -> getGloves(tier); case 11 -> getShoes(tier); case 12 -> getRobeBottom(tier); case 13 -> getHood(tier); case 14 -> getKiteshield(tier); case 15 -> getPlatebody(tier); case 16 -> getSpear(tier); case 17 -> getWarhammer(tier); case 18 -> getRapier(tier); case 19 -> get2HSword(tier); case 20 -> getDagger(tier); case 21 -> getChainbody(tier); case 22 -> getFullHelm(tier); case 23 -> getPlatelegs(tier, true); case 24 -> getMaul(tier); case 25 -> getLongsword(tier); case 26 -> getBoots(tier); case 27 -> getGauntlets(tier); case 28 -> getBattleaxe(tier); default -> getHatchet(tier); // shouldn't }; } public static int getRandomRangeGear(int tier) { return switch (Utils.random(7)) { case 0 -> getLongbow(tier); case 1 -> getShortbow(tier); case 2 -> getChaps(tier); case 3 -> getLeatherBoots(tier); case 4 -> getVambrances(tier); case 5 -> getLeatherBody(tier); case 6 -> getCoif(tier); default -> getHatchet(tier); // shouldn't }; } public static int getRandomMagicGear(int tier) { return switch (Utils.random(7)) { case 0 -> getRobeTop(tier); case 1 -> getElementalStaff(tier); case 2 -> getBasicStaff(tier); case 3 -> getGloves(tier); case 4 -> getShoes(tier); case 5 -> getRobeBottom(tier); case 6 -> getHood(tier); default -> getHatchet(tier); // shouldn't }; } public static int getRandomMeleeGear(int tier) { return switch (Utils.random(15)) { case 0 -> getKiteshield(tier); case 1 -> getPlatebody(tier); case 2 -> getSpear(tier); case 3 -> getWarhammer(tier); case 4 -> getRapier(tier); case 5 -> get2HSword(tier); case 6 -> getDagger(tier); case 7 -> getChainbody(tier); case 8 -> getFullHelm(tier); case 9 -> getPlatelegs(tier, true); case 10 -> getMaul(tier); case 11 -> getLongsword(tier); case 12 -> getBoots(tier); case 13 -> getGauntlets(tier); case 14 -> getBattleaxe(tier); default -> getHatchet(tier); // shouldn't }; } public static int getRandomWeapon(int tier) { return switch (Utils.random(12)) { case 0 -> getLongbow(tier); case 1 -> getShortbow(tier); case 2 -> getElementalStaff(tier); case 3 -> getBasicStaff(tier); case 4 -> getSpear(tier); case 5 -> getWarhammer(tier); case 6 -> getRapier(tier); case 7 -> get2HSword(tier); case 8 -> getDagger(tier); case 9 -> getMaul(tier); case 10 -> getLongsword(tier); case 11 -> getBattleaxe(tier); default -> getHatchet(tier); // shouldn't }; } public static int get2HSword(int tier) { return 16889 + (tier - 1) * 2; } public static int getFood(int tier) { return 18159 + (tier - 1) * 2; } public static int getRapier(int tier) { return 16935 + (tier - 1) * 2; } public static int getWarhammer(int tier) { return 17019 + (tier - 1) * 2; } public static int getSpear(int tier) { return 17063 + (tier - 1) * 8; } public static int getPlatebody(int tier) { return 17239 + (tier - 1) * 2; } public static int getKiteshield(int tier) { return 17341 + (tier - 1) * 2; } public static int getHood(int tier) { return 16735 + (tier - 1) * 2; } public static int getRobeBottom(int tier) { return 16845 + (tier - 1) * 2; } public static int getShoes(int tier) { return 16911 + (tier - 1) * 2; } public static int getGloves(int tier) { return 17151 + (tier - 1) * 2; } public static int getBasicStaff(int tier) { return 16977 + (tier - 1) * 2; } public static int getElementalStaff(int tier) { if (tier == 2) return 17001; // earth if (tier == 3) return 17005; // fire if (tier == 4) return 17009; // air if (tier == 5) return 17013; // catalytic if (tier == 6) return 16999; // empowered water if (tier == 7) return 17003; // empowered earth if (tier == 8) return 17007; // empowered fire if (tier == 9) return 17011; // empowered air if (tier == 10) return 17015; // empowered catalytic if (tier == 11) return 17017; // celestial catalytic return 16997; //water } public static int getStartRunes(int level) { if (level >= 41) return DungeonConstants.RUNES[6]; //death if (level >= 17) return DungeonConstants.RUNES[5]; //chaos return DungeonConstants.RUNES[4]; //mind } public static int getRobeTop(int tier) { return 17217 + (tier - 1) * 2; } public static int getCoif(int tier) { return 17041 + (tier - 1) * 2; } public static int getLeatherBody(int tier) { return 17173 + (tier - 1) * 2; } public static int getVambrances(int tier) { return 17195 + (tier - 1) * 2; } public static int getLeatherBoots(int tier) { return 17297 + (tier - 1) * 2; } public static int getChaps(int tier) { return 17319 + (tier - 1) * 2; } public static int getShortbow(int tier) { return 16867 + (tier - 1) * 2; } public static int getLongbow(int tier) { return 16317 + (tier - 1) * 2; } public static int getMaxTier(DungeonPartyManager party, int cap, int... skills) { int maxTier = cap; for (int skill : skills) { int level = party.getMaxLevel(skill); int tier = getTier(level); if (maxTier > tier) maxTier = tier; } return maxTier; } public static int getTier(int level) { return level == 99 ? 11 : level > 10 ? (1 + level / 10) : 1; } public static boolean isLadder(int id, int type) { return DungeonConstants.LADDERS[type] == id; } public static boolean isOpenSkillDoor(int id, int type) { for (SkillDoors s : SkillDoors.values()) { int openId = s.getOpenObject(type); if (openId != -1 && openId == id) return true; } return false; } public static List getRandomOrderCoords(int size) { List list = new ArrayList<>(); for (int x = 2;x < (15-size);x++) for (int y = 2;y < (15-size);y++) list.add(Tile.of(x, y, 0)); Collections.shuffle(list); return list; } public static List generateRandomMonsters(int floorType, int maxLevel, int combatTotal, int numMonsters) { List list = new ArrayList<>(); if (Utils.random(4) == 0) return list; int[] combatLevels = Utils.randSum(numMonsters, combatTotal); for(int i = 0;i < combatLevels.length;i++) if (combatLevels[i] > maxLevel) combatLevels[i] = maxLevel; List possible = new ArrayList<>(GuardianMonster.forFloor(floorType)); int atts = 0; for (int i = 0;i < numMonsters;) { int try1 = getClosestToCombatLevel(possible.get(Utils.random(possible.size())).getNPCIds(), combatLevels[i]); if (atts++ > 15 || Utils.diff(NPCDefinitions.getDefs(try1).combatLevel, combatLevels[i]) < 15) { list.add(try1); i++; atts = 0; } } return list; } }" "package com.rs.game.content.skills.dungeoneering; @PluginEventHandler public class DungManager { private static final int[] UPGRADE_COSTS = { 135, 175, 335, 660, 1360, 3400, 6800, 18750, 58600, 233000 }; private int tokens; private boolean[] currentProgress; private int previousProgress; private int maxFloor; private int maxComplexity; private ItemsContainer bindedItems; private Item bindedAmmo; private Set resourceXpGranted; private int[] kinshipTiers; private int kinshipResets; private KinshipPerk activeRingPerk; private KinshipPerk quickSwitch; private Object rejoinKey; private transient Player player; private transient DungeonPartyManager party; private transient Player invitingPlayer; public enum ResourceDungeon { EDGEVILLE_DUNGEON(10, 1100, 52849, Tile.of(3132, 9933, 0), 52867, Tile.of(991, 4585, 0)), DWARVEN_MINE(15, 1500, 52855, Tile.of(3034, 9772, 0), 52864, Tile.of(1041, 4575, 0)), EDGEVILLE_DUNGEON_2(20, 1600, 52853, Tile.of(3104, 9826, 0), 52868, Tile.of(1135, 4589, 0)), KARAMJA_VOLCANO(25, 2100, 52850, Tile.of(2845, 9557, 0), 52869, Tile.of(1186, 4598, 0)), DAEMONHEIM_PENINSULA(30, 2400, 52861, Tile.of(3513, 3666, 0), 52862, Tile.of(3498, 3633, 0)), BAXTORIAN_FALLS(35, 3000, 52857, Tile.of(2578, 9898, 0), 52873, Tile.of(1256, 4592, 0)), MINING_GUILD(45, 4400, 52856, Tile.of(3022, 9741, 0), 52866, Tile.of(1052, 4521, 0)), TAVERLEY_DUNGEON_1(55, 6200, 52851, Tile.of(2854, 9841, 0), 52870, Tile.of(1394, 4588, 0)), TAVERLEY_DUNGEON_2(60, 7000, 52852, Tile.of(2912, 9810, 0), 52865, Tile.of(1000, 4522, 0)), VARROCK_SEWERS(65, 8500, 52863, Tile.of(3164, 9878, 0), 52876, Tile.of(1312, 4590, 0)), CHAOS_TUNNELS(70, 9600, 52858, Tile.of(3160, 5521, 0), 52874, Tile.of(1238, 4524, 0)), AL_KHARID(75, 11400, 52860, Tile.of(3298, 3307, 0), 52872, Tile.of(1182, 4515, 0)), BRIMHAVEN_DUNGEON(80, 12800, 52854, Tile.of(2697, 9442, 0), 52871, Tile.of(1140, 4499, 0)), POLYPORE_DUNGEON(82, 13500, 64291, Tile.of(4661, 5491, 3), 64291, Tile.of(4695, 5625, 3)), ASGARNIAN_ICE_DUNGEON(85, 15000, 52859, Tile.of(3033, 9599, 0), 52875, Tile.of(1297, 4510, 0)) ; private static final Map ID_MAP = new HashMap<>(); static { for (ResourceDungeon d : ResourceDungeon.values()) { ID_MAP.put(d.insideId, d); ID_MAP.put(d.outsideId, d); } } public static ResourceDungeon forId(int id) { return ID_MAP.get(id); } ResourceDungeon(int level, int xp) { outsideId = insideId = -1; } // TODO: This may be a huge bug, in which the level, xp, and inside/outside tiles fields are mutated (this is an enum) private int level; private final int outsideId, insideId; private double xp; private Tile inside, outside; ResourceDungeon(int level, double xp, int outsideId, Tile outside, int insideId, Tile inside) { this.level = level; this.xp = xp; this.outsideId = outsideId; this.outside = outside; this.insideId = insideId; this.inside = inside; } } public static ObjectClickHandler handleResourceDungeonEntrance = new ObjectClickHandler(ResourceDungeon.ID_MAP.keySet().toArray(), e -> { ResourceDungeon dung = ResourceDungeon.forId(e.getObjectId()); if (dung == null) return; if (e.getPlayer().getSkills().getLevelForXp(Constants.DUNGEONEERING) < dung.level) { e.getPlayer().simpleDialogue(""You need a dungeoneering level of "" + dung.level + "" to enter this resource dungeon.""); return; } if (dung == ResourceDungeon.POLYPORE_DUNGEON) Magic.sendTeleportSpell(e.getPlayer(), 13288, 13285, 2516, 2517, 0, 0, e.getObject().getX() == 4695 && e.getObject().getY() == 5626 ? dung.outside : dung.inside, 1, false, TeleType.OBJECT, null); else Magic.sendTeleportSpell(e.getPlayer(), 13288, 13285, 2516, 2517, 0, 0, e.getObject().getId() == dung.insideId ? dung.outside : dung.inside, 1, false, TeleType.OBJECT, null); if (!e.getPlayer().getDungManager().gainedXp(dung)) { e.getPlayer().getDungManager().addGainedXp(dung); e.getPlayer().getSkills().addXp(Constants.DUNGEONEERING, dung.xp); } }); public DungManager(Player player) { setPlayer(player); reset(); } protected void addGainedXp(ResourceDungeon dung) { resourceXpGranted.add(dung); } protected boolean gainedXp(ResourceDungeon dung) { return resourceXpGranted.contains(dung); } public void setPlayer(Player player) { this.player = player; if (resourceXpGranted == null) resourceXpGranted = new HashSet<>(); } public void setKinshipLevel(KinshipPerk perk, int level) { if (kinshipTiers == null) { kinshipTiers = new int[KinshipPerk.values().length]; kinshipResets = 5; } kinshipTiers[perk.ordinal()] = level; refreshKinship(); } public int getKinshipTier(KinshipPerk perk) { if (kinshipTiers == null) { kinshipTiers = new int[KinshipPerk.values().length]; kinshipResets = 5; } return kinshipTiers[perk.ordinal()]; } public static ButtonClickHandler handleKinshipInter = new ButtonClickHandler(993, e -> { Item ring = e.getPlayer().getTempAttribs().getO(""kinshipToBeCustomized""); if (ring == null) { e.getPlayer().closeInterfaces(); return; } switch (e.getComponentId()) { case 257: case 242: case 227: case 212: e.getPlayer().getTempAttribs().setI(""kinshipTab"", (257 - e.getComponentId()) / 15); e.getPlayer().getDungManager().refreshKinshipStrings(); break; case 139: case 46: case 88: e.getPlayer().getDungManager().promptRingUpgrade(getPerk(e.getPlayer().getTempAttribs().getI(""kinshipTab""), e.getComponentId() == 139 ? 0 : e.getComponentId() == 46 ? 1 : 2)); break; case 278: e.getPlayer().getTempAttribs().setO(""perkUpgradePrompt"", null); break; case 279: e.getPlayer().getDungManager().upgradePerk(e.getPlayer().getTempAttribs().getO(""perkUpgradePrompt"")); break; case 137: case 44: case 86: if (e.getPacket() == ClientPacket.IF_OP1) e.getPlayer().getDungManager().activeRingPerk = getPerk(e.getPlayer().getTempAttribs().getI(""kinshipTab""), e.getComponentId() == 137 ? 0 : e.getComponentId() == 44 ? 1 : 2); else e.getPlayer().getDungManager().quickSwitch = getPerk(e.getPlayer().getTempAttribs().getI(""kinshipTab""), e.getComponentId() == 137 ? 0 : e.getComponentId() == 44 ? 1 : 2); if (e.getPlayer().getDungManager().activeRingPerk != null) ring.setId(e.getPlayer().getDungManager().activeRingPerk.getItemId()); e.getPlayer().getEquipment().refresh(Equipment.RING); e.getPlayer().getInventory().refresh(); e.getPlayer().getDungManager().refreshKinshipStrings(); break; case 190: e.getPlayer().getDungManager().promptResetRing(); break; } }); private void upgradePerk(KinshipPerk perk) { if (perk == null) return; player.getTempAttribs().setO(""perkUpgradePrompt"", null); int cost = UPGRADE_COSTS[kinshipTiers[perk.ordinal()]]; if (tokens < cost) { player.sendMessage(""You don't have enough tokens to upgrade that.""); return; } kinshipTiers[perk.ordinal()]++; tokens -= cost; refreshKinship(); } private void promptRingUpgrade(KinshipPerk perk) { player.getTempAttribs().setO(""perkUpgradePrompt"", perk); String upgradeInfo = EnumDefinitions.getEnum(3089 + perk.ordinal()).getStringValue(kinshipTiers[perk.ordinal()]); upgradeInfo += ""

""; upgradeInfo += EnumDefinitions.getEnum(3089 + perk.ordinal()).getStringValue(kinshipTiers[perk.ordinal()] + 1); player.getPackets().setIFText(993, 276, upgradeInfo); player.getPackets().setIFText(993, 277, ""Upgrade cost: "" + Utils.formatNumber(UPGRADE_COSTS[kinshipTiers[perk.ordinal()]])); player.getPackets().setIFText(993, 298, Utils.formatNumber(tokens)); player.getPackets().setIFHidden(993, 261, false); } public void customizeKinship(Item ring) { player.getTempAttribs().setO(""kinshipToBeCustomized"", ring); player.getTempAttribs().setI(""kinshipTab"", 0); player.getInterfaceManager().sendInterface(993); refreshKinship(); } private void promptResetRing() { if (kinshipResets <= 0) { player.sendMessage(""You have no kinship resets left.""); return; } player.sendOptionDialogue(""Would you like to reset your ring? You have "" + kinshipResets + "" resets left."", ops -> { ops.add(""Yes, reset my ring."", () -> { int tokensToRefund = 0; for (int kinshipTier : kinshipTiers) for (int lvl = 0; lvl <= kinshipTier; lvl++) if (lvl > 0) tokensToRefund += UPGRADE_COSTS[lvl - 1]; tokens += tokensToRefund; kinshipTiers = new int[KinshipPerk.values().length]; kinshipResets--; refreshKinship(); player.sendMessage(""You reset the ring, and are refunded "" + Utils.formatNumber(tokensToRefund) + "" dungeoneering tokens.""); }); ops.add(""Nevermind.""); }); } public void refreshKinship() { for (KinshipPerk p : KinshipPerk.values()) player.getVars().setVarBit(p.getVarbit(), getKinshipTier(p)); player.getVars().setVarBit(8065, activeRingPerk == null ? 0 : activeRingPerk.ordinal() + 1); if (player.getInterfaceManager().topOpen(993)) player.getPackets().sendRunScriptBlank(3494); refreshKinshipStrings(); } public void refreshKinshipStrings() { player.getPackets().setIFText(993, 138, player.getDungManager().getStatus(getPerk(player.getTempAttribs().getI(""kinshipTab""), 0))); player.getPackets().setIFText(993, 45, player.getDungManager().getStatus(getPerk(player.getTempAttribs().getI(""kinshipTab""), 1))); player.getPackets().setIFText(993, 87, player.getDungManager().getStatus(getPerk(player.getTempAttribs().getI(""kinshipTab""), 2))); } private String getStatus(KinshipPerk perk) { if (activeRingPerk == perk) return ""In-Use""; if (quickSwitch == perk) return ""Quick-switch""; return ""Switch-to""; } private static KinshipPerk getPerk(int page, int offset) { int idx = page * 3 + offset; if (idx < 0 || idx > 11) return null; return KinshipPerk.values()[idx]; } public static ItemClickHandler handleKinship = new ItemClickHandler(Utils.streamObjects(15707, Utils.range(18817, 18828)), new String[] { ""Customise"", ""Quick-switch"", ""Teleport to Daemonheim"", ""Open party interface"" }, e -> { switch (e.getOption()) { case ""Teleport to Daemonheim"": Magic.sendDamonheimTeleport(e.getPlayer(), Tile.of(3449, 3698, 0)); break; case ""Open party interface"": e.getPlayer().getDungManager().openPartyInterface(); break; case ""Customise"": if (e.getPlayer().getControllerManager().isIn(DungeonController.class)) e.getPlayer().getDungManager().customizeKinship(e.getItem()); else e.getPlayer().sendMessage(""You cannot customize your ring outside of a dungeon.""); break; case ""Quick-switch"": if (!e.getPlayer().getControllerManager().isIn(DungeonController.class)) return; e.getPlayer().closeInterfaces(); KinshipPerk active = e.getPlayer().getDungManager().activeRingPerk; KinshipPerk quickSwitch = e.getPlayer().getDungManager().quickSwitch; if (active != null && quickSwitch != null) { e.getPlayer().getDungManager().activeRingPerk = quickSwitch; e.getPlayer().getDungManager().quickSwitch = active; e.getItem().setId(quickSwitch.getItemId()); if (e.isEquipped()) e.getPlayer().getEquipment().refresh(Equipment.RING); else e.getPlayer().getInventory().refresh(e.getItem().getSlot()); } else e.getPlayer().sendMessage(""You need to have an active perk set and a quick-switch to use this feature.""); break; } }); public void addBindedItem(int itemId) { bindedItems.add(new Item(itemId)); } public void setBindedAmmo(int itemId, int dg_bindedAmmoAmount) { if (bindedAmmo == null) bindedAmmo = new Item(itemId); bindedAmmo.setId(itemId); bindedAmmo.setAmount(dg_bindedAmmoAmount); } public void bind(Item item, int slot) { ItemDefinitions defs = item.getDefinitions(); int bindId = DungeonUtils.getBindedId(item); if (bindId == -1) return; if (DungeonUtils.isBindAmmo(item)) { if (bindedAmmo != null && (!defs.isStackable() || bindedAmmo.getId() != bindId)) { player.sendMessage(""A currently bound item must be destroyed before another item may be bound.""); return; } player.getInventory().deleteItem(slot, item); item.setId(bindId); player.getInventory().addItem(item); if (bindedAmmo == null) bindedAmmo = new Item(item); else bindedAmmo.setAmount(bindedAmmo.getAmount() + item.getAmount()); if (bindedAmmo.getAmount() > 255) bindedAmmo.setAmount(255); } else { if (bindedItems.getUsedSlots() >= DungeonUtils.getMaxBindItems(player.getSkills().getLevelForXp(Constants.DUNGEONEERING))) { player.sendMessage(""A currently bound item must be destroyed before another item may be bound.""); return; } item.setId(bindId); player.getInventory().refresh(slot); bindedItems.add(new Item(item)); } player.sendMessage(""You bind the "" + defs.getName() + "" to you. Check in the smuggler to manage your bound items.""); } public void unbind(Item item) { if (bindedAmmo != null && bindedAmmo.getId() == item.getId()) bindedAmmo = null; else bindedItems.remove(item); } public Item getBindedAmmo() { return bindedAmmo; } public boolean isInsideDungeon() { return party != null && party.getDungeon() != null; } public ItemsContainer getBindedItems() { return bindedItems; } public void reset() { currentProgress = new boolean[DungeonConstants.FLOORS_COUNT]; previousProgress = 0; bindedItems = new ItemsContainer<>(10, false); maxFloor = maxComplexity = 1; } public boolean isTickedOff(int floor) { return currentProgress[floor - 1]; } public int getCurrentProgress() { int count = 0; for (boolean b : currentProgress) if (b) count++; return count; } public boolean getCurrentProgresB(int pos) { return currentProgress[pos]; } public void setCurrentProgres(int pos, boolean b) { currentProgress[pos] = b; } public int getPreviousProgress() { return previousProgress; } public void setPreviousProgress(int progress) { previousProgress = progress; } public int getPrestige() { return previousProgress; } public void tickOff(int floor) { currentProgress[floor - 1] = true; refreshCurrentProgress(); } public void resetProgress() { previousProgress = getCurrentProgress(); currentProgress = new boolean[DungeonConstants.FLOORS_COUNT]; refreshCurrentProgress(); refreshPreviousProgress(); } public void removeTokens(int tokens) { this.tokens -= tokens; if (tokens < 0) tokens = 0; } public void addTokens(int tokens) { this.tokens += tokens; } public int getTokens() { return tokens; } public Object getRejoinKey() { return rejoinKey; } public void setRejoinKey(Object rejoinKey) { this.rejoinKey = rejoinKey; } public int getMaxFloor() { return maxFloor; } public void setMaxFloor(int maxFloor) { this.maxFloor = maxFloor; } public void increaseMaxFloor() { if (maxFloor == 60) return; maxFloor++; } public void increaseMaxComplexity() { maxComplexity++; } public int getMaxComplexity() { return maxComplexity; } public void setMaxComplexity(int maxComplexity) { this.maxComplexity = maxComplexity; } public static ButtonClickHandler handleDungTab = new ButtonClickHandler(939, e -> { if (e.getComponentId() >= 59 && e.getComponentId() <= 72) { int playerIndex = (e.getComponentId() - 59) / 3; if ((e.getComponentId() & 0x3) != 0 || e.getComponentId() == 68) e.getPlayer().getDungManager().pressOption(playerIndex, e.getPacket() == ClientPacket.IF_OP1 ? 0 : e.getPacket() == ClientPacket.IF_OP2 ? 1 : 2); else e.getPlayer().getDungManager().pressOption(playerIndex, 3); } else if (e.getComponentId() == 45) e.getPlayer().getDungManager().formParty(); else if (e.getComponentId() == 33 || e.getComponentId() == 36) e.getPlayer().getDungManager().checkLeaveParty(); else if (e.getComponentId() == 43) e.getPlayer().getDungManager().invite(); else if (e.getComponentId() == 102) e.getPlayer().getDungManager().changeComplexity(); else if (e.getComponentId() == 108) e.getPlayer().getDungManager().changeFloor(); else if (e.getComponentId() == 87) e.getPlayer().getDungManager().openResetProgress(); else if (e.getComponentId() == 94) e.getPlayer().getDungManager().switchGuideMode(); else if (e.getComponentId() == 112) e.getPlayer().getInterfaceManager().sendSubDefault(Sub.TAB_QUEST); }); public static ButtonClickHandler handleInviteScreen = new ButtonClickHandler(949, e -> { if (e.getComponentId() == 65) e.getPlayer().getDungManager().acceptInvite(); else if (e.getComponentId() == 61 || e.getComponentId() == 63) e.getPlayer().closeInterfaces(); }); public static ButtonClickHandler handleComplexitySelect = new ButtonClickHandler(938, e -> { switch (e.getComponentId()) { case 39: e.getPlayer().getDungManager().confirmComplexity(); break; case 56: e.getPlayer().getDungManager().selectComplexity(1); break; case 61: e.getPlayer().getDungManager().selectComplexity(2); break; case 66: e.getPlayer().getDungManager().selectComplexity(3); break; case 71: e.getPlayer().getDungManager().selectComplexity(4); break; case 76: e.getPlayer().getDungManager().selectComplexity(5); break; case 81: e.getPlayer().getDungManager().selectComplexity(6); break; } }); public static ButtonClickHandler handleFloorSelect = new ButtonClickHandler(947, e -> { if (e.getComponentId() >= 48 && e.getComponentId() <= 107) e.getPlayer().getDungManager().selectFloor((e.getComponentId() - 48) + 1); else if (e.getComponentId() == 766) e.getPlayer().getDungManager().confirmFloor(); }); public void openPartyInterface() { player.getInterfaceManager().sendSub(Sub.TAB_QUEST, 939); player.getInterfaceManager().openTab(Sub.TAB_QUEST); player.getPackets().sendVarc(234, 3);// Party Config Interface refresh(); } public void refresh() { refreshFloor(); refreshCurrentProgress(); refreshPreviousProgress(); refreshComplexity(); refreshPartyDetailsComponents(); refreshPartyGuideModeComponent(); refreshNames(); } public void refreshPartyGuideModeComponent() { if (!player.getInterfaceManager().topOpen(939)) return; player.getPackets().setIFHidden(939, 93, party == null || !party.getGuideMode()); } /* * called aswell when player added/removed to party */ public void refreshPartyDetailsComponents() { if (!player.getInterfaceManager().topOpen(939)) return; if (party != null) { if (party.isLeader(player)) { // party leader stuff here player.getPackets().setIFHidden(939, 31, false); player.getPackets().setIFHidden(939, 33, false); player.getPackets().setIFHidden(939, 34, true); // Big Button leave Party player.getPackets().setIFHidden(939, 37, true); // big button form party player.getPackets().setIFHidden(939, 38, false); // right button, invite player player.getPackets().setIFHidden(939, 105, true);// Complexity change player.getPackets().setIFHidden(939, 111, true);// Floor change } else { // non-party leader stuff here player.getPackets().setIFHidden(939, 31, true); player.getPackets().setIFHidden(939, 34, false); // Big Button leave Party player.getPackets().setIFHidden(939, 37, true); // big button form party player.getPackets().setIFHidden(939, 38, true); // right button, invite player player.getPackets().setIFHidden(939, 105, true);// Complexity change player.getPackets().setIFHidden(939, 111, true);// Floor change } } else { player.getPackets().setIFHidden(939, 33, true); player.getPackets().setIFHidden(939, 34, true); // Big Button leave Party player.getPackets().setIFHidden(939, 36, false); player.getPackets().setIFHidden(939, 37, false);// big button form party player.getPackets().setIFHidden(939, 38, true);// right button invite player player.getPackets().setIFHidden(939, 105, true);// Complexity change player.getPackets().setIFHidden(939, 111, true);// Floor change } } public void pressOption(int playerIndex, int option) { player.stopAll(); if (party == null || playerIndex >= party.getTeam().size()) return; Player player = party.getTeam().get(playerIndex); if (player == null) return; DungeonManager dungeon = party.getDungeon(); if (option == 0) { if (dungeon == null) { this.player.sendMessage(""You must be in a dungeon to do that.""); return; } inspectPlayer(player); } else if (option == 1) { if (player == this.player) { this.player.sendMessage(""You can't kick yourself!""); return; } if (!party.isLeader(this.player)) { this.player.sendMessage(""Only your party's leader can kick a party member!""); return; } if (player.isLocked() || dungeon != null && dungeon.isBossOpen()) { this.player.sendMessage(""You can't kick this player right now.""); return; } player.getDungManager().leaveParty(); } else if (option == 2) { if (party.isLeader(player)) { this.player.sendMessage(""You can't promote the party leader.""); return; } if (!party.isLeader(this.player)) { this.player.sendMessage(""Only your party's leader can promote a leader!""); return; } party.setLeader(player); for (Player p2 : party.getTeam()) party.refreshPartyDetails(p2); } else if (option == 3) { if (player != this.player) { this.player.sendMessage(""You can't switch another player shared-xp.""); return; } player.sendMessage(""Shared xp is currently disabled.""); } } public static ButtonClickHandler handleInspectTab = new ButtonClickHandler(new Object[] { 936, 946 }, e -> { int comp = e.getComponentId(); if (e.getInterfaceId() == 936) { if (comp == 146)// exit button e.getPlayer().getDungManager().openPartyInterface(); if (comp == 134)// inventory e.getPlayer().sendMessage(""Not implemented""); if (comp == 137)// equipment e.getPlayer().sendMessage(""Not implemented""); if (comp == 140)// summoning e.getPlayer().sendMessage(""Not implemented""); } }); private void inspectPlayer(Player p) { player.setCloseInterfacesEvent(this::openPartyInterface); player.getInterfaceManager().sendSub(Sub.TAB_QUEST, 936); String name = p.getUsername(); name = name.substring(0, 1).toUpperCase() + name.substring(1); player.getPackets().setIFText(936, 132, name); player.getPackets().setIFText(936, 7, String.valueOf(p.getSkills().getLevel(Constants.ATTACK))); player.getPackets().setIFText(936, 22, String.valueOf(p.getSkills().getLevel(Constants.STRENGTH))); player.getPackets().setIFText(936, 37, String.valueOf(p.getSkills().getLevel(Constants.DEFENSE))); player.getPackets().setIFText(936, 52, String.valueOf(p.getSkills().getLevel(Constants.RANGE))); player.getPackets().setIFText(936, 67, String.valueOf(p.getSkills().getLevel(Constants.PRAYER))); player.getPackets().setIFText(936, 82, String.valueOf(p.getSkills().getLevel(Constants.MAGIC))); player.getPackets().setIFText(936, 97, String.valueOf(p.getSkills().getLevel(Constants.RUNECRAFTING))); player.getPackets().setIFText(936, 112, String.valueOf(p.getSkills().getLevel(Constants.CONSTRUCTION))); player.getPackets().setIFText(936, 127, String.valueOf(p.getSkills().getLevel(Constants.DUNGEONEERING))); player.getPackets().setIFText(936, 12, String.valueOf(p.getSkills().getLevel(Constants.HITPOINTS))); player.getPackets().setIFText(936, 27, String.valueOf(p.getSkills().getLevel(Constants.AGILITY))); player.getPackets().setIFText(936, 42, String.valueOf(p.getSkills().getLevel(Constants.HERBLORE))); player.getPackets().setIFText(936, 57, String.valueOf(p.getSkills().getLevel(Constants.THIEVING))); player.getPackets().setIFText(936, 72, String.valueOf(p.getSkills().getLevel(Constants.CRAFTING))); player.getPackets().setIFText(936, 87, String.valueOf(p.getSkills().getLevel(Constants.FLETCHING))); player.getPackets().setIFText(936, 102, String.valueOf(p.getSkills().getLevel(Constants.SLAYER))); player.getPackets().setIFText(936, 117, String.valueOf(p.getSkills().getLevel(Constants.HUNTER))); player.getPackets().setIFText(936, 17, String.valueOf(p.getSkills().getLevel(Constants.MINING))); player.getPackets().setIFText(936, 32, String.valueOf(p.getSkills().getLevel(Constants.SMITHING))); player.getPackets().setIFText(936, 47, String.valueOf(p.getSkills().getLevel(Constants.FISHING))); player.getPackets().setIFText(936, 62, String.valueOf(p.getSkills().getLevel(Constants.COOKING))); player.getPackets().setIFText(936, 77, String.valueOf(p.getSkills().getLevel(Constants.FIREMAKING))); player.getPackets().setIFText(936, 92, String.valueOf(p.getSkills().getLevel(Constants.WOODCUTTING))); player.getPackets().setIFText(936, 107, String.valueOf(p.getSkills().getLevel(Constants.FARMING))); player.getPackets().setIFText(936, 122, String.valueOf(p.getSkills().getLevel(Constants.SUMMONING))); player.getPackets().setIFText(936, 8, String.valueOf(p.getSkills().getLevelForXp(Constants.ATTACK))); player.getPackets().setIFText(936, 23, String.valueOf(p.getSkills().getLevelForXp(Constants.STRENGTH))); player.getPackets().setIFText(936, 38, String.valueOf(p.getSkills().getLevelForXp(Constants.DEFENSE))); player.getPackets().setIFText(936, 53, String.valueOf(p.getSkills().getLevelForXp(Constants.RANGE))); player.getPackets().setIFText(936, 68, String.valueOf(p.getSkills().getLevelForXp(Constants.PRAYER))); player.getPackets().setIFText(936, 83, String.valueOf(p.getSkills().getLevelForXp(Constants.MAGIC))); player.getPackets().setIFText(936, 98, String.valueOf(p.getSkills().getLevelForXp(Constants.RUNECRAFTING))); player.getPackets().setIFText(936, 113, String.valueOf(p.getSkills().getLevelForXp(Constants.CONSTRUCTION))); player.getPackets().setIFText(936, 128, String.valueOf(p.getSkills().getLevelForXp(Constants.DUNGEONEERING))); player.getPackets().setIFText(936, 13, String.valueOf(p.getSkills().getLevelForXp(Constants.HITPOINTS))); player.getPackets().setIFText(936, 28, String.valueOf(p.getSkills().getLevelForXp(Constants.AGILITY))); player.getPackets().setIFText(936, 43, String.valueOf(p.getSkills().getLevelForXp(Constants.HERBLORE))); player.getPackets().setIFText(936, 58, String.valueOf(p.getSkills().getLevelForXp(Constants.THIEVING))); player.getPackets().setIFText(936, 73, String.valueOf(p.getSkills().getLevelForXp(Constants.CRAFTING))); player.getPackets().setIFText(936, 88, String.valueOf(p.getSkills().getLevelForXp(Constants.FLETCHING))); player.getPackets().setIFText(936, 103, String.valueOf(p.getSkills().getLevelForXp(Constants.SLAYER))); player.getPackets().setIFText(936, 118, String.valueOf(p.getSkills().getLevelForXp(Constants.HUNTER))); player.getPackets().setIFText(936, 18, String.valueOf(p.getSkills().getLevelForXp(Constants.MINING))); player.getPackets().setIFText(936, 33, String.valueOf(p.getSkills().getLevelForXp(Constants.SMITHING))); player.getPackets().setIFText(936, 48, String.valueOf(p.getSkills().getLevelForXp(Constants.FISHING))); player.getPackets().setIFText(936, 63, String.valueOf(p.getSkills().getLevelForXp(Constants.COOKING))); player.getPackets().setIFText(936, 78, String.valueOf(p.getSkills().getLevelForXp(Constants.FIREMAKING))); player.getPackets().setIFText(936, 93, String.valueOf(p.getSkills().getLevelForXp(Constants.WOODCUTTING))); player.getPackets().setIFText(936, 108, String.valueOf(p.getSkills().getLevelForXp(Constants.FARMING))); player.getPackets().setIFText(936, 123, String.valueOf(p.getSkills().getLevelForXp(Constants.SUMMONING))); } public void invite() { if (party == null || !party.isLeader(player)) return; player.stopAll(); if (party.getDungeon() != null) { player.sendMessage(""You can't do that right now.""); return; } player.sendInputName(""Enter name:"", name -> player.getDungManager().invite(name)); } public void acceptInvite() { Player invitedBy = player.getTempAttribs().removeO(""DUNGEON_INVITED_BY""); if (invitedBy == null) return; DungeonPartyManager party = invitedBy.getDungManager().getParty(); if (invitedBy.getDungManager().invitingPlayer != player || party == null || !party.isLeader(invitedBy)) { player.closeInterfaces(); player.sendMessage(""You can't do that right now.""); return; } if (party.getTeam().size() >= 5) { player.closeInterfaces(); player.sendMessage(""The party is full.""); return; } if (party.getComplexity() > maxComplexity) { player.closeInterfaces(); player.sendMessage(""You can't do this complexity.""); return; } if (party.getFloor() > maxFloor) { player.closeInterfaces(); player.sendMessage(""You can't do this floor.""); return; } invitedBy.getDungManager().resetInvitation(); invitedBy.getDungManager().getParty().setDificulty(0); invitedBy.getDungManager().getParty().add(player); player.stopAll(); invitedBy.stopAll(); } public void invite(String name) { player.stopAll(); if (party == null) { final Player p2 = World.getPlayerByDisplay(name); if (p2 == null) { player.sendMessage(""Unable to find "" + name); return; } DungeonPartyManager party = p2.getDungManager().getParty(); if (p2.getDungManager().invitingPlayer != player || player.getPlane() != 0 || party == null || !party.isLeader(p2)) { player.sendMessage(""You can't do that right now.""); return; } player.getTempAttribs().setO(""DUNGEON_INVITED_BY"", p2); player.getInterfaceManager().sendInterface(949); for (int i = 0; i < 5; i++) { Player teamMate = i >= party.getTeam().size() ? null : party.getTeam().get(i); player.getPackets().sendVarcString(284 + i, teamMate == null ? """" : teamMate.getDisplayName()); player.getPackets().sendVarc(1153 + i, teamMate == null ? -1 : teamMate.getSkills().getCombatLevelWithSummoning()); player.getPackets().sendVarc(1158 + i, teamMate == null ? -1 : teamMate.getSkills().getLevelForXp(Constants.DUNGEONEERING)); player.getPackets().sendVarc(1163 + i, teamMate == null ? -1 : teamMate.getSkills().getHighestSkillLevel()); player.getPackets().sendVarc(1168 + i, teamMate == null ? -1 : teamMate.getSkills().getTotalLevel()); } player.getPackets().sendVarc(1173, party.getFloor()); player.getPackets().sendVarc(1174, party.getComplexity()); player.setCloseInterfacesEvent(() -> { p2.getDungManager().expireInvitation(); player.getTempAttribs().removeO(""DUNGEON_INVITED_BY""); }); } else { if (!party.isLeader(player) || party.getDungeon() != null) { player.sendMessage(""You can't do that right now.""); return; } if (party.getSize() >= 5) { player.sendMessage(""Your party is full.""); return; } Player p2 = World.getPlayerByDisplay(name); if (p2 == null) { player.sendMessage(""That player is offline, or has privacy mode enabled.""); return; } if (!(p2.getControllerManager().getController() instanceof DamonheimController)) { player.sendMessage(""You can only invite a player in or around Daemonheim.""); return; } if (p2.getDungManager().party != null) { player.sendMessage(p2.getDisplayName() + "" is already in a party.""); return; } if (p2.getInterfaceManager().containsScreenInter() || p2.isCantTrade() || p2.isLocked()) { player.sendMessage(""The other player is busy.""); return; } expireInvitation(); invitingPlayer = p2; player.sendMessage(""Sending party invitation to "" + p2.getDisplayName() + ""...""); p2.getPackets().sendDungeonneringRequestMessage(player); } } public void openResetProgress() { player.stopAll(); player.startConversation(new PrestigeReset(player)); } public void switchGuideMode() { if (party == null) { player.sendMessage(""You must be in a party to do that.""); return; } if (party.getDungeon() != null) { player.sendMessage(""You cannot change the guide mode once the dungeon has started.""); return; } if (!party.isLeader(player)) { player.sendMessage(""Only your party's leader can switch guide mode!""); return; } player.stopAll(); party.setGuideMode(!party.getGuideMode()); if (party.getGuideMode()) player.sendMessage(""Guide mode enabled. Your map will show you the critical path, but you will receive an xp penalty.""); else player.sendMessage(""Guide mode disabled. Your map will no longer show the critical path.""); for (Player p2 : party.getTeam()) p2.getDungManager().refreshPartyGuideModeComponent(); } public static int PLAYER_1_FLOORS = 608; public static int PLAYER_2_FLOORS = 486; public static int PLAYER_3_FLOORS = 364; public static int PLAYER_4_FLOORS = 242; public static int PLAYER_5_FLOORS = 120; public static int PLAYER_1_FLOORS_COMPLETE = 670; public static int PLAYER_2_FLOORS_COMPLETE = 548; public static int PLAYER_3_FLOORS_COMPLETE = 426; public static int PLAYER_4_FLOORS_COMPLETE = 304; public static int PLAYER_5_FLOORS_COMPLETE = 183; public void changeFloor() { // if (party.getDungeon() != null) { // player.sendMessage(""You cannot change these settings while in a dungeon.""); // return; // } // if (!party.isLeader(this.player)) { // this.player.sendMessage(""Only your party's leader can change floor!""); // return; // } if (party == null) { player.sendMessage(""You must be in a party to view your floors.""); return; } player.stopAll(); player.getInterfaceManager().sendInterface(947); for (int i = 0; i < party.getMaxFloor(); i++) player.getPackets().setIFHidden(947, 48 + i, false); int highestFloor = 0; for (int index = party.getTeam().size() - 1; index >= 0; index--) { Player teamMate = party.getTeam().get(index); int startComponentCompleted = 0; int startComponentAvailable = 0; if (index == 0) { startComponentCompleted = PLAYER_1_FLOORS_COMPLETE; startComponentAvailable = PLAYER_1_FLOORS; } else if (index == 1) { startComponentCompleted = PLAYER_2_FLOORS_COMPLETE; startComponentAvailable = PLAYER_2_FLOORS; } else if (index == 2) { startComponentCompleted = PLAYER_3_FLOORS_COMPLETE; startComponentAvailable = PLAYER_3_FLOORS; } else if (index == 3) { startComponentCompleted = PLAYER_4_FLOORS_COMPLETE; startComponentAvailable = PLAYER_4_FLOORS; } else if (index == 4) { startComponentCompleted = PLAYER_5_FLOORS_COMPLETE; startComponentAvailable = PLAYER_5_FLOORS; } if (teamMate.getDungManager().getMaxFloor() > highestFloor) highestFloor = teamMate.getDungManager().getMaxFloor(); selectFloor(highestFloor); for (int floor = 0; floor < teamMate.getDungManager().getMaxFloor(); floor++) { player.getPackets().setIFHidden(947, startComponentAvailable + floor, false); if (teamMate.getDungManager().currentProgress[floor]) player.getPackets().setIFHidden(947, startComponentCompleted + floor - 1, false); } player.getPackets().setIFPosition(947, startComponentAvailable + 121, 3, teamMate.getDungManager().getMaxFloor() * 10); } player.getPackets().sendRunScriptReverse(3285, Math.min(highestFloor * 12 + 80, 700)); player.setCloseInterfacesEvent(() -> player.getTempAttribs().removeI(""DUNG_FLOOR"")); } public void selectFloor(int floor) { if (party == null) { player.sendMessage(""You must be in a party to select floors.""); return; } if (player.getDungManager().isInsideDungeon()) { player.sendMessage(""Floor settings cannot be changed in a dungeon.""); return; } if (!party.isLeader(player)) { player.sendMessage(""Only your party's leader can change floor!""); return; } /* * cant happen, cuz u cant click anyway but oh well */ if (party.getMaxFloor() < party.getMaxFloor()) { player.sendMessage(""A member in your party can't do this floor.""); return; } player.getPackets().setIFText(947, 765, """" + floor); player.getTempAttribs().setI(""DUNG_FLOOR"", floor); } public void confirmFloor() { int selectedFloor = player.getTempAttribs().removeI(""DUNG_FLOOR""); player.stopAll(); if (party == null) { player.sendMessage(""You must be in a party to do that.""); return; } if (selectedFloor == -1) selectedFloor = party.getMaxFloor(); if (party.getMaxFloor() < party.getMaxFloor()) { player.sendMessage(""A member in your party can't do this floor.""); return; } if (party.getDungeon() != null) { player.sendMessage(""Floor settings cannot be changed in a dungeon.""); return; } if (!party.isLeader(player)) { player.sendMessage(""Only your party's leader can change floor!""); return; } party.setFloor(selectedFloor); } public void changeComplexity() { if (party == null) { player.sendMessage(""You must be in a party to do that.""); return; } if (party.getDungeon() != null) { player.sendMessage(""You cannot change these settings while in a dungeon.""); return; } if (!party.isLeader(player)) { player.sendMessage(""Only your party's leader can change complexity!""); return; } player.stopAll(); player.getInterfaceManager().sendInterface(938); selectComplexity(party.getMaxComplexity()); player.setCloseInterfacesEvent(() -> player.getTempAttribs().removeI(""DUNG_COMPLEXITY"")); } public void selectComplexity(int complexity) { if (party == null) { player.sendMessage(""You must be in a party to do that.""); return; } if (party.getMaxComplexity() < complexity) { player.sendMessage(""A member in your party can't do this complexity.""); return; } Integer selectedComplexity = player.getTempAttribs().removeI(""DUNG_COMPLEXITY""); if (selectedComplexity != null) markComplexity(selectedComplexity, false); markComplexity(complexity, true); hideSkills(complexity); int penalty = complexity == 6 ? 0 : ((6 - complexity) * 5 + 25); player.getPackets().setIFText(938, 42, """" + complexity); player.getPackets().setIFText(938, 119, penalty + ""% XP Penalty""); player.getTempAttribs().setI(""DUNG_COMPLEXITY"", complexity); } public void confirmComplexity() { int selectedComplexity = player.getTempAttribs().removeI(""DUNG_COMPLEXITY""); player.stopAll(); if (selectedComplexity == -1) return; if (party == null) { player.sendMessage(""You must be in a party to do that.""); return; } if (party.getMaxComplexity() < selectedComplexity) { player.sendMessage(""A member in your party can't do this complexity.""); return; } if (party.getDungeon() != null) { player.sendMessage(""You cannot change these settings while in a dungeon.""); return; } if (!party.isLeader(player)) { player.sendMessage(""Only your party's leader can change complexity!""); return; } party.setComplexity(selectedComplexity); } private void markComplexity(int complexity, boolean mark) { player.getPackets().setIFHidden(938, 57 + ((complexity - 1) * 5), !mark); } private static final String[] COMPLEXITY_SKILLS = { ""Combat"", ""Cooking"", ""Firemaking"", ""Woodcutting"", ""Fishing"", ""Creating Weapons"", ""Mining"", ""Runecrafting"", ""Farming Textiles"", ""Hunting"", ""Creating Armour"", ""Farming Seeds"", ""Herblore"", ""Thieving"", ""Summoning"", ""Construction"" }; private void hideSkills(int complexity) { int count = 0; if (complexity >= 1) count += 1; if (complexity >= 2) count += 4; if (complexity >= 3) count += 3; if (complexity >= 4) count += 3; if (complexity >= 5) count += 5; if (complexity >= 6) count += 1; for (int i = 0; i < COMPLEXITY_SKILLS.length; i++) player.getPackets().setIFText(938, 90 + i, (i >= count ? """" : """") + COMPLEXITY_SKILLS[i]); } public void expireInvitation() { if (invitingPlayer == null) return; player.sendMessage(""Your dungeon party invitation to "" + invitingPlayer.getDisplayName() + "" has expired.""); invitingPlayer.sendMessage(""A dungeon party invitation from "" + player.getDisplayName() + "" has expired.""); invitingPlayer = null; } public void enterDungeon(boolean selectSize) { player.stopAll(); expireInvitation(); if (party == null) { player.startConversation(new DungeonPartyStart(player)); return; } if (party.getDungeon() != null) // cant happen return; if (!party.isLeader(player)) { player.sendMessage(""Only your party's leader can start a dungeon!""); return; } if (party.getFloor() == 0) { changeFloor(); return; } if (party.getComplexity() == 0) { changeComplexity(); return; } if (party.getDificulty() == 0) { if (party.getTeam().size() != 1) { player.startConversation(new DungeonDifficulty(player, party.getTeam().size())); return; } party.setDificulty(1); } if (selectSize) { if (party.getComplexity() == 6) { player.startConversation(new DungeonSize(player)); return; } party.setSize(DungeonConstants.SMALL_DUNGEON); } for (Player p2 : party.getTeam()) { for (Item item : p2.getInventory().getItems().array()) if (isBannedDungItem(item)) { player.sendMessage(p2.getDisplayName() + "" is carrying items that cannot be taken into Daemonheim.""); return; } for (Item item : p2.getEquipment().getItemsCopy()) if (isBannedDungItem(item)) { player.sendMessage(p2.getDisplayName() + "" is carrying items that cannot be taken into Daemonheim.""); return; } if (p2.getFamiliar() != null || p2.getPet() != null) { player.sendMessage(p2.getDisplayName() + "" is carrying a familiar that cannot be taken into Daemonheim.""); return; } if (p2.getPlane() != 0 || p2.getInterfaceManager().containsScreenInter() || p2.isLocked() || !(p2.getControllerManager().getController() instanceof DamonheimController)) { player.sendMessage(p2.getDisplayName() + "" is busy.""); return; } } party.start(); } public static boolean isBannedDungItem(Item item) { if (item == null) return false; return switch(item.getId()) { case 15707, 18508, 18509, 18510, 19709, 19710, 5733, 25349 -> false; default -> true; }; } public void setSize(int size) { if (party == null || !party.isLeader(player) || party.getComplexity() != 6) return; party.setSize(size); } public void setDificulty(int dificulty) { if (party == null || !party.isLeader(player)) return; party.setDificulty(dificulty); } public void resetInvitation() { if (invitingPlayer == null) return; invitingPlayer = null; } public void refreshNames() { if (party == null) { player.getPackets().setIFHidden(939, 59, true); player.getPackets().setIFHidden(939, 62, true); player.getPackets().setIFHidden(939, 65, true); player.getPackets().setIFHidden(939, 68, true); player.getPackets().setIFHidden(939, 71, true); return; } int index; for (Player selectedPlayer : party.getTeam()) { index = 0; for (Player memberPosition : party.getTeam()) selectedPlayer.getPackets().sendVarcString(292 + index++, memberPosition.getDisplayName()); } refreshDungRingPlayerNames(); } public void refreshDungRingPlayerNames() { for (Player player : party.getTeam()) for (int i = 0; i < 5; i++) hideICompRingPlayerText(player, i, i >= party.getTeam().size()); } public static void hideICompRingPlayerText(Player p, int slot, boolean hidden) { if (slot >= 0 && slot <= 4) p.getPackets().setIFHidden(939, slot == 0 ? 59 : slot == 1 ? 62 : slot == 2 ? 65 : slot == 3 ? 68 : 71, hidden); } public void refreshFloor() { player.getPackets().sendVarc(1180, party == null ? 0 : party.getFloor()); } public void refreshComplexity() { player.getPackets().sendVarc(1183, party == null ? 0 : party.getComplexity()); } public void refreshCurrentProgress() { player.getPackets().sendVarc(1181, getCurrentProgress()); } public void refreshPreviousProgress() { player.getPackets().sendVarc(1182, previousProgress); } public DungeonPartyManager getParty() { return party; } public void setParty(DungeonPartyManager party) { this.party = party; } public void formParty() { if (!player.getInterfaceManager().topOpen(939)) openPartyInterface(); if (party != null) return; if (!(player.getControllerManager().getController() instanceof DamonheimController) || player.getPlane() != 0) { player.sendMessage(""You can only form a party in or around Daemonheim.""); return; } player.stopAll(); new DungeonPartyManager().add(player); refreshFloor(); refreshCurrentProgress(); refreshPreviousProgress(); refreshComplexity(); refreshPartyDetailsComponents(); refreshPartyGuideModeComponent(); refreshNames(); } public void finish() { if (party != null) party.leaveParty(player, true); } public void checkLeaveParty() { if (party == null) return; if (party.getDungeon() != null) player.startConversation(new DungeonLeaveParty(player)); else leaveParty(); } public void leaveParty() { if (party != null) party.leaveParty(player, false); } public KinshipPerk getActivePerk() { if (activeRingPerk == null || getKinshipTier(activeRingPerk) == 0) return null; return activeRingPerk; } }" "package com.rs.game.content.skills.dungeoneering; public class FamiliarSpecs { public static int snaringWave(Player owner, Familiar familiar, Entity target, int tier) { target.freeze(8, true); familiar.setNextSpotAnim(new SpotAnim(2591)); familiar.setNextAnimation(new Animation(13620)); delayHit(familiar, World.sendProjectile(familiar, target, 2592, 41, 16, 41, 2.0, 16, 0).getTaskDelay(), target, getMagicHit(familiar, getMaxHit(familiar, (int) (familiar.getMaxHit() * (1.0 + (0.05 * tier))), AttackStyle.MAGE, target, 1.5)), () -> target.setNextSpotAnim(new SpotAnim(2593))); return Familiar.DEFAULT_ATTACK_SPEED; } public static int poisonousShot(Player owner, Familiar familiar, Entity target, int tier) { familiar.setNextAnimation(new Animation(13203)); familiar.setNextSpotAnim(new SpotAnim(2447)); delayHit(familiar, World.sendProjectile(familiar, target, 2448, 41, 16, 41, 2.0, 16, 0).getTaskDelay(), target, getRangeHit(familiar, getMaxHit(familiar, (int) (familiar.getMaxHit() * (1.0 + (0.05 * tier))), AttackStyle.RANGE, target, 1.5)), () -> target.getPoison().makePoisoned(18+tier)); return Familiar.DEFAULT_ATTACK_SPEED; } public static int sunderingStrike(Player owner, Familiar familiar, Entity target, int tier) { familiar.setNextAnimation(new Animation(13198)); familiar.setNextSpotAnim(new SpotAnim(2444)); Hit hit = getMeleeHit(familiar, getMaxHit(familiar, (int) (familiar.getMaxHit() * (1.0 + (0.05 * tier))), AttackStyle.MELEE, target, 1.5)); delayHit(familiar, 1, target, hit); if (hit.getDamage() > 0 && target instanceof NPC n) n.lowerDefense((hit.getDamage() / 20) * tier, 0.0); return Familiar.DEFAULT_ATTACK_SPEED; } public static boolean aptitude(Player player, Familiar familiar, int boost) { if (player.hasEffect(Effect.DUNG_HS_SCROLL_BOOST)) { player.sendMessage(""You already are benefiting from an invisible skill boost.""); return false; } familiar.setNextAnimation(new Animation(13213)); player.setNextSpotAnim(new SpotAnim(1300)); player.addEffect(Effect.DUNG_HS_SCROLL_BOOST, Ticks.fromMinutes(1)); player.getTempAttribs().setI(""hsDungScrollTier"", boost); return true; } // TODO: secondWind always returns false public static boolean secondWind(Player player, Familiar familiar, int amount) { if (player.getRunEnergy() >= 100) { player.sendMessage(""You are already full run energy.""); return false; } familiar.setNextAnimation(new Animation(13213)); player.setNextSpotAnim(new SpotAnim(1300)); player.restoreRunEnergy(amount); return false; } public static boolean glimmer(Player player, Familiar familiar, int amount) { if (player.getHitpoints() >= player.getMaxHitpoints()) { player.sendMessage(""This scroll would have no effect.""); return false; } familiar.sync(13678, 2445); player.heal(amount); WorldTasks.delay(1, () -> player.spotAnim(2443)); return true; } }" "package com.rs.game.content.skills.dungeoneering; public enum KinshipPerk { TANK(), //DONE TACTICIAN(), //DONE BERSERKER(), //DONE SNIPER(), //TODO KEEN_EYE(), //DONE DESPERADO(), //DONE BLAZER(), //DONE BLASTER(), //TODO BLITZER(), //DONE MEDIC(), //DONE GATHERER(), //TODO ARTISAN(); //TODO public int getVarbit() { return 8053 + ordinal(); } public int getItemId() { return 18817 + ordinal(); } }" "package com.rs.game.content.skills.dungeoneering; public class Room { private HandledRoom room; private final int rotation; private int dropId; // private int creationIndex; private Door[] doors; private int thiefChest; private boolean critPath; public Room(HandledRoom room, int rotation) { this.room = room; this.rotation = rotation; reset(); thiefChest = -1; } public void reset() { critPath = false; dropId = -1; doors = new Door[room.getDoorDirections().length]; } public void setDoor(int index, Door door) { doors[index] = door; } public Door getDoor(int index) { return doors[index]; } public int getDoorsCount() { return doors.length; } public Door getDoorByRotation(int rotation) { int index = getDoorIndexByRotation(rotation); return index == -1 ? null : getDoor(index); } public void removeGuardianDoors() { for (int i = 0; i < doors.length; i++) { Door door = doors[i]; if (door != null && door.getType() == DungeonConstants.GUARDIAN_DOOR) doors[i] = null; } } public void removeChallengeDoors() { for (int i = 0; i < doors.length; i++) { Door door = doors[i]; if (door != null && door.getType() == DungeonConstants.CHALLENGE_DOOR) doors[i] = null; } } public int getDoorIndexByRotation(int rotation) { for (int i = 0; i < room.getDoorDirections().length; i++) if ((room.getDoorDirections()[i] + this.rotation & 0x3) == rotation) return i; return -1; } public int getChunkX(int complexity) { return room.getChunkX() + getChunkXOffset(complexity); } public int getChunkY(int type) { return room.getChunkY() + getChunkYOffset(type); } public int getChunkXOffset(int complexity) { return complexity < 6 && room instanceof StartRoom ? (complexity <= 2 ? -6 : -(5 - complexity) * 2) : 0; } public int getChunkYOffset(int type) { return (room instanceof StartRoom ? 16 : room instanceof NormalRoom ? 48 : room instanceof HandledPuzzleRoom ? 16 : 0) * type; } public int getRotation() { return rotation; } @Override public String toString() { return ""[Room]["" + rotation + ""]"" + "", "" + Arrays.toString(room.getDoorDirections()) + "", "" + (getChunkX(0) << 3) + "", "" + (getChunkY(0) << 3); } public boolean hasSouthDoor() { return room.hasSouthDoor(rotation); } public boolean hasNorthDoor() { return room.hasNorthDoor(rotation); } public boolean hasWestDoor() { return room.hasWestDoor(rotation); } public boolean hasEastDoor() { return room.hasEastDoor(rotation); } public boolean hasDoor(int dir) { return room.hasDoor((dir - rotation) & 0x3); } public boolean containsOnlySouthDoor() { return room.getDoorDirections().length == 1 && room.getDoorDirections()[0] == DungeonConstants.SOUTH_DOOR; } public void setRoom(HandledRoom room) { this.room = room; } public HandledRoom getRoom() { return room; } public void openRoom(DungeonManager dungeon, RoomReference reference) { room.openRoom(dungeon, reference); } // public int getCreationIndex() { // return creationIndex; // } // // public void setCreationIndex(int creationIndex) { // this.creationIndex = creationIndex; // } public int getDropId() { return dropId; } public void setDropId(int dropId) { this.dropId = dropId; } public int getThiefChest() { return thiefChest; } public void setThiefChest(int thiefChest) { this.thiefChest = thiefChest; } public boolean isCritPath() { return critPath; } public void setCritPath(boolean critPath) { this.critPath = critPath; } }" "package com.rs.game.content.skills.dungeoneering; public class RoomNode { int x; int y; int key; int lock; boolean isCritPath; boolean isBoss; public RoomNode parent; public List children; public RoomNode(RoomNode parent, int x, int y) { key = -1; lock = -1; children = new ArrayList<>(); this.parent = parent; if (parent != null) //Base doesn't have a parent parent.children.add(this); this.x = x; this.y = y; } public boolean north() { return children.stream().anyMatch(c -> c.y - 1 == y) || (parent != null && parent.y - 1 == y); } public boolean east() { return children.stream().anyMatch(c -> c.x - 1 == x) || (parent != null && parent.x - 1 == x); } public boolean south() { return children.stream().anyMatch(c -> c.y + 1 == y) || (parent != null && parent.y + 1 == y); } public boolean west() { return children.stream().anyMatch(c -> c.x + 1 == x) || (parent != null && parent.x + 1 == x); } public int rotation() { if(parent == null) throw new RuntimeException(""Cannot calculate rotation for base, no parent""); if(parent.y - y == -1) return 0; if(parent.x - x == -1) return 1; if(parent.y - y == 1) return 2; if(parent.x - x == 1) return 3; throw new RuntimeException(""Cannot calculate rotation, parent is not adjacent""); } public List pathToBase() { List path = new LinkedList<>(); RoomNode p = this; while(p != null) { path.add(p); p = p.parent; } return path; } public List getChildrenR() { return Stream.concat(children.stream(), children.stream().flatMap(r -> r.getChildrenR().stream())).collect(Collectors.toList()); } }" "package com.rs.game.content.skills.dungeoneering; public class RoomReference { private final int x, y; public RoomReference(int x, int y) { this.x = x; this.y = y; } public int getRoomX() { return x; } public int getRoomY() { return y; } public int getBaseX() { return x * 16; } public int getBaseY() { return y * 16; } @Override public boolean equals(Object object) { if (object instanceof RoomReference rRef) return x == rRef.x && y == rRef.y; return false; } @Override public String toString() { return ""[RoomReference]["" + x + ""]["" + y + ""]""; } }" "package com.rs.game.content.skills.dungeoneering; public class VisibleRoom { private int[] musicId; private ArrayList guardians; private int guardianCount; private boolean noMusic; private boolean loaded; protected RoomReference reference; protected DungeonManager manager; protected int type; // TODO: Remove this for a constructor, to satisfy synchronizing non-final field `manager` public void init(DungeonManager manager, RoomReference ref, int type, HandledRoom room) { this.type = type; reference = ref; this.manager = manager; if (room instanceof StartRoom) musicId = new int[] { DungeonConstants.START_ROOM_MUSICS[type] }; else if (room instanceof BossRoom) musicId = new int[] { ((BossRoom) room).getMusicId() }; else { musicId = new int[] { DungeonUtils.getSafeMusic(type), DungeonUtils.getDangerousMusic(type) }; guardians = new ArrayList<>(); } } public int getMusicId() { return noMusic ? -2 : musicId[roomCleared() ? 0 : 1]; } public boolean roomCleared() { if (guardians == null) return true; for (NPC n : guardians) if (!n.hasFinished() && !n.isDead()) return false; return true; } public void addGuardian(NPC n) { guardians.add(n); guardianCount++; } public boolean removeGuardians() { if (roomCleared()) { guardians = null; return true; } return false; } public void forceRemoveGuardians() { if (guardians != null) { for (NPC n : guardians) n.finish(); guardians.clear(); } } public int getGuardiansCount() { return guardianCount; } public int getKilledGuardiansCount() { return guardians == null ? guardianCount : (guardianCount - guardians.size()); } public void setNoMusic() { noMusic = true; } public boolean isLoaded() { return loaded; } public void setLoaded() { loaded = true; } public void destroy() { } public void openRoom() { } public boolean processObjectClick1(Player p, GameObject object) { return true; } public boolean processObjectClick2(Player p, GameObject object) { return true; } public boolean processObjectClick3(Player p, GameObject object) { return true; } public boolean processObjectClick4(Player p, GameObject object) { return true; } public boolean processObjectClick5(Player p, GameObject object) { return true; } public boolean handleItemOnObject(Player player, GameObject object, Item item) { return true; } public boolean processNPCClick1(Player player, NPC npc) { return true; } public boolean processNPCClick2(Player player, NPC npc) { return true; } public boolean canMove(Player player, Tile to) { return true; } public boolean processNPCClick3(Player player, NPC npc) { return true; } }" "package com.rs.game.content.skills.dungeoneering.dialogues; public class DungeonClimbLadder extends Conversation { public DungeonClimbLadder(Player player, DungeonController controller) { super(player); addOptions(""Are you sure you wish to proceed and take your party with you?"", (ops) -> { ops.add(""Yes."", controller::voteToMoveOn); ops.add(""No.""); }); } }" "package com.rs.game.content.skills.dungeoneering.dialogues; public class DungeonDifficulty extends Conversation { public DungeonDifficulty(Player player, int partySize) { super(player); addOptions(""What difficulty of dungeon would you like?"", (ops) -> { for(int i = 1; i <= partySize; i++) { final int size = i; ops.option(i + (i == partySize ? "" (recommended)"" : """"), new Dialogue().addNext(() -> { player.getDungManager().setDificulty(size); player.getDungManager().enterDungeon(true); })); } }); create(); } }" "package com.rs.game.content.skills.dungeoneering.dialogues; @PluginEventHandler public class DungeoneeringTutor extends Conversation { private static final int DUNGEON_TUTOR = 9712; public static NPCClickHandler talk = new NPCClickHandler(new Object[] { DUNGEON_TUTOR }, e -> e.getPlayer().startConversation(new DungeoneeringTutor(e.getPlayer()))); public DungeoneeringTutor(Player player) { super(player); addNPC(DUNGEON_TUTOR, HeadE.CHEERFUL, ""Greetings, adventurer!""); if (!player.containsItem(15707)) { addNPC(DUNGEON_TUTOR, HeadE.CHEERFUL, ""Before we carry on, let me give you this.""); if (player.getInventory().hasFreeSlots()) addItem(15707, ""He hands you a ring."", () -> player.getInventory().addItem(new Item(15707, 1))); else { addSimple(""Your inventory is currently full.""); create(); return; } } addOptions((ops) -> { ops.add(""What is this place?"", new Dialogue() .addPlayer(HeadE.CONFUSED, ""What is this place?"") .addNPC(DUNGEON_TUTOR, HeadE.CHEERFUL_EXPOSITION, ""This is a place of treasures, fierce battles and bitter defeats."") .addNPC(DUNGEON_TUTOR, HeadE.ANGRY, ""We fought our way into the dungeons beneath this place."") .addNPC(DUNGEON_TUTOR, HeadE.ANGRY, ""Those of us who made it out alive..."") .addNPC(DUNGEON_TUTOR, HeadE.ANGRY, ""...called this place Daemonhiem."")); ops.add(""What can I do here?"", new Dialogue() .addPlayer(HeadE.CONFUSED, ""What can I do here?"") .addNPC(DUNGEON_TUTOR, HeadE.CHEERFUL_EXPOSITION, ""Beneath these ruins you will find a multitude of dungeons, filled with strange creatures and resources."") .addNPC(DUNGEON_TUTOR, HeadE.CHEERFUL_EXPOSITION, ""Unfortunately, due to the taint that permiates this place, we cannot risk you taking items in or out of Daemonhiem."")); ops.add(""What does this ring do?"", new Dialogue() .addPlayer(HeadE.CONFUSED, ""What does this ring do?"") .addNPC(DUNGEON_TUTOR, HeadE.CHEERFUL_EXPOSITION, ""Raiding these foresaken dungeons can be alot more rewarding if you're fighting alongside friends and allies. It should be more fun and you gain experience faster."") .addNPC(DUNGEON_TUTOR, HeadE.CHEERFUL_EXPOSITION, ""The ring shows others you are interested in raiding a dungeon. It allowes you to form, join, and manage a raiding party."") .addNPC(DUNGEON_TUTOR, HeadE.CHEERFUL_EXPOSITION, ""We've also setup rooms with the specific purpose of finding a party for you."")); ops.add(""Nevermind.""); }); } }" "package com.rs.game.content.skills.dungeoneering.dialogues; public class DungeonExit extends Conversation { public DungeonExit(Player player, DungeonController controller) { super(player); addSimple(""This ladder leads back to the surface. You will not be able to come back to this dungeon if you leave.""); addOptions(""Leave the dungeon and return to the surface?"", (ops) -> { ops.add(""Yes."", controller::leaveDungeon); ops.add(""No.""); }); } }" "package com.rs.game.content.skills.dungeoneering.dialogues; public class DungeonLeave extends Conversation { public DungeonLeave(Player player, DungeonController controller) { super(player); addOptions(""Leave the dungeon permanently?"", (ops) -> { ops.add(""Yes."", controller::leaveDungeonPermanently); ops.add(""No.""); }); } }" "package com.rs.game.content.skills.dungeoneering.dialogues; public class DungeonLeaveParty extends Conversation { public DungeonLeaveParty(Player player) { super(player); addSimple(""Warning: If you leave the dungeon, you will not be able to return to it!""); addOptions(""Leave the dungeon for good?"", (ops) -> { ops.add(""Yes."", player.getDungManager()::leaveParty); ops.add(""No."", new Dialogue()); }); create(); } }" "package com.rs.game.content.skills.dungeoneering.dialogues; public class DungeonPartyStart extends Conversation { public DungeonPartyStart(Player player) { super(player); addSimple(""You must be in a party to enter a dungeon.""); addOptions(""Would you like to start a dungeon?"", (ops) -> { ops.add(""Yes."", player.getDungManager()::formParty); ops.add(""No.""); }); create(); } }" "package com.rs.game.content.skills.dungeoneering.dialogues; public class DungeonSize extends Conversation { public DungeonSize(Player player) { super(player); DungeonPartyManager party = player.getDungManager().getParty(); addSimple(""What size of dungeon would you like?""); addOptions(""Would you like to start a dungeon?"", (ops) -> { ops.add(""Small."", () -> { if(party != null) { player.getDungManager().setSize(DungeonConstants.SMALL_DUNGEON); player.getDungManager().enterDungeon(false); } }); ops.add(""Medium."", () -> { if(party != null) { player.getDungManager().setSize(DungeonConstants.MEDIUM_DUNGEON); player.getDungManager().enterDungeon(false); } }); ops.add(""Large."", () -> { if(party != null) { player.getDungManager().setSize(DungeonConstants.LARGE_DUNGEON); player.getDungManager().enterDungeon(false); } }); }); create(); } }" "package com.rs.game.content.skills.dungeoneering.dialogues; public class PrestigeReset extends Conversation { public PrestigeReset(Player player) { super(player); addSimple(""Are you sure you want to reset your dungeon progress? Your previous progress will be set to the number of floors you have completed and all floors will be marked as incomplete. This cannot be undone.""); addOptions(""Are you sure?"", (ops) -> { ops.add(""Yes, reset my progress."", player.getDungManager()::resetProgress); ops.add(""No, don't reset my progress.""); }); create(); } }" "package com.rs.game.content.skills.dungeoneering.npcs; public class KalGerWarmonger extends DungeonBoss { private static final int SIZE = 5; private static final int[] WEAPONS = { -1, 56057, 56054, 56056, 56055, 56053 }; private static final int[][] FLY_COORDINATES = { { 4, 2 }, // correct { 0, 0 }, // correct cuz he doesn't even fly { 10, 10 }, // correct { 10, 2 }, // correct { 5, 10 }, // correct { 5, 3 } // correct }; private WarpedSphere sphere; private GameObject nextWeapon; private int type, typeTicks, pullTicks, annoyanceMeter; private boolean stolenEffects; public KalGerWarmonger(Tile tile, final DungeonManager manager, final RoomReference reference) { super(DungeonUtils.getClosestToCombatLevel(Utils.range(12752, 12766), manager.getBossLevel()), tile, manager, reference); setCapDamage(5000); setCantInteract(true); typeTicks = -1; WorldTasks.scheduleTimer(3, (ticks) -> { //playSoundEffect(3033); setNextForceTalk(new ForceTalk(""NOW IT'S YOUR TURN!"")); sphere = new WarpedSphere(reference, 12842, manager.getTile(reference, 11, 12), manager); beginFlyCount(); return false; }); } private void beginFlyCount() { type++; if (type != 1) setHitpoints((int) (getHitpoints() + (getMaxHitpoints() * .15D)));// He heals a bit not 100% sure what the multiplier is typeTicks = type == 2 ? 7 : 0; setCantInteract(true); setNextFaceEntity(null);//Resets? } @Override public void processHit(Hit hit) { if (type != 6) { int max_hp = getMaxHitpoints(), nextStageHP = (int) (max_hp - (max_hp * (type * .20))); if (getHitpoints() - hit.getDamage() < nextStageHP) { hit.setDamage(getHitpoints() - (nextStageHP - 1)); beginFlyCount(); } } super.processHit(hit); } @Override public void handlePreHitOut(Entity target, Hit hit) { if (annoyanceMeter == 10) { annoyanceMeter = 0;// resets it if (target instanceof Player player) { player.setProtectionPrayBlock(2); player.sendMessage(""You have been injured and cannot use protective prayers.""); } hit.setDamage(target.getHitpoints() - 1); } else if (hit.getDamage() == 0) if (target instanceof Player player) if (player.getPrayer().isUsingProtectionPrayer()) annoyanceMeter++; } @Override public void processNPC() { super.processNPC(); if (typeTicks >= 0) { processNextType(); typeTicks++; } else if (type != 0) { pullTicks++; if (isMaximumPullTicks()) { submitPullAttack(); } } } public boolean isUsingMelee() { return getAttackStyle() == AttackStyle.MELEE; } @Override public void sendDeath(Entity source) { super.sendDeath(source); setNextSpotAnim(new SpotAnim(2754)); setNextForceTalk(new ForceTalk(""Impossible!"")); final NPC boss = this; WorldTasks.schedule(new Task() { @Override public void run() { for (Entity t : getPossibleTargets()) if (Utils.inCircle(t.getTile(), boss.getTile(), 8)) t.applyHit(new Hit(boss, Utils.random(300, 990), HitLook.TRUE_DAMAGE)); } }, 2); } @Override public int getMaxHit() { return getCombatLevel() < 300 ? 400 : 650; } @Override public int getMaxHitpoints() { return super.getMaxHitpoints() * 2;//Maybe * 3 } @Override public double getMagePrayerMultiplier() { return .6; } @Override public double getRangePrayerMultiplier() { return .6; } @Override public double getMeleePrayerMultiplier() { return stolenEffects ? 1 : type == 4 ? .3 : .6; } private void processNextType() { if (getManager().isDestroyed()) // Should fix some nullpointers return; if (typeTicks == 1) { setNextSpotAnim(new SpotAnim(2870)); final int[] FLY_LOCATION = FLY_COORDINATES[type - 1]; Tile nextFlyTile = getManager().getTile(getReference(), FLY_LOCATION[0], FLY_LOCATION[1], SIZE, SIZE); forceMove(nextFlyTile, 14995, 25, 150, () -> spotAnim(2870)); } else if (typeTicks == 9) { if (type == 1) { typeTicks = 16; return; } int selectedWeapon = WEAPONS[type - 1]; outer: for (int x = 0; x < 16; x++) for (int y = 0; y < 16; y++) { GameObject next = getManager().getObjectWithType(getReference(), ObjectType.SCENERY_INTERACT, x, y); if (next != null && next.getId() == selectedWeapon) { nextWeapon = next; break outer; } } calcFollow(nextWeapon, false); } else if (typeTicks == 11) { faceObject(nextWeapon); setNextAnimation(new Animation(15027)); } else if (typeTicks == 13) setNextAnimation(new Animation(14923 + (type - 1))); else if (typeTicks == 14) { transformIntoNPC(getId() + 17); World.removeObject(nextWeapon); } else if (typeTicks == 17) { if (type == 6) stealPlayerEffects(); sphere.nextStage(); setCantInteract(false); typeTicks = -2;// cuz it increments by one } } private void submitPullAttack() { //playSoundEffect(3025); setNextForceTalk(new ForceTalk(""You dare hide from me? BURN!"")); setNextAnimation(new Animation(14996)); final NPC boss = this; WorldTasks.scheduleLooping(new Task() { private int ticks; private List possibleTargets; @Override public void run() { ticks++; if (ticks == 1) { possibleTargets = getPossibleTargets(); Tile tile = getManager().getTile(getReference(), 9, 8); for (Entity t : possibleTargets) if (t instanceof Player player) { player.setCantWalk(true); YkLagorThunderousCombat.sendPullAttack(tile, player, false); } } else if (ticks == 10) { for (Entity t : getPossibleTargets()) t.tele(Tile.of(boss.getTile())); stop(); pullTicks = 0; } else if (ticks > 3) for (Entity t : possibleTargets) { if (!getManager().isAtBossRoom(t.getTile())) continue; ((Player) t).setCantWalk(false); if (Utils.random(5) == 0) t.setNextForceTalk(new ForceTalk(""Ow!"")); if (ticks == 8) { t.setNextAnimation(new Animation(14388)); setNextAnimation(new Animation(14996)); } t.applyHit(new Hit(boss, Utils.random(33, 87), HitLook.TRUE_DAMAGE)); } } }, 0, 0); } private void stealPlayerEffects() { //playSoundEffect(3029); setNextForceTalk(new ForceTalk(""Your gods can't help you now!"")); for (Player player : getManager().getParty().getTeam()) { if (!getManager().getCurrentRoomReference(player.getTile()).equals(getReference())) continue; boolean usingPiety = player.getPrayer().active(Prayer.PIETY); boolean usingTurmoil = player.getPrayer().active(Prayer.TURMOIL); if (!usingPiety && !usingTurmoil) continue; player.sendMessage(""The Warmonger steals your "" + (usingPiety ? ""Piety"" : ""Turmoil"") + "" effects!""); stolenEffects = true; } } public int getType() { return type; } public void setPullTicks(int pullCount) { pullTicks = pullCount; } public boolean hasStolenEffects() { return stolenEffects; } public int getAnnoyanceMeter() { return annoyanceMeter; } public void setAnnoyanceMeter(int annoyanceMeter) { this.annoyanceMeter = annoyanceMeter; } public boolean isMaximumPullTicks() { return pullTicks == 35; } }" "package com.rs.game.content.skills.dungeoneering.npcs; public final class DivineSkinweaver extends DungeonBoss { private static final int[][] HOLES = { { 0, 10 }, { 5, 15 }, { 11, 15 }, { 15, 10 }, { 15, 5 } }; private static final String[] CLOSE_HOLE_MESSAGES = { ""Ride the wind and smite the tunnel."", ""We have little time, tear down the tunnel."", ""Churra! Bring down the tunnel while you can."" }; private final boolean[] holeClosed; private int count; private boolean requestedClose; private int healDelay; private int respawnDelay; private final List skeletons; private int killedCount; public DivineSkinweaver(int id, Tile tile, DungeonManager manager, RoomReference reference) { super(id, tile, manager, reference); holeClosed = new boolean[5]; skeletons = new CopyOnWriteArrayList<>(); setIgnoreDocile(true); setForceAgressive(true); } public void removeSkeleton(DungeonSkeletonBoss skeleton) { skeletons.remove(skeleton); if (!requestedClose && count < holeClosed.length) { killedCount++; if (killedCount == 3) { requestedClose = true; killedCount = 0; setNextForceTalk(new ForceTalk(CLOSE_HOLE_MESSAGES[Utils.random(CLOSE_HOLE_MESSAGES.length)])); for (Player p2 : getManager().getParty().getTeam()) { if (!getManager().isAtBossRoom(p2.getTile())) continue; p2.sendMessage(""Divine skinweaver: "" + getNextForceTalk().text()); } } } } private int[] getOpenHole() { List holes = new ArrayList<>(); for (int[] hole : HOLES) { GameObject object = getManager().getObjectWithType(getReference(), 49289, ObjectType.WALL_STRAIGHT, hole[0], hole[1]); if (object != null && object.getId() != 49289) holes.add(new int[] { object.getX() + Utils.ROTATION_DIR_X[object.getRotation()], object.getY() + Utils.ROTATION_DIR_Y[object.getRotation()] }); } if (holes.isEmpty()) return null; return holes.get(Utils.random(holes.size())); } @Override public void processNPC() { List targets = getPossibleTargets(); if(targets.isEmpty()) removeAllSkeletons(); if (respawnDelay > 0) respawnDelay--; else if (count < holeClosed.length && !targets.isEmpty() && skeletons.size() < 20) { // blablala spawn skeletons int[] coords = getOpenHole(); if (coords != null) { int skeleType = Utils.random(3); // TODO: cbLevel should be half of what they are *supposed* to be, I'm not sure if getCloestToCombatLevel is accurate for level selection here int cbLevel = getManager().getCombatLevelMonster(); cbLevel = (int) (cbLevel - Math.ceil(cbLevel * 0.20)); if (skeleType == 0) skeletons.add((DungeonSkeletonBoss) getManager().spawnNPC(DungeonUtils.getClosestToCombatLevel(GuardianMonster.SKELETON_MAGIC.getNPCIds(), cbLevel), 0, Tile.of(coords[0], coords[1], 0), getReference(), DungeonConstants.BOSS_NPC)); else if (skeleType == 1) skeletons.add((DungeonSkeletonBoss) getManager().spawnNPC(DungeonUtils.getClosestToCombatLevel(GuardianMonster.SKELETON_MELEE.getNPCIds(), cbLevel), 0, Tile.of(coords[0], coords[1], 0), getReference(), DungeonConstants.BOSS_NPC)); else if (skeleType == 2) skeletons.add((DungeonSkeletonBoss) getManager().spawnNPC(DungeonUtils.getClosestToCombatLevel(GuardianMonster.SKELETON_RANGED.getNPCIds(), cbLevel), 0, Tile.of(coords[0], coords[1], 0), getReference(), DungeonConstants.BOSS_NPC)); respawnDelay = 20; } } if (healDelay > 0) { healDelay--; return; } Entity healTarget = null; for (Entity target : targets) { if (target.getHitpoints() >= target.getMaxHitpoints()) continue; if (healTarget == null || Utils.getDistance(getTile(), healTarget.getTile()) > Utils.getDistance(getTile(), target.getTile())) healTarget = target; } if (healTarget == null) return; int distance = (int) (4 - Utils.getDistance(getTile(), healTarget.getTile())); if (distance == 4 || distance < 0) return; int maxHeal = (int) (healTarget.getMaxHitpoints() * 0.35); healTarget.heal((distance + 1) * maxHeal / 4, 60); setNextAnimation(new Animation(13678)); setNextSpotAnim(new SpotAnim(2445)); healTarget.setNextSpotAnim(new SpotAnim(2443, 60, 0)); faceEntity(healTarget); healDelay = 4; } private void removeAllSkeletons() { for (DungeonSkeletonBoss skeleton : skeletons) skeleton.sendDeath(skeleton); } public void talkTo(Player player) { if (count < holeClosed.length || !skeletons.isEmpty()) { player.npcDialogue(getId(), HeadE.CALM_TALK, ""Chat later and kill the skeletons now, brah.""); return; } if (killedCount == Integer.MAX_VALUE) return; setNextForceTalk(new ForceTalk(""I see little danger in this room so move on to the next with my thanks."")); for (Player p2 : getManager().getParty().getTeam()) { if (!getManager().isAtBossRoom(p2.getTile())) continue; p2.sendMessage(""Divine skinweaver: "" + getNextForceTalk().text()); } getManager().openStairs(getReference()); drop(); killedCount = Integer.MAX_VALUE; } public void blockHole(Player player, GameObject object) { if (count >= holeClosed.length) return; player.setNextAnimation(new Animation(833)); if (!requestedClose) { player.sendMessage(""The portal is fully powered and shocks you with a large burst of energy.""); player.applyHit(new Hit(player, (int) (player.getMaxHitpoints() * 0.2), HitLook.TRUE_DAMAGE)); return; } holeClosed[count++] = true; requestedClose = false; GameObject closedHole = new GameObject(object); closedHole.setId(49289); World.spawnObject(closedHole); } @Override public List getPossibleTargets() { ArrayList targets = new ArrayList<>(); for (Player player : getManager().getParty().getTeam()) { if (player == null || !getManager().isAtBossRoom(player.getTile())) continue; targets.add(player); } return targets; } }" "package com.rs.game.content.skills.dungeoneering.npcs; public class Dreadnaut extends DungeonBoss { private final List puddles; private int ticks; private boolean reduceMagicLevel; public Dreadnaut(Tile tile, DungeonManager manager, RoomReference reference) { super(DungeonUtils.getClosestToCombatLevel(Utils.range(12848, 12862), manager.getBossLevel()), tile, manager, reference); setForceFollowClose(true); setRun(true); setHitpoints(getMaxHitpoints()); setLureDelay(6000);//6 seconds puddles = new CopyOnWriteArrayList<>(); } @Override public void processNPC() { if (puddles == null) //still loading return; super.processNPC(); if (!reduceMagicLevel) { if (isUnderCombat()) for (Entity t : getPossibleTargets()) if (!t.withinDistance(getTile(), 1)) { ticks++; break; } if (ticks == 25) { reduceMagicLevel = true; setNextForceTalk(new ForceTalk(""You cannot run from me forever!"")); } } for (GassPuddle puddle : puddles) { puddle.cycles++; if (puddle.canDestroyPuddle()) { puddles.remove(puddle); continue; } if (puddle.cycles % 2 != 0) continue; puddle.refreshGraphics(); List targets = getPossibleTargets(true); for (Entity t : targets) { if (!t.matches(puddle.tile)) continue; t.applyHit(new Hit(this, Utils.random((int) (t.getHitpoints() * 0.25)) + 1, HitLook.TRUE_DAMAGE)); } } } @Override public double getMeleePrayerMultiplier() { return 0.60; } public boolean canReduceMagicLevel() { return reduceMagicLevel; } public void setReduceMagicLevel(boolean reduceMagicLevel) { this.reduceMagicLevel = reduceMagicLevel; } public void addSpot(Tile tile) { GassPuddle puddle = new GassPuddle(this, tile); puddle.refreshGraphics(); puddles.add(puddle); } private static class GassPuddle { final Dreadnaut boss; final Tile tile; int cycles; public GassPuddle(Dreadnaut boss, Tile tile) { this.tile = tile; this.boss = boss; } public void refreshGraphics() { World.sendSpotAnim(tile, new SpotAnim(2859, 0, 10)); } public boolean canDestroyPuddle() { return cycles == 50; } } }" "package com.rs.game.content.skills.dungeoneering.npcs; public class DungeonNPC extends NPC { private DungeonManager manager; private boolean marked; public DungeonNPC(int id, Tile tile, DungeonManager manager) { super(id, tile, true); setManager(manager); if (getDefinitions().hasAttackOption()) { setHitpoints(getMaxHitpoints()); resetBonuses(); setForceMultiArea(true); } setForceAggroDistance(20); //includes whole room } protected int getTier() { int tier = getDefinitions().combatLevel / 11; if (tier > 10) tier = 11; else if (tier < 1) tier = 1; return tier; } @Override public boolean canAggroPlayer(Player player) { DungeonConstants.GuardianMonster mob = DungeonConstants.GuardianMonster.forId(getId()); if (mob == null) return true; if (mob == FORGOTTEN_WARRIOR || mob == FORGOTTEN_RANGER || mob == SKELETON_MELEE || mob == SKELETON_RANGED || mob == ZOMBIE_MELEE || mob == ZOMBIE_RANGED || mob == HILL_GIANT || mob == GIANT_SKELETON || mob == HOBGOBLIN || mob == REBORN_WARRIOR || mob == ICE_WARRIOR) { return !player.getEquipment().containsOneItem(17279, 15828) || player.getTempAttribs().getB(""ShadowSilkSpellDisable""); } return true; } public void resetBonuses() { setLevels(manager.getLevels(this instanceof DungeonBoss, getCombatLevel(), getMaxHitpoints())); } /* * they don't respawn anyway, and this way stomp will be fine */ @Override public int getRespawnDirection() { return getFaceAngle(); } public NPC getNPC(int id) { for (NPC npc : World.getNPCsInChunkRange(getChunkId(), 4)) { if (npc.getId() == id) return npc; } return null; } @Override public void sendDeath(Entity source) { super.sendDeath(source); if (marked) { getManager().removeMark(); marked = false; } } @Override public void processNPC() { super.processNPC(); if (isUnderCombat()) { Entity target = getCombat().getTarget(); RoomReference thisR = getManager().getCurrentRoomReference(this.getTile()); RoomReference targetR = getManager().getCurrentRoomReference(target.getTile()); if (!targetR.equals(thisR)) getCombat().removeTarget(); } } @Override public int getMaxHitpoints() { return getCombatLevel() * (this instanceof DungeonBoss ? 25 : 8) + 1; } @Override public int getMaxHit() { return getCombatLevel(); } public void setMarked(boolean marked) { this.marked = marked; } private int getBones() { return getName().toLowerCase().contains(""dragon"") ? 536 : getSize() > 1 ? 532 : 526; } @Override public void drop() { int size = getSize(); ArrayList drops = new ArrayList<>(); if (getId() != 10831 && getId() != 10821) //nature & ghost drops.add(new Item(getBones())); for (int i = 0; i < 1 + Utils.random(10); i++) drops.add(new Item(DungeonUtils.getFood(Math.min(1+Utils.random(getTier()), 8)))); if (Utils.random(10) == 0) drops.add(new Item(DungeonUtils.getDagger(Math.min(1+Utils.random(getTier()), 5)))); if (Utils.random(5) == 0) drops.add(new Item(DungeonConstants.RUNES[Utils.random(DungeonConstants.RUNES.length)], 90 + Utils.random(30))); if (getManager().getParty().getComplexity() >= 5 && Utils.random(5) == 0) // torn bag, 1 drops.add(new Item(DungeonUtils.getTornBag(Math.min(1+Utils.random(getTier()), 10)))); if (getManager().getParty().getComplexity() >= 3 && Utils.random(5) == 0) //ore, up to 10 drops.add(new Item(DungeonUtils.getOre(Math.min(1+Utils.random(getTier()), 5)), 1 + Utils.random(10))); if (getManager().getParty().getComplexity() >= 2 && Utils.random(5) == 0) // branch, up to 10 drops.add(new Item(DungeonUtils.getBranche(Math.min(1+Utils.random(getTier()), 5)), 1 + Utils.random(10))); if (getManager().getParty().getComplexity() >= 4 && Utils.random(5) == 0) //textile, up to 10 drops.add(new Item(DungeonUtils.getTextile(Math.min(1+Utils.random(getTier()), 5)), 1 + Utils.random(10))); if (getManager().getParty().getComplexity() >= 5 && Utils.random(5) == 0) //herb, up to 10 drops.add(new Item(DungeonUtils.getHerb(Math.min(1+Utils.random(getTier()), 3)), 1 + Utils.random(10))); if (getManager().getParty().getComplexity() >= 5 && Utils.random(5) == 0) //seed, up to 10 drops.add(new Item(DungeonUtils.getSeed(Math.min(1+Utils.random(getTier()), 3)), 1 + Utils.random(10))); if (getManager().getParty().getComplexity() >= 5 && Utils.random(3) == 0) //charms, depending in mob size drops.add(new Item(DungeonConstants.CHARMS[Utils.random(DungeonConstants.CHARMS.length)], size)); if (getManager().getParty().getComplexity() >= 2) //coins, 1000 up to 11000 drops.add(new Item(DungeonConstants.RUSTY_COINS, 1000 + Utils.random(10001))); if (getManager().getParty().getComplexity() >= 3 && Utils.random(5) == 0) //essence, 10 up to 300 drops.add(new Item(DungeonConstants.RUNE_ESSENCE, 10 + Utils.random(300))); if (getManager().getParty().getComplexity() >= 2 && Utils.random(5) == 0) //feather, 10 up to 300 drops.add(new Item(DungeonConstants.FEATHER, 10 + Utils.random(300))); if ((getManager().getParty().getComplexity() >= 5 && Utils.random(10) == 0)) //vial, 1 drops.add(new Item(17490)); if ((Utils.random(10) == 0)) //anti dragon shield drops.add(new Item(16933)); if ((getManager().getParty().getComplexity() >= 4 && Utils.random(10) == 0)) //bowstring, 1 drops.add(new Item(17752)); if ((getManager().getParty().getComplexity() >= 2 && Utils.random(10) == 0)) // fly-fishing rod, 1 drops.add(new Item(17794)); if ((getManager().getParty().getComplexity() >= 4 && Utils.random(5) == 0)) //thread, 10 up to 300 drops.add(new Item(17447, 10 + Utils.random(300))); for (Item item : drops) World.addGroundItem(item, Tile.of(getCoordFaceX(size), getCoordFaceY(size), getPlane())); } public DungeonManager getManager() { return manager; } public void setManager(DungeonManager manager) { this.manager = manager; } }" "package com.rs.game.content.skills.dungeoneering.npcs; public class DungeonSkeletonBoss extends DungeonNPC { private final DivineSkinweaver boss; public DungeonSkeletonBoss(int id, Tile tile, DungeonManager manager, RoomReference reference) { super(id, tile, manager); setForceAgressive(true); setIntelligentRouteFinder(true); setLureDelay(0); boss = (DivineSkinweaver) getNPC(10058); } @Override public void sendDeath(Entity source) { super.sendDeath(source); boss.removeSkeleton(this); } @Override public void drop() { } }" "package com.rs.game.content.skills.dungeoneering.npcs; public class DungeonSlayerNPC extends DungeonNPC { public enum DungeonSlayerType { CRAWLING_HAND(10694, 5, 20, new DropTable(1, 3, 17261, 1), new DropTable(1, 10, 17263, 1)), CAVE_CRAWLER(10695, 10, new int[] { DungeonConstants.ABANDONED_FLOORS, DungeonConstants.FURNISHED_FLOORS }, 20, new DropTable(1, 10, 17265, 1), new DropTable(1, 10, 17267, 1)), CAVE_SLIME(10696, 17, 20, new DropTable(1, 10, 17269, 1), new DropTable(1, 10, 17271, 1)), PYREFIEND(10697, 30, 18, new DropTable(1, 10, 17273, 1)), NIGHT_SPIDER(10698, 41, 20, new DropTable(1, 30, 17279, 1)), JELLY(10699, 52, 15, new DropTable(1, 10, 17281, 1), new DropTable(1, 10, 17283, 1)), SPIRITUAL_GUARDIAN(10700, 63, 15, new DropTable(1, 10, 17285, 1), new DropTable(1, 10, 17287, 1)), SEEKER(10701, 71, new int[] { DungeonConstants.ABANDONED_FLOORS, DungeonConstants.OCCULT_FLOORS, DungeonConstants.WARPED_FLOORS }, 10, new DropTable(1, 10, 17289, 1)), NECHRYAEL(10702, 80, new int[] { DungeonConstants.ABANDONED_FLOORS, DungeonConstants.OCCULT_FLOORS, DungeonConstants.WARPED_FLOORS }, 15, new DropTable(1, 30, 17283, 1)), EDIMMU(10703, 90, new int[] { DungeonConstants.OCCULT_FLOORS, DungeonConstants.WARPED_FLOORS }, 5, new DropTable(1, 20, 17291, 1)), //40 damage every 15 seconds SOULGAZER(10704, 99, new int[] { DungeonConstants.OCCULT_FLOORS, DungeonConstants.WARPED_FLOORS }, 5, new DropTable(1, 20, 17295, 1)); private static final Map MAP = new HashMap<>(); static { for (DungeonSlayerType type : DungeonSlayerType.values()) MAP.put(type.id, type); } public static DungeonSlayerType forId(int id) { return MAP.get(id); } private final int id, req, weight; private int[] floors; private final DropSet drops; DungeonSlayerType(int id, int req, int[] floors, int weight, DropTable... drops) { this.id = id; this.req = req; this.floors = floors; this.weight = weight; this.drops = new DropSet(drops); } DungeonSlayerType(int id, int req, int weight, DropTable... drops) { this.id = id; this.req = req; this.weight = weight; this.drops = new DropSet(drops); } public int getReq() { return req; } private boolean containsFloor(int checkFloor) { if (floors == null) return true; for (int floor : floors) if (floor == checkFloor) return true; return false; } } private final DungeonSlayerType type; public DungeonSlayerNPC(int id, Tile tile, DungeonManager manager) { super(id, tile, manager); type = DungeonSlayerType.forId(id); } @Override public void drop() { super.drop(); int size = getSize(); List drops = type.drops.getDropList().genDrop(); for (Item item : drops) World.addGroundItem(item, Tile.of(getCoordFaceX(size), getCoordFaceY(size), getPlane())); } public DungeonSlayerType getType() { return type; } public static int getSlayerCreature(DungeonPartyManager party) { List monsters = new ArrayList<>(); for (DungeonSlayerType type : DungeonSlayerType.values()) for (Player player : party.getTeam()) if (player.getSkills().getLevel(Constants.SLAYER) >= type.req && type.containsFloor(party.getFloorType())) { for (int i = 0;i < type.weight;i++) monsters.add(type.id); } Collections.shuffle(monsters); return !monsters.isEmpty() ? monsters.getFirst() : -1; } }" "package com.rs.game.content.skills.dungeoneering.npcs; public class FamishedEye extends DungeonNPC { private final int weakness, type; private int sleepCycles; private boolean firstHit; private final WorldGorgerShukarhazh boss; public FamishedEye(final WorldGorgerShukarhazh boss, int id, Tile tile, final DungeonManager manager) { super(id, tile, manager); this.boss = boss; this.sleepCycles = -1; int rotationType = (id - 12436) / 15; this.weakness = findWeakness(rotationType); this.type = findType(rotationType); setCantFollowUnderCombat(true); setForceAgressive(true); int rotation = manager.getRoom(manager.getCurrentRoomReference(getTile())).getRotation() + rotationType; setFaceAngle(Utils.getAngleTo(Utils.ROTATION_DIR_X[(rotation + 1) & 0x3], Utils.ROTATION_DIR_Y[(rotation + 1) & 0x3])); } @Override public boolean lineOfSightTo(Object tile, boolean checkClose) { //because npc is under cliped data return getManager().isAtBossRoom(WorldUtil.targetToTile(tile)); } @Override public void setNextFaceEntity(Entity entity) { //this boss doesnt face } @Override public void processHit(Hit hit) { if (weakness != hit.getLook().getMark()) hit.setDamage((int) (hit.getDamage() * 0.2)); super.processHit(hit); } @Override public void processNPC() { super.processNPC(); if (sleepCycles == 45) resetSleepCycles(); else if (sleepCycles >= 0) sleepCycles++; } private void resetSleepCycles() { sleepCycles = -1; setCantInteract(false); setNextAnimation(new Animation(-1)); setHitpoints(getMaxHitpoints()); boss.refreshCapDamage(); for (Entity t : getPossibleTargets()) if (t instanceof Player player) player.sendMessage(""The creature shifts, and one of it's many eyes opens.""); } @Override public void drop() { } @Override public void sendDeath(Entity source) { sleepCycles++;//start the cycles boss.refreshCapDamage(); setCantInteract(true); setNextAnimation(new Animation(14917)); for (Entity t : getPossibleTargets()) if (t instanceof Player player) player.sendMessage(""The creature shifts, and one of it's many eyes closes.""); } public boolean isInactive() { return sleepCycles != -1; } public WorldGorgerShukarhazh getBoss() { return boss; } public int getType() { return type; } public int getWeaknessStyle() { return weakness; } private int findType(int rotation) { // mage, warrior, range return switch (type) { case 0 -> 2; case 1 -> 0; default -> 1; }; } private int findWeakness(int type) { return switch (type) { // mage, warrior, range case 0 -> 1; //range was mage 2 case 1 -> 2; //mage was melee 0 default -> 0; //melee was range 1 }; } public boolean isFirstHit() { return firstHit; } public void setFirstHit(boolean firstHit) { this.firstHit = firstHit; } }" "package com.rs.game.content.skills.dungeoneering.npcs; public class FleshspoilerHaasghenahk extends DungeonBoss { private final List creatures = new CopyOnWriteArrayList<>(); private Entity cachedTarget; private boolean secondStage, useMagicOnly; private int fleshTicks; public FleshspoilerHaasghenahk(Tile tile, DungeonManager manager, RoomReference reference) { super(DungeonUtils.getClosestToCombatLevel(Utils.range(11925, 11939), manager.getBossLevel()), tile, manager, reference); useMagicOnly = true; setHitpoints(getMaxHitpoints()); } @Override public void processNPC() { fleshTicks++; if (fleshTicks % 25 == 0) { if (secondStage) setNextAnimation(new Animation(14469)); for (Entity t : getPossibleTargets()) { t.setNextSpotAnim(new SpotAnim(2775)); t.applyHit(new Hit(this, (int) Utils.random(Utils.random(getMaxHit() * .01, getMaxHit() * .1), getMaxHit()), HitLook.TRUE_DAMAGE)); } } if (secondStage && cachedTarget != null && (cachedTarget.isDead() || cachedTarget.hasFinished())) { calculateNextTarget(); for (DungeonNPC npc : creatures) { npc.resetCombat(); if (cachedTarget != null) npc.getCombat().setTarget(cachedTarget); } } super.processNPC(); } private void addFleshCreatures() { final Tile centerTile = getManager().getTile(getReference(), 8, 7); final List tiles = new LinkedList<>(); for (int i = 0; i < 5; i++) { Tile tile = World.getFreeTile(centerTile, 6); World.sendProjectile(this, tile, 2765, 150, 0, 30, 1, 40, 0); tiles.add(tile); } final FleshspoilerHaasghenahk boss = this; WorldTasks.scheduleTimer(3, (ticks) -> { for (int index = 0; index < 5; index++) creatures.add(new FleshspoilerSpawn(boss, tiles.get(index), getManager())); return false; }); } public void removeFleshCreature(FleshspoilerSpawn spoiler_spawn) { creatures.remove(spoiler_spawn); } @Override public void sendDeath(Entity source) { if (!secondStage) { secondStage = true; calculateNextTarget(); setNextAnimation(new Animation(14467)); setNextSpotAnim(new SpotAnim(2765, 240, 0)); WorldTasks.scheduleTimer(5, (ticks) -> { setNextAnimation(new Animation(-1)); addFleshCreatures(); transformIntoNPC(getId() - 30); setHitpoints(getMaxHitpoints()); setLureDelay(Integer.MAX_VALUE); setCantFollowUnderCombat(true); resetBonuses(); return false; }); return; } for (DungeonNPC npc : creatures) npc.sendDeath(this); creatures.clear(); super.sendDeath(source); } public boolean isSecondStage() { return secondStage; } public boolean canUseMagicOnly() { return useMagicOnly; } public void setUseMagicOnly(boolean useMagicOnly) { this.useMagicOnly = useMagicOnly; } public Entity getCachedTarget() { return cachedTarget; } public void calculateNextTarget() { cachedTarget = null; List targets = getPossibleTargets(); if (targets.isEmpty()) return; cachedTarget = targets.get(Utils.random(targets.size())); } }" "package com.rs.game.content.skills.dungeoneering.npcs; public class FleshspoilerSpawn extends DungeonNPC { private final FleshspoilerHaasghenahk boss; public FleshspoilerSpawn(FleshspoilerHaasghenahk boss, Tile tile, DungeonManager manager) { super(getId(boss.getId()), tile, manager); this.boss = boss; setForceAgressive(true); setLureDelay(Integer.MAX_VALUE); setForceFollowClose(true); setRun(true); } @Override public double getMeleePrayerMultiplier() { return 0.0;//Fully block it. } @Override public void drop() { } @Override public void sendDeath(Entity source) { super.sendDeath(source); boss.removeFleshCreature(this); } private static int getId(int bossId) { if (bossId >= 11895 && bossId <= 11909) return bossId + 15; return bossId - 15; } }" "package com.rs.game.content.skills.dungeoneering.npcs; public class ForgottenWarrior extends Guardian { public ForgottenWarrior(int id, Tile tile, DungeonManager manager, RoomReference reference) { super(id, tile, manager, reference); } @Override public void drop() { super.drop(); GuardianMonster m = GuardianMonster.forId(getId()); if (m == null) return; int size = getSize(); ArrayList drops = new ArrayList<>(); if (m.name().contains(""WARRIOR"")) drops.add(new Item(DungeonUtils.getRandomMeleeGear(Math.min(1+Utils.random(getTier()), 10)))); else if (m.name().contains(""MAGE"")) drops.add(new Item(DungeonUtils.getRandomMagicGear(Math.min(1+Utils.random(getTier()), 10)))); else drops.add(new Item(DungeonUtils.getRandomRangeGear(Math.min(1+Utils.random(getTier()), 10)))); for (Item item : drops) World.addGroundItem(item, Tile.of(getCoordFaceX(size), getCoordFaceY(size), getPlane())); } }" "package com.rs.game.content.skills.dungeoneering.npcs; public class FrozenAdventurer extends NPC { private transient Player player; public FrozenAdventurer(int id, Tile tile, int mapAreaNameHash, boolean canBeAttackFromOutOfArea) { super(id, tile, true); } @Override public void processNPC() { if (player == null || player.isDead() || player.hasFinished()) { finish(); return; } if (!player.getAppearance().isNPC()) { ToKashBloodChillerCombat.removeSpecialFreeze(player); finish(); return; } } public void setPlayer(Player player) { this.player = player; } public Player getFrozenPlayer() { return player; } }" "package com.rs.game.content.skills.dungeoneering.npcs; public final class GluttonousBehemoth extends DungeonBoss { private GameObject heal; private int ticks; public GluttonousBehemoth(Tile tile, DungeonManager manager, RoomReference reference) { super(DungeonUtils.getClosestToCombatLevel(Utils.range(9948, 9964), manager.getBossLevel()), tile, manager, reference); setHitpoints(getMaxHitpoints()); setCantFollowUnderCombat(true); } public void setHeal(GameObject food) { ticks = 0; heal = food; removeTarget(); } @Override public void processNPC() { if (heal != null) { setNextFaceEntity(null); ticks++; if (ticks == 1) calcFollow(heal, true); else if (ticks == 5) setNextAnimation(new Animation(13720)); else if (ticks < 900 && ticks > 7) { if (getHitpoints() >= (getMaxHitpoints() * 0.75)) { setNextAnimation(new Animation(-1)); calcFollow(getRespawnTile(), true); ticks = 995; return; } heal(50 + Utils.random(50)); setNextAnimation(new Animation(13720)); } else if (ticks > 1000) heal = null; return; } super.processNPC(); } }" "package com.rs.game.content.skills.dungeoneering.npcs; public class Gravecreeper extends DungeonBoss { public static final int BURN_DELAY = 17; private final List burnedTiles; private long specialDelay; private final int originalId; private final GameObject[][] plinths; private final boolean[][] triggeredPlinths; public Gravecreeper(Tile tile, DungeonManager manager, RoomReference reference) { super(DungeonUtils.getClosestToCombatLevel(new int[] { 532, 533, 11708, 11709, 11710, 11711, 11712, 11713, 11714, 11715, 11716, 11717, 11718, 11719, 11720 }, manager.getBossLevel()), tile, manager, reference); originalId = getId(); burnedTiles = new CopyOnWriteArrayList<>(); plinths = new GameObject[4][4]; triggeredPlinths = new boolean[4][4]; setHitpoints(getMaxHitpoints()); } @Override public double getRangePrayerMultiplier() { return 0.6; // rs makes it always 0.6 99% time when partialy blocked duh } @Override public double getMagePrayerMultiplier() { return 0.6; } @Override public void processNPC() { if (burnedTiles != null && !burnedTiles.isEmpty()) processBurnAttack(); super.processNPC(); } public boolean removeBurnedTile(Tile center) { for (BurnTile bTile : burnedTiles) if (bTile.center.getX() == center.getX() && bTile.center.getY() == center.getY()) { burnedTiles.remove(bTile); return true; } return false; } private void processBurnAttack() { for (BurnTile bTile : burnedTiles) { bTile.cycles++; if (!bTile.permenant && bTile.cycles == BURN_DELAY) { burnedTiles.remove(bTile); continue; } if (bTile.cycles % 2 != 0) continue; bTile.sendGraphics(); for (Entity t : getPossibleTargets()) { Player p2 = (Player) t; for (Tile tile : bTile.tiles) { if (p2.getX() != tile.getX() || p2.getY() != tile.getY()) continue; p2.applyHit(new Hit(this, (int) Utils.random(getMaxHit() * .1, getMaxHit() * .25), HitLook.TRUE_DAMAGE)); p2.getPrayer().drainPrayer(20); if (p2.getPrayer().hasPrayersOn()) p2.getPrayer().closeAllPrayers(); } } } } @Override public void sendDeath(final Entity source) { if (specialDelay != -2) { setHitpoints(1); specialDelay = -1; return; } burnedTiles.clear(); super.sendDeath(source); } private static final String[] SPECIAL_SHOUTS = { ""Burrrrrry"", ""Digggggg"", ""Brrainnns"" }; public void useSpecial() { Tile walkTo = getNearestPlinch(); if (walkTo == null) return; getManager().setTemporaryBoss(this); setCantInteract(true); resetReceivedHits(); setNextFaceEntity(null); setForceWalk(walkTo); setNextForceTalk(new ForceTalk(SPECIAL_SHOUTS[specialDelay == -1 ? 2 : Utils.random(SPECIAL_SHOUTS.length)])); WorldTasks.schedule(new Task() { @Override public void run() { setNextAnimation(new Animation(14507)); activatePlinths(); activateTombs(); WorldTasks.schedule(new Task() { @Override public void run() { // finish(); transformIntoNPC(1957); if (specialDelay == -1) specialDelay = -2; WorldTasks.schedule(new Task() { @Override public void run() { if (getManager().isDestroyed()) return; tele(getManager().getTile(getReference(), 3 + Utils.random(4) * 3, 3 + Utils.random(4) * 3)); transformIntoNPC(originalId); setNextAnimation(new Animation(14506)); WorldTasks.schedule(new Task() { @Override public void run() { if (getManager().isDestroyed()) return; setCantInteract(false); triggerPlinths(); getManager().setTemporaryBoss(null); } }); } }, 8); } }, 1); } }, Utils.getDistanceI(getTile(), walkTo)); } public Tile getNearestPlinch() { int distance = Integer.MAX_VALUE; GameObject p = null; for (int x = 0; x < plinths.length; x++) for (int y = 0; y < plinths[x].length; y++) { GameObject plinth = getManager().getObjectWithType(getReference(), ObjectType.GROUND_DECORATION, 3 + x * 3, 3 + y * 3); if (plinth == null) continue; int d = (int) Utils.getDistance(getTile(), plinth.getTile()); if (d >= distance) continue; distance = d; p = plinth; } return p.getTile(); } public void triggerPlinths() { List possibleTargets = getPossibleTargets(); for (int x = 0; x < plinths.length; x++) for (int y = 0; y < plinths[x].length; y++) { if (plinths[x][y] == null) continue; Tile altarLoc = getManager().getTile(getReference(), TOMB_LOC_POS_2[y][x][0], TOMB_LOC_POS_2[y][x][1]); World.sendSpotAnim(altarLoc, new SpotAnim(2751)); if (!triggeredPlinths[x][y]) { triggeredPlinths[x][y] = true; createBurnTiles(plinths[x][y].getTile(), true); for (Entity t : possibleTargets) if (WorldUtil.isInRange(t.getX(), t.getY(), t.getSize(), altarLoc.getX(), altarLoc.getY(), 1, 2)) t.applyHit(new Hit(this, Utils.random((int) (t.getMaxHitpoints() * 0.1)) + 1, HitLook.MAGIC_DAMAGE)); } } } public boolean cleanseTomb(Player player, GameObject tomb) { int[] pos = getManager().getRoomPos(tomb.getTile()); for (int x = 0; x < plinths.length; x++) for (int y = 0; y < plinths[x].length; y++) if (TOMB_LOC_POS_2[y][x][0] == pos[0] && TOMB_LOC_POS_2[y][x][1] == pos[1]) { player.lock(1); player.setNextAnimation(new Animation(645)); player.sendMessage(""Blessing the grave costs prayer points, but evil retreats.""); player.getPrayer().drainPrayer(10); cleanseTomb(x, y); return false; } return true; } public void cleanseTomb(int x, int y) { if (plinths[x][y] != null) { World.removeObject(plinths[x][y]); World.sendSpotAnim(plinths[x][y].getTile(), new SpotAnim(2320)); if (triggeredPlinths[x][y]) { removeBurnedTile(plinths[x][y].getTile()); triggeredPlinths[x][y] = false; } plinths[x][y] = null; } } private static final int[][][] TOMB_LOC_POS_2 = { { { 2, 2 }, { 6, 2 }, { 9, 2 }, { 13, 2 } }, { { 2, 6 }, { 7, 7 }, { 8, 7 }, { 13, 6 } }, { { 2, 9 }, { 7, 8 }, { 8, 8 }, { 13, 9 } }, { { 2, 13 }, { 6, 13 }, { 9, 13 }, { 13, 13 } } }; public void activateTombs() { for (int x = 0; x < plinths.length; x++) for (int y = 0; y < plinths[x].length; y++) { if (plinths[x][y] == null) continue; GameObject altar = getManager().getObjectWithType(getReference(), ObjectType.SCENERY_INTERACT, TOMB_LOC_POS_2[y][x][0], TOMB_LOC_POS_2[y][x][1]); if (altar == null) continue; GameObject activeAltar = new GameObject(altar); activeAltar.setId(altar.getId() + 1); World.spawnObjectTemporary(activeAltar, Ticks.fromSeconds(7)); World.sendSpotAnim(activeAltar.getTile(), new SpotAnim(2752)); } } public void activatePlinths() { for (int x = 0; x < plinths.length; x++) for (int y = 0; y < plinths[x].length; y++) { if (plinths[x][y] != null) continue; GameObject plinth = getManager().getObjectWithType(getReference(), ObjectType.GROUND_DECORATION, 3 + x * 3, 3 + y * 3); if (plinth == null) continue; if (plinths[x][y] == null && Utils.random(15) < getManager().getParty().getTeam().size() * 3) { GameObject activePlinth = new GameObject(plinth); activePlinth.setId(plinth.getId() + 1); World.spawnObject(activePlinth); plinths[x][y] = activePlinth; } } } public void createBurnTiles(Tile tile, boolean permenant) { burnedTiles.add(new BurnTile(tile, permenant)); } public void createBurnTiles(Tile tile) { createBurnTiles(tile, false); } public long getSpecialDelay() { return specialDelay; } public void setSpecialDelay(long specialDelay) { this.specialDelay = specialDelay; } public static class BurnTile { private int cycles; private final boolean permenant; private final Tile center; private final Tile[] tiles; public BurnTile(Tile center, boolean permenant) { this.center = center; this.permenant = permenant; tiles = new Tile[9]; int index = 0; for (int x = -1; x < 2; x++) for (int y = -1; y < 2; y++) tiles[index++] = center.transform(x, y, 0); } public void sendGraphics() { World.sendSpotAnim(center, new SpotAnim(133)); } } }" "package com.rs.game.content.skills.dungeoneering.npcs; public class Guardian extends DungeonNPC { private final RoomReference reference; public Guardian(int id, Tile tile, DungeonManager manager, RoomReference reference) { super(id, tile, manager); this.reference = reference; setForceAgressive(true); } @Override public void sendDeath(Entity source) { super.sendDeath(source); getManager().updateGuardian(reference); } }" "package com.rs.game.content.skills.dungeoneering.npcs; public class HobgoblinGeomancer extends DungeonBoss { public HobgoblinGeomancer(Tile tile, DungeonManager manager, RoomReference reference) { super(DungeonUtils.getClosestToCombatLevel(Utils.range(10059, 10072), manager.getBossLevel()), tile, manager, reference); setHitpoints(getMaxHitpoints()); } public void sendTeleport(final Tile tile, final RoomReference room) { setCantInteract(true); setNextAnimation(new Animation(12991, 70)); setNextSpotAnim(new SpotAnim(1576, 70, 0)); WorldTasks.scheduleTimer(5, (ticks) -> { setCantInteract(false); setNextAnimation(new Animation(-1)); tele(World.getFreeTile(getManager().getRoomCenterTile(room), 6)); resetReceivedHits(); return false; }); } }" "package com.rs.game.content.skills.dungeoneering.npcs; public class HopeDevourer extends DungeonBoss { private int auraTicks; private final int auraDamage; public HopeDevourer(Tile tile, DungeonManager manager, RoomReference reference) { super(DungeonUtils.getClosestToCombatLevel(Utils.range(12886, 12900), manager.getBossLevel()), tile, manager, reference); setHitpoints(getMaxHitpoints()); setLureDelay(10000); setForceFollowClose(true); auraDamage = (int) Utils.random(getMaxHit() * .1, getMaxHit() * .15); } @Override public void processNPC() { super.processNPC(); auraTicks++; if (auraTicks == 20) { sendAuraAttack(); auraTicks = 0; } } @Override public boolean canMove(Direction dir) { int nextX = dir.dx + getX(); int nextY = dir.dy + getY(); int size = getSize(); // I always do this instead of calling at loop cuz it grabs npcdef from hashmap every call for (Player player : getManager().getParty().getTeam()) if (WorldUtil.collides(player.getX(), player.getY(), player.getSize(), nextX, nextY, size)) return false; return true; } private void sendAuraAttack() { for (Entity t : super.getPossibleTargets()) { t.applyHit(new Hit(this, auraDamage, HitLook.TRUE_DAMAGE, 60)); if (t instanceof Player player) { int combatSkill = Utils.random(Constants.MAGIC); if (combatSkill == 3) combatSkill = 1; player.getSkills().set(combatSkill, (int) (player.getSkills().getLevel(combatSkill) * Utils.random(0.94, .99))); player.sendMessage(""You feel hopeless...""); } } } @Override public List getPossibleTargets() { List targets = super.getPossibleTargets(); if (getAttackedBy() == null) return targets; ArrayList possibleTargets = new ArrayList<>(); for (Entity t : targets) if (t.inCombat()) possibleTargets.add(t); return possibleTargets; } }" "package com.rs.game.content.skills.dungeoneering.npcs; public final class IcyBones extends DungeonBoss { public IcyBones(Tile tile, DungeonManager manager, RoomReference reference) { super(DungeonUtils.getClosestToCombatLevel(Utils.range(10040, 10057), manager.getBossLevel()), tile, manager, reference); spikes = new ArrayList<>(); setHitpoints(getMaxHitpoints()); } @Override public double getMeleePrayerMultiplier() { return 0.6; } @Override public double getMagePrayerMultiplier() { return 0.6; } @Override public double getRangePrayerMultiplier() { return 0.6; } private final List spikes; public void removeSpikes() { if (spikes.isEmpty()) return; for (GameObject object : spikes) World.removeObject(object); spikes.clear(); } public boolean sendSpikes() { if (!spikes.isEmpty()) return false; int size = getSize(); for (int x = -1; x < 7; x++) for (int y = -1; y < 7; y++) { if (((x != -1 && x != 6) && (y != -1 && y != 6)) || Utils.random(2) != 0) continue; Tile tile = transform(x - size, y - size, 0); RoomReference current = getManager().getCurrentRoomReference(tile); if (current.getRoomX() != getReference().getRoomX() || current.getRoomY() != getReference().getRoomY() || !World.floorFree(tile.getPlane(), tile.getX(), tile.getY())) continue; GameObject object = new GameObject(52285 + Utils.random(3), ObjectType.SCENERY_INTERACT, Utils.random(4), tile.getX(), tile.getY(), tile.getPlane()); spikes.add(object); World.spawnObject(object); for (Player player : getManager().getParty().getTeam()) if (player.getX() == object.getX() && player.getY() == object.getY()) player.applyHit(new Hit(this, 1 + Utils.random(getMaxHit()), HitLook.TRUE_DAMAGE)); } WorldTasks.schedule(new Task() { @Override public void run() { removeSpikes(); } }, 10); return true; } }" "package com.rs.game.content.skills.dungeoneering.npcs; public class LakkTheRiftSplitter extends DungeonBoss { private static final int[] RAIN_GRAPHICS = { 2581, 2583, 2585 }; private final List clusters; public LakkTheRiftSplitter(Tile tile, DungeonManager manager, RoomReference reference) { super(DungeonUtils.getClosestToCombatLevel(Utils.range(9898, 9911), manager.getBossLevel()), tile, manager, reference); clusters = new CopyOnWriteArrayList<>(); } @Override public void processNPC() { if (isDead() || clusters == null) return; super.processNPC(); for (PortalCluster cluster : clusters) { cluster.incrementCycle(); if (cluster.getCycle() == 35) { clusters.remove(cluster); continue; } for (Entity t : getPossibleTargets()) { Player player = (Player) t; if (cluster.getCycle() < 1) continue; if (cluster.getCycle() % 2 == 0) for (Tile tile : cluster.getBoundary()) if (player.getX() == tile.getX() && player.getY() == tile.getY()) { cluster.increaseEffectMultipier(); int type = cluster.getType(); double effectMultiplier = cluster.getEffectMultiplier(); int maxHit = getMaxHit(); if (type == 0) player.applyHit(new Hit(this, (int) (Utils.random(maxHit * .35, maxHit * .55) * effectMultiplier), HitLook.TRUE_DAMAGE)); else if (type == 1) player.getPoison().makePoisoned((int) (Utils.random(maxHit * .10, maxHit * .30) * effectMultiplier)); else { int skill = Utils.random(6); player.getSkills().drainLevel(skill == 3 ? Constants.MAGIC : skill, (int) (Utils.random(2, 3) * effectMultiplier)); } } } if (cluster.getCycle() % 15 == 0) submitGraphics(cluster, this); } } @Override public void sendDeath(Entity killer) { super.sendDeath(killer); clusters.clear(); } public void addPortalCluster(int type, Tile[] boundary) { PortalCluster cluster = new PortalCluster(type, boundary); submitGraphics(cluster, this); clusters.add(cluster); } private static void submitGraphics(PortalCluster cluster, NPC creator) { for (Tile tile : cluster.getBoundary()) World.sendSpotAnim(tile, new SpotAnim((Utils.random(3) == 0 ? 1 : 0) + RAIN_GRAPHICS[cluster.getType()])); } private static class PortalCluster { private final int type; private final Tile[] boundary; private int cycle; private double effectMultiplier; public PortalCluster(int type, Tile[] boundary) { this.type = type; this.boundary = boundary; effectMultiplier = 0.5; } public Tile[] getBoundary() { return boundary; } public int getType() { return type; } public void incrementCycle() { cycle++; } public int getCycle() { return cycle; } public double getEffectMultiplier() { return effectMultiplier; } public void increaseEffectMultipier() { effectMultiplier += 0.5; } } public boolean doesBoundaryOverlap(List boundaries) { for (PortalCluster cluster : clusters) for (Tile tile : cluster.getBoundary()) for (Tile boundary : boundaries) if (tile.getX() == boundary.getX() && tile.getY() == boundary.getY()) return true; return false; } }" "package com.rs.game.content.skills.dungeoneering.npcs; public class LexicusRunewright extends DungeonBoss { private static final int[] TELEPORT_LOCS = { 8, 7, 3, 3, 3, 12, 12, 12, 12, 3 }; private boolean completedFirstAttack; private int attackStage; private final List books = new CopyOnWriteArrayList<>(); public LexicusRunewright(Tile tile, DungeonManager manager, RoomReference reference) { super(DungeonUtils.getClosestToCombatLevel(Utils.range(9842, 9855), manager.getBossLevel()), tile, manager, reference); } @Override public void processHit(Hit hit) { int damage = hit.getDamage(); if (damage > 0) if (hit.getLook() == HitLook.MELEE_DAMAGE) hit.getSource().applyHit(new Hit(this, (int) (damage * .33), HitLook.REFLECTED_DAMAGE)); super.processHit(hit); } @Override public void sendDeath(Entity source) { super.sendDeath(source); for (TombOfLexicus book : books) book.sendDeath(book); } public void sendTeleport() { setCantInteract(true); setNextAnimation(new Animation(13499)); setNextSpotAnim(new SpotAnim(1576)); WorldTasks.scheduleLooping(new Task() { int cycles = 0; @Override public void run() { cycles++; if (cycles == 2) { int random = Utils.random(TELEPORT_LOCS.length); if (random != 0) random -= 1; tele(World.getFreeTile(getManager().getTile(getReference(), TELEPORT_LOCS[random], TELEPORT_LOCS[random + 1]), 2)); setNextAnimation(new Animation(13500)); setNextSpotAnim(new SpotAnim(1577)); } else if (cycles == 4) { setCantInteract(false); getCombat().removeTarget(); } } }, 0, 0); } public boolean sendAlmanacArmyAttack(final Entity target) { final LexicusRunewright boss = this; boss.setNextForceTalk(new ForceTalk(""Almanac Army, attack!"")); WorldTasks.scheduleTimer(2, (ticks) -> { for (int id = 0; id < 2; id++) { if (reachedMaxBookSize()) break; Tile tile = getManager().getTile(getReference(), 6 + Utils.random(4), 6 + Utils.random(4)); TombOfLexicus book = new TombOfLexicus(boss, 9856 + Utils.random(3), tile, getManager()); //TODO scale to combat level book.setTarget(target); books.add(book); } return false; }); return true; } public void removeBook(TombOfLexicus book) { books.remove(book); } private boolean reachedMaxBookSize() { int size = getManager().getParty().getTeam().size(); return books.size() >= (size > 3 ? 4 : size) * 3; } public boolean hasCompletedFirstAttack() { return completedFirstAttack; } public void setCompletedFirstAttack(boolean firstAttack) { completedFirstAttack = firstAttack; } public int getAttackStage() { return attackStage; } public void resetAttackStage() { attackStage = reachedMaxBookSize() ? 1 : 0; } public void incrementAttackStage() { attackStage++; } }" "package com.rs.game.content.skills.dungeoneering.npcs; public class LuminscentIcefiend extends DungeonBoss { private static final byte FIRST_STAGE = 3; private static final SpotAnim ICE_SHARDS = new SpotAnim(2525); private static final int KNOCKBACK = 10070; private final List icicles; private int specialStage; private boolean specialEnabled; public LuminscentIcefiend(Tile tile, DungeonManager manager, RoomReference reference) { super(DungeonUtils.getClosestToCombatLevel(Utils.range(9912, 9928), manager.getBossLevel()), tile, manager, reference); specialStage = FIRST_STAGE; icicles = new LinkedList<>(); } @Override public void processNPC() { super.processNPC(); int max_hp = getMaxHitpoints(); int current_hp = getHitpoints(); if (current_hp < max_hp * (.25 * specialStage) && !specialEnabled)//75, 50, 25 prepareSpecial(); } private void prepareSpecial() { setNextFaceEntity(null); setCapDamage(0); specialEnabled = true; specialStage--; } @Override public void handlePreHit(Hit hit) { int current_hp = getHitpoints(); if (hit.getDamage() >= current_hp && specialStage == 0 && !specialEnabled) { hit.setDamage(current_hp - 1); prepareSpecial(); } super.handlePreHit(hit); } public boolean isSpecialEnabled() { return specialEnabled; } public void commenceSpecial() { specialEnabled = false; final NPC icefiend = this; WorldTasks.scheduleLooping(new Task() { int count = 0; @Override public void run() { if (count == 21 || isDead()) { stop(); icicles.clear(); setCapDamage(-1); for (Player player : getManager().getParty().getTeam()) { player.setCantWalk(false); player.getTempAttribs().removeB(""FIEND_FLAGGED""); } return; } count++; if (count < 5) { if (count == 1) for (Entity t : getPossibleTargets()) { Player player = (Player) t; player.sendMessage(""The luminescent ice fiend is encased in ice and cannot be harmed!""); } return; } for (Entity t : getPossibleTargets()) { Player player = (Player) t; if (player == null || player.isDead() || player.hasFinished()) continue; Tile currentTile = player.getTempAttribs().getB(""FIEND_FLAGGED"") ? Tile.of(player.getTile()) : player.getLastTile(); for (int i = 0; i < icicles.size(); i++) { Tile tile = icicles.remove(i); player.getPackets().sendSpotAnim(ICE_SHARDS, tile); if (player.getTempAttribs().getB(""FIEND_FLAGGED"") || player.getX() != tile.getX() || player.getY() != tile.getY()) continue; player.getTempAttribs().setB(""FIEND_FLAGGED"", true); } icicles.add(currentTile); } if (count < 5) return; for (Tile tile : icicles) { for (Entity t : getPossibleTargets()) { Player player = (Player) t; if (!player.getTempAttribs().getB(""FIEND_FLAGGED"")) continue; Tile nextTile = World.getFreeTile(player.getTile(), 1); if (!player.isCantWalk()) player.setCantWalk(true); if (player.getActionManager().getAction() != null) player.getActionManager().forceStop(); player.forceMove(nextTile, KNOCKBACK, 5, 30); int damageCap = (int) (player.getMaxHitpoints() * .10); if (player.getHitpoints() < damageCap)// If has 10% of HP. continue; int damage = Utils.random(20, 100); if (player.getHitpoints() - damage <= damageCap) damage = damageCap; player.applyHit(new Hit(icefiend, damage, HitLook.TRUE_DAMAGE)); } } } }, 0, 0); } }" "package com.rs.game.content.skills.dungeoneering.npcs; public class MastyxTrap extends NPC { private static final int BASE_TRAP = 11076; private final String playerName; private int ticks; public MastyxTrap(String playerName, int id, Tile tile) { super(id, tile); this.playerName = playerName; } @Override public void processNPC() { //Doesn't move or do anything so we don't process it. ticks++; if (ticks == 500) finish(); } public String getPlayerName() { return playerName; } public int getTier() { return getId() - BASE_TRAP; } }" "package com.rs.game.content.skills.dungeoneering.npcs; public class NecroLord extends DungeonBoss { private int resetTicks; private final List skeletons; public NecroLord(Tile tile, DungeonManager manager, RoomReference reference) { super(DungeonUtils.getClosestToCombatLevel(Utils.range(11737, 11751), manager.getBossLevel()), tile, manager, reference); setCantFollowUnderCombat(true); //force can't walk setLureDelay(Integer.MAX_VALUE);//doesn't stop focusing on target skeletons = new CopyOnWriteArrayList<>(); } @Override public void processNPC() { super.processNPC(); if (!isUnderCombat() && skeletons != null && !skeletons.isEmpty()) { resetTicks++; if (resetTicks == 50) { resetSkeletons(); resetTicks = 0; } } } @Override public double getMagePrayerMultiplier() { return 0.6; } public void addSkeleton(Tile tile) { SkeletalMinion npc = new SkeletalMinion(this, 11722, tile, getManager()); //TODO scale to level npc.setForceAgressive(true); skeletons.add(npc); World.sendSpotAnim(tile, new SpotAnim(2399)); } public void resetSkeletons() { for (SkeletalMinion skeleton : skeletons) skeleton.sendDeath(this); skeletons.clear(); } public void removeSkeleton(DungeonNPC sk) { skeletons.remove(sk); } /* * because necrolord room has a safespot which shouldnt */ @Override public boolean lineOfSightTo(Object tile, boolean checkClose) { //because npc is under cliped data return getManager().isAtBossRoom(WorldUtil.targetToTile(tile)); } @Override public void sendDeath(Entity source) { super.sendDeath(source); resetSkeletons(); } @Override public void sendDrop(Player player, Item item) { List players = getManager().getParty().getTeam(); if (players.isEmpty()) return; player.getInventory().addItemDrop(item); player.sendMessage(""You received: "" + item.getAmount() + "" "" + item.getName() + "".""); for (Player p2 : players) { if (p2 == player) continue; p2.sendMessage("""" + player.getDisplayName() + "" received: "" + item.getAmount() + "" "" + item.getName() + "".""); } } }" "package com.rs.game.content.skills.dungeoneering.npcs; public final class NightGazerKhighorahk extends DungeonBoss { private boolean secondStage; private boolean usedSpecial; private int lightCount; public NightGazerKhighorahk(Tile tile, DungeonManager manager, RoomReference reference) { super(DungeonUtils.getClosestToCombatLevel(Utils.range(9725, 9738), manager.getBossLevel()), tile, manager, reference); setCantFollowUnderCombat(true); //force cant walk } public boolean isSecondStage() { return secondStage; } @Override public void sendDeath(final Entity source) { if (!secondStage) { secondStage = true; setNextAnimation(new Animation(getCombatDefinitions().getDeathEmote())); transformIntoNPC(getId() + 14); setCombatLevel((int) (getCombatLevel() * 0.85)); //15% nerf setHitpoints(getMaxHitpoints()); resetBonuses(); return; } super.sendDeath(source); } public boolean isUsedSpecial() { return usedSpecial; } public void setUsedSpecial(boolean usedSpecial) { this.usedSpecial = usedSpecial; } @Override public void handlePreHit(Hit hit) { if (!secondStage) reduceHit(hit); super.handlePreHit(hit); } public void reduceHit(Hit hit) { if (hit.getLook() != HitLook.MELEE_DAMAGE && hit.getLook() != HitLook.RANGE_DAMAGE && hit.getLook() != HitLook.MAGIC_DAMAGE) return; hit.setDamage((int) (hit.getDamage() * lightCount * 0.25)); } public void lightPillar(Player player, GameObject object) { if (lightCount >= 4) return; if (!player.getInventory().containsOneItem(DungeonConstants.TINDERBOX)) { player.sendMessage(""You need a tinderbox to do this.""); return; } player.setNextAnimation(new Animation(833)); final GameObject light = new GameObject(object); light.setId(object.getId() + 1); World.spawnObject(light); lightCount++; WorldTasks.schedule(new Task() { @Override public void run() { try { lightCount--; World.removeObject(light); for (Entity target : getPossibleTargets()) if (target.withinDistance(light.getTile(), 2)) { target.applyHit(new Hit(NightGazerKhighorahk.this, Utils.random((int) (target.getMaxHitpoints() * 0.25)) + 1, HitLook.TRUE_DAMAGE)); if (target instanceof Player player) player.sendMessage(""You are damaged by the shadows engulfing the pillar of light.""); } } catch (Throwable e) { Logger.handle(NightGazerKhighorahk.class, ""lightPillar"", e); } } }, Ticks.fromSeconds(30) - getManager().getParty().getSize() * Ticks.fromSeconds(3)); } /* @Override public void sendDeath(final Entity source) { final NPCCombatDefinitions defs = getCombatDefinitions(); resetWalkSteps(); getCombat().removeTarget(); setNextAnimation(null); WorldTasksManager.schedule(new WorldTask() { int loop; @Override public void run() { if (loop == 0) { setNextAnimation(new Animation(defs.getDeathEmote())); } else if (loop >= defs.getDeathDelay()) { if (source instanceof Player) ((Player) source).getControllerManager().processNPCDeath(NightGazerKhighorahk.this); drop(); reset(); if (source.getAttackedBy() == NightGazerKhighorahk.this) { //no need to wait after u kill source.setAttackedByDelay(0); source.setAttackedBy(null); source.setFindTargetDelay(0); } setCantInteract(true); setNextNPCTransformation(9781); stop(); } loop++; } }, 0, 1); getManager().openStairs(getReference()); }*/ }" "package com.rs.game.content.skills.dungeoneering.npcs; public class Rammernaut extends DungeonBoss { private Player chargeTarget; private int count; private boolean requestSpecNormalAttack; public Rammernaut(Tile tile, DungeonManager manager, RoomReference reference) { super(DungeonUtils.getClosestToCombatLevel(Utils.range(9767, 9780), manager.getBossLevel()), tile, manager, reference); setForceFollowClose(true); } public void fail() { setNextAnimation(new Animation(13707)); setNextForceTalk(new ForceTalk(""Oooof!!"")); count = -14; } public void sucess() { resetWalkSteps(); setNextAnimation(new Animation(13698)); applyStunHit(chargeTarget, (int) (chargeTarget.getMaxHitpoints() * 0.6)); requestSpecNormalAttack = true; count = -12; } public void applyStunHit(final Entity entity, int maxHit) { entity.applyHit(new Hit(this, Utils.random(maxHit) + 1, HitLook.TRUE_DAMAGE)); entity.freeze(2); if (entity instanceof Player player) { player.stopAll(); player.sendMessage(""You've been stunned.""); player.freeze(2); if (player.getPrayer().hasProtectionPrayersOn()) { player.sendMessage(""Your prayers have been disabled.""); player.setProtectionPrayBlock(2); } WorldTasks.schedule(1, () -> { Tile tile = null; byte[] dirs = Utils.getDirection(getFaceAngle()); for (int distance = 6; distance >= 0; distance--) { tile = Tile.of(Tile.of(entity.getX() + (dirs[0] * distance), entity.getY() + (dirs[1] * distance), entity.getPlane())); if (World.floorFree(tile.getPlane(), tile.getX(), tile.getY()) && getManager().isAtBossRoom(tile)) break; if (distance == 0) tile = Tile.of(entity.getTile()); } entity.faceEntity(this); entity.forceMove(tile, Direction.getDirectionTo(entity, getTile()), 10070, 5, 60); }); } } @Override public void processNPC() { if (isDead()) return; if (chargeTarget != null) { setNextFaceEntity(chargeTarget); if (count == 0) { setNextForceTalk(new ForceTalk(""CHAAAAAARGE!"")); setRun(true); } else if (count == -10) { setRun(false); resetWalkSteps(); calcFollow(chargeTarget, true); } else if (count == -8) setChargeTarget(null); else if (count > 2) { resetWalkSteps(); /* * skip first step else it stucks ofc */ calcFollow(chargeTarget, true); if (count != 3 && !World.floorAndWallsFree(getTile(), getSize())) fail(); else if (WorldUtil.isInRange(getX(), getY(), getSize(), chargeTarget.getX(), chargeTarget.getY(), chargeTarget.getSize(), 0)) sucess(); else if (!hasWalkSteps()) fail(); } count++; return; } super.processNPC(); /*int chargeCount = getChargeCount(npc); if (chargeCount > 1) { if (chargeCount == 2) { npc.setNextForceTalk(new ForceTalk(""CHAAAAAARGE!"")); npc.setRun(true); setChargeCount(npc, 3); return defs.getAttackDelay(); } else if (chargeCount == 3) { npc.calcFollow(target, true); //gotta be changed later if (Utils.isOnRange(npc.getX(), npc.getY(), npc.getSize(), target.getX(), target.getY(), target.getSize(), 0)) { npc.setNextAnimation(new Animation(13705)); setChargeCount(npc, 0); return defs.getAttackDelay(); } } return 0; }*/ } public void setChargeTarget(Player target) { chargeTarget = target; getCombat().removeTarget(); count = 0; } public boolean isRequestSpecNormalAttack() { return requestSpecNormalAttack; } public void setRequestSpecNormalAttack(boolean requestSpecNormalAttack) { this.requestSpecNormalAttack = requestSpecNormalAttack; } }" "package com.rs.game.content.skills.dungeoneering.npcs; public class RuneboundBehemoth extends DungeonBoss { private static final String[] ARTIFACT_TYPE = { ""Melee"", ""Range"", ""Magic"" }; private final BehemothArtifact[] artifacts; private final int baseId; public RuneboundBehemoth(Tile tile, DungeonManager manager, RoomReference reference) { super(DungeonUtils.getClosestToCombatLevel(Utils.range(11812, 11826), manager.getBossLevel()), tile, manager, reference); this.baseId = getId(); this.artifacts = new BehemothArtifact[3]; for (int idx = 0; idx < artifacts.length; idx++) artifacts[idx] = new BehemothArtifact(idx); } @Override public void processNPC() { if (isDead()) return; if (artifacts != null) for (BehemothArtifact artifact : artifacts) artifact.cycle(); super.processNPC(); } @Override public void processHit(Hit hit) { if (hit.getDamage() > 0) reduceHit(hit); super.processHit(hit); } public void reduceHit(Hit hit) { if ((hit.getLook() == HitLook.MELEE_DAMAGE && artifacts[0].isPrayerEnabled()) || (hit.getLook() == HitLook.RANGE_DAMAGE && artifacts[1].isPrayerEnabled()) || (hit.getLook() == HitLook.MAGIC_DAMAGE && artifacts[2].isPrayerEnabled())) return; hit.setDamage(0); } public void activateArtifact(Player player, GameObject object, int type) { BehemothArtifact artifact = artifacts[type]; if (artifact.isActive())//Hax unit 2k13 return; GameObject o = new GameObject(object); o.setId(type == 0 ? 53980 : type == 1 ? 53982 : 53981); World.spawnObjectTemporary(o, Ticks.fromSeconds(30)); artifact.setActive(true, true); sendNPCTransformation(); } public void resetTransformation() { for (BehemothArtifact artifact : artifacts) artifact.setActive(false, false); sendNPCTransformation(); } private void sendNPCTransformation() { transformIntoNPC(getNPCId()); } public int getNPCId() { boolean melee = artifacts[0].isPrayerEnabled(); boolean range = artifacts[1].isPrayerEnabled(); boolean magic = artifacts[2].isPrayerEnabled(); if (melee && magic && range) return baseId - 45; if (melee && range) return baseId + 30; if (melee && magic) return baseId + 15; else if (magic && range) return baseId + 45; else if (melee) return baseId - 15; else if (range) return baseId - 30; else if (magic) return baseId - 60; return baseId; } class BehemothArtifact { final int type; private boolean active; private int cycle; public BehemothArtifact(int type) { this.type = type; } public void cycle() { if (active) { cycle++; if (cycle == 50) setActive(false, true); else if (cycle == 25) sendNPCTransformation(); } } public boolean isPrayerEnabled() { return cycle < 25 && active; } public boolean isActive() { return active; } public void setActive(boolean active, boolean message) { this.active = active; if (!active) cycle = 0; if (message) for (Player p2 : getManager().getParty().getTeam()) { if (getManager().isAtBossRoom(p2.getTile())) continue; p2.sendMessage(""The "" + ARTIFACT_TYPE[type] + "" artifact has been "" + (active ? ""desactivated"" : ""re-charged"") + ""!""); } } } }" "package com.rs.game.content.skills.dungeoneering.npcs; public class Sagittare extends DungeonBoss { private final int stage; private boolean special; public Sagittare(Tile tile, DungeonManager manager, RoomReference reference) { super(DungeonUtils.getClosestToCombatLevel(Utils.range(9753, 9766), manager.getBossLevel()), tile, manager, reference); setCantFollowUnderCombat(true); this.stage = -1; } @Override public void processNPC() { super.processNPC(); // int max_hp = getMaxHitpoints(); // int current_hp = getHitpoints(); // if ((current_hp == 1 || current_hp < max_hp * (.25 * stage)) && !special) { // special = true; // stage--; // } } @Override public void processHit(Hit hit) { int damage = hit.getDamage(); if (damage > 0) if (hit.getLook() == HitLook.RANGE_DAMAGE) hit.setDamage((int) (damage * .4)); super.processHit(hit); } public boolean isUsingSpecial() { return special; } public void setUsingSpecial(boolean special) { this.special = special; } public int getStage() { return stage; } @Override public void sendDeath(final Entity source) { if (stage != -1) { setHitpoints(1); return; } super.sendDeath(source); } @Override public void sendDrop(Player player, Item item) { List players = getManager().getParty().getTeam(); if (players.isEmpty()) return; player.getInventory().addItemDrop(item); player.sendMessage(""You received: "" + item.getAmount() + "" "" + item.getName() + "".""); for (Player p2 : players) { if (p2 == player) continue; p2.sendMessage("""" + player.getDisplayName() + "" received: "" + item.getAmount() + "" "" + item.getName() + "".""); } } }" "package com.rs.game.content.skills.dungeoneering.npcs; public final class ShadowForgerIhlakhizan extends DungeonBoss { public ShadowForgerIhlakhizan(Tile tile, DungeonManager manager, RoomReference reference) { super(DungeonUtils.getClosestToCombatLevel(Utils.range(10143, 10156), manager.getBossLevel()), tile, manager, reference); setCantFollowUnderCombat(true); //force cant walk } @Override public void setNextFaceEntity(Entity entity) { //this boss doesnt face } @Override public boolean ignoreWallsWhenMeleeing() { return true; } @Override public void processNPC() { if (isDead()) return; super.processNPC(); for (Player player : getManager().getParty().getTeam()) { if (!getManager().isAtBossRoom(player.getTile()) || lineOfSightTo(player, false) || player.getTempAttribs().getB(""SHADOW_FORGER_SHADOW"")) continue; player.setNextSpotAnim(new SpotAnim(2378)); player.getTempAttribs().setB(""SHADOW_FORGER_SHADOW"", true); player.applyHit(new Hit(this, Utils.random((int) (player.getMaxHitpoints() * 0.1)) + 1, HitLook.TRUE_DAMAGE)); } } public void setUsedShadow() { for (Player player : getManager().getParty().getTeam()) player.getTempAttribs().setB(""SHADOW_FORGER_SHADOW"", true); } @Override public double getMeleePrayerMultiplier() { return 0.6; } @Override public double getMagePrayerMultiplier() { return 0.6; } @Override public double getRangePrayerMultiplier() { return 0.6; } @Override public void sendDrop(Player player, Item item) { List players = getManager().getParty().getTeam(); if (players.isEmpty()) return; player.getInventory().addItemDrop(item); player.sendMessage(""You received: "" + item.getAmount() + "" "" + item.getName() + "".""); for (Player p2 : players) { if (p2 == player) continue; p2.sendMessage("""" + player.getDisplayName() + "" received: "" + item.getAmount() + "" "" + item.getName() + "".""); } } }" "package com.rs.game.content.skills.dungeoneering.npcs; public final class SkeletalAdventurer extends DungeonBoss { public static final int MELEE = 0, RANGE = 1, MAGE = 2; private final int npcId; public SkeletalAdventurer(int type, Tile tile, DungeonManager manager, RoomReference reference) { super(type == MELEE ? DungeonUtils.getClosestToCombatLevel(Utils.range(11940, 11984, 3), manager.getBossLevel()) : type == RANGE ? DungeonUtils.getClosestToCombatLevel(Utils.range(12044, 12088, 3), manager.getBossLevel()) : DungeonUtils.getClosestToCombatLevel(Utils.range(11999, 12043, 3), manager.getBossLevel()), tile, manager, reference); this.npcId = getId(); } @Override public void processNPC() { if (isDead()) return; super.processNPC(); if (Utils.random(15) == 0) transformIntoNPC(npcId + Utils.random(3)); } @Override public void sendDeath(final Entity source) { final NPCCombatDefinitions defs = getCombatDefinitions(); resetWalkSteps(); getCombat().removeTarget(); setNextAnimation(null); boolean last = true; for (NPC npc : World.getNPCsInChunkRange(getChunkId(), 2)) { if (npc == this || npc.isDead() || npc.hasFinished() || !npc.getName().startsWith(""Skeletal "")) continue; last = false; } final boolean l = last; WorldTasks.scheduleTimer(loop -> { if (loop == 0) setNextAnimation(new Animation(defs.getDeathEmote())); else if (loop >= defs.getDeathDelay()) { if (source instanceof Player player) player.getControllerManager().processNPCDeath(SkeletalAdventurer.this); if (l) drop(); reset(); finish(); return false; } return true; }); if (last) getManager().openStairs(getReference()); } @Override public int getMaxHit() { return super.getMaxHit() * 2; } public int getPrayer() { return getId() - npcId; } @Override public void handlePreHit(Hit hit) { if ((hit.getLook() == HitLook.MELEE_DAMAGE && getPrayer() == 0) || (hit.getLook() == HitLook.RANGE_DAMAGE && getPrayer() == 1) || (hit.getLook() == HitLook.MAGIC_DAMAGE && getPrayer() == 2)) hit.setDamage(0); super.handlePreHit(hit); } @Override public void sendDrop(Player player, Item item) { List players = getManager().getParty().getTeam(); if (players.isEmpty()) return; player.getInventory().addItemDrop(item); player.sendMessage(""You received: "" + item.getAmount() + "" "" + item.getName() + "".""); for (Player p2 : players) { if (p2 == player) continue; p2.sendMessage("""" + player.getDisplayName() + "" received: "" + item.getAmount() + "" "" + item.getName() + "".""); } } }" "package com.rs.game.content.skills.dungeoneering.npcs; public class SkeletalMinion extends DungeonNPC { private final NecroLord boss; public SkeletalMinion(NecroLord boss, int id, Tile tile, DungeonManager manager) { super(id, tile, manager); setForceAgressive(true); this.boss = boss; } @Override public double getMeleePrayerMultiplier() { return 0.6; } @Override public void drop() { } @Override public int getMaxHit() { return super.getMaxHit() * 2; } @Override public void sendDeath(Entity source) { super.sendDeath(source); boss.removeSkeleton(this); } }" "package com.rs.game.content.skills.dungeoneering.npcs; @PluginEventHandler public final class Stomp extends DungeonBoss { private static final int IVULNERABLE_TIMER = 37; // 16.5 sec private int stage; private int count; private int lodeStoneType; private final boolean[] lodestones; private final List shadows; public Stomp(Tile tile, DungeonManager manager, RoomReference reference) { super(DungeonUtils.getClosestToCombatLevel(Utils.range(9782, 9796), manager.getBossLevel()), tile, manager, reference); setCantFollowUnderCombat(true); // force cant walk freeze(5000000); lodestones = new boolean[2]; shadows = new ArrayList<>(); } @ServerStartupEvent public static void overrideLoS() { Entity.addLOSOverride((source, target, melee) -> { if (target instanceof Stomp s) return s.getManager().isAtBossRoom(source.getTile()); return false; }); } @Override public boolean ignoreWallsWhenMeleeing() { return true; } @Override public Tile getMiddleTile() { return this.getTile(); } @Override public void processNPC() { if (getId() == 9781) setNextAnimation(new Animation(13460)); else { if (count > 0) { if (count == IVULNERABLE_TIMER - 3) { List possibleTargets = getPossibleTargets(); for (int[] s : shadows) { GameObject object = getManager().spawnObjectTemporary(getReference(), 49268, ObjectType.SCENERY_INTERACT, 0, s[0], s[1], Ticks.fromSeconds(30)); for (Entity target : possibleTargets) if (target.getX() == object.getX() && target.getY() == object.getY()) target.applyHit(new Hit(this, 1 + Utils.random((int) (target.getMaxHitpoints() * 0.8)), HitLook.TRUE_DAMAGE)); } } if (count == 1) { setCantInteract(false); if (lodestones[0] && lodestones[1]) { stage++; if (stage == 3) { setHitpoints(0); sendDeath(this); destroyExistingDebris(); } for (Entity target : getPossibleTargets()) if (target instanceof Player player) player.sendMessage(""The portal weakens, harming Stomp!""); } else heal((int) (getMaxHitpoints() * 0.25)); lodestones[0] = lodestones[1] = false; refreshLodestones(); removeCrystals(); } count--; return; } super.processNPC(); } } @Override public double getMeleePrayerMultiplier() { return stage == 2 ? 0.6 : 0; } @Override public double getMagePrayerMultiplier() { return stage == 2 ? 0.6 : 0; } @Override public double getRangePrayerMultiplier() { return stage == 2 ? 0.6 : 0; } public void refreshLodestones() { for (int i = 0; i < lodestones.length; i++) refreshLodestone(i); } private static final int[] CRYSTAL = { 15752, 15751, 15750 }; public void refreshLodestone(int index) { int id = count == IVULNERABLE_TIMER ? (49274 + lodeStoneType * 2 + index) : lodestones[index] ? lodeStoneType == 0 ? 51099 : lodeStoneType == 1 ? 51601 : 51647 : (49270 + index); getManager().spawnObject(getReference(), id, ObjectType.SCENERY_INTERACT, 2, index == 1 ? 10 : 5, 10); } public void chargeLodeStone(Player player, int index) { if (lodestones[index] || count <= 1) return; if (player.getInventory().containsItem(CRYSTAL[lodeStoneType], 1)) { player.lock(1); player.setNextAnimation(new Animation(833)); lodestones[index] = true; player.getInventory().deleteItem(CRYSTAL[lodeStoneType], 1); player.sendMessage(""You place the crystal into the device and it powers up.""); refreshLodestone(index); if (lodestones[0] && lodestones[1]) for (Entity target : getPossibleTargets()) if (target instanceof Player p2) p2.sendMessage(""The lodestone has been fully activated.""); } else player.sendMessage(""You need a "" + ItemDefinitions.getDefs(CRYSTAL[lodeStoneType]).getName().toLowerCase() + "" to activate this lodestone.""); } public void charge() { count = IVULNERABLE_TIMER; lodeStoneType = Utils.random(3); refreshLodestones(); setNextAnimation(new Animation(13451)); setNextSpotAnim(new SpotAnim(2407)); setCantInteract(true); for (Entity target : getPossibleTargets()) if (target instanceof Player player) player.sendMessage(""Stomp enters a defensive stance. It is currently invulnerable, but no longer protecting the portal's lodestones!""); destroyExistingDebris(); for (int count = 0; count < 11; count++) l: for (int i = 0; i < DungeonConstants.SET_RESOURCES_MAX_TRY; i++) { int x = 3 + Utils.random(12); int y = 3 + Utils.random(9); if (containsShadow(x, y) || !getManager().isFloorFree(getReference(), x, y)) continue; shadows.add(new int[] { x, y }); getManager().spawnObject(getReference(), 49269, ObjectType.SCENERY_INTERACT, 0, x, y); break l; } for (int count = 0; count < 2; count++) l: for (int i = 0; i < DungeonConstants.SET_RESOURCES_MAX_TRY; i++) { int x = 3 + Utils.random(12); int y = 3 + Utils.random(9); if (containsShadow(x, y) || !getManager().isFloorFree(getReference(), x, y)) continue; getManager().spawnItem(getReference(), new Item(CRYSTAL[lodeStoneType]), x, y); break l; } } /* * if wasnt destroyed yet */ public void destroyExistingDebris() { for (int[] s : shadows) getManager().removeObject(getReference(), 49269, ObjectType.SCENERY_INTERACT, 0, s[0], s[1]); shadows.clear(); } public void removeCrystals() { for (GroundItem item : World.getAllGroundItemsInChunkRange(getChunkId(), 2)) if (item.getId() == CRYSTAL[lodeStoneType]) World.removeGroundItem(item); } public boolean containsShadow(int x, int y) { for (int[] s : shadows) if (s[0] == x && s[1] == y) return true; return false; } @Override public void sendDeath(final Entity source) { if (stage != 3) { setHitpoints(1); return; } final NPCCombatDefinitions defs = getCombatDefinitions(); resetWalkSteps(); getCombat().removeTarget(); setNextAnimation(null); WorldTasks.scheduleTimer(loop -> { if (loop == 0) setNextAnimation(new Animation(defs.getDeathEmote())); else if (loop >= defs.getDeathDelay()) { if (source instanceof Player player) player.getControllerManager().processNPCDeath(Stomp.this); drop(); reset(); setCantInteract(true); transformIntoNPC(9781); return false; } return true; }); getManager().openStairs(getReference()); } /* * @Override public Item sendDrop(Player player, Drop drop) { Item item = new Item(drop.getItemId()); player.getInventory().addItemDrop(item.getId(), item.getAmount()); return item; } */ @Override public void setNextFaceEntity(Entity entity) { // this boss doesnt face } @Override public boolean lineOfSightTo(Object tile, boolean checkClose) { // because npc is under cliped data return getManager().isAtBossRoom(WorldUtil.targetToTile(tile)); } public int getStage() { return stage; } public void setStage(int stage) { this.stage = stage; } }" "package com.rs.game.content.skills.dungeoneering.npcs; public class ToKashBloodChiller extends DungeonBoss { private boolean specialAttack; public ToKashBloodChiller(Tile tile, DungeonManager manager, RoomReference reference) { super(DungeonUtils.getClosestToCombatLevel(Utils.range(10024, 10039), manager.getBossLevel()), tile, manager, reference); } @Override public double getMeleePrayerMultiplier() { return 1.5; } @Override public double getRangePrayerMultiplier() { return 1.5; } public void setSpecialAttack(boolean specialAttack) { this.specialAttack = specialAttack; } public boolean canSpecialAttack() { return !specialAttack; } }" "package com.rs.game.content.skills.dungeoneering.npcs; public class TombOfLexicus extends DungeonNPC { private final LexicusRunewright boss; public TombOfLexicus(LexicusRunewright boss, int id, Tile tile, DungeonManager manager) { super(id, tile, manager); setForceAgressive(true); this.boss = boss; } @Override public double getMeleePrayerMultiplier() { return 0.6; } @Override public double getMagePrayerMultiplier() { return 0.6; } @Override public double getRangePrayerMultiplier() { return 0.6; } @Override public void drop() { } @Override public int getMaxHitpoints() { return 10; } @Override public void sendDeath(Entity source) { super.sendDeath(source); boss.removeBook(this); } }" "package com.rs.game.content.skills.dungeoneering.npcs; public final class UnholyCrossbearer extends DungeonBoss { public UnholyCrossbearer(int id, Tile tile, DungeonManager manager, RoomReference reference) { super(DungeonUtils.getClosestToCombatLevel(Utils.range(10111, 10127), (int)Math.ceil(manager.getBossLevel() - manager.getBossLevel()*0.15)), tile, manager, reference); } }" "package com.rs.game.content.skills.dungeoneering.npcs; public class WarpedGulega extends DungeonBoss { public WarpedGulega(Tile tile, DungeonManager manager, RoomReference reference) { super(DungeonUtils.getClosestToCombatLevel(Utils.range(12737, 12751), manager.getBossLevel()), tile, manager, reference); } //thats default lol /* @Override public double getMeleePrayerMultiplier() { return 0.0;//Fully block it. } @Override public double getRangePrayerMultiplier() { return 0.0;//Fully block it. } @Override public double getMagePrayerMultiplier() { return 0.0;//Fully block it. }*/ @Override public void processHit(Hit hit) { if (!(hit.getSource() instanceof Familiar)) hit.setDamage((int) (hit.getDamage() * 0.45D)); super.processHit(hit); } }" "package com.rs.game.content.skills.dungeoneering.npcs; public class WarpedSphere extends DungeonNPC { private static final int[][] ORB_TELEPORT_LOCATIONS = { { 0, 0 }, { 0, 0 }, { 13, 4 }, { 11, 12 }, { 3, 4 }, { 3, 12 } }; private static final int[][] PLAYER_TELEPORT_LOCATIONS = { { 0, 0 }, { 0, 0 }, { 6, 11 }, { 10, 4 }, { 10, 11 }, { 10, 4 } }; private final RoomReference reference; private int stage; public WarpedSphere(RoomReference reference, int id, Tile tile, DungeonManager manager) { super(id, tile, manager); this.reference = reference; this.stage = -1; // Gotta follow warmonger } @Override public void processNPC() { super.processNPC(); if (stage > 0) if (hasWalkSteps()) { Tile previousTile = getLastTile(); if (previousTile == null) return; final int[] TELEPORT_TILE = PLAYER_TELEPORT_LOCATIONS[stage]; for (Player player : getManager().getParty().getTeam()) if (!player.isLocked() && player.matches(previousTile)) { player.applyHit(new Hit(this, 100, HitLook.REFLECTED_DAMAGE)); Magic.sendTeleportSpell(player, 13493, 13494, 2437, 2435, 0, 0, getManager().getTile(reference, TELEPORT_TILE[0], TELEPORT_TILE[1]), 6, false, TeleType.MAGIC, null); } } if (!hasWalkSteps()) { if (Math.random() > 0.59564) { int moveX = (int) Math.round(Math.random() * 10.0 - 5.0); int moveY = (int) Math.round(Math.random() * 10.0 - 5.0); addWalkSteps(getRespawnTile().getX() + moveX, getRespawnTile().getY() + moveY, 5, true); } } } public void nextStage() { stage++; final int[] TELEPORT_TILE = ORB_TELEPORT_LOCATIONS[stage]; if (TELEPORT_TILE[0] == 0) return; Tile nextTile = getManager().getTile(reference, TELEPORT_TILE[0], TELEPORT_TILE[1]); setRespawnTile(nextTile); tele(nextTile); } }" "package com.rs.game.content.skills.dungeoneering.npcs; public class WorldGorgerShukarhazh extends DungeonBoss { private static final int[][] EYE_COORDINATES = { { 0, 7 }, { 7, 15 }, { 15, 8 } }; private final FamishedEye[] eyes; public WorldGorgerShukarhazh(Tile tile, DungeonManager manager, RoomReference reference) { super(DungeonUtils.getClosestToCombatLevel(Utils.range(12478, 12492), manager.getBossLevel()), tile, manager, reference); eyes = new FamishedEye[3]; for (int idx = 0; idx < eyes.length; idx++) eyes[idx] = new FamishedEye(this, 12436 + (idx * 15), manager.getTile(reference, EYE_COORDINATES[idx][0], EYE_COORDINATES[idx][1]), manager); //TODO scale to combat level refreshCapDamage(); } @Override public void processHit(Hit hit) { for (FamishedEye eye : eyes) if (eye.getType() == hit.getLook().getMark()) { if (eye.isInactive()) hit.setDamage((int) (hit.getDamage() * 0.1)); break; } super.processHit(hit); } public void refreshCapDamage() { int inactiveCounter = 0; for (FamishedEye eye : eyes) { boolean inactive = eye.isInactive(); if (inactive) inactiveCounter++; } setCapDamage(inactiveCounter == 0 ? 500 : inactiveCounter == 1 ? 1500 : -1); } @Override public double getMagePrayerMultiplier() { return 0.6;//reg } @Override public double getMeleePrayerMultiplier() { return 1.0;//prayer dun work m8t } @Override public void sendDeath(Entity source) { super.sendDeath(source); for (FamishedEye eye : eyes) eye.finish(); } public FamishedEye[] getFamishedEyes() { return eyes; } }" "package com.rs.game.content.skills.dungeoneering.npcs; public class YkLagorMage extends DungeonNPC { private final YkLagorThunderous boss; private int cycle; public YkLagorMage(YkLagorThunderous ykLagorThunderous, int id, Tile tile, DungeonManager manager, double multiplier) { super(id, tile, manager); boss = ykLagorThunderous; setNextFaceEntity(boss); setCantFollowUnderCombat(true); } @Override public void processNPC() { if (isDead() || boss == null) return; if (isUnderCombat()) { super.processNPC(); return; } if (cycle > 0) { cycle--; return; } cycle = 5; setNextFaceEntity(boss); setNextAnimation(new Animation(3645)); World.sendProjectile(this, boss, 2704, 39, 39, 55, 70, 0, 0); } @Override public void drop() { } @Override public int getMaxHitpoints() { return 650; } @Override public int getCombatLevel() { return 65; } /*@Override public void sendDeath(Entity source) { super.sendDeath(source); }*/ }" "package com.rs.game.content.skills.dungeoneering.npcs; public class YkLagorThunderous extends DungeonBoss { private static final int[][] BROKEN_FLOORS_TILES = { { 5, 11 }, { 2, 13 }, { 10, 11 }, { 13, 12 }, { 11, 8 }, { 11, 6 }, { 13, 4 }, { 9, 5 }, { 10, 3 }, { 3, 3 }, { 4, 9 }, { 7, 4 }, { 4, 6 } }; private static final int[][] PILLAR_SAFEZONE = { { 1, 6 }, { 1, 9 }, { 14, 9 }, { 14, 6 } }; private static final SpotAnim EARTH_QUAKE_GRAPHICS = new SpotAnim(1551, 10, 20); private YkLagorMage[] mysteriousMages; private int startCountdown; private int nextAttack; private final boolean loaded; public YkLagorThunderous(Tile tile, DungeonManager manager, RoomReference reference) { super(DungeonUtils.getClosestToCombatLevel(Utils.range(11872, 11886), manager.getBossLevel()), tile, manager, reference); setCantInteract(true); setCantFollowUnderCombat(true); setMages(); loaded = true; } private void setMages() { mysteriousMages = new YkLagorMage[] { new YkLagorMage(this, 11887, getManager().getTile(getReference(), 7, 3), getManager(), 1), new YkLagorMage(this, 11887, getManager().getTile(getReference(), 4, 5), getManager(), 1), new YkLagorMage(this, 11887, getManager().getTile(getReference(), 3, 8), getManager(), 1), new YkLagorMage(this, 11887, getManager().getTile(getReference(), 4, 11), getManager(), 1), new YkLagorMage(this, 11887, getManager().getTile(getReference(), 7, 12), getManager(), 1), new YkLagorMage(this, 11887, getManager().getTile(getReference(), 10, 11), getManager(), 1), new YkLagorMage(this, 11887, getManager().getTile(getReference(), 11, 8), getManager(), 1), new YkLagorMage(this, 11887, getManager().getTile(getReference(), 10, 5), getManager(), 1), }; } private final static String[] QUOTES = { ""We will break you!"", ""You've outlived your use!"", ""You do not belong here."", ""Your soul belongs to us!"", ""Mah zodas'bakh me'ah."" }; //private final static int[] QUOTES_SOUNDS = { 1899, 1903, 1902, 1901, 1900 }; public YkLagorMage[] getMages() { return mysteriousMages; } @Override public void processNPC() { if (!loaded) return; if (isCantInteract()) { if (startCountdown > 0) { startCountdown--; if (startCountdown == 0) { YkLagorThunderousCombat.sendMagicalAttack(this, true); getCombat().setCombatDelay(5); setCantInteract(false); mysteriousMages = null; } return; } int distractedMages = 0; for (YkLagorMage mage : mysteriousMages) if (mage.isUnderCombat() || mage.isDead() || mage.hasFinished()) distractedMages++; if (distractedMages >= 4 && Utils.random(5) == 0) { setNextAnimation(new Animation(14443)); setNextSpotAnim(new SpotAnim(166)); setNextForceTalk(new ForceTalk(""MY TURN!"")); //playSound(1935, 1); playMusic(); startCountdown = 10; return; } setNextAnimation(new Animation(14442)); setNextSpotAnim(new SpotAnim(165)); if (Utils.random(33) == 0 && !getPossibleTargets().isEmpty()) { YkLagorMage mage = mysteriousMages[Utils.random(mysteriousMages.length)]; if (mage.isUnderCombat() || mage.isDead() || mage.hasFinished()) return; int index = Utils.random(QUOTES.length); mage.setNextForceTalk(new ForceTalk(QUOTES[index])); //mage.playSound(QUOTES_SOUNDS[index], 1); } return; } super.processNPC(); } public void playMusic() { for (Player player : getManager().getParty().getTeam()) { if (player.isDead() || !getManager().isAtBossRoom(player.getTile())) continue; player.getMusicsManager().forcePlayMusic(863); } } @Override public double getMagePrayerMultiplier() { return 0.6; } public List getPossibleTargets(boolean special, boolean npc) { List possibleTargets = super.getPossibleTargets(npc); if (special) for (int[] element : PILLAR_SAFEZONE) { Tile tile = getManager().getTile(getReference(), element[0], element[1]); possibleTargets.removeIf(t -> t.getX() == tile.getX() && t.getY() == tile.getY()); } return possibleTargets; } public void sendBrokenFloor() { for (int[] element : BROKEN_FLOORS_TILES) { Tile tile = getManager().getTile(getReference(), element[0], element[1]); World.sendSpotAnim(tile, EARTH_QUAKE_GRAPHICS); } } public int getNextAttack() { return nextAttack; } public void increaseNextAttack(int nextAttack) { this.nextAttack += nextAttack; } public static boolean isBehindPillar(Player player, DungeonManager manager, RoomReference rRef) { for (int[] element : PILLAR_SAFEZONE) { Tile tile = manager.getTile(rRef, element[0], element[1]); if (player.getX() == tile.getX() && player.getY() == tile.getY()) return true; } return false; } }" "package com.rs.game.content.skills.dungeoneering.npcs.bosses; public class DungeonBoss extends DungeonNPC { private RoomReference reference; public DungeonBoss(int id, Tile tile, DungeonManager manager, RoomReference reference) { super(id, tile, manager); setReference(reference); resetBonuses(); setForceAgressive(true); setIntelligentRouteFinder(true); setLureDelay(3000); } @Override public void sendDeath(Entity source) { super.sendDeath(source); getManager().openStairs(getReference()); } @Override public void processNPC() { super.processNPC(); resetBonuses(); } @Override public void drop() { DropTable[] drops = DropSets.getDropSet(getId()).getTables(); if (drops == null || drops.length == 0) return; // TODO: Possible drop table mismatch with MEDIUM_DUNGEON? DropTable drop; if (getManager().getParty().getSize() == DungeonConstants.LARGE_DUNGEON) drop = drops[Utils.random(100) < 90 ? drops.length - 1 : Utils.random(drops.length)]; else if (getManager().getParty().getSize() == DungeonConstants.LARGE_DUNGEON) drop = drops[Utils.random(100) < 60 ? drops.length - 1 : Utils.random(drops.length)]; else drop = drops[Utils.random(drops.length)]; List players = getManager().getParty().getTeam(); if (players.isEmpty()) return; Player killer = players.get(Utils.random(players.size())); if (drop != null) for (Item item : drop.toItemArr()) sendDrop(killer, item); } @Override public void sendDrop(Player player, Item item) { List players = getManager().getParty().getTeam(); if (players.isEmpty()) return; player.getInventory().addItemDrop(item); player.sendMessage(""You received: "" + item.getAmount() + "" "" + item.getName() + "".""); for (Player p2 : players) { if (p2 == player) continue; p2.sendMessage("""" + player.getDisplayName() + "" received: "" + item.getAmount() + "" "" + item.getName() + "".""); } } public RoomReference getReference() { return reference; } public void setReference(RoomReference reference) { this.reference = reference; } }" "package com.rs.game.content.skills.dungeoneering.npcs.bosses.asteafrostweb; public final class AsteaFrostweb extends DungeonBoss { private final int meleeNPCId; private int switchPrayersDelay; private int spawnedSpiders; private final NPC[] spiders; public AsteaFrostweb(Tile tile, DungeonManager manager, RoomReference reference) { super(DungeonUtils.getClosestToCombatLevel(Utils.range(9965, 10021, 3), manager.getBossLevel()), tile, manager, reference); setHitpoints(getMaxHitpoints()); resetSwitchPrayersDelay(); this.spiders = new NPC[6]; this.meleeNPCId = getId(); } public void resetSwitchPrayersDelay() { switchPrayersDelay = Ticks.fromSeconds(25); } public void switchPrayers() { transformIntoNPC(getId() == meleeNPCId + 2 ? meleeNPCId : getId() + 1); } @Override public void processNPC() { super.processNPC(); if (isDead()) return; if (switchPrayersDelay > 0) switchPrayersDelay--; else { switchPrayers(); resetSwitchPrayersDelay(); } } @Override public void sendDeath(Entity source) { super.sendDeath(source); for (NPC minion : spiders) { if (minion == null) continue; minion.sendDeath(this); } } // max 6 spiders per fight public void spawnSpider() { if (spawnedSpiders >= spiders.length) return; // spawnedSpiders for (int tryI = 0; tryI < 10; tryI++) { Tile tile = Tile.of(getTile(), 2); if (World.floorAndWallsFree(tile, 1)) { NPC spider = spiders[spawnedSpiders++] = new NPC(64, tile, true); spider.setForceAgressive(true); break; } } } @Override public void handlePreHit(final Hit hit) { super.handlePreHit(hit); if (getId() == meleeNPCId) { if (hit.getLook() == HitLook.MELEE_DAMAGE) hit.setDamage(0); } else if (getId() == meleeNPCId + 1) { if (hit.getLook() == HitLook.MAGIC_DAMAGE) hit.setDamage(0); } else if (hit.getLook() == HitLook.RANGE_DAMAGE) hit.setDamage(0); } }" "package com.rs.game.content.skills.dungeoneering.npcs.bosses.asteafrostweb; public class AsteaFrostwebCombat extends CombatScript { @Override public Object[] getKeys() { return new Object[] { ""Astea Frostweb"" }; } @Override public int attack(final NPC npc, final Entity target) { final NPCCombatDefinitions defs = npc.getCombatDefinitions(); if (Utils.getRandomInclusive(10) == 0) { AsteaFrostweb boss = (AsteaFrostweb) npc; boss.spawnSpider(); } if (Utils.getRandomInclusive(10) == 0) { // spikes List possibleTargets = npc.getPossibleTargets(); npc.setNextAnimation(new Animation(defs.getAttackEmote())); for (Entity t : possibleTargets) delayHit(npc, 1, t, new Hit(npc, Utils.random((int) (npc.getLevelForStyle(AttackStyle.MAGE) * 0.5) + 1), HitLook.TRUE_DAMAGE)); return npc.getAttackSpeed(); } int attackStyle = Utils.random(2); if (attackStyle == 1) { if (Utils.getDistance(npc.getX(), npc.getY(), target.getX(), target.getY()) <= 1) { // melee npc.setNextAnimation(new Animation(defs.getAttackEmote())); delayHit(npc, 0, target, getMeleeHit(npc, getMaxHitFromAttackStyleLevel(npc, AttackStyle.MELEE, target))); return npc.getAttackSpeed(); } attackStyle = 0; } if (attackStyle == 0) { // mage npc.setNextAnimation(new Animation(defs.getAttackEmote())); List possibleTargets = npc.getPossibleTargets(); int d = getMaxHitFromAttackStyleLevel(npc, AttackStyle.MAGE, target); delayHit(npc, 1, target, getMagicHit(npc, d)); if (d != 0) { WorldTasks.delay(1, () -> { if (target.hasEffect(Effect.FREEZE)) target.setNextSpotAnim(new SpotAnim(1677, 0, 100)); else { target.setNextSpotAnim(new SpotAnim(369)); target.freeze(8); } }); for (final Entity t : possibleTargets) if (t != target && t.withinDistance(target.getTile(), 2)) { int damage = getMaxHitFromAttackStyleLevel(npc, AttackStyle.MAGE, t); delayHit(npc, 1, t, getMagicHit(npc, damage)); if (damage != 0) WorldTasks.delay(1, () -> { if (t.hasEffect(Effect.FREEZE)) t.setNextSpotAnim(new SpotAnim(1677, 0, 100)); else { t.setNextSpotAnim(new SpotAnim(369)); t.freeze(8); } }); } } if (Utils.getDistance(npc.getX(), npc.getY(), target.getX(), target.getY()) <= 1) { // lure // after // freeze npc.resetWalkSteps(); npc.addWalkSteps(target.getX() + Utils.random(3), target.getY() + Utils.random(3)); } } return npc.getAttackSpeed(); } }" "package com.rs.game.content.skills.dungeoneering.npcs.bosses.balak; public class BalLakThePummeler extends DungeonBoss { private boolean skip; private int barPercentage; private final List puddles = new CopyOnWriteArrayList<>(); public BalLakThePummeler(Tile tile, DungeonManager manager, RoomReference reference) { super(DungeonUtils.getClosestToCombatLevel(Utils.range(10128, 10141), manager.getBossLevel()), tile, manager, reference); setLureDelay(6000); // this way you can lure him hehe, still not as much as outside dung npcs setHitpoints(getMaxHitpoints()); } @Override public void processNPC() { if (isDead()) return; super.processNPC(); skip = !skip; if (!skip) { boolean reduced = false; for (PoisonPuddle puddle : puddles) { puddle.cycles++; if (puddle.canDestroyPoison()) { puddles.remove(puddle); continue; } List targets = getPossibleTargets(true); if (WorldUtil.collides(getX(), getY(), getSize(), puddle.tile.getX(), puddle.tile.getY(), 1)) { barPercentage = barPercentage > 1 ? barPercentage - 2 : 0; sendDefenceBar(); reduced = true; } for (Entity t : targets) { if (!t.withinDistance(puddle.tile, 1)) continue; t.applyHit(new Hit(this, Utils.random((int) (t.getHitpoints() * 0.25)) + 1, HitLook.TRUE_DAMAGE)); } } if (!reduced) if (!isUnderCombat()) { if (barPercentage > 0) { barPercentage--; sendDefenceBar(); } } else if (barPercentage < 100) { barPercentage++; sendDefenceBar(); } } } @Override public void processHit(Hit hit) { int damage = hit.getDamage(); HitLook look = hit.getLook(); if (damage > 0) if (look == HitLook.MELEE_DAMAGE || look == HitLook.RANGE_DAMAGE || look == HitLook.MAGIC_DAMAGE) { double multiplier = (100D - (barPercentage)) / 100D; hit.setDamage((int) (damage * multiplier)); } super.processHit(hit); } @Override public void sendDeath(Entity source) { super.sendDeath(source); puddles.clear(); sendDefenceBar(); } private void sendDefenceBar() { if (isDead()) getManager().hideBar(getReference()); else getManager().showBar(getReference(), ""Demon's Defence"", barPercentage); } private static class PoisonPuddle { final Tile tile; int cycles; public PoisonPuddle(Tile tile, int barPercentage) { this.tile = tile; } public boolean canDestroyPoison() { return cycles == 15; } } public void addPoisonBubble(Tile centerTile) { puddles.add(new PoisonPuddle(centerTile, barPercentage)); addPoisonBubbleSpotAnimations(centerTile); } private void addPoisonBubbleSpotAnimations(Tile centerTile) { World.sendSpotAnim(Tile.of(centerTile.getX(), centerTile.getY(), centerTile.getPlane()), new SpotAnim(2588)); World.sendSpotAnim(Tile.of(centerTile.getX()+1, centerTile.getY(), centerTile.getPlane()), new SpotAnim(2588)); World.sendSpotAnim(Tile.of(centerTile.getX(), centerTile.getY()+1, centerTile.getPlane()), new SpotAnim(2588)); World.sendSpotAnim(Tile.of(centerTile.getX()+1, centerTile.getY()+1, centerTile.getPlane()), new SpotAnim(2588)); World.sendSpotAnim(Tile.of(centerTile.getX()-1, centerTile.getY(), centerTile.getPlane()), new SpotAnim(2588)); World.sendSpotAnim(Tile.of(centerTile.getX(), centerTile.getY()-1, centerTile.getPlane()), new SpotAnim(2588)); World.sendSpotAnim(Tile.of(centerTile.getX()-1, centerTile.getY()-1, centerTile.getPlane()), new SpotAnim(2588)); World.sendSpotAnim(Tile.of(centerTile.getX()-1, centerTile.getY()+1, centerTile.getPlane()), new SpotAnim(2588)); World.sendSpotAnim(Tile.of(centerTile.getX()+1, centerTile.getY()-1, centerTile.getPlane()), new SpotAnim(2588)); } public List getPoisonPuddles() { return puddles; } }" "package com.rs.game.content.skills.dungeoneering.npcs.bosses.balak; public class BalLakThePummelerCombat extends CombatScript { @Override public Object[] getKeys() { return new Object[] { ""Bal'lak the Pummeller"" }; } @Override public int attack(NPC npc, Entity target) { final BalLakThePummeler boss = (BalLakThePummeler) npc; final DungeonManager manager = boss.getManager(); final NPCCombatDefinitions defs = npc.getCombatDefinitions(); boolean smash = Utils.random(5) == 0 && boss.getPoisonPuddles().size() == 0; for (Player player : manager.getParty().getTeam()) if (WorldUtil.collides(player.getX(), player.getY(), player.getSize(), npc.getX(), npc.getY(), npc.getSize())) { smash = true; delayHit(npc, 0, player, getRegularHit(npc, getMaxHitFromAttackStyleLevel(npc, AttackStyle.MELEE, player))); } if (smash) { npc.setNextAnimation(new Animation(14384)); npc.setNextForceTalk(new ForceTalk(""Rrrraargh!"")); //npc.playSoundEffect(3038); final Tile center = manager.getRoomCenterTile(boss.getReference()); WorldTasks.schedule(new Task() { @Override public void run() { for (int i = 0; i < 3; i++) boss.addPoisonBubble(World.getFreeTile(center, 6)); } }, 1); return npc.getAttackSpeed(); } if (Utils.random(5) == 0) { boss.setNextAnimation(new Animation(14383)); for (Entity t : boss.getPossibleTargets()) { if (!WorldUtil.isInRange(npc.getX(), npc.getY(), npc.getSize(), t.getX(), t.getY(), t.getSize(), 0)) continue; int damage = getMaxHitFromAttackStyleLevel(npc, AttackStyle.MELEE, t); int damage2 = getMaxHitFromAttackStyleLevel(npc, AttackStyle.MELEE, t); if (t instanceof Player player) if ((damage > 0 || damage2 > 0)) { player.setProtectionPrayBlock(2); player.sendMessage(""You are injured and currently cannot use protection prayers.""); } delayHit(npc, 0, t, getRegularHit(npc, damage)); delayHit(npc, 0, t, getRegularHit(npc, damage2)); } return npc.getAttackSpeed(); } switch (Utils.random(2)) { case 0://reg melee left final boolean firstHand = Utils.random(2) == 0; boss.setNextAnimation(new Animation(firstHand ? defs.getAttackEmote() : defs.getAttackEmote() + 1)); delayHit(npc, 0, target, getMeleeHit(npc, getMaxHit(npc, (int) (npc.getLevelForStyle(AttackStyle.MELEE) * 0.8), AttackStyle.MELEE, target))); delayHit(npc, 2, target, getMeleeHit(npc, getMaxHit(npc, (int) (npc.getLevelForStyle(AttackStyle.MELEE) * 0.8), AttackStyle.MELEE, target))); WorldTasks.schedule(new Task() { @Override public void run() { boss.setNextAnimation(new Animation(firstHand ? defs.getAttackEmote() + 1 : defs.getAttackEmote())); } }, 1); break; case 1://magic attack multi boss.setNextAnimation(new Animation(14380)); boss.setNextSpotAnim(new SpotAnim(2441)); for (Entity t : npc.getPossibleTargets()) { World.sendProjectile(npc, t, 2872, 50, 30, 41, 40, 0, 0); delayHit(npc, 1, t, getMagicHit(npc, getMaxHit(npc, (int) (boss.getMaxHit() * 0.6), AttackStyle.MAGE, t))); } return npc.getAttackSpeed() - 2; } return npc.getAttackSpeed(); } }" "package com.rs.game.content.skills.dungeoneering.npcs.bosses.blink; public class Blink extends DungeonBoss { private static final int[][] RUSH_COORDINATES = { { 2, 3, 13, 3 }, { 2, 6, 13, 6 }, { 2, 9, 13, 9 }, { 2, 12, 13, 12 }, { 3, 2, 3, 13 }, { 6, 2, 6, 13 }, { 9, 2, 9, 13 }, { 12, 2, 12, 13 }, }; // private static final int[] FAILURE_SOUNDS = new int[] { 3005, 3006, 3010, 3014, 3048, 2978 }; // private static final int[] RUSH_SOUNDS = { 2982, 2987, 2988, 2989, 2990, 2992, 2998, 3002, 3004, 3009, 3015, 3017, 3018, 3021, 3026, 3027, 3031, 3042, 3043, 3047, 3049 }; private static final String[] RUSH_MESSAGES = { ""Grrrr..."", ""More t...tea Alice?"", ""Where...who?"", ""H..here it comes!"", ""See you all next year!"", """", """", """", ""Coo-coo-ca-choo!"", ""Ah! Grrrr..."", ""Aha! Huh? Ahaha!"", """", """", ""A face! A huuuge face!"", ""Aaahaahaha!"", ""C...can't catch me!"", ""A whole new world!"", ""Over here!"", ""There's no place like home."", ""The...spire...doors...everywhere..."" }; private int rushCount, rushStage; private int[] selectedPath; private boolean inversedPath, specialRequired; private Tile toPath, activePillar; public Blink(Tile tile, DungeonManager manager, RoomReference reference) { super(DungeonUtils.getClosestToCombatLevel(Utils.range(12865, 12878), manager.getBossLevel()), tile, manager, reference); setForceFollowClose(true); setHitpoints(getMaxHitpoints()); setRun(true); rushCount = 0; rushStage = 4; } @Override public void processHit(Hit hit) { super.processHit(hit); if (getHitpoints() <= getMaxHitpoints() * (rushStage * .2125)) { rushStage--; rushCount = 0; } } @Override public double getMagePrayerMultiplier() { return 1.0; } @Override public double getRangePrayerMultiplier() { return 0.6; } @Override public double getMeleePrayerMultiplier() { return 0.8; } private void stopRushAttack() { rushCount = -1;//stops the rush //playSoundEffect(FAILURE_SOUNDS[Utils.random(FAILURE_SOUNDS.length)]); setNextForceTalk(new ForceTalk(""Oof!"")); setNextAnimation(new Animation(14946)); WorldTasks.schedule(new Task() { @Override public void run() { setSpecialRequired(true); setCantInteract(false); } }); } @Override public boolean canMove(Direction dir) { if (!hasActivePillar() || rushCount < 11) return true; int nextX = dir.dx + getX(); int nextY = dir.dy + getY(); if (nextX == activePillar.getX() && nextY == activePillar.getY()) { stopRushAttack(); return false; } return true; } @Override public void processNPC() { super.processNPC(); if (rushCount > -1) { if (getManager().isDestroyed() || isDead()) return; rushCount++; if (rushCount == 1) { resetWalkSteps(); setNextFaceEntity(null); resetCombat(); setCantInteract(true); } else if (rushCount == 3) setNextForceTalk(new ForceTalk(""He saw me!"")); //playSoundEffect(3017); else if (rushCount == 4) { setNextAnimation(new Animation(14994)); setNextSpotAnim(new SpotAnim(2868)); } else if (rushCount == 15 || rushCount == 5) { if (rushCount == 15) rushCount = 5; transformIntoNPC(1957); } else if (rushCount == 8) tele(getNextPath()); else if (rushCount == 9) { transformIntoNPC(12865); toPath = getManager().getTile(getReference(), selectedPath[inversedPath ? 2 : 0], selectedPath[inversedPath ? 3 : 1]); addWalkSteps(toPath.getX(), toPath.getY(), 1, false); } else if (rushCount == 10) { addWalkSteps(toPath.getX(), toPath.getY(), -1, false); int index = Utils.random(RUSH_MESSAGES.length); setNextForceTalk(new ForceTalk(RUSH_MESSAGES[index])); //playSoundEffect(RUSH_SOUNDS[index]); } else if (rushCount == 11) { setNextSpotAnim(new SpotAnim(2869)); for (Player player : getManager().getParty().getTeam()) { if (!getManager().getCurrentRoomReference(getTile()).equals(getManager().getCurrentRoomReference(player.getTile())) || !WorldUtil.isInRange(player.getX(), player.getY(), 1, getX(), getY(), 1, 4)) continue; int damage = Utils.random(200, 600); if (player.getPrayer().isProtectingMage() || player.getPrayer().isProtectingRange()) damage *= 0.5D; player.setNextSpotAnim(new SpotAnim(2854)); player.applyHit(new Hit(this, damage, HitLook.TRUE_DAMAGE, 35)); } } } } public Tile getNextPath() { selectedPath = RUSH_COORDINATES[Utils.random(RUSH_COORDINATES.length)]; inversedPath = Utils.random(2) == 0; return getManager().getTile(getReference(), selectedPath[inversedPath ? 0 : 2], selectedPath[inversedPath ? 1 : 3]); } public void raisePillar(GameObject selectedPillar) { final GameObject newPillar = new GameObject(selectedPillar); newPillar.setId(32196);//Our little secret :D activePillar = Tile.of(selectedPillar.getTile()); World.spawnObjectTemporary(newPillar, 4); WorldTasks.schedule(new Task() { @Override public void run() { activePillar = null; } }, 4); } public boolean hasActivePillar() { return activePillar != null; } public boolean isSpecialRequired() { return specialRequired; } public void setSpecialRequired(boolean specialRequired) { this.specialRequired = specialRequired; } }" "package com.rs.game.content.skills.dungeoneering.npcs.bosses.blink; public class BlinkCombat extends CombatScript { @Override public Object[] getKeys() { return new Object[] { ""Blink"" }; } @Override public int attack(NPC npc, Entity target) { final Blink boss = (Blink) npc; DungeonManager manager = boss.getManager(); if (Utils.random(10) == 0 || boss.isSpecialRequired()) { boss.setSpecialRequired(false); boss.setNextForceTalk(new ForceTalk(""H...Here it comes..."")); // boss.playSoundEffect(2989); WorldTasks.delay(5, () -> { boss.setNextAnimation(new Animation(14956)); boss.setNextForceTalk(new ForceTalk(""Kapow!!"")); // boss.playSoundEffect(3002); for (Entity t : boss.getPossibleTargets()) { if (t instanceof Player player) player.sendMessage(""You are hit by a powerful magical blast.""); t.setNextSpotAnim(new SpotAnim(2855, 0, 50)); delayHit(boss, 0, t, new Hit(boss, (int) Utils.random(boss.getMaxHit() * .6D, boss.getMaxHit()), HitLook.MAGIC_DAMAGE)); } }); return 8; } boolean atDistance = !WorldUtil.isInRange(npc.getX(), npc.getY(), npc.getSize(), target.getX(), target.getY(), target.getSize(), 0); if (!atDistance && (Utils.random(3) != 0)) { boss.setNextAnimation(new Animation(12310)); delayHit(boss, 0, target, getMeleeHit(boss, getMaxHit(boss, boss.getMaxHit(), AttackStyle.MELEE, target))); return 4; } boolean rangeAttack = Utils.random(3) == 0; if (rangeAttack) { if (manager.getParty().getTeam().size() > 1 || Utils.random(3) == 0) { Tile beginningTile = boss.getNextPath(); boss.setNextAnimation(new Animation(14949)); boss.resetCombat(); boss.setNextFaceEntity(null); boss.setNextFaceTile(beginningTile);// Faces the direction it throws into World.sendProjectile(boss, beginningTile, 2853, 18, 18, 50, 50, 0, 0); WorldTasks.scheduleLooping(new Task() { private List knifeTargets; private int cycles; @Override public void run() { cycles++; if (cycles == 1) { knifeTargets = new LinkedList<>(); for (Entity t : boss.getPossibleTargets()) { Tile center = Tile.of(t.getTile()); for (int i = 0; i < 3; i++) knifeTargets.add(i == 0 ? center : World.getFreeTile(center, 1)); } } else if (cycles == 2) { for (Tile tile : knifeTargets) { // outdated method projectile int delay = 3; for (Entity t : boss.getPossibleTargets()) { if (!t.matches(tile)) continue; delayHit(boss, delay, t, getRangeHit(boss, getMaxHit(boss, boss.getMaxHit(), AttackStyle.RANGE, t))); } } stop(); return; } } }, 0, 0); } else { boss.setNextAnimation(new Animation(14949)); World.sendProjectile(boss, target, 2853, 18, 18, 50, 50, 0, 0); delayHit(boss, 1, target, getRangeHit(boss, getMaxHit(boss, boss.getMaxHit(), AttackStyle.RANGE, target))); } } else { if (Utils.random(7) == 0) boss.setNextForceTalk(new ForceTalk(""Magicinyaface!"")); // boss.playSoundEffect(3022); //MAGIC IN YA FACE boss.setNextAnimation(new Animation(14956)); boss.setNextSpotAnim(new SpotAnim(2854)); target.setNextSpotAnim(new SpotAnim(2854, 5, 0)); int damage = getMaxHit(boss, boss.getMaxHit(), AttackStyle.MAGE, target); if (target instanceof Player player) if (player.getPrayer().isProtectingMage()) damage *= 0.5D; delayHit(boss, 1, target, getMagicHit(boss, damage)); } return 5; } }" "package com.rs.game.content.skills.dungeoneering.npcs.bosses.bulwark; public final class BulwarkBeast extends DungeonBoss { private int shieldHP; private final int maxShieldHP; public BulwarkBeast(Tile tile, DungeonManager manager, RoomReference reference) { super(DungeonUtils.getClosestToCombatLevel(Utils.range(10073, 10106, 2), manager.getBossLevel()), tile, manager, reference); maxShieldHP = shieldHP = 500; setHitpoints(getMaxHitpoints()); } @Override public void handlePreHit(final Hit hit) { handleHit(hit); super.handlePreHit(hit); } public void handleHit(Hit hit) { if (shieldHP <= 0 || hit.getLook() == HitLook.MAGIC_DAMAGE) return; hit.setDamage(0); Entity source = hit.getSource(); if (!(source instanceof Player playerSource) || (hit.getLook() != HitLook.MELEE_DAMAGE)) return; int weaponId = playerSource.getEquipment().getWeaponId(); if (weaponId != -1 && DungPickaxe.getBest(playerSource) != null) { hit.setDamage(Utils.random(50)); hit.addSoaking(hit.getDamage()); shieldHP -= hit.getDamage(); playerSource.sendMessage(shieldHP > 0 ? ""Your pickaxe chips away at the beast's armour plates."" : ""Your pickaxe finally breaks through the heavy armour plates.""); refreshBar(); } } public int getShieldHP() { return shieldHP; } public void setShieldHP(int shieldHP) { this.shieldHP = shieldHP; } public boolean hasShield() { return shieldHP > 0 && !isDead() && !hasFinished(); } @Override public void sendDeath(Entity source) { super.sendDeath(source); refreshBar(); } public void refreshBar() { if (hasShield()) getManager().showBar(getReference(), ""Bulwark Beast's Armour"", shieldHP * 100 / maxShieldHP); else getManager().hideBar(getReference()); } }" "package com.rs.game.content.skills.dungeoneering.npcs.bosses.bulwark; public class BulwarkBeastCombat extends CombatScript { @Override public Object[] getKeys() { return new Object[] { ""Bulwark beast"" }; } @Override public int attack(final NPC npc, final Entity target) { final BulwarkBeast beast = (BulwarkBeast) npc; beast.refreshBar(); final NPCCombatDefinitions defs = npc.getCombatDefinitions(); if (Utils.random(15) == 0) { List targets = npc.getPossibleTargets(); npc.setNextAnimation(new Animation(13007)); for (Entity t : targets) if (WorldUtil.isInRange(t.getX(), t.getY(), t.getSize(), npc.getX(), npc.getY(), npc.getSize(), 0)) { t.setNextSpotAnim(new SpotAnim(2400)); delayHit(npc, 1, t, getRegularHit(npc, 1 + Utils.random((int) (npc.getLevelForStyle(AttackStyle.MELEE) * 0.7)))); } return npc.getAttackSpeed(); } // mage, range, melee int attackStyle = Utils.random(WorldUtil.isInRange(target.getX(), target.getY(), target.getSize(), npc.getX(), npc.getY(), npc.getSize(), 0) ? 3 : 2); switch (attackStyle) { case 0 -> { npc.sync(13004, 2397); NPCCombatUtil.projectileBounce(npc, target, new HashSet<>(Set.of(target)), 2398, 2399, 1.8, null, nextTarget -> delayHit(npc, 0, nextTarget, getMagicHit(npc, getMaxHit(npc, npc.getMaxHit(), NPCCombatDefinitions.AttackStyle.MAGE, nextTarget)))); } case 1 -> { npc.setNextAnimation(new Animation(13006)); npc.setNextSpotAnim(new SpotAnim(2394)); List targets = npc.getPossibleTargets(); for (Entity t : targets) { World.sendProjectile(npc, t, 2395, 35, 30, 41, 40, 0, 0); t.setNextSpotAnim(new SpotAnim(2396, 75, 0)); delayHit(npc, 1, t, getRangeHit(npc, getMaxHitFromAttackStyleLevel(npc, AttackStyle.RANGE, t))); } } case 2 -> { npc.setNextAnimation(new Animation(defs.getAttackEmote())); delayHit(npc, 0, target, getMeleeHit(npc, getMaxHitFromAttackStyleLevel(npc, AttackStyle.MELEE, target))); } } return npc.getAttackSpeed(); } }" "package com.rs.game.content.skills.dungeoneering.npcs.combat; public class LexicusRunewrightCombat extends CombatScript { @Override public Object[] getKeys() { return new Object[] { ""Lexicus Runewright"" }; } @Override public int attack(NPC npc, Entity target) { LexicusRunewright boss = (LexicusRunewright) npc; if (boss.getAttackStage() == 0) { boss.sendAlmanacArmyAttack(target); boss.incrementAttackStage(); return 3; } if (boss.getAttackStage() == 1 && Utils.random(4) == 0) { sendBookBarrage(boss); boss.incrementAttackStage(); return 5; } if (boss.getAttackStage() == 2 && Utils.random(4) == 0) { boss.sendTeleport(); boss.resetAttackStage(); return 9; } int attack = Utils.random(WorldUtil.isInRange(target.getX(), target.getY(), target.getSize(), npc.getX(), npc.getY(), npc.getSize(), 0) ? 5 : 4); switch (attack) { case 0:// Range case 1: case 2: case 3:// Magic boolean range_style = attack == 0 || attack == 1; boss.setNextAnimation(new Animation(13470)); boss.setNextSpotAnim(new SpotAnim(range_style ? 2408 : 2424)); World.sendProjectile(npc, target, range_style ? 2409 : 2425, 40, 40, 54, 35, 5, 0); if (range_style) delayHit(npc, 1, target, getRangeHit(npc, getMaxHitFromAttackStyleLevel(npc, AttackStyle.RANGE, target))); else delayHit(npc, 1, target, getMagicHit(npc, getMaxHitFromAttackStyleLevel(npc, AttackStyle.MAGE, target))); target.setNextSpotAnim(new SpotAnim(range_style ? 2410 : 2426, 75, 0)); break; case 4:// MELEE boss.setNextAnimation(new Animation(13469)); delayHit(npc, 0, target, getMeleeHit(npc, getMaxHitFromAttackStyleLevel(npc, AttackStyle.MELEE, target))); break; } return 5; } public static void sendBookBarrage(final LexicusRunewright npc) { final List cases = new ArrayList<>(); for (int x = 0; x < 16; x++) for (int y = 0; y < 16; y++) { GameObject o = npc.getManager().getObjectWithType(npc.getReference(), ObjectType.SCENERY_INTERACT, x, y); if (o != null && o.getId() >= 49280 && o.getId() <= 49282) cases.add(o); } npc.setNextForceTalk(new ForceTalk(""Book barrage!"")); WorldTasks.scheduleLooping(new Task() { private int cycle = 0; private final LinkedList targets = new LinkedList<>(); @Override public void run() { cycle++; if (npc.isDead()) { stop(); return; } if (cycle == 1) for (Entity entity : npc.getPossibleTargets(true)) { if (entity instanceof DungeonNPC) continue; Tile tile = Tile.of(entity.getTile()); targets.add(tile); for (int i = 0; i < 3; i++) { if (cases.isEmpty()) break; GameObject c = cases.get(Utils.random(cases.size())); cases.remove(c); World.sendProjectile(c, tile, 2422, 60, 75, 30, 0, 0, 0); } } else if (cycle == 4) { for (Tile tile : targets) World.sendSpotAnim(tile, new SpotAnim(2423)); for (Entity entity : npc.getPossibleTargets(true)) { if (entity instanceof DungeonNPC) continue; for (Tile tile : targets) { if (entity.getX() != tile.getX() || entity.getY() != tile.getY()) continue; entity.applyHit(new Hit(npc, (int) (entity instanceof Familiar ? 1000 : Utils.random(entity.getMaxHitpoints() * .6, entity.getMaxHitpoints() * .9)), HitLook.TRUE_DAMAGE)); } } targets.clear(); stop(); } } }, 0, 0); // GFX 2421+ } }" "package com.rs.game.content.skills.dungeoneering.npcs.combat; public class AnimatedBookCombat extends CombatScript { @Override public Object[] getKeys() { return new Object[] { ""Animated book"" }; } @Override public int attack(NPC npc, Entity target) { boolean meleeAttack = Utils.random(2) == 0; if (!meleeAttack || !WorldUtil.isInRange(npc.getX(), npc.getY(), npc.getSize(), target.getX(), target.getY(), target.getSize(), 0)) { magicAttack(npc, target); return npc.getAttackSpeed(); } meleeAttack(npc, target); return npc.getAttackSpeed(); } private void meleeAttack(NPC npc, Entity target) { npc.setNextAnimation(new Animation(13479)); delayHit(npc, 0, target, getMeleeHit(npc, getMaxHit(npc, 100, AttackStyle.MELEE, target))); } private void magicAttack(NPC npc, final Entity target) { npc.setNextAnimation(new Animation(13480)); npc.setNextSpotAnim(new SpotAnim(2728)); delayHit(npc, 1, target, getMagicHit(npc, getMaxHit(npc, 100, AttackStyle.MAGE, target))); World.sendProjectile(npc, target, 2731, 34, 16, 30, 35, 16, 0); WorldTasks.schedule(new Task() { @Override public void run() { target.setNextSpotAnim(new SpotAnim(2738, 0, 80)); } }, 2); } }" "package com.rs.game.content.skills.dungeoneering.npcs.combat; public class AntiSilkHoodMages extends CombatScript {//default combat script @Override public Object[] getKeys() { return Stream.concat(Arrays.stream(NECROMANCER.getNPCIds()).boxed(), Arrays.stream(REBORN_MAGE.getNPCIds()).boxed()).toArray(Object[]::new); } @Override public int attack(NPC npc, Entity target) { if(target instanceof Player player && player.getEquipment().containsOneItem(17279, 15828) && !player.getTempAttribs().getB(""ShadowSilkSpellDisable"")){ sendAntiSilkHoodSpell(npc, player); return 5;//delay 5 ticks for spell } return CombatScriptsHandler.getDefaultCombat().apply(npc, target); } private void sendAntiSilkHoodSpell(NPC npc, final Player player) { int animation = 6293; if(Arrays.stream(REBORN_MAGE.getNPCIds()).anyMatch(i -> i == npc.getId())) animation = 11130; npc.sync(animation, 1059); WorldTasks.scheduleTimer(2, (ticks) -> { player.setNextSpotAnim(new SpotAnim(736, 0, 50)); player.getTempAttribs().setB(""ShadowSilkSpellDisable"", true); player.sendMessage(""Your shadow silk hood loses its power...""); WorldTasks.delay(Ticks.fromMinutes(2), () -> { if(player.hasStarted()) { if(player.getTempAttribs().getB(""ShadowSilkSpellDisable"")) player.sendMessage(""Your shadow silk hood returns its power...""); player.getTempAttribs().setB(""ShadowSilkSpellDisable"", false); } }); return false; }); } }" "package com.rs.game.content.skills.dungeoneering.npcs.combat; public class DreadnautCombat extends CombatScript { @Override public Object[] getKeys() { return new Object[] { ""Dreadnaut"" };// GFX 2859 Poop bubbles that drain prayer } @Override public int attack(NPC npc, Entity target) { Dreadnaut boss = (Dreadnaut) npc; if (!WorldUtil.isInRange(npc.getX(), npc.getY(), npc.getSize(), target.getX(), target.getY(), target.getSize(), 0)) return 0; if (Utils.random(5) == 0) { npc.setNextAnimation(new Animation(14982)); npc.setNextSpotAnim(new SpotAnim(2865)); int damage = getMaxHit(boss, boss.getMaxHit(), AttackStyle.MELEE, target); if (damage > 0) { target.setNextSpotAnim(new SpotAnim(2866, 75, 0)); sendReductionEffect(boss, target, damage); } if (target instanceof Player player) { player.sendMessage(""You have been injured and are unable to use protection prayers.""); player.setProtectionPrayBlock(12); } delayHit(npc, 1, target, getMeleeHit(npc, damage)); } else { npc.setNextAnimation(new Animation(14973)); npc.setNextSpotAnim(new SpotAnim(2856)); for (Entity t : boss.getPossibleTargets()) { if (!t.withinDistance(target.getTile(), 2)) continue; int damage = getMaxHit(boss, boss.getMaxHit(), AttackStyle.MELEE, t); World.sendProjectile(boss, t, 2857, 30, 30, 25, 35, 15, 1); if (damage > 0) { sendReductionEffect(boss, t, damage); boss.addSpot(Tile.of(t.getTile())); } else t.setNextSpotAnim(new SpotAnim(2858, 75, 0)); delayHit(npc, 1, t, getMeleeHit(npc, damage)); } } return 5; } private void sendReductionEffect(Dreadnaut boss, Entity target, int damage) { if (!boss.canReduceMagicLevel() || !(target instanceof Player player)) return; player.getSkills().set(Constants.MAGIC, (int) (player.getSkills().getLevel(Constants.MAGIC) - (damage * .10))); } }" "package com.rs.game.content.skills.dungeoneering.npcs.combat; public class FamishedEyeCombat extends CombatScript { @Override public Object[] getKeys() { return new Object[] { ""Famished warrior-eye"", ""Famished ranger-eye"", ""Famished mage-eye"" }; } @Override public int attack(NPC npc, final Entity target) { final FamishedEye eye = (FamishedEye) npc; if (eye.isInactive()) return 0; if (!eye.isFirstHit()) { eye.setFirstHit(true); return Utils.random(5, 15); } npc.setNextAnimation(new Animation(14916)); WorldTasks.scheduleLooping(new Task() { private List tiles; private Tile targetTile; int cycles; @Override public void run() { cycles++; if (cycles == 1) { tiles = new LinkedList<>(); targetTile = Tile.of(target.getTile()); World.sendProjectile(eye, targetTile, 2849, 35, 30, 41, 0, 15, 0); } else if (cycles == 2) for (int x = -1; x < 2; x++) for (int y = -1; y < 2; y++) { Tile attackedTile = targetTile.transform(x, y, 0); if (x != y) World.sendProjectile(targetTile, attackedTile, 2851, 35, 0, 26, 40, 16, 0); tiles.add(attackedTile); } else if (cycles == 3) { for (Tile tile : tiles) { if (!tile.matches(targetTile)) World.sendSpotAnim(tile, new SpotAnim(2852, 35, 5)); for (Entity t : eye.getPossibleTargets()) if (t.matches(tile)) t.applyHit(new Hit(eye, (int) Utils.random(eye.getMaxHit() * .25, eye.getMaxHit()), HitLook.TRUE_DAMAGE)); } tiles.clear(); stop(); } } }, 0, 0); return Utils.random(5, 35); } }" "package com.rs.game.content.skills.dungeoneering.npcs.combat; public class FleshspoilerHaasghenahkCombat extends CombatScript { @Override public Object[] getKeys() { return new Object[] { ""Flesh-Spoiler Haasghenahk"" }; } @Override public int attack(NPC npc, Entity target) { final FleshspoilerHaasghenahk boss = (FleshspoilerHaasghenahk) npc; for (Entity t : npc.getPossibleTargets()) if (WorldUtil.collides(t.getX(), t.getY(), t.getSize(), npc.getX(), npc.getY(), npc.getSize())) delayHit(npc, 0, t, getRegularHit(npc, getMaxHitFromAttackStyleLevel(npc, AttackStyle.MELEE, t))); if (boss.isSecondStage()) return 0; boolean magicOnly = boss.canUseMagicOnly(); if (magicOnly || Utils.random(5) == 0) { if (magicOnly) if (target instanceof Player player) if (player.getPrayer().isProtectingMage() && Utils.random(3) == 0) boss.setUseMagicOnly(false); npc.setNextAnimation(new Animation(14463)); delayHit(npc, 1, target, getMagicHit(npc, getMaxHitFromAttackStyleLevel(npc, AttackStyle.MAGE, target))); } else { npc.setNextAnimation(new Animation(13320)); delayHit(npc, 0, target, getMeleeHit(npc, getMaxHitFromAttackStyleLevel(npc, AttackStyle.MELEE, target))); } return 6; } }" "package com.rs.game.content.skills.dungeoneering.npcs.combat; public class FleshSpoilerSpawnCombat extends CombatScript { @Override public Object[] getKeys() { return new Object[] { ""Flesh-Spoiler spawn"" }; } @Override public int attack(NPC npc, Entity target) { npc.setNextAnimation(new Animation(Utils.random(3) == 0 ? 14474 : 14475)); delayHit(npc, 0, target, getMeleeHit(npc, getMaxHitFromAttackStyleLevel(npc, AttackStyle.MELEE, target))); return 3; } }" "package com.rs.game.content.skills.dungeoneering.npcs.combat; public class ForgottenMage extends CombatScript { private static final int[][] ATTACK_TYPES = { { 0, 9, 10 }, { 10, 11, 0, 12, 1 }, { 12, 13, 0, 1, 3, 2, 14 }, { 14, 15, 0, 3, 16 }, { 17, 18, 0, 1, 2, 3, 19 }, { 20, 21, 0, 1, 2, 22, 4 }, { 22, 23, 0, 1, 4, 6, 24 }, { 24, 25, 0, 6, 7, 5, 26 }, { 26, 27, 6, 7, 8, 5, 28 }, { 28, 29, 6, 7, 8, 5, 30 }, { 30, 6, 7, 8, 5 }, }; private static final int[] ATTACK_ANIMATIONS = { 711, 716, 724, 710, 710, 710, 729, 729, 729, 14221, 14222, 14221, 14221, 14220, 14220, 14222, 14223, 14221, 14220, 14222, 14223, 14221, 14220, 14222, 14223, 10546, 10542, 14209, 2791 }; private static final int[] START_GRAPHICS = { 102, 105, 108, 177, 177, 177, 167, 170, 173, -1, 2701, 2713, 2728, -1, 2707, 2709, 2714, 2728, -1, 2701, 2715, 2728, -1, 2702, 2716, 2728, 457, 2701, 2717, 2728 }; private static final int[] HIT_GRAPHICS = { 104, 107, 110, 181, 180, 179, 169, 172, 107, 2700, 2708, 2723, 2737, 2700, 2704, 2724, 2738, 2700, 2710, 2725, 2739, 2700, 2710, 2726, 2740, 2700, 2712, 2727, 2741 }; private static final int[] PROJECTILES = { 103, 106, 109, 178, 178, 178, 168, 171, 174, 2699, 2703, 2718, 2729, 2699, 2704, 2719, 2731, 2699, 2705, 2720, 2733, 2699, 2706, 2721, 2735, 462, 2707, 2722, -1 }; private static final int[] SKILLS = { Constants.ATTACK, Constants.STRENGTH, Constants.DEFENSE, 0, 1, 2, Constants.DEFENSE, Constants.STRENGTH, Constants.ATTACK }; @Override public Object[] getKeys() { return new Object[] { ""Forgotten mage"" }; } @Override public int attack(NPC npc, Entity target) { int TIER = npc instanceof YkLagorMage ? 3 : npc instanceof SkeletalAdventurer ? 8 : npc.getId() == 10560 ? 0 : ((npc.getId() - 10560) / 5) - 1; if (TIER < 0) TIER = 0; final int[] POSSIBLE_ATTACKS = ATTACK_TYPES[TIER]; int attack = POSSIBLE_ATTACKS[Utils.random(POSSIBLE_ATTACKS.length)]; if ((npc instanceof YkLagorMage || npc instanceof SkeletalAdventurer) && attack <= 8) return 0; if(!(npc instanceof YkLagorMage || npc instanceof SkeletalAdventurer) && target instanceof Player player && player.getEquipment().containsOneItem(17279, 15828) && !player.getTempAttribs().getB(""ShadowSilkSpellDisable"")) { sendAntiSilkHoodSpell(npc, player); return 5; } if (attack >= 0 && attack <= 8) { double drainRate = attack < 2 ? .95 : attack > 6 ? .90 : 0.0; sendWeaken(npc, target, ATTACK_ANIMATIONS[attack], START_GRAPHICS[attack], HIT_GRAPHICS[attack], PROJECTILES[attack], SKILLS[attack], drainRate); } else sendCombatSpell(npc, target, ATTACK_ANIMATIONS[attack], START_GRAPHICS[attack], HIT_GRAPHICS[attack], PROJECTILES[attack]); return 5; } private void sendCombatSpell(NPC npc, final Entity target, int attack, int start, final int hit, int projectileId) { npc.setNextAnimation(new Animation(attack)); if (start != -1) npc.setNextSpotAnim(new SpotAnim(start, 0, 0)); if (attack == 2722) { World.sendProjectile(npc, target, 2735, 18, 18, 50, 1, 3, 0); World.sendProjectile(npc, target, 2736, 18, 18, 50, 1, 20, 0); World.sendProjectile(npc, target, 2736, 18, 18, 50, 1, 110, 0); } else World.sendProjectile(npc, target, projectileId, 18, 18, 50, 1, 3, 0); delayHit(npc, 2, target, getMagicHit(npc, getMaxHit(npc, npc.getMaxHit(), AttackStyle.MAGE, target))); if (hit == -1) return; WorldTasks.schedule(2, () -> target.setNextSpotAnim(new SpotAnim(hit, 0, 85))); } private void sendWeaken(NPC npc, final Entity target, int attack, int start, final int hit, int projectileId, final int skill, final double percentDrain) { npc.setNextAnimation(new Animation(attack)); npc.setNextSpotAnim(new SpotAnim(start, 0, 50)); World.sendProjectile(npc, target, projectileId, 39, 18, 55, 1.2, 5, 0); if (hit > 0) { WorldTasks.scheduleTimer(2, (ticks) -> { if (target instanceof Player player) if (percentDrain == 0) player.freeze(skill == 0 ? 8 : skill == 1 ? 12 : 16, true); else if(player.getSkills().getLevel(skill) > player.getSkills().getLevelForXp(skill)*0.93) player.getSkills().set(skill, (int) (player.getSkills().getLevel(skill) * percentDrain)); return false; }); target.setNextSpotAnim(new SpotAnim(hit, 140, 85)); } } private void sendAntiSilkHoodSpell(NPC npc, final Player player) { npc.setNextAnimation(new Animation(6293)); npc.setNextSpotAnim(new SpotAnim(1059)); WorldTasks.scheduleTimer(2, (ticks) -> { player.setNextSpotAnim(new SpotAnim(736, 0, 50)); player.getTempAttribs().setB(""ShadowSilkSpellDisable"", true); player.sendMessage(""Your shadow silk hood loses its power...""); WorldTasks.delay(Ticks.fromMinutes(2), () -> { if(player.hasStarted()) { if(player.getTempAttribs().getB(""ShadowSilkSpellDisable"")) player.sendMessage(""Your shadow silk hood returns its power...""); player.getTempAttribs().setB(""ShadowSilkSpellDisable"", false); } }); return false; }); } }" "package com.rs.game.content.skills.dungeoneering.npcs.combat; public class GeomancerCombat extends CombatScript { @Override public Object[] getKeys() { return new Object[] { ""Hobgoblin Geomancer"" }; } @Override public int attack(NPC npc, Entity target) { HobgoblinGeomancer boss = (HobgoblinGeomancer) npc; boolean atDistance = !WorldUtil.isInRange(npc.getX(), npc.getY(), npc.getSize(), target.getX(), target.getY(), target.getSize(), 0); if (Utils.random(boss.getManager().getParty().getTeam().size() > 1 ? 6 : 8) == 0 && !boss.isCantInteract()) { Tile tile = Tile.of(target.getTile()); DungeonManager dungeon = boss.getManager(); RoomReference rRef = dungeon.getCurrentRoomReference(tile); Room room = dungeon.getRoom(rRef); if (room != null && room.getRoom() == DungeonUtils.getBossRoomWithChunk(DungeonConstants.ABANDONED_FLOORS, 24, 640)) { sendEntangle(npc, target); boss.sendTeleport(tile, rRef); } return 7; } int attackType = Utils.random(6); switch (attackType) { // MELEE case 0 -> { if (atDistance) { sendEarthBlast(npc, target, true); } else { npc.setNextAnimation(new Animation(12989)); delayHit(npc, 0, target, getMeleeHit(npc, getMaxHitFromAttackStyleLevel(npc, AttackStyle.MELEE, target))); } } // EARTH BLAST case 1, 2 -> sendEarthBlast(npc, target, attackType == 2); // WEAKEN case 3 -> sendWeaken(npc, target); // SNARE case 4 -> sendEntangle(npc, target); case 5 -> sendPrayerSpell(npc); } return 4; } private void sendEarthBlast(NPC npc, Entity target, boolean multiAttack) { npc.setNextSpotAnim(new SpotAnim(2715)); npc.setNextAnimation(new Animation(12990)); for (Entity t : npc.getPossibleTargets()) { if (!multiAttack && t.getIndex() != target.getIndex()) continue; t.setNextSpotAnim(new SpotAnim(2726, 75, 100)); World.sendProjectile(npc, t, 2720, 50, 18, 50, 50, 0, 0); delayHit(npc, 1, t, getMagicHit(npc, getMaxHit(npc, (int) (npc.getLevelForStyle(AttackStyle.MAGE) * .7), AttackStyle.MAGE, t))); } } private void sendEntangle(NPC npc, Entity target) { npc.setNextSpotAnim(new SpotAnim(177, 0, 50)); npc.setNextAnimation(new Animation(12992)); npc.removeTarget(); World.sendProjectile(npc, target, 178, 40, 18, 55, 70, 5, 0); int damage = getMaxHit(npc, (int) (npc.getLevelForStyle(AttackStyle.MAGE) * 0.95), AttackStyle.MAGE, target); if (damage > 0) { target.setNextSpotAnim(new SpotAnim(180, 75, 100)); // if (!target.isBoundImmune()) { // target.setBoundDelay(20, false, 7); target.freeze(20); // } if (target instanceof Player player) player.getActionManager().setActionDelay(4); } } private void sendWeaken(NPC npc, Entity target) { npc.setNextSpotAnim(new SpotAnim(105, 0, 60)); npc.setNextAnimation(new Animation(12992)); World.sendProjectile(npc, target, 106, 40, 18, 55, 70, 5, 0); int damage = getMaxHitFromAttackStyleLevel(npc, AttackStyle.MAGE, target); if (damage > 0) { target.setNextSpotAnim(new SpotAnim(107, 75, 150)); if (target instanceof Player player) { for (int skill = 0; skill < Constants.MAGIC; skill++) { if (skill == 3 || skill == 5) continue; player.getSkills().set(skill, (int) (player.getSkills().getLevel(skill) * .95)); } player.sendMessage(""Your stats have been significantly lowered.""); } } } private void sendPrayerSpell(NPC npc) { npc.setNextAnimation(new Animation(12988)); npc.setNextSpotAnim(new SpotAnim(2147)); boolean hasDrained = false; for (Entity t : npc.getPossibleTargets()) { int damage = getMaxHitFromAttackStyleLevel(npc, AttackStyle.MAGE, t); if (damage > 0) if (t instanceof Player player) if (player.getPrayer().hasPrayersOn()) { if (!hasDrained) { int prayerPoints = (int) player.getPrayer().getPoints(); npc.setNextSpotAnim(new SpotAnim(2369, 70, 0)); if (prayerPoints > 0) { npc.heal(prayerPoints); hasDrained = true; } } player.getPrayer().drainPrayer(); player.getPrayer().closeAllPrayers(); player.sendMessage(""Your prayers have been disabled.""); } delayHit(npc, 1, t, getMagicHit(npc, (int) (damage * .50))); t.setNextSpotAnim(new SpotAnim(2147)); World.sendProjectile(npc, t, 2368, 50, 18, 55, 70, 5, 0); } } }" "package com.rs.game.content.skills.dungeoneering.npcs.combat; public class GluttonousBehemothCombat extends CombatScript { @Override public Object[] getKeys() { return new Object[] { ""Gluttonous behemoth"" }; } @Override public int attack(final NPC npc, final Entity target) { final NPCCombatDefinitions defs = npc.getCombatDefinitions(); DungeonBoss boss = (DungeonBoss) npc; DungeonManager manager = boss.getManager(); boolean lessThanHalf = npc.getHitpoints() < npc.getMaxHitpoints() * .5; if (lessThanHalf && !npc.getTempAttribs().getB(""GLUTTONOUS_HEALING"")) { RoomReference reference = manager.getCurrentRoomReference(npc.getTile()); GameObject food1 = manager.getObject(reference, 49283, 0, 11); GameObject food2 = manager.getParty().getTeam().size() <= 1 ? null : manager.getObject(reference, 49283, 11, 11); GameObject food = food1; if (food1 != null) for (Player player : manager.getParty().getTeam()) if (player.withinDistance(food1.getTile(), food1.getDefinitions().getSizeX() + 1)) { food = null; break; } if (food == null && food2 != null) { food = food2; for (Player player : manager.getParty().getTeam()) if (player.withinDistance(food2.getTile(), food1.getDefinitions().getSizeX() + 1)) { food = null; break; } } if (food != null) { npc.getTempAttribs().setB(""GLUTTONOUS_HEALING"", true); ((GluttonousBehemoth) npc).setHeal(food); return 0; } } boolean stomp = false; for (Player player : manager.getParty().getTeam()) if (WorldUtil.collides(player.getX(), player.getY(), player.getSize(), npc.getX(), npc.getY(), npc.getSize())) { stomp = true; delayHit(npc, 0, player, getRegularHit(npc, getMaxHitFromAttackStyleLevel(npc, AttackStyle.MELEE, player))); } if (stomp) { npc.setNextAnimation(new Animation(13718)); return npc.getAttackSpeed(); } int attackStyle = Utils.getRandomInclusive(2); if (attackStyle == 2) { if (WorldUtil.isInRange(npc.getX(), npc.getY(), npc.getSize(), target.getX(), target.getY(), target.getSize(), 0)) { npc.setNextAnimation(new Animation(defs.getAttackEmote())); delayHit(npc, 0, target, getMeleeHit(npc, getMaxHitFromAttackStyleLevel(npc, AttackStyle.MELEE, target))); return npc.getAttackSpeed(); } attackStyle = Utils.getRandomInclusive(1); } if (attackStyle == 0) { npc.setNextAnimation(new Animation(13719)); World.sendProjectile(npc, target, 2612, 41, 16, 41, 35, 16, 0); int damage = getMaxHitFromAttackStyleLevel(npc, AttackStyle.MAGE, target); delayHit(npc, 2, target, getMagicHit(npc, damage)); if (damage != 0) WorldTasks.schedule(new Task() { @Override public void run() { target.setNextSpotAnim(new SpotAnim(2613)); } }, 1); } else if (attackStyle == 1) { npc.setNextAnimation(new Animation(13721)); World.sendProjectile(npc, target, 2610, 41, 16, 41, 35, 16, 0); delayHit(npc, 2, target, getRangeHit(npc, getMaxHitFromAttackStyleLevel(npc, AttackStyle.RANGE, target))); WorldTasks.schedule(new Task() { @Override public void run() { target.setNextSpotAnim(new SpotAnim(2611)); } }, 1); } return npc.getAttackSpeed(); } }" "package com.rs.game.content.skills.dungeoneering.npcs.combat; public class GravecreeperCombat extends CombatScript { @Override public Object[] getKeys() { return new Object[] { ""Gravecreeper"" }; } @Override public int attack(NPC npc, Entity target) { final Gravecreeper boss = (Gravecreeper) npc; if (boss.getSpecialDelay() != -2 && (boss.getSpecialDelay() == -1 || (Utils.random(10) == 0 && boss.getSpecialDelay() <= World.getServerTicks()))) { if ((boss.getSpecialDelay() == -1) || (Utils.random(5) == 0)) { boss.useSpecial(); return 4; } boss.setNextForceTalk(new ForceTalk(""Burrnnn!"")); WorldTasks.scheduleTimer(1, (ticks) -> { boss.createBurnTiles(Tile.of(boss.getTile())); return false; }); boss.setSpecialDelay(World.getServerTicks() + Gravecreeper.BURN_DELAY); if (WorldUtil.isInRange(npc.getX(), npc.getY(), npc.getSize(), target.getX(), target.getY(), target.getSize(), 0)) { boss.setForceFollowClose(true); WorldTasks.scheduleTimer(7, (ticks) -> { boss.setForceFollowClose(false); return false; }); } return 4; } boolean atDistance = !WorldUtil.isInRange(npc.getX(), npc.getY(), npc.getSize(), target.getX(), target.getY(), target.getSize(), 0); int attack = Utils.random(!atDistance ? 2 : 1); switch (attack) { case 0:// range npc.setNextAnimation(new Animation(14504)); World.sendProjectile(npc, target, 2753, 65, 65, 30, 0, 0, 0); delayHit(npc, 1, target, getRangeHit(npc, getMaxHitFromAttackStyleLevel(npc, AttackStyle.RANGE, target))); break; case 1:// melee npc.setNextAnimation(new Animation(14503)); delayHit(npc, 0, target, getMeleeHit(npc, getMaxHitFromAttackStyleLevel(npc, AttackStyle.MELEE, target))); break; } return 4; } }" "package com.rs.game.content.skills.dungeoneering.npcs.combat; public class HopeDevourerCombat extends CombatScript { @Override public Object[] getKeys() { return new Object[] { ""Hope devourer"" }; } @Override public int attack(final NPC npc, final Entity target) { final HopeDevourer boss = (HopeDevourer) npc; final DungeonManager manager = boss.getManager(); boolean stomp = false; for (Player player : manager.getParty().getTeam()) if (WorldUtil.collides(player.getX(), player.getY(), player.getSize(), npc.getX(), npc.getY(), npc.getSize())) { stomp = true; delayHit(npc, 0, player, getRegularHit(npc, getMaxHitFromAttackStyleLevel(npc, AttackStyle.MELEE, player))); } if (stomp) { npc.setNextAnimation(new Animation(14459)); return 6; } if (Utils.random(10) == 0) { npc.setNextForceTalk(new ForceTalk(""Grrrrrrrrrroooooooooaaaarrrrr"")); WorldTasks.scheduleTimer(2, (ticks) -> { npc.setNextAnimation(new Animation(14460)); npc.setNextSpotAnim(new SpotAnim(2844, 30, 0)); int healedDamage = 0; for (Entity t : npc.getPossibleTargets()) { Player player = (Player) t; int damage = (int) Utils.random(npc.getLevelForStyle(AttackStyle.MAGE) * .85, npc.getLevelForStyle(AttackStyle.MAGE)); if (damage > 0 && player.getPrayer().isUsingProtectionPrayer()) { healedDamage += damage; player.setProtectionPrayBlock(2); t.setNextSpotAnim(new SpotAnim(2845, 75, 0)); delayHit(npc, 0, t, getMagicHit(npc, damage)); } } npc.heal(healedDamage); return false; }); return 8; } if (!WorldUtil.isInRange(npc.getX(), npc.getY(), npc.getSize(), target.getX(), target.getY(), target.getSize(), 0)) return 0; if (Utils.random(5) == 0) { npc.setNextAnimation(new Animation(14458)); final int damage = (int) Utils.random(npc.getLevelForStyle(AttackStyle.MELEE) * .85, npc.getLevelForStyle(AttackStyle.MELEE)); if (target instanceof Player player) player.getSkills().set(Constants.DEFENSE, (int) (player.getSkills().getLevel(Constants.DEFENSE) - (damage * .05))); delayHit(npc, 0, target, getMeleeHit(npc, damage)); WorldTasks.scheduleLooping(new Task() { private int ticks; private Tile tile; @Override public void run() { ticks++; if (ticks == 1) { if (target instanceof Player player) { player.lock(2); player.stopAll(); } byte[] dirs = Utils.getDirection(npc.getFaceAngle()); for (int distance = 2; distance >= 0; distance--) { tile = Tile.of(Tile.of(target.getX() + (dirs[0] * distance), target.getY() + (dirs[1] * distance), target.getPlane())); if (World.floorFree(tile.getPlane(), tile.getX(), tile.getY()) && manager.isAtBossRoom(tile)) break; if (distance == 0) tile = Tile.of(target.getTile()); } target.faceEntity(boss); target.forceMove(tile, 10070, 1, 60); stop(); } } }, 0, 0); } else { npc.setNextAnimation(new Animation(14457)); int damage = (int) Utils.random(npc.getLevelForStyle(AttackStyle.MELEE) * .75, npc.getLevelForStyle(AttackStyle.MELEE)); if (target instanceof Player player) if (player.getPrayer().isProtectingMelee()) { player.sendMessage(""Your prayer completely negates the attack."", true); damage = 0; } delayHit(npc, 0, target, getMeleeHit(npc, damage)); } return 6; } }" "package com.rs.game.content.skills.dungeoneering.npcs.combat; public class IcyBonesCombat extends CombatScript { @Override public Object[] getKeys() { return new Object[] { ""Icy Bones"" }; } @Override public int attack(final NPC npc, final Entity target) { final NPCCombatDefinitions defs = npc.getCombatDefinitions(); DungeonBoss boss = (DungeonBoss) npc; DungeonManager manager = boss.getManager(); if (Utils.random(10) == 0) { npc.setNextAnimation(new Animation(13791, 20)); npc.setNextSpotAnim(new SpotAnim(2594)); boolean mage = Utils.random(2) == 0; if (mage && Utils.random(3) == 0) { target.setNextSpotAnim(new SpotAnim(2597)); target.freeze(8); } if (mage) delayHit(npc, 2, target, getMagicHit(npc, getMaxHitFromAttackStyleLevel(npc, AttackStyle.MAGE, target))); else delayHit(npc, 2, target, getRangeHit(npc, getMaxHitFromAttackStyleLevel(npc, AttackStyle.RANGE, target))); World.sendProjectile(npc, target, 2595, 41, 16, 41, 40, 16, 0); return npc.getAttackSpeed(); } if (Utils.random(3) == 0 && WorldUtil.isInRange(target.getX(), target.getY(), target.getSize(), npc.getX(), npc.getY(), npc.getSize(), 0) && ((IcyBones) npc).sendSpikes()) { npc.setNextSpotAnim(new SpotAnim(2596)); npc.setNextAnimation(new Animation(13790)); delayHit(npc, 0, target, getMeleeHit(npc, getMaxHitFromAttackStyleLevel(npc, AttackStyle.MELEE, target))); return npc.getAttackSpeed(); } boolean onRange = false; for (Player player : manager.getParty().getTeam()) if (WorldUtil.isInRange(player.getX(), player.getY(), player.getSize(), npc.getX(), npc.getY(), npc.getSize(), 0)) { int damage = getMaxHitFromAttackStyleLevel(npc, AttackStyle.MELEE, player); if (damage != 0 && player.getPrayer().isProtectingMelee()) player.sendMessage(""Your prayer offers only partial protection against the attack.""); delayHit(npc, 0, player, getMeleeHit(npc, damage)); onRange = true; } if (onRange) { npc.setNextAnimation(new Animation(defs.getAttackEmote(), 20)); npc.setNextSpotAnim(new SpotAnim(defs.getAttackGfx())); return npc.getAttackSpeed(); } return 0; } }" "package com.rs.game.content.skills.dungeoneering.npcs.combat; public class KalGerWarmongerCombat extends CombatScript { @Override public Object[] getKeys() { return new Object[] { ""Kal'Ger the Warmonger"" }; } @Override public int attack(NPC npc, Entity target) { final KalGerWarmonger boss = (KalGerWarmonger) npc; final DungeonManager manager = boss.getManager(); if (boss.getType() == 0 || boss.isMaximumPullTicks()) return 0; if (boss.isUsingMelee()) { boolean smash = false; for (Player player : manager.getParty().getTeam()) if (WorldUtil.collides(player.getX(), player.getY(), player.getSize(), boss.getX(), boss.getY(), 5)) { smash = true; break; } if (smash) { boss.setNextAnimation(new Animation(14968)); boss.setNextSpotAnim(new SpotAnim(2867)); for (Player player : manager.getParty().getTeam()) { if (!manager.isAtBossRoom(player.getTile())) continue; player.getPackets().sendCameraShake(3, 25, 50, 25, 50);// everyone's camera shakes if (Utils.inCircle(player.getTile(), boss.getTile(), 5))// 5 square radius (imperfect circle) player.applyHit(new Hit(boss, Utils.random(300, boss.getMaxHit()), HitLook.TRUE_DAMAGE)); } WorldTasks.scheduleTimer((ticks) -> { boss.setPullTicks(0); for (Player player : manager.getParty().getTeam())// we obv need to reset the camera ^.^ player.getPackets().sendStopCameraShake(); return false; }); } else if (!WorldUtil.isInRange(npc.getX(), npc.getY(), npc.getSize(), target.getX(), target.getY(), target.getSize(), 0)) return 0; } boss.setPullTicks(0); if (boss.getAnnoyanceMeter() == 8) // boss.playSoundEffect(2986); boss.setNextForceTalk(new ForceTalk(""GRRRR!"")); else if (boss.getAnnoyanceMeter() == 10) // boss.playSoundEffect(3012); boss.setNextForceTalk(new ForceTalk(""ENOUGH!"")); if (boss.getType() == 1) {// NO WEAPONS HUR npc.setNextAnimation(new Animation(14392)); delayHit(npc, 0, target, getMeleeHit(npc, getMaxHit(npc, boss.getMaxHit(), AttackStyle.MELEE, target))); } else if (boss.getType() == 2) {// LONG npc.setNextAnimation(new Animation(14416)); delayHit(npc, 0, target, getMeleeHit(npc, getMaxHit(npc, boss.getMaxHit(), AttackStyle.MELEE, target))); } else if (boss.getType() == 3) {// STAFF npc.setNextAnimation(new Animation(14996)); npc.setNextSpotAnim(new SpotAnim(2874)); for (Entity t : boss.getPossibleTargets()) { World.sendProjectile(boss, t, 2875, 65, 10, 50, 0, 5, 1); t.setNextSpotAnim(new SpotAnim(2873)); delayHit(npc, 0, t, getMagicHit(npc, getMaxHit(npc, boss.getMaxHit(), AttackStyle.MAGE, t))); } } else if (boss.getType() == 4) {// 2H npc.setNextAnimation(new Animation(14450)); delayHit(npc, 0, target, getMeleeHit(npc, getMaxHit(npc, boss.getMaxHit(), AttackStyle.MELEE, target))); } else if (boss.getType() == 5) {// BOW npc.setNextAnimation(new Animation(14537)); npc.setNextSpotAnim(new SpotAnim(2885)); for (Entity t : boss.getPossibleTargets()) { World.sendProjectile(boss, t, 2886, 75, 30, 50, 55, 2, 0); delayHit(npc, 2, t, getRangeHit(npc, getMaxHit(npc, boss.getMaxHit(), AttackStyle.RANGE, t))); } } else if (boss.getType() == 6) {// MAUL npc.setNextAnimation(new Animation(14963)); delayHit(npc, 0, target, getMeleeHit(npc, getMaxHit(npc, boss.getMaxHit(), AttackStyle.MELEE, target))); return 3;// SUPER OP MODE! } return 4; } }" "package com.rs.game.content.skills.dungeoneering.npcs.combat; public class LakkTheRiftSplitterCombat extends CombatScript { // private static final int[] VOICES = { 3034, 2993, 3007 }; private static final String[] MESSAGES = { ""A flame portal will flush you out!"", ""Taste miasma!"", ""This will cut you down to size!"" }; @Override public Object[] getKeys() { return new Object[] { ""Har'Lakk the Riftsplitter"" }; } @Override public int attack(NPC npc, Entity target) { final LakkTheRiftSplitter boss = (LakkTheRiftSplitter) npc; DungeonManager manager = boss.getManager(); boolean smash = false; for (Player player : manager.getParty().getTeam()) if (WorldUtil.collides(player.getX(), player.getY(), player.getSize(), npc.getX(), npc.getY(), npc.getSize())) { smash = true; player.setProtectionPrayBlock(2); delayHit(npc, 0, player, getRegularHit(npc, getMaxHit(npc, (int) (npc.getLevelForStyle(AttackStyle.MELEE) * .85), AttackStyle.MELEE, player))); delayHit(npc, 0, player, getRegularHit(npc, getMaxHit(npc, (int) (npc.getLevelForStyle(AttackStyle.MELEE) * .60), AttackStyle.MELEE, player))); } if (smash) { npc.setNextAnimation(new Animation(14383)); return 5; } if (Utils.random(4) == 0) { final int type = Utils.random(3); switch (type) { case 0, 1, 2: final List boundary = new LinkedList<>(); for (int x = -1; x < 2; x++) for (int y = -1; y < 2; y++) boundary.add(target.transform(x, y, 0)); if (boss.doesBoundaryOverlap(boundary)) { regularMagicAttack(target, npc); return 5; } // npc.playSoundEffect(VOICES[type]); WorldTasks.scheduleTimer(1, (ticks) -> { boss.setNextForceTalk(new ForceTalk(MESSAGES[type])); boss.setNextAnimation(new Animation(14398)); boss.addPortalCluster(type, boundary.toArray(new Tile[1])); return false; }); return 5; } } // melee or magic boolean onRange = WorldUtil.isInRange(npc.getX(), npc.getY(), npc.getSize(), target.getX(), target.getY(), target.getSize(), 0); boolean melee = onRange && Utils.random(2) == 0; if (melee) { npc.setNextAnimation(new Animation(14375)); delayHit(npc, 0, target, getMeleeHit(npc, getMaxHitFromAttackStyleLevel(npc, AttackStyle.MELEE, target))); } else regularMagicAttack(target, npc); return 5; } private void regularMagicAttack(Entity target, NPC npc) { npc.setNextAnimation(new Animation(14398)); World.sendProjectile(npc, target, 2579, 50, 30, 41, 40, 0, 0); if (target instanceof Player player) { int damage = getMaxHitFromAttackStyleLevel(npc, AttackStyle.MAGE, player); if (player.getPrayer().getPoints() > 0 && player.getPrayer().isProtectingMage()) { player.getPrayer().drainPrayer((int) (damage * .5)); player.sendMessage(""Your prayer points feel drained.""); } else delayHit(npc, 1, player, getMagicHit(npc, damage)); } target.setNextSpotAnim(new SpotAnim(2580, 75, 0)); } }" "package com.rs.game.content.skills.dungeoneering.npcs.combat; public class LuminescentIcefiendCombat extends CombatScript { @Override public Object[] getKeys() { return new Object[] { ""Luminescent icefiend"" }; } @Override public int attack(final NPC npc, final Entity target) { final LuminscentIcefiend icefiend = (LuminscentIcefiend) npc; if (icefiend.isSpecialEnabled()) { npc.setNextAnimation(new Animation(13338)); npc.setNextSpotAnim(new SpotAnim(2524)); icefiend.commenceSpecial(); return 20; } boolean magicAttack = Utils.random(2) == 0; if (magicAttack) { npc.setNextAnimation(new Animation(13352)); World.sendProjectile(npc, target, 2529, 15, 16, 35, 35, 16, 0); delayHit(icefiend, 2, target, getMagicHit(npc, getMaxHit(npc, icefiend.getMaxHit(), AttackStyle.MAGE, target))); } else { npc.setNextAnimation(new Animation(13337)); World.sendProjectile(npc, target, 2530, 30, 16, 35, 35, 0, 0); delayHit(icefiend, 2, target, getRangeHit(npc, getMaxHit(npc, (int) (icefiend.getMaxHit() * .90), AttackStyle.RANGE, target))); WorldTasks.schedule(new Task() { @Override public void run() { target.setNextSpotAnim(new SpotAnim(2531)); } }, 2); } return 4; } }" "package com.rs.game.content.skills.dungeoneering.npcs.combat; public class NecroLordCombat extends CombatScript { @Override public Object[] getKeys() { return new Object[] { ""Necrolord"" }; } @Override public int attack(NPC npc, final Entity target) { final NecroLord boss = (NecroLord) npc; if (Utils.random(10) == 0) { final int skeletonCount = boss.getManager().getParty().getTeam().size(); final List projectileTile = new LinkedList<>(); WorldTasks.scheduleTimer((ticks) -> { if (ticks == 2) { for (int i = 0; i < skeletonCount; i++) { Tile tile = World.getFreeTile(boss.getManager().getTile(boss.getReference(), Utils.random(2) == 0 ? 5 : 10, 5), 4); projectileTile.add(tile); World.sendProjectile(boss, tile, 2590, 65, 0, 30, 0, 16, 0); } } else if (ticks == 4) { for (Tile tile : projectileTile) boss.addSkeleton(tile); return false; } return true; }); } final int attack = Utils.random(4); switch (attack) { // main attack case 0, 1 -> { npc.setNextAnimation(new Animation(14209)); npc.setNextSpotAnim(new SpotAnim(2716)); World.sendProjectile(npc, target, 2721, 38, 18, 50, 50, 0, 0); delayHit(npc, 1, target, getMagicHit(npc, getMaxHitFromAttackStyleLevel(npc, AttackStyle.MAGE, target))); target.setNextSpotAnim(new SpotAnim(2726, 75, 80)); } case 2, 3 -> { final Tile tile = Tile.of(target.getTile()); npc.setNextAnimation(new Animation(attack == 2 ? 710 : 729)); npc.setNextSpotAnim(new SpotAnim(attack == 2 ? 177 : 167, 0, 65)); World.sendProjectile(npc, tile, attack == 2 ? 178 : 168, 40, 18, 55, 70, 5, 0); WorldTasks.scheduleTimer(1, (ticks) -> { for (Entity t : boss.getPossibleTargets()) { int damage = getMaxHit(boss, boss.getMaxHit(), AttackStyle.MAGE, t); if (!t.withinDistance(tile, 1)) continue; if (damage > 0) { if (attack == 2) t.freeze(8); else { if (t instanceof Player p2) { p2.sendMessage(""You feel weary.""); p2.setRunEnergy((int) (p2.getRunEnergy() * .5)); } t.applyHit(new Hit(boss, Utils.random(boss.getMaxHit()) + 1, HitLook.MAGIC_DAMAGE)); } t.setNextSpotAnim(new SpotAnim(attack == 2 ? 179 : 169, 60, 65)); } } return false; }); } } return Utils.random(2) == 0 ? 4 : 5; } }" "package com.rs.game.content.skills.dungeoneering.npcs.combat; public class NightGazerKhighorahkCombat extends CombatScript { @Override public Object[] getKeys() { return new Object[] { ""Night-gazer Khighorahk"" }; } public void sendRangeAoe(final NightGazerKhighorahk gazer) { if (gazer.isDead()) return; gazer.setNextAnimation(new Animation(13425)); for (Entity target : gazer.getPossibleTargets()) { World.sendProjectile(gazer, target, 2385, 60, 16, 41, 30, 0, 0); delayHit(gazer, 1, target, getRangeHit(gazer, getMaxHit(gazer, (int) (gazer.getMaxHit() * 0.6), AttackStyle.RANGE, target))); } if (!gazer.isSecondStage()) WorldTasks.delay(5, () -> { if (gazer.isDead()) return; gazer.setNextAnimation(new Animation(13422)); }); } @Override public int attack(final NPC npc, final Entity target) { final NightGazerKhighorahk gazer = (NightGazerKhighorahk) npc; final DungeonManager manager = gazer.getManager(); /* * without this check its possible to lure him so that he always nukes */ if (!gazer.isUsedSpecial()) { final List targets = gazer.getPossibleTargets(); boolean success = false; for (Entity t : targets) if (WorldUtil.isInRange(npc.getX(), npc.getY(), npc.getSize(), t.getX(), t.getY(), t.getSize(), 1)) { if (!success) success = true; npc.setNextAnimation(new Animation(gazer.isSecondStage() ? 13427 : 13429)); npc.setNextSpotAnim(new SpotAnim(/* gazer.isSecondStage() ? 2391 : */2390)); gazer.setUsedSpecial(true); } if (success) { WorldTasks.scheduleLooping(new Task() { private int ticks; private final List tiles = new LinkedList<>(); @Override public void run() { ticks++; if (ticks == 1) npc.setNextAnimation(new Animation(gazer.isSecondStage() ? 13426 : 13428)); else if (ticks == 3) { for (Entity t : targets) if (WorldUtil.isInRange(npc.getX(), npc.getY(), npc.getSize(), t.getX(), t.getY(), t.getSize(), 1)) { t.applyHit(new Hit(npc, Utils.random((int) (t.getMaxHitpoints() * 0.74)) + 1, HitLook.TRUE_DAMAGE)); if (t instanceof Player player) { player.lock(2); player.stopAll(); } byte[] dirs = Utils.getDirection(npc.getFaceAngle()); Tile tile = null; for (int distance = 2; distance >= 0; distance--) { tile = Tile.of(Tile.of(t.getX() + (dirs[0] * distance), t.getY() + (dirs[1] * distance), t.getPlane())); if (World.floorFree(tile.getPlane(), tile.getX(), tile.getY()) && manager.isAtBossRoom(tile)) break; if (distance == 0) tile = Tile.of(t.getTile()); } tiles.add(tile); t.faceEntity(gazer); t.forceMove(tile, 10070, 5, 60); } } else if (ticks == 4) { for (int index = 0; index < tiles.size(); index++) { Entity t = targets.get(index); if (WorldUtil.isInRange(npc.getX(), npc.getY(), npc.getSize(), t.getX(), t.getY(), t.getSize(), 1)) t.tele(tiles.get(index)); } stop(); } } }, 0, 0); return 10; } } else gazer.setUsedSpecial(false); if (Utils.random(10) == 0) { if (gazer.isSecondStage()) { sendRangeAoe(gazer); return npc.getAttackSpeed() + 1; } npc.setNextAnimation(new Animation(13423)); WorldTasks.delay(1, () -> sendRangeAoe(gazer)); return npc.getAttackSpeed() + 6; } if (Utils.random(3) == 0) { // range single target npc.setNextAnimation(new Animation(gazer.isSecondStage() ? 13433 : 13434)); World.sendProjectile(npc, target, 2385, gazer.isSecondStage() ? 60 : 40, 16, 41, 90, 0, 0); delayHit(npc, 3, target, getRangeHit(npc, getMaxHitFromAttackStyleLevel(npc, AttackStyle.RANGE, target))); return npc.getAttackSpeed() + 1; } // magic npc.setNextAnimation(new Animation(gazer.isSecondStage() ? 13430 : 13431)); World.sendProjectile(npc, target, 2385, gazer.isSecondStage() ? 60 : 40, 16, 41, 30, 0, 0); target.setNextSpotAnim(new SpotAnim(2386, 70, 100)); delayHit(npc, 1, target, getMagicHit(npc, getMaxHitFromAttackStyleLevel(npc, AttackStyle.MAGE, target))); return npc.getAttackSpeed(); } }" "package com.rs.game.content.skills.dungeoneering.npcs.combat; public class PlaneFreezerLakhrahnazCombat extends CombatScript { @Override public Object[] getKeys() { return new Object[] { ""Plane-freezer Lakhrahnaz"" }; } @Override public int attack(final NPC npc, final Entity target) { final NPCCombatDefinitions defs = npc.getCombatDefinitions(); if (Utils.random(8) == 0) { npc.resetWalkSteps(); npc.addWalkSteps(npc.getX() + Utils.random(3) - 2, npc.getY() + Utils.random(3) - 2); } if (Utils.random(3) == 0) { int attackStyle = Utils.random(2); if (attackStyle == 1 && !WorldUtil.isInRange(target.getX(), target.getY(), target.getSize(), npc.getX(), npc.getY(), npc.getSize(), 0)) attackStyle = 0; switch (attackStyle) { case 0 -> { npc.setNextAnimation(new Animation(13775)); for (Entity t : npc.getPossibleTargets()) { World.sendProjectile(npc, t, 2577, 16, 16, 41, 30, 0, 0); t.setNextSpotAnim(new SpotAnim(2578, 70, 0)); delayHit(npc, 1, t, getMagicHit(npc, getMaxHit(npc, 100, AttackStyle.MAGE, target))); } } case 1 -> { npc.setNextAnimation(new Animation(defs.getAttackEmote())); Direction dir = Direction.random(); target.addWalkSteps(target.getX() + dir.dx, target.getY() + dir.dy, 1); delayHit(npc, 0, target, getMeleeHit(npc, getMaxHit(npc, 100, AttackStyle.MELEE, target))); } } return npc.getAttackSpeed(); } npc.setNextAnimation(new Animation(13775)); npc.setNextSpotAnim(new SpotAnim(2574)); World.sendProjectile(npc, target, 2595, 16, 16, 41, 30, 0, 0); target.setNextSpotAnim(new SpotAnim(2576, 70, 0)); delayHit(npc, 1, target, getRangeHit(npc, getMaxHit(npc, 100, AttackStyle.RANGE, target))); return npc.getAttackSpeed(); } }" "package com.rs.game.content.skills.dungeoneering.npcs.combat; public class RammernautCombat extends CombatScript { @Override public Object[] getKeys() { return new Object[] { ""Rammernaut"" }; } public static int getChargeCount(NPC npc) { return npc.getTempAttribs().getI(""RAMMERNAUT_CHARGE"", 0); } public static void setChargeCount(NPC npc, int count) { npc.getTempAttribs().setI(""RAMMERNAUT_CHARGE"", count); } @Override public int attack(final NPC npc, final Entity target) { final NPCCombatDefinitions defs = npc.getCombatDefinitions(); int chargeCount = getChargeCount(npc); if (!(npc instanceof Rammernaut rammernaut)) return 0; if (chargeCount > 1 && target instanceof Player player) { ((Rammernaut) npc).setChargeTarget(player); setChargeCount(npc, 0); return 0; } if (!WorldUtil.isInRange(npc.getX(), npc.getY(), npc.getSize(), target.getX(), target.getY(), target.getSize(), 0)) { setChargeCount(npc, chargeCount + 1); return 3; } setChargeCount(npc, Utils.random(10) == 0 ? 2 : 0); // 1 in 10 change charging next att if (Utils.random(5) == 0) { npc.setNextAnimation(new Animation(13705)); for (Entity entity : npc.getPossibleTargets()) { if (!WorldUtil.isInRange(npc.getX(), npc.getY(), npc.getSize(), entity.getX(), entity.getY(), entity.getSize(), 0)) continue; ((Rammernaut) npc).applyStunHit(entity, npc.getLevelForStyle(AttackStyle.MELEE)); } return npc.getAttackSpeed(); } if (rammernaut.isRequestSpecNormalAttack() && target instanceof Player player) { rammernaut.setRequestSpecNormalAttack(false); player.sendMessage(""Your prayers have been disabled.""); player.setProtectionPrayBlock(12); player.sendMessage(""Your defence been reduced.""); player.getSkills().drainLevel(Constants.DEFENSE, Utils.random(3) + 1); } // default melee attack can be protected with prayer npc.setNextAnimation(new Animation(defs.getAttackEmote())); delayHit(npc, 0, target, getMeleeHit(npc, getMaxHitFromAttackStyleLevel(npc, AttackStyle.MELEE, target))); return npc.getAttackSpeed(); } }" "package com.rs.game.content.skills.dungeoneering.npcs.combat; public class RuneboundBehemothCombat extends CombatScript { @Override public Object[] getKeys() { return new Object[] { ""Runebound behemoth"" }; } @Override public int attack(NPC npc, Entity target) { final RuneboundBehemoth boss = (RuneboundBehemoth) npc; final DungeonManager manager = boss.getManager(); boolean trample = false; for (Entity t : npc.getPossibleTargets()) if (WorldUtil.collides(t.getX(), t.getY(), t.getSize(), npc.getX(), npc.getY(), npc.getSize())) { trample = true; delayHit(npc, 0, t, getRegularHit(npc, getMaxHitFromAttackStyleLevel(npc, AttackStyle.MELEE, t))); if (t instanceof Player player) player.sendMessage(""The beast tramples you.""); } if (trample) { npc.setNextAnimation(new Animation(14426)); return 5; } if (Utils.random(15) == 0) {// Special attack final List explosions = new LinkedList<>(); boss.setNextForceTalk(new ForceTalk(""Raaaaaaaaaaaaaaaaaaaaaaaaaawr!"")); WorldTasks.scheduleTimer((ticks) -> { if (ticks == 1) boss.setNextSpotAnim(new SpotAnim(2769)); else if (ticks == 4) boss.setNextSpotAnim(new SpotAnim(2770)); else if (ticks == 5) { boss.setNextSpotAnim(new SpotAnim(2771)); for (Entity t : boss.getPossibleTargets()) for (int i = 0; i < 4; i++) { Tile tile = World.getFreeTile(t.getTile(), 2); if (!manager.isAtBossRoom(tile)) continue; explosions.add(tile); World.sendProjectile(boss, tile, 2414, 120, 0, 20, 0, 20, 0); } } else if (ticks == 8) { for (Tile tile : explosions) World.sendSpotAnim(tile, new SpotAnim(2399)); for (Entity t : boss.getPossibleTargets()) for (Tile tile : explosions) { if (t.getX() != tile.getX() || t.getY() != tile.getY()) continue; t.applyHit(new Hit(boss, (int) Utils.random(boss.getMaxHit() * .6, boss.getMaxHit()), HitLook.TRUE_DAMAGE)); } boss.resetTransformation(); return false; } return true; }); return 8; } int[] possibleAttacks = { 0, 1, 2 }; if (target instanceof Player player) if (player.getPrayer().isProtectingMelee()) possibleAttacks = new int[] { 1, 2 }; else if (player.getPrayer().isProtectingRange()) possibleAttacks = new int[] { 0, 1 }; else if (player.getPrayer().isProtectingMage()) possibleAttacks = new int[] { 0, 2 }; boolean distanced = !WorldUtil.isInRange(npc.getX(), npc.getY(), npc.getSize(), target.getX(), target.getY(), target.getSize(), 0); int attack = possibleAttacks[Utils.random(possibleAttacks.length)]; if (attack == 0 && distanced) attack = possibleAttacks[1]; switch (attack) { //melee case 0 -> { boss.setNextAnimation(new Animation(14423)); delayHit(npc, 0, target, getMeleeHit(npc, getMaxHitFromAttackStyleLevel(npc, AttackStyle.MELEE, target))); } //green exploding blob attack (magic) case 1 -> { boss.setNextAnimation(new Animation(14427)); //boss.setNextGraphics(new Graphics(2413)); World.sendProjectile(npc, target, 2414, 41, 16, 50, 40, 0, 0); delayHit(npc, 1, target, getMagicHit(npc, getMaxHitFromAttackStyleLevel(npc, AttackStyle.MAGE, target))); target.setNextSpotAnim(new SpotAnim(2417, 80, 0)); } //green blob attack (range) case 2 -> { boss.setNextAnimation(new Animation(14424)); boss.setNextSpotAnim(new SpotAnim(2394)); World.sendProjectile(npc, target, 2395, 41, 16, 50, 40, 0, 2); delayHit(npc, 1, target, getRangeHit(npc, getMaxHitFromAttackStyleLevel(npc, AttackStyle.RANGE, target))); target.setNextSpotAnim(new SpotAnim(2396, 80, 0)); } } return 6; } }" "package com.rs.game.content.skills.dungeoneering.npcs.combat; public class SagittareCombat extends CombatScript { @Override public Object[] getKeys() { return new Object[] { ""Sagittare"" }; } @Override public int attack(NPC npc, Entity target) { final Sagittare boss = (Sagittare) npc; if (boss.isUsingSpecial() && !boss.isCantInteract()) { sendRainDropAttack(boss); return 10; } int attack = Utils.random(5); switch (attack) { // Normal range, Normal magic, Multi magic case 0, 1, 2 -> { npc.setNextAnimation(new Animation(13271)); npc.setNextSpotAnim(new SpotAnim(attack == 0 ? 2532 : 2534, 0, 96)); for (Entity t : npc.getPossibleTargets()) { if ((attack == 0 || attack == 1) && t != target) continue; World.sendProjectile(npc, t, attack == 0 ? 2533 : 2535, 65, 50, 54, 35, 5, 0); if (attack == 0) delayHit(npc, 1, t, getRangeHit(npc, getMaxHitFromAttackStyleLevel(npc, AttackStyle.RANGE, t))); else delayHit(npc, 1, t, getMagicHit(npc, getMaxHitFromAttackStyleLevel(npc, AttackStyle.MAGE, t))); } } // Bind attacks case 3, 4 -> { boolean isMagicAttack = attack == 3; npc.setNextAnimation(new Animation(13271)); npc.setNextSpotAnim(new SpotAnim(isMagicAttack ? 2536 : 2539, 0, 96)); for (Entity t : npc.getPossibleTargets()) { if (!(t instanceof Player player)) continue; boolean bindTarget = false; World.sendProjectile(npc, t, isMagicAttack ? 2537 : 2540, 65, 50, 54, 35, 5, 0); if (isMagicAttack) { if (!player.getPrayer().isProtectingMage()) bindTarget = true; delayHit(npc, 1, t, getMagicHit(npc, getMaxHitFromAttackStyleLevel(npc, AttackStyle.MAGE, t))); } else { bindTarget = Utils.random(2) == 0;// 50/50 delayHit(npc, 1, t, getMagicHit(npc, getMaxHitFromAttackStyleLevel(npc, AttackStyle.MAGE, t))); } if (bindTarget) { player.freeze(8); player.setRun(false); } player.setNextSpotAnim(new SpotAnim(2541, 75, 65)); } } } return 5; } private void sendRainDropAttack(final Sagittare boss) { boss.setCantInteract(true); boss.setNextForceTalk(new ForceTalk(""Back off!"")); final Tile center = Tile.of(boss.getTile()); final DungeonManager manager = boss.getManager(); final RoomReference rRef = manager.getCurrentRoomReference(center); if (rRef == null) return; WorldTasks.scheduleTimer((ticks) -> { if (boss.isDead()) { return false; } if (ticks == 2) { boss.setNextForceTalk(new ForceTalk(""Arrow-rain!"")); boss.setNextAnimation(new Animation(13270)); boss.setNextSpotAnim(new SpotAnim(2542, 0, 93)); } else if (ticks == 5) { boss.setCantInteract(false); boss.setNextAnimation(new Animation(8939)); boss.setNextSpotAnim(new SpotAnim(1576)); } else if (ticks == 7) { int stage = boss.getStage(); Tile teleport = World.getFreeTile(manager.getTile(rRef, 6, 6), 1); if (stage != 1 && stage != -1) { int corner = Utils.random(4); if (corner == 0)// this is good teleport = manager.getTile(rRef, 1, Utils.random(14) + 1);// 1,1 14, 1, 14, 14, 2, 14 else if (corner == 1)// this is good teleport = manager.getTile(rRef, 14 - Utils.random(14), 1); else if (corner == 2)// this is good teleport = manager.getTile(rRef, 14, 14 - Utils.random(14)); else // this is good teleport = manager.getTile(rRef, Utils.random(14) + 1, 14); } for (int x = -1; x < 2; x++) for (int y = -1; y < 2; y++) World.sendProjectile(boss, center.transform(x, y, 0), 2533, 250, 0, 40, 0, 0, 0); boss.tele(teleport); boss.setNextAnimation(new Animation(8941)); boss.setNextSpotAnim(new SpotAnim(1577)); } else if (ticks == 8) { targetL: for (Entity target : boss.getPossibleTargets()) { if (!(target instanceof Player player)) continue; for (int x = -1; x < 2; x++) for (int y = -1; y < 2; y++) { Tile projectileTile = center.transform(x, y, 0); if (player.getX() != projectileTile.getX() || player.getY() != projectileTile.getY()) continue targetL; } player.setRun(false); player.freeze(8); player.sendMessage(""You have been injured and can't move.""); int hit = (int) (boss.getMaxHit() * .1 + getMaxHit(boss, (int) (boss.getMaxHit() * .90), AttackStyle.RANGE, player)); player.applyHit(new Hit(boss, hit, HitLook.TRUE_DAMAGE)); } boss.setUsingSpecial(false); return false; } return true; }); } }" "package com.rs.game.content.skills.dungeoneering.npcs.combat; public class ShadowForgerIhlakhizanCombat extends CombatScript { @Override public Object[] getKeys() { return new Object[] { ""Shadow-Forger Ihlakhizan"" }; } @Override public int attack(final NPC npc, final Entity target) { final NPCCombatDefinitions defs = npc.getCombatDefinitions(); final ShadowForgerIhlakhizan forger = (ShadowForgerIhlakhizan) npc; final DungeonManager manager = forger.getManager(); for (Entity t : npc.getPossibleTargets()) t.getTempAttribs().removeB(""SHADOW_FORGER_SHADOW""); if (Utils.random(4) == 0) { if (Utils.random(3) == 0) { npc.setNextAnimation(new Animation(13019)); npc.setNextSpotAnim(new SpotAnim(2370)); for (int i = 0; i < 10; i++) { final Tile tile = ((ShadowForgerIhlakhizan) npc).getManager().getTile(forger.getReference(), 2 + Utils.random(12), 2 + Utils.random(12)); if (WorldUtil.collides(npc.getX(), npc.getY(), npc.getSize(), tile.getX(), tile.getY(), 1)) continue; World.sendProjectile(npc, tile, 2371, 120, 30, 41, 30, 16, 0); WorldTasks.delay(2, () -> { World.sendSpotAnim(tile, new SpotAnim(2374)); for (Player player : forger.getManager().getParty().getTeam()) { if (player.isDead() || player.getX() != tile.getX() || player.getY() != tile.getY()) continue; player.applyHit(new Hit(npc, Utils.random(npc.getLevelForStyle(AttackStyle.RANGE)) + 1, HitLook.RANGE_DAMAGE)); } }); } return npc.getAttackSpeed(); } npc.setNextSpotAnim(new SpotAnim(2600)); for (Entity t : npc.getPossibleTargets()) if (t instanceof Player player) player.sendMessage(""The shadow-forger starts to glow.""); forger.setUsedShadow(); WorldTasks.delay(3, () -> { npc.setNextAnimation(new Animation(13016)); for (Entity t : npc.getPossibleTargets()) { t.applyHit(new Hit(npc, Utils.random((int) (t.getMaxHitpoints() * 0.74)) + 1, HitLook.TRUE_DAMAGE)); if (t instanceof Player player) { WorldTasks.scheduleLooping(new Task() { private int ticks; private Tile tile; @Override public void run() { ticks++; if (ticks == 1) { if (target instanceof Player player) { player.lock(2); player.stopAll(); } byte[] dirs = Utils.getDirection(npc.getFaceAngle()); for (int distance = 2; distance >= 0; distance--) { tile = Tile.of(Tile.of(target.getX() + (dirs[0] * distance), target.getY() + (dirs[1] * distance), target.getPlane())); if (World.floorFree(tile.getPlane(), tile.getX(), tile.getY()) && manager.isAtBossRoom(tile)) break; if (distance == 0) tile = Tile.of(target.getTile()); } target.faceEntity(forger); target.forceMove(tile, 10070, 5, 60); stop(); } } }, 0, 0); for (int stat = 0; stat < 7; stat++) { if (stat == Constants.HITPOINTS) continue; int drain = player.getSkills().getLevel(stat) / 2; if (stat == Constants.PRAYER) player.getPrayer().drainPrayer(drain * 10); player.getSkills().drainLevel(stat, drain); } } } }); return npc.getAttackSpeed() + 3; } int attackStyle = Utils.random(WorldUtil.isInRange(npc.getX(), npc.getY(), npc.getSize(), target.getX(), target.getY(), target.getSize(), 0) ? 2 : 1); switch (attackStyle) { case 0 -> { npc.setNextAnimation(new Animation(13025)); npc.setNextSpotAnim(new SpotAnim(2375)); World.sendProjectile(npc, target, 2376, 120, 30, 60, 70, 16, 0); target.setNextSpotAnim(new SpotAnim(2377, 120, 0)); delayHit(npc, 3, target, getRegularHit(npc, getMaxHitFromAttackStyleLevel(npc, AttackStyle.MAGE, target))); } case 1 -> { npc.setNextAnimation(new Animation(defs.getAttackEmote())); for (Entity t : npc.getPossibleTargets()) { if (!WorldUtil.isInRange(npc.getX(), npc.getY(), npc.getSize(), t.getX(), t.getY(), t.getSize(), 0)) continue; delayHit(npc, 0, t, getMeleeHit(npc, getMaxHitFromAttackStyleLevel(npc, AttackStyle.MELEE, t))); } } } return npc.getAttackSpeed(); } }" "package com.rs.game.content.skills.dungeoneering.npcs.combat; public class StompCombat extends CombatScript { @Override public Object[] getKeys() { return new Object[] { ""Stomp"" }; } @Override public int attack(final NPC npc, final Entity target) { final NPCCombatDefinitions defs = npc.getCombatDefinitions(); Stomp stomp = (Stomp) npc; if (npc.getHitpoints() <= 10 || npc.getHitpoints() < (npc.getMaxHitpoints() * (2 - stomp.getStage()) * 0.33)) { stomp.charge(); return npc.getAttackSpeed(); } // 0 - first 33% // 1 - 66-33% // 2 - 33-0% // 3 - 0% if (stomp.getStage() > 1 && Utils.random(10) == 0) { final Tile tile = Tile.of(target.getTile()); World.sendSpotAnim(tile, new SpotAnim(2400)); WorldTasks.delay(4, () -> { for (Entity entity : npc.getPossibleTargets()) if (entity.getX() == tile.getX() && entity.getY() == tile.getY()) entity.applyHit(new Hit(npc, (int) (entity.getMaxHitpoints() * 0.25), HitLook.RANGE_DAMAGE)); }); } int attackStyle = Utils.random(/* stomp.getStage() > 1 ? 4 : */stomp.getStage() > 0 ? 3 : 2); if (attackStyle == 0 && !WorldUtil.isInRange(npc.getX(), npc.getY(), npc.getSize(), target.getX(), target.getY(), target.getSize(), 0)) attackStyle = 1; switch (attackStyle) { case 0 -> { npc.setNextAnimation(new Animation(defs.getAttackEmote())); delayHit(npc, 0, target, getMeleeHit(npc, getMaxHitFromAttackStyleLevel(npc, AttackStyle.MELEE, target))); } case 1 -> { npc.setNextAnimation(new Animation(13449)); npc.setNextSpotAnim(new SpotAnim(2401)); for (Entity t : npc.getPossibleTargets()) { World.sendProjectile(npc, t, 2402, 16, 16, 41, 30, 0, 0); t.setNextSpotAnim(new SpotAnim(2403, 70, 0)); delayHit(npc, 1, t, getRangeHit(npc, getMaxHitFromAttackStyleLevel(npc, AttackStyle.RANGE, target))); } } case 2 -> { npc.setNextAnimation(new Animation(13450)); npc.setNextSpotAnim(new SpotAnim(2404)); World.sendProjectile(npc, target, 2405, 30, 16, 41, 65, 0, 0); target.setNextSpotAnim(new SpotAnim(2406, 120, 0)); delayHit(npc, 2, target, getMagicHit(npc, getMaxHitFromAttackStyleLevel(npc, AttackStyle.MAGE, target))); } } return npc.getAttackSpeed(); } }" "package com.rs.game.content.skills.dungeoneering.npcs.combat; public class ToKashBloodChillerCombat extends CombatScript { @Override public Object[] getKeys() { return new Object[] { ""To'Kash the Bloodchiller"" }; } @Override public int attack(final NPC npc, Entity target) { final ToKashBloodChiller boss = (ToKashBloodChiller) npc; final DungeonManager manager = boss.getManager(); boolean perfectDamage = false; if (target instanceof Player player) if (player.getAppearance().isNPC()) { perfectDamage = true; player.getAppearance().transformIntoNPC(-1); player.applyHit(new Hit(npc, (int) Utils.random(boss.getMaxHit() * .90, boss.getMaxHit()), HitLook.MAGIC_DAMAGE)); } boolean special = boss.canSpecialAttack() && Utils.random(10) == 0; if (!special) { boolean meleeAttack = perfectDamage || Utils.random(3) == 0; if (meleeAttack) { npc.setNextAnimation(new Animation(14392)); delayHit(npc, 0, target, getMeleeHit(npc, getMaxHit(npc, 200, AttackStyle.MELEE, target))); } else { npc.setNextAnimation(new Animation(14398)); World.sendProjectile(npc, target, 2546, 16, 16, 41, 30, 0, 0); delayHit(npc, 1, target, getMagicHit(npc, getMaxHit(npc, 200, AttackStyle.MAGE, target))); } return meleeAttack ? 4 : 5; } npc.setNextForceTalk(new ForceTalk(""Sleep now, in the bitter cold..."")); // npc.playSoundEffect(2896); boss.setSpecialAttack(true); WorldTasks.delay(3, () -> { npc.setNextForceTalk(new ForceTalk(""DEEP FREEZE!"")); npc.setNextAnimation(new Animation(14396)); npc.setNextSpotAnim(new SpotAnim(2544)); for (Entity t : boss.getPossibleTargets()) setSpecialFreeze((Player) t, boss, manager); }); return 8; } public static void setSpecialFreeze(final Player player, final ToKashBloodChiller boss, DungeonManager dungManager) { player.resetWalkSteps(); player.stopAll(); player.lock(); player.setNextSpotAnim(new SpotAnim(2545)); player.getAppearance().transformIntoNPC(10022); FrozenAdventurer npc = new FrozenAdventurer(10023, player.getTile(), -1, false); npc.setPlayer(player); player.sendMessage(""You have been frozen solid!""); WorldTasks.schedule(new Task() { int counter = 0; @Override public void run() { boss.setSpecialAttack(false); for (Entity t : boss.getPossibleTargets()) { Player player = (Player) t; if (player.isLocked()) { counter++; player.getAppearance().transformIntoNPC(-1); } } if (counter == 0) return; boss.setNextForceTalk(new ForceTalk(""I will shatter your soul!"")); boss.setNextSpotAnim(new SpotAnim(2549, 5, 100)); } }, 5 * dungManager.getParty().getTeam().size()); } public static void removeSpecialFreeze(Player player) { player.unlock(); player.getAppearance().transformIntoNPC(-1); player.setNextSpotAnim(new SpotAnim(2548)); player.sendMessage(""The ice encasing you shatters violently.""); } }" "package com.rs.game.content.skills.dungeoneering.npcs.combat; public class TomeOfLexicus extends CombatScript { @Override public Object[] getKeys() { return new Object[] { ""Tome of Strength"", ""Tome of Ranging"", ""Tome of Magic"" }; } @Override public int attack(NPC npc, Entity target) { int type = npc.getId() - 9856; switch (type) { case 0 -> { npc.setNextAnimation(new Animation(13479)); delayHit(npc, 0, target, getMagicHit(npc, getMaxHitFromAttackStyleLevel(npc, AttackStyle.MAGE, target))); } case 1, 2 -> { boolean range_style = type == 1; npc.setNextAnimation(new Animation(13480)); npc.setNextSpotAnim(new SpotAnim(range_style ? 2408 : 2424)); World.sendProjectile(npc, target, range_style ? 2409 : 2425, 40, 40, 54, 35, 5, 0); if (range_style) delayHit(npc, 1, target, getRangeHit(npc, getMaxHitFromAttackStyleLevel(npc, AttackStyle.RANGE, target))); else delayHit(npc, 1, target, getMagicHit(npc, getMaxHitFromAttackStyleLevel(npc, AttackStyle.MAGE, target))); target.setNextSpotAnim(new SpotAnim(range_style ? 2410 : 2426, 75, 0)); } } return 4; } }" "package com.rs.game.content.skills.dungeoneering.npcs.combat; public class UnholyCursebearerCombat extends CombatScript { @Override public Object[] getKeys() { return new Object[] { ""Unholy cursebearer"" }; } @Override public int attack(final NPC npc, final Entity target) { final NPCCombatDefinitions defs = npc.getCombatDefinitions(); int attackStyle = WorldUtil.isInRange(target.getX(), target.getY(), target.getSize(), npc.getX(), npc.getY(), npc.getSize(), 0) ? Utils.random(2) : 0; if (target instanceof Player player && target.getTempAttribs().getI(""UNHOLY_CURSEBEARER_ROT"") == -1) { target.getTempAttribs().setI(""UNHOLY_CURSEBEARER_ROT"", 1); player.sendMessage(""An undead rot starts to work at your body.""); WorldTasks.scheduleTimer(0, 12, (ticks) -> { int value = target.getTempAttribs().getI(""UNHOLY_CURSEBEARER_ROT""); if (player.hasFinished() || npc.hasFinished() || !((DungeonBoss) npc).getManager().isAtBossRoom(player.getTile()) || value == -1) { target.getTempAttribs().removeI(""UNHOLY_CURSEBEARER_ROT""); return false; } int damage = 20 * value; for (int stat = 0; stat < 7; stat++) { if (stat == Constants.HITPOINTS) continue; int drain = Utils.random(5) + 1; if (stat == Constants.PRAYER) player.getPrayer().drainPrayer(drain * 10); player.getSkills().drainLevel(stat, drain); } int maxDamage = player.getMaxHitpoints() / 10; if (damage > maxDamage) damage = maxDamage; if (value == 6) player.sendMessage(""The undead rot can now be cleansed by the unholy font.""); player.applyHit(new Hit(npc, damage, HitLook.TRUE_DAMAGE)); player.setNextSpotAnim(new SpotAnim(2440)); target.getTempAttribs().incI(""UNHOLY_CURSEBEARER_ROT""); return true; }); } switch (attackStyle) { case 0 -> { boolean multiTarget = Utils.random(2) == 0; npc.setNextAnimation(new Animation(multiTarget ? 13176 : 13175)); if (multiTarget) { npc.setNextSpotAnim(new SpotAnim(2441)); for (Entity t : npc.getPossibleTargets()) { World.sendProjectile(npc, t, 88, 50, 30, 41, 40, 0, 0); delayHit(npc, 1, t, getMagicHit(npc, getMaxHit(npc, (int) (npc.getLevelForStyle(AttackStyle.MAGE) * 0.6), AttackStyle.MAGE, t))); } } else { World.sendProjectile(npc, target, 88, 50, 30, 41, 30, 0, 0); delayHit(npc, 1, target, getMagicHit(npc, getMaxHitFromAttackStyleLevel(npc, AttackStyle.MAGE, target))); } } case 1 -> { npc.setNextAnimation(new Animation(defs.getAttackEmote())); delayHit(npc, 0, target, getMeleeHit(npc, getMaxHitFromAttackStyleLevel(npc, AttackStyle.MELEE, target))); } } return npc.getAttackSpeed(); } }" "package com.rs.game.content.skills.dungeoneering.npcs.combat; public class WarpedGulegaCombat extends CombatScript { private static final SpotAnim MELEE = new SpotAnim(2878); @Override public Object[] getKeys() { return new Object[] { ""Warped Gulega"" }; } @Override public int attack(final NPC npc, final Entity target) { final WarpedGulega boss = (WarpedGulega) npc; int style = Utils.random(4); switch (style) { // reg aeo melee case 3 -> { npc.setNextAnimation(new Animation(15004)); final List attackTiles = new LinkedList<>(); for (Entity t : boss.getPossibleTargets(true)) attackTiles.add(Tile.of(t.getTile())); WorldTasks.schedule(new Task() { @Override public void run() { for (Tile tile : attackTiles) World.sendSpotAnim(tile, MELEE); for (Entity t : boss.getPossibleTargets(true)) tileLoop:for (Tile tile : attackTiles) if (t.getX() == tile.getX() && t.getY() == tile.getY()) { delayHit(npc, 0, t, getMeleeHit(npc, getMaxHit(npc, (int) (npc.getLevelForStyle(AttackStyle.MELEE) * 0.75), AttackStyle.MELEE, t))); break tileLoop; } } }); } // reg range aeo case 1 -> { npc.setNextAnimation(new Animation(15001)); npc.setNextSpotAnim(new SpotAnim(2882)); for (Entity t : npc.getPossibleTargets(true)) { World.sendProjectile(npc, t, 2883, 75, 25, 30, 20, 15, 3); t.setNextSpotAnim(new SpotAnim(2884, 90, 0)); delayHit(npc, 2, t, getRangeHit(npc, getMaxHit(npc, (int) (npc.getLevelForStyle(AttackStyle.MELEE) * 0.75), AttackStyle.RANGE, t))); } } // reg magic aeo case 2 -> { npc.setNextAnimation(new Animation(15007)); for (Entity t : npc.getPossibleTargets(true)) { World.sendProjectile(npc, t, 2880, 150, 75, 30, 35, 15, 1); t.setNextSpotAnim(new SpotAnim(2881, 90, 0)); delayHit(npc, 2, t, getMagicHit(npc, getMaxHit(npc, (int) (npc.getLevelForStyle(AttackStyle.MELEE) * 0.75), AttackStyle.MAGE, t))); } } case 0 -> { npc.setNextAnimation(new Animation(15004)); WorldTasks.scheduleLooping(new Task() { Tile center; int cycles; @Override public void run() { cycles++; if (cycles == 1) { center = Tile.of(target.getTile()); sendTenticals(boss, center, 2); } else if (cycles == 3) sendTenticals(boss, center, 1); else if (cycles == 5) sendTenticals(boss, center, 0); else if (cycles == 6) { for (Entity t : npc.getPossibleTargets(true)) if (t.getX() == center.getX() && t.getY() == center.getY()) t.applyHit(new Hit(npc, t.getHitpoints() - 1, HitLook.TRUE_DAMAGE)); stop(); return; } } }, 0, 0); return 7; } } return 4; } private void sendTenticals(NPC npc, Tile center, int stage) { if (stage == 0) World.sendSpotAnim(center, MELEE); else if (stage == 2 || stage == 1) { World.sendSpotAnim(center.transform(-stage, stage, 0), MELEE); World.sendSpotAnim(center.transform(stage, stage, 0), MELEE); World.sendSpotAnim(center.transform(-stage, -stage, 0), MELEE); World.sendSpotAnim(center.transform(stage, -stage, 0), MELEE); } } }" "package com.rs.game.content.skills.dungeoneering.npcs.combat; public class WorldGorgerShukarhazhCombat extends CombatScript { @Override public Object[] getKeys() { return new Object[] { ""World-gorger Shukarhazh"" }; } @Override public int attack(NPC npc, final Entity target) { final WorldGorgerShukarhazh boss = (WorldGorgerShukarhazh) npc; final DungeonManager manager = boss.getManager(); boolean smash = false; for (Player player : manager.getParty().getTeam()) if (WorldUtil.collides(player.getX(), player.getY(), player.getSize(), npc.getX(), npc.getY(), npc.getSize())) { smash = true; player.sendMessage(""The creature crushes you as you move underneath it.""); delayHit(npc, 0, player, getRegularHit(npc, getMaxHitFromAttackStyleLevel(npc, AttackStyle.MELEE, player))); } if (smash) { npc.setNextAnimation(new Animation(14894)); return 6; } if (Utils.random(manager.getParty().getTeam().size() > 1 ? 20 : 5) == 0 && WorldUtil.isInRange(npc.getX(), npc.getY(), npc.getSize(), target.getX(), target.getY(), target.getSize(), 0)) { npc.setNextAnimation(new Animation(14892)); delayHit(npc, 0, target, getMeleeHit(npc, getMaxHitFromAttackStyleLevel(npc, AttackStyle.MELEE, target))); } else { npc.setNextAnimation(new Animation(14893)); npc.setNextSpotAnim(new SpotAnim(2846, 0, 100)); target.setNextSpotAnim(new SpotAnim(2848, 75, 100)); delayHit(npc, 2, target, getMagicHit(npc, getMaxHitFromAttackStyleLevel(npc, AttackStyle.MAGE, target))); } return 6; } }" "package com.rs.game.content.skills.dungeoneering.npcs.combat; public class YkLagorThunderousCombat extends CombatScript { @Override public Object[] getKeys() { return new Object[] { ""Yk'Lagor the Thunderous"" }; } @Override public int attack(NPC npc, Entity target) { final YkLagorThunderous boss = (YkLagorThunderous) npc; boss.playMusic(); if (boss.getNextAttack() < 2) { if (boss.getNextAttack() == 0) { boss.setNextForceTalk(new ForceTalk(""Come closer!"")); // boss.playSoundEffect(1930); WorldTasks.scheduleTimer((ticks) -> { if (ticks == 3) { boss.setNextAnimation(new Animation(14390)); boss.setNextSpotAnim(new SpotAnim(2768)); } else if (ticks == 7) { List targets = boss.getPossibleTargets(); boolean recovered = false; for (Player player : boss.getManager().getParty().getTeam()) { if (player.isDead() || !boss.getManager().isAtBossRoom(player.getTile())) continue; if (targets.contains(player)) { sendPullAttack(boss.transform(2, 2, 0), player, true); player.sendMessage(""Yk'Lagor sees you and pulls you closer, energising him.""); boss.heal((int) (boss.getMaxHitpoints() * 0.15)); if (!recovered) { boss.setNextForceTalk(new ForceTalk(""There is no escape!"")); // boss.playSoundEffect(1934); recovered = true; } } else player.sendMessage(""Hiding behind the pillar manages to stop Yk'Lagor from pulling you in.""); } return false; } return true; }); } else if (boss.getNextAttack() == 1) {// earthquake shit boss.setNextForceTalk(new ForceTalk(""This is..."")); // boss.playSoundEffect(1929); WorldTasks.scheduleTimer((ticks) -> { if (ticks == 2) { boss.setNextAnimation(new Animation(14384)); boss.setNextSpotAnim(new SpotAnim(2776)); for (Player player : boss.getManager().getParty().getTeam()) { if (player.isDead() || !boss.getManager().isAtBossRoom(player.getTile())) continue; player.getPackets().sendCameraShake(3, 25, 50, 25, 50); } } else if (ticks == 5) { boss.setNextForceTalk(new ForceTalk(""TRUE POWER!"")); // boss.playSoundEffect(1936); boss.sendBrokenFloor(); } else if (ticks == 7) { for (Player player : boss.getManager().getParty().getTeam()) { if (player.isDead() || !boss.getManager().isAtBossRoom(player.getTile())) continue; player.getPackets().sendStopCameraShake(); } for (Entity t : boss.getPossibleTargets()) t.applyHit(new Hit(boss, Utils.random(t.getMaxHitpoints()) + 1, HitLook.TRUE_DAMAGE)); return false; } return true; }); } boss.increaseNextAttack((boss.getNextAttack() == 0 ? 3 : 1) + Utils.random(4, 10) * 2); return 10; } boss.increaseNextAttack(-2); boolean useMelee = false; boolean useMagic = false; if (WorldUtil.isInRange(npc.getX(), npc.getY(), npc.getSize(), target.getX(), target.getY(), target.getSize(), 0)) useMelee = true; for (Entity t : npc.getPossibleTargets()) if (!WorldUtil.isInRange(npc.getX(), npc.getY(), npc.getSize(), t.getX(), t.getY(), t.getSize(), 0)) useMagic = true; int style = !useMelee ? 1 : !useMagic ? 0 : Utils.random(2); switch (style) { case 0 -> { npc.setNextAnimation(new Animation(14392)); int damage = 0; if (target instanceof Player player) if (player.getPrayer().getPoints() > 0 && damage > 0) player.getPrayer().drainPrayer((int) (damage * .5)); delayHit(npc, 0, target, getMeleeHit(npc, getMaxHitFromAttackStyleLevel(npc, AttackStyle.MELEE, target))); } case 1 -> sendMagicalAttack(boss, false); } return 4; } public static void sendPullAttack(final Tile tile, final Player player, final boolean disablePrayers) { player.lock(); player.resetWalkSteps(); player.setNextSpotAnim(new SpotAnim(2767)); player.forceMove(tile, 14388, 5, 60, () -> { player.getActionManager().addActionDelay(10); player.freeze(8); if (disablePrayers) { player.sendMessage(""You've been injured and you cannot use protective "" + (player.getPrayer().isCurses() ? ""curses"" : ""protective prayers"") + ""!""); player.setProtectionPrayBlock(2); } }); } public static void sendMagicalAttack(YkLagorThunderous npc, boolean specialAttack) { npc.setNextAnimation(new Animation(14525)); npc.setNextSpotAnim(new SpotAnim(2754)); if (specialAttack) npc.setNextForceTalk(new ForceTalk(""You dare steal my power?!"")); // npc.playSoundEffect(1926); else if (Utils.random(5) == 0) npc.setNextForceTalk(new ForceTalk(""Fear my wrath!"")); ///////// npc.playSoundEffect(1927); if (!npc.getPossibleTargets().isEmpty()) for (Player player : npc.getManager().getParty().getTeam()) { if (player.isDead() || !npc.getManager().isAtBossRoom(player.getTile())) continue; World.sendProjectile(npc, player, 2733, 75, 50, 20, 0, 20, 0); delayHit(npc, 1, player, getMagicHit(npc, getMaxHitFromAttackStyleLevel(npc, AttackStyle.MAGE, player))); player.setNextSpotAnim(new SpotAnim(2755, 85, 0)); } if (specialAttack) for (YkLagorMage mage : npc.getMages()) { if (mage.isDead() || mage.hasFinished()) continue; mage.applyHit(new Hit(npc, mage.getMaxHitpoints(), HitLook.MAGIC_DAMAGE, 60)); // delayHit(mage, 1, mage, getMagicHit(npc, mage.getMaxHitpoints())); mage.setNextSpotAnim(new SpotAnim(2755, 85, 0)); } // for mages kill blablalb,we dont want to kill familiars lol } }" "package com.rs.game.content.skills.dungeoneering.npcs.misc; public class DungeonFishSpot extends DungeonNPC { private final Fish fish; private int fishes; public DungeonFishSpot(int id, Tile tile, DungeonManager manager, Fish fish) { super(id, tile, manager); this.fish = fish; this.fishes = 14; setName(Utils.formatPlayerNameForDisplay(fish.toString())); } @Override public void processNPC() { } public Fish getFish() { return fish; } public int decreaseFishes() { return fishes--; } public void addFishes() { fishes += Utils.random(5, 10); } }" "package com.rs.game.content.skills.dungeoneering.npcs.misc; public class DungeonHunterNPC extends DungeonNPC { public DungeonHunterNPC(int id, Tile tile, DungeonManager manager) { super(id, tile, manager); } @Override public void processNPC() { if (isCantInteract() || getId() >= 11096 || getManager() == null) return; super.processNPC(); List traps = getManager().getMastyxTraps(); if (traps.isEmpty()) return; final int tier = DungeoneeringTraps.getNPCTier(getId()); for (final MastyxTrap trap : traps) { if (!withinDistance(trap.getTile(), 3) || Utils.getRandomInclusive(3) != 0) continue; trap.setCantInteract(true); setCantInteract(true); setNextFaceEntity(trap); addWalkSteps(trap.getX() + 1, trap.getY() + 1); final int trap_tier = trap.getTier(); double successRatio = getSuccessRatio(tier, trap_tier); final boolean failed = successRatio < Math.random(); setCantInteract(true); if (failed) WorldTasks.scheduleTimer((ticks) -> { if (ticks == 5) anim(13264); else if (ticks == 8) { trap.transformIntoNPC(1957); trap.spotAnim(2561 + trap_tier); } else if (ticks == 16) { getManager().removeMastyxTrap(trap); setCantInteract(false); return false; } return true; }); else WorldTasks.scheduleTimer((ticks) -> { if (ticks == 9) { trap.transformIntoNPC(1957); trap.spotAnim(2551 + trap_tier); } else if (ticks == 13) anim(13260); else if (ticks == 18) transformIntoNPC(getId() + 10); else if (ticks == 20) { setCantInteract(false); getManager().removeMastyxTrap(trap); return false; } return true; }); } } @Override public void drop() { /*World.addGroundItem(new Item(532), Tile.of(this)); //big bones Drops drops = NPCDrops.getDrops(getId()); if (drops == null) return; Drop drop = drops.getDrop(Drops.COMMOM, Double.MAX_VALUE); //to make 100% chance if (drop == null) //shouldnt return; World.addGroundItem(new Item(drop.getItemId()), Tile.of(this)); //hide*/ } private static double getSuccessRatio(int tier, int trapTier) { double successRatio = 0.0; int tierProduct = trapTier - tier; if (tierProduct == 0) successRatio = 0.5; else if (tierProduct > 0) successRatio = 0.5 + (tierProduct / 10.0); if (successRatio > 0.9) successRatio = 0.9; return successRatio; } }" "package com.rs.game.content.skills.dungeoneering.rooms; public class BossRoom extends HandledRoom { private final int minFloor; private final int musicId; public BossRoom(RoomEvent event, int musicId, int minFloor, int chunkX, int chunkY) { super(chunkX, chunkY, event, null, DungeonConstants.SOUTH_DOOR); this.minFloor = minFloor; this.musicId = musicId; } public int getMinFloor() { return minFloor; } public int getMusicId() { return musicId; } @Override public boolean allowResources() { return false; } // @Override // public final boolean allowSpecialDoors() { // return false; // } }" "package com.rs.game.content.skills.dungeoneering.rooms; public class HandledPuzzleRoom extends HandledRoom { private final Puzzle puzzle; public HandledPuzzleRoom(int i, Puzzle puzzle) { this(i, puzzle, null); } public HandledPuzzleRoom(int i, Puzzle puzzle, RoomEvent event) { super(puzzle.getChunkX(), 528 + (i * 2), event, puzzle.getKeySpot(i), DungeonConstants.PUZZLE_DOOR_ORDER[i]); this.puzzle = puzzle; } // @Override // public final boolean allowSpecialDoors() { // return false; // } @Override public boolean isComplexity(int complexity) { return complexity == 6; } public VisibleRoom createVisibleRoom() { return puzzle.newInstance(); } @Override public boolean isAvailableOnFloorType(int floorType) { return puzzle.isAvailableOnFloorType(floorType); } @Override public boolean allowResources() { return puzzle.allowResources(); } }" "package com.rs.game.content.skills.dungeoneering.rooms; public class HandledRoom { private final int chunkX, chunkY; private final int[] doorsDirections; private final RoomEvent event; private final int[] keySpot; public HandledRoom(int chunkX, int chunkY, RoomEvent event, int[] keySpot, int... doorDirections) { this.chunkX = chunkX; this.chunkY = chunkY; this.event = event; doorsDirections = doorDirections; this.keySpot = keySpot; } public HandledRoom(int chunkX, int chunkY, RoomEvent event, int... doorsDirections) { this(chunkX, chunkY, event, null, doorsDirections); } public HandledRoom(int chunkX, int chunkY, int... doorsDirections) { this(chunkX, chunkY, null, null, doorsDirections); } public int getChunkX() { return chunkX; } public int getChunkY() { return chunkY; } public int[] getDoorDirections() { return doorsDirections; } public RoomEvent getRoomEvent() { return event; } public boolean hasSouthDoor(int rotation) { return hasDoor(rotation == 0 ? DungeonConstants.SOUTH_DOOR : rotation == 1 ? DungeonConstants.EAST_DOOR : rotation == 2 ? DungeonConstants.NORTH_DOOR : DungeonConstants.WEST_DOOR); } public boolean hasNorthDoor(int rotation) { return hasDoor(rotation == 0 ? DungeonConstants.NORTH_DOOR : rotation == 1 ? DungeonConstants.WEST_DOOR : rotation == 2 ? DungeonConstants.SOUTH_DOOR : DungeonConstants.EAST_DOOR); } public boolean hasWestDoor(int rotation) { return hasDoor(rotation == 0 ? DungeonConstants.WEST_DOOR : rotation == 1 ? DungeonConstants.SOUTH_DOOR : rotation == 2 ? DungeonConstants.EAST_DOOR : DungeonConstants.NORTH_DOOR); } public boolean hasEastDoor(int rotation) { return hasDoor(rotation == 0 ? DungeonConstants.EAST_DOOR : rotation == 1 ? DungeonConstants.NORTH_DOOR : rotation == 2 ? DungeonConstants.WEST_DOOR : DungeonConstants.SOUTH_DOOR); } public boolean hasDoor(int direction) { for (int dir : doorsDirections) if (dir == direction) return true; return false; } public boolean isComplexity(int complexity) { return true; } public void openRoom(DungeonManager dungeon, RoomReference reference) { if (event == null) return; event.openRoom(dungeon, reference); } // public boolean allowSpecialDoors() { // return true; // } public boolean allowResources() { return true; } public boolean isAvailableOnFloorType(int floorType) { return true; } public int[] getKeySpot() { return keySpot; } }" "package com.rs.game.content.skills.dungeoneering.rooms; public final class NormalRoom extends HandledRoom { @Deprecated public NormalRoom(int chunkX, int chunkY, int... doorsDirections) { this(chunkX, chunkY, null, doorsDirections); } public NormalRoom(int chunkX, int chunkY, int[] keyspot, int... doorsDirections) { super(chunkX, chunkY, new SpawnRandomNpcsEvent(), keyspot, doorsDirections); } }" "package com.rs.game.content.skills.dungeoneering.rooms; public abstract class PuzzleRoom extends VisibleRoom { private boolean complete; private final int[] requirements = new int[25], giveXPCount = new int[25]; public final boolean hasRequirement(Player p, int skill) { return p.getSkills().getLevel(skill) >= getRequirement(skill); } public final int getRequirement(int skill) { setLevel(skill); return requirements[skill]; } public final void giveXP(Player player, int skill) { if (giveXPCount[skill] < 4) { //You only gain xp for the first 4 times you do an action giveXPCount[skill]++; player.getSkills().addXp(skill, getRequirement(skill) * 5 +10); } } private void setLevel(int skill) { if (requirements[skill] == 0) requirements[skill] = !manager.getRoom(reference).isCritPath() ? Utils.random(30, skill == Constants.SUMMONING || skill == Constants.PRAYER ? 100 : 106) : Math.max(1, (manager.getParty().getMaxLevel(skill) - Utils.random(10))); } public void replaceObject(GameObject object, int newId) { if(object == null) return; GameObject newObject = new GameObject(object); newObject.setId(newId); World.spawnObject(newObject); } public boolean isComplete() { return complete; } public void setComplete() { complete = true; if (getCompleteMessage() != null) manager.message(reference, getCompleteMessage()); manager.getRoom(reference).removeChallengeDoors(); } public String getCompleteMessage() { return ""You hear a clunk as the doors unlock.""; } public String getLockMessage() { return ""The door is locked. You can't see any obvious keyhole or mechanism.""; } }" "package com.rs.game.content.skills.dungeoneering.rooms; public interface RoomEvent { void openRoom(DungeonManager dungeon, RoomReference reference); }" "package com.rs.game.content.skills.dungeoneering.rooms; public class SpawnRandomNpcsEvent implements RoomEvent { @Override public void openRoom(DungeonManager dungeon, RoomReference reference) { dungeon.spawnRandomNPCS(reference); } }" "package com.rs.game.content.skills.dungeoneering.rooms; public final class StartRoom extends HandledRoom { public StartRoom(int chunkX, int chunkY, int... doorsDirections) { super(chunkX, chunkY, (RoomEvent) (dungeon, reference) -> { dungeon.telePartyToRoom(reference); dungeon.spawnNPC(reference, DungeonConstants.SMUGGLER, 8, 8).setRandomWalk(false); // smoother dungeon.setTableItems(reference); dungeon.linkPartyToDungeon(); }, new int[] {7, 7}, doorsDirections); } @Override public boolean allowResources() { return false; } }" "package com.rs.game.content.skills.dungeoneering.rooms.puzzles; public class ColouredRecessRoom extends PuzzleRoom { public static final int[] SHELVES = { 35243, 35242, 35241, 35245, 35246 }; //+1-4 for colors public static final int[] BASE_BLOCKS = { 13024, 13029, 13034, 13039, 13044 }; public static final int[][] LOCATIONS = { { 5, 10 }, { 10, 10 }, { 10, 5 }, { 5, 5 }, }; private Block[] blocks; private boolean[] used; @Override public void openRoom() { manager.spawnRandomNPCS(reference); blocks = new Block[4]; used = new boolean[4]; for (int i = 0; i < blocks.length; i++) while_: while (true) { Tile tile = manager.getTile(reference, 4 + Utils.random(8), 4 + Utils.random(8)); if (!World.floorFree(tile, 1)) continue; for (int j = 0; j < i; j++) if (blocks[j].matches(tile)) continue while_; blocks[i] = new Block(tile); break; } } public void checkComplete() { if(isComplete()) return; outer: for (Block block : blocks) { for (int tileColor = 0; tileColor < LOCATIONS.length; tileColor++) { int[] location = LOCATIONS[tileColor]; if (manager.getTile(reference, location[0], location[1]).matches(block.getTile())) { int color = block.getId() - BASE_BLOCKS[type] - 1; if (color == tileColor) continue outer; return; } } return; } setComplete(); } public class Block extends DungeonNPC { public Block(Tile tile) { super(BASE_BLOCKS[type], tile, manager); } public void handle(final Player player, final boolean push) { //TODO: make sure 2 players can't move 2 statues ontop of eachother in the same tick? although it doesn't really matter boolean pull = !push; int[] nPos = manager.getRoomPos(getTile()); int[] pPos = manager.getRoomPos(player.getTile()); final int dx = push ? getX() - player.getX() : player.getX() - getX(); final int dy = push ? getY() - player.getY() : player.getY() - getY(); final int ldx = push ? nPos[0] - pPos[0] : pPos[0] - nPos[0]; final int ldy = push ? nPos[1] - pPos[1] : pPos[1] - nPos[1]; if (nPos[0] + ldx < 4 || nPos[0] + ldx > 11 || nPos[1] + ldy < 4 || nPos[1] + ldy > 11) { player.sendMessage(""You cannot push the block there.""); return; } final Tile nTarget = transform(dx, dy, 0); final Tile pTarget = player.transform(dx, dy, 0); if (!World.floorFree(nTarget, 1) || !World.floorFree(pTarget, 1)) { player.sendMessage(""Something is blocking the way.""); return; } if (!ColouredRecessRoom.this.canMove(null, nTarget) || (pull && !ColouredRecessRoom.this.canMove(null, pTarget))) { player.sendMessage(""A block is blocking the way.""); return; } for (Player team : manager.getParty().getTeam()) if (team != player && team.matches(nTarget)) { player.sendMessage(""A party member is blocking the way.""); return; } player.lock(2); WorldTasks.scheduleLooping(new Task() { private boolean moved; @Override public void run() { if (!moved) { moved = true; addWalkSteps(getX() + dx, getY() + dy); player.forceMove(pTarget, push ? 3065 : 3065, 5, 30); } else { checkComplete(); stop(); } } }, 0, 0); } public boolean useItem(Player player, Item item) { int color = (item.getId() - 19869) / 2; if (color < 0 || color > 3 || (getId() != BASE_BLOCKS[type]) || used[color]) return true; used[color] = true; player.getInventory().deleteItem(item); player.setNextAnimation(new Animation(832)); transformIntoNPC(getId() + color + 1); checkComplete(); return false; } } @Override public boolean canMove(Player player, Tile to) { for (Block block : blocks) if (to.matches(block.getTile())) return false; return true; } private static void getVial(Player p, int itemId) { if (Math.random() < 0.2) { p.sendMessage(""The vial reacts explosively as you pick it up.""); p.applyHit(new Hit(p, (int) (p.getMaxHitpoints() * 0.25D), Hit.HitLook.TRUE_DAMAGE)); return; } p.getInventory().addItem(itemId, 1); p.setNextAnimation(new Animation(832)); } @Override public boolean processObjectClick1(Player p, GameObject object) { if (object.getId() == SHELVES[type]) { p.startConversation(new Dialogue() .addOptions(""Choose an option:"", (ops) -> { ops.add(""Blue vial."", () -> getVial(p, 19869)); ops.add(""Green vial."", () -> getVial(p, 19871)); ops.add(""Yellow vial."", () -> getVial(p, 19873)); ops.add(""Violet vial."", () -> getVial(p, 19875)); })); return false; } return true; } @Override public boolean processNPCClick1(Player player, NPC npc) { if (npc instanceof Block block) { block.handle(player, true); return false; } return true; } @Override public boolean processNPCClick2(Player player, NPC npc) { if (npc instanceof Block block) { block.handle(player, false); return false; } return true; } }" "package com.rs.game.content.skills.dungeoneering.rooms.puzzles; public class CrystalPuzzleRoom extends PuzzleRoom { private static final int ANIM_CHARGE_LODESTONE = 833; // Lodestone base location private static final int[] POS_BASE_LODESTONE = { 10, 1 }; // Large crystal in the center private static final int[] POS_CENTER = { 7, 8 }; // Direction for each color private static final int[][] POS_DELTA = { { 1, 0 }, { 0, -1 }, { -1, 0 }, { 0, 1 }, }; // Pressure plate location for each color private static final int[][] POS_PLATE = { { 2, 8 }, { 7, 13 }, { 12, 8 }, { 7, 3 }, }; // Large center crystal lighting private static final int[] LARGE_CRYSTAL_OFF = { 49507, 49508, 49509, 54275, 34866 }; private static final int[] LARGE_CRYSTAL_FLASH = { 49510, 49511, 49512, 54276, 35070 }; private static final int[] LARGE_CRYSTAL_ON = { 49513, 49514, 49515, 54277, 35231 }; // Tile lighting private static final int[] TILE_INACTIVE = { 49465, 49466, 49467, 54261, 34317 }; private static final int[][] TILE_ACTIVE = { { 49468, 49469, 49470, 54262, 34319 }, { 49477, 49478, 49479, 54265, 34848 }, { 49486, 49487, 49488, 54268, 34856 }, { 49495, 49496, 49497, 54271, 34862 } }; // Pressure plates // private static final int[] PLATE = { 52206, 52206, 52206, 54282, 35232 }; // Active lodestone id's private static final int[][] LODESTONE_ACTIVE = { { 49474, 49475, 49476, 54264, 34847 }, { 49483, 49484, 49485, 54267, 34855 }, { 49492, 49493, 49494, 54270, 34861 }, { 49501, 49502, 49503, 54273, 34864 }, }; // Inactive lodestone id's private static final int[][] LODESTONE_INACTIVE = { { 49471, 49472, 49473, 54263, 34320 }, { 49480, 49481, 49482, 54266, 34852 }, { 49489, 49490, 49491, 54269, 34860 }, { 49498, 49499, 49500, 54272, 34863 }, }; private boolean[] active; private int[][] energyTile; private TileTask task; @Override public void openRoom() { manager.spawnRandomNPCS(reference); type = manager.getParty().getFloorType(); active = new boolean[4]; energyTile = new int[4][2]; int activeCount = 0; for (int color = 0; color < 4; color++) if (Math.random() > 0.66 && activeCount++ != 3) { resetPosition(color); World.spawnObject(new GameObject(LODESTONE_ACTIVE[color][type], ObjectType.SCENERY_INTERACT, 0, manager.getTile(reference, POS_BASE_LODESTONE[0] + color, POS_BASE_LODESTONE[1] + color))); } else World.spawnObject(new GameObject(LODESTONE_INACTIVE[color][type], ObjectType.SCENERY_INTERACT, 0, manager.getTile(reference, POS_BASE_LODESTONE[0] + color, POS_BASE_LODESTONE[1] + color))); task = new TileTask(); WorldTasks.scheduleLooping(task, 0, 0); } @Override public boolean processObjectClick1(Player p, GameObject object) { for (int color = 0; color < 4; color++) if (object.getId() == LODESTONE_INACTIVE[color][type]) { if (!hasRequirement(p, Constants.MAGIC)) { p.sendMessage(""You need a magic level of "" + getRequirement(Constants.MAGIC) + "" to power this lodestone.""); return false; } giveXP(p, Constants.MAGIC); p.setNextAnimation(new Animation(ANIM_CHARGE_LODESTONE)); p.lock(1); resetPosition(color); World.spawnObject(new GameObject(LODESTONE_ACTIVE[color][type], ObjectType.SCENERY_INTERACT, 0, manager.getTile(reference, POS_BASE_LODESTONE[0] + color, POS_BASE_LODESTONE[1] + color))); p.sendMessage(""You reach out and find the lodestone's power source. You spark it into life.""); return false; } return true; } private void resetPosition(int color) { active[color] = true; energyTile[color][0] = POS_PLATE[color][0] + POS_DELTA[color][0]; energyTile[color][1] = POS_PLATE[color][1] + POS_DELTA[color][1]; World.spawnObject(new GameObject(TILE_ACTIVE[color][type], ObjectType.GROUND_DECORATION, 0, manager.getTile(reference, energyTile[color][0], energyTile[color][1]))); } @Override public String getCompleteMessage() { return ""You hear a click. All the doors in the room are now unlocked.""; } public class TileTask extends Task { @Override public void run() { synchronized (manager) { if (manager.isDestroyed() || reference == null) { stop(); return; } outer: for (int color = 0; color < 4; color++) { // Make sure it's actually active if (!active[color]) continue; // ... and nobody is standing on it for (Player player : manager.getParty().getTeam()) { Tile last = player.getTile(); if (player.getLastTile() != null) last = player.getLastTile(); Tile tile = manager.getTile(reference, POS_PLATE[color][0], POS_PLATE[color][1]); if (tile == null) return; if (last.withinDistance(tile, 0)) continue outer; } // Remove current tile World.spawnObject(new GameObject(TILE_INACTIVE[type], ObjectType.GROUND_DECORATION, 0, manager.getTile(reference, energyTile[color][0], energyTile[color][1]))); // Rewind position if it's in the center if (energyTile[color][0] == POS_CENTER[0] && energyTile[color][1] == POS_CENTER[1]) resetPosition(color); else { // Actually move it energyTile[color][0] += POS_DELTA[color][0]; energyTile[color][1] += POS_DELTA[color][1]; World.spawnObject(new GameObject(TILE_ACTIVE[color][type], ObjectType.GROUND_DECORATION, 0, manager.getTile(reference, energyTile[color][0], energyTile[color][1]))); } } // Check if puzzle is complete boolean complete = true; boolean any = false; for (int color = 0; color < 4; color++) if (energyTile[color][0] != POS_CENTER[0] || energyTile[color][1] != POS_CENTER[1]) complete = false; else any = true; if (complete) { World.spawnObject(new GameObject(LARGE_CRYSTAL_ON[type], ObjectType.SCENERY_INTERACT, 0, manager.getTile(reference, POS_CENTER[0], POS_CENTER[1]))); setComplete(); stop(); task = null; } else if (any) World.spawnObject(new GameObject(LARGE_CRYSTAL_FLASH[type], ObjectType.SCENERY_INTERACT, 0, manager.getTile(reference, POS_CENTER[0], POS_CENTER[1]))); else World.spawnObject(new GameObject(LARGE_CRYSTAL_OFF[type], ObjectType.SCENERY_INTERACT, 0, manager.getTile(reference, POS_CENTER[0], POS_CENTER[1]))); } } } @Override public void destroy() { if (task != null) { task.stop(); task = null; } } }" "package com.rs.game.content.skills.dungeoneering.rooms.puzzles; public class FishingFerretRoom extends PuzzleRoom { private static final int FERRET_ID = 11007, VILE_FISH = 17375; private static final int[] PRESSURE_PLATE = { 49555, 49557, 49559, 54296, 54297 }; private static final int[] EMPTY_PLATE = { 49546, 49547, 49548, 54293, 35293 }; private Tile pressurePlate; private List vileFishes; private DungeonFishSpot psuedoFishingSpot;// Cheap hax private int fished = 3; private int cooked = 3; public class Ferret extends DungeonNPC { public Ferret(int id, Tile tile, DungeonManager manager) { super(id, tile, manager); } @Override public void processNPC() { if (isComplete())//We will keep it spawned but it won't do shit :D return; if (getWalkSteps().isEmpty()) { if (getX() == pressurePlate.getX() && getY() == pressurePlate.getY()) { setComplete(); psuedoFishingSpot.finish(); psuedoFishingSpot = null; removeAllVileFish(); return; } if (!vileFishes.isEmpty()) { GroundItem item = vileFishes.getFirst();//Goes in chronological order if (item == null) return; Tile tile = item.getTile(); if (matches(tile)) { removeVileFish(); return; } addWalkSteps(tile.getX(), tile.getY(), -1, false); } } else {// Should be fine won't be checked often anyways GameObject o = World.getObjectWithType(getTile(), ObjectType.GROUND_DECORATION); if (o != null && o.getDefinitions().getName().equals(""Hole"")) { setNextAnimation(new Animation(13797)); WorldTasks.schedule(new Task() { @Override public void run() { resetWalkSteps(); tele(getRespawnTile()); setNextAnimation(new Animation(-1)); removeAllVileFish(); } }); } } super.processNPC(); } } private void removeVileFish() { World.removeGroundItem(vileFishes.removeFirst()); } public void removeAllVileFish() { for (GroundItem fish : vileFishes) World.removeGroundItem(fish); vileFishes.clear(); } @Override public void openRoom() { int[][] possibleCorners = null; outer: for (int x = 0; x < 15; x++) for (int y = 0; y < 15; y++) { GameObject object = manager.getObjectWithType(reference, ObjectType.GROUND_DECORATION, x, y); if (object != null && (object.getDefinitions().getName().equals(""Tile"") || object.getDefinitions().getName().equals(""Hole""))) { possibleCorners = new int[][] { { x + 6, y, x, y + 6 }, { x, y, x + 6, y + 6 } }; break outer; } } vileFishes = new LinkedList<>(); boolean invertChunks = Utils.random(2) == 0; int[] cornerChunks = possibleCorners[Utils.random(possibleCorners.length)]; pressurePlate = manager.getRotatedTile(reference, cornerChunks[invertChunks ? 2 : 0], cornerChunks[invertChunks ? 3 : 1]); Ferret puzzleNPC = new Ferret(FERRET_ID, manager.getRotatedTile(reference, cornerChunks[invertChunks ? 0 : 2], cornerChunks[invertChunks ? 1 : 3]), manager); psuedoFishingSpot = new DungeonFishSpot(1957, manager.getRotatedTile(reference, 7, 13), manager, Fish.VILE_FISH); int floorType = manager.getParty().getFloorType(); World.spawnObject(new GameObject(PRESSURE_PLATE[floorType], ObjectType.GROUND_DECORATION, 0, pressurePlate)); World.spawnObject(new GameObject(EMPTY_PLATE[floorType], ObjectType.GROUND_DECORATION, 0, puzzleNPC.getTile())); } @Override public boolean processObjectClick1(Player player, GameObject object) { if (object.getDefinitions().getName().equals(""Fishing spot"")) { int requiredFishing = getRequirement(Constants.FISHING); if (psuedoFishingSpot == null) return true; if (requiredFishing > player.getSkills().getLevel(Constants.FISHING)) { player.sendMessage(""You need a Fishing level of "" + requiredFishing + "" to catch a raw vile fish.""); return false; } if (fished-- > 0) giveXP(player, Constants.FISHING); player.getActionManager().setAction(new DungeoneeringFishing(psuedoFishingSpot)); return false; } return true; } public static boolean handleFerretThrow(final Player player, final GameObject object, final Item item) { if ((!object.getDefinitions().getName().equals(""Tile"") && !object.getDefinitions().getName().equals(""Pressure plate"")) || item.getId() != VILE_FISH || player.getControllerManager().getController() == null || !(player.getControllerManager().getController() instanceof DungeonController)) return false; DungeonManager manager = player.getDungManager().getParty().getDungeon(); VisibleRoom room = manager.getVisibleRoom(manager.getCurrentRoomReference(player.getTile())); if (!(room instanceof FishingFerretRoom puzzle)) return false; if (puzzle.isComplete()) { player.sendMessage(""I know it smells, but littering is wrong!""); return false; } int requiredRange = puzzle.getRequirement(Constants.RANGE); if (player.getSkills().getLevel(Constants.RANGE) < requiredRange) { player.sendMessage(""You need a Range level of "" + requiredRange + "" to throw a vile fish.""); return false; } player.lock(2); player.setNextAnimation(new Animation(13325)); player.setNextSpotAnim(new SpotAnim(2521)); player.getInventory().deleteItem(item); player.faceObject(object); player.sendMessage(""You throw the fish.""); WorldProjectile p = World.sendProjectile(player, object, 2522, 32, 0, 25, 1, 15, 0); WorldTasks.schedule(new Task() { @Override public void run() { World.sendSpotAnim(object.getTile(), new SpotAnim(2523)); World.addGroundItem(item, object.getTile(), null, false, 0, DropMethod.NORMAL, 40); puzzle.getVileFishes().add(ChunkManager.getChunk(object.getTile().getChunkId()).getGroundItem(item.getId(), object.getTile(), player)); } }, p.getTaskDelay()); return true; } @Override public boolean handleItemOnObject(Player player, GameObject object, Item item) { if (object.getDefinitions().getName().equals(""Fire"") && item.getId() == 17374) { int requiredCooking = getRequirement(Constants.COOKING); if (player.getSkills().getLevel(Constants.COOKING) < requiredCooking) { player.sendMessage(""You need a Cooking level of "" + requiredCooking + "" to cook a raw vile fish.""); return false; } if (cooked-- > 0) giveXP(player, Constants.COOKING); player.getInventory().deleteItem(17374, 1); player.getInventory().addItem(VILE_FISH, 1); return false; } return true; } protected List getVileFishes() { return vileFishes; } @Override public String getCompleteMessage() { return ""You hear a click as the ferret steps on the pressure plate. All the doors in the room are now unlocked.""; } }" "package com.rs.game.content.skills.dungeoneering.rooms.puzzles; public class FlipTilesRoom extends PuzzleRoom { private static final int BASE_TILE = 49637; private static final int YELLOW_TO_GREEN = 13781; private static final int GREEN_TO_YELLOW = 13782; private static final int GREEN = 49638; private static final int YELLOW = 49642; private GameObject[][] tiles; private int xOffset; private int yOffset; @Override public void openRoom() { manager.spawnRandomNPCS(reference); tiles = new GameObject[5][5]; outer: for (int x = 0; x < 15; x++) for (int y = 0; y < 15; y++) { GameObject object = manager.getObjectWithType(reference, ObjectType.GROUND_DECORATION, x, y); if (object != null && object.getId() == BASE_TILE) { xOffset = x; yOffset = y; break outer; } } for (int x = 0; x < 5; x++) for (int y = 0; y < 5; y++) { //Apparently not every configuration is solveable but eh, thats what the force option is for! tiles[x][y] = new GameObject(Math.random() > 0.5 ? GREEN : YELLOW, ObjectType.GROUND_DECORATION, 0, manager.getTile(reference, x + xOffset, y + yOffset)); World.spawnObject(tiles[x][y]); } } @Override public boolean processObjectClick1(Player p, GameObject object) { String name = object.getDefinitions().getName(); if (name.equals(""Green tile"") || name.equals(""Yellow tile"")) { p.lock(2); p.setNextAnimation(new Animation(7660)); int[] pos = manager.getRoomPos(object.getTile()); Set objects = getAdjacent(pos[0] - xOffset, pos[1] - yOffset); for (GameObject tile : objects) flipTile(tile); checkComplete(); return false; } return true; } @Override public boolean processObjectClick2(Player p, GameObject object) { String name = object.getDefinitions().getName(); if (name.equals(""Green tile"") || name.equals(""Yellow tile"")) { p.sendMessage(""You force the tile without changing adjacent tiles, and the released energy harms you.""); p.applyHit(new Hit(p, (int) (p.getMaxHitpoints() * .2), HitLook.TRUE_DAMAGE)); p.lock(2); p.setNextAnimation(new Animation(13695)); int[] pos = manager.getRoomPos(object.getTile()); flipTile(tiles[pos[0] - xOffset][pos[1] - yOffset]); checkComplete(); return false; } return true; } public void flipTile(final GameObject tile) { final int id = tile.getId(); tile.setId(id == GREEN ? YELLOW : GREEN); //instantly update so 2 players pressing the same tiles at once will not bug it out, although visual may be weird, rs might lock the whole puzzle up for 1 sec, not sure tho for (Player team : manager.getParty().getTeam()) team.getPackets().sendObjectAnimation(tile, new Animation(id == GREEN ? GREEN_TO_YELLOW : YELLOW_TO_GREEN)); WorldTasks.scheduleTimer(1, (ticks) -> { World.spawnObject(new GameObject(id == GREEN ? YELLOW : GREEN, ObjectType.GROUND_DECORATION, 0, tile.getTile())); return false; }); } @Override public String getCompleteMessage() { return ""You hear a click as the last tile flips. All the doors in the room are now unlocked.""; } private void checkComplete() { if (isComplete()) return; //You can still flip tiles after puzzle is complete, but don't do any checks int first = tiles[0][0].getId(); for (int x = 0; x < 5; x++) for (int y = 0; y < 5; y++) if (first != tiles[x][y].getId()) return; setComplete(); } private Set getAdjacent(int x, int y) { Set set = new HashSet<>(); set.add(tiles[x][y]); if (x > 0) set.add(tiles[x - 1][y]); if (x < 4) set.add(tiles[x + 1][y]); if (y < 4) set.add(tiles[x][y + 1]); if (y > 0) set.add(tiles[x][y - 1]); return set; } }" "package com.rs.game.content.skills.dungeoneering.rooms.puzzles; public class FlowerRootsRoom extends PuzzleRoom { //order: blue, purple, red, yellow, big plant 7 ticks, small plants 14 ticks //bprybpry //BbpprryY //pPRryybb //rryYBbpp //yybbpPRr private static final int[] DOOR_LEAVES = { 35838, 35839, 35842, 35847, 35849 }; private static final int[][][] PLANTS = { { //LARGE { 35507, 35520 }, { 35523, 35525 }, { 35562, 35568 }, { 35569, 35576 } }, { //SMALL 1 { 35577, 35588 }, { 35602, 35604 }, { 35606, 35609 }, { 35611, 35613 } }, { //SMALL 2 { 35616, 35625 }, { 35655, 35685 }, { 35689, 35708 }, { 35709, 35712 } }, { //SMALL 3 { 35715, 35718 }, { 35719, 35720 }, { 35734, 35739 }, { 35778, 35780 } }, { //SMALL 4 { 35799, 35800 }, { 35804, 35808 }, { 35809, 35812 }, { 35830, 35835 } }, }; //TODO: need end animations: tested 14900-15200 14954 could be useable private static final int BIG_FLOWER_DESPAWN = 14954; private static final int SMALL_FLOWER_DESPAWN = 14954; private static final int LEAF_DESPAWN = 14954; private Plant[][] plants; private Task colorTask; private Task objectTask; private Plant bigPlant; private Set leaves; @Override public void openRoom() { manager.spawnRandomNPCS(reference); leaves = new HashSet<>(); plants = new Plant[16][16]; for (int x = 0; x < 16; x++) for (int y = 0; y < 16; y++) { GameObject object = manager.getObjectWithType(reference, ObjectType.SCENERY_INTERACT, x, y); if (object != null) for (int type = 0; type < 5; type++) { if (object.getId() == DOOR_LEAVES[type]) { leaves.add(object); break; } for (int color = 0; color < 4; color++) if (object.getId() == PLANTS[type][color][0]) { plants[x][y] = new Plant(); plants[x][y].type = type; plants[x][y].currentColor = color; if (type == 0) bigPlant = plants[x][y]; } } } colorTask = new ChangeColorTask(); objectTask = new ChangeObjectTask(); WorldTasks.scheduleLooping(colorTask, 0, 6); WorldTasks.scheduleLooping(objectTask, 4, 6); //color animation is 3 ticks } @Override public boolean processObjectClick1(final Player player, final GameObject object) { for (int type = 0; type < 5; type++) for (int color = 0; color < 4; color++) if (object.getId() == PLANTS[type][color][0] || object.getId() == PLANTS[type][color][1]) { //[1] is clickable for big plant aswell final int[] coords = manager.getRoomPos(object.getTile()); if (type == 0) { if (!hasRequirement(player, Constants.FARMING)) { player.sendMessage(""You need a farming level of "" + getRequirement(Constants.FARMING) + "" to uproot this plant.""); return false; } giveXP(player, Constants.FARMING); player.lock(2); player.setNextAnimation(new Animation(3685)); setComplete(); return false; } if (plants[coords[0]][coords[1]].currentColor != bigPlant.currentColor) { player.applyHit(new Hit(player, (int) (player.getMaxHitpoints() * .15), HitLook.TRUE_DAMAGE)); return false; } if (!hasRequirement(player, Constants.WOODCUTTING)) { player.sendMessage(""You need a woodcutting level of "" + getRequirement(Constants.WOODCUTTING) + "" to chop down this plant.""); return false; } DungHatchet defs = DungHatchet.getHatchet(player); if (defs == null) { player.sendMessage(""You do not have a hatchet or do not have the required level to use the hatchet.""); return false; } if (plants[coords[0]][coords[1]].locked) //already being used by other player return false; plants[coords[0]][coords[1]].locked = true; player.setNextAnimation(new Animation(defs.getEmoteId())); player.lock(4); for (Player team : manager.getParty().getTeam()) team.getPackets().sendObjectAnimation(object, new Animation(SMALL_FLOWER_DESPAWN)); WorldTasks.schedule(new Task() { @Override public void run() { giveXP(player, Constants.WOODCUTTING); player.setNextAnimation(new Animation(-1)); plants[coords[0]][coords[1]] = null; manager.spawnObject(reference, -1, ObjectType.SCENERY_INTERACT, 0, coords[0], coords[1]); } }, 3); return false; } return true; } @Override public void setComplete() { if (manager.isDestroyed()) return; for (Player team : manager.getParty().getTeam()) { for (int x = 0; x < 16; x++) for (int y = 0; y < 16; y++) { Plant p = plants[x][y]; if (p != null) { p.locked = true; if (p.type == 0) team.getPackets().sendObjectAnimation(manager.getObjectWithType(reference, ObjectType.SCENERY_INTERACT, x, y), new Animation(BIG_FLOWER_DESPAWN)); else team.getPackets().sendObjectAnimation(manager.getObjectWithType(reference, ObjectType.SCENERY_INTERACT, x, y), new Animation(SMALL_FLOWER_DESPAWN)); } } for (GameObject leaf : leaves) team.getPackets().sendObjectAnimation(leaf, new Animation(LEAF_DESPAWN)); } WorldTasks.schedule(new Task() { @Override public void run() { for (int x = 0; x < 16; x++) for (int y = 0; y < 16; y++) { Plant p = plants[x][y]; if (p != null) { plants[x][y] = null; manager.spawnObject(reference, -1, ObjectType.SCENERY_INTERACT, 0, x, y); } } for (GameObject leaf : leaves) World.removeObject(leaf); } }, 1); destroy(); super.setComplete(); } public class ChangeColorTask extends Task { boolean odd; @Override public void run() { synchronized (manager) { if (manager == null || manager.isDestroyed()) { stop(); return; } for (int x = 0; x < 16; x++) for (int y = 0; y < 16; y++) { Plant p = plants[x][y]; if (p != null && !p.locked) if (p.type == 0 || odd) { replaceObject(manager.getObjectWithType(reference, ObjectType.SCENERY_INTERACT, x, y), PLANTS[p.type][p.currentColor][1]); p.currentColor++; p.currentColor &= 0x3; } } } odd = !odd; } } public class ChangeObjectTask extends Task { boolean odd; @Override public void run() { synchronized (manager) { if (manager == null || manager.isDestroyed()) { stop(); return; } for (int x = 0; x < 16; x++) for (int y = 0; y < 16; y++) { Plant p = plants[x][y]; if (p != null && !p.locked) if (p.type == 0 || odd) replaceObject(manager.getObjectWithType(reference, ObjectType.SCENERY_INTERACT, x, y), PLANTS[p.type][p.currentColor][0]); } } odd = !odd; } } public class Plant { public boolean locked; private int type; private int currentColor; } @Override public void destroy() { if (colorTask != null) { colorTask.stop(); colorTask = null; } if (objectTask != null) { objectTask.stop(); objectTask = null; } } }" "package com.rs.game.content.skills.dungeoneering.rooms.puzzles; public class FremennikCampRoom extends PuzzleRoom { public static final int FREMENNIK_SCOUT = 11001; private static final int[] RAW_FISH = { 49522, 49523, 49524, 49524, 49524 }; private static final int[] COOKED_FISH = { 49525, 49526, 49527, 49527, 49527 }; private static final int[] BARS = { 49528, 49529, 49530, 49530, 49530 }; private static final int[] BATTLE_AXES = { 49531, 49532, 49533, 49533, 49533 }; private static final int[] LOGS = { 49534, 49535, 49536, 49536, 49536 }; private static final int[] BOWS = { 49537, 49538, 49539, 49539, 49539 }; private int stage = 0; @Override public void openRoom() { manager.spawnNPC(reference, FREMENNIK_SCOUT, 8, 5, false, DungeonConstants.NORMAL_NPC); } @Override public boolean processObjectClick1(Player player, GameObject object) { if (object.getId() == RAW_FISH[type]) { if (!hasRequirement(player, Constants.COOKING)) { player.sendMessage(""You need a cooking level of "" + getRequirement(Constants.COOKING) + "" to cook these fish.""); return false; } giveXP(player, Constants.COOKING); replaceObject(object, COOKED_FISH[type]); advance(player); player.setNextAnimation(new Animation(897)); return false; } if (object.getId() == BARS[type]) { if (!hasRequirement(player, Constants.SMITHING)) { player.sendMessage(""You need a smithing level of "" + getRequirement(Constants.SMITHING) + "" to smith these battle axes.""); return false; } if (!player.getInventory().containsOneItem(Smithing.DUNG_HAMMER)) { player.sendMessage(""You need a hammer to smith battle axes.""); return false; } giveXP(player, Constants.SMITHING); replaceObject(object, BATTLE_AXES[type]); advance(player); player.setNextAnimation(new Animation(898)); player.setNextSpotAnim(new SpotAnim(2123)); return false; } if (object.getId() == LOGS[type]) { if (!hasRequirement(player, Constants.FLETCHING)) { player.sendMessage(""You need a fletching level of "" + getRequirement(Constants.FLETCHING) + "" to fletch these bows.""); return false; } if (!player.getInventory().containsOneItem(Fletching.DUNGEONEERING_KNIFE)) { player.sendMessage(""You need a knife to fletch bows.""); return false; } giveXP(player, Constants.FLETCHING); replaceObject(object, BOWS[type]); advance(player); player.setNextAnimation(new Animation(1248)); return false; } return true; } public void advance(Player player) { if (++stage == 3) { setComplete(); Dialogue fremennikAdvance = new Dialogue(); if (isComplete()) { fremennikAdvance.addNPC(FremennikCampRoom.FREMENNIK_SCOUT, HeadE.CHEERFUL_EXPOSITION, ""Wonderful! That was the last of them. As promised, I'll unlock the door for you.""); } else { fremennikAdvance.addNPC(FremennikCampRoom.FREMENNIK_SCOUT, HeadE.CONFUSED, ""Need some tools?""); fremennikAdvance.addItem(Fletching.DUNGEONEERING_KNIFE, ""The scout hands you a knife."", () -> player.getInventory().addItem(Fletching.DUNGEONEERING_KNIFE, 1)); } player.startConversation(fremennikAdvance); } } @Override public boolean processNPCClick1(Player player, NPC npc) { if (npc.getId() == FREMENNIK_SCOUT) { Dialogue fremennikAdvance = new Dialogue(); if (isComplete()) { fremennikAdvance.addNPC(FremennikCampRoom.FREMENNIK_SCOUT, HeadE.CHEERFUL_EXPOSITION, ""Wonderful! That was the last of them. As promised, I'll unlock the door for you.""); } else { fremennikAdvance.addNPC(FremennikCampRoom.FREMENNIK_SCOUT, HeadE.CONFUSED, ""Need some tools?""); fremennikAdvance.addItem(Fletching.DUNGEONEERING_KNIFE, ""The scout hands you a knife."", () -> player.getInventory().addItem(Fletching.DUNGEONEERING_KNIFE, 1)); } player.startConversation(fremennikAdvance); return false; } return true; } @Override public String getCompleteMessage() { return null; } }" "package com.rs.game.content.skills.dungeoneering.rooms.puzzles; public class LeverRoom extends PuzzleRoom { /* private static final int[] SWITCH_UP = { 49381, 49382, 49383, 54333, 33675 }; */ private static final int[] SWITCH_DOWN = { 49384, 49385, 49386, 49386, 49386 }; //TODO find down of 54333, 33675 private int leverCount, leverTicks, maxTicks; private Task resetTask; @Override public void openRoom() { manager.spawnRandomNPCS(reference); } @Override public boolean processObjectClick1(Player player, GameObject object) { if (object.getDefinitions().getName().equals(""Switch"")) { player.setNextAnimation(new Animation(3611)); if (isComplete()) { player.sendMessage(""The lever doesn't seem to respond.""); return false; } if (resetTask == null) addResetTask(); GameObject down = new GameObject(object); down.setId(SWITCH_DOWN[type]); World.spawnObjectTemporary(down, (maxTicks - leverTicks)); leverCount++; return false; } return true; } private void addResetTask() { //Still want it to be possible when people leave a 5:5 (4:5), and very easy on a 5:1 int size = manager.getParty().getTeam().size(); int difficulty = Math.min(manager.getParty().getDificulty(), size); //5 - 2.4 seconds //4 - 3.6 seconds //3 - 5.4 seconds //2 - 7.2 seconds //1 - 14.4 seconds maxTicks = (6 - difficulty) + ((size == 1 ? 23 : 20) / difficulty); resetTask = new ResetTask(); WorldTasks.scheduleLooping(resetTask, 0, 0); } private void resetTask() { leverTicks = 0; maxTicks = 0; resetTask = null; } private class ResetTask extends Task { @Override public void run() { if (manager == null || manager.isDestroyed()) { stop(); return; } if (leverCount == 5) { setComplete(); resetTask(); stop(); return; } leverTicks++; if (leverTicks >= maxTicks) { resetTask(); if (leverCount != 5) { leverCount = 0; for (Player player : manager.getParty().getTeam()) { player.sendMessage(""You hear a loud noise and all the switches toggle back off.""); if (player.withinDistance(manager.getTile(reference, 7, 8), 2) || !manager.getCurrentRoomReference(Tile.of(player.getTile())).equals(reference)) continue; World.sendSpotAnim(Tile.of(player.getTile()), new SpotAnim(2759)); player.setNextAnimation(new Animation(13694)); player.applyHit(new Hit(player, (int) (player.getMaxHitpoints() * .3), HitLook.TRUE_DAMAGE)); } stop(); return; } } } } @Override public String getCompleteMessage() { return ""As the last lever is pulled, you hear a click. All the doors in the room are now unlocked.""; } }" "package com.rs.game.content.skills.dungeoneering.rooms.puzzles; public class PoltergeistRoom extends PuzzleRoom { public static final int POLTERGEIST_ID = 11245; public static final int CONSECRATED_HERB = 19659; public static final int[] HERBS = { 19653, 19654, 19655, 19656, 19657, 19658 }; private static final int[][] CENSERS = { { -1, -1, -1 }, { 54095, 54099, 54103 }, { 54096, 54100, 54104 }, { 54097, 54101, 54105 }, { 39847, 39850, 39851 }, }; private static final int[][] SARCOPHAGUS = { { -1, -1, -1 }, { 54079, 54083 }, { 54080, 54084 }, { 54081, 54085 }, { 39526, 39840 }, }; private NPC poltergeist; private Item requiredHerb; private int censersLit; private int herbsAvailable = 4; @Override public void openRoom() { manager.spawnRandomNPCS(reference); poltergeist = manager.spawnNPC(reference, POLTERGEIST_ID, 5, 5, false, DungeonConstants.PUZZLE_NPC); requiredHerb = new Item(HERBS[Utils.random(HERBS.length)]); } public boolean canTakeHerb() { return herbsAvailable > 0; } public void takeHerb(Player player, GameObject object, int index) { if (requiredHerb.getId() == HERBS[index]) { if (player.getInventory().addItem(HERBS[index], 1)) { player.lock(1); player.sendMessage(""With great care, you pick a clump of the herb.""); giveXP(player, Constants.HERBLORE); herbsAvailable--; if (herbsAvailable == 0) { GameObject o = new GameObject(object); o.setId(DungeonConstants.EMPTY_FARMING_PATCH); World.spawnObject(o); } } } else player.applyHit(new Hit(player, (int) (player.getMaxHitpoints() * .3), HitLook.TRUE_DAMAGE)); } @Override public boolean processObjectClick1(Player player, GameObject object) { String name = object.getDefinitions().getName(); if (name.equals(""Sarcophagus"")) { player.simpleDialogue(""The inscription reads: 'Here lies Leif, posthumously honoured with the discovery of "" + requiredHerb.getName() + "".""); return false; } if (name.equals(""Censer"") && object.getDefinitions().containsOption(""Light"")) { int requiredFiremaking = getRequirement(Constants.FIREMAKING); if (!player.getInventory().containsOneItem(DungeonConstants.TINDERBOX)) { player.sendMessage(""You need a tinderbox in order to light a censer.""); return false; } else if (requiredFiremaking > player.getSkills().getLevel(Constants.FIREMAKING)) { player.sendMessage(""You need a firemaking level of "" + requiredFiremaking + "" to light this.""); return false; } giveXP(player, Constants.FIREMAKING); player.lock(1); censersLit++; if (censersLit == 4) poltergeist.finish(); World.spawnObject(new GameObject(CENSERS[manager.getParty().getFloorType()][2], object.getType(), object.getRotation(), object.getTile())); return false; } if (name.equals(""Censer"") && object.getDefinitions().containsOption(""Inspect"")) { player.sendMessage(""This censer would be ideal for burning something in.""); return false; } else if (name.equals(""Herb patch"") && object.getDefinitions().containsOption(""Harvest"")) { int requiredHerblore = getRequirement(Constants.HERBLORE); if (requiredHerblore > player.getSkills().getLevel(Constants.HERBLORE)) { player.sendMessage(""You need a herblore level of "" + requiredHerblore + "" to harvest these herbs.""); return false; } player.startConversation(new Dialogue().addOptions(ops -> { for (int i = 0;i < HERBS.length;i++) { final int index = i; ops.add(ItemDefinitions.getDefs(HERBS[i]).name, () -> takeHerb(player, object, index)); } })); return false; } return true; } @Override public boolean handleItemOnObject(Player player, GameObject object, Item item) { if (object.getDefinitions().getName().equals(""Censer"") && object.getDefinitions().containsOption(""Inspect"")) if (item.getId() == CONSECRATED_HERB) { player.lock(1); player.sendMessage(""You pile the herbs into the censer.""); player.getInventory().deleteItem(item); World.spawnObject(new GameObject(CENSERS[manager.getParty().getFloorType()][1], object.getType(), object.getRotation(), object.getTile())); return false; } return true; } @Override public boolean processObjectClick2(Player player, GameObject object) { if (object.getDefinitions().getName().equals(""Sarcophagus"")) { if (censersLit != 4) { player.sendMessage(""lit: "" + censersLit + ""/4""); return false; } int requiredThieving = getRequirement(Constants.THIEVING); if (requiredThieving > player.getSkills().getLevel(Constants.THIEVING)) { player.sendMessage(""You need a thieving level of "" + requiredThieving + "" to open the sarcophagus.""); return false; } giveXP(player, Constants.THIEVING); player.sendMessage(""You successfully open the sarcophagus.""); World.spawnObject(new GameObject(SARCOPHAGUS[manager.getParty().getFloorType()][1], object.getType(), object.getRotation(), object.getTile())); setComplete(); return false; } return true; } public static class Poltergeist extends DungeonNPC { private final Tile[] corners; private int ptr; public Poltergeist(int id, Tile tile, DungeonManager manager, RoomReference reference) { super(id, tile, manager); corners = new Tile[4]; corners[0] = manager.getTile(reference, 5, 5); corners[1] = manager.getTile(reference, 5, 10); corners[2] = manager.getTile(reference, 10, 10); corners[3] = manager.getTile(reference, 10, 5); } @Override public void processNPC() { if (getWalkSteps().isEmpty()) { addWalkSteps(corners[ptr].getX(), corners[ptr].getY()); if (++ptr == corners.length) ptr = 0; } super.processNPC(); } } public void consecrateHerbs(Player player, int id) { int requiredPrayer = getRequirement(Constants.PRAYER); if (requiredPrayer > player.getSkills().getLevel(Constants.PRAYER)) { player.sendMessage(""You need a prayer level of "" + requiredPrayer + "" to consecrate the herbs.""); return; } giveXP(player, Constants.PRAYER); player.lock(2); player.getInventory().deleteItem(id, 1); player.getInventory().addItem(CONSECRATED_HERB, 1); player.sendMessage(""You consecrate the herbs.""); } }" "package com.rs.game.content.skills.dungeoneering.rooms.puzzles; public class ReturnTheFlowRoom extends PuzzleRoom { //private static final int[] PEDESTAL = { 54110, 54111, 54112, 54113, 37202 }; private static final int[] PEDESTAL_FLOW = { 54114, 54115, 54116, 54117, 37203 }; //private static final int[] PILLAR = { 54118, 54119, 54120, 54121, 37204 }; private static final int[] PILLAR_BROKEN = { 54122, 54123, 54124, 54125, 37207 }; private static final int[] PILLAR_REPAIRED = { 54126, 54127, 54128, 54129, 37219 }; //Rubble pieces receiving no flow (each rooms seems to have a few of these prespawned) private static final int[] RUBBLE_PIECE = { 54130, 54131, 54132, 54133, 37220 }; private static final int[] RUBBLE_PIECE_CLEARED = { 54134, 54135, 54136, 54137, 37229 }; //Cleared rubble pieces receiving flow (they still have remnants on them) private static final int[] RUBBLE_PIECE_FLOW = { 54138, 54139, 54140, 54141, 37232 }; private static final int[] RUBBLE_PIECE_CLEARED_FLOW = { 54142, 54143, 54144, 54145, 37249 }; //Clean straight pieces //This must also be used as a base for the rubble pieces to make a groove in the ground private static final int[] STRAIGHT_PIECE_PATH = { 54146, 54147, 54148, 54149, 37250 }; private static final int[] STRAIGHT_PIECE_PATH_FLOW = { 54150, 54151, 54152, 54153, 37251 }; //Clean corner pieces private static final int[] CORNER_PIECE_PATH = { 54154, 54155, 54156, 54157, 37252 }; private static final int[] CORNER_PIECE_PATH_FLOW = { 54158, 54159, 54160, 54161, 37253 }; private static final int[][] pillars = { { 5, 5 }, { 5, 10 }, { 10, 10 }, { 10, 5 } }; private Flow[] flows; private int tasks; @Override public void openRoom() { flows = new Flow[4]; int roomRotation = manager.getRoom(reference).getRotation(); for (int x = 5; x <= 10; x++) for (int y = 5; y <= 10; y++) { GameObject object = manager.getObjectWithType(reference, ObjectType.SCENERY_INTERACT, x, y); if (object != null && object.getId() == RUBBLE_PIECE[type]) World.removeObject(object); } boolean counterClockwise = coinFlip(); int pillarPtr = counterClockwise ? 1 : 0; for (int i = 0; i < 4; i++) { int pillarX = pillars[pillarPtr][0]; int pillarY = pillars[pillarPtr][1]; GameObject pillar = new GameObject(manager.getObjectWithType(reference, ObjectType.SCENERY_INTERACT, pillarX, pillarY)); if (counterClockwise) pillar.setRotation(roomRotation + 1 + i); else pillar.setRotation(roomRotation + 3 + i); boolean broken = false; if (coinFlip()) { tasks++; broken = true; pillar.setId(PILLAR_BROKEN[type]); } World.spawnObject(pillar); flows[i] = new Flow(pillarX, pillarY); if (counterClockwise) flows[i].flow.mirror(); FlowPiece node = flows[i].flow.start; while (node.next != null) { if (i == 1) { int tmp = node.x; node.x = 1 + node.y; node.y = 4 - tmp; } else if (i == 2) { node.y = 3 - node.y; node.x = 5 - node.x; } else if (i == 3) { int tmp = node.x; node.x = 4 - node.y; node.y = tmp - 1; } node.rotation += i; if (!broken && !node.blocked) manager.spawnObject(reference, node.corner ? CORNER_PIECE_PATH_FLOW[type] : STRAIGHT_PIECE_PATH_FLOW[type], ObjectType.GROUND_DECORATION, node.rotation, 5 + node.x, 6 + node.y); else manager.spawnObject(reference, node.corner ? CORNER_PIECE_PATH[type] : STRAIGHT_PIECE_PATH[type], ObjectType.GROUND_DECORATION, node.rotation, 5 + node.x, 6 + node.y); if (node.blocked) { if (!broken) manager.spawnObject(reference, RUBBLE_PIECE_FLOW[type], ObjectType.SCENERY_INTERACT, node.rotation, 5 + node.x, 6 + node.y); else manager.spawnObject(reference, RUBBLE_PIECE[type], ObjectType.SCENERY_INTERACT, node.rotation, 5 + node.x, 6 + node.y); broken = true; } node = node.next; } pillarPtr++; pillarPtr &= 0x3; } //very small chance to have it not generate anything at the start if (tasks == 0) { setComplete(); manager.spawnObject(reference, PEDESTAL_FLOW[type], ObjectType.SCENERY_INTERACT, 0, 7, 7); } manager.spawnRandomNPCS(reference); } @Override public boolean processObjectClick1(final Player player, final GameObject object) { if (object.getId() == RUBBLE_PIECE[type] || object.getId() == RUBBLE_PIECE_FLOW[type]) { if (!hasRequirement(player, Constants.MINING)) { player.sendMessage(""You need a mining level of "" + getRequirement(Constants.MINING) + "" to mine this rock.""); return false; } DungPickaxe pick = DungPickaxe.getBest(player); if (pick == null) { player.sendMessage(""You do not have a pickaxe or do not have the required level to use the pickaxe.""); return false; } player.setNextAnimation(pick.getAnimation()); player.lock(4); WorldTasks.scheduleTimer(3, (ticks) -> { final int[] coords = manager.getRoomPos(object.getTile()); FlowPiece node = findFlowPiece(coords[0], coords[1]); if (node.blocked) { //players might click in same tick giveXP(player, Constants.MINING); player.setNextAnimation(new Animation(-1)); GameObject rubble = new GameObject(object); rubble.setId(object.getId() == RUBBLE_PIECE[type] ? RUBBLE_PIECE_CLEARED[type] : RUBBLE_PIECE_CLEARED_FLOW[type]); World.spawnObject(rubble); node.blocked = false; advance(); if (object.getId() == RUBBLE_PIECE_FLOW[type]) startFlow(node); } return false; }); return false; } if (object.getId() == PILLAR_BROKEN[type]) { if (!hasRequirement(player, Constants.CONSTRUCTION)) { player.sendMessage(""You need a construction level of "" + getRequirement(Constants.CONSTRUCTION) + "" to repair this pillar.""); return false; } int[] coords = manager.getRoomPos(object.getTile()); for (Flow flow : flows) { if (flow.pillarX == coords[0] && flow.pillarY == coords[1]) { giveXP(player, Constants.CONSTRUCTION); player.setNextAnimation(new Animation(14566)); player.lock(2); replaceObject(object, PILLAR_REPAIRED[type]); advance(); startFlow(flow.flow.start); return false; } } } return true; } private void advance() { if (--tasks == 0) { setComplete(); manager.spawnObject(reference, PEDESTAL_FLOW[type], ObjectType.SCENERY_INTERACT, 0, 7, 7); } } private void startFlow(FlowPiece node) { while (node.next != null) { if (node.corner) manager.spawnObject(reference, CORNER_PIECE_PATH_FLOW[type], ObjectType.GROUND_DECORATION, node.rotation, 5 + node.x, 6 + node.y); else if (!node.blocked) manager.spawnObject(reference, STRAIGHT_PIECE_PATH_FLOW[type], ObjectType.GROUND_DECORATION, node.rotation, 5 + node.x, 6 + node.y); else { manager.spawnObject(reference, RUBBLE_PIECE_FLOW[type], ObjectType.SCENERY_INTERACT, node.rotation, 5 + node.x, 6 + node.y); return; } node = node.next; } } private FlowPiece findFlowPiece(int x, int y) { for (Flow flow : flows) { FlowPiece node = flow.flow.start; while (node.next != null) { if (5 + node.x == x && 6 + node.y == y) return node; node = node.next; } } throw new RuntimeException(); } private final int endY = 1 + (int) (Math.random() * 2); public class Flow { int pillarX; int pillarY; FlowBuilder flow; public Flow(int x, int y) { pillarX = x; pillarY = y; flow = new FlowBuilder(); flow.generate(); } public GameObject getPillar() { return manager.getObjectWithType(reference, ObjectType.SCENERY_INTERACT, pillarX, pillarY); } } public class FlowBuilder { public static final int NORTH = 0; public static final int EAST = 1; public static final int SOUTH = 2; public static final int WEST = 3; private static final int SIZE_X = 1; private static final int SIZE_Y = 2; private FlowPiece start; private FlowPiece curr; boolean[][] used = new boolean[2][3]; public void generate() { start = curr = new FlowPiece(0, 0, false, 0, 0, false); while (curr.x != SIZE_X || curr.y != endY) { if (coinFlip()) { if (curr.x == SIZE_X && !used[curr.x - 1][curr.y]) { move(WEST); continue; } if (curr.x == 0 && !used[SIZE_X][curr.y]) { move(EAST); continue; } } //Else can't change X if (curr.y == SIZE_Y) { if (!used[curr.x][curr.y - 1]) move(SOUTH); else move(EAST); //rest is impossible } else move(NORTH); } move(EAST); } public void move(int dir) { used[curr.x][curr.y] = true; if (curr.fromDir == NORTH && dir == NORTH) new FlowPiece(curr.x, curr.y + 1, false, 1, dir, coinFlip()); else if (curr.fromDir == EAST && dir == EAST) new FlowPiece(curr.x + 1, curr.y, false, 2, dir, coinFlip()); else if (curr.fromDir == NORTH && dir == EAST) new FlowPiece(curr.x + 1, curr.y, true, 3, dir, false); else if (curr.fromDir == SOUTH && dir == EAST) new FlowPiece(curr.x + 1, curr.y, true, 2, dir, false); else if (curr.fromDir == NORTH && dir == WEST) new FlowPiece(curr.x - 1, curr.y, true, 0, dir, false); else if (curr.fromDir == EAST && dir == SOUTH) new FlowPiece(curr.x, curr.y - 1, true, 0, dir, false); else if (curr.fromDir == EAST && dir == NORTH) new FlowPiece(curr.x, curr.y + 1, true, 1, dir, false); else if (curr.fromDir == WEST && dir == NORTH) new FlowPiece(curr.x, curr.y + 1, true, 2, dir, false); else throw new RuntimeException(); } public void mirror() { FlowPiece node = start; while (node.next != null) { node.y = SIZE_Y - node.y + 1; if (node.corner) node.rotation = 1 - node.rotation; else if (node.rotation == 1) //turn straight pieces in Y direction node.rotation += 2; node = node.next; } } private boolean hasRock; public class FlowPiece { FlowPiece next; int rotation; int fromDir; boolean blocked; boolean corner; int x; int y; public FlowPiece(int x, int y, boolean corner, int rotation, int dir, boolean blocked) { this.x = x; this.y = y; if (curr != null) { curr.corner = corner; if (!hasRock) { hasRock = true; curr.blocked = blocked; if (blocked) tasks++; } curr.next = this; curr.rotation = rotation; } curr = this; } } } private static boolean coinFlip() { return Math.random() > 0.5; } }" "package com.rs.game.content.skills.dungeoneering.rooms.puzzles; public class SlidingStatuesRoom extends PuzzleRoom { public final int[][] STATUES_INACTIVE = { //{7809, 7810, 7811, 7812}, //?? //range1, warr1, range2, warr2 { 10942, 10943, 10944, 10945 }, //frozen { 10946, 10947, 10948, 10949 }, //aba { 10950, 10951, 10952, 10953 }, //furn { 12117, 12118, 12119, 12120 }, //occ { 12952, 12953, 12954, 12955 }, //warp }; public final int[][] STATUES_ACTIVE = { //{7813, 7814, 7815, 7817}, //?? { 10954, 10955, 10956, 10957 }, { 10958, 10959, 10960, 10961 }, { 10962, 10963, 10964, 10965 }, { 12121, 12122, 12123, 12124 }, { 12956, 12957, 12958, 12959 }, }; public final int[][] STATUE_LOCATIONS = { { 2, 9 }, { 9, 9 }, { 2, 2 }, { 9, 2 }, }; private NPC[] statues; @Override public void openRoom() { statues = new NPC[8]; Tile base = manager.getRoomBaseTile(reference); int index = 0; for (int i = 0; i < 2; i++) { for (int j = 0; j < 2; j++) { while_: while (true) { Tile inactive = base.transform(STATUE_LOCATIONS[i][0] + Utils.random(5), STATUE_LOCATIONS[i][1] + Utils.random(5), 0); Tile active = base.transform(STATUE_LOCATIONS[i + 2][0] + Utils.random(5), STATUE_LOCATIONS[i + 2][1] + Utils.random(5), 0); for (NPC statue : statues) if (statue != null && (inactive.matches(statue.getTile()) || active.matches(statue.getTile()))) continue while_; if (active.transform(0, 7, 0).matches(inactive)) continue while_; statues[index] = manager.spawnNPC(STATUES_INACTIVE[type][index], 0, inactive, reference, DungeonConstants.NORMAL_NPC); statues[index + 4] = new Statue(STATUES_ACTIVE[type][index], active, STATUE_LOCATIONS[i + 2][0], STATUE_LOCATIONS[i + 2][1]); index++; break; } } } for(NPC statue : statues) { WorldCollision.addFlag(statue.getTile(), ClipFlag.PF_FULL); } manager.spawnRandomNPCS(reference); } public class Statue extends DungeonNPC { private final int baseX, baseY; public Statue(int id, Tile tile, int baseX, int baseY) { super(id, tile, manager); this.baseX = baseX; this.baseY = baseY; } public void handle(final Player player, final boolean push) { //TODO: make sure 2 players can't move 2 statues ontop of eachother in the same tick? although it doesn't really matter boolean pull = !push; int x = transform(-baseX, -baseY, 0).getXInChunk(); int y = transform(-baseX, -baseY, 0).getYInChunk(); final int dx = push ? getX() - player.getX() : player.getX() - getX(); final int dy = push ? getY() - player.getY() : player.getY() - getY(); if (x + dx < 0 || x + dx > 4 || y + dy < 0 || y + dy > 4) { player.sendMessage(""You cannot push the statue there.""); return; } final Tile nTarget = transform(dx, dy, 0); final Tile pTarget = player.transform(dx, dy, 0); if (!SlidingStatuesRoom.this.tileHasStatue(null, nTarget) || (pull && !SlidingStatuesRoom.this.tileHasStatue(null, pTarget))) { player.sendMessage(""A statue is blocking the way.""); return; } for (Player team : manager.getParty().getTeam()) { if (team != player && team.matches(nTarget)) { player.sendMessage(""A party member is blocking the way.""); return; } } player.lock(); WorldTasks.schedule(0, () -> { WorldCollision.removeFlag(getTile(), ClipFlag.PF_FULL); addWalkSteps(getX() + dx, getY() + dy); player.forceMove(pTarget, push ? 3065 : 3065, 0, 30, () -> { WorldCollision.addFlag(getTile(), ClipFlag.PF_FULL); checkComplete(); }); }); } } private void checkComplete() { if (isComplete()) return; for (int i = 0; i < 4; i++) if (!statues[i + 4].transform(0, 7, 0).matches(statues[i].getTile())) return; setComplete(); } public boolean tileHasStatue(Player player, Tile to) { for (NPC statue : statues) if (to.matches(statue.getTile())) return false; return true; } @Override public boolean processNPCClick1(Player player, NPC npc) { if (npc instanceof Statue s) { s.handle(player, true); return false; } return true; } @Override public boolean processNPCClick2(Player player, NPC npc) { if (npc instanceof Statue s) { s.handle(player, false); return false; } return true; } @Override public void destroy() { for(NPC statue : statues) { WorldCollision.removeFlag(statue.getTile(), ClipFlag.PF_FULL); } } }" "package com.rs.game.content.skills.dungeoneering.rooms.puzzles; public class SlidingTilesRoom extends PuzzleRoom { private static final int[] BASE_TILE = { 12125, 12133, 12141, 12149, 12963 }; private static final int[][] TILE_COORDS = { { 5, 9 }, { 7, 9 }, { 9, 9 }, { 5, 7 }, { 7, 7 }, { 9, 7 }, { 5, 5 }, { 7, 5 }, { 9, 5 }, }; private static final int[][] VALID_MOVES = { { 1, 3 }, { 0, 2, 4 }, { 1, 5 }, { 0, 4, 6 }, { 1, 3, 5, 7 }, { 2, 4, 8 }, { 3, 7 }, { 4, 6, 8 }, { 5, 7 } }; private DungeonNPC[] tiles; private int freeIndex = 8; private int[] shuffledNpcOrder; private int[] solveOrder; private int solveIndex; @Override public void openRoom() { List monsters = DungeonUtils.generateRandomMonsters(manager.getParty().getFloor(), (int) (manager.getParty().getAverageCombatLevel()*1.3), manager.getParty().getCombatLevel(), Utils.random(4)); for (int i : monsters) { GuardianMonster m = GuardianMonster.forId(i); int x = Utils.random(2) + 1; int y = Utils.random(2) + 1; if (Utils.random(2) == 0) { //vertical spawn x += Utils.random(2) == 0 ? 0 : 11; //left or right side y = Utils.random(14) + 1; } else { //horizontal spawn y += Utils.random(2) == 0 ? 0 : 11; //bottom or top x = Utils.random(14) + 1; } manager.spawnNPC(reference, i, x, y, true, m.name().contains(""FORGOTTEN_"") ? DungeonConstants.FORGOTTEN_WARRIOR : DungeonConstants.GUARDIAN_NPC); } shuffle(); tiles = new SlidingTile[9]; for (int i = 0; i < 9; i++) if (shuffledNpcOrder[i] != 0) { int[] coords = DungeonManager.translate(TILE_COORDS[i][0], TILE_COORDS[i][1], 0, 2, 2, 0); Tile base = manager.getRoomBaseTile(reference); tiles[i] = new SlidingTile(shuffledNpcOrder[i], Tile.of(base.getX() + coords[0], base.getY() + coords[1], 0), manager); } } public static class SlidingTile extends DungeonNPC { public SlidingTile(int id, Tile tile, DungeonManager manager) { super(id, tile, manager); } @Override public int getFaceAngle() { return 0; } } public void shuffle() { int type = manager.getParty().getFloorType(); shuffledNpcOrder = new int[9]; solveOrder = new int[8]; for (int i = 0; i < 8; i++) shuffledNpcOrder[i] = BASE_TILE[type] + i; List set = new ArrayList<>(); boolean[] used = new boolean[9]; while (true) { for (int i = 0; i < VALID_MOVES[freeIndex].length; i++) if (!used[VALID_MOVES[freeIndex][i]]) set.add(VALID_MOVES[freeIndex][i]); if (set.isEmpty()) break; Collections.shuffle(set); int next = set.getFirst(); set.clear(); used[freeIndex] = true; solveOrder[solveIndex++] = freeIndex; shuffledNpcOrder[freeIndex] = shuffledNpcOrder[next]; shuffledNpcOrder[next] = 0; freeIndex = next; } } public static boolean handleSlidingBlock(Player player, NPC npc) { if (!npc.getDefinitions().getName().equals(""Sliding block"") || player.getControllerManager().getController() == null || !(player.getControllerManager().getController() instanceof DungeonController)) return false; DungeonManager manager = player.getDungManager().getParty().getDungeon(); VisibleRoom room = manager.getVisibleRoom(manager.getCurrentRoomReference(player.getTile())); if (!(room instanceof SlidingTilesRoom puzzle)) return false; for (int i = 0; i < puzzle.tiles.length; i++) if (puzzle.tiles[i] == npc) { player.lock(1); if (i != puzzle.solveOrder[puzzle.solveIndex - 1]) { player.sendMessage(""You strain your powers of telekenesis, but the tile just doesn't want to go there.""); player.applyHit(new Hit(player, (int) (player.getMaxHitpoints() * .2), HitLook.TRUE_DAMAGE)); return true; } puzzle.solveIndex--; if (puzzle.solveIndex == 0) { puzzle.setComplete(); //players can keep clicking after it's done but will take damage puzzle.solveIndex = 1; puzzle.solveOrder[0] = -1; } int[] coords = DungeonManager.translate(TILE_COORDS[puzzle.freeIndex][0], TILE_COORDS[puzzle.freeIndex][1], 0, 2, 2, 0); Tile base = puzzle.manager.getRoomBaseTile(puzzle.reference); npc.addWalkSteps(base.getX() + coords[0], base.getY() + coords[1]); puzzle.tiles[puzzle.freeIndex] = puzzle.tiles[i]; puzzle.tiles[i] = null; puzzle.freeIndex = i; return true; } return true; } @Override public String getCompleteMessage() { return ""You hear a click as a nearby door unlocks."";//This is correct } }" "package com.rs.game.content.skills.dungeoneering.rooms.puzzles; public class ToxinMaze extends PuzzleRoom { private static final int TICK_SPEED = 5; private static final int TOTAL_TICKS = 80; //48 secs private static final int BARRIER = 49341; private static final int BARRIER_ENTRANCE = 49344; private static final int[] SWITCH_DOWN = { 49384, 49385, 49386, 49386, 49386 }; //TODO: down of 54333, 33675 private static final int[][] OBSTACLES = { { 49370, 49371, 49372, 49373, 49374 }, //Frozen { 49360, 49361, 49362, 49363, 49364 }, //Abandoned? { 49365, 49366, 49367, 49368, 49369 }, //Furnished? { 54412, 54413, 54414, 54415, 54416 }, //Occult? { 55853, 55854, 55855, 55856, 55857 }, //Warped? }; private boolean expired; private Task toxinTask; @Override public void openRoom() { generate(); } @Override public boolean processObjectClick1(final Player player, GameObject object) { if (object.getDefinitions().getName().equals(""Switch"")) { GameObject down = new GameObject(object); down.setId(SWITCH_DOWN[type]); World.spawnObject(down); player.lock(1); player.setNextAnimation(new Animation(832)); toxinTask = new ToxinTask(); WorldTasks.scheduleLooping(toxinTask, 0, TICK_SPEED); setComplete(); //doors are unlocked instantly return false; } if (object.getDefinitions().getName().equals(""Locked chest"")) { destroy(); for (Connector connector : connectors) if (connector.blocked) World.removeObject(World.getSpawnedObject(manager.getTile(reference, connector.x, connector.y))); if (!expired) { manager.getRoom(reference).setThiefChest(0); //Chest with lvl 1 requirement //fall through to default chest handler return true; } replaceObject(object, DungeonConstants.THIEF_CHEST_OPEN[type]); player.setNextAnimation(new Animation(536)); player.lock(2); player.sendMessage(""You open the chest, but it appears to be empty.""); return false; } if (object.getId() == BARRIER_ENTRANCE && toxinTask == null && !isComplete()) { player.sendMessage(""The barrier won't let you pass, I wonder what that lever is for...""); return false; } if (object.getId() == BARRIER || object.getId() == BARRIER_ENTRANCE) { Tile in = Tile.of(object.getX() + Utils.ROTATION_DIR_X[object.getRotation()], object.getY() + Utils.ROTATION_DIR_Y[object.getRotation()], 0); Tile out = Tile.of(object.getX(), object.getY(), 0); Tile target; int delay = 0; if (player.matches(out)) target = in; else if (player.matches(in)) target = out; else { target = in; delay = 1; } final Tile target_ = target; player.lock(); WorldTasks.schedule(delay, () -> { player.forceMove(target_, 9516, 10, 30); player.spotAnim(2609); }); return false; } return true; } private class ToxinTask extends Task { private int ticks = TOTAL_TICKS / TICK_SPEED; @Override public void run() { if (manager == null || manager.isDestroyed()) { stop(); return; } if (toxinTask == null) { if (ticks > 0) { //Maze finished before timer ran out manager.message(reference, ""The ticking sound from beneath the floor is suddenly silenced.""); manager.hideBar(reference); } else //Maze finished after timer ran out manager.message(reference, ""The toxin in the room seems to have dispersed.""); return; } ticks--; if (ticks > 0) manager.showBar(reference, ""Time remaining"", (ticks * TICK_SPEED * 100) / TOTAL_TICKS); else { if (ticks == 0) { expired = true; manager.message(reference, ""A toxin starts to fill the room...""); manager.hideBar(reference); } for (Player player : manager.getParty().getTeam()) if (manager.getCurrentRoomReference(player.getTile()).equals(reference)) { player.applyHit(new Hit(player, (int) (player.getMaxHitpoints() * .1), HitLook.TRUE_DAMAGE)); player.sendMessage(""You take damage from the toxin in the room.""); } } } } @Override public String getCompleteMessage() { return ""You press the switch, and both the chest in the center of the room and the door next to you unlock. A strange ticking sound comes from beneath the floor.""; } @Override public void destroy() { if (toxinTask != null) { toxinTask.stop(); toxinTask = null; } } /** * Amount of unused barriers at each depth level (for generation only) */ private int[] availableDoors; private final Set connectors = new HashSet<>(); public void generate() { //MAZE GRAPH DO NOT CHANGE, YOU WILL HORRIBLY FUCK THINGS UP int[] doorsPerLayer = { 6, 3, 3, 2, 2 }; /* * The barriers by depth (for linking only) */ Barrier[][] layers = new Barrier[doorsPerLayer.length][]; for (int i = 0; i < layers.length; i++) { layers[i] = new Barrier[doorsPerLayer[i]]; for (int j = 0; j < layers[i].length; j++) layers[i][j] = new Barrier(i); } BarrierSide south = new Barrier(0).outer; //Not counting the entrance bit BarrierSide east = new Barrier(-1).outer; BarrierSide north = layers[0][2].outer; //directly connected BarrierSide west = new Barrier(-1).outer; // Visual maze graph //_________|______|___ //______|_______|_____ //____|____|__|_______ //_____|_|_______|____ //_|_S__|__|_|_|___|__ // E N W //Connect everything with its clockwise neighbor //Exits new Connector(south, layers[1][0].outer, 9, 2); new Connector(east, layers[0][1].outer, 14, 9); new Connector(west, layers[0][4].outer, 1, 5); //Ring 1 new Connector(layers[0][0].outer, east, 14, 5); new Connector(layers[0][0].inner, layers[1][1].outer, 13, 5); new Connector(layers[0][1].outer, layers[0][2].outer, 13, 14); new Connector(layers[0][1].inner, layers[0][2].inner, 12, 13); new Connector(layers[0][2].outer, layers[0][3].outer, 3, 14); new Connector(layers[0][2].inner, layers[0][3].inner, 4, 13); new Connector(layers[0][3].outer, west, 1, 10); new Connector(layers[0][3].inner, layers[1][2].outer, 2, 10); new Connector(layers[0][4].outer, layers[0][5].outer, 1, 2); new Connector(layers[0][4].inner, layers[0][5].inner, 3, 2); new Connector(layers[0][5].inner, south, 6, 2); //Ring 2 new Connector(layers[1][0].outer, layers[0][0].inner, 12, 2); new Connector(layers[1][0].inner, layers[1][1].inner, 12, 4); new Connector(layers[1][1].outer, layers[0][1].inner, 13, 8); new Connector(layers[1][1].inner, layers[2][1].outer, 12, 11); new Connector(layers[1][2].outer, layers[0][4].inner, 2, 6); new Connector(layers[1][2].inner, layers[2][0].outer, 3, 4); //Ring 3 new Connector(layers[2][0].outer, layers[1][0].inner, 7, 3); new Connector(layers[2][0].inner, layers[3][0].outer, 11, 6); new Connector(layers[2][1].outer, layers[2][2].outer, 8, 12); new Connector(layers[2][1].inner, layers[2][2].inner, 7, 11); new Connector(layers[2][2].outer, layers[1][2].inner, 3, 11); new Connector(layers[2][2].inner, layers[3][1].outer, 4, 9); //Ring 4 new Connector(layers[3][0].outer, layers[2][1].inner, 11, 10); new Connector(layers[3][0].inner, layers[4][0].outer, 9, 10); new Connector(layers[3][1].outer, layers[2][0].inner, 4, 5); new Connector(layers[3][1].inner, layers[4][1].outer, 6, 5); //Ring 5 new Connector(layers[4][0].outer, layers[3][1].inner, 6, 10); new Connector(layers[4][1].outer, layers[3][0].inner, 9, 5); availableDoors = doorsPerLayer.clone(); south.door.visited = true; generatePath(south, 1, Math.random() > 0.5); //Make sure exits are reachable if (!north.door.visited) connectExit(north); if (!east.door.visited) connectExit(east); if (!south.door.visited) connectExit(south); if (!west.door.visited) connectExit(west); //Block ALL non-critical connectors for (Connector connector : connectors) if (!connector.critical) connector.blocked = true; layers[4][0].visited = true; layers[4][1].visited = true; //Determine which ones can be unblocked without connecting to crit path boolean progress = true; while (progress) { progress = false; for (Connector connector : connectors) if (connector.blocked) if (connector.left != null && connector.right != null) if (connector.left.door.visited ^ connector.right.door.visited) { connector.blocked = false; connector.left.door.visited = true; connector.right.door.visited = true; progress = true; } } for (Connector connector : connectors) if (connector.blocked) World.spawnObject(new GameObject(OBSTACLES[type][Utils.random(5)], ObjectType.SCENERY_INTERACT, 0, manager.getTile(reference, connector.x, connector.y))); } public boolean generatePath(BarrierSide current, int layer, boolean goRight) { int choicesDown = 0; int choicesUp = 0; List options = new LinkedList<>(); BarrierSide next; if (goRight) next = current.right; else next = current.left; //next can be null due to the default lever obstacles etc while (next != null) { if (next.door.layer != -1) { //Skip exits if (next.door.visited) //can't go further or paths will connect break; if (layer > next.door.layer) { //Door goes back to the outer ring choicesDown++; if (availableDoors[next.door.layer] - choicesDown > 0) options.add(next); } else { choicesUp++; options.add(next); if ((layer == 4) || (availableDoors[next.door.layer] - choicesUp == 0)) //last door, going further is useless break; } } if (goRight) next = next.right; else next = next.left; } if (options.isEmpty()) //backtrack condition return false; Collections.shuffle(options); //Priorize going down (makes mazes longer crit path although going down as much as possible will make the maze have very few dead ends) /*Collections.sort(options, new Comparator() { @Override public int compare(BarrierSide o1, BarrierSide o2) { return o1.door.layer - o2.door.layer; } });*/ for (BarrierSide option : options) { next = current; //Apply new maze state do { if (goRight) { next.rightCon.critical = true; next = next.right; } else { next.leftCon.critical = true; next = next.left; } next.door.visited = true; if (next.door.layer != -1) availableDoors[next.door.layer]--; } while (next != option); if (layer == 4) return true; //Recursive calculation boolean rightFirst = Math.random() > 0.5; //Check both directions if (generatePath(next.otherSide, layer + (layer > next.door.layer ? -1 : 1), rightFirst) || generatePath(next.otherSide, layer + (layer > next.door.layer ? -1 : 1), !rightFirst)) return true; //Backtrack, undo state changes next = current; do { if (goRight) { next.rightCon.critical = false; next = next.right; } else { next.leftCon.critical = false; next = next.left; } next.door.visited = false; if (next.door.layer != -1) availableDoors[next.door.layer]++; } while (next != option); } return false; } public void connectExit(BarrierSide curr) { while (true) { //Keep moving to the right until we find something connected curr.door.visited = true; curr.rightCon.critical = true; curr = curr.right; if (curr.door.visited) break; if (curr.layer() != 1 && curr.otherSide.layer() > curr.layer()) //Attempt to move up to layer 1 curr = curr.otherSide; } } /** * Represents a barrier in the maze */ public class Barrier { /** * Flag set if the barrier is currently being used in the critical path */ public boolean visited; /** * Depth level of this barrier */ public int layer; public Barrier(int layer) { this.layer = layer; outer = new BarrierSide(this); inner = new BarrierSide(this); outer.otherSide = inner; inner.otherSide = outer; } /** * Outer side of the barrier */ public BarrierSide outer; /** * Inner side of the barrier */ public BarrierSide inner; } /** * Represent a single side of a barrier */ public class BarrierSide { /** * The actual barrier */ public Barrier door; public BarrierSide(Barrier door) { this.door = door; } /** * The counter clockwise path on this side of the barrier */ public Connector leftCon; /** * The clockwise path on this side of the barrier */ public Connector rightCon; /** * The other side of this barrier */ public BarrierSide otherSide; /** * Shortcut to leftCon.left */ public BarrierSide left; /** * Shortcut to rightCon.right */ public BarrierSide right; public int layer() { return door.outer == this ? door.layer : door.layer + 1; } } /** * The path between one side of a door to another side of a door */ public class Connector { /** * Coordinates of where an object can be placed on this path to block it */ private final int x; private final int y; /** * Flag set if this connector is a critical part of the generated path */ public boolean critical; public boolean blocked; /** * The door on the connectors counter clockwise path */ public BarrierSide left; /** * The door on the connectors clockwise path */ public BarrierSide right; /** * Creates a connector and sets the links between objects so we can * traverse them */ public Connector(BarrierSide left, BarrierSide right, int x, int y) { this.left = left; this.right = right; this.x = x; this.y = y; left.right = right; left.rightCon = this; right.left = left; right.leftCon = this; connectors.add(this); } } }" "package com.rs.game.content.skills.dungeoneering.rooms.puzzles; public class UnhappyGhostRoom extends PuzzleRoom { public static final int RING = 19879; public static final int GHOST = 11246; private static final int[] COFFIN = { 54582, 54571, 40181, 54593, 55465 }; private static final int[] COFFIN_OPEN = { 54583, 54572, 55451, 54594, 55466 }; private static final int[] COFFIN_BLESSED = { 40172, 40175, 55452, 55463, 55467 }; private static final int[] JEWELLERY_BOX_EMPTY = { 54587, 54576, 55453, 54598, 55468 }; private static final int[] JEWELLERY_BOX = { 40173, 40180, 55454, 55464, 55469 }; private static final int[] BROKEN_POT = { 54588, 54577, 55455, 54599, 55470 }; private static final int[] FIXED_POT = { 54589, 54578, 55456, 54600, 55471 }; private static final int[] DAMAGED_PILLAR = { 54591, 54580, 55457, 54602, 55472 }; private static final int[] REPAIRED_PILLAR = { 54592, 54581, 55458, 54603, 55473 }; private int stage = 0; @Override public void openRoom() { manager.spawnItem(reference, new Item(RING, 1), 5, 9); new UnhappyGhost(manager.getTile(reference, 6, 9), manager); manager.spawnRandomNPCS(reference); } @Override public boolean processObjectClick1(Player player, GameObject object) { //TODO: You can fail skill related tasks if (object.getId() == DAMAGED_PILLAR[type]) { if (!hasRequirement(player, Constants.CONSTRUCTION)) { player.sendMessage(""You need a construction level of "" + getRequirement(Constants.CONSTRUCTION) + "" to repair this pillar.""); return false; } giveXP(player, Constants.CONSTRUCTION); player.lock(4); player.setNextAnimation(new Animation(14566)); replaceObject(object, REPAIRED_PILLAR[type]); advance(player); return false; } if (object.getId() == JEWELLERY_BOX_EMPTY[type]) { if (!player.getInventory().containsItem(RING, 1)) { player.sendMessage(""You don't have any jewellery to put in here.""); return false; } player.lock(3); player.setNextAnimation(new Animation(833)); player.getInventory().deleteItem(RING, 1); replaceObject(object, JEWELLERY_BOX[type]); advance(player); return false; } if (object.getId() == BROKEN_POT[type]) { if (!hasRequirement(player, Constants.CONSTRUCTION)) { player.sendMessage(""You need a construction level of "" + getRequirement(Constants.CONSTRUCTION) + "" to repair this pillar.""); return false; } giveXP(player, Constants.CONSTRUCTION); player.lock(4); player.setNextAnimation(new Animation(14566)); replaceObject(object, FIXED_POT[type]); advance(player); return false; } else if (object.getId() == COFFIN[type]) { if (!hasRequirement(player, Constants.THIEVING)) { player.sendMessage(""You need a thieving level of "" + getRequirement(Constants.THIEVING) + "" to unlock this coffin.""); return false; } giveXP(player, Constants.THIEVING); player.lock(3); player.setNextAnimation(new Animation(833)); replaceObject(object, COFFIN_OPEN[type]); advance(player); return false; } else if (object.getId() == COFFIN_OPEN[type]) { if (!hasRequirement(player, Constants.PRAYER)) { player.sendMessage(""You need a prayer level of "" + getRequirement(Constants.PRAYER) + "" to bless these remains.""); return false; } //TODO: failing drains prayer giveXP(player, Constants.PRAYER); player.lock(3); player.setNextAnimation(new Animation(833)); replaceObject(object, COFFIN_BLESSED[type]); advance(player); return false; } return true; } public void advance(Player player) { if (++stage == 5) setComplete(); } @Override public boolean processNPCClick1(Player player, NPC npc) { if (npc.getId() == GHOST) { player.npcDialogue(GHOST, isComplete() ? HeadE.CHEERFUL : HeadE.SAD, ""Woooo wooooo woooooooo wooo""); return false; } return true; } public class UnhappyGhost extends DungeonNPC { public UnhappyGhost(Tile tile, DungeonManager manager) { super(GHOST, tile, manager); } @Override public void processNPC() { if (!isComplete()) if (Utils.random(5) == 0) setNextAnimation(new Animation(860)); super.processNPC(); } } }" "package com.rs.game.content.skills.dungeoneering.skills; public class DungeoneeringFarming { public enum Harvest { POTATO(17823, 1, 1.3, 17817), GISSEL(17824, 34, 3.5, 17819), EDICAP(17825, 68, 5.7, 17821), SAGEWORT(17826, 7, 15, 17494), VALERIAN(17827, 18, 18.1, 17496), ALOE(17828, 29, 21.9, 17498), WORMWOOD(17829, 40, 27.1, 17500), MAGEBANE(17830, 51, 34.4, 17502), FEATHERFOIL(17831, 62, 44.5, 17504), WINTERS_GRIP(17832, 73, 58.1, 17506), LYCOPUS(17833, 84, 75.9, 17508), BUCKTHORN(17834, 95, 98.6, 17510), SALVE_NETTLES(1, 6.1, 17448), WILDERCRESS(10, 9.2, 17450), BLIGHTLEAF(20, 12.8, 17452), ROSEBLOOD(30, 17.4, 17454), BRYLL(40, 23.5, 17456), DUSKWEED(50, 31.6, 17458), SOULBELL(60, 42.2, 17460), ECTOGRASS(70, 55.8, 17462), RUNELEAF(80, 72.9, 17464), SPIRITBLOOM(90, 94, 17466); private final int seed, lvl, product; private final double exp; Harvest(int seed, int lvl, double exp, int product) { this.seed = seed; this.lvl = lvl; this.exp = exp; this.product = product; } Harvest(int lvl, double exp, int product) { this(-1, lvl, exp, product); } public int getSeed() { return seed; } public int getLvl() { return lvl; } public double getExp() { return exp; } public int getProduct() { return product; } public boolean isTextile() { return seed == -1; } public static Harvest forSeed(int id) { for (Harvest harvest : Harvest.values()) if (harvest.seed == id) return harvest; return null; } } public static int getHerbForLevel(int level) { for (int i = 10; i < Harvest.values().length; i++) if (Harvest.values()[i].lvl == level) return Harvest.values()[i].product; return 17448; } public static void initHarvest(final Player player, final Harvest harvest, final GameObject object) { int harvestCount = player.getTempAttribs().getI(""HARVEST_COUNT""); final boolean isTextile = harvest.isTextile(); final String productName = ItemDefinitions.getDefs(harvest.product).getName().toLowerCase(); DungFarmPatch patch = null; if (object instanceof DungFarmPatch p) patch = p; if (isTextile) if (player.getSkills().getLevel(Constants.FARMING) < harvest.lvl) { player.sendMessage(""You need a Farming level of "" + harvest.lvl + "" in order to pick "" + productName + "".""); return; } if (harvestCount == -1) harvestCount = Utils.random(3, 6); harvestCount--; if (harvestCount == 0) { player.getTempAttribs().removeI(""HARVEST_COUNT""); if (isTextile) player.sendMessage(""You have depleted this resource.""); if (patch != null) patch.destroy(); World.spawnObject(new GameObject(isTextile ? object.getId() + 1 : DungeonConstants.EMPTY_FARMING_PATCH, object.getType(), object.getRotation(), object.getTile())); return; } player.getTempAttribs().setI(""HARVEST_COUNT"", harvestCount); player.setNextAnimation(new Animation(3659)); player.lock(2); WorldTasks.schedule(new Task() { @Override public void run() { if (player.getInventory().addItemDrop(harvest.product, 1)) { player.sendMessage(""You pick a "" + productName + "".""); player.getSkills().addXp(Constants.FARMING, harvest.getExp()); } } }, 2); } public static void plantHarvest(Item item, final Player player, GameObject object, DungeonManager dungeon) { final Harvest harvest = Harvest.forSeed(item.getId()); if (harvest == null) return; if (player.getSkills().getLevel(Constants.FARMING) < harvest.lvl) { player.sendMessage(""You need a Farming level of "" + harvest.lvl + "" in order to plant a "" + ItemDefinitions.getDefs(harvest.seed).getName().toLowerCase() + "".""); return; } DungFarmPatch patch = new DungFarmPatch(player, harvest, object, dungeon); dungeon.getFarmingPatches().add(patch); patch.createReplace(); player.lock(2); player.setNextAnimation(new Animation(3659)); player.getInventory().deleteItem(harvest.seed, 1); } public static void clearHarvest(final Player player, final GameObject object) { player.setNextAnimation(new Animation(3659)); player.lock(2); WorldTasks.scheduleTimer(2, (ticks) -> { World.spawnObject(new GameObject(DungeonConstants.EMPTY_FARMING_PATCH, object.getType(), object.getRotation(), object.getTile())); player.sendMessage(""You empty the harvest patch.""); return false; }); } }" "package com.rs.game.content.skills.dungeoneering.skills; public class DungeoneeringFishing extends PlayerAction { public enum Fish { HEIM_CRAB(17797, 1, 9), RED_EYE(17799, 10, 27), DUSK_EEL(17801, 20, 45), GIANT_FLATFISH(17803, 30, 63), SHORTFINNED_EEL(17805, 40, 81), WEB_SNIPPER(17807, 50, 99), BOULDABASS(17809, 60, 117), SALVE_EEL(17811, 70, 135), BLUE_CRAB(17813, 80, 153), CAVE_MORAY(17815, 90, 171), VILE_FISH(17374, 1, 0); private final int id, level; private final double xp; Fish(int id, int level, double xp) { this.id = id; this.level = level; this.xp = xp; } public int getId() { return id; } public int getLevel() { return level; } public double getXp() { return xp; } } public static final int FLY_FISHING_ROAD_EMOTE = 622; public static final int FLY_FISHING_ROAD = 17794, FEATHER = 17796; private final DungeonFishSpot spot; public DungeoneeringFishing(DungeonFishSpot spot) { this.spot = spot; } @Override public boolean start(Player player) { if (!checkAll(player)) return false; player.sendMessage(""You attempt to capture a fish..."", true); setActionDelay(player, getFishingDelay(player)); return true; } @Override public boolean process(Player player) { player.setNextAnimation(new Animation(FLY_FISHING_ROAD_EMOTE)); return checkAll(player); } private int getFishingDelay(Player player) { int playerLevel = player.getSkills().getLevel(Constants.FISHING); int fishLevel = spot.getFish().getLevel(); int modifier = spot.getFish().getLevel(); int randomAmt = Utils.random(4); double cycleCount, otherBonus = 0; otherBonus += player.getInvisibleSkillBoost(Skills.WOODCUTTING); cycleCount = Math.ceil(((fishLevel + otherBonus) * 50 - playerLevel * 10) / modifier * 0.25 - randomAmt * 4); if (cycleCount < 1) cycleCount = 1; return (int) cycleCount + 1; } @Override public int processWithDelay(Player player) { addFish(player); return getFishingDelay(player); } private void addFish(Player player) { player.sendMessage(""You manage to catch a "" + ItemDefinitions.getDefs(spot.getFish().id).getName().toLowerCase() + ""."", true); player.getInventory().deleteItem(FEATHER, 1); player.getSkills().addXp(Constants.FISHING, spot.getFish().xp); player.getInventory().addItem(spot.getFish().id, 1); if (spot.decreaseFishes() <= 1) { if (spot.getFish() == Fish.VILE_FISH) { spot.addFishes(); player.applyHit(new Hit(player, (int) (player.getMaxHitpoints() * .3), HitLook.TRUE_DAMAGE)); player.sendMessage(""You have a hilarious fishing accident that one day you'll tell your grandchildren about.""); return; } spot.finish(); player.setNextAnimation(new Animation(-1)); player.sendMessage(""You have depleted this resource.""); } } private boolean checkAll(Player player) { if (player.getSkills().getLevel(Constants.FISHING) < spot.getFish().getLevel()) { player.simpleDialogue(""You need a fishing level of "" + spot.getFish().getLevel() + "" to fish here.""); return false; } if (!player.getInventory().containsOneItem(FLY_FISHING_ROAD)) { player.sendMessage(""You need a "" + ItemDefinitions.getDefs(FLY_FISHING_ROAD).getName().toLowerCase() + "" to fish here.""); return false; } if (!player.getInventory().containsOneItem(FEATHER)) { player.sendMessage(""You don't have "" + ItemDefinitions.getDefs(FEATHER).getName().toLowerCase() + "" to fish here.""); return false; } if (!player.getInventory().hasFreeSlots()) { player.setNextAnimation(new Animation(-1)); player.simpleDialogue(""You don't have enough inventory space.""); return false; } return !spot.hasFinished(); } @Override public void stop(Player player) { setActionDelay(player, 3); } }" "package com.rs.game.content.skills.dungeoneering.skills; public class DungeoneeringMining extends PlayerAction { public enum DungeoneeringRocks { NOVITE_ORE(1, 15, 17630, 10, 1), BATHUS_ORE(10, 27.5, 17632, 15, 1), MARMAROS_ORE(20, 41, 17634, 25, 1), KRATONIUM_ORE(30, 56.5, 17636, 50, 5), FRACTITE_ORE(40, 71, 17638, 80, 10), ZEPHYRIUM_ORE(50, 85, 17640, 95, 10), AGRONITE_ORE(60, 100.5, 17642, 100, 15), KATAGON_ORE(70, 117, 17644, 110, 20), GORGONITE_ORE(80, 131, 17646, 123, 22), PROMETHIUM_ORE(90, 148, 17648, 130, 25); private final int level; private final double xp; private final int oreId; private final int oreBaseTime; private final int oreRandomTime; DungeoneeringRocks(int level, double xp, int oreId, int oreBaseTime, int oreRandomTime) { this.level = level; this.xp = xp; this.oreId = oreId; this.oreBaseTime = oreBaseTime; this.oreRandomTime = oreRandomTime; } public int getLevel() { return level; } public double getXp() { return xp; } public int getOreId() { return oreId; } public int getOreBaseTime() { return oreBaseTime; } public int getOreRandomTime() { return oreRandomTime; } } private final GameObject rock; private final DungeoneeringRocks definitions; private DungPickaxe pick; public DungeoneeringMining(GameObject rock, DungeoneeringRocks definitions) { this.rock = rock; this.definitions = definitions; } @Override public boolean start(Player player) { pick = DungPickaxe.getBest(player); if (!checkAll(player)) return false; player.sendMessage(""You swing your pickaxe at the rock.""); setActionDelay(player, getMiningDelay(player)); return true; } private int getMiningDelay(Player player) { int mineTimer = definitions.getOreBaseTime() - player.getSkills().getLevel(Constants.MINING) + Utils.getRandomInclusive(pick.getTicks()); if (mineTimer < 1 + definitions.getOreRandomTime()) mineTimer = 1 + Utils.getRandomInclusive(definitions.getOreRandomTime()); return mineTimer; } private boolean checkAll(Player player) { if (pick == null) { player.sendMessage(""You do not have a pickaxe or do not have the required level to use the pickaxe.""); return false; } if (!hasMiningLevel(player)) return false; if (!player.getInventory().hasFreeSlots()) { player.sendMessage(""Not enough space in your inventory.""); return false; } return true; } private boolean hasMiningLevel(Player player) { if (definitions.getLevel() > player.getSkills().getLevel(Constants.MINING)) { player.sendMessage(""You need a mining level of "" + definitions.getLevel() + "" to mine this rock.""); return false; } return true; } @Override public boolean process(Player player) { player.setNextAnimation(pick.getAnimation()); return checkRock(player); } @Override public int processWithDelay(Player player) { addOre(player); if (Utils.random(5) == 0) { World.spawnObject(new GameObject(rock.getId() + 1, rock.getType(), rock.getRotation(), rock.getX(), rock.getY(), rock.getPlane())); player.sendMessage(""You have depleted this resource.""); player.setNextAnimation(new Animation(-1)); return -1; } if (!player.getInventory().hasFreeSlots() && definitions.getOreId() != -1) { player.setNextAnimation(new Animation(-1)); player.sendMessage(""Not enough space in your inventory.""); return -1; } return getMiningDelay(player); } private void addOre(Player player) { double xpBoost = 1.0; player.getSkills().addXp(Constants.MINING, definitions.getXp() * xpBoost); player.getInventory().addItem(definitions.getOreId(), 1); String oreName = ItemDefinitions.getDefs(definitions.getOreId()).getName().toLowerCase(); player.sendMessage(""You mine some "" + oreName + ""."", true); } private boolean checkRock(Player player) { return World.containsObjectWithId(rock.getTile(), rock.getId()); } @Override public void stop(Player player) { setActionDelay(player, 3); } }" "package com.rs.game.content.skills.dungeoneering.skills; public class DungeoneeringRCD extends Conversation { public enum DungRCRune { // Elemental AIR(17780, 1, .10, 11, 2, 22, 3, 34, 4, 44, 5, 55, 6, 66, 7, 77, 8, 88, 9, 99, 10), WATER(17781, 5, .12, 19, 2, 38, 3, 57, 4, 76, 5, 95, 6), EARTH(17782, 9, .13, 26, 2, 52, 3, 78, 4), FIRE(17783, 14, .14, 35, 2, 70, 3), // Combat MIND(17784, 2, .11, 14, 2, 28, 3, 42, 4, 56, 5, 70, 6, 84, 7, 98, 8), CHAOS(17785, 35, .17, 74, 2), DEATH(17786, 65, .20, 74, 2), BLOOD(17787, 77, .21), // Catalytic BODY(17788, 20, .15, 46, 2, 92, 3), COSMIC(17789, 27, .16, 59, 2), ASTRAL(17790, 40, .174, 82, 2), NATURE(17791, 44, .18, 91, 2), LAW(17792, 54, .19); final int runeId; final int level; final double xp; final int[] multipliers; DungRCRune(int runeId, int level, double xp, int... multipliers) { this.runeId = runeId; this.level = level; this.xp = xp; this.multipliers = multipliers; } } public enum DungRCSet { ELEMENTAL(DungRCRune.AIR, DungRCRune.WATER, DungRCRune.EARTH, DungRCRune.FIRE), COMBAT(DungRCRune.MIND, DungRCRune.CHAOS, DungRCRune.DEATH, DungRCRune.BLOOD), OTHER(DungRCRune.BODY, DungRCRune.COSMIC, DungRCRune.ASTRAL, DungRCRune.NATURE, DungRCRune.LAW), STAVES(); private final DungRCRune[] runes; DungRCSet(DungRCRune... runes) { this.runes = runes; } } static final int[] STAVES = { 16997, 17001, 17005, 17009, 17013, 16999, 17003, 17007, 17011, 17015 }; public DungeoneeringRCD(Player player, DungRCSet set) { super(player); if (set == DungRCSet.STAVES) { addOptions(""What would you like to make?"", ops -> { ops.add(""Runes"").addNext(addMakeOps(DungRCSet.ELEMENTAL)); ops.add(""Staves"").addNext(addMakeOps(null)); }); create(); return; } addNext(addMakeOps(set)); create(); } private Dialogue addMakeOps(DungRCSet set) { Dialogue dialogue = new Dialogue(); if (set == null) { dialogue = dialogue.addNext(new MakeXStatement(MakeXType.MAKE_INTERVAL, STAVES)); for (int i = 0;i < STAVES.length;i++) { final int index = i; dialogue.addNext(() -> player.getActionManager().setAction(new DungeoneeringStaves(index, MakeXStatement.getQuantity(player)))); } return dialogue.getHead(); } int[] items = Arrays.stream(set.runes).mapToInt(rune -> rune.runeId).toArray(); dialogue = dialogue.addNext(new MakeXStatement(MakeXType.MAKE_INTERVAL, items)); for (int i = 0;i < items.length;i++) { final int index = i; dialogue.addNext(() -> player.getActionManager().setAction(new DungeoneeringRunecrafting(MakeXStatement.getQuantity(player), set.runes[index].runeId, set.runes[index].level, set.runes[index].xp, set.runes[index].multipliers))); } return dialogue.getHead(); } }" "package com.rs.game.content.skills.dungeoneering.skills; public class DungeoneeringRunecrafting extends PlayerAction { private final int runeId; private final int levelRequirement; private final int[] multipliers; private int cycles; public DungeoneeringRunecrafting(int cycles, int runeId, int levelRequirement, double experience, int... multipliers) { this.cycles = cycles; this.runeId = runeId; this.levelRequirement = levelRequirement; this.multipliers = multipliers; } @Override public boolean start(Player player) { int actualLevel = player.getSkills().getLevel(Constants.RUNECRAFTING); if (actualLevel < levelRequirement) { player.simpleDialogue(""You need a runecrafting level of "" + levelRequirement + "" to craft this rune.""); return false; } int essence = player.getInventory().getNumberOf(DungeonConstants.ESSENCE); if (essence == 0) return false; if (cycles < essence) cycles = essence; if (cycles > 200) cycles = 200; return true; } @Override public boolean process(Player player) { return cycles > 0; } @Override public int processWithDelay(Player player) { boolean incompleteCycle = cycles < 10; int cycleCount = incompleteCycle ? cycles : 10; cycles -= cycleCount; player.setNextAnimation(new Animation(13659)); player.setNextSpotAnim(new SpotAnim(2571)); player.getSkills().addXp(Constants.RUNECRAFTING, 1); player.getInventory().deleteItem(new Item(DungeonConstants.ESSENCE, cycleCount)); for (int i = multipliers.length - 2; i >= 0; i -= 2) if (player.getSkills().getLevel(Constants.RUNECRAFTING) >= multipliers[i]) { cycleCount *= multipliers[i + 1]; break; } player.getInventory().addItem(new Item(runeId, cycleCount)); return 0; } @Override public void stop(Player player) { setActionDelay(player, 3); } }" "package com.rs.game.content.skills.dungeoneering.skills; public class DungeoneeringSmithing extends PlayerAction { private static final Item[][] materials = { { new Item(17630) }, { new Item(17632) }, { new Item(17634) }, { new Item(17636) }, { new Item(17638) }, { new Item(17640) }, { new Item(17642) }, { new Item(17644) }, { new Item(17646) }, { new Item(17648) } }; private static final Item[][] products = { { new Item(17650) }, { new Item(17652) }, { new Item(17654) }, { new Item(17656) }, { new Item(17658) }, { new Item(17660) }, { new Item(17662) }, { new Item(17664) }, { new Item(17666) }, { new Item(17668) } }; private static final int[] reqs = { 1, 10, 20, 30, 40, 50, 60, 70, 80, 90 }; private static final double[] xp = { 7.0, 13.0, 19.0, 25.0, 32.0, 38.0, 44.0, 51.0, 57.0, 63.0 }; private static final int[] anims = { 3243, 3243, 3243, 3243, 3243, 3243, 3243, 3243, 3243, 3243 }; private static final int[] BASE_COMPONENTS = { 113, 109, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, 105 }; public static void openSmelting(Player player) { player.startConversation(new CreateActionD(player, materials, products, xp, anims, reqs, Constants.SMITHING, 3)); } public static void openInterface(Player player, Item item) { if (item == null) return; DungSmithables[] prods = DungSmithables.forBar(item.getId()); if (prods == null) { player.sendMessage(""You can't smith that.""); return; } player.getTempAttribs().setI(""dungBar"", item.getId()); player.getInterfaceManager().sendInterface(934); for (int i = 0;i < prods.length;i++) { player.getPackets().setIFItem(934, BASE_COMPONENTS[i], prods[i].product.getId(), prods[i].product.getAmount()); player.getPackets().setIFText(934, BASE_COMPONENTS[i] + 1, (prods[i].canMake(player) ? """" : """") + prods[i].product.getName()); player.getPackets().setIFText(934, BASE_COMPONENTS[i] + 2, prods[i].materials[0].getAmount() + "" "" + prods[i].materials[0].getName()); player.getPackets().sendRunScriptReverse(2263, prods[i].product.getName(), prods[i].product.getName(), prods[i].product.getAmount(), (934 << 16 | BASE_COMPONENTS[i] + 3)); } } public static int getIndex(int component) { for (int i = 0;i < BASE_COMPONENTS.length;i++) if ((BASE_COMPONENTS[i]+3) == component) return i; return -1; } public static void handleButtons(Player player, ClientPacket packetId, int componentId) { if (player.getTempAttribs().getI(""dungBar"") == -1) { player.closeInterfaces(); return; } int barId = player.getTempAttribs().getI(""dungBar""); DungSmithables[] prods = DungSmithables.forBar(barId); if (prods == null) return; int index = getIndex(componentId); if (index == -1 || index >= prods.length || prods[index] == null) return; if (packetId == ClientPacket.IF_OP1) player.getActionManager().setAction(new DungeoneeringSmithing(prods[index], 1)); else if (packetId == ClientPacket.IF_OP2) player.getActionManager().setAction(new DungeoneeringSmithing(prods[index], 5)); else if (packetId == ClientPacket.IF_OP3) { player.sendInputInteger(""How many would you like to make?"", number -> player.getActionManager().setAction(new DungeoneeringSmithing(prods[index], number))); } else player.getActionManager().setAction(new DungeoneeringSmithing(prods[index], 28)); } private final DungSmithables bar; private int count; public DungeoneeringSmithing(DungSmithables bar, int count) { this.bar = bar; this.count = count; } @Override public boolean process(Player player) { if (!player.getInventory().containsItem(17883, 1)) { player.sendMessage(""You need a hammer in order to work with metals.""); return false; } if (!bar.canMake(player)) { player.sendMessage(""You need a smithing level of "" + bar.req + "" and "" + bar.materials[0].getAmount() + "" "" + bar.materials[0].getName().toLowerCase() +""s to make that.""); return false; } if (player.getInterfaceManager().containsScreenInter()) { player.getInterfaceManager().removeCentralInterface(); return true; } return true; } @Override public int processWithDelay(Player player) { player.setNextAnimation(new Animation(898)); int numBars = bar.materials[0].getAmount(); if (player.hasScrollOfEfficiency && numBars > 3) if (Utils.getRandomInclusive(15) == 5) numBars--; player.getInventory().deleteItem(bar.materials[0].getId(), numBars); player.getInventory().addItem(bar.product); player.getSkills().addXp(Constants.SMITHING, bar.xp); if (--count == 0) return -1; return 2; } @Override public boolean start(Player player) { if (!player.getInventory().containsItem(17883, 1)) { player.sendMessage(""You need a hammer in order to work with metals.""); return false; } if (!bar.canMake(player)) { player.sendMessage(""You need a smithing level of "" + bar.req + "" and "" + bar.materials[0].getAmount() + "" "" + bar.materials[0].getName().toLowerCase() +""s to make that.""); return false; } return true; } @Override public void stop(Player player) { setActionDelay(player, 2); } }" "package com.rs.game.content.skills.dungeoneering.skills; public class DungeoneeringStaves extends PlayerAction { private static final int[] EMPTY_STAVES = { 16977, 16979, 16981, 16983, 16985, 16987, 16989, 16991, 16993, 16995 }; private static final int[] LEVELS = { 10, 20, 30, 40, 50, 60, 70, 80, 90, 99 }; private static final double[] EXPERIENCE = { 5.5, 12, 20.5, 29, 39.5, 51, 63.5, 76, 90.5, 106 }; private final int index; private int cycles; public DungeoneeringStaves(int index, int cycles) { this.index = index; this.cycles = cycles; } @Override public boolean start(Player player) { int levelReq = LEVELS[index]; if (player.getSkills().getLevel(Constants.RUNECRAFTING) < levelReq) { player.simpleDialogue(""You need a Runecrafting level of "" + levelReq + "" in order to imbue this stave.""); return false; } int staves = getUsableStaves(player, index); if (staves == 0) return false; if (cycles < staves) cycles = staves; if (cycles > 28) cycles = 28; return true; } @Override public boolean process(Player player) { return cycles > 0; } @Override public int processWithDelay(Player player) { cycles--; int stave = getNextStave(player, index); if (stave == -1) return -1; player.setNextAnimation(new Animation(13662)); player.getInventory().deleteItem(new Item(stave, 1)); player.getInventory().addItem(new Item(DungeoneeringRCD.STAVES[index])); double experience = EXPERIENCE[index]; player.getSkills().addXp(Constants.RUNECRAFTING, experience); player.getSkills().addXp(Constants.MAGIC, experience); return 3; } @Override public void stop(Player player) { setActionDelay(player, 3); } private int getUsableStaves(Player player, int beginningIndex) { int staves = 0; for (int i = beginningIndex; i < EMPTY_STAVES.length; i++) staves += player.getInventory().getNumberOf(EMPTY_STAVES[i]); return staves; } private int getNextStave(Player player, int beginningIndex) { for (int i = beginningIndex; i < EMPTY_STAVES.length; i++) { int stave = EMPTY_STAVES[i]; if (player.getInventory().containsItem(stave, 1)) return stave; } return -1; } }" "package com.rs.game.content.skills.dungeoneering.skills; public class DungeoneeringTraps { public static final int[] ITEM_TRAPS = { 17756, 17758, 17760, 17762, 17764, 17766, 17768, 17770, 17772, 17774 }; private static final int[] MASTRYX_HIDES = { 17424, 17426, 17428, 17430, 17432, 17434, 17436, 17438, 17440, 17442 }; private static final int[] HUNTER_LEVELS = { 1, 10, 20, 30, 40, 50, 60, 70, 80, 90 }; public static void placeTrap(final Player player, final DungeonManager manager, final int index) { int levelRequired = HUNTER_LEVELS[index]; if (manager.getMastyxTraps().size() > 5) { player.sendMessage(""Your party has already placed the maximum amount of traps allowed.""); return; } if (player.getSkills().getLevel(Constants.HUNTER) < levelRequired) { player.sendMessage(""You need a Hunter level of "" + levelRequired + "" in order to place this trap.""); return; } player.lock(2); player.setNextAnimation(new Animation(827)); WorldTasks.scheduleTimer(2, (ticks) -> { manager.addMastyxTrap(new MastyxTrap(player.getDisplayName(), 11076 + index, player.getTile())); player.getInventory().deleteItem(new Item(ITEM_TRAPS[index], 1)); player.sendMessage(""You lay the trap onto the floor.""); return false; }); } public static void removeTrap(Player player, MastyxTrap trap, DungeonManager manager) { if (player.getDisplayName().equals(trap.getPlayerName())) { player.setNextAnimation(new Animation(827)); player.sendMessage(""You dismantle the trap.""); player.getInventory().addItem(ITEM_TRAPS[trap.getTier()], 1); manager.removeMastyxTrap(trap); } else player.sendMessage(""This trap is not yours to remove!""); } public static void skinMastyx(Player player, NPC npc) { player.setNextAnimation(new Animation(827)); player.getInventory().addItemDrop(MASTRYX_HIDES[getNPCTier(npc.getId() - 10)], Utils.random(2, 5)); npc.finish(); } public static int getNPCTier(int id) { return id - 11086; } }" "package com.rs.game.content.skills.dungeoneering.skills; public final class DungeoneeringWoodcutting extends PlayerAction { private final GameObject treeObj; private final DungTree type; private DungHatchet hatchet; public DungeoneeringWoodcutting(GameObject treeObj, DungTree type) { this.treeObj = treeObj; this.type = type; } @Override public boolean start(Player player) { if (!checkAll(player)) return false; player.sendMessage(""You swing your hatchet at the tree..."", true); setActionDelay(player, 4); return true; } private boolean checkAll(Player player) { hatchet = DungHatchet.getHatchet(player); if (hatchet == null) { player.sendMessage(""You dont have the required level to use that axe or you don't have a hatchet.""); return false; } if (!hasWoodcuttingLevel(player)) return false; if (!player.getInventory().hasFreeSlots()) { player.sendMessage(""Not enough space in your inventory.""); return false; } return true; } private boolean hasWoodcuttingLevel(Player player) { if (type.getLevel() > player.getSkills().getLevel(8)) { player.sendMessage(""You need a woodcutting level of "" + type.getLevel() + "" to chop down this tree.""); return false; } return true; } @Override public boolean process(Player player) { player.setNextAnimation(new Animation(hatchet.getEmoteId())); return checkTree(player); } @Override public int processWithDelay(Player player) { if (type.rollSuccess(player.getSkills().getLevel(Constants.WOODCUTTING), hatchet)) { type.giveLog(player); if (Utils.random(8) == 0) { World.spawnObject(new GameObject(treeObj.getId() + 1, treeObj.getType(), treeObj.getRotation(), treeObj.getTile())); player.sendMessage(""You have depleted this resource.""); return -1; } } return 4; } private boolean checkTree(Player player) { return ChunkManager.getChunk(treeObj.getTile().getChunkId()).objectExists(treeObj); } @Override public void stop(Player player) { setActionDelay(player, 4); } }" "package com.rs.game.content.skills.dungeoneering.skills; public class DungFarmPatch extends OwnedObject { private int time; private int stage = 1; private final Harvest harvest; private final DungeonManager manager; public DungFarmPatch(Player player, Harvest harvest, GameObject basePatch, DungeonManager manager) { super(player, DungeonConstants.EMPTY_FARMING_PATCH + 1 + 1 + (harvest.ordinal() * 3), basePatch.getType(), basePatch.getRotation(), basePatch.getTile()); this.harvest = harvest; this.manager = manager; } @Override public void onDestroy() { manager.getFarmingPatches().remove(this); } @Override public void tick(Player owner) { time++; if (time >= 50 && stage < 3) { time = 0; stage++; setId(DungeonConstants.EMPTY_FARMING_PATCH + 1 + stage + (harvest.ordinal() * 3)); } } }" "package com.rs.game.content.skills.dungeoneering.skills; public enum DungHatchet { NOVITE(16361, 1, 1.0, 13118), BATHUS(16363, 10, 1.1, 13119), MARMAROS(16365, 20, 1.2, 13120), KRATONITE(16367, 30, 1.3, 13121), FRACTITE(16369, 40, 1.4, 13122), ZEPHYRIUM(16371, 50, 1.5, 13123), ARGONITE(16373, 60, 1.6, 13124), KATAGON(16373, 70, 1.7, 13125), GORGONITE(16375, 80, 1.8, 13126), PROMETHIUM(16379, 90, 1.9, 13127), PRIMAL(16381, 99, 2.0, 13128); private final int itemId, useLevel, emoteId; private final double toolMod; DungHatchet(int itemId, int useLevel, double toolMod, int emoteId) { this.itemId = itemId; this.useLevel = useLevel; this.toolMod = toolMod; this.emoteId = emoteId; } public int getItemId() { return itemId; } public int getUseLevel() { return useLevel; } public double getToolMod() { return toolMod; } public int getEmoteId() { return emoteId; } public static DungHatchet getHatchet(Player player) { for (int i = DungHatchet.values().length-1; i >= 0; i--) { DungHatchet def = DungHatchet.values()[i]; if (player.getInventory().containsItem(def.getItemId()) || player.getEquipment().getWeaponId() == def.getItemId()) if (player.getSkills().getLevel(Constants.WOODCUTTING) >= def.getUseLevel()) return def; } return null; } }" "package com.rs.game.content.skills.dungeoneering.skills; public enum DungPickaxe { NOVITE(16295, 1, 13074, 1), BATHUS(16297, 10, 13075, 3), MARMAROS(16299, 20, 13076, 5), KRATONITE(16301, 30, 13077, 7), FRACTITE(16303, 40, 13078, 10), ZEPHYRIUM(16305, 50, 13079, 12), ARGONITE(16307, 60, 13080, 13), KATAGON(16309, 70, 13081, 15), GORGONITE(16311, 80, 13082, 16), PROMETHIUM(16313, 90, 13083, 17), PRIMAL(16315, 99, 13084, 20); private final int itemId, level, ticks; private final Animation animation; DungPickaxe(int itemId, int level, int animId, int ticks) { this.itemId = itemId; this.level = level; this.animation = new Animation(animId); this.ticks = ticks; } public int getItemId() { return itemId; } public int getLevel() { return level; } public int getTicks() { return ticks; } public Animation getAnimation() { return animation; } public static DungPickaxe getBest(Player player) { for (int i = DungPickaxe.values().length-1; i >= 0; i--) { DungPickaxe def = DungPickaxe.values()[i]; if (player.getInventory().containsItem(def.getItemId()) || player.getEquipment().getWeaponId() == def.getItemId()) if (player.getSkills().getLevel(Constants.MINING) >= def.getLevel()) return def; } return null; } }" "package com.rs.game.content.skills.dungeoneering.skills; public enum DungSmithables { NOVITE_BATTLEAXE(new Item(15753, 1), 5, 25.0, new Item[] { new Item(17650, 2) }), BATHUS_BATTLEAXE(new Item(15755, 1), 15, 43.0, new Item[] { new Item(17652, 2) }), MARMAROS_BATTLEAXE(new Item(15757, 1), 25, 61.0, new Item[] { new Item(17654, 2) }), KRATONITE_BATTLEAXE(new Item(15759, 1), 35, 79.0, new Item[] { new Item(17656, 2) }), FRACTITE_BATTLEAXE(new Item(15761, 1), 45, 97.0, new Item[] { new Item(17658, 2) }), ZEPHYRIUM_BATTLEAXE(new Item(15763, 1), 55, 115.0, new Item[] { new Item(17660, 2) }), ARGONITE_BATTLEAXE(new Item(15765, 1), 65, 133.0, new Item[] { new Item(17662, 2) }), KATAGON_BATTLEAXE(new Item(15767, 1), 75, 151.0, new Item[] { new Item(17664, 2) }), GORGONITE_BATTLEAXE(new Item(15769, 1), 85, 169.0, new Item[] { new Item(17666, 2) }), PROMETHIUM_BATTLEAXE(new Item(15771, 1), 95, 187.0, new Item[] { new Item(17668, 2) }), NOVITE_GAUNTLETS(new Item(16273, 1), 1, 10.0, new Item[] { new Item(17650, 1) }), BATHUS_GAUNTLETS(new Item(16275, 1), 11, 19.0, new Item[] { new Item(17652, 1) }), MARMAROS_GAUNTLETS(new Item(16277, 1), 21, 28.0, new Item[] { new Item(17654, 1) }), KRATONITE_GAUNTLETS(new Item(16279, 1), 31, 37.0, new Item[] { new Item(17656, 1) }), FRACTITE_GAUNTLETS(new Item(16281, 1), 41, 46.0, new Item[] { new Item(17658, 1) }), ZEPHYRIUM_GAUNTLETS(new Item(16283, 1), 51, 55.0, new Item[] { new Item(17660, 1) }), ARGONITE_GAUNTLETS(new Item(16285, 1), 61, 64.0, new Item[] { new Item(17662, 1) }), KATAGON_GAUNTLETS(new Item(16287, 1), 71, 73.0, new Item[] { new Item(17664, 1) }), GORGONITE_GAUNTLETS(new Item(16289, 1), 81, 82.0, new Item[] { new Item(17666, 1) }), PROMETHIUM_GAUNTLETS(new Item(16291, 1), 91, 91.0, new Item[] { new Item(17668, 1) }), NOVITE_PICKAXE(new Item(16295, 1), 2, 11.0, new Item[] { new Item(17650, 1) }), BATHUS_PICKAXE(new Item(16297, 1), 12, 20.0, new Item[] { new Item(17652, 1) }), MARMAROS_PICKAXE(new Item(16299, 1), 22, 29.0, new Item[] { new Item(17654, 1) }), KRATONITE_PICKAXE(new Item(16301, 1), 32, 38.0, new Item[] { new Item(17656, 1) }), FRACTITE_PICKAXE(new Item(16303, 1), 42, 47.0, new Item[] { new Item(17658, 1) }), ZEPHYRIUM_PICKAXE(new Item(16305, 1), 52, 56.0, new Item[] { new Item(17660, 1) }), ARGONITE_PICKAXE(new Item(16307, 1), 62, 65.0, new Item[] { new Item(17662, 1) }), KATAGON_PICKAXE(new Item(16309, 1), 72, 74.0, new Item[] { new Item(17664, 1) }), GORGONITE_PICKAXE(new Item(16311, 1), 82, 83.0, new Item[] { new Item(17666, 1) }), PROMETHIUM_PICKAXE(new Item(16313, 1), 92, 92.0, new Item[] { new Item(17668, 1) }), NOVITE_BOOTS(new Item(16339, 1), 1, 10.0, new Item[] { new Item(17650, 1) }), BATHUS_BOOTS(new Item(16341, 1), 11, 19.0, new Item[] { new Item(17652, 1) }), MARMAROS_BOOTS(new Item(16343, 1), 21, 28.0, new Item[] { new Item(17654, 1) }), KRATONITE_BOOTS(new Item(16345, 1), 31, 37.0, new Item[] { new Item(17656, 1) }), FRACTITE_BOOTS(new Item(16347, 1), 41, 46.0, new Item[] { new Item(17658, 1) }), ZEPHYRIUM_BOOTS(new Item(16349, 1), 51, 55.0, new Item[] { new Item(17660, 1) }), ARGONITE_BOOTS(new Item(16351, 1), 61, 64.0, new Item[] { new Item(17662, 1) }), KATAGON_BOOTS(new Item(16353, 1), 71, 73.0, new Item[] { new Item(17664, 1) }), GORGONITE_BOOTS(new Item(16355, 1), 81, 82.0, new Item[] { new Item(17666, 1) }), PROMETHIUM_BOOTS(new Item(16357, 1), 91, 91.0, new Item[] { new Item(17668, 1) }), NOVITE_HATCHET(new Item(16361, 1), 2, 11.0, new Item[] { new Item(17650, 1) }), BATHUS_HATCHET(new Item(16363, 1), 12, 20.0, new Item[] { new Item(17652, 1) }), MARMAROS_HATCHET(new Item(16365, 1), 22, 29.0, new Item[] { new Item(17654, 1) }), KRATONITE_HATCHET(new Item(16367, 1), 32, 38.0, new Item[] { new Item(17656, 1) }), FRACTITE_HATCHET(new Item(16369, 1), 42, 47.0, new Item[] { new Item(17658, 1) }), ZEPHYRIUM_HATCHET(new Item(16371, 1), 52, 56.0, new Item[] { new Item(17660, 1) }), ARGONITE_HATCHET(new Item(16373, 1), 62, 65.0, new Item[] { new Item(17662, 1) }), KATAGON_HATCHET(new Item(16375, 1), 72, 74.0, new Item[] { new Item(17664, 1) }), GORGONITE_HATCHET(new Item(16377, 1), 82, 83.0, new Item[] { new Item(17666, 1) }), PROMETHIUM_HATCHET(new Item(16379, 1), 92, 92.0, new Item[] { new Item(17668, 1) }), NOVITE_LONGSWORD(new Item(16383, 1), 4, 24.0, new Item[] { new Item(17650, 2) }), BATHUS_LONGSWORD(new Item(16385, 1), 14, 42.0, new Item[] { new Item(17652, 2) }), MARMAROS_LONGSWORD(new Item(16387, 1), 24, 60.0, new Item[] { new Item(17654, 2) }), KRATONITE_LONGSWORD(new Item(16389, 1), 34, 78.0, new Item[] { new Item(17656, 2) }), FRACTITE_LONGSWORD(new Item(16391, 1), 44, 96.0, new Item[] { new Item(17658, 2) }), ZEPHYRIUM_LONGSWORD(new Item(16393, 1), 54, 114.0, new Item[] { new Item(17660, 2) }), ARGONITE_LONGSWORD(new Item(16395, 1), 64, 132.0, new Item[] { new Item(17662, 2) }), KATAGON_LONGSWORD(new Item(16397, 1), 74, 150.0, new Item[] { new Item(17664, 2) }), GORGONITE_LONGSWORD(new Item(16399, 1), 84, 168.0, new Item[] { new Item(17666, 2) }), PROMETHIUM_LONGSWORD(new Item(16401, 1), 94, 186.0, new Item[] { new Item(17668, 2) }), NOVITE_MAUL(new Item(16405, 1), 8, 56.0, new Item[] { new Item(17650, 4) }), BATHUS_MAUL(new Item(16407, 1), 18, 92.0, new Item[] { new Item(17652, 4) }), MARMAROS_MAUL(new Item(16409, 1), 28, 128.0, new Item[] { new Item(17654, 4) }), KRATONITE_MAUL(new Item(16411, 1), 38, 164.0, new Item[] { new Item(17656, 4) }), FRACTITE_MAUL(new Item(16413, 1), 48, 200.0, new Item[] { new Item(17658, 4) }), ZEPHYRIUM_MAUL(new Item(16415, 1), 58, 236.0, new Item[] { new Item(17660, 4) }), ARGONITE_MAUL(new Item(16417, 1), 68, 272.0, new Item[] { new Item(17662, 4) }), KATAGON_MAUL(new Item(16419, 1), 78, 308.0, new Item[] { new Item(17664, 4) }), GORGONITE_MAUL(new Item(16421, 1), 88, 344.0, new Item[] { new Item(17666, 4) }), PROMETHIUM_MAUL(new Item(16423, 1), 98, 380.0, new Item[] { new Item(17668, 4) }), NOVITE_PLATESKIRT(new Item(16647, 1), 7, 40.0, new Item[] { new Item(17650, 3) }), BATHUS_PLATESKIRT(new Item(16649, 1), 17, 67.0, new Item[] { new Item(17652, 3) }), MARMAROS_PLATESKIRT(new Item(16651, 1), 27, 94.0, new Item[] { new Item(17654, 3) }), KRATONITE_PLATESKIRT(new Item(16653, 1), 37, 121.0, new Item[] { new Item(17656, 3) }), FRACTITE_PLATESKIRT(new Item(16655, 1), 47, 148.0, new Item[] { new Item(17658, 3) }), ZEPHYRIUM_PLATESKIRT(new Item(16657, 1), 57, 175.0, new Item[] { new Item(17660, 3) }), ARGONITE_PLATESKIRT(new Item(16659, 1), 67, 202.0, new Item[] { new Item(17662, 3) }), KATAGON_PLATESKIRT(new Item(16661, 1), 77, 229.0, new Item[] { new Item(17664, 3) }), GORGONITE_PLATESKIRT(new Item(16663, 1), 87, 256.0, new Item[] { new Item(17666, 3) }), PROMETHIUM_PLATESKIRT(new Item(16665, 1), 97, 283.0, new Item[] { new Item(17668, 3) }), NOVITE_PLATELEGS(new Item(16669, 1), 7, 40.0, new Item[] { new Item(17650, 3) }), BATHUS_PLATELEGS(new Item(16671, 1), 17, 67.0, new Item[] { new Item(17652, 3) }), MARMAROS_PLATELEGS(new Item(16673, 1), 27, 94.0, new Item[] { new Item(17654, 3) }), KRATONITE_PLATELEGS(new Item(16675, 1), 37, 121.0, new Item[] { new Item(17656, 3) }), FRACTITE_PLATELEGS(new Item(16677, 1), 47, 148.0, new Item[] { new Item(17658, 3) }), ZEPHYRIUM_PLATELEGS(new Item(16679, 1), 57, 175.0, new Item[] { new Item(17660, 3) }), ARGONITE_PLATELEGS(new Item(16681, 1), 67, 202.0, new Item[] { new Item(17662, 3) }), KATAGON_PLATELEGS(new Item(16683, 1), 77, 229.0, new Item[] { new Item(17664, 3) }), GORGONITE_PLATELEGS(new Item(16685, 1), 87, 256.0, new Item[] { new Item(17666, 3) }), PROMETHIUM_PLATELEGS(new Item(16687, 1), 97, 283.0, new Item[] { new Item(17668, 3) }), NOVITE_FULL_HELM(new Item(16691, 1), 5, 25.0, new Item[] { new Item(17650, 2) }), BATHUS_FULL_HELM(new Item(16693, 1), 15, 43.0, new Item[] { new Item(17652, 2) }), MARMAROS_FULL_HELM(new Item(16695, 1), 25, 61.0, new Item[] { new Item(17654, 2) }), KRATONITE_FULL_HELM(new Item(16697, 1), 35, 79.0, new Item[] { new Item(17656, 2) }), FRACTITE_FULL_HELM(new Item(16699, 1), 45, 97.0, new Item[] { new Item(17658, 2) }), ZEPHYRIUM_FULL_HELM(new Item(16701, 1), 55, 115.0, new Item[] { new Item(17660, 2) }), ARGONITE_FULL_HELM(new Item(16703, 1), 65, 133.0, new Item[] { new Item(17662, 2) }), KATAGON_FULL_HELM(new Item(16705, 1), 75, 151.0, new Item[] { new Item(17664, 2) }), GORGONITE_FULL_HELM(new Item(16707, 1), 85, 169.0, new Item[] { new Item(17666, 2) }), PROMETHIUM_FULL_HELM(new Item(16709, 1), 95, 187.0, new Item[] { new Item(17668, 2) }), NOVITE_CHAINBODY(new Item(16713, 1), 6, 39.0, new Item[] { new Item(17650, 3) }), BATHUS_CHAINBODY(new Item(16715, 1), 16, 66.0, new Item[] { new Item(17652, 3) }), MARMAROS_CHAINBODY(new Item(16717, 1), 26, 93.0, new Item[] { new Item(17654, 3) }), KRATONITE_CHAINBODY(new Item(16719, 1), 36, 120.0, new Item[] { new Item(17656, 3) }), FRACTITE_CHAINBODY(new Item(16721, 1), 46, 147.0, new Item[] { new Item(17658, 3) }), ZEPHYRIUM_CHAINBODY(new Item(16723, 1), 56, 174.0, new Item[] { new Item(17660, 3) }), ARGONITE_CHAINBODY(new Item(16725, 1), 66, 201.0, new Item[] { new Item(17662, 3) }), KATAGON_CHAINBODY(new Item(16727, 1), 76, 228.0, new Item[] { new Item(17664, 3) }), GORGONITE_CHAINBODY(new Item(16729, 1), 86, 255.0, new Item[] { new Item(17666, 3) }), PROMETHIUM_CHAINBODY(new Item(16731, 1), 96, 282.0, new Item[] { new Item(17668, 3) }), NOVITE_DAGGER(new Item(16757, 1), 1, 10.0, new Item[] { new Item(17650, 1) }), BATHUS_DAGGER(new Item(16765, 1), 10, 19.0, new Item[] { new Item(17652, 1) }), MARMAROS_DAGGER(new Item(16773, 1), 20, 28.0, new Item[] { new Item(17654, 1) }), KRATONITE_DAGGER(new Item(16781, 1), 30, 37.0, new Item[] { new Item(17656, 1) }), FRACTITE_DAGGER(new Item(16789, 1), 40, 46.0, new Item[] { new Item(17658, 1) }), ZEPHYRIUM_DAGGER(new Item(16797, 1), 50, 55.0, new Item[] { new Item(17660, 1) }), ARGONITE_DAGGER(new Item(16805, 1), 60, 64.0, new Item[] { new Item(17662, 1) }), KATAGON_DAGGER(new Item(16813, 1), 70, 73.0, new Item[] { new Item(17664, 1) }), GORGONITE_DAGGER(new Item(16821, 1), 80, 82.0, new Item[] { new Item(17666, 1) }), PROMETHIUM_DAGGER(new Item(16829, 1), 90, 91.0, new Item[] { new Item(17668, 1) }), NOVITE_2H_SWORD(new Item(16889, 1), 8, 56.0, new Item[] { new Item(17650, 4) }), BATHUS_2H_SWORD(new Item(16891, 1), 18, 92.0, new Item[] { new Item(17652, 4) }), MARMAROS_2H_SWORD(new Item(16893, 1), 28, 128.0, new Item[] { new Item(17654, 4) }), KRATONITE_2H_SWORD(new Item(16895, 1), 38, 164.0, new Item[] { new Item(17656, 4) }), FRACTITE_2H_SWORD(new Item(16897, 1), 48, 200.0, new Item[] { new Item(17658, 4) }), ZEPHYRIUM_2H_SWORD(new Item(16899, 1), 58, 236.0, new Item[] { new Item(17660, 4) }), ARGONITE_2H_SWORD(new Item(16901, 1), 68, 272.0, new Item[] { new Item(17662, 4) }), KATAGON_2H_SWORD(new Item(16903, 1), 78, 308.0, new Item[] { new Item(17664, 4) }), GORGONITE_2H_SWORD(new Item(16905, 1), 88, 344.0, new Item[] { new Item(17666, 4) }), PROMETHIUM_2H_SWORD(new Item(16907, 1), 98, 380.0, new Item[] { new Item(17668, 4) }), NOVITE_RAPIER(new Item(16935, 1), 3, 23.0, new Item[] { new Item(17650, 2) }), BATHUS_RAPIER(new Item(16937, 1), 13, 41.0, new Item[] { new Item(17652, 2) }), MARMAROS_RAPIER(new Item(16939, 1), 23, 59.0, new Item[] { new Item(17654, 2) }), KRATONITE_RAPIER(new Item(16941, 1), 33, 77.0, new Item[] { new Item(17656, 2) }), FRACTITE_RAPIER(new Item(16943, 1), 43, 95.0, new Item[] { new Item(17658, 2) }), ZEPHYRIUM_RAPIER(new Item(16945, 1), 53, 113.0, new Item[] { new Item(17660, 2) }), ARGONITE_RAPIER(new Item(16947, 1), 63, 131.0, new Item[] { new Item(17662, 2) }), KATAGON_RAPIER(new Item(16949, 1), 73, 149.0, new Item[] { new Item(17664, 2) }), GORGONITE_RAPIER(new Item(16951, 1), 83, 167.0, new Item[] { new Item(17666, 2) }), PROMETHIUM_RAPIER(new Item(16953, 1), 93, 185.0, new Item[] { new Item(17668, 2) }), NOVITE_WARHAMMER(new Item(17019, 1), 3, 23.0, new Item[] { new Item(17650, 2) }), BATHUS_WARHAMMER(new Item(17021, 1), 13, 41.0, new Item[] { new Item(17652, 2) }), MARMAROS_WARHAMMER(new Item(17023, 1), 23, 59.0, new Item[] { new Item(17654, 2) }), KRATONITE_WARHAMMER(new Item(17025, 1), 33, 77.0, new Item[] { new Item(17656, 2) }), FRACTITE_WARHAMMER(new Item(17027, 1), 43, 95.0, new Item[] { new Item(17658, 2) }), ZEPHYRIUM_WARHAMMER(new Item(17029, 1), 53, 113.0, new Item[] { new Item(17660, 2) }), ARGONITE_WARHAMMER(new Item(17031, 1), 63, 131.0, new Item[] { new Item(17662, 2) }), KATAGON_WARHAMMER(new Item(17033, 1), 73, 149.0, new Item[] { new Item(17664, 2) }), GORGONITE_WARHAMMER(new Item(17035, 1), 83, 167.0, new Item[] { new Item(17666, 2) }), PROMETHIUM_WARHAMMER(new Item(17037, 1), 93, 185.0, new Item[] { new Item(17668, 2) }), NOVITE_SPEAR(new Item(17063, 1), 7, 54.0, new Item[] { new Item(17650, 4) }), BATHUS_SPEAR(new Item(17071, 1), 17, 90.0, new Item[] { new Item(17652, 4) }), MARMAROS_SPEAR(new Item(17079, 1), 27, 126.0, new Item[] { new Item(17654, 4) }), KRATONITE_SPEAR(new Item(17087, 1), 37, 162.0, new Item[] { new Item(17656, 4) }), FRACTITE_SPEAR(new Item(17095, 1), 47, 198.0, new Item[] { new Item(17658, 4) }), ZEPHYRIUM_SPEAR(new Item(17103, 1), 57, 234.0, new Item[] { new Item(17660, 4) }), ARGONITE_SPEAR(new Item(17111, 1), 67, 270.0, new Item[] { new Item(17662, 4) }), KATAGON_SPEAR(new Item(17119, 1), 77, 306.0, new Item[] { new Item(17664, 4) }), GORGONITE_SPEAR(new Item(17127, 1), 87, 342.0, new Item[] { new Item(17666, 4) }), PROMETHIUM_SPEAR(new Item(17135, 1), 97, 378.0, new Item[] { new Item(17668, 4) }), NOVITE_PLATEBODY(new Item(17239, 1), 9, 72.0, new Item[] { new Item(17650, 5) }), BATHUS_PLATEBODY(new Item(17241, 1), 19, 117.0, new Item[] { new Item(17652, 5) }), MARMAROS_PLATEBODY(new Item(17243, 1), 29, 162.0, new Item[] { new Item(17654, 5) }), KRATONITE_PLATEBODY(new Item(17245, 1), 39, 207.0, new Item[] { new Item(17656, 5) }), FRACTITE_PLATEBODY(new Item(17247, 1), 49, 252.0, new Item[] { new Item(17658, 5) }), ZEPHYRIUM_PLATEBODY(new Item(17249, 1), 59, 297.0, new Item[] { new Item(17660, 5) }), ARGONITE_PLATEBODY(new Item(17251, 1), 69, 342.0, new Item[] { new Item(17662, 5) }), KATAGON_PLATEBODY(new Item(17253, 1), 79, 387.0, new Item[] { new Item(17664, 5) }), GORGONITE_PLATEBODY(new Item(17255, 1), 89, 432.0, new Item[] { new Item(17666, 5) }), PROMETHIUM_PLATEBODY(new Item(17257, 1), 99, 477.0, new Item[] { new Item(17668, 5) }), NOVITE_KITESHIELD(new Item(17341, 1), 6, 39.0, new Item[] { new Item(17650, 3) }), BATHUS_KITESHIELD(new Item(17343, 1), 16, 66.0, new Item[] { new Item(17652, 3) }), MARMAROS_KITESHIELD(new Item(17345, 1), 26, 93.0, new Item[] { new Item(17654, 3) }), KRATONITE_KITESHIELD(new Item(17347, 1), 36, 120.0, new Item[] { new Item(17656, 3) }), FRACTITE_KITESHIELD(new Item(17349, 1), 46, 147.0, new Item[] { new Item(17658, 3) }), ZEPHYRIUM_KITESHIELD(new Item(17351, 1), 56, 174.0, new Item[] { new Item(17660, 3) }), ARGONITE_KITESHIELD(new Item(17353, 1), 66, 201.0, new Item[] { new Item(17662, 3) }), KATAGON_KITESHIELD(new Item(17355, 1), 76, 228.0, new Item[] { new Item(17664, 3) }), GORGONITE_KITESHIELD(new Item(17357, 1), 86, 255.0, new Item[] { new Item(17666, 3) }), PROMETHIUM_KITESHIELD(new Item(17359, 1), 96, 282.0, new Item[] { new Item(17668, 3) }), NOVITE_ARROWHEADS(new Item(17885, 20), 1, 10.0, new Item[] { new Item(17650, 1) }), BATHUS_ARROWHEADS(new Item(17890, 20), 10, 19.0, new Item[] { new Item(17652, 1) }), MARMAROS_ARROWHEADS(new Item(17895, 20), 20, 28.0, new Item[] { new Item(17654, 1) }), KRATONITE_ARROWHEADS(new Item(17900, 20), 30, 37.0, new Item[] { new Item(17656, 1) }), FRACTITE_ARROWHEADS(new Item(17905, 20), 40, 46.0, new Item[] { new Item(17658, 1) }), ZEPHYRIUM_ARROWHEADS(new Item(17910, 20), 50, 55.0, new Item[] { new Item(17660, 1) }), ARGONITE_ARROWHEADS(new Item(17915, 20), 60, 64.0, new Item[] { new Item(17662, 1) }), KATAGON_ARROWHEADS(new Item(17920, 20), 70, 73.0, new Item[] { new Item(17664, 1) }), GORGONITE_ARROWHEADS(new Item(17925, 20), 80, 82.0, new Item[] { new Item(17666, 1) }), PROMETHIUM_ARROWHEADS(new Item(17930, 20), 90, 91.0, new Item[] { new Item(17668, 1) }); public final Item product; public final int req; public final double xp; public final Item[] materials; public static final HashMap SMITHABLES = new HashMap<>(); static { for (int i = 17650;i <= 17668;i += 2) SMITHABLES.put(i, DungSmithables.genSortedArray(i)); } DungSmithables(Item product, int req, double xp, Item[] materials) { this.product = product; this.req = req; this.xp = xp; this.materials = materials; } public static DungSmithables[] forBar(int barId) { return SMITHABLES.get(barId); } private static DungSmithables[] genSortedArray(int barId) { ArrayList prods = new ArrayList<>(); for (DungSmithables d : DungSmithables.values()) if (d.materials[0].getId() == barId) prods.add(d); // TODO: IntelliJ says to replace 247 with prods.sort(Comparator.comparingInt(ds -> ds.req)); prods.sort((ds1, ds2) -> ds1.req < ds2.req ? -1 : (ds1.req > ds2.req) ? 1 : 0); DungSmithables[] arr = new DungSmithables[prods.size()]; for (int i = 0;i < arr.length;i++) arr[i] = prods.get(i); return arr; } public boolean canMake(Player player) { return player.getInventory().containsItems(materials) && player.getSkills().getLevel(Constants.SMITHING) >= req; } }" "package com.rs.game.content.skills.dungeoneering.skills; public enum DungTree { TANGLE_GUM_VINE(1, 35, 17682, 150, 255), SEEPING_ELM_TREE(10, 60, 17684, 150, 240), BLOOD_SPINDLE_TREE(20, 85, 17686, 150, 230), UTUKU_TREE(30, 115, 17688, 150, 220), SPINEBEAM_TREE(40, 145, 17690, 150, 210), BOVISTRANGLER_TREE(50, 175, 17692, 150, 200), THIGAT_TREE(60, 210, 17694, 150, 190), CORPESTHORN_TREE(70, 245, 17696, 150, 180), ENTGALLOW_TREE(80, 285, 17698, 150, 170), GRAVE_CREEPER_TREE(90, 330, 17700, 150, 170); private final int level, logsId, rate1, rate99; private final double xp; DungTree(int level, double xp, int logsId, int rate1, int rate99) { this.level = level; this.xp = xp; this.logsId = logsId; this.rate1 = rate1; this.rate99 = rate99; } public int getLevel() { return level; } public double getXp() { return xp; } public int getLogsId() { return logsId; } public boolean rollSuccess(int level, DungHatchet hatchet) { return Utils.skillSuccess(level, hatchet.getToolMod(), rate1, rate99); } public void giveLog(Player player) { player.getInventory().addItem(logsId, 1); player.getSkills().addXp(Constants.WOODCUTTING, xp); } }" "package com.rs.game.content.skills.farming; @PluginEventHandler public class FarmingContainers { private static void fillUp(Player player, Item item, ProduceContainer container, boolean empty) { if (empty) { Item next = player.getInventory().findItemByIds(ProduceContainer.getReverseFillIdsForContainerId(item.getId())); if (next == null) { player.sendMessage(""You don't have any produce to add!""); return; } container = ProduceContainer.forFillId(next.getId()); } if (container == null) return; int inventoryCount = player.getInventory().getAmountOf(container.getFillId()); if (inventoryCount == 0) { player.sendMessage(""You don't have any produce to add!""); return; } int currentCount = container.getCountForItemId(item.getId()); if (currentCount == container.getContainerSize()) { return; } int maxProduceToFill = Math.min(container.getContainerSize(), currentCount + inventoryCount); int nextId = container.getItemIdForCount(maxProduceToFill); player.getInventory().replace(item, new Item(nextId)); player.getInventory().deleteItem(container.getFillId(), container.getContainerSize() - currentCount); player.getInventory().refresh(); } private static void removeOne(Player player, Item item) { ProduceContainer container = ProduceContainer.forId(item.getId()); if (container == null) return; int currentCount = container.getCountForItemId(item.getId()); if (currentCount == 1) { player.getInventory().replace(item, new Item(container.getContainerId(), 1)); } else { int newCount = currentCount - 1; player.getInventory().replace(item, new Item(container.getItemIdForCount(newCount))); } player.getInventory().addItemDrop(new Item(container.getFillId(), 1)); player.getInventory().refresh(); } private static void empty(Player player, Item item) { ProduceContainer container = ProduceContainer.forId(item.getId()); if (container == null) return; int currentCount = container.getCountForItemId(item.getId()); player.getInventory().replace(item, new Item(container.getContainerId(), 1)); player.getInventory().addItemDrop(new Item(container.getFillId(), currentCount)); player.getInventory().refresh(); } public static ItemOnItemHandler fillFarmingContainer = new ItemOnItemHandler(new int[] { 5376, 5378, 5380, 5382, 5384, 5386, 5388, 5390, 5392, 5394, 5396, 5398, 5400, 5402, 5404, 5406, 5408, 5410, 5412, 5414, 5416, 5960, 5962, 5964, 5966, 5968, 5418, 5420, 5422, 5424, 5426, 5428, 5430, 5432, 5434, 5436, 5438, 5440, 5442, 5444, 5446, 5448, 5450, 5452, 5454, 5456, 5458, 5460, 5462, 5464, 5466, 5468, 5470, 5472, 5474, 5476, 5478, }, new int[] { 1942, 1957, 1965, 1955, 2108, 5504, 1963, 1982 }, e -> { ProduceContainer container = ProduceContainer.forId(e.getItem1().getId()); Item item = e.getItem1(); boolean empty = ProduceContainer.isEmptyContainer(e.getItem1().getId()); if (!empty && container == null) { container = ProduceContainer.forId(e.getItem2().getId()); item = e.getItem2(); empty = ProduceContainer.isEmptyContainer(e.getItem2().getId()); } fillUp(e.getPlayer(), item, container, empty); }); public static ItemClickHandler clickFarmingContainer = new ItemClickHandler(new Integer[] { 5376, 5378, 5380, 5382, 5384, 5386, 5388, 5390, 5392, 5394, 5396, 5398, 5400, 5402, 5404, 5406, 5408, 5410, 5412, 5414, 5416, 5960, 5962, 5964, 5966, 5968, 5418, 5420, 5422, 5424, 5426, 5428, 5430, 5432, 5434, 5436, 5438, 5440, 5442, 5444, 5446, 5448, 5450, 5452, 5454, 5456, 5458, 5460, 5462, 5464, 5466, 5468, 5470, 5472, 5474, 5476, 5478, }, new String[] { ""Fill"", ""Remove-one"", ""Empty"" }, e -> { switch (e.getOption()) { case ""Fill"" -> { ProduceContainer container = ProduceContainer.forId(e.getItem().getId()); boolean empty = ProduceContainer.isEmptyContainer(e.getItem().getId()); fillUp(e.getPlayer(), e.getItem(), container, empty); } case ""Remove-one"" -> removeOne(e.getPlayer(), e.getItem()); case ""Empty"" -> empty(e.getPlayer(), e.getItem()); } }); }" "package com.rs.game.content.skills.farming; @PluginEventHandler public class FarmPatch { public static int FARMING_TICK = 500; public static final int[] COMPOST_ORGANIC = { 6055, 1942, 1957, 1965, 5986, 5504, 5982, 249, 251, 253, 255, 257, 2998, 259, 261, 263, 3000, 265, 2481, 267, 269, 1951, 753, 2126, 247, 239, 6018 }; public static final int[] SUPER_COMPOST_ORGANIC = { 2114, 5978, 5980, 5982, 6004, 247, 6469, 19974 }; public static final Animation RAKING_ANIMATION = new Animation(2273), WATERING_ANIMATION = new Animation(2293), SEED_DIBBING_ANIMATION = new Animation(2291), SPADE_ANIMATION = new Animation(830), HERB_PICKING_ANIMATION = new Animation(2282), MAGIC_PICKING_ANIMATION = new Animation(2286), CURE_PLANT_ANIMATION = new Animation(2288), CHECK_TREE_ANIMATION = new Animation(832), PRUNING_ANIMATION = new Animation(2275), FLOWER_PICKING_ANIMATION = new Animation(2292), FRUIT_PICKING_ANIMATION = new Animation(2280), COMPOST_ANIMATION = new Animation(2283), BUSH_PICKING_ANIMATION = new Animation(2281), FILL_COMPOST_ANIMATION = new Animation(832); public PatchLocation location; public ProduceType seed; public int weeds; public int growthStage; public int totalGrowthTicks; public boolean diseased; public boolean watered; public boolean dead; public boolean diseaseProtected; public int compostLevel; public int lives; public boolean checkedHealth; public FarmPatch(PatchLocation location) { this.location = location; empty(); weeds = 3; } private void handleClick(Player player, GameObject object, String option, ClientPacket opNum) { if (location.type == PatchType.COMPOST) { if (seed == null) { if (lives <= -15) { seed = compostLevel == 1 ? ProduceType.Compost : ProduceType.Supercompost; lives = 0; updateVars(player); } } else if (lives > 0) { if (!checkedHealth) { checkedHealth = true; updateVars(player); return; } player.getActionManager().setAction(new HarvestPatch(this)); } else player.sendMessage(""The compost doesn't smell ready to be collected yet.""); return; } switch(option) { case ""Rake"": player.getActionManager().setAction(new RakeAction(this)); return; case ""Inspect"": if (player.hasRights(Rights.DEVELOPER)) player.sendMessage(this.toString()); player.startConversation(new Dialogue().addSimple(""Yep! Looks like a "" + object.getDefinitions(player).getName().toLowerCase() + "" to me!"")); return; case ""Guide"": return; case ""Check-health"": if (checkedHealth) return; player.getSkills().addXp(Constants.FARMING, seed.experience); checkedHealth = true; updateVars(player); return; case ""Prune"": if (diseased) { player.setNextAnimation(PRUNING_ANIMATION); player.sendMessage(""You prune the diseased leaves from the plant.""); player.lock(6); WorldTasks.delay(5, () -> { diseased = false; updateVars(player); player.setNextAnimation(new Animation(-1)); }); } return; case ""Clear"": if (!player.getInventory().containsItem(952)) { player.sendMessage(""You need a spade to clear the patch with.""); return; } promptClear(player); return; case ""Gather-Branches"": player.getActionManager().setAction(new HarvestPatch(this)); return; } switch(opNum) { case OBJECT_OP1: if (option.contains(""Pick"") || option.contains(""Harvest"")) player.getActionManager().setAction(new HarvestPatch(this)); else if (option.contains(""Chop"")) { TreeType type = TreeType.FRUIT_TREE; type = switch (seed) { case Oak -> TreeType.OAK; case Willow -> TreeType.WILLOW; case Maple -> TreeType.MAPLE; case Yew -> TreeType.YEW; case Magic -> TreeType.MAGIC; default -> TreeType.FRUIT_TREE; }; player.getActionManager().setAction(new Woodcutting(object, type) { @Override public void fellTree() { lives = -1; updateVars(player); } @Override public boolean checkTree() { return lives == 0; } }); } return; default: return; } } private void useItem(Player player, GameObject object, Item item) { if (location.type == PatchType.COMPOST) { if (seed == null) player.getActionManager().setAction(new FillCompostBin(this, item)); return; } ProduceType produce = ProduceType.forSeed(item.getId()); if (produce != null) { if (weeds > 0) { player.sendMessage(""You need to rake the patch first.""); return; } if (seed != null) { player.sendMessage(""You already have something growing here.""); return; } if (produce.type != location.type || (location == PatchLocation.Wilderness_flower && produce != ProduceType.Limpwurt) || (location == PatchLocation.Burthorpe_potato_patch && produce != ProduceType.Potato)) { player.sendMessage(""You can't grow that here.""); return; } if (player.getSkills().getLevel(Constants.FARMING) < produce.level) { player.sendMessage(""You need a Farming level of "" + produce.level + "" to plant that.""); return; } if (!player.getInventory().containsItem(5343)) { player.sendMessage(""You need a seed dibber to plant this.""); return; } int seedCount = 1; switch(produce.type) { case ALLOTMENT: seedCount = 3; break; case HOP: seedCount = produce == ProduceType.Jute ? 3 : 4; break; default: break; } if (!player.getInventory().containsItem(produce.seedId, seedCount)) { player.sendMessage(""You need "" + seedCount + "" seeds for this patch.""); return; } player.getSkills().addXp(Constants.FARMING, produce.plantingExperience); player.setNextAnimation(SEED_DIBBING_ANIMATION); player.getInventory().deleteItem(produce.seedId, seedCount); seed = produce; updateVars(player); return; } switch(item.getId()) { case 6032: case 6034: if (fullyGrown()) { player.sendMessage(""Composting it isn't going to make it get any bigger.""); return; } if (compostLevel >= (item.getId() == 6032 ? 1 : 2)) { player.sendMessage(""This patch has already been treated with ""+(item.getId() == 6032 ? """" : ""super"")+""compost.""); return; } player.setNextFaceTile(object.getTile()); player.getSkills().addXp(Constants.FARMING, 18); player.setNextAnimation(COMPOST_ANIMATION); item.setId(1925); player.getInventory().refresh(); compostLevel = item.getId() == 6032 ? 1 : 2; break; case 6036: if (dead) { player.sendMessage(""It says 'Cure' not 'Resurrect'. Although death may arise from disease, it is not in itself a disease and hence cannot be cured. So there.""); return; } if (!diseased) { player.sendMessage(""It is growing just fine.""); return; } player.setNextFaceTile(object.getTile()); player.getSkills().addXp(Constants.FARMING, 90); player.setNextAnimation(CURE_PLANT_ANIMATION); item.setId(229); player.getInventory().refresh(); diseased = false; updateVars(player); break; case 18682: if (seed == null || fullyGrown() || diseased || dead || watered || (location.type != PatchType.ALLOTMENT && location.type != PatchType.FLOWER && location.type != PatchType.HOP && location.type != PatchType.VINE_FLOWER)) { player.sendMessage(""That patch doesn't need watering.""); return; } player.setNextAnimation(WATERING_ANIMATION); watered = true; updateVars(player); break; case 952: promptClear(player); break; case 20023: case 20024: case 20025: case 20026: case 23161: case 23162: case 23163: case 23164: case 23165: case 23166: if (location != PatchLocation.Herblore_Habitat_flower) { player.sendMessage(""This potion is only effective when poured on the flower patch in Herblore Habitat.""); return; } if (item.getId() == 23166) player.getInventory().deleteItem(item); else item.setId(item.getId() == 20026 ? Potions.JUJU_VIAL : item.getId()+1); player.setNextAnimation(CURE_PLANT_ANIMATION); player.addEffect(Effect.JUJU_HUNTER, Ticks.fromMinutes(10)); player.sendMessage(""You pour the potion onto the blossom.""); player.getInventory().refresh(); break; case 5340: case 5339: case 5338: case 5337: case 5336: case 5335: case 5334: case 5333: if (seed == null || fullyGrown() || diseased || dead || watered || (location.type != PatchType.ALLOTMENT && location.type != PatchType.FLOWER && location.type != PatchType.HOP && location.type != PatchType.VINE_FLOWER)) { player.sendMessage(""That patch doesn't need watering.""); return; } player.setNextAnimation(WATERING_ANIMATION); watered = true; item.setId(item.getId() == 5333 ? 5331 : item.getId() - 1); player.getInventory().refresh(); updateVars(player); break; } } public void updateVars(Player player) { player.getVars().setVarBit(location.varBit, location.type.getValue(this)); } public void promptClear(Player player) { player.sendOptionDialogue(""Do you really want to clear the patch?"", ops -> { ops.add(""Yes, I'd like to clear it."", () -> { player.setNextAnimation(SPADE_ANIMATION); if (seed != null && seed.type == PatchType.TREE && lives == -1) player.getInventory().addItemDrop(seed.productId.getId(), 1); empty(); updateVars(player); }); ops.add(""No thanks.""); }); } public void setInitialLives() { if (seed == null) return; switch(seed.type) { case CACTUS: lives = 3; break; case FRUIT_TREE: case CALQUAT: lives = 6; break; case ALLOTMENT: case HERB: case HOP: case VINE_HERB: lives = 3 + compostLevel; break; case MUSHROOM: lives = seed.productId.getAmount(); break; case BUSH: case VINE_BUSH: lives = 4; break; case FLOWER: case VINE_FLOWER: case BELLADONNA: case EVIL_TURNIP: lives = 1; break; case COMPOST: lives = 15; break; default: break; } } public void tick(Player player) { if (location.type != PatchType.COMPOST) { if (weeds >= 3) { seed = null; return; } if (seed == null) { weeds++; return; } } else if (seed == null) return; if (dead) return; totalGrowthTicks++; if (fullyGrown()) { switch (seed.type) { case BUSH: case CACTUS: case VINE_BUSH: if (totalGrowthTicks % 2 == 0 && checkedHealth && lives < (seed.type == PatchType.CACTUS ? 3 : 4)) lives++; break; case CALQUAT: case FRUIT_TREE: if (totalGrowthTicks % 9 == 0 && checkedHealth && lives < 6) lives++; break; case TREE: if (seed == ProduceType.Willow) { if (checkedHealth && lives < 6) lives++; } else if (checkedHealth && lives < 0) lives++; break; default: break; } } if (totalGrowthTicks % seed.type.getGrowthTicksPerStage() == 0) { if (fullyGrown()) return; if (diseased) { if (Math.random() < 0.5) dead = true; return; } boolean fullGrownBefore = fullyGrown(); growthStage++; boolean hasFullyGrown = !fullGrownBefore && fullyGrown(); if (hasFullyGrown) setInitialLives(); if (!fullyGrown() && Utils.random(128) < (6 - compostLevel)) if (!hasFullyGrown && !isDiseaseProtected(player)) { diseased = true; return; } watered = false; } } public boolean isDiseaseProtected(Player player) { if (seed == null|| watered || diseaseProtected || fullyGrown()) return true; if ((seed == ProduceType.Poison_ivy) || seed == ProduceType.Evil_turnip || location.type == PatchType.COMPOST || location == PatchLocation.Trollheim_herbs || location == PatchLocation.Burthorpe_potato_patch) return true; if (location == PatchLocation.Canifis_mushrooms && SetReward.MORYTANIA_LEGS.hasRequirements(player, AchievementDef.Area.MORYTANIA, AchievementDef.Difficulty.ELITE, false)) return true; if (seed.type == PatchType.ALLOTMENT) { ProduceType flower = seed.getFlowerProtection(); if (flower == null) return false; switch(location) { case Ardougne_allotment_north: case Ardougne_allotment_south: if (player.isGrowing(PatchLocation.Ardougne_flower, flower) || player.isGrowing(PatchLocation.Ardougne_flower, ProduceType.White_lily)) return true; break; case Canifis_allotment_north: case Canifis_allotment_south: if (player.isGrowing(PatchLocation.Canifis_flower, flower) || player.isGrowing(PatchLocation.Canifis_flower, ProduceType.White_lily)) return true; break; case Catherby_allotment_north: case Catherby_allotment_south: if (player.isGrowing(PatchLocation.Catherby_flower, flower) || player.isGrowing(PatchLocation.Catherby_flower, ProduceType.White_lily)) return true; break; case Falador_allotment_north: case Falador_allotment_south: if (player.isGrowing(PatchLocation.Falador_flower, flower) || player.isGrowing(PatchLocation.Falador_flower, ProduceType.White_lily)) return true; break; default: break; } } return false; } public void empty() { seed = null; weeds = 0; diseased = false; dead = false; compostLevel = 0; lives = 0; checkedHealth = false; totalGrowthTicks = 0; watered = false; growthStage = 0; diseaseProtected = location == PatchLocation.Trollheim_herbs; } public boolean needsRemove() { return seed == null && weeds >= 3 && compostLevel == 0; } public boolean fullyGrown() { if (seed == null) return false; return growthStage == seed.stages; } public static ObjectClickHandler handlePatches = new ObjectClickHandler(PatchLocation.MAP.keySet().toArray(), e -> { PatchLocation loc = PatchLocation.forObject(e.getObjectId()); if (loc == null) return; FarmPatch patch = e.getPlayer().getPatch(loc); if (patch == null) patch = new FarmPatch(loc); patch.handleClick(e.getPlayer(), e.getObject(), e.getOption(), e.getOpNum()); e.getPlayer().putPatch(patch); }); public static ItemOnObjectHandler handleItemOnPatch = new ItemOnObjectHandler(PatchLocation.MAP.keySet().toArray(), null, e -> { PatchLocation loc = PatchLocation.forObject(e.getObjectId()); if (loc == null) return; FarmPatch patch = e.getPlayer().getPatch(loc); if (patch == null) patch = new FarmPatch(loc); patch.useItem(e.getPlayer(), e.getObject(), e.getItem()); e.getPlayer().putPatch(patch); }); @Override public String toString() { return ""{ loc: "" + location + "", seed: "" + seed + "", weeds: "" + weeds + "", growth: "" + growthStage + "", totalGrow: "" + totalGrowthTicks + "", disease: "" + diseased + "", water: "" + watered + "", dead: "" + dead + "", prot: "" + diseaseProtected + "", compost: "" + compostLevel + "", lives: "" + lives + "", checked: "" + checkedHealth + "" }""; } }" "package com.rs.game.content.skills.farming; public class FillCompostBin extends PlayerAction { private final FarmPatch patch; private final Item item; private int compostType; public FillCompostBin(FarmPatch patch, Item item) { this.patch = patch; this.item = item; for (int reg : FarmPatch.COMPOST_ORGANIC) if (reg == item.getId()) compostType = 1; for (int reg : FarmPatch.SUPER_COMPOST_ORGANIC) if (reg == item.getId()) compostType = 2; } @Override public boolean start(Player player) { if (compostType == -1) { player.sendMessage(""You can't compost that.""); return false; } if (patch.seed != null) { player.sendMessage(""There's already some "" + patch.seed.name().toLowerCase() + "" decomposing in there.""); return false; } return true; } @Override public boolean process(Player player) { if ((patch.lives <= -15) || !player.getInventory().containsItem(item.getId())) return false; return true; } @Override public int processWithDelay(Player player) { if ((patch.lives <= -15) || !player.getInventory().containsItem(item.getId())) return -1; switch(compostType) { case -1: player.sendMessage(""You can't compost that.""); return -1; case 1: patch.compostLevel = 1; break; case 2: if (patch.compostLevel == 1) patch.compostLevel = 1; else patch.compostLevel = 2; break; } player.setNextAnimation(FarmPatch.FILL_COMPOST_ANIMATION); patch.lives--; patch.updateVars(player); player.getInventory().deleteItem(item.getId(), 1); return 1; } @Override public void stop(Player player) { } }" "package com.rs.game.content.skills.farming; @PluginEventHandler public enum Gardener { ELSTAN(2323, PatchLocation.Falador_allotment_north, PatchLocation.Falador_allotment_south), LYRA(2326, PatchLocation.Canifis_allotment_north, PatchLocation.Canifis_allotment_south), DANTAERA(2324, PatchLocation.Catherby_allotment_north, PatchLocation.Catherby_allotment_south), KRAGEN(2325, PatchLocation.Ardougne_allotment_north, PatchLocation.Ardougne_allotment_south), VASQUEN(2333, PatchLocation.Lumbridge_hops), RHONEN(2334, PatchLocation.Seers_Village_hops), SELENA(2332, PatchLocation.Yanille_hops), FRANCIS(2327, PatchLocation.Entrana_hops), DREVEN(2335, PatchLocation.Champions_Guild_bush), TARIA(2336, PatchLocation.Rimmington_bush), TORRELL(2338, PatchLocation.Ardougne_bush), RHAZIEN(2337, PatchLocation.Etceteria_bush), FAYETH(2342, PatchLocation.Lumbridge_tree), TREZNOR(2341, PatchLocation.Varrock_tree), HESKEL(2340, PatchLocation.Falador_tree), ALAIN(2339, PatchLocation.Taverly_tree), PRISSY_SCILLA(1037, PatchLocation.Gnome_Stronghold_tree), BOLONGO(2343, PatchLocation.Gnome_Stronghold_fruit_tree), GILETH(2344, PatchLocation.Tree_Gnome_Village_fruit_tree), GARTH(2330, PatchLocation.Brimhaven_fruit_tree), ELLENA(2331, PatchLocation.Catherby_fruit_tree), AMAETHWR(2860, PatchLocation.Lletya_fruit_tree), YULF_SQUECKS(4561, PatchLocation.Etceteria_spirit_tree), FRIZZY_SKERNIP(4560, PatchLocation.Port_Sarim_spirit_tree), PRAISTAN_EBOLA(4562, PatchLocation.Brimhaven_spirit_tree), IMIAGO(871, PatchLocation.Karamja_calquat), ZOMBIE_FARMER(13101, PatchLocation.Herblore_Habitat_fruit_tree, PatchLocation.Herblore_Habitat_bush, PatchLocation.Herblore_Habitat_west_herbs); static final Map MAP = new HashMap<>(); static { for (Gardener g : Gardener.values()) MAP.put(g.npcId, g); } private static Gardener forNPC(int npcId) { return MAP.get(npcId); } private final int npcId; private final PatchLocation[] locations; private Gardener(int npcId, PatchLocation... locations) { this.npcId = npcId; this.locations = locations; } public static final NPCClickHandler handleGardeners = new NPCClickHandler(new Object[] { 871, 1037, 2323, 2324, 2325, 2326, 2327, 2330, 2331, 2332, 2333, 2334, 2335, 2336, 2337, 2338, 2339, 2340, 2341, 2342, 2343, 2344, 2860, 4560, 4561, 4562, 13101 }, e -> { Gardener gardener = Gardener.forNPC(e.getNPCId()); if (e.getOption().contains(""Pay"")) { int patchIdx = e.getOpNum()-3; FarmPatch patch = e.getPlayer().getPatch(gardener.locations[patchIdx]); protectPatch(e.getPlayer(), e.getNPC(), patch); return; } if (e.getOption().contains(""Talk"")) e.getPlayer().startConversation(new Conversation(e.getPlayer()).addOptions(""What would you like to say?"", new Options() { @Override public void create() { option(""Would you look after my crops for me?"", new Dialogue() .addNPC(e.getNPCId(), HeadE.CALM, ""Of course, what would you like me to protect?"") .addOptions(""What would you like to protect?"", new Options() { @Override public void create() { for (PatchLocation loc : gardener.locations) option(loc.name().replace(""_"", "" ""), new Dialogue().addNext(() -> protectPatch(e.getPlayer(), e.getNPC(), e.getPlayer().getPatch(loc)))); option(""Nevermind.""); } })); option(""Can you sell me something?"", new Dialogue().addOptions(new Options() { @Override public void create() { option(""Plant cure (25 gold)"", buyItem(e.getPlayer(), e.getNPCId(), 6036, 25)); option(""Compost (35 gold)"", buyItem(e.getPlayer(), e.getNPCId(), 6032, 35)); option(""Rake (15 gold)"", buyItem(e.getPlayer(), e.getNPCId(), 5341, 15)); option(""Watering can (25 gold)"", buyItem(e.getPlayer(), e.getNPCId(), 5331, 25)); option(""Gardening trowel (15 gold)"", buyItem(e.getPlayer(), e.getNPCId(), 5325, 15)); option(""Seed dibber (15 gold)"", buyItem(e.getPlayer(), e.getNPCId(), 5343, 15)); } })); option(""That's all, thanks.""); } })); }); private static void protectPatch(Player player, NPC npc, FarmPatch patch) { if (patch == null || patch.seed == null) { player.startConversation(new Dialogue().addNPC(npc.getId(), HeadE.CHEERFUL, ""You don't have anything planted in that patch. Plant something and I might agree to look after it for you."")); return; } if (patch.isDiseaseProtected(player)) { player.sendMessage(""That patch is already being adequately protected.""); return; } if (patch.dead) { player.startConversation(new Dialogue().addNPC(npc.getId(), HeadE.CALM_TALK, ""It looks a little too late for that, huh?"")); return; } Item cost = patch.seed.protection; if (cost == null) { player.startConversation(new Dialogue().addNPC(npc.getId(), HeadE.CALM_TALK, ""I'm sorry, but I can't help you with that crop."")); return; } if (!player.getInventory().containsItemNoted(cost)) { player.startConversation(new Dialogue().addNPC(npc.getId(), HeadE.CHEERFUL, ""I'd protect that crop for "" + cost.getAmount() + "" "" + cost.getName() + ""."")); return; } player.getInventory().deleteItemNoted(cost); patch.diseaseProtected = true; player.sendMessage(npc.getName(player) + "" takes "" + cost.getAmount() + "" "" + cost.getName() + "" and agrees to protect the patch for you."" ); } private static Dialogue buyItem(Player player, int npcId, int itemId, int cost) { return new Dialogue() .addPlayer(HeadE.CHEERFUL, ""I'd like to buy a "" + ItemDefinitions.getDefs(itemId).name.toLowerCase() + "" please."") .addNPC(npcId, HeadE.CHEERFUL, ""Alright, I can sell you one of those for "" + cost + "" gold."") .addOption(""Buy a "" + ItemDefinitions.getDefs(itemId).name.toLowerCase() + "" for "" + cost + "" gold?"", ""Yes, please."", ""No thanks, that's too much."") .addNext(() -> { if (!player.getInventory().hasFreeSlots()) { player.sendMessage(""You don't have enough inventory space.""); return; } if (player.getInventory().hasCoins(cost)) { player.getInventory().removeCoins(cost); player.getInventory().addItem(itemId); } else player.sendMessage(""You don't have enough coins for that.""); }); } }" "package com.rs.game.content.skills.farming; public class HarvestPatch extends PlayerAction { private final FarmPatch patch; private int tool = -1; private Animation animation; public HarvestPatch(FarmPatch patch) { this.patch = patch; switch(patch.seed.type) { case TREE: animation = FarmPatch.PRUNING_ANIMATION; break; case ALLOTMENT: case HOP: case EVIL_TURNIP: tool = 952; animation = FarmPatch.SPADE_ANIMATION; break; case FLOWER: case VINE_FLOWER: case BELLADONNA: tool = 952; animation = FarmPatch.FLOWER_PICKING_ANIMATION; break; case HERB: case MUSHROOM: case VINE_HERB: tool = 952; animation = FarmPatch.HERB_PICKING_ANIMATION; break; case CALQUAT: case FRUIT_TREE: animation = FarmPatch.FRUIT_PICKING_ANIMATION; break; case BUSH: case VINE_BUSH: case CACTUS: animation = FarmPatch.BUSH_PICKING_ANIMATION; break; case COMPOST: animation = FarmPatch.FILL_COMPOST_ANIMATION; break; default: tool = -1; break; } } @Override public boolean start(Player player) { if (patch.lives <= 0) return false; if (tool != -1 && !player.getInventory().containsItem(tool)) { player.sendMessage(""You need "" + Utils.addArticle(ItemDefinitions.getDefs(tool).name.toLowerCase()) + "" to harvest this patch.""); return false; } return true; } @Override public boolean process(Player player) { if (patch.lives > 0) return true; return false; } @Override public int processWithDelay(Player player) { player.setNextAnimation(animation); if (patch.seed.decreaseLife(player)) patch.lives--; if (patch.seed == ProduceType.Willow) player.getInventory().addItemDrop(5933, 1); else { int amount = patch.seed == ProduceType.Limpwurt ? 3 : 1; if (player.getAuraManager().isActivated(Aura.GREENFINGERS)) amount += Math.random() < 0.03 ? 1 : 0; if (player.getAuraManager().isActivated(Aura.GREATER_GREENFINGERS)) amount += Math.random() < 0.05 ? 1 : 0; if (player.getAuraManager().isActivated(Aura.MASTER_GREENFINGERS)) amount += Math.random() < 0.07 ? 1 : 0; if (player.getAuraManager().isActivated(Aura.SUPREME_GREENFINGERS)) amount += Math.random() < 0.1 ? 1 : 0; if (player.hasEffect(Effect.JUJU_FARMING) && (patch.seed.type == PatchType.HERB || patch.seed.type == PatchType.VINE_HERB)) if (Utils.random(3) == 0) amount++; player.incrementCount(patch.seed.productId.getName() + "" harvested"", amount); player.getInventory().addItemDrop(patch.seed.productId.getId(), amount); } switch (patch.seed.type) { case CALQUAT: case FRUIT_TREE: case BUSH: case VINE_BUSH: case CACTUS: case TREE: player.getSkills().addXp(Constants.FARMING, patch.seed.plantingExperience * 0.375); patch.updateVars(player); if (patch.lives <= 0) return -1; break; default: player.getSkills().addXp(Constants.FARMING, patch.seed.experience); if (patch.lives <= 0) { patch.empty(); patch.updateVars(player); return -1; } break; } return 1; } @Override public void stop(Player player) { } }" "package com.rs.game.content.skills.farming; public enum PatchLocation { Taverly_tree(8388, PatchType.TREE), Falador_tree(8389, PatchType.TREE), Varrock_tree(8390, PatchType.TREE), Lumbridge_tree(8391, PatchType.TREE), Gnome_Stronghold_tree(19147, PatchType.TREE), Gnome_Stronghold_fruit_tree(7962, PatchType.FRUIT_TREE), Tree_Gnome_Village_fruit_tree(7963, PatchType.FRUIT_TREE), Brimhaven_fruit_tree(7964, PatchType.FRUIT_TREE), Catherby_fruit_tree(7965, PatchType.FRUIT_TREE), Lletya_fruit_tree(28919, PatchType.FRUIT_TREE), Herblore_Habitat_fruit_tree(56667, PatchType.FRUIT_TREE), Falador_allotment_north(8550, PatchType.ALLOTMENT), Falador_allotment_south(8551, PatchType.ALLOTMENT), Catherby_allotment_north(8552, PatchType.ALLOTMENT), Catherby_allotment_south(8553, PatchType.ALLOTMENT), Ardougne_allotment_north(8554, PatchType.ALLOTMENT), Ardougne_allotment_south(8555, PatchType.ALLOTMENT), Canifis_allotment_north(8556, PatchType.ALLOTMENT), Canifis_allotment_south(8557, PatchType.ALLOTMENT), Harmony_allotment(21950, PatchType.ALLOTMENT), Burthorpe_potato_patch(66572, PatchType.ALLOTMENT), Yanille_hops(8173, PatchType.HOP), Entrana_hops(8174, PatchType.HOP), Lumbridge_hops(8175, PatchType.HOP), Seers_Village_hops(8176, PatchType.HOP), Falador_flower(7847, PatchType.FLOWER), Catherby_flower(7848, PatchType.FLOWER), Ardougne_flower(7849, PatchType.FLOWER), Canifis_flower(7850, PatchType.FLOWER), Wilderness_flower(37988, PatchType.FLOWER), Champions_Guild_bush(7577, PatchType.BUSH), Rimmington_bush(7578, PatchType.BUSH), Etceteria_bush(7579, PatchType.BUSH), Ardougne_bush(7580, PatchType.BUSH), Falador_herbs(8150, PatchType.HERB), Catherby_herbs(8151, PatchType.HERB), Ardougne_herbs(8152, PatchType.HERB), Canifis_herbs(8153, PatchType.HERB), Trollheim_herbs(18816, PatchType.HERB), Canifis_mushrooms(8337, PatchType.MUSHROOM), Draynor_belladonna(7572, PatchType.BELLADONNA), Herblore_Habitat_west_herbs(56682, PatchType.VINE_HERB), Herblore_Habitat_east_herbs(56683, PatchType.VINE_HERB), Herblore_Habitat_bush(56562, PatchType.VINE_BUSH), Herblore_Habitat_flower(56685, PatchType.VINE_FLOWER), Draynor_manor_evil_turnip(23760, PatchType.EVIL_TURNIP), Al_Kharid_cactus(7771, PatchType.CACTUS), Karamja_calquat(7807, PatchType.CALQUAT), Etceteria_spirit_tree(8382, PatchType.SPIRIT), Brimhaven_spirit_tree(8383, PatchType.SPIRIT), Port_Sarim_spirit_tree(8338, PatchType.SPIRIT), Falador_compost(7836, PatchType.COMPOST), Canifis_compost(7838, PatchType.COMPOST), Ardougne_compost(7839, PatchType.COMPOST), Catherby_compost(7837, PatchType.COMPOST), Taverly_compost(66577, PatchType.COMPOST), Herblore_habitat_compost(56684, PatchType.COMPOST); //TODO //Jade vine public static Map MAP = new HashMap<>(); public static PatchLocation forObject(int objectId) { return MAP.get(objectId); } static { for (PatchLocation information : PatchLocation.values()) MAP.put(information.objectId, information); } public final int objectId; public final int varBit; public final PatchType type; private PatchLocation(int objectId, PatchType type) { this.objectId = objectId; varBit = ObjectDefinitions.getDefs(objectId).varpBit; this.type = type; } }" "package com.rs.game.content.skills.farming; public enum PatchType { ALLOTMENT(2) { @Override int getVarBitValue(FarmPatch patch) { if (patch.location == PatchLocation.Burthorpe_potato_patch) return switch (patch.growthStage) { case 0 -> 6; case 1, 2, 3 -> 5; default -> 7; }; int value = patch.seed.varBitPlanted + patch.growthStage; if (patch.dead) value |= 192; else if (patch.diseased) value |= 128; else if (patch.watered) value |= 64; return value; } }, FLOWER(1) { @Override int getVarBitValue(FarmPatch patch) { int value = patch.seed.varBitPlanted + patch.growthStage; if (patch.dead) value |= 192; else if (patch.diseased) value |= 128; else if (patch.watered) value |= 64; return value; } }, HERB(4) { @Override int getVarBitValue(FarmPatch patch) { int value = patch.growthStage + (patch.seed == ProduceType.Wergali ? 60 : 4); if (patch.dead) value = patch.growthStage + 169; else if (patch.diseased) value = patch.growthStage + 127; return value; } }, HOP(2) { @Override int getVarBitValue(FarmPatch patch) { int value = patch.seed.varBitPlanted + patch.growthStage; if (patch.dead) value |= 192; else if (patch.diseased) value |= 128; else if (patch.watered) value |= 64; return value; } }, TREE(8) { @Override int getVarBitValue(FarmPatch patch) { int baseValue = patch.growthStage + patch.seed.varBitPlanted; if (patch.checkedHealth) { if (patch.lives == -1) return baseValue + 2; return baseValue + 1; } if (patch.dead) return baseValue + 128; if (patch.diseased) return baseValue + 64; return baseValue; } }, FRUIT_TREE(32) { @Override int getVarBitValue(FarmPatch patch) { int baseValue = patch.growthStage + patch.seed.varBitPlanted; if (!patch.checkedHealth && patch.fullyGrown()) return patch.seed.varBitPlanted + 26; if (patch.lives == -1) return patch.seed.varBitPlanted + 25; if (patch.dead) baseValue += 18; else if (patch.diseased) baseValue += 12; return baseValue += patch.lives; } }, BUSH(4) { @Override int getVarBitValue(FarmPatch patch) { int baseValue = patch.growthStage + patch.seed.varBitPlanted; switch(patch.seed) { case Redberry: if (patch.checkedHealth) return patch.lives + baseValue; if (patch.dead) return 129 + baseValue; if (patch.diseased) return 65 + baseValue; if (!patch.checkedHealth && patch.fullyGrown()) return (patch.seed.ordinal() - ProduceType.Redberry.ordinal()) + 250; return baseValue; case Cadavaberry: if (patch.checkedHealth) return patch.lives + baseValue; if (patch.dead) return 129 + baseValue; if (patch.diseased) return 65 + baseValue; if (!patch.checkedHealth && patch.fullyGrown()) return (patch.seed.ordinal() - ProduceType.Redberry.ordinal()) + 250; return baseValue; case Dwellberry: if (patch.checkedHealth) return patch.lives + baseValue; if (patch.dead) return 128 + baseValue; if (patch.diseased) return 64 + baseValue; if (!patch.checkedHealth && patch.fullyGrown()) return (patch.seed.ordinal() - ProduceType.Redberry.ordinal()) + 250; return baseValue; case Jangerberry: if (patch.checkedHealth) return patch.lives + baseValue; if (patch.dead) return 128 + baseValue; if (patch.diseased) return 64 + baseValue; if (!patch.checkedHealth && patch.fullyGrown()) return (patch.seed.ordinal() - ProduceType.Redberry.ordinal()) + 250; return baseValue; case Whiteberry: if (patch.checkedHealth) return patch.lives + baseValue; if (patch.dead) return 129 + baseValue; if (patch.diseased) return 64 + baseValue; if (!patch.checkedHealth && patch.fullyGrown()) return (patch.seed.ordinal() - ProduceType.Redberry.ordinal()) + 250; return baseValue; case Poison_ivy: if (patch.checkedHealth) return patch.lives+baseValue; if (patch.dead) return 20 + baseValue; if (patch.diseased) return 12 + baseValue; if (!patch.checkedHealth && patch.fullyGrown()) return (patch.seed.ordinal() - ProduceType.Redberry.ordinal()) + 250; return baseValue; default: return baseValue; } } }, CACTUS(16) { @Override int getVarBitValue(FarmPatch patch) { int baseValue = patch.growthStage + patch.seed.varBitPlanted; if (patch.checkedHealth) baseValue += patch.lives; else if (patch.dead) return patch.growthStage + 24; else if (patch.diseased) return patch.growthStage + 18; else if (!patch.checkedHealth && patch.fullyGrown()) return 31; return baseValue; } }, EVIL_TURNIP(1) { @Override int getVarBitValue(FarmPatch patch) { return patch.seed.varBitPlanted + patch.growthStage; } }, MUSHROOM(8) { @Override int getVarBitValue(FarmPatch patch) { if (patch.fullyGrown()) return patch.seed.varBitPlanted + patch.growthStage + (patch.seed.productId.getAmount() - patch.lives); switch(patch.seed) { case Bittercap: if (patch.dead) return patch.seed.varBitPlanted + patch.growthStage + 16; if (patch.diseased) return patch.seed.varBitPlanted + patch.growthStage + 11; return patch.seed.varBitPlanted + patch.growthStage; case Morchella: if (patch.dead) return patch.seed.varBitPlanted + patch.growthStage + 19; if (patch.diseased) return patch.seed.varBitPlanted + patch.growthStage + 14; return patch.seed.varBitPlanted + patch.growthStage; default: return patch.seed.varBitPlanted + patch.growthStage; } } }, BELLADONNA(8) { @Override int getVarBitValue(FarmPatch patch) { int baseValue = patch.growthStage + patch.seed.varBitPlanted; if (patch.dead) return baseValue + 7; if (patch.diseased) return baseValue + 4; return baseValue; } }, VINE_FLOWER(1) { @Override int getVarBitValue(FarmPatch patch) { switch(patch.seed) { case Red_blossom: if (patch.dead) return 39 + patch.growthStage; if (patch.diseased) return 30 + patch.growthStage; if (patch.watered) return 19 + patch.growthStage; return patch.growthStage + patch.seed.varBitPlanted; case Blue_blossom: if (patch.dead) return 43 + patch.growthStage; if (patch.diseased) return 33 + patch.growthStage; if (patch.watered) return 23 + patch.growthStage; return patch.growthStage + patch.seed.varBitPlanted; case Green_blossom: if (patch.dead) return 47 + patch.growthStage; if (patch.diseased) return 36 + patch.growthStage; if (patch.watered) return 27 + patch.growthStage; return patch.growthStage + patch.seed.varBitPlanted; default: return patch.growthStage + patch.seed.varBitPlanted; } } }, VINE_HERB(4) { @Override int getVarBitValue(FarmPatch patch) { if (patch.dead) return patch.growthStage + 43; if (patch.diseased) return patch.growthStage + 31; return patch.growthStage + patch.seed.varBitPlanted; } }, VINE_BUSH(4) { @Override int getVarBitValue(FarmPatch patch) { int baseValue = patch.growthStage + patch.seed.varBitPlanted; switch(patch.seed) { case Lergberry: if (patch.fullyGrown()) return patch.checkedHealth ? (patch.seed.varBitPlanted + patch.growthStage + patch.lives) : 50; if (patch.dead) return baseValue + 33; if (patch.diseased) return baseValue + 21; return baseValue; case Kalferberry: if (patch.fullyGrown()) return patch.checkedHealth ? (patch.seed.varBitPlanted + patch.growthStage + patch.lives) : 51; if (patch.dead) return baseValue + 28; if (patch.diseased) return baseValue + 16; return baseValue; default: return baseValue; } } }, CALQUAT(16) { @Override int getVarBitValue(FarmPatch patch) { int baseValue = patch.growthStage + patch.seed.varBitPlanted; if (!patch.checkedHealth && patch.fullyGrown()) return 34; if (patch.fullyGrown()) return baseValue + patch.lives; if (patch.dead) return baseValue + 21; if (patch.diseased) return baseValue + 14; return baseValue; } }, SPIRIT(64) { @Override int getVarBitValue(FarmPatch patch) { int baseValue = patch.growthStage + patch.seed.varBitPlanted; if (patch.dead) return baseValue + 24; if (patch.diseased) return baseValue + 12; return baseValue; } }, COMPOST(9) { @Override int getVarBitValue(FarmPatch patch) { if (patch.seed == null) { if (patch.lives == 0) return 0; if (patch.lives <= -15) return 15; return 5; } switch(patch.seed) { case Compost: case Supercompost: if (patch.lives == 0 || !patch.checkedHealth) return 31; else if (patch.lives >= 7) return patch.seed == ProduceType.Compost ? 30 : 62; else return patch.seed == ProduceType.Compost ? 29 : 61; default: return 0; } } }; private final int growthTicksPerStage; abstract int getVarBitValue(FarmPatch patch); private PatchType(int growthTicksPerStage) { this.growthTicksPerStage = growthTicksPerStage; } public int getGrowthTicksPerStage() { return growthTicksPerStage; } public int getValue(FarmPatch patch) { if (patch.location.type == PatchType.COMPOST) return getVarBitValue(patch); if (patch.weeds > 0) return 3 - patch.weeds; if (patch.seed == null) return 3; return getVarBitValue(patch); } }" "package com.rs.game.content.skills.farming; public enum ProduceContainer { COOKING_APPLES(5376, 5, 1955, 5378, 5386), ORANGES(5376, 5, 2108, 5388, 5396), STRAWBERRIES(5376, 5, 5504, 5398, 5406), BANANAS(5376, 5, 1963, 5408, 5416), POTATO(5418, 10, 1942, 5420, 5438), ONION(5418, 10, 1957, 5440, 5458), CABBAGE(5418, 10, 1965, 5460, 5478), TOMATOES(5376, 5, 1982, 5960, 5968), ; private final static HashMap BY_FILL_ID = new HashMap<>(); static { for (ProduceContainer container : values()) BY_FILL_ID.put(container.fillId, container); } private final static int[] SACK_FILL_IDS_BACKWARDS = new int[] { 1965, 1957, 1942 }; private final static int[] BASKET_FILL_IDS_BACKWARDS = new int[] { 1982, 5504, 2108, 1963, 1955 }; public static int[] getReverseFillIdsForContainerId(int containerId) { if (containerId == 5418) return SACK_FILL_IDS_BACKWARDS; return BASKET_FILL_IDS_BACKWARDS; } public static ProduceContainer forFillId(int fillId) { return BY_FILL_ID.get(fillId); } public static ProduceContainer forId(int containerId) { for (ProduceContainer container : values()) { if (containerId >= container.baseId && containerId <= container.fullId) return container; } return null; } public static boolean isEmptyContainer(int itemId) { return itemId == 5376 || itemId == 5418; } private final int containerId; private final int containerSize; private final int fillId; private final int baseId; private final int fullId; ProduceContainer(int containerId, int containerSize, int fillId, int baseId, int fullId) { this.containerId = containerId; this.containerSize = containerSize; this.fillId = fillId; this.baseId = baseId; this.fullId = fullId; } public int getCountForItemId(int itemId) { if (itemId < baseId || itemId > fullId) return 0; return ((itemId - baseId) / 2) + 1; } public int getItemIdForCount(int count) { if (count >= 10) return fullId; if (count < 0) return baseId; return baseId + (count * 2) - 2; } public int getContainerId() { return containerId; } public int getContainerSize() { return containerSize; } public int getFillId() { return fillId; } public int getBaseId() { return baseId; } public int getFullId() { return fullId; } }" "package com.rs.game.content.skills.farming; public enum ProduceSack { POTATO(1942, 5420, 5438), ONION(1957, 5440, 5458), CABBAGE(1965, 5460, 5478) ; public static final int EMPTY_SACK = 5418; private final static HashMap BY_FILL_ID = new HashMap<>(); private final static int[] FILL_IDS_BACKWARDS = new int[ProduceSack.values().length]; static { for (ProduceSack sack : values()) BY_FILL_ID.put(sack.fillId, sack); for (int i=values().length-1; i>0; i--) FILL_IDS_BACKWARDS[i] = values()[i].fillId; } public static int[] getReverseFillIds() { return FILL_IDS_BACKWARDS; } public static ProduceSack forFillId(int fillId) { return BY_FILL_ID.get(fillId); } public static ProduceSack forSackId(int sackId) { for (ProduceSack sack : values()) if (sackId >= sack.baseId && sackId <= sack.fullId) return sack; return null; } private final int fillId; private final int baseId; private final int fullId; ProduceSack(int fillId, int baseId, int fullId) { this.fillId = fillId; this.baseId = baseId; this.fullId = fullId; } public int getCountForItemId(int itemId) { if (itemId < baseId || itemId > fullId) return 0; return ((itemId - baseId) / 2) + 1; } public int getItemIdForCount(int count) { if (count >= 10) return fullId; if (count < 0) return baseId; return baseId + (count * 2) - 2; } public int getFillId() { return fillId; } public int getBaseId() { return baseId; } public int getFullId() { return fullId; } }" "package com.rs.game.content.skills.farming; public enum ProduceType { Potato(5318, 1, new Item(1942), 6, 8, 9, 4, PatchType.ALLOTMENT, 100, 192, new Item(6032, 2)), Onion(5319, 5, new Item(1957), 13, 9.5, 10.5, 4, PatchType.ALLOTMENT, 95, 192, new Item(5438, 1)), Cabbage(5324, 7, new Item(1965), 20, 10, 11.5, 4, PatchType.ALLOTMENT, 90, 192, new Item(5458, 1)), Tomato(5322, 12, new Item(1982), 27, 12.5, 14, 4, PatchType.ALLOTMENT, 85, 192, new Item(5478, 2)), Sweetcorn(5320, 20, new Item(5986), 34, 17, 19, 6, PatchType.ALLOTMENT, 80, 192, new Item(5931, 10)), Strawberry(5323, 31, new Item(5504), 43, 26, 29, 6, PatchType.ALLOTMENT, 75, 192, new Item(5386, 1)), Watermelon(5321, 47, new Item(5982), 52, 48.5, 54.5, 8, PatchType.ALLOTMENT, 70, 192, new Item(5970, 10)), Guam(5291, 9, new Item(199), 4, 11, 12.5, 4, PatchType.HERB, 25, 80), Marrentill(5292, 14, new Item(201), 4, 13.5, 15, 4, PatchType.HERB, 28, 80), Tarromin(5293, 19, new Item(203), 4, 16, 18, 4, PatchType.HERB, 31, 80), Harralander(5294, 26, new Item(205), 4, 21.5, 24, 4, PatchType.HERB, 36, 80), Rannar(5295, 32, new Item(207), 4, 27, 30.5, 4, PatchType.HERB, 39, 80), Spirit_weed(12176, 36, new Item(12174), 4, 32, 36, 4, PatchType.HERB, 40, 80), Toadflax(5296, 38, new Item(3049), 4, 34, 38.5, 4, PatchType.HERB, 43, 80), Irit(5297, 44, new Item(209), 4, 43, 48.5, 4, PatchType.HERB, 46, 80), Avantoe(5298, 50, new Item(211), 4, 54.4, 61.5, 4, PatchType.HERB, 50, 80), Kwuarm(5299, 56, new Item(213), 4, 69, 78, 4, PatchType.HERB, 54, 80), Snapdragon(5300, 62, new Item(3051), 4, 87.5, 98.5, 4, PatchType.HERB, 57, 80), Cadantine(5301, 67, new Item(215), 4, 106.5, 120, 4, PatchType.HERB, 60, 80), Lantadyme(5302, 73, new Item(2485), 4, 134.5, 151.5, 4, PatchType.HERB, 64, 80), Dwarf_weed(5303, 79, new Item(217), 4, 170.5, 192, 4, PatchType.HERB, 67, 80), Torstol(5304, 85, new Item(219), 4, 199.5, 224.5, 4, PatchType.HERB, 71, 80), Fellstalk(21621, 91, new Item(21626), 4, 225, 315.6, 4, PatchType.HERB, 15, 90), Wergali(14870, 46, new Item(14836), 4, 52.8, 52.8, 4, PatchType.HERB, 48, 80), Gout(6311, 65, new Item(3261), 110, 4, 45, 4, PatchType.HERB, 57, 80), Marigold(5096, 2, new Item(6010), 8, 8.5, 47, 4, PatchType.FLOWER), Rosemary(5097, 11, new Item(6014), 13, 12, 66.5, 4, PatchType.FLOWER), Nasturtium(5098, 24, new Item(6012), 18, 19.5, 111, 4, PatchType.FLOWER), Woad(5099, 25, new Item(1793), 23, 20.5, 115.5, 4, PatchType.FLOWER), Limpwurt(5100, 26, new Item(225), 28, 21.5, 120, 4, PatchType.FLOWER), Scarecrow(6059, 23, new Item(6059), 36, 0, 0, 0, PatchType.FLOWER), White_lily(14589, 52, new Item(14583), 37, 70, 250, 4, PatchType.FLOWER), Barley(5305, 3, new Item(6006), 49, 8.5, 9.5, 4, PatchType.HOP, 95, 185, new Item(6032, 3)), Hammerstone(5307, 4, new Item(5994), 4, 9, 10, 4, PatchType.HOP, 95, 185, new Item(6010, 1)), Asgarnian(5308, 8, new Item(5996), 11, 10.9, 12, 5, PatchType.HOP, 95, 185, new Item(5458, 1)), Jute(5306, 13, new Item(5931), 56, 13, 14.5, 5, PatchType.HOP, 95, 185, new Item(6008, 6)), Yanillian(5309, 16, new Item(5998), 19, 14.5, 16, 6, PatchType.HOP, 95, 185, new Item(5968, 1)), Krandorian(5310, 21, new Item(6000), 28, 17.5, 19.5, 7, PatchType.HOP, 95, 185, new Item(5478, 3)), Wildblood(5311, 28, new Item(6002), 38, 23, 26, 8, PatchType.HOP, 95, 185, new Item(6012, 1)), Oak(5370, 15, new Item(6043), 8, 14, 467.3, 4, PatchType.TREE, new Item(5968, 1)), Willow(5371, 30, new Item(6045), 15, 25, 1456.5, 6, PatchType.TREE, new Item(5386, 1)), Maple(5372, 45, new Item(6047), 24, 45, 3403.4, 8, PatchType.TREE, new Item(5396, 1)), Yew(5373, 60, new Item(6049), 35, 81, 7069.9, 10, PatchType.TREE, new Item(6016, 10)), Magic(5374, 75, new Item(6051), 48, 145.5, 13768.3, 12, PatchType.TREE, new Item(5974, 25)), Apple(5496, 27, new Item(1955), 8, 22, 1199.5, 6, PatchType.FRUIT_TREE, new Item(5986, 9)), Banana(5497, 33, new Item(1963), 35, 28, 1841.5, 6, PatchType.FRUIT_TREE, new Item(5386, 4)), Orange(5498, 39, new Item(2108), 72, 35.5, 2470.2, 6, PatchType.FRUIT_TREE, new Item(5406, 3)), Curry(5499, 42, new Item(5970), 99, 40, 2906.9, 6, PatchType.FRUIT_TREE, new Item(5416, 5)), Pineapple(5500, 51, new Item(2114), 136, 57, 4605.7, 6, PatchType.FRUIT_TREE, new Item(5982, 10)), Papaya(5501, 57, new Item(5972), 163, 72, 6146.4, 6, PatchType.FRUIT_TREE, new Item(2114, 10)), Palm(5502, 68, new Item(5974), 200, 110.5, 10150.1, 6, PatchType.FRUIT_TREE, new Item(5972, 15)), Redberry(5101, 10, new Item(1951), 5, 11.5, 64, 5, PatchType.BUSH, new Item(5478, 4)), Cadavaberry(5102, 22, new Item(753), 15, 18, 102.5, 6, PatchType.BUSH, new Item(5968, 3)), Dwellberry(5103, 36, new Item(2126), 26, 31.5, 177.5, 7, PatchType.BUSH, new Item(5406, 3)), Jangerberry(5104, 48, new Item(247), 38, 50.5, 284.5, 8, PatchType.BUSH, new Item(5982, 6)), Whiteberry(5105, 59, new Item(239), 51, 78, 437.5, 8, PatchType.BUSH, new Item(6004, 8)), Poison_ivy(5106, 70, new Item(6018), 197, 120, 675, 8, PatchType.BUSH), Bittercap(5282, 53, new Item(6004, 6), 4, 61.5, 57.7, 6, PatchType.MUSHROOM), Morchella(21620, 74, new Item(21622, 9), 26, 22, 77.7, 6, PatchType.MUSHROOM), Evil_turnip(12148, 42, new Item(12134, 1), 4, 41, 46, 1, PatchType.EVIL_TURNIP), Belladonna(5281, 63, new Item(2398), 4, 91, 512, 4, PatchType.BELLADONNA), Calquat(5503, 72, new Item(5980, 6), 4, 110.5, 12096, 8, PatchType.CALQUAT, new Item(6018, 8)), Cactus(5280, 55, new Item(6016), 8, 66.5, 374, 7, PatchType.CACTUS, new Item(753, 6)), Erzille(19897, 58, new Item(19984), 4, 87, 87, 4, PatchType.VINE_HERB, 67, 80), Argway(19907, 65, new Item(19985), 4, 110, 125, 4, PatchType.VINE_HERB, 67, 80), Ugune(19902, 70, new Item(19986), 4, 135, 152, 4, PatchType.VINE_HERB, 67, 80), Shengo(19912, 76, new Item(19987), 4, 140.5, 160, 4, PatchType.VINE_HERB, 67, 80), Samaden(19917, 80, new Item(19988), 4, 170, 190, 4, PatchType.VINE_HERB, 67, 80), Red_blossom(19922, 54, new Item(19962), 4, 52, 255, 4, PatchType.VINE_FLOWER), Blue_blossom(19927, 54, new Item(19963), 9, 52, 255, 4, PatchType.VINE_FLOWER), Green_blossom(19932, 54, new Item(19964), 14, 52, 255, 4, PatchType.VINE_FLOWER), Lergberry(19937, 61, new Item(19969, 4), 4, 145.5, 236.3, 6, PatchType.VINE_BUSH, new Item(19962, 3)), Kalferberry(19942, 77, new Item(19970, 4), 15, 220, 375, 6, PatchType.VINE_BUSH, new Item(19969, 3)), Compost(-1, 1, new Item(6032), 0, 0.0, 8.5, 1, PatchType.COMPOST), Supercompost(-2, 1, new Item(6034), 0, 0.0, 8.5, 2, PatchType.COMPOST), Spirit_tree(5375, 83, null, 8, 199.5, 19301.8, 12, PatchType.SPIRIT); private static final Map SEED_MAP = new HashMap<>(); private static final Map PRODUCE_MAP = new HashMap<>(); static { for (ProduceType product : ProduceType.values()) SEED_MAP.put(product.seedId, product); for (ProduceType product : ProduceType.values()) { if (product.productId == null) continue; PRODUCE_MAP.put(product.productId.getId(), product); } } public static ProduceType forSeed(int itemId) { return SEED_MAP.get(itemId); } public static ProduceType forProduce(int itemId) { return PRODUCE_MAP.get(itemId); } public final int seedId; public final int level; public final Item productId; public final int varBitPlanted; public final PatchType type; public final int stages; public final double experience; public final double plantingExperience; public int rate1 = -1, rate99 = -1; public final Item protection; ProduceType(int seedId, int level, Item productId, int varBitPlanted, double plantingExperience, double experience, int stages, PatchType type, int rate1, int rate99, Item protection) { this.seedId = seedId; this.level = level; this.productId = productId; this.varBitPlanted = varBitPlanted; this.plantingExperience = plantingExperience; this.experience = experience; this.stages = stages; this.type = type; this.rate1 = rate1; this.rate99 = rate99; this.protection = protection; } ProduceType(int seedId, int level, Item productId, int varBitPlanted, double plantingExperience, double experience, int stages, PatchType type, int rate1, int rate99) { this(seedId, level, productId, varBitPlanted, plantingExperience, experience, stages, type, rate1, rate99, null); } ProduceType(int seedId, int level, Item productId, int varBitPlanted, double plantingExperience, double experience, int stages, PatchType type, Item protection) { this(seedId, level, productId, varBitPlanted, plantingExperience, experience, stages, type, -1, -1, protection); } ProduceType(int seedId, int level, Item productId, int varBitPlanted, double plantingExperience, double experience, int stages, PatchType type) { this(seedId, level, productId, varBitPlanted, plantingExperience, experience, stages, type, -1, -1, null); } public boolean decreaseLife(Player player) { if (rate1 == -1) return true; return !Utils.skillSuccess(player.getSkills().getLevel(Constants.FARMING), player.getInventory().containsItem(7409) ? 1.1 : 1.0, rate1, rate99); } public ProduceType getFlowerProtection() { return switch (this) { case Potato, Onion, Tomato -> ProduceType.Marigold; case Cabbage -> ProduceType.Rosemary; case Sweetcorn -> ProduceType.Scarecrow; case Watermelon -> ProduceType.Nasturtium; default -> null; }; } }" "package com.rs.game.content.skills.farming; public class RakeAction extends PlayerAction { private final FarmPatch patch; public RakeAction(FarmPatch patch) { this.patch = patch; } @Override public boolean start(Player player) { if (patch.weeds <= 0) return false; player.setNextAnimation(FarmPatch.RAKING_ANIMATION); player.getActionManager().setActionDelay(4); return true; } @Override public boolean process(Player player) { if (patch.weeds <= 0) return false; return true; } @Override public int processWithDelay(Player player) { player.setNextAnimation(FarmPatch.RAKING_ANIMATION); if (patch.weeds > 0) patch.weeds--; patch.updateVars(player); player.putPatch(patch); player.incrementCount(""Weeds raked""); player.getInventory().addItemDrop(6055, 1); player.getSkills().addXp(Constants.FARMING, 4); return patch.weeds == 0 ? -1 : 3; } @Override public void stop(Player player) { player.setNextAnimation(new Animation(-1)); } }" "package com.rs.game.content.skills.farming; public enum StorableItem { RAKE(1, 5341) { @Override public void updateVars(Player player) { player.getVars().setVarBit(VB_RAKE, player.getLeprechaunStorage().containsKey(RAKE) ? 1 : 0); } }, SEED_DIBBER(1, 5343) { @Override public void updateVars(Player player) { player.getVars().setVarBit(VB_SEED_DIBBER, player.getLeprechaunStorage().containsKey(SEED_DIBBER) ? 1 : 0); } }, SPADE(1, 952) { @Override public void updateVars(Player player) { player.getVars().setVarBit(VB_SPADE, player.getLeprechaunStorage().containsKey(SPADE) ? 1 : 0); } }, TROWEL(1, 5325) { @Override public void updateVars(Player player) { player.getVars().setVarBit(VB_TROWEL, player.getLeprechaunStorage().containsKey(TROWEL) ? 1 : 0); } }, SCARECROW(7, 6059) { @Override public void updateVars(Player player) { player.getVars().setVarBit(VB_SCARECROW, player.getNumInLeprechaun(SCARECROW)); } }, BUCKET(255, 1925) { @Override public void updateVars(Player player) { player.getVars().setVarBit(VB_BUCKET, player.getNumInLeprechaun(BUCKET) % 32); player.getVars().setVarBit(VB_EXTRA_BUCKETS, player.getNumInLeprechaun(BUCKET) / 32); } }, COMPOST(255, 6032) { @Override public void updateVars(Player player) { player.getVars().setVarBit(VB_COMPOST, player.getNumInLeprechaun(COMPOST)); } }, SUPERCOMPOST(255, 6034) { @Override public void updateVars(Player player) { player.getVars().setVarBit(VB_SUPERCOMPOST, player.getNumInLeprechaun(SUPERCOMPOST)); } }, SECATEURS(1, 5329, 7409) { @Override public void updateVars(Player player) { Item item = player.getLeprechaunStorage().get(SECATEURS); player.getVars().setVarBit(VB_SECATEURS, player.getLeprechaunStorage().containsKey(SECATEURS) ? 1 : 0); player.getVars().setVarBit(VB_IS_MAGIC_SECATEURS, (item == null || item.getId() == 5329) ? 0 : 1); } }, WATERING_CAN(1, 5331, 5333, 5334, 5335, 5336, 5337, 5338, 5339, 5340, 18682) { @Override public void updateVars(Player player) { if (!player.getLeprechaunStorage().containsKey(WATERING_CAN)) { player.getVars().setVarBit(VB_WATERING_CAN, 0); return; } int index = 0; for (int i = 0;i < validIds.length;i++) if (player.getLeprechaunStorage().get(WATERING_CAN).getId() == validIds[i]) { index = i; break; } player.getVars().setVarBit(VB_WATERING_CAN, index+1); } }, PLANT_CURE(255, 6036) { @Override public void updateVars(Player player) { player.getVars().setVarBit(VB_PLANT_CURE, player.getNumInLeprechaun(PLANT_CURE)); } }; private static final int VB_RAKE = 1435, VB_SEED_DIBBER = 1436, VB_SPADE = 1437, VB_TROWEL = 1440, VB_SCARECROW = 1778, VB_BUCKET = 1441, VB_COMPOST = 1442, VB_SUPERCOMPOST = 1443, VB_SECATEURS = 1438, VB_IS_MAGIC_SECATEURS = 1848, VB_WATERING_CAN = 1439, VB_EXTRA_BUCKETS = 10204, VB_PLANT_CURE = 10205; private static final Map MAP = new HashMap<>(); static { for (StorableItem item : StorableItem.values()) for (int id : item.validIds) MAP.put(id, item); } public static StorableItem forId(int itemId) { return MAP.get(itemId); } public final int maxAmount; public final int[] validIds; public abstract void updateVars(Player player); private StorableItem(int maxAmount, int... validIds) { this.maxAmount = maxAmount; this.validIds = validIds; } }" "package com.rs.game.content.skills.farming; @PluginEventHandler public class ToolLeprechaun { //inventory inter 74 = jadinko related storage public static void openToolStorage(Player player) { for (StorableItem i : StorableItem.values()) i.updateVars(player); player.getInterfaceManager().sendInterface(125); player.getInterfaceManager().sendInventoryInterface(126); } public static void storeTool(Player player, int itemId, int amount) { StorableItem item = StorableItem.forId(itemId); if (item == null) return; player.storeLeprechaunItem(item, itemId, amount); } public static void takeTool(Player player, int itemId, int amount) { StorableItem item = StorableItem.forId(itemId); if (item == null) return; player.takeLeprechaunItem(item, amount); } public static NPCClickHandler handleToolLeprechaun = new NPCClickHandler(new Object[] { ""Tool leprechaun"", ""Tool Leprechaun"" }, e -> { switch(e.getOption()) { case ""Exchange"": case ""Exchange-tools"": case ""Exchange-potions"": openToolStorage(e.getPlayer()); break; case ""Talk-to"": e.getPlayer().startConversation(new Conversation(e.getPlayer()) { { addNPC(e.getNPCId(), HeadE.CHEERFUL, ""Ah, 'tis a foine day, to be sure! Can I help ye with tool storage, or a trip to Winkin's Farm, or what?""); addOptions(""What would you like to say?"", new Options() { @Override public void create() { option(""Tool storage."", new Dialogue() .addNPC(e.getNPCId(), HeadE.CHEERFUL, ""We'll hold onto yer rake, seed dibber, spade, secateurs, waterin' can and trowel - but mind it's not one of them fancy trowels only archaeologists use."") .addNPC(e.getNPCId(), HeadE.CHEERFUL, ""We'll take a few buckets an' scarecrows off yer hands too, and even yer compost and supercompost. There's room in our shed for plenty of compost, so bring it on."") .addNPC(e.getNPCId(), HeadE.CHEERFUL, ""Also, if ye hands us yer Farming produce, we might be able to change it into banknotes."") .addNPC(e.getNPCId(), HeadE.CONFUSED, ""So, do ye want to be using the store?"") .addOption(""What would you like to say?"", ""Yes, please."", ""Nevermind."") .addNext(() -> openToolStorage(e.getPlayer()))); option(""Winkin's farm."", new Dialogue().addNPC(e.getNPCId(), HeadE.UPSET, ""I'm sorry mate, I've been instructed that I'm not allowed to do that yet!"")); } }); } }); break; case ""Teleport"": e.getPlayer().sendMessage(""Vinesweeper is not available yet.""); break; } }); private static final List NOTABLE_HERBS = Arrays.asList( 249, 251, 253, 255, 257, 259, 261, 263, 265, 267, 269, 2481, 2998, 3000, 12172, 14854, 21624 ); public static ItemOnNPCHandler handleItemOnLeprechaun = new ItemOnNPCHandler(new Object[] { ""Tool leprechaun"", ""Tool Leprechaun"" }, e -> { int itemId = e.getItem().getId(); ProduceType produceType = ProduceType.forProduce(itemId); if ((produceType == null || e.getItem().getDefinitions().getCertId() == -1) && !NOTABLE_HERBS.contains(itemId)) { e.getPlayer().sendMessage(""The leprechaun cannot note that item for you.""); return; } int num = e.getPlayer().getInventory().getNumberOf(itemId); e.getPlayer().getInventory().deleteItem(itemId, num); e.getPlayer().getInventory().addItem(new Item(e.getItem().getDefinitions().getCertId(), num)); }); public static ButtonClickHandler handleWithdrawInter = new ButtonClickHandler(125, e -> { switch(e.getPacket()) { case IF_OP1: takeTool(e.getPlayer(), e.getSlotId2(), 1); break; case IF_OP2: takeTool(e.getPlayer(), e.getSlotId2(), 5); break; case IF_OP3: takeTool(e.getPlayer(), e.getSlotId2(), Integer.MAX_VALUE); break; case IF_OP4: e.getPlayer().sendInputInteger(""How many would you like to take?"", num -> takeTool(e.getPlayer(), e.getSlotId2(), num)); break; default: break; } }); public static ButtonClickHandler handleInventoryInter = new ButtonClickHandler(126, e -> { switch(e.getPacket()) { case IF_OP1: storeTool(e.getPlayer(), e.getSlotId2(), 1); break; case IF_OP2: storeTool(e.getPlayer(), e.getSlotId2(), 5); break; case IF_OP3: storeTool(e.getPlayer(), e.getSlotId2(), Integer.MAX_VALUE); break; case IF_OP4: e.getPlayer().sendInputInteger(""How many would you like to store?"", num -> storeTool(e.getPlayer(), e.getSlotId2(), num)); break; default: break; } }); }" "package com.rs.game.content.skills.farming; public class TreeSaplings { private static final int[] SEEDS = { 5312, 5313, 5314, 5315, 5316, 5317, 5283, 5284, 5285, 5286, 5287, 5288, 5289, 5290 }; private static final int[] SAPLINGS = { 5370, 5371, 5372, 5373, 5374, 5375, 5496, 5497, 5498, 5499, 5500, 5501, 5502, 5503 }; public static boolean hasSaplingRequest(Player player, int itemUsed, int itemUsedWith) { boolean hasSeed = false; for (int seedId : SEEDS) if (itemUsed == seedId || itemUsedWith == seedId) { hasSeed = true; break; } return hasSeed && (itemUsed == 5354 || itemUsedWith == 5354); } public static void plantSeed(Player player, int seedId, int slot) { int index = getIndex(seedId); if (index == -1) return; player.lock(1); player.getInventory().replaceItem(SAPLINGS[index], 1, slot); player.getInventory().deleteItem(seedId, 1); } private static int getIndex(int itemId) { for (int index = 0; index < SEEDS.length; index++) if (itemId == SEEDS[index]) return index; return -1; } }" "package com.rs.game.content.skills.firemaking; @PluginEventHandler public class Bonfire extends PlayerAction { public static ItemOnObjectHandler logsOnFire = new ItemOnObjectHandler(new Object[] { ""Fire"" }, Arrays.stream(Log.values()).map(log -> log.logId).toArray(), e -> { if (e.getObject().getDefinitions(e.getPlayer()).containsOption(4, ""Add-logs"")) Bonfire.addLog(e.getPlayer(), e.getObject(), e.getItem()); }); public static enum Log { LOG(1511, 3098, 1, 50, 6), ACHEY(2862, 3098, 1, 50, 6), OAK(1521, 3099, 15, 75, 12), WILLOW(1519, 3101, 30, 112.5, 18), TEAK(6333, 3098, 35, 120, 18), ARCTIC_PINE(10810, 3098, 42, 135, 18), MAPLE(1517, 3100, 45, 157, 36), MAHOGANY(6332, 3098, 50, 180, 36), EUCALYPTUS(12581, 3112, 58, 241, 48), YEWS(1515, 3111, 60, 252, 54), MAGIC(1513, 3135, 75, 378, 60), BLISTERWOOD(21600, 3113, 76, 378, 60), CURSED_MAGIC(13567, 3116, 82, 378, 60); private final int logId; private final int gfxId; private final int level; private final int boostTime; private final double xp; private Log(int logId, int gfxId, int level, double xp, int boostTime) { this.logId = logId; this.gfxId = gfxId; this.level = level; this.xp = xp; this.boostTime = boostTime; } public int getLogId() { return logId; } } private final Log log; private final GameObject object; private int count; public Bonfire(Log log, GameObject object) { this.log = log; this.object = object; } private boolean checkAll(Player player) { if (!ChunkManager.getChunk(object.getTile().getChunkId()).objectExists(object) || !player.getInventory().containsItem(log.logId, 1)) return false; if (player.getSkills().getLevel(Constants.FIREMAKING) < log.level) { player.simpleDialogue(""You need level "" + log.level + "" Firemaking to add these logs to a bonfire.""); return false; } return true; } public static boolean addLog(Player player, GameObject object, Item item) { for (Log log : Log.values()) if (log.logId == item.getId()) { player.getActionManager().setAction(new Bonfire(log, object)); return true; } return false; } public static void addLogs(Player player, GameObject object) { ArrayList possiblities = new ArrayList<>(); for (Log log : Log.values()) if (player.getInventory().containsItem(log.logId, 1)) possiblities.add(log); Log[] logs = possiblities.toArray(new Log[0]); if (logs.length == 0) player.sendMessage(""You do not have any logs to add to this fire.""); else if (logs.length == 1) player.getActionManager().setAction(new Bonfire(logs[0], object)); else player.startConversation(new BonfireD(player, object, logs)); } @Override public boolean start(Player player) { if (checkAll(player)) { player.getAppearance().setBAS(2498); return true; } return false; } @Override public boolean process(Player player) { if (checkAll(player)) { if (Utils.random(500) == 0) { Tile tile = player.getNearestTeleTile(1); if (tile != null) { new FireSpirit(tile, player); player.sendMessage(""A fire spirit emerges from the bonfire.""); } else player.sendMessage(""A fire spirit struggles to escape the bonfire. Try moving elsewhere.""); } return true; } return false; } @Override public int processWithDelay(Player player) { player.incrementCount(ItemDefinitions.getDefs(log.logId).getName()+"" burned in bonfire""); player.getInventory().deleteItem(log.logId, 1); player.getSkills().addXp(Constants.FIREMAKING, Firemaking.increasedExperience(player, log.xp)); player.setNextAnimation(new Animation(16703)); player.setNextSpotAnim(new SpotAnim(log.gfxId)); player.sendMessage(""You add a log to the fire."", true); if (count++ == 4 && !player.hasEffect(Effect.BONFIRE)) { player.addEffect(Effect.BONFIRE, log.boostTime * 100L); int percentage = (int) (getBonfireBoostMultiplier(player) * 100); player.sendMessage(""The bonfire's warmth increases your maximum health by "" + percentage + ""%. This will last "" + log.boostTime + "" minutes.""); } return 5; } public static double getBonfireBoostMultiplier(Player player) { int fmLvl = player.getSkills().getLevel(Constants.FIREMAKING); if (fmLvl >= 90) return 0.1; if (fmLvl >= 80) return 0.09; if (fmLvl >= 70) return 0.08; if (fmLvl >= 60) return 0.07; if (fmLvl >= 50) return 0.06; if (fmLvl >= 40) return 0.05; if (fmLvl >= 30) return 0.04; if (fmLvl >= 20) return 0.03; if (fmLvl >= 10) return 0.02; return 0.01; } @Override public void stop(final Player player) { player.getEmotesManager().setNextEmoteEnd(4); WorldTasks.schedule(new Task() { @Override public void run() { player.setNextAnimation(new Animation(16702)); player.getAppearance().setBAS(-1); } }, 3); } }" "package com.rs.game.content.skills.firemaking; public class BonfireD extends Conversation { public BonfireD(Player player, GameObject object, Log[] logs) { super(player); Dialogue makeX = addNext(new MakeXStatement(MakeXType.SELECT, ""Which logs do you want to add to the bonfire?"", Arrays.stream(logs).mapToInt(Log::getLogId).toArray(), -1)); for (Log log : logs) makeX.addNext(() -> player.getActionManager().setAction(new Bonfire(log, object))); } }" "package com.rs.game.content.skills.firemaking; public class Firemaking extends Action { public static enum Fire { NORMAL(1511, 1, 300, 70755, 40, 20), ACHEY(2862, 1, 300, 70756, 40, 1), OAK(1521, 15, 450, 70757, 60, 1), WILLOW(1519, 30, 450, 70758, 90, 1), TEAK(6333, 35, 450, 70759, 105, 1), ARCTIC_PINE(10810, 42, 500, 70760, 125, 1), MAPLE(1517, 45, 500, 70761, 135, 1), MAHOGANY(6332, 50, 700, 70762, 157.5, 1), EUCALYPTUS(12581, 58, 700, 70763, 193.5, 1), YEW(1515, 60, 800, 70764, 202.5, 1), MAGIC(1513, 75, 900, 70765, 303.8, 1), CURSED_MAGIC(13567, 82, 1000, 70766, 303.8, 1), TANGLE_GUM_BRANCHES(17682, 1, 300, 49940, 25, 1), SEEPING_ELM_BRANCHES(17684, 10, 375, 49941, 44.5, 1), BLOOD_SPINDLE_BRANCHES(17686, 20, 410, 49942, 65.6, 1), UTUKU_BRANCHES(17688, 30, 450, 49943, 88.3, 1), SPINEBEAM_BRANCHES(17690, 40, 500, 49944, 112.6, 1), BOVISTRANGLER_BRANCHES(17692, 50, 700, 49945, 138.5, 1), THIGAT_BRANCHES(17694, 60, 700, 49946, 166, 1), CORPSETHRON_BRANCHES(17696, 70, 850, 49947, 195.1, 1), ENTGALLOW_BRANCHES(17698, 80, 925, 49948, 225.8, 1), GRAVE_CREEPER_BRANCHES(17700, 90, 1000, 49949, 258.1, 1); private final int logId; private final int level; private final int life; private final int fireId; private final int time; private final double xp; Fire(int logId, int level, int life, int fireId, double xp, int time) { this.logId = logId; this.level = level; this.life = life; this.fireId = fireId; this.xp = xp; this.time = time; } public static Fire forId(int logId) { for (Fire fire : Fire.values()) if (fire.getLogId() == logId) return fire; return null; } public int getLogId() { return logId; } public int getLevel() { return level; } public int getLife() { return life; } public int getFireId() { return fireId; } public double getExperience() { return xp; } public int getTime() { return time; } } private final Fire fire; private final GroundItem groundItem; public Firemaking(Fire fire) { this(fire, null); } public Firemaking(Fire fire, GroundItem groundItem) { this.fire = fire; this.groundItem = groundItem; } @Override public boolean start(Entity entity) { Player player = getPlayer(entity); if (!checkAll(entity)) return false; entity.resetWalkSteps(); if (player != null) player.sendMessage(""You attempt to light the logs."", true); if (player != null && groundItem == null) { player.getInventory().deleteItem(fire.getLogId(), 1); World.addGroundItem(new Item(fire.getLogId(), 1), Tile.of(entity.getTile()), player, true, 180); } boolean quickFire = entity.getTempAttribs().removeL(""Fire"") > System.currentTimeMillis(); setActionDelay(entity, quickFire ? 1 : 2); if (!quickFire) entity.setNextAnimation(new Animation(entity instanceof Familiar ? 8085 : 16700)); return true; } public static boolean isFiremaking(Player player, Item item1, Item item2) { Item log = InventoryOptionsHandler.contains(590, item1, item2); if (log == null) return false; return isFiremaking(player, log.getId()); } public static boolean isFiremaking(Player player, int logId) { for (Fire fire : Fire.values()) if (fire.getLogId() == logId) { player.getActionManager().setAction(new Firemaking(fire)); return true; } return false; } public boolean checkAll(Entity entity) { Player player = getPlayer(entity); if (entity instanceof Player && !player.getInventory().containsItem(590, 1) && (fire.ordinal() >= Fire.TANGLE_GUM_BRANCHES.ordinal() && !player.getInventory().containsItem(DungeonConstants.TINDERBOX))) { player.sendMessage(""You do not have the required items to light this.""); return false; } if (player != null && player.getSkills().getLevel(Constants.FIREMAKING) < fire.getLevel()) { player.sendMessage(""You do not have the required level to light this.""); return false; } if (!World.canLightFire(entity.getPlane(), entity.getX(), entity.getY()) || ChunkManager.getChunk(entity.getChunkId()).getSpawnedObject(entity.getTile()) != null || (player != null && (player.getControllerManager().getController() instanceof DuelArenaController || player.getControllerManager().getController() instanceof DuelController))) { // contains if (player != null) player.sendMessage(""You can't light a fire here.""); return false; } return true; } @Override public boolean process(Entity entity) { return checkAll(entity); } public static double increasedExperience(Player player, double totalXp) { if (player.getEquipment().getGlovesId() == 13660) totalXp *= 1.025; if (player.getEquipment().getRingId() == 13659) totalXp *= 1.025; return totalXp; } @Override public int processWithDelay(Entity entity) { Player player = getPlayer(entity); final Tile tile = Tile.of(entity.getTile()); if (!entity.addWalkSteps(entity.getX() - 1, entity.getY(), 1)) if (!entity.addWalkSteps(entity.getX() + 1, entity.getY(), 1)) if (!entity.addWalkSteps(entity.getX(), entity.getY() + 1, 1)) entity.addWalkSteps(entity.getX(), entity.getY() - 1, 1); if (player != null) player.sendMessage(""The fire catches and the logs begin to burn."", true); WorldTasks.schedule(new Task() { @Override public void run() { if (player != null) { final GroundItem item = groundItem != null ? groundItem : ChunkManager.getChunk(tile.getChunkId()).getGroundItem(fire.getLogId(), tile, player); if ((item == null) || !World.removeGroundItem(player, item, false)) return; } World.spawnTempGroundObject(new GameObject(fire.getFireId(), ObjectType.SCENERY_INTERACT, 0, tile.getX(), tile.getY(), tile.getPlane()), 592, fire.getLife()); if (player != null) player.getSkills().addXp(Constants.FIREMAKING, increasedExperience(player, fire.getExperience())); entity.setNextFaceTile(tile); } }, 1); entity.getTempAttribs().setL(""Fire"", System.currentTimeMillis() + 1800); return -1; } @Override public void stop(Entity entity) { setActionDelay(entity, 3); } public Player getPlayer(Entity entity) { if (entity instanceof Player p) return p; else if (entity instanceof Familiar f) return f.getOwner(); return null; } }" "package com.rs.game.content.skills.firemaking; @PluginEventHandler public class FireSpirit extends OwnedNPC { private int life; public FireSpirit(Tile tile, Player target) { super(target, 15451, tile, true); life = Ticks.fromMinutes(1); getNextHitBars().add(new TimerBar(life * 30)); } @Override public void processNPC() { super.processNPC(); if (life-- <= 0) finish(); } @Override public void sendDrop(Player player, Item item) { player.getInventory().addItemDrop(item); } public void giveReward(final Player player) { if (player != getOwner() || player.isLocked()) return; player.lock(); player.setNextAnimation(new Animation(16705)); WorldTasks.schedule(2, () -> { player.unlock(); player.incrementCount(""Fire spirits set free""); drop(player, false); for (int i = 0;i < 5;i++) if (Utils.random(100) < 50) drop(player, false); player.sendMessage(""The fire spirit gives you a reward to say thank you for freeing it, before disappearing.""); finish(); }); } public static NPCClickHandler claim = new NPCClickHandler(new Object[] { 15451 }, e -> { if (e.getNPC() instanceof FireSpirit spirit) spirit.giveReward(e.getPlayer()); }); }" "package com.rs.game.content.skills.fishing; public enum Fish { CRAYFISH(13435, 1, 10, 60, 180), KARAMBWANJI(3150, 5, 5, 100, 250), KARAMBWAN(3142, 65, 50, 1, 160), SHRIMP(317, 1, 10, 60, 180), ANCHOVIES(321, 15, 40, 30, 90), SARDINES(327, 5, 20, 32, 180), GIANT_CARP(338, 10, 50, 32, 192), HERRING(345, 10, 30, 16, 96), TROUT(335, 20, 50, 32, 192), SALMON(331, 30, 70, 16, 96), PIKE(349, 25, 60, 16, 110), FROGSPAWN(5004, 33, 75, 16, 96), TUNA(359, 35, 80, 16, 70, (p) -> { if (Utils.random(10) == 0) if (p.getSkills().getLevel(Constants.AGILITY) >= 35) { p.getInventory().addItemDrop(359, 1); p.sendMessage(""Your quick reflexes allow you to catch an extra fish!"", true); } }), SWORDFISH(371, 50, 100, 8, 50, (p) -> { if (Utils.random(10) == 0) if (p.getSkills().getLevel(Constants.AGILITY) >= 50) { p.getInventory().addItemDrop(371, 1); p.sendMessage(""Your quick reflexes allow you to catch an extra fish!"", true); } }), LOBSTER(377, 40, 90, 1, 120), MACKEREL(353, 16, 20, 10, 50), COD(341, 23, 45, 6, 30), BASS(363, 46, 100, 6, 20), LEATHER_BOOTS(1061, 16, 1, 8, 8), SEAWEED(401, 16, 1, 8, 8), LEATHER_GLOVES(1059, 16, 1, 4, 4), OYSTER(407, 16, 10, 4, 4), CASKET(405, 16, 10, 2, 3), LEAPING_TROUT(11328, 48, 50, 32, 192, (p) -> p.getSkills().getLevel(Constants.AGILITY) >= 15 && p.getSkills().getLevel(Constants.STRENGTH) >= 15, (p) -> { p.getSkills().addXp(Constants.AGILITY, 5); p.getSkills().addXp(Constants.STRENGTH, 5); }), LAVA_EEL(2148, 53, 60, 25, 80), LEAPING_SALMON(11330, 58, 70, 16, 96, (p) -> p.getSkills().getLevel(Constants.AGILITY) >= 30 && p.getSkills().getLevel(Constants.STRENGTH) >= 30, (p) -> { p.getSkills().addXp(Constants.AGILITY, 6); p.getSkills().addXp(Constants.STRENGTH, 6); }), LEAPING_STURGEON(11332, 70, 80, 8, 64, (p) -> p.getSkills().getLevel(Constants.AGILITY) >= 45 && p.getSkills().getLevel(Constants.STRENGTH) >= 45, (p) -> { p.getSkills().addXp(Constants.AGILITY, 7); p.getSkills().addXp(Constants.STRENGTH, 7); }), MONKFISH(7944, 62, 120, 25, 80), SHARK(383, 76, 110, 1, 37, (p) -> { if (Utils.random(10) == 0) if (p.getSkills().getLevel(Constants.AGILITY) >= 76) { p.getInventory().addItemDrop(383, 1); p.sendMessage(""Your quick reflexes allow you to catch an extra fish!"", true); } }), CAVEFISH(15264, 85, 300, -40, 40), ROCKTAIL(15270, 90, 385, -35, 35); private final int fishId, level, rate1, rate99; private final double xp; private final Predicate extraRequirements; private final Consumer extraRewards; Fish(int rawItemId, int level, double xp, int rate1, int rate99, Predicate extraRequirements, Consumer extraRewards) { this.fishId = rawItemId; this.level = level; this.xp = xp; this.rate1 = rate1; this.rate99 = rate99; this.extraRequirements = extraRequirements; this.extraRewards = extraRewards; } Fish(int rawItemId, int level, double xp, int rate1, int rate99, Predicate extraReq) { this(rawItemId, level, xp, rate1, rate99, extraReq, null); } Fish(int rawItemId, int level, double xp, int rate1, int rate99, Consumer extraRewards) { this(rawItemId, level, xp, rate1, rate99, null, extraRewards); } Fish(int rawItemId, int level, double xp, int rate1, int rate99) { this(rawItemId, level, xp, rate1, rate99, null, null); } public int getFishId() { return fishId; } public int getLevel() { return level; } public double getXp() { return xp; } public boolean checkRequirements(Player player) { return player.getSkills().getLevel(Constants.FISHING) >= level && (extraRequirements == null || extraRequirements.test(player)); } public boolean rollSuccess(Player player, int level) { return Utils.skillSuccess(level, player.getAuraManager().getFishingMul(), rate1, rate99); } public void giveFish(Player player, FishingSpot spot) { Item fish = new Item(fishId); deleteBait(player, spot); double totalXp = xp; if (Fishing.hasFishingSuit(player)) totalXp *= 1.025; if (fish.getId() == 383 && player.hasEffect(Effect.JUJU_FISHING)) { int random = Utils.random(100); if (random < 30) fish.setId(19947); } player.sendMessage(Fishing.getMessage(this), true); if (fish.getId() != -1) player.getInventory().addItem(fish); player.getSkills().addXp(Constants.FISHING, totalXp); player.incrementCount(fish.getDefinitions().getName() + "" caught fishing""); if (extraRewards != null) extraRewards.accept(player); } public void deleteBait(Player player, FishingSpot spot) { int baitToDelete = -1; if (spot.getBait() != null) for (int bait : spot.getBait()) if (player.getInventory().containsItem(bait)) { baitToDelete = bait; break; } if (baitToDelete != -1) player.getInventory().deleteItem(baitToDelete, 1); } }" "package com.rs.game.content.skills.fishing; @PluginEventHandler public class Fishing extends PlayerAction { private static final Map FISHING_SPOTS = new HashMap<>(); static { FISHING_SPOTS.put(1174, new FishingSpot[]{FishingSpot.KARAMBWANJI}); FISHING_SPOTS.put(1176, new FishingSpot[]{FishingSpot.KARAMBWAN}); FISHING_SPOTS.put(1177, new FishingSpot[]{FishingSpot.KARAMBWAN}); FISHING_SPOTS.put(1178, new FishingSpot[]{FishingSpot.KARAMBWAN}); FISHING_SPOTS.put(312, new FishingSpot[]{FishingSpot.LOBSTER, FishingSpot.TUNA_SWORDFISH}); FISHING_SPOTS.put(1332, new FishingSpot[]{FishingSpot.LOBSTER, FishingSpot.TUNA_SWORDFISH}); FISHING_SPOTS.put(5470, new FishingSpot[]{FishingSpot.LOBSTER, FishingSpot.TUNA_SWORDFISH}); FISHING_SPOTS.put(7046, new FishingSpot[]{FishingSpot.LOBSTER, FishingSpot.TUNA_SWORDFISH}); FISHING_SPOTS.put(313, new FishingSpot[]{FishingSpot.BIG_NET, FishingSpot.SHARK}); FISHING_SPOTS.put(1333, new FishingSpot[]{FishingSpot.BIG_NET, FishingSpot.SHARK}); FISHING_SPOTS.put(5471, new FishingSpot[]{FishingSpot.BIG_NET, FishingSpot.SHARK}); FISHING_SPOTS.put(3574, new FishingSpot[]{FishingSpot.BIG_NET, FishingSpot.SHARK}); FISHING_SPOTS.put(3575, new FishingSpot[]{FishingSpot.BIG_NET, FishingSpot.SHARK}); FISHING_SPOTS.put(7044, new FishingSpot[]{FishingSpot.BIG_NET, FishingSpot.SHARK}); FISHING_SPOTS.put(317, new FishingSpot[]{FishingSpot.FLY_FISHING, FishingSpot.PIKE}); FISHING_SPOTS.put(315, new FishingSpot[]{FishingSpot.FLY_FISHING, FishingSpot.PIKE}); FISHING_SPOTS.put(309, new FishingSpot[]{FishingSpot.FLY_FISHING, FishingSpot.PIKE}); FISHING_SPOTS.put(326, new FishingSpot[]{FishingSpot.SHRIMP, FishingSpot.SEA_BAIT}); FISHING_SPOTS.put(323, new FishingSpot[]{FishingSpot.SHRIMP, FishingSpot.SEA_BAIT}); FISHING_SPOTS.put(7045, new FishingSpot[]{FishingSpot.SHRIMP, FishingSpot.SEA_BAIT}); FISHING_SPOTS.put(324, new FishingSpot[]{FishingSpot.LOBSTER, FishingSpot.TUNA_SWORDFISH}); FISHING_SPOTS.put(3804, new FishingSpot[]{FishingSpot.LOBSTER, FishingSpot.TUNA_SWORDFISH}); FISHING_SPOTS.put(325, new FishingSpot[]{FishingSpot.SHRIMP, FishingSpot.SEA_BAIT}); FISHING_SPOTS.put(2724, new FishingSpot[]{FishingSpot.SHRIMP, FishingSpot.SEA_BAIT}); FISHING_SPOTS.put(1331, new FishingSpot[]{FishingSpot.SHRIMP, FishingSpot.SEA_BAIT}); FISHING_SPOTS.put(327, new FishingSpot[]{FishingSpot.SHRIMP, FishingSpot.SEA_BAIT}); FISHING_SPOTS.put(328, new FishingSpot[]{FishingSpot.FLY_FISHING, FishingSpot.PIKE}); FISHING_SPOTS.put(329, new FishingSpot[]{FishingSpot.FLY_FISHING, FishingSpot.PIKE}); FISHING_SPOTS.put(330, new FishingSpot[]{FishingSpot.SHRIMP, FishingSpot.SEA_BAIT}); FISHING_SPOTS.put(334, new FishingSpot[]{FishingSpot.MONKFISH, FishingSpot.TUNA_SWORDFISH}); FISHING_SPOTS.put(952, new FishingSpot[]{FishingSpot.SHRIMP}); FISHING_SPOTS.put(2068, new FishingSpot[]{FishingSpot.FROGSPAWN}); FISHING_SPOTS.put(2722, new FishingSpot[]{FishingSpot.BARBARIAN_FLY_FISHING}); FISHING_SPOTS.put(3848, new FishingSpot[]{FishingSpot.TUNA_SWORDFISH, FishingSpot.MONKFISH}); FISHING_SPOTS.put(6267, new FishingSpot[]{FishingSpot.CRAYFISH}); FISHING_SPOTS.put(8841, new FishingSpot[]{FishingSpot.CAVEFISH}); FISHING_SPOTS.put(8842, new FishingSpot[]{FishingSpot.ROCKTAIL}); FISHING_SPOTS.put(14907, new FishingSpot[]{FishingSpot.CRAYFISH}); FISHING_SPOTS.put(7862, new FishingSpot[]{FishingSpot.CRAYFISH}); FISHING_SPOTS.put(15020, new FishingSpot[]{FishingSpot.LAVA_EEL}); } private final FishingSpot spot; private final NPC npc; private final Tile tile; public Fishing(FishingSpot spot, NPC npc) { this.spot = spot; this.npc = npc; this.tile = Tile.of(npc.getTile()); } @Override public boolean start(Player player) { if (!checkAll(player)) return false; player.setNextFaceTile(npc.getTile()); player.sendMessage(""You attempt to capture a fish..."", true); setActionDelay(player, 4); return true; } @Override public boolean process(Player player) { player.setNextAnimation(spot.getAnimation()); return checkAll(player); } @Override public int processWithDelay(Player player) { int level = player.getSkills().getLevel(Constants.FISHING) + player.getInvisibleSkillBoost(Skills.FISHING); for (Fish f : spot.getFish()) { if (f.checkRequirements(player) && f.rollSuccess(player, level)) { f.giveFish(player, spot); return 4; } if (f == Fish.KARAMBWAN) { f.deleteBait(player, spot); player.sendMessage(""A Karambwan deftly snatches the Karambwanji from your vessel!"", true); } } return 4; } private boolean checkAll(Player player) { if (spot == null) { player.sendMessage(""Nothing interesting happens.""); return false; } if (player.getSkills().getLevel(Constants.FISHING) < spot.getLevel()) { player.simpleDialogue(""You need a fishing level of "" + spot.getLevel() + "" to fish here.""); return false; } boolean hasTool = false; for (int tool : spot.getTool()) if (player.getInventory().containsOneItem(tool) || player.getEquipment().getWeaponId() == tool) hasTool = true; if (!hasTool) { player.sendMessage(""You need a "" + new Item(spot.getTool()[0]).getDefinitions().getName().toLowerCase() + "" to fish here.""); return false; } if (spot.getBait() != null && !player.getInventory().containsOneItem(spot.getBait())) { player.sendMessage(""You don't have bait to fish here.""); return false; } if (!player.getInventory().hasFreeSlots()) { player.setNextAnimation(new Animation(-1)); player.simpleDialogue(""You don't have enough inventory space.""); return false; } if (tile.getX() != npc.getX() || tile.getY() != npc.getY()) return false; return true; } @Override public void stop(final Player player) { setActionDelay(player, 4); player.anim(-1); } public static boolean hasFishingSuit(Player player) { return player.getEquipment().getHatId() == 24427 && player.getEquipment().getChestId() == 24428 && player.getEquipment().getLegsId() == 24429 && player.getEquipment().getBootsId() == 24430; } public static String getMessage(Fish fish) { if (fish == Fish.ANCHOVIES || fish == Fish.SHRIMP) return ""You manage to catch some "" + ItemDefinitions.getDefs(fish.getFishId()).getName().toLowerCase() + "".""; return ""You manage to catch a "" + ItemDefinitions.getDefs(fish.getFishId()).getName().toLowerCase() + "".""; } public static NPCClickHandler handleFishingSpots = new NPCClickHandler(FISHING_SPOTS.keySet().toArray(), e -> { e.getNPC().resetDirection(); int op = e.getOpNum() == 1 ? 0 : e.getOpNum() - 2; if (op >= 0 && op < FISHING_SPOTS.get(e.getNPC().getId()).length) e.getPlayer().getActionManager().setAction(new Fishing(FISHING_SPOTS.get(e.getNPC().getId())[op], e.getNPC())); }); public static ObjectClickHandler handleBarbarianBed = new ObjectClickHandler(new Object[]{25268}, e -> { e.getPlayer().getInventory().addItem(11323, 1); e.getPlayer().sendMessage(""You find a barbarian fishing rod under the bed.""); }); public static ItemOnItemHandler handleKnifeOnBarbFish = new ItemOnItemHandler(946, new int[]{11328, 11330, 11332}, e -> { Item fish = e.getUsedWith(946); if (fish == null) return; if (!e.getPlayer().getInventory().containsItem(946, 1)) { e.getPlayer().sendMessage(""You need a knife to gut fish.""); return; } int chance1 = fish.getId() == 11328 ? 2 : 4; int chance99 = fish.getId() == 11328 ? 169 : 317; e.getPlayer().setNextAnimation(new Animation(6702)); e.getPlayer().getInventory().deleteItem(fish); if (Utils.skillSuccess(e.getPlayer().getSkills().getLevel(Skills.COOKING), chance1, chance99)) { double offcutChance = switch(fish.getId()) { default -> 0.5; case 11330 -> 0.75; case 11332 -> 0.83333; }; e.getPlayer().getInventory().addItemDrop(fish.getId() == 11332 ? 11326 : 11324, 1); e.getPlayer().getSkills().addXp(Constants.COOKING, fish.getId() == 11332 ? 15 : 10); if (Math.random() < offcutChance) e.getPlayer().getInventory().addItemDrop(11334, 1); } }); public static ItemOnItemHandler handleKarambwanVessel = new ItemOnItemHandler(3150, 3157, e -> { e.getPlayer().getInventory().deleteItem(new Item(3150, 1)); e.getPlayer().getInventory().replace(3157, 3159); e.getPlayer().getInventory().refresh(); }); }" "package com.rs.game.content.skills.fishing; public enum FishingSpot { CRAYFISH(new int[] { 13431 }, null, new Animation(619), Fish.CRAYFISH), SHRIMP(new int[] { 303 }, null, new Animation(621), Fish.SHRIMP, Fish.ANCHOVIES), KARAMBWANJI(new int[] { 303 }, null, new Animation(621), Fish.KARAMBWANJI), KARAMBWAN(new int[] { 3159 }, new int[] { 3150 }, new Animation(1193), Fish.KARAMBWAN), SEA_BAIT(new int[] { 307 }, new int[] { 313 }, new Animation(622), Fish.SARDINES, Fish.HERRING), GIANT_CARP(new int[] { 307 }, new int[] { 25 }, new Animation(622), Fish.GIANT_CARP), BIG_NET(new int[] { 305 }, null, new Animation(620), Fish.MACKEREL, Fish.COD, Fish.BASS, Fish.SEAWEED, Fish.OYSTER, Fish.CASKET, Fish.LEATHER_BOOTS, Fish.LEATHER_GLOVES), TUNA_SWORDFISH(new int[] { 311, 10129 }, null, new Animation(618), Fish.TUNA, Fish.SWORDFISH), LOBSTER(new int[] { 301 }, null, new Animation(619), Fish.LOBSTER), SHARK(new int[] { 311, 10129 }, null, new Animation(618), Fish.SHARK), FLY_FISHING(new int[] { 309 }, new int[] { 314, 10087, 10088, 10089, 10090, 10091 }, new Animation(622), Fish.TROUT, Fish.SALMON), BARBARIAN_FLY_FISHING(new int[] { 11323 }, new int[] { 11326, 11324, 11334, 313, 314, 10087, 10088, 10089, 10090, 10091 }, new Animation(622), Fish.LEAPING_TROUT, Fish.LEAPING_SALMON, Fish.LEAPING_STURGEON), PIKE(new int[] { 307 }, new int[] { 313 }, new Animation(622), Fish.PIKE), LAVA_EEL(new int[] { 1585 }, new int[] { 313 }, new Animation(622), Fish.LAVA_EEL),//oily fishing rod, bait MONKFISH(new int[] { 303 }, null, new Animation(621), Fish.MONKFISH), FROGSPAWN(new int[] { 303 }, null, new Animation(621), Fish.FROGSPAWN), CAVEFISH(new int[] { 307 }, new int[] { 313 }, new Animation(622), Fish.CAVEFISH), ROCKTAIL(new int[] { 307 }, new int[] { 15263 }, new Animation(622), Fish.ROCKTAIL); private final List fish; private final int[] tool; private final int[] bait; private final Animation animation; FishingSpot(int[] tool, int[] bait, Animation animation, Fish... fish) { this.tool = tool; this.bait = bait; this.animation = animation; this.fish = new ArrayList<>(Arrays.asList(fish)); this.fish.sort((f1, f2) -> f2.getLevel()-f1.getLevel()); } public List getFish() { return fish; } public int[] getTool() { return tool; } public int[] getBait() { return bait; } public int getLevel() { return fish.getLast().getLevel(); } public Animation getAnimation() { return animation; } }" "package com.rs.game.content.skills.fletching; public class Fletching extends PlayerAction { public static final int KNIFE = 946; public static final int CHISLE = 1755; public static final int BOW_STRING = 1777; public static final int CROSSBOW_STRING = 9438; public static final int DUNGEONEERING_KNIFE = 17754; public static enum Fletch { LOG(1511, 946, new int[] { 52, 50, 48, 9440 }, new int[] { 1, 1, 10, 9 }, new double[] { 0.33, 5, 10, 6 }, new Animation(6702)), STRUNG_SHORT_BOW(50, 1777, new int[] { 841 }, new int[] { 1 }, new double[] { 5 }, new Animation(6678)), STRUNG_LONG_BOW(48, 1777, new int[] { 839 }, new int[] { 10 }, new double[] { 10 }, new Animation(6684)), OAK_LOG(1521, 946, new int[] { 52, 54, 56, 9442 }, new int[] { 15, 20, 25, 24 }, new double[] { 0.375, 16.5, 25, 16 }, new Animation(6702)), STRUNG_OAK_SHORT_BOW(54, 1777, new int[] { 843 }, new int[] { 20 }, new double[] { 16.5 }, new Animation(6679)), STRUNG_OAK_LONG_BOW(56, 1777, new int[] { 845 }, new int[] { 25 }, new double[] { 25 }, new Animation(6685)), WILLOW_LOG(1519, 946, new int[] { 52, 60, 58, 9444 }, new int[] { 30, 35, 40, 39 }, new double[] { 0.4, 33.3, 41.5, 22 }, new Animation(6702)), STRUNG_WILLOW_SHORT_BOW(60, 1777, new int[] { 849 }, new int[] { 35 }, new double[] { 33.3 }, new Animation(6680)), STRUNG_WILLOW_LONG_BOW(58, 1777, new int[] { 847 }, new int[] { 40 }, new double[] { 41.5 }, new Animation(6686)), TEAK_LOG(6333, 946, new int[] { 9446 }, new int[] {46 }, new double[] { 27 }, new Animation(6702)), MAHOGANY_LOG (6332, 946, new int[] { 9450 }, new int[] { 61 }, new double[] { 41 }, new Animation(6702)), MAPLE_LOG(1517, 946, new int[] { 52, 64, 62, 9448 }, new int[] { 45, 50, 55, 54 }, new double[] { 0.416, 50, 58.3, 32 }, new Animation(6702)), STRUNG_MAPLE_SHORT_BOW(64, 1777, new int[] { 853 }, new int[] { 50 }, new double[] { 50 }, new Animation(6681)), STRUNG_MAPLE_LONG_BOW(62, 1777, new int[] { 851 }, new int[] { 55 }, new double[] { 58.3 }, new Animation(6687)), YEW_LOG(1515, 946, new int[] { 52, 68, 66, 9452 }, new int[] { 60, 65, 70, 69 }, new double[] { 0.428, 67.5, 75, 50 }, new Animation(6702)), STRUNG_YEW_SHORT_BOW(68, 1777, new int[] { 857 }, new int[] { 65 }, new double[] { 67.5 }, new Animation(6682)), STRUNG_YEW_LONG_BOW(66, 1777, new int[] { 855 }, new int[] { 70 }, new double[] { 75 }, new Animation(6688)), MAGIC_LOG(1513, 946, new int[] { 52, 72, 70 }, new int[] { 75, 80, 85 }, new double[] { 0.4375, 83.25, 91.5 }, new Animation(7211)), STRUNG_MAGIC_SHORT_BOW(72, 1777, new int[] { 861 }, new int[] { 80 }, new double[] { 83.25 }, new Animation(6683)), STRUNG_MAGIC_LONG_BOW(70, 1777, new int[] { 859 }, new int[] { 85 }, new double[] { 91.5 }, new Animation(6689)), /** * Crossbows */ U_BRONZE_CBOW(9440, 9420, new int[] { 9454 }, new int[] { 9 }, new double[] { 6 }, new Animation(-1)), U_IRON_CBOW(9444, 9423, new int[] { 9457 }, new int[] { 39 }, new double[] { 22 }, new Animation(-1)), U_BLURITE_CBOW(9442, 9422, new int[] { 9456 }, new int[] { 24 }, new double[] { 16 }, new Animation(-1)), U_STEEL_CBOW(9446, 9425, new int[] { 9459 }, new int[] { 46 }, new double[] { 27 }, new Animation(-1)), U_MITHRIL_CBOW(9448, 9427, new int[] { 9461 }, new int[] { 54 }, new double[] { 32 }, new Animation(-1)), U_ADAMANT_CBOW(9450, 9429, new int[] { 9463 }, new int[] { 61 }, new double[] { 41 }, new Animation(-1)), U_RUNITE_CBOW(9452, 9431, new int[] { 9465 }, new int[] { 69 }, new double[] { 50 }, new Animation(-1)), BRONZE_CBOW(9454, 9438, new int[] { 9174 }, new int[] { 9 }, new double[] { 6.0 }, new Animation(6671)), IRON_CBOW(9457, 9438, new int[] { 9177 }, new int[] { 39 }, new double[] { 22 }, new Animation(6673)), STEEL_CBOW(9459, 9438, new int[] { 9179 }, new int[] { 46 }, new double[] { 27 }, new Animation(6674)), BLURITE_CBOW(9456, 9438, new int[] { 9176 }, new int[] { 24 }, new double[] { 16 }, new Animation(6672)), MITHRIL_CBOW(9461, 9438, new int[] { 9181 }, new int[] { 52 }, new double[] { 32 }, new Animation(6675)), ADAMANT_CBOW(9463, 9438, new int[] { 9183 }, new int[] { 61 }, new double[] { 41 }, new Animation(6676)), RUNITE_CBOW(9465, 9438, new int[] { 9185 }, new int[] { 69 }, new double[] { 50 }, new Animation(6677)), MITH_GRAPPLE(9416, 9142, new int[] { 9418 }, new int[] { 59 }, new double[] { 11 }, new Animation(-1)), MITH_GRAPPLE_ROPE(9418, 954, new int[] { 9419 }, new int[] { 59 }, new double[] { 0 }, new Animation(-1)), /** * Arrows */ HEADLESS_ARROWS(52, 314, new int[] { 53 }, new int[] { 1 }, new double[] { 1 }, new Animation(-1)), BRONZE_ARROWS(39, 53, new int[] { 882 }, new int[] { 1 }, new double[] { 1.3 }, new Animation(-1)), IRON_ARROWS(40, 53, new int[] { 884 }, new int[] { 15 }, new double[] { 3.8 }, new Animation(-1)), STEEL_ARROWS(41, 53, new int[] { 886 }, new int[] { 30 }, new double[] { 6.3 }, new Animation(-1)), MITHRIL_ARROWS(42, 53, new int[] { 888 }, new int[] { 45 }, new double[] { 8.8 }, new Animation(-1)), ADAMANT_ARROWS(43, 53, new int[] { 890 }, new int[] { 60 }, new double[] { 11.3 }, new Animation(-1)), RUNITE_ARROWS(44, 53, new int[] { 892 }, new int[] { 75 }, new double[] { 13.8 }, new Animation(-1)), DRAGON_ARROWS(11237, 53, new int[] { 11212 }, new int[] { 90 }, new double[] { 16.3 }, new Animation(-1)), BROAD_BOLTS(13279, 314, new int[] { 13280 }, new int[] { 55 }, new double[] { 3 }, new Animation(-1)), BROAD_ARROW(13278, 53, new int[] { 4160 }, new int[] { 52 }, new double[] { 15 }, new Animation(-1)), DRAGONBANE_ARROW(21823, 53, new int[] { 21640 }, new int[] { 76 }, new double[] { 12.5 }, new Animation(-1)), ABYSSALBANE_ARROW(21838, 53, new int[] { 21655 }, new int[] { 76 }, new double[] { 12.5 }, new Animation(-1)), WALLASALKIBANE_ARROW(21828, 53, new int[] { 21645 }, new int[] { 76 }, new double[] { 12.5 }, new Animation(-1)), BASILISKBANE_ARROW(21833, 53, new int[] { 21650 }, new int[] { 76 }, new double[] { 12.5 }, new Animation(-1)), /** * Bolts */ BRONZE_BOLT(9375, 314, new int[] { 877 }, new int[] { 9 }, new double[] { 0.5 }, new Animation(-1)), IRON_BOLT(9377, 314, new int[] { 9140 }, new int[] { 39 }, new double[] { 1.5 }, new Animation(-1)), STEEL_BOLT(9378, 314, new int[] { 9141 }, new int[] { 46 }, new double[] { 3.5 }, new Animation(-1)), MITHRIL_BOLT(9379, 314, new int[] { 9142 }, new int[] { 54 }, new double[] { 5 }, new Animation(-1)), ADAMANT_BOLT(9380, 314, new int[] { 9143 }, new int[] { 61 }, new double[] { 7 }, new Animation(-1)), RUNITE_BOLT(9381, 314, new int[] { 9144 }, new int[] { 69 }, new double[] { 10 }, new Animation(-1)), DRAGONBANE_BOLT(21843, 314, new int[] { 21660 }, new int[] { 80 }, new double[] { 7 }, new Animation(-1)), ABYSSALBANE_BOLT(21858, 314, new int[] { 21675 }, new int[] { 80 }, new double[] { 7 }, new Animation(-1)), WALLASALKIBANE_BOLT(21853, 314, new int[] { 21665 }, new int[] { 80 }, new double[] { 7 }, new Animation(-1)), BASILISKBANE_BOLT(21848, 314, new int[] { 21670 }, new int[] { 80 }, new double[] { 7 }, new Animation(-1)), OPAL_BOLTS(45, 877, new int[] { 879 }, new int[] { 11 }, new double[] { 1.6 }, new Animation(-1)), BLURITE_BOLTS(9376, 314, new int[] { 9139 }, new int[] { 24 }, new double[] { 1 }, new Animation(-1)), JADE_BOLTS(9187, 9376, new int[] { 9335 }, new int[] { 26 }, new double[] { 2.4 }, new Animation(-1)), PEARL_BOLTS(46, 9140, new int[] { 880 }, new int[] { 41 }, new double[] { 3.2 }, new Animation(-1)), SILVER_BOLTS(9382, 314, new int[] { 9145 }, new int[] { 43 }, new double[] { 2.5 }, new Animation(-1)), RED_TOPAZ_BOLTS(9188, 9141, new int[] { 9336 }, new int[] { 48 }, new double[] { 3.9 }, new Animation(-1)), BARBED_BOLTS(47, 877, new int[] { 881 }, new int[] { 51 }, new double[] { 9.5 }, new Animation(-1)), SAPPHIRE_BOLTS(9189, 9142, new int[] { 9337 }, new int[] { 56 }, new double[] { 2.4 }, new Animation(-1)), EMERALD_BOLTS(9190, 9142, new int[] { 9338 }, new int[] { 58 }, new double[] { 5.5 }, new Animation(-1)), RUBY_BOLTS(9191, 9143, new int[] { 9339 }, new int[] { 63 }, new double[] { 6.3 }, new Animation(-1)), DIAMOND_BOLTS(9192, 9143, new int[] { 9340 }, new int[] { 65 }, new double[] { 7 }, new Animation(-1)), DRAGON_BOLTS(9193, 9144, new int[] { 9341 }, new int[] { 71 }, new double[] { 8.2 }, new Animation(-1)), ONYX_BOLTS(9194, 9144, new int[] { 9342 }, new int[] { 73 }, new double[] { 9.4 }, new Animation(-1)), BRONZE_DART(819, 314, new int[] { 806 }, new int[] { 1 }, new double[] { 0.8 }, new Animation(-1)), /** * Darts */ IRON_DART(820, 314, new int[] { 807 }, new int[] { 22 }, new double[] { 1 }, new Animation(-1)), STEEL_DART(821, 314, new int[] { 808 }, new int[] { 37 }, new double[] { 1.7 }, new Animation(-1)), MITHRIL_DART(822, 314, new int[] { 809 }, new int[] { 52 }, new double[] { 4 }, new Animation(-1)), ADAMANT_DART(823, 314, new int[] { 810 }, new int[] { 67 }, new double[] { 7.6 }, new Animation(-1)), RUNITE_DART(824, 314, new int[] { 811 }, new int[] { 81 }, new double[] { 12.2 }, new Animation(-1)), DRAGON_DART(11232, 314, new int[] { 11230 }, new int[] { 95 }, new double[] { 18.4 }, new Animation(-1)), BLISTERWOODS(21600, 946, new int[] { 21580, 21581, 21582 }, new int[] { 70, 70, 70 }, new double[] { 100, 10, 100 }, new Animation(-1)); private static final Map fletching = new HashMap<>(); public static Fletch forId(int id) { return fletching.get(id); } static { for (Fletch fletch : Fletch.values()) fletching.put(fletch.id, fletch); } private final int[] product; private final int[] level; private final int id; private final int selected; private final double[] xp; private final Animation anim; private Fletch(int id, int selected, int[] product, int[] level, double[] xp, Animation anim) { this.id = id; this.product = product; this.selected = selected; this.xp = xp; this.anim = anim; this.level = level; } public int getId() { return id; } public int getSelected() { return selected; } public int[] getProduct() { return product; } public int[] getLevel() { return level; } public double[] getXp() { return xp; } public Animation getAnim() { return anim; } } private final Fletch fletch; private final int option; private int ticks; public Fletching(Fletch fletch, int option, int ticks) { this.fletch = fletch; this.option = option; this.ticks = ticks; } @Override public boolean start(Player player) { if (option >= fletch.getProduct().length) return false; if ((fletch == Fletch.BROAD_ARROW || fletch == Fletch.BROAD_BOLTS) && !player.isBroadFletching()) { player.sendMessage(""You need to unlock the ability to fletch these from a slayer master.""); return false; } if (!process(player)) return false; player.sendMessage(""You attempt to create a "" + new Item(fletch.getProduct()[option]).getDefinitions().getName().replace(""(u)"", """") + ""..."", true); return true; } @Override public boolean process(Player player) { if ((ticks <= 0) || !player.getInventory().containsItem(fletch.getId(), 1) || !player.getInventory().containsItem(fletch.getSelected(), 1)) return false; if (player.getSkills().getLevel(Constants.FLETCHING) < fletch.getLevel()[option]) { player.simpleDialogue(""You need a level of "" + fletch.getLevel()[option] + "" to fletch this.""); return false; } return true; } public static boolean maxMakeQuantityTen(Fletch fletch) { return (fletch.getSelected() == 53 && fletch.getSelected() == 314) || ItemDefinitions.getDefs(fletch.getId()).getName().toLowerCase().contains(""dart"") || ItemDefinitions.getDefs(fletch.getProduct()[0]).getName().toLowerCase().contains(""bolt"") || ItemDefinitions.getDefs(fletch.getProduct()[0]).getName().toLowerCase().contains("" stake"") || ItemDefinitions.getDefs(fletch.getProduct()[0]).getName().toLowerCase().contains(""dart"") || ItemDefinitions.getDefs(fletch.getProduct()[0]).getName().toLowerCase().contains(""arrow""); } public static boolean maxMakeQuantityTen(Fletch fletch, int option) { return (fletch.getSelected() == 53 && fletch.getSelected() == 314) || ItemDefinitions.getDefs(fletch.getId()).getName().toLowerCase().contains(""dart"") || ItemDefinitions.getDefs(fletch.getProduct()[option]).getName().toLowerCase().contains(""bolt"") || ItemDefinitions.getDefs(fletch.getProduct()[0]).getName().toLowerCase().contains("" stake"") || ItemDefinitions.getDefs(fletch.getProduct()[option]).getName().toLowerCase().contains(""dart"") || ItemDefinitions.getDefs(fletch.getProduct()[option]).getName().toLowerCase().contains(""arrow""); } @Override public int processWithDelay(Player player) { ticks--; int amount = maxMakeQuantityTen(fletch, option) ? 15 : 1; if (amount > player.getInventory().getNumberOf(fletch.getId())) amount = player.getInventory().getNumberOf(fletch.getId()); if (amount > player.getInventory().getNumberOf(fletch.getSelected())) amount = player.getInventory().getNumberOf(fletch.getSelected()); if (fletch.getProduct()[option] == 52) amount = switch (fletch.getId()) { case 1511 -> 15; case 1521 -> 20; case 1519 -> 25; case 1517 -> 30; case 1515 -> 35; case 1513 -> 40; default -> 15; }; if (fletch.getProduct()[option] == 21581) amount = 10; if (!player.getInventory().containsItem(fletch.getId(), amount) && (fletch.getProduct()[option] != 52) && (fletch.getProduct()[option] != 21581)) { player.sendMessage(""You don't have enough of the supplies to make that many.""); return -1; } player.setNextAnimation(fletch.getAnim()); player.getInventory().deleteItem(fletch.getId(), fletch.getProduct()[option] == 52 || fletch.getProduct()[option] == 21581 ? 1 : amount); if (fletch.getSelected() != KNIFE && fletch.getSelected() != CHISLE) player.getInventory().deleteItem(fletch.getSelected(), amount); player.getInventory().addItem(fletch.getProduct()[option], amount); player.sendMessage(""You create a "" + new Item(fletch.getProduct()[option]).getDefinitions().getName().toLowerCase().replace("" (u)"", """") + ""."", true); player.getSkills().addXp(Constants.FLETCHING, fletch.getXp()[option] * amount); if (fletch.getSelected() == KNIFE) return 2; if (amount > 5) return 0; return 1; } @Override public void stop(final Player player) { setActionDelay(player, 3); } public static Fletch isFletching(Item first, Item second) { Fletch fletch = Fletch.forId(first.getId()); int selected; if (fletch != null) selected = second.getId(); else { fletch = Fletch.forId(second.getId()); selected = first.getId(); } return fletch != null && fletch.getSelected() == selected ? fletch : null; } }" "package com.rs.game.content.skills.fletching; public class FletchingD extends Conversation { public FletchingD(Player player, Fletch items) { super(player); boolean maxQuantityTen = Fletching.maxMakeQuantityTen(items) && items.getProduct()[0] != 52; String[] replaced = new String[items.getProduct().length]; for (int i = 0;i < items.getProduct().length;i++) replaced[i] = ItemDefinitions.getDefs(items.getProduct()[i]).name.replace("" (u)"", """"); Dialogue makeX = addNext(new MakeXStatement(maxQuantityTen ? MakeXType.MAKE_SET : MakeXType.MAKE, maxQuantityTen ? 10 : 28, ""Choose how many you wish to make,
then click on the item to begin."", items.getProduct(), maxQuantityTen ? null : replaced)); for (int i = 0;i < items.getProduct().length;i++) { final int option = i; makeX.addNext(() -> { int quantity = MakeXStatement.getQuantity(player); int invQuantity = player.getInventory().getItems().getNumberOf(items.getId()); if (quantity > invQuantity) quantity = invQuantity; player.getActionManager().setAction(new Fletching(items, option, quantity)); }); } create(); } }" "package com.rs.game.content.skills.herblore; @PluginEventHandler public class BobBarter { public static NPCClickHandler handleBobBarter = new NPCClickHandler(new Object[] { 6524 }, e -> { if (e.getOption().equalsIgnoreCase(""decant"")) decant(e.getPlayer()); else if (e.getOption().equalsIgnoreCase(""decant-x"")) { Dialogue decantChoices = new Dialogue(); decantChoices.addOption(""Decant to dose"", ""1 dose"", ""2 dose"", ""3 dose"", ""4 dose""); decantChoices.addSimple(""Bob decant's your potions into 1 doses"", () -> decant(e.getPlayer(), 1)); decantChoices.addSimple(""Bob decant's your potions into 2 doses"", () -> decant(e.getPlayer(), 2)); decantChoices.addSimple(""Bob decant's your potions into 3 doses"", () -> decant(e.getPlayer(), 3)); decantChoices.addSimple(""Bob decant's your potions into 4 doses"", () -> decant(e.getPlayer(), 4)); e.getPlayer().startConversation(decantChoices); } }); public static void decant(Player p) { decant(p, 4); } public static void decant(Player p, int dose) { ArrayList checkedPotions = new ArrayList<>(); HashMap> potionDoses = new HashMap<>(); Potion potion; for (Item i : p.getInventory().getItems().array()) { potion = null; if (i == null) continue; ItemDefinitions itemdefs = ItemDefinitions.getDefs(i.getId()); if (checkedPotions.contains(i.getId()) && !itemdefs.isNoted()) { p.getInventory().deleteItem(i); continue; } for (Potion potions : Potion.values()) if (potions != null && potions.isVial()) { int[] potIds = potions.getIds(); for (int potId : potIds) if (itemdefs.isNoted()) { if (potId == itemdefs.getCertId()) { potion = potions; checkedPotions.add(i.getId()); } } else if (potId == i.getId()) { potion = potions; checkedPotions.add(i.getId()); } } if (potion == null || !potion.isVial()) continue; String potionName = getNameWithoutDoses(i.getName()); int doses = p.getInventory().getNumberOf(i.getId()) * getDosage(i.getName()); //Logger.debug(""doses "" + doses); if (potionDoses.containsKey(potionName)) { ArrayList temp = potionDoses.get(potionName); doses += temp.getFirst(); } ArrayList qtyAndIds = new ArrayList<>(); qtyAndIds.add(doses); for (int potId : potion.getIds()) qtyAndIds.add(potId); potionDoses.put(potionName, qtyAndIds); p.getInventory().deleteItem(i); } if (potionDoses.equals(new HashMap<>()) || potionDoses.isEmpty()) p.sendMessage(""You don't have any potions to decant.""); else for (String name : potionDoses.keySet()) { ArrayList pot = potionDoses.get(name); int totalDoses = pot.getFirst(); int fullQty = totalDoses / dose; int partialDose = totalDoses % dose; // Logger.debug(""Making "" + dose + "" dose "" + name + "" potions.""); // Logger.debug(""Total doses available: "" + totalDoses + "", converting to "" + fullQty + "" potions with a remaining "" + partialDose + "" dose""); // // Logger.debug(""item id full: "" + ((int)(pot.get(pot.size()-dose))+1)); ItemDefinitions fullDef = ItemDefinitions.getDefs(((pot.get(pot.size()-dose)))); if (fullDef.name.contains(name) && fullQty > 0) p.getInventory().addItemDrop(fullDef.getCertId() == -1 ? fullDef.getId() : fullDef.getCertId(), fullQty); if (partialDose > 0) { //Logger.debug(""item id partial: "" + ((int)(pot.get(pot.size()-partialDose)))); ItemDefinitions partialDef = ItemDefinitions.getDefs((pot.get(pot.size()-partialDose))); if (partialDef.name.contains(name)) p.getInventory().addItemDrop(partialDef.getCertId() == -1 ? partialDef.getId() : partialDef.getCertId(), 1); } } } public static String getNameWithoutDoses(String itemName) { int end = itemName.indexOf(""("") - 1; if (end < 0) return """"; return itemName.substring(0, end); } public static int getDosage(String itemName) { int start = itemName.indexOf(""("") + 1; int end = start+1; return Integer.parseInt(itemName.substring(start, end)); } }" "package com.rs.game.content.skills.herblore; @PluginEventHandler public class CoconutCracking { public static final int HAMMER = 2347; public static final int COCONUT = 5974; public static final int OPEN_COCONUT = 5976; public static ItemOnItemHandler handle = new ItemOnItemHandler(HAMMER, COCONUT, e -> { e.getPlayer().getInventory().deleteItem(COCONUT, 1); e.getPlayer().getInventory().addItem(OPEN_COCONUT, 1); e.getPlayer().sendMessage(""You break the coconut open with the hammer.""); }); }" "package com.rs.game.content.skills.herblore; public enum CraftablePotion { GUAM_POTION_UNF(new Item(91, 1), 1, 1.0, new Item[] { new Item(227, 1), new Item(249, 1) }), MARRENTILL_POTION_UNF(new Item(93, 1), 5, 1.0, new Item[] { new Item(227, 1), new Item(251, 1) }), TARROMIN_POTION_UNF(new Item(95, 1), 12, 1.0, new Item[] { new Item(227, 1), new Item(253, 1) }), HARRALANDER_POTION_UNF(new Item(97, 1), 22, 1.0, new Item[] { new Item(227, 1), new Item(255, 1) }), RANARR_POTION_UNF(new Item(99, 1), 30, 1.0, new Item[] { new Item(227, 1), new Item(257, 1) }), IRIT_POTION_UNF(new Item(101, 1), 45, 1.0, new Item[] { new Item(227, 1), new Item(259, 1) }), AVANTOE_POTION_UNF(new Item(103, 1), 50, 1.0, new Item[] { new Item(227, 1), new Item(261, 1) }), KWUARM_POTION_UNF(new Item(105, 1), 55, 1.0, new Item[] { new Item(227, 1), new Item(263, 1) }), CADANTINE_POTION_UNF(new Item(107, 1), 66, 1.0, new Item[] { new Item(227, 1), new Item(265, 1) }), DWARF_WEED_POTION_UNF(new Item(109, 1), 72, 1.0, new Item[] { new Item(227, 1), new Item(267, 1) }), TORSTOL_POTION_UNF(new Item(111, 1), 78, 1.0, new Item[] { new Item(227, 1), new Item(269, 1) }), LANTADYME_POTION_UNF(new Item(2483, 1), 69, 1.0, new Item[] { new Item(227, 1), new Item(2481, 1) }), TOADFLAX_POTION_UNF(new Item(3002, 1), 34, 1.0, new Item[] { new Item(227, 1), new Item(2998, 1) }), SNAPDRAGON_POTION_UNF(new Item(3004, 1), 63, 1.0, new Item[] { new Item(227, 1), new Item(3000, 1) }), ROGUES_PURSE_POTION_UNF(new Item(4840, 1), 8, 1.0, new Item[] { new Item(227, 1), new Item(1534, 1) }), SPIRIT_WEED_POTION_UNF(new Item(12181, 1), 40, 1.0, new Item[] { new Item(227, 1), new Item(12172, 1) }), WERGALI_POTION_UNF(new Item(14856, 1), 42, 1.0, new Item[] { new Item(227, 1), new Item(14854, 1) }), FELLSTALK_POTION_UNF(new Item(21628, 1), 94, 1.0, new Item[] { new Item(227, 1), new Item(21624, 1) }), SAGEWORT_POTION_UNF(new Item(17538, 1), 3, 0.0, new Item[] { new Item(17492, 1), new Item(17512, 1) }), VALERIAN_POTION_UNF(new Item(17540, 1), 4, 0.0, new Item[] { new Item(17492, 1), new Item(17514, 1) }), ALOE_POTION_UNF(new Item(17542, 1), 8, 0.0, new Item[] { new Item(17492, 1), new Item(17516, 1) }), WORMWOOD_POTION_UNF(new Item(17544, 1), 34, 0.0, new Item[] { new Item(17492, 1), new Item(17518, 1) }), MAGEBANE_POTION_UNF(new Item(17546, 1), 37, 0.0, new Item[] { new Item(17492, 1), new Item(17520, 1) }), FEATHERFOIL_POTION_UNF(new Item(17548, 1), 41, 0.0, new Item[] { new Item(17492, 1), new Item(17522, 1) }), WINTERS_GRIP_POTION_UNF(new Item(17550, 1), 67, 0.0, new Item[] { new Item(17492, 1), new Item(17524, 1) }), LYCOPUS_POTION_UNF(new Item(17552, 1), 70, 0.0, new Item[] { new Item(17492, 1), new Item(17526, 1) }), BUCKTHORN_POTION_UNF(new Item(17554, 1), 74, 0.0, new Item[] { new Item(17492, 1), new Item(17528, 1) }), ERZILLE_POTION_UNF(new Item(19998, 1), 54, 1.0, new Item[] { new Item(19994, 1), new Item(19989, 1) }), UGUNE_POTION_UNF(new Item(19999, 1), 56, 1.0, new Item[] { new Item(19994, 1), new Item(19991, 1) }), ARGWAY_POTION_UNF(new Item(20000, 1), 57, 1.0, new Item[] { new Item(19994, 1), new Item(19990, 1) }), SHENGO_POTION_UNF(new Item(20001, 1), 58, 1.0, new Item[] { new Item(19994, 1), new Item(19992, 1) }), SAMADEN_POTION_UNF(new Item(20002, 1), 59, 1.0, new Item[] { new Item(19994, 1), new Item(19993, 1) }), ATTACK_POTION(new Item(121, 1), 1, 25.0, new Item[] { new Item(91, 1), new Item(221, 1) }), ANTIPOISON(new Item(175, 1), 5, 37.5, new Item[] { new Item(93, 1), new Item(235, 1) }), RELICYMS_BALM(new Item(4844, 1), 8, 40.0, new Item[] { new Item(4840, 1), new Item(1526, 1) }), STRENGTH_POTION(new Item(115, 1), 12, 50.0, new Item[] { new Item(95, 1), new Item(225, 1) }), SERUM_207(new Item(3410, 1), 15, 50.0, new Item[] { new Item(95, 1), new Item(592, 1) }), GUTHIX_REST(new Item(4419, 1), 18, 59.5, new Item[] { new Item(97, 1), new Item(251, 1) }), RESTORE_POTION(new Item(127, 1), 22, 62.0, new Item[] { new Item(97, 1), new Item(223, 1) }), ENERGY_POTION(new Item(3010, 1), 26, 67.0, new Item[] { new Item(97, 1), new Item(1975, 1) }), DEFENCE_POTION(new Item(133, 1), 30, 75.0, new Item[] { new Item(93, 1), new Item(948, 1) }), PRAYER_POTION(new Item(139, 1), 38, 87.0, new Item[] { new Item(99, 1), new Item(231, 1) }), SUPER_ATTACK(new Item(145, 1), 45, 100.0, new Item[] { new Item(101, 1), new Item(221, 1) }), FISHING_POTION(new Item(151, 1), 50, 112.0, new Item[] { new Item(103, 1), new Item(231, 1) }), SUPER_STRENGTH(new Item(157, 1), 55, 125.0, new Item[] { new Item(105, 1), new Item(225, 1) }), SUPER_DEFENCE(new Item(163, 1), 66, 150.0, new Item[] { new Item(107, 1), new Item(239, 1) }), SUPER_RANGING_POTION(new Item(169, 1), 72, 162.0, new Item[] { new Item(109, 1), new Item(245, 1) }), SUPER_ANTIPOISON(new Item(181, 1), 48, 106.0, new Item[] { new Item(101, 1), new Item(235, 1) }), ZAMORAK_BREW(new Item(189, 1), 78, 175.0, new Item[] { new Item(111, 1), new Item(247, 1) }), ANTIFIRE(new Item(2454, 1), 69, 157.0, new Item[] { new Item(2483, 1), new Item(241, 1) }), SUPER_ENERGY(new Item(3018, 1), 52, 117.0, new Item[] { new Item(103, 1), new Item(2970, 1) }), SUPER_RESTORE(new Item(3026, 1), 63, 142.0, new Item[] { new Item(3004, 1), new Item(223, 1) }), AGILITY_POTION(new Item(3034, 1), 34, 80.0, new Item[] { new Item(3002, 1), new Item(2152, 1) }), SUPER_MAGIC_POTION(new Item(3042, 1), 76, 172.0, new Item[] { new Item(2483, 1), new Item(3138, 1) }), SARADOMIN_BREW(new Item(6687, 1), 81, 180.0, new Item[] { new Item(3002, 1), new Item(6693, 1) }), MAGIC_ESSENCE_UNF(new Item(9019, 1), 57, 1.0, new Item[] { new Item(227, 1), new Item(9017, 1) }), MAGIC_ESSENCE(new Item(9022, 1), 57, 130.0, new Item[] { new Item(9019, 1), new Item(9018, 1) }), COMBAT_POTION(new Item(9741, 1), 36, 84.0, new Item[] { new Item(97, 1), new Item(9736, 1) }), HUNTER_POTION(new Item(10000, 1), 53, 120.0, new Item[] { new Item(103, 1), new Item(10111, 1) }), MIXTURE__STEP_1(new Item(10911, 1), 65, 47.0, new Item[] { new Item(3026, 1), new Item(235, 1) }), MIXTURE__STEP_2(new Item(10919, 1), 65, 52.0, new Item[] { new Item(1526, 1), new Item(10911, 1) }), SANFEW_SERUM(new Item(10927, 1), 65, 60.0, new Item[] { new Item(10937, 1), new Item(10919, 1) }), SUMMONING_POTION(new Item(12142, 1), 40, 92.0, new Item[] { new Item(12181, 1), new Item(12109, 1) }), SUPER_FISHING_EXPLOSIVE(new Item(12633, 1), 31, 55.0, new Item[] { new Item(91, 1), new Item(12630, 1) }), CRAFTING_POTION(new Item(14840, 1), 42, 95.0, new Item[] { new Item(14856, 1), new Item(5004, 1) }), FLETCHING_POTION(new Item(14848, 1), 58, 132.0, new Item[] { new Item(14856, 1), new Item(11525, 1) }), RESTORE_SPECIAL(new Item(15301, 1), 84, 200.0, new Item[] { new Item(3018, 1), new Item(5972, 1) }), SUPER_ANTIFIRE(new Item(15305, 1), 85, 210.0, new Item[] { new Item(2454, 1), new Item(4621, 1) }), EXTREME_ATTACK(new Item(15309, 1), 88, 220.0, new Item[] { new Item(145, 1), new Item(261, 1) }), EXTREME_STRENGTH(new Item(15313, 1), 89, 230.0, new Item[] { new Item(157, 1), new Item(267, 1) }), EXTREME_DEFENCE(new Item(15317, 1), 90, 240.0, new Item[] { new Item(163, 1), new Item(2481, 1) }), EXTREME_MAGIC(new Item(15321, 1), 91, 250.0, new Item[] { new Item(3042, 1), new Item(9594, 1) }), EXTREME_RANGING(new Item(15325, 1), 92, 260.0, new Item[] { new Item(169, 1), new Item(12539, 5) }), SUPER_PRAYER(new Item(15329, 1), 94, 270.0, new Item[] { new Item(139, 1), new Item(6810, 1) }), OVERLOAD(new Item(15333, 1), 96, 1000.0, new Item[] { new Item(269, 1), new Item(15309, 1), new Item(15313, 1), new Item(15317, 1), new Item(15321, 1), new Item(15325, 1)}), PRAYER_RENEWAL(new Item(21632, 1), 94, 190.0, new Item[] { new Item(21628, 1), new Item(21622, 1) }), COCONUT_MILK(new Item(5935, 1), 1, 1.0, new Item[] { new Item(229, 1), new Item(5976, 1) }), WEAPON_POISON(new Item(187, 1), 60, 137.5, new Item[] { new Item(105, 1), new Item(241, 1) }), WEAPON_POISON_P_UNF(new Item(5936, 1), 73, 1.0, new Item[] { new Item(5935, 1), new Item(6016, 1) }), WEAPON_POISON_P(new Item(5937, 1), 73, 165.0, new Item[] { new Item(5936, 1), new Item(223, 1) }), WEAPON_POISON_PP_UNF(new Item(5939, 1), 82, 1.0, new Item[] { new Item(5935, 1), new Item(2398, 1) }), WEAPON_POISON_PP(new Item(5940, 1), 82, 190.0, new Item[] { new Item(5939, 1), new Item(6018, 1) }), ANTIPOISON_P_UNF(new Item(5942, 1), 68, 1.0, new Item[] { new Item(5935, 1), new Item(2998, 1) }), ANTIPOISON_P(new Item(5943, 1), 68, 155.0, new Item[] { new Item(5942, 1), new Item(6049, 1) }), ANTIPOISON_PP_UNF(new Item(5951, 1), 79, 1.0, new Item[] { new Item(5935, 1), new Item(259, 1) }), ANTIPOISON_PP(new Item(5952, 1), 79, 177.0, new Item[] { new Item(5951, 1), new Item(6051, 1) }), GUTHIX_BALANCE_UNF(new Item(7652, 1), 22, 25.0, new Item[] { new Item(2430, 1), new Item(1550, 1) }), GUTHIX_BALANCE_UNF2(new Item(7654, 1), 22, 25.0, new Item[] { new Item(127, 1), new Item(1550, 1) }), GUTHIX_BALANCE_UNF3(new Item(7656, 1), 22, 25.0, new Item[] { new Item(129, 1), new Item(1550, 1) }), GUTHIX_BALANCE_UNF4(new Item(7658, 1), 22, 25.0, new Item[] { new Item(131, 1), new Item(1550, 1) }), GUTHIX_BALANCE_4(new Item(7660, 1), 22, 25.0, new Item[] { new Item(7652, 1), new Item(7650, 1) }), GUTHIX_BALANCE_3(new Item(7662, 1), 22, 25.0, new Item[] { new Item(7654, 1), new Item(7650, 1) }), GUTHIX_BALANCE_2(new Item(7664, 1), 22, 25.0, new Item[] { new Item(7656, 1), new Item(7650, 1) }), GUTHIX_BALANCE_1(new Item(7666, 1), 22, 25.0, new Item[] { new Item(7658, 1), new Item(7650, 1) }), GUAM_TAR(new Item(10142, 15), 19, 30.0, new Item[] { new Item(1939, 15), new Item(249, 1) }), MARRENTILL_TAR(new Item(10143, 15), 31, 42.0, new Item[] { new Item(1939, 15), new Item(251, 1) }), TARROMIN_TAR(new Item(10144, 15), 39, 55.0, new Item[] { new Item(1939, 15), new Item(253, 1) }), HARRALANDER_TAR(new Item(10145, 15), 44, 72.0, new Item[] { new Item(1939, 15), new Item(255, 1) }), SNAKEWEED_MIXTURE(new Item(737, 1), 3, 1.0, new Item[] { new Item(227, 1), new Item(1526, 1) }), ARDRIGAL_MIXTURE(new Item(738, 1), 3, 1.0, new Item[] { new Item(227, 1), new Item(1528, 1) }), BRAVERY_POTION(new Item(739, 1), 1, 0.0, new Item[] { new Item(738, 1), new Item(1526, 1) }), BLAMISH_OIL(new Item(1582, 1), 25, 80.0, new Item[] { new Item(97, 1), new Item(1581, 1) }), ANCHOVY_OIL(new Item(11264, 1), 3, 0.0, new Item[] { new Item(229, 1), new Item(11266, 8) }), IMP_REPLLENT_MARIGOLDS(new Item(11262, 1), 3, 5.0, new Item[] { new Item(11264, 1), new Item(6010, 1) }), IMP_REPLLENT_ROSEMARY(new Item(11262, 1), 3, 5.0, new Item[] { new Item(11264, 1), new Item(6014, 1) }), IMP_REPLLENT_NASTURTIUMS(new Item(11262, 1), 3, 5.0, new Item[] { new Item(11264, 1), new Item(6012, 1) }), IMP_REPLLENT_PASTEL_FLOWERS(new Item(11262, 1), 3, 5.0, new Item[] { new Item(11264, 1), new Item(2460, 1) }), IMP_REPLLENT_RED_FLOWERS(new Item(11262, 1), 3, 5.0, new Item[] { new Item(11264, 1), new Item(2462, 1) }), IMP_REPLLENT_BLUE_FLOWERS(new Item(11262, 1), 3, 5.0, new Item[] { new Item(11264, 1), new Item(2464, 1) }), IMP_REPLLENT_YELLOW_FLOWERS(new Item(11262, 1), 3, 5.0, new Item[] { new Item(11264, 1), new Item(2466, 1) }), IMP_REPLLENT_PURPLE_FLOWERS(new Item(11262, 1), 3, 5.0, new Item[] { new Item(11264, 1), new Item(2468, 1) }), IMP_REPLLENT_ORANGE_FLOWERS(new Item(11262, 1), 3, 5.0, new Item[] { new Item(11264, 1), new Item(2470, 1) }), IMP_REPLLENT_RGB_FLOWERS(new Item(11262, 1), 3, 5.0, new Item[] { new Item(11264, 1), new Item(2472, 1) }), IMP_REPLLENT_WHITE_FLOWERS(new Item(11262, 1), 3, 5.0, new Item[] { new Item(11264, 1), new Item(2474, 1) }), IMP_REPLLENT_BLACK_FLOWERS(new Item(11262, 1), 3, 5.0, new Item[] { new Item(11264, 1), new Item(2476, 1) }), JUJU_MINING_POTION(new Item(20004, 1), 74, 168.0, new Item[] { new Item(20002, 1), new Item(19973, 1) }), JUJU_COOKING_POTION(new Item(20008, 1), 67, 152.0, new Item[] { new Item(20001, 1), new Item(19975, 1) }), JUJU_FARMING_POTION(new Item(20012, 1), 64, 146.0, new Item[] { new Item(19999, 1), new Item(19980, 1) }), JUJU_WOODCUTTING_POTION(new Item(20016, 1), 71, 160.0, new Item[] { new Item(20002, 1), new Item(19972, 1) }), JUJU_FISHING_POTION(new Item(20020, 1), 70, 158.0, new Item[] { new Item(20001, 1), new Item(19976, 1) }), JUJU_HUNTER_POTION(new Item(20024, 1), 54, 123.0, new Item[] { new Item(19998, 1), new Item(19979, 1) }), SCENTLESS_POTION(new Item(20028, 1), 59, 135.0, new Item[] { new Item(20000, 1), new Item(19977, 1) }), SARADOMINS_BLESSING(new Item(20032, 1), 75, 179.0, new Item[] { new Item(20002, 1), new Item(19981, 1) }), GUTHIXS_GIFT(new Item(20036, 1), 75, 179.0, new Item[] { new Item(20002, 1), new Item(19982, 1) }), ZAMORAKS_FAVOUR(new Item(20040, 1), 75, 179.0, new Item[] { new Item(20002, 1), new Item(19983, 1) }), ATTACK_MIX_2(new Item(11429, 1), 4, 8.0, new Item[] { new Item(123, 1), new Item(11326, 1) }), ANTIPOISON_MIX_2(new Item(11433, 1), 6, 1.0, new Item[] { new Item(177, 1), new Item(11326, 1) }), RELICYMS_MIX_2(new Item(11437, 1), 9, 14.0, new Item[] { new Item(4846, 1), new Item(11326, 1) }), STRENGTH_MIX_2(new Item(11443, 1), 14, 17.0, new Item[] { new Item(117, 1), new Item(11326, 1) }), COMBAT_MIX_2(new Item(11445, 1), 40, 28.0, new Item[] { new Item(9743, 1), new Item(11326, 1) }), RESTORE_MIX_2(new Item(11449, 1), 24, 21.0, new Item[] { new Item(129, 1), new Item(11326, 1) }), ENERGY_MIX_2(new Item(11453, 1), 29, 23.0, new Item[] { new Item(3012, 1), new Item(11326, 1) }), DEFENCE_MIX_2(new Item(11457, 1), 33, 25.0, new Item[] { new Item(135, 1), new Item(11326, 1) }), AGILITY_MIX_2(new Item(11461, 1), 37, 27.0, new Item[] { new Item(3036, 1), new Item(11326, 1) }), PRAYER_MIX_2(new Item(11465, 1), 42, 29.0, new Item[] { new Item(141, 1), new Item(11326, 1) }), SUPER_ATTACK_MIX_2(new Item(11469, 1), 47, 33.0, new Item[] { new Item(147, 1), new Item(11326, 1) }), ANTIP_SUPERMIX_2(new Item(11473, 1), 51, 35.0, new Item[] { new Item(183, 1), new Item(11326, 1) }), FISHING_MIX_2(new Item(11477, 1), 53, 38.0, new Item[] { new Item(153, 1), new Item(11326, 1) }), SUPER_ENERGY_MIX_2(new Item(11481, 1), 56, 39.0, new Item[] { new Item(3020, 1), new Item(11326, 1) }), SUPER_STRENGTH_MIX_2(new Item(11485, 1), 59, 42.0, new Item[] { new Item(159, 1), new Item(11326, 1) }), MAGIC_ESSENCE_MIX_2(new Item(11489, 1), 61, 43.0, new Item[] { new Item(9023, 1), new Item(11326, 1) }), SUPER_RESTORE_MIX_2(new Item(11493, 1), 67, 48.0, new Item[] { new Item(3028, 1), new Item(11326, 1) }), SUPER_DEFENCE_MIX_2(new Item(11497, 1), 71, 50.0, new Item[] { new Item(165, 1), new Item(11326, 1) }), ANTIDOTE_MIX_2(new Item(11501, 1), 74, 52.0, new Item[] { new Item(5947, 1), new Item(11326, 1) }), ANTIFIRE_MIX_2(new Item(11505, 1), 75, 53.0, new Item[] { new Item(2456, 1), new Item(11326, 1) }), SUPER_RANGING_MIX_2(new Item(11509, 1), 80, 54.0, new Item[] { new Item(171, 1), new Item(11326, 1) }), SUPER_MAGIC_MIX_2(new Item(11513, 1), 83, 57.0, new Item[] { new Item(3044, 1), new Item(11326, 1) }), HUNTING_MIX_2(new Item(11517, 1), 58, 40.0, new Item[] { new Item(10002, 1), new Item(11326, 1) }), ZAMORAK_MIX_2(new Item(11521, 1), 85, 58.0, new Item[] { new Item(191, 1), new Item(11326, 1) }), GOBLIN_POTION(new Item(11810, 1), 37, 85.0, new Item[] { new Item(3002, 1), new Item(11807, 1) }), WEAK_MAGIC_POTION(new Item(17556, 1), 3, 21.0, new Item[] { new Item(17538, 1), new Item(17530, 1) }), WEAK_RANGED_POTION(new Item(17558, 1), 5, 34.0, new Item[] { new Item(17540, 1), new Item(17530, 1) }), WEAK_MELEE_POTION(new Item(17560, 1), 7, 37.0, new Item[] { new Item(17540, 1), new Item(17532, 1) }), WEAK_DEFENCE_POTION(new Item(17562, 1), 9, 41.0, new Item[] { new Item(17542, 1), new Item(17530, 1) }), WEAK_STAT_RESTORE_POTION(new Item(17564, 1), 12, 47.0, new Item[] { new Item(17542, 1), new Item(17534, 1) }), WEAK_CURE_POTION(new Item(17568, 1), 15, 53.0, new Item[] { new Item(17542, 1), new Item(17536, 1) }), WEAK_REJUVENATION_POTION(new Item(17570, 1), 18, 57.0, new Item[] { new Item(17542, 1), new Item(17532, 1) }), WEAK_WEAPON_POISON(new Item(17572, 1), 21, 61.0, new Item[] { new Item(17538, 1), new Item(17536, 1) }), WEAK_GATHERERS_POTION(new Item(17574, 1), 24, 65.0, new Item[] { new Item(17538, 1), new Item(17534, 1) }), WEAK_ARTISANS_POTION(new Item(17576, 1), 27, 68.0, new Item[] { new Item(17540, 1), new Item(17534, 1) }), WEAK_NATURALISTS_POTION(new Item(17578, 1), 30, 72.0, new Item[] { new Item(17538, 1), new Item(17532, 1) }), WEAK_SURVIVALISTS_POTION(new Item(17580, 1), 33, 75.0, new Item[] { new Item(17540, 1), new Item(17536, 1) }), MAGIC_POTION(new Item(17582, 1), 36, 79.0, new Item[] { new Item(17544, 1), new Item(17530, 1) }), RANGED_POTION(new Item(17584, 1), 38, 83.0, new Item[] { new Item(17546, 1), new Item(17530, 1) }), MELEE_POTION(new Item(17586, 1), 40, 86.0, new Item[] { new Item(17546, 1), new Item(17532, 1) }), DEFENCE_POTION_D(new Item(17588, 1), 42, 89.0, new Item[] { new Item(17548, 1), new Item(17530, 1) }), STAT_RESTORE_POTION(new Item(17590, 1), 45, 93.0, new Item[] { new Item(17548, 1), new Item(17534, 1) }), CURE_POTION(new Item(17592, 1), 48, 98.0, new Item[] { new Item(17548, 1), new Item(17536, 1) }), REJUVENATION_POTION(new Item(17594, 1), 51, 105.0, new Item[] { new Item(17548, 1), new Item(17532, 1) }), WEAPON_POISON_D(new Item(17596, 1), 54, 114.0, new Item[] { new Item(17544, 1), new Item(17536, 1) }), GATHERERS_POTION(new Item(17598, 1), 57, 123.0, new Item[] { new Item(17544, 1), new Item(17534, 1) }), ARTISANS_POTION(new Item(17600, 1), 60, 131.0, new Item[] { new Item(17546, 1), new Item(17534, 1) }), NATURALISTS_POTION(new Item(17602, 1), 63, 139.0, new Item[] { new Item(17544, 1), new Item(17532, 1) }), SURVIVALISTS_POTION(new Item(17604, 1), 66, 147.0, new Item[] { new Item(17546, 1), new Item(17536, 1) }), STRONG_MAGIC_POTION(new Item(17606, 1), 69, 155.0, new Item[] { new Item(17550, 1), new Item(17530, 1) }), STRONG_RANGED_POTION(new Item(17608, 1), 71, 160.0, new Item[] { new Item(17552, 1), new Item(17530, 1) }), STRONG_MELEE_POTION(new Item(17610, 1), 73, 164.0, new Item[] { new Item(17552, 1), new Item(17532, 1) }), STRONG_DEFENCE_POTION(new Item(17612, 1), 75, 170.0, new Item[] { new Item(17554, 1), new Item(17530, 1) }), STRONG_STAT_RESTORE_POTION(new Item(17614, 1), 78, 173.0, new Item[] { new Item(17554, 1), new Item(17534, 1) }), STRONG_CURE_POTION(new Item(17616, 1), 81, 178.0, new Item[] { new Item(17554, 1), new Item(17536, 1) }), STRONG_REJUVENATION_POTION(new Item(17618, 1), 84, 189.0, new Item[] { new Item(17554, 1), new Item(17532, 1) }), STRONG_WEAPON_POISON(new Item(17620, 1), 87, 205.0, new Item[] { new Item(17550, 1), new Item(17536, 1) }), STRONG_GATHERERS_POTION(new Item(17622, 1), 90, 234.0, new Item[] { new Item(17550, 1), new Item(17534, 1) }), STRONG_ARTISANS_POTION(new Item(17624, 1), 93, 253.0, new Item[] { new Item(17552, 1), new Item(17534, 1) }), STRONG_NATURALISTS_POTION(new Item(17626, 1), 96, 279.0, new Item[] { new Item(17550, 1), new Item(17532, 1) }), STRONG_SURVIVALISTS_POTION(new Item(17628, 1), 99, 315.0, new Item[] { new Item(17552, 1), new Item(17536, 1) }), NETTLE_WATER(new Item(4237, 1), 1, 1.0, new Item[] { new Item(1921, 1), new Item(4241, 1) }); private final Item product; private final int req; private final double xp; private final Item primary; private final Item[] secondaries; public static Map MAP = new HashMap<>(); static { for (CraftablePotion p : CraftablePotion.values()) for (Item item : p.getSecondaries()) { MAP.put((p.getPrimary().getId() << 16) + item.getId(), p); MAP.put((item.getId() << 16) + p.getPrimary().getId(), p); } } public static CraftablePotion forCombo(int itemId, int itemId2) { return MAP.get((itemId << 16) + itemId2); } private CraftablePotion(Item product, int req, double xp, Item[] materials) { this.product = product; this.req = req; this.xp = xp; primary = materials[0]; secondaries = new Item[materials.length-1]; System.arraycopy(materials, 1, secondaries, 0, materials.length - 1); } public Item getProduct() { return product; } public int getReq() { return req; } public double getXp() { return xp; } public Item getPrimary() { return primary; } public Item[] getSecondaries() { return secondaries; } }" "package com.rs.game.content.skills.herblore; @PluginEventHandler public class FlaskPotions { static final int EMPTY_FLASK= 23191; static final int EMPTY_POTION=229; static final int[] POTIONS = new int[Flasks.values().length * 4]; static { initializePotions(); } /** * In order of the Herblore skill menu */ private enum Flasks {//[FLASK], [DOSES {1,2,3,4}] SERUM207(23549 , new int[] {3414, 3412, 3410, 3408}), SERUM208(23603 , new int[] { 3419, 3418, 3417, 3416}), ATTACK(23195 , new int[] { 125, 123, 121, 2428}), ANTI_POISON(23315 , new int[] { 179, 177, 175, 2446}), RELICYM_BALM(23537 , new int[] { 4848, 4846, 4844, 4842}), STRENGTH(23207 , new int[] { 119, 117, 115, 113}), RESTORE(23219 , new int[] { 131, 129, 127, 2430}), GUTHIX_BALANCE(23555 , new int[] { 7666, 7664, 7662, 7660}), ENERGY(23375 , new int[] { 3014, 3012, 3010, 3008}), DEFENCE(23231 , new int[] { 137, 135, 133, 2432}), AGILITY(23411 , new int[] { 3038, 3036, 3034, 3032 }), COMBAT(23447 , new int[] { 9745, 9743, 9741, 9739}), PRAYER(23243 , new int[] { 143, 141, 139, 2434}), SUMMONING(23621 , new int[] { 12146, 12144, 12142, 12140}), CRAFTING(23459 , new int[] { 14844, 14842, 14840, 14838}), SUPER_ATTACK(23255 , new int[] { 149, 147, 145, 2436}), SUPER_ANTI_POISON(23327 , new int[] { 185, 183, 181, 2448}), FISHING(23267 , new int[] { 155, 153, 151, 2438}), SUPER_ENERGY(23387 , new int[] { 3022, 3020, 3018, 3016}), HUNTER(23435 , new int[] { 10004, 10002, 10000, 9998}), JUJU_HUNTER(23161 , new int[] { 20026, 20025, 20024, 20023}), SUPER_STRENGTH(23279 , new int[] { 161, 159, 157, 2440}), MAGIC_ESSENCE(23633 , new int[] { 9024, 9023, 9022, 9021}), FLETCHING(23471 , new int[] { 14852, 14850, 14848, 14846}), JUJU_SCENTLESS(23167 , new int[] { 20030, 20029, 20028, 20027}), SUPER_RESTORE(23399 , new int[] { 3030, 3028, 3026, 3024}), JUJU_FARMING(23143 , new int[] { 20014, 20013, 20012, 20011}), SANFEW_SERUM(23567 , new int[] { 10931, 10929, 10927, 10925}), SUPER_DEFENCE(23291 , new int[] { 167, 165, 163, 2442}), JUJU_COOKING(23137 , new int[] { 20010, 20009, 20008, 20007}), ANTI_POISON_PLUS(23579 , new int[] { 5949, 5947, 5945, 5943}), ANTI_FIRE(23363 , new int[] { 2458, 2456, 2454, 2452}), JUJU_FISHING(23155 , new int[] { 20022, 20021, 20020, 20019}), JUJU_WOOD_CUTTING(23149 , new int[] { 20018, 20017, 20016, 20015}), RANGING(23303 , new int[] { 173, 171, 169, 2444}), JUJU_MINING(23131 , new int[] { 20006, 20005, 20004, 20003}), SARADOMIN_BLESSING(23173 , new int[] { 20034, 20033, 20032, 20031}), GUTHIX_GIFT(23179 , new int[] { 20038, 20037, 20036, 20035}), ZAMORAK_FAVOUR(23185 , new int[] { 20042, 20041, 20040, 20039}), MAGIC(23423 , new int[] { 3046, 3044, 3042, 3040}), ZAMORAK_BREW(23339, new int[] { 193, 191, 189, 2450}), ANTI_POISON_PLUS_PLUS(3591 , new int[] { 5958, 5956, 5954, 5952}), SARA_BREW(23351, new int[] {6691, 6689, 6687, 6685}), RECOVERY_SPECIAL(23483 , new int[] { 15303, 15302, 15301, 15300}), SUPER_ANTI_FIRE(23489 , new int[] { 15307, 15306, 15305, 15304}), EXTREME_ATTACK(23495 , new int[] { 15311, 15310, 15309, 15308}), EXTREME_STRENGTH(23501 , new int[] { 15315, 15314, 15313, 15312}), EXTREME_DEFENCE(23507 , new int[] { 15319, 15318, 15317, 15316}), EXTREME_MAGIC(23513 , new int[] { 15323, 15322, 15321, 15320}), EXTREME_RANGING(23519 , new int[] { 15327, 15326, 15325, 15324}), SUPER_PRAYER(23525 , new int[] { 15331, 15330, 15329, 15328}), PRAYER_RENEWAL(23609 , new int[] { 21636, 21634, 21632, 21630}), OVERLOAD(23531 , new int[] { 15335, 15334, 15333, 15332}); // ( , new int[] {}), public final int flaskId; public final int[] potions; Flasks(final int flaskId, final int[] potions) { this.flaskId = flaskId; this.potions = potions; } public int[] getPotions() { return potions; } public static Flasks getFlaskEnum(int potionId) { for (Flasks flask : Flasks.values()) for (int itemId : flask.potions) if (itemId == potionId) return flask; return null; } public static int getFlaskIdFromPotionId(int potionId) { return getFlaskEnum(potionId).flaskId; } public static int getDose(int potion) { for (Flasks flask : Flasks.values()) for (int i = 0; i < flask.potions.length; i++) if (flask.potions[i] == potion) return i + 1; return -1; } } static void initializePotions() { int potionIndex = 0; for (Flasks flask : Flasks.values()) for (int i = 0; i < 4; i++) POTIONS[potionIndex++] = flask.getPotions()[i]; } private static void decantIntoFlask(ItemOnItemEvent e, int dosesLeft) { Player p = e.getPlayer(); int usedOnFlask = e.getUsedWith(EMPTY_FLASK).getId(); if (dosesLeft == 6) { dosesLeft = dosesLeft -Flasks.getDose(usedOnFlask); p.getInventory().deleteItem(e.getUsedWith(EMPTY_FLASK)); } for (int potionId : Flasks.getFlaskEnum(usedOnFlask).getPotions()) if (p.getInventory().containsItem(potionId)) { if (dosesLeft -Flasks.getDose(potionId) < 0) { int dosesOver =Flasks.getDose(potionId) - dosesLeft; int potionIdOver =Flasks.getFlaskEnum(potionId).getPotions()[dosesOver - 1]; p.getInventory().deleteItem(potionId, 1); p.getInventory().addItemDrop(potionIdOver, 1); p.getInventory().replace(e.getUsedWith(usedOnFlask), new Item(Flasks.getFlaskIdFromPotionId(potionId), 1)); break; } if (dosesLeft -Flasks.getDose(potionId) == 0) { // base case p.getInventory().deleteItem(potionId, 1); p.getInventory().addItem(EMPTY_POTION, 1); p.getInventory().addItem(EMPTY_POTION, 1); p.getInventory().replace(e.getUsedWith(usedOnFlask), new Item(Flasks.getFlaskIdFromPotionId(potionId), 1)); return; } if (dosesLeft -Flasks.getDose(potionId) > 0) { dosesLeft = dosesLeft -Flasks.getDose(potionId); p.getInventory().deleteItem(potionId, 1); p.getInventory().addItem(EMPTY_POTION, 1); decantIntoFlask(e, dosesLeft); break; } } } private static boolean inventoryHasEnoughPotion(ItemOnItemEvent e) { int doses = 6; int usedOnFlask = e.getUsedWith(EMPTY_FLASK).getId(); for (int potionId : Flasks.getFlaskEnum(usedOnFlask).getPotions()) if (e.getPlayer().getInventory().containsItem(potionId)) { int potionCount =e.getPlayer().getInventory().getAmountOf(potionId); int potionDose =Flasks.getDose(potionId); doses = doses - potionCount*potionDose; if (doses<=0) return true; } return false; } public static ItemOnItemHandler handlePotionOnFlask = new ItemOnItemHandler(EMPTY_FLASK, POTIONS, e -> { if (inventoryHasEnoughPotion(e)) { decantIntoFlask(e, 6); e.getPlayer().getPackets().sendGameMessage(""You fill the flask""); } }); }" "package com.rs.game.content.skills.herblore; public class HerbCleaning { public static enum Herbs { GUAM(199, 2.5, 1, 249), MARRENTILL(201, 3.8, 5, 251), TARROMIN(203, 5, 11, 253), HARRALANDER(205, 6.3, 20, 255), RANARR(207, 7.5, 25, 257), TOADFLAX(3049, 8, 30, 2998), SPIRIT_WEED(12174, 7.8, 35, 12172), IRIT(209, 8.8, 40, 259), WERGALI(14836, 9.5, 41, 14854), AVANTOE(211, 10, 48, 261), KWUARM(213, 11.3, 54, 263), SNAPDRAGON(3051, 11.8, 59, 3000), CADANTINE(215, 12.5, 65, 265), LANTADYME(2485, 13.1, 67, 2481), DWARF_WEED(217, 13.8, 70, 267), TORSTOL(219, 15, 75, 269), FELLSTALK(21626, 16.8, 91, 21624), SAGEWORT(17494, 2.1, 3, 17512), VALERIAN(17496, 3.2, 4, 17514), ALOE(17498, 4, 8, 17516), WORMWOOD_LEAF(17500, 7.2, 34, 17518), MAGEBANE(17502, 7.7, 37, 17520), FEATHERFOIL(17504, 8.6, 41, 17522), GRIMY_WINTERS_GRIP(17506, 12.7, 67, 17524), LYCOPUS(17508, 13.1, 70, 17526), BUCKTHORN(17510, 13.8, 74, 17528), ERZILLE(19984, 10, 54, 19989), ARGWAY(19985, 11.6, 57, 19990), UGUNE(19986, 11.5, 56, 19991), SHENGO(19987, 11.7, 58, 19992), SAMADEN(19988, 11.7, 59, 19993), SNAKE_WEED(1525, 2.5, 3, 1526), ARDRIGAL(1527, 2.5, 3, 1528), SITO_FOIL(1529, 2.5, 3, 1530), VOLENCIA_MOSS(1531, 2.5, 3, 1532), ROGUES_PURSE(1533, 2.5, 3, 1534), ; private final int herbId; private final int level; private final int cleanId; private final double xp; Herbs(int herbId, double xp, int level, int cleanId) { this.herbId = herbId; this.xp = xp; this.level = level; this.cleanId = cleanId; } public int getHerbId() { return herbId; } public double getExperience() { return xp; } public int getLevel() { return level; } public int getCleanId() { return cleanId; } } public static Herbs getHerb(int id) { for (final Herbs herb : Herbs.values()) if (herb.getHerbId() == id) return herb; return null; } public static boolean clean(final Player player, Item item, final int slotId) { final Herbs herb = getHerb(item.getId()); if (herb == null) return false; if (player.getSkills().getLevel(Constants.HERBLORE) < herb.getLevel()) { player.sendMessage(""You do not have the required level to clean this."", true); return true; } WorldTasks.schedule(new Task() { @Override public void run() { Item i = player.getInventory().getItem(slotId); if ((i == null) || (i.getId() != herb.getHerbId())) return; i.setId(herb.getCleanId()); player.getInventory().refresh(slotId); player.soundEffect(5153, false); player.getSkills().addXp(Constants.HERBLORE, herb.getExperience()); player.sendMessage(""You clean the herb."", true); player.incrementCount(item.getName() + "" cleaned""); } }); return true; } public static List getHerbs() { List herbs = new LinkedList<>(); for (Herbs herb : Herbs.values()) if (herb.ordinal() < 17) herbs.add(herb); return herbs; } }" "package com.rs.game.content.skills.herblore; @PluginEventHandler public class Herblore extends PlayerAction { private final CraftablePotion potion; private int ticks; public Herblore(CraftablePotion potion, int amount) { this.potion = potion; ticks = amount; } @Override public boolean start(Player player) { if (player == null || potion == null) return false; if (player.getSkills().getLevel(Constants.HERBLORE) < potion.getReq()) { player.simpleDialogue(""You need a herblore level of "" + potion.getReq() + "" to combine these ingredients.""); return false; } return true; } @Override public boolean process(Player player) { if (!player.getInventory().containsItem(potion.getPrimary()) || !player.getInventory().containsItems(potion.getSecondaries())) { player.sendMessage(""You don't have enough ingredients left."", true); return false; } return true; } @Override public int processWithDelay(Player player) { player.setNextAnimation(new Animation(363)); ticks--; player.getInventory().deleteItem(potion.getPrimary()); List secondaries = new LinkedList<>(Arrays.asList(potion.getSecondaries())); boolean cleansingProc = player.hasScrollOfCleansing && Utils.random(100) <= 10; if (cleansingProc) player.sendMessage(""Your scroll of cleansing saves "" + Utils.addArticle(secondaries.remove(Utils.random(secondaries.size())).getName().toLowerCase()) + "".""); if (secondaries.size() > 0) player.getInventory().removeItems(secondaries); player.getInventory().addItemDrop(potion.getProduct().clone()); player.incrementCount(potion.getProduct().getName() + "" mixed""); String potName = potion.getProduct().getName().toLowerCase(); player.sendMessage(""You mix "" + Utils.addArticle(potName) + ""."", true); player.getSkills().addXp(Constants.HERBLORE, potion.getXp()); if (ticks > 0) return cleansingProc ? 0 : 1; return -1; } @Override public void stop(final Player player) { setActionDelay(player, 3); } public static ItemOnItemHandler craftPotion = new ItemOnItemHandler(true, CraftablePotion.MAP.keySet().toArray(), e -> { CraftablePotion potion = CraftablePotion.forCombo(e.getItem1().getId(), e.getItem2().getId()); if (potion == null) return; if (potion == CraftablePotion.ANCHOVY_OIL && !e.getPlayer().getInventory().containsItem(6097)) { e.getPlayer().sendMessage(""You need a sieve to make anchovy oil.""); return; } e.getPlayer().startConversation(new Conversation(e.getPlayer()) .addNext(new MakeXStatement(new int[]{potion.getProduct().getId()}, 28)) .addNext(() -> e.getPlayer().getActionManager().setAction(new Herblore(potion, MakeXStatement.getQuantity(e.getPlayer()))))); }); }" "package com.rs.game.content.skills.herblore; @PluginEventHandler public class PestleAndMortar { public enum PestleMortar { ANCHOVIES(319, 1, new Item(11266, 1)), UNICORN_HORN(237, 1, new Item(235, 1)), CHOCOLATE_BAR(1973, 1, new Item(1975, 1)), KEBBIT_TEETH(10109, 1, new Item(10111, 1)), GORAK_CLAW(9016, 1, new Item(9018, 1)), BIRDS_NEST(5075, 1, new Item(6693, 1)), DESERT_GOAT_HORN(9735, 1, new Item(9736, 1)), BLUE_DRAGON_SCALES(243, 1, new Item(241, 1)), CHARCOAL(973, 1, new Item(704, 1)), RUNE_SHARDS(6466, 1, new Item(6467, 1)), ASHES(592, 1, new Item(8865, 1)), RAW_KARAMBWAN(3142, 1, new Item(3152, 1)), KARAMBWAN(3144, 1, new Item(3154, 1)), POISON_KARAMBWAN(3146, 1, new Item(3153, 1)), SUQAH_TOOTH(9079, 1, new Item(9082, 1)), FISHING_BAIT(313, 1, new Item(12129, 1)), DIAMOND_ROOT(14703, 1, new Item(14704, 1)), BLACK_MUSHROOM(4620, 1, new Item(4622, 1)), MUD_RUNES(4698, 1, new Item(9594, 1)), SHARD_OF_ARMADYL(21776, 1, new Item(21774, 8)); private static final Map rawIngredients = new HashMap<>(); public static PestleMortar forId(int itemId) { return rawIngredients.get((short) itemId); } static { for (PestleMortar rawIngredient : PestleMortar.values()) rawIngredients.put(rawIngredient.rawId, rawIngredient); } private final short rawId; private final short rawQty; private final Item crushedItem; private PestleMortar(int rawId, int rawQty, Item crushedItem) { this.rawId = (short) rawId; this.rawQty = (short) rawQty; this.crushedItem = crushedItem; } public short getRawId() { return rawId; } public Item getCrushedItem() { return crushedItem; } } public static ItemOnItemHandler handle = new ItemOnItemHandler(233, e -> { PestleMortar p = PestleMortar.forId(e.getItem1().getId()); if (p == null) p = PestleMortar.forId(e.getItem2().getId()); if (p == null) return; e.getPlayer().startConversation(new CreateActionD(e.getPlayer(), new Item[][] {{new Item(p.getRawId(), p.rawQty)}}, new Item[][] {{p.getCrushedItem()}}, new double[] {0}, new int[] {364}, Constants.HERBLORE, 0)); }); }" "package com.rs.game.content.skills.herblore; @PluginEventHandler public class WeaponPoison { public static enum PoisonableItem { BRONZE_DART(806, 812, 5628, 5635), IRON_DART(807, 813, 5629, 5636), STEEL_DART(808, 814, 5630, 5637), MITHRIL_DART(809, 815, 5632, 5639), ADAMANT_DART(810, 816, 5633, 5640), RUNE_DART(811, 817, 5634, 5641), IRON_JAVELIN(826, 832, 5643, 5649), STEEL_JAVELIN(827, 833, 5644, 5650), MITHRIL_JAVELIN(828, 834, 5645, 5651), ADAMANT_JAVELIN(829, 835, 5646, 5652), RUNE_JAVELIN(830, 836, 5647, 5653), IRON_KNIFE(863, 871, 5655, 5662), BRONZE_KNIFE(864, 870, 5654, 5661), STEEL_KNIFE(865, 872, 5656, 5663), MITHRIL_KNIFE(866, 873, 5657, 5664), ADAMANT_KNIFE(867, 875, 5659, 5666), RUNE_KNIFE(868, 876, 5660, 5667), BLACK_KNIFE(869, 874, 5658, 5665), BRONZE_BOLTS(877, 878, 6061, 6062), BRONZE_ARROW(882, 883, 5616, 5622), IRON_ARROW(884, 885, 5617, 5623), STEEL_ARROW(886, 887, 5618, 5624), MITHRIL_ARROW(888, 889, 5619, 5625), ADAMANT_ARROW(890, 891, 5620, 5626), RUNE_ARROW(892, 893, 5621, 5627), IRON_DAGGER(1203, 1219, 5668, 5686), BRONZE_DAGGER(1205, 1221, 5670, 5688), STEEL_DAGGER(1207, 1223, 5672, 5690), MITHRIL_DAGGER(1209, 1225, 5674, 5692), ADAMANT_DAGGER(1211, 1227, 5676, 5694), RUNE_DAGGER(1213, 1229, 5678, 5696), DRAGON_DAGGER(1215, 1231, 5680, 5698), BLACK_DAGGER(1217, 1233, 5682, 5700), BRONZE_SPEAR(1237, 1251, 5704, 5718, 3170), IRON_SPEAR(1239, 1253, 5706, 5720, 3171), STEEL_SPEAR(1241, 1255, 5708, 5722, 3172), MITHRIL_SPEAR(1243, 1257, 5710, 5724, 3173), ADAMANT_SPEAR(1245, 1259, 5712, 5726, 3174), RUNE_SPEAR(1247, 1261, 5714, 5728, 3175), DRAGON_SPEAR(1249, 1263, 5716, 5730, 3176), BLACK_DART(3093, 3094, 5631, 5638), BLACK_SPEAR(4580, 4582, 5734, 5736, 4584), WHITE_DAGGER(6591, 6593, 6595, 6597), BONE_DAGGER(8872, 8874, 8876, 8878), BLURITE_BOLTS(9139, 9286, 9293, 9300), IRON_BOLTS(9140, 9287, 9294, 9301), STEEL_BOLTS(9141, 9288, 9295, 9302), MITHRIL_BOLTS(9142, 9289, 9296, 9303), ADAMANT_BOLTS(9143, 9290, 9297, 9304), RUNITE_BOLTS(9144, 9291, 9298, 9305), SILVER_BOLTS(9145, 9292, 9299, 9306), KERIS(10581, 10582, 10583, 10584), DRAGON_ARROW(11212, 11227, 11228, 11229), DRAGON_DART(11230, 11231, 11233, 11234), BRONZE_HASTA(11367, 11379, 11382, 11384, 11381), IRON_HASTA(11369, 11386, 11389, 11391, 11388), STEEL_HASTA(11371, 11393, 11396, 11398, 11395), MITHRIL_HASTA(11373, 11400, 11403, 11405, 11402), ADAMANT_HASTA(11375, 11407, 11410, 11412, 11409), RUNE_HASTA(11377, 11414, 11417, 11419, 11416), BLACK_BOLTS(13083, 13084, 13085, 13086), MORRIGANS_JAVELIN(13879, 13880, 13881, 13882), NOVITE_ARROWS(16427, -1, -1, -1, -1, 16482, 16537, 16592), BATHUS_ARROWS(16432, -1, -1, -1, -1, 16487, 16542, 16597), MARMAROS_ARROWS(16437, -1, -1, -1, -1, 16492, 16547, 16602), KRATONITE_ARROWS(16442, -1, -1, -1, -1, 16497, 16552, 16607), FRACTITE_ARROWS(16447, -1, -1, -1, -1, 16502, 16557, 16612), ZEPHYRIUM_ARROWS(16452, -1, -1, -1, -1, 16507, 16562, 16617), ARGONITE_ARROWS(16457, -1, -1, -1, -1, 16512, 16567, 16622), KATAGON_ARROWS(16462, -1, -1, -1, -1, 16517, 16572, 16627), GORGONITE_ARROWS(16467, -1, -1, -1, -1, 16522, 16577, 16632), PROMETHIUM_ARROWS(16472, -1, -1, -1, -1, 16527, 16582, 16637), SAGITTARIAN_ARROWS(16477, -1, -1, -1, -1, 16532, 16587, 16642), NOVITE_DAGGER(16757, -1, -1, -1, -1, 16759, 16761, 16763), BATHUS_DAGGER(16765, -1, -1, -1, -1, 16767, 16769, 16771), MARMAROS_DAGGER(16773, -1, -1, -1, -1, 16775, 16777, 16779), KRATONITE_DAGGER(16781, -1, -1, -1, -1, 16783, 16785, 16787), FRACTITE_DAGGER(16789, -1, -1, -1, -1, 16791, 16793, 16795), ZEPHYRIUM_DAGGER(16797, -1, -1, -1, -1, 16799, 16801, 16803), ARGONITE_DAGGER(16805, -1, -1, -1, -1, 16807, 16809, 16811), KATAGON_DAGGER(16813, -1, -1, -1, -1, 16815, 16817, 16819), GORGONITE_DAGGER(16821, -1, -1, -1, -1, 16823, 16825, 16827), PROMETHIUM_DAGGER(16829, -1, -1, -1, -1, 16831, 16833, 16835), PRIMAL_DAGGER(16837, -1, -1, -1, -1, 16839, 16841, 16843), NOVITE_SPEAR(17063, -1, -1, -1, -1, 17065, 17067, 17069), BATHUS_SPEAR(17071, -1, -1, -1, -1, 17073, 17075, 17077), MARMAROS_SPEAR(17079, -1, -1, -1, -1, 17081, 17083, 17085), KRATONITE_SPEAR(17087, -1, -1, -1, -1, 17089, 17091, 17093), FRACTITE_SPEAR(17095, -1, -1, -1, -1, 17097, 17099, 17101), ZEPHYRIUM_SPEAR(17103, -1, -1, -1, -1, 17105, 17107, 17109), ARGONITE_SPEAR(17111, -1, -1, -1, -1, 17113, 17115, 17117), KATAGON_SPEAR(17119, -1, -1, -1, -1, 17121, 17123, 17125), GORGONITE_SPEAR(17127, -1, -1, -1, -1, 17129, 17131, 17133), PROMETHIUM_SPEAR(17135, -1, -1, -1, -1, 17137, 17139, 17141), PRIMAL_SPEAR(17143, -1, -1, -1, -1, 17145, 17147, 17149); private static final Map POISON_TO_BASE_IDS = new HashMap<>(); private static final Map BASE_IDS_TO_WEAPON = new HashMap<>(); static { for (PoisonableItem wep : PoisonableItem.values()) { BASE_IDS_TO_WEAPON.put(wep.id, wep); for (int poisoned : wep.poisonIds) { if (poisoned != -1) POISON_TO_BASE_IDS.put(poisoned, wep.id); } } } public static int getBaseFromPoisoned(int poisoned) { return POISON_TO_BASE_IDS.get(poisoned); } public static PoisonableItem forId(int baseId) { return BASE_IDS_TO_WEAPON.get(baseId); } private final int id; private final int[] poisonIds; private PoisonableItem(int id, int... poisonIds) { this.id = id; this.poisonIds = poisonIds; } } public static int[] POISONS = { 187, 5937, 5940, 3153, 17572, 17596, 17620 }; public static ItemOnItemHandler handlePoison = new ItemOnItemHandler(Arrays.stream(PoisonableItem.values()).mapToInt(wep -> wep.id).toArray(), POISONS, e -> { Item targetItem = e.getUsedWith(POISONS); Item poison = e.getUsedWith(targetItem.getId()); if (targetItem == null || poison == null) return; PoisonableItem def = PoisonableItem.forId(targetItem.getId()); if (def == null) return; int poisonType = -1; for (int i = 0;i < POISONS.length;i++) { if (poison.getId() == POISONS[i]) poisonType = i; } if (poisonType < 0 || poisonType >= def.poisonIds.length || def.poisonIds[poisonType] == -1) return; int amt = targetItem.getAmount() > 15 ? 15 : targetItem.getAmount(); if (amt > 1 && !e.getPlayer().getInventory().hasFreeSlots()) { e.getPlayer().sendMessage(""Not enough space in your inventory.""); return; } if (poisonType == 3) e.getPlayer().getInventory().deleteItem(poison); else { poison.setId(poisonType > 4 ? 17490 : 229); e.getPlayer().getInventory().refresh(poison.getSlot()); } if (amt < targetItem.getAmount()) { e.getPlayer().getInventory().deleteItem(targetItem.getId(), amt); e.getPlayer().getInventory().addItem(def.poisonIds[poisonType], amt); } else { targetItem.setId(def.poisonIds[poisonType]); e.getPlayer().getInventory().refresh(targetItem.getSlot()); } e.getPlayer().sendMessage(""You dip the tip of the "" + targetItem.getName().toLowerCase() + "" in the poison.""); }); public static ItemOnItemHandler handleClean = new ItemOnItemHandler(PoisonableItem.POISON_TO_BASE_IDS.keySet().stream().mapToInt(key -> key).toArray(), 3188, e -> { Item targetItem = e.getUsedWith(3188); if (targetItem == null) return; int base = PoisonableItem.getBaseFromPoisoned(targetItem.getId()); if (base <= 0) return; targetItem.setId(base); e.getPlayer().getInventory().refresh(targetItem.getSlot()); e.getPlayer().sendMessage(""You clean the poison off the "" + targetItem.getName().toLowerCase() + "".""); }); }" "package com.rs.game.content.skills.hunter; public class BoxAction extends PlayerAction { private final BoxTrapType type; private BoxStyleTrap trap; private final GroundItem groundItem; private final GameObject obj; private Tile tile; public BoxAction(BoxTrapType type, GroundItem groundItem, GameObject obj) { this.type = type; this.groundItem = groundItem; this.obj = obj; } public BoxAction(BoxTrapType type, GroundItem groundItem) { this(type, groundItem, null); } public BoxAction(BoxTrapType type, GameObject obj) { this(type, null, obj); } public BoxAction(BoxTrapType type) { this(type, null, null); } @Override public boolean start(Player player) { player.resetWalkSteps(); tile = Tile.of(player.getTile()); if (type == BoxTrapType.MARASAMAW_PLANT) trap = new MarasamawPlant(player, Tile.of(player.getTile())); else if (type == BoxTrapType.TREE_NET) trap = new NetTrap(player, Tile.of(player.getTile()), obj); else if (type == BoxTrapType.DEAD_FALL) trap = new DeadfallTrap(player, obj); else trap = new BoxStyleTrap(player, type, Tile.of(player.getTile())); if (!checkAll(player)) return false; if (groundItem == null && type != BoxTrapType.TREE_NET) { player.getInventory().deleteItem(type.getId(), 1); World.addGroundItem(new Item(type.getId(), 1), Tile.of(player.getTile()), player, true, 180); } player.sendMessage(""You start setting up the trap..""); player.setNextAnimation(type == BoxTrapType.TREE_NET ? new Animation(5215) : new Animation(5208)); setActionDelay(player, type == BoxTrapType.TREE_NET ? 1 : 2); return true; } @Override public boolean process(Player player) { return true; } @Override public int processWithDelay(Player player) { if (type != BoxTrapType.DEAD_FALL && !player.addWalkSteps(player.getX() - 1, player.getY(), 1)) if (!player.addWalkSteps(player.getX() + 1, player.getY(), 1)) if (!player.addWalkSteps(player.getX(), player.getY() + 1, 1)) player.addWalkSteps(player.getX(), player.getY() - 1, 1); boolean created; if (type == BoxTrapType.DEAD_FALL) { trap.createReplace(); created = true; } else created = trap.createNoReplace(); if (created && type.getId() != -1) if (type == BoxTrapType.TREE_NET) { player.getInventory().deleteItem(954, 1); player.getInventory().deleteItem(303, 1); } else { GroundItem item = groundItem != null ? groundItem : ChunkManager.getChunk(tile.getChunkId()).getGroundItem(type.getId(), tile, player); if (item != null) World.removeGroundItem(player, item, false); } return -1; } @Override public void stop(final Player player) { player.unlock(); setActionDelay(player, 3); } private boolean checkAll(Player player) { if (player.getSkills().getLevel(Constants.HUNTER) < type.getBaseLevel()) { player.sendMessage(""You need a Hunter level of "" + type.getBaseLevel() + "" to place this kind of trap.""); return false; } if (type == BoxTrapType.TREE_NET && (!player.getInventory().containsItem(954, 1, false) || !player.getInventory().containsItem(303, 1, false))) { player.sendMessage(""You need a small fishing net and some rope to set this trap.""); return false; } int trapAmt = getTrapAmount(player); int numberSetup = OwnedObject.getNumOwned(player, BoxStyleTrap.class); if (numberSetup >= trapAmt) { player.sendMessage(""You can't setup more than "" + trapAmt + "" traps.""); return false; } if (type != BoxTrapType.DEAD_FALL && trap.overlapsExisting()) { player.sendMessage(""You can't place a trap here.""); return false; } return true; } public int getTrapAmount(Player player) { return 1 + (int) ((double) player.getSkills().getLevel(Constants.HUNTER) / 20); } }" "package com.rs.game.content.skills.hunter; @PluginEventHandler public class BoxHunterNPC extends NPC { private int captureTicks; public BoxHunterNPC(int id, Tile tile, boolean spawned) { super(id, tile, spawned); setIgnoreNPCClipping(true); } @Override public void processNPC() { super.processNPC(); if (timeSinceSpawned() < 3000) return; if (captureTicks > 0 || hasFinished()) { if (captureTicks > 20) { setRouteEvent(null); captureTicks = 0; return; } captureTicks++; return; } List objects = World.getSpawnedObjectsInChunkRange(getChunkId(), 1); if (objects == null) return; for (final GameObject o : objects) { if (!(o instanceof BoxStyleTrap trapO)) continue; Player owner = trapO.getOwner(); if (owner == null) continue; BoxHunterType type = getType(trapO.getOwner()); if (type == null) continue; if (owner.getSkills().getLevel(Constants.HUNTER) < type.getLevel() || trapO.getStatus() != Status.IDLE || trapO.getLife() < 10 || trapO.getLife() > 75 || trapO.getTrapType() != type.getTrap() || trapO.getBait() != type.getBaitId() || !withinDistance(o.getTile(), 2)) continue; captureTicks = 1; trapO.setStatus(Status.CATCHING); resetWalkSteps(); setRouteEvent(new RouteEvent(trapO, () -> { if (trapO.getOwner() == null || trapO.isDestroyed() || trapO.getTrapType() != type.getTrap()) return; boolean success = Utils.skillSuccess(owner.getSkills().getLevel(Constants.HUNTER), type.getRate1(), type.getRate99()); faceObject(trapO); setNextAnimation(success ? type.getAnimSuccess() : type.getAnimFail()); trapO.handleCatch(this, success); })); break; } } @Override public void setRespawnTask() { super.setRespawnTask(4); } public static NPCInstanceHandler toFunc = new NPCInstanceHandler( Stream.concat( Arrays.stream(JadinkoType.values()).map(JadinkoType::getNpcId).filter(i -> i != -1).distinct(), BoxHunterType.ID_MAP.keySet().stream()) .toArray(), (npcId, tile) -> new BoxHunterNPC(npcId, tile, false)); public BoxHunterType getType(Player owner) { if (owner == null) return null; return BoxHunterType.forId(getDefinitions(owner).getId()); } }" "package com.rs.game.content.skills.hunter; public enum BoxHunterType { CHINCHOMPA(5079, ""hunter_chin"", 53, 198.5, BoxTrapType.BOX, 19188, 19189, 19192, new Animation(5184), new Animation(5185), 145, 268), CARNIVOROUS_CHINCHOMPA(5080, ""hunter_red_chin"", 63, 265, BoxTrapType.BOX, 19188, 19189, 19192, new Animation(5184), new Animation(5185), 115, 228), GRENWALL(7010, 12535, ""hunter_grenwall"", 77, 1100, BoxTrapType.BOX, 19188, 19189, 19192, new Animation(8602), new Animation(8602), 15, 130), PAWYA(7012, 5972, ""hunter_pawya"", 66, 400, BoxTrapType.BOX, 19188, 19189, 19192, new Animation(8615), new Animation(8611), 100, 215), WILD_KEBBIT(5089, ""hunter_kebbitwild"", 23, 128, BoxTrapType.DEAD_FALL, 19207, 19215, 19206, new Animation(5275), new Animation(5277), 105, 354), BARB_TAILED_KEBBIT(5088, ""hunter_kebbitbarb"", 33, 168, BoxTrapType.DEAD_FALL, 19218, 19217, 19206, new Animation(5275), new Animation(5277), 110, 326), PRICKLY_KEBBIT(5086, ""hunter_kebbitprick"", 37, 204, BoxTrapType.DEAD_FALL, 19208, 19218, 19206, new Animation(5275), new Animation(5277), 115, 298), SABRE_TOOTHED_KEBBIT(5087, ""hunter_kebbitsabre"", 51, 200, BoxTrapType.DEAD_FALL, 19209, 19216, 19206, new Animation(5275), new Animation(5277), 120, 268), // FERRET(5081, new Item[] { new Item(10092) }, 27, 115, BoxTrapType.BOX, 19188, 19189, 19192, new Animation(5191), new Animation(5192)), //TODO summoning reqs // // GECKO(6916, new Item[] { new Item(12184) }, 27, 100, BoxTrapType.BOX, 19188, 19189, 19192, new Animation(8362), new Animation(8361)), // // RACCOON(7272, new Item[] { new Item(12487) }, 27, 100, BoxTrapType.BOX, 19188, 19189, 19192, new Animation(7726), new Animation(7727)), SWAMP_LIZARD(5117, ""hunter_salam_swamp"", 29, 152, BoxTrapType.TREE_NET, -1, -1, -1, new Animation(-1), new Animation(-1), -96, 433), ORANGE_SALAMANDER(5114, ""hunter_salam_orange"", 47, 224, BoxTrapType.TREE_NET, -1, -1, -1, new Animation(-1), new Animation(-1), 17, 285), RED_SALAMANDER(5115, ""hunter_salam_red"", 59, 272, BoxTrapType.TREE_NET, -1, -1, -1, new Animation(-1), new Animation(-1), 0, 240), BLACK_SALAMANDER(5116, ""hunter_salam_black"", 67, 319.2, BoxTrapType.TREE_NET, -1, -1, -1, new Animation(-1), new Animation(-1), -2, 212), CRIMSON_SWIFT(5073, ""hunter_crimswift"", 1, 34, BoxTrapType.BIRD_SNARE, 19179, 19180, 19174, new Animation(6775), new Animation(6774), 100, 420), GOLDEN_WARBLER(5075, ""hunter_goldwarb"", 5, 48, BoxTrapType.BIRD_SNARE, 19183, 19184, 19174, new Animation(6775), new Animation(6774), 92, 402), COPPER_LONGTAIL(5076, ""hunter_copperlong"", 9, 61, BoxTrapType.BIRD_SNARE, 19185, 19186, 19174, new Animation(6775), new Animation(6774), 84, 389), CERULEAN_TWITCH(5074, ""hunter_cerutwitch"", 11, 64.67, BoxTrapType.BIRD_SNARE, 19181, 19182, 19174, new Animation(6775), new Animation(6774), 82, 381), TROPICAL_WAGTAIL(5072, ""hunter_tropwag"", 19, 95.2, BoxTrapType.BIRD_SNARE, 19177, 19178, 19174, new Animation(6775), new Animation(6774), 74, 368), WIMPY_BIRD(7031, ""hunter_wimpybird"", 39, 167, BoxTrapType.BIRD_SNARE, 29164, 29165, 19174, new Animation(6775), new Animation(6774), 60, 321), IMP(708, ""hunter_imp"", 71, 450, BoxTrapType.MAGIC_BOX, 19225, 19226, 19224, new Animation(5218), new Animation(5285), 15, 130), COMMON_JADINKO(13119, ""hunter_jadinko_common"", 70, 350, BoxTrapType.MARASAMAW_PLANT, 56830, 56819, 56813, new Animation(3293), new Animation(3293), 30, 150), AMPHIBIOUS_JADINKO(13130, ""hunter_jadinko_amphibious"", 77, 485, BoxTrapType.MARASAMAW_PLANT, 56831, 56820, 56807, new Animation(3293), new Animation(3293), 15, 130), DRACONIC_JADINKO(13131, ""hunter_jadinko_draconic"", 80, 525, BoxTrapType.MARASAMAW_PLANT, 56832, 56821, 56812, new Animation(3293), new Animation(3293), 15, 130), AQUATIC_JADINKO(13142, ""hunter_jadinko_aquatic"", 76, 475, BoxTrapType.MARASAMAW_PLANT, 56833, 56822, 56808, new Animation(3293), new Animation(3293), 15, 135), IGNEOUS_JADINKO(13143, ""hunter_jadinko_igneous"", 74, 465, BoxTrapType.MARASAMAW_PLANT, 56834, 56823, 56815, new Animation(3293), new Animation(3293), 25, 145), CARRION_JADINKO(13154, ""hunter_jadinko_carrion"", 78, 505, BoxTrapType.MARASAMAW_PLANT, 56835, 56824, 56810, new Animation(3293), new Animation(3293), 15, 130), CANNIBAL_JADINKO(13155, ""hunter_jadinko_cannibal"", 75, 475, BoxTrapType.MARASAMAW_PLANT, 56836, 56825, 56809, new Animation(3293), new Animation(3293), 20, 140), GUTHIX_JADINKO(13164, ""hunter_jadinko_guthix"", 81, 600, BoxTrapType.MARASAMAW_PLANT, 56838, 56827, 56814, new Animation(3293), new Animation(3293), 15, 130), SARADOMIN_JADINKO(13163, ""hunter_jadinko_saradomin"", 81, 600, BoxTrapType.MARASAMAW_PLANT, 56837, 56826, 56817, new Animation(3293), new Animation(3293), 15, 130), ZAMORAK_JADINKO(13165, ""hunter_jadinko_zamorak"", 81, 600, BoxTrapType.MARASAMAW_PLANT, 56839, 56828, 56818, new Animation(3293), new Animation(3293), 15, 130); private final int npcId; private final int baitId; private final int level; private final int objectCatch; private final int objectSuccess; private final int objectFail; private final int rate1; private final int rate99; private final double xp; private final BoxTrapType hunter; private final Animation animSuccess; private final Animation animFail; private final String dropTable; public static final Map ID_MAP = new HashMap<>(); public static final Map OBJECTID_MAP = new HashMap<>(); public static BoxHunterType forId(int id) { return ID_MAP.get(id); } static { for (BoxHunterType type : BoxHunterType.values()) { ID_MAP.put(type.npcId, type); OBJECTID_MAP.put(type.objectSuccess, type); } } public static BoxHunterType forObjectId(int id) { return OBJECTID_MAP.get(id); } BoxHunterType(int npcId, String dropTable, int level, double xp, BoxTrapType hunter, int objectCatch, int objectSuccess, int objectFail, Animation animSuccess, Animation animFail, int rate1, int rate99) { this(npcId, -1, dropTable, level, xp, hunter, objectCatch, objectSuccess, objectFail, animSuccess, animFail, rate1, rate99); } BoxHunterType(int npcId, int baitId, String dropTable, int level, double xp, BoxTrapType hunter, int objectCatch, int objectSuccess, int objectFail, Animation animSuccess, Animation animFail, int rate1, int rate99) { this.npcId = npcId; this.baitId = baitId; this.dropTable = dropTable; this.level = level; this.xp = xp; this.hunter = hunter; this.objectCatch = objectCatch; this.objectSuccess = objectSuccess; this.objectFail = objectFail; this.animSuccess = animSuccess; this.animFail = animFail; this.rate1 = rate1; this.rate99 = rate99; } public int getRate1() { return rate1; } public int getRate99() { return rate99; } public int getLevel() { return level; } public int getNpcId() { return npcId; } public double getXp() { return xp; } public Item[] getItems(Player player) { return DropTable.calculateDrops(player, DropSets.getDropSet(dropTable)); } public BoxTrapType getTrap() { return hunter; } public int getObjectCatch() { return objectCatch; } public int getObjectSuccess() { return objectSuccess; } public int getObjectFail() { return objectFail; } public Animation getAnimSuccess() { return animSuccess; } public Animation getAnimFail() { return animFail; } public int getBaitId() { return baitId; } }" "package com.rs.game.content.skills.hunter; public enum BoxTrapType { BIRD_SNARE(10006, 19175, new Animation(5207), 1), DEAD_FALL(1511, 19206, new Animation(451), 23), BOX(10008, 19187, new Animation(451), 27), TREE_NET(303, -1, new Animation(5207), 29), MARASAMAW_PLANT(19965, 56806, new Animation(451), 70), MAGIC_BOX(10025, 19223, new Animation(451), 71); private final int itemId; private final int objectId; private final int baseLevel; private final Animation pickUpAnimation; private static final Map TRAPS_BY_ITEM = new HashMap<>(); static { for (BoxTrapType t : BoxTrapType.values()) TRAPS_BY_ITEM.put(t.itemId, t); } public static BoxTrapType forId(int id) { return TRAPS_BY_ITEM.get(id); } private BoxTrapType(int itemId, int objectId, Animation pickUpAnimation, int baseLevel) { this.itemId = itemId; this.objectId = objectId; this.pickUpAnimation = pickUpAnimation; this.baseLevel = baseLevel; } public int getId() { return itemId; } public int getObjectId() { return objectId; } public Animation getPickUpAnimation() { return pickUpAnimation; } public int getBaseLevel() { return baseLevel; } }" "package com.rs.game.content.skills.hunter; @PluginEventHandler public class FlyingEntityHunter { public static final Animation CAPTURE_ANIMATION = new Animation(6606); public static final Animation CAUGHT_ANIMATION = new Animation(6615); public static final int BUTTERFLY_NET = 10010; public static final int MAGIC_BUTTERFLY_NET = 11259; public static final int IMPLING_JAR = 11260; public static final int BUTTERFLY_JAR = 10012; public static final int[] CHARMS = new int[] { 12158, 12159, 12160, 12163 }; public enum FlyingEntities { BABY_IMPLING(1028, 11238, 25, 17, 79, 400), YOUNG_IMPLING(1029, 11240, 65, 22, 69, 349), GOURMET_IMPLING(1030, 11242, 113, 28, 61, 324), EARTH_IMPLING(1031, 11244, 177, 36, 51, 301), ESSENCE_IMPLING(1032, 11246, 225, 42, 41, 275), ECLECTIC_IMPLING(1033, 11248, 289, 50, 31, 250), SPIRIT_IMPLING(7866, 15513, 321, 54, 24, 225) { @Override public void effect(Player player) { if (Utils.random(2) == 0) { Item charm = new Item(CHARMS[Utils.random(CHARMS.length)], 1); player.startConversation(new Dialogue().addItem(charm.getId(), ""The impling was carrying a "" + charm.getName().toLowerCase() + ""."")); player.getInventory().addItemDrop(charm); } } }, NATURE_IMPLING(1034, 11250, 250, 58, 20, 199), MAGPIE_IMPLING(1035, 11252, 289, 65, 15, 176), NINJA_IMPLING(6053, 11254, 339, 74, 10, 150), PIRATE_IMPLING(7845, 13337, 350, 76, 8, 132), DRAGON_IMPLING(6054, 11256, 390, 83, 5, 125), ZOMBIE_IMPLING(7902, 15515, 412, 87, 8, 140), KINGLY_IMPLING(7903, 15517, 434, 91, 3, 99), BABY_IMPLING_PP(6055, 11238, 25, 17, 79, 400), YOUNG_IMPLING_PP(6056, 11240, 65, 22, 69, 349), GOURMET_IMPLING_PP(6057, 11242, 113, 28, 61, 324), EARTH_IMPLING_PP(6058, 11244, 177, 36, 51, 301), ESSENCE_IMPLING_PP(6059, 11246, 225, 42, 41, 275), ECLECTIC_IMPLING_PP(6060, 11248, 289, 50, 31, 250), SPIRIT_IMPLING_PP(7904, 15513, 321, 54, 24, 225) { @Override public void effect(Player player) { if (Utils.random(2) == 0) { Item charm = new Item(CHARMS[Utils.random(CHARMS.length)], 1); player.startConversation(new Dialogue().addItem(charm.getId(), ""The impling was carrying a "" + charm.getName().toLowerCase() + ""."")); player.getInventory().addItemDrop(charm); } } }, NATURE_IMPLING_PP(6061, 11250, 353, 58, 20, 199), MAGPIE_IMPLING_PP(6062, 11252, 409, 65, 15, 176), NINJA_IMPLING_PP(6063, 11254, 481, 74, 10, 150), PIRATE_IMPLING_PP(7846, 13337, 497, 76, 8, 132), DRAGON_IMPLING_PP(6064, 11256, 553, 83, 5, 125), ZOMBIE_IMPLING_PP(7905, 15515, 585, 87, 8, 140), KINGLY_IMPLING_PP(7906, 15517, 617, 91, 3, 99); public static final Map flyingEntitiesByNPC = new HashMap<>(); public static final Map flyingEntitiesByReward = new HashMap<>(); static { for (FlyingEntities impling : FlyingEntities.values()) { flyingEntitiesByNPC.put(impling.npcId, impling); flyingEntitiesByReward.put(impling.reward, impling); } } public static FlyingEntities forNPC(int npcId) { return flyingEntitiesByNPC.get(npcId); } public static FlyingEntities forItem(int reward) { return flyingEntitiesByReward.get(reward); } private final int npcId; private final int level; private final int reward; private final double experience; private final int rate1; private final int rate99; FlyingEntities(int npcId, int reward, double experience, int level, int rate1, int rate99) { this.npcId = npcId; this.reward = reward; this.experience = experience; this.level = level; this.rate1 = rate1; this.rate99 = rate99; } public int getNpcId() { return npcId; } public int getLevel() { return level; } public int getReward() { return reward; } public double getExperience() { return experience; } public int getRate1() { return rate1; } public int getRate99() { return rate99; } public void effect(Player player) { } public static FlyingEntities forId(int itemId) { for (FlyingEntities entity : FlyingEntities.values()) if (itemId == entity.getReward()) return entity; return null; } } public static boolean hasButterflyNetEquipped(Player p) { return switch (p.getEquipment().getWeaponId()) { case BUTTERFLY_NET, MAGIC_BUTTERFLY_NET -> true; default -> false; }; } public static NPCInteractionDistanceHandler flyingEntitiesDistance = new NPCInteractionDistanceHandler(FlyingEntities.flyingEntitiesByNPC.keySet().toArray(), (player, npc) -> 0); public static NPCClickHandler captureFlyingEntity = new NPCClickHandler(true, FlyingEntities.flyingEntitiesByNPC.keySet().toArray(), e -> { if (!e.getOption().equals(""Catch"") || !e.isAtNPC()) return; final FlyingEntities entity = FlyingEntities.forNPC(e.getNPC().getId()); if (e.getNPC() instanceof Impling && !hasButterflyNetEquipped(e.getPlayer()) && ((Impling) e.getNPC()).getPuroPuro()) { e.getPlayer().sendMessage(""You need to have a butterfly net equipped in order to capture an impling.""); return; } if (hasButterflyNetEquipped(e.getPlayer())) { if (e.getPlayer().getSkills().getLevel(Constants.HUNTER) < entity.getLevel()) { e.getPlayer().sendMessage(""You need a hunter level of "" + entity.getLevel() + "" to capture a "" + e.getNPC().getName().toLowerCase() + "".""); return; } if (!e.getPlayer().getInventory().containsItem(e.getNPC() instanceof Impling ? IMPLING_JAR : BUTTERFLY_JAR, 1)) { e.getPlayer().sendMessage(""You don't have an empty "" + (e.getNPC() instanceof Impling ? ""impling jar"" : ""butterfly jar"") + "" in which to keep "" + (e.getNPC() instanceof Impling ? ""an impling"" : ""a butterfly"") + "".""); return; } } else if (e.getPlayer().getSkills().getLevel(Constants.HUNTER) < entity.getLevel()+10) { e.getPlayer().sendMessage(""You need a hunter level of "" + (entity.getLevel() + 10) + "" in order to capture a "" + e.getNPC().getName().toLowerCase() + "" barehanded.""); return; } e.getPlayer().lock(2); e.getPlayer().sendMessage(""You swing your net...""); e.getPlayer().setNextAnimation(CAPTURE_ANIMATION); if (rollSuccess(e.getPlayer(), entity, e.getPlayer().getEquipment().getWeaponId() == BUTTERFLY_NET)) { e.getNPC().setNextAnimation(CAUGHT_ANIMATION); e.getPlayer().incrementCount(e.getNPC().getName() + "" trapped""); e.getPlayer().getInventory().deleteItem(e.getNPC() instanceof Impling ? IMPLING_JAR : BUTTERFLY_JAR, 1); e.getPlayer().getInventory().addItem(entity.getReward(), 1); e.getPlayer().getSkills().addXp(Constants.HUNTER, entity.getExperience()); e.getPlayer().sendMessage(""You manage to catch the "" + e.getNPC().getName().toLowerCase() + "" and squeeze it into a jar.""); e.getNPC().sendDeath(e.getPlayer()); return; } e.getPlayer().sendMessage(""...you stumble and miss the "" + e.getNPC().getName().toLowerCase()); if (!e.getNPC().hasEffect(Effect.FREEZE)) { e.getNPC().resetWalkSteps(); Tile fleeTo = e.getNPC().getRespawnTile(); fleeTo.transform(Utils.random(-10, 10), Utils.random(-10, 10)); DumbRouteFinder.addDumbPathfinderSteps(e.getNPC(), fleeTo, 10, e.getNPC().getCollisionStrategy()); } if (e.getNPC() instanceof Impling && Utils.random(10) == 0) e.getNPC().setNextForceTalk(new ForceTalk(""Tee hee, you missed me!"")); }); public static ItemClickHandler openJar = new ItemClickHandler(FlyingEntities.flyingEntitiesByReward.keySet().toArray(), new String[]{""Open"", ""Loot"", ""Empty"", ""Release""}, e -> { FlyingEntities entity = FlyingEntities.forId(e.getItem().getId()); if (e.getOption().equals(""Empty"") || e.getOption().equals(""Release"")) { e.getItem().setId(entity.toString().toLowerCase().contains(""impling"") ? IMPLING_JAR : BUTTERFLY_JAR); return; } if (e.getOption().equals(""Open"") || e.getOption().equals(""Loot"")) { if (entity.toString().toLowerCase().contains(""impling"")) { Item[] loot = DropTable.calculateDrops(e.getPlayer(), DropSets.getDropSet(entity.getNpcId())); e.getItem().setId(entity.toString().toLowerCase().contains(""impling"") ? IMPLING_JAR : BUTTERFLY_JAR); if (loot.length > 0) for (Item item : loot) if (item != null) e.getPlayer().getInventory().addItemDrop(item.getId(), item.getAmount()); } entity.effect(e.getPlayer()); if (Utils.random(10) == 0) { e.getPlayer().getInventory().deleteItem(new Item(entity.toString().toLowerCase().contains(""impling"") ? IMPLING_JAR : BUTTERFLY_JAR)); e.getPlayer().sendMessage(""You press too hard on the jar and the glass shatters in your hands.""); e.getPlayer().applyHit(new Hit(e.getPlayer(), 10, HitLook.TRUE_DAMAGE)); } e.getPlayer().getInventory().refresh(e.getSlotId()); } }); public static boolean rollSuccess(Player player, FlyingEntities entity, boolean standardNet) { return Utils.skillSuccess(player.getSkills().getLevel(Skills.HUNTER), ((standardNet ? 0 : 0.1) + player.getAuraManager().getHuntingMul()), entity.getRate1(), entity.getRate99()); } // 1118: Teleport to Impetuous Implings Minigame - Wheat Field beam // 1119: Impling teleporting to a different location GFX - White smoke puff // 1124: Impling jar breaking w/ impling inside // 1125: Impling jar breaking w/ impling inside // 1126: Impling jar breaking w/ impling inside // 1127: Impling jar breaking w/ impling inside // 1128: Impling jar breaking w/ impling inside // 1129: Impling jar breaking w/ impling inside // 1130: Impling jar breaking w/ impling inside // 1131: Impling jar breaking w/ impling inside // 1132: Impling jar breaking w/ impling inside // 1133: Impling jar breaking w/ impling inside // 1134: Exchanging an impling jar w/ impling inside // 1135: Exchanging an impling jar w/ impling inside // 1136: Exchanging an impling jar w/ impling inside // 1137: Exchanging an impling jar w/ impling inside // 1138: Exchanging an impling jar w/ impling inside // 1139: Exchanging an impling jar w/ impling inside // 1140: Exchanging an impling jar w/ impling inside // 1141: Exchanging an impling jar w/ impling inside // 1142: Exchanging an impling jar w/ impling inside // 1143: Exchanging an impling jar w/ impling inside // 1144: Spinning impling jar w/ impling inside // 1145: Spinning impling jar w/ impling inside // 1146: Spinning impling jar w/ impling inside // 1147: Spinning impling jar w/ impling inside // 1148: Spinning impling jar w/ impling inside // 1149: Spinning impling jar w/ impling inside // 1150: Spinning impling jar w/ impling inside // 1151: Spinning impling jar w/ impling inside // 1152: Spinning impling jar w/ impling inside // 1153: Spinning impling jar w/ impling inside // 2327-2330: imp jar breaks // 2331: imp jar flys away // 2332: imp jar breaks // 2333-2335: impling jar flys away // 2336: impling jar projectile // 2337: imp in jar flys away? // 2338: imp in jar flys away? // 1605: Imp relocation }" "package com.rs.game.content.skills.hunter; @PluginEventHandler public final class Hunter { public static final Animation CAPTURE_ANIMATION = new Animation(6606); public static final Animation TEASING_STICK_ANIM = new Animation(5236); public static final Animation NOOSE_WAND_ANIM = new Animation(3297); public static ItemClickHandler handleBoxTypeTraps = new ItemClickHandler(new Object[] { 10006, 10008, 10025, 19965 }, new String[] { ""Lay"", ""Activate"" }, e -> { switch(e.getItem().getId()) { case 10006: e.getPlayer().getActionManager().setAction(new BoxAction(BoxTrapType.BIRD_SNARE)); break; case 10008: e.getPlayer().getActionManager().setAction(new BoxAction(BoxTrapType.BOX)); break; case 10025: e.getPlayer().getActionManager().setAction(new BoxAction(BoxTrapType.MAGIC_BOX)); break; case 19965: e.getPlayer().getActionManager().setAction(new BoxAction(BoxTrapType.MARASAMAW_PLANT)); break; } }); public static ItemClickHandler handleImpInABox = new ItemClickHandler(new Object[] { 10027, 10028 }, e -> { if (e.getOption().equals(""Bank"")) { e.getPlayer().getInterfaceManager().sendInterface(478); e.getPlayer().getPackets().setIFEvents(new IFEvents(478, 14, 0, 27).enableRightClickOptions(0, 1)); } }); public static ItemClickHandler releaseLizards = new ItemClickHandler(new Object[] { 10149, 10146, 10147, 10148 }, new String[] { ""Release"" }, e -> e.getPlayer().startConversation(new Dialogue().addOptions(""How many would you like to release?"", new Options() { @Override public void create() { if (e.getPlayer().getInventory().getAmountOf(e.getItem().getId()) > 1) option(""All"", () -> { e.getPlayer().getInventory().deleteItem(e.getItem().getId(), e.getPlayer().getInventory().getAmountOf(e.getItem().getId())); e.getPlayer().sendMessage(""You release the "" + (e.getItem().getId() == 10149 ? ""lizards"" : ""salamanders"") + "" and they dart away.""); }); option(""One"", () -> { e.getPlayer().getInventory().deleteItem(e.getItem()); e.getPlayer().sendMessage(""You release the "" + (e.getItem().getId() == 10149 ? ""lizard"" : ""salamander"") + "" and it darts away.""); }); } }))); public static ItemOnItemHandler craftPotion = new ItemOnItemHandler(new int[] { 10027, 10028 }, e -> { Item usedWith = e.getUsedWith(10027, 10028); if (usedWith == null) return; if (usedWith.getId() == 10027 || usedWith.getId() == 10028) { e.getPlayer().sendMessage(""You cannot bank an imp using an imp!""); return; } boolean costRemoved = false; if (e.getPlayer().getInventory().containsItem(10028, 1)) { e.getPlayer().getInventory().deleteItem(10028, 1); e.getPlayer().getInventory().addItem(10025, 1); costRemoved = true; } else if (e.getPlayer().getInventory().containsItem(10027, 1)) { e.getPlayer().getInventory().deleteItem(10027, 1); e.getPlayer().getInventory().addItem(10028, 1); costRemoved = true; } if (costRemoved) e.getPlayer().getBank().depositItem(usedWith.getSlot(), usedWith.getAmount(), true); }); public static ButtonClickHandler handleImpInABoxButtons = new ButtonClickHandler(478, e -> { if (e.getComponentId() == 14) { Item item = e.getPlayer().getInventory().getItem(e.getSlotId()); if (item == null) return; if (item.getId() == 10027 || item.getId() == 10028) { e.getPlayer().sendMessage(""You cannot bank an imp using an imp!""); return; } boolean costRemoved = false; if (e.getPlayer().getInventory().containsItem(10028, 1)) { e.getPlayer().getInventory().deleteItem(10028, 1); e.getPlayer().getInventory().addItem(10025, 1); costRemoved = true; } else if (e.getPlayer().getInventory().containsItem(10027, 1)) { e.getPlayer().getInventory().deleteItem(10027, 1); e.getPlayer().getInventory().addItem(10028, 1); costRemoved = true; } if (costRemoved) e.getPlayer().getBank().depositItem(e.getSlotId(), item.getAmount(), true); else e.getPlayer().sendMessage(""You are unable to bank any more items.""); } }); public static ObjectClickHandler handleTrapCheck = new ObjectClickHandler(new Object[] { ""Net trap"", ""Magic box"", ""Magic box failed"", ""Bird snare"", ""Box trap"", ""Shaking box"", ""Marasamaw plant"", ""Wilted marasamaw plant"", ""Shaking marasamaw plant"" }, e -> { if (!(e.getObject() instanceof BoxStyleTrap trap)) return; if (!trap.ownedBy(e.getPlayer())) { e.getPlayer().sendMessage(""This isn't your trap.""); return; } if (e.getOpNum() == ClientPacket.OBJECT_OP1) if (trap.getStatus() == Status.FAIL || trap.getStatus() == Status.IDLE) trap.dismantle(e.getPlayer()); else if (trap.getStatus() == Status.SUCCESS) trap.check(e.getPlayer()); }); public static ItemOnObjectHandler handleBaitTraps = new ItemOnObjectHandler(new Object[] { ""Boulder"", ""Deadfall"", ""Net trap"", ""Magic box"", ""Magic box failed"", ""Bird snare"", ""Box trap"", ""Shaking box"", ""Marasamaw plant"", ""Wilted marasamaw plant"", ""Shaking marasamaw plant"" }, null, e -> { if (!(e.getObject() instanceof BoxStyleTrap trap)) { e.getPlayer().sendMessage(""This trap isn't baitable.""); return; } if (!trap.ownedBy(e.getPlayer())) { e.getPlayer().sendMessage(""This isn't your trap.""); return; } trap.tryBait(e.getPlayer(), e.getItem().getId()); }); public static ObjectClickHandler handleDeadfalls = new ObjectClickHandler(new Object[] { ""Boulder"", ""Deadfall"" }, e -> { if (e.getOption().equals(""Set-trap"")) e.getPlayer().getActionManager().setAction(new BoxAction(BoxTrapType.DEAD_FALL, e.getObject())); else if (e.getOpNum() == ClientPacket.OBJECT_OP1) { if (!(e.getObject() instanceof BoxStyleTrap trap)) return; if (!trap.ownedBy(e.getPlayer())) { e.getPlayer().sendMessage(""This isn't your trap.""); return; } if (trap.getStatus() == Status.FAIL || trap.getStatus() == Status.IDLE) trap.dismantle(e.getPlayer()); else if (trap.getStatus() == Status.SUCCESS) trap.check(e.getPlayer()); } }); public static ObjectClickHandler handleTreeNets = new ObjectClickHandler(new Object[] { ""Young tree"" }, e -> { if (e.getOption().equals(""Set-trap"")) e.getPlayer().getActionManager().setAction(new BoxAction(BoxTrapType.TREE_NET, e.getObject())); else if (e.getOption().equals(""Dismantle"")) { if (e.getObject() instanceof OwnedObject oo && !oo.ownedBy(e.getPlayer())) { e.getPlayer().sendMessage(""This isn't your trap.""); return; } for (OwnedObject o : OwnedObject.getOwnedBy(e.getPlayer())) if (o instanceof NetTrap nt && o.getTile().withinDistance(e.getObject().getTile(), 1)) nt.dismantle(e.getPlayer()); } }); // @ButtonClickHandler(ids = { }) // public static void handleJadinko }" "package com.rs.game.content.skills.hunter; @PluginEventHandler public class Impling extends NPC { private final boolean dynamic; private final boolean puropuro; private final Tile respawnTile; public Impling(int id, Tile tile, boolean dynamic) { super(id, tile); this.dynamic = dynamic; this.respawnTile = tile; this.puropuro = isPuroPuroImpling(id); if (!puropuro) finishAfterTicks(Ticks.fromMinutes(30)); setRandomWalk(true); setCollisionStrategyType(CollisionStrategyType.FLY); addLOSOverrides(id); } public void processNPC() { if (Utils.random(500) == 0) setNextForceTalk(new ForceTalk(Utils.random(2) == 0 ? ""Tee hee!"" : ""Wheee!"")); super.processNPC(); } @Override public void sendDeath(final Entity source) { getInteractionManager().forceStop(); resetWalkSteps(); setNextAnimation(null); reset(); setTile(respawnTile); finish(); int impId = rollImpRespawn(); setNPC(impId == -1 ? rollLowTierOverworldImp() : impId); if (!isSpawned()) setRespawnTask(getRespawnTicks(getId())); } @Override public void onRespawn() { if (dynamic || !puropuro) { setHidden(true); WorldTasks.schedule(Ticks.fromMinutes(Utils.randomInclusive(1, 3)), () -> setHidden(false)); } } public boolean getPuroPuro() { return puropuro; } private static boolean isPuroPuroImpling(int npcId) { return switch(npcId) { case 6055, 6056, 6057, 6058, 6059, 6060, 6061, 6062, 6063, 6064, 7846, 7904, 7905, 7906 -> true; default -> false; }; } private int rollImpRespawn() { if (puropuro && dynamic) return rollHighTierPuroPuroImp(); if (puropuro && !dynamic) return getId(); if (!puropuro && !dynamic) return rollLowTierOverworldImp(); return rollTier(); } public static int rollTier() { int random = Utils.random(100); if (random > 95) return rollHighTierOverworldImp(); if (random > 88) return rollMidTierOverworldImp(); if (random > 74) return rollLowTierOverworldImp(); return -1; } public static int rollLowTierOverworldImp() { int random = Utils.random(100); if (random >= 95) return FlyingEntities.SPIRIT_IMPLING.getNpcId(); if (random >= 85) return FlyingEntities.ECLECTIC_IMPLING.getNpcId(); if (random >= 75) return FlyingEntities.ESSENCE_IMPLING.getNpcId(); if (random >= 55) return FlyingEntities.EARTH_IMPLING.getNpcId(); if (random >= 35) return FlyingEntities.GOURMET_IMPLING.getNpcId(); if (random >= 15) return FlyingEntities.YOUNG_IMPLING.getNpcId(); return FlyingEntities.BABY_IMPLING.getNpcId(); } public static int rollMidTierOverworldImp() { int random = Utils.random(100); if (random >= 99) return FlyingEntities.NINJA_IMPLING.getNpcId(); if (random >= 97) return FlyingEntities.MAGPIE_IMPLING.getNpcId(); if (random >= 77) return FlyingEntities.NATURE_IMPLING.getNpcId(); if (random >= 40) return FlyingEntities.ECLECTIC_IMPLING.getNpcId(); if (random >= 20) return FlyingEntities.ESSENCE_IMPLING.getNpcId(); if (random >= 10) return FlyingEntities.EARTH_IMPLING.getNpcId(); return FlyingEntities.GOURMET_IMPLING.getNpcId(); } public static int rollHighTierOverworldImp() { int random = Utils.getRandomInclusive(100); if (random >= 100) return FlyingEntities.KINGLY_IMPLING.getNpcId(); if (random >= 97) return FlyingEntities.ZOMBIE_IMPLING.getNpcId(); if (random >= 87) return FlyingEntities.DRAGON_IMPLING.getNpcId(); if (random >= 75) return FlyingEntities.PIRATE_IMPLING.getNpcId(); if (random >= 50) return FlyingEntities.NINJA_IMPLING.getNpcId(); if (random >= 10) return FlyingEntities.MAGPIE_IMPLING.getNpcId(); return FlyingEntities.NATURE_IMPLING.getNpcId(); } public static int rollLowTierPuroPuroImp() { int random = Utils.random(100); if (random >= 95) return FlyingEntities.SPIRIT_IMPLING_PP.getNpcId(); if (random >= 85) return FlyingEntities.ECLECTIC_IMPLING_PP.getNpcId(); if (random >= 75) return FlyingEntities.ESSENCE_IMPLING_PP.getNpcId(); if (random >= 55) return FlyingEntities.EARTH_IMPLING_PP.getNpcId(); if (random >= 35) return FlyingEntities.GOURMET_IMPLING_PP.getNpcId(); if (random >= 15) return FlyingEntities.YOUNG_IMPLING_PP.getNpcId(); return FlyingEntities.BABY_IMPLING_PP.getNpcId(); } public static int rollMidTierPuroPuroImp() { int random = Utils.random(100); if (random >= 99) return FlyingEntities.NINJA_IMPLING_PP.getNpcId(); if (random >= 97) return FlyingEntities.MAGPIE_IMPLING_PP.getNpcId(); if (random >= 77) return FlyingEntities.NATURE_IMPLING_PP.getNpcId(); if (random >= 40) return FlyingEntities.ECLECTIC_IMPLING_PP.getNpcId(); if (random >= 20) return FlyingEntities.ESSENCE_IMPLING_PP.getNpcId(); if (random >= 10) return FlyingEntities.EARTH_IMPLING_PP.getNpcId(); return FlyingEntities.GOURMET_IMPLING_PP.getNpcId(); } public static int rollHighTierPuroPuroImp() { int random = Utils.getRandomInclusive(300); if (random >= 300) return FlyingEntities.KINGLY_IMPLING_PP.getNpcId(); if (random >= 297) return FlyingEntities.ZOMBIE_IMPLING_PP.getNpcId(); if (random >= 288) return FlyingEntities.DRAGON_IMPLING_PP.getNpcId(); if (random >= 270) return FlyingEntities.PIRATE_IMPLING_PP.getNpcId(); if (random >= 243) return FlyingEntities.NINJA_IMPLING_PP.getNpcId(); if (random >= 132) return FlyingEntities.MAGPIE_IMPLING_PP.getNpcId(); return FlyingEntities.NATURE_IMPLING_PP.getNpcId(); } public int getRespawnTicks(int npcId) { if (dynamic) return Ticks.fromMinutes(2); return switch (npcId) { case 6058, 6059, 7904 -> 50; //Earth, Essence, Spirit case 6055, 6056, 6057, 6060 -> 7; //Baby, Young, Gourmet, Eclectic default -> Ticks.fromMinutes(2); //Catch all for overworld }; } @ServerStartupEvent public static void initSpawns() { Tile[] STATIC_PUROPURO_BABY_IMPLING_SPAWNS = new Tile[]{ Tile.of(2563, 4291, 0), Tile.of(2563, 4348, 0), Tile.of(2568, 4323, 0), Tile.of(2571, 4305, 0), Tile.of(2571, 4337, 0), Tile.of(2581, 4300, 0), Tile.of(2584, 4344, 0), Tile.of(2596, 4296, 0), Tile.of(2609, 4339, 0), Tile.of(2610, 4304, 0), Tile.of(2615, 4322, 0), Tile.of(2620, 4291, 0), Tile.of(2620, 4348, 0) }; Tile[] STATIC_PUROPURO_YOUNG_IMPLING_SPAWNS = new Tile[]{ Tile.of(2564, 4321, 0), Tile.of(2574, 4321, 0), Tile.of(2574, 4331, 0), Tile.of(2587, 4300, 0), Tile.of(2590, 4348, 0), Tile.of(2592, 4291, 0), Tile.of(2595, 4343, 0), Tile.of(2612, 4309, 0), Tile.of(2612, 4327, 0), Tile.of(2619, 4322, 0) }; Tile[] STATIC_PUROPURO_GOURMET_IMPLING_SPAWNS = new Tile[]{ Tile.of(2568, 4296, 0), Tile.of(2568, 4327, 0), Tile.of(2574, 4311, 0), Tile.of(2580, 4343, 0), Tile.of(2585, 4296, 0), Tile.of(2597, 4293, 0), Tile.of(2602, 4346, 0), Tile.of(2609, 4317, 0), Tile.of(2615, 4298, 0), Tile.of(2615, 4342, 0), Tile.of(2618, 4321, 0) }; Tile[] STATIC_PUROPURO_EARTH_IMPLING_SPAWNS = new Tile[]{ Tile.of(2568, 4317, 0), Tile.of(2570, 4330, 0), Tile.of(2574, 4305, 0), Tile.of(2587, 4342, 0), Tile.of(2590, 4298, 0), Tile.of(2598, 4340, 0), Tile.of(2611, 4334, 0), Tile.of(2612, 4310, 0) }; Tile[] STATIC_PUROPURO_ESSENCE_IMPLING_SPAWNS = new Tile[]{ Tile.of(2574, 4317, 0), Tile.of(2576, 4337, 0), Tile.of(2585, 4298, 0), Tile.of(2601, 4343, 0), Tile.of(2612, 4318, 0) }; Tile[] STATIC_PUROPURO_ECLECTIC_IMPLING_SPAWNS = new Tile[]{ Tile.of(2567, 4319, 0), Tile.of(2591, 4295, 0), Tile.of(2591, 4340, 0), Tile.of(2615, 4326, 0) }; Tile[] DYNAMIC_PUROPURO_LOW_IMPLING_SPAWNS = new Tile[] { Tile.of(2569, 4342, 0), Tile.of(2591, 4339, 0), Tile.of(2616, 4343, 0), Tile.of(2578, 4334, 0), Tile.of(2605, 4334, 0), Tile.of(2572, 4321, 0), Tile.of(2610, 4320, 0), Tile.of(2575, 4306, 0), Tile.of(2591, 4301, 0), Tile.of(2605, 4306, 0), Tile.of(2570, 4297, 0), Tile.of(2617, 4295, 0) }; Tile[] DYNAMIC_PUROPURO_MID_IMPLING_SPAWNS = new Tile[] { Tile.of(2570, 4332, 0), Tile.of(2585, 4340, 0), Tile.of(2603, 4340, 0), Tile.of(2615, 4333, 0), Tile.of(2574, 4322, 0), Tile.of(2609, 4322, 0), Tile.of(2578, 4299, 0), Tile.of(2589, 4299, 0), Tile.of(2598, 4302, 0), Tile.of(2614, 4308, 0) }; Tile[] DYNAMIC_PUROPURO_HIGH_IMPLING_SPAWNS = new Tile[]{ Tile.of(2591, 4340, 0), Tile.of(2591, 4295, 0) }; Tile[] STATIC_OVERWORLD_LOW_IMPLING_SPAWNS = new Tile[] { Tile.of(2481, 4442, 0), Tile.of(2354, 3608, 0), Tile.of(2279, 3188, 0), Tile.of(2455, 3084, 0), Tile.of(2567, 3384, 0), Tile.of(2784, 3463, 0), Tile.of(2967, 3411, 0), Tile.of(3093, 3238, 0), Tile.of(3283, 3428, 0), Tile.of(3278, 3155, 0) }; Tile[] DYNAMIC_OVERWORLD_ALL_IMPLING_SPAWNS = new Tile[] { Tile.of(2203, 3236, 0), Tile.of(2331, 3639, 0), Tile.of(2394, 3512, 0), Tile.of(2459, 3418, 0), Tile.of(2584, 2972, 0), Tile.of(2592, 3252, 0), Tile.of(2739, 3342, 0), Tile.of(2841, 2928, 0), Tile.of(2849, 3033, 0), Tile.of(3018, 3523, 0), Tile.of(3020, 3424, 0), Tile.of(3143, 3231, 0), Tile.of(3239, 3283, 0), Tile.of(3292, 3265, 0), Tile.of(3356, 3013, 0), Tile.of(3408, 3125, 0), Tile.of(3441, 3351, 0), Tile.of(3454, 3486, 0), Tile.of(3548, 3528, 0), Tile.of(3677, 3321, 0), Tile.of(2982, 3276, 0), Tile.of(3169, 3001, 0), Tile.of(2904, 3489, 0), Tile.of(2646, 3421, 0), Tile.of(2654, 3609, 0), Tile.of(3135, 3378, 0), Tile.of(2727, 3768, 0), Tile.of(2814, 3512, 0), Tile.of(2470, 3217, 0), Tile.of(2740, 3535, 0), Tile.of(2843, 3161, 0), Tile.of(3730, 3016, 0), Tile.of(3765, 3798, 0), Tile.of(2198, 2963, 0), Tile.of(2526, 3101, 0), Tile.of(2500, 2875, 0) }; Tile[] IMP_DEFENDER_SPAWNS = new Tile[]{ Tile.of(2563, 4292, 0), Tile.of(2564, 4348, 0), Tile.of(2566, 4294, 0), Tile.of(2566, 4345, 0), Tile.of(2569, 4297, 0), Tile.of(2570, 4342, 0), Tile.of(2572, 4300, 0), Tile.of(2572, 4339, 0), Tile.of(2575, 4303, 0), Tile.of(2575, 4336, 0), Tile.of(2578, 4306, 0), Tile.of(2578, 4333, 0), Tile.of(2581, 4309, 0), Tile.of(2581, 4330, 0), Tile.of(2602, 4310, 0), Tile.of(2602, 4330, 0), Tile.of(2604, 4306, 0), Tile.of(2605, 4333, 0), Tile.of(2608, 4303, 0), Tile.of(2608, 4336, 0), Tile.of(2611, 4300, 0), Tile.of(2611, 4339, 0), Tile.of(2614, 4297, 0), Tile.of(2614, 4342, 0), Tile.of(2616, 4294, 0), Tile.of(2617, 4345, 0), Tile.of(2619, 4291, 0), Tile.of(2619, 4348, 0) }; for (Tile tile : STATIC_PUROPURO_BABY_IMPLING_SPAWNS) { new Impling(FlyingEntityHunter.FlyingEntities.BABY_IMPLING_PP.getNpcId(), tile, false); } for (Tile tile : STATIC_PUROPURO_YOUNG_IMPLING_SPAWNS) { new Impling(FlyingEntityHunter.FlyingEntities.YOUNG_IMPLING_PP.getNpcId(), tile, false); } for (Tile tile : STATIC_PUROPURO_GOURMET_IMPLING_SPAWNS) { new Impling(FlyingEntityHunter.FlyingEntities.GOURMET_IMPLING_PP.getNpcId(), tile, false); } for (Tile tile : STATIC_PUROPURO_EARTH_IMPLING_SPAWNS) { new Impling(FlyingEntityHunter.FlyingEntities.EARTH_IMPLING_PP.getNpcId(), tile, false); } for (Tile tile : STATIC_PUROPURO_ESSENCE_IMPLING_SPAWNS) { new Impling(FlyingEntityHunter.FlyingEntities.ESSENCE_IMPLING_PP.getNpcId(), tile, false); } for (Tile tile : STATIC_PUROPURO_ECLECTIC_IMPLING_SPAWNS) { new Impling(FlyingEntityHunter.FlyingEntities.ECLECTIC_IMPLING_PP.getNpcId(), tile, false); } for (Tile tile : DYNAMIC_PUROPURO_LOW_IMPLING_SPAWNS) { new Impling(Impling.rollLowTierPuroPuroImp(), tile, true); } for (Tile tile : DYNAMIC_PUROPURO_MID_IMPLING_SPAWNS) { new Impling(Impling.rollMidTierPuroPuroImp(), tile, true); } for (Tile tile : DYNAMIC_PUROPURO_HIGH_IMPLING_SPAWNS) { new Impling(Impling.rollHighTierPuroPuroImp(), tile, true); } for (Tile tile : STATIC_OVERWORLD_LOW_IMPLING_SPAWNS) { new Impling(Impling.rollLowTierOverworldImp(), tile, false); } WorldTasks.scheduleLooping(Ticks.fromMinutes(2), Ticks.fromMinutes(30), () -> { for (Tile tile : DYNAMIC_OVERWORLD_ALL_IMPLING_SPAWNS) { for (int i = 0; i < 3; i++) { int npcId = rollTier(); if (npcId != -1) new Impling(npcId, tile, true); } } }); for (Tile tile : IMP_DEFENDER_SPAWNS) { new ImpDefender(tile); } } }" "package com.rs.game.content.skills.hunter; @PluginEventHandler public class Jadinko extends NPC { public Jadinko(int id, Tile tile) { super(id, tile); } @Override public void sendDeath(Entity source) { super.sendDeath(source); if (source instanceof Player player) player.addJadinkoFavor((getId() == 13820 ? 3 : getId() == 13821 ? 7 : 10)); } public static NPCInstanceHandler toFunc = new NPCInstanceHandler(new Object[] { 13820, 13821, 13822 }, Jadinko::new); }" "package com.rs.game.content.skills.hunter.falconry; @PluginEventHandler public class FalconryController extends Controller { public static final int BIRD_GLOVE = 10024, EMPTY_GLOVE = 10023; public static NPCClickHandler catchKebbit = new NPCClickHandler(false, Arrays.stream(KebbitType.values()).map(k -> k.kebbitId).toArray(), e -> { if (!e.getPlayer().getControllerManager().isIn(FalconryController.class)) { e.getPlayer().sendMessage(""I should speak to Matthias about using my own falcon before catching these.""); return; } if (!(e.getNPC() instanceof Kebbit kebbit)) { e.getPlayer().sendMessage(""This shouldn't have happened. Report it as a bug please.""); return; } e.getPlayer().getInteractionManager().setInteraction(new StandardEntityInteraction(e.getNPC(), 8, () -> kebbit.sendFalcon(e.getPlayer()))); }); public static NPCClickHandler lootKebbit = new NPCClickHandler(Arrays.stream(KebbitType.values()).map(k -> k.caughtId).toArray(), e -> { if (!e.getPlayer().getControllerManager().isIn(FalconryController.class)) { e.getPlayer().sendMessage(""I should speak to Matthias about using my own falcon before catching these.""); return; } if (!(e.getNPC() instanceof Kebbit kebbit)) { e.getPlayer().sendMessage(""This shouldn't have happened. Report it as a bug please.""); return; } kebbit.loot(e.getPlayer()); }); @Override public void start() { player.getEquipment().setNoPluginTrigger(Equipment.WEAPON, new Item(BIRD_GLOVE, 1)); player.getEquipment().refresh(Equipment.WEAPON); player.getAppearance().generateAppearanceData(); player.simpleDialogue(""Simply click on the target and try your luck.""); } public static ItemEquipHandler handleFalconersGlove = new ItemEquipHandler(new Object[] { BIRD_GLOVE, EMPTY_GLOVE }, e -> { if (e.equip()) { e.cancel(); e.getPlayer().getInventory().deleteItem(e.getItem()); return; } e.getPlayer().getPackets().sendPlayerMessage(0, 0xFF0000, ""You should speak to Matthias to get this removed safely.""); e.cancel(); }); @Override public boolean login() { return false; } @Override public boolean logout() { return false; } @Override public void onTeleported(TeleType type) { player.getControllerManager().forceStop(); } @Override public void forceClose() { if (player.getEquipment().containsOneItem(BIRD_GLOVE, EMPTY_GLOVE)) player.getEquipment().setNoPluginTrigger(Equipment.WEAPON, null); player.getEquipment().refresh(Equipment.WEAPON); player.getAppearance().generateAppearanceData(); } public static ObjectClickHandler enterArea = new ObjectClickHandler(new Object[] { 19222 }, e -> { if (e.getPlayer().getControllerManager().isIn(FalconryController.class)) { e.getPlayer().sendOptionDialogue(""Are you sure you would like to leave?"", ops -> { ops.add(""Yes"", () -> { e.getPlayer().getControllerManager().forceStop(); e.getPlayer().lock(2); e.getPlayer().setNextAnimation(new Animation(1560)); WorldTasks.schedule(() -> e.getPlayer().tele(e.getPlayer().transform(0, e.getPlayer().getY() > e.getObject().getY() ? -2 : 2))); }); ops.add(""No""); }); return; } e.getPlayer().lock(2); e.getPlayer().setNextAnimation(new Animation(1560)); WorldTasks.schedule(() -> e.getPlayer().tele(e.getPlayer().transform(0, e.getPlayer().getY() > e.getObject().getY() ? -2 : 2))); }); public static void beginFalconry(Player player) { if (player.getEquipment().hasItemInSlot(Equipment.WEAPON, Equipment.SHIELD)) { player.simpleDialogue(""You need both hands free to use a falcon.""); return; } if (player.getSkills().getLevel(Constants.HUNTER) < 43) { player.simpleDialogue(""You need a Hunter level of at least 43 to use a falcon, come back later.""); return; } player.sendOptionDialogue(""Pay 500 coins to borrow a falcon?"", ops -> { ops.add(""Yes"", () -> { if (!player.getInventory().hasCoins(500)) { player.sendMessage(""You need 500 coins to borrow a falcon.""); return; } player.getInventory().removeCoins(500); player.getControllerManager().startController(new FalconryController()); }); ops.add(""No""); }); } }" "package com.rs.game.content.skills.hunter.falconry; @PluginEventHandler public class Kebbit extends NPC { public enum KebbitType { SPOTTED(5098, 5094, 43, 42, 26, 310, 10125), DARK(5099, 5095, 57, 99, 0, 253, 10115), DASHING(5100, 5096, 69, 156, 0, 205, 10127); public final int kebbitId, caughtId, level, xp, rate1, rate99, furId; static final Map CATCH_MAP = new HashMap<>(); static final Map CAUGHT_MAP = new HashMap<>(); static { for (KebbitType k : KebbitType.values()) { CATCH_MAP.put(k.kebbitId, k); CAUGHT_MAP.put(k.caughtId, k); } } static KebbitType forKebbit(int npcId) { return CATCH_MAP.get(npcId); } static KebbitType forCaught(int npcId) { return CAUGHT_MAP.get(npcId); } KebbitType(int kebbitId, int caughtId, int level, int xp, int rate1, int rate99, int furId) { this.kebbitId = kebbitId; this.caughtId = caughtId; this.level = level; this.xp = xp; this.rate1 = rate1; this.rate99 = rate99; this.furId = furId; } } private final KebbitType type; private int catchTimer = -1; private Player caughtBy; private int hintIcon = -1; public Kebbit(int id, Tile tile) { super(id, tile); this.type = KebbitType.forKebbit(id); if (this.type == null) throw new RuntimeException(""Invalid falconry kebbit spawned somehow.""); } @Override public void processNPC() { super.processNPC(); if (catchTimer-- == 0) expire(); } @Override public void finish() { super.finish(); resetValues(); } private void expire() { returnBirdToCatcher(); resetValues(); } private void resetValues() { if (caughtBy != null && !caughtBy.hasFinished() && caughtBy.hasStarted() && caughtBy.getControllerManager().isIn(FalconryController.class)) { caughtBy.getEquipment().setNoPluginTrigger(Equipment.WEAPON, new Item(FalconryController.BIRD_GLOVE)); caughtBy.getAppearance().generateAppearanceData(); caughtBy.unlock(); if (hintIcon != -1) caughtBy.getHintIconsManager().removeHintIcon(hintIcon); } transformIntoNPC(type.kebbitId); catchTimer = -1; hintIcon = -1; caughtBy = null; } public KebbitType getType() { return type; } public void returnBirdToCatcher() { if (caughtBy != null && !caughtBy.hasFinished() && caughtBy.hasStarted() && caughtBy.getControllerManager().isIn(FalconryController.class)) { final Player returnPlayer = caughtBy; if (hintIcon != -1) returnPlayer.getHintIconsManager().removeHintIcon(hintIcon); returnPlayer.lock(); returnPlayer.soundEffect(2633, true); World.sendProjectile(this, caughtBy, 922, 24, 8, 0, 1.0, 15, backProj -> { unlock(); returnPlayer.unlock(); returnPlayer.getEquipment().setNoPluginTrigger(Equipment.WEAPON, new Item(FalconryController.BIRD_GLOVE)); returnPlayer.getAppearance().generateAppearanceData(); }); } hintIcon = -1; caughtBy = null; } public static NPCInstanceHandler toFunc = new NPCInstanceHandler(Arrays.stream(KebbitType.values()).map(k -> k.kebbitId).toArray(), Kebbit::new); public void sendFalcon(Player player) { if (player.getSkills().getLevel(Skills.HUNTER) < type.level) { player.sendMessage(""You need a hunter level of "" + type.level + "" to catch those.""); return; } if (player.getEquipment().getWeaponId() != FalconryController.BIRD_GLOVE) { player.sendMessage(""Your bird is waiting on a catch already.""); return; } if (isLocked() || catchTimer >= 0) { player.sendMessage(""This kebbit is already being targeted.""); return; } resetWalkSteps(); lock(); player.lock(); player.faceEntity(this); player.getEquipment().setNoPluginTrigger(Equipment.WEAPON, new Item(FalconryController.EMPTY_GLOVE)); player.getAppearance().generateAppearanceData(); player.soundEffect(2634, true); World.sendProjectile(player, this, 922, 24, 8, 0, 1.0, 15, toProj -> { if (Utils.skillSuccess(player.getSkills().getLevel(Skills.HUNTER), type.rate1, type.rate99)) { hintIcon = player.getHintIconsManager().addHintIcon(this, 0, -1, false); catchTimer = Ticks.fromSeconds(60); caughtBy = player; transformIntoNPC(type.caughtId); unlock(); player.unlock(); return; } player.soundEffect(2633, true); World.sendProjectile(this, player, 922, 24, 8, 0, 1.0, 15, backProj -> { unlock(); player.unlock(); player.getEquipment().setNoPluginTrigger(Equipment.WEAPON, new Item(FalconryController.BIRD_GLOVE)); player.getAppearance().generateAppearanceData(); }); }); } public void loot(Player player) { if (caughtBy != player) { player.sendMessage(""This isn't your catch to loot.""); return; } if (!player.getInventory().hasFreeSlots()) { player.sendMessage(""You don't have enough space in your inventory.""); return; } player.incrementCount(NPCDefinitions.getDefs(type.kebbitId).getName() + "" hunted at falconry""); player.faceEntity(this); player.lock(); player.anim(827); player.getSkills().addXp(Skills.HUNTER, type.xp); player.getInventory().addItemDrop(type.furId, 1); if (!DropCleanersKt.bonecrush(player, new Item(526, 1))) player.getInventory().addItemDrop(526, 1); sendDeath(player); } }" "package com.rs.game.content.skills.hunter.falconry; @PluginEventHandler public class Matthias extends NPC { private static List POST_TILES = new ArrayList<>(); private static final int BIRD_FREQUENCY = Ticks.fromSeconds(15); public Matthias(Tile tile) { super(5092, tile); } @Override public void processNPC() { super.processNPC(); if (getTickCounter() % BIRD_FREQUENCY == 0) toggleBird(); } private void toggleBird() { boolean hasBird = getId() == 5092; List posts = POST_TILES.stream() .filter(obj -> obj.getId() == (hasBird ? 19220 : 19221)) .toList(); if (posts.isEmpty()) return; GameObject post = posts.get(Utils.random(posts.size())); if (post == null) return; resetWalkSteps(); faceObject(post); freeze(); if (hasBird) { if (Utils.random(10) == 0) forceTalk(""Gouge 'em, Valor!""); transformIntoNPC(5093); setBas(1); World.sendProjectile(this, post, 922, 41, 16, 31, 0.8, 16, proj -> { post.setId(19221); unfreeze(); }); } else { if (Utils.random(10) == 0) forceTalk(""Valor, to me!""); post.setId(19220); World.sendProjectile(post, this, 922, 41, 16, 31, 0.8, 16, proj -> { transformIntoNPC(5092); setBas(-1); unfreeze(); }); } } @ServerStartupEvent public static void init() { POST_TILES = World.getAllObjectsInChunkRange(Tile.of(2374, 3605, 0).getChunkId(), 2) .stream() .filter(obj -> obj != null && (obj.getId() == 19220 || obj.getId() == 19221)) .toList(); } public static NPCClickHandler handleMatthias = new NPCClickHandler(new Object[] { 5092, 5093 }, e -> { switch(e.getOption()) { case ""Talk-to"" -> e.getPlayer().startConversation(new Conversation(e.getPlayer()) { { addPlayer(HeadE.CHEERFUL, ""Hello there.""); addNPC(e.getNPCId(), HeadE.CONFUSED, ""Greetings. Can I help you at all?""); addOptions(ops -> { ops.add(""Do you have any quests I could do?"") .addNPC(e.getNPCId(), HeadE.CONFUSED, ""A quest? What a strange notion. Do you normally go around asking complete strangers for quests?"") .addPlayer(HeadE.SKEPTICAL, ""Er, yes, now that you come to mention it."") .addNPC(e.getNPCId(), HeadE.CHEERFUL, ""Oh, ok then. Well, no, I don't. Sorry.""); ops.add(""What is this place?"") .addNPC(e.getNPCId(), HeadE.CHEERFUL, ""A good question; straight and to the point."") .addNPC(e.getNPCId(), HeadE.CHEERFUL, ""My name is Matthias, I am a falconer, and this is where I train my birds."") .addOptions(watOp -> { watOp.add(""That sounds like fun; could I have a go?"", () -> FalconryController.beginFalconry(e.getPlayer())); watOp.add(""That doesn't sound like my sort of thing."") .addNPC(e.getNPCId(), HeadE.CALM_TALK, ""Fair enough; it does require a great deal of patience and skill, so I can understand if you might feel intimidated.""); watOp.add(""What's this falconry thing all about then?"") .addNPC(e.getNPCId(), HeadE.CHEERFUL, ""Well, some people see it as a sport, although such a term does not really convey the amount of patience and dedication to be profiecient at the task."") .addNPC(e.getNPCId(), HeadE.CHEERFUL, ""Putting it simply, it is the training and use of birds of prey in hunting quarry.""); }); }); create(); } }); case ""Falconry"" -> FalconryController.beginFalconry(e.getPlayer()); } }); public static NPCInstanceHandler toFunc = new NPCInstanceHandler(new Object[] { 5092, 5093 }, (npcId, tile) -> new Matthias(tile)); }" "package com.rs.game.content.skills.hunter.puropuro; @PluginEventHandler public class CropCircles { private static CropCircle locationOne, locationTwo; public enum CropCircle { ARDOUGNE(Tile.of(2647, 3347, 0)), BRIMHAVEN(Tile.of(2808, 3200, 0)), CATHERBY(Tile.of(2818, 3470, 0)), DRAYNOR_VILLAGE(Tile.of(3115, 3272, 0)), HARMONY_ISLAND(Tile.of(3810, 2852, 0)), LUMBRIDGE(Tile.of(3160, 3298, 0)), MISCELLANIA(Tile.of(2538, 3845, 0)), MOS_LE_HARMLESS(Tile.of(3697, 3025, 0)), RIMMINGTON(Tile.of(2979, 3216, 0)), DORICS_HOUSE(Tile.of(2953, 3444, 0)), COOKS_GUILD(Tile.of(3141, 3461, 0)), CHAMPIONS_GUILD(Tile.of(3212, 3345, 0)), TAVERLEY(Tile.of(2893, 3398, 0)), TREE_GNOME_STRONGHOLD(Tile.of(2435, 3472, 0)), YANILLE(Tile.of(2582, 3104, 0)); private final Tile entranceTile; CropCircle(Tile tile) { this.entranceTile = tile; } public Tile getEntranceTile() { return entranceTile; } public int getX() { return entranceTile.getX(); } public int getY() { return entranceTile.getY(); } public int getPlane() { return entranceTile.getPlane(); } } public static ObjectClickHandler teleportToPuroPuro = new ObjectClickHandler(new Object[] { 24988, 24991 }, e -> { if (!e.isAtObject()) return; WorldTasks.schedule(10, () -> { e.getPlayer().getControllerManager().startController(new PuroPuroController(e.getObject().getTile())); if (e.getObjectId() == 24988) { e.getPlayer().addEffect(Effect.FARMERS_AFFINITY, 3000); e.getPlayer().sendMessage(""You feel the magic of the crop circle grant you a Farmer's affinity.""); } }); Magic.sendTeleportSpell(e.getPlayer(), 6601, -1, 1118, -1, 0, 0, Tile.of(2590 + Utils.randomInclusive(0, 3), 4318 + Utils.randomInclusive(0, 3), 0), 9, false, TeleType.OBJECT, null); }); public static NPCClickHandler handleWanderingImpling = new NPCClickHandler(new Object[] { 6073 }, e -> { Cutscene currentLocations = new Cutscene() { @Override public void construct(Player player) { Tile loc1 = locationOne.getEntranceTile(); Tile loc2 = locationTwo.getEntranceTile(); setEndTile(player.getTile()); fadeIn(3); hideMinimap(); action(() -> { player.lock(); player.tele(loc1); player.getAppearance().setHidden(true); }); delay(2); camPos(loc1.getX()-3, loc1.getY()-3, 2500); camLook(loc1.getX(), loc1.getY(), 0); fadeOut(3); camPos(loc1.getX()-10, loc1.getY()-10, 7000, 50,1); delay(3); camPos(loc1.getX(), loc1.getY()-10, 7000,50,1); delay(3); camPos(loc1.getX()+10, loc1.getY()-10, 7000,50,1); delay(4); fadeIn(3); action(() -> player.tele(loc2)); delay(2); camPos(loc2.getX()-3, loc2.getY()-3, 2500); camLook(loc2.getX(), loc2.getY(), 0); fadeOut(3); camPos(loc2.getX()-10, loc2.getY()-10, 7000, 50,1); delay(3); camPos(loc2.getX(), loc2.getY()-10, 7000,50,1); delay(3); camPos(loc2.getX()+10, loc2.getY()-10, 7000,50,1); delay(6); } }; switch (e.getOption()) { case ""Talk-to"" -> e.getPlayer().startConversation(new Conversation(e.getPlayer()) { { addPlayer(HeadE.CHEERFUL, ""Hello there.""); addNPC(e.getNPCId(), HeadE.CONFUSED, ""Are they here? Are they there? Are they elsewhere?""); addPlayer(HeadE.CHEERFUL, ""Are what where?""); addNPC(e.getNPCId(), HeadE.CONFUSED, ""This gate's sisters...""); addPlayer(HeadE.CHEERFUL, ""I didn't know gates had relations.""); addNPC(e.getNPCId(), HeadE.CONFUSED, ""Oh yes. This one here: she is calm and boring. She stays here all the time. She doesn't like to move, but her sisters are fidgety and refuse to stay in the same place for more than half an hour.""); addPlayer(HeadE.CHEERFUL, ""So, where are the, errr, fidgety sisters at the moment?""); addNPC(e.getNPCId(), HeadE.CONFUSED, ""Oh well. I don't know what you humans call these places. Let me show you.""); addNext(() -> { e.getPlayer().playCutscene(currentLocations); }); } }); case ""Check-gates"" -> e.getPlayer().playCutscene(currentLocations); default -> {} } }); @ServerStartupEvent public static void initCropCircles() { WorldTasks.scheduleLooping(0, Ticks.fromMinutes(30), () -> { int random = Utils.random(0, CropCircle.values().length); int random2 = Utils.random(0, CropCircle.values().length); while (random2 == random) random2 = Utils.random(0, CropCircle.values().length); locationOne = CropCircle.values()[random]; locationTwo = CropCircle.values()[random2]; NPC impOne = new NPC(1531, Tile.of(locationOne.getX() - 1, locationOne.getY() - 1, locationOne.getPlane())); NPC impTwo = new NPC(1531, Tile.of(locationTwo.getX() - 1, locationTwo.getY() - 1, locationTwo.getPlane())); Tile[] impPathOne = setImpPath(locationOne); Tile[] impPathTwo = setImpPath(locationTwo); impOne.setRandomWalk(false); impOne.finishAfterTicks(42); impTwo.setRandomWalk(false); impTwo.finishAfterTicks(42); WorldTasks.scheduleTimer(ticks -> { if (ticks % 5 == 0 && ticks <= 35) { impOne.setForceWalk(impPathOne[ticks / 5]); impTwo.setForceWalk(impPathTwo[ticks / 5]); } if (ticks == 41) { impOne.setNextSpotAnim(new SpotAnim(1119)); // 931? impTwo.setNextSpotAnim(new SpotAnim(1119)); // 931? } if (ticks >= 45) { spawnCropCircle(locationOne); spawnCropCircle(locationTwo); return false; } return true; }); }); } private static Tile[] setImpPath(CropCircle location) { Tile[] impPath = new Tile[] { Tile.of(location.getX() + 1, location.getY() - 1, location.getPlane()), Tile.of(location.getX() + 1, location.getY() + 1, location.getPlane()), Tile.of(location.getX() - 1, location.getY() + 1, location.getPlane()), Tile.of(location.getX() - 1, location.getY() - 1, location.getPlane()), Tile.of(location.getX() + 1, location.getY() - 1, location.getPlane()), Tile.of(location.getX() + 1, location.getY() + 1, location.getPlane()), Tile.of(location.getX() - 1, location.getY() + 1, location.getPlane()), Tile.of(location.getX() - 1, location.getY() - 1, location.getPlane()) }; return impPath; } private static void spawnCropCircle(CropCircle location) { World.spawnObjectTemporary(new GameObject(24986, 2, location.getX() - 1, location.getY() + 1, location.getPlane()), Ticks.fromMinutes(30)); World.spawnObjectTemporary(new GameObject(24985, 2, location.getX(), location.getY() + 1, location.getPlane()), Ticks.fromMinutes(30)); World.spawnObjectTemporary(new GameObject(24984, 2, location.getX() + 1, location.getY() + 1, location.getPlane()), Ticks.fromMinutes(30)); World.spawnObjectTemporary(new GameObject(24987, 2, location.getX() - 1, location.getY(), location.getPlane()), Ticks.fromMinutes(30)); World.spawnObjectTemporary(new GameObject(24988, 0, location.getX(), location.getY(), location.getPlane()), Ticks.fromMinutes(30)); World.spawnObjectTemporary(new GameObject(24987, 0, location.getX() + 1, location.getY(), location.getPlane()), Ticks.fromMinutes(30)); World.spawnObjectTemporary(new GameObject(24984, 0, location.getX() - 1, location.getY() - 1, location.getPlane()), Ticks.fromMinutes(30)); World.spawnObjectTemporary(new GameObject(24985, 0, location.getX(), location.getY() - 1, location.getPlane()), Ticks.fromMinutes(30)); World.spawnObjectTemporary(new GameObject(24986, 0, location.getX() + 1, location.getY() - 1, location.getPlane()), Ticks.fromMinutes(30)); } }" "package com.rs.game.content.skills.hunter.puropuro; @PluginEventHandler public class ElnockInquisitor extends Conversation { public static int ELNOCK_INQUISITOR = 6070; public ElnockInquisitor(Player player) { super(player); if (player.getTempAttribs().getB(""puropuro_introduction"") == false) { addPlayer(HeadE.CONFUSED, ""What's a gnome doing here?""); addNPC(ELNOCK_INQUISITOR, HeadE.CALM, ""I'm an investigator. I'm watching the implings.""); addPlayer(HeadE.CALM, ""Why would you want to do that?""); addNPC(ELNOCK_INQUISITOR, HeadE.CALM, ""My client has asked me to find out where certain missing items have been going.""); addPlayer(HeadE.CALM, ""Who is this client?""); addNPC(ELNOCK_INQUISITOR, HeadE.CALM, ""I'm not at liberty to discuss that. Investigator-client confidentiality don't you know. ""); addOptions(""Choose an option:"", ops -> { ops.add(""Where is this place?"") .addNPC(ELNOCK_INQUISITOR, HeadE.CALM, ""The fairies call it Puro-Puro. It seems to be the home plane of the implings."") .addNPC(ELNOCK_INQUISITOR, HeadE.CALM, ""I don't think these creatures have a name for it. As you can see there isn't a lot else here other than wheat. ""); ops.add(""How did you get here?"") .addNPC(ELNOCK_INQUISITOR, HeadE.CALM, ""The same way you did, I suspect. Through a portal in a wheat field. I followed one back."") .addPlayer(HeadE.CALM, ""I haven't noticed them do that."") .addNPC(ELNOCK_INQUISITOR, HeadE.CALM, ""That's why I'm the investigator and you're the adventurer.""); ops.add(""So, what are these implings?"") .addNPC(ELNOCK_INQUISITOR, HeadE.CALM, ""That's a very interesting question. My best guess is that they are relatives to imps, which is why there are imps here as well."") .addNPC(ELNOCK_INQUISITOR, HeadE.CALM, ""Implings do appear to like collecting objects and, as my clients have noted, have no concept of ownership. However, I do not sense any malicious intent."") .addNPC(ELNOCK_INQUISITOR, HeadE.CALM, ""It is my observation that they collect things that other creatures want, rather than they want them themselves. It seems to provide them with sustenance."") .addPlayer(HeadE.CALM, ""So they feed off our desire for things?"") .addNPC(ELNOCK_INQUISITOR, HeadE.CALM, ""Possibly. Either way, it seems that they almost exclusively collect things that people want, except their younglings who I infer haven't learnt the best things to collect yet."") .addPlayer(HeadE.CALM, ""So the more experienced implings have the more desirable items?"") .addNPC(ELNOCK_INQUISITOR, HeadE.CALM, ""That is my observation. Yes.""); ops.add(""Can I catch these implings, then?"") .addNPC(ELNOCK_INQUISITOR, HeadE.CALM, ""Indeed you may. In fact I encourage it. You will, however, require some equipment."") .addNPC(ELNOCK_INQUISITOR, HeadE.CALM, ""Firstly you will need a butterfly net in which to catch them and at least one special impling jar to store an impling."") .addNPC(ELNOCK_INQUISITOR, HeadE.CALM, ""You will also require some experience as a Hunter since these creatures are elusive. The more immature implings require less experience, but some of the rarer implings are extraordinarily hard to find and catch."") .addNPC(ELNOCK_INQUISITOR, HeadE.CALM, ""Once you have caught one, you may break the jar open and obtain the object the impling is carrying. Alternatively, you may exchange certain combinations of jars with me. I will return the jars to my clients. In"") .addNPC(ELNOCK_INQUISITOR, HeadE.CALM, ""exchange I will be able to provide you with some equipment that may help you hunt butterflies more effectively."") .addNPC(ELNOCK_INQUISITOR, HeadE.CALM, ""Also, beware. Those imps walking around the maze do not like the fact that their kindred spirits are being captured and will attempt to steal any full jars you have on you, setting the implings free."") .addPlayer(HeadE.CALM, ""I've heard I may find dragon equipment in Puro-Puro."") .addNPC(ELNOCK_INQUISITOR, HeadE.CALM, ""Have you indeed? Well, that may well be true, though bear in mind that implings are quite small so they are unlikely to be lugging a sizeable shield around with them. However, since it seems that dragon items are"") .addNPC(ELNOCK_INQUISITOR, HeadE.CALM, ""very desirable to humans then it certainly is possible that the most expert implings may try to obtain such equipment."") .addPlayer(HeadE.CALM, ""So, it's true then? Cool!"") .addNPC(ELNOCK_INQUISITOR, HeadE.CALM, ""I should warn you, though, if the impling is strong enough to collect dragon equipment, then you will have to be very skilled at hunting implings in order to catch them."") .addNext(() -> player.getTempAttribs().setB(""puropuro_introduction"", true)); }); } else { addNPC(ELNOCK_INQUISITOR, HeadE.CALM, ""Ah, good day, it's you again. What can I do for you?""); addOptions(""Choose an option:"", ops -> { ops.add(""Can you remind me how to catch implings again?"") .addNPC(ELNOCK_INQUISITOR, HeadE.CALM, ""Certainly."") .addNPC(ELNOCK_INQUISITOR, HeadE.CALM, ""In Puro-Puro, you will need a butterfly net to catch an impling and at least one special impling jar to store them in. "") .addNPC(ELNOCK_INQUISITOR, HeadE.CALM, ""You will also require some experience as a Hunter, since these creatures are elusive. The more immature implings require less experience, but some of the rarer implings are extraordinarily hard to find and catch."") .addNPC(ELNOCK_INQUISITOR, HeadE.CALM, ""Some of these implings have escaped to Gielinor, but have been exhausted by the journey. Assuming you are experienced enough, you can catch them without needing any equipment."") .addNPC(ELNOCK_INQUISITOR, HeadE.CALM, ""Once you have caught an impling in a jar, you can break the jar open to obtain the impling's object, or you can exchange certain combinations of jars with me. I will then return the jars to my clients. In exchange, I will provide"") .addNPC(ELNOCK_INQUISITOR, HeadE.CALM, ""equipment that helps you hunt implings and butterflies more effectively."") .addNPC(ELNOCK_INQUISITOR, HeadE.CALM, ""But beware: imps in the maze do not like their kind being captured, and will attempt to steal any full jars you have on you, setting the implings free."") .addOptions(""Choose an option:"", ops2 -> { ops2.add(""Tell me more about these jars."") .addNPC(ELNOCK_INQUISITOR, HeadE.CALM, ""You cannot use an ordinary butterfly jar as a container, as the implings escape from them with ease. I have, however, done some investigating and come up with a solution: if a butterfly jar is coated with a thin layer of a"") .addNPC(ELNOCK_INQUISITOR, HeadE.CALM, ""substance that is noxious to them, implings become incapable of escape."") .addPlayer(HeadE.CALM, "" What substance is that, then?"") .addNPC(ELNOCK_INQUISITOR, HeadE.CALM, ""I have tried a few experiments with the help of a friend back home, and it turns out that a combination of anchovy oil and flowers - marigolds, rosemary or nasturtiums - will work."") .addPlayer(HeadE.CALM, "" How do you make anchovy oil then?"") .addNPC(ELNOCK_INQUISITOR, HeadE.CALM, ""I'd grind up some cooked anchovies and pass them through a sieve."") .addPlayer(HeadE.CALM, "" Where do I make these jars?"") .addNPC(ELNOCK_INQUISITOR, HeadE.CALM, ""Well, I believe there is a chemist in Rimmington that has a small still that you could use."") .addPlayer(HeadE.CALM, "" Is there anywhere I can buy these jars?"") .addNPC(ELNOCK_INQUISITOR, HeadE.CALM, ""Well, I may be able to sell you a few, although I don't have an infinite supply. I can also offer several empty jars in exchange for any full ones you have.""); ops2.add(""Tell me more about these thieving imps."") .addNPC(ELNOCK_INQUISITOR, HeadE.CALM, ""Imps and implings appear to be related, and the imps here are quite protective of their smaller relations. If you allow them to get too close then they will attempt to steal jarred implings from your pack, if you have them."") .addNPC(ELNOCK_INQUISITOR, HeadE.CALM, ""They will then set them free, dropping your jar on the floor. So, if you're quick, you may be able to catch it again. "") .addNPC(ELNOCK_INQUISITOR, HeadE.CALM, ""I have some impling deterrent which I may trade if you prove that you can catch implings well.""); ops2.add(""So, what's this equipment you can provide, then?"") .addNPC(ELNOCK_INQUISITOR, HeadE.CALM, ""I have been given permission by my clients to give three pieces of equipment to able hunters. "") .addNPC(ELNOCK_INQUISITOR, HeadE.CALM, ""Firstly, I have some imp deterrent. If you bring me three baby implings, two young implings and one gourmet impling already jarred, I will give you a vial. Imps don't like the smell, so they will be less likely to steal jarred implings"") .addNPC(ELNOCK_INQUISITOR, HeadE.CALM, ""from you."") .addNPC(ELNOCK_INQUISITOR, HeadE.CALM, ""Secondly, I have magical butterfly nets. If you bring me three gourmet implings, two earth implings and one essence impling I will give you a new net. It will help you catch both implings and butterflies. "") .addNPC(ELNOCK_INQUISITOR, HeadE.CALM, ""Lastly, I have magical jar generators. If you bring me three essence implings, two eclectic implings and one nature impling I will give you a jar generator. This object will create either butterfly or impling jars (up to a limited"") .addNPC(ELNOCK_INQUISITOR, HeadE.CALM, ""number of charges) without having to carry a pack full of them. ""); if (player.getBool(""puropuro_equipment_claimed"")) ops2.add(""Do you have some spare equipment I can use?"") .addNPC(ELNOCK_INQUISITOR, HeadE.CALM, ""I have already given you some equipment."") .addNPC(ELNOCK_INQUISITOR, HeadE.CALM, ""If you are ready to start hunting implings, then enter the main part of the maze. Just push through the wheat that surrounds the centre of the maze and get catching!""); else ops2.add(""Do you have some spare equipment I can use?"") .addNPC(ELNOCK_INQUISITOR, HeadE.CALM, ""Yes! I have some spare equipment for you."") .addNext(() -> { player.getInventory().addItemDrop(new Item(10010, 1)); player.getInventory().addItemDrop(new Item(11260, 7)); player.save(""puropuro_equipment_claimed"", true); }) .addNPC(ELNOCK_INQUISITOR, HeadE.CALM, ""There you go. You have everything you need now."") .addNPC(ELNOCK_INQUISITOR, HeadE.CALM, ""If you are ready to start hunting implings, then enter the main part of the maze. Just push through the wheat that surrounds the centre of the maze and get catching!""); }); ops.add(""Can I trade some jarred implings, please?"").addNext(() -> openPuroPuroInterface(player)); ops.add(""Can I buy a few impling jars?"").addNext(() -> ShopsHandler.openShop(player, ""elnocks_backup_supply"")); if (player.getBool(""puropuro_equipment_claimed"")) ops.add(""Do you have some spare equipment I can use?"") .addNPC(ELNOCK_INQUISITOR, HeadE.CALM, ""I have already given you some equipment."") .addNPC(ELNOCK_INQUISITOR, HeadE.CALM, ""If you are ready to start hunting implings, then enter the main part of the maze. Just push through the wheat that surrounds the centre of the maze and get catching!""); else ops.add(""Do you have some spare equipment I can use?"") .addNPC(ELNOCK_INQUISITOR, HeadE.CALM, ""Yes! I have some spare equipment for you."") .addNext(() -> { player.getInventory().addItemDrop(new Item(10010, 1)); player.getInventory().addItemDrop(new Item(11260, 7)); player.save(""puropuro_equipment_claimed"", true); }) .addNPC(ELNOCK_INQUISITOR, HeadE.CALM, ""There you go. You have everything you need now."") .addNPC(ELNOCK_INQUISITOR, HeadE.CALM, ""If you are ready to start hunting implings, then enter the main part of the maze. Just push through the wheat that surrounds the centre of the maze and get catching!""); }); } } public enum ElnocksShopSelections { IMP_REPELLENT(20, new Item(11262, 1), new Item[] { new Item(11238, 3), new Item(11240, 2), new Item(11242, 1) }), MAGIC_BUTTERFLY_NET(22, new Item(11259, 1), new Item[] { new Item(11242, 3), new Item(11244, 2), new Item(11246, 1) }), JAR_GENERATOR(24, new Item(11258, 1), new Item[] { new Item(11246, 3), new Item(11248, 2), new Item(11250, 1) }), IMPLING_JAR(26, new Item(11260, 3), null); private final int componentId; private final Item purchased; private final Item[] currency; ElnocksShopSelections(int componentId, Item purchased, Item[] currency) { this.componentId = componentId; this.purchased = purchased; this.currency = currency; } public int getComponentId() { return componentId; } public Item getPurchased() { return purchased; } public Item[] getCurrency() { return currency; } public static final Map ElnocksShop = new HashMap<>(); static { for (ElnocksShopSelections selected : ElnocksShopSelections.values()) { ElnocksShop.put(selected.componentId, selected); } } public static ElnocksShopSelections forComponent(int componentId) { return ElnocksShop.get(componentId); } } public static NPCClickHandler handleElnock = new NPCClickHandler(new Object[] { ELNOCK_INQUISITOR }, e -> { switch(e.getOption()) { case ""Talk-to"" -> e.getPlayer().startConversation(new ElnockInquisitor(e.getPlayer())); case ""Trade"" -> ShopsHandler.openShop(e.getPlayer(), ""elnocks_backup_supply""); case ""Exchange"" -> openPuroPuroInterface(e.getPlayer()); case ""Quick-start"" -> e.getPlayer().sendMessage(""If you are ready to start hunting implings, then enter the main part of the maze.""); default -> e.getPlayer().sendMessage(""Unhandled option.""); } }); public static void openPuroPuroInterface(Player player) { player.getInterfaceManager().sendInterface(540); for (int component = 60; component < 64; component++) player.getPackets().setIFHidden(540, component, false); player.setCloseInterfacesEvent(() -> player.getTempAttribs().removeI(""puropuro_selection"")); } public static ButtonClickHandler handlePuroPuroShopButtons = new ButtonClickHandler(540, e -> { switch(e.getComponentId()) { case 69 -> confirmPuroPuroSelection(e.getPlayer()); case 71 -> ShopsHandler.openShop(e.getPlayer(), ""elnocks_backup_supply""); default -> e.getPlayer().getTempAttribs().setI(""puropuro_selection"", e.getComponentId()); } }); public static void confirmPuroPuroSelection(Player player) { if (player.getTempAttribs().getI(""puropuro_selection"") == -1) return; ElnocksShopSelections selected = ElnocksShopSelections.forComponent(player.getTempAttribs().getI(""puropuro_selection"")); if (selected == null) { player.sendMessage(""You must select an option to exchange.""); return; } if (selected.currency == null) { int currency = ImpDefender.getLowestImplingJar(player); if (currency > -1) { player.getInventory().deleteItem(currency, 1); player.getInventory().addItem(selected.purchased); player.closeInterfaces(); player.sendMessage(""You exchange the required item for: 3 x "" + selected.purchased.getName().toLowerCase() + ""s.""); return; } } if (selected.currency == null || !player.getInventory().containsItems(selected.currency)) { player.sendMessage(""You don't have the required items.""); return; } player.getInventory().removeItems(selected.currency); player.getInventory().addItem(selected.purchased); player.closeInterfaces(); player.sendMessage(""You exchange the required items for: "" + selected.purchased.getName().toLowerCase() + "".""); } }" "package com.rs.game.content.skills.hunter.puropuro; @PluginEventHandler public class ImpDefender extends NPC { public ImpDefender(Tile tile) { super(6074, tile); setCollisionStrategyType(CollisionStrategyType.NORMAL); WorldTasks.scheduleLooping(0, Ticks.fromSeconds(5), this::freeImplings); } public static NPCInstanceHandler toFunc = new NPCInstanceHandler(new Object[] { 6074 }, (npcId, tile) -> new ImpDefender(tile)); public void freeImplings() { List players = World.getPlayersInChunkRange(getChunkId(), 1); if (players.size() == 0) return; for (Player p : players) { if (p.withinDistance(Tile.of(getX(), getY(), getPlane()), 3)) { if (p.getInventory().containsItem(11262)) { Item i = p.getInventory().getItemById(11262); boolean used = (boolean)i.getMetaData(""used""); if (used) { i.setId(229); i.deleteMetaData(); } else i.addMetaData(""used"", true); p.sendMessage(""Your repellent protects you from the Imp Defender.""); if (Utils.random(10000) == 0) { p.faceEntity(this); p.setNextAnimation(new Animation(8991)); p.setNextForceTalk(new ForceTalk(""Swiper, no swiping!"")); } return; } if (Utils.random(10) == 0) { int jar = getLowestImplingJar(p); if (jar == -1) return; p.lock(); walkToAndExecute(p.getNearestTeleTile(1), () -> { p.faceEntity(this); p.getInventory().replace(jar, FlyingEntityHunter.IMPLING_JAR); setNextForceTalk(new ForceTalk(""Be Free!"")); }); p.unlock(); } } } } public static int getLowestImplingJar(Player p) { int jar = -1; for (Item i : p.getInventory().getItems().getItemsNoNull()) { if (FlyingEntities.forItem(i.getId()) != null) { if (jar == -1 || jar > i.getId()) jar = i.getId(); } } return jar; } }" "package com.rs.game.content.skills.hunter.puropuro; @PluginEventHandler public class MagicalWheat { public enum MagicWheat { SPAWN1(Tile.of(2565, 4310, 0), Tile.of(2565, 4311, 0)), SPAWN2(Tile.of(2568, 4329, 0), Tile.of(2568, 4330, 0)), SPAWN3(Tile.of(2571, 4315, 0), Tile.of(2571, 4316, 0)), SPAWN4(Tile.of(2574, 4310, 0), Tile.of(2574, 4311, 0)), SPAWN5(Tile.of(2577, 4327, 0), Tile.of(2577, 4328, 0)), SPAWN6(Tile.of(2576, 4338, 0), Tile.of(2576, 4339, 0)), SPAWN7(Tile.of(2580, 4325, 0), Tile.of(2580, 4326, 0)), SPAWN8(Tile.of(2581, 4337, 0), Tile.of(2582, 4337, 0)), SPAWN9(Tile.of(2582, 4346, 0), Tile.of(2583, 4346, 0)), SPAWN10(Tile.of(2583, 4296, 0), Tile.of(2584, 4296, 0)), SPAWN11(Tile.of(2583, 4303, 0), Tile.of(2583, 4304, 0)), SPAWN12(Tile.of(2584, 4329, 0), Tile.of(2584, 4330, 0)), SPAWN13(Tile.of(2584, 4335, 0), Tile.of(2584, 4336, 0)), SPAWN14(Tile.of(2587, 4306, 0), Tile.of(2587, 4307, 0)), SPAWN15(Tile.of(2582, 4332, 0), Tile.of(2582, 4333, 0)), SPAWN16(Tile.of(2586, 4302, 0), Tile.of(2587, 4302, 0)), SPAWN17(Tile.of(2586, 4334, 0), Tile.of(2587, 4334, 0)), SPAWN18(Tile.of(2585, 4309, 0), Tile.of(2585, 4310, 0)), SPAWN19(Tile.of(2590, 4299, 0), Tile.of(2591, 4299, 0)), SPAWN20(Tile.of(2594, 4329, 0), Tile.of(2594, 4330, 0)), SPAWN21(Tile.of(2595, 4308, 0), Tile.of(2596, 4308, 0)), SPAWN22(Tile.of(2595, 4343, 0), Tile.of(2596, 4343, 0)), SPAWN23(Tile.of(2596, 4331, 0), Tile.of(2597, 4331, 0)), SPAWN24(Tile.of(2598, 4309, 0), Tile.of(2598, 4310, 0)), SPAWN25(Tile.of(2598, 4335, 0), Tile.of(2598, 4336, 0)), SPAWN26(Tile.of(2599, 4305, 0), Tile.of(2600, 4305, 0)), SPAWN27(Tile.of(2600, 4293, 0), Tile.of(2601, 4293, 0)), SPAWN28(Tile.of(2601, 4332, 0), Tile.of(2601, 4333, 0)), SPAWN29(Tile.of(2601, 4340, 0), Tile.of(2602, 4340, 0)), SPAWN30(Tile.of(2602, 4306, 0), Tile.of(2602, 4307, 0)), SPAWN31(Tile.of(2603, 4303, 0), Tile.of(2603, 4304, 0)), SPAWN32(Tile.of(2603, 4313, 0), Tile.of(2603, 4314, 0)), SPAWN33(Tile.of(2604, 4338, 0), Tile.of(2604, 4339, 0)), SPAWN34(Tile.of(2606, 4328, 0), Tile.of(2606, 4329, 0)), SPAWN35(Tile.of(2609, 4309, 0), Tile.of(2609, 4310, 0)), SPAWN36(Tile.of(2612, 4323, 0), Tile.of(2612, 4324, 0)), SPAWN37(Tile.of(2615, 4314, 0), Tile.of(2615, 4315, 0)), SPAWN38(Tile.of(2618, 4304, 0), Tile.of(2618, 4305, 0)); private final Tile tile1, tile2; MagicWheat(Tile tile1, Tile tile2) { this.tile1 = tile1; this.tile2 = tile2; } public Tile getTile1() { return tile1; } public Tile getTile2() { return tile2; } } @ServerStartupEvent public static void initMagicalWheat() { for (MagicWheat wheat : MagicWheat.values()) ChunkManager.permanentlyPreloadRegions(wheat.tile1.getRegionId(), wheat.tile2.getRegionId()); final int NO_WHEAT = 25000; final int HAS_WHEAT = 25021; final int GROWING_WHEAT = 25022; final int WILTING_WHEAT = 25023; WorldTasks.scheduleLooping(0, 25, () -> { for (MagicWheat wheat : MagicWheat.values()) { if (Utils.random(0, 4) != 0) continue; GameObject obj = World.getObject(wheat.getTile1()); boolean growing = (obj == null || obj.getId() != HAS_WHEAT); int rotation = (wheat.getTile1().getX() != wheat.getTile2().getX() ? 1 : 0); WorldTasks.scheduleTimer(tick -> { if (tick == 0) { if (growing) { World.spawnObject(new GameObject(GROWING_WHEAT, ObjectType.GROUND_DECORATION, rotation, wheat.getTile1())); World.spawnObject(new GameObject(GROWING_WHEAT, ObjectType.GROUND_DECORATION, rotation+2, wheat.getTile2())); } else { World.spawnObject(new GameObject(WILTING_WHEAT, ObjectType.GROUND_DECORATION, rotation, wheat.getTile1())); World.spawnObject(new GameObject(WILTING_WHEAT, ObjectType.GROUND_DECORATION, rotation+2, wheat.getTile2())); } } if (tick == 1) { if (growing) { World.sendObjectAnimation(World.getObject(wheat.getTile1()), new Animation(6596)); World.sendObjectAnimation(World.getObject(wheat.getTile2()), new Animation(6596)); } else { World.sendObjectAnimation(World.getObject(wheat.getTile1()), new Animation(6599)); World.sendObjectAnimation(World.getObject(wheat.getTile2()), new Animation(6599)); } } if (tick == 6 && growing) { World.spawnObject(new GameObject(HAS_WHEAT, ObjectType.GROUND_DECORATION, rotation, wheat.getTile1())); World.spawnObject(new GameObject(HAS_WHEAT, ObjectType.GROUND_DECORATION, rotation, wheat.getTile2())); return false; } if (tick == 10) { World.spawnObject( new GameObject(NO_WHEAT, ObjectType.GROUND_DECORATION, rotation, wheat.getTile1())); World.spawnObject( new GameObject(NO_WHEAT, ObjectType.GROUND_DECORATION, rotation, wheat.getTile2())); return false; } return true; }); } }); } public static ObjectClickHandler pushThrough = new ObjectClickHandler(new Object[] { ""Magical wheat"" }, e -> { if (e.isAtObject()) { e.getPlayer().faceObject(e.getObject()); int speed = Utils.randomInclusive(0, 2) * 2; int finalSpeed = e.getPlayer().hasEffect(Effect.FARMERS_AFFINITY) ? 3 + speed : 6 + speed; Tile finalTile = e.getPlayer().getFrontfacingTile(2); GameObject loc = World.getObject(finalTile); if (loc != null && loc.getDefinitions(e.getPlayer()).getName().equals(""Magical wheat"")) { e.getPlayer().sendMessage(""The wheat here seems unusually stubborn. You cannot push through.""); return; } e.getPlayer().lock(); switch (speed) { case 0 -> { if (e.getPlayer().hasEffect(Effect.FARMERS_AFFINITY)) e.getPlayer().sendMessage(""You use your strength to push through the wheat in the most efficient fashion.""); else e.getPlayer().sendMessage(""You use your strength to push through the wheat.""); } case 2 -> e.getPlayer().sendMessage(""You push through the wheat.""); case 4 -> e.getPlayer().sendMessage(""You push through the wheat. It's hard work, though.""); } WorldTasks.schedule(0, () -> e.getPlayer().forceMove(finalTile, (6573 + speed / 2), 0, finalSpeed * 30, () -> { if (e.getPlayer().getO(""ppStrengthEnabled"") == null) e.getPlayer().save(""ppStrengthEnabled"", true); if (e.getPlayer().getBool(""ppStrengthEnabled"")) e.getPlayer().getSkills().addXp(Skills.STRENGTH, 4 - speed); })); } }); }" "package com.rs.game.content.skills.hunter.puropuro; @PluginEventHandler public class PuroPuroController extends Controller { private final Tile entranceTile; public PuroPuroController(Tile tile) { this.entranceTile = tile; } @Override public void start() { player.getPackets().setBlockMinimapState(2); player.getInterfaceManager().sendOverlay(169); } @Override public void forceClose() { player.getPackets().setBlockMinimapState(0); player.getInterfaceManager().removeOverlay(); } @Override public void onTeleported(TeleType type) { player.getControllerManager().forceStop(); } @Override public boolean logout() { return false; } @Override public boolean login() { start(); return false; } @Override public boolean processObjectClick1(GameObject object) { switch (object.getId()) { case 25014: player.getControllerManager().forceStop(); Magic.sendTeleportSpell(player, 6601, -1, 1118, -1, 0, 0, entranceTile, 9, false, TeleType.OBJECT, null); return true; } return true; } }" "package com.rs.game.content.skills.hunter.tracking; public class Burrow { public Burrow(int burrowId, Tile burrowTile, Trail... next) { List next1 = new ArrayList<>(); next1.addAll(Arrays.asList(next)); } }" "package com.rs.game.content.skills.hunter.tracking; public enum Track { PISC_1(new Burrow(19439, Tile.of(2353, 3595, 0), new Trail(19375, Tile.of(2347, 3607, 0), 2976, 4, new Trail(19428, Tile.of(2355, 3601, 0), 2978, 3), new Trail(19428, Tile.of(2354, 3609, 0), 2983, 3), new Trail(19376, Tile.of(2348, 3612, 0), 2988, 3, new Trail(19428, Tile.of(2354, 3609, 0), 2989, 3), new Trail(29428, Tile.of(2351, 3619, 0), 2990, 3))), new Trail(19375, Tile.of(2347, 3607, 0), 2976, 4) )); private Track(Burrow burrow) { } }" "package com.rs.game.content.skills.hunter.tracking; public class Trail { private Trail prev; public Trail(int nextObj, Tile nextObjTile, int varbit, int value, Trail... nexts) { if (nexts.length <= 0) return; List next = new ArrayList<>(); for (Trail t : nexts) { t.prev = this; next.add(t); } } }" "package com.rs.game.content.skills.hunter.traps; public class BoxStyleTrap extends OwnedObject { private static final int[] VALID_BAITS = { 5972, 12535 }; public enum Status { IDLE, CATCHING, SUCCESS, FAIL } protected BoxTrapType type; private int bait = -1; private int life = 0; private Status status = Status.IDLE; private BoxHunterType npcTrapped; public BoxStyleTrap(Player player, BoxTrapType type, Tile tile) { super(player, type.getObjectId(), ObjectType.SCENERY_INTERACT, 0, tile); this.type = type; if (type != BoxTrapType.DEAD_FALL) routeType = RouteType.WALK_ONTO; } public BoxStyleTrap(Player player, BoxTrapType type, Tile tile, int setId, int setRotation) { super(player, setId, ObjectType.SCENERY_INTERACT, setRotation, tile); this.type = type; if (type != BoxTrapType.DEAD_FALL) routeType = RouteType.WALK_ONTO; } @Override public void tick(Player player) { life++; if (life >= 100) { expire(player); destroy(); } } public void expire(Player player) { World.addGroundItem(new Item(type.getId(), 1), Tile.of(this.getTile()), player, true, 60); if (bait != -1) World.addGroundItem(new Item(bait, 1), Tile.of(this.getTile()), player, true, 60); } public void handleCatch(BoxHunterNPC npc, boolean success) { BoxHunterType npcType = npc.getType(getOwner()); if (npcType == null) return; if (type == BoxTrapType.BIRD_SNARE) setId(success ? npcType.getObjectCatch() : 19176); else if (type == BoxTrapType.DEAD_FALL) setId(success ? npcType.getObjectCatch() : 19219); else setId(npcType.getObjectCatch()); WorldTasks.schedule(new Task() { @Override public void run() { if (!success && type == BoxTrapType.DEAD_FALL) { destroy(); return; } setNpcTrapped(npcType); setId(success ? npcType.getObjectSuccess() : npcType.getObjectFail()); setStatus(success ? Status.SUCCESS : Status.FAIL); if (success) { npc.setNextAnimation(new Animation(-1)); npc.setRespawnTask(); } } }, 0); } public void dismantle(Player player) { destroy(); player.setNextAnimation(getTrapType().getPickUpAnimation()); if (getTrapType() == BoxTrapType.TREE_NET) player.getInventory().addItemDrop(954, 1); player.getInventory().addItemDrop(getTrapType().getId(), 1); if (bait != -1) player.getInventory().addItemDrop(bait, 1); } public void check(Player player) { destroy(); player.incrementCount(NPCDefinitions.getDefs(getNpcTrapped().getNpcId()).getName()+"" trapped""); player.setNextAnimation(getTrapType().getPickUpAnimation()); for (Item i : getNpcTrapped().getItems(player)) { if (i == null || DropCleanersKt.bonecrush(player, i) || DropCleanersKt.herbicide(player, i)) continue; player.getInventory().addItemDrop(i); } if (getTrapType() != BoxTrapType.MAGIC_BOX && getTrapType() != BoxTrapType.DEAD_FALL) player.getInventory().addItemDrop(getTrapType().getId(), 1); if (getTrapType() == BoxTrapType.TREE_NET) player.getInventory().addItemDrop(954, 1); if (getTrapType() == BoxTrapType.MARASAMAW_PLANT) player.getSkills().addXp(Constants.HUNTER, getNpcTrapped().getXp() * player.getEquipment().getWitchDoctorBoost()); else player.getSkills().addXp(Constants.HUNTER, getNpcTrapped().getXp()); player.getInventory().refresh(); } public BoxTrapType getTrapType() { return type; } public int getBait() { return bait; } public boolean tryBait(Player player, int bait) { if (Arrays.binarySearch(VALID_BAITS, bait) < 0) { player.sendMessage(""That's not something you'd want to use to bait a trap with.""); return false; } if (!player.getInventory().containsItem(bait)) return false; if (this.bait != -1) { player.sendMessage(""This trap has already been baited.""); return false; } player.getInventory().deleteItem(bait, 1); this.bait = bait; player.sendMessage(""You bait the trap with the "" + ItemDefinitions.getDefs(bait).name.toLowerCase() + "".""); return true; } public int getLife() { return life; } public void setStatus(Status status) { this.status = status; life = 0; } public Status getStatus() { return status; } public void setLife(int life) { this.life = life; } public BoxHunterType getNpcTrapped() { return npcTrapped; } public void setNpcTrapped(BoxHunterType npcTrapped) { this.npcTrapped = npcTrapped; } }" "package com.rs.game.content.skills.hunter.traps; public class DeadfallTrap extends BoxStyleTrap { public DeadfallTrap(Player player, GameObject orig) { super(player, BoxTrapType.DEAD_FALL, orig.getTile()); setRotation(orig.getRotation()); routeType = RouteType.NORMAL; } }" "package com.rs.game.content.skills.hunter.traps; public class MarasamawPlant extends BoxStyleTrap { public MarasamawPlant(Player player, Tile tile) { super(player, BoxTrapType.MARASAMAW_PLANT, tile); } @Override public void handleCatch(BoxHunterNPC npc, boolean success) { BoxHunterType npcType = npc.getType(getOwner()); if (npcType == null) return; if (success) { setId(npcType.getObjectCatch()); npc.setNextAnimation(new Animation(-1)); npc.setRespawnTask(); } else setId(npcType.getObjectFail()); setStatus(Status.CATCHING); if (success) WorldTasks.schedule(new Task() { @Override public void run() { World.sendObjectAnimation(MarasamawPlant.this, new Animation(3300)); } }, 0); WorldTasks.schedule(new Task() { @Override public void run() { if (success) setId(npcType.getObjectSuccess()); setNpcTrapped(npcType); setStatus(success ? Status.SUCCESS : Status.FAIL); } }, 3); } }" "package com.rs.game.content.skills.hunter.traps; public class NetTrap extends BoxStyleTrap { private enum TreeType { SWAMP(19679, 19681, 19678, 19676, 19677, 19674, 19675), DESERT(19652, 19651, 19650, 19657, 19656, 19655, 19654), LAVA(19663, 19665, 19662, 19660, 19661, 19658, 19659), WILDY(19671, 19673, 19670, 19668, 19669, 19666, 19667), SQUIRRELS(28564, 28566, 28563, 28561, 28562, 28750, 28751); private final int base; private final int net; private final int setUp; private final int failing; private final int failed; private final int catching; private final int caught; private static final Map BY_BASE = new HashMap<>(); static { for (TreeType t : TreeType.values()) BY_BASE.put(t.base, t); } public static TreeType fromBase(int base) { return BY_BASE.get(base); } private TreeType(int base, int net, int setUp, int failing, int failed, int catching, int caught) { this.base = base; this.setUp = setUp; this.failing = failing; this.failed = failed; this.catching = catching; this.caught = caught; this.net = net; } } private OwnedObject tree; private final TreeType treeType; public NetTrap(Player player, Tile tile, GameObject tree) { super(player, BoxTrapType.TREE_NET, tile, TreeType.fromBase(tree.getId()).net, tree.getRotation()); treeType = TreeType.fromBase(tree.getId()); if (tree != null) this.tree = new OwnedObject(player, tree, treeType.setUp); } public NetTrap(Player player, Tile tile, TreeType type, int caught) { super(player, BoxTrapType.TREE_NET, tile, caught, 0); this.treeType = type; } @Override public void onCreate() { if (tree != null) tree.createReplace(); } @Override public void onDestroy() { if (tree != null) tree.destroy(); } @Override public void expire(Player player) { Tile tile = Tile.of(this.getTile()); if (tree == null) tile = tile.transform(rotation == 1 ? 1 : rotation == 3 ? -1 : 0, rotation == 0 ? 1 : rotation == 2 ? -1 : 0, 0); World.addGroundItem(new Item(954, 1), tile, player, true, 60); World.addGroundItem(new Item(303, 1), tile, player, true, 60); } @Override public void handleCatch(BoxHunterNPC npc, boolean success) { BoxHunterType npcType = npc.getType(getOwner()); if (npcType == null) return; destroy(); NetTrap compTrap = new NetTrap(getOwner(), tree.getTile().transform(rotation == 3 ? -1 : 0, rotation == 2 ? -1 : 0, 0), treeType, success ? treeType.catching : treeType.failing); compTrap.setRouteType(RouteType.NORMAL); compTrap.setRotation(tree.getRotation()); compTrap.createReplace(); if (success) { npc.setNextAnimation(new Animation(-1)); npc.setRespawnTask(); } WorldTasks.schedule(0, () -> { compTrap.setNpcTrapped(npcType); compTrap.setId(success ? treeType.caught : treeType.failed); compTrap.setStatus(success ? Status.SUCCESS : Status.FAIL); }); } }" "package com.rs.game.content.skills.magic; @PluginEventHandler public class Alchemy { public static InterfaceOnInterfaceHandler handleAlchSuperheat = new InterfaceOnInterfaceHandler(192, new int[] { 38, 50, 59 }, Inventory.INVENTORY_INTERFACE, null, e -> { Item item = e.getPlayer().getInventory().getItem(e.getToSlotId()); if (item == null) return; switch(e.getFromComponentId()) { case 38 -> handleAlchemy(e.getPlayer(), item, true, true); case 50 -> handleSuperheat(e.getPlayer(), item, true); case 59 -> handleAlchemy(e.getPlayer(), item, false, true); } }); public static boolean handleSuperheat(Player player, Item item, boolean useRunes) { if (useRunes) player.getInterfaceManager().openTab(Sub.TAB_MAGIC); if (!player.canCastSpell() || !Magic.checkMagicAndRunes(player, 43, false, useRunes ? new RuneSet(Rune.NATURE, 1, Rune.FIRE, 4) : null)) return false; player.stopAll(false, false, true); SmeltingBar bar = SmeltingBar.forOre(player, item.getId()); if (bar == null) { player.sendMessage(""You can only cast this spell on an ore.""); return false; } if (!player.getInventory().containsItem(bar.getItemsRequired()[0].getId(), bar.getItemsRequired()[0].getAmount())) { player.simpleDialogue(""You need "" + bar.getItemsRequired()[0].getDefinitions().getName() + "" to create a "" + bar.getProducedBar().getDefinitions().getName() + "".""); return false; } if (bar.getItemsRequired().length > 1) if (!player.getInventory().containsItem(bar.getItemsRequired()[1].getId(), bar.getItemsRequired()[1].getAmount()) && !(bar.getItemsRequired()[1].getId() == 453 && (player.getI(""coalBag"")+player.getInventory().getAmountOf(453)) >= bar.getItemsRequired()[1].getAmount())) { player.simpleDialogue(""You need "" + bar.getItemsRequired()[1].getDefinitions().getName() + "" to create a "" + bar.getProducedBar().getDefinitions().getName() + "".""); return false; } if (player.getSkills().getLevel(Constants.SMITHING) < bar.getLevelRequired()) { player.simpleDialogue(""You need a Smithing level of at least "" + bar.getLevelRequired() + "" to smelt "" + bar.getProducedBar().getDefinitions().getName()); return false; } Magic.checkMagicAndRunes(player, 43, true, useRunes ? new RuneSet(Rune.NATURE, 1, Rune.FIRE, 4) : null); player.anim(725); player.spotAnim(148, 0, 96); for (Item itemReq : bar.getItemsRequired()) if (itemReq.getId() == 453 && player.getInventory().containsItem(18339) && player.getI(""coalBag"") > 0) { int coalBag = player.getI(""coalBag""); if (coalBag > itemReq.getAmount()) player.save(""coalBag"", coalBag - itemReq.getAmount()); else { player.save(""coalBag"", 0); player.getInventory().deleteItem(453, itemReq.getAmount()-coalBag); } } else player.getInventory().deleteItem(itemReq.getId(), itemReq.getAmount()); player.getInventory().addItem(bar.getProducedBar().getId(), 1); player.getSkills().addXp(Constants.MAGIC, 53); if (bar == SmeltingBar.GOLD && player.getEquipment().getGlovesId() == 776) player.getSkills().addXp(Constants.SMITHING, 56.2); else player.getSkills().addXp(Constants.SMITHING, bar.getExperience()); player.addSpellDelay(2); return true; } public static boolean handleAlchemy(Player player, Item item, boolean lowAlch, boolean useRunes) { if (useRunes) player.getInterfaceManager().openTab(Sub.TAB_MAGIC); if (!player.canCastSpell()) return false; if ((!ItemConstants.isTradeable(item)) || item.getId() == 995) { player.sendMessage(""You can't cast alchemy on that!""); return false; } if (lowAlch) { if (!Magic.checkMagicAndRunes(player, 21, true, useRunes ? new RuneSet(Rune.NATURE, 1, Rune.FIRE, 3) : null)) return false; } else if (!Magic.checkMagicAndRunes(player, 55, true, useRunes ? new RuneSet(Rune.NATURE, 1, Rune.FIRE, 5) : null)) return false; player.stopAll(false, false, true); ItemDefinitions def = ItemDefinitions.getDefs(item.getId()); if (def == null) return false; ItemDefinitions wDef = null; if (player.getEquipment().getItem(Equipment.WEAPON) != null) wDef = ItemDefinitions.getDefs(player.getEquipment().getWeaponId()); player.incrementCount(""Items alched""); if (lowAlch) { if (wDef != null && wDef.getName().toLowerCase().contains(""staff"")) { player.setNextAnimation(new Animation(9625)); player.setNextSpotAnim(new SpotAnim(1692)); } else { player.setNextAnimation(new Animation(712)); player.setNextSpotAnim(new SpotAnim(112)); } World.soundEffect(player.getTile(), 98); player.getInventory().deleteItem(item.getId(), 1); player.getInventory().addCoins(def.getSellPrice()); player.getSkills().addXp(Constants.MAGIC, 31); player.addSpellDelay(2); } else { if (wDef != null && wDef.getName().toLowerCase().contains(""staff"")) { player.setNextAnimation(new Animation(9633)); player.setNextSpotAnim(new SpotAnim(1693)); } else { player.setNextAnimation(new Animation(713)); player.setNextSpotAnim(new SpotAnim(113)); } World.soundEffect(player.getTile(), 98); //low alch id... high alch doesnt match osrs... reeeee player.getInventory().deleteItem(item.getId(), 1); player.getInventory().addCoins(def.getHighAlchPrice()); player.getSkills().addXp(Constants.MAGIC, 65); player.addSpellDelay(4); } return true; } }" "package com.rs.game.content.skills.magic; @PluginEventHandler public class BoltEnchanting { public enum Bolt { OPAL(14, 4, new RuneSet(Rune.COSMIC, 1, Rune.AIR, 2), 879, 9236, 9), SAPPHIRE(29, 7, new RuneSet(Rune.COSMIC, 1, Rune.WATER, 1, Rune.MIND, 1), 9337, 9240, 17), JADE(18, 14, new RuneSet(Rune.COSMIC, 1, Rune.EARTH, 2), 9335, 9237, 19), PEARL(22, 24, new RuneSet(Rune.COSMIC, 1, Rune.AIR, 2), 880, 9238, 29), EMERALD(32, 27, new RuneSet(Rune.COSMIC, 1, Rune.AIR, 3, Rune.NATURE, 1), 9338, 9241, 37), RED_TOPAZ(26, 29, new RuneSet(Rune.COSMIC, 1, Rune.FIRE, 2), 9336, 9239, 33), RUBY(35, 49, new RuneSet(Rune.COSMIC, 1, Rune.FIRE, 5, Rune.BLOOD, 1), 9339, 9242, 59), DIAMOND(38, 57, new RuneSet(Rune.COSMIC, 1, Rune.EARTH, 10, Rune.LAW, 2), 9340, 9243, 67), DRAGONSTONE(41, 68, new RuneSet(Rune.COSMIC, 1, Rune.EARTH, 15, Rune.SOUL, 1), 9341, 9244, 78), ONYX(44, 87, new RuneSet(Rune.COSMIC, 1, Rune.FIRE, 20, Rune.DEATH, 1), 9342, 9245, 97); private final int componentId; private final int levelRequired; private final RuneSet runes; private final int original; private final int product; private final double xp; Bolt(int componentId, int levelRequired, RuneSet runes, int original, int product, double xp) { this.componentId = componentId; this.levelRequired = levelRequired; this.runes = runes; this.original = original; this.product = product; this.xp = xp; } public static Bolt forId(int id) { for (Bolt bolt : Bolt.values()) if (bolt.getComponentId() == id) return bolt; return null; } public int getComponentId() { return componentId; } public int getLevelRequired() { return levelRequired; } public RuneSet getRunes() { return runes; } public int getProduct() { return product; } public int getOriginal() { return original; } public double getXp() { return xp; } } static class BoltEnchantingAction extends PlayerAction { private final Bolt bolt; private int amount; public BoltEnchantingAction(Bolt bolt, int amount) { this.bolt = bolt; this.amount = amount; } public boolean checkAll(Player player) { if (!Magic.checkRunes(player, false, bolt.getRunes())) return false; if (!player.getInventory().containsItem(bolt.getOriginal(), 10)) { player.sendMessage(""You don't have 10 bolts of this type to enchant.""); return false; } if (player.getSkills().getLevel(Constants.MAGIC) < bolt.getLevelRequired()) { player.sendMessage(""You need a magic level of ""+bolt.getLevelRequired()+"" to enchant those.""); return false; } if (!player.getInventory().hasFreeSlots()) { player.sendMessage(""You don't have enough inventory space.""); return false; } return true; } @Override public boolean start(Player player) { return checkAll(player); } @Override public boolean process(Player player) { return checkAll(player); } @Override public int processWithDelay(Player player) { if (!checkAll(player) || !Magic.checkRunes(player, true, bolt.getRunes())) return -1; amount--; player.getInventory().deleteItem(bolt.getOriginal(), 10); player.getInventory().addItem(bolt.getProduct(), 10); player.setNextAnimation(new Animation(4462)); player.setNextSpotAnim(new SpotAnim(759)); player.getSkills().addXp(Constants.MAGIC, bolt.getXp()); if (amount <= 0) return -1; return 2; } @Override public void stop(Player player) { } } public static ButtonClickHandler handleInter = new ButtonClickHandler(432, e -> { Bolt bolt = Bolt.forId(e.getComponentId()); if (bolt != null) switch(e.getPacket()) { case IF_OP1: //1 e.getPlayer().stopAll(); e.getPlayer().getActionManager().setAction(new BoltEnchantingAction(bolt, 1)); break; case IF_OP2: //5 e.getPlayer().stopAll(); e.getPlayer().getActionManager().setAction(new BoltEnchantingAction(bolt, 5)); break; case IF_OP3: //10 e.getPlayer().stopAll(); e.getPlayer().getActionManager().setAction(new BoltEnchantingAction(bolt, 10)); break; default: break; } }); }" "package com.rs.game.content.skills.magic; @PluginEventHandler public class Enchanting { public enum Sapphire { RING(1637, 2550), NECKLACE(1656, 3853), AMULET(1694, 1727), BRACELET(11072, 11074); private static final Map sapJewelry = new HashMap<>(); public static Sapphire forId(int unenchanted) { return sapJewelry.get(unenchanted); } static { for (Sapphire ring : Sapphire.values()) sapJewelry.put(ring.getUnenchanted(), ring); } private final int unenchanted; private final int enchanted; private Sapphire(int unenchanted, int enchanted) { this.unenchanted = unenchanted; this.enchanted = enchanted; } public int getUnenchanted() { return unenchanted; } public int getEnchanted() { return enchanted; } } public enum Emerald { RING(1639, 2552), NECKLACE(1658, 5521), AMULET(1696, 1729), BRACELET(11076, 11079); private static final Map sapJewelry = new HashMap<>(); public static Emerald forId(int unenchanted) { return sapJewelry.get(unenchanted); } static { for (Emerald ring : Emerald.values()) sapJewelry.put(ring.getUnenchanted(), ring); } private final int unenchanted; private final int enchanted; private Emerald(int unenchanted, int enchanted) { this.unenchanted = unenchanted; this.enchanted = enchanted; } public int getUnenchanted() { return unenchanted; } public int getEnchanted() { return enchanted; } } public enum Ruby { RING(1641, 2568), NECKLACE(1660, 11194), AMULET(1698, 1725), BRACELET(11085, 11088); private static final Map sapJewelry = new HashMap<>(); public static Ruby forId(int unenchanted) { return sapJewelry.get(unenchanted); } static { for (Ruby ring : Ruby.values()) sapJewelry.put(ring.getUnenchanted(), ring); } private final int unenchanted; private final int enchanted; private Ruby(int unenchanted, int enchanted) { this.unenchanted = unenchanted; this.enchanted = enchanted; } public int getUnenchanted() { return unenchanted; } public int getEnchanted() { return enchanted; } } public enum Diamond { RING(1643, 2570), NECKLACE(1662, 11090), AMULET(1700, 1731), BRACELET(11092, 11095); private static final Map sapJewelry = new HashMap<>(); public static Diamond forId(int unenchanted) { return sapJewelry.get(unenchanted); } static { for (Diamond ring : Diamond.values()) sapJewelry.put(ring.getUnenchanted(), ring); } private final int unenchanted; private final int enchanted; private Diamond(int unenchanted, int enchanted) { this.unenchanted = unenchanted; this.enchanted = enchanted; } public int getUnenchanted() { return unenchanted; } public int getEnchanted() { return enchanted; } } public enum Dragonstone { RING(1645, 20659), NECKLACE(1664, 11105), AMULET(1702, 1712), BRACELET(11115, 11118); private static final Map sapJewelry = new HashMap<>(); public static Dragonstone forId(int unenchanted) { return sapJewelry.get(unenchanted); } static { for (Dragonstone ring : Dragonstone.values()) sapJewelry.put(ring.getUnenchanted(), ring); } private final int unenchanted; private final int enchanted; private Dragonstone(int unenchanted, int enchanted) { this.unenchanted = unenchanted; this.enchanted = enchanted; } public int getUnenchanted() { return unenchanted; } public int getEnchanted() { return enchanted; } } public enum Onyx { RING(6575, 6583), NECKLACE(6577, 11128), AMULET(6581, 6585), BRACELET(11130, 11133); private static final Map sapJewelry = new HashMap<>(); public static Onyx forId(int unenchanted) { return sapJewelry.get(unenchanted); } static { for (Onyx ring : Onyx.values()) sapJewelry.put(ring.getUnenchanted(), ring); } private final int unenchanted; private final int enchanted; private Onyx(int unenchanted, int enchanted) { this.unenchanted = unenchanted; this.enchanted = enchanted; } public int getUnenchanted() { return unenchanted; } public int getEnchanted() { return enchanted; } } public static InterfaceOnInterfaceHandler handleEnchantSpells = new InterfaceOnInterfaceHandler(192, new int[] { 29, 41, 53, 61, 76, 88 }, Inventory.INVENTORY_INTERFACE, null, e -> { Item item = e.getPlayer().getInventory().getItem(e.getToSlotId()); if (item == null) return; handleEnchanting(e.getPlayer(), item, e.getFromComponentId()); }); public static void handleEnchanting(Player player, Item item, int comp1) { player.getInterfaceManager().openTab(Sub.TAB_MAGIC); if (!player.canCastSpell()) return; switch (comp1) { // Sapphire case 29: { Sapphire sapphire = Sapphire.forId(item.getId()); if (sapphire != null) { if (Magic.checkMagicAndRunes(player, 7, true, new RuneSet(Rune.COSMIC, 1, Rune.WATER, 1))) { player.setNextAnimation(new Animation(719)); player.setNextSpotAnim(new SpotAnim(114, 0, 100)); player.getInventory().deleteItem(sapphire.getUnenchanted(), 1); player.getInventory().addItem(sapphire.getEnchanted(), 1); player.getSkills().addXp(Constants.MAGIC, 17); player.addSpellDelay(2); } } else player.sendMessage(""That item cannot be enchanted with this spell.""); } break; // Emerald case 41: { Emerald emerald = Emerald.forId(item.getId()); if (emerald != null) { if (Magic.checkMagicAndRunes(player, 27, true, new RuneSet(Rune.COSMIC, 1, Rune.AIR, 3))) { player.setNextAnimation(new Animation(719)); player.setNextSpotAnim(new SpotAnim(114, 0, 100)); player.getInventory().deleteItem(emerald.getUnenchanted(), 1); player.getInventory().addItem(emerald.getEnchanted(), 1); player.getSkills().addXp(Constants.MAGIC, 37); player.addSpellDelay(2); } } else player.sendMessage(""That item cannot be enchanted with this spell.""); } break; // Ruby case 53: { Ruby ruby = Ruby.forId(item.getId()); if (ruby != null) { if (Magic.checkMagicAndRunes(player, 49, true, new RuneSet(Rune.COSMIC, 1, Rune.FIRE, 5))) { player.setNextAnimation(new Animation(719)); player.setNextSpotAnim(new SpotAnim(114, 0, 100)); player.getInventory().deleteItem(ruby.getUnenchanted(), 1); player.getInventory().addItem(ruby.getEnchanted(), 1); player.getSkills().addXp(Constants.MAGIC, 59); player.addSpellDelay(2); } } else player.sendMessage(""That item cannot be enchanted with this spell.""); } break; // Diamond case 61: { Diamond diamond = Diamond.forId(item.getId()); if (diamond != null) { if (Magic.checkMagicAndRunes(player, 57, true, new RuneSet(Rune.COSMIC, 1, Rune.EARTH, 10))) { player.setNextAnimation(new Animation(719)); player.setNextSpotAnim(new SpotAnim(114, 0, 100)); player.getInventory().deleteItem(diamond.getUnenchanted(), 1); player.getInventory().addItem(diamond.getEnchanted(), 1); player.getSkills().addXp(Constants.MAGIC, 67); player.addSpellDelay(2); } } else player.sendMessage(""That item cannot be enchanted with this spell.""); } break; // Dragonstone case 76: { Dragonstone dragonstone = Dragonstone.forId(item.getId()); if (dragonstone != null) { if (Magic.checkMagicAndRunes(player, 68, true, new RuneSet(Rune.COSMIC, 1, Rune.EARTH, 15, Rune.WATER, 15))) { player.setNextAnimation(new Animation(719)); player.setNextSpotAnim(new SpotAnim(114, 0, 100)); player.getInventory().deleteItem(dragonstone.getUnenchanted(), 1); player.getInventory().addItem(dragonstone.getEnchanted(), 1); player.getSkills().addXp(Constants.MAGIC, 78); player.addSpellDelay(2); } } else player.sendMessage(""That item cannot be enchanted with this spell.""); } break; // Onyx case 88: { Onyx onyx = Onyx.forId(item.getId()); if (onyx != null) { if (Magic.checkMagicAndRunes(player, 87, true, new RuneSet(Rune.COSMIC, 1, Rune.FIRE, 20, Rune.EARTH, 20))) { player.setNextAnimation(new Animation(719)); player.setNextSpotAnim(new SpotAnim(114, 0, 100)); player.getInventory().deleteItem(onyx.getUnenchanted(), 1); player.getInventory().addItem(onyx.getEnchanted(), 1); player.getSkills().addXp(Constants.MAGIC, 97); player.addSpellDelay(2); } } else player.sendMessage(""That item cannot be enchanted with this spell.""); } break; } } }" "package com.rs.game.content.skills.magic; @PluginEventHandler public class LodestoneAction extends PlayerAction { private final int HOME_ANIMATION = 16385, HOME_GRAPHIC = 3017; public static enum Lodestone { LUMBRIDGE(69836, null, 47, 10907, Tile.of(3233, 3222, 0)), BURTHORPE(69831, null, 42, 10902, Tile.of(2899, 3545, 0)), LUNAR_ISLE(69828, null, 39, -1, Tile.of(2085, 3915, 0)), BANDIT_CAMP(69827, null, 7, -1, Tile.of(3214, 2955, 0)), TAVERLY(69839, Achievement.RITE_OF_PASSAGE_1005, 50, 10910, Tile.of(2878, 3443, 0)), ALKARID(69829, Achievement.OPEN_SESAME_995, 40, 10900, Tile.of(3297, 3185, 0)), VARROCK(69840, Achievement.WELCOME_TO_BARTERTOWN_1006, 51, 10911, Tile.of(3214, 3377, 0)), EDGEVILLE(69834, Achievement.COMING_LIKE_A_GHOST_TOWN_1000, 45, 10905, Tile.of(3067, 3506, 0)), FALADOR(69835, Achievement.FOLLOW_THAT_STAR_1001, 46, 10906, Tile.of(2967, 3404, 0)), PORT_SARIM(69837, Achievement.SETTING_SAIL_1003, 48, 10908, Tile.of(3011, 3216, 0)), DRAYNOR_VILLAGE(69833, Achievement.AT_A_CROSSROADS_999, 44, 10904, Tile.of(3105, 3299, 0)), ARDOUGNE(69830, Achievement.OPEN_MARKET_996, 41, 10901, Tile.of(2634, 3349, 0)), CATHERBAY(69832, Achievement.BEACHHEAD_998, 43, 10903, Tile.of(2831, 3452, 0)), YANILLE(69841, Achievement.MAGICAL_MYSTERY_TOUR_1007, 52, 10912, Tile.of(2529, 3095, 0)), SEERS_VILLAGE(69838, Achievement.FIND_ENLIGHTENMENT_1004, 49, 10909, Tile.of(2689, 3483, 0)); private final int objectId; private final Achievement achievement; private final int component; private final int configId; private final Tile tile; public static Lodestone forComponent(int component) { for (Lodestone stone : Lodestone.values()) if (stone.component == component) return stone; return null; } public static Lodestone forObject(int objectId) { for (Lodestone stone : Lodestone.values()) if (stone.objectId == objectId) return stone; return null; } private Lodestone(int objectId, Achievement achievement, int component, int configId, Tile tile) { this.objectId = objectId; this.achievement = achievement; this.component = component; this.configId = configId; this.tile = tile; } public int getObjectId() { return objectId; } public Achievement getAchievement() { return achievement; } public int getConfigId() { return configId; } public Tile getTile() { return tile; } } public static ObjectClickHandler handleUnlock = new ObjectClickHandler(new Object[] { 69827, 69828, 69829, 69830, 69831, 69832, 69833, 69834, 69835, 69836, 69837, 69838, 69839, 69840, 69841 }, e -> { if (e.getOpNum() != ClientPacket.OBJECT_OP1) return; Lodestone stone = Lodestone.forObject(e.getObject().getId()); if (stone != null) e.getPlayer().unlockLodestone(stone, e.getObject()); }); public static ButtonClickHandler handleLodestoneButtons = new ButtonClickHandler(1092, e -> { e.getPlayer().stopAll(); Lodestone stone = Lodestone.forComponent(e.getComponentId()); if (stone == null || (stone == Lodestone.BANDIT_CAMP && !e.getPlayer().isQuestComplete(Quest.DESERT_TREASURE, ""to use this lodestone."")) || (stone == Lodestone.LUNAR_ISLE && !e.getPlayer().isQuestComplete(Quest.LUNAR_DIPLOMACY, ""to use this lodestone.""))) return; if (e.getPlayer().unlockedLodestone(stone)) e.getPlayer().getActionManager().setAction(new LodestoneAction(stone.getTile())); else e.getPlayer().sendMessage(""You have not unlocked this lodestone yet. Go find it and activate it!""); }); private int currentTime; private final Tile tile; public LodestoneAction(Tile tile) { this.tile = tile; } @Override public boolean start(final Player player) { Teleport tele = new Teleport(Tile.of(player.getTile()), tile, TeleType.MAGIC, null, null, null, true); if (!player.getControllerManager().processTeleport(tele)) return false; return process(player); } @Override public int processWithDelay(Player player) { if (currentTime++ == 0) { player.setNextAnimation(new Animation(HOME_ANIMATION)); player.setNextSpotAnim(new SpotAnim(HOME_GRAPHIC)); } else if (currentTime == 18) { player.lock(); player.getControllerManager().onTeleported(TeleType.MAGIC); if (player.getControllerManager().getController() == null) Teleport.checkDestinationControllers(player, tile); player.tele(tile); player.setNextFaceTile(tile.transform(0, -1, 0)); player.getTasks().scheduleTimer(""lodestoneArrive"", stage -> { if (stage == 0) { player.setNextAnimation(new Animation(HOME_ANIMATION+1)); player.setNextSpotAnim(new SpotAnim(HOME_GRAPHIC+1)); } else if (stage == 5) player.setNextAnimation(new Animation(16393)); else if (stage == 7) { player.tele(tile.transform(0, -1, 0)); player.setNextAnimation(new Animation(-1)); player.setNextSpotAnim(new SpotAnim(-1)); player.resetReceivedHits(); player.resetReceivedDamage(); player.unlock(); return false; } return true; }); } else if (currentTime == 19) return -1; return 0; } @Override public boolean process(Player player) { if (player.inCombat(10000) || player.hasBeenHit(10000)) { player.sendMessage(""You can't home teleport until 10 seconds after the end of combat.""); return false; } return true; } @Override public void stop(Player player) { if (currentTime < 18) { player.setNextAnimation(new Animation(-1)); player.setNextSpotAnim(new SpotAnim(-1)); } } }" "package com.rs.game.content.skills.magic; @PluginEventHandler public class Lunars { public static int[] unstrung = { 1673, 1675, 1677, 1679, 1681, 1683, 1714, 1720, 6579 }; public static int[] strung = { 1692, 1694, 1696, 1698, 1700, 1702, 1716, 1722, 6581 }; public static Player[] getNearPlayers(Player player, int distance, int maxTargets) { List possibleTargets = new ArrayList<>(); for (Player p2 : player.queryNearbyPlayersByTileRange(distance, p2 -> !p2.isDead() && p2 != player && p2.withinDistance(player.getTile(), distance))) { possibleTargets.add(p2); if (possibleTargets.size() == maxTargets) break; } return possibleTargets.toArray(new Player[0]); } public static boolean hasUnstrungs(Player player) { for (Item item : player.getInventory().getItems().array()) { if (item == null) continue; if (getStrungIndex(item.getId()) != -1) return true; } return false; } public static int getStrungIndex(int ammy) { for (int i = 0; i < unstrung.length; i++) if (unstrung[i] == ammy) return i; return -1; } public static int getPlankIdx(int logId) { for (int i = 0; i < SawmillOperator.logs.length; i++) if (SawmillOperator.logs[i] == logId) return i; return -1; } public static InterfaceOnInterfaceHandler handleLunarOnInventory = new InterfaceOnInterfaceHandler(430, new int[] { 33, 35, 50, 72, 49 }, Inventory.INVENTORY_INTERFACE, null, e -> { Item item = e.getPlayer().getInventory().getItem(e.getToSlotId()); if (item == null) return; switch (e.getFromComponentId()) { case 33 -> handlePlankMake(e.getPlayer(), item); case 35 -> handleTuneBanite(e.getPlayer(), item); case 50 -> handleRestorePotionShare(e.getPlayer(), item); case 72 -> handleLeatherMake(e.getPlayer(), item); case 49 -> handleBoostPotionShare(e.getPlayer(), item); } }); public static ButtonClickHandler handleRemoteFarmButtons = new ButtonClickHandler(1082, e -> { if (e.getPacket() == ClientPacket.IF_OP1) if (e.getPlayer().getTempAttribs().getB(""RemoteFarm"")) { // int[] names = new int[] { 30, 32, 34, 36, 38, 49, 51, 53, 55, 57, 59, 62, 64, 66, 68, 70, 72, 74, 76, 190, 79, 81, 83, 85, 88, 90, 92, 94, 97, 99, 101, 104, 106, 108, 110, 115, 117, 119, 121, 123, 125, 131, 127, 129, 2, 173, 175, 177, 182, 184, 186, 188 }; // for (int i = 0; i < names.length; i++) { // if ((names[i]+1) == e.getComponentId()) { // if (e.getPlayer().getFarming().patches[i] != null) { // if (e.getPlayer().getFarming().patches[i].diseased) { // e.getPlayer().getFarming().patches[i].diseased = false; // refreshRemoteFarm(e.getPlayer()); // } else { // e.getPlayer().sendMessage(""This patch isn't diseased.""); // } // } // } // } } else AchievementTitles.handleButtons(e.getPlayer(), e.getComponentId()); }); public static void openRemoteFarm(Player player) { if (!player.canCastSpell()) { player.sendMessage(""There is a 5 second delay to this.""); return; } player.addSpellDelay(10); player.getTempAttribs().setB(""RemoteFarm"", true); player.getInterfaceManager().sendInterface(1082); refreshRemoteFarm(player); } public static void refreshRemoteFarm(Player player) { // if (!player.getInterfaceManager().containsInterface(1082) || player.getTemporaryAttributes().get(""RemoteFarm"") == null) // return; // Patch patch = null; // int[] names = new int[] { 30, 32, 34, 36, 38, 49, 51, 53, 55, 57, 59, 62, 64, 66, 68, 70, 72, 74, 76, 190, 79, 81, 83, 85, 88, 90, 92, 94, 97, 99, 101, 104, 106, 108, 110, 115, 117, 119, 121, 123, 125, 131, 127, 129, 2, 173, 175, 177, 182, // 184, 186, 188 }; // // for (int i = 0; i < names.length; i++) { // if (i < PatchConstants.WorldPatches.values().length) { // player.getPackets().sendIComponentText(1082, names[i], PatchConstants.WorldPatches.values()[i].name().replace(""_"", "" "").toLowerCase()); // } else { // player.getPackets().sendIComponentText(1082, names[i], """"); // } // } // for (int i = 0; i < names.length; i++) { // if (i < player.getFarming().patches.length) { // patch = player.getFarming().patches[i]; // if (patch != null) { // if (!patch.raked) { // player.getPackets().sendIComponentText(1082, names[i] + 1, ""Full of weeds""); // } else if (patch.dead) { // player.getPackets().sendIComponentText(1082, names[i] + 1, ""Is dead!""); // } else if (patch.diseased) { // player.getPackets().sendIComponentText(1082, names[i] + 1, ""Is disased!""); // } else if (patch.healthChecked) { // player.getPackets().sendIComponentText(1082, names[i] + 1, ""Is ready for health check""); // } else if (patch.grown && patch.yield > 0) { // player.getPackets().sendIComponentText(1082, names[i] + 1, ""Is fully grown with produce available""); // } else if (patch.grown) { // player.getPackets().sendIComponentText(1082, names[i] + 1, ""Is fully grown with no produce available""); // } else if (patch.currentSeed != -1) { // player.getPackets().sendIComponentText(1082, names[i] + 1, ""Is growing healthy.""); // } else if (patch.raked) { // player.getPackets().sendIComponentText(1082, names[i] + 1, ""Is empty""); // } // } else { // player.getPackets().sendIComponentText(1082, names[i] + 1, """"); // } // } else { // player.getPackets().sendIComponentText(1082, names[i] + 1, """"); // } // } } private static final Set DRAGON_ITEMS = new IntOpenHashSet(new int[] { 534, 536, 243, 1753, 1751, 1749, 1747, 24372, 7980, 7987, 8265 }); private static final Set ABYSSAL_ITEMS = new IntOpenHashSet(new int[] { 7979, 7986, 8264 }); private static final Set WALLASALKI_ITEMS = new IntOpenHashSet(new int[] { 6163, 6165, 6167 }); private static final Set BASILISK_ITEMS = new IntOpenHashSet(new int[] { 7977, 7984, 8262 }); public static void handleTuneBanite(Player player, Item item) { if (!player.isQuestComplete(Quest.RITUAL_OF_MAHJARRAT, ""to tune banite ores."")) return; if (!player.canCastSpell() || !Magic.checkMagicAndRunes(player, 87, false, new RuneSet(Rune.ASTRAL, 2, Rune.EARTH, 4))) return; if (!player.getInventory().containsItem(21778)) { player.sendMessage(""You need some banite ore to cast this spell.""); return; } int targetOre; if (DRAGON_ITEMS.contains(item.getId())) targetOre = 21779; else if (ABYSSAL_ITEMS.contains(item.getId())) targetOre = 21782; else if (WALLASALKI_ITEMS.contains(item.getId())) targetOre = 21780; else if (BASILISK_ITEMS.contains(item.getId())) targetOre = 21781; else targetOre = -1; if (targetOre == -1) { player.sendMessage(""The spell fails to react with the targeted item.""); return; } player.stopAll(false, false, true); player.startConversation(new Dialogue().addMakeX(targetOre, player.getInventory().getNumberOf(21778)).addNext(() -> { for (int i = 0;i < MakeXStatement.getQuantity(player);i++) { if (!player.getInventory().containsItem(21778) || !Magic.checkMagicAndRunes(player, 87, true, new RuneSet(Rune.ASTRAL, 2, Rune.EARTH, 4))) return; player.sync(11706, 1344); player.getSkills().addXp(Skills.MAGIC, 90); player.getInventory().deleteItem(21778, 1); player.getInventory().addItem(targetOre, 1); } })); } //spotanim 1320 disruption shield public static void handlePlankMake(Player player, Item item) { player.getInterfaceManager().openTab(Sub.TAB_MAGIC); if (!player.canCastSpell()) return; int index = getPlankIdx(item.getId()); if (index == -1) { player.sendMessage(""You can only cast this spell on a log.""); return; } int price = (int) (SawmillOperator.prices[index] * 0.7); if (!player.getInventory().hasCoins(price)) { player.sendMessage(""You need "" + Utils.formatNumber(price) + "" gold to convert this log.""); return; } if (!player.getInventory().containsItem(SawmillOperator.logs[index], 1) || !Magic.checkMagicAndRunes(player, 86, true, new RuneSet(Rune.NATURE, 1, Rune.ASTRAL, 2, Rune.EARTH, 15))) return; player.setNextAnimation(new Animation(6298)); player.setNextSpotAnim(new SpotAnim(1063, 0, 50)); player.getInventory().removeCoins(price); player.getInventory().deleteItem(SawmillOperator.logs[index], 1); player.getInventory().addItem(SawmillOperator.planks[index], 1); player.getSkills().addXp(Constants.MAGIC, 90); player.addSpellDelay(2); player.soundEffect(3617, true); } public static void handleVengeance(Player player) { long lastVeng = player.getTempAttribs().getL(""LAST_VENG""); if (lastVeng != -1 && lastVeng + 30000 > System.currentTimeMillis()) { player.sendMessage(""You may only cast vengeance once every 30 seconds.""); return; } if (!Magic.checkMagicAndRunes(player, 94, true, new RuneSet(Rune.ASTRAL, 4, Rune.DEATH, 2, Rune.EARTH, 10))) return; player.setNextSpotAnim(new SpotAnim(726, 0, 100)); player.setNextAnimation(new Animation(4410)); player.setCastVeng(true); player.soundEffect(2907, true); player.getSkills().addXp(Constants.MAGIC, 112); player.getTempAttribs().setL(""LAST_VENG"", System.currentTimeMillis()); } public static void handleHumidify(Player player) { if (hasFillables(player)) { if (Magic.checkMagicAndRunes(player, 68, true, new RuneSet(Rune.ASTRAL, 1, Rune.WATER, 3, Rune.FIRE, 1))) { player.setNextSpotAnim(new SpotAnim(1061)); player.setNextAnimation(new Animation(6294)); player.getSkills().addXp(Constants.MAGIC, 65); fillFillables(player); player.soundEffect(3614, true); } } else player.sendMessage(""You need to have something to humidify before using this spell.""); } public static void fillFillables(Player player) { for (Item item : player.getInventory().getItems().array()) { if (item == null) continue; Filler fill = Filler.forEmpty((short) item.getId()); if (fill != null) if (player.getInventory().containsItem(fill.getEmptyItem().getId(), 1)) { player.getInventory().deleteItem(fill.getEmptyItem()); player.getInventory().addItem(fill.getFilledItem()); } } } public static boolean hasFillables(Player player) { for (Item item : player.getInventory().getItems().array()) { if (item == null) continue; Filler fill = Filler.forEmpty((short) item.getId()); if (fill != null) return true; } return false; } public static void handleStringJewelry(Player player) { if (hasUnstrungs(player)) { if (Magic.checkMagicAndRunes(player, 80, true, new RuneSet(Rune.ASTRAL, 2, Rune.EARTH, 10, Rune.WATER, 5))) { player.setNextSpotAnim(new SpotAnim(728, 0, 100)); player.setNextAnimation(new Animation(4412)); player.getSkills().addXp(Constants.MAGIC, 87); for (Item item : player.getInventory().getItems().array()) { if (item == null) continue; int strungId = getStrungIndex(item.getId()); if (strungId != -1) { player.getInventory().deleteItem(item.getId(), 1); player.getInventory().addItem(strung[strungId], 1); player.soundEffect(2903, true); } } } } else player.sendMessage(""You need to have unstrung jewelry to cast this spell.""); } public static void handleFertileSoil(Player player, GameObject object) { PatchLocation loc = PatchLocation.forObject(object.getId()); if (loc == null) { player.sendMessage(""Um...I don't want to fertilise that!""); return; } if (loc.type == PatchType.COMPOST) { player.sendMessage(""Composting the compost??""); return; } FarmPatch spot = player.getPatch(loc); if (spot == null) spot = new FarmPatch(loc); if (spot.fullyGrown()) { player.sendMessage(""Composting it isn't going to make it get any bigger.""); return; } if (spot.compostLevel == 2) { player.sendMessage(""This patch has already been treated with supercompost.""); return; } if (!Magic.checkMagicAndRunes(player, 83, true, new RuneSet(Rune.ASTRAL, 3, Rune.EARTH, 15, Rune.NATURE, 2))) return; player.setNextFaceTile(object.getTile()); player.getSkills().addXp(Constants.FARMING, 18); player.getSkills().addXp(Constants.MAGIC, 87); player.setNextAnimation(new Animation(4411)); player.setNextSpotAnim(new SpotAnim(728, 0, 100)); spot.compostLevel = 2; player.putPatch(spot); } public static void handleCurePlant(Player player, GameObject object) { PatchLocation loc = PatchLocation.forObject(object.getId()); if (loc == null) { player.sendMessage(""There's nothing there to cure!""); return; } FarmPatch spot = player.getPatch(loc); if (spot == null) spot = new FarmPatch(loc); if (spot.dead) { player.sendMessage(""It says 'Cure' not 'Resurrect'. Although death may arise from disease, it is not in itself a disease and hence cannot be cured. So there.""); return; } if (!spot.diseased) { player.sendMessage(""It is growing just fine.""); return; } if (!Magic.checkMagicAndRunes(player, 66, true, new RuneSet(Rune.ASTRAL, 1, Rune.EARTH, 8))) return; player.setNextFaceTile(object.getTile()); player.getSkills().addXp(Constants.FARMING, 90); player.getSkills().addXp(Constants.MAGIC, 60); player.setNextAnimation(new Animation(4411)); player.setNextSpotAnim(new SpotAnim(728, 0, 100)); spot.diseased = false; spot.updateVars(player); player.lock(3); } public static void handleRestorePotionShare(Player player, Item item) { // TODO Auto-generated method stub } public static void handleLeatherMake(Player player, Item item) { // TODO Auto-generated method stub } public static void handleBoostPotionShare(Player player, Item item) { // TODO Auto-generated method stub } public static void handleBakePie(Player player) { // TODO Auto-generated method stub } public static void handleCureMe(Player player) { if (player.getPoison().isPoisoned()) { if (Magic.checkMagicAndRunes(player, 71, true, new RuneSet(Rune.ASTRAL, 2, Rune.COSMIC, 2))) { player.setNextSpotAnim(new SpotAnim(729, 0, 100)); player.setNextAnimation(new Animation(4409)); player.getSkills().addXp(Constants.MAGIC, 69); player.getPoison().reset(); } } else player.sendMessage(""You are not poisoned.""); } public static void handleHunterKit(Player player) { // TODO Auto-generated method stub } public static void handleCureGroup(Player player) { if (!player.canCastSpell()) return; if (Magic.checkMagicAndRunes(player, 74, true, new RuneSet(Rune.ASTRAL, 2, Rune.COSMIC, 2))) { player.getActionManager().addActionDelay(4); player.setNextSpotAnim(new SpotAnim(729, 0, 100)); player.setNextAnimation(new Animation(4411)); player.getPoison().reset(); player.addSpellDelay(2); for (Player other : getNearPlayers(player, 1, 10)) if (other.getPoison().isPoisoned()) { player.setNextSpotAnim(new SpotAnim(729, 0, 100)); player.getPoison().reset(); player.sendMessage(""Your poison has been cured!""); } } } public static void handleSuperGlassMake(Player player) { int secondary = (player.getInventory().containsItem(10978) ? 10978 : (player.getInventory().containsItem(1781)) ? 1781 : 401); //Swamp weed int number = Math.min(player.getInventory().getNumberOf(1783), player.getInventory().getNumberOf(secondary)); if (number <= 0) { player.sendMessage(""You need seaweed and buckets of sand to make molten glass.""); return; } if (Magic.checkMagicAndRunes(player, 77, true, new RuneSet(Rune.ASTRAL, 2, Rune.FIRE, 6, Rune.AIR, 10))) { player.setNextSpotAnim(new SpotAnim(729, 0, 100)); player.setNextAnimation(new Animation(4413)); player.getSkills().addXp(Constants.MAGIC, 78); if (number > 0) { double chance = (number*1.30) - Math.floor(number*1.3); number *= 1.30; player.getInventory().deleteItem(secondary, number); player.getInventory().deleteItem(1783, number); player.getSkills().addXp(Constants.CRAFTING, 10*number); player.getInventory().addItem(1775, number); if ((chance > 0.0) && Utils.randomD() <= chance) { player.getInventory().addItem(1775, 1); player.getSkills().addXp(Constants.CRAFTING, 10); player.soundEffect(2896, true); } } } } public static void handleRemoteFarm(Player player) { openRemoteFarm(player); } public static void handleDream(Player player) { // TODO Auto-generated method stub } public static void handleMagicImbue(Player player) { long lastImbue = player.getTempAttribs().getL(""LAST_IMBUE""); if (lastImbue != -1 && lastImbue + 12600 > System.currentTimeMillis()) { player.sendMessage(""You may only cast magic imbue spells once every 12.6 seconds.""); return; } if (Magic.checkMagicAndRunes(player, 82, true, new RuneSet(Rune.ASTRAL, 2, Rune.WATER, 7, Rune.FIRE, 7))) { player.setNextSpotAnim(new SpotAnim(141, 0, 100)); player.setNextAnimation(new Animation(722)); player.setCastMagicImbue(true); player.soundEffect(2888, true); player.getSkills().addXp(Constants.MAGIC, 86); player.getTempAttribs().setL(""LAST_IMBUE"", System.currentTimeMillis()); } } public static void handleDisruptionShield(Player player) { // TODO Auto-generated method stub } public static void handleGroupVengeance(Player player) { long lastVeng = player.getTempAttribs().getL(""LAST_VENG""); if (lastVeng != -1 && lastVeng + 30000 > System.currentTimeMillis()) { player.sendMessage(""You may only cast vengeance spells once every 30 seconds.""); return; } if (Magic.checkMagicAndRunes(player, 95, true, new RuneSet(Rune.ASTRAL, 4, Rune.DEATH, 3, Rune.EARTH, 11))) { player.setNextSpotAnim(new SpotAnim(725, 0, 100)); player.setNextAnimation(new Animation(4411)); player.setCastVeng(true); player.soundEffect(2908, true); player.getSkills().addXp(Constants.MAGIC, 112); player.getTempAttribs().setL(""LAST_VENG"", System.currentTimeMillis()); for (Player other : getNearPlayers(player, 3, 10)) { long otherVeng = other.getTempAttribs().getL(""LAST_VENG""); if (otherVeng != -1 && otherVeng + 30000 > System.currentTimeMillis()) continue; other.setNextSpotAnim(new SpotAnim(725, 0, 100)); other.setCastVeng(true); other.getTempAttribs().setL(""LAST_VENG"", System.currentTimeMillis()); } } } public static void handleHealGroup(Player player) { // TODO Auto-generated method stub } public static void handleSpellbookSwap(Player player) { // TODO Auto-generated method stub } }" "package com.rs.game.content.skills.magic; @PluginEventHandler public class Magic { public static boolean isSlayerStaff(int weaponId) { return switch (weaponId) { case 4170, 15486, 15502, 22207, 22213, 22211, 22209 -> true; default -> false; }; } public static boolean hasStaffOfLight(int weaponId) { return switch (weaponId) { case 15486, 15502, 22207, 22213, 22211, 22209 -> true; default -> false; }; } public static boolean checkCombatSpell(Player player, CombatSpell spell, int set, boolean delete) { if (spell == CombatSpell.STORM_OF_ARMADYL && !player.isQuestComplete(Quest.RITUAL_OF_MAHJARRAT, ""to cast Storm of Armadyl."")) return false; if (set >= 0) if (set == 0) player.getCombatDefinitions().setAutoCastSpell(spell); else player.getCombatDefinitions().setManualCastSpell(spell); return true; } public static void manualCast(Player player, Entity target, CombatSpell spell) { if (checkCombatSpell(player, spell, 1, false)) { player.setNextFaceTile(target.getMiddleTile()); player.getInteractionManager().setInteraction(new PlayerCombatInteraction(player, target)); } } public static InterfaceOnPlayerHandler manualCastPlayer = new InterfaceOnPlayerHandler(false, new int[]{192, 193, 950}, e -> { CombatSpell combat = CombatSpell.forId(e.getInterfaceId(), e.getComponentId()); if (combat != null) manualCast(e.getPlayer(), e.getTarget(), combat); }); public static InterfaceOnNPCHandler manualCastNPC = new InterfaceOnNPCHandler(false, new int[]{192, 193, 950}, e -> { e.getPlayer().stopAll(false); CombatSpell combat = CombatSpell.forId(e.getInterfaceId(), e.getComponentId()); if (combat != null) { if (!e.getTarget().getDefinitions().hasAttackOption()) { e.getPlayer().sendMessage(""You can't attack that.""); return; } manualCast(e.getPlayer(), e.getTarget(), combat); } }); public static ButtonClickHandler handleNormalSpellbookButtons = new ButtonClickHandler(192, e -> { if (e.getComponentId() == 2) e.getPlayer().getCombatDefinitions().switchDefensiveCasting(); else if (e.getComponentId() == 7) e.getPlayer().getCombatDefinitions().switchShowCombatSpells(); else if (e.getComponentId() == 9) e.getPlayer().getCombatDefinitions().switchShowTeleportSkillSpells(); else if (e.getComponentId() == 11) e.getPlayer().getCombatDefinitions().switchShowMiscSpells(); else if (e.getComponentId() == 13) e.getPlayer().getCombatDefinitions().switchShowSkillSpells(); else if (e.getComponentId() >= 15 & e.getComponentId() <= 17) e.getPlayer().getCombatDefinitions().setSortSpellBook(e.getComponentId() - 15); else Magic.processNormalSpell(e.getPlayer(), e.getComponentId(), e.getPacket()); }); public static ButtonClickHandler handleAncientSpellbookButtons = new ButtonClickHandler(193, e -> { if (e.getComponentId() == 5) e.getPlayer().getCombatDefinitions().switchShowCombatSpells(); else if (e.getComponentId() == 7) e.getPlayer().getCombatDefinitions().switchShowTeleportSkillSpells(); else if (e.getComponentId() >= 9 && e.getComponentId() <= 11) e.getPlayer().getCombatDefinitions().setSortSpellBook(e.getComponentId() - 9); else if (e.getComponentId() == 18) e.getPlayer().getCombatDefinitions().switchDefensiveCasting(); else Magic.processAncientSpell(e.getPlayer(), e.getComponentId(), e.getPacket()); }); public static ButtonClickHandler handleLunarSpellbookButtons = new ButtonClickHandler(430, e -> { if (e.getComponentId() == 5) e.getPlayer().getCombatDefinitions().switchShowCombatSpells(); else if (e.getComponentId() == 7) e.getPlayer().getCombatDefinitions().switchShowTeleportSkillSpells(); else if (e.getComponentId() == 9) e.getPlayer().getCombatDefinitions().switchShowMiscSpells(); else if (e.getComponentId() >= 11 & e.getComponentId() <= 13) e.getPlayer().getCombatDefinitions().setSortSpellBook(e.getComponentId() - 11); else if (e.getComponentId() == 20) e.getPlayer().getCombatDefinitions().switchDefensiveCasting(); else Magic.processLunarSpell(e.getPlayer(), e.getComponentId(), e.getPacket()); }); public static void setCombatSpell(Player player, CombatSpell spell) { if (player.getCombatDefinitions().getAutoCast() == spell) player.getCombatDefinitions().resetSpells(true); else checkCombatSpell(player, spell, 0, false); } public static void processLunarSpell(Player player, int componentId, ClientPacket packetId) { switch (componentId) { case 39: player.stopAll(false); useHomeTele(player); break; case 38: Lunars.handleBakePie(player); break; case 26: //Lunars.handleNPCContact(player); //inter 88 break; case 29: Lunars.handleHumidify(player); break; case 43: player.stopAll(false); sendLunarTeleportSpell(player, 69, 66, Tile.of(2112, 3915, 0), new RuneSet(Rune.LAW, 1, Rune.ASTRAL, 2, Rune.EARTH, 2)); break; case 56: player.stopAll(false); sendLunarTeleportSpell(player, 70, 67, Tile.of(2112, 3915, 0), new RuneSet(Rune.LAW, 1, Rune.ASTRAL, 2, Rune.EARTH, 4)); break; case 54: player.stopAll(false); sendLunarTeleportSpell(player, 71, 69, Tile.of(2466, 3248, 0), new RuneSet(Rune.LAW, 1, Rune.ASTRAL, 2, Rune.EARTH, 6)); break; case 46: Lunars.handleCureMe(player); break; case 30: Lunars.handleHunterKit(player); break; case 67: player.stopAll(false); sendLunarTeleportSpell(player, 72, 70, Tile.of(3005, 3327, 0), new RuneSet(Rune.LAW, 1, Rune.ASTRAL, 2, Rune.AIR, 2)); break; case 47: player.stopAll(false); sendLunarTeleportSpell(player, 72, 71, Tile.of(2546, 3757, 0), new RuneSet(Rune.LAW, 1, Rune.ASTRAL, 2, Rune.WATER, 1)); break; case 57: player.stopAll(false); sendLunarTeleportSpell(player, 73, 72, Tile.of(2546, 3757, 0), new RuneSet(Rune.LAW, 1, Rune.ASTRAL, 2, Rune.WATER, 5)); break; case 25: Lunars.handleCureGroup(player); break; case 22: player.stopAll(false); sendLunarTeleportSpell(player, 75, 76, Tile.of(2542, 3574, 0), new RuneSet(Rune.LAW, 2, Rune.ASTRAL, 2, Rune.FIRE, 3)); break; case 69: player.stopAll(false); sendLunarTeleportSpell(player, 76, 76, Tile.of(2613, 3345, 0), new RuneSet(Rune.LAW, 1, Rune.ASTRAL, 2, Rune.WATER, 5)); break; case 58: player.stopAll(false); sendLunarTeleportSpell(player, 76, 77, Tile.of(2542, 3574, 0), new RuneSet(Rune.LAW, 2, Rune.ASTRAL, 2, Rune.FIRE, 6)); break; case 48: Lunars.handleSuperGlassMake(player); break; case 70: Lunars.handleRemoteFarm(player); break; case 41: player.stopAll(false); sendLunarTeleportSpell(player, 78, 80, Tile.of(2630, 3167, 0), new RuneSet(Rune.LAW, 2, Rune.ASTRAL, 2, Rune.WATER, 4)); break; case 59: player.stopAll(false); sendLunarTeleportSpell(player, 79, 81, Tile.of(2630, 3167, 0), new RuneSet(Rune.LAW, 2, Rune.ASTRAL, 2, Rune.WATER, 8)); break; case 32: Lunars.handleDream(player); break; case 45: Lunars.handleStringJewelry(player); break; case 36: Lunars.handleMagicImbue(player); break; case 40: player.stopAll(false); sendLunarTeleportSpell(player, 85, 89, Tile.of(2614, 3382, 0), new RuneSet(Rune.LAW, 3, Rune.ASTRAL, 3, Rune.WATER, 10)); break; case 60: player.stopAll(false); sendLunarTeleportSpell(player, 86, 90, Tile.of(2614, 3382, 0), new RuneSet(Rune.LAW, 3, Rune.ASTRAL, 3, Rune.WATER, 14)); break; case 44: player.stopAll(false); sendLunarTeleportSpell(player, 87, 92, Tile.of(2804, 3434, 0), new RuneSet(Rune.LAW, 3, Rune.ASTRAL, 3, Rune.WATER, 10)); break; case 61: player.stopAll(false); sendLunarTeleportSpell(player, 88, 93, Tile.of(2804, 3434, 0), new RuneSet(Rune.LAW, 3, Rune.ASTRAL, 3, Rune.WATER, 12)); break; case 51: player.stopAll(false); sendLunarTeleportSpell(player, 89, 96, Tile.of(2977, 3924, 0), new RuneSet(Rune.LAW, 3, Rune.ASTRAL, 3, Rune.WATER, 8)); break; case 62: player.stopAll(false); sendLunarTeleportSpell(player, 90, 99, Tile.of(2977, 3924, 0), new RuneSet(Rune.LAW, 3, Rune.ASTRAL, 3, Rune.WATER, 16)); break; case 73: Lunars.handleDisruptionShield(player); break; case 75: player.stopAll(false); sendLunarTeleportSpell(player, 92, 101, Tile.of(2814, 3677, 0), new RuneSet(Rune.LAW, 3, Rune.ASTRAL, 3, Rune.WATER, 10)); break; case 76: player.stopAll(false); sendLunarTeleportSpell(player, 93, 102, Tile.of(2814, 3677, 0), new RuneSet(Rune.LAW, 3, Rune.ASTRAL, 3, Rune.WATER, 20)); break; case 37: Lunars.handleVengeance(player); break; case 74: Lunars.handleGroupVengeance(player); break; case 53: Lunars.handleHealGroup(player); break; case 34: Lunars.handleSpellbookSwap(player); break; default: if (player.hasRights(Rights.DEVELOPER)) player.sendMessage(""Unhandled lunar spell: "" + componentId); break; } } public static void processAncientSpell(Player player, int componentId, ClientPacket packetId) { player.stopAll(false); CombatSpell combatSpell = CombatSpell.forId(193, componentId); if (combatSpell != null) { setCombatSpell(player, combatSpell); return; } switch (componentId) { case 40: sendAncientTeleportSpell(player, 54, 64, Tile.of(3099, 9882, 0), new RuneSet(Rune.LAW, 2, Rune.FIRE, 1, Rune.AIR, 1)); break; case 41: sendAncientTeleportSpell(player, 60, 70, Tile.of(3222, 3336, 0), new RuneSet(Rune.LAW, 2, Rune.SOUL, 1)); break; case 42: sendAncientTeleportSpell(player, 66, 76, Tile.of(3492, 3471, 0), new RuneSet(Rune.LAW, 2, Rune.BLOOD, 1)); break; case 43: sendAncientTeleportSpell(player, 72, 82, Tile.of(3006, 3471, 0), new RuneSet(Rune.LAW, 2, Rune.WATER, 4)); break; case 44: sendAncientTeleportSpell(player, 78, 88, Tile.of(2990, 3696, 0), new RuneSet(Rune.LAW, 2, Rune.FIRE, 3, Rune.AIR, 2)); break; case 45: sendAncientTeleportSpell(player, 84, 94, Tile.of(3217, 3677, 0), new RuneSet(Rune.LAW, 2, Rune.SOUL, 2)); break; case 46: sendAncientTeleportSpell(player, 90, 100, Tile.of(3288, 3886, 0), new RuneSet(Rune.LAW, 2, Rune.BLOOD, 2)); break; case 47: sendAncientTeleportSpell(player, 96, 106, Tile.of(2977, 3873, 0), new RuneSet(Rune.LAW, 2, Rune.WATER, 8)); break; case 48: useHomeTele(player); break; } } public static void processNormalSpell(Player player, int componentId, ClientPacket packetId) { player.stopAll(false); CombatSpell combatSpell = CombatSpell.forId(192, componentId); if (combatSpell != null) { setCombatSpell(player, combatSpell); return; } switch (componentId) { case 27: if (player.getSkills().getLevel(Constants.MAGIC) < 4) { player.sendMessage(""Your Magic level is not high enough for this spell.""); return; } player.stopAll(); player.getInterfaceManager().sendInterface(432); break; case 24: useHomeTele(player); break; case 37: // mobi sendNormalTeleportSpell(player, 10, 19, Tile.of(2413, 2848, 0), new RuneSet(Rune.LAW, 1, Rune.WATER, 1, Rune.AIR, 1)); break; case 40: // varrock sendNormalTeleportSpell(player, 25, 19, Tile.of(3212, 3424, 0), new RuneSet(Rune.FIRE, 1, Rune.AIR, 3, Rune.LAW, 1)); break; case 43: // lumby sendNormalTeleportSpell(player, 31, 41, Tile.of(3222, 3218, 0), new RuneSet(Rune.EARTH, 1, Rune.AIR, 3, Rune.LAW, 1)); break; case 46: // fally sendNormalTeleportSpell(player, 37, 48, Tile.of(2964, 3379, 0), new RuneSet(Rune.WATER, 1, Rune.AIR, 3, Rune.LAW, 1)); break; case 48: sendNormalTeleportSpell(player, 40, 48, Tile.of(player.getHouse().getLocation().getTile()), new RuneSet(Rune.AIR, 1, Rune.EARTH, 1, Rune.LAW, 1), () -> { player.tele(Tile.of(player.getTile())); //cancel teleport tile movement enterHouseAndResetDamage(player); }); break; case 51: // camelot sendNormalTeleportSpell(player, 45, 55.5, Tile.of(2757, 3478, 0), new RuneSet(Rune.AIR, 5, Rune.LAW, 1)); break; case 57: // ardy sendNormalTeleportSpell(player, 51, 61, Tile.of(2664, 3305, 0), new RuneSet(Rune.WATER, 2, Rune.LAW, 2)); break; case 62: // watch sendNormalTeleportSpell(player, 58, 68, Tile.of(2547, 3113, 2), new RuneSet(Rune.EARTH, 2, Rune.LAW, 2)); break; case 69: // troll sendNormalTeleportSpell(player, 61, 68, Tile.of(2888, 3674, 0), new RuneSet(Rune.FIRE, 2, Rune.LAW, 2)); break; case 72: // ape sendNormalTeleportSpell(player, 64, 76, Tile.of(2797, 2798, 1), new RuneSet(Rune.FIRE, 2, Rune.WATER, 2, Rune.LAW, 2)); break; } } public static void processDungSpell(Player player, int componentId, ClientPacket packetId) { if (player.hasRights(Rights.DEVELOPER)) player.sendMessage(""Dungeoneering spell: "" + componentId + "", "" + packetId); if (packetId == ClientPacket.IF_OP6) { CombatSpell combatSpell = CombatSpell.forId(950, componentId); if (combatSpell != null) setCombatSpell(player, combatSpell); } } private static void useHomeTele(Player player) { player.stopAll(); player.getInterfaceManager().sendInterface(1092); } public static boolean checkSpellLevel(Player player, int level) { if (player.getSkills().getLevel(Constants.MAGIC) < level) { player.sendMessage(""Your Magic level is not high enough for this spell.""); return false; } return true; } public static void sendNormalTeleportNoType(Player player, Tile tile) { sendTeleportSpell(player, 8939, 8941, 1576, 1577, 0, 0, tile, 3, true, TeleType.BYPASS_HOOKS, null); } public static void sendDamonheimTeleport(Player player, Tile tile) { sendTeleportSpell(player, 13652, 13654, 2602, 2603, 0, 0, tile, 10, true, TeleType.MAGIC, null); } public static void sendLunarTeleportSpell(Player player, int level, double xp, Tile tile, RuneSet runes) { sendTeleportSpell(player, 9606, -1, 1685, -1, level, xp, tile, 5, true, TeleType.MAGIC, runes, null); } public static void sendLunarTeleportSpell(Player player, int level, double xp, Tile tile, RuneSet runes, Runnable onArrive) { sendTeleportSpell(player, 9606, -1, 1685, -1, level, xp, tile, 5, true, TeleType.MAGIC, runes, onArrive); } public static void sendAncientTeleportSpell(Player player, int level, double xp, Tile tile, RuneSet runes, Runnable onArrive) { sendTeleportSpell(player, 9599, -2, 1681, -1, level, xp, tile, 5, true, TeleType.MAGIC, runes, onArrive); } public static void sendAncientTeleportSpell(Player player, int level, double xp, Tile tile, RuneSet runes) { sendTeleportSpell(player, 9599, -2, 1681, -1, level, xp, tile, 5, true, TeleType.MAGIC, runes, null); } public static void sendNormalTeleportSpell(Player player, int level, double xp, Tile tile) { sendTeleportSpell(player, 8939, 8941, 1576, 1577, level, xp, tile, 3, true, TeleType.MAGIC, (RuneSet) null, null); } public static void sendNormalTeleportSpell(Player player, int level, double xp, Tile tile, RuneSet runes) { sendTeleportSpell(player, 8939, 8941, 1576, 1577, level, xp, tile, 3, true, TeleType.MAGIC, runes, null); } public static void sendNormalTeleportSpell(Player player, int level, double xp, Tile tile, RuneSet runes, Runnable onArrive) { sendTeleportSpell(player, 8939, 8941, 1576, 1577, level, xp, tile, 3, true, TeleType.MAGIC, runes, onArrive); } public static void sendNormalTeleportSpell(Player player, int level, double xp, Tile tile, Runnable onArrive) { sendNormalTeleportSpell(player, level, xp, tile, null, onArrive); } public static void sendNormalTeleportSpell(Player player, Tile tile) { sendNormalTeleportSpell(player, 0, 0, tile); } public static void sendNormalTeleportSpell(Player player, Tile tile, Runnable onArrive) { sendNormalTeleportSpell(player, 0, 0, tile, onArrive); } public static void sendItemTeleportSpell(Player player, boolean randomize, int upEmoteId, int upGraphicId, int delay, Tile tile) { sendItemTeleportSpell(player, randomize, upEmoteId, upGraphicId, delay, tile, null); } public static void sendItemTeleportSpell(Player player, boolean randomize, int upEmoteId, int upGraphicId, int delay, Tile tile, Runnable onArrive) { player.getTempAttribs().setB(""glory"", true); sendTeleportSpell(player, upEmoteId, -2, upGraphicId, -1, 0, 0, tile, delay, randomize, TeleType.ITEM, onArrive); } public static void pushLeverTeleport(final Player player, final Tile tile) { player.setNextAnimation(new Animation(2140)); player.getTasks().schedule(1, () -> Magic.sendObjectTeleportSpell(player, false, tile, null)); } public static void sendObjectTeleportSpell(Player player, boolean randomize, Tile tile) { sendTeleportSpell(player, 8939, 8941, 1576, 1577, 0, 0, tile, 3, randomize, TeleType.OBJECT, (RuneSet) null, null); } public static void sendObjectTeleportSpell(Player player, boolean randomize, Tile tile, Runnable onArrive) { sendTeleportSpell(player, 8939, 8941, 1576, 1577, 0, 0, tile, 3, randomize, TeleType.OBJECT, (RuneSet) null, onArrive); } public static void sendDelayedObjectTeleportSpell(Player player, int delay, boolean randomize, Tile tile, Runnable onArrive) { sendTeleportSpell(player, 8939, 8941, 1576, 1577, 0, 0, tile, delay, randomize, TeleType.OBJECT, (RuneSet) null, onArrive); } public static boolean sendTeleportSpell(final Player player, int upEmoteId, final int downEmoteId, int upGraphicId, final int downGraphicId, int level, final double xp, final Tile tile, int delay, final boolean randomize, final TeleType teleType, Runnable onArrive) { sendTeleportSpell(player, upEmoteId, downEmoteId, upGraphicId, downGraphicId, level, xp, tile, delay, randomize, teleType, (RuneSet) null, onArrive); return randomize; } public static void sendTeleportSpell(final Player player, int upEmoteId, final int downEmoteId, int upGraphicId, final int downGraphicId, int level, final double xp, final Tile tile, int delay, final boolean randomize, final TeleType teleType, RuneSet runes, Runnable onArrive) { sendTeleportSpell(player, upEmoteId, downEmoteId, upGraphicId, downGraphicId, level, xp, tile, delay, randomize, teleType, runes, null, onArrive); } public static void sendTeleportSpell(final Player player, int upEmoteId, final int downEmoteId, int upGraphicId, final int downGraphicId, int level, final double xp, final Tile tile, int delay, final boolean randomize, final TeleType teleType, Runnable onCast, Runnable onArrive) { sendTeleportSpell(player, upEmoteId, downEmoteId, upGraphicId, downGraphicId, level, xp, tile, delay, randomize, teleType, null, onCast, onArrive); } public static void sendTeleportSpell(final Player player, int upEmoteId, final int downEmoteId, int upGraphicId, final int downGraphicId, int level, final double xp, final Tile tile, int delay, final boolean randomize, final TeleType teleType, RuneSet runes, Runnable onCast, Runnable onArrive) { Teleport tele = new Teleport(Tile.of(player.getTile()), tile, teleType, () -> { if (player.isLocked()) return false; if (player.getSkills().getLevel(Constants.MAGIC) < level) { player.sendMessage(""Your Magic level is not high enough for this spell.""); return false; } if (runes != null && !runes.meetsRequirements(player)) return false; return true; }, () -> { if (runes != null) { List runeList = runes.getRunesToDelete(player); for (Item rune : runeList) if (rune != null) player.getInventory().deleteItem(rune); } player.stopAll(); if (onCast != null) onCast.run(); if (upEmoteId != -1) player.setNextAnimation(new Animation(upEmoteId)); if (upGraphicId != -1) player.setNextSpotAnim(new SpotAnim(upGraphicId)); if (teleType == TeleType.MAGIC) player.voiceEffect(5527, true); player.lock(3 + delay); }, () -> { Tile toTile = tile; if (randomize) { for (int trycount = 0; trycount < 10; trycount++) { toTile = Tile.of(tile, 2); if (World.floorAndWallsFree(toTile, player.getSize())) break; toTile = tile; } } player.tele(toTile); if (teleType != TeleType.BYPASS_HOOKS) player.getControllerManager().onTeleported(teleType); if (xp != 0) player.getSkills().addXp(Constants.MAGIC, xp); if (downEmoteId != -1) player.anim(downEmoteId == -2 ? -1 : downEmoteId); if (downGraphicId != -1) player.spotAnim(downGraphicId); if (teleType == TeleType.MAGIC) { player.voiceEffect(5524, true); player.setNextFaceTile(Tile.of(toTile.getX(), toTile.getY() - 1, toTile.getPlane())); player.setFaceAngle(6); } if (onArrive != null) onArrive.run(); player.resetReceivedHits(); player.resetReceivedDamage(); }, true); Teleport.execute(player, tele, delay); } public static void npcTeleport(NPC npc, int upEmoteId, final int downEmoteId, int upGraphicId, final int downGraphicId, final Tile tile, int delay, final boolean randomize, Consumer onArrive) { npc.resetWalkSteps(); npc.setRouteEvent(null); npc.getActionManager().forceStop(); npc.getInteractionManager().forceStop(); if (upEmoteId != -1) npc.setNextAnimation(new Animation(upEmoteId)); if (upGraphicId != -1) npc.setNextSpotAnim(new SpotAnim(upGraphicId)); WorldTasks.delay(delay, () -> { Tile teleTile = tile; if (randomize) { for (int trycount = 0; trycount < 10; trycount++) { teleTile = Tile.of(tile, 2); if (World.floorAndWallsFree(teleTile, npc.getSize())) break; teleTile = tile; } } npc.tele(teleTile); if (downEmoteId != -1) npc.setNextAnimation(new Animation(downEmoteId == -2 ? -1 : downEmoteId)); if (downGraphicId != -1) npc.setNextSpotAnim(new SpotAnim(downGraphicId)); if (onArrive != null) onArrive.accept(npc); npc.resetReceivedDamage(); npc.resetReceivedHits(); }); } public static void npcNormalTeleport(NPC npc, Tile tile, boolean randomize, Consumer onArrive) { npcTeleport(npc, 8939, 8941, 1576, 1577, tile, 3, randomize, onArrive); } public static void npcAncientTeleport(NPC npc, Tile tile, boolean randomize, Consumer onArrive) { npcTeleport(npc, 9599, -2, 1681, -1, tile, 5, randomize, onArrive); } public static void npcLunarTeleport(NPC npc, Tile tile, boolean randomize, Consumer onArrive) { npcTeleport(npc, 9606, -1, 1685, -1, tile, 5, randomize, onArrive); } public static void npcDaemonheimTeleport(NPC npc, Tile tile, boolean randomize, Consumer onArrive) { npcTeleport(npc, 13652, 13654, 2602, 2603, tile, 10, randomize, onArrive); } public static void npcItemTeleport(NPC npc, Tile tile, boolean randomize, Consumer onArrive) { npcTeleport(npc, 9603, -2, 1684, -1, tile, 4, randomize, onArrive); } private static void enterHouseAndResetDamage(Player player) { if (!player.getHouse().arriveOutsideHouse()) { player.getHouse().setBuildMode(false); player.getHouse().enterMyHouse(); player.setFaceAngle(6); } else player.tele(Tile.of(player.getHouse().getLocation().getTile())); player.resetReceivedHits(); player.resetReceivedDamage(); player.setFaceAngle(6); player.setNextAnimation(new Animation(-1)); } public static void useHouseTab(Player player) { Teleport teleport = new Teleport(Tile.of(player.getTile()), player.getHouse().getLocation().getTile(), TeleType.ITEM, null, null, () -> { player.getInventory().deleteItem(8013, 1); enterHouseAndResetDamage(player); }, true); if (player.isLocked() || (teleport.meetsRequirements() != null && !teleport.meetsRequirements().get())) return; if (!player.getControllerManager().processTeleport(teleport)) return; player.stopAll(); player.lock(); player.sync(9597, 1680); player.getTasks().scheduleTimer(1, 0, tick -> { switch(tick) { case 0 -> player.anim(4731); case 2 -> { player.getControllerManager().onTeleported(teleport.type()); if (teleport.end() != null) teleport.end().run(); player.anim(-1); } case 3 -> { player.resetReceivedHits(); player.resetReceivedDamage(); player.unlock(); return false; } } return true; }); } public static void useTeleTab(Player player, Tile tile, int tabId) { Teleport teleport = new Teleport(Tile.of(player.getTile()), tile, TeleType.ITEM, null, null, () -> player.getInventory().deleteItem(tabId, 1), true); if (player.isLocked() || (teleport.meetsRequirements() != null && !teleport.meetsRequirements().get())) return; if (!player.getControllerManager().processTeleport(teleport)) return; player.stopAll(); player.lock(); player.sync(9597, 1680); player.getTasks().scheduleTimer(1, 0, tick -> { switch(tick) { case 0 -> player.anim(4731); case 2 -> { player.getControllerManager().onTeleported(teleport.type()); player.tele(teleport.destination()); if (teleport.end() != null) teleport.end().run(); player.anim(-1); } case 3 -> { player.resetReceivedHits(); player.resetReceivedDamage(); player.unlock(); return false; } } return true; }); } public static boolean checkMagicAndRunes(Player player, int magicLevel, boolean deleteRunes, RuneSet runes) { if (player.getSkills().getLevel(Constants.MAGIC) < magicLevel) { player.sendMessage(""You need a magic level of "" + magicLevel + "" to cast this spell.""); return false; } if (runes != null && !runes.meetsRequirements(player)) return false; if (runes != null && deleteRunes) { List toDelete = runes.getRunesToDelete(player); for (Item i : toDelete) if (i != null) player.getInventory().deleteItem(i); } return true; } public static boolean checkRunes(Player player, boolean delete, RuneSet runes) { if (runes == null) return true; if (!runes.meetsRequirements(player)) return false; if (delete) { List toDelete = runes.getRunesToDelete(player); for (Item i : toDelete) if (i != null) player.getInventory().deleteItem(i); } return true; } }" "package com.rs.game.content.skills.magic; @PluginEventHandler public class OrbImbuing { public static int UNPOWERED = 567; public enum Orbs { WATER(2151, 60, 56, 66, 571, 149, Rune.WATER), EARTH(29415, 64, 60, 70, 575, 151, Rune.EARTH), FIRE(2153, 71, 63, 73, 569, 152, Rune.FIRE), AIR(2152, 74, 66, 76, 573, 150, Rune.AIR); private final int objectId; private final int componentId; private final int req; private final int xp; private final int orbId; private final int gfx; private final Rune rune; private Orbs(int objectId, int componentId, int req, int xp, int orbId, int gfx, Rune rune) { this.objectId = objectId; this.componentId = componentId; this.req = req; this.xp = xp; this.orbId = orbId; this.gfx = gfx; this.rune = rune; } public int getObjectId() { return objectId; } public int getComponentId() { return componentId; } public int getReq() { return req; } public int getXp() { return xp; } public int getOrbId() { return orbId; } public int getGfx() { return gfx; } public Rune getRune() { return rune; } } static class OrbChargingAction extends PlayerAction { private final Orbs orb; private final Tile tile; public OrbChargingAction(Orbs orb, Tile tile) { this.orb = orb; this.tile = tile; } public boolean checkAll(Player player) { if (player.getSkills().getLevel(Constants.MAGIC) < orb.getReq()) { player.sendMessage(""You need a magic level of "" + orb.getReq() + "" to imbue "" + orb.name().toLowerCase() + "" orbs.""); return false; } return true; } @Override public boolean start(Player player) { if (!checkAll(player)) return false; return true; } @Override public boolean process(Player player) { if (!checkAll(player)) return false; return true; } @Override public int processWithDelay(Player player) { if (!player.getInventory().containsItem(UNPOWERED, 1)) { player.sendMessage(""You've run out of orbs to imbue.""); return -1; } if (!player.getInventory().containsItem(564, 3) || !Magic.checkRunes(player, true, new RuneSet(orb.getRune(), 30))) { player.sendMessage(""You have run out of runes.""); return -1; } player.getInventory().deleteItem(564, 3); player.getInventory().deleteItem(UNPOWERED, 1); player.getInventory().addItem(orb.getOrbId(), 1); player.getSkills().addXp(Constants.MAGIC, orb.getXp()); player.setNextSpotAnim(new SpotAnim(orb.getGfx(), 0, 100)); player.setNextAnimation(new Animation(726)); player.setNextFaceTile(tile); return 3; } @Override public void stop(Player player) { } } public static InterfaceOnObjectHandler handle = new InterfaceOnObjectHandler(true, new int[] { 192 }, new int[] { 60, 64, 71, 74 }, e -> { if (e.isAtObject()) { Orbs orb = null; for (Orbs o : Orbs.values()) if (e.getObjectId() == o.getObjectId() && e.getComponentId() == o.getComponentId()) { orb = o; break; } if (orb == null) { e.getPlayer().sendMessage(""Try using this spell on the correct obelisk.""); return; } e.getPlayer().getActionManager().setAction(new OrbChargingAction(orb, e.getObject().getTile())); } }); }" "package com.rs.game.content.skills.magic; public enum Rune { //varbit 4540 = 2, 3 || varbit 5493 != 0 activates elemental/catalytic miniegame runes AIR(556, 17780, 16091, 4697, 4695, 4696, 20941, 12850), WATER(555, 17781, 16092, 4694, 4695, 4698, 20940, 12850), EARTH(557, 17782, 16093, 4696, 4699, 4698, 20942, 12850), FIRE(554, 17783, 16094, 4694, 4697, 4699, 20939, 12850), BODY(559, 17788, 16099, 20944, 12851), MIND(558, 17784, 16095, 20943, 12851), COSMIC(564, 17789, 16100, 12851), CHAOS(562, 17785, 16096, 20947, 12851), NATURE(561, 17791, 16102, 20946, 12851), //18341 and varc 1234 = nature rune count inside staff DEATH(560, 17786, 16097, 20945, 12851), BLOOD(565, 17787, 16098, 12851), SOUL(566, 17793, 16104, 12851), ASTRAL(9075, 17790, 16101, 12851), LAW(563, 17792, 16103, 20948, 12851), ARMADYL(21773, 12851), STEAM(4694), MIST(4695), DUST(4696), SMOKE(4697), MUD(4698), LAVA(4699); private final static Map MAP = new HashMap<>(); static { for (Rune r : Rune.values()) MAP.put(r.id, r); } public static Rune forId(int itemId) { return MAP.get(itemId); } private final int[] runeIds; private final int id; Rune(int... runeIds) { this.runeIds = runeIds; id = runeIds[0]; } public boolean hasInfinite(Player player) { if (player.getEquipment().getWeaponId() == 24457) return true; switch(this) { case AIR: switch(player.getEquipment().getWeaponId()) { case 1381: case 23044: case 15598: case 17009: case 17011: case 16169: case 16170: case 1397: case 1405: case 19327: case 21777: case 21490: case 21496: case 21500: return true; } break; case WATER: if (player.getEquipment().getShieldId() == 18346) return true; switch(player.getEquipment().getWeaponId()) { case 1383: case 23045: case 16997: case 16999: case 16163: case 16164: case 1395: case 1403: case 6562: case 6563: case 11736: case 11738: case 19325: case 21491: case 21495: case 21499: case 21506: case 21507: case 21504: case 21505: return true; } break; case EARTH: switch(player.getEquipment().getWeaponId()) { case 1385: case 23046: case 17001: case 17003: case 16165: case 16166: case 1399: case 1407: case 3053: case 3054: case 6562: case 6563: case 19329: case 21492: case 21497: case 21501: case 21502: case 21503: case 21504: case 21505: return true; } break; case FIRE: switch(player.getEquipment().getWeaponId()) { case 1387: case 23047: case 17005: case 17007: case 16167: case 16168: case 1393: case 1401: case 3053: case 3054: case 11736: case 11738: case 19323: case 21493: case 21494: case 21498: case 21502: case 21503: case 21506: case 21507: return true; } break; default: return false; } return false; } public int id() { return id; } public List getRunesToDelete(Player player, int num) { List runes = new ArrayList<>(); if (hasInfinite(player)) return runes; int total = 0; for (int runeId : runeIds) { int numHeld = player.getInventory().getNumberOf(runeId); int numNeeded = num-total; if (numHeld > 0) { if (numHeld >= numNeeded) { runes.add(new Item(runeId, numNeeded)); return runes; } runes.add(new Item(runeId, numHeld)); } } return null; } }" "package com.rs.game.content.skills.magic; public class RuneSet { private Rune[] runes; private int[] amounts; public RuneSet() { } public RuneSet(Rune r1, int num1) { runes = new Rune[] { r1 }; amounts = new int[] { num1 }; } public RuneSet(Rune r1, int num1, Rune r2, int num2) { runes = new Rune[] { r1, r2 }; amounts = new int[] { num1, num2 }; } public RuneSet(Rune r1, int num1, Rune r2, int num2, Rune r3, int num3) { runes = new Rune[] { r1, r2, r3 }; amounts = new int[] { num1, num2, num3 }; } public RuneSet(Rune r1, int num1, Rune r2, int num2, Rune r3, int num3, Rune r4, int num4) { runes = new Rune[] { r1, r2, r3, r4 }; amounts = new int[] { num1, num2, num3, num4 }; } public boolean meetsRequirements(Player player) { if (player.getNSV().getB(""infRunes"")) return true; if (runes == null) return true; for (int i = 0;i < runes.length;i++) if (runes[i].getRunesToDelete(player, amounts[i]) == null) { player.sendMessage(""You don't have enough "" + runes[i].toString().toLowerCase() + "" runes to cast this spell.""); return false; } return true; } public boolean meetsPortalRequirements(Player player) { if (runes == null) return true; if (player.getNSV().getB(""infRunes"")) return true; for (int i = 0;i < runes.length;i++) if (runes[i].getRunesToDelete(player, amounts[i]) == null) { player.sendMessage(""You don't have enough "" + runes[i].toString().toLowerCase() + "" runes to tune your portal to this location.""); return false; } return true; } public List getRunesToDelete(Player player) { List toDelete = new ArrayList<>(); if (runes == null || player.getNSV().getB(""infRunes"")) return toDelete; for (int i = 0;i < runes.length;i++) { List rDel = runes[i].getRunesToDelete(player, amounts[i]); if (rDel != null) toDelete.addAll(rDel); } return toDelete; } public void deleteRunes(Player caster) { List toDelete = getRunesToDelete(caster); for (Item i : toDelete) if (i != null) caster.getInventory().deleteItem(i); } }" "package com.rs.game.content.skills.magic; @PluginEventHandler public class TeleportTabs { public enum TeleTab { VARROCK(8007, Tile.of(3217, 3426, 0)), LUMBRIDGE(8008, Tile.of(3222, 3218, 0)), FALADOR(8009, Tile.of(2965, 3379, 0)), CAMELOT(8010, Tile.of(2758, 3478, 0)), ARDOUGNE(8011, Tile.of(2660, 3306, 0)), WATCHTOWER(8012, Tile.of(2549, 3114, 2)), HOUSE(8013, null), RIMMINGTON(18809, Tile.of(2954, 3225, 0)), TAVERLY(18810, Tile.of(2882, 3451, 0)), POLLNIVNEACH(18811, Tile.of(3339, 3004, 0)), RELLEKA(18812, Tile.of(2668, 3631, 0)), BRIMHAVEN(18813, Tile.of(2757, 3177, 0)), YANILLE(18814, Tile.of(2546, 3095, 0)), TROLLHEIM(20175, Tile.of(2891, 3676, 0)), RUNECRAFTING_GUILD(13598, Tile.of(1696, 5465, 2)), AIR_ALTAR(13599, Tile.of(3125, 3406, 0)), MIND_ALTAR(13600, Tile.of(2980, 3513, 0)), WATER_ALTAR(13601, Tile.of(3184, 3163, 0)), EARTH_ALTAR(13602, Tile.of(3303, 3477, 0)), FIRE_ALTAR(13603, Tile.of(3309, 3251, 0)), BODY_ALTAR(13604, Tile.of(3051, 3441, 0)), COSMIC_ALTAR(13605, Tile.of(2407, 4383, 0)), CHAOS_ALTAR(13606, Tile.of(2281, 4837, 0)), //Did not feel like adding separate logic to add wilderness controller and a dialogue safety prompt. NATURE_ALTAR(13607, Tile.of(2865, 3022, 0)), LAW_ALTAR(13608, Tile.of(2857, 3379, 0)), DEATH_ALTAR(13609, Tile.of(1864, 4638, 0)), BLOOD_ALTAR(13610, Tile.of(3559, 9778, 0)), ASTRAL_ALTAR(13611, Tile.of(2150, 3862, 0)); private static final Map MAP = new HashMap<>(); static { for (TeleTab t : TeleTab.values()) MAP.put(t.id, t); } public static TeleTab forId(int itemId) { return MAP.get(itemId); } private final int id; private final Tile teleToTile; private TeleTab (int id, Tile tile) { this.id = id; teleToTile = tile; } public int id() { return id; } public Tile tile() { return teleToTile; } } public static ItemClickHandler handle = new ItemClickHandler(TeleTab.MAP.keySet().toArray(), e -> { switch(e.getOption()) { case ""Break"" -> { if (!meetsTabReqs(e.getItem().getId(), e.getPlayer())) return; if (e.getItem().getId() == 8013) { Magic.useHouseTab(e.getPlayer()); return; } TeleTab t = TeleTab.forId(e.getItem().getId()); Magic.useTeleTab(e.getPlayer(), t.teleToTile, e.getItem().getId()); } case ""Modify"" -> { if (!e.getPlayer().isQuestComplete(Quest.LOVE_STORY, ""to modify house teleports."")) return; e.getPlayer().sendInputInteger(""How many tabs would you like to modify?"", num -> { if (!e.getPlayer().getInventory().containsItem(e.getItem().getId(), num)) { e.getPlayer().sendMessage(""You don't have enough tablets to do that.""); return; } e.getPlayer().sendOptionDialogue(""Which tablet would you like to create?"", ops -> { ops.add(""House teleport"", () -> { e.getPlayer().getInventory().deleteItem(e.getItem().getId(), num); e.getPlayer().getInventory().addItem(8013, num); }); ops.add(""Rimmington teleport"", () -> { e.getPlayer().getInventory().deleteItem(e.getItem().getId(), num); e.getPlayer().getInventory().addItem(TeleTab.RIMMINGTON.id, num); }); ops.add(""Taverly teleport"", () -> { e.getPlayer().getInventory().deleteItem(e.getItem().getId(), num); e.getPlayer().getInventory().addItem(TeleTab.TAVERLY.id, num); }); ops.add(""Pollnivneach teleport"", () -> { e.getPlayer().getInventory().deleteItem(e.getItem().getId(), num); e.getPlayer().getInventory().addItem(TeleTab.POLLNIVNEACH.id, num); }); ops.add(""Relleka teleport"", () -> { e.getPlayer().getInventory().deleteItem(e.getItem().getId(), num); e.getPlayer().getInventory().addItem(TeleTab.RELLEKA.id, num); }); ops.add(""Brimhaven teleport"", () -> { e.getPlayer().getInventory().deleteItem(e.getItem().getId(), num); e.getPlayer().getInventory().addItem(TeleTab.BRIMHAVEN.id, num); }); ops.add(""Yanille teleport"", () -> { e.getPlayer().getInventory().deleteItem(e.getItem().getId(), num); e.getPlayer().getInventory().addItem(TeleTab.YANILLE.id, num); }); ops.add(""Trollheim teleport"", () -> { e.getPlayer().getInventory().deleteItem(e.getItem().getId(), num); e.getPlayer().getInventory().addItem(TeleTab.TROLLHEIM.id, num); }); }); }); if (!e.getPlayer().getInventory().hasFreeSlots()) { e.getPlayer().sendMessage(""You don't have enough inventory space to do that.""); return; } } } }); public static boolean meetsTabReqs(int itemId, Player p) { if (itemId == 20175 || (itemId >= 18809 && itemId <= 18814)) { if (!p.isQuestComplete(Quest.LOVE_STORY, ""to modify house teleports."")) return false; } if (itemId == 13608) { boolean hasEquip = false; for (Item item : p.getInventory().getItems().array()) { if (item == null) continue; if (Equipment.getItemSlot(item.getId()) != -1) { hasEquip = true; break; } } if (p.getEquipment().wearingArmour() || hasEquip) { p.sendMessage(""The power of Saradomin prevents you from teleporting to Entrana. Please bank all your equippable items.""); return false; } } if (itemId == 8012 && !p.isQuestComplete(Quest.WATCHTOWER)) { p.sendMessage(""You must have completed Watchtower to use this teleport.""); return false; } if (itemId == 13610 && !p.isQuestComplete(Quest.LEGACY_OF_SEERGAZE)) { p.sendMessage(""You must have completed Legacy of Seergaze to use this teleport.""); return false; } if (itemId == 13609 && !p.isQuestComplete(Quest.MOURNINGS_ENDS_PART_II)) { p.sendMessage(""You must have completed Mournings End Part II to use this teleport.""); return false; } return true; } }" "package com.rs.game.content.skills.magic; //342 343 teleother spotanims public enum TeleType { BYPASS_HOOKS, MAGIC, ITEM, OBJECT }" "package com.rs.game.content.skills.mining; public class DepletedOres { private static final Map ORE_MAP = new HashMap<>(); private static final Set DEPLETED_ORES = new HashSet<>(); static { ORE_MAP.put(25368, 25371); ORE_MAP.put(61181, 61184); ORE_MAP.put(2561, 10585); ORE_MAP.put(15576, 15582); ORE_MAP.put(15579, 15582); ORE_MAP.put(31167, 15582); ORE_MAP.put(31170, 15582); ORE_MAP.put(31173, 15582); ORE_MAP.put(2609, 14832); ORE_MAP.put(2704, 18961); ORE_MAP.put(14850, 14832); ORE_MAP.put(14853, 14832); ORE_MAP.put(14856, 14832); ORE_MAP.put(14859, 14832); ORE_MAP.put(14862, 14832); ORE_MAP.put(14902, 14892); ORE_MAP.put(14904, 14892); ORE_MAP.put(14906, 14892); ORE_MAP.put(14913, 14892); ORE_MAP.put(16998, 14892); ORE_MAP.put(17001, 14892); ORE_MAP.put(72075, 72078); ORE_MAP.put(72081, 72084); ORE_MAP.put(72087, 72089); ORE_MAP.put(72092, 72095); ORE_MAP.put(72098, 72101); ORE_MAP.put(9708, 9723); ORE_MAP.put(9711, 9723); ORE_MAP.put(9714, 9723); ORE_MAP.put(9717, 9723); ORE_MAP.put(9720, 9723); ORE_MAP.put(32449, 32447); ORE_MAP.put(32451, 32447); ORE_MAP.put(19012, 19009); ORE_MAP.put(19018, 19009); ORE_MAP.put(19024, 19009); ORE_MAP.put(3043, 3431); ORE_MAP.put(12564, 3431); ORE_MAP.put(32426, 33400); ORE_MAP.put(32429, 33400); ORE_MAP.put(32432, 33400); ORE_MAP.put(32435, 33400); ORE_MAP.put(32438, 33400); ORE_MAP.put(32441, 33400); ORE_MAP.put(32444, 33400); ORE_MAP.put(33078, 33400); ORE_MAP.put(37637, 37639); ORE_MAP.put(37638, 37639); ORE_MAP.put(37642, 37639); ORE_MAP.put(37645, 37639); ORE_MAP.put(10577, 10580); ORE_MAP.put(11930, 10580); ORE_MAP.put(11933, 10580); ORE_MAP.put(11936, 10580); ORE_MAP.put(11939, 10580); ORE_MAP.put(11942, 10580); ORE_MAP.put(37304, 10580); ORE_MAP.put(37307, 10580); ORE_MAP.put(37310, 10580); ORE_MAP.put(37670, 10580); ORE_MAP.put(5766, 5763); ORE_MAP.put(5768, 5763); ORE_MAP.put(5770, 5763); ORE_MAP.put(5773, 5763); ORE_MAP.put(5776, 5763); ORE_MAP.put(5779, 5763); ORE_MAP.put(5782, 5763); ORE_MAP.put(5784, 5763); ORE_MAP.put(11183, 37700); ORE_MAP.put(11186, 37700); ORE_MAP.put(11189, 37700); ORE_MAP.put(37208, 37700); ORE_MAP.put(11948, 11555); ORE_MAP.put(11951, 11555); ORE_MAP.put(11954, 11555); ORE_MAP.put(11957, 11555); ORE_MAP.put(11960, 11555); ORE_MAP.put(11963, 11555); ORE_MAP.put(15503, 11555); ORE_MAP.put(10948, 10944); ORE_MAP.put(10574, 19003); ORE_MAP.put(18991, 19003); ORE_MAP.put(18994, 19003); ORE_MAP.put(18997, 19003); ORE_MAP.put(19000, 19003); ORE_MAP.put(6669, 6947); ORE_MAP.put(6943, 6947); ORE_MAP.put(6945, 6947); ORE_MAP.put(2090, 450); ORE_MAP.put(2092, 450); ORE_MAP.put(2094, 450); ORE_MAP.put(2096, 450); ORE_MAP.put(2098, 450); ORE_MAP.put(2100, 450); ORE_MAP.put(2102, 450); ORE_MAP.put(2104, 450); ORE_MAP.put(2108, 450); ORE_MAP.put(21275, 450); ORE_MAP.put(21278, 450); ORE_MAP.put(21281, 450); ORE_MAP.put(21284, 450); ORE_MAP.put(21287, 450); ORE_MAP.put(21293, 450); ORE_MAP.put(29215, 17026); ORE_MAP.put(29221, 17026); ORE_MAP.put(29224, 17026); ORE_MAP.put(29227, 17026); ORE_MAP.put(29230, 17026); ORE_MAP.put(29233, 17026); ORE_MAP.put(29236, 17026); ORE_MAP.put(45067, 17026); ORE_MAP.put(45069, 17026); ORE_MAP.put(15246, 15249); ORE_MAP.put(3229, 3281); ORE_MAP.put(3233, 3281); ORE_MAP.put(3245, 3281); ORE_MAP.put(3273, 3281); ORE_MAP.put(3280, 3281); ORE_MAP.put(59427, 3281); ORE_MAP.put(25370, 25373); ORE_MAP.put(61183, 61186); ORE_MAP.put(33221, 33223); ORE_MAP.put(15578, 15584); ORE_MAP.put(15581, 15584); ORE_MAP.put(31169, 15584); ORE_MAP.put(2611, 14834); ORE_MAP.put(14852, 14834); ORE_MAP.put(14855, 14834); ORE_MAP.put(14858, 14834); ORE_MAP.put(14864, 14834); ORE_MAP.put(17000, 17009); ORE_MAP.put(17003, 17009); ORE_MAP.put(72077, 72080); ORE_MAP.put(72083, 72086); ORE_MAP.put(72088, 72091); ORE_MAP.put(72094, 72097); ORE_MAP.put(72100, 72103); ORE_MAP.put(9710, 9725); ORE_MAP.put(9713, 9725); ORE_MAP.put(9716, 9725); ORE_MAP.put(9719, 9725); ORE_MAP.put(9722, 9725); ORE_MAP.put(19014, 19011); ORE_MAP.put(19020, 19011); ORE_MAP.put(19026, 19011); ORE_MAP.put(3042, 33402); ORE_MAP.put(12566, 33402); ORE_MAP.put(32428, 33402); ORE_MAP.put(32431, 33402); ORE_MAP.put(32434, 33402); ORE_MAP.put(32437, 33402); ORE_MAP.put(32440, 33402); ORE_MAP.put(32443, 33402); ORE_MAP.put(32446, 33402); ORE_MAP.put(37644, 31061); ORE_MAP.put(37647, 31061); ORE_MAP.put(10579, 10582); ORE_MAP.put(11932, 10582); ORE_MAP.put(11935, 10582); ORE_MAP.put(11938, 10582); ORE_MAP.put(11941, 10582); ORE_MAP.put(11944, 10582); ORE_MAP.put(37306, 10582); ORE_MAP.put(37309, 10582); ORE_MAP.put(37312, 10582); ORE_MAP.put(5772, 5765); ORE_MAP.put(5775, 5765); ORE_MAP.put(5778, 5765); ORE_MAP.put(5781, 5765); ORE_MAP.put(5783, 5765); ORE_MAP.put(5786, 5765); ORE_MAP.put(11185, 37702); ORE_MAP.put(11188, 37702); ORE_MAP.put(11191, 37702); ORE_MAP.put(11947, 11557); ORE_MAP.put(11950, 11557); ORE_MAP.put(11953, 11557); ORE_MAP.put(11956, 11557); ORE_MAP.put(11959, 11557); ORE_MAP.put(11962, 11557); ORE_MAP.put(15505, 11557); ORE_MAP.put(10576, 19005); ORE_MAP.put(18993, 19005); ORE_MAP.put(18996, 19005); ORE_MAP.put(18999, 19005); ORE_MAP.put(19002, 19005); ORE_MAP.put(6671, 452); ORE_MAP.put(2091, 452); ORE_MAP.put(2093, 452); ORE_MAP.put(2095, 452); ORE_MAP.put(2097, 452); ORE_MAP.put(2099, 452); ORE_MAP.put(2101, 452); ORE_MAP.put(2103, 452); ORE_MAP.put(2105, 452); ORE_MAP.put(2109, 452); ORE_MAP.put(21277, 21298); ORE_MAP.put(21280, 21298); ORE_MAP.put(21283, 21298); ORE_MAP.put(21286, 21298); ORE_MAP.put(21289, 21298); ORE_MAP.put(21295, 21298); ORE_MAP.put(29217, 29220); ORE_MAP.put(29223, 29220); ORE_MAP.put(29226, 29220); ORE_MAP.put(29229, 29220); ORE_MAP.put(29235, 29220); ORE_MAP.put(15248, 15251); ORE_MAP.put(3027, 3227); ORE_MAP.put(3032, 3227); ORE_MAP.put(3038, 3227); ORE_MAP.put(3040, 3227); ORE_MAP.put(3041, 3227); ORE_MAP.put(59426, 3227); ORE_MAP.put(25369, 25372); ORE_MAP.put(61182, 61185); ORE_MAP.put(25369, 25372); ORE_MAP.put(61182, 61185); ORE_MAP.put(15577, 15583); ORE_MAP.put(15580, 15583); ORE_MAP.put(31168, 15583); ORE_MAP.put(31174, 15583); ORE_MAP.put(2610, 14833); ORE_MAP.put(14851, 14833); ORE_MAP.put(14854, 14833); ORE_MAP.put(14857, 14833); ORE_MAP.put(14860, 14833); ORE_MAP.put(14863, 14833); ORE_MAP.put(14903, 14893); ORE_MAP.put(14905, 14893); ORE_MAP.put(14907, 14893); ORE_MAP.put(16999, 14893); ORE_MAP.put(17002, 14893); ORE_MAP.put(14914, 14916); ORE_MAP.put(72076, 72079); ORE_MAP.put(72082, 72085); ORE_MAP.put(72093, 72096); ORE_MAP.put(72099, 72102); ORE_MAP.put(9709, 9724); ORE_MAP.put(9718, 9724); ORE_MAP.put(32450, 32448); ORE_MAP.put(32452, 32448); ORE_MAP.put(19013, 19010); ORE_MAP.put(19019, 19010); ORE_MAP.put(19025, 19010); ORE_MAP.put(32427, 33401); ORE_MAP.put(32430, 33401); ORE_MAP.put(32433, 33401); ORE_MAP.put(32436, 33401); ORE_MAP.put(32439, 33401); ORE_MAP.put(32442, 33401); ORE_MAP.put(32445, 33401); ORE_MAP.put(33079, 33401); ORE_MAP.put(37643, 31060); ORE_MAP.put(37646, 31060); ORE_MAP.put(10578, 10581); ORE_MAP.put(11931, 11553); ORE_MAP.put(11934, 11553); ORE_MAP.put(11937, 11553); ORE_MAP.put(11943, 11553); ORE_MAP.put(37305, 11553); ORE_MAP.put(37308, 11553); ORE_MAP.put(5767, 5764); ORE_MAP.put(5769, 5764); ORE_MAP.put(5771, 5764); ORE_MAP.put(5774, 5764); ORE_MAP.put(5777, 5764); ORE_MAP.put(5780, 5764); ORE_MAP.put(5785, 5764); ORE_MAP.put(11184, 37701); ORE_MAP.put(11187, 37701); ORE_MAP.put(11190, 37701); ORE_MAP.put(11946, 11556); ORE_MAP.put(11949, 11556); ORE_MAP.put(11952, 11556); ORE_MAP.put(11955, 11556); ORE_MAP.put(11958, 11556); ORE_MAP.put(11961, 11556); ORE_MAP.put(11964, 11556); ORE_MAP.put(15504, 11556); ORE_MAP.put(10949, 10945); ORE_MAP.put(10575, 19004); ORE_MAP.put(18992, 19004); ORE_MAP.put(18995, 19004); ORE_MAP.put(18998, 19004); ORE_MAP.put(19001, 19004); ORE_MAP.put(6670, 6948); ORE_MAP.put(6944, 6948); ORE_MAP.put(6946, 6948); ORE_MAP.put(21276, 21297); ORE_MAP.put(21279, 21297); ORE_MAP.put(21282, 21297); ORE_MAP.put(21285, 21297); ORE_MAP.put(21288, 21297); ORE_MAP.put(21294, 21297); ORE_MAP.put(29216, 29219); ORE_MAP.put(29222, 29219); ORE_MAP.put(29225, 29219); ORE_MAP.put(29231, 29219); ORE_MAP.put(45068, 29219); ORE_MAP.put(45070, 29219); ORE_MAP.put(15247, 15250); ORE_MAP.put(20420, 20442); ORE_MAP.put(70102, 20442); ORE_MAP.put(20412, 20442); ORE_MAP.put(20445, 20442); ORE_MAP.put(20448, 20442); ORE_MAP.put(20416, 20442); ORE_MAP.put(20418, 20441); ORE_MAP.put(20410, 20441); ORE_MAP.put(20422, 20441); ORE_MAP.put(20443, 20441); ORE_MAP.put(20446, 20441); ORE_MAP.put(20449, 20441); ORE_MAP.put(20414, 20441); ORE_MAP.put(20407, 20440); ORE_MAP.put(20421, 20440); ORE_MAP.put(20413, 20440); ORE_MAP.put(20425, 20440); ORE_MAP.put(20408, 20440); ORE_MAP.put(20417, 20440); ORE_MAP.put(20419, 20439); ORE_MAP.put(20411, 20439); ORE_MAP.put(20423, 20439); ORE_MAP.put(20444, 20439); ORE_MAP.put(20447, 20439); ORE_MAP.put(20450, 20439); ORE_MAP.put(20415, 20439); ORE_MAP.put(5989, 5992); ORE_MAP.put(34976, 5992); ORE_MAP.put(34977, 5992); ORE_MAP.put(11195, 11366); ORE_MAP.put(17005, 11366); ORE_MAP.put(11180, 11192); ORE_MAP.put(11194, 11365); ORE_MAP.put(17004, 11365); ORE_MAP.put(11179, 11182); ORE_MAP.put(11364, 11367); ORE_MAP.put(17006, 11367); ORE_MAP.put(11181, 11193); ORE_MAP.put(42868, 42869); ORE_MAP.put(42865, 42866); ORE_MAP.put(42862, 42863); ORE_MAP.put(29746, 29747); ORE_MAP.put(10946, 2551); ORE_MAP.put(10947, 2560); ORE_MAP.put(4027, 4029); ORE_MAP.put(4028, 4029); ORE_MAP.put(17962, 17965); DEPLETED_ORES.addAll(ORE_MAP.values()); } public static int get(int id) { if (ORE_MAP.get(id) != null) return ORE_MAP.get(id); return 11555; } public static boolean isDepleted(int id) { return DEPLETED_ORES.contains(id); } }" "package com.rs.game.content.skills.mining; @PluginEventHandler public class Mining extends Action { public static ObjectClickHandler handleClay = new ObjectClickHandler(new Object[] { ""Clay rocks"", ""Clay vein"", ""Clay rock"" }, e -> e.getPlayer().getActionManager().setAction(new Mining(RockType.CLAY, e.getObject()))); public static ObjectClickHandler handleCopper = new ObjectClickHandler(new Object[] { ""Copper ore rocks"", ""Copper ore vein"", ""Copper rock"" }, e -> e.getPlayer().getActionManager().setAction(new Mining(RockType.COPPER, e.getObject()))); public static ObjectClickHandler handleTin = new ObjectClickHandler(new Object[] { ""Tin ore rocks"", ""Tin ore vein"", ""Tin rock"" }, e -> e.getPlayer().getActionManager().setAction(new Mining(RockType.TIN, e.getObject()))); public static ObjectClickHandler handleBlurite = new ObjectClickHandler(new Object[] { ""Blurite ore rocks"" }, e -> e.getPlayer().getActionManager().setAction(new Mining(RockType.BLURITE, e.getObject()))); public static ObjectClickHandler handleLimestone = new ObjectClickHandler(new Object[] { ""Limestone rocks"" }, e -> e.getPlayer().getActionManager().setAction(new Mining(RockType.LIMESTONE, e.getObject()))); public static ObjectClickHandler handleIron = new ObjectClickHandler(new Object[] { ""Iron ore rocks"", ""Iron ore vein"" }, e -> e.getPlayer().getActionManager().setAction(new Mining(RockType.IRON, e.getObject()))); public static ObjectClickHandler handleSilver = new ObjectClickHandler(new Object[] { ""Silver ore rocks"", ""Silver ore vein"" }, e -> e.getPlayer().getActionManager().setAction(new Mining(RockType.SILVER, e.getObject()))); public static ObjectClickHandler handleGold = new ObjectClickHandler(new Object[] { ""Gold ore rocks"", ""Gold ore vein"" }, e -> { if(e.getObject().getTile().getRegionId() == 10903)//witchhaven mine e.getPlayer().getActionManager().setAction(new Mining(RockType.PERFECT_GOLD, e.getObject())); else e.getPlayer().getActionManager().setAction(new Mining(RockType.GOLD, e.getObject())); }); public static ObjectClickHandler handleCoal = new ObjectClickHandler(new Object[] { ""Coal rocks"", ""Coal vein"" }, e -> e.getPlayer().getActionManager().setAction(new Mining(RockType.COAL, e.getObject()))); public static ObjectClickHandler handleMithril = new ObjectClickHandler(new Object[] { ""Mithril ore rocks"", ""Mithril ore vein"" }, e -> e.getPlayer().getActionManager().setAction(new Mining(RockType.MITHRIL, e.getObject()))); public static ObjectClickHandler handleAddy = new ObjectClickHandler(new Object[] { ""Adamantite ore rocks"", ""Adamantite ore vein"" }, e -> e.getPlayer().getActionManager().setAction(new Mining(RockType.ADAMANT, e.getObject()))); public static ObjectClickHandler handleBane = new ObjectClickHandler(new Object[] { ""Bane ore rock"" }, e -> e.getPlayer().getActionManager().setAction(new Mining(RockType.BANE, e.getObject()))); public static ObjectClickHandler handleRune = new ObjectClickHandler(new Object[] { ""Runite ore rocks"" }, e -> e.getPlayer().getActionManager().setAction(new Mining(RockType.RUNE, e.getObject()))); public static ObjectClickHandler handleGranite = new ObjectClickHandler(new Object[] { ""Granite rocks"" }, e -> e.getPlayer().getActionManager().setAction(new Mining(RockType.GRANITE, e.getObject()))); public static ObjectClickHandler handleSandstone = new ObjectClickHandler(new Object[] { ""Sandstone rocks"" }, e -> e.getPlayer().getActionManager().setAction(new Mining(RockType.SANDSTONE, e.getObject()))); public static ObjectClickHandler handleGemRocks = new ObjectClickHandler(new Object[] { ""Gem rocks"" }, e -> e.getPlayer().getActionManager().setAction(new Mining(RockType.GEM, e.getObject()))); public static ObjectClickHandler handleLRCCoal = new ObjectClickHandler(new Object[] { 5999 }, e -> e.getPlayer().getActionManager().setAction(new Mining(RockType.CONC_COAL, e.getObject()))); public static ObjectClickHandler handleLRCGold = new ObjectClickHandler(new Object[] { 45076 }, e -> e.getPlayer().getActionManager().setAction(new Mining(RockType.CONC_GOLD, e.getObject()))); public static ObjectClickHandler handleEss = new ObjectClickHandler(new Object[] { 2491 }, e -> e.getPlayer().getActionManager().setAction(new Mining(RockType.ESSENCE, e.getObject()))); public static NPCClickHandler handleLRCMinerals = new NPCClickHandler(new Object[] { 8837, 8838, 8839 }, e -> e.getPlayer().getActionManager().setAction(new Mining(RockType.LIVING_MINERALS, e.getNPC(), () -> e.getNPC().getId() - 5))); public static ObjectClickHandler handleRedSandstone = new ObjectClickHandler(new Object[] { 2330 }, e -> { if (e.getPlayer().getDailyI(""redSandstoneMined"") < 50) e.getPlayer().getActionManager().setAction(new Mining(RockType.RED_SANDSTONE, e.getObject())); else e.getPlayer().sendMessage(""You've mined all you can from the rock.""); }); public static LoginHandler updateSandstone = new LoginHandler(e -> e.getPlayer().getVars().setVarBit(10133, e.getPlayer().getDailyI(""redSandstoneMined""))); private final RockType type; private Pickaxe pick; private int rockId; private GameObject rockObj; private NPC rockNPC; private Supplier replaceId; public Mining(RockType type, GameObject rock) { this.type = type; this.rockId = rock.getId(); rockObj = rock; } public Mining(RockType type, NPC rock, Supplier replaceId) { this.type = type; rockNPC = rock; this.replaceId = replaceId; } @Override public boolean start(Entity entity) { if (entity instanceof Player player) pick = Pickaxe.getBest(player); else pick = Pickaxe.DRAGON_G; if (!checkAll(entity)) return false; if (entity instanceof Player player) player.sendMessage(""You swing your pickaxe at the rock..."", true); setActionDelay(entity, ((pick == Pickaxe.DRAGON || pick == Pickaxe.DRAGON_G) && Utils.random(2) == 0) ? 1 : 2); return true; } @Override public boolean process(Entity entity) { entity.anim(pick.getAnimId()); return checkAll(entity); } private static final Map VARROCK_ARMOR_ORE_TIERS = Map.of( Ore.COPPER, new int[] { 0, 4 }, Ore.TIN, new int[] { 0, 4 }, Ore.IRON, new int[] { 0, 4 }, Ore.COAL, new int[] { 0, 4 }, Ore.GOLD, new int[] { 0, 4 }, Ore.MITHRIL, new int[] { 1, 4 }, Ore.ADAMANT, new int[] { 2, 4 }, Ore.RUNE, new int[] { 3, 4 } ); @Override public int processWithDelay(Entity entity) { int level = entity instanceof Player player ? player.getSkills().getLevel(Constants.MINING) + player.getInvisibleSkillBoost(Constants.MINING) : 99; boolean success = false; if (type.getOres().size() == 1 && !type.getOres().getFirst().checkRequirements(entity instanceof Player player ? player : null)) return -1; for (Ore ore : type.getOres()) { if (ore.checkRequirements(entity instanceof Player player ? player : null) && ore.rollSuccess(entity instanceof Player player ? player : null, level)) { if (entity instanceof Player player) { ore.giveOre(player); int[] range = VARROCK_ARMOR_ORE_TIERS.get(ore); if (range != null && Arrays.stream(SetReward.VARROCK_ARMOR.getItemIds(), range[0], range[1]).anyMatch(x -> x == player.getEquipment().getChestId()) && Utils.random(100) <= 10) ore.giveOre(player); if (player.hasEffect(Effect.SHOOTING_STAR_MINING_BUFF) && Utils.random(4) == 0) ore.giveOre(player); } success = true; if (ore.getRollGem() == 1 && entity instanceof Player player) rollForGem(player); break; } } if (rockObj != null && rockObj instanceof Star star && success) star.minedThisTick = true; if (success && depleteOre(entity)) { entity.setNextAnimation(new Animation(-1)); return -1; } return ((pick == Pickaxe.DRAGON || pick == Pickaxe.DRAGON_G) && Utils.random(2) == 0) ? pick.getTicks() - 2 : pick.getTicks() - 1; } public boolean depleteOre(Entity entity) { if (type.depletes()) { if (entity instanceof Player player && player.getAuraManager().isActivated(AuraManager.Aura.RESOURCEFUL) && Utils.random(10) == 0) { player.sendMessage(""Your resourceful aura prevents the rock from being depleted.""); return false; } if (rockObj != null) rockObj.setIdTemporary(DepletedOres.get(rockObj.getId()), type.getRespawnTime()); if (rockNPC != null) { rockNPC.setNPC(replaceId.get()); rockNPC.setLocation(rockNPC.getRespawnTile()); rockNPC.setRandomWalk(true); rockNPC.finish(); if (!rockNPC.isSpawned()) rockNPC.setRespawnTask(); } return true; } return false; } private boolean checkAll(Entity entity) { if (!checkRock()) return false; if (rockObj != null && DepletedOres.isDepleted(rockObj.getId())) { if (entity instanceof Player player) player.sendMessage(""This rock is empty right now.""); return false; } if (pick == null) { if (entity instanceof Player player) player.sendMessage(""You need a pickaxe and the level required to use it to mine.""); return false; } if (entity instanceof Player player) { if (player.getSkills().getLevel(Constants.MINING) < type.getLevel()) { player.sendMessage(""You need a mining level of "" + type.getLevel() + "" to mine here.""); player.soundEffect(2661, false); return false; } if (!player.getInventory().hasFreeSlots()) { player.setNextAnimation(new Animation(-1)); player.sendMessage(""You don't have enough inventory space.""); player.soundEffect(2277, false); return false; } } return true; } @Override public void stop(final Entity entity) { setActionDelay(entity, pick.getTicks()); } public boolean checkRock() { return rockObj != null ? ChunkManager.getChunk(rockObj.getTile().getChunkId()).objectExists(new GameObject(rockObj, rockId)) : !rockNPC.hasFinished(); } public static double getXPMultiplier(Player player) { double mul = 1.0; if (player.getEquipment().getGlovesId() == 20787) mul += 0.01; if (player.getEquipment().getBootsId() == 20788) mul += 0.01; if (player.getEquipment().getHatId() == 20789) mul += 0.01; if (player.getEquipment().getChestId() == 20791) mul += 0.01; if (player.getEquipment().getLegsId() == 20790) mul += 0.01; return mul; } public static void rollForGem(Player player) { int random = Utils.random(256); // >= 10354 && <= 10360 //charged trimmed glory // >= 1706 && <= 1712 //charged glory int neck = player.getEquipment().getAmuletId(); if ((neck >= 10354 && neck <= 10360) || (neck >= 1706 && neck <= 1712)) random = Utils.random(86); if (random == 0) { random = Utils.random(10); if (random >= 9) player.getInventory().addItemDrop(1617, 1); // Uncut Diamond else if (random >= 7) player.getInventory().addItemDrop(1619, 1); // Uncut Ruby else if (random >= 4) player.getInventory().addItemDrop(1621, 1); // Uncut Emerald else player.getInventory().addItemDrop(1623, 1); // Uncut Sapphire } } }" "package com.rs.game.content.skills.mining; public enum Ore { CLAY(434, 1, 5, 128, 402, 0), COPPER(436, 1, 17.5, 60, 220, 1), TIN(438, 1, 17.5, 60, 220, 1), BLURITE(668, 10, 17.5, 60, 140, 1), LIMESTONE(3211, 10, 26.5, 97, 350, 0), IRON(440, 15, 35, 145, 326, 1), DAEYALT(9632, 20, 10, 50, 130, 0), ELEMENTAL(2892, 1, 1, 50, 130, 0), SILVER(442, 20, 40, 26, 201, 1), COAL(453, 30, 50, 16, 100, 1), GOLD(444, 40, 65, 7, 76, 1), PERFECT_GOLD(446, 40, 65, 7, 76, 1), LUNAR(9076, 60, 25, 50, 130, 0), MITHRIL(447, 55, 80, 4, 50, 1), GRANITE_500G(6979, 45, 50, 16, 100, 0), GRANITE_2KG(6981, 45, 60, 8, 75, 0), GRANITE_5KG(6983, 45, 75, 6, 64, 0), SANDSTONE_1KG(6971, 35, 30, 16, 100, 0), SANDSTONE_2KG(6973, 35, 40, 8, 75, 0), SANDSTONE_5KG(6975, 35, 50, 6, 64, 0), SANDSTONE_10KG(6977, 35, 60, 3, 30, 0), ADAMANT(449, 70, 95, 2, 25, 1), BANE(21778, 77, 90, 2, 25, 0), RUNE(451, 85, 125, 11, 19, 0), RUNE_ESSENCE(1436, 1, 5, 180, 380, 0) { @Override public boolean checkRequirements(Player player) { return player.getSkills().getLevel(Constants.MINING) < 30; } }, PURE_ESSENCE(7936, 1, 5, 180, 380, 0) { @Override public boolean checkRequirements(Player player) { return player.getSkills().getLevel(Constants.MINING) >= 30; } }, GEM(-1, 40, 65, 26, 71, 0) { @Override public boolean rollSuccess(Player player, int level) { int neck = player.getEquipment().getAmuletId(); boolean charged = (neck >= 10354 && neck <= 10360) || (neck >= 1706 && neck <= 1712); return Utils.skillSuccess(level, player.getAuraManager().getMiningMul(), charged ? 83 : 26, charged ? 211 : 71); } @Override public void giveOre(Player player) { double totalXp = getXp() * Mining.getXPMultiplier(player); for (Item gem : DropTable.calculateDrops(player, DropSets.getDropSet(""gem_rock""))) { player.sendMessage(""You successfully mine "" + Utils.addArticle(gem.getDefinitions().getName().toLowerCase()) + ""."", true); player.getSkills().addXp(Constants.MINING, totalXp); player.incrementCount(gem.getDefinitions().getName()+"" mined""); player.getInventory().addItem(gem); } } }, LIVING_MINERALS(15263, 73, 25, 30, 145, 0) { @Override public void giveOre(Player player) { double totalXp = getXp() * Mining.getXPMultiplier(player); Item item = new Item(getId(), Utils.random(5, 21)); player.sendMessage(""You successfully mine some "" + item.getDefinitions().getName().toLowerCase() + ""."", true); player.getSkills().addXp(Constants.MINING, totalXp); player.getInventory().addItem(item); player.incrementCount(item.getDefinitions().getName()+"" mined"", item.getAmount()); } }, CONCENTRATED_COAL(453, 77, 50, 16, 100, 1), CONCENTRATED_GOLD(444, 80, 65, 7, 76, 1), RED_SANDSTONE(23194, 81, 70, 30, 145, 0) { @Override public boolean checkRequirements(Player player) { return player.getSkills().getLevel(Constants.MINING) >= getLevel() && player.getDailyI(""redSandstoneMined"") < 50; } @Override public void onGiveOre(Player player) { if (player.getAuraManager().isActivated(AuraManager.Aura.RESOURCEFUL) && Utils.random(10) == 0) { player.sendMessage(""Your resourceful aura prevents the sandstone from being depleted.""); return; } player.incDailyI(""redSandstoneMined""); player.getVars().setVarBit(10133, player.getDailyI(""redSandstoneMined"")); } }, STARDUST_1(13727, 10, 14, 59, 256, 1), STARDUST_2(13727, 20, 25, 59, 146, 1), STARDUST_3(13727, 30, 29, 59, 126, 1), STARDUST_4(13727, 40, 32, 59, 113, 1), STARDUST_5(13727, 50, 47, 59, 77, 1), STARDUST_6(13727, 60, 71, 38, 51, 1), STARDUST_7(13727, 70, 114, 25, 35, 1), STARDUST_8(13727, 80, 145, 20, 30, 1), STARDUST_9(13727, 90, 210, 15, 20, 1), ; private final int id; private final int level; private final int rate1; private final int rate99; private final double xp; private final int rollGem; private Ore(int id, int level, double xp, int rate1, int rate99, int rollGem) { this.id = id; this.level = level; this.xp = xp; this.rate1 = rate1; this.rate99 = rate99; this.rollGem = rollGem; } public int getId() { return id; } public int getLevel() { return level; } public double getXp() { return xp; } public int getRollGem() { return rollGem; } public boolean checkRequirements(Player player) { return player == null ? true : player.getSkills().getLevel(Constants.MINING) >= level; } public boolean rollSuccess(Player player, int level) { return Utils.skillSuccess(level, player != null ? player.getAuraManager().getMiningMul() : 1.0, rate1, rate99); } public void onGiveOre(Player player) { } public void giveOre(Player player) { Item ore = new Item(id); double totalXp = xp * Mining.getXPMultiplier(player); if (player.hasEffect(Effect.JUJU_MINING)) { int random = Utils.random(100); if (random < 11) player.addEffect(Effect.JUJU_MINE_BANK, 75); } if (!name().startsWith(""STARDUST"")) player.sendMessage(""You successfully mine "" + Utils.addArticle(ore.getDefinitions().getName().toLowerCase()) + ""."", true); if (player.hasEffect(Effect.JUJU_MINE_BANK) && !name().startsWith(""STARDUST"")) { player.getBank().addItem(ore, true); player.setNextSpotAnim(new SpotAnim(2896)); } else player.getInventory().addItem(id, 1); player.getSkills().addXp(Constants.MINING, totalXp); player.incrementCount(ore.getDefinitions().getName()+"" mined""); onGiveOre(player); } }" "package com.rs.game.content.skills.mining; public enum Pickaxe { BRONZE(1265, 1, 625, 8), BRONZE_G(20780, 1, 234, 8), IRON(1267, 1, 626, 7), IRON_G(20781, 1, 235, 7), STEEL(1269, 6, 627, 6), STEEL_G(20782, 6, 236, 6), MITHRIL(1273, 21, 629, 5), MITHRIL_G(20784, 21, 238, 5), ADAMANT(1271, 31, 628, 4), ADAMANT_G(20783, 31, 237, 4), RUNE(1275, 41, 624, 3), RUNE_G(20785, 41, 249, 3), DRAGON(15259, 61, 12189, 3), DRAGON_G(20786, 61, 250, 3), INFERNO_ADZE(13661, 61, 10222, 3); private final int itemId; private final int level; private final int ticks; private final int animId; private Pickaxe(int itemId, int level, int animId, int ticks) { this.itemId = itemId; this.level = level; this.animId = animId; this.ticks = ticks; } public int getItemId() { return itemId; } public int getLevel() { return level; } public int getTicks() { return ticks; } public int getAnimId() { return animId; } public static Pickaxe getBest(Player player) { for (int i = Pickaxe.values().length-1; i >= 0; i--) { Pickaxe def = Pickaxe.values()[i]; if (player.getInventory().containsItem(def.itemId) || player.getEquipment().getWeaponId() == def.itemId) if (player.getSkills().getLevel(Constants.MINING) >= def.level) return def; } return null; } }" "package com.rs.game.content.skills.mining; public enum RockType { ESSENCE(-1, Ore.RUNE_ESSENCE, Ore.PURE_ESSENCE), CLAY(2, Ore.CLAY), COPPER(4, Ore.COPPER), TIN(4, Ore.TIN), BLURITE(40, Ore.BLURITE), LIMESTONE(40, Ore.LIMESTONE), IRON(9, Ore.IRON), DAEYALT(40, Ore.DAEYALT), ELEMENTAL(0, Ore.ELEMENTAL), SILVER(100, Ore.SILVER), GEM(60, Ore.GEM), COAL(50, Ore.COAL), GOLD(100, Ore.GOLD), PERFECT_GOLD(100, Ore.PERFECT_GOLD), LUNAR(100, Ore.LUNAR), MITHRIL(200, Ore.MITHRIL), GRANITE(20, Ore.GRANITE_500G, Ore.GRANITE_2KG, Ore.GRANITE_5KG), SANDSTONE(20, Ore.SANDSTONE_10KG, Ore.SANDSTONE_5KG, Ore.SANDSTONE_2KG, Ore.SANDSTONE_1KG), ADAMANT(400, Ore.ADAMANT), BANE(100, Ore.BANE), RUNE(1200, Ore.RUNE), CONC_COAL(-1, Ore.CONCENTRATED_COAL), CONC_GOLD(-1, Ore.CONCENTRATED_GOLD), LIVING_MINERALS(0, Ore.LIVING_MINERALS), RED_SANDSTONE(-1, Ore.RED_SANDSTONE), CRASHED_STAR_1(-1, Ore.STARDUST_1), CRASHED_STAR_2(-1, Ore.STARDUST_2), CRASHED_STAR_3(-1, Ore.STARDUST_3), CRASHED_STAR_4(-1, Ore.STARDUST_4), CRASHED_STAR_5(-1, Ore.STARDUST_5), CRASHED_STAR_6(-1, Ore.STARDUST_6), CRASHED_STAR_7(-1, Ore.STARDUST_7), CRASHED_STAR_8(-1, Ore.STARDUST_8), CRASHED_STAR_9(-1, Ore.STARDUST_9), ; private final int respawnTime; private final List ores; private RockType(int respawnTime, Ore... ores) { this.respawnTime = respawnTime; this.ores = new ArrayList<>(Arrays.asList(ores)); this.ores.sort((f1, f2) -> f2.getLevel() == f1.getLevel() ? Double.compare(f2.getXp(), f1.getXp()) : f2.getLevel()-f1.getLevel()); } public List getOres() { return ores; } public int getLevel() { return ores.getLast().getLevel(); } public int getRespawnTime() { return respawnTime; } public boolean depletes() { return respawnTime != -1; } }" "package com.rs.game.content.skills.prayer; @PluginEventHandler public class BoneAltar { public static final int ANIM = 3705; public static final int GFX = 624; public enum Altar { OAK(13179, 2.0f), TEAK(13182, 2.1f), CLOTH(13185, 2.25f), MAHOGANY(13188, 2.5f), LIMESTONE(13191, 2.75f), MARBLE(13194, 3.0f), GILDED(13197, 3.5f); final int objectId; final float xpMul; private Altar(int objectId, float xpMul) { this.objectId = objectId; this.xpMul = xpMul; } public int getObjectId() { return objectId; } public float getXpMul() { return xpMul; } } static class BoneAction extends PlayerAction { private final Altar altar; private final Bone bone; private final GameObject object; public BoneAction(Altar altar, Bone bone, GameObject object) { this.altar = altar; this.bone = bone; this.object = object; } @Override public boolean start(Player player) { if (object != null && player.getInventory().containsItem(bone.getId(), 1)) return true; return false; } @Override public boolean process(Player player) { if (player.getInventory().containsItem(bone.getId(), 1) && object != null) return true; return false; } @Override public int processWithDelay(Player player) { if (player.getInventory().containsItem(bone.getId(), 1)) { player.incrementCount(ItemDefinitions.getDefs(bone.getId()).getName()+"" offered at altar""); player.getInventory().deleteItem(bone.getId(), 1); player.getSkills().addXp(Constants.PRAYER, bone.getExperience()*altar.getXpMul()); player.setNextAnimation(new Animation(ANIM)); World.sendSpotAnim(object.getTile(), new SpotAnim(GFX)); } return 2; } @Override public void stop(Player player) { } } public static ItemOnObjectHandler handleBonesOnAltar = new ItemOnObjectHandler(new Object[] { 13179, 13182, 13185, 13188, 13191, 13194, 13197 }, Arrays.stream(Bone.values()).map(Bone::getId).toArray(), e -> { Altar altar = null; Bone bone = null; for (Altar altars : Altar.values()) if (altars.getObjectId() == e.getObject().getId()) { altar = altars; break; } for (Bone bones : Bone.values()) if (bones.getId() == e.getItem().getId()) { bone = bones; break; } if (bone == null) return; e.getPlayer().getActionManager().setAction(new BoneAction(altar, bone, e.getObject())); }); }" "package com.rs.game.content.skills.prayer; public class Burying { public enum Bone { NORMAL(526, 4.5), BURNT(528, 4.5), TROLL_GENERAL(23031, 4.5), WOLF(2859, 4.5), MONKEY(3183, 4.5), BAT(530, 5.2), BIG(532, 15), JOGRE(3125, 15), ZOGRE(4812, 22.5), SHAIKAHAN(3123, 25), BABY(534, 30), WYVERN(6812, 50), DRAGON(536, 72), FAYRG(4830, 84), RAURG(4832, 96), DAGANNOTH(6729, 125), OURG(4834, 140), OURG2(14793, 140), FROST_DRAGON2(18830, 180), FROST_DRAGON(18832, 180), IMPIOUS_ASHES(20264, 4), ACCURSED_ASHES(20266, 12.5), INFERNAL_ASHES(20268, 62.5); private final int id; private final double experience; private static final Map bones = new HashMap<>(); static { for (Bone bone : Bone.values()) bones.put(bone.getId(), bone); } public static Bone forId(int id) { return bones.get(id); } private Bone(int id, double experience) { this.id = id; this.experience = experience; } public int getId() { return id; } public double getExperience() { return experience; } public static final Animation BURY_ANIMATION = new Animation(827); public static final Animation SCATTER_ANIMATION = new Animation(445); public static void bury(final Player player, int inventorySlot) { final Item item = player.getInventory().getItem(inventorySlot); if (item == null || Bone.forId(item.getId()) == null || !player.canBury()) return; final Bone bone = Bone.forId(item.getId()); final ItemDefinitions itemDef = new ItemDefinitions(item.getId()); player.lock(); player.soundEffect(2738, true); player.setNextAnimation(bone.name().contains(""ASHES"") ? SCATTER_ANIMATION : BURY_ANIMATION); if (bone == Bone.ACCURSED_ASHES) player.setNextSpotAnim(new SpotAnim(56)); else if (bone == Bone.IMPIOUS_ASHES) player.setNextSpotAnim(new SpotAnim(47)); else if (bone == Bone.INFERNAL_ASHES) player.setNextSpotAnim(new SpotAnim(40)); player.sendMessage(bone.name().contains(""ASHES"") ? ""You scatter the ashes in the wind..."" : ""You dig a hole in the ground...""); WorldTasks.schedule(new Task() { @Override public void run() { handleNecklaces(player, bone.getId()); player.sendMessage(""You bury the "" + itemDef.getName().toLowerCase()); player.getInventory().deleteItem(item.getId(), 1); double xp = bone.getExperience(); player.getSkills().addXp(Constants.PRAYER, xp); player.incrementCount(itemDef.getName()+"" buried""); player.addBoneDelay(1); player.unlock(); stop(); } }, 0); } } public static void handleNecklaces(Player player, int itemId) { ItemDefinitions itemDef = ItemDefinitions.getDefs(itemId); int prayerGain = 0; if (itemDef.getName().toLowerCase().contains(""dragon"") || itemDef.getName().toLowerCase().contains(""ourg"")) switch (player.getEquipment().getAmuletId()) { case 19888: prayerGain = 30; break; case 19887: case 19886: prayerGain = 10; break; default: break; } else if (itemDef.getName().toLowerCase().contains(""big"") || itemDef.getName().toLowerCase().contains(""baby dragon"")) switch (player.getEquipment().getAmuletId()) { case 19888: case 19887: prayerGain = 20; break; case 19886: prayerGain = 10; break; default: break; } else if (itemDef.getName().toLowerCase().equals(""bones"")) switch (player.getEquipment().getAmuletId()) { case 19888: case 19887: case 19886: prayerGain = 10; break; default: break; } player.getPrayer().restorePrayer(prayerGain); } }" "package com.rs.game.content.skills.prayer; @PluginEventHandler public class EnchantSymbols { public static int HOLY_BOOK = 3840; public static int UNHOLY_BOOK = 3842; public static int BOOK_OF_BALANCE = 3844; public static int UNBLESSED_SYMBOL = 1716; public static int UNPOWERED_SYMBOL = 1722; public static int HOLY_SYMBOL = 1718; public static int UNHOLY_SYMBOL = 1724; public static ItemOnItemHandler itemOnItem = new ItemOnItemHandler(new int[] { HOLY_BOOK, UNHOLY_BOOK, BOOK_OF_BALANCE }, new int[] { UNBLESSED_SYMBOL, UNPOWERED_SYMBOL }, e -> { if (e.usedWith(HOLY_BOOK, UNBLESSED_SYMBOL)) { if (e.getPlayer().getSkills().getLevel(Constants.PRAYER) < 50) { e.getPlayer().sendMessage(""You need at least level 50 prayer to enchant this.""); return; } if (e.getPlayer().getPrayer().getPoints() < 20) { e.getPlayer().sendMessage(""You do not have enough prayer points. Please recharge your prayer at the Lumbridge church.""); return; } e.getPlayer().getInventory().deleteItem(UNBLESSED_SYMBOL, 1); e.getPlayer().getInventory().addItem(HOLY_SYMBOL, 1); e.getPlayer().setNextAnimation(new Animation(1335)); e.getPlayer().getPrayer().drainPrayer(20); e.getPlayer().sendMessage(""You bless the holy symbol.""); return; } if (e.usedWith(BOOK_OF_BALANCE, UNBLESSED_SYMBOL)) { if (e.getPlayer().getSkills().getLevel(Constants.PRAYER) < 50) { e.getPlayer().sendMessage(""You need at least level 50 prayer to enchant this.""); return; } if (e.getPlayer().getPrayer().getPoints() < 20) { e.getPlayer().sendMessage(""You do not have enough prayer points. Please recharge your prayer at the Lumbridge church.""); return; } e.getPlayer().getInventory().deleteItem(UNBLESSED_SYMBOL, 1); e.getPlayer().getInventory().addItem(HOLY_SYMBOL, 1); e.getPlayer().setNextAnimation(new Animation(1337)); e.getPlayer().getPrayer().drainPrayer(20); e.getPlayer().sendMessage(""You bless the holy symbol.""); return; } if (e.usedWith(UNHOLY_BOOK, UNPOWERED_SYMBOL)) { if (e.getPlayer().getSkills().getLevel(Constants.PRAYER) < 50) { e.getPlayer().sendMessage(""You need at least level 50 prayer to enchant this.""); return; } if (e.getPlayer().getPrayer().getPoints() < 20) { e.getPlayer().sendMessage(""You do not have enough prayer points. Please recharge your prayer at the Lumbridge church.""); return; } e.getPlayer().getInventory().deleteItem(UNPOWERED_SYMBOL, 1); e.getPlayer().getInventory().addItem(UNHOLY_SYMBOL, 1); e.getPlayer().setNextAnimation(new Animation(1336)); e.getPlayer().getPrayer().drainPrayer(20); e.getPlayer().sendMessage(""You bless the unholy symbol.""); return; } if (e.usedWith(BOOK_OF_BALANCE, UNPOWERED_SYMBOL)) { if (e.getPlayer().getSkills().getLevel(Constants.PRAYER) < 50) { e.getPlayer().sendMessage(""You need at least level 50 prayer to enchant this.""); return; } if (e.getPlayer().getPrayer().getPoints() < 20) { e.getPlayer().sendMessage(""You do not have enough prayer points. Please recharge your prayer at the Lumbridge church.""); return; } e.getPlayer().getInventory().deleteItem(UNPOWERED_SYMBOL, 1); e.getPlayer().getInventory().addItem(UNHOLY_SYMBOL, 1); e.getPlayer().setNextAnimation(new Animation(1337)); e.getPlayer().getPrayer().drainPrayer(20); e.getPlayer().sendMessage(""You bless the unholy symbol.""); } }); }" "package com.rs.game.content.skills.prayer; public enum Leech { ATTACK(Prayer.LEECH_ATTACK, 2231, 2232), STRENGTH(Prayer.LEECH_STRENGTH, 2248, 2250), DEFENSE(Prayer.LEECH_DEFENSE, 2244, 2246), RANGED(Prayer.LEECH_RANGE, 2236, 2238), MAGIC(Prayer.LEECH_MAGIC, 2240, 2242), SPECIAL(Prayer.LEECH_SPECIAL, 2256, 2258), ENERGY(Prayer.LEECH_ENERGY, 2252, 2254); private final Prayer prayer; private final int projAnim; private final int spotAnimHit; private Leech(Prayer prayer, int projAnim, int spotAnimHit) { this.prayer = prayer; this.projAnim = projAnim; this.spotAnimHit = spotAnimHit; } public Prayer getPrayer() { return prayer; } public int getProjAnim() { return projAnim; } public int getSpotAnimHit() { return spotAnimHit; } public void activate(Player player, Entity target) { // if (target.getPrayer().reachedMax(0)) { // target.sendMessage(""Your opponent has been weakened so much that your sap curse has no effect."", true); // } else { // target.prayer.increaseLeechBonus(0); // target.sendMessage(""Your curse drains Attack from the enemy, boosting your Attack."", true); // } } }" "package com.rs.game.content.skills.prayer; public enum Prayer { DEF_T1 (false, 2690, 0, 5942, 5971, 1, 1d/2), STR_T1 (false, 2688, 1, 5943, 5972, 4, 1d/2), ATK_T1 (false, 2664, 2, 5944, 5973, 7, 1d/2), RNG_T1 (false, 2685, 3, 5960, 5989, 8, 1d/2), MAG_T1 (false, 2670, 4, 5961, 5990, 9, 1d/2), DEF_T2 (false, 2684, 5, 5945, 5974, 10, 1), STR_T2 (false, 2689, 6, 5946, 5975, 13, 1), ATK_T2 (false, 2662, 7, 5947, 5976, 16, 1), RAPID_RESTORE (false, 2679, 8, 5948, 5977, 19, 1d/6), RAPID_HEAL (false, 2678, 9, 5949, 5978, 22, 1d/3), PROTECT_ITEM_N (false, 1982, 10, 5950, 5979, 25, 1d/3), RNG_T2 (false, 2666, 11, 5962, 5991, 26, 1), MAG_T2 (false, 2668, 12, 5963, 5992, 27, 1), DEF_T3 (false, 2687, 13, 5951, 5980, 28, 2), STR_T3 (false, 2691, 14, 5952, 5981, 31, 2), ATK_T3 (false, 2667, 15, 5953, 5982, 34, 2), PROTECT_SUMMONING (false, 4262, 16, 5966, 5995, 35, 2), PROTECT_MAGIC (false, 2675, 17, 5954, 5983, 37, 2), PROTECT_RANGE (false, 2677, 18, 5955, 5984, 40, 2), PROTECT_MELEE (false, 2676, 19, 5956, 5985, 43, 2), RNG_T3 (false, 2665, 20, 5964, 5993, 44, 2), MAG_T3 (false, 2669, 21, 5965, 5994, 45, 2), RETRIBUTION (false, 2682, 22, 5957, 5986, 46, 1d/2), REDEMPTION (false, 2680, 23, 5958, 5987, 49, 1), SMITE (false, 2686, 24, 5959, 5988, 52, 10d/3), CHIVALRY (false, 3826, 25, 5967, 5996, 60, 10d/3), RAPID_RENEWAL (false, -1/*TODO*/, 26, 7768, 7770, 65, 5d/2), PIETY (false, 3825, 27, 5968, 5997, 70, 4), RIGOUR (false, 2685, 28, 7381, 7382, 74, 3), AUGURY (false, 2670, 29, 7769, 7771, 77, 10d/3), PROTECT_ITEM_C (true, 11000, 0, 6820, 6862, 50, 1d/3), SAP_WARRIOR (true, 2675, 1, 6821, 6863, 50, 5d/2), SAP_RANGE (true, 2675, 2, 6822, 6864, 52, 5d/2), SAP_MAGE (true, 2675, 3, 6823, 6865, 54, 5d/2), SAP_SPIRIT (true, 2675, 4, 6824, 6866, 56, 5d/2), BERSERKER (true, 11000, 5, 6825, 6867, 59, 1d/3), DEFLECT_SUMMONING (true, 4262, 6, 6826, 6868, 62, 2), DEFLECT_MAGIC (true, 2675, 7, 6827, 6869, 65, 2), DEFLECT_RANGE (true, 2677, 8, 6828, 6870, 68, 2), DEFLECT_MELEE (true, 2676, 9, 6829, 6871, 71, 2), LEECH_ATTACK (true, 2675, 10, 6830, 6872, 74, 5d/3), LEECH_RANGE (true, 2675, 11, 6831, 6873, 76, 5d/3), LEECH_MAGIC (true, 2675, 12, 6832, 6874, 78, 5d/3), LEECH_DEFENSE (true, 2675, 13, 6833, 6875, 80, 5d/3), LEECH_STRENGTH (true, 2675, 14, 6834, 6876, 82, 5d/3), LEECH_ENERGY (true, 2675, 15, 6835, 6877, 84, 5d/3), LEECH_SPECIAL (true, 2675, 16, 6836, 6878, 86, 5d/3), WRATH (true, 2682, 17, 6837, 6879, 89, 1d/2), SOUL_SPLIT (true, 2675, 18, 6838, 6880, 92, 3), TURMOIL (true, 11000, 19, 6839, 6881, 95, 3); private static final Map NORMALS = new HashMap<>(); private static final Map CURSES = new HashMap<>(); static { for (Prayer p : Prayer.values()) if (p.curse) CURSES.put(p.slotId, p); else NORMALS.put(p.slotId, p); } public static Prayer forSlot(int slotId, boolean curse) { if (curse) return CURSES.get(slotId); return NORMALS.get(slotId); } private final boolean curse; private final int activateSound; private final int slotId; private final int req; private final int varBit; private final int qpVarBit; private final double drain; private Prayer(boolean curse, int activateSound, int slotId, int varBit, int qpVarBit, int req, double drain) { this.curse = curse; this.activateSound = activateSound; this.slotId = slotId; this.varBit = varBit; this.qpVarBit = qpVarBit; this.req = req; this.drain = drain; } public int getActivateSound() { return activateSound; } public int getSlotId() { return slotId; } public int getReq() { return req; } public int getVarBit() { return varBit; } public int getQPVarBit() { return qpVarBit; } public double getDrain() { return drain; } public boolean isCurse() { return curse; } }" "package com.rs.game.content.skills.prayer; @PluginEventHandler public class PrayerBooks { public static final int[] BOOKS = { 3839, 3841, 3843, 19612, 19614, 19616 }; private static final int[] ANIMATIONS = { 1335, 1336, 1337, 14308, 14309, 14310 }; private static final int[] PAGE_BASE = { 3827, 3831, 3835, 19600, 19604, 19608 }; private static final String[][] CHANTS = { { ""In the name of Saradomin, protector of us all, I now join you in the eyes of Saradomin."", ""Thy cause was false, thy skills did lack; see you in Lumbridge when you get back."", ""Go in peace in the name of Saradomin; may his glory shine upon you like the sun."", ""Protect your self, protect your friends. Mine is the glory that never ends. This is Saradomin's wisdom."", ""The darkness in life may be avoided, by the light of wisdom shining. This is Saradomin's wisdom."", ""Show love to your friends, and mercy to your enemies, and know that the wisdom of Saradomin will follow. This is Saradomin's wisdom."", ""A fight begun, when the cause is just, will prevail over all others. This is Saradomin's wisdom."" }, { ""Two great warriors, joined by hand, to spread destruction across the land. In Zamorak's name, now two are one."", ""The weak deserve to die, so the strong may flourish. This is the will of Zamorak."", ""May your bloodthirst never be sated, and may all your battles be glorious. Zamorak bring you strength."", ""Battles are not lost and won; They simply remove the weak from the equation. Zamorak give me strength!"", ""Those who fight, then run away, shame Zamorak with their cowardice. Zamorak give me strength!"", ""Battle is my calling, and death shall be my rest. Zamorak give me strength!"", ""Strike fast, strike hard, strike true: The strength of Zamorak will be with you. Zamorak give me strength!"", ""There is no opinion that cannot be proven true, by crushing those who choose to disagree with it. Zamorak give me strength!"", }, { ""Light and dark, day and night, Balance arises from contrast. I unify thee in the name of Guthix."", ""Thy death was not in vain, for it brought some balance to the world. May Guthix bring you rest."", ""May you walk the path, and never fall, For Guthix walks beside thee on thy journey. May Guthix bring you peace."", ""The trees, the earth, the sky, the waters: All play their part upon this land. May Guthix bring you balance."" }, { ""Big High War God want Great Warriors. Because you can make more, I bind you in Big High War God name."", ""You not worthy of Big High War God, you die too easy."", ""Big High War God make you strong, so you smash enemies."", ""Big High War God say: You not run away from battle, or Big High War God strike you."", ""Big High War God say: Good warrior kill enemies, before he get squished."", ""Big High War God say: Follow and obey your commander, unless they run away."", ""Big High War God say: If you not worthy of Big High War God, you get made dead soon."", ""Big High War God say: If your friend get killed, be happy; they were too weak for Big High War God."", ""Big High War God say: War is best, Peace is for weak."", }, { ""As ye vow to be at peace with each other, And to uphold high values of morality and friendship, I now pronounce you united in the law of Armadyl."", ""Thou didst fight true, but the foe was too great. May thy return be as swift as the flight of Armadyl."", ""For thy task is lawful, May the blessing of Armadyl be upon thee."", ""Do not let thy vision be clouded by evil, Look up, for the truth cometh from the skies. This is the law of Armadyl."", ""It is honourable to resist, And fight for what thou believe is just. This is the law of Armadyl."", ""Peace shall bring thee wisdom; Wisdom shall bring thee peace. This is the law of Armadyl."", ""Thou shalt avoid war; but, if thou must fight, Believe, and thou shalt strike true. This is the law of Armadyl."", ""Thou shalt fly like the bird, Not like the rock. This is the law of Armadyl."", ""To those cursed by war and pest, Come into the light of Armadyl and rest. This is the law of Armadyl."", }, { ""Ye faithful and loyal to the Great Lord, May ye together succeed in your deeds, Ye are now joined by the greatest power."", ""Thy faith faltered, no power could save thee. Like the Great Lord, one day you shall rise again."", ""By day or night, in defeat or victory, The power of the Great Lord be with thee."", ""Though your enemies wish to silence thee, Do not falter, defy them to the end. Power to the Great Lord!"", ""The followers of the Great Lord are few, But they are powerful and mighty. Power to the Great Lord!"", ""Follower of the Great Lord be relieved: One day your loyalty will be rewarded. Power to the Great Lord!"", ""Pray for the day that the Great Lord rises; It is that day thou shalt be rewarded. Power to the Great Lord!"", ""Oppressed thou art, but fear not: The day will come when the Great Lord rises. Power to the Great Lord!"", ""Fighting oppression is the wisest way, To prove your worth to the Great Lord. Power to the Great Lord!"", } }; public static boolean isGodBook(int bookId, boolean complete) { for (int book : BOOKS) if (book + (complete ? 1 : 0) == bookId) return true; return false; } public static ItemClickHandler handleGodBooks = new ItemClickHandler(new Object[] { BOOKS }, new String[] { ""Preach"" }, e -> PrayerBooks.handleSermon(e.getPlayer(), e.getItem().getId())); public static void bindPages(Player player, int bookId) { int god = -1; for (int i = 0;i < BOOKS.length;i++) if (BOOKS[i] == bookId) god = i; boolean containsGodPages = true; for (int pageIndex = 0; pageIndex < 4; pageIndex++) if (!player.getInventory().containsItem(PAGE_BASE[god] + pageIndex, 1)) { containsGodPages = false; break; } if (containsGodPages) { for (int pageIndex = 0; pageIndex < 4; pageIndex++) player.getInventory().deleteItem(PAGE_BASE[god] + pageIndex, 1); player.getInventory().deleteItem(bookId, 1); player.getInventory().addItem(BOOKS[god] + 1, 1); player.sendMessage(""You bind all four pages into the book.""); player.getPrayerBook()[god] = true; } else player.sendMessage(""You need all four pages to create this book.""); } public static void handleSermon(Player player, final int bookId) { final int god = (bookId - (bookId > 5000 ? BOOKS[3] - 6 : BOOKS[0])) / 2; final String[] passages = CHANTS[god]; player.sendOptionDialogue(""Select a relevant passage."", ops -> { ops.add(""Wedding Ceremony"", () -> { String message = passages[0]; int animation = ANIMATIONS[god]; if (animation != -1) player.setNextAnimation(new Animation(animation)); player.setNextForceTalk(new ForceTalk(message)); }); ops.add(""Last Rites"", () -> { String message = passages[0]; int animation = ANIMATIONS[god]; if (animation != -1) player.setNextAnimation(new Animation(animation)); player.setNextForceTalk(new ForceTalk(message)); }); ops.add(""Blessings"", () -> { String message = passages[0]; int animation = ANIMATIONS[god]; if (animation != -1) player.setNextAnimation(new Animation(animation)); player.setNextForceTalk(new ForceTalk(message)); }); ops.add(""Preach"", () -> { String message = passages[0]; if (passages.length > 3) message = passages[3 + Utils.random(passages.length - 3)]; int animation = ANIMATIONS[god]; if (animation != -1) player.setNextAnimation(new Animation(animation)); player.setNextForceTalk(new ForceTalk(message)); }); }); } }" "package com.rs.game.content.skills.prayer; public enum Sap { WARRIOR(Prayer.SAP_WARRIOR, 2214, 2215, 2216), RANGE(Prayer.SAP_RANGE, 2217, 2218, 2219), MAGE(Prayer.SAP_MAGE, 2220, 2221, 2222), SPIRIT(Prayer.SAP_SPIRIT, 2223, 2224, 2225); private final Prayer prayer; private final int spotAnimStart; private final int projAnim; private final int spotAnimHit; private Sap(Prayer prayer, int spotAnimStart, int projAnim, int spotAnimHit) { this.prayer = prayer; this.spotAnimStart = spotAnimStart; this.projAnim = projAnim; this.spotAnimHit = spotAnimHit; } public Prayer getPrayer() { return prayer; } public int getSpotAnimStart() { return spotAnimStart; } public int getProjAnim() { return projAnim; } public int getSpotAnimHit() { return spotAnimHit; } public void activate(Player player, Entity target) { // if (target.getPrayer().reachedMax(0)) { // target.sendMessage(""Your opponent has been weakened so much that your sap curse has no effect."", true); // } else { // target.prayer.increaseLeechBonus(0); // target.sendMessage(""Your curse drains Attack from the enemy, boosting your Attack."", true); // } } }" "package com.rs.game.content.skills.prayer.cremation; public enum Corpse { LOAR(new int[] { 3396 }, 35, new WeightedSet( new WeightedTable(6, new Drop(995, 400, 500)), new WeightedTable(1, new Drop(3450)), new WeightedTable(1, new Drop(3451)), new WeightedTable(1, new Drop(3452)) )), PHRIN(new int[] { 3398 }, 46.5, new WeightedSet( new WeightedTable(10, new Drop(995, 600, 700)), new WeightedTable(1, new Drop(3453)), new WeightedTable(1, new Drop(3454)), new WeightedTable(1, new Drop(3455)), new WeightedTable(1, new Drop(3456)), new WeightedTable(1, new Drop(3457)) )), RIYL(new int[] { 3400 }, 61.5, new WeightedSet( new WeightedTable(10, new Drop(995, 700, 800)), new WeightedTable(1, new Drop(3458)), new WeightedTable(1, new Drop(3459)), new WeightedTable(1, new Drop(3460)), new WeightedTable(1, new Drop(3461)), new WeightedTable(1, new Drop(3462)) )), ASYN(new int[] { 3402 }, 80, new WeightedSet( new WeightedTable(10, new Drop(995, 800, 900)), new WeightedTable(1, new Drop(3463)), new WeightedTable(1, new Drop(3464)), new WeightedTable(1, new Drop(3465)), new WeightedTable(1, new Drop(3466)), new WeightedTable(1, new Drop(3467)) )), FIYR(new int[] { 3404 }, 100, new WeightedSet( new WeightedTable(20, new Drop(995, 1500, 5000)), new WeightedTable(2, new Drop(3465)), new WeightedTable(2, new Drop(3466)), new WeightedTable(2, new Drop(3467)), new WeightedTable(2, new Drop(3468)), new WeightedTable(2, new Drop(3469)), new WeightedTable(1, new Drop(21511)) )), VYRE(new int[] { 21454, 21608 }, 79.5, new WeightedSet( new WeightedTable(2, new Drop(995, 600, 700)), new WeightedTable(1, new Drop(13158)) )); private static final Map ID_MAP = new HashMap<>(); static { for (Corpse corpse : Corpse.values()) for (int id : corpse.itemIds) ID_MAP.put(id, corpse); } public static Corpse forId(int id) { return ID_MAP.get(id); } public final int[] itemIds; public final double xp; public final DropSet keyDropSet; private Corpse(int[] itemIds, double xp, DropSet keyDropSet) { this.itemIds = itemIds; this.xp = xp; this.keyDropSet = keyDropSet; } public List getKeyDrop(Player player, PyreLog log) { double modifier = 1.0; switch(log) { case NORMAL: case OAK: modifier -= 0.03; break; case WILLOW: case TEAK: modifier -= 0.06; break; case ARCTIC: case MAPLE: modifier -= 0.09; break; case MAHOGANY: case EUCALYPTUS: modifier -= 0.12; break; case YEW: modifier -= 0.15; break; case MAGIC: modifier -= 0.18; break; } return keyDropSet.getDropList().genDrop(player, modifier); } }" "package com.rs.game.content.skills.prayer.cremation; public class CraftPyreLogs extends PlayerAction { private static final int DOSE_4 = 3430, DOSE_3 = 3432, DOSE_2 = 3434, DOSE_1 = 3436; private final PyreLog log; private int makeX; public CraftPyreLogs(PyreLog log) { this.log = log; } @Override public boolean start(Player player) { makeX = MakeXStatement.getQuantity(player); return true; } @Override public boolean process(Player player) { return true; } @Override public int processWithDelay(Player player) { if (!player.getInventory().containsItem(log.baseLog, 1)) return -1; int doses = getDosesInInv(player); if ((doses < log.oilDoses) || (makeX-- <= 0)) return -1; player.getInventory().deleteItem(log.baseLog, 1); deleteDoses(player, log.oilDoses); player.getInventory().addItem(log.itemId); player.getSkills().addXp(Constants.FIREMAKING, log.getCreationXP()); return 0; } @Override public void stop(Player player) { } private static void deleteDoses(Player player, int doses) { for (Item item : player.getInventory().getItems().array()) { if (item == null) continue; if (doses <= 0) { player.getInventory().refresh(); return; } switch(item.getId()) { case DOSE_4: if (doses >= 4) { item.setId(Potions.VIAL); doses -= 4; } else if (doses >= 3) { item.setId(DOSE_1); doses -= 3; } else if (doses >= 2) { item.setId(DOSE_2); doses -= 2; } else if (doses >= 1) { item.setId(DOSE_3); doses -= 1; } break; case DOSE_3: if (doses >= 3) { item.setId(Potions.VIAL); doses -= 3; } else if (doses >= 2) { item.setId(DOSE_1); doses -= 2; } else if (doses >= 1) { item.setId(DOSE_2); doses -= 1; } break; case DOSE_2: if (doses >= 2) { item.setId(Potions.VIAL); doses -= 2; } else if (doses >= 1) { item.setId(DOSE_1); doses -= 1; } break; case DOSE_1: if (doses >= 1) { item.setId(Potions.VIAL); doses -= 1; } break; } } player.getInventory().refresh(); } private static int getDosesInInv(Player player) { int doses = 0; for (Item item : player.getInventory().getItems().array()) { if (item == null) continue; switch(item.getId()) { case DOSE_4: doses += 4; break; case DOSE_3: doses += 3; break; case DOSE_2: doses += 2; break; case DOSE_1: doses += 1; break; } } return doses; } }" "package com.rs.game.content.skills.prayer.cremation; @PluginEventHandler public class Cremation { public static ItemOnItemHandler handlePyreLogCreation = new ItemOnItemHandler(new int[] { 3430, 3432, 3434, 3436 }, new int[] { 1511, 1521, 1519, 6333, 10810, 1517, 6332, 12581, 1515, 1513 }, e -> { PyreLog log = PyreLog.forBaseLog(e.getUsedWith(3430, 3432, 3434, 3436).getId()); if (e.getPlayer().getSkills().getLevel(Constants.FIREMAKING) < log.level) { e.getPlayer().sendMessage(""You need a Firemaking level of "" + log.level + "" to pyre these logs.""); return; } e.getPlayer().startConversation(new Conversation(e.getPlayer()) .addNext(new MakeXStatement(new int[] { log.itemId }, e.getPlayer().getInventory().getNumberOf(log.baseLog))) .addNext(() -> e.getPlayer().getActionManager().setAction(new CraftPyreLogs(log)))); }); public static LoginHandler unlockColumbariumStairs = new LoginHandler(e -> { e.getPlayer().getVars().setVarBit(4582, 1); //stairs e.getPlayer().getVars().setVarBit(4583, 1); //shiny blood talisman }); public static ObjectClickHandler handleColumbariumStairs = new ObjectClickHandler(new Object[] { 30621, 30534 }, e -> e.getPlayer().useStairs(e.getObjectId() == 30621 ? Tile.of(3422, 9965, 0) : Tile.of(3425, 9899, 0))); public static ItemOnObjectHandler handlePyreLogSetup = new ItemOnObjectHandler(new Object[] { 4093, 30467 }, Arrays.stream(PyreLog.values()).map(log -> log.itemId).toArray(), e -> { PyreLog log = PyreLog.forId(e.getItem().getId()); if (log != null) { e.getPlayer().getInventory().deleteItem(log.itemId, 1); new Pyre(e.getPlayer(), e.getObject(), log, e.getObjectId() == 4093).createReplace(); e.getPlayer().setNextAnimation(new Animation(833)); } }); public static ItemOnObjectHandler handlePyreLogCorpse = new ItemOnObjectHandler(new Object[] { 4094, 4095, 4096, 4097, 4098, 9006, 9007, 21271, 29166, 29181, 30468, 30469, 30470, 30471, 30472, 30473, 30474, 30475, 30476, 30477 }, Arrays.stream(Corpse.values()).flatMap(corpse -> Arrays.stream(corpse.itemIds).boxed()).collect(Collectors.toList()).toArray(), e -> { if (!(e.getObject() instanceof Pyre pyre)) return; Corpse corpse = Corpse.forId(e.getItem().getId()); if (corpse == null) { e.getPlayer().sendMessage(""Nothing interesting happens.""); return; } if (!pyre.ownedBy(e.getPlayer())) { e.getPlayer().sendMessage(""That's not your pyre!""); return; } if (!pyre.setCorpse(corpse)) e.getPlayer().sendMessage(""The logs aren't strong enough to burn this type of corpse.""); else { e.getPlayer().getInventory().deleteItem(e.getItem().getId(), 1); e.getPlayer().setNextAnimation(new Animation(833)); } }); public static ObjectClickHandler handleLightPyre = new ObjectClickHandler(new Object[] { 4100, 4101, 4102, 4103, 4104, 9008, 9009, 21272, 29167, 29182, 30478, 30479, 30480, 30481, 30482, 30483, 30484, 30485, 30486, 30487 }, e -> { if (!(e.getObject() instanceof Pyre pyre)) return; if (!pyre.ownedBy(e.getPlayer())) { e.getPlayer().sendMessage(""That's not your pyre!""); return; } pyre.light(e.getPlayer()); }); public static ObjectClickHandler handleColumbariumKey = new ObjectClickHandler(new Object[] { 30537, 30538 }, e -> { if (!e.getPlayer().getInventory().containsItem(13158)) { e.getPlayer().sendMessage(""It looks securely locked.""); return; } openRecess(e.getPlayer()); }); public static ItemOnObjectHandler handleColumbariumKeyOnRecess = new ItemOnObjectHandler(new Object[] { 30537, 30538 }, new Object[] { 13158 }, e -> openRecess(e.getPlayer())); public static void openRecess(Player player) { player.lock(2); player.getInventory().deleteItem(13158, 1); player.setNextAnimation(new Animation(833)); for (Item item : DropTable.calculateDrops(player, DropSets.getDropSet(""columbarium_safe""))) if (item != null) player.getInventory().addItemDrop(item); } }" "package com.rs.game.content.skills.prayer.cremation; public class Pyre extends OwnedObject { private final PyreLog log; private Corpse corpse; private int life; private boolean lit; private final boolean shadePyre; public Pyre(Player player, GameObject object, PyreLog log, boolean shadePyre) { super(player, new GameObject(object, shadePyre ? log.shadeNoCorpse : log.vyreNoCorpse)); life = 50; this.log = log; this.shadePyre = shadePyre; } @Override public void tick(Player owner) { if (life-- <= 0) destroy(); } public boolean setCorpse(Corpse corpse) { if (!log.validCorpse(corpse) || (corpse == Corpse.VYRE && shadePyre)) return false; this.corpse = corpse; setId(shadePyre ? log.shadeCorpse : log.vyreCorpse); life = 50; return true; } @Override public void onDestroy() { if (lit) return; World.addGroundItem(new Item(log.itemId), getCoordFace(), getOwner()); if (corpse != null) World.addGroundItem(new Item(corpse.itemIds[0]), getCoordFace(), getOwner()); } public void light(Player player) { life = 50; lit = true; player.lock(); player.setNextAnimation(new Animation(16700)); WorldTasks.delay(1, () -> { World.sendSpotAnim(getCoordFace(), new SpotAnim(357)); new ReleasedSpirit(player, getCoordFace(), shadePyre); player.getSkills().addXp(Constants.FIREMAKING, log.xp); player.getSkills().addXp(Constants.PRAYER, corpse.xp); }); WorldTasks.delay(3, this::destroy); WorldTasks.delay(4, () -> { player.incrementCount(ItemDefinitions.getDefs(corpse.itemIds[0]).name + "" cremated""); player.unlock(); GameObject stand = World.getClosestObject(shadePyre ? 4065 : 30488, getCoordFace()); World.sendSpotAnim(stand.getTile(), new SpotAnim(1605)); for (Item item : corpse.getKeyDrop(player, log)) if (item != null) World.addGroundItem(item, stand.getTile()); }); } public PyreLog getLog() { return log; } public boolean isShadePyre() { return shadePyre; } private static class ReleasedSpirit extends OwnedNPC { private int life; public ReleasedSpirit(Player owner, Tile tile, boolean shade) { super(owner, shade ? 1242 : 7687, tile, false); life = shade ? 6 : 12; } @Override public void processNPC() { if (life-- <= 0) finish(); } } }" "package com.rs.game.content.skills.prayer.cremation; public enum PyreLog { NORMAL(5, 50, 1511, 3438, 2, 30468, 30478, 4094, 4100, Corpse.LOAR, Corpse.PHRIN), OAK(20, 70, 1521, 3440, 2, 30469, 30479, 4095, 4101, Corpse.LOAR, Corpse.PHRIN), WILLOW(35, 100, 1519, 3442, 3, 30470, 30480, 4096, 4102, Corpse.LOAR, Corpse.PHRIN, Corpse.RIYL), TEAK(40, 120, 6333, 6211, 3, 30471, 30481, 9006, 9008, Corpse.LOAR, Corpse.PHRIN, Corpse.RIYL, Corpse.VYRE), ARCTIC(47, 158, 10810, 10808, 3, 30472, 30482, 21271, 21272, Corpse.LOAR, Corpse.PHRIN, Corpse.RIYL, Corpse.VYRE), MAPLE(50, 175, 1517, 3444, 3, 30473, 30483, 4097, 4103, Corpse.LOAR, Corpse.PHRIN, Corpse.RIYL, Corpse.VYRE), MAHOGANY(55, 210, 6332, 6213, 3, 30474, 30484, 9007, 9009, Corpse.LOAR, Corpse.PHRIN, Corpse.RIYL, Corpse.VYRE), EUCALYPTUS(63, 246.5, 12581, 12583, 4, 30476, 30485, 29166, 29167, Corpse.LOAR, Corpse.PHRIN, Corpse.RIYL, Corpse.VYRE, Corpse.ASYN), YEW(65, 255, 1515, 3446, 4, 30475, 30486, 4098, 4104, Corpse.LOAR, Corpse.PHRIN, Corpse.RIYL, Corpse.VYRE, Corpse.ASYN), MAGIC(80, 404.5, 1513, 3448, 4, 30477, 30487, 29181, 29182, Corpse.LOAR, Corpse.PHRIN, Corpse.RIYL, Corpse.VYRE, Corpse.ASYN, Corpse.FIYR); private static final Map BASELOG_MAP = new HashMap<>(); private static final Map ID_MAP = new HashMap<>(); static { for (PyreLog l : PyreLog.values()) { BASELOG_MAP.put(l.baseLog, l); ID_MAP.put(l.itemId, l); } } public static PyreLog forBaseLog(int base) { return BASELOG_MAP.get(base); } public static PyreLog forId(int base) { return ID_MAP.get(base); } public final int level, baseLog, itemId, oilDoses, vyreNoCorpse, vyreCorpse, shadeNoCorpse, shadeCorpse; public final double xp; private final Set validCorpseTypes; private PyreLog(int level, double xp, int baseLog, int itemId, int oilDoses, int vyreNoCorpse, int vyreCorpse, int shadeNoCorpse, int shadeCorpse, Corpse... validCorpseTypes) { this.level = level; this.xp = xp; this.baseLog = baseLog; this.itemId = itemId; this.oilDoses = oilDoses; this.vyreNoCorpse = vyreNoCorpse; this.vyreCorpse = vyreCorpse; this.shadeNoCorpse = shadeNoCorpse; this.shadeCorpse = shadeCorpse; this.validCorpseTypes = new HashSet<>(Arrays.asList(validCorpseTypes)); } public int getCreationXP() { return oilDoses * 20; } public boolean validCorpse(Corpse corpse) { return validCorpseTypes.contains(corpse); } }" "package com.rs.game.content.skills.runecrafting; @PluginEventHandler public class Abyss { protected static final int[][] ABYSS_TELEPORT_OUTER = { { 3059, 4817 }, { 3062, 4812 }, { 3052, 4810 }, { 3041, 4807 }, { 3035, 4811 }, { 3030, 4808 }, { 3026, 4810 }, { 3021, 4811 }, { 3015, 4810 }, { 3020, 4818 }, { 3018, 4819 }, { 3016, 4824 }, { 3013, 4827 }, { 3017, 4828 }, { 3015, 4837 }, { 3017, 4843 }, { 3014, 4849 }, { 3021, 4847 }, { 3022, 4852 }, { 3027, 4849 }, { 3031, 4856 }, { 3035, 4854 }, { 3043, 4855 }, { 3045, 4852 }, { 3050, 4857 }, { 3054, 4855 }, { 3055, 4848 }, { 3060, 4848 }, { 3059, 4844 }, { 3065, 4841 }, { 3061, 4836 }, { 3063, 4832 }, { 3064, 4828 }, { 3060, 4824 }, { 3063, 4821 }, { 3041, 4808 }, { 3030, 4810 }, { 3018, 4816 }, { 3015, 4829 }, { 3017, 4840 }, { 3020, 4849 }, { 3031, 4855 }, { 3020, 4854 }, { 3035, 4855 }, { 3047, 4854 }, { 3060, 4846 }, { 3062, 4836 }, { 3060, 4828 }, { 3063, 4820 }, { 3028, 4806 } }; public static ObjectClickHandler handleAltarEntries = new ObjectClickHandler(new Object[] { 7137, 7139, 7140, 7131, 7130, 7129, 7136, 7135, 7133, 7132, 7141, 7134, 7138 }, e -> { switch(e.getObjectId()) { case 7137 -> RunecraftingAltar.Ruins.WATER.canEnter(e.getPlayer(), true); case 7139 -> RunecraftingAltar.Ruins.AIR.canEnter(e.getPlayer(), true); case 7140 -> RunecraftingAltar.Ruins.MIND.canEnter(e.getPlayer(), true); case 7131 -> RunecraftingAltar.Ruins.BODY.canEnter(e.getPlayer(), true); case 7130 -> RunecraftingAltar.Ruins.EARTH.canEnter(e.getPlayer(), true); case 7129 -> RunecraftingAltar.Ruins.FIRE.canEnter(e.getPlayer(), true); case 7136 -> RunecraftingAltar.Ruins.DEATH.canEnter(e.getPlayer(), true); case 7135 -> RunecraftingAltar.Ruins.LAW.canEnter(e.getPlayer(), true); case 7133 -> RunecraftingAltar.Ruins.NATURE.canEnter(e.getPlayer(), true); case 7132 -> RunecraftingAltar.Ruins.COSMIC.canEnter(e.getPlayer(), true); case 7141 -> RunecraftingAltar.Ruins.BLOOD.canEnter(e.getPlayer(), true); case 7134 -> RunecraftingAltar.Ruins.CHAOS.canEnter(e.getPlayer(), true); case 7138 -> e.getPlayer().sendMessage(""A strange power blocks your exit..""); } }); public static ObjectClickHandler handleShortcuts = new ObjectClickHandler(new Object[] { 7143, 7153, 7152, 7144, 7150, 7146, 7147, 7148, 7149, 7151, 7145 }, e -> { switch(e.getObjectId()) { case 7143, 7153 -> clearRocks(e.getPlayer(), e.getObject()); case 7152, 7144 -> clearTendrils(e.getPlayer(), e.getObject(), Tile.of(e.getObjectId() == 7144 ? 3028 : 3051, 4824, 0)); case 7150, 7146 -> clearEyes(e.getPlayer(), e.getObject(), Tile.of(e.getObject().getX() == 3021 ? 3028 : 3050, 4839, 0)); case 7147 -> clearGap(e.getPlayer(), e.getObject(), Tile.of(3030, 4843, 0), false); case 7148 -> clearGap(e.getPlayer(), e.getObject(), Tile.of(3040, 4845, 0), true); case 7149 -> clearGap(e.getPlayer(), e.getObject(), Tile.of(3048, 4842, 0), false); case 7151 -> burnGout(e.getPlayer(), e.getObject(), Tile.of(3053, 4831, 0)); case 7145 -> burnGout(e.getPlayer(), e.getObject(), Tile.of(3024, 4834, 0)); } }); public static void clearRocks(final Player player, final GameObject object) { Pickaxe pick = Pickaxe.getBest(player); if (pick == null) { player.sendMessage(""You need a pickaxe in order to clear this obstacle.""); return; } player.lock(); WorldTasks.scheduleTimer(1, 1, ticks -> { if (ticks == 1) player.faceObject(object); else if (ticks == 2) player.anim(pick.getAnimId()); else if (ticks == 4) { if (!success(player, Constants.MINING)) { player.unlock(); player.anim(-1); return false; } } else if (ticks >= 5 && ticks <= 7) demolish(7158 + (ticks - 5), object); else if (ticks == 9) { player.tele(Tile.of(object.getX(), object.getY() + 13, 0)); player.resetReceivedHits(); player.unlock(); return false; } return true; }); } public static void clearTendrils(final Player player, final GameObject object, final Tile tile) { Hatchet hatchet = Hatchet.getBest(player); if (hatchet == null) { player.sendMessage(""You need a hatchet in order to clear this obstacle.""); return; } player.lock(); WorldTasks.scheduleLooping(new Task() { int ticks = 0; @Override public void run() { ticks++; if (ticks == 1) player.faceObject(object); else if (ticks == 2) player.anim(hatchet.animNormal()); else if (ticks == 3) { if (!success(player, Constants.WOODCUTTING)) { player.unlock(); player.setNextAnimation(new Animation(-1)); stop(); return; } } else if (ticks >= 4 && ticks <= 6) demolish(7161 + (ticks - 4), object); else if (ticks == 7) { player.tele(tile); player.unlock(); stop(); return; } } }, 1, 1); return; } public static void clearEyes(final Player player, final GameObject object, final Tile tile) { player.lock(); WorldTasks.scheduleLooping(new Task() { int ticks = 0; @Override public void run() { ticks++; if (ticks == 1) player.faceObject(object); else if (ticks == 2) player.setNextAnimation(new Animation(866)); else if (ticks == 3) { if (!success(player, Constants.THIEVING)) { player.unlock(); player.setNextAnimation(new Animation(-1)); stop(); return; } } else if (ticks >= 4 && ticks <= 6) demolish(7168 + (ticks - 4), object); else if (ticks == 7) { player.tele(tile); player.unlock(); stop(); return; } } }, 1, 1); return; } public static void clearGap(final Player player, final GameObject object, final Tile tile, final boolean quick) { player.lock(); WorldTasks.scheduleLooping(new Task() { int ticks = 0; @Override public void run() { ticks++; if (ticks == 1) player.faceObject(object); else if (ticks == 3) { player.setNextAnimation(new Animation(844)); if (!quick) if (!success(player, Constants.AGILITY)) { player.sendMessage(""You cannot seem to slip through the gap.""); player.unlock(); player.setNextAnimation(new Animation(-1)); stop(); return; } } else if (ticks == 4) { player.tele(tile); player.unlock(); stop(); return; } } }, 1, 1); return; } public static void burnGout(final Player player, final GameObject object, final Tile tile) { if (!player.getInventory().containsItem(590, 1)) { player.sendMessage(""You need a tinderbox in order to burn the boil.""); return; } player.lock(); WorldTasks.scheduleLooping(new Task() { int ticks = 0; @Override public void run() { ticks++; if (ticks == 1) player.faceObject(object); else if (ticks == 2) player.setNextAnimation(new Animation(733)); else if (ticks == 3) { if (!success(player, Constants.THIEVING)) { player.unlock(); player.setNextAnimation(new Animation(-1)); stop(); return; } } else if (ticks >= 4 && ticks <= 6) demolish(7165 + (ticks - 4), object); else if (ticks == 7) { player.tele(tile); player.unlock(); stop(); return; } } }, 1, 1); return; } private static void demolish(int objectId, GameObject object) { GameObject o = new GameObject(object); o.setId(objectId); World.spawnObjectTemporary(o, Ticks.fromSeconds(10)); } private static boolean success(Player player, int requestedSkill) { if (((double) player.getSkills().getLevel(requestedSkill) / 99.0) > Math.random()) return true; return false; } public static void teleport(final Player player, NPC npc) { player.lock(2); npc.resetWalkSteps(); npc.faceEntity(player); npc.forceTalk(""Veniens! Sallkar! Rinnesset!""); npc.anim(722); npc.spotAnim(343); player.spotAnim(342); WorldTasks.schedule(2, () -> { int index = Utils.random(ABYSS_TELEPORT_OUTER.length); player.useStairs(-1, Tile.of(ABYSS_TELEPORT_OUTER[index][0], ABYSS_TELEPORT_OUTER[index][1], 0), 0, 1); Teleport.checkDestinationControllers(player, Tile.of(ABYSS_TELEPORT_OUTER[index][0], ABYSS_TELEPORT_OUTER[index][1], 0)); player.getPrayer().drainPrayer(player.getPrayer().getPoints()); player.setWildernessSkull(); }); } }" "package com.rs.game.content.skills.runecrafting; public enum AltarCombination { AIR_TO_MIST(2478, RunecraftingTalisman.WATER, RCRune.WATER, 4695, 6, 8.0D), AIR_TO_DUST(2478, RunecraftingTalisman.EARTH, RCRune.EARTH, 4696, 10, 8.3D), AIR_TO_SMOKE(2478, RunecraftingTalisman.FIRE, RCRune.FIRE, 4697, 15, 8.5D), WATER_TO_MIST(2480, RunecraftingTalisman.AIR, RCRune.AIR, 4695, 6, 8.5D), WATER_TO_MUD(2480, RunecraftingTalisman.EARTH, RCRune.EARTH, 4698, 13, 9.3D), WATER_TO_STEAM(2480, RunecraftingTalisman.FIRE, RCRune.FIRE, 4694, 19, 9.3D), EARTH_TO_DUST(2481, RunecraftingTalisman.AIR, RCRune.AIR, 4696, 10, 9.0D), EARTH_TO_MUD(2481, RunecraftingTalisman.WATER, RCRune.WATER, 4698, 13, 9.5D), EARTH_TO_LAVA(2481, RunecraftingTalisman.FIRE, RCRune.FIRE, 4699, 23, 10.0D), FIRE_TO_SMOKE(2482, RunecraftingTalisman.AIR, RCRune.AIR, 4697, 15, 9.5D), FIRE_TO_STEAM(2482, RunecraftingTalisman.WATER, RCRune.WATER, 4694, 19, 10.0D), FIRE_TO_LAVA(2482, RunecraftingTalisman.EARTH, RCRune.EARTH, 4699, 23, 10.5D); private final int altarId; private final RunecraftingTalisman talisman; private final RCRune reagentRune; private final int outputRuneId; private final int levelReq; private final double xp; AltarCombination(int altarId, RunecraftingTalisman talisman, RCRune reagentRune, int outputRuneId, int levelReq, double xp) { this.altarId = altarId; this.talisman = talisman; this.reagentRune = reagentRune; this.outputRuneId = outputRuneId; this.levelReq = levelReq; this.xp = xp; } public int getAltarId() { return altarId; } public RunecraftingTalisman getTalisman() { return talisman; } public RCRune getReagentRune() { return reagentRune; } public int getOutputRuneId() { return outputRuneId; } public int getLevelReq() { return levelReq; } public double getXp() { return xp; } public static AltarCombination getCombinationForTalisman(RunecraftingTalisman talisman, int altarId) { for (AltarCombination combo : values()) { if (talisman == combo.getTalisman() && altarId == combo.getAltarId()) return combo; } return null; } }" "package com.rs.game.content.skills.runecrafting; @PluginEventHandler public class Runecrafting { public final static int[] LEVEL_REQ = { 1, 25, 50, 75, 90 }; public final static int AIR_TIARA = 5527, MIND_TIARA = 5529, WATER_TIARA = 5531, BODY_TIARA = 5533, EARTH_TIARA = 5535, FIRE_TIARA = 5537, COSMIC_TIARA = 5539, NATURE_TIARA = 5541, CHAOS_TIARA = 5543, LAW_TIARA = 5545, DEATH_TIARA = 5547, BLOOD_TIARA = 5549, SOUL_TIARA = 5551, ASTRAL_TIARA = 9106, OMNI_TIARA = 13655, AIR_TALISMAN = 1438, MIND_TALISMAN = 1448, WATER_TALISMAN = 1444, BODY_TALISMAN = 1446, EARTH_TALISMAN = 1440, FIRE_TALISMAN = 1442, COSMIC_TALISMAN = 1454, NATURE_TALISMAN = 1462, CHAOS_TALISMAN = 1452, LAW_TALISMAN = 1458, DEATH_TALISMAN = 1456, BLOOD_TALISMAN = 1450, SOUL_TALISMAN = 1460, ELEMENTAL_TALISMAN = 5516, AIR_TALISMAN_STAFF = 13630, MIND_TALISMAN_STAFF = 13631, WATER_TALISMAN_STAFF = 13632, EARTH_TALISMAN_STAFF = 13633, FIRE_TALISMAN_STAFF = 13634, BODY_TALISMAN_STAFF = 13635, COSMIC_TALISMAN_STAFF = 13636, CHAOS_TALISMAN_STAFF = 13637, NATURE_TALISMAN_STAFF = 13638, LAW_TALISMAN_STAFF = 13639, DEATH_TALISMAN_STAFF = 13640, BLOOD_TALISMAN_STAFF = 13641, OMNI_TALISMAN_STAFF = 13642, WICKED_HOOD = 22332; public static final int BINDING_NECKLACE = 5521; public enum RCRune { AIR(1, 5.0, 556, false, 11, 2, 22, 3, 33, 4, 44, 5, 55, 6, 66, 7, 77, 8, 88, 9, 99, 10), MIND(1, 5.5, 558, false, 14, 2, 28, 3, 42, 4, 56, 5, 70, 6, 84, 7, 98, 8), WATER(5, 6.0, 555, false, 19, 2, 38, 3, 57, 4, 76, 5, 95, 6), EARTH(9, 6.5, 557, false, 26, 2, 52, 3, 78, 4), FIRE(14, 7.0, 554, false, 35, 2, 70, 3), BODY(20, 7.5, 559, false, 46, 2, 92, 3), COSMIC(27, 8.0, 564, true, 59, 2), CHAOS(35, 8.5, 562, true, 74, 2), ASTRAL(40, 8.7, 9075, true, 82, 2), NATURE(44, 9.0, 561, true, 91, 2), LAW(54, 9.5, 563, true), DEATH(65, 10.0, 560, true), BLOOD(77, 10.5, 565, true), SOUL(90, 12.0, 566, true); private static final HashMap BY_RUNE_ID = new HashMap<>(); static { for (RCRune value : values()) BY_RUNE_ID.put(value.runeId, value); } public static RCRune forId(int itemId) { return BY_RUNE_ID.get(itemId); } private final int req, runeId; private final double xp; private final boolean pureEss; private final int[] multipliers; RCRune(int req, double xp, int runeId, boolean pureEss, int... multipliers) { this.req = req; this.xp = xp; this.runeId = runeId; this.pureEss = pureEss; this.multipliers = multipliers; } public int getId() { return runeId; } public boolean isPureEss() { return pureEss; } } public static ItemClickHandler pouches = new ItemClickHandler(new Object[] { 5509, 5510, 5511, 5512, 5513, 5514, 24204, 24205 }, new String[] { ""Fill"", ""Empty"", ""Check"" }, e -> { switch (e.getOption()) { case ""Fill"" -> { switch (e.getItem().getId()) { case 5509 -> fillPouch(e.getPlayer(), 0); case 5510 -> fillPouch(e.getPlayer(), 1); case 5512 -> fillPouch(e.getPlayer(), 2); case 5514 -> fillPouch(e.getPlayer(), 3); case 24204 -> { if (e.getPlayer().getInventory().containsItem(24205, 1) || e.getPlayer().getBank().containsItem(24205, 1)) { e.getPlayer().sendMessage(""You already have a massive pouch.""); return; } if (!e.getPlayer().getInventory().hasFreeSlots()) { e.getPlayer().sendMessage(""Not enough space in your inventory.""); return; } e.getPlayer().getInventory().deleteItem(24204, 1); e.getPlayer().getInventory().addItem(24205, 1); } case 24205 -> fillPouch(e.getPlayer(), 4); } } case ""Empty"" -> { switch (e.getItem().getId()) { case 5509 -> emptyPouch(e.getPlayer(), 0); case 5510 -> emptyPouch(e.getPlayer(), 1); case 5512 -> emptyPouch(e.getPlayer(), 2); case 5514 -> emptyPouch(e.getPlayer(), 3); case 24204 -> e.getPlayer().sendMessage(""This pouch contains no essence in it.""); case 24205 -> emptyPouch(e.getPlayer(), 4); } } case ""Check"" -> { switch (e.getItem().getId()) { case 5509 -> e.getPlayer().sendMessage(""This pouch has "" + e.getPlayer().getPouches()[0] + (e.getPlayer().getPouchesType()[0] ? "" pure"" : "" rune"") + "" essence in it."", false); case 5510 -> e.getPlayer().sendMessage(""This pouch has "" + e.getPlayer().getPouches()[1] + (e.getPlayer().getPouchesType()[1] ? "" pure"" : "" rune"") + "" essence in it."", false); case 5512 -> e.getPlayer().sendMessage(""This pouch has "" + e.getPlayer().getPouches()[2] + (e.getPlayer().getPouchesType()[2] ? "" pure"" : "" rune"") + "" essence in it."", false); case 5514 -> e.getPlayer().sendMessage(""This pouch has "" + e.getPlayer().getPouches()[3] + (e.getPlayer().getPouchesType()[3] ? "" pure"" : "" rune"") + "" essence in it."", false); case 24204 -> e.getPlayer().sendMessage(""An empty pouch.""); case 24205 -> e.getPlayer().sendMessage(""This pouch has "" + e.getPlayer().getPouches()[4] + (e.getPlayer().getPouchesType()[4] ? "" pure"" : "" rune"") + "" essence in it."", false); } } } e.getPlayer().stopAll(false); }); public static ItemEquipHandler shouldShowEnterOption = new ItemEquipHandler(new Object[] { AIR_TIARA, WATER_TIARA, BODY_TIARA, EARTH_TIARA, FIRE_TIARA, COSMIC_TIARA, NATURE_TIARA, CHAOS_TIARA, LAW_TIARA, DEATH_TIARA, BLOOD_TIARA, SOUL_TIARA, ASTRAL_TIARA, OMNI_TIARA }, e -> e.getPlayer().getVars().setVar(491, e.equip() ? 1 : 0)); public static void craftTalisman(Player player, RunecraftingTalisman talisman) { player.sendOptionDialogue(""What would you like to imbue?"", ops -> { ops.add(""Tiara"", () -> { if (!player.getInventory().containsItem(5525, 1) || !player.getInventory().containsItem(talisman.getTalismanId(), 1)) { player.sendMessage(""You need a tiara to do this.""); return; } player.getInventory().deleteItem(5525, 1); player.getInventory().deleteItem(talisman.getTalismanId(), 1); player.getSkills().addXp(Constants.RUNECRAFTING, talisman.getTiaraExp()); player.getInventory().addItem(talisman.getTiaraId(), 1); }); ops.add(""Staff"", () -> { if (!player.getInventory().containsItem(13629, 1) || !player.getInventory().containsItem(talisman.getTalismanId(), 1)) { player.sendMessage(""You need a runecrafting staff to do this.""); return; } if (player.getSkills().getLevel(Constants.RUNECRAFTING) < talisman.getStaffLevelReq()) { player.sendMessage(""You need a runecrafting level of "" + talisman.getStaffLevelReq() + "" to create a "" + new Item(talisman.getStaffId()).getDefinitions().getName() + "".""); return; } player.getInventory().deleteItem(13629, 1); player.getInventory().deleteItem(talisman.getTalismanId(), 1); player.getSkills().addXp(Constants.RUNECRAFTING, talisman.getStaffExp()); player.getInventory().addItem(talisman.getStaffId(), 1); }); }); } public static boolean craftCombinationRune(Player player, AltarCombination combination) { if (player.getSkills().getLevel(Constants.RUNECRAFTING) < combination.getLevelReq()) { return false; } int pureEss = player.getInventory().getNumberOf(PURE_ESS); if (pureEss == 0) { return false; } int reagentRunes = player.getInventory().getNumberOf(combination.getReagentRune().getId()); if (reagentRunes == 0) { return false; } if (!player.isCastMagicImbue()) { if (!player.getInventory().containsItem(combination.getTalisman().getTalismanId(), 1)) { return false; } player.getInventory().deleteItem(combination.getTalisman().getTalismanId(), 1); } int maxCraftable = Math.min(reagentRunes, pureEss); player.getInventory().deleteItem(PURE_ESS, maxCraftable); player.getInventory().deleteItem(combination.getReagentRune().getId(), maxCraftable); double xp = combination.getXp(); if (Runecrafting.hasRcingSuit(player)) xp *= 1.025; String runeName = new Item(combination.getOutputRuneId()).getName(); if (player.getEquipment().getAmuletId() == BINDING_NECKLACE) { player.sendMessage(""You bind the temple's power into "" + runeName + ""s.""); player.bindingNecklaceCharges--; if (player.bindingNecklaceCharges <= 0) { player.getEquipment().deleteSlot(Equipment.NECK); player.sendMessage(""Your binding necklace disintegrates.""); player.bindingNecklaceCharges = 15; } } else { player.sendMessage(""You attempt to bind "" + runeName + ""s.""); maxCraftable /= 2; } player.getInventory().addItem(combination.getOutputRuneId(), maxCraftable); player.getSkills().addXp(Constants.RUNECRAFTING, xp * maxCraftable); return true; } private enum ZMIRune { AIR(5.0, 556, new double[] { 50.0, 15.0, 12.0, 7.0, 6.0, 5.0, 4.5, 3.0, 2.0, 1.0, 1.0 }), MIND(5.5, 558, new double[] { 25.0, 18.0, 13.0, 8.0, 6.5, 5.5, 5.0, 3.0, 2.0, 1.0, 1.0 }), WATER(6.0, 555, new double[] { 12.0, 21.0, 13.5, 9.0, 7.0, 6.0, 5.5, 3.0, 3.0, 2.0, 2.0 }), EARTH(6.5, 557, new double[] { 6.0, 24.0, 14.0, 11.0, 7.5, 6.5, 6.0, 4.0, 4.0, 3.0, 3.0 }), FIRE(7.0, 554, new double[] { 3.0, 12.0, 15.0, 12.0, 8.0, 7.0, 7.0, 4.0, 5.0, 4.0, 3.0 }), BODY(7.5, 559, new double[] { 1.5, 6.0, 16.0, 13.0, 10.0, 7.5, 7.5, 5.0, 6.0, 5.0, 4.0 }), COSMIC(8.0, 564, new double[] { 0.85, 1.75, 8.0, 20.0, 15.0, 10.0, 9.5, 7.0, 7.0, 6.0, 5.0 }), CHAOS(8.5, 562, new double[] { 0.6, 0.8, 4.2, 10.0, 20.0, 11.0, 10.5, 9.0, 8.0, 7.0, 6.0 }), ASTRAL(8.7, 9075, new double[] { 0.45, 0.6, 2.1, 5.0, 10.0, 15.0, 14.0, 12.0, 10.5, 10.0, 9.5 }), NATURE(9.0, 561, new double[] { 0.3, 0.4, 1.1, 2.5, 5.0, 13.5, 15.5, 15.0, 13.5, 13.5, 13.5 }), LAW(9.5, 563, new double[] { 0.15, 0.24, 0.55, 1.3, 2.6, 7.0, 8.0, 18.0, 14.5, 14.5, 14.5 }), DEATH(10.0, 560, new double[] { 0.08, 0.12, 0.32, 0.6, 1.2, 3.5, 4.0, 10.0, 14.5, 16.5, 15.5 }), BLOOD(10.5, 565, new double[] { 0.05, 0.06, 0.15, 0.4, 0.8, 1.7, 2.0, 5.0, 6.0, 10.0, 13.0 }), SOUL(12.0, 566, new double[] { 0.02, 0.03, 0.08, 0.2, 0.4, 0.8, 1.0, 2.0, 4.0, 6.5, 9.0 }); private final double xp; private final int id; private final double[] chances; private static final Map CHANCES = new HashMap<>(); private static final Map BY_ID = new HashMap<>(); static { for (ZMIRune r : ZMIRune.values()) BY_ID.put(r.id, r); for (int i = 0;i < ZMIRune.AIR.chances.length;i++) { DropTable[] tables = new DropTable[ZMIRune.values().length]; for (ZMIRune rune : ZMIRune.values()) tables[rune.ordinal()] = new DropTable(rune.chances[i], 100.0, new Drop(rune.id)); CHANCES.put(i, new DropSet(tables).getDropList()); } } public static ZMIRune calculate(int threshhold) { DropList chances = CHANCES.get(threshhold); List rune = chances.genDrop(); if (rune.isEmpty()) return ZMIRune.AIR; return BY_ID.get(rune.getFirst().getId()); } ZMIRune(double xp, int id, double[] chances) { assert(chances.length == 11); this.xp = xp; this.id = id; this.chances = chances; } public double getXP() { return 1.7 * xp; } } private static ZMIRune rollZMIRune(Player player) { return ZMIRune.calculate(Utils.clampI(player.getSkills().getLevel(Skills.RUNECRAFTING) >= 99 ? 10 : player.getSkills().getLevel(Skills.RUNECRAFTING) / 10, 0, 10)); } public static void craftZMIAltar(Player player) { int level = player.getSkills().getLevel(Constants.RUNECRAFTING); int runes = player.getInventory().getItems().getNumberOf(PURE_ESS); for (Item i : player.getInventory().getItems().array()) { if (i == null) continue; int pouch = switch (i.getId()) { case 5509 -> 0; case 5510 -> 1; case 5512 -> 2; case 5514 -> 3; case 24205 -> 4; default -> -1; }; if (pouch == -1) continue; if (player.getPouchesType()[pouch]) { //only grab pure ess for ZMI altar runes += player.getPouches()[pouch]; player.getPouches()[pouch] = 0; } } switch (player.getFamiliarPouch()) { case ABYSSAL_PARASITE, ABYSSAL_LURKER, ABYSSAL_TITAN -> { runes += player.getFamiliar().getInventory().getNumberOf(PURE_ESS); player.getFamiliar().getInventory().removeAll(PURE_ESS); } case null, default -> {} } for (int i = 0; i < RCRune.values().length; i++) { if (RCRune.values()[i].req > level) break; } double xp = 0; if (runes == 0) { player.simpleDialogue(""You don't have pure essence.""); return; } player.getInventory().deleteItem(PURE_ESS, runes); for (int i = 0; i < runes; i++) { ZMIRune rune = rollZMIRune(player); int amt = Utils.random(1, 3); player.incrementCount(ItemDefinitions.getDefs(rune.id).getName() + "" runecrafted"", amt); player.getInventory().addItem(rune.id, amt); xp += rune.getXP(); } if (hasRcingSuit(player)) xp *= 1.025; player.getSkills().addXp(Constants.RUNECRAFTING, xp * 2); player.setNextSpotAnim(new SpotAnim(186)); player.setNextAnimation(new Animation(791)); player.lock(5); player.sendMessage(""You bind the temple's power into assorted runes.""); } public static void runecraft(Player player, RCRune rune, boolean span) { int actualLevel = player.getSkills().getLevel(Constants.RUNECRAFTING); if (actualLevel < rune.req) { player.simpleDialogue(""You need a runecrafting level of "" + rune.req + "" to craft this rune.""); return; } int runes = player.getInventory().getItems().getNumberOf(PURE_ESS); if (!span) { for (Item i : player.getInventory().getItems().array()) { if (i == null) continue; int pouch = switch (i.getId()) { case 5509 -> 0; case 5510 -> 1; case 5512 -> 2; case 5514 -> 3; case 24205 -> 4; default -> -1; }; if (pouch == -1) continue; if (player.getPouchesType()[pouch]) { runes += player.getPouches()[pouch]; player.getPouches()[pouch] = 0; } else if (!rune.pureEss){ runes += player.getPouches()[pouch]; player.getPouches()[pouch] = 0; } } switch (player.getFamiliarPouch()) { case ABYSSAL_PARASITE, ABYSSAL_LURKER, ABYSSAL_TITAN -> { if (!rune.pureEss) { runes += player.getFamiliar().getInventory().getUsedSlots(); player.getFamiliar().getInventory().removeAll(RUNE_ESS); player.getFamiliar().getInventory().removeAll(PURE_ESS); } else { runes += player.getFamiliar().getInventory().getNumberOf(PURE_ESS); player.getFamiliar().getInventory().removeAll(PURE_ESS); } } case null, default -> {} } } if (runes > 0) { if (span) runes = 1; player.getInventory().deleteItem(PURE_ESS, runes); } if (!rune.pureEss) { int normalEss = player.getInventory().getItems().getNumberOf(RUNE_ESS); if (span) normalEss = 1; if (runes > 0 && span) normalEss = 0; if (normalEss > 0) { player.getInventory().deleteItem(RUNE_ESS, normalEss); runes += normalEss; } } if (runes == 0) { player.simpleDialogue(""You don't have "" + (rune.pureEss ? ""pure"" : ""rune"") + "" essence.""); return; } if (rune.runeId == 556 && player.getInventory().containsItem(21774, 1) && player.getSkills().getLevel(Constants.RUNECRAFTING) >= 72) { int amount = player.getInventory().getAmountOf(21774); if (amount > runes) amount = runes; int numberArma = amount * numberPerShard(player.getSkills().getLevel(Constants.RUNECRAFTING)); player.getInventory().deleteItem(21774, amount); if (!span) { player.setNextSpotAnim(new SpotAnim(186)); player.setNextAnimation(new Animation(791)); player.lock(5); player.sendMessage(""You bind the temple's power into Armadyl runes.""); } player.getSkills().addXp(Constants.RUNECRAFTING, rune.xp * runes); player.getInventory().addItem(21773, numberArma); player.getInventory().addItem(PURE_ESS, runes-amount-1); player.incrementCount(""Armadyl rune runecrafted"", numberArma); return; } double totalXp = rune.xp * runes; if (hasRcingSuit(player)) totalXp *= 1.025; for (int i = rune.multipliers.length - 2; i >= 0; i -= 2) if (actualLevel >= rune.multipliers[i]) { runes *= rune.multipliers[i + 1]; break; } player.getSkills().addXp(Constants.RUNECRAFTING, totalXp); if (!span) { player.setNextSpotAnim(new SpotAnim(186)); player.setNextAnimation(new Animation(791)); player.lock(5); player.sendMessage(""You bind the temple's power into "" + ItemDefinitions.getDefs(rune.runeId).getName().toLowerCase() + ""s.""); } player.getInventory().addItem(rune.runeId, runes); player.incrementCount(ItemDefinitions.getDefs(rune.runeId).getName()+"" runecrafted"", runes); } public static int numberPerShard(int level) { if (level >= 72 && level < 77) return 7; if (level > 76 && level < 88) return 8; if (level > 89 && level < 99) return 9; if (level >= 99) return 10; return 1; } public static boolean hasRcingSuit(Player player) { return player.getEquipment().getHatId() == 21485 && player.getEquipment().getChestId() == 21484 && player.getEquipment().getLegsId() == 21486 && player.getEquipment().getBootsId() == 21487; } public static void locate(Player p, int ruinsXPos, int ruinsYPos) { String direction = """"; int playerXPos = p.getX(); int playerYPos = p.getY(); if (playerXPos < ruinsXPos && playerYPos < ruinsYPos) { direction = ""north-east""; } if (playerXPos < ruinsXPos && playerYPos == ruinsYPos) { direction = ""east""; } if (playerXPos < ruinsXPos && playerYPos > ruinsYPos) { direction = ""south-east""; } if (playerXPos == ruinsXPos && playerYPos > ruinsYPos) { direction = ""south""; } if (playerXPos > ruinsXPos && playerYPos > ruinsYPos) { direction = ""south-west""; } if (playerXPos > ruinsXPos && playerYPos == ruinsYPos) { direction = ""west""; } if (playerXPos > ruinsXPos && playerYPos < ruinsYPos) { direction = ""north-west""; } if (playerXPos == ruinsXPos && playerYPos < ruinsYPos) { direction = ""north""; } p.sendMessage(""The talisman pulls towards the "" + direction + ""."", false); } public static final int[] POUCH_SIZE = { 3, 6, 9, 12, 18 }; public static final int RUNE_ESS = 1436; public static final int PURE_ESS = 7936; public static void fillPouch(Player p, int i) { if (i < 0) return; if (LEVEL_REQ[i] > p.getSkills().getLevel(Constants.RUNECRAFTING)) { p.sendMessage(""You need a Runecrafting level of "" + LEVEL_REQ[i] + "" to use this pouch."", false); return; } if (!p.getInventory().containsOneItem(RUNE_ESS) && !p.getInventory().containsOneItem(PURE_ESS)) { p.sendMessage(""You don't have any essence with you."", false); return; } int essenceToAdd = POUCH_SIZE[i] - p.getPouches()[i]; if (essenceToAdd == POUCH_SIZE[i]) p.getPouchesType()[i] = p.getInventory().getItems().getNumberOf(PURE_ESS) > 0; int essType = p.getPouchesType()[i] ? PURE_ESS : RUNE_ESS; if (essenceToAdd > p.getInventory().getItems().getNumberOf(essType)) essenceToAdd = p.getInventory().getItems().getNumberOf(essType); if (essenceToAdd > POUCH_SIZE[i] - p.getPouches()[i]) essenceToAdd = POUCH_SIZE[i] - p.getPouches()[i]; if (essenceToAdd > 0) { p.getInventory().deleteItem(essType, essenceToAdd); p.getPouches()[i] += essenceToAdd; } if (essenceToAdd == 0) { p.sendMessage(""Your pouch is full."", false); } } public static void fillPouchesFromBank(Player p, int essence) { for (Item i : p.getInventory().getItems().array()) { if (i == null) continue; int pouch = switch (i.getId()) { case 5509 -> 0; case 5510 -> 1; case 5512 -> 2; case 5514 -> 3; case 24205 -> 4; default -> -1; }; if (pouch == -1) continue; if (p.getPouchesType()[pouch] != (essence == PURE_ESS)) continue; if (p.getSkills().getLevel(Skills.RUNECRAFTING) >= LEVEL_REQ[pouch]) { if (p.getBank().containsItem(essence, 1)) { int essenceToAdd = POUCH_SIZE[pouch] - p.getPouches()[pouch]; if (essenceToAdd == POUCH_SIZE[pouch]) p.getPouchesType()[pouch] = p.getBank().getItem(essence).getAmount() > 0; if (essenceToAdd > p.getBank().getItem(essence).getAmount()) essenceToAdd = p.getBank().getItem(essence).getAmount(); if (essenceToAdd > POUCH_SIZE[pouch] - p.getPouches()[pouch]) essenceToAdd = POUCH_SIZE[pouch] - p.getPouches()[pouch]; if (essenceToAdd > 0) { p.getBank().removeItem(p.getBank().getSlot(essence), essenceToAdd, true, false); p.getPouches()[pouch] += essenceToAdd; } if (essenceToAdd != 0) { p.sendMessage(essenceToAdd + "" "" + ItemDefinitions.getDefs(essence).getName() + "" has been placed into your "" + i.getName().toLowerCase() + "".""); p.getPouchesType()[pouch] = (essence == PURE_ESS); } } } } } public static void emptyPouch(Player p, int i) { if (i < 0) return; int essType = p.getPouchesType()[i] ? PURE_ESS : RUNE_ESS; int toAdd = p.getPouches()[i]; if (toAdd > p.getInventory().getFreeSlots()) toAdd = p.getInventory().getFreeSlots(); if (toAdd > 0) { p.getInventory().addItem(essType, toAdd); p.getPouches()[i] -= toAdd; } if (toAdd == 0) { p.sendMessage(""Your pouch has no essence left in it."", false); } } public static ObjectClickHandler handleCraftOnAltar = new ObjectClickHandler(new Object[] { 2478, 2479, 2480, 2481, 2482, 2483, 2484, 2485, 2486, 2487, 2488, 17010, 30624, 26847 }, e -> { RCRune rune = switch (e.getObjectId()) { case 2478 -> RCRune.AIR; case 2479 -> RCRune.MIND; case 2480 -> RCRune.WATER; case 2481 -> RCRune.EARTH; case 2482 -> RCRune.FIRE; case 2483 -> RCRune.BODY; case 2484 -> RCRune.COSMIC; case 2485 -> RCRune.LAW; case 2486 -> RCRune.NATURE; case 2487 -> RCRune.CHAOS; case 2488 -> RCRune.DEATH; case 17010 -> RCRune.ASTRAL; case 30624 -> RCRune.BLOOD; default -> null; }; if (e.getObject().getId() == 26847) Runecrafting.craftZMIAltar(e.getPlayer()); else if (rune != null) Runecrafting.runecraft(e.getPlayer(), rune, false); }); public static ObjectClickHandler handleZmiLadders = new ObjectClickHandler(new Object[] { 26849, 26850 }, e -> { e.getPlayer().setNextAnimation(new Animation(828)); switch (e.getObjectId()) { case 26849 -> WorldTasks.delay(1, () -> e.getPlayer().tele(Tile.of(3271, 4861, 0))); case 26850 -> WorldTasks.delay(1, () -> e.getPlayer().tele(Tile.of(2452, 3232, 0))); } }); }" "package com.rs.game.content.skills.runecrafting; @PluginEventHandler public class RunecraftingAltar { public static final int WICKED_HOOD = 22332; public static final int WICKED_HOOD_INTER = 1153; public static final int OMNI_TIARA = 13655; public static final int OMNI_TALISMAN = 13649; public static final int OMNI_TALISMAN_STAFF = 13642; public enum WickedHoodRune { MIND(558, 25, 50, 8013, 1448, 5529), AIR(556, 24, 55, 8007, 1438, 5527), WATER(555, 27, 51, 8006, 1444, 5531), EARTH(557, 29, 53, 8008, 1440, 5535), FIRE(554, 31, 52, 8005, 1442, 5537), BODY(559, 33, 54, 8014, 1446, 5534), CHAOS(562, 82, 57, 8015, 1452, 5543), BLOOD(565, 91, 62, 8017, 1450, 5549), DEATH(560, 89, 61, 8018, 1456, 5547), SOUL(-1, 93, 65, 8012, 1460, 5551), LAW(563, 87, 60, 8016, 1458, 5545), NATURE(561, 85, 59, 8011, 1462, 5541), ASTRAL(9075, 83, 58, 8010, -1, 9106), COSMIC(564, 80, 56, 8009, 1454, 5539), ELEMENTAL(-1, 96, 64, 8019, 5516, -1), OMNI(-1, 95, 63, 8020, OMNI_TALISMAN, OMNI_TIARA); private final int buttonId; private final int runeId; private final int spriteComp; private final int spriteId; private final int talismanId; private final int tiaraId; WickedHoodRune(int runeId, int componentId, int spriteComp, int spriteId, int talismanId, int tiaraId) { buttonId = componentId; this.runeId = runeId; this.spriteComp = spriteComp; this.spriteId = spriteId; this.talismanId = talismanId; this.tiaraId = tiaraId; } public int getRuneId() { return runeId; } public int getComponentId() { if (buttonId == 24) return 7; if (buttonId == 82) return 5; if (buttonId == 96) return 100; if (buttonId == 95) return 99; return buttonId + 1; } public int getButtonId() { return buttonId; } public int getSpriteComp() { return spriteComp; } public int getSpriteId() { return spriteId; } public int getTalismanId() { return talismanId; } public int getTiaraId() { return tiaraId; } } public static void sendWickedHoodInter(Player player) { player.getInterfaceManager().sendInterface(WICKED_HOOD_INTER); refreshHood(player); } public static void refreshHood(Player player) { player.getPackets().setIFText(WICKED_HOOD_INTER, 139, """" + player.getDailySubI(""wickedEss"", 100)); player.getPackets().setIFText(WICKED_HOOD_INTER, 134, """" + player.getDailySubI(""wickedTeles"", 2)); player.getPackets().setIFText(WICKED_HOOD_INTER, 143, """" + player.getDailySubI(""wickedRunes"", player.getUsedOmniTalisman() ? 2 : 1)); for (WickedHoodRune rune : WickedHoodRune.values()) if (player.hasWickedHoodTalisman(rune) || player.hasWickedHoodTalisman(rune)) player.getPackets().setIFGraphic(WICKED_HOOD_INTER, rune.getSpriteComp(), rune.getSpriteId()); } public static ItemClickHandler handleWickedHood = new ItemClickHandler(new Object[] { WICKED_HOOD }, new String[] { ""Activate"", ""Teleport"" }, e -> { if (e.getOption().equals(""Activate"")) { e.getPlayer().getTempAttribs().removeO(""whr""); sendWickedHoodInter(e.getPlayer()); } else Magic.sendNormalTeleportSpell(e.getPlayer(), 0, 0, Tile.of(3106, 3162, 1), null, null); }); public static ButtonClickHandler handleWickedHoodInter = new ButtonClickHandler(new Object[] { WICKED_HOOD_INTER }, e -> { if (e.getComponentId() == 119) { int amountToTake = e.getPlayer().getInventory().getFreeSlots(); if (amountToTake > e.getPlayer().getDailySubI(""wickedEss"", 100)) amountToTake = e.getPlayer().getDailySubI(""wickedEss"", 100); if (amountToTake > 0 && e.getPlayer().getInventory().hasFreeSlots()) { e.getPlayer().setDailyI(""wickedEss"", e.getPlayer().getDailyI(""wickedEss"") + amountToTake); if (e.getPlayer().getUsedElementalTalisman()) e.getPlayer().getInventory().addItem(7936, amountToTake); else e.getPlayer().getInventory().addItem(1436, amountToTake); refreshHood(e.getPlayer()); } } else if (e.getComponentId() == 111) { if (e.getPlayer().getTempAttribs().getO(""whr"") == null) e.getPlayer().sendMessage(""You need to select a rune first.""); else { WickedHoodRune selection = e.getPlayer().getTempAttribs().getO(""whr""); if (selection != null) { if (selection.name().equals(""OMNI"") || selection.name().equals(""ELEMENTAL"")) { e.getPlayer().sendMessage(""Please choose a valid rune type.""); return; } if (selection.name().equals(""SOUL"")) { e.getPlayer().sendMessage(""The hood refuses to function.""); return; } if (e.getPlayer().hasWickedHoodTalisman(selection)) { if (e.getPlayer().getDailySubI(""wickedRunes"", e.getPlayer().getUsedOmniTalisman() ? 2 : 1) > 0 && e.getPlayer().getInventory().hasFreeSlots()) { e.getPlayer().incDailyI(""wickedRunes""); e.getPlayer().getInventory().addItem(selection.getRuneId(), selection.ordinal() > 5 ? 5 : 100); refreshHood(e.getPlayer()); } } else e.getPlayer().sendMessage(""The hood has not learned this rune type yet.""); } } } else if (e.getComponentId() == 127) { if (e.getPlayer().getTempAttribs().getO(""whr"") == null) e.getPlayer().sendMessage(""You need to select a rune first.""); else { WickedHoodRune selection = e.getPlayer().getTempAttribs().getO(""whr""); if (selection != null) { if (selection.name().equals(""OMNI"") || selection.name().equals(""ELEMENTAL"")) { e.getPlayer().sendMessage(""Please choose a valid rune type.""); return; } if (selection.name().equals(""SOUL"")) { e.getPlayer().sendMessage(""The hood refuses to function.""); return; } if (e.getPlayer().hasWickedHoodTalisman(selection)) { if (e.getPlayer().getDailyI(""wickedTeles"") < 2) { e.getPlayer().incDailyI(""wickedTeles""); Ruins ruins = Ruins.valueOf(selection.name()); if (ruins.canEnter(e.getPlayer(), false)) Magic.sendNormalTeleportSpell(e.getPlayer(), 0, 0, Ruins.valueOf(selection.name()).inside, null, null); } } else e.getPlayer().sendMessage(""The hood has not learned this rune type yet.""); } } } else { WickedHoodRune rune = null; for (WickedHoodRune r : WickedHoodRune.values()) if (r.buttonId == e.getComponentId()) rune = r; if (rune != null) if (e.getPlayer().hasWickedHoodTalisman(rune)) { if (e.getPlayer().getTempAttribs().getO(""whr"") == null) { e.getPlayer().getTempAttribs().setO(""whr"", rune); e.getPlayer().getPackets().setIFHidden(WICKED_HOOD_INTER, rune.getComponentId(), true); } else { WickedHoodRune old = e.getPlayer().getTempAttribs().setO(""whr"", rune); e.getPlayer().getPackets().setIFHidden(WICKED_HOOD_INTER, old.getComponentId(), false); e.getPlayer().getPackets().setIFHidden(WICKED_HOOD_INTER, rune.getComponentId(), true); } } else e.getPlayer().sendMessage(""The hood has not learned this rune type yet.""); } }); public enum Ruins { MIND(1, new int[] { 1448, 5529, 13631 }, Tile.of(2793, 4828, 0), Tile.of(2984, 3515, 0), 2453, 2466), AIR(1, new int[] { 1438, 5527, 13630 }, Tile.of(2841, 4829, 0), Tile.of(3128, 3407, 0), 2452, 2465), WATER(5, new int[] { 1444, 5531, 13632 }, Tile.of(3494, 4832, 0), Tile.of(3183, 3164, 0), 2454, 2467), EARTH(9, new int[] { 1440, 5535, 13633 }, Tile.of(2655, 4830, 0), Tile.of(3306, 3472, 0), 2455, 2468), FIRE(14, new int[] { 1442, 5537, 13634 }, Tile.of(2577, 4846, 0), Tile.of(3312, 3253, 0), 2456, 2469), BODY(20, new int[] { 1446, 5533, 13635 }, Tile.of(2522, 4833, 0), Tile.of(3055, 3444, 0), 2457, 2470), COSMIC(27, new int[] { 1454, 5539, 13636 }, Tile.of(2162, 4833, 0), Tile.of(2408, 4379, 0), 2458, 2471), CHAOS(35, new int[] { 1452, 5543, 13637 }, Tile.of(2281, 4837, 0), Tile.of(3060, 3589, 0), 2461, 2474), ASTRAL(40, new int[] { -1, -1 }, Tile.of(2156, 3863, 0), Tile.of(2156, 3863, 0), 17010, -1), NATURE(44, new int[] { 1462, 5541, 13638 }, Tile.of(2400, 4835, 0), Tile.of(2868, 3017, 0), 2460, 2473), LAW(54, new int[] { 1458, 5545, 13639 }, Tile.of(2464, 4818, 0), Tile.of(2857, 3380, 0), 2459, 2472), DEATH(65, new int[] { 1456, 5547, 13640 }, Tile.of(2208, 4830, 0), Tile.of(1862, 4639, 0), 2462, 2475), BLOOD(77, new int[] { 1450, 5549, 13641 }, Tile.of(2468, 4889, 1), Tile.of(3561, 9779, 0), 2464, 2477); private final int level; private final int[] talisman; private final Tile inside; private final Tile outside; private final int objectId; private final int portal; Ruins(int level, int[] talisman, Tile inside, Tile outside, int objectId, int portal) { this.level = level; this.talisman = talisman; this.inside = inside; this.outside = outside; this.objectId = objectId; this.portal = portal; } public int getLevel() { return level; } public int getTalisman() { return talisman[0]; } public int getTiara() { return talisman[1]; } public int getStaff() { return talisman[2]; } public boolean canEnter(Player player, boolean teleport) { return switch(this) { case COSMIC -> { if (!player.isQuestComplete(Quest.LOST_CITY, ""for the ruin to respond."")) yield false; if (teleport) player.delayLock(1, () -> player.tele(inside)); yield true; } case BLOOD -> { if (!player.isQuestComplete(Quest.LEGACY_OF_SEERGAZE, ""for the ruin to respond."")) yield false; if (teleport) player.delayLock(1, () -> player.tele(inside)); yield true; } default -> { if (teleport) player.delayLock(1, () -> player.tele(inside)); yield true; } }; } public Tile getOutside() { return outside; } public int getObjectId() { return objectId; } public int getPortal() { return portal; } } public static boolean checkItems(Player player, Ruins ruins) { if ((player.getInventory().containsOneItem(WICKED_HOOD) || player.getEquipment().getHatId() == WICKED_HOOD)) for (WickedHoodRune r : WickedHoodRune.values()) if (r.getTalismanId() == ruins.getTalisman()) if (player.hasWickedHoodTalisman(r)) return true; if (player.getInventory().containsItem(ruins.getTalisman(), 1) || player.getInventory().containsItem(OMNI_TALISMAN, 1) || player.getEquipment().getHatId() == ruins.getTiara() || player.getEquipment().getHatId() == OMNI_TIARA) return true; if (player.getEquipment().getWeaponId() == ruins.getStaff() || player.getEquipment().getWeaponId() == OMNI_TALISMAN_STAFF) return true; return false; } // public static ItemOnObjectHandler craft = new ItemOnObjectHandler(new Object[] { AIR_ALTAR, WATER_ALTAR, EARTH_ALTAR, FIRE_ALTAR }, null, e -> { // Player player = e.getPlayer(); // for (CombinationRunes cr : CombinationRunes.values()) { // for (int i = 0; i < cr.altars.length; i++) { // if (e.getObject().getId() == cr.altars[i] || (e.getItem().getId() != cr.getTalismans()[i] && e.getItem().getId() != cr.getRunes()[i])) { // continue; // } // if (player.getSkills().getLevel(Constants.RUNECRAFTING) < cr.getLevel() || player.getInventory().getItems().getNumberOf(cr.getTalismans()[i]) <= 0) { // continue; // } // // int pureEss = player.getInventory().getItems().getNumberOf(Runecrafting.PURE_ESS); // int inputRune = player.getInventory().getItems().getNumberOf(cr.getRunes()[i]); // if (pureEss == 0) { // player.simpleDialogue(""You don't have enough pure essence.""); // return; // } // if (inputRune == 0) { // player.simpleDialogue(""You don't have enough "" + ItemDefinitions.getDefs(cr.getRunes()[i]).getName() + ""s.""); // return; // } // // if (!player.isCastMagicImbue()) // player.getInventory().deleteItem(cr.getTalismans()[i], 1); // // int maxCraftable = Math.min(inputRune, pureEss); // player.getInventory().deleteItem(Runecrafting.PURE_ESS, maxCraftable); // player.getInventory().deleteItem(cr.getRunes()[i], maxCraftable); // player.setNextSpotAnim(new SpotAnim(186)); // player.setNextAnimation(new Animation(791)); // player.lock(5); // // double xp = cr.getXP()[i]; // if (Runecrafting.hasRcingSuit(player)) // xp *= 1.025; // // String runeName = ItemDefinitions.getDefs(cr.getCombinationRune()).getName(); // if (player.getEquipment().getAmuletId() == BINDING_NECKLACE) { // player.sendMessage(""You bind the temple's power into "" + runeName + ""s.""); // player.bindingNecklaceCharges--; // if (player.bindingNecklaceCharges <= 0) { // player.getEquipment().deleteSlot(Equipment.NECK); // player.sendMessage(""Your binding necklace disintegrates.""); // player.bindingNecklaceCharges = 15; // } // return; // } else { // player.sendMessage(""You attempt to bind "" + runeName + ""s.""); // maxCraftable /= 2; // } // player.getInventory().addItem(cr.getCombinationRune(), maxCraftable); // player.getSkills().addXp(Constants.RUNECRAFTING, xp * maxCraftable); // } // } // }); public static ItemOnObjectHandler handleAtlarUse = new ItemOnObjectHandler(new Object[] { 2478, 2479, 2480, 2481, 2482, 2483, 2484, 2485, 2486, 2487, 2488, 30624, 7936 }, null, e -> { Player player = e.getPlayer(); RunecraftingTalisman talisman = null; if (e.getItem().getId() == PURE_ESS) { if (player.getInventory().containsItem(RCRune.AIR.getId())) talisman = RunecraftingTalisman.AIR; else if (player.getInventory().containsItem(RCRune.WATER.getId())) talisman = RunecraftingTalisman.WATER; else if (player.getInventory().containsItem(RCRune.EARTH.getId())) talisman = RunecraftingTalisman.EARTH; else if (player.getInventory().containsItem(RCRune.FIRE.getId())) talisman = RunecraftingTalisman.FIRE; else { RCRune rune = switch (e.getObjectId()) { case 2478 -> RCRune.AIR; case 2480 -> RCRune.WATER; case 2481 -> RCRune.EARTH; case 2482 -> RCRune.FIRE; default -> null; }; if (rune != null) { Runecrafting.runecraft(player, rune, false); } } } else { talisman = RunecraftingTalisman.forItemId(e.getItem().getId()); } if (talisman == null) { return; } AltarCombination combination = AltarCombination.getCombinationForTalisman(talisman, e.getObjectId()); if (combination != null) { if (Runecrafting.craftCombinationRune(player, combination)) return; } Runecrafting.craftTalisman(player, talisman); }); public static ObjectClickHandler handleExitEssMines = new ObjectClickHandler(new Object[] { 2273 }, e -> { if (e.getPlayer().lastEssTele != null) e.getPlayer().tele(e.getPlayer().lastEssTele); else e.getPlayer().sendMessage(""Couldn't lock on to your entry path to safely exit you. Teleport out another way.""); }); public static ObjectClickHandler handleEntrances = new ObjectClickHandler(new Object[] { 2452, 2453, 2454, 2455, 2456, 2457, 2458, 2461, 2460, 2459, 2462, 2464 }, e -> { Ruins ruins = null; for (Ruins altars : Ruins.values()) if (e.getObjectId() == altars.getObjectId()) { ruins = altars; break; } if (ruins != null) { e.getPlayer().sendMessage(""You touch the mysterious ruin...""); final Ruins alterRuins = ruins; WorldTasks.delay(2, () -> { if (checkItems(e.getPlayer(), alterRuins) && alterRuins.canEnter(e.getPlayer(), true)) e.getPlayer().sendMessage(""...and you appear within the ruin!""); else e.getPlayer().sendMessage(""...and nothing happens...""); }); } }); public static ObjectClickHandler handleExitPortals = new ObjectClickHandler(new Object[] { 2465, 2466, 2467, 2468, 2469, 2470, 2471, 2474, 2473, 2472, 2475, 2477 }, e -> { if (e.getObject().getDefinitions().getName().equals(""Portal"")) { Ruins ruins = null; for (Ruins altars : Ruins.values()) if (e.getObjectId() == altars.getPortal()) { ruins = altars; break; } if (ruins != null) { e.getPlayer().tele(ruins.getOutside()); if (ruins.name().equals(Ruins.CHAOS.name())) e.getPlayer().getControllerManager().startController(new WildernessController()); } } }); public static NPCClickHandler handleOthers = new NPCClickHandler(new Object[] { 171, 300, 462, 844, 5913 }, new String[] { ""Teleport"" }, e -> { if (!e.getPlayer().isQuestComplete(Quest.RUNE_MYSTERIES)) { e.getPlayer().sendMessage(""You have no idea where this mage might take you if you try that.""); return; } handleEssTele(e.getPlayer(), e.getNPC()); }); public static void handleEssTele(Player player, NPC npc) { npc.forceTalk(""Senventior Disthine Molenko!""); npc.resetWalkSteps(); npc.faceEntity(player); npc.anim(722); npc.spotAnim(108, 0, 96); player.lock(); WorldTasks.scheduleTimer(0, 0, tick -> { switch(tick) { case 0 -> World.sendProjectile(npc, player, 109, 5, 5, 5, 0.6, 5, 0); case 1 -> player.spotAnim(110, 35, 96); case 3 -> { if (player.getMiniquestStage(Miniquest.ENTER_THE_ABYSS) == EnterTheAbyss.SCRYING_ORB) { if (player.getInventory().containsItem(5519, 1)) { Item item = player.getInventory().getItemById(5519); if (item != null) { ArrayList visited = item.getMetaDataO(""visited""); if (visited == null) visited = new ArrayList<>(); if (!visited.contains((double) npc.getId())) visited.add((double) npc.getId()); item.setMetaDataO(""visited"", visited); player.sendMessage(""The orb in your inventory glows as it absorbs the teleport information. It contains "" + visited.size() + "" "" + (visited.size() == 1 ? ""location"" : ""locations"") + "".""); if (visited.size() >= 3) { item.setId(5518); item.deleteMetaData(); player.getInventory().refresh(); player.sendMessage(""The orb in your inventory glows brightly. It looks like it's gathered enough information.""); } } } } player.unlock(); player.lastEssTele = Tile.of(player.getTile()); player.tele(Tile.of(2911, 4832, 0)); return false; } } return true; }); } }" "package com.rs.game.content.skills.runecrafting; public enum RunecraftingTalisman { AIR(2478, 1438, 5527, 25, 13630, 1, 25), MIND(2479, 1448, 5529, 27.5, 13631, 1, 27), WATER(2480, 1444, 5531, 30, 13632, 7, 30), EARTH(2481, 1440, 5535, 32.5, 13633, 9, 33), FIRE(2482, 1442, 5537, 35, 13634, 14, 35), BODY(2483, 1446, 5533, 37.5, 13635, 1, 37.5), COSMIC(2484, 1454, 5539, 40, 13636, 27, 40), LAW(2485, 1458, 5545, 47.5, 13639, 1, 27), NATURE(2486, 1462, 5541, 45, 13638, 1, 45), CHAOS(2487, 1452, 5543, 42.5, 13637, 35, 42), DEATH(2488, 1456, 5547, 50, 13640, 65, 50), BLOOD(30624, 1450, 5549, 52.5, 13641, 1, 52.5); private static final HashMap BY_OBJ_ID = new HashMap<>(); private static final HashMap BY_ITEM_ID = new HashMap<>(); static { for (RunecraftingTalisman talisman : values()) { BY_OBJ_ID.put(talisman.altarId, talisman); BY_ITEM_ID.put(talisman.talismanId, talisman); } } public static RunecraftingTalisman forObjectId(int objectId) { return BY_OBJ_ID.get(objectId); } public static RunecraftingTalisman forItemId(int objectId) { return BY_ITEM_ID.get(objectId); } private final int altarId; private final int talismanId; private final int tiaraId; private final double tiaraExp; private final int staffId; private final int staffLevelReq; private final double staffExp; RunecraftingTalisman(int altarId, int talismanId, int tiaraId, double tiaraExp, int staffId, int staffLevelReq, double staffExp) { this.altarId = altarId; this.talismanId = talismanId; this.tiaraId = tiaraId; this.tiaraExp = tiaraExp; this.staffId = staffId; this.staffLevelReq = staffLevelReq; this.staffExp = staffExp; } public int getAltarId() { return altarId; } public int getTalismanId() { return talismanId; } public int getTiaraId() { return tiaraId; } public double getTiaraExp() { return tiaraExp; } public int getStaffId() { return staffId; } public int getStaffLevelReq() { return staffLevelReq; } public double getStaffExp() { return staffExp; } }" "package com.rs.game.content.skills.runecrafting.runespan; public enum Creature { AIR_ESSLING(15403, 9.5, 16596, Runecrafting.RCRune.AIR, 16634, 10, 1, 16571, 0.1), MIND_ESSLING(15404, 10, 16596, Runecrafting.RCRune.MIND, 16634, 10, 1, 16571, 0.2), WATER_ESSLING(15405, 12.6, 16596, Runecrafting.RCRune.WATER, 16634, 10, 5, 16571, 0.3), EARTH_ESSLING(15406, 14.3, 16596, Runecrafting.RCRune.EARTH, 16634, 10, 9, 16571, 0.4), FIRE_ESSLING(15407, 17.4, 16596, Runecrafting.RCRune.FIRE, 16634, 10, 14, 16571, 0.5), BODY_ESSHOUND(15408, 23.1, 16596, Runecrafting.RCRune.BODY, 16650, 10, 20, 16661, 0.7), COSMIC_ESSHOUND(15409, 26.6, 16596, Runecrafting.RCRune.COSMIC, 16650, 10, 27, 16661, 0.9), CHOAS_ESSHOUND(15410, 30.8, 16596, Runecrafting.RCRune.CHAOS, 16650, 10, 35, 16661, 1.1), ASTRAL_ESSHOUND(15411, 35.7, 16596, Runecrafting.RCRune.ASTRAL, 16650, 10, 40, 16661, 1.3), NATURE_ESSHOUND(15412, 43.4, 16596, Runecrafting.RCRune.NATURE, 16650, 10, 44, 16661, 1.5), LAW_ESSHOUND(15413, 53.9, 16596, Runecrafting.RCRune.LAW, 16650, 10, 54, 16661, 1.7), DEATH_ESSWRAITH(15414, 60, 16596, Runecrafting.RCRune.DEATH, 16644, 10, 65, 16641, 2.5), BLOOD_ESSWRAITH(15415, 73.1, 16596, Runecrafting.RCRune.BLOOD, 16644, 10, 77, 16641, 3), SOUL_ESSWRAITH(15416, 106.5, 16596, Runecrafting.RCRune.SOUL, 16644, 10, 90, 16641, 3.5); public final Runecrafting.RCRune rune; public final int npcId; public final int playerEmoteId; public final int npcEmoteId; public final int npcLife; public final int levelRequired; public final int deathEmote; public final double pointValue; Creature(int npcId, double xp, int playerEmoteId, Runecrafting.RCRune rune, int npcEmoteId, int npcLife, int levelRequired, int deathEmote, double pointValue) { this.npcId = npcId; //this.xp = xp; this.playerEmoteId = playerEmoteId; this.rune = rune; this.npcEmoteId = npcEmoteId; this.npcLife = npcLife; this.levelRequired = levelRequired; this.deathEmote = deathEmote; this.pointValue = pointValue; } }" "package com.rs.game.content.skills.runecrafting.runespan; @PluginEventHandler public class RunespanController extends Controller { public static Tile WIZARD_TOWER = Tile.of(3106, 6160, 1); public static Tile LOWER_LEVEL = Tile.of(3994, 6105, 1); public static Tile HIGHER_LEVEL_ENTER = Tile.of(4137, 6090, 1); public static Tile HIGHER_LEVEL = Tile.of(4149, 6104, 1); public static Tile VINE_LADDER = Tile.of(3957, 6106, 1); public static Tile TOP_LEVEL = Tile.of(4297, 6040, 1); public static Tile BONE_LADDER = Tile.of(4106, 6042, 1); private static enum HandledPlatforms { EARTH_1(3983, 6112, 3978, 6117), EARTH_2(4019, 6093, 4019, 6099), EARTH_3(4002, 6118, 4007, 6123), EARTH_4(4004, 6134, 3998, 6134), EARTH_5(3957, 6097, 3957, 6091), EARTH_6(3943, 6053, 3943, 6047), EARTH_7(3973, 6047, 3968, 6042), EARTH_8(3984, 6053, 3990, 6053), EARTH_9(4021, 6053, 4021, 6047), EARTH_10(3952, 6039, 3958, 6039), EARTH_11(3943, 6047, 3943, 6053), EARTH_12(3940, 6033, 3935, 6028), EARTH_13(3993, 6036, 3988, 6041), EARTH_14(4021, 6060, 4021, 6066), EARTH_15(3923, 6047, 3928, 6052), EARTH_16(3924, 6063, 3919, 6068), EARTH_17(3925, 6098, 3931, 6098), EARTH_18(3921, 6101, 3921, 6107), EARTH_19(3940, 6122, 3946, 6122), EARTH_20(3946, 6122, 3940, 6122), EARTH_21(3909, 6116, 3909, 6110), EARTH_22(4180, 6086, 4180, 6080), EARTH_23(4303, 6040, 4303, 6046), EARTH_24(4400, 6052, 4400, 6058), EARTH_25(4336, 6134, 4330, 6134), ICE_1(3996, 6118, 3991, 6123), ICE_2(3991, 6097, 3986, 6092), ICE_3(4008, 6087, 4014, 6087), ICE_4(4023, 6110, 4023, 6116), ICE_5(4017, 6130, 4023, 6130), ICE_6(3954, 6087, 3948, 6087), ICE_7(4024, 6033, 4024, 6027), ICE_8(3994, 6029, 3988, 6029), ICE_9(3947, 6032, 3947, 6026), ICE_10(3922, 6032, 3922, 6026), ICE_11(3966, 6032, 3966, 6026), ICE_12(4002, 6025, 4007, 6020), ICE_13(3921, 6057, 3915, 6057), ICE_14(3916, 6085, 3921, 6090), ICE_15(3916, 6100, 3911, 6105), ICE_16(3919, 6114, 3914, 6119), ICE_17(3950, 6133, 3955, 6138), ICE_18(3927, 6127, 3922, 6132), ICE_19(4381, 6025, 4386, 6030), ICE_20(4302, 6066, 4302, 6072), ICE_21(4377, 6136, 4371, 6136), SMALL_MISSILE_1(3932, 6130, 3932, 6136), SMALL_MISSLE_2(4012, 6122, 4012, 6116), SMALL_MISSLE_3(3973, 6132, 3978, 6137), SMALL_MISSLE_4(3963, 6126, 3957, 6126), SMALL_MISSLE_5(4019, 6036, 4014, 6031), SMALL_MISSLE_6(4009, 6029, 4003, 6029), SMALL_MISSLE_7(3980, 6026, 3974, 6026), SMALL_MISSLE_8(3937, 6039, 3931, 6039), SMALL_MISSLE_9(4003, 6029, 4009, 6029), SMALL_MISSLE_10(4022, 6073, 4022, 6079), SMALL_MISSLE_11(3918, 6035, 3912, 6035), SMALL_MISSLE_12(3915, 6072, 3915, 6078), SMALL_MISSLE_13(3942, 6107, 3937, 6112), SMALL_MISSLE_14(3911, 6126, 3911, 6132), SMALL_MISSLE_15(4189, 6053, 4184, 6058), SMALL_MISSLE_16(4203, 6103, 4208, 6108), SMALL_MISSLE_17(4153, 6064, 4159, 6064), SMALL_MISSLE_18(4130, 6089, 4130, 6095), SMALL_MISSLE_19(4167, 6092, 4173, 6092), SMALL_MISSLE_20(4344, 6025, 4350, 6025), SMALL_MISSLE_21(4405, 6123, 4400, 6128), MISSILE_1(4125, 6096, 4120, 6091), MISSILE_2(4114, 6033, 4114, 6027), MISSILE_3(4146, 6026, 4146, 6020), MISSILE_4(4205, 6036, 4200, 6041), MISSILE_5(4113, 6042, 4119, 6042), MISSILE_6(4130, 6051, 4135, 6056), MISSILE_7(4119, 6042, 4113, 6042), MISSLE_8(4113, 6058, 4119, 6058), MISSLE_9(4167, 6031, 4172, 6036), MISSLE_10(4195, 6055, 4172, 6036), MISSLE_11(4200, 6060, 4195, 6055), MISSLE_12(4205, 6071, 4210, 6076), MISSLE_13(4194, 6104, 4189, 6109), MISSLE_14(4195, 6126, 4189, 6126), MISSLE_15(4110, 6119, 4105, 6124), MISSLE_16(4358, 6033, 4358, 6039), MISSLE_17(4334, 6052, 4334, 6058), MISSLE_18(4304, 6082, 4310, 6082), MISSLE_19(4397, 6107, 4391, 6107), MISSLE_20(4382, 6130, 4377, 6125), VINE_1(4125, 6109, 4120, 6114), VINE_2(4104, 6031, 4104, 6025), VINE_3(4188, 6031, 4183, 6036), VINE_4(4147, 6033, 4152, 6038), VINE_5(4203, 6046, 4209, 6046), VINE_6(4212, 6085, 4212, 6091), VINE_7(4188, 6130, 4193, 6135), VINE_8(4152, 6131, 4157, 6126), VINE_9(4119, 6123, 4114, 6128), VINE_10(4332, 6034, 4332, 6040), VINE_11(4311, 6109, 4316, 6104), CONJURATION_1(4141, 6103, 4135, 6103), CONJURATION_2(4193, 6072, 4187, 6072), CONJURATION_3(4193, 6091, 4187, 6091), CONJURATION_5(4206, 6118, 4201, 6123), CONJURATION_6(4146, 6107, 4146, 6113), COSMIC_1(4125, 6122, 4131, 6122), COSMIC_2(4194, 6028, 4200, 6028), COSMIC_3(4130, 6040, 4135, 6035), COSMIC_4(4109, 6045, 4109, 6051), COSMIC_5(4163, 6041, 4169, 6041), COSMIC_6(4213, 6050, 4218, 6055), COSMIC_7(4186, 6122, 4186, 6116), COSMIC_8(4103, 6071, 4103, 6077), COSMIC_9(4140, 6136, 4146, 6136), COSMIC_10(4390, 6043, 4384, 6043), COSMIC_11(4325, 6047, 4320, 6052), COSMIC_12(4310, 6056, 4304, 6056), MIST_1(4110, 6109, 4110, 6103), MIST_2(4125, 6037, 4125, 6031), MIST_3(4213, 6023, 4208, 6028), MIST_4(4153, 6029, 4159, 6029), MIST_5(4152, 6045, 4147, 6050), MIST_6(4212, 6062, 4206, 6062), MIST_7(4206, 6084, 4201, 6089), MIST_8(4210, 6119, 4210, 6125), MIST_9(4180, 6132, 4175, 6137), MIST_10(4183, 6112, 4177, 6112), MIST_11(4113, 6068, 4107, 6068), MIST_12(4136, 6126, 4136, 6132), MIST_13(4158, 6117, 4158, 6111), MIST_14(4312, 6031, 4318, 6031), MIST_15(4339, 6127, 4339, 6121), MIST_16(4324, 6111, 4324, 6117), MIST_17(4376, 6111, 4376, 6105), MIST_18(4390, 6077, 4384, 6077), FLOAT_1(3997, 6094, 3997, 6088), FLOAT_2(3971, 6118, 3971, 6112), FLOAT_3(3982, 6103, 3988, 6103), FLOAT_4(4007, 6104, 4013, 6104), FLOAT_5(3954, 6104, 3948, 6104), FLOAT_6(3937, 6086, 3937, 6092), FLOAT_7(3933, 6075, 3927, 6075), FLOAT_8(3935, 6061, 3929, 6061), FLOAT_9(3954, 6064, 3959, 6059), FLOAT_10(3999, 6062, 3999, 6068), FLOAT_11(4010, 6058, 4016, 6058), FLOAT_12(4004, 6043, 3999, 6038), FLOAT_13(3925, 6114, 3930, 6119), FLOAT_14(4167, 6099, 4172, 6104), FLOAT_15(4136, 6062, 4136, 6068), FLOAT_16(4130, 6071, 4125, 6066), FLOAT_17(4141, 6092, 4146, 6097), FLOAT_18(4406, 6093, 4406, 6099), FLOAT_19(4310, 6123, 4315, 6128), FLOAT_20(4406, 6093, 4406, 6099), FLESH(4337, 6066, 4337, 6072), FLESH2(4358, 6126, 4358, 6120), FLESH3(4324, 6093, 4324, 6099), FLESH4(4364, 6100, 4364, 6094), FLESH5(4389, 6059, 4383, 6059), FLESH6(4356, 6066, 4362, 6066), SKELETAL(4320, 6059, 4325, 6064), SKELETAL2(4329, 6100, 4334, 6095), SKELETAL3(4371, 6112, 4366, 6107), SKELETAL4(4383, 6098, 4383, 6092), SKELETAL5(4374, 6074, 4369, 6069), SKELETAL6(4379, 6048, 4379, 6054), GREATER_MISSILE7(4353, 6054, 4353, 6060), GREATER_MISSILE6(4374, 6082, 4369, 6087), GREATER_MISSILE5(4362, 6117, 4368, 6117), GREATER_MISSILE4(4348, 6107, 4348, 6101), GREATER_MISSILE3(4317, 6085, 4317, 6091), GREATER_MISSILE2(4300, 6092, 4300, 6098), GREATER_MISSILE1(4371, 6032, 4376, 6037), GREATER_MISSILE(4325, 6076, 4331, 6076); private final Tile smallIsland; private final Tile largeIsland; private HandledPlatforms(int largeIslandX, int largeIslandY, int smallIslandX, int smallIslandY) { largeIsland = Tile.of(largeIslandX, largeIslandY, 1); smallIsland = Tile.of(smallIslandX, smallIslandY, 1); } private static Object[] getToPlataform(Tile fromPlataform) { for (HandledPlatforms toPlatraform : HandledPlatforms.values()) { if (toPlatraform.smallIsland.matches(fromPlataform)) return new Object[] { toPlatraform.largeIsland, true }; if (toPlatraform.largeIsland.matches(fromPlataform)) return new Object[] { toPlatraform.smallIsland, false }; } return null; } } private static final int AIR_RUNE = 24215; private static final int EARTH_RUNE = 24216; private static final int WATER_RUNE = 24214; private static final int MIND_RUNE = 24217; private static final int ELEMENTAL_RUNE = -1; private static final int BODY_RUNE = 24218; private static final int CHAOS_RUNE = 24221; private static final int NATURE_RUNE = 24220; private static final int COSMIC_RUNE = 24223; private static final int ASTRAL_RUNE = 24224; private static final int LAW_RUNE = 24222; private static final int BLOOD_RUNE = 24225; private static final int DEATH_RUNE = 24219; private static enum Platforms { EARTH(70478, 16645, 3072, -1, -1, -1, -1, false, EARTH_RUNE), EARTH2(70479, 16645, 3072, -1, -1, -1, -1, false, EARTH_RUNE), EARTH3(70485, 16645, 3072, -1, -1, -1, -1, false, EARTH_RUNE), EARTH4(70495, 16645, 3072, -1, -1, -1, -1, false, EARTH_RUNE), ICE(70480, 16646, 3076, -1, -1, -1, -1, false, AIR_RUNE, WATER_RUNE), ICE2(70496, 16646, 3076, -1, -1, -1, -1, false, AIR_RUNE, WATER_RUNE), VINE(70490, 16645, 3080, -1, -1, -1, -1, false, WATER_RUNE, EARTH_RUNE, NATURE_RUNE), VINE2(70500, 16645, 3080, -1, -1, -1, -1, false, WATER_RUNE, EARTH_RUNE, NATURE_RUNE), SMALL_MISSILE(70481, 16635, 3086, -1, -2, 16672, 3087, true, ELEMENTAL_RUNE, MIND_RUNE), SMALL_MISSILE2(70482, 16635, 3086, -1, -2, 16672, 3087, true, ELEMENTAL_RUNE, MIND_RUNE), SMALL_MISSILE3(70487, 16635, 3086, -1, -2, 16672, 3087, true, ELEMENTAL_RUNE, MIND_RUNE), SMALL_MISSILE4(70497, 16635, 3086, -1, -2, 16672, 3087, true, ELEMENTAL_RUNE, MIND_RUNE), GREATER_MISSILE(70504, 16635, 3086, -1, -2, 16672, 3087, true, ELEMENTAL_RUNE, BLOOD_RUNE, DEATH_RUNE), GREATER_MISSILE2(70505, 16635, 3086, -1, -2, 16672, 3087, true, ELEMENTAL_RUNE, BLOOD_RUNE, DEATH_RUNE), MISSILE(70489, 16635, 3086, -1, -3, 16672, 3087, true, ELEMENTAL_RUNE, CHAOS_RUNE), MISSILE2(70499, 16635, 3086, -1, -3, 16672, 3087, true, ELEMENTAL_RUNE, CHAOS_RUNE), MIST1(70491, 16635, 3086, -1, 3092, 16672, 3087, true, BODY_RUNE, WATER_RUNE, NATURE_RUNE), MIST2(70492, 16635, 3086, -1, 3092, 16672, 3087, true, BODY_RUNE, WATER_RUNE, NATURE_RUNE), MIST3(70501, 16635, 3086, -1, 3092, 16672, 3087, true, BODY_RUNE, WATER_RUNE, NATURE_RUNE), COSMIC(70493, 16685, 3095, -1, -1, 16686, 3096, true, COSMIC_RUNE, ASTRAL_RUNE, LAW_RUNE), COSMIC2(70502, 16685, 3095, -1, -1, 16686, 3096, true, COSMIC_RUNE, ASTRAL_RUNE, LAW_RUNE), CONJURATION(70488, 16662, 3089, 16645, -1, -1, -1, false, MIND_RUNE, BODY_RUNE, 24227), FLESH(70506, 16645, 3074, -1, -1, -1, -1, false, BODY_RUNE, DEATH_RUNE, BLOOD_RUNE), SKELETAL(70503, 16645, 3078, -1, -1, -1, -1, false, DEATH_RUNE), FLOAT(70476, 16654, 3082, 16652, 3084, 16651, 3083, false, AIR_RUNE), FLOAT2(70477, 16654, 3082, 16652, 3084, 16651, 3083, false, AIR_RUNE), FLOAT3(70483, 16654, 3082, 16652, 3084, 16651, 3083, false, AIR_RUNE), FLOAT4(70494, 16654, 3082, 16652, 3084, 16651, 3083, false, AIR_RUNE); private final int objectId; private final int startEmote; private final int startGraphic; private final int middleEmote; private final int middleGraphic; private final int endEmote; private final int endGraphic; private final boolean invisible; private final int[] runes; private Platforms(int objectId, int startEmote, int startGraphic, int middleEmote, int middleGraphic, int endEmote, int endGraphic, boolean invisible, int... runes) { this.objectId = objectId; this.startEmote = startEmote; this.startGraphic = startGraphic; this.middleEmote = middleEmote; this.middleGraphic = middleGraphic; this.endEmote = endEmote; this.endGraphic = endGraphic; this.invisible = invisible; this.runes = runes; } } public static void enterRunespan(final Player player, boolean high) { player.useStairs(-1, high ? HIGHER_LEVEL_ENTER : LOWER_LEVEL, 0, 2); WorldTasks.schedule(new Task() { @Override public void run() { player.getControllerManager().startController(new RunespanController()); } }); } private boolean handlePlatform(GameObject object) { for (Platforms plataform : Platforms.values()) if (plataform.objectId == object.getId()) return handleCrossPlatform(object, plataform); return false; } private int getPlatformSpotAnim(int runesAmt) { if (runesAmt == 1) return 3065; if (runesAmt == 2) return 3064; return 3063; } public static NPCClickHandler handleWizardFinix = new NPCClickHandler(new Object[] { ""Wizard Finix"" }, e -> { switch(e.getOption()) { case ""Teleport"": Magic.sendNormalTeleportSpell(e.getPlayer(), Tile.of(3107, 3162, 1)); break; case ""Shop"": openRewards(e.getPlayer()); break; case ""Talk to"": e.getPlayer().startConversation(new WizardFinix(e.getPlayer())); break; } }); public static ObjectClickHandler runespanPortal = new ObjectClickHandler(new Object[] { 38279 }, new Tile[] { Tile.of(3107, 3160, 1) }, e -> e.getPlayer().startConversation(new Dialogue().addOptions(""Where would you like to travel to?"", ops -> { ops.add(""The Runecrafting Guild"", () -> e.getPlayer().useStairs(-1, Tile.of(1696, 5460, 2), 0, 1)); ops.add(""The Runespan (Low level)"", () -> RunespanController.enterRunespan(e.getPlayer(), false)); ops.add(""The Runespan (High level)"", () -> RunespanController.enterRunespan(e.getPlayer(), true)); }))); private static void openRewards(Player player) { refreshPoints(player); player.getInterfaceManager().setFullscreenInterface(317, 1273); player.getPackets().setIFEvents(new IFEvents(1273, 14, 0, 60).enableRightClickOptions(0, 1, 2, 3, 4)); } public static ButtonClickHandler handleRewards = new ButtonClickHandler(1273, e -> { switch(e.getComponentId()) { case 54: e.getPlayer().closeInterfaces(); break; case 14: switch(e.getPacket()) { case IF_OP1: e.getPlayer().getVars().setVarBit(11106, 1); break; case IF_OP2: e.getPlayer().getVars().setVarBit(11106, 2); break; case IF_OP3: e.getPlayer().getVars().setVarBit(11106, 5); break; case IF_OP4: e.getPlayer().getVars().setVarBit(11106, 10); break; default: break; } StructDefinitions reward = StructDefinitions.getStruct(EnumDefinitions.getEnum(5838).getIntValue(e.getSlotId())); if (reward != null) { e.getPlayer().getVars().setVarBit(11105, e.getSlotId()+1); e.getPlayer().getVars().setVarBit(11104, 0); e.getPlayer().getTempAttribs().setI(""rsShopRew"", e.getSlotId()); } break; case 29: int selection = EnumDefinitions.getEnum(5838).getIntValue(e.getPlayer().getTempAttribs().getI(""rsShopRew"", -1)); if (selection == -1) return; reward = StructDefinitions.getStruct(selection); if (reward != null) { int amount = e.getPlayer().getVars().getVarBit(11106); int totalPrice = (amount * reward.getIntValue(2379)); int lvlReq = reward.getIntValue(2393); if (totalPrice > e.getPlayer().getRuneSpanPoints()) { e.getPlayer().getPackets().setIFText(1273, 68, ""You don't have enough points.""); return; } if (e.getPlayer().getSkills().getLevelForXp(Constants.RUNECRAFTING) < lvlReq) { e.getPlayer().getPackets().setIFText(1273, 68, ""You need a Runecrafting level of "" + lvlReq + "" for that.""); return; } if (!e.getPlayer().getInventory().hasFreeSlots()) { e.getPlayer().getPackets().setIFText(1273, 68, ""You don't have enough inventory space.""); return; } e.getPlayer().getPackets().setIFHidden(1273, 37, false); e.getPlayer().getPackets().setIFText(1273, 2, e.getPlayer().getVars().getVarBit(11106) + "" x "" + reward.getStringValue(2376) + "" "" + reward.getStringValue(2377)); e.getPlayer().getPackets().setIFText(1273, 4, (e.getPlayer().getVars().getVarBit(11106) * reward.getIntValue(2379)) + "" Points""); } break; case 7: selection = EnumDefinitions.getEnum(5838).getIntValue(e.getPlayer().getTempAttribs().getI(""rsShopRew"", -1)); if (selection == -1) return; reward = StructDefinitions.getStruct(selection); if (reward != null) { int amount = e.getPlayer().getVars().getVarBit(11106); int totalPrice = (amount * reward.getIntValue(2379)); int lvlReq = reward.getIntValue(2393); if (totalPrice > e.getPlayer().getRuneSpanPoints()) { e.getPlayer().getPackets().setIFText(1273, 68, ""You don't have enough points.""); return; } if (e.getPlayer().getSkills().getLevelForXp(Constants.RUNECRAFTING) < lvlReq) { e.getPlayer().getPackets().setIFText(1273, 68, ""You need a Runecrafting level of "" + lvlReq + "" for that.""); return; } if (!e.getPlayer().getInventory().hasFreeSlots()) { e.getPlayer().getPackets().setIFText(1273, 68, ""You don't have enough inventory space.""); return; } int itemId = reward.getIntValue(2381); if (itemId <= 0) { e.getPlayer().getPackets().setIFText(1273, 68, ""Error purchasing item.""); return; } e.getPlayer().removeRunespanPoints(totalPrice); e.getPlayer().getInventory().addItem(reward.getIntValue(2381), amount); e.getPlayer().getPackets().setIFHidden(1273, 37, true); refreshPoints(e.getPlayer()); } break; case 8: e.getPlayer().getPackets().setIFHidden(1273, 37, true); break; } }); private boolean handleCrossPlatform(final GameObject object, final Platforms plataform) { Object[] toPlataform = HandledPlatforms.getToPlataform(object.getTile()); if (toPlataform == null) return false; final Tile toTile = (Tile) toPlataform[0]; player.lock(); player.addWalkSteps(object.getX(), object.getY(), 1, false); World.sendSpotAnim(object.getTile(), new SpotAnim(getPlatformSpotAnim(plataform.runes.length))); WorldTasks.scheduleLooping(new Task() { private int stage; @Override public void run() { if (stage == 0) { if (plataform.startEmote != -1) player.setNextAnimation(new Animation(plataform.startEmote)); if (plataform.startGraphic != -1) player.setNextSpotAnim(new SpotAnim(plataform.startGraphic)); player.forceMove(toTile, 30, 150); } else if (stage == 1) { if (plataform.middleEmote != -1) player.setNextAnimation(new Animation(plataform.middleEmote)); if (plataform.middleGraphic == -2) { int gfx; if (plataform.runes[0] == AIR_RUNE) gfx = 2699; else if (plataform.runes[0] == WATER_RUNE) gfx = 2703; else if (plataform.runes[0] == EARTH_RUNE) gfx = 2718; else gfx = 2729; World.sendProjectile(player, toTile, gfx, 18, 18, 20, 50, 145, 0); } else if (plataform.middleGraphic == -3) { int gfx; if (plataform.runes[0] == AIR_RUNE) gfx = 2699; else if (plataform.runes[0] == WATER_RUNE) gfx = 2704; else if (plataform.runes[0] == EARTH_RUNE) gfx = 2719; else gfx = 2731; World.sendProjectile(player, toTile, gfx, 18, 18, 20, 50, 145, 0); } else if (plataform.middleGraphic != -1) player.setNextSpotAnim(new SpotAnim(plataform.middleGraphic)); if (plataform.invisible) player.getAppearance().transformIntoNPC(1957); } else if (stage == 5) { if (plataform.invisible) player.getAppearance().transformIntoNPC(-1); if (plataform.endEmote != -1) player.setNextAnimation(new Animation(plataform.endEmote)); if (plataform.endGraphic != -1) player.setNextSpotAnim(new SpotAnim(plataform.endGraphic)); } else if (stage == 6) World.sendSpotAnim(toTile, new SpotAnim(getPlatformSpotAnim(plataform.runes.length))); stage++; } }, 0, 0); return true; } public int getCurrentFloor() { if (player.getX() > 4280) return 3; if (player.getX() > 4090) return 2; return 1; } @Override public void start() { sendInterfaces(); player.getPackets().sendVarc(1917, getCurrentFloor()); player.getPackets().sendVarc(1918, 0); player.simpleDialogue(""Welcome To the Runespan "", ""Unnote essence on the essence clouds and siphon for runes."", ""Your runes will not be removed when you leave.""); } @Override public void onTeleported(TeleType teleType) { exitRunespan(); } public void exitRunespan() { player.getInterfaceManager().removeOverlay(); removeController(); } @Override public void sendInterfaces() { player.getInterfaceManager().sendOverlay(1274); refreshPoints(player); } public void addRunespanPoints(double value) { player.addRunespanPoints(value); refreshPoints(player); } public static void refreshPoints(Player player) { player.getPackets().sendVarc(1909, (int) player.getRuneSpanPoints()); player.getPackets().sendVarc(1916, 0); } public static ItemOnNPCHandler handleUnnoteEssence = new ItemOnNPCHandler(15402, e -> { Player player = e.getPlayer(); player.setNextAnimation(new Animation(12832)); int freeSlots = player.getInventory().getFreeSlots(); if (e.getItem().getId() == 7937) { if (player.containsItem(7937)) { if (player.getInventory().getNumberOf(7937) < freeSlots) freeSlots = player.getInventory().getNumberOf(7937); if (freeSlots > 0) { player.getInventory().deleteItem(7937, freeSlots); player.getInventory().addItemDrop(Runecrafting.PURE_ESS, freeSlots); } else player.sendMessage(""You don't have enough inventory space to unnote more essence.""); } } else if (e.getItem().getId() == 1437) { if (player.containsItem(1437)) { if (player.getInventory().getNumberOf(1437) < freeSlots) freeSlots = player.getInventory().getNumberOf(1437); if (freeSlots > 0) { player.getInventory().deleteItem(1437, freeSlots); player.getInventory().addItemDrop(Runecrafting.RUNE_ESS, freeSlots); } else player.sendMessage(""You don't have enough inventory space to unnote more essence.""); } } else player.sendMessage(""You can use noted rune essence on this to unnote them.""); }); @Override public boolean processNPCClick1(NPC npc) { switch (npc.getId()) { case 15402: player.setNextAnimation(new Animation(12832)); int freeSlots = player.getInventory().getFreeSlots(); if (player.containsItem(7937)) { if (player.getInventory().getNumberOf(7937) < freeSlots) freeSlots = player.getInventory().getNumberOf(7937); if (freeSlots > 0) { player.getInventory().deleteItem(7937, freeSlots); player.getInventory().addItemDrop(Runecrafting.PURE_ESS, freeSlots); } else player.sendMessage(""You don't have enough inventory space to unnote more essence.""); } else if (player.containsItem(1437)) { if (player.getInventory().getNumberOf(1437) < freeSlots) freeSlots = player.getInventory().getNumberOf(1437); if (freeSlots > 0) { player.getInventory().deleteItem(1437, freeSlots); player.getInventory().addItemDrop(Runecrafting.RUNE_ESS, freeSlots); } else player.sendMessage(""You don't have enough inventory space to unnote more essence.""); } return false; } return true; } @Override public boolean processObjectClick1(final GameObject object) { if (object.getId() == 70507) if (object.getX() == 4367 && object.getY() == 6062) { player.addWalkSteps(object.getX(), object.getY(), 0, false); player.lock(); final Tile dest = Tile.of(4367, 6033, 1); WorldTasks.scheduleLooping(new Task() { private int stage; @Override public void run() { if (stage == 0) { player.setNextFaceTile(Tile.of(4367, 6062, 1)); player.setNextAnimation(new Animation(16662)); player.setNextSpotAnim(new SpotAnim(3090)); } else if (stage == 4) { player.forceMove(dest, 30, 35*30); player.setNextSpotAnim(new SpotAnim(3091)); stop(); } stage++; } }, 0, 0); } else if (object.getX() == 4367 && object.getY() == 6033) { player.addWalkSteps(object.getX(), object.getY(), 0, false); player.lock(); final Tile dest = Tile.of(4367, 6062, 1); WorldTasks.scheduleLooping(new Task() { private int stage; @Override public void run() { if (stage == 0) { player.setNextFaceTile(Tile.of(4367, 6062, 1)); player.setNextAnimation(new Animation(16662)); player.setNextSpotAnim(new SpotAnim(3090)); } else if (stage == 4) { player.forceMove(dest, 30, 35*30); player.setNextSpotAnim(new SpotAnim(3091)); stop(); } stage++; } }, 0, 0); } if (object.getId() == 70508) { player.useStairs(16668, HIGHER_LEVEL, 4, 5); WorldTasks.schedule(new Task() { @Override public void run() { player.setNextAnimation(new Animation(-1)); } }, 3); player.getPackets().sendVarc(1917, 2); return false; } if (object.getId() == 70509) { player.useStairs(16675, VINE_LADDER, 2, 3); WorldTasks.schedule(new Task() { @Override public void run() { player.setNextAnimation(new Animation(-1)); } }, 1); player.getPackets().sendVarc(1917, 1); return false; } if (object.getId() == 70511) { player.useStairs(16675, BONE_LADDER, 2, 3); WorldTasks.schedule(new Task() { @Override public void run() { player.setNextAnimation(new Animation(-1)); } }, 1); player.getPackets().sendVarc(1917, 2); return false; } else if (object.getId() == 70510) { player.useStairs(16675, TOP_LEVEL, 2, 3); WorldTasks.schedule(new Task() { @Override public void run() { player.setNextAnimation(new Animation(-1)); } }, 1); player.getPackets().sendVarc(1917, 3); return false; } return !handlePlatform(object); } @Override public boolean login() { start(); return false; } @Override public boolean logout() { return false; } @Override public void forceClose() { exitRunespan(); } }" "package com.rs.game.content.skills.runecrafting.runespan; public class SiphonAction extends PlayerAction { private final Creature creatures; private final NPC creature; private boolean started; private int npcLife; public SiphonAction(Creature creatures, NPC creature) { this.creature = creature; this.creatures = creatures; } @Override public boolean start(Player player) { if (checkAll(player)) { npcLife = creatures.npcLife; return true; } return false; } @Override public boolean process(Player player) { return checkAll(player); } public boolean checkAll(final Player player) { if (player.isLocked() || creature.hasFinished()) return false; if (player.getSkills().getLevel(Constants.RUNECRAFTING) < creatures.levelRequired) { player.simpleDialogue(""This creature requires level "" + creatures.levelRequired + "" to siphon.""); return false; } if (!creatures.rune.isPureEss() && !player.getInventory().containsOneItem(Runecrafting.PURE_ESS, Runecrafting.RUNE_ESS)) { player.sendMessage(""You don't have any rune essence to siphon from that creature.""); return false; } if (creatures.rune.isPureEss() && !player.getInventory().containsItem(Runecrafting.PURE_ESS)) { player.sendMessage(""You don't have any pure essence to siphon from that creature.""); return false; } if (!started) { creature.resetWalkSteps(); player.resetWalkSteps(); player.setNextAnimation(new Animation(creatures.playerEmoteId)); npcLife = creatures.npcLife; started = true; } return true; } @Override public int processWithDelay(Player player) { if (started) { boolean success = false; if (Utils.getRandomInclusive(4) <= getWickedWornCount(player)) { success = true; npcLife--; Runecrafting.runecraft(player, creatures.rune, true); Controller controller = player.getControllerManager().getController(); if (controller instanceof RunespanController ctrl) ctrl.addRunespanPoints(creatures.pointValue); } else player.getSkills().addXp(Constants.RUNECRAFTING, 0.5); if (npcLife == 0) { processEsslingDeath(player); return -1; } player.setNextAnimation(new Animation(16596)); creature.setNextAnimation(new Animation(creatures.npcEmoteId)); creature.setNextFaceTile(player.getTile()); creature.freeze(4); player.setNextFaceTile(creature.getTile()); WorldProjectile p = World.sendProjectile(creature, player, 3060, 31, 40, 35, 1, 2, 0); boolean finalSuccess = success; WorldTasks.schedule(Utils.clampI(p.getTaskDelay()-1, 0, 100), () -> player.setNextSpotAnim(new SpotAnim(finalSuccess ? 3062 : 3071))); } return 1; } @Override public void stop(Player player) { } public void processEsslingDeath(final Player player) { creature.setNextAnimation(new Animation(creatures.deathEmote)); WorldTasks.schedule(new Task() { @Override public void run() { player.sendMessage(""The creature has been broken down.""); player.setNextAnimation(new Animation(16599)); creature.setRespawnTask(15); stop(); } }, 2); } public static int getWickedWornCount(Player player) { int count = 0; if (player.getEquipment().getHatId() == 22332) count++; if (player.getEquipment().getChestId() == 24206) count++; if (player.getEquipment().getLegsId() == 24208) count++; if (player.getEquipment().getCapeId() == 24210) count++; return count; } }" "package com.rs.game.content.skills.runecrafting.runespan; @PluginEventHandler public class SiphonCreaturesInteraction extends PlayerEntityInteractionAction { public static NPCClickHandler clickHandler = new NPCClickHandler(false, Arrays.stream(Creature.values()).map(c -> c.npcId).toArray(), new String[] { ""Siphon"", ""Chip off"" }, e -> { Creature creature = getCreature(e.getNPC().getId()); if (creature == null) return; e.getPlayer().getInteractionManager().setInteraction(new SiphonCreaturesInteraction(creature, e.getNPC())); }); public SiphonCreaturesInteraction(Creature creatures, NPC creature) { super(creature, new SiphonAction(creatures, creature), 7); } public static boolean siphon(Player player, NPC npc) { Creature creature = getCreature(npc.getId()); if (creature == null) return false; player.getInteractionManager().setInteraction(new SiphonCreaturesInteraction(creature, npc)); return true; } private static Creature getCreature(int id) { for (Creature creature : Creature.values()) if (creature.npcId == id) return creature; return null; } @Override public boolean canStart(Player player) { return getAction().start(player); } @Override public boolean checkAll(Player player) { return getAction().checkAll(player); } @Override public void onStop(Entity player) { player.setNextAnimation(new Animation(16599)); player.getActionManager().setActionDelay(3); } }" "package com.rs.game.content.skills.runecrafting.runespan; @PluginEventHandler public class SiphonNodeAction extends PlayerAction { Node nodes; GameObject node; private boolean started; public SiphonNodeAction(Node nodes, GameObject node) { this.nodes = nodes; this.node = node; } public enum Node { CYCLONE(70455, 16596, 19, 1, 24215), MIND_STORM(70456, 16596, 20, 1, 24217), WATER_POOL(70457, 16596, 25.3, 5, 24214), ROCK_FRAGMENT(70458, 16596, 28.6, 9, 24216), FIRE_BALL(70459, 16596, 34.8, 14, 24213), VINE(70460, 16596, 34.8, 17, 24214, 24216), FLESHLY_GROWTH(70461, 16596, Utils.random(30.3, 34.3), 20, 24218), FIRE_STORM(70462, 16596, Utils.random(22.8, 41.7), 27, 24213, 24215), CHAOTIC_CLOUD(70463, 16596, 61.6, 35, 24221), NEBULA(70464, 16596, Utils.random(63.8, 85.6), 40, 24223, 24224), SHIFTER(70465, 16596, 86.8, 44, 24220), JUMPER(70466, 16596, 107.8, 54, 24222), SKULLS(70467, 16596, 120, 65, 24219), BLOOD_POOL(70468, 16596, 146.3, 77, 24225), BLOODY_SKULLS(70469, 16596, Utils.random(144, 175.5), 83, 24219, 24225), LIVING_SOUL(70470, 16596, 213, 90, 24226), UNDEAD_SOUL(70471, 16596, Utils.random(144, 255.5), 95, 24219, 24226); private static final Map MAP = new HashMap<>(); static { for (Node n : Node.values()) MAP.put(n.objectId, n); } public static Node forId(int objectId) { return MAP.get(objectId); } private int objectId; private int emoteId; private double xp; private int levelRequired; private final int[] runeId; Node(int objectId, int emoteId, double xp, int levelRequired, int... runeId) { this.objectId = objectId; this.emoteId = emoteId; this.xp = xp; this.levelRequired = levelRequired; this.runeId = runeId; } public int getObjectId() { return objectId; } public void setObjectId(int objectId) { this.objectId = objectId; } public int getEmoteId() { return emoteId; } public void setEmoteId(int emoteId) { this.emoteId = emoteId; } public int[] getRuneId() { return runeId; } public double getXp() { return xp; } public void setXp(int xp) { this.xp = xp; } public int getLevelRequired() { return levelRequired; } public void setLevelRequired(int levelRequired) { this.levelRequired = levelRequired; } } public static ObjectClickHandler handleNodes = new ObjectClickHandler(false, Node.MAP.keySet().toArray(), e -> { // Nodes node = getNode(e.getObjectId()); // if (node == null) // return; // e.getPlayer().getActionManager().setAction(new SiphonNodeAction(node, e.getObject())); }); @SuppressWarnings(""unused"") private static int getRandomTransformationId() { return getNode(Utils.getRandomInclusive(Node.values().length)).getObjectId(); } private static Node getNode(int id) { for (Node node : Node.values()) if (node.objectId == id) return node; return null; } @Override public boolean start(Player player) { if (checkAll(player)) return true; return false; } public boolean checkAll(final Player player) { if (player.getSkills().getLevel(Constants.RUNECRAFTING) < nodes.getLevelRequired()) { player.simpleDialogue(""You need a runecrafting level of "" + nodes.getLevelRequired() + "" to siphon from that node.""); return false; } if (!started && !player.withinDistance(node.getTile(), 6)) return true; if (!ChunkManager.getChunk(node.getTile().getChunkId()).objectExists(node)) { stop(player); return false; } // if ((!creatures.rune.isPureEss() && !player.getInventory().containsOneItem(Runecrafting.PURE_ESS, Runecrafting.RUNE_ESS)) || (creatures.rune.isPureEss() && !player.getInventory().containsItem(Runecrafting.PURE_ESS))) { // player.sendMessage(""You don't have any rune essence to siphon from that creature.""); // return false; // } if (!started) { player.resetWalkSteps(); player.setNextAnimation(new Animation(16596)); started = true; } return true; } @Override public boolean process(Player player) { return checkAll(player); } @SuppressWarnings(""unused"") private void processNodeDestroy(final Player player) { player.sendMessage(""The node you were siphoning from has been depleted of energy."", true); WorldTasks.schedule(new Task() { @Override public void run() { player.setNextAnimation(new Animation(16599)); World.removeObject(node); stop(); } }, 2); } @Override public int processWithDelay(final Player player) { if (started) { boolean success = false; if (Utils.getRandomInclusive(4) == 0) { success = true; //Runecrafting.runecraft(player, nodes.randomRune(), true); double totalXp = nodes.getXp(); if (Runecrafting.hasRcingSuit(player)) totalXp *= 1.025; player.getSkills().addXp(Constants.RUNECRAFTING, totalXp); } player.setNextAnimation(new Animation(nodes.getEmoteId())); player.setNextFaceTile(node.getTile()); WorldProjectile p = World.sendProjectile(node, player, 3060, 31, 40, 35, 1, 2, 0); final boolean succF = success; WorldTasks.schedule(new Task() { @Override public void run() { player.setNextSpotAnim(new SpotAnim(succF ? 3062 : 3071)); } }, Utils.clampI(p.getTaskDelay()-1, 0, 100)); } return 1; } @Override public void stop(Player player) { player.setNextAnimation(new Animation(16599)); setActionDelay(player, 3); } }" "package com.rs.game.content.skills.runecrafting.runespan; public class WizardFinix extends Conversation { private static final int FINIX = 15417; public WizardFinix(Player player) { super(player); addOptions(new Options() { @Override public void create() { option(""Hello. Who are you?"", new Dialogue() .addNPC(FINIX, HeadE.CHEERFUL, ""I'm Wizard Finix. I am a student of runecrafting."") .addPlayer(HeadE.CHEERFUL_EXPOSITION, ""Ah, pleased to meet you, Wizard Finix. I'm "" + player.getDisplayName() + "". What are you doing here?"") .addNPC(FINIX, HeadE.CHEERFUL, ""I'm creating runes by siphoning energy out of the Runespan."") .addPlayer(HeadE.CONFUSED, ""Creating runes by siphoning?"") .addNPC(FINIX, HeadE.CHEERFUL, ""Yes, it's a new way to make runes. I discovered it, actually!"") .addOptions(new Options() { @Override public void create() { option(""Why don't you just use the altars?"", new Dialogue() .addNPC(FINIX, HeadE.CHEERFUL, ""That is another one of my discoveries! Runecrafting altars will not last forever. One day, the altars will run out!"") .addPlayer(HeadE.SCARED, ""Run out?"") .addNPC(FINIX, HeadE.SKEPTICAL, ""Yes - of course, it is still only a theory. The Runecrafting Guild Wizards are still skeptical, but they cannot prove me wrong."") .addPlayer(HeadE.SCARED, ""How will humans perform magic if they cannot make runes?"") .addNPC(FINIX, HeadE.CHEERFUL, ""Exactly. That is why learning to siphon energy from the world around us is important."") .addPlayer(HeadE.SCARED, ""You mean I could create runes by pulling energy from Gielinor itself?"") .addNPC(FINIX, HeadE.SKEPTICAL, ""Theoretically, yes, but there is no runecrafter skilled enough to do this yet. In theory, runecrafting and magic should be a self-supporting cycle."") .addPlayer(HeadE.CONFUSED, ""So how can I learn to siphon energy if it is so difficult?"") .addNPC(FINIX, HeadE.CHEERFUL, ""That is why we are in this area. In the Runespan, energy is still in a very raw state and is not tightly bound to matter, as it is in Gielinor. The wizards of the Runecrafting Guild have been using their tower to study."") .addNPC(FINIX, HeadE.CHEERFUL, ""runic energy in the Runespan for years."") .addPlayer(HeadE.SCARED, ""So that means..."") .addNPC(FINIX, HeadE.CHEERFUL, ""...we are outside the Runecrafting Guild - yes!"")); option(""How do you make runes by siphoning?"", new Dialogue() .addNPC(FINIX, HeadE.SKEPTICAL, ""Well, firstly, you must bring your own rune essence into the Runespan as rune essence is depletable resource. Feel free to grab from the floating rune rocks we have placed around, but only if you have"") .addNPC(FINIX, HeadE.SKEPTICAL, ""bank notes of your own to exchange, as we would like to keep the stock plentiful and reduce trips taken to restore the supply."") .addNPC(FINIX, HeadE.CHEERFUL, ""Don't worry, though, that means you are free to keep any runes you create while within the Runespan! The Runecrafting Guild is also willing to keep track of the runes you craft"") .addNPC(FINIX, HeadE.CHEERFUL, ""and award you points to spend in my shop in the Wizards' Tower."") .addPlayer(HeadE.CONFUSED, ""Alright, so how does making runes work?"") .addNPC(FINIX, HeadE.CHEERFUL, ""The process is relatively simple. Once you have rune essence, you can siphon energy from the creatures and pockets of energy that appear randomly on islands in this area."") .addNPC(FINIX, HeadE.CHEERFUL, ""The energy in the creatures is not as dense as it is in the pockets of energy, so they will give you a smaller number of runes."") .addNPC(FINIX, HeadE.CHEERFUL, ""Just be aware it can be tricky to succeed in siphoning when you are starting out. I have infused the various wicked fabric items with some of my experience"") .addNPC(FINIX, HeadE.CHEERFUL, ""should you wish to use it. Wearing various parts of the outfit whilst training in here will certainly help you to be more successful in your training."")); } })); option(""Can you teleport me back to the Wizards' Tower?"", new Dialogue() .addNPC(FINIX, HeadE.CHEERFUL, ""Of course!"") .addNext(() -> Magic.sendNormalTeleportSpell(player, Tile.of(3107, 3162, 1)))); } }); create(); } }" "package com.rs.game.content.skills.slayer; public class BossTask { private int amount; private BossTasks task; public BossTask(BossTasks task, int amount) { this.task = task; this.amount = amount; } public static enum BossTasks { GENERAL_GRAARDOR (6260, 5, 12, 10000), COMMANDER_ZILYANA (6247, 5, 12, 10000), KRIL_TSUTAROTH (6203, 5, 12, 10000), KREE_ARRA (6222, 5, 12, 10000), NEX (13447, 2, 4, 20000), KING_BLACK_DRAGON (50, 10, 15, 6000), KALPHITE_QUEEN (1158, 10, 12, 7000), CORPOREAL_BEAST (8133, 2, 5, 15000), DAGANNOTH_REX (2883, 8, 12, 10000), DAGANNOTH_PRIME (2882, 8, 12, 10000), DAGANNOTH_SUPREME (2881, 8, 12, 10000), CHAOS_ELEMENTAL (3200, 8, 12, 10000), TORMENTED_DEMON (8349, 8, 12, 10000); private static final Map monsters = new HashMap<>(); public static BossTasks forId(int id) { return monsters.get(id); } static { for (BossTasks monster : BossTasks.values()) monsters.put(monster.id, monster); } private final int id; private final int minAmount; private final int maxAmount; private final int xp; private BossTasks(int id, int minAmount, int maxAmount, int xp) { this.id = id; this.minAmount = minAmount; this.maxAmount = maxAmount; this.xp = xp; } public int getId() { return id; } public int getMinAmount() { return minAmount; } public int getMaxAmount() { return maxAmount; } public int getXp() { return xp; } public static BossTasks getRandomTask() { return (BossTasks) monsters.values().toArray()[Utils.random(monsters.values().size()-1)]; } } public String getName() { return NPCDefinitions.getDefs(task.getId()).getName(); } public void finishTask(Player player) { player.incrementCount(""Reaper assignments completed""); player.sendMessage(""You have completed your reaper assignment. You are rewarded with ""+task.getXp()+"" Slayer experience and 15 Reaper points.""); player.getSkills().addXp(Constants.SLAYER, task.getXp()); player.reaperPoints += 15; player.setDailyB(""bossTaskCompleted"", true); player.setBossTask(null); } public void sendKill(Player player, NPC npc) { World.sendProjectile(npc, player, 3060, 18, 18, 15, 0, 20, 0); if (amount >= 1) amount--; if (amount <= 0) finishTask(player); else player.sendMessage(""As ""+npc.getName()+"" dies, you absorb the soul. You now need ""+amount+"" more souls.""); } public static BossTask create() { BossTasks info = BossTasks.getRandomTask(); BossTask task = new BossTask(info, Utils.random(info.getMinAmount(), info.getMaxAmount())); return task; } public BossTasks getTask() { return task; } public void setTask(BossTasks task) { this.task = task; } public int getAmount() { return amount; } public void setAmount(int amount) { this.amount = amount; } public String getMessage() { return ""You are currently assigned to collect souls from: "" + getName() + "". You must still retrieve "" + amount + "" to complete your assignment.""; } }" "package com.rs.game.content.skills.slayer; public class EnchantedGemD extends Conversation { public EnchantedGemD(Player player, Master master) { super(player); int NPC = master.npcId; addNPC(NPC, HeadE.CALM_TALK, ""Hello there, ""+ player.getDisplayName() + "", what can I help you with?""); addOptions(""Choose an option:"", new Options() { @Override public void create() { option(""How am I doing so far?"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""How am I doing so far?"") .addNPC(NPC, HeadE.CALM_TALK, player.getSlayer().getTaskString()) ); option(""Who are you?"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Who are you?"") .addNPC(NPC, HeadE.CALM_TALK, ""My name is ""+Utils.formatPlayerNameForDisplay(Master.getMasterForId(NPC).name().toLowerCase())+""; I'm a Slayer Master."") ); option(""Where are you?"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Where are you?"") .addNPC(NPC, HeadE.CALM_TALK, ""I am talking to you through a spectral dimension and don't want to reveal my location."") .addPlayer(HeadE.HAPPY_TALKING, ""Is that so?"") .addNPC(NPC, HeadE.CALM_TALK, ""Yes."") ); } }); create(); } }" "package com.rs.game.content.skills.slayer; public enum Master { Turael(8480, 3, 1, 1, 1, 3, 10), Mazchna(8481, 20, 1, 2, 2, 5, 15), Vannaka(1597, 40, 1, 3, 4, 20, 60), Chaeldar(1598, 70, 1, 4, 10, 50, 150), Sumona(7779, 85, 35, 5, 12, 60, 180), Duradel(8466, 100, 50, 6, 15, 75, 225), Kuradal(9085, 110, 75, 7, 18, 90, 270); public static final Map SLAYER_MASTERS = new HashMap<>(); public static Master getMaster(int id) { return SLAYER_MASTERS.get(id); } public static Master getMasterForId(int npcId) { for (Master master : Master.values()) if (master != null && master.npcId == npcId) return master; return null; } static { for (Master master : Master.values()) SLAYER_MASTERS.put(master.npcId, master); } public final int npcId; public final int requiredCombatLevel; public final int reqSlayerLevel; public final int masterID; private final int points; private final int points10; private final int points50; private Master(int npcId, int requiredCombatLevel, int requiredSlayerLevel, int slayerMasterID, int points, int points10, int points50) { this.npcId = npcId; this.requiredCombatLevel = requiredCombatLevel; reqSlayerLevel = requiredSlayerLevel; masterID = slayerMasterID; this.points = points; this.points10 = points10; this.points50 = points50; } public int getPoints() { return points; } public int getPoints10() { return points10; } public int getPoints50() { return points50; } }" "package com.rs.game.content.skills.slayer; @PluginEventHandler public class ReaperAssignments { static class ReaperDialogue extends Conversation { public ReaperDialogue(Player player) { super(player); if (!((boolean) player.get(""learnedDeath""))) { addNPC(15661, HeadE.CALM, ""Hello mortal. I am in need of some assistance and I have an offer to propose to you. Listen closely.""); addNPC(15661, HeadE.CALM, ""As you are no doubt aware, I am Death. The Reaper, the Collector of Souls, or any other name civilizations have given me. My task is to retrieve "" + ""the soul from a dying creature, enabling its passage to the underworld.""); addPlayer(HeadE.CONFUSED, ""So what do you need me for?""); addNPC(15661, HeadE.CALM, ""There is an imbalance in the harmony of life and death. There is far too much... life.""); addNPC(15661, HeadE.CALM, ""My eyes have been on you in this age, "" + player.getDisplayName() + "", as have the eyes of many others. You appear to have the skills "" + ""I require to bring balance.""); addPlayer(HeadE.CONFUSED, ""So you want me to kill stuff?""); addNPC(15661, HeadE.CALM, ""If you wish to put it so indelicately, yes.""); addPlayer(HeadE.HAPPY_TALKING, ""Great! When do I start?""); addNPC(15661, HeadE.CALM, ""Immediately.""); addNext(() -> { player.save(""learnedDeath"", true); player.getInventory().addItemDrop(24806, 1); giveNewTask(player); }); } else { addNPC(15661, HeadE.CALM, ""What is it, mortal? Time is ticking.""); addOptions(""What would you like to say?"", new Options() { @Override public void create() { option(""I need an assignment."", () -> talkAboutAssignment(player)); option(""I'd like another grim gem."", new Dialogue() .addItem(24806, ""You receive a grim gem."", () -> player.getInventory().addItem(24806, 1))); option(""Are there any rewards for this?"", new Dialogue() .addNPC(15661, HeadE.CALM, ""Not yet, mortal. I am still thinking about possible reward options. But I will still keep tally of your points regardless."")); } }); } create(); } } public static void talkAboutAssignment(Player player) { if (player.getBossTask() == null) giveNewTask(player); else player.startConversation(new Conversation(player).addNext(getRerollTaskDialogue(player))); } public static void giveNewTask(Player player) { if (player.getDailyB(""bossTaskCompleted"")) { player.startConversation(new Conversation(player) .addNPC(15661, HeadE.CALM, ""The imbalance has been corrected for today; your task is done. Visit me tomorrow for further instructions."")); return; } player.setBossTask(BossTask.create()); player.startConversation(new Conversation(player) .addNPC(15661, HeadE.CALM, ""I require you to collect "" + player.getBossTask().getAmount() + "" souls from the following battle: "" + player.getBossTask().getName() + "". Can I trust you with this task?"") .addOptions(""Select an Option"", new Options() { @Override public void create() { option(""You certainly can. Thanks!"", () -> {}); option(""I'd like a different assignment."", getRerollTaskDialogue(player)); } })); } public static Dialogue getRerollTaskDialogue(Player player) { Dialogue d = new Dialogue(); if (player.getDailyI(""bossTaskRerolls"") < 3) d.addNPC(15661, HeadE.CALM, ""Do not think I will allow you to change your mind freely. I will only allow you to change it 3 times per day. "" + (player.getDailyI(""bossTaskRerolls"") == 0 ? """" : ""You've already used up "" + player.getDailyI(""bossTaskRerolls"") + "" of those."")) .addOption(""Are you sure you want to reroll your task?"", ""Yes, I am sure."", ""Nevermind, I will just do this task."") .addNext(() -> { player.incDailyI(""bossTaskRerolls""); giveNewTask(player); }); else d.addNPC(15661, HeadE.CALM, ""My patience only stretches so far. You have wasted enough of my time, I must address this imbalance myself. Be gone, mortal.""); return d; } public static ItemClickHandler handleGrimGem = new ItemClickHandler(new Object[] { 24806 }, e -> { switch(e.getOption()) { case ""Activate"": e.getPlayer().startConversation(new ReaperDialogue(e.getPlayer())); break; case ""Kills-left"": if (e.getPlayer().getBossTask() != null) e.getPlayer().sendMessage(e.getPlayer().getBossTask().getMessage()); else e.getPlayer().sendMessage(""You do not have a task assigned right now.""); break; case ""Assignment"": talkAboutAssignment(e.getPlayer()); break; } }); public static NPCClickHandler handleDeath = new NPCClickHandler(new Object[] { 15661 }, e -> { switch(e.getOpNum()) { case 1: e.getPlayer().startConversation(new ReaperDialogue(e.getPlayer())); break; case 3: talkAboutAssignment(e.getPlayer()); break; case 4: e.getPlayer().sendMessage(""Rewards are not implemented at the moment, but you can still gain points. Feel free to post suggestions for rewards in Discord.""); break; } }); }" "package com.rs.game.content.skills.slayer; @PluginEventHandler public class Slayer { public static final int BUY_INTERFACE = 164; public static final int LEARN_INTERFACE = 378; public static final int ASSIGNMENT_INTERFACE = 161; public static ItemClickHandler handleKillsLeft = new ItemClickHandler(new String[] { ""Kills-left"" }, e -> e.getPlayer().sendMessage(e.getPlayer().getSlayer().getTaskString())); public static ItemOnPlayerHandler groupSlayer = new ItemOnPlayerHandler(new Object[] { 4155 }, e -> { e.getPlayer().sendMessage(""Group slayer is in progress.""); // if (other.getCoopSlayerPartner() != null) { // player.sendMessage(""This player is already in a slayer group with: "" + other.getCoopSlayerPartner().getDisplayName()); // return; // } // if (player.getCoopSlayerPartner() != null) { // player.sendMessage(""You are already in a slayer group with: "" + player.getCoopSlayerPartner().getDisplayName()); // return; // } // player.sendMessage(""Sending co-op slayer request...""); // other.getPackets().sendCoOpSlayerRequestMessage(player); // player.getTemporaryAttributtes().put(""coopSlayerRequest"", other); }); public static void openBuyInterface(Player player) { player.getInterfaceManager().sendInterface(BUY_INTERFACE); player.getPackets().setIFText(BUY_INTERFACE, 20, """" + player.slayerPoints); } public static void openLearnInterface(Player player) { player.getInterfaceManager().sendInterface(LEARN_INTERFACE); player.getPackets().setIFText(LEARN_INTERFACE, 79, """" + player.slayerPoints); if (player.isSlayerHelmCreation()) player.getPackets().setIFText(LEARN_INTERFACE, 100, ""Learned""); if (player.isBroadFletching()) player.getPackets().setIFText(LEARN_INTERFACE, 90, ""Learned""); if (player.hasCraftROS()) player.getPackets().setIFText(LEARN_INTERFACE, 99, ""Learned""); if (player.aquanitesUnlocked()) player.getPackets().setIFText(LEARN_INTERFACE, 91, ""Learned""); if (player.iceStrykeNoCape()) player.getPackets().setIFText(LEARN_INTERFACE, 98, ""Learned""); if (player.hasLearnedQuickBlows()) player.getPackets().setIFText(LEARN_INTERFACE, 97, ""Learned""); } public static void openAssignmentInterface(Player player) { player.getInterfaceManager().sendInterface(ASSIGNMENT_INTERFACE); player.getPackets().setIFText(ASSIGNMENT_INTERFACE, 19, """" + player.slayerPoints); refreshBlockedTasks(player); } public static void refreshBlockedTasks(Player player) { for(int i = 0;i < player.getBlockedTasks().length;i++) if (player.getBlockedTasks()[i] != null) player.getPackets().setIFText(ASSIGNMENT_INTERFACE, i+31, player.getBlockedTasks()[i].getName()); else player.getPackets().setIFText(ASSIGNMENT_INTERFACE, i+31, ""Empty""); } public static void refreshPoints(Player player, int interfaceId) { switch (interfaceId) { case BUY_INTERFACE: player.getPackets().setIFText(BUY_INTERFACE, 20, """" + player.slayerPoints); break; case LEARN_INTERFACE: player.getPackets().setIFText(LEARN_INTERFACE, 18, """" + player.slayerPoints); break; case ASSIGNMENT_INTERFACE: player.getPackets().setIFText(ASSIGNMENT_INTERFACE, 19, """" + player.slayerPoints); break; default: break; } } public static ButtonClickHandler handleButtons = new ButtonClickHandler(new Object[] { BUY_INTERFACE, LEARN_INTERFACE, ASSIGNMENT_INTERFACE }, e -> { switch (e.getInterfaceId()) { case BUY_INTERFACE: if (e.getComponentId() == 16) openLearnInterface(e.getPlayer()); if (e.getComponentId() == 17) openAssignmentInterface(e.getPlayer()); if (e.getComponentId() == 32 || e.getComponentId() == 24) if (e.getPlayer().slayerPoints >= 400) { e.getPlayer().getSkills().addXp(Constants.SLAYER, 10000); e.getPlayer().slayerPoints -= 400; refreshPoints(e.getPlayer(), e.getInterfaceId()); } else e.getPlayer().sendMessage(""You need 400 points for 10,000 Slayer experience.""); if (e.getComponentId() == 36 || e.getComponentId() == 28) if (e.getPlayer().slayerPoints >= 35) { e.getPlayer().getInventory().addItem(558, 1000); e.getPlayer().getInventory().addItem(560, 250); e.getPlayer().slayerPoints -= 35; refreshPoints(e.getPlayer(), e.getInterfaceId()); } else e.getPlayer().sendMessage(""You need 35 points for 250 slayer dart runes.""); break; case LEARN_INTERFACE: if (e.getComponentId() == 15) openBuyInterface(e.getPlayer()); if (e.getComponentId() == 76) { if (e.getPlayer().slayerPoints < 300) { e.getPlayer().sendMessage(""You need 300 points to buy broad fletching.""); return; } if (!e.getPlayer().isBroadFletching()) { e.getPlayer().slayerPoints -= 300; e.getPlayer().setBroadFletching(true); openLearnInterface(e.getPlayer()); } else e.getPlayer().sendMessage(""You already learned broad fletching.""); } if (e.getComponentId() == 77) { if (e.getPlayer().slayerPoints < 300) { e.getPlayer().sendMessage(""You need 300 points to buy the ability to craft the ring of slaying.""); return; } if (!e.getPlayer().hasCraftROS()) { e.getPlayer().slayerPoints -= 300; e.getPlayer().setCraftROS(true); openLearnInterface(e.getPlayer()); } else e.getPlayer().sendMessage(""You already learned how to craft the ring of slaying.""); } if (e.getComponentId() == 78) { if (e.getPlayer().slayerPoints < 400) { e.getPlayer().sendMessage(""You need 400 points to buy that ability.""); return; } if (!e.getPlayer().isSlayerHelmCreation()) { e.getPlayer().slayerPoints -= 400; e.getPlayer().setSlayerHelmCreation(true); openLearnInterface(e.getPlayer()); } else e.getPlayer().sendMessage(""You already learned how to craft slayer helmets.""); } if (e.getComponentId() == 74) { if (e.getPlayer().slayerPoints < 400) { e.getPlayer().sendMessage(""You need 400 points to buy that ability.""); return; } if (!e.getPlayer().hasLearnedQuickBlows()) { e.getPlayer().slayerPoints -= 400; e.getPlayer().setHasLearnedQuickBlows(true); openLearnInterface(e.getPlayer()); } else e.getPlayer().sendMessage(""You already learned how to deliver quick killing blows.""); } if (e.getComponentId() == 73) { if (e.getPlayer().slayerPoints < 50) { e.getPlayer().sendMessage(""You need 50 points to buy that ability.""); return; } if (!e.getPlayer().aquanitesUnlocked()) { e.getPlayer().slayerPoints -= 50; e.getPlayer().setAquanitesUnlocked(true); openLearnInterface(e.getPlayer()); } else e.getPlayer().sendMessage(""You already persuaded Kuradal to assign aquanites.""); } if (e.getComponentId() == 75) { if (e.getPlayer().slayerPoints < 2000) { e.getPlayer().sendMessage(""You need 2000 points to buy that ability.""); return; } if (!e.getPlayer().iceStrykeNoCape()) { e.getPlayer().slayerPoints -= 2000; e.getPlayer().setIceStrykeNoCape(true); openLearnInterface(e.getPlayer()); } else e.getPlayer().sendMessage(""You already learned how to fight ice strykewyrms without a fire cape.""); } if (e.getComponentId() == 14) openAssignmentInterface(e.getPlayer()); break; case ASSIGNMENT_INTERFACE: if (e.getComponentId() == 15) openBuyInterface(e.getPlayer()); if (e.getComponentId() == 14) openLearnInterface(e.getPlayer()); if (e.getComponentId() == 26) { if (e.getPlayer().slayerPoints < 30) { e.getPlayer().sendMessage(""You need 30 points to cancel your task.""); return; } if (e.getPlayer().hasSlayerTask()) { e.getPlayer().slayerPoints -= 30; e.getPlayer().getSlayer().removeTask(); e.getPlayer().updateSlayerTask(); refreshPoints(e.getPlayer(), e.getInterfaceId()); } else e.getPlayer().sendMessage(""You don't have a slayer task to cancel.""); } if (e.getComponentId() == 27) if (e.getPlayer().slayerPoints >= 100) { if (e.getPlayer().hasSlayerTask()) { if (e.getPlayer().getBlockedTaskNumber() < 6) { e.getPlayer().slayerPoints -= 100; e.getPlayer().blockTask(e.getPlayer().getSlayer().getTask().getMonster()); e.getPlayer().getSlayer().removeTask(); refreshBlockedTasks(e.getPlayer()); refreshPoints(e.getPlayer(), e.getInterfaceId()); } else e.getPlayer().sendMessage(""You are not able to block more than 6 tasks.""); } else e.getPlayer().sendMessage(""You don't have a slayer task to block.""); } else e.getPlayer().sendMessage(""You need 100 points to block a task.""); if (e.getComponentId() >= 37 && e.getComponentId() <= 42) { int index = e.getComponentId() - 37; e.getPlayer().unblockTask(index); refreshBlockedTasks(e.getPlayer()); } break; } }); public static boolean hasNosepeg(Entity target) { if (!(target instanceof Player targetPlayer)) return true; int hat = targetPlayer.getEquipment().getHatId(); return hat == 4168 || hasSlayerHelmet(target); } public static boolean hasEarmuffs(Entity target) { if (!(target instanceof Player targetPlayer)) return true; int hat = targetPlayer.getEquipment().getHatId(); return hat == 4166 || hat == 13277 || hasSlayerHelmet(target); } public static boolean hasMask(Entity target) { if (!(target instanceof Player targetPlayer)) return true; int hat = targetPlayer.getEquipment().getHatId(); return hat == 1506 || hat == 4164 || hat == 13277 || hasSlayerHelmet(target); } public static boolean hasWitchWoodIcon(Entity target) { if (!(target instanceof Player targetPlayer)) return true; int hat = targetPlayer.getEquipment().getAmuletId(); return hat == 8923; } public static boolean hasSlayerHelmet(Entity target) { if (!(target instanceof Player targetPlayer)) return true; int hat = targetPlayer.getEquipment().getHatId(); return hat == 13263 || hat == 14636 || hat == 14637 || hasFullSlayerHelmet(target); } public static boolean hasFullSlayerHelmet(Entity target) { if (!(target instanceof Player targetPlayer)) return true; int hat = targetPlayer.getEquipment().getHatId(); return hat == 15492 || hat == 15496 || hat == 15497 || (hat >= 22528 && hat <= 22550); } public static boolean hasReflectiveEquipment(Entity target) { if (!(target instanceof Player targetPlayer)) return true; int shieldId = targetPlayer.getEquipment().getShieldId(); return shieldId == 4156; } public static boolean hasSpinyHelmet(Entity target) { if (!(target instanceof Player targetPlayer)) return true; int hat = targetPlayer.getEquipment().getHatId(); return hat == 4551 || hasSlayerHelmet(target); } public static boolean isUsingBell(final Player player) { player.lock(3); player.setNextAnimation(new Animation(6083)); List objects = ChunkManager.getChunk(player.getChunkId()).getAllObjects(); if (objects == null) return false; for (final GameObject object : objects) { if (!object.getTile().withinDistance(player.getTile(), 3) || object.getId() != 22545) continue; player.sendMessage(""The bell re-sounds loudly throughout the cavern.""); WorldTasks.schedule(new Task() { @Override public void run() { NPC npc = World.spawnNPC(5751, Tile.of(player.getTile()), -1, true); npc.getCombat().setTarget(player); GameObject o = new GameObject(object); o.setId(22544); World.spawnObjectTemporary(o, Ticks.fromSeconds(30)); } }, 1); return true; } return false; } public static boolean isBlackMask(int requestedId) { return requestedId >= 8901 && requestedId <= 8920; } public static boolean isSlayerHelmet(Item item) { return item.getName().toLowerCase().contains(""slayer helm""); } }" "package com.rs.game.content.skills.slayer; @PluginEventHandler public class SlayerHelmet { static int[] SLAYER_HELMET_PARTS = { 4166, 4164, 4551, 4168 }; static int[] FULL_SLAYER_HELMET_PARTS = { 15490, 15488 }; static int SLAYER_HELMET = 13263; static int FULL_SLAYER_HELMET = 15492; public static ItemClickHandler dismantle = new ItemClickHandler(new Object[] { FULL_SLAYER_HELMET, SLAYER_HELMET }, new String[] { ""Disassemble"" }, e -> { if (e.getItem().getId() == FULL_SLAYER_HELMET) { if (e.getPlayer().getInventory().getFreeSlots() < 7) { e.getPlayer().sendMessage(""You don't have enough space in your inventory to dissassemble the helmet.""); return; } e.getPlayer().getInventory().deleteItem(15492, 1); for (int parts : FULL_SLAYER_HELMET_PARTS) e.getPlayer().getInventory().addItem(parts, 1, true); for (int parts : SLAYER_HELMET_PARTS) e.getPlayer().getInventory().addItem(parts, 1, true); e.getPlayer().getInventory().addItem(8921, 1); return; } if (e.getItem().getId() == SLAYER_HELMET) { if (e.getPlayer().getInventory().getFreeSlots() < 5) { e.getPlayer().sendMessage(""You don't have enough space in your inventory to dissassemble the helmet.""); return; } e.getPlayer().getInventory().deleteItem(13263, 1); for (int parts : SLAYER_HELMET_PARTS) e.getPlayer().getInventory().addItem(parts, 1, true); e.getPlayer().getInventory().addItem(8921, 1); return; } }); public static ItemOnItemHandler craftNormal = new ItemOnItemHandler(SLAYER_HELMET_PARTS, SLAYER_HELMET_PARTS, SlayerHelmet::craft); public static ItemOnItemHandler craftFull = new ItemOnItemHandler(SLAYER_HELMET, FULL_SLAYER_HELMET_PARTS, SlayerHelmet::craft); public static boolean craft(ItemOnItemEvent e) { boolean CRAFT_FULL_SLAYER_HELMET = true; if (!SlayerHelmet.isSlayerHelmComponent(e.getItem1().getId()) || !isSlayerHelmComponent(e.getItem2().getId())) return false; if (!e.getPlayer().isSlayerHelmCreation()) { e.getPlayer().sendMessage(""You don't know what to do with these parts. You should talk to an expert, perhaps they know how to assemble these parts.""); return true; } if (e.getPlayer().getSkills().getLevel(Constants.CRAFTING) < 55) { e.getPlayer().sendMessage(""You need a Crafting level of 55 in order to assemble a slayer helmet.""); return true; } //Determine if the player has the necessary items to craft a full slayer helmet for (int parts : FULL_SLAYER_HELMET_PARTS) if (!e.getPlayer().getInventory().containsItem(parts, 1)) CRAFT_FULL_SLAYER_HELMET = false; //Verify the player has all normal slayer helmet parts for (int parts : SLAYER_HELMET_PARTS) if (!e.getPlayer().getInventory().containsItem(parts, 1)) { if (!CRAFT_FULL_SLAYER_HELMET || !e.getPlayer().getInventory().containsItem(SLAYER_HELMET, 1)) return false; } if ((!e.getPlayer().getInventory().containsItem(""black mask"") && !CRAFT_FULL_SLAYER_HELMET) || (!e.getPlayer().getInventory().containsItem(""black mask"") && !e.getPlayer().getInventory().containsItem(SLAYER_HELMET))) return false; if (!CRAFT_FULL_SLAYER_HELMET) { for (int parts : SLAYER_HELMET_PARTS) e.getPlayer().getInventory().deleteItem(parts, 1); for (int i = 8901; i <= 8922; i++) if (!ItemDefinitions.getDefs(i).isNoted() && e.getPlayer().getInventory().containsItem(i)) { e.getPlayer().getInventory().deleteItem(i, 1); break; } e.getPlayer().getInventory().addItem(new Item(SLAYER_HELMET, 1)); e.getPlayer().sendMessage(""You combine all parts of the helmet.""); return true; } if (e.getPlayer().getInventory().containsItem(SLAYER_HELMET, 1)) { e.getPlayer().getInventory().deleteItem(SLAYER_HELMET, 1); for (int parts : FULL_SLAYER_HELMET_PARTS) e.getPlayer().getInventory().deleteItem(parts, 1); e.getPlayer().getInventory().addItem(new Item(15492, 1)); e.getPlayer().sendMessage(""You attach two parts to your slayer helmet.""); return true; } for (int parts : SLAYER_HELMET_PARTS) e.getPlayer().getInventory().deleteItem(parts, 1); for (int parts : FULL_SLAYER_HELMET_PARTS) e.getPlayer().getInventory().deleteItem(parts, 1); for (int i = 8901; i <= 8922; i++) if (!ItemDefinitions.getDefs(i).isNoted() && e.getPlayer().getInventory().containsItem(i)) { e.getPlayer().getInventory().deleteItem(i, 1); break; } e.getPlayer().getInventory().addItem(new Item(15492, 1)); e.getPlayer().sendMessage(""You combine all parts of the helmet.""); return true; } public static boolean isSlayerHelmComponent(int itemId) { for (int parts : SLAYER_HELMET_PARTS) if (itemId == parts) return true; for (int parts : FULL_SLAYER_HELMET_PARTS) if (itemId == parts) return true; if ((itemId >= 8901 && itemId <= 8922 && !ItemDefinitions.getDefs(itemId).isNoted()) || (itemId == 13263)) return true; return false; } }" "package com.rs.game.content.skills.slayer; @PluginEventHandler public class SlayerMasterD extends Conversation { public static NPCClickHandler handleMasters = new NPCClickHandler(new Object[] { 8480, 8481, 1597, 1598, 7779, 8466, 9085 }, e -> { Master master = Master.getMasterForId(e.getNPC().getId()); switch(e.getOption()) { case ""Talk-to"" -> e.getPlayer().startConversation(new SlayerMasterD(e.getPlayer(), master)); case ""Get-task"" -> e.getPlayer().getSlayer().getTaskFrom(e.getPlayer(), master); case ""Trade"" -> e.getPlayer().getSlayer().openShop(e.getPlayer(), master); case ""Rewards"" -> Slayer.openBuyInterface(e.getPlayer()); } }); public SlayerMasterD(Player player, Master master) { super(player); addNPC(master.npcId, HeadE.NO_EXPRESSION, ""'Ello, and what are you after then?""); addOptions(""What would you like to say?"", ops -> { ops.add(""I need another assignment."", new Dialogue() .addPlayer(HeadE.CHEERFUL, ""I need another assignment."") .addNext(() -> player.getSlayer().getTaskFrom(player, master))); ops.add(""Do you have anything for trade?"", new Dialogue() .addPlayer(HeadE.CHEERFUL, ""Do you have anything for trade?"") .addNext(() -> player.getSlayer().openShop(player, master))); ops.add(""I'd like to see the rewards shop please."", new Dialogue() .addPlayer(HeadE.CHEERFUL, ""I'd like to see the rewards shop please."") .addNext(() -> Slayer.openBuyInterface(player))); if (master == Master.Kuradal) ops.add(""What is that cape you're wearing?"", Skillcapes.Slayer.getOffer99CapeDialogue(player, master.npcId)); if (master == Master.Vannaka) ops.add(""About the Achievement System..."", () -> new AchievementSystemD(player, master.npcId, SetReward.VARROCK_ARMOR)); }); create(); } }" "package com.rs.game.content.skills.slayer; public enum SlayerMonsters { CRAWLING_HAND(1648, 5), CAVE_BUG(1832, 7), CAVE_CRAWLER(7787, 10), BANSHEE(1612, 15), CAVE_SLIME(1831, 17), ROCKSLUG(1631, 20), DESERT_LIZARD(2804, 22), COCKATRICE(1620, 25), PYREFIED(1633, 30), MOGRE(114, 32), HARPIE_BUG_SWARM(3153, 33), WALL_BEAST(7823, 35), KILLERWATT(3201, 37), MOLANISK(5751, 39), TERROR_DOG(5417, 40), BASILISK(1616, 40), FEVER_SPIDER(2850, 42), INFERNAL_MAGE(1643, 45), BRINE_RAT(3707, 47), BLOODVELD(1618, 50), JELLY(1637, 52), TUROTH(1623, 55), WARPED_TERRORBIRD(6285, 56), WARPED_TORTOISE(6296, 56), MUTATED_ZYGOMITE(3346, 57), MUTATED_ZYGOMITE2(3347, 57), CAVE_HORROR(4353, 58), ABERRANT_SPECTRE(1604, 60), RUM_PUMPED_CRAB(13603, 61), SPIRITUAL_RANGER(6256, 63), DUST_DEVIL(1624, 65), SPIRITUAL_WARRIOR(6255, 68), KURASK(1608, 70), SKELETAL_WYVERN(3068, 72), JUNGLE_STRYKEWYRM(9467, 73), GARGOYLE(1610, 75), DESERT_STRYKEWYRM(9465, 77), AQUANITE(9172, 78), NECHRYAEL(1613, 80), JADINKO_BABY(13820, 80), SPIRITUAL_MAGE(6221, 83), SPIRITUAL_MAGE2(6231, 83), SPIRITUAL_MAGE3(6257, 83), SPIRITUAL_MAGE4(6278, 83), ABYSSAL_DEMON(1615, 85), JADINKO_GUARD(13821, 86), GRIFOLAPINE(14688, 88), DARK_BEAST(2783, 90), JADINKO_MALE(13822, 91), ICE_STRYKEWYRM(9463, 93), GANODERMIC_BEAST(14696, 95); private static final Map monsters = new HashMap<>(); public static SlayerMonsters forId(int id) { return monsters.get(NPCDefinitions.getDefs(id).getName()); } static { for (SlayerMonsters monster : SlayerMonsters.values()) monsters.put(NPCDefinitions.getDefs(monster.id).getName(), monster); } private final int id; private final int req; private SlayerMonsters(int id, int req) { this.id = id; this.req = req; } public int getId() { return id; } public int getRequirement() { return req; } }" "package com.rs.game.content.skills.slayer; public class SlayerTaskManager { private TaskMonster lastMonster = TaskMonster.ABYSSAL_DEMONS; private Task task; private int killsLeft = 0; public Master getMaster() { return task == null ? null : task.getMaster(); } public Task getTask() { return task; } public int getTaskMonstersLeft() { return killsLeft; } public void setTask(Task task) { this.task = task; } public void removeTask() { if (task != null) lastMonster = task.getMonster(); setTask(null); killsLeft = 0; } public void setMonstersLeft(int i) { killsLeft = i; } public boolean isOnTaskAgainst(NPC npc) { if (task != null) { String npcName = npc.getDefinitions().getName().toLowerCase(); for (String slayable : task.getMonster().getMonsterNames()) if (slayable != null) if ((npcName.startsWith("" "") && npcName.contains(slayable.replace("" "", """"))) || npcName.contains(slayable)) return true; } return false; } public void sendKill(Player player, NPC n) { player.getSkills().addXp(Constants.SLAYER, (double) n.getCombatDefinitions().getHitpoints() / 10); killsLeft--; if (killsLeft % 10 == 0 && killsLeft != 0) player.sendMessage(""You're doing great, only "" + killsLeft + "" "" + getTask().getMonster().getName() + "" left to slay.""); if (killsLeft <= 0) { player.consecutiveTasks++; int amount = 0; if (player.consecutiveTasks != 0) { if (player.consecutiveTasks % 50 == 0) amount = player.getSlayer().getMaster().getPoints50(); else if (player.consecutiveTasks % 10 == 0) amount = player.getSlayer().getMaster().getPoints10(); else amount = player.getSlayer().getMaster().getPoints(); } else amount = player.getSlayer().getMaster().getPoints(); player.addSlayerPoints(amount); player.sendMessage(""You have completed "" + player.consecutiveTasks + "" tasks in a row and receive ""+amount+"" slayer points!""); player.sendMessage(""You have finished your slayer task, talk to a slayer master for a new one.""); player.incrementCount(""Slayer tasks completed""); player.jingle(61); removeTask(); player.updateSlayerTask(); } } public String getTaskString() { if (task == null) return ""You need something new to hunt; return to a Slayer master.""; return ""Your current assignment is ""+task.getMonster().getName()+""; only ""+killsLeft+"" more to go.""; } public void speakToMaster(Player player, Master master) { if (master == null) { if (player.hasSlayerTask()) player.startConversation(new EnchantedGemD(player, player.getSlayer().getMaster())); else player.sendMessage(""You have no task currently.""); } else player.startConversation(new SlayerMasterD(player, master)); } public void generateNewTask(Player player, Master master) { if (player.hasSlayerTask()) { player.sendMessage(""You are trying to get a task with a task already in progress.""); return; } ArrayList possibleTasks = new ArrayList<>(); for (Task task : Task.values()) { if ((task.getMaster() != master) || player.blockedTaskContains(task.getMonster()) || lastMonster == task.getMonster() || (player.getSkills().getLevelForXp(Constants.SLAYER) < task.getMonster().getLevel())) continue; if (task.getMonster().getQuestReq() != null && !player.isQuestComplete(task.getMonster().getQuestReq())) continue; if ((task.getMonster() == TaskMonster.AQUANITES && !player.aquanitesUnlocked()) || (task.getMonster() == TaskMonster.CYCLOPES && !((player.getSkills().getLevelForXp(Constants.ATTACK) + player.getSkills().getLevelForXp(Constants.STRENGTH)) >= 130))) continue; for (int i = 0;i < task.getWeighting();i++) possibleTasks.add(task); } if (possibleTasks.size() <= 0) { player.sendMessage(""Strange problem. No task available lol.""); return; } Collections.shuffle(possibleTasks); Task chosenTask = possibleTasks.get(Utils.random(possibleTasks.size()-1)); setTask(chosenTask); player.updateSlayerTask(); killsLeft = Utils.random(chosenTask.getMin(), chosenTask.getMax()); } public void getTaskFrom(Player player, final Master master) { if (player.hasSlayerTask()) { if ((master == Master.Turael) && (!player.getSlayer().getTask().getMaster().name().contains(""Turael""))) { player.sendOptionDialogue(""You already have a task, would you like me to assign you something easier?"", ops -> { ops.add(""Yes, please give me an easier task, "" + master.name(), () -> { player.consecutiveTasks = 0; player.getSlayer().removeTask(); player.getSlayer().generateNewTask(player, master); player.updateSlayerTask(); player.npcDialogue(master.npcId, HeadE.CHEERFUL_EXPOSITION, ""You're doing okay, I suppose. Your new task is to kill "" + player.getSlayer().getTaskMonstersLeft() + "" "" + player.getSlayer().getTask().getMonster().getName()); }); ops.add(""No, not now.""); }); } else player.npcDialogue(master.npcId, HeadE.CHEERFUL_EXPOSITION, ""You already have a task of "" + player.getSlayer().getTask().getMonster().getName() + """" + (master == getMaster() ? """" : ("" from ""+ player.getSlayer().getTask().getMaster().name())) + "".""); } else { if (player.getSkills().getLevelForXp(Constants.SLAYER) < master.reqSlayerLevel || player.getSkills().getCombatLevelWithSummoning() < master.requiredCombatLevel) { player.npcDialogue(master.npcId, HeadE.CHEERFUL_EXPOSITION, ""You are not yet experienced enough to recieve my tasks. Come back when you're stronger.""); return; } player.sendOptionDialogue(""Get a task from "" + master.name()+""?"", ops -> { ops.add(""Yes, give me a new task from "" + master.name(), () -> { player.getSlayer().generateNewTask(player, master); player.npcDialogue(master.npcId, HeadE.CHEERFUL_EXPOSITION, ""You're doing okay, I suppose. Your new task is to kill "" + player.getSlayer().getTaskMonstersLeft() + "" "" + player.getSlayer().getTask().getMonster().getName()); }); ops.add(""No, not now.""); }); } } public void openShop(Player player, Master master) { switch(master) { case Turael: ShopsHandler.openShop(player, ""turaels_slayer_equipment""); break; case Mazchna: ShopsHandler.openShop(player, ""mazchnas_slayer_equipment""); break; case Vannaka: ShopsHandler.openShop(player, ""vannakas_slayer_equipment""); break; case Chaeldar: ShopsHandler.openShop(player, ""chaeldars_slayer_equipment""); break; case Sumona: ShopsHandler.openShop(player, ""sumonas_slayer_equipment""); break; case Duradel: ShopsHandler.openShop(player, ""duradels_slayer_equipment""); break; case Kuradal: ShopsHandler.openShop(player, ""kuradals_slayer_equipment""); break; default: break; } } }" "package com.rs.game.content.skills.slayer; public enum Task { BANSHEES_T(Master.Turael, TaskMonster.BANSHEES, 30, 15, 50), BATS_T(Master.Turael, TaskMonster.BATS, 10, 15, 50), BEARS_T(Master.Turael, TaskMonster.BEARS, 10, 15, 50), BIRDS_T(Master.Turael, TaskMonster.BIRDS, 10, 15, 50), CAVE_BUGS_T(Master.Turael, TaskMonster.CAVE_BUGS, 10, 15, 50), CAVE_SLIMES_T(Master.Turael, TaskMonster.CAVE_SLIMES, 30, 15, 50), COWS_T(Master.Turael, TaskMonster.COWS, 10, 15, 50), CRAWLING_HANDS_T(Master.Turael, TaskMonster.CRAWLING_HANDS, 30, 15, 50), DESERT_LIZARDS_T(Master.Turael, TaskMonster.DESERT_LIZARDS, 30, 15, 50), DOGS_T(Master.Turael, TaskMonster.DOGS, 15, 15, 50), DWARVES_T(Master.Turael, TaskMonster.DWARVES, 10, 15, 50), GHOSTS_T(Master.Turael, TaskMonster.GHOSTS, 15, 15, 50), GOBLINS_T(Master.Turael, TaskMonster.GOBLINS, 10, 15, 50), GROTWORMS_T(Master.Turael, TaskMonster.GROTWORMS, 15, 15, 30), ICEFIENDS_T(Master.Turael, TaskMonster.ICEFIENDS, 10, 10, 20), MINOTAURS_T(Master.Turael, TaskMonster.MINOTAURS, 10, 15, 50), MONKEYS_T(Master.Turael, TaskMonster.MONKEYS, 10, 15, 50), SCORPIONS_T(Master.Turael, TaskMonster.SCORPIONS, 10, 15, 50), SKELETONS_T(Master.Turael, TaskMonster.SKELETONS, 15, 15, 50), SPIDERS_T(Master.Turael, TaskMonster.SPIDERS, 10, 15, 50), WOLVES_T(Master.Turael, TaskMonster.WOLVES, 15, 15, 50), ZOMBIES_T(Master.Turael, TaskMonster.ZOMBIES, 10, 15, 50), BANSHEES_M(Master.Mazchna, TaskMonster.BANSHEES, 20, 40, 70), BATS_M(Master.Mazchna, TaskMonster.BATS, 10, 40, 70), BEARS_M(Master.Mazchna, TaskMonster.BEARS, 10, 40, 70), CATABLEPON_M(Master.Mazchna, TaskMonster.CATABLEPON, 10, 40, 70), CAVE_CRAWLERS_M(Master.Mazchna, TaskMonster.CAVE_CRAWLERS, 20, 40, 70), CAVE_SLIMES_M(Master.Mazchna, TaskMonster.CAVE_SLIMES, 10, 40, 70), COCKATRICE_M(Master.Mazchna, TaskMonster.COCKATRICE, 20, 40, 70), CRAWLING_HANDS_M(Master.Mazchna, TaskMonster.CRAWLING_HANDS, 20, 40, 70), CYCLOPES_M(Master.Mazchna, TaskMonster.CYCLOPES, 10, 30, 60), DESERT_LIZARDS_M(Master.Mazchna, TaskMonster.DESERT_LIZARDS, 10, 40, 70), DOGS_M(Master.Mazchna, TaskMonster.DOGS, 10, 40, 70), FLESHCRAWLERS_M(Master.Mazchna, TaskMonster.FLESHCRAWLERS, 10, 40, 70), GHOULS_M(Master.Mazchna, TaskMonster.GHOULS, 10, 40, 70), GHOSTS_M(Master.Mazchna, TaskMonster.GHOSTS, 10, 40, 70), GROTWORMS_M(Master.Mazchna, TaskMonster.GROTWORMS, 10, 20, 40), HILL_GIANTS_M(Master.Mazchna, TaskMonster.HILL_GIANTS, 10, 40, 70), HOBGOBLINS_M(Master.Mazchna, TaskMonster.HOBGOBLINS, 10, 40, 70), ICE_WARRIORS_M(Master.Mazchna, TaskMonster.ICE_WARRIORS, 10, 40, 70), KALPHITE_M(Master.Mazchna, TaskMonster.KALPHITE, 10, 40, 70), PYREFIENDS_M(Master.Mazchna, TaskMonster.PYREFIENDS, 20, 40, 70), ROCKSLUGS_M(Master.Mazchna, TaskMonster.ROCKSLUGS, 15, 40, 70), SKELETONS_M(Master.Mazchna, TaskMonster.SKELETONS, 10, 40, 70), VAMPYRES_M(Master.Mazchna, TaskMonster.VAMPYRES, 10, 40, 70), WOLVES_M(Master.Mazchna, TaskMonster.WOLVES, 10, 40, 70), ZOMBIES_M(Master.Mazchna, TaskMonster.ZOMBIES, 10, 40, 70), ABERRANT_SPECTRES_V(Master.Vannaka, TaskMonster.ABERRANT_SPECTRES, 25, 60, 120), ANKOU_V(Master.Vannaka, TaskMonster.ANKOU, 10, 60, 120), BANSHEES_V(Master.Vannaka, TaskMonster.BANSHEES, 15, 60, 120), BASILISKS_V(Master.Vannaka, TaskMonster.BASILISKS, 10, 60, 120), BLOODVELD_V(Master.Vannaka, TaskMonster.BLOODVELD, 20, 60, 120), BRINE_RATS_V(Master.Vannaka, TaskMonster.BRINE_RATS, 20, 60, 120), COCKATRICE_V(Master.Vannaka, TaskMonster.COCKATRICE, 10, 60, 120), CROCODILES_V(Master.Vannaka, TaskMonster.CROCODILES, 10, 30, 60), CYCLOPES_V(Master.Vannaka, TaskMonster.CYCLOPES, 10, 60, 120), DUST_DEVILS_V(Master.Vannaka, TaskMonster.DUST_DEVILS, 25, 60, 120), EARTH_WARRIORS_V(Master.Vannaka, TaskMonster.EARTH_WARRIORS, 15, 30, 60), GHOULS_V(Master.Vannaka, TaskMonster.GHOULS, 10, 60, 120), GREEN_DRAGONS_V(Master.Vannaka, TaskMonster.GREEN_DRAGONS, 10, 30, 60), GROTWORMS_V(Master.Vannaka, TaskMonster.GROTWORMS, 15, 60, 120), HARPIE_BUG_SWARMS_V(Master.Vannaka, TaskMonster.HARPIE_BUG_SWARMS, 20, 60, 120), HILL_GIANTS_V(Master.Vannaka, TaskMonster.HILL_GIANTS, 10, 60, 120), ICE_GIANTS_V(Master.Vannaka, TaskMonster.ICE_GIANTS, 10, 60, 120), ICE_WARRIORS_V(Master.Vannaka, TaskMonster.ICE_WARRIORS, 10, 60, 120), INFERNAL_MAGES_V(Master.Vannaka, TaskMonster.INFERNAL_MAGES, 10, 60, 120), JELLIES_V(Master.Vannaka, TaskMonster.JELLIES, 20, 60, 120), JUNGLE_HORRORS_V(Master.Vannaka, TaskMonster.JUNGLE_HORRORS, 10, 60, 120), KILLERWATTS_V(Master.Vannaka, TaskMonster.KILLERWATTS, 20, 60, 120), LESSER_DEMONS_V(Master.Vannaka, TaskMonster.LESSER_DEMONS, 10, 60, 120), MOLANISKS_V(Master.Vannaka, TaskMonster.MOLANISKS, 10, 60, 120), MOSS_GIANTS_V(Master.Vannaka, TaskMonster.MOSS_GIANTS, 10, 60, 120), OGRES_V(Master.Vannaka, TaskMonster.OGRES, 10, 60, 120), OTHERWORLDLY_BEINGS_V(Master.Vannaka, TaskMonster.OTHERWORLDLY_BEINGS, 10, 60, 120), PYREFIENDS_V(Master.Vannaka, TaskMonster.PYREFIENDS, 10, 60, 120), SHADES_V(Master.Vannaka, TaskMonster.SHADES, 10, 60, 120), SHADOW_WARRIORS_V(Master.Vannaka, TaskMonster.SHADOW_WARRIORS, 10, 60, 120), TROLLS_V(Master.Vannaka, TaskMonster.TROLLS, 10, 60, 120), TUROTH_V(Master.Vannaka, TaskMonster.TUROTH, 20, 60, 120), VAMPYRES_V(Master.Vannaka, TaskMonster.VAMPYRES, 15, 60, 120), WEREWOLVES_V(Master.Vannaka, TaskMonster.WEREWOLVES, 10, 60, 120), ABERRANT_SPECTRES_C(Master.Chaeldar, TaskMonster.ABERRANT_SPECTRES, 15, 110, 170), BANSHEES_C(Master.Chaeldar, TaskMonster.BANSHEES, 5, 110, 170), BASILISKS_C(Master.Chaeldar, TaskMonster.BASILISKS, 15, 110, 170), BLOODVELD_C(Master.Chaeldar, TaskMonster.BLOODVELD, 15, 110, 170), BLUE_DRAGONS_C(Master.Chaeldar, TaskMonster.BLUE_DRAGONS, 10, 110, 170), BRINE_RATS_C(Master.Chaeldar, TaskMonster.BRINE_RATS, 10, 110, 170), BRONZE_DRAGONS_C(Master.Chaeldar, TaskMonster.BRONZE_DRAGONS, 10, 30, 60), CAVE_CRAWLERS_C(Master.Chaeldar, TaskMonster.CAVE_CRAWLERS, 5, 110, 170), CAVE_HORRORS_C(Master.Chaeldar, TaskMonster.CAVE_HORRORS, 15, 110, 170), CRAWLING_HANDS_C(Master.Chaeldar, TaskMonster.CRAWLING_HANDS, 5, 110, 170), DAGANNOTH_C(Master.Chaeldar, TaskMonster.DAGANNOTH, 10, 110, 170), DUST_DEVILS_C(Master.Chaeldar, TaskMonster.DUST_DEVILS, 15, 110, 170), ELVES_C(Master.Chaeldar, TaskMonster.ELVES, 10, 60, 150), FEVER_SPIDERS_C(Master.Chaeldar, TaskMonster.FEVER_SPIDERS, 10, 110, 170), FIRE_GIANTS_C(Master.Chaeldar, TaskMonster.FIRE_GIANTS, 10, 110, 170), FUNGAL_MAGI_C(Master.Chaeldar, TaskMonster.FUNGAL_MAGI, 10, 83, 136), GARGOYLES_C(Master.Chaeldar, TaskMonster.GARGOYLES, 15, 110, 170), GRIFOLAPINES_C(Master.Chaeldar, TaskMonster.GRIFOLAPINES, 8, 60, 100), GRIFOLAROOS_C(Master.Chaeldar, TaskMonster.GRIFOLAROOS, 8, 60, 100), GROTWORMS_C(Master.Chaeldar, TaskMonster.GROTWORMS, 15, 70, 100), HARPIE_BUG_SWARMS_C(Master.Chaeldar, TaskMonster.HARPIE_BUG_SWARMS, 20, 110, 170), JUNGLE_STRYKEWYRMS_C(Master.Chaeldar, TaskMonster.JUNGLE_STRYKEWYRMS, 12, 80, 110), INFERNAL_MAGES_C(Master.Chaeldar, TaskMonster.INFERNAL_MAGES, 10, 110, 170), JELLIES_C(Master.Chaeldar, TaskMonster.JELLIES, 15, 110, 170), JUNGLE_HORRORS_C(Master.Chaeldar, TaskMonster.JUNGLE_HORRORS, 15, 110, 170), KALPHITE_C(Master.Chaeldar, TaskMonster.KALPHITE, 10, 110, 170), KURASK_C(Master.Chaeldar, TaskMonster.KURASK, 15, 110, 170), LESSER_DEMONS_C(Master.Chaeldar, TaskMonster.LESSER_DEMONS, 10, 110, 170), TROLLS_C(Master.Chaeldar, TaskMonster.TROLLS, 10, 110, 170), TUROTH_C(Master.Chaeldar, TaskMonster.TUROTH, 15, 110, 170), VYREWATCH_C(Master.Chaeldar, TaskMonster.VYREWATCH, 10, 89, 106), WARPED_TORTOISES_C(Master.Chaeldar, TaskMonster.WARPED_TORTOISES, 10, 110, 170), ABERRANT_SPECTRES_S(Master.Sumona, TaskMonster.ABERRANT_SPECTRES, 15, 120, 185), ABYSSAL_DEMONS_S(Master.Sumona, TaskMonster.ABYSSAL_DEMONS, 10, 120, 185), AQUANITES_S(Master.Sumona, TaskMonster.AQUANITES, 10, 120, 185), BANSHEES_S(Master.Sumona, TaskMonster.BANSHEES, 15, 120, 185), BASILISKS_S(Master.Sumona, TaskMonster.BASILISKS, 15, 120, 185), BLACK_DEMONS_S(Master.Sumona, TaskMonster.BLACK_DEMONS, 10, 119, 185), BLOODVELD_S(Master.Sumona, TaskMonster.BLOODVELD, 10, 120, 185), BLUE_DRAGONS_S(Master.Sumona, TaskMonster.BLUE_DRAGONS, 8, 120, 189), CAVE_CRAWLERS_S(Master.Sumona, TaskMonster.CAVE_CRAWLERS, 15, 120, 185), CAVE_HORRORS_S(Master.Sumona, TaskMonster.CAVE_HORRORS, 15, 120, 185), DAGANNOTH_S(Master.Sumona, TaskMonster.DAGANNOTH, 10, 120, 192), DESERT_STRYKEWYRMS_S(Master.Sumona, TaskMonster.DESERT_STRYKEWYRMS, 14, 90, 110), DUST_DEVILS_S(Master.Sumona, TaskMonster.DUST_DEVILS, 15, 120, 185), ELVES_S(Master.Sumona, TaskMonster.ELVES, 10, 60, 90), FIRE_GIANTS_S(Master.Sumona, TaskMonster.FIRE_GIANTS, 10, 120, 185), FUNGAL_MAGI_S(Master.Sumona, TaskMonster.FUNGAL_MAGI, 10, 90, 150), GARGOYLES_S(Master.Sumona, TaskMonster.GARGOYLES, 10, 120, 195), GREATER_DEMONS_S(Master.Sumona, TaskMonster.GREATER_DEMONS, 10, 120, 185), GRIFOLAPINES_S(Master.Sumona, TaskMonster.GRIFOLAPINES, 8, 55, 75), GRIFOLAROOS_S(Master.Sumona, TaskMonster.GRIFOLAROOS, 8, 55, 75), GROTWORMS_S(Master.Sumona, TaskMonster.GROTWORMS, 15, 70, 115), HELLHOUNDS_S(Master.Sumona, TaskMonster.HELLHOUNDS, 10, 120, 185), IRON_DRAGONS_S(Master.Sumona, TaskMonster.IRON_DRAGONS, 7, 30, 85), JUNGLE_STRYKEWYRMS_S(Master.Sumona, TaskMonster.JUNGLE_STRYKEWYRMS, 12, 90, 120), KALPHITE_S(Master.Sumona, TaskMonster.KALPHITE, 10, 120, 189), KURASK_S(Master.Sumona, TaskMonster.KURASK, 15, 120, 185), MUTATED_JADINKOS_S(Master.Sumona, TaskMonster.MUTATED_JADINKOS, 10, 80, 130), NECHRYAEL_S(Master.Sumona, TaskMonster.NECHRYAEL, 10, 120, 185), RED_DRAGONS_S(Master.Sumona, TaskMonster.RED_DRAGONS, 5, 30, 79), SPIRITUAL_MAGES_S(Master.Sumona, TaskMonster.SPIRITUAL_MAGES, 10, 120, 185), SPIRITUAL_WARRIORS_S(Master.Sumona, TaskMonster.SPIRITUAL_WARRIORS, 10, 120, 185), TROLLS_S(Master.Sumona, TaskMonster.TROLLS, 10, 120, 191), TUROTH_S(Master.Sumona, TaskMonster.TUROTH, 15, 120, 185), VYREWATCH_S(Master.Sumona, TaskMonster.VYREWATCH, 10, 96, 105), WARPED_TORTOISES_S(Master.Sumona, TaskMonster.WARPED_TORTOISES, 10, 120, 185), ABERRANT_SPECTRES_D(Master.Duradel, TaskMonster.ABERRANT_SPECTRES, 10, 130, 200), ABYSSAL_DEMONS_D(Master.Duradel, TaskMonster.ABYSSAL_DEMONS, 15, 130, 200), AQUANITES_D(Master.Duradel, TaskMonster.AQUANITES, 9, 130, 200), BLACK_DEMONS_D(Master.Duradel, TaskMonster.BLACK_DEMONS, 10, 130, 200), BLACK_DRAGONS_D(Master.Duradel, TaskMonster.BLACK_DRAGONS, 9, 40, 80), BLOODVELD_D(Master.Duradel, TaskMonster.BLOODVELD, 20, 130, 200), DAGANNOTH_D(Master.Duradel, TaskMonster.DAGANNOTH, 10, 130, 200), DARK_BEASTS_D(Master.Duradel, TaskMonster.DARK_BEASTS, 15, 130, 200), DESERT_STRYKEWYRMS_D(Master.Duradel, TaskMonster.DESERT_STRYKEWYRMS, 11, 90, 140), DUST_DEVILS_D(Master.Duradel, TaskMonster.DUST_DEVILS, 10, 130, 200), FIRE_GIANTS_D(Master.Duradel, TaskMonster.FIRE_GIANTS, 10, 130, 200), FUNGAL_MAGI_D(Master.Duradel, TaskMonster.FUNGAL_MAGI, 8, 100, 200), GANODERMIC_CREATURES_D(Master.Duradel, TaskMonster.GANODERMIC_CREATURES, 6, 55, 70), GARGOYLES_D(Master.Duradel, TaskMonster.GARGOYLES, 10, 130, 200), GORAKS_D(Master.Duradel, TaskMonster.GORAKS, 5, 40, 80), GREATER_DEMONS_D(Master.Duradel, TaskMonster.GREATER_DEMONS, 11, 130, 200), GRIFOLAPINES_D(Master.Duradel, TaskMonster.GRIFOLAPINES, 10, 65, 80), GRIFOLAROOS_D(Master.Duradel, TaskMonster.GRIFOLAROOS, 10, 65, 80), GROTWORMS_D(Master.Duradel, TaskMonster.GROTWORMS, 10, 80, 120), HELLHOUNDS_D(Master.Duradel, TaskMonster.HELLHOUNDS, 9, 130, 200), ICE_STRYKEWYRMS_D(Master.Duradel, TaskMonster.ICE_STRYKEWYRMS, 8, 100, 200), IRON_DRAGONS_D(Master.Duradel, TaskMonster.IRON_DRAGONS, 9, 40, 80), JUNGLE_STRYKEWYRMS_D(Master.Duradel, TaskMonster.JUNGLE_STRYKEWYRMS, 10, 90, 120), KALPHITE_D(Master.Duradel, TaskMonster.KALPHITE, 10, 170, 250), MITHRIL_DRAGONS_D(Master.Duradel, TaskMonster.MITHRIL_DRAGONS, 7, 4, 11), MUTATED_JADINKOS_D(Master.Duradel, TaskMonster.MUTATED_JADINKOS, 8, 120, 200), NECHRYAEL_D(Master.Duradel, TaskMonster.NECHRYAEL, 10, 130, 200), SKELETAL_WYVERNS_D(Master.Duradel, TaskMonster.SKELETAL_WYVERNS, 5, 40, 80), SPIRITUAL_MAGES_D(Master.Duradel, TaskMonster.SPIRITUAL_MAGES, 10, 130, 200), STEEL_DRAGONS_D(Master.Duradel, TaskMonster.STEEL_DRAGONS, 7, 40, 80), SUQAHS_D(Master.Duradel, TaskMonster.SUQAHS, 5, 40, 80), VYREWATCH_D(Master.Duradel, TaskMonster.VYREWATCH, 8, 98, 118), WARPED_TERRORBIRDS_D(Master.Duradel, TaskMonster.WARPED_TERRORBIRDS, 9, 130, 200), WATERFIENDS_D(Master.Duradel, TaskMonster.WATERFIENDS, 10, 130, 200), ABERRANT_SPECTRES_K(Master.Kuradal, TaskMonster.ABERRANT_SPECTRES, 10, 140, 250), ABYSSAL_DEMONS_K(Master.Kuradal, TaskMonster.ABYSSAL_DEMONS, 12, 150, 250), AQUANITES_K(Master.Kuradal, TaskMonster.AQUANITES, 10, 120, 240), BLACK_DEMONS_K(Master.Kuradal, TaskMonster.BLACK_DEMONS, 10, 190, 250), BLACK_DRAGONS_K(Master.Kuradal, TaskMonster.BLACK_DRAGONS, 5, 40, 90), BLOODVELD_K(Master.Kuradal, TaskMonster.BLOODVELD, 10, 180, 250), BLUE_DRAGONS_K(Master.Kuradal, TaskMonster.BLUE_DRAGONS, 7, 120, 200), DAGANNOTH_K(Master.Kuradal, TaskMonster.DAGANNOTH, 10, 170, 240), DARK_BEASTS_K(Master.Kuradal, TaskMonster.DARK_BEASTS, 12, 150, 250), DESERT_STRYKEWYRMS_K(Master.Kuradal, TaskMonster.DESERT_STRYKEWYRMS, 9, 90, 160), DUST_DEVILS_K(Master.Kuradal, TaskMonster.DUST_DEVILS, 10, 150, 250), FIRE_GIANTS_K(Master.Kuradal, TaskMonster.FIRE_GIANTS, 10, 170, 250), GANODERMIC_CREATURES_K(Master.Kuradal, TaskMonster.GANODERMIC_CREATURES, 7, 70, 90), GARGOYLES_K(Master.Kuradal, TaskMonster.GARGOYLES, 12, 150, 250), GREATER_DEMONS_K(Master.Kuradal, TaskMonster.GREATER_DEMONS, 11, 150, 258), GRIFOLAPINES_K(Master.Kuradal, TaskMonster.GRIFOLAPINES, 8, 65, 80), GRIFOLAROOS_K(Master.Kuradal, TaskMonster.GRIFOLAROOS, 8, 65, 80), GROTWORMS_K(Master.Kuradal, TaskMonster.GROTWORMS, 10, 80, 160), HELLHOUNDS_K(Master.Kuradal, TaskMonster.HELLHOUNDS, 10, 130, 230), ICE_STRYKEWYRMS_K(Master.Kuradal, TaskMonster.ICE_STRYKEWYRMS, 12, 100, 220), IRON_DRAGONS_K(Master.Kuradal, TaskMonster.IRON_DRAGONS, 9, 40, 120), JUNGLE_STRYKEWYRMS_K(Master.Kuradal, TaskMonster.JUNGLE_STRYKEWYRMS, 8, 90, 130), KALPHITE_K(Master.Kuradal, TaskMonster.KALPHITE, 5, 170, 250), LIVING_ROCK_CREATURES_K(Master.Kuradal, TaskMonster.LIVING_ROCK_CREATURES, 10, 110, 185), MITHRIL_DRAGONS_K(Master.Kuradal, TaskMonster.MITHRIL_DRAGONS, 8, 20, 35), MUTATED_JADINKOS_K(Master.Kuradal, TaskMonster.MUTATED_JADINKOS, 8, 160, 220), NECHRYAEL_K(Master.Kuradal, TaskMonster.NECHRYAEL, 10, 140, 220), SKELETAL_WYVERNS_K(Master.Kuradal, TaskMonster.SKELETAL_WYVERNS, 5, 40, 90), SPIRITUAL_MAGES_K(Master.Kuradal, TaskMonster.SPIRITUAL_MAGES, 10, 150, 240), STEEL_DRAGONS_K(Master.Kuradal, TaskMonster.STEEL_DRAGONS, 9, 40, 100), SUQAHS_K(Master.Kuradal, TaskMonster.SUQAHS, 5, 50, 100), VOLCANIC_CREATURES_K(Master.Kuradal, TaskMonster.VOLCANIC_CREATURES, 7, 70, 110), VYREWATCH_K(Master.Kuradal, TaskMonster.VYREWATCH, 8, 90, 130), WARPED_TORTOISES_K(Master.Kuradal, TaskMonster.WARPED_TORTOISES, 8, 150, 240), WATERFIENDS_K(Master.Kuradal, TaskMonster.WATERFIENDS, 9, 170, 250); private final Master master; private final TaskMonster creature; private final int[] minMax; private final int weighting; private Task(Master master, TaskMonster creature, int weighting, int min, int max) { this.master = master; this.creature = creature; minMax = new int[] { min, max }; this.weighting = weighting; } public int getMin() { return minMax[0]; } public int getMax() { return minMax[1]; } public int getWeighting() { return weighting; } public TaskMonster getMonster() { return creature; } public Master getMaster() { return master; } }" "package com.rs.game.content.skills.slayer; public enum TaskMonster { MONKEYS(1, 1, ""monkey""), GOBLINS(2, 1, ""goblin""), SPIDERS(4, 1, ""spider""), BIRDS(5, 1, ""chicken"", ""bird""), COWS(6, 1, ""cow""), SCORPIONS(7, 1, ""scorpion""), BATS(8, 1, ""bat"", "" bat""), WOLVES(9, 1, ""wolf""), ZOMBIES(10, 1, ""zombie""), SKELETONS(11, 1, ""skeleton""), GHOSTS(12, 1, ""ghost"", ""revenant""), BEARS(13, 1, "" bear"", ""bear cub""), HILL_GIANTS(14, 1, ""hill giant""), ICE_GIANTS(15, 1, ""ice giant""), FIRE_GIANTS(16, 1, ""fire giant""), MOSS_GIANTS(17, 1, ""moss giant""), TROLLS(18, 1, ""troll""), ICE_WARRIORS(19, 1, ""ice warrior""), OGRES(20, 1, ""ogre""), HOBGOBLINS(21, 1, ""hobgoblin""), DOGS(22, 1, ""jackal"", "" dog""), GHOULS(23, 1, ""ghoul""), GREEN_DRAGONS(24, 1, ""green dragon""), BLUE_DRAGONS(25, 1, ""blue dragon""), RED_DRAGONS(26, 1, ""red dragon""), BLACK_DRAGONS(27, 1, ""black dragon""), LESSER_DEMONS(28, 1, ""lesser demon""), GREATER_DEMONS(29, 1, ""greater demon"", ""tsutsaroth"", ""tstanon""), BLACK_DEMONS(30, 1, ""black demon"", ""kreeyath""), HELLHOUNDS(31, 1, ""hellhound""), SHADOW_WARRIORS(32, 1, Quest.LEGENDS_QUEST, ""shadow warrior""), WEREWOLVES(33, 1, Quest.PRIEST_IN_PERIL, ""werewolf"", ""boris"", ""eduard"", ""galina"", ""georgy"", ""imre"", ""irina"", ""jeroen"", ""joseph"", ""ksenia"", ""liliya"", ""lev"", ""milla"", ""nikita"", ""nikolai"", ""sofiya"", ""svetlana"", ""vera"", ""yadviga"", ""yuri"", ""zoja""), VAMPYRES(34, 1, Quest.PRIEST_IN_PERIL, ""vampyre""), DAGANNOTH(35, 1, ""dagannoth""), TUROTH(36, 55, ""turoth""), CAVE_CRAWLERS(37, 10, ""cave crawler""), BANSHEES(38, 15, Quest.PRIEST_IN_PERIL, ""banshee""), CRAWLING_HANDS(39, 5, "" hand""), INFERNAL_MAGES(40, 45, ""infernal mage""), ABERRANT_SPECTRES(41, 60, Quest.PRIEST_IN_PERIL, ""aberrant spectre""), ABYSSAL_DEMONS(42, 85, ""abyssal demon""), BASILISKS(43, 40, ""basilisk""), COCKATRICE(44, 25, ""cockatrice""), KURASK(45, 70, ""kurask""), GARGOYLES(46, 75, ""gargoyle""), PYREFIENDS(47, 30, ""pyrefiend""), BLOODVELD(48, 50, ""bloodveld""), DUST_DEVILS(49, 65, ""dust devil""), JELLIES(50, 52, ""jelly""), ROCKSLUGS(51, 20, ""rockslug""), NECHRYAEL(52, 80, ""nechryael""), KALPHITE(53, 1, ""kalphite""), EARTH_WARRIORS(54, 1, ""earth warrior""), OTHERWORLDLY_BEINGS(55, 1, Quest.LOST_CITY, ""otherworldly being""), ELVES(56, 1, Quest.MOURNINGS_ENDS_PART_I, ""elf""), DWARVES(57, 1, ""dwarf""), BRONZE_DRAGONS(58, 1, ""bronze dragon""), IRON_DRAGONS(59, 1, ""iron dragon""), STEEL_DRAGONS(60, 1, ""steel dragon""), //61 WALL_BEASTS CAVE_SLIMES(62, 17, ""cave slime""), CAVE_BUGS(63, 7, ""cave bug""), SHADES(64, 1, ""shade"", ""loar shadow""), CROCODILES(65, 1, ""crocodile""), DARK_BEASTS(66, 90, ""dark beast""), //67 MOGRES DESERT_LIZARDS(68, 22, ""lizard""), FEVER_SPIDERS(69, 42, Quest.CABIN_FEVER, ""fever spider""), HARPIE_BUG_SWARMS(70, 33, ""harpie bug swarm""), //71 SEA_SNAKES SKELETAL_WYVERNS(72, 72, ""skeletal wyvern""), KILLERWATTS(73, 37, ""killerwatt""), //74 MUTATED_ZYGOMITES ICEFIENDS(75, 1, ""icefiend""), MINOTAURS(76, 1, ""minotaur""), FLESHCRAWLERS(77, 1, ""flesh crawler""), CATABLEPON(78, 1, ""catablepon""), ANKOU(79, 1, ""ankou""), CAVE_HORRORS(80, 58, Quest.CABIN_FEVER, ""cave horror""), JUNGLE_HORRORS(81, 1, Quest.CABIN_FEVER, ""jungle horror""), GORAKS(82, 1, Quest.FAIRY_TALE_II_CURE_A_QUEEN, ""gorak""), SUQAHS(83, 1, Quest.LUNAR_DIPLOMACY, ""suqah""), BRINE_RATS(84, 47, Quest.OLAFS_QUEST, ""brine rat""), //85 SCABARITES //86 TERROR_DOGS MOLANISKS(87, 39, ""molanisk""), WATERFIENDS(88, 1, ""waterfiend""), SPIRITUAL_WARRIORS(89, 68, ""spiritual warrior""), //90 SPIRITUAL_RANGERS SPIRITUAL_MAGES(91, 83, ""spiritual mage""), WARPED_TORTOISES(92, 56, Quest.PATH_OF_GLOUPHRIE, ""warped tortoise""), WARPED_TERRORBIRDS(93, 56, Quest.PATH_OF_GLOUPHRIE, ""warped terrorbird""), MITHRIL_DRAGONS(94, 1, ""mithril dragon""), AQUANITES(95, 78, ""aquanite""), GANODERMIC_CREATURES(96, 95, ""ganodermic""), GRIFOLAPINES(97, 88, ""grifolapine""), GRIFOLAROOS(98, 82, ""grifolaroo""), FUNGAL_MAGI(99, 1, ""fungal mage""), //100 POLYPORE_CREATURES //101 TZHAAR VOLCANIC_CREATURES(102, 1, ""tz"", ""tok-""), JUNGLE_STRYKEWYRMS(103, 73, ""jungle strykewyrm""), DESERT_STRYKEWYRMS(104, 77, ""desert strykewyrm""), ICE_STRYKEWYRMS(105, 93, ""ice strykewyrm""), LIVING_ROCK_CREATURES(106, 1, ""living rock""), //107 NOTHING CYCLOPES(108, 1, ""cyclops""), MUTATED_JADINKOS(109, 80, ""mutated jadinko""), VYREWATCH(110, 1, Quest.BRANCHES_OF_DARKMEYER, ""vyrewatch"", ""vyrelord"", ""vyrelady""), //111 GELATINOUS_ABOMINATIONS GROTWORMS(112, 1, ""grotworm""); private static final HashMap MAP = new HashMap<>(); static { for (TaskMonster creature : TaskMonster.values()) MAP.put(creature.enumId, creature); } public static TaskMonster forEnum(int enumId) { return MAP.get(enumId); } private final int enumId; private final int level; private final String[] monsterNames; private Quest questReq; private TaskMonster(int enumId, int level, Quest questReq, String... monsterNames) { this.enumId = enumId; this.level = level; this.questReq = questReq; this.monsterNames = monsterNames; } private TaskMonster(int enumId, int level, String... monsterNames) { this.enumId = enumId; this.level = level; this.monsterNames = monsterNames; } public int getEnumId() { return enumId; } public int getLevel() { return level; } public Quest getQuestReq() { return questReq; } public String[] getMonsterNames() { return monsterNames; } public String getName() { return EnumDefinitions.getEnum(1563).getStringValue(enumId); } }" "package com.rs.game.content.skills.slayer.npcs; @PluginEventHandler public class AbyssalDemon extends NPC { public AbyssalDemon(int id, Tile tile) { super(id, tile); } @Override public void processNPC() { super.processNPC(); Entity target = getCombat().getTarget(); if (target != null && WorldUtil.isInRange(target.getX(), target.getY(), target.getSize(), getX(), getY(), getSize(), 4) && Utils.random(50) == 0) sendTeleport(Utils.random(2) == 0 ? target : this); } private void sendTeleport(Entity entity) { if (entity.isLocked()) return; int entitySize = entity.getSize(); for (int c = 0; c < 10; c++) { Direction dir = Direction.values()[Utils.random(Direction.values().length)]; if (World.checkWalkStep(entity.getTile(), dir, entitySize)) { entity.setNextSpotAnim(new SpotAnim(409)); entity.tele(entity.transform(dir.dx, dir.dy, 0)); break; } } } public static NPCInstanceHandler toAbyssalDemon = new NPCInstanceHandler(new Object[] { 1615 }, AbyssalDemon::new); }" "package com.rs.game.content.skills.slayer.npcs; @PluginEventHandler public class ConditionalDeath extends NPC { private final int requiredItem; private final String deathMessage; private final boolean remove; public ConditionalDeath(int requiredItem, String deathMessage, boolean remove, int id, Tile tile) { super(id, tile); this.requiredItem = requiredItem; this.deathMessage = deathMessage; this.remove = remove; } public int getRequiredItem() { return requiredItem; } private boolean removeItem(Player player) { if (getHitpoints() < (getMaxHitpoints() * 0.1) && (player.getEquipment().getWeaponId() == requiredItem || player.getInventory().containsItem(requiredItem, 1))) { if (remove) player.getInventory().deleteItem(requiredItem, 1); return true; } return false; } public boolean useHammer(Player player) { if (removeItem(player)) { if (deathMessage != null) player.sendMessage(deathMessage); // missing emote if (getId() == 14849) player.setNextAnimation(new Animation(15845)); if (getId() == 1610) { player.setNextAnimation(new Animation(1755)); transformIntoNPC(1827); setNextAnimation(new Animation(9513)); WorldTasks.schedule(10, () -> setNPC(1610)); } setHitpoints(0); super.sendDeath(player); return true; } return false; } @Override public void sendDeath(Entity source) { if (source instanceof Player player) { if ((player.hasLearnedQuickBlows() || player.getEquipment().getWeaponId() == requiredItem || player.getEquipment().getGlovesId() == requiredItem) && useHammer(player)) return; player.sendMessage(""The "" + getName() + "" is on its last legs! Finish it quickly!""); } setHitpoints(1); } public static NPCClickHandler gargSmash = new NPCClickHandler(new Object[] {1610}, new String[]{""Smash""}, e -> { if (e.getNPC() instanceof ConditionalDeath cd) cd.useHammer(e.getPlayer()); }); public static NPCInstanceHandler toFunc = new NPCInstanceHandler(new Object[] { 1610, 1631, 1632, 2803, 2804, 2805, 2806, 2807, 2808, 14849 }, (npcId, tile) -> { if (npcId == 1631 || npcId == 1632) return new ConditionalDeath(4161, ""The rockslug shrivels and dies."", true, npcId, tile); if (npcId == 1610) return new ConditionalDeath(4162, ""The gargoyle breaks into pieces as you slam the hammer onto its head."", false, npcId, tile); if (npcId == 14849) return new ConditionalDeath(23035, null, false, npcId, tile); else return new ConditionalDeath(6696, null, true, npcId, tile); }); }" "package com.rs.game.content.skills.slayer.npcs; @PluginEventHandler public class HarpieBug extends NPC { public HarpieBug(int id, Tile tile) { super(id, tile); } @Override public void handlePreHit(Hit hit) { if (hit.getSource() instanceof Player player) { if (player.getEquipment().getShieldId() != 7053) hit.setDamage(0); } super.handlePreHit(hit); } public static NPCInstanceHandler toFunc = new NPCInstanceHandler(3153, HarpieBug::new); }" "package com.rs.game.content.skills.slayer.npcs; @PluginEventHandler public class HoleInTheWall extends NPC { private transient boolean hasGrabbed; public HoleInTheWall(int id, Tile tile) { super(id, tile); setCantFollowUnderCombat(true); setCantInteract(true); setForceAgressive(true); } @Override public void processNPC() { super.processNPC(); if (getId() == 2058) { if (!hasGrabbed) for (Entity entity : getPossibleTargets()) { if (entity == null || entity.isDead() || !withinDistance(entity.getTile(), 1)) continue; if (entity instanceof Player player) { player.resetWalkSteps(); hasGrabbed = true; if (Slayer.hasSpinyHelmet(player)) { transformIntoNPC(7823); setNextAnimation(new Animation(1805)); setCantInteract(false); player.sendMessage(""The spines on your helmet repel the beast's hand.""); return; } setNextAnimation(new Animation(1802)); player.lock(4); player.setNextAnimation(new Animation(425)); player.sendMessage(""A giant hand appears and grabs your head.""); WorldTasks.schedule(new Task() { @Override public void run() { player.applyHit(new Hit(player, Utils.getRandomInclusive(44), HitLook.TRUE_DAMAGE)); setNextAnimation(new Animation(-1)); WorldTasks.schedule(new Task() { @Override public void run() { hasGrabbed = false; } }, 20); } }, 5); } } } else if (!getCombat().process()) { setCantInteract(true); transformIntoNPC(2058); } } @Override public void sendDeath(Entity source) { final NPCCombatDefinitions defs = getCombatDefinitions(); resetWalkSteps(); getCombat().removeTarget(); setNextAnimation(null); WorldTasks.scheduleTimer(loop -> { if (loop == 0) setNextAnimation(new Animation(defs.getDeathEmote())); else if (loop >= defs.getDeathDelay()) { setNPC(2058); drop(); reset(); setLocation(getRespawnTile()); finish(); WorldTasks.schedule(8, () -> hasGrabbed = false); spawn(); return false; } return true; }); } public static NPCInstanceHandler toFunc = new NPCInstanceHandler(2058, HoleInTheWall::new); }" "package com.rs.game.content.skills.slayer.npcs; @PluginEventHandler public class Kurask extends NPC { public Kurask(int id, Tile tile) { super(id, tile); } @Override public void handlePreHit(Hit hit) { if (hit.getSource() instanceof Player player) { RangedWeapon weapon = RangedWeapon.forId(player.getEquipment().getWeaponId()); AmmoType ammo = AmmoType.forId(player.getEquipment().getAmmoId()); if (!(player.getEquipment().getWeaponId() == 13290 || player.getEquipment().getWeaponId() == 4158) && !(weapon != null && weapon.getAmmos() != null && ammo != null && (ammo == AmmoType.BROAD_ARROW || ammo == AmmoType.BROAD_TIPPED_BOLTS))) hit.setDamage(0); } super.handlePreHit(hit); } public static NPCInstanceHandler toFunc = new NPCInstanceHandler(new Object[] { 1608, 1609 }, Kurask::new); }" "package com.rs.game.content.skills.slayer.npcs; @PluginEventHandler public class MutatedZygomite extends ConditionalDeath { boolean lvl74; public MutatedZygomite(int id, Tile tile) { super(7421, null, false, id, tile); lvl74 = id == 3344; } @Override public void processNPC() { super.processNPC(); if (!isUnderCombat() && !isDead()) resetNPC(); } private void resetNPC() { transformIntoNPC(lvl74 ? 3344 : 3345); tele(getRespawnTile()); } @Override public void onRespawn() { resetNPC(); } public static void transform(final Player player, final NPC npc) { if (npc.isCantInteract()) return; player.setNextAnimation(new Animation(2988)); npc.transformIntoNPC(npc.getId() + 2); npc.setNextAnimation(new Animation(2982)); npc.setCantInteract(true); npc.getCombat().setTarget(player); npc.setHitpoints(npc.getMaxHitpoints()); npc.resetLevels(); WorldTasks.schedule(new Task() { @Override public void run() { npc.setCantInteract(false); } }, 1); } public static NPCInstanceHandler toFunc = new NPCInstanceHandler(new Object[] { 3344, 3345, 3346, 3347 }, MutatedZygomite::new); }" "package com.rs.game.content.skills.slayer.npcs; @PluginEventHandler public class Nechryael extends NPC { private NPC[] deathSpawns; public Nechryael(int id, Tile tile, boolean spawned) { super(id, tile, spawned); } @Override public void processNPC() { if (hasActiveSpawns() && !isUnderCombat()) removeDeathSpawns(); super.processNPC(); } public void summonDeathSpawns() { deathSpawns = new NPC[2]; Entity target = getCombat().getTarget(); for (int idx = 0; idx < deathSpawns.length; idx++) { deathSpawns[idx] = World.spawnNPC(getId() + 1, World.getFreeTile(getTile(), 2), -1, true, true); if (target != null) deathSpawns[idx].setTarget(target); } } private void removeDeathSpawns() { if (deathSpawns == null) return; for (NPC npc : deathSpawns) npc.finish(); deathSpawns = null; } @Override public void sendDeath(Entity source) { super.sendDeath(source); removeDeathSpawns(); } public boolean hasActiveSpawns() { return deathSpawns != null; } public static NPCInstanceHandler toFunc = new NPCInstanceHandler(new Object[] { 1613, 10702 }, (npcId, tile) -> new Nechryael(npcId, tile, false)); }" "package com.rs.game.content.skills.slayer.npcs; @PluginEventHandler public class PolyporeNPC extends NPC { private final int realId; private int neemedTicks = 0; public PolyporeNPC(int id, Tile tile, boolean spawned) { super(id, tile, spawned); realId = id; setRandomWalk(true); if (id == 14698) setCantFollowUnderCombat(id == 14698); } @Override public void processNPC() { super.processNPC(); if (neemedTicks-- <= 0 && !canInfect()) transformIntoNPC(realId); if (canInfect() && getTarget() != null && inMeleeRange(getTarget())) { anim(getInfectEmote()); getTarget().applyHit(new Hit(this, getFungalDamage(), HitLook.DISEASE_DAMAGE)); } } public void neem() { neemedTicks = Ticks.fromSeconds(20); transformIntoNPC(realId+1); } @Override public void reset() { setNPC(realId); super.reset(); } public boolean canInfect() { return realId == getId(); } @Override public void handlePreHitOut(Entity target, Hit hit) { if (!canInfect() && (hit.getLook() == HitLook.RANGE_DAMAGE || hit.getLook() == HitLook.MAGIC_DAMAGE)) hit.setDamage(hit.getDamage() / 2); } @Override public void handlePreHit(final Hit hit) { if (canInfect() && (hit.getLook() == HitLook.MELEE_DAMAGE || hit.getLook() == HitLook.RANGE_DAMAGE)) hit.setDamage(hit.getDamage() / 5); super.handlePreHit(hit); } public int getInfectEmote() { return switch (realId) { case 14688 -> 15484; case 14690 -> 15507; case 14692 -> 15514; case 14696 -> 15466; case 14698 -> 15477; case 14700 -> 15492; default -> -1; }; } public int getFungalDamage() { return switch (realId) { case 14690, 14692 -> Utils.randomInclusive(2, 3); //fungal mage case 14700 -> Utils.randomInclusive(7, 13); //grifolaroo case 14688 -> Utils.randomInclusive(10, 19); //grifolapine case 14698 -> Utils.randomInclusive(11, 21); //gano runt case 14696 -> Utils.randomInclusive(15, 28); //gano beast default -> Utils.randomInclusive(5, 10); }; } public static NPCInstanceHandler toFunc = new NPCInstanceHandler(new Object[] { 14688, 14689, 14690, 14691, 14692, 14693, 14696, 14697, 14698, 14699, 14700, 14701 }, (npcId, tile) -> new PolyporeNPC(npcId, tile, false)); }" "package com.rs.game.content.skills.slayer.npcs; @PluginEventHandler public class Strykewyrm extends NPC { private final int stompId; public Strykewyrm(int id, Tile tile) { super(id, tile, false); stompId = id; } @Override public void processNPC() { super.processNPC(); if (isDead()) return; if (getId() != stompId && !isCantInteract() && !isUnderCombat()) { setNextAnimation(new Animation(12796)); setCantInteract(true); WorldTasks.schedule(new Task() { @Override public void run() { transformIntoNPC(stompId); WorldTasks.schedule(new Task() { @Override public void run() { setCantInteract(false); } }); } }); } } @Override public void handlePreHit(Hit hit) { if (getId() == 9462 || getId() == 9463) if (hit.getSource() instanceof Player player) { switch (getId()) { case 9462: case 9463: if (!player.isOnTask(TaskMonster.ICE_STRYKEWYRMS)) { player.sendMessage(""You seem to be unable to damage it.""); hit.setDamage(0); setCapDamage(0); } if (hit.getData(""combatSpell"") != null && hit.getData(""combatSpell"", CombatSpell.class).isFireSpell()) hit.setDamage(hit.getDamage() * 2); break; case 9464: case 9465: if (!player.isOnTask(TaskMonster.DESERT_STRYKEWYRMS)) { player.sendMessage(""You seem to be unable to damage it.""); hit.setDamage(0); setCapDamage(0); } break; case 9466: case 9467: if (!player.isOnTask(TaskMonster.JUNGLE_STRYKEWYRMS)) { player.sendMessage(""You seem to be unable to damage it.""); hit.setDamage(0); setCapDamage(0); } break; } if (!player.getEquipment().hasFirecape() && !player.iceStrykeNoCape()) { player.sendMessage(""The strykewyrm numbs your hands and freezes your attack.""); hit.setDamage(0); setCapDamage(0); return; } if (getCapDamage() == 0) setCapDamage(-1); } super.handlePreHit(hit); } @Override public void reset() { setNPC(stompId); super.reset(); } public int getStompId() { return stompId; } public static void handleStomping(final Player player, final Strykewyrm npc) { if (npc.isCantInteract()) return; if (!player.canAttackMulti(npc)) return; switch (npc.getId()) { case 9462: if (player.getSkills().getLevel(18) < 93) { player.sendMessage(""You need at least a slayer level of 93 to fight this.""); return; } if (!player.isOnTask(TaskMonster.ICE_STRYKEWYRMS)) { player.sendMessage(""The mound doesn't respond.""); return; } break; case 9464: if (player.getSkills().getLevel(18) < 77) { player.sendMessage(""You need at least a slayer level of 77 to fight this.""); return; } if (!player.isOnTask(TaskMonster.DESERT_STRYKEWYRMS)) { player.sendMessage(""The mound doesn't respond.""); return; } break; case 9466: if (player.getSkills().getLevel(18) < 73) { player.sendMessage(""You need at least a slayer level of 73 to fight this.""); return; } if (!player.isOnTask(TaskMonster.JUNGLE_STRYKEWYRMS)) { player.sendMessage(""The mound doesn't respond.""); return; } break; default: return; } npc.setAttackedBy(player); player.setNextAnimation(new Animation(4278)); player.lock(1); npc.setCantInteract(true); WorldTasks.delay(2, () -> { npc.setNextAnimation(new Animation(12795)); npc.transformIntoNPC(npc.stompId + 1); }); WorldTasks.delay(4, () -> { npc.setTarget(player); npc.setAttackedBy(player); npc.setCantInteract(false); }); } public static NPCClickHandler handleStomp = new NPCClickHandler(new Object[] { 9462, 9464, 9466 }, e -> { if (e.getNPC() instanceof Strykewyrm s) handleStomping(e.getPlayer(), s); }); public static NPCInstanceHandler toFunc = new NPCInstanceHandler(new Object[] { 9462, 9463, 9464, 9465, 9466, 9467 }, Strykewyrm::new); }" "package com.rs.game.content.skills.slayer.npcs.combat; public class AberrantSpectre extends CombatScript { @Override public Object[] getKeys() { return new Object[] { ""Aberrant spectre"" }; } @Override public int attack(NPC npc, Entity target) { NPCCombatDefinitions def = npc.getCombatDefinitions(); WorldProjectile p = World.sendProjectile(npc, target, def.getAttackProjectile(), 18, 18, 35, 1, 0, 0); npc.setNextAnimation(new Animation(def.getAttackEmote())); if (!Slayer.hasNosepeg(target)) { Player targetPlayer = (Player) target; if (!targetPlayer.getPrayer().isProtectingMage()) { int randomSkill = Utils.random(0, 6); if (randomSkill != Constants.HITPOINTS) { int currentLevel = targetPlayer.getSkills().getLevel(randomSkill); targetPlayer.getSkills().set(randomSkill, currentLevel < 5 ? 0 : currentLevel - 5); targetPlayer.sendMessage(""The smell of the abberrant spectre make you feel slightly weaker.""); } } delayHit(npc, p.getTaskDelay(), target, getMagicHit(npc, targetPlayer.getMaxHitpoints() / 10)); // TODO player emote hands on ears } else delayHit(npc, p.getTaskDelay(), target, getMagicHit(npc, getMaxHit(npc, npc.getMaxHit(), def.getAttackStyle(), target))); return npc.getAttackSpeed(); } }" "package com.rs.game.content.skills.slayer.npcs.combat; public class BansheeCombat extends CombatScript { @Override public Object[] getKeys() { return new Object[] { ""Banshee"", ""Mighty banshee"" }; } @Override public int attack(NPC npc, Entity target) { NPCCombatDefinitions def = npc.getCombatDefinitions(); if (!Slayer.hasEarmuffs(target)) { Player targetPlayer = (Player) target; int randomSkill = Utils.random(0, 6); if (randomSkill != Constants.HITPOINTS) { int currentLevel = targetPlayer.getSkills().getLevel(randomSkill); targetPlayer.getSkills().set(randomSkill, currentLevel < 5 ? 0 : currentLevel - 5); targetPlayer.sendMessage(""The screams of the banshee make you feel slightly weaker.""); npc.setNextForceTalk(new ForceTalk(""*EEEEHHHAHHH*"")); } delayHit(npc, 1, target, getRegularHit(npc, targetPlayer.getMaxHitpoints() / 10)); // TODO player emote hands on ears } else delayHit(npc, 1, target, getMeleeHit(npc, getMaxHit(npc, npc.getMaxHit(), def.getAttackStyle(), target))); npc.setNextAnimation(new Animation(def.getAttackEmote())); return npc.getAttackSpeed(); } }" "package com.rs.game.content.skills.slayer.npcs.combat; public class Basilisk extends CombatScript { @Override public Object[] getKeys() { return new Object[] { ""Basilisk"" }; } @Override public int attack(NPC npc, final Entity target) { NPCCombatDefinitions def = npc.getCombatDefinitions(); if (!Slayer.hasReflectiveEquipment(target)) { Player targetPlayer = (Player) target; int randomSkill = Utils.random(0, 6); if (randomSkill != Constants.HITPOINTS) { int currentLevel = targetPlayer.getSkills().getLevel(randomSkill); targetPlayer.getSkills().set(randomSkill, currentLevel < 5 ? 0 : currentLevel - 5); delayHit(npc, 0, target, getRegularHit(npc, targetPlayer.getMaxHitpoints() / 10)); WorldTasks.schedule(() -> target.setNextSpotAnim(new SpotAnim(747))); } } else delayHit(npc, 0, target, getMeleeHit(npc, getMaxHit(npc, npc.getMaxHit(), def.getAttackStyle(), target))); npc.setNextAnimation(new Animation(def.getAttackEmote())); return npc.getAttackSpeed(); } }" "package com.rs.game.content.skills.slayer.npcs.combat; public class CaveHorrorCombat extends CombatScript { @Override public Object[] getKeys() { return new Object[] { ""Cave horror"" }; } @Override public int attack(NPC npc, Entity target) { NPCCombatDefinitions def = npc.getCombatDefinitions(); if (!Slayer.hasWitchWoodIcon(target)) { Player targetPlayer = (Player) target; int randomSkill = Utils.random(0, 6); int currentLevel = targetPlayer.getSkills().getLevel(randomSkill); if (randomSkill != Constants.HITPOINTS) { targetPlayer.getSkills().set(randomSkill, currentLevel < 5 ? 0 : currentLevel - 5); targetPlayer.sendMessage(""The screams of the cave horror make you feel slightly weaker.""); npc.setNextForceTalk(new ForceTalk(""*OOOoooAHHHH*"")); } delayHit(npc, 0, target, getMeleeHit(npc, targetPlayer.getMaxHitpoints() / 3)); } else delayHit(npc, 0, target, getMeleeHit(npc, getMaxHit(npc, def.getMaxHit(), def.getAttackStyle(), target))); npc.setNextAnimation(new Animation(4237)); return npc.getAttackSpeed(); } }" "package com.rs.game.content.skills.slayer.npcs.combat; public class CockatriceCombat extends CombatScript { @Override public Object[] getKeys() { return new Object[] { 1620 }; } @Override public int attack(NPC npc, final Entity target) { NPCCombatDefinitions def = npc.getCombatDefinitions(); if (!Slayer.hasReflectiveEquipment(target)) { Player targetPlayer = (Player) target; npc.setNextAnimation(new Animation(7766)); npc.setNextSpotAnim(new SpotAnim(1467)); delayHit(npc, 1, target, getRegularHit(npc, targetPlayer.getMaxHitpoints() / 6)); } else delayHit(npc, 1, target, getMeleeHit(npc, getMaxHit(npc, def.getMaxHit(), def.getAttackStyle(), target))); npc.setNextAnimation(new Animation(def.getAttackEmote())); return npc.getAttackSpeed(); } }" "package com.rs.game.content.skills.slayer.npcs.combat; public class DarkBeastCombat extends CombatScript { @Override public Object[] getKeys() { return new Object[] { 2783 }; } @Override public int attack(NPC npc, final Entity target) { NPCCombatDefinitions def = npc.getCombatDefinitions(); npc.setNextAnimation(new Animation(2731)); if (WorldUtil.isInRange(target, npc, 3)) delayHit(npc, 0, target, getMeleeHit(npc, getMaxHit(npc, 170, def.getAttackStyle(), target))); else { final int damage = getMaxHit(npc, 90, def.getAttackStyle(), target); World.sendProjectile(npc, target, 2181, 41, 16, 41, 35, 16, 0); delayHit(npc, 2, target, getMagicHit(npc, damage)); } return npc.getAttackSpeed(); } }" "package com.rs.game.content.skills.slayer.npcs.combat; public class DustDevil extends CombatScript { @Override public Object[] getKeys() { return new Object[] { 1624 }; } @Override public int attack(NPC npc, Entity target) { NPCCombatDefinitions def = npc.getCombatDefinitions(); if (!Slayer.hasMask(target)) { Player targetPlayer = (Player) target; int randomSkill = Utils.random(0, 6); if (randomSkill != Constants.HITPOINTS) { int currentLevel = targetPlayer.getSkills().getLevel(randomSkill); targetPlayer.getSkills().set(randomSkill, currentLevel < 5 ? 0 : currentLevel - Utils.random(20)); targetPlayer.sendMessage(""The dust devil's smoke suffocates you.""); npc.setNextForceTalk(new ForceTalk(""*cough*"")); } delayHit(npc, 1, target, getRegularHit(npc, targetPlayer.getMaxHitpoints() / 10)); } else delayHit(npc, 1, target, getMeleeHit(npc, getMaxHit(npc, npc.getMaxHit(), def.getAttackStyle(), target))); npc.setNextAnimation(new Animation(def.getAttackEmote())); return npc.getAttackSpeed(); } }" "package com.rs.game.content.skills.slayer.npcs.combat; public class InfernalMage extends CombatScript { @Override public Object[] getKeys() { return new Object[] { ""Infernal Mage"" }; } @Override public int attack(NPC npc, Entity target) { NPCCombatDefinitions defs = npc.getCombatDefinitions(); npc.setNextAnimation(new Animation(defs.getAttackEmote())); World.sendProjectile(npc, target, defs.getAttackProjectile(), 30, 30, 50, 2, Utils.random(5), 5); delayHit(npc, 3, target, getMagicHit(npc, getMaxHit(npc, defs.getMaxHit(), defs.getAttackStyle(), target))); target.setNextSpotAnim(new SpotAnim(2739, 3, 100)); return npc.getAttackSpeed(); } }" "package com.rs.game.content.skills.slayer.npcs.combat; public class NechryaelCombat extends CombatScript { @Override public Object[] getKeys() { return new Object[] { ""Nechryael"" }; } @Override public int attack(NPC npc, Entity target) { NPCCombatDefinitions def = npc.getCombatDefinitions(); if (npc instanceof Nechryael n) if (Utils.random(10) == 0 && !n.hasActiveSpawns()) n.summonDeathSpawns(); npc.setNextAnimation(new Animation(npc.getCombatDefinitions().getAttackEmote())); delayHit(npc, 0, target, getMeleeHit(npc, getMaxHit(npc, def.getMaxHit(), def.getAttackStyle(), target))); return npc.getAttackSpeed(); } }" "package com.rs.game.content.skills.slayer.npcs.combat; public class SpiritualMage extends CombatScript { @Override public Object[] getKeys() { return new Object[] { 6257, 6221, 6278 }; } @Override public int attack(NPC npc, final Entity target) { final NPCCombatDefinitions defs = npc.getCombatDefinitions(); npc.setNextAnimation(new Animation(defs.getAttackEmote())); int damage = getMaxHit(npc, defs.getMaxHit(), AttackStyle.MAGE, target); npc.setNextSpotAnim(new SpotAnim(defs.getAttackGfx())); delayHit(npc, 2, target, getMagicHit(npc, damage)); if (damage > 0) WorldTasks.schedule(new Task() { @Override public void run() { target.setNextSpotAnim(new SpotAnim(defs.getAttackProjectile())); } }, 2); return npc.getAttackSpeed() + 2; } }" "package com.rs.game.content.skills.slayer.npcs.combat; public class StrykewyrmCombat extends CombatScript { @Override public Object[] getKeys() { return new Object[] { 9463, 9465, 9467 }; } @Override public int attack(final NPC npc, final Entity target) { final NPCCombatDefinitions defs = npc.getCombatDefinitions(); int attackStyle = Utils.getRandomInclusive(20); if (attackStyle <= 7 && WorldUtil.isInRange(npc.getX(), npc.getY(), npc.getSize(), target.getX(), target.getY(), target.getSize(), 0)) { // melee npc.setNextAnimation(new Animation(defs.getAttackEmote())); if (npc.getId() == 9467) { if (Utils.getRandomInclusive(10) == 0) { target.setNextSpotAnim(new SpotAnim(2309)); target.getPoison().makePoisoned(44); } } delayHit(npc, 0, target, getMeleeHit(npc, getMaxHit(npc, defs.getMaxHit(), AttackStyle.MAGE, target))); return npc.getAttackSpeed(); } if (attackStyle <= 9) { // mage npc.setNextAnimation(new Animation(12794)); final Hit hit = getMagicHit(npc, getMaxHit(npc, defs.getMaxHit(), AttackStyle.MAGE, target)); delayHit(npc, 1, target, hit); World.sendProjectile(npc, target, defs.getAttackProjectile(), 41, 16, 41, 30, 16, 0); if (npc.getId() == 9463) WorldTasks.schedule(new Task() { @Override public void run() { if (Utils.getRandomInclusive(10) == 0 && !target.hasEffect(Effect.FREEZE)) { target.freeze(Ticks.fromSeconds(3)); target.setNextSpotAnim(new SpotAnim(369)); if (target instanceof Player player) player.stopAll(); } else if (hit.getDamage() != 0) target.setNextSpotAnim(new SpotAnim(2315)); } }, 1); else if (npc.getId() == 9467) if (Utils.getRandomInclusive(10) == 0) { target.setNextSpotAnim(new SpotAnim(2313)); if (Utils.random(2) == 0) target.getPoison().makePoisoned(88); } } else if (attackStyle == 20) { // bury final Tile tile = Tile.of(target.getTile()).transform(-1, -1, 0); npc.setNextAnimation(new Animation(12796)); npc.setCantInteract(true); npc.getCombat().removeTarget(); WorldTasks.scheduleLooping(new Task() { int count; @Override public void run() { if (count == 0) { npc.transformIntoNPC(((Strykewyrm) npc).getStompId()); npc.setForceWalk(tile); count++; } else if (count == 1 && !npc.hasForceWalk()) { npc.transformIntoNPC(((Strykewyrm) npc).getStompId() + 1); npc.setNextAnimation(new Animation(12795)); int distanceX = target.getX() - npc.getX(); int distanceY = target.getY() - npc.getY(); int size = npc.getSize(); if (distanceX < size && distanceX > -1 && distanceY < size && distanceY > -1) { delayHit(npc, 0, target, new Hit(npc, 300, HitLook.TRUE_DAMAGE)); if (npc.getId() == 9467) target.getPoison().makePoisoned(88); else if (npc.getId() == 9465) { delayHit(npc, 0, target, new Hit(npc, 300, HitLook.TRUE_DAMAGE)); target.setNextSpotAnim(new SpotAnim(2311)); } } count++; } else if (count == 2) { WorldTasks.schedule(new Task() { @Override public void run() { npc.getCombat().setCombatDelay(npc.getAttackSpeed()); npc.setTarget(target); npc.setCantInteract(false); } }); stop(); } } }, 1, 1); } return npc.getAttackSpeed(); } }" "package com.rs.game.content.skills.smithing; /* INTERFACE 825 */ /* INTERFACE 1070 */ /* INTERFACE 1071 */ /* INTERFACE 1072 */ @PluginEventHandler public class ArtisansWorkshop { public static final HashMap ORES = new HashMap<>(); public static final int ORE_IDX = 0, ORE_NOTED = 1, A_ORE_ID = 2, CAP_AMT = 3; public static final String[] ORE_OPTIONS = { ""Iron"", ""Coal"", ""Mithril"", ""Adamantite"", ""Runite"" }; static { ORES.put(""Iron"", new int[] { 0, 441, 25629, 4000 }); ORES.put(""Coal"", new int[] { 1, 454, 25630, 8000 }); ORES.put(""Mithril"", new int[] { 2, 448, 25631, 4000 }); ORES.put(""Adamantite"", new int[] { 3, 450, 25632, 4000 }); ORES.put(""Runite"", new int[] { 4, 452, 25633, 4000 }); } public static int numStoredOres(Player player, int itemId) { return player.artisanOres[itemId-25629]; } public static void removeOres(Player player, String oreName, int amount) { player.artisanOres[ORES.get(oreName)[ORE_IDX]] -= amount; player.sendMessage(""You withdraw "" + amount + "" ores. You now have "" + player.artisanOres[ORES.get(oreName)[ORE_IDX]] + "" "" + oreName.toLowerCase() + "" in the furnace.""); sendOreVars(player); } public static void addOres(Player player, String oreName, int amount) { player.artisanOres[ORES.get(oreName)[ORE_IDX]] += amount; player.sendMessage(""You deposit "" + amount + "" ores. You now have "" + player.artisanOres[ORES.get(oreName)[ORE_IDX]] + "" "" + oreName.toLowerCase() + "" in the furnace.""); sendOreVars(player); } public static void depositOres(Player player, String oreName, int amount) { if (amount > player.getInventory().getAmountOf(ORES.get(oreName)[ORE_NOTED])) amount = player.getInventory().getAmountOf(ORES.get(oreName)[ORE_NOTED]); if (amount == 0) { player.sendMessage(""You don't have any "" + oreName + "" to deposit.""); return; } if (amount + player.artisanOres[ORES.get(oreName)[ORE_IDX]] > ORES.get(oreName)[CAP_AMT]) amount = ORES.get(oreName)[CAP_AMT] - player.artisanOres[ORES.get(oreName)[ORE_IDX]]; if (amount == 0) { player.sendMessage(""You already have "" + ORES.get(oreName)[CAP_AMT] + "" "" + oreName + "" stored in the furnace. You can't fit any more in.""); return; } player.getInventory().deleteItem(ORES.get(oreName)[ORE_NOTED], amount); addOres(player, oreName, amount); } public static void withdrawOres(Player player, String oreName, int amount) { if (amount > player.artisanOres[ORES.get(oreName)[ORE_IDX]]) amount = player.artisanOres[ORES.get(oreName)[ORE_IDX]]; if (amount == 0) { player.sendMessage(""You don't have any "" + oreName + "" to withdraw.""); return; } player.getInventory().addItem(ORES.get(oreName)[ORE_NOTED], amount); removeOres(player, oreName, amount); } public static void handleDepositOres(Player player) { String[] filteredOres = Arrays.stream(ORE_OPTIONS).filter(oreName -> oreName.equals(""None"") ? true : player.getInventory().containsItem(ORES.get(oreName)[ORE_NOTED], 1)).toArray(String[]::new); if (filteredOres.length < 1) { player.sendMessage(""You don't have any ores to return.""); return; } player.sendOptionDialogue(""Which ore would you like to deposit?"", ops -> { for (String opName : filteredOres) ops.add(opName, () -> promptForDeposit(player, opName)); ops.add(""None""); }); } public static void promptForDeposit(Player player, String oreName) { player.sendOptionDialogue(""How many would you like to deposit?"", ops -> { ops.add(""10"", () -> depositOres(player, oreName, 10)); ops.add(""100"", () -> depositOres(player, oreName, 100)); ops.add(""1000"", () -> depositOres(player, oreName, 1000)); ops.add(""All"", () -> depositOres(player, oreName, Integer.MAX_VALUE)); ops.add(""X"", () -> player.sendInputInteger(""How many would you like to deposit?"", (amount) -> depositOres(player, oreName, amount))); }); } public static void handleWithdrawOres(Player player) { String[] filteredOres = Arrays.stream(ORE_OPTIONS).filter(oreName -> oreName.equals(""None"") ? true : player.artisanOres[ORES.get(oreName)[ORE_IDX]] > 0).toArray(String[]::new); if (filteredOres.length < 1) { player.sendMessage(""You don't have any ores to return.""); return; } player.sendOptionDialogue(""Which ore would you like to withdraw?"", ops -> { for (String opName : filteredOres) ops.add(opName, () -> promptForWithdrawal(player, opName)); ops.add(""None""); }); } public static void promptForWithdrawal(Player player, String oreName) { player.sendOptionDialogue(""How many would you like to withdraw?"", ops -> { ops.add(""10"", () -> withdrawOres(player, oreName, 10)); ops.add(""100"", () -> withdrawOres(player, oreName, 100)); ops.add(""1000"", () -> withdrawOres(player, oreName, 1000)); ops.add(""All"", () -> withdrawOres(player, oreName, Integer.MAX_VALUE)); ops.add(""X"", () -> player.sendInputInteger(""How many would you like to deposit?"", (amount) -> withdrawOres(player, oreName, amount))); }); } public static void depositAllArmor(Player player) { for (int i = 20572;i <= 20631;i++) if (player.getInventory().containsItem(i, 1)) player.getInventory().deleteItem(i, player.getInventory().getAmountOf(i)); player.sendMessage(""You deposit all your armor.""); } public static void returnAllIngots(Player player) { for (int i = 20632;i <= 20652;i++) if (player.getInventory().containsItem(i, 1)) { ReqItem defs = ReqItem.getRequirements(i); Item[] materials = defs.getMaterialsFor(player.getInventory().getAmountOf(i)); for (Item mat : materials) if (mat.getAmount() + player.artisanOres[ORES.get(mat.getDefinitions().name)[ORE_IDX]] > ORES.get(mat.getDefinitions().name)[CAP_AMT]) { player.sendMessage(""You already have "" + ORES.get(mat.getDefinitions().name)[CAP_AMT] + "" "" + mat.getDefinitions().name + "" stored in the furnace. You can't fit any more in.""); return; } for (Item mat : materials) addOres(player, mat.getDefinitions().name, mat.getAmount()); player.getInventory().deleteItem(i, player.getInventory().getAmountOf(i)); } } public static void openIngotCreation(Player player, final ReqItem[] ingots) { Dialogue dialogue = new Dialogue() .addNext(new MakeXStatement(""What kind of bar would you like?"", Arrays.stream(ingots).mapToInt(ingot -> ingot.getProduct().getId()).toArray(), player.getInventory().getFreeSlots())); for (ReqItem item : ingots) { dialogue.addNext(() -> { int quantity = MakeXStatement.getQuantity(player); if (quantity > player.getInventory().getFreeSlots()) quantity = player.getInventory().getFreeSlots(); Item[] materials = item.getMaterialsFor(quantity); if (materials.length <= 0) return; for (Item mat : materials) { if (player.getInventory().getAmountOf(mat.getId()) < mat.getAmount()) { player.sendMessage(""You need "" + mat.getAmount() + "" "" + mat.getDefinitions().name + "" to make "" + quantity + "" "" + item.getProduct().getDefinitions().name+ (quantity > 1 ? ""s"" : """") +"".""); return; } } for (Item mat : materials) { if (mat.getId() >= 25629 && mat.getId() <= 25633) removeOres(player, mat.getDefinitions().name, mat.getAmount()); } player.getInventory().addItem(new Item(item.getProduct().setAmount(quantity))); }); } player.startConversation(dialogue); } // @Override // public void onItemCreation(Player player, int skill, Item item, double xp) { // if (item.getId() >= 20572 && item.getId() <= 20631) { // int currXp = (int) player.get(""artisan-xp""); // if ((currXp + xp) > 10000) { // int currRep = (int) player.get(""artisan-rep""); // if (currRep >= 100) // return; // player.save(""artisan-xp"", 0); // player.save(""artisan-rep"", currRep+1); // updateReputation(player); // } else { // player.save(""artisan-xp"", currXp + xp); // } // } // } public void updateReputation(Player player) { //TODO find the varbit and the interface } public void openReputationShop(Player player) { //TODO find the interface id for it } // @ButtonClickHandler(ids = { 0 }) // public static void onButtonClick(ButtonClickEvent e) { // //TODO find interface id and button handlers // } public static int getHighestIngot(Player player) { int highest = 20632; for (int i = 20632;i <= 20652;i++) if (player.getInventory().containsItem(i, 1)) highest = i; return highest; } private static final ReqItem[] IRON = { ReqItem.IRON_INGOT_I, ReqItem.IRON_INGOT_II, ReqItem.IRON_INGOT_III, ReqItem.IRON_INGOT_IV }; private static final ReqItem[] STEEL = { ReqItem.STEEL_INGOT_I, ReqItem.STEEL_INGOT_II, ReqItem.STEEL_INGOT_III, ReqItem.STEEL_INGOT_IV }; private static final ReqItem[] MITHRIL = { ReqItem.MITHRIL_INGOT_I, ReqItem.MITHRIL_INGOT_II, ReqItem.MITHRIL_INGOT_III, ReqItem.MITHRIL_INGOT_IV }; private static final ReqItem[] ADAMANT = { ReqItem.ADAMANT_INGOT_I, ReqItem.ADAMANT_INGOT_II, ReqItem.ADAMANT_INGOT_III, ReqItem.ADAMANT_INGOT_IV }; private static final ReqItem[] RUNE = { ReqItem.RUNE_INGOT_I, ReqItem.RUNE_INGOT_II, ReqItem.RUNE_INGOT_III, ReqItem.RUNE_INGOT_IV }; private static final HashMap BAR_SETS = new HashMap<>(); static { BAR_SETS.put(""Iron"", IRON); BAR_SETS.put(""Steel"", STEEL); BAR_SETS.put(""Mithril"", MITHRIL); BAR_SETS.put(""Adamant"", ADAMANT); BAR_SETS.put(""Rune"", RUNE); } public static ObjectClickHandler handleDepositArmor = new ObjectClickHandler(new Object[] { 29396 }, e -> depositAllArmor(e.getPlayer())); public static ObjectClickHandler handleAnvil = new ObjectClickHandler(new Object[] { 4046 }, e -> { int highestIngot = getHighestIngot(e.getPlayer()); if (highestIngot != -1) e.getPlayer().startConversation(new CreationActionD(e.getPlayer(), Category.ARTISANS, highestIngot, 898, 15, true)); else e.getPlayer().sendMessage(""You don't have any ingots to smith.""); }); public static ObjectClickHandler handleFurnaces = new ObjectClickHandler(new Object[] { 29394, 29395 }, e -> { switch(e.getOpNum()) { case OBJECT_OP1: ArrayList options = new ArrayList<>(); for (ReqItem[] bar : BAR_SETS.values()) { if (!e.getPlayer().getInventory().hasMaterials(bar[0].getMaterials())) continue; options.add(bar[0].getProduct().getDefinitions().name.split("" "")[0]); } if (options.size() > 1) { e.getPlayer().sendOptionDialogue(""Which type of bar would you like to make?"", ops -> { for (String opName : options) ops.add(opName, () -> openIngotCreation(e.getPlayer(), BAR_SETS.get(opName))); }); } else if (options.size() == 1) openIngotCreation(e.getPlayer(), BAR_SETS.get(options.getFirst())); else e.getPlayer().sendMessage(""You don't have any ore stored.""); break; case OBJECT_OP2: returnAllIngots(e.getPlayer()); break; case OBJECT_OP3: handleDepositOres(e.getPlayer()); break; case OBJECT_OP4: handleWithdrawOres(e.getPlayer()); break; default: break; } }); public static LoginHandler onLogin = new LoginHandler(e -> { if (e.getPlayer().artisanOres == null) e.getPlayer().artisanOres = new int[5]; sendOreVars(e.getPlayer()); }); public static void sendOreVars(Player player) { player.getVars().setVarBit(8857, player.artisanOres[0]); player.getVars().setVarBit(8859, player.artisanOres[1]); player.getVars().setVarBit(8862, player.artisanOres[2]); player.getVars().setVarBit(8863, player.artisanOres[3]); player.getVars().setVarBit(8865, player.artisanOres[4]); player.getPackets().sendRunScriptReverse(4182); } }" "package com.rs.game.content.skills.smithing; @PluginEventHandler public class CannonBallSmelting { public static int AMMO_MOULD = 4; public static int STEEL_BAR = 2353; private static final Item[][] mats = { { new Item(2353) } }; private static final Item[][] prods = { { new Item(2, 4) } }; private static final int[] reqs = { 35 }; private static final double[] xp = { 25.6 }; private static final int[] anims = { 3243 }; //827, 899 public static ItemOnObjectHandler handleCreate = new ItemOnObjectHandler(new Object[] { ""Furnace"" }, new Object[] { STEEL_BAR, AMMO_MOULD }, e -> { if (!e.getPlayer().getInventory().containsItem(AMMO_MOULD)) { e.getPlayer().sendMessage(""You need an ammo mould to smelt cannonballs.""); return; } if (e.getPlayer().isQuestComplete(Quest.DWARF_CANNON, ""before you can smith cannonballs."")) e.getPlayer().startConversation(new CreateActionD(e.getPlayer(), mats, prods, xp, anims, reqs, Constants.SMITHING, 7)); }); }" "package com.rs.game.content.skills.smithing; @PluginEventHandler public class CoalBag { public static ItemClickHandler handleClickOnCoalBag = new ItemClickHandler(new Object[] { 18339 }, e -> { int current = e.getPlayer().getI(""coalBag""); if (current == -1) e.getPlayer().save(""coalBag"", 0); if (current == -1 || current == 0) { e.getPlayer().sendMessage(""You do not have any coal in your coal bag.""); return; } switch(e.getOption()) { case ""Inspect"": e.getPlayer().sendMessage(""You have "" + current + "" coal in your bag.""); break; case ""Withdraw-one"": if (!e.getPlayer().getInventory().hasFreeSlots()) { e.getPlayer().sendMessage(""You do not have enough inventory spaces to do that.""); return; } if (current > 1) { e.getPlayer().getInventory().addItem(453, 1); e.getPlayer().save(""coalBag"", current-1); e.getPlayer().sendMessage(""You withdraw a coal from your bag.""); } break; case ""Withdraw-many"": if (!e.getPlayer().getInventory().hasFreeSlots()) { e.getPlayer().sendMessage(""You do not have enough inventory spaces to do that.""); return; } int withdraw = (current > e.getPlayer().getInventory().getFreeSlots() ? e.getPlayer().getInventory().getFreeSlots() : current); e.getPlayer().getInventory().addItem(453, withdraw); e.getPlayer().save(""coalBag"", current-withdraw); e.getPlayer().sendMessage(""You withdraw "" + withdraw + "" coal from your bag.""); break; } }); public static ItemOnItemHandler handleItemOnCoalBag = new ItemOnItemHandler(18339, 453, e -> { int current = e.getPlayer().getI(""coalBag""); if (current == -1) e.getPlayer().save(""coalBag"", 0); int room = 0; if (current < 27) room = 27 - current; if (room == 0) { e.getPlayer().sendMessage(""Your coal bag is already full.""); return; } int coalToStore = e.getPlayer().getInventory().getNumberOf(453); if (coalToStore > room) coalToStore = room; e.getPlayer().getInventory().deleteItem(453, coalToStore); e.getPlayer().save(""coalBag"", current+coalToStore); e.getPlayer().sendMessage(""You store "" + coalToStore + "" in your coal bag.""); }); public static ItemOnObjectHandler handleCoalBagOnObject = new ItemOnObjectHandler(new Object[] { ""Bank"", ""Deposit Box"", ""Counter"" }, new Object[] { 18339 }, e -> { if (ObjectDefinitions.getDefs(e.getObject().getId()).getName().contains(""Bank"") || ObjectDefinitions.getDefs(e.getObject().getId()).containsOptionIgnoreCase(""bank"")) e.getPlayer().startConversation(new Dialogue().addOptions(""How much would you like to deposit?"", new Options() { @Override public void create() { option(""All"", () -> { int coalBagAmount = e.getPlayer().getI(""coalBag""); e.getPlayer().getBank().addItem(new Item(453, coalBagAmount), true); e.getPlayer().save(""coalBag"", 0); e.getPlayer().sendMessage(""You store all of your coal in the bank.""); }); option(""Deposit X"", () -> e.getPlayer().sendInputInteger(""How much coal would you like to deposit?"", amount -> { int coalBagAmount = e.getPlayer().getI(""coalBag""); int coalToStore = (amount > coalBagAmount ? coalBagAmount : amount); e.getPlayer().getBank().addItem(new Item(453, coalToStore), true); e.getPlayer().save(""coalBag"", coalBagAmount-coalToStore); e.getPlayer().sendMessage(""You store "" + coalToStore + "" coal in the bank.""); })); } })); }); }" "package com.rs.game.content.skills.smithing; @PluginEventHandler public class ForgingInterface { private static final int SMITHING_INTERFACE = 300; public enum Slot { DAGGER(18), HATCHET(26), MACE(34), MEDIUM_HELM(42), CROSSBOW_BOLTS(50), SWORD(58), DART_TIPS(66), NAILS(74), BRONZE_WIRE(82), SPIT_IRON(90), STUDS(98), ARROW_TIPS(106), SCIMITAR(114), CROSSBOW_LIMBS(122), LONGSWORD(130), THROWING_KNIFE(138), FULL_HELM(146), SQUARE_SHIELD(154), BULLSEYE_LANTERN(162), GRAPPLE_TIP(170), WARHAMMER(178), BATTLEAXE(186), CHAINBODY(194), KITESHIELD(202), CLAWS(210), TWO_HAND_SWORD(218), PLATESKIRT(226), PLATELEGS(234), PLATEBODY(242), PICKAXE(267); private static final Map CLICK_ID_MAP = new HashMap<>(); static { for (Slot s : Slot.values()) { CLICK_ID_MAP.put(s.componentId+3, s); //make all CLICK_ID_MAP.put(s.componentId+4, s); //make x CLICK_ID_MAP.put(s.componentId+5, s); //make 5 CLICK_ID_MAP.put(s.componentId+6, s); //make 1 } } public static Slot forId(int componentId) { return CLICK_ID_MAP.get(componentId); } private final int componentId; Slot(int componentId) { this.componentId = componentId; } } public static ButtonClickHandler handleSmithButtons = new ButtonClickHandler(SMITHING_INTERFACE, e -> { int barId = e.getPlayer().getTempAttribs().getI(""SmithingBar""); GameObject anvil = e.getPlayer().getTempAttribs().getO(""SmithingAnvil""); Slot slot = Slot.forId(e.getComponentId()); if (slot == null) return; Map items = Smithable.forBar(barId); if (items == null || items.get(slot) == null) return; int makeX = switch(e.getComponentId() - slot.componentId) { case 3 -> 28; case 4 -> -1; case 5 -> 5; case 6 -> 1; default -> 1; }; if (makeX < 0) e.getPlayer().sendInputInteger(""How many would you like to make?"", amount -> e.getPlayer().getActionManager().setAction(new Smithing(amount, items.get(slot), anvil))); else e.getPlayer().getActionManager().setAction(new Smithing(makeX, items.get(slot), anvil)); }); public static String[] getStrings(Player player, Smithable item) { StringBuilder barName = new StringBuilder(); StringBuilder levelString = new StringBuilder(); String name = item.product.getDefinitions().getName().toLowerCase(); String barVariableName = item.toString().toLowerCase(); if (player.getInventory().getItems().getNumberOf(item.bar.getId()) >= item.bar.getAmount()) barName.append(""""); barName.append(item.bar.getAmount()).append("" "").append(item.bar.getAmount() > 1 ? ""bars"" : ""bar""); if (player.getSkills().getLevel(Constants.SMITHING) >= item.level) levelString.append(""""); levelString.append(Utils.formatPlayerNameForDisplay(name.replace(barVariableName + "" "", """"))); return new String[] { levelString.toString(), barName.toString() }; } public static void openSmithingInterfaceForHighestBar(Player player, GameObject object) { int bar = Smithable.getHighestBar(player); if (bar != -1) sendSmithingInterface(player, object, bar); else player.sendMessage(""You have no bars which you have smithing level to use.""); } public static void sendSmithingInterface(Player player, GameObject object, int barId) { player.getTempAttribs().setI(""SmithingBar"", barId); player.getTempAttribs().setO(""SmithingAnvil"", object); Map items = Smithable.forBar(barId); for (Slot slot : Slot.values()) { Smithable item = items.get(slot); if (item == null && !IComponentDefinitions.getInterface(300)[slot.componentId].hidden) { player.getPackets().setIFHidden(SMITHING_INTERFACE, slot.componentId-1, true); continue; } if (IComponentDefinitions.getInterface(300)[item.slot.componentId-1].hidden) player.getPackets().setIFHidden(SMITHING_INTERFACE, item.slot.componentId-1, false); player.getPackets().setIFItem(SMITHING_INTERFACE, item.slot.componentId, item.product.getId(), item.product.getAmount()); String[] name = getStrings(player, item); if (name != null) { player.getPackets().setIFText(300, item.slot.componentId + 1, name[0]); player.getPackets().setIFText(300, item.slot.componentId + 2, name[1]); } } player.getPackets().setIFText(300, 14, ItemDefinitions.getDefs(barId).name.replace("" bar"", """")); player.getInterfaceManager().sendInterface(SMITHING_INTERFACE); } }" "package com.rs.game.content.skills.smithing; @PluginEventHandler public class ItemForging { //TODO spotanim 2123 sparks off anvil private enum ForgeableItem { GODSWORD_S1_S2(11710, 11712, 11686, player -> { if (player.getSkills().getLevel(Skills.SMITHING) < 80) { player.sendMessage(""You need 80 Smithing to work with that metal.""); return false; } return true; }, player -> { player.itemDialogue(11686, ""You join the shards together.""); player.getSkills().addXp(Skills.SMITHING, 100); }), GODSWORD_S2_S3(11712, 11714, 11692, player -> { if (player.getSkills().getLevel(Skills.SMITHING) < 80) { player.sendMessage(""You need 80 Smithing to work with that metal.""); return false; } return true; }, player -> { player.itemDialogue(11692, ""You join the shards together.""); player.getSkills().addXp(Skills.SMITHING, 100); }), GODSWORD_S1_S3(11710, 11714, 11688, player -> { if (player.getSkills().getLevel(Skills.SMITHING) < 80) { player.sendMessage(""You need 80 Smithing to work with that metal.""); return false; } return true; }, player -> { player.itemDialogue(11688, ""You join the shards together.""); player.getSkills().addXp(Skills.SMITHING, 100); }), GODSWORD_S1_S2_S3(11686, 11714, 11690, player -> { if (player.getSkills().getLevel(Skills.SMITHING) < 80) { player.sendMessage(""You need 80 Smithing to work with that metal.""); return false; } return true; }, player -> { player.itemDialogue(11690, ""You join the shards together.""); player.getSkills().addXp(Skills.SMITHING, 100); }), GODSWORD_S2_S3_S1(11692, 11710, 11690, player -> { if (player.getSkills().getLevel(Skills.SMITHING) < 80) { player.sendMessage(""You need 80 Smithing to work with that metal.""); return false; } return true; }, player -> { player.itemDialogue(11690, ""You join the shards together.""); player.getSkills().addXp(Skills.SMITHING, 100); }), GODSWORD_S1_S3_S2(11688, 11712, 11690, player -> { if (player.getSkills().getLevel(Skills.SMITHING) < 80) { player.sendMessage(""You need 80 Smithing to work with that metal.""); return false; } return true; }, player -> { player.itemDialogue(11690, ""You join the shards together.""); player.getSkills().addXp(Skills.SMITHING, 100); }), DRAGONFIRE_SHIELD(11286, 1540, 11284, player -> { if (player.getSkills().getLevel(Skills.SMITHING) < 90) { player.sendMessage(""You need 90 Smithing to fuse the visage to the shield.""); return false; } return true; }, player -> { player.itemDialogue(11284, ""You set to work, trying to attach the ancient draconic visage to your anti-dragonbreath shield. It's not easy to work with the ancient artifact and it takes all of your skill as a master smith.""); player.getSkills().addXp(Skills.SMITHING, 2000); }), DRAGON_SQ_SHIELD(2366, 2368, 1187, player -> { if (player.getSkills().getLevel(Skills.SMITHING) < 60) { player.sendMessage(""You need 60 Smithing to work with the dragon metal.""); return false; } return true; }, player -> { player.itemDialogue(1187, ""Even for an experienced armorer it is not an easy task, but eventually it is ready. You have restored the dragon square shield to its former glory.""); player.getSkills().addXp(Skills.SMITHING, 75); }), SPECTRAL_SPIRIT_SHIELD(13752, 13736, 13744, player -> { if (player.getSkills().getLevel(Skills.SMITHING) < 85 || player.getSkills().getLevel(Skills.PRAYER) < 90) { player.sendMessage(""You need 85 Smithing and 90 Prayer to attach the sigil to the spirit shield.""); return false; } return true; }, player -> { player.itemDialogue(13744, ""You successfully attach the spectral sigil to the blessed spirit shield.""); player.getSkills().addXp(Skills.SMITHING, 1800); }), ARCANE_SPIRIT_SHIELD(13746, 13736, 13738, player -> { if (player.getSkills().getLevel(Skills.SMITHING) < 85 || player.getSkills().getLevel(Skills.PRAYER) < 90) { player.sendMessage(""You need 85 Smithing and 90 Prayer to attach the sigil to the spirit shield.""); return false; } return true; }, player -> { player.itemDialogue(13738, ""You successfully attach the arcane sigil to the blessed spirit shield.""); player.getSkills().addXp(Skills.SMITHING, 1800); }), ELYSIAN_SPIRIT_SHIELD(13750, 13736, 13742, player -> { if (player.getSkills().getLevel(Skills.SMITHING) < 85 || player.getSkills().getLevel(Skills.PRAYER) < 90) { player.sendMessage(""You need 85 Smithing and 90 Prayer to attach the sigil to the spirit shield.""); return false; } return true; }, player -> { player.itemDialogue(13742, ""You successfully attach the elysian sigil to the blessed spirit shield.""); player.getSkills().addXp(Skills.SMITHING, 1800); }), DIVINE_SPIRIT_SHIELD(13748, 13736, 13740, player -> { if (player.getSkills().getLevel(Skills.SMITHING) < 85 || player.getSkills().getLevel(Skills.PRAYER) < 90) { player.sendMessage(""You need 85 Smithing and 90 Prayer to attach the sigil to the spirit shield.""); return false; } return true; }, player -> { player.itemDialogue(13740, ""You successfully attach the divine sigil to the blessed spirit shield.""); player.getSkills().addXp(Skills.SMITHING, 1800); }); private final int item1; private final int item2; private final int productId; private final Function hasRequirements; private final Consumer onCreate; ForgeableItem(int item1, int item2, int productId, Function hasRequirements, Consumer onCreate) { this.item1 = item1; this.item2 = item2; this.productId = productId; this.hasRequirements = hasRequirements; this.onCreate = onCreate; } } public static ItemOnObjectHandler smithOnAnvil = new ItemOnObjectHandler(new Object[] { ""Anvil"" }, Arrays.stream(ForgeableItem.values()).flatMap(item -> Stream.of(item.item1, item.item2)).distinct().toArray(), e -> { List creatableItems = new ArrayList<>(); for (ForgeableItem item : ForgeableItem.values()) { if (e.getPlayer().getInventory().containsItem(item.item1) && e.getPlayer().getInventory().containsItem(item.item2)) creatableItems.add(item); } if (creatableItems.isEmpty()) { e.getPlayer().sendMessage(""You don't have all the items required to fix this.""); return; } Dialogue makeX = new Dialogue().addMakeX(creatableItems.stream().mapToInt(item -> item.productId).toArray()); for (ForgeableItem item : creatableItems) makeX.addNext(() -> { if (e.getPlayer().getInventory().containsItem(item.item1) && e.getPlayer().getInventory().containsItem(item.item2) && item.hasRequirements.apply(e.getPlayer())) { e.getPlayer().anim(898); e.getPlayer().getInventory().deleteItem(item.item1, 1); e.getPlayer().getInventory().deleteItem(item.item2, 1); e.getPlayer().getInventory().addItem(item.productId, 1); item.onCreate.accept(e.getPlayer()); } }); e.getPlayer().startConversation(makeX); }); public static ItemOnObjectHandler blessSpiritShield = new ItemOnObjectHandler(new Object[] { 409, 2640, 4008, 19145, 24343, 26287, 27661, 63207 }, new Object[] { 13754, 13734 }, e -> { if (!e.getPlayer().getInventory().containsItems(13754, 13734)) { e.getPlayer().sendMessage(""You need a spirit shield and a holy elixir to create a blessed spirit shield.""); return; } if (!e.getPlayer().isQuestComplete(Quest.SUMMERS_END, ""to bless a spirit shield."")) return; if (e.getPlayer().getSkills().getLevel(Skills.PRAYER) < 85) { e.getPlayer().sendMessage(""You need 85 Prayer to bless a spirit shield.""); return; } e.getPlayer().sendMessage(""You bless the spirit shield.""); e.getPlayer().anim(645); e.getPlayer().getInventory().deleteItem(13754, 1); e.getPlayer().getInventory().deleteItem(13734, 1); e.getPlayer().getInventory().addItemDrop(13736, 1); e.getPlayer().getSkills().addXp(Skills.PRAYER, 1500); }); }" "package com.rs.game.content.skills.smithing; @PluginEventHandler public class MoltenGlassMaking { public static int SODA_ASH = 1781; public static int BUCKET_OF_SAND = 1783; public static int MOLTEN_GLASS = 1775; private static final Item[][] materials = { { new Item(SODA_ASH), new Item(BUCKET_OF_SAND) } }; private static final Item[][] products = { { new Item(MOLTEN_GLASS), new Item(Ectofuntus.EMPTY_BUCKET) } }; private static final int[] reqs = { 1 }; private static final double[] xp = { 20 }; private static final int[] anims = { 3243 }; public static ItemOnObjectHandler handleCreate = new ItemOnObjectHandler(new Object[] { ""Furnace"" }, new Object[] { SODA_ASH, BUCKET_OF_SAND }, e -> openDialogue(e.getPlayer())); public static void openDialogue(Player player) { player.startConversation(new CreateActionD(player, materials, products, xp, anims, reqs, Constants.CRAFTING, 2)); } }" "package com.rs.game.content.skills.smithing; @PluginEventHandler public class Smelting extends PlayerAction { public enum SmeltingBar { BRONZE(1, 6.2, new Item[] { new Item(436), new Item(438) }, new Item(2349), 0), BLURITE(8, 8.0, new Item[] { new Item(668) }, new Item(9467), 1), IRON(15, 12.5, new Item[] { new Item(440) }, new Item(2351), 2), SILVER(20, 13.7, new Item[] { new Item(442) }, new Item(2355), 3), STEEL(30, 17.5, new Item[] { new Item(440), new Item(453, 2) }, new Item(2353), 4), GOLD(40, 22.5, new Item[] { new Item(444) }, new Item(2357), 5), MITHRIL(50, 30, new Item[] { new Item(447), new Item(453, 4) }, new Item(2359), 6), ADAMANT(70, 37.5, new Item[] { new Item(449), new Item(453, 6) }, new Item(2361), 7), RUNE(85, 50, new Item[] { new Item(451), new Item(453, 8) }, new Item(2363), 8), DRAGONBANE(80, 50, new Item[]{new Item(21779)}, new Item(21783, 1), 9), WALLASALKIBANE(80, 50, new Item[]{new Item(21780)}, new Item(21784, 1), 10), BASILISKBANE(80, 50, new Item[]{new Item(21781)}, new Item(21785, 1), 11), ABYSSSALBANE(80, 50, new Item[]{new Item(21782)}, new Item(21786, 1), 12) ; private static final Map bars = new HashMap<>(); private static final Map forOres = new HashMap<>(); private static final Map forBars = new HashMap<>(); public static SmeltingBar forId(int buttonId) { return bars.get(buttonId); } public static SmeltingBar forOre(Player player, int oreId) { //cast on iron, has coal, create steel. if (oreId == 440) if (player.getInventory().containsItem(453, 2) || (player.getInventory().containsItem(18339) && player.getI(""coalBag"") >= 2)) return SmeltingBar.STEEL; //cast on coal, has tertiary. if (oreId == 453) { if (player.getInventory().containsItem(451)) return SmeltingBar.RUNE; if (player.getInventory().containsItem(449)) return SmeltingBar.ADAMANT; if (player.getInventory().containsItem(447)) return SmeltingBar.MITHRIL; if (player.getInventory().containsItem(440)) return SmeltingBar.STEEL; } return forOres.get(oreId); } static { for (SmeltingBar bar : SmeltingBar.values()) { bars.put(bar.getButtonId(), bar); forBars.put(bar.getProducedBar().getId(), bar); for (Item item : bar.getItemsRequired()) { if (bar.getProducedBar().getId() == 2353) continue; forOres.put(item.getId(), bar); } } for (SmeltingBar bar : SmeltingBar.values()) for (Item item : bar.getItemsRequired()) { if (bar.getProducedBar().getId() == 2353) continue; forOres.put(item.getId(), bar); } } private final int levelRequired; private final double experience; private final Item[] itemsRequired; private final int buttonId; private final Item producedBar; private SmeltingBar(int levelRequired, double experience, Item[] itemsRequired, Item producedBar, int buttonId) { this.levelRequired = levelRequired; this.experience = experience; this.itemsRequired = itemsRequired; this.producedBar = producedBar; this.buttonId = buttonId; } public static SmeltingBar forBarId(int id) { return forBars.get(id); } public Item[] getItemsRequired() { return itemsRequired; } public int getLevelRequired() { return levelRequired; } public Item getProducedBar() { return producedBar; } public double getExperience() { return experience; } public int getButtonId() { return buttonId; } } public SmeltingBar bar; public GameObject object; public int ticks; public Smelting(SmeltingBar bar, GameObject object, int ticks) { this.object = object; this.bar = bar; this.ticks = ticks; } @Override public boolean start(Player player) { if (bar == null || player == null || object == null) return false; if (!player.getInventory().containsItem(bar.getItemsRequired()[0].getId(), bar.getItemsRequired()[0].getAmount())) { player.simpleDialogue(""You need "" + bar.getItemsRequired()[0].getDefinitions().getName() + "" to create a "" + bar.getProducedBar().getDefinitions().getName() + "".""); return false; } if (bar.getItemsRequired().length > 1) if (!player.getInventory().containsItem(bar.getItemsRequired()[1].getId(), bar.getItemsRequired()[1].getAmount()) && !(bar.getItemsRequired()[1].getId() == 453 && player.getInventory().containsItem(18339) && (player.getI(""coalBag"")+player.getInventory().getAmountOf(453)) >= bar.getItemsRequired()[1].getAmount())) { player.simpleDialogue(""You need "" + bar.getItemsRequired()[1].getDefinitions().getName() + "" to create a "" + bar.getProducedBar().getDefinitions().getName() + "".""); return false; } if (player.getSkills().getLevel(Constants.SMITHING) < bar.getLevelRequired()) { player.simpleDialogue(""You need a Smithing level of at least "" + bar.getLevelRequired() + "" to smelt "" + bar.getProducedBar().getDefinitions().getName()); return false; } player.sendMessage(""You place the required ores and attempt to create a bar of "" + bar.getProducedBar().getDefinitions().getName().toLowerCase().replace("" bar"", """") + ""."", true); return true; } @Override public boolean process(Player player) { if (bar == null || player == null || object == null) return false; if (!player.getInventory().containsItem(bar.getItemsRequired()[0].getId(), bar.getItemsRequired()[0].getAmount())) { player.simpleDialogue(""You need "" + bar.getItemsRequired()[0].getDefinitions().getName() + "" to create a "" + bar.getProducedBar().getDefinitions().getName() + "".""); return false; } if (bar.getItemsRequired().length > 1) if (!player.getInventory().containsItem(bar.getItemsRequired()[1].getId(), bar.getItemsRequired()[1].getAmount()) && !(bar.getItemsRequired()[1].getId() == 453 && player.getInventory().containsItem(18339) && (player.getI(""coalBag"")+player.getInventory().getAmountOf(453)) >= bar.getItemsRequired()[1].getAmount())) { player.simpleDialogue(""You need "" + bar.getItemsRequired()[1].getDefinitions().getName() + "" to create a "" + bar.getProducedBar().getDefinitions().getName() + "".""); return false; } if (player.getSkills().getLevel(Constants.SMITHING) < bar.getLevelRequired()) { player.simpleDialogue(""You need a Smithing level of at least "" + bar.getLevelRequired() + "" to smelt "" + bar.getProducedBar().getDefinitions().getName()); return false; } player.faceObject(object); return true; } public boolean isSuccessfull(Player player) { if (bar == SmeltingBar.IRON) { if ((player.getEquipment().getItem(Equipment.RING) == null) || (player.getEquipment().getItem(Equipment.RING).getId() != 2568)) return Utils.random(100) <= (player.getSkills().getLevel(Constants.SMITHING) >= 45 ? 80 : 50); player.ringOfForgingCharges--; if (player.ringOfForgingCharges <= 0) { player.getEquipment().deleteSlot(Equipment.RING); player.sendMessage(""Your ring of forging disintegrates with all of the heat.""); player.ringOfForgingCharges = 140; } return true; } return true; } @Override public int processWithDelay(Player player) { ticks--; player.setNextAnimation(new Animation(3243)); smeltBar(player); int[] range = VARROCK_ARMOR_BAR_TIERS.get(bar); if (range != null && Arrays.stream(SetReward.VARROCK_ARMOR.getItemIds(), range[0], range[1]).anyMatch(x -> x == player.getEquipment().getChestId()) && Utils.random(100) <= 10) smeltBar(player); if (ticks > 0) return 2; return -1; } private static final Map VARROCK_ARMOR_BAR_TIERS = Map.of( SmeltingBar.BRONZE, new int[] { 0, 4 }, SmeltingBar.IRON, new int[] { 0, 4 }, SmeltingBar.STEEL, new int[] { 0, 4 }, SmeltingBar.GOLD, new int[] { 0, 4 }, SmeltingBar.MITHRIL, new int[] { 1, 4 }, SmeltingBar.ADAMANT, new int[] { 2, 4 }, SmeltingBar.RUNE, new int[] { 3, 4 } ); public void smeltBar(Player player) { for (Item required : bar.getItemsRequired()) if (required.getId() == 453 && player.getInventory().containsItem(18339) && player.getI(""coalBag"") > 0) { int coalBag = player.getI(""coalBag""); if (coalBag > required.getAmount()) player.save(""coalBag"", coalBag - required.getAmount()); else { player.save(""coalBag"", 0); player.getInventory().deleteItem(453, required.getAmount()-coalBag); } } else player.getInventory().deleteItem(required.getId(), required.getAmount()); if (isSuccessfull(player)) { if (bar == SmeltingBar.GOLD && player.getEquipment().getGlovesId() == 776) player.getSkills().addXp(Constants.SMITHING, 56.2); else player.getSkills().addXp(Constants.SMITHING, bar.getExperience()); player.getInventory().addItem(bar.getProducedBar()); player.sendMessage(""You retrieve a bar of "" + bar.getProducedBar().getDefinitions().getName().toLowerCase().replace("" bar"", """") + ""."", true); } else player.sendMessage(""The ore is too impure and you fail to refine it."", true); } @Override public void stop(Player player) { setActionDelay(player, 3); } public static ItemClickHandler checkChargesRingOfForging = new ItemClickHandler(new Object[] { 2568 }, new String[] { ""Check"" }, e -> e.getPlayer().sendMessage(""You have "" + e.getPlayer().ringOfForgingCharges + "" charges remaining in your ring of forging."")); }" "package com.rs.game.content.skills.smithing; public class SmeltingD extends Conversation { public SmeltingD(Player player, GameObject object) { super(player); List bars = new ArrayList<>(); for (SmeltingBar bar : SmeltingBar.values()) if (player.getInventory().containsItems(bar.getItemsRequired()) && player.getSkills().getLevel(Skills.SMITHING) >= bar.getLevelRequired()) bars.add(bar); if (bars.isEmpty()) { addSimple(""You don't have any ores that you are skilled enough to smelt.""); create(); return; } Dialogue makeX = addNext(new MakeXStatement(bars.stream().mapToInt(bar -> bar.getProducedBar().getId()).toArray())); for (SmeltingBar bar : bars) makeX.addNext(() -> player.getActionManager().setAction(new Smelting(bar, object, MakeXStatement.getQuantity(player)))); create(); } }" "package com.rs.game.content.skills.smithing; @PluginEventHandler public class Smithing extends PlayerAction { public static ItemOnObjectHandler barsOnAnvil = new ItemOnObjectHandler(new Object[] { ""Anvil"" }, Arrays.stream(Smelting.SmeltingBar.values()).map(bar -> bar.getProducedBar().getId()).toArray(), e -> { if (e.getObject().getDefinitions(e.getPlayer()).containsOption(""Smith"")) ForgingInterface.sendSmithingInterface(e.getPlayer(), e.getObject(), e.getItem().getId()); }); public static ObjectClickHandler smithAnvil = new ObjectClickHandler(new Object[] { ""Anvil"", ""Kethsian anvil"" }, e -> { if (e.getOption().equals(""Smith"")) ForgingInterface.openSmithingInterfaceForHighestBar(e.getPlayer(), e.getObject()); }); public enum Smithable { BRONZE_ARROWHEADS(Slot.ARROW_TIPS, new Item(39, 15), 5, 12.5, new Item(2349, 1)), IRON_ARROWHEADS(Slot.ARROW_TIPS, new Item(40, 15), 20, 25.0, new Item(2351, 1)), STEEL_ARROWHEADS(Slot.ARROW_TIPS, new Item(41, 15), 35, 37.5, new Item(2353, 1)), MITHRIL_ARROWHEADS(Slot.ARROW_TIPS, new Item(42, 15), 55, 50.0, new Item(2359, 1)), ADAMANT_ARROWHEADS(Slot.ARROW_TIPS, new Item(43, 15), 75, 62.5, new Item(2361, 1)), RUNE_ARROWHEADS(Slot.ARROW_TIPS, new Item(44, 15), 90, 75.0, new Item(2363, 1)), BRONZE_DART_TIP(Slot.DART_TIPS, new Item(819, 10), 4, 12.5, new Item(2349, 1)), IRON_DART_TIP(Slot.DART_TIPS, new Item(820, 10), 19, 25.0, new Item(2351, 1)), STEEL_DART_TIP(Slot.DART_TIPS, new Item(821, 10), 34, 37.5, new Item(2353, 1)), MITHRIL_DART_TIP(Slot.DART_TIPS, new Item(822, 10), 54, 50.0, new Item(2359, 1)), ADAMANT_DART_TIP(Slot.DART_TIPS, new Item(823, 10), 74, 62.5, new Item(2361, 1)), RUNE_DART_TIP(Slot.DART_TIPS, new Item(824, 10), 89, 75.0, new Item(2363, 1)), IRON_KNIFE(Slot.THROWING_KNIFE, new Item(863, 5), 22, 25.0, new Item(2351, 1)), BRONZE_KNIFE(Slot.THROWING_KNIFE, new Item(864, 5), 7, 12.5, new Item(2349, 1)), STEEL_KNIFE(Slot.THROWING_KNIFE, new Item(865, 5), 37, 37.5, new Item(2353, 1)), MITHRIL_KNIFE(Slot.THROWING_KNIFE, new Item(866, 5), 57, 50.0, new Item(2359, 1)), ADAMANT_KNIFE(Slot.THROWING_KNIFE, new Item(867, 5), 77, 62.5, new Item(2361, 1)), RUNE_KNIFE(Slot.THROWING_KNIFE, new Item(868, 5), 92, 75.0, new Item(2363, 1)), IRON_CHAINBODY(Slot.CHAINBODY, new Item(1101, 1), 26, 75.0, new Item(2351, 3)), BRONZE_CHAINBODY(Slot.CHAINBODY, new Item(1103, 1), 11, 37.0, new Item(2349, 3)), STEEL_CHAINBODY(Slot.CHAINBODY, new Item(1105, 1), 41, 112.0, new Item(2353, 3)), MITHRIL_CHAINBODY(Slot.CHAINBODY, new Item(1109, 1), 61, 150.0, new Item(2359, 3)), ADAMANT_CHAINBODY(Slot.CHAINBODY, new Item(1111, 1), 81, 187.0, new Item(2361, 3)), RUNE_CHAINBODY(Slot.CHAINBODY, new Item(1113, 1), 96, 225.0, new Item(2363, 3)), IRON_PLATEBODY(Slot.PLATEBODY, new Item(1115, 1), 33, 125.0, new Item(2351, 5)), BRONZE_PLATEBODY(Slot.PLATEBODY, new Item(1117, 1), 18, 62.0, new Item(2349, 5)), STEEL_PLATEBODY(Slot.PLATEBODY, new Item(1119, 1), 48, 187.0, new Item(2353, 5)), MITHRIL_PLATEBODY(Slot.PLATEBODY, new Item(1121, 1), 68, 250.0, new Item(2359, 5)), ADAMANT_PLATEBODY(Slot.PLATEBODY, new Item(1123, 1), 88, 312.0, new Item(2361, 5)), RUNE_PLATEBODY(Slot.PLATEBODY, new Item(1127, 1), 99, 375.0, new Item(2363, 5)), IRON_PLATELEGS(Slot.PLATELEGS, 1067, 31, 75.0, new Item(2351, 3)), STEEL_PLATELEGS(Slot.PLATELEGS, 1069, 46, 112.5, new Item(2353, 3)), MITHRIL_PLATELEGS(Slot.PLATELEGS, 1071, 66, 150.0, new Item(2359, 3)), ADAMANT_PLATELEGS(Slot.PLATELEGS, 1073, 86, 187.5, new Item(2361, 3)), BRONZE_PLATELEGS(Slot.PLATELEGS, 1075, 16, 37.5, new Item(2349, 3)), RUNE_PLATELEGS(Slot.PLATELEGS, 1079, 99, 225.0, new Item(2363, 3)), IRON_PLATESKIRT(Slot.PLATESKIRT, 1081, 31, 75.0, new Item(2351, 3)), STEEL_PLATESKIRT(Slot.PLATESKIRT, 1083, 46, 112.5, new Item(2353, 3)), MITHRIL_PLATESKIRT(Slot.PLATESKIRT, 1085, 66, 150.0, new Item(2359, 3)), BRONZE_PLATESKIRT(Slot.PLATESKIRT, 1087, 16, 37.5, new Item(2349, 3)), ADAMANT_PLATESKIRT(Slot.PLATESKIRT, 1091, 86, 187.5, new Item(2361, 3)), RUNE_PLATESKIRT(Slot.PLATESKIRT, 1093, 99, 225.0, new Item(2363, 3)), IRON_HELM(Slot.MEDIUM_HELM, 1137, 18, 25.0, new Item(2351, 1)), BRONZE_HELM(Slot.MEDIUM_HELM, 1139, 1, 12.5, new Item(2349, 1)), STEEL_HELM(Slot.MEDIUM_HELM, 1141, 33, 37.5, new Item(2353, 1)), MITHRIL_HELM(Slot.MEDIUM_HELM, 1143, 53, 50.0, new Item(2359, 1)), ADAMANT_HELM(Slot.MEDIUM_HELM, 1145, 73, 62.5, new Item(2361, 1)), RUNE_HELM(Slot.MEDIUM_HELM, 1147, 88, 75.0, new Item(2363, 1)), IRON_FULL_HELM(Slot.FULL_HELM, 1153, 22, 50.0, new Item(2351, 2)), BRONZE_FULL_HELM(Slot.FULL_HELM, 1155, 7, 25.0, new Item(2349, 2)), STEEL_FULL_HELM(Slot.FULL_HELM, 1157, 37, 75.0, new Item(2353, 2)), MITHRIL_FULL_HELM(Slot.FULL_HELM, 1159, 57, 100.0, new Item(2359, 2)), ADAMANT_FULL_HELM(Slot.FULL_HELM, 1161, 77, 125.0, new Item(2361, 2)), RUNE_FULL_HELM(Slot.FULL_HELM, 1163, 92, 150.0, new Item(2363, 2)), BRONZE_SQ_SHIELD(Slot.SQUARE_SHIELD, 1173, 8, 25.0, new Item(2349, 2)), IRON_SQ_SHIELD(Slot.SQUARE_SHIELD, 1175, 23, 50.0, new Item(2351, 2)), STEEL_SQ_SHIELD(Slot.SQUARE_SHIELD, 1177, 38, 75.0, new Item(2353, 2)), MITHRIL_SQ_SHIELD(Slot.SQUARE_SHIELD, 1181, 58, 100.0, new Item(2359, 2)), ADAMANT_SQ_SHIELD(Slot.SQUARE_SHIELD, 1183, 78, 125.0, new Item(2361, 2)), RUNE_SQ_SHIELD(Slot.SQUARE_SHIELD, 1185, 93, 150.0, new Item(2363, 2)), BRONZE_KITESHIELD(Slot.KITESHIELD, 1189, 12, 37.5, new Item(2349, 3)), IRON_KITESHIELD(Slot.KITESHIELD, 1191, 27, 75.0, new Item(2351, 3)), STEEL_KITESHIELD(Slot.KITESHIELD, 1193, 42, 112.5, new Item(2353, 3)), MITHRIL_KITESHIELD(Slot.KITESHIELD, 1197, 62, 150.0, new Item(2359, 3)), ADAMANT_KITESHIELD(Slot.KITESHIELD, 1199, 82, 187.5, new Item(2361, 3)), RUNE_KITESHIELD(Slot.KITESHIELD, 1201, 97, 225.0, new Item(2363, 3)), IRON_DAGGER(Slot.DAGGER, 1203, 15, 25.0, new Item(2351, 1)), BRONZE_DAGGER(Slot.DAGGER, 1205, 1, 12.5, new Item(2349, 1)), STEEL_DAGGER(Slot.DAGGER, 1207, 30, 37.5, new Item(2353, 1)), MITHRIL_DAGGER(Slot.DAGGER, 1209, 50, 50.0, new Item(2359, 1)), ADAMANT_DAGGER(Slot.DAGGER, 1211, 70, 62.5, new Item(2361, 1)), RUNE_DAGGER(Slot.DAGGER, 1213, 85, 75.0, new Item(2363, 1)), BRONZE_PICKAXE(Slot.PICKAXE, 1265, 5, 25.0, new Item(2349, 2)), IRON_PICKAXE(Slot.PICKAXE, 1267, 20, 50.0, new Item(2351, 2)), STEEL_PICKAXE(Slot.PICKAXE, 1269, 35, 75.0, new Item(2353, 2)), ADAMANT_PICKAXE(Slot.PICKAXE, 1271, 75, 125.0, new Item(2361, 2)), MITHRIL_PICKAXE(Slot.PICKAXE, 1273, 55, 100.0, new Item(2359, 2)), RUNE_PICKAXE(Slot.PICKAXE, 1275, 90, 150.0, new Item(2363, 2)), BRONZE_SWORD(Slot.SWORD, 1277, 4, 12.5, new Item(2349, 1)), IRON_SWORD(Slot.SWORD, 1279, 19, 25.0, new Item(2351, 1)), STEEL_SWORD(Slot.SWORD, 1281, 34, 37.5, new Item(2353, 1)), MITHRIL_SWORD(Slot.SWORD, 1285, 54, 50.0, new Item(2359, 1)), ADAMANT_SWORD(Slot.SWORD, 1287, 74, 62.5, new Item(2361, 1)), RUNE_SWORD(Slot.SWORD, 1289, 89, 75.0, new Item(2363, 1)), BRONZE_LONGSWORD(Slot.LONGSWORD, 1291, 6, 25.0, new Item(2349, 2)), IRON_LONGSWORD(Slot.LONGSWORD, 1293, 21, 50.0, new Item(2351, 2)), STEEL_LONGSWORD(Slot.LONGSWORD, 1295, 36, 75.0, new Item(2353, 2)), MITHRIL_LONGSWORD(Slot.LONGSWORD, 1299, 56, 100.0, new Item(2359, 2)), ADAMANT_LONGSWORD(Slot.LONGSWORD, 1301, 76, 125.0, new Item(2361, 2)), RUNE_LONGSWORD(Slot.LONGSWORD, 1303, 91, 150.0, new Item(2363, 2)), BRONZE_2H_SWORD(Slot.TWO_HAND_SWORD, 1307, 14, 37.5, new Item(2349, 3)), IRON_2H_SWORD(Slot.TWO_HAND_SWORD, 1309, 29, 75.0, new Item(2351, 3)), STEEL_2H_SWORD(Slot.TWO_HAND_SWORD, 1311, 44, 112.5, new Item(2353, 3)), MITHRIL_2H_SWORD(Slot.TWO_HAND_SWORD, 1315, 64, 150.0, new Item(2359, 3)), ADAMANT_2H_SWORD(Slot.TWO_HAND_SWORD, 1317, 84, 187.5, new Item(2361, 3)), RUNE_2H_SWORD(Slot.TWO_HAND_SWORD, 1319, 99, 225.0, new Item(2363, 3)), BRONZE_SCIMITAR(Slot.SCIMITAR, 1321, 5, 25.0, new Item(2349, 2)), IRON_SCIMITAR(Slot.SCIMITAR, 1323, 20, 50.0, new Item(2351, 2)), STEEL_SCIMITAR(Slot.SCIMITAR, 1325, 35, 75.0, new Item(2353, 2)), MITHRIL_SCIMITAR(Slot.SCIMITAR, 1329, 55, 100.0, new Item(2359, 2)), ADAMANT_SCIMITAR(Slot.SCIMITAR, 1331, 75, 125.0, new Item(2361, 2)), RUNE_SCIMITAR(Slot.SCIMITAR, 1333, 90, 150.0, new Item(2363, 2)), IRON_WARHAMMER(Slot.WARHAMMER, 1335, 24, 75.0, new Item(2351, 3)), BRONZE_WARHAMMER(Slot.WARHAMMER, 1337, 9, 37.5, new Item(2349, 3)), STEEL_WARHAMMER(Slot.WARHAMMER, 1339, 39, 112.5, new Item(2353, 3)), MITHRIL_WARHAMMER(Slot.WARHAMMER, 1343, 59, 150.0, new Item(2359, 3)), ADAMANT_WARHAMMER(Slot.WARHAMMER, 1345, 79, 187.5, new Item(2361, 3)), RUNE_WARHAMMER(Slot.WARHAMMER, 1347, 94, 225.0, new Item(2363, 3)), IRON_HATCHET(Slot.HATCHET, 1349, 16, 25.0, new Item(2351, 1)), BRONZE_HATCHET(Slot.HATCHET, 1351, 1, 12.5, new Item(2349, 1)), STEEL_HATCHET(Slot.HATCHET, 1353, 31, 37.5, new Item(2353, 1)), MITHRIL_HATCHET(Slot.HATCHET, 1355, 51, 50.0, new Item(2359, 1)), ADAMANT_HATCHET(Slot.HATCHET, 1357, 71, 62.5, new Item(2361, 1)), RUNE_HATCHET(Slot.HATCHET, 1359, 86, 75.0, new Item(2363, 1)), IRON_BATTLEAXE(Slot.BATTLEAXE, 1363, 25, 75.0, new Item(2351, 3)), STEEL_BATTLEAXE(Slot.BATTLEAXE, 1365, 40, 112.5, new Item(2353, 3)), MITHRIL_BATTLEAXE(Slot.BATTLEAXE, 1369, 60, 150.0, new Item(2359, 3)), ADAMANT_BATTLEAXE(Slot.BATTLEAXE, 1371, 80, 187.5, new Item(2361, 3)), RUNE_BATTLEAXE(Slot.BATTLEAXE, 1373, 95, 225.0, new Item(2363, 3)), BRONZE_BATTLEAXE(Slot.BATTLEAXE, 1375, 10, 37.5, new Item(2349, 3)), IRON_MACE(Slot.MACE, 1420, 17, 25.0, new Item(2351, 1)), BRONZE_MACE(Slot.MACE, 1422, 2, 12.5, new Item(2349, 1)), STEEL_MACE(Slot.MACE, 1424, 32, 37.5, new Item(2353, 1)), MITHRIL_MACE(Slot.MACE, 1428, 52, 50.0, new Item(2359, 1)), ADAMANT_MACE(Slot.MACE, 1430, 72, 62.5, new Item(2361, 1)), RUNE_MACE(Slot.MACE, 1432, 87, 75.0, new Item(2363, 1)), BRONZE_NAILS(Slot.NAILS, new Item(4819, 15), 4, 12.5, new Item(2349, 1)), IRON_NAILS(Slot.NAILS, new Item(4820, 15), 19, 25.0, new Item(2351, 1)), STEEL_NAILS(Slot.NAILS, new Item(1539, 15), 34, 37.5, new Item(2353, 1)), MITHRIL_NAILS(Slot.NAILS, new Item(4822, 15), 54, 50.0, new Item(2359, 1)), ADAMANTITE_NAILS(Slot.NAILS, new Item(4823, 15), 74, 62.5, new Item(2361, 1)), RUNE_NAILS(Slot.NAILS, new Item(4824, 15), 89, 75.0, new Item(2363, 1)), BRONZE_WIRE(Slot.BRONZE_WIRE, 1794, 4, 12.5, new Item(2349, 1)), STEEL_STUDS(Slot.STUDS, 2370, 36, 37.5, new Item(2353, 1)), BRONZE_CLAW(Slot.CLAWS, 3095, 13, 25.0, new Item(2349, 2)), IRON_CLAW(Slot.CLAWS, 3096, 28, 50.0, new Item(2351, 2)), STEEL_CLAW(Slot.CLAWS, 3097, 43, 75.0, new Item(2353, 2)), MITHRIL_CLAW(Slot.CLAWS, 3099, 63, 100.0, new Item(2359, 2)), ADAMANT_CLAW(Slot.CLAWS, 3100, 83, 125.0, new Item(2361, 2)), RUNE_CLAW(Slot.CLAWS, 3101, 98, 150.0, new Item(2363, 2)), OIL_LANTERN_FRAME(Slot.BULLSEYE_LANTERN, 4540, 26, 25.0, new Item(2351, 1)), BULLSEYE_LANTERN(Slot.BULLSEYE_LANTERN, 4544, 49, 37.5, new Item(2353, 1)), IRON_SPIT(Slot.SPIT_IRON, 7225, 17, 25.0, new Item(2351, 1)), BRONZE_BOLTS_UNF(Slot.CROSSBOW_BOLTS, new Item(9375, 10), 3, 12.5, new Item(2349, 1)), BLURITE_BOLTS_UNF(Slot.CROSSBOW_BOLTS, new Item(9376, 10), 8, 17.5, new Item(9467, 1)), IRON_BOLTS_UNF(Slot.CROSSBOW_BOLTS, new Item(9377, 10), 18, 25.0, new Item(2351, 1)), STEEL_BOLTS_UNF(Slot.CROSSBOW_BOLTS, new Item(9378, 10), 33, 37.5, new Item(2353, 1)), MITHRIL_BOLTS_UNF(Slot.CROSSBOW_BOLTS, new Item(9379, 10), 53, 50.0, new Item(2359, 1)), ADAMANT_BOLTS_UNF(Slot.CROSSBOW_BOLTS, new Item(9380, 10), 73, 62.5, new Item(2361, 1)), RUNITE_BOLTS_UNF(Slot.CROSSBOW_BOLTS, new Item(9381, 10), 88, 75.0, new Item(2363, 1)), MITH_GRAPPLE_TIP(Slot.GRAPPLE_TIP, 9416, 59, 50.0, new Item(2359, 1)), BRONZE_LIMBS(Slot.CROSSBOW_LIMBS, 9420, 6, 12.5, new Item(2349, 1)), BLURITE_LIMBS(Slot.CROSSBOW_LIMBS, 9422, 13, 17.5, new Item(9467, 1)), IRON_LIMBS(Slot.CROSSBOW_LIMBS, 9423, 23, 25.0, new Item(2351, 1)), STEEL_LIMBS(Slot.CROSSBOW_LIMBS, 9425, 36, 37.5, new Item(2353, 1)), MITHRIL_LIMBS(Slot.CROSSBOW_LIMBS, 9427, 56, 50.0, new Item(2359, 1)), ADAMANTITE_LIMBS(Slot.CROSSBOW_LIMBS, 9429, 76, 62.5, new Item(2361, 1)), RUNITE_LIMBS(Slot.CROSSBOW_LIMBS, 9431, 91, 75.0, new Item(2363, 1)), BLURITE_SWORD(Slot.SWORD, 667, 8, 17.5, new Item(9467, 1)), DRAGONBANE_ARROWTIPS(Slot.ARROW_TIPS, new Item(21823, 50), 80, 62.5, new Item(21783, 1)), WALLASALKIBANE_ARROWTIPS(Slot.ARROW_TIPS, new Item(21828, 50), 80, 62.5, new Item(21784, 1)), BASILISKBANE_ARROWTIPS(Slot.ARROW_TIPS, new Item(21833, 50), 80, 62.5, new Item(21785, 1)), ABYSSALBANE_ARROWTIPS(Slot.ARROW_TIPS, new Item(21838, 50), 80, 62.5, new Item(21786, 1)), DRAGONBANE_BOLTS(Slot.CROSSBOW_BOLTS, new Item(21843, 50), 80, 62.5, new Item(21783, 1)), WALLASALKIBANE_BOLTS(Slot.CROSSBOW_BOLTS, new Item(21853, 50), 80, 62.5, new Item(21784, 1)), BASILISKBANE_BOLTS(Slot.CROSSBOW_BOLTS, new Item(21848, 50), 80, 62.5, new Item(21785, 1)), ABYSSALBANE_BOLTS(Slot.CROSSBOW_BOLTS, new Item(21858, 50), 80, 62.5, new Item(21786, 1)), ; private static final Map> BAR_MAP = new HashMap<>(); static { for (Smithable s : Smithable.values()) { Map map = BAR_MAP.get(s.bar.getId()); if (map == null) map = new HashMap<>(); if (map.put(s.slot, s) != null) System.err.println(""Duplicate slots for "" + s.slot + "" "" + s); BAR_MAP.put(s.bar.getId(), map); } } public final Slot slot; public final Item product; public final Item bar; public final int level; public final double xp; public static int getHighestBar(Player player) { int highest = -1; for (Item item : player.getInventory().getItems().getItemsCopy()) { if (item == null) continue; if (forBar(item.getId()) != null && item.getId() > highest) highest = item.getId(); } return highest; } public static Map forBar(int barId) { return BAR_MAP.get(barId); } Smithable(Slot slot, Item product, int level, double xp, Item bar) { this.product = product; this.level = level; this.xp = xp; this.bar = bar; this.slot = slot; } Smithable(Slot slot, int product, int level, double xp, Item bar) { this(slot, new Item(product, 1), level, xp, bar); } Smithable(Item product, int level, double xp, Item bar) { this(null, product, level, xp, bar); } Smithable(int product, int level, double xp, Item bar) { this(null, new Item(product, 1), level, xp, bar); } } public static final int HAMMER = 2347, DUNG_HAMMER = 17883; private final GameObject anvil; private final Smithable item; private int ticks; public Smithing(int ticks, Smithable item, GameObject anvil) { this.ticks = ticks; this.item = item; this.anvil = anvil; } @Override public boolean process(Player player) { if (!player.getInventory().containsItem(HAMMER, 1)) { player.sendMessage(""You need a hammer in order to work with a bar of "" + item.bar.getDefinitions().getName().toLowerCase().replace("" bar"", """") + "".""); return false; } if (!player.getInventory().containsItem(item.bar)) { player.sendMessage(""You do not have sufficient bars!""); return false; } if (player.getSkills().getLevel(Constants.SMITHING) < item.level) { player.sendMessage(""You need a Smithing level of "" + item.level + "" to create this.""); return false; } if (player.getInterfaceManager().containsScreenInter()) { player.getInterfaceManager().removeCentralInterface(); return true; } return true; } @Override public int processWithDelay(Player player) { ticks--; player.setNextAnimation(new Animation(898)); int amount = item.bar.getAmount(); if (player.hasScrollOfEfficiency && amount > 3) if (Utils.random(15) < 5) amount--; player.getInventory().deleteItem(item.bar.getId(), amount); player.getInventory().addItemDrop(new Item(item.product)); player.incrementCount(item.product.getName() + "" smithed"", item.product.getAmount()); player.getSkills().addXp(Constants.SMITHING, item.xp); if (ticks > 0) return 3; return -1; } @Override public boolean start(Player player) { if (item.bar.getId() != player.getTempAttribs().getI(""SmithingBar"")) return false; if (!player.getInventory().containsOneItem(HAMMER, item.bar.getId())) { player.sendMessage(""You need a hammer in order to work with a bar of "" + item.bar.getDefinitions().getName().replace(""Bar "", """") + "".""); return false; } if (player.getSkills().getLevel(Constants.SMITHING) < item.level) { player.sendMessage(""You need a Smithing level of "" + item.level + "" to create this.""); return false; } switch(item.bar.getId()) { case 21783, 21784, 21785, 21786 -> { if (!player.isQuestComplete(Quest.RITUAL_OF_MAHJARRAT, ""to smith banite equipment."")) return false; if (anvil.getId() != 6648) { player.sendMessage(""You can't figure out a way to work that metal on this anvil.""); return false; } } } return true; } @Override public void stop(Player player) { setActionDelay(player, 3); } }" "package com.rs.game.content.skills.summoning; @PluginEventHandler public class DismissD extends Conversation { public DismissD(Player p) { super(p); addOptions(p.getPet() != null ? ""Free pet?"" : ""Dismiss Familiar?"", new Options() { @Override public void create() { if(p.getFamiliar() != null) option(""Yes."", new Dialogue() .addNext(()-> { if (p.getFamiliar() != null) p.getFamiliar().dismiss(); }) ); else if(p.getPet() != null) option(""Yes."", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Run along; I'm setting you free."") .addNext(()->{ p.getPetManager().setNpcId(-1); p.getPetManager().setItemId(-1); p.getPetManager().removeDetails(p.getPet().getItemId()); p.getPackets().sendRunScript(2471); p.getInterfaceManager().removeSub(InterfaceManager.Sub.TAB_FOLLOWER); p.getPet().finish(); p.setPet(null); p.sendMessage(""Your pet runs off until it's out of sight.""); }) ); option(""No."", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, """") ); } }); } }" "package com.rs.game.content.skills.summoning; @PluginEventHandler public class EnchantedHeadwear { public enum Headwear { ADAMANT_FULL_HELM (1161, 12658, 12659, 1, 50), RUNE_FULL_HELM (1163, 12664, 12665, 30, 60), DRAGON_HELM (6967, 12666, 12667, 50, 110), BERSERKER_HELM (3751, 12674, 12675, 30, 70), WARRIOR_HELM (3753, 12676,12677, 30, 70), HELM_OF_NEITIZNOT (10828, 12680, 12681, 45, 90), SNAKESKIN_BANDANA (6326, 12660, 12661, 20, 50), ARCHER_HELM (3749, 12672, 12673, 30, 70), ARMADYL_HELMET (11718, 12670, 12671, 60, 120), SPLITBARK_HELM (3385, 12662, 12663, 30, 50), FARSEER_HELM (3755, 12678, 12679, 30, 70), LUNAR_HELM (10609, 12668, 12669, 55, 110), SLAYER_HELMET (13263, 14636, 14637, 20, 50), FULL_SLAYER_HELMET (15492, 15496, 15497, 20, 50), RED_FULL_SLAYER_HELMET (22528, 22530, 22532, 20, 50), BLUE_FULL_SLAYER_HELMET (22534, 22536, 22538, 20, 50), GREEN_FULL_SLAYER_HELMET (22540, 22542, 22544, 20, 50), YELLOW_FULL_SLAYER_HELMET (22546, 22548, 22550, 20, 50), BLUE_FEATHER_HEADDRESS (12210, 12210, 12212, 50, 40), YELLOW_FEATHER_HEADDRESS (12213, 12213, 12215, 50, 40), RED_FEATHER_HEADDRESS (12216, 12216, 12218, 50, 40), STRIPY_FEATHER_HEADDRESS (12219, 12219, 12221, 50, 40), ORANGE_FEATHER_HEADDRESS (12222, 12222, 12224, 50, 40), ANTLERS (12204, 12204, 12206, 10, 40), LIZARD_SKULL (12207, 12207, 12209, 30, 65); private static final Map MAP = new HashMap<>(); static { for (Headwear h : Headwear.values()) { MAP.put(h.baseId, h); MAP.put(h.chargedId, h); MAP.put(h.enchantedId, h); } } final int baseId; final int enchantedId; final int chargedId; final int summReq; final int scrollLimit; Headwear(int id, int enchantedId, int chargedId, int summoningLevel, int scrolls) { this.baseId = id; this.enchantedId = enchantedId; this.chargedId = chargedId; this.summReq = summoningLevel; this.scrollLimit = scrolls; } public static Headwear forId(int id) { return MAP.get(id); } } public static ItemOnNPCHandler headwearOnPikkupstix = new ItemOnNPCHandler(6988, e -> { Headwear helm = Headwear.forId(e.getItem().getId()); if (helm != null) { if (e.getPlayer().getSkills().getLevelForXp(Constants.SUMMONING) < helm.summReq) { e.getPlayer().sendMessage(""You must have a summoning level of "" + helm.summReq + "" to enchant this.""); return; } if (e.getItem().getId() == helm.baseId) { e.getItem().setId(helm.enchantedId); e.getPlayer().getInventory().refresh(e.getItem().getSlot()); e.getPlayer().sendMessage(""Pikkupstix magically enchants your headwear.""); return; } if (e.getItem().getId() == helm.enchantedId) { e.getItem().setId(helm.baseId); e.getPlayer().getInventory().refresh(e.getItem().getSlot()); e.getPlayer().sendMessage(""Pikkupstix removes the enchantment from your headwear.""); return; } if (e.getItem().getId() == helm.chargedId) { e.getPlayer().sendMessage(""You need to remove your scrolls before unenchanting the helmet.""); return; } } }); public static ItemEquipHandler canEquipCharged = new ItemEquipHandler(Arrays.stream(Headwear.values()).map(h -> h.chargedId).toArray(), e -> { if (e.equip() && !ItemConstants.canWear(new Item(Headwear.forId(e.getItem().getId()).baseId, 1), e.getPlayer())) e.cancel(); }); public static ItemEquipHandler canEquipEnchanted = new ItemEquipHandler(Arrays.stream(Headwear.values()).map(h -> h.enchantedId).toArray(), e -> { if (e.equip() && !ItemConstants.canWear(new Item(Headwear.forId(e.getItem().getId()).baseId, 1), e.getPlayer())) e.cancel(); }); // public static NPCClickHandler pikkupstixEnchanting = new NPCClickHandler(new Object[] { 6988 }, e -> { // if (e.getOpNum() == 1) // e.getPlayer().startConversation(new GenericSkillcapeOwnerD(e.getPlayer(), 6988, Skillcapes.Summoning)); // else if (e.getOpNum() == 3) // ShopsHandler.openShop(e.getPlayer(), ""taverly_summoning_shop""); // else if (e.getOpNum() == 4) { // if (e.getPlayer().getInventory().getFreeSlots() < 28) { // for (Item i : e.getPlayer().getInventory().getItems().array()) { // if ((i != null) && (Headwear.forId(i.getId()) != null)) { // e.getPlayer().startConversation(new Dialogue().addSimple(""That is a fine piece of headwear you have there. If you give me a closer look, I may be able to enchant it."")); // return; // } // } // } // e.getPlayer().startConversation(new Dialogue().addSimple(""If you bring me the right headwear, I may be able to assist in enchanting it."")); // } // }); public static ItemOnItemHandler chargeUncharged = new ItemOnItemHandler(Arrays.stream(Headwear.values()).mapToInt(h -> h.enchantedId).toArray(), Arrays.stream(Scroll.values()).mapToInt(Scroll::getId).toArray(), e -> { Headwear wear = Headwear.forId(e.getItem1().getId()); if (wear == null) wear = Headwear.forId(e.getItem2().getId()); Scroll s = Scroll.forId(e.getItem1().getId()); if (s == null) s = Scroll.forId(e.getItem2().getId()); final Scroll scroll = s; if (wear == null) { e.getPlayer().sendMessage(""You cannot charge that item with scrolls.""); return; } if (scroll == null) { e.getPlayer().sendMessage(""You don't have any valid scrolls.""); return; } e.getPlayer().sendInputInteger(""How many would you like to charge the helmet with?"", num -> addScrolls(e.getPlayer(), e.getUsedWith(scroll.getId()), scroll, num)); }); public static ItemClickHandler chargedOps = new ItemClickHandler(Arrays.stream(Headwear.values()).map(h -> h.chargedId).toArray(), new String[] { ""Commune"", ""Uncharge"" }, e -> { if (e.getOption().equals(""Uncharge"")) removeScrolls(e.getPlayer(), e.getItem()); else if (e.getOption().equals(""Commune"")) e.getPlayer().sendMessage(""You have "" + e.getItem().getMetaDataI(""summScrollsStored"") + "" "" + ItemDefinitions.getDefs(e.getItem().getMetaDataI(""summScrollId"")).name + "" stored in this helmet.""); }); public static void addScrolls(Player player, Item item, Scroll scroll, int num) { Headwear headwear = Headwear.forId(item.getId()); if (headwear == null) return; if (item.getMetaDataI(""summScrollId"") != scroll.getId() && item.getMetaDataI(""summScrollsStored"") > 0) { player.sendMessage(""You already have "" + item.getMetaDataI(""summScrollsStored"") + "" "" + ItemDefinitions.getDefs(item.getMetaDataI(""summScrollId"")).name + "" stored in this helmet.""); return; } if (!player.getInventory().containsItem(scroll.getId(), num)) num = player.getInventory().getAmountOf(scroll.getId()); if (num <= 0) return; player.getInventory().deleteItem(scroll.getId(), num); item.addMetaData(""summScrollId"", scroll.getId()); item.addMetaData(""summScrollsStored"", num); item.setId(headwear.chargedId); player.getInventory().refresh(item.getSlot()); } public static void removeScrolls(Player player, Item item) { Headwear wear = Headwear.forId(item.getId()); if (item.getMetaDataI(""summScrollId"", -1) == -1 || item.getMetaDataI(""summScrollsStored"", -1) <= 0) { player.sendMessage(""There's nothing to remove from this helmet.""); if (wear != null) { item.setId(wear.enchantedId); player.getInventory().refresh(item.getSlot()); } return; } player.getInventory().addItemDrop(item.getMetaDataI(""summScrollId"", -1), item.getMetaDataI(""summScrollsStored"", -1)); item.deleteMetaData(); if (wear != null) { item.setId(wear.enchantedId); player.getInventory().refresh(item.getSlot()); } } }" "package com.rs.game.content.skills.summoning; @PluginEventHandler public final class Familiar extends NPC { private static final int ITEMS_KEY = 530; public static final int CANCEL_SPECIAL = -2; public static final int DEFAULT_ATTACK_SPEED = -1; private transient Player owner; private transient int forageTicks = 0; public transient int attackIndex; private int ticks; private int specialEnergy; private boolean specOn = false; private boolean trackDrain; public int autoScrollMod = 0; private ItemsContainer inv; private final Pouch pouch; private final GenericAttribMap attribs = new GenericAttribMap(); public Familiar(Player owner, Pouch pouch, Tile tile, int mapAreaNameHash, boolean canBeAttackFromOutOfArea) { super(pouch.getBaseNpc(), tile, false); this.owner = owner; this.pouch = pouch; setIgnoreNPCClipping(true); setRun(true); resetTickets(); specialEnergy = 60; if (pouch.getBobSize() > 0) inv = new ItemsContainer<>(pouch.getBobSize(), false); anim(pouch.getSpawnAnim()); call(true); } @Override public boolean blocksOtherNpcs() { return false; } public boolean hasInventory() { return inv != null; } public ItemsContainer getInventory() { return inv; } public static ButtonClickHandler handleInvInter = new ButtonClickHandler(665, e -> { if (e.getPlayer().getFamiliar() == null || e.getPlayer().getFamiliar().inv == null || e.getPlayer().getFamiliar().pouch.isForager()) return; if (e.getComponentId() == 0) if (e.getPacket() == ClientPacket.IF_OP1) e.getPlayer().getFamiliar().addItem(e.getSlotId(), 1); else if (e.getPacket() == ClientPacket.IF_OP2) e.getPlayer().getFamiliar().addItem(e.getSlotId(), 5); else if (e.getPacket() == ClientPacket.IF_OP3) e.getPlayer().getFamiliar().addItem(e.getSlotId(), 10); else if (e.getPacket() == ClientPacket.IF_OP4) e.getPlayer().getFamiliar().addItem(e.getSlotId(), Integer.MAX_VALUE); else if (e.getPacket() == ClientPacket.IF_OP5) e.getPlayer().sendInputInteger(""Enter Amount:"", num -> e.getPlayer().getFamiliar().addItem(e.getSlotId(), num)); else if (e.getPacket() == ClientPacket.IF_OP6) e.getPlayer().getInventory().sendExamine(e.getSlotId()); }); public static ButtonClickHandler handleInter = new ButtonClickHandler(671, e -> { if (e.getPlayer().getFamiliar() == null || e.getPlayer().getFamiliar().inv == null) return; if (e.getComponentId() == 27) { if (e.getPacket() == ClientPacket.IF_OP1) e.getPlayer().getFamiliar().removeItem(e.getSlotId(), 1); else if (e.getPacket() == ClientPacket.IF_OP2) e.getPlayer().getFamiliar().removeItem(e.getSlotId(), 5); else if (e.getPacket() == ClientPacket.IF_OP3) e.getPlayer().getFamiliar().removeItem(e.getSlotId(), 10); else if (e.getPacket() == ClientPacket.IF_OP4) e.getPlayer().getFamiliar().removeItem(e.getSlotId(), Integer.MAX_VALUE); else if (e.getPacket() == ClientPacket.IF_OP5) e.getPlayer().sendInputInteger(""Enter Amount:"", num -> e.getPlayer().getFamiliar().removeItem(e.getSlotId(), num)); } else if (e.getComponentId() == 29) e.getPlayer().getFamiliar().takeInventory(); }); public static InterfaceOnInterfaceHandler orbOnInventory = new InterfaceOnInterfaceHandler(747, Inventory.INVENTORY_INTERFACE, e -> { if (e.getPlayer().getFamiliar() == null) return; Item item = e.getPlayer().getInventory().getItem(e.getToSlotId()); if (item == null) return; item.setSlot(e.getToSlotId()); e.getPlayer().getFamiliar().castSpecial(item); }); public static NPCClickHandler handleStore = new NPCClickHandler(Pouch.getAllNPCKeysWithInventory(), new String[] { ""Store"", ""Take"", ""Withdraw"" }, e -> { if (!(e.getNPC() instanceof Familiar familiar)) return; if (familiar.getOwner() != e.getPlayer()) { e.getPlayer().sendMessage(""This isn't your familiar.""); return; } familiar.openInventory(); }); public void openInventory() { if (inv == null) return; owner.getInterfaceManager().sendInterface(671); owner.getPackets().sendItems(ITEMS_KEY, inv); owner.getPackets().setIFRightClickOps(671, 27, 0, ITEMS_KEY, 0, 1, 2, 3, 4, 5); owner.getPackets().sendInterSetItemsOptionsScript(671, 27, ITEMS_KEY, 6, 5, ""Withdraw"", ""Withdraw-5"", ""Withdraw-10"", ""Withdraw-All"", ""Withdraw-X"", ""Examine""); if (!pouch.isForager()) { owner.getInterfaceManager().sendInventoryInterface(665); owner.getPackets().sendItems(93, owner.getInventory().getItems()); owner.getPackets().setIFRightClickOps(665, 0, 0, 27, 0, 1, 2, 3, 4, 5); owner.getPackets().sendInterSetItemsOptionsScript(665, 0, 93, 4, 7, ""Store"", ""Store-5"", ""Store-10"", ""Store-All"", ""Store-X"", ""Examine""); } } public void dropInventory() { if (inv == null) return; Tile tile = Tile.of(getCoordFaceX(getSize()), getCoordFaceY(getSize()), getPlane()); for (int i = 0; i < inv.getSize(); i++) { Item item = inv.get(i); if (item != null) World.addGroundItem(item, tile, owner, false, -1); } inv.reset(); } public void takeInventory() { if (inv == null) return; Item[] itemsBefore = inv.getItemsCopy(); for (int i = 0; i < inv.getSize(); i++) { Item item = inv.get(i); if (item != null) { if (!owner.getInventory().addItem(item)) break; inv.remove(i, item); } } inv.shift(); refreshItems(itemsBefore); } public void removeItem(Item item) { if (inv == null) return; Item[] itemsBefore = inv.getItemsCopy(); inv.remove(item); refreshItems(itemsBefore); } public void removeItem(int slot, int amount) { if (inv == null) return; Item item = inv.get(slot); if (item == null) return; Item[] itemsBefore = inv.getItemsCopy(); int maxAmount = inv.getNumberOf(item); if (amount < maxAmount) item = new Item(item.getId(), amount); else item = new Item(item.getId(), maxAmount); int freeSpace = owner.getInventory().getFreeSlots(); if (!item.getDefinitions().isStackable()) { if (freeSpace == 0) { owner.sendMessage(""Not enough space in your inventory.""); return; } if (freeSpace < item.getAmount()) { item.setAmount(freeSpace); owner.sendMessage(""Not enough space in your inventory.""); } } else if (freeSpace == 0 && !owner.getInventory().containsItem(item.getId(), 1)) { owner.sendMessage(""Not enough space in your inventory.""); return; } inv.remove(slot, item); inv.shift(); owner.getInventory().addItem(item); refreshItems(itemsBefore); } @Override public void processEntity() { super.processEntity(); if (isDead() || isCantInteract()) return; if (forageTicks++ >= 50) { rollForage(); forageTicks = 0; } pouch.tick(owner, this); } public void rollForage() { if (inv == null || inv.freeSlots() <= 0) return; pouch.rollForage(owner, inv); } public void addItem(int slot, int amount) { if (inv == null) return; Item item = owner.getInventory().getItem(slot); if (item == null) return; if (canStoreEssOnly() && item.getId() != 1436 && item.getId() != 7936) { owner.sendMessage(""An abyssal familiar can only carry blank rune essence.""); return; } if (!canStoreEssOnly() && (item.getId() == 1436 || item.getId() == 7936)) { owner.sendMessage(""Only an abyssal familiar can carry blank rune essence.""); return; } if (!ItemConstants.isTradeable(item) || item.getId() == 4049 || item.getDefinitions().getValue() > 50000) { owner.sendMessage(""You cannot store this item.""); return; } Item[] itemsBefore = inv.getItemsCopy(); int maxAmount = owner.getInventory().getItems().getNumberOf(item); if (amount < maxAmount) item = new Item(item.getId(), amount); else item = new Item(item.getId(), maxAmount); int freeSpace = inv.getFreeSlots(); if (!item.getDefinitions().isStackable()) { if (freeSpace == 0) { owner.sendMessage(""Not enough space in your familiar's inventory.""); return; } if (freeSpace < item.getAmount()) { item.setAmount(freeSpace); owner.sendMessage(""Not enough space in your familiar's inventory.""); } } else if (freeSpace == 0 && !inv.containsOne(item)) { owner.sendMessage(""Not enough space in your familiar's inventory.""); return; } inv.add(item); inv.shift(); owner.getInventory().deleteItem(slot, item); refreshItems(itemsBefore); } public void refreshItems(Item[] itemsBefore) { if (inv == null) return; int[] changedSlots = new int[itemsBefore.length]; int count = 0; for (int index = 0; index < itemsBefore.length; index++) { Item item = inv.array()[index]; if (itemsBefore[index] != item) changedSlots[count++] = index; } int[] finalChangedSlots = new int[count]; System.arraycopy(changedSlots, 0, finalChangedSlots, 0, count); refreshItems(finalChangedSlots); } public void refreshItems(int... slots) { if (inv == null) return; owner.getPackets().sendUpdateItems(ITEMS_KEY, inv, slots); } public boolean containsOneItem(int... itemIds) { if (inv == null) return false; for (int itemId : itemIds) if (inv.containsOne(new Item(itemId, 1))) return true; return false; } @Override public void setTarget(Entity target) { if (isPassive()) return; super.setTarget(target); } public boolean isPassive() { return pouch.isPassive(); } public boolean canStoreEssOnly() { return pouch == Pouch.ABYSSAL_LURKER || pouch == Pouch.ABYSSAL_PARASITE || pouch == Pouch.ABYSSAL_TITAN; } public int getOriginalId() { return pouch.getBaseNpc(); } public void resetTickets() { ticks = pouch.getPouchTime(); } public static ButtonClickHandler handleFamiliarOptionSettings = new ButtonClickHandler(880, e -> { if (e.getComponentId() >= 7 && e.getComponentId() <= 19) setLeftclickOption(e.getPlayer(), (e.getComponentId() - 7) / 2); else if (e.getComponentId() == 21) confirmLeftOption(e.getPlayer()); else if (e.getComponentId() == 25) setLeftclickOption(e.getPlayer(), 7); }); public static ButtonClickHandler summoningOrb = new ButtonClickHandler(747, e -> { if (e.getComponentId() == 8) selectLeftOption(e.getPlayer()); else if (e.getPlayer().getPet() != null) { if (e.getComponentId() == 11 || e.getComponentId() == 20) e.getPlayer().getPet().call(); else if (e.getComponentId() == 12 || e.getComponentId() == 21) e.getPlayer().startConversation(new DismissD(e.getPlayer()).getStart()); else if (e.getComponentId() == 10 || e.getComponentId() == 19) e.getPlayer().getPet().sendFollowerDetails(); } else if (e.getPlayer().getFamiliar() != null) if (e.getComponentId() == 11 || e.getComponentId() == 20) e.getPlayer().getFamiliar().call(); else if (e.getComponentId() == 12 || e.getComponentId() == 21) e.getPlayer().startConversation(new DismissD(e.getPlayer()).getStart()); else if (e.getComponentId() == 13 || e.getComponentId() == 22) e.getPlayer().getFamiliar().takeInventory(); else if (e.getComponentId() == 14 || e.getComponentId() == 23) e.getPlayer().getFamiliar().renewFamiliar(); else if (e.getComponentId() == 16) e.getPlayer().getFamiliar().interact(); else if (e.getComponentId() == 19 || e.getComponentId() == 10) e.getPlayer().getFamiliar().sendFollowerDetails(); else if (e.getComponentId() == 18) { if (e.getPlayer().getFamiliar().getPouch().getScroll().getTarget() == ScrollTarget.CLICK) e.getPlayer().getFamiliar().castSpecial(null); else if (e.getPlayer().getFamiliar().getPouch().getScroll().getTarget() == ScrollTarget.COMBAT) e.getPlayer().getFamiliar().setSpecActive(true); } }); public static ButtonClickHandler followerInterface = new ButtonClickHandler(662, e -> { if (e.getPlayer().getFamiliar() == null) { if (e.getPlayer().getPet() == null) return; if (e.getComponentId() == 49) e.getPlayer().getPet().call(); else if (e.getComponentId() == 51) e.getPlayer().startConversation(new DismissD(e.getPlayer()).getStart()); return; } if (e.getComponentId() == 49) e.getPlayer().getFamiliar().call(); else if (e.getComponentId() == 51) e.getPlayer().startConversation(new DismissD(e.getPlayer()).getStart()); else if (e.getComponentId() == 67) e.getPlayer().getFamiliar().takeInventory(); else if (e.getComponentId() == 69) e.getPlayer().getFamiliar().renewFamiliar(); else if (e.getComponentId() == 74) { if (e.getPlayer().getFamiliar().getPouch().getScroll().getTarget() == ScrollTarget.CLICK) e.getPlayer().getFamiliar().castSpecial(null); else if (e.getPlayer().getFamiliar().getPouch().getScroll().getTarget() == ScrollTarget.COMBAT) e.getPlayer().getFamiliar().setSpecActive(true); } }); public Pouch getPouch() { return pouch; } public void castSpecial(Object target) { if (!hasScroll()) { owner.sendMessage(""You don't have any scrolls left.""); return; } if (!hasEnergy() || owner.getTempAttribs().getL(""familiarSpecTimer"") > World.getServerTicks()) return; if (executeSpecial(target)) { owner.getTempAttribs().setL(""familiarSpecTimer"", World.getServerTicks() + 4); owner.setNextAnimation(new Animation(7660)); owner.setNextSpotAnim(new SpotAnim(1316)); drainSpec(); decrementScroll(); } } public boolean executeSpecial(Object target) { switch(pouch.getScroll().getTarget()) { case CLICK: return pouch.getScroll().use(owner, this); case COMBAT: if (getTarget() != null && pouch.getScroll().onCombatActivation(owner, this, getTarget())) setSpecActive(true); return true; case ITEM: if (target instanceof Item i) return pouch.getScroll().item(owner, this, i); return false; case OBJECT: if (target instanceof GameObject o) return pouch.getScroll().object(owner, this, o); return false; case ENTITY: if (target instanceof Entity o) return pouch.getScroll().entity(owner, this, o); break; default: break; } return false; } public int getSpecCost() { if (owner.getEquipment().getCapeId() == 19893) return (int) ((double) pouch.getScroll().getPointCost() * 0.80); return pouch.getScroll().getPointCost(); } public int castCombatSpecial(Entity target) { if (!isSpecOn()) return CANCEL_SPECIAL; if (!hasScroll()) { owner.sendMessage(""You don't have any scrolls left.""); return CANCEL_SPECIAL; } if (!hasEnergy()) return CANCEL_SPECIAL; int spec = executeCombatSpecial(target); if (spec != CANCEL_SPECIAL) { drainSpec(); decrementScroll(); setSpecActive(false); return spec == DEFAULT_ATTACK_SPEED ? getAttackSpeed() : spec; } return CANCEL_SPECIAL; } public int executeCombatSpecial(Entity target) { if (pouch.getScroll().getTarget() != ScrollTarget.COMBAT) return CANCEL_SPECIAL; return pouch.getScroll().attack(owner, this, target); } public boolean hasScroll() { if (owner.getNSV().getB(""infSpecialAttack"")) return true; if (owner.getInventory().containsItem(pouch.getScroll().getId())) return true; Item headwear = owner.getEquipment().get(Equipment.HEAD); if (headwear != null && headwear.getMetaDataI(""summScrollId"") == pouch.getScroll().getId()) return headwear.getMetaDataI(""summScrollsStored"") > 0; return false; } public void decrementScroll() { Item item = owner.getEquipment().get(Equipment.HEAD); if (item != null && item.getMetaDataI(""summScrollId"") == pouch.getScroll().getId()) { item.decMetaDataI(""summScrollsStored""); if (item.getMetaDataI(""summScrollsStored"") <= 0) { item.deleteMetaData(); Headwear headwear = Headwear.forId(item.getId()); if (headwear != null) { item.setId(headwear.enchantedId); owner.getEquipment().refresh(Equipment.HEAD); owner.getAppearance().generateAppearanceData(); } } return; } owner.getInventory().deleteItem(pouch.getScroll().getId(), 1); } @Override public void processNPC() { if (isDead() || isCantInteract()) return; Familiar.sendLeftClickOption(owner); if (!owner.getNSV().getB(""infSpecialAttack"")) ticks--; if (ticks % 50 == 0) { if (trackDrain) owner.getSkills().drainSummoning(1); trackDrain = !trackDrain; if (ticks == 100) owner.sendMessage(""You have 1 minute before your familiar vanishes.""); else if (ticks == 50) owner.sendMessage(""You have 30 seconds before your familiar vanishes.""); sendTimeRemaining(); } if (ticks == 0) { dismiss(); return; } if (pouch.getPVPNpc() != -1 && owner.isCanPvp() && getId() != pouch.getPVPNpc()) { transformIntoNPC(pouch.getPVPNpc()); call(false); return; } if (!owner.isCanPvp() && getId() != pouch.getBaseNpc()) { transformIntoNPC(pouch.getBaseNpc()); call(false); return; } if (!withinDistance(owner, 12)) { call(false); return; } if (!getCombat().process()) if (!getCombat().hasTarget() && isAgressive() && owner.getAttackedBy() != null && owner.inCombat() && canAttack(owner.getAttackedBy()) && Utils.getRandomInclusive(5) == 0) getCombat().setTarget(owner.getAttackedBy()); else if (routeEvent == null && !isLocked() && !getActionManager().hasSkillWorking()) getActionManager().setAction(new EntityFollow(owner)); } public boolean canAttack(Entity target) { if (target instanceof Player player) if (!owner.isCanPvp() || !player.isCanPvp() || (owner == target)) return false; return !target.isDead() && (target instanceof NPC n && n.isForceMultiAttacked()) || ((owner.isAtMultiArea() && isAtMultiArea() && target.isAtMultiArea()) || (owner.isForceMultiArea() && target.isForceMultiArea())) && owner.getControllerManager().canAttack(target); } public boolean renewFamiliar() { if (ticks > 200) { owner.sendMessage(""You need to have at least two minutes remaining before you can renew your familiar."", true); return false; } if (!owner.getInventory().getItems().contains(new Item(pouch.getId(), 1))) { owner.sendMessage(""You need a "" + ItemDefinitions.getDefs(pouch.getId()).getName().toLowerCase() + "" to renew your familiar's timer.""); return false; } resetTickets(); owner.getInventory().deleteItem(pouch.getId(), 1); call(true); owner.sendMessage(""You use your remaining pouch to renew your familiar.""); return true; } public void sendTimeRemaining() { owner.getVars().setVarBit(4534, ticks / 100); owner.getVars().setVarBit(4290, (ticks % 100) == 0 ? 0 : 1); } /** * Var 448 sets to itemId of pouch then gets npc chathead from enum 1279 and stores it in var 1174 * Var 1174 set to 0 will refresh the head as 448 will recalculate from the enum * * */ public void sendMainConfigs() { owner.getVars().setVar(448, pouch.getId());// configures familiar type owner.getVars().setVar(1174, 0, true); //refresh familiar head owner.getVars().setVarBit(4282, pouch.getHeadAnimIndex()); //refresh familiar emote refreshSpecialEnergy(); sendTimeRemaining(); owner.getVars().setVarBit(4288, pouch.getScroll().getPointCost());// check owner.getPackets().sendVarcString(204, pouch.getScroll().getName()); owner.getPackets().sendVarcString(205, pouch.getScroll().getDescription()); owner.getPackets().sendVarc(1436, pouch.getScroll().getTarget() == ScrollTarget.CLICK || pouch.getScroll().getTarget() == ScrollTarget.COMBAT ? 1 : 0); owner.getPackets().sendRunScript(751); sendLeftClickOption(owner); sendOrbTargetParams(); } public void sendFollowerDetails() { owner.getInterfaceManager().sendSub(Sub.TAB_FOLLOWER, 662); owner.getInterfaceManager().openTab(Sub.TAB_FOLLOWER); } public static void selectLeftOption(Player player) { player.getInterfaceManager().sendSub(Sub.TAB_FOLLOWER, 880); player.getInterfaceManager().openTab(Sub.TAB_FOLLOWER); sendLeftClickOption(player); } public static void confirmLeftOption(Player player) { player.getInterfaceManager().openTab(Sub.TAB_INVENTORY); player.getInterfaceManager().removeSub(Sub.TAB_FOLLOWER); sendLeftClickOption(player); } public static void setLeftclickOption(Player player, int summoningLeftClickOption) { if (summoningLeftClickOption == player.getSummoningLeftClickOption()) return; player.setSummoningLeftClickOption(summoningLeftClickOption); sendLeftClickOption(player); } public static void sendLeftClickOption(Player player) { if (player.getFamiliar() == null) return; player.getVars().setVar(1493, player.getSummoningLeftClickOption()); player.getVars().setVar(1494, player.getSummoningLeftClickOption()); player.getPackets().setIFHidden(747, 9, false); } public void sendOrbTargetParams() { switch (pouch.getScroll().getTarget()) { case CLICK: case COMBAT: owner.getPackets().setIFEvents(new IFEvents(747, 18, 0, 0).enableRightClickOptions(0)); owner.getPackets().setIFEvents(new IFEvents(662, 74, 0, 0).enableRightClickOptions(0)); break; case OBJECT: owner.getPackets().setIFEvents(new IFEvents(747, 18, 0, 0).enableUseOptions(UseFlag.WORLD_OBJECT)); owner.getPackets().setIFEvents(new IFEvents(662, 74, 0, 0).enableUseOptions(UseFlag.WORLD_OBJECT)); break; case ENTITY: owner.getPackets().setIFEvents(new IFEvents(747, 18, 0, 0).enableUseOptions(UseFlag.NPC, UseFlag.PLAYER)); owner.getPackets().setIFEvents(new IFEvents(662, 74, 0, 0).enableUseOptions(UseFlag.NPC, UseFlag.PLAYER)); break; case ITEM: owner.getPackets().setIFEvents(new IFEvents(747, 18, 0, 0).enableUseOptions(UseFlag.ICOMPONENT)); owner.getPackets().setIFEvents(new IFEvents(662, 74, 0, 0).enableUseOptions(UseFlag.ICOMPONENT)); break; default: break; } } private transient boolean sentRequestMoveMessage; public void call() { if (isDead() || isCantInteract()) return; call(false); } public void call(boolean login) { if (isDead() || isCantInteract()) return; if (login) sendMainConfigs(); else removeTarget(); Tile teleTile = null; teleTile = owner.getNearestTeleTile(getSize()); if (teleTile == null) { if (!sentRequestMoveMessage) { owner.sendMessage(""Theres not enough space for your familiar to appear.""); sentRequestMoveMessage = true; } return; } sentRequestMoveMessage = false; spotAnim(getSize() > 1 ? 1315 : 1314); tele(teleTile); getActionManager().forceStop(); } public void dismiss() { anim(pouch.getDespawnAnim()); kill(); WorldTasks.schedule(3, this::finish); } public void kill() { resetWalkSteps(); setCantInteract(true); getCombat().removeTarget(); owner.setFamiliar(null); owner.getPackets().sendRunScript(2471); owner.getInterfaceManager().removeSub(Sub.TAB_FOLLOWER); dropInventory(); } private transient boolean dead; @Override public void sendDeath(Entity source) { if (dead) return; dead = true; final NPCCombatDefinitions defs = getCombatDefinitions(); resetWalkSteps(); setCantInteract(true); getCombat().removeTarget(); anim(-1); kill(); WorldTasks.scheduleTimer(loop -> { if (loop == 0) { anim(defs.getDeathEmote()); } else if (loop >= defs.getDeathDelay()) { finish(); return false; } return true; }); } public void respawn(Player owner) { this.owner = owner; initEntity(); deserialize(); call(true); } public boolean isAgressive() { return pouch.getScroll().getTarget() == ScrollTarget.COMBAT; } public void refreshSpecialEnergy() { owner.getVars().setVar(1177, specialEnergy); } public void restoreSpecialAttack(int energy) { if (specialEnergy >= 60) return; specialEnergy = energy + specialEnergy >= 60 ? 60 : specialEnergy + energy; refreshSpecialEnergy(); } public boolean hasEnergy() { if (specialEnergy < getSpecCost()) { owner.sendMessage(""Your familiar doesn't have enough special energy.""); return false; } return true; } public void drainSpec(int specialReduction) { if (owner.getNSV().getB(""infSpecialAttack"")) return; specialEnergy -= specialReduction; if (specialEnergy < 0) specialEnergy = 0; refreshSpecialEnergy(); } public void drainSpec() { drainSpec(getSpecCost()); } public int getSpecialEnergy() { return specialEnergy; } public Player getOwner() { return owner; } public boolean isFinished() { boolean finished = false; return finished; } public GenericAttribMap getAttribs() { return attribs; } public boolean isSpecOn() { return specOn; } public void setSpecActive(boolean specOn) { this.specOn = specOn; } public void interact() { owner.startConversation(new Dialogue().addOptions(""What would you like to do?"", ops -> { if (inv != null) ops.add(""Open Familiar Inventory"", this::openInventory); if (pouch.getScroll().getTarget() == ScrollTarget.COMBAT) ops.add(""Setup scroll auto-fire"", () -> owner.sendInputInteger(""How many attacks would you like your familiar to automatically cast specials?
Setting this value to 0 will turn it off."", i -> { autoScrollMod = i; owner.sendMessage(""Your familiar will now automatically try to use a scroll every "" + i + "" attacks.""); })); ops.add(""Talk-to"", Interactions.getTalkToDialogue(owner, this)); Interactions.addExtraOps(owner, ops, this); })); } public boolean commandAttack(Entity target) { if (target instanceof Player player) { if (!owner.isCanPvp() || !player.isCanPvp()) { owner.sendMessage(""You can only attack players in a player-vs-player area.""); return false; } if (!owner.getFamiliar().canAttack(player)) { owner.sendMessage(""You can only use your familiar in a multi-zone area.""); return false; } } else if (target instanceof NPC npc) { if (!npc.getDefinitions().hasAttackOption()) { owner.sendMessage(""You can't attack them.""); return false; } if (target instanceof Familiar familiar) { if (familiar == this) { owner.sendMessage(""You can't attack your own familiar.""); return false; } if (!owner.getFamiliar().canAttack(familiar.getOwner())) { owner.sendMessage(""You can only attack players in a player-vs-player area.""); return false; } } if (!owner.getFamiliar().canAttack(target)) { owner.sendMessage(""You can only use your familiar in a multi-zone area.""); return false; } } owner.getFamiliar().setTarget(target); return true; } }" "package com.rs.game.content.skills.summoning; @PluginEventHandler public class Interactions { //spotanim 1575 mining boost //TODO 8320 8321 anim interaction to search for fruit fruit bat public static NPCClickHandler handleInteract = new NPCClickHandler(Pouch.getAllNPCIdKeys(), new String[] { ""Interact"" }, e -> { if (!(e.getNPC() instanceof Familiar familiar)) return; if (familiar.getOwner() != e.getPlayer()) { e.getPlayer().sendMessage(""This isn't your familiar""); return; } familiar.interact(); }); public static NPCClickHandler handleUnicornStallion = new NPCClickHandler(Pouch.UNICORN_STALLION.getIdKeys(), new String[] { ""Cure"" },e -> { if (!(e.getNPC() instanceof Familiar familiar)) return; if (familiar.getOwner() != e.getPlayer()) { e.getPlayer().sendMessage(""This isn't your familiar""); return; } if (e.getPlayer().getSkills().getLevel(Constants.SUMMONING) < 2) { e.getPlayer().sendMessage(""You do not have enough summoning points to do this.""); return; } if(!e.getPlayer().getPoison().isPoisoned()){ e.getPlayer().sendMessage(""You're not suffering from poison!""); return; } familiar.sync(8267, 1356); e.getPlayer().getPoison().reset(); e.getPlayer().getSkills().drainSummoning(2); }); public static ItemOnNPCHandler pyrelordFire = new ItemOnNPCHandler(Pouch.PYRELORD.getIdKeys(), e -> { Fire fire = Fire.forId(e.getItem().getId()); if (fire == null) { e.getPlayer().sendMessage(""The pyrelord only burns logs.""); return; } if (e.getPlayer().getSkills().getLevel(Skills.FIREMAKING) < fire.getLevel()) { e.getPlayer().sendMessage(""You need "" + fire.getLevel() + "" firemaking to burn this log.""); return; } e.getNPC().getActionManager().setAction(new Firemaking(fire)); }); public static Dialogue getTalkToDialogue(Player player, Familiar familiar) { boolean canTalk = player.getSkills().getLevelForXp(Skills.SUMMONING) >= familiar.getPouch().getLevel() + 10; return switch(familiar.getPouch()) { case SPIRIT_WOLF -> { if (!canTalk) yield new Dialogue().addNPC(familiar.getId(), HeadE.CAT_EXPLAIN, ""Whurf?""); yield random( new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_EXPLAIN, ""What are you doing?"") .addPlayer(HeadE.HAPPY_TALKING, ""Oh, just some...biped things. I'm sure it would bore you.""), new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_SHOOK, ""Danger!"") .addPlayer(HeadE.HAPPY_TALKING, ""Where?!"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK, ""False alarm...""), new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK, ""I smell something good! Hunting time!"") .addPlayer(HeadE.HAPPY_TALKING, ""We can go hunting in a moment. I just have to take care of something first.""), new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_EXPLAIN, ""When am I going to get to chase something?"") .addPlayer(HeadE.HAPPY_TALKING, ""Oh I'm sure we'll find something for you in a bit."") ); } case DREADFOWL -> { if (!canTalk) yield new Dialogue().addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Cock-!"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Cock-ledoodledoo!""); yield random( new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Attack! Fight! Annihilate!"") .addPlayer(HeadE.HAPPY_TALKING, ""It always worries me when you're so happy saying that.""), new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Can it be fightin' time, please?"") .addPlayer(HeadE.HAPPY_TALKING, ""Look I'll find something for you to fight, just give me a second.""), new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""I want to fight something."") .addPlayer(HeadE.HAPPY_TALKING, ""I'll find something for you in a minute - just be patient."") ); } case SPIRIT_SPIDER -> { if (!canTalk) yield new Dialogue().addNPC(familiar.getId(), HeadE.CAT_CALM_TALK, ""Hisssss!""); if(player.getInventory().containsOneItem(12125)) { yield new Dialogue().addNPC(familiar.getId(), HeadE.CAT_CALM_TALK, ""So, do I get any of those flies?"") .addPlayer(HeadE.HAPPY_TALKING, ""I don't know, I was saving these for a pet."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK, ""I see..."") .addPlayer(HeadE.HAPPY_TALKING, ""Look, you can have some if you want."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK, ""Oh, don't do me any favours."") .addPlayer(HeadE.FRUSTRATED, ""Look, here, have some!"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK, ""Don't want them now."") .addPlayer(HeadE.SECRETIVE, ""Siiiigh...spiders.""); } yield random( new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK, ""Where are we going?"") .addPlayer(HeadE.HAPPY_TALKING, ""I've not decided yet."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK, ""Fine, don't tell me..."") .addPlayer(HeadE.HAPPY_TALKING, ""Oh, okay, well, we are going..."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK, ""Don't want to know now."") .addPlayer(HeadE.SECRETIVE, ""Siiiigh...spiders.""), new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK, ""Who is that?"") .addPlayer(HeadE.HAPPY_TALKING, ""Who?"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK, ""The two-legs over there."") .addPlayer(HeadE.HAPPY_TALKING, ""I can't see who you mean..."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK, ""Never mind..."") .addPlayer(HeadE.HAPPY_TALKING, ""Can you describe them a little better..."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK, ""It doesn't matter now."") .addPlayer(HeadE.SECRETIVE, ""Siiiigh...spiders.""), new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK, ""What are you doing?"") .addPlayer(HeadE.HAPPY_TALKING, ""Nothing that you should concern yourself with."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK, ""I see, you don't think I'm smart enough to understand..."") .addPlayer(HeadE.FRUSTRATED, ""That's not it at all! Look, I was..."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK, ""Don't wanna know now."") .addPlayer(HeadE.SECRETIVE, ""Siiiigh...spiders.""), new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK, ""Sigh..."") .addPlayer(HeadE.FRUSTRATED, ""What is it now?"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK, ""Nothing really."") .addPlayer(HeadE.HAPPY_TALKING, ""Oh, well that's a relief."") ); } case THORNY_SNAIL -> { if(!canTalk) yield new Dialogue().addNPC(familiar.getId(), HeadE.CAT_CALM_TALK, ""Bloop!""); int hat = player.getEquipment().getHatId(); if(hat == 3327 || hat == 3329 || hat == 3331 || hat == 3333 || hat == 3337 || hat == 3339 || hat == 3341 || hat == 3343) { yield new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK, ""..."") .addPlayer(HeadE.HAPPY_TALKING, ""What's the matter?"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK, ""Check your head..."") .addPlayer(HeadE.HAPPY_TALKING, ""What about it... Oh, wait! Oh, this is pretty awkward..."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK, ""You're wearing the spine of one of my relatives as a hat..."") .addPlayer(HeadE.HAPPY_TALKING, ""Well more of a faux-pas, then."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK, ""Just a bit...""); } yield random( new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK, ""All this running around the place is fun!"") .addPlayer(HeadE.HAPPY_TALKING, ""I'll be it's a step up from your usually sedentary lifestyle!"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK, ""True, but it's mostly seeing the sort of sights you don't get at home."") .addPlayer(HeadE.HAPPY_TALKING, ""Such as?"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK, ""Living things for a start."") .addPlayer(HeadE.HAPPY_TALKING, ""Those are in short supply in Mort Myre, I admit.""), new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK, ""I think my stomach is drying out..."") .addPlayer(HeadE.HAPPY_TALKING, ""Your stomach? How do you know how it's feeling?"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK, ""I am walking on it, you know..."") .addPlayer(HeadE.SECRETIVE, ""Urrgh...""), new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK, ""Okay, I have to ask, what are those things you people totter about on?"") .addPlayer(HeadE.HAPPY_TALKING, ""You mean my legs?"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK, ""Yes, those. How are you supposed to eat anything through them?"") .addPlayer(HeadE.HAPPY_TALKING, ""Well, we don't. That's what our mouths are for."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK, ""Oh, right! I thought those were for expelling waste gas and hot air!"") .addPlayer(HeadE.HAPPY_TALKING, ""Well, for a lot of people they are.""), new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Can you slow down?"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK, ""Are we going too fast for you?"") .addPlayer(HeadE.HAPPY_TALKING, ""I bet if you had to run on your internal organs you'd want a break now and then!"") ); } case GRANITE_CRAB -> { if(!canTalk) yield new Dialogue().addNPC(familiar.getId(), HeadE.CALM_TALK, ""Click click!""); if(player.getInventory().containsOneItem(13435, 317, 321, 327, 338, 345, 335, 331, 349, 359, 371, 377, 353, 341, 363, 11328, 2148, 11330, 11332, 7944, 383, 15264, 15270)) { yield new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK, ""Can I have some fish?"") .addPlayer(HeadE.HAPPY_TALKING, ""No, I have to cook these for later."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK, ""Free fish, please?"") .addPlayer(HeadE.HAPPY_TALKING, ""No...I already told you you can't."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK, ""Can it be fish time soon?"") .addPlayer(HeadE.FRUSTRATED, ""Great...I get stuck with the only granite crab in existence that can't take no for an answer...""); } yield random( new Dialogue() .addNPC(familiar.getId(),HeadE.CAT_CALM_TALK, ""Rock fish now, please?"") .addPlayer(HeadE.HAPPY_TALKING, ""Not right now. I don't have any rock fish.""), new Dialogue() .addNPC(familiar.getId(),HeadE.CAT_CALM_TALK, ""When can we go fishing? I want rock fish."") .addPlayer(HeadE.HAPPY_TALKING, ""When I need some fish. It's not that hard to work out, right?""), new Dialogue() .addNPC(familiar.getId(),HeadE.CAT_CALM_TALK, ""I'm stealthy!"") .addPlayer(HeadE.HAPPY_TALKING, ""Errr... of course you are."") ); } case SPIRIT_MOSQUITO -> { if(!canTalk) yield new Dialogue().addNPC(familiar.getId(),HeadE.CAT_CALM_TALK, ""Buzzzzz!""); yield random( new Dialogue() .addNPC(familiar.getId(),HeadE.CAT_CALM_TALK2, ""You have lovely ankles."") .addPlayer(HeadE.HAPPY_TALKING, ""Am I meant to be pleased by that?"") .addNPC(familiar.getId(),HeadE.CAT_CALM_TALK2, ""Thin skin. Your delicious blood is easier to get too."") .addPlayer(HeadE.HAPPY_TALKING, ""I knew I couldn't trust you."") .addNPC(familiar.getId(),HeadE.CAT_CALM_TALK2, ""Oh come on, you won't feel a thing...""), new Dialogue() .addNPC(familiar.getId(),HeadE.CAT_CALM_TALK2, ""How about that local sports team?"") .addPlayer(HeadE.HAPPY_TALKING, ""Which one? The gnomeball team?"") .addNPC(familiar.getId(),HeadE.CAT_CALM_TALK2, ""I must confess: I have no idea."") .addPlayer(HeadE.HAPPY_TALKING, ""Why did you ask, then?"") .addNPC(familiar.getId(),HeadE.CAT_CALM_TALK2, ""I was just trying to be friendly."") .addPlayer(HeadE.HAPPY_TALKING, ""Just trying to get to my veins, more like!""), new Dialogue() .addNPC(familiar.getId(),HeadE.CAT_CALM_TALK2, ""Have you ever tasted pirate blood?"") .addPlayer(HeadE.HAPPY_TALKING, ""Why would I drink pirate blood?"") .addNPC(familiar.getId(),HeadE.CAT_CALM_TALK2, ""How about dwarf blood?"") .addPlayer(HeadE.HAPPY_TALKING, ""I don't think you quite understand..."") .addNPC(familiar.getId(),HeadE.CAT_CALM_TALK2, ""Gnome blood, then?""), new Dialogue() .addNPC(familiar.getId(),HeadE.CAT_CALM_TALK2, ""I'm soooo hungry!"") .addPlayer(HeadE.HAPPY_TALKING, ""What would you like to eat?"") .addNPC(familiar.getId(),HeadE.CAT_CALM_TALK2, ""Well, if you're not too attached to your elbow..."") .addPlayer(HeadE.HAPPY_TALKING, ""You can't eat my elbow! You don't have teeth!"") .addNPC(familiar.getId(),HeadE.CAT_CALM_TALK2, ""Tell me about it. Cousin Nigel always makes fun of me. Calls me 'No-teeth'."") ); } case DESERT_WYRM -> { if(!canTalk) yield new Dialogue().addNPC(familiar.getId(),HeadE.CAT_CALM_TALK2, ""Sssssst!""); if(new Item(player.getEquipment().getWeaponId(), 1).getName().toLowerCase().contains(""pickaxe"")) { yield new Dialogue() .addNPC(familiar.getId(),HeadE.CAT_CALM_TALK2, ""If you have that pick, why make me dig?"") .addPlayer(HeadE.HAPPY_TALKING, ""Because it's a little quicker and easier on my arms."") .addNPC(familiar.getId(),HeadE.CAT_CALM_TALK2, ""I should take industrial action over this..."") .addPlayer(HeadE.HAPPY_TALKING, ""You mean you won't work for me any more?"") .addNPC(familiar.getId(),HeadE.CAT_CALM_TALK2, ""No. It means me and the lads feed you legs-first into some industrial machinery, maybe the Blast Furnace."") .addPlayer(HeadE.HAPPY_TALKING, ""I'll just be over here, digging."") .addNPC(familiar.getId(),HeadE.CAT_CALM_TALK2, ""That's the spirit, lad!""); } yield random( new Dialogue() .addNPC(familiar.getId(),HeadE.CAT_CALM_TALK2, ""This is so unsafe...I should have a hard hat for this work..."") .addPlayer(HeadE.HAPPY_TALKING, ""Well, I could get you a rune helm if you like - those are pretty hard."") .addNPC(familiar.getId(),HeadE.CAT_CALM_TALK2, ""Keep that up and you'll have the union on your back!""), new Dialogue() .addNPC(familiar.getId(),HeadE.CAT_CALM_TALK2, ""You can't touch me, I'm part of the union!"") .addPlayer(HeadE.HAPPY_TALKING, ""Is that some official \""no-touching\"" policy or something?"") .addNPC(familiar.getId(),HeadE.CAT_CALM_TALK2, ""You really don't get it, do you "" + player.getDisplayName() + ""?""), new Dialogue() .addNPC(familiar.getId(),HeadE.CAT_CALM_TALK2, ""You know, you might want to register with the union."") .addPlayer(HeadE.HAPPY_TALKING, ""What are the benefits?"") .addNPC(familiar.getId(),HeadE.CAT_CALM_TALK2, ""I stop bugging you to join the union."") .addPlayer(HeadE.HAPPY_TALKING, ""Ask that again later; I'll have to consider that generous proposal.""), new Dialogue() .addNPC(familiar.getId(),HeadE.CAT_CALM_TALK2, ""Why are you ignoring that good ore seam, "" + player.getPronoun(""mister?"", ""lady?"")) .addPlayer(HeadE.HAPPY_TALKING, ""Which ore seam?"") .addNPC(familiar.getId(),HeadE.CAT_CALM_TALK2, ""There's a good ore seam right underneath us at this very moment."") .addPlayer(HeadE.HAPPY_TALKING, ""Great! How long will it take for you to get to it?"") .addNPC(familiar.getId(),HeadE.CAT_CALM_TALK2, ""Five years, give or take."") .addPlayer(HeadE.HAPPY_TALKING, ""Five years!"") .addNPC(familiar.getId(),HeadE.CAT_CALM_TALK2, ""That's if we go opencast, mind. I could probably reach it in three if I just dug."") .addPlayer(HeadE.HAPPY_TALKING, ""Right. I see. I think I'll skip it thanks."") ); } case SPIRIT_SCORPION -> { if(!canTalk) yield new Dialogue().addNPC(familiar.getId(),HeadE.CAT_CALM_TALK2, ""Hsssst!""); yield random( new Dialogue() .addNPC(familiar.getId(),HeadE.CAT_CALM_TALK2, ""Hey, boss, how about we go to the bank?"") .addPlayer(HeadE.HAPPY_TALKING, ""And do what?"") .addNPC(familiar.getId(),HeadE.CAT_CALM_TALK2, ""Well, we could open by shouting, 'Stand and deliver!'"") .addPlayer(HeadE.HAPPY_TALKING, ""Why does everything with you end with something getting held up?"") .addNPC(familiar.getId(),HeadE.CAT_CALM_TALK2, ""That isn't true! Give me one example."") .addPlayer(HeadE.HAPPY_TALKING, ""How about the post office?"") .addNPC(familiar.getId(),HeadE.CAT_CALM_TALK2, ""How about another?"") .addPlayer(HeadE.HAPPY_TALKING, ""Those junior White Knights? The ones selling the gnome crunchies?"") .addNPC(familiar.getId(),HeadE.CAT_CALM_TALK2, ""That was self defence."") .addPlayer(HeadE.HAPPY_TALKING, ""No! No more hold-ups, stick-ups, thefts, or heists, you got that?""), new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Say hello to my little friend!"") .addNPC(familiar.getId(),HeadE.CAT_CALM_TALK2, ""What?"") .addPlayer(HeadE.HAPPY_TALKING, ""My little friend: you ignored him last time you met him."") .addNPC(familiar.getId(),HeadE.CAT_CALM_TALK2, ""So, who is your friend?"") .addPlayer(HeadE.HAPPY_TALKING, ""If I tell you, what is the point?""), new Dialogue() .addNPC(familiar.getId(),HeadE.CAT_CALM_TALK2, ""Hey, boss, I've been thinking."") .addPlayer(HeadE.HAPPY_TALKING, ""That's never a good sign."") .addNPC(familiar.getId(),HeadE.CAT_CALM_TALK2, ""See, I heard about this railway..."") .addPlayer(HeadE.HAPPY_TALKING, ""We are not robbing it!"") .addNPC(familiar.getId(),HeadE.CAT_CALM_TALK2, ""I might not have wanted to suggest that, boss..."") .addPlayer(HeadE.HAPPY_TALKING, ""Then what were you going to suggest?"") .addNPC(familiar.getId(),HeadE.CAT_CALM_TALK2, ""That isn't important right now."") .addPlayer(HeadE.HAPPY_TALKING, ""I thought as much.""), new Dialogue() .addNPC(familiar.getId(),HeadE.CAT_CALM_TALK2, ""Why do we never go to crossroads and rob travelers?"") .addPlayer(HeadE.HAPPY_TALKING, ""There are already highwaymen at the good spots."") .addNPC(familiar.getId(),HeadE.CAT_CALM_TALK2, ""Maybe we need to think bigger."") ); } case SPIRIT_TZ_KIH -> { if(!canTalk) new Dialogue().addNPC(familiar.getId(),HeadE.CAT_CALM_TALK2, ""Chirp chirp!""); if(player.containsOneItem(139, 141, 143, 2434)) { yield new Dialogue() .addNPC(familiar.getId(),HeadE.CAT_CALM_TALK2, ""You drink pray, me drink pray."") .addPlayer(HeadE.HAPPY_TALKING, ""What's that, Tz-Kih?"") .addNPC(familiar.getId(),HeadE.CAT_CALM_TALK2, ""You got pray pray pot. Tz-Kih drink pray pray you, you drink pray pray pot."") .addPlayer(HeadE.HAPPY_TALKING, ""You want to drink my Prayer points?"") .addNPC(familiar.getId(),HeadE.CAT_CALM_TALK2, ""Yes. Pray pray."") .addPlayer(HeadE.HAPPY_TALKING, ""Err, not right now, Tz-Kih. I, er, need them myself."") .addPlayer(HeadE.HAPPY_TALKING, ""Sorry."") .addNPC(familiar.getId(),HeadE.CAT_CALM_TALK2, ""But, pray praaaay...?""); } yield random( new Dialogue() .addNPC(familiar.getId(),HeadE.CAT_CALM_TALK2, ""How's it going, Tz-kih?"") .addPlayer(HeadE.HAPPY_TALKING, ""Pray pray?"") .addNPC(familiar.getId(),HeadE.CAT_CALM_TALK2, ""Don't start with all that again."") .addPlayer(HeadE.HAPPY_TALKING, ""Hmph, silly JalYt.""), new Dialogue() .addNPC(familiar.getId(),HeadE.CAT_CALM_TALK2, ""Does JalYt think Tz-kih as strong as Jad Jad?"") .addPlayer(HeadE.HAPPY_TALKING, ""Are you as strong as TzTok-Jad? Yeah, sure, why not."") .addNPC(familiar.getId(),HeadE.CAT_CALM_TALK2, ""Really? Thanks, JalYt. Tz-Kih strong and happy.""), new Dialogue() .addNPC(familiar.getId(),HeadE.CAT_CALM_TALK2, ""Have you heard of blood bat, JalYt?"") .addPlayer(HeadE.HAPPY_TALKING, ""Blood bats? You mean vampire bats?"") .addNPC(familiar.getId(),HeadE.CAT_CALM_TALK2, ""Yes. Blood bat."") .addPlayer(HeadE.HAPPY_TALKING, ""Yes, I've heard of them. What about them?"") .addNPC(familiar.getId(),HeadE.CAT_CALM_TALK2, ""Tz-Kih like blood bat, but drink pray pray not blood blood. Blood blood is yuck."") .addPlayer(HeadE.HAPPY_TALKING, ""Thanks, Tz-Kih, that's nice to know.""), new Dialogue() .addNPC(familiar.getId(),HeadE.CAT_CALM_TALK2, ""Pray pray pray pray pray pray pray pray!"") .addPlayer(HeadE.HAPPY_TALKING, ""Calm down, Tz-Kih, we'll find you something to drink soon."") .addNPC(familiar.getId(),HeadE.CAT_CALM_TALK2, ""Pray praaaaaaaaaaaaaay!"") .addPlayer(HeadE.HAPPY_TALKING, ""Okay, okay. Calm down!"") ); } case ALBINO_RAT -> { if(!canTalk) yield new Dialogue().addNPC(familiar.getId(),HeadE.CAT_CALM_TALK2, ""Reeeeee!""); yield random( new Dialogue() .addNPC(familiar.getId(),HeadE.CAT_CALM_TALK2, ""Hey boss, we going to do anything wicked today?"") .addPlayer(HeadE.HAPPY_TALKING, ""Well, I don't know why we would: I tend not to go around being wicked."") .addNPC(familiar.getId(),HeadE.CAT_CALM_TALK2, ""Not even a little?"") .addPlayer(HeadE.HAPPY_TALKING, ""Well there was that one time... I'm sorry, no wickedness today."") .addNPC(familiar.getId(),HeadE.CAT_CALM_TALK2, ""Awwwwww...""), new Dialogue() .addNPC(familiar.getId(),HeadE.CAT_CALM_TALK2, ""Hey boss, can we go and loot something now?"") .addPlayer(HeadE.HAPPY_TALKING, ""Well, what did you have in mind?"") .addNPC(familiar.getId(),HeadE.CAT_CALM_TALK2, ""I dunno - where are we headed?"") .addPlayer(HeadE.HAPPY_TALKING, ""I hadn't decided yet."") .addNPC(familiar.getId(),HeadE.CAT_CALM_TALK2, ""When we get there, let's loot something nearby!"") .addPlayer(HeadE.HAPPY_TALKING, ""Sounds like a plan, certainly.""), new Dialogue() .addNPC(familiar.getId(),HeadE.CAT_CALM_TALK2, ""So what we up to today, boss?"") .addPlayer(HeadE.HAPPY_TALKING, ""Oh I'm sure we'll find something to occupy our time."") .addNPC(familiar.getId(),HeadE.CAT_CALM_TALK2, ""Let's go robbin' graves again!"") .addPlayer(HeadE.HAPPY_TALKING, ""What do you mean 'again'?"") .addNPC(familiar.getId(),HeadE.CAT_CALM_TALK2, ""Nuffin'...""), new Dialogue() .addNPC(familiar.getId(),HeadE.CAT_CALM_TALK2, ""You know, boss, I don't think you're totally into this whole 'evil' thing."") .addPlayer(HeadE.HAPPY_TALKING, ""I wonder what gave you that impression?"") .addNPC(familiar.getId(),HeadE.CAT_CALM_TALK2, ""Well, I worked with a lot of evil people; some of the best."") .addPlayer(HeadE.HAPPY_TALKING, ""Such as?"") .addNPC(familiar.getId(),HeadE.CAT_CALM_TALK2, ""I'm not telling! I've got my principles to uphold."") .addPlayer(HeadE.HAPPY_TALKING, ""There is honour amongst thieves, it would seem."") ); } case SPIRIT_KALPHITE -> { int weaponID = player.getEquipment().getWeaponId(); if(player.getInventory().containsOneItem(10581, 10582, 10583, 10584) || weaponID == 10581 || weaponID == 10582 || weaponID == 10583 || weaponID == 10584) yield new Dialogue().addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""How dare you!"") .addPlayer(HeadE.HAPPY_TALKING, ""How dare I what?"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""That weapon offends us!"") .addPlayer(HeadE.HAPPY_TALKING, ""How dare you!"") .addPlayer(HeadE.HAPPY_TALKING, ""What weapon?"") .addPlayer(HeadE.HAPPY_TALKING, ""That weapon offends us!""); yield random( new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""This activity is not optimal for us."") .addPlayer(HeadE.HAPPY_TALKING, ""Well, you'll just have to put up with it for now."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""We would not have to 'put up' with this in the hive.""), new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""We are growing infuriated. What is our goal?"") .addPlayer(HeadE.HAPPY_TALKING, ""Well, I haven't quite decided yet."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""There is no indecision in the hive."") .addPlayer(HeadE.HAPPY_TALKING, ""Or a sense of humour or patience, it seems.""), new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""We find this to be wasteful of our time."") .addPlayer(HeadE.HAPPY_TALKING, ""Maybe I find you wasteful..."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""We would not face this form of abuse in the hive.""), new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""We grow tired of your antics, biped."") .addPlayer(HeadE.HAPPY_TALKING, ""What antics? I'm just getting on with my day."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""In an inefficient way. In the hive, you would be replaced."") .addPlayer(HeadE.HAPPY_TALKING, ""In the hive this, in the hive that..."") ); } case COMPOST_MOUND -> { if(!canTalk) yield new Dialogue().addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Mwap mwap!""); yield random( new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Oi've gotta braand new comboine 'aarvester!"") .addPlayer(HeadE.HAPPY_TALKING, ""A what?"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Well, it's a flat bit a metal wi' a 'andle that I can use ta 'aarvest all combintions o' plaants."") .addPlayer(HeadE.HAPPY_TALKING, ""You mean a spade?"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Aye, 'aat'll be it."") , new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""What we be doin' 'ere, zur?"") .addPlayer(HeadE.HAPPY_TALKING, ""Oh, I have a few things to take care of here, is all."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Aye, right ye are, zur. Oi'll be roight there."") , new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Errr...are ye gonna eat that?"") .addPlayer(HeadE.HAPPY_TALKING, ""Eat what?"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Y've got summat on yer, goin' wastin'."") .addPlayer(HeadE.HAPPY_TALKING, ""Ewwww!"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""So ye don' want it then?"") .addPlayer(HeadE.HAPPY_TALKING, ""No I do not want it! Nor do I want to put my boot in your mouth for you to clean it off."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""An' why not?"") .addPlayer(HeadE.HAPPY_TALKING, ""It'll likely come out dirtier than when I put it in!"") , new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Sigh..."") .addPlayer(HeadE.HAPPY_TALKING, ""What's the matter?"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Oi'm not 'appy carryin' round these young'uns where we're going."") .addPlayer(HeadE.HAPPY_TALKING, ""Young'uns? Oh, the buckets of compost! Well, those wooden containers will keep them safe."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""'Aah, that be a mighty good point, zur."") , new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Oi wus just a-wonderin'..."") .addPlayer(HeadE.HAPPY_TALKING, ""Oh! What have you been eating! Your breath is making my eyes water!"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Oi! Oi'm 'urt by thaat."") .addPlayer(HeadE.HAPPY_TALKING, ""Sorry."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Oi mean, oi even et some mints earlier."") .addPlayer(HeadE.HAPPY_TALKING, ""You did?"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""'At's roight. Oi found some mint plaants in a big pile o' muck, and oi 'ad 'em fer me breakfast."") .addPlayer(HeadE.HAPPY_TALKING, ""The mystery resolves itself."") ); } case GIANT_CHINCHOMPA -> { if(!canTalk) yield new Dialogue().addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Reep reeeep!""); if(player.getInventory().containsOneItem(9976, 9977, 10033, 10034)) yield new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Woah, woah, woah - hold up there."") .addPlayer(HeadE.HAPPY_TALKING, ""What is it, ratty?"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""You got something in your backpack that you'd like to tell me about?"") .addPlayer(HeadE.HAPPY_TALKING, ""I was wondering when you were going to bring up the chinchompa. I'm sure they like it in my inventory."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Did they not teach you anything in school? Chinchompas die in hot bags. You know what happens when chinchompas die. Are you attached to your back?"") .addPlayer(HeadE.HAPPY_TALKING, ""Medically, yes. And I kind of like it too. I get the point.""); yield random( new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Half a pound of tuppenny rice, half a pound of treacle..."") .addPlayer(HeadE.HAPPY_TALKING, ""I hate it when you sing that song."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""...that's the way the money goes..."") .addPlayer(HeadE.HAPPY_TALKING, ""Couldn't you sing 'Kumbaya' or something?"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""...BANG, goes the chinchompa!"") .addPlayer(HeadE.HAPPY_TALKING, ""Sheesh."") , new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""What's small, brown and blows up?"") .addPlayer(HeadE.HAPPY_TALKING, ""A brown balloon?"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""A chinchompa! Pull my finger."") .addPlayer(HeadE.HAPPY_TALKING, ""I'm not pulling your finger."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Nothing will happen. Truuuuust meeeeee."") .addPlayer(HeadE.HAPPY_TALKING, ""Oh, go away.""), new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""I spy, with my little eye, something beginning with 'B'."") .addPlayer(HeadE.HAPPY_TALKING, ""Bomb? Bang? Boom? Blowing-up-little-chipmunk?"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""No. Body odour. You should wash a bit more."") .addPlayer(HeadE.HAPPY_TALKING, ""Well, that was pleasant. You don't smell all that great either, you know."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Stop talking, stop talking! Your breath stinks!"") .addPlayer(HeadE.HAPPY_TALKING, ""We're never going to get on, are we?""), new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""I seem to have found a paper bag."") .addPlayer(HeadE.HAPPY_TALKING, ""Well done. Anything in it?"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Hmmm. Let me see. It seems to be full of some highly sought after, very expensive...chinchompa breath!"") .addPlayer(HeadE.HAPPY_TALKING, ""No, don't pop it!"") .addSimple(""*BANG!!*"") .addPlayer(HeadE.HAPPY_TALKING, ""You just cannot help yourself, can you?"") ); } case VAMPYRE_BAT -> { if(!canTalk) yield new Dialogue().addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Ree! Ree! Reeeee!""); //less than half hp is this dialogue if(player.getHitpoints() < (player.getMaxHitpoints()/2)) yield new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""You're vasting all that blood, can I have some?"") .addPlayer(HeadE.HAPPY_TALKING, ""No!""); //darkness if((player.getControllerManager().getController() != null && player.getControllerManager().getController() instanceof UndergroundDungeonController)) yield new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Ze creatures ov ze dark; vat vonderful music zey make."") .addPlayer(HeadE.HAPPY_TALKING, ""Riiight."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""I like it down here. Let's stay and eat moths!"") .addPlayer(HeadE.HAPPY_TALKING, ""I think I'll pass, thanks.""); yield random( new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Ven are you going to feed me?"") .addPlayer(HeadE.HAPPY_TALKING, ""Well for a start, I'm not giving you any of my blood.""), new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""I want to eat something."") .addPlayer(HeadE.HAPPY_TALKING, ""I'm sure you do; let's go see what we can find.""), new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Ven can I eat something?"") .addPlayer(HeadE.HAPPY_TALKING, ""Just as soon as I find something to attack."") ); } case HONEY_BADGER -> { if(!canTalk) yield new Dialogue().addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Flop flop!""); yield random( new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""*An outpouring of sanity-straining abuse*"") .addPlayer(HeadE.HAPPY_TALKING, ""Why do I talk to you again?""), new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""*An outpouring of spittal-flecked insults.*"") .addPlayer(HeadE.HAPPY_TALKING, ""Why do I talk to you again?""), new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""*A lambasting of visibly illustrated obscenities.*"") .addPlayer(HeadE.HAPPY_TALKING, ""Why do I talk to you again?""), new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""*A tirade of biologically questionable threats*"") .addPlayer(HeadE.HAPPY_TALKING, ""Why do I talk to you again?""), new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""*A stream of eye-watering crudities*"") .addPlayer(HeadE.HAPPY_TALKING, ""Why do I talk to you again?"") ); } case BEAVER -> { if(!canTalk) yield new Dialogue().addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Chip chip!""); //logs in inventory if(player.getInventory().containsOneItem(1511, 1513, 1515, 1517, 1519, 1521, 2862, 3438, 3440, 3442, 3444, 3446, 3448, 4445, 5211, 5213, 6332, 6333)) yield new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""'Ere, you 'ave ze logs, now form zem into a mighty dam!"") .addPlayer(HeadE.HAPPY_TALKING, ""Well, I was thinking of burning, selling, or fletching them."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Sacre bleu! Such a waste.""); yield random( new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Vot are you doing 'ere when we could be logging and building mighty dams, alors?"") .addPlayer(HeadE.HAPPY_TALKING, ""Why would I want to build a dam again?"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Why vouldn't you want to build a dam again?"") .addPlayer(HeadE.HAPPY_TALKING, ""I can't argue with that logic.""), new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Pardonnez-moi - you call yourself a lumberjack?"") .addPlayer(HeadE.HAPPY_TALKING, ""No"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Carry on zen.""), new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Paul Bunyan 'as nothing on moi!"") .addPlayer(HeadE.HAPPY_TALKING, ""Except several feet in height, a better beard, and opposable thumbs."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""What was zat?"") .addPlayer(HeadE.HAPPY_TALKING, ""Nothing.""), new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Zis is a fine day make some lumber."") .addPlayer(HeadE.HAPPY_TALKING, ""That it is!"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""So why are you talking to moi? Get chopping!"") ); } case VOID_RAVAGER -> { if(!canTalk) yield new Dialogue().addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Raaaaa!""); yield random( new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""You look delicious!"") .addPlayer(HeadE.HAPPY_TALKING, ""Don't make me dismiss you!""), new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Take me to the rift!"") .addPlayer(HeadE.HAPPY_TALKING, ""I'm not taking you there! Goodness knows what you'd get up to."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""I promise not to destroy your world..."") .addPlayer(HeadE.HAPPY_TALKING, ""If only I could believe you...""), new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Pardon me. Could I trouble you for a moment?"") .addPlayer(HeadE.HAPPY_TALKING, ""Yeah, sure."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Oh, it's just a trifling thing. Mmm, trifle...you look like trifle...So, will you help?"") .addPlayer(HeadE.HAPPY_TALKING, ""Pardon me. Could I trouble you for a moment?"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Yeah, sure."") .addPlayer(HeadE.HAPPY_TALKING, ""Oh, just be honest. I just want a second opinion...Is this me? Mmm trifle..."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Pardon me. Could I trouble you for a moment?"") .addPlayer(HeadE.HAPPY_TALKING, ""Erm...why yes...of course. It definitely reflects the inner you."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Oh, just be honest. I just want a second opinion...Is this me? Mmm trifle...""), new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""How do you bear life without ravaging?"") .addPlayer(HeadE.HAPPY_TALKING, ""It's not always easy."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""I could show you how to ravage, if you like..."") ); } case VOID_SPINNER -> { if(!canTalk) yield new Dialogue().addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Psssst!""); //purple sweets if(player.getInventory().containsOneItem(10476, 4561)) yield new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""You have sweeties for spinner?"") .addPlayer(HeadE.HAPPY_TALKING, ""Sweeties? No sweeties here."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""You do! You do! Gimmie sweeties!"") .addPlayer(HeadE.HAPPY_TALKING, ""I don't have any sweeties!"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""What you hiding in your backpack, then?"") .addPlayer(HeadE.HAPPY_TALKING, ""That? Oh, that's...erm...worms! Yes, worms. Purple worms."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Yucky!""); yield random( new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Let's go play hide an' seek!"") .addPlayer(HeadE.HAPPY_TALKING, ""Okay, you hide and I'll come find you."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""You'll never find me!"") .addPlayer(HeadE.HAPPY_TALKING, ""What a disaster that would be...""), new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""My mummy told me I was clever."") .addPlayer(HeadE.HAPPY_TALKING, ""Aren't you meant to be the essence of a spinner? How do you have a mother?"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""What you mean, 'essence'?"") .addPlayer(HeadE.HAPPY_TALKING, ""Never mind, I don't think it matters."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""My logimical powers has proved me smarterer than you!""), new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""I'm coming to tickle you!"") .addPlayer(HeadE.HAPPY_TALKING, ""No! You've got so many tentacles!"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""I'm coming to tickle you!"") .addPlayer(HeadE.HAPPY_TALKING, ""Aieee!""), new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Where's the sweeties?"") .addPlayer(HeadE.HAPPY_TALKING, ""They are wherever good spinners go."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Yay for me!"") ); } case VOID_TORCHER -> { if(!canTalk) yield new Dialogue().addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Reeeeee!""); yield random( new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""You okay there, spinner?"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""I not spinner!"") .addPlayer(HeadE.HAPPY_TALKING, ""Sorry, splatter?"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""I not splatter either!"") .addPlayer(HeadE.HAPPY_TALKING, ""No, wait, I meant defiler."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""I torcher!"") .addPlayer(HeadE.HAPPY_TALKING, ""Hehe, I know. I was just messing with you."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Grr. Don't be such a pest.""), new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""'T' is for torcher, that's good enough for me... 'T' is for torcher, I'm happy you can see."") .addPlayer(HeadE.HAPPY_TALKING, ""You're just a bit weird, aren't you?""), new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Burn, baby, burn! Torcher inferno!"") .addPlayer(HeadE.HAPPY_TALKING, ""*Wibble*""), new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""So hungry... must devour..."") .addPlayer(HeadE.HAPPY_TALKING, ""*Gulp* Er, yeah, I'll find you something to eat in a minute."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Is flesh-bag scared of torcher?"") .addPlayer(HeadE.HAPPY_TALKING, ""No, no. I, er, always look like this... honest."") ); } case VOID_SHIFTER -> { if(!canTalk) yield new Dialogue().addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Screee!""); yield random( new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""What a splendid day, "" + player.getPronoun(""sir!"", ""madam!"")) .addPlayer(HeadE.HAPPY_TALKING, ""Yes, it is!"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""It could only be marginally improved, perhaps, by tea and biscuits."") .addPlayer(HeadE.HAPPY_TALKING, ""What a marvellous idea!""), new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""I'm sorry to bother you, but could you assist me briefly?"") .addPlayer(HeadE.HAPPY_TALKING, ""I suppose so."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""I was wondering, briefly, if perchance you might care to dance?"") .addPlayer(HeadE.HAPPY_TALKING, ""Dance? With a pest?"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Well, you see, I'm dreadfully out of practice and now I can barely leap, let alone teleport."") .addPlayer(HeadE.HAPPY_TALKING, ""I'm not going to help you remember how to destroy the world!"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""What a beastly world we live in where one gentleman/lady will not aid a pest in need...""), new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""How do you do?"") .addPlayer(HeadE.HAPPY_TALKING, ""Okay, I suppose."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Marvellous, simply marvellous!""), new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Lets go and see to those cads and bounders!"") .addPlayer(HeadE.HAPPY_TALKING, ""Which 'cads and bounders' did you mean, exactly?"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Why, the ones with no honour, of course."") .addPlayer(HeadE.HAPPY_TALKING, ""I don't think he knows what pests do..."") ); } case BRONZE_MINOTAUR, IRON_MINOTAUR, STEEL_MINOTAUR, MITHRIL_MINOTAUR, ADAMANT_MINOTAUR, RUNE_MINOTAUR -> { if(!canTalk) yield new Dialogue().addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Rawr!""); String hat = new Item(player.getEquipment().getHatId(), 1).getName().toLowerCase(); if(hat.contains(""guthan"") || hat.contains(""bandos helmet"") || hat.contains(""berserker"") || hat.contains(""archer"") || hat.contains(""dragon med helm"")) yield new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""..."") .addPlayer(HeadE.HAPPY_TALKING, ""What?"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Are you having a laugh?"") .addPlayer(HeadE.HAPPY_TALKING, ""I'm not sure I know what you-"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Listen, no-horns, you have two choices: take off the horns yourself or I'll headbutt you until they fall off."") .addPlayer(HeadE.HAPPY_TALKING, ""Yessir."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Good, no-horns. Let's not have this conversation again.""); yield random( new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""All this walking about is making me angry."") .addPlayer(HeadE.HAPPY_TALKING, ""You seem to be quite happy about that."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Yeah! There's nothing like getting a good rage on and then working it out on some no-horns."") .addPlayer(HeadE.HAPPY_TALKING, ""I can't say I know what you mean."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Well I didn't think a no-horns like you would get it!""), new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Can you tell me why we're not fighting yet?"") .addPlayer(HeadE.HAPPY_TALKING, ""Buck up; I'll find you something to hit soon."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""You'd better, no-horns, because that round head of yours is looking mighty axeable.""), new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Hey, no-horns?"") .addPlayer(HeadE.HAPPY_TALKING, ""Why do you keep calling me no-horns?"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Do I really have to explain that?"") .addPlayer(HeadE.HAPPY_TALKING, ""No, thinking about it, it's pretty self-evident."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Glad we're on the same page, no-horns."") .addPlayer(HeadE.HAPPY_TALKING, ""So, what did you want?"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""I've forgotten, now. I'm sure it'll come to me later.""), new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Hey no-horns!"") .addPlayer(HeadE.HAPPY_TALKING, ""Yes?"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Oh, I don't have anything to say, I was just yelling at you."") .addPlayer(HeadE.HAPPY_TALKING, ""Why?"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""No reason. I do like to mess with the no-horns, though."") ); } case BULL_ANT -> { if(!canTalk) yield new Dialogue().addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Snip snip!""); if(player.getRunEnergy() < 12.0) yield new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""What's the matter, Private? Not enjoying the run?"") .addPlayer(HeadE.HAPPY_TALKING, ""Sir...wheeze...yes Sir!"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Not enjoying the run? You need more training biped?"") .addPlayer(HeadE.HAPPY_TALKING, ""Sir, no Sir! Sir, I'm enjoying the run a great deal, Sir!"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Then hop to, Private!"") .addPlayer(HeadE.HAPPY_TALKING, ""Sir, yes Sir!""); yield random( new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""All right you worthless biped, fall in!"") .addPlayer(HeadE.HAPPY_TALKING, ""Sir, yes Sir!"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""We're going to work you so hard your boots fall off, understood?"") .addPlayer(HeadE.HAPPY_TALKING, ""Sir, yes Sir!"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Carry on Private!""), new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Aten...hut!"") .addPlayer(HeadE.HAPPY_TALKING, ""Sir, Private Player reporting for immediate active duty, Sir!"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""As you were, Private!""), new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""I can't believe they stuck me with you..."") .addPlayer(HeadE.HAPPY_TALKING, ""Buck up, Sir, it's not that bad."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Stow that, Private, and get back to work!"") .addPlayer(HeadE.HAPPY_TALKING, ""Sir, yes Sir!""), new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""What in the name of all the layers of the abyss do you think you're doing, biped?"") .addPlayer(HeadE.HAPPY_TALKING, ""Sir, nothing Sir!"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Well double-time it, Private, whatever it is!"") .addPlayer(HeadE.HAPPY_TALKING, ""Sir, yes Sir!"") ); } case MACAW -> { if(!canTalk) yield new Dialogue().addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Ca-caw! Ca-caw!""); yield random( new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Awk! Gimme the rum! Gimme the rum!"") .addPlayer(HeadE.HAPPY_TALKING, ""I don't think you'll like the stuff. Besides, I think there is a law about feeding birds alcohol.""), new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Awk! I'm a pirate! Awk! Yo, ho ho!"") .addPlayer(HeadE.HAPPY_TALKING, ""I'd best not keep you around any customs officers!""), new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Awk! Caw! Shiver me timbers!"") .addPlayer(HeadE.HAPPY_TALKING, ""I wonder where you picked up all these phrases?"") ); } case EVIL_TURNIP -> { if(!canTalk) yield new Dialogue().addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Yeeeeee!""); yield random( new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""So, how are you feeling?"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""My roots feel hurty. I thinking it be someone I eated."") .addPlayer(HeadE.HAPPY_TALKING, ""You mean someTHING you ate?"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Hur hur hur. Yah, sure, why not.""), new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Hur hur hur..."") .addPlayer(HeadE.HAPPY_TALKING, ""Well, as sinister as it's chuckling is, at least it's happy. That's a good thing, right?""), new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""When we gonna fighting things, boss?"") .addPlayer(HeadE.HAPPY_TALKING, ""Soon enough."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Hur hur hur. I gets the fighting.""), new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""I are turnip hear me roar! I too deadly to ignore."") .addPlayer(HeadE.HAPPY_TALKING, ""I'm glad it's on my side... and not behind me."") ); } case SPIRIT_COCKATRICE, SPIRIT_GUTHATRICE, SPIRIT_SARATRICE, SPIRIT_ZAMATRICE, SPIRIT_PENGATRICE, SPIRIT_CORAXATRICE, SPIRIT_VULATRICE -> { if(!canTalk) yield new Dialogue().addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Cock-ledoodledoooo!""); if(player.getEquipment().getShieldId() == 4156) yield new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""You know, I'm sensing some trust issues here."") .addPlayer(HeadE.HAPPY_TALKING, ""I'm not sure I know what you are talking about."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""What are you holding?"") .addPlayer(HeadE.HAPPY_TALKING, ""A mirror shield."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""And what do those do?"") .addPlayer(HeadE.HAPPY_TALKING, ""Mumblemumble..."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""What was that?"") .addPlayer(HeadE.HAPPY_TALKING, ""It protects me from your gaze attack."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""See! Why would you need one unless you didn't trust me?"") .addPlayer(HeadE.HAPPY_TALKING, ""Who keeps demanding that we stop and have staring contests?"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""How about we drop this and call it even?"") .addPlayer(HeadE.HAPPY_TALKING, ""Fine by me.""); yield random( new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Is this what you do for fun?"") .addPlayer(HeadE.HAPPY_TALKING, ""Sometimes. Why, what do you do for fun?"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""I find things and glare at them until they die!"") .addPlayer(HeadE.HAPPY_TALKING, ""Well...everyone needs a hobby, I suppose.""), new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""You know, I think I might train as a hypnotist."") .addPlayer(HeadE.HAPPY_TALKING, ""Isn't that an odd profession for a cockatrice?"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Not at all! I've already been practicing!"") .addPlayer(HeadE.HAPPY_TALKING, ""Oh, really? How is that going?"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Not good. I tell them to look in my eyes and that they are feeling sleepy."") .addPlayer(HeadE.HAPPY_TALKING, ""I think I can see where this is headed."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""And then they just lie there and stop moving."") .addPlayer(HeadE.HAPPY_TALKING, ""I hate being right sometimes.""), new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Come on, lets have a staring contest!"") .addPlayer(HeadE.HAPPY_TALKING, ""You win!"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Yay! I win again!"") .addPlayer(HeadE.HAPPY_TALKING, ""Oh, it's no contest alright.""), new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""You know, sometimes I don't think we're good friends."") .addPlayer(HeadE.HAPPY_TALKING, ""What do you mean?"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Well, you never make eye contact with me for a start."") .addPlayer(HeadE.HAPPY_TALKING, ""What happened the last time someone made eye contact with you?"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Oh, I petrified them really good! Ooooh...okay, point taken."") .addPlayer(HeadE.HAPPY_TALKING, ""I'm glad we had this chat."") ); } case PYRELORD -> { if(!canTalk) yield new Dialogue().addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Buuuuurrrrrr!""); yield random( new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""What are we doing here?"") .addPlayer(HeadE.HAPPY_TALKING, ""Whatever I feel like doing."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""I was summoned by a greater demon once you know."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""He said we'd see the world..."") .addPlayer(HeadE.HAPPY_TALKING, ""What happened?"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""He was slain; it was hilarious!""), new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""I used to be feared across five planes..."") .addPlayer(HeadE.HAPPY_TALKING, ""Oh dear, now you're going to be sad all day!"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""At least I won't be the only one.""), new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""I could teach you to smite your enemies with flames."") .addPlayer(HeadE.HAPPY_TALKING, ""You're not the only one: we have runes to do that."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Runes? Oh, that's so cute!"") .addPlayer(HeadE.HAPPY_TALKING, ""Cute?"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Well, not cute so much as tragic. I could teach you to do it without runes."") .addPlayer(HeadE.HAPPY_TALKING, ""Really?"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""No.""), new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Have you never been on fire?"") .addPlayer(HeadE.HAPPY_TALKING, ""You say that like it's a bad thing."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Isn't it? It gives me the heebie-jeebies!"") .addPlayer(HeadE.HAPPY_TALKING, ""You're afraid of something?"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Yes: I'm afraid of being you."") .addPlayer(HeadE.HAPPY_TALKING, ""I don't think he likes me..."") ); } case MAGPIE -> { if(!canTalk) yield new Dialogue().addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Breeeee! Breeeeee!""); yield random( new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""There's nowt gannin on here..."") .addPlayer(HeadE.HAPPY_TALKING, ""Err...sure? Maybe?"") .addPlayer(HeadE.HAPPY_TALKING, ""It seems upset, but what is it saying?""), new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Howway, let's gaan see what's happenin' in toon."") .addPlayer(HeadE.HAPPY_TALKING, ""What? I can't understand what you're saying.""), new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Are we gaan oot soon? I'm up fer a good walk me."") .addPlayer(HeadE.HAPPY_TALKING, ""That...that was just noise. What does that mean?""), new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Ye' been plowdin' i' the claarts aall day."") .addPlayer(HeadE.HAPPY_TALKING, ""What? That made no sense."") ); } case BLOATED_LEECH -> { if(!canTalk) yield new Dialogue().addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Sssssssst-t-t-t!""); yield random( new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""I'm afraid it's going to have to come off, "" + player.getDisplayName() + ""."") .addPlayer(HeadE.HAPPY_TALKING, ""What is?"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Never mind. Trust me, I'm almost a doctor."") .addPlayer(HeadE.HAPPY_TALKING, ""I think I'll get a second opinion.""), new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""You're in a critical condition."") .addPlayer(HeadE.HAPPY_TALKING, ""Is it terminal?"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Not yet. Let me get a better look and I'll see what I can do about it."") .addPlayer(HeadE.HAPPY_TALKING, ""There are two ways to take that...and I think I'll err on the side of caution.""), new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Let's get a look at that brain of yours."") .addPlayer(HeadE.HAPPY_TALKING, ""What? My brains stay inside my head, thanks."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""That's ok, I can just drill a hole."") .addPlayer(HeadE.HAPPY_TALKING, ""How about you don't and pretend you did?""), new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""I think we're going to need to operate."") .addPlayer(HeadE.HAPPY_TALKING, ""I think we can skip that for now."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Who's the doctor here?"") .addPlayer(HeadE.HAPPY_TALKING, ""Not you."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""I may not be a doctor, but I'm keen. Does that not count?"") .addPlayer(HeadE.HAPPY_TALKING, ""In most other fields, yes; in medicine, no."") ); } case SPIRIT_TERRORBIRD -> { if(!canTalk) new Dialogue().addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Breeeeee!""); int itemsInBird = familiar.getInventory().getUsedSlots(); if(itemsInBird <= 8) { yield new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""This is a fun little walk."") .addPlayer(HeadE.HAPPY_TALKING, ""Why do I get the feeling you'll change your tune when I start loading you up with items?""); } if(itemsInBird == 9) { yield new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""I can keep this up for hours."") .addPlayer(HeadE.HAPPY_TALKING, ""I'm glad, as we still have plenty of time to go.""); } if(itemsInBird == 10) { yield new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Are we going to visit a bank soon?"") .addPlayer(HeadE.HAPPY_TALKING, ""I'm not sure, you still have plenty of room for more stuff."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Just don't leave it too long, okay?""); } if(itemsInBird == 11) { yield new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Can we go to a bank now?"") .addPlayer(HeadE.HAPPY_TALKING, ""Just give me a little longer, okay?"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""That's what you said last time!"") .addPlayer(HeadE.HAPPY_TALKING, ""Did I?"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Yes!"") .addPlayer(HeadE.HAPPY_TALKING, ""Well, I mean it this time, promise.""); } yield new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""So...heavy..."") .addPlayer(HeadE.HAPPY_TALKING, ""I knew you'd change your tune once you started carrying things."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Can we go bank this stuff now?"") .addPlayer(HeadE.HAPPY_TALKING, ""Sure. You do look like you're about to collapse.""); } case ABYSSAL_PARASITE -> { if(!canTalk) yield new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Reeeeeee!"") .addPlayer(HeadE.SECRETIVE, ""What?"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Reeeeeee!""); yield random( new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Ongk n'hd?"") .addPlayer(HeadE.HAPPY_TALKING, ""Oh, I'm not feeling so well."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Uge f't es?"") .addPlayer(HeadE.HAPPY_TALKING, ""Please have mercy!"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""F'tp ohl't?"") .addPlayer(HeadE.HAPPY_TALKING, ""I shouldn't have eaten that kebab. Please stop talking!""), new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Noslr'rh..."") .addPlayer(HeadE.HAPPY_TALKING, ""What's the matter?"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Kdso Seo..."") .addPlayer(HeadE.HAPPY_TALKING, ""Could you...could you mime what the problem is?"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Yiao itl!"") .addPlayer(HeadE.HAPPY_TALKING, ""I want to help it but, aside from the language gap its noises make me retch!""), new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Ace'e e ur'y!"") .addPlayer(HeadE.HAPPY_TALKING, ""I think I'm going to be sick... The noises! Oh, the terrifying noises.""), new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Tdsa tukk!"") .addPlayer(HeadE.HAPPY_TALKING, ""Oh, the noises again."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Hem s'htee?"") .addPlayer(HeadE.HAPPY_TALKING, ""Please, just stop talking!"") ); } case SPIRIT_JELLY -> { if(!canTalk) yield new Dialogue().addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Bloop!""); yield random( new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Play play play play!"") .addPlayer(HeadE.HAPPY_TALKING, ""The only game I have time to play is the 'Staying Very Still' game."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""But that game is soooooo booooooring..."") .addPlayer(HeadE.HAPPY_TALKING, ""How about we use the extra house rule, that makes it the 'Staying Very Still and Very Quiet' game."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Happy happy! I love new games!""), new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""It's playtime now!"") .addPlayer(HeadE.HAPPY_TALKING, ""Okay, how about we play the 'Staying Very Still' game."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""But that game is booooooring..."") .addPlayer(HeadE.HAPPY_TALKING, ""If you win then you can pick the next game, how about that?"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Happy happy!""), new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Can we go over there now, please please please pleeeeeease?"") .addPlayer(HeadE.HAPPY_TALKING, ""Go over where?"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""I dunno, someplace fun, please please please!"") .addPlayer(HeadE.HAPPY_TALKING, ""Okay, but first, let's play the 'Sitting Very Still' game."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""But that game is booooooring..."") .addPlayer(HeadE.HAPPY_TALKING, ""Well, if you win we can go somewhere else, okay?"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Happy happy!""), new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""What game are we playing now?"") .addPlayer(HeadE.HAPPY_TALKING, ""It's called the 'Staying Very Still' game."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""This game is booooooring..."") .addPlayer(HeadE.HAPPY_TALKING, ""Hey, all that moping doesn't look very still to me."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""I never win at this game..."") .addPlayer(HeadE.HAPPY_TALKING, ""You know what? I think I'll not count it this one time"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Happy happy! You're the best friend ever!"") ); } case IBIS -> { if(!canTalk) yield new Dialogue().addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Reeeeep!""); if(player.getInventory().getAmountOf(383) >= 2) yield new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Can I look after those sharks for you?"") .addPlayer(HeadE.HAPPY_TALKING, ""I don't know. Would you eat them?"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Yes! Ooops..."") .addPlayer(HeadE.HAPPY_TALKING, ""I think I'll hang onto them myself for now.""); yield random( new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""I'm the best fisherman ever!"") .addPlayer(HeadE.HAPPY_TALKING, ""Where is your skillcape to prove it, then?"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""At home..."") .addPlayer(HeadE.HAPPY_TALKING, ""I'll bet it is.""), new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""I'll bet it is."") .addPlayer(HeadE.HAPPY_TALKING, ""I like to fish!""), new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""I'll bet it is."") .addPlayer(HeadE.HAPPY_TALKING, ""I like to fish!""), new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Hey, where are we?"") .addPlayer(HeadE.HAPPY_TALKING, ""What do you mean?"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""I just noticed we weren't fishing."") .addPlayer(HeadE.HAPPY_TALKING, ""Well, we can't fish all the time."") ); } case SPIRIT_KYATT -> { if(!canTalk) yield new Dialogue().addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Rawr!""); if(player.getInventory().containsOneItem(1759, 15416)) yield new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Human, hand me that ball of wool."") .addPlayer(HeadE.HAPPY_TALKING, ""Aww...do you want to play with it?"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""I do not 'play', human."") .addPlayer(HeadE.HAPPY_TALKING, ""If you say so, kitty! Alright, you can have it."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Aha! Ball of wool: you are mine now. I will destroy you!"") .addPlayer(HeadE.HAPPY_TALKING, ""Well I'm not giving it to you, now! I'll never get it back."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Then you leave me no choice but to destroy YOU, human!"") .addPlayer(HeadE.HAPPY_TALKING, ""Bad kitty!""); yield random( new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Guess who wants a belly rub, human."") .addPlayer(HeadE.HAPPY_TALKING, ""Umm...is it me?"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""No, human, it is not you. Guess again."") .addPlayer(HeadE.HAPPY_TALKING, ""Is it the Duke of Lumbridge?"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""You try my patience, human!"") .addPlayer(HeadE.HAPPY_TALKING, ""Is it Zamorak? That would explain why he's so cranky."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Please do not make me destroy you before I get my belly rub!""), new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Here, kitty!"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""What do you want, human?"") .addPlayer(HeadE.HAPPY_TALKING, ""I just thought I would see how you were."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""I do not have time for your distractions. Leave me be!"") .addPlayer(HeadE.HAPPY_TALKING, ""Well, sorry! Would a ball of wool cheer you up?"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""How dare you insult my intelli- what colour wool?"") .addPlayer(HeadE.HAPPY_TALKING, ""Umm...white?"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""I will end you!""), new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Hello, kitty cat!"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Human, leave me be. I'm far too busy to deal with your nonsense."") .addPlayer(HeadE.HAPPY_TALKING, ""What are you up to?"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""I am engaged in an intricate dirt-purging operation!"") .addPlayer(HeadE.HAPPY_TALKING, ""Aww, kitty's cleaning his paws! How cute!"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Know this, human. Once I finish cleaning my paws..."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""I will destroy you!""), new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Here, kitty!"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Do not toy with me, human!"") .addPlayer(HeadE.HAPPY_TALKING, ""What about under your chin?"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""I am not one of your playful kittens, human. I eat playful kittens for breakfast!"") .addPlayer(HeadE.HAPPY_TALKING, ""Not even behind your ears?"") .addSimple(""You lean down and tickle the kyatt behind the ears."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""I will...purrrrr...ooh that's quite nice...destroy...purrrrrrr...you."") ); } case SPIRIT_LARUPIA -> { if(!canTalk) yield new Dialogue().addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Rawr!""); yield random( new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Kitty cat!"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""What is your wish master?"") .addPlayer(HeadE.HAPPY_TALKING, ""Have you ever thought about doing something other than hunting and serving me?"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""You mean, like stand-up comedy, master?"") .addPlayer(HeadE.HAPPY_TALKING, ""Umm...yes, like that."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""No, master.""), new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Hello friend!"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""'Friend', master? I do not understand this word."") .addPlayer(HeadE.HAPPY_TALKING, ""Friends are people, or animals, who like one another. I think we are friends."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Ah, I think I understand friends, master."") .addPlayer(HeadE.HAPPY_TALKING, ""Great!"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""A friend is someone who looks tasty, but you don't eat."") .addPlayer(HeadE.SCARED, ""!""), new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""What are we doing today, master?"") .addPlayer(HeadE.HAPPY_TALKING, ""I don't know, what do you want to do?"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""I desire only to hunt and to serve my master."") .addPlayer(HeadE.HAPPY_TALKING, ""Err...great! I guess I'll decide then.""), new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Master, do you ever worry that I might eat you?"") .addPlayer(HeadE.HAPPY_TALKING, ""No, of course not! We're pals."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""That is good, master."") .addPlayer(HeadE.HAPPY_TALKING, ""Should I?"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Of course not, master."") .addPlayer(HeadE.HAPPY_TALKING, ""Oh. Good."") ); } case SPIRIT_GRAAHK -> { if(!canTalk) yield new Dialogue().addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Grrrrr...""); yield random( new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Your spikes are looking particularly spiky today."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Really, you think so?"") .addPlayer(HeadE.HAPPY_TALKING, ""Yes. Most pointy, indeed."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""That's really kind of you to say. I was going to spike you but I won't now..."") .addPlayer(HeadE.HAPPY_TALKING, ""Thanks?"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""...I'll do it later instead."") .addPlayer(HeadE.HAPPY_TALKING, ""*sigh!*""), new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""My spikes hurt, could you pet them for me?"") .addPlayer(HeadE.HAPPY_TALKING, ""Aww, of course I can I'll just... Oww! I think you drew blood that time.""), new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Hi!"") .addPlayer(HeadE.HAPPY_TALKING, ""Hello. Are you going to spike me again?"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""No, I got a present to apologise for last time."") .addPlayer(HeadE.HAPPY_TALKING, ""That's really sweet, thank you."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Here you go, it's a special cushion to make you comfortable."") .addPlayer(HeadE.HAPPY_TALKING, ""It's made of spikes!"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Yes, but they're therapeutic spikes."") .addPlayer(HeadE.HAPPY_TALKING, ""...""), new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""How's your day going?"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""It's great! Actually I've got something to show you!"") .addPlayer(HeadE.HAPPY_TALKING, ""Oh? What's that?"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""You'll need to get closer!"") .addPlayer(HeadE.HAPPY_TALKING, ""I can't see anything..."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""It's really small - even closer."") .addPlayer(HeadE.HAPPY_TALKING, ""Oww! I'm going to have your spikes trimmed!"") ); } case KARAMTHULU_OVERLORD -> { if(!canTalk) yield new Dialogue().addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Bloooooob.... *burp""); yield random( new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Do you want-"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Silence!"") .addPlayer(HeadE.FRUSTRATED, ""But I only..."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Silence!"") .addPlayer(HeadE.FRUSTRATED, ""Now, listen here..."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""SIIIIIILLLLLEEEEENCE!"") .addPlayer(HeadE.FRUSTRATED, ""Fine!"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Good!"") .addPlayer(HeadE.FRUSTRATED, ""Maybe I'll be so silent you'll think I never existed"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Oh, how I long for that day...""), new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Kneel before my awesome might!"") .addPlayer(HeadE.HAPPY_TALKING, ""I would, but I have a bad knee you see..."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Your feeble prattlings matter not, air-breather! Kneel or face my wrath!"") .addPlayer(HeadE.HAPPY_TALKING, ""I'm not afraid of you. You're only a squid in a bowl!"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Only? I, radiant in my awesomeness, am 'only' a squid in a bowl? Clearly you need to be shown in your place, lung-user!"") .addSimple(""*The Karamthulhu overlord narrows its eye and you find yourself unable to breathe!"") .addPlayer(HeadE.SCARED, ""Gaak! Wheeeze!"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Who rules?"") .addPlayer(HeadE.SCARED, ""You rule!"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""And don't forget it!""), new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""..."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""The answer 'be silent'!"") .addPlayer(HeadE.HAPPY_TALKING, ""You have no idea what I was going to ask you."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Yes I do; I know all!"") .addPlayer(HeadE.HAPPY_TALKING, ""Then you will not be surprised to know I was going to ask you what you wanted to do today."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""You dare doubt me!"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""The answer 'be silent' because your puny compressed brain could not even begin to comprehend my needs!"") .addPlayer(HeadE.HAPPY_TALKING, ""Well, how about I dismiss you so you can go and do what you like?"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Well, how about I topple your nations into the ocean and dance my tentacle-waving victory dance upon your watery graves?"") .addPlayer(HeadE.HAPPY_TALKING, ""Yeah...well..."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Silence! Your burbling vexes me greatly!""), new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Errr...Have you calmed down yet?"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Calmed down? Why would I need to calm down?"") .addPlayer(HeadE.HAPPY_TALKING, ""Well there is that whole 'god complex' thing..."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Complex? What 'complex' are you drooling about this time, minion?"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""It is a sad thing indeed when a god as powerful as I cannot gain recognition from the foolish mewling sheep of this 'surface' place."") .addPlayer(HeadE.SECRETIVE, ""I don't really think sheep really make mewling noises..."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Silence!"") ); } case SMOKE_DEVIL -> { if(!canTalk) yield new Dialogue().addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Roooo.... rooooo!""); yield random( new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""When are you going to be done with that?"") .addPlayer(HeadE.HAPPY_TALKING, ""Soon, I hope."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Good, because this place is too breezy."") .addPlayer(HeadE.HAPPY_TALKING, ""What do you mean?"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""I mean, it's tricky to keep hovering in this draft."") .addPlayer(HeadE.HAPPY_TALKING, ""Ok, we'll move around a little if you like."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Yes please!""), new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Hey!"") .addPlayer(HeadE.HAPPY_TALKING, ""Yes?"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Where are we going again?"") .addPlayer(HeadE.HAPPY_TALKING, ""Well, I have a lot of things to do today, so we might go a lot of places."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Are we there yet?"") .addPlayer(HeadE.HAPPY_TALKING, ""No, not yet."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""How about now?"") .addPlayer(HeadE.FRUSTRATED, ""No."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Are we still not there?"") .addPlayer(HeadE.ANGRY, ""NO!"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Okay, just checking.""), new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Ah, this is the life!"") .addPlayer(HeadE.HAPPY_TALKING, ""Having a good time up there?"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Yeah! It's great to feel the wind in your tentacles."") .addPlayer(HeadE.HAPPY_TALKING, ""Sadly, I don't know what that feels like."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Why not?"") .addPlayer(HeadE.HAPPY_TALKING, ""No tentacles for a start."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Well, nobody's perfect.""), new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Why is it always so cold here?"") .addPlayer(HeadE.HAPPY_TALKING, ""I don't think it's that cold."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""It is compared to back home."") .addPlayer(HeadE.HAPPY_TALKING, ""How hot is it where you are from?"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""I can never remember. What is the vaporisation point of steel again?"") .addPlayer(HeadE.HAPPY_TALKING, ""Pretty high."") .addPlayer(HeadE.HAPPY_TALKING, ""No wonder you feel cold here..."") ); } case ABYSSAL_LURKER -> { if(!canTalk) yield new Dialogue().addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Reeeee!""); yield random( new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Djrej gf'ig sgshe..."") .addPlayer(HeadE.HAPPY_TALKING, ""What? Are we in danger, or something?""), new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""To poshi v'kaa!"") .addPlayer(HeadE.HAPPY_TALKING, ""What? Is that even a language?""), new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""G-harrve shelmie?"") .addPlayer(HeadE.HAPPY_TALKING, ""What? Do you want something?""), new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Jehifk i'ekfh skjd."") .addPlayer(HeadE.HAPPY_TALKING, ""What? Is there somebody down an old well, or something?"") ); } case SPIRIT_COBRA -> { if(!canTalk) yield new Dialogue().addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Sssssst!""); int ringID = player.getEquipment().getRingId(); if(ringID == 4202 || ringID == 6465 || ringID == 15016) yield new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""You are under my power!"") .addPlayer(HeadE.HAPPY_TALKING, ""No, you are under my power!"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""No, you are under my power!"") .addPlayer(HeadE.HAPPY_TALKING, ""No, my power is greater!"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Your power is the greater..."") .addPlayer(HeadE.HAPPY_TALKING, ""Your powers are no match for mine!"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""You are convinced you have won this argument..."") .addPlayer(HeadE.HAPPY_TALKING, ""I won the argument...yay!"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""*Manic serpentine laughter*""); yield random( new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Do we have to do thissss right now?"") .addPlayer(HeadE.HAPPY_TALKING, ""Yes, I'm afraid so."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""You are under my sssspell..."") .addPlayer(HeadE.HAPPY_TALKING, ""I will do as you ask..."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Do we have to do thissss right now?"") .addPlayer(HeadE.HAPPY_TALKING, ""Not at all, I had just finished!""), new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""You are feeling ssssleepy..."") .addPlayer(HeadE.HAPPY_TALKING, ""I am feeling sssso ssssleepy..."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""You will bring me lotssss of sssstuff!"") .addPlayer(HeadE.HAPPY_TALKING, ""What ssssort of sssstuff?"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""What ssssort of sssstuff have you got?"") .addPlayer(HeadE.HAPPY_TALKING, ""All kindsss of sssstuff."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Then just keep bringing sssstuff until I'm ssssatissssfied!""), new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""I'm bored, do ssssomething to entertain me..."") .addPlayer(HeadE.HAPPY_TALKING, ""Errr, I'm not here to entertain you, you know."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""You will do as I assssk..."") .addPlayer(HeadE.HAPPY_TALKING, ""Your will is my command..."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""I'm bored, do ssssomething to entertain me..."") .addPlayer(HeadE.HAPPY_TALKING, ""I'll dance for you!"", ()-> player.setNextAnimation(new Animation(866))), new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""I am king of the world!"") .addPlayer(HeadE.HAPPY_TALKING, ""You know, I think there is a law against snakes being the king."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""My will is your command..."") .addPlayer(HeadE.HAPPY_TALKING, ""I am yours to command..."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""I am king of the world!"") .addPlayer(HeadE.HAPPY_TALKING, ""All hail King Serpentor!"") ); } case STRANGER_PLANT -> { if(!canTalk) yield new Dialogue().addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""...""); yield random( new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""I'M STRANGER PLANT!"") .addPlayer(HeadE.HAPPY_TALKING, ""I know you are."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""I KNOW! I'M JUST SAYING!"") .addPlayer(HeadE.HAPPY_TALKING, ""Do you have to shout like that all of the time?"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""WHO'S SHOUTING?"") .addPlayer(HeadE.HAPPY_TALKING, ""If this is you speaking normally, I'd hate to hear you shouting."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""OH, SNAP!""), new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""WILL WE HAVE TO BE HERE LONG?"") .addPlayer(HeadE.HAPPY_TALKING, ""We'll be here until I am finished."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""BUT THERE'S NO DRAMA HERE!"") .addPlayer(HeadE.HAPPY_TALKING, ""Well, how about you pretend to be an undercover agent."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""WONDERFUL! WHAT'S MY MOTIVATION?"") .addPlayer(HeadE.HAPPY_TALKING, ""You're trying to remain stealthy and secretive, while looking out for clues."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""I'LL JUST GET INTO CHARACTER! AHEM!"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""PAPER! PAPER! VARROCK HERALD FOR SALE!"") .addPlayer(HeadE.HAPPY_TALKING, ""What kind of spy yells loudly like that?"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""ONE WHOSE COVER IDENTITY IS A PAPER-SELLER, OF COURSE!"") .addPlayer(HeadE.HAPPY_TALKING, ""Ask a silly question...""), new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""DIIIIVE!"") .addPlayer(HeadE.HAPPY_TALKING, ""What? Help! Why dive?"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""OH, DON'T WORRY! I JUST LIKE TO YELL THAT FROM TIME TO TIME!"") .addPlayer(HeadE.HAPPY_TALKING, ""Well, can you give me a little warning next time?"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""WHAT, AND TAKE ALL THE FUN OUT OF LIFE?"") .addPlayer(HeadE.HAPPY_TALKING, ""If by 'fun' you mean 'sudden heart attacks', then yes, please take them out of my life!""), new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""I THINK I'M WILTING!"") .addPlayer(HeadE.HAPPY_TALKING, ""Do you need some water?"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""DON'T BE SILLY! I CAN PULL THAT OUT OF THE GROUND!"") .addPlayer(HeadE.HAPPY_TALKING, ""Then why are you wilting?"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""IT'S SIMPLE: THERE'S A DISTINCT LACK OF DRAMA!"") .addPlayer(HeadE.HAPPY_TALKING, ""Drama?"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""YES, DRAMA!"") .addPlayer(HeadE.HAPPY_TALKING, ""Okay..."") .addPlayer(HeadE.HAPPY_TALKING, ""Let's see if we can find some for you."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""LEAD ON!"") ); } case BARKER_TOAD -> { if(!canTalk) yield new Dialogue().addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Riiibit!""); if(player.getInventory().containsOneItem(2150)) yield new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Bwaaarp graaaawk? (What's that croaking in your inventory?)"") .addPlayer(HeadE.HAPPY_TALKING, ""Ah, you mean that toad?"") .addPlayer(HeadE.HAPPY_TALKING, ""Oh, I'm guessing you're not going to like me carrying a toad about."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Craaawk, croak. (I might not be all that happy, no.)"") .addPlayer(HeadE.HAPPY_TALKING, ""I'm not going to eat it."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Craaaaawk braaap croak. (Weeeeell, I'd hope not! Reminds me of my mama toad. She was inflated and fed to a jubbly, you know. A sad, demeaning way to die.)""); yield random( new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Ladies and gentlemen, for my next trick, I shall swallow this fly!"") .addPlayer(HeadE.HAPPY_TALKING, ""Seen it."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Ah, but last time was the frog...on fire?"") .addPlayer(HeadE.HAPPY_TALKING, ""No! That would be a good trick."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Well, it won't be this time either."") .addPlayer(HeadE.HAPPY_TALKING, ""Awwwww...""), new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Roll up, roll up, roll up! See the greatest show on Gielinor!"") .addPlayer(HeadE.HAPPY_TALKING, ""Where?"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Well, it's kind of...you."") .addPlayer(HeadE.HAPPY_TALKING, ""Me?"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Roll up, roll up, roll up! See the greatest freakshow on Gielinor!"") .addPlayer(HeadE.HAPPY_TALKING, ""Don't make me smack you, slimy.""), new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""We need to set up the big top somewhere near here. The locals look friendly enough."") .addPlayer(HeadE.HAPPY_TALKING, ""Are you kidding?"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Your problem is that you never see opportunities.""), new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Braaaaaaaaaaaaaaaaaaaaaaap! (*Burp!*)"") .addPlayer(HeadE.HAPPY_TALKING, ""That's disgusting behaviour!"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Braap craaaaawk craaaawk. (That, my dear boy, was my world-renowned belching.)"") .addPlayer(HeadE.HAPPY_TALKING, ""I got that part. Why are you so happy about it?"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Braaaaaaap craaaaaawk craaaaaaaawk. (My displays have bedazzled the crowned heads of Gielinor.)"") .addPlayer(HeadE.HAPPY_TALKING, ""I'd give you a standing ovation, but I have my hands full."") ); } case WAR_TORTOISE -> { if(!canTalk) yield new Dialogue().addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Roop!""); yield random( new Dialogue() .addSimple(""*The tortoise waggles its head about*"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""What are we doing in this dump?"") .addPlayer(HeadE.HAPPY_TALKING, ""Well, I was just going to take care of a few things."") .addSimple(""*The tortoise shakes its head*"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""I don't believe it. Stuck here with this young whippersnapper running around having fun."") .addPlayer(HeadE.HAPPY_TALKING, ""You know, I'm sure you would enjoy it if you gave it a chance."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Oh, you would say that, wouldn't you?""), new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Hold up a minute, there."") .addPlayer(HeadE.HAPPY_TALKING, ""What do you want?"") .addSimple(""*The tortoise bobs its head*"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""For you to slow down!"") .addPlayer(HeadE.HAPPY_TALKING, ""Well, I've stopped now."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Yes, but you'll soon start up again, won't you?"") .addPlayer(HeadE.HAPPY_TALKING, ""Probably."") .addSimple(""* The tortoise waggles its head despondently.*"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, "" I don't believe it....""), new Dialogue() .addSimple(""* The tortoise bobs its head around energetically.*"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Oh, so now you're paying attention to me, are you?"") .addPlayer(HeadE.HAPPY_TALKING, ""I pay you plenty of attention!"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Only when you want me to carry those heavy things of yours."") .addPlayer(HeadE.HAPPY_TALKING, ""I don't ask you to carry anything heavy."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""What about those lead ingots?"") .addPlayer(HeadE.HAPPY_TALKING, ""What lead ingots?"") .addSimple(""*The tortoise droops its head*"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Well, that's what it felt like...."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""*grumble grumble*""), new Dialogue() .addSimple(""*The tortoise exudes an air of reproach*"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Are you going to keep rushing around all day?"") .addPlayer(HeadE.HAPPY_TALKING, ""Only for as long as I have the energy to."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Oh. I'm glad that my not being able to keep up with you brings you such great amusement."") .addPlayer(HeadE.HAPPY_TALKING, ""I didn't mean it like that."") .addSimple(""*The tortoise waggles its head disapprovingly.*"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Well, when you are QUITE finished laughing at my expense, how about you pick up a rock larger than your body and go crawling about with it?"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""We'll see how energetic you are after an hour or two of that."") ); } case BUNYIP -> { if(!canTalk) yield new Dialogue(); //has fish if(player.getInventory().containsOneItem(13435, 317, 321, 327, 338, 345, 335, 331, 349, 359, 371, 377, 353, 341, 363, 11328, 2148, 11330, 11332, 7944, 383, 15264, 15270)) { yield new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""I see you've got some fish there, mate."") .addPlayer(HeadE.HAPPY_TALKING, ""Yeah, but I might cook them up before I give them to you!"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Humans...always ruining good fishes."") .addPlayer(HeadE.HAPPY_TALKING, ""You know, some people prefer them cooked."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Yeah. We call 'em freaks.""); } yield random( new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Where are we going and why is it not to the beach?"") .addPlayer(HeadE.HAPPY_TALKING, ""Well, we have a fair few places to go, but I suppose we could go to the beach if we get time."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Bonza! I'll get my board ready!"") .addPlayer(HeadE.HAPPY_TALKING, ""Well, even if we do go to the beach I don't know if we'll have time for that."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Awww, that's a drag...""), new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Hey Bruce, can we go down to the beach t'day?"") .addPlayer(HeadE.HAPPY_TALKING, ""Well, I have a lot of things to do today but maybe later."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Bonza!""), new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Pass me another bunch of shrimps, mate!"") .addPlayer(HeadE.HAPPY_TALKING, ""I don't know if I want any more water runes."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Righty, but I do know that I want some shrimps!"") .addPlayer(HeadE.HAPPY_TALKING, ""A fair point.""), new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Sigh..."") .addPlayer(HeadE.HAPPY_TALKING, ""What's the matter?"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""I'm dryin' out in this sun, mate."") .addPlayer(HeadE.HAPPY_TALKING, ""Well, what can I do to help?"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Well, fish oil is bonza for the skin, ya know."") .addPlayer(HeadE.HAPPY_TALKING, ""Oh, right, I think I see where this is going."") ); } case FRUIT_BAT -> { if(!canTalk) yield new Dialogue().addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Squeeeeeek!""); if(player.getInventory().getAmountOf(5972) > 3) yield new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Squeek squeek-a-squeek squeeek? (Can I have a papaya?)"") .addPlayer(HeadE.HAPPY_TALKING, ""No, I have a very specific plan for them."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Squeek? (What?)"") .addPlayer(HeadE.HAPPY_TALKING, ""I was just going to grate it over some other vegetables and eat it. Yum.""); yield random( new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Squeek-a-squeek squeek? (How much longer do you want me for?)"") .addPlayer(HeadE.HAPPY_TALKING, ""I don't really know at the moment, it all depends what I want to do today.""), new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Squeak squeek-a-squeak. (This place is fun!)"") .addPlayer(HeadE.HAPPY_TALKING, ""Glad you think so!""), new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Squeek squeek squeek-a-squeek? (Where are we going?)"") .addPlayer(HeadE.HAPPY_TALKING, ""Oh, we're likely to go to a lot of places today.""), new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Squeek squeek-a-squeek squeek? (Can you smell lemons?)"") .addPlayer(HeadE.HAPPY_TALKING, ""No, why do you ask?"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Squeak-a-squeak squeek. (Must just be thinking about them.)"") ); } case RAVENOUS_LOCUST -> { if(!canTalk) yield new Dialogue().addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Whiiiiiiiiiine!""); yield random( new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Click whiiine whiiiiine click click? (Hey, man, can you spare some lentils?)"") .addPlayer(HeadE.HAPPY_TALKING, ""What would you want with lentils?"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Whiiiiiinewhiiiiiiine click whiiiiiiiine. (I was going to make a casserole.)"") .addPlayer(HeadE.HAPPY_TALKING, ""How? You don't have a fire, pans or thumbs."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Whiiiiiiiiiiiiine! (Stop hassling me, man.)""), new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Whiiiiiine click click! (Man, it's a totally groovy day.)"") .addPlayer(HeadE.HAPPY_TALKING, ""That it is."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Whiiiiine whiiiiine whinewhiiiine. (Now, if only I wasn't being held down by 'The Man'.)"") .addPlayer(HeadE.HAPPY_TALKING, ""Which man?"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Clickclack whiiiiiine whiiiiinewhiiine. ('The Man'; the one that keeps harshing my mellow.)"") .addPlayer(HeadE.HAPPY_TALKING, ""'Harshing your mellow'? Okay, I don't want to know any more.""), new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Whiiiiiine... (Siiiiigh...)"") .addPlayer(HeadE.HAPPY_TALKING, ""What's the matter?"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Whiiiine whiiiineclickwhiiiiine whine... (I was just thinking about how meat is murder...)"") .addPlayer(HeadE.HAPPY_TALKING, ""But it isn't. Killing someone is murder."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Click click! (Good point.)""), new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Whiiiiine whinewhiiiine? (Man, how about time?)"") .addPlayer(HeadE.HAPPY_TALKING, ""I think it's about midday."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Clickwhiiiiine whiiiiiiiiiiiiine... (No, man. Isn't time, like, massive?)"") .addPlayer(HeadE.HAPPY_TALKING, ""I don't think an abstract concept can have mass..."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Whineclick click! (Oh, man, that's heavy.)"") ); } case ARCTIC_BEAR -> { if(!canTalk) yield new Dialogue().addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Rawr!""); yield random( new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Crikey! We’re tracking ourselves a real live one here. I call ’em ‘Brighteyes’."") .addPlayer(HeadE.FRUSTRATED, ""Will you stop stalking me like that?"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Lookit that! Something’s riled this one up good and proper."") .addPlayer(HeadE.HAPPY_TALKING, ""Who are you talking to anyway?"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Looks like I’ve been spotted."") .addPlayer(HeadE.HAPPY_TALKING, ""Did you think you didn’t stand out here or something?""), new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Crikey! Something seems to have startled Brighteyes, here."") .addPlayer(HeadE.HAPPY_TALKING, ""What? What’s happening?"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Maybe "" + player.getPronoun(""he's"", ""she's"") + "" scented a rival."") .addPlayer(HeadE.HAPPY_TALKING, ""I smell something, but it’s not a rival.""), new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""We’re tracking Brighteyes here as "" + player.getPronoun(""he"", ""she"") + "" goes about "" + player.getPronoun(""his"", ""her"") + "" daily routine."") .addPlayer(HeadE.HAPPY_TALKING, ""My name is "" + player.getDisplayName() + "", not Brighteyes!"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Looks like the little critter’s upset about something."") .addPlayer(HeadE.HAPPY_TALKING, ""I wonder if "" + player.getPronoun(""he"", ""she"") + ""’d be quiet if I just did really boring stuff.""), new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""These little guys get riled up real easy."") .addPlayer(HeadE.HAPPY_TALKING, ""Who wouldn’t be upset with a huge bear tracking along behind them, commenting on everything they do?"") ); } case PHOENIX -> { if(!canTalk) yield new Dialogue().addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Skreee!""); yield random( new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Skreee skree skrooo skrooooouuu. (I want to burn something.)"") .addPlayer(HeadE.HAPPY_TALKING, ""Why are you looking at me like that?"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Skeeeeooouoou! Skree skrooo, skrooouuee skreee! (Please! It won't hurt that much, and I'll bring you back straight away!)"") .addPlayer(HeadE.HAPPY_TALKING, ""Maybe later. Much later. When I'm dead from natural causes already. And medicine has failed to bring me back."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Skreee skreeeooouu skroou! (I'll hold you to it!)""), new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""May I ask you a question?"") .addPlayer(HeadE.HAPPY_TALKING, ""Skreeoooouuu, skreeee skreeeeoooo. (Yes, but you have already asked me a question.)"") .addPlayer(HeadE.HAPPY_TALKING, ""Skreeeooo, skreee skreeeeee skreeoooo. (You should have said 'May I ask you two questions?'.)"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Erm, may I ask you two questions?"") .addPlayer(HeadE.HAPPY_TALKING, ""Skroo. (No.)"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""...""), new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""May I ask you... TWO questions?"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Skree ree ree! Skree, skreee skrooou skreeeoou. (Heh heh heh. The answer to your first is yes. You may ask your second.)"") .addPlayer(HeadE.HAPPY_TALKING, ""What was RuneScape like in the distant past?"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Skreee skreeeeout skreeou. Skreee skree. (It was like it is now, only younger.)"") .addPlayer(HeadE.HAPPY_TALKING, ""..."") .addPlayer(HeadE.HAPPY_TALKING, ""You, madam, are the most pestiferous poultry I have ever met."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Skree ree ree! (Heh heh heh!)""), new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Skreeee, skree skrooo. Skrooooou skreee!"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Skreee skroooue, skreeee skreeeeeeeou. (Either you need to practice your phoenixspeak, or I should burn you where you stand.)"") .addPlayer(HeadE.HAPPY_TALKING, ""So that didn't mean 'How are you feeling today?'"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Skroo. Skroo, skreee skreou. (No, it didn't."") ); } case OBSIDIAN_GOLEM -> { if(!canTalk) yield new Dialogue().addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Brrrr!""); int capeID = player.getEquipment().getCapeId(); if(player.getInventory().containsOneItem(6570, 23659) || capeID == 6570 || capeID == 23659) yield new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Truly, you are a powerful warrior, Master!"") .addPlayer(HeadE.HAPPY_TALKING, ""I'm pleased you think so."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""It is my duty to respect you, Master."") .addPlayer(HeadE.HAPPY_TALKING, ""Oh, So you're just saying that to make me happy..."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""I obey all orders, Master.""); yield random( new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Let us go forth and prove our strength, Master!"") .addPlayer(HeadE.HAPPY_TALKING, ""Where would you like to prove it?"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""The caves of the TzHaar are filled with monsters for us to defeat, Master! TzTok-Jad shall quake in his slippers!"") .addPlayer(HeadE.HAPPY_TALKING, ""Have you ever met TzTok-Jad?"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Alas, Master, I have not. No Master has ever taken me to see him.""), new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""How many foes have you defeated, Master?"") .addPlayer(HeadE.HAPPY_TALKING, ""Quite a few, I should think."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Was your first foe as mighty as the volcano, Master?"") .addPlayer(HeadE.HAPPY_TALKING, ""Um, not quite."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""I am sure it must have been a deadly opponent, Master!"") .addPlayer(HeadE.HAPPY_TALKING, ""*Cough* It might have been a chicken. *Cough*""), new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Master! We are truly a mighty duo!"") .addPlayer(HeadE.HAPPY_TALKING, ""Do you think so?"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Of course, Master! I am programmed to believe so."") .addPlayer(HeadE.HAPPY_TALKING, ""Do you do anything you're not programmed to?"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""No, Master."") .addPlayer(HeadE.HAPPY_TALKING, ""I guess that makes things simple for you...""), new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Do you ever doubt your programming, Master?"") .addPlayer(HeadE.HAPPY_TALKING, ""I don't have programming. I can think about whatever I like."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""What do you think about, Master?"") .addPlayer(HeadE.HAPPY_TALKING, ""Oh, simple things: the sound of one hand clapping, where the gods come from...Simple things."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Paradox check = positive. Error. Reboot."") ); } case GRANITE_LOBSTER -> { if(!canTalk) yield new Dialogue().addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""CLomp! Clap Clamp!""); if(player.isQuestComplete(Quest.FREMENNIK_TRIALS)) yield random( new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Ho, my Fremennik brother, shall we go raiding?"") .addPlayer(HeadE.HAPPY_TALKING, ""Well, I suppose we could when I'm done with this."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Yes! To the looting and the plunder!""), new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""We shall heap the helmets of the fallen into a mountain!"") .addPlayer(HeadE.HAPPY_TALKING, ""The outerlanders have insulted our heritage for the last time!"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""The longhall will resound with our celebration!"") ); yield new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Clonkclonk clonk grind clonk. (Keep walking, outerlander. We have nothing to discuss.)"") .addPlayer(HeadE.HAPPY_TALKING, ""Fair enough."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Clonkclonkclonk grind clonk grind? (It's nothing personal, you're just an outerlander, you know?)""); } case PRAYING_MANTIS -> { if(!canTalk) yield new Dialogue().addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Clatter click chitter!""); if(player.getInventory().containsOneItem(10010) || player.getEquipment().getWeaponId() == 10010) yield new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Clatter click chitter click? (Wouldn't you learn focus better if you used chopsticks?)"") .addPlayer(HeadE.HAPPY_TALKING, ""Huh?"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Clicker chirrpchirrup. (For catching the butterflies, grasshopper.)"") .addPlayer(HeadE.HAPPY_TALKING, ""Oh, right! Well, if I use anything but the net I squash them."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Chirrupchirrup click! (Then, I could have them!)""); yield random( new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Chitter chirrup chirrup? (Have you been following your training, grasshopper?)"") .addPlayer(HeadE.HAPPY_TALKING, ""Yes, almost every day."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Chirrupchirrup chirrup. ('Almost' is not good enough.)"") .addPlayer(HeadE.HAPPY_TALKING, ""Well, I'm trying as hard as I can."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Chirrup chitter chitter chirrup? (How do you expect to achieve enlightenment at this rate, grasshopper?)"") .addPlayer(HeadE.HAPPY_TALKING, ""Spontaneously.""), new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Chitterchitter chirrup clatter. (Today, grasshopper, I will teach you to walk on rice paper.)"") .addPlayer(HeadE.HAPPY_TALKING, ""What if I can't find any?"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Clatter chitter click chitter... (Then we will wander about and punch monsters in the head...)"") .addPlayer(HeadE.HAPPY_TALKING, ""I could do in an enlightened way if you want?"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Chirrupchitter! (That will do!)""), new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Clatter chirrup chirp chirrup clatter clatter. (A wise man once said; 'Feed your mantis and it will be happy'.)"") .addPlayer(HeadE.HAPPY_TALKING, ""Is there any point to that saying?"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Clatter chirrupchirrup chirp. (I find that a happy mantis is its own point.)""), new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Clatter chirrupchirp- (Today, grasshopper, we will-)"") .addPlayer(HeadE.HAPPY_TALKING, ""You know, I'd rather you call me something other than grasshopper."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Clitterchirp? (Is there a reason for this?)"") .addPlayer(HeadE.HAPPY_TALKING, ""You drool when you say it."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Clickclatter! Chirrup chirpchirp click chitter... (I do not! Why would I drool when I cann you a juicy...)"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""...clickclick chitter clickchitter click... (...succulent, nourishing, crunchy...)"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""*Drooool*"") .addPlayer(HeadE.HAPPY_TALKING, ""You're doing it again!"") ); } case FORGE_REGENT -> { if(!canTalk) yield new Dialogue().addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Crackley spit crack sizzle...""); yield random( new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Crackley spit crack sizzle? (Can we go Smithing?)"") .addPlayer(HeadE.HAPPY_TALKING, ""Maybe."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Hiss? (Can we go smelt something?)"") .addPlayer(HeadE.HAPPY_TALKING, ""Maybe."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Flicker crackle sizzle? (Can we go mine something to smelt?)"") .addPlayer(HeadE.HAPPY_TALKING, ""Maybe."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Sizzle flicker! (Yay! I like doing that!)"") .addPlayer(HeadE.HAPPY_TALKING, ""...""), new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Hiss. (I'm happy.)"") .addPlayer(HeadE.HAPPY_TALKING, ""Good."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Crackle. (Now I'm sad.)"") .addPlayer(HeadE.HAPPY_TALKING, ""Oh dear, why?"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Hiss-hiss. (Happy again.)"") .addPlayer(HeadE.HAPPY_TALKING, ""Glad to hear it."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Crackley-crick. (Sad now.)"") .addPlayer(HeadE.HAPPY_TALKING, ""Um."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Hiss. (Happy.)"") .addPlayer(HeadE.HAPPY_TALKING, ""Right..."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Crackle. (Sad.)"") .addPlayer(HeadE.HAPPY_TALKING, ""You're very strange."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Sizzle hiss? (What makes you say that?)"") .addPlayer(HeadE.HAPPY_TALKING, ""Oh...nothing in particular.""), new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Sizzle! (I like logs.)"") .addPlayer(HeadE.HAPPY_TALKING, ""They are useful for making planks."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Sizzley crack hiss spit. (No, I just like walking on them. They burst into flames.)"") .addPlayer(HeadE.HAPPY_TALKING, ""It's a good job I can use you as a firelighter really!""), new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Sizzle... (I'm bored.)"") .addPlayer(HeadE.HAPPY_TALKING, ""Are you not enjoying what we're doing?"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Crackley crickle sizzle. (Oh yes, but I'm still bored.)"") .addPlayer(HeadE.HAPPY_TALKING, ""Oh, I see."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Sizzle hiss? (What's that over there?)"") .addPlayer(HeadE.HAPPY_TALKING, ""I don't know. Should we go and look?"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Hiss crackle spit sizzle crack? (Nah, that's old news - I'm bored of it now.)"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Sizzle hiss? (What's that over there?)"") .addPlayer(HeadE.HAPPY_TALKING, ""But...wha...where now?"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Sizzle crack crickle. (Oh no matter, it no longer interests me.)"") .addPlayer(HeadE.HAPPY_TALKING, ""You're hard work."") ); } case TALON_BEAST -> { if(!canTalk) yield new Dialogue().addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Screeee!""); yield random( new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Is this all you apes do all day, then?"") .addPlayer(HeadE.HAPPY_TALKING, ""Well, we do a lot of other things, too."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""That’s dull. Lets go find something and bite it."") .addPlayer(HeadE.HAPPY_TALKING, ""I wouldn’t want to spoil my dinner."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""So, I have to watch you trudge about again? Talk about boring.""), new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""This place smells odd…"") .addPlayer(HeadE.HAPPY_TALKING, ""Odd?"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Yes, not enough is rotting…"") .addPlayer(HeadE.HAPPY_TALKING, ""For which I am extremely grateful.""), new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Hey!"") .addPlayer(HeadE.HAPPY_TALKING, ""Aaaargh!"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Why d’you always do that?"") .addPlayer(HeadE.HAPPY_TALKING, ""I don’t think I’ll ever get used to having a huge, ravenous feline sneaking around behind me all the time."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""That’s okay, I doubt I’ll get used to following an edible, furless monkey prancing in front of me all the time either.""), new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""C’mon! Lets go fight stuff!"") .addPlayer(HeadE.HAPPY_TALKING, ""What sort of stuff?"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""I dunno? Giants, monsters, vaguely-defined philosophical concepts. You know: stuff."") .addPlayer(HeadE.HAPPY_TALKING, ""How are we supposed to fight a philosophical concept?"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""With subtle arguments and pointy sticks!"") .addPlayer(HeadE.HAPPY_TALKING, ""Well, I can see you’re going to go far in debates."") ); } case GIANT_ENT -> { if(!canTalk) yield new Dialogue().addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Creeeeeeeek....""); if(player.getTempAttribs().getI(""ent_fam_dial"") == 0) { player.getTempAttribs().setI(""ent_fam_dial"", 1); yield new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Creeeeeeeeeeeak..... (I.....)"") .addPlayer(HeadE.HAPPY_TALKING, ""Yes?"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""....."") .addSimple(""After a while you realise that the ent has finished speaking for the moment.""); } if(player.getTempAttribs().getI(""ent_fam_dial"") == 1) { player.getTempAttribs().setI(""ent_fam_dial"", 2); yield new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Creak..... Creaaaaaaaaak..... (Am.....)"") .addPlayer(HeadE.HAPPY_TALKING, ""Yes?"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""....."") .addSimple(""After a while you realise that the ent has finished speaking for the moment.""); } if(player.getTempAttribs().getI(""ent_fam_dial"") == 2) { player.getTempAttribs().setI(""ent_fam_dial"", 3); yield new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Grooooooooan..... (Feeling.....)"") .addPlayer(HeadE.HAPPY_TALKING, ""Yes? We almost have a full sentence now - the suspense is killing me!"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""....."") .addSimple(""After a while you realise that the ent has finished speaking for the moment.""); } player.getTempAttribs().setI(""ent_fam_dial"", 0); yield random( new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Groooooooooan..... (Sleepy.....)"") .addPlayer(HeadE.HAPPY_TALKING, ""I'm not sure if that was worth all the waiting.""), new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Grooooooan.....creeeeeeeak (Restful.....)"") .addPlayer(HeadE.HAPPY_TALKING, ""I'm not sure if that was worth all the waiting.""), new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Grrrrooooooooooooooan..... (Achey.....)"") .addPlayer(HeadE.HAPPY_TALKING, ""I'm not sure if that was worth all the waiting.""), new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Creeeeeeeegroooooooan..... (Goood.....)"") .addPlayer(HeadE.HAPPY_TALKING, ""I'm not sure if that was worth all the waiting.""), new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Creeeeeeeeeeeeeaaaaaak..... (Tired.....)"") .addPlayer(HeadE.HAPPY_TALKING, ""I'm not sure if that was worth all the waiting."") ); } case HYDRA -> { if(!canTalk) yield new Dialogue().addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Raaaasp!""); yield random( new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Raaaspraaasp? (Isn't it hard to get things done with just one head?)"") .addPlayer(HeadE.HAPPY_TALKING, ""Not really!"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Raaasp raaaaap raaaasp? (Well I suppose you work with what you got, right?"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Raaaaaasp raaaasp raaaasp. (At least he doesn't have someone whittering in their ear all the time.)"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Raaaaaaasp! (Quiet, you!)""), new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Raaaasp raaaasp! (Man, I feel good!)"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Raaasp ssssss raaaasp. (That's easy for you to say.)"") .addPlayer(HeadE.HAPPY_TALKING, ""What's up?"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Raaa.... (well...)"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Raaaaasp sss rassssp. (Don't pay any attention, they are just feeling whiny.)"") .addPlayer(HeadE.HAPPY_TALKING, ""But they're you, aren't they?"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Raaaasp raasp rasssp! (Don't remind me!)""), new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Rassssp rasssssp! (You know, two heads are better than one!)"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Raaaasp rassssp sssssp.... (Unless you're the one doing all the heavy thinking....)"") .addPlayer(HeadE.HAPPY_TALKING, ""I think I'll stick to one for now, thanks.""), new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Raaaaaaasp. (Siiiigh.)"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Raasp raasp raaaaasp? (What's up this time?)"") .addPlayer(HeadE.HAPPY_TALKING, ""Can I help?"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Rasssp ssssssp? raaaaasp raaaasp. (Do you mind? This is a private conversation.)"") .addPlayer(HeadE.HAPPY_TALKING, ""Well, excu-u-use me."") ); } case SPIRIT_DAGANNOTH -> { if(!canTalk) yield new Dialogue().addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Grooooowl""); yield random( new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Grooooooowl graaaaawl raaaawl? (Are you ready to surrender to the power of the Deep Waters?)"") .addPlayer(HeadE.HAPPY_TALKING, ""Err, not really."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Rooooowl? (How about now?)"") .addPlayer(HeadE.HAPPY_TALKING, ""No, sorry."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Rooooowl? (How about now?)"") .addPlayer(HeadE.HAPPY_TALKING, ""No, sorry. You might want to try again a little later.""), new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Groooooowl. Hsssssssssssssss! (The Deeps will swallow the lands. None will stand before us!)"") .addPlayer(HeadE.HAPPY_TALKING, ""What if we build boats?"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Hsssssssss groooooowl? Hssssshsss grrooooooowl? (What are boats? The tasty wooden containers full of meat?)"") .addPlayer(HeadE.HAPPY_TALKING, ""I suppose they could be described as such, yes.""), new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Hssssss graaaawl grooooowl, growwwwwwwwwl! (Oh how the bleak gulfs hunger for the Day of Rising.)"") .addPlayer(HeadE.HAPPY_TALKING, ""My brain hurts when I listen to you talk..."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Raaaaawl groooowl grrrrawl! (That's the truth biting into your clouded mind!)"") .addPlayer(HeadE.HAPPY_TALKING, ""Could you try using a little less truth please?""), new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Raaaawl! (Submit!)"") .addPlayer(HeadE.HAPPY_TALKING, ""Submit to what?"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Hssssssssss rawwwwwl graaaawl! (To the inevitable defeat of all life on the Surface!)"") .addPlayer(HeadE.HAPPY_TALKING, ""I think I'll wait a little longer before I just keep over and submit, thanks"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Hsssss, grooooowl, raaaaawl. (Well, it's your choice, but those that submit first will be eaten first.)"") .addPlayer(HeadE.HAPPY_TALKING, ""I'll pass on that one, thanks."") ); } case UNICORN_STALLION -> { if(!canTalk) yield new Dialogue().addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Neigh .... neigh!""); if(player.getHitpoints() < player.getMaxHitpoints()*0.6) yield new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Whicker snort! Whinny whinny whinny. (You're hurt! Let me try to heal you.)"") .addPlayer(HeadE.HAPPY_TALKING, ""Yes, please do!"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Snuffle whicker whicker neigh neigh... (Okay, we'll begin with acupuncture and some reiki, then I'll get my crystals...)"") .addPlayer(HeadE.HAPPY_TALKING, ""Or you could use some sort of magic...like the other unicorns..."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Whicker whinny whinny neigh. (Yes, but I believe in alternative medicine.)"") .addPlayer(HeadE.HAPPY_TALKING, ""Riiight. Don't worry about it, then; I'll be fine.""); yield random( new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Neigh neigh neighneigh snort? (Isn't everything so awesomely wonderful?)"") .addPlayer(HeadE.HAPPY_TALKING, ""Err...yes?"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Whicker whicker snuffle. (I can see you're not tuning in, "" + player.getDisplayName() + "".)"") .addPlayer(HeadE.HAPPY_TALKING, ""No, no, I'm completely at one with...you know...everything."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Whicker! (Cosmic.)""), new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Whicker whicker. Neigh, neigh, whinny. (I feel so, like, enlightened. Let's meditate and enhance our auras.)"") .addPlayer(HeadE.HAPPY_TALKING, ""I can't do that! I barely even know you."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Whicker... (Bipeds...)""), new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Whinny whinny whinny. (I think I'm astrally projecting.)"") .addPlayer(HeadE.HAPPY_TALKING, ""Okay... Hang on. Seeing as I summoned you here, wouldn't that mean you are physically projecting instead?"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Whicker whicker whicker. (You're, like, no fun at all, man.)""), new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Whinny, neigh! (Oh, happy day!)"") .addPlayer(HeadE.HAPPY_TALKING, ""Happy day? Is that some sort of holiday or something?"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Snuggle whicker (Man, you're totally, like, uncosmic, "" + player.getDisplayName() + "".)"") ); } case WOLPERTINGER -> new Dialogue().addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Rawr!""); case PACK_YAK -> new Dialogue().addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Barroobaroooo baaaaaaaaarooo!""); case FIRE_TITAN -> { if(!canTalk) yield new Dialogue().addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Brrrr....""); if(player.getInventory().containsOneItem(590)) yield new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Relight my fire."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""A tinderbox is my only desire."") .addPlayer(HeadE.HAPPY_TALKING, ""What are you singing?"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Just a song I heard a while ago."") .addPlayer(HeadE.HAPPY_TALKING, ""A tinderbox is my only desire."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""You're just jealous of my singing voice."") .addPlayer(HeadE.HAPPY_TALKING, ""Where did you hear this again?"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Oh, you know, just with some other fire titans. Out for a night on the pyres."") .addPlayer(HeadE.HAPPY_TALKING, ""Hmm. Come on then. We have stuff to do.""); yield random( new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Pick flax."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Jump to it."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""If you want to get to Fletching level 99."") .addPlayer(HeadE.HAPPY_TALKING, ""That song...is terrible."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Sorry.""), new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""You're fanning my flame with your wind spells."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""I'm singeing the curtains with my heat."") .addPlayer(HeadE.HAPPY_TALKING, ""Oooh, very mellow.""), new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""I'm burning up."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""I want the world to know."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""I got to let it show."") .addPlayer(HeadE.HAPPY_TALKING, ""Catchy.""), new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""It's raining flame!"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Huzzah!"") .addPlayer(HeadE.HAPPY_TALKING, ""You have a...powerful voice."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Thanks""), new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Let's go fireside."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""I think I've roasted the sofa."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""I think I've burnt down the hall."") .addPlayer(HeadE.HAPPY_TALKING, ""Can't you sing quietly?"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Sorry."") ); } case MOSS_TITAN -> { if(!canTalk) yield new Dialogue().addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Brrr...""); yield new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Oh, look! A bug!"") .addPlayer(HeadE.HAPPY_TALKING, ""It's quite a large bug."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""He's so cute! I wanna keep him."") .addPlayer(HeadE.HAPPY_TALKING, ""Well, be careful."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""I'm gonna call him Buggie and I'm gonna keep him in a box."") .addPlayer(HeadE.HAPPY_TALKING, ""Don't get overexcited."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""I'm gonna feed him and we're gonna be so happy together!"") .addSimple(""The Moss titan begins to bounce up and down."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Aww...Buggie went squish."") .addPlayer(HeadE.HAPPY_TALKING, ""Sigh.""); } case ICE_TITAN -> { if(!canTalk) yield new Dialogue().addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Brrrrrr...""); //in kharidian desert if(player.getX() > 3130 && player.getX() < 3520 && player.getY() < 3130 && player.getY() > 2755) yield new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""I'm melting!"") .addPlayer(HeadE.HAPPY_TALKING, ""I have to admit, I am rather on the hot side myself."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""No, I mean I'm actually melting! My legs have gone dribbly."") .addPlayer(HeadE.HAPPY_TALKING, ""Urk! Well, try hold it together.""); yield new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""It's too hot here."") .addPlayer(HeadE.HAPPY_TALKING, ""It's really not that hot. I think it's rather pleasant."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Well, it's alright for some. Some of us don't like the heat. I burn easily - well, okay, melt."") .addPlayer(HeadE.HAPPY_TALKING, ""Well, at least I know where to get a nice cold drink if I need one."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""What was that?"") .addPlayer(HeadE.HAPPY_TALKING, ""Nothing. Hehehehe""); } case LAVA_TITAN -> { if(!canTalk) yield new Dialogue().addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Brrrrr....""); yield new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Isn’t it a lovely day, Titan?"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""It is quite beautiful. The perfect sort of day for a limerick. Perhaps, I could tell you one?"") .addPlayer(HeadE.HAPPY_TALKING, ""That sounds splendid."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""There once was a bard of Edgeville,"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Whose limericks were quite a thrill,"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""He wrote this one here,"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""His best? Nowhere near,"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""But at least half a page it did fill.""); } case SWAMP_TITAN -> { if(!canTalk) yield new Dialogue().addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Brrrrr....""); yield new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""I’m alone, all alone I say."") .addPlayer(HeadE.HAPPY_TALKING, ""Oh, stop being so melodramatic."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""It’s not easy being greenery…well, decomposing greenery."") .addPlayer(HeadE.HAPPY_TALKING, ""Surely, you’re not the only swamp…thing in the world? What about the other swamp titans?"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""They’re not my friends…they pick on me…they’re so mean…"") .addPlayer(HeadE.HAPPY_TALKING, ""Why would they do that?"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""They think I DON’T smell."") .addPlayer(HeadE.HAPPY_TALKING, ""Oh, yes. That is, er, mean…""); } case GEYSER_TITAN -> { if(!canTalk) yield new Dialogue().addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Brrrrr....""); yield new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Did you know a snail can sleep up to three years?"") .addPlayer(HeadE.HAPPY_TALKING, ""I wish I could do that. Ah...sleep.""); } case ABYSSAL_TITAN -> new Dialogue().addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Scruunt, scraaan.....""); case IRON_TITAN, STEEL_TITAN -> new Dialogue().addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Brrrrrr...""); case MEERKATS -> { if(!canTalk) yield new Dialogue().addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Chatter Chatter""); yield new Dialogue() .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Chatter Chatter. Chatter chatter chatter chatter chatter. Chatter! (We're pretty unlucky. Often, we hit a box when we try to burrow where you tell us. Very suspicious!)"") .addPlayer(HeadE.HAPPY_TALKING, ""Well, if we remove all the boxes, you'll be able to burrow anywhere!"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Chatter chatter chatter! (Then the boxes must be removed!)"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Chatter! (Agreed!)"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Chatter chatter chatter! (Let's dig out those boxes!)"") .addPlayer(HeadE.HAPPY_TALKING, ""That's the spirit!""); } case GHAST -> new Dialogue().addNPC(familiar.getId(), HeadE.FRUSTRATED, ""Woooooo woooo!""); case BLOODRAGER_1, BLOODRAGER_2, BLOODRAGER_3, BLOODRAGER_4, BLOODRAGER_5, BLOODRAGER_6, BLOODRAGER_7, BLOODRAGER_8, BLOODRAGER_9, BLOODRAGER_10 ->{ if(!canTalk) yield new Dialogue().addNPC(familiar.getId(), HeadE.FRUSTRATED, ""Yahadahalyonih dahdikad, bebehsha.""); if(!player.getTempAttribs().getB(""talked_to_bloograger"")) { player.getTempAttribs().setB(""talked_to_bloograger"", true); yield new Dialogue().addNPC(familiar.getId(), HeadE.FRUSTRATED, ""Brother, you are always welcome to talk with me.""); } yield random( new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Are all gorajo as cheery as you?"") .addNPC(familiar.getId(), HeadE.FRUSTRATED, ""Come to the gorajo plane and find out, brother! In the clan fringes, you will find bloodragers, and there are none more welcoming. You would be treated like a sachem."") .addPlayer(HeadE.HAPPY_TALKING, ""I would love to! Are the other gorajo as friendly?"") .addNPC(familiar.getId(), HeadE.FRUSTRATED, ""Their lives are more complicated, brother. They must bear burdens, teach, guide and lead. Although we must protect the clan and serve Challem, we have nothing else to cloud our minds."") .addPlayer(HeadE.HAPPY_TALKING, ""Well, I'll hold you to that invite. If we ever get out of here, of course.""), new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""How do you like it in Daemonheim?"") .addNPC(familiar.getId(), HeadE.FRUSTRATED, ""It is a place, as any other. I am just happy to be alive, taking sharp rukhs full of air-"") .addPlayer(HeadE.HAPPY_TALKING, ""Im not sure I have a rukh."") .addNPC(familiar.getId(), HeadE.FRUSTRATED, ""Sure you do! Or how else would you grebbit? I am just happy to be alive, breathing the air and completing the task that has been asked of me. Challem be praised.""), new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""I don't have any more questions."") .addNPC(familiar.getId(), HeadE.FRUSTRATED, ""Shame. I feel that we are pollen on the same wind, friend."") ); } case STORMBRINGER_1, STORMBRINGER_2, STORMBRINGER_3, STORMBRINGER_4, STORMBRINGER_5, STORMBRINGER_6, STORMBRINGER_7, STORMBRINGER_8, STORMBRINGER_9, STORMBRINGER_10 -> { if(!canTalk) yield new Dialogue().addNPC(familiar.getId(), HeadE.FRUSTRATED, ""Rooooooo!""); if(!player.getTempAttribs().getB(""talked_to_stormbringer"")){ player.getTempAttribs().setB(""talked_to_stormbringer"", true); yield new Dialogue().addNPC(familiar.getId(), HeadE.FRUSTRATED, ""Little cub, I see you have questions for me.""); } yield random( new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""How do you cast magic? You don't seem to carry any runes."") .addNPC(familiar.getId(), HeadE.FRUSTRATED, ""So, how can I possibly form magic?"") .addPlayer(HeadE.HAPPY_TALKING, ""Yes, I guess."") .addNPC(familiar.getId(), HeadE.FRUSTRATED, ""You are right, we have no runes, but some of us are born with currents of magic rippling over our bodies. Such is the power generated by a stormbringer that we render our mothers blind and infertile during childbirth."") .addNPC(familiar.getId(), HeadE.FRUSTRATED, ""One day I hope to be a Blind Mother. They are highly esteemed and carried on the back of their own worldbearer.""), new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""How powerful is a stormbringer? Have you killed a dragon?"") .addNPC(familiar.getId(), HeadE.FRUSTRATED, ""A drah-gon? Is that like the triple-bellied wolflok?"") .addPlayer(HeadE.HAPPY_TALKING, ""Probably not. Twenty-feet high, firebreathing?"") .addNPC(familiar.getId(), HeadE.FRUSTRATED, ""Oh, it sounds much like! Seven heads? Large bellows on its sides, pumping out acid?"") .addPlayer(HeadE.HAPPY_TALKING, ""Bellows? No, definitely no bellows."") .addNPC(familiar.getId(), HeadE.FRUSTRATED, ""Then it is a shame. The creatures on our plane sound far more dangerous.""), new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""How do you like it in Daemonheim?"") .addNPC(familiar.getId(), HeadE.FRUSTRATED, ""I like it very little. I grow tired of this place."") .addPlayer(HeadE.HAPPY_TALKING, ""Then why don't you just leave? If you're so tired of floating about behind me, why don't you just go?"") .addNPC(familiar.getId(), HeadE.FRUSTRATED, ""Do not tempt me. You are like a tiny pup, nibbling and barking at my heel. I am here because the gorajos greatest duty is to hinder the one who created this place."") .addNPC(familiar.getId(), HeadE.FRUSTRATED, ""We sense that great headway has been made; that we have dropped over a waterfall and risen, coughing and spluttering to the surface. Yet, there are many turns and falls ahead."") .addNPC(familiar.getId(), HeadE.FRUSTRATED, ""I follow you because you have shown a remarkable habit of stumbling into trouble, young fawn. When that trouble comes, we shall push you aside and finish this."") .addPlayer(HeadE.HAPPY_TALKING, ""Charming.""), new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""I don't have any more questions."") .addNPC(familiar.getId(), HeadE.FRUSTRATED, ""That is a good thing. We must prepare for the next battle."") ); } case HOARDSTALKER_1, HOARDSTALKER_2, HOARDSTALKER_3, HOARDSTALKER_4, HOARDSTALKER_5, HOARDSTALKER_6, HOARDSTALKER_7, HOARDSTALKER_8, HOARDSTALKER_9, HOARDSTALKER_10 -> { if(!canTalk) yield new Dialogue().addNPC(familiar.getId(), HeadE.FRUSTRATED, ""Nabe!""); if(!player.getTempAttribs().getB(""talked_to_hoardstalker"")){ player.getTempAttribs().setB(""talked_to_hoardstalker"", true); yield new Dialogue().addNPC(familiar.getId(), HeadE.FRUSTRATED, ""Are you sure we can stop, naabe? Aren't there creatures about?""); } yield random( new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""You're a little timid for a gorajo, aren't you?"") .addNPC(familiar.getId(), HeadE.FRUSTRATED, ""Naabe, a hoardstalker has little or no experience of combat. I am told that I fight like a cat on hind legs."") .addOptions(""Choose an option:"", new Options() { @Override public void create() { option(""Don't worry, I have your back."", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Don't worry, I have your back."") .addNPC(familiar.getId(), HeadE.FRUSTRATED, ""Not just my back, I hope. I find a foe more terrifying when "" + ""they run at me from the front. Although we do not die in our spirit form, we must rest for a week due to "" + ""our spirit wounds, so others would have to perform my role for me."") .addNPC(familiar.getId(), HeadE.FRUSTRATED, ""They would be like a woodpecket attempting to feed from a tortoise. "" + ""I'd come back to find the crops irrigated with milk, "" + ""weapons dipped in water, "" + ""and babies drinking poison. Churra, it is too terrible to think on."") ); option(""Then what use are you?"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Then what use are you?"") .addNPC(familiar.getId(), HeadE.FRUSTRATED, ""Churra! You have a closed mind on those shoulders. I may not be a"" + "" towering bloodrager or a graceful deathslinger, but I can be useful where they cannot"") .addNPC(familiar.getId(), HeadE.FRUSTRATED, ""Let me scavenge in these ruins, naabe. I will bring you such "" + ""items that you would never question my place here."") ); } }), new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Do you like it in Daemonheim? I can't imagine how anyone could."") .addNPC(familiar.getId(), HeadE.FRUSTRATED, ""I see this place in a way that you do not, naabe. It amazes me how something can "" + ""go down so deep, yet still be strong and broad. I cannot help but applaud the mind behind these dungeons."") .addNPC(familiar.getId(), HeadE.FRUSTRATED, ""The workmanship, too...it makes me want to put down my tools and reincarnate "" + ""as a bloodrager. I feel like a sparrowhawk who has been chased off his kill by a dragon."") .addPlayer(HeadE.HAPPY_TALKING, ""But this place is evil, and thousands died building it. I doubt you've murdered anyone to make a dagger, you know."") .addNPC(familiar.getId(), HeadE.FRUSTRATED, ""And that is some comfort. I feel I must be careful about what I learn and study "" + ""on this plane. There are poisoned thorns among the flowering wonders""), new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Why are you called a hoardstalker? It seems a strange choice for a...blacksmith and scavenger, I guess."") .addNPC(familiar.getId(), HeadE.FRUSTRATED, ""We are not just required to make the tools of our clansmen, naabe, We must "" + ""protect the tools from those who would take them."") .addPlayer(HeadE.HAPPY_TALKING, ""Still, hoardstalker is a silly name."") .addNPC(familiar.getId(), HeadE.FRUSTRATED, ""Naabe, I have held this back from you until now, but the term "" + player.getDisplayName() + "", in our tongue, means 'One-Who-Juggles-Piglets'. A less-mature gorajo would find that amusing.""), new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""I don't have any more questions."") .addNPC(familiar.getId(), HeadE.FRUSTRATED, ""No problem, naabe. Just make sure nothing sneaks past and hurts me."") ); } case SKINWEAVER_1, SKINWEAVER_2, SKINWEAVER_3, SKINWEAVER_4, SKINWEAVER_5, SKINWEAVER_6, SKINWEAVER_7, SKINWEAVER_8, SKINWEAVER_9, SKINWEAVER_10 -> { if(!canTalk) yield new Dialogue().addNPC(familiar.getId(), HeadE.FRUSTRATED, ""Naaabe!""); if(!player.getTempAttribs().getB(""talked_to_skinweaver"")){ player.getTempAttribs().setB(""talked_to_skinweaver"", true); yield new Dialogue().addNPC(familiar.getId(), HeadE.FRUSTRATED, ""This is my first time on this plane, naabe. I hope I can serve you well.""); } yield random( new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""What is your name? My name is ""+ player.getDisplayName() + "", by the way."") .addNPC(familiar.getId(), HeadE.FRUSTRATED, ""I get confused with these titles you humans take pride in. Fremennik names,"" + "" first names, last names... Gorajo have no need to be individual - to have a name that no-one else has."") .addPlayer(HeadE.HAPPY_TALKING, ""How can you not have a name?"") .addNPC(familiar.getId(), HeadE.FRUSTRATED, ""Everything we do is for the clan. If a problem arises, a role will be required, "" + ""not an individual. The individual has no place among the gorajo."") .addNPC(familiar.getId(), HeadE.FRUSTRATED, ""Please do not take it as rudeness, but I cannot understand how your world "" + ""functions with names and individuals, naabe.""), new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""What does a skinweaver do, exactly?"") .addNPC(familiar.getId(), HeadE.FRUSTRATED, ""We are healers of livestock, crops and other gorajo. Which reminds me, "" + ""naabe, do you mind if I ask you a question?"") .addPlayer(HeadE.HAPPY_TALKING, ""Sure."") .addNPC(familiar.getId(), HeadE.FRUSTRATED, ""Do you find that human organs feel like slippery fish? And that your skin is "" + ""stretchy like the dried sap of an utuku?"") .addPlayer(HeadE.HAPPY_TALKING, ""Uh. I'm feeling a little faint."") .addNPC(familiar.getId(), HeadE.FRUSTRATED, ""Don't worry! I have cat spittle for your head should you fall. And I am on hand to suck any blood clots from your brain.""), new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""How do you like it in Daemonheim?."") .addNPC(familiar.getId(), HeadE.FRUSTRATED, ""Naabe, let me tell you something. When I was a few years younger than I am now, "" + ""I helped to heal a nustukh: a creature as big as three floors of this place."") .addNPC(familiar.getId(), HeadE.FRUSTRATED, ""The nustukh do not benefit the gorajo in any way, but they are the "" + ""reincarnations of our greatest leaders. They have great significance to our people."") .addNPC(familiar.getId(), HeadE.FRUSTRATED, ""This nustukh was ravaged by a corruption that ate at every one of its organs. "" + ""A skinweaver was required to crawl in through an open lesion and heal it: I volunteered immediately. I spent two weeks inside."") .addNPC(familiar.getId(), HeadE.FRUSTRATED, ""I cannot help but be reminded of the nustukh in Daemonheim. The dungeons are as rank and unwholesome, and I feel that my powers are just as ineffective inside.""), new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""I don't have any more questions."") .addNPC(familiar.getId(), HeadE.FRUSTRATED, ""I can understand your curiosity, naabe. Feel free to talk whenever you need."") ); } case WORLDBEARER_1, WORLDBEARER_2, WORLDBEARER_3, WORLDBEARER_4, WORLDBEARER_5, WORLDBEARER_6, WORLDBEARER_7, WORLDBEARER_8, WORLDBEARER_9, WORLDBEARER_10 -> { if(!canTalk) yield new Dialogue().addNPC(familiar.getId(), HeadE.FRUSTRATED, ""Naaabe!""); if(!player.getTempAttribs().getB(""talked_to_worldbearer"")){ player.getTempAttribs().setB(""talked_to_worldbearer"", true); yield new Dialogue().addNPC(familiar.getId(), HeadE.FRUSTRATED, ""I am not a great talker, little cub. For my sake, make it quick.""); } yield random( new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Do you need help carrying?"") .addNPC(familiar.getId(), HeadE.FRUSTRATED, ""Little cub, there is no greater insult to a worldbearer. Shall I rub your belly so you can digest? Shall I move your feet so you can walk?"") .addNPC(familiar.getId(), HeadE.FRUSTRATED, ""Garra! I know your culture: you call us pack mules and servants. There is no indignity in what I do! There is only honour in bearing another's burdens."") .addPlayer(HeadE.HAPPY_TALKING, ""I didn't mean to insult you."") .addNPC(familiar.getId(), HeadE.FRUSTRATED, ""Bah, you are right. I must have woken on the wrong side of the stream today, little cub. Ignore me."") .addPlayer(HeadE.HAPPY_TALKING, ""You're carrying a few burdens of your own."") .addNPC(familiar.getId(), HeadE.FRUSTRATED, ""Grrrr! Although my role is to carry - and I carry for you now - I like it as much as I like your stale odour. Can we press on before I do something that I will get exiled for?""), new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""You shouldn't complain so much."") .addNPC(familiar.getId(), HeadE.FRUSTRATED, ""Do not pretend that we are in the servant and master role, little cub! Our alliance is a delicate one and will end some day, through good means or bad."") .addNPC(familiar.getId(), HeadE.FRUSTRATED, ""When that day comes, you may not find that I am so helpful. Our goal is to blast this dungeon apart, but I have no issue with leaving you behind.""), new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""What is it like to be a worldbearer?"") .addNPC(familiar.getId(), HeadE.FRUSTRATED, ""The worldbearers are the legs and back of the gorajo; we bear the provisions, tents and tools from one destination to another."") .addNPC(familiar.getId(), HeadE.FRUSTRATED, ""And when the gorajo are not moving, the worldbearers prepare and serve the food. It is an important role, and one that is esteemed among my clansmen."") .addPlayer(HeadE.HAPPY_TALKING, ""It sounds like hard work. There can't be much time to enjoy yourself."") .addNPC(familiar.getId(), HeadE.FRUSTRATED, ""It is rewarding in its own way. When a worldbearer is put to rest, they are stripped of all belongings, to be reincarnated as a creature without burden: a sparrowhawk or a wildcat, perhaps."") .addNPC(familiar.getId(), HeadE.FRUSTRATED, ""Although we face trials in this life, our next is free and joyful."") .addPlayer(HeadE.HAPPY_TALKING, ""You carry everything and have to serve it too?"") .addNPC(familiar.getId(), HeadE.FRUSTRATED, ""The clan sees the worldbearer as the nurturing mother wolf: proudly defending her pack while carrying the food and delivering it to her pups."") .addNPC(familiar.getId(), HeadE.FRUSTRATED, ""I would prefer a more masculine comparison; never mind, it has been so for centuries.""), new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""I don't have any more questions."") .addNPC(familiar.getId(), HeadE.FRUSTRATED, ""That is good to hear. I am not one to talk."") ); } case DEATHSLINGER_1, DEATHSLINGER_2, DEATHSLINGER_3, DEATHSLINGER_4, DEATHSLINGER_5, DEATHSLINGER_6, DEATHSLINGER_7, DEATHSLINGER_8, DEATHSLINGER_9, DEATHSLINGER_10 -> { if(!canTalk) yield new Dialogue().addNPC(familiar.getId(), HeadE.FRUSTRATED, ""Naaabe!""); if(!player.getTempAttribs().getB(""talked_to_deathslinger"")){ player.getTempAttribs().setB(""talked_to_deathslinger"", true); yield new Dialogue().addNPC(familiar.getId(), HeadE.FRUSTRATED, ""We have much work to do, but I could stop for a moment.""); } yield random( new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""What is the biggest creature you have killed?"") .addNPC(familiar.getId(), HeadE.FRUSTRATED, ""Haha, you sound like my cubs! What did you kill, mama? Did it have "" + ""ten heads, mama? Did it fire magic bolts from its eyes?"") .addPlayer(HeadE.HAPPY_TALKING, ""Alright, I get it. I was just making conversation."") .addNPC(familiar.getId(), HeadE.FRUSTRATED, ""Do not sulk, naabe. You simply reminded me of better times. To answer your question, "" + ""it was most likely a sinkhole. They are huge and flat, shaped something like an open palm. "") .addNPC(familiar.getId(), HeadE.FRUSTRATED, ""They burrow beneath the ground, and then fold themselves into a fist, "" + ""storing the land and people within them to be digested when required."") .addPlayer(HeadE.HAPPY_TALKING, ""That's horrible!"") .addNPC(familiar.getId(), HeadE.FRUSTRATED, ""And so much worse to be inside one. This place is nothing in comparison to a "" + ""sinkhole, naabe. I relish every day outside of that thing.""), new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""How much do you know about Daemonheim?"") .addNPC(familiar.getId(), HeadE.FRUSTRATED, ""I know that it has been here for far longer than you or I have been alive, "" + ""beyond the lifetimes of our parents, grandparents and any relatives they knew."") .addNPC(familiar.getId(), HeadE.FRUSTRATED, ""Many, from so many different races, have been born here. And many have died here, "" + ""filling the holes they helped to dig. It is not a life they deserved, but they knew no other."") .addPlayer(HeadE.HAPPY_TALKING, ""It must have been a terrible life."") .addNPC(familiar.getId(), HeadE.FRUSTRATED, ""It is best to not consider it a life, naabe. They would have burrowed without "" + ""question, knowing no life better than this. Like blind moles, churra. "") .addNPC(familiar.getId(), HeadE.FRUSTRATED, ""They believed that they were burrowing to an exit. It is hateful to think that "" + ""their leader may have played upon this fact, encouraging them downward to their escape.""), new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Why do the gorajo have only one role? You can't be a deathslinger all the time, can you?"") .addNPC(familiar.getId(), HeadE.FRUSTRATED, ""A gorajo needs but one role. How do you humans say it? We...specialise."") .addPlayer(HeadE.HAPPY_TALKING, ""I guess that would make you a pure. I mean, adventurers who specialise in one skill are often called pures."") .addNPC(familiar.getId(), HeadE.FRUSTRATED, ""A pure? I like this. The goraju are pure of action, pure of purpose... Yes, I will accept this term.""), new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""I don't have any more questions."") .addNPC(familiar.getId(), HeadE.FRUSTRATED, ""Fly fast on the wind, young naabe."") ); } case CLAY_POUCH_1, CLAY_POUCH_2, CLAY_POUCH_3, CLAY_POUCH_4, CLAY_POUCH_5 -> { if(!canTalk) yield new Dialogue().addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Rumble Rumble.""); if(familiar.getInventory().getUsedSlots() > 0) yield new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""How are you getting on with the load?"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Rumble. (Just fine, master.)"") .addPlayer(HeadE.HAPPY_TALKING, ""Don't go dropping it, okay?"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Rumble. (I'll try my very best, master.)""); yield random( new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""What is it like to be made out of sacred clay?"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Rumble... (I do not understand the question...)"") .addPlayer(HeadE.HAPPY_TALKING, ""Can you at least tell me how you feel?"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Rumble! (I am happy as long as I can serve you, master!)""), new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""They're attacking!"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Rumble! (Fear not, master, for I'll protect you!)"") .addPlayer(HeadE.HAPPY_TALKING, ""I'm glad you're here!""), new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Hey!"") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Rumble? (Yes, master?)"") .addPlayer(HeadE.HAPPY_TALKING, ""Actually, I probably don't want to be talking to you. It's kind of dangerous here..."") .addNPC(familiar.getId(), HeadE.CAT_CALM_TALK2, ""Rumble... (As You wish...)"") ); } default -> new Dialogue().addSimple(""This familiar can't talk yet.""); }; } public static void addExtraOps(Player player, Options ops, Familiar familiar) { switch(familiar.getPouch()) { case LAVA_TITAN: ops.add(""Teleport to Lava Maze"", new Dialogue().addOptions(""Are you sure you want to teleport here? It's very high wilderness."", yesNo -> { yesNo.add(""Yes. I'm sure."", () -> Magic.sendNormalTeleportSpell(player, Tile.of(3030, 3838, 0))); yesNo.add(""Nevermind. That sounds dangerous.""); })); break; case DREADFOWL: ops.add(""Boost Farming"", new Dialogue().addNext(()->{ if(player.getSkills().getLevel(Skills.FARMING) <= player.getSkills().getLevelForXp(Skills.FARMING)) player.getSkills().set(Skills.FARMING, player.getSkills().getLevel(Skills.FARMING) + 1); })); break; case COMPOST_MOUND: ops.add(""Boost Farming"", new Dialogue().addNext(()->{ int boostAmount = (int)Math.ceil(1 + player.getSkills().getLevelForXp(Skills.FARMING) * 0.02); if(player.getSkills().getLevel(Skills.FARMING) <= player.getSkills().getLevelForXp(Skills.FARMING)) player.getSkills().set(Skills.FARMING, player.getSkills().getLevel(Skills.FARMING) + boostAmount); })); break; default: break; } } private static Dialogue random(Dialogue... options) { return options[Utils.random(options.length)]; } }" "package com.rs.game.content.skills.summoning; @PluginEventHandler public class ObeliskGlobal { public static ObjectClickHandler rechargeSummoning = new ObjectClickHandler(new Object[] { ""Obelisk"" }, e -> { switch(e.getOption()) { case ""Renew-points"" -> { if (e.getPlayer().getSkills().getLevel(Constants.SUMMONING) < e.getPlayer().getSkills().getLevelForXp(Constants.SUMMONING)) { e.getPlayer().sendMessage(""You touch the obelisk"", true); e.getPlayer().setNextAnimation(new Animation(8502)); World.sendSpotAnim(e.getObject().getTile(), new SpotAnim(1308)); WorldTasks.schedule(2, () -> { e.getPlayer().getSkills().set(Constants.SUMMONING, e.getPlayer().getSkills().getLevelForXp(Constants.SUMMONING)); e.getPlayer().sendMessage(""...and recharge your summoning points."", true); }); } } } }); }" "package com.rs.game.content.skills.summoning; public enum Pouch { /** * Hello leecher. Nice to see you here. You're welcome for doing all the hard work for you. * I hope you'll notice the license above :) */ SPIRIT_WOLF(0, 6829, 6830, XPType.ACCURATE, 8298, 8532, Scroll.HOWL, 12047, 1, 0.1, 4.8, Ticks.fromMinutes(16), 1), DREADFOWL(2, 6825, 6826, XPType.MAGIC, 7807, 8555, Scroll.DREADFOWL_STRIKE, 12043, 4, 0.1, 9.3, Ticks.fromMinutes(16), 1), SPIRIT_SPIDER(0, 6841, 6842, XPType.CONTROLLED, 8163, 8544, Scroll.EGG_SPAWN, 12059, 10, 0.2, 12.6, Ticks.fromMinutes(16), 2, ""forage_spirit_spider""), THORNY_SNAIL(0, 6806, 6807, XPType.RANGED, 8141, 8561, Scroll.SLIME_SPRAY, 12019, 13, 0.2, 12.6, Ticks.fromMinutes(16), 2, 3), GRANITE_CRAB(3, 6796, 6797, XPType.DEFENSIVE, 8108, 8541, Scroll.STONY_SHELL, 12009, 16, 0.2, 21.6, Ticks.fromMinutes(16), 2, ""forage_granite_crab"") { @Override public boolean canRollForager(Player player) { return player.getActionManager().doingAction(Fishing.class); } }, SPIRIT_MOSQUITO(4, 7331, 7332, XPType.ACCURATE, 8037, 8915, Scroll.PESTER, 12778, 17, 0.2, 46.5, Ticks.fromMinutes(16), 2), DESERT_WYRM(0, 6831, 6832, XPType.AGGRESSIVE, 7794, 8537, Scroll.ELECTRIC_LASH, 12049, 18, 0.4, 31.2, Ticks.fromMinutes(16), 1), SPIRIT_SCORPION(8, 6837, 6838, XPType.CONTROLLED, 8127, 8546, Scroll.VENOM_SHOT, 12055, 19, 0.9, 83.2, Ticks.fromMinutes(16), 2), SPIRIT_TZ_KIH(32, 7361, 7362, XPType.MAGIC, 8260, 8927, Scroll.FIREBALL, 12808, 22, 1.1, 96.8, Ticks.fromMinutes(16), 3), ALBINO_RAT(7, 6847, 6848, XPType.ACCURATE, 16080, 16081, Scroll.CHEESE_FEAST, 12067, 23, 2.3, 202.4, Ticks.fromMinutes(16), 3, ""forage_albino_rat""), SPIRIT_KALPHITE(8, 6994, 6995, XPType.DEFENSIVE, 8516, 8531, Scroll.SANDSTORM, 12063, 25, 2.5, 220, Ticks.fromMinutes(16), 3, 6), COMPOST_MOUND(70, 6871, 6872, XPType.AGGRESSIVE, 7773, 8540, Scroll.COMPOST_GENERATE, 12091, 28, 0.6, 49.8, Ticks.fromMinutes(32), 6, ""forage_compost_mound""), GIANT_CHINCHOMPA(7, 7353, 7354, XPType.RANGED, 7754, 8922, Scroll.EXPLODE, 12800, 29, 2.5, 255.2, Ticks.fromMinutes(32), 1), VAMPYRE_BAT(4, 6835, 6836, XPType.CONTROLLED, 8279, 8563, Scroll.VAMPYRE_TOUCH, 12053, 31, 1.6, 136.0, Ticks.fromMinutes(32), 4), HONEY_BADGER(7, 6845, 6846, XPType.AGGRESSIVE, 7929, 8568, Scroll.INSANE_FEROCITY, 12065, 32, 1.6, 140.8, Ticks.fromMinutes(32), 4), BEAVER(7, 6808, -1, null, 7721, 8535, Scroll.MULTICHOP, 12021, 33, 0.7, 57.6, Ticks.fromMinutes(32), 4, ""forage_beaver""), VOID_RAVAGER(7, 7370, 7371, XPType.AGGRESSIVE, 8091, 8929, Scroll.CALL_TO_ARMS, 12818, 34, 0.7, 59.6, Ticks.fromMinutes(32), 4, ""forage_void_ravager""), VOID_SPINNER(29, 7333, 7334, XPType.DEFENSIVE, 8174, 8920, Scroll.CALL_TO_ARMS, 12780, 34, 0.7, 59.6, Ticks.fromMinutes(32), 4) { @Override public void tick(Player owner, Familiar familiar) { familiar.getAttribs().decI(""healTicks""); if (familiar.getAttribs().getI(""healTicks"") <= 0 && owner != null) { owner.heal(10); familiar.anim(8179); owner.setNextSpotAnim(new SpotAnim(1507)); familiar.getAttribs().setI(""healTicks"", 25); } } }, VOID_TORCHER(2, 7351, 7352, XPType.MAGIC, 8238, 8921, Scroll.CALL_TO_ARMS, 12798, 34, 0.7, 59.6, Ticks.fromMinutes(32), 4), VOID_SHIFTER(30, 7367, 7368, XPType.ACCURATE, 8134, 8919, Scroll.CALL_TO_ARMS, 12814, 34, 0.7, 59.6, Ticks.fromMinutes(32), 4) { @Override public void tick(Player owner, Familiar familiar) { if (owner.getHitpoints() <= (owner.getMaxHitpoints() * 0.1) && familiar.getTempAttribs().getL(""lastTeleAtt"") <= World.getServerTicks()) { familiar.getTempAttribs().setL(""lastTeleAtt"", World.getServerTicks() + Ticks.fromMinutes(1)); if (Scroll.CALL_TO_ARMS.use(owner, familiar)) { owner.setHitpoints((int) (owner.getMaxHitpoints() * 0.2)); owner.refreshHitPoints(); } } } }, BRONZE_MINOTAUR(57, 6853, 6854, XPType.DEFENSIVE, 8029, 8549, Scroll.BRONZE_BULL, 12073, 36, 2.4, 316.8, Ticks.fromMinutes(32), 9), IRON_MINOTAUR(57, 6855, 6856, XPType.DEFENSIVE, 8029, 8549, Scroll.IRON_BULL, 12075, 46, 4.6, 404.8, Ticks.fromMinutes(32), 9), STEEL_MINOTAUR(57, 6857, 6858, XPType.DEFENSIVE, 8029, 8549, Scroll.STEEL_BULL, 12077, 56, 5.6, 492.8, Ticks.fromMinutes(48), 9), MITHRIL_MINOTAUR(57, 6859, 6860, XPType.DEFENSIVE, 8029, 8549, Scroll.MITHRIL_BULL, 12079, 66, 6.6, 580.8, Ticks.fromMinutes(48), 9), ADAMANT_MINOTAUR(57, 6861, 6862, XPType.DEFENSIVE, 8029, 8549, Scroll.ADAMANT_BULL, 12081, 76, 8.6, 668.8, Ticks.fromMinutes(64), 9), RUNE_MINOTAUR(57, 6863, 6864, XPType.DEFENSIVE, 8029, 8549, Scroll.RUNE_BULL, 12083, 86, 8.6, 756.8, Ticks.fromMinutes(64), 9), BULL_ANT(8, 6867, 6868, XPType.CONTROLLED, 7894, 8554, Scroll.UNBURDEN, 12087, 40, 0.6, 52.8, Ticks.fromMinutes(32), 5, 9), MACAW(2, 6851, 6852, null, 8005, 8553, Scroll.HERBCALL, 12071, 41, 0.8, 72.4, Ticks.fromMinutes(32), 5, ""forage_macaw""), EVIL_TURNIP(5, 6833, 6834, XPType.RANGED, 8252, 8250, Scroll.EVIL_FLAMES, 12051, 42, 2.1, 184.8, Ticks.fromMinutes(32), 5, ""forage_evil_turnip""), SPIRIT_COCKATRICE(89, 6875, 6876, XPType.MAGIC, 7765, 8551, Scroll.PETRIFYING_GAZE, 12095, 43, 0.9, 75.2, Ticks.fromMinutes(32), 5, ""forage_cockatrice""), SPIRIT_GUTHATRICE(89, 6877, 6878, XPType.MAGIC, 7765, 8551, Scroll.PETRIFYING_GAZE, 12097, 43, 0.9, 75.2, Ticks.fromMinutes(32), 5, ""forage_cockatrice""), SPIRIT_SARATRICE(89, 6879, 6880, XPType.MAGIC, 7765, 8551, Scroll.PETRIFYING_GAZE, 12099, 43, 0.9, 75.2, Ticks.fromMinutes(32), 5, ""forage_cockatrice""), SPIRIT_ZAMATRICE(89, 6881, 6882, XPType.MAGIC, 7765, 8551, Scroll.PETRIFYING_GAZE, 12101, 43, 0.9, 75.2, Ticks.fromMinutes(32), 5, ""forage_cockatrice""), SPIRIT_PENGATRICE(89, 6883, 6884, XPType.MAGIC, 7765, 8551, Scroll.PETRIFYING_GAZE, 12103, 43, 0.9, 75.2, Ticks.fromMinutes(32), 5, ""forage_cockatrice""), SPIRIT_CORAXATRICE(89, 6885, 6886, XPType.MAGIC, 7765, 8551, Scroll.PETRIFYING_GAZE, 12105, 43, 0.9, 75.2, Ticks.fromMinutes(32), 5, ""forage_cockatrice""), SPIRIT_VULATRICE(89, 6887, 6888, XPType.MAGIC, 7765, 8551, Scroll.PETRIFYING_GAZE, 12107, 43, 0.9, 75.2, Ticks.fromMinutes(32), 5, ""forage_cockatrice""), PYRELORD(23, 7377, 7378, XPType.AGGRESSIVE, 8081, 8930, Scroll.IMMENSE_HEAT, 12816, 46, 2.3, 202.4, Ticks.fromMinutes(32), 5), MAGPIE(2, 6824, -1, null, 8005, 8553, Scroll.THIEVING_FINGERS, 12041, 47, 0.9, 83.2, Ticks.fromMinutes(32), 5, ""forage_magpie""), BLOATED_LEECH(14, 6843, 6844, XPType.ACCURATE, 7711, 8567, Scroll.BLOOD_DRAIN, 12061, 49, 2.4, 215.2, Ticks.fromMinutes(32), 5), SPIRIT_TERRORBIRD(2, 6794, 6795, XPType.CONTROLLED, 8231, 8557, Scroll.TIRELESS_RUN, 12007, 52, 0.7, 68.4, Ticks.fromMinutes(32), 6, 12), ABYSSAL_PARASITE(0, 6818, 6819, XPType.MAGIC, 7669, 8556, Scroll.ABYSSAL_DRAIN, 12035, 54, 1.1, 94.8, Ticks.fromMinutes(32), 6, 7), SPIRIT_JELLY(13, 6992, 6993, XPType.AGGRESSIVE, 8513, 7075, Scroll.DISSOLVE, 12027, 55, 5.5, 484.0, Ticks.fromMinutes(48), 6), IBIS(2, 6991, -1, null, 8202, 8552, Scroll.FISH_RAIN, 12531, 56, 1.1, 98.8, Ticks.fromMinutes(32), 6, ""forage_ibis"") { @Override public boolean canRollForager(Player player) { return player.getActionManager().doingAction(Fishing.class); } }, SPIRIT_KYATT(7, 7365, 7366, XPType.ACCURATE, 7909, 8917, Scroll.AMBUSH, 12812, 57, 5.7, 501.6, Ticks.fromMinutes(48), 6), SPIRIT_LARUPIA(7, 7337, 7338, XPType.CONTROLLED, 7909, 8917, Scroll.RENDING, 12784, 57, 5.7, 501.6, Ticks.fromMinutes(48), 6), SPIRIT_GRAAHK(7, 7363, 7364, XPType.AGGRESSIVE, 7909, 8917, Scroll.GOAD, 12810, 57, 5.6, 501.6, Ticks.fromMinutes(48), 6), KARAMTHULU_OVERLORD(3, 6809, 6810, XPType.RANGED, 7969, 8543, Scroll.DOOMSPHERE, 12023, 58, 5.8, 510.4, Ticks.fromMinutes(48), 6), SMOKE_DEVIL(22, 6865, 6866, XPType.MAGIC, 7819, 8530, Scroll.DUST_CLOUD, 12085, 61, 3.1, 268.0, Ticks.fromMinutes(48), 7), ABYSSAL_LURKER(2, 6820, 6821, XPType.CONTROLLED, 7683, 8564, Scroll.ABYSSAL_STEALTH, 12037, 62, 1.9, 109.6, Ticks.fromMinutes(48), 7, 12), SPIRIT_COBRA(111, 6802, 6803, XPType.ACCURATE, 8157, 8550, Scroll.OPHIDIAN_INCUBATION, 12015, 63, 3.1, 276.8, Ticks.fromMinutes(48), 7), STRANGER_PLANT(3, 6827, 6828, XPType.CONTROLLED, 8216, 8533, Scroll.POISONOUS_BLAST, 12045, 64, 3.2, 281.6, Ticks.fromMinutes(48), 7, ""forage_stranger_plant""), BARKER_TOAD(1, 6889, 6890, XPType.AGGRESSIVE, 7702, 8539, Scroll.TOAD_BARK, 12123, 66, 1.0, 87.0, Ticks.fromMinutes(48), 7), WAR_TORTOISE(2, 6815, 6816, XPType.DEFENSIVE, 8282, 8542, Scroll.TESTUDO, 12031, 67, 0.7, 58.6, Ticks.fromMinutes(48), 7, 18), BUNYIP(7, 6813, 6814, XPType.ACCURATE, 7736, 8547, Scroll.SWALLOW_WHOLE, 12029, 68, 1.4, 119.2, Ticks.fromMinutes(48), 7) { @Override public void tick(Player owner, Familiar familiar) { familiar.getAttribs().decI(""healTicks""); if (familiar.getAttribs().getI(""healTicks"") <= 0 && owner != null) { owner.heal((int) (owner.getMaxHitpoints()*0.02)); owner.setNextSpotAnim(new SpotAnim(1507)); familiar.getAttribs().setI(""healTicks"", 25); } } }, FRUIT_BAT(7, 6817, -1, null, 8279, 8563, Scroll.FRUITFALL, 12033, 69, 1.4, 121.2, Ticks.fromMinutes(48), 7, ""forage_fruit_bat""), RAVENOUS_LOCUST(6, 7372, 7373, XPType.ACCURATE, 7997, 8931, Scroll.FAMINE, 12820, 70, 1.5, 132.0, Ticks.fromMinutes(48), 4), ARCTIC_BEAR(7, 6839, 6840, XPType.CONTROLLED, 8522, 8566, Scroll.ARCTIC_BLAST, 12057, 71, 1.1, 93.2, Ticks.fromMinutes(48), 8), PHOENIX(3, 8575, 8576, XPType.MAGIC, 11095, 11096, Scroll.RISE_FROM_THE_ASHES, 14623, 72, 3.0, 301.0, Ticks.fromMinutes(48), 8), OBSIDIAN_GOLEM(28, 7345, 7346, XPType.AGGRESSIVE, 8049, 8924, Scroll.VOLCANIC_STRENGTH, 12792, 73, 7.3, 642.4, Ticks.fromMinutes(64), 8), GRANITE_LOBSTER(59, 6849, 6850, XPType.DEFENSIVE, 8122, 8548, Scroll.CRUSHING_CLAW, 12069, 74, 3.7, 325.6, Ticks.fromMinutes(64), 8, ""forage_granite_lobster"") { @Override public boolean canRollForager(Player player) { return player.getActionManager().doingAction(Fishing.class); } }, PRAYING_MANTIS(9, 6798, 6799, XPType.ACCURATE, 8075, 8558, Scroll.MANTIS_STRIKE, 12011, 75, 3.6, 329.6, Ticks.fromMinutes(64), 8), FORGE_REGENT(34, 7335, 7336, XPType.RANGED, 7870, 8934, Scroll.INFERNO, 12782, 76, 1.5, 134.0, Ticks.fromMinutes(64), 9), TALON_BEAST(104, 7347, 7348, XPType.AGGRESSIVE, 8045, 8933, Scroll.DEADLY_CLAW, 12794, 77, 3.8, 1015.2, Ticks.fromMinutes(64), 9), GIANT_ENT(76, 6800, 6801, XPType.CONTROLLED, 7850, 8559, Scroll.ACORN_MISSILE, 12013, 78, 1.6, 136.8, Ticks.fromMinutes(64), 8, ""forage_giant_ent""), HYDRA(19, 6811, 6812, XPType.RANGED, 7940, 8538, Scroll.REGROWTH, 12025, 80, 1.6, 140.8, Ticks.fromMinutes(64), 8), SPIRIT_DAGANNOTH(7, 6804, 6805, XPType.CONTROLLED, 7783, 8560, Scroll.SPIKE_SHOT, 12017, 83, 4.1, 364.8, Ticks.fromMinutes(64), 9), UNICORN_STALLION(107, 6822, 6823, XPType.CONTROLLED, 8266, 8565, Scroll.HEALING_AURA, 12039, 88, 1.8, 154.4, Ticks.fromMinutes(64), 9), WOLPERTINGER(7, 6869, 6870, XPType.MAGIC, 8309, 8534, Scroll.MAGIC_FOCUS, 12089, 92, 4.6, 404.8, Ticks.fromMinutes(64), 10), PACK_YAK(107, 6873, 6874, XPType.AGGRESSIVE, 8058, 8536, Scroll.WINTER_STORAGE, 12093, 96, 4.8, 422.2, Ticks.fromMinutes(64), 10, 30), FIRE_TITAN(23, 7355, 7356, XPType.MAGIC, 7829, 8925, Scroll.TITANS_CONSTITUTION, 12802, 79, 7.9, 695.2, Ticks.fromMinutes(64), 9), MOSS_TITAN(27, 7357, 7358, XPType.AGGRESSIVE, 8188, 8926, Scroll.TITANS_CONSTITUTION, 12804, 79, 7.9, 695.2, Ticks.fromMinutes(64), 9), ICE_TITAN(100, 7359, 7360, XPType.ACCURATE, 8188, 8926, Scroll.TITANS_CONSTITUTION, 12806, 79, 7.9, 695.2, Ticks.fromMinutes(64), 9), LAVA_TITAN(27, 7341, 7342, XPType.AGGRESSIVE, 7987, 8928, Scroll.EBON_THUNDER, 12788, 83, 8.3, 730.4, Ticks.fromMinutes(64), 9), SWAMP_TITAN(104, 7329, 7330, XPType.ACCURATE, 8225, 8932, Scroll.SWAMP_PLAGUE, 12776, 85, 4.2, 373.6, Ticks.fromMinutes(64), 9), GEYSER_TITAN(27, 7339, 7340, XPType.RANGED, 7881, 7880, Scroll.BOIL, 12786, 89, 8.9, 783.2, Ticks.fromMinutes(64), 10), ABYSSAL_TITAN(127, 7349, 7350, XPType.ACCURATE, 8188, 8926, Scroll.ESSENCE_SHIPMENT, 12796, 93, 1.9, 163.2, Ticks.fromMinutes(64), 10, 20), IRON_TITAN(77, 7375, 7376, XPType.DEFENSIVE, 8188, 8926, Scroll.IRON_WITHIN, 12822, 95, 8.6, 417.6, Ticks.fromMinutes(64), 10), STEEL_TITAN(27, 7343, 7344, XPType.RANGED, 8188, 8926, Scroll.STEEL_OF_LEGENDS, 12790, 99, 4.9, 435.2, Ticks.fromMinutes(64), 10), MEERKATS(7, 11640, -1, null, 14316, 14317, Scroll.FETCH_CASKET, 19622, 4, 0.1, 0.0, Ticks.fromMinutes(48), 1), GHAST(36, 13979, 13980, XPType.PRAYER, 6782, 9467, Scroll.GHASTLY_ATTACK, 21444, 87, 3.0, 0.0, Ticks.fromMinutes(64), 1), BLOODRAGER_1(36, 11106, 11107, XPType.AGGRESSIVE, 13684, 13685, Scroll.SUNDERING_STRIKE_1, 17935, 1, 0.5, 5.0, Ticks.fromMinutes(64), 1), BLOODRAGER_2(36, 11108, 11109, XPType.AGGRESSIVE, 13684, 13685, Scroll.SUNDERING_STRIKE_2, 17936, 11, 1.0, 19.5, Ticks.fromMinutes(64), 1), BLOODRAGER_3(36, 11110, 11111, XPType.AGGRESSIVE, 13684, 13685, Scroll.SUNDERING_STRIKE_3, 17937, 21, 1.5, 43, Ticks.fromMinutes(64), 1), BLOODRAGER_4(36, 11112, 11113, XPType.AGGRESSIVE, 13684, 13685, Scroll.SUNDERING_STRIKE_4, 17938, 31, 2.0, 68.5, Ticks.fromMinutes(64), 1), BLOODRAGER_5(36, 11114, 11115, XPType.AGGRESSIVE, 13684, 13685, Scroll.SUNDERING_STRIKE_5, 17939, 41, 2.5, 99.5, Ticks.fromMinutes(64), 1), BLOODRAGER_6(36, 11116, 11117, XPType.AGGRESSIVE, 13684, 13685, Scroll.SUNDERING_STRIKE_6, 17940, 51, 3.0, 157, Ticks.fromMinutes(64), 1), BLOODRAGER_7(36, 11118, 11119, XPType.AGGRESSIVE, 13684, 13685, Scroll.SUNDERING_STRIKE_7, 17941, 61, 3.5, 220, Ticks.fromMinutes(64), 1), BLOODRAGER_8(36, 11120, 11121, XPType.AGGRESSIVE, 13684, 13685, Scroll.SUNDERING_STRIKE_8, 17942, 71, 4.0, 325, Ticks.fromMinutes(64), 1), BLOODRAGER_9(36, 11122, 11123, XPType.AGGRESSIVE, 13684, 13685, Scroll.SUNDERING_STRIKE_9, 17943, 81, 4.5, 517.5, Ticks.fromMinutes(64), 1), BLOODRAGER_10(36, 11124, 11125, XPType.AGGRESSIVE, 13684, 13685, Scroll.SUNDERING_STRIKE_10, 17944, 91, 5.0, 810, Ticks.fromMinutes(64), 1), STORMBRINGER_1(36, 11126, 11127, XPType.MAGIC, 13676, 13677, Scroll.SNARING_WAVE_1, 17945, 3, 0.7, 6.4, Ticks.fromMinutes(64), 1), STORMBRINGER_2(36, 11128, 11129, XPType.MAGIC, 13676, 13677, Scroll.SNARING_WAVE_2, 17946, 13, 1.2, 21.5, Ticks.fromMinutes(64), 1), STORMBRINGER_3(36, 11130, 11131, XPType.MAGIC, 13676, 13677, Scroll.SNARING_WAVE_3, 17947, 23, 1.7, 45.8, Ticks.fromMinutes(64), 1), STORMBRINGER_4(36, 11132, 11133, XPType.MAGIC, 13676, 13677, Scroll.SNARING_WAVE_4, 17948, 33, 2.2, 72.3, Ticks.fromMinutes(64), 1), STORMBRINGER_5(36, 11134, 11135, XPType.MAGIC, 13676, 13677, Scroll.SNARING_WAVE_5, 17949, 43, 2.7, 104.5, Ticks.fromMinutes(64), 1), STORMBRINGER_6(36, 11136, 11137, XPType.MAGIC, 13676, 13677, Scroll.SNARING_WAVE_6, 17950, 53, 3.2, 164, Ticks.fromMinutes(64), 1), STORMBRINGER_7(36, 11138, 11139, XPType.MAGIC, 13676, 13677, Scroll.SNARING_WAVE_7, 17951, 63, 3.7, 229.2, Ticks.fromMinutes(64), 1), STORMBRINGER_8(36, 11140, 11141, XPType.MAGIC, 13676, 13677, Scroll.SNARING_WAVE_8, 17952, 73, 4.2, 336.6, Ticks.fromMinutes(64), 1), STORMBRINGER_9(36, 11142, 11143, XPType.MAGIC, 13676, 13677, Scroll.SNARING_WAVE_9, 17953, 83, 4.7, 531.7, Ticks.fromMinutes(64), 1), STORMBRINGER_10(36, 11144, 11145, XPType.MAGIC, 13676, 13677, Scroll.SNARING_WAVE_10, 17954, 93, 5.2, 827, Ticks.fromMinutes(64), 1), HOARDSTALKER_1(36, 11146, 11147, XPType.DEFENSIVE, 13684, 13685, Scroll.APTITUDE_1, 17955, 5, 0.8, 7.1, Ticks.fromMinutes(64), 1, ""forage_hoardstalker_t1""), HOARDSTALKER_2(36, 11148, 11149, XPType.DEFENSIVE, 13684, 13685, Scroll.APTITUDE_2, 17956, 15, 1.3, 22.5, Ticks.fromMinutes(64), 1, ""forage_hoardstalker_t2""), HOARDSTALKER_3(36, 11150, 11151, XPType.DEFENSIVE, 13684, 13685, Scroll.APTITUDE_3, 17957, 25, 1.8, 47.2, Ticks.fromMinutes(64), 1, ""forage_hoardstalker_t3""), HOARDSTALKER_4(36, 11152, 11153, XPType.DEFENSIVE, 13684, 13685, Scroll.APTITUDE_4, 17958, 35, 2.3, 74.2, Ticks.fromMinutes(64), 1, ""forage_hoardstalker_t4""), HOARDSTALKER_5(36, 11154, 11155, XPType.DEFENSIVE, 13684, 13685, Scroll.APTITUDE_5, 17959, 45, 2.8, 107, Ticks.fromMinutes(64), 1, ""forage_hoardstalker_t5""), HOARDSTALKER_6(36, 11156, 11157, XPType.DEFENSIVE, 13684, 13685, Scroll.APTITUDE_6, 17960, 55, 3.3, 167.5, Ticks.fromMinutes(64), 1, ""forage_hoardstalker_t6""), HOARDSTALKER_7(36, 11158, 11159, XPType.DEFENSIVE, 13684, 13685, Scroll.APTITUDE_7, 17961, 65, 3.8, 233.8, Ticks.fromMinutes(64), 1, ""forage_hoardstalker_t7""), HOARDSTALKER_8(36, 11160, 11161, XPType.DEFENSIVE, 13684, 13685, Scroll.APTITUDE_8, 17962, 75, 4.3, 342.4, Ticks.fromMinutes(64), 1, ""forage_hoardstalker_t8""), HOARDSTALKER_9(36, 11162, 11163, XPType.DEFENSIVE, 13684, 13685, Scroll.APTITUDE_9, 17963, 85, 4.8, 538.8, Ticks.fromMinutes(64), 1, ""forage_hoardstalker_t9""), HOARDSTALKER_10(36, 11164, 11165, XPType.DEFENSIVE, 13684, 13685, Scroll.APTITUDE_10, 17964, 95, 5.3, 835.5, Ticks.fromMinutes(64), 1, ""forage_hoardstalker_t10""), SKINWEAVER_1(36, 11166, 11167, XPType.MAGIC, 13676, 13677, Scroll.GLIMMER_OF_LIGHT_1, 17965, 9, 1.0, 8.5, Ticks.fromMinutes(64), 1), SKINWEAVER_2(36, 11168, 11169, XPType.MAGIC, 13676, 13677, Scroll.GLIMMER_OF_LIGHT_2, 17966, 19, 1.5, 24.5, Ticks.fromMinutes(64), 1), SKINWEAVER_3(36, 11170, 11171, XPType.MAGIC, 13676, 13677, Scroll.GLIMMER_OF_LIGHT_3, 17967, 29, 2.0, 50, Ticks.fromMinutes(64), 1), SKINWEAVER_4(36, 11172, 11173, XPType.MAGIC, 13676, 13677, Scroll.GLIMMER_OF_LIGHT_4, 17968, 39, 2.5, 78, Ticks.fromMinutes(64), 1), SKINWEAVER_5(36, 11174, 11175, XPType.MAGIC, 13676, 13677, Scroll.GLIMMER_OF_LIGHT_5, 17969, 49, 3.0, 112, Ticks.fromMinutes(64), 1), SKINWEAVER_6(36, 11176, 11177, XPType.MAGIC, 13676, 13677, Scroll.GLIMMER_OF_LIGHT_6, 17970, 59, 3.5, 174.5, Ticks.fromMinutes(64), 1), SKINWEAVER_7(36, 11178, 11179, XPType.MAGIC, 13676, 13677, Scroll.GLIMMER_OF_LIGHT_7, 17971, 69, 4.0, 243, Ticks.fromMinutes(64), 1), SKINWEAVER_8(36, 11180, 11181, XPType.MAGIC, 13676, 13677, Scroll.GLIMMER_OF_LIGHT_8, 17972, 79, 4.5, 354, Ticks.fromMinutes(64), 1), SKINWEAVER_9(36, 11182, 11183, XPType.MAGIC, 13676, 13677, Scroll.GLIMMER_OF_LIGHT_9, 17973, 89, 5.0, 553, Ticks.fromMinutes(64), 1), SKINWEAVER_10(36, 11184, 11185, XPType.MAGIC, 13676, 13677, Scroll.GLIMMER_OF_LIGHT_10, 17974, 99, 5.5, 852.5, Ticks.fromMinutes(64), 1), WORLDBEARER_1(36, 11186, 11187, XPType.ACCURATE, 13684, 13685, Scroll.SECOND_WIND_1, 17975, 7, 0.9, 7.8, Ticks.fromMinutes(64), 1, 12), WORLDBEARER_2(36, 11188, 11189, XPType.ACCURATE, 13684, 13685, Scroll.SECOND_WIND_2, 17976, 17, 1.4, 23.5, Ticks.fromMinutes(64), 1, 14), WORLDBEARER_3(36, 11190, 11191, XPType.ACCURATE, 13684, 13685, Scroll.SECOND_WIND_3, 17977, 27, 1.9, 48.6, Ticks.fromMinutes(64), 1, 16), WORLDBEARER_4(36, 11192, 11193, XPType.ACCURATE, 13684, 13685, Scroll.SECOND_WIND_4, 17978, 37, 2.4, 76.1, Ticks.fromMinutes(64), 1, 18), WORLDBEARER_5(36, 11194, 11195, XPType.ACCURATE, 13684, 13685, Scroll.SECOND_WIND_5, 17979, 47, 2.9, 109.5, Ticks.fromMinutes(64), 1, 20), WORLDBEARER_6(36, 11196, 11197, XPType.ACCURATE, 13684, 13685, Scroll.SECOND_WIND_6, 17980, 57, 3.4, 171, Ticks.fromMinutes(64), 1, 22), WORLDBEARER_7(36, 11198, 11199, XPType.ACCURATE, 13684, 13685, Scroll.SECOND_WIND_7, 17981, 67, 3.9, 238.4, Ticks.fromMinutes(64), 1, 24), WORLDBEARER_8(36, 11200, 11201, XPType.ACCURATE, 13684, 13685, Scroll.SECOND_WIND_8, 17982, 77, 4.4, 348.2, Ticks.fromMinutes(64), 1, 26), WORLDBEARER_9(36, 11202, 11203, XPType.ACCURATE, 13684, 13685, Scroll.SECOND_WIND_9, 17983, 87, 4.9, 545.9, Ticks.fromMinutes(64), 1, 28), WORLDBEARER_10(36, 11204, 11205, XPType.ACCURATE, 13684, 13685, Scroll.SECOND_WIND_10, 17984, 97, 5.4, 844, Ticks.fromMinutes(64), 1, 30), DEATHSLINGER_1(36, 11206, 11207, XPType.RANGED, 13684, 13685, Scroll.POISONOUS_SHOT_1, 17985, 2, 0.6, 5.7, Ticks.fromMinutes(64), 1), DEATHSLINGER_2(36, 11208, 11209, XPType.RANGED, 13684, 13685, Scroll.POISONOUS_SHOT_2, 17986, 12, 1.1, 20.5, Ticks.fromMinutes(64), 1), DEATHSLINGER_3(36, 11210, 11211, XPType.RANGED, 13684, 13685, Scroll.POISONOUS_SHOT_3, 17987, 22, 1.6, 44.4, Ticks.fromMinutes(64), 1), DEATHSLINGER_4(36, 11212, 11213, XPType.RANGED, 13684, 13685, Scroll.POISONOUS_SHOT_4, 17988, 32, 2.1, 70.4, Ticks.fromMinutes(64), 1), DEATHSLINGER_5(36, 11214, 11215, XPType.RANGED, 13684, 13685, Scroll.POISONOUS_SHOT_5, 17989, 42, 2.6, 102, Ticks.fromMinutes(64), 1), DEATHSLINGER_6(36, 11216, 11217, XPType.RANGED, 13684, 13685, Scroll.POISONOUS_SHOT_6, 17990, 52, 3.1, 160.5, Ticks.fromMinutes(64), 1), DEATHSLINGER_7(36, 11218, 11219, XPType.RANGED, 13684, 13685, Scroll.POISONOUS_SHOT_7, 17991, 62, 3.6, 224.6, Ticks.fromMinutes(64), 1), DEATHSLINGER_8(36, 11220, 11221, XPType.RANGED, 13684, 13685, Scroll.POISONOUS_SHOT_8, 17992, 72, 4.1, 330.8, Ticks.fromMinutes(64), 1), DEATHSLINGER_9(36, 11222, 11223, XPType.RANGED, 13684, 13685, Scroll.POISONOUS_SHOT_9, 17993, 82, 4.6, 524.6, Ticks.fromMinutes(64), 1), DEATHSLINGER_10(36, 11224, 11225, XPType.RANGED, 13684, 13685, Scroll.POISONOUS_SHOT_10, 17994, 92, 5.1, 818.5, Ticks.fromMinutes(64), 1), CLAY_POUCH_1(57, 8240, 8241, XPType.ACCURATE, 10595, 10593, Scroll.CLAY_DEPOSIT, 14422, 1, 0.0, 0.0, Ticks.fromMinutes(30), 1, 1), CLAY_POUCH_2(57, 8242, 8243, XPType.ACCURATE, 10595, 10593, Scroll.CLAY_DEPOSIT, 14424, 20, 0.0, 0.0, Ticks.fromMinutes(30), 1, 6), CLAY_POUCH_3(57, 8244, 8245, XPType.ACCURATE, 10595, 10593, Scroll.CLAY_DEPOSIT, 14426, 40, 0.0, 0.0, Ticks.fromMinutes(30), 1, 12), CLAY_POUCH_4(57, 8246, 8247, XPType.ACCURATE, 10595, 10593, Scroll.CLAY_DEPOSIT, 14428, 60, 0.0, 0.0, Ticks.fromMinutes(30), 1, 18), CLAY_POUCH_5(57, 8248, 8249, XPType.ACCURATE, 10595, 10593, Scroll.CLAY_DEPOSIT, 14430, 80, 0.0, 0.0, Ticks.fromMinutes(30), 1, 24), ; private static final Map pouches = new HashMap<>(); static { for (Pouch pouch : Pouch.values()) pouches.put(pouch.id, pouch); } public static Pouch forId(int id) { return pouches.get(id); } private final int headAnimIndex; private final int baseNpc; private final int pvpNpc; private final int spawnAnim; private final int despawnAnim; private final XPType xpType; private final Scroll scroll; private final int id; private final int level; private final int summoningCost; private final double summonXp; private final double experience; private final int pouchTime; private final int bobSize; private final String forageDropTable; private Pouch(int headAnimIndex, int baseNpc, int pvpNpc, XPType xpType, int spawnAnimation, int despawnAnim, Scroll scroll, int realPouchId, int level, double minorExperience, double experience, int pouchTime, int summoningCost) { this(headAnimIndex, baseNpc, pvpNpc, xpType, spawnAnimation, despawnAnim, scroll, realPouchId, level, minorExperience, experience, pouchTime, summoningCost, 0, null); } private Pouch(int headAnimIndex, int baseNpc, int pvpNpc, XPType xpType, int spawnAnimation, int despawnAnim, Scroll scroll, int realPouchId, int level, double minorExperience, double experience, int pouchTime, int summoningCost, String forageDropTable) { this(headAnimIndex, baseNpc, pvpNpc, xpType, spawnAnimation, despawnAnim, scroll, realPouchId, level, minorExperience, experience, pouchTime, summoningCost, forageDropTable != null ? 30 : 0, forageDropTable); } private Pouch(int headAnimIndex, int baseNpc, int pvpNpc, XPType xpType, int spawnAnimation, int despawnAnim, Scroll scroll, int realPouchId, int level, double minorExperience, double experience, int pouchTime, int summoningCost, int bobSize) { this(headAnimIndex, baseNpc, pvpNpc, xpType, spawnAnimation, despawnAnim, scroll, realPouchId, level, minorExperience, experience, pouchTime, summoningCost, bobSize, null); } private Pouch(int headAnimIndex, int baseNpc, int pvpNpc, XPType xpType, int spawnAnim, int despawnAnim, Scroll scroll, int realPouchId, int level, double minorExperience, double experience, int pouchTime, int summoningCost, int bobSize, String forageDropTable) { this.headAnimIndex = headAnimIndex; this.xpType = xpType; this.baseNpc = baseNpc; this.pvpNpc = pvpNpc; this.spawnAnim = spawnAnim; this.despawnAnim = despawnAnim; this.scroll = scroll; this.level = level; this.id = realPouchId; this.summonXp = minorExperience; this.experience = experience; this.summoningCost = summoningCost; this.pouchTime = pouchTime; this.bobSize = bobSize; this.forageDropTable = forageDropTable; } public Object[] getIdKeys() { int size = 1; if (pvpNpc != -1) size = 2; Object[] ids = new Object[size]; ids[0] = baseNpc; if (pvpNpc != -1) ids[1] = pvpNpc; return ids; } public void tick(Player owner, Familiar familiar) { } public PouchMaterialList getMaterialList() { return PouchMaterialList.forId(id); } public XPType getXpType() { return xpType; } public int getDespawnAnim() { return despawnAnim; } public boolean isForager() { return forageDropTable != null; } public int getBaseNpc() { return baseNpc; } public int getPVPNpc() { return pvpNpc; } public int getLevel() { return level; } public int getId() { return id; } public int getSummoningCost() { return summoningCost; } public double getSummonXp() { return summonXp; } public double getExperience() { return experience; } public int getPouchTime() { return pouchTime; } public Scroll getScroll() { return scroll; } public int getBobSize() { return bobSize; } public int getSpawnAnim() { return spawnAnim; } public boolean isBob() { return bobSize > 0 && !isForager(); } public static Object[] getAllNPCKeysWithInventory() { return Streams.concat(Arrays.stream(Pouch.values()).filter(p -> p.bobSize > 0).map(p -> p.getIdKeys()[0]).filter(i -> (int) i != -1), Arrays.stream(Pouch.values()).filter(p -> p.bobSize > 0).map(p -> p.getIdKeys().length <= 1 ? -1 : p.getIdKeys()[1]).filter(i -> (int) i != -1)).toArray(); } public static Object[] getAllNPCIdKeys() { return Streams.concat(Arrays.stream(Pouch.values()).map(p -> p.getIdKeys()[0]).filter(i -> (int) i != -1), Arrays.stream(Pouch.values()).map(p -> p.getIdKeys().length <= 1 ? -1 : p.getIdKeys()[1]).filter(i -> (int) i != -1)).toArray(); } public boolean isPassive() { return xpType == null; } public boolean canRollForager(Player player) { return true; } public void rollForage(Player player, ItemsContainer inv) { DropSet drop = DropSets.getDropSet(forageDropTable); if (drop == null || !canRollForager(player)) return; inv.addAll(DropTable.calculateDrops(player, drop)); } public int getHeadAnimIndex() { return headAnimIndex; } }" "package com.rs.game.content.skills.summoning; public enum PouchMaterialList { SPIRIT_TERRORBIRD_POUCH(12007, new Item[] { new Item(12183, 12), new Item(12158, 1), new Item(12155, 1), new Item(9978, 1) }), GRANITE_CRAB_POUCH(12009, new Item[] { new Item(12183, 7), new Item(12158, 1), new Item(12155, 1), new Item(440, 1) }), PRAYING_MANTIS_POUCH(12011, new Item[] { new Item(12183, 168), new Item(12160, 1), new Item(12155, 1), new Item(2466, 1) }), GIANT_ENT_POUCH(12013, new Item[] { new Item(12183, 124), new Item(12159, 1), new Item(12155, 1), new Item(5933, 1) }), SPIRIT_COBRA_POUCH(12015, new Item[] { new Item(12183, 116), new Item(12160, 1), new Item(12155, 1), new Item(6287, 1) }), SPIRIT_DAGANNOTH_POUCH(12017, new Item[] { new Item(12183, 1), new Item(12160, 1), new Item(12155, 1), new Item(6155, 1) }), THORNY_SNAIL_POUCH(12019, new Item[] { new Item(12183, 9), new Item(12158, 1), new Item(12155, 1), new Item(3363, 1) }), BEAVER_POUCH(12021, new Item[] { new Item(12183, 72), new Item(12159, 1), new Item(12155, 1), new Item(1519, 1) }), KARAM_OVERLORD_POUCH(12023, new Item[] { new Item(12183, 144), new Item(12163, 1), new Item(12155, 1), new Item(6667, 1) }), HYDRA_POUCH(12025, new Item[] { new Item(12183, 128), new Item(12159, 1), new Item(12155, 1), new Item(571, 1) }), SPIRIT_JELLY_POUCH(12027, new Item[] { new Item(12183, 151), new Item(12163, 1), new Item(12155, 1), new Item(1937, 1) }), BUNYIP_POUCH(12029, new Item[] { new Item(12183, 110), new Item(12159, 1), new Item(12155, 1), new Item(383, 1) }), WAR_TORTOISE_POUCH(12031, new Item[] { new Item(12183, 1), new Item(12158, 1), new Item(12155, 1), new Item(7939, 1) }), FRUIT_BAT_POUCH(12033, new Item[] { new Item(12183, 130), new Item(12159, 1), new Item(12155, 1), new Item(1963, 1) }), ABYSSAL_PARASITE_POUCH(12035, new Item[] { new Item(12183, 106), new Item(12159, 1), new Item(12155, 1), new Item(12161, 1) }), ABYSSAL_LURKER_POUCH(12037, new Item[] { new Item(12183, 119), new Item(12159, 1), new Item(12155, 1), new Item(12161, 1) }), UNICORN_STALLION_POUCH(12039, new Item[] { new Item(12183, 140), new Item(12159, 1), new Item(12155, 1), new Item(237, 1) }), MAGPIE_POUCH(12041, new Item[] { new Item(12183, 88), new Item(12159, 1), new Item(12155, 1), new Item(1635, 1) }), DREADFOWL_POUCH(12043, new Item[] { new Item(12183, 8), new Item(12158, 1), new Item(12155, 1), new Item(2138, 1) }), STRANGER_PLANT_POUCH(12045, new Item[] { new Item(12183, 128), new Item(12160, 1), new Item(12155, 1), new Item(8431, 1) }), SPIRIT_WOLF_POUCH(12047, new Item[] { new Item(12183, 7), new Item(12158, 1), new Item(12155, 1), new Item(2859, 1) }), DESERT_WYRM_POUCH(12049, new Item[] { new Item(12183, 45), new Item(12159, 1), new Item(12155, 1), new Item(1783, 1) }), EVIL_TURNIP_POUCH(12051, new Item[] { new Item(12183, 104), new Item(12160, 1), new Item(12155, 1), new Item(12153, 1) }), VAMPYRE_BAT_POUCH(12053, new Item[] { new Item(12183, 81), new Item(12160, 1), new Item(12155, 1), new Item(3325, 1) }), SPIRIT_SCORPION_POUCH(12055, new Item[] { new Item(12183, 57), new Item(12160, 1), new Item(12155, 1), new Item(3095, 1) }), ARCTIC_BEAR_POUCH(12057, new Item[] { new Item(12183, 14), new Item(12158, 1), new Item(12155, 1), new Item(10117, 1) }), SPIRIT_SPIDER_POUCH(12059, new Item[] { new Item(12183, 8), new Item(12158, 1), new Item(12155, 1), new Item(6291, 1) }), BLOATED_LEECH_POUCH(12061, new Item[] { new Item(12183, 117), new Item(12160, 1), new Item(12155, 1), new Item(2132, 1) }), SPIRIT_KALPHITE_POUCH(12063, new Item[] { new Item(12183, 51), new Item(12163, 1), new Item(12155, 1), new Item(3138, 1) }), HONEY_BADGER_POUCH(12065, new Item[] { new Item(12183, 84), new Item(12160, 1), new Item(12155, 1), new Item(12156, 1) }), ALBINO_RAT_POUCH(12067, new Item[] { new Item(12183, 75), new Item(12163, 1), new Item(12155, 1), new Item(2134, 1) }), GRANITE_LOBSTER_POUCH(12069, new Item[] { new Item(12183, 166), new Item(12160, 1), new Item(12155, 1), new Item(6979, 1) }), MACAW_POUCH(12071, new Item[] { new Item(12183, 78), new Item(12159, 1), new Item(12155, 1), new Item(249, 1) }), BRONZE_MINOTAUR_POUCH(12073, new Item[] { new Item(12183, 102), new Item(12163, 1), new Item(12155, 1), new Item(2349, 1) }), IRON_MINOTAUR_POUCH(12075, new Item[] { new Item(12183, 125), new Item(12163, 1), new Item(12155, 1), new Item(2351, 1) }), STEEL_MINOTAUR_POUCH(12077, new Item[] { new Item(12183, 141), new Item(12163, 1), new Item(12155, 1), new Item(2353, 1) }), MITHRIL_MINOTAUR_POUCH(12079, new Item[] { new Item(12183, 152), new Item(12163, 1), new Item(12155, 1), new Item(2359, 1) }), ADAMANT_MINOTAUR_POUCH(12081, new Item[] { new Item(12183, 144), new Item(12163, 1), new Item(12155, 1), new Item(2361, 1) }), RUNE_MINOTAUR_POUCH(12083, new Item[] { new Item(12183, 1), new Item(12163, 1), new Item(12155, 1), new Item(2363, 1) }), SMOKE_DEVIL_POUCH(12085, new Item[] { new Item(12183, 141), new Item(12160, 1), new Item(12155, 1), new Item(9736, 1) }), BULL_ANT_POUCH(12087, new Item[] { new Item(12183, 11), new Item(12158, 1), new Item(12155, 1), new Item(6010, 1) }), WOLPERTINGER_POUCH(12089, new Item[] { new Item(12183, 203), new Item(12160, 1), new Item(12155, 1), new Item(2859, 1), new Item(3226, 1) }), COMPOST_MOUND_POUCH(12091, new Item[] { new Item(12183, 47), new Item(12159, 1), new Item(12155, 1), new Item(6032, 1) }), PACK_YAK_POUCH(12093, new Item[] { new Item(12183, 211), new Item(12160, 1), new Item(12155, 1), new Item(10818, 1) }), SP_COCKATRICE_POUCH(12095, new Item[] { new Item(12183, 88), new Item(12159, 1), new Item(12155, 1), new Item(12109, 1) }), SP_GUTHATRICE_POUCH(12097, new Item[] { new Item(12183, 88), new Item(12159, 1), new Item(12155, 1), new Item(12111, 1) }), SP_SARATRICE_POUCH(12099, new Item[] { new Item(12183, 88), new Item(12159, 1), new Item(12155, 1), new Item(12113, 1) }), SP_ZAMATRICE_POUCH(12101, new Item[] { new Item(12183, 88), new Item(12159, 1), new Item(12155, 1), new Item(12115, 1) }), SP_PENGATRICE_POUCH(12103, new Item[] { new Item(12183, 88), new Item(12159, 1), new Item(12155, 1), new Item(12117, 1) }), SP_CORAXATRICE_POUCH(12105, new Item[] { new Item(12183, 88), new Item(12159, 1), new Item(12155, 1), new Item(12119, 1) }), SP_VULATRICE_POUCH(12107, new Item[] { new Item(12183, 88), new Item(12159, 1), new Item(12155, 1), new Item(12121, 1) }), BARKER_TOAD_POUCH(12123, new Item[] { new Item(12183, 11), new Item(12158, 1), new Item(12155, 1), new Item(2150, 1) }), IBIS_POUCH(12531, new Item[] { new Item(12183, 109), new Item(12159, 1), new Item(12155, 1), new Item(311, 1) }), SWAMP_TITAN_POUCH(12776, new Item[] { new Item(12183, 150), new Item(12160, 1), new Item(12155, 1), new Item(10149, 1) }), SPIRIT_MOSQUITO_POUCH(12778, new Item[] { new Item(12183, 1), new Item(12158, 1), new Item(12155, 1), new Item(6319, 1) }), VOID_SPINNER_POUCH(12780, new Item[] { new Item(12183, 74), new Item(12163, 1), new Item(12155, 1), new Item(12166, 1) }), FORGE_REGENT_POUCH(12782, new Item[] { new Item(12183, 141), new Item(12159, 1), new Item(12155, 1), new Item(10020, 1) }), SPIRIT_LARUPIA_POUCH(12784, new Item[] { new Item(12183, 155), new Item(12163, 1), new Item(12155, 1), new Item(10095, 1) }), GEYSER_TITAN_POUCH(12786, new Item[] { new Item(12183, 222), new Item(12163, 1), new Item(12155, 1), new Item(1444, 1) }), LAVA_TITAN_POUCH(12788, new Item[] { new Item(12183, 219), new Item(12163, 1), new Item(12155, 1), new Item(12168, 1) }), STEEL_TITAN_POUCH(12790, new Item[] { new Item(12183, 178), new Item(12160, 1), new Item(12155, 1), new Item(1119, 1) }), OBSIDIAN_GOLEM_POUCH(12792, new Item[] { new Item(12183, 195), new Item(12163, 1), new Item(12155, 1), new Item(12168, 1) }), TALON_BEAST_POUCH(12794, new Item[] { new Item(12183, 174), new Item(12160, 1), new Item(12155, 1), new Item(12162, 1) }), ABYSSAL_TITAN_POUCH(12796, new Item[] { new Item(12183, 113), new Item(12159, 1), new Item(12155, 1), new Item(12161, 1) }), VOID_TORCHER_POUCH(12798, new Item[] { new Item(12183, 74), new Item(12163, 1), new Item(12155, 1), new Item(12167, 1) }), GIANT_CHINCHOMPA_POUCH(12800, new Item[] { new Item(12183, 84), new Item(12163, 1), new Item(12155, 1), new Item(10033, 1) }), FIRE_TITAN_POUCH(12802, new Item[] { new Item(12183, 198), new Item(12163, 1), new Item(12155, 1), new Item(1442, 1) }), MOSS_TITAN_POUCH(12804, new Item[] { new Item(12183, 202), new Item(12163, 1), new Item(12155, 1), new Item(1440, 1) }), ICE_TITAN_POUCH(12806, new Item[] { new Item(12183, 198), new Item(12163, 1), new Item(12155, 1), new Item(1438, 1), new Item(1444, 1) }), SPIRIT_TZ_KIH_POUCH(12808, new Item[] { new Item(12183, 64), new Item(12160, 1), new Item(12155, 1), new Item(12168, 1) }), SPIRIT_GRAAHK_POUCH(12810, new Item[] { new Item(12183, 154), new Item(12163, 1), new Item(12155, 1), new Item(10099, 1) }), SPIRIT_KYATT_POUCH(12812, new Item[] { new Item(12183, 153), new Item(12163, 1), new Item(12155, 1), new Item(10103, 1) }), VOID_SHIFTER_POUCH(12814, new Item[] { new Item(12183, 74), new Item(12163, 1), new Item(12155, 1), new Item(12165, 1) }), PYRELORD_POUCH(12816, new Item[] { new Item(12183, 111), new Item(12160, 1), new Item(12155, 1), new Item(590, 1) }), VOID_RAVAGER_POUCH(12818, new Item[] { new Item(12183, 74), new Item(12159, 1), new Item(12155, 1), new Item(12164, 1) }), RAVENOUS_LOCUST_POUCH(12820, new Item[] { new Item(12183, 79), new Item(12160, 1), new Item(12155, 1), new Item(1933, 1) }), IRON_TITAN_POUCH(12822, new Item[] { new Item(12183, 198), new Item(12160, 1), new Item(12155, 1), new Item(1115, 1) }), PHOENIX_POUCH(14623, new Item[] { new Item(12183, 165), new Item(12160, 1), new Item(12155, 1), new Item(14616, 1) }), CUB_BLOODRAGER_POUCH(17935, new Item[] { new Item(18017, 1), new Item(17630, 1) }), LITTLE_BLOODRAGER_POUCH(17936, new Item[] { new Item(18017, 1), new Item(17632, 1) }), NAIVE_BLOODRAGER_POUCH(17937, new Item[] { new Item(18017, 1), new Item(17634, 1) }), KEEN_BLOODRAGER_POUCH(17938, new Item[] { new Item(18018, 1), new Item(17636, 1) }), BRAVE_BLOODRAGER_POUCH(17939, new Item[] { new Item(18018, 1), new Item(17638, 1) }), BRAH_BLOODRAGER_POUCH(17940, new Item[] { new Item(18018, 1), new Item(17640, 1) }), NAABE_BLOODRAGER_POUCH(17941, new Item[] { new Item(18019, 1), new Item(17642, 1) }), WISE_BLOODRAGER_POUCH(17942, new Item[] { new Item(18019, 1), new Item(17644, 1) }), ADEPT_BLOODRAGER_POUCH(17943, new Item[] { new Item(18020, 1), new Item(17646, 1) }), SACHEM_BLOODRAGER_POUCH(17944, new Item[] { new Item(18020, 1), new Item(17648, 1) }), CUB_STORMBRINGER_POUCH(17945, new Item[] { new Item(18017, 1), new Item(17448, 1) }), LITTLE_STORMBRINGER_POUCH(17946, new Item[] { new Item(18017, 1), new Item(17450, 1) }), NAIVE_STORMBRINGER_POUCH(17947, new Item[] { new Item(18017, 1), new Item(17452, 1) }), KEEN_STORMBRINGER_POUCH(17948, new Item[] { new Item(18018, 1), new Item(17454, 1) }), BRAVE_STORMBRINGER_POUCH(17949, new Item[] { new Item(18018, 1), new Item(17456, 1) }), BRAH_STORMBRINGER_POUCH(17950, new Item[] { new Item(18018, 1), new Item(17458, 1) }), NAABE_STORMBRINGER_POUCH(17951, new Item[] { new Item(18019, 1), new Item(17460, 1) }), WISE_STORMBRINGER_POUCH(17952, new Item[] { new Item(18019, 1), new Item(17462, 1) }), ADEPT_STORMBRINGER_POUCH(17953, new Item[] { new Item(18020, 1), new Item(17464, 1) }), SACHEM_STORMBRINGER_POUCH(17954, new Item[] { new Item(18020, 1), new Item(17466, 1) }), CUB_HOARDSTALKER_POUCH(17955, new Item[] { new Item(18017, 1), new Item(17424, 1) }), LITTLE_HOARDSTALKER_POUCH(17956, new Item[] { new Item(18017, 1), new Item(17426, 1) }), NAIVE_HOARDSTALKER_POUCH(17957, new Item[] { new Item(18017, 1), new Item(17428, 1) }), KEEN_HOARDSTALKER_POUCH(17958, new Item[] { new Item(18018, 1), new Item(17430, 1) }), BRAVE_HOARDSTALKER_POUCH(17959, new Item[] { new Item(18018, 1), new Item(17432, 1) }), BRAH_HOARDSTALKER_POUCH(17960, new Item[] { new Item(18018, 1), new Item(17434, 1) }), NAABE_HOARDSTALKER_POUCH(17961, new Item[] { new Item(18019, 1), new Item(17436, 1) }), WISE_HOARDSTALKER_POUCH(17962, new Item[] { new Item(18019, 1), new Item(17438, 1) }), ADEPT_HOARDSTALKER_POUCH(17963, new Item[] { new Item(18020, 1), new Item(17440, 1) }), SACHEM_HOARDSTALKER_POUCH(17964, new Item[] { new Item(18020, 1), new Item(17442, 1) }), CUB_SKINWEAVER_POUCH(17965, new Item[] { new Item(18017, 1), new Item(18159, 2) }), LITTLE_SKINWEAVER_POUCH(17966, new Item[] { new Item(18017, 1), new Item(18161, 2) }), NAIVE_SKINWEAVER_POUCH(17967, new Item[] { new Item(18017, 1), new Item(18163, 2) }), KEEN_SKINWEAVER_POUCH(17968, new Item[] { new Item(18018, 1), new Item(18165, 2) }), BRAVE_SKINWEAVER_POUCH(17969, new Item[] { new Item(18018, 1), new Item(18167, 2) }), BRAH_SKINWEAVER_POUCH(17970, new Item[] { new Item(18018, 1), new Item(18169, 2) }), NAABE_SKINWEAVER_POUCH(17971, new Item[] { new Item(18019, 1), new Item(18171, 2) }), WISE_SKINWEAVER_POUCH(17972, new Item[] { new Item(18019, 1), new Item(18173, 2) }), ADEPT_SKINWEAVER_POUCH(17973, new Item[] { new Item(18020, 1), new Item(18175, 2) }), SACHEM_SKINWEAVER_POUCH(17974, new Item[] { new Item(18020, 1), new Item(18177, 2) }), CUB_WORLDBEARER_POUCH(17975, new Item[] { new Item(18017, 1), new Item(17995, 1) }), LITTLE_WORLDBEARER_POUCH(17976, new Item[] { new Item(18017, 1), new Item(17997, 1) }), NAIVE_WORLDBEARER_POUCH(17977, new Item[] { new Item(18017, 1), new Item(17999, 1) }), KEEN_WORLDBEARER_POUCH(17978, new Item[] { new Item(18018, 1), new Item(18001, 1) }), BRAVE_WORLDBEARER_POUCH(17979, new Item[] { new Item(18018, 1), new Item(18003, 1) }), BRAH_WORLDBEARER_POUCH(17980, new Item[] { new Item(18018, 1), new Item(18005, 1) }), NAABE_WORLDBEARER_POUCH(17981, new Item[] { new Item(18019, 1), new Item(18007, 1) }), WISE_WORLDBEARER_POUCH(17982, new Item[] { new Item(18019, 1), new Item(18009, 1) }), ADEPT_WORLDBEARER_POUCH(17983, new Item[] { new Item(18020, 1), new Item(18011, 1) }), SACHEM_WORLDBEARER_POUCH(17984, new Item[] { new Item(18020, 1), new Item(18013, 1) }), CUB_DEATHSLINGER_POUCH(17985, new Item[] { new Item(18017, 1), new Item(17682, 2) }), LITTLE_DEATHSLINGER_POUCH(17986, new Item[] { new Item(18017, 1), new Item(17684, 2) }), NAIVE_DEATHSLINGER_POUCH(17987, new Item[] { new Item(18017, 1), new Item(17686, 2) }), KEEN_DEATHSLINGER_POUCH(17988, new Item[] { new Item(18018, 1), new Item(17688, 2) }), BRAVE_DEATHSLINGER_POUCH(17989, new Item[] { new Item(18018, 1), new Item(17690, 2) }), BRAH_DEATHSLINGER_POUCH(17990, new Item[] { new Item(18018, 1), new Item(17692, 2) }), NAABE_DEATHSLINGER_POUCH(17991, new Item[] { new Item(18019, 1), new Item(17694, 2) }), WISE_DEATHSLINGER_POUCH(17992, new Item[] { new Item(18019, 1), new Item(17696, 2) }), ADEPT_DEATHSLINGER_POUCH(17993, new Item[] { new Item(18020, 1), new Item(17698, 2) }), SACHEM_DEATHSLINGER_POUCH(17994, new Item[] { new Item(18020, 1), new Item(17700, 2) }); private static final Map MAP = new HashMap<>(); static { for (PouchMaterialList l : PouchMaterialList.values()) MAP.put(l.pouchId, l); } public static PouchMaterialList forId(int pouchId) { return MAP.get(pouchId); } private final int pouchId; private final Item[] materials; private PouchMaterialList(int pouchId, Item[] materials) { this.pouchId = pouchId; this.materials = materials; } public Item[] get() { return materials; } public int getPouchId() { return pouchId; } }" "package com.rs.game.content.skills.summoning; public enum Scroll { /** * Hello leecher. Nice to see you here. You're welcome for doing all the hard work for you. * I hope you'll notice the license above :) */ HOWL(12425, ScrollTarget.COMBAT, ""Scares non-player opponents, causing them to retreat. However, this lasts for only a few seconds."", 0.1, 3) { @Override public int attack(Player owner, Familiar familiar, Entity target) { familiar.sync(8294, 1334); delayHit(familiar, World.sendProjectile(familiar, target, 1333, 34, 16, 30, 2.0, 16, 0).getTaskDelay(), target, getMagicHit(familiar, getMaxHit(familiar, 20, AttackStyle.MAGE, target))); if (target instanceof Familiar) familiar.getOwner().sendMessage(""Your familiar cannot scare other familiars.""); else if (target instanceof Player) familiar.getOwner().sendMessage(""Your familiar cannot scare a player.""); return Familiar.DEFAULT_ATTACK_SPEED; } }, DREADFOWL_STRIKE(12445, ScrollTarget.COMBAT, ""Fires a long-ranged, magic-based attack which can damage for up to 31."", 0.1, 3) { @Override public int attack(Player owner, Familiar familiar, Entity target) { familiar.sync(7810, 1523); delayHit(familiar, World.sendProjectile(familiar, target, 1318, 34, 16, 30, 35, 16, 0).getTaskDelay(), target, getMagicHit(familiar, getMaxHit(familiar, 40, AttackStyle.MAGE, target))); return Familiar.DEFAULT_ATTACK_SPEED; } }, FETCH_CASKET(19621, ScrollTarget.CLICK, ""Digs for a coordinate, compass, or scan clue any bypasses any mages/double agents."", 0.1, 12) { @Override public boolean use(Player owner, Familiar familiar) { if (owner.getTreasureTrailsManager().useDig(true)) { familiar.sync(14314, 1412); return true; } owner.sendMessage(""The meerkats don't sense anything nearby.""); return false; } }, EGG_SPAWN(12428, ScrollTarget.CLICK, ""Creates up to 5 red spider eggs on the ground next to the player."", 0.2, 6) { @Override public boolean use(Player player, Familiar familiar) { familiar.setNextAnimation(new Animation(8164)); int num = Utils.random(6); Set spawned = new HashSet<>(); for (int trycount = 0; trycount < Utils.getRandomInclusive(50); trycount++) { if (spawned.size() >= num) break; Tile tile = World.findAdjacentFreeTile(player.getTile()); if (spawned.contains(tile.getTileHash())) continue; spawned.add(tile.getTileHash()); num++; World.sendSpotAnim(tile, new SpotAnim(1342)); WorldTasks.schedule(1, () -> World.addGroundItem(new Item(223, 1), tile, player, true, 120)); } return true; } }, SLIME_SPRAY(12459, ScrollTarget.COMBAT, ""Fires a ranged-based attack that damages for up to 42."", 0.2, 3) { @Override public int attack(Player owner, Familiar familiar, Entity target) { familiar.sync(8148, 1385); delayHit(familiar, World.sendProjectile(familiar, target, 1386, 34, 16, 30, 35, 16, 0).getTaskDelay(), target, getRangeHit(familiar, getMaxHit(familiar, 80, AttackStyle.RANGE, target)), () -> target.setNextSpotAnim(new SpotAnim(1387))); return Familiar.DEFAULT_ATTACK_SPEED; } }, STONY_SHELL(12533, ScrollTarget.CLICK, ""Temporarily boosts the player's defence level by 4."", 0.2, 12) { @Override public boolean use(Player player, Familiar familiar) { familiar.sync(8109, 1326); player.getSkills().adjustStat(4, 0.0, Constants.DEFENSE); return true; } }, PESTER(12838, ScrollTarget.ENTITY, ""Immediately moves the mosquito to melee attack the target dealing up to 90 damage."", 0.5, 3) { @Override public boolean entity(Player owner, Familiar familiar, Entity target) { if (!owner.lineOfSightTo(target, false)) { owner.sendMessage(""Your mosquito can't find a way to get there.""); return false; } if (familiar.getTarget() != null) { owner.sendMessage(""Your mosquito is already attacking something.""); return false; } Tile tile = target.getNearestTeleTile(familiar); if (tile == null) { owner.sendMessage(""The mosquito can't find a place to land on that target right now.""); return false; } if (!familiar.commandAttack(target)) return false; familiar.freeze(3); familiar.sync(8040, 1440); delayHit(familiar, 2, target, getMeleeHit(familiar, getMaxHit(familiar, 90, AttackStyle.MELEE, target)), () -> { familiar.tele(target.getNearestTeleTile(familiar)); familiar.sync(8041, 1442); }); return true; } }, ELECTRIC_LASH(12460, ScrollTarget.COMBAT, ""Fires a small, magic lightning bolt at the opponent dealing up to 50 damage and stunning them."", 0.4, 6) { @Override public int attack(Player owner, Familiar familiar, Entity target) { familiar.sync(7803, 1410); delayHit(familiar, World.sendProjectile(familiar, target, 1411, 34, 16, 30, 35, 16, 0).getTaskDelay(), target, getMagicHit(familiar, getMaxHit(familiar, 50, AttackStyle.MAGE, target)), () -> target.setNextSpotAnim(new SpotAnim(1413))); return Familiar.DEFAULT_ATTACK_SPEED; } }, VENOM_SHOT(12432, ScrollTarget.COMBAT, ""Shoots a ranged-based drop of venom at the target, poisoning them for 50 damage."", 0.9, 6) { @Override public int attack(Player owner, Familiar familiar, Entity target) { familiar.sync(8124, 1403); delayHit(familiar, 2, target, getRangeHit(familiar, getMaxHit(familiar, 50, AttackStyle.RANGE, target)), () -> { target.setNextSpotAnim(new SpotAnim(1404)); target.getPoison().makePoisoned(50); }); return Familiar.DEFAULT_ATTACK_SPEED; } }, FIREBALL(12839, ScrollTarget.COMBAT, ""Hits up to 5 nearby targets with a fiery magic attack."", 1.1, 6) { @Override public int attack(Player owner, Familiar familiar, Entity target) { familiar.sync(7871, 1396); delayHit(familiar, World.sendProjectile(familiar, target, 1392, 34, 16, 30, 1.5, 16, 0).getTaskDelay(), target, getMagicHit(familiar, getMaxHit(familiar, 80, AttackStyle.MAGE, target)), () -> target.setNextSpotAnim(new SpotAnim(1390))); for (Entity next : PlayerCombatKt.getMultiAttackTargets(owner, target, 4, 5, false)) delayHit(familiar, World.sendProjectile(familiar, next, 1392, 34, 16, 30, 1.5, 16, 0).getTaskDelay(), next, getMagicHit(familiar, getMaxHit(familiar, 80, AttackStyle.MAGE, next)), () -> next.setNextSpotAnim(new SpotAnim(1390))); return Familiar.DEFAULT_ATTACK_SPEED; } }, CHEESE_FEAST(12430, ScrollTarget.CLICK, ""Fills the rat's inventory with 4 pieces of cheese."", 2.3, 6) { @Override public boolean use(Player owner, Familiar familiar) { if (familiar.getInventory().freeSlots() == 0) { owner.sendMessage(""Your rat already has plenty of cheese.""); return false; } familiar.sync(7906, 1384); familiar.getInventory().add(new Item(1985, 4)); return true; } }, SANDSTORM(12446, ScrollTarget.COMBAT, ""Hits up to 5 nearby targets with a magical sandstorm."", 2.5, 6) { @Override public int attack(Player owner, Familiar familiar, Entity target) { familiar.sync(8517, 1349); delayHit(familiar, World.sendProjectile(familiar, target, 1350, 34, 16, 30, 1.5, 16, 0).getTaskDelay(), target, getMagicHit(familiar, getMaxHit(familiar, 90, AttackStyle.MAGE, target))); for (Entity next : PlayerCombatKt.getMultiAttackTargets(owner, target, 4, 5, false)) delayHit(familiar, World.sendProjectile(familiar, next, 1350, 34, 16, 30, 1.5, 16, 0).getTaskDelay(), next, getMagicHit(familiar, getMaxHit(familiar, 90, AttackStyle.MAGE, next))); return Familiar.DEFAULT_ATTACK_SPEED; } }, COMPOST_GENERATE(12440, ScrollTarget.OBJECT, ""Fills the targeted compost bin with compost. With a 10% chance of yielding super compost."", 0.6, 12) { @Override public boolean object(Player owner, Familiar familiar, GameObject object) { PatchLocation loc = PatchLocation.forObject(object.getId()); if (loc == null || loc.type != PatchType.COMPOST) { owner.sendMessage(""This must be cast on an empty compost bin.""); return false; } FarmPatch getSpot = owner.getPatch(loc); if (getSpot == null) getSpot = new FarmPatch(loc); if (getSpot.lives < 0) { owner.sendMessage(""This must be cast on an empty compost bin.""); return false; } final FarmPatch spot = getSpot; owner.lock(); owner.sync(7660, 1316); familiar.sync(7775, 1461); World.sendProjectile(familiar, object, 1462, 34, 16, 30, 1.0, 16, proj -> { World.sendSpotAnim(object.getTile(), new SpotAnim(1460)); owner.unlock(); boolean superCompost = Utils.random(10) == 0; spot.lives = 15; spot.seed = superCompost ? ProduceType.Supercompost : ProduceType.Compost; spot.compostLevel = superCompost ? 2 : 1; owner.putPatch(spot); spot.updateVars(owner); }); return true; } }, EXPLODE(12834, ScrollTarget.COMBAT, ""Allahu Akbar's the target with an AOE range of damage."", 2.9, 3) { @Override public int attack(Player owner, Familiar familiar, Entity target) { familiar.freeze(3); familiar.setLocked(true); familiar.sync(7758, 1364); for (Entity next : PlayerCombatKt.getMultiAttackTargets(owner, familiar.getTile(), 1, 9)) { delayHit(familiar, 1, next, getRangeHit(familiar, getMaxHit(familiar, 120, AttackStyle.RANGE, next))); delayHit(familiar, 1, next, getRangeHit(familiar, getMaxHit(familiar, 60, AttackStyle.RANGE, next))); delayHit(familiar, 2, next, getRangeHit(familiar, getMaxHit(familiar, 120, AttackStyle.RANGE, next))); delayHit(familiar, 2, next, getRangeHit(familiar, getMaxHit(familiar, 60, AttackStyle.RANGE, next))); } WorldTasks.delay(2, () -> { familiar.kill(); familiar.finish(); }); return Familiar.DEFAULT_ATTACK_SPEED; } }, VAMPYRE_TOUCH(12447, ScrollTarget.COMBAT, ""Attacks the target and heals the player for 50% of the damage dealt."", 1.5, 4) { @Override public int attack(Player owner, Familiar familiar, Entity target) { familiar.sync(8277, 1323); delayHit(familiar, World.sendProjectile(familiar, target, 1324, 34, 16, 30, 35, 16, 0).getTaskDelay(), target, getMagicHit(familiar, getMaxHit(familiar, 180, AttackStyle.MAGE, target)), () -> target.setNextSpotAnim(new SpotAnim(1325))); return Familiar.DEFAULT_ATTACK_SPEED; } }, INSANE_FEROCITY(12433, ScrollTarget.CLICK, ""Boosts the players attack and strength at the cost of magic, ranged, and defense levels."", 1.6, 12) { @Override public boolean use(Player owner, Familiar familiar) { familiar.sync(7930, 1397); owner.spotAnim(1399); familiar.getAttribs().setL(""insaneFerocity"", World.getServerTicks() + Ticks.fromMinutes(5)); owner.getSkills().adjustStat(5, 0.15, Constants.ATTACK); owner.getSkills().adjustStat(5, 0.15, Constants.STRENGTH); owner.lowerStat(Constants.RANGE, 0.1, 0.0); owner.lowerStat(Constants.MAGIC, 0.1, 0.0); owner.lowerStat(Constants.DEFENSE, 0.1, 0.0); return true; } }, MULTICHOP(12429, ScrollTarget.OBJECT, ""Sends off the beaver to chop the target tree."", 0.7, 3) { @Override public boolean object(Player owner, Familiar familiar, GameObject object) { TreeType type = TreeType.forObject(owner, object); if (type == null || (!object.getDefinitions().containsOption(0, ""Chop down"") && !object.getDefinitions().containsOption(0, ""Cut down""))) { owner.sendMessage(""You can't chop that down.""); return false; } if (type.getLevel() > owner.getSkills().getLevel(Skills.WOODCUTTING)) { owner.sendMessage(""You need a woodcutting level of "" + type.getLevel() + "" to chop down this tree.""); return false; } familiar.stopAll(); familiar.faceObject(object); familiar.setNextFaceEntity(null); familiar.walkToAndExecute(object.getTile(), () -> familiar.getActionManager().setAction(new Woodcutting(object, type).setLevel(60))); return true; } }, CALL_TO_ARMS(12443, ScrollTarget.CLICK, ""Teleports the player to the landers at Pest Control."", 0.7, 3) { @Override public boolean use(Player player, Familiar familiar) { Magic.sendTeleportSpell(player, -1, -1, 1503, 1502, 0, 0.0, Tile.of(2662, 2654, 0), 1, true, TeleType.MAGIC, () -> { familiar.decrementScroll(); familiar.sync(switch(familiar.getPouch()) { default -> 8097; case VOID_SPINNER -> 8181; case VOID_TORCHER -> 8243; case VOID_SHIFTER -> 8139; }, 1506); }, null); return false; } }, BRONZE_BULL(12461, ScrollTarget.COMBAT, ""Fires a magic based attack at the opponent hitting for up to 80 damage."", 3.6, 6) { @Override public int attack(Player owner, Familiar familiar, Entity target) { familiar.sync(8026, 1496); delayHit(familiar, World.sendProjectile(familiar, target, 1497, 34, 16, 30, 35, 16, 0).getTaskDelay(), target, getMagicHit(familiar, getMaxHit(familiar, 80, AttackStyle.MAGE, target))); return Familiar.DEFAULT_ATTACK_SPEED; } }, UNBURDEN(12431, ScrollTarget.CLICK, ""Restores the player's run energy by half of their agility level."", 0.6, 12) { @Override public boolean use(Player player, Familiar familiar) { if (player.getRunEnergy() == 100) { player.sendMessage(""This wouldn't affect you at all.""); return false; } familiar.sync(7903, 1382); player.spotAnim(1300); int runEnergy = (int) (player.getRunEnergy() + (Math.round((float) player.getSkills().getLevel(Constants.AGILITY) / 2))); player.setRunEnergy(runEnergy > 100 ? 100 : runEnergy); return true; } }, HERBCALL(12422, ScrollTarget.CLICK, ""Sends the macaw to find a random herb to bring back to the player."", 0.8, 12) { @Override public boolean use(Player owner, Familiar familiar) { owner.lock(); WorldTasks.scheduleTimer(timer -> { switch(timer) { case 0 -> familiar.anim(8013); case 2 -> familiar.spotAnim(1321); case 3 -> familiar.anim(8014); case 5 -> { Item[] herb = DropTable.calculateDrops(owner, DropSets.getDropSet(""herb"")); if (herb.length < 1) { owner.unlock(); return false; } World.addGroundItem(herb[0], Tile.of(familiar.getTile()), owner, true, 120); owner.unlock(); } } return true; }); return true; } }, EVIL_FLAMES(12448, ScrollTarget.COMBAT, ""Fires a magic fireball at the target and lowering their magic level."", 2.1, 6) { @Override public int attack(Player owner, Familiar familiar, Entity target) { familiar.sync(8251, 1328); delayHit(familiar, World.sendProjectile(familiar, target, 1330, 34, 16, 30, 1.5, 16, 0).getTaskDelay(), target, getMagicHit(familiar, getMaxHit(familiar, 120, AttackStyle.MAGE, target)), () -> target.setNextSpotAnim(new SpotAnim(1329))); return Familiar.DEFAULT_ATTACK_SPEED; } }, PETRIFYING_GAZE(12458, ScrollTarget.COMBAT, ""Deals up to 10 damage and lowers the target's levels depending on which cockatrice variant is casting."", 0.9, 3) { @Override public int attack(Player owner, Familiar familiar, Entity target) { familiar.sync(7766, 1467); Hit hit = getMagicHit(familiar, getMaxHit(familiar, 10, AttackStyle.MAGE, target)); delayHit(familiar, World.sendProjectile(familiar, target, 1468, 34, 16, 30, 35, 16, 0).getTaskDelay(), target, hit, () -> { if (hit.getDamage() > 0) { int skill = switch(familiar.getPouch()) { default -> Skills.DEFENSE; case SPIRIT_ZAMATRICE -> Skills.STRENGTH; case SPIRIT_VULATRICE -> Skills.RANGE; case SPIRIT_SARATRICE -> Skills.PRAYER; case SPIRIT_GUTHATRICE -> Skills.ATTACK; case SPIRIT_CORAXATRICE -> Skills.SUMMONING; case SPIRIT_PENGATRICE -> Skills.MAGIC; }; target.spotAnim(1469); target.lowerStat(skill, 1, 0.0); } }); return Familiar.DEFAULT_ATTACK_SPEED; } }, IRON_BULL(12462, ScrollTarget.COMBAT, ""Fires a magic based attack at the opponent hitting for up to 100 damage."", 4.6, 6) { @Override public int attack(Player owner, Familiar familiar, Entity target) { familiar.sync(8026, 1496); delayHit(familiar, World.sendProjectile(familiar, target, 1497, 34, 16, 30, 35, 16, 0).getTaskDelay(), target, getMagicHit(familiar, getMaxHit(familiar, 100, AttackStyle.MAGE, target))); return Familiar.DEFAULT_ATTACK_SPEED; } }, IMMENSE_HEAT(12829, ScrollTarget.ITEM, ""Allows the player to craft a single peice of jewelry without a furnace."", 2.3, 6) { @Override public boolean item(Player owner, Familiar familiar, Item item) { if (item.getId() != JewelryCraftingKt.GOLD_BAR) { owner.sendMessage(""This must be cast on a gold bar.""); return false; } JewelryCraftingKt.openInterface(owner, true); return false; } }, THIEVING_FINGERS(12426, ScrollTarget.CLICK, ""Temporarily raises the player's thieving level by 2."", 0.9, 12) { @Override public boolean use(Player owner, Familiar familiar) { familiar.sync(8020, 1336); owner.spotAnim(1300); owner.getSkills().adjustStat(2, 0.0, Constants.THIEVING); return true; } }, BLOOD_DRAIN(12444, ScrollTarget.CLICK, ""Restores the player's stats by 2 + 20% and cures poison. Damages the player for 25 damage, though."", 2.4, 6) { @Override public boolean use(Player owner, Familiar familiar) { familiar.sync(7715, 1419); owner.spotAnim(1420); World.sendProjectile(familiar, owner, 1417, 15, 16, 30, 2.0, 16, 0); owner.applyHit(new Hit(owner, 25, HitLook.TRUE_DAMAGE)); owner.getPoison().reset(); owner.getSkills().adjustStat(2, 0.20, false, Utils.range(0, Skills.SIZE-1)); return true; } }, TIRELESS_RUN(12441, ScrollTarget.CLICK, ""Restores the player's run energy by half of their agility level. Boosts agility level by 2."", 0.8, 8) { @Override public boolean use(Player player, Familiar familiar) { if (player.getRunEnergy() >= 100) { player.sendMessage(""You're already full run energy.""); return false; } familiar.sync(8229, 1521); player.spotAnim(1300); player.getSkills().adjustStat(2, 0.0, Constants.AGILITY); int runEnergy = (int) (player.getRunEnergy() + (Math.round((float) player.getSkills().getLevel(Constants.AGILITY) / 2))); player.setRunEnergy(runEnergy > 100 ? 100 : runEnergy); return true; } }, ABYSSAL_DRAIN(12454, ScrollTarget.COMBAT, ""Fires a magic based attack that lowers the opponent's magic level and prayer points, restoring them to the player."", 1.1, 6) { @Override public int attack(Player owner, Familiar familiar, Entity target) { familiar.sync(7675, 1422); Hit hit = delayHit(familiar, World.sendProjectile(familiar, target, 1423, 70, 16, 30, 2.0, 16, 0).getTaskDelay(), target, getMagicHit(familiar, getMaxHit(familiar, 95, AttackStyle.MAGE, target))); if (hit.getDamage() > 0) { target.lowerStat(Constants.MAGIC, 0.1, 0.0); target.lowerStat(Constants.PRAYER, 0.1, 0.0); } return Familiar.DEFAULT_ATTACK_SPEED; } }, DISSOLVE(12453, ScrollTarget.COMBAT, ""Fires a magical attack that dissolves the opponent and lowers their attack stat."", 5.5, 6) { @Override public int attack(Player owner, Familiar familiar, Entity target) { familiar.sync(8514, 1361); Hit hit = delayHit(familiar, World.sendProjectile(familiar, target, 1359, 70, 16, 30, 2.0, 16, 0).getTaskDelay(), target, getMagicHit(familiar, getMaxHit(familiar, 120, AttackStyle.MAGE, target)), () -> target.spotAnim(1360)); if (hit.getDamage() > 0) target.lowerStat(Constants.ATTACK, 0.1, 0.0); return Familiar.DEFAULT_ATTACK_SPEED; } }, FISH_RAIN(12424, ScrollTarget.CLICK, ""Produces a random, low-level fish next to the player."", 1.1, 12) { @Override public boolean use(Player owner, Familiar familiar) { familiar.sync(8199, 1337); WorldTasks.schedule(2, () -> World.addGroundItem(new Item(new int[] { 317, 341, 363, 353 }[Utils.random(4)]), Tile.of(familiar.getTile()), owner, true, 120)); return true; } }, STEEL_BULL(12463, ScrollTarget.COMBAT, ""Fires a magic based attack at the opponent hitting for up to 120 damage."", 5.6, 6) { @Override public int attack(Player owner, Familiar familiar, Entity target) { familiar.sync(8026, 1496); delayHit(familiar, World.sendProjectile(familiar, target, 1497, 34, 16, 30, 35, 16, 0).getTaskDelay(), target, getMagicHit(familiar, getMaxHit(familiar, 120, AttackStyle.MAGE, target))); return Familiar.DEFAULT_ATTACK_SPEED; } }, AMBUSH(12836, ScrollTarget.ENTITY, ""Teleports to the target and attacks the target, dealing up to 224 damage."", 5.7, 3) { @Override public boolean entity(Player owner, Familiar familiar, Entity target) { if (!owner.lineOfSightTo(target, false)) { owner.sendMessage(""Your kyatt can't find a way to get there.""); return false; } if (familiar.getTarget() != null) { owner.sendMessage(""Your kyatt is already attacking something.""); return false; } Tile tile = target.getNearestTeleTile(familiar); if (tile == null) { owner.sendMessage(""Your kyatt can't find a place to land on that target right now.""); return false; } if (!familiar.commandAttack(target)) return false; familiar.freeze(2); delayHit(familiar, 0, target, getMeleeHit(familiar, getMaxHit(familiar, 224, AttackStyle.MELEE, target)), () -> { familiar.tele(target.getNearestTeleTile(familiar)); familiar.sync(7914, 1366); }); return true; } }, RENDING(12840, ScrollTarget.COMBAT, ""Performs a magic based attack that lowers the opponent's strength."", 5.7, 3) { @Override public int attack(Player owner, Familiar familiar, Entity target) { familiar.sync(7919, 1370); Hit hit = delayHit(familiar, World.sendProjectile(familiar, target, 1371, 70, 16, 30, 35, 16, 0).getTaskDelay(), target, getMagicHit(familiar, getMaxHit(familiar, 120, AttackStyle.MAGE, target)), () -> target.spotAnim(1372)); if (hit.getDamage() > 0) target.lowerStat(Constants.STRENGTH, 0.1, 0.0); return Familiar.DEFAULT_ATTACK_SPEED; } }, GOAD(12835, ScrollTarget.COMBAT, ""Gores the opponent with a powerful melee attack. Hits twice for up to 120 damage each."", 5.7, 6) { @Override public int attack(Player owner, Familiar familiar, Entity target) { familiar.anim(7915); delayHit(familiar, 0, target, getMeleeHit(familiar, getMaxHit(familiar, 120, AttackStyle.MELEE, target))); delayHit(familiar, 0, target, getMeleeHit(familiar, getMaxHit(familiar, 120, AttackStyle.MELEE, target))); return Familiar.DEFAULT_ATTACK_SPEED; } }, DOOMSPHERE(12455, ScrollTarget.COMBAT, ""Attacks the opponent with a strong water spell that hits up to 76 damage and drains the target's magic."", 5.8, 3) { @Override public int attack(Player owner, Familiar familiar, Entity target) { familiar.sync(7974, 1478); Hit hit = delayHit(familiar, World.sendProjectile(familiar, target, 1479, 34, 16, 30, 35, 16, 0).getTaskDelay(), target, getMagicHit(familiar, getMaxHit(familiar, 78, AttackStyle.MAGE, target)), () -> target.spotAnim(1480)); if (hit.getDamage() > 0) target.lowerStat(Constants.MAGIC, 0.05, 0.0); return Familiar.DEFAULT_ATTACK_SPEED; } }, DUST_CLOUD(12468, ScrollTarget.COMBAT, ""Hits up to 6 nearby targets for up to 79 damage with a strong magical dust cloud."", 3, 6) { @Override public int attack(Player owner, Familiar familiar, Entity target) { familiar.sync(7820, 1375); delayHit(familiar, World.sendProjectile(familiar, target, 1376, 34, 16, 30, 1.5, 16, 0).getTaskDelay(), target, getMagicHit(familiar, getMaxHit(familiar, 80, AttackStyle.MAGE, target)), () -> target.setNextSpotAnim(new SpotAnim(1377))); for (Entity next : PlayerCombatKt.getMultiAttackTargets(owner, target, 7, 6, false)) delayHit(familiar, World.sendProjectile(familiar, next, 1376, 34, 16, 30, 1.5, 16, 0).getTaskDelay(), next, getMagicHit(familiar, getMaxHit(familiar, 80, AttackStyle.MAGE, next)), () -> next.setNextSpotAnim(new SpotAnim(1377))); return Familiar.DEFAULT_ATTACK_SPEED; } }, ABYSSAL_STEALTH(12427, ScrollTarget.CLICK, ""Temporarily boosts the player's agility and thieving levels by 4 each."", 1.9, 20) { @Override public boolean use(Player owner, Familiar familiar) { familiar.sync(7682, 1339); owner.spotAnim(1302); owner.getSkills().adjustStat(4, 0.0, Skills.AGILITY, Skills.THIEVING); return true; } }, OPHIDIAN_INCUBATION(12436, ScrollTarget.ITEM, ""Transforms a single egg in the player's inventory into a cockatrice variant."", 3.1, 3) { enum Egg { CHICKEN(1944, 12109), BLUE(5077, 12113), RED(5076, 12115), GREEN(5078, 12111), RAVEN(11964, 12119), PENGUIN(12483, 12117), VULTURE(11965, 12121); private final int id; private final int toId; Egg(int id, int toId) { this.id = id; this.toId = toId; } static Egg forId(int id) { for (Egg e : Egg.values()) if (e.id == id) return e; return null; } } @Override public boolean item(Player owner, Familiar familiar, Item item) { Egg egg = Egg.forId(item.getId()); if (egg == null) { owner.sendMessage(""The cobra can only incubate eggs.""); return false; } familiar.sync(8159, 1388); item.setId(egg.toId); owner.getInventory().refresh(item.getSlot()); WorldTasks.schedule(2, () -> World.sendProjectile(familiar.getMiddleTile(), owner, 1389, 50, 30, 0, 0.15, 16, 0)); return true; } }, POISONOUS_BLAST(12467, ScrollTarget.COMBAT, ""Attacks the target with a magic attack that deals up to 120 damage."", 3.2, 6) { @Override public int attack(Player owner, Familiar familiar, Entity target) { familiar.anim(8214); delayHit(familiar, World.sendProjectile(familiar, target, 1508, 34, 16, 30, 35, 16, 0).getTaskDelay(), target, getMagicHit(familiar, getMaxHit(familiar, 120, AttackStyle.MAGE, target))); return Familiar.DEFAULT_ATTACK_SPEED; } }, MITHRIL_BULL(12464, ScrollTarget.COMBAT, ""Fires a magic based attack at the opponent hitting for up to 160 damage."", 6.6, 6) { @Override public int attack(Player owner, Familiar familiar, Entity target) { familiar.sync(8026, 1496); delayHit(familiar, World.sendProjectile(familiar, target, 1497, 34, 16, 30, 35, 16, 0).getTaskDelay(), target, getMagicHit(familiar, getMaxHit(familiar, 160, AttackStyle.MAGE, target))); return Familiar.DEFAULT_ATTACK_SPEED; } }, TOAD_BARK(12452, ScrollTarget.COMBAT, ""Performs the same attack as if it were loaded with a cannonball."", 1, 6) { @Override public int attack(Player owner, Familiar familiar, Entity target) { BarkerToad.shootCannonball(familiar, target); return Familiar.DEFAULT_ATTACK_SPEED; } }, TESTUDO(12439, ScrollTarget.CLICK, ""Temporarily boosts the player's defense level by 8 points."", 0.7, 20) { @Override public boolean use(Player player, Familiar familiar) { familiar.sync(8288, 1414); player.getSkills().adjustStat(8, 0.0, Constants.DEFENSE); return true; } }, SWALLOW_WHOLE(12438, ScrollTarget.ITEM, ""Allows a player to eat a raw fish (assuming the player has the proper cooking level for it). Also does not trigger the eat timer."", 1.4, 3) { enum Fish { CRAYFISH(13435, 2), SHRIMP(317, 3), ANCHOVIES(321, 1), SARDINE(327, 3), HERRING(345, 5), MACKEREL(353, 6), TROUT(335, 7), COD(341, 7), PIKE(349, 8), SALMON(331, 9), TUNA(359, 10), LOBSTER(377, 12), BASS(363, 13), SWORDFISH(371, 14), MONKFISH(7944, 16), SHARK(383, 20), TURTLE(395, 21), MANTA(389, 22), CAVEFISH(15264, 22), ROCKTAIL(15270, 23); final int id; final int heal; Fish(int id, int heal) { this.id = id; this.heal = heal; } static Fish forId(int id) { for (Fish f : Fish.values()) if (f.id == id) return f; return null; } } @Override public boolean item(Player owner, Familiar familiar, Item item) { Fish fish = Fish.forId(item.getId()); if (fish == null) { owner.sendMessage(""Your bunyip can only eat raw fish.""); return false; } owner.getInventory().deleteItem(item); familiar.sync(7747, 1481); owner.heal(fish.heal * 10); return true; } }, FRUITFALL(12423, ScrollTarget.CLICK, ""Drops from 0-5 random fruit on the ground around the player."", 1.4, 6) { @Override public boolean use(Player owner, Familiar familiar) { familiar.anim(8277); int num = Utils.random(7); Set spawned = new HashSet<>(); boolean papaya = true; for (int trycount = 0; trycount < Utils.getRandomInclusive(50); trycount++) { if (spawned.size() >= num) break; Tile tile = World.findAdjacentFreeTile(owner.getTile()); if (spawned.contains(tile.getTileHash())) continue; spawned.add(tile.getTileHash()); World.sendSpotAnim(tile, new SpotAnim(1331)); final boolean spawnPapaya = papaya; WorldTasks.schedule(1, () -> World.addGroundItem(new Item(spawnPapaya ? 5972 : randomFruit(), 1), tile, owner, true, 120)); papaya = false; } return true; } private int randomFruit() { return new int[] { 2102, 2108, 2114, 2120, 1963 }[Utils.random(5)]; } }, FAMINE(12830, ScrollTarget.COMBAT, ""Consumes a piece of the target's food."", 1.5, 12) { @Override public int attack(Player owner, Familiar familiar, Entity target) { familiar.sync(7998, 1346); World.sendProjectile(familiar, target, 1347, 34, 16, 30, 1.5, 16, proj -> target.spotAnim(1348)); if (target instanceof Player player) { var foods = Arrays.stream(player.getInventory().getItems().array()).filter(it -> it != null && Foods.isConsumable(it)).toList(); if (!foods.isEmpty()) { var food = foods.get(Utils.random(foods.size())); food.setId(2959); food.setAmount(1); player.getInventory().refresh(); } } return Familiar.DEFAULT_ATTACK_SPEED; } }, ARCTIC_BLAST(12451, ScrollTarget.COMBAT, ""Fires a large magic attack at the opponent, hitting up to 130 damage with a chance of stunning them."", 1.1, 6) { @Override public int attack(Player owner, Familiar familiar, Entity target) { familiar.sync(8523, 1405); Hit hit = delayHit(familiar, World.sendProjectile(familiar, target, 1406, 34, 16, 30, 1.5, 16, 0).getTaskDelay(), target, getMagicHit(familiar, getMaxHit(familiar, 130, AttackStyle.MAGE, target)), () -> target.spotAnim(1407)); if (hit.getDamage() > 0 && Utils.random(5) == 0 && target.getSize() <= 1) target.addEffect(Effect.STUN, 3); return Familiar.DEFAULT_ATTACK_SPEED; } }, RISE_FROM_THE_ASHES(14622, ScrollTarget.COMBAT, ""This special is a pain in the ass to code."", 8, 5) { @Override public int attack(Player owner, Familiar familiar, Entity target) { //TODO return Familiar.CANCEL_SPECIAL; } }, VOLCANIC_STRENGTH(12826, ScrollTarget.CLICK, ""Boosts the player's strength level by 9 points."", 7.3, 12) { @Override public boolean use(Player owner, Familiar familiar) { familiar.sync(8053, 1465); owner.getSkills().adjustStat(9, 0.0, Constants.STRENGTH); return true; } }, MANTIS_STRIKE(12450, ScrollTarget.COMBAT, ""Fires a magic based attack at the opponent dealing up to 100 damage, binding them for 3 seconds, and draining their prayer."", 3.7, 6) { @Override public int attack(Player owner, Familiar familiar, Entity target) { familiar.sync(8071, 1379); Hit hit = delayHit(familiar, World.sendProjectile(familiar, target, 1380, 34, 16, 30, 1.5, 16, 0).getTaskDelay(), target, getMagicHit(familiar, getMaxHit(familiar, 100, AttackStyle.MAGE, target)), () -> target.spotAnim(1381)); if (hit.getDamage() > 0 && target.getSize() <= 1) target.freeze(3, true); return Familiar.DEFAULT_ATTACK_SPEED; } }, CRUSHING_CLAW(12449, ScrollTarget.COMBAT, ""Launches a magic based attack at the target dealing up to 96 damage and draining their defense."", 3.7, 6) { @Override public int attack(Player owner, Familiar familiar, Entity target) { familiar.sync(8118, 1351); Hit hit = delayHit(familiar, World.sendProjectile(familiar, target, 1352, 34, 16, 30, 1.5, 16, 0).getTaskDelay(), target, getMagicHit(familiar, getMaxHit(familiar, 96, AttackStyle.MAGE, target)), () -> target.spotAnim(1353)); if (hit.getDamage() > 0) target.lowerStat(Skills.DEFENSE, 0.05, 0.0); return Familiar.DEFAULT_ATTACK_SPEED; } }, INFERNO(12841, ScrollTarget.COMBAT, ""Fires a magic based attack that disarms the opponent and deals up to 85 damage."", 1.5, 6) { @Override public int attack(Player owner, Familiar familiar, Entity target) { familiar.sync(7871, 1328); delayHit(familiar, World.sendProjectile(familiar, target, 1330, 34, 16, 30, 1.8, 16, 0).getTaskDelay(), target, getMagicHit(familiar, getMaxHit(familiar, 85, AttackStyle.MAGE, target))); return Familiar.DEFAULT_ATTACK_SPEED; } }, ADAMANT_BULL(12465, ScrollTarget.COMBAT, ""Fires a magic based attack at the opponent hitting for up to 200 damage."", 7.6, 6) { @Override public int attack(Player owner, Familiar familiar, Entity target) { familiar.sync(8026, 1496); delayHit(familiar, World.sendProjectile(familiar, target, 1497, 34, 16, 30, 35, 16, 0).getTaskDelay(), target, getMagicHit(familiar, getMaxHit(familiar, 200, AttackStyle.MAGE, target))); return Familiar.DEFAULT_ATTACK_SPEED; } }, DEADLY_CLAW(12831, ScrollTarget.COMBAT, ""Causes the talon beast to attack with magic instead of melee. Dealing up to 300 damage."", 11.4, 6) { @Override public int attack(Player owner, Familiar familiar, Entity target) { familiar.anim(familiar.getCombatDefinitions().getAttackEmote()); delayHit(familiar, 0, target, getMagicHit(familiar, getMaxHit(familiar, familiar.getCombatDefinitions().getMaxHit(), AttackStyle.MAGE, target))); delayHit(familiar, 1, target, getMagicHit(familiar, getMaxHit(familiar, familiar.getCombatDefinitions().getMaxHit(), AttackStyle.MAGE, target))); delayHit(familiar, 2, target, getMagicHit(familiar, getMaxHit(familiar, familiar.getCombatDefinitions().getMaxHit(), AttackStyle.MAGE, target))); return Familiar.DEFAULT_ATTACK_SPEED; } }, ACORN_MISSILE(12457, ScrollTarget.COMBAT, ""Hits anyone around the opponent with a rain of acorns dealing up to 100 damage each."", 1.6, 6) { @Override public int attack(Player owner, Familiar familiar, Entity target) { familiar.anim(7858); delayHit(familiar, World.sendProjectile(familiar, target, 1362, 34, 16, 30, 1.5, 16, 0).getTaskDelay(), target, getMagicHit(familiar, getMaxHit(familiar, 100, AttackStyle.MAGE, target)), () -> target.setNextSpotAnim(new SpotAnim(1363))); for (Entity next : PlayerCombatKt.getMultiAttackTargets(owner, target, 1, 9, false)) delayHit(familiar, World.sendProjectile(familiar, next, 1362, 34, 16, 30, 1.5, 16, 0).getTaskDelay(), next, getMagicHit(familiar, getMaxHit(familiar, 100, AttackStyle.MAGE, next)), () -> next.setNextSpotAnim(new SpotAnim(1363))); return Familiar.DEFAULT_ATTACK_SPEED; } }, TITANS_CONSTITUTION(12824, ScrollTarget.CLICK, ""Boosts the player's defense by 12.5% and restores 10% of their max health."", 7.9, 20) { @Override public boolean use(Player owner, Familiar familiar) { if (owner.getHitpoints() == owner.getMaxHitpoints()) { owner.sendMessage(""You're already at full hitpoints!""); return false; } if (familiar.getPouch() == Pouch.ICE_TITAN) { familiar.sync(7837, 1512); owner.spotAnim(1306); } else if (familiar.getPouch() == Pouch.FIRE_TITAN) { familiar.sync(7835, 1514); owner.spotAnim(1307); } else if (familiar.getPouch() == Pouch.MOSS_TITAN) { familiar.sync(7837, 1513); owner.spotAnim(1308); } owner.heal((int) ((double) owner.getMaxHitpoints() * 0.10)); owner.getSkills().adjustStat(0, 0.125, Constants.DEFENSE); return true; } }, REGROWTH(12442, ScrollTarget.OBJECT, ""Immediately regrows a tree that has been felled by farming."", 1.6, 6) { @Override public boolean object(Player owner, Familiar familiar, GameObject object) { if (object.getAttribs().getI(""originalTrunkId"", -1) == -1 || object.getAttribs().getI(""originalTrunkId"", -1) == object.getId()) { owner.sendMessage(""You can only cast this on a trunk.""); return false; } object.setId(object.getAttribs().getI(""originalTrunkId"", -1)); familiar.setNextFaceEntity(null); familiar.setLockedForTicks(2); familiar.faceObject(object); familiar.sync(7945, 1487); return true; } }, SPIKE_SHOT(12456, ScrollTarget.COMBAT, ""Fires a magic attack that deals up to 170 damage."", 4.1, 6) { @Override public int attack(Player owner, Familiar familiar, Entity target) { familiar.anim(7787); delayHit(familiar, World.sendProjectile(familiar, target, 1426, 34, 16, 30, 35, 16, 0).getTaskDelay(), target, getMagicHit(familiar, getMaxHit(familiar, 170, AttackStyle.MAGE, target)), () -> target.spotAnim(1428)); return Familiar.DEFAULT_ATTACK_SPEED; } }, EBON_THUNDER(12837, ScrollTarget.COMBAT, ""Fires a magic attack that lowers the opponent's special attack energy by 10%."", 8.3, 4) { @Override public int attack(Player owner, Familiar familiar, Entity target) { Hit hit = getMagicHit(familiar, getMaxHit(familiar, 140, AttackStyle.MAGE, target)); familiar.sync(7986, 1492); delayHit(familiar, World.sendProjectile(familiar, target, 1493, 34, 16, 30, 35, 16, 0).getTaskDelay(), target, hit, () -> target.spotAnim(1494)); if (hit.getDamage() > 0 && target instanceof Player player) player.getCombatDefinitions().drainSpec((player.getCombatDefinitions().getSpecialAttackPercentage() / 10)); return Familiar.DEFAULT_ATTACK_SPEED; } }, SWAMP_PLAGUE(12832, ScrollTarget.COMBAT, ""Fires a magic attack that hits for up to 110 damage and poisons the target for 78 damage."", 4.1, 6) { @Override public int attack(Player owner, Familiar familiar, Entity target) { familiar.anim(8223); delayHit(familiar, World.sendProjectile(familiar, target, 1462, 34, 16, 30, 35, 16, 0).getTaskDelay(), target, getMagicHit(familiar, getMaxHit(familiar, 110, AttackStyle.MAGE, target)), () -> target.getPoison().makePoisoned(78)); return Familiar.DEFAULT_ATTACK_SPEED; } }, RUNE_BULL(12466, ScrollTarget.COMBAT, ""Fires a magic based attack at the opponent hitting for up to 240 damage."", 8.6, 6) { @Override public int attack(Player owner, Familiar familiar, Entity target) { familiar.sync(8026, 1496); delayHit(familiar, World.sendProjectile(familiar, target, 1497, 34, 16, 30, 35, 16, 0).getTaskDelay(), target, getMagicHit(familiar, getMaxHit(familiar, 240, AttackStyle.MAGE, target))); return Familiar.DEFAULT_ATTACK_SPEED; } }, HEALING_AURA(12434, ScrollTarget.CLICK, ""Heals the player for 15% of their maximum lifepoints."", 1.8, 20) { @Override public boolean use(Player player, Familiar familiar) { if (player.getHitpoints() == player.getMaxHitpoints()) { player.sendMessage(""You're already at full hitpoints!""); return false; } familiar.sync(8267, 1356); player.spotAnim(1300); player.heal((int) ((double) player.getMaxHitpoints() * 0.15)); return true; } }, BOIL(12833, ScrollTarget.COMBAT, ""Boils the target in their armor causing magic damage based on the opponents defense bonuses."", 8.9, 6) { @Override public int attack(Player owner, Familiar familiar, Entity target) { familiar.setNextAnimation(new Animation(7883)); familiar.setNextSpotAnim(new SpotAnim(1373)); if (!familiar.inMeleeRange(target)) { if (Utils.getRandomInclusive(2) == 0) delayHit(familiar, 1, target, getRangeHit(familiar, getMaxHit(familiar, 240, AttackStyle.RANGE, target))); else delayHit(familiar, 1, target, getMagicHit(familiar, getMaxHit(familiar, 240, AttackStyle.MAGE, target))); } else delayHit(familiar, 1, target, getMeleeHit(familiar, getMaxHit(familiar, 240, AttackStyle.MELEE, target))); World.sendProjectile(familiar, target, 1376, 34, 16, 30, 35, 16, 0); return Familiar.DEFAULT_ATTACK_SPEED; } }, MAGIC_FOCUS(12437, ScrollTarget.CLICK, ""Boosts the player's attack level by 7."", 4.6, 20) { @Override public boolean use(Player owner, Familiar familiar) { familiar.sync(8308, 1464); owner.getSkills().adjustStat(7, 0.0, Constants.MAGIC); return true; } }, ESSENCE_SHIPMENT(12827, ScrollTarget.CLICK, ""Sends all carried essence (both in player inventory and familiar inventory) to the bank."", 1.9, 6) { @Override public boolean use(Player owner, Familiar familiar) { if (!owner.getInventory().containsOneItem(1436, 7936) && familiar.getInventory().isEmpty()) { owner.sendMessage(""You have no essence to ship to the bank.""); return false; } if (!owner.getBank().hasBankSpace()) { owner.sendMessage(""Your bank is full!""); return false; } familiar.sync(7698, 1457); owner.getBank().depositAllBob(false); for (int i = 0;i < owner.getInventory().getItemsContainerSize();i++) { Item item = owner.getInventory().getItem(i); if (item == null || (item.getId() != Runecrafting.RUNE_ESS && item.getId() != Runecrafting.PURE_ESS)) continue; owner.getBank().depositItem(i, 1, false); } return true; } }, IRON_WITHIN(12828, ScrollTarget.COMBAT, ""Hits with melee instead of magic for a turn hitting up to 3 times."", 4.7, 12) { @Override public int attack(Player owner, Familiar familiar, Entity target) { familiar.setNextAnimation(new Animation(7954)); familiar.setNextSpotAnim(new SpotAnim(1450)); if (!familiar.inMeleeRange(target)) { delayHit(familiar, 2, target, getMagicHit(familiar, getMaxHit(familiar, 220, AttackStyle.MAGE, target, 2.0))); delayHit(familiar, 2, target, getMagicHit(familiar, getMaxHit(familiar, 220, AttackStyle.MAGE, target, 2.0))); delayHit(familiar, 3, target, getMagicHit(familiar, getMaxHit(familiar, 220, AttackStyle.MAGE, target, 2.0))); } else { delayHit(familiar, 1, target, getMeleeHit(familiar, getMaxHit(familiar, 230, AttackStyle.MELEE, target, 2.0))); delayHit(familiar, 1, target, getMeleeHit(familiar, getMaxHit(familiar, 230, AttackStyle.MELEE, target, 2.0))); delayHit(familiar, 2, target, getMeleeHit(familiar, getMaxHit(familiar, 230, AttackStyle.MELEE, target, 2.0))); } return Familiar.DEFAULT_ATTACK_SPEED; } }, WINTER_STORAGE(12435, ScrollTarget.ITEM, ""Banks the targeted item for the player."", 4.8, 12) { @Override public boolean item(Player owner, Familiar familiar, Item item) { if (!owner.getBank().hasBankSpace()) { owner.sendMessage(""Your bank is full!""); return false; } if (MinigameUtilKt.isMinigameSupply(item.getId())) { owner.sendMessage(""You can't bank that like this.""); return false; } if (!owner.getBank().depositItem(item.getSlot(), 1, true)) return false; familiar.spotAnim(1358); owner.incrementCount(""Items banked with yak""); owner.sendMessage(""Your pack yak has sent an item to your bank."", true); return true; } }, STEEL_OF_LEGENDS(12825, ScrollTarget.COMBAT, ""Attacks the target with four ranged or melee attacks depending on distance dealing very high damage."", 4.9, 12) { @Override public int attack(Player owner, Familiar familiar, Entity target) { familiar.sync(8190, 1449); target.spotAnim(1449); if (familiar.inMeleeRange(target)) { delayHit(familiar, 1, target, getMeleeHit(familiar, getMaxHit(familiar, 244, Bonus.CRUSH_ATT, AttackStyle.MELEE, target, 1.0))); delayHit(familiar, 1, target, getMeleeHit(familiar, getMaxHit(familiar, 244, Bonus.CRUSH_ATT, AttackStyle.MELEE, target, 1.0))); delayHit(familiar, 2, target, getMeleeHit(familiar, getMaxHit(familiar, 244, Bonus.CRUSH_ATT, AttackStyle.MELEE, target, 1.0))); delayHit(familiar, 2, target, getMeleeHit(familiar, getMaxHit(familiar, 244, Bonus.CRUSH_ATT, AttackStyle.MELEE, target, 1.0))); } else { delayHit(familiar, 2, target, getRangeHit(familiar, getMaxHit(familiar, 244, Bonus.RANGE_ATT, AttackStyle.RANGE, target, 1.0))); delayHit(familiar, 2, target, getRangeHit(familiar, getMaxHit(familiar, 244, Bonus.RANGE_ATT, AttackStyle.RANGE, target, 1.0))); delayHit(familiar, 3, target, getRangeHit(familiar, getMaxHit(familiar, 244, Bonus.RANGE_ATT, AttackStyle.RANGE, target, 1.0))); delayHit(familiar, 3, target, getRangeHit(familiar, getMaxHit(familiar, 244, Bonus.RANGE_ATT, AttackStyle.RANGE, target, 1.0))); } return Familiar.DEFAULT_ATTACK_SPEED; } }, GHASTLY_ATTACK(21453, ScrollTarget.CLICK, ""Restores 100 prayer points to the player."", 0.9, 20) { @Override public boolean use(Player owner, Familiar familiar) { familiar.sync(9470, 1336); owner.spotAnim(1308); owner.getPrayer().restorePrayer(100); return true; } }, SUNDERING_STRIKE_1(18027, ScrollTarget.COMBAT, ""Fires a 50% more accurate attack that reduces the target's defense by 1 for every 20 points of damage dealt."", 0.0, 6) { @Override public int attack(Player owner, Familiar familiar, Entity target) { return FamiliarSpecs.sunderingStrike(owner, familiar, target, 1); } }, SUNDERING_STRIKE_2(18028, ScrollTarget.COMBAT, ""Fires a 50% more accurate attack that reduces the target's defense by 2 for every 20 points of damage dealt."", 0.0, 6) { @Override public int attack(Player owner, Familiar familiar, Entity target) { return FamiliarSpecs.sunderingStrike(owner, familiar, target, 2); } }, SUNDERING_STRIKE_3(18029, ScrollTarget.COMBAT, ""Fires a 50% more accurate attack that reduces the target's defense by 3 for every 20 points of damage dealt."", 0.0, 6) { @Override public int attack(Player owner, Familiar familiar, Entity target) { return FamiliarSpecs.sunderingStrike(owner, familiar, target, 3); } }, SUNDERING_STRIKE_4(18030, ScrollTarget.COMBAT, ""Fires a 50% more accurate attack that reduces the target's defense by 4 for every 20 points of damage dealt."", 0.0, 6) { @Override public int attack(Player owner, Familiar familiar, Entity target) { return FamiliarSpecs.sunderingStrike(owner, familiar, target, 4); } }, SUNDERING_STRIKE_5(18031, ScrollTarget.COMBAT, ""Fires a 50% more accurate attack that reduces the target's defense by 5 for every 20 points of damage dealt."", 0.0, 6) { @Override public int attack(Player owner, Familiar familiar, Entity target) { return FamiliarSpecs.sunderingStrike(owner, familiar, target, 5); } }, SUNDERING_STRIKE_6(18032, ScrollTarget.COMBAT, ""Fires a 50% more accurate attack that reduces the target's defense by 6 for every 20 points of damage dealt."", 0.0, 6) { @Override public int attack(Player owner, Familiar familiar, Entity target) { return FamiliarSpecs.sunderingStrike(owner, familiar, target, 6); } }, SUNDERING_STRIKE_7(18033, ScrollTarget.COMBAT, ""Fires a 50% more accurate attack that reduces the target's defense by 7 for every 20 points of damage dealt."", 0.0, 6) { @Override public int attack(Player owner, Familiar familiar, Entity target) { return FamiliarSpecs.sunderingStrike(owner, familiar, target, 7); } }, SUNDERING_STRIKE_8(18034, ScrollTarget.COMBAT, ""Fires a 50% more accurate attack that reduces the target's defense by 8 for every 20 points of damage dealt."", 0.0, 6) { @Override public int attack(Player owner, Familiar familiar, Entity target) { return FamiliarSpecs.sunderingStrike(owner, familiar, target, 8); } }, SUNDERING_STRIKE_9(18035, ScrollTarget.COMBAT, ""Fires a 50% more accurate attack that reduces the target's defense by 9 for every 20 points of damage dealt."", 0.0, 6) { @Override public int attack(Player owner, Familiar familiar, Entity target) { return FamiliarSpecs.sunderingStrike(owner, familiar, target, 9); } }, SUNDERING_STRIKE_10(18036, ScrollTarget.COMBAT, ""Fires a 50% more accurate attack that reduces the target's defense by 10 for every 20 points of damage dealt."", 0.0, 6) { @Override public int attack(Player owner, Familiar familiar, Entity target) { return FamiliarSpecs.sunderingStrike(owner, familiar, target, 10); } }, POISONOUS_SHOT_1(18037, ScrollTarget.COMBAT, ""Fires a 50% more accurate attack that poisons the target for 18 damage."", 0.0, 6) { @Override public int attack(Player owner, Familiar familiar, Entity target) { return FamiliarSpecs.poisonousShot(owner, familiar, target, 1); } }, POISONOUS_SHOT_2(18038, ScrollTarget.COMBAT, ""Fires a 50% more accurate attack that poisons the target for 28 damage."", 0.0, 6) { @Override public int attack(Player owner, Familiar familiar, Entity target) { return FamiliarSpecs.poisonousShot(owner, familiar, target, 2); } }, POISONOUS_SHOT_3(18039, ScrollTarget.COMBAT, ""Fires a 50% more accurate attack that poisons the target for 38 damage."", 0.0, 6) { @Override public int attack(Player owner, Familiar familiar, Entity target) { return FamiliarSpecs.poisonousShot(owner, familiar, target, 3); } }, POISONOUS_SHOT_4(18040, ScrollTarget.COMBAT, ""Fires a 50% more accurate attack that poisons the target for 48 damage."", 0.0, 6) { @Override public int attack(Player owner, Familiar familiar, Entity target) { return FamiliarSpecs.poisonousShot(owner, familiar, target, 4); } }, POISONOUS_SHOT_5(18041, ScrollTarget.COMBAT, ""Fires a 50% more accurate attack that poisons the target for 58 damage."", 0.0, 6) { @Override public int attack(Player owner, Familiar familiar, Entity target) { return FamiliarSpecs.poisonousShot(owner, familiar, target, 5); } }, POISONOUS_SHOT_6(18042, ScrollTarget.COMBAT, ""Fires a 50% more accurate attack that poisons the target for 68 damage."", 0.0, 6) { @Override public int attack(Player owner, Familiar familiar, Entity target) { return FamiliarSpecs.poisonousShot(owner, familiar, target, 6); } }, POISONOUS_SHOT_7(18043, ScrollTarget.COMBAT, ""Fires a 50% more accurate attack that poisons the target for 78 damage."", 0.0, 6) { @Override public int attack(Player owner, Familiar familiar, Entity target) { return FamiliarSpecs.poisonousShot(owner, familiar, target, 7); } }, POISONOUS_SHOT_8(18044, ScrollTarget.COMBAT, ""Fires a 50% more accurate attack that poisons the target for 88 damage."", 0.0, 6) { @Override public int attack(Player owner, Familiar familiar, Entity target) { return FamiliarSpecs.poisonousShot(owner, familiar, target, 8); } }, POISONOUS_SHOT_9(18045, ScrollTarget.COMBAT, ""Fires a 50% more accurate attack that poisons the target for 98 damage."", 0.0, 6) { @Override public int attack(Player owner, Familiar familiar, Entity target) { return FamiliarSpecs.poisonousShot(owner, familiar, target, 9); } }, POISONOUS_SHOT_10(18046, ScrollTarget.COMBAT, ""Fires a 50% more accurate attack that poisons the target for 108 damage."", 0.0, 6) { @Override public int attack(Player owner, Familiar familiar, Entity target) { return FamiliarSpecs.poisonousShot(owner, familiar, target, 10); } }, SNARING_WAVE_1(18047, ScrollTarget.COMBAT, ""Fires a 50% more accurate attack that snares the opponent."", 0.0, 6) { @Override public int attack(Player owner, Familiar familiar, Entity target) { return FamiliarSpecs.snaringWave(owner, familiar, target, 1); } }, SNARING_WAVE_2(18048, ScrollTarget.COMBAT, ""Fires a 50% more accurate attack that snares the opponent."", 0.0, 6) { @Override public int attack(Player owner, Familiar familiar, Entity target) { return FamiliarSpecs.snaringWave(owner, familiar, target, 2); } }, SNARING_WAVE_3(18049, ScrollTarget.COMBAT, ""Fires a 50% more accurate attack that snares the opponent."", 0.0, 6) { @Override public int attack(Player owner, Familiar familiar, Entity target) { return FamiliarSpecs.snaringWave(owner, familiar, target, 3); } }, SNARING_WAVE_4(18050, ScrollTarget.COMBAT, ""Fires a 50% more accurate attack that snares the opponent."", 0.0, 6) { @Override public int attack(Player owner, Familiar familiar, Entity target) { return FamiliarSpecs.snaringWave(owner, familiar, target, 4); } }, SNARING_WAVE_5(18051, ScrollTarget.COMBAT, ""Fires a 50% more accurate attack that snares the opponent."", 0.0, 6) { @Override public int attack(Player owner, Familiar familiar, Entity target) { return FamiliarSpecs.snaringWave(owner, familiar, target, 5); } }, SNARING_WAVE_6(18052, ScrollTarget.COMBAT, ""Fires a 50% more accurate attack that snares the opponent."", 0.0, 6) { @Override public int attack(Player owner, Familiar familiar, Entity target) { return FamiliarSpecs.snaringWave(owner, familiar, target, 6); } }, SNARING_WAVE_7(18053, ScrollTarget.COMBAT, ""Fires a 50% more accurate attack that snares the opponent."", 0.0, 6) { @Override public int attack(Player owner, Familiar familiar, Entity target) { return FamiliarSpecs.snaringWave(owner, familiar, target, 7); } }, SNARING_WAVE_8(18054, ScrollTarget.COMBAT, ""Fires a 50% more accurate attack that snares the opponent."", 0.0, 6) { @Override public int attack(Player owner, Familiar familiar, Entity target) { return FamiliarSpecs.snaringWave(owner, familiar, target, 8); } }, SNARING_WAVE_9(18055, ScrollTarget.COMBAT, ""Fires a 50% more accurate attack that snares the opponent."", 0.0, 6) { @Override public int attack(Player owner, Familiar familiar, Entity target) { return FamiliarSpecs.snaringWave(owner, familiar, target, 9); } }, SNARING_WAVE_10(18056, ScrollTarget.COMBAT, ""Fires a 50% more accurate attack that snares the opponent."", 0.0, 6) { @Override public int attack(Player owner, Familiar familiar, Entity target) { return FamiliarSpecs.snaringWave(owner, familiar, target, 10); } }, APTITUDE_1(18057, ScrollTarget.CLICK, ""Invisibly boosts all skills by 1."", 0.0, 6) { @Override public boolean use(Player owner, Familiar familiar) { return FamiliarSpecs.aptitude(owner, familiar, 1); } }, APTITUDE_2(18058, ScrollTarget.CLICK, ""Invisibly boosts all skills by 2."", 0.0, 6) { @Override public boolean use(Player owner, Familiar familiar) { return FamiliarSpecs.aptitude(owner, familiar, 2); } }, APTITUDE_3(18059, ScrollTarget.CLICK, ""Invisibly boosts all skills by 3."", 0.0, 6) { @Override public boolean use(Player owner, Familiar familiar) { return FamiliarSpecs.aptitude(owner, familiar, 3); } }, APTITUDE_4(18060, ScrollTarget.CLICK, ""Invisibly boosts all skills by 4."", 0.0, 6) { @Override public boolean use(Player owner, Familiar familiar) { return FamiliarSpecs.aptitude(owner, familiar, 4); } }, APTITUDE_5(18061, ScrollTarget.CLICK, ""Invisibly boosts all skills by 5."", 0.0, 6) { @Override public boolean use(Player owner, Familiar familiar) { return FamiliarSpecs.aptitude(owner, familiar, 5); } }, APTITUDE_6(18062, ScrollTarget.CLICK, ""Invisibly boosts all skills by 6."", 0.0, 6) { @Override public boolean use(Player owner, Familiar familiar) { return FamiliarSpecs.aptitude(owner, familiar, 6); } }, APTITUDE_7(18063, ScrollTarget.CLICK, ""Invisibly boosts all skills by 7."", 0.0, 6) { @Override public boolean use(Player owner, Familiar familiar) { return FamiliarSpecs.aptitude(owner, familiar, 7); } }, APTITUDE_8(18064, ScrollTarget.CLICK, ""Invisibly boosts all skills by 8."", 0.0, 6) { @Override public boolean use(Player owner, Familiar familiar) { return FamiliarSpecs.aptitude(owner, familiar, 8); } }, APTITUDE_9(18065, ScrollTarget.CLICK, ""Invisibly boosts all skills by 9."", 0.0, 6) { @Override public boolean use(Player owner, Familiar familiar) { return FamiliarSpecs.aptitude(owner, familiar, 9); } }, APTITUDE_10(18066, ScrollTarget.CLICK, ""Invisibly boosts all skills by 10."", 0.0, 6) { @Override public boolean use(Player owner, Familiar familiar) { return FamiliarSpecs.aptitude(owner, familiar, 10); } }, SECOND_WIND_1(18067, ScrollTarget.CLICK, ""Restores 20% of the player's run energy."", 0.0, 6) { @Override public boolean use(Player owner, Familiar familiar) { return FamiliarSpecs.secondWind(owner, familiar, 20); } }, SECOND_WIND_2(18068, ScrollTarget.CLICK, ""Restores 22% of the player's run energy."", 0.0, 6) { @Override public boolean use(Player owner, Familiar familiar) { return FamiliarSpecs.secondWind(owner, familiar, 22); } }, SECOND_WIND_3(18069, ScrollTarget.CLICK, ""Restores 24% of the player's run energy."", 0.0, 6) { @Override public boolean use(Player owner, Familiar familiar) { return FamiliarSpecs.secondWind(owner, familiar, 24); } }, SECOND_WIND_4(18070, ScrollTarget.CLICK, ""Restores 26% of the player's run energy."", 0.0, 6) { @Override public boolean use(Player owner, Familiar familiar) { return FamiliarSpecs.secondWind(owner, familiar, 26); } }, SECOND_WIND_5(18071, ScrollTarget.CLICK, ""Restores 28% of the player's run energy."", 0.0, 6) { @Override public boolean use(Player owner, Familiar familiar) { return FamiliarSpecs.secondWind(owner, familiar, 28); } }, SECOND_WIND_6(18072, ScrollTarget.CLICK, ""Restores 30% of the player's run energy."", 0.0, 6) { @Override public boolean use(Player owner, Familiar familiar) { return FamiliarSpecs.secondWind(owner, familiar, 30); } }, SECOND_WIND_7(18073, ScrollTarget.CLICK, ""Restores 32% of the player's run energy."", 0.0, 6) { @Override public boolean use(Player owner, Familiar familiar) { return FamiliarSpecs.secondWind(owner, familiar, 32); } }, SECOND_WIND_8(18074, ScrollTarget.CLICK, ""Restores 34% of the player's run energy."", 0.0, 6) { @Override public boolean use(Player owner, Familiar familiar) { return FamiliarSpecs.secondWind(owner, familiar, 34); } }, SECOND_WIND_9(18075, ScrollTarget.CLICK, ""Restores 36% of the player's run energy."", 0.0, 6) { @Override public boolean use(Player owner, Familiar familiar) { return FamiliarSpecs.secondWind(owner, familiar, 36); } }, SECOND_WIND_10(18076, ScrollTarget.CLICK, ""Restores 38% of the player's run energy."", 0.0, 6) { @Override public boolean use(Player owner, Familiar familiar) { return FamiliarSpecs.secondWind(owner, familiar, 38); } }, GLIMMER_OF_LIGHT_1(18077, ScrollTarget.CLICK, ""Heals the player for 20 hitpoints."", 0.0, 6) { @Override public boolean use(Player owner, Familiar familiar) { return FamiliarSpecs.glimmer(owner, familiar, 20); } }, GLIMMER_OF_LIGHT_2(18078, ScrollTarget.CLICK, ""Heals the player for 40 hitpoints."", 0.0, 6) { @Override public boolean use(Player owner, Familiar familiar) { return FamiliarSpecs.glimmer(owner, familiar, 40); } }, GLIMMER_OF_LIGHT_3(18079, ScrollTarget.CLICK, ""Heals the player for 60 hitpoints."", 0.0, 6) { @Override public boolean use(Player owner, Familiar familiar) { return FamiliarSpecs.glimmer(owner, familiar, 60); } }, GLIMMER_OF_LIGHT_4(18080, ScrollTarget.CLICK, ""Heals the player for 80 hitpoints."", 0.0, 6) { @Override public boolean use(Player owner, Familiar familiar) { return FamiliarSpecs.glimmer(owner, familiar, 80); } }, GLIMMER_OF_LIGHT_5(18081, ScrollTarget.CLICK, ""Heals the player for 100 hitpoints."", 0.0, 6) { @Override public boolean use(Player owner, Familiar familiar) { return FamiliarSpecs.glimmer(owner, familiar, 100); } }, GLIMMER_OF_LIGHT_6(18082, ScrollTarget.CLICK, ""Heals the player for 120 hitpoints."", 0.0, 6) { @Override public boolean use(Player owner, Familiar familiar) { return FamiliarSpecs.glimmer(owner, familiar, 120); } }, GLIMMER_OF_LIGHT_7(18083, ScrollTarget.CLICK, ""Heals the player for 140 hitpoints."", 0.0, 6) { @Override public boolean use(Player owner, Familiar familiar) { return FamiliarSpecs.glimmer(owner, familiar, 140); } }, GLIMMER_OF_LIGHT_8(18084, ScrollTarget.CLICK, ""Heals the player for 160 hitpoints."", 0.0, 6) { @Override public boolean use(Player owner, Familiar familiar) { return FamiliarSpecs.glimmer(owner, familiar, 160); } }, GLIMMER_OF_LIGHT_9(18085, ScrollTarget.CLICK, ""Heals the player for 180 hitpoints."", 0.0, 6) { @Override public boolean use(Player owner, Familiar familiar) { return FamiliarSpecs.glimmer(owner, familiar, 180); } }, GLIMMER_OF_LIGHT_10(18086, ScrollTarget.CLICK, ""Heals the player for 200 hitpoints."", 0.0, 6) { @Override public boolean use(Player owner, Familiar familiar) { return FamiliarSpecs.glimmer(owner, familiar, 200); } }, CLAY_DEPOSIT(14421, ScrollTarget.CLICK, ""Sends all held clay back to the base."", 0.0, 12) { @Override public boolean use(Player owner, Familiar familiar) { if (owner.getControllerManager().getController() == null || !(owner.getControllerManager().getController() instanceof StealingCreationController sc)) { familiar.dismiss(); return false; } Score score = sc.getGame().getScore(owner); if (score == null) return false; for (Item item : familiar.getInventory().array()) { if (item == null) continue; sc.getGame().sendItemToBase(owner, item, sc.getTeam(), true, false); } return true; } }; private static final Map MAP = new HashMap<>(); static { for (Scroll s : Scroll.values()) MAP.put(s.id, s); } private final ScrollTarget target; private final String name; private final String description; private final int id; private final double xp; private final int pointCost; private List fromPouches; private Scroll(int scrollId, ScrollTarget target, String description, double xp, int pointCost) { this.name = Utils.formatPlayerNameForDisplay(ItemDefinitions.getDefs(scrollId).name.replace("" scroll"", """")); this.description = description; this.target = target; this.id = scrollId; this.xp = xp; this.pointCost = pointCost; } public String getName() { return name; } public String getDescription() { return description; } public ScrollTarget getTarget() { return target; } public double getExperience() { return getXp(); } public int getPointCost() { return pointCost; } public List fromPouches() { if (fromPouches == null) { for (Pouch p : Pouch.values()) { if (p.getScroll() == this) } } return fromPouches; } public boolean use(Player owner, Familiar familiar) { owner.sendMessage(""Scroll is not implemented for click targets.""); return false; } public int attack(Player owner, Familiar familiar, Entity target) { return -1; } public boolean entity(Player owner, Familiar familiar, Entity target) { return true; } public boolean onCombatActivation(Player owner, Familiar familiar, Entity target) { return true; } public boolean item(Player owner, Familiar familiar, Item item) { owner.sendMessage(""Scroll is not implemented for item targets.""); return false; } public boolean object(Player owner, Familiar familiar, GameObject object) { owner.sendMessage(""Scroll is not implemented for object targets.""); return false; } public int getId() { return id; } public double getXp() { return xp; } public static Scroll forId(int id) { return MAP.get(id); } }" "package com.rs.game.content.skills.summoning; @PluginEventHandler public class Summoning { public static enum ScrollTarget { ITEM, COMBAT, CLICK, OBJECT, ENTITY } public static final int POUCHES_INTERFACE = 672, SCROLLS_INTERFACE = 666; private static final int SCROLL_ANIM = 723; private static final int POUCH_ANIM = 725; private static final int POUCH_SPOTANIM = 1207; public static boolean isFamiliar(int npcId) { return EnumDefinitions.getEnum(1320).getValues().containsValue(npcId); } public static boolean isFollower(int npcId) { return EnumDefinitions.getEnum(1279).getValues().containsKey((long) npcId); } public static ItemOnItemHandler handleCarveTurnip = new ItemOnItemHandler(946, 12134, e -> e.getPlayer().repeatAction(2, count -> { if (!e.getPlayer().getInventory().containsItem(946, 1)) { e.getPlayer().sendMessage(""You need a knife to cut the turnip.""); return false; } if (!e.getPlayer().getInventory().containsItem(12134)) return false; e.getPlayer().getInventory().deleteItem(12134, 1); e.getPlayer().getInventory().addItem(12153, 1); e.getPlayer().anim(6702); return true; })); public static ItemClickHandler handleSummonOps = new ItemClickHandler(Arrays.stream(Pouch.values()).map(Pouch::getId).toArray(), new String[] { ""Summon"" }, e -> { Pouch pouches = Pouch.forId(e.getItem().getId()); if (pouches != null) { if (e.getPlayer().getSkills().getLevelForXp(Constants.SUMMONING) >= pouches.getLevel()) spawnFamiliar(e.getPlayer(), pouches); else e.getPlayer().sendMessage(""You need a summoning level of "" + pouches.getLevel() + "" to summon this familiar.""); } }); public static InterfaceOnPlayerHandler scrollOnPlayer = new InterfaceOnPlayerHandler(false, new int[] { 662, 747 }, e -> { if (e.getPlayer().getFamiliar() == null) return; e.getPlayer().stopAll(false, true, false); if ((e.getInterfaceId() == 747 && e.getComponentId() == 15) || (e.getInterfaceId() == 662 && e.getComponentId() == 65) || e.getInterfaceId() == 747 && e.getComponentId() == 24) e.getPlayer().getFamiliar().commandAttack(e.getTarget()); if ((e.getInterfaceId() == 662 && e.getComponentId() == 74) || (e.getInterfaceId() == 747 && e.getComponentId() == 18)) e.getPlayer().getFamiliar().executeSpecial(e.getTarget()); }); public static InterfaceOnNPCHandler scrollOnNPC = new InterfaceOnNPCHandler(false, new int[] { 662, 747 }, e -> { if (e.getPlayer().getFamiliar() == null) return; e.getPlayer().stopAll(false, true, false); if ((e.getInterfaceId() == 747 && e.getComponentId() == 15) || (e.getInterfaceId() == 662 && e.getComponentId() == 65) || e.getInterfaceId() == 747 && e.getComponentId() == 24) e.getPlayer().getFamiliar().commandAttack(e.getTarget()); if ((e.getInterfaceId() == 662 && e.getComponentId() == 74) || (e.getInterfaceId() == 747 && e.getComponentId() == 18)) e.getPlayer().getFamiliar().executeSpecial(e.getTarget()); }); private static void spawnFamiliar(Player player, Pouch pouch) { if (player.getFamiliar() != null || player.getPet() != null) { player.sendMessage(""You already have a follower.""); return; } if (!player.getControllerManager().canSummonFamiliar()) return; if (player.getSkills().getLevel(Constants.SUMMONING) < pouch.getSummoningCost()) { player.sendMessage(""You do not have enough summoning points to spawn this.""); return; } if (player.getSkills().getLevelForXp(Constants.SUMMONING) < pouch.getLevel()) { player.sendMessage(""You need a summoning level of "" + pouch.getLevel() + "" in order to use this pouch.""); return; } Tile spawnTile = player.getNearestTeleTile(NPCDefinitions.getDefs(pouch.getBaseNpc(), player.getVars()).size); if (spawnTile == null) { player.sendMessage(""Theres not enough space to summon your familiar here.""); return; } player.getInventory().deleteItem(pouch.getId(), 1); player.getSkills().drainSummoning(pouch.getSummoningCost()); player.setFamiliar(new Familiar(player, pouch, spawnTile, -1, true)); player.getFamiliar().sendFollowerDetails(); } public static boolean hasPouch(Player player) { for (Pouch pouch : Pouch.values()) if (player.getInventory().containsOneItem(pouch.getId())) return true; return false; } public static void openInfusionInterface(Player player, boolean dung) { player.getInterfaceManager().sendInterface(POUCHES_INTERFACE); player.getPackets().sendPouchInfusionOptionsScript(dung, POUCHES_INTERFACE, 16, 78, 8, 10, ""Infuse"", ""Infuse-5"", ""Infuse-10"", ""Infuse-X"", ""Infuse-All"", ""List""); player.getPackets().setIFEvents(new IFEvents(POUCHES_INTERFACE, 16, 0, 462).enableRightClickOptions(0,1,2,3,4,6)); } //1182 = real pouch list public static int forSlotId(int slotId, boolean dung) { EnumDefinitions realDef = EnumDefinitions.getEnum(1182); return realDef.getIntValue(((slotId-2)/5)+(dung ? 1100 : 1)); } public static ButtonClickHandler handleDungeoneeringPouchButtons = new ButtonClickHandler(672, e -> { if (e.getComponentId() == 16) { Pouch pouch = Pouch.forId(e.getSlotId2()); if (pouch == null) { if(e.getPlayer().getControllerManager().isIn(DungeonController.class)) e.getPlayer().sendMessage(""You need "" + getMaterialListString(Pouch.forId(forSlotId(e.getSlotId(), true))) + "" to create this pouch.""); else e.getPlayer().sendMessage(""You need "" + getMaterialListString(Pouch.forId(forSlotId(e.getSlotId(), false))) + "" to create this pouch.""); return; } if (e.getPacket() == ClientPacket.IF_OP1) handlePouchInfusion(e.getPlayer(), pouch, 1); else if (e.getPacket() == ClientPacket.IF_OP2) handlePouchInfusion(e.getPlayer(), pouch, 5); else if (e.getPacket() == ClientPacket.IF_OP3) handlePouchInfusion(e.getPlayer(), pouch, 10); else if (e.getPacket() == ClientPacket.IF_OP4) handlePouchInfusion(e.getPlayer(), pouch, Integer.MAX_VALUE); else if (e.getPacket() == ClientPacket.IF_OP5) handlePouchInfusion(e.getPlayer(), pouch, 28); else if (e.getPacket() == ClientPacket.IF_OP7) e.getPlayer().sendMessage(""You need "" + getMaterialListString(pouch) + "" to create this pouch.""); } else if (e.getComponentId() == 19 && e.getPacket() == ClientPacket.IF_OP1) openScrollInfusionInterface(e.getPlayer(), e.getPlayer().getControllerManager().isIn(DungeonController.class)); }); public static void openScrollInfusionInterface(Player player, boolean dung) { player.getInterfaceManager().sendInterface(SCROLLS_INTERFACE); player.getPackets().sendScrollInfusionOptionsScript(dung, SCROLLS_INTERFACE, 16, 78, 8, 10, ""Transform"", ""Transform-5"", ""Transform-10"", ""Transform-All"", ""Transform-X""); player.getPackets().setIFEvents(new IFEvents(SCROLLS_INTERFACE, 16, 0, 462).enableRightClickOptions(0,1,2,3,4,5)); } public static ButtonClickHandler handleScrollButtons = new ButtonClickHandler(666, e -> { if (e.getComponentId() == 16) { if (e.getPacket() == ClientPacket.IF_OP1) createScroll(e.getPlayer(), e.getSlotId2(), 1); else if (e.getPacket() == ClientPacket.IF_OP2) createScroll(e.getPlayer(), e.getSlotId2(), 5); else if (e.getPacket() == ClientPacket.IF_OP3) createScroll(e.getPlayer(), e.getSlotId2(), 10); else if (e.getPacket() == ClientPacket.IF_OP4) createScroll(e.getPlayer(), e.getSlotId2(), Integer.MAX_VALUE); } else if (e.getComponentId() == 18 && e.getPacket() == ClientPacket.IF_OP1) openInfusionInterface(e.getPlayer(), e.getPlayer().getControllerManager().isIn(DungeonController.class)); }); public static void createScroll(Player player, int itemId, int amount) { Scroll scroll = Scroll.forId(itemId); if (scroll == null) { player.sendMessage(""You do not have the pouch required to create this scroll.""); return; } if (player.getSkills().getLevelForXp(Constants.SUMMONING) < scroll.fromPouches().getFirst().getLevel()) { player.sendMessage(""You need a summoning level of "" + scroll.fromPouches().getFirst().getLevel() + "" to create "" + amount + "" "" + ItemDefinitions.getDefs(scroll.getId()).getName().toLowerCase() + ""s.""); return; } boolean hasReqs = false; for (Pouch pouch : scroll.fromPouches()) { if (player.getInventory().containsItem(pouch.getId())) hasReqs = true; } if (!hasReqs) { player.sendMessage(""You do not have the pouch required to create this scroll.""); return; } for (int i = 0;i < amount;i++) { Pouch pouch = null; for (Pouch p : scroll.fromPouches()) { if (player.getInventory().containsItem(p.getId())) { pouch = p; break; } } if (pouch == null) break; player.getInventory().deleteItem(pouch.getId(), 1); player.getInventory().addItem(pouch.getScroll().getId(), 10); player.getSkills().addXp(Constants.SUMMONING, pouch.getScroll().getXp()); } player.anim(SCROLL_ANIM); } public static void handlePouchInfusion(Player player, Pouch pouch, int creationCount) { if (ItemConstants.isDungItem(pouch.getId()) && !player.getControllerManager().isIn(DungeonController.class)) return; if (!ItemConstants.isDungItem(pouch.getId()) && player.getControllerManager().isIn(DungeonController.class)) return; Item[] itemReq = pouch.getMaterialList().get(); for (int i = 0; i < creationCount; i++) { if (!player.getInventory().containsItems(itemReq)) { player.sendMessage(""You need "" + getMaterialListString(pouch) + "" to create this pouch.""); return; } if (player.getSkills().getLevelForXp(Constants.SUMMONING) < pouch.getLevel()) { player.sendMessage(""You need a summoning level of "" + pouch.getLevel() + "" to create this pouch.""); return; } player.getInventory().removeItems(itemReq); player.getInventory().addItem(new Item(pouch.getId(), 1)); player.getSkills().addXp(Constants.SUMMONING, pouch.getExperience()); } player.sync(POUCH_ANIM, POUCH_SPOTANIM); } public static String getMaterialListString(Pouch pouch) { StringBuilder list = new StringBuilder(); if (pouch == null) return ""nothing""; Item[] items = pouch.getMaterialList().get(); for (int i = 0;i < items.length;i++) list.append(items[i].getAmount()).append("" "").append(items[i].getDefinitions().name.toLowerCase()).append((i == items.length - 1) ? """" : "", ""); return list.toString(); } }" "package com.rs.game.content.skills.summoning.combat; public class FamiliarCombatScript extends CombatScript { protected static final int CANCEL = -50239; @Override public Object[] getKeys() { return Arrays.stream(Pouch.values()).map(p -> NPCDefinitions.getDefs(p.getBaseNpc()).getName()).toArray(); } @Override public final int attack(NPC npc, Entity target) { if (npc instanceof Familiar familiar) { if (familiar.autoScrollMod > 0 && (familiar.attackIndex++ % familiar.autoScrollMod) == 0 && familiar.getSpecialEnergy() >= familiar.getSpecCost()) familiar.setSpecActive(true); int spec = familiar.castCombatSpecial(target); if (spec != Familiar.CANCEL_SPECIAL) return spec; } int alt = alternateAttack(npc, target); if (alt != CANCEL) return alt; return autoAttack(npc, target); } public int alternateAttack(NPC npc, Entity target) { return CANCEL; } public final int autoAttack(NPC npc, Entity target) { NPCCombatDefinitions defs = npc.getCombatDefinitions(); AttackStyle attackStyle = defs.getAttackStyle(); if (attackStyle == AttackStyle.MELEE) delayHit(npc, 0, target, getMeleeHit(npc, getMaxHit(npc, npc.getMaxHit(), attackStyle, target))); else { int damage = getMaxHit(npc, npc.getMaxHit(), attackStyle, target); WorldProjectile p = World.sendProjectile(npc, target, defs.getAttackProjectile(), 32, 32, 50, 2, 2, 0); delayHit(npc, p.getTaskDelay(), target, attackStyle == AttackStyle.RANGE ? getRangeHit(npc, damage) : getMagicHit(npc, damage)); } if (defs.getAttackGfx() != -1) npc.setNextSpotAnim(new SpotAnim(defs.getAttackGfx())); npc.setNextAnimation(new Animation(defs.getAttackEmote())); return npc.getAttackSpeed(); } }" "package com.rs.game.content.skills.summoning.combat.impl; public class AbyssalTitan extends FamiliarCombatScript { @Override public Object[] getKeys() { return Pouch.ABYSSAL_TITAN.getIdKeys(); } @Override public int alternateAttack(final NPC npc, final Entity target) { npc.setNextAnimation(new Animation(7693)); Hit hit = getMeleeHit(npc, getMaxHit(npc, 220, AttackStyle.MELEE, target)); delayHit(npc, 0, target, getMeleeHit(npc, getMaxHit(npc, 220, AttackStyle.MELEE, target))); if (target instanceof Player player) if (hit.getDamage() > 0 && player.getPrayer().getPoints() > 0) player.getPrayer().drainPrayer((double) hit.getDamage() / 2); return npc.getAttackSpeed(); } }" "package com.rs.game.content.skills.summoning.combat.impl; @PluginEventHandler public class BarkerToad extends FamiliarCombatScript { public static ItemOnNPCHandler load = new ItemOnNPCHandler(Pouch.BARKER_TOAD.getIdKeys(), e -> { if (e.getItem().getId() != 2) { e.getPlayer().sendMessage(""You can only load the toad with cannonballs.""); return; } if (e.getNPC() instanceof Familiar f) { if (f.getAttribs().getB(""storedCannonball"")) { e.getPlayer().sendMessage(""The toad already has a cannonball stored in it.""); return; } f.getAttribs().setB(""storedCannonball"", true); e.getPlayer().getInventory().deleteItem(2, 1); f.sync(7704, 1400); } }); @Override public Object[] getKeys() { return Pouch.BARKER_TOAD.getIdKeys(); } @Override public int alternateAttack(final NPC npc, final Entity target) { if (!(npc instanceof Familiar f) || !f.getAttribs().getB(""storedCannonball"")) return CANCEL; shootCannonball(f, target); return f.getAttackSpeed(); } public static void shootCannonball(Familiar f, Entity target) { f.getAttribs().removeB(""storedCannonball""); f.sync(7703, 1401); delayHit(f, 1, target, PlayerCombatKt.calculateHit(f.getOwner(), target, 0, 300, f.getOwner().getEquipment().getWeaponId(), f.getOwner().getCombatDefinitions().getAttackStyle(), PlayerCombatKt.isRanging(f.getOwner()), true, 1.0)).setSource(f); World.sendProjectile(f, target, 1402, 10, 16, 30, 1.5, 16, 0); } }" "package com.rs.game.content.skills.summoning.combat.impl; public class Dreadfowl extends FamiliarCombatScript { @Override public Object[] getKeys() { return Pouch.DREADFOWL.getIdKeys(); } @Override public int alternateAttack(final NPC npc, final Entity target) { if (Utils.getRandomInclusive(10) != 0) return CANCEL; npc.setNextAnimation(new Animation(7810)); npc.setNextSpotAnim(new SpotAnim(1523)); delayHit(npc, 1, target, getMagicHit(npc, getMaxHit(npc, 30, AttackStyle.MAGE, target))); World.sendProjectile(npc, target, 1318, 34, 16, 30, 35, 16, 0); return npc.getAttackSpeed(); } }" "package com.rs.game.content.skills.summoning.combat.impl; public class ForgeRegent extends FamiliarCombatScript { @Override public Object[] getKeys() { return Pouch.FORGE_REGENT.getIdKeys(); } @Override public int alternateAttack(final NPC npc, final Entity target) { if (npc.inMeleeRange(target)) { npc.setNextAnimation(new Animation(7863)); delayHit(npc, 0, target, getMeleeHit(npc, getMaxHit(npc, npc.getCombatDefinitions().getMaxHit(), AttackStyle.MELEE, target))); } else { npc.anim(7866); delayHit(npc, World.sendProjectile(npc, target, 1330, 34, 16, 30, 1.8, 16, 0).getTaskDelay(), target, getMagicHit(npc, getMaxHit(npc, npc.getCombatDefinitions().getMaxHit(), AttackStyle.MAGE, target))); } return npc.getAttackSpeed(); } }" "package com.rs.game.content.skills.summoning.combat.impl; public class GeyserTitan extends FamiliarCombatScript { @Override public Object[] getKeys() { return Pouch.GEYSER_TITAN.getIdKeys(); } @Override public int alternateAttack(final NPC npc, final Entity target) { if (npc.inMeleeRange(target)) { npc.setNextAnimation(new Animation(7879)); delayHit(npc, 0, target, getMeleeHit(npc, getMaxHit(npc, 190, AttackStyle.MELEE, target))); } else { npc.setNextAnimation(new Animation(7883)); npc.setNextSpotAnim(new SpotAnim(1375)); delayHit(npc, World.sendProjectile(npc, target, 1374, 34, 16, 30, 35, 16, 0).getTaskDelay(), target, getRangeHit(npc, getMaxHit(npc, 190, AttackStyle.RANGE, target))); } return npc.getAttackSpeed(); } }" "package com.rs.game.content.skills.summoning.combat.impl; public class HoneyBadger extends FamiliarCombatScript { @Override public Object[] getKeys() { return Pouch.HONEY_BADGER.getIdKeys(); } @Override public int alternateAttack(final NPC npc, final Entity target) { if (!(npc instanceof Familiar fam)) return CANCEL; if (fam.getAttribs().getL(""insaneFerocity"") > World.getServerTicks() || Utils.getRandomInclusive(2) != 0) return CANCEL; npc.sync(7930, 1397); delayHit(npc, 0, target, getMeleeHit(npc, getMaxHit(npc, npc.getCombatDefinitions().getMaxHit(), AttackStyle.MELEE, target))); delayHit(npc, 1, target, getMeleeHit(npc, getMaxHit(npc, npc.getCombatDefinitions().getMaxHit(), AttackStyle.MELEE, target))); return npc.getAttackSpeed(); } }" "package com.rs.game.content.skills.summoning.combat.impl; public class Hydra extends FamiliarCombatScript { @Override public Object[] getKeys() { return Pouch.HYDRA.getIdKeys(); } @Override public int alternateAttack(final NPC npc, final Entity target) { if (Utils.random(2) != 0) return CANCEL; npc.anim(npc.getCombatDefinitions().getAttackEmote()); delayHit(npc, World.sendProjectile(npc, target, 1489, 34, 16, 30, 1.8, 16, 0).getTaskDelay(), target, getMagicHit(npc, getMaxHit(npc, npc.getCombatDefinitions().getMaxHit(), AttackStyle.MAGE, target))); return npc.getAttackSpeed(); } }" "package com.rs.game.content.skills.summoning.combat.impl; public class IronTitan extends FamiliarCombatScript { @Override public Object[] getKeys() { return Pouch.IRON_TITAN.getIdKeys(); } @Override public int alternateAttack(final NPC npc, final Entity target) { if (Utils.random(5) != 0) return CANCEL; npc.sync(7694, 1452); delayHit(npc, World.sendProjectile(npc, target, 1454, 34, 16, 30, 2.0, 16, 0).getTaskDelay(), target, getMagicHit(npc, getMaxHit(npc, 255, AttackStyle.MAGE, target))); return npc.getAttackSpeed(); } }" "package com.rs.game.content.skills.summoning.combat.impl; public class KaramthuluOverlord extends FamiliarCombatScript { @Override public Object[] getKeys() { return Pouch.KARAMTHULU_OVERLORD.getIdKeys(); } @Override public int alternateAttack(final NPC npc, final Entity target) { if (npc.inMeleeRange(target)) { npc.setNextAnimation(new Animation(7963)); delayHit(npc, 0, target, getMeleeHit(npc, getMaxHit(npc, npc.getCombatDefinitions().getMaxHit(), AttackStyle.MELEE, target))); } else { npc.sync(7970, 1474); delayHit(npc, World.sendProjectile(npc, target, 1477, 34, 16, 30, 1.8, 16, 0).getTaskDelay(), target, getMagicHit(npc, getMaxHit(npc, npc.getCombatDefinitions().getMaxHit(), AttackStyle.MAGE, target))); } return npc.getAttackSpeed(); } }" "package com.rs.game.content.skills.summoning.combat.impl; public class LavaTitan extends FamiliarCombatScript { @Override public Object[] getKeys() { return Pouch.LAVA_TITAN.getIdKeys(); } @Override public int alternateAttack(final NPC npc, final Entity target) { npc.setNextAnimation(new Animation(7980)); npc.setNextSpotAnim(new SpotAnim(1490)); delayHit(npc, 1, target, getMeleeHit(npc, getMaxHit(npc, 140, AttackStyle.MELEE, target))); if (Utils.getRandomInclusive(10) == 0) // 1/10 chance of happening delayHit(npc, 1, target, getMeleeHit(npc, Utils.getRandomInclusive(50))); return npc.getAttackSpeed(); } }" "package com.rs.game.content.skills.summoning.combat.impl; public class SpiritDagannoth extends FamiliarCombatScript { @Override public Object[] getKeys() { return Pouch.SPIRIT_DAGANNOTH.getIdKeys(); } @Override public int alternateAttack(final NPC npc, final Entity target) { if (Utils.getRandomInclusive(4) != 0) return CANCEL; npc.sync(7791, 1427); delayHit(npc, 0, target, getMeleeHit(npc, getMaxHit(npc, npc.getCombatDefinitions().getMaxHit(), AttackStyle.MELEE, target))); delayHit(npc, 1, target, getMeleeHit(npc, getMaxHit(npc, npc.getCombatDefinitions().getMaxHit(), AttackStyle.MELEE, target))); return npc.getAttackSpeed(); } }" "package com.rs.game.content.skills.summoning.combat.impl; public class SteelTitan extends FamiliarCombatScript { @Override public Object[] getKeys() { return Pouch.STEEL_TITAN.getIdKeys(); } @Override public int alternateAttack(final NPC npc, final Entity target) { if (npc.inMeleeRange(target)) { npc.setNextAnimation(new Animation(8183)); delayHit(npc, 1, target, getMeleeHit(npc, getMaxHit(npc, 244, AttackStyle.MELEE, target))); } else { switch (Utils.getRandomInclusive(1)) { case 0: npc.sync(7694, 1451); delayHit(npc, World.sendProjectile(npc, target, 1453, 34, 16, 30, 2.0, 16, 0).getTaskDelay(), target, getMagicHit(npc, getMaxHit(npc, 255, AttackStyle.MAGE, target))); break; case 1: npc.sync(8190, 1444); delayHit(npc, World.sendProjectile(npc, target, 1445, 34, 16, 30, 2.0, 16, 0).getTaskDelay(), target, getRangeHit(npc, getMaxHit(npc, 244, AttackStyle.RANGE, target))); break; } } return npc.getAttackSpeed(); } }" "package com.rs.game.content.skills.summoning.combat.impl; public class TalonBeast extends FamiliarCombatScript { @Override public Object[] getKeys() { return Pouch.TALON_BEAST.getIdKeys(); } @Override public int alternateAttack(final NPC npc, final Entity target) { npc.anim(npc.getCombatDefinitions().getAttackEmote()); delayHit(npc, 0, target, getMeleeHit(npc, getMaxHit(npc, 100, AttackStyle.MELEE, target))); delayHit(npc, 1, target, getMeleeHit(npc, getMaxHit(npc, 100, AttackStyle.MELEE, target))); delayHit(npc, 2, target, getMeleeHit(npc, getMaxHit(npc, 100, AttackStyle.MELEE, target))); return npc.getAttackSpeed(); } }" "package com.rs.game.content.skills.summoning.combat.impl; public class TzKih extends FamiliarCombatScript { @Override public Object[] getKeys() { return Pouch.SPIRIT_TZ_KIH.getIdKeys(); } @Override public int alternateAttack(final NPC npc, final Entity target) { npc.sync(npc.getCombatDefinitions().getAttackEmote(), 1422); Hit hit = getMagicHit(npc, getMaxHit(npc, npc.getCombatDefinitions().getMaxHit(), AttackStyle.MAGE, target)); delayHit(npc, World.sendProjectile(npc, target, 1423, 34, 16, 30, 2.0, 16, 0).getTaskDelay(), target, hit); if (hit.getDamage() > 0 && target instanceof Player player) player.getPrayer().drainPrayer(player.getPrayer().getPoints() * 0.02); return npc.getAttackSpeed(); } }" "package com.rs.game.content.skills.thieving; @PluginEventHandler public class Blackjacking { public static NPCClickHandler loothandler = new NPCClickHandler(new Object[] { 1903 }, new String[] {""Pickpocket""}, e -> { if(e.getNPC().getTempAttribs().getO(""K.O"") == null) { e.getPlayer().sendMessage(""You should knock the Menaphite Thug out first.""); return; } if(e.getNPC().getTempAttribs().getO(""K.O"") == e.getPlayer()) { e.getPlayer().getActionManager().setAction(new LootThug()); } else e.getPlayer().sendMessage(""Someone else knocked out that target.""); }); public static NPCClickHandler lure = new NPCClickHandler(new Object[] { 1903 }, new String[] {""Lure""}, e -> { String[] responses = new String[]{ ""Watch out! The fellow behind you has a club!"", ""Behind you! A three-headed monkey!"", ""That's the third biggest platypus I've ever seen!"", ""Look over THERE!"", ""Look! An eagle!"", ""Your shoelace is untied."" }; e.getPlayer().startConversation(new Dialogue() .addPlayer(HeadE.SKEPTICAL, responses[(Utils.random(5))]) .addNPC(e.getNPCId(), HeadE.SCARED, ""Oh nooooo!"") .addNext(() -> { e.getNPC().follow(e.getPlayer()); e.getNPC().getTempAttribs().setO(""lured"", e.getPlayer()); e.getPlayer().sendMessage(); WorldTasks.delay(Ticks.fromSeconds(10), () -> { e.getNPC().getTempAttribs().setO(""lured"", e.getPlayer()); e.getNPC().getActionManager().forceStop(); } ); }) ); }); }" "package com.rs.game.content.skills.thieving fun rollSuccess(player: Player): Boolean { return Utils.skillSuccess( player.skills.getLevel(Constants.THIEVING), player.auraManager.thievingMul + (if (LootThug.hasArdyCloak(player)) 0.1 else 0.0), 185, 255 ) } private fun successful(player: Player): Boolean { return rollSuccess(player) } private fun checkAll(player: Player): Boolean { if (player.isDead || player.hasFinished() || player.hasPendingHits()) return false if (player.attackedBy != null && player.inCombat()) { player.sendMessage(""You can't do this while you're under combat."") return false } return true } @ServerStartupEvent fun mapHandlers() { val validCoshIds = setOf(18644, 4599, 4600, 4612, 4608, 4609, 4610, 4611, 4612, 4613, 4614, 4615, 4616, 4617, 4618, 4619, 4620, 4621) val validTrainingNPC = setOf(11290, 11292, 11288, 11296) val response = arrayOf( ""No, no, not like that."", ""Spotted you!"" ) onNpcClick(11290, 11292, 11288, 11296, options = arrayOf(""Knock-out"")) { e -> if(e.player.equipment.getWeaponId() !in validCoshIds){ e.player.sendMessage(""I'll need a cosh to knock them out"") return@onNpcClick } if (e.npcId in validTrainingNPC && e.player.equipment.getWeaponId() != 18644) { e.player.sendMessage(""I'll need a training cosh to practise my technique with."") return@onNpcClick } val luredBy = e.npc.tempAttribs.getO(""lured"") if (e.npc.tempAttribs.getO(""lured"") == null) { e.player.playerDialogue( HeadE.SKEPTICAL_THINKING, ""I need to divert his attention first."" ) return@onNpcClick } if (luredBy != e.player) { e.player.sendMessage(""Someone else knocked out that target."") return@onNpcClick } if (checkAll(e.player)) { if (successful(e.player)) { e.player.sendMessage(""You smack the "" + e.npc.name + "" over the head."") e.npc.actionManager.forceStop() e.npc.tempAttribs.setO(""K.O"", e.player) e.player.anim(10267) e.npc.anim(837) e.npc.freeze(Ticks.fromSeconds(10)) e.npc.tasks.schedule(Ticks.fromSeconds(10)) { e.npc.anim(-1) e.npc.tempAttribs.removeO(""K.O"") } } else { e.player.anim(10267) if(e.npcId in validTrainingNPC) { e.player.sendMessage( ""You fail to pick the "" + e.npc.definitions.name .lowercase(Locale.getDefault()) + ""'s pocket."" ) e.npc.anim(422) e.npc.faceEntity(e.player) e.player.anim(424) e.player.spotAnim(80, 5, 60) e.player.sendMessage(""You've been stunned."") e.player.applyHit(Hit(e.player, 1, Hit.HitLook.TRUE_DAMAGE)) e.npc.forceTalk(response[Utils.random(2)]) } } } } onNpcClick(1903, options = arrayOf(""Knock-Out"")) { e -> if(e.player.equipment.getWeaponId() !in validCoshIds){ e.player.sendMessage(""I'll need a cosh to knock them out"") return@onNpcClick } if (e.player.equipment.getWeaponId() == 18644) { e.player.sendMessage(""A training cosh will not be enough to knock them out."") return@onNpcClick } val luredBy = e.npc.tempAttribs.getO(""lured"") if (e.npc.tempAttribs.getO(""lured"") == null) { e.player.playerDialogue( HeadE.SKEPTICAL_THINKING, ""I need to divert his attention first."" ) return@onNpcClick } if (luredBy != e.player) { e.player.sendMessage(""Someone else knocked out that target."") return@onNpcClick } if (checkAll(e.player)) { if (successful(e.player)) { e.player.sendMessage(""You smack the "" + e.npc.name + "" over the head."") e.npc.actionManager.forceStop() e.npc.tempAttribs.setO(""K.O"", e.player) e.player.anim(10267) e.npc.anim(837) e.npc.freeze(Ticks.fromSeconds(10)) e.npc.tasks.schedule(Ticks.fromSeconds(10)) { e.npc.anim(-1) e.npc.tempAttribs.removeO(""K.O"") } } else { e.npc.forceTalk(""I'll kill you for that!"") e.npc.setAttackedBy(e.player) } } } }" "package com.rs.game.content.skills.thieving; @PluginEventHandler public class LootThug extends PlayerAction { private boolean success = false; public LootThug() { } @Override public boolean start(Player player) { if (checkAll(player)) { success = successful(player); player.sendMessage(""You search the Menaphite Thug's pocket...""); WorldTasks.delay(0, () -> player.setNextAnimation(new Animation(881))); setActionDelay(player, 2); player.lock(); return true; } return false; } @Override public boolean process(Player player) { return checkAll(player); } @Override public int processWithDelay(Player player) { if (!success) { player.sendMessage(""You find nothing in the Menaphite Thug's pocket.""); } else { player.incrementCount(""Menaphite Thug pickpocketed""); player.getSkills().addXp(Constants.THIEVING, 137.5); player.getInventory().addCoins(60); stop(player); } return -1; } @Override public void stop(Player player) { player.unlock(); player.setNextFaceEntity(null); setActionDelay(player, 1); } public boolean rollSuccess(Player player) { return Utils.skillSuccess(player.getSkills().getLevel(Constants.THIEVING), player.getAuraManager().getThievingMul() + (hasArdyCloak(player) ? 0.1 : 0.0), 185, 255); } private boolean successful(Player player) { if (!rollSuccess(player)) return false; return true; } private boolean checkAll(Player player) { if (player.isDead() || player.hasFinished() || player.hasPendingHits()) return false; if (player.getAttackedBy() != null && player.inCombat()) { player.sendMessage(""You can't do this while you're under combat.""); return false; } return true; } public static boolean hasArdyCloak(Player player) { return switch (player.getEquipment().getCapeId()) { case 15349, 19748, 9777, 9778 -> true; default -> false; }; } }" "package com.rs.game.content.skills.thieving; public enum PickPocketableNPC { POMPOUS_MERCHANT(177, 240, new short[] { 14911 }, new byte[] { 1, 11, 21, 31 }, new byte[] { 1, 1, 11, 21 }, 8.0, 3, 1, new DropTable(995, 3)), MAN(177, 240, new short[] { 1, 2, 3, 4, 5, 6, 16, 24, 25, 170, 3223, 3225, 3226, 3915, 5923, 5924, 7873, 7874, 7875, 7876, 7877, 7878, 7879, 7880, 7881, 7882, 7883, 7884, 8868, 12345, 12346, 12347 }, new byte[] { 1, 11, 21, 31 }, new byte[] { 1, 1, 11, 21 }, 8.0, 4, 10, ""pp_man""), FARMER(155, 240, new short[] { 7, 1757, 1758, 1760 }, new byte[] { 10, 20, 30, 40 }, new byte[] { 1, 10, 20, 30 }, 14.5, 4, 10, ""pp_farmer""), FEMALE_HAM(135, 240, new short[] { 1715 }, new byte[] { 15, 25, 35, 45 }, new byte[] { 1, 15, 25, 35 }, 18.5, 3, 10, ""pp_femaleham""), MALE_HAM(135, 240, new short[] { 1714, 1716 }, new byte[] { 20, 30, 40, 50 }, new byte[] { 1, 20, 30, 40 }, 22.5, 3, 20, ""pp_maleham""), HAM_GUARD(135, 240, new short[] { 1710, 1711, 1712 }, new byte[] { 20, 30, 40, 50 }, new byte[] { 1, 20, 30, 40 }, 22.5, 3, 30, new DropTable(995, 1, 50)), WARRIOR(125, 240, new short[] { 15, 18 }, new byte[] { 25, 35, 45, 55 }, new byte[] { 1, 25, 35, 45 }, 26, 5, 20, new DropTable(995, 18)), ROGUE(115, 240, new short[] { 187, 2267, 2268, 2269, 8122 }, new byte[] { 32, 42, 52, 62 }, new byte[] { 1, 32, 42, 52 }, 35.5, 4, 20, new DropTable(995, 20)), CAVE_GOBLIN(100, 240, new short[] { 5752, 5753, 5754, 5755, 5756, 5757, 5758, 5759, 5760, 5761, 5762, 5763, 5764, 5765, 5766, 5767, 5768 }, new byte[] { 36, 46, 56, 66 }, new byte[] { 1, 36, 46, 56 }, 40, 4, 10, ""pp_cavegoblin""), MASTER_FARMER(90, 240, new short[] { 2234, 2235, 3299 }, new byte[] { 38, 48, 58, 68 }, new byte[] { 1, 38, 48, 58 }, 43, 4, 30, ""pp_masterfarmer""), GUARD(45, 240, new short[] { 9, 32, 206, 296, 297, 298, 299, 344, 345, 346, 368, 678, 812, 2699, 2700, 2701, 2702, 2703, 3228, 3229, 3230, 3231, 3232, 3233, 3241, 3407, 3408, 4307, 4308, 4309, 4310, 4311, 5919, 5920, 5921, 5922 }, new byte[] { 40, 50, 60, 70 }, new byte[] { 1, 40, 50, 60 }, 46.5, 4, 20, new DropTable(995, 30)), FREMENNIK_CITIZEN(35, 240, new short[] { 2462 }, new byte[] { 45, 55, 65, 75 }, new byte[] { 1, 45, 55, 65 }, 65, 4, 20, new DropTable(995, 40)), DESERT_PHOENIX(35, 240, new short[] { 1911 }, new byte[] { 25, 127, 127, 127 }, new byte[] { 1, 1, 1, 1 }, 26, new Animation(-1), 4, 20, new DropTable(4621, 1)), ARDOUGNE_KNIGHT(41, 240, new short[] { 23, 26 }, new byte[] { 55, 65, 75, 85 }, new byte[] { 1, 55, 65, 75 }, 84.3, 4, 30, new DropTable(995, 50)), BANDIT(35, 240, new short[] { 1880, 1881, 1926, 1931, 5050, 6174, 6388 }, new byte[] { 55, 65, 75, 85 }, new byte[] { 1, 55, 65, 75 }, 84.3, 4, 50, new DropTable(995, 50)), WATCHMEN_MENAPHITES(17, 156, new short[] { 34, 1905 }, new byte[] { 65, 75, 85, 95 }, new byte[] { 1, 65, 75, 85 }, 137.5, 4, 50, new DropTable(995, 60)), PALADIN(17, 150, new short[] { 20, 2256 }, new byte[] { 70, 80, 90, 100 }, new byte[] { 1, 70, 80, 90 }, 151.75, 4, 30, ""pp_paladin""), MONKEY_KNIFE_FIGHTER(15, 200, new short[] { 13195, 13212, 13213 }, new byte[] { 70, 127, 127, 127 }, new byte[] { 1, 1, 1, 1 }, 150, 4, 10, ""pp_mkf""), GNOME(13, 120, new short[] { 66, 67, 68, 159, 160, 161, 168, 169, 2249, 2250, 2251, 2371, 2649, 2650, 6002, 6004 }, new byte[] { 75, 85, 95, 105 }, new byte[] { 1, 75, 85, 95 }, 198.5, new Animation(191), 4, 10, ""pp_gnome""), HERO(13, 120, new short[] { 21 }, new byte[] { 80, 90, 100, 110 }, new byte[] { 1, 80, 90, 100 }, 275, 5, 40, ""pp_hero""), ELF(6, 98, new short[] { 2364, 2365, 2366 }, new byte[] { 85, 95, 105, 115 }, new byte[] { 1, 85, 95, 105 }, 353, 10, 50, new DropTable(995, 1, 50)), DWARF_TRADER(1, 150, new short[] { 2109, 2110, 2111, 2112, 2113, 2114, 2115, 2116, 2117, 2118, 2119, 2120, 2121, 2122, 2123, 2124, 2125, 2126, 8824, 8827 }, new byte[] { 90, 100, 110, 120 }, new byte[] { 1, 90, 100, 110 }, 556.5, 6, 10, ""pp_dwarftrader""); private static final Map NPCS = new HashMap<>(); public static PickPocketableNPC get(int id) { return NPCS.get((short) id); } static { for (PickPocketableNPC data : PickPocketableNPC.values()) for (short id : data.npcIds) NPCS.put(id, data); } private final int rate1; private final int rate99; private final short[] npcIds; private final byte[] thievingLevels; private final byte[] agilityLevels; private final double experience; private final byte stunTime; private final byte stunDamage; private String table; private DropSet loot; private Animation stunAnimation = null; private PickPocketableNPC(int rate1, int rate99, short[] npcIds, byte[] thievingLevel, byte[] agilityLevel, double experience, int stunTime, int stunDamage, DropTable... loot) { this.rate1 = rate1; this.rate99 = rate99; this.npcIds = npcIds; thievingLevels = thievingLevel; agilityLevels = agilityLevel; this.experience = experience; this.stunTime = (byte) stunTime; this.stunDamage = (byte) stunDamage; if (loot.length > 0) this.loot = new DropSet(loot); } private PickPocketableNPC(int rate1, int rate99, short[] npcIds, byte[] thievingLevel, byte[] agilityLevel, double experience, int stunTime, int stunDamage, String table) { this(rate1, rate99, npcIds, thievingLevel, agilityLevel, experience, stunTime, stunDamage); this.table = table; } private PickPocketableNPC(int rate1, int rate99, short[] npcIds, byte[] thievingLevel, byte[] agilityLevel, double experience, Animation stunAnimation, int stunTime, int stunDamage, DropTable... loot) { this.rate1 = rate1; this.rate99 = rate99; this.npcIds = npcIds; thievingLevels = thievingLevel; agilityLevels = agilityLevel; this.experience = experience; this.stunTime = (byte) stunTime; this.stunDamage = (byte) stunDamage; this.stunAnimation = stunAnimation; this.loot = new DropSet(loot); } private PickPocketableNPC(int rate1, int rate99, short[] npcIds, byte[] thievingLevel, byte[] agilityLevel, double experience, Animation stunAnimation, int stunTime, int stunDamage, String table) { this(rate1, rate99, npcIds, thievingLevel, agilityLevel, experience, stunAnimation, stunTime, stunDamage); this.table = table; } public short[] getNpcIds() { return npcIds; } public byte[] getThievingLevels() { return thievingLevels; } public byte[] getAgilityLevels() { return agilityLevels; } public double getExperience() { return experience; } public byte getStunTime() { return stunTime; } public byte getStunDamage() { return stunDamage; } public DropSet getLoot() { if (table != null) return DropSets.getDropSet(table); return loot; } public Animation getStunAnimation() { return stunAnimation; } public boolean rollSuccess(Player player) { return Utils.skillSuccess(player.getSkills().getLevel(Constants.THIEVING), player.getAuraManager().getThievingMul() + (hasArdyCloak(player) ? 0.1 : 0.0), rate1, rate99); } public static boolean hasArdyCloak(Player player) { return switch (player.getEquipment().getCapeId()) { case 15349, 19748, 9777, 9778 -> true; default -> false; }; } }" "package com.rs.game.content.skills.thieving; public class PickPocketAction extends PlayerAction { private final NPC npc; private final PickPocketableNPC npcData; private static final Animation STUN_ANIMATION = new Animation(422), PICKPOCKETING_ANIMATION = new Animation(881), DOUBLE_LOOT_ANIMATION = new Animation(5074), TRIPLE_LOOT_ANIMATION = new Animation(5075), QUADRUPLE_LOOT_ANIMATION = new Animation(5078); private static final SpotAnim DOUBLE_LOOT_GFX = new SpotAnim(873), TRIPLE_LOOT_GFX = new SpotAnim(874), QUADRUPLE_LOOT_GFX = new SpotAnim(875); private int index; private boolean success = false; public PickPocketAction(NPC npc, PickPocketableNPC npcData) { this.npc = npc; this.npcData = npcData; } @Override public boolean start(Player player) { if (checkAll(player)) { success = successful(player); player.faceEntity(npc); if (npcData.equals(PickPocketableNPC.DESERT_PHOENIX)) player.sendMessage(""You attempt to grab the phoenix's tail-feather.""); else player.sendMessage(""You attempt to pick the "" + npc.getDefinitions().getName().toLowerCase() + ""'s pocket...""); WorldTasks.delay(0, () -> { player.setNextAnimation(getAnimation()); player.setNextSpotAnim(getGraphics()); }); setActionDelay(player, 2); player.lock(); return true; } return false; } @Override public boolean process(Player player) { return checkAll(player); } @Override public int processWithDelay(Player player) { if (!success) { if (npcData.equals(PickPocketableNPC.DESERT_PHOENIX)) player.sendMessage(""You fail to grab the feather.""); else player.sendMessage(""You fail to pick the "" + npc.getDefinitions().getName().toLowerCase() + ""'s pocket.""); npc.setNextAnimation(npcData.getStunAnimation() != null ? npcData.getStunAnimation() : STUN_ANIMATION); npc.faceEntity(player); player.setNextAnimation(new Animation(424)); player.setNextSpotAnim(new SpotAnim(80, 5, 60)); player.sendMessage(""You've been stunned.""); player.applyHit(new Hit(player, npcData.getStunDamage(), HitLook.TRUE_DAMAGE)); if (npcData.equals(PickPocketableNPC.MASTER_FARMER) || npcData.equals(PickPocketableNPC.FARMER)) npc.setNextForceTalk(new ForceTalk(""Cor blimey mate, what are ye doing in me pockets?"")); else if (npcData.equals(PickPocketableNPC.DESERT_PHOENIX)) npc.setNextForceTalk(new ForceTalk(""Squawk!"")); else npc.setNextForceTalk(new ForceTalk(""What do you think you're doing?"")); stop(player); } else { if (npcData == PickPocketableNPC.DWARF_TRADER) Thieving.checkGuards(player); player.sendMessage("""" + getMessage(player), true); double totalXp = npcData.getExperience(); if (hasTheivingSuit(player)) totalXp *= 1.025; player.incrementCount(npc.getDefinitions().getName()+"" pickpocketed""); player.getSkills().addXp(Constants.THIEVING, totalXp); for (int i = 0; i <= index; i++) { Item[] items = DropTable.calculateDrops(player, npcData.getLoot()); for (Item item : items) player.getInventory().addItem(item.getId(), item.getAmount()); } stop(player); } return -1; } @Override public void stop(Player player) { player.unlock(); npc.setNextFaceEntity(null); player.setNextFaceEntity(null); setActionDelay(player, 1); if (!success) player.lock(npcData.getStunTime()); } private boolean hasTheivingSuit(Player player) { if (player.getEquipment().getHatId() == 21482 && player.getEquipment().getChestId() == 21480 && player.getEquipment().getLegsId() == 21481 && player.getEquipment().getBootsId() == 21483) return true; return false; } private boolean successful(Player player) { if (!npcData.rollSuccess(player)) return false; if (Utils.getRandomInclusive(50) < 5) { for (int i = 0; i < 4; i++) if (npcData.getThievingLevels()[i] <= player.getSkills().getLevel(Constants.THIEVING) && npcData.getAgilityLevels()[i] <= player.getSkills().getLevel(Constants.AGILITY)) index = i; } else index = 0; return true; } private String getMessage(Player player) { if (npcData.equals(PickPocketableNPC.DESERT_PHOENIX)) return ""You grab a tail-feather.""; return switch (index) { case 0 -> ""You succesfully pick the "" + npc.getDefinitions().getName().toLowerCase() + ""'s pocket.""; case 1 -> ""Your lighting-fast reactions allow you to steal double loot.""; case 2 -> ""Your lighting-fast reactions allow you to steal triple loot.""; case 3 -> ""Your lighting-fast reactions allow you to steal quadruple loot.""; default -> null; }; } private boolean checkAll(Player player) { if (player.isDead() || player.hasFinished() || npc.isDead() || npc.hasFinished() || player.hasPendingHits()) return false; if (player.getSkills().getLevel(Constants.THIEVING) < npcData.getThievingLevels()[0]) { player.simpleDialogue(""You need a thieving level of "" + npcData.getThievingLevels()[0] + "" to steal from this npc.""); return false; } if (player.getInventory().getFreeSlots() < 1) { player.sendMessage(""You don't have enough space in your inventory.""); return false; } if (player.getAttackedBy() != null && player.inCombat()) { player.sendMessage(""You can't do this while you're under combat.""); return false; } if (npc.getAttackedBy() != null && npc.inCombat()) { player.sendMessage(""The npc is under combat.""); return false; } if (npc.isDead()) { player.sendMessage(""Too late, the npc is dead.""); return false; } return true; } private Animation getAnimation() { return switch (index) { case 0 -> PICKPOCKETING_ANIMATION; case 1 -> DOUBLE_LOOT_ANIMATION; case 2 -> TRIPLE_LOOT_ANIMATION; case 3 -> QUADRUPLE_LOOT_ANIMATION; default -> null; }; } private SpotAnim getGraphics() { return switch (index) { case 0 -> null; case 1 -> DOUBLE_LOOT_GFX; case 2 -> TRIPLE_LOOT_GFX; case 3 -> QUADRUPLE_LOOT_GFX; default -> null; }; } }" "package com.rs.game.content.skills.thieving; /** * Handles the Thieving Skill * * @author Dragonkk * */ public class Thieving { public enum Stalls { VEGETABLE(4706, 2, new int[] { 1957, 1965, 1942, 1982, 1550 }, 1, 2, 10, 634), VEGETABLE2(66696, 2, new int[] { 1957, 1965, 1942, 1982, 1550 }, 1, 2, 10, 66697), CAKE(34384, 5, new int[] { 1891, 1901, 2309 }, 1, 2, 16, 34381), CAKE2(6163, 5, new int[] { 1891, 1901, 2309 }, 1, 2, 16, 6984), CAKE3(66692, 5, new int[] { 1891, 1901, 2309 }, 1, 2, 16, 66693), CRAFTING(4874, 5, new int[] { 1755, 1592, 1597 }, 1, 7, 16, 4797), CRAFTING2(6166, 5, new int[] { 1755, 1592, 1597 }, 1, 7, 16, 6984), CRAFTING3(66700, 5, new int[] { 1755, 1592, 1597 }, 1, 7, 16, 66701), MONKEY_FOOD(4875, 5, new int[] { 1963 }, 1, 7, 16, 4797), MONKEY_GENERAL(4876, 5, new int[] { 1931, 2347, 590 }, 1, 7, 16, 4797), TEA_STALL(635, 5, new int[] { 1978 }, 1, 7, 16, 634), SILK_STALL(34383, 20, new int[] { 950 }, 1, 2, 24, 34381), WINE_STALL(14011, 22, new int[] { 1937, 1993, 1987, 1935, 7919 }, 1, 16, 27, 2046), WINE_STALL2(66694, 22, new int[] { 1937, 1993, 1987, 1935, 7919 }, 1, 16, 27, 66695), SEED_STALL(7053, 27, new int[] { 5096, 5097, 5098, 5099, 5100, 5101, 5102, 5103, 5105 }, 1, 11, 10, 2047), SEED_STALL2(66698, 27, new int[] { 5096, 5097, 5098, 5099, 5100, 5101, 5102, 5103, 5105 }, 1, 11, 10, 66699), FUR_STALL(34387, 35, new int[] { 6814, 958 }, 1, 15, 36, 34381), FUR_STALL2(4278, 35, new int[] { 6814, 958 }, 1, 15, 36, 634), FISH_STALL(4705, 42, new int[] { 331, 359, 377 }, 1, 16, 42, 634), FISH_STALL2(4277, 42, new int[] { 331, 359, 377 }, 1, 16, 42, 634), CROSSBOW_STALL(17031, 49, new int[] { 877, 9420, 9440 }, 1, 11, 52, 6984), SILVER_STALL(34382, 50, new int[] { 442 }, 1, 30, 54, 34381), SILVER_STALL2(6164, 50, new int[] { 442 }, 1, 30, 54, 6984), SPICE_STALL(34386, 65, new int[] { 2007 }, 1, 80, 81, 34381), MAGIC_STALL(4877, 65, new int[] { 556, 557, 554, 555, 563 }, 1, 80, 100, 4797), SCIMITAR_STALL(4878, 65, new int[] { 1323 }, 1, 80, 100, 4797), GEM_STALL(34385, 75, new int[] { 1623, 1621, 1619, 1617 }, 1, 180, 16, 34381), GEM_STALL2(6162, 75, new int[] { 1623, 1621, 1619, 1617 }, 1, 180, 16, 6984); private final int[] item; private final int level; private final int amount; private final int objectId; private final int replaceObject; private final double experience; private final int seconds; Stalls(int objectId, int level, int[] item, int amount, int seconds, double experience, int replaceObject) { this.objectId = objectId; this.level = level; this.item = item; this.amount = amount; this.seconds = seconds; this.experience = experience; this.replaceObject = replaceObject; } public int getReplaceObject() { return replaceObject; } public int getObjectId() { return objectId; } public int getItem(int count) { return item[count]; } public int getAmount() { return amount; } public int getLevel() { return level; } public int getTime() { return seconds; } public double getExperience() { return experience; } } public static boolean isGuard(int npcId) { if (npcId == 32 || npcId == 21 || npcId == 2256 || npcId == 2132 || npcId == 2236 || npcId == 23 || npcId == 8813) return true; return false; } public static void handleStalls(final Player player, final GameObject object) { for (final Stalls stall : Stalls.values()) if (stall.getObjectId() == object.getId()) { if (player.getAttackedBy() != null && player.inCombat()) { player.sendMessage(""You can't do this while you're under combat.""); return; } final GameObject emptyStall = new GameObject(stall.getReplaceObject(), ObjectType.SCENERY_INTERACT, object.getRotation(), object.getX(), object.getY(), object.getPlane()); if (player.getSkills().getLevel(Constants.THIEVING) < stall.getLevel()) { player.sendMessage(""You need a thieving level of "" + stall.getLevel() + "" to steal from this."", true); return; } if (player.getInventory().getFreeSlots() <= 0) { player.sendMessage(""Not enough space in your inventory."", true); return; } player.setNextAnimation(new Animation(881)); player.lock(2); WorldTasks.scheduleLooping(new Task() { @Override public void run() { if (!ChunkManager.getChunk(object.getTile().getChunkId()).objectExists(object)) { stop(); return; } player.getInventory().addItem(stall.getItem(Utils.getRandomInclusive(stall.item.length - 1)), Utils.getRandomInclusive(stall.getAmount())); player.getSkills().addXp(Constants.THIEVING, stall.getExperience()); checkGuards(player); World.spawnObjectTemporary(emptyStall, stall.getTime()*2); stop(); } }, 0, 0); } } public static void checkGuards(Player player) { NPC guard = null; int lastDistance = -1; for (NPC npc : player.queryNearbyNPCsByTileRange(4, npc -> isGuard(npc.getId()) && !npc.isUnderCombat() && !npc.isDead() && npc.withinDistance(player, 4) && npc.lineOfSightTo(player, false))) { int distance = (int) Utils.getDistance(npc.getX(), npc.getY(), player.getX(), player.getY()); if (lastDistance == -1 || lastDistance > distance) { guard = npc; lastDistance = distance; } } if (guard != null) { guard.setNextForceTalk(new ForceTalk(""Hey, what do you think you are doing!"")); guard.setTarget(player); } } public static void checkTrapsChest(Player player, GameObject object, int openedId, int level , int respawnTime, double xp, DropSet set) { Item[] loot = DropTable.calculateDrops(player, set); checkTrapsChest(player, object, openedId, level , respawnTime, xp, loot); } public static void checkTrapsChest(Player player, GameObject object, int openedId, int level, int respawnTime, double xp, Item... loot) { player.faceObject(object); if (!player.getInventory().hasFreeSlots()) { player.sendMessage(""You don't have any space in your inventory.""); return; } if (player.getSkills().getLevel(Constants.THIEVING) < level) { player.sendMessage(""You need a higher thieving level.""); return; } player.setNextAnimation(new Animation(536)); player.lock(2); player.getSkills().addXp(Constants.THIEVING, xp); player.incrementCount(""Chests thieved""); object.setIdTemporary(openedId, Ticks.fromSeconds(respawnTime)); for (Item item : loot) if (item != null) player.getInventory().addItem(item); } public static boolean pickDoor(Player player, GameObject object) { if (player.getTempAttribs().getI(""numbFingers"") == -1) player.getTempAttribs().setI(""numbFingers"", 0); int thievingLevel = player.getSkills().getLevel(Constants.THIEVING); int increasedChance = getIncreasedChance(player); int decreasedChance = player.getTempAttribs().getI(""numbFingers""); int level = Utils.getRandomInclusive(thievingLevel + (increasedChance - decreasedChance)) + 1; double ratio = (double) level / (Utils.getRandomInclusive(45 + 5) + 1); if (Math.round(ratio * thievingLevel) < (player.inCombat() ? 50 : 40)) { player.sendMessage(""You fail to unlock the door and your hands begin to numb down.""); player.getTempAttribs().setI(""numbFingers"", decreasedChance + 1); return false; } player.sendMessage(""You successfully unlock the door.""); Doors.handleDoor(player, object); return true; } private static int getIncreasedChance(Player player) { int chance = 0; if (Equipment.getItemSlot(Equipment.HANDS) == 10075) chance += 12; player.getEquipment(); if (Equipment.getItemSlot(Equipment.CAPE) == 15349) chance += 15; return chance; } }" "package com.rs.game.content.skills.thieving.thievesGuild; @PluginEventHandler public class HankyPoints { public static int maxPoints(Player player){ int thievingLevel = player.getSkills().getLevel(Skills.THIEVING); int maxPoints = 4 * (10 + (thievingLevel / 9)); return maxPoints; } private static double calculateXP(Player player) { int[][] experienceData = { {99, 10080}, {98, 9840}, {97, 9680}, {96, 9440}, {95, 9280}, {94, 9120}, {93, 8880}, {92, 8720}, {91, 8560}, {90, 8320}, {89, 8132}, {88, 7980}, {87, 7828}, {86, 7600}, {85, 7448}, {84, 7296}, {83, 7144}, {82, 6916}, {81, 6764}, {80, 6624}, {79, 6480}, {78, 6336}, {77, 6120}, {76, 5976}, {75, 5832}, {74, 5688}, {73, 5544}, {72, 5400}, {71, 5236}, {70, 5100}, {69, 4964}, {68, 4828}, {67, 4692}, {66, 4556}, {65, 4420}, {64, 4284}, {63, 4148}, {62, 4032}, {61, 3904}, {60, 3776}, {59, 3648}, {58, 3520}, {57, 3456}, {56, 3384}, {55, 3200}, {54, 3072}, {53, 3000}, {52, 2880}, {51, 2760}, {50, 2700}, {49, 2580}, {48, 2460}, {47, 2400}, {46, 2280}, {45, 2160}, {44, 2072}, {43, 2016}, {42, 1904}, {41, 1848}, {40, 1736}, {39, 1680}, {38, 1568}, {37, 1512}, {36, 1412}, {35, 1352}, {34, 1300}, {33, 1248}, {32, 1092}, {31, 1092}, {30, 1092}, {29, 988}, {28, 936}, {27, 832}, {26, 816}, {25, 768}, {24, 720}, {23, 672}, {22, 624}, {21, 576}, {20, 528}, {19, 480}, {18, 432}, {17, 396}, {16, 352}, {15, 352}, {14, 308}, {13, 264}, {12, 264}, {11, 220}, {10, 220} }; int xp = 0; int level = player.getSkills().getLevel(Skills.THIEVING); for (int[] row : experienceData) { if (row[0] == level) { xp = row[1]; break; } } return xp; } public static void claimHankyPoints(Player player, NPC npc){ int availablePoints = player.getWeeklyI(""HankyPoints"") - player.getWeeklyI(""ClaimedHankyPoints""); double xp = (calculateXP(player) / maxPoints(player)) * availablePoints; if(availablePoints == 0) { player.npcDialogue(npc.getId(), HeadE.CALM_TALK, ""You have no hanky points to claim! Try some of the guild's training exercises.""); } else { player.getSkills().addXp(Skills.THIEVING, xp); player.sendMessage(""You gain "" + (int) xp + "" Thieving XP. ""); player.npcDialogue(npc.getId(), HeadE.CALM_TALK, ""You may turn in up to "" + (maxPoints(player) - player.getWeeklyI(""ClaimedHankyPoints"")) + "" more points this week.""); player.incWeeklyI(""ClaimedHankyPoints"", availablePoints); } } public static void checkPoints(Player player, NPC npc) { int availablePoints = player.getWeeklyI(""HankyPoints"") - player.getWeeklyI(""ClaimedHankyPoints""); if(player.getWeeklyI(""HankyPoints"") == 0) { player.npcDialogue(npc.getId(), HeadE.CALM_TALK, ""You have no hanky points! Try some of the guild's training exercises.""); return; } if(player.getWeeklyI(""ClaimedHankyPoints"") == maxPoints(player)) { player.npcDialogue(npc.getId(), HeadE.CALM_TALK, ""You have collected all your hanky points this week.""); return; } if(player.getWeeklyI(""ClaimedHankyPoints"") > 0) { player.npcDialogue(npc.getId(), HeadE.CALM_TALK, ""You have "" + availablePoints + "" hanky points ready to turn in. You have collected "" + player.getWeeklyI(""ClaimedHankyPoints"") + "" hanky points. You may claim the reward for up to "" + (maxPoints(player) - player.getWeeklyI(""ClaimedHankyPoints"")) + "" more hanky points this week.""); } else player.npcDialogue(npc.getId(), HeadE.CALM_TALK,""You have "" + availablePoints + "" ready to turn in. You may claim the reward for up to "" + (maxPoints(player) - player.getWeeklyI(""ClaimedHankyPoints"")) + "" more hanky points this week.""); } public static NPCClickHandler checkPoints = new NPCClickHandler(new Object[] { 11281, 11294, 11282, 11284, 11286 }, new String[] {""Check-points""}, e -> checkPoints(e.getPlayer(), e.getNPC())); public static NPCClickHandler pickpockethandler = new NPCClickHandler(new Object[] { 11281, 11282, 11284, 11286 }, new String[] {""Pickpocket""}, e -> e.getPlayer().getActionManager().setAction(new PickPocket(e.getNPC()))); public static NPCClickHandler loothandler = new NPCClickHandler(new Object[] { 11290, 11292, 11288, 11296 }, new String[] {""Loot""}, e -> { if(e.getNPC().getTempAttribs().getO(""K.O"") == null) { e.getPlayer().sendMessage(""You should knock him out before attempting to loot him.""); return; } if(e.getNPC().getTempAttribs().getO(""K.O"") == e.getPlayer()) { e.getPlayer().getActionManager().setAction(new Loot(e.getNPC())); } else e.getPlayer().sendMessage(""Someone else knocked out that target.""); }); public static NPCClickHandler lure = new NPCClickHandler(new Object[] { 11290, 11292, 11288, 11296 }, new String[] {""Lure""}, e -> { String[] responses = new String[]{ ""Watch out! The fellow behind you has a club!"", ""Behind you! A three-headed monkey!"", ""That's the third biggest platypus I've ever seen!"", ""Look over THERE!"", ""Look! An eagle!"", ""Your shoelace is untied."" }; int npcId = e.getNPCId(); String npcMessage = ""Oh nooooo!""; if (npcId == 11296) { npcMessage = ""Wha?""; } e.getPlayer().startConversation(new Dialogue() .addPlayer(HeadE.SKEPTICAL, responses[Utils.random(5)]) .addNPC(npcId, HeadE.SCARED, npcMessage) .addNext(() -> { e.getNPC().follow(e.getPlayer()); e.getNPC().getTempAttribs().setO(""lured"", e.getPlayer()); e.getPlayer().sendMessage(); WorldTasks.delay(Ticks.fromSeconds(10), () -> { e.getNPC().getTempAttribs().setO(""lured"", e.getPlayer()); e.getNPC().getActionManager().forceStop(); }); }) ); }); public static ObjectClickHandler handleNorthDoors = new ObjectClickHandler(new Object[] { 52302 }, e -> { if(e.getOption().equalsIgnoreCase(""Open"")) { if(e.getPlayer().getTile().getY() >= e.getObject().getY()) { World.removeObjectTemporary(e.getObject(), Ticks.fromSeconds(10)); World.spawnObjectTemporary(new GameObject(e.getObjectId() + 1, e.getObject().getType(), e.getObject().getRotation() - 1, e.getObject().getTile().transform(0, -1, 0)), Ticks.fromSeconds(10), true); return; } WorldTasks.scheduleTimer(i -> { switch(i) { case 1 -> { e.getPlayer().faceObject(e.getObject()); e.getPlayer().setNextAnimation(new Animation(832)); e.getPlayer().sendMessage(""You examine the lock on the door...""); } case 3 -> { if (Utils.skillSuccess(e.getPlayer().getSkills().getLevel(Skills.THIEVING), 190, 190)) { e.getPlayer().sendMessage(""The door swings open.""); e.getPlayer().getSkills().addXp(Constants.THIEVING, 210); World.removeObjectTemporary(e.getObject(), Ticks.fromMinutes(5)); World.spawnObjectTemporary(new GameObject(e.getObjectId() + 1, e.getObject().getType(), e.getObject().getRotation() - 1, e.getObject().getTile().transform(0, -1, 0)), Ticks.fromMinutes(5), true); } else { e.getPlayer().sendMessage(""You fail to pick the lock.""); e.getPlayer().unlock(); return false; } } case 6 -> e.getPlayer().unlock(); } return true; }); } }); public static ObjectClickHandler handleSouthDoors = new ObjectClickHandler(new Object[] { 52304 }, e -> { if(e.getOption().equalsIgnoreCase(""Open"")) { if(e.getPlayer().getY() <= e.getObject().getY()) { World.removeObjectTemporary(e.getObject(), Ticks.fromSeconds(10)); World.spawnObjectTemporary(new GameObject(e.getObjectId() + 1, e.getObject().getType(), e.getObject().getRotation() + 1, e.getObject().getTile().transform(0, +1, 0)), Ticks.fromSeconds(10), true); return; } if(e.getPlayer().getSkills().getLevel(Skills.THIEVING) < 35){ e.getPlayer().simpleDialogue(""You need a thieving level of at least 35 to pick this lock.""); return; } if(!e.getPlayer().getInventory().containsOneItem(1523)){ e.getPlayer().sendMessage(""This lock is too complex. You need a lockpick to be able to pick the lock.""); return; } WorldTasks.scheduleTimer(i -> { switch(i) { case 1 -> { e.getPlayer().faceObject(e.getObject()); e.getPlayer().setNextAnimation(new Animation(832)); e.getPlayer().sendMessage(""You examine the lock on the door...""); } case 3 -> { if (Utils.skillSuccess(e.getPlayer().getSkills().getLevel(Skills.THIEVING), 190, 190)) { e.getPlayer().sendMessage(""The door swings open.""); e.getPlayer().getSkills().addXp(Constants.THIEVING, 280); World.removeObjectTemporary(e.getObject(), Ticks.fromMinutes(5)); World.spawnObjectTemporary(new GameObject(e.getObjectId() + 1, e.getObject().getType(), e.getObject().getRotation() + 1, e.getObject().getTile().transform(0, +1, 0)), Ticks.fromMinutes(5), true); } else { e.getPlayer().sendMessage(""You fail to pick the lock.""); e.getPlayer().unlock(); return false; } } case 6 -> e.getPlayer().unlock(); } return true; }); } }); public static ObjectClickHandler handleNorthChests = new ObjectClickHandler(new Object[] { 52296 }, e -> { Player player = e.getPlayer(); GameObject object = e.getObject(); player.faceObject(object); if (player.getSkills().getLevel(Constants.THIEVING) < 26) { player.simpleDialogue(""You need a Thieving level of at least 26 to pick this lock.""); return; } player.sendMessage(""You attempt to pick the lock.""); player.setNextAnimation(new Animation(536)); player.lock(2); if (Utils.skillSuccess(e.getPlayer().getSkills().getLevel(Skills.THIEVING), 190, 190)) { player.getSkills().addXp(Constants.THIEVING, 30); object.setIdTemporary(e.getObjectId() + 1, Ticks.fromMinutes(1)); player.incWeeklyI(""HankyPoints"", 1); player.sendMessage(""You find a blue hankerchief.""); } else { e.getPlayer().sendMessage(""You fail to pick the lock.""); e.getPlayer().unlock(); } }); public static ObjectClickHandler handleSouthChests = new ObjectClickHandler(new Object[] { 52299 }, e -> { Player player = e.getPlayer(); GameObject object = e.getObject(); player.faceObject(object); if (player.getSkills().getLevel(Constants.THIEVING) < 35) { player.simpleDialogue(""You need a Thieving level of at least 35 to pick this lock.""); return; } player.sendMessage(""You attempt to pick the lock.""); player.setNextAnimation(new Animation(536)); player.lock(2); if (Utils.skillSuccess(e.getPlayer().getSkills().getLevel(Skills.THIEVING), 190, 190)) { player.getSkills().addXp(Constants.THIEVING, 180); player.sendMessage(""You find a red hankerchief.""); player.incWeeklyI(""HankyPoints"", 4); object.setIdTemporary(e.getObjectId() + 1, Ticks.fromMinutes(1)); } else { e.getPlayer().sendMessage(""You fail to pick the lock.""); e.getPlayer().unlock(); } }); }" "package com.rs.game.content.skills.thieving.thievesGuild; @PluginEventHandler public class Loot extends PlayerAction { private final NPC npc; private boolean success = false; public Loot(NPC npc) { this.npc = npc; } @Override public boolean start(Player player) { if (checkAll(player)) { success = successful(player); player.sendMessage(""You search the "" + npc.getDefinitions().getName().toLowerCase() + ""'s pocket...""); WorldTasks.delay(0, () -> player.setNextAnimation(new Animation(881))); setActionDelay(player, 2); player.lock(); return true; } return false; } @Override public boolean process(Player player) { return checkAll(player); } @Override public int processWithDelay(Player player) { if (!success) { player.sendMessage(""You find nothing in the "" + npc.getDefinitions().getName().toLowerCase() + ""'s pocket.""); } else { double totalXp = calculateExperience(player); player.incrementCount(npc.getDefinitions().getName() + "" pickpocketed""); player.getSkills().addXp(Constants.THIEVING, totalXp); if (player.getWeeklyI(""HankyPoints"") < HankyPoints.maxPoints(player) - 4) { player.sendMessage(""You empty the man's pocket and drape the red handkerchief over him.""); player.simpleDialogue(""You gain 4 Hanky Points.""); player.incWeeklyI(""HankyPoints"", 4); } else player.sendMessage(""You have earned the maximum number of Hanky Points this week.""); stop(player); } return -1; } public static double calculateExperience(Player player) { int playerLevel = player.getSkills().getLevel(Skills.THIEVING); double experience = 0.5 * playerLevel + 26; return experience; } @Override public void stop(Player player) { player.unlock(); player.setNextFaceEntity(null); setActionDelay(player, 1); } public boolean rollSuccess(Player player) { return Utils.skillSuccess(player.getSkills().getLevel(Constants.THIEVING), player.getAuraManager().getThievingMul() + (hasArdyCloak(player) ? 0.1 : 0.0), 185, 255); } private boolean successful(Player player) { if (!rollSuccess(player)) return false; return true; } private boolean checkAll(Player player) { if (player.isDead() || player.hasFinished() || player.hasPendingHits()) return false; if (player.getAttackedBy() != null && player.inCombat()) { player.sendMessage(""You can't do this while you're under combat.""); return false; } return true; } public static boolean hasArdyCloak(Player player) { return switch (player.getEquipment().getCapeId()) { case 15349, 19748, 9777, 9778 -> true; default -> false; }; } }" "package com.rs.game.content.skills.thieving.thievesGuild; @PluginEventHandler public class PickPocket extends PlayerAction { private final NPC npc; private boolean success = false; public PickPocket(NPC npc) { this.npc = npc; } @Override public boolean start(Player player) { if (checkAll(player)) { success = successful(player); player.faceEntity(npc); player.sendMessage(""You attempt to pick the "" + npc.getDefinitions().getName().toLowerCase() + ""'s pocket...""); WorldTasks.delay(0, () -> player.setNextAnimation(new Animation(881))); setActionDelay(player, 2); player.lock(); return true; } return false; } @Override public boolean process(Player player) { return checkAll(player); } public static double calculateExperience(Player player) { int playerLevel = player.getSkills().getLevel(Skills.THIEVING); double experience = 0.5 * playerLevel + 26; return experience; } @Override public int processWithDelay(Player player) { String[] response = new String[]{ ""No, no, not like that."", ""Spotted you!"" }; if (!success) { player.sendMessage(""You fail to pick the "" + npc.getDefinitions().getName().toLowerCase() + ""'s pocket.""); npc.setNextAnimation(new Animation(422)); npc.faceEntity(player); player.setNextAnimation(new Animation(424)); player.setNextSpotAnim(new SpotAnim(80, 5, 60)); player.sendMessage(""You've been stunned.""); player.applyHit(new Hit(player, 1, Hit.HitLook.TRUE_DAMAGE)); npc.setNextForceTalk(new ForceTalk(response[Utils.random(2)])); stop(player); } else { double totalXp = calculateExperience(player); player.incrementCount(npc.getDefinitions().getName() + "" pickpocketed""); player.getSkills().addXp(Constants.THIEVING, totalXp); if (player.getWeeklyI(""HankyPoints"") < HankyPoints.maxPoints(player)) { player.simpleDialogue(""You gain 1 Hanky Point.""); player.incWeeklyI(""HankyPoints""); } else player.sendMessage(""You have earned the maximum number of Hanky Points this week.""); stop(player); } return -1; } @Override public void stop(Player player) { player.unlock(); npc.setNextFaceEntity(null); player.setNextFaceEntity(null); setActionDelay(player, 1); if (!success) player.lock(4); } public boolean rollSuccess(Player player) { if(player.getSkills().getLevel(Skills.THIEVING) >= 95) return true; else return Utils.skillSuccess(player.getSkills().getLevel(Constants.THIEVING), player.getAuraManager().getThievingMul() + (hasArdyCloak(player) ? 0.1 : 0.0), 100, 255); } public static boolean hasArdyCloak(Player player) { return switch (player.getEquipment().getCapeId()) { case 15349, 19748, 9777, 9778 -> true; default -> false; }; } private boolean successful(Player player) { if (!rollSuccess(player)) return false; return true; } private boolean checkAll(Player player) { if (player.isDead() || player.hasFinished() || npc.isDead() || npc.hasFinished() || player.hasPendingHits()) return false; if (player.getAttackedBy() != null && player.inCombat()) { player.sendMessage(""You can't do this while you're under combat.""); return false; } if (npc.getAttackedBy() != null && npc.inCombat()) { player.sendMessage(""The npc is under combat.""); return false; } if (npc.isDead()) { player.sendMessage(""Too late, the npc is dead.""); return false; } return true; } }" "package com.rs.game.content.skills.thieving.thievesGuild; @PluginEventHandler public class PickPocketDummy extends PlayerAction { private final GameObject object; private boolean success = false; public PickPocketDummy(GameObject object) { this.object = object; } @Override public boolean start(Player player) { if (checkAll(player)) { success = successful(player); player.faceObject(object); WorldTasks.delay(0, () -> player.setNextAnimation(getAnimation())); setActionDelay(player, 2); player.lock(); return true; } return false; } @Override public boolean process(Player player) { return checkAll(player); } @Override public int processWithDelay(Player player) { int DarrenLightfinger = 11274; int commentaryStage = player.getQuestManager().getAttribs(Quest.BUYERS_AND_CELLARS).getI(""DarrenLightfingerCommentary""); boolean commentaryEnabled = player.getQuestManager().getAttribs(Quest.BUYERS_AND_CELLARS).getB(""DarrenLightfingerCommentaryEnable""); int questStage = player.getQuestStage(Quest.BUYERS_AND_CELLARS); String[] DarrenLightfingerCommentary = new String[]{ ""Just keep picking that dummy's enormous canvas pockets and I'll give you the benefit of my wisdom."", ""Remember: loose fingers, tight wrists! Do it again. Again!"", ""Calm but quick it, that's the ticket. Again!"", ""It's the eye of the kyatt, it's the will of the heist... Again!"", ""Handkerchief on, handkerchief off. Well, no, just handkerchief off, actually. Again!"", ""Oom-pah-pah! Oom... Wait, no, that's the second act."", ""Once more with feeling!"", }; if (!success) { player.sendMessage(""You failed to pick the dummies' pocket.""); } else { if(commentaryEnabled) { if(commentaryStage >= 6) { player.getQuestManager().getAttribs(Quest.BUYERS_AND_CELLARS).setB(""DarrenLightfingerCommentaryEnable"", false); } else { player.npcDialogue(DarrenLightfinger, HeadE.HAPPY_TALKING, DarrenLightfingerCommentary[player.getQuestManager().getAttribs(Quest.BUYERS_AND_CELLARS).getI(""DarrenLightfingerCommentary"")]); player.getQuestManager().getAttribs(Quest.BUYERS_AND_CELLARS).setI(""DarrenLightfingerCommentary"", commentaryStage + 1); player.getSkills().addXp(Constants.THIEVING, 4); return -1; } } if(questStage == 1) { player.unlock(); player.startConversation(new Dialogue() .addNPC(DarrenLightfinger, HeadE.HAPPY_TALKING, ""That was nicely done, young sir."") .addNPC(DarrenLightfinger, HeadE.HAPPY_TALKING, ""I think you're quite ready enough for the big wide world. Unless you'd like some advice?"") .addOptions(ops -> { ops.add(""What can you teach me?"") .addNPC(DarrenLightfinger, HeadE.CALM_TALK, ""Just keep picking that dummy's enormous canvas pockets and I'll give you the benefit of my wisdom."") .addNext(() -> { player.getQuestManager().getAttribs(Quest.BUYERS_AND_CELLARS).setB(""DarrenLightfingerCommentaryEnable"", true); player.getQuestManager().setStage(Quest.BUYERS_AND_CELLARS, 2); }); ops.add(""No, I think I've got the hang of this."", () -> player.getQuestManager().setStage(Quest.BUYERS_AND_CELLARS, 2)); }) ); } if(questStage == 2) { player.playerDialogue(HeadE.CALM_TALK, ""Can we get started? I'm ready.""); player.npcDialogue(DarrenLightfinger, HeadE.HAPPY_TALKING, ""Excellent! Have a word with me again in a second, then, and we'll get you on your way.""); } if(player.getSkills().getLevel(Skills.THIEVING) <= 15) player.getSkills().addXp(Constants.THIEVING, 4); if(player.getSkills().getLevel(Skills.THIEVING) >= 16) player.sendMessage(""There's not much more you can learn from a static dummy at this point.""); } stop(player); return -1; } @Override public void stop(Player player) { player.unlock(); player.setNextFaceEntity(null); setActionDelay(player, 1); } public boolean rollSuccess(Player player) { return Utils.skillSuccess(player.getSkills().getLevel(Constants.THIEVING), player.getAuraManager().getThievingMul(), 185, 255); } private boolean successful(Player player) { if (!rollSuccess(player)) return false; return true; } private boolean checkAll(Player player) { if (player.isDead() || player.hasFinished() || player.hasPendingHits()) return false; if (player.getAttackedBy() != null && player.inCombat()) { player.sendMessage(""You can't do this while you're under combat.""); return false; } return true; } private Animation getAnimation() { return new Animation(881); } }" "package com.rs.game.content.skills.thieving.thievesGuild; @PluginEventHandler public class PickPocketDummyMK2 extends PlayerAction { private final GameObject object; private boolean success = false; public PickPocketDummyMK2(GameObject object) { this.object = object; } @Override public boolean start(Player player) { if (checkAll(player)) { success = successful(player); player.faceObject(object); WorldTasks.delay(0, () -> player.setNextAnimation(new Animation(881))); setActionDelay(player, 2); player.lock(); return true; } return false; } @Override public boolean process(Player player) { return checkAll(player); } @Override public int processWithDelay(Player player) { if (!success) { player.sendMessage(""You failed to pick the dummies' pocket.""); } else { if(player.getSkills().getLevel(Skills.THIEVING) <= 15) player.getSkills().addXp(Constants.THIEVING, 4); if(player.getSkills().getLevel(Skills.THIEVING) >= 16) player.sendMessage(""There's not much more you can learn from a static dummy at this point.""); } stop(player); return -1; } @Override public void stop(Player player) { player.unlock(); player.setNextFaceEntity(null); setActionDelay(player, 1); } public boolean rollSuccess(Player player) { return Utils.skillSuccess(player.getSkills().getLevel(Constants.THIEVING), player.getAuraManager().getThievingMul() + (hasArdyCloak(player) ? 0.1 : 0.0), 185, 255); } private boolean successful(Player player) { if (!rollSuccess(player)) return false; return true; } private boolean checkAll(Player player) { if (player.isDead() || player.hasFinished() || player.hasPendingHits()) return false; if (player.getAttackedBy() != null && player.inCombat()) { player.sendMessage(""You can't do this while you're under combat.""); return false; } return true; } public static boolean hasArdyCloak(Player player) { return switch (player.getEquipment().getCapeId()) { case 15349, 19748, 9777, 9778 -> true; default -> false; }; } }" "package com.rs.game.content.skills.thieving.thievesGuild; @PluginEventHandler public class SafeCracking extends PlayerAction { public int animationIDCracking = 2246; public int animationIDSpikes = 615; public static GameObject object; private boolean success = false; public SafeCracking(GameObject object) { super(); SafeCracking.object = object; } @Override public boolean start(Player player) { if (checkAll(player)) { success = successful(player); player.faceObject(object); player.sendMessage(""You attempt to crack the safe.""); WorldTasks.delay(0, () -> player.setNextAnimation(new Animation(animationIDCracking))); setActionDelay(player, 4); player.lock(); return true; } return false; } @Override public boolean process(Player player) { return checkAll(player); } public static double calculateExperience(Player player) { return 0.5 * player.getSkills().getLevel(Skills.THIEVING) + 26; } @Override public int processWithDelay(Player player) { if (!success) { player.sendMessage(""You fail to crack the safe and have activated a trap.""); player.spotAnim(animationIDSpikes); player.applyHit(new Hit(player, 1, Hit.HitLook.TRUE_DAMAGE)); stop(player); } else { double totalXp = calculateExperience(player); player.getSkills().addXp(Constants.THIEVING, totalXp); if(object.getId() == 52306) { if (player.getWeeklyI(""HankyPoints"") < HankyPoints.maxPoints(player)) { player.simpleDialogue(""You gain 4 Hanky Points.""); player.incWeeklyI(""HankyPoints"", 4); } else player.sendMessage(""You have earned the maximum number of Hanky Points this week.""); } stop(player); } return -1; } @Override public void stop(Player player) { player.unlock(); setActionDelay(player, 1); if (!success) player.lock(4); } public boolean rollSuccess(Player player) { if(player.getInventory().containsItem(5560)) return Utils.skillSuccess(player.getSkills().getLevel(Constants.THIEVING), player.getAuraManager().getThievingMul(), 8, 160); else return Utils.skillSuccess(player.getSkills().getLevel(Constants.THIEVING), player.getAuraManager().getThievingMul(), 16, 192); } private boolean successful(Player player) { if (!rollSuccess(player)) return false; return true; } private boolean checkAll(Player player) { if (player.isDead() || player.hasFinished() || player.hasPendingHits()) return false; if (player.getAttackedBy() != null && player.inCombat()) { player.sendMessage(""You can't do this while you're under combat.""); return false; } return true; } public static ObjectClickHandler handleGuildSafes = new ObjectClickHandler(new Object[] { 52306 }, e -> { if(e.getOption().equalsIgnoreCase(""Crack"")) e.getPlayer().getActionManager().setAction(new SafeCracking(e.getObject())); }); }" "package com.rs.game.content.skills.util; public enum Category { ARTISANS, DUNG_SPINNING, DUNG_NEEDLE_CRAFTING, DUNG_ARROW_COMBINING, DUNG_BOWSTRINGING, DUNG_KNIFE_FLETCHING }" "package com.rs.game.content.skills.util; public class CreateAction extends PlayerAction { private final int[] anims; private final Item[][] materials; private final Item[][] products; private final double[] xp; private final int[] reqs; private final int skill; private final int delay; private final int choice; private int quantity = -1; public CreateAction(Item[][] materials, Item[][] products, double[] xp, int[] anim, int[] reqs, int skill, int delay, int choice) { anims = anim; this.materials = materials; this.products = products; this.xp = xp; this.skill = skill; this.delay = delay; this.choice = choice; this.reqs = reqs; } public CreateAction setQuantity(int quantity) { this.quantity = quantity; return this; } public boolean checkAll(Player player) { if ((choice >= materials.length) || !player.getInventory().containsItems(materials[choice]) || !player.getInventory().hasRoomFor(materials[choice], products[choice])) return false; if (reqs != null) { if (skill != -1 && player.getSkills().getLevel(skill) < reqs[choice]) { player.sendMessage(""You need a "" + Constants.SKILL_NAME[skill] + "" level of "" + reqs[choice] + "" to make a "" + products[choice][0].getName() + "".""); return false; } } return true; } @Override public boolean start(Player player) { return checkAll(player); } @Override public boolean process(Player player) { return checkAll(player); } @Override public int processWithDelay(Player player) { if (quantity != -1) { quantity--; if (quantity < 0) return -1; } if (!player.getInventory().hasRoomFor(materials[choice], products[choice])) { player.sendMessage(""You don't have enough inventory space.""); return -1; } if (anims != null) player.setNextAnimation(new Animation(anims[choice])); for (int i = 0; i < materials[choice].length; i++) player.getInventory().deleteItem(materials[choice][i]); for (int i = 0; i < products[choice].length; i++) player.getInventory().addItemDrop(products[choice][i]); if (xp != null && skill != -1) player.getSkills().addXp(skill, xp[choice]); return delay; } @Override public void stop(Player player) { } }" "package com.rs.game.content.skills.util; public class CreateActionD extends Conversation { private final int[] anims; private final Item[][] materials; private final Item[][] products; private int[] reqs; private final double[] xp; private final int skill; private final int delay; public CreateActionD(Player player, Item[][] materials, Item[][] products, int delay) { super(player); this.materials = materials; this.products = products; this.delay = delay; skill = -1; anims = null; xp = null; initialize(); create(); } public CreateActionD(Player player, Item[][] materials, Item[][] products, double[] xp, int skill, int delay) { super(player); this.materials = materials; this.products = products; this.delay = delay; this.skill = skill; anims = null; this.xp = xp; initialize(); create(); } public CreateActionD(Player player, Item[][] materials, Item[][] products, double[] xp, int[] anims, int skill, int delay) { super(player); this.materials = materials; this.products = products; this.delay = delay; this.skill = skill; this.anims = anims; this.xp = xp; initialize(); create(); } public CreateActionD(Player player, Item[][] materials, Item[][] products, double[] xp, int[] anims, int[] reqs, int skill, int delay) { super(player); this.materials = materials; this.products = products; this.delay = delay; this.skill = skill; this.anims = anims; this.xp = xp; this.reqs = reqs; initialize(); create(); } public CreateActionD(Player player, Item[][] materials, Item[][] products, double[] xp, int anim, int skill, int delay) { super(player); this.materials = materials; this.products = products; this.delay = delay; this.skill = skill; anims = new int[products.length]; for (int i = 0;i < products.length;i++) anims[i] = anim; this.xp = xp; initialize(); create(); } public CreateActionD(Player player, Item[][] materials, Item[][] products, double[] xp, int anim, int[] reqs, int skill, int delay) { super(player); this.materials = materials; this.products = products; this.delay = delay; this.skill = skill; anims = new int[products.length]; for (int i = 0;i < products.length;i++) anims[i] = anim; this.xp = xp; this.reqs = reqs; initialize(); create(); } public void initialize() { MakeXActionD makeX = new MakeXActionD(); for (int i = 0; i < this.products.length; i++) makeX.addOption(new MakeXItem(player, materials[i], products[i], xp == null ? 0.0 : xp[i], anims == null ? -1 : anims[i], reqs == null ? 1 : reqs[i], skill, delay)); addNext(makeX); } }" "package com.rs.game.content.skills.util; public class CreationAction extends PlayerAction { private final Item[] mats; private final Item product; private final int nonRemReq; private final int skill; private int cycles; private final int level; private final double experience; private final int animationId; private final int gfx; private final int delay; private boolean consistentAnim = false; public CreationAction(ReqItem product, int animationId, int gfx, int delay, int cycles) { skill = product.getSkill(); mats = product.getMaterials(); level = product.getReq(); experience = product.getXp(); this.product = product.getProduct(); nonRemReq = product.getTool(); this.animationId = animationId; this.delay = delay; this.cycles = cycles; this.gfx = gfx; } public CreationAction setConsistentAnimation(boolean consistentAnim) { this.consistentAnim = consistentAnim; return this; } public boolean checkAll(Player player) { if (skill >= 0) { int pLvl = player.getSkills().getLevel(skill); if (skill == Constants.SUMMONING) pLvl = player.getSkills().getLevelForXp(skill); if (pLvl < level) { player.sendMessage(""You need a "" + Constants.SKILL_NAME[skill] + "" level of "" + level + "" to make that.""); return false; } } return continueNextCycle(player); } @Override public boolean start(Player player) { if (!checkAll(player)) return false; if (delay == -2) { if (animationId > 0) player.setNextAnimation(new Animation(animationId)); else if (animationId == -1) { int anim = -1; if (nonRemReq != -1) anim = AnimationDefinitions.getAnimationWithItem(nonRemReq); if (anim == -1) anim = AnimationDefinitions.getAnimationWithItem(product.getId()); for (Item item : mats) if (item != null) { if (anim != -1) break; anim = AnimationDefinitions.getAnimationWithItem(item.getId()); } if (anim != -1) player.setNextAnimation(new Animation(anim)); } if (gfx != -1) player.setNextSpotAnim(new SpotAnim(gfx)); double xp = 0; while (cycles > 0) { cycles--; if (!continueNextCycle(player)) break; for (Item item : mats) if (item != null) player.getInventory().deleteItem(item); xp += experience; player.getInventory().addItem(product.getId(), product.getAmount(), true); } if (skill >= 0 && xp > 0) player.getSkills().addXp(skill, xp); return false; } return true; } @Override public boolean process(Player player) { return continueNextCycle(player) && cycles > 0; } private boolean continueNextCycle(Player player) { if (!player.getInventory().hasFreeSlots(mats, product)) return false; if (consistentAnim) player.setNextAnimation(new Animation(animationId)); if (mats != null && !player.getInventory().containsItems(mats)) { StringBuilder mat = new StringBuilder(); for (Item item : mats) if (item != null) { mat.append(item.getAmount()).append("" ""); mat.append(item.getDefinitions().getName()).append("", ""); } player.sendMessage(""You need "" + mat.toString().toLowerCase().trim().substring(0, mat.length() - 2) + "" to create a "" + product.getName().toLowerCase() + "".""); return false; } if (nonRemReq != -1 && !player.getInventory().containsItem(nonRemReq, 1)) { player.sendMessage(""You require a "" + ItemDefinitions.getDefs(nonRemReq).name.toLowerCase() + "" to create this.""); return false; } return true; } @Override public int processWithDelay(Player player) { cycles--; if (animationId > 0) player.setNextAnimation(new Animation(animationId)); else if (animationId == -1) { int anim = -1; if (nonRemReq != -1) anim = AnimationDefinitions.getAnimationWithItem(nonRemReq); if (anim == -1) anim = AnimationDefinitions.getAnimationWithItem(product.getId()); for (Item item : mats) if (item != null) { if (anim != -1) break; anim = AnimationDefinitions.getAnimationWithItem(item.getId()); } if (anim != -1) player.setNextAnimation(new Animation(anim)); } if (gfx != -1) player.setNextSpotAnim(new SpotAnim(gfx)); for (Item item : mats) if (item != null) player.getInventory().deleteItem(item); if (skill >= 0) player.getSkills().addXp(skill, experience); player.getInventory().addItem(product.getId(), product.getAmount()); return delay; } @Override public void stop(Player player) { setActionDelay(player, delay); } }" "package com.rs.game.content.skills.util; public class CreationActionD extends Conversation { public CreationActionD(Player player, Category category, int material, int animation, int delay, int gfx, int product, CreationAction customAction, ReqItem[] options, boolean consistentAnim) { super(player); options = product != -1 ? new ReqItem[] { ReqItem.getRequirements(product) } : options != null ? options : ReqItem.getProducts(category, material); var makeX = addNext(new MakeXStatement(""What would you like to make?"", Arrays.stream(options).mapToInt(item -> item.getProduct().getId()).toArray(), 28)); for (ReqItem item : options) { makeX.addNext(() -> { int quantity = MakeXStatement.getQuantity(player); ReqItem produce = product == -1 ? item : ReqItem.getRequirements(product); player.getActionManager().setAction(customAction != null ? customAction : new CreationAction(produce, animation, gfx, delay, quantity).setConsistentAnimation(consistentAnim)); }); } create(); } public CreationActionD(Player player, Category category, int material, int animation, int delay) { this(player, category, material, animation, delay, -1, -1, null, null, false); } public CreationActionD(Player player, int product, int animation, int delay) { this(player, null, -1, animation, delay, -1, -1, null, null, false); } public CreationActionD(Player player, Category category, ReqItem[] options, int animation, int delay) { this(player, category, -1, animation, delay, -1, -1, null, options, false); } public CreationActionD(Player player, Category category, int material, int animation, int delay, CreationAction action, boolean consistentAnim) { this(player, category, material, animation, delay, -1, -1, action, null, false); } public CreationActionD(Player player, int product, int animation, int delay, CreationAction action) { this(player, null, -1, animation, delay, -1, -1, action, null, false); } public CreationActionD(Player player, Category category, ReqItem[] options, int animation, int delay, CreationAction action) { this(player, category, -1, animation, delay, -1, -1, action, options, false); } public CreationActionD(Player player, Category category, int material, int animation, int delay, boolean consistentAnim) { this(player, category, material, animation, delay, -1, -1, null, null, consistentAnim); } public CreationActionD(Player player, int product, int animation, int delay, boolean consistentAnim) { this(player, null, -1, animation, delay, -1, -1, null, null, consistentAnim); } public CreationActionD(Player player, Category category, ReqItem[] options, int animation, int delay, boolean consistentAnim) { this(player, category, -1, animation, delay, -1, -1, null, options, consistentAnim); } }" "package com.rs.game.content.skills.util; public enum ReqItem { CANNON_COG(Category.ARTISANS, new Item(20475, 1), Constants.SMITHING, 62, 38.0, 20476, new Item[] { new Item(20638, 1) }), BROKEN_CANNON_BARREL2(Category.ARTISANS, new Item(20478, 1), Constants.SMITHING, 62, 7.0, -1, new Item[] { new Item(20477, 1) }), BROKEN_CANNON_BARREL3(Category.ARTISANS, new Item(20479, 1), Constants.SMITHING, 62, 7.0, -1, new Item[] { new Item(20478, 1) }), CANNON_BARREL(Category.ARTISANS, new Item(20480, 1), Constants.SMITHING, 62, 7.0, -1, new Item[] { new Item(20479, 1) }), PIPE(Category.ARTISANS, new Item(20482, 1), Constants.SMITHING, 62, 3.0, 20483, new Item[] { new Item(20481, 1) }), EMPTY_FUSE_BOX(Category.ARTISANS, new Item(20487, 1), Constants.SMITHING, 62, 15.0, -1, new Item[] { new Item(20488, 1) }), FLINT(Category.ARTISANS, new Item(20491, 1), Constants.SMITHING, 62, 15.0, -1, new Item[] { new Item(20490, 1) }), CANNONBALL2(Category.ARTISANS, new Item(20492, 4), Constants.SMITHING, 62, 38.0, 20493, new Item[] { new Item(20638, 1) }), BRONZE_RAILS(Category.ARTISANS, new Item(20506, 1), Constants.SMITHING, 1, 1.0, -1, new Item[] { new Item(20502, 1) }), BRONZE_BASE_PLATE(Category.ARTISANS, new Item(20507, 1), Constants.SMITHING, 2, 1.0, -1, new Item[] { new Item(20502, 1) }), BRONZE_SPIKES(Category.ARTISANS, new Item(20508, 1), Constants.SMITHING, 5, 1.0, -1, new Item[] { new Item(20502, 1) }), BRONZE_JOINT(Category.ARTISANS, new Item(20509, 1), Constants.SMITHING, 8, 1.0, -1, new Item[] { new Item(20502, 1) }), BRONZE_TIE(Category.ARTISANS, new Item(20510, 1), Constants.SMITHING, 11, 1.0, -1, new Item[] { new Item(20502, 1) }), BRONZE_TRACK_40(Category.ARTISANS, new Item(20511, 1), Constants.SMITHING, 3, 6.0, -1, new Item[] { new Item(20506, 1), new Item(20507, 1) }), BRONZE_TRACK_60(Category.ARTISANS, new Item(20512, 1), Constants.SMITHING, 6, 7.0, -1, new Item[] { new Item(20508, 1), new Item(20511, 1) }), BRONZE_TRACK_80(Category.ARTISANS, new Item(20513, 1), Constants.SMITHING, 9, 9.0, -1, new Item[] { new Item(20509, 1), new Item(20512, 1) }), BRONZE_TRACK_100(Category.ARTISANS, new Item(20514, 1), Constants.SMITHING, 12, 10.0, -1, new Item[] { new Item(20510, 1), new Item(20513, 1) }), IRON_RAILS(Category.ARTISANS, new Item(20515, 1), Constants.SMITHING, 15, 5.0, -1, new Item[] { new Item(20503, 1) }), IRON_BASE_PLATE(Category.ARTISANS, new Item(20516, 1), Constants.SMITHING, 19, 5.0, -1, new Item[] { new Item(20503, 1) }), IRON_SPIKES(Category.ARTISANS, new Item(20517, 1), Constants.SMITHING, 24, 5.0, -1, new Item[] { new Item(20503, 1) }), IRON_JOINT(Category.ARTISANS, new Item(20518, 1), Constants.SMITHING, 29, 5.0, -1, new Item[] { new Item(20503, 1) }), IRON_TIE(Category.ARTISANS, new Item(20519, 1), Constants.SMITHING, 34, 5.0, -1, new Item[] { new Item(20503, 1) }), STEEL_RAILS(Category.ARTISANS, new Item(20520, 1), Constants.SMITHING, 39, 8.0, -1, new Item[] { new Item(20504, 1) }), STEEL_BASE_PLATE(Category.ARTISANS, new Item(20521, 1), Constants.SMITHING, 44, 8.0, -1, new Item[] { new Item(20504, 1) }), STEEL_SPIKES(Category.ARTISANS, new Item(20522, 1), Constants.SMITHING, 49, 8.0, -1, new Item[] { new Item(20504, 1) }), STEEL_JOINT(Category.ARTISANS, new Item(20523, 1), Constants.SMITHING, 54, 8.0, -1, new Item[] { new Item(20504, 1) }), STEEL_TIE(Category.ARTISANS, new Item(20524, 1), Constants.SMITHING, 59, 8.0, -1, new Item[] { new Item(20504, 1) }), IRON_TRACK_40(Category.ARTISANS, new Item(20525, 1), Constants.SMITHING, 20, 10.0, -1, new Item[] { new Item(20515, 1), new Item(20516, 1) }), IRON_TRACK_60(Category.ARTISANS, new Item(20526, 1), Constants.SMITHING, 25, 11.0, -1, new Item[] { new Item(20517, 1), new Item(20525, 1) }), IRON_TRACK_80(Category.ARTISANS, new Item(20527, 1), Constants.SMITHING, 30, 12.0, -1, new Item[] { new Item(20518, 1), new Item(20526, 1) }), IRON_TRACK_100(Category.ARTISANS, new Item(20528, 1), Constants.SMITHING, 35, 13.0, -1, new Item[] { new Item(20519, 1), new Item(20527, 1) }), STEEL_TRACK_40(Category.ARTISANS, new Item(20529, 1), Constants.SMITHING, 45, 13.0, -1, new Item[] { new Item(20520, 1), new Item(20521, 1) }), STEEL_TRACK_60(Category.ARTISANS, new Item(20530, 1), Constants.SMITHING, 50, 16.0, -1, new Item[] { new Item(20522, 1), new Item(20529, 1) }), STEEL_TRACK_80(Category.ARTISANS, new Item(20531, 1), Constants.SMITHING, 55, 22.0, -1, new Item[] { new Item(20523, 1), new Item(20530, 1) }), STEEL_TRACK_100(Category.ARTISANS, new Item(20532, 1), Constants.SMITHING, 60, 25.0, -1, new Item[] { new Item(20524, 1), new Item(20531, 1) }), IRON_INGOT_HEATED(Category.ARTISANS, new Item(20567, 1), Skills.NONE, 70, 0.0, 20565, new Item[] { new Item(20648, 1) }), STEEL_INGOT_HEATED(Category.ARTISANS, new Item(20568, 1), Skills.NONE, 75, 0.0, 20565, new Item[] { new Item(20649, 1) }), MITHRIL_INGOT_HEATED(Category.ARTISANS, new Item(20569, 1), Skills.NONE, 80, 0.0, 20565, new Item[] { new Item(20650, 1) }), ADAMANT_INGOT_HEATED(Category.ARTISANS, new Item(20570, 1), Skills.NONE, 85, 0.0, 20565, new Item[] { new Item(20651, 1) }), RUNE_INGOT_HEATED(Category.ARTISANS, new Item(20571, 1), Skills.NONE, 90, 0.0, 20565, new Item[] { new Item(20652, 1) }), MINER_HELM_IRON(Category.ARTISANS, new Item(20572, 1), Constants.SMITHING, 30, 101.0, -1, new Item[] { new Item(20632, 1) }), MINER_HELM_STEEL(Category.ARTISANS, new Item(20573, 1), Constants.SMITHING, 45, 131.0, -1, new Item[] { new Item(20633, 1) }), MINER_HELM_MITHRIL(Category.ARTISANS, new Item(20574, 1), Constants.SMITHING, 60, 136.0, -1, new Item[] { new Item(20634, 1) }), MINER_HELM_ADAMANT(Category.ARTISANS, new Item(20575, 1), Constants.SMITHING, 70, 278.0, -1, new Item[] { new Item(20635, 1) }), MINER_HELM_RUNE(Category.ARTISANS, new Item(20576, 1), Constants.SMITHING, 90, 505.0, -1, new Item[] { new Item(20636, 1) }), MINER_BOOTS_IRON(Category.ARTISANS, new Item(20577, 1), Constants.SMITHING, 30, 101.0, -1, new Item[] { new Item(20632, 1) }), MINER_BOOTS_STEEL(Category.ARTISANS, new Item(20578, 1), Constants.SMITHING, 45, 131.0, -1, new Item[] { new Item(20633, 1) }), MINER_BOOTS_MITHRIL(Category.ARTISANS, new Item(20579, 1), Constants.SMITHING, 60, 136.0, -1, new Item[] { new Item(20634, 1) }), MINER_BOOTS_ADAMANT(Category.ARTISANS, new Item(20580, 1), Constants.SMITHING, 70, 278.0, -1, new Item[] { new Item(20635, 1) }), MINER_BOOTS_RUNE(Category.ARTISANS, new Item(20581, 1), Constants.SMITHING, 90, 505.0, -1, new Item[] { new Item(20636, 1) }), MINER_CHESTPLATE_IRON(Category.ARTISANS, new Item(20582, 1), Constants.SMITHING, 30, 101.0, -1, new Item[] { new Item(20632, 1) }), MINER_CHESTPLATE_STEEL(Category.ARTISANS, new Item(20583, 1), Constants.SMITHING, 45, 131.0, -1, new Item[] { new Item(20633, 1) }), MINER_CHESTPLATE_MITHRIL(Category.ARTISANS, new Item(20584, 1), Constants.SMITHING, 60, 136.0, -1, new Item[] { new Item(20634, 1) }), MINER_CHESTPLATE_ADAMANT(Category.ARTISANS, new Item(20585, 1), Constants.SMITHING, 70, 278.0, -1, new Item[] { new Item(20635, 1) }), MINER_CHESTPLATE_RUNE(Category.ARTISANS, new Item(20586, 1), Constants.SMITHING, 90, 505.0, -1, new Item[] { new Item(20636, 1) }), MINER_GAUNTLETS_IRON(Category.ARTISANS, new Item(20587, 1), Constants.SMITHING, 30, 101.0, -1, new Item[] { new Item(20632, 1) }), MINER_GAUNTLETS_STEEL(Category.ARTISANS, new Item(20588, 1), Constants.SMITHING, 45, 131.0, -1, new Item[] { new Item(20633, 1) }), MINER_GAUNTLETS_MITHRIL(Category.ARTISANS, new Item(20589, 1), Constants.SMITHING, 60, 136.0, -1, new Item[] { new Item(20634, 1) }), MINER_GAUNTLETS_ADAMANT(Category.ARTISANS, new Item(20590, 1), Constants.SMITHING, 70, 278.0, -1, new Item[] { new Item(20635, 1) }), MINER_GAUNTLETS_RUNE(Category.ARTISANS, new Item(20591, 1), Constants.SMITHING, 90, 505.0, -1, new Item[] { new Item(20636, 1) }), WARRIOR_HELM_IRON(Category.ARTISANS, new Item(20592, 1), Constants.SMITHING, 30, 202.0, -1, new Item[] { new Item(20637, 1) }), WARRIOR_HELM_STEEL(Category.ARTISANS, new Item(20593, 1), Constants.SMITHING, 45, 253.0, -1, new Item[] { new Item(20638, 1) }), WARRIOR_HELM_MITHRIL(Category.ARTISANS, new Item(20594, 1), Constants.SMITHING, 60, 316.0, -1, new Item[] { new Item(20639, 1) }), WARRIOR_HELM_ADAMANT(Category.ARTISANS, new Item(20595, 1), Constants.SMITHING, 70, 455.0, -1, new Item[] { new Item(20640, 1) }), WARRIOR_HELM_RUNE(Category.ARTISANS, new Item(20596, 1), Constants.SMITHING, 90, 631.0, -1, new Item[] { new Item(20641, 1) }), WARRIOR_BOOTS_IRON(Category.ARTISANS, new Item(20597, 1), Constants.SMITHING, 30, 202.0, -1, new Item[] { new Item(20637, 1) }), WARRIOR_BOOTS_STEEL(Category.ARTISANS, new Item(20598, 1), Constants.SMITHING, 45, 253.0, -1, new Item[] { new Item(20638, 1) }), WARRIOR_BOOTS_MITHRIL(Category.ARTISANS, new Item(20599, 1), Constants.SMITHING, 60, 316.0, -1, new Item[] { new Item(20639, 1) }), WARRIOR_BOOTS_ADAMANT(Category.ARTISANS, new Item(20600, 1), Constants.SMITHING, 70, 455.0, -1, new Item[] { new Item(20640, 1) }), WARRIOR_BOOTS_RUNE(Category.ARTISANS, new Item(20601, 1), Constants.SMITHING, 90, 631.0, -1, new Item[] { new Item(20641, 1) }), WARRIOR_CHESTPLATE_IRON(Category.ARTISANS, new Item(20602, 1), Constants.SMITHING, 30, 202.0, -1, new Item[] { new Item(20637, 1) }), WARRIOR_CHESTPLATE_STEEL(Category.ARTISANS, new Item(20603, 1), Constants.SMITHING, 45, 253.0, -1, new Item[] { new Item(20638, 1) }), WARRIOR_CHESTPLATE_MITHRIL(Category.ARTISANS, new Item(20604, 1), Constants.SMITHING, 60, 316.0, -1, new Item[] { new Item(20639, 1) }), WARRIOR_CHESTPLATE_ADAMANT(Category.ARTISANS, new Item(20605, 1), Constants.SMITHING, 70, 455.0, -1, new Item[] { new Item(20640, 1) }), WARRIOR_CHESTPLATE_RUNE(Category.ARTISANS, new Item(20606, 1), Constants.SMITHING, 90, 631.0, -1, new Item[] { new Item(20641, 1) }), WARRIOR_GAUNTLETS_IRON(Category.ARTISANS, new Item(20607, 1), Constants.SMITHING, 30, 202.0, -1, new Item[] { new Item(20637, 1) }), WARRIOR_GAUNTLETS_STEEL(Category.ARTISANS, new Item(20608, 1), Constants.SMITHING, 45, 253.0, -1, new Item[] { new Item(20638, 1) }), WARRIOR_GAUNTLETS_MITHRIL(Category.ARTISANS, new Item(20609, 1), Constants.SMITHING, 60, 316.0, -1, new Item[] { new Item(20639, 1) }), WARRIOR_GAUNTLETS_ADAMANT(Category.ARTISANS, new Item(20610, 1), Constants.SMITHING, 70, 455.0, -1, new Item[] { new Item(20640, 1) }), WARRIOR_GAUNTLETS_RUNE(Category.ARTISANS, new Item(20611, 1), Constants.SMITHING, 90, 631.0, -1, new Item[] { new Item(20641, 1) }), SMITHS_HELM_IRON(Category.ARTISANS, new Item(20612, 1), Constants.SMITHING, 30, 240.0, -1, new Item[] { new Item(20642, 1) }), SMITHS_HELM_STEEL(Category.ARTISANS, new Item(20613, 1), Constants.SMITHING, 45, 389.0, -1, new Item[] { new Item(20643, 1) }), SMITHS_HELM_MITHRIL(Category.ARTISANS, new Item(20614, 1), Constants.SMITHING, 60, 404.0, -1, new Item[] { new Item(20644, 1) }), SMITHS_HELM_ADAMANT(Category.ARTISANS, new Item(20615, 1), Constants.SMITHING, 70, 568.0, -1, new Item[] { new Item(20645, 1) }), SMITHS_HELM_RUNE(Category.ARTISANS, new Item(20616, 1), Constants.SMITHING, 90, 758.0, -1, new Item[] { new Item(20646, 1) }), SMITHS_BOOTS_IRON(Category.ARTISANS, new Item(20617, 1), Constants.SMITHING, 30, 240.0, -1, new Item[] { new Item(20642, 1) }), SMITHS_BOOTS_STEEL(Category.ARTISANS, new Item(20618, 1), Constants.SMITHING, 45, 389.0, -1, new Item[] { new Item(20643, 1) }), SMITHS_BOOTS_MITHRIL(Category.ARTISANS, new Item(20619, 1), Constants.SMITHING, 60, 404.0, -1, new Item[] { new Item(20644, 1) }), SMITHS_BOOTS_ADAMANT(Category.ARTISANS, new Item(20620, 1), Constants.SMITHING, 70, 568.0, -1, new Item[] { new Item(20645, 1) }), SMITHS_BOOTS_RUNE(Category.ARTISANS, new Item(20621, 1), Constants.SMITHING, 90, 758.0, -1, new Item[] { new Item(20646, 1) }), SMITHS_CHESTPLATE_IRON(Category.ARTISANS, new Item(20622, 1), Constants.SMITHING, 30, 240.0, -1, new Item[] { new Item(20642, 1) }), SMITHS_CHESTPLATE_STEEL(Category.ARTISANS, new Item(20623, 1), Constants.SMITHING, 45, 389.0, -1, new Item[] { new Item(20643, 1) }), SMITHS_CHESTPLATE_MITHRIL(Category.ARTISANS, new Item(20624, 1), Constants.SMITHING, 60, 404.0, -1, new Item[] { new Item(20644, 1) }), SMITHS_CHESTPLATE_ADAMANT(Category.ARTISANS, new Item(20625, 1), Constants.SMITHING, 70, 568.0, -1, new Item[] { new Item(20645, 1) }), SMITHS_CHESTPLATE_RUNE(Category.ARTISANS, new Item(20626, 1), Constants.SMITHING, 90, 758.0, -1, new Item[] { new Item(20646, 1) }), SMITHS_GAUNTLETS_IRON(Category.ARTISANS, new Item(20627, 1), Constants.SMITHING, 30, 240.0, -1, new Item[] { new Item(20642, 1) }), SMITHS_GAUNTLETS_STEEL(Category.ARTISANS, new Item(20628, 1), Constants.SMITHING, 45, 389.0, -1, new Item[] { new Item(20643, 1) }), SMITHS_GAUNTLETS_MITHRIL(Category.ARTISANS, new Item(20629, 1), Constants.SMITHING, 60, 404.0, -1, new Item[] { new Item(20644, 1) }), SMITHS_GAUNTLETS_ADAMANT(Category.ARTISANS, new Item(20630, 1), Constants.SMITHING, 70, 568.0, -1, new Item[] { new Item(20645, 1) }), SMITHS_GAUNTLETS_RUNE(Category.ARTISANS, new Item(20631, 1), Constants.SMITHING, 90, 758.0, -1, new Item[] { new Item(20646, 1) }), IRON_INGOT_I(Category.ARTISANS, new Item(20632, 1), Skills.NONE, 1, 0.0, -1, new Item[] { new Item(25629, 1) }), STEEL_INGOT_I(Category.ARTISANS, new Item(20633, 1), Skills.NONE, 1, 0.0, -1, new Item[] { new Item(25629, 1), new Item(25630, 2) }), MITHRIL_INGOT_I(Category.ARTISANS, new Item(20634, 1), Skills.NONE, 1, 0.0, -1, new Item[] { new Item(25631, 1), new Item(25630, 4) }), ADAMANT_INGOT_I(Category.ARTISANS, new Item(20635, 1), Skills.NONE, 1, 0.0, -1, new Item[] { new Item(25632, 1), new Item(25630, 6) }), RUNE_INGOT_I(Category.ARTISANS, new Item(20636, 1), Skills.NONE, 1, 0.0, -1, new Item[] { new Item(25633, 1), new Item(25630, 8) }), IRON_INGOT_II(Category.ARTISANS, new Item(20637, 1), Skills.NONE, 1, 0.0, -1, new Item[] { new Item(25629, 9) }), STEEL_INGOT_II(Category.ARTISANS, new Item(20638, 1), Skills.NONE, 1, 0.0, -1, new Item[] { new Item(25629, 4), new Item(25630, 7) }), MITHRIL_INGOT_II(Category.ARTISANS, new Item(20639, 1), Skills.NONE, 1, 0.0, -1, new Item[] { new Item(25631, 3), new Item(25630, 12) }), ADAMANT_INGOT_II(Category.ARTISANS, new Item(20640, 1), Skills.NONE, 1, 0.0, -1, new Item[] { new Item(25632, 3), new Item(25630, 14) }), RUNE_INGOT_II(Category.ARTISANS, new Item(20641, 1), Skills.NONE, 1, 0.0, -1, new Item[] { new Item(25633, 2), new Item(25630, 16) }), IRON_INGOT_III(Category.ARTISANS, new Item(20642, 1), Skills.NONE, 1, 0.0, -1, new Item[] { new Item(25629, 12) }), STEEL_INGOT_III(Category.ARTISANS, new Item(20643, 1), Skills.NONE, 1, 0.0, -1, new Item[] { new Item(25629, 9), new Item(25630, 17) }), MITHRIL_INGOT_III(Category.ARTISANS, new Item(20644, 1), Skills.NONE, 1, 0.0, -1, new Item[] { new Item(25631, 6), new Item(25630, 24) }), ADAMANT_INGOT_III(Category.ARTISANS, new Item(20645, 1), Skills.NONE, 1, 0.0, -1, new Item[] { new Item(25632, 4), new Item(25630, 22) }), RUNE_INGOT_III(Category.ARTISANS, new Item(20646, 1), Skills.NONE, 1, 0.0, -1, new Item[] { new Item(25633, 4), new Item(25630, 30) }), IRON_INGOT_IV(Category.ARTISANS, new Item(20648, 1), Skills.NONE, 1, 0.0, -1, new Item[] { new Item(25629, 75) }), STEEL_INGOT_IV(Category.ARTISANS, new Item(20649, 1), Skills.NONE, 1, 0.0, -1, new Item[] { new Item(25629, 40), new Item(25630, 80) }), MITHRIL_INGOT_IV(Category.ARTISANS, new Item(20650, 1), Skills.NONE, 1, 0.0, -1, new Item[] { new Item(25631, 30), new Item(25630, 120) }), ADAMANT_INGOT_IV(Category.ARTISANS, new Item(20651, 1), Skills.NONE, 1, 0.0, -1, new Item[] { new Item(25632, 25), new Item(25630, 150) }), RUNE_INGOT_IV(Category.ARTISANS, new Item(20652, 1), Skills.NONE, 1, 0.0, -1, new Item[] { new Item(25633, 18), new Item(25630, 144) }), SALVE_CLOTH(Category.DUNG_SPINNING, new Item(17468, 1), Constants.CRAFTING, 1, 2.0, -1, new Item[] { new Item(17448, 1) }), WILDERCRESS_CLOTH(Category.DUNG_SPINNING, new Item(17470, 1), Constants.CRAFTING, 10, 3.0, -1, new Item[] { new Item(17450, 1) }), BLIGHTLEAF_CLOTH(Category.DUNG_SPINNING, new Item(17472, 1), Constants.CRAFTING, 20, 3.0, -1, new Item[] { new Item(17452, 1) }), ROSEBLOOD_CLOTH(Category.DUNG_SPINNING, new Item(17474, 1), Constants.CRAFTING, 30, 4.0, -1, new Item[] { new Item(17454, 1) }), BRYLL_CLOTH(Category.DUNG_SPINNING, new Item(17476, 1), Constants.CRAFTING, 40, 5.0, -1, new Item[] { new Item(17456, 1) }), DUSKWEED_CLOTH(Category.DUNG_SPINNING, new Item(17478, 1), Constants.CRAFTING, 50, 6.0, -1, new Item[] { new Item(17458, 1) }), SOULBELL_CLOTH(Category.DUNG_SPINNING, new Item(17480, 1), Constants.CRAFTING, 60, 7.0, -1, new Item[] { new Item(17460, 1) }), ECTOCLOTH(Category.DUNG_SPINNING, new Item(17482, 1), Constants.CRAFTING, 70, 9.0, -1, new Item[] { new Item(17462, 1) }), RUNIC_CLOTH(Category.DUNG_SPINNING, new Item(17484, 1), Constants.CRAFTING, 80, 10.0, -1, new Item[] { new Item(17464, 1) }), SPIRITBLOOM_CLOTH(Category.DUNG_SPINNING, new Item(17486, 1), Constants.CRAFTING, 90, 12.0, -1, new Item[] { new Item(17466, 1) }), SALVE_HOOD(Category.DUNG_NEEDLE_CRAFTING, new Item(16735, 1), Constants.CRAFTING, 4, 31.0, 17446, new Item[] { new Item(17468, 2) }), WILDERCRESS_HOOD(Category.DUNG_NEEDLE_CRAFTING, new Item(16737, 1), Constants.CRAFTING, 14, 48.0, 17446, new Item[] { new Item(17470, 2) }), BLIGHTLEAF_HOOD(Category.DUNG_NEEDLE_CRAFTING, new Item(16739, 1), Constants.CRAFTING, 24, 65.0, 17446, new Item[] { new Item(17472, 2) }), ROSEBLOOD_HOOD(Category.DUNG_NEEDLE_CRAFTING, new Item(16741, 1), Constants.CRAFTING, 34, 82.0, 17446, new Item[] { new Item(17474, 2) }), BRYLL_HOOD(Category.DUNG_NEEDLE_CRAFTING, new Item(16743, 1), Constants.CRAFTING, 44, 99.0, 17446, new Item[] { new Item(17476, 2) }), DUSKWEED_HOOD(Category.DUNG_NEEDLE_CRAFTING, new Item(16745, 1), Constants.CRAFTING, 54, 116.0, 17446, new Item[] { new Item(17478, 2) }), SOULBELL_HOOD(Category.DUNG_NEEDLE_CRAFTING, new Item(16747, 1), Constants.CRAFTING, 64, 133.0, 17446, new Item[] { new Item(17480, 2) }), ECTOHOOD(Category.DUNG_NEEDLE_CRAFTING, new Item(16749, 1), Constants.CRAFTING, 74, 150.0, 17446, new Item[] { new Item(17482, 2) }), RUNIC_HOOD(Category.DUNG_NEEDLE_CRAFTING, new Item(16751, 1), Constants.CRAFTING, 84, 167.0, 17446, new Item[] { new Item(17484, 2) }), SPIRITBLOOM_HOOD(Category.DUNG_NEEDLE_CRAFTING, new Item(16753, 1), Constants.CRAFTING, 94, 184.0, 17446, new Item[] { new Item(17486, 2) }), SALVE_ROBE_BOTTOM(Category.DUNG_NEEDLE_CRAFTING, new Item(16845, 1), Constants.CRAFTING, 6, 52.0, 17446, new Item[] { new Item(17468, 3) }), WILDERCRESS_ROBE_BOTTOM(Category.DUNG_NEEDLE_CRAFTING, new Item(16847, 1), Constants.CRAFTING, 16, 78.0, 17446, new Item[] { new Item(17470, 3) }), BLIGHTLEAF_ROBE_BOTTOM(Category.DUNG_NEEDLE_CRAFTING, new Item(16849, 1), Constants.CRAFTING, 26, 103.0, 17446, new Item[] { new Item(17472, 3) }), ROSEBLOOD_ROBE_BOTTOM(Category.DUNG_NEEDLE_CRAFTING, new Item(16851, 1), Constants.CRAFTING, 36, 129.0, 17446, new Item[] { new Item(17474, 3) }), BRYLL_ROBE_BOTTOM(Category.DUNG_NEEDLE_CRAFTING, new Item(16853, 1), Constants.CRAFTING, 46, 154.0, 17446, new Item[] { new Item(17476, 3) }), DUSKWEED_ROBE_BOTTOM(Category.DUNG_NEEDLE_CRAFTING, new Item(16855, 1), Constants.CRAFTING, 56, 180.0, 17446, new Item[] { new Item(17478, 3) }), SOULBELL_ROBE_BOTTOM(Category.DUNG_NEEDLE_CRAFTING, new Item(16857, 1), Constants.CRAFTING, 66, 205.0, 17446, new Item[] { new Item(17480, 3) }), ECTOROBE_BOTTOM(Category.DUNG_NEEDLE_CRAFTING, new Item(16859, 1), Constants.CRAFTING, 76, 231.0, 17446, new Item[] { new Item(17482, 3) }), RUNIC_ROBE_BOTTOM(Category.DUNG_NEEDLE_CRAFTING, new Item(16861, 1), Constants.CRAFTING, 86, 256.0, 17446, new Item[] { new Item(17484, 3) }), SPIRITBLOOM_ROBE_BOTTOM(Category.DUNG_NEEDLE_CRAFTING, new Item(16863, 1), Constants.CRAFTING, 96, 282.0, 17446, new Item[] { new Item(17486, 3) }), SALVE_SHOES(Category.DUNG_NEEDLE_CRAFTING, new Item(16911, 1), Constants.CRAFTING, 2, 14.0, 17446, new Item[] { new Item(17468, 1) }), WILDERCRESS_SHOES(Category.DUNG_NEEDLE_CRAFTING, new Item(16913, 1), Constants.CRAFTING, 12, 22.0, 17446, new Item[] { new Item(17470, 1) }), BLIGHTLEAF_SHOES(Category.DUNG_NEEDLE_CRAFTING, new Item(16915, 1), Constants.CRAFTING, 22, 31.0, 17446, new Item[] { new Item(17472, 1) }), ROSEBLOOD_SHOES(Category.DUNG_NEEDLE_CRAFTING, new Item(16917, 1), Constants.CRAFTING, 32, 39.0, 17446, new Item[] { new Item(17474, 1) }), BRYLL_SHOES(Category.DUNG_NEEDLE_CRAFTING, new Item(16919, 1), Constants.CRAFTING, 42, 48.0, 17446, new Item[] { new Item(17476, 1) }), DUSKWEED_SHOES(Category.DUNG_NEEDLE_CRAFTING, new Item(16921, 1), Constants.CRAFTING, 52, 56.0, 17446, new Item[] { new Item(17478, 1) }), SOULBELL_SHOES(Category.DUNG_NEEDLE_CRAFTING, new Item(16923, 1), Constants.CRAFTING, 62, 65.0, 17446, new Item[] { new Item(17480, 1) }), ECTOSHOES(Category.DUNG_NEEDLE_CRAFTING, new Item(16925, 1), Constants.CRAFTING, 72, 73.0, 17446, new Item[] { new Item(17482, 1) }), RUNIC_SHOES(Category.DUNG_NEEDLE_CRAFTING, new Item(16927, 1), Constants.CRAFTING, 82, 82.0, 17446, new Item[] { new Item(17484, 1) }), SPIRITBLOOM_SHOES(Category.DUNG_NEEDLE_CRAFTING, new Item(16929, 1), Constants.CRAFTING, 92, 90.0, 17446, new Item[] { new Item(17486, 1) }), SALVE_GLOVES(Category.DUNG_NEEDLE_CRAFTING, new Item(17151, 1), Constants.CRAFTING, 1, 12.0, 17446, new Item[] { new Item(17468, 1) }), WILDERCRESS_GLOVES(Category.DUNG_NEEDLE_CRAFTING, new Item(17153, 1), Constants.CRAFTING, 10, 21.0, 17446, new Item[] { new Item(17470, 1) }), BLIGHTLEAF_GLOVES(Category.DUNG_NEEDLE_CRAFTING, new Item(17155, 1), Constants.CRAFTING, 20, 29.0, 17446, new Item[] { new Item(17472, 1) }), ROSEBLOOD_GLOVES(Category.DUNG_NEEDLE_CRAFTING, new Item(17157, 1), Constants.CRAFTING, 30, 38.0, 17446, new Item[] { new Item(17474, 1) }), BRYLL_GLOVES(Category.DUNG_NEEDLE_CRAFTING, new Item(17159, 1), Constants.CRAFTING, 40, 46.0, 17446, new Item[] { new Item(17476, 1) }), DUSKWEED_GLOVES(Category.DUNG_NEEDLE_CRAFTING, new Item(17161, 1), Constants.CRAFTING, 50, 55.0, 17446, new Item[] { new Item(17478, 1) }), SOULBELL_GLOVES(Category.DUNG_NEEDLE_CRAFTING, new Item(17163, 1), Constants.CRAFTING, 60, 63.0, 17446, new Item[] { new Item(17480, 1) }), ECTOGLOVES(Category.DUNG_NEEDLE_CRAFTING, new Item(17165, 1), Constants.CRAFTING, 70, 72.0, 17446, new Item[] { new Item(17482, 1) }), RUNIC_GLOVES(Category.DUNG_NEEDLE_CRAFTING, new Item(17167, 1), Constants.CRAFTING, 80, 80.0, 17446, new Item[] { new Item(17484, 1) }), SPIRITBLOOM_GLOVES(Category.DUNG_NEEDLE_CRAFTING, new Item(17169, 1), Constants.CRAFTING, 90, 89.0, 17446, new Item[] { new Item(17486, 1) }), SALVE_ROBE_TOP(Category.DUNG_NEEDLE_CRAFTING, new Item(17217, 1), Constants.CRAFTING, 8, 96.0, 17446, new Item[] { new Item(17468, 5) }), WILDERCRESS_ROBE_TOP(Category.DUNG_NEEDLE_CRAFTING, new Item(17219, 1), Constants.CRAFTING, 18, 139.0, 17446, new Item[] { new Item(17470, 5) }), BLIGHTLEAF_ROBE_TOP(Category.DUNG_NEEDLE_CRAFTING, new Item(17221, 1), Constants.CRAFTING, 28, 181.0, 17446, new Item[] { new Item(17472, 5) }), ROSEBLOOD_ROBE_TOP(Category.DUNG_NEEDLE_CRAFTING, new Item(17223, 1), Constants.CRAFTING, 38, 224.0, 17446, new Item[] { new Item(17474, 5) }), BRYLL_ROBE_TOP(Category.DUNG_NEEDLE_CRAFTING, new Item(17225, 1), Constants.CRAFTING, 48, 266.0, 17446, new Item[] { new Item(17476, 5) }), DUSKWEED_ROBE_TOP(Category.DUNG_NEEDLE_CRAFTING, new Item(17227, 1), Constants.CRAFTING, 58, 309.0, 17446, new Item[] { new Item(17478, 5) }), SOULBELL_ROBE_TOP(Category.DUNG_NEEDLE_CRAFTING, new Item(17229, 1), Constants.CRAFTING, 68, 351.0, 17446, new Item[] { new Item(17480, 5) }), ECTOROBE_TOP(Category.DUNG_NEEDLE_CRAFTING, new Item(17231, 1), Constants.CRAFTING, 78, 394.0, 17446, new Item[] { new Item(17482, 5) }), RUNIC_ROBE_TOP(Category.DUNG_NEEDLE_CRAFTING, new Item(17233, 1), Constants.CRAFTING, 88, 436.0, 17446, new Item[] { new Item(17484, 5) }), SPIRITBLOOM_ROBE_TOP(Category.DUNG_NEEDLE_CRAFTING, new Item(17235, 1), Constants.CRAFTING, 98, 479.0, 17446, new Item[] { new Item(17486, 5) }), PROTOLEATHER_COIF(Category.DUNG_NEEDLE_CRAFTING, new Item(17041, 1), Constants.CRAFTING, 5, 33.0, 17446, new Item[] { new Item(17424, 2) }), SUBLEATHER_COIF(Category.DUNG_NEEDLE_CRAFTING, new Item(17043, 1), Constants.CRAFTING, 15, 50.0, 17446, new Item[] { new Item(17426, 2) }), PARALEATHER_COIF(Category.DUNG_NEEDLE_CRAFTING, new Item(17045, 1), Constants.CRAFTING, 25, 67.0, 17446, new Item[] { new Item(17428, 2) }), ARCHLEATHER_COIF(Category.DUNG_NEEDLE_CRAFTING, new Item(17047, 1), Constants.CRAFTING, 35, 84.0, 17446, new Item[] { new Item(17430, 2) }), DROMOLEATHER_COIF(Category.DUNG_NEEDLE_CRAFTING, new Item(17049, 1), Constants.CRAFTING, 45, 101.0, 17446, new Item[] { new Item(17432, 2) }), SPINOLEATHER_COIF(Category.DUNG_NEEDLE_CRAFTING, new Item(17051, 1), Constants.CRAFTING, 55, 118.0, 17446, new Item[] { new Item(17434, 2) }), GALLILEATHER_COIF(Category.DUNG_NEEDLE_CRAFTING, new Item(17053, 1), Constants.CRAFTING, 65, 135.0, 17446, new Item[] { new Item(17436, 2) }), STEGOLEATHER_COIF(Category.DUNG_NEEDLE_CRAFTING, new Item(17055, 1), Constants.CRAFTING, 75, 152.0, 17446, new Item[] { new Item(17438, 2) }), MEGALEATHER_COIF(Category.DUNG_NEEDLE_CRAFTING, new Item(17057, 1), Constants.CRAFTING, 85, 169.0, 17446, new Item[] { new Item(17440, 2) }), TYRANNOLEATHER_COIF(Category.DUNG_NEEDLE_CRAFTING, new Item(17059, 1), Constants.CRAFTING, 95, 186.0, 17446, new Item[] { new Item(17442, 2) }), PROTOLEATHER_BODY(Category.DUNG_NEEDLE_CRAFTING, new Item(17173, 1), Constants.CRAFTING, 9, 99.0, 17446, new Item[] { new Item(17424, 5) }), SUBLEATHER_BODY(Category.DUNG_NEEDLE_CRAFTING, new Item(17175, 1), Constants.CRAFTING, 19, 142.0, 17446, new Item[] { new Item(17426, 5) }), PARALEATHER_BODY(Category.DUNG_NEEDLE_CRAFTING, new Item(17177, 1), Constants.CRAFTING, 29, 184.0, 17446, new Item[] { new Item(17428, 5) }), ARCHLEATHER_BODY(Category.DUNG_NEEDLE_CRAFTING, new Item(17179, 1), Constants.CRAFTING, 39, 269.0, 17446, new Item[] { new Item(17430, 5) }), DROMOLEATHER_BODY(Category.DUNG_NEEDLE_CRAFTING, new Item(17181, 1), Constants.CRAFTING, 49, 269.0, 17446, new Item[] { new Item(17432, 5) }), SPINOLEATHER_BODY(Category.DUNG_NEEDLE_CRAFTING, new Item(17183, 1), Constants.CRAFTING, 59, 312.0, 17446, new Item[] { new Item(17434, 5) }), GALLILEATHER_BODY(Category.DUNG_NEEDLE_CRAFTING, new Item(17185, 1), Constants.CRAFTING, 69, 354.0, 17446, new Item[] { new Item(17436, 5) }), STEGOLEATHER_BODY(Category.DUNG_NEEDLE_CRAFTING, new Item(17187, 1), Constants.CRAFTING, 79, 397.0, 17446, new Item[] { new Item(17438, 5) }), MEGALEATHER_BODY(Category.DUNG_NEEDLE_CRAFTING, new Item(17189, 1), Constants.CRAFTING, 89, 439.0, 17446, new Item[] { new Item(17440, 5) }), TYRANNOLEATHER_BODY(Category.DUNG_NEEDLE_CRAFTING, new Item(17191, 1), Constants.CRAFTING, 99, 482.0, 17446, new Item[] { new Item(17442, 5) }), PROTOLEATHER_VAMBRACES(Category.DUNG_NEEDLE_CRAFTING, new Item(17195, 1), Constants.CRAFTING, 1, 13.0, 17446, new Item[] { new Item(17424, 1) }), SUBLEATHER_VAMBRACES(Category.DUNG_NEEDLE_CRAFTING, new Item(17197, 1), Constants.CRAFTING, 11, 21.0, 17446, new Item[] { new Item(17426, 1) }), PARALEATHER_VAMBRACES(Category.DUNG_NEEDLE_CRAFTING, new Item(17199, 1), Constants.CRAFTING, 21, 30.0, 17446, new Item[] { new Item(17428, 1) }), ARCHLEATHER_VAMBRACES(Category.DUNG_NEEDLE_CRAFTING, new Item(17201, 1), Constants.CRAFTING, 31, 38.0, 17446, new Item[] { new Item(17430, 1) }), DROMOLEATHER_VAMBRACES(Category.DUNG_NEEDLE_CRAFTING, new Item(17203, 1), Constants.CRAFTING, 41, 47.0, 17446, new Item[] { new Item(17432, 1) }), SPINOLEATHER_VAMBRACES(Category.DUNG_NEEDLE_CRAFTING, new Item(17205, 1), Constants.CRAFTING, 51, 55.0, 17446, new Item[] { new Item(17434, 1) }), GALLILEATHER_VAMBRACES(Category.DUNG_NEEDLE_CRAFTING, new Item(17207, 1), Constants.CRAFTING, 61, 64.0, 17446, new Item[] { new Item(17436, 1) }), STEGOLEATHER_VAMBRACES(Category.DUNG_NEEDLE_CRAFTING, new Item(17209, 1), Constants.CRAFTING, 71, 72.0, 17446, new Item[] { new Item(17438, 1) }), MEGALEATHER_VAMBRACES(Category.DUNG_NEEDLE_CRAFTING, new Item(17211, 1), Constants.CRAFTING, 81, 81.0, 17446, new Item[] { new Item(17440, 1) }), TYRANNOLEATHER_VAMBRACES(Category.DUNG_NEEDLE_CRAFTING, new Item(17213, 1), Constants.CRAFTING, 91, 89.0, 17446, new Item[] { new Item(17442, 1) }), PROTOLEATHER_BOOTS(Category.DUNG_NEEDLE_CRAFTING, new Item(17297, 1), Constants.CRAFTING, 3, 14.0, 17446, new Item[] { new Item(17424, 1) }), SUBLEATHER_BOOTS(Category.DUNG_NEEDLE_CRAFTING, new Item(17299, 1), Constants.CRAFTING, 13, 23.0, 17446, new Item[] { new Item(17426, 1) }), PARALEATHER_BOOTS(Category.DUNG_NEEDLE_CRAFTING, new Item(17301, 1), Constants.CRAFTING, 23, 31.0, 17446, new Item[] { new Item(17428, 1) }), ARCHLEATHER_BOOTS(Category.DUNG_NEEDLE_CRAFTING, new Item(17303, 1), Constants.CRAFTING, 33, 40.0, 17446, new Item[] { new Item(17430, 1) }), DROMOLEATHER_BOOTS(Category.DUNG_NEEDLE_CRAFTING, new Item(17305, 1), Constants.CRAFTING, 43, 48.0, 17446, new Item[] { new Item(17432, 1) }), SPINOLEATHER_BOOTS(Category.DUNG_NEEDLE_CRAFTING, new Item(17307, 1), Constants.CRAFTING, 53, 57.0, 17446, new Item[] { new Item(17434, 1) }), GALLILEATHER_BOOTS(Category.DUNG_NEEDLE_CRAFTING, new Item(17309, 1), Constants.CRAFTING, 63, 65.0, 17446, new Item[] { new Item(17436, 1) }), STEGOLEATHER_BOOTS(Category.DUNG_NEEDLE_CRAFTING, new Item(17311, 1), Constants.CRAFTING, 73, 74.0, 17446, new Item[] { new Item(17438, 1) }), MEGALEATHER_BOOTS(Category.DUNG_NEEDLE_CRAFTING, new Item(17313, 1), Constants.CRAFTING, 83, 82.0, 17446, new Item[] { new Item(17440, 1) }), TYRANNOLEATHER_BOOTS(Category.DUNG_NEEDLE_CRAFTING, new Item(17315, 1), Constants.CRAFTING, 93, 91.0, 17446, new Item[] { new Item(17442, 1) }), PROTOLEATHER_CHAPS(Category.DUNG_NEEDLE_CRAFTING, new Item(17319, 1), Constants.CRAFTING, 7, 54.0, 17446, new Item[] { new Item(17424, 3) }), SUBLEATHER_CHAPS(Category.DUNG_NEEDLE_CRAFTING, new Item(17321, 1), Constants.CRAFTING, 17, 80.0, 17446, new Item[] { new Item(17426, 3) }), PARALEATHER_CHAPS(Category.DUNG_NEEDLE_CRAFTING, new Item(17323, 1), Constants.CRAFTING, 27, 105.0, 17446, new Item[] { new Item(17428, 3) }), ARCHLEATHER_CHAPS(Category.DUNG_NEEDLE_CRAFTING, new Item(17325, 1), Constants.CRAFTING, 37, 131.0, 17446, new Item[] { new Item(17430, 3) }), DROMOLEATHER_CHAPS(Category.DUNG_NEEDLE_CRAFTING, new Item(17327, 1), Constants.CRAFTING, 47, 156.0, 17446, new Item[] { new Item(17432, 3) }), SPINOLEATHER_CHAPS(Category.DUNG_NEEDLE_CRAFTING, new Item(17329, 1), Constants.CRAFTING, 57, 182.0, 17446, new Item[] { new Item(17434, 3) }), GALLILEATHER_CHAPS(Category.DUNG_NEEDLE_CRAFTING, new Item(17331, 1), Constants.CRAFTING, 67, 207.0, 17446, new Item[] { new Item(17436, 3) }), STEGOLEATHER_CHAPS(Category.DUNG_NEEDLE_CRAFTING, new Item(17333, 1), Constants.CRAFTING, 77, 233.0, 17446, new Item[] { new Item(17438, 3) }), MEGALEATHER_CHAPS(Category.DUNG_NEEDLE_CRAFTING, new Item(17335, 1), Constants.CRAFTING, 87, 258.0, 17446, new Item[] { new Item(17440, 3) }), TYRANNOLEATHER_CHAPS(Category.DUNG_NEEDLE_CRAFTING, new Item(17337, 1), Constants.CRAFTING, 97, 284.0, 17446, new Item[] { new Item(17442, 3) }), HEADLESS_ARROW2(Category.DUNG_ARROW_COMBINING, new Item(17747, 15), Constants.FLETCHING, 1, 0.0, -1, new Item[] { new Item(17742, 15), new Item(17796, 15) }), NOVITE_ARROWS(Category.DUNG_ARROW_COMBINING, new Item(16427, 15), Constants.FLETCHING, 1, 1.0, -1, new Item[] { new Item(17747, 15), new Item(17885, 15) }), BATHUS_ARROWS(Category.DUNG_ARROW_COMBINING, new Item(16432, 15), Constants.FLETCHING, 11, 2.0, -1, new Item[] { new Item(17747, 15), new Item(17890, 15) }), MARMAROS_ARROWS(Category.DUNG_ARROW_COMBINING, new Item(16437, 15), Constants.FLETCHING, 22, 5.0, -1, new Item[] { new Item(17747, 15), new Item(17895, 15) }), KRATONITE_ARROWS(Category.DUNG_ARROW_COMBINING, new Item(16442, 15), Constants.FLETCHING, 33, 7.0, -1, new Item[] { new Item(17747, 15), new Item(17900, 15) }), FRACTITE_ARROWS(Category.DUNG_ARROW_COMBINING, new Item(16447, 15), Constants.FLETCHING, 44, 10.0, -1, new Item[] { new Item(17747, 15), new Item(17905, 15) }), ZEPHYRIUM_ARROWS(Category.DUNG_ARROW_COMBINING, new Item(16452, 15), Constants.FLETCHING, 55, 12.0, -1, new Item[] { new Item(17747, 15), new Item(17910, 15) }), ARGONITE_ARROWS(Category.DUNG_ARROW_COMBINING, new Item(16457, 15), Constants.FLETCHING, 66, 15.0, -1, new Item[] { new Item(17747, 15), new Item(17915, 15) }), KATAGON_ARROWS(Category.DUNG_ARROW_COMBINING, new Item(16462, 15), Constants.FLETCHING, 77, 17.0, -1, new Item[] { new Item(17747, 15), new Item(17920, 15) }), GORGONITE_ARROWS(Category.DUNG_ARROW_COMBINING, new Item(16467, 15), Constants.FLETCHING, 88, 20.0, -1, new Item[] { new Item(17747, 15), new Item(17925, 15) }), PROMETHIUM_ARROWS(Category.DUNG_ARROW_COMBINING, new Item(16472, 15), Constants.FLETCHING, 99, 22.0, -1, new Item[] { new Item(17747, 15), new Item(17930, 15) }), TANGLE_GUM_LONGBOW(Category.DUNG_BOWSTRINGING, new Item(16317, 1), Constants.FLETCHING, 6, 5.0, -1, new Item[] { new Item(17722, 1), new Item(17752, 1) }), SEEPING_ELM_LONGBOW(Category.DUNG_BOWSTRINGING, new Item(16319, 1), Constants.FLETCHING, 16, 10.0, -1, new Item[] { new Item(17724, 1), new Item(17752, 1) }), BLOOD_SPINDLE_LONGBOW(Category.DUNG_BOWSTRINGING, new Item(16321, 1), Constants.FLETCHING, 26, 17.0, -1, new Item[] { new Item(17726, 1), new Item(17752, 1) }), UTUKU_LONGBOW(Category.DUNG_BOWSTRINGING, new Item(16323, 1), Constants.FLETCHING, 36, 26.0, -1, new Item[] { new Item(17728, 1), new Item(17752, 1) }), SPINEBEAM_LONGBOW(Category.DUNG_BOWSTRINGING, new Item(16325, 1), Constants.FLETCHING, 46, 37.0, -1, new Item[] { new Item(17730, 1), new Item(17752, 1) }), BOVISTRANGLER_LONGBOW(Category.DUNG_BOWSTRINGING, new Item(16327, 1), Constants.FLETCHING, 56, 51.0, -1, new Item[] { new Item(17732, 1), new Item(17752, 1) }), THIGAT_LONGBOW(Category.DUNG_BOWSTRINGING, new Item(16329, 1), Constants.FLETCHING, 66, 67.0, -1, new Item[] { new Item(17734, 1), new Item(17752, 1) }), CORPSETHORN_LONGBOW(Category.DUNG_BOWSTRINGING, new Item(16331, 1), Constants.FLETCHING, 76, 86.0, -1, new Item[] { new Item(17736, 1), new Item(17752, 1) }), ENTGALLOW_LONGBOW(Category.DUNG_BOWSTRINGING, new Item(16333, 1), Constants.FLETCHING, 86, 106.0, -1, new Item[] { new Item(17738, 1), new Item(17752, 1) }), GRAVE_CREEPER_LONGBOW(Category.DUNG_BOWSTRINGING, new Item(16335, 1), Constants.FLETCHING, 96, 129.0, -1, new Item[] { new Item(17740, 1), new Item(17752, 1) }), TANGLE_GUM_SHORTBOW(Category.DUNG_BOWSTRINGING, new Item(16867, 1), Constants.FLETCHING, 1, 5.0, -1, new Item[] { new Item(17702, 1), new Item(17752, 1) }), SEEPING_ELM_SHORTBOW(Category.DUNG_BOWSTRINGING, new Item(16869, 1), Constants.FLETCHING, 11, 9.0, -1, new Item[] { new Item(17704, 1), new Item(17752, 1) }), BLOOD_SPINDLE_SHORTBOW(Category.DUNG_BOWSTRINGING, new Item(16871, 1), Constants.FLETCHING, 21, 15.0, -1, new Item[] { new Item(17706, 1), new Item(17752, 1) }), UTUKU_SHORTBOW(Category.DUNG_BOWSTRINGING, new Item(16873, 1), Constants.FLETCHING, 31, 23.0, -1, new Item[] { new Item(17708, 1), new Item(17752, 1) }), SPINEBEAM_SHORTBOW(Category.DUNG_BOWSTRINGING, new Item(16875, 1), Constants.FLETCHING, 41, 33.0, -1, new Item[] { new Item(17710, 1), new Item(17752, 1) }), BOVISTRANGLER_SHORTBOW(Category.DUNG_BOWSTRINGING, new Item(16877, 1), Constants.FLETCHING, 51, 45.0, -1, new Item[] { new Item(17712, 1), new Item(17752, 1) }), THIGAT_SHORTBOW(Category.DUNG_BOWSTRINGING, new Item(16879, 1), Constants.FLETCHING, 61, 59.0, -1, new Item[] { new Item(17714, 1), new Item(17752, 1) }), CORPSETHORN_SHORTBOW(Category.DUNG_BOWSTRINGING, new Item(16881, 1), Constants.FLETCHING, 71, 75.0, -1, new Item[] { new Item(17716, 1), new Item(17752, 1) }), ENTGALLOW_SHORTBOW(Category.DUNG_BOWSTRINGING, new Item(16883, 1), Constants.FLETCHING, 81, 93.0, -1, new Item[] { new Item(17718, 1), new Item(17752, 1) }), GRAVE_CREEPER_SHORTBOW(Category.DUNG_BOWSTRINGING, new Item(16885, 1), Constants.FLETCHING, 91, 113.0, -1, new Item[] { new Item(17720, 1), new Item(17752, 1) }), TANGLE_GUM_STAFF(Category.DUNG_KNIFE_FLETCHING, new Item(16977, 1), Constants.FLETCHING, 8, 9.0, 17754, new Item[] { new Item(17682, 1) }), SEEPING_ELM_STAFF(Category.DUNG_KNIFE_FLETCHING, new Item(16979, 1), Constants.FLETCHING, 18, 16.0, 17754, new Item[] { new Item(17684, 1) }), BLOOD_SPINDLE_STAFF(Category.DUNG_KNIFE_FLETCHING, new Item(16981, 1), Constants.FLETCHING, 28, 27.0, 17754, new Item[] { new Item(17686, 1) }), UTUKU_STAFF(Category.DUNG_KNIFE_FLETCHING, new Item(16983, 1), Constants.FLETCHING, 38, 41.0, 17754, new Item[] { new Item(17688, 1) }), SPINEBEAM_STAFF(Category.DUNG_KNIFE_FLETCHING, new Item(16985, 1), Constants.FLETCHING, 48, 59.0, 17754, new Item[] { new Item(17690, 1) }), BOVISTRANGLER_STAFF(Category.DUNG_KNIFE_FLETCHING, new Item(16987, 1), Constants.FLETCHING, 58, 81.0, 17754, new Item[] { new Item(17692, 1) }), THIGAT_STAFF(Category.DUNG_KNIFE_FLETCHING, new Item(16989, 1), Constants.FLETCHING, 68, 106.0, 17754, new Item[] { new Item(17694, 1) }), CORPSETHORN_STAFF(Category.DUNG_KNIFE_FLETCHING, new Item(16991, 1), Constants.FLETCHING, 78, 135.0, 17754, new Item[] { new Item(17696, 1) }), ENTGALLOW_STAFF(Category.DUNG_KNIFE_FLETCHING, new Item(16993, 1), Constants.FLETCHING, 88, 167.0, 17754, new Item[] { new Item(17698, 1) }), GRAVE_CREEPER_STAFF(Category.DUNG_KNIFE_FLETCHING, new Item(16995, 1), Constants.FLETCHING, 98, 203.0, 17754, new Item[] { new Item(17700, 1) }), TANGLE_GUM_SHORTBOW_U(Category.DUNG_KNIFE_FLETCHING, new Item(17702, 1), Constants.FLETCHING, 1, 5.0, 17754, new Item[] { new Item(17682, 1) }), SEEPING_ELM_SHORTBOW_U(Category.DUNG_KNIFE_FLETCHING, new Item(17704, 1), Constants.FLETCHING, 11, 9.0, 17754, new Item[] { new Item(17684, 1) }), BLOOD_SPINDLE_SHORTBOW_U(Category.DUNG_KNIFE_FLETCHING, new Item(17706, 1), Constants.FLETCHING, 21, 15.0, 17754, new Item[] { new Item(17686, 1) }), UTUKU_SHORTBOW_U(Category.DUNG_KNIFE_FLETCHING, new Item(17708, 1), Constants.FLETCHING, 31, 23.0, 17754, new Item[] { new Item(17688, 1) }), SPINEBEAM_SHORTBOW_U(Category.DUNG_KNIFE_FLETCHING, new Item(17710, 1), Constants.FLETCHING, 41, 33.0, 17754, new Item[] { new Item(17690, 1) }), BOVISTRANGLER_SHORTBOW_U(Category.DUNG_KNIFE_FLETCHING, new Item(17712, 1), Constants.FLETCHING, 51, 45.0, 17754, new Item[] { new Item(17692, 1) }), THIGAT_SHORTBOW_U(Category.DUNG_KNIFE_FLETCHING, new Item(17714, 1), Constants.FLETCHING, 61, 59.0, 17754, new Item[] { new Item(17694, 1) }), CORPSETHORN_SHORTBOW_U(Category.DUNG_KNIFE_FLETCHING, new Item(17716, 1), Constants.FLETCHING, 71, 75.0, 17754, new Item[] { new Item(17696, 1) }), ENTGALLOW_SHORTBOW_U(Category.DUNG_KNIFE_FLETCHING, new Item(17718, 1), Constants.FLETCHING, 81, 93.0, 17754, new Item[] { new Item(17698, 1) }), GRAVE_CREEPER_SHORTBOW_U(Category.DUNG_KNIFE_FLETCHING, new Item(17720, 1), Constants.FLETCHING, 91, 113.0, 17754, new Item[] { new Item(17700, 1) }), TANGLE_GUM_LONGBOW_U(Category.DUNG_KNIFE_FLETCHING, new Item(17722, 1), Constants.FLETCHING, 6, 5.0, 17754, new Item[] { new Item(17682, 1) }), SEEPING_ELM_LONGBOW_U(Category.DUNG_KNIFE_FLETCHING, new Item(17724, 1), Constants.FLETCHING, 16, 10.0, 17754, new Item[] { new Item(17684, 1) }), BLOOD_SPINDLE_LONGBOW_U(Category.DUNG_KNIFE_FLETCHING, new Item(17726, 1), Constants.FLETCHING, 26, 17.0, 17754, new Item[] { new Item(17686, 1) }), UTUKU_LONGBOW_U(Category.DUNG_KNIFE_FLETCHING, new Item(17728, 1), Constants.FLETCHING, 36, 26.0, 17754, new Item[] { new Item(17688, 1) }), SPINEBEAM_LONGBOW_U(Category.DUNG_KNIFE_FLETCHING, new Item(17730, 1), Constants.FLETCHING, 46, 37.0, 17754, new Item[] { new Item(17690, 1) }), BOVISTRANGLER_LONGBOW_U(Category.DUNG_KNIFE_FLETCHING, new Item(17732, 1), Constants.FLETCHING, 56, 51.0, 17754, new Item[] { new Item(17692, 1) }), THIGAT_LONGBOW_U(Category.DUNG_KNIFE_FLETCHING, new Item(17734, 1), Constants.FLETCHING, 66, 67.0, 17754, new Item[] { new Item(17694, 1) }), CORPSETHORN_LONGBOW_U(Category.DUNG_KNIFE_FLETCHING, new Item(17736, 1), Constants.FLETCHING, 76, 86.0, 17754, new Item[] { new Item(17696, 1) }), ENTGALLOW_LONGBOW_U(Category.DUNG_KNIFE_FLETCHING, new Item(17738, 1), Constants.FLETCHING, 86, 106.0, 17754, new Item[] { new Item(17698, 1) }), GRAVE_CREEPER_LONGBOW_U(Category.DUNG_KNIFE_FLETCHING, new Item(17740, 1), Constants.FLETCHING, 96, 129.0, 17754, new Item[] { new Item(17700, 1) }), ARROW_SHAFT2(Category.DUNG_KNIFE_FLETCHING, new Item(17742, 15), Constants.FLETCHING, 1, 0.0, 17754, new Item[] { new Item(17682, 1) }), TANGLE_GUM_TRAP(Category.DUNG_KNIFE_FLETCHING, new Item(17756, 1), Constants.FLETCHING, 3, 12.0, 17754, new Item[] { new Item(17682, 1) }), SEEPING_ELM_TRAP(Category.DUNG_KNIFE_FLETCHING, new Item(17758, 1), Constants.FLETCHING, 13, 21.0, 17754, new Item[] { new Item(17684, 1) }), BLOOD_SPINDLE_TRAP(Category.DUNG_KNIFE_FLETCHING, new Item(17760, 1), Constants.FLETCHING, 23, 36.0, 17754, new Item[] { new Item(17686, 1) }), UTUKU_TRAP(Category.DUNG_KNIFE_FLETCHING, new Item(17762, 1), Constants.FLETCHING, 33, 55.0, 17754, new Item[] { new Item(17688, 1) }), SPINEBEAM_TRAP(Category.DUNG_KNIFE_FLETCHING, new Item(17764, 1), Constants.FLETCHING, 43, 79.0, 17754, new Item[] { new Item(17690, 1) }), BOVISTRANGLER_TRAP(Category.DUNG_KNIFE_FLETCHING, new Item(17766, 1), Constants.FLETCHING, 53, 108.0, 17754, new Item[] { new Item(17692, 1) }), THIGAT_TRAP(Category.DUNG_KNIFE_FLETCHING, new Item(17768, 1), Constants.FLETCHING, 63, 141.0, 17754, new Item[] { new Item(17694, 1) }), CORPSETHORN_TRAP(Category.DUNG_KNIFE_FLETCHING, new Item(17770, 1), Constants.FLETCHING, 73, 180.0, 17754, new Item[] { new Item(17696, 1) }), ENTGALLOW_TRAP(Category.DUNG_KNIFE_FLETCHING, new Item(17772, 1), Constants.FLETCHING, 83, 223.0, 17754, new Item[] { new Item(17698, 1) }), GRAVE_CREEPER_TRAP(Category.DUNG_KNIFE_FLETCHING, new Item(17774, 1), Constants.FLETCHING, 93, 271.0, 17754, new Item[] { new Item(17700, 1) }), ; private final Item product; private final int skill; private final int req; private final double xp; private final int tool; private final Item[] materials; private final Category category; private ReqItem(Category category, Item product, int skill, int req, double xp, int tool, Item[] materials) { this.product = product; this.skill = skill; this.req = req; this.xp = xp; this.tool = tool; this.materials = materials; this.category = category; } private ReqItem(Item product, int skill, int req, double xp, int tool, Item[] materials) { this(null, product, skill, req, xp, tool, materials); } public Item getProduct() { return product; } public int getSkill() { return skill; } public int getReq() { return req; } public double getXp() { return xp; } public int getTool() { return tool; } public Item[] getMaterials() { return materials; } private static final Map items = new HashMap<>(); static { for (ReqItem item : ReqItem.values()) items.put(item.getProduct().getId(), item); } public Item[] getMaterialsFor(int amount) { Item[] mats = new Item[materials.length]; for (int i = 0;i < mats.length;i++) mats[i] = new Item(materials[i].getId(), materials[i].getAmount()*amount); return mats; } public static ReqItem getRequirements(int id) { return items.get(id); } public static ReqItem[] getProducts(Category category, int material) { ArrayList products = new ArrayList<>(); for (ReqItem req : ReqItem.values()) { if (req.category != category) continue; for (Item mat : req.materials) if (mat.getId() == material) products.add(req); } return products.toArray(new ReqItem[0]); } public static ReqItem[] getProducts(Category category) { ArrayList products = new ArrayList<>(); for (ReqItem req : ReqItem.values()) { if (req.category != category) continue; products.add(req); } return products.toArray(new ReqItem[0]); } public Category getCategory() { return category; } }" "package com.rs.game.content.skills.woodcutting; @PluginEventHandler public class BirdNests { public static ItemClickHandler handleBirdNests = new ItemClickHandler(new Object[] { 5070, 5071, 5072, 11966, 5073, 5074, 7413 }, e -> { if (!e.getPlayer().getInventory().hasFreeSlots()) { e.getPlayer().sendMessage(""You don't have enough inventory space.""); return; } e.getPlayer().incrementCount(""Nests searched""); e.getPlayer().getInventory().deleteItem(e.getItem().getId(), 1); e.getPlayer().getInventory().addItem(5075, 1); switch(e.getItem().getId()) { case 5070: e.getPlayer().getInventory().addItem(5076, 1, true); break; case 5071: e.getPlayer().getInventory().addItem(5078, 1, true); break; case 5072: e.getPlayer().getInventory().addItem(5077, 1, true); break; case 11966: e.getPlayer().getInventory().addItem(11964, 1, true); break; case 5073: for (Item rew : DropTable.calculateDrops(e.getPlayer(), DropSets.getDropSet(""nest_tree_seed""))) e.getPlayer().getInventory().addItem(rew); break; case 5074: for (Item rew : DropTable.calculateDrops(e.getPlayer(), DropSets.getDropSet(""nest_ring""))) e.getPlayer().getInventory().addItem(rew); break; case 7413: for (Item rew : DropTable.calculateDrops(e.getPlayer(), DropSets.getDropSet(""nest_shit_seed""))) e.getPlayer().getInventory().addItem(rew); break; } }); }" "package com.rs.game.content.skills.woodcutting; /* * 1351 - {-423442303=[6744], -1127713268=[17091], -812799196=[879], 212908826=[4077], 1728453613=[11594], -1191283983=[12282], -2008713161=[12329], -1226375116=[3324], -219949008=[15832], 1068619588=[9999], 249243873=[12345], 1917942796=[12322], -269793388=[10071]} * 1349 - {-2008713161=[12330], -1226375116=[3323], -423442303=[6743], -1127713268=[17090], 1068619588=[9998], -812799196=[877], 212908826=[4036], 249243873=[12344], 1728453613=[11600], 1917942796=[2847], -269793388=[10072]} * 1353 - {-2008713161=[12331], -1226375116=[3292], -423442303=[6742], -1127713268=[17089], 1068619588=[9997], -812799196=[875], 212908826=[4031], 249243873=[12343], 1728453613=[11599], 1917942796=[880], -269793388=[10073]} * 1361 - {-2008713161=[12332], -1226375116=[3284], -423442303=[6741], 2136703583=[6364], -1127713268=[17088], 1068619588=[9996], -812799196=[873], 1728453613=[11598], 1917942796=[878], -269793388=[10074]} * 1355 - {-2008713161=[12333], -1226375116=[3263], -954432337=[5366], -423442303=[6740], -1127713268=[17087], 1068619588=[9995], -812799196=[871], 212908826=[4017], 249243873=[12342], 1728453613=[11597], 1917942796=[876], -269793388=[10075]} * 1357 - {-2008713161=[12334], -1226375116=[3262], -954432337=[5367], -423442303=[6739], -1127713268=[17086], 1068619588=[9994], -812799196=[869], 212908826=[4012], 249243873=[12341], 1728453613=[11596], 1917942796=[874], -269793388=[10076]} * 1359 - {-423442303=[6738], -1127713268=[17085], -812799196=[867], 212908826=[4011], 1728453613=[11595], -2008713161=[12335], -1226375116=[3261], -954432337=[5368], 1068619588=[9993], -1652546089=[5781], 249243873=[12340], 1917942796=[872], -269793388=[10077]} * 6739 - {-2008713161=[12336], -1226375116=[3260], -954432337=[5369], -423442303=[6745], -1127713268=[17092], 1068619588=[9992], -812799196=[2846], 212908826=[4008], 249243873=[12346], 1728453613=[11601], -1992899638=[870], -269793388=[10078]} * 13661 - {-512925811=[10348], -423442303=[10249], -466056516=[10226], 191151360=[10227], -1127713268=[17093], -1610585784=[10251], 212908826=[4402], 1728453613=[11604], -1153750998=[14366], -2008713161=[12337], -1226375116=[3325], -954432337=[10247], 1312980631=[10224, 10228, 10222], -912685908=[10225], 1068619588=[10250], 249243873=[12347], 2043016414=[16002], -1935819679=[15250], -1636805267=[10341], 1917942796=[12323], -1204678996=[10223], -269793388=[7383]} */ public enum Hatchet { BRONZE(1351, 1, 0.5, 12329, 6744, 3324, 17091, 9999, 879, 4077, 12345, 11594, 12322, 10071), IRON(1349, 1, 0.6, 12330, 6743, 3323, 17090, 9998, 877, 4036, 12344, 11600, 2847, 10072), STEEL(1353, 6, 0.7, 12331, 6742, 3292, 17089, 9997, 875, 4031, 12343, 11599, 880, 10073), BLACK(1361, 6, 0.7, 12332, 6741, 3284, 17088, 9996, 873, -1, -1, 11598, 878, 10074), MITHRIL(1355, 21, 0.8, 12333, 6740, 3263, 17087, 9995, 871, 4017, 12342, 11597, 876, 10075), ADAMANT(1357, 31, 1.0, 12334, 6739, 3262, 17086, 9994, 869, 4012, 12341, 11596, 874, 10076), RUNE(1359, 41, 1.2, 12335, 6738, 3261, 17085, 9993, 867, 4011, 12340, 11595, 872, 10077), DRAGON(6739, 61, 1.3, 12336, 6745, 3260, 17092, 9992, 2846, 4008, 12346, 11601, 870, 10078), INFERNO(13661, 61, 1.3, 12337, 10249, 3325, 17093, 10250, 10251, 4402, 12347, 11604, 12323, 7383); private final int itemId; private final int useLevel; private final int[] animations; private final double toolMod; private Hatchet(int itemId, int useLevel, double toolMod, int... animations) { this.itemId = itemId; this.useLevel = useLevel; this.toolMod = toolMod; this.animations = animations; } /* * 0: OneHandSwingDown * 1: ChopCanoe * 2: IvyFurtherInWall * 3: HighQualityChop * 4: OneSingleOldChop * 5: NormalTree * 6: OneLargeDownwardSwing * 7: ShortCanoeChop * 8: HitGetStuckClearSurface * 9: IvyCutDown * 10: ChopShakeHeadCraft */ public int animNormal() { return animations[5]; } public int animIvy() { return animations[9]; } public int animCanoe() { return animations[1]; } public int getAnim(TreeType type) { return switch(type) { case IVY -> animIvy(); default -> animNormal(); }; } public int getItemId() { return itemId; } public int getUseLevel() { return useLevel; } public double getToolMod() { return toolMod; } public static Hatchet getBest(Player player) { for (int i = Hatchet.values().length-1; i >= 0; i--) { Hatchet def = Hatchet.values()[i]; if (player.getInventory().containsItem(def.itemId) || player.getEquipment().getWeaponId() == def.itemId) if (player.getSkills().getLevel(Constants.WOODCUTTING) >= def.useLevel) return def; } return null; } }" "package com.rs.game.content.skills.woodcutting; public class TreeStumps { private static final Map STUMPS = new HashMap<>(); static { STUMPS.put(139, 5554); STUMPS.put(142, 5554); STUMPS.put(46318, 46319); STUMPS.put(46320, 46321); STUMPS.put(46322, 46323); STUMPS.put(46324, 46325); STUMPS.put(470, 46319); STUMPS.put(670, 46319); STUMPS.put(673, 46319); STUMPS.put(675, 46319); STUMPS.put(66674, 66675); STUMPS.put(66676, 66677); STUMPS.put(66678, 66679); STUMPS.put(1276, 1342); STUMPS.put(1277, 1343); STUMPS.put(1278, 1342); STUMPS.put(1280, 1343); STUMPS.put(1281, 1356); STUMPS.put(1282, 1347); STUMPS.put(1283, 1347); STUMPS.put(1284, 6212); STUMPS.put(1286, 1351); STUMPS.put(1289, 1351); STUMPS.put(1291, 1351); STUMPS.put(1306, 7401); STUMPS.put(1309, 7402); STUMPS.put(1315, 1342); STUMPS.put(1330, 1355); STUMPS.put(1331, 1355); STUMPS.put(1332, 1355); STUMPS.put(1365, 1352); STUMPS.put(1383, 1358); STUMPS.put(1384, 1359); STUMPS.put(2023, 3371); STUMPS.put(2210, 5554); STUMPS.put(2289, 2310); STUMPS.put(2409, 40354); STUMPS.put(2410, 12004); STUMPS.put(2411, 12004); STUMPS.put(2887, 17493); STUMPS.put(2889, 4819); STUMPS.put(2890, 4821); STUMPS.put(3033, 1342); STUMPS.put(3034, 1342); STUMPS.put(3036, 1342); STUMPS.put(3037, 1355); STUMPS.put(3300, 11865); STUMPS.put(3293, 11865); STUMPS.put(4060, 4061); STUMPS.put(4674, 54766); STUMPS.put(51843, 54766); STUMPS.put(4818, 4819); STUMPS.put(4820, 4821); STUMPS.put(9036, 9037); STUMPS.put(9354, 11059); STUMPS.put(9355, 11862); STUMPS.put(9366, 11864); STUMPS.put(9387, 10951); STUMPS.put(9388, 11855); STUMPS.put(11866, 11059); STUMPS.put(11999, 12007); STUMPS.put(12000, 12001); STUMPS.put(14308, 12004); STUMPS.put(14309, 9037); STUMPS.put(16604, 16605); STUMPS.put(24168, 24169); STUMPS.put(28951, 28954); STUMPS.put(28952, 28955); STUMPS.put(32294, 47597); STUMPS.put(37477, 37653); STUMPS.put(37478, 37653); STUMPS.put(37479, 1356); STUMPS.put(37480, 7399); STUMPS.put(37481, 1347); STUMPS.put(37482, 1351); STUMPS.put(37483, 1358); STUMPS.put(37821, 37822); STUMPS.put(38616, 38725); STUMPS.put(38627, 38725); STUMPS.put(38731, 38741); STUMPS.put(38732, 38741); STUMPS.put(38755, 38759); STUMPS.put(38760, 40350); STUMPS.put(38782, 40351); STUMPS.put(38783, 40352); STUMPS.put(38784, 40353); STUMPS.put(38785, 40354); STUMPS.put(38786, 40355); STUMPS.put(38787, 40356); STUMPS.put(38788, 40357); STUMPS.put(46277, 54766); STUMPS.put(47594, 47595); STUMPS.put(47596, 47597); STUMPS.put(47598, 47599); STUMPS.put(47600, 47601); STUMPS.put(54778, 54783); STUMPS.put(54787, 57931); STUMPS.put(57964, 54783); STUMPS.put(57934, 57931); STUMPS.put(58006, 38725); STUMPS.put(58108, 58134); STUMPS.put(58109, 58134); STUMPS.put(58121, 58131); STUMPS.put(58135, 58131); STUMPS.put(58140, 58132); STUMPS.put(58141, 58132); STUMPS.put(58142, 58132); STUMPS.put(61190, 40350); STUMPS.put(61191, 40352); STUMPS.put(61192, 40355); STUMPS.put(61193, 40357); STUMPS.put(63176, 63179); STUMPS.put(68901, 38867); STUMPS.put(68902, 38868); STUMPS.put(68903, 68906); STUMPS.put(69139, 69140); STUMPS.put(69141, 69145); STUMPS.put(69142, 69143); STUMPS.put(69144, 69146); STUMPS.put(69554, 69555); STUMPS.put(69556, 69557); STUMPS.put(70057, 70059); STUMPS.put(70063, 70065); STUMPS.put(70060, 70062); STUMPS.put(70066, 70067); STUMPS.put(70068, 70070); STUMPS.put(70071, 70073); STUMPS.put(70075, 70080); STUMPS.put(70076, 70081); STUMPS.put(70077, 70082); STUMPS.put(70099, 70100); } public static int getStumpId(int treeId) { if (STUMPS.get(treeId) != null) return STUMPS.get(treeId); return 1342; } }" "package com.rs.game.content.skills.woodcutting; public enum TreeType { FRUIT_TREE(1, 0, -1, 60, 200, 8, false), NORMAL(1, 25, 1511, 60, 200, 8, false), OAK(15, 37.5, 1521, 60, 180, 15, true), WILLOW(30, 67.5, 1519, 35, 155, 51, true), TEAK(35, 105, 6333, 1, 130, 51, true), DRAMEN(36, 1, 771, 1, 130, -1, false), SWAYING(40, 1, 3692, 45, 65, -1, false), MAPLE(45, 100, 1517, 45, 65, 72, true), MAHOGANY(50, 125, 6332, 20, 55, 51, true), ARCTIC_PINE(54, 125, 10810, 20, 55, 51, true), YEW(60, 175, 1515, 6, 35, 94, true), IVY(68, 332.5, -1, 16, 30, 58, true), MAGIC(75, 250, 1513, -10, 24, 121, true), BLISTERWOOD(76, 200, 21600, -10, 24, 8, true), BLOODWOOD(85, 100, 24121, -10, 24, 121, true), MUTATED_VINE(83, 140, 21358, 6, 35, 72, false), CURLY_VINE(83, 140, null, 6, 35, 72, false), CURLY_VINE_COLLECTABLE(83, 140, new int[] { 21350, 21350, 21350, 21350 }, 6, 35, 72, false), STRAIGHT_VINE(83, 140, null, 6, 35, 72, false), STRAIGHT_VINE_COLLECTABLE(83, 140, new int[] { 21349, 21349, 21349, 21349 }, 6, 35, 72, false); private final int level; private final double xp; private final int[] logsId; private final int rate1; private final int rate99; private final int respawnDelay; private final boolean persistent; private TreeType(int level, double xp, int[] logsId, int rate1, int rate99, int respawnDelay, boolean persistent) { this.level = level; this.xp = xp; this.logsId = logsId; this.rate1 = rate1; this.rate99 = rate99; this.respawnDelay = respawnDelay; this.persistent = persistent; } private TreeType(int level, double xp, int logsId, int rate1, int rate99, int respawnDelay, boolean persistent) { this(level, xp, new int[] { logsId }, rate1, rate99, respawnDelay, persistent); } public int getLevel() { return level; } public double getXp() { return xp; } public int[] getLogsId() { return logsId; } public int getRespawnDelay() { return respawnDelay; } public boolean isPersistent() { return persistent; } public boolean rollSuccess(double mul, int level, Hatchet hatchet) { return Utils.skillSuccess((int) (level * mul), hatchet.getToolMod(), rate1, rate99); } public static TreeType forObject(Player player, GameObject object) { switch(object.getId()) { case 46274, 46275, 46277, 15062 -> { return null; } } return switch(object.getDefinitions(player).getName()) { case ""Tree"", ""Swamp tree"", ""Dead tree"", ""Evergreen"", ""Dying tree"", ""Jungle tree"" -> TreeType.NORMAL; case ""Oak"", ""Oak tree"" -> TreeType.OAK; case ""Willow"", ""Willow tree"" -> TreeType.WILLOW; case ""Maple"", ""Maple tree"", ""Maple Tree"" -> TreeType.MAPLE; case ""Teak"", ""Teak tree"" -> TreeType.TEAK; case ""Mahogany"", ""Mahogany tree"" -> TreeType.MAHOGANY; case ""Arctic Pine"" -> TreeType.ARCTIC_PINE; case ""Yew"", ""Yew tree"" -> TreeType.YEW; case ""Magic tree"", ""Cursed magic tree"" -> TreeType.MAGIC; default -> null; }; } }" "// This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see . // // Copyright © 2021 Trenton Kress // This file is part of project: Darkan // package com.rs.game.content.skills.woodcutting; @PluginEventHandler public class Woodcutting extends Action { private final int treeId; private final GameObject treeObj; private final TreeType type; private Hatchet hatchet; private int wcLevel = -1; public Woodcutting(GameObject treeObj, TreeType type) { this.treeId = treeObj.getId(); this.treeObj = treeObj; this.type = type; } public Woodcutting setHatchet(Hatchet hatchet) { this.hatchet = hatchet; return this; } public Woodcutting setLevel(int level) { this.wcLevel = level; return this; } public static LoginHandler unlockBlisterwoodTree = new LoginHandler(e -> e.getPlayer().getVars().setVarBit(9776, 1)); public static ObjectClickHandler handleTree = new ObjectClickHandler(new Object[] { ""Tree"", ""Swamp tree"", ""Dead tree"", ""Evergreen"", ""Dying tree"", ""Jungle tree"" }, e -> { if (e.getObject().getDefinitions().containsOption(0, ""Chop down"")) e.getPlayer().getActionManager().setAction(new Woodcutting(e.getObject(), TreeType.NORMAL)); }); public static ObjectClickHandler handleOak = new ObjectClickHandler(new Object[] { ""Oak"", ""Oak tree"" }, e -> { if (e.getObject().getDefinitions().containsOption(0, ""Chop down"")) e.getPlayer().getActionManager().setAction(new Woodcutting(e.getObject(), TreeType.OAK)); }); public static ObjectClickHandler handleWillow = new ObjectClickHandler(new Object[] { ""Willow"", ""Willow tree"" }, e -> { if (e.getObject().getDefinitions().containsOption(0, ""Chop down"")) e.getPlayer().getActionManager().setAction(new Woodcutting(e.getObject(), TreeType.WILLOW)); }); public static ObjectClickHandler handleMaple = new ObjectClickHandler(new Object[] { ""Maple"", ""Maple tree"", ""Maple Tree"" }, e -> { if (e.getObject().getDefinitions().containsOption(0, ""Chop down"")) e.getPlayer().getActionManager().setAction(new Woodcutting(e.getObject(), TreeType.MAPLE)); }); public static ObjectClickHandler handleTeak = new ObjectClickHandler(new Object[] { ""Teak"", ""Teak tree"" }, e -> { if (e.getObject().getDefinitions().containsOption(0, ""Chop down"")) e.getPlayer().getActionManager().setAction(new Woodcutting(e.getObject(), TreeType.TEAK)); }); public static ObjectClickHandler handleMahogany = new ObjectClickHandler(new Object[] { ""Mahogany"", ""Mahogany tree"" }, e -> { if (e.getObject().getDefinitions().containsOption(0, ""Chop down"")) e.getPlayer().getActionManager().setAction(new Woodcutting(e.getObject(), TreeType.MAHOGANY)); }); public static ObjectClickHandler handleArcticPine = new ObjectClickHandler(new Object[] { ""Arctic Pine"" }, e -> { if (e.getObject().getDefinitions().containsOption(0, ""Chop down"") || e.getObject().getDefinitions().containsOption(0, ""Cut down"")) e.getPlayer().getActionManager().setAction(new Woodcutting(e.getObject(), TreeType.ARCTIC_PINE)); }); public static ObjectClickHandler handleIvy = new ObjectClickHandler(new Object[] { ""Ivy"" }, e -> { if (e.getObject().getDefinitions().containsOption(0, ""Chop"")) e.getPlayer().getActionManager().setAction(new Woodcutting(e.getObject(), TreeType.IVY)); }); public static ObjectClickHandler handleYew = new ObjectClickHandler(new Object[] { ""Yew"", ""Yew tree"" }, e -> { if (e.getObject().getDefinitions().containsOption(0, ""Chop down"")) e.getPlayer().getActionManager().setAction(new Woodcutting(e.getObject(), TreeType.YEW)); }); public static ObjectClickHandler handleMagic = new ObjectClickHandler(new Object[] { ""Magic tree"", ""Cursed magic tree"" }, e -> { if (e.getObject().getDefinitions().containsOption(0, ""Chop down"")) e.getPlayer().getActionManager().setAction(new Woodcutting(e.getObject(), TreeType.MAGIC)); }); public static ObjectClickHandler handleSwayingTree = new ObjectClickHandler(new Object[] { ""Swaying tree"" }, e -> { if (e.getObject().getDefinitions().containsOption(0, ""Cut-branch"")) e.getPlayer().getActionManager().setAction(new Woodcutting(e.getObject(), TreeType.SWAYING) { @Override public void fellTree() { } }); }); public static ObjectClickHandler handleBlisterwood = new ObjectClickHandler(new Object[] { 61321 }, e -> { if (e.getOption().equals(""Chop"")) e.getPlayer().getActionManager().setAction(new Woodcutting(e.getObject(), TreeType.BLISTERWOOD) { @Override public void fellTree() { e.getPlayer().getVars().setVarBit(9776, 2); WorldTasks.schedule(Ticks.fromMinutes(2), () -> { try { if (e.getPlayer() != null && !e.getPlayer().hasFinished()) e.getPlayer().getVars().setVarBit(9776, 1); } catch (Throwable e1) { Logger.handle(Woodcutting.class, ""handleBlisterwood"", e1); } }); } @Override public boolean checkTree() { return e.getPlayer().getVars().getVarBit(9776) == 1; } }); }); @Override public boolean start(Entity entity) { if (!checkAll(entity)) return false; entity.faceObject(treeObj); if (entity instanceof Familiar familiar) familiar.getOwner().sendMessage(""Your beaver uses its strong teeth to chop down the tree...""); else if (entity instanceof Player player) player.sendMessage(""You swing your hatchet at the "" + (TreeType.IVY == type ? ""ivy"" : ""tree"") + ""..."", true); setActionDelay(entity, 4); return true; } private boolean checkAll(Entity entity) { if (hatchet == null) hatchet = entity instanceof Player player ? Hatchet.getBest(player) : Hatchet.MITHRIL; if (entity instanceof Player player) { if (hatchet == null) { player.sendMessage(""You dont have the required level to use that axe or you don't have a hatchet.""); return false; } if (!hasWoodcuttingLevel(player)) return false; if (!player.getInventory().hasFreeSlots()) { player.sendMessage(""Not enough space in your inventory.""); player.setNextAnimation(new Animation(-1)); return false; } } else if (entity instanceof Familiar familiar && familiar.getInventory().freeSlots() == 0) return false; return true; } private boolean hasWoodcuttingLevel(Player player) { if (type.getLevel() > player.getSkills().getLevel(8)) { player.sendMessage(""You need a woodcutting level of "" + type.getLevel() + "" to chop down this tree.""); return false; } return true; } @Override public boolean process(Entity entity) { entity.anim(entity instanceof Familiar ? 7722 : hatchet.getAnim(type)); if (entity instanceof Familiar) entity.spotAnim(1459); return checkAll(entity) && checkTree(); } @Override public int processWithDelay(Entity entity) { if (!checkTree()) return -1; int level = entity instanceof Player player ? player.getSkills().getLevel(Constants.WOODCUTTING) + player.getInvisibleSkillBoost(Skills.WOODCUTTING) : wcLevel; entity.faceObject(treeObj); if (type.rollSuccess(entity instanceof Player player ? player.getAuraManager().getWoodcuttingMul() : 1.0, level, hatchet)) { giveLog(entity); int fellChance = entity instanceof Player player && player.hasEffect(Effect.EVIL_TREE_WOODCUTTING_BUFF) ? 16 : 8; if (!type.isPersistent() || (Utils.random(fellChance) == 0)) { if (entity instanceof Player player && player.getAuraManager().isActivated(AuraManager.Aura.RESOURCEFUL) && Utils.random(10) == 0) { player.sendMessage(""Your resourceful aura prevents the tree from being felled.""); return 3; } fellTree(); entity.setNextAnimation(new Animation(-1)); return -1; } } return 3; } public void fellTree() { if (!World.isSpawnedObject(treeObj) && treeObj.getPlane() < 3 && type != TreeType.IVY) { for (int x = -1;x <= 1;x++) { for (int y = -1;y <= 1;y++) { World.removeObjectTemporary(World.getObject(treeObj.getTile().transform(x, y, 1), ObjectType.SCENERY_INTERACT), type.getRespawnDelay()); World.removeObjectTemporary(World.getObject(treeObj.getTile().transform(x, y, 1), ObjectType.GROUND_INTERACT), type.getRespawnDelay()); } } } if (!World.isSpawnedObject(treeObj)) { treeObj.getAttribs().setI(""originalTrunkId"", treeObj.getId()); treeObj.setIdTemporary(TreeStumps.getStumpId(treeObj.getId()), type.getRespawnDelay()); } } public static double getLumberjackBonus(Player player) { double xpBoost = 0.0; if (player.getEquipment().getChestId() == 10939) xpBoost += 0.01; if (player.getEquipment().getLegsId() == 10940) xpBoost += 0.01; if (player.getEquipment().getHatId() == 10941) xpBoost += 0.01; if (player.getEquipment().getBootsId() == 10933) xpBoost += 0.01; if (player.getEquipment().getChestId() == 10939 && player.getEquipment().getLegsId() == 10940 && player.getEquipment().getHatId() == 10941 && player.getEquipment().getBootsId() == 10933) xpBoost += 0.01; return xpBoost; } public void giveLog(Entity entity) { if (entity instanceof Player player) { if (type != TreeType.IVY) { if (type.getLogsId() != null) player.incrementCount(ItemDefinitions.getDefs(type.getLogsId()[0]).getName() + "" chopped""); } else player.incrementCount(""Choking ivy chopped""); if (Utils.random(256) == 0) { for (Item rew : DropTable.calculateDrops(player, DropSets.getDropSet(""nest_drop""))) World.addGroundItem(rew, Tile.of(player.getTile()), player, true, 30); player.sendMessage(""A bird's nest falls out of the tree!""); } double bxp = type.getXp() * getLumberjackBonus(player); player.getSkills().addXp(Constants.WOODCUTTING, type.getXp() + bxp); if (bxp > 0.01) player.getSkills().queueBonusXPDrop(bxp); if (player.hasEffect(Effect.JUJU_WOODCUTTING)) { int random = Utils.random(100); if (random < 11) player.addEffect(Effect.JUJU_WC_BANK, 75); } if (Utils.random(256) == 0) { for (Item rew : DropTable.calculateDrops(player, DropSets.getDropSet(""nest_drop""))) World.addGroundItem(rew, Tile.of(player.getTile()), player, true, 30); player.sendMessage(""A bird's nest falls out of the tree!""); } if (type.getLogsId() != null) { if (player.hasEffect(Effect.JUJU_WC_BANK) || player.hasEffect(Effect.EVIL_TREE_WOODCUTTING_BUFF)) { for (int item : type.getLogsId()) player.getBank().addItem(new Item(item, 1), true); player.spotAnim(player.hasEffect(Effect.EVIL_TREE_WOODCUTTING_BUFF) ? 312 : 2897); } else for (int item : type.getLogsId()) player.getInventory().addItemDrop(item, 1); if (type == TreeType.FRUIT_TREE) return; if (type == TreeType.IVY) { player.sendMessage(""You successfully cut an ivy vine."", true); } else { String logName = ItemDefinitions.getDefs(type.getLogsId()[0]).getName().toLowerCase(); player.sendMessage(""You get some "" + logName + ""."", true); if (player.getEquipment().getWeaponId() == 13661) if (Utils.getRandomInclusive(3) == 0) { player.getSkills().addXp(Constants.FIREMAKING, type.getXp() * 1); player.getInventory().deleteItem(type.getLogsId()[0], 1); player.sendMessage(""The adze's heat instantly incinerates the "" + logName + "".""); player.setNextSpotAnim(new SpotAnim(1776)); } } } } if (entity instanceof Familiar familiar) { for (int item : type.getLogsId()) familiar.getInventory().add(new Item(item, 1)); familiar.getOwner().getSkills().addXp(Constants.WOODCUTTING, type.getXp() * getLumberjackBonus(familiar.getOwner())); } } public boolean checkTree() { return ChunkManager.getChunk(treeObj.getTile().getChunkId()).objectExists(new GameObject(treeObj, treeId)); } @Override public void stop(Entity player) { setActionDelay(player, 4); } }" "package com.rs.game.content.transportation; public class BoatingD extends Conversation { private int cost; private boolean returning; private Carrier ship; public BoatingD(Player player, int npcId) { super(player); if (npcId == 380 && player.getQuestManager().getStage(Quest.PIRATES_TREASURE) == PiratesTreasure.SMUGGLE_RUM) { player.startConversation(new CustomsOfficerPiratesTreasureD(player).getStart()); return; } if (npcId == 744 && !player.isQuestComplete(Quest.DRAGON_SLAYER)) { player.startConversation(new KlarenseDragonSlayerD(player).getStart()); return; } if (npcId == 744 && !player.getQuestManager().getAttribs(Quest.DRAGON_SLAYER).getB(DragonSlayer.IS_BOAT_FIXED_ATTR)) { player.startConversation(new Dialogue().addNPC(KLARENSE, HeadE.CALM_TALK, ""Wow! You sure are lucky! Seems the Lady Lumbridge just washed right up into the dock by herself! She's pretty badly damaged, though ..."")); return; } Object[] attributes = getBoatForShip(player, npcId); if (attributes == null) return; ship = (Carrier) attributes[0]; returning = (Boolean) attributes[1]; cost = -1; if (ship.getFares() != null) cost = ship.getFares()[0]; addNPC(npcId, HeadE.CHEERFUL, ""Hello adventurer, how can I help you today?""); addOptions(ops -> { ops.add(""Where does this boat take me?"", new Dialogue() .addNPC(npcId, HeadE.CHEERFUL, ""This boat? Why this boat takes you to "" + ship.getFixedName(returning) + ((cost == -1) ? ""."" : "", for a small fee of "" + cost + "" coins."")) .addOptions(cost == -1 ? ""Board the ship?"" : ""Pay the price of "" + cost + "" coins?"", conf -> { conf.add(""Yes, board the ship."", () -> TravelMethods.sendCarrier(player, ship, returning)); conf.add(cost == -1 ? ""No, sometime later."" : ""I can't afford that!""); })); ops.add(""Nevermind.""); }); } public static Object[] getBoatForShip(Player player, int npcId) { return switch (npcId) { case 376, 377, 378 -> new Object[]{Carrier.KARAMJA_FARE, false}; case 380 -> player.withinDistance(Tile.of(2772, 3227, 0), 30) ? new Object[]{Carrier.BRIMHAVEN_FARE, true} : new Object[]{Carrier.KARAMJA_FARE, true}; case 381 -> new Object[]{Carrier.BRIMHAVEN_FARE, true}; case 744 -> new Object[]{Carrier.CRANDOR_FARE, false}; case 2728, 2729, 657 -> new Object[]{Carrier.ENTRANA_FARE, false}; case 2730 -> new Object[]{Carrier.ENTRANA_FARE, true}; case 3801 -> new Object[]{Carrier.VOID_OUTPOST_FARE, false}; case 3800 -> new Object[]{Carrier.VOID_OUTPOST_FARE, true}; case 4962 -> new Object[]{Carrier.BRIMHAVEN_FARE, false}; case 5482 -> new Object[]{Carrier.JATIZO, true}; case 5481 -> new Object[]{Carrier.JATIZO, false}; case 5508 -> new Object[]{Carrier.NEITZNOT, false}; case 5507 -> new Object[]{Carrier.NEITZNOT, true}; case 1304 -> new Object[]{Carrier.MISCELLENIA, false}; case 1385 -> new Object[]{Carrier.MISCELLENIA, true}; case 413 -> new Object[]{Carrier.PIRATES_COVE, false}; case 4537 -> new Object[]{Carrier.PIRATES_COVE, true}; case 407 -> new Object[]{Carrier.LUNAR_ISLE, false}; case 408 -> new Object[]{Carrier.LUNAR_ISLE, true}; case 2435 -> new Object[]{Carrier.WATERBIRTH, false}; case 2438 -> new Object[]{Carrier.WATERBIRTH, true}; case 3160 -> new Object[]{Carrier.TEACH_MOS_LE_HARMLESS, player.withinDistance(Tile.of(3714, 3499, 1)) ? false : true}; default -> null; }; } }" "package com.rs.game.content.transportation; public final class FadingScreen { public static void fade(final Player player, int ticks, final Runnable event) { unfade(player, fade(player, ticks), event); } public static void fade(final Player player, final Runnable event) { unfade(player, fade(player), event); } public static void unfade(final Player player, int ticks, final Runnable event) { unfade(player, 4, ticks, event); } public static void unfade(final Player player, int startDelay, int delay, final Runnable event) { int leftTime = startDelay + delay; if (startDelay > 0) WorldTasks.schedule(new Task() { @Override public void run() { try { unfade(player, event); } catch (Throwable e) { Logger.handle(FadingScreen.class, ""unfade"", e); } } }, leftTime); else unfade(player, event); } public static void unfade(final Player player, Runnable event) { event.run(); player.getInterfaceManager().setFadingInterface(170); WorldTasks.schedule(new Task() { @Override public void run() { try { player.getInterfaceManager().closeFadingInterface(); } catch (Throwable e) { Logger.handle(FadingScreen.class, ""unfade"", e); } } }, 4); } public static int fade(Player player, int fadeTicks) { player.getInterfaceManager().setFadingInterface(115); return fadeTicks; } public static int fade(Player player) { return fade(player, 0); } }" "package com.rs.game.content.transportation; @PluginEventHandler public class FairyRings { private final static String[][] LETTERS = { { ""a"", ""b"", ""c"", ""d"" }, { ""i"", ""j"", ""k"", ""l"" }, { ""p"", ""q"", ""r"", ""s"" } }; private final static Tile FAIRY_SOURCE = Tile.of(2412, 4434, 0); private final static int FIRST_ANIMATION = 3254, SECOND_ANIMATION = 3255; private final static int FIRST_GRAPHICS = 2670, SECOND_GRAPHICS = 2671; public static enum Ring { DLS(77, ""Dungeons: Myreque hideout"", Tile.of(3501, 9821, 3)) { @Override public boolean meetsRequirements(Player player, boolean silent) { return player.isQuestComplete(Quest.IN_SEARCH_OF_MYREQUE, silent ? null : ""to use this fairy ring code.""); } }, DLR(76, ""Islands: Poison Waste south of Isafdar"", Tile.of(2213, 3099, 0)), DLQ(75, ""Kharidian Desert: North of Nardah"", Tile.of(3423, 3016, 0)), DLP(74, ""Nowhere"", null), DKS(73, ""Kandarin: Snowy Hunter area"", Tile.of(2744, 3719, 0)), DKR(72, ""Misthalin: Edgeville"", Tile.of(3129, 3496, 0)), DKQ(71, ""Glacor Cave"", Tile.of(4183, 5726, 0)) { @Override public boolean meetsRequirements(Player player, boolean silent) { return player.isQuestComplete(Quest.RITUAL_OF_MAHJARRAT, silent ? null : ""to use this fairy ring code.""); } }, DKP(70, ""Karamja: South of Musa Point"", Tile.of(2900, 3111, 0)), DJS(69, ""Nowhere"", null), DJR(68, ""Kandarin: Sinclair Mansion (west)"", Tile.of(2676, 3587, 0)), DJQ(67, ""Nowhere"", null), DJP(66, ""Kandarin: Tower of Life"", Tile.of(2658, 3230, 0)), DIS(65, ""Misthalin: Wizards' Tower"", Tile.of(3108, 3149, 0)), DIR(64, ""Other Realms: The Gorak Plane"", Tile.of(3038, 5348, 0)), BIQ(31, ""Kharidian Desert: Near Kalphite hive"", Tile.of(3251, 3095, 0)), BIP(30, ""Islands: Polypore Dungeon"", Tile.of(3410, 3324, 0)), ALS(29, ""Kandarin: McGrubor's Wood"", Tile.of(2644, 3495, 0)), ALR(28, ""Other Realms: Abyss"", Tile.of(3059, 4875, 0)), ALQ(27, ""Morytania: Haunted Woods"", Tile.of(3597, 3495, 0)) { @Override public boolean meetsRequirements(Player player, boolean silent) { return player.isQuestComplete(Quest.PRIEST_IN_PERIL, silent ? null : ""to use this fairy ring code.""); } }, ALP(26, ""Kandarin: Feldip Hills"", Tile.of(2468, 4189, 0)) { @Override public boolean meetsRequirements(Player player, boolean silent) { return player.isQuestComplete(Quest.FAIRY_TALE_III_BATTLE_AT_ORKS_RIFT, silent ? null : ""to use this fairy ring code.""); } }, AKS(25, ""Feldip Hills: Feldip Hunter area"", Tile.of(2571, 2956, 0)), AKR(24, ""Nowhere"", null), AKQ(23, ""Kandarin: Piscatoris Hunter area"", Tile.of(2319, 3619, 0)), AKP(22, ""Nowhere"", null), AJS(21, ""Islands: Penguins near Miscellania"", Tile.of(2500, 3896, 0)), AJR(20, ""Kandarin: Slayer cave south-east of Rellekka"", Tile.of(2780, 3613, 0)), AJQ(19, ""Dungeons: Dark cave south of Dorgesh-Kaan"", Tile.of(2735, 5221, 0)) { @Override public boolean meetsRequirements(Player player, boolean silent) { return player.isQuestComplete(Quest.DEATH_TO_DORGESHUUN, silent ? null : ""to use this fairy ring code.""); } }, AJP(18, ""Nowhere"", null), AIS(17, ""Nowhere"", null), AIR(16, ""Islands: South of Witchaven"", Tile.of(2700, 3247, 0)), AIQ(15, ""Asgarnia: Mudskipper Point"", Tile.of(2996, 3114, 0)), AIP(14, ""Nowhere"", null), DIQ(63, ""Nowhere"", null), DIP(62, ""Mos Le'Harmless: Isle on the coast of Mos Le'Harmless"", Tile.of(3763, 2930, 0)) { @Override public boolean meetsRequirements(Player player, boolean silent) { return player.isQuestComplete(Quest.FAIRY_TALE_III_BATTLE_AT_ORKS_RIFT, silent ? null : ""to use this fairy ring code.""); } }, CLS(61, ""Islands: Jungle spiders near Yanille"", Tile.of(2682, 3081, 0)), CLR(60, ""Ape Atoll: West of the Ape Atoll Agility Course"", Tile.of(2735, 2742, 0)) { @Override public boolean meetsRequirements(Player player, boolean silent) { return player.isQuestComplete(Quest.FAIRY_TALE_III_BATTLE_AT_ORKS_RIFT, silent ? null : ""to use this fairy ring code.""); } }, CLQ(59, ""Nowhere"", null), CLP(58, ""Islands: South of Draynor Village"", Tile.of(3082, 3206, 0)), CKS(57, ""Morytania: Canifis"", Tile.of(3447, 3470, 0)) { @Override public boolean meetsRequirements(Player player, boolean silent) { return player.isQuestComplete(Quest.PRIEST_IN_PERIL, silent ? null : ""to use this fairy ring code.""); } }, CKR(56, ""Karamja: South of Tai Bwo Wannai Village"", Tile.of(2801, 3003, 0)), CKQ(55, ""Nowhere"", null), CKP(54, ""Other Realms: Cosmic Entity's plane"", Tile.of(2075, 4848, 0)), CJS(53, ""Nowhere"", null), CJR(52, ""Kandarin: Sinclair Mansion (east)"", Tile.of(2705, 3576, 0)), CJQ(51, ""Nowhere"", null), CJP(50, ""Nowhere"", null), CIS(49, ""Nowhere"", null), CIR(48, ""Nowhere"", null), CIQ(47, ""Kandarin: North-west of Yanille"", Tile.of(2528, 3127, 0)), CIP(46, ""North-west Miscellania"", Tile.of(2513, 3884, 0)) { @Override public boolean meetsRequirements(Player player, boolean silent) { return player.isQuestComplete(Quest.FREMENNIK_TRIALS, silent ? null : ""to use this fairy ring code.""); } }, BLS(45, ""Nowhere"", null), BLR(44, ""Kandarin: Legend's Guild"", Tile.of(2740, 3351, 0)), BLQ(43, ""Yu'biusk"", Tile.of(2228, 4244, 1)) { @Override public boolean meetsRequirements(Player player, boolean silent) { return player.isQuestComplete(Quest.CHOSEN_COMMANDER, silent ? null : ""to use this fairy ring code.""); } }, BLP(42, ""Dungeons: TzHaar area"", Tile.of(4622, 5147, 0)), BKS(41, ""Nowhere"", null), BKR(40, ""Morytania: Mort Myre"", Tile.of(3469, 3431, 0)) { @Override public boolean meetsRequirements(Player player, boolean silent) { return player.isQuestComplete(Quest.PRIEST_IN_PERIL, silent ? null : ""to use this fairy ring code.""); } }, BKQ(39, ""Other Realms: Enchanted Valley"", Tile.of(3041, 4532, 0)), BKP(38, ""Feldip Hills: South of Castle Wars"", Tile.of(2385, 3035, 0)), BJS(37, ""Nowhere"", null), BJR(36, ""Fisher Realm"", Tile.of(2650, 4730, 0)) { @Override public boolean meetsRequirements(Player player, boolean silent) { return player.isQuestComplete(Quest.HOLY_GRAIL, silent ? null : ""to use this fairy ring code.""); } }, BJQ(35, ""Dungeons: Ancient cavern"", Tile.of(1737, 5342, 0)) { @Override public boolean meetsRequirements(Player player, boolean silent) { return player.getVars().getVarBit(AncientCavern.FIXED_RING_VARBIT) == 1; } }, BJP(34, ""Nowhere"", null), BIS(33, ""Kandarin: Ardougne Zoo"", Tile.of(2635, 3266, 0)), BIR(32, ""Sparse Plane"", Tile.of(2455, 4396, 0)) { @Override public boolean meetsRequirements(Player player, boolean silent) { return player.isQuestComplete(Quest.FAIRY_TALE_III_BATTLE_AT_ORKS_RIFT, silent ? null : ""to use this fairy ring code.""); } }, DIR_AKS(-1, ""Kethsi: Isle of Sann"", Tile.of(4026, 5699, 0)) { @Override public boolean meetsRequirements(Player player, boolean silent) { return player.isQuestComplete(Quest.RITUAL_OF_MAHJARRAT, silent ? null : ""to use this fairy ring code.""); } }, AIR_DLR_DJQ_AJS(-1, ""Fairy Queen's Hideout"", Tile.of(1560, 4234, 0)) { @Override public boolean meetsRequirements(Player player, boolean silent) { return player.isQuestComplete(Quest.FAIRY_TALE_II_CURE_A_QUEEN, silent ? null : ""to use this fairy ring code.""); } }, BIR_DIP_CLR_ALP(-1, ""Ork's Rift"", Tile.of(1626, 4176, 0)) { //1567, 4133 during quest? @Override public boolean meetsRequirements(Player player, boolean silent) { return player.isQuestComplete(Quest.FAIRY_TALE_III_BATTLE_AT_ORKS_RIFT, silent ? null : ""to use this fairy ring code.""); } }, ; private final String name; private final int logId; private final Tile tile; Ring(int logId, String name, Tile tile) { this.logId = logId; this.name = name; this.tile = tile; } public static Ring forHash(String hash) { for (Ring ring : Ring.values()) { if (ring.name().length() > 3 && hash.endsWith(ring.name())) return ring; } try { return Ring.valueOf(hash); } catch(IllegalArgumentException e) { return null; } } public Tile getTile() { return tile; } public int getLogId() { return logId; } public boolean meetsRequirements(Player player, boolean silent) { return true; } } public static ObjectClickHandler handleRings = new ObjectClickHandler(new Object[] { ""Fairy ring"", 27331 }, e -> { if (e.getObjectId() == 12094) {//Fairy ring by evil chicken sendTeleport(e.getPlayer(), Tile.of(3202, 3169, 0)); return; } if(e.getPlayer().isQuestComplete(Quest.FAIRY_TALE_I_GROWING_PAINS, ""to use the fairy ring system."")) { FairyRings.openRingInterface(e.getPlayer(), e.getObject().getTile(), e.getObjectId() == 12128); return; } e.getPlayer().startConversation(new Dialogue().addPlayer(HeadE.FRUSTRATED, ""I don't know what's supposed to be happening here..."")); }); public static ButtonClickHandler handleButtons = new ButtonClickHandler(734, e -> { if (e.getComponentId() == 21) confirmRingHash(e.getPlayer()); else handleDialButtons(e.getPlayer(), e.getComponentId()); }); public static ButtonClickHandler handleQuickTeleport = new ButtonClickHandler(735, e -> { if (e.getComponentId() >= 14 && e.getComponentId() <= 14 + 64) sendRingTeleport(e.getPlayer(), e.getComponentId() - 14); }); public static boolean checkAll(Player player) { if ((player.isQuestComplete(Quest.FAIRY_TALE_III_BATTLE_AT_ORKS_RIFT)) || player.getEquipment().getWeaponId() == 772 || player.getEquipment().getWeaponId() == 9084) return true; player.sendMessage(""The fairy ring only works for those who wield fairy magic.""); return false; } public static boolean openRingInterface(Player player, Tile tile, boolean source) { if (checkAll(player)) { player.addWalkSteps(tile.getX(), tile.getY(), -1, true); if (source) { player.getInterfaceManager().sendInterface(734); sendTravelLog(player); resetRingHash(player); } else sendTeleport(player, FAIRY_SOURCE); return true; } return false; } private static void sendTravelLog(Player player) { player.getInterfaceManager().sendInventoryInterface(735); for (Ring r : Ring.values()) if (r.meetsRequirements(player, true) && !r.name.equals(""Nowhere"") && r.logId != -1) player.getPackets().setIFText(735, r.logId, "" "" + r.name); } public static boolean confirmRingHash(Player player) { int[] locationArray = player.getTempAttribs().removeO(""location_array""); if (locationArray == null) return false; StringBuilder string = new StringBuilder(); int index = 0; for (int letterValue : locationArray) string.append(LETTERS[index++][letterValue]); return sendRingTeleport(player, string.toString().toUpperCase()); } public static boolean sendRingTeleport(Player player, int hash) { int letter1 = hash / 16; hash -= letter1 * 16; int letter2 = hash / 4; hash -= letter2 * 4; int letter3 = hash; StringBuilder string = new StringBuilder(); string.append(LETTERS[0][letter1]); string.append(LETTERS[1][letter2]); string.append(LETTERS[2][letter3]); return sendRingTeleport(player, string.toString().toUpperCase()); } public static boolean sendRingTeleport(Player player, String hash) { Ring ring = Ring.forHash(hash); String historyHash = player.getTempAttribs().getO(""fairyRingHistory""); historyHash = historyHash == null ? ring.toString() : (historyHash + ""_"" + hash); if (historyHash.split(""_"").length > 4) historyHash = historyHash.substring(4); Ring specialRing = Ring.forHash(historyHash); if (specialRing != null) ring = specialRing; player.getTempAttribs().setO(""fairyRingHistory"", historyHash); if (ring == null || ring.getTile() == null || !ring.meetsRequirements(player, false)) { sendTeleport(player, Tile.of(FAIRY_SOURCE, 2)); return false; } sendTeleport(player, ring.getTile()); return true; } private static void resetRingHash(Player player) { player.getTempAttribs().setO(""location_array"", new int[3]); for (int i = 0; i < 3; i++) player.getVars().setVarBit(2341 + i, 0); player.getVars().syncVarsToClient(); } public static void sendTeleport(final Player player, final Tile tile) { Magic.sendTeleportSpell(player, FIRST_ANIMATION, SECOND_ANIMATION, FIRST_GRAPHICS, SECOND_GRAPHICS, 0, 0, tile, 2, false, TeleType.OBJECT, null); } public static void handleDialButtons(final Player player, int componentId) { int[] locationArray = player.getTempAttribs().getO(""location_array""); if (locationArray == null) { player.closeInterfaces(); return; } int index = (componentId - 23) / 2; if (componentId % 2 == 0) locationArray[index]++; else locationArray[index]--; locationArray = getCorrectValues(locationArray); player.getTempAttribs().setO(""location_array"", locationArray); for (int i = 0; i < 3; i++) player.getVars().setVarBit(2341 + i, locationArray[i] == 1 ? 3 : locationArray[i] == 3 ? 1 : locationArray[i]); player.getVars().syncVarsToClient(); } private static int[] getCorrectValues(int[] locationArray) { int loop = 0; for (int values : locationArray) locationArray[loop++] = values & 0x3; return locationArray; } }" "package com.rs.game.content.transportation; @PluginEventHandler public class GnomeGlider { private static final int GLIDER_INTEFACE = 138; private static final Tile[] GLIDERS = { Tile.of(3,38,54,32,47), Tile.of(0,44,54,29,42), Tile.of(0,51,53,57,38), Tile.of(0,51,50,20,11), Tile.of(0,46,46,29,25), Tile.of(0,39,46,53,27), Tile.of(0,39,49,0,55) }; private static final int[][] CONFIGS = { { -1, 1, 3, 4, 7, 10, 12 }, { -1, 2, -1, 5, 6, 11, 13 } }; public static ButtonClickHandler handleButtons = new ButtonClickHandler(138, e -> { if (e.getPlayer().getTempAttribs().getB(""using_carrier"")) return; switch (e.getComponentId()) { case 19: sendGlider(e.getPlayer(), 6, false); break; case 22: sendGlider(e.getPlayer(), 4, false); case 23: //grand tree... break; case 24: sendGlider(e.getPlayer(), 1, false); break; case 25: sendGlider(e.getPlayer(), 2, false); break; case 26: sendGlider(e.getPlayer(), 3, false); break; case 27: sendGlider(e.getPlayer(), 5, false); break; default: break; } }); public static NPCClickHandler openInterface = new NPCClickHandler(new Object[] { 1800, 3809, 3810, 3811, 3812, 6563 }, e -> { switch (e.getNPCId()) { case 3809: sendGlider(e.getPlayer(), 3, true); break; case 3810: sendGlider(e.getPlayer(), 1, true); break; case 3812: sendGlider(e.getPlayer(), 4, true); break; case 1800: sendGlider(e.getPlayer(), 5, true); break; case 6563: sendGlider(e.getPlayer(), 6, true); break; default: break; } e.getPlayer().getInterfaceManager().sendInterface(GLIDER_INTEFACE); }); public static void sendGlider(final Player player, final int index, final boolean isReturning) { player.getVars().setVar(153, CONFIGS[isReturning ? 1 : 0][index]); player.getTempAttribs().setB(""using_carrier"", true); FadingScreen.fade(player, 3, () -> { player.useStairs(-1, GLIDERS[isReturning ? 0 : index], 0, 2); player.closeInterfaces(); player.getTempAttribs().removeB(""using_carrier""); player.getVars().setVar(153, 0); }); } }" "package com.rs.game.content.transportation; public class ItemTeleports { /* * 1230, 1232 - grand seed pod gfx */ private static final String[] ITEM_NAMES = { ""ring of duelling"", ""games necklace"", ""amulet of glory (t"", ""amulet of glory"", ""skills necklace"", ""combat bracelet"", ""digsite"", ""ring of wealth"", ""ring of slaying"", ""lumber yard"", ""nardah"", ""tai bwo wannai"", ""bandit camp"", ""phoenix lair"", ""miscellania"" }; private static final String[][] TELEPORT_NAMES = { { ""Al Kharid Duel Arena"", ""Castle Wars Arena"", ""Mobilizing Armies Command Centre"", ""Fist Of Guthix"", ""Nowhere"" }, { ""Burthorpe Games Room"", ""Barbarian Outpost"", ""Gamers' Grotto"", ""Corporeal Beast"", ""Nowhere"" }, { ""Edgeville"", ""Karamja"", ""Draynor Village"", ""Al Kharid"", ""Nowhere"" }, { ""Edgeville"", ""Karamja"", ""Draynor Village"", ""Al Kharid"", ""Nowhere"" }, { ""Fishing Guild"", ""Mining Guild"", ""Crafting Guild"", ""Cooking Guild"", ""Nowhere"" }, { ""Warrior's Guild"", ""Champions Guild"", ""Monastery"", ""Ranging Guild"", ""Nowhere"" }, { ""Digsite"", ""Nowhere"" }, { ""Miscellania"", ""Grand Exchange"", ""Nowhere"" }, { ""Sumona's Lair"", ""Slayer Tower"", ""Fremennik Slayer Dungeon"", ""Tarn's Lair"", ""Nowhere"" }, { ""Lumber Yard"", ""Nowhere"" }, { ""Nardah"", ""Nowhere"" }, { ""Tai Bwo Wannai"", ""Nowhere"" }, { ""Bandit camp"", ""Nowhere"" }, { ""Phoenix lair"", ""Nowhere"" }, { ""Miscellania"", ""Nowhere"" } }; private static final Tile[][] COORDINATES = { { Tile.of(3316, 3232, 0), Tile.of(2443, 3089, 0), Tile.of(2416, 2836, 0), Tile.of(1701, 5600, 0) }, { Tile.of(2208, 4940, 0), Tile.of(2519, 3571, 0), Tile.of(2970, 9679, 0), Tile.of(2886, 4377, 2), }, { Tile.of(3087, 3496, 0), Tile.of(2918, 3176, 0), Tile.of(3105, 3251, 0), Tile.of(3293, 3163, 0) }, { Tile.of(3087, 3496, 0), Tile.of(2918, 3176, 0), Tile.of(3105, 3251, 0), Tile.of(3293, 3163, 0) }, { Tile.of(2614, 3384, 0), Tile.of(3032, 3337, 0), Tile.of(2933, 3293, 0), Tile.of(3143, 3442, 0) }, { Tile.of(2878, 3542, 0), Tile.of(3191, 3363, 0), Tile.of(2607, 3220, 0), Tile.of(2657, 3238, 0) }, { Tile.of(3356, 3421, 0) }, { Tile.of(2527, 3860, 0), Tile.of(3167, 3492, 0) }, { Tile.of(3353, 3006, 0), Tile.of(3427, 3538, 0), Tile.of(2787, 3616, 0), Tile.of(3150, 4666, 0) }, { Tile.of(3305, 3489, 0) }, { Tile.of(3423, 2914, 0) }, { Tile.of(2796, 3082, 0) }, { Tile.of(3170, 2982, 0) }, { Tile.of(2294, 3626, 0) }, { Tile.of(2519, 3860, 0) }, }; private static final int[] LOWEST_AMOUNT = { 2566, 3867, 1706, 10362, 11113, 11126, 11190, 2572, 13288, 19480, 19475, 19479, 19476, 19478, 19477 }; public static final int EMOTE = 9603, GFX = 1684, SCROLL_EMOTE = 14293, SCROLL_GFX = 94; private static Dialogue getTransportationDialogue(Player player, Item item, int itemId, String... locations) { return new Dialogue().addOptions(""Where would you like to teleport to?"", (ops) -> { for (int i = 0; i < locations.length; i++) { final int index = i; ops.add(locations[i], () -> { if (item != null) { ItemTeleports.sendTeleport(player, item, index); return; } ItemTeleports.sendTeleport(player, player.getInventory().getItems().lookup(itemId), index, false, locations.length); }); } }); } public static boolean transportationDialogue(Player player, Item item) { int index = getIndex(item); if (!checkAll(player, item, index, 0, 1)) return false; player.startConversation(getTransportationDialogue(player, null, item.getId(), TELEPORT_NAMES[index])); return true; } public static boolean transportationDialogue(Player player, int itemId) { int index = getIndex(new Item(itemId, 1)); if (index == -1) return false; player.startConversation(getTransportationDialogue(player, new Item(itemId, 1), itemId, TELEPORT_NAMES[index])); return true; } private static boolean checkAll(Player player, Item item, int index, int optionsIndex, int optionsLength) { if (index == -1) return false; if (optionsIndex >= optionsLength || optionsIndex >= COORDINATES[index].length) { player.stopAll(); // nowhere option return false; } if (!isScrollTeleport(index) && (item.getId() == 10362 || !item.getName().toLowerCase().contains(""(""))) { player.sendMessage(""Your "" + item.getName().toLowerCase() + "" has ran out of charges. You need to recharge it if you wish it use it once more.""); return false; } return true; } public static void sendItemTransport(Player player, Item item, boolean wearing, int locationIndex) { if (!wearing) ItemTeleports.transportationDialogue(player, new Item(item.getId(), 1)); else ItemTeleports.sendTeleport(player, player.getEquipment().getItem(Equipment.getItemSlot(item.getId())), locationIndex, true); } public static void sendTeleport(Player player, Item item, int optionIndex) { int index = getIndex(item); if (index < 0) return; if (optionIndex > COORDINATES[index].length) { player.sendMessage(""Error handling teleport option. Report this to administrators.""); return; } Magic.sendTeleportSpell(player, getFirstEmote(index), -2, getFirstGFX(index), -1, 0, 0, COORDINATES[index][optionIndex], 4, true, TeleType.ITEM, null); } public static void sendTeleport(Player player, Item item, int optionIndex, boolean equipmentTeleport) { sendTeleport(player, item, optionIndex, equipmentTeleport, 4); } public static void sendTeleport(Player player, Item item, int optionIndex, boolean equipmentTeleport, int optionslength) { int index = getIndex(item); if (!checkAll(player, item, index, optionIndex, optionslength)) return; if (HeroesGuild.isGloryOrROW(item.getId())) player.getTempAttribs().setB(""glory"", true); Magic.sendTeleportSpell(player, getFirstEmote(index), -2, getFirstGFX(index), -1, 0, 0, COORDINATES[index][optionIndex], 4, true, TeleType.ITEM, () -> { int newItemId = item.getId() + ((isNegative(index) ? -1 : 1) * (isIncremented(index) ? 2 : 1)), slot = equipmentTeleport ? Equipment.getItemSlot(item.getId()) : player.getInventory().getItems().getThisItemSlot(item); if (item.getId() == LOWEST_AMOUNT[index] && destroyOnEmpty(index)) { if (equipmentTeleport) player.getEquipment().deleteItem(item.getId(), item.getAmount()); else player.getInventory().deleteItem(item.getId(), 1); player.sendMessage(""Your "" + item.getName().toLowerCase().replace("" (1)"", """") + "" has crumbled to dust.""); } else { if (newItemId == 20651) newItemId = 2572; item.setId(newItemId); if (equipmentTeleport) player.getEquipment().refresh(slot); else player.getInventory().refresh(slot); } }); } private static boolean isScrollTeleport(int index) { return index >= 9 && index <= 14; } public static int getFirstEmote(int index) { if (isScrollTeleport(index)) return SCROLL_EMOTE; return EMOTE; } public static int getFirstGFX(int index) { if (isScrollTeleport(index)) return SCROLL_GFX; return GFX; } private static int getIndex(Item item) { for (int i = 0; i < ITEM_NAMES.length; i++) if (item.getName().toLowerCase().contains(ITEM_NAMES[i])) return i; return -1; } private static boolean isNegative(int index) { return index == 3 || index == 6 || index == 7; } private static boolean isIncremented(int index) { return index == 0 || index == 1 || index == 2 || index == 3 || index == 4 || index == 5 || index == 7; } private static boolean destroyOnEmpty(int index) { return index == 0 || index == 1 || index == 6 || index == 8 || isScrollTeleport(index); } }" "package com.rs.game.content.transportation; @PluginEventHandler public class SpiritTree { private static final int TREE_INTERFACE = 864; private static final Tile[] TELEPORTS = { Tile.of(2554, 3255, 0), Tile.of(3187, 3507, 0), Tile.of(2416, 2852, 0), Tile.of(2339, 3108, 0), Tile.of(2541, 3170, 0), Tile.of(2462, 3445, 0) }; public static ObjectClickHandler handleTrees = new ObjectClickHandler(new Object[] { ""Spirit Tree"", ""Spirit tree"", 26723 }, e -> { if (!e.getPlayer().isQuestComplete(Quest.TREE_GNOME_VILLAGE)) { e.getPlayer().simpleDialogue(""The tree doesn't feel like talking.""); return; } String op = e.getOption().toLowerCase(); if (op.contains(""talk"")) { int evilTreeHead = (e.getObjectId() == 68973 && e.getObjectId() == 68974) ? 3637 : 3636; e.getPlayer().startConversation(new Dialogue() .addNPC(evilTreeHead, HeadE.CALM_TALK, ""If you are a friend of the gnome people, you are a friend of mine. Do you wish to travel?"") .addOptions(ops -> { ops.add(""Yes, please."", () -> SpiritTree.openInterface(e.getPlayer())); EvilTreesKt.handleEvilTreeOps(e.getPlayer(), ops, evilTreeHead); ops.add(""No, thanks.""); })); } else if (op.contains(""travel"") || op.contains(""teleport"")) { SpiritTree.openInterface(e.getPlayer()); } }); public static void openInterface(Player player) { player.getVars().setVarBit(3959, 3); player.getInterfaceManager().sendInterface(TREE_INTERFACE); player.getPackets().setIFRightClickOps(TREE_INTERFACE, 6, 0, 7, 0); if (player.getRegionId() == 10033 || player.getRegionId() == 12102) player.getVars().setVar(1469, 0x27b8c61); else if (player.getRegionId() == 9781) player.getVars().setVar(1469, 0x2678d74); else sendTeleport(player, TELEPORTS[4]); } public static ButtonClickHandler handleButtons = new ButtonClickHandler(864, e -> handleSpiritTree(e.getPlayer(), e.getSlotId())); public static void sendTeleport(Player player, Tile tile) { player.sendMessage(""You place your hands on the dry tough bark of the spirit tree, and feel a surge of energy run through your veins.""); Magic.sendTeleportSpell(player, 7082, 7084, 1229, 1229, 1, 0, tile, 4, true, TeleType.OBJECT, null); } public static void handleSpiritTree(Player player, int slot) { if (slot == 0) if (player.getRegionId() == 10033) slot = 6; else slot = 5; sendTeleport(player, TELEPORTS[slot - 1]); } }" "package com.rs.game.content.transportation; @PluginEventHandler public class TravelMethods { private static final int TRAVEL_INTERFACE = 299, CHARTER_INTERFACE = 95; private static final int[] REGIONS = { 8496, 14646, 11061, 11823, 11825, 11058, 10545, 12081, 14637, -1, 10284 }; public enum Carrier { PORT_TYRAS(new int[] { -1, 3200, 3200, 3200, 3200, 3200, 3200, 3200, 1600, -1, 3200 }, Tile.of(0,33,48,30,50)), PORT_PHASMATYS(new int[] { 3200, -1, 3500, -1, 2900, 2900, 4100, 1300, -1, -1, 2800 }, Tile.of(0,57,54,54,47)), CATHERBY(new int[] { 3200, 2500, -1, 1600, 480, 480, 1600, 1000, 1750, -1, 3400 }, Tile.of(0,43,53,40,22)), SHIP_YARD(new int[] { 3200, -1, 1600, -1, 200, 400, 720, 400, 225, -1, 900 }, Tile.of(0,46,47,57,24)), KARAMJA(new int[] { 3200, 2900, 480, 200, -1, 200, 400, -1, 225, -1, 2000 }, Tile.of(0,46,49,10,22)), BRIMHAVEN(new int[] { 3200, 2900, 480, 400, 200, -1, 400, 1600, 975, -1, 3800 }, Tile.of(0,43,50,8,38)), PORT_KHAZARD(new int[] { 3200, 4100, 1600, 1600, 1600, 1600, -1, 1280, 1025, -1, 5000 }, Tile.of(0,41,49,50,8)), PORT_SARIM(new int[] { 3200, 1300, 1000, 400, -1, 1600, 1280, -1, 325, -1, 1400 }, Tile.of(3038, 3192, 0)), MOS_LE_HARMLESS(new int[] { 1600, -1, 625, 275, 1025, 725, 1025, 325, -1, -1, 500 }, Tile.of(0,57,45,23,51)), CRANDOR(new int[] { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, Tile.of(0,40,44,63,41)), //disabled OO_GLOG(new int[] { 3200, 2800, 3400, 900, 2000, 3800, 5000, 1400, 550, -1, -1 }, Tile.of(0,40,44,63,41)), ENTRANA_FARE(null, ""Port Sarim"", Tile.of(2834, 3335, 0), Tile.of(3048, 3234, 0)), CRANDOR_FARE(null, ""Port Sarim"", Tile.of(2853, 3238, 0), Tile.of(3047, 3204, 0)), KARAMJA_FARE(new int[] { 30 }, ""Port Sarim"", Tile.of(2956, 3146, 0), Tile.of(3029, 3217, 0)), BRIMHAVEN_FARE(new int[] { 30 }, ""Ardougne"", Tile.of(2772, 3234, 0), Tile.of(2683, 3271, 0)), UNUSED(null, null, null, null), PORT_KHAZARD_FARE(null, ""Ship yard"", Tile.of(2981, 3052, 0), Tile.of(2676, 3170, 0)), // 15 CARIN_ISLAND_FARE(null, ""Ship yard"", Tile.of(2995, 3052, 0), Tile.of(2763, 2956, 1)), VOID_OUTPOST_FARE(null, ""Port Sarim"", Tile.of(2659, 2676, 0), Tile.of(3041, 3202, 0)), JATIZO(null, ""Relleka"", Tile.of(2422, 3781, 0), Tile.of(2643, 3710, 0)), NEITZNOT(null, ""Relleka"", Tile.of(2311, 3781, 0), Tile.of(2643, 3710, 0)), WATERBIRTH(null, ""Relleka"", Tile.of(2551, 3756, 0), Tile.of(2620, 3686, 0)), MISCELLENIA(null, ""Relleka"", Tile.of(2581, 3847, 0), Tile.of(2629, 3693, 0)), PIRATES_COVE(null, ""Relleka"", Tile.of(2213, 3794, 0), Tile.of(2620, 3686, 0)), LUNAR_ISLE(null, ""Pirate's Cove"", Tile.of(2138, 3900, 2), Tile.of(2223, 3797, 2)), TEACH_MOS_LE_HARMLESS(null, ""Relleka"", Tile.of(3682, 2948, 1), Tile.of(3714, 3499, 1)), LUMBRIDGE_CANOE(null, null, Tile.of(3233, 3249, 0), null), CHAMPIONS_GUILD_CANOE(null, null, Tile.of(3199, 3343, 0), null), BARBARIAN_VILLAGE_CANOE(null, null, Tile.of(3113, 3406, 0), null), EDGEVILLE_CANOE(null, null, Tile.of(3130, 3505, 0), null), WILDERNESS_CANOE(null, null, Tile.of(3147, 3799, 0), null); private final int[] fares; private final Tile destination; private final Tile origin; private final String secondDest; private Carrier(int[] fare, String secondDest, Tile destination, Tile origin) { fares = fare; this.destination = destination; this.secondDest = secondDest; this.origin = origin; } public Carrier getCarrier() { return this; } private Carrier(int[] fares, Tile destination) { this(fares, null, destination, null); } public int[] getFares() { return fares; } public Tile getDestination() { return destination; } public Tile getOrigon() { return origin; } public String getFixedName(boolean returning) { return (returning ? secondDest : toString().toLowerCase().replace(""_FARE"", """").replace(""_"", "" "")); } } private static int getComponentForMap(Carrier ship, boolean returning) { int iComp = -1; switch(ship) { case ENTRANA_FARE: if(ship.getFixedName(returning).equalsIgnoreCase(""entrana fare""))//sarim->entrana iComp = 54; else if(ship.getFixedName(returning).equalsIgnoreCase(""port sarim""))//entrana-> sarim iComp = 46; break; case KARAMJA_FARE://fare, meaning not charter if(ship.getFixedName(returning).equalsIgnoreCase(""port sarim""))//brimhaven->port sarim iComp = 42; else if(ship.getFixedName(returning).equalsIgnoreCase(""karamja fare""))//sarim->karamja iComp = 43; break; case BRIMHAVEN_FARE: if(ship.getFixedName(returning).equalsIgnoreCase(""ardougne""))//karamja/brim->ardougn iComp = 40; else if(ship.getFixedName(returning).equalsIgnoreCase(""brimhaven fare""))//ardy->brim fare iComp = 41; break; default: break; } return iComp; } /**Add map then sound, MAP -> 299, music-effect -> 171(short)/172(long) * p.getInterfaceManager().sendInterface(TRAVEL_INTERFACE); * p.getPackets().setIFHidden(299, icomp, false); * 40: brim->ardy(short) * 41: ardy->brim(short) * 42: Karamja->Sarim(short) * 43: sarim -> karamja/(short) * 46: entrana -> sarim(short) * 54: sarim -> entrana(short) * * //save for dragon slayer * * 45: crandor -> sarim(short) * * 44: sarim -> crandor(short) */ public static NPCClickHandler handleCharterShips = new NPCClickHandler(new Object[] { ""Trader Crewmember"", ""Trader crewmember"" }, e -> { if (e.getOpNum() == 3) ShopsHandler.openShop(e.getPlayer(), ""trader_stans_trading_post""); else if (e.getOpNum() == 4) TravelMethods.openCharterInterface(e.getPlayer()); }); public static void openCharterInterface(Player player) { player.getInterfaceManager().sendInterface(CHARTER_INTERFACE); int shipIndex = getOriginIndex(player.getRegionId()); if (shipIndex == -1) return; Carrier ship = Carrier.values()[shipIndex]; for (int index = 0; index < ship.fares.length; index++) if (ship.getFares()[index] == -1) player.getPackets().setIFHidden(CHARTER_INTERFACE, 23 + index, true); } public static ButtonClickHandler handleButtons = new ButtonClickHandler(95, e -> { if (e.getComponentId() >= 23 && e.getComponentId() <= 33) handleCharterOptions(e.getPlayer(), e.getComponentId()); }); public static void handleCharterOptions(Player player, int componentId) { int index = componentId - 23; if (index < 0 || index > 10) return; Carrier ship = Carrier.values()[index]; player.closeInterfaces(); int costIndex = getOriginIndex(player.getRegionId()); player.startConversation(new Dialogue() .addSimple(""Sailing to "" + ship.getFixedName(false) + "" will cost you "" + ship.getFares()[costIndex] + "" gold."") .addOptions(""Are you sure?"", ops -> { ops.add(""Okay"", () -> TravelMethods.sendCarrier(player, ship, costIndex, false)); ops.add(""Choose Again"", () -> TravelMethods.openCharterInterface(player)); ops.add(""No""); })); } private static int getOriginIndex(int regionId) { for (int index = 0; index < REGIONS.length; index++) if (REGIONS[index] == regionId) return index; return -1; } public static boolean sendCarrier(final Player player, final Carrier ship, boolean returning) { return sendCarrier(player, ship, 0, returning); } public static boolean sendCarrier(final Player player, final Carrier ship, int shipIndex, boolean returning) { if (player.getTempAttribs().getB(""using_carrier"")) return false; int cost = -1; if (ship.getFares() != null) cost = ship.getFares()[shipIndex]; if (cost != -1) { if (!player.getInventory().hasCoins(cost)) { player.sendMessage(""You don't have enough money for that.""); return false; } player.getInventory().removeCoins(cost); player.sendMessage(""You pay the fare and sail to "" + ship.getFixedName(returning) + "".""); } final boolean isFare = ship.toString().contains(""Fare""); if (isFare) { if (ship.ordinal() == 10 && !returning) { boolean hasEquip = false; for (Item item : player.getInventory().getItems().array()) { if (item == null) continue; if (Equipment.getItemSlot(item.getId()) != -1) { hasEquip = true; break; } } if (player.getEquipment().wearingArmour() || hasEquip) { player.sendMessage(""The monk refuses to let you board. Please bank all your equippable items.""); return false; } } player.getInterfaceManager().sendInterface(TRAVEL_INTERFACE); int configValue = 1 + (((ship.ordinal() - 10) * 2) + (ship.ordinal() >= 17 ? returning ? -1 : 0 : returning ? 1 : 0)); player.getVars().setVar(75, configValue); } final Tile tile = returning ? ship.getOrigon() : ship.getDestination(); player.lock(); player.getMusicsManager().playSongWithoutUnlocking(550); player.getTempAttribs().setB(""using_carrier"", true); if(getComponentForMap(ship, returning) == -1) FadingScreen.fade(player, () -> {// 9 player.tele(tile); player.lock(1); player.closeInterfaces(); if (isFare) player.getVars().setVar(75, 0); player.getTempAttribs().removeB(""using_carrier""); }); else { player.lock(); if(getComponentForMap(ship, returning) == 54 || getComponentForMap(ship, returning) == 46) WorldTasks.scheduleLooping(new Task() { int tick; @Override public void run() { if (tick == 0) //setup p1 player.getInterfaceManager().setFadingInterface(115); else if (tick == 3) { player.getInterfaceManager().setFadingInterface(516); player.getPackets().setBlockMinimapState(2); player.jingle(172); player.getInterfaceManager().sendInterface(TRAVEL_INTERFACE); player.getPackets().setIFHidden(299, getComponentForMap(ship, returning), false); } else if (tick == 11) { player.tele(tile); player.closeInterfaces(); player.getInterfaceManager().setFadingInterface(170); player.getPackets().setBlockMinimapState(0); } else if (tick == 12) { player.getTempAttribs().removeB(""using_carrier""); player.unlock(); stop(); } tick++; } }, 0, 1); else WorldTasks.scheduleLooping(new Task() { int tick; @Override public void run() { if (tick == 0) //setup p1 player.getInterfaceManager().setFadingInterface(115); else if (tick == 3) { player.getPackets().setBlockMinimapState(2); player.jingle(171); player.getInterfaceManager().sendInterface(TRAVEL_INTERFACE); player.getPackets().setIFHidden(299, getComponentForMap(ship, returning), false); } else if (tick == 7) { player.tele(tile); player.closeInterfaces(); player.getInterfaceManager().setFadingInterface(170); player.getPackets().setBlockMinimapState(0); } else if (tick == 8) { player.getTempAttribs().removeB(""using_carrier""); player.unlock(); stop(); } tick++; } }, 0, 1); } return true; } }" "package com.rs.game.content.transportation; public class WildernessObelisk { private static final Tile[] OBELISK_CENTER_TILES = { Tile.of(2978, 3864, 0), Tile.of(3033, 3730, 0), Tile.of(3104, 3792, 0), Tile.of(3154, 3618, 0), Tile.of(3217, 3654, 0), Tile.of(3305, 3914, 0) }; private static final boolean[] IS_ACTIVE = new boolean[6]; public static void activateObelisk(int id, final Player player) { final int index = id - 65616; final Tile center = OBELISK_CENTER_TILES[index]; player.soundEffect(204, true); if (IS_ACTIVE[index]) { player.sendMessage(""The obelisk is already active.""); return; } IS_ACTIVE[index] = true; GameObject object = World.getObjectWithId(center, id); if (object == null) // still loading objects i guess return; World.sendObjectAnimation(object, new Animation(2226)); World.sendObjectAnimation(World.getObjectWithId(center.transform(4, 0, 0), id), new Animation(2226)); World.sendObjectAnimation(World.getObjectWithId(center.transform(0, 4, 0), id), new Animation(2226)); World.sendObjectAnimation(World.getObjectWithId(center.transform(4, 4, 0), id), new Animation(2226)); WorldTasks.schedule(new Task() { @Override public void run() { for (int x = 1; x < 4; x++) for (int y = 1; y < 4; y++) World.sendSpotAnim(center.transform(x, y, 0), new SpotAnim(661)); Tile newCenter = OBELISK_CENTER_TILES[Utils.random(OBELISK_CENTER_TILES.length)]; for (Player p : World.getPlayersInChunkRange(center.getChunkId(), 1)) { if (p == null || p.isLocked() || p.isDead() || (p.getX() < center.getX() + 1 || p.getX() > center.getX() + 3 || p.getY() < center.getY() + 1 || p.getY() > center.getY() + 3)) continue; int offsetX = p.getX() - center.getX(); int offsetY = p.getY() - center.getY(); Magic.sendTeleportSpell(p, 8939, 8941, 1690, -1, 0, 0, Tile.of(newCenter.getX() + offsetX, newCenter.getY() + offsetY, 0), 3, false, TeleType.OBJECT, null); } IS_ACTIVE[index] = false; } }, 8); } }" "package com.rs.game.content.transportation.canoes enum class CanoeStationObjects(val objectId: Int, val varbitValue: Int) { TREE_STANDING(12144, 0), TREE_FALLING(12145, 9), TREE_FALLEN(12146, 10), TREE_SHAPED_LOG(12147, 1), TREE_SHAPED_DUGOUT(12148, 2), TREE_SHAPED_STABLE_DUGOUT(12149, 3), TREE_SHAPED_WAKA(12150, 4), CANOE_PUSHING_LOG(12151, 5), CANOE_PUSHING_DUGOUT(12152, 6), CANOE_PUSHING_STABLE_DUGOUT(12153, 7), CANOE_PUSHING_WAKA(12154, 8), CANOE_FLOATING_LOG(12155, 11), CANOE_FLOATING_DUGOUT(12156, 12), CANOE_FLOATING_STABLE_DUGOUT(12157, 13), CANOE_FLOATING_WAKA(12158, 14), CANOE_SINKING_LOG(12159, 0), CANOE_SINKING_DUGOUT(12160, 0), CANOE_SINKING_STABLE_DUGOUT(12161, 0), CANOE_SINKING_WAKA(12162, 0); } const val CANOE_STATION_VARBIT = ""canoeStationVarbit"" const val SELECTED_CANOE = ""selectedCanoe"" const val CANOE_SHAPING_INTERFACE = 52 const val CANOE_DESTINATION_INTERFACE = 53 const val CANOE_TRAVEL_INTERFACE = 758 val CANOE_SHAPING_SILHOUETTE = arrayOf(0, 9, 10, 8) val CANOE_SHAPING_TEXT = arrayOf(0, 3, 2, 5) val CANOE_SHAPING_BUTTONS = arrayOf(30, 31, 32, 33) val CANOE_DESTINATION_BUTTONS = arrayOf(47, 48, 3, 6, 49) val CANOE_DESTINATION_HIDE_ROW = arrayOf(10, 11, 12, 20, 18) val CANOE_DESTINATION_YOU_ARE_HERE = arrayOf(25, 24, 23, 19, 0) val CANOE_TREE_FALLING_ANIMATION = Animation(3304) val CANOE_PLAYER_PUSHING_ANIMATION = Animation(3301) val CANOE_PUSHING_ANIMATION = Animation(3304) val CANOE_SINKING_ANIMATION = Animation(3305) val CANOE_TRAVEL_INTERFACE_ANIMATIONS = arrayOf( arrayOf(0, 9890, 9889, 9888, 9887), arrayOf(9906, 0, 9893, 9892, 9891), arrayOf(9904, 9905, 0, 9895, 9894), arrayOf(9901, 9902, 9903, 0, 9896), arrayOf(9897, 9898, 9899, 9900, 0), ) enum class CanoeStations( val stationRegion: Int, val stationVarbit: Int, val playerChopLocation: Tile, val playerFacingLocation: Tile, val playerFloatLocation: Tile, val canoeSinkLocation: Tile, val playerDestination: Tile, val canoeSinkRotation: Int, val locationName: String ) { LUMBRIDGE( 12850, 1839, Tile(3232, 3254, 0), Tile(3233, 3254, 0), Tile(3233, 3252, 0), Tile(3235, 3253, 0), Tile(3232, 3252, 0), 1, ""Lumbridge"" ), CHAMPIONS( 12852, 1840, Tile(3204, 3343, 0), Tile(3204, 3342, 0), Tile(3202, 3343, 0), Tile(3200, 3340, 0), Tile(3202, 3343, 0), 0, ""the Champion's Guild"" ), BARBARIAN( 12341, 1841, Tile(3112, 3409, 0), Tile(3111, 3409, 0), Tile(3112, 3411, 0), Tile(3109, 3410, 0), Tile(3112, 3411, 0), 1, ""the Barbarian Village"" ), EDGEVILLE( 12342, 1842, Tile(3132, 3508, 0), Tile(3131, 3508, 0), Tile(3132, 3510, 0), Tile(3129, 3509, 0), Tile(3132, 3510, 0), 1, ""Edgeville"" ), WILDERNESS( 12603, 0, Tile(0, 0, 0), Tile(0, 0, 0), Tile(0, 0, 0), Tile(3143, 3795, 0), Tile(3139, 3796, 0), 2, ""the Wilderness Pond"" ); companion object { private val stationRegionMap = entries.associateBy { it.stationRegion } @JvmStatic fun getCanoeStationByTile(location: Tile): CanoeStations { return stationRegionMap[location.regionId]!! } } } enum class Canoes( val level: Int, val experience: Double, val maxDistance: Int, val rate1: Int, val rate99: Int, val treeShaped: CanoeStationObjects, val canoePushing: CanoeStationObjects, val canoeFloating: CanoeStationObjects, val canoeSinking: CanoeStationObjects ) { LOG(12, 30.0, 1, 60, 70, CanoeStationObjects.TREE_SHAPED_LOG, CanoeStationObjects.CANOE_PUSHING_LOG, CanoeStationObjects.CANOE_FLOATING_LOG, CanoeStationObjects.CANOE_SINKING_LOG ), DUGOUT(27, 60.0, 2, 35, 65, CanoeStationObjects.TREE_SHAPED_DUGOUT, CanoeStationObjects.CANOE_PUSHING_DUGOUT, CanoeStationObjects.CANOE_FLOATING_DUGOUT, CanoeStationObjects.CANOE_SINKING_DUGOUT ), STABLE_DUGOUT(42, 90.0, 3, 10, 55, CanoeStationObjects.TREE_SHAPED_STABLE_DUGOUT, CanoeStationObjects.CANOE_PUSHING_STABLE_DUGOUT, CanoeStationObjects.CANOE_FLOATING_STABLE_DUGOUT, CanoeStationObjects.CANOE_SINKING_STABLE_DUGOUT ), WAKA(57, 150.0, 4, 6, 35, CanoeStationObjects.TREE_SHAPED_WAKA, CanoeStationObjects.CANOE_PUSHING_WAKA, CanoeStationObjects.CANOE_FLOATING_WAKA, CanoeStationObjects.CANOE_SINKING_WAKA ); companion object { val indexMap = entries.associateBy { it.ordinal } } } @ServerStartupEvent fun handleCanoes() { onObjectClick(""Canoe station"") { (player, obj, option) -> when (option) { ""Chop-down"" -> handleChopDown(player, obj) ""Shape-canoe"" -> handleShapeCanoe(player, obj) ""Float Log"", ""Float Canoe"" -> handleFloatCanoe(player, obj) ""Paddle Log"", ""Paddle Canoe"" -> handlePaddleCanoe(player, obj) else -> return@onObjectClick } } onButtonClick(CANOE_SHAPING_INTERFACE) { e -> handleCanoeShapingButtonClick(e) } onButtonClick(CANOE_DESTINATION_INTERFACE) { e -> handleDestinationButtonClick(e) } } private fun handleChopDown(player: Player, obj: GameObject) { val canoeStation = CanoeStations.getCanoeStationByTile(obj.tile) val hatchet: Hatchet? = Hatchet.getBest(player) player.setRouteEvent(RouteEvent(canoeStation.playerChopLocation) { player.faceObject(obj) if (hatchet == null) { player.sendMessage(""You do not have a hatchet which you have the woodcutting level to use."") return@RouteEvent } if (player.skills.getLevel(Skills.WOODCUTTING) < 12) { player.sendMessage(""You need a woodcutting level of at least 12 to chop down this tree."") return@RouteEvent } player.lock() player.faceTile(canoeStation.playerFacingLocation) player.schedule { player.anim(hatchet.animNormal()) wait(3) player.anim(-1) player.vars.setVarBit(canoeStation.stationVarbit, CanoeStationObjects.TREE_FALLING.varbitValue) obj.animate(CANOE_TREE_FALLING_ANIMATION) wait(2) obj.refresh() player.vars.setVarBit(canoeStation.stationVarbit, CanoeStationObjects.TREE_FALLEN.varbitValue) player.unlock() } }) } private fun handleShapeCanoe(player: Player, obj: GameObject) { val canoeStation = CanoeStations.getCanoeStationByTile(obj.tile) player.setRouteEvent(RouteEvent(canoeStation.playerFloatLocation) { player.faceObject(obj) player.tempAttribs.setI(CANOE_STATION_VARBIT, canoeStation.stationVarbit) Canoes.entries.forEach { canoe -> if (player.skills.getLevel(Skills.WOODCUTTING) >= canoe.level && canoe != Canoes.LOG) { player.packets.setIFHidden(CANOE_SHAPING_INTERFACE, CANOE_SHAPING_SILHOUETTE[canoe.ordinal], true) player.packets.setIFHidden(CANOE_SHAPING_INTERFACE, CANOE_SHAPING_TEXT[canoe.ordinal], false) } } player.interfaceManager.sendInterface(CANOE_SHAPING_INTERFACE) }) } private fun handleFloatCanoe(player: Player, obj: GameObject) { val canoeStation = CanoeStations.getCanoeStationByTile(obj.tile) val canoe = Canoes.indexMap[player.tempAttribs.getI(SELECTED_CANOE)]!! player.setRouteEvent(RouteEvent(canoeStation.playerFloatLocation) { player.lock() player.faceObject(obj) player.anim(CANOE_PLAYER_PUSHING_ANIMATION.defs.id) player.soundEffect(2731, false) player.vars.setVarBit(canoeStation.stationVarbit, canoe.canoePushing.varbitValue) player.packets.sendObjectAnimation(obj, Animation(CANOE_PUSHING_ANIMATION.defs.id)) player.schedule { wait(CANOE_PLAYER_PUSHING_ANIMATION.defs.emoteGameTicks) player.anim(-1) player.vars.setVarBit(canoeStation.stationVarbit, canoe.canoeFloating.varbitValue) player.unlock() } }) } private fun handlePaddleCanoe(player: Player, obj: GameObject) { val canoeStation = CanoeStations.getCanoeStationByTile(obj.tile) val canoe = Canoes.indexMap[player.tempAttribs.getI(SELECTED_CANOE)]!! val origin = CanoeStations.getCanoeStationByTile(player.tile) for (i in CanoeStations.entries) { player.packets.setIFHidden(CANOE_DESTINATION_INTERFACE, CANOE_DESTINATION_HIDE_ROW[i.ordinal], true) if (i == CanoeStations.WILDERNESS) { if (canoe == Canoes.WAKA) { player.packets.setIFHidden(CANOE_DESTINATION_INTERFACE, 22, false) player.packets.setIFHidden(CANOE_DESTINATION_INTERFACE, CANOE_DESTINATION_HIDE_ROW[i.ordinal], false) } } else if (i.ordinal == origin.ordinal) { player.packets.setIFHidden(CANOE_DESTINATION_INTERFACE, CANOE_DESTINATION_YOU_ARE_HERE[i.ordinal], false) } else if (abs(i.ordinal - origin.ordinal) <= canoe.maxDistance) { player.packets.setIFHidden(CANOE_DESTINATION_INTERFACE, CANOE_DESTINATION_HIDE_ROW[i.ordinal], false) } } player.setRouteEvent(RouteEvent(canoeStation.playerFloatLocation) { player.interfaceManager.sendInterface(CANOE_DESTINATION_INTERFACE) }) } private fun handleCanoeShapingButtonClick(e: ButtonClickEvent) { val canoe = Canoes.indexMap[CANOE_SHAPING_BUTTONS.indexOf(e.componentId)]!! val stationVarbit = e.player.tempAttribs.getI(CANOE_STATION_VARBIT) val hatchet: Hatchet? = Hatchet.getBest(e.player) if (hatchet == null) { e.player.sendMessage(""You do not have a hatchet which you have the woodcutting level to use."") return } val level: Int = e.player.skills.getLevel(Constants.WOODCUTTING) + e.player.getInvisibleSkillBoost(Skills.WOODCUTTING) e.player.closeInterfaces() e.player.interfaceManager.removeOverlay(true) e.player.lock() e.player.tempAttribs.setI(SELECTED_CANOE, CANOE_SHAPING_BUTTONS.indexOf(e.componentId)) e.player.repeatAction(2) { e.player.anim(hatchet.animCanoe()) if (rollSuccess(e.player.auraManager.woodcuttingMul, level, hatchet, canoe)) { e.player.anim(-1) e.player.vars.setVarBit(stationVarbit, canoe.treeShaped.varbitValue) e.player.skills.addXp(Skills.WOODCUTTING, canoe.experience) e.player.unlock() return@repeatAction false } else { return@repeatAction true } } } private fun handleDestinationButtonClick(e: ButtonClickEvent) { val origin = CanoeStations.getCanoeStationByTile(e.player.tile) val destination = when (e.componentId) { CANOE_DESTINATION_BUTTONS[0] -> CanoeStations.LUMBRIDGE CANOE_DESTINATION_BUTTONS[1] -> CanoeStations.CHAMPIONS CANOE_DESTINATION_BUTTONS[2] -> CanoeStations.BARBARIAN CANOE_DESTINATION_BUTTONS[3] -> CanoeStations.EDGEVILLE CANOE_DESTINATION_BUTTONS[4] -> CanoeStations.WILDERNESS else -> CanoeStations.LUMBRIDGE } val interfaceAnimation = Animation(CANOE_TRAVEL_INTERFACE_ANIMATIONS[origin.ordinal][destination.ordinal]) if (e.player.hasFamiliar()) { e.player.sendMessage(""You can't take your follower on a canoe."") e.player.closeInterfaces() return } sendTravel(e.player, interfaceAnimation, origin, destination) } fun sendTravel(player: Player, interfaceAnimation: Animation, origin: CanoeStations, destination: CanoeStations) { player.interfaceManager.sendOverlay(115, true) val canoe = Canoes.indexMap[player.tempAttribs.getI(SELECTED_CANOE)]!! val sinkingCanoe = OwnedObject( player, canoe.canoeSinking.objectId, ObjectType.SCENERY_INTERACT, destination.canoeSinkRotation, destination.canoeSinkLocation ) player.interfaceManager.sendInterface(CANOE_TRAVEL_INTERFACE) player.packets.setIFAnimation(interfaceAnimation.defs.id, CANOE_TRAVEL_INTERFACE, 3) player.lock() player.schedule { player.packets.setBlockMinimapState(2) player.interfaceManager.removeSubs(*ALL_GAME_TABS) wait(interfaceAnimation.defs.emoteGameTicks + 1) player.tele(destination.playerDestination) player.interfaceManager.sendOverlay(170, true) player.closeInterfaces() player.packets.setBlockMinimapState(0) player.interfaceManager.sendSubDefaults(*ALL_GAME_TABS) wait(1) World.spawnObjectTemporary(OwnedObject(player, sinkingCanoe), CANOE_SINKING_ANIMATION.defs.emoteGameTicks + 1) player.packets.sendObjectAnimation(sinkingCanoe, CANOE_SINKING_ANIMATION) player.sendMessage(""You arrive at ${destination.locationName}."") player.sendMessage(""Your canoe sinks into the water after the hard journey."") if (destination == CanoeStations.WILDERNESS) { player.sendMessage(""There are no trees nearby to make a new canoe. Guess you're walking."") } player.unlock() player.vars.setVarBit(origin.stationVarbit, CanoeStationObjects.TREE_STANDING.varbitValue) } } fun rollSuccess(mul: Double, level: Int, hatchet: Hatchet, canoe: Canoes): Boolean { return Utils.skillSuccess((level * mul).toInt(), hatchet.toolMod, canoe.rate1, canoe.rate99) }" "package com.rs.game.content.transportation.canoes const val BARFY_BILL = 3331 const val TARQUIN = 3328 const val SIGURD = 3329 const val HARI = 3330 class CanoeD(player: Player, npc: NPC) : Conversation(player) { init { when (npc.id) { BARFY_BILL -> { player.startConversation(Dialogue() .addNPC(BARFY_BILL, HeadE.CHEERFUL, ""Oh! Hello there."") .addOptions(""What would you like to say?"") { initialOps -> initialOptions(initialOps, npc) }) } TARQUIN -> { player.startConversation(Dialogue() .addNPC(TARQUIN, HeadE.CHEERFUL, ""Hello old bean."") .addOptions(""What would you like to say?"") { initialOps -> initialOptions(initialOps, npc) }) } SIGURD -> { player.startConversation(Dialogue() .addNPC(SIGURD, HeadE.CHEERFUL, ""Ha Ha! Hello!"") .addOptions(""What would you like to say?"") { initialOps -> initialOptions(initialOps, npc) }) } HARI -> { player.startConversation(Dialogue() .addNPC(HARI, HeadE.CHEERFUL, ""Hello."") .addOptions(""What would you like to say?"") { initialOps -> initialOptions(initialOps, npc) }) } } create() } private fun initialOptions(initialOps: Options, npc: NPC) { initialOps.add(""Who are you?"") { when (npc.id) { BARFY_BILL -> { player.startConversation(Dialogue() .addPlayer(HeadE.CALM, ""Who are you?"") .addNext { barfyBillWhoAreYou(player) }) } TARQUIN -> { player.startConversation(Dialogue() .addPlayer(HeadE.CALM, ""Who are you?"") .addNext { tarquinWhoAreYou(player) }) } SIGURD -> { player.startConversation(Dialogue() .addPlayer(HeadE.CALM, ""Who are you?"") .addNext { sigurdWhoAreYou(player) }) } HARI -> { player.startConversation(Dialogue() .addPlayer(HeadE.CALM, ""Who are you?"") .addNext { hariWhoAreYou(player) }) } } } initialOps.add(""Can you teach me about canoeing?"") { when (npc.id) { BARFY_BILL -> { player.startConversation(Dialogue() .addPlayer(HeadE.CHEERFUL, ""Can you teach me about canoeing?"") .addNext { barfyBillTeachCanoeing(player) }) } TARQUIN -> { player.startConversation(Dialogue() .addPlayer(HeadE.CHEERFUL, ""Can you teach me about canoeing?"") .addNext { tarquinTeachCanoeing(player) }) } SIGURD -> { player.startConversation(Dialogue() .addPlayer(HeadE.CHEERFUL, ""Can you teach me about canoeing?"") .addNext { sigurdTeachCanoeing(player) }) } HARI -> { player.startConversation(Dialogue() .addPlayer(HeadE.CHEERFUL, ""Can you teach me about canoeing?"") .addNext { hariTeachCanoeing(player) }) } } } } private fun barfyBillWhoAreYou(player: Player) { player.startConversation(Dialogue() .addNPC(BARFY_BILL, HeadE.CHEERFUL, ""My name is Ex Sea Captain Barfy Bill."") .addPlayer(HeadE.CHEERFUL, ""Ex sea captain?"") .addNPC(BARFY_BILL, HeadE.CHEERFUL, ""Yeah, I bought a lovely ship and was planning to make a fortune running her as a merchant vessel."") .addPlayer(HeadE.CHEERFUL, ""Why are you not still sailing?"") .addNPC(BARFY_BILL, HeadE.CHEERFUL, ""Chronic sea sickness. My first and only voyage was spent dry heaving over the rails. If I had known about the sea sickness I could have saved myself a lot of money."") .addPlayer(HeadE.CHEERFUL, ""What are you up to now then?"") .addNPC(BARFY_BILL, HeadE.CHEERFUL, ""Well my ship had a little fire related problem. Fortunately it was well insured. Anyway, I don't have to work anymore so I've taken to canoeing on the river. I don't get river sick! Would you like to know how to make a canoe?"") .addOptions(""What would you like to say?"") { barfyBillOptions -> barfyBillOptions(barfyBillOptions, player) }) } private fun barfyBillOptions(options: Options, player: Player) { options.add(""Yes, please."") { barfyBillTeachCanoeing(player) } options.add(""No, thank you."") { player.startConversation( Dialogue().addPlayer(HeadE.CONFUSED, ""No, thank you."")) } } private fun barfyBillTeachCanoeing(player: Player) { val wcLevel = player.skills.getLevel(Skills.WOODCUTTING) val dialogue = Dialogue() .addNPC(BARFY_BILL, HeadE.HAPPY_TALKING, ""It's really quite simple. Just walk down to that tree on the bank and chop it down. When you have done that you can shape the log further with your hatchet to make a canoe."") when { wcLevel >= 57 -> { dialogue.addNPC(BARFY_BILL, HeadE.HAPPY_TALKING, ""Hoo! You look like you know which end of a hatchet is which. You can easily build one of those Wakas. Be careful if you travel into the Wilderness though. I've heard tell of great evil in that blasted wasteland."") .addPlayer(HeadE.HAPPY_TALKING, ""Thanks for the warning Bill."") } wcLevel in 42..57 -> { dialogue.addNPC(BARFY_BILL, HeadE.HAPPY_TALKING, ""The best canoe you can make is a Stable Dugout, one step beyond a normal Dugout. With a Stable Dugout you can travel to any place on the river."") .addPlayer(HeadE.CONFUSED, ""Even into the Wilderness?"") .addNPC(BARFY_BILL, HeadE.LAUGH, ""Not likely! I've heard tell of a man up near Edgeville who claims he can use a Waka to get up into the Wilderness. I can't think why anyone would wish to venture into that hellish landscape though."") } wcLevel in 27..42 -> { dialogue.addNPC(BARFY_BILL, HeadE.HAPPY_TALKING, ""With your skill in woodcutting you could make my favourite canoe, the Dugout. They might not be the best canoe on the river, but they get you where you're going."") .addPlayer(HeadE.CONFUSED, ""How far will I be able to go in a Dugout canoe?"") .addNPC(BARFY_BILL, HeadE.CALM, ""You will be able to travel 2 stops on the river."") } wcLevel in 12..27 -> { dialogue.addNPC(BARFY_BILL, HeadE.LAUGH, ""Hah! I can tell just by looking that you lack talent in woodcutting."") .addPlayer(HeadE.CONFUSED, ""What do you mean?"") .addNPC(BARFY_BILL, HeadE.LAUGH, ""No Callouses! No Splinters! No camp fires littering the trail behind you. Anyway, the only 'canoe' you can make is a log. You'll be able to travel 1 stop along the river with a log canoe."") } else -> { dialogue.addNPC(BARFY_BILL, HeadE.SAD, ""Well, you don't look like you have the skill to make a canoe. You need to have at least level 12 woodcutting. Once you are able to make a canoe it makes travel along the river much quicker!"") } } player.startConversation(dialogue) } private fun tarquinWhoAreYou(player: Player) { player.startConversation(Dialogue() .addNPC(TARQUIN, HeadE.CHEERFUL, ""My name is Tarquin Marjoribanks. I'd be surprised if you haven't already heard of me?"") .addPlayer(HeadE.CHEERFUL, ""Why would I have heard of you Mr. Marjoribanks?"") .addNPC(TARQUIN, HeadE.CHEERFUL, ""It's pronounced 'Marchbanks'! You should know of me because I am a member of the royal family of Misthalin!"") .addPlayer(HeadE.CHEERFUL, ""Are you related to King Roald?"") .addNPC(TARQUIN, HeadE.CHEERFUL, ""Oh yes! Quite closely actually. I'm his 4th cousin, once removed on his mothers side."") .addPlayer(HeadE.CHEERFUL, ""Er... Okay. What are you doing here then?"") .addNPC(TARQUIN, HeadE.CHEERFUL, ""I'm canoeing on the river! It's enormous fun! Would you like to know how?"") .addOptions(""What would you like to say?"") { tarquinOptions -> tarquinOptions(tarquinOptions, player) }) } private fun tarquinOptions(options: Options, player: Player) { options.add(""Yes, please."") { tarquinTeachCanoeing(player) } options.add(""No, thank you."") { player.startConversation( Dialogue().addPlayer(HeadE.CONFUSED, ""No, thank you."")) } } private fun tarquinTeachCanoeing(player: Player) { val wcLevel = player.skills.getLevel(Skills.WOODCUTTING) val dialogue = Dialogue() .addNPC(TARQUIN, HeadE.HAPPY_TALKING, ""It's really quite simple. Just walk down to that tree on the bank and chop it down. When you have done that you can shape the log further with your hatchet to make a canoe. My personal favourite is the Stable Dugout canoe. A finer craft you'll never see old bean!"") .addNPC(TARQUIN, HeadE.HAPPY_TALKING, ""A Stable Dugout canoe will take you pretty much the length of the Lum river. Of course there are other canoes."") when { wcLevel >= 57 -> { dialogue.addNPC(TARQUIN, HeadE.HAPPY_TALKING, ""Well ... erm. You seem to be able to make a Waka!"") .addPlayer(HeadE.CONFUSED, ""Sounds fun, what's a Waka?"") .addNPC(TARQUIN, HeadE.HAPPY_TALKING, ""I've only ever seen one man on the river who uses a Waka. A big, fearsome looking fellow up near Edgeville. People say he was born in the Wilderness and that he is looking for a route back."") .addPlayer(HeadE.AMAZED, ""Is that true?!"") .addNPC(TARQUIN, HeadE.CALM, ""How should I know? I would not consort with such a base fellow!"") } wcLevel in 42..57 -> { dialogue.addNPC(TARQUIN, HeadE.HAPPY_TALKING, ""Ah! Perfect! You can make a Stable Dugout canoe! One of those will carry you to any civilised place on the river. If you were of good pedigree I'd let you join my boat club. You seem to be one of those vagabond adventurers though."") .addPlayer(HeadE.AMAZED_MILD, ""Charming!"") .addNPC(TARQUIN, HeadE.LAUGH, ""Be off with you rogue!"") } wcLevel in 27..42 -> { dialogue.addNPC(TARQUIN, HeadE.HAPPY_TALKING, ""You seem to be quite handy with a hatchet though! I'm sure you can build a Dugout canoe. Not as fine as a Stable Dugout but it will carry you 2 stops on the river. I should imagine it would suit your limited means."") .addPlayer(HeadE.CONFUSED, ""What do you mean when you say 'limited means'?"") .addNPC(TARQUIN, HeadE.CALM, ""Well, you're just an itinerant adventurer! What possible reason would you have for cluttering up my river with your inferior water craft!"") } wcLevel in 12..27 -> { dialogue.addNPC(TARQUIN, HeadE.LAUGH, ""Further up river, near the Barbarian Village, I saw some darned fool 'canoeing' on a log! Unfortunately, you don't have the skill to create anything more than one of those logs. I dare say it will only get 1 stop down the river. Still, I'm sure it will satisfy one such as yourself."") .addPlayer(HeadE.AMAZED_MILD, ""What's that supposed to mean?!"") .addNPC(TARQUIN, HeadE.ANGRY, ""Do not profane the royal house of Varrock by engaging me in further discourse you knave!"") .addPlayer(HeadE.LAUGH, ""Pfft! I doubt he even knows the King!"") } else -> { dialogue.addNPC(TARQUIN, HeadE.SAD, ""Well, you don't look like you have the skill to make a canoe. You need to have at least level 12 woodcutting. Once you are able to make a canoe it makes travel along the river much quicker!"") } } player.startConversation(dialogue) } private fun sigurdWhoAreYou(player: Player) { player.startConversation(Dialogue() .addNPC(SIGURD, HeadE.CHEERFUL, ""I'm Sigurd the Great and Brainy."") .addPlayer(HeadE.CHEERFUL, ""Why do they call you the Great and Brainy?"") .addNPC(SIGURD, HeadE.CHEERFUL, ""Because I invented the Log Canoe!"") .addPlayer(HeadE.CHEERFUL, ""Log Canoe?"") .addNPC(SIGURD, HeadE.CHEERFUL, ""Yeash! Me and my cousins were having a great party by the river when we decided to have a game of 'Smack The Tree'."") .addPlayer(HeadE.CHEERFUL, ""Smack the Tree?"") .addNPC(SIGURD, HeadE.CHEERFUL, ""It's a game where you take it in turnsh shmacking a tree. First one to uproot the tree winsh! Anyway, I won the game with a flying tackle. The tree came loose and down the river bank I went, still holding the tree."") .addNPC(SIGURD, HeadE.CHEERFUL, ""I woke up a few hours later and found myself several miles down river. And thatsh how I invented the log canoe!"") .addPlayer(HeadE.CHEERFUL, ""So you invented the 'Log Canoe' by falling into a river hugging a tree?"") .addNPC(SIGURD, HeadE.CHEERFUL, ""Well I refined the design from the original you know! I cut all the branches off to make it more comfortable. I could tell you how to if you like?"") .addOptions(""What would you like to say?"") { sigurdOptions -> sigurdOptions(sigurdOptions, player) }) } private fun sigurdOptions(options: Options, player: Player) { options.add(""Yes, please."") { sigurdTeachCanoeing(player) } options.add(""No, thank you."") { player.startConversation( Dialogue().addPlayer(HeadE.CONFUSED, ""No, thank you."")) } } private fun sigurdTeachCanoeing(player: Player) { val wcLevel = player.skills.getLevel(Skills.WOODCUTTING) val dialogue = Dialogue() .addNPC(SIGURD, HeadE.HAPPY_TALKING, ""It's really quite simple. Just walk down to that tree on the bank and chop it down. Then take your hatchet to it and shape it how you like!"") when { wcLevel >= 57 -> { dialogue.addNPC(SIGURD, HeadE.HAPPY_TALKING, ""You look like you know your way around a tree, you can make a Waka canoe."") .addPlayer(HeadE.CONFUSED, ""What's a Waka?"") .addNPC(SIGURD, HeadE.CALM, ""I've only ever seen Hari using them. People say he's found a way to canoe the river underground and into the Wilderness. Hari hangs around up near Edgeville. He's a nice bloke."") } wcLevel in 42..57 -> { dialogue.addNPC(SIGURD, HeadE.HAPPY_TALKING, ""Well, you're pretty handy with an axe! You could make Stable Dugout canoes, like that snooty fella Tarquin. He reckons his canoes are better than mine. He's never said it to my face though."") } wcLevel in 27..42 -> { dialogue.addNPC(SIGURD, HeadE.HAPPY_TALKING, ""You could make a Dugout canoe with your woodcutting skill, but I don't see why you would want to."") } wcLevel in 12..27 -> { dialogue.addNPC(SIGURD, HeadE.HAPPY_TALKING, ""You can make a log canoe like mine! It'll get you 1 stop down the river. There's some snooty fella down near the Champions Guild who reckons his canoes are better than mine. He's never said it to my face though."") } else -> { dialogue.addNPC(SIGURD, HeadE.SAD, ""Well, you don't look like you have the skill to make a canoe. You need to have at least level 12 woodcutting. Once you are able to make a canoe it makes travel along the river much quicker!"") } } player.startConversation(dialogue) } private fun hariWhoAreYou(player: Player) { player.startConversation(Dialogue() .addNPC(HARI, HeadE.CHEERFUL, ""My name is Hari."") .addPlayer(HeadE.CHEERFUL, ""And what are you doing here Hari?"") .addNPC(HARI, HeadE.CHEERFUL, ""Like most people who come here to Edgeville, I am here to seek adventure in the Wilderness. I found a secret underground river that will take me quite a long way north."") .addPlayer(HeadE.CHEERFUL, ""Underground river? Where does it come out?"") .addNPC(HARI, HeadE.CHEERFUL, ""It comes out in a pond located deep in the Wilderness."") .addNPC(HARI, HeadE.CHEERFUL, ""I had to find a very special type of canoe to get me up the river though, would you like to know more?"") .addOptions(""What would you like to say?"") { hariOptions -> hariOptions(hariOptions, player) }) } private fun hariOptions(options: Options, player: Player) { options.add(""Yes, please."") { hariTeachCanoeing(player) } options.add(""No, thank you."") { player.startConversation( Dialogue().addPlayer(HeadE.CONFUSED, ""No, thank you."")) } } private fun hariTeachCanoeing(player: Player) { val wcLevel = player.skills.getLevel(Skills.WOODCUTTING) val dialogue = Dialogue() .addNPC(HARI, HeadE.HAPPY_TALKING, ""It's really quite simple to make. Just walk down to that tree on the bank and chop it down. When you have done that you can shape the log further with your hatchet to make a canoe."") when { wcLevel >= 57 -> { dialogue.addNPC(HARI, HeadE.HAPPY_TALKING, ""Your skills rival mine friend. You will certainly be able to build a Waka."") .addPlayer(HeadE.CONFUSED, ""A Waka? What's that?"") .addNPC(HARI, HeadE.HAPPY_TALKING, ""A Waka is an invention of my people, it's an incredible strong and fast canoe and will carry you safely to any destination on the river."") .addPlayer(HeadE.AMAZED, ""Any destination?"") .addNPC(HARI, HeadE.CALM, ""Yes, you can take a waka north through the underground portion of this river. It will bring you out at a pond in the heart of the Wilderness. Be careful up there, many have lost more than their lives in that dark and twisted place."") } wcLevel in 42..57 -> { dialogue.addNPC(HARI, HeadE.HAPPY_TALKING, ""You seem to be an accomplished woodcutter. You will easily be able to make a Stable Dugout. They are reliable enough to get you anywhere on this river, except to the Wilderness of course. Only a Waka can take you there."") .addPlayer(HeadE.AMAZED_MILD, ""A Waka? What's that?"") .addNPC(HARI, HeadE.LAUGH, ""Come and ask me when you have improved your skills as a woodcutter."") } wcLevel in 27..42 -> { dialogue.addNPC(HARI, HeadE.HAPPY_TALKING, ""You are an average woodcutter. You should be able to make a Dugout canoe quite easily. It will take you 2 stops along the river."") .addPlayer(HeadE.CONFUSED, ""Can I take a dugout canoe to reach the Wilderness?"") .addNPC(HARI, HeadE.LAUGH, ""You would never make it there alive."") .addPlayer(HeadE.WORRIED, ""Best not to try then."") } wcLevel in 12..27 -> { dialogue.addNPC(HARI, HeadE.LAUGH, ""I can sense you're still a novice woodcutter, you will only be able to make a log canoe at present."") .addPlayer(HeadE.CONFUSED, ""Is that good?"") .addNPC(HARI, HeadE.CALM, ""A log will take you one stop along the river. But you won't be able to travel into the Wilderness on it."") } else -> { dialogue.addNPC(HARI, HeadE.SAD, ""Well, you don't look like you have the skill to make a canoe. You need to have at least level 12 woodcutting. Once you are able to make a canoe it makes travel along the river much quicker!"") } } player.startConversation(dialogue) } }" "package com.rs.game.content.tutorialisland; public class BrotherBrace extends Conversation { public BrotherBrace(Player player, NPC npc, TutorialIslandController ctrl) { super(player); npc.faceEntity(player); npc.resetWalkSteps(); createStage(""Intro"", new PlayerStatement(HeadE.NO_EXPRESSION, ""Good day, brother."")) .addNext(new NPCStatement(npc.getId(), HeadE.NO_EXPRESSION, ""Hello, I'm Brother Brace."", ""I'm here to tell you all about Prayer."")) .addNext(new Dialogue().setFunc(() -> ctrl.nextStage(Stage.OPEN_PRAYER_TAB))); createStage(""Prayer"", new NPCStatement(npc.getId(), HeadE.NO_EXPRESSION, ""This is your Prayer list. Prayers can help a lot in"", ""combat. Click on the prayer you wish to use to activate"", ""it, and click it again to deactivate it."")) .addNext(new NPCStatement(npc.getId(), HeadE.NO_EXPRESSION, ""Active prayers will drain your Prayer Points, which"", ""you can recharge by finding an altar or other holy spot"", ""and praying there."")) .addNext(new NPCStatement(npc.getId(), HeadE.NO_EXPRESSION, ""As you noticed, most enemies will drop bones when"", ""defeated. Burying bones, by clicking them in your"", ""inventory, will gain you Prayer experience."")) .addNext(new NPCStatement(npc.getId(), HeadE.NO_EXPRESSION, ""I'm also the community officer 'round here, so it's my"", ""job to tell you about your friends and ignore list."")) .addNext(new Dialogue().setFunc(() -> ctrl.nextStage(Stage.OPEN_FRIENDS_TAB))); createStage(""Friends"", new NPCStatement(npc.getId(), HeadE.NO_EXPRESSION, ""Good. Now you have both menus open I'll tell you a"", ""little about each. You can add people to either list by"", ""clicking the add button then typing their name into the"", ""box that appears."")) .addNext(new NPCStatement(npc.getId(), HeadE.NO_EXPRESSION, ""You remove people from the lists in the same way. If"", ""you add someone to your ignore list they will not be"", ""able to talk to you or send any form of message to"", ""you."")) .addNext(new NPCStatement(npc.getId(), HeadE.NO_EXPRESSION, ""Your friends list shows the online status of your"", ""friends. Friends in red are offline, friends in green are"", ""online and on the same server and friends in yellow"", ""are online, but on a different server."")) .addNext(new PlayerStatement(HeadE.NO_EXPRESSION, ""Are there rules on in-game behaviour?"")) .addNext(new NPCStatement(npc.getId(), HeadE.NO_EXPRESSION, ""Yes, you should read the rules of conduct on the"", ""website to make sure you do nothing to get yourself"", ""banned."")) .addNext(new NPCStatement(npc.getId(), HeadE.NO_EXPRESSION, ""But in general, always try to be courteous to other"", ""players - remember the people in game are real"", ""people with real feelings."")) .addNext(new NPCStatement(npc.getId(), HeadE.NO_EXPRESSION, ""If you go 'round being abusive or causing trouble your"", ""character could end up being the one in trouble."")) .addNext(new PlayerStatement(HeadE.NO_EXPRESSION, ""Okay, thanks, I'll bear that in mind."")) .addNext(new Dialogue().setFunc(() -> ctrl.nextStage(Stage.LEAVE_CHURCH_AREA))); if (ctrl.inSection(Stage.TALK_TO_BROTHER_BRACE, Stage.TALK_TO_BROTHER_BRACE_2)) create(""Intro""); else if (ctrl.inSection(Stage.TALK_TO_BROTHER_BRACE_2, Stage.TALK_TO_BROTHER_BRACE_3)) create(""Prayer""); else if (ctrl.inSection(Stage.TALK_TO_BROTHER_BRACE_3, Stage.LEAVE_CHURCH_AREA)) create(""Friends""); else { addNext(""Recap"", new OptionStatement(""What would you like to hear again?"", ""Explain Prayer to me again."", ""Explain Friends and Ignores to me again."", ""Nothing, I'm ready to move on."")); getStage(""Recap"").addNext(getStage(""Prayer"")); getStage(""Recap"").addNext(getStage(""Friends"")); create(); } } }" "package com.rs.game.content.tutorialisland; public class CombatInstructor extends Conversation { public CombatInstructor(Player player, NPC npc, TutorialIslandController ctrl) { super(player); if (ctrl.inSection(Stage.TALK_TO_COMBAT_INSTRUCTOR, Stage.TALK_TO_COMBAT_INSTRUCTOR_2)) { addNext(new PlayerStatement(HeadE.CHEERFUL, ""Hi! My name's "" + player.getDisplayName() + ""."")); addNext(new NPCStatement(npc.getId(), HeadE.FRUSTRATED, ""Do I look like I care? To me you're just another"", ""newcomer who thinks they're ready to fight."")); addNext(new NPCStatement(npc.getId(), HeadE.NO_EXPRESSION, ""I am Vannaka, the greatest swordsman alive, and I'm"", ""here to teach you the basics of combat. Let's get started"", ""by teaching you to wield a weapon."")); addNext(new Dialogue().setFunc(() -> ctrl.nextStage(Stage.OPEN_EQUIPMENT_TAB))); } else if (ctrl.inSection(Stage.TALK_TO_COMBAT_INSTRUCTOR_2, Stage.TALK_TO_COMBAT_INSTRUCTOR_3)) addNext(new NPCStatement(npc.getId(), HeadE.NO_EXPRESSION, ""Very good, but that little butter knife isn't going to"", ""protect you much. Here, take these."")); else if (ctrl.inSection(Stage.TALK_TO_COMBAT_INSTRUCTOR_3, Stage.LEAVE_COMBAT_AREA)) { addNext(new PlayerStatement(HeadE.CHEERFUL, ""I did it! I killed a giant rat!"")); addNext(new NPCStatement(npc.getId(), HeadE.NO_EXPRESSION, ""I saw. You seem better at this than I thought. Now"", ""that you have grasped basic swordplay, let's move on."")); addNext(new NPCStatement(npc.getId(), HeadE.NO_EXPRESSION,""Let's try some ranged attacking, with this you can kill"", ""foes from a distance. Also, foes unable to reach you are"", ""as good as dead. You'll be able to attack the rats"", ""without entering the pit."")); } else addNext(new NPCStatement(npc.getId(), HeadE.NO_EXPRESSION, ""What now?"")); if (!player.containsOneItem(1277, 1171) && ctrl.pastStage(Stage.TALK_TO_COMBAT_INSTRUCTOR_2)) addNext(new Dialogue(new LegacyItemStatement(1277, 1171, """", ""The Combat Guide gives you a bronze sword and a wooden shield!""), () -> { player.getInventory().addItem(1171, 1); player.getInventory().addItem(1277, 1); ctrl.nextStage(Stage.EQUIP_SWORD_AND_SHIELD); })); if (player.getInventory().missingItems(841, 882) && ctrl.pastStage(Stage.TALK_TO_COMBAT_INSTRUCTOR_3)) addNext(new Dialogue(new LegacyItemStatement(841, 897, """", ""The Combat Guide gives you a shortbow and some arrows!""), () -> { player.getInventory().addItem(841, 1); player.getInventory().addItem(882, 50); ctrl.nextStage(Stage.KILL_RAT_RANGE); })); if (ctrl.getStage().ordinal() >= Stage.LEAVE_COMBAT_AREA.ordinal()) { addNext(""Recap"", new OptionStatement(""What would you like to hear more about?"", ""Tell me about combat stats."", ""Tell me about melee combat again."", ""Tell me about ranged combat again."", ""Tell me about the Wilderness."", ""Nope, I'm ready to move on!"")); getStage(""Recap"").addNext(new PlayerStatement(HeadE.NO_EXPRESSION, ""Tell me about combat stats again."")) .addNext(new Dialogue(new NPCStatement(npc.getId(), HeadE.NO_EXPRESSION, ""Certainly. You have three main combat stats: Strength"", ""Defence and Attack.""), () -> player.getInterfaceManager().openTab(Sub.TAB_SKILLS))) .addNext(new NPCStatement(npc.getId(), HeadE.NO_EXPRESSION, ""Strength determines the maximum hit you will be able"", ""to deal with your blows, Defence determines the amount"", ""of damage you will be able to defend and Attack"", ""determines the accuracy of your blows."")) .addNext(new NPCStatement(npc.getId(), HeadE.NO_EXPRESSION, ""Other stats are used in combat such as Prayer,"", ""Hitpoints, Magic and Ranged. All of these stats can go"", ""towards determining your combat level, which is shown"", ""near the top of your combat interface screen."")) .addNext(new NPCStatement(npc.getId(), HeadE.NO_EXPRESSION, ""You will find out on the mainland that certain items can"", ""also affect your stats. There are potions that can be"", ""drunk that can alter your stats temporarily, such as"", ""raising Strength."")) .addNext(new NPCStatement(npc.getId(), HeadE.NO_EXPRESSION, ""You will also raise your Defence and Attack values by"", ""using different weapons and armours."")) .addNext(new NPCStatement(npc.getId(), HeadE.NO_EXPRESSION, ""Before going into combat with an opponent it is wise to"", ""put the mouse over them and see what combat level"", ""they are."")) .addNext(new NPCStatement(npc.getId(), HeadE.NO_EXPRESSION, ""Green coloured writing usually means it will be an easy"", ""fight for you, red means you will probably lose, yellow"", ""means they are around your level and orange means"", ""they are slightly stronger."")) .addNext(new NPCStatement(npc.getId(), HeadE.NO_EXPRESSION, ""Sometimes things will go your way, sometimes they"", ""won't. There is no such thing as a guaranteed win, but"", ""if the odds are on your side, you stand the best chance"", ""of walking way victorious."")) .addNext(new NPCStatement(npc.getId(), HeadE.NO_EXPRESSION, ""Now, was there something else you wanted to hear"", ""about again?"")) .addNext(getStage(""Recap"")); getStage(""Recap"").addNext(new PlayerStatement(HeadE.NO_EXPRESSION, ""Tell me about melee combat again."")) .addNext(new NPCStatement(npc.getId(), HeadE.NO_EXPRESSION, ""Ah, my speciality. Close combat fighting, which is also"", ""known as melee fighting, covers all combat done at close"", ""range to your opponent."")) .addNext(new NPCStatement(npc.getId(), HeadE.NO_EXPRESSION, ""Melee fighting depends entirely upon your three basic"", ""combat stats: Attack, Defence, and Strength."")) .addNext(new NPCStatement(npc.getId(), HeadE.NO_EXPRESSION, ""Also, of course, it depends on the quality of your"", ""armour and weaponry. A high-levelled fighter with good"", ""armour and weapons will be deadly up close."")) .addNext(new NPCStatement(npc.getId(), HeadE.NO_EXPRESSION, ""If this is the path you wish to take, remember your"", ""success depends on getting as close to your enemy as"", ""quickly as possible."")) .addNext(new NPCStatement(npc.getId(), HeadE.NO_EXPRESSION, ""Personally, I consider the fine art of melee combat to"", ""be the ONLY combat method worth using."")) .addNext(new NPCStatement(npc.getId(), HeadE.NO_EXPRESSION, ""Now, did you want to hear anything else?"")) .addNext(getStage(""Recap"")); getStage(""Recap"").addNext(new PlayerStatement(HeadE.NO_EXPRESSION, ""Tell me about ranged combat again."")) .addNext(new NPCStatement(npc.getId(), HeadE.NO_EXPRESSION, ""Thinking of being a ranger, eh? Well, okay. I don't"", ""enjoy it myself, but I can see the appeal."")) .addNext(new NPCStatement(npc.getId(), HeadE.NO_EXPRESSION, ""Ranging employs a lot of different weapons as a skill,"", ""not just the shortbow you have there. Spears, throwing"", ""knives, and crossbows are all used best at a distance"", ""from your enemy."")) .addNext(new NPCStatement(npc.getId(), HeadE.NO_EXPRESSION, ""Now, those rats were easy pickings, but on the"", ""mainland you will be very lucky if you can find a spot"", ""where you can shoot at your enemies without them"", ""being able to retaliate."")) .addNext(new NPCStatement(npc.getId(), HeadE.NO_EXPRESSION, ""At close range, rangers often do badly in combat. Your"", ""best tactic as a ranger is to hit and run, keeping your"", ""foe at a distance."")) .addNext(new NPCStatement(npc.getId(), HeadE.NO_EXPRESSION, ""Your effectiveness as a ranger is almost entirely"", ""dependent on your Ranged stat. As with all skills, the"", ""more you train it, the more powerful it will become."")) .addNext(new NPCStatement(npc.getId(), HeadE.NO_EXPRESSION, ""Anything else you need to know?"")) .addNext(getStage(""Recap"")); getStage(""Recap"").addNext(new PlayerStatement(HeadE.NO_EXPRESSION, ""Tell me about the Wilderness again."")) .addNext(new NPCStatement(npc.getId(), HeadE.NO_EXPRESSION, ""Ah yes, the Wilderness. It is a place of evil, mark my"", ""words. Many is the colleague I have lost in that foul"", ""place."")) .addNext(new NPCStatement(npc.getId(), HeadE.NO_EXPRESSION, ""It is also a place of both adventure and wealth, so if"", ""you are brave enough and strong enough to survive it,"", ""you will make a killing, Literally!"")) .addNext(new NPCStatement(npc.getId(), HeadE.NO_EXPRESSION, ""It is also the only place in the land of "" + Settings.getConfig().getServerName(), ""where players are able to attack each other at will, and"", ""as such is the haunt of many Player Killers, or PKers"", ""if you will."")) .addNext(new NPCStatement(npc.getId(), HeadE.NO_EXPRESSION, ""There are a few things different in the Wilderness in"", ""comparison to the rest of the lands of "" + Settings.getConfig().getServerName() + ""."", ""Firstly, as I just mentioned, you can and will be"", ""attacked by other players."")) .addNext(new NPCStatement(npc.getId(), HeadE.NO_EXPRESSION, ""For this reason, you will be given a warning when you"", ""approach the Wilderness, as it is not a place you would"", ""wish to enter by accident."")) .addNext(new NPCStatement(npc.getId(), HeadE.NO_EXPRESSION, ""Secondly, there are a number of 'levels' to it. The"", ""further into it you travel, the greater the range of"", ""people you can attack."")) .addNext(new NPCStatement(npc.getId(), HeadE.NO_EXPRESSION, ""In level 1 wilderness you will only be able to attack, or"", ""be attacked by, those players within one combat level of"", ""yourself."")) .addNext(new NPCStatement(npc.getId(), HeadE.NO_EXPRESSION, ""In level 50, any player within fifty levels of you will be"", ""able to attack, or be attacked by you. Always keep an"", ""eye on what level of the Wilderness you are currently"", ""in."")) .addNext(new NPCStatement(npc.getId(), HeadE.NO_EXPRESSION, ""Your current Wildnerness level is shown at the bottom"", ""right of the screen. The final thing you should know"", ""about the Wilderness is being 'skulled'."")) .addNext(new NPCStatement(npc.getId(), HeadE.NO_EXPRESSION, ""If you attack another player without them having"", ""attacked first, you will gain a skull above your"", ""character's head."")) .addNext(new NPCStatement(npc.getId(), HeadE.NO_EXPRESSION, ""What this means is that if you die while skulled, you will"", ""lose EVERYTHING that your character was carrying."")) .addNext(new NPCStatement(npc.getId(), HeadE.NO_EXPRESSION, ""When skulled, you should try to avoid dying for the"", ""twenty minutes or so it will take for the skull to wear"", ""off."")) .addNext(new NPCStatement(npc.getId(), HeadE.NO_EXPRESSION, ""If you wish to find the Wilderness, head north from"", ""where you start on the mainland. It is rather large and"", ""hard to miss."")) .addNext(new NPCStatement(npc.getId(), HeadE.NO_EXPRESSION, ""If you don't wish to end up there, take notice of the"", ""warning you will receive when getting near to it."")) .addNext(new NPCStatement(npc.getId(), HeadE.NO_EXPRESSION, ""Now, was there anything more?"")) .addNext(getStage(""Recap"")); } create(); } }" "package com.rs.game.content.tutorialisland; public class FinancialAdvisor extends Conversation { public FinancialAdvisor(Player player, NPC npc, TutorialIslandController ctrl) { super(player); if (ctrl.getStage() == Stage.TALK_TO_FINANCIAL_ADVISOR) { addNext(new PlayerStatement(HeadE.NO_EXPRESSION, ""Hello, Who are you?"")); addNext(new NPCStatement(npc.getId(), HeadE.CHEERFUL, ""I'm the Financial Advisor. I'm here to tell people how to"", ""make money."")); addNext(new PlayerStatement(HeadE.SKEPTICAL, ""Okay. How can I make money then?"")); addNext(new NPCStatement(npc.getId(), HeadE.CHEERFUL, ""How you can make money? Quite."")); } else { addNext(new OptionStatement(""Would you like to hear about making money again?"", ""Yes!"", ""No thanks."")); addNext(new NPCStatement(npc.getId(), HeadE.CHEERFUL, ""Okay, making money. Quite."")); } addNext(new NPCStatement(npc.getId(), HeadE.CHEERFUL, ""Well, there are three basic ways of making money here:"", ""combat, quests and trading. I will talk you through each"", ""of them very quickly."")); addNext(new NPCStatement(npc.getId(), HeadE.CHEERFUL, ""Let's start with combat as it is probably still fresh in"", ""your mind. Many enemies, both human and monster,"", ""will drop items when they die."")); addNext(new NPCStatement(npc.getId(), HeadE.CHEERFUL, ""Now, the next way to earn money quickly is by quests."", ""Many people on ""+ Settings.getConfig().getServerName()+"" have things they need"", ""doing, which they will reward you for."")); addNext(new NPCStatement(npc.getId(), HeadE.CHEERFUL, ""By getting a high level in skills such as Cooking, Mining,"", ""Smithing or Fishing, you can create or catch your own"", ""items and sell them for pure profit."")); addNext(new NPCStatement(npc.getId(), HeadE.CHEERFUL, ""Well, that about covers it. Come back if you'd like to go"", ""over this again."")); addNext(new Dialogue().setFunc(() -> ctrl.nextStage(Stage.LEAVE_FINANCIAL_ADVISOR_ROOM))); create(); } }" "package com.rs.game.content.tutorialisland; public class GamemodeSelection extends Conversation { public GamemodeSelection(Player player) { super(player); addNext(""start"", new SimpleStatement(""Welcome to Darkan. We will start by setting up your gamemode options."")); addOptions(""Would you like this account to be an ironman?"", ops -> { ops.add(""Yes (No trading, picking up items that aren't yours, etc.)"", new Dialogue().addOptions(""Is an ironman account alright with you?"", confirm -> { confirm.add(""Yes"", () -> { player.setIronMan(true); player.setChosenAccountType(true); player.getAppearance().generateAppearanceData(); }); confirm.add(""No, let me choose again."", new Dialogue().addGotoStage(""start"", this)); })); ops.add(""No"", new Dialogue().addOptions(""Is a normal account alright with you?"", confirm -> { confirm.add(""Yes"", () -> { player.setIronMan(false); player.setChosenAccountType(true); player.getAppearance().generateAppearanceData(); }); confirm.add(""No, let me choose again."", new Dialogue().addGotoStage(""start"", this)); })); }); create(); } }" "package com.rs.game.content.tutorialisland; public class MagicInstructor extends Conversation { public MagicInstructor(Player player, NPC npc, TutorialIslandController ctrl) { super(player); if (ctrl.inSection(Stage.TALK_TO_MAGIC_INSTRUCTOR, Stage.TALK_TO_MAGIC_INSTRUCTOR_2)) { addNext(new PlayerStatement(HeadE.NO_EXPRESSION, ""Hello."")); addNext(new NPCStatement(npc.getId(), HeadE.CHEERFUL, ""Good day, newcomer. My name is Terrova. I'm here"", ""to tell you about Magic. Let's start by opening your"", ""spell list."")); addNext(new Dialogue().setFunc(() -> ctrl.nextStage(Stage.OPEN_MAGIC_TAB))); } else if (ctrl.inSection(Stage.TALK_TO_MAGIC_INSTRUCTOR_2, Stage.TALK_TO_MAGIC_INSTRUCTOR_3)) { addNext(new NPCStatement(npc.getId(), HeadE.CHEERFUL, ""Currently you can only cast one offensive spell called"", ""Wind Strike. Let's try it out on one of those chickens."")); if (player.getInventory().missingItems(558, 556)) addNext(new Dialogue(new LegacyItemStatement(558, 556, """", ""Terrova gives you some air runes and mind runes.""), () -> { player.getInventory().addItem(558, 5); player.getInventory().addItem(556, 5); ctrl.nextStage(Stage.CAST_WIND_STRIKE); })); } else if (ctrl.pastStage(Stage.TALK_TO_MAGIC_INSTRUCTOR_3)) { addNext(new NPCStatement(npc.getId(), HeadE.CHEERFUL, ""Well, you're all finished here now. I'll give you a"", ""reasonable number of runes when you leave."")); addNext(new OptionStatement(""Do you want to go to the mainland?"", ""Yes"", ""No"")); addNext(new NPCStatement(npc.getId(), HeadE.CHEERFUL, ""When you get to the mainland you will find yourself in"", ""the town of Lumbridge. If you want some ideas on"", ""where to go next, talk to my friend the Lumbridge"", ""Guide. You can't miss him; he's holding a big staff with"")); addNext(new NPCStatement(npc.getId(), HeadE.CHEERFUL, ""a question mark on the end. He also has a white beard"", ""and carries a rucksack full of scrolls. There are also"", ""many tutors willing to teach you about the many skills"", ""you could learn."")); addNext(new ItemStatement(5079, 1100, """", ""When you get to Lumbridge, look for this icon on your"", ""mini-map. The Lumbridge Guide or one of the other"", ""tutors should be standing near there. The Lumbridge"", ""Guide should be standing slightly to the north-east of"")); addNext(new ItemStatement(5079, 1100, """", ""the castle's courtyard and the others you will find"", ""scattered around Lumbridge."")); addNext(new NPCStatement(npc.getId(), HeadE.CHEERFUL, ""If all else fails, visit the ""+Settings.getConfig().getServerName()+"" website for a whole"", ""chestload of information on quests, skills and minigames"", ""as well as a very good starter's guide."")); addNext(new Dialogue(new SimpleStatement(""Welcome to Lumbridge! To get more help, simply click on the"", ""Lumbridge Guide or one of the Tutors - these can be found by"", ""looking for the question mark icon on your mini map. If you find"", ""you are lost at any time, look for a signpost or use the Lumbridge"", ""Home Port spell.""), () -> { World.sendWorldMessage(""""+player.getDisplayName()+"" has just joined ""+Settings.getConfig().getServerName()+""!"", false); player.tele(Tile.of(Settings.getConfig().getPlayerStartTile())); player.getControllerManager().forceStop(); player.getInterfaceManager().sendSubDefaults(Sub.ALL_GAME_TABS); player.giveStarter(); player.getInterfaceManager().sendAchievementComplete(Achievement.THE_JOURNEY_BEGINS_3521); })); } create(); } }" "package com.rs.game.content.tutorialisland; public class MasterChef extends Conversation { public MasterChef(Player player, NPC npc, TutorialIslandController ctrl) { super(player); npc.faceEntity(player); npc.resetWalkSteps(); if (ctrl.getStage() == Stage.TALK_TO_CHEF) { addNext(new NPCStatement(npc.getId(), HeadE.CHEERFUL, ""Ah! Welcome, newcomer. I am the Master Chef, Lev. It"", ""is here I will teach you how to cook food truly fit for a"", ""king."")); addNext(new PlayerStatement(HeadE.SKEPTICAL_THINKING, ""I already know how to cook. Brynna taught me just"", ""now."")); addNext(new NPCStatement(npc.getId(), HeadE.LAUGH, ""Hahahahahaha! You call THAT cooking? Some shrimp"", ""on an open log fire? Oh, no, no, no. I am going to"", ""teach you the fine art of cooking bread."")); addNext(new NPCStatement(npc.getId(), HeadE.CHEERFUL, ""And no fine meal is complete without good music, so"", ""we'll cover that while you're here too."")); } else addNext(new NPCStatement(npc.getId(), HeadE.CHEERFUL, ""Hello again."")); if (player.getInventory().missingItems(1929, 1933)) addNext(new Dialogue(new LegacyItemStatement(1929, 1933, """", ""The Cooking Guide gives you a bucket of water and a,"", ""pot of flour!""), () -> { player.getInventory().addItem(1929, 1); player.getInventory().addItem(1933, 1); ctrl.nextStage(Stage.MAKE_DOUGH); })); if (ctrl.pastStage(Stage.MAKE_DOUGH)) { addNext(""Recap"", new OptionStatement(""What would you like to hear more about?"", ""Making dough."", ""Range cooking."", ""Music."", ""Nothing, thanks."")); getStage(""Recap"") .addNext(new PlayerStatement(HeadE.NO_EXPRESSION, ""Tell me more about making dough again."")) .addNext(new NPCStatement(npc.getId(), HeadE.NO_EXPRESSION, ""It's quite simple: just use a pot of flour on a bucket of"", ""water, or vice versa, and you'll make dough. You can"", ""also refill your bucket at the sink."")) .addNext(getStage(""Recap"")); getStage(""Recap"") .addNext(new PlayerStatement(HeadE.NO_EXPRESSION, ""Tell me about range cooking again."")) .addNext(new NPCStatement(npc.getId(), HeadE.NO_EXPRESSION, ""The range is the only place you can cook a lot of the"", ""more complex foods in "" + Settings.getConfig().getServerName() + "". To cook on a"", ""range, right click the item you would like to cook, select"", ""'use', then left click the range."")) .addNext(getStage(""Recap"")); getStage(""Recap"") .addNext(new PlayerStatement(HeadE.NO_EXPRESSION, ""Tell me about music again."")) .addNext(new NPCStatement(npc.getId(), HeadE.NO_EXPRESSION, ""Ah, yes. The music was created by the great bards Ian"", ""and Adam. As you travel the world of "" + Settings.getConfig().getServerName() + "" you"", ""will unlock more of the tunes in your jukebox. Simply"", ""click on a tune in the music menu to listen to it."")) .addNext(getStage(""Recap"")); } create(); } }" "package com.rs.game.content.tutorialisland; public class MiningInstructor extends Conversation { public MiningInstructor(Player player, NPC npc, TutorialIslandController ctrl) { super(player); npc.faceEntity(player); npc.resetWalkSteps(); if (ctrl.inSection(Stage.TALK_TO_MINING_GUIDE, Stage.TALK_TO_MINING_GUIDE_2)) { addNext(new NPCStatement(npc.getId(), HeadE.CHEERFUL, ""Hi there. You must be new around here. So what do I"", ""call you? 'Newcomer' seems so impersonal, and if we're"", ""going to be working together, I'd rather call you by"", ""name."")); addNext(new PlayerStatement(HeadE.CHEERFUL, ""You can call me "" + player.getDisplayName() + ""."")); addNext(new NPCStatement(npc.getId(), HeadE.CHEERFUL, ""Ok then, ""+player.getDisplayName()+"". My name is Dezzick and I'm a miner"", ""by trade. Let's prospect some of those rocks."")); addNext(new Dialogue().setFunc(() -> ctrl.nextStage(Stage.PROSPECTING_TIN))); } else if (ctrl.inSection(Stage.TALK_TO_MINING_GUIDE_2, Stage.TALK_TO_MINING_GUIDE_3)) { addNext(new PlayerStatement(HeadE.CHEERFUL_EXPOSITION, ""I prospected both types of rock! One set contains tin"", ""and the other has copper ore inside."")); addNext(new NPCStatement(npc.getId(), HeadE.CHEERFUL, ""Absolutely right. These two ore types can be smelted"", ""together to make bronze."")); addNext(new NPCStatement(npc.getId(), HeadE.CHEERFUL, ""So now you know what ore is in the rocks over there,"", ""why don't you have a go at mining some tin and"", ""copper? Here, you'll need this to start with."")); } else if (ctrl.inSection(Stage.TALK_TO_MINING_GUIDE_3, Stage.LEAVE_MINING_AREA)) { addNext(new PlayerStatement(HeadE.CONFUSED, ""How do I make a weapon out of this?"")); addNext(new NPCStatement(npc.getId(), HeadE.CHEERFUL, ""Okay, I'll show you how to make a dagger out of it."", ""You'll be needing this..."")); } else addNext(new NPCStatement(npc.getId(), HeadE.NO_EXPRESSION, ""Hello again."")); if (player.getInventory().missingItems(1265) && ctrl.pastStage(Stage.TALK_TO_MINING_GUIDE_2)) addNext(new Dialogue(new ItemStatement(1265, ""Dezzick gives you a bronze pickaxe!""), () -> { player.getInventory().addItem(1265, 1); ctrl.nextStage(Stage.MINING_TIN); })); if (player.getInventory().missingItems(2347) && ctrl.pastStage(Stage.TALK_TO_MINING_GUIDE_3)) addNext(new Dialogue(new ItemStatement(2347, ""Dezzick gives you a hammer!""), () -> { player.getInventory().addItem(2347, 1); ctrl.nextStage(Stage.CLICK_ANVIL); })); if (ctrl.pastStage(Stage.LEAVE_MINING_AREA)) { addNext(""Recap"", new OptionStatement(""What would you like to hear more about?"", ""Tell me about prospecting again."", ""Tell me about Mining again."", ""Tell me about smelting again."", ""Tell me about Smithing again."", ""Nope, I'm ready to move on!"")); getStage(""Recap"").addNext(new PlayerStatement(HeadE.NO_EXPRESSION, ""Tell me about prospecting again."")) .addNext(new NPCStatement(npc.getId(), HeadE.CHEERFUL, ""It's really very simple. Usually when you go mining"", ""you can see if there is ore in a rock or not by its"", ""colour."")) .addNext(new NPCStatement(npc.getId(), HeadE.CHEERFUL, ""If you come across a rock you've not seen before and"", ""want to know what it is, or if you can't tell if a rock"", ""contains ore just by sight,"")) .addNext(new NPCStatement(npc.getId(), HeadE.CHEERFUL, ""then simply right click on the rock and select 'prospect'"", ""to check closely. Anything else you wanted to know?"")) .addNext(getStage(""Recap"")); getStage(""Recap"").addNext(new PlayerStatement(HeadE.NO_EXPRESSION, ""Tell me about mining again."")) .addNext(new NPCStatement(npc.getId(), HeadE.CHEERFUL, ""Certainly. To mine you need a pickaxe. Different"", ""pickaxes let you mine more efficiently."")) .addNext(new NPCStatement(npc.getId(), HeadE.CHEERFUL, ""You have a bronze pickaxe there, which is the most"", ""inefficient pickaxe available, but is perfect for a"", ""beginner."")) .addNext(new NPCStatement(npc.getId(), HeadE.CHEERFUL, ""To mine, simply click on a rock that contains ore while"", ""you have a pickaxe with you, and you will keep mining"", ""the rock until you manage to get some ore, or until it"", ""is empty."")) .addNext(new NPCStatement(npc.getId(), HeadE.CHEERFUL, ""The better the pickaxe you use, the faster you will get"", ""ore from the rock you're mining."")) .addNext(new NPCStatement(npc.getId(), HeadE.CHEERFUL, ""You will be able to buy better pickaxes from the"", ""Dwarven Mine when you reach the mainland, but they"", ""can be expensive."")) .addNext(new NPCStatement(npc.getId(), HeadE.CHEERFUL, ""Also, the better the pickaxe the higher the Mining level"", ""required to use it will be. Was there anything else you"", ""wanted to hear?"")) .addNext(getStage(""Recap"")); getStage(""Recap"").addNext(new PlayerStatement(HeadE.NO_EXPRESSION, ""Tell me about smelting again."")) .addNext(new NPCStatement(npc.getId(), HeadE.CHEERFUL, ""Smelting is very easy. Simply take the ores required to"", ""make a metal to a furnace, then use the ores on the"", ""furnace to smelt them into a bar of metal."")) .addNext(new NPCStatement(npc.getId(), HeadE.CHEERFUL, ""Furnaces are expensive to build and maintain, so there"", ""are not that many scattered around the world. I"", ""suggest when you find one you remember its location"", ""for future use."")) .addNext(new NPCStatement(npc.getId(), HeadE.CHEERFUL, ""An alternative to using a furnace to smelt your ore is"", ""to use high-level magic to do it."")) .addNext(new NPCStatement(npc.getId(), HeadE.CHEERFUL, ""As well as letting you smelt ore anywhere, it has a"", ""guaranteed success rate in smelting all ores."")) .addNext(new NPCStatement(npc.getId(), HeadE.CHEERFUL, ""Some metals, such as iron, contain impurities and can"", ""be destroyed during the smelting process in a traditional"", ""furnace, but magical heat does not destroy them."")) .addNext(new NPCStatement(npc.getId(), HeadE.CHEERFUL, ""Anything else?"")) .addNext(getStage(""Recap"")); getStage(""Recap"").addNext(new PlayerStatement(HeadE.NO_EXPRESSION, ""Tell me about Smithing again."")) .addNext(new NPCStatement(npc.getId(), HeadE.CHEERFUL, ""When you have acquired enough bars of the metal you"", ""wish to work with, you are ready to begin smithing."")) .addNext(new NPCStatement(npc.getId(), HeadE.CHEERFUL, ""Take the hammer I have given you, or buy a new one"", ""from a general store, and proceed to a nearby anvil."")) .addNext(new NPCStatement(npc.getId(), HeadE.CHEERFUL, ""By using a metal bar on an anvil you will be presented"", ""with a screen showing the objects you are able to smith"", ""at your current level."")) .addNext(new NPCStatement(npc.getId(), HeadE.CHEERFUL, ""It's a pretty straightforward skill as I'm sure you"", ""discovered while making me that lovely bronze dagger."")) .addNext(new NPCStatement(npc.getId(), HeadE.CHEERFUL, ""The higher Smithing level you are, the better quality the"", ""metal you can work with. You start off on bronze and"", ""work your way up as your smithing skills increase."")) .addNext(new NPCStatement(npc.getId(), HeadE.CHEERFUL, ""Anything else?"")) .addNext(getStage(""Recap"")); } create(); } }" "package com.rs.game.content.tutorialisland; public class QuestGuide extends Conversation { public QuestGuide(Player player, NPC npc, TutorialIslandController ctrl) { super(player); npc.faceEntity(player); npc.resetWalkSteps(); if (ctrl.getStage().ordinal() >= Stage.TALK_TO_QUEST_GUIDE.ordinal() && ctrl.getStage().ordinal() < Stage.TALK_TO_QUEST_GUIDE_2.ordinal()) addNext(new Dialogue(new NPCStatement(npc.getId(), HeadE.NO_EXPRESSION, ""Ah. Welcome, adventurer. I'm here to tell you all about"", ""quests. Let's start by opening the quest side panel.""), () -> ctrl.nextStage(Stage.OPEN_QUEST_TAB))); else { addNext(new NPCStatement(npc.getId(), HeadE.NO_EXPRESSION, ""Now you have the journal open I'll tell you a bit about"", ""it. At the moment all the quests are shown in red, which"", ""means you have not started them yet."")); addNext(new NPCStatement(npc.getId(), HeadE.NO_EXPRESSION, ""When you start a quest it will change colour to yellow,"", ""and to green when you've finished. This is so you can"", ""easily see what's complete, what's started, and what's left"", ""to begin."")); addNext(new NPCStatement(npc.getId(), HeadE.NO_EXPRESSION, ""The start of quests are easy to find. Look out for the"", ""star icons on the minimap, just like the one you should"", ""see marking my house."")); addNext(new NPCStatement(npc.getId(), HeadE.NO_EXPRESSION, ""The quests themselves can vary greatly from collecting"", ""beads to hunting down dragons. Generally quests are"", ""started by talking to a non-player character like me,"", ""and will involve a series of tasks."")); addNext(new NPCStatement(npc.getId(), HeadE.NO_EXPRESSION, ""There's a lot more I can tell you about questing."", ""You have to experience the thrill of it yourself to fully"", ""understand. You may find some adventure in the caves"", ""under my house."")); addNext(new Dialogue().setFunc(() -> ctrl.nextStage(Stage.LEAVE_QUEST_GUIDE_HOUSE))); } create(); } }" "package com.rs.game.content.tutorialisland; @PluginEventHandler public class RuneScapeGuide extends Conversation { public RuneScapeGuide(Player player, NPC npc, TutorialIslandController ctrl) { super(player); npc.faceEntity(player); npc.resetWalkSteps(); create(""Intro"", new Dialogue(new NPCStatement(npc.getId(), HeadE.CHEERFUL, ""Greetings! I see you are a new arrival to this land. My"", ""job is to welcome all new visitors. So welcome!""))) .addNext(new NPCStatement(npc.getId(), HeadE.CHEERFUL, ""You have already learned the first thing needed to"", ""succeed in this world: talking to other people!"")) .addNext(new NPCStatement(npc.getId(), HeadE.CHEERFUL, ""You will find many inhabitants of this world have useful"", ""things to say to you. By clicking on them with your"", ""mouse you can talk to them."")) .addNext(new NPCStatement(npc.getId(), HeadE.CHEERFUL, ""I would also suggest reading through some of the"", ""supporting information on the website. There you can"", ""find the Knowledge Base, which contains all the"", ""additional information you're ever likely to need. It also"")) .addNext(new NPCStatement(npc.getId(), HeadE.CHEERFUL, ""contains maps and helpful tips to help you on your"", ""journey."")) .addNext(new NPCStatement(npc.getId(), HeadE.CHEERFUL, ""You will notice a flashing icon of a spanner; please click"", ""on this to continue the tutorial."")) .addNext(new Dialogue().setFunc(() -> ctrl.nextStage(Stage.OPEN_SETTINGS))); create(""Outro"", new Dialogue(new NPCStatement(npc.getId(), HeadE.CHEERFUL, ""I'm glad you're making progress!""))) .addNext(new NPCStatement(npc.getId(), HeadE.CHEERFUL, ""To continue the tutorial go through that door over"", ""there and speak to your first instructor!"")) .addNext(new Dialogue().setFunc(() -> ctrl.nextStage(Stage.LEAVE_GUIDE_ROOM))); create(""Recap"", new Dialogue(new NPCStatement(npc.getId(), HeadE.CHEERFUL, ""Welcome back.""))) .addNext(new NPCStatement(npc.getId(), HeadE.CHEERFUL, ""You have already learned the first thing needed to"", ""succeed in this world: talking to other people!"")) .addNext(new NPCStatement(npc.getId(), HeadE.CHEERFUL, ""You will find many inhabitants of this world have useful"", ""things to say to you. By clicking on them with your"", ""mouse you can talk to them."")) .addNext(new NPCStatement(npc.getId(), HeadE.CHEERFUL, ""To continue the tutorial go through that door over"", ""there and speak to your first instructor!"")); if (ctrl.inSection(Stage.TALK_TO_GUIDE, Stage.TALK_TO_GUIDE_2)) create(""Intro""); else if (ctrl.inSection(Stage.TALK_TO_GUIDE_2, Stage.LEAVE_GUIDE_ROOM)) create(""Outro""); else create(""Recap""); } public static NPCInstanceHandler toFunc = new NPCInstanceHandler(new Object[] { 945 }, (npcId, tile) -> { NPC n = new NPC(npcId, tile); n.setPermName(Settings.getConfig().getServerName()+"" Guide""); return n; }); }" "package com.rs.game.content.tutorialisland; public class Skippy extends Conversation { public Skippy(Player player, NPC npc, TutorialIslandController ctrl) { super(player); npc.faceEntity(player); npc.resetWalkSteps(); addNext(new NPCStatement(npc.getId(), HeadE.DRUNK, ""Hey. Do you wanna skip the Tutorial?"", ""I can send you straight to Burthorpe, easy."")); addNext(new OptionStatement(""Do you want to go to the mainland?"", ""Yes, send me to Burthorpe now."", ""No, I'd like to enjoy the nostalgic Tutorial Trent worked so hard on."")); addNext(new NPCStatement(npc.getId(), HeadE.DRUNK, ""Right on. I'll read you the official messages first, then"", ""send you on your way. Ahem..."")); addNext(new NPCStatement(npc.getId(), HeadE.CHEERFUL, ""When you get to the mainland you will find yourself in"", ""the town of Burthorpe. If you want some ideas on"", ""where to go next, talk to my old drinking buddy Major"", ""Nigel Corothers You can't miss him; he's in grey armour"")); addNext(new NPCStatement(npc.getId(), HeadE.CHEERFUL, ""with a sword icon above him and always in a "", ""standard confidence pose. There are also many beginner friendly locations"", ""and shops in Burthorpe for you to skill and learn from"")); addNext(new ItemStatement(2402, 1100, """", ""When you get to Burthorpe, look for a sword icon on your"", ""mini-map. Major Nigel Corothers should be standing slightly off center where you start in Burthorpe, near a bank chest."", ""All the other beginner locations you will find scattered around Burthorpe"")); addNext(new NPCStatement(npc.getId(), HeadE.CHEERFUL, ""If all else fails, visit the "" + Settings.getConfig().getServerName() + "" Discord for a whole"", ""chestload of information on quests, skills and minigames"", ""as well as a very good community."")); addNext(new Dialogue(new SimpleStatement(""Welcome to Burthorpe!"", ""To further learn about Gielinor, simply talk to Major Nigel Corothers."", ""He can be found by looking for the sword icon on your mini map. If you find"", ""you are lost at any time, use the home teleport spell to go to common destinations.""), () -> { World.sendWorldMessage("""" + player.getDisplayName() + "" has just joined ""+Settings.getConfig().getServerName()+""!"", false); player.tele(Tile.of(Settings.getConfig().getPlayerStartTile())); player.getControllerManager().forceStop(); player.getInterfaceManager().flashTabOff(); player.getInterfaceManager().sendSubDefaults(Sub.ALL_GAME_TABS); player.giveStarter(); player.getInterfaceManager().sendAchievementComplete(Achievement.THE_JOURNEY_BEGINS_3521); })); create(); } }" "package com.rs.game.content.tutorialisland; public class SurvivalExpert extends Conversation { public SurvivalExpert(Player player, NPC npc, TutorialIslandController ctrl) { super(player); npc.faceEntity(player); npc.resetWalkSteps(); if (ctrl.inSection(Stage.TALK_TO_SURVIVAL_EXPERT, Stage.TALK_TO_SURVIVAL_EXPERT_2)) addNext(new NPCStatement(npc.getId(), HeadE.NO_EXPRESSION, ""Hello there, newcomer. My name is Brynna. My job is"", ""to teach you a few survival tips and tricks. First off"", ""we're going to start with the most basic survival skill of"", ""all: making a fire."")); else if (ctrl.inSection(Stage.TALK_TO_SURVIVAL_EXPERT_2, Stage.LEAVE_SURVIVAL_EXPERT)) addNext(new NPCStatement(npc.getId(), HeadE.NO_EXPRESSION, ""Well done! Next we need to get some food in our"", ""bellies. We'll need something to cook. There are shrimp"", ""in the pond there. So let's catch and cook some."")); else addNext(new NPCStatement(npc.getId(), HeadE.NO_EXPRESSION, ""Hello again."")); if (player.getInventory().missingItems(590, 1351) && ctrl.pastStage(Stage.TALK_TO_SURVIVAL_EXPERT)) addNext(new Dialogue(new LegacyItemStatement(590, 1351, """", ""The Survival Guide gives you a tinderbox and a bronze"", ""axe!""), () -> { player.getInventory().addItem(1351, 1); player.getInventory().addItem(590, 1); ctrl.nextStage(Stage.OPEN_INVENTORY); })); if (player.getInventory().missingItems(303) && ctrl.pastStage(Stage.TALK_TO_SURVIVAL_EXPERT_2)) addNext(new Dialogue(new ItemStatement(303, ""The Survival Guide gives you a net!""), () -> { player.getInventory().addItem(303, 1); ctrl.nextStage(Stage.CATCH_SHRIMP); })); if (ctrl.pastStage(Stage.LEAVE_SURVIVAL_EXPERT)) { addNext(""Recap"", new OptionStatement(""What would you like to hear more about?"", ""Woodcutting."", ""Firemaking."", ""Fishing."", ""Cooking."", ""My stats."")); getStage(""Recap"").addNext(new PlayerStatement(HeadE.NO_EXPRESSION, ""Tell me about Woodcutting again."")) .addNext(new NPCStatement(npc.getId(), HeadE.CHEERFUL, ""Woodcutting, eh? Don't worry, newcomer, it's really"", ""very easy. Simply equip your axe and click on a"", ""nearby tree to chop away."")) .addNext(new NPCStatement(npc.getId(), HeadE.CHEERFUL, ""As you explore the mainland you will discover many"", ""different kinds of trees that will require different levels"", ""of Woodcutting ability to chop down."")) .addNext(new NPCStatement(npc.getId(), HeadE.CHEERFUL, ""Logs are not only useful for making fires. Many"", ""archers use the skill known as Fletching to craft their"", ""own bows and arrows from trees."")) .addNext(getStage(""Recap"")); getStage(""Recap"").addNext(new PlayerStatement(HeadE.NO_EXPRESSION, ""Tell me about Firemaking again."")) .addNext(new NPCStatement(npc.getId(), HeadE.CHEERFUL, ""Certainly, newcomer. When you have logs simply use"", ""your tinderbox on them. If successful, you will start a"", ""fire."")) .addNext(new NPCStatement(npc.getId(), HeadE.CHEERFUL, ""You can also set fire to logs you find lying on the floor"", ""already, and some other things can also be set alight..."")) .addNext(new NPCStatement(npc.getId(), HeadE.CHEERFUL, ""A tinderbox is always a useful item to keep around!"", ""Was there anything else you wished to hear again?"")) .addNext(getStage(""Recap"")); getStage(""Recap"").addNext(new PlayerStatement(HeadE.NO_EXPRESSION, ""Tell me about Fishing again."")) .addNext(new NPCStatement(npc.getId(), HeadE.CHEERFUL, ""Ah, yes. Fishing!"", ""Fishing is undoubtedly one of the"", ""more popular hobbies here in ""+Settings.getConfig().getServerName()+""!"")) .addNext(new NPCStatement(npc.getId(), HeadE.CHEERFUL, ""Whenever you see sparkling waters, you can be sure"", ""there's probably some good fishing to be had there!"")) .addNext(new NPCStatement(npc.getId(), HeadE.CHEERFUL, ""Not only are fish absolutely delicious when cooked, there"", ""are always fighters willing to buy a well cooked fish"", ""when they're low on health."")) .addNext(new NPCStatement(npc.getId(), HeadE.CHEERFUL, ""I would recommend everybody has a go at Fishing at least once in their lives! Was there anything else you"", ""wished to hear again?"")) .addNext(getStage(""Recap"")); getStage(""Recap"").addNext(new PlayerStatement(HeadE.NO_EXPRESSION, ""Tell me about Cooking again."")) .addNext(new NPCStatement(npc.getId(), HeadE.CHEERFUL, ""Yes, the most basic of survival techniques. Most simple"", ""meals can be cooked on a fire by right-clicking on the"", ""food, selecting use, then left clicking on the fire."")) .addNext(new NPCStatement(npc.getId(), HeadE.CHEERFUL, ""Eating food will restore a little health. The harder"", ""something is to cook, the more it will heal you."", ""Somewhere around here is a chef who will tell you more"", ""about food and cooking it."")) .addNext(getStage(""Recap"")); getStage(""Recap"").addNext(new PlayerStatement(HeadE.NO_EXPRESSION, ""Tell me about my stats again."")) .addNext(new NPCStatement(npc.getId(), HeadE.CHEERFUL, ""To look at your stats, click on the bar graph icon found"", ""near your backpack icon. In this side panel you can"", ""check your skill level."")) .addNext(new NPCStatement(npc.getId(), HeadE.CHEERFUL, ""As you move your mouse over any of the icons in this"", ""panel, the small yellow popup box will show you the"", ""exact amount of experience you have and how much is"", ""needed to get to the next level."")) .addNext(getStage(""Recap"")); } create(); } }" "package com.rs.game.content.tutorialisland; @PluginEventHandler public final class TutorialIslandController extends Controller { private static final IntSet TUTORIAL_REGIONS = IntSet.of(12336, 12592, 12337, 12436); private static final int RUNESCAPE_GUIDE = 945; private static final int SURVIVAL_EXPERT = 943; private static final int MASTER_CHEF = 942; private static final int QUEST_GUIDE = 949; private static final int MINING_INSTRUCTOR = 948; private static final int COMBAT_INSTRUCTOR = 944; private static final int FINANCIAL_ADVISOR = 947; private static final int BROTHER_BRACE = 954; private static final int MAGIC_INSTRUCTOR = 946; private static final int BANKER = 953; private static final int FISHING_SPOT = 952; private static final int GIANT_RAT = 950; private static final int CHICKEN = 951; private static final int SKIPPY = 2795; private transient String[] prevText = {""""}; private Stage stage; @ServerStartupEvent(Priority.POST_PROCESS) public static void init() { ChunkManager.permanentlyPreloadRegions(TUTORIAL_REGIONS); } public enum Stage { TALK_TO_GUIDE(new String[] { ""Getting started"", ""To start the tutorial use your left mouse button to click on the"", Settings.getConfig().getServerName() + "" Guide in this room. He is indicated by a flashing"", ""yellow arrow above his head. If you can't see him, use your"", ""keyboard's arrow keys to rotate the view."" }, ctrl -> ctrl.player.getInterfaceManager().removeSubs(Sub.ALL_GAME_TABS), ctrl -> ctrl.hintNPC(RUNESCAPE_GUIDE)), OPEN_SETTINGS(new String[] { ""Player controls"", ""Please click on the flashing spanner icon found at the bottom"", ""right of your screen. This will display your player controls."" }, ctrl -> ctrl.player.getInterfaceManager().sendSubDefault(Sub.TAB_SETTINGS), ctrl -> { ctrl.removeHint(); ctrl.player.getInterfaceManager().flashTab(Sub.TAB_SETTINGS); }), TALK_TO_GUIDE_2(new String[] { ""Player controls"", ""On the side panel you can now see a variety of options from"", ""changing the brightness of the screen and of the volume of"", ""music, to selecting whether your player should accept help"", ""from other players. Don't worry about these too much for now,"", ""they will become clearer as you explore the game. Talk to the"", Settings.getConfig().getServerName()+"" Guide to continue."" }, ctrl -> { }, ctrl -> { ctrl.player.getInterfaceManager().flashTabOff(); ctrl.hintNPC(RUNESCAPE_GUIDE); }), LEAVE_GUIDE_ROOM(new String[] { ""Interacting with scenery"", ""You can interact with many items of scenery by simply clicking"", ""on them. Right clicking will also give more options. Feel free to"", ""try it with the things in this room, then click the door"", ""indicated with the yellow arrow to go through to the next"", ""instructor."" }, ctrl -> { }, ctrl -> { ctrl.removeHint(); ctrl.hintLocation(3097, 3107, 125); }), TALK_TO_SURVIVAL_EXPERT(new String[] { ""Moving around"", ""Follow the path to find the next instructor. Clicking on the"", ""ground will walk you to that point. Talk to the Survival Expert by"", ""the pond to continue the tutorial. Remember that you can rotate"", ""the view by pressing the arrow keys."" }, ctrl -> { }, ctrl -> ctrl.hintNPC(SURVIVAL_EXPERT)), OPEN_INVENTORY(new String[] { ""Viewing the items that you were given."", ""Click on the flashing backpack icon to the right hand side of"", ""the main window to view your inventory. Your inventory is a list"", ""of everything you have in your backpack."" }, ctrl -> ctrl.player.getInterfaceManager().sendSubDefault(Sub.TAB_INVENTORY), ctrl -> { ctrl.removeHint(); ctrl.player.getInterfaceManager().flashTab(Sub.TAB_INVENTORY); }), CHOP_TREE(new String[] { ""Cut down a tree"", ""You can click on the backpack icon at any time to view the"", ""items that you currently have in your inventory. You will see"", ""that you now have an axe in your inventory. Use this to get"", ""some logs by clicking on one of the trees in the area."" }, ctrl -> { }, ctrl -> { ctrl.player.getInterfaceManager().flashTabOff(); ctrl.removeHint(); ctrl.hintLocation(3099, 3095, 150); }), MAKE_A_FIRE(new String[] { ""Making a fire"", ""Well done! You managed to cut some logs from the tree! Next,"", ""use the tinderbox in your inventory to light the logs."", ""First click on the tinderbox to 'use' it."", ""Then click on the logs in your inventory to light them."" }, ctrl -> { }, TutorialIslandController::removeHint), OPEN_SKILLS(new String[] { """", ""You gained some experience."", ""Click on the flashing bar graph icon near the inventory button"", ""to see your skill stats."" }, ctrl -> ctrl.player.getInterfaceManager().sendSubDefault(Sub.TAB_SKILLS), ctrl -> ctrl.player.getInterfaceManager().flashTab(Sub.TAB_SKILLS)), TALK_TO_SURVIVAL_EXPERT_2(new String[] { ""Your skill stats."", ""Here you will see how good your skills are. As you move your"", ""mouse over any of the icons in this panel, the small yellow"", ""popup box will show you the exact amount of experience you"", ""have and how much is needed to get to the next level. Speak to"", ""the Survival Expert to continue."" }, ctrl -> { }, ctrl -> { ctrl.player.getInterfaceManager().flashTabOff(); ctrl.hintNPC(SURVIVAL_EXPERT); }), CATCH_SHRIMP(new String[] { ""Catch some Shrimp"", ""Click on the sparkling fishing spot, indicated by the flashing"", ""arrow. Remember, you can check your inventory by clicking the"", ""backpack icon."" }, ctrl -> { }, ctrl -> { ctrl.removeHint(); ctrl.hintNPC(FISHING_SPOT); }), BURN_SHRIMP(new String[] { ""Cooking your shrimp."", ""Now you have caught some shrimp, let's cook it. First light a"", ""fire: chop down a tree and then use the tinderbox on the logs."", ""If you've lost your axe or tinderbox Brynna will give you"", ""another."" }, ctrl -> { }, TutorialIslandController::removeHint), COOK_SHRIMP(new String[] { ""Burning your shrimp."", ""You have just burnt your first shrimp. This is normal. As you"", ""get more experience in Cooking, you will burn stuff less often."", ""Let's try cooking without burning it this time. First catch some"", ""more shrimp, then use them on a fire."" }, ctrl -> { }, ctrl -> { }), LEAVE_SURVIVAL_EXPERT(new String[] { ""Well done, you've just cooked your first ""+Settings.getConfig().getServerName()+"" meal."", ""If you'd like a recap on anything you've learnt so far, speak to"", ""the Survival Expert. You can now move on to the next instructor."", ""Click on the gate shown and follow the path."", ""Remember, you can move the camera with the arrow keys."" }, ctrl -> { }, ctrl -> ctrl.hintLocation(3089, 3092, 120)), ENTER_CHEF_HOUSE(new String[] { ""Find your next instructor."", ""Follow the path until you get to the door with the yellow arrow"", ""above it. Click on the door to open it. Notice the mini-map in"", ""the top right; this shows a top down view of the area around"", ""you. This can also be used for navigation."" }, ctrl -> { }, ctrl -> { ctrl.removeHint(); ctrl.hintLocation(3078, 3084, 150); }), TALK_TO_CHEF(new String[] { ""Find your next instructor."", ""Talk to the chef indicated. He will teach you the more advanced"", ""aspects of Cooking such as combining ingredients. He will also"", ""teach you about your music player menu as well."" }, ctrl -> { }, ctrl -> { ctrl.removeHint(); ctrl.hintNPC(MASTER_CHEF); }), MAKE_DOUGH(new String[] { ""Making dough."", ""This is the base for many of the meals. To make dough we must"", ""mix flour and water. First, right click the bucket of water and"", ""select use, then left click on the pot of flour."" }, ctrl -> { }, TutorialIslandController::removeHint), COOK_DOUGH(new String[] { ""Cooking dough."", ""Now you have made dough, you can cook it. To cook the dough,"", ""use it with the range shown by the arrow. If you lose your"", ""dough, talk to Lev - he will give you more ingredients."" }, ctrl -> { }, ctrl -> ctrl.hintLocation(3075, 3081, 125)), OPEN_MUSIC(new String[] { ""Cooking dough"", ""Well done! Your first loaf of bread. As you gain experience in"", ""Cooking, you will be able to make other things like pies, cakes"", ""and even kebabs. Now you've got the hang of cooking, let's"", ""move on. Click on the flashing icon in the bottom right to see"", ""the jukebox."" }, ctrl -> ctrl.player.getInterfaceManager().sendSubDefault(Sub.TAB_MUSIC), ctrl -> { ctrl.removeHint(); ctrl.player.getInterfaceManager().flashTab(Sub.TAB_MUSIC); }), LEAVE_CHEF_HOUSE(new String[] { ""The music player."", ""From this interface you can control the music that is played."", ""As you explore the world, more of the tunes will become"", ""unlocked. Once you've examined this menu use the next door"", ""to continue. If you need a recap on anything covered here,"", ""talk to Lev."" }, ctrl -> { }, ctrl -> { ctrl.hintLocation(3072, 3090, 125); ctrl.player.getInterfaceManager().flashTabOff(); }), OPEN_EMOTES(new String[] { ""Emotes."", """", ""Now, how about showing some feelings? You will see a flashing"", ""icon in the shape of a person. Click on that to access your"", ""emotes."" }, ctrl -> ctrl.player.getInterfaceManager().sendSubDefault(Sub.TAB_EMOTES), ctrl -> { ctrl.removeHint(); ctrl.player.getInterfaceManager().flashTab(Sub.TAB_EMOTES); }), USE_EMOTE(new String[] { ""Emotes."", ""For those situations where words don't quest describe how you"", ""feel, try an emote. Go ahead, try one out! You might notice"", ""that some of the emotes are grey and cannot be used now."", ""Don't worry! As you progress further into the game you'll gain"", ""access to all sorts of things, including more fun emotes like"", ""these"" }, ctrl -> { }, ctrl -> ctrl.player.getInterfaceManager().flashTabOff()), RUN(new String[] { ""Running."", ""It's only a short distance to the next guide."", ""Why not try running there? You can run by clicking"", ""on the boot icon next to your minimap or by holding"", ""down your control key while clicking your destination."" }, ctrl -> ctrl.player.getInterfaceManager().sendSubDefault(Sub.ORB_RUN), ctrl -> { ctrl.player.getInterfaceManager().flashTab(Sub.ORB_RUN); ctrl.getPlayer().setRun(false); }), ENTER_QUEST_GUIDE_HOUSE(new String[] { ""Run to the next guide."", ""Now that you have the run button turned on, follow the path"", ""until you come to the end. You may notice that the number on"", ""the button goes down. This is your run energy. If your run"", ""energy reaches zero, you'll stop running. Click on the door"", ""to pass through it."" }, ctrl -> { }, ctrl -> { ctrl.player.getInterfaceManager().flashTabOff(); ctrl.hintLocation(3086, 3126, 125); }), TALK_TO_QUEST_GUIDE(new String[] { """", ""Talk with the Quest Guide."", """", ""He will tell you all about quests."", """" }, ctrl -> { }, ctrl -> { ctrl.removeHint(); ctrl.hintNPC(QUEST_GUIDE); }), OPEN_QUEST_TAB(new String[] { """", ""Open the Quest Journal."", """", ""Click on the flashing icon next to your inventory."", """" }, ctrl -> ctrl.player.getInterfaceManager().sendSubDefault(Sub.TAB_QUEST), ctrl -> { ctrl.removeHint(); ctrl.player.getInterfaceManager().flashTab(Sub.TAB_QUEST); }), TALK_TO_QUEST_GUIDE_2(new String[] { ""Your Quest Journal"", """", ""This is your Quest Journal, a list of all the quests in the game."", ""Talk to the Quest Guide again for an explanation."", """" }, ctrl -> { }, ctrl -> { ctrl.player.getInterfaceManager().flashTabOff(); ctrl.hintNPC(QUEST_GUIDE); }), LEAVE_QUEST_GUIDE_HOUSE(new String[] { """", ""Moving on."", ""It's time to enter some caves. Click on the ladder to go down to"", ""the next area."", """" }, ctrl -> { }, ctrl -> { ctrl.removeHint(); ctrl.hintLocation(3088, 3119, 50); }), TALK_TO_MINING_GUIDE(new String[] { ""Mining and Smithing."", ""Next let's get you a weapon, or more to the point, you can"", ""make your first weapon yourself. Don't panic, the Mining"", ""Instructor will help you. Talk to him and he'll tell you all about it."", """" }, ctrl -> { }, ctrl -> { ctrl.removeHint(); ctrl.hintNPC(MINING_INSTRUCTOR); }), PROSPECTING_TIN(new String[] { ""Prospecting."", ""To prospect a mineable rock, just right click it and select the"", ""'prospect rock' option. This will tell you the type of ore you can"", ""mine from it. Try it now on one of the rocks indicated."", """" }, ctrl -> { }, ctrl -> { ctrl.removeHint(); ctrl.hintLocation(3076, 9504, 45); }), PROSPECTING_COPPER(new String[] { ""It's tin."", """", ""So now you know there's tin in the grey rocks, try prospecting"", ""the brown ones next."", """" }, ctrl -> { }, ctrl -> { ctrl.removeHint(); ctrl.hintLocation(3086, 9501, 45); }), TALK_TO_MINING_GUIDE_2(new String[] { ""It's copper."", ""Talk to the Mining Instructor to find out about these types of"", ""ore and how you can mind them. He'll even give you the"", ""required tools."", """" }, ctrl -> { }, ctrl -> { ctrl.removeHint(); ctrl.hintNPC(MINING_INSTRUCTOR); }), MINING_TIN(new String[] { ""Mining."", ""It's quite simple really. All you need to do is right click on the"", ""rock and select 'mine'. You can only mine when you have a"", ""pickaxe. So give it a try: first mine one tin ore."", """" }, ctrl -> { }, ctrl -> { ctrl.removeHint(); ctrl.hintLocation(3076, 9504, 45); }), MINING_COPPER(new String[] { ""Mining."", ""Now you have some tin ore you just need some copper ore,"", ""then you'll have all you need to create a bronze bar. As you"", ""did before right click on the copper rock and select 'mine'."", """" }, ctrl -> { }, ctrl -> { ctrl.removeHint(); ctrl.hintLocation(3086, 9501, 45); }), SMELTING(new String[] { ""Smelting."", ""You should now have both some copper and tin ore. So let's"", ""smelt them to make a bronze bar. To do this, right click on"", ""either tin or copper ore and select use then left click on the"", ""furnace. Try it now."" }, ctrl -> { }, ctrl -> { ctrl.removeHint(); ctrl.hintLocation(3079, 9496, 125); }), TALK_TO_MINING_GUIDE_3(new String[] { ""You've made a bronze bar!"", """", ""Speak to the Mining Instructor and he'll show you how to make"", ""it into a weapon."", """" }, ctrl -> { }, ctrl -> { ctrl.removeHint(); ctrl.hintNPC(MINING_INSTRUCTOR); }), CLICK_ANVIL(new String[] { ""Smithing a dagger."", ""To smith you'll need a hammer and enough metal bars to make"", ""the desired item, as well as a handy anvil. To start the"", ""process, click on the anvil, or alternatively use the bar on it."", """" }, ctrl -> { }, ctrl -> { ctrl.removeHint(); ctrl.hintLocation(3083, 9499, 35); }), SMITH_DAGGER(new String[] { ""Smithing a dagger."", ""Now you have the Smithing menu open, you will see a list of all"", ""the things you can make. Only the dagger can be made at your"", ""skill level; this is shown by the white text under it. You'll need"", ""to select the dagger to continue."" }, ctrl -> { }, TutorialIslandController::removeHint), LEAVE_MINING_AREA(new String[] { ""You've finished in this area."", ""So let's move on. Go through the gates shown by the arrow."", ""Remember, you may need to move the camera to see your"", ""surroundings. Speak to the guide for a recap at any time."", """" }, ctrl -> { }, ctrl -> ctrl.hintLocation(3094, 9502, 125)), TALK_TO_COMBAT_INSTRUCTOR(new String[] { ""Combat."", """", ""In this area you will find out about combat with swords and"", ""bows. Speak to the guide and he will tell you all about it."", """" }, ctrl -> { }, ctrl -> { ctrl.removeHint(); ctrl.hintNPC(COMBAT_INSTRUCTOR); }), OPEN_EQUIPMENT_TAB(new String[] { ""Wielding weapons."", """", ""You now have access to a new interface. Click on the flashing"", ""icon of a man, the one to the right of your backpack icon."", """" }, ctrl -> ctrl.player.getInterfaceManager().sendSubDefault(Sub.TAB_EQUIPMENT), ctrl -> { ctrl.removeHint(); ctrl.player.getInterfaceManager().flashTab(Sub.TAB_EQUIPMENT); }), OPEN_EQUIPMENT_SCREEN(new String[] { ""This is your worn inventory."", ""From here you can see what items you have equipped. You will"", ""notice the button 'View equipment stats'. Click on this now to"", ""display the details of what you have equipped."", """" }, ctrl -> { }, ctrl -> ctrl.player.getInterfaceManager().flashTabOff()), WIELD_DAGGER(new String[] { ""Worn interface"", ""You can see what items you are wearing in the worn inventory"", ""to the left of the screen, with their combined statistics on the"", ""right. Let's add something. Left click your dagger to 'wield' it."", """" }, ctrl -> { }, ctrl -> { }), TALK_TO_COMBAT_INSTRUCTOR_2(new String[] { ""You're now holding your dagger."", ""Clothes, armour, weapons and many other items are equipped"", ""like this. You can unequip items by clicking on the item in the"", ""worn inventory. You can close this window by clicking on the"", ""small 'x' in the top right hand corner. Speak to the Combat"", ""Instructor to continue."" }, ctrl -> { }, ctrl -> ctrl.hintNPC(COMBAT_INSTRUCTOR)), EQUIP_SWORD_AND_SHIELD(new String[] { ""Unequipping items."", ""In your worn inventory panel, right click on the dagger and"", ""select the remove option from the drop down list. After you've"", ""unequipped the dagger, wield the sword and shield. As you"", ""pass the mouse over an item, you will see its name appear at"", ""the top left of the screen."" }, ctrl -> { }, TutorialIslandController::removeHint), OPEN_COMBAT_TAB(new String[] { ""Combat interface."", """", ""Click on the flashing crossed swords icon to see the combat"", ""interface."", """" }, ctrl -> ctrl.player.getInterfaceManager().sendSubDefault(Sub.TAB_COMBAT), ctrl -> ctrl.player.getInterfaceManager().flashTab(Sub.TAB_COMBAT)), ENTER_RAT_CAGE(new String[] { ""This is your combat interface."", ""From this interface you can select the type of attack your"", ""character will use. Different monsters have different"", ""weaknesses. If you hover your mouse over the buttons, you"", ""will see the type of XP you will receive when using each type of"", ""attack. Now you have the tools needed for battle why not slay"", ""some rats. Click on the gates indicated to continue."" }, ctrl -> { }, ctrl -> { ctrl.player.getInterfaceManager().flashTabOff(); ctrl.hintLocation(3111, 9518, 125); }), ATTACK_RAT_MELEE(new String[] { ""Attacking."", """", ""To attack the rat, right click it and select the attack option. You"", ""will then walk over to it and start hitting it."", """" }, ctrl -> { }, ctrl -> { ctrl.removeHint(); ctrl.hintNPC(GIANT_RAT); }), KILL_RAT_MELEE(new String[] { ""Sit back and watch."", ""While you are fighting you will see a bar over your head. The"", ""bar shows how much health you have left. Your opponent will"", ""have one too. You will continue to attack the rat until it's dead"", ""or you do something else."" }, ctrl -> { }, ctrl -> { }), TALK_TO_COMBAT_INSTRUCTOR_3(new String[] { ""Well done, you've made your first kill!"", """", ""Pass through the gate and talk to the Combat Instructor; he"", ""will give you your next task."", """" }, ctrl -> { }, ctrl -> { ctrl.removeHint(); ctrl.hintNPC(COMBAT_INSTRUCTOR); }), KILL_RAT_RANGE(new String[] { ""Rat ranging."", ""Now you have a bow and some arrows. Before you can use"", ""them you'll need to equip them. Once equipped with the"", ""ranging gear, try killing another rat. Remember: to attack, right"", ""click on the monster and select attack."" }, ctrl -> { }, ctrl -> { ctrl.removeHint(); ctrl.hintNPC(GIANT_RAT); }), LEAVE_COMBAT_AREA(new String[] { ""Moving on."", ""You have completed the tasks here. To move on, click on the"", ""ladder shown. If you need to go over any of what you learnt"", ""here, just talk to the Combat Instructor and he'll tell you what"", ""he can."" }, ctrl -> { }, ctrl -> { ctrl.removeHint(); ctrl.hintLocation(3111, 9526, 125); }), OPEN_BANK(new String[] { ""Banking."", ""Follow the path and you will come to the front of the building."", ""This is the Bank of "" + Settings.getConfig().getServerName() + "", where you can store all you"", ""most valued items. To open your bank box just right click on an"", ""open booth indicated and select 'use'."" }, ctrl -> { }, ctrl -> { ctrl.removeHint(); ctrl.hintLocation(3122, 3124, 125); }), ENTER_FINANCIAL_ROOM(new String[] { ""This is your bank box."", ""You can store stuff here for safekeeping. If you die, anything"", ""in your bank will be saved. To deposit something, right click it"", ""and select 'store'. Once you've had a good look, close the"", ""window and move through the door indicated."" }, ctrl -> { }, ctrl -> { ctrl.removeHint(); ctrl.hintLocation(3124, 3124, 125); }), TALK_TO_FINANCIAL_ADVISOR(new String[] { ""Financial advice."", """", ""The guide here will tell you all about making cash. Just click on"", ""him to hear what he's got to say."", """" }, ctrl -> { }, ctrl -> { ctrl.removeHint(); ctrl.hintNPC(FINANCIAL_ADVISOR); }), LEAVE_FINANCIAL_ADVISOR_ROOM(new String[] { """", """", ""Continue through the next door."", """", """" }, ctrl -> { }, ctrl -> { ctrl.removeHint(); ctrl.hintLocation(3129, 3124, 125); }), TALK_TO_BROTHER_BRACE(new String[] { ""Prayer."", ""Follow the path to the chapel and enter it."", ""Once inside talk to the monk. He'll tell you all about the Prayer"", ""skill."", """" }, ctrl -> { }, ctrl -> { ctrl.removeHint(); ctrl.hintNPC(BROTHER_BRACE); }), OPEN_PRAYER_TAB(new String[] { ""Your Prayer menu."", """", ""Click on the flashing icon to open the Prayer menu."", """", """" }, ctrl -> ctrl.player.getInterfaceManager().sendSubDefault(Sub.TAB_PRAYER), ctrl -> { ctrl.removeHint(); ctrl.player.getInterfaceManager().flashTab(Sub.TAB_PRAYER); }), TALK_TO_BROTHER_BRACE_2(new String[] { """", ""Your Prayer Menu."", """", ""Talk with Brother Brace and he'll tell you about prayers."", """" }, ctrl -> { }, ctrl -> { ctrl.player.getInterfaceManager().flashTabOff(); ctrl.hintNPC(BROTHER_BRACE); }), OPEN_FRIENDS_TAB(new String[] { """", ""Friends list."", ""You should now see another new icon. Click on the flashing"", ""smiling face to open your friends list."", """" }, ctrl -> ctrl.player.getInterfaceManager().sendSubDefault(Sub.TAB_FRIENDS), ctrl -> { ctrl.removeHint(); ctrl.player.getInterfaceManager().flashTab(Sub.TAB_FRIENDS); }), OPEN_IGNORE_LIST(new String[] { ""This is your friends list."", """", ""This will be explained by Brother Brace shortly, but first click"", ""on the red dot button on the bottom right of the friends list."", """" }, ctrl -> { }, ctrl -> ctrl.player.getInterfaceManager().flashTabOff()), TALK_TO_BROTHER_BRACE_3(new String[] { ""This is your ignore list."", ""The two lists - friends and ignore - can be very helpful for"", ""keeping track of when your friends are online or for blocking"", ""messages from people you simply don't like. Speak with"", ""Brother Brace and he will tell you more."" }, ctrl -> { }, ctrl -> ctrl.hintNPC(BROTHER_BRACE)), LEAVE_CHURCH_AREA(new String[] { """", ""Your final instructor!"", ""You're almost finished on tutorial island. Pass through the"", ""door to find the path leading to your final instructor."", """" }, ctrl -> { }, ctrl -> { ctrl.removeHint(); ctrl.hintLocation(3122, 3102, 125); }), TALK_TO_MAGIC_INSTRUCTOR(new String[] { ""Your final instructor!"", ""Just follow the path to the Wizard's house, where you will be"", ""shown how to cast spells. Just talk with the mage indicated to"", ""find out more."", """" }, ctrl -> { }, ctrl -> { ctrl.removeHint(); ctrl.hintNPC(MAGIC_INSTRUCTOR); }), OPEN_MAGIC_TAB(new String[] { ""Open up your final menu."", """", ""Open up the Magic menu by clicking on the flashing icon next"", ""to the Prayer button you just learned about."", """" }, ctrl -> ctrl.player.getInterfaceManager().sendSubDefault(Sub.TAB_MAGIC), ctrl -> { ctrl.removeHint(); ctrl.player.getInterfaceManager().flashTab(Sub.TAB_MAGIC); }), TALK_TO_MAGIC_INSTRUCTOR_2(new String[] { """", ""This is your spells list."", """", ""Ask the mage about it."", """" }, ctrl -> { }, ctrl -> { ctrl.hintNPC(MAGIC_INSTRUCTOR); ctrl.player.getInterfaceManager().flashTabOff(); ctrl.player.startConversation(new MagicInstructor(ctrl.player, ctrl.getNPC(MAGIC_INSTRUCTOR), ctrl)); }), CAST_WIND_STRIKE(new String[] { ""Cast Wind Strike at a chicken."", ""Now you have runes you should see the Wind Strike icon at the"", ""top left corner of the Magic interface - third in from the"", ""left. Walk over to the caged chickens, click the Wind Strike icon"", ""and then select one of the chickens to cast it on. It may take"", ""several tries. If you need more runes ask Terrova."" }, ctrl -> { }, ctrl -> { ctrl.removeHint(); ctrl.hintNPC(CHICKEN); }), TALK_TO_MAGIC_INSTRUCTOR_3(new String[] { ""You have almost completed the tutorial!"", """", ""All you need to do now is move on to the mainland. Just speak"", ""with Terrova and he'll teleport you to Lumbridge Castle."", """" }, ctrl -> { }, ctrl -> { ctrl.removeHint(); ctrl.hintNPC(MAGIC_INSTRUCTOR); }); private final String[] textBody; private final Consumer setupInterfaces; private final Consumer onStart; Stage(String[] textBody, Consumer setupInterfaces, Consumer onStart) { this.textBody = textBody; this.setupInterfaces = setupInterfaces; this.onStart = onStart; } public void start(TutorialIslandController ctr) { setupInterfaces.accept(ctr); onStart.accept(ctr); ctr.sendText(textBody); ctr.sendProgress(); } public void loadAllUpTo(TutorialIslandController ctr) { for (Stage s : Stage.values()) { if (s == this) { s.start(ctr); return; } s.setupInterfaces.accept(ctr); s.onStart.accept(ctr); } } } public TutorialIslandController() { stage = Stage.TALK_TO_GUIDE; } @Override public boolean processButtonClick(int interfaceId, int componentId, int slotId, int slotId2, ClientPacket packet) { if (interfaceId == Inventory.INVENTORY_INTERFACE && packet == ClientPacket.IF_OP2) { Item item = player.getInventory().getItem(slotId); if (item != null && item.getId() == 1511) sendText(true, ""Please wait."", """", ""Your character is now attempting to light the fire."", ""This should only take a few seconds.""); } if (getStage() == Stage.OPEN_SETTINGS && componentId == 87) nextStage(Stage.TALK_TO_GUIDE_2); else if (getStage() == Stage.OPEN_INVENTORY && (componentId == 79 || componentId == 116)) nextStage(Stage.CHOP_TREE); else if (getStage() == Stage.OPEN_SKILLS && (componentId == 77 || componentId == 114)) nextStage(Stage.TALK_TO_SURVIVAL_EXPERT_2); else if (getStage() == Stage.OPEN_MUSIC && componentId == 89) nextStage(Stage.LEAVE_CHEF_HOUSE); else if (getStage() == Stage.OPEN_EMOTES && componentId == 88) nextStage(Stage.USE_EMOTE); else if (getStage() == Stage.USE_EMOTE && interfaceId == 590 && componentId == 8) nextStage(Stage.RUN); else if (getStage() == Stage.RUN && interfaceId == 750 && componentId == 4) nextStage(Stage.ENTER_QUEST_GUIDE_HOUSE); else if (getStage() == Stage.OPEN_QUEST_TAB && (componentId == 78 || componentId == 115)) nextStage(Stage.TALK_TO_QUEST_GUIDE_2); else if (getStage() == Stage.OPEN_EQUIPMENT_TAB && (componentId == 80 || componentId == 117)) nextStage(Stage.OPEN_EQUIPMENT_SCREEN); else if (getStage() == Stage.OPEN_EQUIPMENT_SCREEN && interfaceId == 387 && componentId == 38) nextStage(Stage.WIELD_DAGGER); else if (getStage() == Stage.OPEN_COMBAT_TAB && (componentId == 75 || componentId == 112)) nextStage(Stage.ENTER_RAT_CAGE); else if (getStage() == Stage.OPEN_PRAYER_TAB && (componentId == 81 || componentId == 118)) nextStage(Stage.TALK_TO_BROTHER_BRACE_2); else if (getStage() == Stage.OPEN_FRIENDS_TAB && componentId == 84) nextStage(Stage.OPEN_IGNORE_LIST); else if (getStage() == Stage.OPEN_IGNORE_LIST && interfaceId == 550 && componentId == 48) nextStage(Stage.TALK_TO_BROTHER_BRACE_3); else if (getStage() == Stage.OPEN_MAGIC_TAB && (componentId == 82 || componentId == 119)) nextStage(Stage.TALK_TO_MAGIC_INSTRUCTOR_2); return true; } @Override public boolean processNPCClick1(NPC npc) { if (npc.getId() == SKIPPY) { player.startConversation(new Skippy(player, npc, this)); return false; } if (npc.getId() == RUNESCAPE_GUIDE && pastStage(Stage.TALK_TO_GUIDE)) { player.startConversation(new RuneScapeGuide(player, npc, this)); return false; } if (npc.getId() == SURVIVAL_EXPERT && pastStage(Stage.TALK_TO_SURVIVAL_EXPERT)) { player.startConversation(new SurvivalExpert(player, npc, this)); return false; } else if (npc.getId() == FISHING_SPOT && pastStage(Stage.CATCH_SHRIMP)) { player.getActionManager().setAction(new Fishing(FishingSpot.SHRIMP, npc)); sendText(true, ""Please wait."", ""This should only take a few seconds."", ""As you gain Fishing experience you'll find that there are many"", ""types of fish and many ways to catch them.""); return false; } else if (npc.getId() == MASTER_CHEF && pastStage(Stage.TALK_TO_CHEF)) { player.startConversation(new MasterChef(player, npc, this)); return false; } else if (npc.getId() == QUEST_GUIDE && pastStage(Stage.TALK_TO_QUEST_GUIDE)) { player.startConversation(new QuestGuide(player, npc, this)); return false; } else if (npc.getId() == MINING_INSTRUCTOR && pastStage(Stage.TALK_TO_MINING_GUIDE)) { player.startConversation(new MiningInstructor(player, npc, this)); return false; } else if (npc.getId() == COMBAT_INSTRUCTOR && pastStage(Stage.TALK_TO_COMBAT_INSTRUCTOR)) { player.startConversation(new CombatInstructor(player, npc, this)); return false; } else if (npc.getId() == BANKER && pastStage(Stage.OPEN_BANK)) { player.startConversation(new Conversation(player, new Dialogue(new NPCStatement(BANKER, HeadE.CHEERFUL, ""Good day, would you like to access your bank account?"")) .addNext(new OptionStatement(""Select an Option"", ""Yes."", ""No thanks."")) .addNext(new Dialogue().setFunc(() -> { player.getBank().clear(); player.getBank().addItem(new Item(995, 25), false); nextStage(Stage.ENTER_FINANCIAL_ROOM); player.getBank().open(); } )).finish())); return false; } else if (npc.getId() == FINANCIAL_ADVISOR && pastStage(Stage.TALK_TO_FINANCIAL_ADVISOR)) { player.startConversation(new FinancialAdvisor(player, npc, this)); return false; } else if (npc.getId() == BROTHER_BRACE && pastStage(Stage.TALK_TO_BROTHER_BRACE)) { player.startConversation(new BrotherBrace(player, npc, this)); return false; } else if (npc.getId() == MAGIC_INSTRUCTOR && pastStage(Stage.TALK_TO_MAGIC_INSTRUCTOR)) { player.startConversation(new MagicInstructor(player, npc, this)); return false; } return true; } @Override public boolean processNPCClick2(NPC npc) { if (npc.getId() == SKIPPY) { player.startConversation(new Skippy(player, npc, this)); return false; } return true; } @Override public boolean processObjectClick1(GameObject object) { if (object.getId() == 36773) { player.sendMessage(""I should continue what I was doing.""); return false; } if (object.getId() == 3014 && pastStage(Stage.LEAVE_GUIDE_ROOM)) { nextStage(Stage.TALK_TO_SURVIVAL_EXPERT); player.handleOneWayDoor(object); return false; } if (object.getId() == 3033 && pastStage(Stage.CHOP_TREE)) { player.getActionManager().setAction(new Woodcutting(object, TreeType.NORMAL)); sendText(true, ""Please wait."", """", ""Your character is now attempting to cut down the tree. Sit back"", ""for a moment while he does all the hard work.""); } else if (object.getDefinitions().getName().equals(""Oak"")) sendText(true, """", """", ""You wouldn't know where to start with this tree.""); else if ((object.getId() == 3015 || object.getId() == 3016) && pastStage(Stage.LEAVE_SURVIVAL_EXPERT)) { nextStage(Stage.ENTER_CHEF_HOUSE); player.handleOneWayDoor(object, 0, 1); } else if (object.getId() == 3017 && pastStage(Stage.ENTER_CHEF_HOUSE)) { nextStage(Stage.TALK_TO_CHEF); player.handleOneWayDoor(object); } else if (object.getId() == 3018 && pastStage(Stage.LEAVE_CHEF_HOUSE)) { nextStage(Stage.OPEN_EMOTES); player.handleOneWayDoor(object, 0, 1); } else if (object.getId() == 3019 && pastStage(Stage.ENTER_QUEST_GUIDE_HOUSE)) { nextStage(Stage.TALK_TO_QUEST_GUIDE); player.handleOneWayDoor(object); } else if (object.getId() == 3029 && pastStage(Stage.LEAVE_QUEST_GUIDE_HOUSE)) { nextStage(Stage.TALK_TO_MINING_GUIDE); player.useLadder(Tile.of(3088, 9520, 0)); } else if (object.getId() == 3028 && pastStage(Stage.LEAVE_QUEST_GUIDE_HOUSE)) player.useLadder(Tile.of(3088, 3120, 0)); else if (object.getId() == 3043) player.getActionManager().setAction(new Mining(RockType.TIN, object)); else if (object.getId() == 3042) player.getActionManager().setAction(new Mining(RockType.COPPER, object)); else if (object.getId() == 2783 && pastStage(Stage.CLICK_ANVIL)) { nextStage(Stage.SMITH_DAGGER); return true; } else if ((object.getId() == 3020 || object.getId() == 3021) && pastStage(Stage.ENTER_CHEF_HOUSE)) { player.handleOneWayDoor(object, 0, 1); nextStage(Stage.TALK_TO_COMBAT_INSTRUCTOR); } else if (object.getId() == 3022 || object.getId() == 3023 && pastStage(Stage.ENTER_RAT_CAGE)) { if (getStage() == Stage.KILL_RAT_RANGE) { player.startConversation(new Conversation(player, new Dialogue(new NPCStatement(COMBAT_INSTRUCTOR, HeadE.FRUSTRATED, ""No, don't enter the pit. Range the rats from outside"", ""the cage."")))); return false; } player.handleOneWayDoor(object, 0, 1); nextStage(Stage.ATTACK_RAT_MELEE); } else if (object.getId() == 3030 && pastStage(Stage.LEAVE_COMBAT_AREA)) { nextStage(Stage.OPEN_BANK); player.useLadder(player.transform(0, -6400, 0)); } else if (object.getId() == 3031 && pastStage(Stage.LEAVE_COMBAT_AREA)) player.useLadder(player.transform(0, 6400, 0)); else if (object.getId() == 3045 && pastStage(Stage.OPEN_BANK)) player.startConversation(new Conversation(player, new Dialogue(new NPCStatement(BANKER, HeadE.CHEERFUL, ""Good day, would you like to access your bank account?"")) .addNext(new OptionStatement(""Select an Option"", ""Yes."", ""No thanks."")) .addNext(new Dialogue().setFunc(() -> { nextStage(Stage.ENTER_FINANCIAL_ROOM); player.getBank().open(); } )).finish())); else if (object.getId() == 3024 && pastStage(Stage.ENTER_FINANCIAL_ROOM)) { nextStage(Stage.TALK_TO_FINANCIAL_ADVISOR); player.handleOneWayDoor(object); } else if (object.getId() == 3025 && pastStage(Stage.LEAVE_FINANCIAL_ADVISOR_ROOM)) { nextStage(Stage.TALK_TO_BROTHER_BRACE); player.handleOneWayDoor(object); } else if (object.getId() == 36999 || object.getId() == 37002) Doors.handleDoubleDoor(player, object); else if (object.getId() == 3026 && pastStage(Stage.LEAVE_CHURCH_AREA)) { nextStage(Stage.TALK_TO_MAGIC_INSTRUCTOR); player.handleOneWayDoor(object, 0, 1); } return false; } @Override public boolean processObjectClick2(GameObject object) { if (object.getId() == 3043) { nextStage(Stage.PROSPECTING_COPPER); player.sendMessage(""The rock contains tin!""); } else if (object.getId() == 3042) { nextStage(Stage.TALK_TO_MINING_GUIDE_2); player.sendMessage(""The rock contains copper!""); } return false; } @Override public boolean processItemOnObject(GameObject object, Item item) { if ((item.getId() == 438 || item.getId() == 436) && object.getId() == 3044) player.getActionManager().setAction(new Smelting(Smelting.SmeltingBar.BRONZE, object, 1)); else if (item.getId() == Fish.SHRIMP.getFishId() || item.getId() == 2307) return true; return false; } @Override public boolean canUseItemOnItem(Item itemUsed, Item usedWith) { if (usedWith(itemUsed, usedWith, 590, 1511)) sendText(true, ""Please wait."", """", ""Your character is now attempting to light the fire."", ""This should only take a few seconds.""); else if (usedWith(itemUsed, usedWith, 1929, 1933)) { player.getInventory().deleteItem(1929, 1); player.getInventory().deleteItem(1933, 1); player.getInventory().addItem(1925, 1); player.getInventory().addItem(1931, 1); player.getInventory().addItem(2307, 1); nextStage(Stage.COOK_DOUGH); return false; } return true; } public boolean usedWith(Item itemUsed, Item usedWith, int item1, int item2) { return (itemUsed.getId() == item1 && usedWith.getId() == item2) || (usedWith.getId() == item1 && itemUsed.getId() == item2); } @Override public boolean gainXP(int skillId, double exp) { if (skillId == Skills.HITPOINTS || player.getSkills().getLevelForXp(skillId) >= 3) return false; double currXp = player.getSkills().getXp(skillId); int levelPost = Skills.getLevelForXp(skillId, (long) (currXp + exp)); if (levelPost > 3) { player.getSkills().set(skillId, 3); return false; } return true; } @Override public void trackXP(int skillId, int addedXp) { player.closeInterfaces(); if (getStage() == Stage.MAKE_A_FIRE && skillId == Constants.FIREMAKING) nextStage(Stage.OPEN_SKILLS); if (getStage() == Stage.ATTACK_RAT_MELEE && (skillId == Constants.ATTACK || skillId == Constants.STRENGTH || skillId == Constants.DEFENSE)) nextStage(Stage.KILL_RAT_MELEE); if (getStage() == Stage.CAST_WIND_STRIKE && skillId == Constants.MAGIC) nextStage(Stage.TALK_TO_MAGIC_INSTRUCTOR_3); } @Override public boolean canAddInventoryItem(int itemId, int amount) { if (getStage() == Stage.CHOP_TREE && itemId == TreeType.NORMAL.getLogsId()[0]) { nextStage(Stage.MAKE_A_FIRE); player.startConversation(new Dialogue().addItem(itemId, ""You get some logs."")); } else if (itemId == Fish.SHRIMP.getFishId()) { if (getStage() == Stage.CATCH_SHRIMP) nextStage(Stage.BURN_SHRIMP); } else if (itemId == Cooking.Cookables.RAW_SHRIMP.getBurntItem().getId()) { if (getStage() == Stage.COOK_SHRIMP) { player.getInventory().addItem(new Item(Cooking.Cookables.RAW_SHRIMP.getProductItem()[0])); return false; } nextStage(Stage.COOK_SHRIMP); } else if (itemId == 2309 && getStage() == Stage.COOK_DOUGH) nextStage(Stage.OPEN_MUSIC); else if (itemId == new Item(Cooking.Cookables.RAW_SHRIMP.getProductItem()[0]).getId()) { if (getStage() == Stage.BURN_SHRIMP) { player.getInventory().addItem(Cooking.Cookables.RAW_SHRIMP.getBurntItem()); return false; } nextStage(Stage.LEAVE_SURVIVAL_EXPERT); } else if (itemId == 438) nextStage(Stage.MINING_COPPER); else if (itemId == 436) nextStage(Stage.SMELTING); else if (itemId == 2349) nextStage(Stage.TALK_TO_MINING_GUIDE_3); else if (itemId == 1205) nextStage(Stage.LEAVE_MINING_AREA); return true; } @Override public void processIncomingHit(Hit hit) { if (player.getHitpoints() <= hit.getDamage()) hit.setDamage(0); } @Override public void processNPCDeath(NPC npc) { if (npc.getId() == GIANT_RAT) { nextStage(Stage.TALK_TO_COMBAT_INSTRUCTOR_3); nextStage(Stage.LEAVE_COMBAT_AREA); } } @Override public boolean canEquip(int slotId, int itemId) { if (pastStage(Stage.WIELD_DAGGER)) { if (itemId == 1205) nextStage(Stage.TALK_TO_COMBAT_INSTRUCTOR_2); else if ((itemId == 1171 && player.getEquipment().getWeaponId() == 1277) || (itemId == 1277 && player.getEquipment().getShieldId() == 1171)) nextStage(Stage.OPEN_COMBAT_TAB); return true; } player.sendMessage(""You'll be told how to equip items later.""); return false; } @Override public void start() { if (getStage() == Stage.TALK_TO_GUIDE) player.tele(Tile.of(3094, 3107, 0)); sendInterfaces(); } @Override public void sendInterfaces() { player.getInterfaceManager().sendSub(Sub.ABOVE_CHATBOX, 371); getStage().loadAllUpTo(this); } @Override public boolean canTakeItem(GroundItem item) { if (item != null && item.isPrivate() && item.getVisibleToId() == player.getUuid()) return true; return false; } @Override public boolean canTrade() { return false; } @Override public boolean login() { start(); sendInterfaces(); return false; } @Override public void forceClose() { player.getInterfaceManager().removeSub(Sub.ABOVE_CHATBOX); player.getInterfaceManager().closeReplacedRealChatBoxInterface(); } @Override public boolean logout() { return false; } public Stage getStage() { return stage; } public void setStage(Stage stage) { this.stage = stage; } public void nextStage(Stage next) { Stage previous = Stage.values()[next.ordinal()-1]; if (getStage() == previous) { setStage(next); next.start(this); } } public void sendProgress() { float percent = (float) getStage().ordinal() / (float) Stage.values().length; player.getVars().setVar(406, Math.round(percent * 21.0f)); } public NPC getNPC(int id) { for (int chunkId : World.mapRegionIdsToChunks(TUTORIAL_REGIONS, 0)) { Chunk r = ChunkManager.getChunk(chunkId, true); if (r == null || r.getNPCsIndexes() == null) continue; for (int npcIdx : r.getNPCsIndexes()) { NPC npc = World.getNPCs().get(npcIdx); if (npc == null || npc.getId() != id) continue; return npc; } } return null; } @Override public boolean processTeleport(Teleport tele) { if (tele.type() != TeleType.OBJECT) return false; return true; } public void removeHint() { player.getHintIconsManager().removeUnsavedHintIcon(); } public void hintLocation(int x, int y, int height) { player.getHintIconsManager().addHintIcon(x, y, 0, height, 10, 0, -1, false); } public void hintNPC(int npcId) { NPC npc = getNPC(npcId); if (npc != null && !npc.isDead()) player.getHintIconsManager().addHintIcon(npc, 0, -1, false); } public boolean inSection(Stage min, Stage max) { return getStage().ordinal() >= min.ordinal() && getStage().ordinal() < max.ordinal(); } public boolean pastStage(Stage stage) { return getStage().ordinal() >= stage.ordinal(); } public void sendText(String... text) { sendText(false, text); } public void sendText(boolean temp, String... text) { player.getInterfaceManager().replaceRealChatBoxInterface(372); player.getPackets().setIFHidden(371, 4, true); for (int i = 0; i < 7; i++) if (i < text.length) player.getPackets().setIFText(372, i, text[i]); else player.getPackets().setIFText(372, i, """"); if (!temp) prevText = text; else player.setCloseInterfacesEvent(() -> sendText(prevText)); } }" "package com.rs.game.content.utils object BartenderUtils { fun buyDrinkOrIngredients(p: Player, npc: NPC, price: Int, item: Item, playerNoCoinsMessage: Boolean) { val hasCoins = p.inventory.hasCoins(price) val hasSlots = p.inventory.hasFreeSlots() if (!hasCoins) { p.startConversation { if (playerNoCoinsMessage) player(HeadE.SAD, ""Oh dear. I don't seem to have enough money."") else npc(npc, HeadE.FRUSTRATED, ""I said 20 coins! You haven't got 20 coins!"") } } else if (!hasSlots) { p.startConversation { npc(npc, HeadE.SHAKING_HEAD, ""You don't have space for ${Utils.addArticle(item.name.lowercase())}!"") } } else { p.inventory.removeCoins(price) p.inventory.addItem(Item(item)) p.startConversation { npc(npc, HeadE.HAPPY_TALKING, ""There you go."") player(HeadE.HAPPY_TALKING, ""Thanks, ${npc.name}!"") } } } fun buyBarcrawlDrink(p: Player, bar: Bars) { if (p.inventory.hasCoins(bar.price)) { p.lock() p.schedule { bar.effect.message(p, start = true) wait(2) bar.effect.effect(p) wait(4) bar.effect.message(p, start = false) } } else { p.startConversation { player(HeadE.SAD, ""I don't have that much money on me."") } } } fun sellBeerGlass(p: Player, npc: NPC) { p.startConversation { player(HeadE.CONFUSED, ""I've got this beer glass..."") npc(npc, HeadE.HAPPY_TALKING, ""We'll buy it for a couple of coins if you're interested."") options { op(""Okay, sure."") { player(HeadE.HAPPY_TALKING, ""Okay, sure."") exec { p.inventory.removeItems(Item(1919, 1)) p.inventory.addItem(995, 2) } npc(npc.id, HeadE.HAPPY_TALKING, ""There you go."") player(HeadE.HAPPY_TALKING, ""Thanks!"") } op(""No thanks, I like empty beer glasses."") { player(HeadE.SHAKING_HEAD, ""No thanks, I like empty beer glasses."") } } } } }" "package com.rs.game.content.utils fun Player.canSpeakWithGhosts(): Boolean { if (setOf(552, 4250, 20064, 20065, 20066, 20067).contains(equipment.neckId)) return true return SetReward.MORYTANIA_LEGS.hasRequirements(this, AchievementDef.Area.MORYTANIA, AchievementDef.Difficulty.HARD, false) }" "package com.rs.game.content.world; public class AgilityShortcuts { public static void climbOver(Player player, Tile toTile) { climbOver(player, toTile, 839); } public static void climbOver(Player player, Tile toTile, int animId) { player.forceMove(toTile, animId, 33, AnimationDefinitions.getDefs(animId).getEmoteTime() / 20 - 5); } public static void sidestep(final Player player, Tile toTile) { player.lock(); WorldTasks.schedule(1, () -> player.forceMove(toTile, 3844, 0, 120)); } public static void crawlUnder(final Player player, Tile toTile) { player.lock(); WorldTasks.schedule(1, () -> player.forceMove(toTile, 2589, 35, 130)); WorldTasks.schedule(4, () -> player.anim(2591)); } public static void walkLog(final Player player, Tile toTile, int delay) { final boolean running = player.getRun(); player.setRunHidden(false); player.lock(delay); player.addWalkSteps(toTile.getX(), toTile.getY(), -1, false); player.sendMessage(""You walk carefully across the slippery log..."", true); WorldTasks.scheduleLooping(new Task() { boolean secondloop; @Override public void run() { if (!secondloop) { secondloop = true; player.getAppearance().setBAS(155); } else { player.getAppearance().setBAS(-1); player.setRunHidden(running); player.getSkills().addXp(Skills.AGILITY, 7.5); player.sendMessage(""... and make it safely to the other side."", true); stop(); } } }, 0, delay); } }" "// This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see . // // Copyright © 2021 Trenton Kress // This file is part of project: Darkan // package com.rs.game.content.world; @PluginEventHandler public class Cow extends NPC { public Cow(int id, Tile tile) { super(id, tile); } @Override public void processNPC() { if (Utils.random(100) == 0) forceTalk(""Moo""); super.processNPC(); } public static ItemOnNPCHandler itemOnCow = new ItemOnNPCHandler(new Object[] { ""Cow"" }, e -> e.getPlayer().sendMessage(""The cow doesn't want that."")); public static NPCInstanceHandler toFunc = new NPCInstanceHandler(new Object[] { ""Cow"" }, Cow::new); public static NPCDeathHandler count = new NPCDeathHandler(new Object[] { ""Cow"" }, e -> World.getData().getAttribs().incI(""cowTrackerKills"")); public static ObjectClickHandler signpost = new ObjectClickHandler(new Object[] { 31297 }, e -> e.getPlayer().sendMessage(""So far, "" + World.getData().getAttribs().getI(""cowTrackerKills"") + "" cows have been killed by adventurers."")); }" "package com.rs.game.content.world; @PluginEventHandler public class DepositChests { public static ObjectClickHandler handleDepositChests = new ObjectClickHandler(new Object[] { ""Deposit chest"" }, e -> { if (e.getOption().equals(""Deposit"")) e.getPlayer().getBank().openDepositBox(); }); }" "package com.rs.game.content.world; @PluginEventHandler public class Duck extends NPC { public Duck(int id, Tile tile) { super(id, tile); } @Override public void processNPC() { super.processNPC(); if (Utils.random(50) == 0) forceTalk(""Quack!""); } public static NPCInstanceHandler toFunc = new NPCInstanceHandler(new Object[] { ""Duck"", ""Drake"" }, Duck::new); }" "package com.rs.game.content.world @ServerStartupEvent fun mapFurnaces() { onObjectClick(""Furnace"", ""Small furnace"", ""Clay forge"", ""Lava Furnace"") { e -> use(e.player, e.getObject()) } } fun use(player: Player, furnace: GameObject?) { if (player.inventory.containsItems(Item(MoltenGlassMaking.SODA_ASH), Item(MoltenGlassMaking.BUCKET_OF_SAND))) { MoltenGlassMaking.openDialogue(player) return } player.startConversation(SmeltingD(player, furnace)) }" "package com.rs.game.content.world; @PluginEventHandler public class GeneralStore { public static NPCClickHandler handleEdgevilleGeneralStore = new NPCClickHandler(new Object[] { 528, 529 }, new String[] { ""Talk-to"", ""Trade"" }, (e) -> { switch (e.getOption()) { case ""Talk-to"" -> talkTo(e.getPlayer(), e.getNPC(), ""edgeville_general_store""); case ""Trade"" -> ShopsHandler.openShop(e.getPlayer(), ""edgeville_general_store""); } }); public static NPCClickHandler handleVarrockGeneralStore = new NPCClickHandler(new Object[] { 522, 523 }, new String[] { ""Talk-to"", ""Trade"" }, (e) -> { switch (e.getOption()) { case ""Talk-to"" -> talkTo(e.getPlayer(), e.getNPC(), ""varrock_general_store""); case ""Trade"" -> ShopsHandler.openShop(e.getPlayer(), ""varrock_general_store""); } }); public static NPCClickHandler handleLumbridgeGeneralStore = new NPCClickHandler(new Object[] { 520, 521 }, new String[] { ""Talk-to"", ""Trade"" }, (e) -> { switch(e.getOption()) { case ""Talk-to"" -> talkTo(e.getPlayer(), e.getNPC(), ""lumbridge_general_store""); case ""Trade"" -> ShopsHandler.openShop(e.getPlayer(), ""lumbridge_general_store""); } }); private static void talkTo(Player player, NPC npc, String shopName) { player.startConversation(new Dialogue() .addNPC(npc, HeadE.CONFUSED, ""Can I help you at all?"") .addOptions(ops -> { ops.add(""Yes, please. What are you selling?"", () -> ShopsHandler.openShop(player, shopName)); ops.add(""How should I use your shop?"") .addNPC(npc, HeadE.CHEERFUL, ""I'm glad you ask! You can buy as many of the items stocked as you wish. The price of these items changes based on the amount in stock."") .addNPC(npc, HeadE.CHEERFUL, ""You can also sell most items to the shop and the price given will be based on the amount in stock.""); ops.add(""No, thanks.""); })); } }" "package com.rs.game.content.world; @PluginEventHandler public class GraveStoneSelection { public static void openSelectionInterface(Player player) { player.getInterfaceManager().sendInterface(652); player.getPackets().setIFRightClickOps(652, 31, 0, 78, 0, 1); player.getPackets().setIFRightClickOps(652, 34, 0, 13, 0, 1); player.getVars().setVar(1146, player.getGraveStone() | 262112); } public static ButtonClickHandler handleSelectionInterface = new ButtonClickHandler(652, e -> { if (e.getComponentId() == 31) e.getPlayer().getTempAttribs().setI(""graveSelection"", e.getSlotId()); else if (e.getComponentId() == 34) confirmSelection(e.getPlayer()); }); private static String getStoneName(int slot) { return EnumDefinitions.getEnum(1099).getStringValue(slot); } private static int getStonePrice(int slot) { return EnumDefinitions.getEnum(1101).getIntValue(slot); } public static void confirmSelection(Player player) { int slot = player.getTempAttribs().getI(""graveSelection"", -1) / 6; int price = getStonePrice(slot); String name = getStoneName(slot); if (slot != -1) { if (player.getGraveStone() == slot) { player.sendMessage(""You already have this gravestone selected.""); return; } if (!player.getInventory().hasCoins(price)) { player.sendMessage(""You need "" + Utils.formatNumber(price) + "" coins to purchase "" + Utils.addArticle(name) + "".""); return; } player.getTempAttribs().removeI(""graveSelection""); player.getInventory().removeCoins(price); player.setGraveStone(slot); player.closeInterfaces(); } } }" "// This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see . // // Copyright © 2021 Trenton Kress // This file is part of project: Darkan // package com.rs.game.content.world; @PluginEventHandler public class GuardBypasses { static { PlayerStepEvent.registerMethod(PlayerStepEvent.class, createDoubleGuardBypass(Tile.of(3146, 3336, 0), Tile.of(3145, 3336, 0), Tile.of(3147, 3336, 0), 85, 24)); //Draynor Manor East PlayerStepEvent.registerMethod(PlayerStepEvent.class, createDoubleGuardBypass(Tile.of(3069, 3276, 0), Tile.of(3070, 3275, 0), Tile.of(3070, 3277, 0), 85, 24)); //Draynor West PlayerStepEvent.registerMethod(PlayerStepEvent.class, createDoubleGuardBypass(Tile.of(3077, 3333, 0), Tile.of(3076, 3333, 0), Tile.of(3078, 3333, 0), 85, 24)); //Draynor Manor West PlayerStepEvent.registerMethod(PlayerStepEvent.class, createDoubleGuardBypass(Tile.of(3108, 3420, 0), Tile.of(3109, 3419, 0), Tile.of(3109, 3421, 0), 88, 87)); //Varrock to Barb Village PlayerStepEvent.registerMethod(PlayerStepEvent.class, createDoubleGuardBypass(Tile.of(3138, 3467, 0), Tile.of(3137, 3467, 0), Tile.of(3139, 3467, 0), 85, 24)); //GE to Edgeville PlayerStepEvent.registerMethod(PlayerStepEvent.class, createDoubleGuardBypass(Tile.of(3260, 3173, 0), Tile.of(3261, 3172, 0), Tile.of(3261, 3174, 0), 88, 87)); //Lumbridge swamp to Al Kharid PlayerStepEvent.registerMethod(PlayerStepEvent.class, createDoubleGuardBypass(Tile.of(3283, 3329, 0), Tile.of(3282, 3330, 0), Tile.of(3284, 3330, 0), 88, 87)); //Al Kharid to Varrock PlayerStepEvent.registerMethod(PlayerStepEvent.class, createDoubleGuardBypass(Tile.of(3292, 3385, 0), Tile.of(3291, 3385, 0), Tile.of(3293, 3385, 0), 4640, 4636)); //Varrock East to Wall } public static PlayerStepHandler createDoubleGuardBypass(Tile bottomLeftTile, Tile guard1, Tile guard2, int openAnim, int closeAnim) { return new PlayerStepHandler(new Tile[] { bottomLeftTile, bottomLeftTile.transform(0, 1), bottomLeftTile.transform(1, 0), bottomLeftTile.transform(1, 1) }, e -> { e.getStep().setCheckClip(false); e.getPlayer().setRunHidden(false); World.sendObjectAnimation(World.getObject(guard1, ObjectType.SCENERY_INTERACT), new Animation(openAnim)); World.sendObjectAnimation(World.getObject(guard2, ObjectType.SCENERY_INTERACT), new Animation(openAnim)); WorldTasks.delay(3, () -> { e.getPlayer().setRunHidden(true); World.sendObjectAnimation(World.getObject(guard1, ObjectType.SCENERY_INTERACT), new Animation(closeAnim)); World.sendObjectAnimation(World.getObject(guard2, ObjectType.SCENERY_INTERACT), new Animation(closeAnim)); }); }); } public static PlayerStepHandler gatesToExamCentreStep = new PlayerStepHandler(new Tile[] { Tile.of(3311, 3331, 0), Tile.of(3311, 3332, 0), Tile.of(3312, 3331, 0), Tile.of(3312, 3332, 0) }, e -> { GameObject gate1 = World.getObjectWithId(Tile.of(3312, 3331, 0), 45856); GameObject gate2 = World.getObjectWithId(Tile.of(3312, 3332, 0), 45857); if (gate1 != null && gate2 != null) { World.spawnObjectTemporary(new GameObject(gate1, 83), 3, true); World.spawnObjectTemporary(new GameObject(gate2, 83), 3, true); World.spawnObjectTemporary(new GameObject(DoorPair.getOpposingDoor(e.getPlayer(), gate1), gate1.getType(), gate1.getRotation(-1), gate1.getTile().transform(-1, 0, 0)), 3, true); World.spawnObjectTemporary(new GameObject(DoorPair.getOpposingDoor(e.getPlayer(), gate2), gate2.getType(), gate2.getRotation(1), gate2.getTile().transform(-1, 0, 0)), 3, true); } e.getStep().setCheckClip(false); e.getPlayer().setRunHidden(false); World.sendObjectAnimation(World.getObject(Tile.of(3311, 3332, 0), ObjectType.SCENERY_INTERACT), new Animation(4640)); World.sendObjectAnimation(World.getObject(Tile.of(3311, 3330, 0), ObjectType.SCENERY_INTERACT), new Animation(4640)); WorldTasks.delay(3, () -> { e.getPlayer().setRunHidden(true); World.sendObjectAnimation(World.getObject(Tile.of(3311, 3332, 0), ObjectType.SCENERY_INTERACT), new Animation(4636)); World.sendObjectAnimation(World.getObject(Tile.of(3311, 3330, 0), ObjectType.SCENERY_INTERACT), new Animation(4636)); }); }); public static PlayerStepHandler varrockEastGates = new PlayerStepHandler(new Tile[] { Tile.of(3273, 3428, 0), Tile.of(3273, 3429, 0), Tile.of(3274, 3428, 0), Tile.of(3274, 3429, 0) }, e -> { GameObject gate1 = World.getObjectWithId(Tile.of(3273, 3429, 0), 45853); GameObject gate2 = World.getObjectWithId(Tile.of(3273, 3428, 0), 45855); if (gate1 != null && gate2 != null) { World.spawnObjectTemporary(new GameObject(gate1, 83), 3, true); World.spawnObjectTemporary(new GameObject(gate2, 83), 3, true); World.spawnObjectTemporary(new GameObject(gate1.getId(), gate1.getType(), gate1.getRotation(-1), gate1.getTile().transform(1, 0, 0)), 3, true); World.spawnObjectTemporary(new GameObject(gate2.getId(), gate2.getType(), gate2.getRotation(1), gate2.getTile().transform(1, 0, 0)), 3, true); } e.getStep().setCheckClip(false); e.getPlayer().setRunHidden(false); WorldTasks.delay(3, () -> e.getPlayer().setRunHidden(true)); }); public static PlayerStepHandler varrockNorthDoor = new PlayerStepHandler(new Tile[] { Tile.of(3245, 3501, 0), Tile.of(3245, 3502, 0) }, e -> { GameObject door = World.getObjectWithId(Tile.of(3245, 3501, 0), 45853); if (door != null) { World.spawnObjectTemporary(new GameObject(door, 83), 3, true); World.spawnObjectTemporary(new GameObject(door.getId(), door.getType(), door.getRotation(-1), door.getTile().transform(0, 1, 0)), 3, true); } e.getStep().setCheckClip(false); e.getPlayer().setRunHidden(false); WorldTasks.delay(3, () -> e.getPlayer().setRunHidden(true)); }); public static PlayerStepHandler daemonheimWildyEntrance = new PlayerStepHandler(new Tile[] { Tile.of(3384, 3615, 0), Tile.of(3385, 3615, 0) }, e -> { e.getStep().setCheckClip(false); e.getPlayer().setRunHidden(false); if (e.getStep().x <= 3384 && e.getStep().dir == Direction.WEST) { e.getPlayer().getControllerManager().forceStop(); e.getPlayer().getControllerManager().startController(new WildernessController()); } else if (e.getStep().x > 3384 && e.getStep().dir == Direction.EAST) { e.getPlayer().getControllerManager().forceStop(); e.getPlayer().getControllerManager().startController(new DamonheimController()); } World.sendObjectAnimation(World.getObject(Tile.of(3385, 3614, 0), ObjectType.SCENERY_INTERACT), new Animation(1366)); WorldTasks.delay(3, () -> { e.getPlayer().setRunHidden(true); World.sendObjectAnimation(World.getObject(Tile.of(3385, 3614, 0), ObjectType.SCENERY_INTERACT), new Animation(1365)); }); }); public static ObjectClickHandler uselessDoors = new ObjectClickHandler(new Object[] { 45854, 45856, 45857, 45858, 45859 }, e -> { }); public static ObjectClickHandler handleNorthAndEastVarrockGates = new ObjectClickHandler(new Object[] { 45853, 45855 }, e -> { GameObject gate1 = World.getObjectWithId(Tile.of(3273, 3429, 0), 45853); GameObject gate2 = World.getObjectWithId(Tile.of(3273, 3428, 0), 45855); if (gate1 != null && gate2 != null) { World.spawnObjectTemporary(new GameObject(gate1, 83), 3, true); World.spawnObjectTemporary(new GameObject(gate2, 83), 3, true); World.spawnObjectTemporary(new GameObject(gate1.getId(), gate1.getType(), gate1.getRotation(-1), gate1.getTile().transform(1, 0, 0)), 3, true); World.spawnObjectTemporary(new GameObject(gate2.getId(), gate2.getType(), gate2.getRotation(1), gate2.getTile().transform(1, 0, 0)), 3, true); } e.getPlayer().lock(2); if(e.getObject().getRotation() == 2) //East e.getPlayer().addWalkSteps(e.getPlayer().getX() > e.getObject().getX() ? e.getObject().getTile().transform(-1, 0) : e.getObject().getTile().transform(1, 0), 3, false); if(e.getObject().getRotation() == 1) //North e.getPlayer().addWalkSteps(e.getPlayer().getY() > e.getObject().getY() ? e.getObject().getTile().transform(0, -1) : e.getObject().getTile().transform(0, 1), 3, false); }); }" "package com.rs.game.content.world; @PluginEventHandler public class Ladders { public static ObjectClickHandler world6400Up = new ObjectClickHandler(new Object[] { 29355 }, e -> e.getPlayer().useStairs(828, e.getPlayer().transform(0, -6400), 1, 2)); }" "package com.rs.game.content.world; @PluginEventHandler public class LightSource { private static final int[][] LIGHT_SOURCES = { { 596, 36, 38, 4529, 4522, 4537, 7051, 4548, 5014, 4701 }, { 594, 33, 32, 4534, 4524, 4539, 7053, 4550, 5013, 4702 } }; public static ItemOnItemHandler lightTinder = new ItemOnItemHandler(LIGHT_SOURCES[0], new int[] { 590 }, e -> lightSource(e.getPlayer(), e.getUsedWith(590).getSlot())); public static ItemClickHandler handleExtinguish = new ItemClickHandler(new Object[] { LIGHT_SOURCES[1] }, new String[] { ""Extinguish"" }, e -> extinguishSource(e.getPlayer(), e.getSlotId(), false)); public static boolean hasExplosiveSource(Player player) { for (Item item : player.getInventory().getItems().array()) { if (item == null) continue; int slot = getSlot(item.getId(), false); if (slot != -1 && (slot == 0 || slot == 1)) return true; } return false; } public static boolean hasPermenantSource(Player player) { if (player.getInventory().containsOneItem(14631, 14662, 14663, 19763) || player.getEquipment().containsOneItem(14631, 14662, 14663, 19763)) return true; for (Item item : player.getInventory().getItems().array()) { if (item == null) continue; int slot = getSlot(item.getId(), false); if (slot != -1 && slot != 0 && slot != 1) return true; } return false; } public static boolean hasLightSource(Player player) { return hasExplosiveSource(player) || hasPermenantSource(player); } private static int getSlot(int itemId, boolean extinguished) { for (int slot = 0; slot < LIGHT_SOURCES[0].length; slot++) { int id = LIGHT_SOURCES[extinguished ? 0 : 1][slot]; if (id == itemId) return slot; } return -1; } public static boolean extinguishSource(Player player, int itemSlot, boolean forceExtinguish) { Item item = player.getInventory().getItem(itemSlot); if (item == null) return false; int slot = getSlot(item.getId(), false); if (slot == -1) return false; if (!forceExtinguish && player.getControllerManager().getController() != null && player.getControllerManager().getController() instanceof UndergroundDungeonController) { player.sendMessage(""You cannot extinguish the "" + item.getName().toLowerCase() + "" as you will not have a light source.""); return false; } player.getInventory().replaceItem(LIGHT_SOURCES[0][slot], item.getAmount(), itemSlot); player.sendMessage(""You extinguish the "" + item.getName().toLowerCase() + "".""); return true; } public static boolean lightSource(Player player, int itemSlot) { Item item = player.getInventory().getItem(itemSlot); if (item == null) return false; int slot = getSlot(item.getId(), true); if (slot == -1) return false; if (!player.getInventory().containsItem(590, 1)) { player.sendMessage(""You need a tinderbox in order to light the "" + item.getName().toLowerCase() + "".""); return false; } player.getInventory().replaceItem(LIGHT_SOURCES[1][slot], item.getAmount(), itemSlot); player.sendMessage(""You light the "" + item.getName().toLowerCase() + "".""); return true; } }" "package com.rs.game.content.world; @PluginEventHandler public class LoyaltyShop { public static LoginHandler sendLoyaltyPoints = new LoginHandler(e -> e.getPlayer().getVars().setVar(2225, e.getPlayer().loyaltyPoints)); public static void refresh(Player player) { player.getVars().setVar(2225, player.loyaltyPoints); player.getPackets().sendVarc(1648, player.loyaltyPoints); refreshOwned(player); refreshFavorite(player); for (Tab tab : Tab.values()) { EnumDefinitions map = EnumDefinitions.getEnum(tab.getCSMapId(player.getAppearance().isMale())); player.getPackets().setIFRightClickOps(1143, tab.getBuyComponent(), 0, map.getSize(), 0, 1); player.getPackets().setIFRightClickOps(1143, tab.getFavoriteComponent(), 0, map.getSize(), 0, 1); } player.getPackets().setIFRightClickOps(1143, 40, 0, 4, 0, 1); //costume color select } public static void open(Player player) { player.getInterfaceManager().setFullscreenInterface(317, 1143); refresh(player); } public static ButtonClickHandler handleButtons = new ButtonClickHandler(1143, e -> { switch (e.getComponentId()) { case 103: e.getPlayer().closeInterfaces(); break; case 1: e.getPlayer().getVars().setVarBit(9487, -1); break; case 13: e.getPlayer().getVars().setVarBit(9487, 6); break; case 3: e.getPlayer().getVars().setVarBit(9487, 8); break; case 50: confirmBuy(e.getPlayer()); break; case 40: e.getPlayer().getTempAttribs().setI(""LoyaltyRewardColor"", e.getSlotId()); break; case 59: case 51: case 163: closeMessage(e.getPlayer()); break; } if (e.getComponentId() >= 7 && e.getComponentId() <= 12) { Tab tab = Tab.values()[e.getComponentId() - 7]; if (tab != null && (e.getPlayer().hasRights(Rights.DEVELOPER) || (tab != Tab.RECOLOR))) e.getPlayer().getVars().setVarBit(9487, tab.configId); else sendMessage(e.getPlayer(), ""Tab not added"", ""That tab hasn't been added yet. Sorry.""); return; } Tab tab = Tab.forId(e.getComponentId()); if (tab != null && tab.isBuyComponent(e.getComponentId())) { EnumDefinitions map = EnumDefinitions.getEnum(tab.getCSMapId(e.getPlayer().getAppearance().isMale())); Reward reward = tab.getReward(e.getSlotId()); if (reward != null) { e.getPlayer().getTempAttribs().setO(""LoyaltyReward"", reward); e.getPlayer().getPackets().sendRunScriptReverse(5355, e.getPlayer().unlockedLoyaltyReward(reward) ? 1 : 0, map.getIntValue(e.getSlotId())); e.getPlayer().getPackets().setIFHidden(1143, 16, false); e.getPlayer().getPackets().setIFHidden(1143, 56, false); e.getPlayer().getPackets().setIFHidden(1143, 58, true); } else e.getPlayer().getTempAttribs().removeO(""LoyaltyReward""); } else if (tab != null && tab.isFavoriteComponent(e.getComponentId())) { Reward reward = tab.getReward(e.getSlotId()); if (reward != null) { if (e.getPlayer().favoritedLoyaltyReward(reward)) e.getPlayer().unfavoriteLoyaltyReward(reward); else e.getPlayer().favoriteLoyaltyReward(reward); refreshFavorite(e.getPlayer()); } } refresh(e.getPlayer()); if (e.getPlayer().hasRights(Rights.DEVELOPER)) e.getPlayer().getPackets().sendDevConsoleMessage(""Loyalty click: "" + e.getComponentId() + "", "" + e.getSlotId() + "", "" + e.getSlotId2()); }); public static void confirmBuy(Player player) { Reward reward = player.getTempAttribs().getO(""LoyaltyReward""); if (reward != null) { if (reward.getPreReq() <= 0 || player.unlockedLoyaltyReward(Reward.forId(reward.getPreReq()))) { if (player.unlockedLoyaltyReward(reward)) { giveReward(player, reward); closeMessage(player); sendMessage(player, ""Success!"", ""You have reclaimed your "" + reward.getItem().getName() + ""! It has been sent to your bank.""); } else if (player.loyaltyPoints >= reward.getPrice()) { player.unlockLoyaltyReward(reward); player.loyaltyPoints -= reward.getPrice(); giveReward(player, reward); closeMessage(player); sendMessage(player, ""Success!"", ""You have unlocked "" + (reward.getType() == Type.EMOTE ? "" the emote "" + reward.name().toLowerCase().replace(""_"", "" "") + ""."" : reward.getItem().getName() + ""! It has been sent to your bank."")); } else sendMessage(player, ""Not Enough Points"", ""You need "" + reward.getPrice() + "" loyalty points to purchase this.""); } else sendMessage(player, ""Previous Reward Required"", ""You need to buy "" + ItemDefinitions.getDefs(reward.getPreReq()).name + "" before purchasing this.""); refresh(player); } } private static void deletePreItems(Player player, Reward reward) { Reward curr = Reward.forId(reward.getPreReq()); while(curr != null) { if (player.getBank().containsItem(curr.getItem().getId(), 1)) player.getBank().removeItem(curr.getItem().getId()); if (player.getInventory().containsItem(curr.getItem().getId(), 1)) player.getInventory().deleteItem(curr.getItem().getId(), Integer.MAX_VALUE); curr = Reward.forId(curr.getPreReq()); } } private static Reward getHighestTierUnlocked(Player player, Reward reward) { Reward highest = reward.getLowestTier(); while(player.unlockedLoyaltyReward(Reward.forPreReq(highest.getItem().getId()))) highest = Reward.forPreReq(highest.getItem().getId()); return highest; } private static void giveReward(Player player, Reward reward) { switch(reward.getType()) { case AURA: reward = getHighestTierUnlocked(player, reward); deletePreItems(player, reward); player.getBank().addItem(reward.getItem(), true); break; case EFFECT: player.getBank().addItem(reward.getItem(), true); break; case COSTUME: int color = 0; Object colObj = player.getTempAttribs().removeI(""LoyaltyRewardColor""); if (colObj != null && colObj instanceof Integer) color = (int) colObj; for (Item item : reward.getItems(player.getAppearance().isMale() ? 0 : 1)) if (item.getAmount() == 1) player.getBank().addItem(item, true); else if (item.getAmount() == 2) player.getBank().addItem(new Item(item.getId() + (color*2), 1), true); break; case TITLE: player.setTitle(null); player.setTitleColor(null); player.setTitleShading(null); player.getAppearance().setTitle(reward.getItem().getId()); player.getAppearance().generateAppearanceData(); break; case EMOTE: for (Emote emote : Emote.values()) if (emote.name().equals(reward.name())) { player.getEmotesManager().unlockEmote(emote); break; } break; default: break; } } /* * player.getPackets().sendHideIComponent(interfaceId, 56, false); * https://i.imgur.com/wnU2rJr.png * * player.getPackets().sendHideIComponent(interfaceId, 57, false); * https://i.imgur.com/50Rt2Rg.png * * player.getPackets().sendHideIComponent(interfaceId, 58, false); * https://i.imgur.com/pqeRgOA.png */ public static void closeMessage(Player player) { player.getPackets().setIFHidden(1143, 16, true); } public static void sendMessage(Player player, String title, String message) { player.getPackets().setIFHidden(1143, 16, false); player.getPackets().setIFHidden(1143, 56, true); //player.getPackets().sendHideIComponent(1143, 57, false); player.getPackets().setIFHidden(1143, 58, false); player.getPackets().setIFText(1143, 161, title); player.getPackets().setIFText(1143, 162, message); } public static int[] getFavoriteFlags(Player player, Tab tab) { if (tab == Tab.AURAS) { int val1 = 0; int val2 = 0; int val3 = 0; for (int i = 0;i < Tab.AURAS.getRewards().length;i++) if (i <= 31 && player.favoritedLoyaltyReward(Tab.AURAS.getRewards()[i])) val1 += (1 << i); else if (i <= 62 && player.favoritedLoyaltyReward(Tab.AURAS.getRewards()[i])) val2 += (1 << (i-31)); else if (player.favoritedLoyaltyReward(Tab.AURAS.getRewards()[i])) val3 += (1 << (i-62)); return new int[] { val1, val2, val3 }; } if (tab != Tab.TITLES) { int val = 0; for (Reward r : tab.getRewards()) if (player.favoritedLoyaltyReward(r)) val += (1 << r.getBit()); return new int[] { val }; } int val1 = 0; int val2 = 0; for (int i = 0;i < Tab.TITLES.getRewards().length;i++) if (i < 16 && player.favoritedLoyaltyReward(Tab.TITLES.getRewards()[i])) val1 += (1 << i); else if (player.favoritedLoyaltyReward(Tab.TITLES.getRewards()[i])) val2 += (1 << (i-16)); return new int[] { val1, val2 }; } public static int[] getUnlockedFlags(Player player, Tab tab) { if (tab == Tab.AURAS) { int val1 = 0; int val2 = 0; int val3 = 0; for (int i = 0;i < Tab.AURAS.getRewards().length;i++) if (i <= 31 && player.unlockedLoyaltyReward(Tab.AURAS.getRewards()[i])) val1 += (1 << i); else if (i <= 62 && player.unlockedLoyaltyReward(Tab.AURAS.getRewards()[i])) val2 += (1 << (i-31)); else if (player.unlockedLoyaltyReward(Tab.AURAS.getRewards()[i])) val3 += (1 << (i-62)); return new int[] { val1, val2, val3 }; } if (tab != Tab.TITLES) { int val = 0; for (Reward r : tab.getRewards()) if (player.unlockedLoyaltyReward(r)) val += (1 << r.getBit()); return new int[] { val }; } int val1 = 0; int val2 = 0; for (int i = 0;i < Tab.TITLES.getRewards().length;i++) if (i < 16 && player.unlockedLoyaltyReward(Tab.TITLES.getRewards()[i])) val1 += (1 << i); else if (player.unlockedLoyaltyReward(Tab.TITLES.getRewards()[i])) val2 += (1 << (i-16)); return new int[] { val1, val2 }; } public static void refreshFavorite(Player player) { int[] auras = getFavoriteFlags(player, Tab.AURAS); player.getVars().setVar(2391, auras[0]); player.getVars().setVar(2444, auras[1]); player.getVars().setVar(2541, auras[2]); int[] titles = getFavoriteFlags(player, Tab.TITLES); player.getVars().setVar(2394, titles[0] + getFavoriteFlags(player, Tab.RECOLOR)[0]); player.getVars().setVar(2445, titles[1]); player.getVars().setVar(2542, getFavoriteFlags(player, Tab.EFFECTS)[0]); player.getVars().setVar(2392, getFavoriteFlags(player, Tab.EMOTES)[0]); player.getVars().setVar(2393, getFavoriteFlags(player, Tab.COSTUMES)[0]); player.getVars().setVar(2541, 0, true); //refresh } public static void refreshOwned(Player player) { int[] auras = getUnlockedFlags(player, Tab.AURAS); player.getVars().setVar(2229, auras[0]); player.getVars().setVar(2443, auras[1]); player.getVars().setVar(2539, auras[2]); int[] titles = getUnlockedFlags(player, Tab.TITLES); player.getVars().setVar(2232, titles[0] + getUnlockedFlags(player, Tab.RECOLOR)[0]); player.getVars().setVar(2447, titles[1]); player.getVars().setVar(2540, getUnlockedFlags(player, Tab.EFFECTS)[0]); player.getVars().setVar(2230, getUnlockedFlags(player, Tab.EMOTES)[0]); player.getVars().setVar(2231, getUnlockedFlags(player, Tab.COSTUMES)[0]); player.getVars().setVar(2541, 0, true); //refresh } }" "package com.rs.game.content.world val MUSICIANS = arrayOf(29, 30, 3463, 3509, 3611, 5442, 5439, 8698, 8699, 8700, 8701, 8702, 8703, 8704, 8705, 8706, 8707, 8708, 8709, 8712, 8713, 8715, 8716, 8717, 8718, 8719, 8720, 8721, 8722, 8723, 14628, 14629, 14640) fun isNearby(p: Player): Boolean { val nearbyNPCs = World.getNPCsInChunkRange(p.chunkId, 1) for (nearbyNPC in nearbyNPCs) { if (nearbyNPC == null) continue for (musicianId in MUSICIANS) if (nearbyNPC.id == musicianId && p.withinDistance(nearbyNPC.middleTile, 2)) return true } return false } @ServerStartupEvent fun mapPlugin() { onNpcClick(*MUSICIANS) { e -> when (e.option.lowercase()) { ""talk-to"" -> { e.npc.resetDirection() e.player.startConversation { options { op(""Who are you?"") { npc(e.npcId, HeadE.CALM_TALK, ""Me? I'm a musician! Let me help you relax: sit down, rest your weary limbs and allow me to wash away the troubles of the day. After a long trek, what could be better than some music to give you the energy to continue?"") npc(e.npcId, HeadE.CALM_TALK, ""Did you know music has curative properties? Music stimulates the healing humours in your body, so they say."") player(HeadE.CALM_TALK, ""Who says that, then?"") npc(e.npcId, HeadE.CALM_TALK, ""I was told by a travelling medical practitioner, selling oil extracted from snakes. It's a commonly known fact, so he said. After resting to some music, you will be able to run longer, and your life points will increase noticeably. A panacea, if you will. Ah, the power of music."") player(HeadE.CALM_TALK, ""So, just listening to some music will cure me of all my ills?"") npc(e.npcId, HeadE.CALM_TALK, ""Well, not quite. Poison, lack of faith, and dismembered limbs are all a bit beyond even the most rousing of harmonies, but I guarantee you will feel refreshed, and better equipped to take on the challenges of the day."") player(HeadE.CALM_TALK, ""Does this cost me anything?"") npc(e.npcId, HeadE.CALM_TALK, ""Oh, no! My reward is the pleasure I bring to the masses. Just remember me and tell your friends, and that is payment enough. So sit down and enjoy!"") } op(""Can I ask you some questions about resting?"") { options { op(""How does resting work?"") { npc(e.npcId, HeadE.CALM_TALK, ""Have you ever been on a long journey, and simply wanted to have a rest? When you’re running from city to city, it’s so easy to run out of breath, don’t you find?"") player(HeadE.CALM_TALK, ""Yes, I can never run as far as I’d like."") npc(e.npcId, HeadE.CALM_TALK, ""Well, you may rest anywhere, simply choose the Rest option on the run buttons. When you are nice and relaxed, you will recharge your run energy more quickly and your life points twice as fast as you would do so normally."") npc(e.npcId, HeadE.CALM_TALK, ""Of course, you can’t do anything else while you’re resting, other than talk."") player(HeadE.CALM_TALK, ""Why not?"") npc(e.npcId, HeadE.CALM_TALK, ""Well, you wouldn’t be resting, now would you? Also, you should know that resting by a musician, has a similar effect but the benefits are greater."") } op(""What's special about resting by a musician?"") { npc(e.npcId, HeadE.CALM_TALK, ""The effects of resting are enhanced by music. Your run energy will recharge many times the normal rate, and your life points three times as fast. Simply sit down and rest as you would normally, nice and close to the musician. "") npc(e.npcId, HeadE.CALM_TALK, ""You’ll turn to face the musician and hear the music. Like resting anywhere, if you do anything other than talk, you will stop resting."") } op(""Can you summarise the effects for me?"") { npc(e.npcId, HeadE.CALM_TALK, ""Certainly. You can rest anywhere, simply choose the Rest option on the run buttons. Resting anywhere will replenish your run energy more quickly than normal, your life points will replenish twice as fast as well! "") npc(e.npcId, HeadE.CALM_TALK, ""Resting by a musician will replenish your run energy many times faster than normal, and your life points will also replenish three times as fast."") } op(""That's all for now."") } } op(""Can I ask you some questions about running?"") { npc(e.npcId, HeadE.CALM_TALK, ""Running? Of course! Not that I do much running, I prefer to saunter. But you adventuring types always seem to be in a rush, zipping hither and thither."") player(HeadE.CALM_TALK, ""Why do I need to run anyway?"") npc(e.npcId, HeadE.CALM_TALK, ""Running is the simplest way to get somewhere quickly. When you run you move twice as fast as you normally would. Also, you don’t look like the cowardly type, but most creatures can’t run very fast, so if you don’t want to fight, you can always run away."") player(HeadE.CALM_TALK, ""Can I keep running forever?"") npc(e.npcId, HeadE.CALM_TALK, ""No, eventually you’ll get tired. When that happens you will stop running, and start walking. It takes a while to get your breath back, but once you’ve recovered it a little, you can start running again. You recover quickly whilst resting, or more slowly whilst walking."") npc(e.npcId, HeadE.CALM_TALK, ""You may start running by clicking once on the Run button, which is the running man icon at the top-right of the minimal. Clicking the Run button a second time will switch you back to walking. It tells you how much run energy you currently have."") } op(""That's all for now."") } } } ""listen-to"" -> { if (e.player.emotesManager.isAnimating) { e.player.sendMessage(""You can't rest while performing an emote."") return@onNpcClick } if (e.player.isLocked) { e.player.sendMessage(""You can't rest while performing an action."") return@onNpcClick } e.player.stopAll() e.npc.resetDirection() e.player.actionManager.setAction(RestMusician(e.npcId)) } } } }" "package com.rs.game.content.world @ServerStartupEvent fun mapPickables() { onObjectClick(""Flax"", ""Cabbage"", ""Potato"", ""Wheat"", ""Onion"", ""Pineapple Plant"") { (player, obj, option) -> if (option == ""Pick"") { when (obj.getDefinitions(player).name) { ""Flax"" -> pick(player, obj, 1779) ""Cabbage"" -> pick(player, obj, 1965) ""Potato"" -> pick(player, obj, 1942) ""Wheat"" -> pick(player, obj, 1947) ""Onion"" -> pick(player, obj, 1957) ""Pineapple Plant"" -> pick(player, obj, 2114) } } } onObjectClick(2073, 2074, 2075, 2076, 2077, 2078, 23625, 23626, 23627, 23628, 23629, 23630) { (player, obj) -> when(obj.id) { 2078 -> { player.sendMessage(""There are no bananas left on the tree."") return@onObjectClick } 23627, 23630 -> { player.sendMessage(""There are no berries left on the bush."") return@onObjectClick } 2073, 2074, 2075, 2076, 2077 -> player.inventory.addItem(1963, 1) 23625, 23626, -> player.inventory.addItem(753, 1) 23628, 23629, -> player.inventory.addItem(1951, 1) } player.anim(2280) obj.setId(obj.id + 1) obj.tasks.scheduleTimer(""regrow"", Ticks.fromSeconds(15), Ticks.fromSeconds(15)) { if (obj.id > obj.originalId) obj.setId(obj.id - 1) else return@scheduleTimer false return@scheduleTimer true } } } private fun pick(player: Player, obj: GameObject, itemId: Int) { if (obj.id == 1413) { player.sendMessage(""There aren't any pineapples left to pick."") return } if (player.inventory.addItem(itemId, 1)) { player.anim(827) player.lock(2) when (itemId) { 1799 -> if (Utils.random(5) == 0) World.removeObjectTemporary(obj, Ticks.fromMinutes(1)) 2114 -> if (Utils.random(5) == 0) obj.setIdTemporary(1413, Ticks.fromMinutes(1)) else -> World.removeObjectTemporary(obj, Ticks.fromMinutes(1)) } } }" "package com.rs.game.content.world; public class Rest extends PlayerAction { private static final int[][] REST_DEFS = { { 5713, 1549, 5748 }, { 11786, 1550, 11788 }, { 5713, 1551, 2921 } // TODO // First // emote }; private int index; @Override public boolean start(Player player) { if (!process(player)) return false; index = Utils.random(REST_DEFS.length); player.setResting(true); player.anim(REST_DEFS[index][0]); player.getAppearance().setBAS(REST_DEFS[index][1]); return true; } @Override public boolean process(Player player) { if (player.getPoison().isPoisoned()) { player.sendMessage(""You can't rest while you're poisoned.""); return false; } if (player.inCombat(10000) || player.hasBeenHit(10000)) { player.sendMessage(""You can't rest until 10 seconds after the end of combat.""); return false; } return true; } @Override public int processWithDelay(Player player) { return 0; } @Override public void stop(Player player) { player.setResting(false); player.anim(REST_DEFS[index][2]); player.getEmotesManager().setNextEmoteEnd(); player.getAppearance().setBAS(-1); } }" "package com.rs.game.content.world; public class RestMusician extends PlayerAction { private static final int[][] REST_DEFS = { { 5713, 1549, 5748 }, { 11786, 1550, 11788 }, { 5713, 1551, 2921 } // TODO // First // emote }; private final int musicId; private int index; public RestMusician(int musicianId) { //lute //lute //violin //lute //double flute //drunk //elven //drum //lute //violin //lyre //lute //violin //lyre //lyre //lute //lute //violin //lute //double flute //double flute //violin //violin //ghost Map musicListing = Map.ofEntries( Map.entry(5439, 661),//lute Map.entry(8705, 661),//lute Map.entry(8698, 657),//violin Map.entry(29, 661),//lute Map.entry(8709, 660),//double flute Map.entry(8715, 664),//drunk Map.entry(8723, 659),//elven Map.entry(8712, 665),//drum Map.entry(8702, 661),//lute Map.entry(8706, 657),//violin Map.entry(8716, 662),//lyre Map.entry(8703, 661), //lute Map.entry(8704, 657),//violin Map.entry(8717, 662),//lyre Map.entry(8718, 662),//lyre Map.entry(5442, 661),//lute Map.entry(30, 661),//lute Map.entry(8699, 657),//violin Map.entry(3463, 661),//lute Map.entry(8708, 660),//double flute Map.entry(8707, 660),//double flute Map.entry(8701, 657),//violin Map.entry(8700, 657),//violin Map.entry(8713, 656)//ghost ); musicId = musicListing.getOrDefault(musicianId, -1); } @Override public boolean start(Player player) { if (!process(player)) return false; index = Utils.random(REST_DEFS.length); player.setResting(true); player.anim(REST_DEFS[index][0]); player.getAppearance().setBAS(REST_DEFS[index][1]); return true; } @Override public boolean process(Player player) { if(musicId != -1 && !player.getMusicsManager().isPlaying(musicId)) player.musicTrack(musicId); if (player.getPoison().isPoisoned()) { player.sendMessage(""You can't rest while you're poisoned.""); return false; } if (player.inCombat(10000) || player.hasBeenHit(10000)) { player.sendMessage(""You can't rest until 10 seconds after the end of combat.""); return false; } return true; } @Override public int processWithDelay(Player player) { return 0; } @Override public void stop(Player player) { player.setResting(false); player.anim(REST_DEFS[index][2]); player.getEmotesManager().setNextEmoteEnd(); player.getAppearance().setBAS(-1); if(musicId != -1) player.getMusicsManager().nextAmbientSong(); } }" "package com.rs.game.content.world; @PluginEventHandler public class SheepShearing { public static ItemOnNPCHandler handleShearsOnSheep = new ItemOnNPCHandler(new Object[] { 5157, 1765, 43, 5160, 5161, 5156 }, e -> { final int npcId = e.getNPC().getId(); if (Utils.getRandomInclusive(2) == 0) { e.getNPC().forceTalk(""Baa!""); e.getNPC().soundEffect(e.getPlayer(), 756, true); e.getNPC().addWalkSteps(npcId, npcId, 4, true); e.getNPC().setRun(true); e.getPlayer().sendMessage(""The sheep runs away from you.""); } else if (e.getPlayer().getInventory().containsItem(1735, 1)) { e.getPlayer().soundEffect(761, true); e.getPlayer().getInventory().addItem(1737, 1); e.getPlayer().sendMessage(""You shear the sheep of it's fleece.""); e.getPlayer().anim(893); e.getNPC().transformIntoNPC(5149); WorldTasks.delay(Ticks.fromSeconds(10), () -> e.getNPC().transformIntoNPC(npcId)); } else e.getPlayer().sendMessage(""You need a pair of shears to shear the sheep.""); }); public static NPCClickHandler handleShearOption = new NPCClickHandler(new Object[] { 5157, 1765, 43, 5160, 5161, 5156 }, e -> { final int npcId = e.getNPC().getId(); if (Utils.getRandomInclusive(2) == 0) { e.getNPC().forceTalk(""Baa!""); e.getNPC().soundEffect(e.getPlayer(), 756, true); e.getNPC().addWalkSteps(npcId, npcId, 4, true); e.getNPC().setRun(true); e.getPlayer().sendMessage(""The sheep runs away from you.""); } else if (e.getPlayer().getInventory().containsItem(1735, 1)) { e.getPlayer().soundEffect(761, true); e.getPlayer().getInventory().addItem(1737, 1); e.getPlayer().sendMessage(""You shear the sheep of it's fleece.""); e.getPlayer().anim(893); e.getNPC().transformIntoNPC(5149); WorldTasks.delay(Ticks.fromSeconds(10), () -> e.getNPC().transformIntoNPC(npcId)); } else e.getPlayer().sendMessage(""You need a pair of shears to shear the sheep.""); }); }" "package com.rs.game.content.world; @PluginEventHandler public class TownCrier extends NPC { public TownCrier(int id, Tile tile) { super(id, tile); } @Override public void processNPC() { if (Settings.getConfig().getLoginMessage() != null && Utils.random(100) == 0) forceTalk(Settings.getConfig().getLoginMessage()); super.processNPC(); } public static NPCInstanceHandler toFunc = new NPCInstanceHandler(new Object[] { 6135, 6136, 6137, 6138, 6139 }, TownCrier::new); }" "package com.rs.game.content.world.areas.falador; @PluginEventHandler public class Falador { public static PlayerStepHandler musicArtisansWorkshop = new PlayerStepHandler(new Tile[] { Tile.of(3035, 3339, 0), Tile.of(3035, 3338, 0), Tile.of(3034, 3339, 0), Tile.of(3034, 3338, 0) }, e -> { if(e.getTile().getX() == 3035 && e.getStep().dir == Direction.EAST) { e.getPlayer().getMusicsManager().playSpecificAmbientSong(582, true); return; } if(e.getTile().getX() == 3034 && e.getPlayer().getMusicsManager().isPlaying(582)) e.getPlayer().getMusicsManager().nextAmbientSong(); }); public static PlayerStepHandler musicRisingSunInn = new PlayerStepHandler(new Tile[] { Tile.of(2956, 3378, 0), Tile.of(2956, 3379, 0), Tile.of(2961, 3372, 0), Tile.of(2962, 3372, 0) }, e -> { if(e.getTile().getY() == 3378 && e.getStep().dir == Direction.SOUTH) { e.getPlayer().getMusicsManager().playSpecificAmbientSong(718, true); return; } if(e.getTile().getX() == 2961 && e.getStep().dir == Direction.WEST) { e.getPlayer().getMusicsManager().playSpecificAmbientSong(718, true); return; } if((e.getTile().getY() == 3379 || e.getTile().getX() == 2961) && e.getPlayer().getMusicsManager().isPlaying(718)) e.getPlayer().getMusicsManager().nextAmbientSong(); }); public static ObjectClickHandler handleUnderwallTunnelShortcut = new ObjectClickHandler(new Object[] { 9309, 9310 }, e -> { if (!Agility.hasLevel(e.getPlayer(), 26)) return; AgilityShortcuts.crawlUnder(e.getPlayer(), e.getPlayer().transform(0, e.getObjectId() == 9310 ? -4 : 4, 0)); }); public static ObjectClickHandler handleFistOfGuthixEntrance = new ObjectClickHandler(new Object[] { 20608, 30203 }, e -> { if(e.getObjectId() == 20608) e.getPlayer().useStairs(-1, Tile.of(1677, 5598, 0), 1, 1); if(e.getObjectId() == 30203) e.getPlayer().useStairs(-1, Tile.of(2969, 9672, 0), 1, 1); }); public static ObjectClickHandler handleCrumblingWallShortcut = new ObjectClickHandler(new Object[] { 11844 }, e -> { if (!Agility.hasLevel(e.getPlayer(), 5)) return; AgilityShortcuts.climbOver(e.getPlayer(), e.getPlayer().transform(e.getPlayer().getX() < e.getObject().getX() ? 2 : -2, 0, 0)); }); public static ObjectClickHandler handleCabbagePatchStile = new ObjectClickHandler(new Object[] { 7527 }, e -> { Player p = e.getPlayer(); WorldObject obj = e.getObject(); if(!obj.getTile().matches(Tile.of(3063, 3282, 0))) return; if(p.getY() > obj.getY()) AgilityShortcuts.climbOver(p, Tile.of(obj.getX(), obj.getY()-1, obj.getPlane())); if(p.getY() < obj.getY()) AgilityShortcuts.climbOver(p, Tile.of(obj.getX(), obj.getY()+1, obj.getPlane())); }); public static ObjectClickHandler handleCowFieldStile = new ObjectClickHandler(new Object[] { 7527 }, e -> { Player p = e.getPlayer(); WorldObject obj = e.getObject(); if(!obj.getTile().matches(Tile.of(3043, 3305, 0))) return; if(p.getX() > obj.getX()) AgilityShortcuts.climbOver(p, Tile.of(obj.getX()-1, obj.getY(), obj.getPlane())); if(p.getX() < obj.getX()) AgilityShortcuts.climbOver(p, Tile.of(obj.getX()+1, obj.getY(), obj.getPlane())); }); //falador public static ObjectClickHandler handlefaladorcastlestairs = new ObjectClickHandler(new Object[] { 11736, 11737 }, e -> { if (e.getObjectId() == 11736) e.getPlayer().tele(e.getPlayer().transform(e.getObject().getRotation() == 3 ? 0 : e.getObject().getRotation() == 0 ? -0 : 0, e.getObject().getRotation() == 3 ? -0 : e.getObject().getRotation() == 0 ? 4 : 0, 1)); else if (e.getObjectId() == 11737) e.getPlayer().tele(e.getPlayer().transform(e.getObject().getRotation() == 3 ? -0 : e.getObject().getRotation() == 0 ? -0 : 0, e.getObject().getRotation() == 3 ? 0 : e.getObject().getRotation() == 0 ? -4 : 0, -1)); }); }" "package com.rs.game.content.world.areas.falador.npcs; @PluginEventHandler public class Askel extends Conversation { private static final int npcId = 6663; public static NPCClickHandler Askel = new NPCClickHandler(new Object[]{ npcId }, e -> { switch (e.getOption()) { case ""Talk-to"" -> e.getPlayer().startConversation(new Askel(e.getPlayer())); } }); public Askel(Player player) { super(player); addNPC(npcId, HeadE.HAPPY_TALKING, ""Welcome. What brings you to the home of the artisans?""); addOptions(new Options() { @Override public void create() { option(""What's an artisan?"", new Dialogue() .addPlayer(HeadE.CALM_TALK, ""What's an artisan?"") .addNPC(npcId, HeadE.HAPPY_TALKING,""Artisans are a collective of skilled smiths who work towards upholding quality as their principle ethos. "") .addNPC(npcId, HeadE.HAPPY_TALKING,""Smithing can be seen as a coarse, unloving undertaking...bashing out platebodies as quickly as you can."") .addNPC(npcId, HeadE.HAPPY_TALKING,""It's not like that here. Recently, we've opened our doors to humans."") .addNPC(npcId, HeadE.HAPPY_TALKING,""Some of our stauncher members aren't happy about this, but if you work hard I'm sure you'll earn our respect. "") ); option(""Tell me more about yourself."", new Dialogue() .addPlayer(HeadE.CALM_TALK, ""Tell me more about yourself."") .addNPC(npcId, HeadE.HAPPY_TALKING, ""I built the furnace that rather dominates this room. Took me four and a half years; carved the rock myself. "") .addNPC(npcId, HeadE.HAPPY_TALKING,""If you need any pointers on how to use it, talk to Egil. "") .addNPC(npcId, HeadE.HAPPY_TALKING,""I don't do much actual smithing any more. I mainly potter around the workshop, helping where I can."") ); } }); } }" "package com.rs.game.content.world.areas.falador.npcs class BartendersRisingSunInn(p: Player, npc: NPC) { init { p.startConversation { npc(npc.id, HeadE.HAPPY_TALKING, ""Hi! What can I get you?"") if (!isBarVisited(p, RISING_SUN) && BarCrawl.hasCard(p) && onBarCrawl(p)) { options { op(""What ales are you serving?"") { exec { normalDialogue(p, npc) } } op(""I'm doing Alfred Grimhand's Barcrawl."") { exec { barCrawlDialogue(p, npc) } } } } else { exec { normalDialogue(p, npc) } } } } private fun normalDialogue(p: Player, npc: NPC) { p.startConversation { player(HeadE.HAPPY_TALKING, ""What ales are you serving?"") npc(npc.id, HeadE.HAPPY_TALKING, ""Well, we've got Asgarnian Ale, Wizard's Mind Bomb and Dwarven Stout, all for only 3 coins."") options { op(""One Asgarnian Ale, please."") { player(HeadE.HAPPY_TALKING, ""One Asgarnian Ale, please."") npc(npc, HeadE.HAPPY_TALKING, ""That'll be 3 coins, please."") exec { buyDrinkOrIngredients(p, npc, 3, Item(1905), false) } } op(""I'll try the Mind Bomb."") { player(HeadE.HAPPY_TALKING, ""I'll try the Mind Bomb."") npc(npc, HeadE.HAPPY_TALKING, ""That'll be 3 coins, please."") exec { buyDrinkOrIngredients(p, npc, 3, Item(1907), false) } } op(""Can I have a Dwarven Stout?"") { player(HeadE.HAPPY_TALKING, ""Can I have a Dwarven Stout?"") npc(npc, HeadE.HAPPY_TALKING, ""That'll be 3 coins, please."") exec { buyDrinkOrIngredients(p, npc, 3, Item(1913), false) } } op(""I don't feel like any of those."") { player(HeadE.HAPPY_TALKING, ""I don't feel like any of those."") } if (p.inventory.containsItem(1919)) { op(""I've got this beer glass..."") { exec { sellBeerGlass(p, npc) } } } } } } private fun barCrawlDialogue(p: Player, npc: NPC) { p.startConversation { player(HeadE.HAPPY_TALKING, ""I'm doing Alfred Grimhand's Barcrawl."") npc(npc, HeadE.LAUGH, ""Heehee, this'll be fun!"") npc(npc, HeadE.CHEERFUL_EXPOSITION, ""You'll be after our ${RISING_SUN.drinkName}, then. Lots of expensive parts to the cocktail, though, so it will cost you ${RISING_SUN.price} coins."") exec { buyBarcrawlDrink(p, RISING_SUN) } } } } @ServerStartupEvent fun mapBartendersRisingSunInn() { getInteractionDistance(736) { _, _ -> 2 } onNpcClick(736, 3217, 3218) { (player, npc) -> BartendersRisingSunInn(player, npc) } }" "package com.rs.game.content.world.areas.falador.npcs; @PluginEventHandler public class Cassie extends Conversation { private static final int npcId = 577; public static NPCClickHandler Cassie = new NPCClickHandler(new Object[]{ npcId }, e -> { switch (e.getOption()) { case ""Talk-to"" -> e.getPlayer().startConversation(new Cassie(e.getPlayer())); case ""Trade"" -> ShopsHandler.openShop(e.getPlayer(), ""cassies_shield_shop""); } }); public Cassie(Player player) { super(player); addNPC(npcId, HeadE.HAPPY_TALKING, ""I buy and sell shields; do you want to trade?""); addOptions(new Options() { @Override public void create() { option(""Yes, please."", new Dialogue() .addNext(() -> ShopsHandler.openShop(player, ""cassies_shield_shop""))); option(""No, thank you."", new Dialogue() .addPlayer(HeadE.CALM_TALK, ""No, thank you."") .addNPC(npcId, HeadE.HAPPY_TALKING, ""Okay, come back soon."") ); } }); } }" "package com.rs.game.content.world.areas.falador.npcs; @PluginEventHandler public class Egil extends Conversation { private static final int npcId = 6642; public static NPCClickHandler Egil = new NPCClickHandler(new Object[]{ npcId }, e -> { switch (e.getOption()) { case ""Talk-to"" -> e.getPlayer().startConversation(new Egil(e.getPlayer())); } }); public Egil(Player player) { super(player); addNPC(npcId, HeadE.HAPPY_TALKING, ""Welcome to the Artisan's Workshop. "" ); addNPC(npcId, HeadE.HAPPY_TALKING, ""We've got normal smithing in the front, and burial smithing in the back! "" ); addNPC(npcId, HeadE.HAPPY_TALKING, ""Also, I'll occasionally stop by and hand you some ceremonial sword plans to complete for extra experience.""); addOptions(new Options() { @Override public void create() { option(""What's a ceremonial sword?"", new Dialogue() .addPlayer(HeadE.CALM_TALK, ""What's a ceremonial sword?"") .addNPC(npcId, HeadE.HAPPY_TALKING,""A ceremonial sword distinguishes the wielder from his peers. They are items of beauty and craftsmanship that are favoured by officers and the very rich."") .addPlayer(HeadE.CALM_TALK, ""I'm guessing they're expensive?"") .addNPC(npcId, HeadE.HAPPY_TALKING,""Quite so. We use only the purest metal to get the most malleable and perfect swords."") .addNPC(npcId, HeadE.HAPPY_TALKING, ""Each blade requires a lot of ore, which we smelt into a pure, dense metal."") .addNPC(npcId, HeadE.HAPPY_TALKING, ""But if we give you some plans, we'll supply all the materials so you'll be able to freely smith your ceremonial sword!"") ); option(""Who are you?"", new Dialogue() .addPlayer(HeadE.CALM_TALK, ""Who are you?"") .addNPC(npcId, HeadE.HAPPY_TALKING, ""I am Egil, ceremonial sword specialist and, apparently, one of the workshop's more senior artisans."") .addPlayer(HeadE.CONFUSED, ""Apparently?"") .addNPC(npcId, HeadE.HAPPY_TALKING,""I don't hold much stock in titles. They garnish the ego, but are rather impractical."") ); } }); } }" "package com.rs.game.content.world.areas.falador.npcs; @PluginEventHandler public class FaladorFarm { public static NPCClickHandler HandleMilkSeller = new NPCClickHandler(new Object[]{ 11547 }, new String[] { ""Talk-to"" }, e -> { Player player = e.getPlayer(); NPC npc = e.getNPC(); player.startConversation(new Dialogue() .addNPC(npc, HeadE.HAPPY_TALKING, ""Would you like to buy some milk?"") .addOptions((ops) -> { ops.add(""Sure."", () -> ShopsHandler.openShop(player, ""milk_shop"")); ops.add(""No, thanks."") .addPlayer(HeadE.CALM_TALK, ""No, thanks."") .addNPC(npc, HeadE.HAPPY_TALKING, ""If you change your mind, you know where we are.""); })); }); public static NPCClickHandler HandleSarah = new NPCClickHandler(new Object[]{ 2304 }, new String[] { ""Talk-to"" }, e -> { Player player = e.getPlayer(); NPC npc = e.getNPC(); player.startConversation(new Dialogue() .addNPC(npc, HeadE.HAPPY_TALKING, ""Would you like to buy some farming supplies?"") .addOptions(ops -> { ops.add(""Let's see what you've got then."", () -> ShopsHandler.openShop(player, ""sarahs_farming_shop"")); ops.add(""No, thanks."") .addPlayer(HeadE.CALM_TALK, ""No, thanks."") .addNPC(npc, HeadE.HAPPY_TALKING, ""Okay. Fare well on your travels.""); })); }); }" "package com.rs.game.content.world.areas.falador.npcs; @PluginEventHandler public class FaladorGeneralStoreAssistant extends Conversation { private static final int npcId = 527; public static NPCClickHandler FaladorGeneralStoreAssistant = new NPCClickHandler(new Object[]{npcId}, e -> { switch (e.getOption()) { case ""Talk-to"" -> e.getPlayer().startConversation(new FaladorGeneralStoreAssistant(e.getPlayer())); case ""Trade"" -> ShopsHandler.openShop(e.getPlayer(), ""falador_general_store""); } }); public FaladorGeneralStoreAssistant(Player player) { super(player); addNPC(npcId, HeadE.HAPPY_TALKING, ""Can I help you at all?""); addOptions(new Options() { @Override public void create() { option(""Yes, please. What are you selling?"", new Dialogue() .addNext(() -> ShopsHandler.openShop(player, ""falador_general_store""))); option(""How should I use your shop?"", new Dialogue() .addNPC(npcId, HeadE.HAPPY_TALKING, ""I'm glad you ask! You can buy as many of the items stocked as you wish. You can also sell most items to the shop."") .addNext(() -> ShopsHandler.openShop(player, ""falador_general_store""))); option(""I think I'll give it a miss."", new Dialogue() .addPlayer(HeadE.CALM_TALK, ""I think I'll give it a miss."") .addNPC(npcId, HeadE.HAPPY_TALKING, ""Okay, come back soon."") ); } }); } }" "package com.rs.game.content.world.areas.falador.npcs; @PluginEventHandler public class FaladorGeneralStoreShopkeeper extends Conversation { private static final int npcId = 526; public static NPCClickHandler FaladorGeneralStoreAssistant = new NPCClickHandler(new Object[]{ npcId }, e -> { switch (e.getOption()) { case ""Talk-to"" -> e.getPlayer().startConversation(new FaladorGeneralStoreShopkeeper(e.getPlayer())); case ""Trade"" -> ShopsHandler.openShop(e.getPlayer(), ""falador_general_store""); } }); public FaladorGeneralStoreShopkeeper(Player player) { super(player); addNPC(npcId, HeadE.HAPPY_TALKING, ""Can I help you at all?""); addOptions(new Options() { @Override public void create() { option(""Yes, please. What are you selling?"", new Dialogue() .addNext(() -> ShopsHandler.openShop(player, ""falador_general_store""))); option(""How should I use your shop?"", new Dialogue() .addNPC(npcId, HeadE.HAPPY_TALKING, ""I'm glad you ask! You can buy as many of the items stocked as you wish. You can also sell most items to the shop."") .addNext(() -> ShopsHandler.openShop(player, ""falador_general_store""))); option(""I think I'll give it a miss."", new Dialogue() .addPlayer(HeadE.CALM_TALK, ""I think I'll give it a miss."") .addNPC(npcId, HeadE.HAPPY_TALKING, ""Okay, come back soon."") ); } }); } }" "package com.rs.game.content.world.areas.falador.npcs; @PluginEventHandler public class Flynn extends Conversation { private static final int npcId = 580; public static NPCClickHandler Flynn = new NPCClickHandler(new Object[]{ npcId }, e -> { switch (e.getOption()) { case ""Talk-to"" -> e.getPlayer().startConversation(new Flynn(e.getPlayer())); case ""Trade"" -> ShopsHandler.openShop(e.getPlayer(), ""flynns_mace_shop""); } }); public Flynn(Player player) { super(player); addNPC(npcId, HeadE.HAPPY_TALKING, ""Hello. Do you want to buy or sell any maces?""); addOptions(new Options() { @Override public void create() { option(""Well, I'll have a look, at least."", new Dialogue() .addNext(() -> ShopsHandler.openShop(player, ""flynns_mace_shop""))); option(""I think I'll give it a miss."", new Dialogue() .addPlayer(HeadE.CALM_TALK, ""I think I'll give it a miss."") .addNPC(npcId, HeadE.HAPPY_TALKING, ""Okay, come back soon."") ); } }); } }" "package com.rs.game.content.world.areas.falador.npcs; @PluginEventHandler public class Hairdresser extends Conversation { private static final int npcId = 598; public static NPCClickHandler Hairdresser = new NPCClickHandler(new Object[]{ npcId }, e -> { switch (e.getOption()) { case ""Talk-to"" -> e.getPlayer().startConversation(new Hairdresser(e.getPlayer())); case ""Hair-cut"" -> PlayerLook.openHairdresserSalon(e.getPlayer()); } }); public Hairdresser(Player player) { super(player); addNPC(npcId, HeadE.HAPPY_TALKING, ""Good afternoon, "" + player.getPronoun(""sir"", ""madam"") + "". Are you interested in a new haircut?""); addOptions(new Options() { @Override public void create() { option(""Yes, please."", new Dialogue() .addNext(() -> PlayerLook.openHairdresserSalon(player))); option(""No, thank you."", new Dialogue() .addPlayer(HeadE.CALM_TALK, ""No, thank you."") .addNPC(npcId, HeadE.HAPPY_TALKING, ""Very well. Come back if you change your mind."") ); } }); } }" "package com.rs.game.content.world.areas.falador.npcs; @PluginEventHandler public class HeraldOfFalador extends Conversation { private static final int npcId = 13939; public static NPCClickHandler IkisKrum = new NPCClickHandler(new Object[]{ npcId }, e -> { switch (e.getOption()) { case ""Talk-to"" -> e.getPlayer().startConversation(new HeraldOfFalador(e.getPlayer())); } }); public HeraldOfFalador(Player player) { super(player); addNPC(npcId, HeadE.HAPPY_TALKING, ""A fine day to be visiting Falador is it not? Welcome, ally!""); addPlayer(HeadE.HAPPY_TALKING, ""Hello to you as well! What do you do here?""); addNPC(npcId, HeadE.HAPPY_TALKING, ""As the Falador herald, I've been put in command of keeping Falador a strong and mighty region within Gielinor.""); addNPC(npcId, HeadE.FRUSTRATED, ""My fighting days are behind me, but I can still conquer the hearts of the people with marching parades and our herald capes.""); } }" "package com.rs.game.content.world.areas.falador.npcs; @PluginEventHandler public class Herquin extends Conversation { private static final int npcId = 584; public static NPCClickHandler Herquin = new NPCClickHandler(new Object[]{ npcId }, e -> { switch (e.getOption()) { case ""Talk-to"" -> e.getPlayer().startConversation(new Herquin(e.getPlayer())); case ""Trade"" -> ShopsHandler.openShop(e.getPlayer(), ""herquins_gems""); } }); public Herquin(Player player) { super(player); addNPC(npcId, HeadE.HAPPY_TALKING, ""Do you wish to trade?""); addOptions(new Options() { @Override public void create() { option(""Yes, please."", new Dialogue() .addNext(() -> ShopsHandler.openShop(player, ""herquins_gems""))); option(""Sorry, I don't want to talk to you, actually."", new Dialogue() .addPlayer(HeadE.CALM_TALK, ""Sorry, I don't want to talk to you, actually."") .addNPC(npcId, HeadE.SHAKING_HEAD, ""Huh, charming."") ); } }); } }" "package com.rs.game.content.world.areas.falador.npcs; @PluginEventHandler public class Iconis extends Conversation { private static final int npcId = 8879; public static NPCClickHandler Iconis = new NPCClickHandler(new Object[]{ npcId }, e -> { switch (e.getOption()) { case ""Talk-to"" -> e.getPlayer().startConversation(new Iconis(e.getPlayer())); case ""Take-picture"" -> e.getPlayer().startConversation(new Dialogue() .addNPC(npcId, HeadE.SHAKING_HEAD, ""Sorry, the imp is a little busy. There's a lot of demand, you see."") ); } }); public static ObjectClickHandler PhotoBooth = new ObjectClickHandler(new Object[] { 46396 }, e -> e.getPlayer().startConversation(new Dialogue() .addNPC(npcId, HeadE.SHAKING_HEAD, ""Sorry, the imp is a little busy. There's a lot of demand, you see.""))); public Iconis(Player player) { super(player); addNPC(npcId, HeadE.HAPPY_TALKING, ""Good day! Would you like to have your picture taken?""); addOptions(new Options() { @Override public void create() { option(""Yes, please!"", new Dialogue() .addNPC(npcId, HeadE.SHAKING_HEAD, ""Sorry, the imp is a little busy. There's a lot of demand, you see."")); option(""No, thank you."", new Dialogue() .addPlayer(HeadE.CALM_TALK, ""No, thank you."") .addNPC(npcId, HeadE.HAPPY_TALKING, ""As you wish."") ); option(""How does it work?"", new Dialogue() .addPlayer(HeadE.CALM_TALK, ""How does it work?"") .addNPC(npcId, HeadE.HAPPY_TALKING, ""There's an imp in there who uses a spell to take your picture. He's having a hard time keeping up at the moment. There's a lot of demand, you see."") .addOptions(new Options() { @Override public void create() { option(""Why an imp?"", new Dialogue() .addPlayer(HeadE.CALM_TALK, ""Why an imp?"") .addNPC(npcId, HeadE.HAPPY_TALKING, ""Ah, good question! "") .addNPC(npcId, HeadE.HAPPY_TALKING, ""See, I've experimented with lots of ways of making accurate visual representations of things in a magical way. "") .addNPC(npcId, HeadE.HAPPY_TALKING, ""Most recently, I've been trying to modify scrying orbs to get a still picture. Because of their shape, though, they always made the subject look fat! "") .addNPC(npcId, HeadE.HAPPY_TALKING, ""So I came up with a scrying cube, but that made things look even worse!"") .addPlayer(HeadE.CALM_TALK, ""So what did you do?"") .addNPC(npcId, HeadE.HAPPY_TALKING, ""I tweaked and tweaked the shape until I got a decent picture - took me weeks to make - but then this imp just teleported in from out of nowhere right next to it. My scrying device fell on the floor and smashed."") .addPlayer(HeadE.AMAZED_MILD, ""Oh, no!"") .addNPC(npcId, HeadE.HAPPY_TALKING, ""Indeed. I caught the culprit in a magic imp box and had a word with him. He seemed rather confused that I was using orbs to take pictures. Apparently, imps have a rather handy spell for that, so I hired him!"") .addPlayer(HeadE.CONFUSED, ""Imps take pictures?"") .addNPC(npcId, HeadE.HAPPY_TALKING, ""Yes. He wouldn't reveal the exact working of the spell to me, or even why they do it, but the result is very convincing."") ); option(""Is it safe?"", new Dialogue() .addPlayer(HeadE.SKEPTICAL, ""Is it safe?"") .addNPC(npcId, HeadE.HAPPY_TALKING, ""Oh, absolutely! I've tried the procedure myself thousands of times to make sure it's safe and that there are no side effects."") .addPlayer(HeadE.SKEPTICAL, ""But are my belongings safe?"") .addNPC(npcId, HeadE.HAPPY_TALKING, ""Totally! I've got a few runes, orbs and trinkets in there to ensure of that."") ); option(""That's all, thank you."", new Dialogue() .addPlayer(HeadE.CALM_TALK, ""That's all, thank you."") .addNPC(npcId, HeadE.HAPPY_TALKING, ""You're welcome!"") ); } }) ); } }); } }" "package com.rs.game.content.world.areas.falador.npcs; @PluginEventHandler public class IkisKrum extends Conversation { private static final int npcId = 12237; public static NPCClickHandler IkisKrum = new NPCClickHandler(new Object[]{ npcId }, e -> { switch (e.getOption()) { case ""Talk-to"" -> e.getPlayer().startConversation(new IkisKrum(e.getPlayer())); } }); public IkisKrum(Player player) { super(player); addPlayer(HeadE.HAPPY_TALKING, ""Hello.""); addNPC(npcId, HeadE.HAPPY_TALKING, ""Good day, "" + player.getPronoun(""sir"", ""madam"") + "". What brings you to this end of town?""); addPlayer(HeadE.HAPPY_TALKING, ""Well, what is there to do around here?""); addNPC(npcId, HeadE.HAPPY_TALKING, ""If you're into Mining, plenty! The dwarves have one of the largest mines in the world just under our feet. There's an entrance in the building just north-east of my house.""); addNPC(npcId, HeadE.FRUSTRATED, ""If you're one of these young, loud, hipster sorts you could visit the Party Room, just north of here. That blasted Pete parties all night and I never get any sleep!""); addPlayer(HeadE.HAPPY_TALKING, ""Thanks.""); } }" "package com.rs.game.content.world.areas.falador.npcs; @PluginEventHandler public class KarmaTheChameleon extends Conversation { private static final int npcId = 8580; public static NPCClickHandler KarmaTheChameleon = new NPCClickHandler(new Object[]{ npcId }, e -> { switch (e.getOption()) { case ""Talk-to"" -> e.getPlayer().startConversation(new KarmaTheChameleon(e.getPlayer())); } }); public KarmaTheChameleon(Player player) { super(player); if(player.getSkills().getLevel(Skills.SUMMONING) <= 98){ addNPC(npcId, HeadE.CHILD_HAPPY_TALK, ""Hssshsss hssssh sssshssss sss.""); addOptions(new Options() { @Override public void create() { option(""Who are you?"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Who are you?"") .addNPC(npcId, HeadE.CHILD_HAPPY_TALK, ""Hssshsss hssssh sssshssss sss."") .addPlayer(HeadE.HAPPY_TALKING, ""That's nice."") .addNPC(npcId, HeadE.CHILD_HAPPY_TALK, ""Hssshsss hssssh sssshssss sss."") .addPlayer(HeadE.HAPPY_TALKING, ""Rock on!."") .addNPC(npcId, HeadE.CHILD_HAPPY_TALK, ""Hssshsss hssssh sssshssss sss."") ); option(""Rock on!."", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Rock on!."") .addNPC(npcId, HeadE.CHILD_HAPPY_TALK, ""Well, see you around, Tiffy."") ); } }); } else { addNPC(npcId, HeadE.CHILD_HAPPY_TALK, ""Party on, dude!""); addOptions(new Options() { @Override public void create() { option(""Who are you?"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Who are you?"") .addNPC(npcId, HeadE.CHILD_HAPPY_TALK, ""My name's Karma. I'm Pete's pet."") .addPlayer(HeadE.HAPPY_TALKING, ""That's nice."") .addNPC(npcId, HeadE.CHILD_HAPPY_TALK, ""Oh yeah, man, it majorly rocks!"") .addPlayer(HeadE.HAPPY_TALKING, ""Rock on!."") .addNPC(npcId, HeadE.CHILD_HAPPY_TALK, ""You betcha!"") ); option(""Rock on!."", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Rock on!."") .addNPC(npcId, HeadE.CHILD_HAPPY_TALK, ""You betcha!"") ); } }); } } }" "package com.rs.game.content.world.areas.falador.npcs; @PluginEventHandler public class MakeOverMage { public static NPCClickHandler makeoverMageHandler = new NPCClickHandler(new Object[] { 599, 2676 }, new String[] { ""Talk-to"", ""Makeover"" }, e -> { Player player = e.getPlayer(); int npc = player.getAppearance().isMale() ? 599 : 2676; switch (e.getOption()) { case ""Makeover"" -> PlayerLook.openMageMakeOver(player); case ""Talk-to"" -> player.startConversation(new Dialogue() .addNPC(npc, HeadE.CALM_TALK, ""Hello there! I am known as the Makeover Mage! I have spent many years researching magicks that can change your physical appearence."") .addNPC(npc, HeadE.CALM_TALK, ""I call it a 'makeover'. Would you like to perform my magicks on you?"") .addOptions((ops) -> { ops.add(""Tell me more about this 'makeover'."") .addPlayer(HeadE.CALM_TALK, ""Tell me more about this 'makeover'."") .addNPC(npc, HeadE.CALM_TALK, ""Why, of course! Basically, and I will explain this so that you understand it correctly"") .addNPC(npc, HeadE.CALM_TALK, ""I use my secret magical technique to melt your body down into a puddle of its elements. When I have broken down all components of your body, I then rebuild it into the form I am thinking of. Or, you know, something vaguely close enough, anyway."") .addNPC(npc, HeadE.CALM_TALK, ""When I have broken down all components of your body, I then rebuild it into the form I am thinking of. Or, you know, something vaguely close enough, anyway."") .addPlayer(HeadE.CALM_TALK, ""Uh...that doesn't sound particularly safe to me."") .addNPC(npc, HeadE.CALM_TALK, ""It's as safe as houses! Why, I have only had thirty-six major accidents this month! So, what do you say? Feel like a change?"") .addOption(""Select an option"", ""Sure, do it."", ""No, thanks."") .addPlayer(HeadE.NERVOUS, ""Sure, do it."") .addNext(() -> PlayerLook.openMageMakeOver(player)); ops.add(""Sure, do it."") .addPlayer(HeadE.CALM_TALK, ""Sure, do it."") .addNPC(npc, HeadE.CALM_TALK, ""You, of course, agree that if by some accident you are turned into a frog you have no rights for compensation or refund."") .addNext(() -> PlayerLook.openMageMakeOver(player)); ops.add(""No thanks."") .addPlayer(HeadE.CALM_TALK, ""No thanks. I'm happy as Saradomin made me."") .addNPC(npc, HeadE.CALM_TALK, ""Ehhh...suit yourself.""); ops.add(""Cool amulet! Can I have one?"") .addPlayer(HeadE.HAPPY_TALKING, ""Cool amulet! Can I have one?"") .addNPC(npc, HeadE.CALM_TALK, ""No problem, but please remember that the amulet I will sell you is only a copy of my own. It contains no magical powers and, as such, it will only cost you 100 coins."") .addOption(""Select an option"", ""Sure, here you go."", ""No way! That's too expensive."") .addNext(() -> { if (player.getInventory().hasCoins(100)) { player.getInventory().removeCoins(100); player.getInventory().addItem(7803, 1); } else player.npcDialogue(npc, HeadE.CALM_TALK, ""Come back with 100gp and I'll sell you a copy.""); }); ops.add(""Holiday makeovers"") .addPlayer(HeadE.HAPPY_TALKING, ""Can you change my skintone to another color?"") .addNPC(npc, HeadE.CONFUSED, ""Woah, you don't look so good. Are you okay?"") .addOptions((ops1) -> { ops1.add(""I'm blue da ba dee da ba di."") .addPlayer(HeadE.CALM_TALK, ""I'm blue da ba dee da ba di."") .addNext(() -> PlayerLook.setSkinCustom(player, 12)); ops1.add(""That's my secret cap, I am always angry. aaaaaaaaaargghhhh."") .addPlayer(HeadE.CALM_TALK, ""That's my secret cap, I am always angry. aaaaaaaaaargghhhh."") .addNext(() -> PlayerLook.setSkinCustom(player, 13)); ops1.add(""No, I'm good thanks."") .addPlayer(HeadE.CALM_TALK, ""No, I'm good thanks.""); }); })); } }); }" "package com.rs.game.content.world.areas.falador.npcs; @PluginEventHandler public class RisingSunInnDrunkenMan extends Conversation { public static NPCClickHandler RisingSunInnDrunkenMan = new NPCClickHandler(new Object[] { 3222 }, e -> { if (e.getOption().equalsIgnoreCase(""talk-to"")) e.getPlayer().startConversation(new RisingSunInnDrunkenMan(e.getPlayer(), e.getNPC().getId())); }); public RisingSunInnDrunkenMan(Player player, int npc) { super(player); addPlayer(HeadE.HAPPY_TALKING, ""Hello""); addNPC(npc, HeadE.DRUNK, ""... whassup?""); addPlayer(HeadE.CONFUSED, ""Are you alright?""); addNPC(npc, HeadE.DRUNK, ""... see ... two of you ... why there two of you?""); addPlayer(HeadE.CONFUSED, ""There's only one of me, friend.""); addNPC(npc, HeadE.DRUNK, ""... no, two of you... you can't count...""); addNPC(npc, HeadE.DRUNK, ""... maybe you drunk too much...""); addPlayer(HeadE.SHAKING_HEAD, ""Whatever you say, friend.""); addNPC(npc, HeadE.DRUNK_ANGRY, ""... giant hairy cabbages...""); } }" "package com.rs.game.content.world.areas.falador.npcs; @PluginEventHandler public class SirTiffyCashien extends Conversation { private static final int npcId = 2290; public static NPCClickHandler SirTiffyCashien = new NPCClickHandler(new Object[]{ npcId }, e -> { switch (e.getOption()) { case ""Talk-to"" -> e.getPlayer().startConversation(new SirTiffyCashien(e.getPlayer())); } }); public SirTiffyCashien(Player player) { super(player); if(!Quest.RECRUITMENT_DRIVE.isImplemented()) { addPlayer(HeadE.HAPPY_TALKING, ""Hello."" ); addNPC(npcId, HeadE.HAPPY_TALKING, ""What ho, "" + player.getPronoun(""sir"", ""milady"")+ "". Spiffing day for a walk in the park, what?"" ); addOptions(new Options() { @Override public void create() { option(""Can I buy some armour?"", new Dialogue() .addPlayer(HeadE.CALM_TALK, ""Can I buy some armour?"") .addNPC(npcId, HeadE.HAPPY_TALKING,""Of course, dear "" + player.getPronoun(""boy"", ""gal"") + ""."") .addNext(() -> ShopsHandler.openShop(player, ""initiate_rank_armory"")) ); option(""Goodbye."", new Dialogue() .addPlayer(HeadE.CALM_TALK, ""Well, see you around, Tiffy."") .addNPC(npcId, HeadE.HAPPY_TALKING, ""Well, see you around, Tiffy."") ); } }); } else if(player.getQuestManager().getStage(Quest.RECRUITMENT_DRIVE) == 0) { addPlayer(HeadE.HAPPY_TALKING, ""Hello."" ); addNPC(npcId, HeadE.HAPPY_TALKING, ""What ho, "" + player.getPronoun(""sir"", ""milady"")+ "". Spiffing day for a walk in the park, what?"" ); addPlayer(HeadE.CONFUSED, ""Spiffing?"" ); addNPC(npcId, HeadE.HAPPY_TALKING, ""Absolutely, top-hole! Well, can't stay and chat all day, dontchaknow! Ta-ta for now!""); addPlayer(HeadE.CONFUSED, ""Erm...goodbye."" ); } } }" "package com.rs.game.content.world.areas.falador.npcs; @PluginEventHandler public class SquireAsrol extends Conversation { private static final int npcId = 606; public static NPCClickHandler SquireAsrol = new NPCClickHandler(new Object[]{ npcId }, e -> { switch (e.getOption()) { case ""Talk-to"" -> e.getPlayer().startConversation(new SquireAsrol(e.getPlayer())); } }); public SquireAsrol(Player player) { super(player); addNPC(npcId, HeadE.CHEERFUL, ""Hello, what are you after?""); addOptions(""What would you like to say?"", new Options() { @Override public void create() { if(!player.isQuestComplete(Quest.KNIGHTS_SWORD)) option(""About Knight's Sword."", new Dialogue() .addNext(()-> player.startConversation(new SquireKnightsSwordD(player))) ); option(""About the Achievement System..."", () -> new AchievementSystemD(player, npcId, SetReward.FALADOR_SHIELD)); } }); } }" "package com.rs.game.content.world.areas.falador.npcs; @PluginEventHandler public class Wayne extends Conversation { private static final int npcId = 581; public static NPCClickHandler Wayne = new NPCClickHandler(new Object[]{ npcId }, e -> { switch (e.getOption()) { case ""Talk-to"" -> e.getPlayer().startConversation(new Wayne(e.getPlayer())); case ""Trade"" -> ShopsHandler.openShop(e.getPlayer(), ""waynes_chains""); } }); public Wayne(Player player) { super(player); addNPC(npcId, HeadE.HAPPY_TALKING, ""Welcome to Wayne's Chains. Do you wanna buy or sell some chainmail?""); addOptions(new Options() { @Override public void create() { option(""Yes, please."", new Dialogue() .addNext(() -> ShopsHandler.openShop(player, ""waynes_chains""))); option(""No, thank you."", new Dialogue() .addPlayer(HeadE.CALM_TALK, ""No, thank you."") .addNPC(npcId, HeadE.HAPPY_TALKING, ""Okay, come back soon."") ); } }); } }" "package com.rs.game.content.world.areas.falador.npcs; @PluginEventHandler public class Wyson extends Conversation { private static final int npcId = 36; public static NPCClickHandler Wyson = new NPCClickHandler(new Object[]{ npcId }, e -> { switch (e.getOption()) { case ""Talk-to"" -> e.getPlayer().startConversation(new Wyson(e.getPlayer())); } }); public Wyson(Player player) { super(player); addNPC(npcId, HeadE.CALM, ""I'm the head gardener around here. If you're looking for woad leaves, or if you need help with owt, I'm yer man.""); addOptions(new Options() { @Override public void create() { option(""Ok, I will trade my mole parts."", new Dialogue().addPlayer(HeadE.CALM_TALK, ""ok, I will trade my mole parts."", () -> { int numNests = player.getInventory().getNumberOf(7416) + player.getInventory().getNumberOf(7418); player.getInventory().deleteItem(7416, Integer.MAX_VALUE); player.getInventory().deleteItem(7418, Integer.MAX_VALUE); for (int i = 0;i < numNests;i++) player.getInventory().addItem(Utils.random(0, 100) <= 7 ? 5075 : 7413, 1); })); option(""Yes please, I need woad leaves."", new Dialogue() .addNPC(npcId, HeadE.AMAZED, ""How much are you willing to pay?"") .addOptions(new Options() { @Override public void create() { option(""How about 5 coins?"", new Dialogue() .addPlayer(HeadE.CALM, ""How about 5 coins?"") .addNPC(npcId, HeadE.FRUSTRATED, ""No no, that's far too little. Woad leaves are hard to get. I used to have plenty but someone kept"" + "" stealing them off me."")); option(""How about 10 coins?"", new Dialogue() .addPlayer(HeadE.CALM, ""How about 10 coins?"") .addNPC(npcId, HeadE.FRUSTRATED, ""No no, that's far too little. Woad leaves are hard to get. I used to have plenty but someone kept "" + ""stealing them off me."")); option(""How about 15 coins?"", new Dialogue().addPlayer(HeadE.CALM, ""How about 15 coins?"") .addNPC(npcId, HeadE.FRUSTRATED, "" Mmmm... okay, that sounds fair."", () -> { if (player.getInventory() .hasCoins(15)) { player.getInventory() .removeCoins(15); player.getInventory().addItem(1793, 1); } else player.getPackets().sendGameMessage( ""You need 15 coins for this transaction""); })); option(""How about 20 coins?"", new Dialogue().addPlayer(HeadE.CALM, ""How about 20 coins?"") .addNPC(npcId, HeadE.FRUSTRATED, ""Okay, that's more than fair"", () -> { if (player.getInventory() .hasCoins(20)) { player.getInventory() .removeCoins(20); player.getInventory().addItem(1793, 2); } else player.getPackets().sendGameMessage( ""You need 20 coins for this transaction""); })); } })); option(""How about ME helping YOU instead?"", new Dialogue() .addPlayer(HeadE.CALM_TALK, ""How about ME helping YOU instead?"") .addNPC(npcId, HeadE.HAPPY_TALKING, ""That's a nice thing to say. I do need a hand, now you mention it. You see, there's some stupid mole "" + ""digging up my lovely garden."") .addPlayer(HeadE.CALM_TALK, ""A mole? Surely you've dealt with moles in the past?"") .addNPC(npcId, HeadE.AMAZED, ""Ah, well this is no ordinary mole! He's a big'un for sure. Ya see... I'm always relied upon to make the"" + "" most of this 'ere garden - the faster and bigger I can grow plants the better!"") .addNPC(npcId, HeadE.WORRIED, ""In my quest for perfection I looked into 'Malignius- Mortifer's-Super-Ultra-Flora-Growth-Potion'. "" + ""It worked well on my plants, no doubt about it! But it had the same effect on a nearby mole. Ya can imagine the"") .addNPC(npcId, HeadE.FRUSTRATED, ""havoc he causes to my patches of sunflowers! Why, if any of the other gardeners knew about this mole,"" + "" I'd be looking for a new job in no time!"") .addPlayer(HeadE.CALM_TALK, ""I see. What do you need me to do?"") .addNPC(npcId, HeadE.HAPPY_TALKING, ""If ya are willing maybe yer wouldn't mind killing it for me? Take a spade and use it to shake up them "" + ""mole hills. Be careful though, he really is big!"") .addPlayer(HeadE.CALM_TALK, ""Is there anything in this for me?"") .addNPC(npcId, HeadE.HAPPY_TALKING, ""Well, if yer gets any mole skin or mole claws off 'un, I'd trade 'em for bird nests if ye brings 'em here to me."") .addPlayer(HeadE.CALM_TALK, ""Right, I'll bear it in mind."")); option(""Sorry, but I'm not interested."", new Dialogue().addPlayer(HeadE.CALM_TALK, ""Sorry, but I'm not interested."") .addNPC(npcId, HeadE.CALM, ""Fair enough."")); } }); } }" "package com.rs.game.content.world.areas.falador.npcs; @PluginEventHandler public class Xuan { public static NPCClickHandler onNPCClick = new NPCClickHandler(new Object[] { 13727 }, e -> { Player player = e.getPlayer(); NPC npc = e.getNPC(); switch (e.getOpNum()) { case 1 -> { if (player.getAuraManager().getJotSkills() >= 10) { player.startConversation(new Dialogue() .addNPC(npc, HeadE.CHEERFUL, ""Good day, my friend! Good day!"").voiceEffect(12253) .addNPC(npc, HeadE.CHEERFUL, ""Wait! I have something here for you..."").voiceEffect(11083) .addItem(20960, ""Xuan hands you a reward book for completing the Jack of Trades."", () -> { player.getInventory().addItemDrop(20960, 1); player.getAuraManager().deactivate(); player.getAuraManager().clearJotFlags(); player.incrementCount(""Jack of Trades completed""); })); return; } player.startConversation(new Dialogue() .addNPC(npc, HeadE.CHEERFUL, ""It is my privilege to offer you access to an exclusive stock of the finest and most exotic wares."").voiceEffect(13331) .addOptions(""What would you like help with?"", (ops) -> { ops.add(""Check the Loyalty Point Shop"", () -> LoyaltyShop.open(player)); ops.add(""Re-apply my account type title"", player::applyAccountTitle); ops.add(""See your available titles"", () -> AchievementTitles.openInterface(player)); ops.add(""Clear my title"") .addOptions(""Really clear your title?"", (ops2) -> { ops2.add(""Yes"", player::clearTitle); ops2.add(""No""); }); })); } case 3 -> LoyaltyShop.open(player); case 4 -> player.sendOptionDialogue(""Really clear your title?"", (ops) -> { ops.add(""Yes"", player::clearTitle); ops.add(""No""); }); } }); }" "package com.rs.game.content.world.areas.falador.npcs.announcers; @PluginEventHandler public class HeraldOfFaladorWorld extends NPC { public HeraldOfFaladorWorld(int id, Tile tile) { super(id, tile); } @Override public void processNPC() { super.processNPC(); if (Utils.random(50) == 0){ Shout(); } } public void Shout() { switch (Utils.random(1, 6)) { case 1 -> setNextForceTalk(new ForceTalk(""Falador, the indestructible city!"")); case 2 -> setNextForceTalk(new ForceTalk(""Falador capes...99% backstab proof!"")); case 3 -> setNextForceTalk(new ForceTalk(""May Falador be your sword on your travels!"")); case 4 -> setNextForceTalk(new ForceTalk(""Welcome to Falador...We'll try not to beat up you too badly."")); case 5 -> setNextForceTalk(new ForceTalk(""I think I am getting splinters."")); } } public static NPCInstanceHandler toFunc = new NPCInstanceHandler(new Object[] { 13939 }, HeraldOfFaladorWorld::new); }" "package com.rs.game.content.world.areas.pollnivneach; @PluginEventHandler public class PollnivneachSlayerDungeon { public static ObjectClickHandler handleBarriers = new ObjectClickHandler(new Object[] { 31435, 31436 }, e -> { e.getPlayer().setNextSpotAnim(new SpotAnim(1659)); if (e.getObjectId() == 31435) e.getPlayer().forceMove(e.getPlayer().transform(e.getPlayer().getX() > e.getObject().getX() ? -2 : 2, 0), 10584, 0, 30); else e.getPlayer().forceMove(e.getPlayer().transform(0, e.getPlayer().getY() > e.getObject().getY() ? -2 : 2), 10584, 0, 30); }); public static ObjectClickHandler handleDownStairsNE = new ObjectClickHandler(new Object[] { 31412 }, new Tile[] { Tile.of(3374, 9426, 0) }, e -> e.getPlayer().useStairs(e.getPlayer().transform(-52, -5061))); public static ObjectClickHandler handleUpStairsNE = new ObjectClickHandler(new Object[] { 31417 }, new Tile[] { Tile.of(3317, 4364, 0) }, e -> e.getPlayer().useStairs(e.getPlayer().transform(52, 5061))); public static ObjectClickHandler handleDownStairsSE = new ObjectClickHandler(new Object[] { 31412 }, new Tile[] { Tile.of(3377, 9367, 0) }, e -> e.getPlayer().useStairs(e.getPlayer().transform(-54, -5028))); public static ObjectClickHandler handleUpStairsSE = new ObjectClickHandler(new Object[] { 31417 }, new Tile[] { Tile.of(3318, 4339, 0) }, e -> e.getPlayer().useStairs(e.getPlayer().transform(54, 5028))); public static ObjectClickHandler handleDownStairsSW = new ObjectClickHandler(new Object[] { 31412 }, new Tile[] { Tile.of(3338, 9368, 0) }, e -> e.getPlayer().useStairs(e.getPlayer().transform(-72, -5029))); public static ObjectClickHandler handleUpStairsSW = new ObjectClickHandler(new Object[] { 31417 }, new Tile[] { Tile.of(3271, 4339, 0) }, e -> e.getPlayer().useStairs(e.getPlayer().transform(72, 5029))); public static ObjectClickHandler handleDownStairsNW = new ObjectClickHandler(new Object[] { 31412 }, new Tile[] { Tile.of(3340, 9426, 0) }, e -> e.getPlayer().useStairs(e.getPlayer().transform(-68, -5059))); public static ObjectClickHandler handleUpStairsNW = new ObjectClickHandler(new Object[] { 31417 }, new Tile[] { Tile.of(3277, 4367, 0) }, e -> e.getPlayer().useStairs(e.getPlayer().transform(68, 5059))); public static ObjectClickHandler handlepulsingmarkingkurask = new ObjectClickHandler(new Object[] { 31363 }, Tile.of(3295, 4407, 0), e -> e.getPlayer().tele(Tile.of(2700, 9999, 0))); public static ObjectClickHandler handlepulsingmarkingcavecrawler = new ObjectClickHandler(new Object[] { 31363 }, Tile.of(3325, 4391, 0), e -> e.getPlayer().tele(Tile.of(2789, 9997, 0))); public static ObjectClickHandler handlepulsingmarkingbasilisk = new ObjectClickHandler(new Object[] { 31363 }, Tile.of(3294, 4293, 0), e -> e.getPlayer().tele(Tile.of(2743, 10009, 0))); public static ObjectClickHandler handlepulsingmarkingturoth = new ObjectClickHandler(new Object[] { 31363 }, Tile.of(3288, 4293, 0), e -> e.getPlayer().tele(Tile.of(2723, 10005, 0))); }" "package com.rs.game.content.world.areas.pollnivneach.npcs; @PluginEventHandler public class AliCat { public static NPCClickHandler handle = new NPCClickHandler(new Object[]{ 7784 }, new String[] { ""Talk-to"" }, e -> { Player player = e.getPlayer(); NPC npc = e.getNPC(); if (ItemDefinitions.getDefs(e.getPlayer().getEquipment().getNeckId()).getName().contains(""Catspeak"")) player.startConversation(new Dialogue() .addNPC(npc,HeadE.CAT_SHOUTING, ""Stop, stop. Silly human."") .addPlayer(HeadE.CONFUSED, ""Not now puss. I have important work to do."") .addSimple(""Ali Cat jumps at your feet four times, twice on each side; you pick up your feet on that side each time he does that."") .addNPC(npc,HeadE.CAT_SHOUTING, ""I said stop. Don't you understand?"") .addSimple(""Ali Cat runs in circles around you twice; you look around as he does so."") .addPlayer(HeadE.CONFUSED, ""Don't you have an owner or something? Get away!"") .addNPC(npc,HeadE.CAT_SHOUTING, ""I have no owner, for I am a free cat. Listen to me or die horribly!"") .addSimple(""Ali Cat jumps at your feet once, jumps down, then jumps at your head; you struggle for a brief moment, then let him go."") .addPlayer(HeadE.CONFUSED, ""Look, fleabag, I need to go down here to rescue a damsel in distress. I know it's dangerous."") .addNPC(npc,HeadE.CAT_SHOUTING, ""You think you can fight banshees while surrounded by smoke? More skilled folk than you have died horribly in there."") .addPlayer(HeadE.CONFUSED, ""Smoke and banshees? Well, I'm sure I'll prevail."") .addNPC(npc,HeadE.CAT_SHOUTING, ""Try wearing your earmuffs and a face mask at the same time, bonehead: it can't be done. You'd be as helpless as a newborn kitten thrown into the Fight Pit. Luckily, I know a solution to this problem."") .addPlayer(HeadE.CONFUSED, ""I suppose you'll have me travelling the globe on some epic quest?"") .addNPC(npc,HeadE.CAT_SHOUTING, ""Oh, no. All you need to do is seek out Catolax, a Slayer master who died ages ago, and have a chat with him. He was buried in the desert, so he may be hard to talk to."") .addPlayer(HeadE.CONFUSED, ""The desert's a big place, any better directions?"") .addNPC(npc,HeadE.CAT_SHOUTING, ""A deity told me to look near the ruins of Ullek. That's some-way east of what you humans call the Agility Pyramid. There are some old tombs in the valley walls there, which are only openable if you know the trick."") .addPlayer(HeadE.SKEPTICAL, ""Okay, the tombs east of the Agility Pyramid, talk to dead Slayer guy, learn the 'trick' and I can be off. Oh, and thanks, too."") .addNPC(npc,HeadE.CAT_SHOUTING, ""My pleasure. A warning: don't trust any redheads."") ); else player.startConversation(new Dialogue() .addNPC(npc,HeadE.CAT_SHOUTING, ""Meeeeow."") .addPlayer(HeadE.SKEPTICAL_THINKING, ""Ah yes, I can't understand you without my amulet of catspeak."") ); }); }" "package com.rs.game.content.world.areas.pollnivneach.npcs; @PluginEventHandler public class AliKebabs { public static NPCClickHandler HandleAliTheKebabSeller = new NPCClickHandler(new Object[]{ 1865 }, new String[] { ""Talk-to"" }, e -> { Player player = e.getPlayer(); NPC npc = e.getNPC(); player.startConversation(new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Hello."") .addNPC(npc, HeadE.HAPPY_TALKING, ""Hello. What can I do for you?"") .addPlayer(HeadE.CONFUSED, ""I don't know, what can you do for me?"") .addNPC(npc, HeadE.HAPPY_TALKING, ""Well, that depends."") .addPlayer(HeadE.CONFUSED, ""Depends on what?"") .addNPC(npc, HeadE.HAPPY_TALKING, ""It depends on whether you like kebabs or not."") .addPlayer(HeadE.CONFUSED, ""Why is that?"") .addNPC(npc, HeadE.HAPPY_TALKING, ""Seeing as I'm in the kebab construction industry, I mainly help people in need of a kebab."") .addPlayer(HeadE.CONFUSED, ""Well then, what kind of kebabs do you, er, construct?"") .addNPC(npc, HeadE.HAPPY_TALKING, ""I offer two different types of kebabs: the standard run- of-the-mill kebab seen throughout Gielinor and enjoyed by many an intoxicated dwarf, and my speciality, the extra-hot kebab. So which shall it be?"") .addOptions(options -> { if(!player.getInventory().hasCoins(3)) options.add(""I want a standard kebab, please."") .addPlayer(HeadE.SHAKING_HEAD, ""I seem to be short on coins. Sorry.""); else if (!player.getInventory().hasFreeSlots()) options.add(""I want a standard kebab, please."") .addNPC(npc, HeadE.SHAKING_HEAD, ""You do not have enough space to carry a kebab""); else options.add(""I want a standard kebab, please."") .addNPC(npc, HeadE.HAPPY_TALKING, ""That will be three gold coins."") .addNPC(npc, HeadE.HAPPY_TALKING, ""Here you go."") .addPlayer(HeadE.HAPPY_TALKING, ""Thanks. "") .addNext(() -> { if (player.getInventory().hasFreeSlots()) { player.getInventory().addItem(1971); player.getInventory().removeCoins(3); } }); if(!player.getInventory().hasCoins(5)) options.add(""Could I have an extra-hot kebab please?"") .addPlayer(HeadE.SHAKING_HEAD, ""I seem to be short on coins. Sorry.""); else if (!player.getInventory().hasFreeSlots()) options.add(""Could I have an extra-hot kebab please?"") .addNPC(npc, HeadE.SHAKING_HEAD, ""You do not have enough space to carry a kebab""); else options.add(""Could I have an extra-hot kebab please?"") .addNPC(npc, HeadE.HAPPY_TALKING, ""One super kebab coming up! Be careful, they really are as hot as they're made out to be."") .addPlayer(HeadE.HAPPY_TALKING, ""Sure, sure"") .addNext(() -> { if (player.getInventory().hasFreeSlots()) { player.getInventory().addItem(4608); player.getInventory().removeCoins(5); } }); }) ); }); }" "package com.rs.game.content.world.areas.pollnivneach.npcs; @PluginEventHandler public class AspAndSnake { public static NPCClickHandler HandleAliTheBarman = new NPCClickHandler(new Object[]{ 1864 }, new String[] { ""Talk-to"" }, e -> { Player player = e.getPlayer(); NPC npc = e.getNPC(); player.startConversation(new Dialogue() .addPlayer(HeadE.CALM_TALK, ""Hello there."") .addNPC(npc, HeadE.CALM_TALK, ""Good day. Can I help you with anything?"") .addOptions(options -> { options.add(""Yes, I'd like a drink please."", () -> ShopsHandler.openShop(e.getPlayer(), ""asp_and_snake"")); options.add(""What's going on in town?"") .addPlayer(HeadE.CALM_TALK, ""What's going on in town?"") .addNPC(npc, HeadE.CALM_TALK, ""Nothing much really. About what you'd expect from a sleepy little town like ours."") .addPlayer(HeadE.SKEPTICAL, ""What about those two gangs? That seems exciting."") .addNPC(npc,HeadE.FRUSTRATED, ""They're paying customers, so I won't rock the boat if you don't mind.""); options.add(""The 'Asp and Snake'? What a strange name for a bar."") .addPlayer(HeadE.CALM_TALK, ""The 'Asp and Snake'? What a strange name for a bar."") .addNPC(npc, HeadE.CALM_TALK, ""Maybe around these parts. Were you expecting it to have 'Ali' in the name?"") .addNPC(npc, HeadE.CALM_TALK, ""I did think about calling it 'Ali's', but then it'd get confused with the Camel Shop, the Kebab House, the Mayor's residence..."") .addPlayer(HeadE.CALM_TALK, ""Yes, I get your point. It's a perfectly fine name.""); }) ); }); public static NPCClickHandler HandleAliTheDrunk = new NPCClickHandler(new Object[]{1863}, new String[]{""Talk-to""}, e -> { Player player = e.getPlayer(); NPC npc = e.getNPC(); player.startConversation(new Dialogue() .addNPC(npc, HeadE.DRUNK, ""Ahh, a kind stranger. Get this old man another drink so that he may wet his throat and talk to you."") ); }); public static ItemOnNPCHandler HandleAliBeer = new ItemOnNPCHandler(new Object[]{1863}, e -> { Player player = e.getPlayer(); NPC npc = e.getNPC(); String[] responses = new String[]{ ""Wha'? Are you lookin' at me? Are you lookin' at me? You know something? You're drunk, you are."", ""Did you hear the one where the camel walks into the bar and orders a pint? The barman asks 'Why the long face!'."", ""Did you hear the one about the man who walked into a bar? He hurt his foot! Hah!"", ""I've got a lovely bunch of coconuts! Hehehe..."", ""What are you looking at?"", ""Why does nobody like me?"", ""You know, I have this friend, and she... I can't remember. What was I saying?"", ""Thank you my friend - now if you don't mind I'm having a conversation with my imaginary friend Ali here."", ""Cheers for the beers!"", ""I was a sailor once, you know..."" }; if (e.getItem().getId() == 1917) { player.getInventory().deleteItem(e.getItem()); player.startConversation(new Dialogue() .addNPC(npc, HeadE.DRUNK, responses[(Utils.random(1, 10))], () -> npc.forceTalk(""Burp"")) ); } else player.startConversation(new Dialogue() .addNPC(npc, HeadE.DRUNK_ANGRY, ""Eh? What's this? I don't want that, get me a beer."") ); }); }" "package com.rs.game.content.world.areas.pollnivneach.npcs; @PluginEventHandler public class MenaphiteThug { public static LoginHandler login = new LoginHandler(e -> { if (e.getPlayer().isQuestComplete(Quest.THE_FEUD)) { e.getPlayer().getVars().setVarBit(340, 2); } }); public static NPCClickHandler HandleMenaphiteThug = new NPCClickHandler(new Object[]{ 1903 }, new String[]{""Talk-to""}, e -> { Player player = e.getPlayer(); NPC npc = e.getNPC(); player.startConversation(new Dialogue() .addPlayer(HeadE.CALM_TALK, ""Hello."") .addNPC(npc, HeadE.FRUSTRATED, ""What do you want?"") .addPlayer(HeadE.CALM_TALK, ""Nothing really, I'm new to town and wanted to get to know the locals."") .addNPC(npc, HeadE.FRUSTRATED, ""I'm too busy for chitchat. Come back if you have some business to discuss with us."") ); }); }" "package com.rs.game.content.world.areas.pollnivneach.npcs; @PluginEventHandler public class PollnivneachGeneralStore { public static NPCClickHandler HandlePollnivneachGeneralStore = new NPCClickHandler(new Object[]{ 1866 }, new String[] { ""Talk-to"" }, e -> { Player player = e.getPlayer(); NPC npc = e.getNPC(); player.startConversation(new Dialogue() .addNPC(npc, HeadE.CALM_TALK, ""Are you in need of provisions?"") .addOptions(options -> { options.add(""Yes thank you."", () -> ShopsHandler.openShop(e.getPlayer(), ""pollnivneach_general_store"")); options.add(""No thanks.""); }) ); }); }" "package com.rs.game.content.world.areas.al_kharid; @PluginEventHandler public class AlKharid { public static PlayerStepHandler shantayPass = new PlayerStepHandler(new Tile[] { Tile.of(3303, 3116, 0), Tile.of(3303, 3117, 0), Tile.of(3305, 3116, 0), Tile.of(3305, 3117, 0) }, e -> { if (e.getStep().y == 3116 && e.getStep().dir == Direction.SOUTH) { if (!e.getPlayer().getInventory().containsItem(1854, 1)) { e.getPlayer().sendMessage(""You should check with Shantay for a pass.""); return; } e.getPlayer().getInventory().deleteItem(1854, 1); } e.getStep().setCheckClip(false); e.getPlayer().setRunHidden(false); WorldTasks.delay(3, () -> e.getPlayer().setRunHidden(true)); }); public static ObjectClickHandler clickShantayPass = new ObjectClickHandler(new Object[] { 12774 }, e -> e.getPlayer().sendMessage(""Walk on through with a pass!"")); public static ObjectClickHandler handleGates = new ObjectClickHandler(new Object[] { 35549, 35551 }, e -> { if (e.getPlayer().getInventory().hasCoins(10)) { e.getPlayer().getInventory().removeCoins(10); Doors.handleDoubleDoor(e.getPlayer(), e.getObject()); } else e.getPlayer().sendMessage(""You need 10 gold to pass through this gate.""); }); public static ObjectClickHandler handleStrykewyrmStile = new ObjectClickHandler(new Object[] { 48208 }, e -> AgilityShortcuts.climbOver(e.getPlayer(), e.getPlayer().transform(e.getPlayer().getX() < e.getObject().getX() ? 3 : -3, 0, 0))); public static ObjectClickHandler handleMiningSiteShortcut = new ObjectClickHandler(new Object[] { 9331, 9332 }, e -> { if (!Agility.hasLevel(e.getPlayer(), 38)) { e.getPlayer().sendMessage(""You need 38 agility""); return; } Player p = e.getPlayer(); WorldObject obj = e.getObject(); if(obj.getTile().matches(Tile.of(3306, 3315, 0)))//above p.forceMove(Tile.of(3303, 3315, 0), 2050, 10, 60); if(obj.getTile().matches(Tile.of(3304, 3315, 0)))//below p.forceMove(Tile.of(3307, 3315, 0), 2049, 10, 60); }); //brimhaven public static ObjectClickHandler handlebrimhavenstairs = new ObjectClickHandler(new Object[] { 45, 46 }, e -> { if (e.getObjectId() == 45) e.getPlayer().tele(e.getPlayer().transform(e.getObject().getRotation() == 2 ? -0 : e.getObject().getRotation() == 0 ? -0 : 0, e.getObject().getRotation() == 2 ? -4 : e.getObject().getRotation() == 0 ? 4 : 0, 1)); else if (e.getObjectId() == 46) e.getPlayer().tele(e.getPlayer().transform(e.getObject().getRotation() == 2 ? 0 : e.getObject().getRotation() == 0 ? -0 : 0, e.getObject().getRotation() == 2 ? 4 : e.getObject().getRotation() == 0 ? -4 : 0, -1)); }); }" "package com.rs.game.content.world.areas.al_kharid.npcs; //TODO Rouge Trader miniquest and add shops @PluginEventHandler public class AliMorrisan extends Conversation { //Identify NPC by ID private static final int npcId = 1862; public static NPCClickHandler AliMorrisan = new NPCClickHandler(new Object[]{npcId}, e -> { switch (e.getOption()) { case ""Talk-to"" -> e.getPlayer().startConversation(new AliMorrisan(e.getPlayer())); } }); public AliMorrisan(Player player) { super(player); addNPC(npcId,HeadE.SAD_CRYING, ""My friend!""); addNPC(npcId, HeadE.SAD_CRYING, ""Can you help me?""); addOptions(new Options() { @Override public void create() { option(""Sure, how can I help?"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Sure, how can I help?"") .addNPC(npcId, HeadE.SAD_CRYING, ""I have no more stock left!"") .addNPC(npcId, HeadE.SAD_CRYING, ""If you can find me a supplier of Blackjacks, Clothes, and Runes I will give you a discount!"") .addPlayer(HeadE.HAPPY_TALKING, ""I'll see what I can do."") ); option(""Not right now."", new Dialogue() .addPlayer(HeadE.CALM_TALK, ""Not right now."") ); } }); } }" "package com.rs.game.content.world.areas.al_kharid.npcs; @PluginEventHandler public class Faruq extends Conversation { //Identify NPC by ID private static final int npcId = 9159; public static NPCClickHandler Faruq = new NPCClickHandler(new Object[]{npcId}, e -> { switch (e.getOption()) { case ""Talk-to"" -> e.getPlayer().startConversation(new Faruq(e.getPlayer())); case ""Trade"" -> ShopsHandler.openShop(e.getPlayer(), ""faruqs_tools_for_games""); } }); public Faruq(Player player) { super(player); addNPC(npcId, HeadE.AMAZED, ""Hello! Have you come to sample my marvellous wares?""); addOptions(new Options() { @Override public void create() { option(""Yes, I'd like to see what you have."", new Dialogue() .addNext(() -> ShopsHandler.openShop(player, ""faruqs_tools_for_games""))); option(""Perhaps. Your stall has some odd-looking stuff; what are they for?"", new Dialogue() .addPlayer(HeadE.CALM_TALK, ""Perhaps. Your stall has some odd-looking stuff; what are they for?"") .addNPC(npcId, HeadE.HAPPY_TALKING, ""I sell them the tools to keep track of time, mark out places and routes, decide things randomly, even to hold great ballots of their group."") .addOptions(new Options() { @java.lang.Override public void create() { option(""Let me see, then."", new Dialogue() .addNext(() -> ShopsHandler.openShop(player, ""faruqs_tools_for_games""))); option(""These tools, are they complicated?"", new Dialogue() .addPlayer(HeadE.CALM_TALK, ""These tools, are they complicated?"") .addNPC(npcId, HeadE.CALM_TALK, ""No, "" + player.getDisplayName() +"", they are not complicated."") .addNPC(npcId, HeadE.CALM_TALK, ""I have a book that explains them, should you need."") .addNext(() -> ShopsHandler.openShop(player, ""faruqs_tools_for_games""))); option(""I don't think this is for me."", new Dialogue() .addPlayer(HeadE.CALM_TALK, ""I don't think this is for me."") .addNPC(npcId, HeadE.CALM_TALK, ""That is a shame. I shall be here if you change your mind."") ); } })); option(""No, thanks."", new Dialogue() .addPlayer(HeadE.CALM_TALK, ""No, thanks."") ); } }); } }" "package com.rs.game.content.world.areas.al_kharid.npcs; @PluginEventHandler public class Karim extends Conversation { //Identify NPC by ID private static final int npcId = 543; public static NPCClickHandler Karim = new NPCClickHandler(new Object[]{npcId}, e -> { switch (e.getOption()) { case ""Talk-to"" -> e.getPlayer().startConversation(new Karim(e.getPlayer())); } }); public Karim(Player player) { super(player); addNPC(npcId, HeadE.CALM_TALK, ""Would you like to buy a nice kebab? Only one gold.""); addOptions(new Options() { @Override public void create() { option(""I think I'll give it a miss."", new Dialogue() .addPlayer(HeadE.CALM_TALK, ""I think I'll give it a miss."") ); option(""Yes please."", new Dialogue() .addNext(() -> { if(player.getInventory().hasCoins(1)){ player.getInventory().removeCoins(1); player.getInventory().addItem(1971, 1); } else { addPlayer(HeadE.CALM_TALK, ""Oops, I forgot to bring any money with me.""); addNPC(npcId, HeadE.SCARED, ""Come back when you have some.""); } }) ); } }); } }" "package com.rs.game.content.world.areas.al_kharid.npcs; @PluginEventHandler public class Osman extends Conversation { private static final int npcId = 5282; public static NPCClickHandler Osman = new NPCClickHandler(new Object[]{npcId}, e -> { int convoID = 1; switch (e.getOption()) { case ""Talk-to"" -> e.getPlayer().startConversation(new Osman(e.getPlayer(), convoID)); } }); public Osman(Player player, int convoID) { super(player); if(convoID == 0) if (player.getInventory().containsOneItem(10848, 10849, 10850, 10851)) { addNext(new PlayerStatement(HeadE.CHEERFUL, ""I have some sq'irk juice for you."")); addNext(new Dialogue(new SimpleStatement(""Osman imparts some Thieving advice to you as a reward for the sq'irk juice.""), () -> { int totalXp = player.getInventory().getAmountOf(10851) * 350; totalXp += player.getInventory().getAmountOf(10848) * 1350; totalXp += player.getInventory().getAmountOf(10850) * 2350; totalXp += player.getInventory().getAmountOf(10849) * 3000; player.getInventory().deleteItem(10848, Integer.MAX_VALUE); player.getInventory().deleteItem(10849, Integer.MAX_VALUE); player.getInventory().deleteItem(10850, Integer.MAX_VALUE); player.getInventory().deleteItem(10851, Integer.MAX_VALUE); player.getSkills().addXp(Constants.THIEVING, totalXp); })); } else { addNext(new PlayerStatement(HeadE.CHEERFUL, ""Hi, I'd like to talk about sq'irks."")); addNext(new NPCStatement(convoID, HeadE.CHEERFUL, ""Alright, what would you like to know about sq'irks?"")); addNext(""SqOp"", new OptionStatement(""What would you like to know?"", ""Where can I find sq'irks?"", ""Why can't you get the sq'irks yourself?"", ""How should I squeeze the fruit?"", ""Is there a reward for getting these sq'irks?"", ""What's so good about sq'irk juice then?"")); getStage(""SqOp"") .addNext(new PlayerStatement(HeadE.CONFUSED, ""Where can I find sq'irks?"")) .addNext(new NPCStatement(convoID, HeadE.FRUSTRATED, ""There is a sorceress near the south eastern edge of Al Kharid who grows them. Once upon a time we considered each other friends."")) .addNext(new PlayerStatement(HeadE.CONFUSED, ""What happened?"")) .addNext(new NPCStatement(convoID, HeadE.FRUSTRATED, ""We fell out, and now she won't give me any more fruit."")) .addNext(new PlayerStatement(HeadE.CONFUSED, ""So all I have to do is ask her for some fruit for you?"")) .addNext(new NPCStatement(convoID, HeadE.NERVOUS, ""I doubt it will be that easy. She is not renowned for her generosity and is very secretive about her garden's location."")) .addNext(new PlayerStatement(HeadE.LAUGH, ""Oh come on, it should be easy enough to find!"")) .addNext(new NPCStatement(convoID, HeadE.SHAKING_HEAD, ""Her garden has remained hidden even to me - the chief spy of Al Kharid. I belive her garden must be hidden by magical means."")) .addNext(new PlayerStatement(HeadE.CHEERFUL, ""This should be an interesting task. How many sq'irks do you want?"")) .addNext(new NPCStatement(convoID, HeadE.CHEERFUL, ""I'll reward you as many as you can get your hands on but could you please squeeze the fruit into a glass first?"")) .addNext(getStage(""SqOp"")); getStage(""SqOp"") .addNext(new PlayerStatement(HeadE.CONFUSED, ""Why can't you get the sq'irks yourself?"")) .addNext(new NPCStatement(convoID, HeadE.FRUSTRATED, ""I may have mentioned that I had a falling out with Sorceress. Well, unsurprisingly, she refuses to give me any more of her garden's produce."")) .addNext(getStage(""SqOp"")); getStage(""SqOp"") .addNext(new PlayerStatement(HeadE.CONFUSED, ""How should I squeeze the fruit?"")) .addNext(new NPCStatement(convoID, HeadE.CHEERFUL, ""Use a pestle and mortal to squeeze the sq'irks. Make sure you have an empty glass with you to collect the juice."")) .addNext(getStage(""SqOp"")); getStage(""SqOp"") .addNext(new PlayerStatement(HeadE.CONFUSED, ""Is there a reward for getting these sq'irks?"")) .addNext(new NPCStatement(convoID, HeadE.LAUGH, ""Of course there is. I am a generous man. I'll teach you the art of Thieving for your troubles."")) .addNext(new PlayerStatement(HeadE.CONFUSED, ""How much training will you give?"")) .addNext(new NPCStatement(convoID, HeadE.CHEERFUL, ""That depends on the quantity and ripeness of the sq'irks you put into the juice."")) .addNext(getStage(""SqOp"")); getStage(""SqOp"") .addNext(new PlayerStatement(HeadE.CONFUSED, ""What's so good about sq'irk juice then?"")) .addNext(new NPCStatement(convoID, HeadE.LAUGH, ""Ah it's sweet, sweet nectar for a thief or spy; it makes light fingers lighter, fleet fleet flightier and comes in four different colours for those who are easily amused."")) .addNext(new SimpleStatement(""Osman starts salivating at the thought of sq'irk juice."")) .addNext(new PlayerStatement(HeadE.SKEPTICAL, ""It wouldn't have any addictive properties, would it?"")) .addNext(new NPCStatement(convoID, HeadE.CHEERFUL, ""It only holds power over those with poor self-control, something which I have an abundance of."")) .addNext(new PlayerStatement(HeadE.SKEPTICAL, ""I see."")) .addNext(getStage(""SqOp"")); } else addOptions(""Choose an option:"", new Options() { @Override public void create() { if(!player.isQuestComplete(Quest.PRINCE_ALI_RESCUE)) option(""About Prince Ali To The Rescue"", new Dialogue() //TODO Non-vanilla dialogue .addNext(()-> player.startConversation(new OsmanPrinceAliRescueD(player)))); option(""Sorcerer's Garden"", new Dialogue() .addNext(()-> player.startConversation(new Osman(player, 0).getStart()))); } }); create(); } }" "package com.rs.game.content.world.areas.al_kharid.npcs; @PluginEventHandler public class SilkTrader extends Conversation { //Identify NPC by ID private static final int npcId = 539; public static NPCClickHandler SilkTrader = new NPCClickHandler(new Object[]{npcId}, e -> { switch (e.getOption()) { case ""Talk-to"" -> e.getPlayer().startConversation(new SilkTrader(e.getPlayer())); } }); public SilkTrader(Player player) { super(player); addNPC(npcId, HeadE.AMAZED, ""Do you want to buy any fine silks?""); addOptions(new Options() { @Override public void create() { option(""How much are they?"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""How much are they?"") .addNPC(npcId,HeadE.HAPPY_TALKING, ""3 coins."") .addOptions(new Options() { @java.lang.Override public void create() { option(""3 coins sounds good."", new Dialogue() .addNext(() -> { if(player.getInventory().hasCoins(3)) { player.getInventory().removeCoins(3); player.getInventory().addItem(950, 1); } else{ addPlayer(HeadE.CALM_TALK, ""Oh dear. I don't have enough money.""); addNPC(npcId, HeadE.SCARED, ""Well, come back when you do have some money!""); } }) ); option(""No. That's too much for me."", new Dialogue() .addPlayer(HeadE.SHAKING_HEAD, ""No. That's too much for me."") .addNPC(npcId, HeadE.SAD, ""2 gp and that's as low as I'll go."") .addNPC(npcId, HeadE.SKEPTICAL, "" I'm not selling it for any less. You'll probably go and sell it in Varrock for a profit, anyway."") .addOptions(new Options() { @java.lang.Override public void create() { option(""2 coins sounds good."", new Dialogue() .addNext(() -> { if(player.getInventory().hasCoins(2)) { player.getInventory().removeCoins(2); player.getInventory().addItem(950, 1); } else{ addPlayer(HeadE.CALM_TALK, ""Oh dear. I don't have enough money.""); addNPC(npcId, HeadE.SCARED, ""Well, come back when you do have some money!""); } }) ); option(""No, really. I don't want it."", new Dialogue() .addPlayer(HeadE.SHAKING_HEAD, ""No, really. I don't want it.."") .addNPC(npcId, HeadE.SAD, ""Okay, but that's the best price you're going to get."") ); } })); } })); option(""No. Silk doesn't suit me."", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""No. Silk doesn't suit me."") ); } }); } }" "package com.rs.game.content.world.areas.ape_atoll; @ServerStartupEvent fun mapApeAtoll() { val ladders = mapOf( 4714 to Tile.of(2803, 9170, 0), 4743 to Tile.of(2803, 2725, 0), 4728 to Tile.of(2765, 2768, 0), 4889 to Tile.of(2748, 2767, 0) ) ladders.forEach { (objectId, toTile) -> onObjectClick(objectId) { (player) -> player.useLadder(toTile) } } onObjectClick(4773, 4779) { (player, obj) -> val deltaX = when(obj.rotation) { 0 -> if (obj.id == 4773) -2 else 2 3 -> 0 else -> 0 } val deltaY = when(obj.rotation) { 0 -> 0 3 -> if (obj.id == 4773) -2 else 2 else -> 0 } val deltaZ = if (obj.id == 4773) 1 else -1 player.tele(player.transform(deltaX, deltaY, deltaZ)) } onObjectClick(4859) { (player) -> player.prayer.worshipAltar() } }" "package com.rs.game.content.world.areas.ape_atoll; @PluginEventHandler public class Greegrees { // /** // * Edge cases // * 1. Taking entity damage ungreegree // * 2. Attacking ungree // * 3. Magic unavailable upon greegree // * 4. Upon teleport and full inventory drops to ground // */ // // private static final int[] greegrees = new int[]{4024, 4025, 4026, 4027, 4028, 4029, 4030, 4031}; // public static ItemClickHandler handleGreeGreeEquip = new ItemClickHandler(greegrees) { // @Override // public void handle(ItemClickEvent e) { // switch(e.getOption()) { // case ""Remove"": // Equipment.sendRemove(e.getPlayer(), Equipment.getItemSlot(e.getItem().getId())); // e.getPlayer().getAppearance().transformIntoNPC(-1); // break; // case ""Hold"": // if (e.getPlayer().isEquipDisabled()) // return; // if(!Areas.withinArea(""greegreeable"", e.getPlayer().getChunkId())) // e.getPlayer().sendMessage(""You attempt to use the monkey greegree but nothing happens""); // Equipment.sendWear(e.getPlayer(), e.getSlotId(), e.getItem().getId()); // break; // } // } // }; // // public static ItemEquipHandler handleNinjaGreeGree = new ItemEquipHandler(greegrees) { // @Override // public void handle(ItemEquipEvent e) { // int idx = e.getItem().getId()-4024; // if(Areas.withinArea(""greegreeable"", e.getPlayer().getChunkId())) // e.getPlayer().getAppearance().transformIntoNPC(1480+idx);//ninja monkey // } // }; // // public static EnterChunkHandler handleRemoveNPCAppearence = new EnterChunkHandler() { // @Override // public void handle(EnterChunkEvent e) { // if (e.getEntity() instanceof Player p && p.hasStarted()) // switch(p.getAppearance().getTransformedNPC()) { // case 1480://Small ninja // case 1481://Medium ninja // case 1482://Gorilla // case 1483: // case 1484: // case 1485://small zombie // case 1486://medium zombie // case 1487://karamja monkey // if (!Areas.withinArea(""greegreeable"", e.getPlayer().getChunkId())) { // p.getAppearance().transformIntoNPC(-1); // if(p.getInventory().hasFreeSlots()) // p.sendMessage(""The monkey greegree wrenches itself from your hand as its power begins to fade.""); // else // p.sendMessage(""The monkey greegree wrenches itself from your hand and drops to the ground as its power begins to fade.""); // } // default: // return; // } // } // }; }" "package com.rs.game.content.world.areas.ape_atoll.npcs; @PluginEventHandler public class Ifaba extends Conversation { private static final int npcId = 1436; public static NPCClickHandler Ifaba = new NPCClickHandler(new Object[]{npcId}, e -> { switch (e.getOption()) { case ""Talk-to"" -> e.getPlayer().startConversation(new Ifaba(e.getPlayer())); case ""Trade"" -> ShopsHandler.openShop(e.getPlayer(), ""ifaba_general_store""); } }); public boolean MonkeyEquipped() { int neckId = player.getEquipment().getNeckId(); int weaponId = player.getEquipment().getWeaponId(); if (neckId == -1 || weaponId == -1) return false; return ItemDefinitions.getDefs(neckId).getName().contains(""Monkeyspeak"") || ItemDefinitions.getDefs(weaponId).getName().contains(""Greegree""); //Greegree needs testing }; public Ifaba(Player player) { super(player); if (MonkeyEquipped()) { addNPC(npcId, HeadE.SECRETIVE, ""Would you like to buy or sell anything?""); addOptions(new Options() { @Override public void create() { option(""I'd like to see what you have for sale."", new Dialogue() .addNext(() -> ShopsHandler.openShop(player, ""ifaba_general_store""))); option(""No thanks."", new Dialogue() .addPlayer(HeadE.CONFUSED, ""No thanks."") ); } }); } else { addNPC(npcId,HeadE.FRUSTRATED,""Ook-ook! Eeek-aak-eek!""); create(); player.sendMessage(""You don't understand Ifaba.""); }; } }" "package com.rs.game.content.world.areas.ardougne; @PluginEventHandler public class Ardougne { public static NPCClickHandler handleSpiritOfScorpius = new NPCClickHandler(new Object[] { 492 }, e -> { boolean observatoryDone = e.getPlayer().isQuestComplete(Quest.OBSERVATORY_QUEST, ""to speak to Scorpius""); e.getPlayer().startConversation(new Dialogue() .addNextIf(() -> e.getPlayer().getEquipment().getAmuletId() != 552, new Dialogue() .addSimple(""This powerful spirit seems capable of speaking to you even though you are not wearing an Amulet of Ghostspeak."")) .addNPC(492, HeadE.OLD_CHAT, observatoryDone ? ""Who treads upon my grave?"" : ""How dare you disturb me!"") .addNextIf(() -> observatoryDone, new Dialogue().addOptions(ops -> { if (!e.getPlayer().getBool(""spiritOfScorpiusTalkedTo"")) { ops.add(""I seek your wisdom."") .addPlayer(HeadE.CALM_TALK, ""I seek your wisdom."") .addNPC(492, HeadE.OLD_CHAT, ""Indeed, I feel you have beheld the far places in the heavens."") .addNPC(492, HeadE.OLD_CHAT, ""My Lord instructs me to help you."") .addNPC(492, HeadE.OLD_CHAT, ""Here is a mould to make a token for our Lord;a mould for the unholy symbol of Zamorak."") .addItem(1594, ""The ghost gives you a casting mould."", () -> { e.getPlayer().save(""spiritOfScorpiusTalkedTo"", true); e.getPlayer().getInventory().addItemDrop(1594, 1); }); } else { Dialogue blessing = ops.add(""I have come to seek a blessing.""); if (!e.getPlayer().getInventory().containsItem(1722)) { blessing.addNPC(492, HeadE.OLD_CHAT, ""No blessings will be given to those who have no symbol of our Lord's love.""); } else { blessing.addNPC(492, HeadE.OLD_CHAT, ""I see you have the unholy symbol of our Lord. I will bless it for you."") .addSimple(""The ghost mutters in a strange voice."") .addSimple(""The unholy symbol throbs with power."", () -> e.getPlayer().getInventory().replace(1722, 1724)) .addNPC(492, HeadE.OLD_CHAT, ""The symbol of our Lord has been blessed with power!"") .addNPC(492, HeadE.OLD_CHAT, ""My master calls.""); } Dialogue mould = ops.add(""I need another unholy symbol mould.""); if (e.getPlayer().getInventory().containsItem(1594)) { mould.addNPC(492, HeadE.OLD_CHAT, ""One you already have, another is not needed.""); } else { mould.addNPC(492, HeadE.OLD_CHAT, ""To lose an object is easy to replace. To lose the affections of our Lord is impossible to forgive."") .addItem(1594, ""The ghost hands you another mould."", () -> e.getPlayer().getInventory().addItemDrop(1594, 1)); } } ops.add(""I have come to kill you."") .addPlayer(HeadE.ANGRY, ""I have come to kill you."") .addNPC(492, HeadE.OLD_CHAT, ""The might of mortals, to me, is as the dust to the sea.""); }))); }); public static NPCClickHandler handleBrotherOmad = new NPCClickHandler(new Object[] { 279 }, e -> e.getPlayer().startConversation(new BrotherOmadMonksFriendD(e.getPlayer()).getStart())); public static NPCClickHandler handleBrotherCedric = new NPCClickHandler(new Object[] { 280 }, e -> e.getPlayer().startConversation(new BrotherCedricMonksFriendD(e.getPlayer()).getStart())); public static NPCClickHandler handleTownCrier = new NPCClickHandler(new Object[] { 6138 }, e -> e.getPlayer().startConversation(new Conversation(e.getPlayer()) { { addNPC(e.getNPCId(), HeadE.CHEERFUL, ""Hello, what are you after?""); addOptions(""What would you like to say?"", new Options() { @Override public void create() { option(""About the Achievement System..."", () -> new AchievementSystemD(player, e.getNPCId(), SetReward.ARDOUGNE_CLOAK)); } }); create(); } })); private static void bank(Player p) { if(!p.getBank().checkPin()) return; p.getTempAttribs().setB(""open_zmi_collect"", false); p.getInterfaceManager().sendInterface(619); } private static void collect(Player p) { if(!p.getBank().checkPin()) return; p.getTempAttribs().setB(""open_zmi_collect"", true); p.getInterfaceManager().sendInterface(619); } public static NPCClickHandler handleZMIBanker = new NPCClickHandler(new Object[] { 6362 }, e -> { switch(e.getOption()) { case ""Bank""-> bank(e.getPlayer()); case ""Collect""-> collect(e.getPlayer()); case ""Talk-to""-> { int NPC = e.getNPCId(); e.getPlayer().startConversation(new Dialogue() .addNPC(NPC, HeadE.CALM_TALK, ""Well met, fellow adventurer! How can I help you?"") .addPlayer(HeadE.HAPPY_TALKING, ""Who are you?"") .addNPC(NPC, HeadE.CALM_TALK, ""How frightfully rude of me, my dear "" +e.getPlayer().getPronoun(""chap"", ""lady"") + "". My name is Eniola and I work for that most excellent enterprise, the Bank of Gielinor."") .addPlayer(HeadE.HAPPY_TALKING, ""If you work for the bank, what are you doing here?"") .addNPC(NPC, HeadE.CALM_TALK, ""My presence here is the start of a new enterprise of travelling banks."") .addNPC(NPC, HeadE.CALM_TALK, ""I can give you bank services for a price..."") .addPlayer(HeadE.HAPPY_TALKING, ""What price?"") .addNPC(NPC, HeadE.CALM_TALK, ""20 of any rune..."") .addNPC(NPC, HeadE.CALM_TALK, ""Would you like to bank or collect?"") .addOptions(""Choose an option:"", ops -> { ops.add(""Bank"", () -> { e.getPlayer().closeInterfaces(); bank(e.getPlayer()); }); ops.add(""Collect"", () -> { e.getPlayer().closeInterfaces(); collect(e.getPlayer()); }); ops.add(""Nevermind""); })); } } }); private static void checkRunesBankOrCollect(Player p, int runeId) { Item runes = new Item(runeId, 20); if(p.getInventory().containsItems(runes)) { p.getInventory().removeItems(runes); if(p.getTempAttribs().getB(""open_zmi_collect"")) GE.openCollection(p); else p.getBank().open(); } else { p.sendMessage(""You don't have enough "" + runes.getName() + ""s!""); p.closeInterfaces(); } } public static ButtonClickHandler handleZMIRunesInterface = new ButtonClickHandler(619, e -> { Player p = e.getPlayer(); switch(e.getComponentId()) { case 28 -> checkRunesBankOrCollect(p, 556); case 29 -> checkRunesBankOrCollect(p, 558); case 30 -> checkRunesBankOrCollect(p, 555); case 31 -> checkRunesBankOrCollect(p, 557); case 32 -> checkRunesBankOrCollect(p, 554); case 33 -> checkRunesBankOrCollect(p, 559); case 34 -> checkRunesBankOrCollect(p, 564); case 35 -> checkRunesBankOrCollect(p, 562); case 36 -> checkRunesBankOrCollect(p, 9075); case 37 -> checkRunesBankOrCollect(p, 563); case 38 -> checkRunesBankOrCollect(p, 560); case 39 -> checkRunesBankOrCollect(p, 565); case 40 -> checkRunesBankOrCollect(p, 561); case 41 -> checkRunesBankOrCollect(p, 566); } }); public static NPCClickHandler handleDrOrbon = new NPCClickHandler(new Object[] { 290 }, e -> e.getPlayer().startConversation(new Conversation(e.getPlayer()) { { addNPC(e.getNPCId(), HeadE.CHEERFUL, ""Hello, what are you after?""); addOptions(""What would you like to say?"", new Options() { @Override public void create() { option(""About the Achievement System..."", () -> new AchievementSystemD(player, e.getNPCId(), SetReward.ARDOUGNE_CLOAK)); } }); create(); } })); public static NPCClickHandler handleAleck = new NPCClickHandler(new Object[] { 5110 }, e -> { if (e.getOpNum() == 1) e.getPlayer().startConversation(new Conversation(e.getPlayer()) { { addNPC(e.getNPCId(), HeadE.CHEERFUL, ""Hello, what are you after?""); addOptions(""What would you like to say?"", new Options() { @Override public void create() { option(""Do you have anything for trade?"", () -> ShopsHandler.openShop(player, ""alecks_hunter_emporium"")); option(""About the Achievement System..."", () -> new AchievementSystemD(player, e.getNPCId(), SetReward.ARDOUGNE_CLOAK)); } }); create(); } }); else ShopsHandler.openShop(e.getPlayer(), ""alecks_hunter_emporium""); }); public static ObjectClickHandler handleZMIShortcut = new ObjectClickHandler(new Object[] { 26844, 26845 }, e -> { if (e.getObject().getId() == 26844) e.getPlayer().tele(Tile.of(3312, 4817, 0)); else if (e.getObject().getId() == 26845) e.getPlayer().tele(Tile.of(3308, 4819, 0)); }); public static ObjectClickHandler handleWitchahavenDungeonEntrance = new ObjectClickHandler(new Object[] { 18266 }, e -> { Player p = e.getPlayer(); p.tele(Tile.of(2696, 9683, 0)); }); public static ObjectClickHandler handleClockTowerDungeonEntrances = new ObjectClickHandler(new Object[] { 1754, 1756 }, new Tile[] { Tile.of(2566, 3242, 0), Tile.of(2566, 3231, 0), Tile.of(2569, 3231, 0), Tile.of(2566, 3227, 0), Tile.of(2569, 3227, 0), Tile.of(2572, 3227, 0), Tile.of(2621, 3261, 0) }, e -> e.getPlayer().useLadder(Tile.of(e.getObject().getX(), e.getObject().getY()+6399, 0))); public static ObjectClickHandler handleClockTowerDungeonExits = new ObjectClickHandler(new Object[] { 32015 }, new Tile[] { Tile.of(2566, 9642, 0), Tile.of(2572, 9631, 0), Tile.of(2566, 9631, 0), Tile.of(2566, 9627, 0), Tile.of(2569, 9627, 0), Tile.of(2572, 9627, 0), Tile.of(2576, 9655, 0), Tile.of(2621, 9661, 0) }, e -> e.getPlayer().useLadder(Tile.of(e.getObject().getX(), e.getObject().getY()-6399, 0))); public static ObjectClickHandler handleArdougneSewerEntrance = new ObjectClickHandler(new Object[] { ""Manhole"" }, e -> { Player p = e.getPlayer(); GameObject obj = e.getObject(); if(e.getOption().equalsIgnoreCase(""Open"")) { GameObject openedHole = new GameObject(obj.getId() + 1, obj.getType(), obj.getRotation(), obj.getX(), obj.getY(), obj.getPlane()); p.faceObject(openedHole); World.spawnObjectTemporary(openedHole, Ticks.fromMinutes(1)); } if(e.getOption().equalsIgnoreCase(""Climb-Down"")) if(obj.getTile().matches(Tile.of(2632, 3294, 0))) p.useStairs(833, Tile.of(2631, 9694, 0), 1, 2); }); public static ObjectClickHandler handleArdougneSewerExit = new ObjectClickHandler(new Object[] { 32015 }, e -> { Player p = e.getPlayer(); GameObject obj = e.getObject(); if(obj.getTile().matches(Tile.of(2632, 9694, 0))) p.ladder(Tile.of(2633, 3294, 0)); }); public static ObjectClickHandler handleWitchahavenDungeonExit = new ObjectClickHandler(new Object[] { 33246 }, e -> { Player p = e.getPlayer(); p.tele(Tile.of(2697, 3283, 0)); }); public static ObjectClickHandler handleClocktowerDungeonLadders = new ObjectClickHandler(new Object[] { 1755, 1756 }, e -> e.getPlayer().ladder(Tile.of(e.getPlayer().getX(), e.getPlayer().getY() + (e.getObjectId() == 1756 ? 6400 : -6400), 0))); public static ObjectClickHandler handleWestArdyPrisonStairs = new ObjectClickHandler(new Object[] { 2523, 2522 }, e -> e.getPlayer().useStairs(e.getPlayer().transform(0, e.getPlayer().getY() > 9000 ? -6400 : 6400, 0))); public static ObjectClickHandler handleLogBalanceShortcut = new ObjectClickHandler(new Object[] { 35997, 35999 }, e -> { if (!Agility.hasLevel(e.getPlayer(), 33)) return; AgilityShortcuts.walkLog(e.getPlayer(), e.getPlayer().transform(e.getObjectId() == 35999 ? -4 : 4, 0, 0), 3); }); public static ObjectClickHandler handleEnterUndergroundPass = new ObjectClickHandler(new Object[] { 36000 }, e -> e.getPlayer().tele(Tile.of(2312, 3217, 0))); public static NPCClickHandler handleDarkMage = new NPCClickHandler(new Object[] { 1001 }, e -> e.getPlayer().sendOptionDialogue(""Buy an Iban's staff for 100,000 gold?"", ops -> { ops.add(""Yes, I'll pay 100,000 gold for a staff."", () -> { if (e.getPlayer().getInventory().hasCoins(100000)) { e.getPlayer().getInventory().removeCoins(100000); e.getPlayer().getInventory().addItem(1409, 1); } else e.getPlayer().sendMessage(""You don't have enough money.""); }); ops.add(""No, that's too much.""); })); public static NPCClickHandler handleSilkTrader = new NPCClickHandler(new Object[] { 574 }, e -> { if (e.getOpNum() == 3) { e.getPlayer().sendOptionDialogue(""Exchange your silk for 20gp each?"", ops -> { ops.add(""Yes"", () -> { int number = e.getPlayer().getInventory().getAmountOf(950); e.getPlayer().getInventory().deleteItem(950, number); e.getPlayer().getInventory().addCoins(20 * number); }); ops.add(""No""); }); } }); public static ObjectClickHandler handleHouseDoors = new ObjectClickHandler(new Object[] { 34812 }, e -> { if (e.getOpNum() == ClientPacket.OBJECT_OP1) e.getPlayer().sendMessage(""This door is securely locked.""); else e.getPlayer().handleOneWayDoor(e.getObject(), 1, 3); }); public static ObjectClickHandler handleChaosDruidTowerDoor = new ObjectClickHandler(new Object[] { 2554 }, e -> { if (e.getOpNum() == ClientPacket.OBJECT_OP1) e.getPlayer().sendMessage(""This door is securely locked.""); else Doors.handleDoor(e.getPlayer(), e.getObject()); }); public static ObjectClickHandler handleEnterTempleOfIkov = new ObjectClickHandler(new Object[] { 1754 }, Tile.of(2677, 3405, 0), e -> e.getPlayer().useStairs(827, e.getPlayer().transform(0, 6400, 0), 1, 2)); public static ObjectClickHandler handleExitTempleOfIkov = new ObjectClickHandler(new Object[] { 32015 }, Tile.of(2677, 9805, 0), e -> e.getPlayer().useStairs(828, e.getPlayer().transform(0, -6400, 0), 1, 2)); public static ObjectClickHandler handleEnterBootsofLightnessRoom = new ObjectClickHandler(new Object[] { 35121 }, Tile.of(2650, 9804, 0), e -> e.getPlayer().useStairs(-1, e.getPlayer().transform(-8, -41, 0), 1, 2)); public static ObjectClickHandler handleExitBootsofLightnessRoom = new ObjectClickHandler(new Object[] { 96 }, Tile.of(2638, 9763, 0), e -> e.getPlayer().useStairs(-1, e.getPlayer().transform(8, 41, 0), 1, 2)); public static ObjectClickHandler handleLegendsGuildDoor = new ObjectClickHandler(new Object[] { ""Legends Guild door"" }, e -> e.getPlayer().handleOneWayDoor(e.getObject(), 1, 3)); public static ObjectClickHandler handleEnterLegendsGuildBasement = new ObjectClickHandler(new Object[] { 41425 }, e -> e.getPlayer().tele(e.getPlayer().transform(-3, 6400, 0))); public static ObjectClickHandler handleExitLegendsGuildBasement = new ObjectClickHandler(new Object[] { 32048 }, Tile.of(2717, 9773, 0), e -> e.getPlayer().tele(e.getPlayer().transform(3, -6400, 0))); public static ObjectClickHandler handleMournerTrapdoor = new ObjectClickHandler(new Object[] { 8783 }, e -> e.getPlayer().ladder(Tile.of(2044, 4649, 0))); public static ObjectClickHandler handleMournerBasementLadder = new ObjectClickHandler(new Object[] { 8785 }, e -> e.getPlayer().ladder(Tile.of(2543, 3327, 0))); public static ObjectClickHandler handleRangeGuildEnter = new ObjectClickHandler(false, new Object[] { 2514 }, e -> { if (e.getPlayer().getSkills().getLevelForXp(Constants.RANGE) <= 40) { e.getPlayer().sendMessage(""You require 40 Ranged to enter the Ranging Guild.""); return; } if (RouteFinderKt.routeEntityToTile(e.getPlayer(), Tile.of(2659, 3437, 0), 25).getSuccess()) e.getPlayer().setRouteEvent(new RouteEvent(Tile.of(2659, 3437, 0), () -> { Doors.handleDoor(e.getPlayer(), e.getObject()); e.getPlayer().addWalkSteps(Tile.of(2657, 3439, 0), 5, false); })); else e.getPlayer().setRouteEvent(new RouteEvent(Tile.of(2657, 3439, 0), () -> { Doors.handleDoor(e.getPlayer(), e.getObject()); e.getPlayer().addWalkSteps(Tile.of(2659, 3437, 0), 5, false); })); }); public static ObjectClickHandler handleNatureRuneChests = new ObjectClickHandler(new Object[] { 2567, 2568 }, e -> { if (e.getOpNum() == ClientPacket.OBJECT_OP2) Thieving.checkTrapsChest(e.getPlayer(), e.getObject(), 2574, 28, 21, 25, new Item(995, 3), new Item(561, 1)); }); public static ObjectClickHandler handleBloodRuneChests = new ObjectClickHandler(new Object[] { 2569 }, e -> { if (e.getOpNum() == ClientPacket.OBJECT_OP2) Thieving.checkTrapsChest(e.getPlayer(), e.getObject(), 2574, 59, 210, 250, new Item(995, 500), new Item(565, 2)); }); public static ObjectClickHandler handle50CoinChests = new ObjectClickHandler(new Object[] { 2566 }, e -> { if (e.getOpNum() == ClientPacket.OBJECT_OP2) Thieving.checkTrapsChest(e.getPlayer(), e.getObject(), 2574, 43, 50, 125, new Item(995, 50)); }); public static ObjectClickHandler handleClosedRangeGuildChests = new ObjectClickHandler(new Object[] { 375 }, e -> { if (e.getOpNum() == ClientPacket.OBJECT_OP1) { GameObject openedChest = new GameObject(378, e.getObject().getType(), e.getObject().getRotation(), e.getObject().getX(), e.getObject().getY(), e.getObject().getPlane()); e.getPlayer().faceObject(openedChest); e.getPlayer().setNextAnimation(new Animation(536)); e.getPlayer().lock(2); World.spawnObjectTemporary(openedChest, Ticks.fromSeconds(30)); } }); public static ObjectClickHandler handleOpenRangeGuildChests = new ObjectClickHandler(new Object[] { 378 }, e -> { if (e.getOpNum() == ClientPacket.OBJECT_OP2) { e.getPlayer().sendMessage(""You search the chest but find nothing.""); e.getPlayer().faceObject(e.getObject()); } else if (e.getOpNum() == ClientPacket.OBJECT_OP3) { e.getPlayer().faceObject(e.getObject()); e.getPlayer().setNextAnimation(new Animation(536)); e.getPlayer().lock(2); World.removeObject(e.getObject()); } }); //Legend's Guild public static ObjectClickHandler handleLegendsGuildstairs = new ObjectClickHandler(new Object[] { 41435, 41436 }, e -> { if (e.getObjectId() == 41435) e.getPlayer().tele(e.getPlayer().transform(e.getObject().getRotation() == 0 ? -0 : e.getObject().getRotation() == 3 ? -0 : 0, e.getObject().getRotation() == 0 ? 4 : e.getObject().getRotation() == 3 ? -0 : 0, 1)); else if (e.getObjectId() == 41436) e.getPlayer().tele(e.getPlayer().transform(e.getObject().getRotation() == 0 ? 0 : e.getObject().getRotation() == 3 ? -0 : 0, e.getObject().getRotation() == 0 ? -4 : e.getObject().getRotation() == 3 ? 3 : 0, -1)); }); //Clocktower public static ObjectClickHandler handleclocktowerspiralstairs = new ObjectClickHandler(new Object[] { 21871, 21872 }, e -> { if (e.getObjectId() == 21871) e.getPlayer().tele(e.getPlayer().transform(e.getObject().getRotation() == 0 ? -2 : e.getObject().getRotation() == 1 ? -2 : 0, e.getObject().getRotation() == 0 ? -2 : e.getObject().getRotation() == 1 ? 2 : 0, 1)); else if (e.getObjectId() == 21872) e.getPlayer().tele(e.getPlayer().transform(e.getObject().getRotation() == 0 ? 2 : e.getObject().getRotation() == 1 ? 2 : 0, e.getObject().getRotation() == 0 ? 2 : e.getObject().getRotation() == 1 ? -2 : 0, -1)); }); public static ObjectClickHandler handleclocktowerandMeiyerditchstairs = new ObjectClickHandler(new Object[] { 17974, 17975 }, e -> { if (e.getObjectId() == 17974) e.getPlayer().tele(e.getPlayer().transform(e.getObject().getRotation() == 1 ? 2 : e.getObject().getRotation() == 3 ? -2 : 0, e.getObject().getRotation() == 2 ? -2 : e.getObject().getRotation() == 0 ? 2 : 0, 1)); else if (e.getObjectId() == 17975) e.getPlayer().tele(e.getPlayer().transform(e.getObject().getRotation() == 1 ? -2 : e.getObject().getRotation() == 3 ? 2 : 0, e.getObject().getRotation() == 2 ? 2 : e.getObject().getRotation() == 0 ? -2 : 0, -1)); }); //Carnillean public static ObjectClickHandler handlecarnilleanstairsup = new ObjectClickHandler(new Object[] { 73418 }, e -> e.getPlayer().tele(Tile.of(2569, 3267, 1))); public static ObjectClickHandler handlecarnilleanstairsdown = new ObjectClickHandler(new Object[] { 73419 }, e -> e.getPlayer().tele(Tile.of(2568, 3269, 0))); public static ObjectClickHandler handlecarnilleankitchenstairsup = new ObjectClickHandler(new Object[] { 34829 }, e -> e.getPlayer().tele(Tile.of(2569, 3268, 0))); public static ObjectClickHandler handlecarnilleankitchenstairsdown = new ObjectClickHandler(new Object[] { 36703 }, e -> e.getPlayer().tele(Tile.of(2569, 9668, 0))); //Fight Arena public static ObjectClickHandler handlefightarenastairs = new ObjectClickHandler(new Object[] { 41121, 41122 }, e -> { if (e.getObjectId() == 41121) e.getPlayer().tele(e.getPlayer().transform(e.getObject().getRotation() == 1 ? 3 : e.getObject().getRotation() == 3 ? -3 : 0, e.getObject().getRotation() == 4 ? 3 : e.getObject().getRotation() == 2 ? -3 : 0, 1)); else if (e.getObjectId() == 41122) e.getPlayer().tele(e.getPlayer().transform(e.getObject().getRotation() == 1 ? -3 : e.getObject().getRotation() == 3 ? 3 : 0, e.getObject().getRotation() == 4 ? -3 : e.getObject().getRotation() == 2 ? 3 : 0, -1)); }); //West Ardougne public static ObjectClickHandler handlewestardougnespiralstairs = new ObjectClickHandler(new Object[] { 34388, 34390 }, e -> { if (e.getObjectId() == 34388) e.getPlayer().tele(e.getPlayer().transform(e.getObject().getRotation() == 0 ? 3 : e.getObject().getRotation() == 2 ? -3 : 0, e.getObject().getRotation() == 3 ? 3 : e.getObject().getRotation() == 1 ? -3 : 0, 1)); else if (e.getObjectId() == 34390) e.getPlayer().tele(e.getPlayer().transform(e.getObject().getRotation() == 0 ? -3 : e.getObject().getRotation() == 2 ? 3 : 0, e.getObject().getRotation() == 3 ? -3 : e.getObject().getRotation() == 1 ? 3 : 0, -1)); }); public static ObjectClickHandler handlewestardougnestairs = new ObjectClickHandler(new Object[] { 34397, 34398 }, e -> { if (e.getObjectId() == 34397) e.getPlayer().tele(e.getPlayer().transform(e.getObject().getRotation() == 1 ? 3 : e.getObject().getRotation() == 3 ? -3 : 0, e.getObject().getRotation() == 4 ? 3 : e.getObject().getRotation() == 2 ? -3 : 0, 1)); else if (e.getObjectId() == 34398) e.getPlayer().tele(e.getPlayer().transform(e.getObject().getRotation() == 1 ? -3 : e.getObject().getRotation() == 3 ? 3 : 0, e.getObject().getRotation() == 4 ? -3 : e.getObject().getRotation() == 2 ? 3 : 0, -1)); }); public static ObjectClickHandler handlehadleyspiralstairs = new ObjectClickHandler(new Object[] { 1738, 1740 }, e -> { if (e.getObjectId() == 1738) e.getPlayer().tele(e.getPlayer().transform(e.getObject().getRotation() == 2 ? 0 : e.getObject().getRotation() == 3 ? -0 : 0, e.getObject().getRotation() == 4 ? 0 : e.getObject().getRotation() == 1 ? -0 : 0, 1)); else if (e.getObjectId() == 1740) e.getPlayer().tele(e.getPlayer().transform(e.getObject().getRotation() == 2 ? -0 : e.getObject().getRotation() == 3 ? -0 : 0, e.getObject().getRotation() == 4 ? -0 : e.getObject().getRotation() == 1 ? -0 : 0, -1)); }); public static ObjectClickHandler handlehadleystairsup = new ObjectClickHandler(new Object[] { 2536 }, e -> e.getPlayer().tele(Tile.of(2517, 3426, 1))); public static ObjectClickHandler handlehadleystairsdown = new ObjectClickHandler(new Object[] { 2535 }, e -> e.getPlayer().tele(Tile.of(2516, 3423, 0))); //Observatory goblin kitchen dungeon-Note the stairs(25429) at (2335, 9350, 0) south of the ruin one is supposed to be a cutscene leading to the end of the quest but shares an ID public static ObjectClickHandler handlegoblinladderup = new ObjectClickHandler(new Object[] { 25429 }, e -> e.getPlayer().tele(Tile.of(2458, 3185, 0))); public static ObjectClickHandler handlegoblinladderdown = new ObjectClickHandler(new Object[] { 25432 }, e -> e.getPlayer().tele(Tile.of(2335, 9394, 0))); public static ObjectClickHandler handleObservatoryladderup = new ObjectClickHandler(new Object[] { 25431 }, e -> e.getPlayer().tele(Tile.of(2443, 3158, 1))); public static ObjectClickHandler handleObservatoryladderdown = new ObjectClickHandler(new Object[] { 25437 }, e -> e.getPlayer().tele(Tile.of(2444, 3162, 0))); }" "package com.rs.game.content.world.areas.ardougne; @PluginEventHandler public class LegendsGuild { public static ItemOnObjectHandler handleFountainOfHeroes = new ItemOnObjectHandler(new Object[] { 2938 }, null, e -> { if (isSkillsNeckOrCombatBrace(e.getItem().getId()) && !e.getItem().getName().toLowerCase().contains(""(4)"")) { for (Item item : e.getPlayer().getInventory().getItems().array()) if (item != null) if (isSkillsNeckOrCombatBrace(item.getId())) { int fullyChargedItemId = getChargedId(item.getId()); if (fullyChargedItemId != -1) { e.getPlayer().getInventory().replace(item, new Item(fullyChargedItemId)); e.getPlayer().anim(899); } } e.getPlayer().sendMessage(""You recharge some jewelry at the totem.""); } }); public static boolean isSkillsNeckOrCombatBrace(int itemId) { return (itemId == 11126) || (itemId == 11124) || (itemId == 11122) || (itemId == 11120) || (itemId == 11118) || (itemId == 11113) || (itemId == 11111) || (itemId == 11109) || (itemId == 11107) || (itemId == 11105); } public static int getChargedId(int itemId) { //Combat Bracelet if ((itemId == 11126) || (itemId == 11124) || (itemId == 11122) || (itemId == 11120)) return 11118; //Skills Necklace if ((itemId == 11113) || (itemId == 11111) || (itemId == 11109) || (itemId == 11107)) return 11105; return -1; } }" "package com.rs.game.content.world.areas.ardougne.npcs; @PluginEventHandler public class Aemad extends Conversation { //Identify NPC by ID private static final int npcId = 590; public static NPCClickHandler Aemad = new NPCClickHandler(new Object[]{npcId}, e -> { switch (e.getOption()) { case ""Talk-to"" -> e.getPlayer().startConversation(new Aemad(e.getPlayer())); case ""Trade-General-Store"" -> ShopsHandler.openShop(e.getPlayer(), ""aemads_adventuring_supplies""); } }); public Aemad(Player player) { super(player); addNPC(npcId, HeadE.SECRETIVE, ""Hello there. You've come to the right place if you're looking for adventurer's equipment.""); addOptions(new Options() { @Override public void create() { option(""Oh that sounds interesting.."", new Dialogue() .addNext(() -> ShopsHandler.openShop(player, ""aemads_adventuring_supplies""))); option(""No, I've come to the wrong place."", new Dialogue() .addPlayer(HeadE.CONFUSED, ""No, I've come to the wrong place."") .addNPC(npcId, HeadE.FRUSTRATED, ""Hmph. Well, perhaps next time you'll need something from me?"") ); } }); }; } /* This fixes Hank and restores default store conversation */" "package com.rs.game.content.world.areas.ardougne.npcs class BartenderFlyingHorseInn(p: Player, npc: NPC) { init { p.startConversation { npc(npc, HeadE.HAPPY_TALKING, ""Would you like to buy a drink?"") player(HeadE.CALM, ""What do you serve?"") npc(npc, HeadE.CHEERFUL_EXPOSITION, ""Beer!"") options { op(""I'll have a beer then."") { player(HeadE.HAPPY_TALKING, ""I'll have a beer then."") npc(npc, HeadE.HAPPY_TALKING, ""Ok, that'll be two coins."") exec { buyDrinkOrIngredients(p, npc, 2, Item(1917), true) } } op(""I'll not have anything then."") { player(HeadE.HAPPY_TALKING, ""I'll not have anything then"") } if (!isBarVisited(p, FLYING_HORSE_INN) && BarCrawl.hasCard(p) && onBarCrawl(p)) { op(""I'm doing Alfred Grimhand's Barcrawl"") { player(HeadE.HAPPY_TALKING, ""I'm doing Alfred Grimhand's Barcrawl."") npc(npc, HeadE.CHEERFUL, ""Fancy a bit of ${FLYING_HORSE_INN.drinkName}. It'll only be ${FLYING_HORSE_INN.price} coins."") exec { buyBarcrawlDrink(p, FLYING_HORSE_INN) } } } } } } } @ServerStartupEvent fun mapBartenderFlyingHorseInn() { onNpcClick(738) { (player, npc) -> BartenderFlyingHorseInn(player, npc) } }" "package com.rs.game.content.world.areas.ardougne.npcs; @PluginEventHandler public class Kortan extends Conversation { //Identify NPC by ID private static final int npcId = 591; public static NPCClickHandler Aemad = new NPCClickHandler(new Object[]{npcId}, e -> { switch (e.getOption()) { case ""Talk-to"" -> e.getPlayer().startConversation(new Kortan(e.getPlayer())); case ""Trade-General-Store"" -> ShopsHandler.openShop(e.getPlayer(), ""aemads_adventuring_supplies""); } }); public Kortan(Player player) { super(player); addNPC(npcId, HeadE.SECRETIVE, ""Hello there. You've come to the right place if you're looking for adventurer's equipment.""); addOptions(new Options() { @Override public void create() { option(""Oh that sounds interesting.."", new Dialogue() .addNext(() -> ShopsHandler.openShop(player, ""aemads_adventuring_supplies""))); option(""No, I've come to the wrong place."", new Dialogue() .addPlayer(HeadE.CONFUSED, ""No, I've come to the wrong place."") .addNPC(npcId, HeadE.FRUSTRATED, ""No, I've come to the wrong place."") ); } }); }; } /* This fixes Hank and restores default store conversation */" "package com.rs.game.content.world.areas.barbarian_village; @PluginEventHandler public class BarbarianVillage { }" "package com.rs.game.content.world.areas.barbarian_village.npcs; @PluginEventHandler public class BarbarianVillageNPC { private static final int CHEIFTAIN_GUNTHOR = 2876; private static final int GUDRUN = 2864; private static final int HAAKON = 3090; private static final int KJELL = 2872; private static final int LITARA = 4376; private static final int TASSIE_SLIPCAST = 1793; public static NPCClickHandler talkToBarbarians = new NPCClickHandler(new Object[]{3246, 3247, 3248, 3249, 3250, 3251, 3252, 3253, 3255, 3256, 3257, 3258, 3259, 3260, 3261, 3262, 3263}, new String[] { ""Talk-to"" }, e -> { String[] responses = new String[]{ ""Ah, you come for fight, ja?!"", ""You look funny!"", ""Wanna fight?"", ""Grrr!"", ""What you want?"", ""Go Away!"" }; e.getPlayer().startConversation(new Dialogue() .addNPC(e.getNPCId(), HeadE.VERY_FRUSTRATED, responses[(Utils.random(1,6))]) .addNext(() -> e.getNPC().setTarget(e.getPlayer())) ); }); public static NPCClickHandler talkToGunthor = new NPCClickHandler(new Object[]{ CHEIFTAIN_GUNTHOR }, new String[] { ""Talk-to"" }, e -> { String[] responses = new String[]{ ""Ah, you've come for fight!"", ""You look funny!"", ""Wanna fight?"", ""Grrr!"", ""What you want?"", ""Go Away!"" }; e.getPlayer().startConversation(new Dialogue() .addNPC(CHEIFTAIN_GUNTHOR, HeadE.VERY_FRUSTRATED, responses[(Utils.random(1,6))]) .addNext(() -> e.getNPC().setTarget(e.getPlayer())) ); }); public static NPCClickHandler HandleGudrun = new NPCClickHandler(new Object[]{ GUDRUN }, new String[] { ""Talk-to"" }, e -> { if (!Quest.GUNNARS_GROUND.isImplemented() || !e.getPlayer().getQuestManager().isComplete(Quest.GUNNARS_GROUND)) e.getPlayer().startConversation(new Dialogue() .addNPC(GUDRUN, HeadE.SKEPTICAL, ""Can I help you, stranger?"") .addNPC(KJELL, HeadE.ANGRY, ""Why are you talking to that outerlander?"") .addNPC(GUDRUN, HeadE.ANGRY, ""It's none of your business, Kjell! Just guard the hut!"") .addNPC(GUDRUN, HeadE.CALM_TALK, ""Sorry about that. Did you want something?"") .addOptions(ops -> { ops.add(""What is this place?"") .addPlayer(HeadE.CALM_TALK, ""What is this place?"") .addNPC(GUDRUN, HeadE.SKEPTICAL, ""Outerlanders call this the barbarian village. It doesn't have a name because... it's complicated."") .addNPC(GUDRUN, HeadE.CALM_TALK, ""If you wish to know more, you should talk to Hunding. He's up in the tower at the east entrance.""); ops.add(""Who are you?"") .addPlayer(HeadE.CALM_TALK, ""Who are you?"") .addNPC(GUDRUN, HeadE.CALM_TALK, ""My name is Gudrun. My father, Gunthor, is chieftain of the village.""); ops.add(""Goodbye."") .addPlayer(HeadE.CALM_TALK, ""Goodbye."") .addNPC(GUDRUN, HeadE.CALM_TALK, ""Goodbye.""); }) ); if (Quest.GUNNARS_GROUND.isImplemented() && e.getPlayer().getQuestManager().isComplete(Quest.GUNNARS_GROUND)) { e.getPlayer().startConversation(new Dialogue() .addNPC(GUDRUN, HeadE.HAPPY_TALKING, ""Hello!"") .addOptions(ops -> { ops.add(""I want to ask you something."") .addNPC(GUDRUN, HeadE.SKEPTICAL, ""Of course, what is it?"") .addOptions(ops2 -> { ops2.add(""How are things with Dororan?"") .addNPC(GUDRUN, HeadE.CALM_TALK, ""I really like him. He's funny, vulnerable and nothing like my people."") .addPlayer(HeadE.CONFUSED, ""You're going to stay together then?"") .addNPC(GUDRUN, HeadE.HAPPY_TALKING, ""Of course!""); ops2.add(""Where did this house come from?"") .addNPC(GUDRUN, HeadE.CALM_TALK, ""I don't know. Papa said the previous owners left it to him. I don't know why they would do that."") .addPlayer(HeadE.CONFUSED, ""Do you have a theory?"") .addNPC(GUDRUN, HeadE.HAPPY_TALKING, ""Gunnar always said 'A warrior does not barter; he simply takes!'. I think papa bought the house, but doesn't want anyone to know.""); ops2.add(""Did you like your present?"") .addNPC(GUDRUN, HeadE.HAPPY_TALKING, ""Look at this bracelet he got for me! 'With beauty blessed.' When I recited that line to papa, it took my breath away.""); ops2.add(""Goodbye."") .addNPC(GUDRUN, HeadE.CALM_TALK, ""Goodbye.""); }); ops.add(""Just passing through."") .addNPC(GUDRUN, HeadE.CALM_TALK, ""Goodbye.""); }) ); } }); public static NPCClickHandler talkToHaakon = new NPCClickHandler(new Object[]{ HAAKON }, new String[] { ""Talk-to"" }, e -> { if (!Quest.GUNNARS_GROUND.isImplemented() || !e.getPlayer().getQuestManager().isComplete(Quest.GUNNARS_GROUND)) e.getPlayer().startConversation(new Dialogue() .addNPC(HAAKON, HeadE.EVIL_LAUGH, ""I am Haakon, champion of this village. Do you seek to challenge me?"") .addOptions(ops -> { ops.add(""I challenge you!"") .addNPC(HAAKON, HeadE.EVIL_LAUGH, ""Make peace with your god, outerlander!"") .addNext(() -> e.getNPC().setTarget(e.getPlayer())); ops.add(""Er, no."") .addPlayer(HeadE.SHAKING_HEAD, ""Er, no.""); })); if (Quest.GUNNARS_GROUND.isImplemented() && e.getPlayer().getQuestManager().isComplete(Quest.GUNNARS_GROUND)) { e.getPlayer().startConversation(new Dialogue() .addNPC(HAAKON, HeadE.EVIL_LAUGH, ""I am Haakon, champion of this village. Do you seek to challenge me?"") .addOptions(ops -> { ops.add(""I challenge you!"") .addNPC(HAAKON, HeadE.EVIL_LAUGH, ""I am Haakon, champion of this village. Do you seek to challenge me?"") .addNext(() -> e.getNPC().setTarget(e.getPlayer())); ops.add(""Are you glad the village has settled finally?"") .addPlayer(HeadE.SHAKING_HEAD, ""I do as my chieftain commands. I respect his wisdom.""); ops.add(""Er, no."") .addPlayer(HeadE.SHAKING_HEAD, ""Er, no.""); }) ); } }); public static NPCClickHandler HandleKjell = new NPCClickHandler(new Object[]{ KJELL }, new String[] { ""Talk-to"" }, e -> { String[] responses = new String[]{ ""...love you like the stars above..."", ""...fall for pretty strangers..."", ""...but I'd do anything for you..."", ""...there's a place for us..."", ""...you exploded into my heart..."", ""...I dreamed your dream for you..."", ""...fall for chains of gold..."", ""...when you gonna realise..."" }; if (!Quest.GUNNARS_GROUND.isImplemented() || !e.getPlayer().getQuestManager().isComplete(Quest.GUNNARS_GROUND)) e.getPlayer().startConversation(new Dialogue() .addNPC(KJELL, HeadE.ANGRY, ""Get out of here, outerlander!"") .addOptions(ops -> { ops.add(""What is this place?"") .addPlayer(HeadE.CALM_TALK, ""What is this place?"") .addNPC(KJELL, HeadE.ANGRY, ""The barbarian village. Go away.""); ops.add(""Who are you?"") .addPlayer(HeadE.CALM_TALK, ""Who are you?"") .addNPC(KJELL, HeadE.ANGRY, ""My name is Kjell. Go away.""); ops.add(""What is in this hut that you're guarding?"") .addPlayer(HeadE.CALM_TALK, ""What is in this hut that you're guarding?"") .addNPC(KJELL, HeadE.ANGRY, ""Nothing yet. Once there is, no one will get in or out! Go away!""); ops.add(""Goodbye then.?"") .addPlayer(HeadE.CONFUSED, ""Goodbye then.""); })); if (Quest.GUNNARS_GROUND.isImplemented() && e.getPlayer().getQuestManager().isComplete(Quest.GUNNARS_GROUND)) { e.getPlayer().startConversation(new Dialogue() .addNPC(KJELL, HeadE.VERY_FRUSTRATED, responses[(Utils.random(1,8))]) .addNPC(KJELL, HeadE.ANGRY, ""Blast!"") .addOptions(ops -> { ops.add(""Having trouble there?"") .addPlayer(HeadE.HAPPY_TALKING,""Having trouble there?"") .addNPC(KJELL, HeadE.VERY_FRUSTRATED, ""I don't need the advice of an outerlander."") .addOptions(ops2-> { ops2.add(""This music isn't very restful."") .addPlayer(HeadE.HAPPY_TALKING,""This music isn't very restful."") .addNPC(KJELL, HeadE.ANGRY, ""Get out of here!""); ops2.add(""Maybe you should take some lessons."") .addPlayer(HeadE.HAPPY_TALKING,""Maybe you should take some lessons."") .addNPC(KJELL, HeadE.ANGRY, ""Get out of here!""); ops2.add(""I'll leave you in peace."") .addPlayer(HeadE.HAPPY_TALKING,""I'll leave you in peace."") .addNPC(KJELL, HeadE.ANGRY, ""Get out of here!""); }); ops.add(""I'll leave you in peace."") .addPlayer(HeadE.HAPPY_TALKING, ""I'll leave you in peace.""); }) ); } }); public static NPCClickHandler HandleLitara = new NPCClickHandler(new Object[]{ LITARA }, new String[] { ""Talk-to"" }, e -> e.getPlayer().startConversation(new Dialogue() .addNPC(LITARA, HeadE.SKEPTICAL, ""Hello there. You look lost - are you okay?"") .addOptions(ops -> { ops.add(""I'm looking for a stronghold, or something."") .addPlayer(HeadE.CALM_TALK, ""I'm looking for a stronghold, or something."") .addNPC(LITARA, HeadE.CALM_TALK, ""Ahh, the Stronghold of Security. It's down there."") .addPlayer(HeadE.NERVOUS, ""Looks kind of...deep and dark."") .addNPC(LITARA, HeadE.SKEPTICAL_THINKING, ""Yeah, tell that to my brother. He still hasn't come back."") .addPlayer(HeadE.CONFUSED, ""Your brother?"") .addNPC(LITARA, HeadE.SAD_MILD, ""He's a explorer too. When the miner fell down that hole he'd made and came back babbling about treasure, my brother went to explore. No one has seen him since."") .addPlayer(HeadE.SAD_MILD_LOOK_DOWN, ""Oh, that's not good."") .addNPC(LITARA, HeadE.SKEPTICAL_THINKING, ""Lots of people have been down there, but none of them have seen him. Let me know if you do, will you?\n"") .addPlayer(HeadE.HAPPY_TALKING, ""I'll certainly keep my eyes open.""); ops.add(""I'm fine, just passing through."") .addPlayer(HeadE.CALM_TALK, ""I'm fine, just passing through.""); }) )); public static NPCClickHandler HandleTassie= new NPCClickHandler(new Object[]{ TASSIE_SLIPCAST }, new String[] { ""Talk-to"" }, e -> e.getPlayer().startConversation(new Dialogue() .addNPC(TASSIE_SLIPCAST, HeadE.HAPPY_TALKING, ""Please feel free to use the pottery wheel, I won't be using it all the time. Put your pots in the kiln when you've made one."") .addNPC(TASSIE_SLIPCAST, HeadE.CALM_TALK, ""And make sure you tidy up after yourself!"") )); }" "package com.rs.game.content.world.areas.barbarian_village.npcs; public class Peska { public static NPCClickHandler handlePeskaBarbarianVillage = new NPCClickHandler(new Object[] { 538 }, e -> { int NPC= e.getNPCId(); if(e.getOption().equalsIgnoreCase(""talk-to"")) { e.getPlayer().startConversation(new Dialogue() .addNPC(NPC, HeadE.CALM_TALK, ""Are you interested in buying or selling a helmet?"") .addOptions(""Choose an option:"", new Options() { @Override public void create() { option(""I could be, yes."", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""I could be, yes."") .addNPC(NPC, HeadE.CALM_TALK, ""Let me show you my inventory then..."") .addNext(()-> ShopsHandler.openShop(e.getPlayer(), ""helmet_shop"")) ); option(""No, I'll pass on that."", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""No, I'll pass on that."") .addNPC(NPC, HeadE.CALM_TALK, ""Well, alright."") ); if(e.getPlayer().getQuestManager().getStage(Quest.SCORPION_CATCHER) == ScorpionCatcher.LOOK_FOR_SCORPIONS && e.getPlayer().getQuestManager().getAttribs(Quest.SCORPION_CATCHER).getB(""scorp2LocKnown"")) option(""I've heard you have a small scorpion in your possession."", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""I've heard you have a small scorpion in your possession."") .addNPC(NPC, HeadE.CALM_TALK, ""Now how could you know about that, I wonder? Mind you, I don't have it anymore."") .addNPC(NPC, HeadE.CALM_TALK, ""I gave it as a present to my brother Ivor when I visited our outpost northwest of Camelot."") .addNPC(NPC, HeadE.CALM_TALK, ""Well, actually I hid it in his bed so it would nip him. It was a bit of a surprise gift."") .addPlayer(HeadE.HAPPY_TALKING, ""Okay ill look at the barbarian outpost, perhaps you mean the barbarian agility area?"") .addNPC(NPC, HeadE.SECRETIVE, ""Perhaps..."") ); } }) ); } if(e.getOption().equalsIgnoreCase(""trade"")) ShopsHandler.openShop(e.getPlayer(), ""helmet_shop""); }); }" "package com.rs.game.content.world.areas.barbarian_village.npcs @ServerStartupEvent fun handleSigurd() { onNpcClick(3329) { e -> e.player.startConversation(CanoeD(e.player, e.npc)) } }" "package com.rs.game.content.world.areas.burthorpe; @PluginEventHandler public class Burthorpe { //Cutscenes //9 - morningstar jumping off the mountain into a house //10 - player ambushes a group of trolls with a group of jewish archers //11 - player gets given a weapon and rushes into the cave with ozan //12 - player fires cannon that breaks the walls down to cover the cave entrance public static ItemClickHandler handleWalkWithBabyTroll = new ItemClickHandler(new Object[] { 23030 }, new String[] { ""Walk with"" }, e -> e.getPlayer().getPetManager().spawnPet(e.getItem().getId(), true)); private static final Dialogue[] trollDialogues = { new Dialogue() .addNPC(14846, HeadE.T_CONFUSED, ""Dadda?"") .addPlayer(HeadE.CONFUSED, ""No, I'm not your dad."") .addNPC(14846, HeadE.T_CONFUSED, ""Momma?"") .addPlayer(HeadE.FRUSTRATED, ""No, I'm not your mother either!"") .addNPC(14846, HeadE.T_CONFUSED, ""Food?"") .addPlayer(HeadE.ANGRY, ""I am not food!"") .addNPC(14846, HeadE.T_SAD, ""I hungry."") .addPlayer(HeadE.LAUGH, ""Aren't you always?""), new Dialogue() .addNPC(14846, HeadE.T_CONFUSED, ""We fight?"") .addPlayer(HeadE.LAUGH, ""You're too young to fight!"") .addNPC(14846, HeadE.T_ANGRY, ""I big and scary!"") .addPlayer(HeadE.CALM_TALK, ""You have to eat a lot more vegetables first."") .addNPC(14846, HeadE.T_SAD, ""I no want to be named vegetable.""), new Dialogue() .addNPC(14846, HeadE.T_CONFUSED, ""Sleepy?"") .addPlayer(HeadE.LAUGH, ""Aww, little baby is sleepy?"") .addNPC(14846, HeadE.T_ANGRY, ""*Grrr*"") .addPlayer(HeadE.LAUGH, ""Uuu, I'm sooo scared."") .addNPC(14846, HeadE.T_ANGRY, ""I eat you!""), new Dialogue() .addNPC(14846, HeadE.T_CONFUSED, ""Food?"") .addPlayer(HeadE.CONFUSED, ""Is that all you think about? Food?"") .addNPC(14846, HeadE.T_ANGRY, ""Food!"") .addPlayer(HeadE.FRUSTRATED, ""I'll see what I can find.."") }; public static NPCClickHandler talkToBabyTroll = new NPCClickHandler(new Object[] { 14846 }, new String[] { ""Talk-to"" }, e -> e.getPlayer().startConversation(trollDialogues[Utils.random(trollDialogues.length)])); public static ObjectClickHandler handleCaveEntrance = new ObjectClickHandler(new Object[]{66876}, e -> e.getPlayer().tele(Tile.of(2292, 4516, 0))); public static ObjectClickHandler handleCaveExit = new ObjectClickHandler(new Object[]{67002}, e -> e.getPlayer().tele(Tile.of(2876, 3502, 0))); public static ObjectClickHandler handleCastleLockedDoor = new ObjectClickHandler(new Object[]{66967}, e -> e.getPlayer().sendMessage(""This door is securely locked"")); public static ObjectClickHandler handleCastleLadders = new ObjectClickHandler(new Object[]{66986, 66988}, e -> { switch (e.getObjectId()) { case 66986 -> e.getPlayer().ladder(Tile.of(e.getPlayer().getX(), e.getPlayer().getY() + 2, 2)); case 66988 -> e.getPlayer().ladder(Tile.of(e.getPlayer().getX(), e.getPlayer().getY() - 2, 0)); } }); public static ObjectClickHandler handleCastleStairs = new ObjectClickHandler(new Object[]{66971, 66970, 66972, 66969}, e -> { switch (e.getObjectId()) { case 66970 -> e.getPlayer().useStairs(Tile.of(e.getPlayer().getX(), e.getPlayer().getY() - 4, 2)); case 66971, 66969 -> e.getPlayer().useStairs(Tile.of(e.getPlayer().getX(), e.getPlayer().getY() + 4, 1)); case 66972 -> e.getPlayer().useStairs(Tile.of(e.getPlayer().getX(), e.getPlayer().getY() - 4, 0)); } }); public static ObjectClickHandler handleHeroesGuildDoors = new ObjectClickHandler(new Object[]{2624, 2625}, e -> { if (e.getPlayer().isQuestComplete(Quest.HEROES_QUEST) || e.getPlayer().getX() < e.getObject().getX()) { handleDoubleDoor(e.getPlayer(), e.getObject()); e.getPlayer().getMusicsManager().playSpecificAmbientSong(77, true); } else e.getPlayer().startConversation(new Conversation(e.getPlayer()) { final int NPC = 796; { addNPC(NPC, HeadE.FRUSTRATED, ""Hey! Only heroes are allowed in there.""); addPlayer(HeadE.SECRETIVE, ""Umm, how do I know if I am a hero?""); addNPC(NPC, HeadE.HAPPY_TALKING, ""By completing the Heroes' Quest of course""); addPlayer(HeadE.SAD, ""Oh..""); create(); } }); }); }" "package com.rs.game.content.world.areas.burthorpe; @PluginEventHandler public class CrystalChest { private final static Item[][] REWARDS = { { new Item(1631), new Item(1969), new Item(995, 2000) }, { new Item(1631) }, { new Item(1631), new Item(554, 50), new Item(556, 50), new Item(555, 50), new Item(557, 50), new Item(559, 50), new Item(558, 50), new Item(560, 10), new Item(561, 10), new Item(562, 10), new Item(563, 10), new Item(564, 10) }, { new Item(1631), new Item(2363, 10) }, { new Item(1631), new Item(454, 100) }, { new Item(1631), new Item(441, 150) }, { new Item(1631), new Item(1603, 2), new Item(1601, 2) }, { new Item(1631), new Item(371, 5), new Item(995, 1000) }, { new Item(1631), new Item(987), new Item(995, 750) }, { new Item(1631), new Item(985), new Item(995, 750) }, { new Item(1631), new Item(1183) }, { new Item(1631), new Item(1079), new Item(1093) } }; public static ItemOnObjectHandler handleKeyUse = new ItemOnObjectHandler(new Object[] { 172 }, new Object[] { 989 }, e -> openChest(e.getPlayer(), e.getObject())); public static ObjectClickHandler handleChest = new ObjectClickHandler(new Object[] { 172 }, e -> openChest(e.getPlayer(), e.getObject())); private static void openChest(Player player, GameObject object) { if (player.getInventory().containsItem(989)) { player.lock(); player.getInventory().deleteItem(989, 1); double random = Utils.random(0, 100); final int reward = random <= 39.69 ? 0 : random <= 56.41 ? 1 : random <= 64.41 ? 2 : random <= 67.65 ? 3 : random <= 74.2 ? 4 : random <= 76.95 ? 5 : random <= 81.18 ? 6 : random <= 91.75 ? 7 : random <= 95.01 ? 8 : random <= 98.68 ? 9 : random <= 99.74 ? 10 : 11; player.setNextAnimation(new Animation(536)); player.sendMessage(""You unlock the chest with your key.""); player.getTasks().schedule(1, () -> { GameObject openedChest = new GameObject(object.getId() + 1, object.getType(), object.getRotation(), object.getX(), object.getY(), object.getPlane()); World.spawnObjectTemporary(openedChest, 1); player.incrementCount(""Crystal chests opened""); player.sendMessage(""You find some treasure in the chest!""); for (Item item : REWARDS[reward]) player.getInventory().addItem(item.getId(), item.getAmount(), true); player.unlock(); }); } else player.sendMessage(""You need a crystal key to unlock this chest.""); } }" "package com.rs.game.content.world.areas.burthorpe; @PluginEventHandler public class HeroesGuild { public static ItemOnObjectHandler handleFountainOfHeroes = new ItemOnObjectHandler(new Object[] { 36695 }, null, e -> { if (isGloryOrROW(e.getItem().getId()) && !e.getItem().getName().toLowerCase().contains(""(4)"")) { for (Item item : e.getPlayer().getInventory().getItems().array()) if (item != null) if (isGloryOrROW(item.getId())) { int fullyChargedItemId = getChargedId(item.getId()); if (fullyChargedItemId != -1) { e.getPlayer().getInventory().replace(item, new Item(fullyChargedItemId)); e.getPlayer().anim(899); } } e.getPlayer().sendMessage(""You dip it into the fountain restoring all charges.""); } }); public static ObjectClickHandler handleLadders = new ObjectClickHandler(new Object[] { 67691, 67690 }, e -> { if (e.getObject().getId() == 67691) e.getPlayer().useLadder(Tile.of(2906, 3516, 0)); else if (e.getObject().getId() == 67690) e.getPlayer().useLadder(Tile.of(2893, 9907, 0)); }); public static boolean isGloryOrROW(int itemId) { return (itemId == 1704) || (itemId == 1706) || (itemId == 1708) || (itemId == 1710) || (itemId == 1712) || (itemId == 10354) || (itemId == 10356) || (itemId == 10358) || (itemId == 10360) || (itemId == 10362) || (itemId == 2572) || (itemId == 20653) || (itemId == 20655) || (itemId == 20657) || (itemId == 20659); } public static int getChargedId(int itemId) { //glory if ((itemId == 1704) || (itemId == 1706) || (itemId == 1708) || (itemId == 1710)) return 1712; //trimmed glory if ((itemId == 10356) || (itemId == 10358) || (itemId == 10360) || (itemId == 10362)) return 10354; //row if ((itemId == 2572) || (itemId == 20653) || (itemId == 20655) || (itemId == 20657)) return 20659; return -1; } }" "package com.rs.game.content.world.areas.burthorpe.npcs; @PluginEventHandler public class Ajjat extends Conversation { private static final int npcId = 4288; public static NPCClickHandler Ajjat = new NPCClickHandler(new Object[]{npcId}, e -> { switch (e.getOption()) { case ""Talk-to"" -> e.getPlayer().startConversation(new Ajjat(e.getPlayer())); } }); public Ajjat(Player player) { super(player); addNPC(npcId, HeadE.NO_EXPRESSION, ""Greetings, fellow warrior. I am Ajjat, former Black Knight and now training officer here in the Warriors' Guild.""); Dialogue options = addOption(""Select an option"", ""What is that cape you are wearing?"", ""Black Knight? Why are you here?"", ""What's the dummy room all about?""); options.addNext(Skillcapes.Attack.getOffer99CapeDialogue(player, npcId)); options.addPlayer(HeadE.CONFUSED, ""Black Knight? Why are you here?"") .addNPC(npcId, HeadE.NO_EXPRESSION, ""Indeed I was, however, their...methods did not match with my ideals, so I left. Harrallak, recognizing my talent as a warrior, took me in and offered me a job here."") .addPlayer(HeadE.NO_EXPRESSION, ""Hmm...well, if Harrallak trusts you, I guess I can.""); options.addPlayer(HeadE.CONFUSED, ""What's the Dummy Room all about?"") .addNPC(npcId, HeadE.CHEERFUL, ""Ahh yes, the dummies. Another ingenious invention of the noble dwarf, Gamfred. They're mechanical, you see, and pop up out of the floor. You have to hit them with the correct attack mode before they disappear again."") .addPlayer(HeadE.CONFUSED, ""So, how do I tell which one is which?"") .addNPC(npcId, HeadE.CHEERFUL, ""There are two different ways. One indication is their colour, the other is the pose and weapons they are holding, for instance, the one holding daggers you will need to hit with a piercing attack."") .addNPC(npcId, HeadE.CHEERFUL, ""In the room, you will find a poster on the wall to help you recognize each different dummy."") .addPlayer(HeadE.CHEERFUL, ""That sounds ingenious!"") .addNPC(npcId, HeadE.CHEERFUL, ""Indeed, you may find that you need several weapons to be successful all of the time, but keep trying. The weapons shop upstairs may help you there.""); create(); } }" "package com.rs.game.content.world.areas.burthorpe.npcs; @PluginEventHandler public class Anton extends Conversation { private static final int npcId = 4295; public static NPCClickHandler Anton = new NPCClickHandler(new Object[]{npcId}, e -> { switch (e.getOption()) { case ""Talk-to"" -> e.getPlayer().startConversation(new Anton(e.getPlayer())); case ""Trade"" -> ShopsHandler.openShop(e.getPlayer(), ""warrior_guild_armory""); //TODO Guild Armoury: Stabbing Weapons / Slashing Weapons / Crushing Weapons / Armour separation } }); public Anton(Player player) { super(player); addNPC(npcId, HeadE.HAPPY_TALKING, ""Ahhh, hello there. How can I help you?""); addPlayer(HeadE.CALM_TALK,""Looks like you have a good selection of weapons around here...""); addNPC(npcId, HeadE.CALM_TALK, ""Indeed so, specially imported from the finest smiths around the lands, take a look at my wares.""); addOptions(new Options() { @Override public void create() { option(""Okay, show me what you have."", new Dialogue() .addNext(() -> ShopsHandler.openShop(player, ""warrior_guild_armory""))); option(""I think I'll give it a miss."", new Dialogue() .addPlayer(HeadE.CALM_TALK, ""I think I'll give it a miss."") .addNPC(npcId, HeadE.HAPPY_TALKING, ""Okay, come back soon."") ); } }); } }" "package com.rs.game.content.world.areas.burthorpe.npcs; @PluginEventHandler public class CorporalBoothe { public static NPCClickHandler handleOps = new NPCClickHandler(new Object[] { 14921 }, e -> { switch(e.getOption()) { case ""Talk-to"" -> e.getPlayer().startConversation(new Dialogue() .addNPC(14921, HeadE.CONFUSED, ""Hello, sir. Can I help?"") .addOptions(ops -> { ops.add(""What do you do here?"") .addNPC(14921, HeadE.CALM_TALK, ""This area has been teeming with trolls ever since they broke through the barricades, so I've been stationed here by the Imperial Guard to help assist any new recruits."") .addNPC(14921, HeadE.CALM_TALK, ""I also buy and sell combat gear, so if there's anything you need just let me know.""); ops.add(""Can you give me combat advice?"") .addNPC(14921, HeadE.CALM_TALK, ""The best advice I can give is to always have some food with you, for healing."") .addNPC(14921, HeadE.CALM_TALK, ""There are farming patches, fishing spots and hunting areas in Taverly, to the south, that you can use.""); })); case ""Trade"" -> ShopsHandler.openShop(e.getPlayer(), ""burthorpe_guard_quartermaster""); } }); }" "package com.rs.game.content.world.areas.burthorpe.npcs; @PluginEventHandler public class Eadburg extends Conversation { private static final int npcId = 1072; public static NPCClickHandler Eadburg = new NPCClickHandler(new Object[] { npcId }, e -> { if (e.getOption().equalsIgnoreCase(""talk-to"")) { e.getPlayer().startConversation(new Eadburg(e.getPlayer())); } }); public Eadburg(Player player) { super(player); addPlayer(HeadE.HAPPY_TALKING, ""What's cooking?""); addNPC(npcId, HeadE.CALM_TALK, ""The stew for the servant's main meal.""); addPlayer(HeadE.CALM_TALK, ""Oh... Fair enough. See you later.""); addNPC(npcId, HeadE.CALM_TALK, ""Bye.""); create(); } }" "package com.rs.game.content.world.areas.burthorpe.npcs; @PluginEventHandler public class Eohric extends Conversation { private static final int npcId = 1080; public static NPCClickHandler Eohric = new NPCClickHandler(new Object[]{npcId}, e -> { switch (e.getOption()) { case ""Talk-to"" -> e.getPlayer().startConversation(new Eohric(e.getPlayer())); } }); public Eohric(Player player) { super(player); addNPC(npcId, HeadE.HAPPY_TALKING, ""Hello. Can I help?""); addOptions(new Options() { @Override public void create() { option(""What is this Place?"", new Dialogue() .addPlayer(HeadE.CONFUSED, ""What is this Place?"") .addNPC(npcId, HeadE.HAPPY_TALKING, ""This is Burthorpe Castle, home to His Royal Highness Prince Anlaf, heir to the throne of Asgarnia."") .addNPC(npcId, HeadE.HAPPY_TALKING, ""No doubt you're impressed."") .addOptions(new Options() { @Override public void create() { option(""Where is the prince?"", new Dialogue() .addNPC(npcId, HeadE.SHAKING_HEAD, "": I cannot disclose the prince's exact whereabouts for fear of compromising his personal safety."") .addNPC(npcId, HeadE.HAPPY_TALKING, "": But rest assured that he is working tirelessly to maintain the safety and wellbeing of Burthorpe's people."") ); option(""Goodbye."", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Goodbye"") .addNPC(npcId, HeadE.HAPPY_TALKING, ""Goodbye."") ); } }) ); option(""That's quite an outfit."", new Dialogue() .addPlayer(HeadE.CONFUSED, ""That's quite an outfit."") .addNPC(npcId, HeadE.HAPPY_TALKING, ""Make them I did, with magics."") .addPlayer(HeadE.CONFUSED, ""Magic, in the Warrior's Guild?"") .addNPC(npcId, HeadE.HAPPY_TALKING, ""A skilled warrior also am I. Harallak mistakes does not make. Potential in my invention he sees and opprotunity grasps."") .addPlayer(HeadE.CHEERFUL, ""I see, so you made the magical machines and Harrallak saw how they could be used in the guild to train warrior's combat... interesting. Harrallak certainly is an intellegent guy."") ); option(""Goodbye."", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Goodbye"") .addNPC(npcId, HeadE.HAPPY_TALKING, ""Goodbye."") ); } }); } }" "package com.rs.game.content.world.areas.burthorpe.npcs; @PluginEventHandler public class ImperialGuard extends Conversation { private static final int npcId = 1076; public static NPCClickHandler ImperialGuard = new NPCClickHandler(new Object[] { npcId }, e -> { if (e.getOption().equalsIgnoreCase(""talk-to"")) { e.getPlayer().startConversation(new ImperialGuard(e.getPlayer())); } }); public ImperialGuard(Player player) { super(player); String[] responses = new String[]{ ""Mihi ignosce. Cum homine de cane debeo congredi."", ""Errare humanum est."", ""Die dulci freure."", ""Carpe Diem!"", ""Te audire non possum. Musa sapientum fixa est in aure."", ""Furnulum pani nolo."", ""Fac ut gaudeam."", ""Utinam barbari spatium proprium tuum invadant!"", ""Quantum materiae materietur marmota monax si marmota monax materiam possit materiari?"", ""Sona si Latine loqueris."", ""Raptus Regaliter."", ""Nemo dat quod non habet."", ""Ne auderis delere orbem rigidum meum!"", ""Da mihi sis bubulae frustum assae, solana tuberosa in modo gallico fricta, ac quassum lactatum coagulatum crassum."", ""Cogito ergo sum."", ""Vacca foeda."", ""Di! Ecce hora! Uxor mea me necabit!"", ""Latine loqui coactus sum."", ""Cave ne ante ullas catapultas ambules."", ""Fac ut vivas!"", ""Noli me vocare, ego te vocabo."", ""Meliora cogito."", ""Braccae tuae aperiuntur."", ""Vescere bracis meis."", ""Corripe cervisiam!"" }; addPlayer(HeadE.HAPPY_TALKING, ""Hi!""); addNPC(npcId, HeadE.SHAKING_HEAD, responses[(Utils.random(25))]); switch (Utils.random(1,4)) { case 1 -> addPlayer(HeadE.CONFUSED, ""What?!""); case 2 -> addPlayer(HeadE.CONFUSED, ""Huh?!""); case 3 -> addPlayer(HeadE.CONFUSED, ""Er...""); case 4 -> addPlayer(HeadE.CONFUSED, ""OK...""); } if(Utils.random(100) <= 25) { addPlayer(HeadE.ANGRY, ""Wait! Are you insulting me in Latin?""); addNPC(npcId, HeadE.FRUSTRATED, ""Yes!""); addPlayer(HeadE.FRUSTRATED, ""Hmm...""); } create(); } }" "package com.rs.game.content.world.areas.burthorpe.npcs; @PluginEventHandler public class Jade extends Conversation { private static final int npcId = 4296; public Jade(Player player, NPC npc) { super(player); addNPC(npc.getId(), HeadE.CHEERFUL_EXPOSITION, ""Good day. How may I help you?""); addOptions(new Options() { @Override public void create() { option(""I'd like to access my bank account, please."", () -> player.getBank().open()); option(""I'd like to check my PIN settings."", () -> player.getBank().openPinSettings()); option(""I'd like to see my collection box."", () -> GE.openCollection(player)); option(""What is this place?"", new Dialogue() .addNPC(npc.getId(), HeadE.CHEERFUL_EXPOSITION, ""This is a branch of the Bank of Gielinor. We have branches in many towns."") .addOptions(new Options() { @Override public void create() { option(""And what do you do?"", new Dialogue() .addNPC(npc.getId(), HeadE.CHEERFUL_EXPOSITION, ""We will look after your items and money for you. Leave your valuables with us if you want to keep them safe."")); option(""Didn't you used to be called the Bank of Varrock?"", new Dialogue() .addNPC(npc.getId(), HeadE.CALM_TALK, ""Yes we did, but people kept on coming into our branches outside of Varrock and telling us that our signs were wrong. They acted as if we didn't know what town we were in or something."")); } })); option(""I'd like to change my theshold for valuable loot notifications."", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""I'd like to change my theshold for valuable loot notifications."") .addNPC(npc.getId(), HeadE.HAPPY_TALKING, ""Okay, your current threshold is "" + player.getI(""lootbeamThreshold"", 90000) + "" GP. What would you like to set it to?"") .addNext(() -> player.sendInputInteger(""What would you like to set it to?"", amount -> { if (amount < 0) return; player.save(""lootbeamThreshold"", amount); }))); } }); create(); } public static NPCInteractionDistanceHandler JadeDistance = new NPCInteractionDistanceHandler(new Object[] { npcId }, (player, npc) -> 1); public static NPCClickHandler JadeHandler = new NPCClickHandler(new Object[]{npcId}, e -> { switch (e.getOption()) { case ""Bank"": e.getPlayer().getBank().open(); break; case ""Collect"": GE.openCollection(e.getPlayer()); break; case ""Talk-to"": e.getPlayer().startConversation(new Jade(e.getPlayer(), e.getNPC())); break; } }); }" "package com.rs.game.content.world.areas.burthorpe.npcs; @PluginEventHandler public class Kaqemeex extends Conversation { private static final int npcId = 455; public static NPCClickHandler Kaqemeex = new NPCClickHandler(new Object[]{npcId}, e -> { switch (e.getOption()) { case ""Talk-to"" -> e.getPlayer().startConversation(new Kaqemeex(e.getPlayer())); } }); public Kaqemeex(Player player) { super(player); switch(player.getQuestManager().getStage(Quest.DRUIDIC_RITUAL)) { case 0: addPlayer(HeadE.CALM_TALK, ""Hello there.""); addNPC(npcId, HeadE.CALM_TALK, ""What brings you to our holy monument?""); addOptions(new Options() { @Override public void create() { option(""Who are you?"", new Dialogue() .addPlayer(HeadE.CALM_TALK, ""Who are you?"") .addNPC(npcId, HeadE.CALM_TALK, ""We are the druids of Guthix. We worship our god at our famous stone circles. You will find them located throughout these lands."") .addOptions(new Options() { @Override public void create() { option(""So what's so good about Guthix?"", new Dialogue() .addPlayer(HeadE.CALM_TALK, ""So what's so good about Guthix?"") .addNPC(npcId, HeadE.CALM_TALK, ""Guthix is the oldest and most powerful god in Gielinor. His existence is vital to this world. He is the god of balance, and nature; he is also a very part of this world."") .addNPC(npcId, HeadE.CALM_TALK, ""He exists in the trees, and the flowers, the water and the rocks. He is everywhere. His purpose is to ensure balance in everything in this world, and as such we worship him."") .addPlayer(HeadE.CALM_TALK, ""He sounds kind of boring..."") .addNPC(npcId, HeadE.CALM_TALK, ""Some day when your mind achieves enlightenment you will see the true beauty of his power."")); option(""Well, I'll be on my way now.""); } })); option(""I'm in search of a quest."", new Dialogue() .addPlayer(HeadE.CALM_TALK, ""I'm in search of a quest"") .addNPC(npcId, HeadE.CALM_TALK, ""Hmm. I think I may have a worthwhile quest for you actually. I don't know if you are familiar with the stone circle south of Varrock or not, but..."") .addPlayer(HeadE.CALM_TALK, ""What about the stone circle full of dark wizards?"") .addNPC(npcId, HeadE.CALM_TALK, ""That used to be OUR stone circle. Unfortunately, many many years ago, dark wizards cast a wicked spell upon it so that they could corrupt its power for their own evil ends."") .addNPC(npcId, HeadE.CALM_TALK, ""When they cursed the rocks for their rituals they made them useless to us and our magics. We require a brave adventurer to go on a quest for us to help purify the circle of Varrock."") .addOptions(new Options() { @Override public void create() { option(""Okay, I will try and help."", new Dialogue() .addPlayer(HeadE.CALM_TALK, ""Okay, I will try and help."") .addNPC(npcId, HeadE.CALM_TALK, ""Excellent. Go to the village south of this place and speak to my fellow "" + ""Sanfew who is working on the purification ritual. He knows better than I what is required to complete it."") .addPlayer(HeadE.CALM_TALK, ""Will do."") .addNext(()-> player.getQuestManager().setStage(Quest.DRUIDIC_RITUAL, 1))); option(""No, that doesn't sound very interesting."", ()->{}); } })); option(""What is that cape you're wearing?"", new Dialogue() .addNext(Skillcapes.Herblore.getOffer99CapeDialogue(player, npcId))); } }); break; case 1: case 2: addPlayer(HeadE.CALM_TALK, ""Hello there.""); addNPC(npcId, HeadE.CALM_TALK, ""What brings you to our holy monument?""); addOptions(new Options() { @Override public void create() { option(""Who are you?"", new Dialogue() .addPlayer(HeadE.CALM_TALK, ""Who are you?"") .addNPC(npcId, HeadE.CALM_TALK, ""We are the druids of Guthix. We worship our god at our famous stone circles. You will find them located throughout these lands."") .addOptions(new Options() { @Override public void create() { option(""So what's so good about Guthix?"", new Dialogue() .addPlayer(HeadE.CALM_TALK, ""So what's so good about Guthix?"") .addNPC(npcId, HeadE.CALM_TALK, ""Guthix is the oldest and most powerful god in Gielinor. His existence is vital to this world. He is the god of balance, and nature; he is also a very part of this world."") .addNPC(npcId, HeadE.CALM_TALK, ""He exists in the trees, and the flowers, the water and the rocks. He is everywhere. His purpose is to ensure balance in everything in this world, and as such we worship him."") .addPlayer(HeadE.CALM_TALK, ""He sounds kind of boring..."") .addNPC(npcId, HeadE.CALM_TALK, ""Some day when your mind achieves enlightenment you will see the true beauty of his power."")); option(""Well, I'll be on my way now.""); } })); option(""About druidic ritual"", new Dialogue() .addPlayer(HeadE.CALM_TALK, ""What did you want me to do again?"") .addNPC(npcId, HeadE.CALM_TALK, ""Go to the village south of this place and speak to my fellow "" + ""Sanfew who is working on the purification ritual. He knows better than I what is required to complete it."") .addPlayer(HeadE.CALM_TALK, ""Will do."")); option(""What is that cape you're wearing?"", new Dialogue() .addNext(Skillcapes.Herblore.getOffer99CapeDialogue(player, npcId))); } }); break; case 3: addPlayer(HeadE.CALM_TALK, ""Hello there.""); addNPC(npcId, HeadE.CALM_TALK, ""I have word from Sanfew that you have been very helpful in assisting him with his preparations for "" + ""the purification ritual. As promised I will now teach you the ancient arts of Herblore.""); addNext(()-> player.getQuestManager().completeQuest(Quest.DRUIDIC_RITUAL)); break; default: addPlayer(HeadE.CALM_TALK, ""Hello there.""); addOptions(new Options() { @Override public void create() { option(""Can you explain herblore?"", new Dialogue() .addNPC(npcId, HeadE.CALM_TALK, ""Herblore is the skill of working with herbs and other ingredients, to make useful potions and poison. "") .addNPC(npcId, HeadE.CALM_TALK, ""First you will need a vial, which can be found or made with the crafting skill. Then you must gather the herbs needed to make the potion you want."") .addNPC(npcId, HeadE.CALM_TALK, ""Refer to the Council's instructions in the Skills section of the website for the items needed to make a particular kind of potion. You must fill the vial with water and add the ingredients you need."") .addNPC(npcId, HeadE.CALM_TALK, ""There are normally 2 ingredients to each type of potion. Bear in mind, you must first identify each herb, to see what it is. You may also have to grind some herbs before you can use them."") .addNPC(npcId, HeadE.CALM_TALK, ""You will need a pestle and mortar in order to do this. Herbs can be found on the ground, and are also dropped by some monsters when you kill them. "") .addNPC(npcId, HeadE.CALM_TALK, ""Let's try an example Attack potion: The first ingredient is Guam leaf; the next is Eye of Newt. Mix these in your water-filled vial and you will produce an Attack potion. "") .addNPC(npcId, HeadE.CALM_TALK, ""Drink this potion to increase your Attack level. Different potions also require different Herblore levels before you can make them. "") .addNPC(npcId, HeadE.CALM_TALK, ""Once again, check the instructions found on the Council's website for the levels needed to make a particular potion.Good luck with your Herblore practices, Good day Adventurer."") .addPlayer(HeadE.CALM_TALK, ""Thanks for your help."")); option(""What is that cape you're wearing?"", new Dialogue() .addNext(Skillcapes.Herblore.getOffer99CapeDialogue(player, npcId))); } }); break; } create(); } }" "package com.rs.game.content.world.areas.burthorpe.npcs; @PluginEventHandler public class Lidio extends Conversation { private static final int npcId = 4293; public static NPCClickHandler Lidio = new NPCClickHandler(new Object[]{npcId}, e -> { switch (e.getOption()) { case ""Talk-to"" -> e.getPlayer().startConversation(new Lidio(e.getPlayer())); case ""Trade"" -> ShopsHandler.openShop(e.getPlayer(), ""warrior_guild_food_shop""); } }); public Lidio(Player player) { super(player); addNPC(npcId, HeadE.HAPPY_TALKING, ""Greetings, warrior, how can I fill your stomach today?""); addOptions(new Options() { @Override public void create() { option(""With food preferably."", new Dialogue() .addNext(() -> ShopsHandler.openShop(player, ""warrior_guild_food_shop""))); option(""I think I'll give it a miss."", new Dialogue() .addPlayer(HeadE.CALM_TALK, ""I think I'll give it a miss."") .addNPC(npcId, HeadE.HAPPY_TALKING, ""Okay, come back soon!"") ); } }); } }" "package com.rs.game.content.world.areas.burthorpe.npcs; @PluginEventHandler public class Lilly extends Conversation { private static final int npcId = 4294; public static NPCClickHandler Lilly = new NPCClickHandler(new Object[]{npcId}, e -> { switch (e.getOption()) { case ""Talk-to"" -> e.getPlayer().startConversation(new Lilly(e.getPlayer())); case ""Trade"" -> ShopsHandler.openShop(e.getPlayer(), ""warrior_guild_potion_shop""); } }); public Lilly(Player player) { super(player); addNPC(npcId, HeadE.SECRETIVE, ""Uh..... hi... didn't see you there. Can.... I help?""); addPlayer(HeadE.CONFUSED, ""Umm... do you sell potions?""); addNPC(npcId, HeadE.SECRETIVE, ""Erm... yes. When I'm not drinking them.""); addOptions(new Options() { @Override public void create() { option(""I'd like to see what you have for sale."", new Dialogue() .addNext(() -> ShopsHandler.openShop(player, ""warrior_guild_potion_shop""))); option(""That's a pretty wall hanging."", new Dialogue() .addPlayer(HeadE.CONFUSED, ""That's a pretty wall hanging."") .addPlayer(HeadE.HAPPY_TALKING, ""That's a pretty wall hanging."") .addNPC(npcId, HeadE.HAPPY_TALKING, ""Do you think so? I made it myself."") .addPlayer(HeadE.CONFUSED, ""Really? Is that why there's all this cloth and dye around?"") .addNPC(npcId, HeadE.HAPPY_TALKING, ""Yes, it's a hobby of mine when I'm.... relaxing."") ); option(""Bye."", new Dialogue() .addPlayer(HeadE.CALM_TALK, ""Bye."") .addNPC(npcId, HeadE.HAPPY_TALKING, ""Have fun and come back soon!"") ); } }); } }" "package com.rs.game.content.world.areas.burthorpe.npcs; @PluginEventHandler public class Servant extends Conversation { private static final int npcId = 1081; public static NPCClickHandler Servant = new NPCClickHandler(new Object[]{npcId}, e -> { switch (e.getOption()) { case ""Talk-to"" -> e.getPlayer().startConversation(new Servant(e.getPlayer())); } }); public Servant(Player player) { super(player); addPlayer(HeadE.HAPPY_TALKING, ""Hi!""); addNPC(npcId, HeadE.HAPPY_TALKING, ""Hi!""); addNPC(npcId,HeadE.SKEPTICAL_HEAD_SHAKE,""Look, I'd better not talk. I'll get in trouble.""); addNPC(npcId, HeadE.CALM_TALK, ""If you want someone to show you round the castle ask Eohric, the Head Servant.""); create(); } }" "package com.rs.game.content.world.areas.burthorpe.npcs; @PluginEventHandler public class Shanomi extends Conversation { private static final int npcId = 4290; public Shanomi(Player player) { super(player); addNPC(npcId, HeadE.HAPPY_TALKING, ""Greetings "" + player.getDisplayName() + "" Welcome you are in the test of combat.""); Dialogue option = addOption(""What do I do here?"", ""What do I do here?"", ""Where do the machines come from?"", ""Bye!""); option.addPlayer(HeadE.CONFUSED, ""What do I do here?"") .addNPC(npcId, HeadE.HAPPY_TALKING, ""A spare suit of armor need you will. Full helm, plate leggings and platebody yes? Placing it in the centre of the magical machines you will be doing. KA-POOF! The armor, it attaks its most furiously as if alive! Kill it you must, yes."") .addPlayer(HeadE.CONFUSED, ""So I use a full set of plate armor on the centre plate of the machines and it will animate it? Then I have to kill my own armor... how bizzare!"") .addNPC(npcId, HeadE.HAPPY_TALKING, ""Yes. It is as you are saying. For this earn tokens you will. Also gain experience in combat you will. Trained long and hard here have I."") .addPlayer(HeadE.CHUCKLE, ""Your not from around here are you?"") .addNPC(npcId, HeadE.HAPPY_TALKING, ""Yes. It is as you say."") .addPlayer(HeadE.CONFUSED, ""So can my armor get damaged?"") .addNPC(npcId, HeadE.HAPPY_TALKING, ""Lose armor you will if damaged too much it becomes. Rare this is, but still possible. If kill you the armor does, also lose armor you will."") .addPlayer(HeadE.CONFUSED, ""So, occasionally I might lose a bit because it's being bashed about and I'll obviously lose it if I die... that it?"") .addNPC(npcId, HeadE.HAPPY_TALKING, ""It is as you say."") .addNext(option); option.addPlayer(HeadE.CONFUSED, ""Where do the machines come from?"") .addNPC(npcId, HeadE.HAPPY_TALKING, ""Make them I did, with magics."") .addPlayer(HeadE.CONFUSED, ""Magic, in the Warrior's Guild?"") .addNPC(npcId, HeadE.HAPPY_TALKING, ""A skilled warrior also am I. Harallak mistakes does not make. Potential in my invention he sees and opprotunity grasps."") .addPlayer(HeadE.CHEERFUL, ""I see, so you made the magical machines and Harrallak saw how they could be used in the guild to train warrior's combat... interesting. Harrallak certainly is an intellegent guy."") .addNext(option); option.addNPC(npcId, HeadE.HAPPY_TALKING, ""Health be with you travelling.""); } }" "package com.rs.game.content.world.areas.burthorpe.npcs; @PluginEventHandler public class TamMcGrubor extends Conversation { private static final int npcId = 14414; public TamMcGrubor(Player player) { super(player); addNPC(npcId, HeadE.SECRETIVE, ""You interested in Runecrafting buddy?.. You wanna get some of that wicked action?"") .addOptions(ops -> { ops.add(""No thanks.. You seem a little sketchy to me \""buddy\"".."") .addPlayer(HeadE.CONFUSED, ""No thanks.. You seem a little sketchy to me \""buddy\""..""); ops.add(""Sure, give me one of those things."") .addPlayer(HeadE.CHEERFUL, ""Sure, give me one of those things."") .addNPC(npcId, HeadE.SECRETIVE, ""Alright son. Go ahead and take it. It recharges its power each day."") .addItem(22332, ""Tam hands you a wicked hood."", () -> player.getInventory().addItem(22332, 1)); }); create(); } public static NPCClickHandler TamMcGruborHandler = new NPCClickHandler(new Object[] { npcId }, e -> { if (e.getOption().equalsIgnoreCase(""talk-to"")) e.getPlayer().startConversation(new TamMcGrubor(e.getPlayer())); }); }" "package com.rs.game.content.world.areas.burthorpe.npcs; @PluginEventHandler public class WoundedSoldier extends Conversation { public WoundedSoldier(Player player) { super(player); String[] whatHappened = new String[]{ ""Troll bite. There's always a fever after you've been bitten by one of those. I'm sure they don't clean their teeth."", ""What happened to me is nothing compared to what's gonna happen to the filthy Troll who did it. When I'm out of here, I'm gonna find him and fix him good."", ""Trolls. I was on patrol on the Plateau, but those Trollheim scumbags jumped me from behind and hit me with a big stick."", ""He broke my bones... my blood... my everything!"", }; addPlayer(HeadE.SCARED, ""What happened to you?""); addNPC(15022, HeadE.SAD_CRYING, whatHappened[(Utils.random(1, 4))]); addPlayer(HeadE.NERVOUS,""I think I'd better leave you to recover.""); create(); } public static NPCClickHandler WoundedSoldierHandler = new NPCClickHandler(new Object[] { 15019,15021,15022,15023,15024,15025,15026,15027,15028,15029,15030,15031,15033 }, e -> { if(e.getOption().equalsIgnoreCase(""talk-to"")){ e.getNPC().resetDirection(); e.getPlayer().startConversation(new WoundedSoldier(e.getPlayer())); } }); }" "package com.rs.game.content.world.areas.burthorpe.npcs.announcers; @PluginEventHandler public class AntonWorld extends NPC { private static final int npcId = 4295; public AntonWorld(int id, Tile tile) { super(id, tile); } @Override public void processNPC() { super.processNPC(); if (Utils.random(50) == 0) setNextForceTalk(new ForceTalk(""Imported weapons from the finest smithys around the lands!"")); if (Utils.random(50) == 25) setNextForceTalk(new ForceTalk(""Ow my toe! That armour is heavy."")); if (Utils.random(50) == 50) setNextForceTalk(new ForceTalk(""Armour and axes to suit your needs."")); } public static NPCInstanceHandler toFunc = new NPCInstanceHandler(new Object[] { npcId }, AntonWorld::new); }" "package com.rs.game.content.world.areas.burthorpe.npcs.announcers; @PluginEventHandler public class LidioWorld extends NPC { private static final int npcId = 4293; public LidioWorld(int id, Tile tile) { super(id, tile); } @Override public void processNPC() { super.processNPC(); if (Utils.random(50) == 0) setNextForceTalk(new ForceTalk(""Potatoes are filling and healthy too!"")); if (Utils.random(50) == 25) setNextForceTalk(new ForceTalk(""Come try my lovely pizza or maybe some fish!"")); if (Utils.random(50) == 50) setNextForceTalk(new ForceTalk(""Stew to fill the belly, on sale here!"")); } public static NPCInstanceHandler toFunc = new NPCInstanceHandler(new Object[] { npcId }, LidioWorld::new); }" "package com.rs.game.content.world.areas.burthorpe.npcs.announcers; @PluginEventHandler public class ShanomiWorld extends NPC { private static final int npcId = 4290; public ShanomiWorld(int id, Tile tile) { super(id, tile); } @Override public void processNPC(){ super.processNPC(); if(Utils.random(0, 100) == 0) { //TODO add a lock to ensure this cannot collide with itself. WorldTasks.scheduleTimer(1, tick -> { //8 seconds based on 0.6 TPS if (tick >= 10 * 13) return false; if (tick == 0) { setNextForceTalk(new ForceTalk(""Think not dishonestly."")); } else if (tick == 13) { setNextForceTalk(new ForceTalk(""The Way in training is."")); } else if (tick == 2 * 13) { setNextForceTalk(new ForceTalk(""Acquainted with every art become."")); } else if (tick == 3 * 13) { setNextForceTalk(new ForceTalk(""Ways of all professions know you."")); } else if (tick == 4 * 13) { setNextForceTalk(new ForceTalk(""Gain and loss between you must distinguish."")); } else if (tick == 5 * 13) { setNextForceTalk(new ForceTalk(""Judgment and understanding for everything develop you must."")); } else if (tick == 6 * 13) { setNextForceTalk(new ForceTalk(""Those things which cannot be seen, perceive them."")); } else if (tick == 7 * 13) { setNextForceTalk(new ForceTalk(""Trifles pay attention even to."")); } else if (tick == 8 * 13) { setNextForceTalk(new ForceTalk(""Do nothing which is of no use."")); } else if (tick == 9 * 13) { setNextForceTalk(new ForceTalk(""Way of the Warrior this is."")); } return true; }); } } public static NPCInstanceHandler toFunc = new NPCInstanceHandler(new Object[] { npcId }, ShanomiWorld::new); }" "package com.rs.game.content.world.areas.burthorpe.npcs.announcers; @PluginEventHandler public class WoundedSoldierWorld extends NPC { public WoundedSoldierWorld(int id, Tile tile) { super(id, tile); } @Override public void processNPC() { super.processNPC(); if (Utils.random(50) == 0){ CallForHelp(); } } public void CallForHelp() { switch (Utils.random(1, 6)) { case 1 -> setNextForceTalk(new ForceTalk(""My duodenum!"")); case 2 -> setNextForceTalk(new ForceTalk(""My spleen!"")); case 3 -> setNextForceTalk(new ForceTalk(""Medic!"")); case 4 -> setNextForceTalk(new ForceTalk(""Gods, all my organs hurt!"")); case 5 -> setNextForceTalk(new ForceTalk(""So much pain!"")); case 6 -> setNextForceTalk(new ForceTalk(""Urgh... my pancreas!"")); } } public static NPCInstanceHandler toFunc = new NPCInstanceHandler(new Object[] { 15019,15021,15022,15023,15024,15025,15026,15027,15028,15029,15030,15031,15033 }, WoundedSoldierWorld::new); }" "package com.rs.game.content.world.areas.camp_tyras; @PluginEventHandler public class Quatermaster extends Conversation { private static final int npcId = 1208; public static NPCClickHandler Quatermaster = new NPCClickHandler(new Object[]{ npcId }, e -> { switch (e.getOption()) { case ""Talk-to"" -> e.getPlayer().startConversation(new Quatermaster(e.getPlayer())); } }); public Quatermaster(Player player) { super(player); addNPC(npcId, HeadE.HAPPY_TALKING, ""Good day "" + player.getPronoun(""Sir"",""Miss"") +"". I'm the quartermaster for King Tyras's camp. We have a little we could trade here. "" + ""We have a new stock of dragon halberds. Would you like a look at what we have now?""); addOptions(new Options() { @Override public void create() { option(""Yes please. What are you selling?"", new Dialogue() .addNext(() -> ShopsHandler.openShop(player, ""quartermasters_stores""))); option(""No, thank you."", new Dialogue() .addPlayer(HeadE.CALM_TALK, ""No, thank you."") .addNPC(npcId, HeadE.HAPPY_TALKING, ""Okay, come back soon."") ); } }); } }" "package com.rs.game.content.world.areas.canifis; @PluginEventHandler public class Canifis { public static ObjectClickHandler handleNettles = new ObjectClickHandler(new Object[]{""Nettles""}, e -> { switch (e.getOption()) { case ""Pick"" -> { if (e.getPlayer().getEquipment().wearingGloves()) if (e.getPlayer().getInventory().hasFreeSlots()) { e.getPlayer().getInventory().addItem(4241, 1); e.getPlayer().sendMessage(""You pick some nettles""); } else { e.getPlayer().sendMessage(""You have no free space""); } else { e.getPlayer().sendMessage(""You shouldn't try picking these with your bare hands..""); } } } }); }" "package com.rs.game.content.world.areas.canifis.npcs; @PluginEventHandler public class Werewolf extends NPC { private final int realId; public Werewolf(int id, Tile tile, boolean spawned) { super(id, tile, spawned); realId = id; } public boolean hasWolfbane(Entity target) { if (target instanceof NPC) return false; return ((Player) target).getEquipment().getWeaponId() == 2952; } @Override public void processNPC() { if (isDead() || isCantInteract()) return; if (isUnderCombat() && getId() == realId && Utils.random(5) == 0) { final Entity target = getCombat().getTarget(); if (!hasWolfbane(target)) { setNextAnimation(new Animation(6554)); setCantInteract(true); WorldTasks.schedule(new Task() { @Override public void run() { transformIntoNPC(realId - 20); setNextAnimation(new Animation(-1)); setCantInteract(false); setTarget(target); } }, 1); return; } } super.processNPC(); } @Override public void reset() { setNPC(realId); super.reset(); } public static NPCInstanceHandler toFunc = new NPCInstanceHandler(new Object[] { 6026, 6027, 6028, 6029, 6030, 6031, 6032, 6033, 6034, 6035, 6036, 6037, 6038, 6039, 6040, 6041, 6042, 6043, 6044, 6045 }, (npcId, tile) -> new Werewolf(npcId, tile, false)); }" "package com.rs.game.content.world.areas.catherby; @PluginEventHandler public class Catherby { public static ObjectClickHandler taverlyDungeonClimbToWaterObelisk = new ObjectClickHandler(new Object[] { 32015 }, new Tile[] { Tile.of(2842, 9824, 0) }, e -> e.getPlayer().ladder(Tile.of(2842, 3423, 0))); public static ObjectClickHandler ArheinsShip = new ObjectClickHandler(new Object[] { 69 }, new Tile[] { Tile.of(2805, 3421, 0) }, e -> { int npcId = 563; e.getPlayer().startConversation(new Dialogue() .addNPC(npcId, HeadE.ANGRY, ""Hey buddy! Get away from my ship alright?"") .addPlayer(HeadE.SAD, ""Yeah... uh... sorry..."") ); }); }" "package com.rs.game.content.world.areas.catherby.npcs; @PluginEventHandler public class Arhein extends Conversation { //Identify NPC by ID private static final int npcId = 563; public static NPCClickHandler Arhein = new NPCClickHandler(new Object[]{npcId}, e -> { switch (e.getOption()) { case ""Talk-to"" -> e.getPlayer().startConversation(new Arhein(e.getPlayer())); case ""Trade"" -> ShopsHandler.openShop(e.getPlayer(), ""arheins_shop""); } }); public Arhein(Player player) { super(player); player.startConversation(new Conversation(new Dialogue() .addNPC(npcId, HeadE.HAPPY_TALKING, ""Hello! Would you like to trade?"") .addOptions(""Would you like to trade?"", new Options() { @Override public void create() { option(""Yes."", new Dialogue() .addNPC(npcId, HeadE.CALM_TALK, ""Sure."") .addNext(() -> ShopsHandler.openShop(player, ""arheins_shop"" ) )); option(""No thank you."", new Dialogue() .addNPC(npcId, HeadE.CALM_TALK, ""No thanks."") ); option(""Is that your ship?"", new Dialogue() .addPlayer(HeadE.CONFUSED, ""Is that your ship?"") .addNPC(npcId, HeadE.CALM_TALK, ""Yes, I use it to make deliveries to my customers up and down the coast. "") .addNPC(npcId, HeadE.CALM_TALK, ""These crates here are all ready for my next trip.."") .addOptions(""What would you like to say?"", new Options() { @Override public void create() { option(""Where do you deliver to?"", new Dialogue() .addPlayer(HeadE.CALM_TALK, ""Where do you deliver to?"") .addNPC(npcId, HeadE.HAPPY_TALKING, ""Oh, various places up and down the coast. Mostly Karamja and Port Sarim."") .addOptions(""What would you like to say?"", new Options() { @Override public void create() { option(""I don't suppose I could get a lift anywhere?"", new Dialogue() .addPlayer(HeadE.CALM_TALK, ""I don't suppose I could get a lift anywhere?"") .addNPC(npcId, HeadE.SHAKING_HEAD, ""Sorry pal, but I'm afraid I'm not quite ready to sail yet."") .addNPC(npcId, HeadE.SKEPTICAL, ""I'm waiting on a big delivery of candles which I need to deliver further along the coast."") ); option(""Well, good luck with your business."", new Dialogue() .addPlayer(HeadE.CALM_TALK, ""Well, good luck with your business."") .addNPC(npcId, HeadE.HAPPY_TALKING, ""Thanks buddy!"") ); } } ) ); option(""Are you rich then?"", new Dialogue() .addPlayer(HeadE.CALM_TALK, ""Are you rich then?"") .addNPC(npcId, HeadE.HAPPY_TALKING, "" Business is going reasonably well... I wouldn't say I was the richest of merchants ever, but I'm doing fairly well all things considered."") ); } })); }}))); } }" "package com.rs.game.content.world.areas.catherby.npcs; @PluginEventHandler public class Beekeeper extends Conversation { //Identify NPC by ID private static final int npcId = 8649; public static NPCClickHandler Beekeeper = new NPCClickHandler(new Object[]{npcId}, e -> { switch (e.getOption()) { case ""Talk-To"" -> e.getPlayer().startConversation(new Beekeeper(e.getPlayer())); } }); public Beekeeper(Player player) { super(player); player.startConversation(new Conversation(new Dialogue() .addNPC(npcId, HeadE.CHEERFUL, ""Hello! What do you think of my apiary? Nice, isn't it?"") .addPlayer(HeadE.SKEPTICAL, ""You mean all these beehives?"") .addNPC(npcId, HeadE.CHEERFUL, ""Yup! They're filled with bees. Also wax, and delicious honey too!"") .addNPC(npcId, HeadE.CHEERFUL, ""You're welcome to help yourself to as much wax and honey as you like."") .addNPC(npcId, HeadE.SKEPTICAL, ""Oh, but you'll need some insect repellant - here."") .addItemToInv(player, new Item(28, 1), ""The beekeeper hands you some insect repellant."") .addPlayer(HeadE.CHEERFUL, ""Thank you!"") .addNPC(npcId, HeadE.ANGRY, ""Leave the bees, though. The bees are mine!"") .addNPC(npcId, HeadE.CHEERFUL_EXPOSITION, ""I love bees!"") .finish())); } }" "package com.rs.game.content.world.areas.citharede; @PluginEventHandler public class Citharede { //Citharede public static ObjectClickHandler handlewinchladderup = new ObjectClickHandler(new Object[] { 63591 }, e -> e.getPlayer().tele(Tile.of(3415, 3159, 1))); public static ObjectClickHandler handlewinchladderdown= new ObjectClickHandler(new Object[] { 63592 }, e -> e.getPlayer().tele(Tile.of(3415, 3161, 0))); public static ObjectClickHandler handlespiraltowerup = new ObjectClickHandler(new Object[] { 63583 }, e -> e.getPlayer().tele(Tile.of(3449, 3174, 1))); public static ObjectClickHandler handlespiraltowerdown= new ObjectClickHandler(new Object[] { 63584 }, e -> e.getPlayer().tele(Tile.of(3446, 3177, 0))); public static ObjectClickHandler handlespiraltowerup2 = new ObjectClickHandler(new Object[] { 63585 }, e -> e.getPlayer().tele(Tile.of(3447, 3179, 2))); public static ObjectClickHandler handlespiraltowerdown2= new ObjectClickHandler(new Object[] { 63586 }, e -> e.getPlayer().tele(Tile.of(3451, 3176, 1))); public static ObjectClickHandler handlespiraltowerup3 = new ObjectClickHandler(new Object[] { 63587 }, e -> e.getPlayer().tele(Tile.of(3447, 3179, 3))); public static ObjectClickHandler handlespiraltowerdown3= new ObjectClickHandler(new Object[] { 63588 }, e -> e.getPlayer().tele(Tile.of(3450, 3175, 2))); }" "package com.rs.game.content.world.areas.daemonheim; @PluginEventHandler public class Daemonheim { public static NPCClickHandler handleFremmyBanker = new NPCClickHandler(new Object[] { 9710 }, e -> { Player p = e.getPlayer(); if(e.getOption().equalsIgnoreCase(""bank"")) p.getBank().open(); if(e.getOption().equalsIgnoreCase(""collect"")) GE.openCollection(p); if(e.getOption().equalsIgnoreCase(""talk-to"")) p.startConversation(new Dialogue() .addNPC(e.getNPCId(), HeadE.HAPPY_TALKING, ""Good day. How may I help you?"") .addOptions(""Select an option"", ops -> { ops.add(""I'd like to access my bank account, please."", new Dialogue().addNext(()-> p.getBank().open())); ops.add(""I'd like to check my PIN settings."", new Dialogue().addNext(()-> p.getBank().openPinSettings())); ops.add(""I'd like to see my collection box"", new Dialogue().addNext(()-> GE.openCollection(p))); })); }); public static NPCClickHandler handleRewardsTrader = new NPCClickHandler(new Object[] { 9711 }, e -> { Player p = e.getPlayer(); int NPC = e.getNPCId(); if(e.getOption().equalsIgnoreCase(""talk-to"")) p.startConversation(new Conversation(p) { { addNPC(NPC, HeadE.CALM_TALK, ""Oh, hello, I didn't see...""); addPlayer(HeadE.HAPPY_TALKING, ""Hey. I was wondering if you could help me?""); addNPC(NPC, HeadE.CALM_TALK, ""Help? Uh... I'm not sure that I can... uh...""); create(); } }); if(e.getOption().equalsIgnoreCase(""shop"")) DungeonRewards.openRewardsShop(p); if(e.getOption().equalsIgnoreCase(""recharge"")) p.startConversation(new Conversation(p) { { addNPC(NPC, HeadE.HAPPY_TALKING, ""Did you want to recharge your gear?""); addPlayer(HeadE.HAPPY_TALKING, ""Yes.""); addNPC(NPC, HeadE.CALM_TALK, ""Give me the item.""); addPlayer(HeadE.HAPPY_TALKING, ""Okay.""); addSimple(""He looks blankly at you...""); addPlayer(HeadE.SECRETIVE, ""Umm...""); addPlayer(HeadE.SECRETIVE, ""How do I give it to you?""); addNPC(NPC, HeadE.CALM_TALK, ""Use it on me, blimey, how else?""); addPlayer(HeadE.HAPPY_TALKING, ""That makes sense.""); addSimple(""He rolls his eyes...""); create(); } }); }); public static ItemOnNPCHandler handleChaoticsRecharge = new ItemOnNPCHandler(new Object[] { 9711 }, e -> { if (e.getItem().getId() < 18349 || e.getItem().getId() > 18374) return; ItemConstants.ItemDegrade deg = ItemConstants.ItemDegrade.forId(e.getItem().getId()); if (deg == null) return; int cost = deg.getCost(e.getItem()); e.getPlayer().startConversation(new Conversation(e.getPlayer()) .addNPC(9711, HeadE.SCARED, ""I can repair that for either "" + Utils.formatNumber(cost) + "" coins or "" + Utils.formatNumber(cost / 10) + "" coins and "" + Utils.formatNumber(cost / 100) + "" dungeoneering tokens."") .addOptions(""Which repair option would you like to use?"", ops -> { ops.add(Utils.formatNumber(cost) + "" coins"", () -> { Item item = e.getPlayer().getInventory().getItem(e.getItem().getSlot()); if (item == null || item.getId() != e.getItem().getId()) return; if (!e.getPlayer().getInventory().hasCoins(cost)) { e.getPlayer().sendMessage(""You don't have enough coins.""); return; } e.getPlayer().getInventory().removeCoins(cost); item.setId(deg.getItemId()); item.deleteMetaData(); e.getPlayer().getInventory().refresh(e.getItem().getSlot()); }); ops.add(Utils.formatNumber(cost / 10) + "" coins and "" + Utils.formatNumber(cost / 100) + "" dungeoneering tokens"", () -> { Item item = e.getPlayer().getInventory().getItem(e.getItem().getSlot()); if (item == null || item.getId() != e.getItem().getId()) return; int coinCost = cost / 10; int tokenCost = cost / 100; if (!e.getPlayer().getInventory().hasCoins(coinCost)) { e.getPlayer().sendMessage(""You don't have enough coins.""); return; } if (e.getPlayer().getDungManager().getTokens() < tokenCost) { e.getPlayer().sendMessage(""You don't have enough dungeoneering tokens.""); return; } e.getPlayer().getInventory().removeCoins(coinCost); e.getPlayer().getDungManager().removeTokens(tokenCost); item.setId(deg.getItemId()); item.deleteMetaData(); e.getPlayer().getInventory().refresh(e.getItem().getSlot()); }); ops.add(""Nevermind.""); })); }); }" "package com.rs.game.content.world.areas.death_plateau.npcs; @PluginEventHandler public class Freda extends Conversation { //Identify NPC by ID private static final int npcId = 15099; public static NPCClickHandler Freda = new NPCClickHandler(new Object[]{npcId}, e -> { switch (e.getOption()) { case ""Talk-to"" -> e.getPlayer().startConversation(new Freda(e.getPlayer())); case ""Trade"" -> ShopsHandler.openShop(e.getPlayer(), ""fredas_boots""); } }); public Freda(Player player) { super(player); addNext(new PlayerStatement(HeadE.NO_EXPRESSION, ""Can I buy some climbing boots?"")); addNext(new Dialogue(new NPCStatement(npcId, HeadE.CHEERFUL, ""I don't see why not. Let me see what I've got in your size.""), () -> ShopsHandler.openShop(player, ""fredas_boots""))); create(); } }" "package com.rs.game.content.world.areas.desert; @PluginEventHandler public class Desert { private enum CarpetLocation { SHANTAY_PASS(2291, Tile.of(3308, 3109, 0)), BEDABIN_CAMP(2292, Tile.of(3180, 3045, 0)), S_POLLNIVNEACH(2293, Tile.of(3351, 2942, 0)), N_POLLNIVNEACH(2294, Tile.of(3349, 3003, 0)), UZER(2295, Tile.of(3469, 3113, 0)), SOPHANEM(2297, Tile.of(3285, 2813, 0)), MENAPHOS(2299, Tile.of(3245, 2813, 0)), NARDAH(3020, Tile.of(3401, 2916, 0)), MONKEY_COLONY(13237, Tile.of(3227, 2988, 0)); private final int npcId; private final Tile tile; public static CarpetLocation forId(int npcId) { for (CarpetLocation loc : CarpetLocation.values()) if (loc.npcId == npcId) return loc; return null; } private CarpetLocation(int npcId, Tile tile) { this.npcId = npcId; this.tile = tile; } } public static NPCClickHandler handleCarpetMerchants = new NPCClickHandler(new Object[] { 2291, 2292, 2293, 2294, 2295, 2297, 2299, 3020, 13237 }, e -> { CarpetLocation loc = CarpetLocation.forId(e.getNPC().getId()); switch(loc) { case SHANTAY_PASS: e.getPlayer().sendOptionDialogue(""Where would you like to travel?"", ops -> { ops.add(""Pollnivneach"", () -> e.getPlayer().tele(CarpetLocation.N_POLLNIVNEACH.tile)); ops.add(""Bedabin Camp"", () -> e.getPlayer().tele(CarpetLocation.BEDABIN_CAMP.tile)); ops.add(""Uzer"", () -> e.getPlayer().tele(CarpetLocation.UZER.tile)); ops.add(""Monkey Colony"", () -> e.getPlayer().tele(CarpetLocation.MONKEY_COLONY.tile)); ops.add(""Nevermind""); }); break; case N_POLLNIVNEACH: case UZER: case BEDABIN_CAMP: case MONKEY_COLONY: e.getPlayer().sendOptionDialogue(""Where would you like to travel?"", ops -> { ops.add(""Shantay Pass"", () -> e.getPlayer().tele(CarpetLocation.SHANTAY_PASS.tile)); ops.add(""Nevermind""); }); break; case S_POLLNIVNEACH: e.getPlayer().sendOptionDialogue(""Where would you like to travel?"", ops -> { ops.add(""Nardah"", () -> e.getPlayer().tele(CarpetLocation.NARDAH.tile)); ops.add(""Sophanem"", () -> e.getPlayer().tele(CarpetLocation.SOPHANEM.tile)); ops.add(""Menaphos"", () -> e.getPlayer().tele(CarpetLocation.MENAPHOS.tile)); ops.add(""Nevermind""); }); break; case NARDAH: case SOPHANEM: case MENAPHOS: e.getPlayer().sendOptionDialogue(""Where would you like to travel?"", ops -> { ops.add(""Pollnivneach"", () -> e.getPlayer().tele(CarpetLocation.S_POLLNIVNEACH.tile)); ops.add(""Nevermind""); }); break; default: break; } }); public static ObjectClickHandler handleSpiritWaterfall = new ObjectClickHandler(new Object[] { 10417, 63173 }, e -> { if (e.getObjectId() == 63173) e.getPlayer().useStairs(Tile.of(3348, 9535, 0)); else e.getPlayer().useStairs(Tile.of(3370, 3129, 0)); }); public static ObjectClickHandler handleSophBankEntrance = new ObjectClickHandler(new Object[] { 20275 }, e -> e.getPlayer().useStairs(Tile.of(2765, 5131, 0))); public static ObjectClickHandler handleSophBankExit = new ObjectClickHandler(new Object[] { 20280 }, e -> e.getPlayer().useStairs(Tile.of(3315, 2796, 0))); public static ObjectClickHandler handleSophDungEntrance = new ObjectClickHandler(new Object[] { 20340 }, e -> e.getPlayer().useStairs(Tile.of(3286, 9273, 0))); public static ObjectClickHandler handleSophDungExit = new ObjectClickHandler(new Object[] { 20284 }, e -> e.getPlayer().useStairs(Tile.of(2766, 5131, 0))); public static LoginHandler unlockMonkeyColonyRugMerchant = new LoginHandler(e -> { e.getPlayer().getVars().setVarBit(8628, 1); e.getPlayer().getVars().setVarBit(8628, 1); e.getPlayer().getVars().setVarBit(8628, 1); e.getPlayer().getVars().setVarBit(395, 1); //unlock menaphos rug }); public static ObjectClickHandler handleCurtainDoors = new ObjectClickHandler(new Object[] { 1528 }, e -> { if (e.getObject().getRotation() == 2 || e.getObject().getRotation() == 0) e.getPlayer().walkOneStep(e.getPlayer().getX() > e.getObject().getX() ? -1 : 1, 0, false); else e.getPlayer().walkOneStep(0, e.getPlayer().getY() == e.getObject().getY() ? -1 : 1, false); }); public static ObjectClickHandler handleEnterTTMine = new ObjectClickHandler(new Object[] { 2675, 2676 }, e -> e.getPlayer().useStairs(Tile.of(3279, 9427, 0))); public static ObjectClickHandler handleExitTTMine = new ObjectClickHandler(new Object[] { 2690, 2691 }, e -> e.getPlayer().useStairs(Tile.of(3301, 3036, 0))); public static NPCClickHandler handleBanditBartender = new NPCClickHandler(new Object[] { 1921 }, e -> ShopsHandler.openShop(e.getPlayer(), ""the_big_heist_lodge"")); public static NPCClickHandler aliSnakeCharmer = new NPCClickHandler(new Object[] { 1872 }, e -> { Player p = e.getPlayer(); p.startConversation(new Conversation(p) { { addPlayer(HeadE.HAPPY_TALKING, ""Hello...""); addNPC(1872, HeadE.FRUSTRATED, ""What do you want "" + p.getPronoun(""sir"", ""m'am"") + ""?""); addOptions(""Choose an option:"", new Options() { @Override public void create() { option(""Would you like some money?"", new Dialogue() .addPlayer(HeadE.CHEERFUL, ""Would you like some money?"") .addNPC(1872, HeadE.FRUSTRATED, ""Why else would I sit here with a dangerous snake?"") .addOptions(""Give money?"", new Options() { @Override public void create() { if(p.getInventory().hasCoins(1)) option(""Yes."", new Dialogue() .addItem(995, ""You give the charmer 1 coin"", ()-> p.getInventory().removeCoins(1)) .addNPC(1872, HeadE.CHEERFUL, ""Oh thank you so much! Please please come again"") .addSimple(""You feel swindled..."") ); else option(""I would give you if I had some..."", new Dialogue() .addPlayer(HeadE.CHEERFUL, ""I would give you money if I had it."") .addNPC(1872, HeadE.FRUSTRATED, ""Leave me alone."") ); option(""No."", new Dialogue()); } }) ); option(""Does the snake ever bite?"", new Dialogue() .addPlayer(HeadE.CHEERFUL, ""Does the snake ever bite?"") .addNPC(1872, HeadE.SECRETIVE, ""It's trained not to."") .addPlayer(HeadE.AMAZED, ""That's cheating isn't it?"") .addNPC(1872, HeadE.CALM_TALK, ""Please, leave me alone."") ); option(""Can I try your flute?"", new Dialogue() .addPlayer(HeadE.CHEERFUL, ""Can I try your flute?"") .addSimple(""He looks upset..."") .addNPC(1872, HeadE.FRUSTRATED, ""Will it get you off my back?"") .addPlayer(HeadE.SECRETIVE, ""Umm, sure."") .addSimple(""He pulls out a set of flutes..."") .addNPC(1872, HeadE.FRUSTRATED, ""I will give you one, just leave me alone"") .addItem(4605, ""He gives you a flute"", ()-> p.getInventory().addItem(4605, 1)) ); } }); create(); } }); }); public static ObjectClickHandler handlePyramidBackEntrance = new ObjectClickHandler(new Object[] { 6481 }, e -> e.getPlayer().tele(Tile.of(3233, 9310, 0))); public static ObjectClickHandler handlePyramidSarcophagi = new ObjectClickHandler(new Object[] { 6516 }, e -> { if (e.getObject().getTile().isAt(3233, 9309)) e.getPlayer().tele(Tile.of(3233, 2887, 0)); else e.getPlayer().sendMessage(""You search the sarcophagus but find nothing.""); }); public static ItemClickHandler handleSplittingGranite = new ItemClickHandler(new Object[] { 6979, 6981, 6983 }, new String[] { ""Craft"" }, e -> { Player player = e.getPlayer(); if (!player.getInventory().containsItem(1755, 1, true)) { player.sendMessage(""You must have a chisel in order to craft granite.""); return; } if (player.getInventory().getFreeSlots() < 3) { player.sendMessage(""You do not have enough room in your inventory to split the granite.""); return; } player.lock(2); switch(e.getItem().getId()) { case 6983: //5kg - splits into 2x 2kg and 2x 500g player.getInventory().deleteItem(6983, 1); player.getInventory().addItem(6981, 2); player.getInventory().addItem(6979, 2); break; case 6981: //2kg - splits into 4x 500g player.getInventory().deleteItem(6981, 1); player.getInventory().addItem(6979, 4); break; case 6979: //500g player.sendMessage(""This block of granite is too small to craft into anything.""); return; } player.anim(11146); }); public static ItemClickHandler handleSplittingSandstone = new ItemClickHandler(new Object[] { 6973, 6975, 6977 }, new String[] { ""Craft"" }, e -> { Player player = e.getPlayer(); if (!player.getInventory().containsItem(1755, 1, true)) { player.sendMessage(""You must have a chisel in order to craft sandstone.""); return; } if (player.getInventory().getFreeSlots() < (e.getItem().getId() == 6975 ? 2 : 1)) { player.sendMessage(""You do not have enough room in your inventory to split the sandstone.""); return; } player.lock(2); player.anim(11146); switch(e.getItem().getId()) { case 6977: //10kg - splits into 2x 5kg player.getInventory().deleteItem(6977, 1); player.getInventory().addItem(6975, 2); break; case 6975: //5kg - splits into 2x 2kg and 1x 1kg player.getInventory().deleteItem(6975, 1); player.getInventory().addItem(6973, 2); player.getInventory().addItem(6971, 1); break; case 6973: //2kg - splits into 2x 1kg player.getInventory().deleteItem(6973, 1); player.getInventory().addItem(6971, 2); break; } }); }" "package com.rs.game.content.world.areas.desert.npcs; @PluginEventHandler public class BanditCampBandit extends NPC { public BanditCampBandit(int id, Tile tile, boolean spawned) { super(id, tile, spawned); setForceAgressive(true); // to ignore combat lvl setIgnoreDocile(true); } @Override public List getPossibleTargets() { List targets = super.getPossibleTargets(); ArrayList targetsCleaned = new ArrayList<>(); for (Entity t : targets) { if (!(t instanceof Player) || (!ZamorakFactionNPC.hasGodItem((Player) t) && !SaradominFactionNPC.hasGodItem((Player) t))) continue; targetsCleaned.add(t); } return targetsCleaned; } @Override public void setTarget(Entity entity) { if (entity instanceof Player && (ZamorakFactionNPC.hasGodItem((Player) entity) || SaradominFactionNPC.hasGodItem((Player) entity))) setNextForceTalk(new ForceTalk(ZamorakFactionNPC.hasGodItem((Player) entity) ? ""Prepare to suffer, Zamorakian scum!"" : ""Time to die, Saradominist filth!"")); super.setTarget(entity); } public static NPCInstanceHandler toFunc = new NPCInstanceHandler(new Object[] { 1926, 1931 }, (npcId, tile) -> new BanditCampBandit(npcId, tile, false)); }" "package com.rs.game.content.world.areas.desert.npcs; public class SimonTempletonD extends Conversation { public SimonTempletonD(Player player, int npcId) { super(player); if (player.getInventory().containsItem(6970)) { addNext(new PlayerStatement(HeadE.CHEERFUL, ""I have a pyramid top I can sell you!"")); addNext(new Dialogue(new NPCStatement(npcId, HeadE.CHEERFUL, ""Excellent job mate! Here's your money.""), () -> { int totalMoney = player.getInventory().getAmountOf(6970) * 10000; player.getInventory().deleteItem(6970, Integer.MAX_VALUE); player.getInventory().addCoins(totalMoney); })); } else { addNext(new PlayerStatement(HeadE.CHEERFUL, ""Hi, what do you do here?"")); addNext(new NPCStatement(npcId, HeadE.CHEERFUL, ""I'll buy any special artefacts you find here in the desert. If you happen to find any pyramid tops, I'll buy them for 10,000 gold each."")); addNext(new PlayerStatement(HeadE.CHEERFUL, ""Great, I'll be sure to come back if I find any."")); } create(); } }" "package com.rs.game.content.world.areas.dorgeshuun; @PluginEventHandler public class Dorgeshuun { //Dorgeshuun public static ObjectClickHandler handleDorgeshuunboilerstairs = new ObjectClickHandler(new Object[] { 22651, 22650 }, e -> { if (e.getObjectId() == 22651) e.getPlayer().tele(e.getPlayer().transform(e.getObject().getRotation() == 0 ? -0 : e.getObject().getRotation() == 3 ? -3 : 0, e.getObject().getRotation() == 0 ? -3 : e.getObject().getRotation() == 3 ? -0 : 0, -1)); else if (e.getObjectId() == 22650) e.getPlayer().tele(e.getPlayer().transform(e.getObject().getRotation() == 0 ? 3 : e.getObject().getRotation() == 3 ? -0 : 0, e.getObject().getRotation() == 0 ? 0 : e.getObject().getRotation() == 3 ? 3 : 0, 1)); }); public static ObjectClickHandler handleDorgeshuunboilerstairs2 = new ObjectClickHandler(new Object[] { 22608, 22609 }, e -> { if (e.getObjectId() == 22608) e.getPlayer().tele(e.getPlayer().transform(e.getObject().getRotation() == 1 ? -0 : e.getObject().getRotation() == 0 ? -3 : 0, e.getObject().getRotation() == 1 ? -3 : e.getObject().getRotation() == 0 ? -0 : 0, 1)); else if (e.getObjectId() == 22609) e.getPlayer().tele(e.getPlayer().transform(e.getObject().getRotation() == 1 ? 3 : e.getObject().getRotation() == 0 ? -0 : 0, e.getObject().getRotation() == 1 ? 0 : e.getObject().getRotation() == 0 ? 3 : 0, -1)); }); }" "package com.rs.game.content.world.areas.draynor; @PluginEventHandler public class Draynor { public static NPCClickHandler handleNed = new NPCClickHandler(new Object[] { 918 }, e -> e.getPlayer().startConversation(new Conversation(e.getPlayer()) { { addNPC(e.getNPCId(), HeadE.CHEERFUL, ""Why, hello there, lass. Me friends call me Ned. I was a man of the sea, but it's past me now."" + "" Could I be making or selling you some rope?""); addOptions(""What would you like to say?"", new Options() { @Override public void create() { if(e.getPlayer().getQuestManager().getStage(Quest.DRAGON_SLAYER) == DragonSlayer.PREPARE_FOR_CRANDOR) option(""About Dragon Slayer"", new Dialogue() .addNext(()-> e.getPlayer().startConversation(new NedDragonSlayerD(e.getPlayer()).getStart()))); option(""Yes, I would like some rope."", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Yes, I would like some rope."") .addNext(() -> player.startConversation(new Conversation(player) { { if(player.getInventory().hasCoins(15)) { addNPC(NED, HeadE.HAPPY_TALKING, ""Okay that will be 15 coins...""); addPlayer(HeadE.CALM_TALK, ""Thats good, here you go!""); addNext(()->{ player.getInventory().removeCoins(15); player.getInventory().addItem(954, 1); }); } else if(player.getInventory().containsItem(BALL_WOOL, 4)) { addNPC(NED, HeadE.CALM_TALK, ""Okay I will need 4 balls of wool...""); addPlayer(HeadE.HAPPY_TALKING, ""Thats good, here you go!""); addNext(()->{ player.getInventory().deleteItem(BALL_WOOL, 4); player.getInventory().addItem(954, 1); }); } else { addNPC(NED, HeadE.CALM_TALK, ""Okay, bring me 15 coins or 4 balls of wool and ill give you some.""); addPlayer(HeadE.HAPPY_TALKING, ""Sounds good""); } create(); } }))); option(""About the Achievement System..."", () -> new AchievementSystemD(player, e.getNPCId(), SetReward.EXPLORERS_RING)); option(""Ned, could you make other things from wool?"", new Dialogue() .addNPC(NED, HeadE.HAPPY_TALKING, ""I am sure I can. What are you thinking of?"") .addOptions(""Choose an option:"", new Options() { @Override public void create() { option(""Could you knit me a sweater?"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Could you knit me a sweater?"") .addNPC(NED, HeadE.FRUSTRATED, ""Do I look like a member of a sewing circle? Be off wi' you. I have"" + "" fought monsters that would turn your hair blue."") .addNPC(NED, HeadE.FRUSTRATED, ""I don't need to be laughed at just 'cos I am getting a bit old."")); option(""How about some sort of a wig?"", new Dialogue() .addPlayer(HeadE.SKEPTICAL_THINKING, ""How about some sort of a wig?"") .addNext(()-> player.startConversation(new Conversation(player) { { addNPC(NED, HeadE.SKEPTICAL_THINKING, ""Well... That's an interesting thought. Yes, I think I could do something. "" + ""Give me 3 balls of wool and I might be able to do it.""); if(player.getInventory().containsItem(BALL_WOOL, 3)) addOptions(""Choose an option:"", new Options() { @Override public void create() { option(""I have that now. Please, make me a wig."", new Dialogue() .addPlayer(HeadE.CALM_TALK, ""I have that now. Please, make me a wig."") .addNPC(NED, HeadE.CALM_TALK, ""Okay, I will have a go."") .addSimple(""You hand Ned 3 balls of wool. Ned works with the wool. His hands "" + ""move with a speed you couldn't imagine."") .addNPC(NED, HeadE.HAPPY_TALKING, ""Here you go, how's that for a quick effort? Not bad I think!"") .addSimple(""Ned gives you a pretty good wig."", ()->{ player.getInventory().deleteItem(BALL_WOOL, 3); player.getInventory().addItem(WIG, 1); }) .addPlayer(HeadE.HAPPY_TALKING, ""Thanks Ned, there's more to you than meets the eye."")); option(""I will come back when I need you to make me one."", new Dialogue()); } }); else addPlayer(HeadE.HAPPY_TALKING, ""I will come back if I need one.""); create(); } }))); option(""Could you repair the arrow holes in the back of my shirt?"", new Dialogue() .addNPC(NED, HeadE.HAPPY_TALKING, ""Ah yes, it's a tough world these days. There's a few brave enough to "" + ""attack from 10 metres away."") .addNPC(NED, HeadE.HAPPY_TALKING, ""There you go, good as new."") .addPlayer(HeadE.HAPPY_TALKING, ""Thanks Ned. Maybe next time they will attack me face to face."") ); } })); } }); create(); } })); public static NPCClickHandler handleAggie = new NPCClickHandler(new Object[] { 922 }, e -> e.getPlayer().startConversation(new Conversation(e.getPlayer()) { { addNPC(e.getNPCId(), HeadE.CALM, ""What can I help you with?""); addOptions(new Options() { @Override public void create() { if(player.getQuestManager().getStage(Quest.PRINCE_ALI_RESCUE) == GEAR_CHECK) option(""Could you think of a way to make skin paste?"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Could you think of a way to make skin paste?"") .addNext(()-> player.startConversation(new Conversation(player) { { Inventory inv = player.getInventory(); if(inv.containsItem(ASHES, 1) && inv.containsItem(REDBERRY, 1) && inv.containsItem(POT_OF_FLOUR, 1) && inv.containsItem(WATER_BUCKET, 1)) { addNPC(AGGIE, HeadE.HAPPY_TALKING, ""Yes I can, I see you already have the ingredients. Would you "" + ""like me to mix some for you now?""); addOptions(""Choose an option:"", new Options() { @Override public void create() { option(""Yes please. Mix me some skin paste."", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Yes please. Mix me some skin paste."") .addNPC(AGGIE, HeadE.HAPPY_TALKING, ""That should be simple. Hand the things to Aggie then."") .addSimple(""You hand the ash, flour, water and redberries to Aggie. Aggie tips the "" + ""ingredients into a cauldron and mutters some words"") .addNPC(AGGIE, HeadE.CALM_TALK, ""Tourniquet, Fenderbaum, Tottenham, Marshmallow, "" + ""MarbleArch."") .addSimple(""Aggie hands you the Skin Paste"", () -> { inv.deleteItem(ASHES, 1); inv.deleteItem(REDBERRY, 1); inv.deleteItem(POT_OF_FLOUR, 1); inv.deleteItem(WATER_BUCKET, 1); inv.addItem(PASTE, 1); }) .addNPC(AGGIE, HeadE.HAPPY_TALKING, ""There you go dearie, your skin potion. That will "" + ""make you look good at the Varrock dances."") .addPlayer(HeadE.SKEPTICAL_THINKING, ""Umm, thanks."")); option(""No thank you, I don't need any skin paste right now."", new Dialogue() .addNPC(AGGIE, HeadE.HAPPY_TALKING, ""Okay dearie, that's always your choice."")); } }); } else { addNPC(AGGIE, HeadE.HAPPY_TALKING, ""For skin paste I am going to need ashes, a pot of flour, redberries "" + ""and a bucket of water""); addPlayer(HeadE.HAPPY_TALKING, ""Okay, thanks. I'll be back with those four things.""); } create(); } }))); else option(""Hey, you are a witch aren't you?"", new Dialogue() .addPlayer(HeadE.SKEPTICAL_THINKING, ""Hey, you are a witch aren't you?"") .addNPC(e.getNPCId(), HeadE.AMAZED, ""My, you are observant!"") .addPlayer(HeadE.CALM_TALK, ""Cool, do you turn people into frogs?"") .addNPC(e.getNPCId(), HeadE.NO_EXPRESSION, ""Oh, not for years. But if you meet a talking chicken, you have probably met the professor in the "" + ""manor north of here. A few years ago it was a flying fish. That machine is a menace."")); option(""So what is actually in that cauldron?"", new Dialogue().addPlayer(HeadE.CALM_TALK, ""So what is actually in that cauldron?"") .addNPC(e.getNPCId(), HeadE.FRUSTRATED, ""You don't really expect me to give away trade secrets, do you?"")); option(""What's new in Draynor village?"", new Dialogue() .addPlayer(HeadE.CALM_TALK, ""What's new in Draynor village?"") .addNPC(e.getNPCId(), HeadE.HAPPY_TALKING, ""Hm, a while ago there was a portal that appeared in the woods to the east of Draynor"") .addNPC(e.getNPCId(), HeadE.HAPPY_TALKING, ""When the portal opened, the god Zamorak stepped through!"") .addNPC(e.getNPCId(), HeadE.HAPPY_TALKING, ""However, immediately he was confronted by Saradomin and a battle ensued. Both forces fought valiantly for "" + ""months, unable to gain the upper hand"") .addNPC(e.getNPCId(), HeadE.HAPPY_TALKING, ""In the end, however, the power of Zamorak was no match for the might of Saradomin. Zamorak was defeated"") .addNPC(e.getNPCId(), HeadE.HAPPY_TALKING, ""Zamorak retreated with the help of his general. But the victory had cost Saradomin dearly, and so he left the "" + ""battlefield to regroup"") .addNPC(e.getNPCId(), HeadE.HAPPY_TALKING, ""The battlefield is at peace now"") .addPlayer(HeadE.HAPPY_TALKING, ""Ok, thanks!"")); option(""What could you make for me?"", new Dialogue() .addPlayer(HeadE.SKEPTICAL_THINKING, ""What could you make for me?"") .addNPC(e.getNPCId(), HeadE.HAPPY_TALKING, ""I mostly just make what I find pretty. I sometimes make dye for the women's clothes to brighten the place up. "" + ""I can make red,yellow and blue dyes. If you'd like some, just bring me the appropriate ingredients."")); option(""Can you make dyes for me please?"", new Dialogue().addPlayer(HeadE.CALM_TALK, ""Can you make dyes for me please?"") .addNPC(e.getNPCId(), HeadE.HAPPY_TALKING, ""What sort of dye would you like? Red, yellow or blue?"") .addOptions(new Options() { @Override public void create() { option(""Red dye"", () -> { if (player.getInventory().containsItem(1951, 3) && player.getInventory().hasCoins(5)) { player.getInventory().deleteItem(1951, 3); player.getInventory().removeCoins(5); player.getInventory().addItem(1763, 1); } else player.getPackets().sendGameMessage( ""You need 3 red berries and 5 coins""); }); option(""Yellow dye"", () -> { if (player.getInventory().containsItem(1957, 2) && player.getInventory().hasCoins(5)) { player.getInventory().deleteItem(1957, 2); player.getInventory().removeCoins(5); player.getInventory().addItem(1765, 1); } else player.getPackets() .sendGameMessage(""You need 2 onions and 5 coins""); }); option(""Blue dye"", () -> { if (player.getInventory().containsItem(1793, 2) && player.getInventory().hasCoins(5)) { player.getInventory().deleteItem(1793, 2); player.getInventory().removeCoins(5); player.getInventory().addItem(1767, 1); } else player.getPackets().sendGameMessage( ""You need 2 woad leaves and 5 coins""); }); } })); } }); create(); } })); public static NPCClickHandler handleAva = new NPCClickHandler(new Object[] { 5199 }, e -> { if (!e.getPlayer().isQuestComplete(Quest.ANIMAL_MAGNETISM, ""to buy Ava's devices."")) return; Conversation chooseDevice = new Conversation(e.getPlayer()) { { addOptions(""Which device would you like?"", new Options() { @Override public void create() { option(""The attractor"", () -> { if (player.getInventory().hasCoins(999)) { player.getInventory().removeCoins(999); player.getInventory().addItem(10498, 1); player.startConversation( new Dialogue().addSimple(""You buy an attractor for 999 coins."")); } else player.startConversation(new Conversation(e.getPlayer()).addNPC(e.getNPCId(), HeadE.NO_EXPRESSION, ""I'm not running a charity. You need at least 999 coins to buy a new attractor."")); }); if (e.getPlayer().getSkills().getLevelForXp(Constants.RANGE) >= 50) option(""The accumulator"", () -> { if (player.getInventory().hasCoins(999) && player.getInventory().containsItem(886, 75)) { player.getInventory().removeCoins(999); player.getInventory().deleteItem(886, 75); player.getInventory().addItem(10499, 1); player.startConversation(new Dialogue().addSimple( ""You buy an accumulator for 999 coins and 75 steel arrows."")); } else player.startConversation(new Conversation(e.getPlayer()).addNPC(e.getNPCId(), HeadE.NO_EXPRESSION, ""I'm not running a charity. You need at least 999 coins and 75 steel arrows to buy a new accumulator."")); }); if (player.isQuestComplete(Quest.DO_NO_EVIL, ""to claim an alerter."")) option(""The alerter"", () -> { if (player.getInventory().hasCoins(999) && player.getInventory().containsItem(886, 75)) { player.getInventory().removeCoins(999); player.getInventory().deleteItem(886, 75); player.getInventory().addItem(20068, 1); player.startConversation(new Dialogue() .addSimple(""You buy an alerter for 999 coins and 75 steel arrows."")); } else player.startConversation(new Conversation(e.getPlayer()).addNPC(e.getNPCId(), HeadE.NO_EXPRESSION, ""I'm not running a charity. You need at least 999 coins and 75 steel arrows to buy a new alerter."")); }); } }); } }; switch(e.getOpNum()) { case 1: e.getPlayer().startConversation(new Conversation(e.getPlayer()) { { addNPC(e.getNPCId(), HeadE.CONFUSED, ""Hello again; I'm busy with my newest research, so can't gossip too much. Are you after information, an upgrade, another device, or would you like to see my goods for sale?""); addOptions(""What would you like to say?"", new Options() { @Override public void create() { option(""I seem to need a new device."", () -> player.startConversation(chooseDevice)); option(""I'd like to see your stuff for sale please."", () -> ShopsHandler.openShop(player, ""avas_odds_and_ends"")); } }); } }); break; case 3: ShopsHandler.openShop(e.getPlayer(), ""avas_odds_and_ends""); break; case 4: e.getPlayer().startConversation(chooseDevice); break; } }); public static ObjectClickHandler handleEnterDraynorSewers = new ObjectClickHandler(new Object[] { 6435 }, e -> { Player p = e.getPlayer(); GameObject obj = e.getObject(); if(obj.getTile().matches(Tile.of(3118, 3244, 0)))//south entrance p.useStairs(827, Tile.of(3118, 9643, 0), 1, 1); if(obj.getTile().matches(Tile.of(3084, 3272, 0)))//north entrance p.useStairs(827, Tile.of(3085, 9672, 0), 1, 1); }); public static ObjectClickHandler handleMorgansChest = new ObjectClickHandler(new Object[] { 46243 }, e -> e.getPlayer().sendMessage(""The chest is locked..."")); public static ObjectClickHandler handleExitsDraynorSewers = new ObjectClickHandler(new Object[] { 26518, 32015 }, e -> { Player p = e.getPlayer(); GameObject obj = e.getObject(); if(obj.getTile().matches(Tile.of(3118, 9643, 0)))//north p.ladder(Tile.of(3118, 3245, 0)); if(obj.getTile().matches(Tile.of(3084, 9672, 0)))//south p.ladder(Tile.of(3084, 3273, 0)); }); public static ObjectClickHandler handleEnterDraynorAvaSecret = new ObjectClickHandler(new Object[] { 160, 47404 }, e -> { e.getPlayer().lock(); e.getPlayer().setNextFaceTile(e.getObject().getTile()); e.getPlayer().setNextAnimation(new Animation(1548)); WorldTasks.delay(2, () -> e.getPlayer().addWalkSteps(e.getPlayer().transform(0, e.getObjectId() == 47404 ? -1 : 1), 1, true)); WorldTasks.delay(4, () -> { GameObject door1 = World.getObjectWithId( e.getObject().getTile().transform(e.getObjectId() == 47404 ? 0 : 1, e.getObjectId() == 47404 ? -1 : 2), 47531); GameObject door2 = World.getObjectWithId( e.getObject().getTile().transform(e.getObjectId() == 47404 ? 0 : 1, e.getObjectId() == 47404 ? -2 : 1), 47529); if (door1 != null && door2 != null) { World.spawnObjectTemporary(new GameObject(door1, 83), 2, true); World.spawnObjectTemporary(new GameObject(door2, 83), 2, true); World.spawnObjectTemporary(new GameObject(DoorPair.getOpposingDoor(e.getPlayer(), door1), door1.getType(), door1.getRotation(1), door1.getTile().transform(-1, 0, 0)), 2, true); World.spawnObjectTemporary(new GameObject(DoorPair.getOpposingDoor(e.getPlayer(), door2), door2.getType(), door2.getRotation(-1), door2.getTile().transform(-1, 0, 0)), 2, true); } e.getPlayer().addWalkSteps( e.getObject().getTile().transform(e.getObjectId() == 47404 ? -1 : 1, e.getObjectId() == 47404 ? -1 : 1), 3, false); e.getPlayer().unlock(); }); }); public static ObjectClickHandler handleClimbWizardsTowerBasement = new ObjectClickHandler(new Object[] { 32015 }, new Tile[] { Tile.of(3103, 9576, 0) }, e -> e.getPlayer().ladder(Tile.of(3105, 3162, 0))); public static ObjectClickHandler handleDraynorManorBasement = new ObjectClickHandler(new Object[] { 47643, 164 }, e -> { if (e.getObjectId() == 47643) e.getPlayer().useStairs(Tile.of(3080, 9776, 0)); else e.getPlayer().useStairs(Tile.of(3115, 3355, 0)); }); public static ObjectClickHandler handleDraynorManorRailing = new ObjectClickHandler(new Object[] { 37703 }, e -> { Player p = e.getPlayer(); GameObject obj = e.getObject(); if (!Agility.hasLevel(p, 28)) { p.getPackets().sendGameMessage(""You need level 28 agility to use this shortcut.""); return; } if(!obj.getTile().matches(Tile.of(3083, 3353, 0))) return; if(p.getX() > obj.getX()) AgilityShortcuts.climbOver(p, Tile.of(obj.getX(), obj.getY(), obj.getPlane())); if(p.getX() <= obj.getX()) AgilityShortcuts.climbOver(p, Tile.of(obj.getX()+1, obj.getY(), obj.getPlane())); }); public static ObjectClickHandler handleDraynorManorStairs = new ObjectClickHandler(new Object[] { 47364, 47657 }, e -> e.getPlayer().useStairs(e.getPlayer().transform(0, e.getObjectId() == 47364 ? 5 : -5, e.getObjectId() == 47364 ? 1 : -1))); }" "package com.rs.game.content.world.areas.draynor.npcs; @PluginEventHandler public class DraynorVillageNPC { private static final int BANK_GUARD = 2574; private static final int DIANGO = 970; private static final int FORTUNATO = 3671; private static final int MARKET_GUARD = 2236; private static final int MISS_SCHISM = 2634; private static final int OLIVIA = 2233; private static final int SHADY_STRANGER = 8339; private static final int SUSPICIOUS_OUTSIDER = 8436; public static NPCClickHandler HandleBankGuard= new NPCClickHandler(new Object[]{ BANK_GUARD }, e -> { switch (e.getOption()) { case ""Talk-to"" -> { if (Quest.LOVE_STORY.isImplemented()) e.getPlayer().startConversation(new Dialogue() .addSimple(""Placeholder"") ); else e.getPlayer().startConversation(new Dialogue() .addNPC(BANK_GUARD, HeadE.FRUSTRATED, ""Yes?"") .addOptions(ops -> { ops.add(""Can I deposit my stuff here?."") .addPlayer(HeadE.HAPPY_TALKING, ""Can I deposit my stuff here?"") .addNPC(BANK_GUARD, HeadE.ANGRY, ""No. I'm a security guard, not a bank clerk.""); ops.add(""That wall doesn't look very good."") .addPlayer(HeadE.HAPPY_TALKING, ""That wall doesn't look very good."") .addNPC(BANK_GUARD, HeadE.ANGRY, ""No, it doesn't."") .addOptions(ops2 -> { ops2.add(""Are you going to tell me what happened?"") .addPlayer(HeadE.CONFUSED, ""Are you going to tell me what happened?"") .addNPC(BANK_GUARD, HeadE.FRUSTRATED, ""I could do."") .addPlayer(HeadE.AMAZED, ""Okay, go on!"") .addNPC(BANK_GUARD, HeadE.FRUSTRATED, ""Someone smashed the wall when they were robbing the bank."") .addPlayer(HeadE.CONFUSED, ""Someone's robbed the bank?"") .addNPC(BANK_GUARD, HeadE.VERY_FRUSTRATED, ""Yes."") .addPlayer(HeadE.AMAZED, ""But... was anyone hurt? Did they get anything valuable?"") .addNPC(BANK_GUARD, HeadE.SKEPTICAL_HEAD_SHAKE, ""Yes, but we were able to get more staff and mend the wall easily enough. The Bank has already replaced all the stolen items that belonged to customers."") .addPlayer(HeadE.UPSET, ""Oh, good... but the bank staff got hurt?"") .addNPC(BANK_GUARD, HeadE.SKEPTICAL_THINKING, ""Yes, but the new ones are just as good."") .addPlayer(HeadE.ANGRY, ""You're not very nice, are you?"") .addNPC(BANK_GUARD, HeadE.LAUGH, ""No-one's expecting me to be nice.""); ops2.add(""Alright, I'll stop bothering you now."") .addPlayer(HeadE.HAPPY_TALKING, ""Alright, I'll stop bothering you now."") .addNPC(BANK_GUARD, HeadE.VERY_FRUSTRATED, ""Good day, "" + e.getPlayer().getPronoun(""sir"", ""ma'am"")+ "".""); }); ops.add(""Sorry, I don't want anything."") .addPlayer(HeadE.HAPPY_TALKING, ""Sorry, I don't want anything."") .addNPC(BANK_GUARD, HeadE.VERY_FRUSTRATED, ""Ok.""); }) ); } } }); public static NPCClickHandler HandleDiango= new NPCClickHandler(new Object[]{ DIANGO }, e -> { switch (e.getOption()) { case ""Trade"" -> ShopsHandler.openShop(e.getPlayer(), ""diangos_toy_store""); case ""Talk-to"" -> e.getPlayer().startConversation(new Dialogue() .addNPC(DIANGO, HeadE.HAPPY_TALKING, ""Howdy there partner! Want to see my spinning plates? Or did ya want a holiday item back?"") .addOptions(ops -> { ops.add(""Spinning plates?"") .addPlayer(HeadE.CONFUSED, ""Spinning plates?"") .addNPC(DIANGO, HeadE.HAPPY_TALKING, ""That's right. There's a funny story behind them, their shipment was held up by thieves."") .addNPC(DIANGO, HeadE.LAUGH, ""The crate was marked 'Dragon Plates'. Apparently they thought it was some kind of armour, when really it's just a plate with a dragon on it!"") .addNext(() -> ShopsHandler.openShop(e.getPlayer(), ""diangos_toy_store"")); ops.add(""I'd like to check holiday items please!"") .addPlayer(HeadE.CALM, ""I'd like to check holiday items please!"") //TODO //.addNPC(DIANGO, HeadE.HAPPY_TALKING, ""Sure thing, let me just see what you're missing."") //.addNext(() -> { // Open holiday item interface (468) // }) .addNPC(DIANGO, HeadE.SHAKING_HEAD, ""I seem to have mislaid my crate of holiday items, Sorry!""); ops.add(""What else are you selling?"") .addPlayer(HeadE.CALM_TALK, ""What else are you selling?"") .addNext(() -> ShopsHandler.openShop(e.getPlayer(), ""diangos_toy_store"")); ops.add(""I'm fine, thanks."") .addPlayer(HeadE.HAPPY_TALKING, ""I'm fine, thanks.""); }) ); } }); public static NPCClickHandler HandleFortunato= new NPCClickHandler(new Object[]{ FORTUNATO }, e -> { switch (e.getOption()) { case ""Trade"" -> ShopsHandler.openShop(e.getPlayer(), ""fortunatos_fine_wine""); case ""Talk-to"" -> e.getPlayer().startConversation(new Dialogue() .addPlayer(HeadE.CALM_TALK, ""Hello. What are you doing here?"") .addNPC(FORTUNATO, HeadE.SKEPTICAL_THINKING, ""Can I help you at all?"") .addOptions(ops -> { ops.add(""Yes, what are you selling?"") .addNext(() -> ShopsHandler.openShop(e.getPlayer(), ""fortunatos_fine_wine"")); if (Quest.RAG_AND_BONE_MAN.isImplemented() && e.getPlayer().getQuestManager().isComplete(Quest.RAG_AND_BONE_MAN)) ops.add(""Talk about Rag and Bone Man"") .addNPC(FORTUNATO, HeadE.SCARED, ""Oh, you've come back. Please, I haven't got any more vinegar. Give me some time, I beg you."") .addPlayer(HeadE.CALM, ""I wasn't after vinegar today."") .addNPC(FORTUNATO, HeadE.SKEPTICAL_THINKING, ""Oh, wonderful.I will have some in soon if 'he' needs it.""); ops.add(""Wine merchant, huh?"") .addNPC(FORTUNATO, HeadE.HAPPY_TALKING, ""Yes, indeed. The finest wines in Misthalin. Care to take a look at my wares?"") .addOptions(ops2 -> { ops2.add(""Yes."") .addNext(() -> ShopsHandler.openShop(e.getPlayer(), ""fortunatos_fine_wine"")); ops2.add(""Not at the moment.""); }); if (Quest.VAMPYRE_SLAYER.isImplemented() && e.getPlayer().getQuestManager().isComplete(Quest.VAMPYRE_SLAYER)) ops.add(""Talk about Vampyre Slayer."") .addNPC(FORTUNATO, HeadE.AMAZED_MILD, ""Well done killing that vampyre. Business has certainly improved since the attacks have stopped."") .addPlayer(HeadE.HAPPY_TALKING, ""Happy to help.""); }) ); } }); public static ItemOnNPCHandler BottleonFortunato = new ItemOnNPCHandler(FORTUNATO, e -> { if (e.getItem().getId() != 7921) return; e.getPlayer().getInventory().deleteItem(7921, 1); e.getPlayer().getInventory().addCoins(2); e.getPlayer().startConversation(new Dialogue() .addNPC(FORTUNATO, HeadE.SKEPTICAL_THINKING, ""Ah! I buy wine bottles back if you want to hand them all over."") ); }); public static NPCClickHandler HandleMissSchism= new NPCClickHandler(new Object[]{ MISS_SCHISM }, e -> { switch (e.getOption()) { case ""Talk-to"" -> e.getPlayer().startConversation(new Dialogue() .addNPC(MISS_SCHISM, HeadE.CALM, ""Oooh, my dear, have you heard the news?"") .addOptions(ops -> { ops.add(""Ok, tell me about the news."") .addNPC(MISS_SCHISM, HeadE.UPSET, ""It's terrible, absolutely terrible! Those poor people!"") .addPlayer(HeadE.CONFUSED, ""Ok, yeah."") .addNPC(MISS_SCHISM, HeadE.UPSET, ""And who'd have ever thought such a sweet old gentleman would do such a thing?"") .addPlayer(HeadE.CONFUSED, ""Are we talking about the bank robbery?"") .addNPC(MISS_SCHISM, HeadE.UPSET, ""Oh yes, my dear. It was terrible! TERRIBLE!"") .addNPC(MISS_SCHISM, HeadE.UPSET_SNIFFLE, ""But tell me - have you been around here before, or are you new to these parts?"") .addOptions(ops2 -> { ops2.add(""I'm quite new."") .addPlayer(HeadE.HAPPY_TALKING, "" I'm quite new."") .addNPC(MISS_SCHISM, HeadE.UPSET, ""Aah, perhaps you missed the excitement. It's that old man in this house here. Do you know him?"") .addPlayer(HeadE.CONFUSED, ""Well, I know of him."") .addNPC(MISS_SCHISM, HeadE.UPSET, ""When he first moved here, he didn't bring much. From the window you could see he just had some old furniture and a few dusty ornaments."") .addNPC(MISS_SCHISM, HeadE.UPSET, ""He always seemed so poor. When I went round to collect donations for the Draynor Manor Restoration Fund, he couldn't spare them a penny!"") .addPlayer(HeadE.CONFUSED, ""So he's redecorated?"") .addNPC(MISS_SCHISM, HeadE.ANGRY, ""Well, just you look in there now!"") .addNPC(MISS_SCHISM, HeadE.ANGRY, ""You see? It's full of jewellery and decorations! And all those expensive things appeared just after the bank got robbed."") .addNPC(MISS_SCHISM, HeadE.ANGRY, ""He changed his hat too - he used to wear a scruffy old black thing, but suddenly he was wearing that party hat!"") .addPlayer(HeadE.AMAZED_MILD, ""So that's why you're telling people he was the bank robber?"") .addNPC(MISS_SCHISM, HeadE.SKEPTICAL_THINKING, ""Oooh, my dear, I'm SURE of it! I went upstairs in his house once, while he was out walking, and do you know what I found?"") .addPlayer(HeadE.CONFUSED, ""A sign saying 'Trespassers will be prosecuted'?"") .addNPC(MISS_SCHISM, HeadE.ANGRY, ""No, it was a telescope! It was pointing right at the bank! He was spying on the bankers, planning the big robbery!"") .addNPC(MISS_SCHISM, HeadE.SKEPTICAL, ""I bet if you go and look through it now, you'll find it's pointing somewhere different now he's finished with the bank."") .addPlayer(HeadE.CONFUSED, ""I'd like to go now."") .addNPC(MISS_SCHISM, HeadE.SKEPTICAL_THINKING, ""Oh, really? Well, do keep an eye on him - I just KNOW he's planning something...""); ops2.add(""I've been around here for ages."") .addPlayer(HeadE.HAPPY_TALKING, "" I've been around here for ages."") .addNPC(MISS_SCHISM, HeadE.UPSET, ""Ah, so you'd have seen the changes here. It's that old man in this house here. Do you know him?"") .addPlayer(HeadE.CONFUSED, ""Well, I know of him."") .addNPC(MISS_SCHISM, HeadE.UPSET, ""When he first moved here, he didn't bring much. From the window you could see he just had some old furniture and a few dusty ornaments."") .addNPC(MISS_SCHISM, HeadE.UPSET, ""He always seemed so poor. When I went round to collect donations for the Draynor Manor Restoration Fund, he couldn't spare them a penny!"") .addPlayer(HeadE.CONFUSED, ""So he's redecorated?"") .addNPC(MISS_SCHISM, HeadE.ANGRY, ""Well, just you look in there now!"") .addNPC(MISS_SCHISM, HeadE.ANGRY, ""You see? It's full of jewellery and decorations! And all those expensive things appeared just after the bank got robbed."") .addNPC(MISS_SCHISM, HeadE.ANGRY, ""He changed his hat too - he used to wear a scruffy old black thing, but suddenly he was wearing that party hat!"") .addPlayer(HeadE.AMAZED_MILD, ""So that's why you're telling people he was the bank robber?"") .addNPC(MISS_SCHISM, HeadE.SKEPTICAL_THINKING, ""Oooh, my dear, I'm SURE of it! I went upstairs in his house once, while he was out walking, and do you know what I found?"") .addPlayer(HeadE.CONFUSED, ""A sign saying 'Trespassers will be prosecuted'?"") .addNPC(MISS_SCHISM, HeadE.ANGRY, ""No, it was a telescope! It was pointing right at the bank! He was spying on the bankers, planning the big robbery!"") .addNPC(MISS_SCHISM, HeadE.SKEPTICAL, ""I bet if you go and look through it now, you'll find it's pointing somewhere different now he's finished with the bank."") .addPlayer(HeadE.CONFUSED, ""I'd like to go now."") .addNPC(MISS_SCHISM, HeadE.SKEPTICAL_THINKING, ""Oh, really? Well, do keep an eye on him - I just KNOW he's planning something...""); ops2.add(""I've had enough of talking to you."") .addPlayer(HeadE.CALM_TALK, ""I've had enough of talking to you."") .addNPC(MISS_SCHISM, HeadE.CALM_TALK, ""Maybe another time, my dear.""); }); ops.add(""Who are you?"") .addPlayer(HeadE.CONFUSED, ""Who are you?"") .addNPC(MISS_SCHISM, HeadE.CALM_TALK, ""I, my dear, am a concerned citizen of Draynor Village. Ever since the Council allowed those farmers to set up their stalls here, we've had a constant flow of thieves and murderers through our fair village."") .addNPC(MISS_SCHISM, HeadE.CALM_TALK, ""I decided that someone HAD to stand up and keep an eye on the situation."") .addNPC(MISS_SCHISM, HeadE.CALM_TALK, ""I also do voluntary work for the Draynor Manor Restoration Fund. We're campaigning to have Draynor Manor turned into a museum before the wet- rot destroys it completely."") .addPlayer(HeadE.CONFUSED, ""Right...""); ops.add(""I'm not talking to you, you horrible woman."") .addPlayer(HeadE.ANGRY, ""I'm not talking to you, you horrible woman."") .addNPC(MISS_SCHISM, HeadE.ANGRY, ""Oooh.""); }) ); } }); public static NPCClickHandler HandleOlivia= new NPCClickHandler(new Object[]{ OLIVIA }, e -> { switch (e.getOption()) { case ""Trade"" -> ShopsHandler.openShop(e.getPlayer(), ""draynor_seed_market""); case ""Talk-to"" -> e.getPlayer().startConversation(new Dialogue() .addNPC(DIANGO, HeadE.HAPPY_TALKING, ""Would you like to trade in seeds?"") .addOptions(ops -> { ops.add(""Yes."") .addNext(() -> ShopsHandler.openShop(e.getPlayer(), ""draynor_seed_market"")); ops.add(""No.!"") .addPlayer(HeadE.CALM, ""No, thanks.""); ops.add(""Where do I get rarer seeds from?"") .addPlayer(HeadE.CALM_TALK, ""Where do I get rarer seeds from?"") .addNPC(OLIVIA, HeadE.CALM_TALK, ""The Master Farmers usually carry a few rare seeds around with them, although I don't know if they'd want to part with them for any price to be honest.""); }) ); } }); public static NPCClickHandler HandleStrangers= new NPCClickHandler(new Object[]{ SHADY_STRANGER, SUSPICIOUS_OUTSIDER }, e -> { switch (e.getOption()) { case ""Talk-to"" -> e.getPlayer().startConversation(new Dialogue() .addPlayer(HeadE.CALM_TALK, ""Hello. What are you doing here?"") .addNPC(e.getNPCId(), HeadE.SKEPTICAL_THINKING, ""Err, nothing much, I'm just here on business. Heard Draynor's a nice place to visit."") ); } }); public static ObjectClickHandler HandleTreeGuard = new ObjectClickHandler(new Object[] { 10041 }, e -> { switch (e.getOption()) { case ""Chop down"" -> TreeGuardResponse(e.getPlayer()); case ""Talk to"" -> { if(!e.getPlayer().getInventory().containsItem(2003)) e.getPlayer().startConversation(new Dialogue() .addPlayer(HeadE.CALM_TALK, ""Hello. What are you doing?"") .addNPC(MARKET_GUARD, HeadE.VERY_FRUSTRATED, ""Ssshhh! What do you want?"") .addPlayer(HeadE.CONFUSED,""Well, it's not every day you see a man up a tree!"") .addNPC(MARKET_GUARD, HeadE.VERY_FRUSTRATED, ""I'm trying to observe a suspect. Leave me alone!"")); else { e.getPlayer().startConversation(new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Hello?"") .addNPC(MARKET_GUARD, HeadE.SKEPTICAL, ""Yes, what do you... I say, is that stew for me?"") .addOptions(ops -> { ops.add(""Ok, take the stew!"") .addPlayer(HeadE.HAPPY_TALKING, ""Ok, take the stew!"") .addNPC(MARKET_GUARD,HeadE.HAPPY_TALKING,""Gosh, that's very kind of you! Here, have a few coins for your trouble..."") .addNext(() -> { e.getPlayer().getInventory().deleteItem(2003, 1); e.getPlayer().getInventory().addCoins(30); e.getPlayer().sendMessage(""The guard drops the empty bowl out of the tree!""); World.addGroundItem(new Item(1923, 1), Tile.of(3085, 3244, 0)); }); ops.add(""No, I want to keep this stew!"") .addPlayer(HeadE.SHAKING_HEAD, ""No, I want to keep this stew!"") .addNPC(MARKET_GUARD,HeadE.UPSET,""Fair enough. But if you change your mind, I'll probably still be here.""); }) ); } } } }); public static void TreeGuardResponse(Player player) { switch (Utils.random(1, 8)) { case 1 -> player.npcDialogue(MARKET_GUARD, HeadE.ANGRY,""Ooooch!""); case 2 -> player.npcDialogue(MARKET_GUARD, HeadE.ANGRY,""Oi!""); case 3 -> player.npcDialogue(MARKET_GUARD, HeadE.ANGRY,""Ow! That really hurt!""); case 4 -> player.npcDialogue(MARKET_GUARD, HeadE.ANGRY,""Watch what you're doing with that axe, you nit!""); case 5 -> player.npcDialogue(MARKET_GUARD, HeadE.ANGRY,""You'll blow my cover! I'm meant to be hidden!""); case 6 -> player.npcDialogue(MARKET_GUARD, HeadE.ANGRY,""Will you stop that?""); case 7 -> player.npcDialogue(MARKET_GUARD, HeadE.ANGRY,""Don't draw attention to me!""); case 8 -> player.npcDialogue(MARKET_GUARD, HeadE.ANGRY,""Hey - gerroff me!""); } } public static ItemOnObjectHandler HandleTreeGuardStew = new ItemOnObjectHandler(new Object[] { 10041 }, null, e -> { if (e.getItem().getId() != 2003) e.getPlayer().startConversation(new Dialogue() .addNPC(MARKET_GUARD, HeadE.ANGRY, ""Why the demoninikin are you waving THAT at me?"") .addPlayer(HeadE.UPSET, ""Sorry, I thought you'd like it."") .addNPC(MARKET_GUARD, HeadE.ANGRY, ""Erm... No thanks! Now, if you don't mind, I'm trying to observe this suspect!"") .addPlayer(HeadE.UPSET, ""Sorry."")); else { e.getPlayer().getInventory().deleteItem(2003, 1); e.getPlayer().getInventory().addCoins(30); e.getPlayer().startConversation(new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Here's some stew."") .addNPC(MARKET_GUARD, HeadE.HAPPY_TALKING, ""Gosh, that's very kind of you! Here, have a few coins for your trouble..."")); e.getPlayer().sendMessage(""The guard drops the empty bowl out of the tree!""); World.addGroundItem(new Item(1923, 1), Tile.of(3085,3244,0)); } }); }" "package com.rs.game.content.world.areas.draynor.npcs; @PluginEventHandler public class WiseOldMan { public static NPCClickHandler handleTalk = new NPCClickHandler(new Object[] { 3820 }, e -> { Player player = e.getPlayer(); NPC npc = e.getNPC(); Dialogue skillcape = new Dialogue() .addNPC(npc, HeadE.HAPPY_TALKING, ""Greetings! What can I do for you?""); if (player.getQuestManager().completedAllQuests()) { skillcape.addPlayer(HeadE.CONFUSED, ""I was wondering if you could sell me a quest cape! I have completed all the quests."") .addNPC(npc, HeadE.LAUGH, ""Impressive! I see you have! It will cost you 99,000 coins, though."") .addOption(""Choose an option"", ""Yes, I have that with me now."", ""Sorry, nevermind.""); if (player.getInventory().hasCoins(99000)) { skillcape.addPlayer(HeadE.HAPPY_TALKING, ""Yeah I have that with me. Here you go."") .addNPC(npc, HeadE.LAUGH, ""Wear the cape with pride, adventurer."", () -> { if (player.getInventory().hasCoins(99000)) { player.getInventory().removeCoins(99000); player.getInventory().addItemDrop(9814, 1); player.getInventory().addItemDrop(9813, 1); } }); } } else { skillcape.addPlayer(HeadE.CONFUSED, ""I'm not sure. What can you do for me?"") .addNPC(npc, HeadE.HAPPY_TALKING, ""I can offer you a quest cape once you reach maximum quest points.""); } player.startConversation(skillcape); }); }" "package com.rs.game.content.world.areas.dungeons; @PluginEventHandler public class AncientGuthixTemple { public static ObjectClickHandler handleClimbWall = new ObjectClickHandler(false, new Object[] { 40261, 40262 }, e -> e.getPlayer().walkToAndExecute(e.getObject().getTile().transform(0, 1, 0), () -> e.getPlayer().useStairs(-1, e.getPlayer().transform(0, -1, 1), 1, 1))); public static ObjectClickHandler handleJumpDownWall = new ObjectClickHandler(new Object[] { 40849 }, e -> e.getPlayer().useStairs(-1, e.getPlayer().transform(0, 1, -1), 1, 1)); public static ObjectClickHandler handleSkullEntrance = new ObjectClickHandler(new Object[] { 48248 }, e -> e.getPlayer().useStairs(-1, Tile.of(2525, 5810, 0), 1, 1)); public static ObjectClickHandler handleSkullExit = new ObjectClickHandler(new Object[] { 41077 }, e -> e.getPlayer().useStairs(-1, Tile.of(2527, 5830, 2), 1, 1)); }" "package com.rs.game.content.world.areas.dungeons; @PluginEventHandler public class BrimhavenDungeon { public static ObjectClickHandler handleVines = new ObjectClickHandler(new Object[] { 5103, 5104, 5105, 5106, 5107 }, e -> { Hatchet defs = Hatchet.getBest(e.getPlayer()); if (defs == null) { e.getPlayer().sendMessage(""You need a hatchet that you are able to use at your Woodcutting level to chop this.""); return; } e.getPlayer().lock(); e.getPlayer().anim(defs.animNormal()); WorldTasks.schedule(new Task() { @Override public void run() { Tile tile = Tile.of(e.getObject().getTile()); if (e.getObject().getRotation() == 3 || e.getObject().getRotation() == 1) tile = e.getObject().getTile().transform(e.getPlayer().getX() < e.getObject().getX() ? 1 : -1, 0, 0); else tile = e.getObject().getTile().transform(0, e.getPlayer().getY() < e.getObject().getY() ? 1 : -1, 0); e.getPlayer().unlock(); e.getPlayer().tele(tile); } }, 4); }); public static ObjectClickHandler handleSteppingStones = new ObjectClickHandler(new Object[] { 5110, 5111 }, e -> { if (!Agility.hasLevel(e.getPlayer(), 12)) return; e.getPlayer().lock(); e.getPlayer().forceMove(e.getObject().getTile(), 741, 0, 30, false); if (e.getObject().getId() == 5110) WorldTasks.scheduleLooping(new Task() { int ticks = 0; @Override public void run() { ticks++; if (ticks == 1) e.getPlayer().tele(e.getObject().getTile()); else if (ticks == 2 || ticks == 3) { Tile next = e.getPlayer().transform(0, -1, 0); if (ticks == 2) { e.getPlayer().forceMove(next, 741, 0, 30, false); } else e.getPlayer().tele(next); } else if (ticks == 4 || ticks == 5) { Tile next = e.getPlayer().transform(-1, 0, 0); if (ticks == 4) { e.getPlayer().forceMove(next, 741, 0, 30, false); } else e.getPlayer().tele(next); } else if (ticks == 6 || ticks == 7) { Tile next = e.getPlayer().transform(-1, 0, 0); if (ticks == 6) { e.getPlayer().forceMove(next, 741, 0, 30, false); } else e.getPlayer().tele(next); } else if (ticks == 8 || ticks == 9) { Tile next = e.getPlayer().transform(0, -1, 0); if (ticks == 8) { e.getPlayer().forceMove(next, 741, 0, 30, false); } else e.getPlayer().tele(next); } else if (ticks == 10 || ticks == 11) { Tile next = e.getPlayer().transform(0, -1, 0); if (ticks == 10) { e.getPlayer().forceMove(next, 741, 0, 30, false); } else e.getPlayer().tele(next); } else { e.getPlayer().unlock(); stop(); return; } } }, 0, 0); else WorldTasks.scheduleLooping(new Task() { int ticks = 0; @Override public void run() { ticks++; if (ticks == 1) e.getPlayer().tele(e.getObject().getTile()); else if (ticks == 2 || ticks == 3) { Tile next = e.getPlayer().transform(0, 1, 0); if (ticks == 2) { e.getPlayer().forceMove(next, 741, 0, 30, false); } else e.getPlayer().tele(next); } else if (ticks == 4 || ticks == 5) { Tile next = e.getPlayer().transform(0, 1, 0); if (ticks == 4) { e.getPlayer().forceMove(next, 741, 0, 30, false); } else e.getPlayer().tele(next); } else if (ticks == 6 || ticks == 7) { Tile next = e.getPlayer().transform(1, 0, 0); if (ticks == 6) { e.getPlayer().forceMove(next, 741, 0, 30, false); } else e.getPlayer().tele(next); } else if (ticks == 8 || ticks == 9) { Tile next = e.getPlayer().transform(1, 0, 0); if (ticks == 8) { e.getPlayer().forceMove(next, 741, 0, 30, false); } else e.getPlayer().tele(next); } else if (ticks == 10 || ticks == 11) { Tile next = e.getPlayer().transform(0, 1, 0); if (ticks == 10) { e.getPlayer().forceMove(next, 741, 0, 30, false); } else e.getPlayer().tele(next); } else { e.getPlayer().unlock(); stop(); return; } } }, 0, 0); }); public static ObjectClickHandler handleRedDragonJump = new ObjectClickHandler(false, new Object[] { 55342 }, e -> { if (!Agility.hasLevel(e.getPlayer(), 34)) return; e.getPlayer().walkToAndExecute(Tile.of(2681, 9540, 0), () -> e.getPlayer().forceMove(Tile.of(2681, 9537, 0), 14717, 0, 30, () -> { e.getPlayer().setNextAnimation(new Animation(14718)); e.getPlayer().tele(Tile.of(2697, 9524, 0)); })); }); public static ObjectClickHandler handleRedDragonLogBalance = new ObjectClickHandler(new Object[] { 5088, 5090 }, e -> { if (!Agility.hasLevel(e.getPlayer(), 30)) return; final int id = e.getObject().getId(); boolean back = id == 5088; e.getPlayer().lock(4); final Tile tile = back ? Tile.of(2687, 9506, 0) : Tile.of(2682, 9506, 0); final boolean isRun = e.getPlayer().isRunning(); e.getPlayer().setRun(false); e.getPlayer().addWalkSteps(tile.getX(), tile.getY(), -1, false); WorldTasks.schedule(new Task() { @Override public void run() { e.getPlayer().setRun(isRun); } }, 4); }); public static ObjectClickHandler handleStairs = new ObjectClickHandler(new Object[] { 5094, 5096, 5097, 5098 }, e -> { switch(e.getObjectId()) { case 5094: e.getPlayer().tele(Tile.of(2643, 9595, 2)); break; case 5096: e.getPlayer().tele(Tile.of(2649, 9591, 0)); break; case 5097: e.getPlayer().tele(Tile.of(2637, 9510, 2)); break; case 5098: e.getPlayer().tele(Tile.of(2637, 9517, 0)); break; } }); }" "package com.rs.game.content.world.areas.dungeons; @PluginEventHandler public class FremennikSlayerDungeon { public static ObjectClickHandler handleChasm = new ObjectClickHandler(false, new Object[] { 44339 }, e -> { if (!Agility.hasLevel(e.getPlayer(), 81)) return; final Tile toTile = e.getPlayer().getX() < 2772 ? Tile.of(2775, 10002, 0) : Tile.of(2768, 10002, 0); e.getPlayer().walkToAndExecute(e.getPlayer().getX() > 2772 ? Tile.of(2775, 10002, 0) : Tile.of(2768, 10002, 0), () -> e.getPlayer().forceMove(toTile, 4721, 20, 85, () -> e.getPlayer().anim(-1))); }); public static ObjectClickHandler handleShortcut2 = new ObjectClickHandler(new Object[] { 9321 }, e -> { if (!Agility.hasLevel(e.getPlayer(), 62)) return; e.getPlayer().forceMove(e.getPlayer().transform(e.getObject().getRotation() == 0 ? 5 : -5, 0), 3844, 25, 75); }); }" "package com.rs.game.content.world.areas.dungeons; @PluginEventHandler public class HAMDungeon { public static LoginHandler unlockTrapdoor = new LoginHandler(e -> e.getPlayer().getVars().setVarBit(2270, 2)); public static ObjectClickHandler handleKeyTrapdoor = new ObjectClickHandler(new Object[] { 15766, 15747 }, e -> { if (e.getObjectId() == 15766) { if (e.getOption().equals(""Climb-down"")) e.getPlayer().useLadder(Tile.of(2568, 5185, 0)); } else e.getPlayer().useLadder(Tile.of(3166, 9623, 0)); }); }" "package com.rs.game.content.world.areas.dungeons; @PluginEventHandler public class KuradalsDungeon { public static ObjectClickHandler handleBarriers = new ObjectClickHandler(new Object[] { 47236 }, e -> { if (e.getObject().getRotation() == 2) e.getPlayer().walkOneStep(e.getPlayer().getX() > e.getObject().getX() ? -1 : 1, 0, false); else e.getPlayer().walkOneStep(0, e.getPlayer().getY() == e.getObject().getY() ? -1 : 1, false); }); public static ObjectClickHandler handleWallRunShortcut = new ObjectClickHandler(new Object[] { 47237 }, e -> { Player p = e.getPlayer(); if(p.getSkills().getLevel(Skills.AGILITY) < 90) { p.getPackets().sendGameMessage(""You need level 90 agility to use this shortcut.""); return; } WorldTasks.scheduleLooping(new Task() { int ticks = 0; boolean isPlayerNorth = true; @Override public void run() { if(ticks == 0) if (p.getX() == 1641 && p.getY() == 5268) { p.setNextAnimation(new Animation(2929)); isPlayerNorth = true; } else if (p.getX() == 1641 && p.getY() == 5260) { p.setNextAnimation(new Animation(2922)); isPlayerNorth = false; } else return; if (ticks == 1) { p.forceMove(isPlayerNorth ? Tile.of(1641, 5260, 0) : Tile.of(1641, 5268, 0), 0, 30); stop(); } ticks++; } }, 0, 1); }); public static ObjectClickHandler handleLowWall = new ObjectClickHandler(new Object[] { 47233, 47234, 47235 }, e -> { Player p = e.getPlayer(); if(p.getSkills().getLevel(Skills.AGILITY) < 86) { p.getPackets().sendGameMessage(""You need level 86 agility to use this shortcut.""); return; } WorldTasks.scheduleLooping(new Task() { int ticks = 0; boolean isPlayerNorth = true; @Override public void run() { if (ticks == 0) { if (p.getX() == 1633 && p.getY() == 5294) { p.setFaceAngle(Direction.getAngleTo(Direction.SOUTH)); p.setNextAnimation(new Animation(839)); isPlayerNorth = true; } else if (p.getX() == 1633 && p.getY() == 5292) { p.setFaceAngle(Direction.getAngleTo(Direction.NORTH)); p.setNextAnimation(new Animation(839)); isPlayerNorth = false; } else return; } else if (ticks >= 1) { if (isPlayerNorth) p.tele(Tile.of(1633, 5292, 0)); if (!isPlayerNorth) p.tele(Tile.of(1633, 5294, 0)); stop(); } ticks++; } }, 0, 1); }); public static ObjectClickHandler handleEntrances = new ObjectClickHandler(new Object[] { 47232 }, e -> { if (e.getPlayer().getSlayer().getTask() != null) { TaskMonster currentTask = e.getPlayer().getSlayer().getTask().getMonster(); switch (currentTask) { case HELLHOUNDS: case GREATER_DEMONS: case BLUE_DRAGONS: case GARGOYLES: case ABYSSAL_DEMONS: case DARK_BEASTS: case IRON_DRAGONS: case STEEL_DRAGONS: e.getPlayer().getControllerManager().startController(new KuradalDungeonController()); return; default: } } e.getPlayer().sendMessage(""Sorry, this dungeon is exclusive only to those who need to go in there.""); }); }" "package com.rs.game.content.world.areas.dungeons; @PluginEventHandler public class LivingRock extends NPC { private Entity source; private long deathTime; public LivingRock(int id, Tile tile, boolean spawned) { super(id, tile, spawned); setForceAggroDistance(4); setIgnoreDocile(true); } @Override public void sendDeath(final Entity source) { final NPCCombatDefinitions defs = getCombatDefinitions(); resetWalkSteps(); getCombat().removeTarget(); setNextAnimation(null); WorldTasks.scheduleTimer(loop -> { if (loop == 0) setNextAnimation(new Animation(defs.getDeathEmote())); else if (loop >= defs.getDeathDelay()) { drop(); reset(); transformIntoRemains(source); return false; } return true; }); } public void transformIntoRemains(Entity source) { this.source = source; deathTime = System.currentTimeMillis(); final int remainsId = getId() + 5; transformIntoNPC(remainsId); setRandomWalk(false); WorldTasks.schedule(Ticks.fromMinutes(3), () -> { try { if (remainsId == getId()) takeRemains(); } catch (Throwable e) { Logger.handle(LivingRock.class, ""transformIntoRemains"", e); } }); } public boolean canMine(Player player) { return System.currentTimeMillis() - deathTime > 60000 || player == source; } public void takeRemains() { setNPC(getId() - 5); setLocation(getRespawnTile()); setRandomWalk(true); finish(); if (!isSpawned()) setRespawnTask(); } public static NPCInstanceHandler toFunc = new NPCInstanceHandler(new Object[] { 8832, 8833, 8834 }, (npcId, tile) -> new LivingRock(npcId, tile, false)); }" "package com.rs.game.content.world.areas.dungeons; @PluginEventHandler public final class LivingRockCavern { private static enum Rocks { COAL_ROCK_1(new GameObject(5999, ObjectType.SCENERY_INTERACT, 1, 3690, 5146, 0)), COAL_ROCK_2(new GameObject(5999, ObjectType.SCENERY_INTERACT, 2, 3690, 5125, 0)), COAL_ROCK_3(new GameObject(5999, ObjectType.SCENERY_INTERACT, 0, 3687, 5107, 0)), COAL_ROCK_4(new GameObject(5999, ObjectType.SCENERY_INTERACT, 1, 3674, 5098, 0)), COAL_ROCK_5(new GameObject(5999, ObjectType.SCENERY_INTERACT, 2, 3664, 5090, 0)), COAL_ROCK_6(new GameObject(5999, ObjectType.SCENERY_INTERACT, 3, 3615, 5090, 0)), COAL_ROCK_7(new GameObject(5999, ObjectType.SCENERY_INTERACT, 1, 3625, 5107, 0)), COAL_ROCK_8(new GameObject(5999, ObjectType.SCENERY_INTERACT, 3, 3647, 5142, 0)), GOLD_ROCK_1(new GameObject(45076, ObjectType.SCENERY_INTERACT, 1, 3667, 5075, 0)), GOLD_ROCK_2(new GameObject(45076, ObjectType.SCENERY_INTERACT, 0, 3637, 5094, 0)), GOLD_ROCK_3(new GameObject(45076, ObjectType.SCENERY_INTERACT, 0, 3677, 5160, 0)), GOLD_ROCK_4(new GameObject(45076, ObjectType.SCENERY_INTERACT, 1, 3629, 5148, 0)); private Rocks(GameObject rock) { this.rock = rock; } private final GameObject rock; } private static void respawnRock(final Rocks rock) { World.spawnObject(rock.rock); WorldTasks.schedule(Ticks.fromMinutes(Utils.random(8) + 3), () -> { try { removeRock(rock); } catch (Throwable e) { Logger.handle(LivingRockCavern.class, ""respawnRock"", e); } }); } private static void removeRock(final Rocks rock) { World.removeObject(rock.rock); WorldTasks.schedule(Ticks.fromMinutes(3), () -> { try { respawnRock(rock); } catch (Throwable e) { Logger.handle(LivingRockCavern.class, ""removeRock"", e); } }); } @ServerStartupEvent public static void init() { for (Rocks rock : Rocks.values()) respawnRock(rock); } }" "package com.rs.game.content.world.areas.dungeons; public class LivingRockStrickerCombat extends CombatScript { @Override public Object[] getKeys() { return new Object[] { 8833 }; } @Override public int attack(final NPC npc, final Entity target) { final NPCCombatDefinitions defs = npc.getCombatDefinitions(); int distanceX = target.getX() - npc.getX(); int distanceY = target.getY() - npc.getY(); int size = npc.getSize(); if ((distanceX <= size) && (distanceX >= -1) && (distanceY <= size) && (distanceY >= -1)) { npc.setNextAnimation(new Animation(defs.getAttackEmote())); delayHit(npc, 0, target, getMeleeHit(npc, getMaxHit(npc, 84, AttackStyle.MELEE, target))); return npc.getAttackSpeed(); } // TODO add projectile npc.setNextAnimation(new Animation(12196)); delayHit(npc, 1, target, getRangeHit(npc, getMaxHit(npc, defs.getMaxHit(), AttackStyle.RANGE, target))); return npc.getAttackSpeed(); } }" "package com.rs.game.content.world.areas.dungeons; @PluginEventHandler public class LumbridgeSwampDungeon { public static ItemOnNPCHandler handleLightCreatures = new ItemOnNPCHandler(false, new Object[] { 2021, 2022 }, e -> { if (e.isAtNPC()) return; if (!e.getPlayer().isQuestComplete(Quest.WHILE_GUTHIX_SLEEPS, ""to lure the light creature."")) return; //spotanims 1932 1933 if (e.getItem().getId() == 4702) e.getPlayer().sendOptionDialogue(e.getNPC().getId() == 2021 ? ""Would you like to go down into the chasm?"" : ""Would you like to go back up the chasm?"", ops -> { ops.add(""Yes"", () -> e.getPlayer().tele(e.getNPC().getId() == 2021 ? Tile.of(2520, 5884, 0) : Tile.of(3219, 9527, 2))); ops.add(""No, that's scary""); }); }); public static ObjectClickHandler enterJunaArea = new ObjectClickHandler(new Object[] { 32944 }, e -> e.getPlayer().tele(Tile.of(3219, 9532, 2))); public static ObjectClickHandler exitJunaArea = new ObjectClickHandler(new Object[] { 6658 }, e -> e.getPlayer().tele(Tile.of(3226, 9542, 0))); public static ObjectClickHandler handleSteppingStone1 = new ObjectClickHandler(false, new Object[] { 5948 }, e -> { final boolean isRunning = e.getPlayer().getRun(); final boolean isWest = e.getPlayer().getX() < 3206; final Tile tile = isWest ? Tile.of(3208, 9572, 0) : Tile.of(3204, 9572, 0); e.getPlayer().lock(); e.getPlayer().setRun(true); e.getPlayer().addWalkSteps(isWest ? 3208 : 3204, 9572); WorldTasks.scheduleLooping(new Task() { int ticks = 0; @Override public void run() { ticks++; if (ticks == 2) e.getPlayer().setNextFaceTile(e.getObject().getTile()); else if (ticks == 3) e.getPlayer().forceMove(tile, 1995, 0, 120, () -> e.getPlayer().setRun(isRunning)); else if (ticks == 4) { e.getPlayer().setNextAnimation(new Animation(1603)); stop(); } } }, 0, 0); }); public static ObjectClickHandler handleSteppingStone2 = new ObjectClickHandler(false, new Object[] { 5949 }, e -> { final boolean isRunning = e.getPlayer().getRun(); final boolean isSouth = e.getPlayer().getY() < 9555; final Tile tile = isSouth ? Tile.of(3221, 9556, 0) : Tile.of(3221, 9553, 0); e.getPlayer().lock(); e.getPlayer().setRun(true); e.getPlayer().addWalkSteps(3221, isSouth ? 9556 : 9553); WorldTasks.scheduleLooping(new Task() { int ticks = 0; @Override public void run() { ticks++; if (ticks == 2) e.getPlayer().setNextFaceTile(e.getObject().getTile()); else if (ticks == 3) e.getPlayer().forceMove(tile, 1995, 0, 120, () -> e.getPlayer().setRun(isRunning)); else if (ticks == 4) { e.getPlayer().setNextAnimation(new Animation(1603)); stop(); } } }, 0, 0); }); }" "package com.rs.game.content.world.areas.dungeons; @PluginEventHandler public class MuspahDungeon { public static ObjectClickHandler handleExit = new ObjectClickHandler(new Object[] { 42891 }, e -> e.getPlayer().tele(Tile.of(2736, 3729, 0))); public static ObjectClickHandler handleEntrance = new ObjectClickHandler(new Object[] { 42793 }, e -> { //subtract 64 from x if muspah has not escaped e.getPlayer().tele(Tile.of(3485, 5511, 0)); }); public static ObjectClickHandler handleOpenings = new ObjectClickHandler(new Object[] { 42794, 42795 }, e -> e.getPlayer().tele(e.getPlayer().transform(0, e.getObjectId() == 42794 ? 8 : -8, 0))); public static ObjectClickHandler handleEnterIceStryke = new ObjectClickHandler(new Object[] { 48188 }, e -> e.getPlayer().tele(Tile.of(3435, 5646, 0))); public static ObjectClickHandler handleExitIceStryke = new ObjectClickHandler(new Object[] { 48189 }, e -> e.getPlayer().tele(Tile.of(3509, 5515, 0))); }" "package com.rs.game.content.world.areas.dungeons /** * interface 893-894 fungal storage */ @ServerStartupEvent fun mapPolypore() { data class Vine(val objectId: Int, val x: Int, val y: Int, val targetTile: Tile, val down: Boolean) fun useStairs(player: Player, tile: Tile, down: Boolean) { player.useStairs(if (down) 15458 else 15456, tile, 2, 3) // TODO find correct emote player.tasks.schedule(1) { player.anim(if (down) 15459 else 15457) } } val vines = listOf( Vine(64360, 4629, 5453, Tile.of(4629, 5451, 2), true), Vine(64361, 4629, 5452, Tile.of(4629, 5454, 3), false), Vine(64359, 4632, 5443, Tile.of(4632, 5443, 1), true), Vine(64361, 4632, 5442, Tile.of(4632, 5444, 2), false), Vine(64359, 4632, 5409, Tile.of(4632, 5409, 2), true), Vine(64361, 4633, 5409, Tile.of(4631, 5409, 3), false), Vine(64359, 4642, 5389, Tile.of(4642, 5389, 1), true), Vine(64361, 4643, 5389, Tile.of(4641, 5389, 2), false), Vine(64359, 4652, 5388, Tile.of(4652, 5388, 0), true), Vine(64362, 4652, 5387, Tile.of(4652, 5389, 1), false), Vine(64359, 4691, 5469, Tile.of(4691, 5469, 2), true), Vine(64361, 4691, 5468, Tile.of(4691, 5470, 3), false), Vine(64359, 4689, 5479, Tile.of(4689, 5479, 1), true), Vine(64361, 4689, 5480, Tile.of(4689, 5478, 2), false), Vine(64359, 4698, 5459, Tile.of(4698, 5459, 2), true), Vine(64361, 4699, 5459, Tile.of(4697, 5459, 3), false), Vine(64359, 4705, 5460, Tile.of(4704, 5461, 1), true), Vine(64361, 4705, 5461, Tile.of(4705, 5459, 2), false), Vine(64359, 4718, 5467, Tile.of(4718, 5467, 0), true), Vine(64361, 4718, 5466, Tile.of(4718, 5468, 1), false), Vine(64360, 4696, 5618, Tile.of(4696, 5618, 2), true), Vine(64361, 4696, 5617, Tile.of(4696, 5619, 3), false), Vine(64359, 4684, 5586, Tile.of(4684, 5588, 2), true), Vine(64361, 4684, 5587, Tile.of(4684, 5585, 3), false), Vine(64359, 4699, 5617, Tile.of(4699, 5617, 1), true), Vine(64361, 4698, 5617, Tile.of(4700, 5617, 2), false), Vine(64359, 4721, 5602, Tile.of(4720, 5601, 1), true), Vine(64361, 4720, 5602, Tile.of(4722, 5602, 2), false), Vine(64359, 4702, 5612, Tile.of(4702, 5610, 0), true), Vine(64361, 4702, 5611, Tile.of(4702, 5613, 1), false) ).associateBy { Triple(it.objectId, it.x, it.y) } onObjectClick(64359, 64360, 64361, 64362) { e -> val key = Triple(e.objectId, e.getObject().x, e.getObject().y) vines[key]?.let { useStairs(e.player, it.targetTile, it.down) } } onObjectClick(""Neem drupes"") { e -> if (e.option == ""Pick"") { e.player.inventory.addItemDrop(22445, 1) val vb = e.getObject().definitions.varpBit e.player.vars.setVarBit(vb, e.player.vars.getVarBit(vb) + 1) e.player.tasks.schedule(""neemRespawn$vb"", Ticks.fromSeconds(10)) { e.player.vars.setVarBit(vb, 0) } } } onItemClick(22445, options = arrayOf(""Squish"")) { e -> val jugOrOil = e.player.inventory.getItemById(22444) ?: e.player.inventory.getItemById(1935) if (jugOrOil == null) return@onItemClick e.player.sendMessage(""You need a jug to hold your oil."") jugOrOil.apply { if (id == 1935) { id = 22444 e.player.inventory.refresh(slot) } val newCharges = e.item.amount + getMetaDataI(""neemCharges"", 0) addMetaData(""neemCharges"", newCharges) e.player.sendMessage(""You add ${Utils.formatNumber(e.item.amount)} charges to your jug. It now contains ${Utils.formatNumber(newCharges)} charges."") } e.player.inventory.deleteItem(e.item) } onItemClick(22444, options = arrayOf(""Sprinkle"", ""Check"")) { e -> when(e.option) { ""Sprinkle"" -> { val polypores = World.getNPCsInChunkRange(e.player.chunkId, 1) .filter { !it.isDead && !it.hasFinished() && Utils.getDistance(it.tile, e.player.tile) <= 5 && it is PolyporeNPC && it.canInfect() } .map { it as PolyporeNPC } if (polypores.isEmpty()) { e.player.sendMessage(""There aren't any creatures around that would be affected."") return@onItemClick } e.player.sync(9954, 2014) if (e.item.decMetaDataI(""neemCharges"") <= 0) { e.item.id = 1935 e.player.inventory.refresh(e.slotId) } polypores.forEach { it.neem() } } ""Check"" -> e.player.sendMessage(""This jug contains "" + Utils.formatNumber(e.item.getMetaDataI(""neemCharges"", 0)) + "" ounces of oil."") } } }" "package com.rs.game.content.world.areas.dungeons; @PluginEventHandler public class StrongholdOfSecurity { public static ItemClickHandler handleSkullSceptreTele = new ItemClickHandler(new Object[] { 9013 }, new String[] { ""Invoke"" }, e -> Magic.sendTeleportSpell(e.getPlayer(), 9601, -1, 1683, -1, 0, 0, Tile.of(3080, 3424, 0), 4, true, TeleType.ITEM, null)); public static ObjectClickHandler handleEntrance = new ObjectClickHandler(new Object[] { 16154 }, e -> e.getPlayer().tele(Tile.of(1859, 5243, 0))); public static ObjectClickHandler handleExitLadders = new ObjectClickHandler(new Object[] { 16148, 16080, 16078, 16112, 16049, 16048 }, e -> e.getPlayer().ladder(Tile.of(3081, 3421, 0))); public static ObjectClickHandler handleF1Shortcut = new ObjectClickHandler(new Object[] { 16150 }, e -> { if (e.getPlayer().getEmotesManager().unlockedEmote(Emote.FLAP)) e.getPlayer().tele(Tile.of(1907, 5221, 0)); else e.getPlayer().sendMessage(""The portal does not allow you to enter yet.""); }); public static ObjectClickHandler handleF1DownLadder = new ObjectClickHandler(new Object[] { 16149 }, e -> e.getPlayer().tele(Tile.of(2042, 5245, 0))); public static ObjectClickHandler handleF2Shortcut = new ObjectClickHandler(new Object[] { 16082 }, e -> { if (e.getPlayer().getEmotesManager().unlockedEmote(Emote.SLAP_HEAD)) e.getPlayer().tele(Tile.of(2022, 5214, 0)); else e.getPlayer().sendMessage(""The portal does not allow you to enter yet.""); }); public static ObjectClickHandler handleF2DownLadder = new ObjectClickHandler(new Object[] { 16081 }, e -> e.getPlayer().ladder(Tile.of(2123, 5252, 0))); public static ObjectClickHandler handleF3Shortcut = new ObjectClickHandler(new Object[] { 16116 }, e -> { if (e.getPlayer().getEmotesManager().unlockedEmote(Emote.IDEA)) e.getPlayer().tele(Tile.of(2144, 5279, 0)); else e.getPlayer().sendMessage(""The portal does not allow you to enter yet.""); }); public static ObjectClickHandler handleF3DownLadder = new ObjectClickHandler(new Object[] { 16115 }, e -> e.getPlayer().ladder(Tile.of(2358, 5215, 0))); public static ObjectClickHandler handleF4Shortcut = new ObjectClickHandler(new Object[] { 16050 }, e -> { if (e.getPlayer().getEmotesManager().unlockedEmote(Emote.STOMP)) e.getPlayer().tele(Tile.of(2344, 5213, 0)); else e.getPlayer().sendMessage(""The portal does not allow you to enter yet.""); }); public static ObjectClickHandler handleGates = new ObjectClickHandler(new Object[] { 16123, 16124, 16065, 16066, 16089, 16090, 16043, 16044 }, e -> { e.getPlayer().lock(3); e.getPlayer().setNextAnimation(new Animation(4282)); e.getPlayer().soundEffect(2858, true); WorldTasks.schedule(new Task() { @Override public void run() { Tile tile = switch (e.getObject().getRotation()) { case 0 -> Tile.of(e.getObject().getX() == e.getPlayer().getX() ? e.getObject().getX() - 1 : e.getObject().getX(), e.getPlayer().getY(), 0); case 1 -> Tile.of(e.getPlayer().getX(), e.getObject().getY() == e.getPlayer().getY() ? e.getObject().getY() + 1 : e.getObject().getY(), 0); case 2 -> Tile.of(e.getObject().getX() == e.getPlayer().getX() ? e.getObject().getX() + 1 : e.getObject().getX(), e.getPlayer().getY(), 0); case 3 -> Tile.of(e.getPlayer().getX(), e.getObject().getY() == e.getPlayer().getY() ? e.getObject().getY() - 1 : e.getObject().getY(), 0); default -> null; }; e.getPlayer().tele(tile); e.getPlayer().setNextAnimation(new Animation(4283)); e.getPlayer().faceObject(e.getObject()); } }, 0); }); }" "package com.rs.game.content.world.areas.dungeons; @PluginEventHandler public class TaverlyDungeon { public static ObjectClickHandler handleVSBSecretLocation = new ObjectClickHandler(new Object[] { 11901, 11902 }, e -> e.getPlayer().useStairs(e.getObjectId() == 11901 ? Tile.of(4498, 5680, 0) : Tile.of(2915, 9673, 0))); public static ObjectClickHandler handlePipeSqueeze = new ObjectClickHandler(new Object[] { 9293 }, e -> { if (e.getPlayer().getSkills().getLevel(Constants.AGILITY) < 70) { e.getPlayer().sendMessage(""You need an agility level of 70 to use this obstacle."", true); return; } int x = e.getPlayer().getX() == 2886 ? 2892 : 2886; e.getPlayer().lock(); WorldTasks.schedule(0, () -> e.getPlayer().forceMove(Tile.of(x, 9799, 0), 10580, 0, 90)); }); public static ObjectClickHandler handleStrangeFloor = new ObjectClickHandler(new Object[] { 9294 }, e -> { if (!Agility.hasLevel(e.getPlayer(), 80)) return; final boolean isRunning = e.getPlayer().getRun(); final boolean isSouth = e.getPlayer().getY() > 9812; final Tile tile = isSouth ? Tile.of(2878, 9812, 0) : Tile.of(2881, 9814, 0); e.getPlayer().setRun(true); e.getPlayer().addWalkSteps(isSouth ? 2881 : 2877, isSouth ? 9814 : 9812); e.getPlayer().lock(); WorldTasks.scheduleLooping(new Task() { int ticks = 0; @Override public void run() { ticks++; if (ticks == 2) e.getPlayer().setNextFaceTile(e.getObject().getTile()); else if (ticks == 3) { e.getPlayer().forceMove(tile, 1995, 0, 100, false); } else if (ticks == 4) e.getPlayer().setNextAnimation(new Animation(1603)); else if (ticks == 7) { e.getPlayer().setRun(isRunning); e.getPlayer().unlock(); stop(); } } }, 0, 0); }); public static ObjectClickHandler handleEntrance = new ObjectClickHandler(new Object[] { 66991, 66992 }, e -> e.getPlayer().tele(e.getObjectId() == 66991 ? Tile.of(2885, 9795, 0) : Tile.of(2885, 3395, 0))); }" "package com.rs.game.content.world.areas.dungeons; @PluginEventHandler public class TempleOfLight { //Temple of Light public static ObjectClickHandler handletempleoflightstairswide = new ObjectClickHandler(new Object[] { 10015, 10016 }, e -> { if (e.getObjectId() == 10015) e.getPlayer().tele(e.getPlayer().transform(e.getObject().getRotation() == 1 ? 4 : e.getObject().getRotation() == 3 ? -4 : 0, e.getObject().getRotation() == 0 ? 4 : e.getObject().getRotation() == 2 ? -4 : 0, 1)); else if (e.getObjectId() == 10016) e.getPlayer().tele(e.getPlayer().transform(e.getObject().getRotation() == 1 ? -4 : e.getObject().getRotation() == 3 ? 4 : 0, e.getObject().getRotation() == 0 ? -4 : e.getObject().getRotation() == 2 ? 4 : 0, -1)); }); public static ObjectClickHandler handletempleoflightstairsthin = new ObjectClickHandler(new Object[] { 10018, 10017 }, e -> { if (e.getObjectId() == 10018) e.getPlayer().tele(e.getPlayer().transform(e.getObject().getRotation() == 1 ? -4 : e.getObject().getRotation() == 3 ? 4 : 0, e.getObject().getRotation() == 0 ? -4 : e.getObject().getRotation() == 2 ? 4 : 0, -1)); else if (e.getObjectId() == 10017) e.getPlayer().tele(e.getPlayer().transform(e.getObject().getRotation() == 1 ? 4 : e.getObject().getRotation() == 3 ? -4 : 0, e.getObject().getRotation() == 0 ? 4 : e.getObject().getRotation() == 2 ? -4 : 0, 1)); }); }" "package com.rs.game.content.world.areas.dungeons; @PluginEventHandler public class TzHaar { public static final int TOKKUL = 6529; public static final int TOKKUL_ZO_CHARGED = 23643; public static final int TOKKUL_ZO_UNCHARGED = 23644; private static final Tile[] TOKKUL_ZO_TELEPORTS = { Tile.of(4744, 5156, 0), Tile.of(4599, 5062, 0), Tile.of(4613, 5128, 0), Tile.of(4744, 5170, 0) }; public static ItemClickHandler handleCheckTokkulZoOptions = new ItemClickHandler(new Object[] { TOKKUL_ZO_CHARGED }, new String[] { ""Check-charge"", ""Check-charges"", ""Teleport"" }, e -> { if (!e.getPlayer().isQuestComplete(Quest.ELDER_KILN, ""to use the Tokkul-Zo."")) return; if (e.getOption().equals(""Teleport"")) { if (e.isEquipped()) { Magic.sendNormalTeleportSpell(e.getPlayer(), TOKKUL_ZO_TELEPORTS[2], () -> depleteTokkulZo(e.getPlayer())); } else e.getPlayer().sendOptionDialogue(""Where would you like to teleport?"", ops -> { ops.add(""Main Plaza"", () -> Magic.sendNormalTeleportSpell(e.getPlayer(), TOKKUL_ZO_TELEPORTS[0], () -> depleteTokkulZo(e.getPlayer()))); ops.add(""Fight Pits"", () -> Magic.sendNormalTeleportSpell(e.getPlayer(), TOKKUL_ZO_TELEPORTS[1], () -> depleteTokkulZo(e.getPlayer()))); ops.add(""Fight Caves"", () -> Magic.sendNormalTeleportSpell(e.getPlayer(), TOKKUL_ZO_TELEPORTS[2], () -> depleteTokkulZo(e.getPlayer()))); ops.add(""Fight Kiln"", () -> Magic.sendNormalTeleportSpell(e.getPlayer(), TOKKUL_ZO_TELEPORTS[3], () -> depleteTokkulZo(e.getPlayer()))); }); } else e.getPlayer().sendMessage(""Your Tokkul-Zo has "" + e.getItem().getMetaDataI(""tzhaarCharges"") + "" charges left.""); }); public static NPCClickHandler handleTzhaarMejJeh = new NPCClickHandler(new Object[] { 15166 }, e -> e.getPlayer().startConversation(new Conversation(e.getPlayer()) { { addNPC(15166, HeadE.CONFUSED, ""What do you need from me?""); addOptions(""What would you like to say?"", new Options() { @Override public void create() { boolean recTZ = player.getBool(""recTokkulZo""); if (!player.containsAnyItems(TOKKUL_ZO_UNCHARGED, TOKKUL_ZO_CHARGED)) if (player.isQuestComplete(Quest.ELDER_KILN, ""to obtain a Tokkul-Zo."")) option(""Can I have a Tokkul-Zo?"" + (recTZ ? "" I've lost mine."" : """"), new Dialogue() .addPlayer(HeadE.CONFUSED, ""Can I have a Tokkul-Zo?"" + (player.getBool(""recTokkulZo"") ? "" I've lost mine."" : """")) .addNPC(15166, HeadE.CALM_TALK, ""Alright, you have proven yourself. Try not to lose it."" + (recTZ ? """" : "" As this is your first time receiving the ring, I have fully charged it for you for free."")) .addPlayer(HeadE.CHEERFUL, ""Thank you!"") .addItem(TOKKUL_ZO_CHARGED, ""TzHaar-Mej-Jeh hands you a ring. It is extremely hot."", () -> { if (!player.getInventory().hasFreeSlots()) { player.sendMessage(""You don't have enough inventory space.""); return; } if (!recTZ) { player.getInventory().addItem(new Item(TOKKUL_ZO_CHARGED).addMetaData(""tzhaarCharges"", 3000)); player.save(""recTokkulZo"", true); } else player.getInventory().addItem(TOKKUL_ZO_UNCHARGED); })); option(""About the Tokkul-Zo"", new Dialogue() .addNPC(15166, HeadE.CONFUSED, ""You want to know more about Tokkul-Zo?"") .addPlayer(HeadE.CONFUSED, ""Yes, what does it do?"") .addNPC(15166, HeadE.CALM_TALK, ""This ring has a piece of Tokkul in it. When worn, it will guide "" + ""your hand and make you better when fighting TzHaar, fire creatures, and maybe even TokHaar."") .addPlayer(HeadE.CONFUSED, ""How does it do that?"") .addNPC(15166, HeadE.CALM_TALK, ""My magic taps into the memories in the ring, so you better at fighting like a TzHaar. "" + ""The magic will fade after time. When this happens, return to me and I will recharge it for you... for a price."") .addPlayer(HeadE.CONFUSED, ""What's your price?"") .addNPC(15166, HeadE.CALM_TALK, ""48,000 Tokkul for a full recharge. Normally I would do it for free, but we need all the Tokkul we can "" + ""get, so they we can melt it down in the sacred lave, and release our ancestors from their suffering."")); if (player.getItemWithPlayer(TOKKUL_ZO_UNCHARGED) != null || player.getItemWithPlayer(TOKKUL_ZO_CHARGED) != null) option(""Recharging the Tokkul-Zo"", new Dialogue() .addPlayer(HeadE.CONFUSED, ""Could you please recharge my ring?"") .addNPC(15166, HeadE.CALM_TALK, player.getInventory().containsItem(TOKKUL, 16) ? ""Of course. Here you go."" : ""You don't have enough Tokkul with you."", () -> rechargeTokkulZo(player))); } }); } })); public static void rechargeTokkulZo(Player player) { Item ring = player.getItemWithPlayer(TOKKUL_ZO_UNCHARGED); if (ring != null) { int chargesToAdd = Utils.clampI(player.getInventory().getAmountOf(TOKKUL)/16, 0, 3000); if (chargesToAdd > 0) { player.getInventory().deleteItem(TOKKUL, chargesToAdd * 16); ring.setId(TOKKUL_ZO_CHARGED); ring.addMetaData(""tzhaarCharges"", chargesToAdd); player.getInventory().refresh(); player.sendMessage(""TzHaar-Mej-Jeh adds "" + chargesToAdd + "" charges to your ring in exchange for "" + Utils.formatNumber(chargesToAdd * 16) + "" Tokkul.""); } return; } ring = player.getItemWithPlayer(TOKKUL_ZO_CHARGED); if (ring != null) { int charges = ring.getMetaDataI(""tzhaarCharges"", -1); int chargesToAdd = Utils.clampI(player.getInventory().getAmountOf(TOKKUL)/16, 0, 3000-charges); if (chargesToAdd > 0) { player.getInventory().deleteItem(TOKKUL, chargesToAdd * 16); ring.addMetaData(""tzhaarCharges"", charges + chargesToAdd); } player.sendMessage(""TzHaar-Mej-Jeh adds "" + chargesToAdd + "" charges to your ring in exchange for "" + Utils.formatNumber(chargesToAdd * 16) + "" Tokkul.""); } } public static boolean depleteTokkulZo(Player player) { Item ring = player.getItemWithPlayer(TOKKUL_ZO_CHARGED); if (ring != null && ring.getId() == TzHaar.TOKKUL_ZO_CHARGED) { int charges = ring.getMetaDataI(""tzhaarCharges"", -1); if (charges <= 1) { ring.setId(TzHaar.TOKKUL_ZO_UNCHARGED); ring.deleteMetaData(); player.getEquipment().refresh(Equipment.RING); player.getInventory().refresh(); player.sendMessage(""Your Tokkul-Zo has degraded and requires recharging.""); return false; } ring.addMetaData(""tzhaarCharges"", charges - 1); return true; } return false; } }" "package com.rs.game.content.world.areas.dungeons; public class UndergroundDungeonController extends Controller { private transient int ticks; private transient boolean initial; private final boolean hasStench; private final boolean requiresLightSource; public UndergroundDungeonController(boolean hasStench, boolean requiresLightSource) { this.hasStench = hasStench; this.requiresLightSource = requiresLightSource; } @Override public void start() { init(); } private void init() { ticks = 0; initial = true; sendInterfaces(); } @Override public void sendInterfaces() { if (requiresLightSource) { boolean hasLight = LightSource.hasLightSource(player); player.getInterfaceManager().sendOverlay(hasLight ? (LightSource.hasExplosiveSource(player) ? 98 : 97) : 96, true); if (!hasLight) player.getPackets().setBlockMinimapState(2); else player.getPackets().setBlockMinimapState(0); } } private void checkRequriments() { boolean lastInitial = initial; if (hasStench) if (!Slayer.hasNosepeg(player) && !Slayer.hasMask(player)) { if (initial) player.sendMessage(""The stench of the monsters begins to reach your nose..""); initial = false; } else initial = true; if (requiresLightSource) if (!LightSource.hasLightSource(player)) { if (initial) player.sendMessage(""You hear tiny insects skittering over the ground...""); initial = false; } else initial = true; if (lastInitial != initial) sendInterfaces(); } @Override public void process() { checkRequriments(); if (initial) return; ticks++; if (hasStench) if (ticks % 12 == 0) { player.sendMessage(""The strench of the monsters burns your innards.""); player.applyHit(new Hit(player, 200, HitLook.TRUE_DAMAGE)); } if (requiresLightSource) if (ticks % 2 == 0) if (!LightSource.hasLightSource(player)) if (!player.isLocked()) player.applyHit(new Hit(player, Utils.random(10, 100), HitLook.TRUE_DAMAGE)); } @Override public boolean processObjectClick1(final GameObject object) { if (object.getId() == 31316) { player.useStairs(-1, Tile.of(3360, 2971, 0), 1, 2); player.getControllerManager().forceStop(); return false; } if (object.getId() == 5946) { player.useStairs(828, Tile.of(3168, 3171, 0), 1, 2); player.getControllerManager().forceStop(); return false; } if (object.getId() == 15811) player.getControllerManager().forceStop(); else if (object.getId() == 32944) { player.useStairs(-1, Tile.of(3219, 9532, 2), 1, 2); player.getControllerManager().forceStop(); return false; } else if (object.getId() == 31435) return false; else if (object.getId() == 15811) { player.useStairs(-1, Tile.of(3749, 2973, 0), 1, 2); return false; } else if (object.getId() == 15790) { if (object.getX() == 3829) player.useStairs(-1, Tile.of(3831, 3062, 0), 1, 2); if (object.getX() == 3814) player.useStairs(-1, Tile.of(3816, 3062, 0), 1, 2); player.getControllerManager().forceStop(); return false; } else if (object.getId() == 32953 || object.getId() == 32952) { player.useStairs(-1, Tile.of(2747, 5374, 0), 0, 1); player.getControllerManager().forceStop(); return false; } else if (object.getId() == 15812) { player.useStairs(-1, Tile.of(3749, 2973, 0), 1, 2); player.getControllerManager().forceStop(); return false; } else if (object.getId() == 6912) { player.setNextAnimation(new Animation(10578)); player.useStairs(-1, object.getTile(), 1, 2); player.useStairs(10579, Tile.of(player.getX(), player.getY() == 9601 ? player.getY() + 2 : player.getY() - 2, 0), 1, 2); return false; } else if (object.getId() == 6899) { player.setNextAnimation(new Animation(10578)); player.useStairs(-1, object.getTile(), 1, 2); player.useStairs(10579, Tile.of(3219, 9618, 0), 1, 2); player.getControllerManager().forceStop(); player.sendMessage(""You squeeze through the hole.""); return false; } else if (object.getId() == 6439) { player.useStairs(828, Tile.of(3310, 2961, 0), 1, 2); player.getControllerManager().forceStop(); return false; } else if (object.getId() == 31390) { player.useStairs(-1, Tile.of(3318, 9355, 0), 1, 2, ""You tumble into the darkness, arriving on a different cave level.""); return false; } else if (object.getId() == 31367) { player.useStairs(-1, Tile.of(3338, 9350, 0), 1, 2, ""You tumble into the darkness, arriving on a different cave level.""); return false; } return true; } @Override public void onTeleported(TeleType type) { player.getControllerManager().forceStop(); } @Override public void forceClose() { player.getPackets().setBlockMinimapState(0); player.getInterfaceManager().removeOverlay(true); } @Override public boolean sendDeath() { player.getPackets().setBlockMinimapState(0); player.getInterfaceManager().removeOverlay(true); removeController(); return true; } @Override public boolean login() { init(); return false; } @Override public boolean logout() { return false; } }" "package com.rs.game.content.world.areas.dungeons; @PluginEventHandler public class UndergroundPass { public static ObjectClickHandler handleSkullDoorEnter = new ObjectClickHandler(new Object[] { 3220, 3221 }, e -> e.getPlayer().useStairs(Tile.of(2173, 4725, 1))); public static ObjectClickHandler handleSkullDoorExit = new ObjectClickHandler(new Object[] { 34288, 34289 }, e -> e.getPlayer().useStairs(Tile.of(2369, 9718, 0))); public static ObjectClickHandler handleWellDoorEnter = new ObjectClickHandler(new Object[] { 3333, 3334 }, e -> e.getPlayer().useStairs(e.getPlayer().getX() < e.getObject().getX() ? Tile.of(2145, 4648, 1) : Tile.of(2014, 4712, 1))); }" "package com.rs.game.content.world.areas.dungeons.ancientcavern; @PluginEventHandler public class AncientCavern { public static int FIXED_RING_VARBIT = 6774; public static ObjectClickHandler handleFixRing = new ObjectClickHandler(new Object[] { ""Enchanted land"" }, e -> { if (!e.getOption().equals(""Plant"")) { e.getPlayer().sendMessage(""YIKES""); return; } if (!e.getPlayer().getInventory().containsItem(6004, 5)) { e.getPlayer().sendMessage(""You need 5 bittercap mushrooms to repair the fairy ring.""); return; } e.getPlayer().setNextAnimation(new Animation(2291)); e.getPlayer().getInventory().deleteItem(6004, 5); e.getPlayer().getVars().saveVarBit(FIXED_RING_VARBIT, 1); }); public static ObjectClickHandler handleRoughSteps = new ObjectClickHandler(new Object[] { 25337, 39468 }, e -> { switch(e.getObjectId()) { case 25337 -> e.getPlayer().tele(Tile.of(1744, 5321, 1)); case 39468 -> e.getPlayer().tele(Tile.of(1745, 5325, 0)); } }); public static ObjectClickHandler handleMithrilDoor = new ObjectClickHandler(new Object[] { 25341, 40208 }, e -> e.getPlayer().useStairs(e.getObjectId() == 25341 ? Tile.of(1823, 5273, 0) : Tile.of(1759, 5342, 1))); public static ObjectClickHandler handleDownStepsEntrance = new ObjectClickHandler(new Object[] { 25338 }, e -> e.getPlayer().tele(Tile.of(1772, 5366, 0))); public static ObjectClickHandler handleUpStepsEntrance = new ObjectClickHandler(new Object[] { 25336 }, e -> e.getPlayer().tele(Tile.of(1768, 5366, 1))); public static ObjectClickHandler handleDownStepsMithDrags = new ObjectClickHandler(new Object[] { 25340 }, e -> e.getPlayer().tele(Tile.of(1778, 5346, 0))); public static ObjectClickHandler handleUpStepsMithDrags = new ObjectClickHandler(new Object[] { 25339 }, e -> e.getPlayer().tele(Tile.of(1778, 5343, 1))); // public static ObjectClickHandler handleDownStepsKuradal = new ObjectClickHandler(new Object[] { 39468 }) { // @Override // public void handle(ObjectClickEvent e) { // e.getPlayer().tele(Tile.of(1744, 5325, 0)); // } // }; // public static ObjectClickHandler handleUpStepsKuradal = new ObjectClickHandler(new Object[] { 25337 }) { // @Override // public void handle(ObjectClickEvent e) { // e.getPlayer().tele(e.getPlayer().isQuestComplete(Quest.WHILE_GUTHIX_SLEEPS) ? Tile.of(1774, 5321, 1) : Tile.of(1694, 5296, 1)); // } // }; public static ObjectClickHandler handleWhirlpool = new ObjectClickHandler(new Object[] { 67966 }, e -> { e.getPlayer().lock(); e.getPlayer().setRunHidden(false); e.getPlayer().walkToAndExecute(Tile.of(2512, 3516, 0), () -> { e.getPlayer().setFaceAngle(WorldUtil.getAngleTo(Direction.SOUTH)); e.getPlayer().forceMove(Tile.of(2512, 3508, 0), 6723, 30, 7*30, () -> { e.getPlayer().anim(-1); e.getPlayer().tele(Tile.of(1764, 5365, 1)); e.getPlayer().setRunHidden(true); }); }); }); }" "package com.rs.game.content.world.areas.dungeons.ancientcavern; @PluginEventHandler public class KuradalDungeonController extends Controller { public static ItemClickHandler handleFerociousRings = new ItemClickHandler(new Object[] { 15398, 15399, 15400, 15401, 15402 }, new String[] { ""Rub"", ""Kuradal"" }, e -> { if (e.getItem().getId() == 15402) { Magic.sendItemTeleportSpell(e.getPlayer(), true, 9603, 1684, 3, Tile.of(1739, 5312, 1)); if (e.isEquipped()) e.getPlayer().getEquipment().deleteSlot(Equipment.RING); else e.getPlayer().getInventory().deleteItem(e.getItem().getId(), 1); } else { Magic.sendItemTeleportSpell(e.getPlayer(), true, 9603, 1684, 3, Tile.of(1739, 5312, 1)); e.getItem().setId(e.getItem().getId()+1); e.getPlayer().getInventory().refresh(); e.getPlayer().getEquipment().refresh(Equipment.RING); } }); public KuradalDungeonController() {} @Override public void start() { player.tele(Tile.of(1661, 5257, 0)); } @Override public boolean canAttack(Entity target) { if (player.getSlayer().isOnTaskAgainst((NPC)target)) return true; player.sendMessage(""This creature is not assigned to you.""); return false; } @Override public boolean keepCombating(Entity target) { if (player.getSlayer().isOnTaskAgainst((NPC)target)) return true; player.sendMessage(""This creature is not assigned to you.""); return false; } @Override public boolean processObjectClick1(GameObject object) { if (object.getId() == 47231) { player.tele(Tile.of(1735, 5313, 1)); removeController(); } return true; } @Override public void onTeleported(TeleType type) { removeController(); } @Override public void moved() { if (player.getRegionId() != 6482) removeController(); } @Override public void processOutgoingHit(Hit hit, Entity target) { if (target != player && hit.getDamage() > 0 && player.getEquipment().getRingId() >= 15398 && player.getEquipment().getRingId() <= 15402) hit.setDamage(hit.getDamage()+40); } @Override public void processNPCDeath(NPC npc) { if (!player.getSlayer().isOnTaskAgainst(npc)) return; if (Utils.random(128) == 0) npc.sendDrop(player, new Item(15398)); } @Override public boolean login() { return false; } @Override public boolean logout() { return false; } }" "package com.rs.game.content.world.areas.dwarven_mine.npcs; @PluginEventHandler public class DrogoDwarf extends Conversation { private static final int npcId = 579; public static NPCClickHandler DrogoDwarf = new NPCClickHandler(new Object[]{npcId}, e -> { switch (e.getOption()) { case ""Talk-to"" -> e.getPlayer().startConversation(new DrogoDwarf(e.getPlayer())); case ""Trade"" -> ShopsHandler.openShop(e.getPlayer(), ""drogos_mining_emporium""); } }); public DrogoDwarf(Player player) { super(player); addNPC(npcId, HeadE.CHEERFUL, ""'Ello. Welcome to my Mining shop, friend.""); addOptions(ops -> { ops.add(""Do you want to trade?"") .addPlayer(HeadE.CONFUSED, ""Do you want to trade?"") .addNext(() -> ShopsHandler.openShop(player, ""drogos_mining_emporium"")); ops.add(""Hello, shorty."") .addPlayer(HeadE.CHEERFUL, ""Hello, shorty."") .addNPC(npcId, HeadE.ANGRY, ""I may be short but at least I've got manners.""); ops.add(""Why don't you ever restock ores and bars?"") .addPlayer(HeadE.CONFUSED, ""Why don't you ever restock ores and bars?"") .addNPC(npcId, HeadE.CHEERFUL, ""The only ores and bars I sell are those sold to me.""); }); } }" "package com.rs.game.content.world.areas.dwarven_mine.npcs; @PluginEventHandler public class DwarvenMineNPC { private static final int DwarfGeneralStore = 582; private static final int DwarfGuard = 4316; private static final int Hura = 4563; private static final int Rolad = 1841; public static NPCClickHandler Dwarf = new NPCClickHandler(new Object[]{ DwarfGeneralStore }, e -> { switch (e.getOption()) { case ""Trade"" -> ShopsHandler.openShop(e.getPlayer(), ""dwarven_shopping_store""); case ""Talk-to"" -> e.getPlayer().startConversation(new Dialogue() .addNPC(DwarfGeneralStore, HeadE.HAPPY_TALKING, ""Can I help you at all?"") .addOptions(ops -> { ops.add(""Yes please, what are you selling?"", () -> ShopsHandler.openShop(e.getPlayer(), ""dwarven_shopping_store"")); ops.add(""No thanks."") .addPlayer(HeadE.SHAKING_HEAD, ""No thanks.""); }) ); } }); public static NPCClickHandler GangMember = new NPCClickHandler(new Object[]{ 1795, 1796, 1797 }, e -> { if (e.getOption().equalsIgnoreCase(""Talk-to"")) e.getPlayer().startConversation(new Dialogue() .addNPC(e.getNPCId(), HeadE.FRUSTRATED, ""Yeah... whada you want?"") .addOptions(ops -> { ops.add(""I'm looking for Hammerspike."") .addNPC(e.getNPCId(), HeadE.FRUSTRATED, ""Well, he's around here somewhere, just use your eyes, I'm sure you'll get there one day."") .addPlayer(HeadE.CALM_TALK, ""Ok, thanks.""); ops.add(""What're you doing here?"") .addNPC(e.getNPCId(), HeadE.FRUSTRATED, ""Well, as if it's any of your business, I'm an associate of Hammerspike. He's a great dwarf you know. You could learn a lot from a dwarf like him."") .addPlayer(HeadE.CALM_TALK, ""Ok, thanks.""); ops.add(""Who do you work for?"") .addNPC(e.getNPCId(), HeadE.FRUSTRATED, ""I have an ongoing contract with Hammerspike, when he gives the word, the hammer starts flying."") .addPlayer(HeadE.CALM_TALK, ""Ok, thanks.""); }) ); }); public static NPCClickHandler DwarfGuildGuard = new NPCClickHandler(new Object[]{ DwarfGuard }, e -> { if (e.getOption().equalsIgnoreCase(""Talk-to"")) e.getPlayer().startConversation(new Dialogue() .addNPC(DwarfGuard, HeadE.HAPPY_TALKING, ""Welcome to the Mining Guild. Can I help you with anything?"") .addOptions(ops -> { ops.add(""What have you got in the guild?"") .addPlayer(HeadE.CONFUSED, ""What have you got in the guild?"") .addNPC(DwarfGuard, HeadE.HAPPY_TALKING, ""Ooh, it's WONDERFUL! There are orichalcite, runite and coal rocks, all exclusively for people with at least level 60 mining."") .addNext(() -> { if(e.getPlayer().getSkills().getLevel(Skills.MINING) >= 60) e.getPlayer().startConversation(new Dialogue() .addPlayer(HeadE.SAD_MILD_LOOK_DOWN, ""It's a good thing I have level "" + e.getPlayer().getSkills().getLevel(Skills.MINING) + "" Mining."") .addNPC(DwarfGuard, HeadE.HAPPY_TALKING, ""Yes, that's amazing!"") ); else e.getPlayer().startConversation(new Dialogue() .addPlayer(HeadE.SAD_MILD_LOOK_DOWN, ""So you won't let me go in there?"") .addNPC(DwarfGuard, HeadE.HAPPY_TALKING, ""Sorry, but rules are rules. Go do some more training first. Can I help you with anything else?"")); } ); ops.add(""What do you dwarves do with the ore you mine?"") .addPlayer(HeadE.CONFUSED, ""What do you dwarves do with the ore you mine?"") .addNPC(DwarfGuard, HeadE.LAUGH, ""What do you think? We smelt it into bars, smith the metal to make armour and weapons, then we exchange them for goods and services."") .addPlayer(HeadE.CONFUSED, ""I don't see many dwarves selling armour or weapons here."") .addNPC(DwarfGuard,HeadE.SHAKING_HEAD, ""No, this is only a mining outpost. We dwarves don't much like to settle in human cities. Most of the ore is carted off to Keldagrim, the great dwarven city. They've got a special blast furnace up there - it makes smelting the ore so much easier."") .addNPC(DwarfGuard, HeadE.HAPPY_TALKING, ""There are plenty of dwarven traders working in Keldagrim."") .addNPC(DwarfGuard, HeadE.HAPPY_TALKING, ""Anyway, can I help you with anything else?""); ops.add(""No thanks, I'm fine."") .addPlayer(HeadE.SHAKING_HEAD, ""No thanks, I'm fine.""); }) ); }); public static NPCClickHandler HandleHura = new NPCClickHandler(new Object[]{ Hura }, e -> { switch (e.getOption()) { case ""Trade"" -> ShopsHandler.openShop(e.getPlayer(), ""dwarven_mine_crossbow_shop""); case ""Talk-to"" -> e.getPlayer().startConversation(new Dialogue() .addNPC(Hura, HeadE.HAPPY_TALKING, ""'Ello "" + e.getPlayer().getDisplayName() + ""."") .addPlayer(HeadE.CONFUSED, ""Hello, what's that you've got there?"") .addNPC(Hura, HeadE.HAPPY_TALKING, ""A crossbow, are you interested?"") .addPlayer(HeadE.SKEPTICAL, ""Maybe, are they any good?"") .addNPC(Hura, HeadE.LAUGH, ""Are they any good?! They're dwarven engineering at its best!"") .addOptions(ops -> { ops.add(""How do I make one for myself?."") .addPlayer(HeadE.SKEPTICAL_THINKING, ""How do I make one for myself?"") .addNPC(Hura, HeadE.HAPPY_TALKING, ""Well, firstly you'll need to chop yourself some wood, then use a knife on the wood to whittle out a nice crossbow stock like these here."") .addPlayer(HeadE.HAPPY_TALKING, ""Wood fletched into stock... check."") .addNPC(Hura, HeadE.HAPPY_TALKING, ""Then get yourself some metal and a hammer and smith yourself some limbs for the bow, mind that you use the right metals and woods though as some wood is too light to use with some metal and vice versa."") .addPlayer(HeadE.CONFUSED, ""Which goes with which?"") .addNPC(Hura, HeadE.HAPPY_TALKING, ""Wood and Bronze as they're basic materials, Oak and Blurite, Willow and Iron, Steel and Teak, Mithril and Maple, Adamantite and Mahogany and finally Runite and Yew."") .addPlayer(HeadE.CONFUSED, ""Ok, so I have my stock and a pair of limbs... what now?"") .addNPC(Hura, HeadE.HAPPY_TALKING, ""Simply take a hammer and smack the limbs firmly onto the stock. You'll then need a string, only they're not the same as normal bows."") .addNPC(Hura, HeadE.HAPPY_TALKING, ""You'll need to dry some large animal's meat to get sinew, then spin that on a spinning wheel, it's the only thing we've found to be strong enough for a crossbow."") .addOptions(ops2 ->{ ops2.add(""What about magic logs?"") .addPlayer(HeadE.CONFUSED, ""What about magic logs?"") .addNPC(Hura, HeadE.SKEPTICAL_THINKING, ""Well.. I don't rightly know... us dwarves don't work with magic, we prefer gold and rock. Much more stable."") .addNPC(Hura, HeadE.SKEPTICAL_HEAD_SHAKE, ""I guess you could ask the humans at the rangers guild to see if they can do something but I don't want anything to do with it!"") .addPlayer(HeadE.HAPPY_TALKING, ""Thanks for telling me. Bye!"") .addNPC(Hura, HeadE.HAPPY_TALKING, ""Take care, straight shooting.""); ops2.add(""Thanks for telling me. Bye!"") .addPlayer(HeadE.HAPPY_TALKING, ""Thanks for telling me. Bye!"") .addNPC(Hura, HeadE.HAPPY_TALKING, ""Take care, straight shooting.""); }); ops.add(""What about ammo?"") .addPlayer(HeadE.CONFUSED, ""What about ammo?"") .addNPC(Hura, HeadE.HAPPY_TALKING, ""You can smith yourself lots of different bolts, don't forget to flight them with feathers like you do arrows though."") .addNPC(Hura, HeadE.HAPPY_TALKING, ""You can poison any untipped bolt but there's also the option of tipping them with gems then enchanting them with runes. This can have some pretty powerful effects."") .addPlayer(HeadE.SAD_CRYING, ""Oh my poor bank, how will I store all those?!"") .addNPC(Hura, HeadE.SKEPTICAL_THINKING ,""Find Hirko in Keldagrim, he also sells crossbow parts and I'm sure he has something you can use to store bolts in."") .addPlayer(HeadE.HAPPY_TALKING, ""Thanks for the info.""); ops.add(""Can I buy some crossbow supplies?"", () -> ShopsHandler.openShop(e.getPlayer(), ""dwarven_mine_crossbow_shop"")); ops.add(""Thanks for telling me. Bye!"") .addPlayer(HeadE.HAPPY_TALKING, ""Thanks for telling me. Bye!"") .addNPC(Hura, HeadE.HAPPY_TALKING, ""Take care, straight shooting.""); }) ); } }); public static NPCClickHandler handleRolad = new NPCClickHandler(new Object[]{ Rolad }, e -> { if(e.getOption().equalsIgnoreCase(""Talk-to"")) e.getPlayer().startConversation(new Dialogue() .addNPC(DwarfGeneralStore, HeadE.FRUSTRATED, ""Can you leave me alone please? I'm trying to study."") ); }); }" "package com.rs.game.content.world.areas.dwarven_mine.npcs; @PluginEventHandler public class Nurmof extends Conversation { private static final int npcId = 594; public static NPCClickHandler Nurmof = new NPCClickHandler(new Object[]{npcId}, e -> { switch (e.getOption()) { case ""Talk-to"" -> e.getPlayer().startConversation(new Nurmof(e.getPlayer())); case ""Trade"" -> ShopsHandler.openShop(e.getPlayer(), ""nurmofs_pickaxe_shop""); } }); public Nurmof(Player player) { super(player); addNPC(npcId, HeadE.CHEERFUL, ""Greetings and welcome to my pickaxe shop. Do you want to buy my premium quality pickaxes?""); addOptions(ops -> { ops.add(""Yes, please."", () -> ShopsHandler.openShop(player, ""nurmofs_pickaxe_shop"")); ops.add(""Are your pickaxes better than other pickaxes, then?"") .addPlayer(HeadE.CONFUSED, ""Are your pickaxes better than other pickaxes, then?"") .addNPC(npcId, HeadE.CHEERFUL_EXPOSITION, ""Of course they are! My pickaxes are made of higher grade metal than your ordinary bronze pickaxes, allowing you to mine ore just that little bit faster.""); ops.add(""No, thank you."") .addPlayer(HeadE.CHEERFUL, ""No, thank you.""); }); } }" "package com.rs.game.content.world.areas.edgeville; @PluginEventHandler public class Edgeville { public static LoginHandler setSafetyStrongholdPosterPulled = new LoginHandler(e -> e.getPlayer().getVars().setVarBit(6278, 1)); public static ObjectClickHandler handleWildernessDitch = new ObjectClickHandler(new Object[] { 29319, 29320 }, e -> { if (e.getPlayer().getY() <= 9917) { e.getPlayer().getControllerManager().startController(new WildernessController()); e.getPlayer().handleOneWayDoor(e.getObject()); } else e.getPlayer().handleOneWayDoor(e.getObject()); }); public static ObjectClickHandler handleBlackKnightWall = new ObjectClickHandler(new Object[] { 2341 }, e -> Doors.handleDoor(e.getPlayer(), e.getObject(), -1)); public static ObjectClickHandler handleJailEntrance = new ObjectClickHandler(new Object[] { 29603 }, e -> e.getPlayer().useStairs(-1, Tile.of(3082, 4229, 0), 0, 1)); public static ObjectClickHandler handleJailExit = new ObjectClickHandler(new Object[] { 29602 }, e -> e.getPlayer().useStairs(-1, Tile.of(3074, 3456, 0), 0, 1)); public static ObjectClickHandler handlePosterEntrance = new ObjectClickHandler(new Object[] { 29735 }, e -> e.getPlayer().useStairs(-1, Tile.of(3140, 4230, 2), 0, 1)); public static ObjectClickHandler handlePosterExit = new ObjectClickHandler(new Object[] { 29623 }, e -> e.getPlayer().useStairs(-1, Tile.of(3077, 4235, 0), 0, 1)); public static ObjectClickHandler handleJailDoors = new ObjectClickHandler(new Object[] { 29624 }, e -> { if (e.getObject().getRotation() == 0) { if (e.getPlayer().getPlane() == 0) e.getPlayer().useStairs(-1, e.getPlayer().transform(0, 3, 2), 0, 1); else e.getPlayer().useStairs(-1, e.getPlayer().transform(0, -3, -2), 0, 1); } else if (e.getPlayer().getPlane() == 0) e.getPlayer().useStairs(-1, e.getPlayer().transform(-1, 2, 1), 0, 1); else e.getPlayer().useStairs(-1, e.getPlayer().transform(1, -2, -1), 0, 1); }); public static ObjectClickHandler handleEdgevilleMonkeybars = new ObjectClickHandler(new Object[] { 29375 }, e -> { if (!Agility.hasLevel(e.getPlayer(), 15)) return; Agility.crossMonkeybars(e.getPlayer(), e.getObject().getTile(), e.getObject().getTile().transform(0, e.getPlayer().getY() > 9967 ? -5 : 5, 0), 20.0); }); public static ObjectClickHandler handleMonastaryLadders = new ObjectClickHandler(new Object[] { 2641 }, e -> { Player p = e.getPlayer(); if(p.getSkills().getLevel(Constants.PRAYER) >= 31) p.useLadder(Tile.of(p.getX(), p.getY(), p.getPlane()+1)); else p.startConversation(new Conversation(p) { final int NPC = 801; { addNPC(NPC, HeadE.FRUSTRATED, ""Hey! You are not part of the monastary!""); addPlayer(HeadE.HAPPY_TALKING, ""Oh.""); addSimple(""You need 31 prayer to enter the inner monastary.""); create(); } }); }); public static NPCClickHandler handleOziachDialogue = new NPCClickHandler(new Object[] { 747 }, e -> { int dragonSlayerStage = e.getPlayer().getQuestManager().getStage(Quest.DRAGON_SLAYER); if (e.getOption().equalsIgnoreCase(""trade"")) switch (dragonSlayerStage) { case NOT_STARTED, TALK_TO_OZIACH: e.getPlayer().startConversation(new Conversation(e.getPlayer()) { { addNPC(e.getNPCId(), HeadE.FRUSTRATED, ""I don't have anything to sell.""); create(); } }); break; case TALK_TO_GUILDMASTER, PREPARE_FOR_CRANDOR, REPORT_TO_OZIACH: e.getPlayer().startConversation(new Conversation(e.getPlayer()) { { addNPC(e.getNPCId(), HeadE.FRUSTRATED, ""I'm not sellin' ye anything till you've slayed that dragon! Now be off wi' ye.""); create(); } }); break; case QUEST_COMPLETE: ShopsHandler.openShop(e.getPlayer(), ""oziach""); break; } if(e.getOption().equalsIgnoreCase(""Talk-to"")) if(e.getPlayer().isQuestComplete(Quest.DRAGON_SLAYER)) e.getPlayer().startConversation(new Conversation(e.getPlayer()) { { addPlayer(HeadE.CALM, ""Good day to you.""); addNPC(747, HeadE.HAPPY_TALKING, ""Aye, 'tis a fair day, mighty dragon-slaying friend.""); if (player.getInventory().containsItem(11286)) addNPC(747, HeadE.AMAZED, ""Ye've got... Ye've found a draconic visage! Could I look at it?""); addOptions(new Options() { @Override public void create() { if (player.getInventory().containsItem(11286)) option(""Here you go"", new Dialogue().addPlayer(HeadE.CALM, ""Here you go."") .addNPC(747, HeadE.AMAZED_MILD, ""Amazin'! Ye can almost feel it pulsing with draconic power!"") .addNPC(747, HeadE.AMAZED_MILD, ""Now, if ye want me to, I could attach this to yer anti-dragonbreath shield and make something pretty special."") .addNPC(747, HeadE.AMAZED_MILD, ""The shield won't be easy to wield though; ye'll need level 75 Defence."") .addNPC(747, HeadE.AMAZED_MILD, ""I'll Charge 1,250,000 coins to construct it. What d'ye say?"") .addOption(""Select an option"", ""Yes, please!"", ""No, thanks."", ""That's a bit expensive!"") .addNPC(747, HeadE.CALM, ""Great lets take a look."") .addNext( (player.getInventory().containsItem(11286) && player.getInventory().hasCoins(1250000) && player.getInventory().containsItem(1540) ? new Dialogue().addItem(11283, ""Oziach skillfully forges the shield and visage into a new shield."", () -> { player.getInventory().deleteItem(11286, 1); player.getInventory().removeCoins(1250000); player.getInventory().deleteItem(1540, 1); player.getInventory().addItem(11283, 1); }) : new Dialogue().addNPC(747, HeadE.CALM_TALK, ""Ye seem to be missing some stuff. Come see me when ye have an anti-dragon shield and my payment."")) )); option(""Can I buy a rune platebody now, please?"", new Dialogue().addPlayer(HeadE.CALM, ""Can I buy a rune platebody now, please?"").addNext(() -> ShopsHandler.openShop(player, ""oziach""))); if (!player.getInventory().containsItem(11286)) { option(""I'm not your friend."", new Dialogue().addPlayer(HeadE.CALM, ""I'm not your friend."").addNPC(747, HeadE.FRUSTRATED, ""I'm surprised if you're anyone's friend with those kind of manners."")); option(""Yes, it's a very nice day."", new Dialogue().addPlayer(HeadE.CALM, ""Yes, it's a very nice day."").addNPC(747, HeadE.HAPPY_TALKING, ""Aye, may the gods walk by yer side. Now leave me alone."")); } } }); create(); } }); else e.getPlayer().startConversation(new OziachDragonSlayerD(e.getPlayer()).getStart()); }); public static NPCClickHandler handleAbbotLangleyDialogue = new NPCClickHandler(new Object[] { 801 }, e -> { Player p = e.getPlayer(); int NPC = e.getNPCId(); p.startConversation(new Conversation(p) { { addOptions(""Choose an option:"", new Options() { @Override public void create() { option(""Can you heal me? I'm injured."", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Can you heal me? I'm injured."") .addNPC(NPC, HeadE.CALM_TALK, ""Ok."") .addSimple(""Abbot Langley places his hands on your head. You feel a little better."", () -> p.heal(p.getMaxHitpoints())) ); option(""Isn't this place built a bit out of the way?"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Isn't this place built a bit out of the way?"") .addNPC(NPC, HeadE.CALM_TALK, ""We like it that way actually! We get disturbed less. We still get rather a large amount "" + ""of travellers looking for sanctuary and healing here as it is!"") ); if(p.getSkills().getLevel(Constants.PRAYER)<31) option(""How do I get further into the monastery?"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""How do I get further into the monastery?"") .addNPC(NPC, HeadE.CALM_TALK, ""I'm sorry but only members of our order are allowed in the second level of the monastery."") .addOptions(""Choose an option:"", new Options() { @Override public void create() { option(""Well can I join your order?"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Well can I join your order?"") .addNPC(NPC, HeadE.CALM_TALK, ""No. I am sorry, but I feel you are not devout enough."") .addSimple(""You need 31 prayer to enter the inner monastary."") ); option(""Oh, sorry."", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Oh, sorry."") ); } }) ); } }); create(); } }); }); }" "package com.rs.game.content.world.areas.edgeville.npcs @ServerStartupEvent fun handleHari() { onNpcClick(3330) { e -> e.player.startConversation(CanoeD(e.player, e.npc)) } }" "package com.rs.game.content.world.areas.edgeville.npcs; @PluginEventHandler public class Mandrith extends Conversation { private static final int npcId = 6537; public static NPCClickHandler Mandrith = new NPCClickHandler(new Object[]{npcId}, e -> { switch (e.getOption()) { case ""Talk-to"" -> e.getPlayer().startConversation(new Mandrith(e.getPlayer())); } }); public Mandrith(Player player) { super(player); addPlayer(HeadE.CONFUSED, ""Who are you?""); addNPC(npcId, HeadE.AMAZED, ""Why, I'm Mandrith! Inspiration to combatants both mighty and puny!""); addPlayer(HeadE.CONFUSED, ""Okay...fair enough.""); addOptions(new Options() { @Override public void create() { option(""Can you exchange some Ancient Revenant Artefacts?"", new Dialogue() .addNext(() -> Statuettes.exchangeStatuettes(player)));//TODO INV check option(""Bye."", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Bye."") ); } }); } }" "package com.rs.game.content.world.areas.edgeville.npcs; public class Monk extends CombatScript { @Override public Object[] getKeys() { return new Object[] { ""Monk"" }; } @Override public int attack(NPC npc, Entity target) { NPCCombatDefinitions def = npc.getCombatDefinitions(); if (Utils.random(100) < 70) { delayHit(npc, 0, target, getMeleeHit(npc, getMaxHit(npc, npc.getMaxHit(), def.getAttackStyle(), target))); npc.setNextAnimation(new Animation(def.getAttackEmote())); } else { npc.heal(20); npc.setNextSpotAnim(new SpotAnim(84)); } return npc.getAttackSpeed(); } }" "package com.rs.game.content.world.areas.edgeville.npcs; @PluginEventHandler public class MrEx extends Conversation { private static final int MREX = 3709; public MrEx(Player player) { super(player); Dialogue options = player.isIronMan() ? addOption(""Select an option"", ""Wilderness hats"", ""Ironman mode"", ""Skull me"") : addOption(""Select an option"", ""Wilderness hats"", ""Skull me""); options.addPlayer(HeadE.CONFUSED, ""I've seen wilderness hats around, what are those?"") .addNPC(MREX, HeadE.NO_EXPRESSION, ""Oh, I'm not giving those out quite yet. Sorry."") .addPlayer(HeadE.NO_EXPRESSION, ""Unlucky..""); if (player.isIronMan()) options.addNPC(MREX, HeadE.CONFUSED, ""Hey, I don't mean any offence by this, but would you like me to teach you to interact with other players?"") .addNPC(MREX, HeadE.CHEERFUL, ""Essentially, I am asking if you would be interested in de-activating your ironman mode by teaching you this."") .addOption(""De-activate Ironman Mode?"", ""Yes, deactivate my ironman mode please."", ""No, I'm quite happy being an Ironman."") .addNPC(MREX, HeadE.CHEERFUL, ""Are you sure? You don't sound very sure."") .addOption(""De-activate Ironman Mode?"", ""Yes, I am completely sure. De-activate my ironman status."", ""No, I've changed my mind."") .addNPC(MREX, HeadE.CHEERFUL, ""Alright, here's the secret to interacting with other players then"") .addSimple(""Mr. Ex whispers in your ears and teaches you how to trade."", () -> { player.setIronMan(false); player.clearTitle(); }) .addPlayer(HeadE.CHEERFUL, ""Thank you!"") .addNPC(MREX, HeadE.CHEERFUL, ""No problem.""); options.addNPC(MREX, HeadE.CONFUSED, ""Skull you?"") .addOption(""Skull?"", ""Yes, skull me."", ""No, nevermind."") .addNPC(MREX, HeadE.CHEERFUL, ""Are you sure?"") .addOption(""Skull?"", ""Yes, skull me."", ""No, I've changed my mind."") .addSimple(""You have been skulled."", player::setWildernessSkull) .addPlayer(HeadE.CHEERFUL, ""Thank you!"") .addNPC(MREX, HeadE.CHEERFUL, ""No problem.""); create(); } public static NPCClickHandler handleTalk = new NPCClickHandler(new Object[] { MREX }, e -> e.getPlayer().startConversation(new MrEx(e.getPlayer()))); }" "package com.rs.game.content.world.areas.enchanted_valley; @PluginEventHandler public class EnchantedValley { public static NPCClickHandler centaurs = new NPCClickHandler(new Object[] { 4438, 4439 }, e -> e.getPlayer().startConversation(new Dialogue().addNPC(e.getNPCId(), e.getNPCId() == 4438 ? HeadE.CALM_TALK : HeadE.CHUCKLE, e.getNPCId() == 4438 ? ""Hello, human, welcome to our valley."" : ""What a funny creature you are! Why, you only have 2 legs!""))); public static NPCClickHandler woodDryad = new NPCClickHandler(new Object[] { 4441 }, e -> e.getPlayer().startConversation(new Dialogue() .addPlayer(HeadE.CONFUSED, ""Hi, why do you have twigs growing out of you?"") .addNPC(e.getNPCId(), HeadE.CHUCKLE, ""Heehee, what a strange question; that's because I'm a dryad.""))); public static ObjectClickHandler treeCut = new ObjectClickHandler(new Object[] { 16265 }, e -> { if (e.getPlayer().inCombat()) { e.getPlayer().sendMessage(""You can't chop down a tree while you are under attack.""); return; } e.getPlayer().getActionManager().setAction(new Woodcutting(e.getObject(), TreeType.NORMAL) { @Override public void giveLog(Entity entity) { } @Override public void fellTree() { NPC treeSpirit = new OwnedNPC(e.getPlayer(), 4470, e.getPlayer().getNearestTeleTile(1), false); treeSpirit.spotAnim(179, 0, 96); treeSpirit.forceTalk(""Leave these woods and never return!""); treeSpirit.setTarget(e.getPlayer()); } }); }); public static ObjectClickHandler rockMine = new ObjectClickHandler(new Object[] { 42366 }, e -> { if (e.getPlayer().inCombat()) { e.getPlayer().sendMessage(""You can't mine a rock while you are under attack.""); return; } e.getPlayer().getActionManager().setAction(new Mining(RockType.CLAY, e.getObject()) { @Override public boolean depleteOre(Entity entity) { NPC rockGolem = new OwnedNPC(e.getPlayer(), 8648, e.getPlayer().getNearestTeleTile(1), false); rockGolem.forceTalk(""Raarrrgghh! Flee human!""); rockGolem.setTarget(e.getPlayer()); return true; } }); }); public static NPCClickHandler fishFish = new NPCClickHandler(new Object[] { 8647 }, e -> { if (e.getPlayer().inCombat()) { e.getPlayer().sendMessage(""You can't fish while you are under attack.""); return; } e.getPlayer().repeatAction(4, num -> { if (Utils.skillSuccess(e.getPlayer().getSkills().getLevel(Skills.FISHING), 32, 192)) { e.getPlayer().anim(-1); NPC rockGolem = new OwnedNPC(e.getPlayer(), 8646, e.getPlayer().getNearestTeleTile(1), false); rockGolem.forceTalk(""Fishies be mine, leave dem fishies!""); rockGolem.setTarget(e.getPlayer()); return false; } e.getPlayer().anim(622); return true; }); }); }" "package com.rs.game.content.world.areas.entrana; @PluginEventHandler public class Entrana { public static ObjectClickHandler handleMagicDoor = new ObjectClickHandler(new Object[] { 2407 }, e -> { Doors.handleDoor(e.getPlayer(), e.getObject()); Magic.sendNormalTeleportSpell(e.getPlayer(), 0, 0, Tile.of(3093, 3222, 0)); }); public static ObjectClickHandler handleEntranaDungeonLadders = new ObjectClickHandler(new Object[] { 2408 }, e -> e.getPlayer().startConversation(new Conversation(e.getPlayer()) .addNPC(656, HeadE.CONFUSED, ""Be careful going in there! You are unarmed, and there is much evilness lurking down there! The evilness seems to block off our contact with our gods,"") .addNPC(656, HeadE.CONFUSED, ""so our prayers seem to have less effect down there. Oh, also, you won't be able to come back this way - This ladder only goes one way!"") .addNPC(656, HeadE.CONFUSED, ""The only exit from the caves below is a portal which is guarded by greater demons!"") .addOption(""Select an Option"", ""Well, that is a risk I will have to take."", ""I don't think I'm strong enough to enter then."") .addPlayer(HeadE.CALM_TALK, ""Well, that's a risk I will have to take."") .addNext(() -> e.getPlayer().useLadder(Tile.of(2822, 9774, 0))))); public static NPCClickHandler handleCaveMonkDialogue = new NPCClickHandler(new Object[] { 656 }, e -> e.getPlayer().startConversation(new Conversation(e.getPlayer()) { { addNPC(656, HeadE.CALM_TALK, ""Hello, I don't recommend going down. But if you must, be careful, it is a one way path!""); addPlayer(HeadE.CALM_TALK, ""All right...""); create(); } })); }" "package com.rs.game.content.world.areas.feldip_hills; @PluginEventHandler public class FeldipHills { public static ObjectClickHandler handleRantzCaves = new ObjectClickHandler(new Object[] { 3379, 32068, 32069 }, e -> e.getPlayer().useStairs(e.getObjectId() == 3379 ? Tile.of(2646, 9378, 0) : Tile.of(2631, 2997, 0))); }" "package com.rs.game.content.world.areas.fisher_realm; @PluginEventHandler public class FisherRealm { //Fisher Realm public static ObjectClickHandler handlefisherkingstairs = new ObjectClickHandler(new Object[] { 1730, 1731 }, e -> { if (e.getObjectId() == 1730) e.getPlayer().tele(e.getPlayer().transform(e.getObject().getRotation() == 0 ? -0 : e.getObject().getRotation() == 3 ? -0 : 0, e.getObject().getRotation() == 0 ? 4 : e.getObject().getRotation() == 3 ? -0 : 0, 1)); else if (e.getObjectId() == 1731) e.getPlayer().tele(e.getPlayer().transform(e.getObject().getRotation() == 0 ? 0 : e.getObject().getRotation() == 3 ? -0 : 0, e.getObject().getRotation() == 0 ? -4 : e.getObject().getRotation() == 3 ? 3 : 0, -1)); }); }" "package com.rs.game.content.world.areas.ghorrock; @PluginEventHandler public class Ghorrock { //Ghorrock public static ObjectClickHandler iceblocks = new ObjectClickHandler(new Object[] { 47130 }, e -> { if (e.getPlayer().isQuestComplete(Quest.RITUAL_OF_MAHJARRAT)) { if (e.getPlayer().getX() < e.getObject().getX()) e.getPlayer().tele(e.getPlayer().transform(e.getObject().getRotation() == 1 ? 4 : e.getObject().getRotation() == 3 ? 4 : 0, e.getObject().getRotation() == 1 ? 0 : e.getObject().getRotation() == 3 ? -0 : 0, 0)); if (e.getPlayer().getX() > e.getObject().getX()) e.getPlayer().tele(e.getPlayer().transform(e.getObject().getRotation() == 1 ? -4 : e.getObject().getRotation() == 3 ? -4 : 0, e.getObject().getRotation() == 1 ? 0 : e.getObject().getRotation() == 3 ? -0 : 0, 0)); }else e.getPlayer().sendMessage(""You do not meet the requirements for Ritual of Mahjarrat.""); }); public static ObjectClickHandler handleGhorrockstairs = new ObjectClickHandler(new Object[] { 47142, 47144 }, e -> { if (e.getObjectId() == 47142) e.getPlayer().tele(e.getPlayer().transform(e.getObject().getRotation() == 3 ? 0 : e.getObject().getRotation() == 0 ? -1 : 0, e.getObject().getRotation() == 3 ? -0 : e.getObject().getRotation() == 0 ? -4 : 0, 1)); else if (e.getObjectId() == 47144) e.getPlayer().tele(e.getPlayer().transform(e.getObject().getRotation() == 3 ? -0 : e.getObject().getRotation() == 0 ? 1 : 0, e.getObject().getRotation() == 3 ? 0 : e.getObject().getRotation() == 0 ? 4 : 0, -1)); }); public static ObjectClickHandler handleGhorrockstairsuponly = new ObjectClickHandler(new Object[] { 47143 }, e -> e.getPlayer().tele(Tile.of(2921, 3931, 1))); public static LoginHandler makeghorrockcanoe = new LoginHandler(e -> e.getPlayer().getVars().setVarBit(6075, 1)); public static ObjectClickHandler handlecanoetoghorrock = new ObjectClickHandler(new Object[] { 42886 }, e -> { if (e.getPlayer().isQuestComplete(Quest.TALE_OF_MUSPAH)) { e.getPlayer().tele(Tile.of(2856, 3933, 0)); } else e.getPlayer().sendMessage(""You do not meet the requirements for Ritual of Mahjarrat.""); }); public static ObjectClickHandler handlecanoeleaveghorrock = new ObjectClickHandler(new Object[] { 42858 }, e -> { if (e.getPlayer().isQuestComplete(Quest.TALE_OF_MUSPAH)) { e.getPlayer().tele(Tile.of(2692, 3793, 0)); } else e.getPlayer().sendMessage(""You do not meet the requirements for Ritual of Mahjarrat.""); }); public static ObjectClickHandler handlemahjarratritualsitecavernentrance = new ObjectClickHandler(new Object[] { 42859 }, e -> { if (e.getPlayer().isQuestComplete(Quest.TALE_OF_MUSPAH)) { e.getPlayer().tele(Tile.of(2843, 10364, 0)); } else e.getPlayer().sendMessage(""You do not meet the requirements for The Tale of the Muspah.""); }); public static ObjectClickHandler handlemahjarratritualsitecavernexit = new ObjectClickHandler(new Object[] { 42892 }, e -> { if (e.getPlayer().isQuestComplete(Quest.TALE_OF_MUSPAH)) { e.getPlayer().tele(Tile.of(2866, 3927, 0)); } else e.getPlayer().sendMessage(""You do not meet the requirements for The Tale of the Muspah.""); }); //Zemouregal's fort public static ObjectClickHandler handleZemouregalstairs = new ObjectClickHandler(new Object[] { 44253, 44255 }, e -> { if (e.getObjectId() == 44253) e.getPlayer().tele(e.getPlayer().transform(e.getObject().getRotation() == 3 ? -3 : e.getObject().getRotation() == 0 ? -0 : 0, e.getObject().getRotation() == 3 ? -0 : e.getObject().getRotation() == 0 ? 3 : 0, 1)); else if (e.getObjectId() == 44255) e.getPlayer().tele(e.getPlayer().transform(e.getObject().getRotation() == 3 ? 3 : e.getObject().getRotation() == 0 ? -0 : 0, e.getObject().getRotation() == 3 ? 0 : e.getObject().getRotation() == 0 ? -3 : 0, -1)); }); public static ObjectClickHandler handleZemouregalrightstairsuponly = new ObjectClickHandler(new Object[] { 44254 }, e -> e.getPlayer().tele(Tile.of(2836, 3868, 1))); }" "package com.rs.game.content.world.areas.harmony; @PluginEventHandler public class Harmony { //Harmony public static ObjectClickHandler handleharmonystairs = new ObjectClickHandler(new Object[] { 22247, 22253 }, e -> { if (e.getObjectId() == 22247) e.getPlayer().tele(e.getPlayer().transform(e.getObject().getRotation() == 1 ? 3 : e.getObject().getRotation() == 3 ? -3 : 0, e.getObject().getRotation() == 2 ? -3 : e.getObject().getRotation() == 0 ? 3 : 0, 1)); else if (e.getObjectId() == 22253) e.getPlayer().tele(e.getPlayer().transform(e.getObject().getRotation() == 1 ? -3 : e.getObject().getRotation() == 3 ? 3 : 0, e.getObject().getRotation() == 2 ? 3 : e.getObject().getRotation() == 0 ? -3 : 0, -1)); }); public static ObjectClickHandler handleharmonystairs2 = new ObjectClickHandler(new Object[] { 22248, 22254 }, e -> { if (e.getObjectId() == 22248) e.getPlayer().tele(e.getPlayer().transform(e.getObject().getRotation() == 1 ? -3 : e.getObject().getRotation() == 3 ? -3 : 0, e.getObject().getRotation() == 2 ? -3 : e.getObject().getRotation() == 0 ? 3 : 0, 1)); else if (e.getObjectId() == 22254) e.getPlayer().tele(e.getPlayer().transform(e.getObject().getRotation() == 1 ? 3 : e.getObject().getRotation() == 3 ? 3 : 0, e.getObject().getRotation() == 2 ? 3 : e.getObject().getRotation() == 0 ? -3 : 0, -1)); }); public static ObjectClickHandler handlepirateshipladders = new ObjectClickHandler(new Object[] { 16945, 16946, 16947 }, e -> { if (e.getObjectId() == 16945) e.getPlayer().tele(e.getPlayer().transform(e.getObject().getRotation() == 0 ? 3 : e.getObject().getRotation() == 2 ? -3 : 0, e.getObject().getRotation() == 3 ? 3 : e.getObject().getRotation() == 1 ? -3 : 0, 1)); else if (e.getObjectId() == 16947) e.getPlayer().tele(e.getPlayer().transform(e.getObject().getRotation() == 0 ? -3 : e.getObject().getRotation() == 2 ? 3 : 0, e.getObject().getRotation() == 3 ? -3 : e.getObject().getRotation() == 1 ? 3 : 0, -1)); else if (e.getObjectId() == 16946) e.getPlayer().tele(e.getPlayer().transform(e.getObject().getRotation() == 2 ? -3 : e.getObject().getRotation() == 0 ? 3 : 0, e.getObject().getRotation() == 1 ? -3 : e.getObject().getRotation() == 3 ? 3 : 0, 1)); }); }" "package com.rs.game.content.world.areas.karamja; @PluginEventHandler public class Karamja { public static ObjectClickHandler handleShiloFurnace = new ObjectClickHandler(new Object[] { 11666 }, (e) -> { Player player = e.getPlayer(); if (!e.getOption().equals(""Smelt"")) return; FurnacesKt.use(player, e.getObject()); }); public static ObjectClickHandler handleShiloFurnaceDoor = new ObjectClickHandler(new Object[] { 2266, 2267 }, e -> { if (e.getObjectId() == 2267) return; Player player = e.getPlayer(); int yohnus = 513; int blacksmithPays = player.getI(""shilo_blacksmith_pay""); switch (e.getOption()) { case ""Open"" -> { if (e.getPlayer().getY() > e.getObject().getY()) { Doors.handleDoor(e.getPlayer(), e.getObject()); return; } if (blacksmithPays <= 0) { player.startConversation(new Dialogue() .addNPC(yohnus, HeadE.CALM_TALK, ""Sorry but the blacksmiths is closed. But I can let you use the furnace at the cost of 20 gold pieces."") .addOptions((ops) -> { ops.add(""Use Furnace - 20 Gold"") .addNext(() -> { if (!player.getInventory().hasCoins(20)) { player.startConversation(new Dialogue() .addNPC(yohnus, HeadE.SAD_MILD_LOOK_DOWN, ""Sorry Bwana, you do not have enough gold!"")); return; } player.getInventory().removeCoins(20); Doors.handleDoor(e.getPlayer(), e.getObject()); }) .addNPC(yohnus, HeadE.HAPPY_TALKING, ""Thanks Bwana! Enjoy the facilities!""); ops.add(""No thanks!"") .addPlayer(HeadE.CALM_TALK, ""No thanks!"") .addNPC(yohnus, HeadE.CALM_TALK, ""Very well Bwana, have a nice day.""); })); return; } player.save(""shilo_blacksmith_pay"", blacksmithPays - 1); Doors.handleDoor(e.getPlayer(), e.getObject()); } case ""Use-furnace(20gp)"" -> { if (e.getPlayer().getY() > e.getObject().getY()) { Doors.handleDoor(e.getPlayer(), e.getObject()); return; } if (!player.getInventory().hasCoins(20)) { player.startConversation(new Dialogue() .addNPC(yohnus, HeadE.SAD_MILD_LOOK_DOWN, ""Sorry Bwana, you do not have enough gold!"")); return; } player.getInventory().removeCoins(20); Doors.handleDoor(e.getPlayer(), e.getObject()); } } }); public static ObjectClickHandler handleBrimhavenDungeonEntrance = new ObjectClickHandler(new Object[] { 5083 }, e -> { if(e.getPlayer().getTempAttribs().getB(""paid_brimhaven_entrance_fee"")) {//12 hours e.getPlayer().tele(Tile.of(2713, 9564, 0)); return; } e.getPlayer().startConversation(new Dialogue().addNPC(1595, HeadE.FRUSTRATED, ""You can't go in there without paying!"")); }); public static ObjectClickHandler handleBoatLadder = new ObjectClickHandler(new Object[] { 273 }, new Tile[] { Tile.of(2847, 3235, 1) }, e -> e.getPlayer().useStairs(e.getPlayer().transform(0, 0, -1))); public static ObjectClickHandler handleBrimhavenDungeonExit = new ObjectClickHandler(new Object[] { 5084 }, e -> e.getPlayer().tele(Tile.of(2745, 3152, 0))); public static ObjectClickHandler handleJogreLogWalk = new ObjectClickHandler(new Object[] { 2332 }, e -> { if (e.getPlayer().getX() > 2908) Agility.walkToAgility(e.getPlayer(), 155, Direction.WEST, 4, 4); else Agility.walkToAgility(e.getPlayer(), 155, Direction.EAST, 4, 4); }); public static ObjectClickHandler handleMossGiantRopeSwings = new ObjectClickHandler(new Object[] { 2322, 2323 }, e -> { final Tile toTile = e.getObjectId() == 2322 ? Tile.of(2704, 3209, 0) : Tile.of(2709, 3205, 0); final Tile fromTile = e.getObjectId() == 2323 ? Tile.of(2704, 3209, 0) : Tile.of(2709, 3205, 0); if (!Agility.hasLevel(e.getPlayer(), 10)) return; if (e.getObjectId() == 2322 ? e.getPlayer().getX() == 2704 : e.getPlayer().getX() == 2709) { e.getPlayer().sendMessage(""You can't reach that."", true); return; } Agility.swingOnRopeSwing(e.getPlayer(), fromTile, toTile, e.getObject(), 0.1); }); public static ObjectClickHandler handleJogreWaterfallSteppingStones = new ObjectClickHandler(new Object[] { 2333, 2334, 2335 }, e -> { if (!Agility.hasLevel(e.getPlayer(), 30)) return; e.getPlayer().forceMove(e.getObject().getTile(), 741, 0, 30); }); public static ObjectClickHandler handleRareTreeDoors = new ObjectClickHandler(new Object[] { 9038, 9039 }, e -> { if (e.getOpNum() == ClientPacket.OBJECT_OP2) { if (e.getPlayer().getX() >= e.getObject().getX()) Doors.handleDoubleDoor(e.getPlayer(), e.getObject()); else if (e.getPlayer().getInventory().containsItem(6306, 100)) { Doors.handleDoubleDoor(e.getPlayer(), e.getObject()); e.getPlayer().getInventory().deleteItem(6306, 100); } else e.getPlayer().sendMessage(""You need 100 trading sticks to use this door.""); } else if (e.getOpNum() == ClientPacket.OBJECT_OP1) if (e.getPlayer().getX() >= e.getObject().getX()) Doors.handleDoubleDoor(e.getPlayer(), e.getObject()); else e.getPlayer().sendOptionDialogue(""Pay 100 trading sticks to enter?"", ops -> { ops.add(""Yes"", () -> { if (e.getPlayer().getInventory().containsItem(6306, 100)) { Doors.handleDoubleDoor(e.getPlayer(), e.getObject()); e.getPlayer().getInventory().deleteItem(6306, 100); } else e.getPlayer().sendMessage(""You need 100 trading sticks to use this door.""); }); ops.add(""No""); }); }); public static ObjectClickHandler handleCrandorVolcanoCrater = new ObjectClickHandler(new Object[] { 25154 }, e -> { Player p = e.getPlayer(); if (p.getQuestManager().getStage(Quest.DRAGON_SLAYER) == DragonSlayer.PREPARE_FOR_CRANDOR && !hasHeadAlready(p)) { if (!p.getQuestManager().getAttribs(Quest.DRAGON_SLAYER).getB(DragonSlayer.INTRODUCED_ELVARG_ATTR)) { DragonSlayer.introduceElvarg(p); return; } } e.getPlayer().tele(Tile.of(2834, 9657, 0)); }); public static ObjectClickHandler handleCrandorVolcanoRope = new ObjectClickHandler(new Object[] { 25213 }, e -> e.getPlayer().ladder(Tile.of(2832, 3255, 0))); public static ObjectClickHandler handleKaramjaVolcanoRocks = new ObjectClickHandler(new Object[] { 492 }, e -> e.getPlayer().tele(Tile.of(2857, 9569, 0))); public static ObjectClickHandler handleKaramjaVolcanoRope = new ObjectClickHandler(new Object[] { 1764 }, e -> e.getPlayer().ladder(Tile.of(2855, 3169, 0))); public static ObjectClickHandler handleElvargHiddenWall = new ObjectClickHandler(new Object[] { 2606 }, e -> { if (e.getPlayer().isQuestComplete(Quest.DRAGON_SLAYER) || e.getPlayer().getQuestManager().getAttribs(Quest.DRAGON_SLAYER).getB(DragonSlayer.FINISHED_BOAT_SCENE_ATTR)) { e.getPlayer().sendMessage(""You know from your boat accident there is more behind this wall...""); Doors.handleDoor(e.getPlayer(), e.getObject()); } else e.getPlayer().sendMessage(""You see nothing but a wall...""); }); public static ObjectClickHandler handleTzhaarEnter = new ObjectClickHandler(new Object[] { 68134 }, e -> e.getPlayer().tele(Tile.of(4667, 5059, 0))); public static ObjectClickHandler handleTzhaarExit = new ObjectClickHandler(new Object[] { 68135 }, e -> e.getPlayer().tele(Tile.of(2845, 3170, 0))); public static ObjectClickHandler handleJogreCaveEnter = new ObjectClickHandler(new Object[] { 2584 }, e -> e.getPlayer().startConversation(new Dialogue() .addSimple(""You search the rocks and find an entrance into some caves."") .addOptions((ops) -> { ops.add(""Yes, I'll enter the cave."") .addSimple(""You decide to enter the caves.
You climb down several steep rock faces into the cavern below."") .addNext(() -> e.getPlayer().tele(Tile.of(2830, 9522, 0))); ops.add(""No, thanks."") .addSimple(""You decide to stay where you are!""); }))); public static ObjectClickHandler handleJogreCaveExit = new ObjectClickHandler(new Object[] { 2585 }, e -> e.getPlayer().startConversation(new Dialogue() .addSimple(""You climb the rocks to get back out."") .addNext(() -> e.getPlayer().ladder(Tile.of(2824, 3120, 0))))); public static ObjectClickHandler handleSteppingStone = new ObjectClickHandler(false, new Object[] { 10536 }, e -> { if (!Agility.hasLevel(e.getPlayer(), 77)) return; Player p = e.getPlayer(); WorldObject obj = e.getObject(); Direction dir = Direction.NORTH; if(!obj.getTile().matches(Tile.of(2860, 2974, 0))) return; if(p.getY() > obj.getY()) dir = Direction.SOUTH; final Direction direction = dir; p.lock(); p.setRouteEvent(new RouteEvent(direction == Direction.NORTH ? Tile.of(2860, 2971, 0) : Tile.of(2860, 2977, 0), () -> p.forceMove(Tile.of(2860, 2974, 0), 741, 0, 30, false, () -> p.forceMove(direction == Direction.NORTH ? Tile.of(2860, 2977, 0) : Tile.of(2860, 2971, 0), 741, 0, 30)))); }); public static ObjectClickHandler handleShiloEnter = new ObjectClickHandler(new Object[] { 2216 }, e -> { e.getPlayer().sendMessage(""You quickly climb over the cart.""); e.getPlayer().ladder(e.getPlayer().getX() > e.getObject().getX() ? e.getPlayer().transform(-4, 0, 0) : e.getPlayer().transform(4, 0, 0)); }); public static ObjectClickHandler handleShiloCartEnter = new ObjectClickHandler(new Object[] { 2230 }, e -> e.getPlayer().tele(Tile.of(2833, 2954, 0))); public static ObjectClickHandler handleShiloCartExit = new ObjectClickHandler(new Object[] { 2265 }, e -> e.getPlayer().tele(Tile.of(2778, 3210, 0))); public static ObjectClickHandler handleElvargEntrance = new ObjectClickHandler(new Object[] { 25161 }, e -> { Player p = e.getPlayer(); int dragonSlayerStage = p.getQuestManager().getStage(Quest.DRAGON_SLAYER); boolean hasHeadAlready = hasHeadAlready(p); if (((dragonSlayerStage >= PREPARE_FOR_CRANDOR && dragonSlayerStage <= REPORT_TO_OZIACH && !hasHeadAlready) || p.getX() == 2847) || (dragonSlayerStage == REPORT_TO_OZIACH && p.getX() == 2847)) { WorldTasks.scheduleLooping(new Task() { int ticks = 0; boolean goingEast = true; @Override public void run() { if (ticks == 0) { if (p.getX() == 2845) { p.setFaceAngle(Direction.getAngleTo(Direction.EAST)); p.setNextAnimation(new Animation(839)); goingEast = true; } else if (p.getX() == 2847) { p.setFaceAngle(Direction.getAngleTo(Direction.WEST)); p.setNextAnimation(new Animation(839)); goingEast = false; } else return; } else if (ticks >= 1) { if (goingEast) p.tele(Tile.of(2847, p.getY(), 0)); if (!goingEast) p.tele(Tile.of(2845, p.getY(), 0)); stop(); } ticks++; } }, 0, 1); } else { String message = (dragonSlayerStage < PREPARE_FOR_CRANDOR) ? ""I shouldn't need to go in there."" : ""I shouldn't need to go back in there.""; p.sendMessage(message); } }); }" "package com.rs.game.content.world.areas.karamja.npcs class BartenderDeadMansChest(p: Player, npc: NPC) { init { p.startConversation { npc(npc, HeadE.HAPPY_TALKING, ""Yohoho me hearty what would you like to drink?"") options { op(""Nothing, thank you."") { player(HeadE.HAPPY_TALKING, ""Nothing, thank you."") } op(""A pint of Grog please."") { player(HeadE.HAPPY_TALKING, ""A pint of Grog please."") npc(npc, HeadE.HAPPY_TALKING, ""One grog coming right up, that'll be three coins."") exec { buyDrinkOrIngredients(p, npc, 3, Item(1915), true) } } op(""A bottle of rum please."") { player(HeadE.HAPPY_TALKING, ""A bottle of rum please."") npc(npc, HeadE.HAPPY_TALKING, ""That'll be 27 coins."") exec { buyDrinkOrIngredients(p, npc, 27, Item(431), true) } } if (!isBarVisited(p, DEAD_MANS_CHEST) && BarCrawl.hasCard(p) && onBarCrawl(p)) { op(""I'm doing Alfred Grimhand's Barcrawl."") { player(HeadE.HAPPY_TALKING, ""I'm doing Alfred Grimhand's Barcrawl."") npc(npc, HeadE.CHEERFUL, ""Haha time to be breaking out the old ${DEAD_MANS_CHEST.drinkName}. That'll be ${DEAD_MANS_CHEST.price} coins please."") exec { buyBarcrawlDrink(p, DEAD_MANS_CHEST) } } } } } } } @ServerStartupEvent fun mapBartenderDeadMansChest() { onNpcClick(735) { (player, npc) -> BartenderDeadMansChest(player, npc) } }" "package com.rs.game.content.world.areas.karamja.npcs; @PluginEventHandler public class Fernahei { public static NPCClickHandler handleFernahei = new NPCClickHandler(new Object[] { 517 }, new String[] { ""Talk-to"" }, e -> { Player player = e.getPlayer(); NPC npc = e.getNPC(); player.startConversation(new Dialogue() .addNPC(npc, HeadE.CALM_TALK, ""Welcome to Fernahei's Fishing Shop Bwana! Would you like to see my items?"") .addOptions((ops) -> { ops.add(""Yes please!"") .addNext(() -> ShopsHandler.openShop(player, ""fernaheis_fishing_shop"")); ops.add(""No, but thanks for the offer."") .addPlayer(HeadE.CALM_TALK, ""No, but thanks for the offer."") .addNPC(npc, HeadE.CALM_TALK, ""That's fine and thanks for your interest.""); })); }); }" "package com.rs.game.content.world.areas.karamja.npcs; @PluginEventHandler public class Gabooty { public static NPCClickHandler handleGabooty = new NPCClickHandler(new Object[] { 2520 }, new String[] { ""Trade-Co-op"", ""Trade-Drinks"" }, e -> { if (!e.getPlayer().isQuestComplete(Quest.JUNGLE_POTION)) return; switch (e.getOption()) { case ""Trade-Co-op"" -> ShopsHandler.openShop(e.getPlayer(), ""gabootys_tai_bwo_wannai_cooperative""); case ""Trade-Drinks"" -> ShopsHandler.openShop(e.getPlayer(), ""gabootys_tai_bwo_wannai_drinky_store""); } }); }" "package com.rs.game.content.world.areas.karamja.npcs; @PluginEventHandler public class JungleForester { public static NPCClickHandler handleJungleForesters = new NPCClickHandler(new Object[] { 401, 402 }, new String[] { ""Talk-to"" }, e -> { Player player = e.getPlayer(); int npcId = e.getNPC().getId(); player.startConversation(new Dialogue() .addNPC(npcId, HeadE.CHEERFUL, ""Hello, what are you after?"") .addOptions(""What would you like to say?"", (ops) -> ops.option(""About the Achievement System..."", () -> new AchievementSystemD(player, npcId, SetReward.KARAMJA_GLOVES)))); }); }" "package com.rs.game.content.world.areas.karamja.npcs; @PluginEventHandler public class KalebParamaya { public static NPCClickHandler handleKalebParamaya = new NPCClickHandler(new Object[] { 512 }, e -> { Player player = e.getPlayer(); int npcId = e.getNPC().getId(); player.startConversation(new Dialogue() .addNPC(npcId, HeadE.CHEERFUL, ""Hello, what are you after?"") .addOptions(""What would you like to say?"", (ops) -> ops.option(""About the Achievement System..."", () -> new AchievementSystemD(player, npcId, SetReward.KARAMJA_GLOVES)))); }); }" "package com.rs.game.content.world.areas.karamja.npcs; @PluginEventHandler public class Obli { public static NPCClickHandler handleObli = new NPCClickHandler(new Object[] { 516 }, new String[] { ""Talk-to"" }, e -> { Player player = e.getPlayer(); NPC npc = e.getNPC(); if (!player.isQuestComplete(Quest.SHILO_VILLAGE)) return; player.startConversation(new Dialogue() .addNPC(npc, HeadE.CALM_TALK, ""Welcome to Obli's General Store Bwana! Would you like to see my items?"") .addOptions((ops) -> { ops.add(""Yes please!"") .addPlayer(HeadE.CALM_TALK, ""Yes please!"") .addNext(() -> ShopsHandler.openShop(player, ""oblis_general_store"")); ops.add(""No, but thanks for the offer."") .addPlayer(HeadE.CALM_TALK, ""No, but thanks for the offer.""); })); }); }" "package com.rs.game.content.world.areas.karamja.npcs; @PluginEventHandler public class PirateJackieTheFruit { public static NPCClickHandler handlePirateJackieFruit = new NPCClickHandler(new Object[] { 1055 }, new String[] { ""Talk-to"" }, e -> { Player player = e.getPlayer(); int npcId = e.getNPC().getId(); player.startConversation(new Dialogue() .addNPC(npcId, HeadE.CHEERFUL, ""Hello, what are you after?"") .addOptions(""What would you like to say?"", (ops) -> ops.option(""About the Achievement System..."", () -> new AchievementSystemD(player, npcId, SetReward.KARAMJA_GLOVES)))); }); }" "package com.rs.game.content.world.areas.karamja.npcs; @PluginEventHandler public class Saniboch { public static NPCClickHandler handleSaniboch = new NPCClickHandler(new Object[] { 1595 }, new String[] { ""Talk-to"", ""Pay"" }, e -> { Player player = e.getPlayer(); NPC npc = e.getNPC(); boolean hasPaid = player.getTempAttribs().getB(""paid_brimhaven_entrance_fee""); boolean hasEnoughGP = player.getInventory().hasCoins(875); Dialogue lackOfGPResponse = new Dialogue() .addPlayer(HeadE.SAD, ""I don't have that..."") .addNPC(npc, HeadE.FRUSTRATED, ""Well this is a dungeon for the more wealthy discerning adventurer, be gone with you riff raff."") .addPlayer(HeadE.HAPPY_TALKING, ""But you don't even have clothes, how can you seriously call anyone riff raff."") .addNPC(npc, HeadE.FRUSTRATED, ""Hummph.""); switch (e.getOption()) { case ""Talk-to"" -> { if (hasPaid) { player.startConversation(new Dialogue() .addNPC(npc, HeadE.HAPPY_TALKING, ""Thank you for your payment, bwana."")); return; } player.startConversation(new Dialogue() .addNPC(npc, HeadE.HAPPY_TALKING, ""Good day to you bwana"") .addOptions(""Choose an option:"", (ops) -> { Dialogue goThroughDialogue = new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Can I go through that door please?"") .addNPC(npc, HeadE.HAPPY_TALKING, ""Most certainly, but I must charge you the sum of 875 coins first""); if (!hasEnoughGP) { goThroughDialogue.addNext(lackOfGPResponse.getHead()); } else { goThroughDialogue.addOptions(""Choose an option:"", (ops1) -> { ops1.option(""Ok, here's 875 coins"", new Dialogue() .addPlayer(HeadE.CALM_TALK, ""Ok, here's 875 coins"") .addItem(6964, ""You give Saniboch 875 coins."", () -> { player.getInventory().removeCoins(875); player.getTempAttribs().setB(""paid_brimhaven_entrance_fee"", true); }) .addNPC(npc, HeadE.HAPPY_TALKING, ""Many thanks. You may now pass the door. May your death be a glorious one!"")); ops1.option(""Never mind."", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Never mind."")); ops1.option(""Why is it worth the entry cost?"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Why is it worth the entry cost?"") .addNPC(npc, HeadE.CALM_TALK, ""It leads to a huge fearsome dungeon, populated by giants and strange dogs. Adventurers come from all around to explore its depths."") .addNPC(npc, HeadE.CALM_TALK, ""I know not what lies deeper in myself, for my skills in agility and woodcutting are inadequate, but I hear tell of even greater dangers deeper in."") .addPlayer(HeadE.HAPPY_TALKING, ""That's nice."")); }); } ops.option(""Can I go through that door please?"", goThroughDialogue); ops.option(""Where does this strange entrance lead?"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Where does this strange entrance lead?"") .addNPC(npc, HeadE.CALM_TALK, ""To a huge fearsome dungeon, populated by giants and strange dogs. Adventurers come from all around to explore its depths."") .addNPC(npc, HeadE.CALM_TALK, ""I know not what lies deeper in myself, for my skills in agility and woodcutting are inadequate."") .addPlayer(HeadE.HAPPY_TALKING, ""That's nice."")); ops.option(""Good day to you too"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Good day to you too"") .addNPC(npc, HeadE.CALM_TALK, ""..."")); ops.option(""I'm impressed, that tree is growing on that shed."", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""I'm impressed, that tree is growing on that shed."") .addNPC(npc, HeadE.CALM_TALK, ""My employer tells me it is an uncommon sort of tree called the Fyburglars tree."") .addPlayer(HeadE.HAPPY_TALKING, ""That's nice."")); })); } case ""Pay"" -> { if (hasPaid) { player.startConversation(new Dialogue() .addNPC(npc, HeadE.HAPPY_TALKING, ""You already paid, bwana."")); return; } if (hasEnoughGP) { player.startConversation(new Dialogue() .addItem(6964, ""You give Saniboch 875 coins."", () -> { player.getInventory().removeCoins(875); player.getTempAttribs().setB(""paid_brimhaven_entrance_fee"", true); }) .addNPC(npc, HeadE.HAPPY_TALKING, ""Many thanks. You may now pass the door. May your death be a glorious one!"")); return; } player.startConversation(lackOfGPResponse); } } }); }" "package com.rs.game.content.world.areas.karamja.npcs; @PluginEventHandler public class YanniSalika { public static NPCClickHandler handleYanniSalika = new NPCClickHandler(new Object[] { 515 }, new String[] { ""Talk-to"" }, e -> { Player player = e.getPlayer(); NPC npc = e.getNPC(); Dialogue oneSmallFavour = new Dialogue() .addPlayer(HeadE.SECRETIVE, ""Is there anything else interesting to do around here?"") .addNPC(npc, HeadE.CALM_TALK, ""You sound a bit bored of Shilo Village...what's wrong?"") .addPlayer(HeadE.CALM_TALK, ""Nothing, I was just wondering if there was anything else to do?"") .addNPC(npc, HeadE.CALM_TALK, ""Well, if you're bored, you could do me a small favour and nip to see the jungle forester. I need a piece of red mahogany to resurface an antique wardrobe."") .addOptions((ops1) -> { ops1.add(""You want me to do you a favour?"") .addPlayer(HeadE.CALM_TALK, ""You want me to do you a favour?"") .addNPC(npc, HeadE.CALM_TALK, ""Well, if you've got nothing better to do...I mean, you looked bored.""); ops1.add(""An adventurer of my calibre, isn't that overkill."") .addPlayer(HeadE.CALM_TALK, ""An adventurer of my calibre, isn't that overkill."") .addNPC(npc, HeadE.CALM_TALK, ""Coooiii! Sorry your most amazingness, didn't realise you were too above it all to do someone a favour!""); ops1.add(""What are you going to give me if I do it?"") .addPlayer(HeadE.CALM_TALK, ""What are you going to give me if I do it?"") .addNPC(npc, HeadE.CALM_TALK, ""Give you? I don't think you heard me...I asked for a favour! It means that I'll 'owe you one' when you need something doing. That's what a favour is!""); ops1.add(""Nah thanks, I've got bigger fish to fry."") .addPlayer(HeadE.CALM_TALK, ""Nah thanks, I've got bigger fish to fry."") .addNPC(npc, HeadE.CALM_TALK, ""Fair enough! Hope it all goes well...but, you know, you looked bored so I just thought I'd suggest it.""); ops1.add(""Ok, see you in a tick!"") .addSimple(""Sorry, the 'One Small Favor' quest is not implemented yet.""); }); player.startConversation(new Dialogue() .addOptions((ops) -> { ops.add(""Tell me about this antiques business."") .addNPC(npc, HeadE.CALM_TALK, ""I buy antiques and other interesting items. If you have any interesting items that you might want to sell me, please let me see them and I'll offer you a fair price. Would you like me to have a look at your items and give"") .addNPC(npc, HeadE.CALM_TALK, ""you a quote?"") .addOptions((ops1) -> { ops1.add(""Yes please!"") .addPlayer(HeadE.CALM_TALK, ""Yes please!"") .addNPC(npc, HeadE.CALM_TALK, ""Great Bwana!"") .addNext(() -> { Dialogue tradeIn = new Dialogue(); Inventory inventory = player.getInventory(); int items = 0; if (inventory.containsItem(605)) { tradeIn = tradeIn.addNPC(npc, HeadE.CALM_TALK, ""I'll give you 100 Gold for the Bone Key.""); items++; } if (inventory.containsItem(606)) { tradeIn = tradeIn.addNPC(npc, HeadE.CALM_TALK, ""I'll give you 100 Gold for the Stone-Plaque.""); items++; } if (inventory.containsItem(607)) { tradeIn = tradeIn.addNPC(npc, HeadE.CALM_TALK, ""I'll give you 100 Gold for the tattered scroll.""); items++; } if (inventory.containsItem(608)) { tradeIn = tradeIn.addNPC(npc, HeadE.CALM_TALK, ""I'll give you 100 Gold for the crumpled scroll.""); items++; } if (inventory.containsItem(624)) { tradeIn = tradeIn.addNPC(npc, HeadE.CALM_TALK, ""I'll give you 100 Gold for your Bervirius notes.""); items++; } if (inventory.containsItem(611)) { tradeIn = tradeIn.addNPC(npc, HeadE.CALM_TALK, ""I'll give you 500 Gold for your locating crystal.""); items++; } if (inventory.containsItem(616)) { tradeIn = tradeIn.addNPC(npc, HeadE.CALM_TALK, ""I'll give you 1000 Gold for your 'Beads of the Dead'.""); items++; } if (inventory.containsItem(4808)) { tradeIn = tradeIn.addNPC(npc, HeadE.CALM_TALK, ""I'll give you 5000 Gold for your black prism.""); items++; } if (items == 0) tradeIn = tradeIn.addNPC(npc, HeadE.CALM_TALK, ""Sorry Bwana, you have nothing I am interested in.""); if (items == 1) tradeIn = tradeIn .addNPC(npc, HeadE.CALM_TALK, ""And that's the only item I am interested in."") .addNPC(npc, HeadE.CALM_TALK, ""If you want to sell me that item, simply show it to me.""); if (items > 1) { tradeIn = tradeIn .addNPC(npc, HeadE.CALM_TALK, ""Those are the items I am interested in Bwana."") .addNPC(npc, HeadE.CALM_TALK, ""If you want to sell me those items, simply show them to me.""); } player.startConversation(tradeIn); }); ops1.add(""Maybe some other time?"") .addPlayer(HeadE.CALM_TALK, ""Maybe some other time?"") .addNPC(npc, HeadE.CALM_TALK, ""Sure thing. Have a nice day Bwana.""); ops1.add(""Is there anything else interesting to do around here?"") .addNext(() -> player.startConversation(oneSmallFavour)); ops1.add(""Hmm, sorry, not interested."") .addPlayer(HeadE.CALM_TALK, ""Hmm, sorry, not interested."") .addNPC(npc, HeadE.CALM_TALK, ""Fair enough, come back if you change your mind.""); }); ops.add(""Is there anything else interesting to do around here?"") .addNext(() -> player.startConversation(oneSmallFavour)); ops.add(""Hmm, sorry, not interested."") .addPlayer(HeadE.CALM_TALK, ""Hmm, sorry, not interested."") .addNPC(npc, HeadE.CALM_TALK, ""Fair enough, come back if you change your mind.""); })); }); }" "package com.rs.game.content.world.areas.karamja.npcs; @PluginEventHandler public class Yohnus { public static NPCClickHandler handleYohnus = new NPCClickHandler(new Object[] { 513 }, new String[]{ ""Talk-to"" }, e -> { Player player = e.getPlayer(); NPC npc = e.getNPC(); if (!player.isQuestComplete(Quest.SHILO_VILLAGE)) return; int blacksmithPays = player.getI(""shilo_blacksmith_pay""); player.startConversation(new Dialogue() .addPlayer(HeadE.CALM_TALK, ""Hello."") .addNPC(npc, HeadE.CALM_TALK, ""Sorry but the blacksmiths is closed. But I can let you use the furnace at the cost of 20 gold pieces."") .addOptions((ops) -> { ops.add(""Use Furnace - 20 Gold"") .addNextIf(() -> !player.getInventory().hasCoins(20), () -> player.startConversation(new Dialogue() .addNPC(npc, HeadE.SAD_MILD_LOOK_DOWN, ""Sorry Bwana, you do not have enough gold!""))) .addNPC(npc, HeadE.HAPPY_TALKING, ""Thanks Bwana! Enjoy the facilities!"", () -> { player.getInventory().removeCoins(20); player.save(""shilo_blacksmith_pay"", blacksmithPays + 1); }); ops.add(""No thanks!"") .addPlayer(HeadE.CALM_TALK, ""No thanks!"") .addNPC(npc, HeadE.CALM_TALK, ""Very well Bwana, have a nice day.""); })); }); }" "package com.rs.game.content.world.areas.karamja.npcs class ZamboKaramjaSpiritsBar(p: Player, npc: NPC) { init { p.startConversation { npc(npc, HeadE.HAPPY_TALKING, ""Hey, are you wanting to try some of my fine wines and spirits? All brewed locally on Karamja."") options { op(""Yes, please."") { player(HeadE.HAPPY_TALKING, ""Yes, please."") exec { ShopsHandler.openShop(p, ""karamja_wines_spirits_and_beers"") } } op(""No, thank you."") { player(HeadE.HAPPY_TALKING, ""No, thank you."") } if (!isBarVisited(p, KARAMJA_SPIRITS) && BarCrawl.hasCard(p) && onBarCrawl(p)) { op(""I'm doing Alfred Grimhand's Barcrawl."") { player(HeadE.HAPPY_TALKING, ""I'm doing Alfred Grimhand's Barcrawl."") npc(npc, HeadE.CHEERFUL, ""Ah, you'll be wanting some ${KARAMJA_SPIRITS.drinkName}, then. It's got a lovely banana taste and it'll only cost you ${KARAMJA_SPIRITS.price} coins."") exec { buyBarcrawlDrink(p, KARAMJA_SPIRITS) } } } } } } } @ServerStartupEvent fun mapZamboKaramjaSpiritsBar() { onNpcClick(568) { (player, npc) -> ZamboKaramjaSpiritsBar(player, npc) } }" "package com.rs.game.content.world.areas.keldagrim @ServerStartupEvent fun mapKeldagrim() { onNpcClick(4558) { e -> when (e.option) { ""Talk-to"" -> e.player.startConversation { npc(e.npcId, HeadE.HAPPY_TALKING, ""Can I help you at all?"") exec { ShopsHandler.openShop(e.player, ""keldagrim_crossbow_shop"") } } ""Trade"" -> ShopsHandler.openShop(e.player, ""keldagrim_crossbow_shop"") } } onNpcClick(2158) { e -> when (e.option) { ""Talk-to"" -> e.player.startConversation { npc(e.npcId, HeadE.HAPPY_TALKING, ""Can I help you at all?"") exec { ShopsHandler.openShop(e.player, ""carefree_crafting_stall"") } } ""Trade"" -> ShopsHandler.openShop(e.player, ""carefree_crafting_stall"") } } val stairMap = mapOf( 5973 to Tile.of(2838, 10124, 0), 5998 to Tile.of(2780, 10161, 0), 9084 to Tile.of(1939, 4958, 0), 9138 to Tile.of(2931, 10196, 0), 45060 to Tile.of(1520, 4704, 0), 45008 to Tile.of(2817, 10155, 0), 45005 to Tile.of(2871, 10176, 1), 45006 to Tile.of(2871, 10173, 0), 45007 to Tile.of(2873, 10173, 2), ) fun handleStairs(objectId: Int, player: Player) { stairMap[objectId]?.let { player.useStairs(it) } } stairMap.keys.forEach { objectId -> onObjectClick(objectId) { e -> handleStairs(e.objectId, e.player) } } onObjectClick(6085, 6086) { e -> if (e.objectId == 6085) e.player.tele(e.player.transform(if (e.getObject().rotation == 1) 3 else if (e.getObject().rotation == 3) -3 else 0, if (e.getObject().rotation == 2) -3 else if (e.getObject().rotation == 0) 3 else 0, 1)) else if (e.objectId == 6086) e.player.tele(e.player.transform(if (e.getObject().rotation == 1) -3 else if (e.getObject().rotation == 3) 3 else 0, if (e.getObject().rotation == 2) 3 else if (e.getObject().rotation == 0) -3 else 0, -1)) } onObjectClick(6089, 6090) { e -> if (e.objectId == 6089) e.player.tele(e.player.transform(if (e.getObject().rotation == 3) -3 else if (e.getObject().rotation == 1) 3 else 0, if (e.getObject().rotation == 3) 0 else if (e.getObject().rotation == 1) -0 else 0, 1)) else if (e.objectId == 6090) e.player.tele(e.player.transform(if (e.getObject().rotation == 3) 3 else if (e.getObject().rotation == 1) -3 else 0, if (e.getObject().rotation == 3) -0 else if (e.getObject().rotation == 1) -0 else 0, -1)) } onObjectClick(6087, 6088) { e -> if (e.objectId == 6087) e.player.tele(e.player.transform(if (e.getObject().rotation == 2) 0 else if (e.getObject().rotation == 0) -0 else 0, if (e.getObject().rotation == 2) -3 else if (e.getObject().rotation == 0) -0 else 0, 1)) else if (e.objectId == 6088) e.player.tele(e.player.transform(if (e.getObject().rotation == 2) -0 else if (e.getObject().rotation == 0) -0 else 0, if (e.getObject().rotation == 2) 3 else if (e.getObject().rotation == 0) -0 else 0, -1)) } }" "package com.rs.game.content.world.areas.keldagrim.npcs; @PluginEventHandler public class Gunslik extends Conversation { //Identify NPC by ID private static final int npcId = 2154; public static NPCClickHandler Gunslik = new NPCClickHandler(new Object[]{npcId}, e -> { switch (e.getOption()) { case ""Talk-to"" -> e.getPlayer().startConversation(new Gunslik(e.getPlayer())); case ""Trade"" -> ShopsHandler.openShop(e.getPlayer(), ""gunsliks_assorted_items""); } }); public Gunslik(Player player) { super(player); addNPC(npcId, HeadE.SECRETIVE, ""Hello there. You've come to the right place if you're looking for adventurer's equipment.""); addOptions(new Options() { @Override public void create() { option(""Oh good!"", new Dialogue() .addNext(() -> ShopsHandler.openShop(player, ""gunsliks_assorted_items""))); option(""Nothing, thanks."", new Dialogue() .addPlayer(HeadE.CONFUSED, ""Nothing, thanks."") ); } }); }; } /* This fixes Hank and restores default store conversation */" "package com.rs.game.content.world.areas.kethsi; @PluginEventHandler public class Kethsi { //sync 11705 1340 (get stone of jas buff) public static ObjectClickHandler handleGlacorCavePassBarrier = new ObjectClickHandler(new Object[] { 61584 }, e -> e.getPlayer().tele(e.getPlayer().transform(e.getPlayer().getX() == 4206 ? -1 : 1, 0, 0))); public static ObjectClickHandler statueArmRubble = new ObjectClickHandler(new Object[] { 6655 }, e -> { if (e.getPlayer().getVars().getVarBit(9833) == 1 || e.getPlayer().getInventory().containsItem(21797)) { e.getPlayer().simpleDialogue(""You search the rubble, but find nothing of interest.""); return; } e.getPlayer().itemDialogue(21797, ""You find a statue arm.""); e.getPlayer().getInventory().addItem(21797, 1); }); public static ItemOnObjectHandler restoreArm = new ItemOnObjectHandler(new Object[] { 10466 }, new Object[] { 21797 }, e -> { if (e.getPlayer().getVars().getVarBit(9833) == 1) { e.getPlayer().simpleDialogue(""It doesn't look like the arm will fit.""); return; } e.getPlayer().simpleDialogue(""You attach the missing arm to the statue and notice it doing a very vertraut pose. A ramp falls down nearby.""); e.getPlayer().getInventory().deleteItem(21797, 1); e.getPlayer().getVars().saveVarBit(9833, 1); }); public static ObjectClickHandler ladders = new ObjectClickHandler(new Object[] { 6754, 6755, 6753 }, e -> { boolean up = e.getObjectId() == 6753; e.getPlayer().useLadder(e.getPlayer().transform(e.getObject().getRotation() == 1 ? (up ? 2 : -2) : e.getObject().getRotation() == 3 ? (up ? -2 : 2) : 0, e.getObject().getRotation() == 2 ? (up ? -2 : 2) : e.getObject().getRotation() == 0 ? (up ? 2 : -2) : 0, up ? 1 : -1)); }); public static ObjectClickHandler jumpGap = new ObjectClickHandler(new Object[] { 10372, 10390 }, e -> e.getPlayer().walkToAndExecute(e.getObject().getTile(), () -> e.getPlayer().forceMove(e.getPlayer().transform(e.getObjectId() == 10372 ? -3 : 3, 0, 0), 11729, 20, 60))); public static ObjectClickHandler crossSpire = new ObjectClickHandler(new Object[] { 10456 }, e -> Agility.walkToAgility(e.getPlayer(), 155, e.getPlayer().getY() < 5709 ? Direction.NORTH : Direction.SOUTH, 6, 6)); public static ObjectClickHandler ramps = new ObjectClickHandler(new Object[] { 6751, 6752 }, e -> e.getPlayer().useStairs(e.getPlayer().transform(0, e.getObjectId() == 6751 ? -5 : 5, e.getObjectId() == 6751 ? 1 : -1))); }" "package com.rs.game.content.world.areas.lighthouse; @PluginEventHandler public class Lighthouse { public static ObjectClickHandler handleEntranceLadders = new ObjectClickHandler(new Object[] { 4383, 4412 }, e -> e.getPlayer().useLadder(e.getObjectId() == 4412 ? Tile.of(2510, 3644, 0) : Tile.of(2519, 9995, 1))); public static ObjectClickHandler handleDoors = new ObjectClickHandler(new Object[] { 4545, 4546 }, e -> Doors.handleDoor(e.getPlayer(), e.getObject())); public static ObjectClickHandler handleLadders = new ObjectClickHandler(new Object[] { 4413, 4485 }, e -> e.getPlayer().useLadder(e.getPlayer().transform(0, e.getObjectId() == 4485 ? 3 : -3, e.getObjectId() == 4485 ? -1 : 1))); }" "package com.rs.game.content.world.areas.lighthouse.npcs; @PluginEventHandler public class Jossik extends Conversation { private static final int JOSSIK = 1334; public static NPCClickHandler handle = new NPCClickHandler(new Object[] { 1334 }, e -> { if (e.getOption().contains(""Talk"")) e.getPlayer().startConversation(new Jossik(e.getPlayer())); else if (e.getOption().contains(""Trade"")) ShopsHandler.openShop(e.getPlayer(), ""book_shop""); }); public Jossik(Player player) { super(player); addNPC(JOSSIK, HeadE.CHEERFUL, ""Hello again, adventurer. What brings you this way?""); addOptions(ops -> { ops.add(""Can I see your wares?"") .addPlayer(HeadE.CONFUSED, ""Can I see your wares?"") .addNPC(JOSSIK, HeadE.CHEERFUL_EXPOSITION, ""Sure thing! I think you'll agree, my prices are remarkable."") .addNext(() -> ShopsHandler.openShop(player, ""the_lighthouse_store"")); ops.add(""Have you found any new prayer books?"") .addNext(() -> { for (int i = 0; i < player.getPrayerBook().length; i++) { if (player.getPrayerBook()[i] && !player.containsOneItem(PrayerBooks.BOOKS[i] + 1)) { player.npcDialogue(JOSSIK, HeadE.CHEERFUL, ""As a matter of fact I did! I found a "" + ItemDefinitions.getDefs(PrayerBooks.BOOKS[i] + 1).getName() + "", and I recognised it as yours immediately! Here you go!""); player.getInventory().addItem(PrayerBooks.BOOKS[i] + 1, 1); return; } } ShopsHandler.openShop(player, ""book_shop""); }); ops.add(""Nevermind.""); }); } }" "package com.rs.game.content.world.areas.lumbridge; @PluginEventHandler public class Lumbridge { public static final String WHEAT_DEPOSITED = ""wheatInMill""; public static final String WHEAT_GRINDED = ""wheatGrinded""; public static ItemOnNPCHandler handleBobRepairs = new ItemOnNPCHandler(new Object[] { 519 }, e -> ItemConstants.handleRepairs(e.getPlayer(), e.getItem(), false, e.getItem().getSlot())); public static NPCClickHandler handleExplorerJack = new NPCClickHandler(new Object[] { 7969 }, e -> e.getPlayer().startConversation(new Conversation(e.getPlayer()) { { addNPC(e.getNPCId(), HeadE.CHEERFUL, ""Hello, what can I do for you?""); addOptions(""What would you like to say?"", new Options() { @Override public void create() { option(""About the Achievement System..."", () -> new AchievementSystemD(player, e.getNPCId(), SetReward.EXPLORERS_RING)); } }); } })); public static NPCClickHandler handleLachtopher = new NPCClickHandler(new Object[] { 7870 }, e -> e.getPlayer().startConversation(new Conversation(e.getPlayer()) { { addPlayer(HeadE.CALM_TALK, ""Hello there""); addNPC(e.getNPCId(), HeadE.DRUNK, ""Hello, I suppose. I'm Lachtopher. Could you lend me some money?""); addPlayer(HeadE.SKEPTICAL, ""Lend you money? I really don't think so. Don't you have any of your own?""); addNPC(e.getNPCId(), HeadE.DRUNK, ""I spend it all and I can't be bothered to earn any more""); addPlayer(HeadE.VERY_FRUSTRATED, ""Right, and you want my hard earned money instead? no chance!""); addNPC(e.getNPCId(), HeadE.DRUNK, ""You are just like my sister, Victoria. She wont give me any money""); addPlayer(HeadE.VERY_FRUSTRATED, ""Your sister sounds like she has the right idea""); addNPC(e.getNPCId(), HeadE.DRUNK, ""Yeah, i've heard it all before. 'Oh', she says, 'it is easy to make money: just complete tasks for cash'""); addPlayer(HeadE.VERY_FRUSTRATED, ""Well, if you want to make money...""); addNPC(e.getNPCId(), HeadE.DRUNK, ""That's just it. I don't want to make money. I just want to have money""); addPlayer(HeadE.VERY_FRUSTRATED, ""I've had it with you!""); create(); } })); public static NPCClickHandler handleBob = new NPCClickHandler(new Object[] { 519 }, e -> { if (e.getOpNum() == 1) e.getPlayer().startConversation(new Conversation(e.getPlayer()) { { addNPC(e.getNPCId(), HeadE.CHEERFUL, ""Hello, what can I do for you?""); addOptions(""What would you like to say?"", new Options() { @Override public void create() { option(""What do you have for sale?"", () -> ShopsHandler.openShop(player, ""bobs_brilliant_axes"")); option(""Can you repair my items?"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Can you repair my items?"") .addNPC(519, HeadE.CALM_TALK, ""Sure just give me the item."") .addSimple(""(Use the item on Bob)"") ); option(""About the Achievement System..."", () -> new AchievementSystemD(player, e.getNPCId(), SetReward.EXPLORERS_RING)); } }); } }); else ShopsHandler.openShop(e.getPlayer(), ""bobs_brilliant_axes""); }); public static ItemOnObjectHandler handleWheatDeposit = new ItemOnObjectHandler(new Object[] { 70034 }, new Object[] { 1947 }, e -> { if (e.getPlayer().get(WHEAT_DEPOSITED) == Boolean.FALSE) { e.getPlayer().getInventory().deleteItem(1947, 1); e.getPlayer().setNextAnimation(new Animation(832)); e.getPlayer().sendMessage(""You put the wheat in the hopper.""); e.getPlayer().save(WHEAT_DEPOSITED, Boolean.TRUE); } }); public static void updateWheat(Player player) { player.getVars().setVar(695, player.get(WHEAT_GRINDED) == Boolean.TRUE ? 1 : 0); } public static LoginHandler updateWheatLogin = new LoginHandler(e -> updateWheat(e.getPlayer())); public static NPCClickHandler handleDukeHoratio = new NPCClickHandler(new Object[] { 741 }, e -> { if (e.getOption().equalsIgnoreCase(""talk-to"")) { int NPC = e.getNPCId(); e.getPlayer().startConversation(new Dialogue() .addNPC(NPC, HeadE.CALM_TALK, ""Greetings. Welcome to my castle."") .addOptions(""Choose an option:"", new Options() { @Override public void create() { if(e.getPlayer().getQuestManager().getStage(Quest.DRAGON_SLAYER) == DragonSlayer.PREPARE_FOR_CRANDOR && e.getPlayer().getQuestManager().getAttribs(Quest.DRAGON_SLAYER).getB(KNOWS_ABOUT_DRAGON_BREATH_ATTR)) option(""I seek a shield that will protect me from dragonbreath."", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""I seek a shield that will protect me from dragonbreath."") .addNPC(NPC, HeadE.SKEPTICAL_THINKING, ""Interesting, how do you know I have a shield?"") .addPlayer(HeadE.SECRETIVE, ""The Champions' Guild, er, guildmaster, told me..."") .addNPC(NPC, HeadE.HAPPY_TALKING, ""The guildmaster eh? What dragon do you intend to slay?"") .addPlayer(HeadE.HAPPY_TALKING, ""Elvarg..."") .addNPC(NPC, HeadE.AMAZED, ""ELVARG!?"") .addNPC(NPC, HeadE.LAUGH, ""He has not given you an easy task has he?"") .addPlayer(HeadE.CALM, ""..."") .addNPC(NPC, HeadE.CALM_TALK, ""Okay, for this specific purpose I can give you a shield."") .addSimple(""The duke hands you the shield."", ()-> e.getPlayer().getInventory().addItem(1540, 1)) ); if(e.getPlayer().getQuestManager().getStage(Quest.DRAGON_SLAYER) >= DragonSlayer.REPORT_TO_OZIACH) option(""I seek a shield that will protect me from dragonbreath."", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""I seek a shield that will protect me from dragonbreath."") .addNPC(NPC, HeadE.CALM_TALK, ""A knight going on a dragon quest, hmm? What dragon do you intend to slay?"") .addNPC(NPC, HeadE.CALM_TALK, ""Ah, well, nvm. Of course, now you've slain Elvarg, you've earned the right to it!"") .addSimple(""The duke hands you the shield."", ()-> e.getPlayer().getInventory().addItem(1540, 1)) ); option(""About Rune Mysteries"", new RuneMysteries.DukeHoracioRuneMysteriesD(e.getPlayer()).getCurrent()); option(""Where can I find money?"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Where can I find money?"") .addNPC(NPC, HeadE.CALM_TALK, ""I hear many of the local people earn money by learning a skill. Many people get by in"" + "" life by becoming accomplished smiths, cooks, miners and woodcutters."") ); option(""Farewell"", new Dialogue()); } }) ); } }); public static ObjectClickHandler handleCellarLadders = new ObjectClickHandler(new Object[] { 24360, 24365 }, e -> { if (e.getObjectId() == 24360) e.getPlayer().tele(Tile.of(3190, 9834, 0)); else if (e.getObjectId() == 24365) e.getPlayer().tele(Tile.of(3188, 3433, 0)); }); public static ObjectClickHandler handleRFDChest = new ObjectClickHandler(new Object[] { 12308 }, e -> { switch (e.getOpNum()) { case OBJECT_OP1: e.getPlayer().getBank().open(); break; case OBJECT_OP2: ShopsHandler.openShop(e.getPlayer(), ""culinaromancer_food_10""); break; case OBJECT_OP3: ShopsHandler.openShop(e.getPlayer(), ""culinaromancer_equipment_10""); break; default: break; } }); public static ObjectClickHandler handleLadders = new ObjectClickHandler(new Object[] { 36771, 36772 }, e -> { if (e.getObjectId() == 36771) e.getPlayer().useLadder(Tile.of(3207, 3222, 3)); else if (e.getObjectId() == 36772) e.getPlayer().useLadder(Tile.of(3207, 3224, 2)); }); public static ObjectClickHandler handleTakeFlour = new ObjectClickHandler(new Object[] { 36880 }, e -> { if (e.getPlayer().getInventory().containsItem(1931, 1)) { if (e.getPlayer().get(WHEAT_GRINDED) == Boolean.TRUE) { e.getPlayer().save(WHEAT_GRINDED, Boolean.FALSE); e.getPlayer().save(WHEAT_DEPOSITED, Boolean.FALSE); e.getPlayer().sendMessage(""You take the ground flour.""); e.getPlayer().setNextAnimation(new Animation(832)); e.getPlayer().getInventory().deleteItem(1931, 1); e.getPlayer().getInventory().addItem(1933, 1); updateWheat(e.getPlayer()); } } else e.getPlayer().sendMessage(""You need an empty pot to gather the flour.""); }); public static ItemOnObjectHandler handleTakeFlourWithPot = new ItemOnObjectHandler(new Object[] { 36880 }, new Object[] { 1931 }, e -> { if (e.getPlayer().get(WHEAT_GRINDED) == Boolean.TRUE) { e.getPlayer().save(WHEAT_GRINDED, Boolean.FALSE); e.getPlayer().save(WHEAT_DEPOSITED, Boolean.FALSE); e.getPlayer().sendMessage(""You take the ground flour.""); e.getPlayer().setNextAnimation(new Animation(832)); e.getPlayer().getInventory().replace(1931, 1933); updateWheat(e.getPlayer()); } }); public static ObjectClickHandler handleWindmillLever = new ObjectClickHandler(new Object[] { 2718 }, e -> { e.getPlayer().sendMessage(""You pull the lever.""); if (e.getPlayer().get(WHEAT_DEPOSITED) == Boolean.TRUE) { e.getPlayer().save(WHEAT_GRINDED, Boolean.TRUE); e.getPlayer().sendMessage(""You hear the grinding of stones and the wheat falls below.""); updateWheat(e.getPlayer()); } }); public static ObjectClickHandler handleHatchetStump = new ObjectClickHandler(new Object[] { 36974 }, e -> { if (e.getPlayer().getInventory().containsItem(1351, 1)) e.getPlayer().sendMessage(""You have already taken the hatchet.""); else e.getPlayer().getInventory().addItem(1351, 1); }); public static ObjectClickHandler handleStaircases1 = new ObjectClickHandler(new Object[] { 45481, 45482 }, e -> { if (e.getObjectId() == 45481) e.getPlayer().tele(e.getPlayer().transform(e.getObject().getRotation() == 1 ? 3 : e.getObject().getRotation() == 3 ? -3 : 0, e.getObject().getRotation() == 0 ? 3 : e.getObject().getRotation() == 2 ? -3 : 0, 1)); else if (e.getObjectId() == 45482) e.getPlayer().tele(e.getPlayer().transform(e.getObject().getRotation() == 1 ? -3 : e.getObject().getRotation() == 3 ? 3 : 0, e.getObject().getRotation() == 0 ? -3 : e.getObject().getRotation() == 2 ? 3 : 0, -1)); }); public static ObjectClickHandler handleStaircases2 = new ObjectClickHandler(new Object[] { 45483, 45484 }, e -> { if (e.getObjectId() == 45483) e.getPlayer().tele(e.getPlayer().transform(e.getObject().getRotation() == 1 ? -3 : e.getObject().getRotation() == 3 ? 3 : 0, e.getObject().getRotation() == 0 ? -3 : e.getObject().getRotation() == 2 ? 3 : 0, 1)); else if (e.getObjectId() == 45484) e.getPlayer().tele(e.getPlayer().transform(e.getObject().getRotation() == 1 ? 3 : e.getObject().getRotation() == 3 ? -3 : 0, e.getObject().getRotation() == 0 ? 3 : e.getObject().getRotation() == 2 ? -3 : 0, -1)); }); public static ObjectClickHandler handleChurchLadders = new ObjectClickHandler(new Object[] { 36984, 36986 }, e -> e.getPlayer().useLadder(e.getPlayer().transform(e.getObjectId() == 36984 ? -2 : 2, 0, 1))); public static ObjectClickHandler handleChurchLaddersT2Up = new ObjectClickHandler(new Object[] { 36988, 36989 }, e -> e.getPlayer().useLadder(e.getPlayer().transform(e.getObjectId() == 36988 ? -1 : 1, -1, 1))); public static ObjectClickHandler handleChurchLaddersT2Down = new ObjectClickHandler(new Object[] { 36990, 36991 }, e -> e.getPlayer().useLadder(e.getPlayer().transform(e.getObjectId() == 36990 ? 1 : -1, 1, -1))); }" "package com.rs.game.content.world.areas.lumbridge.npcs; @PluginEventHandler public class ApprenticeSmith extends Conversation { //Identify NPC by ID private static final int npcId = 4904; public static NPCClickHandler ApprenticeSmith = new NPCClickHandler(new Object[]{npcId}, e -> { switch (e.getOption()) { case ""Talk-to"" -> e.getPlayer().startConversation(new ApprenticeSmith(e.getPlayer())); } }); public ApprenticeSmith(Player player) { super(player); addNPC(npcId, HeadE.CALM_TALK, ""Would you like to learn about the basics of smithing?""); addOptions(new Options() { @Override public void create() { if (!player.getInventory().containsItems(new Item(438, 1), new Item(436, 1))) { option(""Yes"", new Dialogue() .addNPC(npcId, HeadE.WORRIED, ""You'll need to have mined some tin and copper ore to smelt first. Go see the mining tutor to the south if you're not sure how to do this."") ); } else { option(""Yes"", new Dialogue() .addNPC(npcId, HeadE.HAPPY_TALKING, ""I see you have some ore with you to smelt, so let's get started."") .addNPC(npcId, HeadE.CALM_TALK, ""Click on the furnace to bring up a menu of metal bars you can try to make from your ore."") .addNPC(npcId, HeadE.CALM_TALK, ""When you have a full inventory, take it to the bank, you can find it on the roof of the castle in Lumbridge."") .addNPC(npcId, HeadE.CALM_TALK, ""If you have a hammer with you, you can smith the bronze bars into equipment on the anvil."") .addNPC(npcId, HeadE.HAPPY_TALKING, ""Alternatively you can run up to Varrock. Look for my Master, the Smithing Tutor, in the west of the city, he can help you smith better gear."") ); } option(""Not today."", new Dialogue() .addPlayer(HeadE.SKEPTICAL, ""Not today thanks."") .addNPC(npcId, HeadE.LAUGH, ""Okay, be sure to come ask me if you need some help."") ); } }); } }" "package com.rs.game.content.world.areas.lumbridge.npcs; @ServerStartupEvent fun handleBarfyBill() { onNpcClick(3331) { e -> e.player.startConversation(CanoeD(e.player, e.npc)) } }" "package com.rs.game.content.world.areas.lumbridge.npcs; @PluginEventHandler public class CircusBarker extends Conversation { //Identify NPC by ID private static final int npcId = 8081; public static NPCClickHandler CircusBarker = new NPCClickHandler(new Object[]{8079, 8080, 8081}, e -> { switch (e.getOption()) { // case ""Talk-to"" -> e.getPlayer().startConversation(new CircusBarker(e.getPlayer())); // } // } } }); public CircusBarker(Player player) { super(player); //Identify NPC by ID //TODO add support for ID 8079 8080 too, might not be needed? //Add NPC conversation line addNPC(npcId, HeadE.LOSING_IT_LAUGHING, ""Come to Balthzar Beauregard's Big Top Bonanza! It's fun for all; with rewards for all. Come and have a laugh."") //Add PLAYER conversation line .addPlayer(HeadE.HAPPY_TALKING, ""Where is it? Can you take me there?"") //TODO Ticket Vendor locate and teleport .addNPC(npcId, HeadE.ANGRY, ""Do I look like a carrier pigeon!"") .addPlayer(HeadE.CONFUSED, ""Erm, sorry?"") .addNPC(npcId, HeadE.ANGRY, ""Have a nice walk!""); create(); } } //Correct Behaviour //Circus Barker: The ticket vendor is currently located near the . //Circus Barker: The nearest lodestone is in . Would you like me to send you there? //Yes, Please! //(Teleport to lodestone starts.) //No, thank you." "package com.rs.game.content.world.areas.lumbridge.npcs; @PluginEventHandler public class Donie extends Conversation { //Identify NPC by ID private static final int npcId = 2238; public static NPCClickHandler Donie = new NPCClickHandler(new Object[]{npcId}, e -> { switch (e.getOption()) { case ""Talk-to"" -> e.getPlayer().startConversation(new Donie(e.getPlayer())); } }); public Donie(Player player) { super(player); addOptions(new Options() { @Override public void create() { //Give player options addOptions(new Options() { @Override public void create() { //Simple Reply option(""Where am I?"", new Dialogue() .addNPC(npcId, HeadE.CALM_TALK, ""This is the town of Lumbridge my friend."")); //Conversation option(""How are you today?"", new Dialogue() .addNPC(npcId, HeadE.CALM_TALK, ""Aye, not too bad thank you. Lovely weather in RuneScape this fine day."") .addPlayer(HeadE.CALM_TALK, ""Weather?"") .addNPC(npcId, HeadE.CHUCKLE, ""Yes weather, you know."") .addNPC(npcId, HeadE.CALM_TALK, ""The state or condition of the atmosphere at a time and place, with respect to variables such as temperature, moisture, wind velocity, and barometric pressure."") .addPlayer(HeadE.ROLL_EYES, ""..."") .addNPC(npcId, HeadE.LAUGH, ""Not just a pretty face eh? Ha ha ha."") ); //Nested player options with responses option(""Are there any quests I can do here?"", new Dialogue() //NPC to respond first .addNPC(npcId, HeadE.CALM_TALK, ""What kind of quest are you looking for?"") //Show next set of options .addOptions(new Options() { @Override public void create() { option(""I fancy a bit of a fight, anything dangerous?"", new Dialogue() .addNPC(npcId, HeadE.SKEPTICAL, ""Hmm.. dangerous you say? What sort of creatures are you looking to fight?"") .addOptions(new Options() { @Override public void create() { option(""Big scary demons!"", new Dialogue() .addNPC(npcId, HeadE.AMAZED_MILD, ""You are a brave soul indeed."") .addNPC(npcId, HeadE.CALM_TALK, ""Now that you mention it, I heard a rumour about a Saradominist in the Varrock church who is rambling about some kind of greater evil.."") .addNPC(npcId, HeadE.CALM_TALK, ""sounds demon-like if you ask me..."") .addNPC(npcId, HeadE.CALM_TALK, ""Perhaps you should check it out if you are as brave as you say?"") ); option(""Vampyres!"", new Dialogue() .addNPC(npcId, HeadE.SKEPTICAL, ""Ha ha. I personally don't believe in such things."") .addNPC(npcId, HeadE.CALM_TALK, ""However, there is a man in Draynor Village who has been scaring the village folk with stories of vampyres."") .addNPC(npcId, HeadE.CALM_TALK, ""He's named Morgan and can be found in one of the village houses. Perhaps you could see what the matter is?"") ); option(""Small.. something small would be good."", new Dialogue() .addNPC(npcId, HeadE.LAUGH, ""Small? Small isn't really that dangerous though is it?"") .addPlayer(HeadE.FRUSTRATED, ""Yes it can be! There could be anything from an evil chicken to a poisonous spider. They attack in numbers you know!"") .addNPC(npcId, HeadE.CALM_TALK, ""Yes ok, point taken. Speaking of small monsters,"") .addNPC(npcId, HeadE.CALM_TALK, ""I hear old Wizard Mizgog in the wizards' tower has just had all his beads taken by a gang of mischievous imps."") .addNPC(npcId, HeadE.CALM_TALK,""Sounds like it could be a quest for you?"") ); option(""That's all for now.""); } })); option(""Something easy please, I'm new here."", new Dialogue() .addNPC(npcId, HeadE.LAUGH, ""I can tell you about plenty of small easy tasks."") .addNPC(npcId, HeadE.CALM_TALK, ""The Lumbridge cook has been having problems and the Duke is confused over some strange rocks."") .addOptions(new Options() { @Override public void create() { option(""The Lumbridge cook."", new Dialogue() .addNPC(npcId, HeadE.LOSING_IT_LAUGHING, ""It's funny really, the cook would forget his head if it wasn't screwed on."") .addNPC(npcId, HeadE.CALM_TALK,""This time he forgot to get ingredients for the Duke's birthday cake."") .addNPC(npcId, HeadE.CALM_TALK, ""Perhaps you could help him? You will probably find him in the Lumbridge Castle kitchen."") ); option(""The Duke's strange stones."", new Dialogue() .addNPC(npcId, HeadE.CALM_TALK, ""Well the Duke of Lumbridge has found a strange stone that no one seems to understand."") .addNPC(npcId, HeadE.CALM_TALK,""Perhaps you could help him? You can probably find him upstairs in Lumbridge Castle."") ); option(""That's all for now.""); } })); option(""I'm a thinker rather than a fighter, anything skill oriented?"", new Dialogue() .addNPC(npcId, HeadE.CALM_TALK,""Skills play a big part when you want to progress in knowledge throughout RuneScape. "" ) .addNPC(npcId, HeadE.CALM_TALK,""I know of a few skill-related quests that can get you started."") .addNPC(npcId, HeadE.CALM_TALK, ""You may be able to help out Fred the farmer who is in need of someones crafting expertise."") .addNPC(npcId, HeadE.CALM_TALK, ""Or, there's always Doric the dwarf who needs an errand running for him?"") .addOptions(new Options() { @Override public void create() { option(""Farmer Fred."", new Dialogue() .addNPC(npcId, HeadE.CALM_TALK, ""You can find Fred next to the field of sheep in Lumbridge."") .addNPC(npcId, HeadE.CALM_TALK, ""Perhaps you should go and speak with him. He always needs help shearing the sheep!"") ); option(""Doric the dwarf."", new Dialogue() .addNPC(npcId, HeadE.CALM_TALK, ""Doric the dwarf is located north of Falador. "") .addNPC(npcId, HeadE.CALM_TALK,""He might be able to help you with smithing. You should speak to him. He may let you use his anvils."") ); option(""That's all for now.""); }} )); option(""I want to do all kinds of things, do you know of anything like that"", new Dialogue() .addNPC(npcId, HeadE.CALM_TALK,""of course I do. RuneScape is a huge place you know, now let me think... "") .addNPC(npcId, HeadE.CALM_TALK,""Hetty the witch in Rimmington might be able to offer help in the ways of magical abilities. "") .addNPC(npcId, HeadE.CALM_TALK, ""Also, pirates are currently docked in Port Sarim. Where pirates are, treasure is never far away..."") .addNPC(npcId, HeadE.CALM_TALK, ""Or you could go and help out Ernest who got lost in Draynor Manor, spooky place that."") .addOptions(new Options() { @Override public void create() { option(""Hetty the Witch."", new Dialogue() .addNPC(npcId, HeadE.CALM_TALK, ""Hetty the witch can be found in Rimmington, south of Falador. "" ) .addNPC(npcId, HeadE.CALM_TALK, ""She's currently working on some new potions. Perhaps you could give her a hand? "") .addNPC(npcId, HeadE.CALM_TALK, ""She might be able to offer help with your magical abilities."") ); option(""Pirate's treasure."", new Dialogue() .addNPC(npcId, HeadE.CALM_TALK, ""RedBeard Frank in Port Sarim's bar,"") .addNPC(npcId, HeadE.CALM_TALK, ""the Rusty Anchor might be able to tell you about the rumoured treasure that is buried somewhere in RuneScape."") ); option(""Ernest and Draynor Manor."", new Dialogue() .addNPC(npcId,HeadE.CALM_TALK, ""The best place to start would be at the gate to Draynor Manor. "") .addNPC(npcId, HeadE.CALM_TALK, ""There you will find Veronica who will be able to tell you more."") .addNPC(npcId, HeadE.CALM_TALK, ""I suggest you tread carefully in that place;"") .addNPC(npcId, HeadE.SCARED, ""it's haunted."") ); option(""That's all for now.""); }} )); option(""That's all for now.""); } }) ); } }); } }); //TODO add mission checks and alternative responses } }" "package com.rs.game.content.world.areas.lumbridge.npcs; @PluginEventHandler public class Doomsayer extends Conversation { private static final int npcId = 3777; public static NPCClickHandler Doomsayer = new NPCClickHandler(new Object[] { npcId }, e -> { switch(e.getOption()) { case ""Talk-to"" -> e.getPlayer().startConversation(new Doomsayer(e.getPlayer())); } }); public Doomsayer(Player player) { super(player); addNPC(npcId, HeadE.SCARED, ""Dooooom!"") .addPlayer( HeadE.WORRIED, ""Do you mean the Battle of Lumbridge? Are you telling me I should go and help out by going to join in?"") .addNPC(npcId, HeadE.CONFUSED,""No, why should I be doing that? I'm talking about doooooom here, not some battlefield."") .addPlayer(HeadE.CONFUSED, ""Well, everyone else seems to be... um... anyway, you mentioned doom. Where is this doom?"") .addNPC(npcId, HeadE.SCARED, ""All around us! I can feel it in the air, hear it on the wind, smell it...also in the air!"") .addPlayer(HeadE.CONFUSED, ""Is there anything we can do about this doom?"") .addNPC(npcId, HeadE.HAPPY_TALKING, ""There is nothing you need to do my friend! I am the Doomsayer, although my real title could be something like the Danger Tutor."") .addPlayer(HeadE.CONFUSED, ""Danger Tutor?"") .addNPC(npcId, HeadE.CHEERFUL, ""Yes! I roam the world sensing danger."") .addNPC(npcId, HeadE.CHEERFUL, "" If I find a dangerous area, then I put up warning signs that will tell you what is so dangerous about that area.""); create(); } } //TODO add toggle warnings handler //Correct Behaviour //Doomsayer: If you see the signs often enough, then you can turn them of; by that time you likely known what the area has in store for you. //Player: But what If I want to see the warnings again? //Doomsayer: That's why I'm waiting here! //Doomsayer: If you want to see the warning messages again, I can turn them back on for you. //Doomsayer: Do you need to turn on any warnings right now? //Player: Yes, I do. //Screen opens //Player: Not right now. //Doomsayer: Ok, keep an eye out for the messages though! //Player: I will." "package com.rs.game.content.world.areas.lumbridge.npcs; @PluginEventHandler public class FatherAereck extends Conversation { //Identify NPC by ID //NPC handler was 9827? check restless ghost quest.. private static final int npcId = 456; public static NPCClickHandler FatherAereck = new NPCClickHandler(new Object[]{npcId}, e -> { switch (e.getOption()) { case ""Talk-to"" -> e.getPlayer().startConversation(new FatherAereck(e.getPlayer())); } }); public FatherAereck(Player player) { super(player); addNPC(npcId, HeadE.CALM_TALK, ""Hello there "" + player.getPronoun(""brother "", ""sister "") + Utils.formatPlayerNameForDisplay(player.getDisplayName()) + "". How may I help you today?""); addOptions(""What would you like to say?"", new Options() { @Override public void create() { if(player.getQuestManager().getStage(Quest.RESTLESS_GHOST) == 0) option(""I'm looking for a quest."", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""I'm looking for a quest."") .addNPC(npcId, HeadE.CALM_TALK, ""Well that's convenient. I seem to be having a bit of a
ghost problem. Could you go speak to "" + ""speak to
Father Urhney down in the swamp about how to
exorcise the spirit?"", () -> player.getQuestManager().setStage(Quest.RESTLESS_GHOST, 1)) ); option(""Can I have a different gravestone?"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Can I have a different gravestone?"") .addNPC(npcId, HeadE.CALM_TALK, ""Of course you can. Have a look at this selection of gravestones."") .addNext(()-> GraveStoneSelection.openSelectionInterface(player)) ); option(""Can you restore my prayer?"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Can you restore my prayer?"") .addNPC(npcId, HeadE.CALM_TALK, ""I think the Gods prefer it if you pray
to them at an altar dedicated to their name."") ); } }); } } //TODO restore standard conversation options" "package com.rs.game.content.world.areas.lumbridge.npcs; @PluginEventHandler public class FatherUrhney { private static final int NPC = 458; public static NPCClickHandler Urhney = new NPCClickHandler(new Object[]{NPC}, new String[]{""Talk-to""}, e -> { Player player = e.getPlayer(); boolean hasRestlessGhost = player.isQuestComplete(Quest.RESTLESS_GHOST); boolean hasBuyersAndCellars = player.isQuestComplete(Quest.BUYERS_AND_CELLARS); int stageRestlessGhost = player.getQuestManager().getStage(Quest.RESTLESS_GHOST); int stageBuyersAndCellars = player.getQuestManager().getStage(Quest.BUYERS_AND_CELLARS); player.startConversation(new Dialogue() .addNPC(NPC, HeadE.FRUSTRATED, ""Get out of my house!"") .addOptions(questOptions -> { if (stageRestlessGhost == 1) questOptions.add(""Talk about Restless Ghost."", () -> restlessGhostStage1(player)); if (hasRestlessGhost || stageRestlessGhost >= 2) questOptions.add(""Talk about Restless Ghost."", () -> afterRestlessGhost(player)); if (stageBuyersAndCellars >= 4 && !hasBuyersAndCellars) questOptions.add(""Talk about Buyers and Cellars."", () -> { if (stageBuyersAndCellars == 4 || stageBuyersAndCellars == 5) { FatherUrhneyBuyersAndCellars.stage4(player, e.getNPC()); } else FatherUrhneyBuyersAndCellars.stage6(player, e.getNPC()); }); questOptions.add(""Never mind."") .addPlayer(HeadE.CALM_TALK, ""Erm nothing, never mind."") .addNPC(NPC, HeadE.FRUSTRATED, ""Bah.""); }) ); }); public static void restlessGhostStage1(Player player) { player.startConversation(new Dialogue() .addNext(() -> { if (!player.getInventory().containsItem(552, 1)) { player.startConversation(new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Father Aereck told me to come talk to you about a ghost haunting his graveyard."") .addNPC(NPC, HeadE.FRUSTRATED, ""Oh the silly old fool. Here, take this amulet and see if you can communicate with the spectre"", () -> { player.getInventory().addItem(552, 1); player.getQuestManager().setStage(Quest.RESTLESS_GHOST, 2); }) .addPlayer(HeadE.HAPPY_TALKING, ""Thank you. I'll try."") ); } player.getQuestManager().setStage(Quest.RESTLESS_GHOST, 2); })); }; public static void afterRestlessGhost(Player player) { player.startConversation(new Dialogue() .addNext(() -> { if (player.getInventory().containsItem(552, 1) || player.getEquipment().getNeckId() == 552) { player.npcDialogue(NPC, HeadE.FRUSTRATED, ""What are you talking about? I can see you've got it with you.""); return; } if (player.getBank().containsItem(552, 1)) { player.npcDialogue(NPC, HeadE.FRUSTRATED, ""Why do you insist on wasting my time? Has it even occurred to you to look in your bank? Now go away!""); return; } else { player.startConversation(new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""I've lost my amulet of ghostspeak."") .addNPC(NPC, HeadE.CALM_TALK, ""Have another one then. But be more careful next time!"", () -> player.getInventory().addItem(552, 1)) .addPlayer(HeadE.HAPPY_TALKING, ""Thank you. I'll try."") ); } })); } }" "package com.rs.game.content.world.areas.lumbridge.npcs; @PluginEventHandler public class Gee extends Conversation { //Identify NPC by ID private static final int npcId = 2237; public static NPCClickHandler Gee = new NPCClickHandler(new Object[]{2237, 7932, 7923}, e -> { switch (e.getOption()) { case ""Talk-to"" -> e.getPlayer().startConversation(new Gee(e.getPlayer())); } }); public Gee(Player player) { super(player); //Identify NPC by ID //Gee has the same script as Donie.. addOptions(new Options() { @Override public void create() { //Give player options addNPC(npcId, HeadE.CALM_TALK, ""Hello there, Can I help you?""); addOptions(new Options() { @Override public void create() { //Simple Reply option(""Where am I?"", new Dialogue() .addNPC(npcId, HeadE.CALM_TALK, ""This is the town of Lumbridge my friend."")); //Conversation option(""How are you today?"", new Dialogue() .addNPC(npcId, HeadE.CALM_TALK, ""Aye, not too bad thank you. Lovely weather in RuneScape this fine day."") .addPlayer(HeadE.CALM_TALK, ""Weather?"") .addNPC(npcId, HeadE.CHUCKLE, ""Yes weather, you know."") .addNPC(npcId, HeadE.CALM_TALK, ""The state or condition of the atmosphere at a time and place, with respect to variables such as temperature, moisture, wind velocity, and barometric pressure."") .addPlayer(HeadE.ROLL_EYES, ""..."") .addNPC(npcId, HeadE.LAUGH, ""Not just a pretty face eh? Ha ha ha."") ); //Nested player options with responses option(""Are there any quests I can do here?"", new Dialogue() //NPC to respond first .addNPC(npcId, HeadE.CALM_TALK, ""What kind of quest are you looking for?"") //Show next set of options .addOptions(new Options() { @Override public void create() { option(""I fancy a bit of a fight, anything dangerous?"", new Dialogue() .addNPC(npcId, HeadE.SKEPTICAL, ""Hmm.. dangerous you say? What sort of creatures are you looking to fight?"") .addOptions(new Options() { @Override public void create() { option(""Big scary demons!"", new Dialogue() .addNPC(npcId, HeadE.AMAZED_MILD, ""You are a brave soul indeed."") .addNPC(npcId, HeadE.CALM_TALK, ""Now that you mention it, I heard a rumour about a Saradominist in the Varrock church who is rambling about some kind of greater evil.."") .addNPC(npcId, HeadE.CALM_TALK, ""sounds demon-like if you ask me..."") .addNPC(npcId, HeadE.CALM_TALK, ""Perhaps you should check it out if you are as brave as you say?"") ); option(""Vampyres!"", new Dialogue() .addNPC(npcId, HeadE.SKEPTICAL, ""Ha ha. I personally don't believe in such things."") .addNPC(npcId, HeadE.CALM_TALK, ""However, there is a man in Draynor Village who has been scaring the village folk with stories of vampyres."") .addNPC(npcId, HeadE.CALM_TALK, ""He's named Morgan and can be found in one of the village houses. Perhaps you could see what the matter is?"") ); option(""Small.. something small would be good."", new Dialogue() .addNPC(npcId, HeadE.LAUGH, ""Small? Small isn't really that dangerous though is it?"") .addPlayer(HeadE.FRUSTRATED, ""Yes it can be! There could be anything from an evil chicken to a poisonous spider. They attack in numbers you know!"") .addNPC(npcId, HeadE.CALM_TALK, ""Yes ok, point taken. Speaking of small monsters,"") .addNPC(npcId, HeadE.CALM_TALK, ""I hear old Wizard Mizgog in the wizards' tower has just had all his beads taken by a gang of mischievous imps."") .addNPC(npcId, HeadE.CALM_TALK,""Sounds like it could be a quest for you?"") ); option(""That's all for now.""); } })); option(""Something easy please, I'm new here."", new Dialogue() .addNPC(npcId, HeadE.LAUGH, ""I can tell you about plenty of small easy tasks."") .addNPC(npcId, HeadE.CALM_TALK, ""The Lumbridge cook has been having problems and the Duke is confused over some strange rocks."") .addOptions(new Options() { @Override public void create() { option(""The Lumbridge cook."", new Dialogue() .addNPC(npcId, HeadE.LOSING_IT_LAUGHING, ""It's funny really, the cook would forget his head if it wasn't screwed on."") .addNPC(npcId, HeadE.CALM_TALK,""This time he forgot to get ingredients for the Duke's birthday cake."") .addNPC(npcId, HeadE.CALM_TALK, ""Perhaps you could help him? You will probably find him in the Lumbridge Castle kitchen."") ); option(""The Duke's strange stones."", new Dialogue() .addNPC(npcId, HeadE.CALM_TALK, ""Well the Duke of Lumbridge has found a strange stone that no one seems to understand."") .addNPC(npcId, HeadE.CALM_TALK,""Perhaps you could help him? You can probably find him upstairs in Lumbridge Castle."") ); option(""That's all for now.""); } })); option(""I'm a thinker rather than a fighter, anything skill oriented?"", new Dialogue() .addNPC(npcId, HeadE.CALM_TALK,""Skills play a big part when you want to progress in knowledge throughout RuneScape. "" ) .addNPC(npcId, HeadE.CALM_TALK,""I know of a few skill-related quests that can get you started."") .addNPC(npcId, HeadE.CALM_TALK, ""You may be able to help out Fred the farmer who is in need of someones crafting expertise."") .addNPC(npcId, HeadE.CALM_TALK, ""Or, there's always Doric the dwarf who needs an errand running for him?"") .addOptions(new Options() { @Override public void create() { option(""Farmer Fred."", new Dialogue() .addNPC(npcId, HeadE.CALM_TALK, ""You can find Fred next to the field of sheep in Lumbridge."") .addNPC(npcId, HeadE.CALM_TALK, ""Perhaps you should go and speak with him. He always needs help shearing the sheep!"") ); option(""Doric the dwarf."", new Dialogue() .addNPC(npcId, HeadE.CALM_TALK, ""Doric the dwarf is located north of Falador. "") .addNPC(npcId, HeadE.CALM_TALK,""He might be able to help you with smithing. You should speak to him. He may let you use his anvils."") ); option(""That's all for now.""); }} )); option(""I want to do all kinds of things, do you know of anything like that"", new Dialogue() .addNPC(npcId, HeadE.CALM_TALK,""of course I do. RuneScape is a huge place you know, now let me think... "") .addNPC(npcId, HeadE.CALM_TALK,""Hetty the witch in Rimmington might be able to offer help in the ways of magical abilities. "") .addNPC(npcId, HeadE.CALM_TALK, ""Also, pirates are currently docked in Port Sarim. Where pirates are, treasure is never far away..."") .addNPC(npcId, HeadE.CALM_TALK, ""Or you could go and help out Ernest who got lost in Draynor Manor, spooky place that."") .addOptions(new Options() { @Override public void create() { option(""Hetty the Witch."", new Dialogue() .addNPC(npcId, HeadE.CALM_TALK, ""Hetty the witch can be found in Rimmington, south of Falador. "" ) .addNPC(npcId, HeadE.CALM_TALK, ""She's currently working on some new potions. Perhaps you could give her a hand? "") .addNPC(npcId, HeadE.CALM_TALK, ""She might be able to offer help with your magical abilities."") ); option(""Pirate's treasure."", new Dialogue() .addNPC(npcId, HeadE.CALM_TALK, ""RedBeard Frank in Port Sarim's bar,"") .addNPC(npcId, HeadE.CALM_TALK, ""the Rusty Anchor might be able to tell you about the rumoured treasure that is buried somewhere in RuneScape."") ); option(""Ernest and Draynor Manor."", new Dialogue() .addNPC(npcId,HeadE.CALM_TALK, ""The best place to start would be at the gate to Draynor Manor. "") .addNPC(npcId, HeadE.CALM_TALK, ""There you will find Veronica who will be able to tell you more."") .addNPC(npcId, HeadE.CALM_TALK, ""I suggest you tread carefully in that place;"") .addNPC(npcId, HeadE.SCARED, ""it's haunted."") ); option(""That's all for now.""); }} )); option(""That's all for now.""); } }) ); } }); } }); //TODO add mission checks and alternative responses. Maybe rewrite this as Gee and Donie have the same script which is a bore. } }" "package com.rs.game.content.world.areas.lumbridge.npcs; @PluginEventHandler public class GillieGroats { //Identify NPC by ID private static final int npcId = 3807; public static NPCClickHandler GillieGroats = new NPCClickHandler(new Object[]{npcId}, e -> { switch (e.getOption()) { case ""Talk-to"" -> e.getPlayer().startConversation(new GrilleGoatsDialogue(e.getPlayer())); } }); };" "package com.rs.game.content.world.areas.lumbridge.npcs; @PluginEventHandler public class GillieGroatsCow extends Conversation { //Identify Cow by ID private static final int objId = 47721; //Identify Gillie by ID private static final int npcId = 3807; public static ObjectClickHandler handleOptions = new ObjectClickHandler(new Object[] {objId}, e -> { if (e.getOption().equals(""Milk"")) { e.getPlayer().startConversation(new GillieGroatsCow(e.getPlayer())); } }); public GillieGroatsCow(Player player) { super(player); //Identify NPC by ID if(player.getQuestManager().getStage(Quest.COOKS_ASSISTANT) != 1) { addNPC(npcId, HeadE.ANGRY, ""Hands off, That milk is for the Duke!""); create(); } else player.getInventory().addItem(new Item(1927, 1)); } } //TODO handle steal cowbell" "package com.rs.game.content.world.areas.lumbridge.npcs; public class GrilleGoatsDialogue extends Conversation { public GrilleGoatsDialogue(Player player) { super(player); addNPC(3807, HeadE.CALM_TALK, ""Hello, I'm Gillie. What can I do for you?""); addOptions(""baseOptions"", ops -> { ops.add(""Who are you?"") .addPlayer(HeadE.CALM_TALK, ""Who are you?"") .addNPC(3807, HeadE.CALM_TALK, ""My name's Gillie Groats. My father is a farmer and I milk the cows for him."") .addPlayer(HeadE.CALM_TALK, ""Do you have any buckets of milk spare?"") .addNPC(3807, HeadE.CALM_TALK, ""I'm afraid not. We need all of our milk to sell to market, but you can milk the cow yourself if you need milk."") .addPlayer(HeadE.CALM_TALK, ""Thanks.""); ops.add(""Can you tell me how to milk a cow?"") .addPlayer(HeadE.CALM_TALK, ""Can you tell me how to milk a cow?"") .addNPC(3807, HeadE.CALM_TALK, ""It's very easy. First, you need an empty bucket to hold the milk."") .addNPC(3807, HeadE.CALM_TALK, ""You can buy empty buckets from the general store in Lumbridge, south-west of here, or from general stores in RuneScape. You can also buy them from the Grand Exchange in Varrock."") .addNPC(3807, HeadE.CALM_TALK, ""You look like you could do with an empty bucket. Here, take this spare one."") .addItemToInv(player, new Item(1925, 1), ""She hands you a bucket."") .addNPC(3807, HeadE.CALM_TALK, ""Then find a dairy cow to milk - you can't milk just any cow."") .addPlayer(HeadE.CALM_TALK, ""How do I find a dairy cow?"") .addNPC(3807, HeadE.CALM_TALK, ""They are easy to spot - they have a cowbell around their neck and are tethered to a post to stop them wandering around all over the place. There are a couple in this field."") .addPlayer(HeadE.CALM_TALK, ""What about top-quality milk?"") .addNPC(3807, HeadE.CALM_TALK, ""Ah, for that you'll have to see my prized cow, on the east side of the field, over by the cliff."") .addNPC(3807, HeadE.CALM_TALK, ""Then you just need to use your bucket on the cow and you'll get some tasty, nutritious milk.""); ops.add(""Can I buy milk off you?"") .addPlayer(HeadE.CALM_TALK, ""Can I buy milk off you?"") .addNPC(3807, HeadE.CALM_TALK, ""I'm afraid not. My husband has already taken all of our stocks to the market."") .addNPC(3807, HeadE.CALM_TALK, ""You could get some by milking the dairy cows yourself. If you would still rather buy it, you can probably get some at the Grand Exchange in Varrock, just north of here. A lot of adventurers sell their goods there.""); ops.add(""I'm fine thanks."") .addPlayer(HeadE.CALM_TALK, ""I'm fine thanks.""); }); } }" "package com.rs.game.content.world.areas.lumbridge.npcs; @PluginEventHandler public class GuardsmanBrawn extends Conversation { //Identify NPC by ID private static final int npcId = 7887; public static NPCClickHandler GuardsmanBrawn = new NPCClickHandler(new Object[]{npcId}, e -> { switch (e.getOption()) { case ""Talk-to"" -> e.getPlayer().startConversation(new GuardsmanBrawn(e.getPlayer())); } }); public GuardsmanBrawn(Player player) { super(player); //TODO replace placeholder conversation addNPC(npcId, HeadE.FRUSTRATED, ""Not right now, I'm Busy!""); create(); } }" "package com.rs.game.content.world.areas.lumbridge.npcs; @PluginEventHandler public class GuardsmanDante extends Conversation { //Identify NPC by ID private static final int npcId = 7885; public static NPCClickHandler GuardsmanDante = new NPCClickHandler(new Object[]{npcId}, e -> { switch (e.getOption()) { case ""Talk-to"" -> e.getPlayer().startConversation(new GuardsmanDante(e.getPlayer())); } }); public GuardsmanDante(Player player) { super(player); //TODO replace placeholder conversation addNPC(npcId, HeadE.FRUSTRATED, ""Not right now, I'm Busy!""); create(); } }" "package com.rs.game.content.world.areas.lumbridge.npcs; @PluginEventHandler public class GuardsmanDeShawn extends Conversation { //Identify NPC by ID private static final int npcId = 7886; public static NPCClickHandler GuardsmanDeShawn = new NPCClickHandler(new Object[]{npcId}, e -> { switch (e.getOption()) { case ""Talk-to"" -> e.getPlayer().startConversation(new GuardsmanDeShawn(e.getPlayer())); } }); public GuardsmanDeShawn(Player player) { super(player); //TODO replace placeholder conversation addNPC(npcId, HeadE.FRUSTRATED, ""Not right now, I'm Busy!""); create(); } }" "package com.rs.game.content.world.areas.lumbridge.npcs; @PluginEventHandler public class GuardsmanPazel extends Conversation { //Identify NPC by ID private static final int npcId = 7889; public static NPCClickHandler GuardsmanPazel = new NPCClickHandler(new Object[]{npcId}, e -> { switch (e.getOption()) { case ""Talk-to"" -> e.getPlayer().startConversation(new GuardsmanPazel(e.getPlayer())); } }); public GuardsmanPazel(Player player) { super(player); //TODO replace placeholder conversation addNPC(npcId, HeadE.FRUSTRATED, ""Not right now, I'm Busy!""); create(); } }" "package com.rs.game.content.world.areas.lumbridge.npcs; @PluginEventHandler public class GuardsmanPeale extends Conversation { //Identify NPC by ID private static final int npcId = 7890; public static NPCClickHandler GuardsmanPeale = new NPCClickHandler(new Object[]{npcId}, e -> { switch (e.getOption()) { case ""Talk-to"" -> e.getPlayer().startConversation(new GuardsmanPeale(e.getPlayer())); } }); public GuardsmanPeale(Player player) { super(player); //TODO replace placeholder conversation addNPC(npcId, HeadE.FRUSTRATED, ""Not right now, I'm Busy!""); create(); } }" "package com.rs.game.content.world.areas.lumbridge.npcs; @PluginEventHandler public class Hank extends Conversation { //Identify NPC by ID private static final int npcId = 8864; public static NPCClickHandler Hank = new NPCClickHandler(new Object[]{npcId}, e -> { switch (e.getOption()) { case ""Talk-to"" -> e.getPlayer().startConversation(new Hank(e.getPlayer())); case ""Trade"" -> ShopsHandler.openShop(e.getPlayer(), ""lumbridge_fishing_supplies""); } }); public Hank(Player player) { super(player); }; } /* This fixes Hank and restores default store conversation */" "package com.rs.game.content.world.areas.lumbridge.npcs; @PluginEventHandler public class Hans extends Conversation { //Identify NPC by ID private static final int npcId = 0; public static NPCClickHandler Hans = new NPCClickHandler(new Object[]{npcId}, e -> { switch (e.getOption()) { case ""Talk-to"" -> e.getPlayer().startConversation(new Hans(e.getPlayer(), e.getNPC())); } }); public Hans(Player player, NPC npc) { super(player); //Identify NPC by ID addOptions(new Options() { @Override public void create() { //Player initiates addNPC(npcId, HeadE.CALM_TALK, ""Hello. What are you doing here?""); addOptions(new Options() { @Override public void create() { option(""I'm looking for whoever is in charge of this place."", new Dialogue() .addPlayer(HeadE.CALM_TALK, ""I'm looking for whoever is in charge of this place."") .addNPC(npcId, HeadE.CALM_TALK, ""Who, the Duke? He's in his study, on the first floor."") ); option(""I have come to kill everyone in this castle!"", new Dialogue() .addPlayer(HeadE.EVIL_LAUGH, ""I have come to kill everyone in this castle!"") .addNPC(npcId, HeadE.TERRIFIED, ""Help!"") .addNext(() -> npc.setNextForceTalk(new ForceTalk(""Help! Help! Help!""))) //TODO Make run-away ); option(""Can you tell me how long I've been here?"", new Dialogue() .addPlayer(HeadE.CALM_TALK, ""Can you tell me how long I've been here?"") .addNPC(npcId, HeadE.CALM_TALK, ""As long as you have been wasting my time!"") ); option(""Nothing."", new Dialogue() ); } } ); } }); } }" "package com.rs.game.content.world.areas.lumbridge.npcs; @PluginEventHandler public class Iain extends Conversation { //Identify NPC by ID //Iain has the same script as Donie.. private static final int npcId = 7868; public static NPCClickHandler Iain = new NPCClickHandler(new Object[]{npcId}, e -> { switch (e.getOption()) { case ""Talk-to"" -> e.getPlayer().startConversation(new Iain(e.getPlayer())); } }); public Iain(Player player) { super(player); addOptions(new Options() { @Override public void create() { //Give player options addOptions(new Options() { @Override public void create() { //Simple Reply option(""Where am I?"", new Dialogue() .addNPC(npcId, HeadE.CALM_TALK, ""This is the town of Lumbridge my friend."")); //Conversation option(""How are you today?"", new Dialogue() .addNPC(npcId, HeadE.CALM_TALK, ""Aye, not too bad thank you. Lovely weather in RuneScape this fine day."") .addPlayer(HeadE.CALM_TALK, ""Weather?"") .addNPC(npcId, HeadE.CHUCKLE, ""Yes weather, you know."") .addNPC(npcId, HeadE.CALM_TALK, ""The state or condition of the atmosphere at a time and place, with respect to variables such as temperature, moisture, wind velocity, and barometric pressure."") .addPlayer(HeadE.ROLL_EYES, ""..."") .addNPC(npcId, HeadE.LAUGH, ""Not just a pretty face eh? Ha ha ha."") ); //Nested player options with responses option(""Are there any quests I can do here?"", new Dialogue() //NPC to respond first .addNPC(npcId, HeadE.CALM_TALK, ""What kind of quest are you looking for?"") //Show next set of options .addOptions(new Options() { @Override public void create() { option(""I fancy a bit of a fight, anything dangerous?"", new Dialogue() .addNPC(npcId, HeadE.SKEPTICAL, ""Hmm.. dangerous you say? What sort of creatures are you looking to fight?"") .addOptions(new Options() { @Override public void create() { option(""Big scary demons!"", new Dialogue() .addNPC(npcId, HeadE.AMAZED_MILD, ""You are a brave soul indeed."") .addNPC(npcId, HeadE.CALM_TALK, ""Now that you mention it, I heard a rumour about a Saradominist in the Varrock church who is rambling about some kind of greater evil.."") .addNPC(npcId, HeadE.CALM_TALK, ""sounds demon-like if you ask me..."") .addNPC(npcId, HeadE.CALM_TALK, ""Perhaps you should check it out if you are as brave as you say?"") ); option(""Vampyres!"", new Dialogue() .addNPC(npcId, HeadE.SKEPTICAL, ""Ha ha. I personally don't believe in such things."") .addNPC(npcId, HeadE.CALM_TALK, ""However, there is a man in Draynor Village who has been scaring the village folk with stories of vampyres."") .addNPC(npcId, HeadE.CALM_TALK, ""He's named Morgan and can be found in one of the village houses. Perhaps you could see what the matter is?"") ); option(""Small.. something small would be good."", new Dialogue() .addNPC(npcId, HeadE.LAUGH, ""Small? Small isn't really that dangerous though is it?"") .addPlayer(HeadE.FRUSTRATED, ""Yes it can be! There could be anything from an evil chicken to a poisonous spider. They attack in numbers you know!"") .addNPC(npcId, HeadE.CALM_TALK, ""Yes ok, point taken. Speaking of small monsters,"") .addNPC(npcId, HeadE.CALM_TALK, ""I hear old Wizard Mizgog in the wizards' tower has just had all his beads taken by a gang of mischievous imps."") .addNPC(npcId, HeadE.CALM_TALK,""Sounds like it could be a quest for you?"") ); option(""That's all for now.""); } })); option(""Something easy please, I'm new here."", new Dialogue() .addNPC(npcId, HeadE.LAUGH, ""I can tell you about plenty of small easy tasks."") .addNPC(npcId, HeadE.CALM_TALK, ""The Lumbridge cook has been having problems and the Duke is confused over some strange rocks."") .addOptions(new Options() { @Override public void create() { option(""The Lumbridge cook."", new Dialogue() .addNPC(npcId, HeadE.LOSING_IT_LAUGHING, ""It's funny really, the cook would forget his head if it wasn't screwed on."") .addNPC(npcId, HeadE.CALM_TALK,""This time he forgot to get ingredients for the Duke's birthday cake."") .addNPC(npcId, HeadE.CALM_TALK, ""Perhaps you could help him? You will probably find him in the Lumbridge Castle kitchen."") ); option(""The Duke's strange stones."", new Dialogue() .addNPC(npcId, HeadE.CALM_TALK, ""Well the Duke of Lumbridge has found a strange stone that no one seems to understand."") .addNPC(npcId, HeadE.CALM_TALK,""Perhaps you could help him? You can probably find him upstairs in Lumbridge Castle."") ); option(""That's all for now.""); } })); option(""I'm a thinker rather than a fighter, anything skill oriented?"", new Dialogue() .addNPC(npcId, HeadE.CALM_TALK,""Skills play a big part when you want to progress in knowledge throughout RuneScape. "" ) .addNPC(npcId, HeadE.CALM_TALK,""I know of a few skill-related quests that can get you started."") .addNPC(npcId, HeadE.CALM_TALK, ""You may be able to help out Fred the farmer who is in need of someones crafting expertise."") .addNPC(npcId, HeadE.CALM_TALK, ""Or, there's always Doric the dwarf who needs an errand running for him?"") .addOptions(new Options() { @Override public void create() { option(""Farmer Fred."", new Dialogue() .addNPC(npcId, HeadE.CALM_TALK, ""You can find Fred next to the field of sheep in Lumbridge."") .addNPC(npcId, HeadE.CALM_TALK, ""Perhaps you should go and speak with him. He always needs help shearing the sheep!"") ); option(""Doric the dwarf."", new Dialogue() .addNPC(npcId, HeadE.CALM_TALK, ""Doric the dwarf is located north of Falador. "") .addNPC(npcId, HeadE.CALM_TALK,""He might be able to help you with smithing. You should speak to him. He may let you use his anvils."") ); option(""That's all for now.""); }} )); option(""I want to do all kinds of things, do you know of anything like that"", new Dialogue() .addNPC(npcId, HeadE.CALM_TALK,""of course I do. RuneScape is a huge place you know, now let me think... "") .addNPC(npcId, HeadE.CALM_TALK,""Hetty the witch in Rimmington might be able to offer help in the ways of magical abilities. "") .addNPC(npcId, HeadE.CALM_TALK, ""Also, pirates are currently docked in Port Sarim. Where pirates are, treasure is never far away..."") .addNPC(npcId, HeadE.CALM_TALK, ""Or you could go and help out Ernest who got lost in Draynor Manor, spooky place that."") .addOptions(new Options() { @Override public void create() { option(""Hetty the Witch."", new Dialogue() .addNPC(npcId, HeadE.CALM_TALK, ""Hetty the witch can be found in Rimmington, south of Falador. "" ) .addNPC(npcId, HeadE.CALM_TALK, ""She's currently working on some new potions. Perhaps you could give her a hand? "") .addNPC(npcId, HeadE.CALM_TALK, ""She might be able to offer help with your magical abilities."") ); option(""Pirate's treasure."", new Dialogue() .addNPC(npcId, HeadE.CALM_TALK, ""RedBeard Frank in Port Sarim's bar,"") .addNPC(npcId, HeadE.CALM_TALK, ""the Rusty Anchor might be able to tell you about the rumoured treasure that is buried somewhere in RuneScape."") ); option(""Ernest and Draynor Manor."", new Dialogue() .addNPC(npcId,HeadE.CALM_TALK, ""The best place to start would be at the gate to Draynor Manor. "") .addNPC(npcId, HeadE.CALM_TALK, ""There you will find Veronica who will be able to tell you more."") .addNPC(npcId, HeadE.CALM_TALK, ""I suggest you tread carefully in that place;"") .addNPC(npcId, HeadE.SCARED, ""it's haunted."") ); option(""That's all for now.""); }} )); option(""That's all for now.""); } }) ); } }); } }); //TODO add mission checks and alternative responses } }" "package com.rs.game.content.world.areas.lumbridge.npcs; @PluginEventHandler public class LumbridgeSage extends Conversation { // Identify NPC by ID private static final int npcId = 2244; public static NPCClickHandler LumbridgeSage = new NPCClickHandler(new Object[] { 2244 }, e -> { switch (e.getOption()) { // Start Conversation case ""Talk-to"" -> e.getPlayer().startConversation(new LumbridgeSage(e.getPlayer())); } }); public LumbridgeSage(Player player) { super(player); // Identify NPC by ID addOptions(new Options() { @Override public void create() { // Give player options addOptions(new Options() { @Override public void create() { // Simple Reply addNPC(npcId, HeadE.CALM_TALK, ""Greetings, adventurer. How may I help you?""); option(""Who are you?"", new Dialogue() .addNPC(npcId, HeadE.CALM_TALK, ""I am Phileas, the Lumbridge Sage. "") .addNPC(npcId, HeadE.CALM_TALK, "" In times past, people came from all around to ask me for advice. "") .addNPC(npcId, HeadE.CALM_TALK, ""My renown seems to have diminished somewhat in recent years, though."") .addNPC(npcId, HeadE.CALM_TALK, ""Can I help you with anything?"")); // Conversation option(""Tell me about the town of Lumbridge"", new Dialogue().addNPC(npcId, HeadE.CALM_TALK, ""Lumbridge is one of the older towns in the human-controlled kingdoms. IT was founded over two hundred years ago towards the end of the Fourth Age. It's called Lumbridge because of this bridge built over the River Lum."") .addNPC(npcId, HeadE.CALM_TALK, ""The town is governed by Duke Horacio, who is a good friend of our monarch, King Roald of Misthalin."") .addNPC(npcId, HeadE.CALM_TALK, ""Recently, however, there have been great changes due to the Battle of Lumbridge."") .addNPC(npcId, HeadE.CALM_TALK, ""Indeed, not long ago there was a great fight between Saradomin and Zamorak on the battlefield to the west of the castle."") .addNPC(npcId, HeadE.CALM_TALK, ""Titanic forces were unleashed as neither side could gain the upper hand. Each side sought advantages, but it was close until the end."") .addNPC(npcId, HeadE.CALM_TALK, ""The battle lasted for months, but in the end the forces of the holy Saradomin were triumphant. Zamorak was defeated... but..."") .addNPC(npcId, HeadE.CALM_TALK, ""Before Saradomin could complete his victory, Moia, the general of Zamorak's forces, transported him away."") .addNPC(npcId, HeadE.CALM_TALK, ""Now, the battlefield lies empty save for a single Saradominist devotee, and Lumbridge lies in ruins. Luckily, Foreman George is organising a rebuilding effort, to the north of the castle."")); option(""Goodbye""); } }); } }); } }" "package com.rs.game.content.world.areas.lumbridge.npcs; @PluginEventHandler public class Victoria extends Conversation { // Identify NPC by ID private static final int npcId = 7872; public static NPCClickHandler Iain = new NPCClickHandler(new Object[] { npcId }, e -> { switch (e.getOption()) { // Start Conversation case ""Talk-to"" -> e.getPlayer().startConversation(new Victoria(e.getPlayer())); } }); public Victoria(Player player) { super(player); // TODO replace placeholder conversation addNPC(npcId, HeadE.FRUSTRATED, ""Not right now, I'm Busy!""); create(); } }" "package com.rs.game.content.world.areas.lumbridge.npcs; @PluginEventHandler public class Yauchomi extends Conversation { // Identify NPC by ID private static final int npcId = 4903; public static NPCClickHandler Yauchomi = new NPCClickHandler(new Object[] { npcId }, e -> { switch (e.getOption()) { // Start Conversation case ""Talk-to"" -> e.getPlayer().startConversation(new Yauchomi(e.getPlayer())); } }); public Yauchomi(Player player) { super(player); // Identify NPC by ID addOptions(new Options() { @Override public void create() { // Player initiates addPlayer(HeadE.CALM_TALK, ""Good day, sister.""); // NPC responds addNPC(npcId, HeadE.CALM_TALK, ""Greetings, "" + player.getDisplayName() + "", Can I help you with anything, today?""); // Player given choices addOptions(new Options() { @Override public void create() { option(""How can I train my prayer?"", new Dialogue() .addNPC(npcId, HeadE.CALM_TALK, ""Well, if you really want my advice..."") .addNPC(npcId, HeadE.CALM_TALK, ""The most common way to train prayer is by either burying bones, or offering them to the gods at some kind of an altar."") .addNPC(npcId, HeadE.CALM_TALK, ""Lots of adventurers build such altars in their own homes, or there are a few frequent places of worship around the world."") .addNPC(npcId, HeadE.CALM_TALK, ""Different kinds of bones will help you to train faster. Generally speaking, the bigger they are and the more frightening a creature they come from, the better they are for it."")); option("" What is prayer useful for??"", new Dialogue() .addNPC(npcId, HeadE.CALM_TALK, ""The gods look kindly upon their devout followers. There are all kinds of benefits they may provide, if you pray for them!"") .addPlayer(HeadE.AMAZED_MILD, ""Really? What kind of benefits?"") .addNPC(npcId, HeadE.CALM_TALK, ""They could help you in combat, help your wounds to heal more quickly, protect your belongings... There's a lot they can do for you!"") .addNPC(npcId, HeadE.CALM_TALK, ""You can find out more by looking in your prayer book."") .addPlayer(HeadE.AMAZED_MILD, ""Wow! That sounds great."") .addNPC(npcId, HeadE.CALM_TALK, ""You need to be careful that your prayers don't run out, though. You can get prayer potions to help you recharge, or you can pray at an altar whenever one's nearby"")); } }); } }); } }" "package com.rs.game.content.world.areas.lunar_isle; @PluginEventHandler public class LunarIsle { public static NPCClickHandler enterBabaYagaHouse = new NPCClickHandler(new Object[] { 4512 }, e -> e.getPlayer().tele(Tile.of(3103, 4447, 0))); public static ObjectClickHandler exitBabaYagaHouse = new ObjectClickHandler(new Object[] { 16774 }, e -> e.getPlayer().tele(Tile.of(2087, 3930, 0))); public static NPCClickHandler babaYaga = new NPCClickHandler(new Object[] { 4513 }, e -> { switch(e.getOption()) { case ""Talk-to"" -> e.getPlayer().startConversation(new Dialogue() .addNPC(4513, HeadE.CHEERFUL, ""Ah, a visitor from a distant land. How can I help?"") .addOptions(ops -> { if (e.getPlayer().isQuestComplete(Quest.LUNAR_DIPLOMACY)) ops.add(""Have you got anything to trade?""); ops.add(""It's a very interesting house you have here."") .addPlayer(HeadE.CONFUSED, ""It's a very interesting house you have here. Does he have a name?"") .addNPC(4513, HeadE.CHEERFUL, ""Why of course. It's Berty."") .addPlayer(HeadE.CONFUSED, ""Berty? Berty the Chicken leg house?"") .addNPC(4513, HeadE.CHEERFUL, ""Yes."") .addPlayer(HeadE.CONFUSED, ""May I ask why?"") .addNPC(4513, HeadE.LAUGH, ""It just has a certain ring to it, don't you think? Beeerteeee!"") .addPlayer(HeadE.SHAKING_HEAD, ""You're ins..."") .addNPC(4513, HeadE.CHEERFUL, ""Insane? Very.""); ops.add(""I'm good, thanks, bye."") .addPlayer(HeadE.CHEERFUL, ""I'm good, thanks, bye.""); }) ); case ""Trade"" -> { if (e.getPlayer().isQuestComplete(Quest.LUNAR_DIPLOMACY)) ShopsHandler.openShop(e.getPlayer(), ""baba_yagas_magic_shop""); } } }); }" "package com.rs.game.content.world.areas.meiyerditch; @PluginEventHandler public class Meiyerditch { public static LoginHandler unlockVars = new LoginHandler(e -> { e.getPlayer().getVars().setVarBit(2587, 1); //boat e.getPlayer().getVars().setVarBit(2589, 1); //kick down floor }); public static ObjectClickHandler handleBoat = new ObjectClickHandler(false, new Object[] { 12945, 17955 }, e -> { if (e.getObjectId() == 12945) e.getPlayer().walkToAndExecute(Tile.of(3525, 3170, 0), () -> { e.getPlayer().faceObject(e.getObject()); e.getPlayer().fadeScreen(() -> e.getPlayer().tele(Tile.of(3605, 3163, 0))); }); else e.getPlayer().walkToAndExecute(Tile.of(3605, 3163, 0), () -> { e.getPlayer().faceObject(e.getObject()); e.getPlayer().fadeScreen(() -> e.getPlayer().tele(Tile.of(3525, 3170, 0))); }); }); public static ObjectClickHandler handleRocks1 = new ObjectClickHandler(new Object[] { 17960, 17679 }, e -> e.getPlayer().useLadder(e.getPlayer().transform(e.getObjectId() == 17960 ? 4 : -4, 0, e.getObjectId() == 17960 ? -1 : 1))); public static ObjectClickHandler handleFloorClimb = new ObjectClickHandler(new Object[] { 18122, 18124 }, e -> e.getPlayer().useLadder(e.getObject().getTile().transform(e.getObjectId() == 18122 ? -1 : 1, 0, e.getObjectId() == 18122 ? -1 : 1))); public static ObjectClickHandler handleRubble = new ObjectClickHandler(new Object[] { 18037, 18038 }, e -> e.getPlayer().useLadder(e.getObject().getTile().transform(e.getObjectId() == 18037 ? 3 : -3, 0, 0))); public static ObjectClickHandler handleMeiyerditchstairs = new ObjectClickHandler(new Object[] { 17976, 17978 }, e -> { if (e.getObjectId() == 17976) e.getPlayer().tele(e.getPlayer().transform(e.getObject().getRotation() == 1 ? 3 : e.getObject().getRotation() == 3 ? -3 : 0, e.getObject().getRotation() == 2 ? -3 : e.getObject().getRotation() == 0 ? 3 : 0, 1)); else if (e.getObjectId() == 17978) e.getPlayer().tele(e.getPlayer().transform(e.getObject().getRotation() == 1 ? -3 : e.getObject().getRotation() == 3 ? 3 : 0, e.getObject().getRotation() == 2 ? 3 : e.getObject().getRotation() == 0 ? -3 : 0, -1)); }); }" "package com.rs.game.content.world.areas.miscellania; @PluginEventHandler public class Miscellania { public static NPCClickHandler handleAdvisorGhrim = new NPCClickHandler(new Object[] { 1375 }, e -> e.getPlayer().startConversation(new Conversation(e.getPlayer()) { { addNPC(e.getNPCId(), HeadE.CHEERFUL, ""Hello, what can I do for you?""); addOptions(""What would you like to say?"", new Options() { @Override public void create() { option(""About the Achievement System..."", () -> new AchievementSystemD(player, e.getNPCId(), SetReward.FREMENNIK_BOOTS)); } }); } })); public static ObjectClickHandler handleUndergroundEntrance = new ObjectClickHandler(new Object[] { 15115, 15116 }, e -> e.getPlayer().ladder(e.getObjectId() == 15115 ? Tile.of(2509, 3847, 0) : Tile.of(2509, 10245, 0))); public static ObjectClickHandler handleUndergroundCrevices = new ObjectClickHandler(new Object[] { 15186, 15187 }, e -> e.getPlayer().tele(e.getObjectId() == 15186 ? Tile.of(2505, 10283, 0) : Tile.of(2505, 10280, 0))); public static ObjectClickHandler handleTrees = new ObjectClickHandler(new Object[] { 46274, 46275, 46277, 15062 }, e -> e.getPlayer().sendMessage(""You'd better leave that to the serfs."")); }" "package com.rs.game.content.world.areas.miscellania; @PluginEventHandler public class MiscellaniaAndEtceteriaDungeon { public static ObjectClickHandler secondcreviceentrance = new ObjectClickHandler(new Object[] { 15194 }, e -> e.getPlayer().tele(Tile.of(2585, 10262, 0))); public static ObjectClickHandler secondcreviceexit = new ObjectClickHandler(new Object[] { 15195 }, e -> e.getPlayer().tele(Tile.of(2585, 10259, 0))); public static ObjectClickHandler thirdcreviceentrance = new ObjectClickHandler(new Object[] { 15196 }, e -> e.getPlayer().tele(Tile.of(2617, 10274, 0))); public static ObjectClickHandler thirdcreviceexit = new ObjectClickHandler(new Object[] { 15197 }, e -> e.getPlayer().tele(Tile.of(2617, 10271, 0))); public static ObjectClickHandler takeropecrate = new ObjectClickHandler(new Object[] { 15245 }, e -> e.getPlayer().tele(Tile.of(2509, 10288, 1))); public static ObjectClickHandler crawltunnelentrance = new ObjectClickHandler(new Object[] { 15188 }, e -> e.getPlayer().tele(Tile.of(2514, 10291, 0))); public static ObjectClickHandler crawltunnelexit = new ObjectClickHandler(new Object[] { 15189 }, e -> e.getPlayer().tele(Tile.of(2510, 10287, 1))); public static ItemOnObjectHandler TEMPneedropeswingrock = new ItemOnObjectHandler(new Object[] { 15252 }, new Object[] { 954 }, e -> { if (e.getPlayer().getX() == 2538 && e.getPlayer().getY() == 10299) { e.getPlayer().tele(Tile.of(2543, 10299, 0)); } else e.getPlayer().sendMessage(""You are too far away to do this.""); }); public static ObjectClickHandler ropeswingexit = new ObjectClickHandler(new Object[] { 15216 }, e -> e.getPlayer().tele(Tile.of(2536, 10296, 0))); public static ItemOnObjectHandler TEMPlightropeup = new ItemOnObjectHandler(new Object[] { 15193 }, new Object[] { 954 }, e -> e.getPlayer().tele(Tile.of(2620, 3864, 0))); public static ItemOnObjectHandler TEMPlightropedown = new ItemOnObjectHandler(new Object[] { 15200 }, new Object[] { 954 }, e -> e.getPlayer().tele(Tile.of(2617, 10265, 0))); }" "package com.rs.game.content.world.areas.mortton; @PluginEventHandler public class Mortton { public static ItemOnNPCHandler handleRazmireCure = new ItemOnNPCHandler(new Object[] { 7899 }, e -> { if (e.getPlayer().getVars().getVarBit(e.getNPC().getDefinitions().varpBit) == 1) { e.getPlayer().sendMessage(""He's already cured!""); return; } switch(e.getItem().getId()) { case 3408: case 3410: case 3412: case 3414: e.getItem().setId(e.getItem().getId() == 3414 ? Potions.VIAL : e.getItem().getId()+2); e.getPlayer().getVars().setVarBit(e.getNPC().getDefinitions().varpBit, 1); e.getPlayer().getInventory().refresh(); break; } }); public static NPCClickHandler handleRazmire = new NPCClickHandler(new Object[] { 7899 }, e -> { switch(e.getOption()) { case ""Talk-to"": e.getPlayer().startConversation(new Conversation(e.getPlayer()) { { if (e.getPlayer().getVars().getVarBit(e.getNPC().getDefinitions().varpBit) == 1) addNPC(e.getNPCId(), HeadE.CHEERFUL, ""Hello, there!""); else addNPC(e.getNPCId(), HeadE.DIZZY, ""Auuhghhhh...""); create(); } }); break; case ""Trade-General-Store"": ShopsHandler.openShop(e.getPlayer(), ""razmire_general""); break; case ""Trade-Builders-Store"": ShopsHandler.openShop(e.getPlayer(), ""razmire_builders""); break; } }); }" "package com.rs.game.content.world.areas.morytania; @PluginEventHandler public class Morytania { public static NPCClickHandler handleHiylikMyna = new NPCClickHandler(new Object[] { 1514 }, e -> e.getPlayer().startConversation(new Conversation(e.getPlayer()) { { addNPC(e.getNPCId(), HeadE.CHEERFUL, ""Hello, what can I do for you?""); addOptions(""What would you like to say?"", new Options() { @Override public void create() { option(""About the Achievement System..."", () -> new AchievementSystemD(player, e.getNPCId(), SetReward.MORYTANIA_LEGS)); } }); } })); public static NPCClickHandler handleRobin = new NPCClickHandler(new Object[] { 1694 }, e -> e.getPlayer().startConversation(new Conversation(e.getPlayer()) { { addNPC(e.getNPCId(), HeadE.CHEERFUL, ""Hello, what can I do for you?""); addOptions(""What would you like to say?"", new Options() { @Override public void create() { option(""About the Achievement System..."", () -> new AchievementSystemD(player, e.getNPCId(), SetReward.MORYTANIA_LEGS)); } }); } })); public static NPCClickHandler handleStrangeOldManBarrows = new NPCClickHandler(new Object[] { 2024 }, e -> e.getPlayer().startConversation(new Conversation(e.getPlayer()) { { addNPC(e.getNPCId(), HeadE.CHEERFUL, ""Hello, what can I do for you?""); addOptions(""What would you like to say?"", new Options() { @Override public void create() { option(""About the Achievement System..."", () -> new AchievementSystemD(player, e.getNPCId(), SetReward.MORYTANIA_LEGS)); } }); } })); public static NPCClickHandler handleOldManRal = new NPCClickHandler(new Object[] { 4708 }, e -> e.getPlayer().startConversation(new Conversation(e.getPlayer()) { { addNPC(e.getNPCId(), HeadE.CHEERFUL, ""Hello, what can I do for you?""); addOptions(""What would you like to say?"", new Options() { @Override public void create() { option(""About the Achievement System..."", () -> new AchievementSystemD(player, e.getNPCId(), SetReward.MORYTANIA_LEGS)); } }); } })); public static ObjectClickHandler handleSlayerTowerChains = new ObjectClickHandler(new Object[] { 9319, 9320 }, e -> { if (!Agility.hasLevel(e.getPlayer(), e.getObject().getX() < 3447 ? 61 : 71)) return; e.getPlayer().useStairs(828, e.getPlayer().transform(0, 0, e.getObjectId() == 9319 ? 1 : -1), 1, 2); }); public static ObjectClickHandler handleLabEntrance = new ObjectClickHandler(new Object[] { 18049 }, e -> e.getPlayer().useStairs(-1, Tile.of(3637, 9695, 0), 1, 1)); public static ObjectClickHandler handleLabExit = new ObjectClickHandler(new Object[] { 18050 }, e -> e.getPlayer().useStairs(-1, Tile.of(3643, 3306, 0), 1, 1)); public static ObjectClickHandler handleBurghDeRottToMineFence = new ObjectClickHandler(new Object[] { 12776 }, e -> AgilityShortcuts.climbOver(e.getPlayer(), e.getPlayer().transform(e.getPlayer().getX() < e.getObject().getX() ? 1 : -1, 0, 0), 2923)); public static ObjectClickHandler handleBrokenFence = new ObjectClickHandler(new Object[] { 18411 }, e -> AgilityShortcuts.climbOver(e.getPlayer(), e.getPlayer().transform(0, e.getPlayer().getY() > e.getObject().getY() ? -1 : 1, 0))); public static ObjectClickHandler handleTempleTrapdoor = new ObjectClickHandler(new Object[] { 30572 }, e -> e.getPlayer().ladder(Tile.of(3405, 9906, 0))); public static ObjectClickHandler handleTempleTrapdoorCanifisSide = new ObjectClickHandler(new Object[] { 30574 }, e -> e.getPlayer().ladder(Tile.of(3440, 9887, 0))); public static ObjectClickHandler handleTempleLadder = new ObjectClickHandler(new Object[] { 30575 }, e -> e.getPlayer().ladder(Tile.of(3405, 3506, 0))); public static ObjectClickHandler handleSwampTrapdoorShortcut = new ObjectClickHandler(new Object[] { 5055, 5054 }, e -> e.getPlayer().ladder(e.getObjectId() == 5055 ? Tile.of(3477, 9845, 0) : Tile.of(3495, 3466, 0))); public static ObjectClickHandler handleMyrequeWall = new ObjectClickHandler(new Object[] { 5052 }, e -> Doors.handleOneWayDoor(e.getPlayer(), e.getObject(), 1)); public static ObjectClickHandler handleSwampWoodenDoors = new ObjectClickHandler(new Object[] { 30261, 30262, 30265 }, e -> e.getPlayer().useStairs(e.getObjectId() == 30265 ? Tile.of(3500, 9812, 0) : Tile.of(3510, 3448, 0))); public static ObjectClickHandler handleTreeBridgeShortcut = new ObjectClickHandler(new Object[] { 5005 }, e -> { if (e.getObject().getTile().isAt(3502, 3431)) e.getPlayer().ladder(Tile.of(3502, 3425, 0)); else e.getPlayer().ladder(Tile.of(3502, 3432, 0)); }); public static ObjectClickHandler handleSwampBoatFromMorton = new ObjectClickHandler(new Object[] { 6969 }, e -> e.getPlayer().tele(Tile.of(3500, 3380, 0))); public static ObjectClickHandler handleSwampBoatToMorton = new ObjectClickHandler(new Object[] { 6970 }, e -> e.getPlayer().tele(Tile.of(3521, 3284, 0))); public static ObjectClickHandler handleGrottoBridge = new ObjectClickHandler(new Object[] { 3522 }, e -> { int jumpTo = ((e.getObject().getY() <= 3329) ? e.getObject().getY()+2 : e.getObject().getY()-2); Tile endTile = Tile.of(e.getObject().getX(), jumpTo, e.getObject().getPlane()); e.getPlayer().lock(); e.getPlayer().setNextFaceTile(endTile); e.getPlayer().setNextAnimation(new Animation(769)); WorldTasks.schedule(new Task() { @Override public void run() { e.getPlayer().unlockNextTick(); e.getPlayer().tele(endTile); e.getPlayer().setNextAnimation(new Animation(-1)); } }, 1); }); public static ItemClickHandler handleBonesackTele = new ItemClickHandler(new Object[] { 15215 }, new String[] { ""Teleport"" }, e -> Magic.sendTeleportSpell(e.getPlayer(), 12055, 12057, 2133, 2134, 0, 0, Tile.of(3362, 3504, 0), 3, true, TeleType.ITEM, null)); private static void drakanTeleport(Player player, Item item, Tile location) { if (item.getMetaDataI(""drakanCharges"") <= 0) { player.sendMessage(""The medallion seems unresponsive. It probably needs recharging.""); return; } Magic.sendTeleportSpell(player, 8939, 8941, 1864, 1864, 0, 0, location, 2, true, TeleType.ITEM, () -> { if (player.getX() >= 3398 && player.getX() <= 3841 && player.getY() >= 3161 && player.getY() <= 3586) player.sendMessage(""Due to the short nature of your teleport, the medallion does not use a charge.""); else player.sendMessage(""Your medallion has "" + item.decMetaDataI(""drakanCharges"") + "" charges left.""); }); } public static ItemClickHandler handleDrakansMedallion = new ItemClickHandler(new Object[] { 21576 }, new String[] { ""Teleport"", ""Check-charges"" }, e -> { if (!e.getPlayer().isQuestComplete(Quest.BRANCHES_OF_DARKMEYER, ""to use the medallion."")) return; if (e.getOption().equals(""Teleport"")) { if (e.getItem().getMetaDataI(""drakanCharges"") <= 0) { e.getPlayer().sendMessage(""The medallion seems unresponsive. It probably needs recharging.""); return; } e.getPlayer().startConversation(new Conversation(e.getPlayer()) { { addOptions(""Where would you like to teleport?"", new Options() { @Override public void create() { option(""Barrows"", () -> drakanTeleport(e.getPlayer(), e.getItem(), Tile.of(3565, 3312, 0))); option(""Burgh de Rott"", () -> drakanTeleport(e.getPlayer(), e.getItem(), Tile.of(3491, 3199, 0))); option(""Meiyerditch"", () -> drakanTeleport(e.getPlayer(), e.getItem(), Tile.of(3626, 9618, 0))); option(""Darkmeyer"", () -> drakanTeleport(e.getPlayer(), e.getItem(), Tile.of(3628, 3364, 00))); option(""Meiyerditch Laboratories"", () -> drakanTeleport(e.getPlayer(), e.getItem(), Tile.of(3633, 9696, 0))); } }); } }); } else e.getPlayer().sendMessage(""It looks like it has another "" + e.getItem().getMetaDataI(""drakanCharges"", 0) + "" charges left.""); }); public static ObjectClickHandler handleMedallionRecharge = new ObjectClickHandler(new Object[] { 61094 }, e -> { Item medal = e.getPlayer().getItemWithPlayer(21576); if (medal == null) { e.getPlayer().sendMessage(""You don't have a medallion with you.""); return; } medal.addMetaData(""drakanCharges"", 10); e.getPlayer().sendMessage(""You dip the medallion into the blood. Eww. It feels heartily recharged, though.""); }); public static ObjectClickHandler handleDrakanMedallionCave = new ObjectClickHandler(new Object[] { 61091, 59921 }, e -> { if (!e.getPlayer().isQuestComplete(Quest.BRANCHES_OF_DARKMEYER, ""to enter the cave."")) return; e.getPlayer().fadeScreen(() -> e.getPlayer().tele(e.getObjectId() == 59921 ? Tile.of(2273, 5152, 0) : Tile.of(3498, 3204, 0))); }); public static ObjectClickHandler handleClaimDrakanMedallion = new ObjectClickHandler(new Object[] { 61092 }, e -> { if (!e.getPlayer().isQuestComplete(Quest.BRANCHES_OF_DARKMEYER, ""to search this."")) return; if (e.getPlayer().containsItem(21576)) { e.getPlayer().sendMessage(""You have already retrieved the medallion from here.""); return; } e.getPlayer().sendOptionDialogue(""Are you sure you want to inspect the coffin?"", ops -> { ops.add(""Yes."", () -> { e.getPlayer().setNextAnimation(new Animation(14745)); e.getPlayer().lock(); e.getPlayer().applyHit(new Hit(null, 10, HitLook.TRUE_DAMAGE), 0, () -> { e.getPlayer().getInventory().addItem(new Item(21576, 1).addMetaData(""drakanCharges"", 10)); e.getObject().setIdTemporary(61093, 20); e.getPlayer().unlock(); }); }); ops.add(""No, I'm scared!"", new Dialogue().addPlayer(HeadE.SAD_MILD_LOOK_DOWN, ""Veliaf did ask me to search everywhere."")); }); }); //Fenkenstraincastle public static ObjectClickHandler handleFenkenstraincastlestairs = new ObjectClickHandler(new Object[] { 5206, 5207 }, e -> { if (e.getObjectId() == 5206) e.getPlayer().tele(e.getPlayer().transform(e.getObject().getRotation() == 0 ? -0 : e.getObject().getRotation() == 1 ? -0 : 0, e.getObject().getRotation() == 0 ? 4 : e.getObject().getRotation() == 1 ? -0 : 0, 1)); else if (e.getObjectId() == 5207) e.getPlayer().tele(e.getPlayer().transform(e.getObject().getRotation() == 0 ? 0 : e.getObject().getRotation() == 1 ? -0 : 0, e.getObject().getRotation() == 0 ? -4 : e.getObject().getRotation() == 1 ? -0 : 0, -1)); }); public static ObjectClickHandler experimentcavegraveentrance = new ObjectClickHandler(new Object[] { 5167 }, e -> e.getPlayer().useLadder(e.getPlayer().transform(0, 6400))); //TakenTemple public static ObjectClickHandler handleTemplespiralstairsup = new ObjectClickHandler(new Object[] { 30722 }, e -> e.getPlayer().tele(Tile.of(3415, 3485, 1))); public static ObjectClickHandler handleTemplespiralstairsdown = new ObjectClickHandler(new Object[] { 30723 }, e -> e.getPlayer().tele(Tile.of(3414, 3486, 0))); public static ObjectClickHandler handleTemplespiralstairsup2 = new ObjectClickHandler(new Object[] { 30724 }, e -> e.getPlayer().tele(Tile.of(3415, 3492, 1))); public static ObjectClickHandler handleTemplespiralstairsdown2 = new ObjectClickHandler(new Object[] { 30725 }, e -> e.getPlayer().tele(Tile.of(3414, 3491, 0))); }" "package com.rs.game.content.world.areas.morytania.npcs const val DREZEL = 1049 @ServerStartupEvent fun mapDrezel() { onNpcClick(DREZEL, options = arrayOf(""Talk-to"")) { e -> e.player.apply { sendOptionDialogue { it.add(""Talk about Priest in Peril"") { startConversation(DrezelMausoleumD(this)) } drezelNatureSpiritOptions(this, e.npc, it) } } } }" "package com.rs.game.content.world.areas.nardah; @PluginEventHandler public class Nardah { //Handle random nardah plugins }" "package com.rs.game.content.world.areas.nardah.npcs; @PluginEventHandler public class Artimeus extends Conversation { public static NPCClickHandler handleArtimeus = new NPCClickHandler(new Object[] { 5109 }, e -> { switch(e.getOption()) { case ""Talk-to"" -> e.getPlayer().startConversation(new Artimeus(e.getPlayer(), e.getNPC())); } }); public Artimeus(Player player, NPC npc) { super(player); addNPC(npc.getId(), HeadE.CHEERFUL, ""Greetings, friend. My business here deals with Hunter- related items. Is there anything in which I can interest you?""); addOptions(this, ""baseOptions"", ops -> { ops.add(""What kinds of items do you stock?"") .addPlayer(HeadE.CONFUSED, ""What kinds of items do you stock?"") .addNPC(npc.getId(), HeadE.CALM_TALK, ""Take a look for yourself."") .addGotoStage(""baseOptions"", this); ops.add(""I'm not in the market for Hunter equipment right now, thanks."") .addPlayer(HeadE.CALM_TALK, ""I'm not in the market for Hunter equipment right now, thanks."") .addNPC(npc.getId(), HeadE.CALM_TALK, ""Maybe another time, then."") .addGotoStage(""baseOptions"", this); ops.add(""Do you have any Hunter wisdom to share?"") .addPlayer(HeadE.CONFUSED, ""Do you have any Hunter wisdom to share?"") .addNPC(npc.getId(), HeadE.CALM_TALK, ""Some creatures can be particularly fond of certain food. If you bait your trap you are more likely to succeed."") .addPlayer(HeadE.CONFUSED, ""So I need to use bait?"") .addNPC(npc.getId(), HeadE.CALM_TALK, ""Sometimes it's essential. Creatures in Isafdar, for example, won't go near a trap that isn't baited. They are clever animals but quite greedy, it seems."") .addOptions(ops2 -> { ops2.add(""Can you tell me more about hunting in Isafdar?"") .addPlayer(HeadE.CONFUSED, ""Can you tell me more about hunting in Isafdar?"") .addNPC(npc.getId(), HeadE.CALM_TALK, ""There are two animals ideal for hunting there: the pawya and the grenwall. Grenwall hunt for pawya, so pawya meat is a good bait to catch them."") .addPlayer(HeadE.CONFUSED, ""And what about catching pawya?"") .addNPC(npc.getId(), HeadE.CALM_TALK, ""From the Hunter tales I've heard around campfires, they seem to find papaya fruit irresistable."") .addGotoStage(""baseOptions"", this); ops2.add(""Thanks for your help."") .addPlayer(HeadE.CONFUSED, ""Thanks for your help."") .addNPC(npc.getId(), HeadE.CALM_TALK, ""It's always a pleasure to share Hunter knowledge."") .addNPC(npc.getId(), HeadE.CALM_TALK, ""Is there anything else in which I can interest you?"") .addGotoStage(""baseOptions"", this); }); }); } }" "package com.rs.game.content.world.areas.neitiznot; @PluginEventHandler public class Neitiznot { static class MawnisBurowgarD extends Conversation { private static final int MAWNIS = 5503; public MawnisBurowgarD(Player player) { super(player); addNPC(MAWNIS, HeadE.HAPPY_TALKING, ""It makes me proud to know that the helm of my ancestors will be worn in battle.""); addNPC(MAWNIS, HeadE.HAPPY_TALKING, ""I thank you on behalf of all my kinsmen Dallim Far-strider.""); addPlayer(HeadE.WORRIED, ""Ah yes, about that beautiful helmet.""); addNPC(MAWNIS, HeadE.CONFUSED, ""You mean the priceless heirloom that I gave to you as a sign of my trust and gratitude?""); addPlayer(HeadE.WORRIED, ""Err yes, that one. I may have mislaid it.""); addNPC(MAWNIS, HeadE.CONFUSED, ""It's a good job I have alert and loyal men who notice when something like this is left lying around and picks it up.""); addNPC(MAWNIS, HeadE.CONFUSED, ""I'm afraid I'm going to have to charge you a 50,000GP handling cost.""); Dialogue op = addOption(""Pay 50,000GP to recover your helmet?"", ""Yes, that would be fine."", ""No, that's too much.""); if (player.getInventory().hasCoins(50000)) op.addNPC(MAWNIS, HeadE.HAPPY_TALKING, ""Please be more careful with it in the future."", () -> { if (player.getInventory().hasCoins(50000)) { player.getInventory().removeCoins(50000); player.getInventory().addItem(10828, 1, true); } }); else op.addNPC(MAWNIS, HeadE.HAPPY_TALKING, ""You don't have enough gold right now.""); op.addNPC(MAWNIS, HeadE.HAPPY_TALKING, ""Okay. Come back later if you change your mind.""); create(); } } public static ObjectClickHandler handleLadders = new ObjectClickHandler(new Object[] { 21512, 21513, 21514, 21515 }, e -> { if (e.getObjectId() == 21512 || e.getObjectId() == 21513) e.getPlayer().useLadder(e.getObjectId() == 21512 ? e.getPlayer().transform(2, 0, 2) : e.getPlayer().transform(-2, 0, -2)); else if (e.getObjectId() == 21514 || e.getObjectId() == 21515) e.getPlayer().useLadder(e.getObjectId() == 21514 ? e.getPlayer().transform(-2, 0, 1) : e.getPlayer().transform(2, 0, -1)); }); public static NPCClickHandler handleMawnis = new NPCClickHandler(new Object[] { 5503 }, e -> e.getPlayer().startConversation(new MawnisBurowgarD(e.getPlayer()))); public static NPCClickHandler handleShops = new NPCClickHandler(new Object[] { 5509, 5487, 5484, 5486, 5485, 5483, 5495 }, e -> { switch(e.getNPC().getId()) { case 5509: ShopsHandler.openShop(e.getPlayer(), ""neitiznot_supplies""); break; case 5487: ShopsHandler.openShop(e.getPlayer(), ""keepa_kettilons_store""); break; case 5484: ShopsHandler.openShop(e.getPlayer(), ""flosis_fishmongers""); break; case 5486: ShopsHandler.openShop(e.getPlayer(), ""weapons_galore""); break; case 5485: ShopsHandler.openShop(e.getPlayer(), ""armour_shop""); break; case 5483: ShopsHandler.openShop(e.getPlayer(), ""ore_store""); break; case 5495: ShopsHandler.openShop(e.getPlayer(), ""contraband_yak_produce""); break; } }); public static NPCClickHandler handleCureHide = new NPCClickHandler(new Object[] { 5506 }, e -> e.getPlayer().sendOptionDialogue(""What can I help you with?"", ops -> { ops.add(""Cure my yak-hide, please."", () -> { if (e.getPlayer().getInventory().containsItem(10818, 1)) { int number = e.getPlayer().getInventory().getAmountOf(10818); e.getPlayer().getInventory().deleteItem(10818, number); e.getPlayer().getInventory().addItem(10820, number); } }); ops.add(""Nothing, thanks.""); })); public static NPCClickHandler handleNeitzTravel = new NPCClickHandler(new Object[] { 5507, 5508 }, e -> e.getPlayer().tele(e.getNPC().getId() == 5507 ? Tile.of(2644, 3709, 0) : Tile.of(2310, 3781, 0))); public static NPCClickHandler handleJatizoTravel = new NPCClickHandler(new Object[] { 5482, 5481 }, e -> e.getPlayer().tele(e.getNPC().getId() == 5482 ? Tile.of(2644, 3709, 0) : Tile.of(2420, 3781, 0))); public static NPCClickHandler handleMagnusBanker = new NPCClickHandler(new Object[] { 5488 }, e -> e.getPlayer().getBank().open()); }" "package com.rs.game.content.world.areas.oo_glog; @PluginEventHandler public class AcheyTree { public static ObjectClickHandler tree = new ObjectClickHandler(new Object[] { 29089, 29088 }, e -> { if (e.getOption().equalsIgnoreCase(""Chop"")) { e.getPlayer().startConversation(new Dialogue() .addNPC(7055, HeadE.CHILD_ANGRY, ""Hey! You no cut down those treesies! Me needs dem for de spit!"")); } }); }" "package com.rs.game.content.world.areas.oo_glog; @PluginEventHandler public class RobustGlassMachine { public static final int RutmirArnholdID = 15044; public static ObjectClickHandler RobustGlassMachine = new ObjectClickHandler(new Object[] { 2331 }, e -> { if (e.getOption().equalsIgnoreCase(""Fill"")) { if (e.getPlayer().isQuestComplete(Quest.AS_A_FIRST_RESORT)) afterAsAFirstResort(e.getPlayer()); else beforeAsAFirstResort(e.getPlayer()); } }); public static void afterAsAFirstResort(Player player){ int amount = player.getInventory().getNumberOf(23194); if (amount > 0) { player.getInventory().deleteItem(23194, amount); player.getInventory().addItem(23193, amount); player.sendMessage(""You magically turn the sandstone into glass without moving since Trent can't find the object and player animations!""); } else player.sendMessage(""You do not have any sandstone to turn into glass!""); } public static void beforeAsAFirstResort(Player player) { player.startConversation(new Dialogue() .addNPC(RutmirArnholdID, HeadE.SHAKING_HEAD, ""Do you always use other people's things without asking?."") .addPlayer(HeadE.CALM_TALK, ""Uh, sorry."") .addNPC(RutmirArnholdID, HeadE.SHAKING_HEAD, ""I'm ever so busy at the moment trying to get this machine working."") .addPlayer(HeadE.CALM_TALK, ""Uh, sure."") ); } }" "package com.rs.game.content.world.areas.oo_glog; @PluginEventHandler public class Spa { public static ObjectClickHandler Mud = new ObjectClickHandler(new Object[] { 29004 }, e -> { if(!e.getPlayer().isQuestComplete(Quest.AS_A_FIRST_RESORT, ""to use the spa."")) return; jumpIn(e.getObject(),e.getPlayer()); e.getPlayer().getTasks().schedule(4, () -> { if (e.getPlayer().getTile().withinArea(2592, 2859, 2600, 2862)) { e.getPlayer().sendMessage(""You jump into the pit of thick, squelching mud.""); e.getPlayer().getSkills().adjustStat(0, 0.1, Constants.HUNTER); e.getPlayer().sendMessage(""After a bath in such luxuriant mud, you feel your Hunter skills are extra keen.""); } }); }); public static ObjectClickHandler Thermal = new ObjectClickHandler(new Object[] { 29044 }, e -> { if(!e.getPlayer().isQuestComplete(Quest.AS_A_FIRST_RESORT, ""to use the spa."")) return; jumpIn(e.getObject(),e.getPlayer()); e.getPlayer().getTasks().schedule(4, () -> { if (e.getPlayer().getTile().withinArea(2572, 2863, 2577, 2866)) { e.getPlayer().sendMessage(""You jump into the warm, relaxing thermal bath.""); e.getPlayer().addEffect(Effect.OOG_THERMAL_POOL, Ticks.fromHours(1)); e.getPlayer().sendMessage(""You feel restored and invigorated.""); } }); }); public static ObjectClickHandler Spring = new ObjectClickHandler(new Object[] { 29031 }, e -> { if(!e.getPlayer().isQuestComplete(Quest.AS_A_FIRST_RESORT, ""to use the spa."")) return; jumpIn(e.getObject(),e.getPlayer()); e.getPlayer().getTasks().schedule(4, () -> { if (e.getPlayer().getTile().withinArea(2555, 2861, 2559, 2866)) { e.getPlayer().sendMessage(""You jump into the limpid, salty waters.""); e.getPlayer().addEffect(Effect.OOG_SALTWATER_POOL, Ticks.fromMinutes(Utils.random(9, 24))); e.getPlayer().sendMessage(""You feel energised and hastened after your relaxing soak.""); } }); }); public static ObjectClickHandler Sulphur = new ObjectClickHandler(new Object[] { 29018 }, e -> { if(!e.getPlayer().isQuestComplete(Quest.AS_A_FIRST_RESORT, ""to use the spa."")) return; jumpIn(e.getObject(),e.getPlayer()); e.getPlayer().getTasks().schedule(4, () -> { if (e.getPlayer().getTile().withinArea(2533, 2853, 2541, 2856)) { e.getPlayer().sendMessage(""You jump into the bubbling, sulphurous waters.""); e.getPlayer().getPrayer().restorePrayer(e.getPlayer().getSkills().getLevelForXp(Constants.PRAYER) * 10); e.getPlayer().sendMessage(""You feel serene after your rest. Your Prayer points have been restored.""); } }); }); public static ObjectClickHandler Banados = new ObjectClickHandler(new Object[] { 29057 }, e -> { if(!e.getPlayer().isQuestComplete(Quest.AS_A_FIRST_RESORT, ""to use the spa."")) return; jumpIn(e.getObject(),e.getPlayer()); e.getPlayer().getTasks().schedule(4, () -> { if (e.getPlayer().getTile().withinArea(2522, 2842, 2527, 2848)) { e.getPlayer().sendMessage(""You jump into the copper-infused waters.""); e.getPlayer().addEffect(Effect.OOG_BANDOS_POOL, Ticks.fromHours(1)); e.getPlayer().sendMessage(""You feel the favour of Bandos wash over you.""); } }); }); private static void jumpIn(GameObject object, Player player){ switch (object.getRotation()) { case 3, 1 -> AgilityShortcuts.climbOver(player, player.transform(0, player.getY() >= object.getY() ? -3 : 3, 0), 839); case 0, 2 -> AgilityShortcuts.climbOver(player, player.transform(player.getX() >= object.getX() ? -3 : 3, 0, 0), 839); } } }" "package com.rs.game.content.world.areas.oo_glog.npcs; @PluginEventHandler public class Balnea { public static NPCClickHandler Balnea = new NPCClickHandler(new Object[]{ 7047 }, new String[]{""Talk-to""}, e -> { if (e.getPlayer().isQuestComplete(Quest.AS_A_FIRST_RESORT)) afterAsAFirstResort(e.getPlayer(), e.getNPC()); else beforeAsAFirstResort(e.getPlayer(), e.getNPC()); }); private static void beforeAsAFirstResort(Player player, NPC npc) { player.startConversation(new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Hi there!"") .addNPC(npc.getId(), HeadE.SHAKING_HEAD, ""I'm ever so busy at the moment; please come back after the grand opening."") .addPlayer(HeadE.HAPPY_TALKING, ""What grand opening?"") .addNPC(npc.getId(), HeadE.FRUSTRATED, ""I'm sorry, I really can't spare the time to talk to you."") .addPlayer(HeadE.CALM_TALK, ""Uh, sure."") ); } private static void afterAsAFirstResort(Player player, NPC npc) { player.startConversation(new Dialogue() .addNPC(npc.getId(), HeadE.HAPPY_TALKING, ""Hi, "" + player.getDisplayName() + "". What can I do for you today?"") .addOptions(ops -> { ops.add(""So, how's business?"") .addPlayer(HeadE.CALM_TALK, ""So, how's business?"") .addNPC(npc.getId(), HeadE.CALM_TALK, ""Word seems to be spreading and, now that we've launched, we're beginning to drill down and strategize about long-term bench-marking and sure-fire value-adding propositions."") .addNPC(npc.getId(), HeadE.CALM_TALK, ""Would you like to be involved in some horizon scanning? We could use someone with your talent for joined-up thinking and can-do ideation as we upsize this venture to the next level."") .addPlayer(HeadE.SKEPTICAL, ""Ah, yes. Now I remember why I was never going to talk to you again.""); ops.add(""What did you say about hunting baby platypodes?"") .addPlayer(HeadE.HAPPY_TALKING, ""What did you say about hunting baby platypodes?"") .addNPC(npc.getId(), HeadE.CALM_TALK, ""If you have the skill to care for it, you can catch a baby platypus and raise it as a pet."") .addNPC(npc.getId(), HeadE.CALM_TALK, ""They need special care, so you can't have more than one at a time, and you can't catch one if you are unable to care for it."") .addNPC(npc.getId(), HeadE.CALM_TALK, ""If you do manage to catch one, try feeding it raw fish. They seem to love that."") .addPlayer(HeadE.HAPPY_TALKING, ""Thanks for the info!""); }) ); } }" "package com.rs.game.content.world.areas.oo_glog.npcs; @PluginEventHandler public class Banker { private static final int Balnea = 7047; private static final int Banker = 7050; public static NPCInteractionDistanceHandler bankerDistance = new NPCInteractionDistanceHandler(new Object[] { 7050, 7049 }, (p, n) -> 1); public static NPCClickHandler OgressBanker = new NPCClickHandler(new Object[]{ 7050, 7049 }, e -> { switch (e.getOption()) { case ""Talk-to"" -> { if (e.getPlayer().isQuestComplete(Quest.AS_A_FIRST_RESORT)) afterAsAFirstResort(e.getPlayer()); else beforeAsAFirstResort(e.getPlayer()); } case ""Collect"" -> { if (e.getPlayer().isQuestComplete(Quest.AS_A_FIRST_RESORT)) GE.openCollection(e.getPlayer()); else beforeAsAFirstResort(e.getPlayer()); } case ""Bank"" -> { if (e.getPlayer().isQuestComplete(Quest.AS_A_FIRST_RESORT)) e.getPlayer().getBank().open(); else beforeAsAFirstResort(e.getPlayer()); } } }); public static ObjectClickHandler booth = new ObjectClickHandler(new Object[] { 29085 }, e -> { switch (e.getOption()) { case ""Collect"" -> { if (e.getPlayer().isQuestComplete(Quest.AS_A_FIRST_RESORT)) GE.openCollection(e.getPlayer()); else beforeAsAFirstResort(e.getPlayer()); } case ""Bank"" -> { if (e.getPlayer().isQuestComplete(Quest.AS_A_FIRST_RESORT)) e.getPlayer().getBank().open(); else beforeAsAFirstResort(e.getPlayer()); } } }); private static void beforeAsAFirstResort(Player player) { player.startConversation(new Dialogue() .addPlayer(HeadE.CALM_TALK, ""Excuse me, can I get some service here, please?"") .addNPC(Banker, HeadE.CHILD_ANGRY_HEADSHAKE, ""GRAAAAAH! You go away, human! Me too busy with training to talk to puny thing like you."") .addNPC(Balnea, HeadE.SHAKING_HEAD, ""I do apologise, sir. We're temporarily unable to meet your banking needs."") .addNPC(Balnea, HeadE.CALM_TALK, ""We'll be open just as soon as we realise our customer experience goals and can guarantee the high standards of service that you expect from all branches of the Bank of Gielinor."") .addNPC(Banker, HeadE.CHILD_ANGRY_HEADSHAKE, ""What did you just say to me?"") .addNPC(Balnea, HeadE.ANGRY, ""We're closed until I can teach these wretched creatures some manners."") .addPlayer(HeadE.SKEPTICAL, ""Ah, right. Good luck with that."") ); } private static void afterAsAFirstResort(Player player) { player.startConversation(new Dialogue() .addNPC(Banker, HeadE.CHILD_CALM_TALK, ""Hi, human! You want to take or give your things?"") .addPlayer(HeadE.HAPPY_TALKING, ""What is this place?"") .addNPC(Banker, HeadE.CHILD_CALM_TALK, ""Dis Oo'glog bank place! We friends with Bank of RuneScape."") .addNPC(Banker, HeadE.CHILD_CALM_TALK, ""We no thumpy-thumpy customers for their stuffses."") .addPlayer(HeadE.HAPPY_TALKING, ""That's...good to hear."") ); } }" "package com.rs.game.content.world.areas.oo_glog.npcs; @PluginEventHandler public class Chargurr { public static NPCClickHandler Chargurr = new NPCClickHandler(new Object[]{ 7055 }, new String[]{ ""Talk-to"" }, e -> { if (e.getPlayer().isQuestComplete(Quest.AS_A_FIRST_RESORT)) afterAsAFirstResort(e.getPlayer(), e.getNPC()); else beforeAsAFirstResort(e.getPlayer(), e.getNPC()); }); private static void beforeAsAFirstResort(Player player, NPC npc) { player.startConversation(new Dialogue() .addNPC(npc.getId(), HeadE.CHILD_CALM_TALK, ""You scrawny, but look like you might make good dessert. You come back when fire lit and I introduce you to cooking spit."") .addPlayer(HeadE.SKEPTICAL, ""Somehow, this doesn't seem in-line with my personal development plan but, um, thanks for the offer."") ); } private static void afterAsAFirstResort(Player player, NPC npc) { player.startConversation(new Dialogue() .addNPC(npc.getId(), HeadE.CHILD_CALM_TALK, ""Now we open, you want some meat? I cook for you or you cook dem yourself! I also give shiny pretties if you have meats you no want."") .addOptions(ops -> { ops.add(""Sure, show me what you've got."") .addNext(() -> ShopsHandler.openShop(player, ""fresh_meat"") ); ops.add(""Maybe later."") .addPlayer(HeadE.SCARED, ""Maybe later.""); }) ); } }" "package com.rs.game.content.world.areas.oo_glog.npcs; @PluginEventHandler public class Dawg { private static final int chiefTess = 7051; public static NPCClickHandler Frawd = new NPCClickHandler(new Object[]{ 7104 }, new String[] { ""Talk-to"" }, e -> { if (e.getPlayer().isQuestComplete(Quest.AS_A_FIRST_RESORT)) afterAsAFirstResort(e.getPlayer(), e.getNPC()); else beforeAsAFirstResort(e.getPlayer(), e.getNPC()); }); private static void beforeAsAFirstResort(Player player, NPC npc) { player.startConversation(new Dialogue() .addNPC(npc.getId(), HeadE.CAT_DISAPPOINTED, ""Grrrr!"") .addNPC(chiefTess, HeadE.CHILD_LAUGH, ""Watch out, human; Dawg like human for breakfast."") ); } private static void afterAsAFirstResort(Player player, NPC npc) { player.startConversation(new Dialogue() .addPlayer(HeadE.SCARED, ""Hi there, um, puppy... cat... thing. Good Dawg."") .addNPC(npc.getId(), HeadE.CAT_DISAPPOINTED, ""Grrrr!"") .addNPC(chiefTess, HeadE.CHILD_LAUGH, ""Huh, huh! Me think Dawg like you now."") .addPlayer(HeadE.SCARED, ""He has a funny way of showing it!"") ); } }" "package com.rs.game.content.world.areas.oo_glog.npcs; @PluginEventHandler public class Frawd { public static NPCClickHandler Frawd = new NPCClickHandler(new Object[]{ 7048 }, e -> { switch (e.getOption()) { case ""Talk-to"" -> { if (e.getPlayer().isQuestComplete(Quest.AS_A_FIRST_RESORT)) afterAsAFirstResort(e.getPlayer(), e.getNPC()); else beforeAsAFirstResort(e.getPlayer(), e.getNPC()); } case ""Trade"" -> ShopsHandler.openShop(e.getPlayer(),""gift_shop""); } }); private static void beforeAsAFirstResort(Player player, NPC npc) { player.startConversation(new Dialogue() .addNPC(npc.getId(), HeadE.CHILD_ANGRY_HEADSHAKE, ""Go away, human. Can't you see me busy here?"") .addPlayer(HeadE.CONFUSED, ""Oh, well, excuse me! My mistake entirely!"") .addPlayer(HeadE.FRUSTRATED, ""Why would I ever think that someone standing behind a cash register might be interested in helping me?"") .addNPC(npc.getId(), HeadE.CHILD_ANGRY_HEADSHAKE, ""Go away, human. We're not open yet!"") .addPlayer(HeadE.FRUSTRATED, ""Well, excuse me!"") ); } private static void afterAsAFirstResort(Player player, NPC npc) { player.startConversation(new Dialogue() .addNPC(npc.getId(), HeadE.CHILD_CALM_TALK, ""What you want, human?"") .addOptions(ops -> { ops.add(""So what do you have for sale, then?"") .addPlayer(HeadE.CALM_TALK, ""So what do you have for sale, then?"", () -> ShopsHandler.openShop(player,""gift_shop"")); ops.add(""Never mind."") .addPlayer(HeadE.CALM_TALK, ""Never mind."") .addNPC(npc.getId(), HeadE.CHILD_ANGRY_HEADSHAKE, ""You're a bit annoying, human; you know that?"") .addPlayer(HeadE.LAUGH, ""Thanks. I try.""); }) ); } }" "package com.rs.game.content.world.areas.oo_glog.npcs; @PluginEventHandler public class GenericOgre { public static NPCClickHandler GenericOgre = new NPCClickHandler(new Object[]{ 15235, 15236, 15237, 15238, 15239, 15240, 15241, 15242, 15243, 15244 }, new String[]{""Talk-to""}, e -> { if (e.getPlayer().isQuestComplete(Quest.AS_A_FIRST_RESORT)) afterAsAFirstResort(e.getPlayer(), e.getNPC()); else beforeAsAFirstResort(e.getPlayer(), e.getNPC()); }); private static void beforeAsAFirstResort(Player player, NPC npc) { player.startConversation(new Dialogue() .addNPC(npc.getId(), HeadE.CHILD_CALM_TALK, ""Hi, human."") .addPlayer(HeadE.CALM_TALK, ""Hi, ogre."") .addPlayer(HeadE.CALM_TALK, ""How are you today, little ogre?"") .addNext(() -> randomDialogue(player, npc)) ); } private static void afterAsAFirstResort(Player player, NPC npc) { player.startConversation(new Dialogue() .addNPC(npc.getId(), HeadE.CHILD_CALM_TALK, ""Hi, human."") .addPlayer(HeadE.CALM_TALK, ""Hi, ogre."") .addOptions(ops -> { ops.add(""How are you today?"", () -> randomDialogue(player, npc)); int npcId = npc.getId(); switch (npc.getId()) { // Thuddley & Snert case 15235, 15240 -> ops.add(""Can you tell me about this copper-coloured pool?"") .addPlayer(HeadE.CONFUSED, ""Can you tell me about this copper-coloured pool?"") .addNPC(npcId, HeadE.CHILD_CALM_TALK, ""Yeah, it red!"") .addPlayer(HeadE.ROLL_EYES, ""Yes, I can see that."") .addNPC(npcId, HeadE.CHILD_THINKING, ""Then why you ask, silly human?"") .addPlayer(HeadE.CALM_TALK, ""Well, it's hard to explain. I just sense a strange energy coming from this pool. Do you know anything about it?"") .addNPC(npcId, HeadE.CHILD_CALM_TALK, ""Oh, well, it called de 'Bandos pool' round here. It s'pposed to be special-special."") .addNPC(npcId, HeadE.CHILD_CALM_TALK, ""It hard to explain to human creature like you. Maybe you need talk to auntie Seegud. She explain good about these things.""); // Tyke & Grr'bah case 15236, 15241 -> ops.add(""Can you tell me about this stinky, green spring?"") .addPlayer(HeadE.CONFUSED, ""Can you tell me about this stinky, green pool?"") .addNPC(npcId, HeadE.CHILD_CALM_TALK, ""What you mean, stinky? It smell delightful!"") .addPlayer(HeadE.ROLL_EYES, ""Um, right. Semantics aside, can you tell me anything about it?"") .addNPC(npcId, HeadE.CHILD_THINKING, ""Oh, yeah, it very nice place to have a bath. You smell pretty, and mum says it refreshes the soul."") .addPlayer(HeadE.CALM_TALK, ""What do you mean?"") .addNPC(npcId, HeadE.CHILD_CALM_TALK, ""Well, it's a bit confusing, but mum says that taking a bath here is as good as going to the altar.""); // Snarrl & Chomp case 15237, 15242 -> ops.add(""Can you tell me about this salt-water spring?"") .addPlayer(HeadE.CONFUSED, ""Can you tell me about this salt-water spring?"") .addNPC(npcId, HeadE.CHILD_CALM_TALK, ""Yeah, sure, human! The water flows fast from underground. When you bathe here, it makes you flow fast overground for a long, long time."") .addPlayer(HeadE.CONFUSED, ""Flow fast?"") .addNPC(npcId, HeadE.CHILD_THINKING, ""You know, flow on your feetsies. Fast-like. Quick, like a bunny!"") .addPlayer(HeadE.CALM_TALK, ""Are you talking about running?"") .addNPC(npcId, HeadE.CHILD_CALM_TALK, ""Yeah, run, flow - same thing. Have a bath here, it doesn't matter how heavy you are, how much you carry - you can flow for a long time!"") .addPlayer(HeadE.HAPPY_TALKING, ""Thanks, that's good to know.""); // Snarrk & Grubb case 15238, 15243 -> ops.add(""Can you tell me about this thermal bath?"") .addPlayer(HeadE.CONFUSED, ""Can you tell me about this thermal bath?"") .addNPC(npcId, HeadE.CHILD_CALM_TALK, ""Yes, it very hot!"") .addPlayer(HeadE.CONFUSED, ""Yes. Hence the word 'thermal' as a descriptor. How terribly observant of you."") .addNPC(npcId, HeadE.CHILD_THINKING, ""Heat come up from belly of de ground, make you feel lots better when you swim in it."") .addPlayer(HeadE.CALM_TALK, ""What do you mean?"") .addNPC(npcId, HeadE.CHILD_CALM_TALK, ""Oh, it simple! You feel poisoned, you feel diseased or you just take beating in battle, just take bath in de hot water and you feel all better in no time. It easy to notice effect if you just try it out - but maybe you human types not smart enough to notice things much."") .addPlayer(HeadE.HAPPY_TALKING, ""Ahem!"") .addNPC(npcId, HeadE.CHILD_CALM_TALK, ""Oo, no spread that cough to me - it sound bad! You better take a swim right now, feel better!""); // Grunther & I'rk case 15239, 15244 -> ops.add(""Can you tell me about this mud pool?"") .addPlayer(HeadE.CONFUSED, ""Can you tell me about this mud pool?"") .addNPC(npcId, HeadE.CHILD_CALM_TALK, ""Dat my favourite pool, dat is! It nice and sticky mud, very warm and comfy. It de muddiest mud around!"") .addPlayer(HeadE.CONFUSED, ""The muddiest mud?"") .addNPC(npcId, HeadE.CHILD_THINKING, ""Plus, if you lie in de mud for a while, it much easier to sneaky-sneak hunt de creatures. De mud, it cover your awful human stink!"") .addPlayer(HeadE.HAPPY_TALKING, ""Huh! I'll have to try that sometime.""); } }) ); } private static void randomDialogue(Player player, NPC npc) { int randomCase = Utils.random(1, 9); switch (randomCase) { case 1: player.startConversation(new Dialogue() .addNPC(npc.getId(), HeadE.CHILD_CALM_TALK, ""Can I have some shiny pretties, human?"") .addPlayer(HeadE.SKEPTICAL, ""What makes you think I'd give my shiny pretties to you?"") .addNPC(npc.getId(), HeadE.CHILD_CALM_TALK, ""That skinny lady at de bank say visitors bring lots of shiny pretties with them when they come visit Oo'glog."") .addNPC(npc.getId(), HeadE.CHILD_TANTRUM, ""Me want my share!"") .addPlayer(HeadE.HAPPY_TALKING, ""Ah, you see, I've given your share to that skinny lady at the bank; you'll have to ask her for it yourself."") .addPlayer(HeadE.HAPPY_TALKING, ""Make sure you ask really loudly and growl at her every time she uses a word you don't understand, okay?"") .addNPC(npc.getId(), HeadE.CHILD_HAPPY_TALK, ""Yay! Thanks human. I'm gonna get my shiny pretties, even if I have to growl all afternoon."") ); break; case 2: player.startConversation(new Dialogue() .addNPC(npc.getId(), HeadE.CHILD_CALM_TALK, ""Fine, please and thank you very much, madam sir!"") .addPlayer(HeadE.HAPPY_TALKING, ""You're very...polite."") .addNPC(npc.getId(), HeadE.CHEERFUL, ""Me know! Me practising! Balnea say I can have job in Customer Rations when I grow up if me polite enough."") .addPlayer(HeadE.CONFUSED, ""Don't you mean 'Customer Relations'?"") .addNPC(npc.getId(), HeadE.CHILD_TANTRUM, ""Blechh! Dat not sound near as tasty as 'Customer Rations'. Me not sure me want de job after all."") ); break; case 3: player.startConversation(new Dialogue() .addNPC(npc.getId(), HeadE.CHILD_CALM_TALK, ""Hey, human. What did you bring me?"") .addPlayer(HeadE.LAUGH, ""Hmm, let me think carefully about this. Oh, yes, I remember, now! Absolutely nothing."") .addNPC(npc.getId(), HeadE.CHILD_SAD, ""Aw, shucks."") ); break; case 4: player.startConversation(new Dialogue() .addNPC(npc.getId(), HeadE.CHILD_CALM_TALK, ""How does it feel to be so puny wee small, human?"") .addPlayer(HeadE.CONFUSED, ""Oh, I dunno. How does it feel to be so incredibly dense?"") .addNPC(npc.getId(), HeadE.CALM_TALK, ""Uhh...what dat s'pposed to mean?"") .addPlayer(HeadE.SKEPTICAL, ""Never mind."") ); break; case 5: player.startConversation(new Dialogue() .addNPC(npc.getId(), HeadE.CHILD_CALM_TALK, ""Me like pie!"") .addPlayer(HeadE.HAPPY_TALKING, ""Doesn't everyone?"") .addNPC(npc.getId(), HeadE.CHILD_LAUGH, ""Pie! Pie! Pie! Pie! Pie!"") .addPlayer(HeadE.CHEERFUL_EXPOSITION, ""Yes, dear, pie."") ); break; case 6: player.startConversation(new Dialogue() .addNPC(npc.getId(), HeadE.CHILD_CALM_TALK, ""Me wanna go visit Fycie 'n Bugs!"") .addPlayer(HeadE.HAPPY_TALKING, ""Yes, they're both delightful individuals."") .addNPC(npc.getId(), HeadE.CHILD_THINKING, ""Will you take me to see dem, human?"") .addPlayer(HeadE.SKEPTICAL, ""Didn't your mother ever teach you not to talk to strangers?"") ); break; case 7: player.startConversation(new Dialogue() .addNPC(npc.getId(), HeadE.CHILD_CALM_TALK, ""Me wants CHOMPY for dinner!"") .addPlayer(HeadE.LAUGH, ""Me hopes you GETS chompy for dinner!"") .addNPC(npc.getId(), HeadE.CHILD_FRUSTRATED, ""What you talk weird like dat for, human? You sound silly!"") ); break; case 8: player.startConversation(new Dialogue() .addNPC(npc.getId(), HeadE.CHILD_CALM_TALK, ""Not so very good. Me just drop me lunch in de pool."") .addPlayer(HeadE.SKEPTICAL, ""Ew...I think I can see it floating over there."") .addNPC(npc.getId(), HeadE.HAPPY_TALKING, ""Oh, thank you human! I have it as a snack next time I go for swim!"") ); break; case 9: player.startConversation(new Dialogue() .addNPC(npc.getId(), HeadE.CHILD_CALM_TALK, ""You very cute, little creature. Me want to have a human as a pet."") .addNPC(npc.getId(), HeadE.CHILD_LAUGH, ""What you doing, human? You busy? You want be my little pet human creature?"") .addPlayer(HeadE.CONFUSED, ""Uh...I think I'm busy at the moment."") .addNPC(npc.getId(), HeadE.CHILD_AWE, ""Pwetty please?"") .addPlayer(HeadE.SHAKING_HEAD, ""Look, sorry to disappoint, but this isn't going to happen."") .addNPC(npc.getId(), HeadE.CHILD_FRUSTRATED, ""Aw, you no fun, human."") ); break; } } }" "package com.rs.game.content.world.areas.oo_glog.npcs; @PluginEventHandler public class Kringk { public static NPCClickHandler Kringk = new NPCClickHandler(new Object[]{ 7102, 7099 }, new String[]{""Talk-to""}, e -> { if (e.getPlayer().isQuestComplete(Quest.AS_A_FIRST_RESORT)) afterAsAFirstResort(e.getPlayer(), e.getNPC()); else beforeAsAFirstResort(e.getPlayer(), e.getNPC()); }); public static ObjectClickHandler Grimechin = new ObjectClickHandler(new Object[]{ 29108 }, e -> { if(e.getOption().equalsIgnoreCase(""Talk-to"")) e.getPlayer().startConversation(new Dialogue() .addPlayer(HeadE.CONFUSED, ""So, how do you like what's, um, being done to your head?"") .addNPC(7063, HeadE.CHILD_ANGRY_HEADSHAKE, ""Quit talking to goblin, Player. If she moves her head, she mess up work."") .addPlayer(HeadE.SKEPTICAL, ""Oh, sorry! I would never dream of interfering in the creative process."") ); }); public static ObjectClickHandler SalonCustomer = new ObjectClickHandler(new Object[]{ 4105 }, e -> { if(e.getOption().equalsIgnoreCase(""Talk-to"")) e.getPlayer().startConversation(new Dialogue() .addPlayer(HeadE.CALM_TALK, ""Hello, there."") .addPlayer(HeadE.CALM_TALK, ""Hello?"") .addPlayer(HeadE.CALM_TALK, ""Hello."") .addPlayer(HeadE.SHAKING_HEAD, ""I don't think she can hear me under there."") ); }); private static void beforeAsAFirstResort(Player player, NPC npc) { player.startConversation(new Dialogue() .addPlayer(HeadE.CALM_TALK, ""What's going on here?"") .addNPC(7063, HeadE.CHILD_FRUSTRATED, ""Me very busy. No have time to talk to puny creature like you."") .addPlayer(HeadE.FRUSTRATED, ""Well, excuse me!"") .addNPC(7063, HeadE.CHILD_FRUSTRATED, ""No excuse for you - you in my way."") ); } private static void afterAsAFirstResort(Player player, NPC npc) { player.startConversation(new Dialogue() .addNPC(7063, HeadE.CHILD_CALM_TALK, ""I would offer haircut, but it hard to do style for puny human with puny head. Me know. You want wig intead? Me give you big-big discount!"") .addOptions(ops -> { ops.add(""Would you like to buy an ogre wig for 50 gp?"") .addPlayer(HeadE.HAPPY_TALKING, ""Yes, please."") .addNext(() -> { if (!player.getInventory().hasCoins(50)) { player.startConversation(new Dialogue() .addNPC(7063, HeadE.CHILD_CALM_TALK, ""You no have enough shiny pretties, human."")); return; } if (!player.getInventory().hasFreeSlots()) { player.startConversation(new Dialogue() .addNPC(7063, HeadE.CHILD_CALM_TALK, ""You no have enough room to hold it, human. Come back when you have space."")); } else { player.getInventory().removeCoins(50); player.getInventory().addItem(12559); player.startConversation(new Dialogue() .addNPC(7063, HeadE.CHILD_CALM_TALK, ""There you go. Nice wig for you, made from de freshest wolfsie bones."")); } }); ops.add(""No, thank you."") .addPlayer(HeadE.SCARED, ""No, thank you.""); })); } }" "package com.rs.game.content.world.areas.oo_glog.npcs; @PluginEventHandler public class Mud { public static ItemClickHandler applyMud = new ItemClickHandler(new Object[] { 12558 }, e -> { Player player = e.getPlayer(); if(e.getOption().equalsIgnoreCase(""Apply"")) { if (player.getEquipment().getHatId() != -1) { player.getInventory().replace(12558, player.getEquipment().getHatId()); player.getEquipment().setSlot(Equipment.HEAD, new Item(12558)); } else { player.getInventory().deleteItem(12558, 1); player.getEquipment().setSlot(Equipment.HEAD, new Item(12558)); } player.getEquipment().refresh(Equipment.HEAD); player.getAppearance().generateAppearanceData(); } //TODO DOESN'T RESPOND IN INV? // if(e.getOption().equalsIgnoreCase(""Remove"")) { // player.sendMessage(""The mud mask crumbles as you rub it off your face.""); // player.getEquipment().deleteSlot(Equipment.HEAD); // player.getEquipment().refresh(Equipment.HEAD); // player.getAppearance().generateAppearanceData(); // } }); }" "package com.rs.game.content.world.areas.oo_glog.npcs; @PluginEventHandler public class Muggh { public static NPCClickHandler Muggh = new NPCClickHandler(new Object[]{ 7062 }, new String[]{""Talk-to""}, e -> { if (e.getPlayer().isQuestComplete(Quest.AS_A_FIRST_RESORT)) afterAsAFirstResort(e.getPlayer(), e.getNPC()); else beforeAsAFirstResort(e.getPlayer(), e.getNPC()); }); private static void beforeAsAFirstResort(Player player, NPC npc) { player.startConversation(new Dialogue() .addNPC(npc.getId(), HeadE.CHILD_ANGRY_HEADSHAKE, ""Hey, what you doing here? We not open yet."") .addPlayer(HeadE.CONFUSED, ""Just having a nosey, really."") .addNPC(npc.getId(), HeadE.CHILD_LAUGH, ""You bring dat nose back here when we open for business. I fix you up good."") .addPlayer(HeadE.CONFUSED, ""Fix me up?"") .addNPC(npc.getId(), HeadE.CHILD_LAUGH, ""Yeah, me give you facial. Try to make your ugly face look bit nicer."") .addPlayer(HeadE.SKEPTICAL, ""Charming."") ); } private static void afterAsAFirstResort(Player player, NPC npc) { player.startConversation(new Dialogue() .addNPC(npc.getId(), HeadE.CHILD_HAPPY_TALK, ""Hey, what you doing here? You want me give you facial?"") .addOptions(options -> { options.add(""Why, sure, since you make it sound so delightful."") .addNext(()-> { if (player.getEquipment().getHatId() == 12558) { player.startConversation(new Dialogue() .addPlayer(HeadE.CHILD_ANGRY_HEADSHAKE, ""Silly human, you already gots face full of muds."")); return; } if(player.getEquipment().getId(Equipment.HEAD) != -1) { player.startConversation(new Dialogue() .addNPC(npc.getId(), HeadE.CHILD_ANGRY_HEADSHAKE, ""Take dat thing off your head, human, else you no get facial."")); } else { Equipment.sendWear(player, Equipment.HEAD, 12558); player.sendMessage(""Muggh smacks a fistful of mud on your face.""); //TODO npc.anim(); World.sendProjectile(npc, player, 1462, 30, 30, 45, 30, 15, 0); player.delayLock(2, () -> { player.getEquipment().setSlot(Equipment.HEAD, new Item(12558)); player.getEquipment().refresh(Equipment.HEAD); player.getAppearance().generateAppearanceData(); }); } }); options.add(""Um, maybe later."") .addPlayer(HeadE.SKEPTICAL, ""Um, maybe later.""); }) ); } }" "package com.rs.game.content.world.areas.oo_glog.npcs; @PluginEventHandler public class RutmirArnhold { public static final int RutmirArnholdID = 15044; public static NPCClickHandler RutmirArnhold = new NPCClickHandler(new Object[]{ 15044 }, new String[]{""Talk-to""}, e -> { if (e.getPlayer().isQuestComplete(Quest.AS_A_FIRST_RESORT)) afterAsAFirstResort(e.getPlayer()); else beforeAsAFirstResort(e.getPlayer()); }); public static void beforeAsAFirstResort(Player player) { player.startConversation(new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Hi there!"") .addNPC(RutmirArnholdID, HeadE.SHAKING_HEAD, ""I'm ever so busy at the moment trying to get this machine working."") .addPlayer(HeadE.CALM_TALK, ""Uh, sure."") ); } private static void afterAsAFirstResort(Player player) { player.startConversation(new Dialogue() .addNPC(RutmirArnholdID, HeadE.HAPPY_TALKING, ""What are you after, human? I'm busy making robust glass from red sandstone."") .addOptions(ops -> { ops.add(""What brings you to Oo'glog?"") .addPlayer(HeadE.CALM_TALK, ""What brings you to Oo'glog?"") .addNPC(RutmirArnholdID, HeadE.CALM_TALK, ""There is red sandstone in this area, of the finest quality in all the land."") .addNPC(RutmirArnholdID, HeadE.CALM_TALK, ""At first, it didn't seem safe to venture into a town full of ogresses, but it came to my attention that Oo'glog had become a holiday resort."") .addNPC(RutmirArnholdID, HeadE.CALM_TALK, ""So now I've come to see what I can find.""); ops.add(""What do you want with red sandstone?"") .addPlayer(HeadE.CALM_TALK, ""What do you want with red sandstone?"") .addNPC(RutmirArnholdID, HeadE.CALM_TALK, ""This special machine I've made will combine red sandstone with special, secret ingredients to produce robust glass.""); ops.add(""Where can I find red sandstone?"") .addPlayer(HeadE.CALM_TALK, ""Where can I find red sandstone?"") .addNPC(RutmirArnholdID, HeadE.CALM_TALK, ""The very walls of this town are made from the stuff."") .addNPC(RutmirArnholdID, HeadE.CALM_TALK,""The ogresses don't like me chipping away at their walls, but there is a large separate piece near the outside of the north wall."") .addNPC(RutmirArnholdID, HeadE.CALM_TALK, ""Big piece of rock that it is, you should be able to mine about fifty pieces of red sandstone a day from it."") .addPlayer(HeadE.CALM_TALK, ""Well, I'll leave you to it then.""); ops.add(""What is that machine?"") .addPlayer(HeadE.CALM_TALK, ""What is that machine?"") .addNPC(RutmirArnholdID, HeadE.CALM_TALK, ""This special machine I've made will combine red sandstone with special, secret ingredients to produce robust glass.""); ops.add(""Nothing, sorry to bother you."") .addPlayer(HeadE.CALM_TALK, ""Nothing, sorry to bother you."") .addNPC(RutmirArnholdID, HeadE.HAPPY_TALKING, ""Okay bye.""); }) ); } }" "package com.rs.game.content.world.areas.oo_glog.npcs; @PluginEventHandler public class Seegud { public static NPCClickHandler Seegud = new NPCClickHandler(new Object[]{ 7052 }, new String[]{""Talk-to""}, e -> { if (e.getPlayer().isQuestComplete(Quest.AS_A_FIRST_RESORT)) afterAsAFirstResort(e.getPlayer(), e.getNPC()); else beforeAsAFirstResort(e.getPlayer(), e.getNPC()); }); private static void beforeAsAFirstResort(Player player, NPC npc) { player.startConversation(new Dialogue() .addPlayer(HeadE.CALM_TALK, ""Hello, there! Nice day, isn't it?"") .addNPC(npc.getId(), HeadE.CHILD_FRUSTRATED, ""Hmph, it an okay day. Not so sure is nice day. Bit sticky, bit hot. Makes my bones itch."") .addPlayer(HeadE.HAPPY_TALKING, ""Makes your bones...itch? How does that work?"") .addNPC(npc.getId(), HeadE.CHILD_FRUSTRATED, ""When you get old, you understand."") ); } private static void afterAsAFirstResort(Player player, NPC npc) { player.startConversation(new Dialogue() .addNPC(npc.getId(), HeadE.CHILD_CALM_TALK, ""Thank you much, human. You may be scrawny, but you not bad thinker."") .addOptions(ops -> { ops.add(""Thanks!"") .addPlayer(HeadE.HAPPY_TALKING, ""Thanks!""); ops.add(""Can you tell me about these pools?"") .addPlayer(HeadE.HAPPY_TALKING, ""Can you tell me about these pools?"") .addNext(() -> player.startConversation(new Dialogue() .addOptions(poolOps -> { poolOps.add(""Bandos pool"") .addPlayer(HeadE.HAPPY_TALKING, ""Can you tell me about the red Bandos pool, please?"") .addNPC(npc.getId(), HeadE.CHILD_CALM_TALK, ""Oh, dat de most mysterious of all pools here - it infused with energy of Bandos."") .addNPC(npc.getId(), HeadE.CHILD_CALM_TALK, ""Anyone who takes bath in dat pool can be recognised as one of Bandos' own."") .addNPC(npc.getId(), HeadE.CHILD_CALM_TALK, ""No follower of Bandos will raise hand against you when you purified with dat water.""); poolOps.add(""Salt-water spring"") .addPlayer(HeadE.HAPPY_TALKING, ""Can you tell me about the salt-water spring, please?"") .addNPC(npc.getId(), HeadE.CHILD_CALM_TALK, ""Dat pool very interesting - is fed by source under surface of water"") .addNPC(npc.getId(), HeadE.CHILD_CALM_TALK, ""You feel it moving fast when you bathe there. We take swim in that pool if we know we have a long way to run."") .addNPC(npc.getId(), HeadE.CHILD_CALM_TALK, ""Always seems like one not get so tired quickly after a bath in fast waters.""); poolOps.add(""Mud bath"") .addPlayer(HeadE.HAPPY_TALKING, ""Can you tell me about the mud pool, please?"") .addNPC(npc.getId(), HeadE.CHILD_CALM_TALK, ""Dat a very useful pool for young creatures who like to hunt."") .addNPC(npc.getId(), HeadE.CHILD_CALM_TALK, ""Mud very good at disguising smells."") .addNPC(npc.getId(), HeadE.CHILD_CALM_TALK, ""You take a swim in de mud, you find de little creatures nearly jump into your traps.""); poolOps.add(""Sulphur spring"") .addPlayer(HeadE.HAPPY_TALKING, ""Can you tell me about the sulphur spring, please?"") .addNPC(npc.getId(), HeadE.CHILD_CALM_TALK, ""Hmm, yes, dat an interesting pool, human."") .addNPC(npc.getId(), HeadE.CHILD_CALM_TALK, ""Mostly used by ogre shamans and mystics like me, though some like to bathe in it because it smells so nice."") .addPlayer(HeadE.SCARED, ""It smells like horrible rotten eggs that have been marinated in swamp gas!"") .addNPC(npc.getId(), HeadE.CHILD_CALM_TALK, ""Yes, very lovely smell - and lasts a long time!"") .addPlayer(HeadE.SKEPTICAL, ""Uh, right.""); poolOps.add(""Thermal bath"") .addPlayer(HeadE.HAPPY_TALKING, ""Can you tell me about the thermal bath, please?"") .addNPC(npc.getId(), HeadE.CHILD_CALM_TALK, ""Ah, dat pool very pure and it runs deep - you can tell by de turquoise colour."") .addNPC(npc.getId(), HeadE.CHILD_CALM_TALK, ""You relax in dat pool for a while, you feel much better."") .addNPC(npc.getId(), HeadE.CHILD_CALM_TALK,""Ogres use dat pool for many, many years to cure all sorts of ailments."") .addNPC(npc.getId(), HeadE.CHILD_CALM_TALK, ""If you poisoned, if you diseased, if you hurt, you just take a swim - you feel better than ever, me promise!""); }))); ops.add(""No, thanks."") .addPlayer(HeadE.SHAKING_HEAD, ""No, thanks.""); })); } }" "package com.rs.game.content.world.areas.oo_glog.npcs; @PluginEventHandler public class Snurgh { public static NPCClickHandler Snurgh = new NPCClickHandler(new Object[]{ 7057 }, new String[]{""Talk-to""}, e -> { if (e.getPlayer().isQuestComplete(Quest.AS_A_FIRST_RESORT)) afterAsAFirstResort(e.getPlayer(), e.getNPC()); else beforeAsAFirstResort(e.getPlayer(), e.getNPC()); }); private static void beforeAsAFirstResort(Player player, NPC npc) { player.startConversation(new Dialogue() .addNPC(npc.getId(), HeadE.CHILD_ANGRY_HEADSHAKE, ""Outta de way, human. Dis place not open yet!"") .addPlayer(HeadE.SAD, ""That's not very friendly."") .addNPC(npc.getId(), HeadE.CHILD_ANGRY_HEADSHAKE, ""Me said OUTTA DE WAY! You no can sleep here!"") .addPlayer(HeadE.SKEPTICAL_HEAD_SHAKE, ""Alright, alright! Keep your hat on! I never said I wanted to."") ); } private static void afterAsAFirstResort(Player player, NPC npc) { player.startConversation(new Dialogue() .addPlayer(HeadE.CALM_TALK, ""How's business?"") .addNPC(npc.getId(), HeadE.CHILD_HAPPY_TALK, ""Is okay. De sleepers like de fluffsie pillows. Dey good for small, soft heads like yours."") .addNPC(npc.getId(), HeadE.CHILD_HAPPY_TALK, ""You big help to Snurgh. If you ever wants to try dem out, you can stay free anytime."") .addPlayer(HeadE.HAPPY_TALKING, ""Why, thank you. I'll keep that in mind."") ); } }" "package com.rs.game.content.world.areas.oo_glog.npcs; @PluginEventHandler public class Thump { //Varbit handles all post quest content, Move to quest once implemented public static LoginHandler login = new LoginHandler(e -> { if (e.getPlayer().isQuestComplete(Quest.AS_A_FIRST_RESORT)) e.getPlayer().getVars().setVarBit(4322, 1); else e.getPlayer().getVars().setVarBit(4322, 0); }); public static NPCClickHandler Thump = new NPCClickHandler(new Object[]{ 7101, 7100 }, new String[]{""Talk-to""}, e -> { if (!Quest.AS_A_FIRST_RESORT.isImplemented()) { afterAsAFirstResort(e.getPlayer(), e.getNPC()); return; } if (e.getPlayer().isQuestComplete(Quest.AS_A_FIRST_RESORT)) afterAsAFirstResort(e.getPlayer(), e.getNPC()); else beforeAsAFirstResort(e.getPlayer(), e.getNPC()); }); private static void beforeAsAFirstResort(Player player, NPC npc) { player.startConversation(new Dialogue() .addNPC(7061, HeadE.CHILD_HAPPY_TALK, ""C'mere, human. Me need practice at dis massage thing."") .addNPC(7061, HeadE.CHILD_HAPPY_TALK, ""Me not sure how to do it without breaking spine of small, puny creatures."") .addPlayer(HeadE.SCARED, ""I...think I'll take a rain check on that."") ); } private static void afterAsAFirstResort(Player player, NPC npc) { player.startConversation(new Dialogue() .addNPC(7061, HeadE.CHILD_ANGRY_HEADSHAKE, ""RAAAAAAAGH!"") .addNext(() -> npc.forceTalk(""Send...help...!"")) ); } }" "package com.rs.game.content.world.areas.piscatoris; @PluginEventHandler public class Piscatoris { public static ObjectClickHandler handleColonyDoors = new ObjectClickHandler(new Object[] { 14929, 14931 }, e -> Doors.handleDoubleDoors.getHandler().accept(e)); public static NPCClickHandler handleArnoldPiscatorisBanker = new NPCClickHandler(new Object[] { 3824 }, e -> { if (e.getOption().equalsIgnoreCase(""Talk-to"")) e.getPlayer().startConversation(new Banker(e.getPlayer(), e.getNPC())); if (e.getOption().equalsIgnoreCase(""Trade"")) ShopsHandler.openShop(e.getPlayer(), ""arnolds_eclectic_supplies""); if (e.getOption().equalsIgnoreCase(""Bank"")) e.getPlayer().getBank().open(); if (e.getOption().equalsIgnoreCase(""Collect"")) GE.openCollection(e.getPlayer()); }); public static ObjectClickHandler handlePiscSummLadders = new ObjectClickHandler(new Object[] { 28742, 28743 }, e -> { if (e.getObjectId() == 28742) e.getPlayer().useLadder(Tile.of(2333, 10015, 0)); else e.getPlayer().useLadder(Tile.of(2329, 3645, 0)); }); public static ObjectClickHandler handleColonyTunnels = new ObjectClickHandler(new Object[] { 14922 }, e -> { if (!e.getPlayer().isQuestComplete(Quest.SWAN_SONG, ""to enter the Piscatoris Fishing Colony."")) return; final boolean isNorth = e.getPlayer().getY() > 3653; final Tile tile = isNorth ? Tile.of(2344, 3650, 0) : Tile.of(2344, 3655, 0); WorldTasks.scheduleLooping(new Task() { int ticks = 0; @Override public void run() { e.getPlayer().lock(); ticks++; if (ticks == 1) { e.getPlayer().forceMove(e.getObject().getTile(), 2589, 0, 30, false, () -> e.getPlayer().setNextAnimation(new Animation(2590))); } else if (ticks == 5) e.getPlayer().setNextAnimation(new Animation(2591)); else if (ticks == 6) { e.getPlayer().tele(Tile.of(tile.getX(), tile.getY(), tile.getPlane())); e.getPlayer().unlock(); stop(); } } }, 0, 0); }); public static ObjectClickHandler handleEaglesPeakShortcut = new ObjectClickHandler(new Object[] { 19849 }, e -> { Player p = e.getPlayer(); WorldObject obj = e.getObject(); if (!Agility.hasLevel(p, 25)) { p.getPackets().sendGameMessage(""You need level 25 agility to use this shortcut.""); return; } if(obj.getTile().matches(Tile.of(2323, 3497, 0)))//above p.forceMove(Tile.of(2322, 3502, 0), 2050, 25, 60); if(obj.getTile().matches(Tile.of(2322, 3501, 0)))//below p.forceMove(Tile.of(2323, 3496, 0), 2049, 25, 60); }); }" "package com.rs.game.content.world.areas.planes; @PluginEventHandler public class EnchantedPlane { public static ObjectClickHandler handleEnchantedTree = new ObjectClickHandler(new Object[] { 16265 }, e -> { }); }" "package com.rs.game.content.world.areas.port_khazard; @PluginEventHandler public class PortKhazard { public static NPCClickHandler handleMontyClick = new NPCClickHandler(new Object[] { 463 }, e -> { Controller controller = e.getPlayer().getControllerManager().getController(); if((controller instanceof FishingTrawlerGameController) && FishingTrawler.getInstance().isTrawlerMonty(e.getNPC())) { e.getPlayer().startConversation(new MontyGameConversation(e.getPlayer())); return; } e.getPlayer().startConversation(new MontyConversation(e.getPlayer())); }); public static NPCClickHandler handleKhazardShopkeeper = new NPCClickHandler(new Object[] { 555 }, e -> { int option = e.getOpNum(); if (option == 1) e.getPlayer().startConversation(new Conversation(e.getPlayer()) {{ addNPC(e.getNPCId(), HeadE.HAPPY_TALKING, ""Can I help you at all?""); addNext(() -> ShopsHandler.openShop(e.getPlayer(), ""khazard_general_store"")); create(); }}); if (option == 3) ShopsHandler.openShop(e.getPlayer(), ""khazard_general_store""); }); }" "package com.rs.game.content.world.areas.port_phasmatys; @PluginEventHandler public class PortPhasmatys { public static NPCClickHandler handleBillTeach = new NPCClickHandler(new Object[] { 3157 }, e -> { if (!e.getPlayer().isQuestComplete(Quest.CABIN_FEVER, ""to travel to Mos' Le Harmless."")) return; e.getPlayer().sendOptionDialogue(ops -> { if (e.getPlayer().getRegionId() == 14638) ops.add(""Travel to Port Phasmatys."", () -> e.getPlayer().tele(Tile.of(3713, 3497, 1))); else ops.add(""Travel to Mos' Le Harmless."", () -> e.getPlayer().tele(Tile.of(3682, 2949, 1))); ops.add(""Nevermind.""); }); }); public static ItemClickHandler handleEctophial = new ItemClickHandler(new Object[] { 4251 }, e -> { if (!e.getPlayer().isQuestComplete(Quest.GHOSTS_AHOY, ""to use the ectophial."")) return; Ectofuntus.sendEctophialTeleport(e.getPlayer(), Tile.of(3659, 3523, 0)); }); public static NPCClickHandler handleVelorina = new NPCClickHandler(new Object[] { 1683 }, e -> e.getPlayer().startConversation(new Conversation(e.getPlayer()) { { if (e.getPlayer().getEquipment().getAmuletId() != 552) { addNPC(1683, HeadE.CALM_TALK, ""Woooowoooooo woooooo!""); addSimple(""You cannot understand a word the ghost is saying.""); } else addOptions(""What would you like to say?"", new Options() { @Override public void create() { if (!player.containsAnyItems(4251)) if (player.isQuestComplete(Quest.GHOSTS_AHOY, ""to obtain an ectophial."")) option(""Can I have another ectophial?"", new Dialogue() .addPlayer(HeadE.CONFUSED, ""Can I have an ectophial?"" + (player.getBool(""recTokkulZo"") ? "" I've lost mine."" : """")) .addNPC(1683, HeadE.CALM_TALK, ""Of course you can, you have helped us more than we could ever have hoped."") .addItem(4251, ""Velorina gives you a vial of bright green ectoplasm."", () -> { if (!player.getInventory().hasFreeSlots()) { player.sendMessage(""You don't have enough inventory space.""); return; } player.getInventory().addItem(4251); })); option(""I thought you were going to pass over to the next world."", new Dialogue() .addPlayer(HeadE.CONFUSED, ""I thought you were going to pass over to the next world."") .addNPC(1683, HeadE.CALM_TALK, ""All in good time, "" + player.getDisplayName() + "". We stand forever in your debt, and will certainly"" + ""put in a good word for you when we pass over."")); } }); create(); } })); public static ObjectClickHandler barTrapdoor = new ObjectClickHandler(new Object[] { 7433, 7434 }, e -> { switch(e.getObjectId()) { case 7433 -> e.getPlayer().useStairs(828, Tile.of(3681, 3497, 0), 1, 2); case 7434 -> e.getPlayer().useStairs(828, Tile.of(3682, 9961, 0), 1, 2); } }); }" "package com.rs.game.content.world.areas.port_phasmatys.npcs; @PluginEventHandler public class AkHaranu extends Conversation { private static final int npcId = 1687; public static NPCClickHandler AkHaranu = new NPCClickHandler(new Object[] { npcId }, e -> { switch (e.getOption()) { case ""Talk-To"" -> e.getPlayer().startConversation(new AkHaranu(e.getPlayer())); case ""Trade"" -> ShopsHandler.openShop(e.getPlayer(), ""akharanus_exotic_shop""); } }); public AkHaranu(Player player) { super(player); player.startConversation(new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""It's nice to see a human face around here."") .addNPC(npcId, HeadE.HAPPY_TALKING, ""My name is Ak-Haranu. I am trader, come from many far across sea in east."") .addPlayer(HeadE.HAPPY_TALKING, ""You come from the lands of the East?"") /* Ghosts Ahoy .addPlayer(HeadE.HAPPY_TALKING, ""You come from the lands of the East? Do you have anything that can help me translate a book that is scribed in your language?"") .addNPC(npcId, HeadE.SECRETIVE, ""Ak-Haranu may help you. A translation manual I have. Much good for reading Eastern language."") .addPlayer(HeadE.HAPPY_TALKING, ""How much do you want for it?"") .addNPC(npcId, HeadE.SECRETIVE, ""Ak-Haranu not want money for this book, as is such small thing. But there may be something you could do for Ak-Haranu."") .addNPC(npcId, HeadE.SECRETIVE, ""I am big admirer of Robin, Master Bowman. He staying in village inn."") .addPlayer(HeadE.HAPPY_TALKING, ""What would you like me to do?"") .addNPC(npcId, HeadE.SECRETIVE, ""Please get Master Bowman sign an oak longbow for me. So Ak-Haranu can show family and friends when returning home and become much admired. Then I give book in exchange."") .addPlayer(HeadE.HAPPY_TALKING, ""Ok, wait here - I'll get you your bow."") */ .addNPC(npcId, HeadE.HAPPY_TALKING, ""Yes, Would you like buy Eastern gifts?"") .addOptions(ops -> { ops.add(""I'd like to see what you have for sale."", () -> ShopsHandler.openShop(player, ""akharanus_exotic_shop"")); ops.add(""No thanks."") .addPlayer(HeadE.CONFUSED, ""No thanks.""); })); } }" "package com.rs.game.content.world.areas.port_phasmatys.npcs; @PluginEventHandler public class GhostShopkeeper { private static final int npcId = 1699; public static NPCClickHandler ghostShopkeeper = new NPCClickHandler(new Object[] { npcId }, e -> { switch (e.getOption()) { case ""Talk-to"" -> { if (e.getPlayer().getEquipment().getNeckId() != 552) { e.getPlayer().startConversation(new Dialogue().addNPC(npcId, HeadE.FRUSTRATED, ""Woooo wooo wooooo woooo"")); e.getPlayer().sendMessage(""You cannot understand the ghost.""); return; } e.getPlayer().startConversation(new Dialogue() .addNPC(npcId, HeadE.SECRETIVE, ""Would you like to buy or sell anything?"") .addOptions(ops -> { ops.add(""I'd like to see what you have for sale."", () -> ShopsHandler.openShop(e.getPlayer(), ""port_phasmatys_general_store"")); ops.add(""No thanks."") .addPlayer(HeadE.CONFUSED, ""No thanks.""); })); } case ""Trade"" -> ShopsHandler.openShop(e.getPlayer(), ""port_phasmatys_general_store""); } }); }" "package com.rs.game.content.world.areas.port_phasmatys.npcs; @PluginEventHandler public class GhostVillager extends Conversation { private static final int npcId = 1697; public static NPCClickHandler GhostVillager = new NPCClickHandler(new Object[] { npcId }, e -> { switch (e.getOption()) { case ""Talk-To"" -> e.getPlayer().startConversation(new GhostVillager(e.getPlayer())); } }); public GhostVillager(Player player) { super(player); if (player.getEquipment().getNeckId() != 552) { addNPC(npcId,HeadE.FRUSTRATED,""Woooo wooo wooooo woooo""); create(); player.sendMessage(""You cannot understand the ghost.""); return; } switch (Utils.random(1, 5)) { case 1 -> addNPC(npcId,HeadE.CALM, ""What do you want, mortal?""); case 2 -> addNPC(npcId,HeadE.CALM, ""We do not talk to the warm-bloods.""); case 3 -> addNPC(npcId,HeadE.CALM, ""Why did we have to listen to that maniacal priest?""); case 4 -> addNPC(npcId,HeadE.CALM, ""This cold wind blows right through you, doesn't it?""); case 5 -> addNPC(npcId,HeadE.CALM, ""Worship the Ectofuntus all you want, but don't bother us, human.""); } create(); } }" "package com.rs.game.content.world.areas.port_sarim; @PluginEventHandler public class PortSarim { public static PlayerStepHandler musicRustyAnchorInn = new PlayerStepHandler(new Tile[]{Tile.of(3053, 3255, 0), Tile.of(3053, 3254, 0), Tile.of(3053, 3259, 0), Tile.of(3053, 3260, 0)}, e -> { if (e.getTile().getY() == 3255 && e.getStep().dir == Direction.NORTH) { e.getPlayer().getMusicsManager().playSpecificAmbientSong(719, true); return; } if (e.getTile().getY() == 3259 && e.getStep().dir == Direction.SOUTH) { e.getPlayer().getMusicsManager().playSpecificAmbientSong(719, true); return; } if ((e.getTile().getY() == 3260 || e.getTile().getY() == 3254) && e.getPlayer().getMusicsManager().isPlaying(719)) e.getPlayer().getMusicsManager().nextAmbientSong(); }); public static ItemOnNPCHandler handleThurgoItem = new ItemOnNPCHandler(new Object[]{ 604 }, e -> { if (e.getItem().getId() == 24303 || e.getItem().getId() == 24339) e.getPlayer().sendOptionDialogue(""Would you like Thurgo to "" + (e.getItem().getId() == 24339 ? ""repair"" : ""forge"") + "" your Royal Crossbow?"", ops -> { ops.add(""Yes, please (Requires a stabilizer, frame, sight, and spring)"", () -> { if (e.getPlayer().getInventory().containsItems(new Item(24340), new Item(24342), new Item(24344), new Item(24346))) { e.getPlayer().getInventory().deleteItem(e.getItem().getId(), 1); e.getPlayer().getInventory().deleteItem(24340, 1); e.getPlayer().getInventory().deleteItem(24342, 1); e.getPlayer().getInventory().deleteItem(24344, 1); e.getPlayer().getInventory().deleteItem(24346, 1); e.getPlayer().getInventory().addItem(e.getItem().getId() == 24339 ? 24338 : 24337, 1); e.getPlayer().sendMessage(""Thurgo "" + (e.getItem().getId() == 24339 ? ""repairs"" : ""forges"") + "" your Royal crossbow.""); } }); ops.add(""No, thanks.""); }); }); public static ItemAddedToInventoryHandler handlePortSarimApron = new ItemAddedToInventoryHandler(new Object[]{ 7957 }, e -> e.getItem().setId(1005)); public static NPCClickHandler Thurgo = new NPCClickHandler(new Object[]{ 604 }, e -> e.getPlayer().startConversation(new Conversation(e.getPlayer()) { { addOptions(""What would you like to say?"", new Options() { @Override public void create() { if (player.getQuestManager().getStage(Quest.KNIGHTS_SWORD) >= KnightsSword.FIND_DWARF) option(""About Knight's Sword."", new Dialogue() .addNext(() -> e.getPlayer().startConversation(new ThurgoKnightsSwordD(e.getPlayer()).getStart()))); option(""About that skill cape..."", new Dialogue() .addNext(() -> player.startConversation(new GenericSkillcapeOwnerD(player, 604, Skillcapes.Smithing))) ); } }); create(); } })); public static NPCClickHandler GerrantFishingShop = new NPCClickHandler(new Object[]{ 558 }, e -> { if (e.getOption().equalsIgnoreCase(""Trade"")) ShopsHandler.openShop(e.getPlayer(), ""gerrants_fishy_business""); if (e.getOption().equalsIgnoreCase(""Talk-to"")) e.getPlayer().startConversation(new Conversation(e.getPlayer()) { final int NPC = e.getNPCId(); { addNPC(NPC, HeadE.CALM_TALK, ""Welcome! You can buy fishing equipment at my store. We'll also buy anything you catch off you.""); addOptions(""Choose an option:"", new Options() { @Override public void create() { if (e.getPlayer().getQuestManager().getStage(Quest.HEROES_QUEST) == HeroesQuest.GET_ITEMS && !e.getPlayer().getInventory().containsItem(1581, 1))//blamish snail slime option(""I want to find out how to catch a lava eel."", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""I want to find out how to catch a lava eel."") .addNPC(NPC, HeadE.CALM_TALK, ""Lava eels, eh? That's a tricky one, that is. You'll need a lava-proof fishing rod. The"" + "" method for making this would be to take an ordinary fishing rod, and then cover it with fire-proof blamish oil."") .addPlayer(HeadE.HAPPY_TALKING, ""Do you have one of those snail oils?"") .addNPC(NPC, HeadE.CALM_TALK, ""I do, yes..."") .addPlayer(HeadE.HAPPY_TALKING, ""..."") .addPlayer(HeadE.HAPPY_TALKING, ""Can I have one?"") .addNPC(NPC, HeadE.CALM_TALK, ""Sure!"") .addSimple(""He looks around the shop..."") .addNPC(NPC, HeadE.CALM_TALK, ""Got it!"") .addItem(1581, ""He gives you some blamish snail oil..."", () -> e.getPlayer().getInventory().addItem(1581, 1, true)) .addNPC(NPC, HeadE.CALM_TALK, ""Don't forget to add this to unfinished Harralander"") .addPlayer(HeadE.HAPPY_TALKING, ""So, where can I fish lava eels?"") .addNPC(NPC, HeadE.CALM_TALK, ""Taverley dungeon or the lava maze in the Wilderness."") ); option(""Let's see what you've got then."", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Let's see what you've got then."") .addNext(() -> ShopsHandler.openShop(e.getPlayer(), ""gerrants_fishy_business""))); option(""Sorry, I'm not interested."", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Sorry, I'm not interested."") ); } }); create(); } }); }); public static ObjectClickHandler handleEnterIceDungeon = new ObjectClickHandler(new Object[]{ 9472 }, e -> e.getPlayer().tele(Tile.of(3007, 9550, 0))); public static ObjectClickHandler handleExitIceDungeon = new ObjectClickHandler(new Object[]{ 32015 }, new Tile[]{Tile.of(3008, 9550, 0)}, e -> e.getPlayer().tele(Tile.of(3008, 3149, 0))); public static ObjectClickHandler handleEnterWyvern = new ObjectClickHandler(new Object[]{ 33173 }, e -> e.getPlayer().tele(Tile.of(3056, 9555, 0))); public static ObjectClickHandler handleExitWyvern = new ObjectClickHandler(new Object[]{ 33174 }, e -> e.getPlayer().tele(Tile.of(3056, 9562, 0))); public static ObjectClickHandler handleEnterLadyLumbridgeBoat = new ObjectClickHandler(new Object[]{ 2594, 2593 }, e -> { Player p = e.getPlayer(); GameObject obj = e.getObject(); if (p.getY() > obj.getY()) e.getPlayer().tele(Tile.of(3047, 3204, 0)); if (p.getY() < obj.getY()) e.getPlayer().tele(Tile.of(3047, 3207, 1)); }); public static ObjectClickHandler handleEnterLadyLumbridgeBoatUpperLadder = new ObjectClickHandler(new Object[]{ 2590 }, e -> e.getPlayer().useStairs(828, Tile.of(e.getObject().getX() - 1, e.getObject().getY(), e.getObject().getPlane() - 1), 1, 2)); public static ObjectClickHandler handlePrisonTrapdoor = new ObjectClickHandler(new Object[]{ 40113 }, Tile.of(3013, 3179, 2), e -> e.getPlayer().useStairs(828, Tile.of(3013, 3180, 1))); public static ObjectClickHandler handleLowerBoatLadder = new ObjectClickHandler(new Object[]{ 272 }, e -> { Player p = e.getPlayer(); GameObject obj = e.getObject(); if (obj.getRotation() == 0) p.useStairs(828, Tile.of(obj.getX(), obj.getY() - 1, obj.getPlane() + 1), 1, 2); if (obj.getRotation() == 1) p.useStairs(828, Tile.of(obj.getX() - 1, obj.getY(), obj.getPlane() + 1), 1, 2); if (obj.getRotation() == 2) p.useStairs(828, Tile.of(obj.getX(), obj.getY() + 1, obj.getPlane() + 1), 1, 2); if (obj.getRotation() == 3) p.useStairs(828, Tile.of(obj.getX() + 1, obj.getY(), obj.getPlane() + 1), 1, 2); }); public static PickupItemHandler handleAhabsBeer = new PickupItemHandler(new Object[]{ 6561 }, new Tile[]{Tile.of(3049, 3257, 0)}, e -> { e.cancelPickup(); e.getPlayer().startConversation(new Dialogue() .addNPC(2692, HeadE.ANGRY, ""Oi matey, leave my beer alone!"") .addPlayer(HeadE.SKEPTICAL, ""Sorry!"") ); }); }" "package com.rs.game.content.world.areas.port_sarim.npcs class BartenderRustyAnchor(p: Player, npc: NPC) { init { p.startConversation { player(HeadE.HAPPY_TALKING, ""Good day to you!"") npc(npc, HeadE.HAPPY_TALKING, ""Hello there!"") options { if (!isBarVisited(p, RUSTY_ANCHOR) && BarCrawl.hasCard(p) && onBarCrawl(p)) { op(""I'm doing Alfred Grimhand's Barcrawl."") { player(HeadE.HAPPY_TALKING, ""I'm doing Alfred Grimhand's Barcrawl."") npc(npc, HeadE.LAUGH, ""Are you sure? You look a bit skinny for that."") player(HeadE.FRUSTRATED, ""Just give me whatever I need to drink here."") npc(npc, HeadE.CHEERFUL, ""Okay, one ${RUSTY_ANCHOR.drinkName} coming up. ${RUSTY_ANCHOR.price} coins, please."") exec { buyBarcrawlDrink(p, RUSTY_ANCHOR) } } } op(""Could I buy a beer, please?"") { player(HeadE.HAPPY_TALKING, ""Could I buy a beer, please?"") npc(npc, HeadE.HAPPY_TALKING, ""Sure, that will be two gold coins, please."") exec { buyDrinkOrIngredients(p, npc, 2, Item(1917), false) } } op(""Have you heard any rumours here?"") { player(HeadE.HAPPY_TALKING, ""Have you heard any rumours here?"") exec { if (!p.questManager.isComplete(Quest.GOBLIN_DIPLOMACY)) { npc(npc, HeadE.CONFUSED, ""Well, there was a guy in here earlier saying the goblins up by the mountain are arguing again, about the colour of their armour of all things."") npc(npc, HeadE.WORRIED, ""Knowing the goblins it could easily turn into a full blown war, which wouldn't be good. Goblin wars make such a mess of the countryside."") player(HeadE.CALM, ""Well if I have the time I'll go and see if I can knock some sense into them."") } else { npc(npc, HeadE.SHAKING_HEAD, ""No, it hasn't been very busy lately."") } } } op(""Bye, then."") { player(HeadE.HAPPY_TALKING, ""Bye, then."") npc(npc, HeadE.CALM, ""Come back soon!"") } } } } } @ServerStartupEvent fun mapBartenderRustyAnchor() { onNpcClick(734) { (player, npc) -> BartenderRustyAnchor(player, npc) } }" "package com.rs.game.content.world.areas.port_sarim.npcs; @PluginEventHandler public class PortSarimNPC { private static final int AHAB = 2692; private static final int BARD_ROBERTS = 3509; private static final int BELLEMORDE = 2942; private static final int BETTY = 583; private static final int BRIAN = 559; private static final int DRUNKEN_SAILOR = 1207; private static final int FELKRASH = 2951; private static final int GRUM = 556; private static final int JACK_SEAGULL = 2690; private static final int LONGBOW_BEN = 2691; private static final int REDBEARD_FRANK = 375; private static final int STANKY_MORGAN = 6667; private static final int THAKI = 7115; private static final int THE_FACE = 2950; public static NPCClickHandler Ahab = new NPCClickHandler(new Object[]{ AHAB }, e -> { switch (e.getOption()) { case ""Talk-to"" -> e.getPlayer().startConversation(new Dialogue() .addNPC(AHAB, HeadE.HAPPY_TALKING, ""Arrr, matey!"") .addOptions(ops -> { ops.add(""Arrr!"") .addPlayer(HeadE.HAPPY_TALKING, ""Arrr!"") .addNPC(AHAB, HeadE.HAPPY_TALKING, ""Arrr, matey!""); ops.add(""Are you going to sit there all day?!"", new Dialogue() .addPlayer(HeadE.SKEPTICAL, ""Are you going to sit there all day?"") .addNPC(AHAB, HeadE.FRUSTRATED, ""Aye, I am. I canna walk, ye see."") .addPlayer(HeadE.SKEPTICAL, ""What's stopping you from walking?"") .addNPC(AHAB, HeadE.FRUSTRATED, ""Arrr, I 'ave only the one leg! I lost its twin when my last ship went down."") .addPlayer(HeadE.SKEPTICAL_HEAD_SHAKE, ""But I can see both your legs!"") .addNPC(AHAB, HeadE.FRUSTRATED, ""Nay, young "" + e.getPlayer().getPronoun(""laddie"", ""lassie"") + "", this be a false leg. For years I had me a sturdy wooden peg-leg, but now I wear this dainty little feller."") .addNPC(AHAB, HeadE.FRUSTRATED, ""Yon peg-leg kept getting stuck in the floorboards."") .addPlayer(HeadE.SKEPTICAL, ""Right..."") ); })); } }); public static NPCClickHandler Bellemorde = new NPCClickHandler(new Object[]{ BELLEMORDE }, e -> { switch (e.getOption()) { case ""Talk-to"" -> { if (ItemDefinitions.getDefs(e.getPlayer().getEquipment().getNeckId()).getName().contains(""Catspeak"")) { e.getPlayer().startConversation(new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, "" Hello puss."") .addNPC(BELLEMORDE, HeadE.CAT_CALM_TALK, "" Hello human."") .addPlayer(HeadE.HAPPY_TALKING, ""Would you like a fish?"") .addPlayer(HeadE.CAT_SHOUTING, "" I don't want your fish. I hunt and eat what I need by myself."")); } else { e.getPlayer().startConversation(new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, "" Hello puss."") .addNPC(BELLEMORDE, HeadE.CAT_SHOUTING, "" Hiss!"")); } } } }); public static NPCClickHandler Betty = new NPCClickHandler(new Object[]{ BETTY }, e -> { switch (e.getOption()) { case ""Trade"" -> ShopsHandler.openShop(e.getPlayer(), ""bettys_magic_emporium""); case ""Talk-to"" -> { if (Quest.HAND_IN_SAND.isImplemented() && e.getPlayer().getQuestManager().isComplete(Quest.HAND_IN_SAND)) { e.getPlayer().startConversation(new Dialogue() .addNPC(BETTY, HeadE.HAPPY_TALKING, "" Zavistic told me what a good job you did. If you want some more pink dye, I have made up a batch and you can have some for 20 gold."") .addOptions(ops -> { ops.add(""Yes, please! "") .addNext(() -> { if (!e.getPlayer().getInventory().hasFreeSlots()) e.getPlayer().startConversation(new Dialogue() .addNPC(BETTY, HeadE.SHAKING_HEAD, ""You don't have the space for any more dye."")); if (!e.getPlayer().getInventory().hasCoins(20)) e.getPlayer().startConversation(new Dialogue() .addNPC(BETTY, HeadE.SHAKING_HEAD, ""You don't have enough coins!"")); if (e.getPlayer().getInventory().hasFreeSlots() && e.getPlayer().getInventory().hasCoins(20)) { e.getPlayer().getInventory().removeCoins(20); e.getPlayer().getInventory().addItem(6955); e.getPlayer().sendMessage(""You receive some pink dye from Betty.""); } }); ops.add(""Can I see your wares?"") .addNext(() -> ShopsHandler.openShop(e.getPlayer(), ""bettys_magic_emporium"")); ops.add(""No thanks, Betty."") .addPlayer(HeadE.HAPPY_TALKING, ""No thanks, Betty. Good luck with the shop. I might be back for some dye later."") .addNPC(BETTY, HeadE.HAPPY_TALKING, ""Thanks, "" + e.getPlayer().getDisplayName() + "". See you soon.""); })); } else { e.getPlayer().startConversation(new Dialogue() .addNPC(BETTY, HeadE.HAPPY_TALKING, ""Welcome to the magic emporium."") .addOptions(ops -> { ops.add(""Can I see your wares? "") .addNext(() -> ShopsHandler.openShop(e.getPlayer(), ""bettys_magic_emporium"")); ops.add(""Sorry, I'm not into magic."") .addPlayer(HeadE.HAPPY_TALKING, ""Sorry, I'm not into magic."") .addNPC(BETTY, HeadE.HAPPY_TALKING, "" Well, if you see anyone who is into magic, please send them my way.""); })); } } } }); public static NPCClickHandler BrianBattleaxe = new NPCClickHandler(new Object[]{ BRIAN }, e -> { switch (e.getOption()) { case ""Trade"" -> ShopsHandler.openShop(e.getPlayer(), ""brians_battleaxe_bazaar""); case ""Talk-to"" -> e.getPlayer().startConversation(new Dialogue() .addNPC(BRIAN, HeadE.HAPPY_TALKING, ""Hello."") .addOptions(ops -> { ops.add(""So, are you selling something? "") .addPlayer(HeadE.CALM_TALK, ""So, are you selling something?"") .addNPC(BRIAN, HeadE.HAPPY_TALKING, ""Yep, take a look at these great axes."") .addNext(() -> ShopsHandler.openShop(e.getPlayer(), ""brians_battleaxe_bazaar"")); ops.add(""'Ello'"") .addPlayer(HeadE.HAPPY_TALKING, ""'Ello."") .addNPC(BRIAN, HeadE.HAPPY_TALKING, ""'Ello""); })); } }); public static NPCClickHandler DrunkenSailor = new NPCClickHandler(new Object[]{ DRUNKEN_SAILOR }, e -> { switch (e.getOption()) { case ""Talk-to"" -> e.getPlayer().simpleDialogue(""You shake the snoring sailor by the shoulder. It doesn't look like he's going to wake up any time soon. ""); case ""Search"" -> { if (e.getPlayer().getInventory().hasFreeSlots()) { e.getPlayer().simpleDialogue(""You find the sailor's hat in one of his pockets. You put it in your inventory. ""); e.getPlayer().getInventory().addItem(12595); } else e.getPlayer().simpleDialogue(""You don't enough space to carry that""); } } }); public static NPCClickHandler Felkrash = new NPCClickHandler(new Object[]{ FELKRASH }, e -> { switch (e.getOption()) { case ""Talk-to"" -> e.getPlayer().startConversation(new Dialogue() .addNPC(FELKRASH, HeadE.ANGRY, ""What are you doing in here? This is a private club, get out."") .addPlayer(HeadE.CONFUSED, ""What club? I don't see anything here."") .addNPC(FELKRASH, HeadE.SAD_CRYING, ""It is... It used to be my rat pits. You could bring your cats here to fight. It was going to be glorious! It was open for years. Not a single person visited! How could so many be so foolish as to ignore such brilliance?"") .addPlayer(HeadE.CONFUSED, ""I guess brillance is one word for it."") .addSimple(""Felkrash glares at you angrily, you walk away while you can"") ); } }); public static NPCClickHandler Grum = new NPCClickHandler(new Object[]{ GRUM }, e -> { switch (e.getOption()) { case ""Trade"" -> ShopsHandler.openShop(e.getPlayer(), ""grums_gold_exchange""); case ""Talk-to"" -> e.getPlayer().startConversation(new Dialogue() .addNPC(GRUM, HeadE.HAPPY_TALKING, "" Would you like to buy or sell some gold jewellery?"") .addOptions(ops -> { ops.add(""Yes, please."") .addNext(() -> ShopsHandler.openShop(e.getPlayer(), ""grums_gold_exchange"")); ops.add(""No, I'm not that rich."") .addPlayer(HeadE.SHAKING_HEAD, ""No, I'm not that rich. "") .addNPC(GRUM, HeadE.ANGRY, "" Get out, then! We don't want any riff-raff in here.""); }) ); } }); public static NPCClickHandler JackSeagull = new NPCClickHandler(new Object[]{ JACK_SEAGULL }, e -> { switch (e.getOption()) { case ""Talk-to"" -> e.getPlayer().startConversation(new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Arrr, matey!."") .addNPC(JACK_SEAGULL, HeadE.HAPPY_TALKING, ""Yo ho ho!"") .addPlayer(HeadE.HAPPY_TALKING, ""So are you pirates?"") .addNPC(LONGBOW_BEN, HeadE.HAPPY_TALKING, ""Aye "" + e.getPlayer().getPronoun(""laddie"", ""miss"") + "", that we are."") .addNPC(JACK_SEAGULL, HeadE.HAPPY_TALKING, ""Aye, that we be."") .addNPC(LONGBOW_BEN, HeadE.SHAKING_HEAD, ""Nay, always ye say it wrong! Tis 'we are', not 'we be'."") .addNPC(JACK_SEAGULL, HeadE.FRUSTRATED, ""I be a pirate, not a scurvy schoolmaster!"") .addNPC(LONGBOW_BEN, HeadE.VERY_FRUSTRATED, ""Ye be a fool, and a disgrace to piracy."") .addNPC(JACK_SEAGULL, HeadE.CONFUSED, ""Now ye be saying 'be' too!"") .addNPC(LONGBOW_BEN, HeadE.ANGRY, ""Arrr! Tis thy fault."") .addPlayer(HeadE.CONFUSED, ""I think I'll leave you two to sort it out."") ); } }); public static NPCClickHandler LongbowBen = new NPCClickHandler(new Object[]{ LONGBOW_BEN }, e -> { switch (e.getOption()) { case ""Talk-to"" -> e.getPlayer().startConversation(new Dialogue() .addNPC(LONGBOW_BEN, HeadE.HAPPY_TALKING, ""Arrr, matey!"") .addPlayer(HeadE.HAPPY_TALKING, ""Why are you called Longbow Ben?"") .addNPC(LONGBOW_BEN, HeadE.SKEPTICAL_THINKING, ""Arrr, that's a strange yarn."") .addNPC(LONGBOW_BEN, HeadE.FRUSTRATED, ""I was to be marooned, ye see. A scurvy troublemaker had taken my ship, and he put me ashore on a little island."") .addPlayer(HeadE.AMAZED, ""Gosh, how did you escape?"") .addNPC(LONGBOW_BEN, HeadE.HAPPY_TALKING, ""Arrr, ye see, he made one mistake! Before he sailed away, he gave me a bow and one arrow so that I wouldn't have to die slowly."") .addNPC(LONGBOW_BEN, HeadE.LAUGH, ""So I shot him and took my ship back."") .addNPC(LONGBOW_BEN, HeadE.CONFUSED, ""Right..."") ); } }); public static NPCClickHandler RedBeardFrank = new NPCClickHandler(new Object[]{ REDBEARD_FRANK }, e -> { switch (e.getOption()) { case ""Talk-to"" -> e.getPlayer().startConversation(new Dialogue() .addNPC(REDBEARD_FRANK, HeadE.CHEERFUL, ""Arr, Matey!"") .addOptions(ops -> { if (!e.getPlayer().isQuestComplete(Quest.PIRATES_TREASURE)) ops.add(""About Pirate's Treasure"", new Dialogue() .addNext(() -> e.getPlayer().startConversation(new RedbeardFrankPiratesTreasureD(e.getPlayer())))); ops.add(""About the Achievement System..."", () -> new AchievementSystemD(e.getPlayer(), REDBEARD_FRANK, SetReward.FALADOR_SHIELD)); })); } }); public static NPCClickHandler StankyMorgan = new NPCClickHandler(new Object[]{ STANKY_MORGAN }, e -> { switch (e.getOption()) { case ""Talk-to"" -> e.getPlayer().startConversation(new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Good day."") .addNPC(STANKY_MORGAN, HeadE.FRUSTRATED, ""Is it, indeed."") .addPlayer(HeadE.CONFUSED, ""Erm..."") .addNPC(STANKY_MORGAN, HeadE.FRUSTRATED, "" What's so good about it?"") .addPlayer(HeadE.CONFUSED, ""Uh..."") .addNPC(BARD_ROBERTS, HeadE.FRUSTRATED, "" Over here, lass."") ); } }); public static NPCClickHandler Thaki = new NPCClickHandler(new Object[]{ THAKI }, e -> { switch (e.getOption()) { case ""Talk-to"" -> { e.getNPC().forceTalk(""HIC!""); e.getPlayer().sendMessage(""The dwarf hiccups, then burps a foul cloud of stench that turns your stomach. You feel it best to leave before something worse happens.""); } } }); public static NPCClickHandler TheFace = new NPCClickHandler(new Object[]{ THE_FACE }, e -> { switch (e.getOption()) { case ""Talk-to"" -> { e.getPlayer().startConversation(new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Hello"")); e.getPlayer().sendMessage(""She looks through as if you don't exist.""); } } }); }" "package com.rs.game.content.world.areas.rellekka; @PluginEventHandler public class Rellekka { public static NPCClickHandler handleCouncilWorkman = new NPCClickHandler(new Object[] { 1287 }, e -> e.getPlayer().startConversation(new Conversation(e.getPlayer()) { { addNPC(e.getNPCId(), HeadE.CHEERFUL, ""Hello, what can I do for you?""); addOptions(""What would you like to say?"", new Options() { @Override public void create() { option(""About the Achievement System..."", () -> new AchievementSystemD(player, e.getNPCId(), SetReward.FREMENNIK_BOOTS)); } }); } })); public static NPCClickHandler handleYrsa = new NPCClickHandler(new Object[] { 1301 }, e -> { switch(e.getOpNum()) { case 1: e.getPlayer().startConversation(new Conversation(e.getPlayer()) { { addNPC(e.getNPCId(), HeadE.CHEERFUL, ""Welcome to my clothes shop. I can change your shoes, or I've got a fine selection of clothes for sale.""); addOptions(""What would you like to say?"", new Options() { @Override public void create() { option(""I'd like to buy some clothes."", () -> ShopsHandler.openShop(player, ""yrsas_accoutrements"")); option(""I'd like to change my shoes."", () -> PlayerLook.openYrsaShop(player)); option(""About the Achievement System..."", () -> new AchievementSystemD(player, e.getNPCId(), SetReward.FREMENNIK_BOOTS)); } }); } }); break; case 3: ShopsHandler.openShop(e.getPlayer(), ""yrsas_accoutrements""); break; case 4: PlayerLook.openYrsaShop(e.getPlayer()); break; } }); public static ItemOnItemHandler handleStringLyre = new ItemOnItemHandler(3694, 3688, e -> { if (e.getPlayer().getSkills().getLevel(Constants.FLETCHING) < 25) { e.getPlayer().sendMessage(""You need a Fletching level of 25 to string the lyre.""); return; } Item branch = e.getUsedWith(3694); if (branch != null) { e.getPlayer().getInventory().deleteItem(3694, 1); branch.setId(3689); e.getPlayer().getInventory().refresh(branch.getSlot()); } }); public static ItemOnItemHandler handleCutLyre = new ItemOnItemHandler(946, new int[] { 3692 }, e -> { Item branch = e.getUsedWith(946); if (branch != null) { branch.setId(3688); e.getPlayer().getInventory().refresh(branch.getSlot()); e.getPlayer().anim(6702); } }); public static void rechargeLyre(Player player) { if (!player.isQuestComplete(Quest.FREMENNIK_TRIALS, ""to charge a lyre."")) return; if (!player.getInventory().containsItem(383, 1)) { player.sendMessage(""The Fossegrimen is unresponsive.""); return; } Item lyre = player.getItemWithPlayer(3689); if (lyre != null) { player.getInventory().deleteItem(383, 1); lyre.setId(3690); player.getInventory().refresh(lyre.getSlot()); player.startConversation(new Conversation(player).addNPC(1273, HeadE.CHEERFUL, ""I offer you this enchantment for your worthy offering."")); } else { lyre = player.getItemWithPlayer(3690); if (lyre != null) { player.getInventory().deleteItem(383, 1); lyre.setId(6126); player.getInventory().refresh(lyre.getSlot()); player.startConversation(new Conversation(player).addNPC(1273, HeadE.CHEERFUL, ""I offer you this enchantment for your worthy offering."")); } else player.sendMessage(""You need a strung lyre with you to call upon the Fossegrimen.""); } } public static ItemOnObjectHandler handleChargeLyre = new ItemOnObjectHandler(new Object[] { 4141 }, new Object[] { 383, 395, 363 }, e -> { rechargeLyre(e.getPlayer()); //TODO no way is this real in RS lmao }); private static final int[] LYRE_IDS = { 3690, 3691, 6125, 6126, 6127, 14590, 14591 }; private static int getLowerLyreId(int curr) { for (int i = 0;i < LYRE_IDS.length;i++) if (LYRE_IDS[i] == curr) return LYRE_IDS[i-1]; return 3690; } private static void lyreTele(Player player, Tile loc, Item lyre, boolean reduceDaily) { Magic.sendTeleportSpell(player, 9600, -1, 1682, -1, 0, 0, loc, 5, true, TeleType.ITEM, () -> { if (reduceDaily) { player.setDailyB(""freeLyreTele"", true); return; } if (lyre != null) { lyre.setId(getLowerLyreId(lyre.getId())); player.getInventory().refresh(); } }); } public static Dialogue getLyreTeleOptions(Player player, Item item, boolean reduceDaily) { if (reduceDaily && player.getDailyB(""freeLyreTele"")) return new Dialogue().addNext(() -> player.sendMessage(""You've already used your free teleport today."")); return new Dialogue().addOptions(""Where would you like to teleport?"", ops -> { ops.add(""Rellekka"", () -> Rellekka.lyreTele(player, Tile.of(2643, 3676, 0), item, reduceDaily)); if (AchievementDef.meetsRequirements(player, Area.FREMENNIK, Difficulty.HARD, false)) ops.add(""Waterbirth Island"", () -> Rellekka.lyreTele(player, Tile.of(2547, 3757, 0), item, reduceDaily)); if (AchievementDef.meetsRequirements(player, Area.FREMENNIK, Difficulty.ELITE, false)) { ops.add(""Jatizso"", () -> Rellekka.lyreTele(player, Tile.of(2407, 3803, 0), item, reduceDaily)); ops.add(""Neitiznot"", () -> Rellekka.lyreTele(player, Tile.of(2336, 3803, 0), item, reduceDaily)); } }); } public static ItemClickHandler handleEnchantedLyre = new ItemClickHandler(new Object[] { 3690 }, new String[] { ""Play"" }, e -> e.getPlayer().sendMessage(""The lyre is unresponsive. I should contact the Fossegrimen."")); public static ItemClickHandler handleEnchantedLyreTeleports = new ItemClickHandler(new Object[] { 3691, 6125, 6126, 6127, 14590, 14591 }, new String[] { ""Play"" }, e -> e.getPlayer().startConversation(getLyreTeleOptions(e.getPlayer(), e.getItem(), false))); public static ObjectClickHandler handleLighthouseDoor = new ObjectClickHandler(new Object[] { 4577 }, e -> e.getPlayer().handleOneWayDoor(e.getObject(), e.getObject().getId()+1)); public static ObjectClickHandler handleMountainCampWall = new ObjectClickHandler(new Object[] { 5847 }, e -> AgilityShortcuts.climbOver(e.getPlayer(), e.getPlayer().transform(e.getPlayer().getX() < e.getObject().getX() ? 2 : -2, 0, 0))); public static ObjectClickHandler handleKeldagrimEntrance = new ObjectClickHandler(new Object[] { 5008 }, e -> e.getPlayer().tele(Tile.of(2773, 10162, 0))); public static ObjectClickHandler handleKeldagrimExit = new ObjectClickHandler(new Object[] { 5014 }, e -> e.getPlayer().tele(Tile.of(2730, 3713, 0))); public static ObjectClickHandler handleLallisCave = new ObjectClickHandler(new Object[] { 4147 }, e -> e.getPlayer().startConversation(new Dialogue().addNPC(1270, HeadE.T_ANGRY, ""Hey human! You not go in my house! It where me keep all my stuff!""))); public static NPCClickHandler handleLallisConversation = new NPCClickHandler(new Object[] { 1270 }, e -> { // e.getPlayer().startConversation(new Dialogue() // .addPlayer(HeadE.CALM, ""Hello there."") // .addNPC(1270, HeadE.T_ANGRY, ""Bah! Puny humans always try steal Lallis' golden apples! You go away now!"") // .addPlayer(HeadE.CONFUSED, ""Uh.... Okay..."")); e.getPlayer().startConversation(new Dialogue() .addPlayer(HeadE.CALM, ""Hello there."") .addNPC(1270, HeadE.T_ANGRY, ""Bah! Puny humans always try steal Lallis' golden apples! You go away now!"") .addPlayer(HeadE.CONFUSED, ""Oh no, I'm not here for golden apples, I was just wondering if I could have some golden fleece from the sheep over there."") .addNPC(1270, HeadE.T_CONFUSED, ""Mmmm.. Here den, take some and leave Lalli alone!"") .addItem(3693, ""The troll hands you some golden fleece."", () -> e.getPlayer().getInventory().addItem(3693, 1))); }); }" "package com.rs.game.content.world.areas.rellekka.npcs; public class FremennikShipmaster extends Conversation { public FremennikShipmaster(Player player, int npcId, boolean backing) { super(player); addNPC(npcId, HeadE.CONFUSED, backing ? ""Do you want a lift back to the south?"" : ""You want passage to Daemonheim?""); addOptions(ops -> { ops.add(""Yes, please."", () -> sail(player, backing)); ops.add(""Not right now, thanks.""); }); create(); } public static void sail(Player player, boolean backing) { player.useStairs(-1, backing ? Tile.of(3254, 3171, 0) : Tile.of(3511, 3692, 0), 2, 3); if (backing) player.getControllerManager().forceStop(); else player.getControllerManager().startController(new DamonheimController()); } }" "package com.rs.game.content.world.areas.rellekka.npcs; @PluginEventHandler public class PeerTheSeer { public static NPCClickHandler handler = new NPCClickHandler(new Object[] { ""Peer the Seer"" }, e -> { switch(e.getOption()) { case ""Deposit"": if (e.getPlayer().isQuestComplete(Quest.FREMENNIK_TRIALS, ""to deposit with Peer."")) e.getPlayer().getBank().openDepositBox(); break; } }); }" "package com.rs.game.content.world.areas.rellekka.npcs; @PluginEventHandler public class RockCrab extends NPC { private final int realId; public RockCrab(int id, Tile tile, boolean spawned) { super(id, tile, spawned); realId = id; setForceAgressive(true); // to ignore combat lvl } @Override public void setTarget(Entity entity) { if (realId == getId()) { transformIntoNPC(realId - 1); setHitpoints(getMaxHitpoints()); } super.setTarget(entity); } @Override public void reset() { setNPC(realId); super.reset(); } public static NPCInstanceHandler toFunc = new NPCInstanceHandler(new Object[] { 1266, 1268, 2453, 2886 }, (npcId, tile) -> new RockCrab(npcId, tile, false)); }" "package com.rs.game.content.world.areas.rimmington; @PluginEventHandler public class Rimmington { /** * Shopkeepers and simple NPCs */ public static NPCClickHandler GENERAL_STORES = new NPCClickHandler(new Object[] { 530, 531 }, e -> { switch (e.getOption()) { case ""Trade"" -> ShopsHandler.openShop(e.getPlayer(), ""rimmington_general_store""); case ""Talk-to"" -> e.getPlayer().startConversation(new Dialogue() .addNPC(530, HeadE.HAPPY_TALKING, ""Can I help you at all?"") .addOptions(ops -> { ops.add(""Yes, please. What are you selling?"", () -> ShopsHandler.openShop(e.getPlayer(), ""rimmington_general_store"")); ops.add(""How should I use your shop?"") .addNPC(530, HeadE.HAPPY_TALKING, ""I'm glad you ask! You can buy as many of the items stocked as you wish. You can also sell most items to the shop."") .addNext(() -> ShopsHandler.openShop(e.getPlayer(), ""rimmington_general_store"")); ops.add(""I think I'll give it a miss."") .addPlayer(HeadE.CALM_TALK, ""I think I'll give it a miss."") .addNPC(530, HeadE.HAPPY_TALKING, ""Okay, come back soon.""); }) ); } }); public static NPCClickHandler BRIAN = new NPCClickHandler(new Object[]{ 1860 }, e -> { switch (e.getOption()) { case ""Trade"" -> ShopsHandler.openShop(e.getPlayer(), ""brians_archery_supplies""); case ""Talk-to"" -> e.getPlayer().startConversation(new Dialogue() .addNPC(1860, HeadE.HAPPY_TALKING, ""Would you like to buy some archery equipment?"") .addOptions(ops -> { ops.add(""Let's see what you've got then."", () -> ShopsHandler.openShop(e.getPlayer(), ""brians_archery_supplies"")); ops.add(""No thanks, I've got all the archery equipment I need."") .addPlayer(HeadE.CALM_TALK, ""No thanks, I've got all the archery equipment I need."") .addNPC(1860, HeadE.HAPPY_TALKING, ""Okay. Fare well on your travels.""); })); } }); public static NPCClickHandler ROMMIK = new NPCClickHandler(new Object[]{ 585 }, e -> { switch (e.getOption()) { case ""Trade"" -> ShopsHandler.openShop(e.getPlayer(), ""rommiks_crafting_shop""); case ""Talk-to"" -> e.getPlayer().startConversation(new Dialogue() .addNPC(585, HeadE.HAPPY_TALKING, ""Would you like to buy some archery equipment?"") .addOptions(ops -> { ops.add(""Let's see what you've got then."", () -> ShopsHandler.openShop(e.getPlayer(), ""rommiks_crafting_shop"")); ops.add(""No thanks, I've got all the crafting equipment I need."") .addPlayer(HeadE.CALM_TALK, ""No thanks, I've got all the crafting equipment I need."") .addNPC(585, HeadE.HAPPY_TALKING, ""Okay. Fare well on your travels.""); })); } }); /** * Purely Biohazard related Quest NPCs that will need to be eventually moved into * a Biohazard class once the quest gets added. */ public static NPCClickHandler CHANCY = new NPCClickHandler(new Object[]{ 338 }, e -> e.getPlayer().startConversation(new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Hello! Playing Solitaire?"") .addNPC(338, HeadE.FRUSTRATED, ""Hush - I'm trying to perfect the art of dealing off the bottom of the deck. Whatever you want, come back later."") .addSimple(""Chancy doesn't feel like talking.""))); public static NPCClickHandler DA_VINCI = new NPCClickHandler(new Object[]{ 336 }, e -> e.getPlayer().startConversation(new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Hello!"") .addNPC(336, HeadE.FRUSTRATED, ""Bah! A great artist such as myself should not have to suffer the HUMILIATION of spending time where commoners wander everywhere!"") .addSimple(""Da Vinci does not feel sufficiently moved to talk.""))); public static NPCClickHandler HOPS = new NPCClickHandler(new Object[]{ 340 }, e -> e.getPlayer().startConversation(new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Hello!"") .addNPC(340, HeadE.DRUNK, ""Hops don't wanna talk now. HIC!"") .addSimple(""He isn't in a fit state to talk.""))); }" "package com.rs.game.content.world.areas.rimmington.npcs; @PluginEventHandler public class Chemist extends Conversation { public static int CHEMIST = 367; public Chemist(Player player) { super(player); addOptions(""Choose an option:"", ops -> { ops.add(""Ask about lamp oil."") .addPlayer(HeadE.CALM_TALK, ""Hi, I need fuel for a lamp."") .addNPC(CHEMIST, HeadE.CALM_TALK, ""Hello there, the fuel you need is lamp oil, do you need help making it?"") .addOptions(""Choose an option:"", ops2 -> { ops2.add(""Yes please."") .addPlayer(HeadE.CALM_TALK, ""Yes please."") .addNPC(CHEMIST, HeadE.CALM_TALK, ""It's really quite simple. all set up, so there's no fiddling around with dials... Just put ordinary swamp tar in, and then use a lantern or lamp to get the oil out."") .addPlayer(HeadE.CALM_TALK, ""Thanks.""); ops2.add(""No thanks."") .addPlayer(HeadE.CALM_TALK, ""No thanks.""); }); if (player.getInventory().containsItem(11262)) ops.add(""Ask about impling jars."") .addNPC(CHEMIST, HeadE.CALM_TALK, ""My lamp oil still may be able to do what you want. Use the oil and flower mix on the still."") .addNPC(CHEMIST, HeadE.CALM_TALK, ""Once that's done, get one of those butterfly jars to collect the distillate."") .addPlayer(HeadE.CALM_TALK, ""Thanks!""); else if (player.getInventory().containsItem(11264)) ops.add(""Ask about impling jars."") .addPlayer(HeadE.CALM_TALK, ""Do you know how I might distil a mix of anchovy oil and flowers so that it forms a layer on the inside of a butterfly jar?"") .addNPC(CHEMIST, HeadE.CALM_TALK, ""My lamp oil still may be able to do what you want. "" + (player.getInventory().containsOneItem(6010, 6012, 6014, 2460, 2462, 2466, 2468, 2470, 2472, 2474, 2474, 2476) ? ""You'll need to mix your flowers to the anchovy oil first. Then use the oil and flower mix on the still."" : ""You'll need to get flowers first, then mix them to your anchovy oil. Then use the oil and flower mix on the still."")) .addNPC(CHEMIST, HeadE.CALM_TALK, ""Once that's done, "" + (player.getInventory().containsOneItem(10012) ? ""use"" : ""get"") + "" one of those butterfly jars to collect the distillate."") .addPlayer(HeadE.CALM_TALK, ""Thanks!""); else ops.add(""Ask about impling jars."") .addPlayer(HeadE.CALM_TALK, ""I have a slightly odd question."") .addNPC(CHEMIST, HeadE.CALM_TALK, ""Jolly good, the odder the better. I like oddities."") .addPlayer(HeadE.CALM_TALK, ""Do you know how I might distil a mix of anchovy oil and flowers so that it forms a layer on the inside of a butterfly jar?"") .addNPC(CHEMIST, HeadE.CALM_TALK, ""That is an odd question. I commend you for it. Why would you want to do that?"") .addPlayer(HeadE.CALM_TALK, ""Apparently, if I can make a jar like this it will be useful for storing implings in."") .addNPC(CHEMIST, HeadE.CALM_TALK, ""So, do you have any of this fish-and-flower flavoured oil and a butterfly jar then?"") .addPlayer(HeadE.CALM_TALK, ""Actually, no."") .addNPC(CHEMIST, HeadE.CALM_TALK, ""If you go and get them then I may be able to help you. I'm better at coming up with answers if the questions are in my hands."") .addNPC(CHEMIST, HeadE.CALM_TALK, ""Is there anything else you want to ask?"") .addOptions(""Choose an option:"", ops2 -> { ops2.add(""So how do you make anchovy oil?"") .addPlayer(HeadE.CALM_TALK, ""How do you make anchovy oil?"") .addNPC(CHEMIST, HeadE.CALM_TALK, ""Anchovies are pretty oily fish. I'd have thought you could just grind them up using a pestle and mortar and sieve out the bits."") .addNPC(CHEMIST, HeadE.CALM_TALK, ""You'd probably want to remove any water first - Cooking should do that pretty well. I reckon you'll need to sieve 8 lots of anchovies[sic] paste to get one vial of anchovy oil.""); if (!player.getInventory().containsItem(6097)) ops2.add(""Do you have a sieve I can use?"") .addPlayer(HeadE.CALM_TALK, ""Do you have a sieve I can use?"") .addNPC(CHEMIST, HeadE.CALM_TALK, ""Errm, yes. Here, have this one. It's only been used for sieving dead rats out of sewer water."") .addPlayer(HeadE.CALM_TALK, ""Err, why? Actually, on second thoughts I don't want to know."") .addNPC(CHEMIST, HeadE.CALM_TALK, ""Well, it should be ideally suited to your task."") .addItem(6097, ""The chemist gives you a sieve."", () -> player.getInventory().addItemDrop(6097, 1)); else ops2.add(""Do you have a sieve I can use?"") .addPlayer(HeadE.CALM_TALK, ""Do you have a sieve I can use?"") .addNPC(CHEMIST, HeadE.CALM_TALK, ""Errm, yes. But you already have one. Two sieves is a bit excessive, don't you think?""); ops2.add(""I'd better go and get the ingredients."") .addPlayer(HeadE.CALM_TALK, ""I'd better go and get the ingredients."") .addNPC(CHEMIST, HeadE.CALM_TALK, ""I think so.""); }); ops.add(""About the Task System..."", () -> new AchievementSystemD(player, CHEMIST, SetReward.FALADOR_SHIELD)); }); } public static NPCClickHandler handleChemist = new NPCClickHandler(new Object[] { CHEMIST }, e -> e.getPlayer().startConversation(new Chemist(e.getPlayer()))); }" "package com.rs.game.content.world.areas.rimmington.npcs; @PluginEventHandler public class SirRebrum { public static NPCClickHandler talkToSirRebrum = new NPCClickHandler(new Object[] { 15460 }, e -> { Player player = e.getPlayer(); NPC npc = e.getNPC(); player.startConversation(new Dialogue() .addNPC(npc, HeadE.DRUNK, ""Half, adventurer! Go no further! Mortal, wormy peril lies within this cave!"") .addOptions(ops -> { ops.add(""Wormy?""); ops.add(""Who are you again?""); ops.add(""Don't worry, I eat peril for breakfast.""); if (!player.containsAnyItems(24303, 24337, 24338, 24339)) { ops.add(""Would you happen to have found a Coral Crossbow?"") .addNPC(npc, HeadE.DRUNK, ""Why, yes I have! The Raptor passed by earlier. He said you might need it."") .addItemToInv(player, new Item(24303, 1), ""You receive a Coral Crossbow.""); } })); }); }" "package com.rs.game.content.world.areas.rimmington.npcs.announcers; @PluginEventHandler public class SkippyWorld extends NPC { public SkippyWorld(int id, Tile tile) { super(id, tile); } @Override public void processNPC() { super.processNPC(); if (Utils.random(50) == 0){ Shout(); } } public void Shout() { switch (Utils.random(1, 6)) { case 1 -> setNextForceTalk(new ForceTalk(""I've got a bottle with your name on it!"")); case 2 -> setNextForceTalk(new ForceTalk(""Mudskippers, thousands of them!"")); case 3 -> setNextForceTalk(new ForceTalk(""They're coming out of the walls!"")); case 4 -> setNextForceTalk(new ForceTalk(""The horror... The horror..."")); case 5 -> setNextForceTalk(new ForceTalk(""I'll get you, I'll get you all!"")); case 6 -> setNextForceTalk(new ForceTalk(""Take this!"")); } } public static NPCInstanceHandler toFunc = new NPCInstanceHandler(new Object[] { 2795 }, SkippyWorld::new); }" "package com.rs.game.content.world.areas.seers_village const val STANKERS_ID = 383 const val COAL_ITEM_ID = 453 const val PLAYER_COAL_TRUCK_VAR = 74 const val DEFAULT_MAX_COAL_STORAGE = 120 val MAX_COAL_STORAGE_MAP = mapOf( ""Easy"" to 140, ""Medium"" to 168, ""Hard"" to 196 ) @ServerStartupEvent fun handleCoalTrucks() { onNpcClick(STANKERS_ID, options = arrayOf(""Talk-to"")) { e -> e.player.apply { e.player.startConversation(StankersD(this, e.npc)) } } onItemOnObject(arrayOf(""Coal Truck""), arrayOf(COAL_ITEM_ID)) { e -> e.apply { val maxCoalStorage = getMaxCoalStorage(player) val currentCoalInTruck = player.vars.getVar(PLAYER_COAL_TRUCK_VAR) val coalToAdd = minOf(player.inventory.getAmountOf(COAL_ITEM_ID), maxCoalStorage - currentCoalInTruck) if (coalToAdd <= 0) { player.simpleDialogue(""The coal truck is too full to hold any more coal."") return@apply } player.inventory.removeItems(Item(COAL_ITEM_ID, coalToAdd)) player.vars.saveVar(PLAYER_COAL_TRUCK_VAR, currentCoalInTruck + coalToAdd) player.sendMessage(""You add some coal to the coal truck."") if (currentCoalInTruck + coalToAdd == maxCoalStorage) { player.simpleDialogue(""The coal truck is now full."") return@apply } return@apply } } onObjectClick(""Coal Truck"") { (player, _, option) -> when (option) { ""Investigate"" -> { val maxCoalStorage = getMaxCoalStorage(player) val spaceLeft = maxCoalStorage - player.vars.getVar(PLAYER_COAL_TRUCK_VAR) val message = if (spaceLeft > 0) { ""The coal truck has space for $spaceLeft more coal."" } else { ""The coal truck doesn't have space for any more coal."" } player.simpleDialogue(""There is currently ${player.vars.getVar(PLAYER_COAL_TRUCK_VAR)} coal in the coal truck.
$message"") } ""Remove-coal"" -> { val currentCoalInTruck = player.vars.getVar(PLAYER_COAL_TRUCK_VAR) if (currentCoalInTruck <= 0) { player.simpleDialogue(""The coal truck is empty."") return@onObjectClick } val coalToRemove = minOf(player.inventory.freeSlots, currentCoalInTruck) if (player.inventory.addItem(COAL_ITEM_ID, coalToRemove)) { player.vars.saveVar(PLAYER_COAL_TRUCK_VAR, currentCoalInTruck - coalToRemove) player.sendMessage(""You remove some coal from the coal truck."") } } } } onLogin { (player) -> player.vars.getVar(PLAYER_COAL_TRUCK_VAR) } } private fun getMaxCoalStorage(player: Player): Int { val seersHeadbandRequirements = getSeersHeadbandRequirements(player) return MAX_COAL_STORAGE_MAP.getOrElse(seersHeadbandRequirements) { DEFAULT_MAX_COAL_STORAGE } } private fun getSeersHeadbandRequirements(player: Player): String { val area = AchievementDef.Area.SEERS val easyRequirementMet = SetReward.SEERS_HEADBAND.hasRequirements(player, area, AchievementDef.Difficulty.EASY, false) val mediumRequirementMet = SetReward.SEERS_HEADBAND.hasRequirements(player, area, AchievementDef.Difficulty.MEDIUM, false) val hardRequirementMet = SetReward.SEERS_HEADBAND.hasRequirements(player, area, AchievementDef.Difficulty.HARD, false) return when { hardRequirementMet -> ""Hard"" mediumRequirementMet -> ""Medium"" easyRequirementMet -> ""Easy"" else -> ""None"" } }" "package com.rs.game.content.world.areas.seers_village; @PluginEventHandler public class SeersVillage { public static ObjectClickHandler beehives = new ObjectClickHandler(new Object[] { 68 }, e -> { if (e.getPlayer().getInventory().containsItem(28)) { if (e.getPlayer().getInventory().containsItem(1925)) { e.getPlayer().setNextAnimation(new Animation(833)); e.getPlayer().lock(1); e.getPlayer().getInventory().deleteItem(1925, 1); e.getPlayer().getInventory().addItem(30, 1); } else e.getPlayer().sendMessage(""You need a bucket to gather the wax into.""); } else { e.getPlayer().setNextAnimation(new Animation(833)); e.getPlayer().lock(1); e.getPlayer().setNextForceTalk(new ForceTalk(""Ouch!"")); e.getPlayer().applyHit(new Hit(10, HitLook.TRUE_DAMAGE)); e.getPlayer().sendMessage(""The bees sting your hands as you reach inside!""); } }); public static ObjectClickHandler grubersWoodFence = new ObjectClickHandler(new Object[] { 51 }, e -> { Player p = e.getPlayer(); GameObject obj = e.getObject(); p.forceMove(p.getX() < obj.getX() ? Tile.of(2662, 3500, 0) : Tile.of(2661, 3500, 0), 3844, 25, 75); }); public static ObjectClickHandler grubersShedDoor = new ObjectClickHandler(new Object[] { 99 }, e -> { if(e.getPlayer().getInventory().containsItem(85) || e.getPlayer().getY() <= 3496) { handleDoor(e.getPlayer(), e.getObject()); return; } e.getPlayer().sendMessage(""It is locked...""); }); public static NPCClickHandler handleSeer = new NPCClickHandler(new Object[] { 388 }, e -> e.getPlayer().startConversation(new Conversation(e.getPlayer()) { { addNPC(e.getNPCId(), HeadE.DRUNK, ""Uh, what was that dark force? I've never sensed anything like it...""); addNPC(e.getNPCId(), HeadE.NO_EXPRESSION, ""Anyway, sorry about that.""); addOptions(""What would you like to say?"", new Options() { @Override public void create() { if (e.getPlayer().getQuestManager().getStage(Quest.SCORPION_CATCHER) == ScorpionCatcher.LOOK_FOR_SCORPIONS) option(""About Scorpion Catcher"", new SeerScorpionCatcherD(e.getPlayer()).getStart()); option(""About the Achievement System..."", () -> new AchievementSystemD(player, e.getNPCId(), SetReward.SEERS_HEADBAND)); } }); } })); public static int[] battlestaves = { 1397, 1395, 1399, 1393, 3053, 6562, 11736 }; public static int[] mystics = { 1405, 1403, 1407, 1401, 3054, 6563, 11738 }; public static ButtonClickHandler handleButtons = new ButtonClickHandler(332, e -> { int staffIdx = e.getComponentId()-21; if (e.getPlayer().getInventory().hasCoins(40000) && e.getPlayer().getInventory().containsItem(battlestaves[staffIdx], 1)) { e.getPlayer().getInventory().removeCoins(40000); e.getPlayer().getInventory().deleteItem(battlestaves[staffIdx], 1); e.getPlayer().getInventory().addItem(mystics[staffIdx], 1); } else e.getPlayer().sendMessage(""You need 40,000 coins and a battlestaff of the correct type to enchant.""); }); public static NPCClickHandler handleThormacDialogue = new NPCClickHandler(new Object[] { 389 }, e -> { if (!e.getPlayer().isQuestComplete(Quest.SCORPION_CATCHER)) e.getPlayer().startConversation(new ThormacScorpionCatcherD(e.getPlayer()).getStart()); else e.getPlayer().startConversation(new Conversation(e.getPlayer()) { { addPlayer(HeadE.HAPPY_TALKING, ""You said you would give me mystic battlestaffs for enchanted battlestaffs for 40k...""); addNext(() -> player.getInterfaceManager().sendInterface(332)); create(); } }); }); //---Camelot Castle public static NPCClickHandler handleSirKay = new NPCClickHandler(new Object[] { 241 }, e -> e.getPlayer().startConversation(new Conversation(e.getPlayer()) { { addNPC(e.getNPCId(), HeadE.CHEERFUL, ""Hello, what can I do for you?""); addOptions(""What would you like to say?"", new Options() { @Override public void create() { option(""About the Achievement System..."", () -> new AchievementSystemD(player, e.getNPCId(), SetReward.SEERS_HEADBAND)); if(e.getPlayer().getQuestManager().getStage(Quest.HOLY_GRAIL) > HolyGrail.NOT_STARTED) option(""About Holy Grail"", new Dialogue() .addNext(()-> e.getPlayer().startConversation(new SirKayHolyGrailD(e.getPlayer()).getStart()))); if (!player.isQuestComplete(Quest.MERLINS_CRYSTAL)) option(""About Merlin's Crystal"", new Dialogue() .addNext(()-> e.getPlayer().startConversation(new SirKayMerlinsCrystalD(e.getPlayer()).getStart()))); } }); } })); public static NPCClickHandler handleSirBedivere = new NPCClickHandler(new Object[] { 242 }, e -> { if(e.getPlayer().getQuestManager().getStage(Quest.HOLY_GRAIL) > HolyGrail.NOT_STARTED) { e.getPlayer().startConversation(new SirBedivereHolyGrailD(e.getPlayer()).getStart()); return; } e.getPlayer().startConversation(new SirBedivereMerlinsCrystalD(e.getPlayer()).getStart()); }); public static NPCClickHandler handleSirGawain = new NPCClickHandler(new Object[] { 240 }, e -> { if(e.getPlayer().getQuestManager().getStage(Quest.HOLY_GRAIL) > HolyGrail.NOT_STARTED) { e.getPlayer().startConversation(new SirGawainHolyGrailD(e.getPlayer()).getStart()); return; } e.getPlayer().startConversation(new SirGawainMerlinsCrystalD(e.getPlayer()).getStart()); }); public static NPCClickHandler handleSirLancelot = new NPCClickHandler(new Object[] { 239 }, e -> { if(e.getPlayer().getQuestManager().getStage(Quest.HOLY_GRAIL) > HolyGrail.NOT_STARTED) { e.getPlayer().startConversation(new SirLancelotHolyGrailD(e.getPlayer()).getStart()); return; } e.getPlayer().startConversation(new SirLancelotMerlinsCrystalD(e.getPlayer()).getStart()); }); public static NPCClickHandler handleSirLucan = new NPCClickHandler(new Object[] { 245 }, e -> { if(e.getPlayer().getQuestManager().getStage(Quest.HOLY_GRAIL) > HolyGrail.NOT_STARTED) { e.getPlayer().startConversation(new SirLucanHolyGrailD(e.getPlayer()).getStart()); return; } e.getPlayer().startConversation(new SirLucanMerlinsCrystalD(e.getPlayer()).getStart()); }); public static NPCClickHandler handleSirPalomedes = new NPCClickHandler(new Object[] { 3787 }, e -> { if(e.getPlayer().getQuestManager().getStage(Quest.HOLY_GRAIL) > HolyGrail.NOT_STARTED) { e.getPlayer().startConversation(new SirPalomedesHolyGrailD(e.getPlayer()).getStart()); return; } e.getPlayer().startConversation(new SirPalomedesMerlinsCrystalD(e.getPlayer()).getStart()); }); public static NPCClickHandler handleSirPelleas = new NPCClickHandler(new Object[] { 244 }, e -> { if(e.getPlayer().getQuestManager().getStage(Quest.HOLY_GRAIL) > HolyGrail.NOT_STARTED) { e.getPlayer().startConversation(new SirPelleasHolyGrailD(e.getPlayer()).getStart()); return; } e.getPlayer().startConversation(new SirPelleasMerlinsCrystalD(e.getPlayer()).getStart()); }); public static NPCClickHandler handleTristram = new NPCClickHandler(new Object[] { 243 }, e -> { if(e.getPlayer().getQuestManager().getStage(Quest.HOLY_GRAIL) > HolyGrail.NOT_STARTED) { e.getPlayer().startConversation(new SirTristamHolyGrailD(e.getPlayer()).getStart()); return; } e.getPlayer().startConversation(new SirTristramMerlinsCrystalD(e.getPlayer()).getStart()); }); public static NPCClickHandler handleKingArthur = new NPCClickHandler(new Object[] { 251 }, e -> { if(e.getPlayer().isQuestComplete(Quest.MERLINS_CRYSTAL)) {//After merlins crystal is holy grail... e.getPlayer().startConversation(new KingArthurHolyGrailD(e.getPlayer()).getStart()); return; } e.getPlayer().startConversation(new KingArthurMerlinsCrystalD(e.getPlayer()).getStart()); }); public static NPCClickHandler handleMerlin = new NPCClickHandler(new Object[] { 213 }, e -> { if(e.getPlayer().getQuestManager().getStage(Quest.HOLY_GRAIL) > HolyGrail.NOT_STARTED) { e.getPlayer().startConversation(new MerlinHolyGrailD(e.getPlayer()).getStart()); return; } if(e.getPlayer().isQuestComplete(Quest.MERLINS_CRYSTAL)) e.getPlayer().startConversation(new Dialogue().addNPC(e.getNPCId(), HeadE.HAPPY_TALKING, ""Thank you for saving me from that crystal!"")); }); //--End Camelot Castle public static ObjectClickHandler handleRoofLadder = new ObjectClickHandler(new Object[] { 26118, 26119 }, e -> e.getPlayer().ladder(e.getPlayer().transform(0, 0, e.getObjectId() == 26118 ? 2 : -2))); public static ObjectClickHandler handleIkovTrapDoor = new ObjectClickHandler(new Object[] { 6278 }, e -> e.getPlayer().sendMessage(""It appears locked from the inside..."")); public static ObjectClickHandler handleCoalTruckLogBalance = new ObjectClickHandler(new Object[] { 2296 }, e -> { if (!Agility.hasLevel(e.getPlayer(), 20)) return; AgilityShortcuts.walkLog(e.getPlayer(), e.getPlayer().transform(e.getObject().getRotation() == 1 ? -5 : 5, 0, 0), 4); }); public static ObjectClickHandler handleSinclairMansionLogBalance = new ObjectClickHandler(new Object[] { 9322, 9324 }, e -> { if (!Agility.hasLevel(e.getPlayer(), 48)) return; AgilityShortcuts.walkLog(e.getPlayer(), e.getPlayer().transform(0, e.getObjectId() == 9322 ? -4 : 4, 0), 3); }); }" "package com.rs.game.content.world.areas.seers_village.npcs class BartenderForestersArms(p: Player, npc: NPC) { init { p.startConversation { npc(npc, HeadE.HAPPY_TALKING, ""Good morning, what would you like?"") options { op(""What do you have?"") { player(HeadE.HAPPY_TALKING, ""What do you have?"") npc(npc, HeadE.HAPPY_TALKING, ""Well we have beer, or if you want some food, we have our home made stew and meat pies."") options { op(""Beer please."") { player(HeadE.HAPPY_TALKING, ""Beer please."") npc(npc, HeadE.HAPPY_TALKING, ""One beer coming up. Ok, that'll be two coins."") exec { buyDrinkOrIngredients(p, npc, 2, Item(1917), true) p.sendMessage(""You buy a pint of beer."") } } op(""I'll try the meat pie."") { player(HeadE.HAPPY_TALKING, ""I'll try the meat pie."") npc(npc, HeadE.HAPPY_TALKING, ""Ok, that'll be 16 coins."") exec { buyDrinkOrIngredients(p, npc, 16, Item(2327), true) p.sendMessage(""You buy a nice hot meat pie."") } } op(""Could I have some stew please?"") { player(HeadE.HAPPY_TALKING, ""Could I have some stew please?"") npc(npc, HeadE.HAPPY_TALKING, ""A bowl of stew, that'll be 20 coins please."") exec { buyDrinkOrIngredients(p, npc, 20, Item(2003), true) p.sendMessage(""You buy a bowl of home made stew."") } } op(""I don't really want anything thanks."") { player(HeadE.HAPPY_TALKING, ""I don't really want anything thanks."") } } } op(""Beer please."") { player(HeadE.HAPPY_TALKING, ""Beer please."") npc(npc, HeadE.HAPPY_TALKING, ""One beer coming up. Ok, that'll be two coins."") exec { buyDrinkOrIngredients(p, npc, 2, Item(1917), true) p.sendMessage(""You buy a pint of beer."") } } if (!isBarVisited(p, FORESTERS_ARMS) && BarCrawl.hasCard(p) && onBarCrawl(p)) { op(""I'm doing Alfred Grimhand's Barcrawl."") { player(HeadE.HAPPY_TALKING, ""I'm doing Alfred Grimhand's Barcrawl."") npc(npc, HeadE.CHEERFUL, ""Oh you're a barbarian then. Now which of these barrels contained the ${FORESTERS_ARMS.drinkName}? That'll be ${FORESTERS_ARMS.price} coins please."") exec { buyBarcrawlDrink(p, FORESTERS_ARMS) } } } } } } } @ServerStartupEvent fun mapBartenderForestersArms() { onNpcClick(737) { (player, npc) -> BartenderForestersArms(player, npc) } }" "package com.rs.game.content.world.areas.seers_village.npcs class StankersD(player: Player, npc: NPC) : Conversation(player) { init { player.startConversation { npc(npc.id, HeadE.HAPPY_TALKING, ""Hello, bold adventurer."") label(""initialOps"") options { op(""Are these your trucks?"") { player(HeadE.CALM, ""Are these your trucks?"") npc(npc.id, HeadE.CALM, ""Yes, I use them to transport coal over the river. I will let other people use them too, I'm a nice person like that..."") npc(npc.id, HeadE.CALM, ""Just put coal in a truck and I'll move it down to my depot over the river."") goto(""initialOps"") } op(""Hello, Mr Stankers."") { player(HeadE.CHEERFUL, ""Hello, Mr Stankers."") npc(npc.id, HeadE.CALM, ""Would you like a poison chalice?"") label(""chaliceOps"") options(""Would you like a poison chalice?"") { op(""Yes, please."") { player(HeadE.NO_EXPRESSION, ""Yes, please."") npc(npc.id, HeadE.CHEERFUL, ""Take one from my shop. You might consider buying one of my fine pickaxes while you're looking."") player(HeadE.CONFUSED, ""Pickaxes?"") npc(npc.id, HeadE.CALM, ""Yes, I've started a business. It's not going very well so far, but the poison chalices are quite a nice loss-leader."") exec { ShopsHandler.openShop(player, ""stankers_bronze_pickaxes"") } } op(""What's a poison chalice?"") { player(HeadE.CONFUSED, ""What's a poison chalice?"") npc(npc.id, HeadE.CHEERFUL, ""It's an exciting drink I've invented. I don't know what it tastes like, I haven't tried it myself."") goto(""chaliceOps"") } op(""No, thank you."") { player(HeadE.NONE, ""No, thank you."") goto(""initialOps"") } } } op(""About the Achievement System..."") { exec { AchievementSystemD(player, npc.id, SetReward.SEERS_HEADBAND) } } } } } }" "package com.rs.game.content.world.areas.slayer_tower; @PluginEventHandler public class SlayerTower { public static PlayerStepHandler doors = new PlayerStepHandler(new Tile[] { Tile.of(3428, 3535, 0), Tile.of(3429, 3535, 0)}, e -> { e.getStep().setCheckClip(false); GameObject door = World.getObjectWithId(Tile.of(3428, 3535, 0), 4487); if (door != null) Doors.handleDoubleDoor(e.getPlayer(), door); World.sendObjectAnimation(World.getObject(Tile.of(3426, 3534, 0), ObjectType.SCENERY_INTERACT), new Animation(1533)); World.sendObjectAnimation(World.getObject(Tile.of(3430, 3534, 0), ObjectType.SCENERY_INTERACT), new Animation(1533)); }); }" "package com.rs.game.content.world.areas.stronghold_of_safety; @PluginEventHandler public class SoSNpcs { private static final int JAILGUARD = 7142; private static final int PROFESSOR_HENRY = 7143; public static NPCClickHandler HandleSoPSGuard = new NPCClickHandler(new Object[]{JAILGUARD}, e -> { switch (e.getOption()) { case ""Talk-to"" -> e.getPlayer().startConversation(new Dialogue() .addNPC(JAILGUARD, HeadE.HAPPY_TALKING, ""Can I help you?"") .addPlayer(HeadE.CONFUSED, ""I hope so. What is this place?"") .addNPC(JAILGUARD, HeadE.HAPPY_TALKING, ""Above us is the Misthalin Training Centre of Excellence, where young adventurers are taught things that will help keep themselves safe."") .addNPC(JAILGUARD, HeadE.HAPPY_TALKING, ""They say that hidden away somewhere here is the entrance to the old jail, which no doubt has fabulous treasures for those willing to search for them."") .addNPC(JAILGUARD, HeadE.HAPPY_TALKING, ""Together they’re called the Stronghold of Player Safety, for historical reasons."") .addPlayer(HeadE.CONFUSED, ""So what do you do?"") .addNPC(JAILGUARD, HeadE.HAPPY_TALKING, ""I guard this stairway to make sure that prospective students are ready."") .addNPC(JAILGUARD, HeadE.HAPPY_TALKING, ""That’s interesting. Goodbye."")); } }); public static NPCClickHandler HandleProfessorHenry = new NPCClickHandler(new Object[]{PROFESSOR_HENRY}, e -> { switch (e.getOption()) { case ""Talk-to"" -> { if (e.getPlayer().getEmotesManager().unlockedEmote(EmotesManager.Emote.SAFETY_FIRST)) e.getPlayer().startConversation(new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Hello, Professor."") .addNPC(PROFESSOR_HENRY, HeadE.HAPPY_TALKING, ""Ah, hello, "" + e.getPlayer().getDisplayName() + "". How goes the adventuring? I trust you are enjoying your adventures?"") .addPlayer(HeadE.HAPPY_TALKING, ""I am, thanks. I was wondering where the jail block might be."") .addNPC(PROFESSOR_HENRY, HeadE.HAPPY_TALKING, ""Ah, yes. Search the cells downstairs and I’m sure you’ll find it easily enough."") .addPlayer(HeadE.CONFUSED, ""Okay, thanks."") ); else e.getPlayer().startConversation(new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Hello!"") .addNPC(PROFESSOR_HENRY, HeadE.HAPPY_TALKING, ""Good day! Did you want to know about the old jail block? We always need adventurers to keep the cockroaches in check."") .addPlayer(HeadE.HAPPY_TALKING, ""Do I need to do your exam?"") .addNPC(PROFESSOR_HENRY, HeadE.HAPPY_TALKING, ""No, the exam isn’t really for adventurers like you. Are you looking for the jail block?"") .addPlayer(HeadE.CONFUSED, ""Sure, tell me about the jail."") .addNPC(PROFESSOR_HENRY, HeadE.HAPPY_TALKING, ""In the cells downstairs there’s a secret passage into the old prison. I hear that fame and fortune awaits a suitably skilled adventurer."") .addPlayer(HeadE.HAPPY_TALKING, ""Thanks, I’ll look into that."") ); } } }); public static NPCClickHandler HandleStudents = new NPCClickHandler(new Object[]{ 7151, 7152, 7153, 7154, 7155, 7156, 7157 }, e -> { switch (e.getOption()) { case ""Talk-to"" -> { e.getNPC().resetDirection(); e.getPlayer().startConversation(new Dialogue() .addNPC(PROFESSOR_HENRY, HeadE.VERY_FRUSTRATED, ""No talking during the exam!"") .addPlayer(HeadE.SAD_MILD_LOOK_DOWN, ""Sorry, Professor!"") ); } } }); }" "package com.rs.game.content.world.areas.stronghold_of_safety; @PluginEventHandler public class StrongholdOfSafety { public static ObjectClickHandler handleTrainingCentreStairsDown = new ObjectClickHandler(new Object[] { 29592 }, Tile.of(3084, 3452, 0), e -> e.getPlayer().useStairs(827, Tile.of(3086, 4247, 0))); public static ObjectClickHandler handleTrainingCentreStairsUp = new ObjectClickHandler(new Object[] { 29589 }, Tile.of(3086, 4244, 0), e -> e.getPlayer().useStairs(827, Tile.of(3084, 3452, 0), 1, 2)); public static ObjectClickHandler handleSecureZoneLever = new ObjectClickHandler(new Object[]{ 29736 }, Tile.of(3146, 4278, 3), e -> { e.getObject().setIdTemporary(29731, Ticks.fromSeconds(20)); e.getPlayer().getTempAttribs().setB(""TrainingCentreSecureZoneDoor"", true); e.getPlayer().sendMessage(""You hear a door unlock.""); }); public static ObjectClickHandler handleSecureZoneDoorEast = new ObjectClickHandler(new Object[] { 29624 }, Tile.of(3178, 4269, 2), e -> { if(!e.getPlayer().getTempAttribs().getB(""TrainingCentreSecureZoneDoor"")) e.getPlayer().sendMessage(""This door is locked, maybe there is a way to unlock it?""); else e.getPlayer().useStairs(Tile.of(3177, 4266, 0)); e.getPlayer().faceEast(); }); public static ObjectClickHandler handleSecureZoneDoorWest = new ObjectClickHandler(new Object[] { 29624 }, Tile.of(3141, 4272, 1), e -> { if(!e.getPlayer().getTempAttribs().getB(""TrainingCentreSecureZoneDoor"")) e.getPlayer().sendMessage(""This door is locked, maybe there is a way to unlock it?""); else{ e.getPlayer().useStairs(Tile.of(3143, 4270, 0)); e.getPlayer().faceWest(); } }); public static ObjectClickHandler handleSecureZoneChest = new ObjectClickHandler(new Object[] { 29734 }, Tile.of(3166, 4259, 0), e -> { if(e.getPlayer().getEmotesManager().unlockedEmote(EmotesManager.Emote.SAFETY_FIRST)) { e.getPlayer().sendMessage(""You have already looted this chest.""); } else { e.getPlayer().save(""sopsRew"", true); e.getPlayer().simpleDialogue(""You open the chest to find a large pile of gold, along with a pair of safety gloves, and two antique lamps. Also in the chest is the secret to the 'Safety First' emote.""); e.getPlayer().getEmotesManager().unlockEmote(EmotesManager.Emote.SAFETY_FIRST); e.getPlayer().getInventory().addCoins(10000); if(e.getPlayer().getInventory().hasFreeSlots()) e.getPlayer().getInventory().addItem(12629); else World.addGroundItem(new Item(12629),e.getPlayer().getTile(),e.getPlayer()); if(e.getPlayer().getInventory().hasFreeSlots()) e.getPlayer().getInventory().addItem(12628); else World.addGroundItem(new Item(12628),e.getPlayer().getTile(),e.getPlayer()); if(e.getPlayer().getInventory().hasFreeSlots()) e.getPlayer().getInventory().addItem(12628); else World.addGroundItem(new Item(12628),e.getPlayer().getTile(),e.getPlayer()); } }); }" "package com.rs.game.content.world.areas.taverley; @PluginEventHandler public class Taverley { public static ObjectClickHandler handleTaverleyHouseStaircase = new ObjectClickHandler(new Object[] { 66637, 66638 }, e -> { Player p = e.getPlayer(); GameObject o = e.getObject(); Tile tile = o.getTile(); if (e.getObjectId() == 66637) { if (tile.isAt(2928, 3445, 0)) { if (p.getQuestManager().getStage(Quest.WOLF_WHISTLE) == WolfWhistle.WOLPERTINGER_MATERIALS) { if (!p.getInventory().containsItem(WolfWhistle.EMBROIDERED_POUCH) && !p.getBank().containsItem(WolfWhistle.EMBROIDERED_POUCH, 1)) { p.forceTalk(""Okay, that pouch has to be here somewhere...""); } } } tile = switch (o.getRotation()) { case 0 -> tile.transform(0, 2, 1); case 1 -> tile.transform(2, 0, 1); case 2 -> tile.transform(0, -1, 1); default -> tile.transform(-1, 0, 1); }; } else if (e.getObjectId() == 66638) { tile = switch (o.getRotation()) { case 0 -> tile.transform(-1, -1, -1); case 1 -> tile.transform(-1, 1, -1); case 2 -> tile.transform(1, 2, -1); default -> tile.transform(2, -1, -1); }; } p.useStairs(-1, tile, 0, 0); }); public static ObjectClickHandler handleWell = new ObjectClickHandler(new Object[] { 67498 }, e -> { Player p = e.getPlayer(); if (p.getQuestManager().getStage(Quest.WOLF_WHISTLE) == WolfWhistle.NOT_STARTED) { p.startConversation(new Dialogue() .addSimple(""I'm sure there is nothing down there. It's just an old, dry well that is making funny echoes."") ); } else if (p.getQuestManager().getStage(Quest.WOLF_WHISTLE) == WolfWhistle.PIKKUPSTIX_HELP) { /* TODO: start cutscene * set up cutscene props * cutscene fade to black, fade to white at bottom of well * .addPlayer(HeadE.ANGRY, ""All right you trolls, let the druid go!"") * zoom out to room * .addPlayer(HeadE.WORRIED, ""Wow...there certainly are a lot of you..."") * .addNPC(WOLF_MEAT, HeadE.LAUGH, ""Hur hur hur, more food come to us!"") * .addPlayer(HeadE.ANGRY, ""I warn you, you'd better let him go!"") * .addNPC(WOLF_BONES, HeadE.SHAKE, ""Or what? Wolf Bones tink you're not gonna last long!"") * .addNPC(WOLF_MEAT, HeadE.LAUGH, ""Specially not if we cut 'em into little bitty bites!"") * .addPlayer(HeadE.TERRIFIED, ""Bowloftrix! Don't worry. I'm going to go and get help!"") * .addNPC(BOWLOFTRIX, HeadE.?, ""Please hurry!"") * If player has already been in the well another different cutscene plays. * .addPlayer(HeadE.ANGRY, ""Alright, trolls. Time for round two!"") */ } else { // TODO: create well instance filled with trolls } }); public static ObjectClickHandler handleSummoningObelisk = new ObjectClickHandler(new Object[] { 67036 }, e -> { Player p = e.getPlayer(); switch (e.getOption()) { case ""Infuse-pouch"" -> { if (p.getQuestManager().getStage(Quest.WOLF_WHISTLE) == WolfWhistle.WOLPERTINGER_CREATION) { if (WolfWhistle.wolfWhistleObeliskReadyToInfusePouch(p)) { WolfWhistle.doWolpertingerPouchCreation(p, e.getObject()); break; } } Summoning.openInfusionInterface(p, false); break; } case ""Renew-points"" -> { int summonLevel = p.getSkills().getLevelForXp(Constants.SUMMONING); if (p.getSkills().getLevel(Constants.SUMMONING) < summonLevel) { p.lock(3); p.setNextAnimation(new Animation(8502)); p.getSkills().set(Constants.SUMMONING, summonLevel); p.sendMessage(""You have recharged your Summoning points."", true); break; } p.sendMessage(""You already have full Summoning points.""); } } }); public static ObjectClickHandler handleTaverleyDungeonOddWall = new ObjectClickHandler(new Object[] { 2117 }, e -> Doors.handleDoor(e.getPlayer(), e.getObject(), -1)); public static PickupItemHandler zammyWines = new PickupItemHandler(new Object[] { 245 }, new Tile[] { Tile.of(2946, 3474, 0), Tile.of(2946, 3473, 0) }, e -> { if (!e.isTelegrabbed()) { e.getPlayer().applyHit(new Hit(e.getPlayer(), 50, Hit.HitLook.TRUE_DAMAGE)); for (NPC n : e.getPlayer().queryNearbyNPCsByTileRange(7, n -> n.getId() == 189)) { if (n.isDead()) continue; n.forceTalk(""Hands off Zamorak's wine!""); n.setTarget(e.getPlayer()); } e.cancelPickup(); } }); //Nora T. Hagg House public static ObjectClickHandler handlenorathaggstairs = new ObjectClickHandler(new Object[] { 24672, 24673 }, e -> { if (e.getObjectId() == 24672) e.getPlayer().tele(e.getPlayer().transform(e.getObject().getRotation() == 0 ? -0 : e.getObject().getRotation() == 1 ? -0 : 0, e.getObject().getRotation() == 0 ? 4 : e.getObject().getRotation() == 1 ? -0 : 0, 1)); else if (e.getObjectId() == 24673) e.getPlayer().tele(e.getPlayer().transform(e.getObject().getRotation() == 0 ? 0 : e.getObject().getRotation() == 1 ? -0 : 0, e.getObject().getRotation() == 0 ? -4 : e.getObject().getRotation() == 1 ? -0 : 0, -1)); }); }" "package com.rs.game.content.world.areas.taverley const val AUSTRI_ID = 232 const val VESTRI_ID = 3679 @ServerStartupEvent fun handleShortcutStairs() { onObjectClick(54, 55, 56, 66990) { (player, obj) -> val targetLocation = when { obj.id == 54 && obj.x == 2820 && obj.y == 9883 -> Tile.of(2820, 3486, 0) obj.id == 55 && obj.x == 2820 && obj.y == 3484 -> Tile.of(2821, 9882, 0) obj.id == 56 && obj.x == 2876 && obj.y == 9880 -> Tile.of(2879, 3465, 0) obj.id == 66990 && obj.x == 2876 && obj.y == 3462 -> Tile.of(2876, 9879, 0) else -> null } if (targetLocation != null && player.questManager.getStage(Quest.FISHING_CONTEST) == QUEST_COMPLETE) { player.useStairs(-1, targetLocation, 0, 1) } else { val npcId = if (obj.id == 66990) AUSTRI_ID else VESTRI_ID World.getNPCsInChunkRange(player.chunkId, 2).firstOrNull { it.id == npcId }?.let { player.setRouteEvent(RouteEvent(it) { player.faceEntity(it) it.faceEntity(player) player.startConversation(DwarfBrothersFishingContestD(player, npcId).start) }) } } } } @ServerStartupEvent fun handleDwarfNPCDialogue() { onNpcClick(AUSTRI_ID, VESTRI_ID, options = arrayOf(""Talk-to"")) { e -> val npcId = e.npc.id e.player.startConversation(DwarfBrothersFishingContestD(e.player, npcId).start) } }" "package com.rs.game.content.world.areas.taverley.npcs; @PluginEventHandler public class AlisonElmshaper extends Conversation { private static final int npcId = 14858; public AlisonElmshaper(Player player) { super(player); addNPC(npcId, HeadE.CALM_TALK, ""Oh, hello. Need something?""); addOptions(new Options() { @Override public void create() { option(""I need fletching supplies"", () -> ShopsHandler.openShop(player, ""alison_fletch_shop"")); option(""Farewell""); } }); create(); } public static NPCClickHandler AlisonElmshaperHandler = new NPCClickHandler(new Object[] { npcId }, e -> { if (e.getOption().equalsIgnoreCase(""talk-to"")) e.getPlayer().startConversation(new AlisonElmshaper(e.getPlayer())); if (e.getOption().equalsIgnoreCase(""trade"")) ShopsHandler.openShop(e.getPlayer(), ""alison_fletch_shop""); }); }" "package com.rs.game.content.world.areas.taverley.npcs; @PluginEventHandler public class ApprenticeClara extends Conversation { private static final int npcId = 14906; public static NPCInteractionDistanceHandler rcShopsDistance = new NPCInteractionDistanceHandler(new Object[] { 14906, 14872 }, (p, n) -> 2); public ApprenticeClara(Player player) { super(player); addNPC(npcId, HeadE.HAPPY_TALKING, ""So many runes...""); addPlayer(HeadE.ROLL_EYES, ""Are you alright?""); addNPC(npcId, HeadE.HAPPY_TALKING, ""Oh! Don't worry. I'm trying to learn about runes from Mistress Carwen. It's a fascinating subject!""); addOptions(new Options() { @Override public void create() { option(""I need Runecrafting supplies"", () -> ShopsHandler.openShop(player, ""carwens_rune_shop"")); option(""What can you tell me about Runecrafting?"", new Dialogue().addNPC(npcId, HeadE.HAPPY_TALKING, ""There's so much to talk about! I'm just learning the ropes though. You'd be"" + "" better off talking to Mistress Carwen. As part of my duties I do help her by selling runes. Would you like to"" + "" take a look?"") .addPlayer(HeadE.CALM, ""I'll have a look."").addNext(() -> ShopsHandler.openShop(player, ""carwens_rune_shop""))); option(""Farewell""); } }); create(); } public static NPCClickHandler ApprenticeClaraHandler = new NPCClickHandler(new Object[] { npcId }, e -> { if (e.getOption().equalsIgnoreCase(""talk-to"")) e.getPlayer().startConversation(new ApprenticeClara(e.getPlayer())); if (e.getOption().equalsIgnoreCase(""trade"")) ShopsHandler.openShop(e.getPlayer(), ""carwens_rune_shop""); }); }" "package com.rs.game.content.world.areas.taverley.npcs; @PluginEventHandler public class AylethBeaststalker extends Conversation { private static final int npcId = 14864; public AylethBeaststalker(Player player) { super(player); addNPC(npcId, HeadE.TALKING_ALOT, ""I walk the lonely path of the hunter. Will you walk with me? Wait, did that make sense?""); addOptions(new Options() { @Override public void create() { option(""I need hunter supplies"", () -> ShopsHandler.openShop(player, ""ayleths_hunting_supplies"")); option(""Farewell""); } }); create(); } public static NPCClickHandler AylethBeaststalkerHandler = new NPCClickHandler(new Object[] { npcId }, e -> { if (e.getOption().equalsIgnoreCase(""talk-to"")) e.getPlayer().startConversation(new AylethBeaststalker(e.getPlayer())); if (e.getOption().equalsIgnoreCase(""trade"")) ShopsHandler.openShop(e.getPlayer(), ""ayleths_hunting_supplies""); }); }" "package com.rs.game.content.world.areas.taverley.npcs; @PluginEventHandler public class CarwenEssencebinder extends Conversation { private static final int npcId = 14872; public CarwenEssencebinder(Player player, NPC npc) { super(player); addNPC(npcId, HeadE.HAPPY_TALKING, ""Welcome to my shop, friend. Are you here to practice runecrafting?""); addPlayer(HeadE.ROLL_EYES, ""Are you alright?""); addOptions(new Options() { @Override public void create() { option(""Can you teleport me to the Essence Mine?"", () -> RunecraftingAltar.handleEssTele(player, npc)); option(""What can you tell me about Runecrafting?"", new Dialogue() .addNPC(npcId, HeadE.HAPPY_TALKING,""When you cast a spell, you tap into the latent power of runes."") .addNPC(npcId, HeadE.HAPPY_TALKING,""Naturally occuring runes are incredibly rare, but the recent rediscovered art of runecrafting allows us to create them ourselves."") .addNPC(npcId, HeadE.HAPPY_TALKING,""By acquiring essence stones and infusing them at an elemental altar, you make it possible for mages to work their magic."") .addPlayer(HeadE.CALM, ""I'll have a look."") ); option(""Farewell""); } }); create(); } public static NPCClickHandler CarwenEssencebinderHandler = new NPCClickHandler(new Object[] { npcId }, e -> { if (e.getOption().equalsIgnoreCase(""talk-to"")) e.getPlayer().startConversation(new CarwenEssencebinder(e.getPlayer(), e.getNPC())); if (e.getOption().equalsIgnoreCase(""teleport"")) RunecraftingAltar.handleEssTele(e.getPlayer(), e.getNPC()); }); }" "package com.rs.game.content.world.areas.taverley.npcs; @PluginEventHandler public class FarmerJones extends Conversation { private static final int npcId = 14860; public FarmerJones(Player player) { super(player); addNPC(npcId, HeadE.CALM, ""Can I help you with your farming troubles?""); addOptions(new Options() { @Override public void create() { option(""I need farming supplies"", () -> ShopsHandler.openShop(player, ""head_farmer_jones_shop"") ); option(""Tell me more about farming"", new Dialogue().addNPC(npcId, HeadE.HAPPY_TALKING, ""By farming you can grow your own plants. You'll start with simple stuff like potatoes"" + "" but if you stick at it, you'll even be able to grow trees and the like. Farming's a slow-paced skill. If you want"") .addNPC(npcId, HeadE.CALM, "" something that only needs checking on occasionally, it'll suit you down to the ground. Plant as many crops as ya can,"" + "" as often as ya can. It's only through practice that you'll improve."")); option(""Farewell""); } }); create(); } public static NPCClickHandler FarmerJonesHandler = new NPCClickHandler(new Object[] { npcId }, e -> { if (e.getOption().equalsIgnoreCase(""talk-to"")) e.getPlayer().startConversation(new FarmerJones(e.getPlayer())); if (e.getOption().equalsIgnoreCase(""trade"")) ShopsHandler.openShop(e.getPlayer(), ""head_farmer_jones_shop""); }); }" "package com.rs.game.content.world.areas.taverley.npcs; @PluginEventHandler public class JackOval extends Conversation { private static final int npcId = 14877; public JackOval(Player player) { super(player); addNPC(npcId, HeadE.HAPPY_TALKING, ""You need to make things. Leather. Pottery. Every piece you make will increase your skill.""); addOptions(new Options() { @Override public void create() { option(""I need crafting supplies"", () -> ShopsHandler.openShop(player, ""jack_crafting_shop"")); option(""I need you to tan some leather for me."", () -> player.startConversation(new TanningD(player, false, npcId))); option(""Farewell""); } }); create(); } public static NPCClickHandler JackOvalHandler = new NPCClickHandler(new Object[] { npcId }, e -> { if (e.getOption().equalsIgnoreCase(""talk-to"")) e.getPlayer().startConversation(new JackOval(e.getPlayer())); if (e.getOption().equalsIgnoreCase(""trade"")) ShopsHandler.openShop(e.getPlayer(), ""jack_crafting_shop""); if (e.getOption().equalsIgnoreCase(""tan-hide"")) e.getPlayer().startConversation(new TanningD(e.getPlayer(),false, npcId)); }); }" "package com.rs.game.content.world.areas.taverley.npcs; @PluginEventHandler public class MarcusEverburn extends Conversation { private static final int npcId = 14883; public MarcusEverburn(Player player) { super(player); addNPC(npcId, HeadE.HAPPY_TALKING, ""Hey! Let's SET SOMETHING ON FIRE!""); addOptions(new Options() { @Override public void create() { option(""I need firemaking supplies"", () -> ShopsHandler.openShop(player, ""marcus_firemaking_shop"")); option(""Farewell""); } }); create(); } public static NPCClickHandler MarcusEverburnHandler = new NPCClickHandler(new Object[] { npcId }, e -> { if (e.getOption().equalsIgnoreCase(""talk-to"")) e.getPlayer().startConversation(new MarcusEverburn(e.getPlayer())); if (e.getOption().equalsIgnoreCase(""trade"")) ShopsHandler.openShop(e.getPlayer(), ""marcus_firemaking_shop""); }); }" "package com.rs.game.content.world.areas.taverley.npcs; @PluginEventHandler public class MartinSteelweaver extends Conversation { private static final int npcId = 14874; public MartinSteelweaver(Player player) { super(player); addNPC(npcId, HeadE.HAPPY_TALKING, ""Do you need smithing help?""); addOptions(new Options() { @Override public void create() { option(""I need smithing supplies"", () -> ShopsHandler.openShop(player, ""martin_smithing_shop"")); option(""Farewell""); } }); create(); } public static NPCClickHandler MartinSteelweaverHandler = new NPCClickHandler(new Object[] { npcId }, e -> { if (e.getOption().equalsIgnoreCase(""talk-to"")) e.getPlayer().startConversation(new MartinSteelweaver(e.getPlayer())); if (e.getOption().equalsIgnoreCase(""trade"")) ShopsHandler.openShop(e.getPlayer(), ""martin_smithing_shop""); }); }" "package com.rs.game.content.world.areas.taverley.npcs; @PluginEventHandler public class NicholasAngle extends Conversation { private static final int npcId = 14879; public NicholasAngle(Player player) { super(player); addNPC(npcId, HeadE.CALM, ""I'm not surprised you want to fish. Fishing is great!""); addOptions(new Options() { @Override public void create() { option(""I need fishing bait"", () -> ShopsHandler.openShop(player, ""nicholas_fishing_shop"")); option(""Tell me more about fishing"", new Dialogue().addNPC(npcId, HeadE.HAPPY_TALKING, ""Fishing is more than a method of gathering food. It's more than a profession. "" + ""It's a way of life! Fish makes good eating, especially when you need to recover after battle."")); option(""Farewell""); } }); create(); } public static NPCClickHandler NicholasAngleHandler = new NPCClickHandler(new Object[] { npcId }, e -> { if (e.getOption().equalsIgnoreCase(""talk-to"")) e.getPlayer().startConversation(new NicholasAngle(e.getPlayer())); if (e.getOption().equalsIgnoreCase(""trade"")) ShopsHandler.openShop(e.getPlayer(), ""nicholas_fishing_shop""); }); }" "package com.rs.game.content.world.areas.taverley.npcs; @PluginEventHandler public class PetShopOwner extends Conversation { final static int PETSHOPOWNER = 6893; static final int WHITE_HARE_MEAT = 23067; public PetShopOwner(Player p) { super(p); if (p.getQuestManager().getStage(Quest.WOLF_WHISTLE) == WolfWhistle.WOLPERTINGER_MATERIALS) { addOptions(""Select an Option"", new Options() { @Override public void create() { if (!p.getInventory().containsItem(WHITE_HARE_MEAT) && !p.getBank().containsItem(WHITE_HARE_MEAT, 1)) { if (p.getQuestManager().getAttribs(Quest.WOLF_WHISTLE).getB(""HARE_MEAT"")) { option(""Ask about the white hare meat."", new Dialogue() .addPlayer(HeadE.CONFUSED, ""Hello there, do you sell white hare meat?"") .addNPC(PETSHOPOWNER, HeadE.CONFUSED, ""Well I do, but what about the portion I gave you earlier?"") .addPlayer(HeadE.SAD, ""I may have accidentally lost it."") .addItem(WHITE_HARE_MEAT, ""The pet shop owner gives you a portion of white hare meat."", () -> p.getInventory().addItem(WHITE_HARE_MEAT)) .addNPC(PETSHOPOWNER, HeadE.CONFUSED, ""I do hope this emergency is cleared up soon. I only have a few bits left!"") ); } else { option(""Ask about the white hare meat."", new Dialogue() .addPlayer(HeadE.CONFUSED, ""Hello there, do you sell white hare meat?"") .addNPC(PETSHOPOWNER, HeadE.CHUCKLE, ""Yes I do! I stock it as a treat for the animals, but some people round here snap it up for themselves! Waste not, want not!"") .addNPC(PETSHOPOWNER, HeadE.CHEERFUL_EXPOSITION, ""I get it imported from a very reputable trapper in Morytania called Rufus."") .addNPC(PETSHOPOWNER, HeadE.CHEERFUL, ""He always knows how to get the best meat for the animals and ships it pre-skinned, boned and cut. White hare, basilisk, chinchompa, veal..."") .addPlayer(HeadE.CALM, ""That's all very interesting, but do you happen to have some white hare meat I could have? It is an emergency."") .addNPC(PETSHOPOWNER, HeadE.CALM, ""Well if it is an emergency I suppose I can let you have some. I hope things work out for you!"") .addItem(WHITE_HARE_MEAT, ""The pet shop owner gives you a portion of white hare meat."", () -> { p.getInventory().addItem(WHITE_HARE_MEAT); p.getQuestManager().getAttribs(Quest.WOLF_WHISTLE).setB(""HARE_MEAT"", true); }) .addNPC(PETSHOPOWNER, HeadE.CONFUSED, ""Is there anything else I can help you with?"") .addNext(() -> p.startConversation(new PetShopOwner(p))) ); } } else { option(""Ask about the white hare meat."", new Dialogue() .addNPC(PETSHOPOWNER, HeadE.CONFUSED, ""Well I do, but what about the portion I gave you earlier?"") .addPlayer(HeadE.CONFUSED, ""Uh, right, now I remember where I put it. Thanks."") ); } option(""Ask about something else.""); } }); } else addNPC(PETSHOPOWNER, HeadE.CHEERFUL, ""Hello!""); } public static NPCClickHandler handlePetshopownerDialogue = new NPCClickHandler(new Object[] { PETSHOPOWNER }, e -> { if (e.getOption().toLowerCase().equals(""talk-to"")) e.getPlayer().startConversation(new PetShopOwner(e.getPlayer())); else if (e.getOption().toLowerCase().equals(""trade"")) ShopsHandler.openShop(e.getPlayer(), ""taverly_pet_shop""); }); }" "package com.rs.game.content.world.areas.taverley.npcs; @PluginEventHandler public class Pikkupstix extends Conversation { final static int PIKKUPSTIX = 6988; // right click options final static int TALK_TO = 1; final static int TRADE = 3; final static int ENCHANT = 4; public Pikkupstix(Player p, NPC pikkupstix, boolean greeting) { super(p); if (greeting) { addNPC(PIKKUPSTIX, HeadE.HAPPY_TALKING, ""Hello there! Welcome to my humble abode. How can I help you?""); } addOptions(""Choose an option:"", new Options() { @Override public void create() { option(""I have a question about Summoning..."", new Dialogue() .addOptions(new Options() { @Override public void create() { option(""So, what's Summoning all about, then?"", new Dialogue() .addNPC(PIKKUPSTIX, HeadE.CONFUSED, ""In general? Or did you have a specific topic mind?"") .addOptions(new Options() { @Override public void create() { option(""In general."", new Dialogue() .addNPC(PIKKUPSTIX, HeadE.CALM_TALK, ""Well, you already know about Summoning in general; otherwise, we would not be having this conversation!"") .addNPC(PIKKUPSTIX, HeadE.CALM_TALK, ""Effectively, the skill can be broken into three main parts: summoned familiars, charged items and pets."") .addNPC(PIKKUPSTIX, HeadE.CALM_TALK, ""Summoned familiars are spiritual animals that can be called to you from the spirit plane, to serve you for a period of time."") .addNPC(PIKKUPSTIX, HeadE.CALM_TALK, ""These animals can also perform a special move, which is specific to the species. For example, a spirit wolf can perform the Howl special move if you are holding the correct Howl scroll."") .addNPC(PIKKUPSTIX, HeadE.CALM_TALK, ""Charged items contain summoning power, but in a stable form."") .addNPC(PIKKUPSTIX, HeadE.CALM_TALK, ""They can be used to physically store any scrolls you have"") .addNPC(PIKKUPSTIX, HeadE.CALM_TALK, ""Those are the main effects of Summoning."") .addNPC(PIKKUPSTIX, HeadE.CONFUSED, ""Are you still following me?"") .addPlayer(HeadE.CALM_TALK, ""Yes, I think so."") .addNPC(PIKKUPSTIX, HeadE.CALM_TALK, ""I can supply you with pouches and spirit shards, but you will have to bring your own charms and secondary ingredients."") .addNPC(PIKKUPSTIX, HeadE.CALM_TALK, ""Many creatures drop charms when you kill them in combat."") .addNPC(PIKKUPSTIX, HeadE.CALM_TALK, ""There are many different charms in the world: gold, blue, green, crimson and even some specialist ones like obsidian or void."") .addPlayer(HeadE.CALM_TALK, ""I'll be sure to keep my eyes open for them."") .addNPC(PIKKUPSTIX, HeadE.CALM_TALK, ""The best way to raise your Summoning level is to infuse pouches."") .addNPC(PIKKUPSTIX, HeadE.CALM_TALK, ""You will still learn a little from summoning a familiar, as well as using a scroll and transforming the summoning pouches into scrolls."") .addNPC(PIKKUPSTIX, HeadE.CALM_TALK, ""But nothing is more potent than infusing a spirit into a Summoning pouch in the first place."") .addNPC(PIKKUPSTIX, HeadE.CONFUSED, ""Do you understand?"") .addPlayer(HeadE.CHEERFUL_EXPOSITION, ""Sure!"") .addNPC(PIKKUPSTIX, HeadE.CHEERFUL_EXPOSITION, ""Good!"") .addNPC(PIKKUPSTIX, HeadE.CONFUSED, ""Where was I?"") .addNPC(PIKKUPSTIX, HeadE.CALM_TALK, ""Ah, yes, the last part of Summoning: the pets. The more you practice the skill, the more you will comprehend the natural world around you."") .addNPC(PIKKUPSTIX, HeadE.CALM_TALK, ""This is reflected in your increased ability to raise animals as pets, It takes a skilled summoner to be able to raise some of Gielinor's more exotic animals, such as the lizards of Karamja, or even dragons!"") //.addNPC(PIKKUPSTIX, HeadE.CALM_TALK, ""Now that I've given you this overview, do you want to know about anything specific?"") LOOP ME ); option(""Tell me about summoning familiars."", new Dialogue() .addNPC(PIKKUPSTIX, HeadE.CALM_TALK, ""Summoned familiars are at the very core of Summoning. Each familiar is different, and the more powerful the summoner, the more powerful the familiar they can summon."") .addNPC(PIKKUPSTIX, HeadE.CALM_TALK, ""The animals themselves are not real, in the sense that you or I are real; they are spirits drawn from the spirit plane."") .addNPC(PIKKUPSTIX, HeadE.CALM_TALK, ""As a result, they have powers that the animals they resemble do not."") .addNPC(PIKKUPSTIX, HeadE.CALM_TALK, ""They cannot remain in this world indefinitely; they require a constant supply of energy to maintain their link to the spirit plane."") .addNPC(PIKKUPSTIX, HeadE.CALM_TALK, ""This energy is drained from your Summoning skill points."") .addNPC(PIKKUPSTIX, HeadE.CALM_TALK, ""Your level of the Summoning skill is not drained, and you can refresh your points back up to your maximum level at an obelisk whenever you wish."") .addPlayer(HeadE.CONFUSED, ""So, my Summoning skill points are like food to them?"") .addNPC(PIKKUPSTIX, HeadE.CHEERFUL_EXPOSITION, ""Yes, that is an appropriate analogy."") .addNPC(PIKKUPSTIX, HeadE.CALM_TALK, ""The more powerful the familiar, the more it must 'feed' and the more 'food' it will need to be satisfied."") .addNPC(PIKKUPSTIX, HeadE.CALM_TALK, ""As a result, only the most powerful summoners are able to maintain a link from a familiar to the spirit plane, since they are able to provide more 'food' with each Summoning level they gain."") .addPlayer(HeadE.CALM_TALK, ""I'm starting to get a little hungry now."") .addNPC(PIKKUPSTIX, HeadE.CALM_TALK, ""As you gain mastery of the skill you will be able to have familiars out for the full time they exist. And still have some points over to re-summon them afterwards, if you wish."") .addNPC(PIKKUPSTIX, HeadE.CALM_TALK, ""This is because you are able to feed them the energy they need and have leftovers to spare!"") .addPlayer(HeadE.CHEERFUL_EXPOSITION, ""Great!"") .addPlayer(HeadE.CONFUSED, ""So, what can these familiars do?"") .addNPC(PIKKUPSTIX, HeadE.LAUGH, ""Why not ask me to count every blade of grass on a lawn?"") .addNPC(PIKKUPSTIX, HeadE.CALM_TALK, ""The familiars each have unique abilities and even the most experience summoner will not know them all."") .addPlayer(HeadE.CALM_TALK, ""Well, can you give me some hints?"") .addNPC(PIKKUPSTIX, HeadE.CALM_TALK, ""Well, some familiars are able to fight with you in combat. They will keep an eye out to see if you are fighting and will intervene, if they can."") .addNPC(PIKKUPSTIX, HeadE.CALM_TALK, ""Other familiars will not fight, for various reasons, but they may provide bonuses in other tasks. Some will even carry your items for you, if you need them to."") .addPlayer(HeadE.CHEERFUL_EXPOSITION, ""Amazing!"") .addNPC(PIKKUPSTIX, HeadE.CALM_TALK, """") //.addNPC(PIKKUPSTIX, HeadE.CALM_TALK, ""Would you like to know anything else about summoning?"") LOOP ME ); if (player.getQuestManager().isComplete(Quest.WOLF_WHISTLE)) { option(""Tell me about special moves."", new Dialogue() .addNPC(PIKKUPSTIX, HeadE.CALM_TALK, ""Well, if a Summoning pouch is split apart at an obselisk, then the energy it contained will reconstritue itself - transform - into a scroll. This scroll can then be used to make your familiar perform its special move."") .addNPC(PIKKUPSTIX, HeadE.CALM_TALK, ""For example, spirit wolves are able to Howl, scaring away an opponent for a short period of time."") .addNPC(PIKKUPSTIX, HeadE.CALM, ""Well, each familiar has its own special move, and you can only use scrolls on the familiar that it applies to."") .addPlayer(HeadE.LAUGH, ""Or longer, in the case of that giant wolpertinger."") .addNPC(PIKKUPSTIX, HeadE.LAUGH, ""Indeed!"") .addNPC(PIKKUPSTIX, HeadE.CALM, ""Well, each familiar has its own special move, and you can only use scrolls on the familiar that it applies to."") .addNPC(PIKKUPSTIX, HeadE.CALM_TALK, ""For example, a spirit wolf will only look at you oddly if you wish it to perform a dreadfowl special move."") .addPlayer(HeadE.CONFUSED, ""So, what sort of special moves are there?"") .addNPC(PIKKUPSTIX, HeadE.CALM_TALK, ""The special moves are as varied as the familiars themselves."") .addNPC(PIKKUPSTIX, HeadE.CALM_TALK, ""A good rule of thumb is that if a familiar helps you in combat, then its special move is likely to damage attackers when you use a scroll."") .addNPC(PIKKUPSTIX, HeadE.CALM_TALK, ""On the other hand, if a familiar is more peaceful by nature, then its special move might heal or provide means to train your other skill - that sort of thing."") .addPlayer(HeadE.CONFUSED, ""Are the familiar's special moves similar to its normal abilities?"") .addNPC(PIKKUPSTIX, HeadE.CALM_TALK, ""In general, no. But some familiars' special moves can be a more powerful verison of their normal ability."") .addNPC(PIKKUPSTIX, HeadE.CALM_TALK, ""Take the spirit wolf, for example. Its special move and its normal ability are essentially the same."") .addNPC(PIKKUPSTIX, HeadE.CALM_TALK, ""However, the special move can be used on any nearby opponent, while the normal ability only works on those opponents you are currently fighting."") .addNPC(PIKKUPSTIX, HeadE.CALM_TALK, ""If your familiar is fighting with you, it will use its normal ability whenever it can."") .addNPC(PIKKUPSTIX, HeadE.CALM_TALK, ""It won't however, use its special move unless you have expressly asked it to, by activating a scroll."") .addPlayer(HeadE.CALM_TALK, ""I see. Thanks for the information."") //.addNPC(PIKKUPSTIX, HeadE.CALM_TALK, ""Would you like to know anything else about summoning?"") LOOP ME ); } else { option(""Tell me about special moves."", new Dialogue() .addNPC(PIKKUPSTIX, HeadE.CALM_TALK, ""Well, if a Summoning pouch is split apart at an obselisk, then the energy it contained will reconstritue itself - transform - into a scroll. This scroll can then be used to make your familiar perform its special move."") .addNPC(PIKKUPSTIX, HeadE.CALM_TALK, ""For example, spirit wolves are able to Howl, scaring away an opponent for a short period of time."") .addNPC(PIKKUPSTIX, HeadE.CALM, ""Well, each familiar has its own special move, and you can only use scrolls on the familiar that it applies to."") .addNPC(PIKKUPSTIX, HeadE.CALM_TALK, ""For example, a spirit wolf will only look at you oddly if you wish it to perform a dreadfowl special move."") .addPlayer(HeadE.CONFUSED, ""So, what sort of special moves are there?"") .addNPC(PIKKUPSTIX, HeadE.CALM_TALK, ""The special moves are as varied as the familiars themselves."") .addNPC(PIKKUPSTIX, HeadE.CALM_TALK, ""A good rule of thumb is that if a familiar helps you in combat, then its special move is likely to damage attackers when you use a scroll."") .addNPC(PIKKUPSTIX, HeadE.CALM_TALK, ""On the other hand, if a familiar is more peaceful by nature, then its special move might heal or provide means to train your other skill - that sort of thing."") .addPlayer(HeadE.CONFUSED, ""Are the familiar's special moves similar to its normal abilities?"") .addNPC(PIKKUPSTIX, HeadE.CALM_TALK, ""In general, no. But some familiars' special moves can be a more powerful verison of their normal ability."") .addNPC(PIKKUPSTIX, HeadE.CALM_TALK, ""Take the spirit wolf, for example. Its special move and its normal ability are essentially the same."") .addNPC(PIKKUPSTIX, HeadE.CALM_TALK, ""However, the special move can be used on any nearby opponent, while the normal ability only works on those opponents you are currently fighting."") .addNPC(PIKKUPSTIX, HeadE.CALM_TALK, ""If your familiar is fighting with you, it will use its normal ability whenever it can."") .addNPC(PIKKUPSTIX, HeadE.CALM_TALK, ""It won't however, use its special move unless you have expressly asked it to, by activating a scroll."") .addPlayer(HeadE.CALM_TALK, ""I see. Thanks for the information."") ); } option(""Tell me about charged items.""); // unimplemented option(""Tell me about pets."", new Dialogue() .addNPC(PIKKUPSTIX, HeadE.SAD_MILD_LOOK_DOWN, ""Unfortunately, pets are not implemented yet."") ); } })); option(""Can I buy some Summoning supplies?"", () -> ShopsHandler.openShop(player, ""taverly_summoning_shop"")); option(""Please tell me about skillcapes."", () -> player.startConversation(new GenericSkillcapeOwnerD(player, 6988, Skillcapes.Summoning))); } })); String quest_option = QuestPikkupstix.getNextOptionTextPikkupstix(p); if (quest_option != null) { option(quest_option, () -> p.startConversation(new QuestPikkupstix(p, pikkupstix))); } // only if you know about Pikkenmix // option(""Talk about Pikkenmix.""); if (p.getQuestManager().getStage(Quest.WOLF_WHISTLE) > WolfWhistle.WOLPERTINGER_CREATION) { option(""You really seem to have had some problems with your assistants."", new Dialogue() .addNPC(PIKKUPSTIX, HeadE.SAD, ""You are right, it has been pretty hard since the war started."") .addPlayer(HeadE.CONFUSED, ""Well what's happened? Have the trolls been killing them, or has it all been down to accidents?"") .addNPC(PIKKUPSTIX, HeadE.CALM, ""It is a mixture of both, really. To be honest, I have always found that my assistants have had a lot of eagerness and a lot less common sense for self-preservation."") .addNPC(PIKKUPSTIX, HeadE.CONFUSED, ""Now, let me see...You already know about Stikklebrix...who else was there?"") .addNPC(PIKKUPSTIX, HeadE.CALM, ""There was poor Lunatrix, who went mad. He tried to commune with some elder spirits, and they were not happy."") .addNPC(PIKKUPSTIX, HeadE.SAD_MILD_LOOK_DOWN, ""Last I saw of him, he went running out of the door with his pants on his head..."") .addNPC(PIKKUPSTIX, HeadE.CALM, ""Then there was Ashtrix. He managed to cut his own hand off, the poor fool."") .addNPC(PIKKUPSTIX, HeadE.SAD_MILD_LOOK_DOWN, ""It would have been all right, except he then managed to wedge a hacksaw in the stump, and in his delirium wouldn't let anyone help him."") .addNPC(PIKKUPSTIX, HeadE.CALM, ""Then there was Spartrix, who was captured by the Black Knights and taken as a slave."") .addNPC(PIKKUPSTIX, HeadE.SAD_MILD_LOOK_DOWN, ""I hear that he tried to lead a slaved rebellion. Which, while noble in itself, is not really the sort of thing a 5-foot, sickly, bookish druid should do."") .addNPC(PIKKUPSTIX, HeadE.SAD_MILD_LOOK_DOWN, ""Especially when unarmed and facing evil knights in full plate mail."") .addNPC(PIKKUPSTIX, HeadE.CONFUSED, ""Let's see...there was Beezeltrix and the smoke devil; we literally lost Felitrix; those trolls took the twins when they were healing soldiers on the front line..."") .addNPC(PIKKUPSTIX, HeadE.MORTIFIED, ""And the less said about Hastrix, the better!"") .addPlayer(HeadE.AMAZED, ""Wow...you really haven't had much luck with assistants."") .addNPC(PIKKUPSTIX, HeadE.SAD, ""It has been one heck of a busy week, I can tell you."") .addNPC(PIKKUPSTIX, HeadE.CONFUSED, ""Now, is there anything else you need?"") .addNext(() -> p.startConversation(new Pikkupstix(p, pikkupstix, false))) ); } } }); create(); } public static NPCClickHandler handlePikkupstixDialogue = new NPCClickHandler(new Object[] { PIKKUPSTIX }, e -> { Player p = e.getPlayer(); switch(e.getOption()) { case ""Talk-to"" -> p.startConversation(new Pikkupstix(e.getPlayer(), e.getNPC(), true)); case ""Trade"" -> ShopsHandler.openShop(p, ""taverly_summoning_shop""); case ""Enchant"" -> { for (Item i : p.getInventory().getItems().array()) { if ((null != i) && (null != EnchantedHeadwear.Headwear.forId(i.getId()))) { p.startConversation(new Dialogue() .addNPC(PIKKUPSTIX, HeadE.HAPPY_TALKING, ""That is a fine piece of headwear you have there. If you give me a closer look, I may be able to enchant it."") ); return; } } p.startConversation(new Dialogue() .addNPC(PIKKUPSTIX, HeadE.HAPPY_TALKING, ""If you bring me the right headwear, I may be able to assist in enchanting it."") ); } } }); }" "package com.rs.game.content.world.areas.taverley.npcs; @PluginEventHandler public class Poletax extends Conversation { private static final int npcId = 14854; public Poletax(Player player) { super(player); addNPC(npcId, HeadE.HAPPY_TALKING, ""Are you here to practice your herblore?""); addOptions(new Options() { @Override public void create() { option(""I need herblore supplies"", () -> ShopsHandler.openShop(player, ""poletaxs_herblore_shop"")); option(""Farewell""); } }); create(); } public static NPCClickHandler PoletaxHandler = new NPCClickHandler(new Object[] { npcId }, e -> { if (e.getOption().equalsIgnoreCase(""talk-to"")) e.getPlayer().startConversation(new Poletax(e.getPlayer())); if (e.getOption().equalsIgnoreCase(""trade"")) ShopsHandler.openShop(e.getPlayer(), ""poletaxs_herblore_shop""); }); }" "package com.rs.game.content.world.areas.taverley.npcs; @PluginEventHandler public class Rohak { public static NPCClickHandler handleRohak = new NPCClickHandler(new Object[] { ""Rohak"" }, e -> e.getPlayer().startConversation(new Dialogue().addOptions((ops) -> { ops.add(""Hot Dwarven Rock Cake"", () -> e.getPlayer().getInventory().addItemDrop(7509, 1)); ops.add(""Cool Dwarven Rock Cake"", () -> e.getPlayer().getInventory().addItemDrop(7510, 1)); }))); }" "package com.rs.game.content.world.areas.taverley.npcs; @PluginEventHandler public class Sanfew extends Conversation { final static int ENCHANTED_RAW_BEAR_MEAT = 524; final static int ENCHANTED_RAW_RAT_MEAT = 523; final static int ENCHANTED_RAW_CHICKEN = 525; final static int ENCHANTED_RAW_BEEF = 522; private final static int SANFEW = 454; static boolean hasEnchantedItems(Player player) { boolean hasItems = false; if(player.getInventory().containsItem(ENCHANTED_RAW_BEAR_MEAT) && player.getInventory().containsItem(ENCHANTED_RAW_RAT_MEAT) && player.getInventory().containsItem(ENCHANTED_RAW_CHICKEN) && player.getInventory().containsItem(ENCHANTED_RAW_BEEF)) hasItems = true; return hasItems; } public Sanfew(Player player) { super(player); switch(player.getQuestManager().getStage(Quest.DRUIDIC_RITUAL)) { case 1: addPlayer(HeadE.CALM_TALK, ""Hello there.""); addNPC(SANFEW, HeadE.CALM_TALK, ""What can I do for you young 'un?"", () -> player.voiceEffect(77263, false)); addPlayer(HeadE.CALM_TALK, ""I've been sent to assist you with the ritual to purify the Varrockian stone circle."", ()-> player.getPackets().resetSounds()); addNPC(SANFEW, HeadE.CALM_TALK, ""Well, what I'm struggling with right now is the meats needed for the potion to honour Guthix. I need the raw"" + "" meats of four different animals for it, ""); addNPC(SANFEW, HeadE.CALM_TALK, ""but not just any old meats will do. Each meat has to be dipped individually into the Cauldron of Thunder "" + ""for it to work correctly.""); addNPC(SANFEW, HeadE.CALM_TALK, ""I will need 4 raw meats put into the cauldron. They are rat, bear, beef and chicken""); addOptions(new Options() { @Override public void create() { option(""Where can I find this cauldron?"", new Dialogue() .addPlayer(HeadE.CALM_TALK, ""Where can I find this cauldron?"") .addNPC(SANFEW, HeadE.CALM_TALK, ""It is located somewhere in the mysterious underground halls which are located somewhere"" + "" in the woods just South of here. They are too dangerous for me to go myself however."") .addPlayer(HeadE.CALM_TALK, ""Ok, I'll go do that then."", () -> player.getQuestManager().setStage(Quest.DRUIDIC_RITUAL, 2))); option(""Ok, I'll go do that then."", () -> player.getQuestManager().setStage(Quest.DRUIDIC_RITUAL, 2)); } }); break; case 2: addNPC(SANFEW, HeadE.CALM_TALK, ""Did you bring me the required ingredients for the potion?""); if (hasEnchantedItems(player)) { addPlayer(HeadE.CALM_TALK, ""Yes, I have all four now!""); addNPC(SANFEW, HeadE.CALM_TALK, ""Well hand 'em over then lad! Thank you so much adventurer! These meats will allow our potion to honour "" + ""Guthix to be completed, and bring one step closer to reclaiming our stone circle! ""); addNPC(SANFEW, HeadE.CALM_TALK, ""Now go and talk to Kaqemeex and he will introduce you to the wonderful world of herblore and "" + ""potion making!"", () -> { player.getInventory().deleteItem(ENCHANTED_RAW_BEAR_MEAT, 1); player.getInventory().deleteItem(ENCHANTED_RAW_CHICKEN, 1); player.getInventory().deleteItem(ENCHANTED_RAW_RAT_MEAT, 1); player.getInventory().deleteItem(ENCHANTED_RAW_BEEF, 1); player.getQuestManager().setStage(Quest.DRUIDIC_RITUAL, 3); }); } else { addPlayer(HeadE.CALM_TALK, ""No, not yet...""); addNPC(SANFEW, HeadE.CALM_TALK, ""Well, let me know when you do young 'un.""); addPlayer(HeadE.CALM_TALK, ""I'll get on with it.""); } break; default: addNPC(SANFEW, HeadE.CALM_TALK, ""What can I do for you young 'un?"", ()-> player.voiceEffect(77263, false)); addPlayer(HeadE.CALM_TALK, ""Nothing at the moment."", ()->{ }); break; } create(); } public static NPCClickHandler sanfewHandler = new NPCClickHandler(new Object[] { SANFEW }, e -> { if (e.getOption().equalsIgnoreCase(""talk-to"")) e.getPlayer().startConversation(new Sanfew(e.getPlayer())); }); }" "package com.rs.game.content.world.areas.taverley.npcs; @PluginEventHandler public class Scalectrix extends Conversation { // npc id final static int SCALECTRIX = 15055; public Scalectrix(Player p) { super(p); switch (p.getQuestManager().getStage(Quest.WOLF_WHISTLE)) { case WolfWhistle.NOT_STARTED -> addNPC(SCALECTRIX, HeadE.WORRIED, ""Oh dear...oh dear..."") .addPlayer(HeadE.CONFUSED, ""Are you alright?"") .addSimple(""The young druidess seems intent on staring into the well and wringing her hands, and does not reply."") .addPlayer(HeadE.CONFUSED, ""Uh...ok then! Have a nice day!""); case WolfWhistle.FIND_SCALECTRIX -> addPlayer(HeadE.CONFUSED, ""Hey, are you Scalectrix; the assistant to Pikkupstix?"") .addNPC(SCALECTRIX, HeadE.AMAZED, ""Yes! How did you know that?"") .addPlayer(HeadE.CALM_TALK, ""He sent me to find you, apparently you were supposed to be back a while ago."") .addNPC(SCALECTRIX, HeadE.NERVOUS, ""Well, I would have come back, but Bowloftrix has been captured by trolls! I've been waiting here for someone to come and help me!"") .addPlayer(HeadE.ANGRY, ""Trolls! Where are they?"") .addNPC(SCALECTRIX, HeadE.WORRIED, ""They're in this well. But don't go in there! There are way too many to handle!"") .addNPC(SCALECTRIX, HeadE.WORRIED, ""We need something to keep them at bay or break them up; something that will scare them. I tried using a spirit wolf, but they just laughed."") .addNPC(SCALECTRIX, HeadE.SAD, ""The leaders seem immune to the howl of the spirit wolf...but without something to thin their numbers we'll never get Bowloftrix back!"") .addNPC(SCALECTRIX, HeadE.WORRIED, ""Please, sir, can you let Pikkupstix know what has happened? I'm sure with your help he can come up with something to drive away these trolls."") .addOptions(""Select an Option"", new Options() { @Override public void create() { // TODO: option(""Look, I'll just go and take a look myself..."", new Dialogue() .addPlayer(HeadE.CALM_TALK, ""Look, I'll just go and take a look myself. I am trained for this sort of thing, after all."") .addNPC(SCALECTRIX, HeadE.AMAZED_MILD, ""Be careful!"", () -> p.getQuestManager().setStage(Quest.WOLF_WHISTLE, WolfWhistle.PIKKUPSTIX_HELP))); option(""All right. Wait here, I'll be right back."", new Dialogue() .addPlayer(HeadE.CALM_TALK, ""Alright. Wait here, I'll be right back."", () -> p.getQuestManager().setStage(Quest.WOLF_WHISTLE, WolfWhistle.PIKKUPSTIX_HELP))); } }); case WolfWhistle.PIKKUPSTIX_HELP -> addNPC(SCALECTRIX, HeadE.CONFUSED, ""So what's the plan?"") .addPlayer(HeadE.CONFUSED, ""The...plan?"") .addNPC(SCALECTRIX, HeadE.AMAZED, ""The plan! The plan to save Bowloftrix!"") .addPlayer(HeadE.CALM, ""Oh! That plan! Sorry, I still need to speak to Pikkupstix to find out what he has in mind."") .addNPC(SCALECTRIX, HeadE.SAD_MILD_LOOK_DOWN, ""Well could you PLEASE hurry up?"") .addPlayer(HeadE.CALM, ""Hey, you can't rush heroism. I'll be right back.""); case WolfWhistle.WOLPERTINGER_POUCH_CHECK -> addNPC(SCALECTRIX, HeadE.CONFUSED, ""So what's the plan?"") .addPlayer(HeadE.CHEERFUL_EXPOSITION, ""I have made the giant wolpertinger pouch! I have it here, let's go!"") .addNPC(SCALECTRIX, HeadE.AMAZED, ""Wait, wait!"") .addNPC(SCALECTRIX, HeadE.CONFUSED, ""As pleased as I am that you have accomplished this feat, have you had the pouch checked by Pikkupstix?"") .addPlayer(HeadE.CONFUSED, ""Why do I need to do that? I mean, I'm a big darn hero. I know what I'm doing."") .addNPC(SCALECTRIX, HeadE.AMAZED, ""But that's a legendary summoning spirit! If something has gone wrong in the creation of the pouch then anything could happen!"") .addNPC(SCALECTRIX, HeadE.AMAZED, ""The last time someone tired to summon a giant wolpertinger, the pouch they used was slightly frayed, and the spirit was so offended...well...it..."") .addPlayer(HeadE.TERRIFIED, ""It what? Didn't work? It was a little upset?"") .addNPC(SCALECTRIX, HeadE.AMAZED, ""Well, if by 'didn't work' you mean his skull melted, then yes!"") .addPlayer(HeadE.TERRIFIED, ""I'm, uh, just going to take this to Pikkupstix...just in case."") .addNPC(SCALECTRIX, HeadE.SAD_MILD_LOOK_DOWN, ""Please, hurry back!""); case WolfWhistle.SAVE_BOWLOFTRIX -> { if (player.getInventory().containsItem(WolfWhistle.GIANT_WOLPERTINGER_POUCH)) { addNPC(SCALECTRIX, HeadE.CONFUSED, ""You're back! What's the news?"") .addPlayer(HeadE.CALM, ""I have a giant wolpertinger. Here, take a look."") .addNPC(SCALECTRIX, HeadE.AMAZED, ""A giant wolpertinger pouch...I never thought I'd see one."") .addNPC(SCALECTRIX, HeadE.AMAZED, ""With just the two of us it'll be a stretch, and we'll only be able to summon it for a few seconds, but that might be all the time we need."") .addPlayer(HeadE.HAPPY_TALKING, ""Come on, let's get Bowloftrix before he comes a bowl of Bowloftrix."") .addNext(() -> { if (player.hasFamiliar() || player.getPet() != null) { p.startConversation(new Dialogue() .addNPC(SCALECTRIX, HeadE.CALM_TALK, ""Wait, wait, we can't do this while you have a follower."") .addPlayer(HeadE.CONFUSED, ""Why not?"") .addNPC(SCALECTRIX, HeadE.CALM, ""Well you can only have one follower, and if you want to summon the wolpertinger with my help then you'll need to put that one away."") .addPlayer(HeadE.CALM, ""Fair enough. Give me a moment."") ); } else { p.playCutscene(new WolfWhistleWellCutscene()); } }); } else { addNPC(SCALECTRIX, HeadE.CONFUSED, ""You're back! What's the news?"") .addPlayer(HeadE.CALM_TALK, ""I have made a giant wolpertinger pouch, and I'm all ready to save Bowloftrix."") .addNPC(SCALECTRIX, HeadE.CHEERFUL_EXPOSITION, ""That's wonderful news! Can I see the pouch?"") .addPlayer(HeadE.CHEERFUL_EXPOSITION, ""Of course, here it..."") .addPlayer(HeadE.AMAZED, ""..."") .addPlayer(HeadE.SECRETIVE, ""...uh, give me a minute..."") .addNPC(SCALECTRIX, HeadE.CONFUSED, ""Oh...of course.""); } } } } public static NPCClickHandler handleScalectrixDialogue = new NPCClickHandler(new Object[] { SCALECTRIX }, e -> e.getPlayer().startConversation(new Scalectrix(e.getPlayer()))); }" "package com.rs.game.content.world.areas.taverley.npcs; @PluginEventHandler public class TobiasBronzearms extends Conversation { private static final int npcId = 14870; public TobiasBronzearms(Player player) { super(player); addNPC(npcId, HeadE.HAPPY_TALKING, ""Tobias Bronzearms at your service.""); addOptions(new Options() { @Override public void create() { option(""I need mining supplies"", () -> ShopsHandler.openShop(player, ""tobias_mining_shop"")); option(""Farewell""); } }); create(); } public static NPCClickHandler TobiasBronzearmsHandler = new NPCClickHandler(new Object[] { npcId }, e -> { if (e.getOption().equalsIgnoreCase(""talk-to"")) e.getPlayer().startConversation(new TobiasBronzearms(e.getPlayer())); if (e.getOption().equalsIgnoreCase(""trade"")) ShopsHandler.openShop(e.getPlayer(), ""tobias_mining_shop""); }); }" "package com.rs.game.content.world.areas.taverley.npcs; @PluginEventHandler public class WillOakfeller extends Conversation { private static final int npcId = 14885; public WillOakfeller(Player player) { super(player); addNPC(npcId, HeadE.HAPPY_TALKING, ""Want to do some woodcutting, mate?""); addOptions(new Options() { @Override public void create() { option(""I need woodcutting supplies"", () -> ShopsHandler.openShop(player, ""will_woodcut_shop"")); option(""Farewell""); } }); create(); } public static NPCClickHandler WillOakfellerHandler = new NPCClickHandler(new Object[] { npcId }, e -> { if (e.getOption().equalsIgnoreCase(""talk-to"")) e.getPlayer().startConversation(new WillOakfeller(e.getPlayer())); if (e.getOption().equalsIgnoreCase(""trade"")) ShopsHandler.openShop(e.getPlayer(), ""will_woodcut_shop""); }); }" "package com.rs.game.content.world.areas.thieves_guild; @PluginEventHandler public class TheivesGuild { public static LoginHandler login = new LoginHandler(e -> { if (Miniquest.A_GUILD_OF_OUR_OWN.isImplemented() && e.getPlayer().isMiniquestComplete(Miniquest.A_GUILD_OF_OUR_OWN, false)) { e.getPlayer().getVars().saveVarBit(7792, 40); return; } if (Miniquest.LOST_HER_MARBLES.isImplemented() && e.getPlayer().isMiniquestComplete(Miniquest.LOST_HER_MARBLES, false)) { e.getPlayer().getVars().saveVarBit(7792, 20); return; } if (Miniquest.FROM_TINY_ACORNS.isImplemented() && e.getPlayer().isMiniquestComplete(Miniquest.FROM_TINY_ACORNS, false)) { e.getPlayer().getVars().saveVarBit(7792, 10); return; } if (Quest.BUYERS_AND_CELLARS.isImplemented() && e.getPlayer().isQuestComplete(Quest.BUYERS_AND_CELLARS, null)) { e.getPlayer().getVars().saveVarBit(7792, 10); } }); public static ObjectClickHandler handleThievesGuildExitLadder = new ObjectClickHandler(new Object[]{ 52308 }, e -> e.getPlayer().useLadder(Tile.of(3223, 3269, 0)) ); public static ObjectClickHandler handleThievesGuildEntrance = new ObjectClickHandler(new Object[]{ 52309 }, e -> { if (e.getPlayer().getSkills().getLevel(Skills.THIEVING) <= 4) { e.getPlayer().sendMessage(""The cellar is securely locked.""); return; } if (Miniquest.A_GUILD_OF_OUR_OWN.isImplemented() && e.getPlayer().isMiniquestComplete(Miniquest.A_GUILD_OF_OUR_OWN, false)) { e.getPlayer().useLadder(Tile.of(4762, 5763, 0)); e.getPlayer().getVars().saveVarBit(7792, 40); //Darren T4 e.getPlayer().getMusicsManager().unlockMusic(840); return; } if (Miniquest.LOST_HER_MARBLES.isImplemented() && e.getPlayer().isMiniquestComplete(Miniquest.LOST_HER_MARBLES, false)) { e.getPlayer().useLadder(Tile.of(4634, 5763, 0)); e.getPlayer().getVars().saveVarBit(7792, 20); //Darren T3 e.getPlayer().getMusicsManager().unlockMusic(838); return; } if (Miniquest.FROM_TINY_ACORNS.isImplemented() && e.getPlayer().isMiniquestComplete(Miniquest.FROM_TINY_ACORNS, false)) { e.getPlayer().useLadder(Tile.of(4634, 5763, 0)); e.getPlayer().getMusicsManager().unlockMusic(839); return; } if (Quest.BUYERS_AND_CELLARS.isImplemented() && e.getPlayer().isQuestComplete(Quest.BUYERS_AND_CELLARS, null)) { e.getPlayer().useLadder(Tile.of(4762, 5891, 0)); e.getPlayer().getVars().saveVarBit(7792, 10); //Darren T2 } else { e.getPlayer().useLadder(Tile.of(4664, 5891, 0)); e.getPlayer().getMusicsManager().unlockMusic(842); } }); public static ObjectClickHandler handleMarkI = new ObjectClickHandler(new Object[]{ 52316 }, e -> { if (e.getOption().equalsIgnoreCase(""attack"")) { e.getPlayer().anim(12477); e.getPlayer().npcDialogue(11274, HeadE.SHAKING_HEAD, ""Now, you see, that's the thing you don't want to be doing if you want to avoid notice.""); } if (e.getOption().equalsIgnoreCase(""pickpocket"")) { e.getPlayer().getActionManager().setAction(new PickPocketDummy(e.getObject())); } }); public static ObjectClickHandler handleMarkII = new ObjectClickHandler(new Object[]{52317}, e -> { if (e.getOption().equalsIgnoreCase(""pickpocket"")) { e.getPlayer().getActionManager().setAction(new PickPocketDummyMK2(e.getObject())); } }); public static ItemClickHandler read = new ItemClickHandler(new Object[]{ 18646 }, new String[]{""Read""}, e -> { e.getPlayer().itemDialogue(18646, ""You read the instructive document, and feel rather more adept in pilferage and larceny. You gain 175 Thieving XP""); e.getPlayer().getSkills().addXp(Skills.THIEVING, 175); e.getPlayer().getInventory().deleteItem(18646, 1); }); public static NPCClickHandler DodgyDerek = new NPCClickHandler(new Object[]{ 11298 }, e -> { switch (e.getOption()) { case ""Talk-to"" -> e.getPlayer().startConversation(new Dialogue() .addNPC(e.getNPCId(), HeadE.HAPPY_TALKING, ""Psst... Need a lockpick or a blackjack? I've got dirty deals to do dirt cheap, so get the goods while they're hot!"") .addOptions(ops-> { ops.add(""I'll take a look."", () -> ShopsHandler.openShop(e.getPlayer(), ""dodgy_dereks_dirty_deals"")); ops.add(""No."") .addPlayer(HeadE.SHAKING_HEAD, ""I'll pass for now, no 'fence meant.""); })); case ""Trade"" -> ShopsHandler.openShop(e.getPlayer(), ""dodgy_dereks_dirty_deals""); } }); public static NPCInteractionDistanceHandler MrPinsworthDistance = new NPCInteractionDistanceHandler(new Object[] { 11299 }, (p, n) -> 1); public static NPCClickHandler MrPinsworth = new NPCClickHandler(new Object[] { 11299 }, e -> { switch(e.getOption()) { case ""Bank"": e.getPlayer().getBank().open(); break; case ""Collect"": GE.openCollection(e.getPlayer()); break; case ""Talk-to"": e.getPlayer().startConversation(new Dialogue() .addPlayer(HeadE.CONFUSED, ""What're you up to in here?"") .addNPC(e.getNPCId(), HeadE.HAPPY_TALKING, ""We managed to...acquire access to the banking system. Want a look?"") .addOptions(ops-> { ops.add(""Yes."", () -> e.getPlayer().getBank().open()); ops.add(""No."") .addPlayer(HeadE.SHAKING_HEAD, ""No thanks.""); }) ); break; } }); public static NPCClickHandler PickpocketingVolunteer = new NPCClickHandler(new Object[]{ 11282, 11284, 11286 }, new String[]{""Talk-to""}, e -> e.getPlayer().npcDialogue(e.getNPCId(), HeadE.SHAKING_HEAD, ""Alright there! I'm here for you to practise the ol' dippetydoodah on. If you want to know more, talk to the trainer."")); }" "package com.rs.game.content.world.areas.thieves_guild.npcs; @PluginEventHandler public class AdvPickpocketingTrainer { static String[] Lure = new String[]{ ""Watch out! The fellow behind you has a club!"", ""Behind you! A three-headed monkey!"", ""That's the third biggest platypus I've ever seen!"", ""Look over THERE!"", ""Look! An eagle!"", ""Your shoelace is untied."", }; public static NPCClickHandler pickpocketTrainer = new NPCClickHandler(new Object[]{11296}, new String[]{""Talk-to""}, e -> { int npcid = e.getNPCId(); Player player = e.getPlayer(); if (player.getEquipment().getWeaponId() != 18644) { player.sendMessage(""The trainer does his best to focus on you.""); player.npcDialogue(npcid, HeadE.SKEPTICAL_THINKING, ""I teach 'Aggressive Pickpocketing'. You need t' be be'er equipped before I can 'elp yer - git yerself a blackjack.""); } else { player.startConversation(new Dialogue() .addNPC(npcid, HeadE.CALM_TALK, ""A cosh is a fan'astic tool, and that's no 'yperbole. Know 'ow to use it?"") .addOptions(ops -> { ops.add(""About those hankies..."") .addOptions(ops2 -> { ops2.add(""What are these handkerchiefs for?"") .addNPC(npcid, HeadE.CALM_TALK, ""Oh, we use them to keep track of our members' training regimen. Blue handkerchiefs will earn you one point, red ones are worth four. You can claim a reward from any trainer with your hanky points.""); ops2.add(""How often can I do this?"") .addNPC(npcid, HeadE.CALM_TALK, ""The number of hanky points you can claim for depends on your dedication to the art. At the moment, you can claim [number] hanky points' worth of training per week.""); ops2.add(""Which activities give which handkerchiefs?"") .addNPC(npcid, HeadE.CALM_TALK, ""Our pickpocketing trainers, safes and easy chests carry blue hankies; red hankies can be found on the coshing trainers and behind harder locks.""); ops2.add(""Bye for now."") .addPlayer(HeadE.HAPPY_TALKING, ""Bye for now.""); }); ops.add(""How many hanky points do I have?"", () -> HankyPoints.checkPoints(player, e.getNPC())); ops.add(""I'd like to claim a reward for my hanky points."", () -> { int availablePoints = player.getWeeklyI(""HankyPoints"") - player.getWeeklyI(""ClaimedHankyPoints""); if (availablePoints == 0) HankyPoints.claimHankyPoints(player, e.getNPC()); else player.startConversation(new Dialogue() .addNPC(npcid, HeadE.CALM_TALK, ""Sure things! Let's see now..."", () -> HankyPoints.claimHankyPoints(player, e.getNPC()) )); }); ops.add(""I've had some experience, yes."") .addPlayer(HeadE.HAPPY_TALKING, ""I've had some experience, yes."") .addNPC(npcid, HeadE.CALM_TALK, ""You can prac'ise on me if yer want, but only wiv a training cosh...""); ops.add(""Remind me of the finer points, please."") .addPlayer(HeadE.HAPPY_TALKING, ""Remind me of the finer points, please?"") .addNPC(npcid, HeadE.CALM_TALK, ""A blackjack, cosh or sap is a tool for openin' the pockets of people who keep a be'er eye on their wallet than on the back of their own 'ed."") .addNPC(npcid, HeadE.CALM_TALK, ""First you need to get 'em out of the reach of pryin' eyes, then just give 'em a good whack right 'ere and down they'll go."") .addNPC(npcid, HeadE.CALM_TALK, ""Then you can see what they've got that you migh' want. Got it?"") .addPlayer(HeadE.HAPPY_TALKING, ""Yes, that was blunt enough. Thank you.""); })); } }); }" "package com.rs.game.content.world.areas.thieves_guild.npcs; @PluginEventHandler public class CoshingVolunteer { public static NPCClickHandler CoshingVolunteer = new NPCClickHandler(new Object[]{ 11290, 11292, 11288 }, new String[]{""Talk-to""}, e -> { Player player = e.getPlayer(); NPC npc = e.getNPC(); player.startConversation(new Dialogue() .addNPC(npc.getId(), HeadE.CALM_TALK, ""I'm a coshing trainer. I'm here to..."") .addNext(() -> npc.forceTalk(""Gulp"")) .addNPC(npc.getId(), HeadE.SHAKING_HEAD, ""I'm here to get hit over the head with a rubber cosh and be robbed of my hankies. Why did I ever agree to this?"") .addNPC(npc.getId(), HeadE.CALM_TALK, ""Anyway, Big Man's your man for more info. He's the big man over there."") ); }); }" "package com.rs.game.content.world.areas.thieves_guild.npcs @ServerStartupEvent fun mapDarrenLightfingerGeneric() { onNpcClick(11273, options = arrayOf(""Talk-to"")) { (p, npc) -> if (!p.isQuestStarted(Quest.BUYERS_AND_CELLARS)) { DarrenBuyersAndCellars.preQuest(p, npc) return@onNpcClick } when (p.getQuestStage(Quest.BUYERS_AND_CELLARS)) { 1 -> DarrenBuyersAndCellars.preQuest(p, npc) 2 -> DarrenBuyersAndCellars.stage2(p, npc) else -> DarrenLightfingerGeneric(p, npc) } } } class DarrenLightfingerGeneric(p: Player, npc: NPC) { init { p.startConversation { exec { stage3(p, npc) } } } private fun stage3(p: Player, npc: NPC) { val thievingLevel = p.skills.getLevelForXp(Skills.THIEVING) val agilityLevel = p.skills.getLevelForXp(Skills.AGILITY) val herbloreLevel = p.skills.getLevelForXp(Skills.HERBLORE) p.startConversation { npc(npc, HAPPY_TALKING, ""Greetings, my young recruit!"") label(""options"") options { op(""Can we try out that testing dummy again?"") { player(CALM_TALK, ""Can we try out that testing dummy again?"") npc(npc, HAPPY_TALKING, ""Of course!"") exec { p.walkToAndExecute(Tile.of(4762, 5903, 0)) { p.actionManager.setAction(PickPocketDummy(GameObject(52316, 1, 4665, 5903, 0))) } } } op(""How's the guild coming along these days?"") { if (p.isMiniquestComplete(Miniquest.A_GUILD_OF_OUR_OWN, false)) { //AGuildOfOurOwnTXT goto(""options"") } if (p.isMiniquestComplete(Miniquest.LOST_HER_MARBLES)) { //LostHerMarblesOptionsTXT goto(""options"") } if (p.isMiniquestComplete(Miniquest.FROM_TINY_ACORNS)) { player(CALM_TALK, ""How's the guild coming along these days?"") npc(npc, HAPPY_TALKING, ""A coshing tutor has moved in and we've now opened a store. We'll need more funds if we're to continue with renovations. Anything else I can do for you? "") goto(""options"") } else { player(CALM_TALK, ""How's the guild coming along these days?"") npc(npc, HAPPY_TALKING, ""We're really only getting started at the moment. I've made a training dummy to practice on, but we'll need funds if we're to begin to command any respect. Anything else I can do for you?"") goto(""options"") } } op(""I'd like to talk about capers."") { if (p.isQuestStarted(Quest.BUYERS_AND_CELLARS) && !p.isQuestComplete(Quest.BUYERS_AND_CELLARS)) { exec { buyersAndCellarsOptions(p, npc) } } if (thievingLevel >= 24 && !p.isMiniquestComplete(Miniquest.FROM_TINY_ACORNS)) { exec { DarrenFromTinyAcorns(p, npc) } } if (thievingLevel >= 41 && !p.isMiniquestComplete(Miniquest.LOST_HER_MARBLES)) { //LostHerMarblesOptions(player); } if (thievingLevel >= 62 && agilityLevel >= 40 && herbloreLevel >= 46 && !p.isMiniquestComplete(Miniquest.A_GUILD_OF_OUR_OWN)) { //AGuildOfOurOwnOptions(player); } npc(npc, HAPPY_TALKING, ""I don't have any capers for you at the moment, come back and see me in a little while."") } op(""Sorry, I was just leaving."") { player(CALM, ""Sorry, I was just leaving."") } } } } private fun buyersAndCellarsOptions(p: Player, npc: NPC) { p.startConversation { npc(npc, HAPPY_TALKING, ""Have you retrieved the chalice?"") when (p.getQuestStage(Quest.BUYERS_AND_CELLARS)) { 3 -> { player(CALM_TALK, ""Not yet."") npc(npc, HAPPY_TALKING, ""Head to Lumbridge Castle as soon as you may, then; Robin will meet you there."") } 4 -> { player(CALM_TALK, ""Not yet, but I'm on its trail"") } 5, 6 -> { player(CALM_TALK, ""I've tracked it down, but I've not yet retrieved it."") } 7 -> { player(CALM_TALK, ""I have the key, but not the chalice."") npc(npc, CALM_TALK, ""You've used several keys in the past, I'm sure; one more should pose no difficulty."") } 8 -> { player(HAPPY_TALKING, ""I have!"") npc(npc, HAPPY_TALKING, ""Fantastic work! I knew I had chosen wisely when I recruited you. Now we can expand the guild and do some proper training around here."") player(SKEPTICAL_HEAD_SHAKE, ""Your buyer is still interested, I hope?"") npc(npc, CALM_TALK, ""Yes, of course, why?"") player(CALM_TALK, ""Well, the chalice wasn't where you said it was, nor was the owner; I just wanted to make sure you had something right in all of this."") npc(npc, LAUGH, ""Ha! I do appreciate a sense of humor in my members."") player(CALM_TALK, ""It wasn't actually a joke, to be honest."") npc(npc, SKEPTICAL_HEAD_SHAKE, ""To be honest? You don't want to be honest; you're a member of the illustrious Thieves' Guild! Now get out there and make me proud... and both of us rich!"") exec { p.fadeScreen { p.inventory.deleteItem(18648, 1) p.tele(Tile.of(3223, 3269, 0)) p.vars.saveVarBit(7792, 10) p.vars.setVarBit(7793, 0) p.questManager.completeQuest(Quest.BUYERS_AND_CELLARS) } } } } } } }" "package com.rs.game.content.world.areas.thieves_guild.npcs; @PluginEventHandler public class LocksAndTrapsTrainer { public static NPCClickHandler locksandtraps = new NPCClickHandler(new Object[] { 11294 }, new String[] {""Talk-to""}, e -> { int npcid = e.getNPCId(); Player player = e.getPlayer(); player.startConversation(new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""What can you teach me?"") .addNPC(npcid, HeadE.CALM_TALK, ""I'm the locks and traps trainer. Need any advice?"") .addOptions(ops -> { ops.add(""About those hankies..."") .addOptions(ops2 -> { ops2.add(""What are these handkerchiefs for?"") .addNPC(npcid, HeadE.CALM_TALK, ""Oh, we use them to keep track of our members' training regimen. Blue handkerchiefs will earn you one point, red ones are worth four. You can claim a reward from any trainer with your hanky points.""); ops2.add(""How often can I do this?"") .addNPC(npcid, HeadE.CALM_TALK, ""The number of hanky points you can claim for depends on your dedication to the art. At the moment, you can claim [number] hanky points' worth of training per week.""); ops2.add(""Which activities give which handkerchiefs?"") .addNPC(npcid, HeadE.CALM_TALK, ""Our pickpocketing trainers, safes and easy chests carry blue hankies; red hankies can be found on the coshing trainers and behind harder locks.""); ops2.add(""Bye for now."") .addPlayer(HeadE.HAPPY_TALKING, ""Bye for now.""); }); ops.add(""How many hanky points do I have?"", () -> HankyPoints.checkPoints(player, e.getNPC())); ops.add(""I'd like to claim a reward for my hanky points."", () -> { int availablePoints = player.getWeeklyI(""HankyPoints"") - player.getWeeklyI(""ClaimedHankyPoints""); if (availablePoints == 0) HankyPoints.claimHankyPoints(player, e.getNPC()); else player.startConversation(new Dialogue() .addNPC(npcid, HeadE.CALM_TALK, ""Sure things! Let's see now..."", () -> HankyPoints.claimHankyPoints(player, e.getNPC()) )); }); ops.add(""That's alright, thanks."") .addNPC(npcid, HeadE.CALM_TALK, ""Feel free to practise on my coffers; the ones in the south are examples of more complex locks.""); ops.add(""I'm always happy to learn."") .addPlayer(HeadE.HAPPY_TALKING, ""I'm always happy to learn."") .addNPC(npcid, HeadE.CALM_TALK, ""You'll come across a fair few doors and chests around the world, and people tend to lock 'em. "" + ""With a bit of skill, though, and sometimes some specialised tools, you can crack them open and disarm the triggers on the traps they hold. "" + ""If something looks suspicious, examine it closely before you touch it."") .addPlayer(HeadE.CONFUSED, ""Specialised tools?"") .addNPC(npcid, HeadE.CALM_TALK, ""Some locks are more complex than others; trickier ones need a lockpick. You can buy one in the shop if you lose yours or it breaks."") .addPlayer(HeadE.HAPPY_TALKING, ""Another mystery unlocked. Thank you."") .addNPC(npcid, HeadE.HAPPY_TALKING, ""Feel free to practise on my coffers; the ones in the south are examples of more complex locks.""); })); }); }" "package com.rs.game.content.world.areas.thieves_guild.npcs; @PluginEventHandler public class pickpocketingTrainer { public static NPCClickHandler pickpocket = new NPCClickHandler(new Object[] { 11281 }, new String[] {""Talk-to""}, e -> { int npcid = e.getNPCId(); Player player = e.getPlayer(); player.startConversation(new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Hello there."") .addNPC(npcid, HeadE.CALM_TALK, ""Ah, Player. I'm doing classes on picking pockets, if you're interested."") .addOptions(ops -> { ops.add(""About those hankies..."") .addOptions(ops2 -> { ops2.add(""What are these handkerchiefs for?"") .addNPC(npcid, HeadE.CALM_TALK, ""Oh, we use them to keep track of our members' training regimen. Blue handkerchiefs will earn you one point, red ones are worth four. You can claim a reward from any trainer with your hanky points.""); ops2.add(""How often can I do this?"") .addNPC(npcid, HeadE.CALM_TALK, ""The number of hanky points you can claim for depends on your dedication to the art. At the moment, you can claim [number] hanky points' worth of training per week.""); ops2.add(""Which activities give which handkerchiefs?"") .addNPC(npcid, HeadE.CALM_TALK, ""Our pickpocketing trainers, safes and easy chests carry blue hankies; red hankies can be found on the coshing trainers and behind harder locks.""); ops2.add(""Bye for now."") .addPlayer(HeadE.HAPPY_TALKING, ""Bye for now.""); }); ops.add(""How many hanky points do I have?"", () -> HankyPoints.checkPoints(player, e.getNPC())); ops.add(""I'd like to claim a reward for my hanky points."", () -> { int availablePoints = player.getWeeklyI(""HankyPoints"") - player.getWeeklyI(""ClaimedHankyPoints""); if (availablePoints == 0) HankyPoints.claimHankyPoints(player, e.getNPC()); else player.startConversation(new Dialogue() .addNPC(npcid, HeadE.CALM_TALK, ""Sure things! Let's see now..."", () -> HankyPoints.claimHankyPoints(player, e.getNPC()) )); }); ops.add(""Bye for now."") .addPlayer(HeadE.HAPPY_TALKING, ""Bye for now.""); ops.add(""Not at the moment, thanks."") .addNPC(npcid, HeadE.CALM_TALK, ""You can give it a try with myself or my colleagues, although we've not got anything but hankies.""); ops.add("" Give me a few pointers, then."") .addNPC(npcid, HeadE.CALM_TALK, ""Picking a pocket is a simple thing, really. Just act casual, keep your fingers loose, and be sure you can take a beating if you're spotted. Most people don;t take kindly to someone running a hand through their belongings, and they'll give you a good whack if they catch you at it."") .addPlayer(HeadE.HAPPY_TALKING, ""Thank you for that stunning revelation.""); })); }); }" "package com.rs.game.content.world.areas.thieves_guild.npcs @ServerStartupEvent fun mapRobinGeneric() { onNpcClick(7955, 11268, 11279, 11280, options = arrayOf(""Talk-to"")) { (p, npc) -> if (p.isMiniquestStarted(Miniquest.FROM_TINY_ACORNS) && !p.isMiniquestComplete(Miniquest.FROM_TINY_ACORNS)) { RobinFromTinyAcorns(p, npc) } val questStage = p.getQuestStage(Quest.BUYERS_AND_CELLARS) when (questStage) { 0 -> RobinCastleKt.preQuest(p, npc) 1, 2 -> RobinCastleKt.someExtraHelp(p, npc) 3, 4 -> if (npc.tile == Tile.of(4762, 5904, 0)) { RobinCastleKt.someExtraHelp(p, npc) } else RobinCastleKt.stage3(p, npc) 5, 6 -> RobinCastleKt.stage5(p, npc) 7 -> RobinCastleKt.stage7(p, npc) 8 -> if (npc.tile == Tile.of(4762, 5904, 0)) { RobinCastleKt.someExtraHelp(p, npc) } else RobinCastleKt.stage8(p, npc) else -> postQuest(p, npc) } } } fun postQuest(p: Player, npc: NPC) { p.startConversation { player(CALM_TALK, ""Hello there."") npc(npc, CALM_TALK, ""The Guildmaster wanted me to be on hand in case you needed some more hints on picking pockets. Now, what can I do for you?"") options { op(""I'm always willing to learn."") { player(CALM_TALK, ""I'm always willing to learn."") npc(npc, CALM_TALK, ""When you're on the prowl for pickpocketing targets, it should be fairly obvious who's not paying enough attention to the world around them."") npc(npc, CALM_TALK, ""Just saunter up to them all casual-like, then dip your hand into their wallets as gently and as neatly as you can."") npc(npc, CALM_TALK, ""If you succeed, you'll get some of the contents of their pockets; it not, they'll likely punch you in the face, so be warned."") npc(npc, CALM_TALK, ""It stings, and you'll need a moment to gather your wits."") player(CALM_TALK, ""Thanks, Robin."") npc(npc, CALM_TALK, ""You can use the training dummy if you'd like, but after a while you'll need to switch to real marks if you want to improve."") } op(""I've got it, thanks."") { player(CALM_TALK, ""I’ve got it, thanks."") npc(npc, CALM_TALK, ""You can use the training dummy if you'd like, but after a while you'll need to switch to real marks if you want to improve."") } op(""Bye for now."") { player(CALM_TALK, ""Bye for now."")} } } }" "package com.rs.game.content.world.areas.tirannwn; @PluginEventHandler public class Tirannwn { // public static void unlockPrisonerOfGlouphrieEntrance(LoginEvent e) { // e.getPlayer().getVars().setVarBit(5332, 1); //remove boulder // e.getPlayer().getVars().setVarBit(8749, 2); //expose vent and tie rope // return false; // } public static ObjectClickHandler handleStickTraps = new ObjectClickHandler(new Object[] { 3922 }, e -> { /* * 3 = S -> N 2 = W -> E 1 = N- > S 0 = E -> W */ Player p = e.getPlayer(); Tile objTile = Tile.of(e.getObject().getX(), e.getObject().getY(), e.getObject().getPlane()); if (p.withinDistance(objTile, 3) && (e.getObject().getRotation() == 3 || e.getObject().getRotation() == 1)) if (p.getY() > objTile.getY()) p.addWalkSteps(Tile.of(objTile.getX(), objTile.getY() - 1, objTile.getPlane()), 5, false); else if (p.getY() <= objTile.getY()) p.addWalkSteps(Tile.of(objTile.getX(), objTile.getY() + 2, objTile.getPlane()), 5, false); if (p.withinDistance(objTile, 3) && (e.getObject().getRotation() == 0 || e.getObject().getRotation() == 2)) if (p.getX() > objTile.getX()) p.addWalkSteps(Tile.of(objTile.getX() - 1, objTile.getY(), objTile.getPlane()), 5, false); else if (p.getX() <= objTile.getX()) p.addWalkSteps(Tile.of(objTile.getX() + 2, objTile.getY(), objTile.getPlane()), 5, false); }); public static ObjectClickHandler handleTripWire = new ObjectClickHandler(new Object[] { 3921 }, e -> { /* * 2 = S -> N 3 = W -> E 0 = N- > S 1 = E -> W */ Player p = e.getPlayer(); Tile objTile = Tile.of(e.getObject().getX(), e.getObject().getY(), e.getObject().getPlane()); if (p.withinDistance(objTile, 3) && (e.getObject().getRotation() == 0 || e.getObject().getRotation() == 2)) if (p.getY() > objTile.getY()) p.addWalkSteps(Tile.of(objTile.getX(), objTile.getY() - 1, objTile.getPlane()), 5, false); else if (p.getY() <= objTile.getY()) p.addWalkSteps(Tile.of(objTile.getX(), objTile.getY() + 2, objTile.getPlane()), 5, false); if (p.withinDistance(objTile, 3) && (e.getObject().getRotation() == 1 || e.getObject().getRotation() == 3)) if (p.getX() > objTile.getX()) p.addWalkSteps(Tile.of(objTile.getX() - 1, objTile.getY(), objTile.getPlane()), 5, false); else if (p.getX() <= objTile.getX()) p.addWalkSteps(Tile.of(objTile.getX() + 2, objTile.getY(), objTile.getPlane()), 5, false); }); public static ObjectClickHandler handleLeafTrap = new ObjectClickHandler(new Object[] { 3923, 3925 }, e -> { Player p = e.getPlayer(); Tile objTile = Tile.of(e.getObject().getX(), e.getObject().getY(), e.getObject().getPlane()); if (p.withinDistance(Tile.of(2208, 3204, 0), 4)) if (p.getY() > objTile.getY()) p.forceMove(Tile.of(2209, 3201, 0), 10963, 0, 25); else if (p.getY() < objTile.getY()) p.forceMove(Tile.of(2209, 3205, 0), 10963, 0, 25); if (p.withinDistance(Tile.of(2267, 3202, 0), 4)) if (p.getY() > objTile.getY()) p.forceMove(Tile.of(2267, 3201, 0), 10963, 0, 25); else if (p.getY() < objTile.getY()) p.forceMove(Tile.of(2267, 3205, 0), 10963, 0, 25); if (p.withinDistance(Tile.of(2274, 3174, 0), 4)) if (p.getY() > objTile.getY()) p.forceMove(Tile.of(2274, 3172, 0), 10963, 0, 25); else if (p.getY() < objTile.getY()) p.forceMove(Tile.of(2274, 3176, 0), 10963, 0, 25); if (p.withinDistance(Tile.of(2278, 3262, 0), 4)) if (p.getX() > objTile.getX()) p.forceMove(Tile.of(2275, 3262, 0), 10963, 0, 25); else if (p.getX() < objTile.getX()) p.forceMove(Tile.of(2279, 3262, 0), 10963, 0, 25); }); public static ObjectClickHandler handleGlouphrieCave = new ObjectClickHandler(new Object[] { 20750, 20753 }, e -> { if (e.getObjectId() == 20753) e.getPlayer().useStairs(Tile.of(2389, 3193, 0)); else e.getPlayer().useStairs(Tile.of(3577, 4400, 0)); }); public static ObjectClickHandler handleGlouphrieCaveStairs1 = new ObjectClickHandler(new Object[] { 20652, 20653 }, e -> { if (e.getObjectId() == 20652) e.getPlayer().useStairs(Tile.of(3546, 4581, 0)); else e.getPlayer().useStairs(Tile.of(3619, 4582, 0)); }); public static ObjectClickHandler handleGlouphrieCaveStairs2 = new ObjectClickHandler(new Object[] { 20655, 20631 }, e -> { if (e.getObjectId() == 20655) e.getPlayer().useStairs(Tile.of(3545, 4577, 0)); else e.getPlayer().useStairs(Tile.of(3540, 4512, 0)); }); public static ObjectClickHandler handleGlouphrieVent = new ObjectClickHandler(new Object[] { 20719, 20659 }, e -> { if (e.getObjectId() == 20719 && e.getOption().equals(""Climb-down"")) e.getPlayer().useStairs(Tile.of(3541, 4571, 0)); else e.getPlayer().useStairs(Tile.of(2375, 3181, 0)); }); public static ObjectClickHandler handleGrenwallLogBalance = new ObjectClickHandler(new Object[] { 3931, 3932 }, e -> { if (!Agility.hasLevel(e.getPlayer(), 45)) { e.getPlayer().sendMessage(""You need 45 agility""); return; } AgilityShortcuts.walkLog(e.getPlayer(), e.getPlayer().transform(e.getPlayer().getX() > e.getObject().getX() ? -6 : 6, 0, 0), 4); }); public static ObjectClickHandler handleArandarLogBalance = new ObjectClickHandler(new Object[] { 3933 }, e -> { if (!Agility.hasLevel(e.getPlayer(), 45)) { e.getPlayer().sendMessage(""You need 45 agility""); return; } AgilityShortcuts.walkLog(e.getPlayer(), e.getPlayer().transform(0, e.getPlayer().getY() > e.getObject().getY() ? -7 : 7, 0), 6); }); public static ObjectClickHandler handleEnterUndergroundPass = new ObjectClickHandler(new Object[] { 4006 }, e -> e.getPlayer().tele(Tile.of(2438, 3315, 0))); public static ObjectClickHandler handleLletyaTreePass = new ObjectClickHandler(new Object[] { 8742 }, e -> { if (!e.getPlayer().isQuestComplete(Quest.ROVING_ELVES, ""to navigate the forest."")) return; Agility.handleObstacle(e.getPlayer(), 3303, 1, e.getPlayer().transform(e.getPlayer().getX() < e.getObject().getX() ? 2 : -2, 0, 0), 0); }); public static ObjectClickHandler handleDenseForest = new ObjectClickHandler(new Object[] { ""Dense forest"" }, e -> { if (!Agility.hasLevel(e.getPlayer(), 56)) { e.getPlayer().sendMessage(""You need 56 agility""); return; } if (e.getObject().getRotation() == 3 || e.getObject().getRotation() == 1) Agility.handleObstacle(e.getPlayer(), 3303, 1, e.getPlayer().transform(e.getPlayer().getX() < e.getObject().getX() ? 3 : -3, 0, 0), 0); else Agility.handleObstacle(e.getPlayer(), 3303, 1, e.getPlayer().transform(0, e.getPlayer().getY() < e.getObject().getY() ? 3 : -3, 0), 0); }); public static ObjectClickHandler handleHeavyGateToArandar = new ObjectClickHandler(new Object[] { 3945, 3944 }, e -> { Player p = e.getPlayer(); WorldObject obj = e.getObject(); if (p.getY() > obj.getY()) p.tele(Tile.of(obj.getX(), obj.getY() - 1, obj.getPlane())); if (p.getY() < obj.getY()) p.tele(Tile.of(obj.getX(), obj.getY() + 1, obj.getPlane())); }); public static ObjectClickHandler handleAdvancedElvenCliffside = new ObjectClickHandler(new Object[] { 9297, 9296 }, e -> { Player p = e.getPlayer(); WorldObject obj = e.getObject(); if (obj.getId() == 9296) {// above if (obj.getTile().matches(Tile.of(2333, 3252, 0))) { if (!Agility.hasLevel(p, 85)) { p.getPackets().sendGameMessage(""You need level 85 agility to use this shortcut.""); return; } p.forceMove(Tile.of(2338, 3253, 0), 2050, 0, 30); } if (obj.getTile().matches(Tile.of(2338, 3282, 0))) { if (!Agility.hasLevel(p, 68)) { p.getPackets().sendGameMessage(""You need level 68 agility to use this shortcut.""); return; } p.forceMove(Tile.of(2338, 3286, 0), 2050, 0, 30); } if (obj.getTile().matches(Tile.of(2346, 3299, 0))) { if (!Agility.hasLevel(p, 59)) { p.getPackets().sendGameMessage(""You need level 59 agility to use this shortcut.""); return; } p.forceMove(Tile.of(2344, 3294, 0), 2050, 0, 30); } } if (obj.getId() == 9297) {// below if (obj.getTile().matches(Tile.of(2337, 3253, 0))) { if (!Agility.hasLevel(p, 85)) { p.getPackets().sendGameMessage(""You need level 85 agility to use this shortcut.""); return; } p.forceMove(Tile.of(2332, 3252, 0), 2049, 0, 30); } if (obj.getTile().matches(Tile.of(2338, 3285, 0))) { if (!Agility.hasLevel(p, 68)) { p.getPackets().sendGameMessage(""You need level 68 agility to use this shortcut.""); return; } p.forceMove(Tile.of(2338, 3281, 0), 2049, 0, 30); } if (obj.getTile().matches(Tile.of(2344, 3295, 0))) { if (!Agility.hasLevel(p, 59)) { p.getPackets().sendGameMessage(""You need level 59 agility to use this shortcut.""); return; } p.forceMove(Tile.of(2346, 3300, 0), 2049, 0, 30); } } }); public static NPCClickHandler handleArianwynCampTalk = new NPCClickHandler(new Object[] { ""Arianwyn"" }, e -> { if (!e.getPlayer().isQuestComplete(Quest.ROVING_ELVES, ""to talk to Arianwyn about teleport seeds and crystal weaponry."")) return; e.getPlayer().startConversation(new Conversation(e.getPlayer()) { { addNPC(e.getNPCId(), HeadE.CHEERFUL, ""Hello "" + e.getPlayer().getDisplayName() + "". What is it you need?""); addOptions(""What would you like to say?"", new Options() { @Override public void create() { option(""Could you repair some seeds for me?"", new Dialogue().addNPC(e.getNPCId(), HeadE.CHEERFUL, ""Of course! If you have a seed you would like me to repair, use it on me."")); option(""Could I buy a crystal bow?"", new Dialogue().addNPC(e.getNPCId(), HeadE.CHEERFUL, ""Yes, but it will cost you 1,000,000 coins."").addOption(""Buy a crystal bow for 1,000,000 coins?"", ""Yes, I'd like to buy one."", ""No thanks, that's way too much for me."").addNext(() -> { if (player.getInventory().hasCoins(1000000)) { player.getInventory().removeCoins(1000000); player.getInventory().addItem(4212, 1); } else player.sendMessage(""You don't have enough money.""); })); option(""Could I buy a crystal shield?"", new Dialogue().addNPC(e.getNPCId(), HeadE.CHEERFUL, ""Yes, but it will cost you 750,000 coins."").addOption(""Buy a crystal shield for 750,000 coins?"", ""Yes, I'd like to buy one."", ""No thanks, that's way too much for me."").addNext(() -> { if (player.getInventory().hasCoins(750000)) { player.getInventory().removeCoins(750000); player.getInventory().addItem(4224, 1); } else player.sendMessage(""You don't have enough money.""); })); } }); } }); }); public static ItemOnNPCHandler handleArianwynCamp = new ItemOnNPCHandler(new Object[] { ""Arianwyn"" }, e -> { if (e.getItem().getId() == 4207) { int estCost = 1000000; if (e.getPlayer().getCrystalSeedRepairs() >= 0) { int repairs = e.getPlayer().getCrystalSeedRepairs(); if (repairs <= 5) estCost -= repairs * 200000; else estCost = 200000; } final int cost = estCost; e.getPlayer().sendOptionDialogue(""Would you like to attune your crystal seed for "" + cost + "" gold?"", ops -> { ops.add(""Yes, I'll pay "" + cost + "" gold for a bow."", () -> { if (e.getPlayer().getInventory().hasCoins(cost) && e.getPlayer().getInventory().containsItem(4207, 1)) { e.getPlayer().getInventory().deleteItem(4207, 1); e.getPlayer().getInventory().removeCoins(cost); e.getPlayer().getInventory().addItem(4212, 1); e.getPlayer().incrementCrystalSeedRepair(); } else e.getPlayer().sendMessage(""You don't have enough money.""); }); ops.add(""Yes, I'll pay "" + cost + "" gold for a shield."", () -> { if (e.getPlayer().getInventory().hasCoins(cost) && e.getPlayer().getInventory().containsItem(4207, 1)) { e.getPlayer().getInventory().deleteItem(4207, 1); e.getPlayer().getInventory().removeCoins(cost); e.getPlayer().getInventory().addItem(4224, 1); e.getPlayer().incrementCrystalSeedRepair(); } else e.getPlayer().sendMessage(""You don't have enough money.""); }); ops.add(""No, that's too much.""); }); } else if (e.getItem().getId() == 6103) { int numSeeds = e.getPlayer().getInventory().getNumberOf(6103); int cost = 750; if (e.getPlayer().getTinyCrystalSeedRepairs() >= 0) { int repairs = e.getPlayer().getTinyCrystalSeedRepairs(); if (repairs < 5) cost -= repairs * 120; else cost = 150; } int totalCost = cost * numSeeds; e.getPlayer().sendOptionDialogue(""Repair all your teleport seeds for "" + totalCost + ""?"", ops -> { ops.add(""Yes, please."", () -> { if (e.getPlayer().getInventory().hasCoins(totalCost) && e.getPlayer().getInventory().containsItem(6103, numSeeds)) { e.getPlayer().getInventory().deleteItem(6103, numSeeds); e.getPlayer().getInventory().removeCoins(totalCost); e.getPlayer().getInventory().addItem(6099, numSeeds); for (int i = 0; i < numSeeds; i++) e.getPlayer().incrementTinyCrystalSeedRepair(); } else e.getPlayer().sendMessage(""You don't have enough money.""); }); ops.add(""No, thank you.""); }); } }); public static ItemClickHandler handleTeleportCrystal = new ItemClickHandler(new Object[] { 6099, 6100, 6101, 6102 }, new String[] { ""Activate"" }, e -> Magic.sendNormalTeleportSpell(e.getPlayer(), Tile.of(2340, 3172, 0), () -> { e.getItem().setId(e.getItem().getId() + 1); e.getPlayer().getInventory().refresh(e.getItem().getSlot()); })); }" "package com.rs.game.content.world.areas.tree_gnome_stronghold; @PluginEventHandler public class TreeGnomeStronghold { public static ObjectClickHandler handleGnomeSpiralStairsUp = new ObjectClickHandler(new Object[] { 69505 }, e -> { GameObject oppObj = e.getObject(); for(GameObject obj : ChunkManager.getChunk(e.getPlayer().transform(0, 0, 1).getChunkId()).getBaseObjects()) if(obj.getId()== 69504 && obj.getTile().withinDistance(e.getObject().getTile().transform(0, 0, 1), 3)) oppObj = obj; if(oppObj.getTile().matches(Tile.of(2444, 3415, 0))) { e.getPlayer().useStairs(Tile.of(2445, 3416, 1)); return; } if(oppObj.getTile().matches(Tile.of(2456, 3417, 0))) { e.getPlayer().useStairs(Tile.of(2457, 3417, 1)); return; } if(oppObj.getTile().matches(Tile.of(2440, 3404, 0))) { e.getPlayer().useStairs(Tile.of(2440, 3403, 1)); return; } if(oppObj.getRotation() == 0) e.getPlayer().useStairs(oppObj.getTile().transform(1, 0)); if(oppObj.getRotation() == 1) e.getPlayer().useStairs(oppObj.getTile().transform(0, -1)); if(oppObj.getRotation() == 2) e.getPlayer().useStairs(oppObj.getTile().transform(-1, 0)); if(oppObj.getRotation() == 3) e.getPlayer().useStairs(oppObj.getTile().transform(0, 1)); }); public static ObjectClickHandler handleGnomeSpiralStairsDown = new ObjectClickHandler(new Object[] { 69504 }, e -> { GameObject oppObj = e.getObject(); for(GameObject obj : ChunkManager.getChunk(e.getPlayer().transform(0, 0, -1).getChunkId()).getBaseObjects()) if(obj.getId()== 69505 && obj.getTile().withinDistance(e.getObject().getTile().transform(0, 0, -1), 3)) oppObj = obj; if(oppObj.getTile().matches(Tile.of(2445, 3415, 1))) { e.getPlayer().useStairs(Tile.of(2446, 3416, 0)); return; } if(oppObj.getTile().matches(Tile.of(2416, 3446, 1))) { e.getPlayer().useStairs(Tile.of(2416, 3447, 0)); return; } if(oppObj.getTile().matches(Tile.of(2421, 3472, 1))) { e.getPlayer().useStairs(Tile.of(2420, 3473, 0)); return; } if(oppObj.getRotation() == 0) e.getPlayer().useStairs(oppObj.getTile().transform(1, -1)); if(oppObj.getRotation() == 1) e.getPlayer().useStairs(oppObj.getTile().transform(-1, 0)); if(oppObj.getRotation() == 2) e.getPlayer().useStairs(oppObj.getTile().transform(0, 2)); if(oppObj.getRotation() == 3) e.getPlayer().useStairs(oppObj.getTile().transform(2, 1)); }); public static ObjectClickHandler handleSpecialStair = new ObjectClickHandler(new Object[] { 69549, 69550 }, e -> { if(e.getPlayer().getPlane() == 1) { e.getPlayer().useStairs(Tile.of(2485, 3463, 2)); return; } e.getPlayer().useStairs(Tile.of(2483, 3463, 1)); }); }" "package com.rs.game.content.world.areas.tree_gnome_stronghold.npcs class BarmanBlurberry(p: Player, npc: NPC) { init { p.startConversation { npc(npc, HeadE.HAPPY_TALKING, ""Good day to you. What can I get you to drink?"") options { if (!isBarVisited(p, BLURBERRYS_BAR) && hasCard(p) && onBarCrawl(p)) { op(""I'm trying to do Alfred Grimhand's Barcrawl."") { player(HeadE.HAPPY_TALKING, ""I'm trying to do Alfred Grimhand's barcrawl."") npc(npc, HeadE.FRUSTRATED, ""Oh, another silly human come to have his mind melted? You should take that barcrawl card to Blurberry - he always likes to serve the ${BLURBERRYS_BAR.drinkName} himself!"") player(HeadE.FRUSTRATED, ""Um... thanks?!"") } } op(""What do you have?"") { player(HeadE.HAPPY_TALKING, ""What do you have?"") npc(npc, HeadE.HAPPY_TALKING, ""Here, take a look at our menu."") exec { ShopsHandler.openShop(p, ""blurberry_bar"") } } op(""Can I buy some ingredients?"") { player(HeadE.HAPPY_TALKING, ""I was just wanting to buy a cocktail ingredient actually."") npc(npc, HeadE.HAPPY_TALKING, ""Sure thing, what did you want?"") exec { purchaseIngredients(p, npc) } } } } } private fun purchaseIngredients(p: Player, npc: NPC) { p.startConversation { options { op(""A lemon."") { player(HeadE.HAPPY_TALKING, ""A lemon."") npc(npc, HeadE.HAPPY_TALKING, ""20 coins please."") exec { buyDrinkOrIngredients(p, npc, 20, Item(2102), false) } } op(""An orange."") { player(HeadE.HAPPY_TALKING, ""An orange."") npc(npc, HeadE.HAPPY_TALKING, ""20 coins please."") exec { buyDrinkOrIngredients(p, npc, 20, Item(2108), false) } } op(""A cocktail shaker."") { player(HeadE.HAPPY_TALKING, ""A cocktail shaker."") npc(npc, HeadE.HAPPY_TALKING, ""20 coins please."") exec { buyDrinkOrIngredients(p, npc, 20, Item(2025), false) } } op(""Nothing thanks."") { player(HeadE.HAPPY_TALKING, ""Actually nothing thanks."") } } } } } @ServerStartupEvent fun mapBarmanBlurberry() { onNpcClick(849) { (player, npc) -> BarmanBlurberry(player, npc) } }" "package com.rs.game.content.world.areas.tree_gnome_stronghold.npcs class Blurberry(p: Player, npc: NPC) { init { p.startConversation { player(HeadE.HAPPY_TALKING, ""Hello."") npc(npc, HeadE.HAPPY_TALKING, ""Well hello there traveller. If you're looking for a cocktail, the barman will happily make you one."") exec { if (!isBarVisited(p, BLURBERRYS_BAR) && hasCard(p) && onBarCrawl(p)) { player(HeadE.HAPPY_TALKING, ""I'm doing Alfred Grimhand's Barcrawl."") npc(npc, HeadE.CHEERFUL, ""Ah, you've come to the best stop on your list! I'll give you my famous ${BLURBERRYS_BAR.drinkName}! It'll cost you ${BLURBERRYS_BAR.price} coins."") exec { buyBarcrawlDrink(p, BLURBERRYS_BAR) } } } } } } @ServerStartupEvent fun mapBlurberry() { onNpcClick(848) { (player, npc) -> Blurberry(player, npc) } }" "package com.rs.game.content.world.areas.trollheim @ServerStartupEvent fun mapTrollheim() { //Unlock Sabbot's cave entrance (1 = mineable, 2 = being mined, 3 = mined) onLogin { it.player.vars.setVarBit(10762, 3) } onObjectClick(5012) { e -> e.player.tele(Tile.of(2799, 10134, 0)) } onObjectClick(5013) { e -> e.player.tele(Tile.of(2796, 3719, 0)) } onObjectClick(3758) { e -> if (e.objectAt(2906, 10036)) e.player.tele(Tile.of(2922, 3658, 0)) else if (e.objectAt(2906, 10017)) e.player.tele(Tile.of(2911, 3636, 0)) } onObjectClick(26342) { e -> if (e.player.controllerManager.controller == null) { e.player.useStairs(828, Tile.of(2881, 5310, 2), 0, 0) e.player.controllerManager.startController(GodwarsController()) } else e.player.sendMessage(""Invalid teleport."") } onObjectClick(35390) { e -> val lift = e.opNum == ClientPacket.OBJECT_OP1 if (e.player.skills.getLevel(if (lift) Skills.STRENGTH else Skills.AGILITY) < 60) { e.player.sendMessage(""You need a "" + (if (lift) ""Strength"" else ""Agility"") + "" of 60 in order to "" + (if (lift) ""lift"" else ""squeeze past"") + "" this boulder."") return@onObjectClick } val isReturning = e.player.y >= 3709 val liftAnimation = if (isReturning) 3624 else 3725 val squeezeAnimation = if (isReturning) 3465 else 3466 val destination = Tile.of(e.player.x, e.player.y + (if (isReturning) -4 else 4), 0) e.player.lock() e.player.schedule { e.player.faceTile(destination) wait(1) e.player.anim(if (lift) liftAnimation else squeezeAnimation) wait(2) if (lift && isReturning) World.sendObjectAnimation(e.getObject(), 318) wait(1) if (lift && !isReturning) World.sendObjectAnimation(e.getObject(), 318) wait(2) if (!lift) { e.player.anim(-1) e.player.tele(destination) e.player.unlockNextTick() return@schedule } wait(2) if (isReturning) { e.player.anim(-1) e.player.tele(destination) e.player.unlockNextTick() return@schedule } wait(3) e.player.anim(-1) e.player.tele(destination) e.player.unlockNextTick() } } onObjectClick(34395) { e -> if (e.getObject().tile.isAt(2920, 3654)) e.player.tele(Tile.of(2907, 10035, 0)) else if (e.getObject().tile.isAt(2910, 3637)) e.player.tele(Tile.of(2907, 10019, 0)) else if (e.getObject().tile.isAt(2857, 3578)) e.player.tele(Tile.of(2269, 4752, 0)) else if (e.getObject().tile.isAt(2885, 3673)) e.player.tele(Tile.of(2893, 10074, 2)) else if (e.getObject().tile.isAt(2847, 3688)) e.player.tele(Tile.of(2837, 10090, 2)) else if (e.getObject().tile.isAt(2885, 3673)) e.player.tele(Tile.of(2893, 10074, 2)) else if (e.getObject().tile.isAt(2796, 3614)) e.player.tele(Tile.of(2808, 10002, 0)) else e.player.sendMessage(""Unhandled TrollheimMisc.handleTrollheimCaveEntrances()"") } onObjectClick(32738, 18834, 18833, 4500, 3774) { e -> when (e.getObject().id) { 32738 -> e.player.tele(Tile.of(2889, 3675, 0)) 18834 -> e.player.ladder(Tile.of(2812, 3669, 0)) 18833 -> e.player.ladder(Tile.of(2831, 10076, 2)) 4500 -> e.player.tele(Tile.of(2795, 3615, 0)) 3774 -> e.player.tele(Tile.of(2848, 3687, 0)) } } onObjectClick(67752, 67679, checkDistance = false) { e -> if (e.objectId == 67752) { e.player.setRouteEvent(RouteEvent(if (e.player.x > e.getObject().x) Tile.of(3434, 4261, 1) else Tile.of(3430, 4261, 1)) { e.player.lock() e.player.resetWalkSteps() World.sendObjectAnimation(e.getObject(), 497) e.player.forceMove(if (e.player.x < e.getObject().x) Tile.of(3434, 4261, 1) else Tile.of(3430, 4261, 1), 751, 20, 75) }) } else { val goWest = e.player.x > 3419 e.player.setRouteEvent(RouteEvent(if (goWest) Tile.of(3423, 4260, 1) else Tile.of(3415, 4260, 1)) { e.player.lock() e.player.faceObject(e.getObject()) e.player.schedule { for (i in 0..3) { e.player.anim(13495) wait(3) e.player.anim(-1) e.player.tele(e.player.transform(if (goWest) -2 else 2, 0)) wait(3) } e.player.unlock() } }) } } onObjectClick(67568, 67569, 67567, 67562, 67572, 67674, 67676, 67678, 67679, 67752, 67570) { e -> when (e.objectId) { 67568 -> e.player.tele(Tile.of(2858, 3577, 0)) 67569 -> e.player.tele(Tile.of(2854, 3617, 0)) 67572 -> e.player.tele(Tile.of(3435, 4240, 2)) 67567 -> e.player.tele(Tile.of(2267, 4758, 0)) 67562 -> e.player.tele(Tile.of(3405, 4284, 2)) 67676 -> { //squeeze gaps val deltaX = if (e.getObject().tile.isAt(3421, 4280)) if (e.player.x > e.getObject().x) -2 else 2 else 0 val deltaY = if (e.getObject().tile.isAt(3421, 4280)) 0 else if (e.player.y > e.getObject().y) -2 else 2 e.player.lock() e.player.schedule { wait(1) e.player.anim(16025) wait(7) e.player.anim(-1) e.player.tele(e.player.transform(deltaX, deltaY)) e.player.unlockNextTick() } } 67678 -> { e.player.lock() e.player.addWalkSteps(e.getObject().tile, 2, false) e.player.schedule { wait(1) e.player.faceTile(e.player.transform(0, if (e.getObject().tile.isAt(3434, 4275)) 2 else -2)) wait(1) e.player.anim(13495) wait(3) e.player.anim(-1) e.player.tele(e.player.transform(0, if (e.getObject().tile.isAt(3434, 4275)) 2 else -2)) e.player.unlockNextTick() } } 67674, 67570 -> { val horizontal = e.getObject().rotation == 0 || e.getObject().rotation == 2 val dx = if (horizontal) (if (e.getObject().id == 67674) -4 else 4) else 0 val dy = if (!horizontal) (if (e.getObject().id == 67674) -4 else 4) else 0 val dz = if (e.getObject().id == 67674) -1 else 1 climbCliff(e.player, e.player.tile, e.player.transform(dx, dy, dz), e.getObject().id == 67570) } } } onObjectClick(34836, 34839) { e -> if (!ChunkManager.getChunk(e.getObject().tile.chunkId).baseObjects.contains(e.getObject())) return@onObjectClick Doors.handleDoubleDoor(e.player, e.getObject()) } onObjectClick(35391, 3748, 34877, 34889, 34878, 9306, 9305, 3803, 9304, 9303) { e -> if (e.getObject().id == 35391) { if (e.getObject().rotation == 3 || e.getObject().rotation == 1) Agility.handleObstacle(e.player, 3303, 1, e.player.transform(if (e.player.x < e.getObject().x) 2 else -2, 0, 0), 1.0) else Agility.handleObstacle(e.player, 3303, 1, e.player.transform(0, if (e.player.y < e.getObject().y) 2 else -2, 0), 1.0) } else if (e.getObject().id == 3748) { if (e.getObject().rotation == 3 || e.getObject().rotation == 1) Agility.handleObstacle(e.player, 3377, 2, e.player.transform(if (e.player.x < e.getObject().x) 2 else -2, 0, 0), 1.0) else Agility.handleObstacle(e.player, 3377, 2, e.player.transform(0, if (e.player.y < e.getObject().y) 2 else -2, 0), 1.0) } else if (e.getObject().id == 34877 || e.getObject().id == 34889 || e.objectId == 34878 || e.getObject().id == 3803 || e.getObject().id == 9304 || e.getObject().id == 9303) { if (e.getObject().rotation == 0 || e.getObject().rotation == 2) Agility.handleObstacle(e.player, if (e.player.x < e.getObject().x) 3381 else 3382, 3, e.player.transform(if (e.player.x < e.getObject().x) 4 else -4, 0, 0), 1.0) else Agility.handleObstacle(e.player, if (e.player.y < e.getObject().y) 3381 else 3382, 3, e.player.transform(0, if (e.player.y < e.getObject().y) 4 else -4, 0), 1.0) } else if (e.getObject().id == 9306 || e.getObject().id == 9305) { if (e.getObject().rotation == 0 || e.getObject().rotation == 2) Agility.handleObstacle(e.player, if (e.player.x < e.getObject().x) 3382 else 3381, 3, e.player.transform(if (e.player.x < e.getObject().x) 4 else -4, 0, 0), 1.0) else Agility.handleObstacle(e.player, if (e.player.y < e.getObject().y) 3382 else 3381, 3, e.player.transform(0, if (e.player.y < e.getObject().y) 4 else -4, 0), 1.0) } } } fun climbCliff(player: Player, start: Tile, end: Tile, up: Boolean) { player.walkToAndExecute(start) { player.lock() if (!up) player.addWalkSteps(end.x().toInt(), end.y().toInt(), 1, false) player.schedule { wait(1) player.faceTile(end) wait(1) player.anim(if (up) 16031 else 16016) wait(if (up) 5 else 2) player.anim(-1) player.tele(end) player.unlockNextTick() } } }" "package com.rs.game.content.world.areas.trollheim; @PluginEventHandler public class TrollheimGuardTroll extends NPC { public TrollheimGuardTroll(int id, Tile tile) { super(id, tile); if(isGWDGaurd()) setRandomWalk(false); } @Override public boolean withinDistance(Player tile, int distance) { if(super.withinDistance(tile, distance)) { if(isGWDGaurd() && getTarget() == null && super.withinDistance(tile, 8)) setTarget(tile); return true; } return false; } private boolean isGWDGaurd() { if(getX() > 2885 && getX() < 2914 && getY() > 3690 && getY() < 3703) return true; return false; } @Override public void processNPC() { super.processNPC(); if (Utils.getDistance(this.getTile(), getRespawnTile()) > 2) DumbRouteFinder.addDumbPathfinderSteps(this, getRespawnTile(), 5, getCollisionStrategy()); } // public static NPCInstanceHandler toFunc = new NPCInstanceHandler(1130, 1131, 1132, 1133, 1134) { // @Override // public NPC getNPC(int npcId, Tile tile) { // return new TrollheimGuardTroll(npcId, tile); // } // }; }" "package com.rs.game.content.world.areas.tzhaar; @PluginEventHandler public class TzHaar { //TODO plugins for misc TzHaar object interactions etc }" "package com.rs.game.content.world.areas.tzhaar.npcs; @PluginEventHandler public class TzHaarMejJal extends Conversation { private static final int npcId = 2617; public static NPCClickHandler TzHaarMejJal = new NPCClickHandler(new Object[]{npcId}, e -> { switch(e.getOption()) { case ""Bank"": e.getPlayer().getBank().open(); break; case ""Collect"": GE.openCollection(e.getPlayer()); break; case ""Talk-to"": e.getPlayer().startConversation(new TzHaarMejJal(e.getPlayer(), e.getNPC())); break; } }); public TzHaarMejJal(Player player, NPC npc) { super(player); addNPC(npc.getId(), HeadE.T_CONFUSED, ""You want help TzHaar-Mej-"" + player.getDisplayName() + ""?""); addOptions(this, ""baseOptions"", ops -> { ops.add(""What is this place?"") .addPlayer(HeadE.CONFUSED, ""What is this place?"") .addNPC(npc.getId(), HeadE.T_CALM_TALK, ""This is the Fight Cave, ThzHaar-Xil made it for practice but many JalYt come here to fight, too. Just enter the cave and make sure you're prepared."") .addOptions(ops2 -> { ops2.add(""Are there any rules?"") .addPlayer(HeadE.CONFUSED, ""Are there any rules?"") .addNPC(npc.getId(), HeadE.T_LAUGH, ""Rules? Survival is the only rule in there."") .addOptions(ops3 -> { ops3.add(""Do I win anything?"") .addPlayer(HeadE.CONFUSED, ""Do I win anything?"") .addNPC(npc.getId(), HeadE.T_CALM_TALK, ""You ask a lot questions. Might give you TokKul if you last long enough."") .addPlayer(HeadE.CONFUSED, ""You're still handing out ToKKul as a reward? TzHaar-Mej- Jeh said it was going to be melted down in the sacred lava, to release your dead from their torment."") .addNPC(npc.getId(), HeadE.T_ANGRY, ""You ask a lot questions. Might give you TokKul if you last long enough."") .addNPC(npc.getId(), HeadE.T_CALM_TALK, ""TzHaar do not need currency. Each TzHaar work hard, and does their duty according to their caste. TzHaar ensure they have food and shelter,"") .addNPC(npc.getId(), HeadE.T_CALM_TALK, ""and all needs are met. JalYt come to TzHaar City, with heads full of gold and wealth and greed."") .addNPC(npc.getId(), HeadE.T_CALM_TALK, ""Gold no use to TzHaar. Soft and easily broken, like JalYt. JalYt need rare token to trade. TokKul is memories of dead TzHaar. Trapped. Precious."") .addNPC(npc.getId(), HeadE.T_CALM_TALK, ""TokKul is only rare token TzHaar have. Until TzHaar find new token, or JalYt have less greed, must trade in TokKul.""); ops3.add(""Sounds good."") .addGotoStage(""baseOptions"", this); }); ops2.add(""Thanks.""); }); ops.add(""What did you call me?"") .addPlayer(HeadE.CONFUSED, ""What did you call me?"") .addNPC(npc.getId(), HeadE.T_CONFUSED, ""Are you not TzHaar-Mej?"") .addOptions(ops2 -> { ops2.add(""Why do you call me 'TzHaar-Mej'?"") .addPlayer(HeadE.CONFUSED, ""Why do you call me 'TzHaar-Mej'?"") .addNPC(npc.getId(), HeadE.T_CALM_TALK, ""That what you are...you user of mystic powers, no? And you are JalYt no longer. You are TzHaar now."") .addPlayer(HeadE.CONFUSED, ""Well, yes, I suppose I am..."") .addNPC(npc.getId(), HeadE.T_LAUGH, ""Then you TzHaar-Mej!"") .addOptions(ops3 -> { ops3.add(""What are you then?"") .addPlayer(HeadE.CONFUSED, ""What are you then?"") .addNPC(npc.getId(), HeadE.T_CALM_TALK, ""I am TzHaar-Mej, one of the mystics of this city. The TzHaar-Mej guide the TzHaar when change is necessary, and tend to TzHaar eggs to ensure they are hot and healthy."") .addNPC(npc.getId(), HeadE.CALM_TALK, ""TzHaar-Mej are keepers of knowledge and magic. There are also the mighty TzHaar-Ket who guard us, the swift TzHaar-Xil who hunt for our food, and the skilled TzHaar-Hur who craft our homes and tools.""); ops3.add(""Thanks for explaining it.""); }); ops2.add(""Yes, I certainly am."") .addPlayer(HeadE.CHEERFUL, ""Yes, I certainly am."") .addNPC(npc.getId(), HeadE.T_CALM_TALK, ""Then it is an honour to speak with you, TzHaar-Mej-"" + player.getDisplayName() + "". You great and powerful TzHaar, and defender of our city.""); ops2.add(""You must have me confused with another TzHaar."") .addPlayer(HeadE.CONFUSED, ""You must have me confused with another TzHaar."") .addNPC(npc.getId(), HeadE.T_LAUGH, ""I heard you are modest, TzHaar-Mej-"" + player.getDisplayName() + "". No need. Revel in our praise. You deserve all honour.""); }); ops.add(""No I'm fine thanks.""); }); } }" "package com.rs.game.content.world.areas.tzhaar.npcs; @PluginEventHandler public class TzHaarMejKah extends Conversation { private static final int npcId = 2618; public static NPCClickHandler TzHaarMejKah = new NPCClickHandler(new Object[]{npcId}, e -> { switch(e.getOption()) { case ""Bank"": e.getPlayer().getBank().open(); break; case ""Collect"": GE.openCollection(e.getPlayer()); break; case ""Talk-to"": e.getPlayer().startConversation(new TzHaarMejKah(e.getPlayer())); break; } }); public TzHaarMejKah(Player player) { super(player); addNPC(npcId, HeadE.SKEPTICAL_HEAD_SHAKE, ""You want help JalYt-Ket-"" + player.getDisplayName() + ""?""); addOptions(""Choose an option:"", ops -> { ops.add(""What is this place?"") .addPlayer(HeadE.SKEPTICAL_HEAD_SHAKE, ""What is this place?"") .addNPC(npcId, HeadE.CALM_TALK, ""This is the Fight Pit. TzHaar-Xil made it for their sport but many JalYt come here to fight, too. If you are wanting to fight then enter the cage, you will be summoned when next round is ready to begin."") .addOptions(""Choose an option:"", op2 -> { op2.add(""Are there any rules?"") .addPlayer(HeadE.HAPPY_TALKING, ""Are there any rules?"") .addNPC(npcId, HeadE.CALM_TALK, ""No rules, you use whatever you want. Last person standing wins and is declared champion, they stay in the pit for next fight."") .addOptions(""Choose an option:"", op3 -> { op3.add(""Do I win anything?"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Do I win anything?"") .addNPC(npcId, HeadE.CALM_TALK, ""You ask a lot questions.
Champion gets TokKul as reward, more fights the more TokKul they get."") .addPlayer(HeadE.HAPPY_TALKING, ""..."") .addNPC(npcId, HeadE.CALM_TALK, ""Before you ask, TokKul is like your coins."") .addNPC(npcId, HeadE.CALM_TALK, ""Gold is like you JalYt, soft and easily broken, we use hard rock forged in fire like TzHaar!"")); op3.add(""Sounds good.""); }); op2.add(""Ok thanks.""); }); ops.add(""Who's the current champion?"", new Dialogue() .addPlayer(HeadE.SKEPTICAL_HEAD_SHAKE, ""Who's the current champion?"") .addNPC(npcId, HeadE.CALM_TALK, ""Ah that would be Y'Haar-Mej-"" + (FightPits.currentChampion == null ? ""none"" : FightPits.currentChampion) + ""!"")); ops.add(""What did you call me?"", new Dialogue() .addPlayer(HeadE.SKEPTICAL_HEAD_SHAKE, ""What did you call me?"") .addNPC(npcId, HeadE.CALM_TALK, ""Are you not a JalYt-Ket?"") .addOptions(""Choose an option:"", op2 -> { op2.add(""What's a 'JalYt-Ket'?"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""What's a 'JalYt-Ket'?"") .addNPC(npcId, HeadE.CALM_TALK, ""That what you are...you tough and strong, no?"") .addNPC(npcId, HeadE.CALM_TALK, ""Well, yes I suppose I am..."") .addNPC(npcId, HeadE.CALM_TALK, ""Then you JalYt-Ket!"") .addOptions(""Choose an option:"", op3 -> { op3.add(""What are you then?"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""What are you then?"") .addNPC(npcId, HeadE.CALM_TALK, ""Foolish JalYt, I am TzHaar-Mej one of the mystics of this city."") .addOptions(""Choose an option:"", op4 -> { op4.add(""What other types are there?"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""What other types are there?"") .addNPC(npcId, HeadE.CALM_TALK, ""There are the mighty TzHaar-Key who guard us, the swift TzHaar-Xil who hunt for our food, and the skilled TzHaar-Hur who craft our homes and tools."") .addPlayer(HeadE.HAPPY_TALKING, ""Awesome..."")); op4.add(""Ah ok then."", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Ah ok then."") .addNPC(npcId, HeadE.CALM_TALK, ""..."")); })); op3.add(""Thanks for explaining it."", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Thanks for explaining it."") .addNPC(npcId, HeadE.CALM_TALK, ""..."")); })); op2.add(""I guess so...?"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""I guess so...?"") .addNPC(npcId, HeadE.CALM_TALK, ""..."")); op2.add(""No I'm not!"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""No I'm not!"") .addNPC(npcId, HeadE.CALM_TALK, ""..."")); })); ops.add(""No I'm fine thanks."", new Dialogue()); }); create(); } }" "package com.rs.game.content.world.areas.ullek; //wrong animations @PluginEventHandler public class Ullek { public static ObjectClickHandler handlereeds = new ObjectClickHandler(new Object[] { 28474 }, e -> { if (e.getObject().getRotation() == 3 || e.getObject().getRotation() == 1) Agility.handleObstacle(e.getPlayer(), 3303, 1, e.getPlayer().transform(e.getPlayer().getX() < e.getObject().getX() ? 2 : -2, 0, 0), 0); else Agility.handleObstacle(e.getPlayer(), 3303, 1, e.getPlayer().transform(0, e.getPlayer().getY() < e.getObject().getY() ? 2 : -2, 0), 0); });//wrong animation public static ObjectClickHandler handleplateauentrance = new ObjectClickHandler(new Object[] { 28515 }, e -> e.getPlayer().tele(Tile.of(3419, 2803, 1))); public static ObjectClickHandler handleplateauexit= new ObjectClickHandler(new Object[] { 28516 }, e -> e.getPlayer().tele(Tile.of(3419, 2801, 0))); public static ObjectClickHandler handlelowall = new ObjectClickHandler(new Object[] { 28512 }, e -> { if (e.getObject().getRotation() == 3 || e.getObject().getRotation() == 1) Agility.handleObstacle(e.getPlayer(), 3303, 1, e.getPlayer().transform(e.getPlayer().getX() < e.getObject().getX() ? 2 : -2, 0, 0), 0); else Agility.handleObstacle(e.getPlayer(), 3303, 1, e.getPlayer().transform(0, e.getPlayer().getY() < e.getObject().getY() ? 2 : -2, 0), 0); });//wrong animation public static ObjectClickHandler handleullekentrance= new ObjectClickHandler(new Object[] { 28481 }, e -> e.getPlayer().tele(Tile.of(3448, 9252, 1))); public static ObjectClickHandler handleullekexit= new ObjectClickHandler(new Object[] { 28401 }, e -> e.getPlayer().tele(Tile.of(3412, 2847, 1))); public static ObjectClickHandler handlefloortrapullek = new ObjectClickHandler(new Object[] { 28525 }, e -> { if (e.getObject().getRotation() == 3 || e.getObject().getRotation() == 1) Agility.handleObstacle(e.getPlayer(), 3303, 1, e.getPlayer().transform(e.getPlayer().getX() < e.getObject().getX() ? 2 : -2, 0, 0), 0); else Agility.handleObstacle(e.getPlayer(), 3303, 1, e.getPlayer().transform(0, e.getPlayer().getY() < e.getObject().getY() ? 2 : -2, 0), 0); });//wrong animation and trap public static ItemOnObjectHandler TEMPneedropedecendrock = new ItemOnObjectHandler(new Object[] { 28494 }, new Object[] { 954 }, e -> { if (e.getPlayer().getX() == 3382 && e.getPlayer().getY() == 2823) { e.getPlayer().tele(Tile.of(3382, 2826, 0)); } else e.getPlayer().sendMessage(""You are too far away to do this.""); }); }" "package com.rs.game.content.world.areas.varrock; @PluginEventHandler public class Varrock { public static PlayerStepHandler musicBlueMoonInn = new PlayerStepHandler(new Tile[] { Tile.of(3215, 3395, 0), Tile.of(3216, 3395, 0), Tile.of(3233, 3396, 0) }, e -> { if(e.getTile().getX() <= 3216 && e.getStep().dir == Direction.WEST) if(e.getPlayer().getMusicsManager().isPlaying(716)) e.getPlayer().getMusicsManager().nextAmbientSong(); if(e.getTile().getX() == 3216 && e.getStep().dir == Direction.EAST) e.getPlayer().getMusicsManager().playSpecificAmbientSong(716, true); if(e.getTile().getX() == 3233 && e.getStep().dir == Direction.WEST) e.getPlayer().getMusicsManager().playSpecificAmbientSong(716, true); if(e.getTile().getX() == 3233 && e.getStep().dir == Direction.EAST) { if(e.getPlayer().getMusicsManager().isPlaying(716)) e.getPlayer().getMusicsManager().nextAmbientSong(); } }); public static PlayerStepHandler musicDancingDonkeyInn = new PlayerStepHandler(new Tile[] { Tile.of(3274, 3389, 0), Tile.of(3275, 3389, 0) }, e -> { if (e.getTile().getX() <= 3275 && e.getStep().dir == Direction.EAST) if (e.getPlayer().getMusicsManager().isPlaying(721)) e.getPlayer().getMusicsManager().nextAmbientSong(); if (e.getTile().getX() == 3274 && e.getStep().dir == Direction.WEST) e.getPlayer().getMusicsManager().playSpecificAmbientSong(721, true); }); public static PlayerStepHandler musicBoarsHeadInn = new PlayerStepHandler(new Tile[] { Tile.of(3281, 3506, 0), Tile.of(3280, 3506, 0) }, e -> { if (e.getStep().dir == Direction.NORTH) if (e.getPlayer().getMusicsManager().isPlaying(720)) e.getPlayer().getMusicsManager().nextAmbientSong(); if (e.getStep().dir == Direction.SOUTH) e.getPlayer().getMusicsManager().playSpecificAmbientSong(720, true); }); public static NPCClickHandler handlePeskaBarbarianVillage = new NPCClickHandler(new Object[] { 538 }, e -> { int NPC= e.getNPCId(); if(e.getOption().equalsIgnoreCase(""talk-to"")) { e.getPlayer().startConversation(new Dialogue() .addNPC(NPC, HeadE.CALM_TALK, ""Are you interested in buying or selling a helmet?"") .addOptions(""Choose an option:"", new Options() { @Override public void create() { option(""I could be, yes."", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""I could be, yes."") .addNPC(NPC, HeadE.CALM_TALK, ""Let me show you my inventory then..."") .addNext(()-> ShopsHandler.openShop(e.getPlayer(), ""helmet_shop"")) ); option(""No, I'll pass on that."", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""No, I'll pass on that."") .addNPC(NPC, HeadE.CALM_TALK, ""Well, alright."") ); if(e.getPlayer().getQuestManager().getStage(Quest.SCORPION_CATCHER) == ScorpionCatcher.LOOK_FOR_SCORPIONS && e.getPlayer().getQuestManager().getAttribs(Quest.SCORPION_CATCHER).getB(""scorp2LocKnown"")) option(""I've heard you have a small scorpion in your possession."", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""I've heard you have a small scorpion in your possession."") .addNPC(NPC, HeadE.CALM_TALK, ""Now how could you know about that, I wonder? Mind you, I don't have it anymore."") .addNPC(NPC, HeadE.CALM_TALK, ""I gave it as a present to my brother Ivor when I visited our outpost northwest of Camelot."") .addNPC(NPC, HeadE.CALM_TALK, ""Well, actually I hid it in his bed so it would nip him. It was a bit of a surprise gift."") .addPlayer(HeadE.HAPPY_TALKING, ""Okay ill look at the barbarian outpost, perhaps you mean the barbarian agility area?"") .addNPC(NPC, HeadE.SECRETIVE, ""Perhaps..."") ); } }) ); } if(e.getOption().equalsIgnoreCase(""trade"")) ShopsHandler.openShop(e.getPlayer(), ""helmet_shop""); }); public static ObjectClickHandler varrockCenterStairs = new ObjectClickHandler(new Object[] { 24367 }, e -> e.getPlayer().useStairs(-1, Tile.of(e.getObject().getX(), 3476, 1), 1, 2)); public static ObjectClickHandler blueMoonStairs = new ObjectClickHandler(new Object[] { 37117 }, e -> e.getPlayer().useStairs(-1, Tile.of(e.getObject().getX()-2, e.getPlayer().getY(), 0), 1, 2)); public static ObjectClickHandler handleVariousStaircases = new ObjectClickHandler(new Object[] { 24356 }, e -> { Player p = e.getPlayer(); GameObject obj = e.getObject(); if(obj.getRotation() == 0) p.useStairs(-1, Tile.of(p.getX(), obj.getY()+3, p.getPlane() + 1), 0, 1); else if (obj.getRotation() == 1) p.useStairs(-1, Tile.of(p.getX()+4, p.getY(), p.getPlane() + 1), 0, 1); return; }); public static ObjectClickHandler handleChaosAltar = new ObjectClickHandler(new Object[] { 61 }, e -> { Player p = e.getPlayer(); if(e.getOption().equalsIgnoreCase(""Pray-at"")) p.getPrayer().worshipAltar(); else if(e.getOption().equalsIgnoreCase(""Check"")) p.startConversation(new Conversation(p) { { addSimple(""You find a small inscription at the bottom of the altar. It reads: 'Snarthon Candtrick Termanto'.""); create(); } }); }); public static ObjectClickHandler handleDummies = new ObjectClickHandler(new Object[] { 23921 }, e -> { if (e.getPlayer().getSkills().getLevelForXp(Constants.ATTACK) >= 8) { e.getPlayer().sendMessage(""There is nothing more you can learn from hitting a dummy.""); return; } XPType type = e.getPlayer().getCombatDefinitions().getAttackStyle().xpType; if (type != XPType.ACCURATE && type != XPType.AGGRESSIVE && type != XPType.CONTROLLED && type != XPType.DEFENSIVE) { e.getPlayer().sendMessage(""You can't hit a dummy with that attack style.""); return; } e.getPlayer().setNextAnimation(new Animation(PlayerCombatKt.getWeaponAttackEmote(e.getPlayer().getEquipment().getWeaponId(), e.getPlayer().getCombatDefinitions().getAttackStyle()))); e.getPlayer().lock(3); World.sendObjectAnimation(e.getObject(), new Animation(6482)); e.getPlayer().getSkills().addXp(Constants.ATTACK, 5); }); public static ObjectClickHandler handleVarrockSewerEntrance = new ObjectClickHandler(new Object[] { ""Manhole"" }, e -> { Player p = e.getPlayer(); GameObject obj = e.getObject(); if(e.getOption().equalsIgnoreCase(""Climb-Down"")) if(obj.getTile().matches(Tile.of(3237, 3458, 0))) p.useStairs(833, Tile.of(3237, 9858, 0), 1, 2); }); public static ObjectClickHandler handleKeldagrimTrapdoor = new ObjectClickHandler(new Object[] { 28094 }, e -> e.getPlayer().tele(Tile.of(2911, 10176, 0))); public static ObjectClickHandler handleRiverLumSteppingStones = new ObjectClickHandler(new Object[] { 9315 }, e -> { if (!Agility.hasLevel(e.getPlayer(), 31)) return; AgilityShortcuts.walkLog(e.getPlayer(), e.getPlayer().transform(e.getObject().getRotation() == 1 ? -5 : 5, 0, 0), 4); }); public static ObjectClickHandler handleGrandExchangeShortcut = new ObjectClickHandler(new Object[] { 9311, 9312 }, e -> { if (!Agility.hasLevel(e.getPlayer(), 21)) return; WorldTasks.scheduleLooping(new Task() { int ticks = 0; @Override public void run() { boolean withinGE = e.getObjectId() == 9312; Tile tile = withinGE ? Tile.of(3139, 3516, 0) : Tile.of(3143, 3514, 0); e.getPlayer().lock(); ticks++; if (ticks == 1) { e.getPlayer().forceMove(e.getObject().getTile(), 2589, 5, 35, false); } else if (ticks == 3) { e.getPlayer().setNextAnimation(new Animation(2590)); } else if (ticks == 5) { e.getPlayer().setNextAnimation(new Animation(2591)); e.getPlayer().tele(tile); } else if (ticks == 6) { e.getPlayer().tele(Tile.of(tile.getX() + (withinGE ? -1 : 1), tile.getY(), tile.getPlane())); e.getPlayer().unlock(); stop(); } } }, 0, 0); }); public static ObjectClickHandler handleFenceShortcut = new ObjectClickHandler(new Object[] { 9300 }, e -> { if (!e.isAtObject()) return; switch (e.getObject().getRotation()) { case 0 -> AgilityShortcuts.climbOver(e.getPlayer(), e.getPlayer().transform(e.getPlayer().getX() >= e.getObject().getX() ? -1 : 1, 0, 0), 839); case 1 -> AgilityShortcuts.climbOver(e.getPlayer(), e.getPlayer().transform(0, e.getPlayer().getY() >= e.getObject().getY() ? -1 : 1, 0), 839); case 2 -> AgilityShortcuts.climbOver(e.getPlayer(), e.getPlayer().transform(e.getPlayer().getX() >= e.getObject().getX() ? -1 : 1, 0, 0), 839); case 3 -> AgilityShortcuts.climbOver(e.getPlayer(), e.getPlayer().transform(0, e.getPlayer().getY() >= e.getObject().getY() ? -1 : 1, 0), 839); } }); public static ObjectClickHandler handleStileShortcuts = new ObjectClickHandler(new Object[] { 45205, 34776, 48208 }, e -> { if (!e.isAtObject()) return; switch (e.getObject().getRotation()) { case 0 -> AgilityShortcuts.climbOver(e.getPlayer(), e.getPlayer().transform(0, e.getPlayer().getY() >= e.getObject().getY() ? -3 : 3, 0), 839); case 1 -> AgilityShortcuts.climbOver(e.getPlayer(), e.getPlayer().transform(e.getPlayer().getX() >= e.getObject().getX() ? -3 : 3, 0, 0), 839); case 2 -> AgilityShortcuts.climbOver(e.getPlayer(), e.getPlayer().transform(0, e.getPlayer().getY() >= e.getObject().getY() ? -3 : 3, 0), 839); case 3 -> AgilityShortcuts.climbOver(e.getPlayer(), e.getPlayer().transform(e.getPlayer().getX() >= e.getObject().getX() ? -3 : 3, 0, 0), 839); } }); public static ObjectClickHandler handlePhoenixGangHideoutLadder = new ObjectClickHandler(new Object[] { 24363 }, e -> { if (e.getObject().getTile().matches(Tile.of(3244, 3383, 0)) && e.getOption().equalsIgnoreCase(""climb-down"")) e.getPlayer().ladder(Tile.of(3245, 9783, 0)); }); public static ObjectClickHandler handlePhoenixGangVarrockLadder = new ObjectClickHandler(new Object[] { 2405 }, e -> { if (e.getObject().getTile().matches(Tile.of(3244, 9783, 0)) && e.getOption().equalsIgnoreCase(""climb-up"")) e.getPlayer().ladder(Tile.of(3243, 3383, 0)); }); public static ObjectClickHandler handleChampionsGuildFrontDoor = new ObjectClickHandler(new Object[] { 1805 }, e -> { Player p = e.getPlayer(); GameObject obj = e.getObject(); if (p.getY() >= obj.getY()) { if (p.getQuestManager().getQuestPoints() <= 31) { e.getPlayer().startConversation(new Conversation(e.getPlayer()) { { addSimple(""You need 32 quest points to enter the champions guild.""); create(); } }); return; } Doors.handleDoor(p, obj); p.npcDialogue(198, HeadE.CHEERFUL, ""Greetings bold adventurer. Welcome to the guild of Champions.""); } else Doors.handleDoor(p, obj); }); }" "package com.rs.game.content.world.areas.varrock.npcs; @PluginEventHandler public class Asyff extends Conversation { public static NPCClickHandler fancyShopOwner = new NPCClickHandler(new Object[] { 554 }, e -> { final int npcId = 554; switch(e.getOption()) { case ""Talk-to"" -> e.getPlayer().startConversation(new Asyff(e.getPlayer())); case ""Trade"" -> ShopsHandler.openShop(e.getPlayer(), ""fancy_clothes_store""); case ""Fur-shop"" -> { e.getPlayer().getPackets().sendItems(482, Arrays.stream(InventoryDefinitions.getContainer(482).ids).mapToObj(id -> new Item(id, 1)).toArray(Item[]::new)); e.getPlayer().getInterfaceManager().sendInterface(477); e.getPlayer().getPackets().setIFRightClickOps(477, 26, 0, 20, 0, 1, 2, 3); } } }); public Asyff(Player player) { super(player); final int npcId = 554; addNPC(npcId, HeadE.HAPPY_TALKING,""Now you look like someone who goes to a lot of fancy dress parties.""); addPlayer(HeadE.CONFUSED,""Errr...what are you saying exactly?""); addNPC(npcId,HeadE.HAPPY_TALKING,""I'm just saying that perhaps you would like to peruse my selection of garments.""); addNPC(npcId,HeadE.SKEPTICAL_THINKING,""Or, if that doesn't interest you, then maybe you have something else to offer? I'm always on the look out for interesting or unusual new materials.""); addOptions(new Options() { @Override public void create() { option(""Okay, lets see what you've got then."", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Okay, lets see what you've got then."") .addNext(() -> ShopsHandler.openShop(player, ""fancy_clothes_store""))); option(""Can you make clothing suitable for hunting in?"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Can you make clothing suitable for hunting in?"") .addNPC(npcId, HeadE.SKEPTICAL, ""Certainly. Take a look at my range of made-to-order items. If you can supply the furs, I'll gladly make any of these for you."") .addNext(() -> { player.getPackets().sendItems(482, Arrays.stream(InventoryDefinitions.getContainer(482).ids).mapToObj(id -> new Item(id, 1)).toArray(Item[]::new)); player.getInterfaceManager().sendInterface(477); player.getPackets().setIFRightClickOps(477, 26, 0, 20, 0, 1, 2, 3); })); option(""I'm okay thanks."", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""I'm okay thanks."")); } }); } enum FurItem { POLAR_TOP(10065, 20, 2, 10117), POLAR_BOT(10067, 20, 2, 10117), WOODS_TOP(10053, 20, 2, 10121), WOODS_BOT(10055, 20, 2, 10121), FELDI_TOP(10057, 20, 2, 10119), FELDI_BOT(10059, 20, 2, 10119), DESER_TOP(10061, 20, 2, 10123), DESER_BOT(10063, 20, 2, 10123), LARUP_HAT(10045, 500, 1, 10095), LARUP_TOP(10043, 100, 1, 10093, 10095), LARUP_BOT(10041, 100, 1, 10093, 10095), GRAAH_HAT(10051, 750, 1, 10099), GRAAH_TOP(10049, 150, 1, 10097, 10099), GRAAH_BOT(10047, 150, 1, 10097, 10099), KYATT_HAT(10039, 1000, 1, 10103), KYATT_TOP(10037, 200, 1, 10101, 10103), KYATT_BOT(10035, 200, 1, 10101, 10103), GLOVES_SI(10075, 600, 2, 10115), SPOT_CAPE(10069, 400, 2, 10125), SPOTICAPE(10071, 800, 2, 10127); private static final Map BY_ITEMID = new HashMap<>(); static { for (FurItem item : FurItem.values()) BY_ITEMID.put(item.id, item); } private final int id; private final int gpCost; private final int furCost; private final int[] furIds; FurItem(int itemId, int gpCost, int furCost, int... furIds) { this.id = itemId; this.gpCost = gpCost; this.furCost = furCost; this.furIds = furIds; } private static FurItem forId(int item) { return BY_ITEMID.get(item); } } private static void buy(Player player, FurItem item, int amount) { player.sendOptionDialogue(""Are you sure you'd like to buy "" + amount + "" "" + ItemDefinitions.getDefs(item.id).name + ""?"", ops -> { ops.add(""Yes, I am sure (""+ Utils.formatNumber(item.gpCost*amount) + "" coins)"", () -> { if (item.furCost*amount > player.getInventory().getTotalNumberOf(item.furIds)) { player.sendMessage(""You don't have enough furs to exchange for that.""); return; } int paid = 0; for (int i = 0;i < amount*2;i++) { for (int furId : item.furIds) { if (player.getInventory().containsItem(furId)) { player.getInventory().deleteItem(furId, 1); if (++paid == (item.furCost*amount)) break; } } } player.getInventory().addItemDrop(item.id, amount); }); ops.add(""No thanks.""); }); } public static ButtonClickHandler furclothingShop = new ButtonClickHandler(477, e -> { FurItem item = FurItem.forId(e.getSlotId2()); if (item == null) return; String name = ItemDefinitions.getDefs(e.getSlotId2()).name; switch(e.getPacket()) { case IF_OP1 -> e.getPlayer().sendMessage(name + "" costs "" + Utils.formatNumber(item.gpCost) + ""gp and "" + item.furCost + "" "" + ItemDefinitions.getDefs(item.furIds[0]).name.toLowerCase() + "".""); case IF_OP2 -> buy(e.getPlayer(), item, 1); case IF_OP3 -> buy(e.getPlayer(), item, 5); case IF_OP4 -> buy(e.getPlayer(), item, 10); default -> {} } }); }" "package com.rs.game.content.world.areas.varrock.npcs; @PluginEventHandler public class Baraek { public static NPCClickHandler handleBaraek = new NPCClickHandler(new Object[] { 547 }, e -> { if(e.getPlayer().isQuestComplete(Quest.SHIELD_OF_ARRAV)) e.getPlayer().sendMessage(""Nothing interesting happens""); else e.getPlayer().startConversation(new BaraekShieldOfArravD(e.getPlayer()).getStart()); }); }" "package com.rs.game.content.world.areas.varrock.npcs class BartenderBlueMoonInn(p: Player, npc: NPC) { init { p.startConversation { npc(npc, HeadE.HAPPY_TALKING, ""What can I do yer for?"") options { if (!isBarVisited(p, BLUE_MOON_INN) && hasCard(p) && onBarCrawl(p)) { op(""I'm doing Alfred Grimhand's Barcrawl"") { player(HeadE.HAPPY_TALKING, ""I'm doing Alfred Grimhand's Barcrawl. Do you have any ${BLUE_MOON_INN.drinkName}?"") npc(npc, HeadE.FRUSTRATED, ""Oh no not another of you guys."") npc(npc, HeadE.FRUSTRATED, ""These barbarian barcrawls cause too much damage to my bar."") npc(npc, HeadE.CALM, ""You're going to have to pay me ${BLUE_MOON_INN.price} gold for the ${BLUE_MOON_INN.drinkName}."") exec { buyBarcrawlDrink(p, BLUE_MOON_INN); } } } op(""A glass of your finest ale please."") { player(HeadE.HAPPY_TALKING, ""A glass of your finest ale please."") npc(npc, HeadE.HAPPY_TALKING, ""No problemo. That'll be 2 coins."") exec { buyDrinkOrIngredients(p, npc, 2, Item(1917), true) } } op(""Can you recommend where an adventurer might make his fortune?"") { player(HeadE.HAPPY_TALKING, ""Can you recommend where an adventurer might make his fortune?"") npc(npc, HeadE.HAPPY_TALKING, ""Ooh I don't know if I should be giving away information, makes the game too easy."") options { op(""Oh ah well..."") { player(HeadE.SAD_MILD, ""Oh ah well..."") } op(""Game? What are you talking about?"") { player(HeadE.SKEPTICAL_THINKING, ""Game? What are you talking about?"") npc(npc, HeadE.TALKING_ALOT, ""This world around us... is an online game... called RuneScape."") player(HeadE.SKEPTICAL_THINKING, ""Nope, still don't understand what you are talking about. What does 'online' mean?"") npc(npc, HeadE.TALKING_ALOT, ""It's a sort of connection between magic boxes across the world, big boxes on people's desktops and little ones people can carry. They can talk to each other to play games."") player(HeadE.AMAZED_MILD, ""I give up. You're obviously completely mad!"") } op(""Just a small clue?"") { player(HeadE.HAPPY_TALKING, ""Just a small clue?"") npc(npc, HeadE.HAPPY_TALKING, ""Go and talk to the bartender at the Jolly Boar Inn, he doesn't seem to mind giving away clues."") } } } op(""Do you know where I can get some good equipment?"") { player(HeadE.HAPPY_TALKING, ""Do you know where I can get some good equipment?"") npc(npc, HeadE.HAPPY_TALKING, ""Well, there's the sword shop across the road, or there's also all sorts of shops up around the market."") } } } } } @ServerStartupEvent fun mapBartenderBlueMoonInn() { onNpcClick(733) { (player, npc) -> BartenderBlueMoonInn(player, npc) } }" "package com.rs.game.content.world.areas.varrock.npcs class BartenderJollyBoarInn(p: Player, npc: NPC) { init { p.startConversation { npc(npc, HeadE.HAPPY_TALKING, ""Can I help you?"") options { op(""I'll have a beer please."") { player(HeadE.HAPPY_TALKING, ""I'll have a pint of beer please."") npc(npc, HeadE.HAPPY_TALKING, ""Ok, that'll be two coins please."") exec { buyDrinkOrIngredients(p, npc, 2, Item(1917), true) } } op(""Any hints where I can go adventuring?"") { player(HeadE.HAPPY_TALKING, ""Any hints on where I can go adventuring?"") npc(npc, HeadE.SKEPTICAL_THINKING, ""Ooh, now. Let me see..."") npc(npc, HeadE.CHEERFUL, ""Well there is the Varrock sewers. There are tales of untold horrors coming out at night and stealing babies from houses."") player(HeadE.CHEERFUL, ""Sounds perfect! Where's the entrance?"") npc(npc, HeadE.CHEERFUL, ""It's just to the east of the palace."") } op(""Heard any good gossip?"") { player(HeadE.SECRETIVE, ""Heard any gossip?"") npc(npc, HeadE.LAUGH, ""I'm not that well up on the gossip out here. I've heard that the bartender in the Blue Moon Inn has gone a little crazy, he keeps claiming he is part of something called a computer game."") npc(npc, HeadE.LAUGH, ""What that means, I don't know. That's probably old news by now though."") } if (!isBarVisited(p, JOLLY_BOAR_INN) && hasCard(p) && onBarCrawl(p)) { op(""I'm doing Alfred Grimhand's Barcrawl."") { player(HeadE.HAPPY_TALKING, ""I'm doing Alfred Grimhand's Barcrawl."") npc(npc, HeadE.CHEERFUL, ""Ah, there seems to be a fair few doing that one these days. My supply of ${JOLLY_BOAR_INN.drinkName} is starting to run low, it'll cost you ${JOLLY_BOAR_INN.price} coins."") exec { buyBarcrawlDrink(p, JOLLY_BOAR_INN) } } } } } } } @ServerStartupEvent fun mapBartenderJollyBoarInn() { onNpcClick(731) { (player, npc) -> BartenderJollyBoarInn(player, npc) } }" "package com.rs.game.content.world.areas.varrock.npcs; @PluginEventHandler public class Benny extends Conversation { public static NPCClickHandler handleArtimeus = new NPCClickHandler(new Object[] { 5925 }, e -> { switch(e.getOption()) { case ""Talk-to"" -> e.getPlayer().startConversation(new Benny(e.getPlayer(), e.getNPC())); } }); public Benny(Player player, NPC npc) { super(player); addOptions(this, ""baseOptions"", ops -> { ops.add(""Can I have a newspaper, please?"") .addPlayer(HeadE.CONFUSED, ""Can I have a newspaper, please?"") .addNPC(npc.getId(), HeadE.CALM_TALK, ""Certainly, "" + (player.getAppearance().isMale() ? ""Guv"" : ""Missus"") + "". That'll be 50 gold pieces, please."") .addOptions(ops2 -> { ops2.add(""Sure, here you go."") .addPlayer(HeadE.CALM_TALK, ""Sure, here you go."") .addItemToInv(player, new Item(11169, 1), ""You buy a newspaper."") .addGotoStage(""baseOptions"", this); ops2.add(""Uh, no thanks, I've changed my mind."") .addPlayer(HeadE.CALM_TALK, ""Uh, no thanks, I've changed my mind."") .addNPC(npc.getId(), HeadE.CALM_TALK, ""Ok, suit yourself. Plenty more fish in the sea."") .addGotoStage(""baseOptions"", this); }); ops.add(""How much does a paper cost?"") .addPlayer(HeadE.CONFUSED, ""How much does a paper cost?"") .addNPC(npc.getId(), HeadE.CALM_TALK, ""Just 50 gold pieces! An absolute bargain! Want one?"") .addOptions(ops2 -> { ops2.add(""Sure, here you go."") .addPlayer(HeadE.CALM_TALK, ""Sure, here you go."") .addItemToInv(player, new Item(11169, 1), ""You buy a newspaper."") .addGotoStage(""baseOptions"", this); ops2.add(""No, thanks."") .addPlayer(HeadE.CALM_TALK, ""No, thanks."") .addNPC(npc.getId(), HeadE.CALM_TALK, ""Ok, suit yourself. Plenty more fish in the sea."") .addGotoStage(""baseOptions"", this); }); ops.add(""Varrock Herald? Never heard of it."") .addPlayer(HeadE.CONFUSED, ""Varrock Herald? Never heard of it."") .addNPC(npc.getId(), HeadE.CALM_TALK, ""For the illiterate amongst us, I shall elucidate. The Varrock Herald is a new newspaper. It is edited, printed and published by myself, Benny Gutenberg, and each edition promises to enthrall the reader with captivating material! Now, can I interest you in buying one for a mere 50 gold?"") .addOptions(this, ""newspaperOptions"", ops4 -> { ops4.add(""Sure, here you go."") .addPlayer(HeadE.CHEERFUL, ""Sure, here you go."") .addNPC(npc.getId(), HeadE.CHEERFUL, ""Thank you, here is your newspaper!"") .addItemToInv(player, new Item(11169, 1), ""You buy a newspaper."") .addGotoStage(""baseOptions"", this); ops4.add(""No, thanks."") .addPlayer(HeadE.CALM_TALK, ""No, thanks."") .addNPC(npc.getId(), HeadE.CALM_TALK, ""Ok, suit yourself. Plenty more fish in the sea."") .addGotoStage(""baseOptions"", this); }); }); } }" "package com.rs.game.content.world.areas.varrock.npcs; @PluginEventHandler public class ChamiponsGuildmaster { public static NPCClickHandler handleGuildMaster = new NPCClickHandler(new Object[] { 198 }, e -> { if (e.getPlayer().getQuestManager().getQuestPoints() <= 31) { e.getPlayer().startConversation(new Conversation(e.getPlayer()) { { addNPC(e.getNPCId(), HeadE.FRUSTRATED, ""You really shouldn't be in here, but I will let that slide...""); create(); } }); return; } e.getPlayer().startConversation(new Conversation(e.getPlayer()) { { addNPC(e.getNPCId(), HeadE.CHEERFUL, ""Greetings!""); addOptions(""What would you like to say?"", new Options() { @Override public void create() { option(""What is this place?"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""What is this place?"") .addNPC(198, HeadE.HAPPY_TALKING, ""This is the Champions' Guild. Only adventurers who have proved themselves worthy "" + ""by gaining influence from quests are allowed in here."")); if(!e.getPlayer().isQuestComplete(Quest.DRAGON_SLAYER)) option(""About Dragon Slayer"", new Dialogue() .addNext(()-> e.getPlayer().startConversation(new GuildMasterDragonSlayerD(e.getPlayer()).getStart()))); } }); create(); } }); }); }" "package com.rs.game.content.world.areas.varrock.npcs; @PluginEventHandler public class Charlie { public static NPCClickHandler handleCharlie = new NPCClickHandler(new Object[] { 641 }, e -> { if(e.getPlayer().isQuestComplete(Quest.SHIELD_OF_ARRAV)) e.getPlayer().sendMessage(""Nothing interesting happens""); else e.getPlayer().startConversation(new CharlieTheTrampArravD(e.getPlayer()).getStart()); }); }" "package com.rs.game.content.world.areas.varrock.npcs; @PluginEventHandler public class Curator { public static NPCClickHandler handleMuseumCurator = new NPCClickHandler(new Object[] { 646 }, e -> { if(e.getOption().equalsIgnoreCase(""talk-to"")) e.getPlayer().startConversation(new Conversation(e.getPlayer()) { { addOptions(""What would you like to say?"", new Options() { @Override public void create() { option(""About Shield Of Arrav..."", new MuseumCuratorArravD(player).getStart()); option(""Farewell."", new Dialogue()); } }); create(); } }); }); }" "package com.rs.game.content.world.areas.varrock.npcs; @PluginEventHandler public class Dealga { public static NPCClickHandler handleDealga = new NPCClickHandler(new Object[] { 11475 }, e -> ShopsHandler.openShop(e.getPlayer(), ""dealgas_scimitar_emporium"")); }" "package com.rs.game.content.world.areas.varrock.npcs; @PluginEventHandler public class JohnnyTheBeard { public static NPCClickHandler handleJohnnyTheBeard = new NPCClickHandler(new Object[] { 645 }, new String[] { ""Talk-to"" }, e -> e.getPlayer().sendMessage(""Johnny the beard is not interested in talking."")); }" "package com.rs.game.content.world.areas.varrock.npcs; @PluginEventHandler public class Katrine { public static NPCClickHandler handleKatrine = new NPCClickHandler(new Object[] { 642 }, e -> { Player p = e.getPlayer(); if(p.isQuestComplete(Quest.SHIELD_OF_ARRAV ) && ShieldOfArrav.isBlackArmGang(p) && p.getQuestManager().getStage(Quest.HEROES_QUEST) > 0) p.startConversation(new KatrineHeroesQuestD(p).getStart()); else p.startConversation(new KatrineShieldOfArravD(p).getStart()); }); }" "package com.rs.game.content.world.areas.varrock.npcs; //import com.rs.game.content.quests.allfiredup.KingRoaldAllFiredUpD; @PluginEventHandler public class KingRoald { public static final int ID = 648; public static NPCClickHandler handleKingRoald = new NPCClickHandler(new Object[]{ ID }, e -> { Dialogue showQuests = new Dialogue().addOptions(questOptions -> { if (!e.getPlayer().isQuestComplete(Quest.PRIEST_IN_PERIL)) questOptions.add(""About Priest In Peril..."", () -> new KingRoaldPriestInPerilD(e.getPlayer())); if (!e.getPlayer().isQuestComplete(Quest.SHIELD_OF_ARRAV)) questOptions.add(""About Shield Of Arrav..."", new KingRoaldShieldOfArravD(e.getPlayer()).getStart()); // if (e.getPlayer().isQuestComplete(Quest.PRIEST_IN_PERIL) && !e.getPlayer().isQuestComplete(Quest.ALL_FIRED_UP) && e.getPlayer().getSkills().getLevel(Skills.FIREMAKING) >= 43) // options.add(""About All Fired Up..."", new KingRoaldAllFiredUpD(e.getPlayer())); questOptions.add(""Farewell.""); }); Dialogue showLetter = new Dialogue() .addPlayer(HeadE.CALM_TALK, ""Your majesty, I think that you should see this letter."") .addNPC(ID, HeadE.CALM_TALK, ""Letter? Let me see. Where's Postie Pete? He usually deals with the mail around here."") .addPlayer(HeadE.CALM_TALK, ""This letter was delivered to me by hand, your majesty. I think you may be in some danger."") .addNPC(ID, HeadE.CALM_TALK, ""Hmmm. I see. I appreciate your concern. However, I assure you, I am quite safe here. My guards are on full alert at all times."") .addPlayer(HeadE.CALM_TALK, ""I don't think you understand..."") .addNPC(ID, HeadE.CALM_TALK, ""I understand perfectly. Now, for all I know, that letter could be a fake ruse. We get a lot of that sort of thing and it causes a lot of hassle."") .addPlayer(HeadE.ANGRY, ""I'm trying to save your life!"") .addNPC(ID, HeadE.ANGRY, ""And you are shouting at your king! People who yell at their monarchs often find their heads become...loose!"") .addPlayer(HeadE.CALM_TALK, ""I'm just saying that the letter is real."") .addNPC(ID, HeadE.CONFUSED, ""Then why do you have it?"") .addPlayer(HeadE.CONFUSED, ""Because I'm supposed to deliv...oh."") .addNPC(ID, HeadE.CALM_TALK, ""It seems to me that if that letter were genuine, I would be forced to arrest its bearer for treason. You understand."") .addNPC(ID, HeadE.CONFUSED, ""So what do you say?"") .addPlayer(HeadE.SAD_MILD, ""I...er...reckon it's a fake! ...I guess..."") .addNPC(ID, HeadE.CHEERFUL, ""Just as I thought! Now off you go!""); e.getPlayer().startConversation(new Dialogue() .addOptions(outerOptions -> { outerOptions.add(""Greet the king."", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Hello, your majesty."") .addNPC(ID, HeadE.CHEERFUL, ""Hello citizen, what can I do for you?"") .addNext(showQuests)); if (e.getPlayer().getInventory().containsItem(11010)) outerOptions.add(""Show him the letter."", showLetter); outerOptions.add(""Nevermind.""); })); } ); }" "package com.rs.game.content.world.areas.varrock.npcs @ServerStartupEvent fun mapMarketGuardPlugins() { onNpcClick(11269) { (player, npc) -> val miniquestManager = player.miniquestManager val distracted = miniquestManager.getAttribs(Miniquest.FROM_TINY_ACORNS).getB(""UristDistracted"") if (distracted) { distracted(player, npc) return@onNpcClick } if (player.isMiniquestStarted(Miniquest.FROM_TINY_ACORNS)) { preQuest(player, npc) return@onNpcClick } stage1(player, npc) } } private fun preQuest(player: Player, npc: NPC) { player.startConversation { npc(npc, CALM_TALK, ""Greetings, citizen."") player(CHEERFUL, ""Good day to you."") options { op(""How's everything going today?"") { npc(npc, CALM, ""Fairly uneventful so far. Varrock's not the hotbed of crime that Ardougne is, after all."") player(HAPPY_TALKING, ""I'll let you get on with it then."") npc(npc, CALM, ""Stay safe, citizen."") } op(""Goodbye."") { player(HAPPY_TALKING, ""Goodbye."") npc(npc, CALM, ""Stay safe, citizen."") } } } } private fun stage1(player: Player, npc: NPC) { player.startConversation { npc(npc, CALM_TALK, ""Greetings, citizen."") player(CHEERFUL, ""Good day to you."") options { op(""How's everything going today?"") { npc(npc, CALM, ""Fairly uneventful so far. Varrock's not the hotbed of crime that Ardougne is, after all."") player(HAPPY_TALKING, ""I'll let you get on with it then."") npc(npc, CALM, ""Stay safe, citizen."") } op(""Who's the dwarf over there?"") { player(SKEPTICAL, ""Who's the dwarf over there?"") npc(npc, SKEPTICAL, ""Urist Loric. He's a craftsman from some fortress or other. Does some seriously delicate work, if the magnification on that monocle is anything to go by."") player(SKEPTICAL, ""Do you know what he's working on?"") npc(npc, CALM_TALK, ""It's a toy dragon of some sort. I've been keeping an eye on him 'cos he's working with some seriously valuable materials, but nobody's tried anything yet. Nobody's going to either, I reckon. Must have heard I'm on the case."") player(CHEERFUL_EXPOSITION, ""How's his dragon coming along?"") npc(npc, CALM_TALK, ""Looks like it's almost finished."") player(CHEERFUL, ""He seems very focused."") npc(npc, CALM_TALK, ""There's only two things he cares more about than his work, and he's had his morning booze."") player(SKEPTICAL, ""What's the other thing?"") npc(npc, CALM_TALK, ""Oh, some sort of talisman he keeps in his back pocket. I've told him he shouldn't keep it there - it's asking to be stolen - but he won't listen."") player(HAPPY_TALKING, ""I'll let you get on with it, then."") npc(npc, CALM_TALK, ""Stay safe, citizen."") } op(""Goodbye."") { player(HAPPY_TALKING, ""Goodbye."") npc(npc, CALM, ""Stay safe, citizen."") } } } } private fun distracted(player: Player, npc: NPC) { player.startConversation { player(CHEERFUL_EXPOSITION, ""Gypsy Aris' sign is giving you the evil eye!"") npc(npc, CONFUSED, ""What? Not again!"") { player.schedule { var count = 0 while (true) { val distracted = player.miniquestManager.getAttribs(Miniquest.FROM_TINY_ACORNS).getB(""UristDistracted"") if (distracted) { if (count == 0) { npc.faceTile(Tile.of(3208, 3423, 0)) npc.forceTalk(""Hmm, it looks innocuous to me."") player.miniquestManager.getAttribs(Miniquest.FROM_TINY_ACORNS).setB(""GuardDistracted"", true) } else { npc.forceTalk(""Hmm..."") } count++ wait(Ticks.fromSeconds(1)) } else { player.miniquestManager.getAttribs(Miniquest.FROM_TINY_ACORNS).setB(""GuardDistracted"", false) npc.faceEast() break } } } } } }" "package com.rs.game.content.world.areas.varrock.npcs; @PluginEventHandler public class Minas { public static NPCClickHandler handleHistorianMinas = new NPCClickHandler(new Object[] { 5931 }, e -> { if(e.getOption().equalsIgnoreCase(""talk-to"")) e.getPlayer().startConversation(new Conversation(e.getPlayer()) { { addPlayer(HeadE.CHEERFUL, ""Hello.""); addOptions(""What would you like to say?"", new Options() { @Override public void create() { if (e.getPlayer().isQuestComplete(Quest.SHIELD_OF_ARRAV) && !((boolean)e.getPlayer().get(""claimedArravLamp""))) option(""About Shield Of Arrav..."", new Dialogue() .addNPC(5931, HeadE.HAPPY_TALKING, ""Thank you for returning the shield"") .addSimple(""A lamp is placed in your hand"") .addNext(() -> { e.getPlayer().getInventory().addItem(4447, 1); e.getPlayer().save(""claimedArravLamp"", true); })); else if(e.getPlayer().isQuestComplete(Quest.SHIELD_OF_ARRAV)) option(""About Shield Of Arrav..."", new Dialogue() .addNPC(5931, HeadE.HAPPY_TALKING, ""Thank you for returning the shield"")); else option(""About Shield Of Arrav..."", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""There is nothing to say."")); option(""Farewell.""); } }); create(); } }); }); }" "package com.rs.game.content.world.areas.varrock.npcs; @PluginEventHandler public class Naff { public static NPCClickHandler handleNaff = new NPCClickHandler(new Object[] { 359 }, e -> { int max = 8; if (AchievementDef.meetsRequirements(e.getPlayer(), AchievementDef.Area.VARROCK, AchievementDef.Difficulty.ELITE, false)) max = 80; else if (AchievementDef.meetsRequirements(e.getPlayer(), AchievementDef.Area.VARROCK, AchievementDef.Difficulty.HARD, false)) max = 64; else if (AchievementDef.meetsRequirements(e.getPlayer(), AchievementDef.Area.VARROCK, AchievementDef.Difficulty.MEDIUM, false)) max = 32; else if (AchievementDef.meetsRequirements(e.getPlayer(), AchievementDef.Area.VARROCK, AchievementDef.Difficulty.EASY, false)) max = 16; int amountLeft = max - e.getPlayer().getDailyI(""naffStavesBought""); if (amountLeft <= 0) { e.getPlayer().sendMessage(""Naff has no staves left today.""); return; } if (!e.getPlayer().getInventory().hasFreeSlots()) { e.getPlayer().sendMessage(""You don't have enough inventory space to buy any staves.""); return; } e.getPlayer().sendInputInteger(""How many battlestaves would you like to buy? ("" + amountLeft +"" available)"", amount -> { int coinsOnPlayer = e.getPlayer().getInventory().getCoinsAsInt(); int maxBuyable = coinsOnPlayer / 7000; if (amount > maxBuyable) amount = maxBuyable; if (amount > amountLeft) amount = amountLeft; if (amount <= 0) { e.getPlayer().sendMessage(""You don't have enough money to buy any staves right now.""); return; } final int finalAmount = amount; final int cost = 7000 * amount; e.getPlayer().sendOptionDialogue(""Buy "" + amount + "" battlestaves for "" + Utils.formatNumber(cost) + "" coins?"", ops -> { ops.add(""Yes"", () -> { if (!e.getPlayer().getInventory().hasCoins(cost)) { e.getPlayer().sendMessage(""You don't have enough money for that.""); return; } e.getPlayer().getInventory().removeCoins(cost); e.getPlayer().getInventory().addItemDrop(1392, finalAmount); e.getPlayer().setDailyI(""naffStavesBought"", e.getPlayer().getDailyI(""naffStavesBought"") + finalAmount); }); ops.add(""Not thanks.""); }); }); }); }" "package com.rs.game.content.world.areas.varrock.npcs; @PluginEventHandler public class Reldo { public static NPCClickHandler handleReldo = new NPCClickHandler(new Object[] { 647 }, e -> e.getPlayer().startConversation(new Conversation(e.getPlayer()) { { addNPC(e.getNPCId(), HeadE.CHEERFUL, ""Hello, what are you after?""); addOptions(""What would you like to say?"", new Options() { @Override public void create() { if(!e.getPlayer().isQuestComplete(Quest.SHIELD_OF_ARRAV)) option(""About Shield Of Arrav..."", new ReldoShieldOfArravD(player).getStart()); if(e.getPlayer().getQuestManager().getStage(Quest.KNIGHTS_SWORD) >= KnightsSword.TALK_TO_RELDO && !e.getPlayer().isQuestComplete(Quest.KNIGHTS_SWORD)) option(""About Knight's Sword..."", new ReldoKnightsSwordD(player).getStart()); option(""About the Achievement System..."", () -> new AchievementSystemD(player, e.getNPCId(), SetReward.VARROCK_ARMOR)); } }); create(); } })); }" "package com.rs.game.content.world.areas.varrock.npcs; @PluginEventHandler public class Scavvo { public static NPCClickHandler handleValaineChampsGuild = new NPCClickHandler(new Object[] { 537 }, e -> { int NPC = e.getNPCId(); if (e.getOption().equalsIgnoreCase(""talk-to"")) e.getPlayer().startConversation(new Dialogue() .addNPC(NPC, HeadE.CALM_TALK, ""Hello there. Want to have a look at what we're selling today?"") .addOptions(""Choose an option:"", new Options() { @Override public void create() { option(""Yes, please."", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Yes, please."") .addNext(() -> ShopsHandler.openShop(e.getPlayer(), ""scavvos_rune_shop""))); option(""No, thank you."", new Dialogue().addPlayer(HeadE.HAPPY_TALKING, ""No, thank you."").addNPC(NPC, HeadE.CALM_TALK, ""Well, alright."")); } })); if (e.getOption().equalsIgnoreCase(""trade"")) ShopsHandler.openShop(e.getPlayer(), ""scavvos_rune_shop""); }); }" "package com.rs.game.content.world.areas.varrock.npcs; @PluginEventHandler public class Straven { public static NPCClickHandler handleStraven = new NPCClickHandler(new Object[] { 644 }, e -> { Player p = e.getPlayer(); if(p.isQuestComplete(Quest.SHIELD_OF_ARRAV ) && ShieldOfArrav.isPhoenixGang(p) && p.getQuestManager().getStage(Quest.HEROES_QUEST) > 0) //started p.startConversation(new StravenHeroesQuestD(p).getStart()); else p.startConversation(new StravenShieldOfArravD(p).getStart()); }); }" "package com.rs.game.content.world.areas.varrock.npcs; @ServerStartupEvent fun handleTarquin() { onNpcClick(3328) { e -> e.player.startConversation(CanoeD(e.player, e.npc)) } }" "package com.rs.game.content.world.areas.varrock.npcs private const val talisman = 18649 private const val bankNote = 18652 private const val babyDragon = 18651 private const val waitTime = 5 private val uristTile: Tile = Tile.of(3222, 3424, 0) @ServerStartupEvent fun mapUristPlugins() { onNpcClick(11270, options = arrayOf(""Talk-to"")) { (player, npc) -> if (npc.tile != uristTile) { player.sendMessage(""He looks busy."") return@onNpcClick } if (!player.isMiniquestStarted(Miniquest.FROM_TINY_ACORNS)) { preQuest(player) return@onNpcClick } if (player.isMiniquestComplete(Miniquest.FROM_TINY_ACORNS)) { postQuest(player, npc) return@onNpcClick } when (player.getMiniquestStage(Miniquest.FROM_TINY_ACORNS)) { 1 -> stage1(player, npc) 2 -> stage2(player, npc) 3 -> stage3(player, npc) else -> postQuest(player, npc) } } onNpcClick(11270, options = arrayOf(""Pickpocket"")) { (p, npc) -> if (!p.isMiniquestStarted(Miniquest.FROM_TINY_ACORNS)) { p.startConversation { npc(npc, HeadE.ANGRY, ""Oi! Leave that alone."") } return@onNpcClick } if (p.inventory.containsItem(talisman)) { p.sendMessage(""You've stolen his talisman already."") return@onNpcClick } if (getFloorDrop(p) != null) { p.sendMessage(""His talisman isn't in his pocket, it's on the ground nearby."") return@onNpcClick } if (p.inventory.containsItem(babyDragon) || p.miniquestManager.isComplete(Miniquest.FROM_TINY_ACORNS)) { p.sendMessage(""You don't need this; you've already got the dragon."") return@onNpcClick } p.actionManager.setAction(PickPocketUrist(npc)) } } private fun getFloorDrop(player: Player): GroundItem? { for (groundItem in World.getAllGroundItemsInChunkRange(823724, 1)) { if (groundItem == null || groundItem.definitions == null || groundItem.id != talisman) { continue } if (!groundItem.tile.withinArea(3220, 3427, 3228, 3432)) { player.sendMessage(""I should find a suitable spot to put this. Maybe just north of him..."") continue } return groundItem } return null } private fun preQuest(player: Player) { player.sendMessage(""The Dwarf is hard at work on some sort of highly delicate construction, and doesn't pay you any notice."") } private fun stage1(player: Player, npc: NPC) { getFloorDrop(player)?.let { floorDrop -> player.startConversation { player(HeadE.CALM_TALK, ""That thing on the ground... Is it yours?"") npc(npc, HeadE.SCARED, ""What thing? Oh! Thank you kindly, I'd have been sad if I'd lost that."") exec { npc.walkToAndExecute(floorDrop.tile) { player.schedule { for (i in 0..3) { when (i) { 0 -> { player.miniquestManager.getAttribs(Miniquest.FROM_TINY_ACORNS).setB(""UristDistracted"", true) npc.forceTalk(""Hmm, how'd this get over here?"") World.removeGroundItem(floorDrop) wait(Ticks.fromSeconds(waitTime)) } 1 -> { npc.forceTalk(""Ugh it's all dirty. Lucky I've got my blue silk handkerchief on me."") wait(Ticks.fromSeconds(waitTime)) } 2 -> { npc.forceTalk(""There, that's better."") wait(Ticks.fromSeconds(waitTime)) } 3 -> { npc.forceTalk(""Well, back to work."") player.miniquestManager.getAttribs(Miniquest.FROM_TINY_ACORNS).setB(""UristDistracted"", false) wait(Ticks.fromSeconds(waitTime)) } } } npc.walkToAndExecute(uristTile) { npc.resetDirection() } player.unlock() } } } } } ?: run { // No floor drop present, proceed with normal conversation player.startConversation { player(HeadE.CALM_TALK, ""Are you the master craftsman working on a commission for Darren Lightfinger?"") npc(npc, HeadE.HAPPY_TALKING, ""That I am. What can I do for you?"") player(HeadE.CALM_TALK, ""How's it coming along?"") npc(npc, HeadE.HAPPY_TALKING, ""It's very nearly done. Just needs a bath in preserving oil to protect the mechanisms, and then a good polish."") player(HeadE.CALM_TALK, ""Is this it here on your stall?"") npc(npc, HeadE.HAPPY_TALKING, ""Aye, the baby red dragon there. As ordered, its scales are perfect rubies and it's capable of walking and breathing fire."") npc(npc, HeadE.HAPPY_TALKING, ""Could have made it fly too, given another six months or so."") player(HeadE.CALM_TALK, ""Very nice. Well, see you later."") npc(npc, HeadE.HAPPY_TALKING, ""Aye, that you will."") } } } private fun stage2(player: Player, npc: NPC) { if (player.inventory.containsItem(babyDragon) || player.bank.containsItem(babyDragon, 1)) { player.startConversation { player(HeadE.CALM_TALK, ""I'm just checking up on progress for Mr. Lightfinger. You said it would be ready in a couple of days?"") npc(npc, HeadE.HAPPY_TALKING, ""Aye, it's nearly done. It's right he-"") player(HeadE.CONFUSED, ""..."") npc(npc, HeadE.SCARED, ""By all the gods! Where's it gone? Where's it got to?"") player(HeadE.CONFUSED, ""It's not walked off, has it?"") npc(npc, HeadE.FRUSTRATED, ""It couldn't walk that far on one turn of the spring."") player(HeadE.CALM_TALK, ""I hope it turns up, then; it's due very soon. Could it have been stolen?"") npc(npc, HeadE.FRUSTRATED, ""In Varrock? With that guard watching like a hawk?"") player(HeadE.CALM_TALK, ""He doesn't seem all that hawklike."") npc(npc, HeadE.SKEPTICAL, ""Now that you mention it..."") player(HeadE.CALM_TALK, ""Will you be able to finish by the deadline?"") npc(npc, HeadE.SHAKING_HEAD, ""Are you serious? Not a chance!"") player(HeadE.CALM_TALK, ""Then what will you tell Mr. Lightfinger?"") npc(npc, HeadE.VERY_FRUSTRATED, ""I don't see that I have much choice; I shall have to give him his money back."") player(HeadE.CALM_TALK, ""That sounds fair."") npc(npc, HeadE.HAPPY_TALKING, ""Since you're working for him, can you take this banker's note to him with my sincerest apologies?"") simple(""Urist hands you a banker's note. The figure on it is astronomical."") { player.inventory.addItem(18652, 1) player.miniquestManager.setStage(Miniquest.FROM_TINY_ACORNS, 3) } player(HeadE.CALM_TALK, ""I should think so."") npc(npc, HeadE.CALM_TALK, ""I appreciate your understanding."") player(HeadE.CALM_TALK, ""I appreciate your cooperation."") } } else { player.startConversation { player(HeadE.CALM_TALK, ""Oh, nice dragon."") npc(npc, HeadE.HAPPY_TALKING, ""I thought I'd lost it for a while. Lucky I found it, eh?"") { player.miniquestManager.setStage(Miniquest.FROM_TINY_ACORNS, 1) } } } } private fun stage3(player: Player, npc: NPC) { player.startConversation{ if (!player.inventory.containsItem(babyDragon) && !player.bank.containsItem(babyDragon, 1)) { player(HeadE.CALM_TALK, ""Oh, nice dragon."") npc(npc, HeadE.HAPPY_TALKING, ""I thought I'd lost it for a while. Lucky I found it, eh?"") { player.miniquestManager.setStage(Miniquest.FROM_TINY_ACORNS, 1) if (player.inventory.containsItem(bankNote)) { player.inventory.deleteItem(bankNote, 1) player.sendMessage(""The banker's note is now useless to you; you crumple it and throw it away."") } if (player.bank.containsItem(bankNote, 1)) { player.bank.deleteItem(bankNote, 1) player.sendMessage(""The banker's note is now useless, I'm sure the bank will dispose of it."") } } player(HeadE.FRUSTRATED, ""How... fortunate."") return@startConversation } if (!player.inventory.containsItem(bankNote) && !player.bank.containsItem(bankNote, 1)) { player(HeadE.CALM_TALK, ""I'm afraid I can't find the banker's note you made out."") npc(npc, HeadE.FRUSTRATED, ""Then I'll have to write another."") { player.inventory.addItem(bankNote) player.sendMessage(""Urist hands you another banker's note. The figure on it is still astronomical."") } return@startConversation } npc(npc, HeadE.SAD_CRYING, ""Ruined! Ruined! It makes me want to throw a tantrum!"") } } fun postQuest(player: Player, npc: NPC) { player.startConversation { npc(npc, HeadE.SAD_CRYING, ""Ruined! Ruined! It makes me want to throw a tantrum!"") } }" "package com.rs.game.content.world.areas.varrock.npcs; @PluginEventHandler public class Valaine { public static NPCClickHandler handleValaineChampsGuild = new NPCClickHandler(new Object[] { 536 }, e -> { int NPC = e.getNPCId(); if (e.getOption().equalsIgnoreCase(""talk-to"")) e.getPlayer().startConversation(new Dialogue() .addNPC(NPC, HeadE.CALM_TALK, ""Hello there. Want to have a look at what we're selling today?"") .addOptions(""Choose an option:"", new Options() { @Override public void create() { option(""Yes, please."", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Yes, please."") .addNext(() -> ShopsHandler.openShop(e.getPlayer(), ""valaines_shop_of_champions""))); option(""How should I use your shop?"", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""How should I use your shop?"") .addNPC(NPC, HeadE.CALM_TALK, ""I'm glad you ask! You can buy as many of the items stocked as you wish. You can also sell most items to the shop."") .addNext(() -> ShopsHandler.openShop(e.getPlayer(), ""valaines_shop_of_champions""))); option(""No, thank you."", new Dialogue().addPlayer(HeadE.HAPPY_TALKING, ""No, thank you."").addNPC(NPC, HeadE.CALM_TALK, ""Well, alright."")); } })); if (e.getOption().equalsIgnoreCase(""trade"")) ShopsHandler.openShop(e.getPlayer(), ""valaines_shop_of_champions""); }); }" "package com.rs.game.content.world.areas.varrock.npcs; @PluginEventHandler public class VarrockBankDoor extends Conversation { private final int npcId = 2759; public static ObjectClickHandler VarrockBankDoor = new ObjectClickHandler(new Object[]{24389}, new Tile[]{Tile.of(3190, 3445, 0)}, e -> { if (e.getOpNum() == ClientPacket.OBJECT_OP1) { e.getPlayer().startConversation(new VarrockBankDoor(e.getPlayer())); } }); public VarrockBankDoor(Player player) { super(player); player.lock(10); player.anim(9105); player.forceTalk(""Knock knock...""); addPlayer(HeadE.SKEPTICAL_HEAD_SHAKE, ""I don't think I'm ever going to be allowed in there.""); addNPC(npcId, HeadE.CONFUSED, ""Who's there?""); addOptions(new Options() { @Override public void create() { option(""I'm "" + player.getDisplayName() + "". Please let me in."", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""I'm "" + player.getDisplayName() + "". Please let me in."") .addNPC(npcId, HeadE.SHAKING_HEAD, ""No. Staff only beyond this point. You can't come in here."")); option(""Boo."", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Boo."") .addNPC(npcId, HeadE.SKEPTICAL, ""Boo who?"") .addPlayer(HeadE.LOSING_IT_LAUGHING, ""There's no need to cry!"") .addNPC(npcId, HeadE.ANGRY, ""What? I'm not... oh, just go away!"")); option(""Kanga."", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Kanga."") .addNPC(npcId, HeadE.SKEPTICAL, ""Kanga who?"") .addPlayer(HeadE.LOSING_IT_LAUGHING, ""No, 'kangaroo'."") .addNPC(npcId, HeadE.ANGRY, ""Stop messing about and go away!"")); option(""Thank."", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Thank."") .addNPC(npcId, HeadE.SKEPTICAL, ""Thank who?"") .addPlayer(HeadE.LOSING_IT_LAUGHING, ""You're welcome!"") .addNPC(npcId, HeadE.ANGRY, ""Stop it!"")); option(""Doctor."", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""Doctor."") .addNPC(npcId, HeadE.SKEPTICAL, ""Doctor wh.. hang on, I'm not falling for that one again! Go away."")); } });; } }" "package com.rs.game.content.world.areas.varrock.npcs; @PluginEventHandler public class Zaff extends Conversation { public static final int ID = 546; public static NPCClickHandler handleOps = new NPCClickHandler(new Object[] { ID }, e -> { switch(e.getOption()) { case ""Talk-to"" -> e.getPlayer().startConversation(new Zaff(e.getPlayer())); case ""Trade"" -> ShopsHandler.openShop(e.getPlayer(), ""zaffs_superior_staves""); } }); public Zaff(Player player) { super(player); addNPC(ID, HeadE.CHEERFUL, ""Would you like to buy or sell some staves or is there something else you need?""); addOptions(ops -> { ops.add(""Yes, please."", () -> ShopsHandler.openShop(player, ""zaffs_superior_staves"")); ops.add(""No, thank you.""); ops.add(""Do you have any battlestaves?"") .addPlayer(HeadE.CONFUSED, ""Do you have any battlestaves?"") .addNPC(ID, HeadE.CALM_TALK, ""I'm not sure. My assistant Naff is in charge of those now.""); WhatLiesBelow.addZaffOptions(player, ops); }); create(); } }" "package com.rs.game.content.world.areas.wilderness; @PluginEventHandler public class MuddyChest { private final static DropSet REWARDS = new DropSet( new DropTable(995, 5000), new DropTable(75, 100, new Drop(995, 10000), new Drop(1392, 2), new Drop(565, 20), new Drop(5300, 1)), new DropTable(20, 100, 1305, 1), new DropTable(5, 100, 989, 1)); public static ObjectClickHandler openChest = new ObjectClickHandler(new Object[] { 170 }, e -> { if (e.getPlayer().getInventory().containsItem(991)) { e.getPlayer().lock(); e.getPlayer().getInventory().deleteItem(991, 1); Item[] loot = DropTable.calculateDrops(e.getPlayer(), REWARDS); e.getPlayer().setNextAnimation(new Animation(536)); e.getPlayer().sendMessage(""You unlock the chest with your key.""); e.getPlayer().getTasks().schedule(1, () -> { GameObject openedChest = new GameObject(e.getObject().getId() + 1, e.getObject().getType(), e.getObject().getRotation(), e.getObject().getX(), e.getObject().getY(), e.getObject().getPlane()); World.spawnObjectTemporary(openedChest, 1); e.getPlayer().incrementCount(""Muddy chests opened""); e.getPlayer().sendMessage(""You find some treasure in the chest!""); for (Item item : loot) e.getPlayer().getInventory().addItem(item.getId(), item.getAmount(), true); e.getPlayer().unlock(); }); } else e.getPlayer().sendMessage(""The chest is locked.""); }); }" "package com.rs.game.content.world.areas.wilderness; @PluginEventHandler public class Wilderness { public static ObjectClickHandler handleMagicAxeHutChests = new ObjectClickHandler(new Object[] { 2566 }, new Tile[] { Tile.of(3188, 3962, 0), Tile.of(3189, 3962, 0), Tile.of(3193, 3962, 0) }, e -> { switch(e.getOpNum()) { case OBJECT_OP1 -> { e.getPlayer().sendMessage(""You attempt to open the chest without disarming the traps.""); e.getPlayer().applyHit(new Hit((int) (e.getPlayer().getSkills().getLevel(Skills.HITPOINTS) + 20), Hit.HitLook.TRUE_DAMAGE)); } case OBJECT_OP2 -> Thieving.checkTrapsChest(e.getPlayer(), e.getObject(), 2574, 32, 14, 7.5, DropSets.getDropSet(""magic_axe_hut_chest"")); default -> e.getPlayer(); } }); public static ObjectClickHandler handleKBDEnterLadder = new ObjectClickHandler(new Object[] { 1765 }, new Tile[] { Tile.of(3017, 3849, 0) }, e -> e.getPlayer().useStairs(828, Tile.of(3069, 10255, 0), 1, 2)); public static ObjectClickHandler handleKBDExitLadder = new ObjectClickHandler(new Object[] { 32015 }, new Tile[] { Tile.of(3069, 10256, 0) }, e -> e.getPlayer().useStairs(828, Tile.of(3017, 3848, 0), 1, 2)); public static ObjectClickHandler handleKBDEnterLever = new ObjectClickHandler(new Object[] { 1816 }, new Tile[] { Tile.of(3067, 10252, 0) }, e -> { e.getPlayer().stopAll(); Magic.pushLeverTeleport(e.getPlayer(), Tile.of(2273, 4681, 0)); e.getPlayer().getControllerManager().forceStop(); }); public static ObjectClickHandler handleKBDExitLever = new ObjectClickHandler(new Object[] { 1817 }, new Tile[] { Tile.of(2273, 4680, 0) }, e -> { Magic.pushLeverTeleport(e.getPlayer(), Tile.of(3067, 10254, 0)); e.getPlayer().getControllerManager().startController(new WildernessController()); }); public static ObjectClickHandler handleFireGiantDungeonExit = new ObjectClickHandler(new Object[] { 32048 }, new Tile[] { Tile.of(3043, 10328, 0) }, e -> { e.getPlayer().tele(e.getPlayer().transform(3, -6400, 0)); e.getPlayer().getControllerManager().startController(new WildernessController()); }); public static ObjectClickHandler handleRedDragIsleShortcut = new ObjectClickHandler(new Object[] { 73657 }, e -> { if (!Agility.hasLevel(e.getPlayer(), 54)) { e.getPlayer().getPackets().sendGameMessage(""You need level 54 agility to use this shortcut.""); return; } e.getPlayer().forceMove(e.getPlayer().transform(e.getPlayer().getY() > 3800 ? 1 : -1, e.getPlayer().getY() > 3800 ? -2 : 2), 4721, 25, 30); }); public static ObjectClickHandler handleGWDShortcut = new ObjectClickHandler(new Object[] { 26323, 26324, 26328, 26327 }, e -> { Player p = e.getPlayer(); WorldObject obj = e.getObject(); if (!Agility.hasLevel(p, 60)) { p.getPackets().sendGameMessage(""You need level 60 agility to use this shortcut.""); return; } //Wildy if(obj.getId() == 26327) e.getPlayer().forceMove(Tile.of(2943, 3767, 0), 2049, 25, 60); if(obj.getId() == 26328) { p.tele(Tile.of(2943, 3767, 0)); e.getPlayer().forceMove(Tile.of(2950, 3767, 0), 2050, 25, 60); } //Outside GWD if(obj.getId() == 26324) e.getPlayer().forceMove(Tile.of(2928, 3757, 0), 2049, 25, 60); if(obj.getId() == 26323) e.getPlayer().forceMove(Tile.of(2927, 3761, 0), 2050, 25, 60); }); }" "package com.rs.game.content.world.areas.wilderness; public class WildernessController extends Controller { private transient boolean showingSkull; @Override public void start() { Potions.checkOverloads(player); player.addEffect(Effect.OVERLOAD_PVP_REDUCTION, Integer.MAX_VALUE); } @Override public boolean login() { moved(); return false; } @Override public boolean keepCombating(Entity target) { if (target instanceof NPC) return true; if (!canAttack(target)) return false; if (target instanceof Player opp) if (!player.attackedBy(opp.getUsername())) player.setWildernessSkull(); if (player.getCombatDefinitions().getSpell() == null && Utils.inCircle(Tile.of(3105, 3933, 0), target.getTile(), 24)) { player.sendMessage(""You can only use magic in the arena.""); return false; } return true; } @Override public boolean canAttack(Entity target) { if (target instanceof Player p2) { if (player.isCanPvp() && !p2.isCanPvp()) { player.sendMessage(""That player is not in the wilderness.""); return false; } if (canHit(target)) return true; return false; } return true; } @Override public boolean canHit(Entity target) { if (target instanceof NPC) return true; Player p2 = (Player) target; if (Math.abs(player.getSkills().getCombatLevel() - p2.getSkills().getCombatLevel()) > Math.min(player.getPvpCombatLevelThreshhold(), p2.getPvpCombatLevelThreshhold())) { player.sendMessage(""Your level difference is too great!
You need to move deeper into the Wilderness.""); return false; } return true; } @Override public boolean processTeleport(Teleport tele) { if ((tele.type() != TeleType.OBJECT && getWildLevel() > (player.getTempAttribs().getB(""glory"") ? 30 : 20)) || player.hasEffect(Effect.TELEBLOCK)) { player.sendMessage(""A mysterious force prevents you from teleporting.""); return false; } return true; } public void showSkull() { player.getInterfaceManager().sendOverlay(381); } public static boolean isDitch(int id) { return id >= 1440 && id <= 1444 || id >= 65076 && id <= 65087; } @Override public boolean processObjectClick1(final GameObject object) { if (isDitch(object.getId())) { final Tile toTile = Tile.of(object.getRotation() == 1 || object.getRotation() == 3 ? object.getX() + 2 : player.getX(), object.getRotation() == 0 || object.getRotation() == 2 ? object.getY() - 1 : player.getY(), object.getPlane()); player.forceMove(toTile, 6132, 30, 60, () -> { player.faceObject(object); removeIcon(); removeController(); player.resetReceivedDamage(); }); return false; } if (object.getId() == 2557 || object.getId() == 65717) { player.sendMessage(""It seems it is locked, maybe you should try something else.""); return false; } return true; } @Override public boolean processObjectClick2(final GameObject object) { if (object.getId() == 2557 || object.getId() == 65717) { if (player.getSkills().getLevel(Skills.THIEVING) < 23) { player.sendMessage(""You need at least 23 thieving to pick this lock.""); return false; } if (!player.getInventory().containsItem(1523, 1)) { player.sendMessage(""You cannot seem to pick this lock. Perhaps a lock pick would help.""); return false; } Thieving.pickDoor(player, object); return false; } return true; } @Override public void sendInterfaces() { if (isAtWild(player.getTile())) showSkull(); } @Override public boolean sendDeath() { WorldTasks.scheduleTimer(0, 1, loop -> { if (loop == 0) player.setNextAnimation(new Animation(836)); else if (loop == 1) player.sendMessage(""Oh dear, you have died.""); else if (loop == 3) { Player killer = player.getMostDamageReceivedSourcePlayer(); if (killer != null) { killer.removeDamage(player); killer.increaseKillCount(player); } player.sendPVPItemsOnDeath(killer); player.getEquipment().init(); player.getInventory().init(); player.reset(); if (player.get(""customspawn"") instanceof Tile spawn) player.tele(spawn); else player.tele(Tile.of(Settings.getConfig().getPlayerRespawnTile())); player.setNextAnimation(new Animation(-1)); } else if (loop == 4) { removeIcon(); removeController(); player.jingle(90); return false; } return true; }); return false; } @Override public void moved() { boolean isAtWild = isAtWild(player.getTile()); boolean isAtWildSafe = isAtWildSafe(); if (!isAtWildSafe && !isAtWild) { player.setPvpCombatLevelThreshhold(-1); player.setCanPvp(false); removeIcon(); removeController(); } else if (!showingSkull && isAtWild && !isAtWildSafe) { showingSkull = true; player.setCanPvp(true); showSkull(); player.setPvpCombatLevelThreshhold(getWildLevel()); } else if (showingSkull && (isAtWildSafe || !isAtWild)) removeIcon(); } public void removeIcon() { if (showingSkull) { showingSkull = false; player.setCanPvp(false); player.getInterfaceManager().removeOverlay(); player.setPvpCombatLevelThreshhold(-1); player.getEquipment().refresh(null); } } @Override public boolean logout() { return false; // so doesnt remove script } @Override public void forceClose() { removeIcon(); player.removeEffect(Effect.OVERLOAD_PVP_REDUCTION); } @Override public void onRemove() { player.removeEffect(Effect.OVERLOAD_PVP_REDUCTION); } public static boolean isAtWild(Tile tile) {// TODO fix this return (tile.getX() >= 3011 && tile.getX() <= 3132 && tile.getY() >= 10052 && tile.getY() <= 10175) || (tile.getX() >= 2940 && tile.getX() <= 3395 && tile.getY() >= 3525 && tile.getY() <= 4000) || (tile.getX() >= 3078 && tile.getX() <= 3139 && tile.getY() >= 9923 && tile.getY() <= 10002) || (tile.getX() >= 3264 && tile.getX() <= 3279 && tile.getY() >= 3279 && tile.getY() <= 3672) || (tile.getX() >= 2756 && tile.getX() <= 2875 && tile.getY() >= 5512 && tile.getY() <= 5627) || (tile.getX() >= 3158 && tile.getX() <= 3181 && tile.getY() >= 3679 && tile.getY() <= 3697) || (tile.getX() >= 3280 && tile.getX() <= 3183 && tile.getY() >= 3885 && tile.getY() <= 3888) || (tile.getX() >= 3012 && tile.getX() <= 3059 && tile.getY() >= 10303 && tile.getY() <= 10351) || (tile.getX() >= 3061 && tile.getX() <= 3071 && tile.getY() >= 10251 && tile.getY() <= 10262); } public boolean isAtWildSafe() { return (player.getX() >= 2940 && player.getX() <= 3395 && player.getY() <= 3524 && player.getY() >= 3523) || (player.getX() >= 3129 && player.getX() <= 3135 && player.getY() <= 9922 && player.getY() >= 9918); } public int getWildLevel() { if (player.getY() > 9900) return (player.getY() - 9920) / 8 + 1; return (player.getY() - 3520) / 8 + 1; } }" "package com.rs.game.content.world.areas.wilderness.forinthry; @PluginEventHandler public class Revenant extends NPC { public Revenant(int id, Tile tile, boolean spawned) { super(id, tile, spawned); setForceAggroDistance(4); } public static ItemClickHandler forinthryBrace = new ItemClickHandler(new Object[] { 11095, 11097, 11099, 11101, 11103 }, new String[] { ""Repel"", ""Check"" }, e -> { switch(e.getOption()) { case ""Check"" -> { e.getPlayer().sendMessage(""You are currently "" + (!e.getPlayer().hasEffect(Effect.REV_AGGRO_IMMUNE) ? ""not"" : """") + "" protected from revenant aggression.""); e.getPlayer().sendMessage(""You are currently "" + (!e.getPlayer().hasEffect(Effect.REV_IMMUNE) ? ""not"" : """") + "" protected from revenant damage.""); } case ""Repel"" -> { if (e.getPlayer().getInventory().containsItem(e.getItem().getId(), 1)) { e.getPlayer().getInventory().deleteItem(e.getItem().getId(), 1); if (e.getItem().getId() != 11103) e.getPlayer().getInventory().addItem(e.getItem().getId() + 2, 1); e.getPlayer().refreshForinthry(); } } } }); @Override public void spawn() { super.spawn(); setNextAnimation(new Animation(getSpawnAnimation())); } @Override public void drop(Player killer, boolean verifyCombatDefs) { try { if (!getDefinitions().getName().equals(""null"")) killer.sendNPCKill(getDefinitions().getName()); List drops = genDrop(killer, getDefinitions().getName(), getDefinitions().combatLevel); for (Item item : drops) sendDrop(killer, item); } catch (Exception | Error e) { e.printStackTrace(); } } public int getSpawnAnimation() { return switch (getId()) { case 13465 -> 7410; case 13466, 13467, 13468, 13469 -> 7447; case 13470, 13471 -> 7485; case 13472 -> 7424; case 13473 -> 7426; case 13474 -> 7403; case 13475 -> 7457; case 13476 -> 7464; case 13477 -> 7478; case 13478 -> 7417; case 13479 -> 7471; case 13480 -> 7440; case 13481 -> 3643; default -> -1; }; } public static List genDrop(Player killer, String name, int combatLevel) { List drops = new ArrayList<>(); double g = Utils.clampD(Math.sqrt(combatLevel), 1.0, 12.0); double r = 60000.0 / g; Utils.add(drops, DropTable.calculateDrops(killer, new DropSet( //1/R chance each to obtain an Ancient, Seren, Armadyl, Zamorak, Saradomin or Bandos statuette, or a random brawling glove. The rate for brawling gloves is 2/15 for Smithing and Hunter gloves, and 1/15 for all others new DropTable(1, r, new Drop(14876)), new DropTable(1, r, new Drop(14877)), new DropTable(1, r, new Drop(14878)), new DropTable(1, r, new Drop(14879)), new DropTable(1, r, new Drop(14880)), new DropTable(1, r, new Drop(14881)), new DropTable(1, r, new Drop(13845), new Drop(13846), new Drop(13847), new Drop(13848), new Drop(13849), new Drop(13850), new Drop(13851), new Drop(13852), new Drop(13853), new Drop(13854), new Drop(13855), new Drop(13856), new Drop(13857), new Drop(13855), new Drop(13853)), //2/R chance each to obtain a Ruby chalice, Guthixian brazier, Armadyl totem, Zamorak medallion, Saradomin carving, Bandos scrimshaw or a corrupt dragon item new DropTable(2, r, new Drop(14882)), new DropTable(2, r, new Drop(14883)), new DropTable(2, r, new Drop(14884)), new DropTable(2, r, new Drop(14885)), new DropTable(2, r, new Drop(14886)), new DropTable(2, r, new Drop(14887)), new DropTable(2, r, new Drop(13958), new Drop(13961), new Drop(13964), new Drop(13967), new Drop(13970), new Drop(13973), new Drop(13976), new Drop(13979), new Drop(13982), new Drop(13985), new Drop(13988)), //3/R chance each to obtain a Saradomin amphora, Ancient psaltery bridge, Bronzed dragon claw, Third age carafe or broken statue headdress new DropTable(3, r, new Drop(14888)), new DropTable(3, r, new Drop(14889)), new DropTable(3, r, new Drop(14890)), new DropTable(3, r, new Drop(14891)), new DropTable(3, r, new Drop(14892)), //10/R chance each to obtain a piece of Ancient Warriors' equipment or its corrupt version new DropTable(10, r, new Drop(13858), new Drop(13861), new Drop(13864), new Drop(13867), new Drop(13870), new Drop(13873), new Drop(13876), new Drop(13879, 15, 50), new Drop(13883, 15, 50), new Drop(13884), new Drop(13887), new Drop(13890), new Drop(13893), new Drop(13896), new Drop(13899), new Drop(13902), new Drop(13905) ), new DropTable(10, r, new Drop(13908), new Drop(13911), new Drop(13914), new Drop(13917), new Drop(13920), new Drop(13923), new Drop(13926), new Drop(13929), new Drop(13932), new Drop(13935), new Drop(13938), new Drop(13941), new Drop(13944), new Drop(13947), new Drop(13950), new Drop(13953, 15, 50), new Drop(13957, 15, 50) ) ))); //If no unique is dropped, then a final roll for coins appear, the cap roughly equal to 50 times G. if (drops.isEmpty()) drops.add(new Item(995, (int) (50.0 * g))); return drops; } public static NPCInstanceHandler toFunc = new NPCInstanceHandler(new Object[] { 13465, 13466, 13467, 13468, 13469, 13470, 13471, 13472, 13473, 13474, 13475, 13476, 13477, 13478, 13479, 13480, 13481 }, (npcId, tile) -> new Revenant(npcId, tile, false)); }" "package com.rs.game.content.world.areas.wilderness.forinthry; public class RevenantCombat extends CombatScript { @Override public Object[] getKeys() { return new Object[] { 13465, 13466, 13467, 13468, 13469, 13470, 13471, 13472, 13473, 13474, 13475, 13476, 13477, 13478, 13479, 13480, 13481 }; } public int getMagicAnimation(NPC npc) { return switch (npc.getId()) { case 13465 -> 7500; case 13466, 13467, 13468, 13469 -> 7499; case 13470, 13471 -> 7506; case 13472 -> 7503; case 13473 -> 7507; case 13474 -> 7496; case 13475 -> 7497; case 13476 -> 7515; case 13477 -> 7498; case 13478 -> 7505; case 13479 -> 7515; case 13480 -> 7508; default -> // melee emote, better than 0 npc.getCombatDefinitions().getAttackEmote(); }; } public int getRangeAnimation(NPC npc) { return switch (npc.getId()) { case 13465 -> 7501; case 13466, 13467, 13468, 13469 -> 7513; case 13470, 13471 -> 7519; case 13472 -> 7516; case 13473 -> 7520; case 13474 -> 7521; case 13475 -> 7510; case 13476 -> 7501; case 13477 -> 7512; case 13478 -> 7518; case 13479 -> 7514; case 13480 -> 7522; default -> // melee emote, better than 0 npc.getCombatDefinitions().getAttackEmote(); }; } @Override public int attack(final NPC npc, final Entity target) { final NPCCombatDefinitions defs = npc.getCombatDefinitions(); if (npc.getHitpoints() < npc.getMaxHitpoints() / 2 && Utils.random(5) == 0) npc.heal(100); int attackStyle = Utils.random(3); if (attackStyle == 2) { // checks if can melee int distanceX = target.getX() - npc.getX(); int distanceY = target.getY() - npc.getY(); int size = npc.getSize(); if ((distanceX > size || distanceX < -1 || distanceY > size || distanceY < -1)) attackStyle = Utils.random(2); } if (attackStyle != 2) npc.soundEffect(target, 202, true); switch (attackStyle) { case 0: // magic int damage = getMaxHit(npc, defs.getMaxHit(), AttackStyle.MAGE, target); if (target instanceof Player player && player.hasEffect(Effect.REV_IMMUNE)) damage = 0; delayHit(npc, 2, target, getMagicHit(npc, damage)); World.sendProjectile(npc, target, 1276, 34, 16, 30, 35, 16, 0); if (damage > 0) WorldTasks.schedule(new Task() { @Override public void run() { target.setNextSpotAnim(new SpotAnim(1277, 0, 100)); if (Utils.random(5) == 0) { target.setNextSpotAnim(new SpotAnim(363)); target.freeze(Ticks.fromSeconds(5)); } } }, 2); npc.setNextAnimation(new Animation(getMagicAnimation(npc))); break; case 1: // range int damage2 = getMaxHit(npc, defs.getMaxHit(), AttackStyle.RANGE, target); if (target instanceof Player player && player.hasEffect(Effect.REV_IMMUNE)) damage = 0; delayHit(npc, 2, target, getRangeHit(npc, damage2)); World.sendProjectile(npc, target, 1278, 34, 16, 30, 35, 16, 0); npc.setNextAnimation(new Animation(getRangeAnimation(npc))); break; case 2: // melee int damage3 = getMaxHit(npc, defs.getMaxHit(), AttackStyle.MELEE, target); if (target instanceof Player player && player.hasEffect(Effect.REV_IMMUNE)) damage = 0; delayHit(npc, 0, target, getMeleeHit(npc, damage3)); npc.setNextAnimation(new Animation(defs.getAttackEmote())); break; } return npc.getAttackSpeed(); } }" "package com.rs.game.content.world.areas.yanille; @PluginEventHandler public class Yanille { public static ObjectClickHandler handleUnderwallTunnelShortcut = new ObjectClickHandler(new Object[] { 9301, 9302 }, e -> { if (!Agility.hasLevel(e.getPlayer(), 14)) return; AgilityShortcuts.crawlUnder(e.getPlayer(), e.getPlayer().transform(0, e.getObjectId() == 9302 ? -5 : 5, 0)); }); public static ObjectClickHandler handleMagicGuildStairs = new ObjectClickHandler(new Object[] { 1722, 1723 }, e -> e.getPlayer().tele(e.getPlayer().transform(0, e.getObjectId() == 1722 ? 4 : -4, e.getObjectId() == 1722 ? 1 : -1))); public static ObjectClickHandler handleTreeGnomeVillageGateSqueeze = new ObjectClickHandler(new Object[] { 2186 }, e -> AgilityShortcuts.sidestep(e.getPlayer(), e.getPlayer().getY() < e.getObject().getY() ? e.getPlayer().transform(0, 1, 0) : e.getPlayer().transform(0, -1, 0))); public static NPCClickHandler handleMagicGuildArmorShop = new NPCClickHandler(new Object[] { 1658 }, e -> { if (e.getOpNum() == 3) ShopsHandler.openShop(e.getPlayer(), ""magic_guild_store_robes""); }); public static NPCClickHandler handleElkoy = new NPCClickHandler(new Object[] { 473, 474 }, e -> { if(e.getOption().equalsIgnoreCase(""Talk-to"")) { e.getPlayer().startConversation(new ElkoyTreeGnomeVillageD(e.getPlayer()).getStart()); } if (e.getOpNum() == 3) e.getPlayer().fadeScreen(() -> { e.getPlayer().sendMessage(""Elkoy leads you through the maze...""); e.getPlayer().tele(e.getNPC().getId() == 473 ? Tile.of(2515, 3160, 0) : Tile.of(2502, 3193, 0)); }); }); public static ObjectClickHandler handleMagicGuildPortals = new ObjectClickHandler(new Object[] { 2518, 2156, 2157 }, e -> { switch(e.getObjectId()) { case 2518: e.getPlayer().sendOptionDialogue(""Teleport to Thormac's Tower?"", ops -> { ops.add(""Yes, teleport me to Thormac's Tower."", () -> e.getPlayer().tele(Tile.of(2702, 3403, 0))); ops.add(""Not right now.""); }); break; case 2156: e.getPlayer().sendOptionDialogue(""Teleport to the Wizard's Tower?"", ops -> { ops.add(""Yes, teleport me to the Wizard's Tower."", () -> e.getPlayer().tele(Tile.of(3109, 3164, 0))); ops.add(""Not right now.""); }); break; case 2157: e.getPlayer().sendOptionDialogue(""Teleport to the Dark Wizard's Tower?"", ops -> { ops.add(""Yes, teleport me to the Dark Wizard's Tower."", () -> e.getPlayer().tele(Tile.of(2906, 3334, 0))); ops.add(""Not right now.""); }); break; } }); public static ObjectClickHandler handleMagicGuildEnter = new ObjectClickHandler(new Object[] { ""Magic guild door"" }, e -> { if (e.getPlayer().getSkills().getLevel(Skills.MAGIC) < 66) { e.getPlayer().sendMessage(""You require 66 magic to enter the Magic Guild.""); return; } Doors.handleDoubleDoor(e.getPlayer(), e.getObject()); }); public static ObjectClickHandler handleGrottoBridge = new ObjectClickHandler(new Object[] { 2830, 2831 }, e -> { Tile endLoc; if (e.getObjectId() == 2830) endLoc = Tile.of(2530, 3029, 0); else endLoc = Tile.of(2531, 3026, 0); e.getPlayer().lock(); e.getPlayer().setNextFaceTile(endLoc); e.getPlayer().setNextAnimation(new Animation(769)); WorldTasks.schedule(new Task() { @Override public void run() { e.getPlayer().unlockNextTick(); e.getPlayer().tele(endLoc); e.getPlayer().setNextAnimation(new Animation(-1)); } }, 0); }); public static ObjectClickHandler handleTrellis = new ObjectClickHandler(new Object[] { 20056 }, e -> { if (!Agility.hasLevel(e.getPlayer(), 18)) { e.getPlayer().sendMessage(""You need 18 Agility to climb that.""); return; } Player p = e.getPlayer(); WorldObject obj = e.getObject(); if(obj.getId() == 20056) { p.useLadder(Tile.of(2548, 3118, 1)); p.getSkills().addXp(Skills.AGILITY, 31); } }); }" "package com.rs.game.content.world.areas.yanille.agility_dungeon; @PluginEventHandler public class AgilityDungeon { public static ObjectClickHandler handleSinisterChest = new ObjectClickHandler(new Object[] { 377 }, e -> { if (!e.getPlayer().getInventory().containsItem(993, 1)) { e.getPlayer().sendMessage(""The chest is securely locked.""); return; } e.getPlayer().anim(536); e.getPlayer().lock(2); e.getPlayer().sendMessage(""You unlock the chest with your key.""); e.getPlayer().getInventory().deleteItem(993, 1); e.getPlayer().getInventory().addItemDrop(206, 2); e.getPlayer().getInventory().addItemDrop(208, 3); e.getPlayer().getInventory().addItemDrop(210, 1); e.getPlayer().getInventory().addItemDrop(212, 1); e.getPlayer().getInventory().addItemDrop(214, 1); e.getPlayer().getInventory().addItemDrop(220, 1); }); public static ObjectClickHandler handleThievingDoor = new ObjectClickHandler(new Object[] { 2559 }, e -> { switch(e.getOption()) { case ""Open"" -> e.getPlayer().sendMessage(""The door is securely locked.""); case ""Pick-lock"" -> { if (!e.getPlayer().getInventory().containsOneItem(1523, 11682)) { e.getPlayer().sendMessage(""You need a lockpick to open this door.""); return; } if (e.getPlayer().getSkills().getLevel(Skills.THIEVING) < 82) { e.getPlayer().sendMessage(""You need a Thieving level of 82 to pick this lock.""); return; } Doors.handleLeftHandedDoor(e.getPlayer(), e.getObject()); } } }); public static ObjectClickHandler handleWebStairs = new ObjectClickHandler(new Object[] { 32270, 32271, 37023 }, e -> { if (e.getObject().getTile().isAt(2603, 9478) || e.getObjectId() == 32271) e.getPlayer().useStairs(e.getPlayer().getTile().transform(e.getObjectId() == 32271 ? -4 : 4, e.getObjectId() == 32271 ? 6400 : -6400)); else e.getPlayer().useStairs(e.getPlayer().getTile().transform(0, e.getObjectId() == 37023 ? 6404 : -6404)); }); public static ObjectClickHandler handleLockpickRoomStairs = new ObjectClickHandler(new Object[] { 1728, 1729 }, e -> e.getPlayer().useStairs(e.getPlayer().getTile().transform(0, e.getObjectId() == 1728 ? 68 : -68))); public static ObjectClickHandler poisonSpiderStairs = new ObjectClickHandler(new Object[] { 2316 }, e -> e.getPlayer().useStairs(Tile.of(2572, 9533, 0))); public static NPCClickHandler handleSigbert = new NPCClickHandler(new Object[] { 37 }, e -> e.getPlayer().startConversation(new Dialogue() .addNPC(37, HeadE.CALM_TALK, ""I'd be very careful going down there, friend."") .addOptions(ops -> { ops.add(""Why? What's down there?"") .addPlayer(HeadE.CONFUSED, ""Why? What's down there?"") .addNPC(37, HeadE.CALM_TALK, ""Salarin the Twisted, one of Kandarin's most dangerous chaos druids. I tried to take him on , then suddenly felt immensely weak."") .addNPC(37, HeadE.CALM_TALK, ""I hear he's susceptible to attacks from the mind. However, I have no idea what that means, so it's not much help to me.""); ops.add(""Fear not! I am very strong!"") .addPlayer(HeadE.CHEERFUL, ""Fear not! I am very strong!"") .addNPC(37, HeadE.CALM_TALK, ""You might find you are not so strong shortly...""); }))); public static ObjectClickHandler handleLedge = new ObjectClickHandler(new Object[] { 2303, 35969 }, e -> { if (!Agility.hasLevel(e.getPlayer(), 40)) return; final Tile north = Tile.of(2580, 9520, 0); final Tile south = Tile.of(2580, 9512, 0); final Tile mid = Tile.of(2580, 9516, 0); final boolean isNorth = e.getPlayer().getY() > mid.getY(); if (!Utils.skillSuccess(e.getPlayer().getSkills().getLevel(Skills.AGILITY), -67, 416)) { Agility.crossLedge(e.getPlayer(), isNorth ? north : south, e.getPlayer().transform(0, isNorth ? -2 : 2), 20, isNorth); WorldTasks.schedule(6, () -> { e.getPlayer().tele(Tile.of(2572, 9568, 0)); e.getPlayer().applyHit(Hit.flat(e.getPlayer(), (int) (e.getPlayer().getMaxHitpoints() * 0.2))); }); return; } Agility.crossLedge(e.getPlayer(), isNorth ? north : south, isNorth ? south : north, 20, isNorth); }); public static ObjectClickHandler handlePipe = new ObjectClickHandler(new Object[] { 2290 }, e -> { if (!Agility.hasLevel(e.getPlayer(), 49)) return; e.getPlayer().forceMove(e.getObject().getTile().transform(e.getPlayer().getX() < 2575 ? 5 : -5, 0, 0), 10580, 35, 120, () -> e.getPlayer().getSkills().addXp(Constants.AGILITY, 5.0)); if (!Utils.skillSuccess(e.getPlayer().getSkills().getLevel(Skills.AGILITY), -35, 350)) e.getPlayer().applyHit(Hit.flat(e.getPlayer(), (int) (e.getPlayer().getMaxHitpoints() * 0.1))); }); public static ObjectClickHandler handleMonkeybars = new ObjectClickHandler(new Object[] { 2321 }, e -> { if (!Agility.hasLevel(e.getPlayer(), 57)) return; if (!Utils.skillSuccess(e.getPlayer().getSkills().getLevel(Skills.AGILITY), -15, 323)) { Agility.crossMonkeybars(e.getPlayer(), e.getObject().getTile(), e.getObject().getTile().transform(0, e.getPlayer().getY() > 9491 ? -2 : 2), 0); WorldTasks.schedule(6, () -> { e.getPlayer().tele(Tile.of(2572, 9568, 0)); e.getPlayer().applyHit(Hit.flat(e.getPlayer(), (int) (e.getPlayer().getMaxHitpoints() * 0.2))); }); return; } Agility.crossMonkeybars(e.getPlayer(), e.getObject().getTile(), e.getObject().getTile().transform(0, e.getPlayer().getY() > 9491 ? -5 : 5), 20); }); public static ObjectClickHandler handleRubble = new ObjectClickHandler(new Object[] { 2317, 2318 }, e -> { if (!Agility.hasLevel(e.getPlayer(), 67)) return; e.getPlayer().useStairs(e.getPlayer().getTile().transform(e.getObjectId() == 2318 ? 1 : -1, e.getObjectId() == 2318 ? 65 : -65)); if (e.getObjectId() == 2317) e.getPlayer().getSkills().addXp(Skills.AGILITY, 5.5); }); }" "package com.rs.game.content.world.areas.yanille.agility_dungeon; @PluginEventHandler public class SalarinTheTwisted extends NPC { public SalarinTheTwisted(int id, Tile tile, boolean permaDeath) { super(id, tile, permaDeath); } @Override public void handlePreHit(final Hit hit) { super.handlePreHit(hit); CombatSpell spell = hit.getData(""combatSpell"", CombatSpell.class); if (hit.getDamage() == 0) return; if (spell == null) { forceTalk(""Your pitiful attacks cannot hurt me!""); hit.setDamage(0); return; } switch(spell) { case WIND_STRIKE -> hit.setDamage(90); case WATER_STRIKE -> hit.setDamage(100); case EARTH_STRIKE -> hit.setDamage(110); case FIRE_STRIKE -> hit.setDamage(120); default -> { forceTalk(""Your pitiful attacks cannot hurt me!""); hit.setDamage(0); } } } public static NPCInstanceHandler toFunc = new NPCInstanceHandler(new Object[] { 205 }, (npcId, tile) -> new SalarinTheTwisted(npcId, tile, false)); }" "package com.rs.game.content.world.areas.yanille.npcs class BartenderDragonInn(p: Player, npc: NPC) { init { p.startConversation { npc(npc, HeadE.HAPPY_TALKING, ""What can I get you?"") player(HeadE.CALM, ""What's on the menu?"") npc(npc, HeadE.HAPPY_TALKING, ""Dragon Bitter and Greenman's Ale, oh and some cheap beer."") options { op(""I'll give it a miss I think."") { player(HeadE.HAPPY_TALKING, ""I'll give it a miss I think."") npc(npc, HeadE.SAD_MILD, ""Come back when you're a little thirstier."") } op(""I'll try the Dragon Bitter."") { player(HeadE.HAPPY_TALKING, ""I'll try the Dragon Bitter."") npc(npc, HeadE.HAPPY_TALKING, ""Ok, that'll be two coins."") exec { buyDrinkOrIngredients(p, npc, 2, Item(1911), true) p.sendMessage(""You buy a pint of Dragon Bitter."") } } op(""Can I have some Greenman's Ale?"") { player(HeadE.HAPPY_TALKING, ""Can I have some Greenman's Ale?"") npc(npc, HeadE.HAPPY_TALKING, ""Ok, that'll be ten coins."") exec { buyDrinkOrIngredients(p, npc, 10, Item(1901), true) p.sendMessage(""You buy a pint of Greenman's Ale."") } } op(""One cheap beer please!"") { player(HeadE.HAPPY_TALKING, ""One cheap beer please!"") npc(npc, HeadE.HAPPY_TALKING, ""That'll be 2 gold coins please!"") exec { buyDrinkOrIngredients(p, npc, 2, Item(1917), true) p.sendMessage(""You buy a pint of cheap beer."") } } if (!isBarVisited(p, DRAGON_INN) && BarCrawl.hasCard(p) && onBarCrawl(p)) { op(""I'm doing Alfred Grimhand's Barcrawl."") { player(HeadE.HAPPY_TALKING, ""I'm doing Alfred Grimhand's Barcrawl."") npc(npc, HeadE.CHEERFUL, ""I suppose you'll be wanting some ${DRAGON_INN.drinkName}. That'll cost you ${DRAGON_INN.price} coins."") exec { buyBarcrawlDrink(p, DRAGON_INN) } } } } } } } @ServerStartupEvent fun mapBartenderDragonInn() { onNpcClick(739) { (player, npc) -> BartenderDragonInn(player, npc) } }" "package com.rs.game.content.world.areas.zanaris; @PluginEventHandler public class Zanaris { public static ItemOnObjectHandler handleEnterBlackDragonPlane = new ItemOnObjectHandler(new Object[] { 12093 }, new Object[] { 2138 }, e -> { e.getPlayer().getInventory().deleteItem(2138, 1); FairyRings.sendTeleport(e.getPlayer(), Tile.of(1565, 4356, 0)); }); public static ItemOnObjectHandler handleDownBabyBlackDragons = new ItemOnObjectHandler(new Object[] { 12253 }, new Object[] { 954 }, e -> e.getPlayer().useLadder(Tile.of(1544, 4381, 0))); public static ObjectClickHandler handleUpBabyBlackDragons = new ObjectClickHandler(new Object[] { 12255 }, e -> e.getPlayer().useLadder(Tile.of(1561, 4380, 0))); public static ObjectClickHandler handleExitBlackDragonPlane = new ObjectClickHandler(new Object[] { 12260 }, e -> e.getPlayer().tele(Tile.of(2453, 4476, 0))); public static ObjectClickHandler handleCosmicAltarShortcuts = new ObjectClickHandler(new Object[] { 12127 }, e -> { if (!Agility.hasLevel(e.getPlayer(), e.getObject().getTile().isAt(2400, 4403) ? 46 : 66)) return; AgilityShortcuts.sidestep(e.getPlayer(), e.getPlayer().transform(0, e.getPlayer().getY() > e.getObject().getY() ? -2 : 2, 0)); }); public static NPCClickHandler handleLunderwin = new NPCClickHandler(new Object[] { 565 }, e -> { int cabbageCount = e.getPlayer().getInventory().getAmountOf(1965); int option = e.getOpNum(); if (option == 1) e.getPlayer().startConversation(new Conversation(e.getPlayer()) { { addNPC(e.getNPCId(), HeadE.HAPPY_TALKING, ""Buying cabbage am I, not have such thing where I from. Will pay money much handsome for "" + ""wondrous object, cabbage you called. Say I 100 gold coins each fair price to be giving yes?""); if (cabbageCount <= 0) { addPlayer(HeadE.NERVOUS, ""Alas, I have no cabbages either...""); addNPC(e.getNPCId(), HeadE.FRUSTRATED, ""Pity be that, I want badly do.""); } else addOptions(new Options() { @Override public void create() { option(""Yes, I'll sell you all my cabbages"", () -> { e.getPlayer().getInventory().deleteItem(1965, cabbageCount); e.getPlayer().getInventory().addCoins(cabbageCount * 100); }); option(""No, I will keep my cabbages"", new Dialogue() .addPlayer(HeadE.CALM_TALK, ""Yes, I'll sell you all my cabbages"")); } }); create(); } }); if (option == 3) ShopsHandler.openShop(e.getPlayer(), ""zanaris_general_store""); }); }" "package com.rs.game.content.world.doors; @PluginEventHandler public class DoorPair { private static final String PATH = ""./data/map/doorPairs.json""; private static DoorPair[] DOOR_PAIRS; private static final Map PAIRING_MAP = new HashMap<>(); private final int closed; private final int open; @ServerStartupEvent(Priority.FILE_IO) public static void loadPairs() { try { DOOR_PAIRS = (DoorPair[]) JsonFileManager.loadJsonFile(new File(PATH), DoorPair[].class); } catch (JsonIOException | IOException e) { e.printStackTrace(); } for (DoorPair pair : DOOR_PAIRS) { PAIRING_MAP.put(pair.open, pair.closed); PAIRING_MAP.put(pair.closed, pair.open); } } public static int getOpposingDoor(Player player, GameObject door) { return PAIRING_MAP.get(door.getDefinitions(player).id) != null ? PAIRING_MAP.get(door.getDefinitions(player).id) : 1532; } public DoorPair(int closed, int open) { this.closed = closed; this.open = open; } public int getClosed() { return closed; } public int getOpen() { return open; } }" "package com.rs.game.content.world.doors; @PluginEventHandler public class Doors { public static ObjectClickHandler handleDoors = new ObjectClickHandler(new Object[] { 1531, ""Door"", ""Throne Room Door"", ""Magic door"", ""Doorway"", ""Sturdy door"", ""Bamboo Door"", ""Long hall door"", ""Castle door"", ""Heavy door"", ""Gate"", ""Large door"", ""Metal door"", ""City gate"", ""Red door"", ""Orange door"", ""Yellow door"", ""Cell door"", ""Cell Door"", ""Wall"", ""Storeroom Door"", ""Solid bronze door"", ""Solid steel door"", ""Solid black door"", ""Solid silver door"" }, e -> handleDoor(e.getPlayer(), e.getObject())); public static ObjectClickHandler handleLeftHandedDoors = new ObjectClickHandler(new Object[] { 22921 }, e -> handleLeftHandedDoor(e.getPlayer(), e.getObject())); public static ObjectClickHandler handleInvertedDoors = new ObjectClickHandler(new Object[] { 1531 }, ObjectType.WALL_INTERACT, e -> handleDoor(e.getPlayer(), e.getObject(), 1)); public static ObjectClickHandler handleDoubleDoors = new ObjectClickHandler(new Object[] { 704, 707, 708, 709, 1516, 1517, 1519, 1520, 1542, 1543, 1544, 1545, 1560, 1561, 1596, 1597, 2039, 2041, 2058, 2060, 2199, 2200, 2255, 2256, 2259, 2260, 2546, 2547, 2548, 2549, 2552, 2553, 2896, 2897, 2391, 2392, 2912, 2913, 2922, 2923, 3020, 3021, 3022, 3023, 2673, 2674, 2786, 2787, 2788, 2789, 3506, 3507, 4423, 4424, 4425, 4426, 4427, 4428, 4429, 4430, 4487, 4491, 4490, 4492, 4629, 4630, 4631, 4632, 4633, 4634, 4963, 4964, 5183, 5186, 5187, 5188, 2416, 2417, 26207, 5667, 6238, 6240, 6451, 6452, 6871, 6872, 10262, 10263, 10264, 10265, 10423, 10425, 10427, 10429, 10527, 10528, 10529, 10530, 11620, 11621, 11624, 11625, 11716, 11717, 11718, 11719, 11720, 11721, 11722, 11723, 12045, 12047, 12172, 14443, 14444, 14445, 12349, 12350, 12446, 12447, 12448, 12449, 12467, 12468, 13094, 13095, 13096, 13097, 14233, 14234, 14235, 14236, 15604, 15605, 15641, 15644, 15658, 15660, 17091, 17092, 17093, 17094, 18698, 18699, 18700, 18701, 18971, 18973, 20195, 20196, 20197, 20198, 20391, 21403, 21404, 21405, 21406, 21505, 21506, 21507, 21508, 22435, 22437, 24369, 24370, 24373, 24374, 25638, 25639, 25640, 25641, 25788, 25789, 25790, 25791, 25813, 25814, 25815, 25816, 25825, 25826, 25827, 25828, 26081, 26082, 26083, 26084, 26114, 26115, 27851, 27852, 27853, 27854, 28690, 28691, 28692, 28693, 29315, 29316, 29317, 29318, 31814, 31815, 31816, 31817, 31820, 31821, 31822, 31823, 31824, 31825, 31826, 31827, 31829, 31830, 31831, 31832, 31833, 31834, 31841, 31844, 34819, 34820, 34822, 34823, 34825, 34826, 34827, 34828, 36315, 36316, 36317, 36318, 36999, 37002, 39975, 39976, 39978, 39979, 41131, 41132, 41133, 41134, 41174, 41175, 41178, 41179, 45964, 45965, 45966, 45967, 47240, 47241, 48938, 48939, 48940, 48941, 48942, 48943, 48944, 48945, 49014, 49016, 52176, 52183, 52381, 52313, 52382, 52315, 53671, 53672, 53674, 53675, 59958, 59961, 61051, 61052, 61053, 61054, 64835, 64837, 66599, 66601, 66938, 66940, 66941, 66942 }, e -> handleDoubleDoor(e.getPlayer(), e.getObject())); public static ObjectClickHandler handleInvertedDoubles = new ObjectClickHandler(new Object[] { 37000, 37003 }, e -> handleDoubleDoor(e.getPlayer(), e.getObject(), true)); public static ObjectClickHandler handleInvertedDoublesYanille = new ObjectClickHandler(new Object[] { 1517, 1520 }, new Tile[] { Tile.of(2561, 3099, 0), Tile.of(2561, 3098, 0) }, e -> handleDoubleDoor(e.getPlayer(), e.getObject(), true)); public static ObjectClickHandler handleGates = new ObjectClickHandler(new Object[] { 166, 167, 1551, 1552, 1553, 1556, 2050, 2051, 2306, 2313, 2320, 2344, 2261, 2262, 2438, 2439, 3015, 3016, 3725, 3726, 4311, 4312, 7049, 7050, 7051, 7052, 15510, 15511, 15512, 15513, 15514, 15515, 15516, 15517, 24560, 24561, 34777, 34778, 34779, 34780, 36912, 36913, 36914, 36915, 37351, 37352, 37353, 37354, 45206, 45207, 45208, 45209, 45210, 45211, 45212, 45213 }, e -> handleGate(e.getPlayer(), e.getObject())); public static ObjectClickHandler handleInPlaceSingleDoors = new ObjectClickHandler(new Object[] { 4250, 4251, 5887, 5888, 5889, 5890, 5891, 5893, 64833, 64834, 65365, 65367, 65386, 65387, 65573, 65574, 68977, 68978, 68983 }, e -> handleInPlaceSingleDoor(e.getPlayer(), e.getObject())); public static ObjectClickHandler handleInPlaceDoubleDoors = new ObjectClickHandler(new Object[] { 6553, 6555, 9330, 9738, 69197, 69198 }, e -> handleInPlaceDoubleDoor(e.getPlayer(), e.getObject())); public static ObjectClickHandler handleWasteMyTimeDoors = new ObjectClickHandler(new Object[] { 52, 53, 71, 73, 74, 79, 80, 1589, 1590, 1591, 2154, 2155, 2184, 2685, 2686, 2687, 2688, 3442, 3626, 5730, 18168, 20341, 20665, 20666, 20695, 21065, 37470, 67747 }, e -> e.getPlayer().sendMessage(""The door is securely locked."")); public static ObjectClickHandler handleKeyDoors = new ObjectClickHandler(new Object[] { 1804, 2623 }, e -> { if ((e.getObjectId() == 1804 && e.getPlayer().getInventory().containsItem(""brass key"")) || (e.getObjectId() == 2623 && e.getPlayer().getInventory().containsItem(""dusty key""))) { handleDoor(e.getPlayer(), e.getObject()); return; } e.getPlayer().sendMessage(""The door is securely locked.""); }); public static ObjectClickHandler handleWasteMyTimeDoor1 = new ObjectClickHandler(new Object[] { 1591 }, new Tile[] { Tile.of(2794, 3199, 0) }, e -> handleDoor(e.getPlayer(), e.getObject())); public static ObjectClickHandler handleWasteMyTimeDoor2 = new ObjectClickHandler(new Object[] { 21401 }, e -> e.getPlayer().sendMessage(""The door won't budge."")); public static boolean isTempMove(ObjectDefinitions defs) { return switch (defs.id) { case 39, 2267, 2559, 3437, 34836, 34839, 45856, 45857, 45858, 45859, 24815 -> true; default -> !((defs.containsOption(""Open"") || defs.containsOption(""Close"")) && defs.interactable != 0); }; } public static void handleClosedDoor(Player player, GameObject object) { boolean open = object.getDefinitions(player).containsOption(""Open""); int rotation = object.getRotation(open ? 0 : -1); Tile adjusted = object.getTile(); adjusted = switch (rotation) { case 0 -> adjusted.transform(open ? -1 : 1, 0, 0); case 1 -> adjusted.transform(0, open ? 1 : -1, 0); case 2 -> adjusted.transform(open ? 1 : -1, 0, 0); case 3 -> adjusted.transform(0, open ? -1 : 1, 0); default -> adjusted; }; GameObject opp = new GameObject(DoorPair.getOpposingDoor(player, object), object.getType(), object.getRotation(open ? -1 : 1), adjusted); if (!isTempMove(opp.getDefinitions(player))) { World.removeObject(object); World.spawnObject(opp, true); } else { Tile toTile = object.getTile().transform(0, 0, 0); toTile = switch (object.getRotation()) { case 0 -> toTile.transform(player.getX() < object.getX() ? 0 : -1, 0, 0); case 1 -> toTile.transform(0, player.getY() > object.getY() ? 0 : 1, 0); case 2 -> toTile.transform(player.getX() > object.getX() ? 0 : 1, 0, 0); case 3 -> toTile.transform(0, player.getY() < object.getY() ? 0 : -1, 0); default -> toTile; }; World.spawnObjectTemporary(new GameObject(object, 83), 2, true); World.spawnObjectTemporary(opp, 2, true); player.addWalkSteps(toTile, 3, false); } } public static void handleInPlaceSingleDoor(Player player, GameObject object) { ObjectDefinitions openedDef = ObjectDefinitions.getDefs(DoorPair.getOpposingDoor(player, object)); boolean tempMove = isTempMove(openedDef); if (tempMove) { World.spawnObjectTemporary(new GameObject(DoorPair.getOpposingDoor(player, object), object.getType(), object.getRotation(), object.getTile()), 2, true); Tile toTile = object.getTile().transform(0, 0, 0); toTile = switch (object.getRotation()) { case 0 -> toTile.transform(player.getX() < object.getX() ? 0 : -1, 0, 0); case 1 -> toTile.transform(0, player.getY() > object.getY() ? 0 : 1, 0); case 2 -> toTile.transform(player.getX() > object.getX() ? 0 : 1, 0, 0); case 3 -> toTile.transform(0, player.getY() < object.getY() ? 0 : -1, 0); default -> toTile; }; player.addWalkSteps(toTile, 3, false); } else World.spawnObject(new GameObject(DoorPair.getOpposingDoor(player, object), object.getType(), object.getRotation(), object.getTile())); } public static void handleInPlaceDoubleDoor(Player player, GameObject object) { ObjectDefinitions openedDef = ObjectDefinitions.getDefs(DoorPair.getOpposingDoor(player, object)); boolean tempMove = isTempMove(openedDef); GameObject[] doors = getNearby(player, object, (t1, t2) -> t1.getY() > t2.getY(), object.getTile().transform(0, 1, 0), object.getTile().transform(0, -1, 0)); if (doors == null) doors = getNearby(player, object, (t1, t2) -> t1.getX() > t2.getX(), object.getTile().transform(1, 0, 0), object.getTile().transform(-1, 0, 0)); if (doors == null) { handleDoor(player, object); return; } if (tempMove) { World.spawnObjectTemporary(new GameObject(DoorPair.getOpposingDoor(player, doors[0]), doors[0].getType(), doors[0].getRotation(), doors[0].getTile()), 3, true); World.spawnObjectTemporary(new GameObject(DoorPair.getOpposingDoor(player, doors[1]), doors[1].getType(), doors[1].getRotation(), doors[1].getTile()), 3, true); switch (object.getRotation()) { case 0: player.addWalkSteps(object.getTile().transform(player.getX() > object.getX() ? -2 : 2, 0, 0), 3, false); break; case 1: player.addWalkSteps(object.getTile().transform(0, player.getY() < object.getY() ? 2 : -2, 0), 3, false); break; case 2: player.addWalkSteps(object.getTile().transform(player.getX() < object.getX() ? 2 : -2, 0, 0), 3, false); break; case 3: player.addWalkSteps(object.getTile().transform(0, player.getY() > object.getY() ? -2 : 2, 0), 3, false); break; } } else { World.spawnObject(new GameObject(DoorPair.getOpposingDoor(player, doors[0]), doors[0].getType(), doors[0].getRotation(), doors[0].getTile())); World.spawnObject(new GameObject(DoorPair.getOpposingDoor(player, doors[1]), doors[1].getType(), doors[1].getRotation(), doors[1].getTile())); } } public static void handleDoor(Player player, GameObject object) { handleDoor(player, object, 0); } public static void handleDoor(Player player, GameObject object, int offset) { boolean open = object.getDefinitions(player).containsOption(""Open""); int rotation = object.getRotation(open ? offset : -1 + offset); Tile adjusted = object.getTile(); adjusted = switch (rotation) { case 0 -> adjusted.transform(open ? -1 : 1, 0, 0); case 1 -> adjusted.transform(0, open ? 1 : -1, 0); case 2 -> adjusted.transform(open ? 1 : -1, 0, 0); case 3 -> adjusted.transform(0, open ? -1 : 1, 0); default -> adjusted; }; Door opp = new Door(DoorPair.getOpposingDoor(player, object), object.getType(), object.getRotation(open ? 1 : -1), adjusted, object); if (!isTempMove(opp.getDefinitions(player))) { if (object instanceof Door door) { World.removeObject(object); World.spawnObject(door.original, true); } else { World.removeObject(object); World.spawnObject(opp, true); } } else { Tile toTile = object.getTile(); toTile = switch (object.getRotation()) { case 0 -> toTile.transform(player.getX() < object.getX() ? 0 : -1, 0, 0); case 1 -> toTile.transform(0, player.getY() > object.getY() ? 0 : 1, 0); case 2 -> toTile.transform(player.getX() > object.getX() ? 0 : 1, 0, 0); case 3 -> toTile.transform(0, player.getY() < object.getY() ? 0 : -1, 0); default -> toTile; }; World.spawnObjectTemporary(new GameObject(object, 83), 2, true); World.spawnObjectTemporary(opp, 2, true); player.addWalkSteps(toTile, 3, false); } } public static void handleLeftHandedDoor(Player player, GameObject object) { handleLeftHandedDoor(player, object, 0); } public static void handleLeftHandedDoor(Player player, GameObject object, int offset) { boolean open = object.getDefinitions(player).containsOption(""Open""); int rotation = object.getRotation(open ? offset : -1 + offset); Tile adjusted = object.getTile(); adjusted = switch (rotation) { case 0 -> adjusted.transform(open ? -1 : 1, 0, 0); case 1 -> adjusted.transform(0, open ? 1 : -1, 0); case 2 -> adjusted.transform(open ? 1 : -1, 0, 0); case 3 -> adjusted.transform(0, open ? -1 : 1, 0); default -> adjusted; }; Door opp = new Door(object.getId(), object.getType(), object.getRotation(open ? 3 : -1), adjusted, object); if (!isTempMove(opp.getDefinitions(player))) { if (object instanceof Door door) { World.removeObject(object); World.spawnObject(door.original, true); } else { World.removeObject(object); World.spawnObject(opp, true); } } else { Tile toTile = object.getTile(); toTile = switch (object.getRotation()) { case 0 -> toTile.transform(player.getX() < object.getX() ? 0 : -1, 0, 0); case 1 -> toTile.transform(0, player.getY() > object.getY() ? 0 : 1, 0); case 2 -> toTile.transform(player.getX() > object.getX() ? 0 : 1, 0, 0); case 3 -> toTile.transform(0, player.getY() < object.getY() ? 0 : -1, 0); default -> toTile; }; World.spawnObjectTemporary(new GameObject(object, 83), 2, true); World.spawnObjectTemporary(opp, 2, true); player.addWalkSteps(toTile, 3, false); } } public static void handleOneWayDoor(Player player, GameObject object, int rotation) { boolean open = object.getDefinitions(player).containsOption(""Open""); Tile adjusted = object.getTile(); adjusted = switch (rotation) { case 0 -> adjusted.transform(open ? -1 : 1, 0, 0); case 1 -> adjusted.transform(0, open ? 1 : -1, 0); case 2 -> adjusted.transform(open ? 1 : -1, 0, 0); case 3 -> adjusted.transform(0, open ? -1 : 1, 0); default -> adjusted; }; GameObject opp = new GameObject(DoorPair.getOpposingDoor(player, object), object.getType(), object.getRotation(1), adjusted); if (!isTempMove(opp.getDefinitions(player))) { World.removeObject(object); if (object instanceof Door door) World.spawnObject(door.getOriginal()); else World.spawnObject(opp, true); } else { Tile toTile = object.getTile(); toTile = switch (object.getRotation()) { case 0 -> toTile.transform(player.getX() < object.getX() ? 0 : -1, 0, 0); case 1 -> toTile.transform(0, player.getY() > object.getY() ? 0 : 1, 0); case 2 -> toTile.transform(player.getX() > object.getX() ? 0 : 1, 0, 0); case 3 -> toTile.transform(0, player.getY() < object.getY() ? 0 : -1, 0); default -> toTile; }; World.spawnObjectTemporary(new GameObject(object, 83), 2, true); World.spawnObjectTemporary(opp, 2, true); player.addWalkSteps(toTile, 3, false); } } public static void handleDoubleDoor(Player player, GameObject object) { handleDoubleDoor(player, object, false); } public static void handleDoubleDoor(Player player, GameObject object, boolean invert) { boolean open = object.getDefinitions(player).containsOption(""Open""); ObjectDefinitions openedDef = ObjectDefinitions.getDefs(DoorPair.getOpposingDoor(player, object)); boolean tempMove = isTempMove(openedDef); GameObject[] doors = new GameObject[2]; if (object instanceof Door door && door.getPair() != null) { doors[0] = door; doors[1] = door.getPair(); } else { doors = getNearby(player, object, (t1, t2) -> t1.getY() > t2.getY(), object.getTile().transform(0, 1, 0), object.getTile().transform(0, -1, 0)); if (doors == null) doors = getNearby(player, object, (t1, t2) -> t1.getX() > t2.getX(), object.getTile().transform(1, 0, 0), object.getTile().transform(-1, 0, 0)); if (doors == null) { handleDoor(player, object); return; } } int rotation = doors[0].getRotation(open ? invert ? 2 : 0 : invert ? 3 : 1); switch (rotation) { case 0: if (tempMove) { World.spawnObjectTemporary(new GameObject(doors[0], 83), 2, true); World.spawnObjectTemporary(new GameObject(doors[1], 83), 2, true); World.spawnObjectTemporary(new GameObject(DoorPair.getOpposingDoor(player, doors[0]), doors[0].getType(), doors[0].getRotation(-1), doors[0].getTile().transform(-1, 0, 0)), 2, true); World.spawnObjectTemporary(new GameObject(DoorPair.getOpposingDoor(player, doors[1]), doors[1].getType(), doors[1].getRotation(1), doors[1].getTile().transform(-1, 0, 0)), 2, true); player.addWalkSteps(object.getTile().transform(player.getX() >= object.getX() ? -1 : 0, 0, 0), 3, false); } else { World.removeObject(doors[0]); World.removeObject(doors[1]); if (doors[0] instanceof Door d0 && doors[1] instanceof Door d1) { World.spawnObject(d0.getOriginal()); World.spawnObject(d1.getOriginal()); } else { Door door0 = new Door(DoorPair.getOpposingDoor(player, doors[0]), doors[0].getType(), doors[0].getRotation(open ? -1 : 1), open ? doors[0].getTile().transform(-1, 0, 0) : doors[0].getTile().transform(1, 0, 0), doors[0]); Door door1 = new Door(DoorPair.getOpposingDoor(player, doors[1]), doors[1].getType(), doors[1].getRotation(open ? 1 : -1), open ? doors[1].getTile().transform(-1, 0, 0) : doors[1].getTile().transform(1, 0, 0), doors[1]); World.spawnObject(door0.setPair(door1)); World.spawnObject(door1.setPair(door0)); } } break; case 1: if (tempMove) { World.spawnObjectTemporary(new GameObject(doors[0], 83), 2, true); World.spawnObjectTemporary(new GameObject(doors[1], 83), 2, true); World.spawnObjectTemporary(new GameObject(DoorPair.getOpposingDoor(player, doors[0]), doors[0].getType(), doors[0].getRotation(-1), doors[0].getTile().transform(0, 1, 0)), 2, true); World.spawnObjectTemporary(new GameObject(DoorPair.getOpposingDoor(player, doors[1]), doors[1].getType(), doors[1].getRotation(1), doors[1].getTile().transform(0, 1, 0)), 2, true); player.addWalkSteps(object.getTile().transform(0, player.getY() <= object.getY() ? 1 : 0, 0), 3, false); } else { World.removeObject(doors[0]); World.removeObject(doors[1]); if (doors[0] instanceof Door d0 && doors[1] instanceof Door d1) { World.spawnObject(d0.getOriginal()); World.spawnObject(d1.getOriginal()); } else { Door door0 = new Door(DoorPair.getOpposingDoor(player, doors[0]), doors[0].getType(), doors[0].getRotation(open ? -1 : 1), open ? doors[0].getTile().transform(0, 1, 0) : doors[0].getTile().transform(0, -1, 0), doors[0]); Door door1 = new Door(DoorPair.getOpposingDoor(player, doors[1]), doors[1].getType(), doors[1].getRotation(open ? 1 : -1), open ? doors[1].getTile().transform(0, 1, 0) : doors[1].getTile().transform(0, -1, 0), doors[1]); World.spawnObject(door0.setPair(door1)); World.spawnObject(door1.setPair(door0)); } } break; case 2: if (tempMove) { World.spawnObjectTemporary(new GameObject(doors[0], 83), 2, true); World.spawnObjectTemporary(new GameObject(doors[1], 83), 2, true); World.spawnObjectTemporary(new GameObject(DoorPair.getOpposingDoor(player, doors[0]), doors[0].getType(), doors[0].getRotation(1), doors[0].getTile().transform(1, 0, 0)), 2, true); World.spawnObjectTemporary(new GameObject(DoorPair.getOpposingDoor(player, doors[1]), doors[1].getType(), doors[1].getRotation(-1), doors[1].getTile().transform(1, 0, 0)), 2, true); player.addWalkSteps(object.getTile().transform(player.getX() <= object.getX() ? 1 : 0, 0, 0), 3, false); } else { World.removeObject(doors[0]); World.removeObject(doors[1]); if (doors[0] instanceof Door d0 && doors[1] instanceof Door d1) { World.spawnObject(d0.getOriginal()); World.spawnObject(d1.getOriginal()); } else { Door door0 = new Door(DoorPair.getOpposingDoor(player, doors[0]), doors[0].getType(), doors[0].getRotation(open ? 1 : -1), open ? doors[0].getTile().transform(1, 0, 0) : doors[0].getTile().transform(-1, 0, 0), doors[0]); Door door1 = new Door(DoorPair.getOpposingDoor(player, doors[1]), doors[1].getType(), doors[1].getRotation(open ? -1 : 1), open ? doors[1].getTile().transform(1, 0, 0) : doors[1].getTile().transform(-1, 0, 0), doors[1]); World.spawnObject(door0.setPair(door1)); World.spawnObject(door1.setPair(door0)); } } break; case 3: if (tempMove) { World.spawnObjectTemporary(new GameObject(doors[0], 83), 2, true); World.spawnObjectTemporary(new GameObject(doors[1], 83), 2, true); World.spawnObjectTemporary(new GameObject(DoorPair.getOpposingDoor(player, doors[0]), doors[0].getType(), doors[0].getRotation(1), doors[0].getTile().transform(0, -1, 0)), 2, true); World.spawnObjectTemporary(new GameObject(DoorPair.getOpposingDoor(player, doors[1]), doors[1].getType(), doors[1].getRotation(-1), doors[1].getTile().transform(0, -1, 0)), 2, true); player.addWalkSteps(object.getTile().transform(0, player.getY() >= object.getY() ? -1 : 0, 0), 3, false); } else { World.removeObject(doors[0]); World.removeObject(doors[1]); if (doors[0] instanceof Door d0 && doors[1] instanceof Door d1) { World.spawnObject(d0.getOriginal()); World.spawnObject(d1.getOriginal()); } else { Door door0 = new Door(DoorPair.getOpposingDoor(player, doors[0]), doors[0].getType(), doors[0].getRotation(open ? 1 : -1), open ? doors[0].getTile().transform(0, -1, 0) : doors[0].getTile().transform(0, 1, 0), doors[0]); Door door1 = new Door(DoorPair.getOpposingDoor(player, doors[1]), doors[1].getType(), doors[1].getRotation(open ? -1 : 1), open ? doors[1].getTile().transform(0, -1, 0) : doors[1].getTile().transform(0, 1, 0), doors[1]); World.spawnObject(door0.setPair(door1)); World.spawnObject(door1.setPair(door0)); } } break; } } public static void handleGate(Player player, GameObject object) { boolean open = object.getDefinitions(player).containsOption(""Open""); int rotation = object.getRotation(open ? 0 : 1); ObjectDefinitions openedDef = ObjectDefinitions.getDefs(DoorPair.getOpposingDoor(player, object)); boolean tempMove = !((openedDef.containsOption(""Open"") || openedDef.containsOption(""Close"")) && openedDef.interactable != 0); GameObject[] gates; switch (rotation) { case 0: if (open) gates = getNearby(player, object, (t1, t2) -> t1.getY() > t2.getY(), object.getTile().transform(0, -1, 0), object.getTile().transform(0, 1, 0)); else gates = getNearby(player, object, (t1, t2) -> t1.getX() < t2.getX(), object.getTile().transform(-1, 0, 0), object.getTile().transform(1, 0, 0)); if (gates == null) { handleDoor(player, object); return; } if (tempMove) { World.spawnObjectTemporary(new GameObject(gates[0], 83), 2, true); World.spawnObjectTemporary(new GameObject(gates[1], 83), 2, true); World.spawnObjectTemporary(new GameObject(DoorPair.getOpposingDoor(player, gates[0]), gates[0].getType(), gates[0].getRotation(open ? -1 : 1), open ? gates[0].getTile().transform(-1, 0, 0) : gates[0].getTile().transform(1, 0, 0)), 2, true); World.spawnObjectTemporary(new GameObject(DoorPair.getOpposingDoor(player, gates[1]), gates[1].getType(), gates[1].getRotation(open ? -1 : 1), open ? gates[1].getTile().transform(-2, -1, 0) : gates[1].getTile().transform(2, 1, 0)), 2, true); player.addWalkSteps(object.getTile().transform(player.getX() < object.getX() ? 0 : -1, 0, 0), 3, false); } else { World.removeObject(gates[0]); World.removeObject(gates[1]); World.spawnObject(new GameObject(DoorPair.getOpposingDoor(player, gates[0]), gates[0].getType(), gates[0].getRotation(open ? -1 : 1), open ? gates[0].getTile().transform(-1, 0, 0) : gates[0].getTile().transform(1, 0, 0))); World.spawnObject(new GameObject(DoorPair.getOpposingDoor(player, gates[1]), gates[1].getType(), gates[1].getRotation(open ? -1 : 1), open ? gates[1].getTile().transform(-2, -1, 0) : gates[1].getTile().transform(2, 1, 0))); } break; case 1: if (open) gates = getNearby(player, object, (t1, t2) -> t1.getX() > t2.getX(), object.getTile().transform(1, 0, 0), object.getTile().transform(-1, 0, 0)); else gates = getNearby(player, object, (t1, t2) -> t1.getY() > t2.getY(), object.getTile().transform(0, 1, 0), object.getTile().transform(0, -1, 0)); if (gates == null) { handleDoor(player, object); return; } if (tempMove) { World.spawnObjectTemporary(new GameObject(gates[0], 83), 2, true); World.spawnObjectTemporary(new GameObject(gates[1], 83), 2, true); World.spawnObjectTemporary(new GameObject(DoorPair.getOpposingDoor(player, gates[0]), gates[0].getType(), gates[0].getRotation(-1), gates[0].getTile().transform(0, 1, 0)), 2, true); World.spawnObjectTemporary(new GameObject(DoorPair.getOpposingDoor(player, gates[1]), gates[1].getType(), gates[1].getRotation(-1), gates[1].getTile().transform(-1, 2, 0)), 2, true); player.addWalkSteps(object.getTile().transform(0, player.getY() <= object.getY() ? 1 : 0, 0), 3, false); } else { World.removeObject(gates[0]); World.removeObject(gates[1]); World.spawnObject(new GameObject(DoorPair.getOpposingDoor(player, gates[0]), gates[0].getType(), gates[0].getRotation(open ? -1 : 1), open ? gates[0].getTile().transform(0, 1, 0) : gates[0].getTile().transform(0, -1, 0))); World.spawnObject(new GameObject(DoorPair.getOpposingDoor(player, gates[1]), gates[1].getType(), gates[1].getRotation(open ? -1 : 1), open ? gates[1].getTile().transform(-1, 2, 0) : gates[1].getTile().transform(1, -2, 0))); } break; case 2: if (open) gates = getNearby(player, object, (t1, t2) -> t1.getY() < t2.getY(), object.getTile().transform(0, 1, 0), object.getTile().transform(0, -1, 0)); else gates = getNearby(player, object, (t1, t2) -> t1.getX() > t2.getX(), object.getTile().transform(1, 0, 0), object.getTile().transform(-1, 0, 0)); if (gates == null) { handleDoor(player, object); return; } if (tempMove) { World.spawnObjectTemporary(new GameObject(gates[0], 83), 2, true); World.spawnObjectTemporary(new GameObject(gates[1], 83), 2, true); World.spawnObjectTemporary(new GameObject(DoorPair.getOpposingDoor(player, gates[0]), gates[0].getType(), gates[0].getRotation(open ? -1 : 1), open ? gates[0].getTile().transform(1, 0, 0) : gates[0].getTile().transform(-1, 0, 0)), 2, true); World.spawnObjectTemporary(new GameObject(DoorPair.getOpposingDoor(player, gates[1]), gates[1].getType(), gates[1].getRotation(open ? -1 : 1), open ? gates[1].getTile().transform(2, 1, 0) : gates[1].getTile().transform(-2, -1, 0)), 2, true); player.addWalkSteps(object.getTile().transform(player.getX() > object.getX() ? 0 : 1, 0, 0), 3, false); } else { World.removeObject(gates[0]); World.removeObject(gates[1]); World.spawnObject(new GameObject(DoorPair.getOpposingDoor(player, gates[0]), gates[0].getType(), gates[0].getRotation(open ? -1 : 1), open ? gates[0].getTile().transform(1, 0, 0) : gates[0].getTile().transform(-1, 0, 0))); World.spawnObject(new GameObject(DoorPair.getOpposingDoor(player, gates[1]), gates[1].getType(), gates[1].getRotation(open ? -1 : 1), open ? gates[1].getTile().transform(2, 1, 0) : gates[1].getTile().transform(-2, -1, 0))); } break; case 3: if (open) gates = getNearby(player, object, (t1, t2) -> t1.getX() < t2.getX(), object.getTile().transform(1, 0, 0), object.getTile().transform(-1, 0, 0)); else gates = getNearby(player, object, (t1, t2) -> t1.getY() < t2.getY(), object.getTile().transform(0, 1, 0), object.getTile().transform(0, -1, 0)); if (gates == null) { handleDoor(player, object); return; } if (tempMove) { World.spawnObjectTemporary(new GameObject(gates[0], 83), 2, true); World.spawnObjectTemporary(new GameObject(gates[1], 83), 2, true); World.spawnObjectTemporary(new GameObject(DoorPair.getOpposingDoor(player, gates[0]), gates[0].getType(), gates[0].getRotation(-1), gates[0].getTile().transform(0, -1, 0)), 2, true); World.spawnObjectTemporary(new GameObject(DoorPair.getOpposingDoor(player, gates[1]), gates[1].getType(), gates[1].getRotation(-1), gates[1].getTile().transform(1, -2, 0)), 2, true); player.addWalkSteps(object.getTile().transform(0, player.getY() < object.getY() ? 0 : -1, 0), 3, false); } else { World.removeObject(gates[0]); World.removeObject(gates[1]); World.spawnObject(new GameObject(DoorPair.getOpposingDoor(player, gates[0]), gates[0].getType(), gates[0].getRotation(open ? -1 : 1), open ? gates[0].getTile().transform(0, -1, 0) : gates[0].getTile().transform(0, 1, 0))); World.spawnObject(new GameObject(DoorPair.getOpposingDoor(player, gates[1]), gates[1].getType(), gates[1].getRotation(open ? -1 : 1), open ? gates[1].getTile().transform(1, -2, 0) : gates[1].getTile().transform(-1, 2, 0))); } break; } } private static GameObject[] getNearby(Player player, GameObject object, BiFunction sort, Tile... toCheck) { GameObject[] g = new GameObject[2]; for (Tile t : toCheck) if (g[0] == null || g[0].getDefinitions().interactable == 0 || !g[0].getDefinitions().getName().equals(object.getDefinitions().getName())) g[0] = World.getObject(t, object.getType()); if (g[0] == null || g[0].getDefinitions().interactable == 0 || !g[0].getDefinitions().getName().equals(object.getDefinitions().getName())) return null; if (sort.apply(g[0].getTile(), object.getTile())) { g[1] = g[0]; g[0] = object; } else g[1] = object; return g; } public static void searchDoors(int search) { int SEARCH_FOR = search; Map> doors = new HashMap<>(); for (int i = 0; i < Utils.getObjectDefinitionsSize(); i++) { if (i != SEARCH_FOR) continue; ObjectDefinitions defs = ObjectDefinitions.getDefs(i); if (defs.varp != -1 || defs.varpBit != -1) continue; if (defs.getName().toLowerCase().contains(""door"") || defs.getName().toLowerCase().contains(""gate"") || defs.getName().toLowerCase().contains(""fence"") || defs.getName().toLowerCase().contains(""wall"")) if (defs.containsOptionIgnoreCase(""open"")) { List opened = new ArrayList<>(); for (int op = 0; op < Utils.getObjectDefinitionsSize(); op++) { if (op == i || op < 0 || op > Utils.getObjectDefinitionsSize()) continue; ObjectDefinitions openedDef = ObjectDefinitions.getDefs(op); if (!openedDef.containsOptionIgnoreCase(""open"") && openedDef.modelIds != null && defs.modelIds[0][0] == openedDef.modelIds[0][0]) if (Arrays.equals(defs.modifiedColors, openedDef.modifiedColors) && Arrays.equals(defs.originalColors, openedDef.originalColors)) opened.add(op); } doors.put(i, opened); } } List closedList = new ArrayList<>(doors.keySet()); Collections.sort(closedList); for (int closed : closedList) { List openedList = doors.get(closed); if (openedList.isEmpty()) continue; ObjectDefinitions closedDef = ObjectDefinitions.getDefs(closed); Logger.debug(Doors.class, ""searchDoors"", closedDef.id + "" - "" + closedDef.getName() + "" - "" + closedDef.modelIds[0][0] + "" - "" + Arrays.toString(closedDef.types) + "" {""); for (int open : openedList) { ObjectDefinitions openedDef = ObjectDefinitions.getDefs(open); Logger.debug(Doors.class, ""searchDoors"", ""\t"" + openedDef.id + "" - "" + openedDef.getName() + "" - "" + openedDef.modelIds[0][0] + "" - "" + Arrays.toString(openedDef.types) + "" - "" + Arrays.toString(openedDef.options)); Logger.debug(Doors.class, ""searchDoors"", ""\tap("" + search + "", "" + openedDef.id + "");""); } Logger.debug(Doors.class, ""searchDoors"", ""}""); } } public static class Door extends GameObject { private final GameObject original; private Door pair; public Door(int id, ObjectType type, int rotation, Tile location, GameObject original) { super(id, type, rotation, location); this.original = new GameObject(original); } public GameObject getOriginal() { return original; } public Door getPair() { return pair; } public Door setPair(Door pair) { this.pair = pair; return this; } } }" "package com.rs.game.content.world.doors; public class DoubleDoor { private final int first; private final int second; public DoubleDoor(int first, int second) { this.first = first; this.second = second; } public int getFirst() { return first; } public int getSecond() { return second; } }" "package com.rs.game.content.world.npcs; @PluginEventHandler public class Banker extends Conversation { public Banker(Player player, NPC npc) { super(player); addNPC(npc.getId(), HeadE.CHEERFUL_EXPOSITION, ""Good day. How may I help you?""); addOptions(new Options() { @Override public void create() { option(""I'd like to access my bank account, please."", () -> player.getBank().open()); option(""I'd like to check my PIN settings."", () -> player.getBank().openPinSettings()); option(""I'd like to see my collection box."", () -> GE.openCollection(player)); option(""What is this place?"", new Dialogue() .addNPC(npc.getId(), HeadE.CHEERFUL_EXPOSITION, ""This is a branch of the Bank of Gielinor. We have branches in many towns."") .addOptions(new Options() { @Override public void create() { option(""And what do you do?"", new Dialogue() .addNPC(npc.getId(), HeadE.CHEERFUL_EXPOSITION, ""We will look after your items and money for you. Leave your valuables with us if you want to keep them safe."")); option(""Didn't you used to be called the Bank of Varrock?"", new Dialogue() .addNPC(npc.getId(), HeadE.CALM_TALK, ""Yes we did, but people kept on coming into our branches outside of Varrock and telling us that our signs were wrong. They acted as if we didn't know what town we were in or something."")); } })); option(""I'd like to change my theshold for valuable loot notifications."", new Dialogue() .addPlayer(HeadE.HAPPY_TALKING, ""I'd like to change my theshold for valuable loot notifications."") .addNPC(npc.getId(), HeadE.HAPPY_TALKING, ""Okay, your current threshold is "" + player.getI(""lootbeamThreshold"", 90000) + "" GP. What would you like to set it to?"") .addNext(() -> player.sendInputInteger(""What would you like to set it to?"", amount -> { if (amount < 0) return; player.save(""lootbeamThreshold"", amount); }))); } }); create(); } public static NPCInteractionDistanceHandler bankerDistance = new NPCInteractionDistanceHandler(new Object[] { ""Banker"" }, (p, n) -> 1); public static NPCClickHandler bankerHandler = new NPCClickHandler(new Object[] { ""Banker"", 14707, 2619, 13455, 15194 }, e -> { switch(e.getOption()) { case ""Bank"": e.getPlayer().getBank().open(); break; case ""Collect"": GE.openCollection(e.getPlayer()); break; case ""Talk-to"": e.getPlayer().startConversation(new Banker(e.getPlayer(), e.getNPC())); break; } }); public static ObjectClickHandler bankObjHandler = new ObjectClickHandler(new Object[] { ""Bank booth"", ""Bank"", ""Bank chest"", ""Bank table"", ""Counter"", ""Shantay chest"", ""Darkmeyer Treasury"" }, e -> { switch(e.getOption()) { case ""Bank"": e.getPlayer().getBank().open(); break; case ""Collect"": GE.openCollection(e.getPlayer()); break; case ""Use"": if (e.getObject().getDefinitions().getName(e.getPlayer().getVars()).equals(""Bank chest"")) e.getPlayer().getBank().open(); break; case ""Open"": if (e.getObject().getDefinitions().getName(e.getPlayer().getVars()).equals(""Shantay chest"")) e.getPlayer().getBank().open(); break; default: e.getPlayer().sendMessage(""Unhandled bank object option: "" + e.getOption()); break; } }); public static ObjectClickHandler depositBoxHandler = new ObjectClickHandler(new Object[] { ""Bank deposit box"", ""Deposit box"", ""Deposit Box"", ""Deposit chest"", ""Pulley lift"" }, e -> { switch(e.getOption()) { case ""Deposit"": case ""Use"": e.getPlayer().getBank().openDepositBox(); break; default: e.getPlayer().sendMessage(""Unhandled deposit box object option: "" + e.getOption()); break; } }); }" "package com.rs.game.content.world.npcs; public class BrutalDragonCombat extends CombatScript { @Override public Object[] getKeys() { return new Object[] { ""Brutal green dragon"" }; } @Override public int attack(NPC npc, Entity target) { final NPCCombatDefinitions defs = npc.getCombatDefinitions(); int damage; switch (Utils.getRandomInclusive(3)) { case 0: // Melee if (npc.withinDistance(target.getTile(), 3)) { damage = getMaxHit(npc, defs.getMaxHit(), AttackStyle.MELEE, target); npc.setNextAnimation(new Animation(defs.getAttackEmote())); delayHit(npc, 0, target, getMeleeHit(npc, damage)); } else { damage = Utils.getRandomInclusive(500); int protection = PlayerCombatKt.getAntifireLevel(target, true); if (protection == 1) damage = Utils.getRandomInclusive(50); else if (protection == 2) damage = 0; npc.setNextAnimation(new Animation(12259)); WorldProjectile p = World.sendProjectile(npc, target, 393, 28, 32, 50, 2, 16, 0); delayHit(npc, p.getTaskDelay(), target, getRegularHit(npc, damage)); } break; case 1: // Dragon breath if (npc.withinDistance(target.getTile(), 3)) { damage = Utils.getRandomInclusive(650); int protection = PlayerCombatKt.getAntifireLevel(target, true); if (protection == 1) damage = Utils.getRandomInclusive(300); else if (protection == 2) damage = 0; npc.setNextAnimation(new Animation(14245)); npc.setNextSpotAnim(new SpotAnim(2465)); delayHit(npc, 1, target, getRegularHit(npc, damage)); } else { damage = Utils.getRandomInclusive(650); int protection = PlayerCombatKt.getAntifireLevel(target, true); if (protection == 1) damage = Utils.getRandomInclusive(40); else if (protection == 2) damage = 0; npc.setNextAnimation(new Animation(12259)); WorldProjectile p = World.sendProjectile(npc, target, 393, 28, 32, 50, 2, 16, 0); delayHit(npc, p.getTaskDelay(), target, getRegularHit(npc, damage)); } break; case 2: case 3: damage = Utils.getRandomInclusive(180); npc.setNextAnimation(new Animation(12259)); WorldProjectile p = World.sendProjectile(npc, target, 2705, 28, 32, 50, 2, 16, 0); delayHit(npc, p.getTaskDelay(), target, getMagicHit(npc, damage)); break; } return npc.getAttackSpeed(); } }" "package com.rs.game.content.world.npcs; public class CatableponCombat extends CombatScript { @Override public Object[] getKeys() { return new Object[] { 4397, 4398, 4399 }; } @Override public int attack(NPC npc, final Entity target) { NPCCombatDefinitions def = npc.getCombatDefinitions(); if (Utils.random(10) == 0 && target instanceof Player player) { int strLvl = player.getSkills().getLevelForXp(Constants.STRENGTH); if (strLvl - player.getSkills().getLevel(Constants.STRENGTH) < 8) { player.getSkills().drainLevel(Constants.STRENGTH, (int) (strLvl * 0.15)); npc.setNextAnimation(new Animation(4272)); delayHit(npc, 1, target, getMagicHit(npc, getMaxHit(npc, def.getMaxHit(), def.getAttackStyle(), target))); return npc.getAttackSpeed(); } } delayHit(npc, 0, target, getMeleeHit(npc, getMaxHit(npc, def.getMaxHit(), def.getAttackStyle(), target))); npc.setNextAnimation(new Animation(def.getAttackEmote())); return npc.getAttackSpeed(); } }" "package com.rs.game.content.world.npcs; @PluginEventHandler public class DoorSupport extends NPC { public DoorSupport(int id, Tile tile) { super(id, tile, true); setCantFollowUnderCombat(true); } @Override public void processNPC() { cancelFaceEntityNoCheck(); } public boolean canDestroy(Player player) { if (getId() == 2446) return player.getY() < getY(); if (getId() == 2440) return player.getY() > getY(); return player.getX() > getX(); } @Override public boolean ignoreWallsWhenMeleeing() { return true; } @Override public void sendDeath(Entity killer) { transformIntoNPC(getId() + 1); final GameObject door = World.getObjectWithId(getTile(), 8967); if (door != null) World.removeObject(door); WorldTasks.schedule(Ticks.fromSeconds(60), () -> { try { transformIntoNPC(getId() - 1); reset(); if (door != null) World.spawnObject(door); } catch (Throwable e) { Logger.handle(DoorSupport.class, ""DoorSupport.sendDeath"", e); } }); } public static NPCInstanceHandler toFunc = new NPCInstanceHandler(new Object[] { 2440, 2443, 2446 }, DoorSupport::new); }" "package com.rs.game.content.world.npcs; public class FrostDragonCombat extends CombatScript { @Override public Object[] getKeys() { return new Object[] { ""Frost dragon"" }; } @Override public int attack(NPC npc, Entity target) { final NPCCombatDefinitions defs = npc.getCombatDefinitions(); int damage; int mageRange = npc.getTempAttribs().getI(""frostAtkStyle"", -1) == -1 ? Utils.getRandomInclusive(1) : npc.getTempAttribs().getI(""frostAtkStyle"", -1); npc.getTempAttribs().setI(""frostAtkStyle"", mageRange); if (Utils.random(3) == 0) { if (WorldUtil.isInRange(npc, target, 0)) { damage = Utils.getRandomInclusive(500); int protection = PlayerCombatKt.getAntifireLevel(target, true); if (protection == 1) damage = Utils.getRandomInclusive(40); else if (protection == 2) damage = 0; npc.setNextAnimation(new Animation(13152)); npc.setNextSpotAnim(new SpotAnim(2465)); delayHit(npc, 1, target, getRegularHit(npc, damage)); } else { damage = Utils.getRandomInclusive(500); int protection = PlayerCombatKt.getAntifireLevel(target, true); if (protection == 1) damage = Utils.getRandomInclusive(50); else if (protection == 2) damage = 0; npc.setNextAnimation(new Animation(13155)); delayHit(npc, World.sendProjectile(npc, target, 393, 28, 16, 35, 2, 16, 0).getTaskDelay(), target, getRegularHit(npc, damage)); } } else if (npc.withinDistance(target.getTile(), 3) && Utils.random(2) == 0) { damage = getMaxHit(npc, defs.getMaxHit(), AttackStyle.MELEE, target); npc.setNextAnimation(new Animation(defs.getAttackEmote())); delayHit(npc, 0, target, getMeleeHit(npc, damage)); } else if (mageRange == 0) { damage = Utils.getRandomInclusive(250); npc.setNextAnimation(new Animation(13155)); delayHit(npc, World.sendProjectile(npc, target, 2705, 28, 16, 35, 2, 16, 0).getTaskDelay(), target, getMagicHit(npc, damage), () -> target.setNextSpotAnim(new SpotAnim(2711))); } else { damage = Utils.getRandomInclusive(250); npc.setNextAnimation(new Animation(13155)); delayHit(npc, World.sendProjectile(npc, target, 11, 28, 16, 35, 2, 16, 0).getTaskDelay(), target, getRangeHit(npc, damage)); } return npc.getAttackSpeed(); } }" "package com.rs.game.content.world.npcs; public class GorakCombat extends CombatScript { @Override public Object[] getKeys() { return new Object[] { ""Gorak"" }; } @Override public int attack(NPC npc, Entity target) { NPCCombatDefinitions defs = npc.getCombatDefinitions(); int damage = getMaxHit(npc, defs.getMaxHit(), AttackStyle.MELEE, target); npc.setNextAnimation(new Animation(defs.getAttackEmote())); delayHit(npc, 0, target, new Hit(npc, damage, HitLook.TRUE_DAMAGE)); return npc.getAttackSpeed(); } }" "package com.rs.game.content.world.npcs; public class LeatherDragonCombat extends CombatScript { @Override public Object[] getKeys() { return new Object[] { ""Green dragon"", ""Blue dragon"", ""Red dragon"", ""Black dragon"", 742, 14548 }; } @Override public int attack(final NPC npc, final Entity target) { final NPCCombatDefinitions defs = npc.getCombatDefinitions(); int distanceX = target.getX() - npc.getX(); int distanceY = target.getY() - npc.getY(); int size = npc.getSize(); if (distanceX > size || distanceX < -1 || distanceY > size || distanceY < -1) return 0; if (Utils.getRandomInclusive(3) != 0) { npc.setNextAnimation(new Animation(defs.getAttackEmote())); delayHit(npc, 0, target, getMeleeHit(npc, getMaxHit(npc, defs.getMaxHit(), AttackStyle.MELEE, target))); } else { int damage = Utils.getRandomInclusive(500); int fireBreathAnimID = 12259; if(npc.getId() >= 10219 && npc.getId() <= 10224)//Black dragons in dung fireBreathAnimID = 13155; npc.setNextAnimation(new Animation(fireBreathAnimID)); npc.setNextSpotAnim(new SpotAnim(1, 0, 100)); int protection = PlayerCombatKt.getAntifireLevel(target, true); if (protection == 1) damage = Utils.getRandomInclusive(50); else if (protection == 2) damage = 0; delayHit(npc, 1, target, getRegularHit(npc, damage)); } return npc.getAttackSpeed(); } }" "package com.rs.game.content.world.npcs; public class MetalDragonCombat extends CombatScript { @Override public Object[] getKeys() { return new Object[] { ""Bronze dragon"", ""Iron dragon"", ""Steel dragon"", ""Pit iron dragon"" }; } @Override public int attack(NPC npc, Entity target) { NPCCombatDefinitions defs = npc.getCombatDefinitions(); if (WorldUtil.isInRange(npc.getX(), npc.getY(), npc.getSize(), target.getX(), target.getY(), target.getSize(), 0) && Utils.random(2) == 0) { npc.setNextAnimation(new Animation(defs.getAttackEmote())); delayHit(npc, 0, target, getMeleeHit(npc, getMaxHit(npc, defs.getMaxHit(), AttackStyle.MELEE, target))); } else { int damage = 100 + Utils.getRandomInclusive(500); final Player player = target instanceof Player p ? p : null; if (player != null) { int protection = PlayerCombatKt.getAntifireLevel(target, false); if (protection == 1) damage = Utils.getRandomInclusive(50); else if (protection == 2) damage = 0; } npc.setNextAnimation(new Animation(13160)); World.sendProjectile(npc, target, 393, 28, 16, 35, 35, 16, 0); delayHit(npc, 1, target, getRegularHit(npc, damage)); } return npc.getAttackSpeed(); } }" "package com.rs.game.content.world.npcs; public class MithrilDragonCombat extends CombatScript { @Override public Object[] getKeys() { return new Object[] { ""Mithril dragon"" }; } @Override public int attack(NPC npc, Entity target) { final NPCCombatDefinitions defs = npc.getCombatDefinitions(); int damage; switch (Utils.getRandomInclusive(3)) { case 0: // Melee if (npc.withinDistance(target.getTile(), 3)) { damage = getMaxHit(npc, defs.getMaxHit(), AttackStyle.MELEE, target); npc.setNextAnimation(new Animation(defs.getAttackEmote())); delayHit(npc, 0, target, getMeleeHit(npc, damage)); } else { damage = Utils.getRandomInclusive(500); int protection = PlayerCombatKt.getAntifireLevel(target, true); if (protection == 1) damage = Utils.getRandomInclusive(50); else if (protection == 2) damage = 0; npc.setNextAnimation(new Animation(14252)); WorldProjectile p = World.sendProjectile(npc, target, 393, 28, 32, 50, 2, 16, 0); delayHit(npc, p.getTaskDelay(), target, getRegularHit(npc, damage)); } break; case 1: // Dragon breath if (npc.withinDistance(target.getTile(), 3)) { damage = Utils.getRandomInclusive(650); int protection = PlayerCombatKt.getAntifireLevel(target, true); if (protection == 1) damage = Utils.getRandomInclusive(300); else if (protection == 2) damage = 0; npc.setNextAnimation(new Animation(14252)); npc.setNextSpotAnim(new SpotAnim(2465)); delayHit(npc, 1, target, getRegularHit(npc, damage)); } else { damage = Utils.getRandomInclusive(650); int protection = PlayerCombatKt.getAntifireLevel(target, true); if (protection == 1) damage = Utils.getRandomInclusive(40); else if (protection == 2) damage = 0; npc.setNextAnimation(new Animation(14252)); WorldProjectile p = World.sendProjectile(npc, target, 393, 28, 32, 50, 2, 16, 0); delayHit(npc, p.getTaskDelay(), target, getRegularHit(npc, damage)); } break; case 2: // Range damage = Utils.getRandomInclusive(250); npc.setNextAnimation(new Animation(14252)); World.sendProjectile(npc, target, 2707, 28, 16, 35, 35, 16, 0); delayHit(npc, 1, target, getRangeHit(npc, damage)); break; case 3: // Ice arrows range damage = Utils.getRandomInclusive(250); npc.setNextAnimation(new Animation(14252)); WorldProjectile p = World.sendProjectile(npc, target, 2705, 28, 32, 50, 2, 16, 0); delayHit(npc, p.getTaskDelay(), target, getMagicHit(npc, damage)); break; } return npc.getAttackSpeed(); } }" "package com.rs.game.content.world.npcs; public class MysteriousShadeCombat extends CombatScript { @Override public Object[] getKeys() { return new Object[] { ""Mysterious shade"" }; } @Override public int attack(NPC npc, final Entity target) { final boolean rangeAttack = Utils.random(1) == 0; npc.setNextAnimation(new Animation(rangeAttack ? 13396 : 13398)); npc.setNextSpotAnim(new SpotAnim(rangeAttack ? 2514 : 2515)); WorldProjectile projectile = World.sendProjectile(npc, target, rangeAttack ? 2510 : 2511, 18, 18, 25, 3, 0, 0); if (rangeAttack) delayHit(npc, Utils.projectileTimeToCycles(projectile.getEndTime()) - 1, target, getRangeHit(npc, getMaxHitFromAttackStyleLevel(npc, AttackStyle.RANGE, target)), () -> target.setNextSpotAnim(new SpotAnim(2512))); else delayHit(npc, Utils.projectileTimeToCycles(projectile.getEndTime()) - 1, target, getMagicHit(npc, getMaxHitFromAttackStyleLevel(npc, AttackStyle.MAGE, target)), () -> target.setNextSpotAnim(new SpotAnim(2513))); target.setNextSpotAnim(new SpotAnim(rangeAttack ? 2512 : 2513, projectile.getEndTime(), 0)); return npc.getAttackSpeed(); } }" "package com.rs.game.content.world.npcs; public class SkeletalWyvernCombat extends CombatScript { @Override public Object[] getKeys() { return new Object[] { 3068, 3069, 3070, 3071 }; } private static boolean hasShield(Entity target) { if (!(target instanceof Player)) return true; int shieldId = ((Player) target).getEquipment().getShieldId(); return shieldId == 2890 || shieldId == 9731 || shieldId == 20436 || shieldId == 20438 || shieldId == 18691 || (shieldId >= 11283 && shieldId <= 12285); } @Override public int attack(NPC npc, Entity target) { NPCCombatDefinitions defs = npc.getCombatDefinitions(); int attackStyle = Utils.random(WorldUtil.isInRange(npc.getX(), npc.getY(), npc.getSize(), target.getX(), target.getY(), target.getSize(), 0) ? 3 : 2); switch (attackStyle) { case 0: npc.setNextAnimation(new Animation(1592)); npc.setNextSpotAnim(new SpotAnim(501)); target.setNextSpotAnim(new SpotAnim(502)); if (Utils.random(10) == 0) target.freeze(Ticks.fromSeconds(5)); delayHit(npc, 1, target, getRegularHit(npc, Utils.getRandomInclusive(hasShield(target) ? 150 : 600))); break; case 1: npc.setNextAnimation(new Animation(1593)); npc.setNextSpotAnim(new SpotAnim(499)); delayHit(npc, 1, target, getRangeHit(npc, getMaxHit(npc, defs.getMaxHit(), AttackStyle.RANGE, target))); break; case 2: npc.setNextAnimation(new Animation(1589 + Utils.random(2))); delayHit(npc, 0, target, getMeleeHit(npc, getMaxHit(npc, defs.getMaxHit(), AttackStyle.MELEE, target))); break; } return npc.getAttackSpeed(); } }" "package com.rs.game.content.world.npcs; public class SuqahCombat extends CombatScript { @Override public Object[] getKeys() { return new Object[] { ""Suqah"" }; } @Override public int attack(NPC npc, final Entity target) { NPCCombatDefinitions defs = npc.getCombatDefinitions(); boolean meleeOnly = npc.getId() == 4528 || npc.getId() == 4529 || npc.getId() == 4531 || npc.getId() == 4532; if (!meleeOnly && Utils.getRandomInclusive(3) == 0) {// barrage boolean hit = Utils.getRandomInclusive(1) == 0; delayHit(npc, 2, target, getMagicHit(npc, hit ? 100 : 0)); WorldTasks.schedule(new Task() { @Override public void run() { target.setNextSpotAnim(new SpotAnim(369)); npc.soundEffect(168, true); target.freeze(Ticks.fromSeconds(5)); } }); } else { npc.setNextAnimation(new Animation(defs.getAttackEmote())); delayHit(npc, 0, target, getMeleeHit(npc, getMaxHit(npc, defs.getMaxHit(), defs.getAttackStyle(), target))); } return npc.getAttackSpeed(); } }" "package com.rs.game.content.world.npcs; public class WaterfiendCombat extends CombatScript { @Override public Object[] getKeys() { return new Object[] { 5361 }; } @Override public int attack(NPC npc, Entity target) { final NPCCombatDefinitions defs = npc.getCombatDefinitions(); int spellType = Utils.getRandomInclusive(2); Hit hit; if (spellType > 1) hit = getMagicHit(npc, getMaxHit(npc, defs.getMaxHit(), AttackStyle.MAGE, target)); else hit = getRangeHit(npc, getMaxHit(npc, defs.getMaxHit(), AttackStyle.RANGE, target)); npc.setNextAnimation(new Animation(defs.getAttackEmote())); if (spellType == 0) { World.sendProjectile(npc, target, 11, 20, 20, 25, 30, 25, 0); delayHit(npc, 2, target, hit); } else if (spellType == 1) { World.sendProjectile(npc, target, 11, 20, 20, 25, 30, 25, 0); delayHit(npc, 2, target, hit); } else if (spellType == 2) { World.sendProjectile(npc, target, 2704, 20, 20, 25, 30, 25, 0); delayHit(npc, 2, target, hit); } else { World.sendProjectile(npc, target, 2704, 20, 20, 25, 30, 25, 0); delayHit(npc, 2, target, hit); } return npc.getAttackSpeed(); } }" "package com.rs.game.content.world.npcs; public class Wolverine extends NPC { public Wolverine(Player target, int id, Tile tile, int mapAreaNameHash, boolean canBeAttackFromOutOfArea) { super(id, tile); setCombatLevel(target.getSkills().getCombatLevel() + new Random().nextInt(100) + 100); int hitpoints = 1000 + getCombatLevel() + target.getSkills().getCombatLevel() / 2 + new Random().nextInt(10); super.getCombatDefinitions().setHitpoints(hitpoints); setHitpoints(hitpoints); setRandomWalk(true); setForceAgressive(true); setAttackedBy(target); setAtMultiArea(true); faceEntity(target); } }" "package com.rs.game.content.world.npcs; public class WolverineCombat extends CombatScript { @Override public Object[] getKeys() { return new Object[] { 14899 }; } @Override public int attack(final NPC npc, final Entity target) { final Player player = (Player) target; npc.setNextAnimation(new Animation(10961)); int damage = player.getSkills().getCombatLevel() / 3 + new Random().nextInt(20) + 40; int dclaw1 = damage / 2; int dclaw2 = damage / 3; int dclaw3 = damage / 3; delayHit(npc, 2, target, getMeleeHit(npc, damage)); delayHit(npc, 2, target, getMeleeHit(npc, dclaw1)); delayHit(npc, 2, target, getMeleeHit(npc, dclaw2 / 10)); delayHit(npc, 2, target, getMeleeHit(npc, dclaw3 / 10)); return npc.getAttackSpeed(); } }" "package com.rs.game.content.world.npcs.max; @PluginEventHandler public class Max extends NPC { public static final int NORM = 3373, PESTLE = 3374, FLETCH = 3380, SMITH = 3399, ADZE = 3705; private static int RANK_DISPLAY = 0; private Task task; private int sleepTicks; private int right = -1, left = -1; private final int rank; private String displayName; private int cbLevel; public Max(int id, Tile tile) { super(id, tile); setRun(true); setIgnoreNPCClipping(true); transformIntoNPC(PESTLE); nextTask(); rank = RANK_DISPLAY; RANK_DISPLAY++; updateName(); setLoadsUpdateZones(); } public void setTask(Task task) { this.task = task; } @Override public void processNPC() { super.processNPC(); if (task != null && sleepTicks-- <= 0) sleepTicks = task.tick(this); if (displayName != null) setPermName(displayName); if (cbLevel > 0) setCombatLevel(cbLevel); if (getTickCounter() % 300 == 0) updateName(); } public String getRankColor() { return switch(rank) { case 0 -> """"; case 1 -> """"; case 2 -> """"; default -> """"; }; } private void updateName() { try { WorldDB.getHighscores().getPlayerAtPosition(rank, hs -> { try { displayName = getRankColor() + hs.getDisplayName() + "" (total: "" + hs.getTotalLevel() + "")""; cbLevel = getCombatLevel( Skills.getLevelForXp(Skills.ATTACK, hs.getXp()[Skills.ATTACK]), Skills.getLevelForXp(Skills.STRENGTH, hs.getXp()[Skills.STRENGTH]), Skills.getLevelForXp(Skills.DEFENSE, hs.getXp()[Skills.DEFENSE]), Skills.getLevelForXp(Skills.RANGE, hs.getXp()[Skills.RANGE]), Skills.getLevelForXp(Skills.MAGIC, hs.getXp()[Skills.MAGIC]), Skills.getLevelForXp(Skills.HITPOINTS, hs.getXp()[Skills.HITPOINTS]), Skills.getLevelForXp(Skills.PRAYER, hs.getXp()[Skills.PRAYER]), Skills.getLevelForXp(Skills.SUMMONING, hs.getXp()[Skills.SUMMONING])); } catch(Throwable e) { Logger.warn(Max.class, ""updateName"", ""Error updating Max name for rank "" + rank + "" player.""); } }); } catch(Throwable e) { Logger.warn(Max.class, ""updateName"", ""Error updating Max name for rank "" + rank + "" player.""); } } public static int getCombatLevel(int atk, int str, int def, int range, int magic, int hp, int pray, int summ) { int meleeBased = atk + str; int rangeBased = (int) (range * 1.5); int magicBased = (int) (magic * 1.5); int realBase = meleeBased; if (rangeBased > realBase) realBase = rangeBased; if (magicBased > realBase) realBase = magicBased; realBase *= 1.3; realBase = ((realBase + def + hp + (pray / 2)) + (summ / 2)) / 4; return realBase; } public void wearItems(int weapon, int shield) { this.right = weapon; this.left = shield; setBodyMeshModifier(new NPCBodyMeshModifier(getDefinitions()) //head body legs boots gloves .addModels(65291, 62746, 62743, 53327, 2301, weapon == -1 ? -1 : ItemDefinitions.getDefs(weapon).maleEquip1, 65300, shield == -1 ? -1 : ItemDefinitions.getDefs(shield).maleEquip1, 252)); } public String getCurrName() { return getCustomName() == null ? ""Max"" : getCustomName().substring(getCustomName().indexOf(""0>"")+2, getCustomName().indexOf("" wearItems(prevRight, prevLeft)); } public void nextTask() { getActionManager().forceStop(); task = getNextPossibleTasks().getFirst(); } private List getNextPossibleTasks() { List nextTasks = new ArrayList<>(); nextTasks.add(new MaxTaskWC()); nextTasks.add(new MaxTaskFarm()); nextTasks.add(new MaxTaskFM()); nextTasks.add(new MaxTaskAlch()); nextTasks.add(new MaxTaskSmith()); nextTasks.add(new MaxTaskCook()); Collections.shuffle(nextTasks); if (task == null) return nextTasks; return nextTasks.stream().filter(pred -> !pred.getClass().isAssignableFrom(task.getClass())).toList(); } public static NPCClickHandler clickClose = new NPCClickHandler(new Object[] { NORM, PESTLE, FLETCH, SMITH, ADZE }, new String[] { ""Talk-to"", ""Trade"" }, e -> { if (!(e.getNPC() instanceof Max max)) return; switch(e.getOption()) { case ""Talk-to"" -> e.getPlayer().startConversation(new MaxD(e.getPlayer(), max)); case ""Trade"" -> e.getPlayer().sendMessage(""Sending trade request...""); } }); public static NPCClickHandler clickDistance = new NPCClickHandler(false, new Object[] { NORM, PESTLE, FLETCH, SMITH, ADZE }, new String[] { ""Follow"" }, e -> e.getPlayer().getActionManager().setAction(new EntityFollow(e.getNPC()))); public static NPCInstanceHandler toFunc = new NPCInstanceHandler(new Object[] { NORM, PESTLE, FLETCH, SMITH, ADZE }, Max::new); }" "package com.rs.game.content.world.npcs.max; public class MaxD extends Conversation { public MaxD(Player player, Max max) { super(player); if (max.hasWalkSteps()) { addNPC(max, HeadE.CHEERFUL, ""Can't stop right now! Catch me up at my next stop?""); player.getTempAttribs().setB(""talkedMaxWalking"", true); create(); return; } if (player.getTempAttribs().getB(""talkedMaxWalking"")) { addNPC(max, HeadE.CHEERFUL, ""Sorry about that. XP waste if I stopped back there, eh?""); player.getTempAttribs().removeB(""talkedMaxWalking""); } addNPC(max, HeadE.CHEERFUL, ""How can I help you?""); addOptions(""startOps"", ""What would you like to say?"", ops -> { ops.add(""Who are you?"", new Dialogue() .addPlayer(HeadE.CONFUSED, ""Who are you?"") .addNPC(max, HeadE.CHEERFUL_EXPOSITION, ""Oh, sorry - I'm ""+max.getCurrName()+"". Some say I'm a bit obsessed with skilling."") .addPlayer(HeadE.CHEERFUL, ""And I'm "" + player.getDisplayName() + "", nice to meet you."") .addNPC(max, HeadE.CONFUSED, ""Indeed, so can I help you with anything?"") .addGotoStage(""startOps"", this)); ops.add(""Nice cape you have there..."", new Conversation(player) { { addPlayer(HeadE.AMAZED_MILD, ""Nice cape you have there...""); addNPC(max, HeadE.CHEERFUL_EXPOSITION, ""This? Thanks! It's a symbol that I've trained all my skills to level 99.""); if (player.getSkills().isMaxed(false)) { addPlayer(HeadE.CHEERFUL_EXPOSITION, ""I've maxed all my skills!""); addNPC(max, HeadE.AMAZED_MILD, ""Indeed so. Would you like to show that fact off? 2,673,000 coins - 99,000 for each skill!""); addOptions(ops -> { ops.add(""I'll take one!"", () -> { int value = 2475000; if (player.getInventory().getFreeSlots() < 2) { player.npcDialogue(max, HeadE.SHAKING_HEAD, ""You don't have enough inventory space for that.""); } else { if (player.getInventory().hasCoins(value)) { player.getInventory().removeCoins(value); player.getInventory().addItemDrop(20768, 1); player.getInventory().addItemDrop(20767, 1); player.npcDialogue(max, HeadE.SHAKING_HEAD, ""Thanks. Enjoy!""); if (player.getSkills().isMaxed(false) && !player.isMaxed) { player.isMaxed = true; World.sendWorldMessage(""News: "" + player.getDisplayName() + "" has just been awarded the Max cape!"" + "" "", false); } } else player.npcDialogue(max, HeadE.SHAKING_HEAD, ""You don't have enough money for that!""); } }); ops.add(""No, thanks."", new Dialogue().addPlayer(HeadE.CALM_TALK, ""No, thanks."")); }); } else { addPlayer(HeadE.AMAZED_MILD, ""Wow, that's quite impressive.""); addNPC(max, HeadE.CHEERFUL_EXPOSITION, ""Thanks. I have faith in you "" + player.getDisplayName() + "" - one day you'll be here and I'll sell you one myself.""); addPlayer(HeadE.SKEPTICAL, ""We'll see about that, thanks.""); addNPC(max, HeadE.CHEERFUL, ""Farewell and good luck.""); } } }.getStart()); ops.add(""Nothing, thanks."", new Dialogue() .addPlayer(HeadE.CHEERFUL, ""Nothing, thanks."") .addNPC(max, HeadE.CHEERFUL, ""Farewell, and good luck with your skills."")); }); } }" "package com.rs.game.content.world.npcs.max.tasks; public class MaxTaskAlch implements Task { private enum AlchLocation { EDGE(Tile.of(3087, 3494, 0), Tile.of(3093, 3497, 0)), SEERS(Tile.of(2757, 3479, 0), Tile.of(2725, 3491, 0)), VARROCK(Tile.of(3212, 3423, 0), Tile.of(3185, 3436, 0)), ; private final Tile tele; private final Tile alchSpot; AlchLocation(Tile tele, Tile alchSpot) { this.tele = tele; this.alchSpot = alchSpot; } } private boolean started = false; private boolean atLocation = false; private int itemsAlched = Utils.random(85, 150); private final AlchLocation loc = AlchLocation.values()[Utils.random(AlchLocation.values().length)]; @Override public int tick(Max max) { if (!started) { max.wearItems(6563, 18747); started = true; } if (!max.withinDistance(loc.alchSpot, 64)) { Magic.npcNormalTeleport(max, loc.tele, true, null); return 10; } if (itemsAlched <= 0) { max.nextTask(); return 10; } if (!atLocation && !max.getActionManager().hasSkillWorking() && !max.hasWalkSteps()) { max.setRouteEvent(new RouteEvent(Tile.of(loc.alchSpot, 2), () -> { atLocation = true; max.repeatAction(5, count -> { if (itemsAlched <= 0) { max.nextTask(); return false; } max.anim(9633); max.spotAnim(1693); itemsAlched--; return true; }); })); } return 5; } }" "package com.rs.game.content.world.npcs.max.tasks; public class MaxTaskCook implements Task { private static final GameObject RANGE = new GameObject(114, ObjectType.SCENERY_INTERACT, 2, Tile.of(3212, 3215, 0)); private boolean started = false; private int itemsCooked = Utils.random(85, 150); @Override public int tick(Max max) { if (!started) { max.wearItems(-1, -1); started = true; } if (!max.withinDistance(RANGE.getTile(), 64)) { Magic.npcNormalTeleport(max, Tile.of(3235, 3219, 0), true, null); return 10; } if (itemsCooked <= 0) { max.nextTask(); return 10; } if (!max.getActionManager().hasSkillWorking() && !max.hasWalkSteps()) { max.setRouteEvent(new RouteEvent(RANGE, () -> max.repeatAction(3, count -> { if (itemsCooked <= 0) { max.nextTask(); return false; } max.faceObject(RANGE); max.anim(897); itemsCooked--; return true; }))); } return 5; } }" "package com.rs.game.content.world.npcs.max.tasks; public class MaxTaskFarm implements Task { private boolean started = false; private GameObject patch; private boolean reached; @Override public int tick(Max max) { patch = World.getObject(Tile.of(3228, 3458, 0), ObjectType.SCENERY_INTERACT); if (patch == null) return 0; if (!started) { max.wearItems(5341, 19749); started = true; } if (!max.withinDistance(patch.getTile(), 80)) { Magic.npcNormalTeleport(max, Tile.of(3213, 3423, 0), true, null); return 10; } if (!reached) { if (!max.hasWalkSteps()) max.setRouteEvent(new RouteEvent(patch, () -> reached = true)); return 10; } if (max.getActionManager().hasSkillWorking()) return 3; max.repeatAction(5, rakeCount -> { max.faceObject(patch); if (rakeCount > 5) { max.repeatAction(10, compostCount -> { if (compostCount >= 2) { max.nextTask(); return true; } max.itemAnim(FarmPatch.COMPOST_ANIMATION, 5); return true; }); return true; } max.itemAnim(FarmPatch.RAKING_ANIMATION, 5); return true; }); return 2; } }" "package com.rs.game.content.world.npcs.max.tasks; public class MaxTaskFM implements Task { private boolean started = false; private GameObject currentBonfire; private int logsBurned = Utils.random(85, 150); @Override public int tick(Max max) { if (!started) { max.wearItems(590, 23027); started = true; } if (!max.withinDistance(Tile.of(3087, 3494, 0), 64)) { Magic.npcItemTeleport(max, Tile.of(3087, 3494, 0), true, null); return 10; } if (logsBurned <= 0) { max.setBas(-1); max.nextTask(); return 10; } currentBonfire = World.getClosestObject(ObjectType.SCENERY_INTERACT, Fire.MAGIC.getFireId(), max.getTile()); if (currentBonfire == null) { max.getActionManager().setAction(new Firemaking(Fire.MAGIC)); return 20; } if (!max.getActionManager().hasSkillWorking() && !max.hasWalkSteps()) { max.setRouteEvent(new RouteEvent(currentBonfire, () -> { max.setBas(2498); max.repeatAction(5, count -> { if (World.getObjectWithType(currentBonfire.getTile(), currentBonfire.getType()) != currentBonfire) { max.anim(-1); max.setBas(-1); currentBonfire = null; return false; } max.faceObject(currentBonfire); max.anim(16703); max.spotAnim(3135); logsBurned--; return true; }); })); } return 5; } }" "package com.rs.game.content.world.npcs.max.tasks; public class MaxTaskSmith implements Task { private static final GameObject WEST = new GameObject(2783, ObjectType.SCENERY_INTERACT, 0, Tile.of(3188, 3426, 0)); private static final GameObject EAST = new GameObject(2783, ObjectType.SCENERY_INTERACT, 0, Tile.of(3228, 3436, 0)); private boolean started = false; private int itemsSmithed = Utils.random(85, 150); @Override public int tick(Max max) { if (!started) { max.wearItems(2347, 22422); started = true; } if (!max.withinDistance(WEST.getTile(), 64)) { Magic.npcNormalTeleport(max, Tile.of(3212, 3423, 0), true, null); return 10; } if (itemsSmithed <= 0) { max.nextTask(); return 10; } if (!max.getActionManager().hasSkillWorking() && !max.hasWalkSteps()) { GameObject anvil = Utils.random(2) == 0 ? WEST : EAST; max.setRouteEvent(new RouteEvent(anvil, () -> max.repeatAction(3, count -> { if (itemsSmithed <= 0) { max.nextTask(); return false; } max.faceObject(anvil); max.anim(898); itemsSmithed--; return true; }))); } return 5; } }" "package com.rs.game.content.world.npcs.max.tasks; public class MaxTaskWC implements Task { private boolean started = false; private GameObject currentIvy; private int ivysCut = Utils.random(3, 5); @Override public int tick(Max max) { if (!started) { max.wearItems(6739, -1); started = true; } if (max.getTile().getRegionId() != 12854) { if (max.getTile().getRegionId() != 12853) Magic.npcNormalTeleport(max, Tile.of(3213, 3423, 0), true, null); else { if (!max.hasWalkSteps()) max.setRouteEvent(new RouteEvent(Tile.of(3232, 3459, 0), () -> { })); } return 10; } if (ivysCut <= 0) { max.nextTask(); return 10; } currentIvy = getClosestIvy(max.getTile()); if (currentIvy == null || !currentIvy.getDefinitions().containsOption(""Chop"")) return 0; if (!max.getActionManager().hasSkillWorking() && !max.hasWalkSteps()) { max.setRouteEvent(new RouteEvent(currentIvy, () -> max.getActionManager().setAction(new Woodcutting(currentIvy, TreeType.IVY) { @Override public void fellTree() { super.fellTree(); ivysCut--; } }.setHatchet(Hatchet.DRAGON).setLevel(110)))); return 10; } return 0; } public GameObject getClosestIvy(Tile tile) { GameObject ivy = null; double closest = Double.MAX_VALUE; for (GameObject obj : World.getAllObjectsInChunkRange(tile.getChunkId(), 2)) { if (obj == null || obj.getDefinitions() == null || !obj.getDefinitions().getName().equals(""Ivy"") || !obj.getDefinitions().containsOption(""Chop"")) continue; double dist = Utils.getDistance(obj.getTile(), tile); if (dist < closest) { ivy = obj; closest = dist; } } return ivy; } }" "package com.rs.game.content.world.npcs.max.tasks; public interface Task { int tick(Max max); }" "package com.rs.game.content.world.unorganized_dialogue; public class DestroyItem extends Conversation { public DestroyItem(Player player, int slotId, Item item) { this(player, slotId, item, null); } public DestroyItem(Player player, int slotId, Item item, String message) { super(player); addNext(new DestroyItemStatement(item, message)); addNext(() -> { PluginManager.handle(new DestroyItemEvent(player, item)); player.getInventory().deleteItem(slotId, item); if (item.getDefinitions().isBinded()) player.getDungManager().unbind(item); player.soundEffect(4500, false); }); create(); } }" "package com.rs.game.content.world.unorganized_dialogue; @PluginEventHandler public class FlamingSkull extends Conversation { private static final String[] COLORS = { ""Green"", ""Purple"", ""Blue"", ""Red"" }; public static ItemClickHandler handleSwitchColor = new ItemClickHandler(new Object[] { 24437, 24439, 24440, 24441 }, new String[] { ""Change-colour"", ""Change colour"" }, e -> e.getPlayer().startConversation(new FlamingSkull(e.getPlayer(), e.getItem(), e.isEquipped()))); public FlamingSkull(Player player, Item item, boolean worn) { super(player); int index = (item.getId() == 24437 ? 24442 : item.getId()) - 24439; addOptions(""What color do you want your skull to be?"", ops -> { ops.add(COLORS[(index + 1) % 4], () -> { int itemId = 24439 + ((index + 1) % 4); item.setId(itemId == 24442 ? 24437 : itemId); if (worn) { player.getEquipment().refresh(Equipment.HEAD); player.getAppearance().generateAppearanceData(); } else player.getInventory().refresh(item.getSlot()); }); ops.add(COLORS[(index + 2) % 4], () -> { int itemId = 24439 + ((index + 2) % 4); item.setId(itemId == 24442 ? 24437 : itemId); if (worn) { player.getEquipment().refresh(Equipment.HEAD); player.getAppearance().generateAppearanceData(); } else player.getInventory().refresh(item.getSlot()); }); ops.add(COLORS[(index + 3) % 4], () -> { int itemId = 24439 + ((index + 3) % 4); item.setId(itemId == 24442 ? 24437 : itemId); if (worn) { player.getEquipment().refresh(Equipment.HEAD); player.getAppearance().generateAppearanceData(); } else player.getInventory().refresh(item.getSlot()); }); }); } }" "package com.rs.game.content.world.unorganized_dialogue; public class FlowerPickup extends Conversation { public FlowerPickup(Player player, GameObject flowerObject, int flowerId) { super(player); addOptions(""What do you want to do with the flowers?"", ops -> { ops.add(""Pick"", () -> { player.setNextAnimation(new Animation(827)); player.getInventory().addItem(getFlowerId(flowerId), 1); player.getInventory().refresh(); World.removeObject(flowerObject); }); ops.add(""Leave them""); }); } public int getFlowerId(int objectId) { return 2460 + ((objectId - 2980) * 2); } }" "package com.rs.game.content.world.unorganized_dialogue; public class LeatherCraftingD extends Conversation { public static final int DUNG_NEEDLE = 17446; public static final int[] BASE_LEATHER = { 1741, 1743, 1745, 2505, 2507, 2509, 24374, 22451, 22449, 22450, 6289, 10820 }; public static final double[][] EXPERIENCE = { { 13.8, 16.25, 18.5, 22, 25, 27, 37 }, { 35 }, { 62, 124, 186 }, { 70, 140, 210 }, { 78, 156, 234 }, { 86, 172, 258 }, { 94, 188, 282 }, { 100, 300, 1000 }, { 10, 20, 30 }, { 50, 150, 500 }, { 30, 35, 45, 50, 55 }, { 32, 32 } }; private final int[][] LEVELS = { { 1, 7, 9, 11, 14, 18, 38 }, { 28 }, { 57, 60, 63 }, { 66, 68, 71 }, { 73, 75, 77 }, { 79, 82, 84 }, { 87, 89, 93 }, { 86, 92, 98 }, { 3, 12, 21 }, { 65, 72, 78 }, { 45, 47, 48, 51, 53 }, { 43, 46 } }; private static final Item[][] POTENTIAL_PRODUCTS = { { new Item(1059, 1), new Item(1061, 1), new Item(1167, 1), new Item(1063, 1), new Item(1129, 1), new Item(1095, 1), new Item(1169, 1) }, { new Item(1131, 1) }, { new Item(1065, 1), new Item(1099, 2), new Item(1135, 3) }, { new Item(2487, 1), new Item(2493, 2), new Item(2499, 3) }, { new Item(2489, 1), new Item(2495, 2), new Item(2501, 3) }, { new Item(2491, 1), new Item(2497, 2), new Item(2503, 3) }, { new Item(24376, 1), new Item(24379, 2), new Item(24382, 3) }, { new Item(22482, 500), new Item(22486, 1500), new Item(22490, 5000) }, { new Item(22458, 300), new Item(22462, 1000), new Item(22466, 2500) }, { new Item(22470, 400), new Item(22474, 1200), new Item(22478, 3500) }, { new Item(6328, 6), new Item(6330, 8), new Item(6326, 5), new Item(6324, 12), new Item(6322, 15) }, { new Item(10824, 1), new Item(10822, 2) } }; private static final Item[][] REQUIRED_BASE_ITEMS = { null, null, null, null, null, null, null, new Item[] { new Item(22452, 1), new Item(22454, 1), new Item(22456, 1) }, new Item[] { new Item(22452, 1), new Item(22454, 1), new Item(22456, 1) }, new Item[] { new Item(22452, 1), new Item(22454, 1), new Item(22456, 1) }, null, null }; public LeatherCraftingD(Player player, int index) { super(player); int[] ids = new int[POTENTIAL_PRODUCTS[index].length]; String[] names = new String[POTENTIAL_PRODUCTS[index].length]; for (int i = 0; i < ids.length; i++) { ids[i] = POTENTIAL_PRODUCTS[index][i].getId(); if (player.getSkills().getLevel(Constants.CRAFTING) < LEVELS[index][i]) names[i] = """" + ItemDefinitions.getDefs(ids[i]).name + ""
Level "" + LEVELS[index][i]; else names[i] = ItemDefinitions.getDefs(ids[i]).name; } Dialogue makeX = addNext(new MakeXStatement(MakeXType.MAKE, 28, ""Choose how many you wish to make,
then click on the item to begin."", ids, names)); for (int i = 0; i < ids.length; i++) { final int componentIndex = i; makeX.addNext(() -> player.getActionManager().setAction(new PlayerAction() { int ticks; @Override public boolean start(final Player player) { if (!checkAll(player)) return false; int leatherAmount = player.getInventory().getAmountOf(BASE_LEATHER[index]); int requestedAmount = MakeXStatement.getQuantity(player); if (requestedAmount > leatherAmount) requestedAmount = leatherAmount; setTicks(requestedAmount); return true; } public void setTicks(int ticks) { this.ticks = ticks; player.getInventory().deleteItem(1734, 1); } public boolean checkAll(Player player) { final int levelReq = LEVELS[index][componentIndex]; if (player.getSkills().getLevel(Constants.CRAFTING) < levelReq) { player.sendMessage(""You need a Crafting level of "" + levelReq + "" to craft this hide.""); return false; } if (player.getInventory().getItems().getNumberOf(BASE_LEATHER[index]) < POTENTIAL_PRODUCTS[index][componentIndex].getAmount()) { player.sendMessage(""You don't have enough hides in your inventory.""); return false; } if (!player.getInventory().containsOneItem(1734)) { player.sendMessage(""You need a thread in order to bind the tanned hides together.""); return false; } if (!player.getInventory().containsItem(1733, 1)) { player.sendMessage(""You need a needle in order to bind the tanned hides together.""); return false; } Item[] extraItems = REQUIRED_BASE_ITEMS[index]; if (extraItems != null) { Item item = extraItems[componentIndex]; if (!player.getInventory().containsItem(item.getId(), item.getAmount())) { player.sendMessage(""You need a "" + item.getName().toLowerCase() + "".""); return false; } } return true; } @Override public boolean process(Player player) { return checkAll(player) && ticks > 0; } @Override public int processWithDelay(Player player) { ticks--; if (ticks % 4 == 0) player.getInventory().deleteItem(1734, 1); Item item = POTENTIAL_PRODUCTS[index][componentIndex]; player.getInventory().deleteItem(new Item(BASE_LEATHER[index], item.getAmount())); player.getInventory().addItem(item.getId(), 1); player.getSkills().addXp(Constants.CRAFTING, EXPERIENCE[index][componentIndex]); Item[] extraItems = REQUIRED_BASE_ITEMS[index]; if (extraItems != null) player.getInventory().deleteItem(extraItems[componentIndex]); player.setNextAnimation(new Animation(1249)); return 3; } @Override public void stop(Player player) { setActionDelay(player, 3); } })); } create(); } public static int getIndex(int requestedId) { for (int index = 0; index < BASE_LEATHER.length; index++) { int baseId = BASE_LEATHER[index]; if (requestedId == baseId) return index; } return -1; } public static boolean isExtraItem(int requestedId) { for (Item[] items : REQUIRED_BASE_ITEMS) { if (items == null) continue; for (Item item : items) if (item.getId() == requestedId) return true; } return false; } }" "package com.rs.game.content.world.unorganized_dialogue; @PluginEventHandler public class RepairStandD extends Conversation { public RepairStandD(Player player, ItemConstants.ItemDegrade details, Item item, final boolean stand, final int slot) { super(player); player.getInterfaceManager().sendChatBoxInterface(1183); player.getPackets().setIFText(1183, 12, ""It will cost "" + (stand ? details.getRepairStandCost(player) : details.getCost(item)) + "" to repair your "" + item.getDefinitions().getName() + "".""); player.getPackets().setIFItem(1183, 13, details.getItemId(), 1); player.getPackets().setIFText(1183, 7, ""Repair this item fully for "" + (stand ? details.getRepairStandCost(player) : details.getCost(item)) + "" coins?""); player.getPackets().setIFText(1183, 22, ""Confirm repair""); player.save(""repairDetails"", details); player.save(""repairItem"", item); player.save(""repairStand"", stand); player.save(""repairSlot"", slot); } public static ButtonClickHandler handleRepair = new ButtonClickHandler(1183, e -> { ItemConstants.ItemDegrade details = e.getPlayer().getO(""repairDetails""); Item item = e.getPlayer().getO(""repairItem""); boolean stand = e.getPlayer().getO(""repairStand""); int slot = e.getPlayer().getO(""repairSlot""); if (e.getComponentId() == 9) { if (e.getPlayer().getInventory().hasCoins(stand ? details.getRepairStandCost(e.getPlayer()) : details.getCost(item))) { if (e.getPlayer().getInventory().getItem(slot) == null || e.getPlayer().getInventory().getItem(slot).getId() != item.getId()) return; e.getPlayer().getInventory().getItems().set(slot, new Item(details.getItemId(), 1)); e.getPlayer().getInventory().removeCoins(stand ? details.getRepairStandCost(e.getPlayer()) : details.getCost(item)); e.getPlayer().getInventory().refresh(); } else e.getPlayer().sendMessage(""You don't have enough coins.""); } e.getPlayer().closeInterfaces(); }); }" "package com.rs.game.content.world.unorganized_dialogue; public class ShotputD extends Conversation { public ShotputD(Player player, boolean is18LB) { super(player); WarriorsGuild controller = player.getControllerManager().getController(WarriorsGuild.class); if (controller == null) return; player.setNextAnimation(new Animation(827)); addOptions(ops -> { ops.add(""Standing Throw."", () -> { controller.prepareShotput((byte) 0, is18LB); player.setNextAnimation(new Animation(15079)); }); ops.add(""Step and throw."", () -> { controller.prepareShotput((byte) 1, is18LB); player.setNextAnimation(new Animation(15080)); }); ops.add(""Spin and throw."", () -> { controller.prepareShotput((byte) 2, is18LB); player.setNextAnimation(new Animation(15078)); }); }); } }" "package com.rs.game.content.world.unorganized_dialogue; public class StageSelectDialogue extends Dialogue { private String stageName; private Map markedStages; private Dialogue directNextReference; public StageSelectDialogue(String stageName, Map markedStages) { this.stageName = stageName; this.markedStages = markedStages; } public StageSelectDialogue(Dialogue directNextReference) { this.directNextReference = directNextReference; } public String getStageName() { return stageName; } public Map getStages() { return markedStages; } public Dialogue getDirectNextReference() { return directNextReference; } }" "package com.rs.game.content.world.unorganized_dialogue; public class StrongholdRewardD extends Conversation { // TODO: Remove Stronghold of security out of ObjectHandler.java so this can be inlined/refactored public StrongholdRewardD(Player player, int reward) { super(player); switch (reward) { case 0 -> { addSimple(""The box hinges and crack and appear to be forming audible words....""); addSimple(""...congratulations adventurer, you have been deemed worthy of this reward. You have also unlocked the Flap emote!"", () -> { player.getInventory().addCoins(2000); player.getEmotesManager().unlockEmote(Emote.FLAP); }); } case 1 -> { addSimple(""The grain shifts in the sack, sighing audible words....""); addSimple(""...congratulations adventurer, you have been deemed worthy of this reward. You have also unlocked the Slap Head emote!"", () -> { player.getInventory().addCoins(3000); player.getEmotesManager().unlockEmote(Emote.SLAP_HEAD); }); } case 2 -> { addSimple(""The box hinges creak and appear to be forming audible words....""); addSimple(""...congratulations adventurer, you have been deemed worthy of this reward. You have also unlocked the Idea emote!"", () -> { player.getInventory().addCoins(5000); player.getEmotesManager().unlockEmote(Emote.IDEA); player.sendMessage(""You feel refreshed.""); player.reset(); }); } case 3 -> { addSimple(""As your hand touches the cradle, you hear the voices of a million dead adventurers...""); if (!player.containsOneItem(9005, 9006)) { addSimple(""Welcome adventurer... you appear to have a choice...""); addSimple(""You can choose between these two pairs of boots. They will both protect your feet in exactly same manner; however, they look very different. You can always come back and get another pair if you lose them, or even swap them for the other style!""); Dialogue op = addOption(""Choose your style of boots"", ""I'll take the colourful ones."", ""I'll take the fighting ones.""); if (player.getEmotesManager().unlockedEmote(Emote.STOMP)) { op.addPlayer(HeadE.CHEERFUL, ""I'll take the colourful ones."") .addSimple(""Enjoy your new boots."", () -> player.getInventory().addItem(9005, 1)); op.addPlayer(HeadE.CHEERFUL, ""I'll take the fighting ones."") .addSimple(""Enjoy your new boots."", () -> player.getInventory().addItem(9006, 1)); } else { op.addPlayer(HeadE.CHEERFUL, ""I'll take the colourful ones."") .addSimple(""Congratulations! You have succefully nagivated the Stronghold of secuity and learned to secure your account. You have unlocked the 'Stamp Foot'emote. Remember to keep your account secured in the future!"", () -> { player.getInventory().addItem(9005, 1); player.getEmotesManager().unlockEmote(Emote.STOMP); }); op.addPlayer(HeadE.CHEERFUL, ""I'll take the fighting ones."") .addSimple(""Congratulations! You have succefully nagivated the Stronghold of secuity and learned to secure your account. You have unlocked the 'Stamp Foot'emote. Remember to keep your account secured in the future!"", () -> { player.getInventory().addItem(9006, 1); player.getEmotesManager().unlockEmote(Emote.STOMP); }); } } else addSimple(""You already have your boots. Return if you lose them.""); } } create(); } }" "package com.rs.game.content.world.unorganized_dialogue; public class TanningD extends Conversation { private enum Leather { SOFT(1739, 1741, 0, 2), HARD(1739, 1743, 3, 5), SNAKE(6287, 6289, 15, 25), GREEN(1753, 1745, 20, 45), BLUE(1751, 2505, 20, 45), RED(1749, 2507, 20, 45), BLACK(1747, 2509, 20, 45), ROYAL(24372, 24374, 20, 45); private final int kharidPrice; private final int canifisPrice; private final int raw; private final int tanned; private Leather(int raw, int tanned, int kharidPrice, int canifisPrice) { this.raw = raw; this.tanned = tanned; this.kharidPrice = kharidPrice; this.canifisPrice = canifisPrice; } } public TanningD(Player player, boolean canifis, int NPC) { super(player); List craftable = new ArrayList<>(); for (Leather leather : Leather.values()) if (player.getInventory().containsItem(leather.raw)) craftable.add(leather); if (craftable.isEmpty()) { addNPC(NPC, HeadE.CHEERFUL, ""You don't have any leather that I can tan. Bring me some raw leather and then I can be more help to you.""); create(); return; } Dialogue makeX = addNext(new MakeXStatement(MakeXType.MAKE, ""How many hides would you like to tan?
Choose a number, then click the hide to begin."", craftable.stream().mapToInt(leather -> leather.tanned).toArray(), 28)); for (Leather leather : craftable) { makeX.addNext(() -> { int amount = MakeXStatement.getQuantity(player); int pricePer = canifis ? leather.canifisPrice : leather.kharidPrice; if (amount > player.getInventory().getAmountOf(leather.raw)) amount = player.getInventory().getAmountOf(leather.raw); for (int i = 0;i < amount;i++) { if (!player.getInventory().hasCoins(pricePer)) { player.sendMessage(""You have run out of gold.""); break; } if (!player.getInventory().containsItem(leather.raw)) { player.sendMessage(""You have run out of raw leather.""); break; } player.getInventory().removeCoins(pricePer); player.getInventory().deleteItem(leather.raw, 1); player.getInventory().addItem(leather.tanned); } }); } create(); } }" "package com.rs.game.content.world.unorganized_dialogue.skillmasters; public class GenericSkillcapeOwnerD extends Conversation { public GenericSkillcapeOwnerD(Player player, int npcId, Skillcapes cape) { super(player); addOption(""Choose an option"", ""What is that cape you're wearing?"", ""Bye."") .addNext(cape.getOffer99CapeDialogue(player, npcId)); create(); } }" "package com.rs.game.ge; @PluginEventHandler public class GE { private static final int OFFER_SELECTION = 105; private static final int SPECIAL_DEPOSIT_INV = 107; private static final int COLLECTION_BOX = 109; private static final int VAR_ITEM = 1109; private static final int VAR_ITEM_AMOUNT = 1110; private static final int VAR_FOR_PRICE_TEXT = 1111; private static final int VAR_CURR_BOX = 1112; private static final int VAR_IS_SELLING = 1113; private static final int VAR_MEDIAN_PRICE = 1114; public enum GrandExchangeType { BUYING, SELLING, ABORTED } public enum OfferType { BUY, SELL } public static ButtonClickHandler mainInterface = new ButtonClickHandler(105, e -> { if (e.getPlayer().isIronMan()) { e.getPlayer().sendMessage(""Ironmen stand alone.""); return; } if (e.getPlayer().getTempAttribs().getB(""geLocked"")) return; switch(e.getComponentId()) { //Buy box selection case 31 -> openBuy(e.getPlayer(), 0); case 47 -> openBuy(e.getPlayer(), 1); case 63 -> openBuy(e.getPlayer(), 2); case 82 -> openBuy(e.getPlayer(), 3); case 101 -> openBuy(e.getPlayer(), 4); case 120 -> openBuy(e.getPlayer(), 5); //Sell box selection case 32 -> openSell(e.getPlayer(), 0); case 48 -> openSell(e.getPlayer(), 1); case 64 -> openSell(e.getPlayer(), 2); case 83 -> openSell(e.getPlayer(), 3); case 102 -> openSell(e.getPlayer(), 4); case 121 -> openSell(e.getPlayer(), 5); case 19 -> clickBox(e.getPlayer(), 0, e.getPacket() != ClientPacket.IF_OP1); case 35 -> clickBox(e.getPlayer(), 1, e.getPacket() != ClientPacket.IF_OP1); case 51 -> clickBox(e.getPlayer(), 2, e.getPacket() != ClientPacket.IF_OP1); case 70 -> clickBox(e.getPlayer(), 3, e.getPacket() != ClientPacket.IF_OP1); case 89 -> clickBox(e.getPlayer(), 4, e.getPacket() != ClientPacket.IF_OP1); case 108 -> clickBox(e.getPlayer(), 5, e.getPacket() != ClientPacket.IF_OP1); case 200 -> clickBox(e.getPlayer(), e.getPlayer().getVars().getVar(VAR_CURR_BOX), true); //Back button case 128 -> open(e.getPlayer()); case 206, 208 -> collectItems(e.getPlayer(), e.getPlayer().getVars().getVar(VAR_CURR_BOX), e.getComponentId() == 206 ? 0 : 1, e.getPacket() == ClientPacket.IF_OP1); //Amount adjustments case 155 -> e.getPlayer().getVars().setVar(VAR_ITEM_AMOUNT, Utils.clampI(e.getPlayer().getVars().getVar(VAR_ITEM_AMOUNT) - 1, 0, Integer.MAX_VALUE)); case 157 -> e.getPlayer().getVars().setVar(VAR_ITEM_AMOUNT, Utils.clampI(e.getPlayer().getVars().getVar(VAR_ITEM_AMOUNT) + 1, 0, Integer.MAX_VALUE)); case 160 -> e.getPlayer().getVars().setVar(VAR_ITEM_AMOUNT, e.getPlayer().getVars().getVar(VAR_IS_SELLING) == 1 ? 1 : Utils.clampI(e.getPlayer().getVars().getVar(VAR_ITEM_AMOUNT) + 1, 0, Integer.MAX_VALUE)); case 162 -> e.getPlayer().getVars().setVar(VAR_ITEM_AMOUNT, e.getPlayer().getVars().getVar(VAR_IS_SELLING) == 1 ? 10 : Utils.clampI(e.getPlayer().getVars().getVar(VAR_ITEM_AMOUNT) + 10, 0, Integer.MAX_VALUE)); case 164 -> e.getPlayer().getVars().setVar(VAR_ITEM_AMOUNT, e.getPlayer().getVars().getVar(VAR_IS_SELLING) == 1 ? 100 : Utils.clampI(e.getPlayer().getVars().getVar(VAR_ITEM_AMOUNT) + 100, 0, Integer.MAX_VALUE)); case 166 -> e.getPlayer().getVars().setVar(VAR_ITEM_AMOUNT, e.getPlayer().getVars().getVar(VAR_IS_SELLING) == 1 ? e.getPlayer().getInventory().getAmountOf(e.getPlayer().getVars().getVar(VAR_ITEM)) : Utils.clampI(e.getPlayer().getVars().getVar(VAR_ITEM_AMOUNT) + 1000, 0, Integer.MAX_VALUE)); case 168 -> e.getPlayer().sendInputInteger(""Enter amount"", amount -> e.getPlayer().getVars().setVar(VAR_ITEM_AMOUNT, Utils.clampI(amount, 0, Integer.MAX_VALUE))); //Price adjustments case 169 -> e.getPlayer().getVars().setVar(VAR_FOR_PRICE_TEXT, Utils.clampI(e.getPlayer().getVars().getVar(VAR_FOR_PRICE_TEXT) - 1, 0, Integer.MAX_VALUE)); case 171 -> e.getPlayer().getVars().setVar(VAR_FOR_PRICE_TEXT, Utils.clampI(e.getPlayer().getVars().getVar(VAR_FOR_PRICE_TEXT) + 1, 0, Integer.MAX_VALUE)); case 175 -> e.getPlayer().getVars().setVar(VAR_FOR_PRICE_TEXT, e.getPlayer().getVars().getVar(VAR_MEDIAN_PRICE)); case 179 -> e.getPlayer().getVars().setVar(VAR_FOR_PRICE_TEXT, Utils.clampI((int) (e.getPlayer().getVars().getVar(VAR_FOR_PRICE_TEXT) * 1.05), 0, Integer.MAX_VALUE)); case 181 -> e.getPlayer().getVars().setVar(VAR_FOR_PRICE_TEXT, Utils.clampI((int) (e.getPlayer().getVars().getVar(VAR_FOR_PRICE_TEXT) * 0.95), 0, Integer.MAX_VALUE)); case 177 -> e.getPlayer().sendInputInteger(""Enter desired price"", price -> e.getPlayer().getVars().setVar(VAR_FOR_PRICE_TEXT, Utils.clampI(price, 0, Integer.MAX_VALUE))); //Confirm offer case 186 -> confirmOffer(e.getPlayer()); //Search item case 190 -> e.getPlayer().getPackets().openGESearch(); default -> Logger.debug(GE.class, ""mainInterface"", ""Unhandled GE button: "" + e.getComponentId() + "", "" + e.getSlotId()); } }); public static ButtonClickHandler sellInv = new ButtonClickHandler(SPECIAL_DEPOSIT_INV, e -> { if (e.getPlayer().isIronMan()) { e.getPlayer().sendMessage(""Ironmen stand alone.""); return; } if (e.getPlayer().getTempAttribs().getB(""geLocked"")) return; if (e.getComponentId() == 18) { Item item = e.getPlayer().getInventory().getItem(e.getSlotId()); if (item == null) return; if (item.getDefinitions().isNoted()) item = new Item(item.getDefinitions().getCertId(), item.getAmount()); selectItem(e.getPlayer(), item.getId(), item.getAmount()); } }); public static ButtonClickHandler collBox = new ButtonClickHandler(COLLECTION_BOX, e -> { if (e.getPlayer().isIronMan()) { e.getPlayer().sendMessage(""Ironmen stand alone.""); return; } if (e.getPlayer().getTempAttribs().getB(""geLocked"")) return; switch(e.getComponentId()) { case 19 -> collectItems(e.getPlayer(), 0, e.getSlotId() / 2, e.getPacket() == ClientPacket.IF_OP1); case 23 -> collectItems(e.getPlayer(), 1, e.getSlotId() / 2, e.getPacket() == ClientPacket.IF_OP1); case 27 -> collectItems(e.getPlayer(), 2, e.getSlotId() / 2, e.getPacket() == ClientPacket.IF_OP1); case 32 -> collectItems(e.getPlayer(), 3, e.getSlotId() / 2, e.getPacket() == ClientPacket.IF_OP1); case 37 -> collectItems(e.getPlayer(), 4, e.getSlotId() / 2, e.getPacket() == ClientPacket.IF_OP1); case 42 -> collectItems(e.getPlayer(), 5, e.getSlotId() / 2, e.getPacket() == ClientPacket.IF_OP1); default -> Logger.debug(GE.class, ""collBox"", ""Unhandled collection box button: "" + e.getComponentId() + "", "" + e.getSlotId()); } }); public static void open(Player player) { player.abortDialogue(); resetVars(player); if (player.getInterfaceManager().containsInventoryInter()) player.getInterfaceManager().removeInventoryInterface(); if (!player.getInterfaceManager().topOpen(OFFER_SELECTION)) player.getInterfaceManager().sendInterface(OFFER_SELECTION); player.setCloseInterfacesEvent(() -> { player.abortDialogue(); Familiar.sendLeftClickOption(player); }); } public static void collectItems(Player player, int box, int slot, boolean noted) { Offer offer = player.getGEOffers().get(box); if (offer == null) return; Item orig = offer.getProcessedItems().get(slot).clone(); Item item = orig.clone(); if (item == null) return; ItemDefinitions defs = item.getDefinitions(); if (noted) { if (item.getAmount() > 1 && !defs.isNoted() && defs.getCertId() != -1 && item.getMetaData() == null) item.setId(defs.getCertId()); } if (!item.getDefinitions().isStackable() && item.getAmount() > player.getInventory().getFreeSlots()) item.setAmount(player.getInventory().getFreeSlots()); if (item.getAmount() <= 0 || !player.getInventory().hasRoomFor(item)) { player.sendMessage(""Not enough space in your inventory.""); player.soundEffect(2277, false); return; } player.getTempAttribs().setB(""geLocked"", true); offer.getProcessedItems().remove(new Item(orig.getId(), item.getAmount())); if (offer.getProcessedItems().isEmpty() && offer.getState() != State.STABLE) { WorldDB.getGE().remove(offer.getOwner(), box, () -> { player.getGEOffers().remove(box); player.getInventory().addItemDrop(item); player.getTempAttribs().setB(""geLocked"", false); updateGE(player); }); } else { WorldDB.getGE().save(offer, () -> { player.getInventory().addItemDrop(item); player.getTempAttribs().setB(""geLocked"", false); updateGE(player); }); } } public static void clickBox(Player player, int box, boolean abort) { Offer offer = player.getGEOffers().get(box); if (offer == null) return; if (abort) { if (offer.getState() == State.FINISHED) return; player.getTempAttribs().setB(""geLocked"", true); WorldDB.getGE().remove(player.getUsername(), offer.getBox(), () -> { player.getTempAttribs().setB(""geLocked"", false); offer.abort(); updateGE(player); }); return; } player.getVars().setVar(VAR_CURR_BOX, box); player.getPackets().setIFText(OFFER_SELECTION, 143, ItemConfig.get(offer.getItemId()).getExamine(new Item(offer.getItemId()))); player.getPackets().setIFEvents(new IFEvents(OFFER_SELECTION, 206, -1, 0).enableRightClickOptions(0,1)); player.getPackets().setIFEvents(new IFEvents(OFFER_SELECTION, 208, -1, 0).enableRightClickOptions(0,1)); } public static void openCollection(Player player) { player.getInterfaceManager().sendInterface(COLLECTION_BOX); player.getPackets().setIFEvents(new IFEvents(COLLECTION_BOX, 19, 0, 2).enableRightClickOptions(0, 1)); player.getPackets().setIFEvents(new IFEvents(COLLECTION_BOX, 23, 0, 2).enableRightClickOptions(0, 1)); player.getPackets().setIFEvents(new IFEvents(COLLECTION_BOX, 27, 0, 2).enableRightClickOptions(0, 1)); player.getPackets().setIFEvents(new IFEvents(COLLECTION_BOX, 32, 0, 2).enableRightClickOptions(0, 1)); player.getPackets().setIFEvents(new IFEvents(COLLECTION_BOX, 37, 0, 2).enableRightClickOptions(0, 1)); player.getPackets().setIFEvents(new IFEvents(COLLECTION_BOX, 42, 0, 2).enableRightClickOptions(0, 1)); for (Offer offer : player.getGEOffers().values()) if (offer != null) offer.sendItems(player); } public static void openBuy(Player player, int box) { player.getVars().setVar(VAR_CURR_BOX, box); player.getVars().setVar(VAR_IS_SELLING, 0); player.getPackets().openGESearch(); } public static void openSell(Player player, int box) { player.getVars().setVar(VAR_CURR_BOX, box); player.getVars().setVar(VAR_IS_SELLING, 1); player.getInterfaceManager().sendInventoryInterface(SPECIAL_DEPOSIT_INV); player.getPackets().sendItems(93, player.getInventory().getItems()); player.getPackets().setIFRightClickOps(SPECIAL_DEPOSIT_INV, 18, 0, 27, 0); player.getPackets().sendInterSetItemsOptionsScript(SPECIAL_DEPOSIT_INV, 18, 93, 4, 7, ""Offer""); player.getInterfaceManager().closeChatBoxInterface(); player.getPackets().setIFHidden(OFFER_SELECTION, 196, true); } public static void selectItem(Player player, int itemId, int amount) { if (!ItemDefinitions.getDefs(itemId).canExchange()) { player.sendMessage(""That item can't be exchanged.""); player.soundEffect(2277, false); return; } player.getVars().setVar(VAR_ITEM, itemId); player.getVars().setVar(VAR_ITEM_AMOUNT, amount); player.getVars().setVar(VAR_FOR_PRICE_TEXT, ItemDefinitions.getDefs(itemId).getHighAlchPrice()); player.getVars().setVar(VAR_MEDIAN_PRICE, ItemDefinitions.getDefs(itemId).getHighAlchPrice()); player.getPackets().setIFText(OFFER_SELECTION, 143, ItemConfig.get(itemId).getExamine(new Item(itemId))); WorldDB.getGE().getBestOffer(itemId, player.getVars().getVar(VAR_IS_SELLING) == 1, offer -> player.getPackets().setIFText(OFFER_SELECTION, 143, ItemConfig.get(itemId).getExamine(new Item(itemId)) + ""
"" + ""Best offer: "" + (offer == null ? ""None"" : Utils.formatNumber(offer.getPrice())))); } public static void confirmOffer(Player player) { if (player.getVars().getVar(VAR_IS_SELLING) == -1) return; int box = player.getVars().getVar(VAR_CURR_BOX); boolean selling = player.getVars().getVar(VAR_IS_SELLING) == 1; int itemId = player.getVars().getVar(VAR_ITEM); int amount = player.getVars().getVar(VAR_ITEM_AMOUNT); int price = player.getVars().getVar(VAR_FOR_PRICE_TEXT); int totalPrice = price * amount; if (player.getVars().getVar(VAR_IS_SELLING) == -1) return; if (box < 0 || box > 5) { player.sendMessage(""Invalid box selection "" + box + "".""); return; } if (itemId <= 0) return; if (totalPrice <= 0 || totalPrice > Integer.MAX_VALUE) { player.sendMessage(""Invalid total price.""); return; } if (amount <= 0) { player.sendMessage(""Invalid amount.""); return; } Offer offer; if (selling) offer = new Offer(player.getUsername(), box, selling, itemId, amount, price, OfferType.SELL); else offer = new Offer(player.getUsername(), box, selling, itemId, amount, price, OfferType.BUY); if (!deleteItems(player, offer)) { player.sendMessage(""You don't have the items to cover the offer.""); return; } resetVars(player); player.getGEOffers().put(offer.getBox(), offer); updateGE(player); player.getTempAttribs().setB(""geLocked"", true); WorldDB.getGE().execute(() -> { Set ownersNeedUpdate = new HashSet<>(); List offers = WorldDB.getGE().getBestOffersSync(offer); offer.setState(State.STABLE); if (offers == null || offers.isEmpty()) { WorldDB.getGE().saveSync(offer); updateGE(player); player.getTempAttribs().setB(""geLocked"", false); return; } for (Offer other : offers) if (offer.process(other)) { WorldDB.getGE().saveSync(other); ownersNeedUpdate.add(other.getOwner()); } if (offer.getState() == State.STABLE) WorldDB.getGE().saveSync(offer); updateGE(player); player.getTempAttribs().setB(""geLocked"", false); if (!ownersNeedUpdate.isEmpty()) for (String username : ownersNeedUpdate) GE.updateOffers(username); }); } private static boolean deleteItems(Player player, Offer offer) { if (!offer.isSelling()) { if (player.getInventory().hasCoins(offer.getPrice() * offer.getAmount())) { player.getInventory().removeCoins(offer.getPrice() * offer.getAmount()); return true; } return false; } int notedId = ItemDefinitions.getDefs(offer.getItemId()).certId; int nonNotedAmt = player.getInventory().getAmountOf(offer.getItemId()); int notedAmt = player.getInventory().getAmountOf(notedId); if (nonNotedAmt >= offer.getAmount()) { player.getInventory().deleteItem(offer.getItemId(), offer.getAmount()); return true; } if (notedAmt >= offer.getAmount()) { player.getInventory().deleteItem(notedId, offer.getAmount()); return true; } if (notedAmt + nonNotedAmt >= offer.getAmount()) { int amtLeft = offer.getAmount(); player.getInventory().deleteItem(offer.getItemId(), nonNotedAmt); amtLeft -= nonNotedAmt; player.getInventory().deleteItem(notedId, amtLeft); return true; } return false; } public static void resetVars(Player player) { player.getVars().setVar(VAR_CURR_BOX, -1); player.getVars().setVar(VAR_IS_SELLING, -1); player.getVars().setVar(VAR_ITEM, -1); player.getVars().setVar(VAR_ITEM_AMOUNT, 0); player.getVars().setVar(VAR_FOR_PRICE_TEXT, 0); } public static void updateOffers(String username) { Player player = World.getPlayerByUsername(username); if (player != null) WorldDB.getGE().get(username, offers -> { boolean diff = false; Map prev = player.getGEOffers(); for (Offer offer : offers) { if (offer == null) continue; if (prev.get(offer.getBox()) != null && offer.amountLeft() != prev.get(offer.getBox()).amountLeft() || offer.getState() != prev.get(offer.getBox()).getState()) diff = true; } player.setGEOffers(offers); updateGE(player); if (diff) if (player.getTempAttribs().getL(""GENotificationTime"") == 0) { player.getTempAttribs().setL(""GENotificationTime"", System.currentTimeMillis()); player.soundEffect(4042, false); player.sendMessage(""One or more of your grand exchange offers has been updated.""); } else if ((System.currentTimeMillis() - player.getTempAttribs().getL(""GENotificationTime"")) > 1000 * 60) { //1 minute player.getTempAttribs().setL(""GENotificationTime"", System.currentTimeMillis()); player.soundEffect(4042, false); player.sendMessage(""One or more of your grand exchange offers has been updated.""); } }); } private static void updateGE(Player player) { updateCollectionBox(player); for (int i = 0; i < 6; i++) { Offer offer = player.getGEOffers().get(i); if (offer == null) player.getPackets().updateGESlot(i, 0, -1, -1, -1, -1, -1); else { player.getPackets().updateGESlot(i, offer.getStateHash(), offer.getItemId(), offer.getPrice(), offer.getAmount(), offer.getCompletedAmount(), offer.getTotalGold()); offer.sendItems(player); } } } private static void updateCollectionBox(Player player) { for (int box = 0; box < 6; box++) { Offer offer = player.getGEOffers().get(box); if (offer == null) { sendItems(player, new Item[]{new Item(-1, 0)}, box); continue; } switch(offer.getCurrentType()) { case SELLING: sendItems(player, new Item[] { new Item(offer.getTotalGold() > 0 ? 995 : -1, offer.getTotalGold()) }, offer.getBox()); break; case BUYING: sendItems(player, new Item[] { new Item(offer.getCompletedAmount() == 0 ? -1 : offer.getItemId(), offer.getCompletedAmount()), new Item(offer.getTotalGold() > 0 ? 995 : -1, offer.getTotalGold()) }, offer.getBox()); break; case ABORTED: if (offer.getOfferType() == OfferType.BUY) sendItems(player, new Item[] { new Item(offer.getCompletedAmount() == 0 ? -1 : offer.getItemId(), offer.getCompletedAmount()), new Item(offer.getTotalGold() > 0 ? 995 : -1, offer.getTotalGold()) }, offer.getBox()); else sendItems(player, new Item[] { new Item(offer.getItemId(), offer.getAmount()), new Item(offer.getTotalGold() > 0 ? 995 : -1, offer.getTotalGold()) }, offer.getBox()); break; } } } public static void sendItems(Player player, Item[] items, int box) { int iComp = getComponentForBox(box); player.getPackets().sendItems(iComp, items); } public static int getComponentForBox(int box) { return switch (box) { case 0 -> 523; case 1 -> 524; case 2 -> 525; case 3 -> 526; case 4 -> 527; case 5 -> 528; default -> -1; }; } public static NPCInteractionDistanceHandler clerkDistance = new NPCInteractionDistanceHandler(new Object[] { ""Grand Exchange clerk"" }, (player, npc) -> 1); public static NPCClickHandler handleClerks = new NPCClickHandler(new Object[] { ""Grand Exchange clerk"" }, e -> { switch (e.getOption()) { case ""Talk-to"": e.getPlayer().sendOptionDialogue(""What would you like to do?"", ops -> { ops.add(""Open the Grand Exchange"", () -> GE.open(e.getPlayer())); ops.add(""Nevermind.""); }); break; case ""Exchange"": GE.open(e.getPlayer()); break; case ""History"": break; case ""Sets"": Sets.open(e.getPlayer()); break; } }); }" "package com.rs.game.ge; public class Offer { private final String owner; private final int box; private final boolean selling; private State state; private final int itemId; private final int amount; private final int price; private int completedAmount; private int totalGold; private GE.GrandExchangeType currentType; private final GE.OfferType offerType; private boolean aborted = false; private final ItemsContainer processedItems = new ItemsContainer<>(2, true); public Offer(String owner, int box, boolean selling, int itemId, int amount, int price, GE.OfferType type) { this.owner = owner; this.box = box; this.selling = selling; this.itemId = itemId; this.amount = amount; this.price = price; offerType = type; state = State.SUBMITTING; updateCurrentType(); } public void updateCurrentType() { if (offerType == GE.OfferType.BUY) currentType = GE.GrandExchangeType.BUYING; else currentType = GE.GrandExchangeType.SELLING; if (aborted) currentType = GE.GrandExchangeType.ABORTED; } public enum State { EMPTY(), SUBMITTING(), STABLE(), UNK_3(), UNK_4(), FINISHED(), UNK_6(), UNK_7() } public int getStateHash() { return state.ordinal() + (selling ? 0x8 : 0); } public String getOwner() { return owner; } public boolean isSelling() { return selling; } public State getState() { return state; } public void setState(State state) { this.state = state; } public int getCompletedAmount() { return completedAmount; } public void setCompletedAmount(int completedAmount) { this.completedAmount = completedAmount; } public ItemsContainer getProcessedItems() { return processedItems; } public int getPrice() { return price; } public int getBox() { return box; } public int getItemId() { return itemId; } public int getAmount() { return amount; } public int amountLeft() { return amount - completedAmount; } public void addCompleted(int num) { completedAmount += num; if (completedAmount >= amount) { if (completedAmount > amount) Logger.handle(Offer.class, ""addCompleted"", ""GE completed amount higher than sale amount: "" + this, null); state = State.FINISHED; } } public void sendItems(Player player) { player.getPackets().sendItems(523+box, processedItems); if (player.getInterfaceManager().topOpen(105)) { player.getPackets().setIFEvents(new IFEvents(105, 206, -1, 0).enableRightClickOptions(0,1)); player.getPackets().setIFEvents(new IFEvents(105, 208, -1, 0).enableRightClickOptions(0,1)); } } @Override public String toString() { return ""["" + owner + "", "" + box + "", "" + selling + "", "" + state + "", "" + itemId + "", "" + amount + "", "" + price + ""]""; } public boolean process(Offer other) { if (state != State.STABLE || other.getState() != State.STABLE || (selling && price > other.getPrice())) return false; if ((!selling && price < other.getPrice()) || (itemId != other.getItemId())) return false; int numTransact = Math.min(amountLeft(), other.amountLeft()); int finalPrice = numTransact * other.price; WorldDB.getLogs().logGE(this, other, numTransact, price); addCompleted(numTransact); totalGold += finalPrice; other.addCompleted(numTransact); other.totalGold += finalPrice; if (selling) { processedItems.add(new Item(995, finalPrice)); other.processedItems.add(new Item(itemId, numTransact)); } else { int diff = (price * numTransact) - finalPrice; if (diff > 0) processedItems.add(new Item(995, diff)); processedItems.add(new Item(itemId, numTransact)); other.processedItems.add(new Item(995, finalPrice)); } return true; } public void abort() { state = State.FINISHED; processedItems.add(selling ? new Item(itemId, amountLeft()) : new Item(995, amountLeft() * price)); aborted = true; updateCurrentType(); } public int getTotalGold() { return totalGold; } public GE.GrandExchangeType getCurrentType() { return currentType; } public GE.OfferType getOfferType() { return offerType; } }" "package com.rs.game.ge; @PluginEventHandler public class Sets { public enum Set { BRONZE_LG(11814, 1155, 1117, 1075, 1189), BRONZE_SK(11816, 1155, 1117, 1087, 1189), IRON_LG(11818, 1153, 1115, 1067, 1191), IRON_SK(11820, 1153, 1115, 1081, 1191), STEEL_LG(11822, 1157, 1119, 1069, 1193), STEEL_SK(11824, 1157, 1119, 1083, 1193), BLACK_LG(11826, 1165, 1125, 1077, 1195), BLACK_SK(11828, 1165, 1125, 1089, 1195), MITHRIL_LG(11830, 1159, 1121, 1071, 1197), MITHRIL_SK(11832, 1159, 1121, 1085, 1197), ADAMANT_LG(11834, 1161, 1123, 1073, 1199), ADAMANT_SK(11836, 1161, 1123, 1091, 1199), PROSELYTE_LG(9666, 9672, 9674, 9676), PROSELYTE_SK(9670, 9672, 9674, 9678), RUNE_LG(11838, 1163, 1127, 1079, 1201), RUNE_SK(11840, 1163, 1127, 1093, 1201), DRAG_CHAIN_LG(11842, 1149, 2513, 4087, 1187), DRAG_CHAIN_SK(11844, 1149, 2513, 4585, 1187), DRAG_PLATE_LG(14529, 11335, 14479, 4087, 1187), DRAG_PLATE_SK(14531, 11335, 14479, 4585, 1187), BLACK_H1_LG(19520, 10306, 19167, 7332, 19169), BLACK_H1_SK(19530, 10306, 19167, 7332, 19171), BLACK_H2_LG(19522, 10308, 19188, 7338, 19190), BLACK_H2_SK(19532, 10308, 19188, 7338, 19192), BLACK_H3_LG(19524, 10310, 19209, 7344, 19211), BLACK_H3_SK(19534, 10310, 19209, 7344, 19213), BLACK_H4_LG(19526, 10312, 19230, 7350, 19232), BLACK_H4_SK(19536, 10312, 19230, 7350, 19234), BLACK_H5_LG(19528, 10314, 19251, 7356, 19253), BLACK_H5_SK(19538, 10314, 19251, 7356, 19255), BLACK_TRIM_LG(11878, 2587, 2583, 2585, 2589), BLACK_TRIM_SK(11880, 2587, 2583, 3472, 2589), BLACK_GTRIM_LG(11882, 2595, 2591, 2593, 2597), BLACK_GTRIM_SK(11884, 2595, 2591, 3473, 2597), ADAMANT_H1_LG(19540, 10296, 19173, 7334, 19175), ADAMANT_H1_SK(19550, 10296, 19173, 7334, 19177), ADAMANT_H2_LG(19542, 10298, 19194, 7340, 19196), ADAMANT_H2_SK(19552, 10298, 19194, 7340, 19198), ADAMANT_H3_LG(19544, 10300, 19215, 7346, 19217), ADAMANT_H3_SK(19554, 10300, 19215, 7346, 19219), ADAMANT_H4_LG(19546, 10302, 19236, 7352, 19238), ADAMANT_H4_SK(19556, 10302, 19236, 7352, 19240), ADAMANT_H5_LG(19548, 10304, 19257, 7358, 19259), ADAMANT_H5_SK(19558, 10304, 19257, 7358, 19261), ADAMANT_TRIM_LG(11886, 2605, 2599, 2601, 2603), ADAMANT_TRIM_SK(11888, 2605, 2599, 3474, 2603), ADAMANT_GTRIM_LG(11890, 2613, 2607, 2609, 2611), ADAMANT_GTRIM_SK(11892, 2613, 2607, 3475, 2611), RUNE_H1_LG(19560, 10286, 19179, 19182, 7336), RUNE_H1_SK(19570, 10286, 19179, 19185, 7336), RUNE_H2_LG(19562, 10288, 19200, 19203, 7342), RUNE_H2_SK(19572, 10288, 19200, 19206, 7342), RUNE_H3_LG(19564, 10290, 19221, 19224, 7348), RUNE_H3_SK(19574, 10290, 19221, 19227, 7348), RUNE_H4_LG(19566, 10292, 19242, 19245, 7354), RUNE_H4_SK(19576, 10292, 19242, 19248, 7354), RUNE_H5_LG(19568, 10294, 19263, 19266, 7360), RUNE_H5_SK(19578, 10294, 19263, 19269, 7360), RUNE_TRIM_LG(11894, 2627, 2623, 2625, 2629), RUNE_TRIM_SK(11896, 2627, 2623, 3477, 2629), RUNE_GTRIM_LG(11898, 2619, 2615, 2617, 2621), RUNE_GTRIM_SK(11900, 2619, 2615, 3676, 2621), GUTHIX_LG(11926, 2673, 2669, 2671, 2675), GUTHIX_SK(11932, 2673, 2669, 3480, 2675), SARADOMIN_LG(11928, 2665, 2661, 2663, 2667), SARADOMIN_SK(11934, 2665, 2661, 3479, 2667), ZAMORAK_LG(11930, 2657, 2653, 2655, 2659), ZAMORAK_SK(11936, 2657, 2653, 3478, 2659), ROCKSHELL(11942, 6128, 6129, 6130, 6151, 6145), ELITEBLACK(14527, 14494, 14492, 14490), THIRDAGEMELEE(11858, 10350, 10348, 10352, 10346), THIRDAGERANGE(11860, 10334, 10330, 10332, 10336), THIRDAGEMAGE(11862, 10342, 10334, 10338, 10340), THIRDAGEDRUIDIC(19580, 19308, 19311, 19314, 19317, 19320), AHRIM(11846, 4708, 4712, 4714, 4710), DHAROK(11848, 4716, 4720, 4722, 4718), GUTHAN(11850, 4724, 4728, 4730, 4726), KARIL(11852, 4732, 4736, 4738, 4734), TORAG(11854, 4745, 4749, 4751, 4747), VERAC(11856, 4753, 4757, 4759, 4755), AKRISAE(21768, 21736, 21744, 21752, 21760), GREEN_DHIDE(11864, 1135, 1099, 1065), BLUE_DHIDE(11866, 2499, 2493, 2487), RED_DHIDE(11868, 2501, 2495, 2489), BLACK_DHIDE(11870, 2503, 2497, 2491), ROYAL_DHIDE(24386, 24382, 24379, 24376), MYSTIC(11872, 4089, 4091, 4093, 4095, 4097), MYSTICD(11962, 4099, 4101, 4103, 4105, 4107), MYSTICL(11960, 4109, 4111, 4113, 4115, 4117), INFINITY(11874, 6918, 6916, 6924, 6920, 6922), SPLITBARK(11876, 3385, 3387, 3389, 3391, 3393), ENCHANTED(11902, 7400, 7399, 7398), BLUE_ROBE_T(11904, 7396, 7392, 7388), BLUE_ROBE_G(11906, 7394, 7390, 7386), LEATHER_T(11908, 7364, 7368), LEATHER_G(11910, 7362, 7366), GREEN_DH_T(11912, 7372, 7380), GREEN_DH_G(11914, 7370, 7378), BLUE_DH_T(11916, 7376, 7384), BLUE_DH_G(11918, 7374, 7382), GREEN_BLESS(11920, 10382, 10378, 10380, 10376), BLUE_BLESS(11922, 10390, 10386, 10388, 10384), RED_BLESS(11924, 10374, 10370, 10372, 10368), BROWN_DHIDE(19582, 19457, 19453, 19455, 19451), PURPLE_DHIDE(19584, 19449, 19445, 19449, 19443), SILVER_DHIDE(19586, 19465, 19461, 19463, 19459), ARMA_LG(19588, 19422, 19413, 19416, 19410), ARMA_SK(19590, 19422, 19413, 19419, 19410), BAND_LG(19592, 19437, 19428, 19431, 19440), BAND_SK(19594, 19437, 19428, 19434, 19440), ANCI_LG(19596, 19407, 19398, 19401, 19410), ANCI_SK(19598, 19407, 19398, 19404, 19410), GILDED_LG(11938, 3486, 3481, 3483, 3488), GILDED_SK(11940, 3486, 3481, 3485, 3488), SPINED(11944, 6131, 6133, 6135, 6143, 6149), SKELETAL(11946, 6137, 6139, 6141, 6147, 6153), CANNON(11967, 6, 8, 10, 12), DAGON_HAI(14525, 14497, 14499, 14501); private final int setId; private final int[] items; Set(int setId, int... items) { this.setId = setId; this.items = items; } private static final Map SETS = new HashMap<>(); public static Set forId(int itemId) { return SETS.get(itemId); } static { for (Set set : Set.values()) SETS.put(set.getId(), set); } public int getId() { return setId; } public int[] getItems() { return items; } } public static void open(Player player) { player.getInterfaceManager().sendInterface(645); player.getInterfaceManager().sendInventoryInterface(644); player.getPackets().setIFRightClickOps(645, 16, 0, 115, 0, 1); player.getPackets().sendRunScriptReverse(676); player.getPackets().sendInterSetItemsOptionsScript(644, 0, 93, 4, 7, ""Components"", ""Exchange""); player.getPackets().setIFRightClickOps(644, 0, 0, 27, 0, 1); } public static void unpackSet(Player player, Set set) { if (set != null) { if (!player.getInventory().containsItem(set.getId())) return; if (player.getInventory().getFreeSlots() < set.getItems().length) { player.sendMessage(""You don't have enough space for that.""); return; } for (int itemId : set.getItems()) player.getInventory().addItem(new Item(itemId, 1)); player.getInventory().deleteItem(set.getId(), 1); } } public static void packSet(Player player, Set set) { if (set != null) { for (int itemId : set.getItems()) if (!player.getInventory().containsItem(itemId)) { player.sendMessage(""You need a "" + ItemDefinitions.getDefs(itemId).name + "" to exchange this set.""); return; } for (int itemId : set.getItems()) player.getInventory().deleteItem(new Item(itemId, 1)); player.getInventory().addItem(set.getId(), 1); } } public static void printSet(Player player, Set set) { if (set != null) { StringBuilder components = new StringBuilder(); for (int i = 0;i < set.getItems().length;i++) components.append(ItemDefinitions.getDefs(set.getItems()[i]).name.toLowerCase()).append(i == set.getItems().length - 1 ? """" : "", ""); player.sendMessage(""This set contains "" + components + "".""); } } public static ButtonClickHandler processItemSets = new ButtonClickHandler(new Object[] { 644, 645 }, e -> { if (e.getPacket() == ClientPacket.IF_OP1) printSet(e.getPlayer(), Set.forId(e.getSlotId2())); else if (e.getComponentId() == 16) packSet(e.getPlayer(), Set.forId(e.getSlotId2())); else unpackSet(e.getPlayer(), Set.forId(e.getSlotId2())); }); }" "package com.rs.game.map; public class Chunk { public static final int PLANE_INC = 0x400000; public static final int X_INC = 0x800; private final int id; private final int x; private final int y; private final int plane; private final List updates = ObjectLists.synchronize(new ObjectArrayList<>()); protected Set players = IntSets.synchronize(new IntOpenHashSet()); protected Set npcs = IntSets.synchronize(new IntOpenHashSet()); private final Set updateZones = ObjectSets.synchronize(new ObjectOpenHashSet<>()); protected GameObject[][][] baseObjects = new GameObject[8][8][4]; protected Map removedBaseObjects = Int2ObjectMaps.synchronize(new Int2ObjectOpenHashMap<>()); protected List spawnedObjects = ObjectLists.synchronize(new ObjectArrayList<>()); protected Set flaggedObjectsForTickProcessing = ObjectSets.synchronize(new ObjectOpenHashSet<>()); protected Map>> groundItems = Int2ObjectMaps.synchronize(new Int2ObjectOpenHashMap<>()); protected List groundItemList = ObjectLists.synchronize(new ObjectArrayList<>()); protected volatile boolean loadingSpawnData = false; protected volatile boolean loadedSpawnData = false; protected volatile boolean loadingMapData = false; protected volatile boolean loadedMapData = false; private int[] musicIds; public Chunk(int chunkId) { this.id = chunkId; int[] coords = MapUtils.decode(Structure.CHUNK, chunkId); this.x = coords[0]; this.y = coords[1]; this.plane = coords[2]; musicIds = Music.getRegionMusics(MapUtils.chunkToRegionId(chunkId)); } public void clearCollisionData() { WorldCollision.clearChunk(id); } public void setMusicIds(int[] musicIds) { this.musicIds = musicIds; } public void addProjectile(WorldProjectile projectile) { addChunkUpdate(new ProjAnim(projectile.getFromTile().getChunkLocalHash(), projectile)); } public void addSpotAnim(Tile tile, SpotAnim spotAnim) { addChunkUpdate(new TileSpotAnim(tile.getChunkLocalHash(), spotAnim)); } public void addObjectAnim(WorldObject object, Animation anim) { addChunkUpdate(new ObjectAnim(object.getTile().getChunkLocalHash(), object, anim)); } public void addSound(Tile tile, Sound sound) { addChunkUpdate(new TileSound(tile.getChunkLocalHash(), sound)); } public List getAllGroundItems() { return groundItemList; } public GroundItem getGroundItem(int itemId, Tile tile, int playerId) { Map> tileMap = groundItems.get(playerId); if (tileMap == null) return null; List items = tileMap.get(tile.getTileHash()); if (items == null) return null; for (GroundItem item : items) if (item.getId() == itemId) return item; return null; } public boolean itemExists(GroundItem item) { return getGroundItem(item.getId(), item.getTile(), item.getVisibleToId()) != null; } public GroundItem getGroundItem(int itemId, Tile tile, Player player) { GroundItem item = getGroundItem(itemId, tile, player == null ? 0 : player.getUuid()); if (item == null) item = getGroundItem(itemId, tile, 0); return item; } public void processSpawnedObjects() { if (flaggedObjectsForTickProcessing.isEmpty()) return; Set toRemove = new ObjectOpenHashSet<>(); for (GameObject object : flaggedObjectsForTickProcessing) if (!object.process()) toRemove.add(object); for (GameObject object : toRemove) unflagForProcess(object); } public void flagForProcess(GameObject object) { flaggedObjectsForTickProcessing.add(object); } public void unflagForProcess(GameObject object) { flaggedObjectsForTickProcessing.remove(object); } public void processGroundItems() { if (groundItems.isEmpty()) return; List toRemove = new ArrayList<>(); for (GroundItem item : groundItemList) { item.tick(); if (item.getDeleteTime() != -1 && item.getTicks() >= item.getDeleteTime()) toRemove.add(item); if (item.getPrivateTime() != -1 && item.getTicks() >= item.getPrivateTime() && item.isPrivate()) { if (!item.isInvisible() || !ItemConstants.isTradeable(item)) continue; removeItemFromOwnerMapping(item); Player creator = item.getCreatorUsername() != null ? World.getPlayerByUsername(item.getCreatorUsername()) : null; addChunkUpdate(new RevealGroundItem(item.getTile().getChunkLocalHash(), item, creator == null ? -1 : creator.getIndex())); item.removeOwner(); addItemToOwnerMapping(item); } } for (GroundItem item : toRemove) deleteGroundItem(item); } public boolean removeItemFromOwnerMapping(GroundItem item) { int tileHash = item.getTile().getTileHash(); Map> tileMap = groundItems.get(item.getVisibleToId()); if (tileMap == null) return false; List items = tileMap.get(tileHash); if (items == null) return false; if (items.remove(item)) { if (items.isEmpty()) tileMap.remove(tileHash); if (tileMap.isEmpty()) groundItems.remove(item.getVisibleToId()); return true; } return false; } public boolean addItemToOwnerMapping(GroundItem item) { Map> tileMap = groundItems.computeIfAbsent(item.getVisibleToId(), k -> Int2ObjectMaps.synchronize(new Int2ObjectOpenHashMap<>())); List items = tileMap.computeIfAbsent(item.getTile().getTileHash(), k -> ObjectLists.synchronize(new ObjectArrayList<>())); items.add(item); return true; } public boolean addGroundItem(GroundItem item) { ChunkManager.markChunkActive(id); Map> tileMap = groundItems.computeIfAbsent(item.getVisibleToId(), k -> Int2ObjectMaps.synchronize(new Int2ObjectOpenHashMap<>())); List items = tileMap.computeIfAbsent(item.getTile().getTileHash(), k -> ObjectLists.synchronize(new ObjectArrayList<>())); GroundItem existing = getGroundItem(item.getId(), item.getTile(), item.getVisibleToId()); if (item.getDefinitions().isStackable() && !item.containsMetaData() && existing != null) { int oldAmount = existing.getAmount(); existing.setAmount(existing.getAmount() + item.getAmount()); if (existing.getCreatorUsername() != null && World.getPlayerByUsername(existing.getCreatorUsername()) != null) World.getPlayerByUsername(existing.getCreatorUsername()).getPackets().sendSetGroundItemAmount(existing, oldAmount); else addChunkUpdate(new SetGroundItemAmount(existing.getTile().getChunkLocalHash(), existing, oldAmount)); return false; } groundItemList.add(item); items.add(item); if (item.isPrivate() && World.getPlayerByUsername(item.getCreatorUsername()) != null) World.getPlayerByUsername(item.getCreatorUsername()).getPackets().sendGroundItem(item); else addChunkUpdate(new CreateGroundItem(item.getTile().getChunkLocalHash(), item)); return true; } public boolean deleteGroundItem(GroundItem item) { ChunkManager.markChunkActive(id); int tileHash = item.getTile().getTileHash(); Map> tileMap = groundItems.get(item.getVisibleToId()); if (tileMap == null) return false; List items = tileMap.get(tileHash); if (items == null) return false; groundItemList.remove(item); if (items.remove(item)) { if (items.isEmpty()) tileMap.remove(tileHash); if (tileMap.isEmpty()) groundItems.remove(item.getVisibleToId()); if (item.isPrivate() && World.getPlayerByUsername(item.getCreatorUsername()) != null) World.getPlayerByUsername(item.getCreatorUsername()).getPackets().removeGroundItem(item); else addChunkUpdate(new RemoveGroundItem(item.getTile().getChunkLocalHash(), item)); return true; } return false; } public Map>> getGroundItems() { return groundItems; } public void checkLoaded() { if (!loadingMapData) { loadingMapData = true; ChunkManager.loadRegionMapDataByChunkId(id); loadedMapData = true; } if (!loadingSpawnData) { loadingSpawnData = true; NPCSpawns.loadNPCSpawns(id); ItemSpawns.loadItemSpawns(id); ObjectSpawns.loadObjectSpawns(id); loadedSpawnData = true; } } public void setMapDataLoaded() { loadingMapData = true; loadedMapData = true; } // public void loadMapFromCache() { // baseObjects = new GameObject[8][8][4]; // Region region = new Region(getRegionId()); // region.loadRegionMap(false); // for (int xOff = 0;xOff < 8;xOff++) // for (int yOff = 0;yOff < 8;yOff++) // WorldCollision.addFlag(Tile.of(getBaseX()+xOff, getBaseY()+yOff, plane), region.getClipFlags()[plane][(getBaseX()-region.getBaseX())+xOff][(getBaseY()-region.getBaseY())+yOff]); // if (region.getObjects() != null && !region.getObjects().isEmpty()) { // for (WorldObject object : region.getObjects()) { // if (object.getTile().getChunkId() != id) // continue; // addBaseObject(new GameObject(object)); // } // } // } public boolean isLoaded() { return loadedSpawnData && loadedMapData; } public void addBaseObject(GameObject obj) { baseObjects[obj.getTile().getXInChunk()][obj.getTile().getYInChunk()][obj.getSlot()] = obj; WorldCollision.clip(obj); } public void spawnObject(GameObject newObj, boolean clip) { GameObject baseObj = baseObjects[newObj.getTile().getXInChunk()][newObj.getTile().getYInChunk()][newObj.getSlot()]; GameObject spawnedObj = getSpawnedObjectWithSlot(newObj.getTile(), newObj.getSlot()); if (spawnedObj != null) { spawnedObjects.remove(spawnedObj); if (clip) WorldCollision.unclip(spawnedObj); } if (newObj.equals(baseObj)) { newObj = baseObj; deleteRemovedObject(baseObj); } else if (baseObj != newObj) { if (!newObj.equals(baseObj)) addRemovedObject(baseObj); ChunkManager.markChunkActive(id); spawnedObjects.add(newObj); if (clip && baseObj != null) WorldCollision.unclip(baseObj); } else if (spawnedObj == null) { Logger.info(Chunk.class, ""spawnObject"", ""Requested object to spawn is already spawned. (Shouldnt happen) "" + baseObj); return; } if (clip) WorldCollision.clip(newObj); addChunkUpdate(new AddObject(newObj.getTile().getChunkLocalHash(), newObj)); } public void removeObject(GameObject toRemove) { GameObject baseObject = baseObjects[toRemove.getTile().getXInChunk()][toRemove.getTile().getYInChunk()][toRemove.getSlot()]; GameObject removedBaseObject = getRemovedObject(baseObject); boolean replace = false; if (removedBaseObject != null) { deleteRemovedObject(baseObject); WorldCollision.clip(baseObject); replace = true; } GameObject spawned = getSpawnedObjectWithSlot(toRemove.getTile(), toRemove.getSlot()); if (spawned != null) { spawnedObjects.remove(toRemove); unflagForProcess(toRemove); WorldCollision.unclip(toRemove); if (baseObject != null) WorldCollision.clip(baseObject); replace = true; } else if (toRemove.equals(baseObject)) { unflagForProcess(toRemove); WorldCollision.unclip(toRemove); addRemovedObject(baseObject); } else return; if (replace && baseObject != null) addChunkUpdate(new AddObject(baseObject.getTile().getChunkLocalHash(), baseObject)); else addChunkUpdate(new RemoveObject(toRemove.getTile().getChunkLocalHash(), toRemove)); } public void addRemovedObject(GameObject object) { if (removedBaseObjects == null || object == null) return; removedBaseObjects.put(object.positionHashCode(), object); } public void deleteRemovedObject(GameObject object) { if (removedBaseObjects == null || object == null) return; removedBaseObjects.remove(object.positionHashCode()); } public GameObject getRemovedObject(GameObject object) { if (removedBaseObjects == null || object == null) return null; return removedBaseObjects.get(object.positionHashCode()); } public GameObject getObject(Tile tile) { GameObject[] objects = getBaseObjects(tile); if (objects == null) return null; for (GameObject object : objects) { if (object == null || getRemovedObject(object) != null) continue; return object; } return getSpawnedObject(tile); } public GameObject getObject(Tile tile, ObjectType type) { GameObject[] objects = getBaseObjects(tile); if (objects == null) return null; for (GameObject object : objects) { if (object == null || getRemovedObject(object) != null) continue; if (object.getType() == type) return object; } return getSpawnedObject(tile, type); } public GameObject[] getBaseObjects(Tile tile) { GameObject[] objs = baseObjects[tile.getXInChunk()][tile.getYInChunk()]; return objs == null ? new GameObject[0] : objs; } public GameObject[] getBaseObjects(int localX, int localY) { return getBaseObjects(Tile.of(getBaseX()+localX, getBaseY()+localY, plane)); } public List getBaseObjects() { if (baseObjects == null) return null; List list = new ArrayList<>(); for (GameObject[][] object : baseObjects) { if (object == null) continue; for (GameObject[] element : object) { if (element == null) continue; for (GameObject o : element) if (o != null) list.add(o); } } return list; } public GameObject getSpawnedObject(Tile tile) { if (spawnedObjects == null) return null; for (GameObject object : spawnedObjects) if (object.getX() == tile.getX() && object.getY() == tile.getY() && object.getPlane() == tile.getPlane()) return object; return null; } public GameObject getSpawnedObject(Tile tile, ObjectType type) { if (spawnedObjects == null) return null; for (GameObject object : spawnedObjects) if (object.getType() == type && object.getX() == tile.getX() && object.getY() == tile.getY() && object.getPlane() == tile.getPlane()) return object; return null; } public List getSpawnedObjects() { return spawnedObjects == null ? new ArrayList<>() : spawnedObjects; } public Map getRemovedObjects() { return removedBaseObjects; } public List getAllBaseObjects(boolean ignoreRemoved) { if (baseObjects == null) return null; List list = new ObjectArrayList<>(); for (int x = 0; x < 8; x++) for (int y = 0; y < 8; y++) { if (baseObjects[x][y] == null) continue; for (GameObject o : baseObjects[x][y]) { if (o != null && (ignoreRemoved || getRemovedObject(o) == null)) list.add(o); } } return list; } public List getAllObjects() { List list = new ObjectArrayList<>(); for (GameObject base : getAllBaseObjects(false)) if (!removedBaseObjects.containsValue(base)) list.add(base); list.addAll(spawnedObjects); return list; } public GameObject getObjectWithType(Tile tile, ObjectType type) { GameObject object = getObjectWithSlot(tile, type.slot); return object != null && object.getType() == type ? object : null; } public GameObject getObjectWithSlot(Tile tile, int slot) { GameObject o = getSpawnedObjectWithSlot(tile, slot); if (o == null) { GameObject real = getBaseObjects(tile)[slot]; return real == null ? null : getRemovedObject(real) != null ? null : real; } return o; } public boolean containsObjectWithId(Tile tile, int id) { GameObject object = getObjectWithId(tile, id); return object != null && object.getId() == id; } public GameObject getSpawnedObjectWithSlot(Tile tile, int slot) { for (GameObject object : spawnedObjects) if (object.getTile().matches(tile) && object.getSlot() == slot) return object; return null; } public GameObject getObjectWithId(Tile tile, int id) { for (int i = 0; i < 4; i++) { GameObject object = getBaseObjects(tile)[i]; if (object != null && getRemovedObject(object) != null) object = null; if (object != null && object.getId() == id) { GameObject spawned = getSpawnedObjectWithSlot(tile, object.getSlot()); return spawned == null ? object : spawned; } } for (GameObject object : spawnedObjects) if (tile.matches(object.getTile()) && object.getId() == id) return object; return null; } public boolean objectExists(GameObject object) { return containsObjectWithId(object.getTile(), object.getId()); } public GameObject getObjectWithId(int id, int plane) { if (baseObjects == null) return null; for (GameObject object : spawnedObjects) if (object.getId() == id && object.getPlane() == plane) return object; for (int x = 0; x < 64; x++) for (int y = 0; y < 64; y++) for (int slot = 0; slot < baseObjects[x][y].length; slot++) { GameObject object = baseObjects[x][y][slot]; if (object != null && object.getId() == id && getRemovedObject(object) == null) return object; } return null; } public GameObject getRealObject(GameObject spawnObject) { GameObject[] mapObjects = getBaseObjects(spawnObject.getTile()); if (mapObjects == null) return null; for (GameObject object : mapObjects) { if (object == null) continue; if (object.getType() == spawnObject.getType()) return object; } return null; } public int getMusicId() { if (musicIds == null) return -1; if (musicIds.length == 1) return musicIds[0]; return musicIds[Utils.getRandomInclusive(musicIds.length - 1)]; } public int[] getMusicIds() { return musicIds; } public Set getPlayerIndexes() { return players; } public Set getNPCsIndexes() { return npcs; } public void addPlayerIndex(int index) { players.add(index); } public void addNPCIndex(int index) { npcs.add(index); } public boolean removePlayerIndex(Integer index) { return players.remove(index); } public boolean removeNPCIndex(Object index) { return npcs.remove(index); } public void addChunkUpdate(UpdateZonePacketEncoder update) { ChunkManager.markChunkActive(id); updates.add(update); } public List getUpdates() { return updates; } public int getId() { return id; } public int getX() { return x; } public int getY() { return y; } public int getPlane() { return plane; } public int getRenderChunkX() { return x; } public int getRenderChunkY() { return y; } public int getRenderPlane() { return plane; } public int getRenderRegionId() { return (((getRenderChunkX() / 8) << 8) + (getRenderChunkY() / 8)); } public int getRotation() { return 0; } public void process() { updates.clear(); processGroundItems(); processSpawnedObjects(); if (groundItems.isEmpty() && spawnedObjects.isEmpty() && flaggedObjectsForTickProcessing.isEmpty()) ChunkManager.markChunkInactive(id); } public int getBaseX() { return x << 3; } public int getBaseY() { return y << 3; } public int getRegionX() { return x >> 3; } public int getRegionY() { return y >> 3; } public int getRegionId() { return (getRegionX() << 8) + getRegionY(); } public void init(Player player) { List initUpdates = new ObjectArrayList<>(); for (GroundItem item : getAllGroundItems()) { if (item.isPrivate() && item.getVisibleToId() != player.getUuid()) continue; initUpdates.add(new CreateGroundItem(item.getTile().getChunkLocalHash(), item)); } for (GameObject object : new ArrayList<>(getRemovedObjects().values())) initUpdates.add(new RemoveObject(object.getTile().getChunkLocalHash(), object)); for (GameObject object : getSpawnedObjects()) initUpdates.add(new AddObject(object.getTile().getChunkLocalHash(), object)); for (GameObject object : flaggedObjectsForTickProcessing) initUpdates.add(new AddObject(object.getTile().getChunkLocalHash(), object)); for (GameObject object : getAllObjects()) { if (object.getMeshModifier() != null) initUpdates.add(new CustomizeObject(object.getTile().getChunkLocalHash(), object.getMeshModifier().getObject(), object.getMeshModifier().getModelIds(), object.getMeshModifier().getModifiedColors(), object.getMeshModifier().getModifiedTextures())); } if (!initUpdates.isEmpty()) { player.getSession().writeToQueue(new UpdateZoneFull(player.getSceneBaseChunkId(), getId())); for (UpdateZonePacketEncoder packet : initUpdates) player.getSession().writeToQueue(packet); } } public void destroy() { loadingMapData = false; loadedMapData = false; if (getAllGroundItems() != null) getAllGroundItems().clear(); if (getGroundItems() != null) getGroundItems().clear(); getBaseObjects().clear(); getSpawnedObjects().clear(); getRemovedObjects().clear(); for (int npcIndex : new IntOpenHashSet(npcs)) { NPC npc = World.getNPCs().get(npcIndex); if (npc == null || npc instanceof Familiar || npc instanceof Pet) continue; npc.finish(); } ChunkManager.removeChunk(id); for (int playerIndex : players) { Player player = World.getPlayers().get(playerIndex); if (player == null || !player.hasStarted() || player.hasFinished()) continue; player.setForceNextMapLoadRefresh(true); player.loadMapRegions(); } } public void addUpdateZone(UpdateZone zone) { updateZones.add(zone); ChunkManager.unmarkRegionUnloadable(getRegionId()); } public void removeUpdateZone(UpdateZone zone) { updateZones.remove(zone); } public Set getUpdateZones() { return updateZones; } }" "package com.rs.game.map; @PluginEventHandler public final class ChunkManager { private static final Map CHUNKS = Int2ObjectMaps.synchronize(new Int2ObjectOpenHashMap<>()); private static final Set ACTIVE_CHUNKS = IntSets.synchronize(new IntOpenHashSet()); private static final Set UNLOADABLE_REGIONS = IntSets.synchronize(new IntOpenHashSet()); private static final Set PERMANENTLY_LOADED_REGIONS = IntSets.synchronize(new IntOpenHashSet()); private static final Map UPDATE_ZONES = new HashMap<>(); private static final Map> UPDATE_ZONES_REGION = new HashMap<>(); @ServerStartupEvent(ServerStartupEvent.Priority.FILE_IO) public static void loadAllMapData() { Logger.info(WorldCollision.class, ""loadAllMapData"", Runtime.getRuntime().maxMemory()/(1024*1024)+""mb heap space available. For better performance, allocate at least 1024mb or 3072mb""); boolean preloadCollision = Settings.getConfig().isAllowHighMemUseOptimizations() && Runtime.getRuntime().maxMemory() != Integer.MAX_VALUE && Runtime.getRuntime().maxMemory() > 1024*1024*1024; //1024mb HEAP boolean preloadObjects = Settings.getConfig().isAllowHighMemUseOptimizations() && Runtime.getRuntime().maxMemory() != Integer.MAX_VALUE && Runtime.getRuntime().maxMemory() > 3072L *1024*1024; //3072mb HEAP if (preloadCollision) { for (int regionId = 0; regionId < 0xFFFF; regionId++) { if (regionId == 18754) //citadel map that gets partially decoded with xteas but fails to pass gzip format tests continue; Region region = new Region(regionId); region.loadRegionMap(false); if (!region.hasData()) continue; for (int x = 0; x < 64; x++) for (int y = 0; y < 64; y++) for (int plane = 0; plane < 4; plane++) WorldCollision.addFlag(Tile.of(region.getBaseX() + x, region.getBaseY() + y, plane), region.getClipFlags()[plane][x][y]); if (preloadObjects) { if (region.getObjects() == null || region.getObjects().isEmpty()) continue; for (WorldObject object : region.getObjects()) { Chunk chunk = getChunk(object.getTile().getChunkId()); chunk.addBaseObject(new GameObject(object)); chunk.setMapDataLoaded(); } } } } } public static void updateChunks(Entity entity) { if (entity instanceof NPC) WorldCollision.clipNPC((NPC) entity); if (entity.hasFinished()) { if (entity instanceof Player) { getChunk(entity.getLastChunkId()).removePlayerIndex(entity.getIndex()); getUpdateZone(entity.getSceneBaseChunkId(), entity.getMapSize()).removePlayerWatcher(entity.getIndex()); } else { getChunk(entity.getLastChunkId()).removeNPCIndex(entity.getIndex()); if (entity instanceof NPC n && n.isLoadsUpdateZones()) getUpdateZone(entity.getSceneBaseChunkId(), entity.getMapSize()).removeNPCWatcher(entity.getIndex()); } return; } int chunkId = MapUtils.encode(MapUtils.Structure.CHUNK, entity.getChunkX(), entity.getChunkY(), entity.getPlane()); if (entity.getLastChunkId() != chunkId || entity.isForceUpdateEntityRegion()) { PluginManager.handle(new EnterChunkEvent(entity, chunkId)); entity.checkMultiArea(); if (entity instanceof Player player) { if(Settings.getConfig().isDebug() && player.hasStarted() && Music.getGenre(player) == null && !(getChunk(player.getChunkId()) instanceof InstancedChunk)) player.sendMessage(chunkId + "" has no music genre!"", true); if (entity.getLastChunkId() > 0) getChunk(entity.getLastChunkId()).removePlayerIndex(entity.getIndex()); Chunk chunk = getChunk(chunkId); chunk.addPlayerIndex(entity.getIndex()); //Unlock all region music at once. int[] musicIds = chunk.getMusicIds(); if (player.hasStarted() && musicIds != null) for (int musicId : musicIds) if (!player.getMusicsManager().hasMusic(musicId)) player.getMusicsManager().unlockMusic(musicId); //if should play random song on enter region /** * If the player is in the world and no genre is playing * if there is no controller and the region and playing genres don't match, play a song * same if there is a controller but check if the controller allows region play. */ if(player.hasStarted() && (Music.getGenre(player) == null || player.getMusicsManager().getPlayingGenre() == null || !player.getMusicsManager().getPlayingGenre().matches(Music.getGenre(player)))) {//tested, looks good. if (player.getControllerManager().getController() == null) { player.getMusicsManager().nextAmbientSong(); } else if (player.getControllerManager().getController().playAmbientOnControllerRegionEnter() && !player.getDungManager().isInsideDungeon()) { //if we start the dungeon controller before the region enter we can get rid of that inside dungeon thing. if(player.getMusicsManager().getPlayingGenre() == null || !player.getMusicsManager().getPlayingGenre().matches(player.getControllerManager().getController().getGenre())) { player.getMusicsManager().nextAmbientSong(); } } } player.getControllerManager().moved(); } else { if (entity.getLastChunkId() > 0) getChunk(entity.getLastChunkId()).removeNPCIndex(entity.getIndex()); getChunk(chunkId).addNPCIndex(entity.getIndex()); } entity.setForceUpdateEntityRegion(false); entity.setLastChunkId(chunkId); } else if (entity instanceof Player player) { player.getControllerManager().moved(); } } public static void loadRegionMapDataByChunkId(int chunkId) { synchronized (CHUNKS) { Chunk chunk = CHUNKS.get(chunkId); if (chunk == null) { chunk = new Chunk(chunkId); CHUNKS.put(chunkId, chunk); return; } if (chunk.loadedMapData) return; int regionId = MapUtils.chunkToRegionId(chunkId); Region region = new Region(regionId); verifyChunksInited(region); region.loadRegionMap(false); if (!region.hasData()) { markAllChunksInRegionLoaded(region); return; } for (int x = 0; x < 64; x++) for (int y = 0; y < 64; y++) for (int plane = 0; plane < 4; plane++) WorldCollision.addFlag(Tile.of(region.getBaseX() + x, region.getBaseY() + y, plane), region.getClipFlags()[plane][x][y]); if (region.getObjects() == null || region.getObjects().isEmpty()) { markAllChunksInRegionLoaded(region); return; } for (WorldObject object : region.getObjects()) { int oCid = object.getTile().getChunkId(); Chunk oChunk = CHUNKS.get(oCid); if (oChunk instanceof InstancedChunk) continue; if (oChunk == null) oChunk = new Chunk(oCid); oChunk.addBaseObject(new GameObject(object)); CHUNKS.put(oCid, oChunk); } markAllChunksInRegionLoaded(region); } } private static void verifyChunksInited(Region region) { int chunkBaseId = MapUtils.encode(Structure.CHUNK, region.getBaseX() >> 3, region.getBaseY() >> 3, 0); for (int planeOff = 0; planeOff < 4 * Chunk.PLANE_INC; planeOff += Chunk.PLANE_INC) { for (int chunkXOff = 0; chunkXOff < 8 * Chunk.X_INC; chunkXOff += Chunk.X_INC) { for (int chunkYOff = 0; chunkYOff < 8; chunkYOff++) { int cid = chunkBaseId + chunkXOff + chunkYOff + planeOff; Chunk c = CHUNKS.get(cid); if (c == null) { c = new Chunk(cid); CHUNKS.put(cid, c); return; } } } } } private static void markAllChunksInRegionLoaded(Region region) { int chunkBaseId = MapUtils.encode(Structure.CHUNK, region.getBaseX() >> 3, region.getBaseY() >> 3, 0); for (int planeOff = 0; planeOff < 4 * Chunk.PLANE_INC; planeOff += Chunk.PLANE_INC) { for (int chunkXOff = 0; chunkXOff < 8 * Chunk.X_INC; chunkXOff += Chunk.X_INC) { for (int chunkYOff = 0; chunkYOff < 8; chunkYOff++) { int cid = chunkBaseId + chunkXOff + chunkYOff + planeOff; Chunk c = CHUNKS.get(cid); if (c == null) continue; c.setMapDataLoaded(); } } } } public static Chunk getChunk(int id, boolean load) { synchronized (CHUNKS) { Chunk chunk = CHUNKS.get(id); if (CHUNKS.get(id) != null) { if (load) chunk.checkLoaded(); return chunk; } chunk = new Chunk(id); CHUNKS.put(id, chunk); if (load) chunk.checkLoaded(); return chunk; } } public static Chunk getChunk(int id) { return getChunk(id, false); } public static Chunk putChunk(int id, Chunk chunk) { synchronized (CHUNKS) { return CHUNKS.put(id, chunk); } } public static Chunk removeChunk(int id) { synchronized (CHUNKS) { return CHUNKS.remove(id); } } public static UpdateZone removeUpdateZone(int baseChunkId, RegionSize size) { synchronized (UPDATE_ZONES) { UpdateZone zone = UPDATE_ZONES.remove(UpdateZone.getId(baseChunkId, size)); if (zone == null) return null; //Logger.debug(ChunkManager.class, ""removeUpdateZone"", UpdateZone.getId(baseChunkId, size) + "" update zone removed""); for (int chunkId : zone.getChunkIds()) ChunkManager.getChunk(chunkId).removeUpdateZone(zone); for (int regionId : zone.getRegionIds()) { List zones = UPDATE_ZONES_REGION.get(regionId); if (zones != null) { zones.remove(zone); if (zones.isEmpty()) { UPDATE_ZONES_REGION.remove(regionId); markRegionUnloadable(regionId); } } } return zone; } } public static UpdateZone getUpdateZone(int baseChunkId, RegionSize size) { synchronized (UPDATE_ZONES) { int id = UpdateZone.getId(baseChunkId, size); UpdateZone zone = UPDATE_ZONES.get(id); if (zone == null) { zone = new UpdateZone(baseChunkId, size); UPDATE_ZONES.put(id, zone); //Logger.debug(ChunkManager.class, ""getUpdateZone"", UpdateZone.getId(baseChunkId, size) + "" update zone added""); for (int regionId : zone.getRegionIds()) { List zones = UPDATE_ZONES_REGION.get(regionId); if (zones == null) { zones = new ArrayList<>(); zones.add(zone); UPDATE_ZONES_REGION.put(regionId, zones); } } for (int chunkId : zone.getChunkIds()) ChunkManager.getChunk(chunkId).addUpdateZone(zone); } return zone; } } public static void markRegionUnloadable(int regionId) { if (!PERMANENTLY_LOADED_REGIONS.contains(regionId)) { UNLOADABLE_REGIONS.add(regionId); //Logger.debug(ChunkManager.class, ""markRegionUnloadable"", regionId + "" UNLOADABLE""); } } public static void unmarkRegionUnloadable(int regionId) { if (!PERMANENTLY_LOADED_REGIONS.contains(regionId)) { UNLOADABLE_REGIONS.remove(regionId); } } public static void permanentlyPreloadRegions(int... regionIds) { for (int regionId : regionIds) { if (PERMANENTLY_LOADED_REGIONS.contains(regionId)) continue; getChunk(Tile.of((regionId >> 8) * 64 + 32, (regionId & 0xff) * 64 + 32, 0).getChunkId(), true); PERMANENTLY_LOADED_REGIONS.add(regionId); } } public static void permanentlyPreloadRegions(Set regionIds) { for (int regionId : regionIds) { if (PERMANENTLY_LOADED_REGIONS.contains(regionId)) continue; getChunk(Tile.of((regionId >> 8) * 64 + 32, (regionId & 0xff) * 64 + 32, 0).getChunkId(), true); PERMANENTLY_LOADED_REGIONS.add(regionId); } } public static void processChunks() { synchronized(CHUNKS) { try { for (int chunkId : new IntOpenHashSet(ACTIVE_CHUNKS)) ChunkManager.getChunk(chunkId).process(); } catch(Throwable e) { Logger.handle(ChunkManager.class, ""processChunks"", e); } } } public static void markChunkActive(int chunkId) { ACTIVE_CHUNKS.add(chunkId); } public static void markChunkInactive(int chunkId) { ACTIVE_CHUNKS.remove(chunkId); } public static void processUpdateZones() { synchronized(UPDATE_ZONES) { for (UpdateZone c : UPDATE_ZONES.values()) { if (c != null) c.update(); } } } public static void clearUnusedMemory() { synchronized (CHUNKS) { List destroyed = new IntArrayList(); regionLoop: for (int regionId : UNLOADABLE_REGIONS) { int chunkBaseId = Tile.of((regionId >> 8) * 64, (regionId & 0xff) * 64, 0).getChunkId(); Set chunksToDestroy = new IntOpenHashSet(); for (int planeOff = 0; planeOff < 4 * Chunk.PLANE_INC; planeOff += Chunk.PLANE_INC) { for (int chunkXOff = 0; chunkXOff < 8 * Chunk.X_INC; chunkXOff += Chunk.X_INC) { for (int chunkYOff = 0; chunkYOff < 8; chunkYOff++) { int chunkId = chunkBaseId + chunkXOff + chunkYOff + planeOff; Chunk chunk = getChunk(chunkId); if (ACTIVE_CHUNKS.contains(chunkId)) continue regionLoop; if (chunk != null && !(chunk instanceof InstancedChunk)) chunksToDestroy.add(chunkId); } } } for (int chunkId : chunksToDestroy) { Chunk chunk = getChunk(chunkId); if (chunk == null) continue; chunk.clearCollisionData(); chunk.destroy(); destroyed.add(chunkId); } } for (int regionId : destroyed) UNLOADABLE_REGIONS.remove(regionId); } } }" "package com.rs.game.map; public class UpdateZone { private final int baseChunkId; private final RegionSize size; private final Set chunkIds = new IntOpenHashSet(); private final Set regionIds = new IntOpenHashSet(); protected Set playerWatchers = IntSets.synchronize(new IntOpenHashSet()); protected Set npcWatchers = IntSets.synchronize(new IntOpenHashSet()); private final List chunkUpdates = new ObjectArrayList<>(); public UpdateZone(int baseChunkId, RegionSize size) { this.baseChunkId = baseChunkId; this.size = size; for (int planeOff = 0;planeOff < 4 * Chunk.PLANE_INC;planeOff += Chunk.PLANE_INC) { for (int chunkXOff = 0; chunkXOff <= (size.size / 8) * Chunk.X_INC; chunkXOff += Chunk.X_INC) { for (int chunkYOff = 0; chunkYOff <= (size.size / 8); chunkYOff++) { int chunkId = baseChunkId + chunkXOff + chunkYOff + planeOff; chunkIds.add(chunkId); regionIds.add(MapUtils.chunkToRegionId(chunkId)); } } } } public static int getId(int baseChunkId, RegionSize size) { return Objects.hashCode(baseChunkId, size); } public void rebuildUpdateZone() { for (int chunkId : chunkIds) { Chunk chunk = ChunkManager.getChunk(chunkId); if (!chunk.getUpdates().isEmpty()) { chunkUpdates.add(new UpdateZonePartialEnclosed(baseChunkId, chunk.getId(), chunk.getUpdates())); } } } private void sendUpdates(Player player) { if (chunkUpdates.isEmpty() || player == null || player.hasFinished() || !player.hasStarted()) return; for (UpdateZonePartialEnclosed packet : chunkUpdates) player.getSession().writeToQueue(packet); } public void update() { rebuildUpdateZone(); for (int pid : playerWatchers) sendUpdates(World.getPlayers().get(pid)); chunkUpdates.clear(); } public void addPlayerWatcher(int pid) { playerWatchers.add(pid); } public void removePlayerWatcher(int pid) { playerWatchers.remove(pid); if (playerWatchers.isEmpty() && npcWatchers.isEmpty()) ChunkManager.removeUpdateZone(baseChunkId, size); } public void addNPCWatcher(int nid) { npcWatchers.add(nid); } public void removeNPCWatcher(int nid) { npcWatchers.remove(nid); if (playerWatchers.isEmpty() && npcWatchers.isEmpty()) ChunkManager.removeUpdateZone(baseChunkId, size); } public Set getChunkIds() { return chunkIds; } public Set getRegionIds() { return regionIds; } }" "package com.rs.game.map.instance; public class Instance { private static final Map INSTANCES = Object2ObjectMaps.synchronize(new Object2ObjectOpenHashMap<>()); private final UUID id = UUID.randomUUID(); private final Tile returnTo; private int[] entranceOffset; private boolean persistent; private transient int[] chunkBase; private final transient IntSet chunkIds = new IntOpenHashSet(); private final int width; private final int height; private final boolean copyNpcs; private final transient AtomicBoolean destroyed; private Instance() { this.returnTo = Settings.getConfig().getPlayerStartTile(); this.width = 1; this.height = 1; destroyed = new AtomicBoolean(false); this.copyNpcs = false; } private Instance(Tile returnTo, int width, int height, boolean copyNpcs) { this.returnTo = returnTo; this.width = width; this.height = height; destroyed = new AtomicBoolean(false); this.copyNpcs = copyNpcs; } public static Instance of(Tile returnTo, int width, int height, boolean copyNpcs) { Instance instance = new Instance(returnTo, width, height, copyNpcs); INSTANCES.put(instance.id, instance); return new Instance(returnTo, width, height, copyNpcs); } public static Instance of(Tile returnTo, int width, int height) { return of(returnTo, width, height, false); } public static Instance get(UUID uuid) { return INSTANCES.get(uuid); } public int[] getEntranceOffset() { return entranceOffset; } public Instance setEntranceOffset(int[] entranceOffset) { this.entranceOffset = entranceOffset; return this; } public Instance persist() { persistent = true; return this; } public CompletableFuture requestChunkBound() { CompletableFuture future = new CompletableFuture<>(); destroyed.set(false); InstanceBuilder.findEmptyChunkBound(this, future); return future; } public CompletableFuture copyChunk(int localChunkX, int localChunkY, int plane, int fromChunkX, int fromChunkY, int fromPlane, int rotation) { CompletableFuture future = new CompletableFuture<>(); if (chunkBase == null) requestChunkBound().thenAccept(bool -> InstanceBuilder.copyChunk(this, localChunkX, localChunkY, plane, fromChunkX, fromChunkY, fromPlane, rotation, future)).exceptionally(e -> { future.completeExceptionally(e); return null; }); else InstanceBuilder.copyChunk(this, localChunkX, localChunkY, plane, fromChunkX, fromChunkY, fromPlane, rotation, future); return future; } public CompletableFuture clearChunk(int localChunkX, int localChunkY, int plane) { CompletableFuture future = new CompletableFuture<>(); if (chunkBase == null) requestChunkBound().thenAccept(bool -> InstanceBuilder.clearChunk(this, localChunkX, localChunkY, plane, future)).exceptionally(e -> { future.completeExceptionally(e); return null; }); else InstanceBuilder.clearChunk(this, localChunkX, localChunkY, plane, future); return future; } public CompletableFuture copy2x2ChunkSquare(int localChunkX, int localChunkY, int fromChunkX, int fromChunkY, int rotation, int[] planes) { CompletableFuture future = new CompletableFuture<>(); if (chunkBase == null) requestChunkBound().thenAccept(bool -> InstanceBuilder.copy2x2ChunkSquare(this, localChunkX, localChunkY, fromChunkX, fromChunkY, rotation, planes, future)).exceptionally(e -> { future.completeExceptionally(e); return null; }); else InstanceBuilder.copy2x2ChunkSquare(this, localChunkX, localChunkY, fromChunkX, fromChunkY, rotation, planes, future); return future; } public CompletableFuture copyMap(int localChunkX, int localChunkY, int fromChunkX, int fromChunkY, int size) { CompletableFuture future = new CompletableFuture<>(); if (chunkBase == null) requestChunkBound().thenAccept(bool -> InstanceBuilder.copyMap(this, localChunkX, localChunkY, fromChunkX, fromChunkY, size, future)).exceptionally(e -> { future.completeExceptionally(e); return null; }); else InstanceBuilder.copyMap(this, localChunkX, localChunkY, fromChunkX, fromChunkY, size, future); return future; } public CompletableFuture copyMapAllPlanes(int fromChunkX, int fromChunkY, int size) { return copyMap(0, 0, fromChunkX, fromChunkY, size); } public CompletableFuture copyMap(int localChunkX, int localChunkY, int[] planes, int fromChunkX, int fromChunkY, int[] fromPlanes, int width, int height) { CompletableFuture future = new CompletableFuture<>(); if (chunkBase == null) requestChunkBound().thenAccept(bool -> InstanceBuilder.copyMap(this, localChunkX, localChunkY, planes, fromChunkX, fromChunkY, fromPlanes, width, height, copyNpcs, future)).exceptionally(e -> { future.completeExceptionally(e); return null; }); else InstanceBuilder.copyMap(this, localChunkX, localChunkY, planes, fromChunkX, fromChunkY, fromPlanes, width, height, copyNpcs, future); return future; } public CompletableFuture copyMap(int[] planes, int fromChunkX, int fromChunkY, int[] fromPlanes, int width, int height) { return copyMap(0, 0, planes, fromChunkX, fromChunkY, fromPlanes, width, height); } public CompletableFuture copyMapSinglePlane(int fromChunkX, int fromChunkY) { return copyMap(0, 0, new int[1], fromChunkX, fromChunkY, new int[1], width, height); } public CompletableFuture copyMapAllPlanes(int fromChunkX, int fromChunkY) { return copyMap(0, 0, new int[] { 0, 1, 2, 3 }, fromChunkX, fromChunkY, new int[] { 0, 1, 2, 3 }, width, height); } public CompletableFuture clearMap(int chunkX, int chunkY, int width, int height, int[] planes) { CompletableFuture future = new CompletableFuture<>(); if (chunkBase == null) requestChunkBound().thenAccept(bool -> InstanceBuilder.clearMap(this, chunkX, chunkY, width, height, planes, future)).exceptionally(e -> { future.completeExceptionally(e); return null; }); else InstanceBuilder.clearMap(this, chunkX, chunkY, width, height, planes, future); return future; } public CompletableFuture clearMap(int width, int height, int[] planes) { return clearMap(0, 0, width, height, planes); } public CompletableFuture clearMap(int[] planes) { return clearMap(width, height, planes); } public CompletableFuture destroy() { CompletableFuture future = new CompletableFuture<>(); INSTANCES.remove(id); if (destroyed.get()) { future.complete(null); return future; } WorldTasks.schedule(5, () -> { destroyed.set(true); InstanceBuilder.destroyMap(this, future); }); return future; } public int[] getChunkBase() { return chunkBase; } public int getBaseChunkX() { return chunkBase[0]; } public int getBaseChunkY() { return chunkBase[1]; } public int getBaseX() { return chunkBase[0] << 3; } public int getBaseY() { return chunkBase[1] << 3; } public Tile getTileBase() { return Tile.of(getBaseX(), getBaseY(), 0); } public Tile getLocalTile(int offsetX, int offsetY, int plane) { return Tile.of(getLocalX(offsetX), getLocalY(offsetY), plane); } public Tile getLocalTile(int offsetX, int offsetY) { return getLocalTile(offsetX, offsetY, 0); } public int getLocalX(int offset) { return getBaseX() + offset; } public int getLocalY(int offset) { return getBaseY() + offset; } public int getLocalX(int chunkXOffset, int tileXOffset) { return (getChunkX(chunkXOffset) << 3) + tileXOffset; } public int getLocalY(int chunkYOffset, int tileYOffset) { return (getChunkY(chunkYOffset) << 3) + tileYOffset; } public int getChunkX(int offsetX) { return getBaseChunkX() + offsetX; } public int getChunkY(int offsetY) { return getBaseChunkY() + offsetY; } public int getChunkId(int offsetX, int offsetY, int plane) { return MapUtils.encode(Structure.CHUNK, getBaseChunkX()+offsetX, getBaseChunkY()+offsetY, plane); } public boolean isCopyNpcs() { return copyNpcs; } public boolean isDestroyed() { return destroyed.get(); } public boolean isCreated() { return chunkBase != null; } public IntSet getChunkIds() { return chunkIds; } /** * Only the instance builder should be setting this value. */ @Deprecated public void setChunkBase(int[] chunkBase) { this.chunkBase = chunkBase; } public int getWidth() { return width; } public int getHeight() { return height; } public Tile getReturnTo() { return returnTo; } public void teleportLocal(Player player, int localX, int localY, int plane) { player.setInstancedArea(this); player.tele(Tile.of(getBaseX() + localX, getBaseY() + localY, plane)); } public void teleportLocal(NPC npc, int localX, int localY, int plane) { npc.tele(Tile.of(getBaseX() + localX, getBaseY() + localY, plane)); } public void teleportChunkLocal(Player player, int chunkXOffset, int chunkYOffset, int xOffset, int yOffset, int plane) { player.setInstancedArea(this); player.tele(Tile.of(getLocalX(chunkXOffset, xOffset), getLocalY(chunkYOffset, yOffset), plane)); } public void teleportChunkLocal(NPC npc, int chunkXOffset, int chunkYOffset, int xOffset, int yOffset, int plane) { npc.tele(Tile.of(getLocalX(chunkXOffset, xOffset), getLocalY(chunkYOffset, yOffset), plane)); } public void teleportTo(Player player) { teleportLocal(player, entranceOffset == null ? width * 4 : entranceOffset[0], entranceOffset == null ? height * 4 : entranceOffset[1], entranceOffset == null || entranceOffset.length < 3 ? 0 : entranceOffset[2]); } public void teleportTo(NPC npc) { teleportLocal(npc, entranceOffset == null ? width * 4 : entranceOffset[0], entranceOffset == null ? height * 4 : entranceOffset[1], entranceOffset == null || entranceOffset.length < 3 ? 0 : entranceOffset[2]); } public UUID getId() { return id; } public boolean isPersistent() { return persistent; } }" "package com.rs.game.map.instance; public final class InstanceBuilder { public static final int NORTH = 0, EAST = 1, SOUTH = 2, WEST = 3; private static final Set RESERVED_REGIONS = new HashSet<>(); private static final int MAX_REGION_X = 127; private static final int MAX_REGION_Y = 255; private static void reserveRegions(int fromRegionX, int fromRegionY, int width, int height, boolean remove) { synchronized(RESERVED_REGIONS) { for (int regionX = fromRegionX; regionX < fromRegionX + width; regionX++) for (int regionY = fromRegionY; regionY < fromRegionY + height; regionY++) if (remove) { Logger.info(InstanceBuilder.class, ""reserveRegions"", ""Freeing region: "" + regionX + "", "" + regionY); RESERVED_REGIONS.remove(MapUtils.encode(Structure.REGION, regionX, regionY)); } else { Logger.info(InstanceBuilder.class, ""reserveRegions"", ""Reserving region: "" + regionX + "", "" + regionY); RESERVED_REGIONS.add(MapUtils.encode(Structure.REGION, regionX, regionY)); } Logger.info(InstanceBuilder.class, ""reserveRegions"", ""Reserved regions: "" + RESERVED_REGIONS.size()); } } private static boolean regionReserved(int regionId) { synchronized(RESERVED_REGIONS) { return RESERVED_REGIONS.contains(regionId); } } public static InstancedChunk createAndReserveChunk(int fromChunkId, int toChunkId, int rotation) { Chunk chunk = ChunkManager.getChunk(toChunkId); if (chunk != null) chunk.destroy(); InstancedChunk newChunk = new InstancedChunk(fromChunkId, toChunkId, rotation); ChunkManager.putChunk(toChunkId, newChunk); return newChunk; } public static void destroyChunk(int chunkId) { Chunk chunk = ChunkManager.getChunk(chunkId); if (chunk != null) chunk.destroy(); } public static void findEmptyChunkBound(Instance ref, CompletableFuture future) { AsyncTaskExecutor.executeWorldThreadSafe(""InstanceBuilder.findEmptyChunkBound"", future, 30, () -> { ref.setChunkBase(findEmptyChunkBound(ref.getWidth(), ref.getHeight())); for (int plane = 0;plane < 4;plane++) { for (int x = ref.getChunkBase()[0]; x < ref.getWidth(); x++) { for (int y = ref.getChunkBase()[1];y < ref.getHeight();y++) { ref.getChunkIds().add(MapUtils.encode(Structure.CHUNK, x, y, plane)); } } } }); } private static int[] findEmptyChunkBounds(int widthChunks, int heightChunks) { int chunkId = findEmptyBaseChunkId(widthChunks, heightChunks); int[] xyz = MapUtils.decode(Structure.CHUNK, chunkId); return new int[] { xyz[0], xyz[1] }; } private static int[] findEmptyChunkBound(int widthChunks, int heightChunks) { return findEmptyChunkBounds(widthChunks, heightChunks); } private static int findEmptyBaseChunkId(int widthChunks, int heightChunks) { int regionsDistanceX = 2; while (widthChunks > 8) { regionsDistanceX += 1; widthChunks -= 8; } int regionsDistanceY = 2; while (heightChunks > 8) { regionsDistanceY += 1; heightChunks -= 8; } for (int regionX = 2; regionX <= MAX_REGION_X - regionsDistanceX; regionX++) skip: for (int regionY = 2; regionY <= MAX_REGION_Y - regionsDistanceY; regionY++) { for (int checkRegionX = regionX - 1; checkRegionX <= regionX + regionsDistanceX; checkRegionX++) for (int checkRegionY = regionY - 1; checkRegionY <= regionY + regionsDistanceY; checkRegionY++) { int regionId = MapUtils.encode(Structure.REGION, checkRegionX, checkRegionY); if (regionReserved(regionId)) continue skip; } reserveRegions(regionX, regionY, regionsDistanceX, regionsDistanceY, false); return MapUtils.encode(Structure.CHUNK, regionX << 3, regionY << 3); } return -1; } private static void destroyMap(int chunkX, int chunkY, int width, int height) { int fromRegionX = chunkX / 8; int fromRegionY = chunkY / 8; final int fromWidth = width; final int fromHeight = height; int regionsDistanceX = 2; while (width > 8) { regionsDistanceX += 1; width -= 8; } int regionsDistanceY = 2; while (height > 8) { regionsDistanceY += 1; height -= 8; } int baseChunk = MapUtils.encode(Structure.CHUNK, chunkX, chunkY, 0); for (int plane = 0; plane < 4 * Chunk.PLANE_INC; plane += Chunk.PLANE_INC) for (int x = 0; x <= fromWidth * Chunk.X_INC; x += Chunk.X_INC) for (int y = 0; y <= fromHeight; y++) destroyChunk(baseChunk + x + y + plane); reserveRegions(fromRegionX, fromRegionY, regionsDistanceX, regionsDistanceY, true); } static void destroyMap(Instance ref, CompletableFuture future) { if (ref.getChunkBase() == null) { future.complete(true); return; } AsyncTaskExecutor.executeWorldThreadSafe(""InstanceBuilder.destroyMap"", future, 30, () -> destroyMap(ref.getBaseChunkX(), ref.getBaseChunkY(), ref.getWidth(), ref.getHeight())); } static void copyChunk(Instance ref, int localChunkX, int localChunkY, int plane, int fromChunkX, int fromChunkY, int fromPlane, int rotation, CompletableFuture future) { AsyncTaskExecutor.executeWorldThreadSafe(""InstanceBuilder.copyChunk"", future, 30, () -> { InstancedChunk chunk = createAndReserveChunk(fromChunkX, fromChunkY, fromPlane, ref.getBaseChunkX() + localChunkX, ref.getBaseChunkY() + localChunkY, plane, rotation); chunk.clearCollisionData(); chunk.loadMap(ref.isCopyNpcs()); }); } public static InstancedChunk createAndReserveChunk(int fromChunkX, int fromChunkY, int fromPlane, int toChunkX, int toChunkY, int toPlane, int rotation) { return createAndReserveChunk(MapUtils.encode(Structure.CHUNK, fromChunkX, fromChunkY, fromPlane), MapUtils.encode(Structure.CHUNK, toChunkX, toChunkY, toPlane), rotation); } static void copy2x2ChunkSquare(Instance ref, int chunkX, int chunkY, int fromChunkX, int fromChunkY, int rotation, int[] planes, CompletableFuture future) { AsyncTaskExecutor.executeWorldThreadSafe(""InstanceBuilder.copy2x2ChunkSquare"", future, 30, () -> { List chunks = copy2x2ChunkSquare(fromChunkX, fromChunkY, ref.getBaseChunkX() + chunkX, ref.getBaseChunkY() + chunkY, rotation, planes); for (InstancedChunk chunk : chunks) { chunk.clearCollisionData(); chunk.loadMap(ref.isCopyNpcs()); } }); } private static List copyChunkRect(int fromRegionX, int fromRegionY, int toRegionX, int toRegionY, int width, int height, int rotation, int... planes) { List chunks = new ObjectArrayList<>(); int[][] offsets = getOffsets(width, height, rotation); for (int plane : planes) { for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { int xOffset = offsets[y][x] % width; int yOffset = offsets[y][x] / width; chunks.add(createAndReserveChunk(fromRegionX + x, fromRegionY + y, plane, toRegionX + xOffset, toRegionY + yOffset, plane, rotation)); } } } return chunks; } private static int[][] getOffsets(int width, int height, int rotation) { int[][] offsets = new int[height][width]; for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { int index = y * width + x; switch (rotation) { case 1 -> offsets[x][height - 1 - y] = index; case 2 -> offsets[height - 1 - y][width - 1 - x] = index; case 3 -> offsets[width - 1 - x][y] = index; default -> offsets[y][x] = index; } } } return offsets; } private static List copy2x2ChunkSquare(int fromChunkBaseX, int fromChunkBaseY, int toChunkBaseX, int toChunkBaseY, int rotation, int... planes) { return copyChunkRect(fromChunkBaseX, fromChunkBaseY, toChunkBaseX, toChunkBaseY, 2, 2, rotation, planes); } static void clearChunk(Instance ref, int localChunkX, int localChunkY, int plane, CompletableFuture future) { AsyncTaskExecutor.executeWorldThreadSafe(""InstanceBuilder.clearChunk"", future, 30, () -> cutChunk(ref.getBaseChunkX()+localChunkX, ref.getBaseChunkY()+localChunkY, plane)); } private static void cutChunk(int toChunkX, int toChunkY, int toPlane) { InstancedChunk chunk = createAndReserveChunk(0, 0, 0, toChunkX, toChunkY, toPlane, 0); chunk.clearCollisionData(); chunk.loadMap(false); } private static List repeatMap(int toChunkX, int toChunkY, int widthChunks, int heightChunks, int fromChunkX, int fromChunkY, int fromPlane, int rotation, int... toPlanes) { List chunks = new ObjectArrayList<>(); for (int plane : toPlanes) { for (int xOffset = 0; xOffset < widthChunks; xOffset++) { for (int yOffset = 0; yOffset < heightChunks; yOffset++) { chunks.add(createAndReserveChunk( MapUtils.encode(Structure.CHUNK, fromChunkX, fromChunkY, fromPlane), MapUtils.encode(Structure.CHUNK, toChunkX + xOffset, toChunkY + yOffset, plane), rotation )); } } } return chunks; } static void clearMap(Instance ref, int localChunkX, int localChunkY, int width, int height, int[] planes, CompletableFuture future) { AsyncTaskExecutor.executeWorldThreadSafe(""InstanceBuilder.clearMap"", future, 30, () -> cutMap(ref.getBaseChunkX()+localChunkX, ref.getBaseChunkY()+localChunkY, width, height, planes)); } private static void cutMap(int toChunkX, int toChunkY, int widthChunks, int heightChunks, int... toPlanes) { List chunks = repeatMap(toChunkX, toChunkY, widthChunks, heightChunks, 0, 0, 0, 0, toPlanes); for (InstancedChunk chunk : chunks) { chunk.clearCollisionData(); chunk.loadMap(false); } } static void copyMap(Instance ref, int localChunkX, int localChunkY, int fromChunkX, int fromChunkY, int size, CompletableFuture future) { AsyncTaskExecutor.executeWorldThreadSafe(""InstanceBuilder.copyMap"", future, 30, () -> copyMap(fromChunkX, fromChunkY, ref.getBaseChunkX()+localChunkX, ref.getBaseChunkY()+localChunkY, size, ref.isCopyNpcs())); } private static void copyMap(int fromRegionX, int fromRegionY, int toRegionX, int toRegionY, int size, boolean copyNpcs) { int[] planes = new int[4]; for (int plane = 1; plane < 4; plane++) planes[plane] = plane; copyMap(fromRegionX, fromRegionY, toRegionX, toRegionY, size, planes, planes, copyNpcs); } @SuppressWarnings(""unused"") private static void copyMap(int fromRegionX, int fromRegionY, int toRegionX, int toRegionY, int widthRegions, int heightRegions, boolean copyNpcs) { int[] planes = new int[4]; for (int plane = 1; plane < 4; plane++) planes[plane] = plane; copyMap(fromRegionX, fromRegionY, toRegionX, toRegionY, widthRegions, heightRegions, planes, planes, copyNpcs); } private static void copyMap(int fromRegionX, int fromRegionY, int toRegionX, int toRegionY, int size, int[] fromPlanes, int[] toPlanes, boolean copyNpcs) { copyMap(fromRegionX, fromRegionY, toRegionX, toRegionY, size, size, fromPlanes, toPlanes, copyNpcs); } static void copyMap(Instance ref, int localChunkX, int localChunkY, int[] planes, int fromChunkX, int fromChunkY, int[] fromPlanes, int width, int height, boolean copyNpcs, CompletableFuture future) { AsyncTaskExecutor.executeWorldThreadSafe(""InstanceBuilder.copyMap"", future, 30, () -> copyMap(fromChunkX, fromChunkY, ref.getBaseChunkX()+localChunkX, ref.getBaseChunkY()+localChunkY, width, height, fromPlanes, planes, copyNpcs)); } private static void copyMap(int fromChunkX, int fromChunkY, int toChunkX, int toChunkY, int width, int height, int[] fromPlanes, int[] toPlanes, boolean copyNpcs) { if (fromPlanes.length != toPlanes.length) throw new RuntimeException(""PLANES LENGTH ISNT SAME OF THE NEW PLANES ORDER!""); for (int planeIdx = 0; planeIdx < fromPlanes.length; planeIdx++) { for (int xOffset = 0; xOffset < width; xOffset++) for (int yOffset = 0; yOffset < height; yOffset++) { InstancedChunk instance = createAndReserveChunk( MapUtils.encode(Structure.CHUNK, fromChunkX + xOffset, fromChunkY + yOffset, fromPlanes[planeIdx]), MapUtils.encode(Structure.CHUNK, toChunkX + xOffset, toChunkY + yOffset, toPlanes[planeIdx]), 0 ); instance.loadMap(copyNpcs); } } } public static int getReservedRegionCount() { return RESERVED_REGIONS.size(); } }" "package com.rs.game.map.instance; public class InstancedChunk extends Chunk { private final int fromChunkId; private final int fromChunkX; private final int fromChunkY; private final int fromPlane; private int rotation; private final List npcSpawns = ObjectLists.synchronize(new ObjectArrayList<>()); public InstancedChunk(int fromChunkId, int toChunkId, int rotation) { super(toChunkId); loadingMapData = true; loadedMapData = true; loadingSpawnData = true; loadedSpawnData = true; this.fromChunkId = fromChunkId; int[] coords = MapUtils.decode(Structure.CHUNK, fromChunkId); this.fromChunkX = coords[0]; this.fromChunkY = coords[1]; this.fromPlane = coords[2]; this.rotation = rotation; } @Override public void checkLoaded() { } public void loadMap(boolean copyNpcs) { Chunk realChunk = ChunkManager.getChunk(getFromChunkId(), true); setMapDataLoaded(); for (int x = 0;x < 8;x++) { for (int y = 0;y < 8;y++) { Tile original = Tile.of(getOriginalBaseX()+x, getOriginalBaseY()+y, fromPlane); int[] coords = transform(x, y, rotation); Tile toTile = Tile.of(getBaseX()+coords[0], getBaseY()+coords[1], getPlane()); WorldCollision.addFlag(toTile, WorldCollision.getFlags(original) & (ClipFlag.PFBW_FLOOR.flag | ClipFlag.UNDER_ROOF.flag)); } } for (WorldObject orig : realChunk.getBaseObjects()) { GameObject adjusted = new GameObject(orig); int[] coords = InstancedChunk.transform(orig.getTile().getXInChunk(),orig.getTile().getYInChunk(), rotation, orig.getDefinitions().getSizeX(), orig.getDefinitions().getSizeY(), orig.getRotation()); adjusted.setTile(Tile.of(getBaseX() + coords[0], getBaseY() + coords[1], getPlane())); adjusted.setRotation((adjusted.getRotation() + rotation) & 0x3); ChunkManager.getChunk(adjusted.getTile().getChunkId()).addBaseObject(adjusted); } if (copyNpcs) { List npcSpawns = NPCSpawns.getSpawnsForChunk(getFromChunkId()); if (npcSpawns != null) { for (NPCSpawn npcSpawn : npcSpawns) { int[] coords = InstancedChunk.transform(npcSpawn.getTile().getXInChunk(), npcSpawn.getTile().getYInChunk(), rotation, npcSpawn.getDefs().size, npcSpawn.getDefs().size, 0); npcSpawn.spawnAtCoords(Tile.of(getBaseX() + coords[0], getBaseY() + coords[1], getPlane()), npcSpawn.getDir() == null ? null : Direction.rotateClockwise(npcSpawn.getDir(), rotation*2)); } } } } public static int[] transform(int localX, int localY, int rotation) { return switch(rotation) { default -> new int[] { localX, localY }; case 1 -> new int[] { localY, 7 - localX }; case 2 -> new int[] { 7 - localX, 7 - localY }; case 3 -> new int[] { 7 - localY, localX }; }; } public static int[] transform(int localX, int localY, int mapRotation, int sizeX, int sizeY, int objectRotation) { if ((objectRotation & 0x1) == 1) { int prevSizeX = sizeX; sizeX = sizeY; sizeY = prevSizeX; } return switch(mapRotation) { default -> new int[] { localX, localY }; case 1 -> new int[] { localY, 7 - localX - (sizeX - 1) }; case 2 -> new int[] { 7 - localX - (sizeX - 1), 7 - localY - (sizeY - 1) }; case 3 -> new int[] { 7 - localY - (sizeY - 1), localX }; }; } @Override public void destroy() { clearCollisionData(); super.destroy(); for (NPC npc : npcSpawns) { if (npc != null) npc.permanentlyDelete(); } } @Override public int getRotation() { return rotation; } public void setRotation(int rotation) { this.rotation = rotation; } public int getFromChunkId() { return fromChunkId; } public int getRenderChunkX() { return fromChunkX; } public int getRenderChunkY() { return fromChunkY; } public int getRenderPlane() { return fromPlane; } public int getOriginalBaseX() { return fromChunkX << 3; } public int getOriginalBaseY() { return fromChunkY << 3; } }" "package com.rs.game.model; public class WorldProjectile extends Projectile { public WorldProjectile(Object from, Object to, int spotAnimId, int startHeight, int endHeight, int startTime, int endTime, int slope, int angle, Consumer task) { super(switch(from) { case Tile t -> t; case Entity e -> e.getMiddleTile(); case GameObject g -> g.getTile(); default -> throw new IllegalArgumentException(""Unexpected value: "" + from); }, from instanceof Entity e ? e.getIndex() : -1, switch(to) { case Tile t -> t; case Entity e -> e.getMiddleTile(); case GameObject g -> g.getTile(); default -> throw new IllegalArgumentException(""Unexpected value: "" + to); }, to instanceof Entity e ? e.getIndex() : -1, spotAnimId, startHeight, endHeight, startTime, endTime, slope, angle); Entity fromE = from instanceof Entity e ? e : null; sourceId = fromE == null ? 0 : (fromE instanceof Player ? -(fromE.getIndex() + 1) : fromE.getIndex() + 1); Entity toE = to instanceof Entity e ? e : null; lockOnId = toE == null ? 0 : (toE instanceof Player ? -(toE.getIndex() + 1) : toE.getIndex() + 1); if (task != null) WorldTasks.schedule(getTaskDelay(), () -> task.accept(WorldProjectile.this)); if (from instanceof Entity e) else if (from instanceof GameObject go) { ObjectDefinitions defs = go.getDefinitions(); } else if (to instanceof Entity e) toSizeX = toSizeY = e.getSize(); else if (to instanceof GameObject go) { ObjectDefinitions defs = go.getDefinitions(); toSizeX = defs.getSizeX(); toSizeY = defs.getSizeY(); } else toSizeX = toSizeY = 1; toSizeX -= 1; toSizeY -= 1; } public int getTaskDelay() { return Utils.clampI(Utils.projectileTimeToCycles(getEndTime()) - 1, 0, Integer.MAX_VALUE); } }" "package com.rs.game.model.entity; public class BodyGlow { private int time; private final int redAdd; private final int greenAdd; private final int blueAdd; private final int scalar; public BodyGlow(int time, int color1, int color2, int color3, int color4) { this.time = time; redAdd = color1; greenAdd = color2; blueAdd = color3; scalar = color4; } public static BodyGlow generateRandomBodyGlow(int time) { return new BodyGlow(time, Utils.random(254), Utils.random(254), Utils.random(254), Utils.random(254)); } public static BodyGlow GREEN(int time) { return new BodyGlow(time, 20, 20, 110, 150); } public static BodyGlow BLUE(int time) { return new BodyGlow(time, 92, 44, 126, 130); } public int getTime() { return time; } public void setTime(int time) { this.time = time; } public int getRedAdd() { return redAdd; } public int getGreenAdd() { return greenAdd; } public int getScalar() { return scalar; } public int getBlueAdd() { return blueAdd; } }" "package com.rs.game.model.entity; public abstract class Entity { public enum MoveType { WALK(1), RUN(2), TELE(127); private final int id; MoveType(int id) { this.id = id; } public int getId() { return id; } } // transient stuff private transient int index; private final String uuid; private transient int sceneBaseChunkId; private transient int lastChunkId; private transient boolean forceUpdateEntityRegion; private transient boolean nextTickUnlock; private transient Set mapChunkIds; protected transient GenericAttribMap temporaryAttributes; protected transient GenericAttribMap nonsavingVars; private transient int faceAngle; private transient Tile lastTile; private transient Tile tileBehind; private transient Tile nextTile; public transient Walk walkRequest; private transient boolean walkedThisTick; private transient Direction nextWalkDirection; private transient Direction nextRunDirection; private transient Tile nextFaceTile; private transient Tile fixedFaceTile; private transient boolean teleported; private transient ConcurrentLinkedQueue walkSteps; protected transient RouteEvent routeEvent; private transient ActionManager actionManager; private transient InteractionManager interactionManager; private transient CollisionStrategy collisionStrategy = CollisionStrategyType.NORMAL.getStrategy(); private transient long lockDelay; // used for doors and stuff like that private transient BodyGlow nextBodyGlow; private transient ConcurrentLinkedQueue receivedHits; private transient Map receivedDamage; private transient boolean finished; private transient long tickCounter = 0; // entity masks private transient int bas = -1; private transient Animation nextAnimation; private transient SpotAnim nextSpotAnim1; private transient SpotAnim nextSpotAnim2; private transient SpotAnim nextSpotAnim3; private transient SpotAnim nextSpotAnim4; private transient ModelRotator bodyModelRotator; private transient ArrayList nextHits; private transient ArrayList nextHitBars; private transient ForceMovement nextForceMovement; private transient ForceTalk nextForceTalk; private transient int nextFaceEntity; private transient int lastFaceEntity; private transient Entity attackedBy; // whos attacking you, used for single protected transient long attackedByDelay; // delay till someone else can attack you protected transient long timeLastHit; private transient boolean multiArea; private transient boolean hasNearbyInstancedChunks; private transient long lastAnimationEnd; private transient boolean forceMultiArea; private transient long findTargetDelay; // saving stuff private int hitpoints; private Tile tile; private RegionSize regionSize; protected MoveType moveType = MoveType.WALK; private final Poison poison; private Map effects = new HashMap<>(); private transient AsyncTaskScheduler asyncTasks = new AsyncTaskScheduler(); private transient TaskManager tasks = new TaskManager(); // creates Entity and saved classes public Entity(Tile tile) { this.tile = Tile.of(tile); this.uuid = UUID.randomUUID().toString(); poison = new Poison(); } public void clearEffects() { if (effects == null) return; Map persisted = new HashMap<>(); for (Effect effect : effects.keySet()) { if (effect == null) continue; if (!effect.isRemoveOnDeath()) persisted.put(effect, effects.get(effect)); } effects = persisted; } public boolean hasEffect(Effect effect) { return effects != null && effects.containsKey(effect); } public long getEffectTicks(Effect effect) { return effects != null && effects.containsKey(effect) ? effects.get(effect) : 0; } public void addEffect(Effect effect, long ticks) { if (effects == null) effects = new HashMap<>(); effects.put(effect, ticks); effect.apply(this); effect.tick(this, ticks); } public void extendEffect(Effect effect, long ticks) { if (effects == null) effects = new HashMap<>(); if (effects.containsKey(effect)) effects.put(effect, effects.get(effect) + ticks); else addEffect(effect, ticks); } public void removeEffect(Effect effect) { if (effects == null) return; if (effect.sendWarnings() && this instanceof Player p) p.sendMessage(effect.getExpiryMessage()); effects.remove(effect); effect.expire(this); } public void removeEffects(Effect... effects) { for (Effect e : effects) removeEffect(e); } public void walkToAndExecute(Tile startTile, Runnable event) { setRouteEvent(new RouteEvent(startTile, event)); } private void processEffects() { if (effects == null) return; Set expired = new HashSet<>(); for (Effect effect : effects.keySet()) { if (effect == null) continue; long time = effects.get(effect); time--; effect.tick(this, time); if (time == 50 && effect.sendWarnings() && this instanceof Player p) p.sendMessage(effect.get30SecWarning()); if (time <= 0) { if (effect.sendWarnings() && this instanceof Player p) p.sendMessage(effect.getExpiryMessage()); expired.add(effect); } else effects.put(effect, time); } for (Effect e : expired) { effects.remove(e); e.expire(this); } } public boolean isBehind(Entity other) { if (other.getFaceAngle() <= 2048 || other.getFaceAngle() >= 14336) if (getY() > other.getY()) return true; if (other.getFaceAngle() <= 10240 && other.getFaceAngle() >= 6144) if (getY() < other.getY()) return true; if (other.getFaceAngle() <= 6144 && other.getFaceAngle() >= 2048) if (getX() > other.getX()) return true; if (other.getFaceAngle() <= 14336 && other.getFaceAngle() >= 10240) return getX() < other.getX(); return false; } public Tile getBackfacingTile() { int[] backFaceDirs = Utils.getBackFace(faceAngle); return transform(backFaceDirs[0], backFaceDirs[1], 0); } public Tile getBackfacingTile(int distance) { int[] backFaceDirs = Utils.getBackFace(faceAngle); return transform(backFaceDirs[0] * distance, backFaceDirs[1] * distance, 0); } public Tile getFrontfacingTile() { int[] frontFaceDirs = Utils.getFrontFace(faceAngle); return transform(frontFaceDirs[0], frontFaceDirs[1], 0); } public Tile getFrontfacingTile(int distance) { int[] frontFaceDirs = Utils.getFrontFace(faceAngle); return transform(frontFaceDirs[0] * distance, frontFaceDirs[1] * distance, 0); } public boolean inArea(int a, int b, int c, int d) { return getX() >= a && getY() >= b && getX() <= c && getY() <= d; } public Tile getTileInScene(int x, int y) { Tile tile = Tile.of(x, y, getPlane()); return Tile.of(tile.getXInScene(getSceneBaseChunkId()), tile.getYInScene(getSceneBaseChunkId()), getPlane()); } public int getSceneX(int targetX) { return Tile.of(targetX, 0, 0).getXInScene(getSceneBaseChunkId()); } public int getSceneY(int targetY) { return Tile.of(0, targetY, 0).getYInScene(getSceneBaseChunkId()); } public final void initEntity() { mapChunkIds = IntSets.synchronize(new IntOpenHashSet()); walkSteps = new ConcurrentLinkedQueue<>(); receivedHits = new ConcurrentLinkedQueue<>(); receivedDamage = new ConcurrentHashMap<>(); temporaryAttributes = new GenericAttribMap(); nonsavingVars = new GenericAttribMap(); nextHits = new ArrayList<>(); nextHitBars = new ArrayList<>(); actionManager = new ActionManager(this); tasks = new TaskManager(); asyncTasks = new AsyncTaskScheduler(); interactionManager = new InteractionManager(this); nextWalkDirection = nextRunDirection = null; lastFaceEntity = -1; nextFaceEntity = -2; bas = -1; if (!(this instanceof NPC)) faceAngle = 2; poison.setEntity(this); if (moveType == null) moveType = MoveType.WALK; } public int getClientIndex() { return index + (this instanceof Player ? 32768 : 0); } public void applyHit(Hit hit) { applyHit(hit, -1); } public void applyHit(Hit hit, int delay) { applyHit(hit, delay, null); } public void applyHit(Hit hit, int delay, Runnable onHit) { if (isDead()) { hit.setDamage(0); return; } handlePreHit(hit); if (hit.getSource() != null) hit.getSource().handlePreHitOut(this, hit); if (hit.getSource() instanceof Familiar f) { hit.setSource(f.getOwner()); PlayerCombatKt.addXpFamiliar(f.getOwner(), this, f.getPouch().getXpType(), hit); } if (delay < 0) { handlePostHit(hit); if (onHit != null) onHit.run(); receivedHits.add(hit); } else (hit.getSource() != null ? hit.getSource().getTasks() : tasks).schedule(delay, () -> { if (isDead()) { hit.setDamage(0); return; } if (onHit != null) onHit.run(); receivedHits.add(hit); }); } public abstract void handlePreHit(Hit hit); public abstract void handlePreHitOut(Entity target, Hit hit); public void reset(boolean attributes) { setHitpoints(getMaxHitpoints()); receivedHits.clear(); resetCombat(); walkSteps.clear(); poison.reset(); clearPendingTasks(); resetReceivedDamage(); clearEffects(); if (attributes) temporaryAttributes.clear(); } public void reset() { reset(true); } public void resetCombat() { attackedBy = null; attackedByDelay = 0; removeEffects(Effect.FREEZE, Effect.FREEZE_BLOCK); } public void processReceivedHits() { if (lockDelay > tickCounter) return; if (this instanceof Player p) if (p.getEmotesManager().isAnimating()) return; Hit hit; int count = 0; while ((hit = receivedHits.poll()) != null && count++ < 10) processHit(hit); } public boolean hasPendingHits() { return !receivedHits.isEmpty(); } public void sendSoulSplit(Hit hit, Entity user) { if (hit.getDamage() > 0) World.sendProjectile(user, this, 2263, 11, 11, 0, -1, 0, 0); user.heal(hit.getDamage() / 5); if (user instanceof Player p) p.incrementCount(""Health soulsplitted back"", hit.getDamage() / 5); if (this instanceof Player p) p.getPrayer().drainPrayer((double) hit.getDamage() / 5); WorldTasks.schedule(new Task() { @Override public void run() { setNextSpotAnim(new SpotAnim(2264)); if (hit.getDamage() > 0) World.sendProjectile(Entity.this, user, 2263, 11, 11, 0, -1, 0, 0); } }, 0); } protected void processHit(Hit hit) { if (isDead()) return; if (hit.getSource() != this) refreshTimeLastHit(); removeHitpoints(hit); nextHits.add(hit); if (nextHitBars.isEmpty()) addHitBars(); } public void fakeHit(Hit hit) { nextHits.add(hit); if (nextHitBars.isEmpty()) addHitBars(); } public Sound sound(Entity playTo, Sound sound, boolean alsoAmbient) { if (sound.getId() == -1) return sound; //Logger.info(Entity.class, ""sound"", this + "" playing "" + sound.getType() + "" sound to "" + playTo + "", "" + alsoAmbient + "" -> [id: "" + sound.getId() + "", rad: "" + sound.getRadius() + "", vol: "" + sound.getVolume() + ""]""); if (this instanceof Player player) player.addSound(sound); if (playTo instanceof Player player && this != playTo) player.addSound(sound); if (alsoAmbient) ChunkManager.getChunk(getChunkId()).addSound(tile, sound); return sound; } public Sound sound(Entity playTo, int soundId, int delay, Sound.SoundType type, int radius, boolean alsoAmbient) { return sound(playTo, new Sound(soundId, delay, type).radius(radius), alsoAmbient); } public Sound soundEffect(Entity playTo, int soundId, int delay, boolean alsoAmbient) { return sound(playTo, soundId, delay, Sound.SoundType.EFFECT, 10, alsoAmbient); } public Sound soundEffect(Entity playTo, int soundId, boolean alsoAmbient) { return soundEffect(playTo, soundId, 0, alsoAmbient); } public Sound voiceEffect(Entity playTo, int voiceId, int delay, boolean alsoAmbient) { return sound(playTo, voiceId, delay, Sound.SoundType.VOICE, 10, alsoAmbient); } public Sound voiceEffect(Entity playTo, int voiceId, boolean alsoAmbient) { return voiceEffect(playTo, voiceId, 0, alsoAmbient); } public Sound sound(int soundId, int delay, Sound.SoundType type, boolean alsoAmbient) { return sound(null, new Sound(soundId, delay, type), alsoAmbient); } public Sound soundEffect(int soundId, int delay, boolean alsoAmbient) { return sound(null, soundId, delay, Sound.SoundType.EFFECT, 10, alsoAmbient); } public Sound soundEffect(int soundId, boolean alsoAmbient) { return soundEffect(null, soundId, 0, alsoAmbient); } public Sound voiceEffect(int voiceId, int delay, boolean alsoAmbient) { return sound(null, voiceId, delay, Sound.SoundType.VOICE, 10, alsoAmbient); } public Sound voiceEffect(int voiceId, boolean alsoAmbient) { return voiceEffect(null, voiceId, 0, alsoAmbient); } public void addHitBars() { nextHitBars.add(new EntityHitBar(this)); } public void resetReceivedHits() { nextHits.clear(); receivedHits.clear(); } public void removeHitpoints(Hit hit) { if (isDead() || hit.getLook() == HitLook.ABSORB_DAMAGE) return; if (hit.getLook() == HitLook.HEALED_DAMAGE) { heal(hit.getDamage()); return; } if (hit.getDamage() > hitpoints) hit.setDamage(hitpoints); addReceivedDamage(hit.getSource(), hit.getDamage()); setHitpoints(hitpoints - hit.getDamage()); if (this instanceof Player p) if (p.getNSV().getB(""godMode"")) setHitpoints(getMaxHitpoints()); if (hitpoints <= 0) sendDeath(hit.getSource()); else if (this instanceof Player player) { if (player.getEquipment().getRingId() == 2550) if (hit.getSource() != null && hit.getSource() != player && (hit.getLook() == HitLook.MELEE_DAMAGE || hit.getLook() == HitLook.RANGE_DAMAGE || hit.getLook() == HitLook.MAGIC_DAMAGE)) hit.getSource().applyHit(new Hit(player, (int) (hit.getDamage() * 0.1), HitLook.REFLECTED_DAMAGE)); if (player.getPrayer().hasPrayersOn()) if ((hitpoints < player.getMaxHitpoints() * 0.1) && player.getPrayer().active(Prayer.REDEMPTION)) { player.soundEffect(hit.getSource(), 2681, true); setNextSpotAnim(new SpotAnim(436)); setHitpoints((int) (hitpoints + player.getSkills().getLevelForXp(Constants.PRAYER) * 2.5)); player.getPrayer().setPoints(0); } if (player.getEquipment().getAmuletId() == 11090 && player.getHitpoints() <= player.getMaxHitpoints() * 0.2) { player.heal((int) (player.getMaxHitpoints() * 0.3)); player.getEquipment().deleteItem(11090, 1); player.getAppearance().generateAppearanceData(); player.sendMessage(""Your pheonix necklace heals you, but is destroyed in the process.""); } if (player.getHitpoints() <= (player.getMaxHitpoints() * 0.1) && player.getEquipment().getRingId() == 2570) Magic.sendItemTeleportSpell(player, true, 9603, 1684, 4, Settings.getConfig().getPlayerRespawnTile(), () -> { player.getEquipment().deleteSlot(Equipment.RING); player.getEquipment().refresh(Equipment.RING); player.sendMessage(""Your ring of life saves you and is destroyed in the process.""); }); } } public void resetReceivedDamage() { receivedDamage.clear(); } public void removeDamage(Entity entity) { receivedDamage.remove(entity); } public void entityFollow(Entity target, boolean intelligent, int distance) { if (!target.hasWalkSteps() && WorldUtil.collides(getX(), getY(), getSize(), target.getX(), target.getY(), target.getSize())) { resetWalkSteps(); if (!addWalkSteps(target.getX() + target.getSize(), getY())) { resetWalkSteps(); if (!addWalkSteps(target.getX() - getSize(), getY())) { resetWalkSteps(); if (!addWalkSteps(getX(), target.getY() + target.getSize())) { resetWalkSteps(); if (!addWalkSteps(getX(), target.getY() - getSize())) return; } } } return; } if (target.getSize() == 1 && getSize() == 1 && Math.abs(getX() - target.getX()) == 1 && Math.abs(getY() - target.getY()) == 1 && !target.hasWalkSteps()) { if (!addWalkSteps(target.getX(), getY(), 1, true)) addWalkSteps(getX(), target.getY(), 1, true); return; } if (!WorldUtil.isInRange(this, target, distance) || !lineOfSightTo(target, distance == 0)) { if (!hasWalkSteps() || target.hasWalkSteps()) { resetWalkSteps(); calcFollow(target, getRun() ? 2 : 1, true); } } else resetWalkSteps(); } public boolean calcFollow(Object target, boolean inteligent) { return calcFollow(target, -1, inteligent); } public abstract boolean canMove(Direction dir); public void handlePostHit(Hit hit) { } public boolean calcFollow(Object target, int maxStepsCount, boolean intelligent) { if (intelligent) { Route route = RouteFinderKt.routeEntityTo(this, target, maxStepsCount < 0 ? 25 : maxStepsCount); if (route.getFailed()) return false; // if (route.getStepCount() == 0) //TODO why did I add this? // return DumbRouteFinder.addDumbPathfinderSteps(this, target, getClipType()); RouteFinderKt.addSteps(this, route,true, maxStepsCount); return true; } return DumbRouteFinder.addDumbPathfinderSteps(this, target, getCollisionStrategy()); } public Player getMostDamageReceivedSourcePlayer() { Player player = null; int damage = -1; for (Entity source : receivedDamage.keySet()) { if (!(source instanceof Player)) continue; Integer d = receivedDamage.get(source); if (d == null || source.hasFinished()) { receivedDamage.remove(source); continue; } if (d > damage) { player = (Player) source; damage = d; } } return player; } public void processReceivedDamage() { if (isDead()) return; for (Entity source : receivedDamage.keySet()) { Integer damage = receivedDamage.get(source); if (damage == null || source.hasFinished()) { receivedDamage.remove(source); continue; } damage--; if (damage == 0) { receivedDamage.remove(source); continue; } receivedDamage.put(source, damage); } } public void addReceivedDamage(Entity source, int amount) { if (source == null) return; Integer damage = receivedDamage.get(source); damage = damage == null ? amount : damage + amount; if (source instanceof Familiar fs) { if (damage < 0) receivedDamage.remove(fs.getOwner()); else receivedDamage.put(fs.getOwner(), damage); } else if (damage < 0) receivedDamage.remove(source); else receivedDamage.put(source, damage); } public void heal(int ammount) { heal(ammount, 0); } public void heal(int ammount, int extra) { setHitpoints((hitpoints + ammount) >= (getMaxHitpoints() + extra) ? (getMaxHitpoints() + extra) : (hitpoints + ammount)); } public boolean hasWalkSteps() { return !walkSteps.isEmpty() || walkedThisTick; } // public boolean isMoving() { // return hasWalkSteps() || walkedThisTick; // } public abstract void sendDeath(Entity source); public void updateAngle(Tile base, int sizeX, int sizeY) { Tile from = nextTile != null ? nextTile : this.getTile(); int srcX = (from.getX() * 512) + (getSize() * 256); int srcY = (from.getY() * 512) + (getSize() * 256); int dstX = (base.getX() * 512) + (sizeX * 256); int dstY = (base.getY() * 512) + (sizeY * 256); int deltaX = srcX - dstX; int deltaY = srcY - dstY; faceAngle = deltaX != 0 || deltaY != 0 ? (int) (Math.atan2(deltaX, deltaY) * 2607.5945876176133) & 0x3FFF : 0; } public void processMovement() { NPC npc = this instanceof NPC ? (NPC) this : null; Player player = this instanceof Player ? (Player) this : null; lastTile = Tile.of(getTile()); if (lastFaceEntity >= 0) { Entity target = lastFaceEntity >= 32768 ? World.getPlayers().get(lastFaceEntity - 32768) : World.getNPCs().get(lastFaceEntity); if (target != null) { int size = target.getSize(); updateAngle(target.getTile(), size, size); } } nextWalkDirection = nextRunDirection = null; if (nextTile != null && nextTile.getX() > 32 && nextTile.getY() > 32) { tile = nextTile; tileBehind = getBackfacingTile(); nextTile = null; teleported = true; int deltaX = lastTile.getX() - this.getX(); int deltaY = lastTile.getY() - this.getY(); if (player != null && player.getTemporaryMoveType() == null && !(deltaX <= 14 && deltaX >= -14 && deltaY <= 14 && deltaY >= -14)) player.setTemporaryMoveType(MoveType.TELE); ChunkManager.updateChunks(this); if (needMapUpdate()) loadMapRegions(); resetWalkSteps(); return; } teleported = false; if (walkSteps.isEmpty()) return; walkedThisTick = true; if (player != null) { if (player.getEmotesManager().isAnimating()) return; if (player.getRunEnergy() <= 0.0 || player.isRunBlocked()) setRun(false); if (walkSteps.size() <= 1) player.setTemporaryMoveType(MoveType.WALK); } if (npc != null) if (npc.getDefinitions().movementType == MovementType.HALF_WALK) if (npc.switchWalkStep()) return; StepValidator step = new StepValidator(WorldCollision.INSTANCE.getAllFlags()); for (int stepCount = 0; stepCount < (moveType == MoveType.RUN ? 2 : 1); stepCount++) { WalkStep nextStep = getNextWalkStep(); if (nextStep == null) break; if (player != null) PluginManager.handle(new PlayerStepEvent(player, nextStep, Tile.of(getX() + nextStep.dir.dx, getY() + nextStep.dir.dy, getPlane()))); if ((nextStep.checkClip() && !step.canTravel(getPlane(), getX(), getY(), nextStep.dir.dx, nextStep.dir.dy, getSize(), 0, getCollisionStrategy())) || (nextStep.checkClip() && npc != null && !npc.checkNPCCollision(nextStep.dir)) || !canMove(nextStep.dir)) { resetWalkSteps(); break; } if (stepCount == 0) nextWalkDirection = nextStep.dir; else nextRunDirection = nextStep.dir; tileBehind = Tile.of(getTile()); moveLocation(nextStep.dir.dx, nextStep.dir.dy, 0); if (moveType == MoveType.RUN && stepCount == 0) { // fixes impossible steps TODO is this even necessary? WalkStep previewStep = previewNextWalkStep(); if (previewStep == null) break; int dx = nextStep.dir.dx + previewStep.dir.dx; int dy = nextStep.dir.dy + previewStep.dir.dy; if (Utils.getPlayerRunningDirection(dx, dy) == -1 && Utils.getPlayerWalkingDirection(dx, dy) == -1) break; } if (player != null) if (nextRunDirection != null) { player.drainRunEnergy((Math.min(player.getWeight(), 64) / 100.0) + 0.64); if (player.getRunEnergy() == 0.0) player.setRun(false); } } ChunkManager.updateChunks(this); if (needMapUpdate()) loadMapRegions(); } public WalkStep previewNextWalkStep() { WalkStep step = walkSteps.peek(); return step; } public void moveLocation(int xOffset, int yOffset, int planeOffset) { tile = tile.transform(xOffset, yOffset, planeOffset); faceAngle = Utils.getAngleTo(xOffset, yOffset); } private boolean needMapUpdate() { return needMapUpdate(getTile()); } public boolean needMapUpdate(Tile tile) { int[] baseChunk = MapUtils.decode(Structure.CHUNK, sceneBaseChunkId); // chunks length - offset. if within 16 tiles of border it updates map int limit = getMapSize().size / 8 - 2; int offsetX = tile.getChunkX() - baseChunk[0]; int offsetY = tile.getChunkY() - baseChunk[1]; return offsetX < 2 || offsetX >= limit || offsetY < 2 || offsetY >= limit; } public boolean addWalkSteps(int destX, int destY) { return addWalkSteps(destX, destY, -1, true); } public Tile getMiddleTile() { int size = getSize(); return size == 1 ? getTile() : Tile.of(getCoordFaceX(size), getCoordFaceY(size), getPlane()); } public boolean ignoreWallsWhenMeleeing() { return false; } private static final Set LOS_NPC_OVERRIDES = new HashSet<>(); private static final List> LOS_FUNCTION_OVERRIDES = new ArrayList<>(); public static void addLOSOverride(int npcId) { LOS_NPC_OVERRIDES.add(npcId); } public static void addLOSOverride(String npcName) { LOS_NPC_OVERRIDES.add(npcName); } public static void addLOSOverrides(int... npcIds) { for (int npcId : npcIds) addLOSOverride(npcId); } public static void addLOSOverrides(String... npcNames) { for (String npcName : npcNames) addLOSOverride(npcName); } public static void addLOSOverride(TriFunction func) { LOS_FUNCTION_OVERRIDES.add(func); } public boolean lineOfSightTo(Object target, boolean melee) { Tile tile = WorldUtil.targetToTile(target); int targSize = target instanceof Entity ? ((Entity) target).getSize() : 1; if (target instanceof NPC npc) { if (LOS_NPC_OVERRIDES.contains(npc.getId()) || LOS_NPC_OVERRIDES.contains(npc.getName())) return true; } for (TriFunction func : LOS_FUNCTION_OVERRIDES) if (func.apply(this, target, melee)) return true; if (melee && !(target instanceof Entity e && e.ignoreWallsWhenMeleeing())) return World.checkMeleeStep(this, this.getSize(), target, targSize) && World.hasLineOfSight(getMiddleTile(), getSize(), target instanceof Entity e ? e.getMiddleTile() : tile, targSize); return World.hasLineOfSight(getMiddleTile(), getSize(), target instanceof Entity e ? e.getMiddleTile() : tile, targSize); } public boolean addWalkSteps(final int destX, final int destY, int maxStepsCount) { return addWalkSteps(destX, destY, maxStepsCount, true, false); } public boolean addWalkSteps(final int destX, final int destY, int maxStepsCount, boolean clip) { return addWalkSteps(destX, destY, maxStepsCount, clip, false); } public boolean addWalkSteps(final int destX, final int destY, int maxStepsCount, boolean clip, boolean force) { int[] lastTile = getLastWalkTile(); int myX = lastTile[0]; int myY = lastTile[1]; int stepCount = 0; while (true) { stepCount++; if (myX < destX) myX++; else if (myX > destX) myX--; if (myY < destY) myY++; else if (myY > destY) myY--; if (!addWalkStep(myX, myY, lastTile[0], lastTile[1], clip, force)) return false; if (stepCount == maxStepsCount) return true; lastTile[0] = myX; lastTile[1] = myY; if (lastTile[0] == destX && lastTile[1] == destY) return true; } } private int[] getLastWalkTile() { Object[] steps = walkSteps.toArray(); if (steps.length == 0) return new int[] { getX(), getY() }; WalkStep step = (WalkStep) steps[steps.length - 1]; return new int[] {step.x, step.y}; } public boolean walkOneStep(int x, int y, boolean clipped) { return addWalkStep(getX() + x, getY() + y, getX(), getY(), clipped, false); } public boolean addWalkStep(int nextX, int nextY, int lastX, int lastY, boolean check) { return addWalkStep(nextX, nextY, lastX, lastY, check, true); } public boolean addWalkStep(int nextX, int nextY, int lastX, int lastY, boolean check, boolean force) { //World.sendSpotAnim(Tile.of(nextX, nextY, getPlane()), new SpotAnim(2000)); Direction dir = Direction.forDelta(nextX - lastX, nextY - lastY); StepValidator step = new StepValidator(WorldCollision.INSTANCE.getAllFlags()); if (dir == null) return false; if (!force && check && !step.canTravel(getPlane(), lastX, lastY, dir.dx, dir.dy, getSize(), 0, getCollisionStrategy()) || (check && this instanceof NPC n && !n.checkNPCCollision(dir)))// double return false; if (this instanceof Player player) if (!player.getControllerManager().checkWalkStep(lastX, lastY, nextX, nextY)) return false; walkSteps.add(new WalkStep(dir, nextX, nextY, check)); return true; } public ConcurrentLinkedQueue getWalkSteps() { return walkSteps; } public void resetWalkSteps() { walkSteps.clear(); } private WalkStep getNextWalkStep() { WalkStep step = walkSteps.poll(); return step; } public boolean restoreHitPoints() { int maxHp = getMaxHitpoints(); if (hitpoints > maxHp) { setHitpoints(hitpoints - 1); return true; } if (hitpoints < maxHp) { setHitpoints(hitpoints + 1); return true; } return false; } public boolean needMasksUpdate() { return nextBodyGlow != null || nextFaceEntity != -2 || nextAnimation != null || nextSpotAnim1 != null || nextSpotAnim2 != null || nextSpotAnim3 != null || nextSpotAnim4 != null || (nextWalkDirection == null && nextFaceTile != null) || fixedFaceTile != null || !nextHits.isEmpty() || !nextHitBars.isEmpty() || nextForceMovement != null || nextForceTalk != null || bodyModelRotator != null; } public boolean isDead() { return hitpoints <= 0; } public void resetMasks() { walkedThisTick = false; nextBodyGlow = null; nextAnimation = null; nextSpotAnim1 = null; nextSpotAnim2 = null; nextSpotAnim3 = null; nextSpotAnim4 = null; if (nextWalkDirection == null) nextFaceTile = null; if (bodyModelRotator == ModelRotator.RESET) bodyModelRotator = null; nextForceMovement = null; nextForceTalk = null; nextFaceEntity = -2; nextHits.clear(); nextHitBars.clear(); } public abstract void finish(); public abstract int getMaxHitpoints(); public void processEntity() { tickCounter++; if (walkRequest != null) { RouteFinderKt.walkRoute(this, RouteFinderKt.routeEntityWalkRequest(this, walkRequest, 25), true); walkRequest = null; } RouteEvent prevEvent = routeEvent; if (routeEvent != null && routeEvent.processEvent(this)) { if (routeEvent == prevEvent) routeEvent = null; } poison.processPoison(); processReceivedHits(); processReceivedDamage(); if (!isDead()) if (tickCounter % 10 == 0) restoreHitPoints(); processEffects(); interactionManager.process(); actionManager.process(); if (nextTickUnlock) { unlock(); nextTickUnlock = false; } } public void loadMapRegions() { loadMapRegions(getMapSize()); } public void loadMapRegions(RegionSize oldSize) { Player player = this instanceof Player p ? p : null; NPC npc = this instanceof NPC n ? n : null; Set old = player != null && mapChunkIds != null ? IntSets.synchronize(new IntOpenHashSet(mapChunkIds)) : null; if (player != null) ChunkManager.getUpdateZone(sceneBaseChunkId, oldSize).removePlayerWatcher(player.getIndex()); if (npc != null && npc.isLoadsUpdateZones()) ChunkManager.getUpdateZone(sceneBaseChunkId, oldSize).removeNPCWatcher(npc.getIndex()); mapChunkIds.clear(); if (player != null) player.getMapChunksNeedInit().clear(); hasNearbyInstancedChunks = false; int currChunkX = getChunkX(); int currChunkY = getChunkY(); int sceneChunkRadius = getMapSize().size / 16; int sceneBaseChunkX = (currChunkX - sceneChunkRadius); int sceneBaseChunkY = (currChunkY - sceneChunkRadius); if (sceneBaseChunkX < 0) sceneBaseChunkX = 0; if (sceneBaseChunkY < 0) sceneBaseChunkY = 0; sceneBaseChunkId = MapUtils.encode(Structure.CHUNK, sceneBaseChunkX, sceneBaseChunkY, 0); for (int planeOff = 0;planeOff < 4 * Chunk.PLANE_INC;planeOff += Chunk.PLANE_INC) { for (int chunkOffX = 0; chunkOffX <= sceneChunkRadius * Chunk.X_INC * 2; chunkOffX += Chunk.X_INC) { for (int chunkOffY = 0; chunkOffY <= sceneChunkRadius * 2; chunkOffY++) { int chunkId = sceneBaseChunkId + chunkOffX + chunkOffY + planeOff; Chunk chunk = ChunkManager.getChunk(chunkId, (npc != null && npc.isLoadsUpdateZones()) || player != null); if (chunk instanceof InstancedChunk) hasNearbyInstancedChunks = true; mapChunkIds.add(chunkId); if (old != null) { if (!old.contains(chunkId)) player.getMapChunksNeedInit().add(chunkId); old.remove(chunkId); } } } } if (player != null) ChunkManager.getUpdateZone(sceneBaseChunkId, oldSize).addPlayerWatcher(player.getIndex()); if (npc != null && npc.isLoadsUpdateZones()) ChunkManager.getUpdateZone(sceneBaseChunkId, oldSize).addNPCWatcher(npc.getIndex()); } public void setIndex(int index) { this.index = index; } public int getIndex() { return index; } public int getHitpoints() { return hitpoints; } public void setHitpoints(int hitpoints) { this.hitpoints = hitpoints; } public RegionSize getMapSize() { if (regionSize == null) regionSize = RegionSize.SIZE_104; return regionSize; } public void setMapSize(RegionSize size) { RegionSize oldSize = regionSize; regionSize = size; loadMapRegions(oldSize); } public Set getMapChunkIds() { return mapChunkIds; } /** * use .anim(id) instead */ @Deprecated() public void setNextAnimation(Animation nextAnimation) { if (nextAnimation != null && nextAnimation.getIds()[0] >= 0) lastAnimationEnd = World.getServerTicks() + AnimationDefinitions.getDefs(nextAnimation.getIds()[0]).getEmoteGameTicks(); this.nextAnimation = nextAnimation; } public void setNextAnimationNoPriority(Animation nextAnimation) { if (lastAnimationEnd > World.getServerTicks()) return; setNextAnimation(nextAnimation); } public Animation getNextAnimation() { return nextAnimation; } /** * Use .spotAnim(id) instead * @param nextSpotAnim */ @Deprecated public void setNextSpotAnim(SpotAnim nextSpotAnim) { if (nextSpotAnim == null) { if (nextSpotAnim4 != null) nextSpotAnim4 = null; else if (nextSpotAnim3 != null) nextSpotAnim3 = null; else if (nextSpotAnim2 != null) nextSpotAnim2 = null; else nextSpotAnim1 = null; } else { if (nextSpotAnim.equals(nextSpotAnim1) || nextSpotAnim.equals(nextSpotAnim2) || nextSpotAnim.equals(nextSpotAnim3) || nextSpotAnim.equals(nextSpotAnim4)) return; if (nextSpotAnim1 == null) nextSpotAnim1 = nextSpotAnim; else if (nextSpotAnim2 == null) nextSpotAnim2 = nextSpotAnim; else if (nextSpotAnim3 == null) nextSpotAnim3 = nextSpotAnim; else nextSpotAnim4 = nextSpotAnim; } } public void tele(Tile tile) { if (this instanceof Player player) player.setTemporaryMoveType(MoveType.TELE); move(tile); } public void tele(int x, int y, int plane) { tele(Tile.of(x, y, plane)); } public SpotAnim getNextSpotAnim1() { return nextSpotAnim1; } public SpotAnim getNextSpotAnim2() { return nextSpotAnim2; } public SpotAnim getNextSpotAnim3() { return nextSpotAnim3; } public SpotAnim getNextSpotAnim4() { return nextSpotAnim4; } public void setFaceAngle(int direction) { faceAngle = direction; } public int getFaceAngle() { return faceAngle; } public void setFinished(boolean finished) { this.finished = finished; } public boolean hasFinished() { return finished; } /** * This method will NOT teleport the player if the player is close to the destination tile. * @param tile */ public void move(Tile tile) { this.nextTile = Tile.of(tile); } public Tile getMoveTile() { return nextTile; } public boolean hasTeleported() { return teleported; } public Direction getNextWalkDirection() { return nextWalkDirection; } public Direction getNextRunDirection() { return nextRunDirection; } public void setRun(boolean run) { this.moveType = run ? MoveType.RUN : MoveType.WALK; } public boolean getRun() { return this.moveType == MoveType.RUN; } public Tile getNextFaceTile() { return nextFaceTile; } public Tile getFixedFaceTile() { return fixedFaceTile; } public Direction getDirection() { return Direction.fromAngle(getFaceAngle()); } public void setNextFaceTile(Tile nextFaceTile) { if (nextFaceTile != null && nextFaceTile.getX() == getX() && nextFaceTile.getY() == getY()) return; this.nextFaceTile = nextFaceTile; if (nextFaceTile == null) return; if (nextTile != null) faceAngle = Utils.getAngleTo(nextFaceTile.getX() - nextTile.getX(), nextFaceTile.getY() - nextTile.getY()); else faceAngle = Utils.getAngleTo(nextFaceTile.getX() - getX(), nextFaceTile.getY() - getY()); } public void setFixedFaceTile(Tile tile) { this.fixedFaceTile = tile; } public void faceNorth() { setNextFaceTile(Tile.of(getX(), getY()+1, getPlane())); } public void faceEast() { setNextFaceTile(Tile.of(getX()+1, getY(), getPlane())); } public void faceSouth() { setNextFaceTile(Tile.of(getX(), getY()-1, getPlane())); } public void faceWest() { setNextFaceTile(Tile.of(getX()-1, getY(), getPlane())); } public abstract int getSize(); public void cancelFaceEntityNoCheck() { nextFaceEntity = -2; lastFaceEntity = -1; } public void setNextFaceEntity(Entity entity) { if (entity == null) { nextFaceEntity = -1; lastFaceEntity = -1; } else { nextFaceEntity = entity.getClientIndex(); lastFaceEntity = nextFaceEntity; } } public int getNextFaceEntity() { return nextFaceEntity; } public int getLastFaceEntity() { return lastFaceEntity; } public void unfreeze() { removeEffect(Effect.FREEZE); } public void freeze() { freeze(Integer.MAX_VALUE, false); } public void freeze(int ticks) { freeze(ticks, false); } public void freeze(int ticks, boolean freezeBlock) { if (hasEffect(Effect.FREEZE_BLOCK) && freezeBlock) return; if (this instanceof Player p) p.sendMessage(""You have been frozen!""); resetWalkSteps(); addEffect(Effect.FREEZE, ticks); if (freezeBlock) addEffect(Effect.FREEZE_BLOCK, ticks + 15); } public abstract double getMagePrayerMultiplier(); public abstract double getRangePrayerMultiplier(); public abstract double getMeleePrayerMultiplier(); public Entity getAttackedBy() { return attackedBy; } public void setAttackedBy(Entity attackedBy) { this.attackedBy = attackedBy; } public boolean hasBeenHit(int time) { return (timeLastHit + time) > System.currentTimeMillis(); } public void refreshTimeLastHit() { timeLastHit = System.currentTimeMillis(); } public boolean inCombat(int time) { return (attackedByDelay + time) > System.currentTimeMillis(); } public boolean inCombat() { return attackedByDelay > System.currentTimeMillis(); } public boolean isAttacking() { if (this instanceof Player p) return p.getInteractionManager().doingInteraction(PlayerCombatInteraction.class); if (this instanceof NPC n) return n.getCombat().hasTarget(); return false; } public void setAttackedByDelay(long attackedByDelay) { this.attackedByDelay = attackedByDelay; } public void checkMultiArea() { multiArea = forceMultiArea || World.isMultiArea(this.getTile()); } public boolean isAtMultiArea() { if (this instanceof NPC n && n.isForceMultiAttacked()) return true; return multiArea; } public void setAtMultiArea(boolean multiArea) { this.multiArea = multiArea; } public boolean isHasNearbyInstancedChunks() { return hasNearbyInstancedChunks; } public ForceMovement getNextForceMovement() { return nextForceMovement; } protected void setNextForceMovement(ForceMovement movement) { this.nextForceMovement = movement; } public void forceMoveVisually(Tile destination, int animation, int startClientCycles, int speedClientCycles) { forceMoveVisually(getTile(), destination, animation, startClientCycles, speedClientCycles); } public void forceMoveVisually(Tile start, Tile destination, int animation, int startClientCycles, int speedClientCycles) { if (animation != -1) anim(animation); setNextForceMovement(new ForceMovement(start, destination, startClientCycles, speedClientCycles)); } public void forceMoveVisually(Direction dir, int distance, int animation, int startClientCycles, int speedClientCycles) { if (animation != -1) anim(animation); setNextForceMovement(new ForceMovement(getTile(), transform(dir.dx *distance, dir.dy *distance), startClientCycles, speedClientCycles)); } public void forceMoveVisually(Tile destination, int startClientCycles, int speedClientCycles) { forceMoveVisually(destination, -1, startClientCycles, speedClientCycles); } public void forceMoveVisually(Direction dir, int distance, int startClientCycles, int speedClientCycles) { forceMoveVisually(dir, distance, -1, startClientCycles, speedClientCycles); } public void forceMove(Tile destination, int animation, int startClientCycles, int speedClientCycles, boolean autoUnlock, Runnable afterComplete) { forceMove(Tile.of(getTile()), destination, animation, startClientCycles, speedClientCycles, autoUnlock, afterComplete); } public void forceMove(Tile destination, Direction faceDir, int animation, int startClientCycles, int speedClientCycles) { forceMove(Tile.of(getTile()), destination, faceDir, animation, startClientCycles, speedClientCycles, true, null); } public void forceMove(Tile start, Tile destination, Direction faceDir, int animation, int startClientCycles, int speedClientCycles) { forceMove(start, destination, faceDir, animation, startClientCycles, speedClientCycles, true, null); } public void forceMove(Tile start, Tile destination, int animation, int startClientCycles, int speedClientCycles, boolean autoUnlock, Runnable afterComplete) { forceMove(start, destination, null, animation, startClientCycles, speedClientCycles, autoUnlock, afterComplete); } public void forceMove(Tile start, Tile destination, Direction faceDir, int animation, int startClientCycles, int speedClientCycles, boolean autoUnlock, Runnable afterComplete) { ForceMovement movement = new ForceMovement(start, destination, startClientCycles, speedClientCycles, faceDir == null ? Utils.getAngleTo(start, destination) : faceDir.getAngle()); if (animation != -1) anim(animation); lock(); resetWalkSteps(); if (this instanceof Player player) player.setTemporaryMoveType(MoveType.WALK); move(destination); setNextForceMovement(movement); tasks.schedule(movement.getTickDuration(), () -> { if (autoUnlock) unlock(); if (afterComplete != null) afterComplete.run(); }); } public void forceMove(Tile destination, int animation, int startClientCycles, int speedClientCycles, boolean autoUnlock) { forceMove(destination, animation, startClientCycles, speedClientCycles, autoUnlock, null); } public void forceMove(Tile start, Tile destination, int animation, int startClientCycles, int speedClientCycles, boolean autoUnlock) { forceMove(start, destination, animation, startClientCycles, speedClientCycles, autoUnlock, null); } public void forceMove(Tile destination, int startClientCycles, int speedClientCycles, boolean autoUnlock, Runnable afterComplete) { forceMove(destination, -1, startClientCycles, speedClientCycles, autoUnlock, afterComplete); } public void forceMove(Tile destination, int anim, int startClientCycles, int speedClientCycles, Runnable afterComplete) { forceMove(destination, anim, startClientCycles, speedClientCycles, true, afterComplete); } public void forceMove(Tile start, Tile destination, int anim, int startClientCycles, int speedClientCycles, Runnable afterComplete) { forceMove(start, destination, anim, startClientCycles, speedClientCycles, true, afterComplete); } public void forceMove(Tile destination, int anim, int startClientCycles, int speedClientCycles) { forceMove(destination, anim, startClientCycles, speedClientCycles, true, null); } public void forceMove(Direction dir, int distance, int anim, int startClientCycles, int speedClientCycles, boolean autoUnlock, Runnable afterComplete) { forceMove(transform(dir.dx *distance, dir.dy *distance), anim, startClientCycles, speedClientCycles, autoUnlock, afterComplete); } public void forceMove(Direction dir, int distance, int anim, int startClientCycles, int speedClientCycles, Runnable afterComplete) { forceMove(dir, distance, anim, startClientCycles, speedClientCycles, true, afterComplete); } public void forceMove(Direction dir, int distance, int anim, int startClientCycles, int speedClientCycles) { forceMove(dir, distance, anim, startClientCycles, speedClientCycles, true, null); } public void forceMove(Tile destination, int startClientCycles, int speedClientCycles, Runnable afterComplete) { forceMove(destination, -1, startClientCycles, speedClientCycles, true, afterComplete); } public void forceMove(Tile destination, int startClientCycles, int speedClientCycles) { forceMove(destination, -1, startClientCycles, speedClientCycles, true, null); } public void forceMove(Direction dir, int distance, int startClientCycles, int speedClientCycles, boolean autoUnlock, Runnable afterComplete) { forceMove(transform(dir.dx *distance, dir.dy *distance), -1, startClientCycles, speedClientCycles, autoUnlock, afterComplete); } public void forceMove(Direction dir, int distance, int startClientCycles, int speedClientCycles, Runnable afterComplete) { forceMove(dir, distance, -1, startClientCycles, speedClientCycles, true, afterComplete); } public void forceMove(Direction dir, int distance, int startClientCycles, int speedClientCycles) { forceMove(dir, distance, -1, startClientCycles, speedClientCycles, true, null); } public Poison getPoison() { return poison; } public ForceTalk getNextForceTalk() { return nextForceTalk; } /** * Use forceTalk(string message) instead * @param nextForceTalk */ @Deprecated public void setNextForceTalk(ForceTalk nextForceTalk) { this.nextForceTalk = nextForceTalk; } public void forceTalk(String message) { setNextForceTalk(new ForceTalk(message)); } public void faceEntity(Entity target) { setNextFaceTile(Tile.of(target.getCoordFaceX(target.getSize()), target.getCoordFaceY(target.getSize()), target.getPlane())); } public void faceObject(GameObject object) { int x = -1, y = -1; if (object.getType() == ObjectType.WALL_STRAIGHT) { // wall if (object.getRotation() == 0) { // west x = object.getX() - 1; y = object.getY(); } else if (object.getRotation() == 1) { // north x = object.getX(); y = object.getY() + 1; } else if (object.getRotation() == 2) { // east x = object.getX() + 1; y = object.getY(); } else if (object.getRotation() == 3) { // south x = object.getX(); y = object.getY() - 1; } } else if (object.getType() == ObjectType.WALL_DIAGONAL_CORNER || object.getType() == ObjectType.WALL_WHOLE_CORNER) { // corner and corner wall if (object.getRotation() == 0) { // nw x = object.getX() - 1; y = object.getY() + 1; } else if (object.getRotation() == 1) { // ne x = object.getX() + 1; y = object.getY() + 1; } else if (object.getRotation() == 2) { // se x = object.getX() + 1; y = object.getY() - 1; } else if (object.getRotation() == 3) { // sw x = object.getX() - 1; y = object.getY() - 1; } } else if (object.getType() == ObjectType.WALL_STRAIGHT_CORNER) { // inverted corner if (object.getRotation() == 0) { // se x = object.getX() + 1; y = object.getY() - 1; } else if (object.getRotation() == 1) { // sw x = object.getX() - 1; y = object.getY() - 1; } else if (object.getRotation() == 2) { // nw x = object.getX() - 1; y = object.getY() + 1; } else if (object.getRotation() == 3) { // ne x = object.getX() + 1; y = object.getY() + 1; } } else if (object.getType().id < ObjectType.SCENERY_INTERACT.id) { // walldeco's if (object.getRotation() == 0) { // west x = object.getX() - 1; y = object.getY(); } else if (object.getRotation() == 1) { // north x = object.getX(); y = object.getY() + 1; } else if (object.getRotation() == 2) { // east x = object.getX() + 1; y = object.getY(); } else if (object.getRotation() == 3) { // south x = object.getX(); y = object.getY() - 1; } } else { // rest x = object.getCoordFaceX(); y = object.getCoordFaceY(); } setNextFaceTile(Tile.of(x, y, object.getPlane())); } public void faceTile(Tile tile) { setNextFaceTile(tile); } public long getLastAnimationEnd() { return lastAnimationEnd; } public GenericAttribMap getTempAttribs() { return temporaryAttributes; } public List queryNearbyNPCsByTileRange(int tileRange, Function predicate) { List startList = World.getNPCsInChunkRange(getChunkId(), ((tileRange / 8) + 1)); List list = new ObjectArrayList<>(); for (NPC npc : startList) { if (predicate == null || predicate.apply(npc)) list.add(npc); } return list; } public List queryNearbyPlayersByTileRange(int tileRange, Function predicate) { List startList = World.getPlayersInChunkRange(getChunkId(), ((tileRange / 8) + 1)); List list = new ObjectArrayList<>(); for (Player npc : startList) { if (predicate == null || predicate.apply(npc)) list.add(npc); } return list; } public List queryNearbyPlayersByTileRangeAsEntityList(int tileRange, Function predicate) { return queryNearbyPlayersByTileRange(tileRange, predicate).stream().map(e -> (Entity) e).collect(Collectors.toList()); } public List queryNearbyNPCsByTileRangeAsEntityList(int tileRange, Function predicate) { return queryNearbyNPCsByTileRange(tileRange, predicate).stream().map(e -> (Entity) e).collect(Collectors.toList()); } public GenericAttribMap getNSV() { return nonsavingVars; } public boolean isForceMultiArea() { return forceMultiArea; } public Entity setForceMultiArea(boolean forceMultiArea) { this.forceMultiArea = forceMultiArea; checkMultiArea(); return this; } public Tile getLastTile() { return lastTile; } public ArrayList getNextHits() { return nextHits; } public int getSceneBaseChunkId() { return sceneBaseChunkId; } public long getFindTargetDelay() { return findTargetDelay; } public void setFindTargetDelay(long findTargetDelay) { this.findTargetDelay = findTargetDelay; } public BodyGlow getNextBodyGlow() { return nextBodyGlow; } public void setNextBodyGlow(BodyGlow nextBodyGlow) { this.nextBodyGlow = nextBodyGlow; } public ArrayList getNextHitBars() { return nextHitBars; } public int getLastChunkId() { return lastChunkId; } public void setLastChunkId(int lastChunkId) { this.lastChunkId = lastChunkId; } public Tile getTileBehind() { return tileBehind; } public void setRouteEvent(RouteEvent routeEvent) { this.resetWalkSteps(); this.routeEvent = routeEvent; } public long getTickCounter() { return tickCounter; } public Vec2 getMiddleTileAsVector() { int size = getSize(); if (size == 1) return new Vec2(this.getTile()); return new Vec2(getX() + (size-1)/ 2.0f, getY() + (size-1)/ 2.0f); } public boolean inMeleeRange(Entity target) { return WorldUtil.isInRange(getX(), getY(), getSize(), target.getX(), target.getY(), target.getSize(), 0); } public boolean isForceUpdateEntityRegion() { return forceUpdateEntityRegion; } public void setForceUpdateEntityRegion(boolean forceUpdateEntityRegion) { this.forceUpdateEntityRegion = forceUpdateEntityRegion; } public CollisionStrategy getCollisionStrategy() { if (collisionStrategy == null) collisionStrategy = CollisionStrategyType.NORMAL.getStrategy(); return collisionStrategy; } public Entity setCollisionStrategy(CollisionStrategy strategy) { this.collisionStrategy = strategy; return this; } public Entity setCollisionStrategyType(CollisionStrategyType type) { setCollisionStrategy(type == null ? CollisionStrategyType.NORMAL.getStrategy() : type.getStrategy()); return this; } public Tile getNearestTeleTile(Entity toMove) { return getNearestTeleTile(toMove.getSize()); } public Tile getNearestTeleTile(int size) { return World.findAdjacentFreeSpace(this.getTile(), size); } public Tile getNearestTeleTile(Direction... blacklistedDirections) { return World.findAdjacentFreeSpace(this.getTile(), blacklistedDirections); } public Tile getTile() { return tile; } public void setTile(Tile tile) { this.tile = tile; } public void setLocation(Tile tile) { this.tile = tile; } public void setLocation(int x, int y, int z) { this.tile = Tile.of(x, y, z); } public boolean isAt(int x, int y) { return tile.isAt(x, y); } public boolean isAt(int x, int y, int z) { return tile.isAt(x, y, z); } public int getX() { return tile.getX(); } public int getXInRegion() { return tile.getXInRegion(); } public int getYInRegion() { return tile.getYInRegion(); } public int getXInChunk() { return tile.getXInChunk(); } public int getYInChunk() { return tile.getYInChunk(); } public int getY() { return tile.getY(); } public int getPlane() { return tile.getPlane(); } public int getChunkX() { return tile.getChunkX(); } public int getChunkId() { return tile.getChunkId(); } public int getChunkXInScene(int chunkId) { return tile.getChunkXInScene(chunkId); } public int getChunkYInScene(int chunkId) { return tile.getChunkYInScene(chunkId); } public int getXInScene(int chunkId) { return tile.getXInScene(chunkId); } public int getYInScene(int chunkId) { return tile.getYInScene(chunkId); } public int getChunkY() { return tile.getChunkY(); } public int getRegionX() { return tile.getRegionX(); } public int getRegionY() { return tile.getRegionY(); } public int getRegionId() { return tile.getRegionId(); } @Override public int hashCode() { return uuid.hashCode(); } @Override public boolean equals(Object other) { if (other instanceof Entity n) return n.hashCode() == hashCode(); return false; } public int getRegionHash() { return tile.getRegionHash(); } public int getTileHash() { return tile.getTileHash(); } public boolean withinDistance(Tile other, int distance) { return tile.withinDistance(other, distance); } public boolean withinDistance(Tile tile) { return tile.withinDistance(tile); } public int getCoordFaceX(int sizeX) { return tile.getCoordFaceX(sizeX); } public int getCoordFaceX(int sizeX, int sizeY, int rotation) { return tile.getCoordFaceX(sizeX, sizeY, rotation); } public int getCoordFaceY(int sizeY) { return tile.getCoordFaceY(sizeY); } public int getCoordFaceY(int sizeX, int sizeY, int rotation) { return tile.getCoordFaceY(sizeX, sizeY, rotation); } public int getLongestDelta(Tile other) { return tile.getLongestDelta(other); } public Tile transform(int x, int y) { return tile.transform(x, y); } public Tile transform(int x, int y, int plane) { return tile.transform(x, y, plane); } public boolean matches(Tile other) { return tile.matches(other); } public boolean withinArea(int a, int b, int c, int d) { return tile.withinArea(a, b, c, d); } public boolean canAttackMulti(Entity target) { if(this instanceof Familiar && target.isForceMultiArea()) return true; if(target instanceof Familiar && this.isForceMultiArea()) return true; if ((this instanceof NPC n && n.isForceMultiAttacked()) || (target instanceof NPC npc && npc.isForceMultiAttacked())) return true; if (target.isAtMultiArea() && isAtMultiArea()) return true; if (this instanceof Player p) { if (target instanceof Player) { if (getAttackedBy() instanceof Player && inCombat() && getAttackedBy() != target) { p.sendMessage(""You are already in combat.""); return false; } if (target.getAttackedBy() instanceof Player && target.inCombat() && target.getAttackedBy() != this) { p.sendMessage(""They are already in combat.""); return false; } } else if (target instanceof NPC) { if (inCombat() && getAttackedBy() != target) { p.sendMessage(""You are already in combat.""); return false; } if (target.inCombat() && target.getAttackedBy() != this) { p.sendMessage(""They are already in combat.""); return false; } } } else if (this instanceof NPC n) { if (inCombat() && getAttackedBy() != target) return false; return !target.inCombat() || target.getAttackedBy() == this; } return true; } public void anim(int anim) { setNextAnimation(new Animation(anim)); } public void anim(Animation anim) { setNextAnimation(anim); } public void spotAnim(int spotAnim, int speed, int height) { setNextSpotAnim(new SpotAnim(spotAnim, speed, height)); } public void spotAnim(int spotAnim, int speed) { setNextSpotAnim(new SpotAnim(spotAnim, speed)); } public void spotAnim(int spotAnim) { setNextSpotAnim(new SpotAnim(spotAnim)); } public void spotAnim(SpotAnim spotAnim) { setNextSpotAnim(spotAnim); } public void sync(int anim, int spotAnim) { anim(anim); spotAnim(spotAnim); } public void sync(Animation anim, SpotAnim spotAnim) { setNextAnimation(anim); setNextSpotAnim(spotAnim); } public InteractionManager getInteractionManager() { return interactionManager; } public ActionManager getActionManager() { return actionManager; } public void follow(Entity target) { actionManager.setAction(new EntityFollow(target)); } public int lowerStat(int skillId, double perc, double maxDrain) { if (this instanceof Player player) { if (skillId == Skills.HITPOINTS) return 0; if (skillId == Skills.PRAYER) { player.getPrayer().drainPrayer(player.getPrayer().getPoints() * perc); return (int) (player.getPrayer().getPoints() / 10); } return player.getSkills().lowerStat(skillId, perc, maxDrain); } else if (this instanceof NPC npc) { return switch(skillId) { case Skills.ATTACK -> npc.lowerAttack(perc, maxDrain); case Skills.STRENGTH -> npc.lowerStrength(perc, maxDrain); case Skills.DEFENSE -> npc.lowerDefense(perc, maxDrain); case Skills.MAGIC -> npc.lowerMagic(perc, maxDrain); case Skills.RANGE -> npc.lowerRange(perc, maxDrain); default -> 0; }; } return 0; } public int lowerStat(int skillId, int amt, double maxDrain) { if (this instanceof Player player) { if (skillId == Skills.HITPOINTS) return 0; if (skillId == Skills.PRAYER) { player.getPrayer().drainPrayer(amt * 10); return (int) (player.getPrayer().getPoints() / 10); } return player.getSkills().lowerStat(skillId, amt, maxDrain); } else if (this instanceof NPC npc) { return switch(skillId) { case Skills.ATTACK -> npc.lowerAttack(amt, maxDrain); case Skills.STRENGTH -> npc.lowerStrength(amt, maxDrain); case Skills.DEFENSE -> npc.lowerDefense(amt, maxDrain); case Skills.MAGIC -> npc.lowerMagic(amt, maxDrain); case Skills.RANGE -> npc.lowerRange(amt, maxDrain); default -> 0; }; } return 0; } public void repeatAction(int ticks, Function action) { getActionManager().setAction(new Action() { int count = 0; @Override public boolean start(Entity entity) { return true; } @Override public boolean process(Entity entity) { return true; } @Override public int processWithDelay(Entity entity) { if (action.apply(++count)) return ticks; return -1; } @Override public void stop(Entity entity) { } }); } public ModelRotator getBodyModelRotator() { return bodyModelRotator; } public void setBodyModelRotator(ModelRotator bodyModelRotator) { if (bodyModelRotator == null) { this.bodyModelRotator = ModelRotator.RESET; return; } this.bodyModelRotator = bodyModelRotator; } public int getBas() { return bas; } public void setBas(int basAnim) { if (basAnim == -1) { setBasNoReset(-2); return; } setBasNoReset(basAnim); } public void setBasNoReset(int bas) { this.bas = bas; } public boolean isLocked() { return lockDelay >= tickCounter; } /** * You are invincible & cannot use your character until unlocked. * All hits are processed after unlocking. * If you use resetRecievedHits you lose those hits. */ public void lock() { lockDelay = Long.MAX_VALUE; } public void lock(int ticks) { lockDelay = tickCounter + ticks; } public void unlock() { lockDelay = 0; } public void unlockNextTick() { nextTickUnlock = true; } public TaskManager getTasks() { return tasks; } public void processTasks() { if (tasks != null) tasks.processTasks(); if (asyncTasks != null) asyncTasks.tick(); } public void clearPendingTasks() { tasks = new TaskManager(); asyncTasks.stopAll(); } public AsyncTaskScheduler getAsyncTasks() { return asyncTasks; } }" "package com.rs.game.model.entity; public class EntityHitBar extends HitBar { public EntityHitBar(Entity entity) { this.entity = entity; } private final Entity entity; @Override public int getPercentage() { int hp = entity.getHitpoints(); int maxHp = entity.getMaxHitpoints(); if (hp > maxHp) hp = maxHp; return maxHp == 0 ? 0 : (int) ((long)hp * 255 / maxHp); } @Override public int getType() { int size = entity.getSize(); return size >= 5 ? 3 : size >= 3 ? 4 : 0; } @Override public boolean display(Player player) { return true; } }" "package com.rs.game.model.entity; public class EntityList extends AbstractCollection { public Object[] entities; private final IntSet usedIndices = new IntOpenHashSet(); private final IntPriorityQueue freeIndices = new IntHeapPriorityQueue(); private final IntSet toFreeUp = new IntOpenHashSet(); private int freeCap = 1; private final Object lock = new Object(); public EntityList(int capacity) { entities = new Object[capacity]; } @Override public boolean add(T entity) { synchronized (lock) { int slot = getEmptySlot(); if (slot == -1) return false; if (entities[slot] != null) return false; entities[slot] = entity; entity.setIndex(slot); usedIndices.add(slot); return true; } } private int getEmptySlot() { if (freeIndices.isEmpty()) { if (freeCap < entities.length) freeIndices.enqueue(freeCap++); else return -1; } return freeIndices.dequeueInt(); } public void remove(T entity) { synchronized (lock) { entities[entity.getIndex()] = null; usedIndices.remove(entity.getIndex()); toFreeUp.add(entity.getIndex()); } } @SuppressWarnings(""unchecked"") public T remove(int index) { synchronized (lock) { Object temp = entities[index]; entities[index] = null; usedIndices.remove(index); toFreeUp.add(index); return (T) temp; } } public void processPostTick() { synchronized (lock) { for (int toFree : toFreeUp) { if (toFree == 0) continue; freeIndices.enqueue(toFree); } toFreeUp.clear(); } } @SuppressWarnings(""unchecked"") public T get(int index) { synchronized (lock) { if (index >= entities.length || index < 1) return null; return (T) entities[index]; } } @Override public @NotNull Iterator iterator() { synchronized (lock) { return new EntityListIterator<>(entities, usedIndices, this); } } public boolean contains(T entity) { return indexOf(entity) > -1; } public int indexOf(T entity) { synchronized (lock) { for (int index : usedIndices) if (entities[index].equals(entity)) return index; } return -1; } @Override public int size() { return usedIndices.size(); } }" "/* * Copyright (C) 2008 RS2DBase Development team * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ package com.rs.game.model.entity; public class EntityListIterator implements Iterator { private final Integer[] indicies; private final Object[] entities; @SuppressWarnings(""rawtypes"") private final EntityList entityList; private int curIndex = 0; public EntityListIterator(Object[] entities, Set indicies, @SuppressWarnings(""rawtypes"") EntityList entityList) { this.entities = entities; this.indicies = indicies.toArray(new Integer[0]); this.entityList = entityList; } @Override public boolean hasNext() { return indicies.length != curIndex; } @Override @SuppressWarnings(""unchecked"") public E next() { Object temp = entities[indicies[curIndex]]; curIndex++; return (E) temp; } @Override public void remove() { if (curIndex >= 1) entityList.remove(indicies[curIndex - 1]); } }" "package com.rs.game.model.entity; public class ForceMovement { private final Tile start; private final Tile[] path; private final int startClientCycles; private final int speedClientCycles; private final int direction; public ForceMovement(Tile start, Tile[] path, int startClientCycles, int speedClientCycles, int direction) { this.start = start; this.path = path; this.startClientCycles = startClientCycles; this.speedClientCycles = speedClientCycles; this.direction = direction; } public ForceMovement(Tile start, Tile destination, int startClientCycles, int speedClientCycles, int direction) { this(start, new Tile[] { destination }, startClientCycles, speedClientCycles, direction); } public ForceMovement(Tile start, Tile destination, int startClientCycles, int speedClientCycles, Direction direction) { this(start, destination, startClientCycles, speedClientCycles, WorldUtil.getAngleTo(direction)); } public ForceMovement(Tile start, Tile destination, int startClientCycles, int speedClientCycles) { this(start, destination, startClientCycles, speedClientCycles, Utils.getAngleTo(start, destination)); } public int getTickDuration() { return (int) Math.ceil((double) Math.max(startClientCycles, speedClientCycles) / 30.0); } public int getDiffX1() { return start.getX() - path[0].getX(); } public int getDiffX2() { if (path.length <= 1) return 0; return start.getX() - path[1].getX(); } public int getDiffY1() { return start.getY() - path[0].getY(); } public int getDiffY2() { if (path.length <= 1) return 0; return start.getY() - path[1].getY(); } public Tile getStart() { return start; } public Tile[] getPath() { return path; } public int getStartClientCycles() { return startClientCycles; } public int getSpeedClientCycles() { return speedClientCycles; } public int getDirection() { return direction; } }" "package com.rs.game.model.entity; public record ForceTalk(String text) { }" "package com.rs.game.model.entity; public final class Hit { public enum HitLook { MISSED(8), TRUE_DAMAGE(3), MELEE_DAMAGE(0), RANGE_DAMAGE(1), MAGIC_DAMAGE(2), REFLECTED_DAMAGE(4), ABSORB_DAMAGE(5), POISON_DAMAGE(6), DISEASE_DAMAGE(7), HEALED_DAMAGE(9), CANNON_DAMAGE(13); private final int mark; HitLook(int mark) { this.mark = mark; } public int getMark() { return mark; } } private Entity source; private HitLook look; private int maxHit; private int damage; private boolean critical; private Hit soaking; private final int delay; private final Map data = new HashMap<>(); public void setCriticalMark() { critical = true; } public void setHealHit() { look = HitLook.HEALED_DAMAGE; critical = false; } public Hit(int damage, HitLook look) { this(null, damage, look, 0); } public Hit(Entity source, int damage, HitLook look) { this(source, damage, look, 0); } public Hit(Entity source, int damage, HitLook look, int delay) { this.source = source; this.damage = damage; this.look = look; this.delay = delay; } public boolean missed() { return damage == 0; } public boolean interactingWith(Player player, Entity victm) { return player == victm || player == source; } public int getMark(Player player, Entity victm) { if (HitLook.HEALED_DAMAGE == look) return look.getMark(); if (damage == 0) return HitLook.MISSED.getMark(); int mark = look.getMark(); if (critical) mark += 10; if (!interactingWith(player, victm)) mark += 14; return mark; } public Hit setMaxHit(int maxHit) { this.maxHit = maxHit; return this; } public HitLook getLook() { return look; } public int getDamage() { return damage; } public Hit setDamage(int damage) { this.damage = damage; return this; } public Entity getSource() { return source; } public Hit setSource(Entity source) { this.source = source; return this; } public Hit setLook(HitLook look) { this.look = look; return this; } public boolean isCriticalHit() { return critical; } public Hit getSoaking() { return soaking; } private void setSoaking(Hit soaking) { this.soaking = soaking; } public void addSoaking(int damage) { if (soaking == null) setSoaking(new Hit(source, damage, HitLook.ABSORB_DAMAGE)); else soaking.damage += damage; } public void soakDamage(double reductionPerc) { int reduction = (int) ((double) this.damage * reductionPerc); if (reduction <= 0) return; this.damage -= reduction; addSoaking(reduction); } public int getDelay() { return delay; } public int getMaxHit() { return maxHit; } public Hit setData(String key, Object obj) { data.put(key, obj); return this; } public static Hit miss(Entity source) { return new Hit(source, 0, HitLook.MISSED); } public static Hit melee(Entity source, int damage) { return new Hit(source, damage, HitLook.MELEE_DAMAGE); } public static Hit range(Entity source, int damage) { return new Hit(source, damage, HitLook.RANGE_DAMAGE); } public static Hit magic(Entity source, int damage) { return new Hit(source, damage, HitLook.MAGIC_DAMAGE); } public static Hit flat(Entity source, int damage) { return new Hit(source, damage, HitLook.TRUE_DAMAGE); } public T getData(String key, Class clazz) { try { if (data.containsKey(key)) return clazz.cast(data.get(key)); } catch(ClassCastException e) { return null; } return null; } public Object getData(String key) { if (data.containsKey(key)) return data.get(key); return null; } }" "package com.rs.game.model.entity; public abstract class HitBar { public abstract int getType(); public abstract int getPercentage(); public int getToPercentage() { return getPercentage(); } public int getTimer() { return getPercentage() == getToPercentage() ? 0 : 1; } public int getDelay() { return 0; } public boolean display(Player player) { return true; } }" "package com.rs.game.model.entity; public class ModelRotator { public static final ModelRotator RESET = new ModelRotator().addRotator(new Rotation().enableAll()); private final int[] targetData = new int[15]; private final int[] slotHashes = new int[15]; private int curr = 0; public ModelRotator() { } public ModelRotator addRotator(Rotation rotator) { targetData[curr] = rotator.getData(); slotHashes[curr++] = rotator.getMask(); return this; } public void encodeNPC(OutputStream stream) { stream.write128Byte(curr); for (int i = 0;i < curr;i++) { if ((targetData[i] & 0xc000) == 0xc000) { stream.writeShortLE128(targetData[i] >> 16); stream.writeShort(targetData[i] & 0xFFFF); } else stream.writeShortLE128(targetData[i]); stream.writeShortLE128(slotHashes[i]); } } public void encodePlayer(OutputStream stream) { stream.write128Byte(curr); for (int i = 0;i < curr;i++) { if ((targetData[i] & 0xc000) == 0xc000) { stream.writeShort128(targetData[i] >> 16); stream.writeShort128(targetData[i] & 0xFFFF); } else stream.writeShort128(targetData[i]); stream.writeShort(slotHashes[i]); } } }" "package com.rs.game.model.entity; public final class Poison { private transient Entity entity; private int poisonDamage; private int poisonCount; public void setEntity(Entity entity) { this.entity = entity; } public Entity getEntity() { return entity; } public void makePoisoned(int startDamage) { if (poisonDamage > startDamage) return; if (entity instanceof Player player) { if (player.hasEffect(Effect.ANTIPOISON)) return; if (poisonDamage == 0) player.sendMessage(""You are poisoned.""); } poisonDamage = startDamage; refresh(); } public void processPoison() { if (!entity.isDead() && isPoisoned()) { if (poisonCount > 0) { poisonCount--; return; } boolean heal = false; if (entity instanceof Player player) { if (player.getInterfaceManager().containsScreenInter()) return; if (player.getAuraManager().isActivated(Aura.POISON_PURGE, Aura.GREATER_POISON_PURGE, Aura.MASTER_POISON_PURGE, Aura.SUPREME_POISON_PURGE)) heal = true; } if (!heal && entity instanceof Player p) p.incrementCount(""Poison damage taken"", poisonDamage); entity.applyHit(new Hit(entity, poisonDamage, heal ? HitLook.HEALED_DAMAGE : HitLook.POISON_DAMAGE)); poisonDamage -= 2; if (isPoisoned()) { poisonCount = 30; return; } reset(); } } public void reset() { poisonDamage = 0; poisonCount = 0; refresh(); } public void refresh() { if (entity instanceof Player player) player.getVars().setVar(102, isPoisoned() ? 1 : 0); } public boolean isPoisoned() { return poisonDamage >= 1; } public void lowerPoisonDamage(int reduction) { poisonDamage = Utils.clampI(poisonDamage - reduction, 0, poisonDamage); } }" "package com.rs.game.model.entity; public class Rotation { private int data; private int mask; public Rotation() { data = -1; } public Rotation(Entity entity) { data = entity.getClientIndex(); } public Rotation(Tile tile) { data |= -0x40000000; data += tile.getY() + (tile.getX() << 14); } public Rotation enable(int... slots) { for (int i : slots) mask |= (1 << i); return this; } public Rotation enableAll() { enable(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14); return this; } public int getData() { return data; } public int getMask() { return mask; } }" "package com.rs.game.model.entity; public record Teleport(Tile start, Tile destination, TeleType type, Supplier meetsRequirements, Runnable begin, Runnable end, boolean clearDamage) { public static void execute(Player player, Teleport teleport, int delay) { if (player.isLocked() || (teleport.meetsRequirements != null && !teleport.meetsRequirements.get())) return; if (!player.getControllerManager().processTeleport(teleport)) return; player.stopAll(); player.lock(); if (teleport.begin != null) teleport.begin.run(); player.getTasks().schedule(delay, () -> { player.getControllerManager().onTeleported(teleport.type); player.tele(teleport.destination); if (teleport.end != null) teleport.end.run(); if (player.getControllerManager().getController() == null) checkDestinationControllers(player, teleport.destination); if (teleport.clearDamage) { player.resetReceivedDamage(); player.resetReceivedHits(); } player.unlock(); }); } public static void checkDestinationControllers(Player player, Tile teleTile) { if (DamonheimController.isAtKalaboss(teleTile)) player.getControllerManager().startController(new DamonheimController()); else if (GodwarsController.isAtGodwars(teleTile)) player.getControllerManager().startController(new GodwarsController()); else if (WildernessController.isAtWild(teleTile)) player.getControllerManager().startController(new WildernessController()); } }" "package com.rs.game.model.entity; public class TestBar extends HitBar { private final int type; private final int delay; private final int perc; private final int toPerc; private final int timer; public TestBar(int type, int delay, int perc, int toPerc, int timer) { this.type = type; this.delay = delay; this.perc = perc; this.toPerc = toPerc; this.timer = timer; } @Override public int getTimer() { return timer; } @Override public int getType() { return type; } @Override public int getToPercentage() { return toPerc; } @Override public int getDelay() { return delay; } @Override public int getPercentage() { return perc; } }" "package com.rs.game.model.entity; public class TimerBar extends HitBar { private final int timer; public TimerBar(int timer) { this.timer = timer; } @Override public int getType() { return 2; } @Override public int getTimer() { return timer; } @Override public int getToPercentage() { return 255; } @Override public int getPercentage() { return 0; } }" "package com.rs.game.model.entity.actions; public abstract class Action { public abstract boolean start(Entity entity); public abstract boolean process(Entity entity); public abstract int processWithDelay(Entity entity); public abstract void stop(Entity entity); public void setActionDelay(Entity entity, int delay) { entity.getActionManager().setActionDelay(delay); } }" "package com.rs.game.model.entity.actions; public class EntityFollow extends Action { private final Entity target; public EntityFollow(Entity target) { this.target = target; } @Override public boolean start(Entity entity) { entity.setNextFaceEntity(target); if (checkAll(entity)) return true; entity.setNextFaceEntity(null); return false; } private boolean checkAll(Entity entity) { if (entity.isDead() || entity.hasFinished() || target.isDead() || target.hasFinished()) return false; if (entity.getPlane() != target.getPlane()) return false; if (entity.hasEffect(Effect.FREEZE)) return true; int distanceX = entity.getX() - target.getX(); int distanceY = entity.getY() - target.getY(); int size = entity.getSize(); int maxDistance = 16; if (entity.getPlane() != target.getPlane() || distanceX > size + maxDistance || distanceX < -1 - maxDistance || distanceY > size + maxDistance || distanceY < -1 - maxDistance) return false; int lastFaceEntity = target.getLastFaceEntity(); Tile toTile = target.getTileBehind() != null && Utils.getDistance(target.getTile(), target.getTileBehind()) <= 3 ? target.getTileBehind() : target.getBackfacingTile(); if (lastFaceEntity == entity.getClientIndex() && target.getActionManager().getAction() instanceof EntityFollow) entity.addWalkSteps(toTile.getX(), toTile.getY()); else if (!entity.lineOfSightTo(target, true) || !WorldUtil.isInRange(entity.getX(), entity.getY(), size, target.getX(), target.getY(), target.getSize(), 0)) { Route route = RouteFinderKt.routeEntityToEntity(entity, target, entity.getRun() ? 2 : 1); if (!route.getSuccess()) return false; entity.resetWalkSteps(); RouteFinderKt.addSteps(entity, route, true, entity.getRun() ? 2 : 1); entity.setNextFaceEntity(target); return true; } return true; } @Override public boolean process(Entity entity) { return checkAll(entity); } @Override public int processWithDelay(Entity entity) { return 0; } @Override public void stop(final Entity entity) { entity.setNextFaceEntity(null); } }" "package com.rs.game.model.entity.async class AsyncTaskScheduler { private val tasks = LinkedList() private val namedTasks: MutableMap = Object2ObjectOpenHashMap() fun tick() { val currentTasks = tasks.toList() for (task in currentTasks) { if (!tasks.contains(task)) continue if (!task.started) { task.started = true task.coroutine.resume(Unit) } task.tick() if (!task.isWaiting()) tasks.remove(task) } } fun schedule(name: String? = null, block: suspend ScheduledTask.(CoroutineScope) -> Unit) { val task = ScheduledTask(name) if (namedTasks[name] != null) cancel(name) if (name != null) namedTasks[name] = task task.coroutine = suspend { block(task, CoroutineScope(AsyncTaskExecutor.getWorldThreadExecutor().asCoroutineDispatcher())) }.createCoroutine(completion = task) tasks.add(task) } fun cancel(name: String?) { val task = namedTasks[name]; if (task != null) { task.stop() tasks.remove(task) namedTasks.remove(name) } } fun stopAll() { tasks.forEach { it.stop() } tasks.clear() namedTasks.clear() } } fun Entity.schedule(mapping: String, task: suspend ScheduledTask.(CoroutineScope) -> Unit) { this.asyncTasks.schedule(mapping, task) } fun Entity.schedule(task: suspend ScheduledTask.(CoroutineScope) -> Unit) { this.asyncTasks.schedule(null, task) } fun Entity.cancel(mapping: String) { this.asyncTasks.cancel(mapping) }" "package com.rs.game.model.entity.async class ScheduledTask(val mapping: String? = null) : Continuation { lateinit var coroutine: Continuation private var onStop: ((ScheduledTask).() -> Unit)? = null private var waitCondition: WaitCondition? = null var started = false override val context: CoroutineContext = EmptyCoroutineContext internal fun tick() { val next = waitCondition ?: return if (next.wait.canContinue()) { next.continuation.resume(Unit) } } override fun resumeWith(result: Result) { waitCondition = null result.exceptionOrNull()?.let { e -> Logger.handle(ScheduledTask::class.java, ""resumeWith"", e) } } fun stop() { waitCondition = null onStop?.invoke(this) } fun isWaiting(): Boolean = waitCondition != null suspend fun wait(ticks: Int): Unit = suspendCoroutine { waitCondition = WaitCondition(TickWait(ticks), it) } suspend fun wait(condition: () -> Boolean): Unit = suspendCoroutine { waitCondition = WaitCondition(ConditionalWait { condition() }, it) } }" "package com.rs.game.model.entity.async data class WaitCondition(val wait: Wait, val continuation: Continuation) abstract class Wait { abstract fun canContinue(): Boolean } class TickWait(ticks: Int) : Wait() { private val ticks = AtomicInteger(ticks) override fun canContinue(): Boolean = ticks.decrementAndGet() <= 0 } class ConditionalWait(private val predicate: () -> Boolean) : Wait() { override fun canContinue(): Boolean = predicate.invoke() }" "package com.rs.game.model.entity.interactions; public abstract class EntityInteraction extends Interaction { protected Entity target; private int distance; private boolean stopFaceOnReached = true; private boolean stopWhenReached = true; public EntityInteraction(Entity target, int distance) { this.target = target; this.distance = distance; } public EntityInteraction keepFacing() { stopFaceOnReached = false; return this; } public EntityInteraction continueAfterReached() { stopWhenReached = false; return this; } public abstract boolean canStart(Entity entity); public abstract boolean checkAll(Entity entity); public abstract void interact(Entity entity); public abstract void onStop(Entity entity); @Override public final boolean start(Entity entity) { entity.setNextFaceEntity(target); if (!canStart(entity)) return false; return checkDistance(entity) && checkAll(entity); } @Override public void stop(Entity entity) { super.stop(entity); entity.setNextFaceEntity(null); } @Override public final boolean process(Entity player) { if (checkDistance(player) && checkAll(player)) { if (isWithinDistance(player, target, true)) { interact(player); if (stopFaceOnReached) player.setNextFaceEntity(null); if (stopWhenReached) { stop(player); return false; } } return true; } return false; } public boolean isWithinDistance(Entity entity, Entity target, boolean addRunSteps) { if (entity.hasEffect(Effect.FREEZE)) addRunSteps = false; boolean los = entity.lineOfSightTo(target, distance == 0); boolean inRange = WorldUtil.isInRange(entity, target, distance + (addRunSteps ? (target.getRun() ? target.hasWalkSteps() ? 2 : 1 : target.hasWalkSteps() ? 1 : 0) : 0)); //boolean collides = WorldUtil.collides(player, target); return los && inRange; } public final boolean checkDistance(Entity entity) { if (entity.isDead() || entity.hasFinished() || target.isDead() || target.hasFinished()) return false; int distanceX = entity.getX() - target.getX(); int distanceY = entity.getY() - target.getY(); int size = target.getSize(); int maxDistance = 16; if (entity.getPlane() != target.getPlane() || distanceX > size + maxDistance || distanceX < -1 - maxDistance || distanceY > size + maxDistance || distanceY < -1 - maxDistance) return false; if (entity.hasEffect(Effect.FREEZE)) return !WorldUtil.collides(entity, target); if (WorldUtil.collides(entity, target)) { if (!entity.hasWalkSteps() && !target.hasWalkSteps()) { entity.resetWalkSteps(); return entity.calcFollow(target, !(entity instanceof NPC n) || n.isIntelligentRouteFinder()); } return target instanceof Player || (entity instanceof Player ? target.hasWalkSteps() ? target instanceof NPC : entity.calcFollow(target, true) : entity.calcFollow(target, !(entity instanceof NPC n) || n.isIntelligentRouteFinder())); } if (distance == 0 && !target.hasWalkSteps() && target.getSize() == 1) { Direction dir = Direction.forDelta(target.getX() - entity.getX(), target.getY() - entity.getY()); if (dir != null) switch(dir) { case NORTH: case SOUTH: case EAST: case WEST: break; default: entity.resetWalkSteps(); entity.calcFollow(target, entity.getRun() ? 2 : 1, !(entity instanceof NPC n) || n.isIntelligentRouteFinder()); return true; } } if (!isWithinDistance(entity, target, false)) { entity.resetWalkSteps(); entity.calcFollow(target, entity.getRun() ? 2 : 1, !(entity instanceof NPC n) || n.isIntelligentRouteFinder()); } else { entity.resetWalkSteps(); if (distance == 0 && target.getRun() == entity.getRun()) entity.calcFollow(target, entity.getRun() ? 2 : 1, !(entity instanceof NPC n) || n.isIntelligentRouteFinder()); } return true; } public void setDistance(int distance) { this.distance = distance; } }" "package com.rs.game.model.entity.interactions; public abstract class EntityInteractionAction extends EntityInteraction { private final T action; private boolean started = false; public EntityInteractionAction(Entity target, T action, int distance) { super(target, distance); continueAfterReached(); keepFacing(); this.action = action; } @Override public void interact(Entity entity) { if (!started) { if (!action.start(entity)) { stop(entity); return; } started = true; } if (entity.getActionManager().getActionDelay() > 0) return; int newDelay = action.processWithDelay(entity) + 1; if (newDelay == -1) { stop(entity); return; } entity.getActionManager().setActionDelay(newDelay); } public T getAction() { return action; } @Override public void onStop(Entity entity) { if (!(entity instanceof Player player)) return; action.stop(player); } }" "package com.rs.game.model.entity.interactions; public abstract class Interaction { private boolean stopped = false; public abstract boolean start(Entity player); public abstract boolean process(Entity player); public void stop(Entity player) { stopped = true; } public boolean isStopped() { return stopped; } }" "package com.rs.game.model.entity.interactions; public final class InteractionManager { private final Entity player; private Interaction interaction; public InteractionManager(Entity player) { this.player = player; } public void process() { if (interaction != null && (interaction.isStopped() || player.isDead() || !interaction.process(player))) forceStop(); } public boolean setInteraction(Interaction skill) { forceStop(); if (!skill.start(player)) return false; interaction = skill; return true; } public void forceStop() { if (interaction == null) return; player.setNextFaceEntity(null); interaction.stop(player); interaction = null; } public Interaction getInteraction() { return interaction; } public boolean doingInteraction(Class type) { if (interaction == null) return false; return type.isInstance(interaction); } }" "package com.rs.game.model.entity.interactions; public class PlayerCombatInteraction extends PlayerEntityInteractionAction { public PlayerCombatInteraction(Player player, Entity target) { super(target, new PlayerCombat(target), PlayerCombatKt.getAttackRange(player)); } @Override public boolean canStart(Player player) { player.setNextFaceEntity(target); return true; } @Override public boolean checkAll(Player player) { if (target.isDead() || (target instanceof NPC n && n.isCantInteract())) return false; setDistance(PlayerCombatKt.getAttackRange(player)); player.setNextFaceEntity(target); return getAction().checkAll(player); } }" "package com.rs.game.model.entity.interactions; public class StandardEntityInteraction extends EntityInteraction { private final Runnable onReached; public StandardEntityInteraction(Entity target, int distance, Runnable onReached) { super(target, distance); this.onReached = onReached; } @Override public boolean canStart(Entity player) { return true; } @Override public boolean checkAll(Entity player) { return true; } @Override public void interact(Entity player) { onReached.run(); } @Override public void onStop(Entity player) { } }" "package com.rs.game.model.entity.npc; public class NPC extends Entity { private int id; private Tile respawnTile; private boolean randomWalk; private Map combatLevels; private boolean spawned; private transient NPCCombat combat; private transient boolean ignoreNPCClipping; private Tile forceWalk; private int size; private boolean hidden = false; private transient boolean loadsUpdateZones = false; private long lastAttackedByTarget; private boolean cantInteract; private int capDamage; private int lureDelay; private boolean cantFollowUnderCombat; private boolean forceAgressive; private boolean ignoreDocile; private int forceAggroDistance; private boolean forceFollowClose; private boolean forceMultiAttacked; private boolean noDistanceCheck; private transient long timeLastSpawned; private boolean canAggroNPCs; // npc masks private transient Transformation nextTransformation; private transient NPCBodyMeshModifier bodyMeshModifier; protected transient ConcurrentHashMap temporaryAttributes; // name changing masks private String name; private transient boolean changedName; private transient boolean permName; private int combatLevel; private transient boolean changedCombatLevel; private transient boolean locked; private transient boolean skipWalkStep; private transient boolean deleted = false; private transient TaskInformation respawnTask; public boolean switchWalkStep() { return skipWalkStep = !skipWalkStep; } private boolean intelligentRoutefinder; public boolean maskTest; public NPC(int id, Tile tile, Direction direction, boolean permaDeath) { super(tile); this.id = id; respawnTile = Tile.of(tile); setSpawned(permaDeath); combatLevel = -1; setHitpoints(getMaxHitpoints()); setFaceAngle(direction == null ? getRespawnDirection() : direction.getAngle()); setRandomWalk((getDefinitions().walkMask & 0x2) != 0 || forceRandomWalk(id)); setCollisionStrategyType((getDefinitions().walkMask & 0x4) != 0 ? CollisionStrategyType.WATER : CollisionStrategyType.NORMAL); size = getDefinitions().size; if (getDefinitions().hasAttackOption()) setRandomWalk(true); if (getDefinitions().getName().toLowerCase().contains(""glac"")) setRandomWalk(false); if (id == 7891) setRandomWalk(false); BoxHunterType npc = BoxHunterType.forId(id); if (npc != null) setRandomWalk(true); if (getDefinitions().combatLevel >= 200) setIgnoreDocile(true); combatLevels = NPCCombatDefinitions.getDefs(id).getLevels(); combat = new NPCCombat(this); capDamage = -1; lureDelay = 12000; // npc is inited on creating instance initEntity(); World.addNPC(this); ChunkManager.updateChunks(this); // npc is started on creating instance loadMapRegions(); checkMultiArea(); } public NPC(int id, Tile tile, boolean permaDeath) { this(id,tile, null, permaDeath); } public NPC(int id, Tile tile) { this(id, tile, false); } public boolean walksOnWater() { return (getDefinitions().walkMask & 0x4) != 0; } @Override public boolean needMasksUpdate() { return super.needMasksUpdate() || nextTransformation != null || bodyMeshModifier != null || getBas() != -1 || changedCombatLevel || changedName || maskTest || permName; } public void setLoadsUpdateZones() { loadsUpdateZones = true; } public void resetLevels() { combatLevels = NPCCombatDefinitions.getDefs(id).getLevels(); } public void transformIntoNPC(int id) { setNPC(id); nextTransformation = new Transformation(id); } public void setNPC(int id) { this.id = id; size = getDefinitions().size; combatLevels = NPCCombatDefinitions.getDefs(id).getLevels(); } public void setLevels(Map levels) { this.combatLevels = levels; } public void resetDirection() { setNextFaceTile(null); setNextFaceEntity(null); setFaceAngle(getRespawnDirection()); } @Override public void resetMasks() { super.resetMasks(); nextTransformation = null; changedName = false; if (bodyMeshModifier == NPCBodyMeshModifier.RESET) bodyMeshModifier = null; if (getBas() == -2) setBasNoReset(-1); } public NPCDefinitions getDefinitions(Player player) { return NPCDefinitions.getDefs(id, player.getVars()); } public NPCDefinitions getDefinitions() { return NPCDefinitions.getDefs(id); } public NPCCombatDefinitions getCombatDefinitions() { return NPCCombatDefinitions.getDefs(id); } @Override public int getMaxHitpoints() { return getCombatDefinitions().getHitpoints(); } public int getId() { return id; } public boolean checkNPCCollision(Direction dir) { if (isIgnoreNPCClipping() || isIntelligentRouteFinder() || isForceWalking()) return true; return WorldCollision.checkNPCClip(this, dir); } private void restoreTick() { for (Skill skill : Skill.values()) { int currentLevel = getLevel(skill); int normalLevel = getCombatDefinitions().getLevel(skill); if (currentLevel > normalLevel) setStat(skill, currentLevel - 1); else if (currentLevel < normalLevel) setStat(skill, Utils.clampI(currentLevel + 1, 0, normalLevel)); } } public void processNPC() { if (isDead() || locked) return; //Restore combat stats if (getTickCounter() % 100 == 0) restoreTick(); if (!combat.process() && routeEvent == null) { if (getTickCounter() % 3 == 0 && !isForceWalking() && !cantInteract && !checkAggressivity() && !hasEffect(Effect.FREEZE)) { if (!hasWalkSteps() && shouldRandomWalk()) { boolean can = Math.random() > 0.9; if (can) { int moveX = Utils.random(getDefinitions().hasAttackOption() ? 4 : 2, getDefinitions().hasAttackOption() ? 8 : 4); int moveY = Utils.random(getDefinitions().hasAttackOption() ? 4 : 2, getDefinitions().hasAttackOption() ? 8 : 4); if (Utils.random(2) == 0) moveX = -moveX; if (Utils.random(2) == 0) moveY = -moveY; resetWalkSteps(); DumbRouteFinder.addDumbPathfinderSteps(this, respawnTile.transform(moveX, moveY, 0), getDefinitions().hasAttackOption() ? 7 : 3, getCollisionStrategy()); if (Utils.getDistance(this.getTile(), respawnTile) > 3 && !getDefinitions().hasAttackOption()) DumbRouteFinder.addDumbPathfinderSteps(this, respawnTile, getDefinitions().hasAttackOption() ? 7 : 3, getCollisionStrategy()); } } } } if (isForceWalking()) if (!hasEffect(Effect.FREEZE)) if (getX() != forceWalk.getX() || getY() != forceWalk.getY()) { if (!hasWalkSteps()) { Route route = RouteFinderKt.routeEntityToTile(this, forceWalk, 25); if (route.getFailed()) { tele(Tile.of(forceWalk)); forceWalk = null; } else RouteFinderKt.walkRoute(this, route, true); } } else // walked till forcewalk place forceWalk = null; } @Override public void processEntity() { try { super.processEntity(); processNPC(); } catch (Throwable e) { Logger.handle(NPC.class, ""processEntityNPC"", e); } } public int getRespawnDirection() { return Direction.getById(getDefinitions().respawnDirection).getAngle(); } private static boolean forceRandomWalk(int npcId) { return switch (npcId) { case 11226 -> true; case 3341, 3342, 3343 -> true; default -> false; }; } @Override public void handlePreHit(final Hit hit) { if (capDamage != -1 && hit.getDamage() > capDamage) hit.setDamage(capDamage); if (hit.getLook() != HitLook.MELEE_DAMAGE && hit.getLook() != HitLook.RANGE_DAMAGE && hit.getLook() != HitLook.MAGIC_DAMAGE && hit.getLook() != HitLook.CANNON_DAMAGE) return; Entity source = hit.getSource(); if (source == null) return; if (source instanceof Player player) { SlayerMonsters thisMonster = SlayerMonsters.forId(getId()); if (thisMonster != null) if (player.getSkills().getLevel(Constants.SLAYER) < thisMonster.getRequirement()) { hit.setDamage(0); player.sendMessage(""You do not have the slayer level required to damage this monster.""); } if (hit.getDamage() > 0 && isTzhaarMonster() && TzHaar.depleteTokkulZo(player)) hit.setDamage((int) (hit.getDamage() * 1.1)); } handlePostHit(hit); } @Override public void handlePreHitOut(Entity target, Hit hit) { } @Override public void handlePostHit(Hit hit) { super.handlePostHit(hit); if (capDamage != -1 && hit.getDamage() > capDamage) hit.setDamage(capDamage); if (hit.getLook() == HitLook.MAGIC_DAMAGE) { if (hit.getSource() instanceof Player player && player.getAuraManager().isActivated(AuraManager.Aura.DARK_MAGIC) && hit.getData(""darkMagicBleed"") == null && Utils.random(100) < 13) { for (int i = 1; i <= 4; i++) { int finalI = i; getTasks().schedule(2 * i, () -> applyHit(new Hit(hit.getSource(), 26 - finalI, hit.getLook()).setData(""darkMagicBleed"", true))); } } } } @Override public void reset() { super.reset(); getInteractionManager().forceStop(); setFaceAngle(getRespawnDirection()); combat.reset(); combatLevels = NPCCombatDefinitions.getDefs(id).getLevels(); // back to real bonuses forceWalk = null; } @Override public void finish() { if (hasFinished()) return; setFinished(true); ChunkManager.updateChunks(this); WorldCollision.fillNPCClip(getTile(), getSize(), false); World.removeNPC(this); } public void setRespawnTask() { setRespawnTask(-1); } /** * For quests * @param ticks */ public void finishAfterTicks(final int ticks) { WorldTasks.scheduleTimer(tick -> { if (tick >= ticks) { if (!hasFinished()) finish(); return false; } return true; }); } public void setRespawnTask(int time) { if (!hasFinished()) { reset(); setTile(respawnTile); finish(); } respawnTask = WorldTasks.schedule(time < 0 ? getCombatDefinitions().getRespawnDelay() : time, this::spawn); } public void cancelRespawnTask() { if (respawnTask != null) WorldTasks.remove(respawnTask); } public void deserialize() { if (combat == null) combat = new NPCCombat(this); spawn(); } public void spawn() { if (deleted) return; timeLastSpawned = System.currentTimeMillis(); setFinished(false); World.addNPC(this); setLastChunkId(0); ChunkManager.updateChunks(this); loadMapRegions(); checkMultiArea(); if (getCombatDefinitions().getRespawnAnim() != -1) anim(getCombatDefinitions().getRespawnAnim()); onRespawn(); } public void permanentlyDelete() { finish(); deleted = true; } public void onRespawn() { } public long timeSinceSpawned() { return System.currentTimeMillis() - timeLastSpawned; } public NPCCombat getCombat() { return combat; } public int getLevel(Skill skill) { return combatLevels == null ? 1 : combatLevels.get(skill); } public int getAttackLevel() { return getLevel(Skill.ATTACK); } public int getDefenseLevel() { return getLevel(Skill.DEFENSE); } public int getStrengthLevel() { return getLevel(Skill.STRENGTH); } public int getRangeLevel() { return getLevel(Skill.RANGE); } public int getMagicLevel() { return getLevel(Skill.MAGE); } @Override public void sendDeath(final Entity source) { clearPendingTasks(); final NPCCombatDefinitions defs = getCombatDefinitions(); getInteractionManager().forceStop(); resetWalkSteps(); if (combat.getTarget() != null) combat.getTarget().setAttackedByDelay(0); combat.removeTarget(); if (source.getAttackedBy() == NPC.this) { source.setAttackedBy(null); source.setFindTargetDelay(0); } setNextAnimation(null); PluginManager.handle(new NPCDeathEvent(this, source)); WorldTasks.scheduleTimer(loop -> { if (loop == 0) { setNextAnimation(new Animation(defs.getDeathEmote())); soundEffect(source, getCombatDefinitions().getDeathSound(), true); } else if (loop >= defs.getDeathDelay()) { if (source instanceof Player player) player.getControllerManager().processNPCDeath(NPC.this); drop(); reset(); setTile(respawnTile); finish(); if (!isSpawned()) setRespawnTask(); return false; } return true; }); } public void drop(Player killer) { drop(killer, true); } public void drop(Player killer, boolean verifyCombatDefs) { try { if (verifyCombatDefs && (getCombatDefinitions() == NPCCombatDefinitions.DEFAULT_DEF || getMaxHitpoints() == 1)) return; String name = getDefinitions(killer).getName(); if (!name.equals(""null"") && !name.equals(""Fire spirit"")) killer.sendNPCKill(name); if (killer.getControllerManager().getController() != null && killer.getControllerManager().getController() instanceof GodwarsController) killer.sendGodwarsKill(this); if (killer.hasBossTask()) { String taskName = killer.getBossTask().getName().toLowerCase(); if (this.getDefinitions().getName().equalsIgnoreCase(taskName)) killer.getBossTask().sendKill(killer, this); } if (killer.hasSlayerTask() && killer.getSlayer().isOnTaskAgainst(this)) killer.getSlayer().sendKill(killer, this); if (getId() >= 2031 && getId() <= 2037) { killer.setBarrowsKillCount(killer.getBarrowsKillCount()+1); killer.getVars().setVarBit(464, killer.getBarrowsKillCount()+killer.getKilledBarrowBrothersCount()); } Item[] drops = DropTable.calculateDrops(killer, DropSets.getDropSet(id)); for (Item item : drops) sendDrop(killer, item); if (DropSets.getDropSet(id) != null && DropSets.getDropSet(id) != DropSets.DEFAULT_DROPSET && EffigyDrop.dropEffigy(getDefinitions().combatLevel)) sendDrop(killer, new Item(18778, 1)); Item[] clues = DropTable.calculateDrops(killer, NPCClueDrops.rollClues(id)); for (Item item : clues) sendDrop(killer, item); DropTable charm = CharmDrop.getCharmDrop(NPCDefinitions.getDefs(getId()).getName().toLowerCase()); if (charm != null) for (Drop d : charm.getDrops()) sendDrop(killer, d.toItem()); } catch (Exception | Error e) { e.printStackTrace(); } } public void drop() { try { Player killer = getMostDamageReceivedSourcePlayer(); if (killer == null) return; drop(killer); } catch (Exception | Error e) { e.printStackTrace(); } } public static boolean yellDrop(int itemId) { //Nex //Revenants if ((itemId >= 20125 && itemId <= 20174) || (itemId >= 13845 && itemId <= 13990)) return true; //Barrows if (itemId >= 4708 && itemId <= 4759 && itemId != 4740) return true; //New GWD Items if (itemId >= 24974 && itemId <= 25039) return true; return switch (itemId) { //KBD //Slayer Drops //Dagganoth Drops //Glacors //KQ //Tormented Demons //Original GWD case 25312, 25314, 25316, 25318, 11286, 11732, 15486, 11235, 4151, 21369, 6731, 6733, 6735, 6737, 6739, 21777, 21787, 21790, 21793, 3140, 14484, 11702, 11704, 11706, 11708, 11718, 11722, 11720, 11724, 11726, 11728, 11716, 11730 -> true; default -> false; }; } public void sendDrop(Player player, Item item) { Player dropTo = player; if (player.isLootSharing() && player.getAccount().getSocial().getCurrentFriendsChat() != null && !TreasureTrailsManager.isScroll(item.getId())) { ArrayList possible = player.getNearbyFCMembers(this); if (possible.size() > 0) { dropTo = possible.get(Utils.random(possible.size())); for (Player p : possible) if (!p.getUsername().equals(dropTo.getUsername())) p.sendMessage(dropTo.getDisplayName()+"" has recieved: ""+item.getAmount()+"" ""+item.getName()+"".""); else p.sendMessage(""You recieved: ""+item.getAmount()+"" ""+item.getName()+"".""); } } dropTo.incrementCount(item.getName()+"" drops earned"", item.getAmount()); if (yellDrop(item.getId())) World.broadcastLoot(dropTo.getDisplayName() + "" has just received a "" + item.getName() + "" drop from "" + getDefinitions().getName() + ""!""); final int size = getSize(); PluginManager.handle(new NPCDropEvent(dropTo, this, item)); if (item.getId() != -1 && dropTo.getNSV().getB(""sendingDropsToBank"")) { if (item.getDefinitions().isNoted()) item.setId(item.getDefinitions().certId); sendDropDirectlyToBank(dropTo, item); return; } GroundItem gItem = World.addGroundItem(item, Tile.of(getCoordFaceX(size), getCoordFaceY(size), getPlane()), dropTo, true, 60); int value = item.getDefinitions().getValue() * item.getAmount(); if (gItem != null && (value > player.getI(""lootbeamThreshold"", 90000) || item.getDefinitions().name.contains(""Scroll box"") || item.getDefinitions().name.contains("" defender"") || yellDrop(item.getId()))) player.getPackets().sendGroundItemMessage(50, 0xFF0000, gItem, ""You received: ""+ item.getAmount() + "" "" + item.getDefinitions().getName()); } public static void sendDropDirectlyToBank(Player player, Item item) { player.getBank().addItem(item, true); } public static ItemsContainer getDropsFor(int npcId, int npcAmount, boolean row) { ItemsContainer dropCollection = new ItemsContainer<>(Bank.MAX_BANK_SIZE, true); double modifier = 1.0; if (row) modifier -= 0.01; for (int i = 0; i < npcAmount; i++) { List drops = DropSets.getDropSet(npcId).getDropList().genDrop(modifier); for (Item item : drops) dropCollection.add(item); List clues = NPCClueDrops.rollClues(npcId).getDropList().genDrop(modifier); for (Item item : clues) dropCollection.add(item); if (EffigyDrop.dropEffigy(NPCDefinitions.getDefs(npcId).combatLevel)) dropCollection.add(new Item(18778, 1)); DropTable charm = CharmDrop.getCharmDrop(NPCDefinitions.getDefs(npcId).getName().toLowerCase()); if (charm != null) for (Drop d : charm.getDrops()) dropCollection.add(d.toItem()); } return dropCollection; } public static void displayDropsFor(Player player, int npcId, int npcAmount) { player.sendMessage(""Calculating drops...""); AsyncTaskExecutor.execute(() -> { long start = System.currentTimeMillis(); ItemsContainer dropCollection = getDropsFor(npcId, npcAmount, player.getEquipment().wearingRingOfWealth()); if (dropCollection == null) { player.sendMessage(""No drops found for that NPC.""); return; } dropCollection.sortByItemId(); player.getTempAttribs().setB(""viewingOtherBank"", true); player.getVars().setVarBit(8348, 0); player.getVars().syncVarsToClient(); player.getInterfaceManager().sendInterface(762); player.getPackets().sendRunScript(2319); player.getPackets().setIFText(762, 47, npcAmount+"" ""+NPCDefinitions.getDefs(npcId).getName()+"" kills""); player.getPackets().sendItems(95, dropCollection); player.getPackets().setIFEvents(new IFEvents(762, 95, 0, 516).enableRightClickOptions(0,1,2,3,4,5,6,9).setDepth(2).enableDrag()); player.getVars().setVarBit(4893, 1); player.getVars().syncVarsToClient(); player.sendMessage(""Calculated drops in "" + Utils.formatLong(System.currentTimeMillis() - start) + ""ms""); }); } @Override public int getSize() { return size; } public int getMaxHit() { return getCombatDefinitions().getMaxHit(); } public int getLevelForStyle(AttackStyle style) { int maxHit = getAttackLevel(); if (style == AttackStyle.RANGE) maxHit = getRangeLevel(); else if (style == AttackStyle.MAGE) maxHit = getMagicLevel(); return maxHit; } public int lowerDefense(double multiplier, double maxDrain) { return lowerStat(Skill.DEFENSE, multiplier, maxDrain); } public int lowerDefense(int drain, double maxDrain) { return lowerStat(Skill.DEFENSE, drain, maxDrain); } public int lowerAttack(double multiplier, double maxDrain) { return lowerStat(Skill.ATTACK, multiplier, maxDrain); } public int lowerAttack(int drain, double maxDrain) { return lowerStat(Skill.ATTACK, drain, maxDrain); } public int lowerStrength(double multiplier, double maxDrain) { return lowerStat(Skill.STRENGTH, multiplier, maxDrain); } public int lowerStrength(int drain, double maxDrain) { return lowerStat(Skill.STRENGTH, drain, maxDrain); } public int lowerMagic(double multiplier, double maxDrain) { return lowerStat(Skill.MAGE, multiplier, maxDrain); } public int lowerMagic(int drain, double maxDrain) { return lowerStat(Skill.MAGE, drain, maxDrain); } public int lowerRange(double multiplier, double maxDrain) { return lowerStat(Skill.RANGE, multiplier, maxDrain); } public int lowerRange(int drain, double maxDrain) { return lowerStat(Skill.RANGE, drain, maxDrain); } public int getStat(Skill skill) { if (combatLevels == null) return 0; Integer level = combatLevels.get(skill); if (level == null) return 0; return level; } public void setStat(Skill skill, int level) { if (combatLevels == null) combatLevels = new HashMap<>(); if (level < 0) level = 0; combatLevels.put(skill, level); } public int lowerStat(Skill stat, double multiplier, double maxDrain) { if (combatLevels != null) setStat(stat, Utils.clampI((int) (getStat(stat) - (getStat(stat) * multiplier)), (int) ((double) getCombatDefinitions().getLevels().get(stat) * maxDrain), getStat(stat))); return getStat(stat); } public int lowerStat(Skill stat, int levelDrain, double maxDrain) { if (combatLevels != null) setStat(stat, Utils.clampI(getStat(stat) - levelDrain, (int) ((double) getCombatDefinitions().getLevels().get(stat) * maxDrain), getStat(stat))); return getStat(stat); } public int getBonus(Bonus bonus) { if (NPCCombatDefinitions.getDefs(id).hasOverriddenBonuses()) return NPCCombatDefinitions.getDefs(id).getBonus(bonus); else return NPCDefinitions.getDefs(id).getBonus(bonus); } public void resetHP() { setHitpoints(getMaxHitpoints()); } public Bonus getHighestAttackBonus() { int highest = getBonus(Bonus.STAB_ATT); Bonus attType = Bonus.STAB_ATT; if (getBonus(Bonus.SLASH_ATT) > highest) { highest = getBonus(Bonus.SLASH_ATT); attType = Bonus.SLASH_ATT; } if (getBonus(Bonus.CRUSH_ATT) > highest) { highest = getBonus(Bonus.CRUSH_ATT); attType = Bonus.CRUSH_ATT; } return attType; } public Bonus getHighestDefenseBonus() { int highest = getBonus(Bonus.STAB_DEF); Bonus defType = Bonus.STAB_DEF; if (getBonus(Bonus.SLASH_DEF) > highest) { highest = getBonus(Bonus.SLASH_DEF); defType = Bonus.SLASH_DEF; } if (getBonus(Bonus.CRUSH_DEF) > highest) { highest = getBonus(Bonus.CRUSH_DEF); defType = Bonus.CRUSH_DEF; } return defType; } @Override public double getMagePrayerMultiplier() { return 0; } @Override public double getRangePrayerMultiplier() { return 0; } @Override public double getMeleePrayerMultiplier() { return 0; } public Tile getRespawnTile() { return respawnTile; } protected void setRespawnTile(Tile respawnTile) { this.respawnTile = Tile.of(respawnTile); } public boolean isUnderCombat() { return combat.hasTarget(); } @Override public void setAttackedBy(Entity target) { super.setAttackedBy(target); if (target == combat.getTarget() && !(combat.getTarget() instanceof Familiar)) lastAttackedByTarget = System.currentTimeMillis(); } public boolean canBeAutoRetaliated() { return System.currentTimeMillis() - lastAttackedByTarget > lureDelay; } public boolean isForceWalking() { return forceWalk != null; } public Entity getTarget() { return combat.getTarget(); } public void setTarget(Entity entity) { if (isForceWalking()) // if force walk not gonna get target return; combat.setTarget(entity); lastAttackedByTarget = System.currentTimeMillis(); } public void removeTarget() { if (combat.getTarget() == null) return; combat.removeTarget(); } public void forceWalkRespawnTile() { setForceWalk(respawnTile); } public void setForceWalk(Tile tile) { resetWalkSteps(); forceWalk = tile; } public boolean hasForceWalk() { return forceWalk != null; } public boolean isRevenant() { return getDefinitions().getName().toLowerCase().contains(""revenant""); } public AttackStyle getAttackStyle() { return getCombatDefinitions().getAttackStyle(); // if (bonuses[2] > 0) // return NPCCombatDefinitions.MAGE; // if (bonuses[1] > 0) // return NPCCombatDefinitions.RANGE; // return NPCCombatDefinitions.MELEE; } public List getPossibleTargets() { return getPossibleTargets(getCombatDefinitions().aggroDistance, canAggroNPCs); } public List getPossibleTargets(boolean includeNpcs) { return getPossibleTargets(getCombatDefinitions().aggroDistance, includeNpcs); } public List getPossibleTargets(int tileRadius) { return getPossibleTargets(tileRadius, canAggroNPCs); } public List getPossibleTargets(int tileRadius, boolean includeNpcs) { boolean isNormallyPassive = !forceAgressive && getCombatDefinitions().getAgressivenessType() == AggressiveType.PASSIVE; ArrayList possibleTarget = new ArrayList<>(); possibleTarget.addAll(queryNearbyPlayersByTileRange(tileRadius, player -> { if (isRevenant() && player.hasEffect(Effect.REV_AGGRO_IMMUNE)) return false; return !player.isDead() && canAggroPlayer(player) && (!isNormallyPassive || player.hasEffect(Effect.AGGRESSION_POTION)) && (player.hasEffect(Effect.AGGRESSION_POTION) || !player.isDocile() || ignoreDocile) && !player.getAppearance().isHidden() && !player.isTrulyHidden() && WorldUtil.isInRange(getX(), getY(), getSize(), player.getX(), player.getY(), player.getSize(), getAggroDistance()) && (forceMultiAttacked || (isAtMultiArea() && player.isAtMultiArea()) || player.getAttackedBy() == this || (!player.inCombat() && player.getFindTargetDelay() <= System.currentTimeMillis())) && lineOfSightTo(player, false) && (player.hasEffect(Effect.AGGRESSION_POTION) || forceAgressive || WildernessController.isAtWild(this.getTile()) || player.getSkills().getCombatLevelWithSummoning() < getCombatLevel() * 2); })); if (includeNpcs && !isNormallyPassive) { possibleTarget.addAll(queryNearbyNPCsByTileRange(tileRadius, npc -> npc != this && !npc.isDead() && canAggroNPC(npc) && WorldUtil.isInRange(getX(), getY(), getSize(), npc.getX(), npc.getY(), npc.getSize(), getAggroDistance()) && npc.getDefinitions().hasAttackOption() && (forceMultiAttacked || (isAtMultiArea() && npc.isAtMultiArea()) || npc.getAttackedBy() == this || (!npc.inCombat() && npc.getFindTargetDelay() <= System.currentTimeMillis())) && lineOfSightTo(npc, false))); } return possibleTarget; } private int getAggroDistance() { return forceAggroDistance > 0 ? forceAggroDistance : getCombatDefinitions().getAggroDistance(); } public boolean canAggroPlayer(Player target) { return true; } public boolean canAggroNPC(NPC target) { return true; } public boolean checkAggressivity() { if ((this instanceof Familiar || !getDefinitions().hasAttackOption()) && !forceAgressive) return false; List possibleTarget = getPossibleTargets(); if (!possibleTarget.isEmpty()) { Entity target = possibleTarget.get(Utils.random(possibleTarget.size())); setTarget(target); target.setAttackedBy(target); //target.setFindTargetDelay(System.currentTimeMillis() + 10000); //TODO makes everything possible aggro to you return true; } return false; } public boolean isCantInteract() { return cantInteract; } public void setCantInteract(boolean cantInteract) { this.cantInteract = cantInteract; if (cantInteract) combat.reset(); } public int getCapDamage() { return capDamage; } public void setCapDamage(int capDamage) { this.capDamage = capDamage; } public int getLureDelay() { return lureDelay; } public void setLureDelay(int lureDelay) { this.lureDelay = lureDelay; } public boolean isCantFollowUnderCombat() { return cantFollowUnderCombat; } public void setCantFollowUnderCombat(boolean canFollowUnderCombat) { cantFollowUnderCombat = canFollowUnderCombat; } public Transformation getNextTransformation() { return nextTransformation; } @Override public String toString() { return ""[""+getDefinitions().getName() + "" - id: "" + id + "" @ ("" + getX() + "","" + getY() + "","" + getPlane()+"")]""; } public boolean isForceAgressive() { return forceAgressive; } public NPC setForceAgressive(boolean forceAgressive) { this.forceAgressive = forceAgressive; return this; } public void setForceAggroDistance(int forceAggroDistance) { this.forceAggroDistance = forceAggroDistance; } public boolean isForceFollowClose() { return forceFollowClose; } public void setForceFollowClose(boolean forceFollowClose) { this.forceFollowClose = forceFollowClose; } public boolean isForceMultiAttacked() { return forceMultiAttacked; } public void setForceMultiAttacked(boolean forceMultiAttacked) { this.forceMultiAttacked = forceMultiAttacked; } public boolean shouldRandomWalk() { return randomWalk; } public void setRandomWalk(boolean forceRandomWalk) { randomWalk = forceRandomWalk; } public String getCustomName() { return name; } public void setPermName(String string) { name = getDefinitions().getName().equals(string) ? null : string; permName = true; } public void setName(String string) { name = getDefinitions().getName().equals(string) ? null : string; changedName = true; } public int getCustomCombatLevel() { return combatLevel; } public int getCombatLevel() { return combatLevel >= 0 ? combatLevel : getDefinitions().combatLevel; } public String getName() { return name != null ? name : getDefinitions().getName(); } public String getName(Player player) { return name != null ? name : getDefinitions().getName(player.getVars()); } public void setCombatLevel(int level) { combatLevel = getDefinitions().combatLevel == level ? -1 : level; changedCombatLevel = true; } public boolean hasChangedName() { return permName || changedName; } public boolean hasChangedCombatLevel() { return changedCombatLevel; } public boolean isSpawned() { return spawned; } public void setSpawned(boolean spawned) { this.spawned = spawned; } public boolean isNoDistanceCheck() { return noDistanceCheck; } public void setNoDistanceCheck(boolean noDistanceCheck) { this.noDistanceCheck = noDistanceCheck; } public boolean withinDistance(Player tile, int distance) { return !hidden && super.withinDistance(tile.getTile(), distance); } /** * Gets the locked. * * @return The locked. */ public boolean isLocked() { return locked; } /** * Sets the locked. * * @param locked * The locked to set. */ public void setLocked(boolean locked) { this.locked = locked; } public void setLockedForTicks(int ticks) { WorldTasks.scheduleTimer(i -> { if(i==0) this.locked = true; if(i==ticks) { this.locked = false; return false; } return true; }); } @Override public boolean canMove(Direction dir) { return true; } public boolean isIntelligentRouteFinder() { return intelligentRoutefinder; } public void setIntelligentRouteFinder(boolean intelligentRoutefinder) { this.intelligentRoutefinder = intelligentRoutefinder; } public int getAttackSpeed() { return NPCDefinitions.getDefs(id).getAttackDelay()+1; } public boolean isIgnoreDocile() { return ignoreDocile; } public void setIgnoreDocile(boolean ignoreDocile) { this.ignoreDocile = ignoreDocile; } private boolean isTzhaarMonster() { return switch (getId()) { case 2591, 2592, 2594, 2595, 2596, 2597, 2600, 2601, 2602, 2603, 2605, 2606, 2607, 2608, 2609, 2611, 2614, 2615, 2616, 2617, 2628, 2629, 2630, 2631, 2632, 2734, 2735, 2736, 2737, 2738, 2739, 2740, 2741, 2742, 2743, 2744, 2745, 2746, 7767, 7768, 7769, 7770, 7771, 7772, 7773, 15170, 15171, 15177, 15178, 15181, 15182, 15183, 15184, 15186, 15187, 15188, 15189, 15190, 15191, 15192, 15196, 15197, 15198, 15199, 15201, 15202, 15203, 15204, 15205, 15206, 15207, 15208, 15209, 15210, 15211, 15212, 15213, 15214 -> true; default -> false; }; } public boolean canBeAttackedBy(Player player) { if (getId() == 879 || getId() == 14578) if (player.getEquipment().getWeaponId() != 2402 && player.getCombatDefinitions().getSpell() != null && !PolyporeStaffKt.usingPolypore(player)) { player.sendMessage(""I'd better wield Silverlight first.""); return false; } return true; } public boolean canAggroNPCs() { return canAggroNPCs; } public void setCanAggroNPCs(boolean canAggroNPCs) { this.canAggroNPCs = canAggroNPCs; } public boolean blocksOtherNpcs() { return true; } public boolean isIgnoreNPCClipping() { return ignoreNPCClipping; } public void setIgnoreNPCClipping(boolean ignoreNPCClipping) { this.ignoreNPCClipping = ignoreNPCClipping; } public NPCBodyMeshModifier getBodyMeshModifier() { return bodyMeshModifier; } public void setBodyMeshModifier(NPCBodyMeshModifier meshModifier) { if (meshModifier == null) { bodyMeshModifier = NPCBodyMeshModifier.RESET; return; } bodyMeshModifier = meshModifier; } public NPCBodyMeshModifier modifyMesh() { bodyMeshModifier = new NPCBodyMeshModifier(getDefinitions()); return bodyMeshModifier; } public void resetMesh() { setBodyMeshModifier(NPCBodyMeshModifier.RESET); } public boolean isHidden() { return hidden; } public void setHidden(boolean hidden) { this.hidden = hidden; } public boolean isLoadsUpdateZones() { return loadsUpdateZones; } public void persistBeyondCutscene() { getTempAttribs().setB(""persistBeyondCutscene"", true); } public boolean persistsBeyondCutscene() { return getTempAttribs().getB(""persistBeyondCutscene""); } public void stopAll() { getActionManager().forceStop(); getInteractionManager().forceStop(); } }" "package com.rs.game.model.entity.npc; public class NPCBodyMeshModifier { public static final NPCBodyMeshModifier RESET = new NPCBodyMeshModifier(); private static final byte RESET_FLAG = 0x1, MODEL_FLAG = 0x2, COLOR_FLAG = 0x4, TEXTURE_FLAG = 0x8; private NPCDefinitions defs; private int[] modelIds; private short[] modifiedColors; private short[] modifiedTextures; private NPCBodyMeshModifier() { } public NPCBodyMeshModifier(NPCDefinitions defs) { this.defs = defs; } public NPCBodyMeshModifier setModel(int index, int modelId) { if (modelIds == null) { modelIds = new int[defs.modelIds.length]; System.arraycopy(defs.modelIds, 0, modelIds, 0, modelIds.length); } if (index < 0 || index >= modelIds.length) throw new RuntimeException(""Index "" + index + "" for models of "" + defs.id + "" is out of bounds.""); if (modelId == -1) modelIds[index] = defs.modelIds[index]; else modelIds[index] = modelId; return this; } public NPCBodyMeshModifier addModels(int... models) { if (Arrays.equals(models, defs.modelIds)) return this; modelIds = new int[defs.modelIds.length]; System.arraycopy(defs.modelIds, 0, modelIds, 0, modelIds.length); for (int i = 0;i < defs.modelIds.length;i++) { if (i >= models.length) continue; modelIds[i] = models[i]; } return this; } public NPCBodyMeshModifier setColor(int index, int color) { if (modifiedColors == null && defs.modifiedColors != null) { modifiedColors = new short[defs.modifiedColors.length]; System.arraycopy(defs.modifiedColors, 0, modifiedColors, 0, modifiedColors.length); } if (modifiedColors == null || index < 0 || index >= modifiedColors.length) throw new RuntimeException(""Index "" + index + "" for models of "" + defs.id + "" is out of bounds.""); if (color == -1) modifiedColors[index] = defs.modifiedColors[index]; else modifiedColors[index] = (short) color; return this; } public NPCBodyMeshModifier addColors(int... colors) { if (defs.modifiedColors != null) { modifiedColors = new short[defs.modifiedColors.length]; System.arraycopy(defs.modifiedColors, 0, modifiedColors, 0, modifiedColors.length); } if (modifiedColors == null) return this; for (int i = 0;i < modifiedColors.length;i++) { if (i >= colors.length) break; modifiedColors[i] = (short) colors[i]; } return this; } public NPCBodyMeshModifier setTexture(int index, int texId) { if (modifiedTextures == null && defs.modifiedTextures != null) { modifiedTextures = new short[defs.modifiedTextures.length]; System.arraycopy(defs.modifiedTextures, 0, modifiedTextures, 0, modifiedTextures.length); } if (modifiedTextures == null || index < 0 || index >= modifiedTextures.length) throw new RuntimeException(""Index "" + index + "" for models of "" + defs.id + "" is out of bounds.""); if (texId == -1) modifiedTextures[index] = defs.modifiedTextures[index]; else modifiedTextures[index] = (short) texId; return this; } public NPCBodyMeshModifier addTextures(int... textures) { if (defs.modifiedTextures != null) { modifiedTextures = new short[defs.modifiedTextures.length]; System.arraycopy(defs.modifiedTextures, 0, modifiedTextures, 0, modifiedTextures.length); } if (modifiedTextures == null) return this; for (int i = 0;i < modifiedTextures.length;i++) { if (i >= textures.length) break; modifiedTextures[i] = (short) textures[i]; } return this; } public int encode(OutputStream stream) { int flags = getModificationFlags(); if (flags == 0) return -1; stream.write128Byte(flags); if ((flags & MODEL_FLAG) != 0) encodeModels(stream); if ((flags & COLOR_FLAG) != 0) encodeColors(stream); if ((flags & TEXTURE_FLAG) != 0) encodeTextures(stream); return flags; } public void encodeModels(OutputStream stream) { for (int modelId : modelIds) stream.writeBigSmart(modelId); } public void encodeColors(OutputStream stream) { for (short modifiedColor : modifiedColors) stream.writeShort(modifiedColor); } public void encodeTextures(OutputStream stream) { for (short modifiedTexture : modifiedTextures) stream.writeShort(modifiedTexture); } public int getModificationFlags() { int flags = 0; if (modelIds != null) flags |= MODEL_FLAG; if (modifiedColors != null) flags |= COLOR_FLAG; if (modifiedTextures != null) flags |= TEXTURE_FLAG; if (flags == 0) flags |= RESET_FLAG; return flags; } }" "package com.rs.game.model.entity.npc; public class OwnedNPC extends NPC { private final Player owner; private final boolean hideFromOtherPlayers; private boolean autoDespawnAtDistance = true; public OwnedNPC(Player owner, int id, Tile tile, boolean hideFromOtherPlayers) { super(id, tile, true); this.owner = owner; this.hideFromOtherPlayers = hideFromOtherPlayers; } @Override public void processNPC() { if (getOwner() == null || getOwner().hasFinished() || (autoDespawnAtDistance && !withinDistance(getOwner(), 15))) { onDespawnEarly(); finish(); } super.processNPC(); } @Override public boolean withinDistance(Player player, int distance) { if (!hideFromOtherPlayers || player == getOwner()) return super.withinDistance(player, distance); return false; } @Override public boolean canBeAttackedBy(Player player) { if (getOwner() != player) { player.sendMessage(""They aren't interested in you.""); return false; } return true; } public void onDespawnEarly() {} public Player getOwner() { return owner; } public void teleToOwner() { Tile tile = owner.getNearestTeleTile(this); if (tile != null) tele(tile); } public boolean isAutoDespawnAtDistance() { return autoDespawnAtDistance; } public void setAutoDespawnAtDistance(boolean autoDespawnAtDistance) { this.autoDespawnAtDistance = autoDespawnAtDistance; } }" "package com.rs.game.model.entity.npc; public record Transformation(int toNPCId) { }" "package com.rs.game.model.entity.npc.combat; public abstract class CombatScript { public abstract Object[] getKeys(); public abstract int attack(NPC npc, Entity target); public static void delayHit(NPC npc, int delay, final Entity target, final int gfx, final Hit... hits) { npc.getCombat().addAttackedByDelay(target); for (Hit hit : hits) { if (npc.isDead() || npc.hasFinished() || target.isDead() || target.hasFinished()) return; target.applyHit(hit, delay, () -> { npc.getCombat().doDefenceEmote(target); target.setNextSpotAnim(new SpotAnim(gfx)); if (target instanceof Player player) { player.closeInterfaces(); if (!player.isLocked() && player.getCombatDefinitions().isAutoRetaliate() && !player.getActionManager().hasSkillWorking() && player.getInteractionManager().getInteraction() == null && !player.hasWalkSteps()) player.getInteractionManager().setInteraction(new PlayerCombatInteraction(player, npc)); } else { NPC n = (NPC) target; if (!n.isUnderCombat() || n.canBeAutoRetaliated()) n.setTarget(npc); } }); } } public static Hit delayHit(NPC npc, int delay, Entity target, Hit hit) { return delayHit(npc, delay, target, hit, null); } public static Hit delayHit(NPC npc, int delay, Entity target, Hit hit, Runnable afterDelay) { npc.getCombat().addAttackedByDelay(target); if (npc.isDead() || npc.hasFinished() || target.isDead() || target.hasFinished()) { hit.setDamage(0); return hit; } target.applyHit(hit, delay, () -> { if (afterDelay != null) afterDelay.run(); npc.getCombat().doDefenceEmote(target); if (target instanceof Player player) { player.closeInterfaces(); if (!player.isLocked() && player.getCombatDefinitions().isAutoRetaliate() && !player.getActionManager().hasSkillWorking() && player.getInteractionManager().getInteraction() == null && !player.hasWalkSteps()) player.getInteractionManager().setInteraction(new PlayerCombatInteraction(player, npc)); } else { NPC n = (NPC) target; if (!n.isUnderCombat() || n.canBeAutoRetaliated()) n.setTarget(npc); } }); return hit; } public static Hit getRangeHit(NPC npc, int damage) { return new Hit(npc, damage, HitLook.RANGE_DAMAGE); } public static Hit getMagicHit(NPC npc, int damage) { return new Hit(npc, damage, HitLook.MAGIC_DAMAGE); } public static Hit getRegularHit(NPC npc, int damage) { return new Hit(npc, damage, HitLook.TRUE_DAMAGE); } public static Hit getMeleeHit(NPC npc, int damage) { return new Hit(npc, damage, HitLook.MELEE_DAMAGE); } public static int getMaxHitFromAttackStyleLevel(NPC npc, AttackStyle attackType, Entity target) { return getMaxHit(npc, npc.getLevelForStyle(attackType), attackType, target); } public static int getMaxHit(NPC npc, AttackStyle attackType, Entity target) { return getMaxHit(npc, npc.getMaxHit(), attackType, target); } public static int getMaxHit(NPC npc, int maxHit, AttackStyle attackStyle, Entity target) { return getMaxHit(npc, maxHit, attackStyle, target, 1.0D); } public static int getMaxHit(NPC npc, int maxHit, AttackStyle attackStyle, Entity target, double accuracyModifier) { return getMaxHit(npc, maxHit, null, attackStyle, target, accuracyModifier); } public static int getMaxHit(NPC npc, int maxHit, Bonus attackBonus, AttackStyle attackStyle, Entity target) { return getMaxHit(npc, maxHit, attackBonus, attackStyle, target, 1.0D); } public static int getMaxHit(NPC npc, int maxHit, Bonus attackBonus, AttackStyle attackStyle, Entity target, double accuracyModifier) { double atkLvl; double atkBonus; Bonus attType; if (attackStyle == AttackStyle.RANGE) atkLvl = npc.getRangeLevel() + 8; else if (attackStyle == AttackStyle.MAGE) atkLvl = npc.getMagicLevel() + 8; else atkLvl = npc.getAttackLevel() + 8; if (attackStyle == AttackStyle.RANGE) { atkBonus = npc.getBonus(Bonus.RANGE_ATT); attType = Bonus.RANGE_ATT; } else if (attackStyle == AttackStyle.MAGE) { atkBonus = npc.getBonus(Bonus.MAGIC_ATT); attType = Bonus.MAGIC_ATT; } else if (attackBonus == null) { if (npc.getCombatDefinitions().getAttackBonus() == null) { int highest = npc.getBonus(Bonus.STAB_ATT); attType = Bonus.STAB_ATT; if (npc.getBonus(Bonus.SLASH_ATT) > highest) { highest = npc.getBonus(Bonus.SLASH_ATT); attType = Bonus.SLASH_ATT; } if (npc.getBonus(Bonus.CRUSH_ATT) > highest) { highest = npc.getBonus(Bonus.CRUSH_ATT); attType = Bonus.CRUSH_ATT; } atkBonus = highest; } else { attType = npc.getCombatDefinitions().getAttackBonus(); atkBonus = npc.getBonus(npc.getCombatDefinitions().getAttackBonus()); } } else { attType = attackBonus; atkBonus = npc.getBonus(attackBonus); } double atk = Math.floor(atkLvl * (atkBonus + 64)); atk *= accuracyModifier; double def; if (target instanceof Player player) { def = switch (attType) { case RANGE_ATT -> { double defLvl = Math.floor(player.getSkills().getLevel(Constants.DEFENSE) * player.getPrayer().getDefenceMultiplier()); double defBonus = player.getCombatDefinitions().getBonus(Bonus.RANGE_DEF); defLvl += 8; yield Math.floor(defLvl * (defBonus + 64)); } case MAGIC_ATT -> { double defLvl = Math.floor(player.getSkills().getLevel(Constants.DEFENSE) * player.getPrayer().getDefenceMultiplier()); defLvl += player.getCombatDefinitions().getAttackStyle().attackType == AttackType.LONG_RANGE || player.getCombatDefinitions().getAttackStyle().xpType == XPType.DEFENSIVE ? 3 : player.getCombatDefinitions().getAttackStyle().xpType == XPType.CONTROLLED ? 1 : 0; defLvl += 8; defLvl *= 0.3; double magLvl = Math.floor(player.getSkills().getLevel(Constants.MAGIC) * player.getPrayer().getMageMultiplier()); magLvl *= 0.7; double totalDefLvl = defLvl+magLvl; double defBonus = player.getCombatDefinitions().getBonus(Bonus.MAGIC_DEF); yield Math.floor(totalDefLvl * (defBonus + 64)); } case STAB_ATT, SLASH_ATT, CRUSH_ATT -> { double defLvl = Math.floor(player.getSkills().getLevel(Constants.DEFENSE) * player.getPrayer().getDefenceMultiplier()); double defBonus = player.getCombatDefinitions().getBonus(attType == Bonus.CRUSH_ATT ? Bonus.CRUSH_DEF : attType == Bonus.STAB_ATT ? Bonus.STAB_DEF : Bonus.SLASH_DEF); defLvl += 8; yield Math.floor(defLvl * (defBonus + 64)); } default -> player.getCombatDefinitions().getBonus(Bonus.STAB_ATT); }; if (attackStyle == AttackStyle.MELEE) if (player.getFamiliarPouch() == Pouch.STEEL_TITAN) def *= 1.15; } else { NPC n = (NPC) target; def = switch (attType) { case RANGE_ATT -> { int defLvl = n.getDefenseLevel(); int defBonus = n.getDefinitions().getRangeDef(); defLvl += 8; yield (double) (defLvl * (defBonus + 64)); } case MAGIC_ATT -> { double defLvl = n.getMagicLevel(); double defBonus = n.getDefinitions().getMagicDef(); defLvl += 8; yield Math.floor(defLvl * (defBonus + 64)); } case STAB_ATT -> { double defLvl = n.getDefenseLevel(); double defBonus = n.getDefinitions().getStabDef(); defLvl += 8; yield Math.floor(defLvl * (defBonus + 64)); } case SLASH_ATT -> { double defLvl = n.getDefenseLevel(); double defBonus = n.getDefinitions().getSlashDef(); defLvl += 8; yield Math.floor(defLvl * (defBonus + 64)); } case CRUSH_ATT -> { double defLvl = n.getDefenseLevel(); double defBonus = n.getDefinitions().getCrushDef(); defLvl += 8; yield Math.floor(defLvl * (defBonus + 64)); } default -> { double defLvl = n.getDefenseLevel(); double defBonus = n.getDefinitions().getStabDef(); defLvl += 8; yield Math.floor(defLvl * (defBonus + 64)); } }; } double prob = atk > def ? (1 - (def+2) / (2*(atk+1))) : (atk / (2*(def+1))); if (Settings.getConfig().isDebug() && target instanceof Player player) if (player.getNSV().getB(""hitChance"")) player.sendMessage(""Your chance of being hit: "" + Utils.formatDouble(prob*100.0) + ""%""); if (prob <= Math.random()) return 0; return Utils.getRandomInclusive(maxHit); } }" "package com.rs.game.model.entity.npc.combat; @PluginEventHandler public class CombatScriptsHandler { private static final HashMap> MAPPED_SCRIPTS = new HashMap<>(); static { MAPPED_SCRIPTS.put(""DEFAULT"", (npc, target) -> { NPCCombatDefinitions defs = npc.getCombatDefinitions(); NPCCombatDefinitions.AttackStyle attackStyle = defs.getAttackStyle(); if (attackStyle == NPCCombatDefinitions.AttackStyle.MELEE) CombatScript.delayHit(npc, 0, target, CombatScript.getMeleeHit(npc, CombatScript.getMaxHit(npc, npc.getMaxHit(), attackStyle, target))); else { int damage = CombatScript.getMaxHit(npc, npc.getMaxHit(), attackStyle, target); WorldProjectile p = World.sendProjectile(npc, target, defs.getAttackProjectile(), 32, 32, 50, 2, 2, 0); CombatScript.delayHit(npc, p.getTaskDelay(), target, attackStyle == NPCCombatDefinitions.AttackStyle.RANGE ? CombatScript.getRangeHit(npc, damage) : CombatScript.getMagicHit(npc, damage)); } if (defs.getAttackGfx() != -1) npc.setNextSpotAnim(new SpotAnim(defs.getAttackGfx())); npc.setNextAnimation(new Animation(defs.getAttackEmote())); npc.soundEffect(target, npc.getCombatDefinitions().getAttackSound(), true); return npc.getAttackSpeed(); }); } @ServerStartupEvent(Priority.FILE_IO) public static void loadScripts() { List> classes; try { classes = Utils.getSubClasses(""com.rs"", CombatScript.class); for (Class c : classes) { if (c.isAnonymousClass()) // next continue; Object o = c.getDeclaredConstructor().newInstance(); if (!(o instanceof CombatScript script)) continue; for (Object key : script.getKeys()) { if (key instanceof Object[] arr) { for (Object val : arr) MAPPED_SCRIPTS.put(val, script::attack); } else MAPPED_SCRIPTS.put(key, script::attack); } } } catch (Exception e) { e.printStackTrace(); } Logger.info(CombatScriptsHandler.class, ""loadScripts"", ""Loaded combat scripts for "" + MAPPED_SCRIPTS.size() + "" NPCs...""); } public static int attack(final NPC npc, final Entity target) { BiFunction script = MAPPED_SCRIPTS.get(npc.getId()); if (script == null) { script = MAPPED_SCRIPTS.get(npc.getDefinitions().getName()); if (script == null) script = getDefaultCombat(); } return script.apply(npc, target); } public static BiFunction getDefaultCombat() { return MAPPED_SCRIPTS.get(""DEFAULT""); } public static void addCombatScript(Object npcNameOrId, BiFunction script) { MAPPED_SCRIPTS.put(npcNameOrId, script); } public static void addCombatScript(Object[] npcNameOrIds, BiFunction script) { for (Object key : npcNameOrIds) MAPPED_SCRIPTS.put(key, script); } }" "package com.rs.game.model.entity.npc.combat; public final class NPCCombat { private final NPC npc; private int combatDelay; private Entity target; public NPCCombat(NPC npc) { this.npc = npc; } public int getCombatDelay() { return combatDelay; } /* * returns if under combat */ public boolean process() { if (combatDelay > 0) combatDelay--; if (target != null) { if (!checkAll()) { removeTarget(); return false; } if (combatDelay <= 0) combatDelay = combatAttack(); return true; } return false; } /* * return combatDelay */ private int combatAttack() { Entity target = this.target; // prevents multithread issues if (target == null) return 0; if (target instanceof Familiar familiar && familiar.getPouch().getScroll().getTarget() == ScrollTarget.COMBAT && Utils.random(3) == 0) { Player player = familiar.getOwner(); if (player != null) { target = player; npc.setTarget(target); addAttackedByDelay(target); } } int maxDistance = npc.getCombatDefinitions().getAttackRange(); if (!(npc instanceof Nex) && !npc.lineOfSightTo(target, maxDistance == 0)) return npc.getAttackSpeed(); boolean los = npc.lineOfSightTo(target, maxDistance == 0); boolean inRange = WorldUtil.isInRange(npc, target, maxDistance + (npc.hasWalkSteps() && target.hasWalkSteps() ? (npc.getRun() && target.getRun() ? 2 : 1) : 0)); //boolean collidesCheck = !npc.isCantFollowUnderCombat() && WorldUtil.collides(npc, target); //add collision check here to enable jagex's cancer NPC walking mechanic if (!los || !inRange) return 0; addAttackedByDelay(target); return CombatScriptsHandler.attack(npc, target); } void doDefenceEmote(Entity target) { target.setNextAnimationNoPriority(new Animation(PlayerCombatKt.getDefenceEmote(target))); } public Entity getTarget() { return target; } public void addAttackedByDelay(Entity target) { target.setAttackedBy(npc); target.setAttackedByDelay(System.currentTimeMillis() + npc.getAttackSpeed() * 600L + 600); // 8seconds } public void setTarget(Entity target) { this.target = target; npc.setNextFaceEntity(target); if (!checkAll()) { removeTarget(); } } public boolean checkAll() { Entity target = this.target; // prevents multithread issues if (target == null) return false; if (npc.isDead() || npc.hasFinished() || npc.isForceWalking() || target.isDead() || target.hasFinished() || npc.getPlane() != target.getPlane()) return false; if (npc.hasEffect(Effect.FREEZE)) return true; // if freeze cant move ofc int distanceX = npc.getX() - npc.getRespawnTile().getX(); int distanceY = npc.getY() - npc.getRespawnTile().getY(); int size = npc.getSize(); int maxDistance; if (!npc.isNoDistanceCheck() && !npc.isCantFollowUnderCombat()) { maxDistance = npc.getCombatDefinitions().getMaxDistFromSpawn(); if (!(npc instanceof Familiar)) if (distanceX > size + maxDistance || distanceX < -1 - maxDistance || distanceY > size + maxDistance || distanceY < -1 - maxDistance) { npc.forceWalkRespawnTile(); return false; } maxDistance = npc.getCombatDefinitions().getDeAggroDistance(); distanceX = target.getX() - npc.getX(); distanceY = target.getY() - npc.getY(); if (distanceX > size + maxDistance || distanceX < -1 - maxDistance || distanceY > size + maxDistance || distanceY < -1 - maxDistance) return false; // if target distance higher 16 } if (!npc.canAttackMulti(target) || !target.canAttackMulti(npc)) return false; int targetSize = target.getSize(); boolean colliding = WorldUtil.collides(npc.getX(), npc.getY(), size, target.getX(), target.getY(), targetSize); if (!npc.isCantFollowUnderCombat()) { if (colliding) { if (!npc.hasWalkSteps() && !target.hasWalkSteps()) { if (!npc.addWalkSteps(target.getX() - size, npc.getY())) { //check west npc.resetWalkSteps(); if (!npc.addWalkSteps(target.getX() + targetSize, npc.getY())) { //check east npc.resetWalkSteps(); if (!npc.addWalkSteps(npc.getX(), target.getY() - size)) { //check south npc.resetWalkSteps(); if (!npc.addWalkSteps(npc.getX(), target.getY() + targetSize)) { //check north return true; } } } } } return true; } if (npc.getAttackStyle() == AttackStyle.MELEE && targetSize == 1 && size == 1 && Math.abs(npc.getX() - target.getX()) == 1 && Math.abs(npc.getY() - target.getY()) == 1 && !target.hasWalkSteps()) { if (!npc.addWalkSteps(target.getX(), npc.getY(), 1)) npc.addWalkSteps(npc.getX(), target.getY(), 1); return true; } maxDistance = npc.isForceFollowClose() ? 0 : npc.getCombatDefinitions().getAttackRange(); npc.resetWalkSteps(); boolean los = npc.lineOfSightTo(target, maxDistance == 0); boolean inRange = WorldUtil.isInRange(npc.getX(), npc.getY(), size, target.getX(), target.getY(), targetSize, maxDistance); if (!los || !inRange) { npc.calcFollow(target, npc.getRun() ? 2 : 1, npc.isIntelligentRouteFinder()); return true; } } return true; } public void addCombatDelay(int delay) { combatDelay += delay; } public void setCombatDelay(int delay) { combatDelay = delay; } public boolean hasTarget() { return target != null; } public void removeTarget() { target = null; npc.setNextFaceEntity(null); } public void reset() { combatDelay = 0; target = null; } }" "package com.rs.game.model.entity.npc.combat; @PluginEventHandler public class NPCCombatDefinitions { private final static String PATH = ""data/npcs/combatdefs/""; public static HashMap COMBAT_DEFINITIONS = new HashMap<>(); public static NPCCombatDefinitions DEFAULT_DEF; private static Map DEFAULT_LEVELS = new HashMap<>(); static { for (Skill skill : Skill.values()) DEFAULT_LEVELS.put(skill, 0); NPCCombatDefinitions def = new NPCCombatDefinitions(); def.attackStyle = AttackStyle.MELEE; def.agressivenessType = AggressiveType.PASSIVE; DEFAULT_DEF = def; } public enum AttackStyle { MELEE, RANGE, MAGE } public enum Skill { ATTACK, STRENGTH, DEFENSE, RANGE, MAGE } public enum AggressiveType { PASSIVE, AGGRESSIVE } private transient boolean realStats = true; private int[] ids; private String[] names; private int attackAnim; private int attackSound = -1; private int defenceAnim; private int defendSound = -1; private int deathAnim; private int deathDelay; private int deathSound = -1; private int respawnDelay; private int respawnAnim = -1; private int hitpoints; private int maxHit; private AttackStyle attackStyle; private Bonus attackBonus; private Map combatLevels; private Map bonuses; private int attackRange = -1; //10 by default for range private int attackGfx; private int attackProjectile; private AggressiveType agressivenessType; public int aggroDistance = -1; //4 for melee, 8 for range default private int deAggroDistance = -1; //16 by default private int maxDistFromSpawn = -1; //16 by default 64 for special/special2 public NPCCombatDefinitions() { hitpoints = 1; attackAnim = -1; deathAnim = -1; defenceAnim = -1; deathDelay = 3; respawnDelay = 60; maxHit = 1; attackGfx = -1; attackProjectile = -1; } public NPCCombatDefinitions(int... ids) { this(); this.ids = ids; } public NPCCombatDefinitions(String... names) { this(); this.names = names; } public NPCCombatDefinitions(NPCCombatDefinitions defs) { ids = defs.ids == null ? null : defs.ids.clone(); names = defs.names == null ? null : defs.names.clone(); hitpoints = defs.hitpoints; attackAnim = defs.attackAnim; defenceAnim = defs.defenceAnim; deathAnim = defs.deathAnim; deathDelay = defs.deathDelay; respawnDelay = defs.respawnDelay; maxHit = defs.maxHit; attackStyle = defs.attackStyle; attackGfx = defs.attackGfx; attackProjectile = defs.attackProjectile; agressivenessType = defs.agressivenessType; attackBonus = defs.attackBonus; combatLevels = defs.combatLevels == null ? null : new HashMap<>(defs.combatLevels); } @ServerStartupEvent(Priority.FILE_IO) public static final void init() { loadPackedCombatDefinitions(); } public static void reload() { COMBAT_DEFINITIONS.clear(); loadPackedCombatDefinitions(); } public static NPCCombatDefinitions getDefs(int npcId) { NPCCombatDefinitions defs = COMBAT_DEFINITIONS.get(npcId); if (defs == null && (NPCDefinitions.getDefs(npcId).hasAttackOption() || Summoning.isFamiliar(npcId))) defs = COMBAT_DEFINITIONS.get(NPCDefinitions.getDefs(npcId).getName()); if (defs == null) defs = DEFAULT_DEF; if (defs.combatLevels == null) { if (NPCDefinitions.getDefs(npcId).combatLevel > 0) { defs.combatLevels = generateLevels(NPCDefinitions.getDefs(npcId).combatLevel, (int) (defs.hitpoints / 10.0)); } defs.realStats = false; } else defs.realStats = true; return defs; } private static void loadPackedCombatDefinitions() { try { File[] dropFiles = new File(PATH).listFiles(); for (File f : dropFiles) loadFile(f); } catch (Throwable e) { Logger.handle(NPCCombatDefinitions.class, ""loadPackedCombatDefinitions"", e); } } private static void loadFile(File f) { try { if (f.isDirectory()) { for (File dir : f.listFiles()) loadFile(dir); return; } NPCCombatDefinitions defs = (NPCCombatDefinitions) JsonFileManager.loadJsonFile(f, NPCCombatDefinitions.class); if (defs != null) { if (defs.getIds() != null) for (int id : defs.getIds()) COMBAT_DEFINITIONS.put(id, defs); if (defs.getNames() != null) for (String name : defs.getNames()) COMBAT_DEFINITIONS.put(name, defs); } } catch(Throwable e) { System.err.println(""Error loading file: "" + f.getPath()); } } public int getRespawnAnim() { return respawnAnim; } public int getRespawnDelay() { return respawnDelay; } public int getDeathEmote() { return deathAnim; } public int getDefenceEmote() { return defenceAnim; } public int getAttackEmote() { return attackAnim; } public int getAttackGfx() { return attackGfx; } public AggressiveType getAgressivenessType() { return agressivenessType; } public int getAttackProjectile() { return attackProjectile; } public AttackStyle getAttackStyle() { return attackStyle; } public Bonus getAttackBonus() { return attackBonus; } public int getMaxHit() { return maxHit; } public void setMaxHit(int maxHit) { this.maxHit = maxHit; } public int getHitpoints() { return hitpoints; } public void setHitpoints(int hitpoints) { this.hitpoints = hitpoints; } public int getDeathDelay() { return deathDelay; } public Map getLevels() { if (combatLevels == null) return new HashMap<>(DEFAULT_LEVELS); return new HashMap<>(combatLevels); } public int[] getIds() { return ids; } public String[] getNames() { return names; } public int getLevel(Skill skill) { return getLevels().get(skill) == null ? 1 : getLevels().get(skill); } public int getAttackLevel() { return getLevel(Skill.ATTACK); } public int getStrengthLevel() { return getLevel(Skill.STRENGTH); } public int getDefenseLevel() { return getLevel(Skill.DEFENSE); } public int getMagicLevel() { return getLevel(Skill.MAGE); } public int getRangeLevel() { return getLevel(Skill.RANGE); } public static Map generateLevels(int combat, int hp) { return generateLevels(combat, hp, Integer.MAX_VALUE, Integer.MAX_VALUE); } public static Map generateLevels(int combat, int hp, int clampAttack, int clampDefense) { Map levels = new HashMap<>(); int def = (int) (((combat/1.32 + 1) / 0.25) - hp); combat -= (int) ((def + hp) * 0.25) + 1; int off = (int) ((combat/0.325)/1.5); int avg = (def+off)/2; levels.put(Skill.ATTACK, Utils.clampI(avg, 0, clampAttack)); levels.put(Skill.STRENGTH, Utils.clampI(avg, 0, clampAttack)); levels.put(Skill.DEFENSE, Utils.clampI(avg, 0, clampDefense)); levels.put(Skill.RANGE, Utils.clampI(avg, 0, clampAttack)); levels.put(Skill.MAGE, Utils.clampI(avg, 0, clampDefense)); return levels; } public int getCombatLevel() { int attack = getLevel(Skill.ATTACK); int defence = getLevel(Skill.DEFENSE); int strength = getLevel(Skill.STRENGTH); int hp = hitpoints/10; int ranged = getLevel(Skill.RANGE); int magic = getLevel(Skill.MAGE); int combatLevel = 3; combatLevel = (int) ((defence + hp) * 0.25) + 1; double melee = (attack + strength) * 0.325; double ranger = Math.floor(ranged * 1.5) * 0.325; double mage = Math.floor(magic * 1.5) * 0.325; if (melee >= ranger && melee >= mage) combatLevel += melee; else if (ranger >= melee && ranger >= mage) combatLevel += ranger; else if (mage >= melee && mage >= ranger) combatLevel += mage; return combatLevel; } public void setAttackBonus(Bonus bonus) { attackBonus = bonus; } public void addId(int npcId) { names = null; if (ids == null) { ids = new int[] { npcId }; return; } for (int id : ids) if (id == npcId) return; int[] newIds = new int[ids.length+1]; for (int i = 0;i < ids.length;i++) newIds[i] = ids[i]; newIds[ids.length] = npcId; ids = newIds; } public void addName(String name) { ids = null; names = new String[] { name }; } public boolean isRealStats() { return realStats; } public int getMaxDistFromSpawn() { if (maxDistFromSpawn <= 0) return 16; return maxDistFromSpawn; } public int getDeAggroDistance() { if (deAggroDistance <= 0) return 16; return deAggroDistance; } public int getAggroDistance() { if (aggroDistance <= 0) return getAttackStyle() == AttackStyle.MELEE ? 4 : getAttackRange() - 2; return aggroDistance; } public int getAttackRange() { if (attackRange < 0) return getAttackStyle() == AttackStyle.MELEE ? 0 : getAttackStyle() == AttackStyle.RANGE ? 7 : 10; return attackRange; } public boolean hasOverriddenBonuses() { return bonuses != null && bonuses.size() > 0; } public int getBonus(Bonus bonus) { if (bonuses == null) return 1000; if (bonuses.get(bonus) == null) return 0; return (Integer) bonuses.get(bonus); } public int getAttackSound() { return attackSound; } public int getDefendSound() { return defendSound; } public int getDeathSound() { return deathSound; } }" "package com.rs.game.model.entity.npc.combat class NPCCombatUtil { companion object { @JvmStatic fun projectileBounce(npc: NPC, target: Entity, targetsHit: MutableSet, projId: Int, hitSpotAnim: Int, bounceSpeed: Double, bouncedFrom: Entity? = null, onHit: Consumer) { World.sendProjectile(bouncedFrom ?: npc, target, projId, 30, 15, bounceSpeed) { target.spotAnim(hitSpotAnim) onHit.accept(target) val nextTarget = npc.queryNearbyPlayersByTileRange(2) { !targetsHit.contains(it) } .minByOrNull { Utils.getDistance(it.tile, target.tile) } if (nextTarget != null) { targetsHit.add(nextTarget) projectileBounce(npc, nextTarget, targetsHit, projId, hitSpotAnim, bounceSpeed, target, onHit) } } } } }" "package com.rs.game.model.entity.player; public class Appearance { private int title; private int[] lookI; private int[] colour; private boolean male; private transient boolean glowRed; private transient byte[] appearanceData; private transient byte[] md5AppearanceDataHash; private transient short transformedNpcId; private transient boolean hidePlayer; public static final int FEMALE_HAIR_STRUCT_LOOKUP = 2341; public static final int MALE_HAIR_STRUCT_LOOKUP = 2338; public static final int MALE_HAIR_SLOT_LOOKUP = 2339; public static final int FEMALE_HAIR_SLOT_LOOKUP = 2342; public static final int HAIR_WITH_HAT_PARAM = 790; public static final int HAIR_WITH_FACE_MASK_PARAM = 791; private transient Player player; public Appearance() { male = true; title = -1; resetAppearance(); } public void setGlowRed(boolean glowRed) { this.glowRed = glowRed; generateAppearanceData(); } public void setPlayer(Player player) { this.player = player; transformedNpcId = -1; if (lookI == null) resetAppearance(); } public void transformIntoNPC(int id) { transformedNpcId = (short) id; generateAppearanceData(); } public void switchHidden() { hidePlayer = !hidePlayer; generateAppearanceData(); } public void setHidden(boolean hidden) { hidePlayer = hidden; generateAppearanceData(); } public boolean isHidden() { return hidePlayer; } public boolean isGlowRed() { return glowRed; } private int getHatHairStyle(int baseStyle, boolean isFaceMask) { EnumDefinitions lookup = EnumDefinitions.getEnum(male ? MALE_HAIR_SLOT_LOOKUP : FEMALE_HAIR_SLOT_LOOKUP); int slot = lookup.getIntValue(baseStyle); EnumDefinitions structLookup = EnumDefinitions.getEnum(male ? MALE_HAIR_STRUCT_LOOKUP : FEMALE_HAIR_STRUCT_LOOKUP); int structID = structLookup.getIntValue(slot); return StructDefinitions.getStruct(structID).getIntValue(isFaceMask ? HAIR_WITH_FACE_MASK_PARAM : HAIR_WITH_HAT_PARAM, -1); } public void generateAppearanceData() { OutputStream stream = new OutputStream(); boolean pvpArea = World.isPvpArea(player); boolean showSkillTotal = player.getTempAttribs().getB(""showSkillTotal"") && !pvpArea; if (glowRed && player.getNextBodyGlow() == null) player.setNextBodyGlow(new BodyGlow(90, 0, 0, 0, 255)); int flag = 0; if (!male) flag |= 0x1; if (transformedNpcId >= 0 && NPCDefinitions.getDefs(transformedNpcId).aBool4872) flag |= 0x2; if (showSkillTotal) flag |= 0x4; if (title != 0 || player.getTitle() != null) flag |= isTitleAfter(title) || player.isTitleAfter() ? 0x80 : 0x40; // after/before // flag += sizeOffset << 3; // flag |= 0x7; stream.writeByte(flag); if (title != 0 || player.getTitle() != null) stream.writeGJString(player.getFormattedTitle()); stream.writeByte(player.hasSkull() ? player.getSkullId() : -1); stream.writeByte(player.getTempAttribs().getI(""customHeadIcon"", -1) != -1 ? player.getTempAttribs().getI(""customHeadIcon"") : player.getPrayer().getPrayerHeadIcon()); stream.writeByte(hidePlayer ? 1 : 0); if (transformedNpcId >= 0) { stream.writeShort(-1); stream.writeShort(transformedNpcId); stream.writeByte(0); } else { for (int index = 0; index < 4; index++) { Item item = player.getEquipment().get(index); if (item == null) stream.writeByte(0); else stream.writeShort(16384 + item.getId()); } Item item = player.getEquipment().get(Equipment.CHEST); stream.writeShort(item == null ? 0x100 + lookI[2] : 16384 + item.getId()); item = player.getEquipment().get(Equipment.SHIELD); if (item == null) stream.writeByte(0); else stream.writeShort(16384 + item.getId()); item = player.getEquipment().get(Equipment.CHEST); if (lookI[3] != -1 && (item == null || !Equipment.hideArms(item))) stream.writeShort(0x100 + lookI[3]); else if (item != null && !Equipment.hideArms(item)) stream.writeShort(0x100 + getOldArms()); else stream.writeByte(0); item = player.getEquipment().get(Equipment.LEGS); stream.writeShort(item == null ? 0x100 + lookI[5] : 16384 + item.getId()); item = player.getEquipment().get(Equipment.HEAD); if (lookI[0] != -1 && (item == null || !Equipment.hideHair(item))) { if (item == null) stream.writeShort(0x100 + lookI[0]); else { int hatHairStyle = getHatHairStyle(lookI[0], item.getDefinitions().faceMask()); if (hatHairStyle != -1) stream.writeShort(0x100 + hatHairStyle); else stream.writeByte(0); } } else stream.writeByte(0); item = player.getEquipment().get(Equipment.HANDS); stream.writeShort(item == null ? 0x100 + lookI[4] : 16384 + item.getId()); item = player.getEquipment().get(Equipment.FEET); stream.writeShort(item == null ? 0x100 + lookI[6] : 16384 + item.getId()); item = player.getEquipment().get(male ? Equipment.HEAD : Equipment.CHEST); if (male && lookI[1] != -1 && (item == null || (male && !Equipment.hideBeard(item)))) stream.writeShort(0x100 + lookI[1]); else stream.writeByte(0); item = player.getEquipment().get(Equipment.AURA); if (item == null) stream.writeByte(0); else stream.writeShort(16384 + item.getId()); encodeMeshModifiers(stream); } for (int element : colour) stream.writeByte(element); stream.writeShort(getRenderEmote()); stream.writeString(player.getDisplayName()); stream.writeByte(pvpArea ? player.getSkills().getCombatLevel() : player.getSkills().getCombatLevelWithSummoning()); if (showSkillTotal) stream.writeShort(player.getSkills().getTotalLevel()); else { stream.writeByte(pvpArea ? player.getSkills().getCombatLevelWithSummoning() : 0); stream.writeByte(player.getPvpCombatLevelThreshhold()); } stream.writeByte(transformedNpcId >= 0 ? 1 : 0); if (transformedNpcId >= 0) { NPCDefinitions defs = NPCDefinitions.getDefs(transformedNpcId); stream.writeShort(defs.walkingAnimation); stream.writeShort(defs.rotate180Animation); stream.writeShort(defs.rotate90RightAnimation); stream.writeShort(defs.rotate90LeftAnimation); stream.writeByte(defs.specialByte); } // done separated for safe because of synchronization byte[] appeareanceData = new byte[stream.getOffset()]; System.arraycopy(stream.getBuffer(), 0, appeareanceData, 0, appeareanceData.length); byte[] md5Hash = Utils.encryptUsingMD5(appeareanceData); appearanceData = appeareanceData; md5AppearanceDataHash = md5Hash; } private ArrayList getMeshModifiers() { ArrayList modifiers = new ArrayList<>(); int slotFlag = -1; for (int slotId = 0; slotId < Equipment.SIZE; slotId++) { if (Equipment.DISABLED_SLOTS[slotId] != 0) continue; slotFlag++; if (player.getEquipment().getId(slotId) == -1) continue; Item item = player.getEquipment().get(slotId); if (item == null) continue; ItemDefinitions defs = item.getDefinitions(); if (defs == null) continue; switch(defs.getId()) { case 1833: case 1835: case 1171: case 2637: ItemMeshModifier mod = new ItemMeshModifier(defs, slotFlag); boolean add = false; if (item.getMetaDataI(""drTOr"", -1) > 0) { mod.addTextures(item.getMetaDataI(""drTOr"", -1), item.getMetaDataI(""drTOr"", -1), item.getMetaDataI(""drTOr"", -1)); add = true; } if (item.getMetaDataI(""drCOr"", -1) > 0) { mod.addColors(item.getMetaDataI(""drCOr"", -1)); add = true; } if (add) modifiers.add(mod); break; case 20767: case 20768: modifiers.add(new ItemMeshModifier(defs, slotFlag) .addColors(player.getMaxedCapeCustomized())); break; case 20769: case 20770: case 20771: case 20772: modifiers.add(new ItemMeshModifier(defs, slotFlag) .addColors(player.getCompletionistCapeCustomized())); break; case 20708: case 20709: if (player.getClan() != null) modifiers.add(new ItemMeshModifier(defs, slotFlag) .addColors(player.getClan().getMotifColors()) .addTextures(player.getClan().getMotifTextures())); break; } if (slotId == Equipment.AURA && player.getAuraManager().isActive()) modifiers.add(new ItemMeshModifier(defs, slotFlag) .addBodyModels(player.getAuraManager().getAuraModelId(), player.getAuraManager().getAuraModelId2())); } return modifiers; } private void encodeMeshModifiers(OutputStream stream) { int start = stream.getOffset(); stream.writeShort(0); int slotHash = 0; for (ItemMeshModifier modifier : getMeshModifiers()) { int slot = modifier.encode(stream); if (slot != -1) slotHash |= 1 << slot; } int end = stream.getOffset(); stream.setOffset(start); stream.writeShort(slotHash); stream.setOffset(end); } public int getSize() { if (transformedNpcId >= 0) return NPCDefinitions.getDefs(transformedNpcId).size; return 1; } public void setBAS(int id) { player.setBas(id); generateAppearanceData(); } public boolean isTitleAfter(int title) { if (title >= 32 && title <= 37) return true; if (title == 64) return false; if (title >= 58 && title <= 65) return true; return title == 40 || title == 43 || title == 45 || title == 47 || title == 49 || title == 53 || title == 55 || title == 56 || title == 72 || title == 73; } public int getTransformedNPC() { return transformedNpcId; } public boolean isNPC() { return transformedNpcId != -1; } public int getRenderEmote() { if (player.getBas() >= 0) return player.getBas(); if (transformedNpcId >= 0) return NPCDefinitions.getDefs(transformedNpcId).basId; return player.getEquipment().getWeaponBAS(); } public void resetAppearance() { lookI = new int[7]; colour = new int[10]; male(); } public int getOldArms() { return male ? 26 : 61; } public void male() { lookI[0] = 310; lookI[1] = 16; lookI[2] = 452; lookI[3] = -1; lookI[4] = 371; lookI[5] = 627; lookI[6] = 433; colour[0] = 12; colour[1] = 218; colour[2] = 218; colour[3] = 180; colour[4] = 110; colour[5] = 0; colour[6] = 0; colour[7] = 0; colour[8] = 0; colour[9] = 0; male = true; } public void female() { lookI[0] = 274; lookI[1] = -1; lookI[2] = 561; lookI[3] = -1; lookI[4] = 514; lookI[5] = 482; lookI[6] = 547; colour[0] = 12; colour[1] = 218; colour[2] = 218; colour[3] = 180; colour[4] = 110; colour[5] = 0; colour[6] = 0; colour[7] = 0; colour[8] = 0; colour[9] = 0; male = false; } public byte[] getAppeareanceData() { return appearanceData; } public byte[] getMD5AppeareanceDataHash() { return md5AppearanceDataHash; } public boolean isMale() { return male; } public void setLook(int i, int i2) { lookI[i] = i2; if (i == 2) verifyArms(); } public void setColor(int i, int i2) { colour[i] = (byte) i2; } public void setMale(boolean male) { this.male = male; } public void setHairStyle(int i) { lookI[0] = i; } public void setTopStyle(int i) { lookI[2] = i; verifyArms(); } public int getTopStyle() { return lookI[2]; } public void setArmsStyle(int i) { lookI[3] = i; } public int getArmsStyle() { return lookI[3]; } public void setWristsStyle(int i) { lookI[4] = i; } public int getWristsStyle() { return lookI[4]; } public void setLegsStyle(int i) { lookI[5] = i; } public int getHairStyle() { return lookI[0]; } public void setBeardStyle(int i) { lookI[1] = i; } public int getBeardStyle() { return lookI[1]; } public void setFacialHair(int i) { lookI[1] = i; } public int getFacialHair() { return lookI[1]; } public void setSkinColor(int color) { colour[4] = (byte) color; } public int getSkinColor() { return colour[4]; } public void setHairColor(int color) { colour[0] = (byte) color; } public void setTopColor(int color) { colour[1] = (byte) color; } public void setLegsColor(int color) { colour[2] = (byte) color; } public void setBootsStyle(int i) { lookI[6] = i; } public void setBootsColor(int color) { colour[3] = (byte) color; } public int getHairColor() { return colour[0]; } public void setTitle(int title) { this.title = title; generateAppearanceData(); } public int getTitle() { return title; } public void verifyArms() { int topStyle = getTopStyle(); int setId = getSetByStyle(topStyle, 3, !isMale()); if (setId != -1) { StructDefinitions set = StructDefinitions.getStruct(setId); setArmsStyle(set.getIntValue(1183, -1)); setWristsStyle(set.getIntValue(1184, -1)); } else { if (EnumDefinitions.getEnum(isMale() ? 711 : 693).getKeyForValue(getArmsStyle()) == -1) setArmsStyle(isMale() ? 26 : 61); if (EnumDefinitions.getEnum(isMale() ? 749 : 751).getKeyForValue(getWristsStyle()) == -1) setWristsStyle(isMale() ? 34 : 68); } } private static int getSetByStyle(int styleID, int styleSlot, boolean female) { EnumDefinitions sets = EnumDefinitions.getEnum(5735); for (int slot = sets.getSize() - 1; slot >= 0; slot--) { int structId = sets.getIntValue(slot); if (structId != -1) { StructDefinitions struct = StructDefinitions.getStruct(structId); int v7 = 0; for (int setId = getSetStruct(struct, 0, female); setId != -1; setId = getSetStruct(struct, v7, female)) { StructDefinitions setStyles = StructDefinitions.getStruct(setId); switch (styleSlot) { case 3: if (setStyles.getIntValue(1182, -1) == styleID) return setId; break; case 4: if (setStyles.getIntValue(1183, -1) == styleID) return setId; break; case 5: if (setStyles.getIntValue(1184, -1) == styleID) return setId; break; case 6: if (setStyles.getIntValue(1185, -1) == styleID) return setId; break; default: return -1; } v7++; } } } return -1; } private static int getSetStruct(StructDefinitions struct, int slot, boolean female) { return switch (slot) { case 0 -> struct.getIntValue(female ? 1175 : 1169, -1); case 1 -> struct.getIntValue(female ? 1176 : 1170, -1); case 2 -> struct.getIntValue(female ? 1177 : 1171, -1); case 3 -> struct.getIntValue(female ? 1178 : 1172, -1); case 4 -> struct.getIntValue(female ? 1179 : 1173, -1); case 5 -> struct.getIntValue(female ? 1180 : 1174, -1); default -> -1; }; } public void printDebug() { for (int i = 0;i < lookI.length;i++) Logger.debug(Appearance.class, ""printDebug"", ""lookI[""+i+""] = "" + lookI[i] + "";""); for (int i = 0;i < colour.length;i++) Logger.debug(Appearance.class, ""printDebug"", ""colour[""+i+""] = "" + colour[i] + "";""); } }" "package com.rs.game.model.entity.player; @PluginEventHandler public class Bank { public static Set BLOCKED_BANK_ITEMS = new IntOpenHashSet(List.of(2528, 4447, 6543, 6796, 7498, 10586, 10889, 11137, 11139, 11141, 11157, 11185, 11186, 11187, 11188, 11189, 11679, 11753, 11754, 11755, 12627, 12628, 13227, 13439, 13446, 13447, 13448, 13463, 14574, 14575, 14576, 14580, 14581, 14582, 14633, 14634, 14635, 14711, 14740, 15346, 15348, 15350, 15351, 15389, 15390, 18782, 18783, 18808, 19750, 19751, 19752, 19755, 19756, 19758, 19759, 19761, 19764, 19765, 19767, 19768, 19775, 21770, 21771, 21772, 23085, 23086, 23087, 23088, 23089, 23090, 23645, 23648, 24138, 24139, 24140, 24141, 24142, 24143, 24151, 24300, 24503, 24504, 24506, 25070, 25119, 25131, 25131, 25132, 25133, 20935, 20936, 20960)); static { for (int id : Utils.range(23713, 23771)) BLOCKED_BANK_ITEMS.add(id); for (int id : Utils.range(23773, 23817)) BLOCKED_BANK_ITEMS.add(id); } public static ItemAddedToBankHandler blockXpItems = new ItemAddedToBankHandler(BLOCKED_BANK_ITEMS.toArray(), e -> { e.getPlayer().sendMessage(""A magical force prevents you from banking this item.""); e.cancel(); }); private static final long PIN_VALIDITY_TIME = 6 * 60 * 60 * 1000; //6 hours private Item[][] bankTabs; private short bankPin; private int lastX; private transient Player player; private transient int currentTab; private transient Item[] lastContainerCopy; private transient boolean withdrawNotes; private transient boolean insertItems; private transient boolean sessionPin; private Map enteredPin; public static final int MAX_BANK_SIZE = 800; public Bank() { bankTabs = new Item[1][0]; } public static ButtonClickHandler handleDepositBox = new ButtonClickHandler(11, e -> { if (e.getComponentId() == 17) { if (e.getPacket() == ClientPacket.IF_OP1) e.getPlayer().getBank().depositItem(e.getSlotId(), 1, false); else if (e.getPacket() == ClientPacket.IF_OP2) e.getPlayer().getBank().depositItem(e.getSlotId(), 5, false); else if (e.getPacket() == ClientPacket.IF_OP3) e.getPlayer().getBank().depositItem(e.getSlotId(), 10, false); else if (e.getPacket() == ClientPacket.IF_OP4) e.getPlayer().getBank().depositItem(e.getSlotId(), Integer.MAX_VALUE, false); else if (e.getPacket() == ClientPacket.IF_OP5) e.getPlayer().sendInputInteger(""How many would you like to deposit?"", (integer) -> e.getPlayer().getBank().depositItem(e.getSlotId(), integer, true)); else if (e.getPacket() == ClientPacket.IF_OP6) e.getPlayer().getInventory().sendExamine(e.getSlotId()); } else if (e.getComponentId() == 18) e.getPlayer().getBank().depositAllInventory(false); else if (e.getComponentId() == 22) e.getPlayer().getBank().depositAllEquipment(false); }); public static ButtonClickHandler handleInvButtons = new ButtonClickHandler(762, e -> { if (e.getPlayer().getTempAttribs().getB(""viewingOtherBank"")) return; if (e.getComponentId() == 15) e.getPlayer().getBank().switchInsertItems(); else if (e.getComponentId() == 19) e.getPlayer().getBank().switchWithdrawNotes(); else if (e.getComponentId() == 33) e.getPlayer().getBank().depositAllInventory(true); else if (e.getComponentId() == 37) e.getPlayer().getBank().depositAllEquipment(true); else if (e.getComponentId() == 39) e.getPlayer().getBank().depositAllBob(true); else if (e.getComponentId() == 35) { int amount = e.getPlayer().getInventory().getPouchCoinsAsInt(); if (amount <= 0) return; Item bankCoins = e.getPlayer().getBank().getItem(995); int bankAmt = bankCoins == null ? 0 : bankCoins.getAmount(); if (amount + bankAmt <= 0) amount = Integer.MAX_VALUE - bankAmt; if (amount == 0) { e.getPlayer().sendMessage(""You can't deposit any coins.""); return; } e.getPlayer().getInventory().removeCoins(amount, true); e.getPlayer().getBank().addItem(new Item(995, amount), true); } else if (e.getComponentId() == 46) { e.getPlayer().closeInterfaces(); e.getPlayer().getInterfaceManager().sendInterface(767); e.getPlayer().setCloseInterfacesEvent(() -> { e.getPlayer().getBank().open(); e.getPlayer().abortDialogue(); e.getPlayer().getPackets().sendRunScript(571); }); } else if (e.getComponentId() >= 46 && e.getComponentId() <= 64) { int tabId = 9 - ((e.getComponentId() - 46) / 2); if (e.getPacket() == ClientPacket.IF_OP1) e.getPlayer().getBank().setCurrentTab(tabId); else if (e.getPacket() == ClientPacket.IF_OP2) e.getPlayer().getBank().collapse(tabId); } else if (e.getComponentId() == 95) { if (e.getPacket() == ClientPacket.IF_OP1) e.getPlayer().getBank().withdrawItem(e.getSlotId(), 1); else if (e.getPacket() == ClientPacket.IF_OP2) e.getPlayer().getBank().withdrawItem(e.getSlotId(), 5); else if (e.getPacket() == ClientPacket.IF_OP3) e.getPlayer().getBank().withdrawItem(e.getSlotId(), 10); else if (e.getPacket() == ClientPacket.IF_OP4) e.getPlayer().getBank().withdrawLastAmount(e.getSlotId()); else if (e.getPacket() == ClientPacket.IF_OP5) e.getPlayer().sendInputInteger(""How many would you like to withdraw?"", amount -> { if (amount < 0) return; e.getPlayer().getBank().setLastX(amount); e.getPlayer().getBank().refreshLastX(); e.getPlayer().getBank().withdrawItem(e.getSlotId(), amount); }); else if (e.getPacket() == ClientPacket.IF_OP6) e.getPlayer().getBank().withdrawItem(e.getSlotId(), Integer.MAX_VALUE); else if (e.getPacket() == ClientPacket.IF_OP7) e.getPlayer().getBank().withdrawItemButOne(e.getSlotId()); else if (e.getPacket() == ClientPacket.IF_OP10) e.getPlayer().getBank().sendExamine(e.getSlotId()); } else if (e.getComponentId() == 119) Equipment.openEquipmentBonuses(e.getPlayer(), true); }); public static ButtonClickHandler handleBankButtons = new ButtonClickHandler(763, e -> { if (e.getPlayer().getTempAttribs().getB(""viewingOtherBank"")) return; if (e.getComponentId() == 0) if (e.getPacket() == ClientPacket.IF_OP1) e.getPlayer().getBank().depositItem(e.getSlotId(), 1, true); else if (e.getPacket() == ClientPacket.IF_OP2) e.getPlayer().getBank().depositItem(e.getSlotId(), 5, true); else if (e.getPacket() == ClientPacket.IF_OP3) e.getPlayer().getBank().depositItem(e.getSlotId(), 10, true); else if (e.getPacket() == ClientPacket.IF_OP4) e.getPlayer().getBank().depositLastAmount(e.getSlotId()); else if (e.getPacket() == ClientPacket.IF_OP5) e.getPlayer().sendInputInteger(""How many would you like to deposit?"", amount -> { if (amount < 0) return; e.getPlayer().getBank().setLastX(amount); e.getPlayer().getBank().refreshLastX(); e.getPlayer().getBank().depositItem(e.getSlotId(), amount, !e.getPlayer().getInterfaceManager().topOpen(11)); }); else if (e.getPacket() == ClientPacket.IF_OP6) e.getPlayer().getBank().depositItem(e.getSlotId(), Integer.MAX_VALUE, true); else if (e.getPacket() == ClientPacket.IF_OP10) e.getPlayer().getInventory().sendExamine(e.getSlotId()); }); public void removeItem(int id) { if (bankTabs != null) for (int i = 0; i < bankTabs.length; i++) for (int i2 = 0; i2 < bankTabs[i].length; i2++) if (bankTabs[i][i2].getId() == id) removeItem(new int[] { i, i2 }, Integer.MAX_VALUE, true, false); } public void deleteItem(int itemId, int amount) { if (bankTabs != null) for (Item[] bankTab : bankTabs) for (Item element : bankTab) if (element.getId() == itemId) { element.setAmount(element.getAmount() - amount); refreshItems(); } } public boolean containsItem(int itemId, int amount) { if (bankTabs != null) for (Item[] bankTab : bankTabs) for (Item element : bankTab) if (element.getId() == itemId) if (element.getAmount() >= amount) return true; return false; } public boolean containsItem(int itemId) { if (bankTabs != null) { for (Item[] bankTab : bankTabs) { for (Item element : bankTab) { if (element.getId() == itemId) { return true; } } } } return false; } public void setPlayer(Player player) { this.player = player; if (bankTabs == null || bankTabs.length == 0) bankTabs = new Item[1][0]; } public boolean sortCurrentTab() { if (currentTab < 0 || currentTab >= bankTabs.length) return false; Item[] tab = bankTabs[currentTab]; Arrays.sort(tab, (o1, o2) -> { int o1Id = o1 == null ? Integer.MAX_VALUE : o1.getId(); int o2Id = o2 == null ? Integer.MAX_VALUE : o2.getId(); return o1Id - o2Id; }); refreshItems(); refreshTabs(); refreshViewingTab(); return true; } @SuppressWarnings(""null"") public void setItem(int slotId, int amt) { Item item = getItem(slotId); if (item == null) { item.setAmount(amt); refreshItems(); refreshTabs(); refreshViewingTab(); } } public void refreshTabs(Player player) { for (int slot = 1; slot < 9; slot++) refreshTab(player, slot); } public void refreshTabs() { for (int slot = 1; slot < 9; slot++) refreshTab(slot); } public int getTabSize(int slot) { if (slot >= bankTabs.length) return 0; return bankTabs[slot].length; } public int getTabSize(Player other, int slot) { if (slot >= other.getBank().getBankTabs().length) return 0; return other.getBank().getBankTabs()[slot].length; } public Item[][] getBankTabs() { return bankTabs; } public void withdrawLastAmount(int bankSlot) { withdrawItem(bankSlot, lastX); } public void withdrawItemButOne(int fakeSlot) { int[] fromRealSlot = getRealSlot(fakeSlot); Item item = getItem(fromRealSlot); if (item == null) return; if (item.getAmount() <= 1) { player.sendMessage(""You only have one of this item in your bank""); return; } withdrawItem(fakeSlot, item.getAmount() - 1); } public void depositLastAmount(int bankSlot) { depositItem(bankSlot, lastX, true); } public void depositAllInventory(boolean banking) { if (player.getTempAttribs().getB(""viewingOtherBank"")) return; if (Bank.MAX_BANK_SIZE - getBankSize() < player.getInventory().getItems().getSize()) { player.sendMessage(""Not enough space in your bank.""); return; } for (int i = 0; i < 28; i++) { depositItem(i, Integer.MAX_VALUE, true); refreshTab(currentTab); refreshItems(); } } public void depositAllBob(boolean banking) { if (player.getTempAttribs().getB(""viewingOtherBank"")) return; Familiar familiar = player.getFamiliar(); if (familiar == null || familiar.getInventory() == null) return; for (int i = 0; i < familiar.getInventory().getSize(); i++) { if (addItem(familiar.getInventory().get(i), banking)) familiar.getInventory().set(i, null); } } public void depositAllEquipment(boolean banking) { if (player.getTempAttribs().getB(""viewingOtherBank"")) return; for (int i = 0;i < Equipment.SIZE;i++) { Item prev = player.getEquipment().setSlot(i, null); if (prev == null || prev.getId() == -1) continue; if (!addItem(prev, banking)) { player.sendMessage(""Not enough space in your bank.""); break; } } player.getAppearance().generateAppearanceData(); } public void collapse(int tabId) { if (tabId == 0 || tabId >= bankTabs.length) return; Item[] items = bankTabs[tabId]; for (Item item : items) removeItem(getItemSlot(item.getId()), item.getAmount(), false, true); for (Item item : items) addItem(item, 0, false); refreshTabs(); refreshItems(); } public void switchItem(int fromSlot, int toSlot, int fromComponentId, int toComponentId) { if (toSlot == -1) { int toTab = toComponentId >= 76 ? 8 - (84 - toComponentId) : 9 - ((toComponentId - 46) / 2); if (toTab < 0 || toTab > 9) return; if (bankTabs.length == toTab) { int[] fromRealSlot = getRealSlot(fromSlot); if (fromRealSlot == null) return; if (toTab == fromRealSlot[0]) { switchItem(fromSlot, getStartSlot(toTab)); return; } Item item = getItem(fromRealSlot); if (item == null) return; removeItem(fromSlot, item.getAmount(), false, true); createTab(); bankTabs[bankTabs.length - 1] = new Item[] { item }; refreshTab(fromRealSlot[0]); refreshTab(toTab); refreshItems(); } else if (bankTabs.length > toTab) { int[] fromRealSlot = getRealSlot(fromSlot); if (fromRealSlot == null) return; if (toTab == fromRealSlot[0]) { switchItem(fromSlot, getStartSlot(toTab)); return; } Item item = getItem(fromRealSlot); if (item == null) return; boolean removed = removeItem(fromSlot, item.getAmount(), false, true); if (!removed) refreshTab(fromRealSlot[0]); else if (fromRealSlot[0] != 0 && toTab >= fromRealSlot[0]) toTab -= 1; refreshTab(fromRealSlot[0]); addItem(item, toTab, true); } } else if (!insertItems) switchItem(fromSlot, toSlot); else insert(fromSlot, toSlot); } public void insert(int fromSlot, int toSlot) { int[] fromRealSlot = getRealSlot(fromSlot); Item fromItem = getItem(fromRealSlot); if (fromItem == null) return; int[] toRealSlot = getRealSlot(toSlot); Item toItem = getItem(toRealSlot); if ((toItem == null) || (toRealSlot[0] != fromRealSlot[0])) return; if (toRealSlot[1] > fromRealSlot[1]) for (int slot = fromRealSlot[1]; slot < toRealSlot[1]; slot++) { Item temp = bankTabs[toRealSlot[0]][slot]; bankTabs[toRealSlot[0]][slot] = bankTabs[toRealSlot[0]][slot + 1]; bankTabs[toRealSlot[0]][slot + 1] = temp; } else if (fromRealSlot[1] > toRealSlot[1]) for (int slot = fromRealSlot[1]; slot > toRealSlot[1]; slot--) { Item temp = bankTabs[toRealSlot[0]][slot]; bankTabs[toRealSlot[0]][slot] = bankTabs[toRealSlot[0]][slot - 1]; bankTabs[toRealSlot[0]][slot - 1] = temp; } refreshItems(); } public void switchItem(int fromSlot, int toSlot) { int[] fromRealSlot = getRealSlot(fromSlot); Item fromItem = getItem(fromRealSlot); if (fromItem == null) return; int[] toRealSlot = getRealSlot(toSlot); Item toItem = getItem(toRealSlot); if (toItem == null) return; bankTabs[fromRealSlot[0]][fromRealSlot[1]] = toItem; bankTabs[toRealSlot[0]][toRealSlot[1]] = fromItem; refreshTab(fromRealSlot[0]); if (fromRealSlot[0] != toRealSlot[0]) refreshTab(toRealSlot[0]); refreshItems(); } public void openDepositBox() { player.getTempAttribs().setB(""viewingOtherBank"", false); player.getTempAttribs().setB(""viewingDepositBox"", true); player.getInterfaceManager().sendInterface(11); player.getInterfaceManager().removeSubs(Sub.TAB_INVENTORY, Sub.TAB_EQUIPMENT); player.getInterfaceManager().openTab(Sub.TAB_FRIENDS); sendBoxInterItems(); player.getPackets().setIFText(11, 13, ""Bank Of "" + Settings.getConfig().getServerName() + "" - Deposit Box""); player.setCloseInterfacesEvent(() -> { player.getPackets().sendRunScript(571); player.abortDialogue(); player.getInterfaceManager().sendSubDefaults(Sub.TAB_INVENTORY, Sub.TAB_EQUIPMENT); player.getInterfaceManager().openTab(Sub.TAB_INVENTORY); player.getTempAttribs().setB(""viewingDepositBox"", false); Familiar.sendLeftClickOption(player); }); } public void sendBoxInterItems() { player.getPackets().sendInterSetItemsOptionsScript(11, 17, 93, 6, 5, ""Deposit-1"", ""Deposit-5"", ""Deposit-10"", ""Deposit-All"", ""Deposit-X"", ""Examine""); player.getPackets().setIFRightClickOps(11, 17, 0, 27, 0, 1, 2, 3, 4, 5); } public void setPin(byte num1, byte num2, byte num3, byte num4) { bankPin = (short) ((num1 << 12) + (num2 << 8) + (num3 << 4) + num4); } public boolean pinCorrect(byte num1, byte num2, byte num3, byte num4) { return bankPin == (short) ((num1 << 12) + (num2 << 8) + (num3 << 4) + num4); } public void openPinSettings() { if (!checkPin()) return; player.endConversation(); player.getTempAttribs().setB(""settingPin"", false); player.getTempAttribs().setB(""cancellingPin"", false); player.getTempAttribs().setB(""changingPin"", false); player.getPackets().sendVarc(98, bankPin == 0 ? 0 : 1); player.getPackets().sendVarcString(344, ""Please set a secure pin.
0, 0, 0, 0 will be considered as no pin.""); player.getInterfaceManager().sendInterface(14); } public void sendPinConfirmScreen(String question, String op1, String op2) { player.getPackets().sendVarc(98, -1); player.getPackets().setIFText(14, 32, question); player.getPackets().setIFText(14, 34, op1); player.getPackets().setIFText(14, 36, op2); player.getInterfaceManager().sendInterface(14); } public void confirmSetPin() { player.getTempAttribs().setB(""settingPin"", true); sendPinConfirmScreen(""Do you really wish to set a PIN on your bank account?"", ""Yes, I really want a bank PIN. I will never forget it!"", ""No, I might forget it!""); } public void confirmCancelPin() { player.getTempAttribs().setB(""cancellingPin"", true); sendPinConfirmScreen(""Do you still want your PIN?"", ""Yes, I asked to cancel my PIN."", ""No, I didn't ask to cancel my PIN.""); } public void confirmChangePin() { player.getTempAttribs().setB(""changingPin"", true); sendPinConfirmScreen(""Do you really want to change your PIN?"", ""Yes, I asked to change my PIN."", ""No, I didn't ask to change my PIN.""); } public void openPin() { player.getTempAttribs().setI(""pinStage"", 0); player.getTempAttribs().setI(""enteredPin"", 0); player.getTempAttribs().setI(""prevPin"", -1); player.getPackets().setIFText(13, 27, ""Bank of "" + Settings.getConfig().getServerName()); player.getInterfaceManager().sendInterface(13); player.getInterfaceManager().sendSubSpecific(false, 13, 5, 759); player.getPackets().sendVarc(98, bankPin == 0 ? 0 : 1); player.getVars().setVarBit(1010, 1, true); player.getVars().syncVarsToClient(); player.getVars().setVarBit(1010, player.getTempAttribs().getI(""pinStage""), true); player.getVars().syncVarsToClient(); player.getPackets().sendRunScriptBlank(1107); } public static ButtonClickHandler handlePin = new ButtonClickHandler(new Object[] { 13, 14, 759 }, e -> { switch(e.getInterfaceId()) { case 14: switch(e.getComponentId()) { case 18: if (e.getPlayer().getBank().bankPin == 0) e.getPlayer().getBank().confirmSetPin(); else e.getPlayer().getBank().confirmChangePin(); break; case 33: if (e.getPlayer().getBank().bankPin == 0) e.getPlayer().getBank().openPin(); else if (e.getPlayer().getTempAttribs().getB(""changingPin"")) { e.getPlayer().getBank().bankPin = 0; e.getPlayer().sendMessage(""Your pin has been removed. Please set a new one.""); e.getPlayer().getBank().openPin(); } else { e.getPlayer().getBank().bankPin = 0; e.getPlayer().sendMessage(""Your pin has been removed.""); } break; case 19: e.getPlayer().getBank().confirmCancelPin(); break; case 35: e.getPlayer().getBank().openPinSettings(); break; default: e.getPlayer().getBank().openPinSettings(); break; } break; case 13: break; case 759: int num = (e.getComponentId() / 4) - 1; e.getPlayer().getTempAttribs().setI(""enteredPin"", e.getPlayer().getTempAttribs().getI(""enteredPin"") + (num << (e.getPlayer().getTempAttribs().getI(""pinStage"") * 4))); e.getPlayer().getTempAttribs().incI(""pinStage""); if (e.getPlayer().getTempAttribs().getI(""pinStage"") == 3) for (Object ifComp : EnumDefinitions.getEnum(3554).getValues().values()) e.getPlayer().getPackets().setIFHidden(Utils.interfaceIdFromHash((int) ifComp), Utils.componentIdFromHash((int) ifComp), false); else if (e.getPlayer().getTempAttribs().getI(""pinStage"") == 4) { e.getPlayer().getVars().setVarBit(1010, 4, true); e.getPlayer().getVars().syncVarsToClient(); if (e.getPlayer().getBank().bankPin == 0) { if (e.getPlayer().getTempAttribs().getI(""prevPin"", -1) == -1) { e.getPlayer().getPackets().setIFText(13, 26, ""Please repeat that PIN again.""); int prev = e.getPlayer().getTempAttribs().getI(""enteredPin""); e.getPlayer().getBank().openPin(); e.getPlayer().getTempAttribs().setI(""prevPin"", prev); e.getPlayer().getTempAttribs().setI(""enteredPin"", 0); e.getPlayer().getTempAttribs().setI(""pinStage"", 0); e.getPlayer().getVars().setVarBit(1010, 0, true); e.getPlayer().getVars().syncVarsToClient(); } else if (e.getPlayer().getTempAttribs().getI(""prevPin"") != e.getPlayer().getTempAttribs().getI(""enteredPin"")) { e.getPlayer().sendMessage(""The PIN you entered did not match the first one.""); e.getPlayer().closeInterfaces(); e.getPlayer().getBank().openPinSettings(); } else { e.getPlayer().getBank().bankPin = (short) e.getPlayer().getTempAttribs().getI(""prevPin""); e.getPlayer().sendMessage(""Your PIN has been set.""); e.getPlayer().closeInterfaces(); } } else { if (e.getPlayer().getTempAttribs().getI(""enteredPin"") != e.getPlayer().getBank().bankPin) e.getPlayer().sendMessage(""That PIN was incorrect.""); else { e.getPlayer().sendMessage(""You have entered your PIN successfully.""); e.getPlayer().getBank().setEnteredPIN(); } e.getPlayer().closeInterfaces(); } } break; } }); public void open() { if (!checkPin()) return; withdrawNotes = false; player.getTempAttribs().removeB(""viewingOtherBank""); player.getVars().setVar(638, 0); player.getVars().setVarBit(8348, 0); refreshTabs(); refreshViewingTab(); refreshLastX(); refreshTab(currentTab); player.getVars().syncVarsToClient(); player.getInterfaceManager().sendInterface(762); player.getInterfaceManager().sendInventoryInterface(763); player.getPackets().sendRunScript(2319); player.getPackets().setIFText(762, 47, ""Bank of "" + Settings.getConfig().getServerName()); unlockButtons(); sendItems(); refreshItems(); player.setCloseInterfacesEvent(() -> { player.getPackets().sendRunScript(571); player.abortDialogue(); Familiar.sendLeftClickOption(player); }); } public void openBankOther(Player other) { player.getVars().setVarBit(8348, 0); player.getVars().syncVarsToClient(); player.getInterfaceManager().sendInterface(762); player.getPackets().sendRunScript(2319); refreshTabs(other); sendItemsOther(other); unlockButtons(); player.getPackets().sendItems(93, other.getInventory().getItems()); player.getPackets().sendItems(94, other.getEquipment().getItemsCopy()); player.getTempAttribs().setB(""viewingOtherBank"", true); player.setCloseInterfacesEvent(() -> { player.getPackets().sendRunScript(571); player.abortDialogue(); player.getInventory().refresh(); player.getEquipment().refresh(); Familiar.sendLeftClickOption(player); }); } public void refreshLastX() { player.getVars().setVar(1249, lastX); } public void createTab() { int slot = bankTabs.length; Item[][] tabs = new Item[slot + 1][]; System.arraycopy(bankTabs, 0, tabs, 0, slot); tabs[slot] = new Item[0]; bankTabs = tabs; } public void destroyTab(int slot) { Item[][] tabs = new Item[bankTabs.length - 1][]; System.arraycopy(bankTabs, 0, tabs, 0, slot); System.arraycopy(bankTabs, slot + 1, tabs, slot, bankTabs.length - slot - 1); bankTabs = tabs; if (currentTab != 0 && currentTab >= slot) currentTab--; } public boolean hasBankSpace() { return getBankSize() < MAX_BANK_SIZE; } public void withdrawItem(int bankSlot, int quantity) { if (player.getTempAttribs().getB(""viewingOtherBank"") || (quantity < 1)) return; Item item = getItem(getRealSlot(bankSlot)); if (item == null) return; if (item.getMetaData() != null) quantity = 1; if (item.getAmount() < quantity) item = new Item(item.getId(), item.getAmount(), item.getMetaData()); else item = new Item(item.getId(), quantity, item.getMetaData()); boolean noted = false; ItemDefinitions defs = item.getDefinitions(); if (withdrawNotes) if (!defs.isNoted() && defs.getCertId() != -1 && item.getMetaData() == null) { item.setId(defs.getCertId()); noted = true; } else player.sendMessage(""You cannot withdraw this item as a note.""); if ((noted || defs.isStackable()) && item.getMetaData() == null) { if (player.getInventory().getItems().containsOne(item)) { int slot = player.getInventory().getItems().getThisItemSlot(item); Item invItem = player.getInventory().getItems().get(slot); if (invItem.getAmount() + item.getAmount() <= 0) { item.setAmount(Integer.MAX_VALUE - invItem.getAmount()); player.sendMessage(""Not enough space in your inventory.""); return; } } else if (!player.getInventory().hasFreeSlots()) { player.sendMessage(""Not enough space in your inventory.""); return; } } else { int freeSlots = player.getInventory().getFreeSlots(); if (freeSlots == 0) { player.sendMessage(""Not enough space in your inventory.""); return; } if (freeSlots < item.getAmount()) { item.setAmount(freeSlots); player.sendMessage(""Not enough space in your inventory.""); } } removeItem(bankSlot, item.getAmount(), true, false); player.getInventory().addItem(item); if (item.getId() == Runecrafting.RUNE_ESS || item.getId() == Runecrafting.PURE_ESS) Runecrafting.fillPouchesFromBank(player, item.getId()); } public void sendExamine(int fakeSlot) { int[] slot = getRealSlot(fakeSlot); if (slot == null) return; Item item = bankTabs[slot[0]][slot[1]]; player.sendMessage(ItemConfig.get(item.getId()).getExamine(item)); if (item.getMetaData(""combatCharges"") != null) player.sendMessage(""It looks like it will last another "" + Utils.ticksToTime(item.getMetaDataI(""combatCharges""))); } public boolean depositItem(int invSlot, int quantity, boolean refresh) { if (player.getTempAttribs().getB(""viewingOtherBank"") || quantity < 1 || invSlot < 0 || invSlot > 27) return false; Item item = player.getInventory().getItem(invSlot); if (item == null) return false; if (item.getMetaData() != null) quantity = 1; int amt = player.getInventory().getItems().getNumberOf(item); if (amt < quantity) item = new Item(item.getId(), amt, item.getMetaData()); else item = new Item(item.getId(), quantity, item.getMetaData()); ItemDefinitions defs = item.getDefinitions(); int originalId = item.getId(); if (defs.isNoted() && defs.getCertId() != -1) item.setId(defs.getCertId()); Item bankedItem = getItem(item.getId()); if (bankedItem != null) { if (bankedItem.getAmount() + item.getAmount() <= 0) { item.setAmount(Integer.MAX_VALUE - bankedItem.getAmount()); player.sendMessage(""Not enough space in your bank.""); } } else if (!hasBankSpace()) { player.sendMessage(""Not enough space in your bank.""); return false; } if (addItem(item, refresh)) { player.getInventory().deleteItem(invSlot, new Item(originalId, item.getAmount(), item.getMetaData())); return true; } return false; } // public void addItem(Item item, boolean refresh) { // addItem(item.getId(), item.getAmount(), refresh); // } public boolean addItem(Item item, boolean refresh) { return addItem(item, currentTab, refresh); } public boolean addItem(Item item, int creationTab, boolean refresh) { if (item == null || item.getId() == -1) return false; if (!player.getControllerManager().canDepositItem(item)) return false; var event = new ItemAddedToBankEvent(player, item); PluginManager.handle(event); if (event.isCancelled()) return false; int[] slotInfo = getItemSlot(item.getId()); if (slotInfo == null || item.getMetaData() != null || bankTabs[slotInfo[0]][slotInfo[1]].getMetaData() != null) { if (creationTab >= bankTabs.length) creationTab = bankTabs.length - 1; if (creationTab < 0) // fixed now, alex creationTab = 0; int slot = bankTabs[creationTab].length; Item[] tab = new Item[slot + 1]; System.arraycopy(bankTabs[creationTab], 0, tab, 0, slot); tab[slot] = item; bankTabs[creationTab] = tab; if (refresh) refreshTab(creationTab); } else { Item existingItem = bankTabs[slotInfo[0]][slotInfo[1]]; bankTabs[slotInfo[0]][slotInfo[1]] = new Item(item.getId(), existingItem.getAmount() + item.getAmount(), item.getMetaData()); } if (refresh) refreshItems(); return true; } public boolean removeItem(int fakeSlot, int quantity, boolean refresh, boolean forceDestroy) { return removeItem(getRealSlot(fakeSlot), quantity, refresh, forceDestroy); } public boolean removeItem(int[] slot, int quantity, boolean refresh, boolean forceDestroy) { if (slot == null) return false; Item item = bankTabs[slot[0]][slot[1]]; boolean destroyed = false; if (quantity >= item.getAmount()) { if (bankTabs[slot[0]].length == 1 && (forceDestroy || bankTabs.length != 1)) { destroyTab(slot[0]); if (refresh) refreshTabs(); destroyed = true; } else { Item[] tab = new Item[bankTabs[slot[0]].length - 1]; System.arraycopy(bankTabs[slot[0]], 0, tab, 0, slot[1]); System.arraycopy(bankTabs[slot[0]], slot[1] + 1, tab, slot[1], bankTabs[slot[0]].length - slot[1] - 1); bankTabs[slot[0]] = tab; if (refresh) refreshTab(slot[0]); } } else bankTabs[slot[0]][slot[1]] = new Item(item.getId(), item.getAmount() - quantity, item.getMetaData()); if (refresh) refreshItems(); return destroyed; } public int[] getSlot(int itemId) { if (bankTabs != null) for (int i = 0; i < bankTabs.length; i++) for (int i2 = 0; i2 < bankTabs[i].length; i2++) if (bankTabs[i][i2].getId() == itemId) return new int[] { i, i2 }; return null; } public boolean withdrawItemDel(int itemId, int amount) { boolean refresh = true; boolean forceDestroy = true; int[] slot = getSlot(itemId); if (slot == null) return false; Item item = bankTabs[slot[0]][slot[1]]; boolean destroyed = false; if (amount >= item.getAmount()) { if (bankTabs[slot[0]].length == 1 && (forceDestroy || bankTabs.length != 1)) { destroyTab(slot[0]); if (refresh) refreshTabs(); destroyed = true; } else { Item[] tab = new Item[bankTabs[slot[0]].length - 1]; System.arraycopy(bankTabs[slot[0]], 0, tab, 0, slot[1]); System.arraycopy(bankTabs[slot[0]], slot[1] + 1, tab, slot[1], bankTabs[slot[0]].length - slot[1] - 1); bankTabs[slot[0]] = tab; if (refresh) refreshTab(slot[0]); } } else bankTabs[slot[0]][slot[1]] = new Item(item.getId(), item.getAmount() - amount, item.getMetaData()); if (refresh) refreshItems(); return destroyed; } public Item getItem(int id) { for (Item[] bankTab : bankTabs) for (Item item : bankTab) if (item.getId() == id) return item; return null; } public int[] getItemSlot(int id) { for (int tab = 0; tab < bankTabs.length; tab++) for (int slot = 0; slot < bankTabs[tab].length; slot++) if (bankTabs[tab][slot].getId() == id) return new int[] { tab, slot }; return null; } public Item getItem(int[] slot) { if (slot == null) return null; return bankTabs[slot[0]][slot[1]]; } public int getStartSlot(int tabId) { int slotId = 0; for (int tab = 1; tab < (tabId == 0 ? bankTabs.length : tabId); tab++) slotId += bankTabs[tab].length; return slotId; } public int[] getRealSlot(int slot) { for (int tab = 1; tab < bankTabs.length; tab++) { if (slot < bankTabs[tab].length) return new int[] { tab, slot }; slot -= bankTabs[tab].length; } if (slot >= bankTabs[0].length) return null; return new int[] { 0, slot }; } public void refreshViewingTab() { player.getVars().setVarBit(4893, currentTab + 1); player.getVars().syncVarsToClient(); } public void refreshTab(Player other, int slot) { if (slot == 0) return; player.getVars().setVarBit(4885 + (slot - 1), getTabSize(other, slot)); refreshViewingTab(); } public void refreshTab(int slot) { if (slot == 0) return; player.getVars().setVarBit(4885 + (slot - 1), getTabSize(slot)); refreshViewingTab(); } public void sendItems() { player.getPackets().sendItems(95, getContainerCopy()); player.getPackets().sendVarc(1038, 0); player.getPackets().sendVarc(192, getBankSize()); } public void sendItemsOther(Player other) { player.getPackets().sendItems(95, other.getBank().getContainerCopy()); } public void refreshItems(int[] slots) { player.getPackets().sendUpdateItems(95, getContainerCopy(), slots); player.getPackets().sendVarc(1038, 0); player.getPackets().sendVarc(192, getBankSize()); } public Item[] getContainerCopy() { if (lastContainerCopy == null) lastContainerCopy = generateContainer(); return lastContainerCopy; } public void refreshItems() { refreshItems(generateContainer(), getContainerCopy()); } public void refreshItems(Item[] itemsAfter, Item[] itemsBefore) { if (itemsBefore.length != itemsAfter.length) { lastContainerCopy = itemsAfter; sendItems(); return; } int[] changedSlots = new int[itemsAfter.length]; int count = 0; for (int index = 0; index < itemsAfter.length; index++) if (itemsBefore[index] != itemsAfter[index]) changedSlots[count++] = index; int[] finalChangedSlots = new int[count]; System.arraycopy(changedSlots, 0, finalChangedSlots, 0, count); lastContainerCopy = itemsAfter; refreshItems(finalChangedSlots); } public int getBankSize() { int size = 0; for (Item[] bankTab : bankTabs) size += bankTab.length; return size; } public Item[] generateContainer() { Item[] container = new Item[getBankSize()]; int count = 0; for (int slot = 1; slot < bankTabs.length; slot++) { System.arraycopy(bankTabs[slot], 0, container, count, bankTabs[slot].length); count += bankTabs[slot].length; } System.arraycopy(bankTabs[0], 0, container, count, bankTabs[0].length); return container; } public void unlockButtons() { // player.getPackets().sendHideIComponent(762, 42, false); // player.getPackets().sendHideIComponent(762, 43, false); //unlocks bank pin shit // player.getPackets().sendHideIComponent(762, 44, false); player.getPackets().setIFEvents(new IFEvents(762, 95, 0, MAX_BANK_SIZE) .enableRightClickOptions(0,1,2,3,4,5,6,9) .setDepth(2) .enableDrag()); player.getPackets().setIFEvents(new IFEvents(763, 0, 0, 27) .enableUseOptions(UseFlag.ICOMPONENT) .enableRightClickOptions(0,1,2,3,4,5,9) .setDepth(1) .enableDrag()); } public void switchWithdrawNotes() { withdrawNotes = !withdrawNotes; } public void switchInsertItems() { insertItems = !insertItems; player.getVars().setVar(305, insertItems ? 1 : 0); } public boolean getInsertItems() { return insertItems; } public boolean getWithdrawNotes() { return withdrawNotes; } public int getCurrentTab() { return currentTab; } public void setCurrentTab(int currentTab) { if (currentTab >= bankTabs.length) return; this.currentTab = currentTab; player.getPackets().sendVarc(190, 1); } public int getLastX() { return lastX; } public void setLastX(int lastX) { this.lastX = lastX; } public void clear() { bankTabs = new Item[1][0]; } public boolean enteredPIN() { if (bankPin == 0 || sessionPin) return true; if (enteredPin == null) return false; List toRemove = new ArrayList<>(); for (String ip : enteredPin.keySet()) if (System.currentTimeMillis() - enteredPin.get(ip) > PIN_VALIDITY_TIME) toRemove.add(ip); for (String ip : toRemove) enteredPin.remove(ip); if (enteredPin.containsKey(player.getSession().getIP())) { sessionPin = true; return true; } return false; } public void setEnteredPIN() { if (enteredPin == null) enteredPin = new ConcurrentHashMap<>(); enteredPin.put(player.getSession().getIP(), System.currentTimeMillis()); sessionPin = true; } public boolean checkPin() { if (bankPin != 0 && !enteredPIN()) { openPin(); return false; } return true; } }" "package com.rs.game.model.entity.player; public abstract class Controller { protected transient Player player; public final void setPlayer(Player player) { this.player = player; } public Player getPlayer() { return player; } public final void removeController() { player.getControllerManager().removeControllerWithoutCheck(); } public abstract void start(); public boolean canEat(Food food) { return true; } public boolean canTakeItem(GroundItem item) { return true; } public void processIncomingHit(final Hit hit) { } /** * Should there be ambient music at all? * @return */ public boolean playAmbientMusic() { return true; } /** * No unlocks and no music outside of genre. * @return */ public boolean playAmbientStrictlyBackgroundMusic() { return false; } /** * Genre of controller * @return */ public Genre getGenre() { return Music.getGenre(player); } /** * After starting the controller if you enter a new region should you play the controller genre, true or false? * Also, if you enter a region then start the controller you wont get the genre change. * After first time music doesn't play on region enter. * @return */ public boolean playAmbientOnControllerRegionEnter() { return true; } public void processOutgoingHit(final Hit hit, Entity target) { } public boolean processItemOnPlayer(Player p2, Item item, int slot) { return true; } public boolean canPot(Potion pot) { return true; } /** * after the normal checks, extra checks, only called when you attacking */ public boolean keepCombating(Entity target) { return true; } public boolean canEquip(int slotId, int itemId) { return true; } /** * after the normal checks, extra checks, only called when you start trying * to attack */ public boolean canAttack(Entity target) { return true; } public void trackXP(int skillId, int addedXp) { } public boolean gainXP(int skillId, double exp) { return true; } public boolean processButtonClick(int interfaceId, int componentId, int slotId, int slotId2, ClientPacket packet) { return true; } public boolean canDeleteInventoryItem(int itemId, int amount) { return true; } public boolean canUseItemOnItem(Item itemUsed, Item usedWith) { return true; } public boolean canAddInventoryItem(int itemId, int amount) { return true; } public boolean canPlayerOption1(Player target) { return true; } public boolean canPlayerOption2(Player target) { return true; } public boolean canPlayerOption3(Player target) { return true; } public boolean canPlayerOption4(Player target) { return true; } public void processNPCDeath(int id) { } /** * hits as ice barrage and that on multi areas */ public boolean canHit(Entity entity) { return true; } /** * processes every game ticket, usualy not used */ public void process() { } public void moved() { } /** * called once teleport is performed */ public void onTeleported(TeleType type) { } public void sendInterfaces() { } /** * return can use script */ public boolean useDialogueScript(Object key) { return true; } /** * return can teleport */ public boolean processTeleport(Teleport tele) { return true; } /** * return process normaly */ public boolean processObjectClick1(GameObject object) { return true; } /** * return process normaly */ public boolean processNPCClick1(NPC npc) { return true; } /** * return process normaly */ public boolean processNPCClick2(NPC npc) { return true; } /** * return process normaly */ public boolean processNPCClick3(NPC npc) { return true; } /** * return process normaly */ public boolean processObjectClick2(GameObject object) { return true; } /** * return process normaly */ public boolean processObjectClick3(GameObject object) { return true; } public boolean processObjectClick5(GameObject object) { return true; } /** * return let default death */ public boolean sendDeath() { return true; } /** * return can move that step */ public boolean canMove(Direction dir) { return true; } /** * return can set that step */ public boolean checkWalkStep(int lastX, int lastY, int nextX, int nextY) { return true; } /** * return remove controller */ public boolean login() { return true; } /** * return remove controller */ public boolean logout() { return true; } public void forceClose() { } public void onRemove() { } public boolean processItemOnObject(GameObject object, Item item) { return true; } public boolean processObjectClick4(GameObject object) {// TODO implement return true; } public boolean processItemOnNPC(NPC npc, Item item) { return true; } public boolean canDropItem(Item item) { return true; } public boolean canSummonFamiliar() { return true; } public void processNPCDeath(NPC npc) { } public boolean canTrade() { return true; } public boolean canDepositItem(Item item) { return true; } }" "package com.rs.game.model.entity.player; @PluginEventHandler public final class Equipment { public static final int HEAD = 0, CAPE = 1, NECK = 2, WEAPON = 3, CHEST = 4, SHIELD = 5, LEGS = 7, HANDS = 9, FEET = 10, RING = 12, AMMO = 13, AURA = 14; public static final int SIZE = 15; private final ItemsContainer items; private transient Player player; private transient int equipmentHpIncrease; private transient double equipmentWeight; static final int[] DISABLED_SLOTS = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0 }; public Equipment() { items = new ItemsContainer<>(15, false); } public void setPlayer(Player player) { this.player = player; } public void replace(Item item, Item newItem) { if (item != null) PluginManager.handle(new ItemEquipEvent(player, item, false)); if (newItem != null) PluginManager.handle(new ItemEquipEvent(player, newItem, true)); items.set(item.getSlot(), newItem); refresh(); } public void init() { for (int i = 0;i < items.getSize();i++) { Item item = items.get(i); if (item == null) continue; if (!ItemConstants.canWear(item, player)) { if (player.getInventory().hasFreeSlots()) { player.getInventory().addItem(item); player.sendMessage(""You no longer meet the requirements for "" + item.getDefinitions().getName() + "" and it has been unequipped.""); } else { player.getBank().addItem(item, false); player.sendMessage(""You no longer meet the requirements for "" + item.getDefinitions().getName() + "" and it has been sent to your bank.""); } items.set(i, null); } } player.getPackets().sendItems(94, items); refresh(null); } public void refresh(int... slots) { if (slots != null) { player.getPackets().sendUpdateItems(94, items, slots); player.getCombatDefinitions().checkAttackStyle(); } player.getCombatDefinitions().refreshBonuses(); refreshConfigs(slots == null); } public void reset() { for (Item item : getItemsCopy()) if (item != null) PluginManager.handle(new ItemEquipEvent(player, item, false)); items.reset(); init(); } public Item getItem(int slot) { return items.get(slot); } public Item getItemById(int id) { for (Item item : items.array()) if (item != null && item.getId() == id) return item; return null; } public void sendExamine(int slotId) { Item item = items.get(slotId); if (item == null) return; player.sendMessage(ItemConfig.get(item.getId()).getExamine(item)); if (item.getMetaData(""combatCharges"") != null) player.sendMessage(""It looks like it will last another "" + Utils.ticksToTime(item.getMetaDataI(""combatCharges""))); else if (item.getMetaData(""brawlerCharges"") != null) player.sendMessage(""These gloves have "" + item.getMetaDataI(""brawlerCharges"") + "" charges left.""); } public boolean containsOneItem(int... itemIds) { for (int itemId : itemIds) if (items.containsOne(new Item(itemId, 1))) return true; return false; } public boolean hasItemInSlot(int... slots) { for (int slot : slots) if (getId(slot) != -1) return true; return false; } public boolean fullGuthansEquipped() { int helmId = player.getEquipment().getHatId(); int chestId = player.getEquipment().getChestId(); int legsId = player.getEquipment().getLegsId(); int weaponId = player.getEquipment().getWeaponId(); if (helmId == -1 || chestId == -1 || legsId == -1 || weaponId == -1) return false; return ItemDefinitions.getDefs(helmId).getName().contains(""Guthan's"") && ItemDefinitions.getDefs(chestId).getName().contains(""Guthan's"") && ItemDefinitions.getDefs(legsId).getName().contains(""Guthan's"") && ItemDefinitions.getDefs(weaponId).getName().contains(""Guthan's""); } public void refreshConfigs(boolean init) { double hpIncrease = 0; for (int index = 0; index < items.getSize(); index++) { Item item = items.get(index); if (item == null) continue; switch(item.getId()) { case 20135, 20137, 20147, 20149, 20159, 20161 -> hpIncrease += 66; case 20139, 20141, 20151, 20153, 20163, 20165 -> hpIncrease += 200; case 20143, 20145, 20155, 20157, 20167, 20169 -> hpIncrease += 134; case 24974, 24975, 24977, 24978, 24980, 24981, 24983, 24984, 24986, 24987, 24989, 24990, 25058, 25060, 25062, 25064, 25066, 25068 -> hpIncrease += 25; } } int maxHp = player.getSkills().getLevel(Constants.HITPOINTS) * 10; if (player.hasEffect(Effect.BONFIRE)) hpIncrease += (maxHp + (int) hpIncrease) * Bonfire.getBonfireBoostMultiplier(player); if (player.hasEffect(Effect.OOG_THERMAL_POOL)) hpIncrease += (maxHp + (int) hpIncrease) * 0.03; if (player.getHpBoostMultiplier() != 0) hpIncrease += maxHp * player.getHpBoostMultiplier(); if (hpIncrease != equipmentHpIncrease) { equipmentHpIncrease = (int) hpIncrease; if (!init) player.refreshHitPoints(); } double w = 0; for (Item item : items.array()) { if (item == null) continue; w += ItemConfig.get(item.getId()).getWeight(true); } equipmentWeight = w; player.getPackets().refreshWeight(player.getInventory().getInventoryWeight() + equipmentWeight); } public static boolean hideArms(Item item) { return item.getDefinitions().isEquipType(6); } public static boolean hideHair(Item item) { return item.getDefinitions().isEquipType(8); } public static boolean hideBeard(Item item) { return item.getDefinitions().isEquipType(11); } public static int getItemSlot(int itemId) { return ItemDefinitions.getDefs(itemId).getEquipSlot(); } public static boolean isTwoHandedWeapon(Item item) { return item.getDefinitions().isEquipType(5); } public int getWeaponBAS() { Item weapon = items.get(3); if (weapon == null) return 1426; return weapon.getDefinitions().getRenderAnimId(); } public boolean hasShield() { return items.get(5) != null; } public String getWeaponName() { Item item = items.get(WEAPON); if (item == null) return """"; return item.getDefinitions().getName(); } public int getWeaponId() { Item item = items.get(WEAPON); if (item == null) return -1; return item.getId(); } public int getChestId() { Item item = items.get(CHEST); if (item == null) return -1; return item.getId(); } public int getHatId() { Item item = items.get(HEAD); if (item == null) return -1; return item.getId(); } public int getShieldId() { Item item = items.get(SHIELD); if (item == null) return -1; return item.getId(); } public int getLegsId() { Item item = items.get(LEGS); if (item == null) return -1; return item.getId(); } public void removeAmmo(int slot, int amount) { if (items.get(slot) == null) return; items.remove(slot, new Item(items.get(slot).getId(), amount)); refresh(slot); if (items.get(slot) == null) { player.sendMessage(""That was your last one!""); player.getAppearance().generateAppearanceData(); } } public int getAuraId() { Item item = items.get(AURA); if (item == null) return -1; return item.getId(); } public int getCapeId() { Item item = items.get(CAPE); if (item == null) return -1; return item.getId(); } public int getNeckId() { Item item = items.get(NECK); if (item == null) return -1; return item.getId(); } public int getRingId() { Item item = items.get(RING); if (item == null) return -1; return item.getId(); } public int getAmmoId() { Item item = items.get(AMMO); if (item == null) return -1; return item.getId(); } public void deleteItem(int itemId, int amount) { Item[] itemsBefore = items.getItemsCopy(); if (items.contains(new Item(itemId, amount))) PluginManager.handle(new ItemEquipEvent(player, new Item(itemId, amount), false)); items.remove(new Item(itemId, amount)); refreshItems(itemsBefore); } public void refreshItems(Item[] itemsBefore) { int[] changedSlots = new int[itemsBefore.length]; int count = 0; for (int index = 0; index < itemsBefore.length; index++) if (itemsBefore[index] != items.array()[index]) changedSlots[count++] = index; int[] finalChangedSlots = new int[count]; System.arraycopy(changedSlots, 0, finalChangedSlots, 0, count); refresh(finalChangedSlots); } public int getBootsId() { Item item = items.get(FEET); if (item == null) return -1; return item.getId(); } public boolean wearingGloves() { return items.get(HANDS) != null; } public int getGlovesId() { Item item = items.get(HANDS); if (item == null) return -1; return item.getId(); } public int getIdInSlot(int slot) { Item item = items.get(slot); if (item == null) return -1; return item.getId(); } public boolean wearingSlot(int slot, int... items) { int id = getIdInSlot(slot); for (int check : items) if (id == check) return true; return false; } public Item get(int slot) { return items.get(slot); } public Item setSlot(int slot, Item item) { Item prev = items.get(slot); if (item == null && items.get(slot) == null) return null; if (prev != null) { ItemEquipEvent dequip = new ItemEquipEvent(player, prev, false); PluginManager.handle(dequip); if (!dequip.isCancelled()) { if (item == null) { items.set(slot, null); refresh(slot); return prev; } } else return new Item(-1, -1); } ItemEquipEvent equip = new ItemEquipEvent(player, item, true); PluginManager.handle(equip); if (!equip.isCancelled()) { items.set(slot, item); refresh(slot); return prev; } else return new Item(-1, -1); } public boolean deleteSlot(int slot) { Item prev = setSlot(slot, null); if (prev != null && prev.getId() == -1) return false; refresh(slot); return true; } public void setNoPluginTrigger(int slot, Item item) { items.set(slot, item); } public boolean isEmpty() { return items.isEmpty(); } public Item[] getItemsCopy() { return items.getItemsCopy(); } public int getEquipmentHpIncrease() { return equipmentHpIncrease; } public void setEquipmentHpIncrease(int hp) { equipmentHpIncrease = hp; } public boolean wearingArmour() { return getItem(HEAD) != null || getItem(CAPE) != null || getItem(NECK) != null || getItem(WEAPON) != null || getItem(CHEST) != null || getItem(SHIELD) != null || getItem(LEGS) != null || getItem(HANDS) != null || getItem(FEET) != null; } public int getId(int slot) { Item item = items.get(slot); if (item == null) return -1; return item.getId(); } public int getAmuletId() { Item item = items.get(NECK); if (item == null) return -1; return item.getId(); } public boolean hasTwoHandedWeapon() { Item weapon = items.get(WEAPON); return weapon != null && isTwoHandedWeapon(weapon); } public boolean wearingBlackMask() { if (items.get(HEAD) != null) return ItemDefinitions.getDefs(items.get(HEAD).getId()).getName().toLowerCase().contains(""black mask""); return false; } public boolean wearingHexcrest() { if (items.get(HEAD) != null) return items.get(HEAD).getId() == 15488; return false; } public boolean wearingFocusSight() { if (items.get(HEAD) != null) return items.get(HEAD).getId() == 15490; return false; } public boolean wearingSlayerHelmet() { if (items.get(HEAD) != null) return items.get(HEAD).getId() == 15492 || items.get(HEAD).getId() == 15496 || items.get(HEAD).getId() == 15497; return false; } public float getWitchDoctorBoost() { float boost = 1.0f; if (items.get(HEAD) != null) if (items.get(HEAD).getId() == 20046) boost += 0.01f; if (items.get(LEGS) != null) if (items.get(LEGS).getId() == 20045) boost += 0.02f; if (items.get(CHEST) != null) if (items.get(CHEST).getId() == 20044) boost += 0.02f; return boost; } public boolean isWearingSlayerHelmet() { Item helmet = items.get(HEAD); if (helmet == null) return false; return helmet.getDefinitions().getName().toLowerCase().contains(""slayer helmet""); } public boolean wearingFullCeremonial() { if (items.get(HEAD) != null && items.get(CHEST) != null && items.get(LEGS) != null && items.get(HANDS) != null && items.get(FEET) != null) return items.get(HEAD).getId() == 20125 && items.get(CHEST).getId() == 20127 && items.get(LEGS).getId() == 20129 && items.get(HANDS).getId() == 20131 && items.get(FEET).getId() == 20133; return false; } public boolean hasFirecape() { if (items.get(CAPE) != null) { String name = items.get(CAPE).getDefinitions().getName().toLowerCase(); return name.contains(""fire cape"") || name.contains(""tokhaar-kal"") || name.contains(""completionist cape""); } return false; } public double getEquipmentWeight() { return equipmentWeight; } public int getSalveAmulet() { if (getAmuletId() == 4081) return 0; if (getAmuletId() == 10588) return 1; return -1; } public static ButtonClickHandler handle = new ButtonClickHandler(884, e -> { if (e.getComponentId() == 4) SpecialAttacksKt.handleClick(e.getPlayer()); else if (e.getComponentId() >= 7 && e.getComponentId() <= 10) e.getPlayer().getCombatDefinitions().setAttackStyle(e.getComponentId() - 7); else if (e.getComponentId() == 11) e.getPlayer().getCombatDefinitions().switchAutoRetaliate(); }); public static InterfaceOnInterfaceHandler handleCompareItem = new InterfaceOnInterfaceHandler(true,670, 667, e -> { Item item1 = e.getFromInterfaceId() == 670 ? e.getPlayer().getInventory().getItem(e.getFromSlotId()) : e.getPlayer().getEquipment().get(e.getFromSlotId()); Item item2 = e.getToInterfaceId() == 670 ? e.getPlayer().getInventory().getItem(e.getToSlotId()) : e.getPlayer().getEquipment().get(e.getToSlotId()); if (item1 == null || item2 == null || item1 == item2) return; compareItems(e.getPlayer(), item1, item2); }); public static InterfaceOnInterfaceHandler handleCompareItemInv = new InterfaceOnInterfaceHandler(670, 670, e -> { Item item1 = e.getFromInterfaceId() == 670 ? e.getPlayer().getInventory().getItem(e.getFromSlotId()) : e.getPlayer().getEquipment().get(e.getFromSlotId()); Item item2 = e.getToInterfaceId() == 670 ? e.getPlayer().getInventory().getItem(e.getToSlotId()) : e.getPlayer().getEquipment().get(e.getToSlotId()); if (item1 == null || item2 == null || item1 == item2) return; compareItems(e.getPlayer(), item1, item2); }); public static void compareItems(Player p, Item item1, Item item2) { if (item1 == null || item2 == null || item1.getDefinitions().getEquipSlot() != item2.getDefinitions().getEquipSlot()) { p.sendMessage(""These two items cannot be compared because they are not the same type.""); return; } p.getPackets().sendVarcString(321, ""Comparison""); StringBuilder categories = new StringBuilder(); StringBuilder subCategories = new StringBuilder(); StringBuilder item1Desc = new StringBuilder(item1.getDefinitions().name); StringBuilder item2Desc = new StringBuilder(item2.getDefinitions().name); for (Bonus b : Bonus.values()) { if (Equipment.getBonus(p, item1, b) != 0 || Equipment.getBonus(p, item2, b) != 0) { if (!categories.toString().contains(""Attack Bonuses"") && b.ordinal() >= Bonus.STAB_ATT.ordinal() && b.ordinal() <= Bonus.RANGE_ATT.ordinal()) { categories.append(""
Attack Bonuses
""); subCategories.append(""

""); item1Desc.append(""
""); item2Desc.append(""
""); } if (!categories.toString().contains(""Defense Bonuses"") && b.ordinal() >= Bonus.STAB_DEF.ordinal() && b.ordinal() <= Bonus.ABSORB_RANGE.ordinal()) { categories.append(""
Defense Bonuses
""); subCategories.append(""

""); item1Desc.append(""

""); item2Desc.append(""

""); } if (!categories.toString().contains(""Other"") && b.ordinal() >= Bonus.MELEE_STR.ordinal() && b.ordinal() <= Bonus.MAGIC_STR.ordinal()) { categories.append(""
Other
""); subCategories.append(""

""); item1Desc.append(""

""); item2Desc.append(""

""); } categories.append(""
""); subCategories.append(Utils.formatPlayerNameForDisplay(b.name().replace(""_ATT"", """").replace(""_DEF"", """"))).append("":
""); item1Desc.append(""
"").append(wrapIfSuperior(Equipment.getBonus(p, item1, b) + (List.of(Bonus.ABSORB_MELEE, Bonus.ABSORB_MAGIC, Bonus.ABSORB_RANGE, Bonus.MAGIC_STR).contains(b) ? ""%"" : """"), Equipment.getBonus(p, item1, b), Equipment.getBonus(p, item2, b))); item2Desc.append(""
"").append(wrapIfSuperior(Equipment.getBonus(p, item2, b) + (List.of(Bonus.ABSORB_MELEE, Bonus.ABSORB_MAGIC, Bonus.ABSORB_RANGE, Bonus.MAGIC_STR).contains(b) ? ""%"" : """"), Equipment.getBonus(p, item2, b), Equipment.getBonus(p, item1, b))); } } categories.append(""
""); subCategories.append(""
""); item1Desc.append(""
""); item2Desc.append(""
""); p.getPackets().sendVarcString(322, categories.toString()); p.getPackets().sendVarcString(323, subCategories.toString()); p.getPackets().sendVarcString(324, item1Desc.toString()); p.getPackets().sendVarcString(325, item2Desc.toString()); } private static String wrapIfSuperior(String in, int bonus1, int bonus2) { if (bonus1 > bonus2) return """"+in+""""; return in; } public static ButtonClickHandler handleEquipmentStatsInterface = new ButtonClickHandler(new Object[] { 667, 670 }, e -> { if (e.getInterfaceId() == 667) { if (e.getComponentId() == 9) { if (e.getSlotId() >= 14) return; Item item = e.getPlayer().getEquipment().getItem(e.getSlotId()); if (item == null) return; if (e.getPacket() == ClientPacket.IF_OP10) { e.getPlayer().sendMessage(ItemConfig.get(item.getId()).getExamine(item)); if (item.getMetaData(""combatCharges"") != null) e.getPlayer().sendMessage(""It looks like it will last another "" + Utils.ticksToTime(item.getMetaDataI(""combatCharges""))); } else if (e.getPacket() == ClientPacket.IF_OP1) { remove(e.getPlayer(), e.getSlotId()); Equipment.refreshEquipBonuses(e.getPlayer()); } } else if (e.getComponentId() == 46 && e.getPlayer().getTempAttribs().removeB(""Banking"")) e.getPlayer().getBank().open(); } else if (e.getInterfaceId() == 670) if (e.getComponentId() == 0) { if (e.getSlotId() >= e.getPlayer().getInventory().getItemsContainerSize()) return; Item item = e.getPlayer().getInventory().getItem(e.getSlotId()); if (item == null) return; if (e.getPacket() == ClientPacket.IF_OP1) { if (e.getPlayer().isEquipDisabled()) return; if (sendWear(e.getPlayer(), e.getSlotId(), item.getId())) Equipment.refreshEquipBonuses(e.getPlayer()); } else if (e.getPacket() == ClientPacket.IF_OP4) e.getPlayer().getInventory().sendExamine(e.getSlotId()); } }); public static ButtonClickHandler handleEquipmentTabButtons = new ButtonClickHandler(387, e -> { if (e.getPlayer().getInterfaceManager().containsInventoryInter()) return; if (e.getComponentId() == 40) { if (e.getPlayer().getInterfaceManager().containsScreenInter()) { e.getPlayer().sendMessage(""Please finish what you're doing before opening the price checker.""); return; } e.getPlayer().stopAll(); PriceChecker.openPriceCheck(e.getPlayer()); return; } if (e.getComponentId() == 38) { openEquipmentBonuses(e.getPlayer(), false); openEquipmentBonuses(e.getPlayer(), false); return; } if (e.getComponentId() == 41) { e.getPlayer().stopAll(); ItemsKeptOnDeath.openItemsKeptOnDeath(e.getPlayer()); return; } else if (e.getComponentId() == 42) { e.getPlayer().getInterfaceManager().sendInterface(1178); return; } else if (e.getComponentId() == 43) { PriceChecker.openPriceCheck(e.getPlayer()); // e.getPlayer().sendMessage(""Customizations not finished.""); return; } Item item = e.getPlayer().getEquipment().getItem(Equipment.getItemSlot(e.getSlotId2())); if ((item == null) || PluginManager.handle(new ItemClickEvent(e.getPlayer(), item, e.getSlotId(), item.getDefinitions().getEquipmentOption(getOptionForPacket(e.getPacket())), true))) return; if (e.getPacket() == ClientPacket.IF_OP10) { e.getPlayer().getEquipment().sendExamine(Equipment.getItemSlot(e.getSlotId2())); return; } if (e.getPacket() == ClientPacket.IF_OP1 && PluginManager.handle(new ItemClickEvent(e.getPlayer(), item, e.getSlotId(), ""Remove"", true))) return; if (e.getComponentId() == 12) { if (e.getPacket() == ClientPacket.IF_OP2) ItemTeleports.sendTeleport(e.getPlayer(), e.getPlayer().getEquipment().getItem(Equipment.getItemSlot(e.getSlotId2())), 0, true); else if (e.getPacket() == ClientPacket.IF_OP3) ItemTeleports.sendTeleport(e.getPlayer(), e.getPlayer().getEquipment().getItem(Equipment.getItemSlot(e.getSlotId2())), 1, true); else if (e.getPacket() == ClientPacket.IF_OP4) ItemTeleports.sendTeleport(e.getPlayer(), e.getPlayer().getEquipment().getItem(Equipment.getItemSlot(e.getSlotId2())), 2, true); else if (e.getPacket() == ClientPacket.IF_OP5) ItemTeleports.sendTeleport(e.getPlayer(), e.getPlayer().getEquipment().getItem(Equipment.getItemSlot(e.getSlotId2())), 3, true); } else if (e.getComponentId() == 15) { if (e.getPacket() == ClientPacket.IF_OP2) { int weaponId = e.getPlayer().getEquipment().getWeaponId(); if (weaponId == 15484) e.getPlayer().getInterfaceManager().gazeOrbOfOculus(); } } else if (e.getComponentId() == 33) if (e.getPacket() == ClientPacket.IF_OP2) ItemTeleports.sendTeleport(e.getPlayer(), e.getPlayer().getEquipment().getItem(Equipment.getItemSlot(e.getSlotId2())), 0, true); else if (e.getPacket() == ClientPacket.IF_OP3) ItemTeleports.sendTeleport(e.getPlayer(), e.getPlayer().getEquipment().getItem(Equipment.getItemSlot(e.getSlotId2())), 1, true); else if (e.getPacket() == ClientPacket.IF_OP4) ItemTeleports.sendTeleport(e.getPlayer(), e.getPlayer().getEquipment().getItem(Equipment.getItemSlot(e.getSlotId2())), 2, true); else if (e.getPacket() == ClientPacket.IF_OP5) ItemTeleports.sendTeleport(e.getPlayer(), e.getPlayer().getEquipment().getItem(Equipment.getItemSlot(e.getSlotId2())), 3, true); }); public static void remove(Player player, int slotId, boolean stopAll) { if (slotId >= 15) return; player.stopAll(false, false); Item item = player.getEquipment().getItem(slotId); if (item == null || !player.getInventory().hasRoomFor(item)) return; if (!player.getEquipment().deleteSlot(slotId)) return; player.getInventory().addItem(item); player.getEquipment().refresh(slotId); player.getAppearance().generateAppearanceData(); if (slotId == 3) player.getCombatDefinitions().drainSpec(0); } public static void remove(Player player, int slotId) { remove(player, slotId, true); } public static boolean sendWear(Player player, int slotId, int itemId) { return sendWear(player, slotId, itemId, false); } public static boolean sendWear(Player player, int slotId, int itemId, boolean overrideWear) { if (player.hasFinished() || player.isDead()) return false; player.stopAll(false, false); Item item = player.getInventory().getItem(slotId); if (item == null || item.getId() != itemId) return false; if (!overrideWear && (!item.getDefinitions().containsOption(""Wear"") && !item.getDefinitions().containsOption(""Wield""))) return false; if (item.getDefinitions().isNoted() || !item.getDefinitions().isWearItem(player.getAppearance().isMale())) { player.sendMessage(""You can't wear that.""); return true; } int targetSlot = Equipment.getItemSlot(itemId); if (targetSlot <= -1 || targetSlot >= Equipment.SIZE) { player.sendMessage(""You can't wear that.""); return true; } if (!ItemConstants.canWear(item, player)) return true; boolean isTwoHandedWeapon = targetSlot == WEAPON && Equipment.isTwoHandedWeapon(item); if (isTwoHandedWeapon && !player.getInventory().hasFreeSlots() && player.getEquipment().hasShield()) { player.sendMessage(""Not enough free space in your inventory.""); return true; } if (!player.getControllerManager().canEquip(targetSlot, itemId)) return false; player.stopAll(false, false); if (!fireEvent(player, item, true)) return false; if (player.getEquipment().get(targetSlot) != null && !fireEvent(player, player.getEquipment().get(targetSlot), false)) return false; boolean dequipShield = targetSlot == WEAPON && isTwoHandedWeapon && player.getEquipment().getItem(SHIELD) != null; if (dequipShield && !fireEvent(player, player.getEquipment().getItem(SHIELD), false)) return false; boolean dequipWeapon = targetSlot == SHIELD && player.getEquipment().getItem(WEAPON) != null && Equipment.isTwoHandedWeapon(player.getEquipment().getItem(WEAPON)); if (dequipWeapon && !fireEvent(player, player.getEquipment().getItem(WEAPON), false)) return false; player.getInventory().deleteItem(slotId, item); if (dequipShield) { if (!player.getInventory().addItem(player.getEquipment().getItem(SHIELD))) { player.getInventory().getItems().set(slotId, item); player.getInventory().refresh(slotId); player.getPackets().sendVarc(779, player.getAppearance().getRenderEmote()); return true; } player.getEquipment().setNoPluginTrigger(SHIELD, null); } else if (dequipWeapon) { if (!player.getInventory().addItem(player.getEquipment().getItem(WEAPON))) { player.getInventory().getItems().set(slotId, item); player.getInventory().refresh(slotId); player.getPackets().sendVarc(779, player.getAppearance().getRenderEmote()); return true; } player.getEquipment().setNoPluginTrigger(WEAPON, null); } if (player.getEquipment().getItem(targetSlot) != null && (itemId != player.getEquipment().getItem(targetSlot).getId() || !item.getDefinitions().isStackable())) { if (player.getInventory().getItems().get(slotId) == null && !item.getDefinitions().isStackable()) { player.getInventory().getItems().set(slotId, new Item(player.getEquipment().getItem(targetSlot))); player.getInventory().refresh(slotId); } else player.getInventory().addItem(new Item(player.getEquipment().getItem(targetSlot))); player.getEquipment().setNoPluginTrigger(targetSlot, null); } int oldAmt = 0; if (player.getEquipment().getItem(targetSlot) != null) oldAmt = player.getEquipment().getItem(targetSlot).getAmount(); Item item2 = new Item(itemId, oldAmt + item.getAmount(), item.getMetaData()); player.getEquipment().setNoPluginTrigger(targetSlot, item2); player.getEquipment().refresh(targetSlot, targetSlot == WEAPON ? SHIELD : targetSlot == WEAPON ? 0 : WEAPON); player.getAppearance().generateAppearanceData(); player.getPackets().sendVarc(779, player.getAppearance().getRenderEmote()); player.soundEffect(ItemConfig.get(item.getId()).getEquipSound(), false); if (targetSlot == WEAPON) player.getCombatDefinitions().drainSpec(0); return true; } private static boolean fireEvent(Player player, Item item, boolean equip) { ItemEquipEvent wear = new ItemEquipEvent(player, item, equip); PluginManager.handle(wear); return !wear.isCancelled(); } private static int getOptionForPacket(ClientPacket packet) { return switch (packet) { case IF_OP2 -> 0; case IF_OP3 -> 1; case IF_OP4 -> 2; case IF_OP5 -> 3; case IF_OP6 -> 4; case IF_OP7 -> 5; case IF_OP8 -> 6; case IF_OP9 -> 7; case IF_OP10 -> 8; default -> -1; }; } public static void openEquipmentBonuses(final Player player, boolean banking) { player.stopAll(); player.getVars().setVarBit(4894, banking ? 1 : 0); player.getVars().setVarBit(8348, 1); player.getVars().syncVarsToClient(); player.getPackets().sendItems(93, player.getInventory().getItems()); player.getPackets().setIFEvents(new IFEvents(667, 9, 0, 20).enableUseOption(UseFlag.ICOMPONENT) .enableUseTargetability() .enableRightClickOptions(0, 1, 2, 3, 4, 5, 6, 7, 8, 9)); player.getPackets().setIFEvents(new IFEvents(670, 0, 0, 27).enableUseOption(UseFlag.ICOMPONENT) .enableUseTargetability() .enableRightClickOptions(0, 1, 2, 3)); refreshEquipBonuses(player); player.getInterfaceManager().sendInventoryInterface(670); player.getInterfaceManager().sendInterface(667); WorldTasks.delay(0, () -> { player.getPackets().sendVarc(779, player.getAppearance().getRenderEmote()); player.getPackets().sendRunScript(2319); }); if (banking) { player.getTempAttribs().setB(""Banking"", true); player.setCloseInterfacesEvent(() -> player.getTempAttribs().removeB(""Banking"")); } } public static void refreshEquipBonuses(Player player) { player.getPackets().setIFText(667, 28, ""Stab: "" + player.getCombatDefinitions().getBonus(Bonus.STAB_ATT)); player.getPackets().setIFText(667, 29, ""Slash: "" + player.getCombatDefinitions().getBonus(Bonus.SLASH_ATT)); player.getPackets().setIFText(667, 30, ""Crush: "" + player.getCombatDefinitions().getBonus(Bonus.CRUSH_ATT)); player.getPackets().setIFText(667, 31, ""Magic: "" + player.getCombatDefinitions().getBonus(Bonus.MAGIC_ATT)); player.getPackets().setIFText(667, 32, ""Range: "" + player.getCombatDefinitions().getBonus(Bonus.RANGE_ATT)); player.getPackets().setIFText(667, 33, ""Stab: "" + player.getCombatDefinitions().getBonus(Bonus.STAB_DEF)); player.getPackets().setIFText(667, 34, ""Slash: "" + player.getCombatDefinitions().getBonus(Bonus.SLASH_DEF)); player.getPackets().setIFText(667, 35, ""Crush: "" + player.getCombatDefinitions().getBonus(Bonus.CRUSH_DEF)); player.getPackets().setIFText(667, 36, ""Magic: "" + player.getCombatDefinitions().getBonus(Bonus.MAGIC_DEF)); player.getPackets().setIFText(667, 37, ""Range: "" + player.getCombatDefinitions().getBonus(Bonus.RANGE_DEF)); player.getPackets().setIFText(667, 38, ""Summoning: "" + player.getCombatDefinitions().getBonus(Bonus.SUMM_DEF)); player.getPackets().setIFText(667, 39, ""Absorb Melee: "" + player.getCombatDefinitions().getBonus(Bonus.ABSORB_MELEE) + ""%""); player.getPackets().setIFText(667, 40, ""Absorb Magic: "" + player.getCombatDefinitions().getBonus(Bonus.ABSORB_MAGIC) + ""%""); player.getPackets().setIFText(667, 41, ""Absorb Ranged: "" + player.getCombatDefinitions().getBonus(Bonus.ABSORB_RANGE) + ""%""); player.getPackets().setIFText(667, 42, ""Strength: "" + player.getCombatDefinitions().getBonus(Bonus.MELEE_STR)); player.getPackets().setIFText(667, 43, ""Ranged Str: "" + player.getCombatDefinitions().getBonus(Bonus.RANGE_STR)); player.getPackets().setIFText(667, 44, ""Prayer: "" + player.getCombatDefinitions().getBonus(Bonus.PRAYER)); player.getPackets().setIFText(667, 45, ""Magic Damage: "" + player.getCombatDefinitions().getBonus(Bonus.MAGIC_STR) + ""%""); } public static int getBonus(Player player, Item item, Bonus bonus) { int value = item.getDefinitions().getBonuses()[bonus.ordinal()]; switch(item.getId()) { case 11283, 11284 -> { return switch(bonus) { case STAB_DEF, SLASH_DEF, CRUSH_DEF, RANGE_DEF -> value + item.getMetaDataI(""dfsCharges"", 0); default -> value; }; } case 19152, 19157, 19162 -> { return switch(bonus) { case RANGE_STR -> value + Utils.clampI((int) (player.getSkills().getLevelForXp(Constants.RANGE) * 0.7), 0, 49); default -> value; }; } default -> { return value; } } } public boolean wearingRingOfWealth() { return getRingId() != -1 && ItemDefinitions.getDefs(getRingId()).getName().toLowerCase().contains(""ring of wealth""); } }" "package com.rs.game.model.entity.player; public abstract class InstancedController extends Controller { private final Instance instance; public InstancedController(Instance instance) { this.instance = instance; } public final void start() { _buildInstance(() -> { }); } @Override public void onTeleported(TeleType type) { _destroyInstance(); removeController(); } @Override public void forceClose() { _destroyInstance(); } public final void _buildInstance(Runnable onBuild) { instance.requestChunkBound().thenAccept(b -> { onBuild.run(); onBuildInstance(); }); } public abstract void onBuildInstance(); public final void _destroyInstance() { if (instance != null) instance.destroy(); onDestroyInstance(); } public abstract void onDestroyInstance(); public final boolean login() { if (instance.isPersistent()) _buildInstance(() -> { player.setForceNextMapLoadRefresh(true); player.loadMapRegions(); }); return !instance.isPersistent(); } public final boolean logout() { player.setTile(instance.getReturnTo()); _destroyInstance(); return !instance.isPersistent(); } public Instance getInstance() { return instance; } }" "package com.rs.game.model.entity.player; @PluginEventHandler public final class Inventory { private long coins; private final ItemsContainer items; private transient Player player; private transient double inventoryWeight; private final transient Set slotsToUpdate = new HashSet<>(); private transient boolean updateAll = true; public static final int INVENTORY_INTERFACE = 679; public Inventory() { items = new ItemsContainer<>(28, false); } public static ButtonClickHandler handleInventoryButtons = new ButtonClickHandler(INVENTORY_INTERFACE, e -> { if (e.getComponentId() == 0) { if (e.getSlotId() > 27 || e.getPlayer().getInterfaceManager().containsInventoryInter()) return; Item item = e.getPlayer().getInventory().getItem(e.getSlotId()); if (item == null || item.getId() != e.getSlotId2()) { e.getPlayer().getInventory().refresh(e.getSlotId()); return; } if (e.getPacket() == ClientPacket.IF_OP1) InventoryOptionsHandler.handleItemOption1(e.getPlayer(), e.getSlotId(), e.getSlotId2(), item); else if (e.getPacket() == ClientPacket.IF_OP2) InventoryOptionsHandler.handleItemOption2(e.getPlayer(), e.getSlotId(), e.getSlotId2(), item); else if (e.getPacket() == ClientPacket.IF_OP3) InventoryOptionsHandler.handleItemOption3(e.getPlayer(), e.getSlotId(), e.getSlotId2(), item); else if (e.getPacket() == ClientPacket.IF_OP4) InventoryOptionsHandler.handleItemOption4(e.getPlayer(), e.getSlotId(), e.getSlotId2(), item); else if (e.getPacket() == ClientPacket.IF_OP5) InventoryOptionsHandler.handleItemOption5(e.getPlayer(), e.getSlotId(), e.getSlotId2(), item); else if (e.getPacket() == ClientPacket.IF_OP7) InventoryOptionsHandler.handleItemOption6(e.getPlayer(), e.getSlotId(), e.getSlotId2(), item); else if (e.getPacket() == ClientPacket.IF_OP8) InventoryOptionsHandler.handleItemOption7(e.getPlayer(), e.getSlotId(), e.getSlotId2(), item); else if (e.getPacket() == ClientPacket.IF_OP10) InventoryOptionsHandler.handleItemOption8(e.getPlayer(), e.getSlotId(), e.getSlotId2(), item); } }); public static InterfaceOnInterfaceHandler handleItemOnItem = new InterfaceOnInterfaceHandler(INVENTORY_INTERFACE, INVENTORY_INTERFACE, e -> { if (e.getPlayer().getInterfaceManager().containsInventoryInter()) return; if (e.getFromSlotId() < 0 || e.getFromSlotId() >= 28 || e.getToSlotId() < 0 || e.getToSlotId() >= 28) return; Item usedWith = e.getPlayer().getInventory().getItem(e.getToSlotId()); Item itemUsed = e.getPlayer().getInventory().getItem(e.getFromSlotId()); if (itemUsed == null || usedWith == null || itemUsed.getId() != e.getFromSlotId2() || usedWith.getId() != e.getToSlotId2()) return; if (e.getFromSlotId() == e.getToSlotId()) return; e.getPlayer().stopAll(); if (!InventoryOptionsHandler.handleItemOnItem(e.getPlayer(), itemUsed, usedWith, e.getFromSlotId(), e.getToSlotId())) e.getPlayer().sendMessage(""Nothing interesting happens.""); }); public static InterfaceOnPlayerHandler handleItemOnPlayer = new InterfaceOnPlayerHandler(false, new int[] { 679 }, e -> { Item item = e.getPlayer().getInventory().getItem(e.getSlotId()); if (item == null) return; if (!e.getPlayer().getControllerManager().processItemOnPlayer(e.getTarget(), item, e.getSlotId())) return; e.getPlayer().stopAll(false); if (PluginManager.handle(new ItemOnPlayerEvent(e.getPlayer(), e.getTarget(), item, false))) return; e.getPlayer().getInteractionManager().setInteraction(new StandardEntityInteraction(e.getTarget(), 0, () -> { if (!e.getPlayer().getInventory().containsItem(item.getId(), item.getAmount())) return; e.getPlayer().faceEntity(e.getTarget()); PluginManager.handle(new ItemOnPlayerEvent(e.getPlayer(), e.getTarget(), item, true)); })); }); public static InterfaceOnNPCHandler handleItemOnNpc = new InterfaceOnNPCHandler(false, new int[] { 679 }, e -> { Item item = e.getPlayer().getInventory().getItem(e.getSlotId()); if (item == null) return; if (!e.getPlayer().getControllerManager().processItemOnNPC(e.getTarget(), item)) return; e.getPlayer().stopAll(false); if (PluginManager.handle(new ItemOnNPCEvent(e.getPlayer(), e.getTarget(), item.setSlot(e.getSlotId()), false))) return; Object dist = PluginManager.getObj(new NPCInteractionDistanceEvent(e.getPlayer(), e.getTarget())); int distance = 0; if (dist != null) distance = (int) dist; e.getPlayer().getInteractionManager().setInteraction(new StandardEntityInteraction(e.getTarget(), distance, () -> { if (!e.getPlayer().getInventory().containsItem(item.getId(), item.getAmount())) return; e.getPlayer().faceEntity(e.getTarget()); //TODO move this block to plugins after mapping NPC ids support if (e.getTarget() instanceof Familiar f && f.getPouch() == Pouch.GEYSER_TITAN) { if (e.getTarget().getId() == 7339 || e.getTarget().getId() == 7339) if ((item.getId() >= 1704 && item.getId() <= 1710 && item.getId() % 2 == 0) || (item.getId() >= 10356 && item.getId() <= 10366 && item.getId() % 2 == 0) || (item.getId() == 2572 || (item.getId() >= 20653 && item.getId() <= 20657 && item.getId() % 2 != 0))) { for (Item i : e.getPlayer().getInventory().getItems().array()) { if (i == null) continue; if (i.getId() >= 1704 && i.getId() <= 1710 && i.getId() % 2 == 0) i.setId(1712); else if (i.getId() >= 10356 && i.getId() <= 10362 && i.getId() % 2 == 0) i.setId(10354); else if (i.getId() == 2572 || (i.getId() >= 20653 && i.getId() <= 20657 && i.getId() % 2 != 0)) i.setId(20659); } e.getPlayer().getInventory().refresh(); e.getPlayer().itemDialogue(1712, ""Your ring of wealth and amulet of glory have all been recharged.""); } } else if (e.getTarget() instanceof Pet p) { e.getPlayer().faceEntity(e.getTarget()); e.getPlayer().getPetManager().eat(item.getId(), p); return; } else if (e.getTarget() instanceof ConditionalDeath cd) { cd.useHammer(e.getPlayer()); return; } PluginManager.handle(new ItemOnNPCEvent(e.getPlayer(), e.getTarget(), item, true)); })); }); public void setPlayer(Player player) { this.player = player; } public void replaceItem(int itemId, int amount, int slot) { if (items.get(slot) == null) return; items.get(slot).setId(itemId); items.get(slot).setAmount(amount); refresh(); } public void replace(Item item, Item newItem) { if (items.get(item.getSlot()) == null) throw new RuntimeException(""Yikes. Expected a "" + item.getId() + "" but was not found.""); if (item.getId() != items.get(item.getSlot()).getId()) throw new RuntimeException(""Yikes. Expected a "" + item.getId() + "" but found "" + items.get(item.getSlot()).getId() + "" instead.""); items.set(item.getSlot(), newItem); refresh(); } public void replace(int fromId, int toId) { for (Item item : items.array()) { if (item == null) continue; if (item.getId() == fromId) { item.setId(toId); refresh(); return; } } } public void init() { refresh(); items.initSlots(); player.getPackets().sendRunScript(5560, coins > Integer.MAX_VALUE ? Integer.MAX_VALUE : (int) coins); } public void unlockInventoryOptions() { player.getPackets().setIFEvents(new IFEvents(INVENTORY_INTERFACE, 0, 0, 27) .enableUseOptions(UseFlag.GROUND_ITEM,UseFlag.NPC,UseFlag.WORLD_OBJECT,UseFlag.PLAYER,UseFlag.ICOMPONENT) .enableRightClickOptions(0,1,2,6,7,9) .setDepth(1) .enableUseTargetability()); player.getPackets().setIFEvents(new IFEvents(INVENTORY_INTERFACE, 0, 28, 55).enableDrag()); } public void reset() { items.reset(); init(); // as all slots reseted better just send all again } public void refresh(int... slots) { for (int i : slots) slotsToUpdate.add(i); } public boolean hasMaterials(Item[] mats) { for (Item mat : mats) if (getAmountOf(mat.getId()) < mat.getAmount()) return false; return true; } public boolean addItem(int itemId) { return addItem(itemId, 1); } public boolean addItem(int itemId, int amount) { Item item = new Item(itemId, amount); PluginManager.handle(new ItemAddedToInventoryEvent(player, item)); if (item.getId() < 0 || item.getAmount() < 0 || !Utils.itemExists(item.getId()) || !player.getControllerManager().canAddInventoryItem(item.getId(), item.getAmount())) return false; Item[] itemsBefore = items.getItemsCopy(); if (!items.add(item)) { items.add(new Item(item.getId(), items.getFreeSlots())); player.sendMessage(""Not enough space in your inventory.""); refreshItems(itemsBefore); return false; } refreshItems(itemsBefore); return true; } public int getAmountOf(int itemId) { if (PluginManager.getAmountPlayerHas(player, itemId) != -1) return PluginManager.getAmountPlayerHas(player, itemId); return items.getNumberOf(itemId); } public boolean addItem(Item item) { PluginManager.handle(new ItemAddedToInventoryEvent(player, item)); if (item.getId() < 0 || item.getAmount() < 0 || !Utils.itemExists(item.getId()) || !player.getControllerManager().canAddInventoryItem(item.getId(), item.getAmount())) return false; Item[] itemsBefore = items.getItemsCopy(); if (!items.add(item)) { if (!item.getDefinitions().isStackable() && item.getMetaData() != null) items.add(new Item(item.getId(), items.getFreeSlots(), item.getMetaData())); player.sendMessage(""Not enough space in your inventory.""); refreshItems(itemsBefore); return false; } refreshItems(itemsBefore); return true; } public void deleteItem(int slot, Item item) { if (!player.getControllerManager().canDeleteInventoryItem(item.getId(), item.getAmount())) return; Item[] itemsBefore = items.getItemsCopy(); items.remove(slot, item); refreshItems(itemsBefore); } public void removeItems(Item... list) { for (Item item : list) { if (item == null) continue; deleteItem(item); } } public void removeAllItems(int... list) { for (int item : list) { if (!containsItem(item, 1)) continue; deleteItem(item, Integer.MAX_VALUE); } } public void deleteItem(int itemId, int amount) { if (!player.getControllerManager().canDeleteInventoryItem(itemId, amount)) return; Item[] itemsBefore = items.getItemsCopy(); items.remove(new Item(itemId, amount)); refreshItems(itemsBefore); } public void deleteItem(Item item) { if ((item == null) || !player.getControllerManager().canDeleteInventoryItem(item.getId(), item.getAmount())) return; Item[] itemsBefore = items.getItemsCopy(); items.remove(item); refreshItems(itemsBefore); } /* * No refresh needed its client to who does it :p */ public void switchItem(int fromSlot, int toSlot) { Item[] itemsBefore = items.getItemsCopy(); Item fromItem = items.get(fromSlot); Item toItem = items.get(toSlot); items.set(fromSlot, toItem); items.set(toSlot, fromItem); refreshItems(itemsBefore); } public void refreshItems(Item[] itemsBefore) { int[] changedSlots = new int[itemsBefore.length]; int count = 0; for (int index = 0; index < itemsBefore.length; index++) if (itemsBefore[index] != items.array()[index]) changedSlots[count++] = index; int[] finalChangedSlots = new int[count]; System.arraycopy(changedSlots, 0, finalChangedSlots, 0, count); refresh(finalChangedSlots); } public ItemsContainer getItems() { return items; } public boolean hasFreeSlots() { return items.getFreeSlot() != -1; } public int getFreeSlots() { return items.getFreeSlots(); } public int getNumberOf(int itemId) { return getNumberOf(itemId, true); } public int getNumberOf(int itemId, boolean checkToolbelt) { if (PluginManager.getAmountPlayerHas(player, itemId) != -1) return PluginManager.getAmountPlayerHas(player, itemId); int amount = items.getNumberOf(itemId); if (checkToolbelt && player.containsTool(itemId)) amount++; return amount; } public Item getItem(int slot) { return items.get(slot); } public boolean hasRoomFor(Item... item) { return hasRoomFor(null, item); } public boolean hasRoomFor(Item[] deleting, Item... adding) { int freeSlots = getFreeSlots(); int freedSlots = 0; if (deleting != null) for (Item i : deleting) { if (i == null) continue; if (!i.getDefinitions().isStackable() || (i.getDefinitions().isStackable() && getNumberOf(i.getId(), false) <= i.getAmount())) freedSlots++; } freeSlots += freedSlots; int neededSlots = 0; for (Item i : adding) { if (i == null) continue; if (i.getDefinitions().isStackable() && (getNumberOf(i.getId()) + i.getAmount()) <= 0) return false; if (!i.getDefinitions().isStackable() || (i.getDefinitions().isStackable() && getNumberOf(i.getId(), false) <= 0)) neededSlots++; } return freeSlots >= neededSlots; } public Item getItemById(int id) { for (Item item : items.array()) if (item != null && item.getId() == id) return item; return null; } public boolean hasFreeSlots(Item[] mats, Item product) { boolean allStack = true; for (Item i : mats) if (i != null) if (!i.getDefinitions().isStackable()) allStack = false; return hasRoomFor(product) || (mats.length > 0 && !allStack); } public int getItemsContainerSize() { return items.getSize(); } public boolean containsItem(String name) { for (Item item : items.toArray()) if (item != null) if (item.getDefinitions().getName().equalsIgnoreCase(name)) return true; return false; } public boolean containsItems(int... itemIds) { for (int itemId : itemIds) if (!items.contains(new Item(itemId, 1))) return false; return true; } public boolean containsItems(Item... item) { for (Item element : item) if (!items.contains(element)) return false; return true; } public boolean containsItems(int[] itemIds, int[] amounts) { int size = itemIds.length > amounts.length ? amounts.length : itemIds.length; for (int i = 0; i < size; i++) if (!items.contains(new Item(itemIds[i], amounts[i]))) return false; return true; } public boolean containsItem(Item item) { return containsItem(item.getId(), item.getAmount(), true); } public boolean containsItem(int itemId, int amount) { return containsItem(itemId, amount, true); } public boolean containsItem(int itemId, int amount, boolean checkToolbelt) { if (PluginManager.getAmountPlayerHas(player, itemId) != -1) return PluginManager.getAmountPlayerHas(player, itemId) >= amount; return items.contains(new Item(itemId, amount)) || (checkToolbelt && player.containsTool(itemId)); } public boolean missingItems(int... itemIds) { for (int itemId : itemIds) { boolean found = false; for (Item item : items.array()) { if (item == null) continue; if (item.getId() == itemId) found = true; } if (found) return false; } return true; } public boolean containsOneItem(int... itemIds) { return containsOneItem(true, itemIds); } public boolean containsOneItem(boolean checkToolbelt, int... itemIds) { for (int itemId : itemIds) if (items.containsOne(new Item(itemId, 1)) || (checkToolbelt && player.containsTool(itemId))) return true; return false; } public void sendExamine(int slotId) { if (slotId >= getItemsContainerSize()) return; Item item = items.get(slotId); if (item == null) return; ItemDefinitions def = ItemDefinitions.getDefs(item.getId()); player.getPackets().sendInventoryMessage(0, slotId, ItemConfig.get(item.getId()).getExamine(item) + (ItemConstants.isTradeable(item) ? ("" General store: "" + Utils.formatTypicalInteger(item.getDefinitions().getSellPrice()) + "" High Alchemy: "" + Utils.formatTypicalInteger(def.getHighAlchPrice())) : """")); if (item.getMetaData(""combatCharges"") != null) player.sendMessage(""It looks like it will last another "" + Utils.ticksToTime(item.getMetaDataI(""combatCharges""))); else if (item.getMetaData(""brawlerCharges"") != null) player.sendMessage(""These gloves have "" + item.getMetaDataI(""brawlerCharges"") + "" charges left.""); } public void refresh() { updateAll = true; } public void processRefresh() { boolean needsRefresh = updateAll || !slotsToUpdate.isEmpty(); if (updateAll) player.getPackets().sendItems(93, items); else if (!slotsToUpdate.isEmpty()) player.getPackets().sendUpdateItems(93, items, slotsToUpdate.stream().mapToInt(Integer::intValue).toArray()); if (needsRefresh) { updateAll = false; slotsToUpdate.clear(); refreshConfigs(); } } public boolean addItem(int itemId, int amount, boolean dropIfInvFull) { return addItem(new Item(itemId, amount), dropIfInvFull); } public boolean addItem(Item item, boolean dropIfInvFull) { if (item.getId() < 0 || item.getAmount() < 0 || !Utils.itemExists(item.getId()) || !player.getControllerManager().canAddInventoryItem(item.getId(), item.getAmount())) return false; Item[] itemsBefore = items.getItemsCopy(); int numberToDrop = 0; if (!items.add(item)) { numberToDrop = item.getAmount() - items.getFreeSlots(); items.add(new Item(item).setAmount(items.getFreeSlots())); player.sendMessage(""Not enough space in your inventory.""); World.addGroundItem(item.setAmount(numberToDrop), Tile.of(player.getTile()), player, true, 60); refreshItems(itemsBefore); return true; } PluginManager.handle(new ItemAddedToInventoryEvent(player, new Item(item.getId(), numberToDrop))); refreshItems(itemsBefore); return true; } public void refreshConfigs() { double w = 0; for (Item item : items.array()) { if (item == null) continue; w += ItemConfig.get(item.getId()).getWeight(false); } inventoryWeight = w; player.getPackets().refreshWeight(player.getEquipment().getEquipmentWeight() + inventoryWeight); } public boolean addItemDrop(int id, int amount) { return addItem(id, amount, true); } public boolean addItemDrop(Item item) { return addItem(item, true); } public boolean containsItems(List list) { for (Item item : list) if (!items.contains(item)) return false; return true; } public boolean removeItems(List list) { for (Item item : list) { if (item == null) continue; deleteItem(item); } return true; } public double getInventoryWeight() { return inventoryWeight; } public boolean containsItem(int id) { return containsItem(id, 1); } public boolean containsItemNoted(Item item) { int itemId = item.getId(); int notedId = item.getDefinitions().getCertId(); return containsItem(itemId, item.getAmount()) || containsItem(notedId, item.getAmount()); } public void deleteItemNoted(Item item) { int itemId = item.getId(); int notedId = item.getDefinitions().getCertId(); if (containsItem(itemId)) deleteItem(itemId, item.getAmount()); else deleteItem(notedId, item.getAmount()); } public int getTotalNumberOf(int... ids) { int count = 0; for (int id : ids) count += getNumberOf(id); return count; } public static ItemClickHandler coinPouch = new ItemClickHandler(new Object[] { 995 }, new String[] { ""Add-to-pouch"" }, e -> { if ((e.getPlayer().getInventory().getCoins() + e.getItem().getAmount()) < 0L) { e.getPlayer().sendMessage(""Your pouch is full somehow. This kind of money probably deserves a ban LOL.""); return; } e.getPlayer().getInventory().deleteItem(e.getItem()); e.getPlayer().getInventory().addCoins(e.getItem().getAmount()); }); public void coinPouchToInventory(int num) { if (num > coins) num = (int) coins; if (num <= 0) return; if ((getNumberOf(995) + num) < 0) num = Integer.MAX_VALUE - getNumberOf(995) - 1; coins -= num; player.getPackets().sendRunScript(5561, num, 0); player.getPackets().sendRunScript(5560, coins > Integer.MAX_VALUE ? Integer.MAX_VALUE : (int) coins); addItemDrop(995, num); } public void addCoins(int num) { if (num <= 0) return; if ((coins + num) > 0L) { coins += num; player.getPackets().sendRunScript(5561, num, 1); player.getPackets().sendRunScript(5560, coins > Integer.MAX_VALUE ? Integer.MAX_VALUE : (int) coins); return; } addItemDrop(995, num); } public boolean hasCoins(int num) { if (coins >= num) return true; return coins + getNumberOf(995) >= num; } public long getCoins() { long total = coins + getNumberOf(995); if (total < 0L) return coins; return total; } public long getPouchCoins() { return coins; } public int getPouchCoinsAsInt() { long coins = getPouchCoins(); if (coins > Integer.MAX_VALUE) return Integer.MAX_VALUE; return (int) coins; } public int getCoinsAsInt() { long coins = getCoins(); if (coins > Integer.MAX_VALUE) return Integer.MAX_VALUE; return (int) coins; } public void removeCoins(int num) { removeCoins(num, false); } public void removeCoins(int num, boolean pouchOnly) { if (num <= 0) return; if (coins >= num) { coins -= num; player.getPackets().sendRunScript(5561, num, 0); player.getPackets().sendRunScript(5560, coins > Integer.MAX_VALUE ? Integer.MAX_VALUE : (int) coins); return; } if (pouchOnly) return; if (coins > 0) { num -= coins; player.getPackets().sendRunScript(5561, (int) coins, 0); player.getPackets().sendRunScript(5560, coins > Integer.MAX_VALUE ? Integer.MAX_VALUE : (int) coins); coins = 0; } if (getNumberOf(995) >= num) deleteItem(995, num); else { player.sendMessage(""Error removing coins. Please report how you managed to produce this message.""); Logger.error(Inventory.class, ""removeCoins (""+player.getUsername()+"")"", Arrays.toString(Thread.currentThread().getStackTrace())); } } public Item findItemByIds(int... ids) { for (int itemId : ids) { Item item = getItemById(itemId); if (item != null) return item; } return null; } }" "package com.rs.game.model.entity.player; public class ItemMeshModifier { private static final byte BODY_MODEL_FLAG = 0x1, HEAD_MODEL_FLAG = 0x2, COLOR_FLAG = 0x4, TEXTURE_FLAG = 0x8; private static final byte EMPTY_VALUE = 0xF; private final ItemDefinitions defs; private final int slotFlag; private int[] maleBody; private int[] femaleBody; private int[] maleHead; private int[] femaleHead; private int[] modifiedColors; private int[] modifiedTextures; public ItemMeshModifier(ItemDefinitions defs, int slotFlag) { this.defs = defs; this.slotFlag = slotFlag; } public ItemMeshModifier addBodyModels(int[] maleBodies, int[] femaleBodies) { maleBody = new int[3]; femaleBody = new int[3]; maleBody[0] = defs.maleEquip1; maleBody[1] = defs.maleEquip2; maleBody[2] = defs.maleEquip3; femaleBody[0] = defs.femaleEquip1; femaleBody[1] = defs.femaleEquip2; femaleBody[2] = defs.femaleEquip3; for (int i = 0;i < maleBody.length;i++) { if (i >= maleBodies.length) continue; maleBody[i] = maleBodies[i]; femaleBody[i] = femaleBodies[i]; } return this; } public ItemMeshModifier addBodyModels(int... bodies) { return addBodyModels(bodies, bodies); } public ItemMeshModifier addHeadModels(int[] maleHeads, int[] femaleHeads) { maleHead = new int[2]; femaleHead = new int[2]; maleHead[0] = defs.maleHead1; maleHead[1] = defs.maleHead2; femaleHead[0] = defs.femaleHead1; femaleHead[1] = defs.femaleHead2; for (int i = 0;i < maleHead.length;i++) { if (i >= maleHeads.length) continue; maleHead[i] = maleHeads[i]; femaleHead[i] = femaleHeads[i]; } return this; } public ItemMeshModifier addHeadModels(int... heads) { return addHeadModels(heads, heads); } public ItemMeshModifier addColors(int... colors) { if (defs.modifiedModelColors != null) { modifiedColors = new int[defs.modifiedModelColors.length]; System.arraycopy(defs.modifiedModelColors, 0, modifiedColors, 0, modifiedColors.length); } for (int i = 0;i < modifiedColors.length;i++) { if (i >= colors.length) break; modifiedColors[i] = colors[i]; } return this; } public ItemMeshModifier addTextures(int... textures) { if (defs.modifiedTextureIds != null) { modifiedTextures = new int[defs.modifiedTextureIds.length]; System.arraycopy(defs.modifiedTextureIds, 0, modifiedTextures, 0, modifiedTextures.length); } if (modifiedTextures == null) return this; for (int i = 0;i < modifiedTextures.length;i++) { if (i >= textures.length) break; modifiedTextures[i] = textures[i]; } return this; } public int encode(OutputStream stream) { int flags = getModificationFlags(); if (flags == 0) return -1; stream.writeByte(flags); if ((flags & BODY_MODEL_FLAG) != 0) encodeBodyModels(stream); if ((flags & HEAD_MODEL_FLAG) != 0) encodeHeadModels(stream); if ((flags & COLOR_FLAG) != 0) encodeColors(stream); if ((flags & TEXTURE_FLAG) != 0) encodeTextures(stream); return slotFlag; } public void encodeBodyModels(OutputStream stream) { stream.writeBigSmart(maleBody[0]); stream.writeBigSmart(femaleBody[0]); if (defs.maleEquip2 != -1 || defs.femaleEquip2 != -1) { stream.writeBigSmart(maleBody[1]); stream.writeBigSmart(femaleBody[1]); } if (defs.maleEquip3 != -1 || defs.femaleEquip3 != -1) { stream.writeBigSmart(maleBody[2]); stream.writeBigSmart(femaleBody[2]); } } public void encodeHeadModels(OutputStream stream) { stream.writeBigSmart(maleHead[0]); stream.writeBigSmart(femaleHead[0]); if (defs.maleHead2 != -1 || defs.femaleHead2 != -1) { stream.writeBigSmart(maleHead[1]); stream.writeBigSmart(femaleHead[1]); } } public void encodeColors(OutputStream stream) { int slots = 0; for (int i = 1;i < 4;i++) if (i < modifiedColors.length) slots |= i << (i * 4); else slots |= EMPTY_VALUE << (i * 4); stream.writeShort(slots); for (int i = 0;i < 4;i++) if (i < modifiedColors.length) stream.writeShort(modifiedColors[i]); } public void encodeTextures(OutputStream stream) { int slots = 0; for (int i = 1;i < 2;i++) if (i < modifiedTextures.length) slots |= i << (i * 4); else slots |= EMPTY_VALUE << (i * 4); stream.writeByte(slots); for (int i = 0;i < 2;i++) if (i < modifiedTextures.length) stream.writeShort(modifiedTextures[i]); } public int getModificationFlags() { int flags = 0; if (maleBody != null || femaleBody != null) flags |= BODY_MODEL_FLAG; if (maleHead != null || femaleHead != null) flags |= HEAD_MODEL_FLAG; if (modifiedColors != null) flags |= COLOR_FLAG; if (modifiedTextures != null) flags |= TEXTURE_FLAG; return flags; } }" "package com.rs.game.model.entity.player; public final class LocalNPCUpdate { private final Player player; private final LinkedList localNPCs; public void reset() { localNPCs.clear(); } public LocalNPCUpdate(Player player) { this.player = player; localNPCs = new LinkedList<>(); } public void write(OutputStream stream, boolean largeSceneView) { OutputStream updateBlockData = new OutputStream(); processLocalNPCsInform(stream, updateBlockData, largeSceneView); stream.writeBytes(updateBlockData.getBuffer(), 0, updateBlockData.getOffset()); } private void processLocalNPCsInform(OutputStream stream, OutputStream updateBlockData, boolean largeSceneView) { stream.initBitAccess(); processInScreenNPCs(stream, updateBlockData, largeSceneView); addInScreenNPCs(stream, updateBlockData, largeSceneView); if (updateBlockData.getOffset() > 0) stream.writeBits(15, 32767); stream.finishBitAccess(); } private void processInScreenNPCs(OutputStream stream, OutputStream updateBlockData, boolean largeSceneView) { stream.writeBits(8, localNPCs.size()); for (Iterator it = localNPCs.iterator(); it.hasNext();) { NPC n = it.next(); if (n.hasFinished() || !n.withinDistance(player, largeSceneView ? 126 : 14) || n.hasTeleported()) { stream.writeBits(1, 1); stream.writeBits(2, 3); it.remove(); continue; } boolean needUpdate = n.needMasksUpdate(); boolean walkUpdate = n.getNextWalkDirection() != null; stream.writeBits(1, (needUpdate || walkUpdate) ? 1 : 0); if (walkUpdate) { if (n.getNextRunDirection() == null) { if (n.getDefinitions().movementType == MovementType.HALF_WALK) { stream.writeBits(2, 2); stream.writeBits(1, 0); stream.writeBits(3, n.getNextWalkDirection().id); } else { stream.writeBits(2, 1); stream.writeBits(3, n.getNextWalkDirection().id); } } else { stream.writeBits(2, 2); stream.writeBits(1, 1); stream.writeBits(3, n.getNextWalkDirection().id); stream.writeBits(3, n.getNextRunDirection().id); } stream.writeBits(1, needUpdate ? 1 : 0); } else if (needUpdate) stream.writeBits(2, 0); if (needUpdate) appendUpdateBlock(n, updateBlockData, false); } } private void addInScreenNPCs(OutputStream stream, OutputStream updateBlockData, boolean largeSceneView) { int radius = largeSceneView ? 126 : 14; //TODO is isDead really necessary here? for (NPC n : player.queryNearbyNPCsByTileRange(radius, n -> /*!n.isDead() && */!localNPCs.contains(n) && n.withinDistance(player, radius))) { if (localNPCs.size() == Settings.LOCAL_NPCS_LIMIT) break; stream.writeBits(15, n.getIndex()); boolean needUpdate = n.needMasksUpdate() || n.getLastFaceEntity() != -1; int x = n.getX() - player.getX(); int y = n.getY() - player.getY(); if (largeSceneView) { if (x < 127) x += 256; if (y < 127) y += 256; } else { if (x < 15) x += 32; if (y < 15) y += 32; } stream.writeBits(1, needUpdate ? 1 : 0); stream.writeBits(largeSceneView ? 8 : 5, y); stream.writeBits(3, (n.getFaceAngle() >> 11) - 4); stream.writeBits(15, n.getId()); stream.writeBits(largeSceneView ? 8 : 5, x); stream.writeBits(1, n.hasTeleported() ? 1 : 0); stream.writeBits(2, n.getPlane()); localNPCs.add(n); if (needUpdate) appendUpdateBlock(n, updateBlockData, true); } } private void appendUpdateBlock(NPC n, OutputStream data, boolean added) { OutputStream block = new OutputStream(); int maskData = 0; if (n.getNextAnimation() != null) { maskData |= 0x10; applyAnimationMask(n, block); } if (n.getBodyMeshModifier() != null) { maskData |= 0x100; applyBodyMeshModifierMask(n, block); } if (n.getNextForceMovement() != null) { maskData |= 0x400; applyForceMovementMask(n, block); } if (n.getBas() != -1) { maskData |= 0x1000; block.writeShort(n.getBas() == -2 ? -1 : n.getBas()); } //0x200000 unused outdated varn if (n.getNextSpotAnim4() != null) { maskData |= 0x1000000; applyGraphicsMask4(n, block); } if (n.getNextFaceEntity() != -2 || (added && n.getLastFaceEntity() != -1)) { maskData |= 0x80; applyFaceEntityMask(n, block); } //0x8000 animation related if (n.getNextSpotAnim2() != null) { maskData |= 0x800; applyGraphicsMask2(n, block); } if (!n.getNextHits().isEmpty() || !n.getNextHitBars().isEmpty()) { maskData |= 0x1; applyHitMask(n, block); } if (n.getNextTransformation() != null) { maskData |= 0x8; applyTransformationMask(n, block); } if (n.getNextSpotAnim3() != null) { maskData |= 0x2000000; applyGraphicsMask3(n, block); } //0x80000 unused double array of size 6 modification? //0x40000 mesh modifier for npc chatheads? if (n.hasChangedCombatLevel() || (added && n.getCustomCombatLevel() >= 0)) { maskData |= 0x10000; applyChangeLevelMask(n, block); } //0x400000 unused outdated varn if (n.getFixedFaceTile() != null || (n.getNextFaceTile() != null && n.getNextRunDirection() == null && n.getNextWalkDirection() == null)) { maskData |= 0x4; applyFaceTileMask(n, block); } if (n.getNextBodyGlow() != null) { maskData |= 0x20000; applyBodyGlowMask(n, block); } if (n.hasChangedName() || (added && n.getCustomName() != null)) { maskData |= 0x800000; applyNameChangeMask(n, block); } if (n.getNextForceTalk() != null) { maskData |= 0x2; applyForceTalkMask(n, block); } if (n.getBodyModelRotator() != null) { maskData |= 0x4000; n.getBodyModelRotator().encodeNPC(block); } if (n.getNextSpotAnim1() != null) { maskData |= 0x20; applyGraphicsMask1(n, block); } if (maskData > 0xff) maskData |= 0x40; if (maskData > 0xffff) maskData |= 0x2000; if (maskData > 0xffffff) maskData |= 0x100000; data.writeByte(maskData); if (maskData > 0xff) data.writeByte(maskData >> 8); if (maskData > 0xffff) data.writeByte(maskData >> 16); if (maskData > 0xffffff) data.writeByte(maskData >> 24); data.writeBytes(block.toByteArray()); } private void applyBodyMeshModifierMask(NPC n, OutputStream block) { n.getBodyMeshModifier().encode(block); } private void applyBodyGlowMask(NPC n, OutputStream data) { data.write128Byte(n.getNextBodyGlow().getRedAdd()); data.writeByte(n.getNextBodyGlow().getGreenAdd()); data.writeByte(n.getNextBodyGlow().getBlueAdd()); data.write128Byte(n.getNextBodyGlow().getScalar()); data.writeShortLE(0); data.writeShort(n.getNextBodyGlow().getTime()); } private void applyChangeLevelMask(NPC n, OutputStream data) { data.writeShort128(n.getCombatLevel()); } private void applyNameChangeMask(NPC npc, OutputStream data) { data.writeString(npc.getName()); } private void applyTransformationMask(NPC n, OutputStream data) { data.writeBigSmart(n.getNextTransformation().toNPCId()); } private void applyForceTalkMask(NPC n, OutputStream data) { data.writeString(n.getNextForceTalk().text()); } private void applyForceMovementMask(NPC n, OutputStream data) { data.write128Byte(n.getNextForceMovement().getDiffX1()); data.writeByte128(n.getNextForceMovement().getDiffY1()); data.writeByteC(n.getNextForceMovement().getDiffX2()); data.writeByte128(n.getNextForceMovement().getDiffY2()); data.writeShortLE(n.getNextForceMovement().getStartClientCycles()); data.writeShortLE(n.getNextForceMovement().getSpeedClientCycles()); data.writeShortLE128(n.getNextForceMovement().getDirection()); } private void applyFaceTileMask(NPC n, OutputStream data) { Tile tile = n.getFixedFaceTile() != null ? n.getFixedFaceTile() : n.getNextFaceTile(); data.writeShortLE128((tile.getX() << 1) + 1); data.writeShortLE((tile.getY() << 1) + 1); } private void applyHitMask(NPC n, OutputStream data) { data.writeByte128(n.getNextHits().size()); for (Hit hit : n.getNextHits().toArray(new Hit[0])) { boolean interactingWith = hit.interactingWith(player, n); if (hit.missed() && !interactingWith) { data.writeSmart(32766); data.writeByte(hit.getDamage()); } else if (hit.getSoaking() != null) { data.writeSmart(32767); data.writeSmart(hit.getMark(player, n)); data.writeSmart(Utils.clampI(hit.getDamage(), 0, Short.MAX_VALUE/2)); data.writeSmart(hit.getSoaking().getMark(player, n)); data.writeSmart(Utils.clampI(hit.getSoaking().getDamage(), 0, Short.MAX_VALUE/2)); } else { data.writeSmart(hit.getMark(player, n)); data.writeSmart(Utils.clampI(hit.getDamage(), 0, Short.MAX_VALUE/2)); } data.writeSmart(hit.getDelay()); } data.writeByte128(n.getNextHitBars().size()); for (HitBar bar : n.getNextHitBars()) { data.writeSmart(bar.getType()); int perc = bar.getPercentage(); int toPerc = bar.getToPercentage(); boolean display = bar.display(player); data.writeSmart(display ? perc != toPerc ? bar.getTimer() : 0 : 32767); if (display) { data.writeSmart(bar.getDelay()); data.write128Byte(perc); if (toPerc != perc) data.writeByte128(toPerc); } } } private void applyFaceEntityMask(NPC n, OutputStream data) { data.writeShortLE(n.getNextFaceEntity() == -2 ? n.getLastFaceEntity() : n.getNextFaceEntity()); } private void applyAnimationMask(NPC n, OutputStream data) { for (int id : n.getNextAnimation().getIds()) data.writeBigSmart(id); data.writeByte(n.getNextAnimation().getSpeed()); } private void applyGraphicsMask4(NPC n, OutputStream data) { data.writeShort128(n.getNextSpotAnim4().getId()); data.writeIntV2(n.getNextSpotAnim4().getSettingsHash()); data.writeByte128(n.getNextSpotAnim4().getSettings2Hash()); } private void applyGraphicsMask3(NPC n, OutputStream data) { data.writeShortLE(n.getNextSpotAnim3().getId()); data.writeIntLE(n.getNextSpotAnim3().getSettingsHash()); data.writeByte(n.getNextSpotAnim3().getSettings2Hash()); } private void applyGraphicsMask2(NPC n, OutputStream data) { data.writeShortLE(n.getNextSpotAnim2().getId()); data.writeInt(n.getNextSpotAnim2().getSettingsHash()); data.writeByte128(n.getNextSpotAnim2().getSettings2Hash()); } private void applyGraphicsMask1(NPC n, OutputStream data) { data.writeShort(n.getNextSpotAnim1().getId()); data.writeIntV2(n.getNextSpotAnim1().getSettingsHash()); data.writeByteC(n.getNextSpotAnim1().getSettings2Hash()); } }" "package com.rs.game.model.entity.player; public final class LocalPlayerUpdate { private static final int MAX_PLAYER_ADD = 15; private final Player player; private final byte[] slotFlags; private final Player[] localPlayers; private final int[] localPlayersIndexes; private int localPlayersIndexesCount; private final int[] outPlayersIndexes; private int outPlayersIndexesCount; private final int[] regionHashes; private final byte[][] cachedAppearencesHashes; private int totalRenderDataSentLength; /** * The amount of local players added this tick. */ private int localAddedPlayers; public Player[] getLocalPlayers() { return localPlayers; } public boolean needAppearenceUpdate(int index, byte[] hash) { if (totalRenderDataSentLength > ((Constants.PACKET_SIZE_LIMIT - 500) / 2) || hash == null) return false; return cachedAppearencesHashes[index] == null || !MessageDigest.isEqual(cachedAppearencesHashes[index], hash); } public LocalPlayerUpdate(Player player) { this.player = player; slotFlags = new byte[2048]; localPlayers = new Player[2048]; localPlayersIndexes = new int[Settings.PLAYERS_LIMIT]; outPlayersIndexes = new int[2048]; regionHashes = new int[2048]; cachedAppearencesHashes = new byte[Settings.PLAYERS_LIMIT][]; } public void init(OutputStream stream) { stream.initBitAccess(); stream.writeBits(30, player.getTileHash()); localPlayers[player.getIndex()] = player; localPlayersIndexes[localPlayersIndexesCount++] = player.getIndex(); for (int playerIndex = 1; playerIndex < 2048; playerIndex++) { if (playerIndex == player.getIndex()) continue; Player player = World.getPlayers().get(playerIndex); stream.writeBits(18, regionHashes[playerIndex] = player == null ? 0 : player.getRegionHash()); outPlayersIndexes[outPlayersIndexesCount++] = playerIndex; } stream.finishBitAccess(); } private boolean needsRemove(Player p) { return (p.hasFinished() || !player.withinDistance(p, player.hasLargeSceneView() ? 126 : 14)); } private boolean needsAdd(Player p) { return p != null && !p.hasFinished() && player.withinDistance(p, player.hasLargeSceneView() ? 126 : 14) && localAddedPlayers < MAX_PLAYER_ADD; } private void updateRegionHash(OutputStream stream, int lastRegionHash, int currentRegionHash) { int lastRegionX = lastRegionHash >> 8; int lastRegionY = 0xff & lastRegionHash; int lastPlane = lastRegionHash >> 16; int currentRegionX = currentRegionHash >> 8; int currentRegionY = 0xff & currentRegionHash; int currentPlane = currentRegionHash >> 16; int planeOffset = currentPlane - lastPlane; if (lastRegionX == currentRegionX && lastRegionY == currentRegionY) { stream.writeBits(2, 1); stream.writeBits(2, planeOffset); } else if (Math.abs(currentRegionX - lastRegionX) <= 1 && Math.abs(currentRegionY - lastRegionY) <= 1) { int opcode; int dx = currentRegionX - lastRegionX; int dy = currentRegionY - lastRegionY; if (dx == -1 && dy == -1) opcode = 0; else if (dx == 1 && dy == -1) opcode = 2; else if (dx == -1 && dy == 1) opcode = 5; else if (dx == 1 && dy == 1) opcode = 7; else if (dy == -1) opcode = 1; else if (dx == -1) opcode = 3; else if (dx == 1) opcode = 4; else opcode = 6; stream.writeBits(2, 2); stream.writeBits(5, (planeOffset << 3) + (opcode & 0x7)); } else { int xOffset = currentRegionX - lastRegionX; int yOffset = currentRegionY - lastRegionY; stream.writeBits(2, 3); stream.writeBits(18, (yOffset & 0xff) + ((xOffset & 0xff) << 8) + (planeOffset << 16)); } } private void processOutsidePlayers(OutputStream stream, OutputStream updateBlockData, boolean nsn2) { stream.initBitAccess(); int skip = 0; localAddedPlayers = 0; for (int i = 0; i < outPlayersIndexesCount; i++) { int playerIndex = outPlayersIndexes[i]; if (nsn2 == ((0x1 & slotFlags[playerIndex]) == 0)) continue; if (skip > 0) { skip--; slotFlags[playerIndex] = (byte) (slotFlags[playerIndex] | 2); continue; } Player p = World.getPlayers().get(playerIndex); if (needsAdd(p)) { stream.writeBits(1, 1); stream.writeBits(2, 0); // request add int hash = p.getRegionHash(); if (hash == regionHashes[playerIndex]) stream.writeBits(1, 0); else { stream.writeBits(1, 1); updateRegionHash(stream, regionHashes[playerIndex], hash); regionHashes[playerIndex] = hash; } stream.writeBits(6, p.getXInRegion()); stream.writeBits(6, p.getYInRegion()); boolean needAppearenceUpdate = needAppearenceUpdate(p.getIndex(), p.getAppearance().getMD5AppeareanceDataHash()); appendUpdateBlock(p, updateBlockData, needAppearenceUpdate, true); stream.writeBits(1, 1); localAddedPlayers++; localPlayers[p.getIndex()] = p; slotFlags[playerIndex] = (byte) (slotFlags[playerIndex] | 2); } else { int hash = p == null ? regionHashes[playerIndex] : p.getRegionHash(); if (p != null && hash != regionHashes[playerIndex]) { stream.writeBits(1, 1); updateRegionHash(stream, regionHashes[playerIndex], hash); regionHashes[playerIndex] = hash; } else { stream.writeBits(1, 0); // no update needed for (int i2 = i + 1; i2 < outPlayersIndexesCount; i2++) { int p2Index = outPlayersIndexes[i2]; if (nsn2 == ((0x1 & slotFlags[p2Index]) == 0)) continue; Player p2 = World.getPlayers().get(p2Index); if (needsAdd(p2) || (p2 != null && p2.getRegionHash() != regionHashes[p2Index])) break; skip++; } skipPlayers(stream, skip); slotFlags[playerIndex] = (byte) (slotFlags[playerIndex] | 2); } } } stream.finishBitAccess(); } private void processLocalPlayers(OutputStream stream, OutputStream updateBlockData, boolean nsn0) { stream.initBitAccess(); int skip = 0; for (int i = 0; i < localPlayersIndexesCount; i++) { int playerIndex = localPlayersIndexes[i]; if (nsn0 == ((0x1 & slotFlags[playerIndex]) != 0)) continue; if (skip > 0) { skip--; slotFlags[playerIndex] = (byte) (slotFlags[playerIndex] | 2); continue; } Player p = localPlayers[playerIndex]; if (needsRemove(p)) { stream.writeBits(1, 1); // needs update stream.writeBits(1, 0); // no masks update needeed stream.writeBits(2, 0); // request remove regionHashes[playerIndex] = p.getLastTile() == null ? p.getRegionHash() : p.getLastTile().getRegionHash(); int hash = p.getRegionHash(); if (hash == regionHashes[playerIndex]) stream.writeBits(1, 0); else { stream.writeBits(1, 1); updateRegionHash(stream, regionHashes[playerIndex], hash); regionHashes[playerIndex] = hash; } localPlayers[playerIndex] = null; continue; } boolean needAppearenceUpdate = needAppearenceUpdate(p.getIndex(), p.getAppearance().getMD5AppeareanceDataHash()); boolean needUpdate = p.needMasksUpdate() || needAppearenceUpdate; if (needUpdate) appendUpdateBlock(p, updateBlockData, needAppearenceUpdate, false); if (p.hasTeleported()) { stream.writeBits(1, 1); // needs update stream.writeBits(1, needUpdate ? 1 : 0); stream.writeBits(2, 3); int xOffset = p.getX() - p.getLastTile().getX(); int yOffset = p.getY() - p.getLastTile().getY(); int planeOffset = p.getPlane() - p.getLastTile().getPlane(); if (Math.abs(xOffset) <= 14 && Math.abs(yOffset) <= 14) { stream.writeBits(1, 0); if (xOffset < 0) xOffset += 32; if (yOffset < 0) yOffset += 32; stream.writeBits(12, yOffset + (xOffset << 5) + (planeOffset << 10)); } else { stream.writeBits(1, 1); stream.writeBits(30, (yOffset & 0x3fff) + ((xOffset & 0x3fff) << 14) + ((planeOffset & 0x3) << 28)); } } else if (p.getNextWalkDirection() != null) { int dx = p.getNextWalkDirection().dx; int dy = p.getNextWalkDirection().dy; boolean running; int opcode; if (p.getNextRunDirection() != null) { dx += p.getNextRunDirection().dx; dy += p.getNextRunDirection().dy; opcode = Utils.getPlayerRunningDirection(dx, dy); if (opcode == -1) { running = false; opcode = Utils.getPlayerWalkingDirection(dx, dy); } else running = true; } else { running = false; opcode = Utils.getPlayerWalkingDirection(dx, dy); } stream.writeBits(1, 1); if ((dx == 0 && dy == 0)) { stream.writeBits(1, 1); // quick fix stream.writeBits(2, 0); if (!needUpdate) // hasnt been sent yet appendUpdateBlock(p, updateBlockData, needAppearenceUpdate, false); } else { stream.writeBits(1, needUpdate ? 1 : 0); stream.writeBits(2, running ? 2 : 1); stream.writeBits(running ? 4 : 3, opcode); } } else if (needUpdate) { stream.writeBits(1, 1); // needs update stream.writeBits(1, 1); stream.writeBits(2, 0); } else { // skip stream.writeBits(1, 0); // no update needed for (int i2 = i + 1; i2 < localPlayersIndexesCount; i2++) { int p2Index = localPlayersIndexes[i2]; if (nsn0 == ((0x1 & slotFlags[p2Index]) != 0)) continue; Player p2 = localPlayers[p2Index]; if (needsRemove(p2) || p2.hasTeleported() || p2.getNextWalkDirection() != null || (p2.needMasksUpdate() || needAppearenceUpdate(p2.getIndex(), p2.getAppearance().getMD5AppeareanceDataHash()))) break; skip++; } skipPlayers(stream, skip); slotFlags[playerIndex] = (byte) (slotFlags[playerIndex] | 2); } } stream.finishBitAccess(); } private void skipPlayers(OutputStream stream, int amount) { if (amount == 0) { stream.writeBits(2, 0); } else if (amount < 32) { stream.writeBits(2, 1); stream.writeBits(5, amount); } else if (amount < 256) { stream.writeBits(2, 2); stream.writeBits(8, amount); } else if (amount < 2048) { stream.writeBits(2, 3); stream.writeBits(11, amount); } } private void appendUpdateBlock(Player p, OutputStream data, boolean needAppearenceUpdate, boolean added) { OutputStream block = new OutputStream(); int maskData = 0; if (p.getNextBodyGlow() != null) { maskData |= 0x20000; applyBodyGlowMask(p, block); } //maskData |= 0x400000; //who knows // block.writeByte(4); // for (int i = 0;i < 4;i++) { // block.writeShortLE(3); // block.writeInt(523562); // } if (p.getNextSpotAnim2() != null) { maskData |= 0x200; applyGraphicsMask2(p, block); } if (added || p.getFixedFaceTile() != null || (p.getNextFaceTile() != null && p.getNextRunDirection() == null && p.getNextWalkDirection() == null)) { maskData |= 0x20; applyFaceDirectionMask(p, block); } //maskData |= 0x800000; //same as 0x400000 but resets data // block.writeByte(4); // for (int i = 0;i < 4;i++) { // block.writeShortLE(3); // block.writeInt(523562); // } //maskData |= 0x10000; //map dot edit if (p.getBodyModelRotator() != null) { maskData |= 0x100000; p.getBodyModelRotator().encodePlayer(block); } if (p.getNextForceTalk() != null) { maskData |= 0x4000; applyForceTalkMask(p, block); } //maskData |= 0x80000; //Forcechat with optional display in chatbox (nex cough?) if (p.getNextSpotAnim3() != null) { maskData |= 0x40000; applyGraphicsMask3(p, block); } //maskData |= 0x8000; //map dot edit if (!p.getNextHits().isEmpty() || !p.getNextHitBars().isEmpty()) { maskData |= 0x40; applyHitsMask(p, block); } if (needAppearenceUpdate) { maskData |= 0x1; applyAppearanceMask(p, block); } if (p.getNextAnimation() != null) { maskData |= 0x10; applyAnimationMask(p, block); } if (p.getNextFaceEntity() != -2 || (added && p.getLastFaceEntity() != -1)) { maskData |= 0x2; applyFaceEntityMask(p, block); } if (p.getTemporaryMoveType() != null) { maskData |= 0x1000; applyTemporaryMoveTypeMask(p, block); } //maskData |= 0x2000; //animation related? if (added || p.isUpdateMovementType()) { maskData |= 0x4; applyMoveTypeMask(p, block); } if (p.getNextSpotAnim4() != null) { maskData |= 0x200000; applyGraphicsMask4(p, block); } if (p.getNextForceMovement() != null) { maskData |= 0x800; applyForceMovementMask(p, block); } if (p.getNextSpotAnim1() != null) { maskData |= 0x80; applyGraphicsMask1(p, block); } if (maskData >= 256) maskData |= 0x8; if (maskData >= 65536) maskData |= 0x100; data.writeByte(maskData); if (maskData >= 256) data.writeByte(maskData >> 8); if (maskData >= 65536) data.writeByte(maskData >> 16); data.writeBytes(block.toByteArray()); } private void applyBodyGlowMask(Player p, OutputStream data) { data.writeByte(p.getNextBodyGlow().getRedAdd()); data.writeByteC(p.getNextBodyGlow().getGreenAdd()); data.write128Byte(p.getNextBodyGlow().getBlueAdd()); data.write128Byte(p.getNextBodyGlow().getScalar()); data.writeShort128(0); data.writeShort(p.getNextBodyGlow().getTime()); } private void applyForceTalkMask(Player p, OutputStream data) { data.writeString(p.getNextForceTalk().text()); } private void applyHitsMask(Player p, OutputStream data) { data.write128Byte(p.getNextHits().size()); for (Hit hit : p.getNextHits()) { boolean interactingWith = hit.interactingWith(player, p); if (hit.missed() && !interactingWith) { data.writeSmart(32766); data.writeByteC(hit.getDamage()); } else if (hit.getSoaking() != null) { data.writeSmart(32767); data.writeSmart(hit.getMark(player, p)); data.writeSmart(Utils.clampI(hit.getDamage(), 0, Short.MAX_VALUE/2)); data.writeSmart(hit.getSoaking().getMark(player, p)); data.writeSmart(Utils.clampI(hit.getSoaking().getDamage(), 0, Short.MAX_VALUE/2)); } else { data.writeSmart(hit.getMark(player, p)); data.writeSmart(Utils.clampI(hit.getDamage(), 0, Short.MAX_VALUE/2)); } data.writeSmart(hit.getDelay()); } data.writeByte(p.getNextHitBars().size()); for (HitBar bar : p.getNextHitBars()) { data.writeSmart(bar.getType()); int perc = bar.getPercentage(); int toPerc = bar.getToPercentage(); boolean display = bar.display(player); data.writeSmart(display ? perc != toPerc ? bar.getTimer() : 0 : 32767); if (display) { data.writeSmart(bar.getDelay()); data.write128Byte(perc); if (toPerc != perc) data.writeByte128(toPerc); } } } private void applyFaceEntityMask(Player p, OutputStream data) { data.writeShort128(p.getNextFaceEntity() == -2 ? p.getLastFaceEntity() : p.getNextFaceEntity()); } private void applyFaceDirectionMask(Player p, OutputStream data) { data.writeShort128(p.getFaceAngle()); // also works as face tile as dir // calced on setnextfacetile } private void applyMoveTypeMask(Player p, OutputStream data) { data.write128Byte(p.getMovementType() == Entity.MoveType.RUN ? 2 : 1); } private void applyTemporaryMoveTypeMask(Player p, OutputStream data) { data.writeByteC(p.getTemporaryMoveType().getId()); } private void applyGraphicsMask1(Player p, OutputStream data) { data.writeShortLE(p.getNextSpotAnim1().getId()); data.writeInt(p.getNextSpotAnim1().getSettingsHash()); data.writeByte128(p.getNextSpotAnim1().getSettings2Hash()); } private void applyGraphicsMask2(Player p, OutputStream data) { data.writeShort(p.getNextSpotAnim2().getId()); data.writeIntV2(p.getNextSpotAnim2().getSettingsHash()); data.write128Byte(p.getNextSpotAnim2().getSettings2Hash()); } private void applyGraphicsMask3(Player p, OutputStream data) { data.writeShortLE128(p.getNextSpotAnim3().getId()); data.writeIntV2(p.getNextSpotAnim3().getSettingsHash()); data.writeByte128(p.getNextSpotAnim3().getSettings2Hash()); } private void applyGraphicsMask4(Player p, OutputStream data) { data.writeShortLE(p.getNextSpotAnim4().getId()); data.writeIntLE(p.getNextSpotAnim4().getSettingsHash()); data.write128Byte(p.getNextSpotAnim4().getSettings2Hash()); } private void applyAnimationMask(Player p, OutputStream data) { for (int id : p.getNextAnimation().getIds()) data.writeBigSmart(id); data.writeByte(p.getNextAnimation().getSpeed()); } private void applyAppearanceMask(Player p, OutputStream data) { byte[] renderData = p.getAppearance().getAppeareanceData(); totalRenderDataSentLength += renderData.length; cachedAppearencesHashes[p.getIndex()] = p.getAppearance().getMD5AppeareanceDataHash(); data.writeByteC(renderData.length); data.writeBytes(renderData); } private void applyForceMovementMask(Player p, OutputStream data) { data.writeByteC(p.getNextForceMovement().getDiffX1()); data.write128Byte(p.getNextForceMovement().getDiffY1()); data.writeByte128(p.getNextForceMovement().getDiffX2()); data.writeByteC(p.getNextForceMovement().getDiffY2()); data.writeShortLE128(p.getNextForceMovement().getStartClientCycles()); data.writeShortLE(p.getNextForceMovement().getSpeedClientCycles()); data.writeShort128(p.getNextForceMovement().getDirection()); } public void write(OutputStream stream) { OutputStream updateBlockData = new OutputStream(); processLocalPlayers(stream, updateBlockData, true); processLocalPlayers(stream, updateBlockData, false); processOutsidePlayers(stream, updateBlockData, true); processOutsidePlayers(stream, updateBlockData, false); stream.writeBytes(updateBlockData.getBuffer(), 0, updateBlockData.getOffset()); totalRenderDataSentLength = 0; localPlayersIndexesCount = 0; outPlayersIndexesCount = 0; for (int playerIndex = 1; playerIndex < 2048; playerIndex++) { slotFlags[playerIndex] >>= 1; Player player = localPlayers[playerIndex]; if (player == null) outPlayersIndexes[outPlayersIndexesCount++] = playerIndex; else localPlayersIndexes[localPlayersIndexesCount++] = playerIndex; } } }" "package com.rs.game.model.entity.player; public class Player extends Entity { private String username; private Date dateJoined; private Map dailyAttributes; private Map weeklyAttributes; public transient int chatType; private long timePlayed = 0; private transient long timePlayedThisSession = 0; private long timeLoggedOut; private transient HashMap reflectionAnalyses = new HashMap<>(); private long docileTimer; private Brewery keldagrimBrewery; private Brewery phasmatysBrewery; private int placedCannon; private Set diangoReclaim = new HashSet<>(); private boolean slayerHelmCreation; private boolean quickBlows; private boolean broadFletching; private boolean craftROS; //ring of slay private boolean iceStrykeNoCape; private boolean aquanitesUnlocked; private DungManager dungManager; private boolean trulyHidden; public transient long tolerance = 0; public transient long idleTime = 0; public transient long dyingTime = 0; public transient long spellDelay = 0; public transient boolean disconnected = false; private transient int pvpCombatLevelThreshhold = -1; private transient String[] playerOptions = new String[10]; private transient Set sounds = new HashSet<>(); private Instance instancedArea; public transient Runnable onPacketCutsceneFinish; public void refreshChargeTimer() { addEffect(Effect.CHARGED, 600); } public void refreshMiasmicTimer(int ticks) { if (hasEffect(Effect.MIASMIC_BLOCK)) return; sendMessage(""You feel slowed down.""); addEffect(Effect.MIASMIC_BLOCK, ticks+15); addEffect(Effect.MIASMIC_SLOWDOWN, ticks); } public void addSpellDelay(int ticks) { spellDelay = ticks + World.getServerTicks(); } public boolean canCastSpell() { return spellDelay < World.getServerTicks(); } public void refreshIdleTime() { idleTime = 420000L + System.currentTimeMillis(); } public boolean isIdle() { return idleTime < System.currentTimeMillis(); } public void refreshDyingTime() { dyingTime = 10000L + System.currentTimeMillis(); } public boolean isDying() { return dyingTime > System.currentTimeMillis(); } // transient stuff private transient Session session; private transient long clientLoadedMapRegion; private transient Set mapChunksNeedInit; private transient ScreenMode screenMode; private transient int screenWidth; private transient int screenHeight; private transient Conversation conversation; private transient InterfaceManager interfaceManager; private transient HintIconsManager hintIconsManager; private transient CutsceneManager cutsceneManager; private transient Trade trade; private transient DuelRules lastDuelRules; private transient Pet pet; private VarManager varManager; private int lsp; private boolean chosenAccountType; private boolean ironMan; private int jadinkoFavor; public int soulWarsZeal; private long lastLoggedIn = 0; public int ringOfForgingCharges = 140; public int bindingNecklaceCharges = 15; private Map savingAttributes; private Map npcKills; private Map variousCounter; private Set unlockedLoyaltyRewards; private Set favoritedLoyaltyRewards; private Map toolbelt; private transient ArrayList attackedBy = new ArrayList<>(); private transient Recorder recorder; public int[] artisanOres = new int[5]; public double artisanXp = 0.0; public int artisanRep = 0; public int loyaltyPoints = 0; public ArrayList getAttackedByList() { return attackedBy; } public boolean attackedBy(String name) { for (String other : attackedBy) if (other.equals(name)) return true; return false; } public void addToAttackedBy(String name) { attackedBy.add(name); } // used for update private transient LocalPlayerUpdate localPlayerUpdate; private transient LocalNPCUpdate localNPCUpdate; private transient MoveType tempMoveType = moveType; public transient boolean updateMovementType = true; // player stages private transient boolean started; private transient boolean running; private transient boolean resting; private transient boolean canPvp; private transient boolean cantTrade; private transient long foodDelay; private transient long potionDelay; private transient long boneDelay; private transient Runnable closeInterfacesEvent; private transient Runnable closeChatboxInterfaceEvent; private transient Runnable finishConversationEvent; private transient boolean disableEquip; private transient MachineInformation machineInformation; private transient boolean castedVeng; private transient boolean castedMagicImbue; private transient boolean invulnerable; private transient double hpBoostMultiplier; private transient boolean largeSceneView; private transient String lastNpcInteractedName = null; private transient Account account; private transient boolean tileMan; private transient int tilesAvailable; private transient Set tilesUnlocked; private HabitatFeature habitatFeature; private transient int uuid; private String lastIP; private ArrayList ipAddresses; private final Appearance appearence; private final Inventory inventory; private final Equipment equipment; private final Skills skills; private final CombatDefinitions combatDefinitions; private final PrayerManager prayer; private final Bank bank; private int starter; private final ControllerManager controllerManager; private final MusicsManager musicsManager; private final EmotesManager emotesManager; private final DominionTower dominionTower; private Familiar summFamiliar; private final AuraManager auraManager; private PetManager petManager; private BossTask bossTask; private final QuestManager questManager; private MiniquestManager miniquestManager; private final TreasureTrailsManager treasureTrailsManager; private Map geOffers = new HashMap<>(); public int reaperPoints; private boolean[] wickedHoodTalismans; private boolean hasUsedOmniTalisman; private boolean hasUsedElementalTalisman; public Set herbicideSettings = new HashSet<>(); public ItemsContainer partyDeposit; private Map leprechaunStorage; private int graveStone; private boolean runBlocked; private ItemsContainer trawlerRewards; // ectofuntus public int boneType; public boolean bonesGrinded; public int unclaimedEctoTokens; public boolean hasScrollOfLife; public boolean hasScrollOfCleansing; public boolean hasScrollOfEfficiency; public boolean hasRigour; public boolean hasAugury; public boolean hasRenewalPrayer; private double runEnergy; private boolean allowChatEffects; private boolean mouseButtons; public int totalDonated; private int skullId; private boolean forceNextMapLoadRefresh; private double runeSpanPoints; private transient double bonusXpRate = 0.0; private int crystalSeedRepairs; private int tinySeedRepairs; public Tile lastEssTele; private boolean[] prayerBook; private SlayerTaskManager slayer = new SlayerTaskManager(); private TaskMonster[] taskBlocks; public int slayerPoints = 0; public int consecutiveTasks = 0; private int[] warriorPoints = new int[6]; private transient boolean cantWalk; private Map patches; public boolean isCantWalk() { return cantWalk; } public void setCantWalk(boolean cantWalk) { this.cantWalk = cantWalk; } public SlayerTaskManager getSlayer() { return slayer; } public void setSlayer(SlayerTaskManager slayer) { this.slayer = slayer; } public TaskMonster[] getBlockedTasks() { if (taskBlocks == null) taskBlocks = new TaskMonster[6]; return taskBlocks; } public boolean hasSlayerTask() { return slayer.getTask() != null; } public void blockTask(TaskMonster task) { if (getBlockedTaskNumber() == 6 || blockedTaskContains(task)) return; for (int i = 0; i < 6; i++) if (taskBlocks[i] == null) { taskBlocks[i] = task; return; } } public boolean blockedTaskContains(TaskMonster task) { if (taskBlocks == null) taskBlocks = new TaskMonster[6]; for (int i = 0; i < 6; i++) if (taskBlocks[i] != null && taskBlocks[i] == task) return true; return false; } public int getBlockedTaskNumber() { if (taskBlocks == null) taskBlocks = new TaskMonster[6]; int num = 0; for (int i = 0; i < 6; i++) if (taskBlocks[i] != null) num++; return num; } public void unblockTask(int slot) { if (taskBlocks == null) taskBlocks = new TaskMonster[6]; taskBlocks[slot] = null; } public void setSlayerPoints(int points) { slayerPoints = points; } public void addSlayerPoints(int points) { slayerPoints += points; } public void removeSlayerPoints(int points) { slayerPoints -= points; } public int getSlayerPoints() { return slayerPoints; } public int getTinyCrystalSeedRepairs() { return tinySeedRepairs; } public void incrementTinyCrystalSeedRepair() { if (tinySeedRepairs <= 0) tinySeedRepairs = 1; else tinySeedRepairs++; } public int getCrystalSeedRepairs() { return crystalSeedRepairs; } public void incrementCrystalSeedRepair() { if (crystalSeedRepairs <= 0) crystalSeedRepairs = 1; else crystalSeedRepairs++; } private int lastDate = 0; private int weeklyDate = 0; private int[] pouches; private boolean[] pouchesType; private boolean filterGame; private boolean xpLocked; private boolean yellOff; // game bar status private int publicStatus; private int clanStatus; private int tradeStatus; private int assistStatus; // Recovery ques. & ans. private String recovQuestion; private String recovAnswer; // Used for storing recent ips private Set ipList = new HashSet<>(); private Map machineMap = new HashMap<>(); // honor private int killCount, deathCount; // barrows private boolean[] killedBarrowBrothers; private int hiddenBrother; private int barrowsKillCount; private int pestPoints; // skill capes customizing private int[] maxedCapeCustomized; private int[] completionistCapeCustomized; private int summoningLeftClickOption; // objects private boolean khalphiteLairEntranceSetted; private boolean khalphiteLairSetted; // voting private int votes; private String yellColor = ""ff0000""; private String yellTitle = """"; private String title = null; private String titleColor = null; private String titleShading = null; private boolean titleAfter = false; private House house; // creates Player and saved classes public Player(Account account) { super(Tile.of(Settings.getConfig().getPlayerStartTile())); this.account = account; username = account.getUsername(); setHitpoints(100); dateJoined = Date.from(Clock.systemUTC().instant()); house = new House(); chosenAccountType = false; appearence = new Appearance(); inventory = new Inventory(); equipment = new Equipment(); skills = new Skills(); combatDefinitions = new CombatDefinitions(); prayer = new PrayerManager(); bank = new Bank(); controllerManager = new ControllerManager(); musicsManager = new MusicsManager(); emotesManager = new EmotesManager(); notes = new Notes(); dominionTower = new DominionTower(); auraManager = new AuraManager(); petManager = new PetManager(); treasureTrailsManager = new TreasureTrailsManager(); questManager = new QuestManager(); miniquestManager = new MiniquestManager(); dungManager = new DungManager(this); pouchesType = new boolean[5]; runEnergy = 100; allowChatEffects = true; mouseButtons = true; pouches = new int[5]; taskBlocks = new TaskMonster[6]; for (int i = 0; i < 6; i++) taskBlocks[i] = null; slayer = new SlayerTaskManager(); setWickedHoodTalismans(new boolean[WickedHoodRune.values().length]); resetBarrows(); SkillCapeCustomizer.resetSkillCapes(this); prayerBook = new boolean[PrayerBooks.BOOKS.length]; herbicideSettings = new HashSet<>(); ipList = new HashSet<>(); machineMap = new HashMap<>(); long creationDate = System.currentTimeMillis(); resetLodestones(); } public void init(Session session, Account account, int screenMode, int screenWidth, int screenHeight, MachineInformation machineInformation) { if (mapChunksNeedInit == null) mapChunksNeedInit = IntSets.synchronize(new IntOpenHashSet()); if (getTile() == null) setTile(Tile.of(Settings.getConfig().getPlayerStartTile())); this.session = session; this.account = account; uuid = getUsername().hashCode(); this.screenMode = ScreenMode.forId(screenMode); this.screenWidth = screenWidth; this.screenHeight = screenHeight; this.machineInformation = machineInformation; refreshIdleTime(); addSpellDelay(0); if (house == null) house = new House(); if (lodestones == null) resetLodestones(); if (dungManager == null) dungManager = new DungManager(this); if (herbicideSettings == null) herbicideSettings = new HashSet<>(); if (notes == null) notes = new Notes(); recorder = new Recorder(this); reflectionAnalyses = new HashMap<>(); attackedBy = new ArrayList<>(); interfaceManager = new InterfaceManager(this); hintIconsManager = new HintIconsManager(this); localPlayerUpdate = new LocalPlayerUpdate(this); localNPCUpdate = new LocalNPCUpdate(this); if (varManager == null) varManager = new VarManager(); varManager.setSession(session); sounds = new HashSet<>(); cutsceneManager = new CutsceneManager(this); trade = new Trade(this); // loads player on saved instances appearence.setPlayer(this); treasureTrailsManager.setPlayer(this); questManager.setPlayer(this); if (miniquestManager == null) miniquestManager = new MiniquestManager(); miniquestManager.setPlayer(this); inventory.setPlayer(this); equipment.setPlayer(this); skills.setPlayer(this); notes.setPlayer(this); house.setPlayer(this); combatDefinitions.setPlayer(this); prayer.setPlayer(this); bank.setPlayer(this); controllerManager.setPlayer(this); dungManager.setPlayer(this); musicsManager.setPlayer(this); emotesManager.setPlayer(this); dominionTower.setPlayer(this); auraManager.setPlayer(this); petManager.setPlayer(this); setFaceAngle(Utils.getAngleTo(0, -1)); tempMoveType = null; initEntity(); if (pouchesType == null) pouchesType = new boolean[5]; if (pouches.length == 4) pouches = new int[5]; if (pouchesType.length == 4) pouchesType = new boolean[5]; World.addPlayer(this); ChunkManager.updateChunks(this); Logger.info(Player.class, ""init"", ""Initiated player: "" + account.getUsername()); // Do not delete >.>, useful for security purpose. this wont waste that // much space.. if (prayerBook == null) prayerBook = new boolean[PrayerBooks.BOOKS.length]; if (ipList == null) ipList = new HashSet<>(); if (machineMap == null) machineMap = new HashMap<>(); updateMachineIPs(); } public void updateMachineIPs() { if (ipList.size() > 50) ipList.remove(new ArrayList<>(ipList).get(Utils.random(ipList.size()))); ipList.add(getLastIP()); if (machineMap.size() > 15) machineMap.remove(new ArrayList<>(machineMap.keySet()).get(Utils.random(machineMap.keySet().size()))); if (machineInformation != null) machineMap.put(machineInformation.hashCode(), machineInformation); } public boolean[] getPrayerBook() { return prayerBook; } public TreasureTrailsManager getTreasureTrailsManager() { return treasureTrailsManager; } public void setWildernessSkull() { addEffect(Effect.SKULL, Ticks.fromMinutes(30)); skullId = 0; appearence.generateAppearanceData(); } public void setFightPitsSkull() { addEffect(Effect.SKULL, Integer.MAX_VALUE); skullId = 1; appearence.generateAppearanceData(); } public void setSkullInfiniteDelay(int skullId) { addEffect(Effect.SKULL, Integer.MAX_VALUE); this.skullId = skullId; appearence.generateAppearanceData(); } public void removeSkull() { removeEffect(Effect.SKULL); appearence.generateAppearanceData(); } public boolean hasSkull() { return hasEffect(Effect.SKULL); } public void unlockLoyaltyReward(Reward reward) { if (unlockedLoyaltyRewards == null) unlockedLoyaltyRewards = new HashSet<>(); unlockedLoyaltyRewards.add(reward); } public boolean unlockedLoyaltyReward(Reward reward) { if (unlockedLoyaltyRewards == null) return false; return unlockedLoyaltyRewards.contains(reward); } public Set getUnlockedLoyaltyRewards() { return unlockedLoyaltyRewards; } public void favoriteLoyaltyReward(Reward reward) { if (favoritedLoyaltyRewards == null) favoritedLoyaltyRewards = new HashSet<>(); favoritedLoyaltyRewards.add(reward); } public void unfavoriteLoyaltyReward(Reward reward) { if (favoritedLoyaltyRewards == null) favoritedLoyaltyRewards = new HashSet<>(); favoritedLoyaltyRewards.remove(reward); } public boolean favoritedLoyaltyReward(Reward reward) { if (favoritedLoyaltyRewards == null) return false; return favoritedLoyaltyRewards.contains(reward); } public Set getFavoritedLoyaltyRewards() { return favoritedLoyaltyRewards; } public void removeDungItems() { if (hasFamiliar()) if (getFamiliar() != null) if (getFamiliar().getInventory() != null) for (Item item : getFamiliar().getInventory().array()) if (item != null) if (ItemConstants.isDungItem(item.getId())) getFamiliar().getInventory().remove(item); for (Item item : getInventory().getItems().array()) if (item != null) if (ItemConstants.isDungItem(item.getId())) getInventory().deleteItem(item); for (Item item : getBank().getContainerCopy()) if (item != null) if (ItemConstants.isDungItem(item.getId())) getBank().getItem(item.getId()).setId(995); for (Item item : getEquipment().getItemsCopy()) if (item != null) if (ItemConstants.isDungItem(item.getId())) getEquipment().deleteItem(item.getId(), 2147000000); getAppearance().generateAppearanceData(); } public void removeHouseOnlyItems() { if (hasFamiliar()) if (getFamiliar() != null) if (getFamiliar().getInventory() != null) for (Item item : getFamiliar().getInventory().array()) if (item != null) if (ItemConstants.isHouseOnlyItem(item.getId())) getFamiliar().getInventory().remove(item); for (Item item : getInventory().getItems().array()) if (item != null) if (ItemConstants.isHouseOnlyItem(item.getId())) getInventory().deleteItem(item); for (Item item : getBank().getContainerCopy()) if (item != null) if (ItemConstants.isHouseOnlyItem(item.getId())) getBank().getItem(item.getId()).setId(995); for (Item item : getEquipment().getItemsCopy()) if (item != null) if (ItemConstants.isHouseOnlyItem(item.getId())) getEquipment().deleteItem(item.getId(), 2147000000); getAppearance().generateAppearanceData(); } public void initNewChunks() { for (int chunkId : getMapChunksNeedInit()) ChunkManager.getChunk(chunkId).init(this); } // now that we inited we can start showing game public void start() { loadMapRegions(); getMapChunksNeedInit().addAll(getMapChunkIds()); started = true; Logger.info(Player.class, ""start"", ""Started player: "" + account.getUsername()); run(); if (isDead()) sendDeath(null); } public void stopAll() { stopAll(true); } public void stopAll(boolean stopWalk) { stopAll(stopWalk, true); } public void stopAll(boolean stopWalk, boolean stopInterface) { stopAll(stopWalk, stopInterface, true); } // as walk done clientsided public void stopAll(boolean stopWalk, boolean stopInterfaces, boolean stopActions) { TransformationRing.triggerDeactivation(this); setRouteEvent(null); walkRequest = null; if (stopInterfaces) closeInterfaces(); if (stopWalk) resetWalkSteps(); if (stopActions) { getActionManager().forceStop(); getInteractionManager().forceStop(); } combatDefinitions.resetSpells(false); } @Override public void reset(boolean attributes) { super.reset(attributes); refreshHitPoints(); hintIconsManager.removeAll(); skills.restoreSkills(); combatDefinitions.resetSpecialAttack(); prayer.reset(); combatDefinitions.resetSpells(true); resting = false; foodDelay = 0; potionDelay = 0; castedVeng = false; castedMagicImbue = false; setRunEnergy(100); appearence.generateAppearanceData(); } @Override public void reset() { reset(true); } public void closeInterfaces() { if (interfaceManager.containsScreenInter()) interfaceManager.removeCentralInterface(); if (interfaceManager.containsInventoryInter()) interfaceManager.removeInventoryInterface(); endConversation(); if (closeInterfacesEvent != null) { Runnable event = closeInterfacesEvent; closeInterfacesEvent = null; event.run(); } if (closeChatboxInterfaceEvent != null) { Runnable event = closeChatboxInterfaceEvent; closeChatboxInterfaceEvent = null; event.run(); } if (getInterfaceManager().topOpen(755)) setNextAnimation(new Animation(-1)); } public void abortDialogue() { getSession().writeToQueue(ServerPacket.TRIGGER_ONDIALOGABORT); } public void setClientHasntLoadedMapRegion() { clientLoadedMapRegion = World.getServerTicks() + 10; } @Override public void loadMapRegions() { if (started) docileTimer = System.currentTimeMillis(); else docileTimer = System.currentTimeMillis()-(lastLoggedIn-docileTimer); boolean wasAtDynamicRegion = isHasNearbyInstancedChunks(); super.loadMapRegions(); setClientHasntLoadedMapRegion(); if (isHasNearbyInstancedChunks()) { getPackets().sendDynamicMapRegion(!started); if (!wasAtDynamicRegion) localNPCUpdate.reset(); } else { getPackets().sendMapRegion(!started); if (wasAtDynamicRegion) localNPCUpdate.reset(); setInstancedArea(null); } forceNextMapLoadRefresh = false; } public boolean isDocile() { return (System.currentTimeMillis() - docileTimer) >= 600000L; } @Override public void processEntity() { try { if (getSession().isClosed()) finish(0); processPackets(); cutsceneManager.process(); super.processEntity(); if (hasStarted() && isIdle() && !hasRights(Rights.ADMIN) && !getNSV().getB(""idleLogImmune"")) { if (getInteractionManager().getInteraction() instanceof PlayerCombatInteraction combat) { if (!(combat.getAction().target instanceof Player)) idleLog(); } else logout(true); } if (disconnected && !finishing) finish(0); timePlayed++; timePlayedThisSession++; timeLoggedOut = System.currentTimeMillis(); if (getTickCounter() % FarmPatch.FARMING_TICK == 0) tickFarming(); if (getTickCounter() % FarmPatch.FARMING_TICK == 0) { getKeldagrimBrewery().process(); getPhasmatysBrewery().process(); } processTimePlayedTasks(); processTimedRestorations(); processMusic(); processItemDegrades(); auraManager.process(); prayer.processPrayer(); controllerManager.process(); } catch (Throwable e) { Logger.handle(Player.class, ""processEntity:Player"", e); } } private void processTimePlayedTasks() { if (timePlayed % 500 == 0) { if (getDailyI(""loyaltyTicks"") < 12) { loyaltyPoints += 175; incDailyI(""loyaltyTicks""); } else if (!getDailyB(""loyaltyNotifiedCap"")) { sendMessage(""You've reached your loyalty point cap for the day. You now have "" + Utils.formatNumber(loyaltyPoints) + "".""); setDailyB(""loyaltyNotifiedCap"", true); } } } private void processTimedRestorations() { if (getNextRunDirection() == null) { double energy = (8.0 + Math.floor(getSkills().getLevel(Constants.AGILITY) / 6.0)) / 100.0; if (isResting()) { energy = 1.68; if (MusicianKt.isNearby(this)) //TODO optimize this with its own resting variable energy = 2.28; } restoreRunEnergy(energy); } if (!isDead()) { if (getTickCounter() % 50 == 0) getCombatDefinitions().restoreSpecialAttack(); //Restore skilling stats if (getTickCounter() % 100 == 0) { final int amount = (getPrayer().active(Prayer.RAPID_RESTORE) ? 2 : 1) + (isResting() ? 1 : 0); Arrays.stream(Skills.SKILLING).forEach(skill -> restoreTick(skill, amount)); } //Restore combat stats if (getTickCounter() % (getPrayer().active(Prayer.BERSERKER) ? 115 : 100) == 0) { final int amount = (getPrayer().active(Prayer.RAPID_RESTORE) ? 2 : 1) + (isResting() ? 1 : 0); Arrays.stream(Skills.COMBAT).forEach(skill -> restoreTick(skill, amount)); } } } private void processItemDegrades() { if (inCombat() || isAttacking()) { for (int i = 0; i < Equipment.SIZE; i++) { Item item = getEquipment().getItem(i); if (item == null) continue; for (ItemDegrade d : ItemDegrade.values()) if ((d.getItemId() == item.getId() || d.getDegradedId() == item.getId()) && item.getMetaData() == null) { getEquipment().setSlot(i, new Item(d.getDegradedId() != -1 ? d.getDegradedId() : d.getItemId(), item.getAmount()).addMetaData(""combatCharges"", d.getDefaultCharges())); sendMessage(""Your "" + ItemDefinitions.getDefs(item.getId()).getName() + "" has slightly degraded!""); break; } if (item.getMetaData(""combatCharges"") != null) { item.addMetaData(""combatCharges"", item.getMetaDataI(""combatCharges"") - 1); if (item.getMetaDataI(""combatCharges"") <= 0) { ItemDegrade deg = null; for (ItemDegrade d : ItemDegrade.values()) if (d.getItemId() == item.getId() || d.getDegradedId() == item.getId() && d.getBrokenId() != -1) { deg = d; break; } if (deg != null) { if (deg.getBrokenId() == 4207) { getEquipment().deleteSlot(i); getAppearance().generateAppearanceData(); if (getInventory().hasFreeSlots()) { getInventory().addItem(4207, 1); sendMessage(""Your "" + ItemDefinitions.getDefs(deg.getItemId()).getName() + "" has reverted to a crystal seed!""); } else { World.addGroundItem(new Item(4207), Tile.of(getX(), getY(), getPlane())); sendMessage(""Your "" + ItemDefinitions.getDefs(deg.getItemId()).getName() + "" has reverted to a crystal seed and fallen to the floor!""); } break; } getEquipment().setSlot(i, new Item(deg.getBrokenId(), item.getAmount())); getAppearance().generateAppearanceData(); sendMessage(""Your "" + ItemDefinitions.getDefs(item.getId()).getName() + "" has fully degraded!""); } else { getEquipment().deleteSlot(i); getAppearance().generateAppearanceData(); sendMessage(""Your "" + ItemDefinitions.getDefs(item.getId()).getName() + "" has degraded to dust!""); } } } } } } private void processMusic() { if (!getTempAttribs().getB(""MUSIC_BREAK"") && musicsManager.musicEnded()) { getTempAttribs().setB(""MUSIC_BREAK"", true); WorldTasks.schedule(new Task() { @Override public void run() { musicsManager.nextAmbientSong(); getTempAttribs().setB(""MUSIC_BREAK"", false); } }, Utils.randomInclusive(10, 30)); } } public void restoreTick(int skill, int restore) { int currentLevel = getSkills().getLevel(skill); int normalLevel = getSkills().getLevelForXp(skill); if (currentLevel > normalLevel) getSkills().set(skill, currentLevel - 1); else if (currentLevel < normalLevel) getSkills().set(skill, Utils.clampI(currentLevel + restore, 0, normalLevel)); } public void postSync() { getInventory().processRefresh(); getVars().syncVarsToClient(); skills.updateXPDrops(); for (Sound sound : sounds) if (sound != null) getPackets().sendSound(sound); sounds.clear(); } public void tickFarming() { List toRemove = new ArrayList<>(); for (FarmPatch patch : getPatches().values()) { if (patch == null) continue; patch.tick(this); patch.updateVars(this); if (patch.needsRemove()) toRemove.add(patch.location); } for (PatchLocation p : toRemove) getPatches().remove(p); } @Override public void processReceivedHits() { super.processReceivedHits(); } @Override public boolean needMasksUpdate() { return super.needMasksUpdate() || tempMoveType != null || updateMovementType; } @Override public void processMovement() { super.processMovement(); } @Override public void resetMasks() { super.resetMasks(); tempMoveType = null; updateMovementType = false; } public void toggleRun(boolean update) { super.setRun(!getRun()); updateMovementType = true; if (update) sendRunButtonConfig(); } public void setRunHidden(boolean run) { super.setRun(run); updateMovementType = true; } @Override public void setRun(boolean run) { super.setRun(run); updateMovementType = true; sendRunButtonConfig(); } public VarManager getVars() { return varManager; } public void sendRunButtonConfig() { getVars().setVar(173, resting ? 3 : getRun() ? 1 : 0); } public void restoreRunEnergy(double energy) { if (runEnergy + energy > 100.0) runEnergy = 100.0; else runEnergy += energy; getPackets().sendRunEnergy(runEnergy); } public void drainRunEnergy(double energy) { if (getNSV().getB(""infRun"")) return; if ((runEnergy - energy) < 0.0) runEnergy = 0.0; else runEnergy -= energy; getPackets().sendRunEnergy(runEnergy); } public void run() { if (getAccount().getRights() == null) { setRights(Rights.PLAYER); LobbyCommunicator.updateRights(this); } LobbyCommunicator.addWorldPlayer(account, response -> { if (response == null || !response) forceLogout(); }); getClan(clan -> appearence.generateAppearanceData()); getGuestClan(); int updateTimer = (int) World.getTicksTillUpdate(); if (updateTimer != -1) getPackets().sendSystemUpdate(updateTimer); addIP(getSession().getIP()); lastIP = getSession().getIP(); interfaceManager.sendInterfaces(); getPackets().sendRunEnergy(runEnergy); refreshAllowChatEffects(); refreshMouseButtons(); sendRunButtonConfig(); if (!hasRights(Rights.ADMIN)) { removeDungItems(); removeHouseOnlyItems(); } sendDefaultPlayersOptions(); checkMultiArea(); inventory.init(); equipment.init(); skills.init(); combatDefinitions.init(); prayer.init(); house.init(); refreshHitPoints(); prayer.refreshPoints(); getPoison().refresh(); getVars().setVar(281, 1000); // unlock can't do this on tutorial getVars().setVar(1160, -1); // unlock summoning orb getVars().setVar(1159, 1); getVars().setVarBit(4221, 0); //unlock incubator getVars().setVarBit(1766, 1); //unlock killerwatt portal getVars().setVarBit(6471, 45); //chaos dwarf area getVars().setVarBit(532, 4); //lumbridge underground getVars().setVar(678, 3); //rfd chest updateSlayerTask(); Toolbelt.refreshToolbelt(this); questManager.unlockQuestTabOptions(); questManager.updateAllQuestStages(); miniquestManager.updateAllStages(); getPackets().sendGameBarStages(); musicsManager.init(); emotesManager.refreshListConfigs(); sendUnlockedObjectConfigs(); questManager.sendQuestPoints(); AchievementInterface.init(this); for (Item item : equipment.getItemsCopy()) if (item != null) PluginManager.handle(new ItemEquipEvent(this, item, true)); GE.updateOffers(username); if (summFamiliar != null) summFamiliar.respawn(this); else petManager.init(); running = true; updateMovementType = true; pvpCombatLevelThreshhold = -1; appearence.generateAppearanceData(); checkWasInDynamicRegion(); controllerManager.login(); // checks what to do on login after welcome //unlock robust glass getVars().setVarBit(4322, 1); //unlock ability to use elemental and catalytic runes getVars().setVarBit(5493, 1); // screen if (machineInformation != null) machineInformation.sendSuggestions(this); notes.init(); double farmingTicksMissed = Math.floor(getTicksSinceLastLogout() / FarmPatch.FARMING_TICK); if (farmingTicksMissed > 768.0) farmingTicksMissed = 768.0; if (farmingTicksMissed < 1.0) farmingTicksMissed = 0.0; for (int i = 0;i < farmingTicksMissed;i++) tickFarming(); for (FarmPatch p : getPatches().values()) if (p != null) p.updateVars(this); if (getStarter() > 0) { sendMessage(""Welcome to "" + Settings.getConfig().getServerName() + "".""); if (!Settings.getConfig().getLoginMessage().isEmpty()) sendMessage(Settings.getConfig().getLoginMessage()); processDailyTasks(); processWeeklyTasks(); } if (!isChosenAccountType()) { if (!Settings.getConfig().isDebug()) getControllerManager().startController(new TutorialIslandController()); else setStarter(1); PlayerLook.openCharacterCustomizing(this); startConversation(new GamemodeSelection(this)); } if (getUsername().startsWith(""cli_bot"")) { if (getControllerManager().isIn(TutorialIslandController.class)) { tele(Settings.getConfig().getPlayerStartTile()); getControllerManager().forceStop(); } setChosenAccountType(true); setStarter(1); } //getPackets().write(new UpdateRichPresence(""state"", ""Logged in as "" + getDisplayName())); PluginManager.handle(new LoginEvent(this)); PluginManager.handle(new EnterChunkEvent(this, getChunkId())); } private double getTicksSinceLastLogout() { if (timeLoggedOut <= 0) return 0; return (double) ((System.currentTimeMillis() - timeLoggedOut) / 600L); } public void processDailyTasks() { if (Utils.getTodayDate() != lastDate) { incrementCount(""Unique days logged in""); sendMessage(""Your dailies have been reset.""); dailyAttributes = new ConcurrentHashMap<>(); lastDate = Utils.getTodayDate(); } } public boolean containsOneItem(int... itemIds) { if (getInventory().containsOneItem(itemIds) || getEquipment().containsOneItem(itemIds)) return true; Familiar familiar = getFamiliar(); return familiar != null && ((familiar.getInventory() != null && familiar.containsOneItem(itemIds) || familiar.isFinished())); } public void processWeeklyTasks() { if (Utils.getTodayDate() >= weeklyDate) { sendMessage(""Your weekly tasks have been reset.""); weeklyAttributes = new ConcurrentHashMap<>(); weeklyDate = setLastDateToNextWednesday(); } } public int setLastDateToNextWednesday() { Calendar cal = new GregorianCalendar(); cal.setTimeZone(TimeZone.getTimeZone(""UTC"")); int daysUntilNextWednesday = (Calendar.WEDNESDAY - cal.get(Calendar.DAY_OF_WEEK) + 7) % 7; if (daysUntilNextWednesday == 0) { daysUntilNextWednesday = 7; } cal.add(Calendar.DAY_OF_MONTH, daysUntilNextWednesday); int day = cal.get(Calendar.DAY_OF_MONTH); int month = cal.get(Calendar.MONTH); return (month * 100 + day); } private void sendUnlockedObjectConfigs() { refreshKalphiteLairEntrance(); refreshKalphiteLair(); refreshLodestoneNetwork(); refreshFightKilnEntrance(); } private boolean[] lodestones = new boolean[Lodestone.values().length]; public void resetLodestones() { lodestones = new boolean[Lodestone.values().length]; lodestones[0] = true; lodestones[1] = true; } public void unlockLodestone(Lodestone stone, GameObject object) { if (lodestones[stone.ordinal()]) return; if (stone == Lodestone.BANDIT_CAMP || stone == Lodestone.LUNAR_ISLE) { sendMessage(""This lodestone doesn't respond.""); return; } if (object == null) { lodestones[stone.ordinal()] = true; refreshLodestoneNetwork(); return; } final Tile tile = object.getTile(); if (object != null) { playCutscene(cs -> { cs.camPos(object.getX()+1, object.getY()+6, 5000); cs.camLook(object.getX(), object.getY(), 0); cs.delay(2); cs.action(() -> { lodestones[stone.ordinal()] = true; refreshLodestoneNetwork(); getPackets().sendSpotAnim(new SpotAnim(3019), tile); if (stone.getAchievement() != null) getInterfaceManager().sendAchievementComplete(stone.getAchievement()); }); cs.delay(10); cs.camPosResetSoft(); }); } } public boolean unlockedLodestone(Lodestone stone) { if (stone == Lodestone.BANDIT_CAMP) return isQuestComplete(Quest.DESERT_TREASURE); if (stone == Lodestone.LUNAR_ISLE) return isQuestComplete(Quest.LUNAR_DIPLOMACY); return lodestones[stone.ordinal()]; } private void refreshLodestoneNetwork() { for (Lodestone stone : Lodestone.values()) if (stone.getConfigId() != -1 && unlockedLodestone(stone)) getVars().setVarBit(stone.getConfigId(), 1); // // unlocks bandit camp lodestone // getPackets().sendConfigByFile(358, 15); // // unlocks lunar isle lodestone // getPackets().sendConfigByFile(2448, 190); } private void refreshKalphiteLair() { if (khalphiteLairSetted) getVars().setVarBit(7263, 1); } public void setKalphiteLair() { khalphiteLairSetted = true; refreshKalphiteLair(); } public void refreshFightKilnEntrance() { if (getCounterValue(""Fight Caves clears"") > 0) getVars().setVarBit(10838, 1); } private void refreshKalphiteLairEntrance() { if (khalphiteLairEntranceSetted) getVars().setVarBit(7262, 1); } public void setKalphiteLairEntrance() { khalphiteLairEntranceSetted = true; refreshKalphiteLairEntrance(); } public boolean isKalphiteLairEntranceSetted() { return khalphiteLairEntranceSetted; } public boolean isKalphiteLairSetted() { return khalphiteLairSetted; } public void save(String key, Object value) { if (savingAttributes == null) savingAttributes = new ConcurrentHashMap<>(); savingAttributes.put(key, value); } @SuppressWarnings(""unchecked"") public T getO(String name) { if (savingAttributes == null) savingAttributes = new ConcurrentHashMap<>(); if (savingAttributes.get(name) == null) return null; return (T) savingAttributes.get(name); } public Object get(String key) { if (savingAttributes == null) savingAttributes = new ConcurrentHashMap<>(); if (savingAttributes.get(key) != null) return savingAttributes.get(key); return false; } public int getI(String key) { return getI(key, -1); } public int getI(String key, int def) { Object val = get(key); if (val == Boolean.FALSE) return def; return (int) (val instanceof Integer ? (int) val : (double) val); } public long getL(String key) { return getL(key, -1L); } public long getL(String key, long def) { Object val = get(key); if (val == Boolean.FALSE) return def; return (val instanceof Long ? (long) val : ((Double) val).longValue()); } public boolean getBool(String key) { Object val = get(key); if (val == Boolean.FALSE) return false; return (Boolean) val; } public Map getSavingAttributes() { if (savingAttributes == null) savingAttributes = new ConcurrentHashMap<>(); return savingAttributes; } public void delete(String key) { if (savingAttributes == null) savingAttributes = new ConcurrentHashMap<>(); savingAttributes.remove(key); } public int getCounterValueContaining(String npcName) { if (variousCounter == null) variousCounter = new ConcurrentHashMap<>(); int number = 0; for (String key : variousCounter.keySet()) if (key.contains(npcName) || key.contains(npcName.toLowerCase())) number += variousCounter.get(key); return number; } public int getCounterValue(String npcName) { if (variousCounter == null) variousCounter = new ConcurrentHashMap<>(); if (npcName.startsWith(""%"")) return getCounterValueContaining(npcName.replace(""%"", """")); if (variousCounter.containsKey(npcName)) return variousCounter.get(npcName); return 0; } public void incrementCount(String string) { incrementCount(string, 1); } public void incrementCount(String string, int count) { if (variousCounter == null) variousCounter = new ConcurrentHashMap<>(); variousCounter.put(string, variousCounter.getOrDefault(string, 0) + count); } public int getNumberKilled(String npcName) { if (npcKills == null) npcKills = new ConcurrentHashMap<>(); if (npcName.startsWith(""%"")) return getNumberKilledContaining(npcName.replace(""%"", """")); if (npcKills.containsKey(npcName)) return npcKills.get(npcName); return 0; } public int getNumberKilledContaining(String regex) { if (npcKills == null) npcKills = new ConcurrentHashMap<>(); int number = 0; for (String key : npcKills.keySet()) if (key.contains(regex) || key.contains(regex.toLowerCase())) number += npcKills.get(key); return number; } public Map getNPCKills() { return npcKills; } public void sendNPCKill(String string) { if (npcKills == null) npcKills = new ConcurrentHashMap<>(); npcKills.put(string, npcKills.getOrDefault(string, 0) + 1); } public void sendDefaultPlayersOptions() { setPlayerOption(""Follow"", 2); setPlayerOption(""Trade with"", 4); } @SuppressWarnings(""deprecation"") public void setPlayerOption(String option, int slot, boolean forceFirstOption) { if (playerOptions == null) playerOptions = new String[10]; playerOptions[slot-1] = option.equals(""null"") ? null : option; getPackets().sendPlayerOption(option, slot, forceFirstOption); } public void setPlayerOption(String option, int slot) { setPlayerOption(option, slot, false); } public String getPlayerOption(ClientPacket packet) { return switch (packet) { case PLAYER_OP1 -> playerOptions[0]; case PLAYER_OP2 -> playerOptions[1]; case PLAYER_OP3 -> playerOptions[2]; case PLAYER_OP4 -> playerOptions[3]; case PLAYER_OP5 -> playerOptions[4]; case PLAYER_OP6 -> playerOptions[5]; case PLAYER_OP7 -> playerOptions[6]; case PLAYER_OP8 -> playerOptions[7]; case PLAYER_OP9 -> playerOptions[8]; case PLAYER_OP10 -> playerOptions[9]; default -> ""null""; }; } @Override public void checkMultiArea() { if (!started) return; boolean isAtMultiArea = isForceMultiArea() || World.isMultiArea(getTile()); if (isAtMultiArea && !isAtMultiArea()) { setAtMultiArea(isAtMultiArea); getPackets().sendVarc(616, 1); } else if (!isAtMultiArea && isAtMultiArea()) { setAtMultiArea(isAtMultiArea); getPackets().sendVarc(616, 0); } } /** * Logs the player out. * * @param lobby: If we're logging out to the lobby. */ public void logout(boolean lobby) { if (!running) return; if (inCombat(10000) || hasBeenHit(10000)) { sendMessage(""You can't log out until 10 seconds after the end of combat.""); return; } if (getEmotesManager().isAnimating()) { sendMessage(""You can't log out while performing an emote.""); return; } if (isLocked()) { sendMessage(""You can't log out while performing an action.""); return; } if (isDead() || isDying()) return; getPackets().sendLogout(lobby); finish(); running = false; } public void forceLogout() { getPackets().sendLogout(false); running = false; realFinish(); } public void idleLog() { incrementCount(""Idle logouts""); getPackets().sendLogout(true); finish(); } private transient boolean finishing; private Notes notes; public boolean isMaxed = false; public int scPoints; @Override public void finish() { finish(0); } public void finish(final int tryCount) { disconnected = true; if (hasFinished()) return; stopAll(false, true, !(getInteractionManager().getInteraction() instanceof PlayerCombatInteraction)); if ((inCombat(10000) || hasBeenHit(10000) || getEmotesManager().isAnimating() || isLocked()) && tryCount < 6) { WorldTasks.schedule(Ticks.fromSeconds(10), () -> { try { finishing = false; if (isDead() || isDying()) finish(tryCount); else finish(tryCount + 1); } catch (Throwable e) { Logger.handle(Player.class, ""finish"", e); } }); return; } realFinish(); } public void realFinish() { getTempAttribs().setB(""realFinished"", true); if (isDead() || isDying()) return; stopAll(); cutsceneManager.logout(); controllerManager.logout(); // checks what to do on before logout for house.finish(); dungManager.finish(); running = false; if (summFamiliar != null && !summFamiliar.isFinished()) summFamiliar.finish(); else if (pet != null) pet.finish(); lastLoggedIn = System.currentTimeMillis(); setFinished(true); AccountLimiter.remove(getSession().getIP()); session.setDecoder(null); WorldDB.getPlayers().save(this, () -> { LobbyCommunicator.removeWorldPlayer(this); World.removePlayer(this); ChunkManager.updateChunks(this); WorldDB.getHighscores().save(this); Logger.info(Player.class, ""realFinish"", ""Finished Player: "" + getUsername()); }); ChunkManager.updateChunks(this); } public long getLastLoggedIn() { return lastLoggedIn; } @Override public boolean restoreHitPoints() { boolean update = super.restoreHitPoints(); int toRegen = 0; if (isResting()) toRegen += 1; if (getPrayer().active(Prayer.RAPID_HEAL)) toRegen += 1; if (getPrayer().active(Prayer.RAPID_RENEWAL)) toRegen += 4; if (getEquipment().getGlovesId() == 11133) toRegen *= 2; if (getAuraManager().isActivated(AuraManager.Aura.REGENERATION)) toRegen *= 2; if ((getHitpoints() + toRegen) > getMaxHitpoints()) toRegen = getMaxHitpoints() - getHitpoints(); if (getHitpoints() < getMaxHitpoints()) setHitpoints(getHitpoints() + toRegen); if (update || toRegen > 0) refreshHitPoints(); return update; } public void refreshHitPoints() { getVars().setVarBit(7198, Utils.clampI(getHitpoints(), 0, Short.MAX_VALUE)); } @Override public void removeHitpoints(Hit hit) { super.removeHitpoints(hit); refreshHitPoints(); } public DungManager getDungManager() { return dungManager; } public void setDungManager(DungManager dungManager) { this.dungManager = dungManager; } @Override public int getMaxHitpoints() { return skills.getLevel(Constants.HITPOINTS) * 10 + equipment.getEquipmentHpIncrease(); } public String getUsername() { return username; } public Set getIPList() { return ipList; } public int getMessageIcon() { return getRights().getCrown(); } public WorldEncoder getPackets() { try { return session.getEncoder(WorldEncoder.class); } catch(Throwable e) { System.err.println(""Error casting player's encoder to world encoder.""); return null; } } public void visualizeChunk(int chunkId) { int[] oldChunk = MapUtils.decode(Structure.CHUNK, chunkId); for (int i = 0;i < 8;i++) getPackets().sendGroundItem(new GroundItem(new Item(14486, 1), Tile.of((oldChunk[0] << 3) + i, (oldChunk[1] << 3), getPlane()))); for (int i = 0;i < 8;i++) getPackets().sendGroundItem(new GroundItem(new Item(14486, 1), Tile.of((oldChunk[0] << 3), (oldChunk[1] << 3) + i, getPlane()))); for (int i = 0;i < 8;i++) getPackets().sendGroundItem(new GroundItem(new Item(14486, 1), Tile.of((oldChunk[0] << 3) + i, (oldChunk[1] << 3) + 7, getPlane()))); for (int i = 0;i < 8;i++) getPackets().sendGroundItem(new GroundItem(new Item(14486, 1), Tile.of((oldChunk[0] << 3) + 7, (oldChunk[1] << 3) + i, getPlane()))); } public void devisualizeChunk(int chunkId) { int[] oldChunk = MapUtils.decode(Structure.CHUNK, chunkId); for (int i = 0;i < 8;i++) getPackets().removeGroundItem(new GroundItem(new Item(14486, 1), Tile.of((oldChunk[0] << 3) + i, (oldChunk[1] << 3), getPlane()))); for (int i = 0;i < 8;i++) getPackets().removeGroundItem(new GroundItem(new Item(14486, 1), Tile.of((oldChunk[0] << 3), (oldChunk[1] << 3) + i, getPlane()))); for (int i = 0;i < 8;i++) getPackets().removeGroundItem(new GroundItem(new Item(14486, 1), Tile.of((oldChunk[0] << 3) + i, (oldChunk[1] << 3) + 7, getPlane()))); for (int i = 0;i < 8;i++) getPackets().removeGroundItem(new GroundItem(new Item(14486, 1), Tile.of((oldChunk[0] << 3) + 7, (oldChunk[1] << 3) + i, getPlane()))); } public void sendOptionDialogue(Consumer options) { startConversation(new Dialogue().addOptions(options)); } public void sendOptionDialogue(String question, Consumer options) { startConversation(new Dialogue().addOptions(question, options)); } public void sendInputName(String question, InputStringEvent e) { sendInputName(question, null, e); } public void sendInputName(String question, String description, InputStringEvent e) { getTempAttribs().setO(""pluginEnterName"", e); getPackets().sendInputNameScript(question); if (description != null) getPackets().setIFText(1110, 70, description); setCloseChatboxInterfaceEvent(() -> { getTempAttribs().removeO(""pluginEnterName""); abortDialogue(); }); } public void sendInputLongText(String question, InputStringEvent e) { getTempAttribs().setO(""pluginEnterLongText"", e); getPackets().sendInputLongTextScript(question); setCloseChatboxInterfaceEvent(() -> { getTempAttribs().removeO(""pluginEnterLongText""); abortDialogue(); }); } public void sendInputInteger(String question, InputIntegerEvent e) { getTempAttribs().setO(""pluginInteger"", e); getPackets().sendInputIntegerScript(question); setCloseChatboxInterfaceEvent(() -> { if(getTempAttribs().getB(""viewingDepositBox"") && !getInterfaceManager().topOpen(11)) { getInterfaceManager().sendSubDefaults(Sub.TAB_INVENTORY, Sub.TAB_EQUIPMENT); getTempAttribs().setB(""viewingDepositBox"", false); } getTempAttribs().removeO(""pluginInteger""); abortDialogue(); }); } public void sendInputHSL(InputHSLEvent e) { getTempAttribs().setO(""pluginHSL"", e); setCloseChatboxInterfaceEvent(() -> { getTempAttribs().removeO(""pluginHSL""); abortDialogue(); }); } public void sendInputForumQFC(InputStringEvent e) { getTempAttribs().setO(""pluginQFCD"", e); setCloseChatboxInterfaceEvent(() -> { getTempAttribs().removeO(""pluginQFCD""); abortDialogue(); }); } public boolean hasStarted() { return started; } public boolean isRunning() { return running; } public String getDisplayName() { return account.getDisplayName(); } public Appearance getAppearance() { return appearence; } public Equipment getEquipment() { return equipment; } public MoveType getTemporaryMoveType() { return tempMoveType; } public void setTemporaryMoveType(MoveType temporaryMovementType) { this.tempMoveType = temporaryMovementType; } public LocalPlayerUpdate getLocalPlayerUpdate() { return localPlayerUpdate; } public LocalNPCUpdate getLocalNPCUpdate() { return localNPCUpdate; } public ScreenMode getScreenMode() { return screenMode; } public void setScreenMode(ScreenMode mode) { this.screenMode = mode; } public boolean resizeable() { return screenMode.resizeable(); } public InterfaceManager getInterfaceManager() { return interfaceManager; } public Session getSession() { return session; } public void setScreenWidth(int screenWidth) { this.screenWidth = screenWidth; } public int getScreenWidth() { return screenWidth; } public void setScreenHeight(int screenHeight) { this.screenHeight = screenHeight; } public int getScreenHeight() { return screenHeight; } public boolean clientHasLoadedMapRegion() { return clientLoadedMapRegion < World.getServerTicks(); } public void setClientHasLoadedMapRegion() { clientLoadedMapRegion = -1; } public boolean clientHasLoadedMapRegionFinished() { return clientLoadedMapRegion == -1; } public Inventory getInventory() { return inventory; } public Skills getSkills() { return skills; } public double getRunEnergy() { return runEnergy; } public void setRunEnergy(double runEnergy) { if (getNSV().getB(""infRun"")) { this.runEnergy = 100.0; getPackets().sendRunEnergy(this.runEnergy); return; } this.runEnergy = runEnergy; if (this.runEnergy < 0.0) this.runEnergy = 0.0; if (this.runEnergy > 100.0) this.runEnergy = 100.0; getPackets().sendRunEnergy(this.runEnergy); } public boolean isResting() { return resting; } public void setResting(boolean resting) { this.resting = resting; sendRunButtonConfig(); } public CombatDefinitions getCombatDefinitions() { return combatDefinitions; } @Override public double getMagePrayerMultiplier() { return 0.6; } @Override public double getRangePrayerMultiplier() { return 0.6; } @Override public double getMeleePrayerMultiplier() { return 0.6; } @Override public void handlePreHit(Hit hit) { TransformationRing.triggerDeactivation(this); if (hit.getLook() != HitLook.MELEE_DAMAGE && hit.getLook() != HitLook.RANGE_DAMAGE && hit.getLook() != HitLook.MAGIC_DAMAGE) return; if (invulnerable) { hit.setDamage(0); return; } if (hasEffect(Effect.MELEE_IMMUNE) && hit.getLook() == HitLook.MELEE_DAMAGE) { hit.setDamage(0); return; } Entity source = hit.getSource(); if (source == null) return; if (hasEffect(Effect.STAFF_OF_LIGHT_SPEC) && hit.getLook() == HitLook.MELEE_DAMAGE) { hit.soakDamage(0.5); spotAnim(2320); } if (prayer.hasPrayersOn() && hit.getDamage() != 0) if (hit.getLook() == HitLook.MAGIC_DAMAGE) { if (prayer.active(Prayer.PROTECT_MAGIC)) hit.setDamage((int) (hit.getDamage() * source.getMagePrayerMultiplier())); else if (prayer.active(Prayer.DEFLECT_MAGIC)) { int deflectedDamage = source instanceof Nex ? 0 : (int) (hit.getDamage() * 0.1); hit.setDamage((int) (hit.getDamage() * source.getMagePrayerMultiplier())); if (deflectedDamage > 0 && Math.random() < 0.6) { source.applyHit(new Hit(this, deflectedDamage, HitLook.REFLECTED_DAMAGE)); setNextSpotAnim(new SpotAnim(2228)); setNextAnimation(new Animation(12573)); } } } else if (hit.getLook() == HitLook.RANGE_DAMAGE) { if (prayer.active(Prayer.PROTECT_RANGE)) hit.setDamage((int) (hit.getDamage() * source.getRangePrayerMultiplier())); else if (prayer.active(Prayer.DEFLECT_RANGE)) { int deflectedDamage = source instanceof Nex ? 0 : (int) (hit.getDamage() * 0.1); hit.setDamage((int) (hit.getDamage() * source.getRangePrayerMultiplier())); if (deflectedDamage > 0 && Math.random() < 0.6) { source.applyHit(new Hit(this, deflectedDamage, HitLook.REFLECTED_DAMAGE)); setNextSpotAnim(new SpotAnim(2229)); setNextAnimation(new Animation(12573)); } } } else if (hit.getLook() == HitLook.MELEE_DAMAGE) if (prayer.active(Prayer.PROTECT_MELEE)) hit.setDamage((int) (hit.getDamage() * source.getMeleePrayerMultiplier())); else if (prayer.active(Prayer.DEFLECT_MELEE)) { int deflectedDamage = source instanceof Nex ? 0 : (int) (hit.getDamage() * 0.1); hit.setDamage((int) (hit.getDamage() * source.getMeleePrayerMultiplier())); if (deflectedDamage > 0 && Math.random() < 0.6) { source.applyHit(new Hit(this, deflectedDamage, HitLook.REFLECTED_DAMAGE)); setNextSpotAnim(new SpotAnim(2230)); setNextAnimation(new Animation(12573)); } } if (hit.getDamage() >= 200) { Bonus bonus = switch(hit.getLook()) { case MELEE_DAMAGE -> Bonus.ABSORB_MELEE; case RANGE_DAMAGE -> Bonus.ABSORB_RANGE; default -> Bonus.ABSORB_MAGIC; }; int reducedDamage = hit.getDamage() * combatDefinitions.getBonus(bonus) / 100; if (reducedDamage > 0) { hit.setDamage(hit.getDamage() - reducedDamage); hit.addSoaking(reducedDamage); } } if (hit.getDamage() > 0 && auraManager.isActivated(AuraManager.Aura.AEGIS) && Utils.skillSuccess(skills.getLevel(Skills.DEFENSE), 15, 128)) { hit.soakDamage(0.10); spotAnim(2180); } int shieldId = equipment.getShieldId(); if (shieldId == 13742) { if (Utils.getRandomInclusive(100) <= 70) hit.soakDamage(0.25); } else if (shieldId == 13740) { // divine int drain = (int) (Math.ceil(hit.getDamage() * 0.3) / 2); if (prayer.getPoints() >= drain) { hit.soakDamage(0.3); prayer.drainPrayer(drain); } } if (castedVeng && hit.getDamage() >= 4) { castedVeng = false; setNextForceTalk(new ForceTalk(""Taste vengeance!"")); WorldTasks.schedule(new Task() { @Override public void run() { source.applyHit(new Hit(Player.this, (int) (hit.getDamage() * 0.75), HitLook.TRUE_DAMAGE)); } }); } if (source instanceof Player p2) if (p2.prayer.hasPrayersOn()) if (p2.prayer.active(Prayer.SMITE)) { int drain = hit.getDamage() / 4; if (drain > 0) prayer.drainPrayer(drain); } else if (hit.getDamage() == 0) return; getControllerManager().processIncomingHit(hit); getAuraManager().onIncomingHit(hit); } @Override public void handlePreHitOut(Entity target, Hit hit) { if (getEquipment().fullGuthansEquipped()) if (Utils.random(4) == 0) { int heal = hit.getDamage(); if (heal > 0) if (getHitpoints() < getMaxHitpoints()) { heal(heal); target.setNextSpotAnim(new SpotAnim(398)); } } if (getPrayer().hasPrayersOn()) if (getPrayer().active(Prayer.SOUL_SPLIT)) { if (hit.getDamage() == 0) return; soundEffect(8113, true); switch(hit.getLook()) { case MELEE_DAMAGE: case RANGE_DAMAGE: case MAGIC_DAMAGE: target.sendSoulSplit(hit, this); break; default: break; } } getAuraManager().onOutgoingHit(hit); getControllerManager().processOutgoingHit(hit, target); } @Override public void handlePostHit(Hit hit) { super.handlePostHit(hit); } public void safeDeath(Tile respawnTile) { safeDeath(null, respawnTile, ""Oh dear, you are dead!"", null); } public void safeDeath(Tile respawnTile, String message, Consumer onFall) { safeDeath(null, respawnTile, message, onFall); } public void safeDeath(Tile respawnTile, Consumer onFall) { safeDeath(null, respawnTile, ""Oh dear, you are dead!"", onFall); } public void safeDeath(Entity source, Tile respawnTile, String message, Consumer onFall) { lock(); stopAll(); if (prayer.active(Prayer.RETRIBUTION)) retribution(source); if (prayer.active(Prayer.WRATH)) wrath(source); WorldTasks.scheduleTimer(0, 1, tick -> { switch(tick) { case 0 -> setNextAnimation(new Animation(836)); case 1 -> sendMessage(message); case 3 -> { reset(); tele(respawnTile); setNextAnimation(new Animation(-1)); if (onFall != null) onFall.accept(this); } case 4 -> { jingle(90); unlock(); return false; } } return true; }); } @Override public void sendDeath(final Entity source) { clearPendingTasks(); incrementCount(""Deaths""); if (prayer.hasPrayersOn() && !getTempAttribs().getB(""startedDuel"")) { if (prayer.active(Prayer.RETRIBUTION)) retribution(source); if (prayer.active(Prayer.WRATH)) wrath(source); } refreshDyingTime(); setNextAnimation(new Animation(-1)); if (!controllerManager.sendDeath()) return; lock(7); stopAll(); if (summFamiliar != null) summFamiliar.sendDeath(this); Tile lastTile = Tile.of(getTile()); if (isHasNearbyInstancedChunks()) lastTile = getRandomGraveyardTile(); final Tile deathTile = lastTile; WorldTasks.scheduleLooping(new Task() { int loop; @Override public void run() { if (loop == 0) setNextAnimation(new Animation(836)); else if (loop == 1) sendMessage(""Oh dear, you are dead!""); else if (loop == 2) { reset(); if (source instanceof Player opp && opp.hasRights(Rights.ADMIN)) tele(Settings.getConfig().getPlayerRespawnTile()); else controllerManager.startController(new DeathOfficeController(deathTile, hasSkull())); } else if (loop == 3) { setNextAnimation(new Animation(-1)); } else if (loop == 4) { jingle(90); unlock(); stop(); } loop++; } }, 0, 1); } public void retribution(Entity source) { setNextSpotAnim(new SpotAnim(437)); for (Direction dir : Direction.values()) World.sendSpotAnim(Tile.of(getX() - dir.dx, getY() - dir.dy, getPlane()), new SpotAnim(438, 20, 10, dir.id)); if (isAtMultiArea()) { for (Player player : queryNearbyPlayersByTileRange(1, player -> !player.isDead() && player.isCanPvp() && player.withinDistance(getTile(), 1) || getControllerManager().canHit(player))) player.applyHit(new Hit(this, Utils.getRandomInclusive((int) (skills.getLevelForXp(Constants.PRAYER) * 2.5)), HitLook.TRUE_DAMAGE)); for (NPC npc : queryNearbyNPCsByTileRange(1, npc -> !npc.isDead() && npc.withinDistance(this, 1) && npc.getDefinitions().hasAttackOption() && getControllerManager().canHit(npc))) npc.applyHit(new Hit(this, Utils.getRandomInclusive((int) (skills.getLevelForXp(Constants.PRAYER) * 2.5)), HitLook.TRUE_DAMAGE)); } else if (source != null && source != this && !source.isDead() && !source.hasFinished() && source.withinDistance(getTile(), 1)) source.applyHit(new Hit(this, Utils.getRandomInclusive((int) (skills.getLevelForXp(Constants.PRAYER) * 2.5)), HitLook.TRUE_DAMAGE)); } public boolean withinDistance(Player other, int distance) { if (other.trulyHidden && other != this) return false; return super.withinDistance(other.getTile(), distance); } public void wrath(Entity source) { for (Direction dir : Direction.values()) World.sendProjectile(this, Tile.of(getX() + (dir.dx *2), getY() + (dir.dy *2), getPlane()), 2261, 0, 0, 15, 0.4, 35, proj -> World.sendSpotAnim(proj.getToTile(), new SpotAnim(2260))); setNextSpotAnim(new SpotAnim(2259)); WorldTasks.schedule(() -> { if (isAtMultiArea()) { for (Player player : queryNearbyPlayersByTileRange(1, player -> !player.isDead() && player.isCanPvp() && player.withinDistance(getTile(), 2) || getControllerManager().canHit(player))) player.applyHit(new Hit(this, Utils.getRandomInclusive((skills.getLevelForXp(Constants.PRAYER) * 3)), HitLook.TRUE_DAMAGE)); for (NPC npc : queryNearbyNPCsByTileRange(1, npc -> !npc.isDead() && npc.withinDistance(this, 2) && npc.getDefinitions().hasAttackOption() && getControllerManager().canHit(npc))) npc.applyHit(new Hit(this, Utils.getRandomInclusive((skills.getLevelForXp(Constants.PRAYER) * 3)), HitLook.TRUE_DAMAGE)); } else if (source != null && source != this && !source.isDead() && !source.hasFinished() && source.withinDistance(getTile(), 2)) source.applyHit(new Hit(this, Utils.getRandomInclusive((skills.getLevelForXp(Constants.PRAYER) * 3)), HitLook.TRUE_DAMAGE)); }); } public Tile getRandomGraveyardTile() { return Tile.of(Tile.of(2900, 3537, 0), 4); } public void sendPVEItemsOnDeath(Player killer, boolean dropItems) { Integer[][] slots = GraveStone.getItemSlotsKeptOnDeath(this, true, dropItems, prayer.isProtectingItem()); sendPVEItemsOnDeath(killer, Tile.of(getTile()), true, slots); } public void sendPVEItemsOnDeath(Player killer, Tile deathTile, boolean noGravestone, Integer[][] slots) { if ((Settings.getConfig().isDebug() && !hasRights(Rights.ADMIN)) || (!Settings.getConfig().isDebug() && hasRights(Rights.ADMIN))) return; auraManager.removeAura(); Item[][] items = GraveStone.getItemsKeptOnDeath(this, slots); if (summFamiliar != null) summFamiliar.sendDeath(this); inventory.reset(); equipment.reset(); appearence.generateAppearanceData(); WorldDB.getPlayers().save(this); for (Item item : items[0]) inventory.addItem(item); for (Item item : items[1]) { if (item == null) continue; ItemDegrade deg = null; for(ItemDegrade d : ItemDegrade.values()) if (d.getDegradedId() == item.getId() || d.getItemId() == item.getId()) { deg = d; break; } if (deg != null) if (deg.getBrokenId() != -1) { item.setId(deg.getBrokenId()); item.deleteMetaData(); } else { item.setAmount(ItemDefinitions.getDefs(item.getId()).getValue()); item.setId(995); item.deleteMetaData(); } } if (items[1].length != 0) if (noGravestone) for (Item item : items[1]) World.addGroundItem(item, deathTile, killer == null ? this : killer, true, 210, (killer == null || killer == this) ? DropMethod.NORMAL : DropMethod.TURN_UNTRADEABLES_TO_COINS); else new GraveStone(this, deathTile, items[1]); } public void sendPVPItemsOnDeath(Player killer) { // if (hasRights(Rights.ADMIN) || Settings.getConfig().isDebug()) // return; if (killer != null && !killer.getUsername().equals(getUsername()) && killer.isIronMan()) killer = null; auraManager.removeAura(); CopyOnWriteArrayList containedItems = new CopyOnWriteArrayList<>(); for (int i = 0; i < 14; i++) if (equipment.getItem(i) != null && equipment.getItem(i).getId() != -1 && equipment.getItem(i).getAmount() != -1) containedItems.add(new Item(equipment.getItem(i).getId(), equipment.getItem(i).getAmount(), equipment.getItem(i).getMetaData())); for (int i = 0; i < 28; i++) if (inventory.getItem(i) != null && inventory.getItem(i).getId() != -1 && inventory.getItem(i).getAmount() != -1) containedItems.add(new Item(getInventory().getItem(i).getId(), getInventory().getItem(i).getAmount(), getInventory().getItem(i).getMetaData())); if (containedItems.isEmpty()) return; int keptAmount = hasSkull() ? 0 : 3; if (prayer.isProtectingItem()) keptAmount++; CopyOnWriteArrayList keptItems = new CopyOnWriteArrayList<>(); Item lastItem = new Item(1, 1); for (int i = 0; i < keptAmount; i++) { for (Item item : containedItems) { int price = item.getDefinitions().getValue(); if (price >= lastItem.getDefinitions().getValue()) lastItem = item; } keptItems.add(lastItem); containedItems.remove(lastItem); lastItem = new Item(1, 1); } if (summFamiliar != null) summFamiliar.sendDeath(killer); inventory.reset(); equipment.reset(); WorldDB.getPlayers().save(this); for (Item item : keptItems) if (item.getId() != 1) getInventory().addItem(item); List droppedItems = new ArrayList<>(); for (Item item : containedItems) { if (ItemConstants.isTradeable(item) || item.getId() == 24444) droppedItems.add(item); //World.addGroundItem(item, getLastTile(), killer == null ? this : killer, true, 60); else { ItemDegrade deg = null; for (ItemDegrade d : ItemDegrade.values()) { if (d.getDegradedId() == item.getId() || d.getItemId() == item.getId()) { deg = d; break; } } if (deg != null && deg.getBrokenId() != -1) { Item broken = new Item(deg.getBrokenId(), item.getAmount()); droppedItems.add((!ItemConstants.isTradeable(broken) && (killer != null && killer != this)) ? new Item(995, item.getDefinitions().getValue()) : broken); } else droppedItems.add(new Item(995, item.getDefinitions().getValue())); } } if (killer == null) { for (Item item : droppedItems) World.addGroundItem(item, getLastTile(), this, true, 60); } else { List foodItems = new ArrayList<>(); List trophyItems = new ArrayList<>(); for (Item item : droppedItems) { if (Foods.isConsumable(item) || Potions.Potion.POTS.containsKey(item.getId()) || item.getId() == 24444) foodItems.add(item); else trophyItems.add(item); } if (!trophyItems.isEmpty()) World.addGroundItem(new Item(24444, 1).addMetaData(""trophyBoneOriginator"", getDisplayName()).addMetaData(""trophyBoneItems"", trophyItems), getLastTile(), killer, true, 60); for (Item item : foodItems) World.addGroundItem(item, getLastTile(), killer, true, 60); } getAppearance().generateAppearanceData(); } public void increaseKillCount(Player killed) { killed.deathCount++; if (killed.getSession().getIP().equals(getSession().getIP())) return; killCount++; sendMessage(""You have killed "" + killed.getDisplayName() + "", you have now "" + killCount + "" kills.""); } public void increaseKillCountSafe(Player killed) { if (killed.getSession().getIP().equals(getSession().getIP())) return; killCount++; sendMessage(""You have killed "" + killed.getDisplayName() + "", you have now "" + killCount + "" kills.""); } @Override public int getSize() { return appearence.getSize(); } public boolean isCanPvp() { return canPvp; } public void setCanPvp(boolean canPvp, boolean topOption) { this.canPvp = canPvp; appearence.generateAppearanceData(); setPlayerOption(canPvp ? ""Attack"" : ""null"", 1, topOption); getPackets().sendDrawOrder(canPvp && !topOption); } public void setCanPvp(boolean canPvp) { setCanPvp(canPvp, true); } public PrayerManager getPrayer() { return prayer; } public void useStairs(Tile dest) { useStairs(-1, dest, 1, 2); } public int getQuestStage(Quest quest) { return getQuestManager().getStage(quest); } public int getMiniquestStage(Miniquest quest) { return getMiniquestManager().getStage(quest); } public void useStairs(int animId, Tile dest) { useStairs(animId, dest, 1, 2, null); } public void useStairs(int animId, final Tile dest, int useDelay, int totalDelay) { useStairs(animId, dest, useDelay, totalDelay, null); } public void promptUpDown(int emoteId, String up, Tile upTile, String down, Tile downTile) { startConversation(new Dialogue().addOptions(ops -> { ops.add(up, () -> useStairs(emoteId, upTile, 2, 3)); ops.add(down, () -> useStairs(emoteId, downTile, 2, 3)); })); } public void promptUpDown(String up, Tile upTile, String down, Tile downTile) { promptUpDown(-1, up, upTile, down, downTile); } public void handleOneWayDoor(GameObject object, int xOff, int yOff) { handleOneWayDoor(object, new GameObject(object.getId(), object.getType(), object.getRotation() + 1, object.getX(), object.getY(), object.getPlane()), xOff, yOff); } public void handleOneWayDoor(GameObject object, int replaceId) { handleOneWayDoor(object, new GameObject(replaceId, object.getType(), object.getRotation(), object.getX(), object.getY(), object.getPlane())); } public void handleOneWayDoor(GameObject object) { handleOneWayDoor(object, new GameObject(object.getId(), object.getType(), object.getRotation() + 1, object.getX(), object.getY(), object.getPlane())); } public void handleOneWayDoor(GameObject object, GameObject opened, int rotation1, int rotation2) { //TODO so broken World.spawnObjectTemporary(opened, 2); lock(2); stopAll(); if (object.getRotation() == rotation1 || object.getRotation() == rotation2) addWalkSteps(object.getX(), getY() == object.getY() ? object.getY()+1 : object.getY(), -1, false); else addWalkSteps(getX() == object.getX() ? object.getX()+1 : object.getX(), object.getY(), -1, false); } public void handleOneWayDoor(GameObject object, GameObject opened) { World.spawnObjectTemporary(opened, 2); lock(2); stopAll(); if (object.getRotation() % 2 != 0) addWalkSteps(object.getX(), getY() >= object.getY() ? object.getY() - 1 : object.getY(), -1, false); else addWalkSteps(getX() >= object.getX() ? object.getX() - 1 : object.getX(), object.getY(), -1, false); } public void useStairs(int emoteId, final Tile dest, int useDelay, int totalDelay, final String message) { useStairs(emoteId, dest, useDelay, totalDelay, message, false); } public void useStairs(int emoteId, final Tile dest, int useDelay, int totalDelay, final String message, final boolean resetAnimation) { stopAll(); lock(totalDelay); if (emoteId != -1) setNextAnimation(new Animation(emoteId)); if (useDelay == 0) tele(dest); else { WorldTasks.schedule(new Task() { @Override public void run() { if (isDead()) return; if (resetAnimation) setNextAnimation(new Animation(-1)); tele(dest); if (message != null) sendMessage(message); } }, useDelay - 1); } } public Bank getBank() { return bank; } public ControllerManager getControllerManager() { return controllerManager; } public void switchMouseButtons() { mouseButtons = !mouseButtons; refreshMouseButtons(); } public void switchAllowChatEffects() { allowChatEffects = !allowChatEffects; refreshAllowChatEffects(); } public void refreshAllowChatEffects() { getVars().setVar(171, allowChatEffects ? 0 : 1); } public void refreshMouseButtons() { getVars().setVar(170, mouseButtons ? 0 : 1); } public boolean isForceNextMapLoadRefresh() { return forceNextMapLoadRefresh; } public void setForceNextMapLoadRefresh(boolean forceNextMapLoadRefresh) { this.getMapChunkIds().clear(); this.forceNextMapLoadRefresh = forceNextMapLoadRefresh; setForceUpdateEntityRegion(true); } public void addPotionDelay(int ticks) { potionDelay = ticks + World.getServerTicks(); } public boolean canPot() { return World.getServerTicks() >= potionDelay; } public void addFoodDelay(int ticks) { foodDelay = ticks + World.getServerTicks(); } public boolean canEat() { return World.getServerTicks() >= foodDelay; } public boolean canBury() { return World.getServerTicks() >= boneDelay; } public void addBoneDelay(int ticks) { boneDelay = ticks + World.getServerTicks(); } @Override public void heal(int ammount, int extra) { super.heal(ammount, extra); refreshHitPoints(); } public MusicsManager getMusicsManager() { return musicsManager; } public HintIconsManager getHintIconsManager() { return hintIconsManager; } public boolean isCastVeng() { return castedVeng; } public void setCastVeng(boolean castVeng) { castedVeng = castVeng; } public boolean isCastMagicImbue() { return castedMagicImbue; } public void setCastMagicImbue(boolean castMagicImbue) { castedMagicImbue = castMagicImbue; } public int getKillCount() { return killCount; } public int getBarrowsKillCount() { return barrowsKillCount; } public int setBarrowsKillCount(int barrowsKillCount) { return this.barrowsKillCount = barrowsKillCount; } public int setKillCount(int killCount) { return this.killCount = killCount; } public int getDeathCount() { return deathCount; } public int setDeathCount(int deathCount) { return this.deathCount = deathCount; } public void setCloseChatboxInterfaceEvent(Runnable closeInterfacesEvent) { this.closeChatboxInterfaceEvent = closeInterfacesEvent; } public void setCloseInterfacesEvent(Runnable closeInterfacesEvent) { this.closeInterfacesEvent = closeInterfacesEvent; } public void setFinishConversationEvent(Runnable finishConversationEvent) { this.finishConversationEvent = finishConversationEvent; } public boolean[] getKilledBarrowBrothers() { return killedBarrowBrothers; } public int getKilledBarrowBrothersCount() { int count = 0; for (boolean b : killedBarrowBrothers) if (b) count++; return count; } public void setHiddenBrother(int hiddenBrother) { this.hiddenBrother = hiddenBrother; } public int getHiddenBrother() { return hiddenBrother; } public void resetBarrows() { hiddenBrother = -1; killedBarrowBrothers = new boolean[7]; barrowsKillCount = 0; } public ItemsContainer getTrawlerRewards() { return trawlerRewards; } public void setTrawlerRewards(ItemsContainer trawlerRewards) { this.trawlerRewards = trawlerRewards; } public int getVotes() { return votes; } public void setVotes(int votes) { this.votes = votes; } public String getRecovQuestion() { return recovQuestion; } public void setRecovQuestion(String recovQuestion) { this.recovQuestion = recovQuestion; } public String getRecovAnswer() { return recovAnswer; } public void setRecovAnswer(String recovAnswer) { this.recovAnswer = recovAnswer; } public boolean[] getPouchesType() { return pouchesType; } public int[] getPouches() { return pouches; } public EmotesManager getEmotesManager() { return emotesManager; } public String getLastIP() { return lastIP; } public String getLastHostname() { InetAddress addr; try { addr = InetAddress.getByName(getLastIP()); String hostname = addr.getHostName(); return hostname; } catch (UnknownHostException e) { e.printStackTrace(); } return null; } public void setPestPoints(int pestPoints) { this.pestPoints = pestPoints; } public int getPestPoints() { return pestPoints; } public boolean isUpdateMovementType() { return updateMovementType; } public CutsceneManager getCutsceneManager() { return cutsceneManager; } public void sendPublicChatMessage(PublicChatMessage message) { for (Player p : queryNearbyPlayersByTileRange(16, p -> p.getLocalPlayerUpdate().getLocalPlayers()[getIndex()] != null)) p.getPackets().sendPublicMessage(this, message); } public int[] getCompletionistCapeCustomized() { return completionistCapeCustomized; } public void setCompletionistCapeCustomized(int[] skillcapeCustomized) { completionistCapeCustomized = skillcapeCustomized; } public int[] getMaxedCapeCustomized() { return maxedCapeCustomized; } public void setMaxedCapeCustomized(int[] maxedCapeCustomized) { this.maxedCapeCustomized = maxedCapeCustomized; } public void setSkullId(int skullId) { this.skullId = skullId; } public int getSkullId() { return skullId; } public boolean isFilterGame() { return filterGame; } public void setFilterGame(boolean filterGame) { this.filterGame = filterGame; } public DominionTower getDominionTower() { return dominionTower; } public Trade getTrade() { return trade; } public void setProtectionPrayBlock(int ticks) { getTempAttribs().setL(""protPrayBlock"", World.getServerTicks() + ticks); if (ticks > 0) prayer.closePrayers(Prayer.PROTECT_MAGIC, Prayer.PROTECT_MELEE, Prayer.PROTECT_RANGE, Prayer.PROTECT_SUMMONING, Prayer.DEFLECT_MAGIC, Prayer.DEFLECT_MELEE, Prayer.DEFLECT_RANGE, Prayer.DEFLECT_SUMMONING); } public boolean isProtectionPrayBlocked() { return World.getServerTicks() < getTempAttribs().getL(""protPrayBlock""); } public Familiar getFamiliar() { return summFamiliar; } public Pouch getFamiliarPouch() { if (summFamiliar == null) return null; return summFamiliar.getPouch(); } public void setFamiliar(Familiar familiar) { this.summFamiliar = familiar; } public int getSummoningLeftClickOption() { return summoningLeftClickOption; } public void setSummoningLeftClickOption(int summoningLeftClickOption) { this.summoningLeftClickOption = summoningLeftClickOption; } public AuraManager getAuraManager() { return auraManager; } public String getPronoun(String male, String female) { return (getAppearance().isMale() ? male : female); } public MoveType getMovementType() { return moveType; } public void setDisableEquip(boolean equip) { disableEquip = equip; } public boolean isEquipDisabled() { return disableEquip; } public int getPublicStatus() { return publicStatus; } public void setPublicStatus(int publicStatus) { this.publicStatus = publicStatus; } public int getClanStatus() { return clanStatus; } public void setClanStatus(int clanStatus) { this.clanStatus = clanStatus; } public int getTradeStatus() { return tradeStatus; } public void setTradeStatus(int tradeStatus) { this.tradeStatus = tradeStatus; } public int getAssistStatus() { return assistStatus; } public void setAssistStatus(int assistStatus) { this.assistStatus = assistStatus; } public Notes getNotes() { return notes; } public boolean isCantTrade() { return cantTrade; } public void setCantTrade(boolean canTrade) { cantTrade = canTrade; } public String getYellColor() { return yellColor; } public void setYellColor(String yellColor) { this.yellColor = yellColor; } /** * Gets the pet. * * @return The pet. */ public Pet getPet() { return pet; } /** * Sets the pet. * * @param pet * The pet to set. */ public void setPet(Pet pet) { this.pet = pet; } /** * Gets the petManager. * * @return The petManager. */ public PetManager getPetManager() { return petManager; } /** * Sets the petManager. * * @param petManager * The petManager to set. */ public void setPetManager(PetManager petManager) { this.petManager = petManager; } public boolean isXpLocked() { return xpLocked; } public void setXpLocked(boolean locked) { xpLocked = locked; } public boolean isYellOff() { return yellOff; } public void setYellOff(boolean yellOff) { this.yellOff = yellOff; } public void setInvulnerable(boolean invulnerable) { this.invulnerable = invulnerable; } public double getHpBoostMultiplier() { return hpBoostMultiplier; } public void setHpBoostMultiplier(double hpBoostMultiplier) { this.hpBoostMultiplier = hpBoostMultiplier; } public boolean hasLargeSceneView() { return largeSceneView; } public void setLargeSceneView(boolean largeSceneView) { this.largeSceneView = largeSceneView; } public double getRuneSpanPoints() { return runeSpanPoints; } public void setRuneSpanPoint(double runeSpanPoints) { this.runeSpanPoints = runeSpanPoints; } public void addRunespanPoints(double points) { runeSpanPoints += points; } public void removeRunespanPoints(double points) { runeSpanPoints -= points; if (runeSpanPoints < 0) runeSpanPoints = 0; } public DuelRules getLastDuelRules() { return lastDuelRules; } public void setLastDuelRules(DuelRules duelRules) { lastDuelRules = duelRules; } public int getStarter() { return starter; } public void setStarter(int starter) { this.starter = starter; } public void ladder(final Tile toTile) { setNextAnimation(new Animation(828)); getTasks().schedule(1, () -> tele(toTile)); } public void giveStarter() { getBank().clear(); getEquipment().reset(); getInventory().reset(); setStarter(1); getBank().addItem(new Item(995, 25), false); for (Item item : Settings.getConfig().getStartItems()) getInventory().addItem(item); sendMessage(""Welcome to "" + Settings.getConfig().getServerName() + "".""); if (!Settings.getConfig().getLoginMessage().isEmpty()) sendMessage(Settings.getConfig().getLoginMessage()); getAppearance().generateAppearanceData(); } public boolean hasFamiliar() { return summFamiliar != null; } public double getBonusXpRate() { return bonusXpRate; } public void setBonusXpRate(double bonusXpRate) { this.bonusXpRate = bonusXpRate; } public String getTitle() { return title; } public void setTitle(String title) { this.title = title; } public void clearTitle() { setTitleAfter(false); setTitle(null); setTitleColor(null); setTitleShading(null); getAppearance().setTitle(0); getAppearance().generateAppearanceData(); } public void clearCustomTitle() { setTitleAfter(false); setTitle(null); setTitleColor(null); setTitleShading(null); } public String getTitleColor() { return titleColor; } public void setTitleColor(String titleColor) { this.titleColor = titleColor; } public String getTitleShading() { return titleShading; } public void setTitleShading(String titleShading) { this.titleShading = titleShading; } public boolean isTitleAfter() { return titleAfter; } public void setTitleAfter(boolean titleAfter) { this.titleAfter = titleAfter; } public String getLastNpcInteractedName() { return lastNpcInteractedName; } public void setLastNpcInteractedName(String lastNpcInteractedName) { this.lastNpcInteractedName = lastNpcInteractedName; } public boolean checkCompRequirements(boolean trimmed) { if (!getSkills().isMaxed(true)) return false; if (getCounterValue(""Fight Kiln clears"") <= 0 && !Settings.getConfig().isDebug()) { sendMessage(""You need to have completed the fight kiln at least once.""); return false; } if (getNumberKilled(""Queen Black Dragon"") > 0 && !Settings.getConfig().isDebug()) { sendMessage(""You need to have killed the Queen black dragon at least once.""); return false; } if (getDominionTower().getKilledBossesCount() < 500 && !Settings.getConfig().isDebug()) { sendMessage(""You need to have killed 500 bosses in the dominion tower.""); return false; } if (trimmed) { } return true; } public void refreshForinthry() { addEffect(Effect.REV_IMMUNE, 100); addEffect(Effect.REV_AGGRO_IMMUNE, 6000); sendMessage(""You will not be harmed by revenants for 1 minute.""); sendMessage(""Revenants will have no aggression towards you for one hour.""); } public long getTicksSinceLastAction() { return recorder.getTicksSinceLastAction(); } public void sendGodwarsKill(NPC npc) { boolean dropKey = Utils.getRandomInclusive(500) <= 10 && npc.getDefinitions().combatLevel <= 134; if (npc.getId() >= 6247 && npc.getId() <= 6259) { ((GodwarsController) getControllerManager().getController()).sendKill(GodwarsController.SARADOMIN); if (dropKey) World.addGroundItem(new Item(20124, 1), Tile.of(npc.getCoordFaceX(npc.getSize()), npc.getCoordFaceY(npc.getSize()), npc.getPlane()), this, false, 60); return; } if (npc.getId() >= 6260 && npc.getId() <= 6283) { ((GodwarsController) getControllerManager().getController()).sendKill(GodwarsController.BANDOS); if (dropKey) World.addGroundItem(new Item(20122, 1), Tile.of(npc.getCoordFaceX(npc.getSize()), npc.getCoordFaceY(npc.getSize()), npc.getPlane()), this, false, 60); return; } if (npc.getId() >= 6222 && npc.getId() <= 6246) { ((GodwarsController) getControllerManager().getController()).sendKill(GodwarsController.ARMADYL); if (dropKey) World.addGroundItem(new Item(20121, 1), Tile.of(npc.getCoordFaceX(npc.getSize()), npc.getCoordFaceY(npc.getSize()), npc.getPlane()), this, false, 60); return; } if (npc.getId() >= 6203 && npc.getId() <= 6221) { ((GodwarsController) getControllerManager().getController()).sendKill(GodwarsController.ZAMORAK); if (dropKey) World.addGroundItem(new Item(20123, 1), Tile.of(npc.getCoordFaceX(npc.getSize()), npc.getCoordFaceY(npc.getSize()), npc.getPlane()), this, false, 60); return; } if (npc.getId() >= 13447 && npc.getId() <= 13459) { ((GodwarsController) getControllerManager().getController()).sendKill(GodwarsController.ZAROS); } } public void openBook(Book book) { book.open(this); } public void useLadder(Tile tile) { useLadder(828, tile); } public void updateSlayerTask() { if (getSlayer().getTask() != null) getVars().setVar(394, getSlayer().getTask().getMonster().getEnumId()); else getVars().setVar(394, 0); } public void useLadder(int anim, final Tile tile) { lock(2); anim(anim); getTasks().schedule(1, () -> tele(tile)); } public void sendMessage(String mes, boolean canBeFiltered) { getPackets().sendGameMessage(mes, canBeFiltered); } public void sendMessage(String mes) { sendMessage(mes, false); } public void sendMessage(MessageType type, String message) { getPackets().sendMessage(type, message, null); } public void sendMessage(String... mes) { StringBuilder text = new StringBuilder(); for (String str : mes) text.append(str).append(""
""); getPackets().sendGameMessage(text.toString()); } public Date getDateJoined() { return dateJoined; } public void setDateJoined(Date dateJoined) { this.dateJoined = dateJoined; } public QuestManager getQuestManager() { return questManager; } public MiniquestManager getMiniquestManager() { return miniquestManager; } public boolean isSlayerHelmCreation() { return slayerHelmCreation; } public void setSlayerHelmCreation(boolean slayerHelmCreation) { this.slayerHelmCreation = slayerHelmCreation; } public boolean hasLearnedQuickBlows() { return quickBlows; } public void setHasLearnedQuickBlows(boolean slayerHelmCreation) { quickBlows = slayerHelmCreation; } public boolean hasYellTitle() { return getYellTitle() != null && !getYellTitle().isEmpty(); } public String getYellTitle() { return yellTitle; } public void setYellTitle(String yellTitle) { this.yellTitle = yellTitle; } public int getGraveStone() { return graveStone; } public void setGraveStone(int graveStone) { this.graveStone = graveStone; } public boolean isIronMan() { return ironMan; } public Map getDailyAttributes() { if (dailyAttributes == null) dailyAttributes = new ConcurrentHashMap<>(); return dailyAttributes; } public void setDailyI(String name, int value) { getDailyAttributes().put(""dailyI""+name, value); } public void setDailyB(String name, boolean value) { getDailyAttributes().put(""dailyB""+name, value); } public void setDailyL(String name, long value) { getDailyAttributes().put(""dailyL""+name, value); } public boolean getDailyB(String name) { if (getDailyAttributes().get(""dailyB""+name) == null) return false; return (Boolean) getDailyAttributes().get(""dailyB""+name); } public int getDailySubI(String name, int sub) { return sub - getDailyI(name); } public int getDailyI(String name, int def) { if (getDailyAttributes().get(""dailyI""+name) == null) return def; if (getDailyAttributes().get(""dailyI""+name) != null && getDailyAttributes().get(""dailyI""+name) instanceof Integer) return (int) getDailyAttributes().get(""dailyI""+name); return (int) Math.floor(((double) getDailyAttributes().get(""dailyI""+name))); } public int getDailyI(String name) { return getDailyI(name, 0); } public long getDailyL(String name) { if (getDailyAttributes().get(""dailyL""+name) == null) return 0; if (getDailyAttributes().get(""dailyI""+name) != null && getDailyAttributes().get(""dailyI""+name) instanceof Long) return (long) getDailyAttributes().get(""dailyI""+name); return (long) Math.floor(((double) getDailyAttributes().get(""dailyI""+name))); } public void incDailyI(String name) { int newVal = getDailyI(name) + 1; setDailyI(name, newVal); } public Map getWeeklyAttributes() { if (weeklyAttributes == null) weeklyAttributes = new ConcurrentHashMap<>(); return weeklyAttributes; } public void setWeeklyI(String name, int value) { getWeeklyAttributes().put(""weeklyI""+name, value); } public void incWeeklyI(String name) { int newVal = getWeeklyI(name) + 1; setWeeklyI(name, newVal); } public void incWeeklyI(String name, int i) { int newVal = getWeeklyI(name) + i; setWeeklyI(name, newVal); } public int getWeeklyI(String name) { return getWeeklyI(name, 0); } public int getWeeklyI(String name, int def) { if (getWeeklyAttributes().get(""weeklyI""+name) == null) return def; if (getWeeklyAttributes().get(""weeklyI""+name) != null && getWeeklyAttributes().get(""weeklyI""+name) instanceof Integer) return (int) getWeeklyAttributes().get(""weeklyI""+name); return (int) Math.floor(((double) getWeeklyAttributes().get(""weeklyI""+name))); } public void setIronMan(boolean ironMan) { this.ironMan = ironMan; if (ironMan) { setTitle(""Ironman""); setTitleColor(""FF0000""); setTitleShading(""000000""); } } public void applyAccountTitle() { if (ironMan) { setTitle(""Ironman""); setTitleColor(""FF0000""); setTitleShading(""000000""); } getAppearance().generateAppearanceData(); } public boolean isChosenAccountType() { return chosenAccountType; } public void setChosenAccountType(boolean chosenAccountType) { this.chosenAccountType = chosenAccountType; } public boolean getUsedOmniTalisman() { return hasUsedOmniTalisman; } public boolean getUsedElementalTalisman() { return hasUsedElementalTalisman; } public void setUsedOmniTalisman(boolean bool) { hasUsedOmniTalisman = bool; } public void setUsedElementalTalisman(boolean bool) { hasUsedElementalTalisman = bool; } public boolean[] getWickedHoodTalismans() { return wickedHoodTalismans; } public void setWickedHoodTalismans(boolean[] wickedHoodTalismans) { this.wickedHoodTalismans = wickedHoodTalismans; } public int getLastDate() { return lastDate; } public void setLastDate(int lastDate) { this.lastDate = lastDate; } public House getHouse() { return house; } public void setHouse(House house) { this.house = house; } public boolean hasBossTask() { return bossTask != null; } public BossTask getBossTask() { return bossTask; } public void setBossTask(BossTask bossTask) { this.bossTask = bossTask; } public void simpleDialogue(String... message) { startConversation(new Dialogue().addSimple(message)); } public void npcDialogue(int npcId, HeadE emote, String message) { startConversation(new Dialogue().addNPC(npcId, emote, message)); } public void npcDialogue(NPC npc, HeadE emote, String message) { startConversation(new Dialogue().addNPC(npc, emote, message)); } public void itemDialogue(int itemId, String message) { startConversation(new Dialogue().addItem(itemId, message)); } public void playerDialogue(HeadE emote, String message) { startConversation(new Dialogue().addPlayer(emote, message)); } public ArrayList getNearbyFCMembers(NPC npc) { ArrayList eligible = new ArrayList<>(); FCData fc = FCManager.getFCData(getSocial().getCurrentFriendsChat()); if (fc == null) { sendMessage(""Error loading active friend's chat. Could not lootshare.""); eligible.add(this); return eligible; } for (Player player : World.getPlayersInChunkRange(npc.getChunkId(), 4)) { if (!player.isRunning() || !player.isLootSharing() || !fc.getUsernames().contains(player.getUsername())) continue; if (fc.getRank(player.getAccount()).ordinal() >= fc.getSettings().getRankToLS().ordinal()) //TODO friend rank may need to be coded differently? eligible.add(player); } return eligible; } public boolean isLootSharing() { return getNSV().getB(""lootShare""); } public void refreshLootShare() { if (isLootSharing()) getVars().setVarBit(4071, 1); else getVars().setVarBit(4071, 0); getVars().setVarBit(4072, 0); } public void toggleLootShare() { if (getAccount().getSocial().getCurrentFriendsChat() != null) { if (isLootSharing()) getNSV().removeB(""lootShare""); else getNSV().setB(""lootShare"", true); if (isLootSharing()) sendMessage(""You are now lootsharing.""); else sendMessage(""You are no longer lootsharing.""); refreshLootShare(); } else { sendMessage(""You aren't currently in a friends chat.""); getVars().setVarBit(4072, 0); } } public void fadeScreen(Runnable runnable) { FadingScreen.fade(this, runnable); } public void addIP(String ip) { if (ipAddresses == null) ipAddresses = new ArrayList<>(); if (!ipAddresses.contains(ip)) ipAddresses.add(ip); } public ArrayList getIpAddresses() { if (ipAddresses == null) ipAddresses = new ArrayList<>(); return ipAddresses; } public int getXInScene() { return getXInScene(getSceneBaseChunkId()); } public int getYInScene() { return getYInScene(getSceneBaseChunkId()); } public String getFormattedTitle() { if (title == null && appearence.getTitle() == 0) return null; if (title == null) return EnumDefinitions.getEnum(appearence.isMale() ? 1093 : 3872).getStringValue(appearence.getTitle()); String formTitle = title; if (getTitleShading() != null) formTitle = """" + formTitle; if (getTitleColor() != null) formTitle = """" + formTitle; formTitle = formTitle + "" ""; return formTitle; } public boolean containsItem(int id) { return getInventory().containsItem(id, 1) || getEquipment().containsOneItem(id) || getBank().containsItem(id, 1); } public boolean containsAnyItems(int... ids) { for (int id : ids) if (containsItem(id)) return true; return false; } public void startConversation(com.rs.engine.dialogue.Dialogue dialogue) { startConversation(new Conversation(dialogue.finish())); } public boolean startConversation(Conversation conversation) { if (conversation.getCurrent() == null) return false; conversation.setPlayer(this); if (!conversation.isCreated()) conversation.create(); this.conversation = conversation; conversation.start(); return true; } public void endConversation() { conversation = null; if (getInterfaceManager().containsChatBoxInter()) getInterfaceManager().closeChatBoxInterface(); if (finishConversationEvent != null) { Runnable event = finishConversationEvent; finishConversationEvent = null; event.run(); } } public Conversation getConversation() { return conversation; } public void sm(String string) { sendMessage(string); } @Override public boolean canMove(Direction dir) { if (!getControllerManager().canMove(dir)) return false; if (tileMan) { if (tilesUnlocked == null) { tilesUnlocked = new HashSet<>(); tilesAvailable = 50; } int tileHash = getTile().transform(dir.dx, dir.dy).getTileHash(); if (!tilesUnlocked.contains(tileHash)) { if (tilesAvailable <= 0) return false; tilesAvailable--; tilesUnlocked.add(tileHash); markTile(Tile.of(tileHash)); } } return true; } public void markTile(Tile tile) { getPackets().sendAddObject(new GameObject(21777, ObjectType.GROUND_DECORATION, 0, tile)); //model 4162 = orange square //model 2636 = white dot? } public void updateTilemanTiles() { for (int i : tilesUnlocked) { Tile tile = Tile.of(i); if (Utils.getDistance(getTile(), tile) < 64) markTile(tile); } } @Override public int hashCode() { return uuid; } @Override public boolean equals(Object other) { if (other instanceof Player p) return p.hashCode() == hashCode(); return false; } public double getWeight() { return inventory.getInventoryWeight() + equipment.getEquipmentWeight(); } public boolean hasWickedHoodTalisman(WickedHoodRune rune) { return wickedHoodTalismans[rune.ordinal()]; } public ReflectionAnalysis getReflectionAnalysis(int id) { return reflectionAnalyses.get(id); } public void queueReflectionAnalysis(ReflectionAnalysis reflectionCheck) { if (!reflectionCheck.isBuilt()) throw new RuntimeException(""Cannot queue an unbuilt reflection analysis.""); reflectionAnalyses.put(reflectionCheck.getId(), reflectionCheck); getSession().writeToQueue(new ReflectionCheckRequest(reflectionCheck.getChecks())); } public void unlockWickedHoodRune(WickedHoodRune rune) { wickedHoodTalismans[rune.ordinal()] = true; } public boolean iceStrykeNoCape() { return iceStrykeNoCape; } public boolean aquanitesUnlocked() { return aquanitesUnlocked; } public void setIceStrykeNoCape(boolean unlocked) { iceStrykeNoCape = unlocked; } public void setAquanitesUnlocked(boolean unlocked) { aquanitesUnlocked = unlocked; } public boolean isBroadFletching() { return broadFletching; } public boolean hasCraftROS() { return craftROS; } public void setBroadFletching(boolean broadFletching) { this.broadFletching = broadFletching; } public void setCraftROS(boolean canCraftROS) { craftROS = canCraftROS; } public int getJadinkoFavor() { return jadinkoFavor; } public Map getToolbelt() { return toolbelt; } public void processPackets() { Packet packet; while ((packet = session.getPacketQueue().poll()) != null) { //Logger.trace(Player.class, ""processPackets"", ""Packet processed: "" + packet.getOpcode()); if (hasStarted() && packet.getOpcode() != ClientPacket.IF_CONTINUE && packet.getOpcode() != ClientPacket.IF_OP1 && !isChosenAccountType()) continue; PacketHandler handler = PacketHandlers.getHandler(packet.getOpcode()); if (handler != null) handler.handle(this, packet); } } public Item getItemWithPlayer(int id) { Item item = getItemFromInv(id); if (item == null) item = getItemFromEquip(id); return item; } public Item getItemFromEquip(int id) { return getEquipment().getItemById(id); } public Item getItemFromInv(int id) { return getInventory().getItemById(id); } public void clearToolbelt() { toolbelt.clear(); } public boolean addToolbelt(int itemId) { if (toolbelt == null) toolbelt = new HashMap<>(); Tools tool = Tools.forId(itemId); if (tool == null) return false; if (toolbelt.get(tool) != null && toolbelt.get(tool) >= tool.getValue(itemId)) { sendMessage(""You already have this tool on your belt.""); return false; } toolbelt.put(tool, tool.getValue(itemId)); sendMessage(""You add the "" + ItemDefinitions.getDefs(itemId).name + "" to your toolbelt.""); return true; } public boolean containsTool(int itemId) { if (toolbelt == null) return false; Tools tool = Tools.forId(itemId); if (tool == null) return false; return tool.contains(getToolValue(tool), itemId); } public int getToolValue(Tools tool) { if ((toolbelt == null) || (toolbelt.get(tool) == null)) return 0; return toolbelt.get(tool); } public void setJadinkoFavor(int jadinkoFavor) { this.jadinkoFavor = jadinkoFavor; } public void addJadinkoFavor(int amount) { jadinkoFavor += amount; if (jadinkoFavor > 2000) jadinkoFavor = 2000; } public void removeJadinkoFavor(int amount) { jadinkoFavor -= amount; if (jadinkoFavor < 0) jadinkoFavor = 0; } public boolean isOnTask(TaskMonster monster) { return getSlayer().getTask() != null && getSlayer().getTask().getMonster() == monster; } public void addWalkSteps(Tile toTile, int maxSteps, boolean clip) { addWalkSteps(toTile.getX(), toTile.getY(), maxSteps, clip); } public void passThrough(Tile tile) { final boolean running = getRun(); setRunHidden(false); lock(5); addWalkSteps(tile.getX(), tile.getY(), 3, false); getTasks().schedule(3, () -> { setRunHidden(running); unlock(); }); } public int[] getWarriorPoints() { if (warriorPoints == null || warriorPoints.length != 6) warriorPoints = new int[6]; return warriorPoints; } public void setWarriorPoints(int index, int pointsDifference) { if (warriorPoints == null || warriorPoints.length != 6) warriorPoints = new int[6]; warriorPoints[index] += pointsDifference; if (warriorPoints[index] < 0) { Controller controller = getControllerManager().getController(); if (controller == null || !(controller instanceof WarriorsGuild guild)) return; guild.inCyclopse = false; tele(WarriorsGuild.CYCLOPS_LOBBY); warriorPoints[index] = 0; } else if (warriorPoints[index] > 65535) warriorPoints[index] = 65535; refreshWarriorPoints(index); } public void refreshWarriorPoints(int index) { if (warriorPoints == null || warriorPoints.length != 6) warriorPoints = new int[6]; getVars().setVarBit(index + 8662, warriorPoints[index]); } public Brewery getKeldagrimBrewery() { if (keldagrimBrewery == null) keldagrimBrewery = new Brewery(true); keldagrimBrewery.setPlayer(this); return keldagrimBrewery; } public Brewery getPhasmatysBrewery() { if (phasmatysBrewery == null) phasmatysBrewery = new Brewery(false); phasmatysBrewery.setPlayer(this); return phasmatysBrewery; } public boolean isRunBlocked() { return runBlocked; } public void blockRun() { runBlocked = true; } public void unblockRun() { runBlocked = false; } public Set getDiangoReclaim() { if (diangoReclaim == null) diangoReclaim = new HashSet<>(); return diangoReclaim; } public void addDiangoReclaimItem(int itemId) { if (diangoReclaim == null) diangoReclaim = new HashSet<>(); diangoReclaim.add(itemId); } public int getPlacedCannon() { return placedCannon; } public void setPlacedCannon(int placedCannon) { this.placedCannon = placedCannon; } public HabitatFeature getHabitatFeature() { return habitatFeature; } public Clan getClan() { return ClansManager.getClan(getAccount().getSocial().getClanName()); } public void getClan(Consumer cb) { ClansManager.getClan(getAccount().getSocial().getClanName(), cb); } public Clan getGuestClan() { return ClansManager.getClan(getAccount().getSocial().getGuestedClanChat()); } public void getGuestClan(Consumer cb) { ClansManager.getClan(getAccount().getSocial().getGuestedClanChat(), cb); } public void setHabitatFeature(HabitatFeature habitatFeature) { getVars().setVarBit(8354, habitatFeature == null ? 0 : habitatFeature.val); this.habitatFeature = habitatFeature; } public boolean hasRights(Rights rights) { return getAccount().hasRights(rights); } public Rights getRights() { return getAccount().getRights(); } public void setRights(Rights staffRights) { getAccount().setRights(staffRights); LobbyCommunicator.updateRights(this); } public Map getPatches() { if (patches == null) patches = new HashMap<>(); return patches; } public boolean isGrowing(PatchLocation loc, ProduceType produce) { FarmPatch patch = getPatch(loc); if (patch == null) return produce == null; if (produce != null) return patch.seed != null && patch.seed == produce; return patch.seed == null; } public FarmPatch getPatch(PatchLocation loc) { return getPatches().get(loc); } public void putPatch(FarmPatch patch) { getPatches().put(patch.location, patch); } public void clearPatch(PatchLocation loc) { getPatches().remove(loc); } public long getTimePlayed() { return timePlayed; } public long getTimePlayedThisSession() { return timePlayedThisSession; } public Map getLeprechaunStorage() { if (leprechaunStorage == null) leprechaunStorage = new HashMap<>(); return leprechaunStorage; } public int getNumInLeprechaun(StorableItem item) { return leprechaunStorage.get(item) == null ? 0 : leprechaunStorage.get(item).getAmount(); } public void storeLeprechaunItem(StorableItem item, int itemId, int amount) { Item curr = leprechaunStorage.get(item); if (curr == null) { if (amount > item.maxAmount) amount = item.maxAmount; if (amount > getInventory().getNumberOf(itemId)) amount = getInventory().getNumberOf(itemId); if (amount <= 0) return; curr = new Item(itemId, amount); getInventory().deleteItem(itemId, amount); } else { if ((curr.getAmount()+amount) > item.maxAmount) amount = item.maxAmount - curr.getAmount(); if (amount > getInventory().getNumberOf(itemId)) amount = getInventory().getNumberOf(itemId); if (amount <= 0) return; curr.setAmount(curr.getAmount() + amount); getInventory().deleteItem(itemId, amount); } leprechaunStorage.put(item, curr); item.updateVars(this); } public void takeLeprechaunItem(StorableItem item, int amount) { Item curr = leprechaunStorage.get(item); if (curr == null) return; if (amount > curr.getAmount()) amount = curr.getAmount(); if (amount > getInventory().getFreeSlots()) amount = getInventory().getFreeSlots(); curr.setAmount(curr.getAmount() - amount); getInventory().addItem(curr.getId(), amount); if (curr.getAmount() == 0) leprechaunStorage.remove(item); else leprechaunStorage.put(item, curr); item.updateVars(this); } public int getUuid() { return getUsername().hashCode(); } public Social getSocial() { return getAccount().getSocial(); } public Account getAccount() { return account; } public void setAccount(Account account) { this.account = account; } public Map getGEOffers() { if (geOffers == null) geOffers = new HashMap<>(); return geOffers; } public void setGEOffers(List offers) { for (Offer offer : offers) geOffers.put(offer.getBox(), offer); } public int getLsp() { return lsp; } public void setLsp(int lsp) { this.lsp = lsp; } public boolean isTrulyHidden() { return trulyHidden; } public void setTrulyHidden(boolean trulyHidden) { this.trulyHidden = trulyHidden; } public void promptSetYellColor() { sendInputName(""Enter yell color in HEX: (ex: 00FF00 for green)"", color -> { if (color.length() != 6) startConversation(new Dialogue().addSimple(""The HEX yell color you wanted to pick cannot be longer and shorter then 6."")); else if (Utils.containsInvalidCharacter(color.toLowerCase()) || color.contains(""_"")) startConversation(new Dialogue().addSimple(""The requested yell color can only contain numeric and regular characters."")); else { setYellColor(color); startConversation(new Dialogue().addSimple(""Your yell color has been changed to "" + getYellColor() + ""."")); } }); } public void promptSetYellTitle() { sendInputName(""Enter yell title:"", title -> { if (title.length() > 20) startConversation(new Dialogue().addSimple(""Your yell title cannot be longer than 20 characters."")); else if (Utils.containsBadCharacter(title)) startConversation(new Dialogue().addSimple(""Keep your title as only letters and numbers.."")); else { setYellTitle(title); getAppearance().generateAppearanceData(); startConversation(new Dialogue().addSimple(""Your yell title has been changed to "" + getYellTitle() + ""."")); } }); } public void promptSetTitle() { sendInputName(""Enter title:"", title -> { if (title.length() > 20) startConversation(new Dialogue().addSimple(""Your title cannot be longer than 20 characters."")); else if (Utils.containsBadCharacter(title)) startConversation(new Dialogue().addSimple(""Keep your title as only letters and numbers.."")); else if (title.toLowerCase().contains(""ironman"") || title.toLowerCase().contains(""hard"")) startConversation(new Dialogue().addSimple(""That title is reserved for special account types."")); else { setTitle(title); getAppearance().generateAppearanceData(); startConversation(new Dialogue().addSimple(""Your title has been changed to "" + getTitle() + ""."")); } }); } public void promptSetTitleColor() { sendInputName(""Enter title color in HEX: (ex: 00FF00 for green)"", color -> { if (color.length() != 6) startConversation(new Dialogue().addSimple(""HEX colors are 6 characters long bud."")); else if (Utils.containsInvalidCharacter(color.toLowerCase()) || color.contains(""_"")) startConversation(new Dialogue().addSimple(""HEX colors just contain letters and numbers bud."")); else { setTitleColor(color); getAppearance().generateAppearanceData(); startConversation(new Dialogue().addSimple(""Your title has been changed to "" + getTitle() + ""."")); } }); } public void promptSetTitleShade() { sendInputName(""Enter title shade color in HEX: (ex: 00FF00 for green)"", color -> { if (color.length() != 6) startConversation(new Dialogue().addSimple(""HEX colors are 6 characters long bud."")); else if (Utils.containsInvalidCharacter(color.toLowerCase()) || color.contains(""_"")) startConversation(new Dialogue().addSimple(""HEX colors just contain letters and numbers bud."")); else { setTitleShading(color); getAppearance().generateAppearanceData(); startConversation(new Dialogue().addSimple(""Your title has been changed to "" + getTitle() + ""."")); } }); } public void simpleDialogue(String message) { startConversation(new com.rs.engine.dialogue.Dialogue(new SimpleStatement(message))); } public void setUsername(String username) { this.username = username; } public int getInvisibleSkillBoost(int skill) { int boost = 0; if (Arrays.stream(Skills.SKILLING).anyMatch(check -> check == skill) && hasEffect(Effect.DUNG_HS_SCROLL_BOOST)) boost += getTempAttribs().getI(""hsDungScrollTier"", 0); switch(skill) { case Skills.WOODCUTTING: if (getFamiliarPouch() == Pouch.BEAVER) boost += 2; break; case Skills.MINING: if (getFamiliarPouch() == Pouch.DESERT_WYRM) boost += 1; else if (getFamiliarPouch() == Pouch.VOID_RAVAGER) boost += 1; else if (getFamiliarPouch() == Pouch.OBSIDIAN_GOLEM) boost += 7; else if (getFamiliarPouch() == Pouch.LAVA_TITAN) boost += 10; break; case Skills.FISHING: if (getFamiliarPouch() == Pouch.GRANITE_CRAB) boost += 1; else if (getFamiliarPouch() == Pouch.IBIS) boost += 3; else if (getFamiliarPouch() == Pouch.GRANITE_LOBSTER) boost += 4; break; case Skills.FIREMAKING: if (getFamiliarPouch() == Pouch.PYRELORD) boost += 3; else if (getFamiliarPouch() == Pouch.LAVA_TITAN) boost += 10; else if (getFamiliarPouch() == Pouch.PHOENIX) boost += 12; break; case Skills.HUNTER: if (getFamiliarPouch() == Pouch.SPIRIT_GRAAHK || getFamiliarPouch() == Pouch.SPIRIT_LARUPIA || getFamiliarPouch() == Pouch.SPIRIT_KYATT) boost += 5; else if (getFamiliarPouch() == Pouch.WOLPERTINGER) boost += 5; else if (getFamiliarPouch() == Pouch.ARCTIC_BEAR) boost += 7; break; } return boost; } public boolean isTileMan() { return tileMan; } public void setTileMan(boolean tileMan) { this.tileMan = tileMan; } public int getPvpCombatLevelThreshhold() { return pvpCombatLevelThreshhold; } public void setPvpCombatLevelThreshhold(int pvpCombatLevelThreshhold) { this.pvpCombatLevelThreshhold = pvpCombatLevelThreshhold; getAppearance().generateAppearanceData(); } public Sound addSound(Sound sound) { if (sound.getId() == -1) return null; sounds.add(sound); return sound; } private Sound addSound(int soundId, int delay, SoundType type) { return addSound(new Sound(soundId, delay, type)); } public void jingle(int jingleId, int delay) { addSound(jingleId, delay, SoundType.JINGLE); } public void jingle(int jingleId) { addSound(jingleId, 0, SoundType.JINGLE); } public void musicTrack(int trackId, int delay, int volume) { addSound(trackId, delay, SoundType.MUSIC).volume(volume); } public void musicTrack(int trackId, int delay) { addSound(trackId, delay, SoundType.MUSIC); } public void musicTrack(int trackId) { musicTrack(trackId, 100); } public Map getMachineMap() { return machineMap; } public MachineInformation getMachineInfo() { return machineInformation; } private void checkWasInDynamicRegion() { if (instancedArea != null) { Instance prevInstance = Instance.get(instancedArea.getId()); if (prevInstance != null && prevInstance.isPersistent()) { prevInstance.teleportTo(this); setForceNextMapLoadRefresh(true); return; } tele(instancedArea.getReturnTo()); instancedArea = null; } } public Recorder getRecorder() { return recorder; } public boolean isQuestComplete(Quest quest, String actionString) { return getQuestManager().isComplete(quest, actionString); } public boolean isQuestComplete(Quest quest) { return isQuestComplete(quest, null); } public boolean isMiniquestComplete(Miniquest quest, String actionString, boolean outputReqs) { return getMiniquestManager().isComplete(quest, actionString, outputReqs); } public boolean isQuestStarted(Quest quest) { return getQuestStage(quest) > 0; } public boolean isMiniquestStarted(Miniquest quest) { return getMiniquestStage(quest) > 0; } public boolean isMiniquestComplete(Miniquest quest) { return isMiniquestComplete(quest, null, false); } public boolean isMiniquestComplete(Miniquest quest, boolean outputReqs) { return isMiniquestComplete(quest, null, outputReqs); } public void delayLock(int ticks, Runnable task) { lock(); WorldTasks.delay(ticks, task); WorldTasks.delay(ticks+1, this::unlock); } public void playPacketCutscene(int id, Runnable onFinish) { getPackets().sendCutscene(id); onPacketCutsceneFinish = onFinish; } public void playCutscene(Consumer constructor) { getCutsceneManager().play(new Cutscene() { @Override public void construct(Player player) { constructor.accept(this); } }); } public void playCutscene(Cutscene scene) { getCutsceneManager().play(scene); } @Override public void setBasNoReset(int bas) { super.setBasNoReset(bas); getAppearance().generateAppearanceData(); } public void setInstancedArea(Instance instancedArea) { this.instancedArea = instancedArea; } public Instance getInstancedArea() { return instancedArea; } public Set getMapChunksNeedInit() { return mapChunksNeedInit; } public void setQuestStage(Quest quest, int stage) { getQuestManager().setStage(quest, stage); } public void setMiniquestStage(Miniquest quest, int stage) { getMiniquestManager().setStage(quest, stage); } @Override public String toString() { return ""[""+getDisplayName() + "" @ ("" + getX() + "","" + getY() + "","" + getPlane()+"")]""; } @NotNull public String genderTerm(@NotNull String male, @NotNull String female) { return getAppearance().isMale() ? male : female; } public void completeQuest(@NotNull Quest quest) { getQuestManager().completeQuest(quest); } }" "package com.rs.game.model.entity.player; @PluginEventHandler public final class Skills { public static final double MAXIMUM_EXP = 200000000; public static final int ATTACK = 0, DEFENSE = 1, STRENGTH = 2, HITPOINTS = 3, RANGE = 4, PRAYER = 5, MAGIC = 6, COOKING = 7, WOODCUTTING = 8, FLETCHING = 9, FISHING = 10, FIREMAKING = 11, CRAFTING = 12, SMITHING = 13, MINING = 14, HERBLORE = 15, AGILITY = 16, THIEVING = 17, SLAYER = 18, FARMING = 19, RUNECRAFTING = 20, HUNTER = 21, CONSTRUCTION = 22, SUMMONING = 23, DUNGEONEERING = 24; public static int SIZE = 25; public static final String[] SKILL_NAME = { ""Attack"", ""Defence"", ""Strength"", ""Constitution"", ""Ranged"", ""Prayer"", ""Magic"", ""Cooking"", ""Woodcutting"", ""Fletching"", ""Fishing"", ""Firemaking"", ""Crafting"", ""Smithing"", ""Mining"", ""Herblore"", ""Agility"", ""Thieving"", ""Slayer"", ""Farming"", ""Runecrafting"", ""Hunter"", ""Construction"", ""Summoning"", ""Dungeoneering"" }; public static final int NONE = -1; public static final int[] SKILLING = { PRAYER, COOKING, WOODCUTTING, FLETCHING, FISHING, FIREMAKING, CRAFTING, SMITHING, MINING, HERBLORE, AGILITY, THIEVING, RUNECRAFTING, SLAYER, FARMING, HUNTER, CONSTRUCTION, DUNGEONEERING }; public static final int[] COMBAT = { ATTACK, DEFENSE, STRENGTH, RANGE, MAGIC }; private short[] level; private double[] xp; private double[] xpTracks; private boolean[] trackSkills; private byte[] trackSkillsIds; private boolean[] enabledSkillsTargets; private boolean[] skillsTargetsUsingLevelMode; private int[] skillTargetStartValues; private int[] skillsTargetsValues; private boolean xpDisplay, xpPopup; private transient int currentCounter; private transient Player player; private final transient Set markedForUpdate = IntSets.synchronize(new IntOpenHashSet()); private transient double bonusXpDrop; private transient int markedForLevelUp = -1; private final transient int[] lastCheckedLevels = new int[25]; public void passLevels(Player p) { level = p.getSkills().level; xp = p.getSkills().xp; } public Skills() { level = new short[25]; xp = new double[25]; for (int i = 0; i < level.length; i++) { level[i] = 1; xp[i] = 0; } level[3] = 10; xp[3] = 1184; enabledSkillsTargets = new boolean[25]; skillsTargetsUsingLevelMode = new boolean[25]; skillsTargetsValues = new int[25]; skillTargetStartValues = new int[25]; xpPopup = true; xpTracks = new double[3]; trackSkills = new boolean[3]; trackSkillsIds = new byte[3]; trackSkills[0] = true; for (int i = 0; i < trackSkillsIds.length; i++) trackSkillsIds[i] = 30; } public boolean checkMulti99s() { int num99s = 0; for (int i = 0;i < xp.length;i++) if (getLevelForXp(i) >= 99) num99s++; return num99s > 1; } public void trimCapes() { if (checkMulti99s()) for (Skillcapes cape : Skillcapes.values()) { if (player.getEquipment().getCapeId() == cape.untrimmed) { player.getEquipment().setSlot(Equipment.CAPE, new Item(cape.trimmed, 1)); player.getAppearance().generateAppearanceData(); } for(int i = 0;i < player.getInventory().getItems().getSize();i++) { if (player.getInventory().getItem(i) != null && player.getInventory().getItem(i).getId() == cape.untrimmed) player.getInventory().replaceItem(cape.trimmed, 1, i); player.getInventory().refresh(); } for(int tab = 0;tab < player.getBank().getBankTabs().length;tab++) { if (player.getBank().getBankTabs()[tab] == null) continue; for (int i = 0;i < player.getBank().getBankTabs()[tab].length;i++) { if (player.getBank().getBankTabs()[tab][i] == null) continue; if (player.getBank().getBankTabs()[tab][i].getId() == cape.untrimmed) { player.getBank().getBankTabs()[tab][i].setId(cape.trimmed); player.getBank().refreshItems(); } } } } } public static int getTargetIdByComponentId(int componentId) { return switch (componentId) { case 150 -> // Attack 0; case 9 -> // Strength 1; case 40 -> // Range 2; case 71 -> // Magic 3; case 22 -> // Defence 4; case 145 -> // Constitution 5; case 58 -> // Prayer 6; case 15 -> // Agility 7; case 28 -> // Herblore 8; case 46 -> // Theiving 9; case 64 -> // Crafting 10; case 84 -> // Runecrafting 11; case 140 -> // Mining 12; case 135 -> // Smithing 13; case 34 -> // Fishing 14; case 52 -> // Cooking 15; case 130 -> // Firemaking 16; case 125 -> // Woodcutting 17; case 77 -> // Fletching 18; case 90 -> // Slayer 19; case 96 -> // Farming 20; case 102 -> // Construction 21; case 108 -> // Hunter 22; case 114 -> // Summoning 23; case 120 -> // Dungeoneering 24; default -> -1; }; } public static int getSkillIdByTargetId(int targetId) { return switch (targetId) { case 0 -> // Attack Constants.ATTACK; case 1 -> // Strength Constants.STRENGTH; case 2 -> // Range Constants.RANGE; case 3 -> // Magic Constants.MAGIC; case 4 -> // Defence Constants.DEFENSE; case 5 -> // Constitution Constants.HITPOINTS; case 6 -> // Prayer Constants.PRAYER; case 7 -> // Agility Constants.AGILITY; case 8 -> // Herblore Constants.HERBLORE; case 9 -> // Thieving Constants.THIEVING; case 10 -> // Crafting Constants.CRAFTING; case 11 -> // Runecrafting Constants.RUNECRAFTING; case 12 -> // Mining Constants.MINING; case 13 -> // Smithing Constants.SMITHING; case 14 -> // Fishing Constants.FISHING; case 15 -> // Cooking Constants.COOKING; case 16 -> // Firemaking Constants.FIREMAKING; case 17 -> // Woodcutting Constants.WOODCUTTING; case 18 -> // Fletching Constants.FLETCHING; case 19 -> // Slayer Constants.SLAYER; case 20 -> // Farming Constants.FARMING; case 21 -> // Construction Constants.CONSTRUCTION; case 22 -> // Hunter Constants.HUNTER; case 23 -> // Summoning Constants.SUMMONING; case 24 -> // Dungeoneering Constants.DUNGEONEERING; default -> -1; }; } public static int getTargetIdBySkillId(int targetId) { return switch (targetId) { case Constants.ATTACK -> 1; case Constants.STRENGTH -> 2; case Constants.RANGE -> 3; case Constants.MAGIC -> 4; case Constants.DEFENSE -> 5; case Constants.HITPOINTS -> 6; case Constants.PRAYER -> 7; case Constants.AGILITY -> 8; case Constants.HERBLORE -> 9; case Constants.THIEVING -> 10; case Constants.CRAFTING -> 11; case Constants.RUNECRAFTING -> 12; case Constants.MINING -> 13; case Constants.SMITHING -> 14; case Constants.FISHING -> 15; case Constants.COOKING -> 16; case Constants.FIREMAKING -> 17; case Constants.WOODCUTTING -> 18; case Constants.FLETCHING -> 19; case Constants.SLAYER -> 20; case Constants.FARMING -> 21; case Constants.CONSTRUCTION -> 22; case Constants.HUNTER -> 23; case Constants.SUMMONING -> 24; case Constants.DUNGEONEERING -> 25; default -> -1; }; } public static ButtonClickHandler handleLevelupButtons = new ButtonClickHandler(741, e -> { if (e.getComponentId() == 9) e.getPlayer().getInterfaceManager().sendInterface(499); }); public static ButtonClickHandler handleGuideButtons = new ButtonClickHandler(499, e -> e.getPlayer().getVars().setVarBit(3289, e.getComponentId()-9)); public static ButtonClickHandler handleSkillTabButtons = new ButtonClickHandler(320, e -> { if (e.getPacket() == ClientPacket.IF_OP1) { e.getPlayer().stopAll(); int targetId = Skills.getTargetIdByComponentId(e.getComponentId()); int skillId = Skills.getSkillIdByTargetId(targetId); e.getPlayer().getVars().setVarBit(3289, 0); e.getPlayer().getVars().setVarBit(3288, targetId+1); if (e.getPlayer().getSkills().lastCheckedLevels[skillId] != e.getPlayer().getSkills().getLevelForXp(skillId)) { e.getPlayer().getPackets().sendVarc(getVarcIdFromTarget(targetId), e.getPlayer().getSkills().lastCheckedLevels[skillId]); e.getPlayer().getVars().setVarBit(4729, targetId+1); } e.getPlayer().getVars().syncVarsToClient(); if (e.getPlayer().getSkills().lastCheckedLevels[skillId] != e.getPlayer().getSkills().getLevelForXp(skillId)) { e.getPlayer().getSkills().lastCheckedLevels[skillId] = e.getPlayer().getSkills().getLevelForXp(skillId); e.getPlayer().getInterfaceManager().sendInterface(741); } else e.getPlayer().getInterfaceManager().sendInterface(499); if (targetId != -1) switchFlash(e.getPlayer(), skillId, false); } else if (e.getPacket() == ClientPacket.IF_OP2 || e.getPacket() == ClientPacket.IF_OP3) { int skillId = Skills.getSkillIdByTargetId(Skills.getTargetIdByComponentId(e.getComponentId())); final boolean usingLevel = e.getPacket() == ClientPacket.IF_OP2; e.getPlayer().sendInputInteger(""Please enter target "" + (usingLevel ? ""level"" : ""xp"") + "" you want to set: "", integer -> { if (!usingLevel) { int xpTarget = integer; if (xpTarget < e.getPlayer().getSkills().getXp(skillId) || e.getPlayer().getSkills().getXp(skillId) >= 200000000) return; if (xpTarget > 200000000) xpTarget = 200000000; e.getPlayer().getSkills().setSkillTarget(false, skillId, xpTarget); } else { int levelTarget = integer; int curLevel = e.getPlayer().getSkills().getLevel(skillId); if (curLevel >= (skillId == 24 ? 120 : 99)) return; if (levelTarget > (skillId == 24 ? 120 : 99)) levelTarget = skillId == 24 ? 120 : 99; if (levelTarget < e.getPlayer().getSkills().getLevel(skillId)) return; e.getPlayer().getSkills().setSkillTarget(true, skillId, levelTarget); } }); } else if (e.getPacket() == ClientPacket.IF_OP4) { int skillId = Skills.getSkillIdByTargetId(Skills.getTargetIdByComponentId(e.getComponentId())); e.getPlayer().getSkills().setSkillTargetEnabled(skillId, false); e.getPlayer().getSkills().setSkillTargetValue(skillId, 0); e.getPlayer().getSkills().setSkillTargetUsingLevelMode(skillId, false); } }); private static int getVarcIdFromTarget(int targetId) { return switch (targetId) { case 0 -> 1469; case 1 -> 1470; case 4 -> 1471; case 2 -> 1472; case 6 -> 1473; case 3 -> 1474; case 5 -> 1475; case 7 -> 1476; case 8 -> 1477; case 9 -> 1478; case 10 -> 1479; case 18 -> 1480; case 12 -> 1481; case 13 -> 1482; case 14 -> 1483; case 15 -> 1484; case 16 -> 1485; case 17 -> 1486; case 11 -> 1487; case 19 -> 1488; case 20 -> 1489; case 21 -> 1490; case 22 -> 1491; case 23 -> 1492; case 24 -> 1493; default -> -1; }; } @Deprecated public static ButtonClickHandler handleSkillGuideButtons = new ButtonClickHandler(1218, e -> { // if ((e.getComponentId() >= 33 && e.getComponentId() <= 55) || e.getComponentId() == 120 || e.getComponentId() == 151 || e.getComponentId() == 189) // e.getPlayer().getInterfaceManager().setInterface(false, 1218, 1, 1217); }); public void refreshEnabledSkillsTargets() { int value = 0; for (int i = 0;i < enabledSkillsTargets.length;i++) if (enabledSkillsTargets[i]) value |= 1 << getTargetIdBySkillId(i); player.getVars().setVar(1966, value); } public void refreshUsingLevelTargets() { int value = 0; for (int i = 0;i < skillsTargetsUsingLevelMode.length;i++) if (skillsTargetsUsingLevelMode[i]) value |= 1 << getTargetIdBySkillId(i); player.getVars().setVar(1968, value); } public void refreshSkillsTargetsValues() { for (int i = 0; i < 25; i++) player.getVars().setVar(1969 + getTargetIdBySkillId(i)-1, skillsTargetsValues[i]); } public void refreshSkillTargetStartValues() { for (int i = 0; i < 25; i++) player.getVars().setVar(1994 + getTargetIdBySkillId(i)-1, skillTargetStartValues[i]); } public void setSkillTargetEnabled(int id, boolean enabled) { enabledSkillsTargets[id] = enabled; refreshEnabledSkillsTargets(); } public void setSkillTargetUsingLevelMode(int id, boolean using) { skillsTargetsUsingLevelMode[id] = using; refreshUsingLevelTargets(); } public void setSkillTargetValue(int skillId, int value) { skillsTargetsValues[skillId] = value; refreshSkillsTargetsValues(); } public void setSkillTargetStartValue(int skillId, int value) { if (skillTargetStartValues == null) skillTargetStartValues = new int[25]; skillTargetStartValues[skillId] = value; refreshSkillTargetStartValues(); } public void setSkillTarget(boolean usingLevel, int skillId, int target) { setSkillTargetEnabled(skillId, true); setSkillTargetUsingLevelMode(skillId, usingLevel); setSkillTargetValue(skillId, target); setSkillTargetStartValue(skillId, (int) (usingLevel ? player.getSkills().getLevelForXp(skillId) : player.getSkills().getXp(skillId))); } public void sendXPDisplay() { for (int i = 0; i < trackSkills.length; i++) { player.getVars().setVarBit(10444 + i, trackSkills[i] ? 1 : 0); player.getVars().setVarBit(10440 + i, trackSkillsIds[i] + 1); refreshCounterXp(i); } } public void setupXPCounter() { player.getInterfaceManager().sendInterface(1214); } public void refreshCurrentCounter() { player.getVars().setVar(2478, currentCounter + 1); } public void setCurrentCounter(int counter) { if (counter != currentCounter) { currentCounter = counter; refreshCurrentCounter(); } } public void switchTrackCounter() { trackSkills[currentCounter] = !trackSkills[currentCounter]; player.getVars().setVarBit(10444 + currentCounter, trackSkills[currentCounter] ? 1 : 0); } public void resetCounterXP() { xpTracks[currentCounter] = 0; refreshCounterXp(currentCounter); } public void setCounterSkill(int skill) { xpTracks[currentCounter] = 0; trackSkillsIds[currentCounter] = (byte) skill; player.getVars().setVarBit(10440 + currentCounter, trackSkillsIds[currentCounter] + 1); refreshCounterXp(currentCounter); } public void refreshCounterXp(int counter) { player.getVars().setVar(counter == 0 ? 1801 : 2474 + counter, (int) (xpTracks[counter] * 10)); } public static ButtonClickHandler handleSetupXPCounter = new ButtonClickHandler(1214, e -> { if (e.getComponentId() == 18) e.getPlayer().closeInterfaces(); else if (e.getComponentId() >= 22 && e.getComponentId() <= 24) e.getPlayer().getSkills().setCurrentCounter(e.getComponentId() - 22); else if (e.getComponentId() == 27) e.getPlayer().getSkills().switchTrackCounter(); else if (e.getComponentId() == 61) e.getPlayer().getSkills().resetCounterXP(); else if (e.getComponentId() >= 31 && e.getComponentId() <= 57) if (e.getComponentId() == 33) e.getPlayer().getSkills().setCounterSkill(4); else if (e.getComponentId() == 34) e.getPlayer().getSkills().setCounterSkill(2); else if (e.getComponentId() == 35) e.getPlayer().getSkills().setCounterSkill(3); else if (e.getComponentId() == 42) e.getPlayer().getSkills().setCounterSkill(18); else if (e.getComponentId() == 49) e.getPlayer().getSkills().setCounterSkill(11); else e.getPlayer().getSkills().setCounterSkill(e.getComponentId() >= 56 ? e.getComponentId() - 27 : e.getComponentId() - 31); }); public void switchXPDisplay() { xpDisplay = !xpDisplay; } public void switchXPPopup() { xpPopup = !xpPopup; player.sendMessage(""XP pop-ups are now "" + (xpPopup ? ""en"" : ""dis"") + ""abled.""); if (xpPopup) player.getInterfaceManager().sendSub(Sub.XP_DROPS, 1213); else player.getInterfaceManager().removeSub(Sub.XP_DROPS); } public void restoreSkills() { for (int skill = 0; skill < level.length; skill++) { level[skill] = (short) getLevelForXp(skill); markForRefresh(skill); } } public void setPlayer(Player player) { this.player = player; for (int i = 0;i < Constants.SKILL_NAME.length;i++) { markForRefresh(i); lastCheckedLevels[i] = getLevelForXp(i); } if (xpTracks == null) { xpPopup = true; xpTracks = new double[3]; trackSkills = new boolean[3]; trackSkillsIds = new byte[3]; trackSkills[0] = true; for (int i = 0; i < trackSkillsIds.length; i++) trackSkillsIds[i] = 30; } } public short[] getLevels() { return level; } public double[] getXp() { return xp; } public int getLevel(int skill) { return level[skill]; } public double getXp(int skill) { return xp[skill]; } public boolean hasRequirements(int... skills) { for (int i = 0; i < skills.length; i += 2) { int skillId = skills[i]; if (skillId == Constants.CONSTRUCTION || skillId == Constants.FARMING) continue; int skillLevel = skills[i + 1]; if (getLevelForXp(skillId) < skillLevel) return false; } return true; } public int getCombatLevel() { return getCombatLevel(false); } public int getCombatLevelWithSummoning() { return getCombatLevel(true); } public int getCombatLevel(boolean summ) { int meleeBased = getLevelForXp(Constants.ATTACK) + getLevelForXp(Constants.STRENGTH); int rangeBased = (int) (getLevelForXp(Constants.RANGE) * 1.5); int magicBased = (int) (getLevelForXp(Constants.MAGIC) * 1.5); int realBase = meleeBased; if (rangeBased > realBase) realBase = rangeBased; if (magicBased > realBase) realBase = magicBased; realBase *= 1.3; realBase = (realBase + getLevelForXp(Constants.DEFENSE) + getLevelForXp(Constants.HITPOINTS) + (getLevelForXp(Constants.PRAYER) / 2) + (summ ? (getLevelForXp(Constants.SUMMONING) / 2) : 0)) / 4; return realBase; } public void set(int skill, int newLevel) { level[skill] = (short) newLevel; markForRefresh(skill); } public int drainLevel(int skill, int drain) { int drainLeft = drain - level[skill]; if (drainLeft < 0) drainLeft = 0; level[skill] -= drain; if (level[skill] < 0) level[skill] = 0; markForRefresh(skill); return drainLeft; } public void drainSummoning(int amt) { if (player.getNSV().getB(""infPrayer"")) return; int level = getLevel(Constants.SUMMONING); if (level == 0) return; set(Constants.SUMMONING, amt > level ? 0 : level - amt); } public static int getXPForLevel(int level) { int points = 0; int output = 0; for (int lvl = 1; lvl <= level; lvl++) { points += Math.floor(lvl + 300.0 * Math.pow(2.0, lvl / 7.0)); if (lvl >= level) return output; output = (int) ((double) points / 4); } return 0; } public int getLevelForXp(int skill) { double exp = Math.floor(xp[skill]); int points = 0; int output = 0; for (int lvl = 1; lvl <= (skill == Constants.DUNGEONEERING ? 120 : 99); lvl++) { points += Math.floor(lvl + 300.0 * Math.pow(2.0, lvl / 7.0)); output = (int) ((double) points / 4); if ((output - 1) >= exp) return lvl; } return skill == Constants.DUNGEONEERING ? 120 : 99; } public static int getLevelForXp(int skill, long xp) { int points = 0; int output = 0; for (int lvl = 1; lvl <= (skill == Constants.DUNGEONEERING ? 120 : 99); lvl++) { points += Math.floor(lvl + 300.0 * Math.pow(2.0, lvl / 7.0)); output = (int) ((double) points / 4); if ((output - 1) >= Math.floor(xp)) return lvl; } return skill == Constants.DUNGEONEERING ? 120 : 99; } public int getTotalLevel() { int totalLevel = 0; for (int i = 0; i < level.length; i++) totalLevel += getLevelForXp(i); return totalLevel; } public void init() { for (int skill = 0; skill < level.length; skill++) markForRefresh(skill); if (enabledSkillsTargets == null) enabledSkillsTargets = new boolean[25]; if (skillsTargetsUsingLevelMode == null) skillsTargetsUsingLevelMode = new boolean[25]; if (skillsTargetsValues == null) skillsTargetsValues = new int[25]; if (xp[3] < 1184) { xp[3] = 1184; markForRefresh(3); } sendXPDisplay(); refreshEnabledSkillsTargets(); refreshUsingLevelTargets(); refreshSkillsTargetsValues(); refreshSkillTargetStartValues(); updateXPDrops(); } public void queueBonusXPDrop(double amount) { bonusXpDrop += amount * 10.0; } public void markForRefresh(int skill) { markedForUpdate.add(skill); } public void updateXPDrops() { if (bonusXpDrop > 0) player.getVars().setVar(2044, (int) bonusXpDrop); else player.getVars().setVar(2044, 0); player.getVars().syncVarsToClient(); Set toUpdate = new HashSet<>(markedForUpdate); player.getPackets().updateStats(toUpdate.stream().mapToInt(e -> e).toArray()); if (markedForLevelUp != -1) sendLevelUp(markedForLevelUp); markedForUpdate.clear(); markedForLevelUp = -1; bonusXpDrop = 0; } public static final int[] SKILL_LEVEL_UP_MUSIC_EFFECTS = { 30, 38, 65, 48, 58, 56, 52, 34, 70, 44, 42, 39, 36, 64, 54, 46, 28, 68, 62, -1, 60, 50, 32, 300, 417 }; private void sendLevelUp(int skill) { int level = getLevelForXp(skill); player.getInterfaceManager().sendSub(Sub.LEVEL_UP, 1216); player.getPackets().sendVarc(1756, Skills.getTargetIdBySkillId(skill)); switchFlash(player, skill, true); int musicEffect = SKILL_LEVEL_UP_MUSIC_EFFECTS[skill]; if (musicEffect != -1) player.jingle(musicEffect); if (!player.hasRights(Rights.ADMIN) && (level == 99 || level == 120)) checkMaxedNotification(player, skill, level); } public static void checkMaxedNotification(Player player, int skill, int level) { boolean reachedAll = true; for (int i = 0; i < Constants.SKILL_NAME.length; i++) if (player.getSkills().getLevelForXp(i) < 99) { reachedAll = false; break; } if (reachedAll) World.sendWorldMessage(""News: "" + player.getDisplayName() + "" has just achieved at least level 99 in all skills!"", false); } public static void switchFlash(Player player, int skill, boolean on) { int id; if (skill == Constants.ATTACK) id = 4732; else if (skill == Constants.STRENGTH) id = 4733; else if (skill == Constants.DEFENSE) id = 4734; else if (skill == Constants.RANGE) id = 4735; else if (skill == Constants.PRAYER) id = 4736; else if (skill == Constants.MAGIC) id = 4737; else if (skill == Constants.HITPOINTS) id = 4738; else if (skill == Constants.AGILITY) id = 4739; else if (skill == Constants.HERBLORE) id = 4740; else if (skill == Constants.THIEVING) id = 4741; else if (skill == Constants.CRAFTING) id = 4742; else if (skill == Constants.FLETCHING) id = 4743; else if (skill == Constants.MINING) id = 4744; else if (skill == Constants.SMITHING) id = 4745; else if (skill == Constants.FISHING) id = 4746; else if (skill == Constants.COOKING) id = 4747; else if (skill == Constants.FIREMAKING) id = 4748; else if (skill == Constants.WOODCUTTING) id = 4749; else if (skill == Constants.RUNECRAFTING) id = 4750; else if (skill == Constants.SLAYER) id = 4751; else if (skill == Constants.FARMING) id = 4752; else if (skill == Constants.CONSTRUCTION) id = 4753; else if (skill == Constants.HUNTER) id = 4754; else if (skill == Constants.SUMMONING) id = 4755; else id = 7756; player.getVars().setVarBit(id, on ? 1 : 0); } public int getCounterSkill(int skill) { return switch (skill) { case Constants.ATTACK -> 0; case Constants.STRENGTH -> 1; case Constants.DEFENSE -> 4; case Constants.RANGE -> 2; case Constants.HITPOINTS -> 5; case Constants.PRAYER -> 6; case Constants.AGILITY -> 7; case Constants.HERBLORE -> 8; case Constants.THIEVING -> 9; case Constants.CRAFTING -> 10; case Constants.MINING -> 12; case Constants.SMITHING -> 13; case Constants.FISHING -> 14; case Constants.COOKING -> 15; case Constants.FIREMAKING -> 16; case Constants.WOODCUTTING -> 17; case Constants.SLAYER -> 19; case Constants.FARMING -> 20; case Constants.CONSTRUCTION -> 21; case Constants.HUNTER -> 22; case Constants.SUMMONING -> 23; case Constants.DUNGEONEERING -> 24; case Constants.MAGIC -> 3; case Constants.FLETCHING -> 18; case Constants.RUNECRAFTING -> 11; default -> -1; }; } public double addXpLamp(int skill, double exp) { player.getControllerManager().trackXP(skill, (int) exp); int oldLevel = getLevelForXp(skill); double oldXp = xp[skill]; if (!player.getControllerManager().gainXP(skill, exp)) return 0.0; if (Settings.getConfig().getXpRate() > 1) exp *= Settings.getConfig().getXpRate(); xp[skill] += exp; int newLevel = getLevelForXp(skill); double newXp = xp[skill]; for (int i = 0; i < trackSkills.length; i++) if (trackSkills[i]) if (trackSkillsIds[i] == 30 || (trackSkillsIds[i] == 29 && (skill == Constants.ATTACK || skill == Constants.DEFENSE || skill == Constants.STRENGTH || skill == Constants.MAGIC || skill == Constants.RANGE || skill == Constants.HITPOINTS)) || trackSkillsIds[i] == getCounterSkill(skill)) { xpTracks[i] += exp; refreshCounterXp(i); } if (xp[skill] > MAXIMUM_EXP) xp[skill] = MAXIMUM_EXP; if (oldLevel < 99 && newLevel >= 99) { World.sendWorldMessage("""" + player.getDisplayName() + "" has achieved 99 "" + Constants.SKILL_NAME[skill] + ""!"", false); trimCapes(); } if (oldXp <= 104273166 && newXp > 104273166) World.sendWorldMessage("""" + player.getDisplayName() + "" has achieved the equivalent of 120 "" + Constants.SKILL_NAME[skill] + ""!"", false); int levelDiff = newLevel - oldLevel; if (newLevel > oldLevel) { level[skill] += levelDiff; markedForLevelUp = skill; //gold fireworks 2589, 2599 player.setNextSpotAnim(new SpotAnim(2456, 0, 254)); player.setNextSpotAnim(new SpotAnim(2457, 25, 254)); player.setNextSpotAnim(new SpotAnim(2456, 50, 220)); if (newLevel == 99 || newLevel == 120) World.sendSpotAnim(Tile.of(player.getTile()), new SpotAnim(1765)); if (skill == Constants.SUMMONING || (skill >= Constants.ATTACK && skill <= Constants.MAGIC)) { player.getAppearance().generateAppearanceData(); if (skill == Constants.HITPOINTS) player.heal(levelDiff * 10); else if (skill == Constants.PRAYER) player.getPrayer().restorePrayer(levelDiff * 10); } } markForRefresh(skill); return exp; } public void addXpQuest(int skill, double exp) { player.getControllerManager().trackXP(skill, (int) exp); if (player.isXpLocked()) return; if (Settings.getConfig().getXpRate() > 1) exp *= Settings.getConfig().getXpRate(); int oldLevel = getLevelForXp(skill); double oldXp = xp[skill]; if (!player.getControllerManager().gainXP(skill, exp)) return; xp[skill] += exp; int newLevel = getLevelForXp(skill); double newXp = xp[skill]; for (int i = 0; i < trackSkills.length; i++) if (trackSkills[i]) if (trackSkillsIds[i] == 30 || (trackSkillsIds[i] == 29 && (skill == Constants.ATTACK || skill == Constants.DEFENSE || skill == Constants.STRENGTH || skill == Constants.MAGIC || skill == Constants.RANGE || skill == Constants.HITPOINTS)) || trackSkillsIds[i] == getCounterSkill(skill)) { xpTracks[i] += exp; refreshCounterXp(i); } if (xp[skill] > MAXIMUM_EXP) xp[skill] = MAXIMUM_EXP; if (oldLevel < 99 && newLevel >= 99) { World.sendWorldMessage("""" + player.getDisplayName() + "" has achieved 99 "" + Constants.SKILL_NAME[skill] + ""!"", false); trimCapes(); } if (oldXp <= 104273166 && newXp > 104273166) World.sendWorldMessage("""" + player.getDisplayName() + "" has achieved the equivalent of 120 "" + Constants.SKILL_NAME[skill] + ""!"", false); int levelDiff = newLevel - oldLevel; if (newLevel > oldLevel) { level[skill] += levelDiff; markedForLevelUp = skill; //gold fireworks 2589, 2599 player.setNextSpotAnim(new SpotAnim(2456, 0, 254)); player.setNextSpotAnim(new SpotAnim(2457, 25, 254)); player.setNextSpotAnim(new SpotAnim(2456, 50, 220)); if (newLevel == 99 || newLevel == 120) player.setNextSpotAnim(new SpotAnim(1765)); if (skill == Constants.SUMMONING || (skill >= Constants.ATTACK && skill <= Constants.MAGIC)) { player.getAppearance().generateAppearanceData(); if (skill == Constants.HITPOINTS) player.heal(levelDiff * 10); else if (skill == Constants.PRAYER) player.getPrayer().restorePrayer(levelDiff * 10); } } markForRefresh(skill); } public void addXp(int skill, double exp) { player.getControllerManager().trackXP(skill, (int) exp); XPGainEvent event = new XPGainEvent(player, skill, exp); PluginManager.handle(event); if (player.isXpLocked()) return; if (Settings.getConfig().getXpRate() > 1) exp *= Settings.getConfig().getXpRate(); double modifier = 1.0; if (Utils.random(600) == 0) RandomEvents.attemptSpawnRandom(player); modifier += getBrawlerModifiers(skill, exp); if (player.hasEffect(Effect.DOUBLE_XP)) modifier += 1.0; if (player.getBonusXpRate() > 0.0) modifier += player.getBonusXpRate(); if (event.getMultiplier() > 1.0) modifier += event.getMultiplier(); if (player.getAuraManager().isActivated(Aura.WISDOM)) modifier += 0.025; if (modifier > 1.0) { double origXp = exp; exp *= modifier; queueBonusXPDrop(exp - origXp); } if (!player.getControllerManager().gainXP(skill, exp)) return; int oldLevel = getLevelForXp(skill); double oldXp = xp[skill]; if ((skill == HITPOINTS || skill == MAGIC) && (player.getInventory().containsItem(12850, 1) || player.getInventory().containsItem(12851, 1))) ; //do not add any XP if they are using minigame runes else xp[skill] += exp; int newLevel = getLevelForXp(skill); double newXp = xp[skill]; for (int i = 0; i < trackSkills.length; i++) if (trackSkills[i]) if (trackSkillsIds[i] == 30 || (trackSkillsIds[i] == 29 && (skill == Constants.ATTACK || skill == Constants.DEFENSE || skill == Constants.STRENGTH || skill == Constants.MAGIC || skill == Constants.RANGE || skill == Constants.HITPOINTS)) || trackSkillsIds[i] == getCounterSkill(skill)) { xpTracks[i] += exp; refreshCounterXp(i); } if (xp[skill] > MAXIMUM_EXP) xp[skill] = MAXIMUM_EXP; if (oldLevel < 99 && newLevel >= 99) { World.sendWorldMessage("""" + player.getDisplayName() + "" has achieved 99 "" + Constants.SKILL_NAME[skill] + ""!"", false); trimCapes(); } if (oldXp <= 104273166 && newXp > 104273166) World.sendWorldMessage("""" + player.getDisplayName() + "" has achieved the equivalent of 120 "" + Constants.SKILL_NAME[skill] + ""!"", false); int levelDiff = newLevel - oldLevel; if (newLevel > oldLevel) { level[skill] += levelDiff; markedForLevelUp = skill; //gold fireworks 2589, 2599 player.setNextSpotAnim(new SpotAnim(2456, 0, 254)); player.setNextSpotAnim(new SpotAnim(2457, 25, 254)); player.setNextSpotAnim(new SpotAnim(2456, 50, 220)); if (newLevel == 99 || newLevel == 120) player.setNextSpotAnim(new SpotAnim(1765)); if (skill == Constants.SUMMONING || (skill >= Constants.ATTACK && skill <= Constants.MAGIC)) { player.getAppearance().generateAppearanceData(); if (skill == Constants.HITPOINTS) player.heal(levelDiff * 10); else if (skill == Constants.PRAYER) player.getPrayer().restorePrayer(levelDiff * 10); } } markForRefresh(skill); } private double processBrawlers(Item gloves, int charges, int skill, double xp, int... validSkills) { boolean validSkill = false; for (int valid : validSkills) if (valid == skill) { validSkill = true; break; } if (!validSkill) return 0.0; if (charges <= -1) { charges = switch (gloves.getId()) { case 13845, 13846, 13847 -> 300000; default -> 464; }; } else { charges -= switch (gloves.getId()) { case 13845, 13846, 13847 -> xp; default -> 1; }; } gloves.addMetaData(""brawlerCharges"", charges); if (charges <= 0) { player.getEquipment().setSlot(Equipment.HANDS, null); player.sendMessage(""Your brawling gloves have degraded.""); } if (player.getControllerManager().getController() != null && player.getControllerManager().getController() instanceof WildernessController) return 2.0; return 0.5; } public double getBrawlerModifiers(int skill, double exp) { Item gloves = player.getEquipment().get(Equipment.HANDS); if (gloves == null) return 0.0; int charges = gloves.getMetaDataI(""brawlerCharges"", -1); return switch (gloves.getId()) { case 13845 -> processBrawlers(gloves, charges, skill, exp, Constants.ATTACK, Constants.STRENGTH, Constants.DEFENSE); case 13846 -> processBrawlers(gloves, charges, skill, exp, Constants.RANGE); case 13847 -> processBrawlers(gloves, charges, skill, exp, Constants.MAGIC); case 13848 -> processBrawlers(gloves, charges, skill, exp, Constants.PRAYER); case 13849 -> processBrawlers(gloves, charges, skill, exp, Constants.AGILITY); case 13850 -> processBrawlers(gloves, charges, skill, exp, Constants.WOODCUTTING); case 13851 -> processBrawlers(gloves, charges, skill, exp, Constants.FIREMAKING); case 13852 -> processBrawlers(gloves, charges, skill, exp, Constants.MINING); case 13853 -> processBrawlers(gloves, charges, skill, exp, Constants.HUNTER); case 13854 -> processBrawlers(gloves, charges, skill, exp, Constants.THIEVING); case 13855 -> processBrawlers(gloves, charges, skill, exp, Constants.SMITHING); case 13856 -> processBrawlers(gloves, charges, skill, exp, Constants.FISHING); case 13857 -> processBrawlers(gloves, charges, skill, exp, Constants.COOKING); default -> 0.0; }; } public void addSkillXpRefresh(int skill, double xp) { this.xp[skill] += xp; level[skill] = (short) getLevelForXp(skill); } public void resetSkillNoRefresh(int skill) { xp[skill] = 0; level[skill] = 1; } public void resetSkillNoRefresh(int skill, int e) { xp[skill] = e; level[skill] = 10; } public void setXp(int skill, double exp) { xp[skill] = exp; markForRefresh(skill); } public boolean isMaxed(boolean compCape) { boolean maxed = true; for (int i = 0; i < level.length; i++) if (getLevelForXp(i) < 99) { if (player != null) player.sendMessage(""You need a "" + Constants.SKILL_NAME[i] + "" level of 99.""); maxed = false; } if (compCape && (getLevelForXp(Constants.DUNGEONEERING) < 120)) { if (player != null) player.sendMessage(""You need a Dungeoneering level of 120.""); maxed = false; } return maxed; } public long getTotalXp() { long totalXp = 0; for (int i = 0; i < level.length; i++) totalXp += xp[i]; return totalXp; } public static int getSkillIndex(String skillName) { for (int i = 0; i < Constants.SKILL_NAME.length; i++) if (skillName.equalsIgnoreCase(Constants.SKILL_NAME[i])) return i; return 0; } public double getXp(String skillName) { for (int i = 0; i < Constants.SKILL_NAME.length; i++) if (skillName.equalsIgnoreCase(Constants.SKILL_NAME[i])) return xp[i]; return 0.0; } public boolean is120(int skillId) { return xp[skillId] >= 104273166; } public int[] getXpInt() { int[] skills = new int[xp.length]; for (int i = 0;i < skills.length;i++) skills[i] = (int) xp[i]; return skills; } public int getHighestSkillLevel() { int maxLevel = 1; for (int skill = 0; skill < level.length; skill++) { int level = getLevelForXp(skill); if (level > maxLevel) maxLevel = level; } return maxLevel; } public void divideXp(double xpRate) { if (xpRate > 2) for (int i = 0;i < xp.length;i++) { xp[i] = xp[i] / xpRate; level[i] = (short) getLevelForXp(i); } } public void adjustStat(boolean calcFromBase, int baseMod, double mul, int... skills) { for (int i : skills) adjustStat(calcFromBase, baseMod, mul, true, i); } public void adjustStat(boolean calcFromBase, int baseMod, double mul, boolean boost, int... skills) { for (int i : skills) adjustStat(calcFromBase, baseMod, mul, boost, i); } public void adjustStat(boolean calcFromBase, int baseMod, double mul, boolean boost, int skill) { int realLevel = getLevelForXp(skill); int realBoost = (int) (baseMod + ((calcFromBase ? realLevel : getLevel(skill)) * mul)); if (realBoost < 0) realLevel = getLevel(skill); int maxBoost = (int) (realLevel + (baseMod + (realLevel * mul))); level[skill] = (short) Utils.clampI(level[skill] + realBoost, 0, boost ? maxBoost : Math.max(getLevel(skill), realLevel)); markForRefresh(skill); } public void adjustStat(int baseMod, double mul, int... skills) { adjustStat(false, baseMod, mul, skills); } public void adjustStat(int baseMod, double mul, boolean boost, int... skills) { adjustStat(false, baseMod, mul, boost, skills); } public void adjustStat(int baseMod, double mul, boolean boost, int skill) { adjustStat(false, baseMod, mul, boost, skill); } public int lowerStat(int skill, double mul, double maxDrain) { return lowerStat(0, mul, maxDrain, skill); } public int lowerStat(int skill, int amt, double maxDrain) { return lowerStat(amt, 0.0, maxDrain, skill); } public void lowerStat(int skill, int amt) { lowerStat(amt, 0.0, 0.0, skill); } public int lowerStat(int baseMod, double mul, double maxDrain, int skill) { int realLevel = getLevelForXp(skill); int realDrain = (int) (baseMod + (getLevel(skill) * mul)); level[skill] = (short) Utils.clampI(level[skill] - realDrain, (int) ((double) realLevel * maxDrain), getLevel(skill)); markForRefresh(skill); return level[skill]; } public static int[] allExcept(int... exclude) { int[] skills = new int[1+Constants.SKILL_NAME.length-exclude.length]; int idx = 0; skills: for (int i = 0;i < Constants.SKILL_NAME.length;i++) { for (int ex : exclude) { if (i == ex) continue skills; } skills[idx++] = i; } return skills; } public boolean xpCounterOpen() { return xpDisplay; } public boolean xpDropsActive() { return xpPopup; } }" "package com.rs.game.model.entity.player; @PluginEventHandler public class Trade { private final Player player; private Player target; private final ItemsContainer items; private boolean tradeModified; private boolean accepted; private boolean logged = false; public Trade(Player player) { this.player = player; // player reference items = new ItemsContainer<>(28, false); } public static ButtonClickHandler handleTradeWindow = new ButtonClickHandler(new Object[] { 334, 335, 336 }, e -> { if (e.getInterfaceId() == 334) { if (e.getPlayer().isIronMan()) return; if (e.getPlayer().getRights() == Rights.ADMIN) { e.getPlayer().sendMessage(""Administrators cannot trade.""); return; } if (e.getComponentId() == 22) e.getPlayer().closeInterfaces(); else if (e.getComponentId() == 21) e.getPlayer().getTrade().accept(false); } else if (e.getInterfaceId() == 335) { if (e.getPlayer().isIronMan()) return; if (e.getComponentId() == 18) e.getPlayer().getTrade().accept(true); else if (e.getComponentId() == 20) e.getPlayer().closeInterfaces(); else if (e.getComponentId() == 32) { if (e.getPacket() == ClientPacket.IF_OP1) e.getPlayer().getTrade().removeItem(e.getSlotId(), 1); else if (e.getPacket() == ClientPacket.IF_OP2) e.getPlayer().getTrade().removeItem(e.getSlotId(), 5); else if (e.getPacket() == ClientPacket.IF_OP3) e.getPlayer().getTrade().removeItem(e.getSlotId(), 10); else if (e.getPacket() == ClientPacket.IF_OP4) e.getPlayer().getTrade().removeItem(e.getSlotId(), Integer.MAX_VALUE); else if (e.getPacket() == ClientPacket.IF_OP5) e.getPlayer().sendInputInteger(""Enter Amount:"", num -> e.getPlayer().getTrade().removeItem(e.getSlotId(), num)); else if (e.getPacket() == ClientPacket.IF_OP6) e.getPlayer().getTrade().sendValue(e.getSlotId(), false); else if (e.getPacket() == ClientPacket.IF_OP10) e.getPlayer().getTrade().sendExamine(e.getSlotId(), false); } else if (e.getComponentId() == 35) { if (e.getPacket() == ClientPacket.IF_OP1) e.getPlayer().getTrade().sendValue(e.getSlotId(), true); else if (e.getPacket() == ClientPacket.IF_OP10) e.getPlayer().getTrade().sendExamine(e.getSlotId(), true); } else if (e.getComponentId() == 53) e.getPlayer().sendInputInteger(""Enter Amount:"", num -> e.getPlayer().getTrade().addCoinsFromPouch(num)); } else if (e.getInterfaceId() == 336) if (e.getComponentId() == 0) if (e.getPacket() == ClientPacket.IF_OP1) e.getPlayer().getTrade().addItem(e.getSlotId(), 1); else if (e.getPacket() == ClientPacket.IF_OP2) e.getPlayer().getTrade().addItem(e.getSlotId(), 5); else if (e.getPacket() == ClientPacket.IF_OP3) e.getPlayer().getTrade().addItem(e.getSlotId(), 10); else if (e.getPacket() == ClientPacket.IF_OP4) e.getPlayer().getTrade().addItem(e.getSlotId(), Integer.MAX_VALUE); else if (e.getPacket() == ClientPacket.IF_OP5) e.getPlayer().sendInputInteger(""Enter Amount:"", num -> e.getPlayer().getTrade().addItem(e.getSlotId(), num)); else if (e.getPacket() == ClientPacket.IF_OP6) e.getPlayer().getTrade().sendValue(e.getSlotId()); else if (e.getPacket() == ClientPacket.IF_OP10) e.getPlayer().getInventory().sendExamine(e.getSlotId()); }); /* * called to both players */ public void openTrade(Player target) { synchronized (this) { synchronized (target.getTrade()) { if (target.isIronMan() || player.isIronMan()) { player.sendMessage(""You may not trade an ironman.""); target.sendMessage(""You may not trade an ironman.""); return; } if (target.getRights() == Rights.ADMIN || player.getRights() == Rights.ADMIN) { player.sendMessage(""You may not trade an administrator.""); target.sendMessage(""You may not trade an administrator.""); return; } this.target = target; player.getPackets().setIFText(335, 17, ""Trading With: "" + target.getDisplayName()); player.getPackets().sendVarcString(203, target.getDisplayName()); sendInterItems(); sendOptions(); sendTradeModified(); refreshFreeInventorySlots(); refreshTradeWealth(); refreshStageMessage(true); player.getInterfaceManager().sendInterface(335); player.getInterfaceManager().sendInventoryInterface(336); player.setCloseInterfacesEvent(() -> closeTrade(CloseTradeStage.CANCEL)); } } } private void addCoinsFromPouch(int num) { synchronized (this) { if (!isTrading()) return; synchronized (target.getTrade()) { if (player.getInventory().getCoinsAsInt() < num) num = player.getInventory().getCoinsAsInt(); Item[] itemsBefore = items.getItemsCopy(); if (!items.add(new Item(995, num))) { player.sendMessage(""Cannot add more money than this.""); return; } player.getInventory().removeCoins(num); refreshItems(itemsBefore); cancelAccepted(); } } } public void removeItem(final int slot, int amount) { synchronized (this) { if (!isTrading()) return; synchronized (target.getTrade()) { Item item = items.get(slot); if (item == null) return; Item[] itemsBefore = items.getItemsCopy(); if (!item.containsMetaData()) { int maxAmount = items.getNumberOf(item); if (amount < maxAmount) item = new Item(item.getId(), amount); else item = new Item(item.getId(), maxAmount); } items.remove(slot, item); if (item.getId() == 995) player.getInventory().addCoins(item.getAmount()); else player.getInventory().addItem(item); refreshItems(itemsBefore); cancelAccepted(); setTradeModified(true); } } } public void sendFlash(int slot) { player.getPackets().sendInterFlashScript(335, 33, 4, 7, slot); target.getPackets().sendInterFlashScript(335, 36, 4, 7, slot); } public void cancelAccepted() { boolean canceled = false; if (accepted) { accepted = false; canceled = true; } if (target.getTrade().accepted) { target.getTrade().accepted = false; canceled = true; } if (canceled) refreshBothStageMessage(canceled); } public void addItem(int slot, int amount) { synchronized (this) { if (!isTrading()) return; synchronized (target.getTrade()) { Item item = player.getInventory().getItem(slot); if (item == null) return; if (!player.hasRights(Rights.OWNER) && !ItemConstants.isTradeable(item)) { player.sendMessage(""That item isn't tradeable.""); return; } Item[] itemsBefore = items.getItemsCopy(); if (!item.containsMetaData()) { int maxAmount = player.getInventory().getItems().getNumberOf(item); if (amount < maxAmount) item = new Item(item.getId(), amount); else item = new Item(item.getId(), maxAmount); } items.add(item); player.getInventory().deleteItem(slot, item); refreshItems(itemsBefore); cancelAccepted(); } } } public void refreshItems(Item[] itemsBefore) { int[] changedSlots = new int[itemsBefore.length]; int count = 0; for (int index = 0; index < itemsBefore.length; index++) { Item item = items.array()[index]; if (itemsBefore[index] != item) { if (itemsBefore[index] != null && (item == null || item.getId() != itemsBefore[index].getId() || item.getAmount() < itemsBefore[index].getAmount())) sendFlash(index); changedSlots[count++] = index; } } int[] finalChangedSlots = new int[count]; System.arraycopy(changedSlots, 0, finalChangedSlots, 0, count); refresh(finalChangedSlots); refreshFreeInventorySlots(); refreshTradeWealth(); } public void sendOptions() { player.getPackets().sendInterSetItemsOptionsScript(336, 0, 93, 4, 7, ""Offer"", ""Offer-5"", ""Offer-10"", ""Offer-All"", ""Offer-X"", ""Value"", ""Lend""); player.getPackets().setIFEvents(new IFEvents(336, 0, 0, 27).enableRightClickOptions(0,1,2,3,4,5,6,9)); player.getPackets().sendInterSetItemsOptionsScript(335, 32, 90, 4, 7, ""Remove"", ""Remove-5"", ""Remove-10"", ""Remove-All"", ""Remove-X"", ""Value""); player.getPackets().setIFEvents(new IFEvents(335, 32, 0, 27).enableRightClickOptions(0,1,2,3,4,5,9)); player.getPackets().sendInterSetItemsOptionsScript(335, 35, 90, true, 4, 7, ""Value""); player.getPackets().setIFEvents(new IFEvents(335, 35, 0, 27).enableRightClickOptions(0,9)); } public boolean isTrading() { return target != null; } public void setTradeModified(boolean modified) { if (modified == tradeModified) return; tradeModified = modified; sendTradeModified(); } public void sendInterItems() { player.getPackets().sendItems(90, items); target.getPackets().sendItems(90, true, items); } public void refresh(int... slots) { player.getPackets().sendUpdateItems(90, items, slots); target.getPackets().sendUpdateItems(90, true, items.array(), slots); } public void accept(boolean firstStage) { synchronized (this) { if (!isTrading()) return; synchronized (target.getTrade()) { if (target.getTrade().accepted) { if (firstStage) { if (nextStage()) target.getTrade().nextStage(); } else { player.setCloseInterfacesEvent(null); player.closeInterfaces(); closeTrade(CloseTradeStage.DONE); } return; } accepted = true; refreshBothStageMessage(firstStage); } } } public void sendValue(int slot, boolean traders) { if (!isTrading()) return; Item item = traders ? target.getTrade().items.get(slot) : items.get(slot); if (item == null) return; if (!ItemConstants.isTradeable(item)) { player.sendMessage(""That item isn't tradeable.""); return; } int price = EconomyPrices.getPrice(item.getId()); player.sendMessage(item.getDefinitions().getName() + "": market price is "" + price + "" coins.""); } public void sendValue(int slot) { Item item = player.getInventory().getItem(slot); if (item == null) return; if (!ItemConstants.isTradeable(item)) { player.sendMessage(""That item isn't tradeable.""); return; } int price = EconomyPrices.getPrice(item.getId()); player.sendMessage(item.getDefinitions().getName() + "": market price is "" + price + "" coins.""); } public void sendExamine(int slot, boolean traders) { if (!isTrading()) return; Item item = traders ? target.getTrade().items.get(slot) : items.get(slot); if (item == null) return; player.sendMessage(ItemConfig.get(item.getId()).getExamine(item)); if (player.hasRights(Rights.DEVELOPER)) player.sendMessage(""Item: "" + (item.getId() + "", ""+item.getMetaData())); } public boolean nextStage() { if (!isTrading()) return false; if (!player.getInventory().hasRoomFor(target.getTrade().items.getItemsNoNull())) { player.setCloseInterfacesEvent(null); player.closeInterfaces(); closeTrade(CloseTradeStage.NO_SPACE); return false; } accepted = false; player.getInterfaceManager().sendInterface(334); player.getInterfaceManager().removeInventoryInterface(); player.getPackets().setIFHidden(334, 55, !(tradeModified || target.getTrade().tradeModified)); refreshBothStageMessage(false); return true; } public void refreshBothStageMessage(boolean firstStage) { refreshStageMessage(firstStage); target.getTrade().refreshStageMessage(firstStage); } public void refreshStageMessage(boolean firstStage) { player.getPackets().setIFText(firstStage ? 335 : 334, firstStage ? 39 : 34, getAcceptMessage(firstStage)); } public String getAcceptMessage(boolean firstStage) { if (target == null) return """"; if (accepted) return ""Waiting for other player...""; if (target.getTrade().accepted) return ""Other player has accepted.""; return firstStage ? """" : ""Are you sure you want to make this trade?""; } public void sendTradeModified() { player.getVars().setVar(1042, tradeModified ? 1 : 0); target.getVars().setVar(1043, tradeModified ? 1 : 0); } public void refreshTradeWealth() { int wealth = getTradeWealth(); player.getPackets().sendVarc(729, wealth); target.getPackets().sendVarc(697, wealth); } public void refreshFreeInventorySlots() { int freeSlots = player.getInventory().getFreeSlots(); target.getPackets().setIFText(335, 23, ""has "" + (freeSlots == 0 ? ""no"" : freeSlots) + "" free"" + ""
inventory slots""); } public int getTradeWealth() { int wealth = 0; for (Item item : items.array()) { if (item == null) continue; wealth += EconomyPrices.getPrice(item.getId()) * item.getAmount(); } return wealth; } public ItemsContainer getItems() { return items; } private enum CloseTradeStage { CANCEL, NO_SPACE, DONE } public void closeTrade(CloseTradeStage stage) { synchronized (this) { synchronized (target.getTrade()) { Player oldTarget = target; target = null; tradeModified = false; accepted = false; if (CloseTradeStage.DONE != stage) { player.getInventory().getItems().addAll(items); player.getInventory().init(); items.clear(); } else { player.sendMessage(""Accepted trade.""); if (!logged && !oldTarget.getTrade().logged) { WorldDB.getLogs().logTrade(player, this, oldTarget, oldTarget.getTrade()); logged = true; } player.getInventory().getItems().addAll(oldTarget.getTrade().items); player.getInventory().init(); oldTarget.getTrade().items.clear(); } if (oldTarget.getTrade().isTrading()) { oldTarget.setCloseInterfacesEvent(null); oldTarget.closeInterfaces(); oldTarget.getTrade().closeTrade(stage); if (CloseTradeStage.CANCEL == stage) oldTarget.sendMessage(""Other player declined trade!""); else if (CloseTradeStage.NO_SPACE == stage) { player.sendMessage(""You don't have enough space in your inventory for this trade.""); oldTarget.sendMessage(""Other player doesn't have enough space in their inventory for this trade.""); } } } } } }" "package com.rs.game.model.entity.player.actions; public final class ActionManager { private final Entity entity; private Action action; private int actionDelay; public ActionManager(Entity entity) { this.entity = entity; } public void process() { if (action != null) if (entity.isDead()) forceStop(); else if (!action.process(entity)) forceStop(); if (actionDelay > 0) { actionDelay--; return; } if (action == null || entity == null) return; int delay = action.processWithDelay(entity); if (delay == -1) { forceStop(); return; } actionDelay += delay; } public boolean setAction(Action skill) { forceStop(); if (!skill.start(entity)) return false; action = skill; return true; } public void forceStop() { if (action == null) return; action.stop(entity); action = null; } public int getActionDelay() { return actionDelay; } public void addActionDelay(int skillDelay) { actionDelay += skillDelay; } public void setActionDelay(int skillDelay) { actionDelay = skillDelay; } public boolean hasSkillWorking() { return action != null; } public Action getAction() { return action; } public boolean doingAction(Class type) { if (action == null) return false; return type.isInstance(action); } }" "package com.rs.game.model.entity.player.actions; public abstract class PlayerAction extends Action { public abstract boolean start(Player entity); public abstract boolean process(Player entity); public abstract int processWithDelay(Player entity); public abstract void stop(Player entity); @Override public boolean start(Entity entity) { if (!(entity instanceof Player player)) return false; return start(player); } @Override public boolean process(Entity entity) { if (!(entity instanceof Player player)) return false; return process(player); } @Override public int processWithDelay(Entity entity) { if (!(entity instanceof Player player)) return -1; return processWithDelay(player); } @Override public void stop(Entity entity) { if (entity instanceof Player player) stop(player); } }" "package com.rs.game.model.entity.player.interactions; public abstract class PlayerEntityInteraction extends EntityInteraction { public PlayerEntityInteraction(Entity target, int distance) { super(target, distance); } public abstract boolean canStart(Player player); public abstract boolean checkAll(Player player); public abstract void interact(Player player); public abstract void onStop(Player player); @Override public boolean canStart(Entity entity) { if (!(entity instanceof Player player)) return false; return canStart(player); } @Override public boolean checkAll(Entity entity) { if (!(entity instanceof Player player)) return false; return checkAll(player); } @Override public void interact(Entity entity) { if (entity instanceof Player player) interact(player); } @Override public void onStop(Entity entity) { if (entity instanceof Player player) onStop(player); } }" "package com.rs.game.model.entity.player.interactions; public abstract class PlayerEntityInteractionAction extends EntityInteractionAction { public abstract boolean canStart(Player player); public abstract boolean checkAll(Player player); public PlayerEntityInteractionAction(Entity target, T action, int distance) { super(target, action, distance); } @Override public boolean canStart(Entity entity) { if (!(entity instanceof Player player)) return false; return canStart(player); } @Override public boolean checkAll(Entity entity) { if (!(entity instanceof Player player)) return false; return checkAll(player); } }" "package com.rs.game.model.entity.player.managers; @PluginEventHandler public class AuraManager { private transient Player player; private transient boolean warned; private Map auraCds; private long currActivated; private Aura currAura; private int jotFlags; public enum Aura { ODDBALL (20957, Millis.fromHours(1), 0), POISON_PURGE (20958, Millis.fromMinutes(10), Millis.fromHours(1)), FRIEND_IN_NEED (20963, Millis.fromSeconds(12), Millis.fromMinutes(15)), KNOCK_OUT (20961, Millis.fromHours(1), Millis.fromHours(4)), SHARPSHOOTER (20967, Millis.fromHours(1), Millis.fromHours(3)), RUNIC_ACCURACY (20962, Millis.fromHours(1), Millis.fromHours(3)), SUREFOOTED (20964, Millis.fromMinutes(20), Millis.fromHours(2)), REVERENCE (20965, Millis.fromHours(1), Millis.fromHours(3)), CALL_OF_THE_SEA (20966, Millis.fromHours(1), Millis.fromHours(3)), JACK_OF_TRADES (20959, Millis.fromHours(3), -1), GREATER_POISON_PURGE (22268, Millis.fromMinutes(20), Millis.fromHours(1)), GREATER_RUNIC_ACCURACY (22270, Millis.fromHours(1), Millis.fromHours(3)), GREATER_SHARPSHOOTER (22272, Millis.fromHours(1), Millis.fromHours(3)), GREATER_CALL_OF_THE_SEA (22274, Millis.fromHours(1), Millis.fromHours(3)), GREATER_REVERENCE (22276, Millis.fromHours(1), Millis.fromHours(3)), GREATER_SUREFOOTED (22278, Millis.fromMinutes(40), Millis.fromHours(2)), LUMBERJACK (22280, Millis.fromHours(1), Millis.fromHours(3)), GREATER_LUMBERJACK (22282, Millis.fromHours(1), Millis.fromHours(3)), QUARRYMASTER (22284, Millis.fromHours(1), Millis.fromHours(3)), GREATER_QUARRYMASTER (22286, Millis.fromHours(1), Millis.fromHours(3)), FIVE_FINGER_DISCOUNT (22288, Millis.fromHours(1), Millis.fromHours(3)), GREATER_FIVE_FINGER_DISCOUNT(22290, Millis.fromHours(1), Millis.fromHours(3)), RESOURCEFUL (22292, Millis.fromHours(1), Millis.fromHours(3)), EQUILIBRIUM (22294, Millis.fromHours(2), Millis.fromHours(4)), INSPIRATION (22296, Millis.fromHours(1), Millis.fromHours(3)), VAMPYRISM (22298, Millis.fromHours(1), Millis.fromHours(3)), PENANCE (22300, Millis.fromHours(1), Millis.fromHours(3)), WISDOM (22302, Millis.fromMinutes(30), -1), AEGIS (22889, Millis.fromMinutes(30), Millis.fromHours(5)), REGENERATION (22893, Millis.fromHours(1), Millis.fromHours(3)), DARK_MAGIC (22891, Millis.fromHours(1), Millis.fromHours(3)), BERSERKER (22897, Millis.fromMinutes(10), Millis.fromHours(5)), ANCESTOR_SPIRITS (22895, Millis.fromMinutes(30), Millis.fromHours(5)), GREENFINGERS (22883, Millis.fromMinutes(20), Millis.fromHours(1)), GREATER_GREENFINGERS (22885, Millis.fromMinutes(20), Millis.fromHours(1)), MASTER_GREENFINGERS (22887, Millis.fromMinutes(20), Millis.fromHours(1)), TRACKER (22927, Millis.fromHours(1), Millis.fromHours(3)), GREATER_TRACKER (22929, Millis.fromHours(1), Millis.fromHours(3)), MASTER_TRACKER (22931, Millis.fromHours(1), Millis.fromHours(3)), SALVATION (22899, Millis.fromHours(1), Millis.fromHours(3)), GREATER_SALVATION (22901, Millis.fromHours(1), Millis.fromHours(3)), MASTER_SALVATION (22903, Millis.fromHours(1), Millis.fromHours(3)), CORRUPTION (22905, Millis.fromHours(1), Millis.fromHours(3)), GREATER_CORRUPTION (22907, Millis.fromHours(1), Millis.fromHours(3)), MASTER_CORRUPTION (22909, Millis.fromHours(1), Millis.fromHours(3)), MASTER_FIVE_FINGER_DISCOUNT (22911, Millis.fromHours(1), Millis.fromHours(3)), MASTER_QUARRYMASTER (22913, Millis.fromHours(1), Millis.fromHours(3)), MASTER_LUMBERJACK (22915, Millis.fromHours(1), Millis.fromHours(3)), MASTER_POISON_PURGE (22917, Millis.fromMinutes(30), Millis.fromHours(1)), MASTER_RUNIC_ACCURACY (22919, Millis.fromHours(1), Millis.fromHours(3)), MASTER_SHARPSHOOTER (22921, Millis.fromHours(1), Millis.fromHours(3)), MASTER_CALL_OF_THE_SEA (22923, Millis.fromHours(1), Millis.fromHours(3)), MASTER_REVERENCE (22925, Millis.fromHours(1), Millis.fromHours(3)), MASTER_KNOCK_OUT (22933, Millis.fromHours(1), Millis.fromHours(4)), SUPREME_SALVATION (23876, Millis.fromHours(1), Millis.fromHours(3)), SUPREME_CORRUPTION (23874, Millis.fromHours(1), Millis.fromHours(3)), HARMONY (23848, Millis.fromHours(1), Millis.fromHours(3)), GREATER_HARMONY (23850, Millis.fromHours(1), Millis.fromHours(3)), MASTER_HARMONY (23852, Millis.fromHours(1), Millis.fromHours(3)), SUPREME_HARMONY (23854, Millis.fromHours(1), Millis.fromHours(3)), INVIGORATE (23840, Millis.fromHours(1), Millis.fromHours(3)), GREATER_INVIGORATE (23842, Millis.fromHours(1), Millis.fromHours(3)), MASTER_INVIGORATE (23844, Millis.fromHours(1), Millis.fromHours(3)), SUPREME_INVIGORATE (23846, Millis.fromHours(1), Millis.fromHours(3)), SUPREME_FIVE_FINGER_DISCOUNT(23856, Millis.fromHours(1), Millis.fromHours(3)), SUPREME_QUARRYMASTER (23858, Millis.fromHours(1), Millis.fromHours(3)), SUPREME_LUMBERJACK (23860, Millis.fromHours(1), Millis.fromHours(3)), SUPREME_POISON_PURGE (23862, Millis.fromHours(1), Millis.fromHours(1)), SUPREME_RUNIC_ACCURACY (23864, Millis.fromHours(1), Millis.fromHours(3)), SUPREME_SHARPSHOOTER (23866, Millis.fromHours(1), Millis.fromHours(3)), SUPREME_CALL_OF_THE_SEA (23868, Millis.fromHours(1), Millis.fromHours(3)), SUPREME_REVERENCE (23870, Millis.fromHours(1), Millis.fromHours(3)), SUPREME_TRACKER (23872, Millis.fromHours(1), Millis.fromHours(3)), SUPREME_GREENFINGERS (23878, Millis.fromMinutes(20), Millis.fromHours(1)); private static final Map ITEMID_MAP = new HashMap<>(); static { for (Aura a : Aura.values()) ITEMID_MAP.put(a.itemId, a); } public static Aura forId(int itemId) { return ITEMID_MAP.get(itemId); } public final int itemId; private final long duration; private final long cooldown; Aura(int itemId, long duration, long cooldown) { this.itemId = itemId; this.duration = duration; this.cooldown = cooldown; } } public static ItemClickHandler handleAuraOptions = new ItemClickHandler(Aura.ITEMID_MAP.keySet().toArray(), new String[] { ""Activate aura"", ""Activate Aura"", ""Aura Time remaining"", ""Aura time remaining"", ""Time-Remaining"" }, e -> { switch(e.getOption()) { case ""Activate aura"": case ""Activate Aura"": e.getPlayer().getAuraManager().activate(); break; case ""Aura time remaining"": case ""Aura Time remaining"": case ""Time-Remaining"": Aura aura = Aura.forId(e.getItem().getId()); e.getPlayer().getAuraManager().sendAuraRemainingTime(aura); if (aura == Aura.JACK_OF_TRADES) e.getPlayer().sendMessage(""You have trained "" + e.getPlayer().getAuraManager().getJotSkills() + "" out of 10 skills so far.""); break; } }); public static ItemEquipHandler handleDequipAura = new ItemEquipHandler(Aura.ITEMID_MAP.keySet().toArray(), e -> { if (e.dequip()) e.getPlayer().getAuraManager().removeAura(); }); public static XPGainHandler handleXpGain = new XPGainHandler(e -> { if (!e.getPlayer().getAuraManager().isActivated(Aura.JACK_OF_TRADES)) return; int total = e.getPlayer().getAuraManager().getJotSkills(); e.getPlayer().getAuraManager().setJotFlag(e.getSkillId()); if (total != e.getPlayer().getAuraManager().getJotSkills()) e.getPlayer().sendMessage(""You have now gained XP in "" + e.getPlayer().getAuraManager().getJotSkills() + "" of the 10 required skills.""); }); public void clearJotFlags() { jotFlags = 0; } public void setJotFlag(int skillId) { int flag = 1 << skillId; jotFlags |= flag; } public int getJotSkills() { int skills = 0; for (int i = 0;i < Constants.SKILL_NAME.length;i++) if ((jotFlags & (1 << i)) != 0) skills++; return skills; } public void setPlayer(Player player) { this.player = player; } public long getTimeLeft() { long timeLeft = currActivated - System.currentTimeMillis(); if (timeLeft <= 0) return 0; return timeLeft; } public void process() { if (currActivated <= 0) return; if (getTimeLeft() <= 60000 && !warned) { player.sendMessage(""Your aura will deplete in 1 minute.""); warned = true; return; } if (System.currentTimeMillis() < currActivated) return; deactivate(); player.getAppearance().generateAppearanceData(); } public void removeAura() { if (currActivated != 0) deactivate(); } public void deactivate() { if (currAura == null) return; if (currAura == Aura.JACK_OF_TRADES && getJotSkills() >= 10) player.setDailyB(""usedJoT"", true); else if (currAura == Aura.WISDOM) player.setDailyB(""usedWisdom"", true); else subtractCooldownTime(currAura, getTimeLeft()); currAura = null; currActivated = 0; warned = false; player.sendMessage(""Your aura has depleted.""); } public void subtractCooldownTime(Aura aura, long time) { if (onCooldown(aura)) auraCds.put(aura, auraCds.get(aura) - time); } public void putOnCooldown(Aura aura) { if (auraCds == null) auraCds = new HashMap<>(); auraCds.put(aura, System.currentTimeMillis() + aura.cooldown + aura.duration); } public boolean onCooldown(Aura aura) { return getCooldownTime(aura) > 0; } public long getCooldownTime(Aura aura) { if (auraCds == null) auraCds = new HashMap<>(); if (auraCds.get(aura) == null) return 0; if (aura == Aura.JACK_OF_TRADES) return player.getDailyB(""usedJoT"") ? Long.MAX_VALUE : 0; if (aura == Aura.WISDOM) return player.getDailyB(""usedWisdom"") ? Long.MAX_VALUE : 0; return auraCds.get(aura) - System.currentTimeMillis(); } public void activate() { Item item = player.getEquipment().getItem(Equipment.AURA); if (item == null) return; Aura aura = Aura.forId(item.getId()); if (aura == null) return; player.stopAll(false); if (currActivated != 0) { player.sendMessage(""Your aura is already activated.""); return; } if ((player.getDailyB(""usedJoT"") && aura == Aura.JACK_OF_TRADES) || (player.getDailyB(""usedWisdom"") && aura == Aura.WISDOM)) { player.sendMessage(""Your aura has not recharged yet.""); return; } if (getCooldownTime(aura) > 0) { player.sendMessage(""Your aura has not recharged yet.""); return; } currAura = aura; currActivated = System.currentTimeMillis() + aura.duration; player.setNextAnimation(new Animation(2231)); player.setNextSpotAnim(new SpotAnim(getActivateSpotAnim(aura))); player.getAppearance().generateAppearanceData(); putOnCooldown(aura); } public int getActivateSpotAnim(Aura aura) { if (ItemDefinitions.getDefs(aura.itemId).getName().startsWith(""Master "")) return 1764; if (ItemDefinitions.getDefs(aura.itemId).getName().startsWith(""Supreme "")) return 1763; return 370; } public void sendAuraRemainingTime() { sendAuraRemainingTime(Aura.forId(player.getEquipment().getAuraId())); } public void sendAuraRemainingTime(Aura aura) { if (aura == null) return; if (currActivated <= 0) { long cooldown = getCooldownTime(aura); if (cooldown > 0) { if (cooldown == Long.MAX_VALUE) player.sendMessage(""Your aura will reset tomorrow.""); else player.sendMessage(""Currently recharging. "" + formatTime(cooldown / 1000) + "" remaining.""); return; } player.sendMessage(""Your aura has finished recharging. It is ready to use.""); return; } player.sendMessage(""Currently active. "" + formatTime(getTimeLeft() / 1000) + "" remaining""); } public String formatTime(long seconds) { long minutes = seconds / 60; long hours = minutes / 60; minutes -= hours * 60; seconds -= (hours * 60 * 60) + (minutes * 60); String minutesString = (minutes < 10 ? ""0"" : """") + minutes; String secondsString = (seconds < 10 ? ""0"" : """") + seconds; return hours + "":"" + minutesString + "":"" + secondsString; } public void sendTimeRemaining(Aura aura) { long cooldown = getCooldownTime(aura); if (cooldown < System.currentTimeMillis()) { player.sendMessage(""Your aura has finished recharging. It is ready to use.""); return; } player.sendMessage(""Currently recharging. "" + formatTime((cooldown - System.currentTimeMillis()) / 1000) + "" remaining.""); } public boolean isActivated(Aura... auras) { for (Aura aura : auras) if (isActivated(aura)) return true; return false; } public boolean isActivated(Aura aura) { Aura worn = Aura.forId(player.getEquipment().getAuraId()); return worn == aura && currActivated != 0; } public boolean isActive() { return currActivated != 0; } public void onIncomingHit(Hit hit) { if (isActivated(Aura.PENANCE)) player.getPrayer().restorePrayer(hit.getDamage() * 0.2); } public void onOutgoingHit(Hit hit) { if (isActivated(Aura.INSPIRATION) && hit.getDamage() > 0) useInspiration(); if (isActivated(Aura.VAMPYRISM)) player.heal((int) (hit.getDamage() * 0.05)); } public void useInspiration() { int atts = player.getTempAttribs().getI(""InspirationAura"", 0); atts++; if (atts == 5) { atts = 0; player.getCombatDefinitions().restoreSpecialAttack(1); } player.getTempAttribs().setI(""InspirationAura"", atts); } public int getAuraModelId() { Item weapon = player.getEquipment().getItem(Equipment.WEAPON); if (weapon == null) return 8719; String name = weapon.getDefinitions().getName().toLowerCase(); if (name.contains(""dagger"")) return 8724; if (name.contains(""whip"")) return 8725; if (name.contains(""2h sword"") || name.contains(""godsword"")) return 8773; if (name.contains(""sword"") || name.contains(""scimitar"") || name.contains(""korasi"")) return 8722; return 8719; } public int getAuraModelId2() { Aura aura = Aura.forId(player.getEquipment().getAuraId()); if (aura == null) return -1; return switch (aura) { case CORRUPTION -> 16449; case SALVATION -> 16465; case HARMONY -> 68605; case GREATER_CORRUPTION -> 16464; case GREATER_SALVATION -> 16524; case GREATER_HARMONY -> 68610; case MASTER_CORRUPTION -> 16429; case MASTER_SALVATION -> 16450; case MASTER_HARMONY -> 68607; case SUPREME_CORRUPTION -> 68615; case SUPREME_SALVATION -> 68611; case SUPREME_HARMONY -> 68613; default -> -1; }; } public static boolean isWingedAura(Aura aura) { return switch (aura) { case CORRUPTION, SALVATION, HARMONY, GREATER_CORRUPTION, GREATER_SALVATION, GREATER_HARMONY, MASTER_CORRUPTION, MASTER_SALVATION, MASTER_HARMONY, SUPREME_CORRUPTION, SUPREME_SALVATION, SUPREME_HARMONY -> true; default -> false; }; } public double getThievingMul() { if (currAura == null) return 1.0; return switch (currAura) { case FIVE_FINGER_DISCOUNT -> 1.03; case GREATER_FIVE_FINGER_DISCOUNT -> 1.05; case MASTER_FIVE_FINGER_DISCOUNT -> 1.07; case SUPREME_FIVE_FINGER_DISCOUNT -> 1.1; default -> 1.0; }; } public double getFishingMul() { if (currAura == null) return 1.0; return switch (currAura) { case CALL_OF_THE_SEA -> 1.03; case GREATER_CALL_OF_THE_SEA -> 1.05; case MASTER_CALL_OF_THE_SEA -> 1.07; case SUPREME_CALL_OF_THE_SEA -> 1.1; default -> 1.0; }; } public double getWoodcuttingMul() { if (currAura == null) return 1.0; return switch (currAura) { case LUMBERJACK -> 1.03; case GREATER_LUMBERJACK -> 1.05; case MASTER_LUMBERJACK -> 1.07; case SUPREME_LUMBERJACK -> 1.1; default -> 1.0; }; } public double getMiningMul() { if (currAura == null) return 1.0; return switch (currAura) { case QUARRYMASTER -> 1.03; case GREATER_QUARRYMASTER -> 1.05; case MASTER_QUARRYMASTER -> 1.07; case SUPREME_QUARRYMASTER -> 1.1; default -> 1.0; }; } public double getHuntingMul() { if (currAura == null) return 1.0; return switch (currAura) { case TRACKER -> 1.03; case GREATER_TRACKER -> 1.05; case MASTER_TRACKER -> 1.07; case SUPREME_TRACKER -> 1.1; default -> 1.0; }; } public double getRangeAcc() { if (currAura == null) return 1.0; return switch (currAura) { case SHARPSHOOTER -> 1.03; case GREATER_SHARPSHOOTER -> 1.05; case MASTER_SHARPSHOOTER -> 1.07; case SUPREME_SHARPSHOOTER -> 1.1; default -> 1.0; }; } public double getMagicAcc() { if (currAura == null) return 1.0; return switch (currAura) { case RUNIC_ACCURACY -> 1.03; case GREATER_RUNIC_ACCURACY -> 1.05; case MASTER_RUNIC_ACCURACY -> 1.07; case SUPREME_RUNIC_ACCURACY -> 1.1; default -> 1.0; }; } public double getPrayerResMul() { if (currAura == null) return 1.0; return switch (currAura) { case REVERENCE -> 1.03; case GREATER_REVERENCE -> 1.05; case MASTER_REVERENCE -> 1.07; case SUPREME_REVERENCE -> 1.1; default -> 1.0; }; } }" "package com.rs.game.model.entity.player.managers; public final class ControllerManager { private transient Player player; private transient boolean inited; private final transient Set> teleportHooks = new ObjectOpenHashSet<>(); private final transient Set> keepCombatingHooks = new ObjectOpenHashSet<>(); private final transient Set> canAttackHooks = new ObjectOpenHashSet<>(); private final transient Set> canHitHooks = new ObjectOpenHashSet<>(); private final transient Set> deathHooks = new ObjectOpenHashSet<>(); private Controller controller; public void setPlayer(Player player) { this.player = player; } public Controller getController() { return controller; } public void startController(Controller controller) { if (controller != null) forceStop(); this.controller = controller; if (controller == null) return; controller.setPlayer(player); controller.start(); inited = true; } public void login() { if (controller == null) { forceStop(); return; } controller.setPlayer(player); if (controller.login()) forceStop(); else inited = true; } public void logout() { if (controller == null) return; if (controller.logout()) forceStop(); } public boolean canMove(Direction dir) { if (controller == null || !inited) return true; return controller.canMove(dir); } public boolean checkWalkStep(int lastX, int lastY, int nextX, int nextY) { if (controller == null || !inited) return true; return controller.checkWalkStep(lastX, lastY, nextX, nextY); } public boolean keepCombating(Entity target) { if (controller != null && inited) return controller.keepCombating(target); for (var keepCombatingHook : keepCombatingHooks) { if (!keepCombatingHook.apply(player, target)) return false; } return true; } public boolean canEquip(int slotId, int itemId) { if (controller == null || !inited) return true; return controller.canEquip(slotId, itemId); } public boolean canAddInventoryItem(int itemId, int amount) { if (controller == null || !inited) return true; return controller.canAddInventoryItem(itemId, amount); } public void trackXP(int skillId, int addedXp) { if (controller == null || !inited) return; controller.trackXP(skillId, addedXp); } public boolean gainXP(int skillId, double exp) { if (controller == null || !inited) return true; return controller.gainXP(skillId, exp); } public boolean canDeleteInventoryItem(int itemId, int amount) { if (controller == null || !inited) return true; return controller.canDeleteInventoryItem(itemId, amount); } public boolean canUseItemOnItem(Item itemUsed, Item usedWith) { if (controller == null || !inited) return true; return controller.canUseItemOnItem(itemUsed, usedWith); } public boolean canAttack(Entity entity) { if (controller != null && inited) return controller.canAttack(entity); for (var canAttackHook : canAttackHooks) { if (!canAttackHook.apply(player, entity)) return false; } return true; } public boolean canPlayerOption1(Player target) { if (controller == null || !inited) return true; return controller.canPlayerOption1(target); } public boolean canPlayerOption2(Player target) { if (controller == null || !inited) return true; return controller.canPlayerOption2(target); } public boolean canPlayerOption3(Player target) { if (controller == null || !inited) return true; return controller.canPlayerOption3(target); } public boolean canPlayerOption4(Player target) { if (controller == null || !inited) return true; return controller.canPlayerOption4(target); } public boolean canHit(Entity entity) { if (controller != null && inited) return controller.canHit(entity); for (var canHitHook : canHitHooks) { if (!canHitHook.apply(player, entity)) return false; } return true; } public void moved() { if (controller == null || !inited) return; controller.moved(); } public boolean canTakeItem(GroundItem item) { if (controller == null || !inited) return true; return controller.canTakeItem(item); } public void processNPCDeath(int id) { if (controller == null || !inited) return; controller.processNPCDeath(id); } public void processOutgoingHit(Hit hit, Entity target) { if (controller == null || !inited) return; controller.processOutgoingHit(hit, target); } public void processIncomingHit(Hit hit) { if (controller == null || !inited) return; controller.processIncomingHit(hit); } public void processNPCDeath(NPC id) { if (controller == null || !inited) return; controller.processNPCDeath(id.getId()); controller.processNPCDeath(id); } public void onTeleported(TeleType type) { if (controller == null || !inited) return; controller.onTeleported(type); } public void sendInterfaces() { if (controller == null || !inited) return; controller.sendInterfaces(); } public void process() { if (controller == null || !inited) return; controller.process(); } public boolean sendDeath() { if (controller != null && inited) return controller.sendDeath(); for (var deathHook : deathHooks) { if (deathHook.apply(player)) return false; } return true; } public boolean canDepositItem(Item item) { if (controller == null || !inited) return true; return controller.canDepositItem(item); } public boolean canEat(Food food) { if (controller == null || !inited) return true; return controller.canEat(food); } public boolean canPot(Potion pot) { if (controller == null || !inited) return true; return controller.canPot(pot); } public boolean useDialogueScript(Object key) { if (controller == null || !inited) return true; return controller.useDialogueScript(key); } public boolean processTeleport(Teleport tele) { if (controller != null && inited) return controller.processTeleport(tele); for (var teleportHook : teleportHooks) { if (!teleportHook.apply(player, tele)) return false; } return true; } public boolean processObjectClick1(GameObject object) { if (controller == null || !inited) return true; return controller.processObjectClick1(object); } public boolean processButtonClick(int interfaceId, int componentId, int slotId, int slotId2, ClientPacket packet) { if (controller == null || !inited) return true; return controller.processButtonClick(interfaceId, componentId, slotId, slotId2, packet); } public boolean processNPCClick1(NPC npc) { if (controller == null || !inited) return true; return controller.processNPCClick1(npc); } public boolean canSummonFamiliar() { if (controller == null || !inited) return true; return controller.canSummonFamiliar(); } public boolean processNPCClick2(NPC npc) { if (controller == null || !inited) return true; return controller.processNPCClick2(npc); } public boolean processNPCClick3(NPC npc) { if (controller == null || !inited) return true; return controller.processNPCClick3(npc); } public boolean processObjectClick2(GameObject object) { if (controller == null || !inited) return true; return controller.processObjectClick2(object); } public boolean processObjectClick3(GameObject object) { if (controller == null || !inited) return true; return controller.processObjectClick3(object); } public boolean processItemOnNPC(NPC npc, Item item) { if (controller == null || !inited) return true; return controller.processItemOnNPC(npc, item); } public boolean canDropItem(Item item) { if (controller == null || !inited) return true; return controller.canDropItem(item); } public void forceStop() { if (controller != null) { controller.onRemove(); controller.forceClose(); controller = null; } inited = false; } public void removeControllerWithoutCheck() { if (controller != null) controller.onRemove(); controller = null; inited = false; } public boolean processObjectClick4(GameObject object) { if (controller == null || !inited) return true; return controller.processObjectClick4(object); } public boolean processObjectClick5(GameObject object) { if (controller == null || !inited) return true; return controller.processObjectClick5(object); } public boolean processItemOnPlayer(Player p2, Item item, int slot) { if (controller == null || !inited) return true; return controller.processItemOnPlayer(p2, item, slot); } public boolean handleItemOnObject(GameObject object, Item item) { if (controller == null || !inited) return true; return controller.processItemOnObject(object, item); } public boolean canTrade() { if (controller == null || !inited) return true; return controller.canTrade(); } public boolean isIn(Class type) { if (controller == null) return false; return controller.getClass().isAssignableFrom(type); } /** * Very unsafe to use this. Do not please. * @param controller */ @Deprecated public void setController(Controller controller) { this.controller = controller; } @SuppressWarnings(""unchecked"") public T getController(Class clazz) { if (controller == null || !controller.getClass().isAssignableFrom(clazz)) return null; return (T) controller; } public void addTeleportHook(BiFunction func) { teleportHooks.add(func); } public void addCanAttackHook(BiFunction func) { canAttackHooks.add(func); } public void addKeepFightingHook(BiFunction func) { keepCombatingHooks.add(func); } public void addCanHitHook(BiFunction func) { canHitHooks.add(func); } public void addDeathHook(Function func) { deathHooks.add(func); } }" "package com.rs.game.model.entity.player.managers; public final class CutsceneManager { private final Player player; private Cutscene cutscene; public CutsceneManager(Player player) { this.player = player; } public void process() { if ((cutscene == null) || cutscene.process()) return; cutscene = null; } public void logout() { if (hasCutscene()) cutscene.logout(); } public boolean hasCutscene() { return cutscene != null; } public boolean play(Cutscene cutscene) { if (hasCutscene() || (cutscene == null)) return false; cutscene.setPlayer(player); cutscene.createObjectMap(); cutscene.construct(player); this.cutscene = cutscene; return true; } }" "package com.rs.game.model.entity.player.managers; @PluginEventHandler public final class EmotesManager { private final ArrayList unlocked; private transient Player player; private transient long nextEmoteEnd; public enum Emote { YES(0, 1796, ""Yes"", new Animation(855)), NO(1, 1797, ""No"", new Animation(856)), BOW(2, 1783, ""Bow"", new Animation(858)), ANGRY(3, 1790, ""Angry"", new Animation(859)), THINK(4, 1792, ""Think"", new Animation(857)), WAVE(5, 1793, ""Wave"", new Animation(863)), SHRUG(6, 1829, ""Shrug"", new Animation(2113)), CHEER(7, 1804, ""Cheer"", new Animation(862)), BECKON(8, 1795, ""Beckon"", new Animation(864)), LAUGH(9, 1798, ""Laugh"", new Animation(861)), JUMP_FOR_JOY(10, 1825, ""Jump For Joy"", new Animation(2109)), YAWN(11, 1827, ""Yawn"", new Animation(2111)), DANCE(12, 1794, ""Dance"", new Animation(866)), JIG(13, 1822, ""Jig"", new Animation(2106)), TWIRL(14, 1823, ""Twirl"", new Animation(2107)), HEADBANG(15, 1824, ""Headbang"", new Animation(2108)), CRY(16, 1791, ""Cry"", new Animation(860)), BLOW_KISS(17, 1820, ""Blow Kiss"", new Animation(1374), new SpotAnim(1702)), PANIC(18, 1821, ""Panic"", new Animation(2105)), RASPBERRY(19, 1826, ""Raspberry"", new Animation(2110)), CLAP(20, 1805, ""Clap"", new Animation(865)), SALUTE(21, 1828, ""Salute"", new Animation(2112)), GOBLIN_BOW(22, 1830, ""Goblin Bow"", 532, 7, new Animation(2127)), GOBLIN_SALUTE(23, 1831, ""Goblin Salute"", 532, 7, new Animation(2128)), GLASS_BOX(24, 1817, ""Glass Box"", 1368, new Animation(1131)), CLIMB_ROPE(25, 1818, ""Climb Rope"", 1369, new Animation(1130)), LEAN(26, 1819, ""Lean"", 1370, new Animation(1129)), GLASS_WALL(27, 1806, ""Glass Wall"", 1367, new Animation(1128)), IDEA(28, 1838, ""Idea"", 2311, new Animation(4276)), STOMP(29, 1839, ""Stomp"", 2312, new Animation(4278)), FLAP(30, 1836, ""Flap"", 2309, new Animation(4280)), SLAP_HEAD(31, 1837, ""Slap Head"", 2310, new Animation(4275)), ZOMBIE_WALK(32, 1834, ""Zombie Walk"", 1921, new Animation(3544)), ZOMBIE_DANCE(33, 1833, ""Zombie Dance"", 1920, new Animation(3543)), ZOMBIE_HAND(34, 1835, ""Zombie Hand"", 4075, 12, new Animation(7272), new SpotAnim(1244)), SCARED(35, 1832, ""Scared"", 1371, new Animation(2836)), BUNNY_HOP(36, 1840, ""Bunny-hop"", 2055, new Animation(6111)), CAPE(37, 1855, ""Cape"", 2787), SNOWMAN_DANCE(38, 1841, ""Snowman Dance"", 4202, new Animation(7531)), AIR_GUITAR(39, 1842, ""Air Guitar"", 4394, new Animation(2414), new SpotAnim(1537)), //music 302 SAFETY_FIRST(40, 1843, ""Safety First"", 4476, new Animation(8770), new SpotAnim(1553)), EXPLORE(41, 1844, ""Explore"", 4884, new Animation(9990), new SpotAnim(1734)), TRICK(42, 1845, ""Trick"", 5490, new Animation(10530), new SpotAnim(1864)), FREEZE(43, 1846, ""Freeze"", 5732, new Animation(11044), new SpotAnim(1973)), GIVE_THANKS(44, 1847, ""Give Thanks"", 5641), AROUND_THE_WORLD(45, 1848, ""Around the World in Eggty Days"", 9194, new Animation(11542), new SpotAnim(2037)), DRAMATIC_POINT(46, 1849, ""Dramatic Point"", 6936, new Animation(12658), new SpotAnim(780)), FAINT(47, 1850, ""Faint"", 6095, new Animation(14165)), PUPPET_MASTER(48, 1851, ""Puppet Master"", 8300, 20, new Animation(14869), new SpotAnim(2837)), TASKMASTER(49, 1853, ""Taskmaster"", 8601, 534), SEAL_OF_APPROVAL(50, 1852, ""Seal of Approval"", 8688), CAT_FIGHT(51, 2658, ""Cat Fight"", new Animation(2252)), TALK_TO_THE_HAND(52, 2654, ""Talk to the Hand"", new Animation(2416)), SHAKE_HANDS(53, 2651, ""Shake Hands"", new Animation(2303)), HIGH_FIVE(54, 2652, ""High Five"", new Animation(2312)), FACE_PALM(55, 2657, ""Face-palm"", new Animation(2254)), SURRENDER(56, 2661, ""Surrender"", new Animation(2360)), LEVITATE(57, 2653, ""Levitate"", new Animation(2327)), MUSCLE_MAN_POSE(58, 2650, ""Muscle-man Pose"", new Animation(2566)), ROFL(59, 2659, ""ROFL"", new Animation(2347)), BREATHE_FIRE(60, 2660, ""Breathe Fire"", new Animation(2238), new SpotAnim(358)), STORM(61, 2655, ""Storm"", new Animation(2563), new SpotAnim(365)), SNOW(62, 2656, ""Snow"", new Animation(2417), new SpotAnim(364)), INVOKE_SPRING(63, 1854, ""Invoke Spring"", 9194, new Animation(15357), new SpotAnim(1391)), HEAD_IN_THE_SAND(64, 2662, ""Head in the Sand"", new Animation(12926), new SpotAnim(1761)), HULA_HOOP(65, 2663, ""Hula Hoop"", new Animation(12928)), DISAPPEAR(66, 2664, ""Disappear"", new Animation(12929), new SpotAnim(1760)), GHOST(67, 2665, ""Ghost"", new Animation(12932), new SpotAnim(1762)), BRING_IT(68, 2666, ""Bring It!"", new Animation(12934)), PALM_FIST(69, 2667, ""Palm-fist"", new Animation(12931)), KNEEL(70, 2687, ""Kneel"", new Animation(12449)), BEGGING(71, 2688, ""Begging"", new Animation(12450)), STIR_COULDRON(72, 2689, ""Stir Cauldron"", new Animation(12463)), CHEER2(73, 2690, ""Cheer"", new Animation(12473)), TANTRUM(74, 2691, ""Tantrum"", new Animation(12497)), DRAMATIC_DEATH(75, 2692, ""Dramatic Death"", new Animation(12544)), JUMP_YELL(76, 2693, ""Jump & Yell"", new Animation(12472)), POINT(77, 2694, ""Point"", new Animation(12476)), PUNCH(78, 2695, ""Punch"", new Animation(12477)), RAISE_HAND(79, 2696, ""Raise Hand"", new Animation(12484)), MAKE_SPEECH(80, 2697, ""Make Speech"", new Animation(12489)), SWORD_FIGHT(81, 2698, ""Sword Fight"", new Animation(12496)), RAISE_HAND_SIT(82, 2699, ""Raise Hand (Sitting)"", new Animation(12487)), WAVE_SIT(83, 2700, ""Wave (Sitting)"", new Animation(12488)), CHEER_SIT(84, 2701, ""Cheer (Sitting)"", new Animation(12500)), THROW_TOMATO_SIT(85, 2708, ""Throw Tomato (Sitting)"", new Animation(12468)), THROW_FLOWERS(86, 2709, ""Throw Flowers (Sitting)"", new Animation(12469)), AGREE(87, 2702, ""Agree (Sitting)"", new Animation(12504)), POINT_SIT(88, 2703, ""Point (Sitting)"", new Animation(12505)), WHISTLE(89, 2704, ""Whistle (Sitting)"", new Animation(12509)), THUMBSUP_SIT(90, 2706, ""Thumbs-Up (Sitting)"", new Animation(12687)), THUMBSDOWN_SIT(91, 2707, ""Thumbs-Down (Sitting)"", new Animation(12688)), CLAP_SIT(92, 2705, ""Clap (Sitting)"", new Animation(12691)), LIVING_BORROWED_TIME(93, 2749, ""Living on Borrowed Time"", 9930, 15), TROUBADOUR_DANCE(94, 2812, ""Troubadour dance"", 10138, 100, new Animation(15424)), EVIL_LAUGH(95, 2935, ""Evil Laugh""), GOLF_CLAP(96, 2936, ""Golf Clap"", new Animation(15520)), LOLCANO(97, 2937, ""LOLcano""), INFERNAL_POWER(98, 2938, ""Infernal Power"", new Animation(15529), new SpotAnim(2197)), DIVINE_POWER(99, 2939, ""Divine Power"", new Animation(15524), new SpotAnim(2195)), YOURE_DEAD(100, 2940, ""You're Dead"", new Animation(14195)), SCREAM(101, 2941, ""Scream""), TORNADO(102, 2942, ""Tornado"", new Animation(15530), new SpotAnim(2196)), CHAOTIC_COOKERY(103, 2943, ""Chaotic Cookery"", 10340, new Animation(15604), new SpotAnim(2239)), ROFLCOPTER(104, 9780, ""ROFLcopter""), NATURES_MIGHT(105, 9781, ""Nature's Might"", new Animation(16376), new SpotAnim(3011)), INNER_POWER(106, 9782, ""Inner Power"", new Animation(16382), new SpotAnim(3014)), WEREWOLF_TRANSFORMATION(107, 9783, ""Werewolf Transformation""), CELEBRATE(108, 10516, ""Celebrate"", new Animation(16913), new SpotAnim(3175)), BREAKDANCE(109, 11187, ""Breakdance"", new Animation(17079)), MAHJARRAT_TRANS(110, 11188, ""Mahjarrat Transformation"", new Animation(17103), new SpotAnim(3222)), BREAK_WIND(111, 11189, ""Break Wind"", new Animation(17076), new SpotAnim(3226)), BACKFLIP(112, 11190, ""Backflip"", new Animation(17101), new SpotAnim(3221)), GRAVEDIGGER(113, 11191, ""Gravedigger"", new Animation(17077), new SpotAnim(3219)), FROG_TRANS(114, 11192, ""Frog Transformation"", new Animation(17080), new SpotAnim(3220)), MEXICAN_WAVE(115, 11387, ""Mexican Wave"", new Animation(17163)), SPORTSMAN(116, 11388, ""Sportsman"", new Animation(17166)); private static final HashMap MAP = new HashMap<>(); static { for (Emote emote : Emote.values()) MAP.put(emote.slotId, emote); } public static Emote forSlot(int slotId) { return MAP.get(slotId); } private final int slotId; private final int mapId; private final String name; private final int varpbit; private final int value; private final Animation animation; private final SpotAnim spotAnim; Emote(int slotId, int mapId, String name) { this(slotId, mapId, name, -1, -1, null, null); } Emote(int slotId, int mapId, String name, Animation animation) { this(slotId, mapId, name, -1, -1, animation, null); } Emote(int slotId, int mapId, String name, Animation animation, SpotAnim spotAnim) { this(slotId, mapId, name, -1, -1, animation, spotAnim); } Emote(int slotId, int mapId, String name, int varpbit) { this(slotId, mapId, name, varpbit, 1, null, null); } Emote(int slotId, int mapId, String name, int varpbit, Animation animation) { this(slotId, mapId, name, varpbit, 1, animation, null); } Emote(int slotId, int mapId, String name, int varpbit, Animation animation, SpotAnim spotAnim) { this(slotId, mapId, name, varpbit, 1, animation, spotAnim); } Emote(int slotId, int mapId, String name, int varpbit, int value) { this(slotId, mapId, name, varpbit, value, null, null); } Emote(int slotId, int mapId, String name, int varpbit, int value, Animation animation) { this(slotId, mapId, name, varpbit, value, animation, null); } Emote(int slotId, int mapId, String name, int varpbit, int value, Animation animation, SpotAnim spotAnim) { this.slotId = slotId; this.mapId = mapId; this.name = name; this.varpbit = varpbit; this.value = value; this.animation = animation; this.spotAnim = spotAnim; } public int getMapId() { return mapId; } public Animation getAnim() { return animation; } } public EmotesManager() { unlocked = new ArrayList<>(); } public void setPlayer(Player player) { this.player = player; } public void unlockEmote(Emote emote) { if (unlocked.contains(emote)) return; if (unlocked.add(emote)) refreshListConfigs(); } public void lockEmote(Emote emote) { if (!unlocked.contains(emote)) return; if (unlocked.remove(emote)) refreshListConfigs(); } public boolean unlockedEmote(Emote emote) { if (player.hasRights(Rights.ADMIN) || emote.ordinal() <= Emote.SALUTE.ordinal() || emote == Emote.CELEBRATE || emote == Emote.CAPE) return true; return unlocked.contains(emote); } public static ButtonClickHandler handleEmoteBook = new ButtonClickHandler(new Object[] { 590, 464 }, e -> { if ((e.getInterfaceId() == 590 && e.getComponentId() != 8)) return; Emote emote = Emote.forSlot(e.getSlotId()); if (emote != null) e.getPlayer().getEmotesManager().useBookEmote(emote); }); public void useBookEmote(Emote emote) { if (player.inCombat(10000) || player.hasBeenHit(10000)) { player.sendMessage(""You can't do this while you're under combat.""); return; } player.stopAll(false); player.getTreasureTrailsManager().useEmote(emote); if (!unlockedEmote(emote)) { if (emote == Emote.AIR_GUITAR) player.simpleDialogue(""This emote can be acessed by unlocking "" + Settings.AIR_GUITAR_MUSICS_COUNT + "" pieces of music.""); else player.simpleDialogue(""You haven't unlocked ""+emote.name+"" yet.""); } else { if (World.getServerTicks() < nextEmoteEnd) { player.sendMessage(""You're already doing an emote!""); return; } if (emote.animation != null) { player.setNextAnimation(emote.animation); if(emote == Emote.AIR_GUITAR) player.jingle(302); if (emote.spotAnim != null) player.setNextSpotAnim(emote.spotAnim); } else if (emote == Emote.TASKMASTER) { player.setNextAnimation(new Animation(player.getAppearance().isMale() ? 15033 : 15034)); player.setNextSpotAnim(new SpotAnim(2930)); } else if (emote == Emote.LOLCANO) { player.setNextAnimation(new Animation(player.getAppearance().isMale() ? 15532 : 15533)); player.setNextSpotAnim(new SpotAnim(2191)); } else if (emote == Emote.SCREAM) player.setNextAnimation(new Animation(player.getAppearance().isMale() ? 15526 : 15527)); else if (emote == Emote.ROFLCOPTER) { player.setNextAnimation(new Animation(player.getAppearance().isMale() ? 16373 : 16374)); player.setNextSpotAnim(new SpotAnim(3010)); } else if (emote == Emote.WEREWOLF_TRANSFORMATION) { player.setNextAnimation(new Animation(16380)); player.setNextSpotAnim(new SpotAnim(3013)); player.setNextSpotAnim(new SpotAnim(3016)); } else if (emote == Emote.EVIL_LAUGH) { player.setNextAnimation(new Animation(player.getAppearance().isMale() ? 15535 : 15536)); player.setNextSpotAnim(new SpotAnim(2191)); } else if (emote == Emote.LIVING_BORROWED_TIME) { final NPC grim = new NPC(14388, Tile.of(player.getX(), player.getY() + 1, player.getPlane())); World.addNPC(grim); player.lock(); grim.setNextFaceEntity(player); player.setNextFaceEntity(grim); WorldTasks.scheduleTimer(1, tick -> { if (tick >= 10 || player.hasFinished()) return false; if (tick == 0) { grim.setNextAnimation(new Animation(13964)); player.setNextSpotAnim(new SpotAnim(1766)); player.setNextAnimation(new Animation(13965)); } else if (tick == 8) { grim.setFinished(true); World.removeNPC(grim); grim.setNextFaceEntity(null); } else if (tick == 9) { player.setNextForceTalk(new ForceTalk(""Phew! Close call."")); player.setNextFaceEntity(null); player.unlock(); } return true; }); } else if (emote == Emote.CAPE) { final int capeId = player.getEquipment().getCapeId(); switch (capeId) { case 9747: case 9748: case 25324: player.setNextAnimation(new Animation(4959)); player.setNextSpotAnim(new SpotAnim(823)); break; case 9753: case 9754: case 25326: player.setNextAnimation(new Animation(4961)); player.setNextSpotAnim(new SpotAnim(824)); break; case 9750: case 9751: case 25325: player.setNextAnimation(new Animation(4981)); player.setNextSpotAnim(new SpotAnim(828)); break; case 9768: case 9769: case 25332: player.setNextAnimation(new Animation(14242)); player.setNextSpotAnim(new SpotAnim(2745)); break; case 9756: case 9757: case 25327: player.setNextAnimation(new Animation(4973)); player.setNextSpotAnim(new SpotAnim(832)); break; case 9762: case 9763: case 25329: player.setNextAnimation(new Animation(4939)); player.setNextSpotAnim(new SpotAnim(813)); break; case 9759: case 9760: case 25328: player.setNextAnimation(new Animation(4979)); player.setNextSpotAnim(new SpotAnim(829)); break; case 9801: case 9802: case 25344: player.setNextAnimation(new Animation(4955)); player.setNextSpotAnim(new SpotAnim(821)); break; case 9807: case 9808: case 25346: player.setNextAnimation(new Animation(4957)); player.setNextSpotAnim(new SpotAnim(822)); break; case 9783: case 9784: case 25337: player.setNextAnimation(new Animation(4937)); player.setNextSpotAnim(new SpotAnim(812)); break; case 9798: case 9799: case 25343: player.setNextAnimation(new Animation(4951)); player.setNextSpotAnim(new SpotAnim(819)); break; case 9804: case 9805: case 25345: player.setNextAnimation(new Animation(4975)); player.setNextSpotAnim(new SpotAnim(831)); break; case 9780: case 9781: case 25336: player.setNextAnimation(new Animation(4949)); player.setNextSpotAnim(new SpotAnim(818)); break; case 9795: case 9796: case 25342: player.setNextAnimation(new Animation(4943)); player.setNextSpotAnim(new SpotAnim(815)); break; case 9792: case 9793: case 25341: player.setNextAnimation(new Animation(4941)); player.setNextSpotAnim(new SpotAnim(814)); break; case 9774: case 9775: case 25334: player.setNextAnimation(new Animation(4969)); player.setNextSpotAnim(new SpotAnim(835)); break; case 9771: case 9772: case 25333: player.setNextAnimation(new Animation(4977)); player.setNextSpotAnim(new SpotAnim(830)); break; case 9777: case 9778: case 25335: player.setNextAnimation(new Animation(4965)); player.setNextSpotAnim(new SpotAnim(826)); break; case 9786: case 9787: case 25338: player.setNextAnimation(new Animation(4967)); player.setNextSpotAnim(new SpotAnim(1656)); break; case 9810: case 9811: case 25347: player.setNextAnimation(new Animation(4963)); player.setNextSpotAnim(new SpotAnim(825)); break; case 9765: case 9766: case 25330: player.setNextAnimation(new Animation(4947)); player.setNextSpotAnim(new SpotAnim(817)); break; case 9789: case 9790: case 25331: player.setNextAnimation(new Animation(4953)); player.setNextSpotAnim(new SpotAnim(820)); break; case 12169: case 12170: case 25348: player.setNextAnimation(new Animation(8525)); player.setNextSpotAnim(new SpotAnim(1515)); break; case 9948: case 9949: case 25339: player.setNextAnimation(new Animation(5158)); player.setNextSpotAnim(new SpotAnim(907)); break; case 9813: player.setNextAnimation(new Animation(4945)); player.setNextSpotAnim(new SpotAnim(816)); break; case 18508: case 18509: // Dungeoneering cape if (player.isLocked()) break; final int rand = Utils.random(0, 3); player.setNextAnimation(new Animation(13190)); player.setNextSpotAnim(new SpotAnim(2442)); player.lock(); WorldTasks.scheduleLooping(new Task() { int step; @Override public void run() { if (step == 1) { if (rand == 0) player.getAppearance().transformIntoNPC(11227); else if (rand == 1) player.getAppearance().transformIntoNPC(11228); else if (rand == 2) player.getAppearance().transformIntoNPC(11229); if (rand == 0) player.setNextAnimation(new Animation(13192)); else if (rand == 1) player.setNextAnimation(new Animation(13193)); else if (rand == 2) player.setNextAnimation(new Animation(13194)); } if (step == 6) player.getAppearance().transformIntoNPC(-1); if (step == 8) { player.unlock(); stop(); } step++; } }, 0, 0); break; case 19709: case 19710: // Master dungeoneering cape if (player.isLocked()) break; player.setNextFaceTile(Tile.of(player.getX(), player.getY() - 1, player.getPlane())); player.lock(); WorldTasks.scheduleLooping(new Task() { int step; @Override public void run() { if (step == 1) { player.getAppearance().transformIntoNPC(11229); player.setNextAnimation(new Animation(14608)); World.sendProjectile(player, Tile.of(player.getX(), player.getY() - 1, player.getPlane()), 2781, 30, 30, 6, 20, 1, 0); World.sendSpotAnim(Tile.of(player.getX(), player.getY() - 1, player.getPlane()), new SpotAnim(2777)); } if (step == 3) { player.getAppearance().transformIntoNPC(11228); player.setNextAnimation(new Animation(14609)); player.setNextSpotAnim(new SpotAnim(2782)); World.sendSpotAnim(Tile.of(player.getX() + 1, player.getY() - 1, player.getPlane()), new SpotAnim(2778)); } if (step == 5) { player.getAppearance().transformIntoNPC(11227); player.setNextAnimation(new Animation(14610, 15)); World.sendSpotAnim(Tile.of(player.getX(), player.getY() - 1, player.getPlane()), new SpotAnim(2779)); World.sendSpotAnim(Tile.of(player.getX(), player.getY() + 1, player.getPlane()), new SpotAnim(2780)); } if (step == 9) player.setNextSpotAnim(new SpotAnim(2442)); if (step == 10) { player.setNextSpotAnim(new SpotAnim(-1)); player.getAppearance().transformIntoNPC(-1); player.unlock(); stop(); } step++; } }, 0, 0); break; case 20763: // Veteran cape if (player.getControllerManager().getController() != null) { player.sendMessage(""You cannot do this here!""); return; } player.setNextAnimation(new Animation(352)); player.setNextSpotAnim(new SpotAnim(1446)); break; case 20765: // Classic cape if (player.getControllerManager().getController() != null) { player.sendMessage(""You cannot do this here!""); return; } int random = Utils.getRandomInclusive(2); player.setNextAnimation(new Animation(122)); player.setNextSpotAnim(new SpotAnim(random == 0 ? 1471 : 1466)); break; case 20767: // Max cape if (player.getControllerManager().getController() != null) { player.sendMessage(""Dont annoy other players!""); return; } int size = NPCDefinitions.getDefs(1224).size; Tile spawnTile = Tile.of(Tile.of(player.getX() + 1, player.getY(), player.getPlane())); if (!World.floorAndWallsFree(spawnTile, size)) spawnTile = player.getNearestTeleTile(size); if (spawnTile == null) { player.sendMessage(""Need more space to perform this skillcape emote.""); return; } nextEmoteEnd = World.getServerTicks() + 25; final Tile npcTile = spawnTile; WorldTasks.scheduleLooping(new Task() { private int step; private NPC npc; @Override public void run() { if (step == 0) { npc = new NPC(1224, npcTile); npc.setNextAnimation(new Animation(1434)); npc.setNextSpotAnim(new SpotAnim(1482)); player.setNextAnimation(new Animation(1179)); npc.setNextFaceEntity(player); player.setNextFaceEntity(npc); } else if (step == 2) { npc.setNextAnimation(new Animation(1436)); npc.setNextSpotAnim(new SpotAnim(1486)); player.setNextAnimation(new Animation(1180)); } else if (step == 3) { npc.setNextSpotAnim(new SpotAnim(1498)); player.setNextAnimation(new Animation(1181)); } else if (step == 4) player.setNextAnimation(new Animation(1182)); else if (step == 5) { npc.setNextAnimation(new Animation(1448)); player.setNextAnimation(new Animation(1250)); } else if (step == 6) { player.setNextAnimation(new Animation(1251)); player.setNextSpotAnim(new SpotAnim(1499)); npc.setNextAnimation(new Animation(1454)); npc.setNextSpotAnim(new SpotAnim(1504)); } else if (step == 11) { player.setNextAnimation(new Animation(1291)); player.setNextSpotAnim(new SpotAnim(1686)); player.setNextSpotAnim(new SpotAnim(1598)); npc.setNextAnimation(new Animation(1440)); } else if (step == 16) { player.setNextFaceEntity(null); npc.finish(); stop(); } step++; } }, 0, 1); break; case 20769: case 20771: // Compl cape if (!World.floorAndWallsFree(player.getTile(), 3)) { player.sendMessage(""Need more space to perform this skillcape emote.""); return; } if (player.getControllerManager().getController() != null) { player.sendMessage(""Dont annoy other players!""); return; } nextEmoteEnd = World.getServerTicks() + 20; WorldTasks.scheduleLooping(new Task() { private int step; @Override public void run() { if (step == 0) { player.setNextAnimation(new Animation(356)); player.setNextSpotAnim(new SpotAnim(307)); } else if (step == 2) { player.getAppearance().transformIntoNPC(capeId == 20769 ? 1830 : 3372); player.setNextAnimation(new Animation(1174)); player.setNextSpotAnim(new SpotAnim(1443)); } else if (step == 4) player.getPackets().sendCameraShake(3, 25, 50, 25, 50); else if (step == 5) player.getPackets().sendStopCameraShake(); else if (step == 8) { player.getAppearance().transformIntoNPC(-1); player.setNextAnimation(new Animation(1175)); stop(); } step++; } }, 0, 1); break; default: player.sendMessage(""You need to be wearing a skillcape in order to perform this emote.""); break; } return; } else if (emote == Emote.GIVE_THANKS) WorldTasks.scheduleLooping(new Task() { @Override public void run() { if (step == 0) { player.setNextAnimation(new Animation(10994)); player.setNextSpotAnim(new SpotAnim(86)); } else if (step == 1) { player.setNextAnimation(new Animation(10996)); player.getAppearance().transformIntoNPC(8499); } else if (step == 6) { player.setNextAnimation(new Animation(10995)); player.setNextSpotAnim(new SpotAnim(86)); player.getAppearance().transformIntoNPC(-1); stop(); } step++; } private int step; }, 0, 1); else if (emote == Emote.SEAL_OF_APPROVAL) WorldTasks.scheduleLooping(new Task() { final int random = (int) (Math.random() * (2 + 1)); @Override public void run() { if (step == 0) { player.setNextAnimation(new Animation(15104)); player.setNextSpotAnim(new SpotAnim(1287)); } else if (step == 1) { player.setNextAnimation(new Animation(15106)); player.getAppearance().transformIntoNPC(random == 0 ? 13255 : (random == 1 ? 13256 : 13257)); } else if (step == 2) player.setNextAnimation(new Animation(15108)); else if (step == 3) { player.setNextAnimation(new Animation(15105)); player.setNextSpotAnim(new SpotAnim(1287)); player.getAppearance().transformIntoNPC(-1); stop(); } step++; } private int step; }, 0, 1); setNextEmoteEnd(); } } public void setNextEmoteEnd() { nextEmoteEnd = player.getLastAnimationEnd() - 1; } public void setNextEmoteEnd(int ticks) { nextEmoteEnd = World.getServerTicks() + ticks; } public void refreshListConfigs() { for (Emote emote : unlocked) if (emote.varpbit != -1) player.getVars().setVarBit(emote.varpbit, emote.value); } public boolean isAnimating() { return World.getServerTicks() < nextEmoteEnd; } public void unlockEmotesBook() { player.getPackets().setIFRightClickOps(590, 8, 0, Emote.values().length, 0, 1); } }" "package com.rs.game.model.entity.player.managers; public class HintIconsManager { private final Player player; private final HintIcon[] loadedIcons; public HintIconsManager(Player p) { player = p; loadedIcons = new HintIcon[7]; } public int addHintIcon(int index, Entity target, int arrowType, int modelId, boolean saveIcon) { if (index != -1) { HintIcon icon = new HintIcon(target.getIndex(), target instanceof Player ? 10 : 1, arrowType, modelId, index); player.getPackets().sendHintIcon(icon); if (saveIcon) loadedIcons[index] = icon; } return index; } public int addHintIcon(Entity target, int arrowType, int modelId, boolean saveIcon) { int index = saveIcon ? getFreeIndex() : 7; if (index != -1) { HintIcon icon = new HintIcon(target.getIndex(), target instanceof Player ? 10 : 1, arrowType, modelId, index); player.getPackets().sendHintIcon(icon); if (saveIcon) loadedIcons[index] = icon; } return index; } public int addHintIcon(int coordX, int coordY, int height, int distanceFromFloor, int direction, int arrowType, int modelId, boolean saveIcon) { int index = saveIcon ? getFreeIndex() : 7; if (index != -1) { if (direction < 2 || direction > 6) direction = 2; HintIcon icon = new HintIcon(coordX, coordY, height, distanceFromFloor, direction, arrowType, modelId, index); player.getPackets().sendHintIcon(icon); if (saveIcon) loadedIcons[index] = icon; } return index; } public int addHintIcon(int modelId, boolean saveIcon) { int index = saveIcon ? getFreeIndex() : 7; if (index != -1) { HintIcon icon = new HintIcon(8, modelId, index); player.getPackets().sendHintIcon(icon); if (saveIcon) loadedIcons[index] = icon; } return index; } public void removeUnsavedHintIcon() { player.getPackets().sendHintIcon(new HintIcon()); } public boolean reloadHintIcon(int index) { if ((index >= loadedIcons.length) || (loadedIcons[index] == null)) return false; player.getPackets().sendHintIcon(loadedIcons[index]); return true; } public boolean removeHintIcon(int index) { if (index == 7) { removeUnsavedHintIcon(); return true; } if ((index >= loadedIcons.length) || (loadedIcons[index] == null)) return false; loadedIcons[index].setTargetType(0); player.getPackets().sendHintIcon(loadedIcons[index]); loadedIcons[index] = null; return true; } public void removeAll() { for (int index = 0; index < loadedIcons.length; index++) if (loadedIcons[index] != null) { loadedIcons[index].setTargetType(0); player.getPackets().sendHintIcon(loadedIcons[index]); loadedIcons[index] = null; } } public boolean isEmpty() { for (HintIcon loadedIcon : loadedIcons) if (loadedIcon != null) return false; return true; } private int getFreeIndex() { for (int index = 0; index < loadedIcons.length; index++) if (loadedIcons[index] == null) return index; return -1; } public boolean hasHintIcon(int index) { if (index >= loadedIcons.length) return false; return loadedIcons[index] != null; } }" "package com.rs.game.model.entity.player.managers; public class InterfaceManager { public static final int FIXED_TOP = 548; public static final int RESIZEABLE_TOP = 746; public static final int CHATBOX_TOP = 752; public static final int CHATBOX_SUB = 13; private final Player player; private int top; private final Map openedInterfaces = new ConcurrentHashMap<>(); public enum ScreenMode { FULLSCREEN, FIXED, RESIZEABLE, FULLSCREEN2MAYBE; public static ScreenMode forId(int id) { if (id < 0 || id >= ScreenMode.values().length) return null; return ScreenMode.values()[id]; } public boolean resizeable() { return this == RESIZEABLE || this == FULLSCREEN; } } public enum Sub { /* GAME WINDOWS */ RENDER_SPACE(48, 0), CENTRAL(29, 44), //CENTRAL_SMALL(10, 44), FULL_GAMESPACE_BG(2, 28), FULL_GAMESPACE_BG2(11, 29), MINIGAME_HUD(12, 47), FADING(13, 48), ABOVE_CHATBOX(27, 43), LEVEL_UP(35, 46), ACHIEVEMENT_NOTIF(41, 271), FULLSCREEN_BG(42, 15), FULLSCREEN_BG2(44, 17), FULLSCREEN_FG(45, 18), FULLSCREEN_FG2(46, 204), /* HUD */ CHATBOX(22, 168, CHATBOX_TOP), CHATBAR_SETTINGS(23, 53, 751, p -> p.getInterfaceManager().sendChatBoxInterface(9, 137)), MULTICOMBAT_SIGN(16, 40, 745), SYSTEM_UPDATE(25, 42, 754), LOGOUT(130, 194, 182), XP_DROPS(39, 16, 1213, p -> p.getPackets().setIFHidden(p.resizeable() ? RESIZEABLE_TOP : FIXED_TOP, p.resizeable() ? 39 : 16, !p.getSkills().xpDropsActive())), XP_COUNTER(202, 50, 1215), /* TABS */ /* CONFIRMED */ ORB_HP(196, 160, 748), /* CONFIRMED */ ORB_PRAYER(197, 161, 749), /* CONFIRMED */ ORB_SUMMONING(199, 164, 747), /* CONFIRMED */ ORB_RUN(198, 162, 750, Player::sendRunButtonConfig), /* CONFIRMED */ ORB_MONEYPOUCH(208, 167), /* CONFIRMED */ INVENTORY_OVERLAY(109, 172), /* CONFIRMED */ TAB_COMBAT(112, 176, 884, p -> p.getCombatDefinitions().sendUnlockAttackStylesButtons()), /* CONFIRMED */ TAB_ACHIEVEMENT(113, 177, 1056, AchievementInterface::init), /* CONFIRMED */ TAB_SKILLS(114, 178, 320), /* CONFIRMED */ TAB_QUEST(115, 179, 190, p -> p.getQuestManager().unlockQuestTabOptions()), /* CONFIRMED */ TAB_INVENTORY(116, 180, Inventory.INVENTORY_INTERFACE, p -> p.getInventory().unlockInventoryOptions()), /* CONFIRMED */ TAB_EQUIPMENT(117, 181, 387), /* CONFIRMED */ TAB_PRAYER(118, 182, 271, p -> p.getPrayer().unlockPrayerBookButtons()), /* CONFIRMED */ TAB_MAGIC(119, 183) { @Override public int getDefaultInterfaceId(Player p) { return p.getCombatDefinitions().getSpellbook().interfaceId; } }, /* CONFIRMED */ TAB_FOLLOWER(120, 184), /* CONFIRMED */ TAB_FRIENDS(121, 185, 550), /* CONFIRMED */ TAB_FRIENDS_CHAT(122, 186, 1109), /* CONFIRMED */ TAB_CLAN_CHAT(123, 187, 1110), /* CONFIRMED */ TAB_SETTINGS(124, 188, 261), /* CONFIRMED */ TAB_EMOTES(125, 189, 590, p -> p.getEmotesManager().unlockEmotesBook()), /* CONFIRMED */ TAB_MUSIC(126, 190, 187, p -> p.getMusicsManager().unlockMusicPlayer()), /* CONFIRMED */ TAB_NOTES(127, 191, 34); public static final Sub[] ALL_GAME_TABS = { Sub.TAB_COMBAT, Sub.TAB_ACHIEVEMENT, Sub.TAB_SKILLS, Sub.TAB_QUEST, Sub.TAB_INVENTORY, Sub.TAB_EQUIPMENT, Sub.TAB_PRAYER, Sub.TAB_MAGIC, Sub.TAB_FOLLOWER, Sub.TAB_FRIENDS, Sub.TAB_FRIENDS_CHAT, Sub.TAB_CLAN_CHAT, Sub.TAB_SETTINGS, Sub.TAB_EMOTES, Sub.TAB_MUSIC, Sub.TAB_NOTES, Sub.ORB_RUN }; private static final Map BY_HASH = new HashMap<>(); static { for (Sub sub : Sub.values()) { if (BY_HASH.put(Utils.toInterfaceHash(FIXED_TOP, sub.fixed), sub) != null) System.err.println(""Duplicate fixed hash for: "" + sub + "" - "" + sub.fixed); if (BY_HASH.put(Utils.toInterfaceHash(RESIZEABLE_TOP, sub.resizeable), sub) != null) System.err.println(""Duplicate resizeable hash for: "" + sub + "" - "" + sub.resizeable); } } public static Sub forHash(int hash) { return BY_HASH.get(hash); } private final int resizeable; private final int fixed; private int defaultInter = -1; private Consumer defaultProcedure = p -> {}; Sub(int resizeable, int fixed) { this.resizeable = resizeable; this.fixed = fixed; } Sub(int resizeable, int fixed, int defaultInter) { this(resizeable, fixed); this.defaultInter = defaultInter; } Sub(int resizeable, int fixed, int defaultInterfaceId, Consumer defaultProcedure) { this(resizeable, fixed, defaultInterfaceId); this.defaultProcedure = defaultProcedure; } public int getComponent(boolean resizeableScreen) { return resizeableScreen ? resizeable : fixed; } public boolean isClicked(int interfaceId, int componentId) { return (interfaceId == RESIZEABLE_TOP && componentId == resizeable) || (interfaceId == FIXED_TOP && componentId == fixed); } public int getDefaultInterfaceId(Player player) { return defaultInter; } public int getHash(ScreenMode oldMode) { return Utils.toInterfaceHash(oldMode.resizeable() ? RESIZEABLE_TOP : FIXED_TOP, oldMode.resizeable() ? resizeable : fixed); } } public InterfaceManager(Player player) { this.player = player; } public void sendGameWindowSub(int resizable, int fixed, int interfaceId, boolean clickThrough) { sendSubSpecific(clickThrough, player.resizeable() ? RESIZEABLE_TOP : FIXED_TOP, player.resizeable() ? resizable : fixed, interfaceId); } public void removeGameWindowSub(int resizableComponentId, int fixedComponentId) { removeSubSpecific(player.resizeable() ? RESIZEABLE_TOP : FIXED_TOP, player.resizeable() ? resizableComponentId : fixedComponentId); } public void sendChatBoxInterface(int interfaceId) { sendSubSpecific(true, CHATBOX_TOP, CHATBOX_SUB, interfaceId); } public void sendChatBoxInterface(int componentId, int interfaceId) { sendSubSpecific(true, CHATBOX_TOP, componentId, interfaceId); } public void closeChatBoxInterface() { removeSubSpecific(CHATBOX_TOP, CHATBOX_SUB); } public boolean containsChatBoxInter() { return isSubOpen(CHATBOX_TOP, CHATBOX_SUB); } public boolean isSubOpen(int parentInterfaceId, int parentInterfaceComponentId) { return openedInterfaces.containsKey(getComponentUId(parentInterfaceId, parentInterfaceComponentId)); } public boolean isSubOpenWindow(int componentId) { return isSubOpen(player.resizeable() ? RESIZEABLE_TOP : FIXED_TOP, componentId); } public void sendSubSpecific(boolean clickThrough, int parentInterfaceId, int parentInterfaceComponentId, int interfaceId) { //Logger.debug(parentInterfaceId + "" - "" + parentInterfaceComponentId + "" - "" + interfaceId + "" - "" + clickThrough); int parentComponentUID = getComponentUId(parentInterfaceId, parentInterfaceComponentId); //int parentId = getInterfaceParentId(interfaceId); Integer oldInterface = openedInterfaces.get(parentComponentUID); if (oldInterface != null) clearChilds(oldInterface); openedInterfaces.put(parentComponentUID, interfaceId); player.getPackets().sendInterface(clickThrough, parentInterfaceId, parentInterfaceComponentId, interfaceId); } public void removeSubSpecific(int parentInterfaceId, int parentInterfaceComponentId) { removeInterfaceByParent(getComponentUId(parentInterfaceId, parentInterfaceComponentId)); } public void removeInterfaceByParent(int parentUID) { Integer removedInterface = openedInterfaces.remove(parentUID); if (removedInterface != null) { clearChilds(removedInterface); player.getPackets().closeInterface(parentUID); // if (player.getFamiliar() != null) // Familiar.sendLeftClickOption(player); } } public static int getComponentUId(int interfaceId, int componentId) { return interfaceId << 16 | componentId; } public int getInterfaceParentId(int interfaceId) { if (interfaceId == top) return -1; for (int key : openedInterfaces.keySet()) { int value = openedInterfaces.get(key); if (value == interfaceId) return key; } return -1; } private void clearChilds(int parentInterfaceId) { for (int key : openedInterfaces.keySet()) if (key >> 16 == parentInterfaceId) openedInterfaces.remove(key); } public void removeInterface(int interfaceId) { int parentUID = getInterfaceParentId(interfaceId); if (parentUID == -1) return; removeInterfaceByParent(parentUID); } public boolean topOpen(int interfaceId) { if (interfaceId == top) return true; for (int value : openedInterfaces.values()) if (value == interfaceId) return true; return false; } public void sendSub(Sub sub, int interfaceId, boolean clickThrough) { if (interfaceId == -1) return; sendGameWindowSub(sub.resizeable, sub.fixed, interfaceId, clickThrough); } public void sendSub(Sub sub, int interfaceId) { sendSub(sub, interfaceId, true); } public void removeSubs(Sub... subs) { for (Sub tab : subs) removeSub(tab); } public void removeSub(Sub sub) { removeGameWindowSub(sub.resizeable, sub.fixed); } public void sendSubDefault(Sub sub) { sendSub(sub, sub.getDefaultInterfaceId(player), true); if (sub.defaultProcedure != null) sub.defaultProcedure.accept(player); } public void sendSubDefaults(Sub... subs) { for (Sub sub : subs) sendSubDefault(sub); } public boolean isSubClick(Sub sub, int interfaceId, int componentId) { return sub.isClicked(interfaceId, componentId); } public void flashTab(Sub tab) { int tabId = switch(tab) { case TAB_COMBAT -> 1; case TAB_ACHIEVEMENT -> 2; case TAB_SKILLS -> 3; case TAB_QUEST -> 4; case TAB_INVENTORY -> 5; case TAB_EQUIPMENT -> 6; case TAB_PRAYER -> 7; case TAB_MAGIC -> 8; case TAB_FOLLOWER -> 9; case TAB_FRIENDS -> 10; case TAB_FRIENDS_CHAT -> 11; case TAB_CLAN_CHAT -> 12; case TAB_SETTINGS -> 13; case TAB_EMOTES -> 14; case TAB_MUSIC -> 15; case TAB_NOTES -> 16; case ORB_RUN -> 17; default -> 0; }; player.getVars().setVar(1021, tabId); } public void openTab(Sub tab) { int tabId = switch(tab) { case TAB_COMBAT -> 0; case TAB_ACHIEVEMENT -> 1; case TAB_SKILLS -> 2; case TAB_QUEST -> 3; case TAB_INVENTORY -> 4; case TAB_EQUIPMENT -> 5; case TAB_PRAYER -> 6; case TAB_MAGIC -> 7; case TAB_FOLLOWER -> 8; case TAB_FRIENDS -> 9; case TAB_FRIENDS_CHAT -> 10; case TAB_CLAN_CHAT -> 11; case TAB_SETTINGS -> 12; case TAB_EMOTES -> 13; case TAB_MUSIC -> 14; case TAB_NOTES -> 15; case ORB_RUN -> 16; default -> 0; }; player.getPackets().sendVarc(168, tabId); } public void flashTabOff() { player.getVars().setVar(1021, 0); } public final void sendInterfaces() { if (openedInterfaces != null) openedInterfaces.clear(); setDefaultTopInterface(); if (player.getFamiliar() != null && player.isRunning()) player.getFamiliar().sendMainConfigs(); for (Sub sub : Sub.values()) sendSubDefault(sub); player.getControllerManager().sendInterfaces(); } public final void switchDisplayModes(ScreenMode screenMode) { if (player.getScreenMode() == screenMode) return; Map old = new HashMap<>(openedInterfaces); for (int parentUid : old.keySet()) { Sub sub = Sub.forHash(parentUid); if (sub != null) removeSub(sub); } ScreenMode oldMode = player.getScreenMode(); player.setScreenMode(screenMode); openedInterfaces.clear(); setDefaultTopInterface(); if (player.getFamiliar() != null && player.isRunning()) player.getFamiliar().sendMainConfigs(); for (Sub sub : Sub.values()) { // sendSubDefault(sub); Integer prev = old.get(sub.getHash(oldMode)); if (prev != null) { sendSub(sub, prev, sub != Sub.CENTRAL); if (sub.defaultProcedure != null) sub.defaultProcedure.accept(player); } } } public void sendInterface(int interfaceId) { if (interfaceId > Utils.getInterfaceDefinitionsSize()) return; sendSub(Sub.CENTRAL, interfaceId, false); } public void sendInterface(int interfaceId, boolean clickThrough) { if (interfaceId > Utils.getInterfaceDefinitionsSize()) return; sendSub(Sub.CENTRAL, interfaceId, clickThrough); } public void sendInventoryInterface(int interfaceId) { sendSub(Sub.INVENTORY_OVERLAY, interfaceId, false); } public boolean containsReplacedChatBoxInter() { return isSubOpen(CHATBOX_TOP, 11); } public void replaceRealChatBoxInterface(int interfaceId) { sendSubSpecific(true, CHATBOX_TOP, 11, interfaceId); } public void closeReplacedRealChatBoxInterface() { removeSubSpecific(CHATBOX_TOP, 11); } public void setDefaultTopInterface() { setTopInterface(player.resizeable() ? RESIZEABLE_TOP : FIXED_TOP, false); } public void setTopInterface(int rootInterface, boolean gc) { top = rootInterface; player.getPackets().sendWindowsPane(rootInterface, gc ? 3 : 0); } public void setWindowsPane(int windowsPane) { top = windowsPane; player.getPackets().sendWindowsPane(top, 2); } public void sendAchievementComplete(Achievement achievement) { if (achievement == null) return; sendSub(Sub.ACHIEVEMENT_NOTIF, 1055); player.getPackets().sendVarc(1425, achievement.getId()); } public boolean containsScreenInter() { return isSubOpenWindow(player.resizeable() ? Sub.CENTRAL.resizeable : Sub.CENTRAL.fixed); } public boolean containsInventoryInter() { return isSubOpenWindow(Sub.INVENTORY_OVERLAY.getComponent(player.resizeable())); } public void removeInventoryInterface() { this.removeSub(Sub.INVENTORY_OVERLAY); } public void setFadingInterface(int interfaceId) { sendSub(Sub.FADING, interfaceId); } public void closeFadingInterface() { removeSub(Sub.FADING); } public void removeCentralInterface() { removeSub(Sub.CENTRAL); } public void setFullscreenInterface(int backgroundInterface, int interfaceId) { removeCentralInterface(); sendSub(Sub.FULLSCREEN_BG, backgroundInterface, false); sendSub(Sub.FULLSCREEN_BG2, interfaceId, false); player.setCloseInterfacesEvent(() -> removeSubs(Sub.FULLSCREEN_BG, Sub.FULLSCREEN_BG2)); } public int getTopInterface() { return top; } public void gazeOrbOfOculus() { setTopInterface(475, false); sendSubSpecific(true, 475, 57, 751); sendSubSpecific(true, 475, 55, 752); player.setCloseInterfacesEvent(() -> { setDefaultTopInterface(); player.getPackets().sendResetCamera(); }); } public void fadeIn() { setFadingInterface(115); } public void fadeOut() { setFadingInterface(170); } public void fadeInBG() { sendBackgroundInterfaceOverGameWindow(115); } public void fadeOutBG() { sendBackgroundInterfaceOverGameWindow(170); } public void sendBackgroundInterfaceOverGameWindow(int id) { sendSub(Sub.FULLSCREEN_BG, id); } public void sendForegroundInterfaceOverGameWindow(int id) { sendSub(Sub.FULLSCREEN_BG2, id); } public void closeInterfacesOverGameWindow() { removeSubs(Sub.FULLSCREEN_BG, Sub.FULLSCREEN_BG2); } public void removeOverlay(boolean fullGameWindow) { removeSub(fullGameWindow ? Sub.FULL_GAMESPACE_BG2 : Sub.MINIGAME_HUD); } public void removeOverlay() { removeOverlay(false); } public void sendOverlay(int id, boolean fullGameWindow) { sendSub(fullGameWindow ? Sub.FULL_GAMESPACE_BG2 : Sub.MINIGAME_HUD, id); } public void sendOverlay(int id) { sendOverlay(id, false); } }" "package com.rs.game.model.entity.player.managers; @PluginEventHandler public final class MusicsManager { private static final int[] CONFIG_IDS = {20, 21, 22, 23, 24, 25, 298, 311, 346, 414, 464, 598, 662, 721, 906, 1009, 1104, 1136, 1180, 1202, 1381, 1394, 1434, 1596, 1618, 1619, 1620, 1865, 1864, 2246, 2019, -1, 2430, 2559}; private static final int[] PLAY_LIST_CONFIG_IDS = {1621, 1622, 1623, 1624, 1625, 1626}; private static final int NULL_SOUND_TRACK = 147; private transient Player player; private transient Genre playingGenre; private transient int playingMusic; private transient long playingMusicDelay; private transient boolean settedMusic; private final ArrayList unlockedMusics; private final ArrayList playList; private final Deque lastTenSongs = new ArrayDeque<>(); private transient boolean playListOn; private transient int nextPlayListMusic; private transient boolean shuffleOn; public MusicsManager() { unlockedMusics = new ArrayList<>(); playList = new ArrayList<>(12); // auto unlocked musics unlockedMusics.add(62); unlockedMusics.add(400); unlockedMusics.add(16); unlockedMusics.add(466); unlockedMusics.add(321); unlockedMusics.add(547); unlockedMusics.add(621); unlockedMusics.add(207); unlockedMusics.add(401); unlockedMusics.add(457); unlockedMusics.add(552); unlockedMusics.add(621); } public static ButtonClickHandler handlePlaylistButtons = new ButtonClickHandler(187, e -> { if (e.getComponentId() == 1) { if (e.getPacket() == ClientPacket.IF_OP1) e.getPlayer().getMusicsManager().playAnotherMusic(e.getSlotId() / 2); else if (e.getPacket() == ClientPacket.IF_OP2) e.getPlayer().getMusicsManager().sendHint(e.getSlotId() / 2); else if (e.getPacket() == ClientPacket.IF_OP3) e.getPlayer().getMusicsManager().addToPlayList(e.getSlotId() / 2); else if (e.getPacket() == ClientPacket.IF_OP4) e.getPlayer().getMusicsManager().removeFromPlayList(e.getSlotId() / 2); } else if (e.getComponentId() == 4) e.getPlayer().getMusicsManager().addPlayingMusicToPlayList(); else if (e.getComponentId() == 10) e.getPlayer().getMusicsManager().switchPlayListOn(); else if (e.getComponentId() == 11) e.getPlayer().getMusicsManager().clearPlayList(); else if (e.getComponentId() == 13) e.getPlayer().getMusicsManager().switchShuffleOn(); }); /** * Only for debug use * */ public void clearUnlocked() { unlockedMusics.clear(); unlockedMusics.add(62); unlockedMusics.add(400); unlockedMusics.add(16); unlockedMusics.add(466); unlockedMusics.add(321); unlockedMusics.add(547); unlockedMusics.add(621); unlockedMusics.add(207); unlockedMusics.add(401); unlockedMusics.add(457); unlockedMusics.add(552); } public void passMusics(Player p) { for (int musicId : p.getMusicsManager().unlockedMusics) if (!unlockedMusics.contains(musicId)) unlockedMusics.add(musicId); } public boolean hasMusic(int id) { return unlockedMusics.contains(id); } public void setPlayer(Player player) { this.player = player; playingMusic = ChunkManager.getChunk(player.getChunkId()).getMusicId(); } public void switchShuffleOn() { if (shuffleOn) { playListOn = false; refreshPlayListConfigs(); } shuffleOn = !shuffleOn; } public int getPlayingMusicId() { return playingMusic; } public void switchPlayListOn() { if (playListOn) { playListOn = false; shuffleOn = false; refreshPlayListConfigs(); } else { playListOn = true; nextPlayListMusic = 0; nextAmbientSong(); } } public void clearPlayList() { if (playList.isEmpty()) return; playList.clear(); refreshPlayListConfigs(); } public void addPlayingMusicToPlayList() { addToPlayList((int) EnumDefinitions.getEnum(1351).getKeyForValue(playingMusic)); } public void addToPlayList(int musicIndex) { if (playList.size() == 12) return; int musicId = EnumDefinitions.getEnum(1351).getIntValue(musicIndex); if (musicId != -1 && unlockedMusics.contains(musicId) && !playList.contains(musicId)) { playList.add(musicId); if (playListOn) switchPlayListOn(); else refreshPlayListConfigs(); } } public void removeFromPlayList(int musicIndex) { Integer musicId = EnumDefinitions.getEnum(1351).getIntValue(musicIndex); if (musicId != -1 && unlockedMusics.contains(musicId) && playList.contains(musicId)) { playList.remove(musicId); if (playListOn) switchPlayListOn(); else refreshPlayListConfigs(); } } public void refreshPlayListConfigs() { int[] configValues = new int[PLAY_LIST_CONFIG_IDS.length]; Arrays.fill(configValues, -1); for (int i = 0; i < playList.size(); i += 2) { Integer musicId1 = playList.get(i); Integer musicId2 = (i + 1) >= playList.size() ? null : playList.get(i + 1); if (musicId1 == null && musicId2 == null) break; int musicIndex = (int) EnumDefinitions.getEnum(1351).getKeyForValue(musicId1); int configValue; if (musicId2 != null) { int musicIndex2 = (int) EnumDefinitions.getEnum(1351).getKeyForValue(musicId2); configValue = musicIndex | musicIndex2 << 15; } else configValue = musicIndex | -1 << 15; configValues[i / 2] = configValue; } for (int i = 0; i < PLAY_LIST_CONFIG_IDS.length; i++) if (PLAY_LIST_CONFIG_IDS[i] == -1) player.getVars().setVar(PLAY_LIST_CONFIG_IDS[i], configValues[i]); } public void refreshListConfigs() { int[] configValues = new int[CONFIG_IDS.length]; for (int musicId : unlockedMusics) { int musicIndex = (int) EnumDefinitions.getEnum(1351).getKeyForValue(musicId); if (musicIndex == -1) continue; int index = getConfigIndex(musicIndex); if (index >= CONFIG_IDS.length) continue; configValues[index] |= 1 << (musicIndex - (index * 32)); } for (int i = 0; i < CONFIG_IDS.length; i++) if (CONFIG_IDS[i] != -1 && configValues[i] != 0) player.getVars().setVar(CONFIG_IDS[i], configValues[i]); } public void addMusicToUnlockedList(int musicId) { unlockedMusics.add(musicId); refreshListConfigs(); } public int unlockedMusicCount() { return unlockedMusics.size(); } public Genre getPlayingGenre() { return playingGenre; } public int getConfigIndex(int musicId) { return (musicId + 1) / 32; } public void unlockMusicPlayer() { player.getPackets().setIFRightClickOps(187, 1, 0, CONFIG_IDS.length * 64, 0, 1, 2, 3); } public void init() { refreshListConfigs(); refreshPlayListConfigs(); } public boolean musicEnded() { return playingMusic != NULL_SOUND_TRACK && playingMusicDelay + (180000) < System.currentTimeMillis(); } /** * Next ambient song by genre or region. */ public void nextAmbientSong() { if (player.getCutsceneManager().hasCutscene()) return; if (player.getControllerManager().getController() != null && !player.getControllerManager().getController().playAmbientMusic()) return; if (playListOn && playList.size() > 0)//playlist pickPlaylistSong(); else if (unlockedMusics.size() > 0) {//ambient music at random lastTenSongs.addFirst(playingMusic); if(lastTenSongs.size() > 10) lastTenSongs.removeLast(); if (player.getControllerManager().getController() != null && player.getControllerManager().getController().playAmbientStrictlyBackgroundMusic()) pickAmbientStrictlyBackgroundMusic(); else pickAmbientSong(); } playSongWithoutUnlocking(playingMusic); } public void playSpecificAmbientSong(int song) { playSpecificAmbientSong(song, false); } /** * Play song but not * 1. if in the last ten * 2. if a playlist is on * @param song */ public void playSpecificAmbientSong(int song, boolean unlock) { if(playListOn && playList.size() > 0) return; lastTenSongs.addFirst(playingMusic); if(lastTenSongs.size() > 10) lastTenSongs.removeLast(); if(lastTenSongs.contains(song)) return; if(unlock) { playSongAndUnlock(song); return; } playSongWithoutUnlocking(song); } /** * Only for use in nextAmbientSong */ private void pickPlaylistSong() { if (shuffleOn) playingMusic = playList.get(Utils.getRandomInclusive(playList.size() - 1)); else { if (nextPlayListMusic >= playList.size()) nextPlayListMusic = 0; playingMusic = playList.get(nextPlayListMusic++); } } /** * Only for use with dungeoneering. It does not include unlocked musics */ private void pickAmbientStrictlyBackgroundMusic() { playingGenre = player.getControllerManager().getController().getGenre(); if (playingGenre == null) { playingMusic = NULL_SOUND_TRACK;//don't play music return; } List genreSongs = Arrays.stream(playingGenre.getSongs()).boxed().collect(Collectors.toList()); cycleMusic(null, genreSongs); } /** * Only for use in nextAmbientSong. */ private void pickAmbientSong() { playingGenre = player.getControllerManager().getController() == null ? Music.getGenre(player) : player.getControllerManager().getController().getGenre(); if (playingGenre == null) { playingMusic = NULL_SOUND_TRACK;//don't play music. } else { //genre song ids int[] -> list<> List genreSongs = Arrays.stream(playingGenre.getSongs()).boxed().collect(Collectors.toList()); genreSongs.retainAll(new ArrayList<>() { private static final long serialVersionUID = 1L; { //Unlocked music or allowed ambient music inside the genre & region music addAll(unlockedMusics); addAll(Music.getAllowAmbientMusic()); } }); //Tack on region music to local genre. List regionSongs = new ArrayList<>(); try { regionSongs.addAll((Arrays.stream(Music.getRegionMusics(player.getRegionId())).boxed().toList())); } catch (NullPointerException e) { //empty song region } cycleMusic(regionSongs, genreSongs); } } private void cycleMusic(List regionSongs, List genreSongs) { if(regionSongs != null && regionSongs.size() > 0) { int attempts = regionSongs.size(); for (int i = 0; i < attempts; i++) { int random = Utils.random(regionSongs.size()); if(!lastTenSongs.contains(regionSongs.get(random))) { playingMusic = regionSongs.get(random); return; } else regionSongs.remove(random); } } if(genreSongs == null || genreSongs.size() <= 0) return; int attempts = genreSongs.size(); for (int i = 0; i < attempts; i++) { int random = Utils.random(genreSongs.size()); if(!lastTenSongs.contains(genreSongs.get(random))) { playingMusic = genreSongs.get(random); return; } else genreSongs.remove(random); } playingMusic = NULL_SOUND_TRACK;//Don't play music. } public void playSongWithoutUnlocking(int musicId) { if (!player.hasStarted()) return; playingMusicDelay = System.currentTimeMillis(); if (musicId == NULL_SOUND_TRACK || Music.getSong(musicId) == null) { playingMusic = musicId; player.musicTrack(NULL_SOUND_TRACK); player.getPackets().setIFText(187, 4, """"); return; } Song song = Music.getSong(musicId); player.getPackets().setIFText(187, 4, song.getName() != null ? song.getName() : """"); player.musicTrack(musicId, playingMusic == NULL_SOUND_TRACK ? 0 : 100); playingMusic = musicId; } /** * Plays music if checked music is not on but includes hints * * @param requestMusicId */ public void checkMusic(int requestMusicId) { if (playListOn || settedMusic && playingMusicDelay + (180000) >= System.currentTimeMillis()) return; settedMusic = false; if (playingMusic != requestMusicId) playSongWithoutUnlocking(requestMusicId); playingGenre = Music.getGenre(player); } public void forcePlayMusic(int musicId) { settedMusic = true; playSongWithoutUnlocking(musicId); } public boolean isPlaying(int requestMusicId) { return playingMusic == requestMusicId; } public void reset() { settedMusic = false; player.getMusicsManager().checkMusic(ChunkManager.getChunk(player.getChunkId()).getMusicId()); } public void sendHint(int slotId) { int musicId = EnumDefinitions.getEnum(1351).getIntValue(slotId); Song song = Music.getSong(musicId); if (song == null) { player.sendMessage(""Error handling song: "" + musicId); return; } if (player.hasRights(Rights.DEVELOPER)) player.sendMessage(""Music id: "" + musicId); if (musicId != NULL_SOUND_TRACK) player.sendMessage(""This track "" + (unlockedMusics.contains(musicId) ? ""was unlocked"" : ""unlocks"") + "" "" + song.getHint()); } public void playAnotherMusic(int musicIndex) { int musicId = EnumDefinitions.getEnum(1351).getIntValue(musicIndex); if (musicId != -1 && unlockedMusics.contains(musicId)) { settedMusic = true; if (playListOn) switchPlayListOn(); playSongWithoutUnlocking(musicId); } } public void playSongAndUnlock(int musicId) { if (!player.hasStarted()) return; playingMusicDelay = System.currentTimeMillis(); if (musicId == NULL_SOUND_TRACK) { playingMusic = musicId; player.musicTrack(NULL_SOUND_TRACK); player.getPackets().setIFText(187, 4, """"); return; } player.musicTrack(musicId, playingMusic == NULL_SOUND_TRACK ? 0 : 100); playingMusic = musicId; Song song = Music.getSong(musicId); if (song != null) { player.getPackets().setIFText(187, 4, song.getName() != null ? song.getName() : """"); if (!unlockedMusics.contains(musicId)) { addMusicToUnlockedList(musicId); if (song.getName() != null) player.sendMessage(""You have unlocked a new play play music track: "" + song.getName() + "".""); } } } public void unlockMusic(int musicId) { Song song = Music.getSong(musicId); if (song != null) if (!unlockedMusics.contains(musicId)) { addMusicToUnlockedList(musicId); if (song.getName() != null) player.sendMessage(""You have unlocked unlocked a new music track: "" + song.getName() + "".""); } } public boolean isUnlocked(int musicId) { Song song = Music.getSong(musicId); if (song != null) return unlockedMusics.contains(musicId); return false; } }" "package com.rs.game.model.entity.player.managers; @PluginEventHandler public class PrayerManager { private enum StatMod { ATTACK, STRENGTH, DEFENSE, RANGE, MAGE } private transient Player player; private transient CopyOnWriteArraySet active = new CopyOnWriteArraySet<>(); private transient int[] statMods; private transient boolean settingQuickPrayers; private transient boolean quickPrayersOn; private double points; private boolean curses; private CopyOnWriteArraySet quickPrays = new CopyOnWriteArraySet<>(); private CopyOnWriteArraySet quickCurses = new CopyOnWriteArraySet<>(); public static ButtonClickHandler handlePrayerInterface = new ButtonClickHandler(271, e -> { if (e.getComponentId() == 8 || e.getComponentId() == 42) e.getPlayer().getPrayer().switchPrayer(e.getSlotId()); else if (e.getComponentId() == 43 && e.getPlayer().getPrayer().settingQuickPrayers) e.getPlayer().getPrayer().switchSettingQuickPrayer(); }); public void switchPrayer(int prayerId) { Prayer prayer = Prayer.forSlot(prayerId, curses); if (prayer == null) return; if (active.contains(prayer) || (settingQuickPrayers && (quickPrays.contains(prayer) || quickCurses.contains(prayer)))) closePrayer(prayer); else activatePrayer(prayer); } private boolean canUsePrayer(Prayer prayer) { if (player.getSkills().getLevelForXp(Constants.PRAYER) < prayer.getReq()) { player.sendMessage(""You need a prayer level of at least "" + prayer.getReq() + "" to use this prayer.""); return false; } if (prayer.isCurse() && !player.isQuestComplete(Quest.TEMPLE_AT_SENNTISTEN, ""to use ancient curses."")) return false; switch(prayer) { case RAPID_RENEWAL: if (!player.hasRenewalPrayer) { player.sendMessage(""You must unlock this prayer as a dungeoneering reward.""); return false; } break; case RIGOUR: if (!player.hasRigour) { player.sendMessage(""You must unlock this prayer as a dungeoneering reward.""); return false; } break; case AUGURY: if (!player.hasAugury) { player.sendMessage(""You must unlock this prayer as a dungeoneering reward.""); return false; } break; case CHIVALRY: if (player.getSkills().getLevelForXp(Constants.DEFENSE) < 65) { player.sendMessage(""You need a defence level of at least 65 to use this prayer.""); return false; } break; case PIETY: if (player.getSkills().getLevelForXp(Constants.DEFENSE) < 70) { player.sendMessage(""You need a defence level of at least 70 to use this prayer.""); return false; } break; case PROTECT_MAGIC: case PROTECT_RANGE: case PROTECT_SUMMONING: case PROTECT_MELEE: case DEFLECT_MAGIC: case DEFLECT_RANGE: case DEFLECT_SUMMONING: case DEFLECT_MELEE: if (player.isProtectionPrayBlocked()) { player.sendMessage(""You are currently injured and cannot use protection prayers!""); return false; } break; default: break; } return true; } private boolean activatePrayer(Prayer prayer) { if (!canUsePrayer(prayer)) return false; switch(prayer) { case ATK_T1: case ATK_T2: case ATK_T3: closePrayers(Prayer.ATK_T1, Prayer.ATK_T2, Prayer.ATK_T3, Prayer.RNG_T1, Prayer.RNG_T2, Prayer.RNG_T3, Prayer.MAG_T1, Prayer.MAG_T2, Prayer.MAG_T3, Prayer.CHIVALRY, Prayer.PIETY, Prayer.RIGOUR, Prayer.AUGURY); break; case STR_T1: case STR_T2: case STR_T3: closePrayers(Prayer.STR_T1, Prayer.STR_T2, Prayer.STR_T3, Prayer.RNG_T1, Prayer.RNG_T2, Prayer.RNG_T3, Prayer.MAG_T1, Prayer.MAG_T2, Prayer.MAG_T3, Prayer.CHIVALRY, Prayer.PIETY, Prayer.RIGOUR, Prayer.AUGURY); break; case DEF_T1: case DEF_T2: case DEF_T3: closePrayers(Prayer.DEF_T1, Prayer.DEF_T2, Prayer.DEF_T3, Prayer.CHIVALRY, Prayer.PIETY, Prayer.RIGOUR, Prayer.AUGURY); break; case RNG_T1: case RNG_T2: case RNG_T3: closePrayers(Prayer.ATK_T1, Prayer.ATK_T2, Prayer.ATK_T3, Prayer.STR_T1, Prayer.STR_T2, Prayer.STR_T3, Prayer.RNG_T1, Prayer.RNG_T2, Prayer.RNG_T3, Prayer.MAG_T1, Prayer.MAG_T2, Prayer.MAG_T3, Prayer.CHIVALRY, Prayer.PIETY, Prayer.RIGOUR, Prayer.AUGURY); break; case MAG_T1: case MAG_T2: case MAG_T3: closePrayers(Prayer.ATK_T1, Prayer.ATK_T2, Prayer.ATK_T3, Prayer.STR_T1, Prayer.STR_T2, Prayer.STR_T3, Prayer.RNG_T1, Prayer.RNG_T2, Prayer.RNG_T3, Prayer.MAG_T1, Prayer.MAG_T2, Prayer.MAG_T3, Prayer.CHIVALRY, Prayer.PIETY, Prayer.RIGOUR, Prayer.AUGURY); break; case CHIVALRY: case PIETY: case RIGOUR: case AUGURY: closePrayers(Prayer.ATK_T1, Prayer.ATK_T2, Prayer.ATK_T3, Prayer.STR_T1, Prayer.STR_T2, Prayer.STR_T3); closePrayers(Prayer.RNG_T1, Prayer.RNG_T2, Prayer.RNG_T3, Prayer.MAG_T1, Prayer.MAG_T2, Prayer.MAG_T3); closePrayers(Prayer.DEF_T1, Prayer.DEF_T2, Prayer.DEF_T3, Prayer.CHIVALRY, Prayer.PIETY, Prayer.RIGOUR, Prayer.AUGURY); break; case RAPID_RENEWAL: case RAPID_HEAL: closePrayers(Prayer.RAPID_RENEWAL, Prayer.RAPID_HEAL); break; case PROTECT_MAGIC: case PROTECT_RANGE: case PROTECT_MELEE: closePrayers(Prayer.PROTECT_MAGIC, Prayer.PROTECT_RANGE, Prayer.PROTECT_MELEE, Prayer.RETRIBUTION, Prayer.REDEMPTION, Prayer.SMITE); break; case PROTECT_SUMMONING: closePrayers(Prayer.PROTECT_SUMMONING, Prayer.RETRIBUTION, Prayer.REDEMPTION, Prayer.SMITE); break; case SMITE: case REDEMPTION: case RETRIBUTION: closePrayers(Prayer.PROTECT_MAGIC, Prayer.PROTECT_RANGE, Prayer.PROTECT_MELEE, Prayer.PROTECT_SUMMONING, Prayer.RETRIBUTION, Prayer.REDEMPTION, Prayer.SMITE); break; case PROTECT_ITEM_C: if (!settingQuickPrayers) { player.setNextAnimation(new Animation(12567)); player.setNextSpotAnim(new SpotAnim(2213)); } break; case BERSERKER: if (!settingQuickPrayers) { player.setNextAnimation(new Animation(12589)); player.setNextSpotAnim(new SpotAnim(2266)); } break; case SAP_WARRIOR: if (!settingQuickPrayers) { player.setNextAnimation(new Animation(12569)); player.setNextSpotAnim(new SpotAnim(2214)); player.soundEffect(8115, true); } closePrayers(Prayer.TURMOIL, Prayer.LEECH_ATTACK, Prayer.LEECH_STRENGTH, Prayer.LEECH_DEFENSE); break; case SAP_MAGE: if (!settingQuickPrayers) { player.setNextAnimation(new Animation(12569)); player.setNextSpotAnim(new SpotAnim(2220)); player.soundEffect(8115, true); } closePrayers(Prayer.TURMOIL, Prayer.LEECH_MAGIC); break; case SAP_RANGE: if (!settingQuickPrayers) { player.setNextAnimation(new Animation(12569)); player.setNextSpotAnim(new SpotAnim(2217)); player.soundEffect(8115, true); } closePrayers(Prayer.TURMOIL, Prayer.LEECH_RANGE); break; case SAP_SPIRIT: if (!settingQuickPrayers) { player.setNextAnimation(new Animation(12569)); player.setNextSpotAnim(new SpotAnim(2223)); player.soundEffect(8115, true); } closePrayers(Prayer.TURMOIL, Prayer.LEECH_SPECIAL, Prayer.LEECH_ENERGY); break; case LEECH_ATTACK: if (!settingQuickPrayers) { player.setNextAnimation(new Animation(12575)); player.setNextSpotAnim(new SpotAnim(2232)); player.soundEffect(8110, true); } closePrayers(Prayer.TURMOIL, Prayer.SAP_WARRIOR); break; case LEECH_STRENGTH: if (!settingQuickPrayers) { player.setNextAnimation(new Animation(12575)); player.setNextSpotAnim(new SpotAnim(2250)); player.soundEffect(8110, true); } closePrayers(Prayer.TURMOIL, Prayer.SAP_WARRIOR); break; case LEECH_DEFENSE: if (!settingQuickPrayers) { player.setNextAnimation(new Animation(12575)); player.setNextSpotAnim(new SpotAnim(2246)); player.soundEffect(8110, true); } closePrayers(Prayer.TURMOIL, Prayer.SAP_WARRIOR); break; case LEECH_RANGE: if (!settingQuickPrayers) { player.setNextAnimation(new Animation(12575)); player.setNextSpotAnim(new SpotAnim(2238)); player.soundEffect(8110, true); } closePrayers(Prayer.TURMOIL, Prayer.SAP_RANGE); break; case LEECH_MAGIC: if (!settingQuickPrayers) { player.setNextAnimation(new Animation(12575)); player.setNextSpotAnim(new SpotAnim(2242)); player.soundEffect(8110, true); } closePrayers(Prayer.TURMOIL, Prayer.SAP_MAGE); break; case LEECH_SPECIAL: if (!settingQuickPrayers) { player.setNextAnimation(new Animation(12575)); player.setNextSpotAnim(new SpotAnim(2258)); player.soundEffect(8110, true); } break; case LEECH_ENERGY: if (!settingQuickPrayers) { player.setNextAnimation(new Animation(12575)); player.setNextSpotAnim(new SpotAnim(2254)); player.soundEffect(8110, true); } closePrayers(Prayer.TURMOIL, Prayer.SAP_SPIRIT); break; case DEFLECT_MAGIC: if (!settingQuickPrayers) { player.setNextSpotAnim(new SpotAnim(2228)); player.setNextAnimation(new Animation(12573)); } closePrayers(Prayer.DEFLECT_MAGIC, Prayer.DEFLECT_MELEE, Prayer.DEFLECT_RANGE, Prayer.WRATH, Prayer.SOUL_SPLIT); break; case DEFLECT_RANGE: if (!settingQuickPrayers) { player.setNextSpotAnim(new SpotAnim(2229)); player.setNextAnimation(new Animation(12573)); } closePrayers(Prayer.DEFLECT_MAGIC, Prayer.DEFLECT_MELEE, Prayer.DEFLECT_RANGE, Prayer.WRATH, Prayer.SOUL_SPLIT); break; case DEFLECT_MELEE: if (!settingQuickPrayers) { player.setNextSpotAnim(new SpotAnim(2230)); player.setNextAnimation(new Animation(12573)); } closePrayers(Prayer.DEFLECT_MAGIC, Prayer.DEFLECT_RANGE, Prayer.DEFLECT_MELEE, Prayer.WRATH, Prayer.SOUL_SPLIT); break; case DEFLECT_SUMMONING: if (!settingQuickPrayers) { player.setNextSpotAnim(new SpotAnim(2227)); player.setNextAnimation(new Animation(12573)); } closePrayers(Prayer.DEFLECT_SUMMONING, Prayer.WRATH, Prayer.SOUL_SPLIT); break; case WRATH: if (!settingQuickPrayers) { player.setNextAnimation(new Animation(12575)); } break; case SOUL_SPLIT: player.setNextAnimation(new Animation(12575)); player.setNextSpotAnim(new SpotAnim(2264)); player.soundEffect(8113, true); closePrayers(Prayer.DEFLECT_MAGIC, Prayer.DEFLECT_MELEE, Prayer.DEFLECT_RANGE, Prayer.DEFLECT_SUMMONING, Prayer.WRATH, Prayer.SOUL_SPLIT); break; case TURMOIL: closePrayers(Prayer.SAP_WARRIOR, Prayer.SAP_MAGE, Prayer.SAP_RANGE, Prayer.SAP_SPIRIT); closePrayers(Prayer.LEECH_ATTACK, Prayer.LEECH_STRENGTH, Prayer.LEECH_DEFENSE, Prayer.LEECH_MAGIC, Prayer.LEECH_RANGE, Prayer.LEECH_SPECIAL, Prayer.LEECH_ENERGY); if (!settingQuickPrayers) { player.setNextAnimation(new Animation(12565)); player.setNextSpotAnim(new SpotAnim(2226)); } break; default: break; } if (settingQuickPrayers) { if (curses) quickCurses.add(prayer); else quickPrays.add(prayer); } else { active.add(prayer); if (isOverhead(prayer)) player.getAppearance().generateAppearanceData(); if (prayer.getActivateSound() != -1) player.soundEffect(prayer.getActivateSound(), false); else player.soundEffect(2662, false); } refresh(); return true; } public void closePrayer(Prayer prayer) { if (settingQuickPrayers) { if (curses) quickCurses.remove(prayer); else quickPrays.remove(prayer); return; } if (!active.contains(prayer)) return; switch (prayer) { case LEECH_ATTACK: if (getStatMod(StatMod.ATTACK) > 0) player.sendMessage(""Your Attack is now unaffected by sap and leech curses."", true); setStatMod(StatMod.ATTACK, 0); break; case LEECH_STRENGTH: if (getStatMod(StatMod.STRENGTH) > 0) player.sendMessage(""Your Strength is now unaffected by sap and leech curses."", true); setStatMod(StatMod.STRENGTH, 0); break; case LEECH_DEFENSE: if (getStatMod(StatMod.DEFENSE) > 0) player.sendMessage(""Your Defense is now unaffected by sap and leech curses."", true); setStatMod(StatMod.DEFENSE, 0); break; case LEECH_RANGE: if (getStatMod(StatMod.RANGE) > 0) player.sendMessage(""Your Range is now unaffected by sap and leech curses."", true); setStatMod(StatMod.RANGE, 0); break; case LEECH_MAGIC: if (getStatMod(StatMod.MAGE) > 0) player.sendMessage(""Your Magic is now unaffected by sap and leech curses."", true); setStatMod(StatMod.MAGE, 0); break; case TURMOIL: setStatMod(StatMod.ATTACK, 0); setStatMod(StatMod.STRENGTH, 0); setStatMod(StatMod.DEFENSE, 0); break; default: break; } active.remove(prayer); if (isOverhead(prayer)) player.getAppearance().generateAppearanceData(); player.soundEffect(2663, false); if (active.isEmpty()) setQuickPrayersOn(false); refresh(); } public void closePrayers(Prayer... prayers) { for (Prayer p : prayers) closePrayer(p); } public int getPrayerHeadIcon() { if (active.isEmpty()) return -1; if (active.contains(Prayer.PROTECT_SUMMONING)) { if (active.contains(Prayer.PROTECT_MELEE)) return 8; if (active.contains(Prayer.PROTECT_RANGE)) return 9; if (active.contains(Prayer.PROTECT_MAGIC)) return 10; return 7; } if (active.contains(Prayer.DEFLECT_SUMMONING)) { if (active.contains(Prayer.DEFLECT_MELEE)) return 16; if (active.contains(Prayer.DEFLECT_RANGE)) return 17; if (active.contains(Prayer.DEFLECT_MAGIC)) return 18; return 15; } if (active.contains(Prayer.PROTECT_MELEE)) return 0; if (active.contains(Prayer.PROTECT_RANGE)) return 1; if (active.contains(Prayer.PROTECT_MAGIC)) return 2; else if (active.contains(Prayer.RETRIBUTION)) return 3; else if (active.contains(Prayer.SMITE)) return 4; else if (active.contains(Prayer.REDEMPTION)) return 5; else if (active.contains(Prayer.DEFLECT_MELEE)) return 12; else if (active.contains(Prayer.DEFLECT_MAGIC)) return 13; else if (active.contains(Prayer.DEFLECT_RANGE)) return 14; else if (active.contains(Prayer.WRATH)) return 19; else if (active.contains(Prayer.SOUL_SPLIT)) return 20; return -1; } public void processPrayer() { if (player.isDead() || !player.isRunning() || active.isEmpty()) return; double drain = 0; for (Prayer p : active) drain += p.getDrain(); drain /= 1.0 + ((1.0/30.0) * player.getCombatDefinitions().getBonus(Bonus.PRAYER)); if (drain > 0) { drainPrayer(drain); if (!checkPrayer()) { closeAllPrayers(); player.soundEffect(2673, false); } } if ((player.getTickCounter() % 10) == 0 && active(Prayer.TURMOIL, Prayer.SAP_MAGE, Prayer.SAP_RANGE, Prayer.SAP_SPIRIT, Prayer.SAP_WARRIOR, Prayer.LEECH_ATTACK, Prayer.LEECH_DEFENSE, Prayer.LEECH_STRENGTH, Prayer.LEECH_MAGIC, Prayer.LEECH_RANGE, Prayer.LEECH_SPECIAL, Prayer.LEECH_ENERGY)) if (player.getInteractionManager().getInteraction() instanceof PlayerCombatInteraction combat) if (active(Prayer.TURMOIL)) processTurmoil(combat.getAction().target); else processLeeches(combat.getAction().target); } private void processTurmoil(Entity target) { if (target == null) return; if (player.getTempAttribs().getO(""lastTurmTarget"") != target) { setTurmoilBonus(target); player.getTempAttribs().setO(""lastTurmTarget"", target); } } private void processLeeches(Entity target) { if (target == null) return; for (Sap sap : Sap.values()) if (active(sap.getPrayer()) && Utils.random(4) == 0) { sap.activate(player, target); player.setNextAnimation(new Animation(12569)); player.soundEffect(target, 8115, true); player.setNextSpotAnim(new SpotAnim(sap.getSpotAnimStart())); World.sendProjectile(player, target, sap.getProjAnim(), 35, 35, 20, 0.6, 0, p -> { if (target != null) target.setNextSpotAnim(new SpotAnim(sap.getSpotAnimHit())); player.soundEffect(target, 8116, true); }); } for (Leech leech : Leech.values()) if (active(leech.getPrayer()) && Utils.random(7) == 0) { leech.activate(player, target); player.setNextAnimation(new Animation(12575)); player.soundEffect(target, 8109, true); World.sendProjectile(player, target, leech.getProjAnim(), 35, 35, 20, 0.6, 0, p -> { if (target != null) target.setNextSpotAnim(new SpotAnim(leech.getSpotAnimHit())); player.soundEffect(target, 8110, true); }); } } private void setTurmoilBonus(Entity e) { if (e instanceof Player p2) { setStatMod(StatMod.ATTACK, (int) Math.floor(((100 * Math.floor(0.15 * p2.getSkills().getLevelForXp(Constants.ATTACK))) / player.getSkills().getLevelForXp(Constants.ATTACK)))); setStatMod(StatMod.STRENGTH, (int) Math.floor(((100 * Math.floor(0.1 * p2.getSkills().getLevelForXp(Constants.STRENGTH))) / player.getSkills().getLevelForXp(Constants.STRENGTH)))); setStatMod(StatMod.DEFENSE, (int) Math.floor(((100 * Math.floor(0.15 * p2.getSkills().getLevelForXp(Constants.DEFENSE))) / player.getSkills().getLevelForXp(Constants.DEFENSE)))); } else if (e instanceof NPC npc) { setStatMod(StatMod.ATTACK, (int) Math.floor(((100 * Math.floor(0.15 * Utils.clampI(npc.getAttackLevel(), 1, 99))) / player.getSkills().getLevelForXp(Constants.ATTACK)))); setStatMod(StatMod.STRENGTH, (int) Math.floor(((100 * Math.floor(0.1 * Utils.clampI(npc.getStrengthLevel(), 1, 99))) / player.getSkills().getLevelForXp(Constants.STRENGTH)))); setStatMod(StatMod.DEFENSE, (int) Math.floor(((100 * Math.floor(0.15 * Utils.clampI(npc.getDefenseLevel(), 1, 99))) / player.getSkills().getLevelForXp(Constants.DEFENSE)))); } updateStatMods(); } public void closeAllPrayers() { active.clear(); statMods = new int[5]; setQuickPrayersOn(false); player.getVars().setVar(curses ? 1582 : 1395, 0); player.getAppearance().generateAppearanceData(); resetStatMods(); } public void switchSettingQuickPrayer() { settingQuickPrayers = !settingQuickPrayers; refreshSettingQuickPrayers(); unlockPrayerBookButtons(); if (settingQuickPrayers) player.getInterfaceManager().openTab(Sub.TAB_PRAYER); } public void switchQuickPrayers() { if (!checkPrayer()) return; boolean wasOn = quickPrayersOn; boolean turnedOn = false; closeAllPrayers(); if (!wasOn) { if (curses) { for (Prayer curse : quickCurses) if (activatePrayer(curse)) turnedOn = true; } else for (Prayer prayer : quickPrays) if (activatePrayer(prayer)) turnedOn = true; setQuickPrayersOn(turnedOn); } } public void setQuickPrayersOn(boolean on) { quickPrayersOn = on; player.getPackets().sendVarc(182, quickPrayersOn ? 1 : 0); } public boolean checkPrayer() { if (points <= 0) { player.soundEffect(2672, false); player.sendMessage(""Please recharge your prayer at the Lumbridge Church.""); return false; } return true; } public void refresh() { for (Prayer p : Prayer.values()) { player.getVars().setVarBit(p.getVarBit(), active.contains(p) ? 1 : 0); player.getVars().setVarBit(p.getQPVarBit(), quickPrays.contains(p) || quickCurses.contains(p) ? 1 : 0); } player.getVars().setVar(1584, curses ? 1 : 0); } public void refreshSettingQuickPrayers() { player.getPackets().sendVarc(181, settingQuickPrayers ? 1 : 0); } public void init() { player.getVars().setVar(curses ? 1582 : 1395, 0); resetStatMods(); refresh(); refreshSettingQuickPrayers(); unlockPrayerBookButtons(); } public void unlockPrayerBookButtons() { player.getPackets().setIFRightClickOps(271, settingQuickPrayers ? 42 : 8, 0, 29, 0); } public void setPrayerBook(boolean curses) { if (curses && !player.isQuestComplete(Quest.TEMPLE_AT_SENNTISTEN, ""to use ancient curses."")) return; closeAllPrayers(); this.curses = curses; player.getInterfaceManager().sendSubDefault(Sub.TAB_PRAYER); refresh(); unlockPrayerBookButtons(); } public PrayerManager() { quickPrays = new CopyOnWriteArraySet<>(); quickCurses = new CopyOnWriteArraySet<>(); points = 10.0; } public void setPlayer(Player player) { this.player = player; active = new CopyOnWriteArraySet<>(); statMods = new int[5]; if (quickPrays == null) quickPrays = new CopyOnWriteArraySet<>(); if (quickCurses == null) quickCurses = new CopyOnWriteArraySet<>(); } private void resetStatMods() { for (StatMod mod : StatMod.values()) setStatMod(mod, 0); } private int getStatMod(StatMod mod) { return statMods[mod.ordinal()]; } private void setStatMod(StatMod mod, int bonus) { statMods[mod.ordinal()] = bonus; updateStatMod(mod); } public boolean decreaseStatModifier(StatMod mod, int bonus, int max) { if (statMods[mod.ordinal()] > max) { statMods[mod.ordinal()]--; updateStatMod(mod); return true; } return false; } public boolean increaseStatModifier(StatMod mod, int bonus, int max) { if (statMods[mod.ordinal()] < max) { statMods[mod.ordinal()]++; updateStatMod(mod); return true; } return false; } private void updateStatMod(StatMod mod) { player.getVars().setVarBit(6857 + mod.ordinal(), 30 + statMods[mod.ordinal()]); } private void updateStatMods() { for (StatMod m : StatMod.values()) updateStatMod(m); } public double getMageMultiplier() { if (active.isEmpty()) return 1.0; double value = 1.0; if (active(Prayer.MAG_T1)) value += 0.05; else if (active(Prayer.MAG_T2)) value += 0.10; else if (active(Prayer.MAG_T3)) value += 0.15; else if (active(Prayer.AUGURY)) value += 0.20; else if (active(Prayer.LEECH_MAGIC)) { double d = (5 + getStatMod(StatMod.MAGE)); value += d / 100; } return value; } public double getRangeMultiplier() { if (active.isEmpty()) return 1.0; double value = 1.0; if (active(Prayer.RNG_T1)) value += 0.05; else if (active(Prayer.RNG_T2)) value += 0.10; else if (active(Prayer.RNG_T3)) value += 0.15; else if (active(Prayer.RIGOUR)) value += 0.20; else if (active(Prayer.LEECH_RANGE)) { double d = (5 + getStatMod(StatMod.RANGE)); value += d / 100; } return value; } public double getAttackMultiplier() { if (active.isEmpty()) return 1.0; double value = 1.0; if (active(Prayer.ATK_T1)) value += 0.05; else if (active(Prayer.ATK_T2)) value += 0.10; else if (active(Prayer.ATK_T3)) value += 0.15; else if (active(Prayer.CHIVALRY)) value += 0.15; else if (active(Prayer.PIETY)) value += 0.20; else if (active(Prayer.LEECH_ATTACK)) { double d = (5 + getStatMod(StatMod.ATTACK)); value += d / 100; } else if (active(Prayer.TURMOIL)) { double d = (15 + getStatMod(StatMod.ATTACK)); value += d / 100; } return value; } public double getStrengthMultiplier() { if (active.isEmpty()) return 1.0; double value = 1.0; if (active(Prayer.STR_T1)) value += 0.05; else if (active(Prayer.STR_T2)) value += 0.10; else if (active(Prayer.STR_T3)) value += 0.15; else if (active(Prayer.CHIVALRY)) value += 0.18; else if (active(Prayer.PIETY)) value += 0.23; else if (active(Prayer.LEECH_STRENGTH)) { double d = (5 + getStatMod(StatMod.STRENGTH)); value += d / 100; } else if (active(Prayer.TURMOIL)) { double d = (23 + getStatMod(StatMod.STRENGTH)); value += d / 100; } return value; } public double getDefenceMultiplier() { if (active.isEmpty()) return 1.0; double value = 1.0; if (active(Prayer.DEF_T1)) value += 0.05; else if (active(Prayer.DEF_T2)) value += 0.10; else if (active(Prayer.DEF_T3)) value += 0.15; else if (active(Prayer.CHIVALRY)) value += 0.20; else if (active(Prayer.PIETY) || active(Prayer.RIGOUR) || active(Prayer.AUGURY)) value += 0.25; else if (active(Prayer.LEECH_DEFENSE)) { double d = (6 + getStatMod(StatMod.DEFENSE)); value += d / 100; } else if (active(Prayer.TURMOIL)) { double d = (15 + getStatMod(StatMod.DEFENSE)); value += d / 100; } return value; } public boolean isCurses() { return curses; } public double getPoints() { return points; } public void setPoints(double points) { this.points = points; refreshPoints(); } public void refreshPoints() { player.getVars().setVar(2382, (int) points); } public boolean hasFullPoints() { return getPoints() >= player.getSkills().getLevelForXp(Constants.PRAYER) * 10; } public void drainPrayer(double amount) { if (player.getNSV().getB(""infPrayer"")) return; points -= amount; if (points <= 0) points = 0; refreshPoints(); } public void drainPrayer() { if (player.getNSV().getB(""infPrayer"")) return; points = 0; refreshPoints(); } public void restorePrayer(double amount) { int maxPrayer = player.getSkills().getLevelForXp(Constants.PRAYER) * 10; amount *= player.getAuraManager().getPrayerResMul(); if ((points + amount) <= maxPrayer) points += amount; else points = maxPrayer; refreshPoints(); } public boolean active(Prayer... prayers) { for (Prayer prayer : prayers) if (active.contains(prayer)) return true; return false; } public static boolean isOverhead(Prayer p) { return switch (p) { case PROTECT_MAGIC, PROTECT_SUMMONING, PROTECT_RANGE, PROTECT_MELEE, RETRIBUTION, REDEMPTION, SMITE, DEFLECT_MELEE, DEFLECT_SUMMONING, DEFLECT_MAGIC, DEFLECT_RANGE, WRATH, SOUL_SPLIT -> true; default -> false; }; } public boolean isProtectingItem() { return active(Prayer.PROTECT_ITEM_C, Prayer.PROTECT_ITEM_N); } public boolean isProtectingMage() { return active(Prayer.PROTECT_MAGIC, Prayer.DEFLECT_MAGIC); } public boolean isProtectingRange() { return active(Prayer.PROTECT_RANGE, Prayer.DEFLECT_RANGE); } public boolean isProtectingMelee() { return active(Prayer.PROTECT_MELEE, Prayer.DEFLECT_MELEE); } public boolean hasProtectionPrayersOn() { return active(Prayer.PROTECT_MAGIC, Prayer.PROTECT_MELEE, Prayer.PROTECT_RANGE, Prayer.PROTECT_SUMMONING, Prayer.DEFLECT_MAGIC, Prayer.DEFLECT_MELEE, Prayer.DEFLECT_RANGE, Prayer.DEFLECT_SUMMONING); } public void reset() { closeAllPrayers(); points = player.getSkills().getLevelForXp(Constants.PRAYER) * 10; refreshPoints(); } public boolean isUsingProtectionPrayer() { return isProtectingMage() || isProtectingRange() || isProtectingMelee(); } public boolean hasPrayersOn() { return !active.isEmpty(); } public void worshipAltar(double multiplier) { double maxPray = player.getSkills().getLevelForXp(Constants.PRAYER) * 10.0; maxPray = (int) (maxPray * multiplier); if (points < maxPray) { player.lock(); player.sendMessage(""You pray to the gods..."", true); player.anim(645); double finalMaxPray = maxPray; player.getTasks().schedule(2, () -> { player.unlock(); restorePrayer(finalMaxPray); player.sendMessage(""...and recharged your prayer."", true); }); } } public void worshipAltar() { worshipAltar(1.0); } }" "package com.rs.game.model.entity.player.managers; @PluginEventHandler public class PriceChecker { public static void openPriceCheck(Player player) { player.getTempAttribs().setO(""pcContainer"", new ItemsContainer<>(28, false)); player.getTempAttribs().setO(""pcInvContainer"", new ItemsContainer<>(28, false)); ItemsContainer pc = player.getTempAttribs().getO(""pcContainer""); ItemsContainer inv = player.getTempAttribs().getO(""pcInvContainer""); for (int i = 0;i < player.getInventory().getItems().getItemsCopy().length;i++) { Item[] items = player.getInventory().getItems().getItemsCopy(); inv.set(i, items[i] == null ? null : new Item(items[i])); } player.getInterfaceManager().sendInterface(206); player.getInterfaceManager().sendInventoryInterface(207); sendInterItems(player); sendOptions(player); player.getPackets().sendVarc(728, 0); for (int i = 0; i < pc.getSize(); i++) player.getPackets().sendVarc(700 + i, 0); player.setCloseInterfacesEvent(() -> player.getInventory().init()); } public static int getSlotId(int clickSlotId) { return clickSlotId / 2; } public static void removeItem(Player player, int clickSlotId, int amount) { ItemsContainer pc = player.getTempAttribs().getO(""pcContainer""); ItemsContainer inv = player.getTempAttribs().getO(""pcInvContainer""); if (pc == null || inv == null) return; int slot = getSlotId(clickSlotId); Item item = pc.get(slot); if (item == null) return; Item[] itemsBefore = pc.getItemsCopy(); int maxAmount = pc.getNumberOf(item); if (amount < maxAmount) item = new Item(item.getId(), amount); else item = new Item(item.getId(), maxAmount); pc.remove(slot, item); inv.add(item); refreshItems(player, itemsBefore); } public static void addItem(Player player, int slot, int amount) { ItemsContainer pc = player.getTempAttribs().getO(""pcContainer""); ItemsContainer inv = player.getTempAttribs().getO(""pcInvContainer""); if (pc == null || inv == null) return; Item item = inv.get(slot); if (item == null) return; if (!ItemConstants.isTradeable(item)) { player.sendMessage(""That item isn't tradeable.""); return; } Item[] itemsBefore = pc.getItemsCopy(); int maxAmount = inv.getNumberOf(item); if (amount < maxAmount) item = new Item(item.getId(), amount); else item = new Item(item.getId(), maxAmount); pc.add(item); inv.remove(item); refreshItems(player, itemsBefore); } public static void refreshItems(Player player, Item[] itemsBefore) { ItemsContainer pc = player.getTempAttribs().getO(""pcContainer""); ItemsContainer inv = player.getTempAttribs().getO(""pcInvContainer""); if (pc == null || inv == null) return; int totalPrice = 0; int[] changedSlots = new int[itemsBefore.length]; int count = 0; for (int index = 0; index < itemsBefore.length; index++) { Item item = pc.array()[index]; if (item != null) totalPrice += EconomyPrices.getPrice(item.getId()) * item.getAmount(); if (itemsBefore[index] != item) { changedSlots[count++] = index; player.getPackets().sendVarc(700 + index, item == null ? 0 : EconomyPrices.getPrice(item.getId())); } } int[] finalChangedSlots = new int[count]; System.arraycopy(changedSlots, 0, finalChangedSlots, 0, count); refresh(player, finalChangedSlots); player.getPackets().sendVarc(728, totalPrice); } public static void refresh(Player player, int... slots) { ItemsContainer pc = player.getTempAttribs().getO(""pcContainer""); ItemsContainer inv = player.getTempAttribs().getO(""pcInvContainer""); if (pc == null || inv == null) return; player.getPackets().sendUpdateItems(90, pc, slots); player.getPackets().sendItems(93, inv); } public static void sendOptions(Player player) { player.getPackets().setIFRightClickOps(206, 15, 0, 54, 0, 1, 2, 3, 4, 5, 6); player.getPackets().setIFRightClickOps(207, 0, 0, 27, 0, 1, 2, 3, 4, 5); player.getPackets().sendInterSetItemsOptionsScript(207, 0, 93, 4, 7, ""Add"", ""Add-5"", ""Add-10"", ""Add-All"", ""Add-X"", ""Examine""); } public static void sendInterItems(Player player) { ItemsContainer pc = player.getTempAttribs().getO(""pcContainer""); ItemsContainer inv = player.getTempAttribs().getO(""pcInvContainer""); if (pc == null || inv == null) return; player.getPackets().sendItems(90, pc); player.getPackets().sendItems(93, inv); } public static ButtonClickHandler handleButtons = new ButtonClickHandler(new Object[] { 206, 207 }, e -> { if (e.getInterfaceId() == 206) { if (e.getComponentId() == 15) switch(e.getPacket()) { case IF_OP1: removeItem(e.getPlayer(), e.getSlotId(), 1); break; case IF_OP2: removeItem(e.getPlayer(), e.getSlotId(), 5); break; case IF_OP3: removeItem(e.getPlayer(), e.getSlotId(), 10); break; case IF_OP4: removeItem(e.getPlayer(), e.getSlotId(), Integer.MAX_VALUE); break; case IF_OP5: e.getPlayer().sendInputInteger(""Enter Amount:"", amount -> removeItem(e.getPlayer(), e.getSlotId(), amount)); break; default: break; } } else if (e.getInterfaceId() == 207) if (e.getComponentId() == 0) switch(e.getPacket()) { case IF_OP1: addItem(e.getPlayer(), e.getSlotId(), 1); break; case IF_OP2: addItem(e.getPlayer(), e.getSlotId(), 5); break; case IF_OP3: addItem(e.getPlayer(), e.getSlotId(), 10); break; case IF_OP4: addItem(e.getPlayer(), e.getSlotId(), Integer.MAX_VALUE); break; case IF_OP5: e.getPlayer().sendInputInteger(""Enter Amount:"", amount -> addItem(e.getPlayer(), e.getSlotId(), amount)); break; case IF_OP6: e.getPlayer().getInventory().sendExamine(e.getSlotId()); break; default: break; } }); }" "package com.rs.game.model.entity.player.social; @PluginEventHandler public class FCManager { private static final int FC_SETUP_INTER = 1108; private static final int FC_TAB = 1109; private static final Map FRIEND_CHATS = new ConcurrentHashMap<>(); public static ButtonClickHandler handleInterface = new ButtonClickHandler(FC_SETUP_INTER, e -> { switch (e.getComponentId()) { case 1 -> { switch (e.getPacket()) { case IF_OP1 -> e.getPlayer().sendInputName(""Enter chat prefix:"", str -> { e.getPlayer().getSocial().getFriendsChat().setName(str); LobbyCommunicator.updateFC(e.getPlayer(), res -> { if (res == null) e.getPlayer().sendMessage(""Error communicating with social service.""); else refreshFC(e.getPlayer()); }); }); case IF_OP2 -> e.getPlayer().getSocial().getFriendsChat().setName(null); // TODO when fc block update is // sent, check if name was // set to null and destroy // chat default -> e.getPlayer().sendMessage(""Unexpected FC interface packet...""); } } case 2 -> e.getPlayer().getSocial().getFriendsChat().setRankToEnter(getRankFromPacket(e.getPacket())); case 3 -> e.getPlayer().getSocial().getFriendsChat().setRankToSpeak(getRankFromPacket(e.getPacket())); case 4 -> e.getPlayer().getSocial().getFriendsChat().setRankToKick(getRankFromPacket(e.getPacket())); case 5 -> e.getPlayer().getSocial().getFriendsChat().setRankToLS(getRankFromPacket(e.getPacket())); } LobbyCommunicator.updateFC(e.getPlayer(), res -> { if (res == null) e.getPlayer().sendMessage(""Error communicating with social service.""); else refreshFC(e.getPlayer()); }); }); public static ButtonClickHandler handleTab = new ButtonClickHandler(FC_TAB, e -> { switch (e.getComponentId()) { case 26 -> { if (e.getPlayer().getSocial().getCurrentFriendsChat() != null) //TODO make sure to force leave the player from existing if they try to join new FC without leaving old LobbyCommunicator.forwardPackets(e.getPlayer(), new FCJoin().setOpcode(ClientPacket.FC_JOIN)); } case 31 -> { if (e.getPlayer().getInterfaceManager().containsScreenInter()) { e.getPlayer().sendMessage(""Please close the interface you have opened before using Friends Chat setup.""); return; } e.getPlayer().stopAll(); openFriendChatSetup(e.getPlayer()); } case 19 -> e.getPlayer().toggleLootShare(); } }); public static void openFriendChatSetup(Player player) { player.getInterfaceManager().sendInterface(FC_SETUP_INTER); refreshFC(player); player.getPackets().setIFHidden(FC_SETUP_INTER, 49, true); player.getPackets().setIFHidden(FC_SETUP_INTER, 63, true); player.getPackets().setIFHidden(FC_SETUP_INTER, 77, true); player.getPackets().setIFHidden(FC_SETUP_INTER, 91, true); } public static void refreshFC(Player player) { player.getPackets().setIFText(FC_SETUP_INTER, 1, player.getSocial().getFriendsChat().getName() == null ? ""Chat disabled"" : player.getSocial().getFriendsChat().getName()); sendRankRequirement(player, player.getSocial().getFriendsChat().getRankToEnter(), 2); sendRankRequirement(player, player.getSocial().getFriendsChat().getRankToSpeak(), 3); sendRankRequirement(player, player.getSocial().getFriendsChat().getRankToKick(), 4); sendRankRequirement(player, player.getSocial().getFriendsChat().getRankToLS(), 5); } public static void sendRankRequirement(Player player, Rank rank, int component) { switch (rank) { case UNRANKED -> player.getPackets().setIFText(FC_SETUP_INTER, component, ""Anyone""); case FRIEND -> player.getPackets().setIFText(FC_SETUP_INTER, component, ""Any friends""); case RECRUIT -> player.getPackets().setIFText(FC_SETUP_INTER, component, ""Recruit+""); case CORPORAL -> player.getPackets().setIFText(FC_SETUP_INTER, component, ""Corporal+""); case SERGEANT -> player.getPackets().setIFText(FC_SETUP_INTER, component, ""Sergeant+""); case LIEUTENANT -> player.getPackets().setIFText(FC_SETUP_INTER, component, ""Lieutenant+""); case CAPTAIN -> player.getPackets().setIFText(FC_SETUP_INTER, component, ""Captain+""); case GENERAL -> player.getPackets().setIFText(FC_SETUP_INTER, component, ""General+""); case OWNER -> player.getPackets().setIFText(FC_SETUP_INTER, component, component == 5 ? ""No-one"" : ""Only me""); default -> throw new IllegalArgumentException(""Unexpected value: "" + rank); } } public static Rank getRankFromPacket(ClientPacket packet) { return switch (packet) { case IF_OP1 -> Rank.UNRANKED; case IF_OP2 -> Rank.FRIEND; case IF_OP3 -> Rank.RECRUIT; case IF_OP4 -> Rank.CORPORAL; case IF_OP5 -> Rank.SERGEANT; case IF_OP6 -> Rank.LIEUTENANT; case IF_OP7 -> Rank.CAPTAIN; case IF_OP8 -> Rank.GENERAL; case IF_OP9 -> Rank.OWNER; default -> Rank.UNRANKED; }; } public static FCData getFCData(String username) { if (username == null) return null; return FRIEND_CHATS.get(username); } public static void updateFCData(FCData fc) { FRIEND_CHATS.put(fc.getOwnerDisplayName(), fc); } }" "package com.rs.game.model.item; /** * Container class. * * @author Graham / edited by Dragonkk(Alex) * @param */ public final class ItemsContainer { private Item[] data; private boolean alwaysStackable = false; public ItemsContainer(int size, boolean alwaysStackable) { data = new Item[size]; this.alwaysStackable = alwaysStackable; } public void shift() { Item[] oldData = data; data = new Item[oldData.length]; int ptr = 0; for (int i = 0; i < data.length; i++) if (oldData[i] != null) data[ptr++] = oldData[i]; } @SuppressWarnings(""unchecked"") public T get(int slot) { if (slot < 0 || slot >= data.length) return null; return (T) data[slot]; } public void set(int slot, T item) { if (slot < 0 || slot >= data.length) return; data[slot] = item; if (data[slot] != null) data[slot].setSlot(slot); } public void set2(int slot, Item item) { if (slot < 0 || slot >= data.length) return; data[slot] = item; } public boolean forceAdd(T item) { for (int i = 0; i < data.length; i++) if (data[i] == null) { data[i] = item; return true; } return false; } public boolean add(T item) { if ((alwaysStackable || item.getDefinitions().isStackable() || item.getDefinitions().isNoted()) && item.getMetaData() == null) { for (int i = 0; i < data.length; i++) if (data[i] != null) if (data[i].getId() == item.getId()) { if (data[i].getAmount() + item.getAmount() <= 0) return false; data[i] = new Item(data[i].getId(), data[i].getAmount() + item.getAmount(), item.getMetaData()); data[i].setSlot(i); return true; } } else if (item.getAmount() > 1) { if (freeSlots() < item.getAmount()) return false; for (int i = 0; i < item.getAmount(); i++) { int index = freeSlot(); data[index] = new Item(item.getId(), 1); data[index].setSlot(index); } return true; } int index = freeSlot(); if (index == -1) return false; data[index] = item; data[index].setSlot(index); return true; } public int getThisItemSlot(int itemId) { for (int i = 0; i < data.length; i++) if (data[i] != null) if (data[i].getId() == itemId) return i; return -1; } public int freeSlots() { int j = 0; for (Item aData : data) if (aData == null) j++; return j; } public int remove(T item) { int removed = 0, toRemove = item.getAmount(); for (int i = 0; i < data.length; i++) if (data[i] != null) if (data[i].getId() == item.getId()) { int amt = data[i].getAmount(); if (amt > toRemove) { removed += toRemove; amt -= toRemove; toRemove = 0; data[i] = new Item(data[i].getId(), amt); return removed; } removed += amt; toRemove -= amt; data[i] = null; } return removed; } public void removeAll(T item) { for (int i = 0; i < data.length; i++) if (data[i] != null) if (data[i].getId() == item.getId()) data[i] = null; } public void removeAll(int item) { for (int i = 0; i < data.length; i++) if (data[i] != null) if (data[i].getId() == item) data[i] = null; } public boolean containsOne(T item) { for (Item aData : data) if (aData != null) if (aData.getId() == item.getId()) return true; return false; } public boolean contains(T item) { int amtOf = 0; if (item == null) return false; for (Item aData : data) if (aData != null) if (aData.getId() == item.getId()) amtOf += aData.getAmount(); return amtOf >= item.getAmount(); } public int freeSlot() { for (int i = 0; i < data.length; i++) if (data[i] == null) return i; return -1; } public void clear() { Arrays.fill(data, null); } public int getSize() { return data.length; } public int getFreeSlots() { int s = 0; for (Item aData : data) if (aData == null) s++; return s; } public int getUsedSlots() { int s = 0; for (Item aData : data) if (aData != null) s++; return s; } public int getNumberOf(Item item) { if (item.getMetaData() != null) return 1; int count = 0; for (Item aData : data) if (aData != null) if (aData.getId() == item.getId() && aData.getMetaData() == item.getMetaData()) count += aData.getAmount(); return count; } public int getNumberOf(int item) { int count = 0; for (Item aData : data) if (aData != null) if (aData.getId() == item) count += aData.getAmount(); return count; } public Item[] array() { return data; } public Item[] getItemsCopy() { Item[] newData = new Item[data.length]; System.arraycopy(data, 0, newData, 0, newData.length); return newData; } public List asList() { List list = new ArrayList<>(); for (Item i : getItemsCopy()) if (i != null) list.add(i); return list; } public ItemsContainer asItemContainer() { ItemsContainer c = new ItemsContainer<>(data.length, this.alwaysStackable); System.arraycopy(data, 0, c.data, 0, data.length); return c; } public int getFreeSlot() { for (int i = 0; i < data.length; i++) if (data[i] == null) return i; return -1; } public int getThisItemSlot(T item) { for (int i = 0; i < data.length; i++) if (data[i] != null) if (data[i].getId() == item.getId()) return i; return getFreeSlot(); } public Item lookup(int id) { for (Item aData : data) { if (aData == null) continue; if (aData.getId() == id) return aData; } return null; } public int lookupSlot(int id) { for (int i = 0; i < data.length; i++) { if (data[i] == null) continue; if (data[i].getId() == id) return i; } return -1; } public void reset() { data = new Item[data.length]; } public int remove(int preferredSlot, Item item) { int removed = 0, toRemove = item.getAmount(); if (data[preferredSlot] != null) if (data[preferredSlot].getId() == item.getId() && data[preferredSlot].getMetaData() == item.getMetaData()) { int amt = data[preferredSlot].getAmount(); if (amt > toRemove) { removed += toRemove; amt -= toRemove; toRemove = 0; set2(preferredSlot, new Item(data[preferredSlot].getId(), amt, data[preferredSlot].getMetaData())); return removed; } removed += amt; toRemove -= amt; set(preferredSlot, null); } for (int i = 0; i < data.length; i++) if (data[i] != null) if (data[i].getId() == item.getId() && item.getMetaData() == data[i].getMetaData()) { int amt = data[i].getAmount(); if (amt > toRemove) { removed += toRemove; amt -= toRemove; toRemove = 0; set2(i, new Item(data[i].getId(), amt, data[i].getMetaData())); return removed; } removed += amt; toRemove -= amt; set(i, null); } return removed; } public void addAll(ItemsContainer container) { for (int i = 0; i < container.getSize(); i++) { T item = container.get(i); if (item != null) this.add(item); } } @SuppressWarnings(""unchecked"") public void addAll(Item[] container) { for (Item item : container) if (item != null) this.add((T) item); } public boolean hasSpaceFor(ItemsContainer container) { for (int i = 0; i < container.getSize(); i++) { T item = container.get(i); if (item != null) if (!this.hasSpaceForItem(item)) return false; } return true; } private boolean hasSpaceForItem(T item) { if (alwaysStackable || item.getDefinitions().isStackable() || item.getDefinitions().isNoted()) { for (Item aData : data) if (aData != null) if (aData.getId() == item.getId()) return true; } else if (item.getAmount() > 1) return freeSlots() >= item.getAmount(); int index = freeSlot(); return index != -1; } public Item[] toArray() { return data; } public void initSlots() { for (int i = 0;i < data.length;i++) if (data[i] != null) data[i].setSlot(i); } public void addAll(List list) { for (T item : list) add(item); } public boolean isEmpty() { for (Item element : data) if (element != null) return false; return true; } public ItemsContainer sortByItemId() { Arrays.sort(data, (o1, o2) -> { int o1Id = o1 == null ? Integer.MAX_VALUE : o1.getId(); int o2Id = o2 == null ? Integer.MAX_VALUE : o2.getId(); return o1Id - o2Id; }); return this; } public Item[] getItemsNoNull() { List items = new ArrayList<>(); for (Item i : data) if (i != null) items.add(i); return items.toArray(new Item[0]); } }" "package com.rs.game.model.object; public class GameObject extends WorldObject { protected transient GenericAttribMap attribs; public enum RouteType { NORMAL, WALK_ONTO } protected RouteType routeType = RouteType.NORMAL; private transient ObjectMeshModifier meshModifier; private transient TaskManager tasks; private transient int originalId; private transient int idChangeTicks = -1; private final int hashCode; public GameObject(int id, ObjectType type, int rotation, Tile tile) { super(id, type, rotation, tile); this.originalId = id; this.routeType = World.getRouteType(id); this.hashCode = genHashCode(); } public GameObject(int id, int rotation, int x, int y, int plane) { super(id, rotation, x, y, plane); this.originalId = id; this.routeType = World.getRouteType(id); this.hashCode = genHashCode(); } public GameObject(int id, ObjectType type, int rotation, int x, int y, int plane) { super(id, type, rotation, x, y, plane); this.originalId = id; this.routeType = World.getRouteType(id); this.hashCode = genHashCode(); } public GameObject(WorldObject object) { super(object); this.originalId = id; this.routeType = World.getRouteType(id); this.hashCode = genHashCode(); } public GameObject(GameObject object) { super(object); this.originalId = id; routeType = object.getRouteType(); this.hashCode = genHashCode(); } public GameObject(WorldObject object, int newId) { super(object); this.id = newId; this.originalId = newId; this.routeType = World.getRouteType(newId); this.hashCode = genHashCode(); } public GameObject(GameObject object, int newId) { super(object); this.id = newId; this.originalId = newId; this.routeType = object.getRouteType(); this.hashCode = genHashCode(); } @Override public boolean equals(Object other) { if (!(other instanceof GameObject obj)) return false; return obj.hashCode() == hashCode(); } @Override public int hashCode() { return hashCode; } public int genHashCode() { int hash = tile.getTileHash(); hash = ((hash << 5) - hash) + id; hash = ((hash << 5) - hash) + rotation; hash = ((hash << 5) - hash) + type.id; return hash; } public int positionHashCode() { int hash = tile.getTileHash(); hash = ((hash << 5) - hash) + type.id; return hash; } @Override public String toString() { return ""[id:""+id+"" loc:(""+getX()+"",""+getY()+"",""+getPlane()+"") type:""+type+"" rot:""+rotation+"" name:""+getDefinitions().getName()+""]""; } public boolean process() { boolean continueProcessing = false; if (tasks != null) { if (tasks.getSize() > 0) { tasks.processTasks(); continueProcessing = true; } else tasks = null; } if (idChangeTicks == -2) return true; if (idChangeTicks > -1) { if (idChangeTicks-- == 0) setId(originalId); else continueProcessing = true; } return continueProcessing; } public TaskManager getTasks() { if (tasks == null) { tasks = new TaskManager(); flagForProcess(); } return tasks; } public GameObject setId(int id) { int lastId = this.id; this.id = id; if (lastId != id) World.refreshObject(this); if (id != originalId) { ChunkManager.getChunk(getTile().getChunkId(), true).flagForProcess(this); idChangeTicks = -2; } else { ChunkManager.getChunk(getTile().getChunkId(), true).unflagForProcess(this); idChangeTicks = -1; } return this; } public ObjectMeshModifier modifyMesh() { this.meshModifier = new ObjectMeshModifier(this); return this.meshModifier; } public void refresh() { World.refreshObject(this); } public void setIdTemporary(int id, int ticks) { if (this.id == id) return; Chunk chunk = ChunkManager.getChunk(getTile().getChunkId(), true); chunk.flagForProcess(this); setId(id); idChangeTicks = ticks; } public GameObject setRouteType(RouteType routeType) { this.routeType = routeType; return this; } public boolean exists() { return ChunkManager.getChunk(getTile().getChunkId()).objectExists(new GameObject(this, id)); } public void flagForProcess() { ChunkManager.getChunk(getTile().getChunkId(), true).flagForProcess(this); } public void unflagForProcess() { ChunkManager.getChunk(getTile().getChunkId(), true).unflagForProcess(this); } public ObjectDefinitions getDefinitions(Player player) { return ObjectDefinitions.getDefs(id, player.getVars()); } public void animate(Animation animation) { World.sendObjectAnimation(this, animation); } public void animate(int animation) { World.sendObjectAnimation(this, new Animation(animation)); } public RouteType getRouteType() { return routeType; } public GenericAttribMap getAttribs() { if (attribs == null) attribs = new GenericAttribMap(); return attribs; } public ObjectMeshModifier getMeshModifier() { return meshModifier; } public int getOriginalId() { return originalId; } }" "package com.rs.game.model.object; public class ObjectMeshModifier { public static final ObjectMeshModifier RESET = new ObjectMeshModifier(); private transient GameObject object; private int slot = -1; private int[] modelIds; private int[] modifiedColors; private int[] modifiedTextures; private ObjectMeshModifier() { } public ObjectMeshModifier(GameObject object) { this.object = object; if (object.getDefinitions().types != null) { for (int i = 0; i < object.getDefinitions().types.length; i++) { if (object.getType() == object.getDefinitions().types[i]) { slot = i; break; } } } if (slot == -1) Logger.error(ObjectMeshModifier.class, ""constructor()"", ""Object "" + object + "" has no slot type.""); } public ObjectMeshModifier setModel(int index, int modelId) { if (modelIds == null) { modelIds = new int[object.getDefinitions().modelIds[slot].length]; System.arraycopy(object.getDefinitions().modelIds[slot], 0, modelIds, 0, modelIds.length); } if (index < 0 || index >= modelIds.length) throw new RuntimeException(""Index "" + index + "" for models of ["" + slot + ""] "" + object.getDefinitions().id + "" is out of bounds.""); if (modelId == -1) modelIds[index] = object.getDefinitions().modelIds[slot][index]; else modelIds[index] = modelId; return this; } public ObjectMeshModifier addModels(int... models) { if (Arrays.equals(models, object.getDefinitions().modelIds[slot])) return this; modelIds = new int[object.getDefinitions().modelIds[slot].length]; System.arraycopy(object.getDefinitions().modelIds[slot], 0, modelIds, 0, modelIds.length); for (int i = 0;i < object.getDefinitions().modelIds[slot].length;i++) { if (i >= models.length) continue; modelIds[i] = models[i]; } return this; } public ObjectMeshModifier setColor(int index, int color) { if (modifiedColors == null && object.getDefinitions().modifiedColors != null) { modifiedColors = new int[object.getDefinitions().modifiedColors.length]; for (int i = 0;i < modifiedColors.length;i++) modifiedColors[i] = object.getDefinitions().modifiedColors[i]; } if (modifiedColors == null || index < 0 || index >= modifiedColors.length) throw new RuntimeException(""Index "" + index + "" for models of "" + object.getDefinitions().id + "" is out of bounds.""); if (color == -1) modifiedColors[index] = object.getDefinitions().modifiedColors[index]; else modifiedColors[index] = (short) color; return this; } public ObjectMeshModifier addColors(int... colors) { if (object.getDefinitions().modifiedColors != null) { modifiedColors = new int[object.getDefinitions().modifiedColors.length]; for (int i = 0;i < modifiedColors.length;i++) modifiedColors[i] = object.getDefinitions().modifiedColors[i]; } if (modifiedColors == null) return this; for (int i = 0;i < modifiedColors.length;i++) { if (i >= colors.length) break; modifiedColors[i] = (short) colors[i]; } return this; } public ObjectMeshModifier setTexture(int index, int texId) { if (modifiedTextures == null && object.getDefinitions().modifiedTextures != null) { modifiedTextures = new int[object.getDefinitions().modifiedTextures.length]; for (int i = 0;i < modifiedTextures.length;i++) modifiedTextures[i] = object.getDefinitions().modifiedTextures[i]; } if (modifiedTextures == null || index < 0 || index >= modifiedTextures.length) throw new RuntimeException(""Index "" + index + "" for models of "" + object.getDefinitions().id + "" is out of bounds.""); if (texId == -1) modifiedTextures[index] = object.getDefinitions().modifiedTextures[index]; else modifiedTextures[index] = (short) texId; return this; } public ObjectMeshModifier addTextures(int... textures) { if (object.getDefinitions().modifiedTextures != null) { modifiedTextures = new int[object.getDefinitions().modifiedTextures.length]; for (int i = 0;i < modifiedTextures.length;i++) modifiedTextures[i] = object.getDefinitions().modifiedTextures[i]; } if (modifiedTextures == null) return this; for (int i = 0;i < modifiedTextures.length;i++) { if (i >= textures.length) break; modifiedTextures[i] = (short) textures[i]; } return this; } public GameObject getObject() { return object; } public int[] getModelIds() { return modelIds; } public int[] getModifiedColors() { return modifiedColors; } public int[] getModifiedTextures() { return modifiedTextures; } }" "package com.rs.game.model.object; public class OwnedObject extends GameObject { private static final Map OBJECTS = new ConcurrentHashMap<>(); private static final Map> OWNER_MAP = new ConcurrentHashMap<>(); private final String owner; private boolean destroyed; public OwnedObject(Player player, GameObject object) { this(player, object.getId(), object.getType(), object.getRotation(), object.getTile()); } public OwnedObject(Player player, GameObject object, int newId) { this(player, newId, object.getType(), object.getRotation(), object.getTile()); } public OwnedObject(Player player, int id, ObjectType type, int rotation, Tile tile) { super(id, type, rotation, tile); owner = player.getUsername(); } public void tick(Player owner) { } public void onDestroy() { } public void onCreate() { } public Player getOwner() { return World.getPlayerByUsername(owner); } public boolean ownedBy(Player player) { return player.getUsername().equals(owner); } public static void processAll() { try { for (Integer key : OBJECTS.keySet()) { OwnedObject o = OBJECTS.get(key); if (o == null || o.destroyed) continue; o.tick(World.getPlayerByUsername(o.owner)); } } catch(Throwable e) { Logger.handle(OwnedObject.class, ""process"", e); } } public boolean overlapsExisting() { return World.getObject(this.tile, getType()) != null; } public final boolean createNoReplace() { if (World.getObject(this.tile, getType()) != null) return false; World.spawnObject(this); OBJECTS.put(tile.getTileHash(), this); onCreate(); Map ownedBy = OWNER_MAP.get(owner); if (ownedBy == null) ownedBy = new ConcurrentHashMap<>(); ownedBy.put(tile.getTileHash(), this); OWNER_MAP.put(owner, ownedBy); return true; } public final void createReplace() { World.spawnObject(this); OBJECTS.put(tile.getTileHash(), this); onCreate(); Map ownedBy = OWNER_MAP.get(owner); if (ownedBy == null) ownedBy = new ConcurrentHashMap<>(); ownedBy.put(tile.getTileHash(), this); OWNER_MAP.put(owner, ownedBy); } public final void destroy() { World.removeObject(this); OBJECTS.remove(tile.getTileHash()); onDestroy(); Map ownedBy = OWNER_MAP.get(owner); if (ownedBy != null) { ownedBy.remove(tile.getTileHash()); if (ownedBy.size() == 0) OWNER_MAP.remove(owner); destroyed = true; } } public boolean isDestroyed() { return destroyed; } public static Collection getOwnedBy(Player owner) { if (OWNER_MAP.get(owner.getUsername()) == null) return new CopyOnWriteArrayList<>(); return OWNER_MAP.get(owner.getUsername()).values(); } public static int getNumOwned(Player owner, Class type) { int count = 0; Collection objs = getOwnedBy(owner); if (objs == null) return 0; for (OwnedObject obj : objs) if (type.isInstance(obj)) count++; return count; } }" "package com.rs.game.tasks; public abstract class Task implements Runnable { protected boolean needRemove; public final void stop() { needRemove = true; } }" "package com.rs.game.tasks; public final class TaskInformation { String mapping; Task task; int loopDelay; int currDelay; public TaskInformation(String mapping, Task task, int startDelay, int loopDelay) { this.mapping = mapping; this.task = task; this.currDelay = startDelay; this.loopDelay = loopDelay; if (loopDelay == -1) task.needRemove = true; } public String getMapping() { return mapping; } public Task getTask() { return task; } public int getLoopDelay() { return loopDelay; } public int getCurrDelay() { return currDelay; } }" "package com.rs.game.tasks; public class TaskLambda extends Task { private final Runnable task; private String stack; public TaskLambda(Runnable task) { this.task = task; stack = """"; StackTraceElement[] elements = Thread.currentThread().getStackTrace(); for(int i = 1; i < elements.length; ++i) { StackTraceElement s = elements[i]; String var10001 = s.getClassName(); stack += ""\tat "" + var10001 + ""."" + s.getMethodName() + ""("" + s.getFileName() + "":"" + s.getLineNumber() + "")""; } } @Override public void run() { task.run(); } @Override public String toString() { return ""TaskLambda\n"" + stack; } }" "package com.rs.game.tasks; public class TaskManager { private final List tasks = new ObjectArrayList<>(); private final Map mappedTasks = new Object2ObjectOpenHashMap<>(); public void processTasks() { synchronized(tasks) { try { List toRemove = new ArrayList<>(); for (TaskInformation task : tasks) { if (task == null) continue; try { if (task.currDelay > 0) { task.currDelay--; continue; } try { task.getTask().run(); } catch (Throwable e) { Logger.handle(WorldTasks.class, ""processTasksRun:"" + (task.getClass().getDeclaringClass() != null ? task.getClass().getDeclaringClass().getSimpleName() : ""UnknownSource""), task.toString(), e); } if (task.getTask().needRemove) toRemove.add(task); else task.currDelay = task.getLoopDelay(); } catch (Throwable e) { Logger.handle(WorldTasks.class, ""processTasks:"" + (task.getClass().getDeclaringClass() != null ? task.getClass().getDeclaringClass().getSimpleName() : ""UnknownSource""), task.toString(), e); } } for (TaskInformation task : toRemove) if (task != null) { tasks.remove(task); if (task.mapping != null) mappedTasks.remove(task.mapping); } } catch(Throwable e) { Logger.handle(WorldTasks.class, ""processTasks"", e); } } } public TaskInformation scheduleLooping(String mapping, Task task, int startDelay, int loopDelay) { synchronized(tasks) { if (task == null || startDelay < 0 || loopDelay < 0) return null; return mapTaskInformation(mapping, new TaskInformation(mapping, task, startDelay, loopDelay)); } } public TaskInformation scheduleLooping(Task task, int startDelay, int loopDelay) { return scheduleLooping(null, task, startDelay, loopDelay); } public TaskInformation schedule(String mapping, Task task, int delayCount) { synchronized(tasks) { if (task == null || delayCount < 0) return null; return mapTaskInformation(mapping, new TaskInformation(mapping, task, delayCount, -1)); } } public TaskInformation schedule(Task task, int delayCount) { return schedule(null, task, delayCount); } public TaskInformation schedule(String mapping, Task task) { synchronized(tasks) { if (task == null) return null; return mapTaskInformation(mapping, new TaskInformation(mapping, task, 0, -1)); } } public TaskInformation schedule(Task task) { return schedule(null, task); } public TaskInformation scheduleLooping(String mapping, int startDelay, int loopDelay, Runnable task) { synchronized(tasks) { if (task == null || startDelay < 0 || loopDelay < 0) return null; return mapTaskInformation(mapping, new TaskInformation(mapping, new TaskLambda(task), startDelay, loopDelay)); } } public TaskInformation scheduleLooping(int startDelay, int loopDelay, Runnable task) { return scheduleLooping(null, startDelay, loopDelay, task); } public TaskInformation scheduleHalfHourly(Runnable task) { ZonedDateTime now = ZonedDateTime.now(); ZonedDateTime nextHalfHour; if (now.getMinute() < 30) nextHalfHour = now.withMinute(30).withSecond(0).withNano(0); else nextHalfHour = now.plusHours(1).withMinute(0).withSecond(0).withNano(0); int delay = (int) (Duration.between(now, nextHalfHour).toMillis() / 600L); return scheduleLooping(delay, Ticks.fromMinutes(30), task); } public TaskInformation scheduleNthHourly(int hour, Runnable task) { ZonedDateTime now = ZonedDateTime.now(); int currentHour = now.getHour(); int hoursUntilNextMark = hour - (currentHour % hour); ZonedDateTime nextThreeHourMark = now.plusHours(hoursUntilNextMark).withMinute(0).withSecond(0).withNano(0); int delay = (int) (Duration.between(now, nextThreeHourMark).toMillis() / 600L); return scheduleLooping(delay, Ticks.fromHours(hour), task); } public TaskInformation scheduleHourly(Runnable task) { return scheduleNthHourly(1, task); } public TaskInformation schedule(String mapping, int startDelay, Runnable task) { synchronized(tasks) { if (task == null || startDelay < 0) return null; return mapTaskInformation(mapping, new TaskInformation(mapping, new TaskLambda(task), startDelay, -1)); } } public TaskInformation schedule(int startDelay, Runnable task) { return schedule(null, startDelay, task); } public TaskInformation schedule(String mapping, Runnable task) { synchronized(tasks) { if (task == null) return null; return mapTaskInformation(mapping, new TaskInformation(mapping, new TaskLambda(task), 0, -1)); } } public TaskInformation schedule(Runnable task) { return schedule(null, task); } public TaskInformation scheduleTimer(String mapping, int startDelay, int loopDelay, Function task) { synchronized(tasks) { if (task == null || startDelay < 0 || loopDelay < 0) return null; return mapTaskInformation(mapping, new TaskInformation(mapping, new TaskTimerLambda(task), startDelay, loopDelay)); } } public TaskInformation scheduleTimer(int startDelay, int loopDelay, Function task) { return scheduleTimer(null, startDelay, loopDelay, task); } public TaskInformation scheduleTimer(String mapping, Function task) { synchronized(tasks) { if (task == null) return null; return mapTaskInformation(mapping, new TaskInformation(mapping, new TaskTimerLambda(task), 0, 0)); } } public TaskInformation scheduleTimer(Function task) { return scheduleTimer(null, task); } public TaskInformation scheduleTimer(String mapping, int startDelay, Function task) { synchronized(tasks) { if (task == null || startDelay < 0) return null; return mapTaskInformation(mapping, new TaskInformation(mapping, new TaskTimerLambda(task), startDelay, 0)); } } public TaskInformation scheduleTimer(int startDelay, Function task) { return scheduleTimer(null, startDelay, task); } public void remove(TaskInformation task) { synchronized(tasks) { if (task == null) return; tasks.remove(task); if (task.mapping != null) mappedTasks.remove(task.mapping); } } public void remove(String mapping) { synchronized(tasks) { TaskInformation task = mappedTasks.remove(mapping); if (task == null) return; tasks.remove(task); } } public boolean hasTask(String mapping) { synchronized (tasks) { return mappedTasks.containsKey(mapping); } } private TaskInformation mapTaskInformation(String mapping, TaskInformation taskInfo) { tasks.add(taskInfo); if (mapping != null) { TaskInformation existing = mappedTasks.get(mapping); if (existing != null) tasks.remove(mappedTasks.get(mapping)); mappedTasks.put(mapping, taskInfo); } return taskInfo; } public int getSize() { return tasks.size(); } }" "package com.rs.game.tasks; public class TaskTimerLambda extends Task { int tick = 0; private final Function task; private String stack; public TaskTimerLambda(Function task) { this.task = task; stack = """"; StackTraceElement[] elements = Thread.currentThread().getStackTrace(); for(int i = 1; i < elements.length; ++i) { StackTraceElement s = elements[i]; String var10001 = s.getClassName(); stack += ""\tat "" + var10001 + ""."" + s.getMethodName() + ""("" + s.getFileName() + "":"" + s.getLineNumber() + "")""; } } @Override public void run() { if (!task.apply(tick)) stop(); tick++; } @Override public String toString() { return ""TaskTimerLambda\n"" + stack; } }" "package com.rs.game.tasks; public class WorldTasks { private static final TaskManager TASKS = new TaskManager(); public static void processTasks() { TASKS.processTasks(); } /** * Please use scheduleTimer for this sparingly and be absurdly careful to end the loops * when they are supposed to end. */ @Deprecated public static TaskInformation scheduleLooping(Task task, int startDelay, int loopDelay) { return TASKS.scheduleLooping(task, startDelay, loopDelay); } public static TaskInformation schedule(Task task, int delayCount) { return TASKS.schedule(task, delayCount); } public static TaskInformation schedule(Task task) { return TASKS.schedule(task); } /** * Please use scheduleTimer for this sparingly and be absurdly careful to end the loops * when they are supposed to end. */ @Deprecated public static TaskInformation scheduleLooping(int startDelay, int loopDelay, Runnable task) { return TASKS.scheduleLooping(startDelay, loopDelay, task); } public static TaskInformation scheduleHalfHourly(Runnable task) { return TASKS.scheduleHalfHourly(task); } public static TaskInformation scheduleNthHourly(int hour, Runnable task) { return TASKS.scheduleNthHourly(hour, task); } public static TaskInformation scheduleHourly(Runnable task) { return scheduleNthHourly(1, task); } public static TaskInformation schedule(int startDelay, Runnable task) { return TASKS.schedule(startDelay, task); } public static TaskInformation schedule(Runnable task) { return TASKS.schedule(task); } public static void scheduleTimer(int startDelay, int loopDelay, Function task) { TASKS.scheduleTimer(startDelay, loopDelay, task); } public static void scheduleTimer(Function task) { TASKS.scheduleTimer(task); } public static void scheduleTimer(int startDelay, Function task) { TASKS.scheduleTimer(startDelay, task); } public static void remove(TaskInformation task) { TASKS.remove(task); } private WorldTasks() { } public static void delay(int ticks, Runnable task) { schedule(new Task() { @Override public void run() { task.run(); } }, ticks); } public static int getSize() { return TASKS.getSize(); } }" "package com.rs.net; public class LobbyCommunicator { public static void addWorldPlayer(Account account, Consumer cb) { post(Boolean.class, new WorldPlayerAction(account, Settings.getConfig().getWorldInfo()), ""addworldplayer"", cb); } public static void removeWorldPlayer(Player player) { post(new WorldPlayerAction(player.getAccount(), Settings.getConfig().getWorldInfo()), ""removeworldplayer""); } public static Account authWorldLogin(String username, String password) throws InterruptedException, ExecutionException, IOException { return postSync(Account.class, new LoginRequest(username, password), ""authworldlogin""); } public static void getAccountByDisplay(String displayName, Consumer cb) { post(Account.class, new LoginRequest(displayName, ""cock""), ""getaccountbydisplay"", cb); } public static void getAccount(String username, String password, Consumer cb) { post(Account.class, new LoginRequest(username, password), ""getaccountauth"", cb); } public static void getAccount(String username, Consumer cb) { post(Account.class, new LoginRequest(username, ""cock""), ""getaccount"", cb); } public static void updatePunishments(Player player) { post(player.getAccount(), ""updatepunishments""); } public static void updatePunishments(Player player, Consumer cb) { post(Boolean.class, player.getAccount(), ""updatepunishments"", cb); } public static void updateRights(Player player) { post(player.getAccount(), ""updaterights""); } public static void updateRights(Player player, Consumer cb) { post(Boolean.class, player.getAccount(), ""updaterights"", cb); } public static void updateSocial(Player player) { post(player.getAccount(), ""updatesocial""); } public static void updateSocial(Player player, Consumer cb) { post(Boolean.class, player.getAccount(), ""updatesocial"", cb); } public static void updateFC(Player player, Consumer cb) { post(FriendsChat.class, new UpdateFC(player.getDisplayName(), player.getSocial().getFriendsChat()), ""updatefc"", cb); } public static void forwardPackets(Player player, Packet... packets) { post(Boolean.class, new PacketDto(player.getUsername(), packets), ""forwardpackets"", res -> { if (res != null && !res) player.sendMessage(""Error forwarding packet to lobby.""); }); } public static void forwardPacket(Player player, Packet packet, Consumer cb) { post(Boolean.class, new PacketDto(player.getUsername(), packet), ""forwardpackets"", cb); } public static void getClan(String clan, Consumer cb) { get(Clan.class, ""clans/""+clan, cb); } public static void updateClan(Clan clan, Consumer res) { if (clan == null) { res.accept(null); return; } post(Clan.class, clan, ""clans/update"", res); } public static void post(Object body, String endpoint) { post(null, body, endpoint, null); } public static void get(Class type, String endpoint, Consumer cb) { APIUtil.get(type, ""http://""+Settings.getConfig().getLobbyIp()+"":4040/api/""+endpoint, Settings.getConfig().getLobbyApiKey(), cb); } public static T getSync(Class type, String endpoint) { return APIUtil.getSync(type, ""http://""+Settings.getConfig().getLobbyIp()+"":4040/api/""+endpoint, Settings.getConfig().getLobbyApiKey()); } public static void post(Class type, Object body, String endpoint, Consumer cb) { APIUtil.post(type, body, ""http://""+Settings.getConfig().getLobbyIp()+"":4040/api/""+endpoint, Settings.getConfig().getLobbyApiKey(), cb); } public static T postSync(Class type, Object body, String endpoint) { return APIUtil.postSync(type, body, ""http://""+Settings.getConfig().getLobbyIp()+"":4040/api/""+endpoint, Settings.getConfig().getLobbyApiKey()); } }" "package com.rs.net.decoders; public final class BaseWorldDecoder extends Decoder { public BaseWorldDecoder() { } public BaseWorldDecoder(Session connection) { super(connection); } @Override public int decode(InputStream stream) { session.setDecoder(null); int packetId = stream.readUnsignedByte(); switch (packetId) { case 14: return decodeLogin(stream); default: Logger.debug(BaseWorldDecoder.class, ""decode"", ""Connection type: "" + packetId + "" Remaining: "" + stream.getRemaining()); StringBuilder hex = new StringBuilder(); for (byte i : stream.getBuffer()) hex.append(String.format(""%02X"", i)); Logger.debug(BaseWorldDecoder.class, ""decode"", hex.toString()); return -1; } } private int decodeLogin(InputStream stream) { if (stream.getRemaining() != 0) { session.getChannel().close(); return -1; } session.setDecoder(new WorldLoginDecoder(session)); session.setEncoder(new Encoder(session)); session.sendLoginStartup(); return stream.getOffset(); } }" "package com.rs.net.decoders; public final class WorldLoginDecoder extends Decoder { public WorldLoginDecoder(Session session) { super(session); } @Override public int decode(InputStream stream) { session.setDecoder(null); int packetId = stream.readUnsignedByte(); long update = World.getTicksTillUpdate(); if (update != -1 && update < 20) { session.sendClientPacket(14); return -1; } int packetSize = stream.readUnsignedShort(); if (packetSize != stream.getRemaining()) { session.getChannel().close(); return -1; } if (stream.readInt() != Constants.CLIENT_BUILD) { session.sendClientPacket(6); return -1; } if (packetId == 16 || packetId == 18) // 16 world login return decodeWorldLogin(stream); Logger.debug(WorldLoginDecoder.class, ""decode"", ""Unknown connection type: "" + packetId + "" Remaining: "" + stream.getRemaining()); session.getChannel().close(); return -1; } @SuppressWarnings(""unused"") public int decodeWorldLogin(InputStream stream) { if (stream.readInt() != Constants.CUSTOM_CLIENT_BUILD) { session.sendClientPacket(6); return -1; } boolean gameStateIsUnk10 = stream.readUnsignedByte() == 1; int rsaBlockSize = stream.readUnsignedShort(); if (rsaBlockSize > stream.getRemaining()) { session.sendClientPacket(10); return -1; } byte[] data = new byte[rsaBlockSize]; stream.readBytes(data, 0, rsaBlockSize); InputStream rsaStream = new InputStream(Utils.cryptRSA(data, Constants.RSA_PRIVATE_EXPONENT, Constants.RSA_PRIVATE_MODULUS)); if (rsaStream.readUnsignedByte() != 10) { session.sendClientPacket(10); return -1; } int[] isaacKeys = new int[4]; for (int i = 0; i < isaacKeys.length; i++) isaacKeys[i] = rsaStream.readInt(); if (rsaStream.readLong() != 0L) { // rsa block check, pass part session.sendClientPacket(10); return -1; } String password = rsaStream.readString(); //old password rsaStream.readLong(); rsaStream.readLong(); stream.decodeXTEA(isaacKeys, stream.getOffset(), stream.getLength()); boolean stringUsername = stream.readUnsignedByte() == 1; // unknown String username = Utils.formatPlayerNameForProtocol(stringUsername ? stream.readString() : Utils.longToString(stream.readLong())); int displayMode = stream.readUnsignedByte(); int screenWidth = stream.readUnsignedShort(); int screenHeight = stream.readUnsignedShort(); int unknown2 = stream.readUnsignedByte(); stream.skip(24); // 24bytes directly from a file, no idea whats there String settings = stream.readString(); int affid = stream.readInt(); int prefSize = stream.readUnsignedByte(); int[] prefs = new int[prefSize]; for (int i = 0;i < prefs.length;i++) prefs[i] = stream.readUnsignedByte(); //Logger.debug(i+"": "" + prefs[i]); int success = stream.readUnsignedByte(); if (success != 6) Logger.error(WorldLoginDecoder.class, ""decodeWorldLogin"", ""Failed to parse machine info "" + username); MachineInformation mInformation = MachineInformation.parse(stream); stream.readInt(); stream.readLong(); stream.readString(); if (stream.readUnsignedByte() == 1) stream.readString(); stream.readUnsignedByte(); stream.readUnsignedByte(); stream.readUnsignedByte(); stream.readByte(); stream.readInt(); String token = stream.readString(); if (!token.equals(Constants.WORLD_TOKEN)) { session.sendClientPacket(6); return -1; } stream.readUnsignedByte(); int worldId = stream.readInt(); for (int index = 0; index < Cache.STORE.getIndices().length; index++) { if (index > 35) break; int crc = Cache.STORE.getIndices()[index] == null ? -1011863738 : Cache.STORE.getIndices()[index].getCRC(); int receivedCRC = stream.readInt(); if (crc != receivedCRC && index < 32) { Logger.error(WorldLoginDecoder.class, ""decodeWorldLogin"", ""CRC mismatch: "" + crc + "", "" + receivedCRC + "" from "" + username); session.sendClientPacket(6); return -1; } } if (World.getPlayers().size() >= Settings.PLAYERS_LIMIT - 10) { session.sendClientPacket(7); return -1; } if (AccountLimiter.getSessionsIP(session.getIP()) > 3) { session.sendClientPacket(9); return -1; } Account a = null; try { a = LobbyCommunicator.authWorldLogin(username, password); } catch (InterruptedException | ExecutionException | IOException e) { System.err.println(""Error connecting to login server!""); session.sendClientPacket(23); return -1; } final Account account = a; if (account == null || account.getUsername() == null || account.getUsername().isEmpty()) { session.sendClientPacket(3); return -1; } if (World.containsPlayer(account.getUsername())) { session.sendClientPacket(5); return -1; } WorldDB.getPlayers().getByUsername(account.getUsername(), pRes -> { if (pRes == null) pRes = new Player(account); final Player player = pRes; if (account.isBanned()) { session.sendClientPacket(4); return; } player.init(session, account, displayMode, screenWidth, screenHeight, mInformation); session.write(new WorldLoginDetails(Settings.getConfig().isDebug() ? 2 : player.getRights().getCrown(), player.getIndex(), player.getDisplayName(), 0, false, Settings.getConfig().getWorldInfo().members())); session.setIsaac(new IsaacKeyPair(isaacKeys)); session.setDecoder(new GameDecoder(session)); session.setEncoder(new WorldEncoder(player, session)); player.start(); }); return stream.getOffset(); } }" "package com.rs.net.decoders.handlers; public class InventoryOptionsHandler { public static boolean handleItemOnItem(Player player, Item used, Item usedWith, int fromSlot, int toSlot) { int usedId = used.getId(), usedWithId = usedWith.getId(); if (!player.getControllerManager().canUseItemOnItem(used, usedWith)) return false; if (PrayerBooks.isGodBook(usedId, false) || PrayerBooks.isGodBook(usedWithId, false)) { PrayerBooks.bindPages(player, used.getName().contains("" page "") ? usedWithId : usedId); return true; } if (CookingCombos.handleCombos(player, used, usedWith)) return true; if (TreeSaplings.hasSaplingRequest(player, usedId, usedWithId)) { if (usedId == 5354) TreeSaplings.plantSeed(player, usedWithId, fromSlot); else TreeSaplings.plantSeed(player, usedId, toSlot); return true; } if (usedWithId == 22332) { WickedHoodRune rune = null; for (WickedHoodRune r : WickedHoodRune.values()) if (r.getTalismanId() == usedId || r.getTiaraId() == usedId) rune = r; if (rune != null) { if (player.hasWickedHoodTalisman(rune)) { //failsafe check for players who manually use all elemental runes so they can still use the talisman to unlock pure ess. if (usedId == WickedHoodRune.ELEMENTAL.getTalismanId() && !player.getUsedElementalTalisman()) { player.getInventory().deleteItem(usedId, 1); player.setUsedElementalTalisman(true); player.sendMessage(""You unlock the ability to receive pure essence from the wicked hood.""); return true; } player.sendMessage(""The hood doesn't appear to be interested in that anymore.""); return true; } player.getInventory().deleteItem(usedId, 1); player.getSkills().addXp(Constants.RUNECRAFTING, 50); if (usedId == WickedHoodRune.OMNI.getTalismanId()) { for (WickedHoodRune r : WickedHoodRune.values()) player.unlockWickedHoodRune(r); player.setUsedOmniTalisman(true); } else if (usedId == WickedHoodRune.ELEMENTAL.getTalismanId()) { player.unlockWickedHoodRune(WickedHoodRune.AIR); player.unlockWickedHoodRune(WickedHoodRune.WATER); player.unlockWickedHoodRune(WickedHoodRune.EARTH); player.unlockWickedHoodRune(WickedHoodRune.FIRE); player.setUsedElementalTalisman(true); player.sendMessage(""You unlock the ability to receive pure essence from the wicked hood.""); } player.unlockWickedHoodRune(rune); } return true; } if ((usedId == 7225 && usedWithId == 9978) || (usedId == 1391 && usedWithId == 9978)) { player.getInventory().deleteItem(7225, 1); player.getInventory().deleteItem(9978, 1); player.getInventory().addItem(9984, 1); return true; } if (usedId == 1759 && Lunars.getStrungIndex(usedWithId) != -1) if (player.getInventory().containsItem(1759, 1) && player.getInventory().containsItem(usedWithId, 1)) { player.getInventory().deleteItem(used.getId(), 1); player.getInventory().deleteItem(usedWith.getId(), 1); player.getInventory().addItem(Lunars.strung[Lunars.getStrungIndex(usedWithId)], 1); return true; } if ((usedId == 21775 && usedWithId == 1391) || (usedId == 1391 && usedWithId == 21775)) { if (player.getSkills().getLevel(Constants.CRAFTING) >= 77) { if (player.getInventory().containsItem(21775, 1) && player.getInventory().containsItem(1391, 1)) { player.getInventory().deleteItem(21775, 1); player.getInventory().deleteItem(1391, 1); player.getSkills().addXp(Constants.CRAFTING, 150); player.getInventory().addItem(21777, 1); player.sendMessage(""You fuse the orb with the battlestaff.""); } } else player.sendMessage(""You need 77 crafting to create an armadyl battlestaff.""); return true; } if ((usedId >= 20121 && usedId <= 20124) || (usedWithId >= 20121 && usedWithId <= 20124)) { if (player.getInventory().containsItem(20121, 1) && player.getInventory().containsItem(20122, 1) && player.getInventory().containsItem(20123, 1) && player.getInventory().containsItem(20124, 1)) { player.getInventory().deleteItem(20121, 1); player.getInventory().deleteItem(20122, 1); player.getInventory().deleteItem(20123, 1); player.getInventory().deleteItem(20124, 1); player.getInventory().addItem(new Item(20120, 1).addMetaData(""frozenKeyCharges"", 6.0)); } else player.sendMessage(""You need all 4 peices to create a frozen key.""); return true; } if (usedId == 12435 && player.getFamiliarPouch() == Pouch.PACK_YAK) { usedWith.setSlot(usedWith.getSlot()); player.getFamiliar().castSpecial(usedWith); return true; } if (usedWith.getId() == 946 || used.getId() == 946) { CuttableFruit fruit = CuttableFruit.forId(used.getId()); if (fruit != null && usedWith.getId() == 946) { player.startConversation(new FruitCuttingD(player, fruit)); return true; } fruit = CuttableFruit.forId(usedWith.getId()); if (fruit != null && used.getId() == 946) { player.startConversation(new FruitCuttingD(player, fruit)); return true; } } Fletch fletch = Fletching.isFletching(usedWith, used); if (fletch != null) { player.startConversation(new FletchingD(player, fletch)); return true; } int leatherIndex = LeatherCraftingD.getIndex(usedId) == -1 ? LeatherCraftingD.getIndex(usedWith.getId()) : LeatherCraftingD.getIndex(usedId); if (leatherIndex != -1 && ((usedId == 1733 || usedWith.getId() == 1733) || LeatherCraftingD.isExtraItem(usedWith.getId()) || LeatherCraftingD.isExtraItem(usedId))) { player.startConversation(new LeatherCraftingD(player, leatherIndex)); return true; } if (Firemaking.isFiremaking(player, used, usedWith) || GemCutting.isCutting(player, used, usedWith)) return true; if (contains(1755, Gem.OPAL.getCut(), used, usedWith)) GemTipCutting.cut(player, GemTips.OPAL); else if (contains(1755, Gem.JADE.getCut(), used, usedWith)) GemTipCutting.cut(player, GemTips.JADE); else if (contains(1755, Gem.RED_TOPAZ.getCut(), used, usedWith)) GemTipCutting.cut(player, GemTips.RED_TOPAZ); else if (contains(1755, Gem.SAPPHIRE.getCut(), used, usedWith)) GemTipCutting.cut(player, GemTips.SAPPHIRE); else if (contains(1755, Gem.EMERALD.getCut(), used, usedWith)) GemTipCutting.cut(player, GemTips.EMERALD); else if (contains(1755, Gem.RUBY.getCut(), used, usedWith)) GemTipCutting.cut(player, GemTips.RUBY); else if (contains(1755, Gem.DIAMOND.getCut(), used, usedWith)) GemTipCutting.cut(player, GemTips.DIAMOND); else if (contains(1755, Gem.DRAGONSTONE.getCut(), used, usedWith)) GemTipCutting.cut(player, GemTips.DRAGONSTONE); else if (contains(1755, Gem.ONYX.getCut(), used, usedWith)) GemTipCutting.cut(player, GemTips.ONYX); else if (PluginManager.handle(new ItemOnItemEvent(player, used.setSlot(fromSlot), usedWith.setSlot(toSlot)))) return true; Logger.debug(InventoryOptionsHandler.class, ""handleItemOnItem"", ""ItemOnItem "" + used.getId() + "" -> "" + usedWith.getId()); return false; } public static void handleItemOption1(Player player, final int slotId, final int itemId, Item item) { if (player.isLocked() || player.getEmotesManager().isAnimating()) return; player.stopAll(false); if (PluginManager.handle(new ItemClickEvent(player, item, slotId, item.getDefinitions().getInventoryOption(0)))) return; if (itemId == 4155) { player.getSlayer().speakToMaster(player, null); return; } if (itemId == CoconutCracking.COCONUT) if (player.getInventory().containsItem(CoconutCracking.HAMMER)) { player.getInventory().deleteItem(CoconutCracking.COCONUT, 1); player.getInventory().addItem(CoconutCracking.OPEN_COCONUT, 1); player.sendMessage(""You break the coconut open with the hammer.""); } else player.sendMessage(""You need a hammer to break this open.""); if (Lamps.isSelectable(itemId) || Lamps.isSkillLamp(itemId) || Lamps.isOtherSelectableLamp(itemId)) Lamps.processLampClick(player, slotId, itemId); if (item.getId() == 405) { Item[] loot = DropTable.calculateDrops(player, DropSets.getDropSet(""fishing_casket"")); player.getInventory().deleteItem(405, 1); for (Item l : loot) if (item != null) player.getInventory().addItem(l); } if (item.getId() == 20120) { player.sendMessage(""Your key has "" + (item.getMetaDataI(""frozenKeyCharges"")-1) + "" uses left.""); return; } if (item.getId() == 20667) { player.stopAll(false); long lastVecna = player.getTempAttribs().getL(""LAST_VECNA""); if (lastVecna != -1 && lastVecna + 420000 > System.currentTimeMillis()) { player.sendMessage(""The skull has not yet regained "" + ""its mysterious aura. You will need to wait another "" + (lastVecna != -1 && lastVecna + 60000 > System.currentTimeMillis() ? ""7"" : (lastVecna != -1 && lastVecna + 120000 > System.currentTimeMillis() ? ""6"" : (lastVecna != -1 && lastVecna + 180000 > System.currentTimeMillis() ? ""5"" : (lastVecna != -1 && lastVecna + 240000 > System.currentTimeMillis() ? ""4"" : (lastVecna != -1 && lastVecna + 300000 > System.currentTimeMillis() ? ""3"" : (lastVecna != -1 && lastVecna + 360000 > System.currentTimeMillis() ? ""2"" : ""1"")))))) + "" minutes.""); return; } player.getTempAttribs().setL(""LAST_VECNA"", System.currentTimeMillis()); player.setNextSpotAnim(new SpotAnim(738, 0, 100)); player.setNextAnimation(new Animation(10530)); player.sendMessage(""The skull feeds off the life around you, boosting your magical ability.""); int actualLevel = player.getSkills().getLevel(Constants.MAGIC); int realLevel = player.getSkills().getLevelForXp(Constants.MAGIC); int level = actualLevel > realLevel ? realLevel : actualLevel; player.getSkills().set(Constants.MAGIC, level + 6); return; } if (item.getId() == 19675) { DungeonRewards.openHerbSelection(player); return; } if (itemId == 21776) { if (player.getInventory().containsItem(21776, 100)) { player.getInventory().deleteItem(21776, 100); player.getInventory().addItem(21775, 1); player.sendMessage(""You combine the shards into an orb.""); } else player.sendMessage(""You need 100 shards to create an orb.""); return; } if (itemId == 299) { if (player.isLocked()) return; if (World.getObject(Tile.of(player.getTile()), ObjectType.SCENERY_INTERACT) != null) { player.sendMessage(""You cannot plant flowers here..""); return; } final double random = Utils.random(100.0); final Tile tile = Tile.of(player.getTile()); int flower = Utils.random(2980, 2987); if (random < 0.2) flower = Utils.random(2987, 2989); if (!player.addWalkSteps(player.getX() - 1, player.getY(), 1)) if (!player.addWalkSteps(player.getX() + 1, player.getY(), 1)) if (!player.addWalkSteps(player.getX(), player.getY() + 1, 1)) player.addWalkSteps(player.getX(), player.getY() - 1, 1); player.getInventory().deleteItem(299, 1); final GameObject flowerObject = new GameObject(2987, ObjectType.SCENERY_INTERACT, Utils.getRandomInclusive(4), tile.getX(), tile.getY(), tile.getPlane()); final int flowerId = flower; World.spawnObjectTemporary(flowerObject, Ticks.fromSeconds(45)); player.lock(); WorldTasks.scheduleLooping(new Task() { int step; @Override public void run() { if (player == null || player.hasFinished()) stop(); if (step == 1) { player.startConversation(new FlowerPickup(player, flowerObject, flowerId)); player.setNextFaceTile(tile); player.unlock(); stop(); } step++; } }, 0, 0); } if (itemId >= 2520 && itemId <= 2526) { String[] phrases = { ""Come on Dobbin, we can win the race!"", ""Hi-ho Silver, and away!"", ""Neaahhhyyy! Giddy-up horsey!"" }; player.setNextAnimation(new Animation(918+((itemId-2520)/2))); player.setNextForceTalk(new ForceTalk(phrases[Utils.random(phrases.length)])); return; } if (itemId == 18336) { player.hasScrollOfLife = true; player.getInventory().deleteItem(18336, 1); player.sendMessage(""The secret is yours! You read the scroll and unlock the long lost technique of regaining seeds from dead farming patches.""); return; } if (itemId == 19890) { player.hasScrollOfCleansing = true; player.getInventory().deleteItem(19890, 1); player.sendMessage(""You read the scroll and unlock the ability to save herblore ingredients!""); return; } if (itemId == 19670) { player.hasScrollOfEfficiency = true; player.getInventory().deleteItem(19670, 1); player.sendMessage(""You read the scroll and unlock the ability to save bars when smithing!""); return; } if (itemId == 18344) { player.hasAugury = true; player.getInventory().deleteItem(18344, 1); player.sendMessage(""You read the scroll and unlock the ability to use the Augury prayer!""); return; } if (itemId == 18839) { player.hasRigour = true; player.getInventory().deleteItem(18839, 1); player.sendMessage(""You read the scroll and unlock the ability to use the Rigour prayer!""); return; } if (itemId == 18343) { player.hasRenewalPrayer = true; player.getInventory().deleteItem(18343, 1); player.sendMessage(""You read the scroll and unlock the ability to use the Rapid renewal prayer!""); return; } if (HerbCleaning.clean(player, item, slotId)) return; if (Lamps.isSelectable(itemId) || Lamps.isSkillLamp(itemId) || Lamps.isOtherSelectableLamp(itemId)) { Lamps.processLampClick(player, slotId, itemId); return; } Bone bone = Bone.forId(itemId); if (bone != null) { Bone.bury(player, slotId); return; } if (ItemTeleports.transportationDialogue(player, item)) return; if (itemId == 19967) { if (Magic.sendTeleportSpell(player, 7082, 7084, 1229, 1229, 1, 0, Tile.of(2952, 2933, 0), 4, true, TeleType.ITEM, null)) player.getInventory().deleteItem(19967, 1); return; } if (itemId >= 23653 && itemId <= 23658) FightKilnController.useCrystal(player, itemId); else if (player.getTreasureTrailsManager().useItem(item, slotId)) return; else if (itemId == 2574) player.getTreasureTrailsManager().useSextant(); else if (itemId == 2798 || itemId == 3565 || itemId == 3576 || itemId == 19042) player.getTreasureTrailsManager().openPuzzle(itemId); else if (item.getDefinitions().getName().startsWith(""Burnt"")) player.simpleDialogue(""Ugh, this is inedible.""); if (player.hasRights(Rights.DEVELOPER)) player.sendMessage(""ItemOption1: item: "" + itemId + "", slotId: "" + slotId); } public static void handleItemOption2(final Player player, final int slotId, final int itemId, Item item) { if (player.isLocked() || player.getEmotesManager().isAnimating() || PluginManager.handle(new ItemClickEvent(player, item, slotId, item.getDefinitions().getInventoryOption(1))) || Firemaking.isFiremaking(player, itemId)) { } } public static void handleItemOption3(Player player, int slotId, int itemId, Item item) { if (player.isLocked() || player.getEmotesManager().isAnimating() || PluginManager.handle(new ItemClickEvent(player, item, slotId, item.getDefinitions().getInventoryOption(2)))) return; player.stopAll(false); if (item.getDefinitions().isBindItem()) player.getDungManager().bind(item, slotId); else if (item.getDefinitions().containsOption(""Teleport"") && ItemTeleports.transportationDialogue(player, item)) return; if (player.hasRights(Rights.DEVELOPER)) player.sendMessage(""ItemOption3: item: "" + itemId + "", slotId: "" + slotId); } public static void handleItemOption4(Player player, int slotId, int itemId, Item item) { if (player.isLocked() || player.getEmotesManager().isAnimating()) { } } public static void handleItemOption5(Player player, int slotId, int itemId, Item item) { if (player.isLocked() || player.getEmotesManager().isAnimating()) { } } public static void handleItemOption6(Player player, int slotId, int itemId, Item item) { if (player.isLocked() || player.getEmotesManager().isAnimating() || PluginManager.handle(new ItemClickEvent(player, item, slotId, item.getDefinitions().getInventoryOption(3)))) return; player.stopAll(false); if (itemId == 1438) Runecrafting.locate(player, 3127, 3405); else if (itemId == 1440) Runecrafting.locate(player, 3306, 3474); else if (itemId == 1442) Runecrafting.locate(player, 3313, 3255); else if (itemId == 1444) Runecrafting.locate(player, 3185, 3165); else if (itemId == 1446) Runecrafting.locate(player, 3053, 3445); else if (itemId == 1448) Runecrafting.locate(player, 2982, 3514); else if ((item.getDefinitions().containsOption(""Rub"") || item.getDefinitions().containsOption(""Cabbage-port"")) && ItemTeleports.transportationDialogue(player, item)) return; else if (itemId >= 8901 && itemId <= 8920 && !ItemDefinitions.getDefs(itemId).isNoted()) { player.getInventory().deleteItem(itemId, 1); player.getInventory().addItem(8921, 1); } else if (itemId == 14057) SorceressGardenController.teleportToSocreressGarden(player, true); if (player.hasRights(Rights.DEVELOPER)) player.sendMessage(""ItemOption6: item: "" + itemId + "", slotId: "" + slotId); } public static void handleItemOption7(Player player, int slotId, int itemId, Item item) { if (player.isLocked() || player.getEmotesManager().isAnimating() || !player.getBank().checkPin() || !player.getControllerManager().canDropItem(item)) return; if (item.getDefinitions().isDestroyItem()) { player.startConversation(new DestroyItem(player, slotId, item)); return; } if (PluginManager.handle(new ItemClickEvent(player, item, slotId, item.getDefinitions().getInventoryOption(4)))) return; player.stopAll(false); if (player.getPetManager().spawnPet(itemId, true)) return; DropItemEvent event = new DropItemEvent(player, item); PluginManager.handle(event); if (event.dropCancelled()) return; player.getInventory().deleteItem(slotId, item); World.addGroundItem(item, Tile.of(player.getTile()), player); player.soundEffect(ItemConfig.get(item.getId()).getDropSound(), false); } public static void handleItemOption8(Player player, int slotId, int itemId, Item item) { player.getInventory().sendExamine(slotId); } public static Item contains(int id1, Item item1, Item item2) { if (item1.getId() == id1) return item2; if (item2.getId() == id1) return item1; return null; } public static boolean contains(int id1, int id2, Item... items) { boolean containsId1 = false; boolean containsId2 = false; for (Item item : items) if (item.getId() == id1) containsId1 = true; else if (item.getId() == id2) containsId2 = true; return containsId1 && containsId2; } }" "package com.rs.net.decoders.handlers; public class NPCHandler { public static void handleExamine(final Player player, final NPC npc) { if (player.hasRights(Rights.DEVELOPER)) { player.sendMessage(""NPC - [id="" + npc.getId() + "", loc=["" + npc.getX() + "", "" + npc.getY() + "", "" + npc.getPlane() + ""]]. "" + npc.getDefinitions().respawnDirection); player.sendMessage(""HP: "" + npc.getMaxHitpoints() + "" Crush Def: "" + npc.getDefinitions().getCrushDef() + "" Slash Def: "" + npc.getDefinitions().getSlashDef() + "" Stab Def: "" + npc.getDefinitions().getStabDef() + "" Range Def: ""+ npc.getDefinitions().getRangeDef() + "" Mage Def: "" + npc.getDefinitions().getMagicDef()); if (npc.getDefinitions().transformTo != null) player.sendMessage(npc.getDefinitions().getConfigInfoString()); player.sendMessage(""Spawn tile ["" + npc.getRespawnTile().getX() + "", "" + npc.getRespawnTile().getY() + "", "" + npc.getRespawnTile().getPlane() + ""]]. ""); } player.getPackets().sendNPCMessage(0, 0xFFFFFF, npc, NPCExamines.getExamine(npc, player) + "" (""+npc.getId()+"")""); if (npc.getDefinitions().hasAttackOption() || npc.getDefinitions().hasOption(""Investigate"")) player.sendOptionDialogue(""Would you like to check the drops on this monster?"", ops -> { ops.add(""Show drops (1,000 kills)"", () -> NPC.displayDropsFor(player, npc.getId(), 1000)); ops.add(""Show drops (5,000 kills)"", () -> NPC.displayDropsFor(player, npc.getId(), 5000)); ops.add(""Show drops (10,000 kills)"", () -> NPC.displayDropsFor(player, npc.getId(), 10000)); ops.add(""Nevermind""); }); Logger.debug(NPCHandler.class, ""handleExamine"", ""Examined NPC: index: "" + npc.getIndex() + "", id: "" + npc.getId()); } public static void handleOption1(final Player player, final NPC npc) { player.stopAll(true); if (PluginManager.handle(new NPCClickEvent(player, npc, 1, false))) return; Object dist = PluginManager.getObj(new NPCInteractionDistanceEvent(player, npc)); int distance = 0; if (dist != null) distance = (int) dist; player.getInteractionManager().setInteraction(new StandardEntityInteraction(npc, distance, () -> { if (!player.getControllerManager().processNPCClick1(npc)) return; npc.resetWalkSteps(); player.faceEntity(npc); npc.faceEntity(player); Object[] shipAttributes = BoatingD.getBoatForShip(player, npc.getId()); if (shipAttributes != null) { player.startConversation(new BoatingD(player, npc.getId())); return; } if (npc instanceof GraveStone grave) { grave.sendGraveInscription(player); npc.resetDirection(); return; } if (player.getTreasureTrailsManager().useNPC(npc)) return; if (npc.getId() == 2825) player.sendOptionDialogue(""Would you like to travel to Braindeath Island?"", ops -> { ops.add(""Yes"", () -> player.tele(Tile.of(2163, 5112, 1))); ops.add(""No""); }); else if (npc.getId() == 2826) player.sendOptionDialogue(""Would you like to travel back to Port Phasmatys?"", ops -> { ops.add(""Yes"", () -> player.tele(Tile.of(3680, 3536, 0))); ops.add(""No""); }); else if (npc.getId() == 9707) player.startConversation(new FremennikShipmaster(player, npc.getId(), true)); else if (npc.getId() == 8269) player.startConversation(new GenericSkillcapeOwnerD(player, 8269, Skillcapes.Strength)); else if (npc.getId() == 705) player.startConversation(new GenericSkillcapeOwnerD(player, 705, Skillcapes.Defence)); else if (npc.getId() == 961) player.startConversation(new GenericSkillcapeOwnerD(player, 961, Skillcapes.Constitution)); else if (npc.getId() == 682) player.startConversation(new GenericSkillcapeOwnerD(player, 682, Skillcapes.Ranging)); else if (npc.getId() == 802) player.startConversation(new GenericSkillcapeOwnerD(player, 802, Skillcapes.Prayer)); else if (npc.getId() == 1658) player.startConversation(new GenericSkillcapeOwnerD(player, 1658, Skillcapes.Magic)); else if (npc.getId() == 847) player.startConversation(new GenericSkillcapeOwnerD(player, 847, Skillcapes.Cooking)); else if (npc.getId() == 4906) player.startConversation(new GenericSkillcapeOwnerD(player, 4906, Skillcapes.Woodcutting)); else if (npc.getId() == 575) player.startConversation(new GenericSkillcapeOwnerD(player, 575, Skillcapes.Fletching)); else if (npc.getId() == 308) player.startConversation(new GenericSkillcapeOwnerD(player, 308, Skillcapes.Fishing)); else if (npc.getId() == 4946) player.startConversation(new GenericSkillcapeOwnerD(player, 4946, Skillcapes.Firemaking)); else if (npc.getId() == 805) player.startConversation(new GenericSkillcapeOwnerD(player, 805, Skillcapes.Crafting)); else if (npc.getId() == 3295) player.startConversation(new GenericSkillcapeOwnerD(player, 3295, Skillcapes.Mining)); else if (npc.getId() == 437) player.startConversation(new GenericSkillcapeOwnerD(player, 437, Skillcapes.Agility)); else if (npc.getId() == 2270) player.startConversation(new GenericSkillcapeOwnerD(player, 2270, Skillcapes.Thieving)); else if (npc.getId() == 3299) player.startConversation(new GenericSkillcapeOwnerD(player, 3299, Skillcapes.Farming)); else if (npc.getId() == 13632) player.startConversation(new GenericSkillcapeOwnerD(player, 13632, Skillcapes.Runecrafting)); else if (npc.getId() == 5113) player.startConversation(new GenericSkillcapeOwnerD(player, 5113, Skillcapes.Hunter)); else if (npc.getId() == 9713) player.startConversation(new GenericSkillcapeOwnerD(player, 9713, Skillcapes.Dungeoneering)); else if (npc.getId() == 9708 || npc.getId() == 14847) player.startConversation(new FremennikShipmaster(player, npc.getId(), false)); else if (npc.getId() == 6715 || npc.getId() == 14862) player.startConversation(new EstateAgentDialogue(player, npc.getId())); else if (npc.getId() == 3344 || npc.getId() == 3345) MutatedZygomite.transform(player, npc); else if (npc.getId() == 4236 || npc.getId() == 4238 || npc.getId() == 4240 || npc.getId() == 4242 || npc.getId() == 4244) player.startConversation(new ServantDialogue(player, npc)); else if (npc.getId() == 2824 || npc.getId() == 1041 || npc.getId() == 804) player.startConversation(new TanningD(player, npc.getId() == 1041, npc.getId())); else if (PluginManager.handle(new NPCClickEvent(player, npc, 1, true))) { } else if (npc instanceof Pet pet) { if (pet != player.getPet()) { player.sendMessage(""This isn't your pet.""); return; } player.setNextAnimation(new Animation(827)); pet.pickup(); } else { player.sendMessage(""Nothing interesting happens."" + npc.getId()); Logger.debug(NPCHandler.class, ""handleOption1"", ""NPC: "" + npc.getId() + "", ("" + npc.getX() + "", "" + npc.getY() + "", "" + npc.getPlane() + "")""); } })); } public static void handleOption2(Player player, NPC npc) { player.stopAll(true); if (PluginManager.handle(new NPCClickEvent(player, npc, 2, false))) return; player.getInteractionManager().setInteraction(new StandardEntityInteraction(npc, 0, () -> PluginManager.handle(new NPCClickEvent(player, npc, 2, true)))); } public static void handleOption3(final Player player, final NPC npc) { if (player.isLocked() && player.getActionManager().getAction() != null && player.getActionManager().getAction() instanceof PickPocketAction) return; player.stopAll(true); if (PluginManager.handle(new NPCClickEvent(player, npc, 3, false))) return; Object dist = PluginManager.getObj(new NPCInteractionDistanceEvent(player, npc)); int distance = 0; if (dist != null) distance = (int) dist; player.getInteractionManager().setInteraction(new StandardEntityInteraction(npc, distance, () -> { if (!player.getControllerManager().processNPCClick2(npc)) return; player.faceEntity(npc); npc.faceEntity(player); if (player.getTreasureTrailsManager().useNPC(npc)) return; PickPocketableNPC pocket = PickPocketableNPC.get(npc.getId()); if (pocket != null) { npc.resetDirection(); player.getActionManager().setAction(new PickPocketAction(npc, pocket)); return; } npc.resetWalkSteps(); Object[] shipAttributes = BoatingD.getBoatForShip(player, npc.getId()); if (shipAttributes != null) { if(npc.getId() == 380 && player.getQuestManager().getStage(Quest.PIRATES_TREASURE) == PiratesTreasure.SMUGGLE_RUM) { player.startConversation(new CustomsOfficerPiratesTreasureD(player).getStart()); return; } TravelMethods.sendCarrier(player, (Carrier) shipAttributes[0], (boolean) shipAttributes[1]); return; } if (npc instanceof Familiar && npc.getDefinitions().hasOption(""cure"")) { if (player.getFamiliar() != npc) { player.sendMessage(""That isn't your familiar.""); return; } if (!player.getPoison().isPoisoned()) { player.sendMessage(""Your arent poisoned or diseased.""); return; } player.getFamiliar().drainSpec(2); player.addEffect(Effect.ANTIPOISON, Ticks.fromMinutes(2)); return; } if (npc.getId() == 9707) FremennikShipmaster.sail(player, true); else if (npc.getId() == 1686) { if (player.getInventory().hasFreeSlots() && player.unclaimedEctoTokens > 0) { player.getInventory().addItem(Ectofuntus.ECTO_TOKEN, player.unclaimedEctoTokens); player.unclaimedEctoTokens = 0; } } else if (npc.getId() == 9708 || npc.getId() == 14847) FremennikShipmaster.sail(player, false); else if (npc instanceof GraveStone grave) { grave.repair(player, false); } else if (npc.getId() == 11267) { int[] noteableFish = { 377, 371, 359, 317, 345, 327 }; for (Item item : player.getInventory().getItems().array()) { if (item == null) continue; for (int id : noteableFish) if (item.getId() == id) { player.getInventory().deleteItem(item.getId(), 1); player.getInventory().addItem(item.getDefinitions().getCertId(), 1); } } } else if (npc.getId() == 8228) StealingCreationShop.openInterface(player); else if (npc.getId() == 14849 && npc instanceof ConditionalDeath cd) cd.useHammer(player); else if (npc.getId() == 2824 || npc.getId() == 1041) player.startConversation(new TanningD(player, npc.getId() == 1041, npc.getId())); else if (npc.getId() == 1843) player.tele(Tile.of(2836, 10142, 0)); else if (npc.getId() == 1844) player.tele(Tile.of(2839, 10131, 0)); else if (npc.getId() == 1419) GE.open(player); else if (npc.getId() == 2676 || npc.getId() == 599) PlayerLook.openMageMakeOver(player); else if (npc.getId() == 598) PlayerLook.openHairdresserSalon(player); else if (PluginManager.handle(new NPCClickEvent(player, npc, 3, true))) ; else { player.sendMessage(""Nothing interesting happens."" + npc.getId()); Logger.debug(NPCHandler.class, ""handleOption2"", ""NPC: "" + npc.getId() + "", ("" + npc.getX() + "", "" + npc.getY() + "", "" + npc.getPlane() + "") op: "" + npc.getDefinitions(player).getOption(2)); } })); } public static void handleOption4(final Player player, final NPC npc) { player.stopAll(true); if (PluginManager.handle(new NPCClickEvent(player, npc, 4, false))) return; Object dist = PluginManager.getObj(new NPCInteractionDistanceEvent(player, npc)); int distance = 0; if (dist != null) distance = (int) dist; player.getInteractionManager().setInteraction(new StandardEntityInteraction(npc, distance, () -> { if (!player.getControllerManager().processNPCClick3(npc)) return; npc.resetWalkSteps(); player.faceEntity(npc); npc.faceEntity(player); if (npc instanceof GraveStone grave) { grave.repair(player, true); npc.resetDirection(); return; } if (npc.getId() == 548) PlayerLook.openThessaliasMakeOver(player); else if (npc.getId() == 1526) player.getInterfaceManager().sendInterface(60); else if (PluginManager.handle(new NPCClickEvent(player, npc, 4, true))) { } else player.sendMessage(""Nothing interesting happens."" + npc.getId()); })); Logger.debug(NPCHandler.class, ""handleOption4"", ""NPC: "" + npc.getId() + "", ("" + npc.getX() + "", "" + npc.getY() + "", "" + npc.getPlane() + "")""); } public static void handleOption5(final Player player, final NPC npc) { player.stopAll(true); PluginManager.handle(new NPCClickEvent(player, npc, 5, false)); Object dist = PluginManager.getObj(new NPCInteractionDistanceEvent(player, npc)); int distance = 0; if (dist != null) distance = (int) dist; player.getInteractionManager().setInteraction(new StandardEntityInteraction(npc, distance, () -> { if (!player.getControllerManager().processNPCClick3(npc)) return; npc.resetWalkSteps(); player.faceEntity(npc); npc.faceEntity(player); if (npc instanceof GraveStone grave) { grave.demolish(player); npc.resetDirection(); return; } if (PluginManager.handle(new NPCClickEvent(player, npc, 5, true))) return; player.sendMessage(""Nothing interesting happens. "" + npc.getId()); Logger.debug(NPCHandler.class, ""handleOption5"", ""NPC: "" + npc.getId() + "", ("" + npc.getX() + "", "" + npc.getY() + "", "" + npc.getPlane() + "")""); })); } public static int getShopIdForNpc(int npcId) { return switch (npcId) { case 1254 -> // Razmire's General Store"", Razmire Keelgan. (3488, 3296, 0) -1; // TODO get burgh de rott transforming npc spawns case 1866 -> // Pollniveach General Store"", Market Seller. (3359, 2983, 0) -1; // TODO case 3166 -> // Dodgy Mike's Second-hand Clothing"", Mike. (3689, 2977, 0) -1; // TODO case 2162 -> // Vermundi's Clothes Stall"", Vermundia. (2887, 10189, 0) -1; // TODO case 517 -> // Shilo Village Fishing Shop"", Fernahei. (2871, 2968, 0) -1; // TODO implemented in Karamja.java case 1433 -> // Solihib's food stall"", Solihib. (2769, 2789, 0) -1; // TODO case 1862 -> // Ali's Discount Wares"", Ali. (3301, 3211, 0) -1; // TODO case 1435 -> // Tutab's Magical Market"", Tutab. (2757, 2770, 0) -1; // TODO case 1980 -> // The Spice is Right"", Embalmer. (3286, 2805, 0) -1; // TODO default -> -1; }; } }" "package com.rs.net.decoders.handlers; public final class ObjectHandler { public static void handleOption1(final Player player, final GameObject object) { final ObjectDefinitions objectDef = object.getDefinitions(player); final int id = object.getId(); final int x = object.getX(); final int y = object.getY(); if (!objectDef.containsOption(0) || PluginManager.handle(new ObjectClickEvent(player, object, ClientPacket.OBJECT_OP1, false))) return; player.setRouteEvent(new RouteEvent(object, () -> { player.stopAll(); player.faceObject(object); if (!player.getControllerManager().processObjectClick1(object) || player.getTreasureTrailsManager().useObject(object)) return; if (object.getId() == 5259) { if (player.getY() == 3507) player.tele(Tile.of(player.getX(), player.getY() + 2, 0)); else if (player.getY() == 3509) player.tele(Tile.of(player.getX(), player.getY() - 2, 0)); return; } else if (object.getId() == 29099) { if (player.getY() > object.getY()) player.tele(object.getTile().transform(1, -1, 0)); else player.tele(object.getTile().transform(1, 1, 0)); } if (object.getId() == 36687) { player.useStairs(828, Tile.of(player.getX(), player.getY() + 6400, 0)); return; } if (object.getId() == 16535) { player.getControllerManager().startController(new AgilityPyramidController()); AgilityPyramidController.climbRocks(player, object); } else if (object.getId() == 11739) { player.useStairs(828, player.transform(0, -2, 1)); return; } else if (object.getId() == 11741) { player.useStairs(828, player.transform(0, 2, -1)); return; } else if (object.getId() == 24357 || object.getId() == 24358 || object.getId() == 11734) { switch(object.getRotation()) { case 0: player.useStairs(-1, player.transform(0, 4, 1), 1, 1); break; case 1: player.useStairs(-1, player.transform(4, 0, 1), 1, 1); break; case 2: player.useStairs(-1, player.transform(0, -4, 1), 1, 1); break; case 3: player.useStairs(-1, player.transform(-4, 0, 1), 1, 1); break; } return; } else if (object.getId() == 24359 || object.getId() == 24360 || object.getId() == 35783) { if (object.getTile().isAt(3189, 3432)) { player.useStairs(-1, player.transform(2, 6400, 0), 1, 1); return; } switch(object.getRotation()) { case 0: player.useStairs(-1, player.transform(0, -4, -1), 1, 1); break; case 1: player.useStairs(-1, player.transform(-4, 0, -1), 1, 1); break; case 2: player.useStairs(-1, player.transform(0, 4, -1), 1, 1); break; case 3: player.useStairs(-1, player.transform(4, 0, -1), 1, 1); break; } return; } else if (object.getId() == 66518) { player.useStairs(828, Tile.of(3047, 4971, 0)); return; } else if (object.getId() == 7258) { player.useStairs(-1, Tile.of(2896, 3447, 0), 1, 1); return; } if (object.getId() == 15468) { if (!player.getInventory().containsItem(2347, 1)) { player.getInventory().addItem(2347, 1); player.sendMessage(""You take a hammer.""); return; } player.sendMessage(""You don't need another one right now.""); return; } if (object.getId() == 48496) player.getDungManager().enterDungeon(true); else if (id == 31149) { boolean isEntering = player.getX() <= 3295; player.useStairs(isEntering ? 9221 : 9220, Tile.of(x + (isEntering ? 1 : 0), y, 0)); } else if (id == 2350 && (object.getX() == 3352 && object.getY() == 3417 && object.getPlane() == 0)) player.useStairs(832, Tile.of(3177, 5731, 0)); else if (id >= 65616 && id <= 65622) WildernessObelisk.activateObelisk(id, player); else if (id == 10229) { // dag up ladder player.setNextAnimation(new Animation(828)); WorldTasks.schedule(1, () -> player.tele(Tile.of(1910, 4367, 0))); } else if (id == 17757) { Agility.handleObstacle(player, 3303, 1, player.transform(0, player.getY() < object.getY() ? 2 : -2, 0), 0); } else if (id == 56805) { // HARBLORE HARBITAT if (object.getRotation() == 3 || object.getRotation() == 1) Agility.handleObstacle(player, 3303, 1, player.transform(player.getX() < object.getX() ? 2 : -2, 0, 0), 0); else Agility.handleObstacle(player, 3303, 1, player.transform(0, player.getY() < object.getY() ? 2 : -2, 0), 0); } else if (id == 27126) { // HARBLORE HARBITAT if (player.getX() >= 2961 && player.getX() <= 2964) player.tele(Tile.of(player.getX() + 12, player.getY() + 2, player.getPlane())); else if (player.getX() >= 2975 && player.getX() <= 2979) player.tele(Tile.of(player.getX() - 12, player.getY() - 2, player.getPlane())); } else if (id == 10230) { // dag down ladder player.setNextAnimation(new Animation(828)); WorldTasks.schedule(new Task() { @Override public void run() { player.tele(Tile.of(2900, 4449, 0)); } }, 1); } else if (id == 15653) { if (World.isSpawnedObject(object) || !WarriorsGuild.canEnter(player)) return; player.lock(2); GameObject opened = new GameObject(object.getId(), object.getType(), object.getRotation() - 1, object.getX(), object.getY(), object.getPlane()); World.spawnObjectTemporary(opened, 1); player.addWalkSteps(2876, 3542, 2, false); } else if (id == 14315) { if (Lander.canEnter(player, 0)) { } } else if (id == 25631) { if (Lander.canEnter(player, 1)) { } } else if (id == 25632) { if (Lander.canEnter(player, 2)) { } } else if (id == 35391 || id == 2832) { if (!Agility.hasLevel(player, id == 2832 ? 20 : 41)) return; player.addWalkSteps(x, y); WorldTasks.schedule(new Task() { @Override public void run() { boolean isTravelingWest = id == 2832 ? player.getX() >= 2508 : (x == 2834 && y == 3626) ? player.getX() >= 2834 : player.getX() >= 2900; player.useStairs(3303, Tile.of((isTravelingWest ? -2 : 2) + player.getX(), player.getY(), 0), 2, 3, null, true); } }); } else if (id == 65371) // Chaos altar (armored zombie) player.getPrayer().worshipAltar(); else if (id == 65715) // Armored zombie trapdoor player.tele(Tile.of(3241, 9991, 0)); else if (id == 12328) // Jadinko lair player.tele(Tile.of(3011, 9276, 0)); else if (id == 11209) player.useStairs(-1, player.transform(3, 0, 1), 0, 1); else if (id == 11210) player.useStairs(-1, player.transform(-3, 0, -1), 0, 1); else if (id == 11212) player.useStairs(-1, player.transform(0, 3, -1), 0, 1); else if (id == 11211) player.useStairs(-1, player.transform(0, -3, 1), 0, 1); else if (id == 38279 && x == 1696 && y == 5460) player.useStairs(-1, Tile.of(3106, 3160, 1), 0, 1); else if (id == 12327) { // jadinko lair out player.tele(Tile.of(2948, 2955, 0)); } else if (id == 4495) { // Slayer tower stairs up player.tele(Tile.of(3417, 3541, 2)); } else if (id == 4496) { // Slayer tower stairs down player.tele(Tile.of(3412, 3540, 1)); } else if (id == 39191) { // Armored zombie up ladder player.setNextAnimation(new Animation(828)); WorldTasks.schedule(1, () -> { player.tele(Tile.of(3240, 3607, 0)); player.getControllerManager().startController(new WildernessController()); }); } else if (id == 2353 && (object.getX() == 3177 && object.getY() == 5730 && object.getPlane() == 0)) player.useStairs(828, Tile.of(3353, 3416, 0)); else if (id == 66115 || id == 66116) Spade.dig(player); else if (id == 20604) player.useStairs(-1, Tile.of(3018, 3404, 0), 0, 1); else if (object.getId() == 39508 || object.getId() == 39509) StealingCreationLobbyController.climbOverStile(player, object, true); else if (id == 16135) { if (player.getEmotesManager().unlockedEmote(Emote.FLAP)) { player.sendMessage(""You have already claimed your reward from this level.""); return; } player.startConversation(new StrongholdRewardD(player, 0)); } else if (id == 16077) { if (player.getEmotesManager().unlockedEmote(Emote.SLAP_HEAD)) { player.sendMessage(""You have already claimed your reward from this level.""); return; } player.startConversation(new StrongholdRewardD(player, 1)); } else if (id == 16118) { if (player.getEmotesManager().unlockedEmote(Emote.IDEA)) { player.sendMessage(""You have already claimed your reward from this level.""); return; } player.startConversation(new StrongholdRewardD(player, 2)); } else if (id == 16047) player.startConversation(new StrongholdRewardD(player, 3)); else if (id == 47120) { // zaros altar recharge if needed if (player.getPrayer().getPoints() < player.getSkills().getLevelForXp(Constants.PRAYER) * 10) { player.lock(12); player.setNextAnimation(new Animation(12563)); player.getPrayer().setPoints(((player.getSkills().getLevelForXp(Constants.PRAYER) * 10) * 1.15)); player.getPrayer().refreshPoints(); } player.startConversation(new Dialogue() .addOptions(""Change from "" + ((player.getPrayer().isCurses() ? ""curses"" : ""prayers"")) + ""?"", ops -> { ops.add(""Yes, replace my prayer book."", () -> { if (player.getPrayer().isCurses()) player.simpleDialogue(""The altar eases its grip on your mid. The curses slip from"", ""your memory and you recall the prayers you used to know.""); else player.simpleDialogue(""The altar fills your head with dark thoughts, purging the"", ""prayers from your memory and leaving only curses in"", "" their place.""); player.getPrayer().setPrayerBook(!player.getPrayer().isCurses()); }); ops.add(""Nevermind.""); })); } else if (id == 9356) FightCavesController.enterFightCaves(player); else if (id == 68107) FightKilnController.enterFightKiln(player, false); else if (id == 68223) FightPits.enterLobby(player, false); else if (id == 26684 || id == 26685 || id == 26686) // poison waste cave player.useStairs(-1, Tile.of(1989, 4174, 0), 1, 2, ""You enter the murky cave...""); else if (id == 26571 || id == 26572 || id == 26573 || id == 26574) player.useStairs(-1, Tile.of(2321, 3100, 0)); else if (id == 26560 && x == 2015 && y == 4255) player.simpleDialogue(""The room beyond the door is covered in gas, it is probably dangerous to go in there.""); else if (id == 26519) { if (x == 1991 && y == 4175) player.useStairs(827, Tile.of(1991, 4175, 0)); else if (x == 1998 && y == 4218) player.useStairs(827, Tile.of(1998, 4218, 0)); else if (x == 2011 && y == 4218) player.useStairs(827, Tile.of(2011, 4218, 0)); else player.useStairs(827, Tile.of(x - 1, y, 0)); } else if (id == 19171) { if (!Agility.hasLevel(player, 20)) return; player.useStairs(-1, Tile.of(player.getX() >= 2523 ? 2522 : 2523, 3375, 0), 1, 2, ""You easily squeeze through the railing.""); } else if (id == 22945) { player.useStairs(-1, Tile.of(3318, 9602, 0), 0, 1); player.getControllerManager().startController(new UndergroundDungeonController(false, true)); } else if (id == 15767) { player.useStairs(-1, Tile.of(3748, 9373, 0), 0, 1); player.getControllerManager().startController(new UndergroundDungeonController(false, true)); } else if (object.getId() == 15791) { if (object.getX() == 3829) player.useStairs(-1, Tile.of(3830, 9461, 0)); if (object.getX() == 3814) player.useStairs(-1, Tile.of(3815, 9461, 0)); player.getControllerManager().startController(new UndergroundDungeonController(false, true)); } else if (id == 5947) { player.useStairs(540, Tile.of(3170, 9571, 0), 8, 9); WorldTasks.schedule(new Task() { @Override public void run() { player.getControllerManager().startController(new UndergroundDungeonController(false, true)); player.setNextAnimation(new Animation(-1)); } }, 8); } else if (object.getId() == 6658) { player.useStairs(-1, Tile.of(3226, 9542, 0)); player.getControllerManager().startController(new UndergroundDungeonController(false, true)); } else if (object.getId() == 6898) { player.setNextAnimation(new Animation(10578)); player.useStairs(-1, object.getTile()); player.useStairs(10579, Tile.of(3221, 9618, 0)); player.getControllerManager().startController(new UndergroundDungeonController(false, true)); player.sendMessage(""You squeeze through the hole.""); } else if (id == 36002) { player.getControllerManager().startController(new UndergroundDungeonController(true, false)); player.useStairs(833, Tile.of(3206, 9379, 0)); } else if (id == 31359) { player.useStairs(-1, Tile.of(3360, 9352, 0)); player.getControllerManager().startController(new UndergroundDungeonController(true, true)); } else if (id == 69197 || id == 69198) { Doors.handleInPlaceDoubleDoor(player, object); player.resetWalkSteps(); player.addWalkSteps(object.getX(), player.getY() <= 3491 ? player.getY() + 2 : player.getY() - 2, -1, false); } else if (id == 4756) switch(object.getRotation()) { case 0: player.useStairs(-1, player.transform(0, 4, 1), 1, 1); break; case 1: player.useStairs(-1, player.transform(-4, 0, 1), 1, 1); break; case 2: player.useStairs(-1, player.transform(0, -4, 1), 1, 1); break; case 3: player.useStairs(-1, player.transform(4, 0, 1), 1, 1); break; } else if (id == 4755) switch(object.getRotation()) { case 0: player.useStairs(-1, player.transform(0, -4, -1), 1, 1); break; case 1: player.useStairs(-1, player.transform(4, 0, -1), 1, 1); break; case 2: player.useStairs(-1, player.transform(0, 4, -1), 1, 1); break; case 3: player.useStairs(-1, player.transform(-4, 0, -1), 1, 1); break; } else if (id == 16960 || id == 16959) switch(object.getRotation()) { case 0: player.useStairs(828, player.transform(2, 0, 1), 1, 1); break; case 1: player.useStairs(828, player.transform(0, -2, 1), 1, 1); break; case 2: player.useStairs(828, player.transform(0, 2, 1), 1, 1); break; case 3: player.useStairs(828, player.transform(0, 2, 1), 1, 1); break; } else if (id == 16962 || id == 16961) switch(object.getRotation()) { case 0: player.useStairs(827, player.transform(-2, 0, -1), 1, 1); break; case 1: player.useStairs(827, player.transform(0, 2, -1), 1, 1); break; case 2: player.useStairs(827, player.transform(0, -2, -1), 1, 1); break; case 3: player.useStairs(827, player.transform(0, -2, -1), 1, 1); break; } else if (id == 1759 || id == 4780) player.useStairs(827, player.transform(0, 6400, 0), 1, 1); else if (id == 4781) player.useStairs(828, player.transform(0, -6400, 0), 1, 1); else if (id == 29392) player.useStairs(-1, Tile.of(3061, 3335, 0), 1, 1); else if (id == 29386 || id == 29385) player.useStairs(-1, Tile.of(3067, 9710, 0), 1, 1); else if (id == 29391) player.useStairs(-1, Tile.of(3037, 3342, 0), 1, 1); else if (id == 29387) player.useStairs(-1, Tile.of(3035, 9713, 0), 1, 1); else if (id == 7104) player.useStairs(-1, player.transform(4, -2, 1), 1, 1); else if (id == 7107) player.useStairs(-1, player.transform(-4, 2, -1), 1, 1); else if (id == 4772) player.useStairs(828, player.transform(0, 0, 1), 1, 1); else if (id == 4778) player.useStairs(827, player.transform(0, 0, -1), 1, 1); else if (id == 4622) player.useStairs(-1, player.transform(0, object.getRotation() == 2 ? -4 : 4, 1), 1, 1); else if (id == 4620) player.useStairs(-1, player.transform(0, object.getRotation() == 2 ? 4 : -4, -1), 1, 1); else if (id == 73681) player.useStairs(-1, player.transform(player.getX() < x ? 3 : -3, 0, 0), 1, 1); else if (id == 2712) { if (player.getSkills().getLevel(Constants.COOKING) < 32 && player.getY() < 3444) { player.startConversation(new Conversation(player, new Dialogue(new NPCStatement(847, HeadE.ANGRY, ""I can't allow someone as novice as you into my kitchen!"")))); return; } if (player.getEquipment().getHatId() != 1949 && player.getY() < 3444) { player.startConversation(new Conversation(player, new Dialogue(new NPCStatement(847, HeadE.ANGRY, ""You sure don't look much like a chef!"")))); return; } Doors.handleDoor(player, object); } else if (id == 2647) { if (player.getSkills().getLevel(Constants.CRAFTING) < 40 && player.getY() < 3288) { player.startConversation(new Conversation(player, new Dialogue(new NPCStatement(805, HeadE.CHEERFUL, ""I'm sorry, you need to have a crafting level of 40 to use my facilities."")))); return; } if (player.getEquipment().getChestId() != 1757 && player.getY() > 3288) { player.startConversation(new Conversation(player, new Dialogue(new NPCStatement(805, HeadE.CHEERFUL, ""Don't forget to put on your brown apron! It can be a little messy in here."")))); return; } Doors.handleDoor(player, object); } else if (id == 64890) player.useLadder(player.transform(0, 0, 1)); //bottom floor ladders of dark warriors fortress. else if (id == 71921) player.useStairs(828, player.transform(0, 0, 1)); else if (id == 20602) player.useStairs(-1, Tile.of(2969, 9672, 0), 1, 1); else if (id == 4627) player.useStairs(-1, Tile.of(2893, 3567, 0), 1, 1); else if (id == 66973) player.useStairs(-1, Tile.of(2206, 4934, 1), 1, 1); else if (id == 22666) { player.useStairs(-1, player.transform(-5, 0, -3), 1, 1); } else if (id == 22600) { player.useStairs(-1, player.transform(5, 0, 3), 1, 1); } else if (id == 22937) switch(object.getRotation()) { case 0: player.useStairs(-1, player.transform(4, 0, 1), 1, 1); break; case 1: player.useStairs(-1, player.transform(0, -4, 1), 1, 1); break; case 2: player.useStairs(-1, player.transform(-4, 0, 1), 1, 1); break; case 3: player.useStairs(-1, player.transform(0, 4, 1), 1, 1); break; } else if (id == 22938) switch(object.getRotation()) { case 0: player.useStairs(-1, player.transform(-4, 0, -1), 1, 1); break; case 1: player.useStairs(-1, player.transform(0, 4, -1), 1, 1); break; case 2: player.useStairs(-1, player.transform(4, 0, -1), 1, 1); break; case 3: player.useStairs(-1, player.transform(0, -4, -1), 1, 1); break; } else if (id == 22931) switch(object.getRotation()) { case 0: player.useStairs(-1, player.transform(0, 3, 1), 1, 1); break; case 1: player.useStairs(-1, player.transform(3, 0, 1), 1, 1); break; case 2: player.useStairs(-1, player.transform(0, -3, 1), 1, 1); break; case 3: player.useStairs(-1, player.transform(-3, 0, 1), 1, 1); break; } else if (id == 22932) switch(object.getRotation()) { case 0: player.useStairs(-1, player.transform(0, -3, -1), 1, 1); break; case 1: player.useStairs(-1, player.transform(-3, 0, -1), 1, 1); break; case 2: player.useStairs(-1, player.transform(0, 3, -1), 1, 1); break; case 3: player.useStairs(-1, player.transform(3, 0, -1), 1, 1); break; } else if (id == 22933) switch(object.getRotation()) { case 0: player.useStairs(-1, player.transform(0, -3, -1), 1, 1); break; case 1: player.useStairs(-1, player.transform(-3, 0, -1), 1, 1); break; case 2: player.useStairs(-1, player.transform(0, 3, -1), 1, 1); break; case 3: player.useStairs(-1, player.transform(3, 0, -1), 1, 1); break; } else if (id == 34548 || id == 22941 || id == 22939) switch(object.getRotation()) { case 0: player.useStairs(-1, player.transform(3, 0, 1), 1, 1); break; case 1: player.useStairs(-1, player.transform(0, -3, 1), 1, 1); break; case 2: player.useStairs(-1, player.transform(-3, 0, 1), 1, 1); break; case 3: player.useStairs(-1, player.transform(0, 3, 1), 1, 1); break; } else if (id == 34550 || id == 22942 || id == 22940) switch(object.getRotation()) { case 0: player.useStairs(-1, player.transform(-3, 0, -1), 1, 1); break; case 1: player.useStairs(-1, player.transform(0, 3, -1), 1, 1); break; case 2: player.useStairs(-1, player.transform(3, 0, -1), 1, 1); break; case 3: player.useStairs(-1, player.transform(0, -3, -1), 1, 1); break; } else if (id == 34567) player.useStairs(-1, player.transform(object.getRotation() == 3 ? -3 : 3, 0, 1), 1, 1); else if (id == 34568) player.useStairs(-1, player.transform(object.getRotation() == 3 ? 3 : -3, 0, -1), 1, 1); else if (id == 34498) switch(object.getRotation()) { case 0: player.useStairs(-1, player.transform(0, 3, 1), 1, 1); break; case 1: player.useStairs(-1, player.transform(3, 0, 1), 1, 1); break; case 2: player.useStairs(-1, player.transform(0, -3, 1), 1, 1); break; case 3: player.useStairs(-1, player.transform(-3, 0, 1), 1, 1); break; } else if (id == 34499) switch(object.getRotation()) { case 0: player.useStairs(-1, player.transform(0, -3, -1), 1, 1); break; case 1: player.useStairs(-1, player.transform(-3, 0, -1), 1, 1); break; case 2: player.useStairs(-1, player.transform(0, 3, -1), 1, 1); break; case 3: player.useStairs(-1, player.transform(3, 0, -1), 1, 1); break; } else if (id == 71902) player.useStairs(-1, player.transform(object.getRotation() == 1 ? 4 : 0, object.getRotation() == 0 ? 4 : 0, 1), 1, 1); else if (id == 71903) player.useStairs(-1, player.transform(object.getRotation() == 1 ? -4 : 0, object.getRotation() == 0 ? -4 : 0, -1), 1, 1); else if (id == 26518) { if (x == 1991 && y == 4175) player.useStairs(828, Tile.of(1991, 4176, 1)); else if (x == 1998 && y == 4218) player.useStairs(828, Tile.of(1998, 4219, 1)); else if (x == 2011 && y == 4218) player.useStairs(828, Tile.of(2011, 4219, 1)); else if (x == 3118 && y == 9643) player.useStairs(828, Tile.of(3118, player.getY() - 6400, 0)); else player.useStairs(828, Tile.of(x + 1, y, 1)); } else if (id == 46500 && object.getX() == 3351 && object.getY() == 3415) { // zaros // portal player.useStairs(-1, Tile.of(Settings.getConfig().getPlayerRespawnTile().getX(), Settings.getConfig().getPlayerRespawnTile().getY(), Settings.getConfig().getPlayerRespawnTile().getPlane()), 2, 3, ""You found your way back to home.""); player.addWalkSteps(3351, 3415, -1, false); } else if (id == 29370 && (object.getX() == 3150 || object.getX() == 3153) && object.getY() == 9906) { // edgeville // dungeon // cut if (player.getSkills().getLevel(Constants.AGILITY) < 53) { player.sendMessage(""You need an agility level of 53 to use this obstacle.""); return; } final boolean running = player.getRun(); player.setRunHidden(false); player.lock(8); player.addWalkSteps(x == 3150 ? 3155 : 3149, 9906, -1, false); player.sendMessage(""You pulled yourself through the pipes."", true); WorldTasks.scheduleLooping(new Task() { boolean secondloop; @Override public void run() { if (!secondloop) { secondloop = true; player.getAppearance().setBAS(295); } else { player.getAppearance().setBAS(-1); player.setRunHidden(running); player.getSkills().addXp(Constants.AGILITY, 7); stop(); } } }, 0, 5); } else if (id == 17222 || id == 17223) player.useStairs(-1, Tile.of(2402, 3419, 0), 0, 1); else if (id == 17209) player.useStairs(-1, Tile.of(2408, 9812, 0), 0, 1); else if (id == 1754) player.useLadder(player.transform(0, 6400)); else if (id == 2811 || id == 2812) { player.useStairs(id == 2812 ? 827 : -1, id == 2812 ? Tile.of(2501, 2989, 0) : Tile.of(2574, 3029, 0)); WorldTasks.schedule(() -> player.playerDialogue(HeadE.AMAZED, ""Wow! That tunnel went a long way."")); } else if (id == 2890 || id == 2892 || id == 2893) { if (player.getEquipment().getWeaponId() != 975 && !player.getInventory().containsItem(975, 1) && player.getEquipment().getWeaponId() != 6313 && !player.getInventory().containsItem(6313, 1) && player.getEquipment().getWeaponId() != 6315 && !player.getInventory().containsItem(6315, 1) && player.getEquipment().getWeaponId() != 6317 && !player.getInventory().containsItem(6317, 1)) { player.sendMessage(""You need a machete in order to cutt through the terrain.""); return; } player.setNextAnimation(new Animation(910)); WorldTasks.schedule(new Task() { @Override public void run() { if (Utils.random(3) == 0) { player.sendMessage(""You fail to slash through the terrain.""); return; } GameObject o = new GameObject(object); o.setId(id + 1); World.spawnObjectTemporary(o, 8); player.addWalkSteps(object.getX(), object.getY(), 0, false); } }); } else if (id == 2231) player.useStairs(-1, Tile.of(x == 2792 ? 2795 : 2791, 2979, 0), 1, 2, x == 2792 ? ""You climb down the slope."" : ""You climb up the slope.""); // start forinthry dungeon else if (id == 18341 && object.getX() == 3036 && object.getY() == 10172) player.useStairs(-1, Tile.of(3039, 3765, 0), 0, 1); else if (id == 20599 && object.getX() == 3038 && object.getY() == 3761) player.useStairs(-1, Tile.of(3037, 10171, 0), 0, 1); else if (id == 18342 && object.getX() == 3075 && object.getY() == 10057) player.useStairs(-1, Tile.of(3071, 3649, 0), 0, 1); else if (id == 20600 && object.getX() == 3072 && object.getY() == 3648) player.useStairs(-1, Tile.of(3077, 10058, 0), 0, 1); else if (id == 8689) player.getActionManager().setAction(new CowMilkingAction()); // start falador mininig else if (id == 30942 && object.getX() == 3019 && object.getY() == 3450) player.useStairs(828, Tile.of(3020, 9850, 0)); else if (id == 6226 && object.getX() == 3019 && object.getY() == 9850) player.useStairs(833, Tile.of(3018, 3450, 0)); else if (id == 30943 && object.getX() == 3059 && object.getY() == 9776) player.useStairs(-1, Tile.of(3061, 3376, 0), 0, 1); else if (id == 30944 && object.getX() == 3059 && object.getY() == 3376) player.useStairs(-1, Tile.of(3058, 9776, 0), 0, 1); else if (id == 2112 && object.getX() == 3046 && object.getY() == 9756) { if (player.getSkills().getLevelForXp(Constants.MINING) < 60) { player.npcDialogue(3294, HeadE.CHEERFUL, ""Sorry, but you need level 60 Mining to go in there.""); return; } Doors.handleDoor(player, object); } else if (id == 2113) { if (player.getSkills().getLevelForXp(Constants.MINING) < 60) { player.npcDialogue(3294, HeadE.CHEERFUL, ""Sorry, but you need level 60 Mining to go in there.""); return; } player.useStairs(-1, Tile.of(3021, 9739, 0), 0, 1); } else if (id == 6226 && object.getX() == 3019 && object.getY() == 9740) player.useStairs(828, Tile.of(3019, 3341, 0)); else if (id == 6226 && object.getX() == 3019 && object.getY() == 9738) player.useStairs(828, Tile.of(3019, 3337, 0)); else if (id == 6226 && object.getX() == 3018 && object.getY() == 9739) player.useStairs(828, Tile.of(3017, 3339, 0)); else if (id == 6226 && object.getX() == 3020 && object.getY() == 9739) player.useStairs(828, Tile.of(3021, 3339, 0)); else if (id == 46250) player.getInventory().addItem(new Item(1550, 1)); else if (id == 6045) player.sendMessage(""You search the cart but find nothing.""); else if (id == 5906) { if (player.getSkills().getLevel(Constants.AGILITY) < 42) { player.sendMessage(""You need an agility level of 42 to use this obstacle.""); return; } player.lock(); WorldTasks.schedule(0, () -> player.forceMove(Tile.of(object.getX() + (object.getRotation() == 2 ? -2 : +2), object.getY(), 0), 2594, 0, 120, false, () -> player.forceMove(Tile.of(object.getX() + (object.getRotation() == 2 ? -5 : +5), object.getY(), 0), 2590, 0, 120, false, () -> player.forceMove(Tile.of(object.getX() + (object.getRotation() == 2 ? -6 : +6), object.getY(), 0), 2595, 0, 75)))); // rock living caverns } else if (id == 45077) { player.lock(); if (player.getX() != object.getX() || player.getY() != object.getY()) player.addWalkSteps(object.getX(), object.getY(), -1, false); WorldTasks.scheduleLooping(new Task() { private int count; @Override public void run() { if (count == 0) { player.setNextFaceTile(Tile.of(object.getX() - 1, object.getY(), 0)); player.setNextAnimation(new Animation(12216)); } else if (count == 2) { player.tele(Tile.of(3651, 5122, 0)); player.setNextFaceTile(Tile.of(3651, 5121, 0)); player.setNextAnimation(new Animation(12217)); } else if (count == 3) { // TODO find emote // player.getPackets().sendObjectAnimation(new // WorldObject(45078, 0, 3, 3651, 5123, 0), new // Animation(12220)); } else if (count == 5) { player.unlock(); stop(); } count++; } }, 1, 0); } else if (id == 65367) WildernessAgility.gateWalkOut(player, object); else if (id == 65365) WildernessAgility.gateWalkIn(player, object); else if (id == 65734) WildernessAgility.climbCliff(player, object); else if (id == 65362) WildernessAgility.enterObstaclePipe(player, object.getX(), object.getY()); else if (id == 64696) WildernessAgility.swingOnRopeSwing(player, object); else if (id == 64698) WildernessAgility.walkLog(player); else if (id == 64699) WildernessAgility.crossSteppingPalletes(player, object); else if (id == 45078) player.useStairs(2413, Tile.of(3012, 9832, 0), 2, 2); // champion guild else if (id == 24357 && object.getX() == 3188 && object.getY() == 3355) player.useStairs(-1, Tile.of(3189, 3354, 1), 0, 1); else if (id == 24359 && object.getX() == 3188 && object.getY() == 3355) player.useStairs(-1, Tile.of(3189, 3358, 0), 0, 1); // start of varrock dungeon else if (id == 29355 && object.getX() == 3230 && object.getY() == 9904) // varrock // dungeon // climb // to // bear player.useStairs(828, Tile.of(3229, 3503, 0)); else if (id == 24264) player.useStairs(833, Tile.of(3229, 9904, 0)); else if (id == 24366) player.useStairs(828, Tile.of(3237, 3459, 0)); else if (id == 29355 && object.getX() == 3097 && object.getY() == 9867) // edge // dungeon // climb player.useStairs(828, Tile.of(3096, 3468, 0)); else if (id == 26934) player.useStairs(833, Tile.of(3096, 9868, 0)); else if (id == 29355 && object.getX() == 3088 && object.getY() == 9971) player.useStairs(828, Tile.of(3087, 3571, 0)); else if (id == 65453) player.useStairs(833, Tile.of(3089, 9971, 0)); else if (id == 12389 && object.getX() == 3116 && object.getY() == 3452) player.useStairs(833, Tile.of(3117, 9852, 0)); else if (id == 29355 && object.getX() == 3116 && object.getY() == 9852) player.useStairs(833, Tile.of(3115, 3452, 0)); else if (WildernessController.isDitch(id)) { player.startConversation(new Dialogue().addNext(new Statement() { @Override public void send(Player player) { player.getInterfaceManager().sendInterface(382); } @Override public int getOptionId(int componentId) { return componentId == 19 ? 0 : 1; } @Override public void close(Player player) { } }).addNext(() -> { player.stopAll(); player.forceMove(Tile.of(object.getRotation() == 3 || object.getRotation() == 1 ? object.getX() - 1 : player.getX(), object.getRotation() == 0 || object.getRotation() == 2 ? object.getY() + 2 : player.getY(), object.getPlane()), 6132, 25, 60, () -> { player.faceObject(object); player.getControllerManager().startController(new WildernessController()); player.resetReceivedDamage(); }); })); } else if (id >= 8958 && id <= 8960) World.removeObjectTemporary(object, Ticks.fromMinutes(1)); else if (id == 10177 && x == 2546 && y == 10143) player.promptUpDown(828, ""Go up the stairs."", Tile.of(2544, 3741, 0), ""Go down the stairs."", Tile.of(1798, 4407, 3)); else if ((id == 10193 && x == 1798 && y == 4406) || (id == 8930 && x == 2542 && y == 3740)) player.useStairs(-1, Tile.of(2545, 10143, 0), 0, 1); else if (id == 10195 && x == 1808 && y == 4405) player.useStairs(-1, Tile.of(1810, 4405, 2), 0, 1); else if (id == 10196 && x == 1809 && y == 4405) player.useStairs(-1, Tile.of(1807, 4405, 3), 0, 1); else if (id == 10198 && x == 1823 && y == 4404) player.useStairs(-1, Tile.of(1825, 4404, 3), 0, 1); else if (id == 10197 && x == 1824 && y == 4404) player.useStairs(-1, Tile.of(1823, 4404, 2), 0, 1); else if (id == 10199 && x == 1834 && y == 4389) player.useStairs(-1, Tile.of(1834, 4388, 2), 0, 1); else if (id == 10200 && x == 1834 && y == 4388) player.useStairs(-1, Tile.of(1834, 4390, 3), 0, 1); else if (id == 10201 && x == 1811 && y == 4394) player.useStairs(-1, Tile.of(1810, 4394, 1), 0, 1); else if (id == 10202 && x == 1810 && y == 4394) player.useStairs(-1, Tile.of(1812, 4394, 2), 0, 1); else if (id == 10203 && x == 1799 && y == 4388) player.useStairs(-1, Tile.of(1799, 4386, 2), 0, 1); else if (id == 10204 && x == 1799 && y == 4387) player.useStairs(-1, Tile.of(1799, 4389, 1), 0, 1); else if (id == 10205 && x == 1797 && y == 4382) player.useStairs(-1, Tile.of(1797, 4382, 1), 0, 1); else if (id == 10206 && x == 1798 && y == 4382) player.useStairs(-1, Tile.of(1796, 4382, 2), 0, 1); else if (id == 10207 && x == 1802 && y == 4369) player.useStairs(-1, Tile.of(1800, 4369, 2), 0, 1); else if (id == 10208 && x == 1801 && y == 4369) player.useStairs(-1, Tile.of(1802, 4369, 1), 0, 1); else if (id == 10209 && x == 1826 && y == 4362) player.useStairs(-1, Tile.of(1828, 4362, 1), 0, 1); else if (id == 10210 && x == 1827 && y == 4362) player.useStairs(-1, Tile.of(1825, 4362, 2), 0, 1); else if (id == 10211 && x == 1863 && y == 4371) player.useStairs(-1, Tile.of(1863, 4373, 2), 0, 1); else if (id == 10212 && x == 1863 && y == 4372) player.useStairs(-1, Tile.of(1863, 4370, 1), 0, 1); else if (id == 10213 && x == 1864 && y == 4388) player.useStairs(-1, Tile.of(1864, 4389, 1), 0, 1); else if (id == 10214 && x == 1864 && y == 4389) player.useStairs(-1, Tile.of(1864, 4387, 2), 0, 1); else if (id == 10215 && x == 1890 && y == 4407) player.useStairs(-1, Tile.of(1890, 4408, 0), 0, 1); else if (id == 10216 && x == 1890 && y == 4408) player.useStairs(-1, Tile.of(1890, 4406, 1), 0, 1); else if (id == 10230 && x == 1911 && y == 4367) // kings // entrance //BossInstanceHandler.enterInstance(player, Boss.Dagannoth_Kings); player.useStairs(-1, Tile.of(2900, 4449, 0), 0, 1); else if (id == 10229 && x == 2899 && y == 4449) player.useStairs(-1, Tile.of(1912, 4367, 0), 0, 1); else if (id == 10217 && x == 1957 && y == 4371) player.useStairs(-1, Tile.of(1957, 4373, 1), 0, 1); else if (id == 10218 && x == 1957 && y == 4372) player.useStairs(-1, Tile.of(1957, 4370, 0), 0, 1); else if (id == 10226 && x == 1932 && y == 4378) player.useStairs(-1, Tile.of(1932, 4380, 2), 0, 1); else if (id == 10225 && x == 1932 && y == 4379) player.useStairs(-1, Tile.of(1932, 4377, 1), 0, 1); else if (id == 10228 && x == 1961 && y == 4391) player.useStairs(-1, Tile.of(1961, 4393, 3), 0, 1); else if (id == 10227 && x == 1961 && y == 4392) player.useStairs(-1, Tile.of(1961, 4392, 2), 0, 1); else if (id == 10194 && x == 1975 && y == 4408) player.useStairs(-1, Tile.of(2501, 3636, 0), 0, 1); else if (id == 10219 && x == 1824 && y == 4381) player.useStairs(-1, Tile.of(1824, 4379, 3), 0, 1); else if (id == 10220 && x == 1824 && y == 4380) player.useStairs(-1, Tile.of(1824, 4382, 2), 0, 1); else if (id == 10221 && x == 1838 && y == 4376) player.useStairs(-1, Tile.of(1838, 4374, 2), 0, 1); else if (id == 10222 && x == 1838 && y == 4375) player.useStairs(-1, Tile.of(1838, 4377, 3), 0, 1); else if (id == 10223 && x == 1850 && y == 4386) player.useStairs(-1, Tile.of(1850, 4385, 1), 0, 1); else if (id == 10224 && x == 1850 && y == 4385) player.useStairs(-1, Tile.of(1850, 4387, 2), 0, 1); // sabbot lair else if (id == 19690) player.useStairs(-1, player.transform(0, 4, 1), 0, 1); else if (id == 19691) player.useStairs(-1, player.transform(0, -4, -1), 0, 1); else if (id == 61336) player.getPrayer().worshipAltar(); else if (id == 2878 || id == 2879) { player.simpleDialogue(""You step into the pool of sparkling water. You feel the energy rush through your veins.""); player.forceMove(id == 2879 ? Tile.of(2509, 4687, 0) : Tile.of(2542, 4720, 0), 13842, 0, 60, () -> { player.setNextAnimation(new Animation(-1)); player.tele(id == 2879 ? Tile.of(2542, 4718, 0) : Tile.of(2509, 4689, 0)); }); } else if (id == 2873 || id == 2874 || id == 2875) { player.sendMessage(""You kneel and begin to chant to "" + objectDef.getName().replace(""Statue of "", """") + ""...""); player.setNextAnimation(new Animation(645)); WorldTasks.schedule(new Task() { @Override public void run() { player.simpleDialogue(""You feel a rush of energy charge through your veins. Suddenly a cape appears before you.""); World.sendSpotAnim(Tile.of(object.getX(), object.getY() - 1, 0), new SpotAnim(1605)); World.addGroundItem(new Item(id == 2873 ? 2412 : id == 2874 ? 2414 : 2413), Tile.of(object.getX(), object.getY() - 1, 0)); } }, 3); } else if (id == 49016 || id == 49014) { if (player.getSkills().getLevel(Constants.FISHING) < 68) { player.sendMessage(""You need a Fishing level of 68 in order to pass through this gate.""); return; } Doors.handleDoubleDoor(player, object); } else if (id == 9738 || id == 9330) { boolean rightDoor = object.getId() == 9330; GameObject o = new GameObject(object); o.setRotation(rightDoor ? -1 : 1); World.spawnObjectTemporary(o, 2); GameObject o2 = new GameObject(rightDoor ? 9738 : 9330, object.getType(), object.getRotation(), 2558, rightDoor ? 3299 : 3300, object.getPlane()); o2.setRotation(rightDoor ? 1 : 3); World.spawnObjectTemporary(o2, 2); player.addWalkSteps(player.getX() + (player.getX() >= 2559 ? -3 : 3), y, -1, false); } else if (id == 70794) player.useStairs(-1, Tile.of(1340, 6488, 0)); else if (id == 70795) { if (!Agility.hasLevel(player, 50)) return; player.startConversation(new Dialogue() .addSimple(""The shortcut leads to the deepest level of the dungeon. The worms in that area are significantly more dangerous."") .addOptions(""Slide down the worm burrow?"", ops -> { ops.add(""Yes."", () -> player.useStairs(Tile.of(1206, 6506, 0))); ops.add(""No.""); })); } else if (id == 70799) player.useStairs(-1, Tile.of(1178, 6355, 0)); else if (id == 70796) player.useStairs(-1, Tile.of(1090, 6360, 0)); else if (id == 70798) player.useStairs(-1, Tile.of(1340, 6380, 0)); else if (id == 70797) player.useStairs(-1, Tile.of(1090, 6497, 0)); else if (id == 70792) player.useStairs(-1, Tile.of(1206, 6371, 0)); else if (id == 70793) player.useStairs(-1, Tile.of(2989, 3237, 0)); else if (id == 12202) {// mole entrance if (!player.getInventory().containsItem(952, 1)) { player.sendMessage(""You need a spade to dig this.""); return; } if (player.getX() != object.getX() || player.getY() != object.getY()) { player.lock(); player.addWalkSteps(object.getX(), object.getY()); WorldTasks.schedule(new Task() { @Override public void run() { Spade.dig(player); } }, 1); } else Spade.dig(player); } else if (id == 11724) player.useStairs(-1, Tile.of(2968, 3348, 1), 0, 1); else if (id == 11725) player.useStairs(-1, Tile.of(2971, 3347, 0), 0, 1); else if (id == 8929) player.useStairs(-1, Tile.of(2442, 10147, 0), 0, 1); else if (id == 8966) player.useStairs(-1, Tile.of(2523, 3740, 0), 0, 1); else if (id == 29728) player.useStairs(-1, Tile.of(3158, 4280, 3), 0, 1); else if (id == 29729) player.useStairs(-1, Tile.of(3078, 3463, 0), 0, 1); else if (id == 29672) player.useStairs(-1, Tile.of(3171, 4271, 3), 0, 1); else if (id == 29671) player.useStairs(-1, Tile.of(3174, 4273, 2), 0, 1); else if (id == 23158) player.useStairs(-1, Tile.of(2730, 3734, 0), 0, 1); else if (id == 11355) player.useStairs(-1, Tile.of(2677, 5214, 2), 0, 1); else if (id == 11356) player.useStairs(-1, Tile.of(3110, 3363, 2), 0, 1); else if (id == 15811 || id == 15812) player.useStairs(-1, Tile.of(3749, 2973, 0), 0, 1); else if (id == 63093) player.useStairs(-1, Tile.of(4620, 5458, 3), 0, 1); else if (id == 63094) player.useStairs(-1, Tile.of(3410, 3329, 0), 0, 1); else if (id == 2147) player.ladder(Tile.of(3104, 9576, 0)); else if (id == 5492) player.ladder(Tile.of(3149, 9652, 0)); else if (id == 5493) player.ladder(Tile.of(3165, 3251, 0)); else if (id == 68983) { Doors.handleInPlaceSingleDoor(player, object); player.resetWalkSteps(); player.addWalkSteps(2461, player.getY() > object.getY() ? object.getY() - 1 : object.getY() + 3, -1, false); } else if (id == 12230 && object.getX() == 1752 && object.getY() == 5136) player.tele(Tile.of(2996, 3378, 0)); else if (id == 38811 || id == 37929) {// corp beast if (object.getX() == 2971 && object.getY() == 4382) player.getInterfaceManager().sendInterface(650); else if (object.getX() == 2918 && object.getY() == 4382) { player.stopAll(); player.tele(Tile.of(player.getX() == 2921 ? 2917 : 2921, player.getY(), player.getPlane())); } } else if (id == 37928 && object.getX() == 2883 && object.getY() == 4370) { player.stopAll(); player.tele(Tile.of(3214, 3782, 0)); player.getControllerManager().startController(new WildernessController()); } else if (id == 38815 && object.getX() == 3209 && object.getY() == 3780 && object.getPlane() == 0) { if (player.getSkills().getLevelForXp(Constants.WOODCUTTING) < 37 || player.getSkills().getLevelForXp(Constants.MINING) < 45 || player.getSkills().getLevelForXp(Constants.SUMMONING) < 23 || player.getSkills().getLevelForXp(Constants.FIREMAKING) < 47 || player.getSkills().getLevelForXp(Constants.PRAYER) < 55) { player.sendMessage(""You need 23 Summoning, 37 Woodcutting, 45 Mining, 47 Firemaking and 55 Prayer to enter this dungeon.""); return; } player.stopAll(); player.tele(Tile.of(2885, 4372, 2)); player.getControllerManager().forceStop(); // TODO all reqs, skills not added } else if (id == 48803 && player.isKalphiteLairSetted()) player.tele(Tile.of(3508, 9494, 0)); else if (id == 48802 && player.isKalphiteLairEntranceSetted()) player.tele(Tile.of(3483, 9510, 2)); else if (id == 3829) { if (object.getX() == 3483 && object.getY() == 9510) player.useStairs(828, Tile.of(3226, 3108, 0)); } else if (id == 3832) { if (object.getX() == 3508 && object.getY() == 9494) player.useStairs(828, Tile.of(3509, 9496, 2)); } else if (id == 14315) player.getControllerManager().startController(new PestControlLobbyController(1)); else if (id == 5959) Magic.pushLeverTeleport(player, Tile.of(2539, 4712, 0)); else if (id == 5960) Magic.pushLeverTeleport(player, Tile.of(3089, 3957, 0)); else if (id == 1814) Magic.pushLeverTeleport(player, Tile.of(3155, 3923, 0)); else if (id == 1815) Magic.pushLeverTeleport(player, Tile.of(2561, 3311, 0)); else if (id == 62675) player.getCutsceneManager().play(new DTPreview()); else if (id == 62678 || id == 62679) player.getDominionTower().openModes(); else if (id == 62688) player.startConversation(new Dialogue() .addSimple(""You have a Dominion Factor of "" + player.getDominionTower().getDominionFactor() + ""."") .addOptions(""If you claim your rewards your progress will be reset."", ops -> { ops.add(""Claim rewards"", () -> player.getDominionTower().openRewardsChest()); ops.add(""Nevermind.""); })); else if (id == 62677) player.getDominionTower().talkToFace(); else if (id == 62680) player.getDominionTower().openBankChest(); else if (id == 48797) player.useStairs(-1, Tile.of(3877, 5526, 1), 0, 1); else if (id == 48798) player.useStairs(-1, Tile.of(3246, 3198, 0), 0, 1); else if (id == 48678 && x == 3858 && y == 5533) player.useStairs(-1, Tile.of(3861, 5533, 0), 0, 1); else if (id == 48678 && x == 3858 && y == 5543) player.useStairs(-1, Tile.of(3861, 5543, 0), 0, 1); else if (id == 48678 && x == 3858 && y == 5533) player.useStairs(-1, Tile.of(3861, 5533, 0), 0, 1); else if (id == 48677 && x == 3858 && y == 5543) player.useStairs(-1, Tile.of(3856, 5543, 1), 0, 1); else if (id == 48677 && x == 3858 && y == 5533) player.useStairs(-1, Tile.of(3856, 5533, 1), 0, 1); else if (id == 48679) player.useStairs(-1, Tile.of(3875, 5527, 1), 0, 1); else if (id == 48688) player.useStairs(-1, Tile.of(3972, 5565, 0), 0, 1); else if (id == 48683) player.useStairs(-1, Tile.of(3868, 5524, 0), 0, 1); else if (id == 48682) player.useStairs(-1, Tile.of(3869, 5524, 0), 0, 1); else if (id == 62676) player.useStairs(-1, Tile.of(3374, 3093, 0), 0, 1); else if (id == 62674) player.useStairs(-1, Tile.of(3744, 6405, 0), 0, 1); else if (id == 65349) player.useStairs(-1, Tile.of(3044, 10325, 0), 0, 1); else if (id == 32048 && object.getX() == 3043 && object.getY() == 10328) player.useStairs(-1, Tile.of(3045, 3927, 0), 0, 1); else if (id == 2348) player.tele(player.transform(object.getRotation() == 3 ? -3 : 3, 0, -1)); else if (id == 2347) player.tele(player.transform(object.getRotation() == 3 ? 3 : -3, 0, 1)); else if (id == 26193) PartyRoom.openChest(player); else if (PluginManager.handle(new ObjectClickEvent(player, object, ClientPacket.OBJECT_OP1, true))) { } else switch (objectDef.getName().toLowerCase()) { case ""trapdoor"": if (objectDef.containsOption(0, ""Open"")) { GameObject openedTrapdoor = new GameObject(object.getId() + 1, object.getType(), object.getRotation(), object.getX(), object.getY(), object.getPlane()); player.setNextAnimation(new Animation(536)); player.lock(2); player.faceObject(openedTrapdoor); World.spawnObjectTemporary(openedTrapdoor, Ticks.fromMinutes(1)); } break; case ""closed chest"": if (objectDef.containsOption(0, ""Open"")) { GameObject openedChest = new GameObject(object.getId() + 1, object.getType(), object.getRotation(), object.getX(), object.getY(), object.getPlane()); if (!openedChest.getDefinitions().containsOption(""Search"") && !openedChest.getDefinitions().containsOption(""Close"")) return; player.setNextAnimation(new Animation(536)); player.lock(2); player.faceObject(openedChest); World.spawnObjectTemporary(openedChest, Ticks.fromMinutes(1)); } break; case ""open chest"": if (objectDef.containsOption(0, ""Search"")) player.sendMessage(""You search the chest but find nothing.""); break; case ""spiderweb"": if (object.getRotation() == 2) { player.lock(2); if (Utils.getRandomInclusive(1) == 0) { player.addWalkSteps(player.getX(), player.getY() < y ? object.getY() + 2 : object.getY() - 1, -1, false); player.sendMessage(""You squeeze though the web.""); } else player.sendMessage(""You fail to squeeze though the web; perhaps you should try again.""); } break; case ""web"": if (objectDef.containsOption(0, ""Slash"")) { player.setNextAnimation(new Animation(PlayerCombatKt.getWeaponAttackEmote(player.getEquipment().getWeaponId(), player.getCombatDefinitions().getAttackStyle()))); slashWeb(player, object); } break; case ""ladder"": handleLadder(player, object, 1); break; case ""staircase"": handleStaircases(player, object, 1); break; case ""small obelisk"": if (objectDef.containsOption(0, ""Renew-points"")) { int summonLevel = player.getSkills().getLevelForXp(Constants.SUMMONING); if (player.getSkills().getLevel(Constants.SUMMONING) < summonLevel) { player.lock(3); player.setNextAnimation(new Animation(8502)); player.getSkills().set(Constants.SUMMONING, summonLevel); player.sendMessage(""You have recharged your Summoning points."", true); } else player.sendMessage(""You already have full Summoning points.""); } break; case ""altar"": case ""chaos altar"": case ""altar of guthix"": if (objectDef.containsOption(0, ""Pray"") || objectDef.containsOption(0, ""Pray-at"") || objectDef.containsOption(0, ""Recharge"")) { player.getPrayer().worshipAltar(); if (id == 6552) { player.startConversation(new Dialogue().addOptions(""Change spellbooks?"", ops -> { ops.add(""Yes, replace my spellbook."", () -> { if (player.getCombatDefinitions().getSpellbook() != Spellbook.ANCIENT) { player.sendMessage(""Your mind clears and you switch back to the ancient spellbook.""); player.getCombatDefinitions().setSpellbook(Spellbook.ANCIENT); } else { player.sendMessage(""Your mind clears and you switch back to the normal spellbook.""); player.getCombatDefinitions().setSpellbook(Spellbook.MODERN); } }); ops.add(""Nevermind.""); })); } } break; default: break; } })); Logger.debug(ObjectHandler.class, ""handleOption1"", ""Object interaction 1: "" + object); } public static void handleOption2(final Player player, final GameObject object) { final ObjectDefinitions def = object.getDefinitions(player); final int id = object.getId(); if (!def.containsOption(1) || PluginManager.handle(new ObjectClickEvent(player, object, ClientPacket.OBJECT_OP2, false))) return; player.setRouteEvent(new RouteEvent(object, () -> { player.stopAll(); player.faceObject(object); if (!player.getControllerManager().processObjectClick2(object) || player.getTreasureTrailsManager().useObject(object)) return; else if (id == 17010) { player.startConversation(new Dialogue().addOptions(""Change spellbooks?"", ops -> { ops.add(""Yes, replace my spellbook."", () -> { if (player.getCombatDefinitions().getSpellbook() != Spellbook.LUNAR) { if (!player.isQuestComplete(Quest.LUNAR_DIPLOMACY, ""to use the Lunar Spellbook."")) return; player.sendMessage(""Your mind clears and you switch back to the ancient spellbook.""); player.getCombatDefinitions().setSpellbook(Spellbook.LUNAR); } else { player.sendMessage(""Your mind clears and you switch back to the normal spellbook.""); player.getCombatDefinitions().setSpellbook(Spellbook.MODERN); } }); ops.add(""Nevermind.""); })); } else if (id == 62677) player.getDominionTower().openRewards(); else if (id == 62688) player.simpleDialogue(""You have a Dominion Factor of "" + player.getDominionTower().getDominionFactor() + "".""); else if (id == 68107) FightKilnController.enterFightKiln(player, true); else if (id == 70795) { if (!Agility.hasLevel(player, 50)) return; player.useStairs(-1, Tile.of(1206, 6506, 0)); } else if (object.getId() == 68 && player.getInventory().hasFreeSlots()) { player.setNextAnimation(new Animation(833)); player.lock(1); if (player.getInventory().containsItem(28)) player.getInventory().addItem(12156, 1); else { player.setNextForceTalk(new ForceTalk(""Ouch!"")); player.applyHit(new Hit(10, HitLook.TRUE_DAMAGE)); player.sendMessage(""The bees sting your hands as you reach inside!""); } } else if (object.getDefinitions(player).getName().toLowerCase().contains("" stall"")) Thieving.handleStalls(player, object); else if (id == 22697) Thieving.checkTrapsChest(player, object, 22683, 52, 210, 200, new DropSet( new DropTable(1, 5, 995, 1, 200), new DropTable(1, 5, 4537, 1), new DropTable(1, 5, 4546, 1), new DropTable(1, 5, 5014, 1), new DropTable(1, 5, 10981, 1))); else if (id == 22681) Thieving.checkTrapsChest(player, object, 22683, 78, 300, 650, new DropSet( new DropTable(1, 15, 1623, 1), new DropTable(1, 15, 1621, 1), new DropTable(1, 15, 1619, 1), new DropTable(1, 15, 1617, 1), new DropTable(1, 15, 1625, 1), new DropTable(1, 15, 1627, 1), new DropTable(1, 15, 1629, 1), new DropTable(1, 15, 4546, 1), new DropTable(1, 15, 5014, 1), new DropTable(1, 15, 10954, 1), new DropTable(1, 15, 10956, 1), new DropTable(1, 15, 2351, 1), new DropTable(1, 15, 10981, 1), new DropTable(1, 15, 10973, 1), new DropTable(1, 15, 10980, 1) )); else if (PluginManager.handle(new ObjectClickEvent(player, object, ClientPacket.OBJECT_OP2, true))) return; else switch (def.getName().toLowerCase()) { case ""ladder"": handleLadder(player, object, 2); break; case ""staircase"": handleStaircases(player, object, 2); break; default: break; } Logger.debug(ObjectHandler.class, ""handleOption2"", ""Object interaction 2: "" + object); })); } public static void handleOption3(final Player player, final GameObject object) { final ObjectDefinitions def = object.getDefinitions(player); if (!def.containsOption(2) || PluginManager.handle(new ObjectClickEvent(player, object, ClientPacket.OBJECT_OP3, false))) return; player.setRouteEvent(new RouteEvent(object, () -> { player.stopAll(); player.faceObject(object); if (!player.getControllerManager().processObjectClick3(object) || PluginManager.handle(new ObjectClickEvent(player, object, ClientPacket.OBJECT_OP3, true))) return; switch (def.getName().toLowerCase()) { case ""bank"": case ""bank chest"": case ""bank booth"": case ""bank table"": case ""counter"": if (def.containsOption(2, ""Collect"") || def.containsOption(2, ""Use"")) { // player.sendOptionDialogue(""What would you like to do?"", new String[] { ""Loadouts"", ""Clan Bank"" }, ops -> { // @Override // public void run(Player player) { // if (option == 1) { // player.openLoadouts(); // } else { // player.openClanBank(); // } // } // }); } break; case ""ladder"": handleLadder(player, object, 3); break; case ""staircase"": handleStaircases(player, object, 3); break; default: break; } Logger.debug(ObjectHandler.class, ""handleOption3"", ""Object interaction 3: "" + object); })); } public static void handleOption4(final Player player, final GameObject object) { final ObjectDefinitions def = object.getDefinitions(player); if (!def.containsOption(3) || PluginManager.handle(new ObjectClickEvent(player, object, ClientPacket.OBJECT_OP4, false))) return; player.setRouteEvent(new RouteEvent(object, () -> { player.stopAll(); player.faceObject(object); if (!player.getControllerManager().processObjectClick4(object) || PluginManager.handle(new ObjectClickEvent(player, object, ClientPacket.OBJECT_OP4, true))) return; switch (def.getName().toLowerCase()) { default: player.sendMessage(""Nothing interesting happens.""); break; } Logger.debug(ObjectHandler.class, ""handleOption4"", ""Object interaction 4: "" + object); })); } public static void handleOption5(final Player player, final GameObject object) { final ObjectDefinitions def = object.getDefinitions(player); final int id = object.getId(); if (!def.containsOption(4) || PluginManager.handle(new ObjectClickEvent(player, object, ClientPacket.OBJECT_OP5, false))) return; player.setRouteEvent(new RouteEvent(object, () -> { player.stopAll(); player.faceObject(object); if (!player.getControllerManager().processObjectClick5(object) || PluginManager.handle(new ObjectClickEvent(player, object, ClientPacket.OBJECT_OP5, true))) return; if (id == -1) { // unused } else switch (def.getName().toLowerCase()) { case ""fire"": if (def.containsOption(4, ""Add-logs"")) Bonfire.addLogs(player, object); break; default: player.sendMessage(""Nothing interesting happens.""); break; } Logger.debug(ObjectHandler.class, ""handleOption5"", ""Object interaction 5: "" + object); })); } public static void handleOptionExamine(final Player player, final GameObject object) { player.getPackets().sendObjectMessage(0, 0xFFFFFF, object, ""It's "" + Utils.addArticle(object.getDefinitions(player).getName()).toLowerCase() + "".""); if (player.hasRights(Rights.DEVELOPER)) { player.sendMessage(object.toString()); if (object.getDefinitions().varpBit != -1) player.sendMessage(""Transforms with varbit "" + object.getDefinitions().varpBit + "" - current obj: "" + object.getDefinitions(player).id); if (object.getDefinitions().varp != -1) player.sendMessage(""Transforms with var "" + object.getDefinitions().varp + "" - current obj: "" + object.getDefinitions(player).id); if (object.getMeshModifier() != null) player.sendMessage(Arrays.toString(object.getMeshModifier().getModelIds())); } } private static void slashWeb(Player player, GameObject object) { if (Utils.getRandomInclusive(1) == 0) { if (World.removeObjectTemporary(object, Ticks.fromMinutes(1))) player.sendMessage(""You slash through the web!""); } else player.sendMessage(""You fail to cut through the web.""); } public static boolean handleStaircases(Player player, GameObject object, int optionId) { String option = object.getDefinitions(player).getOption(optionId); if (option.equalsIgnoreCase(""Climb-up"")) { if (player.getPlane() == 3) return false; player.useStairs(-1, Tile.of(player.getX(), player.getY(), player.getPlane() + 1), 0, 1); } else if (option.equalsIgnoreCase(""Climb-down"")) { if (player.getPlane() == 0) return false; player.useStairs(-1, Tile.of(player.getX(), player.getY(), player.getPlane() - 1), 0, 1); } else if (option.equalsIgnoreCase(""Climb"")) { if (player.getPlane() == 3 || player.getPlane() == 0) return false; player.promptUpDown(""Go up the stairs."", player.transform(0, 0, 1), ""Go down the stairs."", player.transform(0, 0, -1)); } else return false; return false; } private static boolean handleLadder(Player player, GameObject object, int optionId) { String option = object.getDefinitions(player).getOption(optionId); if (option.equalsIgnoreCase(""Climb-up"")) { if (player.getPlane() == 3) return false; player.useStairs(828, Tile.of(player.getX(), player.getY(), player.getPlane() + 1)); } else if (option.equalsIgnoreCase(""Climb-down"")) { if (player.getPlane() == 0) return false; player.useStairs(828, Tile.of(player.getX(), player.getY(), player.getPlane() - 1)); } else if (option.equalsIgnoreCase(""Climb"")) { if (player.getPlane() == 3 || player.getPlane() == 0) return false; player.promptUpDown(828, ""Climb up the ladder."", player.transform(0, 0, 1), ""Climb down the ladder."", player.transform(0, 0, -1)); } else return false; return true; } public static void handleItemOnObject(final Player player, final GameObject object, final int interfaceId, final Item item, final int slot) { final int itemId = item.getId(); final ObjectDefinitions objectDef = object.getDefinitions(player); if (PluginManager.handle(new ItemOnObjectEvent(player, item, object, false)) || FishingFerretRoom.handleFerretThrow(player, object, item)) return; player.setRouteEvent(new RouteEvent(object, () -> { player.faceObject(object); if (!player.getControllerManager().handleItemOnObject(object, item) || Ectofuntus.handleItemOnObject(player, itemId, object.getId())) return; if (itemId == 1925 && objectDef.getName().toLowerCase().contains(""sand"") && objectDef.getName().toLowerCase().contains(""pit"")) { player.getActionManager().setAction(new SandBucketFill()); return; } if (itemId == JewelryCraftingKt.GOLD_BAR && (objectDef.getName().toLowerCase().contains(""furnace"") || object.getDefinitions(player).getName().equalsIgnoreCase(""clay forge"") || object.getDefinitions(player).getName().equalsIgnoreCase(""lava furnace""))) { JewelryCraftingKt.openInterface(player, false); player.getTempAttribs().setO(""jewelryObject"", object); return; } if (itemId == Silver.SILVER_BAR && (objectDef.getName().toLowerCase().contains(""furnace"") || object.getDefinitions(player).getName().equalsIgnoreCase(""clay forge"") || object.getDefinitions(player).getName().equalsIgnoreCase(""lava furnace""))) { Silver.openSilverInterface(player); player.getTempAttribs().setO(""silverObject"", object); return; } if (object.getId() == 13715) ItemConstants.handleRepairs(player, item, true, slot); else if (object.getId() == 28352 || object.getId() == 28550) Incubator.useEgg(player, itemId); else if (object.getId() == 733 || object.getId() == 64729) { player.setNextAnimation(new Animation(PlayerCombatKt.getWeaponAttackEmote(player.getEquipment().getWeaponId(), player.getCombatDefinitions().getAttackStyle()))); slashWeb(player, object); } else if (object.getId() == 48803 && itemId == 954) { if (player.isKalphiteLairSetted()) return; player.getInventory().deleteItem(954, 1); player.setKalphiteLair(); } else if (object.getId() == 48802 && itemId == 954) { if (player.isKalphiteLairEntranceSetted()) return; player.getInventory().deleteItem(954, 1); player.setKalphiteLairEntrance(); } else PluginManager.handle(new ItemOnObjectEvent(player, item, object, true)); })); } }" "package com.rs.net.decoders.handlers; @PluginEventHandler public class PacketHandlers { private static final Map> PACKET_HANDLERS = new HashMap<>(); @ServerStartupEvent(Priority.FILE_IO) public static void loadPacketDecoders() { loadHandlersFromPackage(""com.rs.net.decoders.handlers.impl""); } public static void loadHandlersFromPackage(String pack) { try { Logger.info(PacketHandlers.class, ""loadHandlersFromPackage"", ""Initializing packet handlers (""+pack+"")...""); List> classes = Utils.getClasses(pack); for (Class clazz : classes) mapHandler((PacketHandler) clazz.getConstructor().newInstance()); Set missing = new HashSet<>(); for (ClientPacket packet : ClientPacket.values()) if (PACKET_HANDLERS.get(packet) == null) missing.add(packet); int handled = ClientPacket.values().length - missing.size(); Logger.info(PacketHandlers.class, ""loadHandlersFromPackage"", ""Packet handlers loaded for "" + handled + "" packets...""); Logger.info(PacketHandlers.class, ""loadHandlersFromPackage"", ""Packets missing: "" + missing); } catch (ClassNotFoundException | IOException | IllegalArgumentException | SecurityException | InstantiationException | IllegalAccessException | InvocationTargetException | NoSuchMethodException e) { Logger.handle(PacketHandlers.class, ""loadHandlersFromPackage"", e); } } public static void mapHandler(PacketHandler handler) { ParameterizedType type = (ParameterizedType) handler.getClass().getGenericInterfaces()[0]; Class clazz = (Class) type.getActualTypeArguments()[1]; PacketDecoder annotation = clazz.getAnnotation(PacketDecoder.class); for (ClientPacket packet : annotation.value()) PACKET_HANDLERS.put(packet, handler); } @SuppressWarnings(""unchecked"") public static PacketHandler getHandler(ClientPacket packet) { return (PacketHandler) PACKET_HANDLERS.get(packet); } }" "package com.rs.net.decoders.handlers.impl; public class ClickWorldMapHandler implements PacketHandler { @Override public void handle(Player player, WorldMapClick packet) { int hash = player.getTempAttribs().getI(""worldHash""); if (packet.getTile().getTileHash() != hash) player.getTempAttribs().setI(""worldHash"", packet.getTile().getTileHash()); else { player.getHintIconsManager().removeAll(); player.getTempAttribs().removeI(""worldHash""); player.getHintIconsManager().addHintIcon(packet.getTile().getX(), packet.getTile().getY(), packet.getTile().getPlane(), 20, 0, 2, -1, true); player.getVars().setVar(1159, packet.getTile().getTileHash()); } } }" "package com.rs.net.decoders.handlers.impl; public class ClientCheatHandler implements PacketHandler { @Override public void handle(Player player, ClientCheat packet) { if (!player.isRunning()) return; try { Commands.processCommand(player, packet.getCommand(), true, packet.isClient()); } catch(Throwable e) { } } }" "package com.rs.net.decoders.handlers.impl; public class CloseInterfaceHandler implements PacketHandler { @Override public void handle(Player player, CloseInterface packet) { if (player.hasStarted() && !player.hasFinished() && !player.isRunning()) { player.run(); return; } if (player.getInterfaceManager().containsScreenInter()) player.stopAll(); } }" "package com.rs.net.decoders.handlers.impl; public class CutsceneFinishedHandler implements PacketHandler { @Override public void handle(Player player, CutsceneFinished packet) { player.loadMapRegions(); if (player.onPacketCutsceneFinish != null) { player.onPacketCutsceneFinish.run(); player.onPacketCutsceneFinish = null; } } }" "package com.rs.net.decoders.handlers.impl; public class GEItemSelectHandler implements PacketHandler { @Override public void handle(Player player, GEItemSelect packet) { ItemDefinitions def = ItemDefinitions.getDefs(packet.getItemId()); if (def != null) GE.selectItem(player, packet.getItemId(), 1); } }" "package com.rs.net.decoders.handlers.impl; public class GroundItemOpHandler implements PacketHandler { @Override public void handle(Player player, GroundItemOp packet) { if (!player.hasStarted() || !player.clientHasLoadedMapRegion() || player.isDead()) return; if (player.isLocked() || player.hasEffect(Effect.FREEZE)) return; final Tile tile = Tile.of(packet.getX(), packet.getY(), player.getPlane()); if (!player.getMapChunkIds().contains(tile.getChunkId())) return; final GroundItem item = ChunkManager.getChunk(tile.getChunkId()).getGroundItem(packet.getObjectId(), tile, player); if (item == null) return; if (packet.getOpcode() == ClientPacket.GROUND_ITEM_EXAMINE) { ItemDefinitions def = ItemDefinitions.getDefs(item.getId()); if (item.getMetaData(""combatCharges"") != null) player.sendMessage(""It looks like it will last another "" + Utils.ticksToTime(item.getMetaDataI(""combatCharges""))); player.getPackets().sendGroundItemMessage(item, ItemConfig.get(item.getId()).getExamine(item) + "" General store: "" + Utils.formatTypicalInteger(def.getSellPrice()) + "" High Alchemy: "" + Utils.formatTypicalInteger(def.getHighAlchPrice())); return; } player.stopAll(); if (packet.isForceRun()) player.setRun(packet.isForceRun()); switch(packet.getOpcode()) { case GROUND_ITEM_OP1: break; case GROUND_ITEM_OP2: break; case GROUND_ITEM_OP3: player.setRouteEvent(new RouteEvent(item, () -> { final GroundItem groundItem = ChunkManager.getChunk(tile.getChunkId()).getGroundItem(packet.getObjectId(), tile, player); if (groundItem == null || !player.getControllerManager().canTakeItem(groundItem)) return; if (TreasureTrailsManager.isScroll(groundItem.getId())) if (player.getTreasureTrailsManager().hasClueScrollItem()) { player.sendMessage(""You should finish the clue you are currently doing first.""); return; } PickupItemEvent e2 = new PickupItemEvent(player, groundItem, false); PluginManager.handle(e2); if (!e2.isCancelPickup()) { player.soundEffect(2582, false); World.removeGroundItem(player, groundItem, true); } }, () -> { final GroundItem groundItem = ChunkManager.getChunk(tile.getChunkId()).getGroundItem(packet.getObjectId(), tile, player); if (groundItem == null || !player.getControllerManager().canTakeItem(groundItem)) return true; if (!player.lineOfSightTo(groundItem.getTile(), true)) { player.sendMessage(""You can't reach that.""); return true; } player.anim(833); player.faceTile(groundItem.getTile()); PickupItemEvent e1 = new PickupItemEvent(player, groundItem, false); PluginManager.handle(e1); if (!e1.isCancelPickup()) { player.soundEffect(2582, false); World.removeGroundItem(player, groundItem, true); } return true; })); break; case GROUND_ITEM_OP4: player.setRouteEvent(new RouteEvent(item, () -> { final GroundItem groundItem = ChunkManager.getChunk(tile.getChunkId()).getGroundItem(packet.getObjectId(), tile, player); if (groundItem == null) return; Fire fire = Fire.forId(groundItem.getId()); if (fire != null) { player.getActionManager().setAction(new Firemaking(fire, groundItem)); return; } BoxTrapType trap = BoxTrapType.forId(groundItem.getId()); if (trap != null) { player.getActionManager().setAction(new BoxAction(trap, groundItem)); } })); break; case GROUND_ITEM_OP5: break; default: break; } } }" "package com.rs.net.decoders.handlers.impl; public class KeepAliveHandler implements PacketHandler { @Override public void handle(Player player, KeepAlive packet) { player.getSession().writeToQueue(ServerPacket.KEEPALIVE); } }" "package com.rs.net.decoders.handlers.impl; public class KeyPressHandler implements PacketHandler { @Override public void handle(Player player, KeyPress packet) { player.refreshIdleTime(); switch(packet.getKeyCode()) { case 13 -> { if(!player.getTempAttribs().getB(""CUTSCENE_INTERFACE_CLOSE_DISABLED"")) player.closeInterfaces(); if (player.getInterfaceManager().topOpen(755)) {//World map //Send window pane player.getPackets().sendWindowsPane(player.resizeable() ? 746 : 548, 2); //Reset top of interface stack on client player.getInterfaceManager().setDefaultTopInterface(); } } // case 33, 48, 49, 50, 83 -> { //WASD walking lmao // switch(packet.getKeyCode()) { // case 33 -> { // player.stopAll(); // player.resetWalkSteps(); // player.addWalkSteps(player.getX(), player.getY()+5); // } // case 48 -> { // player.stopAll(); // player.resetWalkSteps(); // player.addWalkSteps(player.getX()-5, player.getY()); // } // case 49 -> { // player.stopAll(); // player.resetWalkSteps(); // player.addWalkSteps(player.getX(), player.getY()-5); // } // case 50 -> { // player.stopAll(); // player.resetWalkSteps(); // player.addWalkSteps(player.getX()+5, player.getY()); // } // case 83 -> { // GameObject object = World.getObject(player.transform(player.getDirection().getDx(), player.getDirection().getDy(), player.getPlane()), ObjectType.SCENERY_INTERACT); // if (object != null) // PluginManager.handle(new ObjectClickEvent(player, object, ClientPacket.OBJECT_OP1, true)); // } // } // } // case 83 -> { // if (player.getConversation() != null) { // player.getConversation().process(0); // } // } // default -> player.sendMessage(""Keycode: "" + packet.getKeyCode()); } } }" "package com.rs.net.decoders.handlers.impl; public class NPCOpHandler implements PacketHandler { @Override public void handle(Player player, NPCOp packet) { if (!player.hasStarted() || !player.clientHasLoadedMapRegion()) return; if (packet.isForceRun()) player.setRun(true); NPC npc = World.getNPCs().get(packet.getNpcIndex()); if (npc == null || npc.isDead() || npc.hasFinished() || !player.getMapChunkIds().contains(npc.getChunkId()) || npc.getDefinitions().getIdForPlayer(player.getVars()) == -1) return; if (packet.getOpcode() == ClientPacket.NPC_EXAMINE) { NPCHandler.handleExamine(player, npc); if (player.getNSV().getB(""clanifyStuff"")) ClansManager.clanifyNPC(player.getClan(), npc); return; } if (player.isDead() || player.isLocked()) return; switch(packet.getOpcode()) { case NPC_OP1: NPCHandler.handleOption1(player, npc); break; case NPC_OP2: NPCHandler.handleOption2(player, npc); break; case NPC_OP3: NPCHandler.handleOption3(player, npc); break; case NPC_OP4: NPCHandler.handleOption4(player, npc); break; case NPC_OP5: NPCHandler.handleOption5(player, npc); break; default: break; } } }" "package com.rs.net.decoders.handlers.impl; public class ObjectOptionHandler implements PacketHandler { @Override public void handle(Player player, ObjectOp packet) { if (!player.hasStarted() || !player.clientHasLoadedMapRegion() || player.isDead()) return; final Tile tile = Tile.of(packet.getX(), packet.getY(), player.getPlane()); if (!player.getMapChunkIds().contains(tile.getChunkId())) return; GameObject mapObject = World.getObjectWithId(tile, packet.getObjectId()); if (mapObject == null || mapObject.getId() != packet.getObjectId()) return; final GameObject object = mapObject; if (packet.getOpcode() == ClientPacket.OBJECT_EXAMINE) { ObjectHandler.handleOptionExamine(player, object); if (player.getNSV().getB(""clanifyStuff"")) ClansManager.clanifyObject(player.getClan(), object); return; } if (player.isLocked() || player.getEmotesManager().isAnimating()) return; player.stopAll(false); if (packet.isForceRun()) player.setRun(true); switch(packet.getOpcode()) { case OBJECT_OP1 -> ObjectHandler.handleOption1(player, object); case OBJECT_OP2 -> ObjectHandler.handleOption2(player, object); case OBJECT_OP3 -> ObjectHandler.handleOption3(player, object); case OBJECT_OP4 -> ObjectHandler.handleOption4(player, object); case OBJECT_OP5 -> ObjectHandler.handleOption5(player, object); default -> System.err.println(""Unexpected object interaction packet: "" + packet.getOpcode()); } } }" "package com.rs.net.decoders.handlers.impl; public class PlayerOptionHandler implements PacketHandler { @Override public void handle(Player player, PlayerOp packet) { if (!player.hasStarted() || !player.clientHasLoadedMapRegion() || player.isDead() || player.isLocked()) return; Player target = World.getPlayers().get(packet.getPid()); if (target == null || target.isDead() || target.hasFinished() || !player.getMapChunkIds().contains(target.getChunkId())) return; if (packet.isForceRun()) player.setRun(true); if (PluginManager.handle(new PlayerClickEvent(player, target, player.getPlayerOption(packet.getOpcode()), false))) return; // player.setRouteEvent(new RouteEvent(target, new Runnable() { // @Override // public void run() { // PluginManager.handle(new PlayerClickEvent(player, target, player.getPlayerOption(packet), true)); // } // })); switch(packet.getOpcode()) { case PLAYER_OP1: if (!player.getControllerManager().canPlayerOption1(target) || !player.isCanPvp() || !player.getControllerManager().canAttack(target)) return; if (!player.isCanPvp() || !target.isCanPvp()) { player.sendMessage(""You can only attack players in a player-vs-player area.""); return; } if (!target.isAtMultiArea() || !player.isAtMultiArea()) { if (player.getAttackedBy() != target && player.inCombat()) { player.sendMessage(""You are already in combat.""); return; } if (target.getAttackedBy() != player && target.inCombat()) { if (!(target.getAttackedBy() instanceof NPC)) { player.sendMessage(""That player is already in combat.""); return; } target.setAttackedBy(player); } } player.stopAll(true); player.getInteractionManager().setInteraction(new PlayerCombatInteraction(player, target)); break; case PLAYER_OP2: if (!player.getControllerManager().canPlayerOption2(target)) return; player.stopAll(true); player.getActionManager().setAction(new EntityFollow(target)); break; case PLAYER_OP3: if (!player.getControllerManager().canPlayerOption3(target)) return; player.stopAll(true); break; case PLAYER_OP4: player.stopAll(true); if (!player.getControllerManager().canTrade() || !player.getControllerManager().canPlayerOption4(target)) return; player.setRouteEvent(new RouteEvent(target, () -> { // if (p2.getTemporaryAttributtes().get(""coopSlayerRequest"") == player) { // if (p2.isIronMan() || player.isIronMan()) { // player.sendMessage(""Ironmen cannot participate in co-op slayer.""); // return; // } // if (p2.getCoopSlayerPartner() != null || player.getCoopSlayerPartner() != null) { // player.sendMessage(""You or the other player are already in a co-op slayer group.""); // return; // } // p2.setCoopSlayerPartner(player); // player.setCoopSlayerPartner(p2); // p2.sendMessage(""You are now in a co-op slayer group with "" + player.getDisplayName() + "". Go get a task.""); // player.sendMessage(""You are now in a co-op slayer group with "" + p2.getDisplayName() + "". Go get a task.""); // p2.sendMessage(""To leave the slayer group, relog.""); // player.sendMessage(""To leave the slayer group, relog.""); // p2.getTemporaryAttributtes().remove(""coopSlayerRequest""); // return; // } if (player.isCantTrade()) { player.sendMessage(""You are busy.""); return; } if (target.getInterfaceManager().containsScreenInter() || target.isCantTrade()) { player.sendMessage(""The other player is busy.""); return; } if (!target.withinDistance(player.getTile(), 14)) { player.sendMessage(""Unable to find target "" + target.getDisplayName()); return; } if (target.getTempAttribs().getO(""TradeTarget"") == player) { target.getTempAttribs().removeO(""TradeTarget""); if (!player.getBank().checkPin()) return; if (!target.getBank().checkPin()) return; player.getTrade().openTrade(target); target.getTrade().openTrade(player); return; } player.getTempAttribs().setO(""TradeTarget"", target); player.sendMessage(""Sending "" + target.getDisplayName() + "" a request...""); target.getPackets().sendTradeRequestMessage(player); })); break; case PLAYER_OP5: break; case PLAYER_OP6: break; case PLAYER_OP7: break; case PLAYER_OP8: break; case PLAYER_OP9: player.stopAll(); ClansManager.openClanInvite(player, target, target.getClan()); break; case PLAYER_OP10: break; default: break; } } }" "package com.rs.net.decoders.handlers.impl; public class ReflectionCheckResponseHandler implements PacketHandler { @Override public void handle(Player player, ReflectionCheckResponse packet) { ReflectionAnalysis analysis = player.getReflectionAnalysis(packet.getId()); if (analysis == null) { World.sendWorldMessage("""" + player.getDisplayName() + "" failed reflection check. Reason: Check id not found."", true); return; } for (ReflectionCheck check : analysis.getChecks().getChecks()) check.decode(packet.getData()); for (Player staff : World.getPlayers()) { if (staff == null || !staff.hasStarted() || staff.hasFinished() || !staff.hasRights(Rights.ADMIN)) continue; ArrayList lines = new ArrayList<>(); lines.add(""Current Machine""); lines.add(""""); lines.add(""Operating System: "" + switch(player.getMachineInfo().operatingSystem) { case 1 -> ""Windows""; case 2 -> ""Mac""; case 3 -> ""Linux""; default -> ""Other/Uknown""; } + "" (x"" + (player.getMachineInfo().x64os ? ""64"" : ""86"") + "")""); lines.add(""""); lines.add(""Java: ""); lines.add(""Version: "" + player.getMachineInfo().javaBuild + "" ("" + player.getMachineInfo().javaUpdate + ""."" + player.getMachineInfo().javaSubBuild + ""_"" + switch(player.getMachineInfo().javaVersion) { case 1 -> ""sun""; case 2 -> ""microsoft""; case 3 -> ""apple""; default -> ""open""; } + "")""); lines.add(""JVM max memory: "" + Utils.formatNumber(player.getMachineInfo().maxMem) + ""mb""); lines.add(""""); lines.add(""Processor: ""); lines.add(""Model: "" + player.getMachineInfo().cpuData); lines.add(""Type: "" + player.getMachineInfo().cpuType); lines.add(""Cores: "" + player.getMachineInfo().processors); lines.add(""RAM: "" + Utils.formatNumber(player.getMachineInfo().ram) + ""mb""); lines.add(""""); for (ReflectionTest check : analysis.getTests()) { boolean pass = check.getValidation().apply(check.getCheck()); lines.add("""" + check.getName() + "" ("" + check.getDescription() + ""): passed"" : ""FF0000>failed"")); lines.add(check.getCheck().getResponse().toString()); lines.add(""""); } staff.getInterfaceManager().sendInterface(275); staff.getPackets().sendRunScriptReverse(1207, lines.size()); staff.getPackets().setIFText(275, 1, ""Client Analysis Results for "" + player.getDisplayName()); for (int i = 10; i < 289; i++) staff.getPackets().setIFText(275, i, ((i - 10) >= lines.size() ? "" "" : lines.get(i - 10))); } } }" "package com.rs.net.decoders.handlers.impl; public class RegionLoadedHandler implements PacketHandler { @Override public void handle(Player player, RegionLoaded packet) { if (!player.clientHasLoadedMapRegionFinished()) { player.setClientHasLoadedMapRegion(); player.initNewChunks(); } } }" "package com.rs.net.decoders.handlers.impl; public class ReportAbuseHandler implements PacketHandler { @Override public void handle(Player player, ReportAbuse packet) { if (!player.hasStarted()) return; ReportsManager.report(player, packet.getUsername(), packet.getType(), packet.isMute()); } }" "package com.rs.net.decoders.handlers.impl; public class ResumeCountDialogueHandler implements PacketHandler { @Override public void handle(Player player, ResumeCountDialogue packet) { if (!player.isRunning() || player.isDead()) return; if (player.getTempAttribs().getO(""pluginInteger"") != null && player.getTempAttribs().removeO(""pluginInteger"") instanceof InputIntegerEvent iie) iie.run(packet.getValue()); } }" "package com.rs.net.decoders.handlers.impl; public class ResumeHSLDialogueHandler implements PacketHandler { @Override public void handle(Player player, ResumeHSLDialogue packet) { if (!player.hasStarted()) return; if (player.getTempAttribs().getO(""pluginHSL"") != null && player.getTempAttribs().removeO(""pluginHSL"") instanceof InputHSLEvent ise) ise.run(packet.getColorId()); } }" "package com.rs.net.decoders.handlers.impl; public class ResumeTextDialoguesHandler implements PacketHandler { @Override public void handle(Player player, ResumeTextDialogue packet) { if (!player.isRunning() || player.isDead() || packet.getText().equals("""")) return; switch (packet.getOpcode()) { case RESUME_CLANFORUMQFCDIALOG -> { if (player.getTempAttribs().getO(""pluginQFCD"") != null && player.getTempAttribs().removeO(""pluginQFCD"") instanceof InputStringEvent ise) ise.run(packet.getText()); } case RESUME_NAMEDIALOG -> { if (player.getTempAttribs().getO(""pluginEnterName"") != null && player.getTempAttribs().removeO(""pluginEnterName"") instanceof InputStringEvent ise) ise.run(packet.getText()); } case RESUME_TEXTDIALOG -> { if (player.getTempAttribs().getO(""pluginEnterLongText"") != null && player.getTempAttribs().removeO(""pluginEnterLongText"") instanceof InputStringEvent ise) ise.run(packet.getText()); } default -> {} } } }" "package com.rs.net.decoders.handlers.impl; public class SetScreenSizeHandler implements PacketHandler { @Override public void handle(Player player, SetScreenSize packet) { player.setScreenWidth(packet.getWidth()); player.setScreenHeight(packet.getHeight()); if (!player.hasStarted() || player.hasFinished() || !player.getInterfaceManager().topOpen(742)) return; ScreenMode mode = ScreenMode.forId(packet.getDisplayMode()); if (mode == null) { player.sendMessage(""Invalid screen mode: "" + packet.getDisplayMode()); return; } player.getInterfaceManager().switchDisplayModes(mode); } }" "package com.rs.net.decoders.handlers.impl; public class SocialAddRemoveHandler implements PacketHandler { @Override public void handle(Player player, SocialAddRemove packet) { LobbyCommunicator.forwardPackets(player, packet); } }" "package com.rs.net.decoders.handlers.impl; public class WalkingHandler implements PacketHandler { @Override public void handle(Player player, Walk packet) { player.refreshIdleTime(); if (!player.hasStarted() || !player.clientHasLoadedMapRegion() || player.isDead() || player.isLocked()) return; if (player.hasEffect(Effect.FREEZE)) { player.sendMessage(""A magical force prevents you from moving.""); return; } player.stopAll(); player.walkRequest = packet; } }" "package com.rs.net.decoders.handlers.impl; public class WritePingHandler implements PacketHandler { @Override public void handle(Player player, WritePing packet) { player.getNSV().setI(""ping"", packet.getPing()); } }" "package com.rs.net.decoders.handlers.impl.chat; public class ChatHandler implements PacketHandler { @Override public void handle(Player player, Chat packet) { if (!player.hasStarted()) return; if (packet.getMessage().startsWith(""::"") || packet.getMessage().startsWith("";;"")) { try { Commands.processCommand(player, packet.getMessage().replace(""::"", """").replace("";;"", """"), false, false); } catch(Throwable e) { } return; } int effects = (packet.getColor() << 8) | (packet.getEffect() & 0xff); switch(player.chatType) { case 1, 2, 3 -> LobbyCommunicator.forwardPackets(player, packet.setType(player.chatType)); default -> { if (packet.getMessage() == null || packet.getMessage().replaceAll("" "", """").equals("""")) return; if (player.getAccount().isMuted()) { player.sendMessage(""You are muted. The mute will be lifted at "" + player.getAccount().getUnmuteDate()); return; } if (player.getControllerManager().getController() instanceof DungeonController) for (Player party : player.getDungManager().getParty().getTeam()) party.getPackets().sendPublicMessage(player, new PublicChatMessage(packet.getMessage(), effects)); else player.sendPublicChatMessage(new PublicChatMessage(packet.getMessage(), effects)); } } } }" "package com.rs.net.decoders.handlers.impl.chat; public class ChatSetFilterHandler implements PacketHandler { @Override public void handle(Player player, ChatSetFilter packet) { player.setPublicStatus(packet.getPublicFilter()); player.getAccount().getSocial().setStatus(packet.getPrivateFilter()); player.setTradeStatus(packet.getTradeFilter()); LobbyCommunicator.updateSocial(player); } }" "package com.rs.net.decoders.handlers.impl.chat; public class ChatTypeHandler implements PacketHandler { @Override public void handle(Player player, ChatType packet) { player.chatType = packet.getType(); } }" "package com.rs.net.decoders.handlers.impl.chat; public class QCPrivateHandler implements PacketHandler { @Override public void handle(Player player, QCPrivate packet) { if (!player.hasStarted() || !Utils.isQCValid(packet.getQcId())) return; packet.setCompletedData(WorldUtil.completeQuickMessage(player, packet.getQcId(), packet.getMessageData())); LobbyCommunicator.forwardPackets(player, packet); } }" "package com.rs.net.decoders.handlers.impl.chat; public class QCPublicHandler implements PacketHandler { @Override public void handle(Player player, QCPublic packet) { if (!player.hasStarted() || !Utils.isQCValid(packet.getQcId())) return; packet.setCompletedData(WorldUtil.completeQuickMessage(player, packet.getQcId(), packet.getMessageData())); switch(packet.getChatType()) { case 1, 2, 3 -> LobbyCommunicator.forwardPackets(player, packet); case 0 -> { if (player.getControllerManager().getController() instanceof DungeonController) for (Player party : player.getDungManager().getParty().getTeam()) party.getPackets().sendPublicMessage(player, new QuickChatMessage(packet.getQcId(), packet.getCompletedData())); else player.sendPublicChatMessage(new QuickChatMessage(packet.getQcId(), packet.getCompletedData())); } } } }" "package com.rs.net.decoders.handlers.impl.chat; public class SendPrivateMessageHandler implements PacketHandler { @Override public void handle(Player player, SendPrivateMessage packet) { if (player.getAccount().isMuted()) { player.sendMessage(""You are muted. The mute will be lifted at "" + player.getAccount().getUnmuteDate()); return; } LobbyCommunicator.forwardPackets(player, packet); } }" "package com.rs.net.decoders.handlers.impl.clan; public class CCKickHandler implements PacketHandler { @Override public void handle(Player player, CCKick p) { if (!player.hasStarted()) return; LobbyCommunicator.forwardPackets(player, p); } }" "package com.rs.net.decoders.handlers.impl.clan; public class ClanCheckNameHandler implements PacketHandler { @Override public void handle(Player player, ClanCheckName packet) { if (packet.isApproved()) ClansManager.create(player, packet.getName()); else ClansManager.promptName(player); } }" "package com.rs.net.decoders.handlers.impl.fc; public class FCJoinHandler implements PacketHandler { @Override public void handle(Player player, FCJoin packet) { if ((!player.hasStarted())) return; LobbyCommunicator.forwardPackets(player, packet); } }" "package com.rs.net.decoders.handlers.impl.fc; public class FCKickHandler implements PacketHandler { @Override public void handle(Player player, FCKick packet) { if (!player.hasStarted()) return; LobbyCommunicator.forwardPackets(player, packet); } }" "package com.rs.net.decoders.handlers.impl.fc; public class FCSetRankHandler implements PacketHandler { @Override public void handle(Player player, FCSetRank packet) { if (!player.hasStarted()) return; LobbyCommunicator.forwardPackets(player, packet); } }" "package com.rs.net.decoders.handlers.impl.interfaces; public class IFContinueHandler implements PacketHandler { @Override public void handle(Player player, IFContinue packet) { if (Utils.getInterfaceDefinitionsSize() <= packet.getInterfaceId() || !player.isRunning() || !player.getInterfaceManager().topOpen(packet.getInterfaceId())) return; if (player.getConversation() != null) { player.getConversation().process(packet.getInterfaceId(), packet.getComponentId()); return; } PluginManager.handle(new ButtonClickEvent(player, packet.getInterfaceId(), packet.getComponentId(), -1, -1, ClientPacket.IF_CONTINUE)); } }" "package com.rs.net.decoders.handlers.impl.interfaces; public class IFDragOntoIFHandler implements PacketHandler { @Override public void handle(Player player, IFDragOntoIF packet) { if (Utils.getInterfaceDefinitionsSize() <= packet.getFromInter() || Utils.getInterfaceDefinitionsSize() <= packet.getToInter() || !player.getInterfaceManager().topOpen(packet.getFromInter()) || !player.getInterfaceManager().topOpen(packet.getToInter())) return; if ((packet.getFromComp() != -1 && Utils.getInterfaceDefinitionsComponentsSize(packet.getFromInter()) <= packet.getFromComp()) || (packet.getToComp() != -1 && Utils.getInterfaceDefinitionsComponentsSize(packet.getToInter()) <= packet.getToComp())) return; if (packet.getFromInter() == Inventory.INVENTORY_INTERFACE && packet.getFromComp() == 0 && packet.getToInter() == Inventory.INVENTORY_INTERFACE && packet.getToComp() == 0) { player.closeInterfaces(); if (packet.getToSlot()-28 < 0 || packet.getToSlot()-28 >= player.getInventory().getItemsContainerSize() || packet.getFromSlot() >= player.getInventory().getItemsContainerSize()) return; player.getInventory().switchItem(packet.getFromSlot(), packet.getToSlot()-28); } else if (packet.getFromInter() == 763 && packet.getFromComp() == 0 && packet.getToInter() == 763 && packet.getToComp() == 0) { if (packet.getToSlot() >= player.getInventory().getItemsContainerSize() || packet.getFromSlot() >= player.getInventory().getItemsContainerSize()) return; player.getInventory().switchItem(packet.getFromSlot(), packet.getToSlot()); } else if (packet.getFromInter() == 762 && packet.getToInter() == 762) player.getBank().switchItem(packet.getFromSlot(), packet.getToSlot(), packet.getFromComp(), packet.getToComp()); else if (packet.getFromInter() == 1265 && packet.getToInter() == 1266 && player.getTempAttribs().getB(""shop_buying"")) { if (player.getTempAttribs().getB(""shop_buying"")) { Shop shop = player.getTempAttribs().getO(""Shop""); if (shop == null) return; shop.buy(player, packet.getFromSlot(), 1); } } else if (packet.getFromInter() == 34 && packet.getToInter() == 34) player.getNotes().switchNotes(packet.getFromSlot(), packet.getToSlot()); } }" "package com.rs.net.decoders.handlers.impl.interfaces; public class IFOnGroundItemHandler implements PacketHandler { @Override public void handle(Player player, IFOnGroundItem packet) { if ((Utils.getInterfaceDefinitionsSize() <= packet.getInterfaceId()) || player.isDead() || !player.getInterfaceManager().topOpen(packet.getInterfaceId())) return; if (packet.getComponentId() != 65535 && Utils.getInterfaceDefinitionsComponentsSize(packet.getInterfaceId()) <= packet.getComponentId()) return; final Tile tile = Tile.of(packet.getX(), packet.getY(), player.getPlane()); if (!player.getMapChunkIds().contains(tile.getChunkId())) return; GroundItem groundItem = ChunkManager.getChunk(tile.getChunkId()).getGroundItem(packet.getItemId(), tile, player); if (groundItem == null) return; player.stopAll(); if (packet.isForceRun()) player.setRun(packet.isForceRun()); if (packet.getInterfaceId() == 679) { Item item = player.getInventory().getItem(packet.getSlotId()); if (item == null) return; player.setRouteEvent(new RouteEvent(groundItem, () -> { if (item.getId() == 590) { Fire fire = Fire.forId(groundItem.getId()); if (fire != null) player.getActionManager().setAction(new Firemaking(fire, groundItem)); } })); } else if (packet.getInterfaceId() == 192 && packet.getComponentId() == 44) player.getActionManager().setAction(new PlayerAction() { @Override public boolean start(Player player) { return true; } public boolean process() { if (player.isDead() || player.hasFinished()) return false; final GroundItem item = ChunkManager.getChunk(tile.getChunkId()).getGroundItem(packet.getItemId(), tile, player); if ((item == null) || (player.getPlane() != tile.getPlane())) return false; if (player.hasEffect(Effect.FREEZE)) return true; if (!player.lineOfSightTo(tile, false) || Utils.getDistance(player.getTile(), tile) > 8) { if (player.hasWalkSteps()) player.resetWalkSteps(); player.calcFollow(tile, 25, true); return true; } if (TreasureTrailsManager.isScroll(item.getId())) if (player.getTreasureTrailsManager().hasClueScrollItem()) { player.sendMessage(""You should finish the clue you are currently doing first.""); return false; } if (player.canCastSpell() && Magic.checkMagicAndRunes(player, 33, true, new RuneSet(Rune.AIR, 1, Rune.LAW, 1))) { player.getActionManager().setActionDelay(3); player.addSpellDelay(2); player.resetWalkSteps(); player.setNextFaceTile(tile); player.setNextAnimation(new Animation(711)); player.getSkills().addXp(Constants.MAGIC, 43); player.setNextSpotAnim(new SpotAnim(142, 2, 50, Utils.getAngleTo(tile.getX() - player.getX(), tile.getY() - player.getY()))); World.sendProjectile(player, tile, 143, 35, 0, 60, 1, 0, p -> { final GroundItem gItem = ChunkManager.getChunk(tile.getChunkId()).getGroundItem(packet.getItemId(), tile, player); if (gItem == null) { player.sendMessage(""Too late. It's gone!""); return; } World.sendSpotAnim(tile, new SpotAnim(144)); PickupItemEvent e2 = new PickupItemEvent(player, gItem, true); PluginManager.handle(e2); if (!e2.isCancelPickup()) World.removeGroundItem(player, gItem, true); }); } return false; } @Override public boolean process(Player player) { return process(); } @Override public int processWithDelay(Player player) { return 0; } @Override public void stop(Player player) { } }); } }" "package com.rs.net.decoders.handlers.impl.interfaces; public class IFOnIFHandler implements PacketHandler { @Override public void handle(Player player, IFOnIF packet) { if ((packet.getFromInter() >= Utils.getInterfaceDefinitionsSize()) || (player.isLocked() || player.isDead() || !player.getInterfaceManager().topOpen(packet.getFromInter()))) return; if ((packet.getFromComp() != 65535 && Utils.getInterfaceDefinitionsComponentsSize(packet.getFromInter()) <= packet.getFromComp())) return; if ((packet.getToInter() >= Utils.getInterfaceDefinitionsSize()) || !player.getInterfaceManager().topOpen(packet.getToInter())) return; if ((packet.getToComp() != 65535 && Utils.getInterfaceDefinitionsComponentsSize(packet.getToInter()) <= packet.getToComp())) return; PluginManager.handle(new IFOnIFEvent(player, packet.getFromInter(), packet.getFromComp(), packet.getFromSlot(), packet.getFromItemId(), packet.getToInter(), packet.getToComp(), packet.getToSlot(), packet.getToItemId())); Logger.debug(IFOnIFHandler.class, ""handle"", ""IF on IF: ("" + packet.getFromInter() + "", "" + packet.getFromComp() + "", "" + packet.getFromSlot() + "") -> ("" + packet.getToInter() + "", "" + packet.getToComp() + "", "" + packet.getToSlot() + "")""); } }" "package com.rs.net.decoders.handlers.impl.interfaces; public class IFOnNPCHandler implements PacketHandler { @Override public void handle(Player player, IFOnNPC packet) { if (!player.hasStarted() || !player.clientHasLoadedMapRegion() || player.isDead() || player.isLocked()) return; if ((Utils.getInterfaceDefinitionsSize() <= packet.getInterfaceId()) || !player.getInterfaceManager().topOpen(packet.getInterfaceId()) || (packet.getComponentId() != -1 && Utils.getInterfaceDefinitionsComponentsSize(packet.getInterfaceId()) <= packet.getComponentId())) return; NPC npc = World.getNPCs().get(packet.getNpcIndex()); if (npc == null || npc.isDead() || npc.hasFinished() || !player.getMapChunkIds().contains(npc.getChunkId()) || npc.getDefinitions().getIdForPlayer(player.getVars()) == -1) return; player.stopAll(true); if (PluginManager.handle(new IFOnNPCEvent(player, npc, packet.getInterfaceId(), packet.getComponentId(), packet.getSlotId(), packet.getItemId(), false))) return; player.setRouteEvent(new RouteEvent(npc, () -> { player.faceEntity(npc); PluginManager.handle(new IFOnNPCEvent(player, npc, packet.getInterfaceId(), packet.getComponentId(), packet.getSlotId(), packet.getItemId(), true)); })); } }" "package com.rs.net.decoders.handlers.impl.interfaces; public class IFOnObjectHandler implements PacketHandler { @Override public void handle(Player player, IFOnObject packet) { if (!player.hasStarted() || !player.clientHasLoadedMapRegion() || player.isDead()) return; if (player.isLocked() || player.getEmotesManager().isAnimating()) return; final Tile tile = Tile.of(packet.getX(), packet.getY(), player.getPlane()); if (!player.getMapChunkIds().contains(tile.getChunkId())) return; GameObject mapObject = World.getObjectWithId(tile, packet.getObjectId()); if (mapObject == null || mapObject.getId() != packet.getObjectId()) return; final GameObject object = mapObject; if (player.isDead() || Utils.getInterfaceDefinitionsSize() <= packet.getInterfaceId() || player.isLocked() || !player.getInterfaceManager().topOpen(packet.getInterfaceId())) return; player.stopAll(); if (packet.isForceRun()) player.setRun(true); switch (packet.getInterfaceId()) { case 430: player.stopAll(true); if (packet.getComponentId() == 55) Lunars.handleCurePlant(player, object); else if (packet.getComponentId() == 24) Lunars.handleFertileSoil(player, object); break; case Inventory.INVENTORY_INTERFACE: // inventory final Item item = player.getInventory().getItem(packet.getSlotId()); if (item == null || item.getId() != packet.getItemId()) return; ObjectHandler.handleItemOnObject(player, object, packet.getInterfaceId(), item, packet.getSlotId()); break; case 662: case 747: if (player.getFamiliar() == null) return; player.resetWalkSteps(); if ((packet.getInterfaceId() == 662 && packet.getComponentId() == 74) || (packet.getInterfaceId() == 747 && packet.getComponentId() == 18)) player.getFamiliar().castSpecial(object); break; default: PluginManager.handle(new InterfaceOnObjectEvent(player, object, packet.getInterfaceId(), packet.getComponentId(), packet.getSlotId(), false)); player.setRouteEvent(new RouteEvent(object, () -> { player.faceObject(object); PluginManager.handle(new InterfaceOnObjectEvent(player, object, packet.getInterfaceId(), packet.getComponentId(), packet.getSlotId(), true)); })); break; } } }" "package com.rs.net.decoders.handlers.impl.interfaces; public class IFOnPlayerHandler implements PacketHandler { @Override public void handle(Player player, IFOnPlayer packet) { if (!player.hasStarted() || !player.clientHasLoadedMapRegion() || player.isDead() || player.isLocked()) return; if ((Utils.getInterfaceDefinitionsSize() <= packet.getInterfaceId()) || !player.getInterfaceManager().topOpen(packet.getInterfaceId()) || (packet.getComponentId() != -1 && Utils.getInterfaceDefinitionsComponentsSize(packet.getInterfaceId()) <= packet.getComponentId())) return; Player p2 = World.getPlayers().get(packet.getPlayerIndex()); if (p2 == null || p2.isDead() || p2.hasFinished() || !player.getMapChunkIds().contains(p2.getChunkId())) return; player.stopAll(false); if (PluginManager.handle(new IFOnPlayerEvent(player, p2, packet.getInterfaceId(), packet.getComponentId(), packet.getSlotId(), packet.getItemId(), false))) return; player.setRouteEvent(new RouteEvent(p2, () -> { player.faceEntity(p2); PluginManager.handle(new IFOnPlayerEvent(player, p2, packet.getInterfaceId(), packet.getComponentId(), packet.getSlotId(), packet.getItemId(), true)); })); } }" "package com.rs.net.decoders.handlers.impl.interfaces; public class IFOpHandler implements PacketHandler { @Override public void handle(Player player, IFOp packet) { if ((packet.getInterfaceId() >= Utils.getInterfaceDefinitionsSize()) || (player.isLocked() && !player.getTempAttribs().getB(""TransformationRing"")) || player.isDead() || !player.getInterfaceManager().topOpen(packet.getInterfaceId())) return; if ((packet.getComponentId() != 65535 && Utils.getInterfaceDefinitionsComponentsSize(packet.getInterfaceId()) <= packet.getComponentId()) || !player.getControllerManager().processButtonClick(packet.getInterfaceId(), packet.getComponentId(), packet.getSlotId(), packet.getItemId(), packet.getOpcode())) return; PluginManager.handle(new ButtonClickEvent(player, packet.getInterfaceId(), packet.getComponentId(), packet.getSlotId(), packet.getItemId(), packet.getOpcode())); } }" "package com.rs.net.decoders.handlers.impl.record; public class ClientFocusHandler implements PacketHandler { @Override public void handle(Player player, ClientFocus packet) { player.getRecorder().record(new Focus(packet.getTimeRecieved(), packet.isInFocus())); } }" "package com.rs.net.decoders.handlers.impl.record; public class MouseClickHWHandler implements PacketHandler { @Override public void handle(Player player, MouseClickHW packet) { player.getRecorder().record(new ClickHW(packet.getTimeRecieved(), packet.getTime(), packet.getX(), packet.getY(), packet.getMouseButton(), packet.isHardware())); } }" "package com.rs.net.decoders.handlers.impl.record; public class MouseClickJavHandler implements PacketHandler { @Override public void handle(Player player, MouseClickJav packet) { player.getRecorder().record(new Click(packet.getTimeRecieved(), packet.getTime(), packet.getX(), packet.getY(), packet.getMouseButton())); } }" "package com.rs.net.decoders.handlers.impl.record; public class MouseMoveHWHandler implements PacketHandler { @Override public void handle(Player player, MouseMoveJav packet) { player.getRecorder().record(new MouseMove(packet.getTimeRecieved(), 0, packet.getSteps(), true)); } }" "package com.rs.net.decoders.handlers.impl.record; public class MouseMoveJavHandler implements PacketHandler { @Override public void handle(Player player, MouseMoveJav packet) { player.getRecorder().record(new MouseMove(packet.getTimeRecieved(), 0, packet.getSteps(), false)); } }" "package com.rs.net.encoders; public class WorldEncoder extends Encoder { private final Player player; public WorldEncoder(Player player, Session session) { super(session); this.player = player; } public void sendWindowsPane(int id, int type) { session.writeToQueue(new IFOpenTop(id, type)); } public void sendInterface(boolean overlay, int topId, int topChildId, int subId) { session.writeToQueue(new IFOpenSub(topId, topChildId, subId, overlay)); } public void sendNPCInterface(NPC npc, boolean overlay, int topId, int topChildId, int subId) { session.writeToQueue(new IFOpenSubActiveNPC(topId, topChildId, subId, overlay, npc.getIndex())); } public void sendObjectInterface(GameObject object, boolean overlay, int topId, int topChildId, int subId) { session.writeToQueue(new IFOpenSubActiveObject(topId, topChildId, subId, overlay, object)); } public void sendPlayerInterface(boolean overlay, int topId, int topChildId, int subId) { session.writeToQueue(new IFOpenSubActivePlayer(topId, topChildId, subId, overlay, player.getIndex())); } public void sendGroundItemInterface(GroundItem item, boolean overlay, int topId, int topChildId, int subId) { session.writeToQueue(new IFOpenSubActiveGroundItem(topId, topChildId, subId, overlay, item)); } public void closeInterface(int topChildId) { session.writeToQueue(new IFCloseSub(topChildId)); } public void setIFGraphic(int interfaceId, int componentId, int spriteId) { session.writeToQueue(new IFSetGraphic(interfaceId, componentId, spriteId)); } public void setIFPosition(int interfaceId, int componentId, int x, int y) { session.writeToQueue(new IFSetPosition(interfaceId, componentId, x, y)); } public void setIFModel(int interfaceId, int componentId, int modelId) { session.writeToQueue(new IFSetModel(interfaceId, componentId, modelId)); } public void setIFHidden(int interfaceId, int componentId, boolean hidden) { session.writeToQueue(new IFSetHide(interfaceId, componentId, hidden)); } public void setIFEvents(IFEvents params) { session.writeToQueue(new IFSetEvents(params)); } public void setIFRightClickOps(int interfaceId, int componentId, int fromSlot, int toSlot, int... optionsSlots) { setIFEvents(new IFEvents(interfaceId, componentId, fromSlot, toSlot).enableRightClickOptions(optionsSlots)); } public void setIFTargetParam(int interfaceId, int componentId, int fromSlot, int toSlot, int targetParam) { session.writeToQueue(new IFSetTargetParam(interfaceId, componentId, fromSlot, toSlot, targetParam)); } public void setIFText(int interfaceId, int componentId, String text) { session.writeToQueue(new IFSetText(interfaceId, componentId, text)); } public void setIFAnimation(int emoteId, int interfaceId, int componentId) { session.writeToQueue(new IFSetAnimation(interfaceId, componentId, emoteId)); } public void setIFAngle(int interfaceId, int componentId, int pitch, int roll, int scale) { session.writeToQueue(new IFSetAngle(interfaceId, componentId, pitch, roll, scale)); } public void setIFItem(int interfaceId, int componentId, int id, int amount) { session.writeToQueue(new IFSetItem(interfaceId, componentId, id, amount)); } public void setIFPlayerHead(int interfaceId, int componentId) { session.writeToQueue(new IFSetPlayerHead(interfaceId, componentId)); } public void setIFNPCHead(int interfaceId, int componentId, int npcId) { session.writeToQueue(new IFSetNPCHead(interfaceId, componentId, npcId)); } public void updateGESlot(int slot, int progress, int item, int price, int amount, int currAmount, int totalPrice) { session.writeToQueue(new UpdateGESlot(slot, progress, item, price, amount, currAmount, totalPrice)); } public void sendDrawOrder(boolean playerFirst) { session.writeToQueue(new DrawOrder(playerFirst)); } public void sendHintIcon(HintIcon icon) { session.writeToQueue(new HintArrow(icon)); } public void sendCameraShake(int slotId, int v1, int v2, int v3, int v4) { session.writeToQueue(new CamShake(slotId, v1, v2, v3, v4)); } public void sendStopCameraShake() { session.writeToQueue(ServerPacket.CAM_RESET_HARD); } public void sendCameraLook(Tile tile, int viewZ) { sendCameraLook(tile.getXInScene(player.getSceneBaseChunkId()), tile.getYInScene(player.getSceneBaseChunkId()), viewZ); } public void sendCameraLook(Tile tile, int viewZ, int speedToExactDestination, int speedOnRoutePath) { sendCameraLook(tile.getXInScene(player.getSceneBaseChunkId()), tile.getYInScene(player.getSceneBaseChunkId()), viewZ, speedToExactDestination, speedOnRoutePath); } public void sendCameraLook(int viewLocalX, int viewLocalY, int viewZ) { sendCameraLook(viewLocalX, viewLocalY, viewZ, -1, -1); } public void sendCameraLook(int viewLocalX, int viewLocalY, int viewZ, int speedToExactDestination, int speedOnRoutePath) { session.writeToQueue(new CamLookAt(viewLocalX, viewLocalY, viewZ, speedToExactDestination, speedOnRoutePath)); } public void sendResetCamera() { session.writeToQueue(ServerPacket.CAM_RESET_HARD); } public void sendResetCameraSoft() { session.writeToQueue(ServerPacket.CAM_RESET_SMOOTH); } public void sendCameraPos(Tile tile, int z) { sendCameraPos(tile.getXInScene(player.getSceneBaseChunkId()), tile.getYInScene(player.getSceneBaseChunkId()), z); } public void sendCameraPos(Tile tile, int z, int speedToTile, int speedToExactDestination) { sendCameraPos(tile.getXInScene(player.getSceneBaseChunkId()), tile.getYInScene(player.getSceneBaseChunkId()), z, speedToTile, speedToExactDestination); } public void sendCameraPos(int moveLocalX, int moveLocalY, int moveZ) { sendCameraPos(moveLocalX, moveLocalY, moveZ, -1, -1); } /** * @param speedToTile defines speed of the camera to the world tile with the default height then the exact position * @param speedToExactDestination defines speed of camera to the exact position specified by previous parameters. */ public void sendCameraPos(int moveLocalX, int moveLocalY, int moveZ, int speedToTile, int speedToExactDestination) { session.writeToQueue(new CamMoveTo(moveLocalX, moveLocalY, moveZ, speedToTile, speedToExactDestination)); } public void sendRunScript(int scriptId, Object... params) { List l = Arrays.asList(params); Collections.reverse(l); sendRunScriptReverse(scriptId, l.toArray()); } public void setIFSprite(int interfaceId, int componentId, int slotId, int spriteId) { sendRunScript(1351, Utils.toInterfaceHash(interfaceId, componentId), slotId, spriteId); } public void setIFText(int interfaceId, int componentId, int slotId, String text) { sendRunScript(6566, Utils.toInterfaceHash(interfaceId, componentId), slotId, text); } public void sendRunScriptReverse(int scriptId, Object... params) { session.writeToQueue(new ExecuteCS2(scriptId, params)); } public void sendVarc(int id, int value) { session.writeToQueue(new SetVarc(id, value)); } public void sendVarcString(int id, String string) { session.writeToQueue(new SetVarcString(id, string)); } @Deprecated public void sendVar(int id, int value) { session.writeToQueue(new SetVarp(id, value)); } @Deprecated public void sendVarBit(int id, int value) { session.writeToQueue(new SetVarpBit(id, value)); } @Deprecated public void clearVarps() { session.writeToQueue(ServerPacket.CLEAR_VARPS); } public void sendRunEnergy(double energy) { session.writeToQueue(new RunEnergy((int) energy)); } public void refreshWeight(double weight) { session.writeToQueue(new RunWeight((int) weight)); } public void sendObjectAnimation(GameObject object, Animation animation) { session.writeToQueue(new UpdateZonePartial(player.getSceneBaseChunkId(), object.getTile().getChunkId())); session.writeToQueue(new ObjectAnim(object.getTile().getChunkLocalHash(), object, animation)); } public void removeGroundItem(GroundItem item) { session.writeToQueue(new UpdateZonePartial(player.getSceneBaseChunkId(), item.getTile().getChunkId())); session.writeToQueue(new RemoveGroundItem(item.getTile().getChunkLocalHash(), item)); } public void sendGroundItem(GroundItem item) { session.writeToQueue(new UpdateZonePartial(player.getSceneBaseChunkId(), item.getTile().getChunkId())); session.writeToQueue(new CreateGroundItem(item.getTile().getChunkLocalHash(), item)); } public void sendSetGroundItemAmount(GroundItem item, int oldAmount) { session.writeToQueue(new UpdateZonePartial(player.getSceneBaseChunkId(), item.getTile().getChunkId())); session.writeToQueue(new SetGroundItemAmount(item.getTile().getChunkLocalHash(), item, oldAmount)); } public void sendProjectile(WorldProjectile projectile) { session.writeToQueue(new UpdateZonePartial(player.getSceneBaseChunkId(), projectile.getFromTile().getChunkId())); session.writeToQueue(new ProjAnim(projectile.getFromTile().getChunkLocalHash(), projectile)); } public void sendTileMessage(String message, Tile tile, int delay, int height, int color) { session.writeToQueue(new UpdateZonePartial(player.getSceneBaseChunkId(), tile.getChunkId())); session.writeToQueue(new TileMessage(tile.getChunkLocalHash(), message, delay, height, color)); } public void sendTileMessage(String message, Tile tile, int color) { sendTileMessage(message, tile, 5000, 255, color); } public void sendRemoveObject(GameObject object) { session.writeToQueue(new UpdateZonePartial(player.getSceneBaseChunkId(), object.getTile().getChunkId())); session.writeToQueue(new RemoveObject(object.getTile().getChunkLocalHash(), object)); } public void sendAddObject(GameObject object) { session.writeToQueue(new UpdateZonePartial(player.getSceneBaseChunkId(), object.getTile().getChunkId())); session.writeToQueue(new AddObject(object.getTile().getChunkLocalHash(), object)); if (object.getMeshModifier() != null) sendCustomizeObject(object.getMeshModifier()); } public void sendCustomizeObject(ObjectMeshModifier modifier) { session.writeToQueue(new UpdateZonePartial(player.getSceneBaseChunkId(), modifier.getObject().getTile().getChunkId())); session.writeToQueue(new CustomizeObject(modifier.getObject().getTile().getChunkLocalHash(), modifier.getObject(), modifier.getModelIds(), modifier.getModifiedColors(), modifier.getModifiedTextures())); } public void sendMessage(MessageType type, String text, Player p) { session.writeToQueue(new MessageGame(type, text, p == null ? null : p.getAccount())); } public void sendPublicMessage(Player p, PublicChatMessage message) { session.writeToQueue(new MessagePublic(p.getIndex(), p.getMessageIcon(), message)); } public void sendPrivateMessage(String username, String message) { session.writeToQueue(new MessagePrivate(username, message)); } public void receivePrivateMessage(Account account, String message) { session.writeToQueue(new MessagePrivateEcho(account, message)); } public void receivePrivateChatQuickMessage(Account account, QuickChatMessage message) { session.writeToQueue(new QuickChatPrivateEcho(account, message)); } public void sendPrivateQuickMessage(String username, QuickChatMessage message) { session.writeToQueue(new QuickChatPrivate(username, message)); } public void sendFriendsChatMessage(Account account, String chatName, String message) { session.writeToQueue(new MessageFriendsChat(account, chatName, message)); } public void receiveFriendChatQuickMessage(Account account, String chatName, QuickChatMessage message) { session.writeToQueue(new QuickChatFriendsChat(account, chatName, message)); } public void receiveClanChatMessage(Account account, String message, boolean guest) { session.writeToQueue(new MessageClan(account, message, guest)); } public void receiveClanChatQuickMessage(Account account, QuickChatMessage message, boolean guest) { session.writeToQueue(new QuickChatClan(account, message, guest)); } public void sendChatFilterSettings() { session.writeToQueue(new ChatFilterSettings(player.getTradeStatus(), player.getPublicStatus())); } public void sendChatFilterSettingsPrivateChat() { session.writeToQueue(new ChatFilterSettingsPriv(player.getAccount().getSocial().getStatus())); } public void sendDynamicMapRegion(boolean sendLSWP) { byte[] lswp = null; if (sendLSWP) { OutputStream stream = new OutputStream(); player.getLocalPlayerUpdate().init(stream); lswp = stream.toByteArray(); } OutputStream stream = new OutputStream(); stream.initBitAccess(); int mapHash = player.getMapSize().size >> 4; int[] realRegionIds = new int[4 * mapHash * mapHash]; int realRegionIdsCount = 0; // Logger.debug(WorldEncoder.class, ""sendDynamicMapRegion"", ""[Start DynamicRegion]""); // Logger.debug(WorldEncoder.class, ""sendDynamicMapRegion"", player.getMapSize() + "", (""+player.getChunkX() + "", "" + player.getChunkY() + "")""); for (int plane = 0; plane < 4 * Chunk.PLANE_INC; plane += Chunk.PLANE_INC) { for (int chunkX = (player.getChunkX() - mapHash) * Chunk.X_INC; chunkX <= ((player.getChunkX() + mapHash)) * Chunk.X_INC; chunkX += Chunk.X_INC) { for (int chunkY = (player.getChunkY() - mapHash); chunkY <= ((player.getChunkY() + mapHash)); chunkY++) { Chunk chunk = ChunkManager.getChunk(chunkX + chunkY + plane); if (chunk.getRenderChunkX() == 0 || chunk.getRenderChunkY() == 0) { // Logger.debug(WorldEncoder.class, ""sendDynamicMapRegion"", ""Empty block: "" + chunk.getX() + "", "" + chunk.getY()); stream.writeBits(1, 0); } else { // Logger.debug(WorldEncoder.class, ""sendDynamicMapRegion"", ""Dynamic block: "" + chunk.getX() + "", "" + chunk.getY()); // Logger.debug(WorldEncoder.class, ""sendDynamicMapRegion"", ""["" + chunk.getRenderChunkX() + "", "" + chunk.getRenderChunkY() + "", "" + chunk.getRenderPlane() + ""] rot: "" + chunk.getRotation()); stream.writeBits(1, 1); stream.writeBits(26, (chunk.getRotation() << 1) | (chunk.getRenderPlane() << 24) | (chunk.getRenderChunkX() << 14) | (chunk.getRenderChunkY() << 3)); boolean found = false; for (int index = 0; index < realRegionIdsCount; index++) { if (realRegionIds[index] == chunk.getRenderRegionId()) { found = true; break; } } if (!found) realRegionIds[realRegionIdsCount++] = chunk.getRenderRegionId(); } } } } stream.finishBitAccess(); // Logger.debug(WorldEncoder.class, ""sendDynamicMapRegion"", Arrays.toString(realRegionIds)); // Logger.debug(WorldEncoder.class, ""sendDynamicMapRegion"", realRegionIds.length + "" - "" + realRegionIdsCount); // Logger.debug(WorldEncoder.class, ""sendDynamicMapRegion"", ""[End DynamicRegion]""); session.writeToQueue(new DynamicMapRegion(lswp, player.getMapSize(), player.getChunkX(), player.getChunkY(), player.isForceNextMapLoadRefresh(), stream.toByteArray(), realRegionIds)); } public void sendMapRegion(boolean sendLSWP) { byte[] lswp = null; if (sendLSWP) { OutputStream stream = new OutputStream(); player.getLocalPlayerUpdate().init(stream); lswp = stream.toByteArray(); } Set mapRegionIds = new IntOpenHashSet(); for (int chunkId : player.getMapChunkIds()) { int[] coords = MapUtils.decode(Structure.CHUNK, chunkId); mapRegionIds.add(MapUtils.encode(Structure.REGION, coords[0] >> 3, coords[1] >> 3)); } session.writeToQueue(new MapRegion(lswp, player.getMapSize(), player.getChunkX(), player.getChunkY(), player.isForceNextMapLoadRefresh(), mapRegionIds)); } public void sendCutscene(int id) { session.writeToQueue(new Cutscene(id, player.getAppearance().getAppeareanceData())); } @Deprecated public void sendPlayerOption(String option, int slot, boolean top) { sendPlayerOption(option, slot, top, -1); } @Deprecated public void sendPlayerOption(String option, int slot, boolean top, int cursor) { session.writeToQueue(new PlayerOption(option, slot, top, cursor)); } public void sendLocalPlayersUpdate() { OutputStream stream = new OutputStream(); player.getLocalPlayerUpdate().write(stream); session.writeToQueue(new PlayerUpdate(stream.toByteArray())); } public void sendLocalNPCsUpdate() { OutputStream stream = new OutputStream(); player.getLocalNPCUpdate().write(stream, player.hasLargeSceneView()); session.writeToQueue(new NPCUpdate(player.hasLargeSceneView(), stream.toByteArray())); } public void sendSpotAnim(SpotAnim spotAnim, Object target) { int targetHash = 0; if (target instanceof Player p) targetHash = p.getIndex() & 0xffff | 1 << 28; else if (target instanceof NPC n) targetHash = n.getIndex() & 0xffff | 1 << 29; else if (target instanceof Tile tile) targetHash = tile.getPlane() << 28 | tile.getX() << 14 | tile.getY() & 0x3fff | 1 << 30; session.writeToQueue(new SpotAnimSpecific(spotAnim, targetHash)); } public void sendSystemUpdate(int delay) { session.writeToQueue(new SystemUpdateTimer(delay)); } public void sendUpdateItems(int key, boolean negativeKey, Item[] items, int... slots) { session.writeToQueue(new UpdateItemContainer(key, negativeKey, items, slots)); } public void sendUpdateItems(int key, ItemsContainer items, int... slots) { sendUpdateItems(key, items.array(), slots); } public void sendUpdateItems(int key, Item[] items, int... slots) { sendUpdateItems(key, key < 0, items, slots); } public void sendItems(int key, boolean negativeKey, Item[] items) { session.writeToQueue(new UpdateItemContainer(key, negativeKey, items)); } public void sendItems(int key, ItemsContainer items) { sendItems(key, key < 0, items); } public void sendItems(int key, boolean negativeKey, ItemsContainer items) { sendItems(key, negativeKey, items.array()); } public void sendItems(int key, Item[] items) { sendItems(key, key < 0, items); } public void sendLogout(boolean lobby) { session.writeToQueue(lobby ? ServerPacket.LOGOUT_LOBBY : ServerPacket.LOGOUT_FULL); ChannelFuture future = player.getSession().flush(); if (player.hasFinished()) if (future != null) future.addListener(ChannelFutureListener.CLOSE); else player.getSession().getChannel().close(); } public void sendSound(Sound sound) { session.writeToQueue(sound); } public void resetSounds() { session.writeToQueue(ServerPacket.RESET_SOUNDS); } public void updateStats(int... skills) { UpdateStat[] updateStats = new UpdateStat[skills.length]; for (int i = 0;i < skills.length;i++) updateStats[i] = new UpdateStat(skills[i], (int) player.getSkills().getXp(skills[i]), player.getSkills().getLevel(skills[i])); session.writeToQueue(updateStats); } public void setBlockMinimapState(int state) { session.writeToQueue(new BlockMinimapState(state)); } public void sendOpenURL(String url) { session.writeToQueue(new OpenURL(url)); } public void sendSetCursor(String walkHereReplace, int cursor) { session.writeToQueue(new SetCursor(walkHereReplace, cursor)); } public void sendGameBarStages() { sendVar(1054, player.getClanStatus()); sendVar(1055, player.getAssistStatus()); sendVar(1056, player.isFilterGame() ? 1 : 0); sendVar(2159, player.getAccount().getSocial().getFcStatus()); sendChatFilterSettings(); sendChatFilterSettingsPrivateChat(); } public void sendInventoryMessage(int border, int slotId, String message) { sendGameMessage(message); sendRunScriptReverse(948, border, slotId, message); } public void sendGameMessage(String text) { sendGameMessage(text, false); } public void sendGameMessage(String text, boolean filter) { sendMessage(filter ? MessageType.FILTERABLE : MessageType.UNFILTERABLE, text, null); } public void sendDevConsoleMessage(String text) { sendMessage(MessageType.DEV_CONSOLE, text, null); } public void sendTradeRequestMessage(Player p) { sendMessage(MessageType.TRADE_REQUEST, ""wishes to trade with you."", p); } public void sendClanWarsRequestMessage(Player p) { sendMessage(MessageType.CLAN_CHALLENGE_REQUEST, ""wishes to challenge your clan to a clan war."", p); } public void sendDuelChallengeRequestMessage(Player p, boolean friendly) { sendMessage(MessageType.DUEL_REQUEST, ""wishes to duel with you ("" + (friendly ? ""friendly"" : ""stake"") + "")."", p); } public void sendDungeonneringRequestMessage(Player p) { sendMessage(MessageType.DUNGEONEERING_INVITE, ""has invited you to a dungeon party."", p); } public void sendClanInviteMessage(Player p) { sendMessage(MessageType.CLAN_INVITE, p.getDisplayName() + "" is inviting you to join their clan."", p); } public void sendPouchInfusionOptionsScript(boolean dung, int interfaceId, int componentId, int slotLength, int width, int height, String... options) { Object[] parameters = new Object[5 + options.length]; int index = 0; if (dung) { parameters[index++] = 1159; parameters[index++] = 1100; } else { parameters[index++] = slotLength; parameters[index++] = 1; } for (int count = options.length - 1; count >= 0; count--) parameters[index++] = options[count]; parameters[index++] = height; parameters[index++] = width; parameters[index++] = interfaceId << 16 | componentId; sendRunScriptReverse(757, parameters); } public void sendScrollInfusionOptionsScript(boolean dung, int interfaceId, int componentId, int slotLength, int width, int height, String... options) { Object[] parameters = new Object[5 + options.length]; int index = 0; if (dung) { parameters[index++] = 1159; parameters[index++] = 1100; } else { parameters[index++] = slotLength; parameters[index++] = 1; } for (int count = options.length - 1; count >= 0; count--) parameters[index++] = options[count]; parameters[index++] = height; parameters[index++] = width; parameters[index++] = interfaceId << 16 | componentId; sendRunScriptReverse(763, parameters); } public void sendRunScriptBlank(int scriptId) { sendRunScriptReverse(scriptId); } public void sendGroundItemMessage(GroundItem item, String message) { sendGroundItemMessage(0, 0xFFFFFF, item, message); } public void sendPlayerMessage(int border, int color, String message) { sendGameMessage(message); sendVarcString(306, message); sendVarc(1699, color); sendVarc(1700, border); sendVarc(1695, 1); sendPlayerInterface(true, player.getInterfaceManager().getTopInterface(), Sub.RENDER_SPACE.getComponent(player.resizeable()), 1177); } public void sendNPCMessage(int border, int color, NPC npc, String message) { sendGameMessage(message); sendVarcString(306, message); sendVarc(1699, color); sendVarc(1700, border); sendVarc(1695, 1); sendNPCInterface(npc, true, player.getInterfaceManager().getTopInterface(), Sub.RENDER_SPACE.getComponent(player.resizeable()), 1177); } public void sendGroundItemMessage(int border, int color, GroundItem item, String message) { sendGameMessage(message); sendVarcString(306, message); sendVarc(1699, color); sendVarc(1700, border); sendVarc(1695, 1); sendGroundItemInterface(item, true, player.getInterfaceManager().getTopInterface(), Sub.RENDER_SPACE.getComponent(player.resizeable()), 1177); } public void sendObjectMessage(int border, int color, GameObject object, String message) { sendGameMessage(message); sendVarcString(306, message); sendVarc(1699, color); sendVarc(1700, border); sendVarc(1695, 1); sendObjectInterface(object, true, player.getInterfaceManager().getTopInterface(), Sub.RENDER_SPACE.getComponent(player.resizeable()), 1177); } public void openGESearch() { player.getInterfaceManager().sendChatBoxInterface(7, 389); sendRunScriptReverse(570, ""Grand Exchange Item Search""); } public void sendInterFlashScript(int interfaceId, int componentId, int width, int height, int slot) { Object[] parameters = new Object[4]; int index = 0; parameters[index++] = slot; parameters[index++] = height; parameters[index++] = width; parameters[index++] = interfaceId << 16 | componentId; sendRunScriptReverse(143, parameters); } public void sendInterSetItemsOptionsScript(int interfaceId, int componentId, int key, int width, int height, String... options) { sendInterSetItemsOptionsScript(interfaceId, componentId, key, false, width, height, options); } public void sendInterSetItemsOptionsScript(int interfaceId, int componentId, int key, boolean negativeKey, int width, int height, String... options) { Object[] parameters = new Object[6 + options.length]; int index = 0; for (int count = options.length - 1; count >= 0; count--) parameters[index++] = options[count]; parameters[index++] = -1; // dunno but always this parameters[index++] = 0;// dunno but always this, maybe startslot? parameters[index++] = height; parameters[index++] = width; parameters[index++] = key; parameters[index++] = interfaceId << 16 | componentId; sendRunScriptReverse(negativeKey ? 695 : 150, parameters); // scriptid 150 does // that the method // name says*/ } public void sendInputIntegerScript(String message) { sendRunScriptReverse(108, message); } public void sendInputNameScript(String message) { sendRunScriptReverse(109, message); } public void sendInputLongTextScript(String message) { sendRunScriptReverse(110, message); } public void setClanVar(int varId, Object value) { session.writeToQueue(new SetVarClan(varId, value)); } }" "package com.rs.plugin; public class PluginManager { private static final Map>> UNMAPPED_HANDLERS = new HashMap<>(); private static final List STARTUP_HOOKS = new ArrayList<>(); private static final PluginMethodRepository REPOSITORY = new PluginMethodRepository(); private static void addUnmappedHandler(String type, PluginHandler method) { HashSet> methods = UNMAPPED_HANDLERS.get(type); if (methods == null) methods = new HashSet<>(); methods.add(method); UNMAPPED_HANDLERS.put(type, methods); } public static void loadPlugins() { try { long start = System.currentTimeMillis(); Logger.info(PluginManager.class, ""loadPlugins"", ""Loading plugins...""); List> eventTypes = Utils.getClasses(""com.rs.plugin.events""); List> classes = Utils.getClassesWithAnnotation(""com.rs"", PluginEventHandler.class); Set visitedFields = new HashSet<>(); Logger.info(PluginManager.class, ""loadPlugins"", ""Loading "" + eventTypes.size() + "" event types and "" + classes.size() + "" plugin enabled classes.""); int handlers = 0; List startupMethods = Utils.getMethodsWithAnnotation(""com.rs"", ServerStartupEvent.class); Set visitedMethods = new HashSet<>(); for (Method method : startupMethods) { if (visitedMethods.contains(method)) continue; if (!Modifier.isStatic(method.getModifiers())) throw new RuntimeException(""Startup method should be static: "" + method.getDeclaringClass() + ""."" + method.getName()); if (method.getParameterCount() > 0) throw new RuntimeException(""Startup method should have no parameters: "" + method.getDeclaringClass() + ""."" + method.getName()); visitedMethods.add(method); STARTUP_HOOKS.add(method); handlers++; } for (Class clazz : classes) { for (Field field : clazz.getFields()) { if (!Modifier.isStatic(field.getModifiers()) || visitedFields.contains(field)) continue; visitedFields.add(field); handlers += processField(field, eventTypes); } } int kotlinScripts = PluginScriptHost.Companion.loadAndExecuteScripts(); handlers += kotlinScripts; Logger.info(PluginManager.class, ""loadPlugins"", ""Loaded "" + kotlinScripts + "" kotlin script plugins in "" + (System.currentTimeMillis()-start) + ""ms.""); Logger.info(PluginManager.class, ""loadPlugins"", ""Loaded "" + handlers + "" plugin event handlers in "" + (System.currentTimeMillis()-start) + ""ms.""); } catch (ClassNotFoundException | IOException | IllegalArgumentException | IllegalAccessException e) { e.printStackTrace(); } } @SuppressWarnings(""unchecked"") public static int processField(Field field, List> eventTypes) throws IllegalAccessException { int found = 0; for (Class eventType : eventTypes) { if (field.getType() == PluginHandler.class) { Class type = ((Class) ((ParameterizedType) field.getGenericType()).getActualTypeArguments()[0]); if (type != eventType) continue; } else if (field.getType().getSuperclass() == PluginHandler.class) { Class type = ((Class) ((ParameterizedType) field.getType().getGenericSuperclass()).getActualTypeArguments()[0]); if (type != eventType) continue; } else continue; field.setAccessible(true); PluginHandler handler = (PluginHandler) field.get(null); if (handler.keys() == null || handler.keys().length <= 0) { addUnmappedHandler(eventType.getName(), handler); } else { REPOSITORY.addMappedHandler(eventType, handler); } found++; } return found; } public static void executeStartupHooks() { STARTUP_HOOKS.sort(Comparator.comparingInt(m -> m.getAnnotationsByType(ServerStartupEvent.class)[0].value().ordinal())); for (Method m : STARTUP_HOOKS) { long start = System.currentTimeMillis(); try { m.invoke(null); } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { System.err.println(""Error executing startup hook: "" + m.getDeclaringClass().getName() + ""."" + m.getName()); e.printStackTrace(); } long time = System.currentTimeMillis() - start; if (time > 100L) Logger.info(m.getDeclaringClass(), m.getName(), m.getDeclaringClass().getSimpleName() + "": Executed "" + m.getName() + "" in "" + time + ""ms...""); } } public static boolean handle(PluginEvent event) { if (REPOSITORY.handle(event)) return true; HashSet> methods = UNMAPPED_HANDLERS.get(event.getClass().getName()); if (methods == null) return false; boolean usedPlugins = false; for (PluginHandler method : methods) if (method.handleGlobal(event)) usedPlugins = true; return usedPlugins; } public static Object getObj(PluginEvent event) { Object obj = REPOSITORY.getObj(event); if (obj != null) return obj; HashSet> methods = UNMAPPED_HANDLERS.get(event.getClass().getName()); if (methods == null) return null; for (PluginHandler method : methods) { obj = method.getObj(event); if (obj != null) return obj; } return null; } public static boolean handle(Method method, Object event) { try { return (boolean) method.invoke(null, event); } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { Logger.handle(method.getDeclaringClass(), method.getName(), e); } return false; } public static int getAmountPlayerHas(Player player, int itemId) { if (itemId >= 25629 && itemId <= 25633) return ArtisansWorkshop.numStoredOres(player, itemId); return -1; } }" "package com.rs.plugin; public class PluginMethodRepository { public void addMappedHandler(Class eventType, PluginHandler method) { try { eventType.getMethod(""registerMethod"", Class.class, PluginHandler.class).invoke(null, eventType, method); } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException e) { System.err.println(""Error registering method for event type: "" + eventType.getName() + "" from registering method""); e.printStackTrace(); } } @SuppressWarnings(""unchecked"") public boolean handle(PluginEvent event) { PluginHandler method = (PluginHandler) event.getMethod(); if (method != null) { try { method.getHandler().accept(event); return true; } catch (Exception e) { Logger.handle(PluginMethodRepository.class, ""handle:"" + event.getClass().getSimpleName(), e); return false; } } List> methods = event.getMethods(); if (methods == null || methods.size() <= 0) return false; for (PluginHandler m : methods) try { PluginHandler pHandle = (PluginHandler) m; pHandle.getHandler().accept(event); } catch (Exception e) { Logger.handle(PluginMethodRepository.class, ""handle:"" + event.getClass().getSimpleName(), e); return false; } return true; } @SuppressWarnings(""unchecked"") public Object getObj(PluginEvent event) { Object obj = null; PluginHandler method = (PluginHandler) event.getMethod(); if (method == null) { List> methods = event.getMethods(); if (methods == null || methods.size() <= 0) return null; for (PluginHandler m : methods) try { PluginHandler pHandle = (PluginHandler) m; obj = pHandle.getObj(event); } catch (Exception e) { Logger.handle(PluginMethodRepository.class, ""getObj:"" + event.getClass().getSimpleName(), e); return null; } return obj; } try { obj = method.getObj(event); if (obj != null) return obj; } catch (Exception e) { Logger.handle(PluginMethodRepository.class, ""getObj:"" + event.getClass().getSimpleName(), e); return null; } return null; } }" "package com.rs.plugin.annotations; @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.TYPE) public @interface PluginEventHandler { }" "package com.rs.plugin.annotations; @Retention(RUNTIME) @Target(METHOD) public @interface ServerStartupEvent { enum Priority { SYSTEM, FILE_IO, GENERAL, POST_PROCESS } Priority value() default Priority.GENERAL; }" "package com.rs.plugin.events; public class ButtonClickEvent implements PluginEvent { private static final Map> HANDLERS = new HashMap<>(); private final Player player; private final int interfaceId; private final int componentId; private final int slotId; private final int slotId2; private final ClientPacket packet; public ButtonClickEvent(Player player, int interfaceId, int componentId, int slotId, int slotId2, ClientPacket packet) { this.player = player; this.interfaceId = interfaceId; this.componentId = componentId; this.slotId = slotId; this.slotId2 = slotId2; this.packet = packet; } public Player getPlayer() { return player; } public int getInterfaceId() { return interfaceId; } public int getComponentId() { return componentId; } public int getSlotId() { return slotId; } public int getSlotId2() { return slotId2; } public ClientPacket getPacket() { return packet; } @Override public PluginHandler getMethod() { return HANDLERS.get(getInterfaceId()); } public static void registerMethod(Class eventType, PluginHandler method) { for (Object key : method.keys()) { PluginHandler old = HANDLERS.put(key, method); if (old != null) System.err.println(""ERROR: Duplicate ButtonClick methods for key: "" + key); } } public Player component1() { return player; } public int component2() { return interfaceId; } public int component3() { return componentId; } public int component4() { return slotId; } public int component5() { return slotId2; } public ClientPacket component6() { return packet; } }" "package com.rs.plugin.events; public class DestroyItemEvent implements PluginEvent { private static final Map> HANDLERS = new HashMap<>(); private final Player player; private final Item item; public DestroyItemEvent(Player player, Item item) { this.player = player; this.item = item; } public Player getPlayer() { return player; } public Item getItem() { return item; } @Override public PluginHandler getMethod() { PluginHandler method = HANDLERS.get(item.getId()); if (method == null) method = HANDLERS.get(item.getDefinitions().getName()); if (method == null) return null; return method; } public static void registerMethod(Class eventType, PluginHandler method) { for (Object key : method.keys()) { PluginHandler old = HANDLERS.put(key, method); if (old != null) System.err.println(""ERROR: Duplicate DestroyItem methods for key: "" + key); } } public Player component1() { return player; } public Item component2() { return item; } }" "package com.rs.plugin.events; public class DropItemEvent implements PluginEvent { private static final Map> HANDLERS = new HashMap<>(); private final Player player; private final Item item; private boolean cancelDrop = false; public DropItemEvent(Player player, Item item) { this.player = player; this.item = item; } public Player getPlayer() { return player; } public Item getItem() { return item; } @Override public PluginHandler getMethod() { PluginHandler method = HANDLERS.get(item.getId()); if (method == null) method = HANDLERS.get(item.getDefinitions().getName()); if (method == null) return null; return method; } public static void registerMethod(Class eventType, PluginHandler method) { for (Object key : method.keys()) { PluginHandler old = HANDLERS.put(key, method); if (old != null) System.err.println(""ERROR: Duplicate DropItem methods for key: "" + key); } } public boolean dropCancelled() { return cancelDrop; } public void cancelDrop() { this.cancelDrop = true; } public Player component1() { return player; } public Item component2() { return item; } }" "package com.rs.plugin.events; public class EnterChunkEvent implements PluginEvent { private static final List> HANDLERS = new ArrayList<>(); private final Entity entity; private final int chunkId; public EnterChunkEvent(Entity entity, int chunkId) { this.entity = entity; this.chunkId = chunkId; } public NPC getNPC() { if (entity instanceof NPC n) return n; return null; } public Player getPlayer() { if (entity instanceof Player p) return p; return null; } public Entity getEntity() { return entity; } public int getChunkId() { return chunkId; } @Override public List> getMethods() { return HANDLERS; } public static void registerMethod(Class eventType, PluginHandler method) { HANDLERS.add(method); } public Entity component1() { return entity; } public int component2() { return chunkId; } }" "package com.rs.plugin.events; public class IFOnIFEvent implements PluginEvent { private static final Map> FROM_HANDLERS = new HashMap<>(); private static final Map> TO_HANDLERS = new HashMap<>(); private final Player player; private final int fromInterfaceId; private final int fromComponentId; private final int fromSlotId; private final int fromSlotId2; private final int toInterfaceId; private final int toComponentId; private final int toSlotId; private final int toSlotId2; public IFOnIFEvent(Player player, int fromInterfaceId, int fromComponentId, int fromSlotId, int fromSlotId2, int toInterfaceId, int toComponentId, int toSlotId, int toSlotId2) { this.player = player; this.fromInterfaceId = fromInterfaceId; this.fromComponentId = fromComponentId; this.fromSlotId = fromSlotId; this.fromSlotId2 = fromSlotId2; this.toInterfaceId = toInterfaceId; this.toComponentId = toComponentId; this.toSlotId = toSlotId; this.toSlotId2 = toSlotId2; } public Player getPlayer() { return player; } public int getFromInterfaceId() { return fromInterfaceId; } public int getFromComponentId() { return fromComponentId; } public int getFromSlotId() { return fromSlotId; } public int getFromSlotId2() { return fromSlotId2; } public int getToInterfaceId() { return toInterfaceId; } public int getToComponentId() { return toComponentId; } public int getToSlotId() { return toSlotId; } public int getToSlotId2() { return toSlotId2; } @Override public PluginHandler getMethod() { boolean to = false; Map mapping = FROM_HANDLERS.get((fromInterfaceId << 16) + fromComponentId); if (mapping == null) { mapping = TO_HANDLERS.get((toInterfaceId << 16) + toComponentId); to = true; } if (mapping != null) { InterfaceOnInterfaceHandler handler = mapping.get(((to ? fromInterfaceId : toInterfaceId) << 16) + (to ? fromComponentId : toComponentId)); if (handler == null) handler = mapping.get(to ? fromInterfaceId : toInterfaceId); if (handler == null) handler = mapping.get(-1); if (handler != null) return handler; } to = false; mapping = FROM_HANDLERS.get(fromInterfaceId); if (mapping == null) { mapping = TO_HANDLERS.get(toInterfaceId); to = true; } if (mapping != null) { InterfaceOnInterfaceHandler handler = mapping.get(((to ? fromInterfaceId : toInterfaceId) << 16) + (to ? fromComponentId : toComponentId)); if (handler == null) handler = mapping.get(to ? fromInterfaceId : toInterfaceId); if (handler == null) handler = mapping.get(-1); if (handler != null) return handler; } return null; } public static void registerMethod(Class eventType, PluginHandler method) { InterfaceOnInterfaceHandler handler = (InterfaceOnInterfaceHandler) method; map(handler, false); if (handler.isBidirectional()) map(handler, true); } public static void map(InterfaceOnInterfaceHandler handler, boolean reverse) { Object[] fromKeys = (reverse ? handler.getToKeys() : handler.getFromKeys()); Object[] toKeys = (reverse ? handler.getFromKeys() : handler.getToKeys()); if (fromKeys != null) { for (Object fromKey : fromKeys) { Map toMapping = FROM_HANDLERS.get(fromKey); if (toMapping == null) toMapping = new HashMap<>(); if (toKeys == null) toMapping.put(-1, handler); else for (Object toKey : toKeys) toMapping.put(toKey, handler); FROM_HANDLERS.put(fromKey, toMapping); } } else if (toKeys != null) { for (Object toKey : toKeys) { Map toMapping = TO_HANDLERS.get(toKey); if (toMapping == null) toMapping = new HashMap<>(); if (fromKeys == null) toMapping.put(-1, handler); else for (Object fromKey : fromKeys) toMapping.put(fromKey, handler); TO_HANDLERS.put(toKey, toMapping); } } } }" "package com.rs.plugin.events; public class IFOnNPCEvent implements PluginEvent { private static final Map HANDLERS = new HashMap<>(); private final Player player; private final NPC target; private final int interfaceId; private final int componentId; private final int slotId; private final int slotId2; private final boolean atNPC; public IFOnNPCEvent(Player player, NPC target, int interfaceId, int componentId, int slotId, int slotId2, boolean atNPC) { this.player = player; this.target = target; this.interfaceId = interfaceId; this.componentId = componentId; this.slotId = slotId; this.slotId2 = slotId2; this.atNPC = atNPC; } public Player getPlayer() { return player; } public NPC getTarget() { return target; } public int getInterfaceId() { return interfaceId; } public int getComponentId() { return componentId; } public int getSlotId() { return slotId; } public int getSlotId2() { return slotId2; } public boolean isAtNPC() { return atNPC; } @Override public PluginHandler getMethod() { InterfaceOnNPCHandler method = HANDLERS.get((interfaceId << 16) + componentId); if (method == null) method = HANDLERS.get(getInterfaceId()); if ((method == null) || (!isAtNPC() && method.isCheckDistance())) return null; return method; } public static void registerMethod(Class eventType, PluginHandler method) { for (Object key : method.keys()) { InterfaceOnNPCHandler old = HANDLERS.put(key, (InterfaceOnNPCHandler) method); if (old != null) System.err.println(""ERROR: Duplicate InterfaceOnNPC methods for key: "" + key); } } }" "package com.rs.plugin.events; public class IFOnPlayerEvent implements PluginEvent { private static final Map HANDLERS = new HashMap<>(); private final Player player; private final Player target; private final int interfaceId; private final int componentId; private final int slotId; private final int slotId2; private final boolean atPlayer; public IFOnPlayerEvent(Player player, Player target, int interfaceId, int componentId, int slotId, int slotId2, boolean atPlayer) { this.player = player; this.target = target; this.interfaceId = interfaceId; this.componentId = componentId; this.slotId = slotId; this.slotId2 = slotId2; this.atPlayer = atPlayer; } public Player getPlayer() { return player; } public Player getTarget() { return target; } public int getInterfaceId() { return interfaceId; } public int getComponentId() { return componentId; } public int getSlotId() { return slotId; } public int getSlotId2() { return slotId2; } public boolean isAtPlayer() { return atPlayer; } @Override public PluginHandler getMethod() { InterfaceOnPlayerHandler method = HANDLERS.get((interfaceId << 16) + componentId); if (method == null) method = HANDLERS.get(getInterfaceId()); if ((method == null) || (!isAtPlayer() && method.isCheckDistance())) return null; return method; } public static void registerMethod(Class eventType, PluginHandler method) { for (Object key : method.keys()) { PluginHandler old = HANDLERS.put(key, (InterfaceOnPlayerHandler) method); if (old != null) System.err.println(""ERROR: Duplicate InterfaceOnPlayer methods for key: "" + key); } } }" "package com.rs.plugin.events; public interface InputHSLEvent { void run(int color); }" "package com.rs.plugin.events; public interface InputIntegerEvent { void run(int choice); }" "package com.rs.plugin.events; public interface InputStringEvent { void run(String string); }" "package com.rs.plugin.events; public class InterfaceOnObjectEvent implements PluginEvent { private static final Map HANDLERS = new HashMap<>(); private final Player player; private final int interfaceId; private final int componentId; private final int slotId; private final GameObject object; private final boolean atObject; public InterfaceOnObjectEvent(Player player, GameObject object, int interfaceId, int componentId, int slotId, boolean atObject) { this.player = player; this.interfaceId = interfaceId; this.componentId = componentId; this.slotId = slotId; this.object = object; this.atObject = atObject; } public Player getPlayer() { return player; } public int getInterfaceId() { return interfaceId; } public int getComponentId() { return componentId; } public int getSlotId() { return slotId; } public GameObject getObject() { return object; } public int getObjectId() { return object.getId(); } public boolean isAtObject() { return atObject; } @Override public PluginHandler getMethod() { InterfaceOnObjectHandler method = HANDLERS.get((interfaceId << 16) + componentId); if (method == null) method = HANDLERS.get(getInterfaceId()); if ((method == null) || (!isAtObject() && method.isCheckDistance())) return null; return method; } public static void registerMethod(Class eventType, PluginHandler method) { for (Object key : method.keys()) { PluginHandler old = HANDLERS.put(key, (InterfaceOnObjectHandler) method); if (old != null) System.err.println(""ERROR: Duplicate InterfaceOnObject methods for key: "" + key); } } }" "package com.rs.plugin.events; public class ItemAddedToBankEvent implements PluginEvent { private static final Map> HANDLERS = new HashMap<>(); private final Player player; private final Item item; private boolean cancelled; public ItemAddedToBankEvent(Player player, Item item) { this.player = player; this.item = item; } public Player getPlayer() { return player; } public Item getItem() { return item; } public void cancel() { cancelled = true; } @Override public PluginHandler getMethod() { PluginHandler method = HANDLERS.get(item.getId()); if (method == null) method = HANDLERS.get(item.getDefinitions().getName()); if (method == null) return null; return method; } public static void registerMethod(Class eventType, PluginHandler method) { for (Object key : method.keys()) { PluginHandler old = HANDLERS.put(key, method); if (old != null) System.err.println(""ERROR: Duplicate ItemAddedToBankEvent methods for key: "" + key + "":""); } } public Player component1() { return player; } public Item component2() { return item; } public boolean isCancelled() { return cancelled; } }" "package com.rs.plugin.events; public class ItemAddedToInventoryEvent implements PluginEvent { private static final Map> HANDLERS = new HashMap<>(); private final Player player; private final Item item; public ItemAddedToInventoryEvent(Player player, Item item) { this.player = player; this.item = item; } public Player getPlayer() { return player; } public Item getItem() { return item; } public void cancel() { item.setId(-1); } @Override public PluginHandler getMethod() { PluginHandler method = HANDLERS.get(item.getId()); if (method == null) method = HANDLERS.get(item.getDefinitions().getName()); if (method == null) return null; return method; } public static void registerMethod(Class eventType, PluginHandler method) { for (Object key : method.keys()) { PluginHandler old = HANDLERS.put(key, method); if (old != null) System.err.println(""ERROR: Duplicate ItemAddedToInventory methods for key: "" + key + "":""); } } public Player component1() { return player; } public Item component2() { return item; } }" "package com.rs.plugin.events; public class ItemClickEvent implements PluginEvent { private static final Map HANDLERS = new HashMap<>(); private final Player player; private final Item item; private final String option; private final boolean isEquipped; private final int slotId; public ItemClickEvent(Player player, Item item, int slotId, String option) { this(player, item, slotId, option, false); } public ItemClickEvent(Player player, Item item, int slotId, String option, boolean isEquipped) { this.player = player; this.item = item.setSlot(slotId); this.option = option; this.isEquipped = isEquipped; this.slotId = slotId; } public boolean isEquipped() { return isEquipped; } public String getOption() { return option; } public Player getPlayer() { return player; } public Item getItem() { return item; } public int getSlotId() { return slotId; } @Override public PluginHandler getMethod() { ItemClickHandler method = HANDLERS.get(item.getId()); if (method == null || !method.containsOption(option)) method = HANDLERS.get(item.getDefinitions().getName()); if (method == null || !method.containsOption(option)) method = HANDLERS.get(option); if (method == null) return null; return method; } public static void registerMethod(Class eventType, PluginHandler method) { for (Object key : method.keys()) { PluginHandler old = HANDLERS.put(key, (ItemClickHandler) method); if (old != null) System.err.println(""ERROR: Duplicate ItemClick methods for key: "" + key); } } public Player component1() { return player; } public Item component2() { return item; } public String component3() { return option; } public boolean component4() { return isEquipped; } }" "package com.rs.plugin.events; public class ItemEquipEvent implements PluginEvent { private static final Map> HANDLERS = new HashMap<>(); private final Player player; private final Item item; private final boolean equipping; private boolean cancelled = false; public ItemEquipEvent(Player player, Item item, boolean equipping) { this.player = player; this.item = item; this.equipping = equipping; } public Player getPlayer() { return player; } public Item getItem() { return item; } public void cancel() { cancelled = true; } public boolean equip() { return equipping; } public boolean dequip() { return !equipping; } @Override public PluginHandler getMethod() { PluginHandler method = HANDLERS.get(item.getId()); if (method == null) method = HANDLERS.get(item.getDefinitions().getName()); if (method == null) return null; return method; } public static void registerMethod(Class eventType, PluginHandler method) { for (Object key : method.keys()) { PluginHandler old = HANDLERS.put(key, method); if (old != null) System.err.println(""ERROR: Duplicate ItemEquip methods for key: "" + key); } } public boolean isCancelled() { return cancelled; } }" "package com.rs.plugin.events; public class ItemOnItemEvent implements PluginEvent { private static final Map> HANDLERS = new HashMap<>(); private final Player player; private final Item item1; private final Item item2; public ItemOnItemEvent(Player player, Item item1, Item item2) { this.player = player; this.item1 = item1; this.item2 = item2; } public boolean usedWith(int item1, int item2) { return (this.item1.getId() == item1 && this.item2.getId() == item2) || (this.item1.getId() == item2 && this.item2.getId() == item1); } public Item getUsedWith(int used) { if (item1.getId() == used) return item2; if (item2.getId() == used) return item1; return null; } public Item getUsedWith(int... used) { for (int use : used) { if (item1.getId() == use) return item2; if (item2.getId() == use) return item1; } return null; } public Item getItem2() { return item2; } public Item getItem1() { return item1; } public Player getPlayer() { return player; } @Override public PluginHandler getMethod() { int hash1 = (item1.getId() << 16) + item2.getId(); int hash2 = (item2.getId() << 16) + item1.getId(); PluginHandler method = HANDLERS.get(hash1); if (method == null) method = HANDLERS.get(hash2); if (method == null) method = HANDLERS.get(-item1.getId()); if (method == null) method = HANDLERS.get(-item2.getId()); if (method == null) return null; return method; } public static void registerMethod(Class eventType, PluginHandler method) { for (Object key : method.keys()) { PluginHandler old = HANDLERS.put(key, method); if (old != null) { int item1 = Utils.interfaceIdFromHash((int) key); int item2 = Utils.componentIdFromHash((int) key); System.err.println(""ERROR: Duplicate ItemOnItem methods for key: "" + key + ""("" + item1 + "", "" + item2 + "") "" + method); } } } }" "package com.rs.plugin.events; public class ItemOnNPCEvent implements PluginEvent { private static final Map HANDLERS = new HashMap<>(); private final Player player; private final NPC npc; private final Item item; private final boolean atNPC; public ItemOnNPCEvent(Player player, NPC npc, Item item, boolean atNPC) { this.player = player; this.npc = npc; this.item = item; this.atNPC = atNPC; } public Player getPlayer() { return player; } public NPC getNPC() { return npc; } public Item getItem() { return item; } public boolean isAtNPC() { return atNPC; } @Override public PluginHandler getMethod() { ItemOnNPCHandler method = HANDLERS.get(getNPC().getId()); if (method == null) method = HANDLERS.get(getNPC().getDefinitions().getName(getPlayer().getVars())); if ((method == null) || (!isAtNPC() && method.isCheckDistance())) return null; return method; } public static void registerMethod(Class eventType, PluginHandler method) { for (Object key : method.keys()) { PluginHandler old = HANDLERS.put(key, (ItemOnNPCHandler) method); if (old != null) System.err.println(""ERROR: Duplicate ItemOnNPC methods for key: "" + key); } } }" "package com.rs.plugin.events; public class ItemOnObjectEvent implements PluginEvent { private static final Map>>> OBJECT_HANDLERS = new HashMap<>(); private static final Map>> ITEM_HANDLERS = new HashMap<>(); private final Player player; private final Item item; private final GameObject object; private final boolean atObject; private final int objectId; public ItemOnObjectEvent(Player player, Item item, GameObject object, boolean atObject) { this.player = player; this.item = item; this.object = object; this.atObject = atObject; objectId = object.getId(); } public Player getPlayer() { return player; } public Item getItem() { return item; } public GameObject getObject() { return object; } public boolean isAtObject() { return atObject; } public int getObjectId() { return objectId; } @Override public List> getMethods() { List> valids = new ArrayList<>(); Map> tileMaps = null; Map>> itemMappings = OBJECT_HANDLERS.get(object.getId()); if (itemMappings == null) itemMappings = OBJECT_HANDLERS.get(object.getDefinitions(player).getName()); if (itemMappings != null) { if (tileMaps == null) tileMaps = itemMappings.get(item.getDefinitions().getName()); if (tileMaps == null) tileMaps = itemMappings.get(item.getId()); if (tileMaps == null) tileMaps = itemMappings.get(-1); } else { if (tileMaps == null) tileMaps = ITEM_HANDLERS.get(item.getDefinitions().getName()); if (tileMaps == null) tileMaps = ITEM_HANDLERS.get(item.getId()); } if (tileMaps == null) return null; List methods = tileMaps.get(getObject().getTile().getTileHash()); if (methods == null) methods = tileMaps.get(-getObject().getType().id); if (methods == null) methods = tileMaps.get(0); for (ItemOnObjectHandler method : methods) { if (!isAtObject() && method.isCheckDistance()) continue; valids.add(method); } return valids; } public static void registerMethod(Class eventType, PluginHandler method) { ItemOnObjectHandler handler = (ItemOnObjectHandler) method; if (handler.getObjectKeys() != null) { for (Object objectKey : handler.getObjectKeys()) { Map>> itemMap = OBJECT_HANDLERS.computeIfAbsent(objectKey, k -> new HashMap<>()); if (handler.getItemKeys() != null) { for (Object itemKey : handler.getItemKeys()) updateLocationMap(handler, itemMap.computeIfAbsent(itemKey, k -> new HashMap<>())); } else updateLocationMap(handler, itemMap.computeIfAbsent(-1, k -> new HashMap<>())); } } else { for (Object itemKey : handler.getItemKeys()) updateLocationMap(handler, ITEM_HANDLERS.computeIfAbsent(itemKey, k -> new HashMap<>())); } } private static void updateLocationMap(ItemOnObjectHandler handler, Map> locMap) { if (handler.getTiles() == null || handler.getTiles().length <= 0) { List methods = locMap.computeIfAbsent(0, k -> new ArrayList<>()); methods.add(handler); } else { for (Tile tile : handler.getTiles()) { List methods = locMap.computeIfAbsent(tile.getTileHash(), k -> new ArrayList<>()); methods.add(handler); } } } }" "package com.rs.plugin.events; public class ItemOnPlayerEvent implements PluginEvent { private static final Map HANDLERS = new HashMap<>(); private final Player player; private final Player otherPlayer; private final Item item; private final boolean atPlayer; public ItemOnPlayerEvent(Player player, Player otherPlayer, Item item, boolean atPlayer) { this.player = player; this.otherPlayer = otherPlayer; this.item = item; this.atPlayer = atPlayer; } public Player getPlayer() { return player; } public Player getTarget() { return otherPlayer; } public Item getItem() { return item; } public boolean isAtPlayer() { return atPlayer; } @Override public PluginHandler getMethod() { ItemOnPlayerHandler method = HANDLERS.get(item.getId()); if (method == null) method = HANDLERS.get(item.getDefinitions().getName()); if ((method == null) || (!isAtPlayer() && method.isCheckDistance())) return null; return method; } public static void registerMethod(Class eventType, PluginHandler method) { for (Object key : method.keys()) { ItemOnPlayerHandler old = HANDLERS.put(key, (ItemOnPlayerHandler) method); if (old != null) System.err.println(""ERROR: Duplicate ItemOnPlayer methods for key: "" + key); } } }" "package com.rs.plugin.events; public class LoginEvent implements PluginEvent { private static final List> HANDLERS = new ArrayList<>(); private final Player player; public LoginEvent(Player player) { this.player = player; } public Player getPlayer() { return player; } @Override public List> getMethods() { return HANDLERS; } public static void registerMethod(Class eventType, PluginHandler method) { HANDLERS.add(method); } public Player component1() { return player; } }" "package com.rs.plugin.events; public class NPCClickEvent implements PluginEvent { private static final Map> HANDLERS = new HashMap<>(); private final Player player; private final NPC npc; private final int opNum; private final String option; private final boolean atNPC; public NPCClickEvent(Player player, NPC npc, int opNum, boolean atNPC) { this.player = player; this.npc = npc; this.opNum = opNum; this.atNPC = atNPC; option = npc.getDefinitions(player).getOption(opNum-1); } public Player getPlayer() { return player; } public NPC getNPC() { return npc; } public int getNPCId() { return npc.getId(); } public String getOption() { return option; } public int getOpNum() { return opNum; } public boolean isAtNPC() { return atNPC; } @Override public PluginHandler getMethod() { Map options = HANDLERS.get(getNPC().getId()); if (options == null) options = HANDLERS.get(getNPC().getDefinitions().getName(getPlayer().getVars())); if (options == null) { options = HANDLERS.get(getOption()); if (options != null) { NPCClickHandler globalOption = options.get(""global""); if (globalOption == null) throw new RuntimeException(""No global NPCClick method for option: "" + getOption()); if (!isAtNPC() && globalOption.isCheckDistance()) return null; return globalOption; } } if (options == null) return null; NPCClickHandler method = options.get(getOption()); if (method == null) method = options.get(""global""); if (method == null) { options = HANDLERS.get(getOption()); if (options != null) { NPCClickHandler globalOption = options.get(""global""); method = globalOption; } } if ((method == null) || (!isAtNPC() && method.isCheckDistance())) return null; return method; } public static void registerMethod(Class eventType, PluginHandler method) { NPCClickHandler handler = (NPCClickHandler) method; if (handler.getOptions() == null || handler.getOptions().isEmpty()) { for (Object key : handler.keys()) { Map map = HANDLERS.get(key); if (map == null) map = new HashMap<>(); NPCClickHandler old = map.put(""global"", handler); HANDLERS.put(key, map); if (old != null) System.err.println(""ERROR: Duplicate global NPCClick methods for key: "" + key); } } else { for (String option : handler.getOptions()) { if (handler.keys() == null || handler.keys().length == 0 || handler.keys()[0] == null) { Map map = HANDLERS.get(option); if (map == null) map = new HashMap<>(); NPCClickHandler old = map.put(""global"", handler); HANDLERS.put(option, map); if (old != null) System.err.println(""ERROR: Duplicate global NPCClick option methods for key: "" + option); } else { for (Object key : handler.keys()) { Map map = HANDLERS.get(key); if (map == null) map = new HashMap<>(); NPCClickHandler old = map.put(option, handler); HANDLERS.put(key, map); if (old != null) System.err.println(""ERROR: Duplicate NPCClick option methods for key: "" + key + "" option: "" + option + "" method: "" + method); } } } } } public Player component1() { return player; } public NPC component2() { return npc; } public String component3() { return option; } }" "package com.rs.plugin.events; public class NPCDeathEvent implements PluginEvent { private static final Map> HANDLERS = new HashMap<>(); private final NPC npc; private final Entity killer; public NPCDeathEvent(NPC npc, Entity killer) { this.npc = npc; this.killer = killer; } public NPC getNPC() { return npc; } public Entity getKiller() { return killer; } public boolean killedByPlayer() { if (killer != null && (killer instanceof Player)) return true; return false; } @Override public PluginHandler getMethod() { PluginHandler method = HANDLERS.get(npc.getId()); if (method == null) method = HANDLERS.get(npc.getDefinitions().getName()); if (method == null) return null; return method; } public static void registerMethod(Class eventType, PluginHandler method) { for (Object key : method.keys()) { PluginHandler old = HANDLERS.put(key, method); if (old != null) System.err.println(""ERROR: Duplicate NPCDeath methods for key: "" + key); } } }" "package com.rs.plugin.events; public class NPCDropEvent implements PluginEvent { private static final Map> NPC_HANDLERS = new HashMap<>(); private static final Map ITEM_HANDLERS = new HashMap<>(); private final Player player; private final NPC npc; private final Item item; public NPCDropEvent(Player player, NPC npc, Item item) { this.player = player; this.npc = npc; this.item = item; } public Player getPlayer() { return player; } public Item getItem() { return item; } public NPC getNPC() { return npc; } public void deleteItem() { item.setId(-1); } @Override public PluginHandler getMethod() { NPCDropHandler method = null; Map itemFromNPCHandlers = NPC_HANDLERS.get(npc.getDefinitions(player).getName()); if (itemFromNPCHandlers == null) itemFromNPCHandlers = NPC_HANDLERS.get(npc.getId()); if (itemFromNPCHandlers != null) { if (method == null) method = itemFromNPCHandlers.get(item.getDefinitions().getName()); if (method == null) method = itemFromNPCHandlers.get(item.getId()); if (method == null) method = itemFromNPCHandlers.get(-1); } else { if (method == null) method = ITEM_HANDLERS.get(item.getDefinitions().getName()); if (method == null) method = ITEM_HANDLERS.get(item.getId()); } if (method == null) return null; return method; } public static void registerMethod(Class eventType, PluginHandler method) { NPCDropHandler handler = (NPCDropHandler) method; if (handler.getNpcKeys() != null) { for (Object npcKey : handler.getNpcKeys()) { Map map = NPC_HANDLERS.get(npcKey); if (map == null) map = new HashMap<>(); if (handler.getItemKeys() != null) { for (Object itemKey : handler.getItemKeys()) if (map.put(itemKey, handler) != null) System.err.println(""ERROR: Duplicate NPCDrop methods for npc key: "" + npcKey + "" and item key: "" + itemKey); } else map.put(-1, handler); if (NPC_HANDLERS.put(npcKey, map) != null) System.err.println(""ERROR: Duplicate NPCDrop methods for npc key: "" + npcKey); } } else { for (Object key : handler.getItemKeys()) { PluginHandler old = ITEM_HANDLERS.put(key, handler); if (old != null) System.err.println(""ERROR: Duplicate NPCDrop methods for item key: "" + key); } } } }" "package com.rs.plugin.events; public class NPCInstanceEvent implements PluginEvent { private static final Map HANDLERS = new HashMap<>(); private final int npcId; private final Tile tile; private final boolean spawned; public NPCInstanceEvent(int npcId, Tile tile, boolean spawned) { this.npcId = npcId; this.tile = tile; this.spawned = spawned; } public int getNpcId() { return npcId; } public Tile getTile() { return tile; } public boolean isSpawned() { return spawned; } @Override public PluginHandler getMethod() { NPCInstanceHandler method = HANDLERS.get(npcId); if (method == null) method = HANDLERS.get(NPCDefinitions.getDefs(npcId).getName()); if (method == null) return null; return method; } public static void registerMethod(Class eventType, PluginHandler method) { for (Object key : method.keys()) { PluginHandler old = HANDLERS.put(key, (NPCInstanceHandler) method); if (old != null) System.err.println(""ERROR: Duplicate NPC instance methods for key: "" + key); } } }" "package com.rs.plugin.events; public class NPCInteractionDistanceEvent implements PluginEvent { private static final Map HANDLERS = new HashMap<>(); private final Player player; private final NPC npc; public NPCInteractionDistanceEvent(Player player, NPC npc) { this.player = player; this.npc = npc; } public Player getPlayer() { return player; } public NPC getNpc() { return npc; } @Override public PluginHandler getMethod() { NPCInteractionDistanceHandler method = HANDLERS.get(npc.getId()); if (method == null) method = HANDLERS.get(npc.getDefinitions().getName(player.getVars())); if (method == null) return null; return method; } public static void registerMethod(Class eventType, PluginHandler method) { for (Object key : method.keys()) { PluginHandler old = HANDLERS.put(key, (NPCInteractionDistanceHandler) method); if (old != null) System.err.println(""ERROR: Duplicate ItemOnNPC methods for key: "" + key); } } }" "package com.rs.plugin.events; public class ObjectClickEvent implements PluginEvent { private static final Map>> METHODS = new HashMap<>(); private final Player player; private final GameObject object; private final ClientPacket opNum; private final String option; private final boolean atObject; private final int objectId; public ObjectClickEvent(Player player, GameObject object, ClientPacket opNum, boolean atObject) { this.player = player; this.object = object; this.opNum = opNum; this.atObject = atObject; objectId = object.getId(); option = object.getDefinitions(player).getOption(opNum); } public String getOption() { return option; } public Player getPlayer() { return player; } public GameObject getObject() { return object; } public ClientPacket getOpNum() { return opNum; } public boolean isAtObject() { return atObject; } public int getObjectId() { return objectId; } public boolean objectAt(int x, int y) { return object.getTile().isAt(x, y); } public boolean objectAt(int x, int y, int plane) { return object.getTile().isAt(x, y, plane); } @Override public List> getMethods() { List> valids = new ArrayList<>(); Map> methodMapping = METHODS.get(getObjectId()); if (methodMapping == null) methodMapping = METHODS.get(getObject().getDefinitions(getPlayer()).getName()); if (methodMapping == null) return null; List methods = methodMapping.get(getObject().getTile().getTileHash()); if (methods == null) methods = methodMapping.get(-getObject().getType().id); if (methods == null) methods = methodMapping.get(0); if (methods == null) return null; for (ObjectClickHandler method : methods) { if (!isAtObject() && method.isCheckDistance()) continue; valids.add(method); } return valids; } public static void registerMethod(Class eventType, PluginHandler method) { ObjectClickHandler handler = (ObjectClickHandler) method; for (Object key : handler.keys()) { Map> locMap = METHODS.computeIfAbsent(key, k -> new HashMap<>()); if (handler.getType() == null && (handler.getTiles() == null || handler.getTiles().length <= 0)) { List methods = locMap.get(0); if (methods == null) methods = new ArrayList<>(); methods.add(handler); locMap.put(0, methods); } else if (handler.getType() != null) { List methods = locMap.get(-handler.getType().id); if (methods == null) methods = new ArrayList<>(); methods.add(handler); locMap.put(-handler.getType().id, methods); } else for (Tile tile : handler.getTiles()) { List methods = locMap.get(tile.getTileHash()); if (methods == null) methods = new ArrayList<>(); methods.add(handler); locMap.put(tile.getTileHash(), methods); } } } public Player component1() { return player; } public GameObject component2() { return object; } public String component3() { return option; } }" "package com.rs.plugin.events; public class PickupItemEvent implements PluginEvent { private static final Map>> HANDLERS = new HashMap<>(); private final Player player; private final GroundItem item; private boolean cancelPickup; private final boolean telegrabbed; public PickupItemEvent(Player player, GroundItem item, boolean telegrabbed) { this.player = player; this.item = item; this.telegrabbed = telegrabbed; } public Player getPlayer() { return player; } public GroundItem getItem() { return item; } public boolean isTelegrabbed() { return telegrabbed; } @Override public List> getMethods() { List> valids = new ArrayList<>(); Map> methodMapping = HANDLERS.get(getItem().getId()); if (methodMapping == null) methodMapping = HANDLERS.get(getItem().getName()); if (methodMapping == null) return null; List methods = methodMapping.get(getItem().getTile().getTileHash()); if (methods == null) methods = methodMapping.get(-getItem().getId()); if (methods == null) methods = methodMapping.get(0); if (methods == null) return null; valids.addAll(methods); return valids; } public static void registerMethod(Class eventType, PluginHandler method) { PickupItemHandler handler = (PickupItemHandler) method; for (Object key : handler.keys()) { Map> locMap = HANDLERS.computeIfAbsent(key, k -> new HashMap<>()); if (handler.getTiles() == null || handler.getTiles().length <= 0) { List methods = locMap.get(0); if (methods == null) methods = new ArrayList<>(); methods.add(handler); locMap.put(0, methods); } else for (Tile tile : handler.getTiles()) { List methods = locMap.get(tile.getTileHash()); if (methods == null) methods = new ArrayList<>(); methods.add(handler); locMap.put(tile.getTileHash(), methods); } } } public boolean isCancelPickup() { return cancelPickup; } public void cancelPickup() { this.cancelPickup = true; } }" "package com.rs.plugin.events; public class PlayerClickEvent implements PluginEvent { private static final Map HANDLERS = new HashMap<>(); private final Player player; private final Player otherPlayer; private final String option; private final boolean atPlayer; public PlayerClickEvent(Player player, Player otherPlayer, String option, boolean atPlayer) { this.player = player; this.otherPlayer = otherPlayer; this.option = option; this.atPlayer = atPlayer; } public Player getPlayer() { return player; } public Player getTarget() { return otherPlayer; } public String getOption() { return option; } public boolean isAtPlayer() { return atPlayer; } @Override public PluginHandler getMethod() { PlayerClickHandler method = HANDLERS.get(option); if ((method == null) || (!isAtPlayer() && method.isCheckDistance())) return null; return method; } public static void registerMethod(Class eventType, PluginHandler method) { for (Object key : method.keys()) { PluginHandler old = HANDLERS.put(key, (PlayerClickHandler) method); if (old != null) System.err.println(""ERROR: Duplicate NPCClick methods for key: "" + key); } } public Player component1() { return player; } public Player component2() { return otherPlayer; } public String component3() { return option; } }" "package com.rs.plugin.events; public class PlayerStepEvent implements PluginEvent { private static final Map METHODS = new HashMap<>(); private final Player player; private final Tile tile; private final WalkStep step; public PlayerStepEvent(Player player, WalkStep step, Tile tile) { this.player = player; this.tile = tile; this.step = step; } public Player getPlayer() { return player; } public Tile getTile() { return tile; } public WalkStep getStep() { return step; } @Override public PluginHandler getMethod() { return METHODS.get(tile.getTileHash()); } public static void registerMethod(Class eventType, PluginHandler method) { PlayerStepHandler handler = (PlayerStepHandler) method; for (Object key : handler.keys()) if (METHODS.put(key, handler) != null) System.err.println(""Duplicate player step events for key "" + key); } }" "package com.rs.plugin.events; public interface PluginEvent { public default PluginHandler getMethod() { return null; } public default List> getMethods() { return null; } }" "package com.rs.plugin.events; public class XPGainEvent implements PluginEvent { private static final List> HANDLERS = new ArrayList<>(); private final Player player; private final int skillId; private final double xp; private double multiplier = 1.0; public XPGainEvent(Player player, int skillId, double xp) { this.player = player; this.skillId = skillId; this.xp = xp; } public Player getPlayer() { return player; } public int getSkillId() { return skillId; } public double getXp() { return xp; } public double getMultiplier() { return multiplier; } public void setMultiplier(double multiplier) { this.multiplier = multiplier; } @Override public List> getMethods() { return HANDLERS; } public static void registerMethod(Class eventType, PluginHandler method) { HANDLERS.add(method); } }" "package com.rs.plugin.handlers; public class ButtonClickHandler extends PluginHandler { public ButtonClickHandler(Object[] interfaceIds, Consumer handler) { super(interfaceIds, handler); } public ButtonClickHandler(Object interfaceId, Consumer handler) { super(new Object[] { interfaceId }, handler); } }" "package com.rs.plugin.handlers; public class DestroyItemHandler extends PluginHandler { public DestroyItemHandler(Object[] namesOrIds, Consumer handler) { super(namesOrIds, handler); } }" "package com.rs.plugin.handlers; public class DropItemHandler extends PluginHandler { public DropItemHandler(Object[] namesOrIds, Consumer handler) { super(namesOrIds, handler); } }" "package com.rs.plugin.handlers; public class EnterChunkHandler extends PluginHandler { public EnterChunkHandler(Consumer handler) { super(new Object[] { ""meme"" }, handler); } }" "package com.rs.plugin.handlers; public class InterfaceOnInterfaceHandler extends PluginHandler { private final boolean bidirectional; private final Object[] fromKeys; private final Object[] toKeys; public InterfaceOnInterfaceHandler(boolean bidirectional, int[] fromInterfaceIds, int[] fromComponentIds, int[] toInterfaceIds, int[] toComponentIds, Consumer handler) { super(new Object[] { ""meme"" }, handler); this.bidirectional = bidirectional; List fromList = new ArrayList<>(); if (fromComponentIds == null || fromComponentIds.length <= 0) for (Integer id : fromInterfaceIds) else for (int id : fromInterfaceIds) for (int comp : fromComponentIds) List toList = new ArrayList<>(); if (toComponentIds == null || toComponentIds.length <= 0) for (Integer id : toInterfaceIds) toList.add(id); else for (int id : toInterfaceIds) for (int comp : toComponentIds) toList.add((id << 16) + comp); toKeys = toList.toArray(); } public InterfaceOnInterfaceHandler(int[] fromInterfaceIds, int[] fromComponentIds, int[] toInterfaceIds, int[] toComponentIds, Consumer handler) { this(false, fromInterfaceIds, fromComponentIds, toInterfaceIds, toComponentIds, handler); } public InterfaceOnInterfaceHandler(boolean bidirectional, int fromInterfaceId, int[] fromComponentIds, int toInterfaceId, int[] toComponentIds, Consumer handler) { this(bidirectional, new int[] {fromInterfaceId}, fromComponentIds, new int[] {toInterfaceId}, toComponentIds, handler); } public InterfaceOnInterfaceHandler(boolean bidirectional, int fromInterfaceId, int fromComponentId, int toInterfaceId, int toComponentId, Consumer handler) { this(bidirectional, fromInterfaceId, new int[] { fromComponentId }, toInterfaceId, new int[] {toComponentId}, handler); } public InterfaceOnInterfaceHandler(boolean bidirectional, int fromInterfaceId, int toInterfaceId, Consumer handler) { this(bidirectional, fromInterfaceId, null, toInterfaceId, null, handler); } public InterfaceOnInterfaceHandler(int fromInterfaceId, int[] fromComponentIds, int toInterfaceId, int[] toComponentIds, Consumer handler) { this(false, new int[] {fromInterfaceId}, fromComponentIds, new int[] {toInterfaceId}, toComponentIds, handler); } public InterfaceOnInterfaceHandler(int fromInterfaceId, int fromComponentId, int toInterfaceId, int toComponentId, Consumer handler) { this(false, fromInterfaceId, new int[] { fromComponentId }, toInterfaceId, new int[] {toComponentId}, handler); } public InterfaceOnInterfaceHandler(int fromInterfaceId, int toInterfaceId, Consumer handler) { this(false, fromInterfaceId, null, toInterfaceId, null, handler); } public Object[] getFromKeys() { return fromKeys; } public Object[] getToKeys() { return toKeys; } public boolean isBidirectional() { return bidirectional; } }" "package com.rs.plugin.handlers; public class InterfaceOnNPCHandler extends PluginHandler { private boolean checkDistance = true; public InterfaceOnNPCHandler(boolean checkDistance, int[] interfaceIds, int[] componentIds, Consumer handler) { super(null, handler); this.checkDistance = checkDistance; List list = new ArrayList<>(); if (componentIds == null || componentIds.length <= 0) for (Integer id : interfaceIds) list.add(id); else for (int id : interfaceIds) for (int comp : componentIds) list.add((id << 16) + comp); keys = list.toArray(); } public InterfaceOnNPCHandler(boolean checkDistance, int[] interfaceIds, Consumer handler) { this(checkDistance, interfaceIds, null, handler); } public InterfaceOnNPCHandler(int[] interfaceIds, int[] componentIds, Consumer handler) { this(true, interfaceIds, componentIds, handler); } public InterfaceOnNPCHandler(int[] interfaceIds, Consumer handler) { this(true, interfaceIds, null, handler); } public boolean isCheckDistance() { return checkDistance; } }" "package com.rs.plugin.handlers; public class InterfaceOnObjectHandler extends PluginHandler { private boolean checkDistance = true; public InterfaceOnObjectHandler(boolean checkDistance, int[] interfaceIds, int[] componentIds, Consumer handler) { super(null, handler); this.checkDistance = checkDistance; List list = new ArrayList<>(); if (componentIds.length <= 0) for (Integer id : interfaceIds) list.add(id); else for (int id : interfaceIds) for (int comp : componentIds) list.add((id << 16) + comp); keys = list.toArray(); } public InterfaceOnObjectHandler(int[] interfaceIds, int[] componentIds, Consumer handler) { this(true, interfaceIds, componentIds, handler); } public boolean isCheckDistance() { return checkDistance; } }" "package com.rs.plugin.handlers; public class InterfaceOnPlayerHandler extends PluginHandler { private boolean checkDistance = true; public InterfaceOnPlayerHandler(boolean checkDistance, int[] interfaceIds, int[] componentIds, Consumer handler) { super(null, handler); this.checkDistance = checkDistance; List list = new ArrayList<>(); if (componentIds == null || componentIds.length <= 0) for (Integer id : interfaceIds) list.add(id); else for (int id : interfaceIds) for (int comp : componentIds) list.add((id << 16) + comp); keys = list.toArray(); } public InterfaceOnPlayerHandler(boolean checkDistance, int[] interfaceIds, Consumer handler) { this(checkDistance, interfaceIds, null, handler); } public InterfaceOnPlayerHandler(int[] interfaceIds, int[] componentIds, Consumer handler) { this(true, interfaceIds, componentIds, handler); } public InterfaceOnPlayerHandler(int[] interfaceIds, Consumer handler) { this(true, interfaceIds, null, handler); } public boolean isCheckDistance() { return checkDistance; } }" "package com.rs.plugin.handlers; public class ItemAddedToBankHandler extends PluginHandler { public ItemAddedToBankHandler(Object[] namesOrIds, Consumer handler) { super(namesOrIds, handler); } public ItemAddedToBankHandler(int id, Consumer handler) { this(new Object[] { id }, handler); } public ItemAddedToBankHandler(String name, Consumer handler) { this(new Object[] { name }, handler); } }" "package com.rs.plugin.handlers; public class ItemAddedToInventoryHandler extends PluginHandler { public ItemAddedToInventoryHandler(Object[] namesOrIds, Consumer handler) { super(namesOrIds, handler); } public ItemAddedToInventoryHandler(int id, Consumer handler) { this(new Object[] { id }, handler); } public ItemAddedToInventoryHandler(String name, Consumer handler) { this(new Object[] { name }, handler); } }" "package com.rs.plugin.handlers; public class ItemClickHandler extends PluginHandler { private Set options; public ItemClickHandler(Object[] namesOrIds, Consumer handler) { super(namesOrIds, handler); } public ItemClickHandler(Object[] namesOrIds, String[] options, Consumer handler) { super(namesOrIds, handler); this.options = new HashSet<>(Arrays.asList(options)); } public ItemClickHandler(String[] options, Consumer handler) { super(null, handler); this.options = new HashSet<>(Arrays.asList(options)); } public boolean containsOption(String option) { return (options == null || options.size() == 0) ? true : options.contains(option); } @Override public Object[] keys() { return (keys == null || keys.length <= 0) ? options.toArray() : keys; } }" "package com.rs.plugin.handlers; public class ItemEquipHandler extends PluginHandler { public ItemEquipHandler(Object[] namesOrIds, Consumer handler) { super(namesOrIds, handler); } public ItemEquipHandler(int id, Consumer handler) { this(new Object[] { id }, handler); } public ItemEquipHandler(String name, Consumer handler) { this(new Object[] { name }, handler); } }" "package com.rs.plugin.handlers; public class ItemOnItemHandler extends PluginHandler { public ItemOnItemHandler(int[] itemsUsed, int[] usedWiths, Consumer handler) { super(null, handler); Set list = new HashSet<>(); if (usedWiths.length > 0) for (Integer usedWith : usedWiths) for (int used : itemsUsed) { list.add((usedWith << 16) + used); list.add((used << 16) + usedWith); } else for (int used : itemsUsed) list.add(-used); keys = list.toArray(); } public ItemOnItemHandler(int itemUsed, int[] usedWith, Consumer handler) { this(new int[] { itemUsed }, usedWith, handler); } public ItemOnItemHandler(int[] itemUsed, int usedWith, Consumer handler) { this(itemUsed, new int[] { usedWith }, handler); } public ItemOnItemHandler(int used, int usedWith, Consumer handler) { this(new int[] { used }, new int[] { usedWith }, handler); } public ItemOnItemHandler(int[] used, Consumer handler) { this(used, new int[] { }, handler); } public ItemOnItemHandler(int used, Consumer handler) { this(new int[] { used }, new int[] { }, handler); } public ItemOnItemHandler(boolean directKeySet, Object[] keys, Consumer handler) { super(keys, handler); } }" "package com.rs.plugin.handlers; public class ItemOnNPCHandler extends PluginHandler { private boolean checkDistance = true; public ItemOnNPCHandler(boolean checkDistance, Object[] namesOrIds, Consumer handler) { super(namesOrIds, handler); this.checkDistance = checkDistance; } public ItemOnNPCHandler(int id, Consumer handler) { super(new Object[] { id }, handler); } public ItemOnNPCHandler(String name, Consumer handler) { super(new Object[] { name }, handler); } public ItemOnNPCHandler(Object[] namesOrIds, Consumer handler) { super(namesOrIds, handler); } public boolean isCheckDistance() { return checkDistance; } }" "package com.rs.plugin.handlers; public class ItemOnObjectHandler extends PluginHandler { private final Object[] objectKeys; private final Object[] itemKeys; private final Tile[] tiles; private boolean checkDistance = true; public ItemOnObjectHandler(boolean checkDistance, Object[] objectNamesOrIds, Object[] itemNamesOrIds, Tile[] tiles, Consumer handler) { super(new Object[] { ""meme"" }, handler); this.tiles = tiles; this.checkDistance = checkDistance; this.objectKeys = objectNamesOrIds; this.itemKeys = itemNamesOrIds; } public ItemOnObjectHandler(Object[] objectNamesOrIds, Object[] itemNamesOrIds, Tile[] tiles, Consumer handler) { this(true, objectNamesOrIds, itemNamesOrIds, tiles, handler); } public ItemOnObjectHandler(boolean checkDistance, Object[] objectNamesOrIds, Object[] itemNamesOrIds, Consumer handler) { this(true, objectNamesOrIds, itemNamesOrIds, null, handler); this.checkDistance = checkDistance; } public ItemOnObjectHandler(Object[] objectNamesOrIds, Object[] itemNamesOrIds, Consumer handler) { this(true, objectNamesOrIds, itemNamesOrIds, null, handler); } public boolean isCheckDistance() { return checkDistance; } public Tile[] getTiles() { return tiles; } public Object[] getObjectKeys() { return objectKeys; } public Object[] getItemKeys() { return itemKeys; } }" "package com.rs.plugin.handlers; public class ItemOnPlayerHandler extends PluginHandler { private boolean checkDistance = true; public ItemOnPlayerHandler(boolean checkDistance, Object[] namesOrIds, Consumer handler) { super(namesOrIds, handler); this.checkDistance = checkDistance; } public ItemOnPlayerHandler(Object[] namesOrIds, Consumer handler) { super(namesOrIds, handler); } public boolean isCheckDistance() { return checkDistance; } }" "package com.rs.plugin.handlers; public class LoginHandler extends PluginHandler { public LoginHandler(Consumer handler) { super(new Object[] { ""meme"" }, handler); } }" "package com.rs.plugin.handlers; public class NPCClickHandler extends PluginHandler { private boolean checkDistance = true; private Set options; public NPCClickHandler(boolean checkDistance, Object[] namesOrIds, String[] options, Consumer handler) { super(namesOrIds == null ? new Object[] { null } : namesOrIds, handler); if (options != null && options.length > 0) this.options = new HashSet<>(Arrays.asList(options)); this.checkDistance = checkDistance; } public NPCClickHandler(Object[] namesOrIds, String[] options, Consumer handler) { this(true, namesOrIds, options, handler); } public NPCClickHandler(boolean checkDistance, Object[] namesOrIds, Consumer handler) { this(checkDistance, namesOrIds, null, handler); } public NPCClickHandler(Object[] namesOrIds, Consumer handler) { this(true, namesOrIds, null, handler); } public boolean isCheckDistance() { return checkDistance; } public Set getOptions() { return options; } public boolean containsOption(String option) { return (options == null || options.size() == 0) ? true : options.contains(option); } }" "package com.rs.plugin.handlers; public class NPCDeathHandler extends PluginHandler { public NPCDeathHandler(Object[] namesOrIds, Consumer handler) { super(namesOrIds, handler); } public NPCDeathHandler(int id, Consumer handler) { super(new Object[] { id }, handler); } public NPCDeathHandler(String name, Consumer handler) { super(new Object[] { name }, handler); } }" "package com.rs.plugin.handlers; public class NPCDropHandler extends PluginHandler { private final Object[] npcKeys; private final Object[] itemKeys; public NPCDropHandler(Object[] npcNamesOrIds, Object[] itemNamesOrIds, Consumer handler) { super(new Object[] { ""meme"" }, handler); this.npcKeys = npcNamesOrIds; this.itemKeys = itemNamesOrIds; } public Object[] getNpcKeys() { return npcKeys; } public Object[] getItemKeys() { return itemKeys; } }" "package com.rs.plugin.handlers; public class NPCInstanceHandler extends PluginHandler { private final BiFunction instantiator; public NPCInstanceHandler(Object[] keys, BiFunction instantiator) { super(keys, null); this.instantiator = instantiator; } public NPCInstanceHandler(int id, BiFunction instantiator) { super(new Object[] { id }, null); this.instantiator = instantiator; } public NPCInstanceHandler(String name, BiFunction instantiator) { super(new Object[] { name }, null); this.instantiator = instantiator; } @Override public final boolean handleGlobal(NPCInstanceEvent e) { return false; } @Override public final Object getObj(NPCInstanceEvent e) { NPC npc = instantiator.apply(e.getNpcId(), e.getTile()); npc.setSpawned(e.isSpawned()); return npc; } }" "package com.rs.plugin.handlers; public class NPCInteractionDistanceHandler extends PluginHandler { private final BiFunction supplier; public NPCInteractionDistanceHandler(Object[] keys, BiFunction supplier) { super(keys, null); this.supplier = supplier; } public NPCInteractionDistanceHandler(int id, BiFunction supplier) { super(new Object[] { id }, null); this.supplier = supplier; } public NPCInteractionDistanceHandler(String name, BiFunction supplier) { super(new Object[] { name }, null); this.supplier = supplier; } @Override public final boolean handleGlobal(NPCInteractionDistanceEvent e) { return false; } @Override public final Object getObj(NPCInteractionDistanceEvent e) { return supplier.apply(e.getPlayer(), e.getNpc()); } }" "package com.rs.plugin.handlers; public class ObjectClickHandler extends PluginHandler { private Tile[] tiles; private ObjectType type; private boolean checkDistance = true; public ObjectClickHandler(boolean checkDistance, Object[] namesOrIds, Tile[] tiles, Consumer handler) { super(namesOrIds, handler); this.tiles = tiles; this.checkDistance = checkDistance; } public ObjectClickHandler(boolean checkDistance, Object[] namesOrIds, Consumer handler) { super(namesOrIds, handler); this.checkDistance = checkDistance; } public ObjectClickHandler(Object[] namesOrIds, Tile[] tiles, Consumer handler) { this(true, namesOrIds, tiles, handler); } public ObjectClickHandler(Object[] namesOrIds, Tile tile, Consumer handler) { this(true, namesOrIds, new Tile[] { tile }, handler); } public ObjectClickHandler(Object[] namesOrIds, ObjectType type, Consumer handler) { this(true, namesOrIds, null, handler); this.type = type; } public ObjectClickHandler(Object[] namesOrIds, Consumer handler) { this(true, namesOrIds, null, handler); } public ObjectType getType() { return type; } public boolean isCheckDistance() { return checkDistance; } public Tile[] getTiles() { return tiles; } }" "package com.rs.plugin.handlers; public class PickupItemHandler extends PluginHandler { private final Tile[] tiles; public PickupItemHandler(Object[] namesOrIds, Tile[] tiles, Consumer handler) { super(namesOrIds, handler); this.tiles = tiles; } public PickupItemHandler(Object[] namesOrIds, Tile tile, Consumer handler) { super(namesOrIds, handler); this.tiles = new Tile[] { tile }; } public PickupItemHandler(int id, Tile[] tiles, Consumer handler) { this(new Object[] { id }, tiles, handler); } public PickupItemHandler(int id, Tile tile, Consumer handler) { this(new Object[] { id }, tile, handler); } public PickupItemHandler(String name, Tile[] tiles, Consumer handler) { this(new Object[] { name }, tiles, handler); } public PickupItemHandler(String name, Tile tile, Consumer handler) { this(new Object[] { name }, tile, handler); } public Tile[] getTiles() { return tiles; } }" "package com.rs.plugin.handlers; public class PlayerClickHandler extends PluginHandler { private boolean checkDistance = true; public PlayerClickHandler(boolean checkDistance, String option, Consumer handler) { super(new Object[] { option }, handler); this.checkDistance = checkDistance; } public boolean isCheckDistance() { return checkDistance; } }" "package com.rs.plugin.handlers; public class PlayerStepHandler extends PluginHandler { public PlayerStepHandler(Tile[] tiles, Consumer handler) { super(null, handler); List tileHashes = new ArrayList<>(); for (Tile tile : tiles) tileHashes.add(tile.getTileHash()); keys = tileHashes.toArray(); } public PlayerStepHandler(Tile tile, Consumer handler) { this(new Tile[] { tile }, handler); } }" "package com.rs.plugin.handlers; public abstract class PluginHandler { protected Object[] keys; protected Consumer handler; public PluginHandler(Object[] keys, Consumer handler) { this.keys = keys; this.handler = handler; } public boolean handleGlobal(T e) { return false; } public Object getObj(T e) { return null; } public Object[] keys() { return keys; } public Consumer getHandler() { return handler; } }" "package com.rs.plugin.handlers; public class XPGainHandler extends PluginHandler { public XPGainHandler(Consumer handler) { super(new Object[] { ""meme"" }, handler); } }" "package com.rs.tools; public class AnimationDumper { public static void main(String[] args) throws IOException { Cache.init(Settings.getConfig().getCachePath()); File file = new File(""animationDump.txt""); if (file.exists()) file.delete(); else file.createNewFile(); File file2 = new File(""unidAnimSkeles.txt""); if (file2.exists()) file2.delete(); else file2.createNewFile(); BufferedWriter writer = new BufferedWriter(new FileWriter(file)); writer.append(""//Version = 727\n""); writer.flush(); BufferedWriter writer2 = new BufferedWriter(new FileWriter(file2)); writer2.append(""//Version = 727\n""); writer2.flush(); Map used = new HashMap<>(); for (int npcId = 0;npcId < Utils.getNPCDefinitionsSize();npcId++) { NPCDefinitions npcDef = NPCDefinitions.getDefs(npcId); if (npcDef.basId != -1) if (BASDefinitions.getDefs(npcDef.basId).standAnimation != -1) if (AnimationDefinitions.getDefs(BASDefinitions.getDefs(npcDef.basId).standAnimation).frameSetIds != null) { int skeleton = AnimationDefinitions.getDefs(BASDefinitions.getDefs(npcDef.basId).standAnimation).frameSetIds[0]; for (int i = 0; i < Utils.getAnimationDefinitionsSize(); i++) { AnimationDefinitions check = AnimationDefinitions.getDefs(i); if ((check == null) || check.frameSetIds == null || check.frameSetIds[0] == -1) continue; if (check.frameSetIds[0] == skeleton) { if (used.get(i) != null) used.put(i, used.get(i) + "", "" + npcId + "" ("" + npcDef.getName() + "")"" ); else used.put(i, ""[""+AnimationDefinitions.getDefs(i).frameSetIds[0] + ""] "" + npcId + "" ("" + npcDef.getName() + "")""); if (skeleton == 2183 || skeleton == 1843) used.put(i, ""[""+AnimationDefinitions.getDefs(i).frameSetIds[0] + ""] Player animation/Humanoid""); } } } } for (int spotAnimId = 0;spotAnimId < Utils.getSpotAnimDefinitionsSize();spotAnimId++) { SpotAnimDefinitions defs = SpotAnimDefinitions.getDefs(spotAnimId); if (defs.animationId != -1) if (used.get(defs.animationId) != null) used.put(defs.animationId, used.get(defs.animationId) + "", SpotAnim: "" + spotAnimId ); else used.put(defs.animationId, ""[""+AnimationDefinitions.getDefs(defs.animationId).frameSetIds[0] + ""] SpotAnim: "" + spotAnimId); } for (int objectId = 0;objectId < Utils.getObjectDefinitionsSize();objectId++) { ObjectDefinitions defs = ObjectDefinitions.getDefs(objectId); if (defs.animations != null) for (int animId : defs.animations) if (used.get(animId) != null) used.put(animId, used.get(animId) + "", Object: "" + objectId ); else used.put(animId, ""[""+AnimationDefinitions.getDefs(animId).frameSetIds[0] + ""] Object: "" + objectId); } Map UNIDS = new HashMap<>(); for (int i = 0; i < Utils.getAnimationDefinitionsSize(); i++) { String name = used.get(i); if (name == null) name = switch (AnimationDefinitions.getDefs(i).frameSetIds[0]) { case 2409, 2410, 2411, 2414, 2417, 2418, 2421, 2429, 2420 -> ""Humanoid chathead""; case 3102 -> ""Troll/Tzhaar chathead""; case 1815 -> ""Child chathead""; case 1981 -> ""Werewolf/Cat chathead""; case 1459 -> ""Penguin chathead""; case 81, 83 -> ""Old NPC chathead""; default -> { UNIDS.put(AnimationDefinitions.getDefs(i).frameSetIds[0], i); yield ""["" + AnimationDefinitions.getDefs(i).frameSetIds[0] + ""] Unknown""; } }; writer.append(String.valueOf(i)).append("": "").append(name); writer.newLine(); writer.flush(); } List keys = new ArrayList<>(UNIDS.keySet()); Collections.sort(keys); for (int skele : keys) { writer2.append(String.valueOf(UNIDS.get(skele))).append("",""); writer2.newLine(); writer2.flush(); } writer.close(); writer2.close(); } }" "package com.rs.tools; public class BankSpaceIncreaser { public static void main(String[] args) throws IOException { JsonFileManager.setGSON(new GsonBuilder() .registerTypeAdapter(Controller.class, new ControllerAdapter()) .registerTypeAdapter(Date.class, new DateAdapter()) .registerTypeAdapter(PacketEncoder.class, new PacketEncoderAdapter()) .registerTypeAdapter(Packet.class, new PacketAdapter()) .registerTypeAdapterFactory(new RecordTypeAdapterFactory()) .disableHtmlEscaping() .setPrettyPrinting() .create()); Settings.loadConfig(); Cache.init(Settings.getConfig().getCachePath()); final int MAX_SIZE = Bank.MAX_BANK_SIZE; final int MEMS_SIZE = MAX_SIZE-87; InventoryDefinitions def = InventoryDefinitions.getContainer(95); int old = def.maxSize; def.maxSize = MAX_SIZE; def.write(Cache.STORE); System.out.println(""Replaced container max size from "" + old + "" to "" + MAX_SIZE); CS2Script script = CS2Definitions.getScript(1465); replaceOpValue(script.intOpValues, 40, MEMS_SIZE); replaceOpValue(script.intOpValues, 59, MEMS_SIZE); script.write(Cache.STORE); script = CS2Definitions.getScript(1467); replaceOpValue(script.intOpValues, 28, MAX_SIZE); script.write(Cache.STORE); script = CS2Definitions.getScript(1665); replaceOpValue(script.intOpValues, 19, MEMS_SIZE); replaceOpValue(script.intOpValues, 32, MEMS_SIZE); script.write(Cache.STORE); script = CS2Definitions.getScript(1329); replaceOpValue(script.intOpValues, 0, MAX_SIZE); replaceOpValue(script.intOpValues, 1, MEMS_SIZE); script.write(Cache.STORE); script = CS2Definitions.getScript(1248); replaceOpValue(script.intOpValues, 0, MAX_SIZE); script.write(Cache.STORE); Cache.STORE.getIndex(IndexType.CONFIG).rewriteTable(); Cache.STORE.getIndex(IndexType.CS2_SCRIPTS).rewriteTable(); } public static void replaceOpValue(int[] values, int index, int value) { int old = values[index]; values[index] = value; System.out.println(""Replaced intOpValue#""+index+"" ("" + old + "") with "" + value); } }" "package com.rs.tools; public class BASDumper { public static void main(String[] args) throws IOException { Cache.init(Settings.getConfig().getCachePath()); File file = new File(""basDump.txt""); if (file.exists()) file.delete(); else file.createNewFile(); BufferedWriter writer = new BufferedWriter(new FileWriter(file)); writer.append(""//Version = 727\n""); writer.flush(); Map used = new HashMap<>(); for (int npcId = 0;npcId < Utils.getNPCDefinitionsSize();npcId++) { NPCDefinitions npcDef = NPCDefinitions.getDefs(npcId); if (npcDef.basId != -1) { BASDefinitions render = BASDefinitions.getDefs(npcDef.basId); if (render.standAnimation == -1 && render.walkAnimation == -1) { if (used.get(npcDef.basId) != null) used.put(npcDef.basId, used.get(npcDef.basId) + "", "" + npcId + "" ("" + npcDef.getName() + "")"" ); else used.put(npcDef.basId, ""[""+AnimationDefinitions.getDefs(npcDef.basId).frameSetIds[0] + ""] "" + npcId + "" ("" + npcDef.getName() + "")""); continue; } AnimationDefinitions check = AnimationDefinitions.getDefs(render.standAnimation == -1 ? render.walkAnimation : render.standAnimation); if (used.get(npcDef.basId) != null) used.put(npcDef.basId, used.get(npcDef.basId) + "", "" + npcId + "" ("" + npcDef.getName() + "")"" ); else used.put(npcDef.basId, ""[""+AnimationDefinitions.getDefs(npcDef.basId).frameSetIds[0] + ""] "" + npcId + "" ("" + npcDef.getName() + "")""); if (check.frameSetIds[0] == 2183 || check.frameSetIds[0] == 1843) used.put(npcDef.basId, ""[""+AnimationDefinitions.getDefs(npcDef.basId).frameSetIds[0] + ""] Humanoid""); } } Map UNIDS = new HashMap<>(); for (int i = 0; i < Utils.getBASAnimDefSize(); i++) { String name = used.get(i); if (name == null) { BASDefinitions bas = BASDefinitions.getDefs(i); if (bas.standAnimation != -1 || bas.walkAnimation != -1) { AnimationDefinitions check = AnimationDefinitions.getDefs(bas.standAnimation == -1 ? bas.walkAnimation : bas.standAnimation); name = switch (check.id) { case 2409, 2410, 2411, 2414, 2417, 2418, 2421, 2429, 2420 -> ""Humanoid chathead""; case 3102 -> ""Troll/Tzhaar chathead""; case 1815 -> ""Child chathead""; case 1981 -> ""Werewolf/Cat chathead""; case 1459 -> ""Penguin chathead""; case 81, 83 -> ""Old NPC chathead""; case 2183, 1843 -> ""Humanoid""; default -> { UNIDS.put(i, i); yield ""["" + AnimationDefinitions.getDefs(i).frameSetIds[0] + ""] Unknown""; } }; } } writer.append(String.valueOf(i)).append("": "").append(name); writer.newLine(); writer.flush(); } writer.close(); } }" "package com.rs.tools; public class CS2ScriptPacker { public static void main(String[] args) throws IOException { //Cache.init(); int baseId = 1351; int toId = 6566; CS2Script script = CS2Definitions.getScript(baseId); script.id = toId; System.out.println(Arrays.toString(script.arguments)); System.out.println(Arrays.toString(script.intOpValues)); System.out.println(script.intLocalsCount); System.out.println(script.stringLocalsCount); for (int i = 0;i < script.operations.length;i++) System.out.println(""/*[""+i+""]:*/ "" + script.getOpString(i)); script.intArgsCount = 2; script.stringArgsCount = 1; script.intLocalsCount = 2; script.stringLocalsCount = 1; script.setInstruction(6, CS2Instruction.LOAD_STRING, 0); script.setInstruction(7, CS2Instruction.CC_SETTEXT, 0); script = new CS2Script(new InputStream(script.encode())); script.id = toId; System.out.println(Arrays.toString(script.arguments)); System.out.println(Arrays.toString(script.intOpValues)); for (int i = 0;i < script.operations.length;i++) System.out.println(""/*[""+i+""]:*/ "" + script.getOpString(i)); script.write(Cache.STORE); } }" "package com.rs.tools; public class EmoteParser { EnumDefinitions emoteEnum; public static void main(String[] args) throws IOException { //Cache.init(); EnumDefinitions emoteEnum = EnumDefinitions.getEnum(3874); for (int i = 0;i < 500;i++) { Integer key = emoteEnum.getIntValue(i); if (key == null || (i > 2 && key == 1783)) continue; StructDefinitions emoteStruct = StructDefinitions.getStruct(key); System.out.println(""E_""+String.format(""%03d"", i) + ""("" + i + "", ""+key+"", \""""+ emoteStruct.getStringValue(1419) + ""\""),""); } } }" "package com.rs.tools; public class ItemDefReplacer { private static Store NEW; private static final HashMap PACKED_MAP = new HashMap<>(); public static void main(String[] args) throws IOException { //Cache.init(); NEW = new Store(""D:/RSPS/cache_742_cleaned/""); System.out.println(""Packing...""); for (int itemId = 0;itemId < Utils.getItemDefinitionsSize(NEW);itemId++) { // replaceItem(itemId); ItemDefinitions def = ItemDefinitions.getItemDefinitions(NEW, itemId, false); if (def.wearPos != -1 || def.wearPos2 != -1 || def.wearPos3 != -1) if (def.getName().contains(""chainbody"")) System.out.println(itemId + "" ("" + def.getName() + "") | "" + def.wearPos + "" | "" + def.wearPos2 + "" | "" + def.wearPos3); } // Cache.STORE.getIndex(IndexType.ITEMS).rewriteTable(); // Cache.STORE.getIndex(IndexReference.MODELS).rewriteTable(); } public static void replace100Name(int itemId) { ItemDefinitions def = ItemDefinitions.getDefs(itemId); if (def.name.endsWith("" 100"")) { def.name = def.name.replace("" 100"", "" (deg)""); def.write(Cache.STORE); System.out.println(""Name replaced with: "" + def.name); } } public static void replaceItem(int itemId) { ItemDefinitions def = ItemDefinitions.getItemDefinitions(NEW, itemId); ItemDefinitions old = ItemDefinitions.getDefs(itemId); if (old.wearPos2 == 5 || def.wearPos2 == 5 || (old.wearPos2 == def.wearPos2 && old.wearPos3 == def.wearPos3)) return; if ((!def.containsOption(""Wear"") && !def.containsOption(""Equip"") && !def.containsOption(""Wield"")) || (!old.containsOption(""Wear"") && !old.containsOption(""Equip"") && !old.containsOption(""Wield""))) return; System.out.println(""Packing: "" + itemId + "" ("" + def.name + "") ("" + old.wearPos2 + ""->"" + def.wearPos2 + "")"" + ""("" + old.wearPos3 + ""->"" + def.wearPos3 + "")""); packModels(old, def); old.write(Cache.STORE); System.out.println(""Packed: "" + itemId + "" ("" + def.name + "")""); } public static int packModel(Store cache, int modelId) { if (modelId == -1) return -1; if (PACKED_MAP.get(modelId) != null) return PACKED_MAP.get(modelId); int archiveId = cache.getIndex(IndexType.MODELS).getLastArchiveId()+1; System.out.println(""Packing model: "" + modelId + "" to "" + archiveId); PACKED_MAP.put(modelId, archiveId); if(cache.getIndex(IndexType.MODELS).putFile(archiveId, 0, NEW.getIndex(IndexType.MODELS).getFile(modelId, 0))) return archiveId; throw new RuntimeException(); } public static void packModels(ItemDefinitions to, ItemDefinitions from) { // to.modelId = packModel(Cache.STORE, from.modelId); // to.maleEquip1 = packModel(Cache.STORE, from.maleEquip1); // to.maleEquip2 = packModel(Cache.STORE, from.maleEquip2); // to.maleEquip3 = packModel(Cache.STORE, from.maleEquip3); // to.femaleEquip1 = packModel(Cache.STORE, from.femaleEquip1); // to.femaleEquip2 = packModel(Cache.STORE, from.femaleEquip2); // to.femaleEquip3 = packModel(Cache.STORE, from.femaleEquip3); // to.maleHead1 = packModel(Cache.STORE, from.maleHead1); // to.maleHead2 = packModel(Cache.STORE, from.maleHead2); // to.femaleHead1 = packModel(Cache.STORE, from.femaleHead1); // to.femaleHead2 = packModel(Cache.STORE, from.femaleHead2); // to.modelZoom = from.modelZoom; // to.modelOffsetX = from.modelOffsetX; // to.modelOffsetY = from.modelOffsetY; // to.modelRotationX = from.modelRotationX; // to.modelRotationY = from.modelRotationY; // to.modelRotationZ = from.modelRotationZ; // to.originalModelColors = from.originalModelColors; // to.modifiedModelColors = from.modifiedModelColors; // to.originalTextureIds = from.originalTextureIds; // to.modifiedTextureIds = from.modifiedTextureIds; } }" "package com.rs.tools; public class ItemListDumper { public static void main(String[] args) { try { //Cache.init(); // for (int i = 0; i < Utils.getItemDefinitionsSize(); i++) { // ItemDefinitions def = ItemDefinitions.getItemDefinitions(i); // if (def.getClientScriptData() == null || def.getClientScriptData().isEmpty() || !def.getName().contains(""potion"")) // continue; // System.out.println(def.getName() + "" - "" + def.getClientScriptData() + "" -""); // } new ItemListDumper(); } catch (IOException e) { e.printStackTrace(); } } public ItemListDumper() throws IOException { File file = new File(""itemList.txt""); // = new // File(""information/itemlist.txt""); if (file.exists()) file.delete(); else file.createNewFile(); BufferedWriter writer = new BufferedWriter(new FileWriter(file)); writer.append(""//Version = 727\n""); writer.flush(); for (int id = 0; id < Utils.getItemDefinitionsSize(); id++) { ItemDefinitions def = ItemDefinitions.getDefs(id); StringBuilder values = new StringBuilder(); if (def.getClientScriptData() != null) for (Integer key : def.getClientScriptData().keySet()) { CS2ParamDefs param = CS2ParamDefs.getParams(key); values.append(""["").append(key).append("" ("").append(param.type).append(""): "").append(Utils.CS2ValTranslate(param.type, def.getClientScriptData().get(key))).append(""],""); } writer.append(String.valueOf(id)).append("" - "").append(def.getName()).append("" - ["").append(values.toString()).append(""]""); writer.newLine(); writer.flush(); } writer.close(); } public static int convertInt(String str) { try { int i = Integer.parseInt(str); return i; } catch (NumberFormatException e) { } return 0; } }" "package com.rs.tools; public class LampCalc { public enum Lamp { SMALL(2, 1700), MEDIUM(3, 2500), LARGE(8, 6400); private final int mul; private final int price; private Lamp(int mul, int price) { this.mul = mul; this.price = price; } public int getXp(int level) { if (level >= 99) level = 98; return (int) ((double) (LAMP_XP_VALUES[level - 1] * mul) / 4); } } public static int[] LAMP_XP_VALUES = { 250, 276, 308, 340, 373, 416, 492, 508, 777, 614, 680, 752, 822, 916, 1008, 1046, 1096, 1140, 1192, 1240, 1298, 1348, 1408, 1470, 1536, 1596, 1621, 1656, 1812, 1892, 1973, 2056, 2144, 2237, 2332, 2434, 2540, 2648, 2766, 2882, 3008, 3138, 3272, 3414, 3558, 3716, 3882, 4050, 4220, 4404, 4593, 4800, 4998, 5218, 5448, 5688, 5940, 6184, 6466, 6737, 7030, 7342, 7645, 8018, 8432, 8686, 9076, 9516, 9880, 10371, 10772, 11237, 11786, 12328, 12855, 13358, 13980, 14587, 15169, 15920, 16664, 17390, 18087, 19048, 19674, 20132, 21502, 22370, 23690, 24486, 25806, 26458, 27714, 28944, 30130, 32258, 33390, 34408 }; public static int SMALL = 2, MEDIUM = 3, LARGE = 8; public static void main(String[] args) { Lamp lamp = Lamp.LARGE; int currentLevel = 50; int currentXp = 0; int targetLevel = 120; int lampsUsed = 0; if (currentLevel != -1) currentXp = Skills.getXPForLevel(currentLevel); while (Skills.getLevelForXp(Constants.DUNGEONEERING, currentXp) < targetLevel) { System.out.println(""Lamp used at level "" + Skills.getLevelForXp(Constants.DUNGEONEERING, currentXp) + "" given "" + lamp.getXp(Skills.getLevelForXp(Constants.DUNGEONEERING, currentXp))); currentXp += lamp.getXp(Skills.getLevelForXp(Constants.DUNGEONEERING, currentXp)); lampsUsed++; } System.out.println(""Lamps used: "" + lampsUsed + "" costing "" + (lamp.price * lampsUsed) + "" chimes.""); } }" "package com.rs.tools; public class LandscapeDataReplacer { private static Store NEW; public static void main(String[] args) throws IOException { //Cache.init(); NEW = new Store(""C:/Users/John/Desktop/723 cache/""); MapXTEAs.loadKeys(); //Fix all broken regions // for (int regionId = 0;regionId < Short.MAX_VALUE;regionId++) { // Region region = new Region(regionId); // region.loadRegionMap(); // // if (region.isMissingXtea()) { // try { // if (!packMapObjects(region)) { // try { // packPurifiedMapObjects(region); // } catch(Exception e) { // continue; // } // } // } catch(Exception e) { // System.out.println(""Failed "" + regionId + "": "" + e.getMessage()); // } // } // } int regionId = 12853; int regionX = (regionId >> 8) * 64; int regionY = (regionId & 0xff) * 64; int landArchiveId = NEW.getIndex(IndexType.MAPS).getArchiveId(""l"" + ((regionX >> 3) / 8) + ""_"" + ((regionY >> 3) / 8)); int mapArchiveId = NEW.getIndex(IndexType.MAPS).getArchiveId(""m"" + ((regionX >> 3) / 8) + ""_"" + ((regionY >> 3) / 8)); Cache.STORE.getIndex(IndexType.MAPS).putArchive(mapArchiveId, NEW.getIndex(IndexType.MAPS).getFile(mapArchiveId, 0)); Cache.STORE.getIndex(IndexType.MAPS).putArchive(landArchiveId, NEW.getIndex(IndexType.MAPS).getFile(landArchiveId, 0)); //Cache.STORE.getIndex(IndexType.MAPS).putFile(landArchiveId, 0, Constants.GZIP_COMPRESSION, NEW.getIndex(IndexType.MAPS).getFile(landArchiveId, 0), new int[] { 0, 0, 0, 0 }, true, true, -1, -1); } public static void copyMapObjects(Region from, Region to, boolean compare) { if (!compareObjects(from, to) && compare) return; int fromLandArchiveId = Cache.STORE.getIndex(IndexType.MAPS).getArchiveId(""l"" + ((((from.getRegionId() >> 8) * 64) >> 3) / 8) + ""_"" + ((((from.getRegionId() & 0xff) * 64) >> 3) / 8)); int toLandArchiveId = Cache.STORE.getIndex(IndexType.MAPS).getArchiveId(""l"" + ((((to.getRegionId() >> 8) * 64) >> 3) / 8) + ""_"" + ((((to.getRegionId() & 0xff) * 64) >> 3) / 8)); byte[] fromData = Cache.STORE.getIndex(IndexType.MAPS).getFile(fromLandArchiveId, 0, MapXTEAs.getMapKeys(from.getRegionId())); if (fromData == null || toLandArchiveId <= -1) { System.out.println(""Null data: "" + from.getRegionId()); return; } if (verifyObjectData(fromData)) System.out.println(from.getRegionId() + ""->"" + to.getRegionId() + "" - Copied: "" + Cache.STORE.getIndex(IndexType.MAPS).putFile(toLandArchiveId, 0, Constants.GZIP_COMPRESSION, fromData, new int[] { 0, 0, 0, 0 }, true, true, -1, -1)); } public static boolean packPurifiedMapObjects(Region region) { return packPurifiedMapObjects(region, region); } public static boolean packPurifiedMapObjects(Region from, Region to) { int regionX = (to.getRegionId() >> 8) * 64; int regionY = (to.getRegionId() & 0xff) * 64; byte[] newLandData = NEW.getIndex(IndexType.MAPS).getFile(((from.getRegionId() >> 8) | (from.getRegionId() & 0xff) << 7), 0); int landArchiveId = Cache.STORE.getIndex(IndexType.MAPS).getArchiveId(""l"" + ((regionX >> 3) / 8) + ""_"" + ((regionY >> 3) / 8)); byte[] purified = purifyObjectData(newLandData); if (purified != null && verifyObjectData(purified)) { boolean success = Cache.STORE.getIndex(IndexType.MAPS).putFile(landArchiveId, 0, Constants.GZIP_COMPRESSION, purified, new int[] { 0, 0, 0, 0 }, true, true, -1, -1); System.out.println(from.getRegionId() + "" - 764 map data valid: "" + Cache.STORE.getIndex(IndexType.MAPS).putFile(landArchiveId, 0, Constants.GZIP_COMPRESSION, purified, new int[] { 0, 0, 0, 0 }, true, true, -1, -1)); return success; } System.out.println(from.getRegionId() + "" - Failed to purify""); return false; } public static boolean packMapObjects(Region region) { return packMapObjects(region, region); } public static boolean packMapObjects(Region from, Region to) { int regionX = (to.getRegionId() >> 8) * 64; int regionY = (to.getRegionId() & 0xff) * 64; byte[] newLandData = NEW.getIndex(IndexType.MAPS).getFile(((from.getRegionId() >> 8) | (from.getRegionId() & 0xff) << 7), 0); int landArchiveId = Cache.STORE.getIndex(IndexType.MAPS).getArchiveId(""l"" + ((regionX >> 3) / 8) + ""_"" + ((regionY >> 3) / 8)); boolean success = Cache.STORE.getIndex(IndexType.MAPS).putFile(landArchiveId, 0, Constants.GZIP_COMPRESSION, newLandData, new int[] { 0, 0, 0, 0 }, true, true, -1, -1); if (verifyObjectData(newLandData)) { System.out.println(from.getRegionId() + "" - 764 map data valid: "" + success); return success; } System.out.println(from.getRegionId() + "" - 764 map data invalid version""); return false; } public static byte[] purifyObjectData(byte[] data) { ArrayList objects = new ArrayList<>(); InputStream landStream = new InputStream(data); OutputStream fixed = new OutputStream(); int realSize = 0; int objectId = -1; int incr; while ((incr = landStream.readSmart2()) != 0) { objectId += incr; int location = 0; int incr2; while ((incr2 = landStream.readUnsignedSmart()) != 0) { location += incr2 - 1; int localX = (location >> 6 & 0x3f); int localY = (location & 0x3f); int plane = location >> 12; int objectData = landStream.readUnsignedByte(); int type = objectData >> 2; int rotation = objectData & 0x3; if (localX < 0 || localX >= 64 || localY < 0 || localY >= 64) { System.out.println(""Skipping: Pos: "" + localX + "", "" + localY); continue; } int objectPlane = plane; if (objectPlane < 0 || objectPlane >= 4 || plane < 0 || plane >= 4) { System.out.println(""Skipping: Plane: "" + objectPlane + "", "" + plane); continue; } realSize++; if (objectId >= Utils.getObjectDefinitionsSize()) continue; objects.add(new GameObject(objectId, ObjectType.forId(type), rotation, localX, localY, objectPlane)); } } System.out.println(""Real size: "" + realSize + "" - Fixed size: "" + objects.size()); int lastLoc = 0; int lastObj = -1; for (GameObject current : objects) { if (lastObj != current.getId()) { if (lastLoc != 0) { lastLoc = 0; fixed.writeSmart(0); } fixed.writeSum(current.getId() - lastObj); lastObj = current.getId(); } int currLoc = (current.getY() + (current.getX() << 6) + (current.getPlane() << 12)); fixed.writeSmart((currLoc - lastLoc) + 1); lastLoc = currLoc; fixed.writeByte(current.getRotation() + (current.getType().id << 2)); } fixed.writeSum(0); if (!compareObjects(objects, getObjects(fixed.getBuffer()))) return null; return fixed.getBuffer(); } public static boolean verifyObjectData(byte[] data) { ArrayList objects = new ArrayList<>(); InputStream landStream = new InputStream(data); boolean valid = true; int objectId = -1; int incr; while ((incr = landStream.readSmart2()) != 0) { objectId += incr; int location = 0; int incr2; while ((incr2 = landStream.readUnsignedSmart()) != 0) { location += incr2 - 1; int localX = (location >> 6 & 0x3f); int localY = (location & 0x3f); int plane = location >> 12; int objectData = landStream.readUnsignedByte(); int type = objectData >> 2; int rotation = objectData & 0x3; if (localX < 0 || localX >= 64 || localY < 0 || localY >= 64) continue; int objectPlane = plane; if (objectPlane < 0 || objectPlane >= 4 || plane < 0 || plane >= 4) continue; if (objectId >= Utils.getObjectDefinitionsSize()) { System.out.println(""Invalid object: "" + objectId); valid = false; continue; } objects.add(new GameObject(objectId, ObjectType.forId(type), rotation, localX, localY, objectPlane)); } } return valid; } public static boolean compareObjects(Region r1, Region r2) { return compareObjects(getObjects(r1), getObjects(r2)); } public static boolean compareObjects(ArrayList objects, ArrayList objects2) { if (objects.size() != objects2.size()) { System.out.println(""Size mismatch""); return false; } boolean matches = true; for (int i = 0;i < objects.size();i++) { GameObject o1 = objects.get(i); GameObject o2 = objects2.get(i); if (o1.getId() != o2.getId()) { matches = false; System.out.println(""Id mismatch: "" + o1.getId() + "", "" + o2.getId()); } if (!o1.getTile().isAt(o2.getX(), o2.getY())) { matches = false; System.out.println(""Loc mismatch: "" + o1.getTile().getTileHash() + "", "" + o2.getTile().getTileHash()); } } return matches; } public static ArrayList getObjects(Region region) { byte[] newLandData = NEW.getIndex(IndexType.MAPS).getFile(((region.getRegionId() >> 8) | (region.getRegionId() & 0xff) << 7), 0); return getObjects(newLandData); } public static ArrayList getObjects(byte[] data) { ArrayList objects = new ArrayList<>(); InputStream landStream = new InputStream(data); int objectId = -1; int incr; while ((incr = landStream.readSmart2()) != 0) { objectId += incr; int location = 0; int incr2; while ((incr2 = landStream.readUnsignedSmart()) != 0) { location += incr2 - 1; int localX = (location >> 6 & 0x3f); int localY = (location & 0x3f); int plane = location >> 12; int objectData = landStream.readUnsignedByte(); int type = objectData >> 2; int rotation = objectData & 0x3; if (localX < 0 || localX >= 64 || localY < 0 || localY >= 64) continue; int objectPlane = plane; if (objectPlane < 0 || objectPlane >= 4 || plane < 0 || plane >= 4) continue; objects.add(new GameObject(objectId, ObjectType.forId(type), rotation, localX, localY, objectPlane)); } } return objects; } }" "package com.rs.tools; public class MapImageDumper { private static final int[][] TILE_SHAPES = { { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }, { 1, 0, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 1, 1, 1, 1 }, { 1, 1, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0 }, { 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 1, }, { 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }, { 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1 }, { 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0 }, { 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 1 }, { 1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 1, 1 } }; private static final int[][] TILE_ROTATIONS = { { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 }, { 12, 8, 4, 0, 13, 9, 5, 1, 14, 10, 6, 2, 15, 11, 7, 3 }, { 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 }, { 3, 7, 11, 15, 2, 6, 10, 14, 1, 5, 9, 13, 0, 4, 8, 12 } }; private final List regions = new ArrayList<>(); private final List flags = new ArrayList<>(); private Region lowestX; private Region lowestY; private Region highestX; private Region highestY; private static final int MAX_REGION = Short.MAX_VALUE-2; private static final int PIXELS_PER_TILE = 4; private static final boolean DRAW_UNDERLAY = true; private static final boolean DRAW_OVERLAY = true; private static final boolean DRAW_OBJECTS = true; private static final boolean DRAW_WALLS = true; private static final boolean DRAW_ICONS = true; private static final boolean DRAW_REGIONS = false; private static final boolean LABEL = true; private static final boolean OUTLINE = true; private static final boolean FILL = true; private static final int Z_MIN = 0, Z_MAX = 3; private void initialize() throws IOException { for (int i = 0; i < MAX_REGION; i++) { final Region region = new Region(i); region.loadRegionMap(true); if (region.isMissingXtea()) flags.add(i); if (region.hasData() || i == 0) { regions.add(region); if (lowestX == null || region.getBaseX() < lowestX.getBaseX()) lowestX = region; if (highestX == null || region.getBaseX() > highestX.getBaseX()) highestX = region; if (lowestY == null || region.getBaseY() < lowestY.getBaseY()) lowestY = region; if (highestY == null || region.getBaseY() > highestY.getBaseY()) highestY = region; } } } private void draw() throws IOException { int minX = lowestX.getBaseX(); int minY = lowestY.getBaseY(); int maxX = highestX.getBaseX() + Region.WIDTH; int maxY = highestY.getBaseY() + Region.HEIGHT; int dimX = maxX - minX; int dimY = maxY - minY; int boundX = dimX - 1; int boundY = dimY - 1; dimX *= PIXELS_PER_TILE; dimY *= PIXELS_PER_TILE; for (int z = Z_MIN; z <= Z_MAX; z++) { if (z != 0) continue; System.out.println(""Generating map images for z = "" + z); System.out.println(""dimx: "" + dimX + "", "" + dimY); BufferedImage baseImage = BigBufferedImage.create(dimX, dimY, BufferedImage.TYPE_INT_RGB); BufferedImage fullImage = BigBufferedImage.create(dimX, dimY, BufferedImage.TYPE_INT_RGB); //BufferedImage baseImage = new BufferedImage(dimX, dimY, BufferedImage.TYPE_INT_RGB); //BufferedImage fullImage = new BufferedImage(dimX, dimY, BufferedImage.TYPE_INT_RGB); Graphics2D graphics = fullImage.createGraphics(); graphics.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC); graphics.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY); graphics.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_PURE); if (DRAW_UNDERLAY) { System.out.println(""Drawing underlay""); drawUnderlay(z, baseImage); } if (DRAW_UNDERLAY) { System.out.println(""Blending underlay""); blendUnderlay(z, baseImage, fullImage, boundX, boundY); } if (DRAW_OVERLAY) { System.out.println(""Drawing overlay""); drawOverlay(z, fullImage); } if (DRAW_OBJECTS) { System.out.println(""Drawing locations""); drawLocations(z, graphics); } if (DRAW_WALLS) { System.out.println(""Drawing walls""); drawWalls(z, graphics); } if (DRAW_ICONS) { System.out.println(""Drawing icons""); drawIcons(z, graphics); } if (DRAW_REGIONS) { System.out.println(""Drawing regions""); drawRegions(z, graphics); } graphics.dispose(); System.out.println(""Writing to files""); ImageIO.write(fullImage, ""png"", new File(""WORLD_MAP_"" + z + "".png"")); } } private void drawUnderlay(int z, BufferedImage image) { for (Region region : regions) { int drawBaseX = region.getBaseX() - lowestX.getBaseX(); int drawBaseY = highestY.getBaseY() - region.getBaseY(); for (int x = 0; x < Region.WIDTH; ++x) { int drawX = drawBaseX + x; for (int y = 0; y < Region.HEIGHT; ++y) { int drawY = drawBaseY + ((Region.HEIGHT - 1) - y); int underlayId = region.getUnderlayId(z, x, y) - 1; int rgb = Color.CYAN.getRGB(); if (underlayId > -1) { UnderlayDefinitions underlay = UnderlayDefinitions.getUnderlayDefinitions(underlayId); rgb = underlay.rgb; } drawMapSquare(image, drawX, drawY, rgb, -1, -1); } } } } private void blendUnderlay(int z, BufferedImage baseImage, BufferedImage fullImage, int boundX, int boundY) { for (Region region : regions) { int drawBaseX = region.getBaseX() - lowestX.getBaseX(); int drawBaseY = highestY.getBaseY() - region.getBaseY(); for (int x = 0; x < Region.WIDTH; ++x) { int drawX = drawBaseX + x; for (int y = 0; y < Region.HEIGHT; ++y) { int drawY = drawBaseY + ((Region.HEIGHT - 1) - y); Color c = getMapSquare(baseImage, drawX, drawY); if (c.equals(Color.CYAN)) continue; int tRed = 0, tGreen = 0, tBlue = 0; int count = 0; int maxDY = Math.min(boundY, drawY + 3); int maxDX = Math.min(boundX, drawX + 3); int minDY = Math.max(0, drawY - 3); int minDX = Math.max(0, drawX - 3); for (int dy = minDY; dy < maxDY; dy++) for (int dx = minDX; dx < maxDX; dx++) { c = getMapSquare(baseImage, dx, dy); if (c.equals(Color.CYAN)) continue; tRed += c.getRed(); tGreen += c.getGreen(); tBlue += c.getBlue(); count++; } if (count > 0) { c = new Color(tRed / count, tGreen / count, tBlue / count); drawMapSquare(fullImage, drawX, drawY, c.getRGB(), -1, -1); } } } } } private void drawOverlay(int z, BufferedImage image) { for (Region region : regions) { int drawBaseX = region.getBaseX() - lowestX.getBaseX(); int drawBaseY = highestY.getBaseY() - region.getBaseY(); for (int x = 0; x < Region.WIDTH; ++x) { int drawX = drawBaseX + x; for (int y = 0; y < Region.HEIGHT; ++y) { int drawY = drawBaseY + ((Region.HEIGHT - 1) - y); int overlayId = region.getOverlayId(z, x, y) - 1; int shapeId = region.getOverlayPathShape(z, x, y) - 1; if (overlayId > -1) { int rgb = OverlayDefinitions.getOverlayDefinitions(overlayId).getOverlayRGB(); drawMapSquare(image, drawX, drawY, rgb, region.getOverlayPathShape(z, x, y), region.getOverlayRotation(z, x, y)); } else if (shapeId > -1) { int rgb = OverlayDefinitions.getOverlayDefinitions(shapeId).getShapeRGB(); drawMapSquare(image, drawX, drawY, rgb, region.getOverlayPathShape(z, x, y), region.getOverlayRotation(z, x, y)); } } } } } private void drawLocations(int z, Graphics2D graphics) { for (Region region : regions) { int drawBaseX = region.getBaseX() - lowestX.getBaseX(); int drawBaseY = highestY.getBaseY() - region.getBaseY(); if (region.getObjects() == null) continue; for (WorldObject location : region.getObjects()) { int localX = location.getX() - region.getBaseX(); int localY = location.getY() - region.getBaseY(); if (!canDrawLocation(region, location, z, localX, localY)) continue; ObjectDefinitions objType = ObjectDefinitions.getDefs(location.getId()); int drawX = drawBaseX + localX; int drawY = drawBaseY + ((Region.HEIGHT - 1) - localY); if (objType.mapSpriteId != -1) { int spriteId = MapSpriteDefinitions.getMapSpriteDefinitions(objType.mapSpriteId).spriteId; if (spriteId == -1) continue; Image spriteImage = new SpriteDefinitions(Cache.STORE, spriteId, 0).getImages()[0]; graphics.drawImage(spriteImage, drawX * PIXELS_PER_TILE, drawY * PIXELS_PER_TILE, null); } } } } private void drawWalls(int z, Graphics2D graphics) { for (Region region : regions) { int drawBaseX = region.getBaseX() - lowestX.getBaseX(); int drawBaseY = highestY.getBaseY() - region.getBaseY(); if (region.getObjects() == null) continue; for (WorldObject location : region.getObjects()) { graphics.setColor(Color.WHITE); int localX = location.getX() - region.getBaseX(); int localY = location.getY() - region.getBaseY(); if (!canDrawLocation(region, location, z, localX, localY)) continue; ObjectDefinitions objType = ObjectDefinitions.getDefs(location.getId()); // Don't draw walls on water if (objType.mapSpriteId == 22) continue; String objName = objType.getName().toLowerCase(); if (objName.contains(""door"") || objName.contains(""gate"")) graphics.setColor(Color.RED); int drawX = drawBaseX + localX; int drawY = drawBaseY + ((Region.HEIGHT - 1) - localY); drawX *= PIXELS_PER_TILE; drawY *= PIXELS_PER_TILE; if (location.getType() == ObjectType.WALL_STRAIGHT) { // Straight walls if (location.getRotation() == 0) graphics.drawLine(drawX, drawY, drawX, drawY + PIXELS_PER_TILE); else if (location.getRotation() == 1) graphics.drawLine(drawX, drawY, drawX + PIXELS_PER_TILE, drawY); else if (location.getRotation() == 2) graphics.drawLine(drawX + PIXELS_PER_TILE, drawY, drawX + PIXELS_PER_TILE, drawY + PIXELS_PER_TILE); else if (location.getRotation() == 3) graphics.drawLine(drawX, drawY + PIXELS_PER_TILE, drawX + PIXELS_PER_TILE, drawY + PIXELS_PER_TILE); } else if (location.getType() == ObjectType.WALL_WHOLE_CORNER) { // Corner walls if (location.getRotation() == 0) { // West & South graphics.drawLine(drawX, drawY, drawX, drawY + PIXELS_PER_TILE); graphics.drawLine(drawX, drawY, drawX + PIXELS_PER_TILE, drawY); } else if (location.getRotation() == 1) { // South & East graphics.drawLine(drawX, drawY, drawX + PIXELS_PER_TILE, drawY); graphics.drawLine(drawX + PIXELS_PER_TILE, drawY, drawX + PIXELS_PER_TILE, drawY + PIXELS_PER_TILE); } else if (location.getRotation() == 2) { // East & North graphics.drawLine(drawX + PIXELS_PER_TILE, drawY, drawX + PIXELS_PER_TILE, drawY + PIXELS_PER_TILE); graphics.drawLine(drawX, drawY + PIXELS_PER_TILE, drawX + PIXELS_PER_TILE, drawY + PIXELS_PER_TILE); } else if (location.getRotation() == 3) { // North & West graphics.drawLine(drawX, drawY + PIXELS_PER_TILE, drawX + PIXELS_PER_TILE, drawY + PIXELS_PER_TILE); graphics.drawLine(drawX, drawY, drawX, drawY + PIXELS_PER_TILE); } } else if (location.getType() == ObjectType.WALL_STRAIGHT_CORNER) { // Single points if (location.getRotation() == 0) graphics.drawLine(drawX, drawY + 1, drawX, drawY + 1); else if (location.getRotation() == 1) graphics.drawLine(drawX + 3, drawY + 1, drawX + 3, drawY + 1); else if (location.getRotation() == 2) graphics.drawLine(drawX + 3, drawY + 4, drawX + 3, drawY + 4); else if (location.getRotation() == 3) graphics.drawLine(drawX, drawY + 3, drawX, drawY + 3); } else if (location.getType() == ObjectType.WALL_INTERACT) if (location.getRotation() == 0 || location.getRotation() == 2) graphics.drawLine(drawX, drawY + PIXELS_PER_TILE, drawX + PIXELS_PER_TILE, drawY); else if (location.getRotation() == 1 || location.getRotation() == 3) graphics.drawLine(drawX, drawY, drawX + PIXELS_PER_TILE, drawY + PIXELS_PER_TILE); } } } private void drawIcons(int z, Graphics2D graphics) { for (Region region : regions) { int drawBaseX = region.getBaseX() - lowestX.getBaseX(); int drawBaseY = highestY.getBaseY() - region.getBaseY(); if (region.getObjects() == null) continue; for (WorldObject location : region.getObjects()) { int localX = location.getX() - region.getBaseX(); int localY = location.getY() - region.getBaseY(); if (!canDrawLocation(region, location, z, localX, localY)) continue; ObjectDefinitions objType = ObjectDefinitions.getDefs(location.getId()); int drawX = drawBaseX + localX; int drawY = drawBaseY + (63 - localY); if (objType.mapIcon != -1) { AreaDefinitions areaType = AreaDefinitions.getDefinitions(objType.mapIcon); if (areaType.areaName != null) System.out.println(""{ \""name\"": \""""+areaType.areaName+""\"", \""coords\"": [""+location.getX()+"", ""+location.getY()+"", 0] },""); if (areaType.spriteId != -1) { Image spriteImage = new SpriteDefinitions(Cache.STORE, areaType.spriteId, 0).getImages()[0]; graphics.drawImage(spriteImage, (drawX - 1) * PIXELS_PER_TILE, (drawY - 1) * PIXELS_PER_TILE, null); } } } } } private boolean canDrawLocation(Region region, WorldObject location, int z, int x, int y) { if (region.isLinkedBelow(z, x, y) || region.isVisibleBelow(z, x, y)) return false; if (location.getPlane() == z + 1 && (region.isLinkedBelow(z + 1, x, y) || region.isVisibleBelow(z + 1, x, y))) return true; return z == location.getPlane(); } private void drawRegions(int z, Graphics2D graphics) { for (Region region : regions) { int baseX = region.getBaseX(); int baseY = region.getBaseY(); int drawBaseX = baseX - lowestX.getBaseX(); int drawBaseY = highestY.getBaseY() - baseY; if (LABEL) { graphics.setColor(Color.RED); graphics.drawString(String.valueOf(region.getRegionId()), drawBaseX * PIXELS_PER_TILE, drawBaseY * PIXELS_PER_TILE + graphics.getFontMetrics().getHeight()); } if (OUTLINE) { graphics.setColor(Color.RED); graphics.drawRect(drawBaseX * PIXELS_PER_TILE, drawBaseY * PIXELS_PER_TILE, 64 * PIXELS_PER_TILE, 64 * PIXELS_PER_TILE); } if (FILL) if (flags.contains(region.getRegionId())) { graphics.setColor(new Color(255, 0, 0, 80)); graphics.fillRect(drawBaseX * PIXELS_PER_TILE, drawBaseY * PIXELS_PER_TILE, 64 * PIXELS_PER_TILE, 64 * PIXELS_PER_TILE); } } } private void drawMapSquare(BufferedImage image, int x, int y, int overlayRGB, int shape, int rotation) { if (shape > -1) { int[] shapeMatrix = TILE_SHAPES[shape]; int[] rotationMatrix = TILE_ROTATIONS[rotation & 0x3]; int shapeIndex = 0; for (int tilePixelY = 0; tilePixelY < PIXELS_PER_TILE; tilePixelY++) for (int tilePixelX = 0; tilePixelX < PIXELS_PER_TILE; tilePixelX++) { int drawx = x * PIXELS_PER_TILE + tilePixelX; int drawy = y * PIXELS_PER_TILE + tilePixelY; if (shapeMatrix[rotationMatrix[shapeIndex++]] != 0) image.setRGB(drawx, drawy, new Color(overlayRGB).getRGB()); } } else for (int tilePixelY = 0; tilePixelY < PIXELS_PER_TILE; tilePixelY++) for (int tilePixelX = 0; tilePixelX < PIXELS_PER_TILE; tilePixelX++) { int drawx = x * PIXELS_PER_TILE + tilePixelX; int drawy = y * PIXELS_PER_TILE + tilePixelY; image.setRGB(drawx, drawy, new Color(overlayRGB).getRGB()); } } public Color getMapSquare(BufferedImage image, int x, int y) { x *= PIXELS_PER_TILE; y *= PIXELS_PER_TILE; return new Color(image.getRGB(x, y)); } public static void main(String[] args) throws IOException { //Cache.init(); MapXTEAs.loadKeys(); long ms = System.currentTimeMillis(); MapImageDumper dumper = new MapImageDumper(); dumper.initialize(); dumper.draw(); System.out.println(""Time taken: "" + TimeUnit.MILLISECONDS.toSeconds(System.currentTimeMillis() - ms) + ""s""); } }" "package com.rs.tools; public class MapSearcher { public static void main(String[] args) throws IOException, InterruptedException { //Cache.init(); MapXTEAs.loadKeys(); int SEARCH = 27241; for (GameObject obj : getObjectsById(SEARCH)) System.out.println(obj); //System.out.println(""PITFALLS.add(""+obj.getTileHash()+"");""); } public static void removeAllObjects(int id) { for (GameObject obj : getObjectsById(id)) World.removeObject(obj); } public static List getObjectsById(int id) { List objects = new ArrayList<>(); for (int regionId = 0; regionId < 30000; regionId++) { if (regionId == 18754) continue; int regionX = (regionId >> 8) * 64; int regionY = (regionId & 0xff) * 64; int landArchiveId = Cache.STORE.getIndex(IndexType.MAPS).getArchiveId(""l"" + ((regionX >> 3) / 8) + ""_"" + ((regionY >> 3) / 8)); byte[] data = landArchiveId == -1 ? null : Cache.STORE.getIndex(IndexType.MAPS).getFile(landArchiveId, 0, MapXTEAs.getMapKeys(regionId)); if (data == null) continue; InputStream landStream = new InputStream(data); int objectId = -1; int incr; while ((incr = landStream.readSmart2()) != 0) { objectId += incr; int location = 0; int incr2; while ((incr2 = landStream.readUnsignedSmart()) != 0) { location += incr2 - 1; int localX = (location >> 6 & 0x3f); int localY = (location & 0x3f); int plane = location >> 12; int objectData = landStream.readUnsignedByte(); int type = objectData >> 2; int rotation = objectData & 0x3; if (localX < 0 || localX >= 64 || localY < 0 || localY >= 64) continue; // ObjectDefinitions def = ObjectDefinitions.getDefs(objectId); if (objectId != id) continue; // if (def.ignoreAltClip) // continue; objects.add(new GameObject(objectId, ObjectType.forId(type), rotation, (regionX + localX), (regionY + localY), plane)); } } } return objects; } }" "package com.rs.tools; public class NPCAnimationChecker { public static void main(String[] args) throws IOException { //Cache.init(); File file = new File(""npcAnimationsCompat.txt""); if (file.exists()) file.delete(); else file.createNewFile(); BufferedWriter writer = new BufferedWriter(new FileWriter(file)); writer.append(""//Version = 727\n""); writer.flush(); for (int npcId = 0;npcId < Utils.getNPCDefinitionsSize();npcId++) { NPCDefinitions npcDef = NPCDefinitions.getDefs(npcId); if (npcDef.basId != -1) if (BASDefinitions.getDefs(npcDef.basId).standAnimation != -1) if (AnimationDefinitions.getDefs(BASDefinitions.getDefs(npcDef.basId).standAnimation).frameSetIds != null) { int frameSetId = AnimationDefinitions.getDefs(BASDefinitions.getDefs(npcDef.basId).standAnimation).frameSetIds[0]; HashSet animsUsingSet = new HashSet<>(); for (int i = 0; i < Utils.getAnimationDefinitionsSize(); i++) { AnimationDefinitions check = AnimationDefinitions.getDefs(i); if ((check == null) || check.frameSetIds == null || check.frameSetIds[0] == -1) continue; if (check.frameSetIds[0] == frameSetId) animsUsingSet.add(i); } writer.append(String.valueOf(npcId)).append("" ("").append(npcDef.getName()).append("") set#"").append(String.valueOf(frameSetId)).append("": "").append(animsUsingSet.toString()); writer.newLine(); writer.flush(); } } writer.close(); } }" "package com.rs.tools; public class NPCCharmDumper { private static final Set DUMPED = new HashSet<>(); private static final Map MAP = new HashMap<>(); public static void main(String[] args) { try { //Cache.init(); NPCCombatDefinitions.init(); File file = new File(""charmDrops.txt""); if (file.exists()) file.delete(); else file.createNewFile(); BufferedWriter writer = new BufferedWriter(new FileWriter(file)); for (int npcId = 0;npcId < Utils.getNPCDefinitionsSize();npcId++) { NPCDefinitions defs = NPCDefinitions.getDefs(npcId); if (defs.hasAttackOption() && !defs.isDungNPC()) { if (DUMPED.contains(defs.getName())) continue; if (dumpNPC(defs.getName())) System.out.println(""Successfully dumped "" + defs.getName()); DUMPED.add(defs.getName()); } } List sorted = new ArrayList<>(MAP.keySet()); Collections.sort(sorted); for (String key : sorted) { writer.append(MAP.get(key)); writer.newLine(); writer.flush(); } writer.close(); } catch (IOException e) { e.printStackTrace(); } } public static boolean dumpNPC(String pageName) { try { WebPage page = new WebPage(""https://runescape.wiki/w/Charm:""+pageName+""?action=raw""); try { page.load(); } catch (SocketTimeoutException e) { return dumpNPC(pageName); } catch (Exception e) { return false; } int kills = -1, gold = -1, green = -1, crimson = -1, blue = -1, charms = 1; for (String line : page.getLines()) { line = line.replace("" "", """").replace(""|"", """"); String[] split = line.split(""=""); if (split[0].startsWith(""kills"")) { split[0] = split[0].replace(""kills"", """"); if ((split[0].length() > 2) || (split.length < 2)) continue; try { kills = Integer.valueOf(split[1]); } catch (Exception e) { } } else if (split[0].startsWith(""charms"")) { split[0] = split[0].replace(""charms"", """"); if ((split[0].length() > 2) || (split.length < 2)) continue; try { charms = Integer.valueOf(split[1]); } catch (Exception e) { } } else if (split[0].startsWith(""gold"")) { split[0] = split[0].replace(""gold"", """"); if ((split[0].length() > 2) || (split.length < 2)) continue; try { gold = Integer.valueOf(split[1]); } catch (Exception e) { } } else if (split[0].startsWith(""green"")) { split[0] = split[0].replace(""green"", """"); if ((split[0].length() > 2) || (split.length < 2)) continue; try { green = Integer.valueOf(split[1]); } catch (Exception e) { } } else if (split[0].startsWith(""crimson"")) { split[0] = split[0].replace(""crimson"", """"); if ((split[0].length() > 2) || (split.length < 2)) continue; try { crimson = Integer.valueOf(split[1]); } catch (Exception e) { } } else if (split[0].startsWith(""blue"")) { split[0] = split[0].replace(""blue"", """"); if ((split[0].length() > 2) || (split.length < 2)) continue; try { blue = Integer.valueOf(split[1]); } catch (Exception e) { } } } if (kills > 500) { System.out.println(pageName + "" - "" + kills + "", "" + gold + "", "" + green + "", "" + crimson + "", "" + blue); int goldRate = (int) Math.round((((double) gold / (double) charms) / kills * 100.0)); int greenRate = (int) Math.round((((double) green / (double) charms) / kills * 100.0)); int crimsonRate = (int) Math.round((((double) crimson / (double) charms) / kills * 100.0)); int blueRate = (int) Math.round((((double) blue / (double) charms) / kills * 100.0)); MAP.put(pageName, pageName.toLowerCase().replace("" "", ""_"") + "":"" + goldRate + ""-"" + greenRate + ""-"" + crimsonRate + ""-"" + blueRate + "":""); } else System.err.println(pageName + "" - "" + kills + "" too small sample size.""); return true; } catch (Exception e) { e.printStackTrace(); } return false; } }" "package com.rs.tools; public class NPCCombatDefMerger { private final static String ORIGINAL_PATH = ""data/npcs/combatdefs/""; public static Map ORIGINAL = new HashMap<>(); public static void main(String[] args) throws IOException { JsonFileManager.setGSON(new GsonBuilder() .registerTypeAdapter(Controller.class, new ControllerAdapter()) .registerTypeAdapter(Date.class, new DateAdapter()) .registerTypeAdapter(PacketEncoder.class, new PacketEncoderAdapter()) .registerTypeAdapter(Packet.class, new PacketAdapter()) .registerTypeAdapterFactory(new RecordTypeAdapterFactory()) .disableHtmlEscaping() .setPrettyPrinting() .create()); Settings.loadConfig(); Cache.init(Settings.getConfig().getCachePath()); loadPackedCombatDefinitions(); for (File file : ORIGINAL.keySet()) { NPCCombatDefinitions def = ORIGINAL.get(file); //TODO any bulk processing here // if (def.getAggroDistance() > 60) { // def.aggroDistance = def.getAttackStyle() == AttackStyle.MELEE ? 4 : def.getAttackRange() - 2; // System.out.println(""Modified: "" + file); // } JsonFileManager.saveJsonFile(def, file); System.out.println(""Processed: "" + file); } } private static void loadPackedCombatDefinitions() { try { File[] files = new File(ORIGINAL_PATH).listFiles(); for (File f : files) loadFile(f, ORIGINAL); } catch (Throwable e) { Logger.handle(NPCCombatDefMerger.class, ""loadPackedCombatDefinitions"", e); } } private static void loadFile(File f, Map map) throws JsonIOException, IOException { if (f.isDirectory()) { for (File dir : f.listFiles()) loadFile(dir, map); return; } NPCCombatDefinitions defs = (NPCCombatDefinitions) JsonFileManager.loadJsonFile(f, NPCCombatDefinitions.class); if (defs != null) map.put(f, defs); } }" "package com.rs.tools; public class NPCDropDumper { // private static Set DUMPED = new HashSet<>(); public static void main(String[] args) { //Cache.init(); dumpNPC(""Chaos druid""); // for (int npcId = 0;npcId < Utils.getNPCDefinitionsSize();npcId++) { // NPCDefinitions defs = NPCDefinitions.getDefs(npcId); // if (!DUMPED.contains(defs.getName()) && defs.hasAttackOption()) { // DUMPED.add(defs.getName()); // if (dumpNPC(defs.getName().replace("" "", "" ""))) // System.out.println(""Successfully dumped "" + defs.getName()); //// else //// System.out.println(""Failed to dump "" + defs.getName()); // } // } } private static final Map CUSTOM_NAME_MAP = new HashMap<>(); static { CUSTOM_NAME_MAP.put(""Coins"", 995); CUSTOM_NAME_MAP.put(""Tinderbox"", 590); CUSTOM_NAME_MAP.put(""Mystic hat (dark)"", 4099); CUSTOM_NAME_MAP.put(""Blue wizard robe"", 577); CUSTOM_NAME_MAP.put(""Blue wizard hat"", 579); CUSTOM_NAME_MAP.put(""Mystic robe top (dark)"", 4101); CUSTOM_NAME_MAP.put(""Mystic robe bottom (dark)"", 4103); CUSTOM_NAME_MAP.put(""Mystic gloves (dark)"", 4105); CUSTOM_NAME_MAP.put(""Mystic boots (dark)"", 4107); CUSTOM_NAME_MAP.put(""Mystic hat (light)"", 4109); CUSTOM_NAME_MAP.put(""Mystic robe top (light)"", 4111); CUSTOM_NAME_MAP.put(""Mystic robe bottom (light)"", 4113); CUSTOM_NAME_MAP.put(""Mystic gloves (light)"", 4115); CUSTOM_NAME_MAP.put(""Mystic boots (light)"", 4117); CUSTOM_NAME_MAP.put(""Adamantite bar"", 2361); CUSTOM_NAME_MAP.put(""Runite bar"", 2363); CUSTOM_NAME_MAP.put(""Grimy ranarr weed"", 207); CUSTOM_NAME_MAP.put(""Seers ring"", 6731); CUSTOM_NAME_MAP.put(""Archers ring"", 6733); CUSTOM_NAME_MAP.put(""Black cape"", 1019); CUSTOM_NAME_MAP.put(""Black robe"", 581); CUSTOM_NAME_MAP.put(""Zamorak monk bottom"", 1033); CUSTOM_NAME_MAP.put(""Zamorak monk top"", 1035); CUSTOM_NAME_MAP.put(""Pot"", 1931); CUSTOM_NAME_MAP.put(""Raw beef (undead)"", 4287); CUSTOM_NAME_MAP.put(""Raw chicken (undead)"", 4289); CUSTOM_NAME_MAP.put(""Right eye patch"", 1025); CUSTOM_NAME_MAP.put(""Gold amulet (u)"", 1673); CUSTOM_NAME_MAP.put(""Sapphire amulet (u)"", 1675); CUSTOM_NAME_MAP.put(""Emerald amulet (u)"", 1677); CUSTOM_NAME_MAP.put(""Ruby amulet (u)"", 1679); CUSTOM_NAME_MAP.put(""Diamond amulet (u)"", 1681); CUSTOM_NAME_MAP.put(""Gold amulet"", 1692); CUSTOM_NAME_MAP.put(""Sapphire amulet"", 1694); CUSTOM_NAME_MAP.put(""Emerald amulet"", 1696); CUSTOM_NAME_MAP.put(""Ruby amulet"", 1698); CUSTOM_NAME_MAP.put(""Diamond amulet"", 1700); CUSTOM_NAME_MAP.put(""Dragon chainbody"", 3140); CUSTOM_NAME_MAP.put(""Purple gloves"", 2942); CUSTOM_NAME_MAP.put(""Yellow gloves"", 2922); CUSTOM_NAME_MAP.put(""Red gloves"", 2912); CUSTOM_NAME_MAP.put(""Teal gloves"", 2932); CUSTOM_NAME_MAP.put(""Grain"", 1947); CUSTOM_NAME_MAP.put(""Red cape"", 1007); CUSTOM_NAME_MAP.put(""Blue cape"", 1021); CUSTOM_NAME_MAP.put("""", 00000); CUSTOM_NAME_MAP.put("""", 00000); CUSTOM_NAME_MAP.put("""", 00000); CUSTOM_NAME_MAP.put("""", 00000); CUSTOM_NAME_MAP.put("""", 00000); CUSTOM_NAME_MAP.put("""", 00000); CUSTOM_NAME_MAP.put("""", 00000); CUSTOM_NAME_MAP.put("""", 00000); CUSTOM_NAME_MAP.put("""", 00000); CUSTOM_NAME_MAP.put("""", 00000); CUSTOM_NAME_MAP.put("""", 00000); CUSTOM_NAME_MAP.put(""Dragon pickaxe"", -2); CUSTOM_NAME_MAP.put(""Dragon arrowtips"", -2); CUSTOM_NAME_MAP.put(""Dragon javelin heads"", -2); CUSTOM_NAME_MAP.put(""Dark fishing bait"", -2); CUSTOM_NAME_MAP.put(""Smouldering stone"", -2); CUSTOM_NAME_MAP.put(""Giant key"", -2); CUSTOM_NAME_MAP.put(""Looting bag"", -2); CUSTOM_NAME_MAP.put(""Ancient shard"", -2); CUSTOM_NAME_MAP.put(""Brimstone key"", -2); CUSTOM_NAME_MAP.put(""Dark totem base"", -2); CUSTOM_NAME_MAP.put(""Dark totem middle"", -2); CUSTOM_NAME_MAP.put(""Dark totem top"", -2); CUSTOM_NAME_MAP.put("""", -2); CUSTOM_NAME_MAP.put("""", -2); CUSTOM_NAME_MAP.put("""", -2); CUSTOM_NAME_MAP.put("""", -2); CUSTOM_NAME_MAP.put("""", -2); CUSTOM_NAME_MAP.put("""", -2); CUSTOM_NAME_MAP.put("""", -2); CUSTOM_NAME_MAP.put("""", -2); CUSTOM_NAME_MAP.put("""", -2); } public static boolean dumpNPC(String pageName) { try { WebPage page = new WebPage(""https://oldschool.runescape.wiki/w/""+pageName+""?action=raw""); try { page.load(); } catch (SocketTimeoutException e) { return dumpNPC(pageName); } catch (Exception e) { return false; } boolean accurate = false; String lastDesc = """"; String subName = """"; for (String line : page.getLines()) if (line.contains(""DropLogProject"")) { accurate = true; break; } if (!accurate) return false; boolean skipping = false; int tableNum = 1; ArrayList drops = new ArrayList<>(); for (String line : page.getLines()) { line = line.replace(""{"", """").replace(""}"", """"); if (line.contains(""=="")) lastDesc = line.toLowerCase().replace(""="", """").replace("" "", ""_"").replace(""drops "", """"); if (line.contains(""DropLogProject|jagex=yes"")) { if (drops.isEmpty()) subName = lastDesc; else finalizeDrops(pageName, subName.isEmpty() ? (pageName+""_sub""+tableNum) : (pageName+""_""+subName), drops); subName = lastDesc; } if (line.contains(""Deadman mode"") || line.contains(""Pickpocketing"")) skipping = true; if (line.contains(""DropsTableBottom"")) skipping = false; if (skipping) continue; int itemId = -1; int min = -1; int max = -1; double num = -1; double den = -1; String name = """"; if (line.contains(""RareDropTable/Sandbox|"")) { String[] rdt = line.split(""\\|""); if (rdt[1].toLowerCase().contains(""/"")) { String[] frac = rdt[1].replace(""~"", """").replace("" "", """").split(""/""); num = Double.valueOf(frac[0].trim()); den = Double.valueOf(frac[1].trim()); } if (num != -1 && den != -1) drops.add(new DropTable(num, den, ""rdt_standard"")); else System.out.println(""Failed parsing drop: RareDropTable/Sandbox: "" + itemId + "", "" + min + "", "" + max + "", "" + num + ""/"" + den); if (rdt[2].toLowerCase().contains(""/"")) { String[] frac = rdt[2].replace(""~"", """").replace("" "", """").split(""/""); num = Double.valueOf(frac[0].trim()); den = Double.valueOf(frac[1].trim()); } if (num != -1 && den != -1) drops.add(new DropTable(num, den, ""rdt_gem"")); else System.out.println(""Failed parsing drop: "" + name + "", "" + itemId + "", "" + min + "", "" + max + "", "" + num + ""/"" + den); } else if (line.equals(""GWDRDT"") || line.contains(""VariableAllotmentSeedDropTable|"") || line.contains(""FixedAllotmentSeedDropTable|"") || line.contains(""HerbDropTable|"") || line.contains(""GemDropTable|"") || line.contains(""ManySeedDropTable|"") || line.contains(""RareSeedDropTable|"")) addDropTable(line, drops); else if (line.contains(""Ensouled"") || line.contains(""Curved bone"") || line.contains(""Long bone"") || line.contains(""Rag and Bone"") || line.contains(""Clue scroll"") || line.contains(""Only dropped"") || line.contains(""f2p=yes"") || line.contains(""name=\""f2"")) continue; else if (line.contains(""DropsLine|"") && (line.contains(""/"") || line.toLowerCase().contains(""always""))) { String[] memes = line.split(""\\|""); for (String meme : memes) { String[] key = meme.split(""=""); if (key[0].toLowerCase().equals(""name"")) { name = key[1].replace(""("", "" ("").replace("" ("", "" (""); name = name.replace("" axe"", "" hatchet""); name = name.replace(""med helm"", ""helm""); name = name.replace(""dueling"", ""duelling""); name = name.replace("" leaf"", """"); name = name.replace(""d'hide vamb"", ""d'hide vambraces""); name = name.replace(""crossbow (u)"", ""c'bow (u)""); if (name.contains(""mix ("")) name = name.replace(""str."", ""strength"").replace(""Superattack"", ""Super attack"").replace(""def."", ""defence""); for (int i = 0;i < Utils.getItemDefinitionsSize();i++) if (ItemDefinitions.getDefs(i).getName().equalsIgnoreCase(name)) { itemId = i; break; } if (CUSTOM_NAME_MAP.get(name) != null) itemId = CUSTOM_NAME_MAP.get(name); } else if (key[0].toLowerCase().equals(""quantity"")) { if (key[1].toLowerCase().contains(""(noted)"")) { key[1] = key[1].toLowerCase().replace("" (noted)"", """").replace(""(noted)"", """"); itemId = ItemDefinitions.getDefs(itemId).getCertId(); } if (key[1].contains("","")) { key[1] = key[1].replace("" "", """"); String[] minMax = key[1].split("",""); min = Integer.valueOf(minMax[0].trim()); max = Integer.valueOf(minMax[1].trim()); } else if (key[1].contains(""-"")) { String[] minMax = key[1].split(""-""); min = Integer.valueOf(minMax[0].trim()); max = Integer.valueOf(minMax[1].trim()); } else { min = Integer.valueOf(key[1].replace("" "", """").trim()); max = min; } } else if (key[0].toLowerCase().equals(""rarity"")) { if (key[1].toLowerCase().contains(""always"")) { num = 0; den = 0; } if (key[1].toLowerCase().contains(""/"")) { String[] frac = key[1].replace(""~"", """").replace("" "", """").split(""/""); num = Double.valueOf(frac[0].trim()); den = Double.valueOf(frac[1].trim()); } } else if (key[0].toLowerCase().equals(""altrarity"")) { if (key[1].toLowerCase().contains(""always"")) { num = 0; den = 0; } if (key[1].toLowerCase().contains(""/"")) { String[] frac = key[1].replace(""~"", """").replace("" "", """").split(""/""); num = Double.valueOf(frac[0].trim()); den = Double.valueOf(frac[1].trim()); } } } if (itemId >= 0 && min != -1 && max != -1 && num != -1 && den != -1) drops.add(new DropTable(num, den, itemId, min, max)); else { if (itemId == -1) System.out.println(pageName + "" Error -> Unknown item: "" + name); if (min == -1 || max == -1) System.out.println(pageName + "" Error -> Failed to parse min/max of ""+name+"": "" + min + "", "" + max); if (num == -1 || den == -1) System.out.println(pageName + "" Error -> Failed to parse rate of ""+name+"": "" + num + "", "" + den); } } } finalizeDrops(pageName, subName.isEmpty() ? pageName : (pageName + ""_"" + subName), drops); return true; } catch (Exception e) { e.printStackTrace(); } return false; } private static void addDropTable(String line, List drops) { try { String[] memes = line.split(""\\|""); double num = -1, den = -1; String tableName = """"; if (line.contains(""ManySeedDropTable|"")) tableName = ""common_seeds""; else if (line.contains(""FixedAllotmentSeedDropTable|"")) tableName = ""fixed_allotment""; else if (line.contains(""RareSeedDropTable|"")) tableName = ""rare_seeds""; else if (line.contains(""VariableAllotmentSeedDropTable|"")) tableName = ""variable_allotment""; else if (line.contains(""HerbDropTable|"")) tableName = ""herb""; else if (line.contains(""GemDropTable|"")) tableName = ""rdt_gem""; else if (line.contains(""GWDRDT"")) { drops.add(new DropTable(8, 127, ""rdt_standard_gwd"")); drops.add(new DropTable(2, 127, ""rdt_gem_gwd"")); return; } if (memes[1].toLowerCase().contains(""/"")) { String[] frac = memes[1].replace(""~"", """").replace("" "", """").split(""/""); num = Double.valueOf(frac[0].trim()); den = Double.valueOf(frac[1].trim()); } if (num != -1 && den != -1 && !tableName.isEmpty()) drops.add(new DropTable(num, den, tableName)); else System.out.println(""Failed parsing drop: table:"" + tableName + "", "" + num + ""/"" + den); } catch(Exception e) { System.err.println(""Failed to parse drop: "" + line); } } public static void finalizeDrops(String pageName, String name, List drops) { System.out.println(""Finalizing drop: "" + name + "" "" + drops.size()); drops.sort((o1, o2) -> Double.compare(o2.getRate() == 0.0 ? 100.0 : o2.getRate(), o1.getRate() == 0.0 ? 100.0 : o1.getRate())); try { DropTable[] dropArr = new DropTable[drops.size()]; for (int i = 0;i < drops.size();i++) dropArr[i] = drops.get(i); DropSet table = new DropSet(null, new String[] { pageName.replace(""_"", "" "") }, dropArr); table.createDropList(); if (table.getDropList() == null) { System.out.println(""Empty drop list for "" + name); return; } if (table.isOverflowed()) System.out.println(""Overflowed: "" + name.toLowerCase()); if (name.toLowerCase().contains(""revenant"") || name.toLowerCase().contains(""kourend"")) return; JsonFileManager.saveJsonFile(table, new File(""./dumps/""+(table.isOverflowed() ? ""overflowed"" : ""success"")+""/""+name.toLowerCase().replace("" "", ""_"").replace(""_drops"", """")+"".json"")); } catch (Exception e) { e.printStackTrace(); } drops.clear(); } }" "package com.rs.tools; public class NPCListDumper { public static void main(String[] args) throws IOException { //Cache.init(); File file = new File(""npcsThatTransform.txt""); if (file.exists()) file.delete(); else file.createNewFile(); BufferedWriter writer = new BufferedWriter(new FileWriter(file)); writer.append(""//Version = 727\n""); writer.flush(); for (int id = 0; id < Utils.getNPCDefinitionsSize(); id++) { NPCDefinitions def = NPCDefinitions.getDefs(id); if (def.varp == -1 && def.varpBit == -1) continue; writer.append(String.valueOf(id)).append("" - "").append(def.getName()).append("" transforms to ""); for (int tf : def.transformTo) writer.append(String.valueOf(tf)).append("" ("").append(NPCDefinitions.getDefs(tf).getName()).append(""), ""); writer.newLine(); writer.flush(); } writer.close(); } }" "package com.rs.tools; public class NPCSpawnChecker { public static void main(String[] args) throws IOException { //Cache.init(); NPCSpawns.init(); for (NPCSpawn spawn : NPCSpawns.getAllSpawns()) { NPCDefinitions defs = NPCDefinitions.getDefs(spawn.getNPCId()); if (defs.getConfigInfoString().contains(""transformed into by"")) System.out.println(""NPC: "" + defs.getName()); } } }" "package com.rs.tools; public class ObjectListDumper { public static void main(String[] args) throws IOException { //Cache.init(); File file = new File(""objectlist.txt""); if (file.exists()) file.delete(); else file.createNewFile(); BufferedWriter writer = new BufferedWriter(new FileWriter(file)); writer.append(""//Version = 727\n""); writer.flush(); for (int id = 0; id < Utils.getObjectDefinitionsSize(); id++) { ObjectDefinitions def = ObjectDefinitions.getDefs(id); // if (def.getConfigInfoString().isEmpty()) // continue; // writer.append(id + "" - "" + def.getName() + def.getConfigInfoString()); writer.append(String.valueOf(id)).append("" - "").append(def.getName()).append("" "").append(Arrays.toString(def.types)).append("" "").append(Arrays.toString(def.options)); writer.newLine(); writer.flush(); } writer.close(); } }" "package com.rs.tools; public class Test { public static void main(String[] args) throws IOException { JsonFileManager.setGSON(new GsonBuilder() .registerTypeAdapter(Controller.class, new ControllerAdapter()) .registerTypeAdapter(Date.class, new DateAdapter()) .registerTypeAdapter(PacketEncoder.class, new PacketEncoderAdapter()) .registerTypeAdapter(Packet.class, new PacketAdapter()) .registerTypeAdapterFactory(new RecordTypeAdapterFactory()) .disableHtmlEscaping() .setPrettyPrinting() .create()); Settings.loadConfig(); } }" "package com.rs.tools; public class VerifyDrops { private static final Map NAMES = new HashMap<>(); private static final int ITEM_TO_SEARCH_FOR = 14642; public static void main(String[] args) throws IOException { //Cache.init(); System.out.println(""Checking dumps folder...""); File[] dumpFiles = new File(""./dumps/"").listFiles(); for (File f : dumpFiles) loadFile(f); NAMES.clear(); System.out.println(""Checking drops folder...""); File[] dropFiles = new File(""./data/npcs/drops/"").listFiles(); for (File f : dropFiles) loadFile(f); } public static void loadFile(File f) throws JsonIOException, IOException { try { if (f.isDirectory()) { for (File dir : f.listFiles()) loadFile(dir); return; } DropSet set = (DropSet) JsonFileManager.loadJsonFile(f, DropSet.class); if (set != null) { set.getDropList(); if (set.getNames() != null && set.getNames().length > 0) for (String n : set.getNames()) { String prev = NAMES.put(n, f.getName()); if (prev != null) { System.err.println(""Duplicate table for: "" + prev); System.err.println(""Duplicate table for: "" + f.getName()); } } for (DropEntry drop : set.getDropList().getDrops()) { if (drop.getTable() == null || drop.getTable().getDrops() == null || drop.getTable().getDrops().length <= 0) continue; if (drop.getTable().getDrops()[0].getId() == ITEM_TO_SEARCH_FOR) System.out.println(ItemDefinitions.getDefs(ITEM_TO_SEARCH_FOR).getName() + "" in "" + f.getName()); } if (set.isOverflowed()) System.out.println(""Overflow in "" + f.getName()); } } catch (Exception e) { System.err.println(""Exception loading: "" + f.getName()); e.printStackTrace(); System.exit(1); } } }" "package com.rs.tools.old; public final class BeastiaryInfo { public static void main(String[] args) throws IOException { Cache.init(Settings.getConfig().getCachePath()); createData(); } class Animations { int death; int attack; } class BestiaryInfo { int magic; int defence; int level; int ranged; int attack; int size; int lifepoints; double xp; int id; Animations animations; boolean poisonous; boolean members; boolean aggressive; String weakness; boolean attackable; String description; String name; String[] areas; } private static final Map beasts = new HashMap<>(); private static void loadBeastData() throws IOException { BufferedReader in = new BufferedReader(new FileReader(new File(""./beasts.txt""))); while (true) { String line = in.readLine(); if (line == null) { in.close(); break; } Gson gson = new GsonBuilder().create(); BestiaryInfo bi = gson.fromJson(line, BestiaryInfo.class); if (bi.id == 0) continue; beasts.put(bi.id, bi); } } private static void createData() { try { loadBeastData(); try (BufferedWriter writer = new BufferedWriter(new FileWriter(new File(""backupAnimations.txt"")))) { for (int npcId = 0; npcId < Utils.getNPCDefinitionsSize(); npcId++) { NPCDefinitions def = NPCDefinitions.getDefs(npcId); BestiaryInfo line = beasts.remove(npcId); if (line == null || !def.getName().equals(line.name) || (line.animations.attack == 0 && line.animations.death == 0)) continue; writer.write(""//"" + def.getName() + "" ("" + def.combatLevel + "")""); writer.newLine(); writer.write(npcId + "" - "" + (line.animations.attack > Utils.getAnimationDefinitionsSize() ? -1 : line.animations.attack) + "" "" + (line.animations.death > Utils.getAnimationDefinitionsSize() ? -1 : line.animations.death)); writer.newLine(); writer.flush(); } } catch (Exception e) { e.printStackTrace(); } } catch (IOException e) { e.printStackTrace(); } } private BeastiaryInfo() { } }" "package com.rs.tools.old; @PluginEventHandler public class CharmDrop { private final static String PACKED_PATH = ""data/npcs/charmDrops.txt""; private static HashMap charmDrops; final static Charset ENCODING = StandardCharsets.UTF_8; public static int getCharmAmount(String npcName) { return switch (npcName) { case ""brutal green dragon"", ""iron dragon"", ""rock lobster"", ""skeletal wyvern"" -> 2; case ""black dragon"", ""giant rock crab"", ""glacor"", ""steel dragon"", ""tormented demon"" -> 3; case ""king black dragon"", ""mithril dragon"" -> 4; case ""corporeal beast"" -> 13; case ""nex"" -> 20; default -> 1; }; } public static int getCharmType(int[] chances) { int goldRate = chances[0]; int greenRate = chances[1]; int crimRate = chances[2]; int blueRate = chances[3]; ArrayList possibleCharms = new ArrayList<>(); int rand = Utils.getRandomInclusive(100); if (rand <= (blueRate) && blueRate != 0) possibleCharms.add(3); if (rand <= (crimRate) && crimRate != 0) possibleCharms.add(2); if (rand <= (greenRate) && greenRate != 0) possibleCharms.add(1); if (rand <= (goldRate) && goldRate != 0) possibleCharms.add(0); if (possibleCharms.isEmpty()) return -1; Collections.shuffle(possibleCharms); return possibleCharms.get(Utils.random(possibleCharms.size())); } public static DropTable getCharmDrop(String npcName) { String lowerName = npcName.toLowerCase(); int[] chances = charmDrops.get(lowerName.replace("" "", ""_"")); if (chances == null) return null; int charmIndex = getCharmType(chances); int amount = getCharmAmount(lowerName); if (charmIndex == -1) { switch(lowerName) { case ""abyssal walker"" -> { if (Utils.random(4) == 0) return new DropTable(0, 0, 12161, 2, 2); } case ""abyssal guardian"", ""abyssal leech"" -> { if (Utils.random(4) == 0) return new DropTable(0, 0, 12161, 1, 1); } } return null; } DropTable charm = new DropTable(0, 0, ItemConstants.CHARM_IDS[charmIndex], amount, amount); return charm; } @ServerStartupEvent(Priority.FILE_IO) public static void loadCharmDrops() { try { charmDrops = new HashMap<>(); Path path = Paths.get(PACKED_PATH); try (Scanner scanner = new Scanner(path, ENCODING.name())) { int lineNumber = 0; String npcName = null; int[] charmPerc = new int[4]; while (scanner.hasNextLine()) { String line = scanner.nextLine(); lineNumber++; if (line.startsWith(""//"") || line.isEmpty()) continue; String[] subs = line.split("":""); String[] info = subs[1].split(""-""); npcName = subs[0]; charmPerc[0] = Integer.parseInt(info[0]); charmPerc[1] = Integer.parseInt(info[1]); charmPerc[2] = Integer.parseInt(info[2]); charmPerc[3] = Integer.parseInt(info[3]); charmDrops.put(npcName, new int[] {charmPerc[0], charmPerc[1], charmPerc[2], charmPerc[3]}); } Logger.info(CharmDrop.class, ""loadCharmDrops"", ""Parsed "" + lineNumber + "" lines of NPC charm drops.""); } } catch (Throwable e) { Logger.handle(CharmDrop.class, ""loadCharmDrops"", e); } } }" "package com.rs.tools.old; public class DumpItemRenderIds { public static void main(String[] args) throws IOException { //Cache.init(); dumpRenders(); } public static void dumpRenders() throws IOException { File file = new File(""./renderids.txt""); if (file.exists()) file.delete(); BufferedWriter writer = new BufferedWriter(new FileWriter(file)); for (int i = 0; i < 13247; i++) { ItemDefinitions def = ItemDefinitions.getDefs(i); if (def == null) continue; writer.write(i + ""="" + def.getRenderAnimId()); writer.newLine(); } writer.flush(); writer.close(); System.out.println(""Dumped all render ids.""); } }" "package com.rs.tools.old; public class IComponentSettingsBuilder { /** * Contains the value which should be sended in access mask packet. */ private int value; /** * Set's standart option settings. Great example of standart click option is * the Continue button in dialog interface. If the option is not allowed the * packet won't be send to server. * * @param allowed */ public void setStandartClickOptionSettings(boolean allowed) { value &= ~(0x1); if (allowed) value |= 0x1; } /** * Set's right click option settings. Great example of right click option is * the Dismiss option in summoning orb. If specified option is not allowed , * it will not appear in right click menu and the packet will not be send to * server when clicked. */ public void setRightClickOptionSettings(int optionID, boolean allowed) { if (optionID < 0 || optionID > 9) throw new IllegalArgumentException(""optionID must be 0-9.""); value &= ~(0x1 << (optionID + 1)); // disable if (allowed) value |= (0x1 << (optionID + 1)); } /** * Sets use on settings. By use on , I mean the options such as Cast in * spellbook or use in inventory. If nothing is allowed then 'use' option * will not appear in right click menu. */ public void setUseOnSettings(boolean canUseOnGroundItems, boolean canUseOnNpcs, boolean canUseOnObjects, boolean canUseOnNonselfPlayers, boolean canUseOnSelfPlayer, boolean canUseOnInterfaceComponent) { int useFlag = 0; if (canUseOnGroundItems) useFlag |= 0x1; if (canUseOnNpcs) useFlag |= 0x2; if (canUseOnObjects) useFlag |= 0x4; if (canUseOnNonselfPlayers) useFlag |= 0x8; if (canUseOnSelfPlayer) useFlag |= 0x10; if (canUseOnInterfaceComponent) useFlag |= 0x20; value &= ~(127 << 7); // disable value |= useFlag << 7; } /** * Set's interface events depth. For example, we have inventory interface * which is opened on gameframe interface (548 or 746). If depth is 1 , then * the clicks in inventory will also invoke click event handler scripts on * gameframe interface. */ public void setInterfaceEventsDepth(int depth) { if (depth < 0 || depth > 7) throw new IllegalArgumentException(""depth must be 0-7.""); value &= ~(0x7 << 18); value |= (depth << 18); } /** * Set's canUseOnFlag. if it's true then other interface components can do * use on this interface component. Example would be using High alchemy * spell on the inventory item. If inventory component where items are * stored doesn't allow the canUseOn , it would not be possible to use High * Alchemy on that item. */ public void setCanUseOn(boolean allow) { value &= ~(1 << 22); if (allow) value |= (1 << 22); } public int getValue() { return value; } }" "package com.rs.tools.old; public class InterfaceName { public static final char[] VALID_CHARS = { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z' }; public static void printAllCombinations4Letters() { } /** * @param args * @throws IOException */ public static void main(String[] args) throws IOException { Store rscache = new Store(""data/cache/""); System.out.println(rscache.getIndex(IndexType.INTERFACES).getTable().isNamed()); System.out.println(rscache.getIndex(IndexType.INTERFACES).getArchiveId(""chat"")); System.out.println(CacheUtil.getNameHash(""price checker"")); /* * System.out.println(Utils.getNameHash(""prayer"")); * System.out.println(Utils.unhash(Utils.getNameHash(""t""))); */ // System.out.println(Utils.getNameHash(""prayer"")); /* * int hash = * rscache.getIndexes()[Constants.INTERFACE_DEFINITIONS_INDEX] * .getTable().getArchives()[884].getNameHash(); for(char l1 : * VALID_CHARS) { System.out.println(l1); for(char l2 : VALID_CHARS) { * for(char l3 : VALID_CHARS) { * * for(char l4 : VALID_CHARS) { for(char l5 : VALID_CHARS) { for(char l6 * : VALID_CHARS) { String name = new String(new char[] {l1, l2, l3, * l4,l5, l6}); if(Utils.getNameHash(name) == hash) * System.out.println(name); } } } } } } */ } }" "package com.rs.tools.old; public class ItemCheck { public static void main(String[] args) throws IOException { //Cache.init(); int total = 0; for (int itemId = 0; itemId < Utils.getItemDefinitionsSize(); itemId++) if (ItemDefinitions.getDefs(itemId).isWearItem(true) && !ItemDefinitions.getDefs(itemId).isNoted()) { File file = new File(""bonuses/"" + itemId + "".txt""); if (!file.exists()) { System.out.println(file.getName()); total++; } } System.out.println(""Total "" + total); } }" "package com.rs.tools.old; public class LocationFinder { public static int getArchiveId(int regionX, int regionY) { return regionX | regionY << 7; } public static void main(String[] args) throws IOException { //Cache.init(); MapXTEAs.loadKeys(); // Region region; // region = new Region(11826); // region.loadRegionMap(); // System.out.println(""""+region.getAllObjects().size()); // for (int regionId = 0; regionId < 16000;regionId++) { //for (int y = 0; y < 10000; y += 64) { //int regionId = Tile.of(x, y, 0).getRegionId(); int regionId = 11826; int regionX = (regionId >> 8) * 64; int regionY = (regionId & 0xff) * 64; //int landArchiveId = 2075; //int mapArchiveId = 2075; int landArchiveId = Cache.STORE.getIndex(IndexType.MAPS).getArchiveId(""l"" + ((regionX >> 3) / 8) + ""_"" + ((regionY >> 3) / 8)); byte[] landContainerData = landArchiveId == -1 ? null : Cache.STORE.getIndex(IndexType.MAPS).getFile(landArchiveId, 0, MapXTEAs.getMapKeys(regionId)); int mapArchiveId = Cache.STORE.getIndex(IndexType.MAPS).getArchiveId(""m"" + ((regionX >> 3) / 8) + ""_"" + ((regionY >> 3) / 8)); byte[] mapContainerData = mapArchiveId == -1 ? null : Cache.STORE.getIndex(IndexType.MAPS).getFile(mapArchiveId, 0); System.out.println("""" + landArchiveId + "", "" + mapArchiveId); System.out.println("""" + landContainerData + "", "" + mapContainerData); // int landArchiveId = getArchiveId(((regionX >> 3) / 8), ((regionY >> 3) / 8)); // byte[] landContainerData = landArchiveId == -1 ? null : Cache.STORE.getIndexes()[5].getFile(landArchiveId, 0); // // int mapArchiveId = Cache.STORE.getIndexes()[5].getArchiveId(""m"" + // // ((regionX >> 3) / 8) + ""_"" + ((regionY >> 3) / 8)); // int mapArchiveId = getArchiveId(((regionX >> 3) / 8), ((regionY >> 3) / 8)); // byte[] mapContainerData = mapArchiveId == -1 ? null : Cache.STORE.getIndexes()[5].getFile(mapArchiveId, 3); byte[][][] mapSettings = mapContainerData == null ? null : new byte[4][64][64]; if (mapContainerData != null) { InputStream mapStream = new InputStream(mapContainerData); for (int plane = 0; plane < 4; plane++) for (int x = 0; x < 64; x++) for (int y = 0; y < 64; y++) while (true) { int value = mapStream.readUnsignedByte(); if (value == 0) break; if (value == 1) { mapStream.readByte(); break; } if (value <= 49) mapStream.readByte(); else if (value <= 81) mapSettings[plane][x][y] = (byte) (value - 49); } } else for (int plane = 0; plane < 4; plane++) for (int x = 0; x < 64; x++) for (int y = 0; y < 64; y++) { } if (landContainerData != null) { InputStream landStream = new InputStream(landContainerData); int objectId = -1; int incr; while ((incr = landStream.readSmart2()) != 0) { objectId += incr; int location = 0; int incr2; while ((incr2 = landStream.readUnsignedSmart()) != 0) { location += incr2 - 1; int localX = (location >> 6 & 0x3f); int localY = (location & 0x3f); int plane = location >> 12; int objectData = landStream.readUnsignedByte(); int type = objectData >> 2; int rotation = objectData & 0x3; if (localX < 0 || localX >= 64 || localY < 0 || localY >= 64) continue; int objectPlane = plane; if (mapSettings != null && (mapSettings[1][localX][localY] & 2) == 2) objectPlane--; if (objectPlane < 0 || objectPlane >= 4 || plane < 0 || plane >= 4) continue; GameObject obj = new GameObject(objectId, ObjectType.forId(type), rotation, localX + regionX, localY + regionY, objectPlane); System.out.println(""Object: "" + obj.getDefinitions().getName() + "", "" + objectId); } } } //} } // } }" "package com.rs.tools.old; public class MapDump { private static final int SIZE = 200; public static void main(String[] args) throws IOException { //Cache.init(); MapXTEAs.loadKeys(); File outputfile = new File(""map.png""); ImageIO.write(getMap(0), ""png"", outputfile); } @SuppressWarnings(""unused"") public static BufferedImage getMap(int z) { int[][] rgb = new int[SIZE * 64][SIZE * 64]; int[] a1 = new int[(64 * SIZE) * (64 * SIZE)]; int[] a2 = new int[(64 * SIZE) * (64 * SIZE)]; int[] a3 = new int[(64 * SIZE) * (64 * SIZE)]; int[] a4 = new int[(64 * SIZE) * (64 * SIZE)]; int[] a5 = new int[(64 * SIZE) * (64 * SIZE)]; BufferedImage img = new BufferedImage(rgb.length, rgb[0].length, BufferedImage.TYPE_INT_RGB); int[][] overlayIds = new int[64 * SIZE][64 * SIZE]; int[][] underlayIds = new int[64 * SIZE][64 * SIZE]; int[][] dataOpcodes = new int[64 * SIZE][64 * SIZE]; int[][] shapes = new int[64 * SIZE][64 * SIZE]; int[][] overlayRotations = new int[64 * SIZE][64 * SIZE]; int[][] heights = new int[64 * SIZE][64 * SIZE]; int[][] masks = new int[64 * SIZE][64 * SIZE]; for (int rx = 0; rx < SIZE; rx++) for (int ry = 0; ry < SIZE; ry++) { int regionId = (rx << 8) | ry; int regionX = (regionId >> 8) * 64; int regionY = (regionId & 0xff) * 64; int mapArchiveId = Cache.STORE.getIndex(IndexType.MAPS).getArchiveId(""m"" + ((regionX >> 3) / 8) + ""_"" + ((regionY >> 3) / 8)); byte[] data = mapArchiveId == -1 ? null : Cache.STORE.getIndex(IndexType.MAPS).getFile(mapArchiveId, 0); if (data == null) continue; if (data != null) { InputStream mapStream = new InputStream(data); for (int plane = 0; plane < 4; plane++) for (int x = 0; x < 64; x++) for (int y = 0; y < 64; y++) while (true) { int value = mapStream.readUnsignedByte(); if (plane == 0) dataOpcodes[rx * 64 + x][ry * 64 + y] = value; if (value == 0) break; if (value == 1) { int v = mapStream.readUnsignedByte(); if (plane == 0) heights[rx * 64 + x][ry * 64 + y] = v; break; } if (value <= 49) { int v = mapStream.readUnsignedByte(); if (plane == 0) { overlayIds[rx * 64 + x][ry * 64 + y] = v; shapes[rx * 64 + x][ry * 64 + y] = (byte) ((value - 2) / 4); overlayRotations[rx * 64 + x][ry * 64 + y] = (byte) ((value - 2) & 0x3); } } else if (value <= 81) { if (plane == 0) masks[rx * 64 + x][ry * 64 + y] = (byte) (value - 49); } else if (plane == 0) underlayIds[rx * 64 + x][ry * 64 + y] = (value - 81); } } } for (int x = -5; x < rgb.length; x++) { for (int y = 0; y < rgb[0].length; y++) { int x2 = 5 + x; if (x2 < rgb.length) { int i_98_ = ((underlayIds[x2][y]) & 0x7fff); if (i_98_ > 0) { UnderlayDefinitions defs = UnderlayDefinitions.getUnderlayDefinitions(i_98_ - 1); a1[y] += defs.r; a2[y] += defs.g; a3[y] += defs.b; a4[y] += defs.a; a5[y]++; } } int x3 = x - 5; if (x3 >= 0) { int i_100_ = ((underlayIds[x3][y]) & 0x7fff); if (i_100_ > 0) { UnderlayDefinitions defs = UnderlayDefinitions.getUnderlayDefinitions(i_100_ - 1); a1[y] -= defs.r; a2[y] -= defs.g; a3[y] -= defs.b; a4[y] -= defs.a; a5[y]--; } } } if (x >= 0) { int c1 = 0; int c2 = 0; int c3 = 0; int r2 = 0; int r3 = 0; for (int y = -5; y < rgb[0].length; y++) { int i_107_ = y + 5; if (i_107_ < rgb[0].length) { c1 += a1[i_107_]; c2 += a2[i_107_]; c3 += a3[i_107_]; r2 += a4[i_107_]; r3 += a5[i_107_]; } int i_108_ = y - 5; if (i_108_ >= 0) { c1 -= a1[i_108_]; c2 -= a2[i_108_]; c3 -= a3[i_108_]; r2 -= a4[i_108_]; r3 -= a5[i_108_]; } if (y >= 0 && r3 > 0) rgb[x][y] = new Color(c1 / r3, c2 / r3, c3 / r3).getRGB(); } } } for (int x = 0; x < rgb.length; x++) for (int y = 0; y < rgb[0].length; y++) if (((overlayIds[x][y]) & 0x7fff) > 0) { OverlayDefinitions defs = OverlayDefinitions.getOverlayDefinitions(((overlayIds[x][y]) & 0x7fff) - 1); int col = defs.primaryRgb == -1 || defs.primaryRgb == 16711935 || defs.primaryRgb == 0 ? defs.secondaryRgb : defs.primaryRgb; if (col == 0 || col == -1 || col == 16711935) col = 0; if (col == 0 && defs.texture != -1) col = TextureDefinitions.getDefinitions(defs.texture & 0xFF).color; img.setRGB(x, (rgb[0].length - 1) - y, new Color(col).getRGB()); } else if (((shapes[x][y]) & 0x7fff) > 0) { OverlayDefinitions defs = OverlayDefinitions.getOverlayDefinitions(((shapes[x][y]) & 0x7fff) - 1); int col = defs.primaryRgb == -1 || defs.primaryRgb == 16711935 || defs.primaryRgb == 0 ? defs.secondaryRgb : defs.primaryRgb; if (col == 0 || col == -1 || col == 16711935) col = 0; img.setRGB(x, (rgb[0].length - 1) - y, new Color(col).getRGB()); } else { // //RAW rgb setting no blending // UnderlayDefinitions defs = UnderlayDefinitions.getUnderlayDefinitions(((underlayData[(int) (x / scale)][(int) (y / scale)]) & 0x7fff) - 1); // int col = defs.rgb == -1 || defs.rgb == 16711935 || defs.rgb == 0 ? defs.rgb : defs.rgb; // if (col == 0 || col == -1 || col == 16711935) { // col = 0; // } // img.setRGB(x, (rgb[0].length - 1) - y, new Color(defs.r, defs.g, defs.b).getRGB()); //img.setRGB(x, (rgb[0].length - 1) - y, rgb[x][y]); } for (int rx = 0; rx < SIZE; rx++) for (int ry = 0; ry < SIZE; ry++) { int regionId = (rx << 8) | ry; int regionX = (regionId >> 8) * 64; int regionY = (regionId & 0xff) * 64; int landArchiveId = Cache.STORE.getIndex(IndexType.MAPS).getArchiveId(""l"" + ((regionX >> 3) / 8) + ""_"" + ((regionY >> 3) / 8)); byte[] data = landArchiveId == -1 ? null : Cache.STORE.getIndex(IndexType.MAPS).getFile(landArchiveId, 0, MapXTEAs.getMapKeys(regionId)); if (data == null) continue; InputStream landStream = new InputStream(data); int objectId = -1; int incr; while ((incr = landStream.readSmart2()) != 0) { objectId += incr; int location = 0; int incr2; while ((incr2 = landStream.readUnsignedSmart()) != 0) { location += incr2 - 1; int localX = (location >> 6 & 0x3f); int localY = (location & 0x3f); int plane = location >> 12; int objectData = landStream.readUnsignedByte(); int type = objectData >> 2; int rotation = objectData & 0x3; if (localX < 0 || localX >= 64 || localY < 0 || localY >= 64) continue; if (plane == z) { int mapSpriteId = ObjectDefinitions.getDefs(objectId).mapSpriteId; if (mapSpriteId == -1) continue; int spriteId = MapSpriteDefinitions.getMapSpriteDefinitions(mapSpriteId).spriteId; if (spriteId == -1) continue; SpriteDefinitions sprite = new SpriteDefinitions(Cache.STORE, spriteId, 0); BufferedImage s = sprite.getImages()[0]; int width = s.getWidth()/2; int height = s.getHeight()/2; if (width == 0 || height == 0) continue; //img.getGraphics().drawImage(s.getScaledInstance(width, height, 0), (int) ((rx * 64 + localX)), (int) (((SIZE * 64 - 1) - (ry * 64 + localY))), null); } } } } return img; } public static int getV(int i, int i_1_, int i_2_) { if (i_2_ > 243) i_1_ >>= 4; else if (i_2_ > 217) i_1_ >>= 3; else if (i_2_ > 192) i_1_ >>= 2; else if (i_2_ > 179) i_1_ >>= 1; return (i_2_ >> 1) + (((i & 0xff) >> 2 << 10) + (i_1_ >> 5 << 7)); } }" "package com.rs.tools.old; public class MapGenerator extends JFrame implements MouseListener, MouseMotionListener, MouseWheelListener { private static final long serialVersionUID = -6054276817868497393L; public static void main(String[] args) throws IOException { //Cache.init(); MapXTEAs.loadKeys(); new MapGenerator(); } public MapGenerator() { xPos = 1500; yPos = 1500; scale = 1; ratio = 20; setTitle(""Map Viewer""); setSize(640, 640); setVisible(true); addMouseListener(this); addMouseMotionListener(this); addMouseWheelListener(this); setDefaultCloseOperation(EXIT_ON_CLOSE); checkLoad(); } private int xPos; private int yPos; private int planePos; private int maxRX; private int maxRY; private int rxPos; private int ryPos; private final int ratio; private double scale; private BufferedImage map; private boolean loading; private boolean forceNoRefresh; public void checkLoad() { if (!loading) { final int newRX = xPos / 64; final int newRY = yPos / 64; final int newMaxRX = (int) ((getWidth() / 64) / scale) + (int) (1 * scale) + ratio * 2; final int newMaxRY = (int) ((getHeight() / 64) / scale) + (int) (1 * scale) + ratio * 2; if (Math.abs(newRX - rxPos) >= ratio / 2 || Math.abs(newRY - ryPos) >= ratio / 2 || newMaxRX != maxRX || newMaxRY != maxRY || forceNoRefresh) { loading = true; repaint(); Thread t = new Thread(() -> { map = getMap(newRX, newRY, newMaxRX, newMaxRY); rxPos = newRX; ryPos = newRY; maxRX = newMaxRX; maxRY = newMaxRY; loading = false; forceNoRefresh = false; repaint(); }); t.setPriority(Thread.MIN_PRIORITY); t.setDaemon(true); t.start(); } } } @Override public void paint(Graphics g) { // for (int x = 0; x < 10; x++) { // for (int y = 0; y < 10; y++) { // int regionId = ((x + xPos) << 8) | (y + yPos); // BufferedImage[] data = getMap(regionId); // if (data == null) // continue; // g.drawImage(data[planePos], x * 64, 640 - y * 64, null); // // } // } BufferedImage screen = new BufferedImage(getWidth(), getHeight(), BufferedImage.TYPE_INT_RGB); Graphics g2 = screen.getGraphics(); int localX = xPos & 63; int localY = yPos & 63; if (map != null && !forceNoRefresh) g2.drawImage(map, (int) (((-localX) + (rxPos - xPos / 64) * 64 - ratio * 64) * scale), (int) ((-((64 + (ryPos - yPos / 64) * 64 + ratio * 64) - localY)) * scale), this); g2.setColor(Color.PINK); if (loading) g2.drawString(""Loading"", 50, 50); if (mouseLocation2 != null) { int[] pos = getPos(); g2.drawString(""Position: "" + pos[0] + "", "" + pos[1], 50, 60); } g2.dispose(); g.drawImage(screen, 0, 0, this); } public int[] getPos() { return new int[] { (int) (xPos + ratio * 64 + mouseLocation2.getX() / scale), (int) (yPos + ratio * 64 + (getHeight() - mouseLocation2.getY() / scale)) }; } @SuppressWarnings(""unused"") public BufferedImage getMap(int rxPos, int ryPos, int maxRX, int maxRY) { int[][] rgb = new int[(int) (maxRX * 64 * scale)][(int) (maxRY * 64 * scale)]; int[] a1 = new int[(int) ((64 * maxRX) * (64 * maxRY) * scale)]; int[] a2 = new int[(int) ((64 * maxRX) * (64 * maxRY) * scale)]; int[] a3 = new int[(int) ((64 * maxRX) * (64 * maxRY) * scale)]; int[] a4 = new int[(int) ((64 * maxRX) * (64 * maxRY) * scale)]; int[] a5 = new int[(int) ((64 * maxRX) * (64 * maxRY) * scale)]; BufferedImage img = new BufferedImage(rgb.length, rgb[0].length, BufferedImage.TYPE_INT_RGB); int[][] overlayIds = new int[64 * maxRX][64 * maxRY]; int[][] underlayIds = new int[64 * maxRX][64 * maxRY]; int[][] dataOpcodes = new int[64 * maxRX][64 * maxRY]; int[][] shapes = new int[64 * maxRX][64 * maxRY]; int[][] overlayRotations = new int[64 * maxRX][64 * maxRY]; int[][] heights = new int[64 * maxRX][64 * maxRY]; int[][] masks = new int[64 * maxRX][64 * maxRY]; for (int rx = 0; rx < maxRX; rx++) for (int ry = 0; ry < maxRY; ry++) { int regionId = ((rx + rxPos) << 8) | (ry + ryPos); int regionX = (regionId >> 8) * 64; int regionY = (regionId & 0xff) * 64; int mapArchiveId = Cache.STORE.getIndex(IndexType.MAPS).getArchiveId(""m"" + ((regionX >> 3) / 8) + ""_"" + ((regionY >> 3) / 8)); byte[] data = mapArchiveId == -1 ? null : Cache.STORE.getIndex(IndexType.MAPS).getFile(mapArchiveId, 0); if (data == null) continue; if (data != null) { InputStream mapStream = new InputStream(data); for (int plane = 0; plane < 4; plane++) for (int x = 0; x < 64; x++) for (int y = 0; y < 64; y++) while (true) { int value = mapStream.readUnsignedByte(); if (plane == planePos) dataOpcodes[rx * 64 + x][ry * 64 + y] = value; if (value == 0) break; if (value == 1) { int v = mapStream.readUnsignedByte(); if (plane == planePos) heights[rx * 64 + x][ry * 64 + y] = v; break; } if (value <= 49) { int v = mapStream.readUnsignedByte(); if (plane == planePos) { overlayIds[rx * 64 + x][ry * 64 + y] = v; shapes[rx * 64 + x][ry * 64 + y] = (byte) ((value - 2) / 4); overlayRotations[rx * 64 + x][ry * 64 + y] = (byte) ((value - 2) & 0x3); } } else if (value <= 81) { if (plane == planePos) masks[rx * 64 + x][ry * 64 + y] = (byte) (value - 49); } else if (plane == planePos) underlayIds[rx * 64 + x][ry * 64 + y] = (value - 81); } } } for (int x = -5; x < rgb.length; x++) { for (int y = 0; y < rgb[0].length; y++) { int x2 = 5 + x; if (x2 < rgb.length) { int i_98_ = ((underlayIds[(int) (x2 / scale)][(int) (y / scale)]) & 0x7fff); if (i_98_ > 0) { UnderlayDefinitions defs = UnderlayDefinitions.getUnderlayDefinitions(i_98_ - 1); a1[y] += defs.r; a2[y] += defs.g; a3[y] += defs.b; a4[y] += defs.a; a5[y]++; } } int x3 = x - 5; if (x3 >= 0) { int i_100_ = ((underlayIds[(int) (x3 / scale)][(int) (y / scale)]) & 0x7fff); if (i_100_ > 0) { UnderlayDefinitions defs = UnderlayDefinitions.getUnderlayDefinitions(i_100_ - 1); a1[y] -= defs.r; a2[y] -= defs.g; a3[y] -= defs.b; a4[y] -= defs.a; a5[y]--; } } } if (x >= 0) { int c1 = 0; int c2 = 0; int c3 = 0; int r2 = 0; int r3 = 0; for (int y = -5; y < rgb[0].length; y++) { int i_107_ = y + 5; if (i_107_ < rgb[0].length) { c1 += a1[i_107_]; c2 += a2[i_107_]; c3 += a3[i_107_]; r2 += a4[i_107_]; r3 += a5[i_107_]; } int i_108_ = y - 5; if (i_108_ >= 0) { c1 -= a1[i_108_]; c2 -= a2[i_108_]; c3 -= a3[i_108_]; r2 -= a4[i_108_]; r3 -= a5[i_108_]; } // sets map if (y >= 0 && r3 > 0) rgb[x][y] = new Color(c1 / r3, c2 / r3, c3 / r3).getRGB(); } } } for (int x = 0; x < rgb.length; x++) for (int y = 0; y < rgb[0].length; y++) if (((overlayIds[(int) (x / scale)][(int) (y / scale)]) & 0x7fff) > 0) { OverlayDefinitions defs = OverlayDefinitions.getOverlayDefinitions(((overlayIds[(int) (x / scale)][(int) (y / scale)]) & 0x7fff) - 1); int col = defs.primaryRgb == -1 || defs.primaryRgb == 16711935 || defs.primaryRgb == 0 ? defs.secondaryRgb : defs.primaryRgb; if (col == 0 || col == -1 || col == 16711935) col = 0; if (col == 0 && defs.texture != -1) col = TextureDefinitions.getDefinitions(defs.texture & 0xFF).color; img.setRGB(x, (rgb[0].length - 1) - y, new Color(col).getRGB()); } else if (((shapes[(int) (x / scale)][(int) (y / scale)]) & 0x7fff) > 0) { OverlayDefinitions defs = OverlayDefinitions.getOverlayDefinitions(((shapes[(int) (x / scale)][(int) (y / scale)]) & 0x7fff) - 1); int col = defs.primaryRgb == -1 || defs.primaryRgb == 16711935 || defs.primaryRgb == 0 ? defs.secondaryRgb : defs.primaryRgb; if (col == 0 || col == -1 || col == 16711935) col = 0; img.setRGB(x, (rgb[0].length - 1) - y, new Color(col).getRGB()); } else // //RAW rgb setting no blending // UnderlayDefinitions defs = UnderlayDefinitions.getUnderlayDefinitions(((underlayData[(int) (x / scale)][(int) (y / scale)]) & 0x7fff) - 1); // int col = defs.rgb == -1 || defs.rgb == 16711935 || defs.rgb == 0 ? defs.rgb : defs.rgb; // if (col == 0 || col == -1 || col == 16711935) { // col = 0; // } // img.setRGB(x, (rgb[0].length - 1) - y, new Color(defs.r, defs.g, defs.b).getRGB()); img.setRGB(x, (rgb[0].length - 1) - y, rgb[x][y]); for (int rx = 0; rx < maxRX; rx++) for (int ry = 0; ry < maxRY; ry++) { int regionId = ((rx + rxPos) << 8) | (ry + ryPos); int regionX = (regionId >> 8) * 64; int regionY = (regionId & 0xff) * 64; int landArchiveId = Cache.STORE.getIndex(IndexType.MAPS).getArchiveId(""l"" + ((regionX >> 3) / 8) + ""_"" + ((regionY >> 3) / 8)); byte[] data = landArchiveId == -1 ? null : Cache.STORE.getIndex(IndexType.MAPS).getFile(landArchiveId, 0, MapXTEAs.getMapKeys(regionId)); if (data == null) continue; InputStream landStream = new InputStream(data); int objectId = -1; int incr; while ((incr = landStream.readSmart2()) != 0) { objectId += incr; int location = 0; int incr2; while ((incr2 = landStream.readUnsignedSmart()) != 0) { location += incr2 - 1; int localX = (location >> 6 & 0x3f); int localY = (location & 0x3f); int plane = location >> 12; int objectData = landStream.readUnsignedByte(); int type = objectData >> 2; int rotation = objectData & 0x3; if (localX < 0 || localX >= 64 || localY < 0 || localY >= 64) continue; /* * int objectPlane = plane; if (mapSettings != null && (mapSettings[1][localX][localY] & 2) * == 2) objectPlane--; if (objectPlane < 0 || objectPlane >= 4 || plane < 0 || plane >= 4) * continue; */ // System.out.println(spriteId); if (plane == planePos) { int mapSpriteId = ObjectDefinitions.getDefs(objectId).mapSpriteId; if (mapSpriteId == -1) continue; int spriteId = MapSpriteDefinitions.getMapSpriteDefinitions(mapSpriteId).spriteId; if (spriteId == -1) continue; SpriteDefinitions sprite = new SpriteDefinitions(Cache.STORE, spriteId, 0); BufferedImage s = sprite.getImages()[0]; int width = (int) (s.getWidth() / 2 * scale); int height = (int) (s.getHeight() / 2 * scale); if (width == 0 || height == 0) continue; /* * if(width > s.getWidth() || height > s.getHeight()) { width = s.getWidth(); height = * s.getHeight(); * * } */ img.getGraphics().drawImage(s.getScaledInstance(width, height, 0), (int) ((rx * 64 + localX) * scale), (int) (((maxRY * 64 - 1) - (ry * 64 + localY)) * scale), null); } // spawnObject(new WorldObject(objectId, type, rotation, // localX + regionX*64, localY + regionY*64, // objectPlane), objectPlane, localX, localY, true); } } } return img; } public static int getV(int i, int i_1_, int i_2_) { if (i_2_ > 243) i_1_ >>= 4; else if (i_2_ > 217) i_1_ >>= 3; else if (i_2_ > 192) i_1_ >>= 2; else if (i_2_ > 179) i_1_ >>= 1; return (i_2_ >> 1) + (((i & 0xff) >> 2 << 10) + (i_1_ >> 5 << 7)); } @Override public void mouseClicked(MouseEvent e) { mouseLocation = e.getPoint(); int[] pos = getPos(); StringSelection selection = new StringSelection(pos[0] + "" "" + pos[1] + "" "" + planePos); Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); clipboard.setContents(selection, selection); e.consume(); } private Point mouseLocation; private Point mouseLocation2; @Override public void mousePressed(MouseEvent e) { mouseLocation = e.getPoint(); e.consume(); } @Override public void mouseReleased(MouseEvent e) { drag(e.getPoint()); e.consume(); } public void drag(Point newLoc) { int diffX = (int) ((mouseLocation.x - newLoc.x) / scale); int diffY = (int) ((mouseLocation.y - newLoc.y) / scale); if (diffX != 0 || diffY != 0) { xPos += diffX; yPos -= diffY; mouseLocation = newLoc; checkLoad(); repaint(); } } @Override public void mouseEntered(MouseEvent e) { } @Override public void mouseExited(MouseEvent e) { } @Override public void mouseDragged(MouseEvent e) { drag(e.getPoint()); e.consume(); } @Override public void mouseMoved(MouseEvent e) { mouseLocation2 = e.getPoint(); this.repaint(); } @Override public void mouseWheelMoved(MouseWheelEvent e) { if (!loading) { if (e.getUnitsToScroll() > 0) { if (e.isControlDown()) planePos = (planePos - 1) & 0x3; else scale /= 1.5; } else if (e.isControlDown()) planePos = (planePos + 1) & 0x3; else scale *= 1.5; forceNoRefresh = true; checkLoad(); } } }" "package com.rs.tools.old; public class ModelDumper { public static void main(String[] args) throws IOException { Cache.STORE = new Store(""C:/Users/Alexandre/Desktop/Java/projectos/FileStore2/cache562/""); Index index = Cache.STORE.getIndex(IndexType.MODELS); System.out.println(index.getLastArchiveId()); for (int i = 0; i < index.getLastArchiveId(); i++) { byte[] data = index.getFile(i); if (data == null) continue; // if(!(data[data.length + -1] == -1 && data[-2 + data.length] == // -1)) // if((data[-1 + data.length] ^ 0xffffffff) != 0 || data[-2 + // data.length] != -1) // System.out.println(i); writeFile(data, ""C:/Users/Alexandre/Downloads/RSMV 2/Models3/"" + i + "".dat""); } } public static void writeFile(byte[] data, String fileName) throws IOException { OutputStream out = new FileOutputStream(fileName); out.write(data); out.close(); } }" "package com.rs.tools.old; public class NPCAnimationDumper { public static void main(String[] args) throws IOException { //Cache.init(); File file = new File(""npcAnimations.txt""); if (file.exists()) file.delete(); else file.createNewFile(); BufferedWriter writer = new BufferedWriter(new FileWriter(file)); writer.flush(); for (int id = 0; id < Utils.getNPCDefinitionsSize(); id++) { NPCDefinitions npc = NPCDefinitions.getDefs(id); if (npc.basId <= 0) continue; BASDefinitions render = BASDefinitions.getDefs(npc.basId); AnimationDefinitions anim = AnimationDefinitions.getDefs(render.standAnimation); if (anim.anIntArray5923 == null) continue; ArrayList relatedDefs = new ArrayList<>(); for (int i = 0;i < Utils.getAnimationDefinitionsSize();i++) { AnimationDefinitions def = AnimationDefinitions.getDefs(i); if (def.anIntArray5923 != null && def.anIntArray5923[0] == anim.anIntArray5923[0]) relatedDefs.add(def); } writer.append(String.valueOf(id)).append("" ("").append(npc.getName()).append("") - "").append(Arrays.toString(relatedDefs.stream().map(def -> def.id + "" ("" + (def.getEmoteTime() / 1000.0) + "" secs)"").toArray())); writer.newLine(); writer.flush(); } writer.close(); } }" "package com.rs.tools.old; public class NPCCheck { public static void main(String[] args) throws IOException { //Cache.init(); ItemDefinitions defs = ItemDefinitions.getDefs(19760); ItemDefinitions defs2 = ItemDefinitions.getDefs(20771); System.out.println(""defs"" + defs.inventoryOptions[50]); System.out.println(""defs"" + Arrays.toString(defs2.inventoryOptions)); } }" "package com.rs.tools.old; public final class NPCCombatConverter { public static void main(String[] args) throws IOException { //Cache.init(); createData2(); } class CombatInfo { int hitpoints; int maxHit; int attackStyle; boolean aggro; int npcId; int[] levels; } private static final Map beasts = new HashMap<>(); private static void loadBeastData() throws IOException { BufferedReader in = new BufferedReader(new FileReader(new File(""./testdefs.txt""))); while (true) { String line = in.readLine(); if (line == null) { in.close(); break; } if (line.startsWith(""//"")) continue; Gson gson = new GsonBuilder().create(); CombatInfo bi = gson.fromJson(line, CombatInfo.class); beasts.put(bi.npcId, bi); } } @SuppressWarnings(""unused"") private static void createData() { try { loadBeastData(); try (BufferedWriter writer = new BufferedWriter(new FileWriter(new File(""dumpedBonuses.txt"")))) { for (int npcId = 0; npcId < Utils.getNPCDefinitionsSize(); npcId++) { NPCDefinitions def = NPCDefinitions.getDefs(npcId); CombatInfo line = beasts.remove(npcId); if (line == null) continue; int stabatt = 0, slashatt = 0, crushatt = 0, magicatt = 0, rangeatt = 0, stabdef = 0, slashdef = 0, crushdef = 0, magicdef = 0, rangedef = 0; stabatt += def.getStabAtt() + line.levels[0]; slashatt += def.getSlashAtt() + line.levels[0]; crushatt += def.getCrushAtt() + line.levels[0]; magicatt += def.getMagicAtt() + line.levels[4]; magicdef += def.getMagicDef() + line.levels[4]; rangeatt += def.getRangeAtt() + line.levels[3]; rangedef += def.getRangeDef() + line.levels[2]; crushdef += def.getCrushDef() + line.levels[2]; slashdef += def.getSlashDef() + line.levels[2]; stabdef += def.getStabDef() + line.levels[2]; writer.write(""//"" + def.getName() + "" ("" + def.combatLevel + "")""); writer.newLine(); writer.write(npcId + "" - "" + stabatt + "" "" + slashatt + "" "" + crushatt + "" "" + magicatt + "" "" + rangeatt + "" "" + stabdef + "" "" + slashdef + "" "" + crushdef + "" "" + magicdef + "" "" + rangedef); writer.newLine(); writer.flush(); } } catch (Exception e) { e.printStackTrace(); } } catch (IOException e) { e.printStackTrace(); } } private static void createData2() { try { loadBeastData(); try (BufferedWriter writer = new BufferedWriter(new FileWriter(new File(""dumpedDefinitions.txt"")))) { for (int npcId = 0; npcId < Utils.getNPCDefinitionsSize(); npcId++) { NPCDefinitions def = NPCDefinitions.getDefs(npcId); CombatInfo line = beasts.remove(npcId); if (line == null) continue; String attackStyle = ""MELEE""; if (line.attackStyle == 1) attackStyle = ""RANGE""; if (line.attackStyle == 2) attackStyle = ""MAGE""; String aggro = line.aggro ? ""AGRESSIVE"" : ""PASSIVE""; writer.write(""//"" + def.getName() + "" ("" + def.combatLevel + "")""); writer.newLine(); writer.write(npcId + "" - "" + line.hitpoints + "" "" + -1 + "" "" + -1 + "" "" + -1 + "" "" + 1 + "" "" + 3 + "" "" + 40 + "" "" + line.maxHit + "" "" + attackStyle + "" "" + -1 + "" "" + -1 + "" "" + aggro); writer.newLine(); writer.flush(); } } catch (Exception e) { e.printStackTrace(); } } catch (IOException e) { e.printStackTrace(); } } private NPCCombatConverter() { } }" "package com.rs.tools.old; public class NPCDropConverter { public static void main(String[] args) throws IOException { RandomAccessFile in = new RandomAccessFile(""./data/npcs/npcDrops.bin"", ""r""); FileChannel channel = in.getChannel(); ByteBuffer buffer = channel.map(MapMode.READ_ONLY, 0, channel.size()); BufferedWriter writer = new BufferedWriter(new FileWriter(""npcDrops.txt"", true)); int dropMapSize = buffer.getShort(); /** * At this point we are going through the drop tables */ for (int i = 0; i < dropMapSize; i++) { int npcId = buffer.getShort(); short dropAmount = buffer.getShort(); for (int x = 0; x < dropAmount; x++) { /** * At this point we are reading the drops from the table */ short itemId = buffer.getShort(); int minItemAmount = buffer.getInt(); int maxItemAmount = buffer.getInt(); int chanceTypeOrdinal = buffer.getInt(); // ChanceType Enum // Ordinal // TODO organize the drops in rarity order String rarity = switch (chanceTypeOrdinal) { case 0 -> ""ALWAYS""; case 1 -> ""COMMON""; case 2 -> ""UNCOMMON""; case 3 -> ""RARE""; case 4 -> ""VERYRARE""; default -> """"; }; writer.write(npcId + "":""); writer.write(itemId + ""-"" + rarity + ""-"" + minItemAmount + ""-"" + maxItemAmount + "":""); writer.newLine(); writer.flush(); } writer.newLine(); } writer.flush(); writer.close(); } }" "package com.rs.tools.old; public class NPCSpawnsDumper { private static int writtenCount; public static void main(String[] args) throws IOException { BufferedWriter out = new BufferedWriter(new FileWriter(""data/npcs/unpackedSpawnsList.txt"", true)); //Cache.init(); MapXTEAs.loadKeys(); for (int regionId = 0; regionId < 20000; regionId++) { if (new File(""data/npcs/packedSpawns/"" + regionId + "".ns"").exists()) continue; dumpRegionNPCs(regionId, out); } out.close(); System.out.println(""found "" + writtenCount + "" npc spawns on cache.""); } public static void dumpRegionNPCs(int regionId, BufferedWriter writer) throws IOException { writer.flush(); int regionX = (regionId >> 8) * 64; int regionY = (regionId & 0xff) * 64; int npcSpawnsContainerId = Cache.STORE.getIndex(IndexType.MAPS).getArchiveId(""n"" + ((regionX >> 3) / 8) + ""_"" + ((regionY >> 3) / 8)); if (npcSpawnsContainerId == -1) return; byte[] npcSpawnsContainerData = Cache.STORE.getIndex(IndexType.MAPS).getFile(npcSpawnsContainerId, 0, MapXTEAs.getMapKeys(regionId)); if (npcSpawnsContainerData == null) return; System.out.println(regionId); InputStream stream = new InputStream(npcSpawnsContainerData); while (stream.getRemaining() > 0) { int hash = stream.readUnsignedShort(); int npcId = stream.readUnsignedShort(); int plane = hash >> 14; int localX = (0x1f92 & hash) >> 7; int x = regionX + localX; int localY = 0x3f & hash; int y = regionY + localY; writer.newLine(); writer.write(npcId + "" - "" + x + "" "" + y + "" "" + plane); writer.flush(); writtenCount++; System.out.println(""123""); } } }" "package com.rs.tools.old; public class ObjectCheck { public static void main(String[] args) throws IOException { //Cache.init(); for (int i = 0; i < Utils.getObjectDefinitionsSize(); i++) { ObjectDefinitions def = ObjectDefinitions.getDefs(i); if (def.containsOption(""Steal-from"")) System.out.println(def.id + "" - "" + def.getName()); } } }" "package com.rs.tools.old; public class PotionCreator { public static void main(String[] args) { //Cache.init(); int amt = 1; String lastName = null; @SuppressWarnings(""unused"") String modified = null; for (int i = 23100; i < Utils.getItemDefinitionsSize(); i++) { ItemDefinitions def = ItemDefinitions.getDefs(i); String name = def.getName(); lastName = name; modified = lastName.replace("" "", ""_"").replace(""(6)"", """").replace(""(5)"", """").replace(""(4)"", """").replace(""(3)"", """").replace(""(2)"", """").replace(""(1)"", """").toUpperCase(); if (name.contains(""flask"") && !name.matches(lastName) && !def.isNoted()) { System.out.print(amt == 6 ? i + ""\n\n"" : i + "", ""); if (amt == 6) amt = 0; amt++; } } } }" "package com.rs.tools.old; public class RsWikiEquipSlotsDumper { private static final ArrayList slots = new ArrayList<>(); private static boolean dumpEquipmentSlot(Item item) { if (item.getDefinitions() != null && !item.getDefinitions().isWearItem()) return false; ArrayList lines = getPage(item); if (lines == null) return false; Iterator iterator = lines.iterator(); try { while (iterator.hasNext()) { String line = iterator.next(); if (line.startsWith("""")) { line = iterator.next(); // System.out.println(line.indexOf(""\"">\""""));\"""")); getPage(Item item) { try { WebPage page = new WebPage(""http://runescape.wikia.com/wiki/"" + item.getName()); try { page.load(); } catch (Exception e) { System.out.println(""Invalid page: "" + item.getId() + "", "" + item.getName()); return null; } return page.getLines(); } catch (Exception e) { e.printStackTrace(); } return null; } public static void main(String[] args) { //Cache.init(); for (int i = 0; i < 75; i++) { Item item = new Item(i, 1); if (dumpEquipmentSlot(item)) System.out.println(""Dumped Item "" + item.getName()); } try { DataOutputStream out = new DataOutputStream(new FileOutputStream(new File(""./slots.s""))); for (EquipSlot slot : slots) { out.writeShort(slot.getId()); out.write(slot.getType().toString().getBytes()); } out.flush(); out.close(); } catch (IOException e) { e.printStackTrace(); } } static class EquipSlot { private final int id; private final SlotType type; public EquipSlot(int id, SlotType type) { this.id = id; this.type = type; } public int getId() { return id; } public SlotType getType() { return type; } enum SlotType { WEAPON_SLOT, HEAD_SLOT, RING_SLOT, BODY_SLOT, LEGWEAR_SLOT, HANDS_SLOT, AURA_SLOT, FEET_SLOT, CAPE_SLOT, AMMUNITION_SLOT, NECK_SLOT, SLOT_SHIELD } } }" "package com.rs.tools.old; public class RuneWikiBonusDumper { public static void main(String[] args) throws IOException { System.out.println(""Starting..""); //Cache.init(); for (int itemId = 22067; itemId < Utils.getItemDefinitionsSize(); itemId++) if (ItemDefinitions.getDefs(itemId).isWearItem() && !ItemDefinitions.getDefs(itemId).isNoted()) if (dumpItem(itemId)) System.out.println(""Dumped ITEM: "" + itemId + "", "" + ItemDefinitions.getDefs(itemId).getName()); } public static boolean dumpItem(int itemId) { File file = new File(""bonuses/"" + itemId + "".txt""); if (file.exists()) return false; String pageName = ItemDefinitions.getDefs(itemId).getName().replace("" (black)"", """").replace("" (white)"", """").replace("" (yellow)"", """").replace("" (red)"", """"); if (pageName == null || pageName.equals(""null"")) return false; pageName = pageName.replace("" (p)"", """"); pageName = pageName.replace("" (p+)"", """"); pageName = pageName.replace("" (p++)"", """"); pageName = pageName.replace("" Broken"", """"); pageName = pageName.replace("" 25"", """"); pageName = pageName.replace("" 50"", """"); pageName = pageName.replace("" 75"", """"); pageName = pageName.replace("" 100"", """"); pageName = pageName.replace(""jav'n"", ""javelin""); pageName = pageName.replaceAll("" "", ""_""); try { WebPage page = new WebPage(""http://runescape.wikia.com/wiki/"" + pageName); try { page.load(); } catch (Exception e) { System.out.println(""Invalid page: "" + itemId + "", "" + pageName); return false; } int bonusId = 0; int[] bonuses = new int[18]; for (String line : page.getLines()) if (bonusId == 0 || bonusId == 5) { String replace = """"; if (line.startsWith(replace)) { line = line.replace(replace, """").replaceAll("" "", """").replace(""+"", """").replace(""
"", """"); int bonus = Integer.valueOf(line); // System.out.println(bonus); bonuses[bonusId++] = bonus; continue; } } else if ((bonusId >= 1 && bonusId <= 4) || (bonusId >= 6 && bonusId <= 10)) { String replace = """"; if (line.startsWith(replace)) { line = line.replace(replace, """").replaceAll("" "", """").replace(""+"", """").replace(""64to100"", ""100""); int bonus = Integer.valueOf(line); // System.out.println(bonus); bonuses[bonusId++] = bonus; continue; } } else if (bonusId == 11) { String replace = """"; if (line.startsWith(replace)) { line = line.replace(replace, """").replaceAll("" "", """").replace(""%"", """").replace("".0"", """"); int bonus = Integer.valueOf(line); // System.out.println(bonus); bonuses[bonusId++] = bonus; continue; } } else if (bonusId == 12 || bonusId == 13) { String replace = """"; if (line.startsWith(replace)) { line = line.replace(replace, """").replaceAll("" "", """").replace(""%"", """").replace("".0"", """"); int bonus = Integer.valueOf(line); // System.out.println(bonus); bonuses[bonusId++] = bonus; continue; } } else if (bonusId == 14) { String replace = """"; if (line.startsWith(replace)) { line = line.replace(replace, """").replaceAll("" "", """").replace(""+"", """").replace("".0"", """").replace("".1"", """").replace("".5"", """"); int bonus = (Double.valueOf(line)).intValue(); // System.out.println(bonus); bonuses[bonusId++] = bonus; continue; } } else if (bonusId >= 15 && bonusId <= 17) { String replace = """"; if (line.startsWith(replace)) { line = line.replace(replace, """").replaceAll("" "", """").replace(""%"", """").replace(""+"", """").replace("".0"", """").replace(""52to70"", ""70"").replace(""0(4trimmed)"", ""4"").replace(""15(Slayertasksonly)"", ""0"").replace("".5"", """") .replace(""?"", ""0"").replace(""Varies"", ""0""); int bonus = Integer.valueOf(line); // System.out.println(bonus); bonuses[bonusId++] = bonus; if (bonusId == 18) break; continue; } } if (bonusId != 18) return false; boolean letssee = false; for (int bonus : bonuses) if (bonus != 0) { letssee = true; break; } if (!letssee) return false; try { BufferedWriter writer = new BufferedWriter(new FileWriter(file)); writer.write(""Attack bonus""); writer.newLine(); writer.flush(); for (int index = 0; index < 5; index++) { writer.write("""" + bonuses[index]); writer.newLine(); writer.flush(); } writer.write(""Defence bonus""); writer.newLine(); writer.flush(); for (int index = 5; index < 11; index++) { writer.write("""" + bonuses[index]); writer.newLine(); writer.flush(); } writer.write(""Damage absorption""); writer.newLine(); writer.flush(); for (int index = 11; index < 14; index++) { writer.write("""" + bonuses[index]); writer.newLine(); writer.flush(); } writer.write(""Other bonuses""); writer.newLine(); writer.flush(); for (int index = 14; index < 18; index++) { writer.write("""" + bonuses[index]); writer.newLine(); writer.flush(); System.out.println(""Exists ? : "" + file.exists()); } writer.close(); } catch (IOException e) { e.printStackTrace(); } return true; } catch (Exception e) { e.printStackTrace(); } return false; } }" "package com.rs.tools.old; public class RuneWikiExaminesDumper { public static void main(String[] args) throws IOException { System.out.println(""Starting..""); //Cache.init(); for (int itemId = 0; itemId < Utils.getItemDefinitionsSize(); itemId++) if (!ItemDefinitions.getDefs(itemId).isNoted()) if (dumpItem(itemId)) System.out.println(""DUMPED ITEM : "" + itemId); else System.out.println(""FAILED ITEM: "" + itemId + "", "" + ItemDefinitions.getDefs(itemId).getName()); } public static boolean dumpItem(int itemId) { String pageName = ItemDefinitions.getDefs(itemId).getName(); if (pageName == null || pageName.equals(""null"")) return false; pageName = pageName.replace(""(p)"", """"); pageName = pageName.replace(""(p+)"", """"); pageName = pageName.replace(""(p++)"", """"); pageName = pageName.replaceAll("" "", ""_""); try { WebPage page = new WebPage(""http://runescape.wikia.com/wiki/"" + pageName); try { page.load(); } catch (Exception e) { System.out.println(""Invalid page: "" + itemId + "", "" + pageName); return false; } boolean isNextLine = false; for (String line : page.getLines()) { if (isNextLine) { String examine = line.replace("" "", """"); examine = examine.replace("""", """"); examine = examine.replace("" "", """"); examine = examine.replace("" "", """"); examine = examine.replace(""<colour> "", """"); examine = examine.replace(""(bright/thick/warm)"", ""bright""); examine = examine.replace(""(Temple of Ikov) "", """"); examine = examine.replace(""(Fight Arena) "", """"); try { BufferedWriter writer = new BufferedWriter(new FileWriter(""itemExamines.txt"", true)); writer.write(itemId + "" - "" + examine); writer.newLine(); writer.flush(); writer.close(); } catch (IOException e) { e.printStackTrace(); } return true; } if (line.equals(""Examine"")) isNextLine = true; } } catch (MalformedURLException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); return dumpItem(itemId); } return false; } }" "package com.rs.tools.old; public class RuneWikiNPCDefinitionsDumper { /** * @param args */ public static void main(String[] args) { //Cache.init(); for (int i = 6793; i < 6891; i++) if (!dumpNPC(i)) System.out.println(""Failed dumping npc: "" + i + "", "" + NPCDefinitions.getDefs(i).getName()); } private static final String COMBAT_LEVEL_LINE = ""Combat level""; private static final String HP_LINE = "" Life points""; private static final String AGGRESSIVE_LINE = "" Aggressive?""; private static final String COMBAT_STYLE_LINE = ""Attack style""; private static final String MAX_HIT_LINE = ""Max hit""; private static final String ATTACK_SPEED_LINE = ""Attack speed""; public static boolean dumpNPC(int npcId) { NPCDefinitions defs = NPCDefinitions.getDefs(npcId); if (!defs.hasAttackOption()) return true; String pageName = defs.getName(); if (pageName == null || pageName.equals(""null"")) return true; pageName = pageName.replaceAll("" "", ""_""); try { WebPage page = new WebPage(""http://runescape.wikia.com/wiki/"" + pageName); try { page.load(); } catch (SocketTimeoutException e) { return dumpNPC(npcId); } catch (Exception e) { System.out.println(""Invalid page: "" + npcId + "", "" + pageName); return false; } int hitpoints = -1; boolean aggressive = false; int attackStyle = -1; int maxhit = -1; int attackSpeed = -1; for (int linesCount = 0; linesCount < page.getLines().size(); linesCount++) { String line = page.getLines().get(linesCount); if (line.equalsIgnoreCase(COMBAT_LEVEL_LINE)) { linesCount++; String combatLevelsLine = getFormatedString(page.getLines().get(linesCount)); String[] levels = combatLevelsLine.split("",""); linesCount += 3; String hpCheckLine = page.getLines().get(linesCount); if (!hpCheckLine.equalsIgnoreCase(HP_LINE)) throw new RuntimeException(""invalid hp line.""); linesCount++; String lifePointsLine = getFormatedString(page.getLines().get(linesCount)); String[] lifePoints = lifePointsLine.split("",""); for (int i = 0; i < levels.length; i++) { int level = Integer.valueOf(levels[i]); if (level == defs.combatLevel) { hitpoints = Integer.valueOf(lifePoints[i >= lifePoints.length ? lifePoints.length - 1 : i]); break; } } if (hitpoints < 0) return false; } else if (line.equalsIgnoreCase(AGGRESSIVE_LINE)) { linesCount++; String isAggresive = getFormatedString(page.getLines().get(linesCount)); aggressive = !isAggresive.equalsIgnoreCase(""No""); } else if (line.equalsIgnoreCase(COMBAT_STYLE_LINE)) { // Melee linesCount++; String attackStyleLine = page.getLines().get(linesCount).toLowerCase(); if (attackStyleLine.contains(""melee"")) attackStyle = 0; else if (attackStyleLine.contains(""ranged"")) attackStyle = 1; else if (attackStyleLine.contains(""magic"")) attackStyle = 2; } else if (line.equalsIgnoreCase(MAX_HIT_LINE)) { linesCount++; String maxhitLine = page.getLines().get(linesCount); maxhitLine = maxhitLine.replace("" "", """"); maxhitLine = maxhitLine.replace("""", """"); maxhitLine = maxhitLine.replace(""/"", "" ""); maxhitLine = maxhitLine.split("" "")[0]; if (maxhitLine.equals("""")) { linesCount++; maxhitLine = page.getLines().get(linesCount); maxhitLine = maxhitLine.replace(""
  • "", """"); maxhitLine = maxhitLine.replace(""/"", "" ""); maxhitLine = maxhitLine.split("" "")[0]; } maxhitLine = maxhitLine.replace("","", """"); maxhitLine = maxhitLine.replace("""", """").replace(""to"", "","").replace(""-"", "","").replace(""/"", "","").replace(""Varies"", ""0"").replaceAll("" "", """").replace(""(0inDaemonheim)"", """") .replace(""(13inTheRestlessGhost)"", ""13,"").replace(""(variesinDaemonheim:..."", """"); } }" "package com.rs.tools.old; public class ShopListDumper { public static void main(String[] args) { try { //Cache.init(); File file = new File(""cacheShops.txt""); if (file.exists()) file.delete(); else file.createNewFile(); BufferedWriter writer = new BufferedWriter(new FileWriter(file)); writer.append(""//Version = 727\n""); writer.flush(); int id = 300; for (int i = 0; i < Cache.STORE.getIndex(IndexType.CONFIG).getValidFilesCount(ArchiveType.INVENTORIES.getId()); i++) { InventoryDefinitions def = InventoryDefinitions.getContainer(i); if (def.ids == null || def.ids.length <= 0) continue; System.out.println(""Container: "" + id); StringBuilder sb = new StringBuilder(id+"" 995 false - UNNAMED"" + id + "" - ""); for (int x = 0;x < def.ids.length;x++) sb.append("""").append(def.ids[x]).append("" "").append(def.amounts[x]).append("" ""); writer.append(sb.toString()); writer.newLine(); writer.flush(); id++; } writer.close(); } catch (IOException e) { e.printStackTrace(); } } }" "package com.rs.tools.old; public class SpawnFormatChanger { class ShaunyNPCSpawn { private String npcName; private int npcId; private int x, y, plane; } public static void main(String[] args) throws JsonIOException, IOException { //Cache.init(); List converted = new ArrayList<>(); ShaunyNPCSpawn[] spawns = (ShaunyNPCSpawn[]) JsonFileManager.loadJsonFile(new File(""./dumps/newSpawns.json""), ShaunyNPCSpawn[].class); for (ShaunyNPCSpawn spawn : spawns) { if (spawn.npcId > Utils.getNPCDefinitionsSize()) continue; converted.add(new NPCSpawn(spawn.npcId, Tile.of(spawn.x, spawn.y, spawn.plane), spawn.npcName)); } JsonFileManager.saveJsonFile(converted, new File(""./dumps/shaunySpawns.json"")); } }" "package com.rs.tools.old; public class WebPage { private final URL url; private ArrayList lines; private String wholePage = """"; public WebPage(String url) throws MalformedURLException { this.url = new URL(url); } public void load() throws IOException { lines = new ArrayList<>(); HttpsURLConnection c = (HttpsURLConnection) url.openConnection(); c.setRequestProperty(""User-Agent"", ""Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.4; en-US; rv:1.9.2.2) Gecko/20100316 Firefox/3.6.2""); c.setReadTimeout(3000); BufferedReader stream = new BufferedReader(new InputStreamReader(c.getInputStream())); String line; while ((line = stream.readLine()) != null) { if (line.contains(""}} {{"")) { lines.add(line.substring(0, line.indexOf(""}} {{""))); lines.add(line.substring(line.indexOf(""}} {{""))); } else if (line.contains(""}}{{"")) { lines.add(line.substring(0, line.indexOf(""}}{{""))); lines.add(line.substring(line.indexOf(""}}{{""))); } else lines.add(line); wholePage += line; } stream.close(); } public void setLines(ArrayList lines) { this.lines = lines; } public ArrayList getLines() { return lines; } public String getPage() { return wholePage; } }" "package com.rs.tools.old; public class WikiEqupSlotDumper { private static final ArrayList slots = new ArrayList<>(); private static boolean dumpEquipmentSlot(Item item) { if (!item.getDefinitions().isWearItem() || item.getDefinitions().isNoted()) return false; ArrayList lines = getPage(item); if (lines == null) return false; Iterator iterator = lines.iterator(); try { while (iterator.hasNext()) { String line = iterator.next(); if (line.startsWith("""")) { line = iterator.next(); line = line.substring(line.indexOf(""title="") + ""title="".length() + 1, line.indexOf(""\"">\"""")); getPage(Item item) { try { String pageName = item.getDefinitions().getName().replace("" (black)"", """").replace("" (white)"", """").replace("" (yellow)"", """").replace("" (red)"", """"); if (pageName == null || pageName.equals(""null"")) return null; pageName = pageName.replace("" (p)"", """"); pageName = pageName.replace("" (p+)"", """"); pageName = pageName.replace("" (p++)"", """"); pageName = pageName.replace("" Broken"", """"); pageName = pageName.replace("" 25"", """"); pageName = pageName.replace("" 50"", """"); pageName = pageName.replace("" 75"", """"); pageName = pageName.replace("" 100"", """"); pageName = pageName.replaceAll("" "", ""_""); WebPage page = new WebPage(""http://runescape.wikia.com/wiki/"" + pageName); try { page.load(); } catch (Exception e) { System.out.println(""Invalid page: "" + item.getId() + "", "" + pageName); return null; } return page.getLines(); } catch (Exception e) { e.printStackTrace(); } return null; } public static void main(String[] args) { //Cache.init(); for (int i = 0; i < Utils.getItemDefinitionsSize(); i++) { Item item = new Item(i, 1); dumpEquipmentSlot(item); } try { DataOutputStream out = new DataOutputStream(new FileOutputStream(""./slots.s/"")); for (EquipSlot slot : slots) { byte[] bytes = slot.getType().toString().getBytes(); out.writeShort(slot.getId()); out.writeByte(bytes.length); out.write(bytes); } out.close(); System.out.println(""Packed Defintions.""); } catch (IOException e) { e.printStackTrace(); } } public static class EquipSlot { private final int id; private final SlotType type; public EquipSlot(int id, SlotType type) { this.id = id; this.type = type; } public int getId() { return id; } public SlotType getType() { return type; } public enum SlotType { WEAPON_SLOT, HEAD_SLOT, RING_SLOT, BODY_SLOT, LEGWEAR_SLOT, HANDS_SLOT, AURA_SLOT, FEET_SLOT, CAPE_SLOT, AMMUNITION_SLOT, NECK_SLOT, SHIELD_SLOT, FULL_HELMET, FULL_MASK, TWO_HANDED } } }" "package com.rs.tools.old; public class WikiNpcDropDumper { public static void main(String[] args) throws IOException { System.out.println(""Starting..""); //Cache.init(); for (int npcId = 0; npcId < Utils.getNPCDefinitionsSize(); npcId++) if (NPCDefinitions.getDefs(npcId).hasAttackOption()) if (dumpDrops(npcId)) System.out.println(""DUMPED NPC : "" + npcId); } public static boolean dumpDrops(int npcId) { String pageName = NPCDefinitions.getDefs(npcId).getName(); String rarity = ""null""; String itemName = """"; int minAmount = 0; int maxAmount = 0; int itemId = 0; boolean noted = false; if (pageName == null || pageName.equals(""null"")) return false; try { WebPage page = new WebPage(""http://runescape.wikia.com/wiki/"" + pageName); try { page.load(); } catch (Exception e) { System.out.println(""Invalid page: "" + npcId + "", "" + pageName); return false; } BufferedWriter writer = new BufferedWriter(new FileWriter(""npcDrops.txt"", true)); writer.write(npcId + "":""); for (String line : page.getLines()) { boolean nextIsAmounts = false; if (line.contains(""Edit Rare drop table drops section"")) return true; /* * Rarity */ if (line.contains(""background:#98FB98"") && line.contains(""Common"")) rarity = ""COMMON""; else if (line.contains(""background:#F0E68C"") && line.contains(""Uncommon"")) rarity = ""UNCOMMON""; else if (line.contains(""background:#F4A460"") && line.contains(""Rare"")) rarity = ""RARE""; else if (line.contains(""background:#F08080"") && line.contains(""Very rare"")) rarity = ""VERYRARE""; /* * Item name */ if (line.contains("""") + 1).replace("""", """"); itemId = getItemIdByName(itemName); } /* * Amounts */ if (nextIsAmounts) { if (line.contains(""(noted)"")) noted = true; if (line.contains(""1 – 3"")) { minAmount = Integer.parseInt(line.substring(line.indexOf("""") + 1)); maxAmount = Integer.parseInt(line.substring(line.indexOf(""11; 3"") + 1)); } nextIsAmounts = false; } if (!rarity.equals(""null"") && itemId != 0 && minAmount != 0 && maxAmount != 0) try { if (noted && ItemDefinitions.getDefs(itemId).getCertId() != -1) itemId = ItemDefinitions.getDefs(itemId).getCertId(); writer.write(itemId + ""-"" + rarity + ""-"" + minAmount + ""-"" + maxAmount + "":""); } catch (IOException e) { e.printStackTrace(); } } writer.newLine(); writer.flush(); writer.close(); return true; } catch (MalformedURLException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); return dumpDrops(npcId); } return false; } public static int getItemIdByName(String name) { if (name.equalsIgnoreCase(""tinderbox"")) return 590; for (int i = 0; i < Utils.getItemDefinitionsSize(); i++) { ItemDefinitions itemDef = ItemDefinitions.getDefs(i); if (itemDef.getName().equals(name)) return i; } System.out.println(""Error finding item with name: "" + name); return -1; } }" "package com.rs.tools.old; public class XteaMaker { public static void main(String[] args) { try { BufferedReader stream = new BufferedReader(new InputStreamReader(new FileInputStream(""xtea650.txt""))); while (true) { String line = stream.readLine(); if (line == null) break; if (line.startsWith(""--"")) continue; String[] spaceSplitLine = line.split("" ""); int regionId = Integer.valueOf(spaceSplitLine[0]); String[] xteaSplit = spaceSplitLine[3].split(""\\.""); /* * for(byte c : spaceSplitLine[3].getBytes()) { * System.out.println(c); System.out.println((char) c); } */ if (xteaSplit[0].equals(""0"") && xteaSplit[1].equals(""0"") && xteaSplit[2].equals(""0"") && xteaSplit[3].equals(""0"")) continue; BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(""convertedXtea/"" + regionId + "".txt""))); for (String xtea : xteaSplit) { writer.append(xtea); writer.newLine(); writer.flush(); } } } catch (IOException e) { e.printStackTrace(); } } }" "package com.rs.utils; public class Millis { public static long fromHours(int hours) { return fromMinutes(hours * 60); } public static long fromMinutes(int minutes) { return minutes * 60000L; } public static long fromSeconds(int seconds) { return seconds * 1000L; } }" "package com.rs.utils; public final class AccountLimiter { private static final Map CONNECTIONS = new ConcurrentHashMap<>(); public static void add(String ip) { CONNECTIONS.merge(ip, 1, Integer::sum); } public static void remove(String ip) { Integer amount = CONNECTIONS.get(ip); if (amount == null) amount = 0; if (amount <= 1) CONNECTIONS.remove(ip); else CONNECTIONS.put(ip, amount-1); } public static int getSessionsIP(String ip) { Integer connections = CONNECTIONS.get(ip); if (connections == null) return 1; return connections; } }" "package com.rs.utils; @PluginEventHandler public class Areas { private final static String PATH = ""data/areas/""; private static final HashMap> AREAS = new HashMap<>(); @ServerStartupEvent(Priority.FILE_IO) public static void init() throws JsonIOException, IOException { Logger.info(Areas.class, ""init"", ""Loading areas...""); File[] spawnFiles = new File(PATH).listFiles(); for (File f : spawnFiles) { Set initial = JsonFileManager.loadJsonFile(f, Set.class); Set area = initial.stream().map(number -> { if (number instanceof Integer) return (Integer) number; else if (number instanceof Double) return ((Double) number).intValue(); else if (number instanceof Long) return ((Long) number).intValue(); else throw new IllegalArgumentException(""Unsupported chunk ID type: "" + number.getClass().getName()); }).collect(Collectors.toSet()); AREAS.put(f.getName().replace("".json"", """"), area); } Logger.info(Areas.class, ""init"", ""Loaded "" + AREAS.size() + "" areas...""); } @SuppressWarnings(""unlikely-arg-type"") public static boolean withinArea(String name, int chunkId) { Set area = AREAS.get(name); if (area != null) return AREAS.get(name).contains(chunkId); return false; } // public static void main(String[] args) throws JsonIOException, IOException { // Logger.setupFormat(); // Logger.setLevel(Level.FINE); //FINER for traces // JsonFileManager.setGSON(new GsonBuilder() // .setObjectToNumberStrategy(ToNumberPolicy.LONG_OR_DOUBLE) // .registerTypeAdapter(Controller.class, new ControllerAdapter()) // .registerTypeAdapter(Date.class, new DateAdapter()) // .registerTypeAdapter(PacketEncoder.class, new PacketEncoderAdapter()) // .registerTypeAdapter(Packet.class, new PacketAdapter()) // .registerTypeAdapterFactory(new RecordTypeAdapterFactory()) // .disableHtmlEscaping() // .setPrettyPrinting() // .create()); // // Settings.loadConfig(); // if (!Settings.getConfig().isDebug()) // Logger.setLevel(Level.WARNING); // Cache.init(Settings.getConfig().getCachePath()); // init(); // Set area = AREAS.get(""christmasevent""); // Set newMulti = new HashSet<>(); // for (int d : area) { // for (int newId : oldChunkIdToNewChunkIds(d)) // newMulti.add(newId); // } // JsonFileManager.saveJsonFile(newMulti, new File(""./dumps/christmasevent.json"")); // Set newOnes = JsonFileManager.loadJsonFile(new File(""./dumps/christmasevent.json""), Set.class); // System.out.println(newOnes); // } public static int[] oldChunkIdToNewChunkIds(int oldChunkId) { int chunkX = oldChunkId >> 14 & 2047; int chunkY = oldChunkId >> 3 & 2047; return new int[] { MapUtils.encode(MapUtils.Structure.CHUNK, chunkX, chunkY, 0), MapUtils.encode(MapUtils.Structure.CHUNK, chunkX, chunkY, 1), MapUtils.encode(MapUtils.Structure.CHUNK, chunkX, chunkY, 2), MapUtils.encode(MapUtils.Structure.CHUNK, chunkX, chunkY, 3) }; } }" "package com.rs.utils; public class BigBufferedImage extends BufferedImage { private static final String TMP_DIR = ""D:\\temp""; public static final int MAX_PIXELS_IN_MEMORY = 1024 * 1024; public static BufferedImage create(int width, int height, int imageType) { if (width * height <= MAX_PIXELS_IN_MEMORY) return new BufferedImage(width, height, imageType); try { final File tempDir = new File(TMP_DIR); System.out.println(""Width: "" + width +"", "" + height); return createBigBufferedImage(tempDir, width, height, imageType); } catch (IOException e) { throw new RuntimeException(e); } } public static BufferedImage create(File inputFile, int imageType) throws IOException { try (ImageInputStream stream = ImageIO.createImageInputStream(inputFile);) { Iterator readers = ImageIO.getImageReaders(stream); if (readers.hasNext()) try { ImageReader reader = readers.next(); reader.setInput(stream, true, true); int width = reader.getWidth(reader.getMinIndex()); int height = reader.getHeight(reader.getMinIndex()); BufferedImage image = create(width, height, imageType); int cores = Math.max(1, Runtime.getRuntime().availableProcessors() / 2); int block = Math.min(MAX_PIXELS_IN_MEMORY / cores / width, (int) (Math.ceil(height / (double) cores))); ExecutorService generalExecutor = Executors.newFixedThreadPool(cores); List> partLoaders = new ArrayList<>(); for (int y = 0; y < height; y += block) partLoaders.add(new ImagePartLoader( y, width, Math.min(block, height - y), inputFile, image)); generalExecutor.invokeAll(partLoaders); generalExecutor.shutdown(); return image; } catch (InterruptedException ex) { Logger.getLogger(BigBufferedImage.class.getName()).log(Level.SEVERE, null, ex); } } return null; } private static BufferedImage createBigBufferedImage(File tempDir, int width, int height, int imageType) throws FileNotFoundException, IOException { FileDataBuffer buffer = new FileDataBuffer(tempDir, width * height, 4); ColorModel colorModel = null; BandedSampleModel sampleModel = null; sampleModel = switch (imageType) { case TYPE_INT_RGB -> { colorModel = new ComponentColorModel(ColorSpace.getInstance(ColorSpace.CS_sRGB), new int[]{8, 8, 8, 0}, false, false, Transparency.TRANSLUCENT, DataBuffer.TYPE_BYTE); yield new BandedSampleModel(DataBuffer.TYPE_BYTE, width, height, 3); } case TYPE_INT_ARGB -> { colorModel = new ComponentColorModel(ColorSpace.getInstance(ColorSpace.CS_sRGB), new int[]{8, 8, 8, 8}, true, false, Transparency.TRANSLUCENT, DataBuffer.TYPE_BYTE); yield new BandedSampleModel(DataBuffer.TYPE_BYTE, width, height, 4); } default -> throw new IllegalArgumentException(""Unsupported image type: "" + imageType); }; SimpleRaster raster = new SimpleRaster(sampleModel, buffer, new Point(0, 0)); BigBufferedImage image = new BigBufferedImage(colorModel, raster, colorModel.isAlphaPremultiplied(), null); return image; } private static class ImagePartLoader implements Callable { private final int y; private final BufferedImage image; private final Rectangle region; private final File file; public ImagePartLoader(int y, int width, int height, File file, BufferedImage image) { this.y = y; this.image = image; this.file = file; region = new Rectangle(0, y, width, height); } @Override public ImagePartLoader call() throws Exception { Thread.currentThread().setPriority((Thread.MIN_PRIORITY + Thread.NORM_PRIORITY) / 2); try (ImageInputStream stream = ImageIO.createImageInputStream(file);) { Iterator readers = ImageIO.getImageReaders(stream); if (readers.hasNext()) { ImageReader reader = readers.next(); reader.setInput(stream, true, true); ImageReadParam param = reader.getDefaultReadParam(); param.setSourceRegion(region); BufferedImage part = reader.read(0, param); Raster source = part.getRaster(); WritableRaster target = image.getRaster(); target.setRect(0, y, source); } } return ImagePartLoader.this; } } private BigBufferedImage(ColorModel cm, SimpleRaster raster, boolean isRasterPremultiplied, Hashtable properties) { super(cm, raster, isRasterPremultiplied, properties); } public void dispose() { ((SimpleRaster) getRaster()).dispose(); } public static void dispose(RenderedImage image) { if (image instanceof BigBufferedImage bbi) bbi.dispose(); } private static class SimpleRaster extends WritableRaster { public SimpleRaster(SampleModel sampleModel, FileDataBuffer dataBuffer, Point origin) { super(sampleModel, dataBuffer, origin); } public void dispose() { ((FileDataBuffer) getDataBuffer()).dispose(); } } private static final class FileDataBufferDeleterHook extends Thread { static { Runtime.getRuntime().addShutdownHook(new FileDataBufferDeleterHook()); } private static final HashSet undisposedBuffers = new HashSet<>(); @Override public void run() { final FileDataBuffer[] buffers = undisposedBuffers.toArray(new FileDataBuffer[0]); for (FileDataBuffer b : buffers) b.disposeNow(); } } private static class FileDataBuffer extends DataBuffer { private final String id = ""buffer-"" + System.currentTimeMillis() + ""-"" + ((int) (Math.random() * 1000)); private File dir; private String path; private File[] files; private RandomAccessFile[] accessFiles; private MappedByteBuffer[] buffer; public FileDataBuffer(File dir, int size) throws FileNotFoundException, IOException { super(TYPE_BYTE, size); this.dir = dir; init(); } public FileDataBuffer(File dir, int size, int numBanks) throws FileNotFoundException, IOException { super(TYPE_BYTE, size, numBanks); this.dir = dir; init(); } private void init() throws FileNotFoundException, IOException { FileDataBufferDeleterHook.undisposedBuffers.add(this); if (dir == null) dir = new File("".""); if (!dir.exists()) throw new RuntimeException(""FileDataBuffer constructor parameter dir does not exist: "" + dir); if (!dir.isDirectory()) throw new RuntimeException(""FileDataBuffer constructor parameter dir is not a directory: "" + dir); path = dir.getPath() + ""/"" + id; File subDir = new File(path); subDir.mkdir(); buffer = new MappedByteBuffer[banks]; accessFiles = new RandomAccessFile[banks]; files = new File[banks]; for (int i = 0; i < banks; i++) { File file = files[i] = new File(path + ""/bank"" + i + "".dat""); final RandomAccessFile randomAccessFile = accessFiles[i] = new RandomAccessFile(file, ""rw""); buffer[i] = randomAccessFile.getChannel().map(FileChannel.MapMode.READ_WRITE, 0, getSize()); } } @Override public int getElem(int bank, int i) { return buffer[bank].get(i) & 0xff; } @Override public void setElem(int bank, int i, int val) { buffer[bank].put(i, (byte) val); } private void disposeNow() { final MappedByteBuffer[] disposedBuffer = buffer; buffer = null; disposeNow(disposedBuffer); } public void dispose() { final MappedByteBuffer[] disposedBuffer = buffer; buffer = null; new Thread(() -> disposeNow(disposedBuffer)).start(); } private void disposeNow(final MappedByteBuffer[] disposedBuffer) { FileDataBufferDeleterHook.undisposedBuffers.remove(this); if (disposedBuffer != null) for (MappedByteBuffer b : disposedBuffer) b.clear(); if (accessFiles != null) { for (RandomAccessFile file : accessFiles) try { file.close(); } catch (IOException e) { e.printStackTrace(); } accessFiles = null; } if (files != null) { for (File file : files) file.delete(); files = null; } if (path != null) { new File(path).delete(); path = null; } } } }" "package com.rs.utils; @PluginEventHandler public class DropSets { private final static String PATH = ""data/npcs/drops/""; public static HashMap DROPS = new HashMap<>(); public static HashMap NPC_DROPS = new HashMap<>(); public static final DropSet DEFAULT_DROPSET = new DropSet(new DropTable(0.0, 0.0, false)); final static Charset ENCODING = StandardCharsets.UTF_8; @ServerStartupEvent(Priority.FILE_IO) public static void init() { loadPackedNPCDrops(); } public static void reloadDrops() { NPC_DROPS.clear(); DROPS.clear(); loadPackedNPCDrops(); } public static DropSet getDropSet(String string) { if (NPC_DROPS.get(string) != null) return NPC_DROPS.get(string); return null; } public static DropSet getDropSet(int npcId) { if (NPC_DROPS.get(npcId) != null) return NPC_DROPS.get(npcId); if (NPC_DROPS.get(NPCDefinitions.getDefs(npcId).getName()) != null) return NPC_DROPS.get(NPCDefinitions.getDefs(npcId).getName()); return DEFAULT_DROPSET; } private static void loadPackedNPCDrops() { try { File[] dropFiles = new File(PATH).listFiles(); for (File f : dropFiles) loadFile(f); } catch (Throwable e) { Logger.handle(DropSets.class, ""loadPackedNPCDrops"", e); } } private static void loadFile(File f) throws JsonIOException, IOException { if (f.isDirectory()) { for (File dir : f.listFiles()) loadFile(dir); return; } DropSet table = (DropSet) JsonFileManager.loadJsonFile(f, DropSet.class); if (table != null) { table.getDropList(); if (table.isOverflowed()) System.err.println(f.getName() + "" is overflowed by "" + table.getDropList().getOverflow()); DROPS.put(f.getName(), table); if (table.getIds() != null) for (int id : table.getIds()) NPC_DROPS.put(id, table); if (table.getNames() != null) for (String name : table.getNames()) NPC_DROPS.put(name, table); } } public HashMap getDropMap() { return NPC_DROPS; } }" "package com.rs.utils; public class DumpItemConfigs { public static void main(String[] args) { //Cache.init(); dump2h(); } public static void dump2h() { try { File file = new File(""2hs.txt""); if (file.exists()) file.delete(); else file.createNewFile(); BufferedWriter writer = new BufferedWriter(new FileWriter(file)); writer.flush(); for (int id = 0; id < 7956; id++) { if (Equipment.isTwoHandedWeapon(new Item(id, 1))) writer.append(String.valueOf(id)).append("", ""); writer.flush(); } writer.close(); } catch (Exception e) { e.printStackTrace(); } } public static void dumpEquipInfo() { try { File file = new File(""itemEquipInfo.txt""); if (file.exists()) file.delete(); else file.createNewFile(); BufferedWriter writer = new BufferedWriter(new FileWriter(file)); writer.flush(); for (int id = 0; id < 7956; id++) { ItemDefinitions def = ItemDefinitions.getDefs(id); if (def.isWearItem()) //writer.append(id + "" "" + def.getEquipType() + "" "" + def.getEquipSlot()); writer.newLine(); writer.flush(); } writer.close(); } catch (Exception e) { e.printStackTrace(); } } public static boolean hasCombatRequirements(ItemDefinitions def) { if ((def.getWearingSkillRequiriments() == null) || def.getWearingSkillRequiriments().isEmpty()) return false; for (int skillId : def.getWearingSkillRequiriments().keySet()) { if (skillId < 0 && skillId > 6) return false; int level = def.getWearingSkillRequiriments().get(skillId); if (level < 0 || level > 99) return false; } return true; } public static void dumpItemInfo() { try { File file = new File(""wieldReqs.txt""); if (file.exists()) file.delete(); else file.createNewFile(); BufferedWriter writer = new BufferedWriter(new FileWriter(file)); writer.flush(); for (int id = 0; id < 7956; id++) { ItemDefinitions def = ItemDefinitions.getDefs(id); if (def.isWearItem()) if (hasCombatRequirements(def)) { writer.append(String.valueOf(id)).append("" ""); for (int skillId : def.getWearingSkillRequiriments().keySet()) { if (skillId < 0 && skillId > 6) continue; int level = def.getWearingSkillRequiriments().get(skillId); if (level < 0 || level > 120) continue; writer.append(String.valueOf(skillId)).append(""-"").append(String.valueOf(level)).append("" ""); } writer.newLine(); } writer.flush(); } writer.close(); } catch (Exception e) { e.printStackTrace(); } } }" "package com.rs.utils; public final class EconomyPrices { public static int getPrice(int itemId) { ItemDefinitions defs = ItemDefinitions.getDefs(itemId); if (defs.isNoted()) itemId = defs.getCertId(); else if (defs.isLended()) itemId = defs.getLendId(); if (!ItemConstants.isTradeable(new Item(itemId, 1))) return 0; if (itemId == 12183) return 25; if (itemId == 995) // TODO after here return 1; return defs.getHighAlchPrice(); // TODO get price from real item from saved // prices from ge } private EconomyPrices() { } }" "package com.rs.utils; public class EffigyDrop { public static boolean dropEffigy(int combatLevel) { return Math.random() <= (1.0 / getRate(combatLevel)); } public static double getRate(int combatLevel) { return Utils.clampD(169075.845*(Math.pow(0.9807522225, combatLevel)), 128.0, 1000000.0); } }" "package com.rs.utils; public class GenericsUtils { public static boolean isi(Object cst) { return cst instanceof Integer; } public static boolean iss(Object cst) { return cst instanceof String; } public static boolean isl(Object cst) { return cst instanceof Long; } public static Integer asi(Object cst) { return as(cst); } public static String ass(Object cst) { return as(cst); } public static Long asl(Object cst) { return as(cst); } public static int shrn(int val, int shr, int n) { return (val >>> shr) & n; } public static long shrn(long val, int shr, long n) { return (val >>> shr) & n; } @SuppressWarnings(""unchecked"") public static T as(Class t, Object cst) { return (T)cst; } @SuppressWarnings(""unchecked"") public static T as(Object cst) { return (T)cst; } }" "package com.rs.utils; /** * My custom Runtime debugging tool * Author: Jawarrior1 */ public class Getlineonce { static Dictionary> lines = new Hashtable<>(); public Getlineonce(boolean repeat) { StackTraceElement[] stackTrace = Thread.currentThread().getStackTrace(); //Check if this line as been taking, so as not to repeat with loops or recursion int line = stackTrace[2].getLineNumber(); String fileName = stackTrace[2].getFileName(); List tempLines = new ArrayList<>();//only used if key doesn't exist if (lines.isEmpty()) { tempLines.add(line); lines.put(fileName, tempLines); // lines.put(""tester"", oneline); } else { boolean keyExists = false; for (Enumeration k = lines.keys(); k.hasMoreElements(); ) { String key = k.nextElement(); //Check if there is a kay if (!key.equalsIgnoreCase(fileName)) continue; keyExists = true; if (!lines.get(key).contains(line)) { tempLines = lines.get(key); tempLines.add(line); lines.put(fileName, tempLines); Logger.debug(Getlineonce.class, ""constructor()"", fileName + "": "" + line);// should run once } else if (repeat) Logger.debug(Getlineonce.class, ""constructor()"", fileName + "": "" + line); } //If after searching all of those you found nothing if (!keyExists) { tempLines.add(line); lines.put(fileName, tempLines); } } } }" "package com.rs.utils; @PluginEventHandler public class ItemConfig { private static Map CONFIG_CACHE = new HashMap<>(); private static final Map UID_TO_ID = new HashMap<>(); private final static String PATH = ""./data/items/config.json""; private String uidName; private int dropSound = -1; private int equipSound = -1; private int attackDelay = -1; private Map attackAnims; private Map attackSounds; private int defendAnim = -1; private int defendSound = -1; private int attackRange = 0; private double weight; private String examine; @ServerStartupEvent(Priority.FILE_IO) public static void init() throws JsonIOException, IOException { if (new File(PATH).exists()) CONFIG_CACHE = JsonFileManager.loadJsonFile(new File(PATH), new TypeToken>(){}.getType()); else Logger.error(ItemConfig.class, ""init"", ""No item config file found at "" + PATH + ""!""); for (int key : CONFIG_CACHE.keySet()) { if (UID_TO_ID.get(CONFIG_CACHE.get(key).uidName) != null) Logger.error(ItemConfig.class, ""init"", ""Duplicate item uid names "" + CONFIG_CACHE.get(key).uidName + "" - "" + key); UID_TO_ID.put(CONFIG_CACHE.get(key).uidName, key); } } public static void main(String[] args) throws IOException { JsonFileManager.setGSON(new GsonBuilder() .registerTypeAdapter(Controller.class, new ControllerAdapter()) .registerTypeAdapter(Date.class, new DateAdapter()) .registerTypeAdapter(PacketEncoder.class, new PacketEncoderAdapter()) .registerTypeAdapter(Packet.class, new PacketAdapter()) .registerTypeAdapterFactory(new RecordTypeAdapterFactory()) .disableHtmlEscaping() .setPrettyPrinting() .create()); Settings.loadConfig(); Cache.init(Settings.getConfig().getCachePath()); init(); for (int i = 0;i < Utils.getItemDefinitionsSize();i++) { ItemConfig config = get(i); ItemDefinitions def = ItemDefinitions.getDefs(i); if (def.getEquipSlot() == Equipment.WEAPON) { String weaponName = def.getName().toLowerCase(); if (config.getAttackAnim(0) == -1) System.out.println(""Missing attack animation for: "" + i + "" ("" + weaponName + "")""); } } // JsonFileManager.saveJsonFile(CONFIG_CACHE, new File(PATH)); } public ItemConfig() { } public int getAttackRange() { return attackRange; } public int getDropSound() { return dropSound <= 0 ? 2739 : dropSound; } public int getEquipSound() { return equipSound <= 0 ? 2240 : equipSound; } /** * TODO * Dump all sounds into the config * Dump all existing anims into the config * Automatically dump any equippable item that is wieldable but does not have an animation */ public int getAttackSound(int attackStyleIndex) { return attackSounds == null ? -1 : attackSounds.getOrDefault(attackStyleIndex, attackSounds.get(0)); } public int getDefendSound() { return defendSound <= 0 ? 2240 : defendSound; } public int getAttackAnim(int attackStyleIndex) { //422 return attackAnims == null ? -1 : attackAnims.getOrDefault(attackStyleIndex, attackAnims.get(0)); } public int getAttackDelay() { return attackDelay <= 0 ? 3 : attackDelay; } public int getDefendAnim() { return defendAnim; } public double getWeight(boolean equipped) { if (weight < 0.0) { if (equipped) return weight; return 0; } return weight; } public String getUidName() { return uidName; } public String getExamine(Item item) { if (item.getAmount() >= 100000) return Utils.formatNumber(item.getAmount()) + "" x "" + item.getDefinitions().getName() + "".""; if (item.getDefinitions().isNoted()) return ""Swap this note at any bank for the equivalent item.""; return examine; } public static ItemConfig get(int itemId) { return CONFIG_CACHE.getOrDefault(itemId, new ItemConfig()); } public static ItemConfig get(Item item) { return CONFIG_CACHE.get(item.getId()); } public static int forUid(String uid) { if (UID_TO_ID.get(uid) == null) throw new IllegalArgumentException(""No item with UID "" + uid + "" found in item configuration.""); return UID_TO_ID.get(uid); } }" "package com.rs.utils fun Array.closestOrNull(tile: Tile): Entity? = this.minByOrNull { entity -> getDistance(entity.tile, tile) }" "package com.rs.utils; public class MachineInformation { public int operatingSystem; public boolean x64os; public int osVendor; public int javaVersion; public int javaSubBuild; public int javaBuild; public int javaUpdate; public int ram; public transient String aString8157; public transient String aString8160; public transient String aString8159; public transient String aString8153; public int[] rawCPUInformationData = new int[3]; public transient boolean idk; public int maxMem; public int processors; public int cpuCores; public int cpuClock; public String cpuType; public int rawCPUInformation2; public int rawCPUInformation; public String cpuData; public int dxDriverMonth; public int dxDriverYear; public static MachineInformation parse(InputStream stream) { MachineInformation info = new MachineInformation(); info.operatingSystem = stream.readUnsignedByte(); info.x64os = stream.readUnsignedByte() == 1; info.osVendor = stream.readUnsignedByte(); info.javaVersion = stream.readUnsignedByte(); info.javaBuild = stream.readUnsignedByte(); info.javaSubBuild = stream.readUnsignedByte(); info.javaUpdate = stream.readUnsignedByte(); info.idk = stream.readUnsignedByte() == 1; info.maxMem = stream.readUnsignedShort(); info.processors = stream.readUnsignedByte(); info.ram = stream.read24BitInt(); info.cpuClock = stream.readUnsignedShort(); info.aString8157 = stream.readJagString(); info.aString8160 = stream.readJagString(); info.aString8159 = stream.readJagString(); info.aString8153 = stream.readJagString(); info.dxDriverMonth = stream.readUnsignedByte(); info.dxDriverYear = stream.readUnsignedShort(); info.cpuType = stream.readJagString(); info.cpuData = stream.readJagString(); info.cpuCores = stream.readUnsignedByte(); for (int i = 0;i < info.rawCPUInformationData.length;i++) info.rawCPUInformationData[i] = stream.readInt(); info.rawCPUInformation2 = stream.readInt(); return info; } @Override public int hashCode() { int result = Objects.hash(operatingSystem, x64os, osVendor, javaVersion, javaSubBuild, javaBuild, javaUpdate, ram, aString8157, aString8160, aString8159, aString8153, idk, maxMem, processors, cpuCores, cpuClock, cpuType, rawCPUInformation2, rawCPUInformation, cpuData, dxDriverMonth, dxDriverYear); result = 31 * result + Arrays.hashCode(rawCPUInformationData); return result; } public String getVersion() { return javaBuild + ""."" + javaVersion + ""."" + javaSubBuild; } public void sendSuggestions(Player player) { String suggestion = null; String title = null; if (javaBuild < 6) { title = ""Client Issues""; suggestion = ""You seem to be using java version: "" + getVersion() + "".
    You should update to jre6.""; }/* * else if(javaVersionBuild != 0 || javaVersionBuild2 < 31) { title = * ""Outdated Java Version""; suggestion = * ""Your java seems outdated: ""+getVersion * ()+"".
    You should update your to 6.0.31.""; *//* * }else if (hasApplet && ((availableProcessors <= (x64Arch ? 2 : * 1)) || ram <= (x64Arch ? 1024 : 512) || cpuClockFrequency <= * 1500)) { title = ""Weak Specs""; suggestion = * ""Your computer seems to have weak specs. You'd better download desktop client for better perfomance."" * ; } */ if (title != null) { player.getInterfaceManager().sendInterface(405); player.getPackets().setIFText(405, 16, title); player.getPackets().setIFText(405, 17, suggestion); } } }" "package com.rs.utils; public class MapHeightCalc { private static final int JAGEX_CIRCULAR_ANGLE = 2048; private static final double ANGULAR_RATIO = 360D / JAGEX_CIRCULAR_ANGLE; private static final double JAGEX_RADIAN = Math.toRadians(ANGULAR_RATIO); private static final int[] SIN = new int[JAGEX_CIRCULAR_ANGLE]; private static final int[] COS = new int[JAGEX_CIRCULAR_ANGLE]; static { for (int i = 0; i < JAGEX_CIRCULAR_ANGLE; i++) { SIN[i] = (int) (65536.0D * Math.sin(i * JAGEX_RADIAN)); COS[i] = (int) (65536.0D * Math.cos(i * JAGEX_RADIAN)); } } public static int calculate(int x, int y) { int n = interpolateNoise(x + 45365, y + 91923, 4) - 128 + (interpolateNoise(10294 + x, y + 37821, 2) - 128 >> 1) + (interpolateNoise(x, y, 1) - 128 >> 2); n = 35 + (int) (n * 0.3D); if (n < 10) n = 10; else if (n > 60) n = 60; return n; } public static int interpolateNoise(int x, int y, int frequency) { int intX = x / frequency; int fracX = x & frequency - 1; int intY = y / frequency; int fracY = y & frequency - 1; int v1 = smoothedNoise1(intX, intY); int v2 = smoothedNoise1(intX + 1, intY); int v3 = smoothedNoise1(intX, intY + 1); int v4 = smoothedNoise1(1 + intX, 1 + intY); int i1 = interpolate(v1, v2, fracX, frequency); int i2 = interpolate(v3, v4, fracX, frequency); return interpolate(i1, i2, fracY, frequency); } public static int smoothedNoise1(int x, int y) { int corners = noise(x - 1, y - 1) + noise(x + 1, y - 1) + noise(x - 1, 1 + y) + noise(x + 1, y + 1); int sides = noise(x - 1, y) + noise(1 + x, y) + noise(x, y - 1) + noise(x, 1 + y); int center = noise(x, y); return center / 4 + sides / 8 + corners / 16; } public static int noise(int x, int y) { int n = x + y * 57; n ^= n << 13; return ((n * (n * n * 15731 + 789221) + 1376312589) & Integer.MAX_VALUE) >> 19 & 255; } public static int interpolate(int a, int b, int x, int y) { int f = 65536 - COS[1024 * x / y] >> 1; return (f * b >> 16) + (a * (65536 - f) >> 16); } }" "package com.rs.utils; public class NanotimeSleeper { private long aLong7735; private long aLong7738; private long aLong7734; private int anInt7737; private int anInt7736 = 1; long[] aLongArray7733 = new long[10]; public NanotimeSleeper() { aLong7738 = System.nanoTime(); aLong7734 = System.nanoTime(); } public long method4852() { return aLong7738; } public long getSleepTimeMs() { aLong7738 += method12495(); return aLong7734 > aLong7738 ? (aLong7734 - aLong7738) / 1000000L : 0L; } public int sleepNano(long nanoseconds) { long sleepTime = getSleepTimeMs(); try { if (sleepTime > 0L) if (sleepTime % 10L == 0L) { Thread.sleep(sleepTime - 1L); Thread.sleep(1L); } else Thread.sleep(sleepTime); } catch (InterruptedException e) { } return method4845(nanoseconds); } public int method4845(long long_1) { if (aLong7734 > aLong7738) { aLong7735 += aLong7734 - aLong7738; aLong7738 += aLong7734 - aLong7738; aLong7734 += long_1; return 1; } int ticksSkipped = 0; do { ++ticksSkipped; aLong7734 += long_1; } while (ticksSkipped < 10 && aLong7734 < aLong7738); if (aLong7734 < aLong7738) aLong7734 = aLong7738; return ticksSkipped; } public void method4853() { aLong7735 = 0L; if (aLong7734 > aLong7738) aLong7738 += aLong7734 - aLong7738; } public long method12495() { long currTime = System.nanoTime(); long elapsed = currTime - aLong7735; aLong7735 = currTime; if (elapsed > -5000000000L && elapsed < 5000000000L) { aLongArray7733[anInt7737] = elapsed; anInt7737 = (anInt7737 + 1) % 10; if (anInt7736 < 1) ++anInt7736; } long long_6 = 0L; for (int i_8 = 1; i_8 <= anInt7736; i_8++) long_6 += aLongArray7733[(anInt7737 - i_8 + 10) % 10]; return long_6 / anInt7736; } }" "package com.rs.utils; public class NPCClueDrops { private static final Map EASY = new HashMap<>(); private static final Map MEDIUM = new HashMap<>(); private static final Map HARD = new HashMap<>(); private static final Map ELITE = new HashMap<>(); static { EASY.put(""banshee"", new ClueDrop(128)); EASY.put(""barbarian"", new ClueDrop(128)); EASY.put(""borrokar"", new ClueDrop(128)); EASY.put(""cave slime"", new ClueDrop(128)); EASY.put(""dagannoth spawn"", new ClueDrop(128)); EASY.put(""farmer"", new ClueDrop(128)); EASY.put(""freidir"", new ClueDrop(128)); EASY.put(""freygerd"", new ClueDrop(128)); EASY.put(""giant cave bug"", new ClueDrop(128)); EASY.put(""goblin"", new ClueDrop(128)); EASY.put(""icefiend"", new ClueDrop(128)); EASY.put(""inga"", new ClueDrop(128)); EASY.put(""jennella"", new ClueDrop(128)); EASY.put(""lanzig"", new ClueDrop(128)); EASY.put(""lensa"", new ClueDrop(128)); EASY.put(""molanisk"", new ClueDrop(128)); EASY.put(""mugger"", new ClueDrop(128)); EASY.put(""ork"", new ClueDrop(128)); EASY.put(""pontak"", new ClueDrop(128)); EASY.put(""rock crab"", new ClueDrop(128)); EASY.put(""sassilik"", new ClueDrop(128)); EASY.put(""thug"", new ClueDrop(128)); EASY.put(""werewolf"", new ClueDrop(128)); EASY.put(""agnar"", new ClueDrop(128)); EASY.put(""h.a.m. guard"", new ClueDrop(55)); EASY.put(""icefiend"", new ClueDrop(128)); EASY.put(""man"", new ClueDrop(128)); EASY.put(""minotaur"", new ClueDrop(101)); EASY.put(""skeleton"", new ClueDrop(128, 21, 22, 25)); EASY.put(""woman"", new ClueDrop(128)); MEDIUM.put(""abyssal guardian"", new ClueDrop(256)); MEDIUM.put(""abyssal leech"", new ClueDrop(256)); MEDIUM.put(""abyssal walker"", new ClueDrop(256)); MEDIUM.put(""barbarian skeleton"", new ClueDrop(128)); MEDIUM.put(""barbarian spirit"", new ClueDrop(128)); MEDIUM.put(""black guard"", new ClueDrop(128)); MEDIUM.put(""black guard berserker"", new ClueDrop(128)); MEDIUM.put(""black heather"", new ClueDrop(128)); MEDIUM.put(""brine rat"", new ClueDrop(128)); MEDIUM.put(""catablepon"", new ClueDrop(101)); MEDIUM.put(""cockatrice"", new ClueDrop(128)); MEDIUM.put(""dagannoth"", new ClueDrop(128)); MEDIUM.put(""donny the lad"", new ClueDrop(128)); MEDIUM.put(""giant sea snake"", new ClueDrop(128)); MEDIUM.put(""giant rock crab"", new ClueDrop(128)); MEDIUM.put(""giant skeleton"", new ClueDrop(128, 100)); MEDIUM.put(""guard"", new ClueDrop(128)); MEDIUM.put(""harpie swarm"", new ClueDrop(128)); MEDIUM.put(""ice warrior"", new ClueDrop(128)); MEDIUM.put(""jogre"", new ClueDrop(129)); MEDIUM.put(""jungle horror"", new ClueDrop(128)); MEDIUM.put(""magic axe"", new ClueDrop(256)); MEDIUM.put(""magic pickaxe"", new ClueDrop(256)); MEDIUM.put(""paladin"", new ClueDrop(128)); MEDIUM.put(""pyrefiend"", new ClueDrop(128)); MEDIUM.put(""rock lobster"", new ClueDrop(128)); MEDIUM.put(""sea snake hatchling"", new ClueDrop(128)); MEDIUM.put(""sea snake young"", new ClueDrop(128)); MEDIUM.put(""skeleton"", new ClueDrop(128, 87, 72, 13, 45, 77)); MEDIUM.put(""skeleton mage"", new ClueDrop(128, 94)); MEDIUM.put(""skeleton miner"", new ClueDrop(128)); MEDIUM.put(""speedy keith"", new ClueDrop(128)); MEDIUM.put(""tribesman"", new ClueDrop(138)); MEDIUM.put(""vampyre"", new ClueDrop(128)); MEDIUM.put(""wallasalki"", new ClueDrop(128)); MEDIUM.put(""werewolf"", new ClueDrop(512)); MEDIUM.put(""mummy"", new ClueDrop(513)); HARD.put(""aberrant spectre"", new ClueDrop(128)); HARD.put(""abyssal demon"", new ClueDrop(128)); HARD.put(""ankou"", new ClueDrop(512)); HARD.put(""balfrug kreeyath"", new ClueDrop(128)); HARD.put(""black demon"", new ClueDrop(128)); HARD.put(""black dragon"", new ClueDrop(128)); HARD.put(""bloodveld"", new ClueDrop(256)); HARD.put(""blue dragon"", new ClueDrop(128)); HARD.put(""bree"", new ClueDrop(128)); HARD.put(""bronze dragon"", new ClueDrop(128)); HARD.put(""brutal green dragon"", new ClueDrop(128)); HARD.put(""cave horror"", new ClueDrop(128)); HARD.put(""cosmic being"", new ClueDrop(128)); HARD.put(""dagannoth rex"", new ClueDrop(42)); HARD.put(""dagannoth supreme"", new ClueDrop(42)); HARD.put(""dagannoth prime"", new ClueDrop(42)); HARD.put(""dark beast"", new ClueDrop(128)); HARD.put(""elf warrior"", new ClueDrop(128)); HARD.put(""flight kilisa"", new ClueDrop(128)); HARD.put(""flockleader geerin"", new ClueDrop(128)); HARD.put(""gargoyle"", new ClueDrop(128)); HARD.put(""gorak"", new ClueDrop(128)); HARD.put(""greater demon"", new ClueDrop(128)); HARD.put(""green dragon"", new ClueDrop(128)); HARD.put(""growler"", new ClueDrop(128)); HARD.put(""hellhound"", new ClueDrop(64)); HARD.put(""iron dragon"", new ClueDrop(128)); HARD.put(""jelly"", new ClueDrop(128)); HARD.put(""kurask"", new ClueDrop(128)); HARD.put(""nechryael"", new ClueDrop(128)); HARD.put(""red dragon"", new ClueDrop(128)); HARD.put(""saradomin knight"", new ClueDrop(128)); HARD.put(""saradomin priest"", new ClueDrop(128)); HARD.put(""sergeant grimspike"", new ClueDrop(128)); HARD.put(""sergeant steelwill"", new ClueDrop(128)); HARD.put(""sergeant strongstack"", new ClueDrop(128)); HARD.put(""spiritual mage"", new ClueDrop(128)); HARD.put(""spiritual ranger"", new ClueDrop(128)); HARD.put(""spiritual warrior"", new ClueDrop(128)); HARD.put(""starlight"", new ClueDrop(128)); HARD.put(""steel dragon"", new ClueDrop(64)); HARD.put(""suqah"", new ClueDrop(129)); HARD.put(""terror dog"", new ClueDrop(128)); HARD.put(""tstanon karlak"", new ClueDrop(128)); HARD.put(""vyrewatch"", new ClueDrop(128)); HARD.put(""waterfiend"", new ClueDrop(128)); HARD.put(""wingman skree"", new ClueDrop(128)); HARD.put(""zakl'n gritch"", new ClueDrop(128)); HARD.put(""bandit"", new ClueDrop(128)); HARD.put(""cyclops"", new ClueDrop(512)); HARD.put(""dark warrior"", new ClueDrop(128)); HARD.put(""ork"", new ClueDrop(128)); HARD.put(""turoth"", new ClueDrop(128)); HARD.put(""jungle strykewyrm"", new ClueDrop(128)); HARD.put(""desert strykewyrm"", new ClueDrop(128)); HARD.put(""ice strykewyrm"", new ClueDrop(128)); HARD.put(""glacor"", new ClueDrop(128)); HARD.put(""mithril dragon"", new ClueDrop(128)); HARD.put(""scabaras ranger"", new ClueDrop(128)); HARD.put(""scabaras lancer"", new ClueDrop(128)); HARD.put(""locust lancer"", new ClueDrop(128)); HARD.put(""locust ranger"", new ClueDrop(128)); ELITE.put(""abyssal demon"", new ClueDrop(1200)); ELITE.put(""black dragon"", new ClueDrop(500)); ELITE.put(""nex"", new ClueDrop(128)); ELITE.put(""jungle strykewyrm"", new ClueDrop(500)); ELITE.put(""desert strykewyrm"", new ClueDrop(500)); ELITE.put(""ice strykewyrm"", new ClueDrop(500)); ELITE.put(""glacor"", new ClueDrop(500)); ELITE.put(""bronze dragon"", new ClueDrop(500)); ELITE.put(""chaos elemental"", new ClueDrop(200)); ELITE.put(""commander zilyana"", new ClueDrop(250)); ELITE.put(""corporeal beast"", new ClueDrop(200)); ELITE.put(""dagannoth prime"", new ClueDrop(750)); ELITE.put(""dagannoth rex"", new ClueDrop(750)); ELITE.put(""dagannoth supreme"", new ClueDrop(750)); ELITE.put(""dark beast"", new ClueDrop(1200)); ELITE.put(""general graardor"", new ClueDrop(250)); ELITE.put(""giant mole"", new ClueDrop(500)); ELITE.put(""k'ril tsutsaroth"", new ClueDrop(250)); ELITE.put(""kalphite queen"", new ClueDrop(100)); ELITE.put(""king black dragon"", new ClueDrop(450)); ELITE.put(""kree'arra"", new ClueDrop(250)); ELITE.put(""salarin the twisted"", new ClueDrop(500)); ELITE.put(""skeletal wyvern"", new ClueDrop(350)); ELITE.put(""steel dragon"", new ClueDrop(500)); ELITE.put(""tormented demon"", new ClueDrop(1500)); ELITE.put(""ganodermic beast"", new ClueDrop(1200)); ELITE.put(""mithril dragon"", new ClueDrop(350)); } public static DropSet rollClues(int npcId) { List tables = new ArrayList<>(); NPCDefinitions defs = NPCDefinitions.getDefs(npcId); String name = defs.getName().toLowerCase(); ClueDrop drop; drop = EASY.get(name); if (drop != null && drop.validCombatLevel(defs.combatLevel)) tables.add(new DropTable(1.0, drop.getWeight(), new Drop(TreasureTrailsManager.SCROLL_BOXES[0]))); drop = MEDIUM.get(name); if (drop != null && drop.validCombatLevel(defs.combatLevel)) tables.add(new DropTable(1.0, drop.getWeight(), new Drop(TreasureTrailsManager.SCROLL_BOXES[1]))); drop = HARD.get(name); if (drop != null && drop.validCombatLevel(defs.combatLevel)) tables.add(new DropTable(1.0, drop.getWeight(), new Drop(TreasureTrailsManager.SCROLL_BOXES[2]))); drop = ELITE.get(name); if (drop != null && drop.validCombatLevel(defs.combatLevel)) tables.add(new DropTable(1.0, drop.getWeight(), new Drop(TreasureTrailsManager.SCROLL_BOXES[3]))); return new DropSet(tables); } }" "package com.rs.utils; @PluginEventHandler public class NPCExamines { private static Map EXAMINES = new HashMap<>(); private final static String PATH = ""./data/npcs/examines.json""; @ServerStartupEvent(Priority.FILE_IO) public static void init() throws JsonIOException, IOException { if (new File(PATH).exists()) EXAMINES = JsonFileManager.loadJsonFile(new File(PATH), new TypeToken>(){}.getType()); else System.err.println(""No NPC examines file found at "" + PATH + ""!""); } public static String getExamine(NPC npc, Player player) { if(Settings.getConfig().isDebug()) player.sendMessage(npc.getId() + "", X: "" + npc.getX() + "", Y: "" + npc.getY() + "", Plane: "" + npc.getPlane() + "". Transforms with varbit "" + npc.getDefinitions().varpBit + "" and var "" + npc.getDefinitions().varp); String examine = EXAMINES.get(npc.getId()); if (examine != null) return examine; return ""It's "" + Utils.addArticle(npc.getDefinitions().getName(player.getVars())).toLowerCase() + "".""; } }" "package com.rs.utils; public class ObjAnimList { private static final Set USED = new HashSet<>(); private static final List OBJECT_ANIMS = new ArrayList<>(); public static void main(String[] args) throws IOException { //Cache.init(); init(); System.out.println(OBJECT_ANIMS.size()); } public static boolean inited() { return USED.size() > 0; } public static boolean isUsed(int anim) { return USED.contains(anim); } public static void init() { for (int npcId = 0;npcId < Utils.getNPCDefinitionsSize();npcId++) { NPCDefinitions npcDef = NPCDefinitions.getDefs(npcId); if (npcDef.basId != -1) if (BASDefinitions.getDefs(npcDef.basId).standAnimation != -1) if (AnimationDefinitions.getDefs(BASDefinitions.getDefs(npcDef.basId).standAnimation).frameSetIds != null) { int skeleton = AnimationDefinitions.getDefs(BASDefinitions.getDefs(npcDef.basId).standAnimation).frameSetIds[0]; for (int i = 0; i < Utils.getAnimationDefinitionsSize(); i++) { AnimationDefinitions check = AnimationDefinitions.getDefs(i); if ((check == null) || check.frameSetIds == null || check.frameSetIds[0] == -1) continue; if (check.frameSetIds[0] == skeleton) USED.add(i); } } } for (int spotAnimId = 0;spotAnimId < Utils.getSpotAnimDefinitionsSize();spotAnimId++) { SpotAnimDefinitions defs = SpotAnimDefinitions.getDefs(spotAnimId); if (defs.animationId != -1) USED.add(defs.animationId); } for (int objectId = 0;objectId < Utils.getObjectDefinitionsSize();objectId++) { ObjectDefinitions defs = ObjectDefinitions.getDefs(objectId); if (defs.animations != null) for (int animId : defs.animations) USED.add(animId); } for (int i = 0; i < Utils.getAnimationDefinitionsSize(); i++) if (!USED.contains(i)) OBJECT_ANIMS.add(i); } }" "package com.rs.utils; public class ReportsManager { public static void report(Player player) { report(player, null); } public static void report(Player player, String name) { if (player.getInterfaceManager().containsScreenInter()) { player.sendMessage(""Please close the interface that you opened before activating the 'Report' system.""); return; } if (name != null) player.getPackets().sendVarcString(24, name); if (player.hasRights(Rights.MOD)) player.getPackets().setIFHidden(594, 8, false); player.getInterfaceManager().sendInterface(594); } public static void report(Player player, String displayName, int type, boolean mute) { if (mute && !player.hasRights(Rights.MOD)) return; if (displayName == null) return; Player reported = World.getPlayerByUsername(displayName); if (reported == null) return; if (mute) { reported.getAccount().muteDays(2); reported.sendMessage(""You've been muted for 2 days by "" + player.getDisplayName() + "".""); LobbyCommunicator.updatePunishments(reported); } player.sendMessage(""Thank-you, your abuse report has been received.""); try { // Rule rule = Rule.forId(type); // if (rule != null) // WorldDB.getLogs().logReport(player, reported, rule); } catch (Throwable e) { Logger.handle(ReportsManager.class, ""report"", e); } } public enum Rule { BUG_EXPLOITATION(4), STAFF_IMPERSONATION(5), REAL_WORLD_TRADING(6, 17), MACROING(7), ENCOURAGING_RULE_BREAKING(9), SCAMMING(15), OFFENSIVE_LANGUAGE(16), DISRUPTIVE_BEHAVIOR(18), OFFENSIVE_NAME(19), REAL_WORLD_OFFENSE(20, 21, 13), ADVERTISING(11); private static final Map MAPPING = new HashMap<>(); static { for (Rule rule : Rule.values()) { for (int id : rule.ids) MAPPING.put(id, rule); } } public static Rule forId(int id) { return MAPPING.get(id); } private final int[] ids; private Rule(int... ids) { this.ids = ids; } public int[] getIds() { return ids; } } }" "package com.rs.utils; public class RSAKeyGenerator { public static void main(String[] args) throws IOException, NoSuchAlgorithmException, InvalidKeySpecException { KeyFactory factory = KeyFactory.getInstance(""RSA""); KeyPairGenerator keyGen = KeyPairGenerator.getInstance(""RSA""); keyGen.initialize(1024); KeyPair keypair = keyGen.genKeyPair(); PrivateKey privateKey = keypair.getPrivate(); PublicKey publicKey = keypair.getPublic(); RSAPrivateKeySpec privSpec = factory.getKeySpec(privateKey, RSAPrivateKeySpec.class); RSAPublicKeySpec pubSpec = factory.getKeySpec(publicKey, RSAPublicKeySpec.class); System.out.println(""public static final BigInteger RSA_PRIVATE_MODULUS = new BigInteger(\"""" + privSpec.getModulus().toString() + ""\"");""); System.out.println(""public static final BigInteger RSA_PRIVATE_EXPONENT = new BigInteger(\"""" + privSpec.getPrivateExponent().toString() + ""\"");""); System.out.println(""public static final BigInteger RSA_PUBLIC_MODULUS = new BigInteger(\"""" + pubSpec.getModulus().toString() + ""\"");""); System.out.println(""public static final BigInteger RSA_PUBLIC_EXPONENT = new BigInteger(\"""" + pubSpec.getPublicExponent().toString() + ""\"");""); } }" "package com.rs.utils; public class Test { public static int HOURS_TO_SAMPLE = 300; public static void main(String[] args) throws IOException { JsonFileManager.setGSON(new GsonBuilder() .registerTypeAdapter(Controller.class, new ControllerAdapter()) .registerTypeAdapter(Date.class, new DateAdapter()) .registerTypeAdapter(PacketEncoder.class, new PacketEncoderAdapter()) .registerTypeAdapter(Packet.class, new PacketAdapter()) .registerTypeAdapterFactory(new RecordTypeAdapterFactory()) .disableHtmlEscaping() .setPrettyPrinting() .create()); Settings.getConfig(); Cache.init(Settings.getConfig().getCachePath()); // IComponentDefinitions[] summ = IComponentDefinitions.getInterface(672); // for (int i = 0;i < summ.length;i++) // System.out.println(summ[i]); int num = 2319; DropSet reward = new DropSet( new DropTable(995, 5000), new DropTable(75, 100, new Drop(995, 10000), new Drop(1392, 2), new Drop(565, 20), new Drop(5300, 1)), new DropTable(20, 100, 1305, 1), new DropTable(5, 100, 989, 1)); long total = 0; for (int i = 0; i < 1_000_000; i++) { total += Arrays.stream(DropTable.calculateDrops(reward)) .mapToInt(item -> Utils.clampI(item.getDefinitions().getHighAlchPrice(), 1, Integer.MAX_VALUE) * item.getAmount()) .sum(); } System.out.println(""Average loot per key: "" + (total / 1_000_000L)); } // public static void main(String[] args) throws IOException { // int numKills = 1000000; // // JsonFileManager.setGSON(new GsonBuilder() // .registerTypeAdapter(Controller.class, new ControllerAdapter()) // .registerTypeAdapter(Date.class, new DateAdapter()) // .registerTypeAdapter(PacketEncoder.class, new PacketEncoderAdapter()) // .registerTypeAdapter(Packet.class, new PacketAdapter()) // .registerTypeAdapterFactory(new RecordTypeAdapterFactory()) // .disableHtmlEscaping() // .setPrettyPrinting() // .create()); // // Settings.getConfig(); // Cache.init(Settings.getConfig().getCachePath()); // DropSets.init(); // // ItemsContainer items = new ItemsContainer<>(500, true); // // DropList table = DropSets.getDropSet(6260).createDropList(); // for (int i = 0;i < numKills;i++) // items.addAll(table.genDrop()); // // List sorted = new ArrayList<>(); // // for (Item item : items.array()) { // if (item == null) // continue; // sorted.add(item); // } // // sorted.sort((o1, o2) -> o1.getId() - o2.getId()); // // for (Item item : sorted) // Logger.debug(item.getName() + "" - "" + item.getAmount() + "" Rate: 1/"" + (numKills / item.getAmount())); // } // for (int i = 0;i < 2000;i++) { // int musicIndex = (int) EnumDefinitions.getEnum(1351).getKeyForValue(i); // if (musicIndex != -1) { // String musicName = EnumDefinitions.getEnum(1345).getStringValue(musicIndex); // Logger.debug(i + "" - "" + musicName + "" - musicIndex: "" + musicIndex); // } // } // for (NPCDirection dir : NPCDirection.values()) { // Logger.debug(dir.name() + "" - "" + dir.getFaceDirection()); // int d = ((int) (Math.atan2(dir.getDx(), dir.getDy()) * 2607.5945876176133)); // double ang = d / 2607.5945876176133; // Logger.debug(Math.round(Math.sin(ang)) + "", "" + Math.round(Math.cos(ang))); // } // // // RockType rock = RockType.GEM; // Pickaxe pick = Pickaxe.RUNE; // for (int pickIdx = Pickaxe.BRONZE.ordinal();pickIdx <= Pickaxe.DRAGON.ordinal();pickIdx += 2) { // for (int i = 1;i <= 99;i += 1) { // if (i % 5 == 0 || i == rock.getLevel() || i == 99) { // String average = getMiningAverage(rock, i, Pickaxe.values()[pickIdx]); // if (!average.isEmpty()) // Logger.debug(average); // } // } // Logger.debug(); // } // for (int i = 1; i <= 99; i += 1) { // if (i % 5 == 0 || i == rock.getLevel() || i == 99) { // String average = getMiningAverage(rock, i, pick); // if (!average.isEmpty()) // Logger.debug(average); // } // } // } // // private static String getFishingAverage(FishingSpot spot, int level) { // if (level < spot.getLevel()) // return """"; // ItemsContainer fishContainer = new ItemsContainer<>(10, true); // // int attemptsPerHour = (60*60*1000)/(5*600); // int xp = 0; // for (int hours = 0;hours < HOURS_TO_SAMPLE;hours++) { // for (int i = 0;i < attemptsPerHour;i++) { // for (Fish f : spot.getFish()) { // if (level >= f.getLevel() && f.rollSuccess(level)) { // fishContainer.add(new Item(f.getId(), 1)); // xp += f.getXp(); // break; // } // } // } // } // // String fishCounts = """"; // List sorted = fishContainer.asList(); // sorted.sort((o1, o2) -> { // return o1.getName().compareTo(o2.getName()); // }); // for (Item f : sorted) { // if (f != null) // fishCounts += (int) ((double) f.getAmount() / (double) HOURS_TO_SAMPLE) + "" "" + f.getName() + "", ""; // } // // return spot.name() + "" -> Level: "" + level + "" Caught: "" + fishCounts + "" XP: "" + Utils.formatNumber((int) (xp / HOURS_TO_SAMPLE)); // } // // private static String getWoodcuttingAverage(TreeType tree, int level, Hatchet hatchet) { // if (level < tree.getLevel()) // return """"; // ItemsContainer wood = new ItemsContainer<>(10, true); // // int attemptsPerHour = (60*60*1000)/(4*600); // int xp = 0; // for (int hours = 0;hours < HOURS_TO_SAMPLE;hours++) { // for (int i = 0;i < attemptsPerHour;i++) { // if (tree.rollSuccess(level, hatchet)) { // wood.add(new Item(tree.getLogsId()[0], 1)); // xp += tree.getXp(); // } // } // } // // String logCounts = """"; // List sorted = wood.asList(); // sorted.sort((o1, o2) -> { // return o1.getName().compareTo(o2.getName()); // }); // for (Item f : sorted) { // if (f != null) // logCounts += (int) ((double) f.getAmount() / (double) HOURS_TO_SAMPLE) + "" "" + f.getName() + "", ""; // } // // return ""Tree: "" + tree.name() + "" Hatchet: "" + hatchet.name() + "" Level: "" + level + "" Cut: "" + logCounts + "" XP: "" + Utils.formatNumber((int) (xp / HOURS_TO_SAMPLE)); // } // // private static String getMiningAverage(RockType rock, int level, Pickaxe pick) { // if (level < rock.getLevel() || level < pick.getLevel()) // return """"; // ItemsContainer ores = new ItemsContainer<>(10, true); // // int totalTicks = 6000 * HOURS_TO_SAMPLE; // int usedTicks = 0; // int xp = 0; // int tries = 0; // while (usedTicks < totalTicks) { // boolean success = false; // tries++; // for (Ore ore : rock.getOres()) { // if (level >= ore.getLevel() && ore.rollSuccess(level)) { // ores.add(new Item(ore.getId(), 1)); // xp += ore.getXp(); // success = true; // break; // } // } // if (success) { // if ((pick == Pickaxe.DRAGON || pick == Pickaxe.DRAGON_G) && Utils.random(2) == 0) // usedTicks += tries <= 1 ? 2 : pick.getTicks()-1; // else // usedTicks += tries <= 1 ? 3 : pick.getTicks(); // tries = 0; // } else { // if ((pick == Pickaxe.DRAGON || pick == Pickaxe.DRAGON_G) && Utils.random(2) == 0) // usedTicks += pick.getTicks()-1; // else // usedTicks += pick.getTicks(); // } // } // // String logCounts = """"; // List sorted = ores.asList(); // sorted.sort((o1, o2) -> { // return o1.getName().compareTo(o2.getName()); // }); // for (Item f : sorted) { // if (f != null) // logCounts += (int) ((double) f.getAmount() / (double) HOURS_TO_SAMPLE) + "" "" + f.getName() + "", ""; // } // // return ""Rock: "" + rock.name() + "" Pickaxe: "" + pick.name() + "" Level: "" + level + "" Mined: "" + logCounts + "" XP: "" + Utils.formatNumber((int) (xp / HOURS_TO_SAMPLE)); // } // // private static String getJagAverageFor(int ticksPerAction, int level, int sucLvl1, int sucLvl99, double xp) { // return getJagAverageFor(ticksPerAction, level, 0, sucLvl1, sucLvl99, xp); // } // // private static String getJagAverageFor(int ticksPerAction, int level, int toolBonus, int sucLvl1, int sucLvl99, double xp) { // int attemptsPerHour = (60*60*1000)/(ticksPerAction*600); // int caught = 0; // for (int hours = 0;hours < HOURS_TO_SAMPLE;hours++) { // for (int i = 0;i < attemptsPerHour;i++) { // if (Utils.skillSuccess(level, toolBonus, sucLvl1, sucLvl99)) // caught++; // } // } // // return ""Level: "" + level + "" Tool: ""+toolBonus+"" Items: "" + Utils.formatNumber(caught / HOURS_TO_SAMPLE) + "" XP: "" + Utils.formatNumber((int) (xp * (caught / HOURS_TO_SAMPLE))); // } }" "package com.rs.utils; public class Ticks { public static int fromHours(int hours) { return fromMinutes(hours * 60); } public static int fromMinutes(int minutes) { return minutes * 100; } public static int fromMinutes(double minutes) { return (int) (minutes * 100); } public static int fromSeconds(int seconds) { return (int) (seconds / 0.6); } }" "package com.rs.utils; public class Timer { private long time = 0L; private long timeMs = 0L; public Timer() { } public Timer start() { time = System.nanoTime(); return this; } public String stop() { time = System.nanoTime() - time; timeMs = TimeUnit.NANOSECONDS.toMillis(time); return getFormattedTime(); } public String getFormattedTime() { if (timeMs > 5) return Utils.formatLong(timeMs) + ""ms""; return Utils.formatDouble(time / 1000000.0) + ""ms""; } public long getTimeMs() { return timeMs; } }" "package com.rs.utils; public class ToolbeltDump { @SuppressWarnings(""unused"") public static void main(String[] args) throws IOException { //Cache.init(); EnumDefinitions general = EnumDefinitions.getEnum(5350); EnumDefinitions fishing = EnumDefinitions.getEnum(5353); EnumDefinitions crafting = EnumDefinitions.getEnum(5356); EnumDefinitions farming = EnumDefinitions.getEnum(5359); EnumDefinitions dung = EnumDefinitions.getEnum(5731); System.out.println(EnumDefinitions.getEnum(5732).getValues().values()); for (Object itemId : dung.getValues().values()) System.out.println(ItemDefinitions.getDefs((int) itemId).name.toUpperCase().replace("" "", ""_"") + ""(0000, "" + itemId + ""),""); } }" "package com.rs.utils; @FunctionalInterface public interface TriFunction { R apply(A a, B b, C c); default TriFunction andThen(Function after) { Objects.requireNonNull(after); return (A a, B b, C c) -> after.apply(apply(a, b, c)); } }" "package com.rs.utils; @PluginEventHandler public class WorldPersistentData { private static final String DATA_PATH = ""./data/world.json""; private static WorldPersistentData ATTRIBUTES; @ServerStartupEvent(Priority.FILE_IO) public static void loadStorage() { File dataFile = new File(DATA_PATH); if (!dataFile.exists()) ATTRIBUTES = new WorldPersistentData(); else try { ATTRIBUTES = JsonFileManager.loadJsonFile(dataFile, WorldPersistentData.class); } catch (Exception e) { e.printStackTrace(); ATTRIBUTES = new WorldPersistentData(); } } public static void save() { try { File dataFile = new File(DATA_PATH); if (ATTRIBUTES == null) ATTRIBUTES = new WorldPersistentData(); JsonFileManager.saveJsonFile(ATTRIBUTES, dataFile); } catch (IOException e) { e.printStackTrace(); } } private final GenericAttribMap counters; private ItemsContainer partyRoomStorage; private ItemsContainer partyRoomDrop; public WorldPersistentData() { counters = new GenericAttribMap(); } public static WorldPersistentData get() { return ATTRIBUTES; } public GenericAttribMap getAttribs() { return counters; } public ItemsContainer getPartyRoomStorage() { if (partyRoomStorage == null) partyRoomStorage = new ItemsContainer<>(216, false); return partyRoomStorage; } public ItemsContainer getPartyRoomDrop() { if (partyRoomDrop == null) partyRoomDrop = new ItemsContainer<>(216, false); return partyRoomDrop; } }" "package com.rs.utils; public class WorldUtil { public static byte[] completeQuickMessage(Player player, int fileId, byte[] data) { QCMesDefinitions defs = QCMesDefinitions.getDefs(fileId); if (defs == null || defs.types == null) return null; OutputStream stream = new OutputStream(); System.out.println(Arrays.toString(defs.types)); System.out.println(defs); for (int i = 0;i < defs.types.length;i++) switch(defs.types[i]) { case STAT_BASE -> stream.writeByte(player.getSkills().getLevelForXp(defs.configs[i][0])); case TOSTRING_VARP -> stream.writeInt(player.getVars().getVar(defs.configs[i][0])); case TOSTRING_VARBIT -> stream.writeInt(player.getVars().getVarBit(defs.configs[i][0])); case ENUM_STRING -> stream.writeInt(player.getVars().getVar(defs.configs[i][1]-1)); case ENUM_STRING_STATBASE -> stream.writeByte(player.getSkills().getLevelForXp(defs.configs[i][1])); case OBJTRADEDIALOG, OBJDIALOG, LISTDIALOG -> { if (data != null && data.length >= 2) return data; } case ACTIVECOMBATLEVEL -> stream.writeByte(player.getSkills().getCombatLevelWithSummoning()); case ACC_GETMEANCOMBATLEVEL -> { FCData fc = FCManager.getFCData(player.getSocial().getCurrentFriendsChat()); if (fc == null) stream.writeByte(0); else { int total = 0; int count = 0; for (String username : fc.getUsernames()) { Player p = World.getPlayerByUsername(username); if (p != null) { count++; total += p.getSkills().getCombatLevelWithSummoning(); } } stream.writeByte(count > 0 ? total / count : 0); } } case ACC_GETCOUNT_WORLD -> { FCData fc = FCManager.getFCData(player.getSocial().getCurrentFriendsChat()); if (fc == null) stream.writeByte(0); else { int count = 0; for (String username : fc.getUsernames()) { Player p = World.getPlayerByUsername(username); if (p != null) count++; } stream.writeByte(count); } } case TOSTRING_SHARED -> stream.writeInt(SoulWarsKt.getQuickchatVar(defs.configs[i][0])); case COUNTDIALOG, ENUM_STRING_CLAN -> { /*TODO*/ } default -> {} } return stream.toByteArray(); } public static Tile targetToTile(Object object) { if (object instanceof Tile t) return t; else if (object instanceof Entity e) return e.getTile(); else if (object instanceof WorldObject w) return w.getTile(); throw new IllegalArgumentException(""Invalid target object passed.""); } public static Direction getDirectionTo(Entity entity, Object target) { Tile targTile = WorldUtil.targetToTile(target); Vec2 from = entity.getMiddleTileAsVector(); Vec2 to = target instanceof Entity e ? e.getMiddleTileAsVector() : new Vec2(targTile); Vec2 sub = to.sub(from); sub.norm(); Tile delta = sub.toTile(); return Direction.forDelta(delta.getX(), delta.getY()); } public static int getAngleTo(Direction dir) { return ((int) (Math.atan2(-dir.dx, -dir.dy) * 2607.5945876176133)) & 0x3fff; } public static Direction getFaceDirection(Tile faceTile, Player player) { if (player.getX() < faceTile.getX()) return Direction.EAST; if (player.getX() > faceTile.getX()) return Direction.WEST; if (player.getY() < faceTile.getY()) return Direction.NORTH; else if (player.getY() > faceTile.getY()) return Direction.SOUTH; else return Direction.NORTH; } public static boolean collides(Entity entity, Entity target) { return entity.getPlane() == target.getPlane() && collides(entity.getX(), entity.getY(), entity.getSize(), target.getX(), target.getY(), target.getSize()); } public static boolean collides(Tile entity, Tile target) { return entity.getPlane() == target.getPlane() && collides(entity.getX(), entity.getY(), 1, target.getX(), target.getY(), 1); } public static boolean collides(Tile entity, Tile target, int s1, int s2) { return entity.getPlane() == target.getPlane() && collides(entity.getX(), entity.getY(), s1, target.getX(), target.getY(), s2); } public static boolean isInRange(Tile entity, Tile target, int rangeRatio) { return entity.getPlane() == target.getPlane() && isInRange(entity.getX(), entity.getY(), 1, target.getX(), target.getY(), 1, rangeRatio); } public static boolean isInRange(Entity entity, Entity target, int rangeRatio) { return entity.getPlane() == target.getPlane() && isInRange(entity.getX(), entity.getY(), entity.getSize(), target.getX(), target.getY(), target.getSize(), rangeRatio); } public static boolean isInRange(Tile entity, Tile target, int rangeRatio, int s1, int s2) { return entity.getPlane() == target.getPlane() && isInRange(entity.getX(), entity.getY(), s1, target.getX(), target.getY(), s2, rangeRatio); } public static boolean collides(int x1, int y1, int size1, int x2, int y2, int size2) { int distanceX = x1 - x2; int distanceY = y1 - y2; return distanceX < size2 && distanceX > -size1 && distanceY < size2 && distanceY > -size1; } public static boolean isInRange(int x1, int y1, int size1, int x2, int y2, int size2, int maxDistance) { int distanceX = x1 - x2; int distanceY = y1 - y2; if (distanceX > size2 + maxDistance || distanceX < -size1 - maxDistance || distanceY > size2 + maxDistance || distanceY < -size1 - maxDistance) return false; return true; } public static double getMemUsedPerc() { MemoryMXBean memoryMXBean = ManagementFactory.getMemoryMXBean(); MemoryUsage heapMemoryUsage = memoryMXBean.getHeapMemoryUsage(); MemoryUsage nonHeapMemoryUsage = memoryMXBean.getNonHeapMemoryUsage(); long jvmHeapUsed = heapMemoryUsage.getUsed() / 1048576L; // in MB long jvmNonHeapUsed = nonHeapMemoryUsage.getUsed() / 1048576L; // in MB long jvmTotalUsed = jvmHeapUsed + jvmNonHeapUsed; long jvmMaxMemory = (heapMemoryUsage.getMax() + nonHeapMemoryUsage.getMax()) / 1048576L; // in MB double jvmMemUsedPerc = ((double) jvmTotalUsed / jvmMaxMemory) * 100.0; return jvmMemUsedPerc; } public static ItemsContainer gsonTreeMapToItemContainer(Object metadata) { if (metadata == null) return null; try { ItemsContainer container = null; if (metadata instanceof List list) { container = new ItemsContainer<>(list.size(), false); for (Object itemObj : list) { if (itemObj instanceof Item item) container.add(item); else if (itemObj instanceof LinkedTreeMap item) { if (item.get(""metadata"") != null) { Object rawMetadata = item.get(""metadata""); if (rawMetadata instanceof Map rawMap) { Map metadataMap = new HashMap<>(); boolean valid = true; for (Map.Entry entry : rawMap.entrySet()) { if (entry.getKey() instanceof String) { metadataMap.put((String) entry.getKey(), entry.getValue()); } else { valid = false; break; } } if (valid) container.add(new Item(((Double) item.get(""id"")).intValue(), ((Double) item.get(""amount"")).intValue(), metadataMap)); } } else container.add(new Item(((Double) item.get(""id"")).intValue(), ((Double) item.get(""amount"")).intValue())); } } } return container != null && container.isEmpty() ? null : container; } catch(Throwable e) { Logger.error(WorldUtil.class, ""gsonTreeMapToItemContainer"", e); return null; } } }" "package com.rs.utils.bench; public class JavaBench { private static final ExecutorService service = Executors.newFixedThreadPool(1); public static void main(String[] args) throws IOException, InterruptedException { Cache.init(""../cache/""); for (int i = 0;i <= 50;i++) { test(); } System.out.println(""JVM heated up. Starting...""); List results = new ArrayList<>(); for (int i = 0;i <= 50;i++) { var start = System.nanoTime(); test(); results.add((System.nanoTime() - start) / 1000000.0); } service.shutdown(); //System.out.println(""Calculated "" + RouteFinder.COUNT + "" routes across Burthorpe.""); System.out.println(""Java executor service: ""+results.stream().mapToDouble(a -> a).average().getAsDouble()+"" ms""); } private static void test() { CompletableFuture[] futures = new CompletableFuture[1000]; for (int i = 0;i < futures.length;i++) { //futures[i] = CompletableFuture.runAsync(() -> RouteFinder.find(2888, 3452, 0, 1, new FixedTileStrategy(2917, 3524), true), service); } CompletableFuture.allOf(futures).join(); for (CompletableFuture f : futures) if (f.isCompletedExceptionally()) f.exceptionNow().printStackTrace(); } }" "package com.rs.utils.bench; public class JavaLoomBench { private static final ExecutorService service = Executors.newVirtualThreadPerTaskExecutor(); public static void main(String[] args) throws IOException, InterruptedException { Cache.init(""../cache/""); for (int i = 0;i <= 50;i++) { test(); } System.out.println(""JVM heated up. Starting...""); List results = new ArrayList<>(); for (int i = 0;i <= 50;i++) { var start = System.nanoTime(); test(); results.add((System.nanoTime() - start) / 1000000.0); } service.shutdown(); //System.out.println(""Calculated "" + RouteFinder.COUNT + "" routes across Burthorpe.""); System.out.println(""Java loom virtual thread executor: ""+results.stream().mapToDouble(a -> a).average().getAsDouble()+"" ms""); } private static void test() { CompletableFuture[] futures = new CompletableFuture[1000]; for (int i = 0;i < futures.length;i++) { //futures[i] = CompletableFuture.runAsync(() -> RouteFinder.find(2888, 3452, 0, 1, new FixedTileStrategy(2917, 3524), true), service); } CompletableFuture.allOf(futures).join(); for (CompletableFuture f : futures) if (f.isCompletedExceptionally()) f.exceptionNow().printStackTrace(); } }" "package com.rs.utils.bench fun main() { for (i in 0..50) runCoroutineTest() println(""JVM heated up. Starting..."") var results: MutableList = mutableListOf() for (i in 0..50) { var start = System.nanoTime() runCoroutineTest() results.add((System.nanoTime() - start) / 1000000.0) } //println(""Calculated "" + RouteFinder.COUNT + "" routes across Burthorpe."") println(""Kotlin coroutines: ""+results.average()+"" ms"") } fun runCoroutineTest() { Cache.init(""../cache/"") runBlocking { (0 until 1000).map { _ -> launch { //RouteFinder.find(2888, 3452, 0, 1, FixedTileStrategy(2917, 3524), true) } }.forEach { it.join() } } }" "package com.rs.utils.bench private lateinit var executorService: ExecutorService private lateinit var executorCoroutineDispatcher: ExecutorCoroutineDispatcher fun main() { executorService = Executors.newVirtualThreadPerTaskExecutor() executorCoroutineDispatcher = executorService.asCoroutineDispatcher() for (i in 0..50) runLoomCoroutineTest() println(""JVM heated up. Starting..."") var results: MutableList = mutableListOf() for (i in 0..50) { var start = System.nanoTime() runLoomCoroutineTest() results.add((System.nanoTime() - start) / 1000000.0) } //println(""Calculated "" + RouteFinder.COUNT + "" routes across Burthorpe."") println(""Kotlin loom coroutines: ""+results.average()+"" ms"") } fun runLoomCoroutineTest() { Cache.init(""../cache/"") runBlocking(executorCoroutineDispatcher) { (0 until 1000).map { _ -> launch { //RouteFinder.find(2888, 3452, 0, 1, FixedTileStrategy(2917, 3524), true) } }.forEach { it.join() } } }" "package com.rs.utils.configuration; /** * An exception thrown if the value of the configuration is not the appropriate * type * * @author Nikki * */ @SuppressWarnings(""serial"") public class ConfigurationException extends IllegalArgumentException { public ConfigurationException(String string) { super(string); } }" "package com.rs.utils.configuration; /** * Represents a configuration sub-node * * @author Nikki * */ public class ConfigurationNode { /** * A map of the children of this node */ private final Map children = new HashMap<>(); /** * Set a value * * @param key * The key * @param value * The value */ public void set(String key, Object value) { children.put(key, value); } /** * Check if the map contains a key * * @param key * The key to check * @return true, if found */ public boolean has(String key) { return children.containsKey(key); } /** * Get a sub-node for the specified name * * @param name * The name * @return The node */ public ConfigurationNode nodeFor(String name) { if (children.containsKey(name)) { Object value = children.get(name); if (value.getClass() != this.getClass()) throw new ConfigurationException(""Invalid node "" + name + ""!""); return (ConfigurationNode) value; } return null; } /** * List the sub values * * @return A list of all sub values */ public String listChildren() { StringBuilder builder = new StringBuilder(); builder.append(""[""); for (Entry entry : children.entrySet()) { builder.append(entry.getKey()).append("" => ""); if (entry.getValue() instanceof ConfigurationNode cn) builder.append(cn.listChildren()); else builder.append(entry.getValue()); builder.append("", ""); } if (builder.length() > 2) { builder.deleteCharAt(builder.length() - 1); builder.deleteCharAt(builder.length() - 1); } builder.append(""]""); return builder.toString(); } /** * Get an Object value from the map * * @param key * The key * @return The value */ public Object get(String key) { return children.get(key); } /** * Get a string value from this node * * @param string * The key of the value * @return The string, or null */ public String getString(String string) { Object value = get(string); if (value instanceof String) return (String) value; return ""null""; } /** * Get an integer value from this node * * @param key * The key of the value * @return The value, parsed as an integer */ public int getInteger(String key) { return Integer.parseInt(getString(key)); } /** * Get a boolean value from this node * * @param key * The key of the value * @return The value, parsed as a boolean */ public boolean getBoolean(String key) { return Boolean.parseBoolean(getString(key)); } /** * Get a list of the children * * @return The map */ public Map getChildren() { return children; } }" "package com.rs.utils.configuration; /** * A class to parse a configuration file, based on the perl configuration system * Azusa::Configuration s * * @author Nikki * @author solar * */ public class ConfigurationParser { /** * The pattern to match scalar lines */ private final Pattern scalarPattern = Pattern.compile(""\\s*(.*?)\\s*\""((?:\\\""|[^\""])+?)\""\\s*(?:\\#.*)?$""); /** * The pattern to match arrays.. */ private final Pattern arrayPattern = Pattern.compile(""\\s*(.*?)\\s*\\s*\\{\\s*(?:\\#.*)?$""); /** * The pattern to match nested arrays */ private final Pattern nestedArrayPattern = Pattern.compile(""\\s*(.*?)\\s*\""((?:\\\""|[^\""])+?)\""\\s*\\(\\s*(?:\\#.*)?$""); /** * The pattern to match nested hashes */ private final Pattern nestedHashPattern = Pattern.compile(""\\s*(.*?)\\s*\""((?:\\\\\""|[^\""])+?)\""\\s*\\{\\s*(?:\\#.*)?$""); /** * The patter to find the end of a nested array */ private final Pattern nestedEndPattern = Pattern.compile(""^\\s*(}|\\))\\s*""); /** * The reader object which the configuration is parsed from */ private final BufferedReader reader; public ConfigurationParser(InputStream input) { reader = new BufferedReader(new InputStreamReader(input)); } /** * Parse the configuration from the specified file * * @return The configuration * @throws IOException */ public ConfigurationNode parse() throws IOException { ConfigurationNode node = new ConfigurationNode(); try { parse(node); } finally { reader.close(); } return node; } /** * Parse a block of data, reading line per line from the reader. */ public void parse(ConfigurationNode node) throws IOException { String line = reader.readLine(); if (line == null) return; line = line.trim(); if (!line.startsWith(""#"") && line.length() != 0) { // Scalar match Matcher scalar = scalarPattern.matcher(line); Matcher array = arrayPattern.matcher(line); Matcher nestedArrayBlock = nestedArrayPattern.matcher(line); Matcher nestedHashBlock = nestedHashPattern.matcher(line); if (scalar.find()) node.set(scalar.group(1), scalar.group(2)); else if (nestedArrayBlock.find()) { String name = nestedArrayBlock.group(1); String key = nestedArrayBlock.group(2); key = key.replaceAll(""\\\"""", ""\""""); if (!node.has(name)) node.set(name, new ConfigurationNode()); parse(node.nodeFor(name)); } else if (nestedHashBlock.find()) { String name = nestedHashBlock.group(1); String key = nestedHashBlock.group(2); ConfigurationNode sub = node.has(name) ? node.nodeFor(name) : new ConfigurationNode(); if (!node.has(name)) node.set(name, sub); if (!sub.has(key)) sub.set(key, new ConfigurationNode()); parse(sub.nodeFor(key)); } else if (array.find()) { ConfigurationNode newNode = new ConfigurationNode(); node.set(array.group(1), newNode); parse(newNode); } Matcher nestedEnd = nestedEndPattern.matcher(line); if (nestedEnd.find()) return; } parse(node); } }" "package com.rs.utils.drop; public class ClueDrop { private final Set combatLevels = new HashSet<>(); private final int weight; public ClueDrop(int weight, int... combatLevels) { this.weight = weight; for (int combatLevel : combatLevels) this.combatLevels.add(combatLevel); } public Set getCombatLevels() { return combatLevels; } public int getWeight() { return weight; } public boolean validCombatLevel(int combatLevel) { if (combatLevels.isEmpty()) return true; return combatLevels.contains(combatLevel); } }" "package com.rs.utils.drop; public class Drop { private int id = -1; private int min; private int max; private String rollTable; public Drop(String rollTable) { this.rollTable = rollTable; } public Drop(int itemId, int min, int max) { id = itemId; this.min = min; this.max = max; } public Drop(int itemId, int amount) { id = itemId; min = amount; max = amount; } public Drop(int itemId) { id = itemId; min = 1; max = 1; } public Item toItem() { return new Item(id, getAmount()); } public int getId() { return id; } public int getAmount() { int amt = Utils.random(min, max+1); if (max < 2) amt = 1; return amt; } public int getMin() { return min; } public int getMax() { return max; } public DropSet getRollTable() { return rollTable == null ? null : DropSets.getDropSet(rollTable); } @Override public String toString() { return ""["" + id + "", "" + min + "", "" + max + ""]""; } }" "package com.rs.utils.drop; public class DropEntry { private final DropTable table; private final double min; private final double max; private boolean always; public DropEntry(DropTable table) { this(table, 0.0, 0.0); always = true; } public DropEntry(DropTable table, double min, double max) { this.table = table; this.min = min; this.max = max; } public DropTable getTable() { return table; } public double getMin() { return min; } public double getMax() { return max; } public boolean isAlways() { return always; } @Override public String toString() { return ""["" + (table == null ? ""Nothing"" : table.toString()) + "" ("" + min + ""-"" + max + "")]""; } }" "package com.rs.utils.drop; public class DropList { private static final double MAX_ROLL = Math.nextDown(1.0); private final List drops = new ArrayList<>(); private double nothingRate = 0.0; private boolean overflowed; private double overflow; public DropList(DropTable... tables) { this(new ArrayList<>(Arrays.asList(tables))); } public DropList(List tables) { double curr = 0.0; tables.sort((o1, o2) -> { if ((o1 == null) || (o2 == null)) return Integer.MAX_VALUE; return Double.compare(o1.chance / o1.outOf, o2.chance / o2.outOf); }); for (DropTable table : tables) { if (table == null) continue; double rate = table.getRate(); if (rate == 0.0) { drops.add(new DropEntry(table)); continue; } drops.add(new DropEntry(table, curr, curr + rate)); curr += rate; if (curr > 1.0000000000000009) { overflowed = true; overflow = curr - 1.0; System.err.println(""Drop rate overflow for table: "" + curr + "", "" + table.toString()); } } double emptySlots = 1.0-curr; nothingRate = emptySlots; drops.add(new DropEntry(null, curr, curr+emptySlots)); } public boolean isOverflowed() { return overflowed; } public double getOverflow() { return overflow; } public String getNothingFracString() { return Rational.toRational(nothingRate).toString(); } public double getNothingRate() { return Utils.round(nothingRate, 10); } public List genDrop() { return genDrop(1.0); } public List genDrop(double modifier) { return genDrop(null, modifier); } public List getDrops() { return drops; } public List genDrop(Player killer, double modifier) { List finals = new ArrayList<>(); modifier *= Settings.getConfig().getDropModifier(); double roll = Utils.clampD(Utils.randomD() * modifier, -100, MAX_ROLL); for (DropEntry drop : drops) { if ((!drop.isAlways() && roll < drop.getMin()) || (!drop.isAlways() && roll >= drop.getMax())) continue; DropTable table = drop.getTable(); if (table == null) continue; if (table.getRollTable() != null) { if (killer != null) switch(table.getRollTable().getNames()[0]) { case ""rdt_gem"": killer.incrementCount(""Gem drop table drops""); if (killer.getEquipment().getRingId() != -1 && ItemDefinitions.getDefs(killer.getEquipment().getRingId()).getName().toLowerCase().contains(""ring of wealth"")) killer.sendMessage(""Your ring of wealth shines brightly!""); break; case ""rdt_standard"": killer.incrementCount(""Rare drop table drops""); if (killer.getEquipment().getRingId() != -1 && ItemDefinitions.getDefs(killer.getEquipment().getRingId()).getName().toLowerCase().contains(""ring of wealth"")) killer.sendMessage(""Your ring of wealth shines brightly!""); break; case ""rdt_mega_rare"": killer.incrementCount(""Mega rare drop table drops""); if (killer.getEquipment().getRingId() != -1 && ItemDefinitions.getDefs(killer.getEquipment().getRingId()).getName().toLowerCase().contains(""ring of wealth"")) killer.sendMessage(""Your ring of wealth shines brightly!""); break; } finals.addAll(table.getRollTable().getDropList().genDrop(modifier)); continue; } if (table.isDropOne()) { Drop d = table.getDrops()[Utils.random(table.getDrops().length)]; if (d.getRollTable() == null) finals.add(d.toItem()); else for(int i = 0;i < d.getAmount();i++) finals.addAll(d.getRollTable().getDropList().genDrop(modifier)); } else for (Drop d : table.getDrops()) if (d.getRollTable() == null) finals.add(d.toItem()); else for(int i = 0;i < d.getAmount();i++) finals.addAll(d.getRollTable().getDropList().genDrop(modifier)); } return finals; } @Override public String toString() { StringBuilder str = new StringBuilder(); for (DropEntry d : drops) str.append(d).append(""\n""); return str.toString(); } }" "package com.rs.utils.drop; public class DropSet { protected int[] ids; protected String[] names; protected DropTable[] tables; protected transient DropList dropList; private transient boolean overflowed; public DropSet(int[] ids, String[] names, DropTable[] tables) { this.ids = ids; this.names = names; this.tables = tables; } public DropSet(DropTable... tables) { this.tables = tables; } public DropSet(List tables) { this.tables = new DropTable[tables.size()]; this.tables = tables.toArray(this.tables); } public int[] getIds() { return ids; } public String[] getNames() { return names; } public DropTable[] getTables() { return tables; } public void setNames(String[] names) { this.names = names; } public DropList createDropList() { dropList = new DropList(tables); overflowed = dropList.isOverflowed(); return dropList; } public DropList getDropList() { if (dropList == null) return createDropList(); return dropList; } public boolean isOverflowed() { return overflowed; } @Override public String toString() { StringBuilder s = new StringBuilder(); if (ids != null && ids.length > 0) s.append(Arrays.toString(ids)).append(""\n""); if (names != null && names.length > 0) s.append(Arrays.toString(names)).append(""\n""); for (DropTable table : tables) s.append(table.toString()).append(""\n""); s.append(""[ ("").append(getDropList().getNothingFracString()).append("") - (-1(Nothing)\n""); return s.toString(); } public boolean isEmpty() { return tables == null || tables.length == 0; } }" "package com.rs.utils.drop; public class DropTable { protected double chance; protected double outOf; protected boolean dropOne; protected Drop[] drops; protected String rollTable; public DropTable(double chance, double outOf, boolean dropOne, List drops) { this.chance = chance; this.outOf = outOf; Drop[] dArr = new Drop[drops.size()]; drops.toArray(dArr); this.drops = dArr; this.dropOne = dropOne; } public DropTable(double chance, double outOf, List drops) { this.chance = chance; this.outOf = outOf; Drop[] dArr = new Drop[drops.size()]; drops.toArray(dArr); this.drops = dArr; dropOne = true; } public DropTable(double chance, double outOf, boolean dropOne, Drop... drops) { this.chance = chance; this.outOf = outOf; this.drops = drops; this.dropOne = dropOne; } public DropTable(double chance, double outOf, Drop... drops) { this.chance = chance; this.outOf = outOf; this.drops = drops; dropOne = true; } public DropTable(double chance, double outOf, String rollTable) { this.chance = chance; this.outOf = outOf; this.rollTable = rollTable; } public DropTable(double chance, double outOf, int itemId, int min, int max) { this.chance = chance; this.outOf = outOf; drops = new Drop[] { new Drop(itemId, min, max) }; } public DropTable(double chance, double outOf, int itemId, int amount) { this(chance, outOf, itemId, amount, amount); } public DropTable(Drop... drops) { this(0, 0, true, drops); } public DropTable(int itemId, int amount) { this(0, 0, itemId, amount, amount); } public DropTable(int itemId, int min, int max) { this(0, 0, itemId, min, max); } public DropTable(WeightedTable table) { chance = table.chance; drops = table.drops; dropOne = table.dropOne; outOf = table.outOf; rollTable = table.rollTable; } public static void displayDropsFor(Player player, String tableName, int amount) { player.sendMessage(""Calculating drops...""); AsyncTaskExecutor.execute(() -> { long start = System.currentTimeMillis(); ItemsContainer dropCollection = new ItemsContainer<>(Bank.MAX_BANK_SIZE, true); double modifier = 1.0; if (player.getEquipment().wearingRingOfWealth()) modifier -= 0.01; for (int i = 0; i < amount; i++) { List drops = DropSets.getDropSet(tableName).getDropList().genDrop(modifier); for (Item item : drops) dropCollection.add(item); } dropCollection.sortByItemId(); player.getTempAttribs().setB(""viewingOtherBank"", true); player.getVars().setVarBit(8348, 0); player.getVars().syncVarsToClient(); player.getInterfaceManager().sendInterface(762); player.getPackets().sendRunScript(2319); player.getPackets().setIFText(762, 47, amount + "" "" + tableName + "" rolls""); player.getPackets().sendItems(95, dropCollection); player.getPackets().setIFEvents(new IFEvents(762, 95, 0, 516).enableRightClickOptions(0,1,2,3,4,5,6,9).setDepth(2).enableDrag()); player.getVars().setVarBit(4893, 1); player.getVars().syncVarsToClient(); player.sendMessage(""Calculated drops in "" + Utils.formatLong(System.currentTimeMillis() - start) + ""ms""); }); } public double getNumerator() { return chance; } public double getDenominator() { return outOf; } public double getRate() { return outOf == 0.0 ? 0.0 : chance / outOf; } public void setChance(int num, int den) { chance = num; outOf = den; } public void setChance(double num, double den) { chance = num; outOf = den; } public Drop[] getDrops() { return drops; } public DropSet getRollTable() { return rollTable == null ? null : DropSets.getDropSet(rollTable); } public String getRollTableName() { return rollTable; } public Item[] toItemArr() { if (dropOne) return new Item[] { drops[Utils.random(drops.length)].toItem() }; Item[] items = new Item[drops.length]; for (int i = 0;i < items.length;i++) items[i] = drops[i].toItem(); return items; } public static Item[] calculateDrops(DropSet dropSet) { return calculateDrops(null, dropSet); } public static Item[] calculateDrops(Player killer, DropSet dropSet) { if (dropSet == null) return new Item[] {}; double modifier = 1.0; if (killer != null) if (killer.getEquipment().getRingId() != -1 && ItemDefinitions.getDefs(killer.getEquipment().getRingId()).getName().toLowerCase().contains(""ring of wealth"")) modifier -= 0.01; List drops = dropSet.getDropList().genDrop(killer, modifier); Item[] items = new Item[drops.size()]; for (int i = 0;i < items.length;i++) items[i] = drops.get(i); return items; } public boolean isDropOne() { return dropOne; } @Override public String toString() { StringBuilder s = new StringBuilder(""[ ("" + chance + ""/"" + outOf + "") - ""); if (rollTable != null) return s + rollTable; if (drops == null) return s + ""Nothing""; for (Drop d : drops) s.append(""("").append(d.getId()).append(""("").append(ItemDefinitions.getDefs(d.getId()).name).append(""),"").append(d.getMin()).append("","").append(d.getMax()).append("") ]""); return s.toString(); } }" "package com.rs.utils.drop; public class Fix { private static final List INC = new ArrayList<>(); private static final Map MAP = new HashMap<>(); static { for (double denom = 1.0;denom <= 2000.0;denom += 1.0) for (double num = 1.0;num <= denom;num += 1.0) { double val = num / denom; if (MAP.containsKey(val)) continue; INC.add(val); MAP.put(val, new double[] { num, denom }); } INC.sort((o1, o2) -> Double.compare(o2, o1)); } private final static String PATH = ""data/npcs/drops/""; public static void main(String[] args) throws IOException { //Cache.init(); //File f = new File(PATH + ""general_graardor.json""); File[] dropFiles = new File(PATH).listFiles(); for (File f : dropFiles) { DropSet set = (DropSet) JsonFileManager.loadJsonFile(f, DropSet.class); if (set != null) { set.getDropList(); if (set.isOverflowed()) { //System.err.println(f.getName() + "" is overflowed by "" + set.getDropList().getOverflow() + "".. Fixing..""); double total = 0; for (DropTable table : set.getTables()) { if (table.getRate() == 0.0) continue; total += table.getRate(); } for (DropTable table : set.getTables()) try { if (table.getRate() == 0.0) continue; double rate = table.getRate() / total; double last = -1.0; for (double d : INC) { if (rate > d) { rate = last < 0.0 ? d : last; break; } last = rate; } //Rational frac = Utils.toRational(rate); //int[] meme = Utils.asFractionArr(frac.getNum(), frac.denom()); // double num = 1.0; // double denom = Utils.round(((double) meme[1]) / ((double) meme[0]), 4); double[] fracD = MAP.get(rate); table.setChance(fracD[0], fracD[1]); } catch (Exception e) { double rate = table.getRate() / total; Rational frac = Utils.toRational(rate); int[] meme = Utils.asFractionArr(frac.getNum(), frac.denom()); table.setChance(meme[0], meme[1]); //e.printStackTrace(); //System.err.println(""Error with table: "" + f.getName() + "", "" + table.getDrops()[0].toItem().getName()); } //Logger.debug(""Fixed. Checking validity.""); set.createDropList(); //Logger.debug(set); if (!set.isOverflowed()) JsonFileManager.saveJsonFile(set, new File(""./fixed/""+f.getName())); } } } } }" "package com.rs.utils.drop; public class Test { public static void main(String[] args) throws IOException { //Cache.init(); DropSets.init(); ItemsContainer drops = new ItemsContainer<>(200, true); long start = System.currentTimeMillis(); int sample = 100000; for (int i = 0;i < sample;i++) drops.addAll(BarrowsController.getSimulatedDrop(7, 1012)); long time = System.currentTimeMillis() - start; drops.sortByItemId(); for (Item item : drops.toArray()) { if (item == null) continue; System.out.println(item.getDefinitions().getName()+"": "" + Utils.getFormattedNumber(item.getAmount()) + "" (1/"" + Math.round((double) sample / (double) item.getAmount()) + "")""); } System.out.println(""Generated "" + sample + "" drops in "" + time + ""ms""); int barrowsItems = 0; for (Item i : drops.toArray()) if (i != null && i.getName().contains(""'"")) barrowsItems += i.getAmount(); System.out.println(""Barrows item approximately 1/""+(sample/barrowsItems)); } }" "package com.rs.utils.drop; public class WeightedSet extends DropSet { public WeightedSet(WeightedTable... wTables) { super(); int total = 0; for (WeightedTable table : wTables) total += table.getWeight(); for (WeightedTable table : wTables) table.setChance(table.getWeight(), total); DropTable[] tables = new DropTable[wTables.length]; for (int i = 0;i < tables.length;i++) { WeightedTable table = wTables[i]; tables[i] = new DropTable(table); } this.tables = tables; } }" "package com.rs.utils.drop; public class WeightedTable extends DropTable { private final transient int weight; public WeightedTable(int weight, Drop... drops) { this.weight = weight; this.drops = drops; dropOne = true; } public WeightedTable(int weight, String rollTable) { this.weight = weight; this.rollTable = rollTable; } public WeightedTable(Drop... drops) { this(1, drops); } public WeightedTable(String rollTable) { this(1, rollTable); } public int getWeight() { return weight; } }" "package com.rs.utils.json; @PluginEventHandler public class ControllerAdapter implements JsonSerializer, JsonDeserializer { private static final Map> CONTROLLER_CLASSES = new HashMap<>(); @ServerStartupEvent(Priority.FILE_IO) public static void init() { try { List> classes = Utils.getSubClasses(""com.rs"", Controller.class); for (Class clazz : classes) { if (CONTROLLER_CLASSES.put(clazz.getSimpleName(), clazz) != null) Logger.error(ControllerAdapter.class, ""init"", ""Duplicate controller class: "" + clazz.getName()); } } catch (ClassNotFoundException | IOException e) { e.printStackTrace(); } Logger.info(ControllerAdapter.class, ""init"", ""Loaded "" + CONTROLLER_CLASSES.size() + "" controllers...""); } @Override public JsonElement serialize(Controller controller, Type type, JsonSerializationContext context) { JsonObject result = new JsonObject(); result.add(""type"", new JsonPrimitive(controller.getClass().getSimpleName())); result.add(""properties"", context.serialize(controller, controller.getClass())); return result; } @Override public Controller deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { JsonObject jsonObject = json.getAsJsonObject(); String type = jsonObject.get(""type"").getAsString(); JsonElement element = jsonObject.get(""properties""); Class clazz = CONTROLLER_CLASSES.get(type); if (clazz == null) throw new RuntimeException(""Controller not found: "" + type); return context.deserialize(element, clazz); } }" "package com.rs.utils.music; /** * There should be no duplicate region keys. But there can be parent genres. */ public class Genre { private String genre; private String parent; private String comment; private boolean isActive; private int[] chunkIds; private int[] regionIds; private int[] songs; public String getGenreName() { return genre; } public String getParent() { return parent; } public String getComment() { return comment; } public boolean isActive() { return isActive; } public int[] getChunkIds() { if(chunkIds == null) return new int[0]; return chunkIds; } public int[] getRegionIds() { return regionIds; } public int[] getSongs() { Genre parent = Music.getParent(this.parent); if(parent == null) return songs; List allSongs = Arrays.stream(parent.getSongs()).boxed().collect(Collectors.toList()); allSongs.addAll(Arrays.stream(songs).boxed().collect(Collectors.toList())); return allSongs.stream().distinct().mapToInt(Integer::intValue).toArray(); } public boolean matches(Genre g) { if(g == null || genre == null) return false; return genre.equalsIgnoreCase(g.getGenreName()); } }" "package com.rs.utils.music; @PluginEventHandler public class Music { /** Summary of Music System * -When initially entering a region the songs associated with that region play first * from songs.json. * -Afterward genre ambient songs play. Region specific songs are added to that genre. * -When entering other regions the only time it switches songs is when the region * has a different genre in the genre map or the region has no genre. This means * less song changes as the player moves around. * -allowAmbient allows players to play the music as ambient music, though it is still * locked. This works to increase variety but never adds to unlocked music. This is * mostly used just to increase ambient song variety and does not affect region or * playlist music. * Chunks are secondary and do not change the current music but whatever plays next. */ private static final Map MUSICS = new HashMap<>();//Full music listing private static final Map MUSICS_REGION = new HashMap<>();//hints & unlocks private static final Map GENRE_CHUNKS = new HashMap<>();//Genre per chunk private static final Map GENRE_REGION = new HashMap<>();//Genre per region private static final List genres = new ArrayList<>(); private static Genre[] parentGenres; private static final ArrayList allowAmbientMusic = new ArrayList<>(); @ServerStartupEvent(Priority.FILE_IO) public static void init() { try { Song[] songs = JsonFileManager.loadJsonFile(new File(""./data/music/songs.json""), Song[].class); for (Song s : songs) { MUSICS.put(s.getId(), s); for (int regionId : s.getRegionIds()) if (MUSICS_REGION.get(regionId) == null) MUSICS_REGION.put(regionId, new int[] { s.getId() }); else { int[] musicIds = MUSICS_REGION.get(regionId); int[] newMusicIds = new int[musicIds.length+1]; System.arraycopy(musicIds, 0, newMusicIds, 0, musicIds.length); newMusicIds[musicIds.length] = s.getId(); MUSICS_REGION.put(regionId, newMusicIds); } } parentGenres = JsonFileManager.loadJsonFile(new File(""./data/music/parent-genres.json""), Genre[].class); File[] genreFiles = new File(""./data/music/regions/"").listFiles(); for (File f : genreFiles) genres.addAll(Arrays.asList(JsonFileManager.loadJsonFile(f, Genre[].class))); addGenresToChunkMap(); addGenresToRegionMap(); //Auto-unlock songs list. for(Song s : songs) if(s.isAllowAmbient()) allowAmbientMusic.add(s.getId()); } catch (JsonIOException | IOException e) { e.printStackTrace(); } } private static void addGenresToRegionMap() { for(Genre g : genres) if(g.isActive()) for (int regionId : g.getRegionIds()) { if (GENRE_REGION.containsKey(regionId)) throw new java.lang.Error(""Error, duplicate key at: "" + regionId); GENRE_REGION.put(regionId, g);//none of the values can be empty } } private static void addGenresToChunkMap() { for(Genre g : genres) if(g.isActive()) for (int chunkId : g.getChunkIds()) { if (GENRE_CHUNKS.containsKey(chunkId)) throw new java.lang.Error(""Error, duplicate key at: "" + chunkId); GENRE_CHUNKS.put(chunkId, g);//none of the values can be empty } } /** * This is for the music system to check if a song is unlocked. * @param regionId * @return */ public static int[] getRegionMusics(int regionId) { return MUSICS_REGION.get(regionId); } public static Song getSong(int musicId) { return MUSICS.get(musicId); } /** * Start with the region genre but if there are genre chunks then default to that. * Lastly make sure the genre is active. * @param player * @return */ public static Genre getGenre(Player player) { if(!GENRE_REGION.containsKey(player.getRegionId())) return null; Genre g = GENRE_REGION.get(player.getRegionId()); if(GENRE_CHUNKS.containsKey(player.getChunkId())) g = GENRE_CHUNKS.get(player.getChunkId()); if(g.isActive()) return g; return null; } public static Genre getParent(String name) { for(Genre g : parentGenres) if(g.getGenreName().equalsIgnoreCase(name)) return g; return null; } public static String[] getSongGenres(int musicId) { List genreNames = new ArrayList<>(); for(Genre g : genres) for(int songId : g.getSongs()) if(songId == musicId) genreNames.add(g.getGenreName()); return genreNames.stream().toArray(String[]::new); } public static Genre getGenreByName(String name) { for(Genre g : genres) if(g.getGenreName().equalsIgnoreCase(name)) return g; return null; } public static ArrayList getAllowAmbientMusic() { return allowAmbientMusic; } }" "package com.rs.utils.music; public class Song { private String name; private String hint; private String comment; private boolean allowAmbient; private int id; private int[] regionIds; public String getName() { return name; } public String getHint() { return hint; } public String getComment() { return comment; } public boolean isAllowAmbient() { return allowAmbient; } public int getId() { return id; } public int[] getRegionIds() { return regionIds; } }" "package com.rs.utils.music; public class Voice { String category; int[] voiceIDs; public Voice(String category, int[] voiceIDs) { this.category = category; this.voiceIDs = voiceIDs; } public String getCategory() { return category; } public int[] getVoiceIDs() { return voiceIDs; } }" "package com.rs.utils.music; @PluginEventHandler public class Voices {//set public static Set voicesMarked = new HashSet<>(); @ServerStartupEvent(Priority.FILE_IO) public static void init() { if(!Settings.getConfig().isDebug()) return; try { Voice[] voices = JsonFileManager.loadJsonFile(new File(""./developer-information/voice.json""), Voice[].class); for(Voice voice : voices) for(int voiceID : voice.getVoiceIDs()) voicesMarked.add(voiceID); } catch (Exception e) { Logger.handle(Voices.class, ""init"", ""Error initializing voices"", e); } } }" "package com.rs.utils.record; public class RecordedAction implements Comparable { private final int time; private final long tick; private final long timeLogged; public RecordedAction(long timeLogged, int time) { this.timeLogged = timeLogged; this.time = time; this.tick = World.getServerTicks(); } @Override public int compareTo(RecordedAction other) { return Long.compare(timeLogged, other.timeLogged); } public int getTime() { return time; } public long getTick() { return tick; } public long getTimeLogged() { return timeLogged; } @Override public String toString() { return ""(""+time+""ms) "" + getClass().getSimpleName() + "": ""; } }" "package com.rs.utils.record; public class Recorder { private final Player player; private final Deque actions = new ArrayDeque<>(); private int sizeLimit = 100; public Recorder(Player player) { this.player = player; this.sizeLimit = 100; } public void record(RecordedAction action) { player.refreshIdleTime(); actions.offerLast(action); if (actions.size() > sizeLimit) actions.poll(); } public long getTicksSinceLastAction() { if (actions.peekLast() == null) return Long.MAX_VALUE; return World.getServerTicks() - actions.peekLast().getTick(); } public int getSizeLimit() { return sizeLimit; } public void setSizeLimit(int sizeLimit) { actions.clear(); this.sizeLimit = sizeLimit; } public static void showConcatenatedActions(Player player, String... displayNames) { List> actions = getActionsFor(displayNames); if (actions == null) { player.sendMessage(""Actions not found for one or more players.""); return; } player.getPackets().sendDevConsoleMessage(""Past actions for: "" + Utils.concat(displayNames)); SimpleEntry prev = null; long startTime = actions.getFirst().getValue().getTimeLogged(); for (SimpleEntry action : actions) { consoleLogAction(player, action, prev, startTime); prev = action; } } private static List> getActionsFor(String... displayNames) { List> actions = new ArrayList<>(); for (String name : displayNames) { Player target = World.getPlayerByDisplay(name); if (target == null || target.getRecorder() == null) return null; for (RecordedAction click : target.getRecorder().actions) actions.add(new SimpleEntry<>(name, click)); } if (actions.isEmpty()) return null; actions.sort(Comparator.comparing(SimpleEntry::getValue)); return actions; } public static void watchPlayers(Player player, String... displayNames) { Set printed = new HashSet<>(); List> initialActions = getActionsFor(displayNames); if (initialActions == null || initialActions.isEmpty()) return; long startTime = initialActions.getFirst().getValue().getTimeLogged(); player.getPackets().sendDevConsoleMessage(""Starting watch for: "" + Arrays.toString(displayNames)); WorldTasks.scheduleTimer(tick -> { if (player == null || !player.isRunning() || player.hasFinished()) return false; List> actions = getActionsFor(displayNames); player.getNSV().setO(""lastWatchActionLogged"", initialActions.getFirst()); if (actions == null || actions.isEmpty() || player.getNSV().getB(""stopWatchActionLoop"")) { player.getPackets().sendDevConsoleMessage(""Watching stopped. Player went offline.""); player.getNSV().removeB(""stopWatchActionLoop""); return false; } for (SimpleEntry action : actions) { if (printed.contains(action.getValue())) continue; consoleLogAction(player, action, player.getNSV().getO(""lastWatchActionLogged""), startTime); player.getNSV().setO(""lastWatchActionLogged"", action); printed.add(action.getValue()); } return true; }); } private static void consoleLogAction(Player player, SimpleEntry action, SimpleEntry prev, long startTime) { boolean flag = false; if (prev != null) { if (Math.abs((int) (action.getValue().getTimeLogged() - prev.getValue().getTimeLogged())) < 300 && !prev.getKey().equals(action.getKey())) flag = true; } if (action.getValue() instanceof ClickHW hw && !hw.isHardware()) flag = true; if (action.getValue() instanceof MouseMove mm && mm.containsSoftwareClicks()) flag = true; player.getPackets().sendDevConsoleMessage((flag ? """" : """") + ""["" + formatTimePrecise((action.getValue().getTimeLogged() - startTime)) + ""] "" + action.getKey() + "": "" + action.getValue().toString()); } private static String formatTimePrecise(long time) { int millis = (int) (time % 1000); int seconds = (int) (time / 1000L); int minutes = (int) (seconds / 60); seconds = seconds % 60; minutes = minutes % 60; StringBuilder string = new StringBuilder(); string.append(String.format(""%02d"", minutes)); string.append("":"").append(String.format(""%02d"", seconds)); string.append("":"").append(String.format(""%04d"", millis)); return string.toString(); } }" "package com.rs.utils.record.impl; public class Click extends RecordedAction { private final int x; private final int y; private final int button; public Click(long timeLogged, int time, int x, int y, int button) { super(timeLogged, time); this.x = x; this.y = y; this.button = button; } public int getX() { return x; } public int getY() { return y; } public int getButton() { return button; } @Override public String toString() { return super.toString() + "" [""+x+"",""+y+""] b:"" + button; } }" "package com.rs.utils.record.impl; public class ClickHW extends Click { private final boolean hardware; public ClickHW(long timeLogged, int time, int x, int y, int button, boolean hardware) { super(timeLogged, time, x, y, button); this.hardware = hardware; } public boolean isHardware() { return hardware; } @Override public String toString() { return super.toString() + "" hw: "" + hardware; } }" "package com.rs.utils.record.impl; public class Focus extends RecordedAction { private final boolean focused; public Focus(long timeLogged, boolean focused) { super(timeLogged, 0); this.focused = focused; } public boolean isFocused() { return focused; } @Override public String toString() { return super.toString() + "" "" + focused; } }" "package com.rs.utils.record.impl; public class MouseMove extends RecordedAction { private final boolean icmp; private final List steps; private int x = 0, y = 0; private boolean containsSoftwareClicks = false; public MouseMove(long timeLogged, int time, List steps, boolean icmp) { super(timeLogged, time); this.steps = steps; this.icmp = icmp; for (MouseTrailStep step : steps) { if (!containsSoftwareClicks && !step.isHardware()) containsSoftwareClicks = true; if (x == 0 && y == 0 && step.getType() == Type.SET_POSITION) { x = step.getX(); y = step.getY(); } } } @Override public String toString() { return super.toString() + "" [""+x+"",""+y+""] "" + (icmp ? (""ICMP: "" + containsSoftwareClicks) : """"); } public List getSteps() { return steps; } public boolean isIcmp() { return icmp; } public boolean containsSoftwareClicks() { return containsSoftwareClicks; } }" "package com.rs.utils.reflect; public class ReflectionAnalysis { private boolean built = false; private final ReflectionChecks checks; private final List tests = new ArrayList<>(); public ReflectionAnalysis() { this.checks = new ReflectionChecks(); } public ReflectionAnalysis addTest(ReflectionTest test) { if (built) throw new RuntimeException(""Cannot add a test once it has been finalized.""); tests.add(test); return this; } public ReflectionAnalysis build() { this.checks.setReflectionChecks(tests.stream().map(ReflectionTest::getCheck).toArray(ReflectionCheck[]::new)); built = true; return this; } public int getId() { return checks.getId(); } public ReflectionChecks getChecks() { return checks; } public boolean isBuilt() { return built; } public List getTests() { return tests; } }" "package com.rs.utils.reflect; public class ReflectionTest { private final String name; private final String description; private final ReflectionCheck check; private final Function validation; public ReflectionTest(String name, String description, ReflectionCheck check, Function validation) { this.name = name; this.description = description; this.check = check; this.validation = validation; } public String getName() { return name; } public String getDescription() { return description; } public ReflectionCheck getCheck() { return check; } public Function getValidation() { return validation; } }" "package com.rs.utils.shop; public class ShopDef { private String name; private boolean generalStore; private boolean buyOnly; private int currency; private ShopItem[] items; private int[] npcIds; public String getName() { return name; } public ShopItem[] getItems() { return items; } public int getCurrency() { return currency; } public boolean isGeneralStore() { return generalStore; } public int[] getNpcIds() { return npcIds; } public boolean isBuyOnly() { return buyOnly; } }" "package com.rs.utils.shop; public class ShopItem { private Item item; private transient int ticks; private int capStock; private int customPrice; private Integer restockTicks = -1; public ShopItem(int id, int amount) { item = new Item(id, amount); } public void init() { capStock = item.getAmount(); } public Item getItem() { return item; } public int getCustomPrice() { return customPrice; } public int getRestockTicks() { return restockTicks == null ? 50 : restockTicks; } public void setCap(int cap) { capStock = cap; } public boolean tickRestock() { if (++ticks > getRestockTicks()) { ticks = 0; if (item.getAmount() > capStock) { item.setAmount(item.getAmount()-1); return true; } if (item.getAmount() < capStock) { item.setAmount(item.getAmount()+1); return true; } } return false; } }" "package com.rs.utils.shop; @PluginEventHandler public class ShopsHandler { private static final Map SHOPS = new HashMap<>(); private static final Map SHOP_DEFS = new HashMap<>(); private static final Map NPC_SHOPS = new HashMap<>(); private static final String PATH = ""data/items/shops/""; @ServerStartupEvent(Priority.FILE_IO) public static void loadShops() { loadShopFiles(); } public static void reloadShops() { SHOPS.clear(); SHOP_DEFS.clear(); NPC_SHOPS.clear(); loadShopFiles(); } @ServerStartupEvent public static void addRestoreShopItemsTask() { WorldTasks.scheduleLooping(0, 0, () -> { try { ShopsHandler.restoreShops(); } catch (Throwable e) { Logger.handle(World.class, ""addRestoreShopItemsTask"", e); } }); } private static void loadShopFiles() { Logger.info(ShopsHandler.class, ""loadShopFiles"", ""Loading shops...""); try { File[] dropFiles = new File(PATH).listFiles(); for (File f : dropFiles) loadFile(f); } catch (Throwable e) { Logger.handle(ShopsHandler.class, ""loadShopFiles"", e); } for (String key : SHOP_DEFS.keySet()) { ShopDef shop = SHOP_DEFS.get(key); addShop(key, new Shop(shop.getName(), shop.getCurrency(), shop.getItems(), shop.isGeneralStore(), shop.isBuyOnly())); if (shop.getNpcIds() != null && shop.getNpcIds().length > 0) for (int npcId : shop.getNpcIds()) NPC_SHOPS.put(npcId, key); } Logger.info(ShopsHandler.class, ""loadShopFiles"", ""Loaded ""+SHOPS.size()+"" shops...""); } private static void loadFile(File f) { try { if (f.isDirectory()) { for (File dir : f.listFiles()) loadFile(dir); return; } ShopDef def = (ShopDef) JsonFileManager.loadJsonFile(f, ShopDef.class); if (def != null) SHOP_DEFS.put(f.getName().replace("".json"", """"), def); } catch(Throwable e) { System.err.println(""Error loading file: "" + f.getPath()); } } private static String getShopForNpc(int npcId) { return NPC_SHOPS.get(npcId); } public static NPCClickHandler handleShop = new NPCClickHandler(new String[] { ""Trade"", ""Shop"" }, e -> { String key = getShopForNpc(e.getNPCId()); if (key == null) return; openShop(e.getPlayer(), key); }); public static void restoreShops() { for (Shop shop : SHOPS.values()) shop.restoreItems(); } public static boolean openShop(Player player, String key) { Shop shop = getShop(key); if ((shop == null) || !player.getBank().checkPin()) return false; shop.addPlayer(player); return true; } public static Shop getShop(String key) { return SHOPS.get(key); } public static void addShop(String key, Shop shop) { SHOPS.put(key, shop); } }" "package com.rs.utils.spawns; public class ItemSpawn { private final String comment; private final int itemId; private final int amount; private final Tile tile; private final int respawnTicks; public ItemSpawn(int itemId, int amount, Tile tile, int respawnTicks, String comment) { this.itemId = itemId; this.amount = amount; this.tile = tile; this.respawnTicks = respawnTicks; this.comment = comment; } @SuppressWarnings(""deprecation"") public void spawn() { World.addGroundItemForever(new Item(itemId, amount), tile, getRespawnTicks()); } public Tile getTile() { return tile; } public int getItemId() { return itemId; } public int getAmount() { return amount; } public String getComment() { return comment; } public int getRespawnTicks() { return respawnTicks <= 0 ? 25 : respawnTicks; } }" "package com.rs.utils.spawns; @PluginEventHandler public final class ItemSpawns { private final static String PATH = ""data/items/spawns/""; final static Charset ENCODING = StandardCharsets.UTF_8; private static final Object lock = new Object(); private static final ArrayList ALL_SPAWNS = new ArrayList<>(); private static final ArrayList ADDED_SPAWNS = new ArrayList<>(); private static final Map> ITEM_SPAWNS = new HashMap<>(); @SuppressWarnings(""deprecation"") public static boolean addSpawn(String username, int id, int amount, int respawnTicks, Tile tile) { synchronized (lock) { File file = new File(""data/items/addedSpawns.json""); ADDED_SPAWNS.add(new ItemSpawn(id, amount, tile, respawnTicks, """"+ItemDefinitions.getDefs(id).getName()+"" added by "" + username)); World.addGroundItemForever(new Item(id, amount), tile, respawnTicks); try { JsonFileManager.saveJsonFile(ADDED_SPAWNS, file); } catch (IOException e) { return false; } return true; } } @ServerStartupEvent(Priority.FILE_IO) public static void init() throws JsonIOException, IOException { Logger.info(ItemSpawns.class, ""init"", ""Loading item spawns...""); File[] spawnFiles = new File(PATH).listFiles(); for (File f : spawnFiles) load(f); Logger.info(ItemSpawns.class, ""init"", ""Loaded "" + ALL_SPAWNS.size() + "" item spawns...""); } public static void load(File file) throws IOException { if (file.getName().startsWith(""_"")) return; if (file.isDirectory()) { for (File f : file.listFiles()) load(f); return; } ItemSpawn[] spawns = JsonFileManager.loadJsonFile(file, ItemSpawn[].class); if (spawns != null) for(ItemSpawn spawn : spawns) add(spawn); } public static void add(ItemSpawn spawn) { if (spawn != null) { ALL_SPAWNS.add(spawn); List regionSpawns = ITEM_SPAWNS.get(spawn.getTile().getChunkId()); if (regionSpawns == null) regionSpawns = new ArrayList<>(); regionSpawns.add(spawn); ITEM_SPAWNS.put(spawn.getTile().getChunkId(), regionSpawns); } } public static void loadItemSpawns(int chunkId) { List spawns = ITEM_SPAWNS.get(chunkId); if (spawns != null) for (ItemSpawn spawn : spawns) spawn.spawn(); } }" "package com.rs.utils.spawns; public class NPCSpawn { private final String comment; private final int npcId; private final Tile tile; private final Direction dir; private final CollisionStrategyType clip; private String customName; public NPCSpawn(int npcId, Tile tile, Direction dir, String comment, CollisionStrategyType clip) { this.npcId = npcId; this.tile = tile; this.dir = dir; this.comment = comment; this.clip = clip; } public NPCSpawn(int npcId, Tile tile, String comment, CollisionStrategyType clip) { this(npcId, tile, null, comment, clip); } public NPCSpawn(int npcId, Tile tile, Direction dir, String comment) { this(npcId, tile, dir, comment, CollisionStrategyType.NORMAL); } public NPCSpawn(int npcId, Tile tile, String comment) { this(npcId, tile, null, comment, CollisionStrategyType.NORMAL); } public NPC spawn() { return (NPC) World.spawnNPC(npcId, tile, dir, false, true, customName).setCollisionStrategyType(clip); } public NPC spawnAtCoords(Tile tile, Direction dir) { return (NPC) World.spawnNPC(npcId, tile, dir, false, true, customName).setCollisionStrategyType(clip); } public Tile getTile() { return tile; } public int getNPCId() { return npcId; } public String getComment() { return comment; } public Direction getDir() { return dir; } public NPCSpawn setCustomName(String customName) { this.customName = customName; return this; } public String getCustomName() { return customName; } public NPCDefinitions getDefs() { return NPCDefinitions.getDefs(npcId); } public CollisionStrategyType getCollisionStrategyType() { return clip == null ? CollisionStrategyType.NORMAL : clip; } }" "package com.rs.utils.spawns; @PluginEventHandler public final class NPCSpawns { private final static String PATH = ""data/npcs/spawns/""; final static Charset ENCODING = StandardCharsets.UTF_8; private static final Object lock = new Object(); private static final ArrayList ALL_SPAWNS = new ArrayList<>(); private static final ArrayList ADDED_SPAWNS = new ArrayList<>(); private static final Map> NPC_SPAWNS = new HashMap<>(); public static boolean addSpawn(String username, int id, Tile tile) { synchronized (lock) { File file = new File(""./data/npcs/addedSpawns.json""); ADDED_SPAWNS.add(new NPCSpawn(id, tile, """"+NPCDefinitions.getDefs(id).getName()+"" added by "" + username)); World.spawnNPC(id, tile, -1, true); try { JsonFileManager.saveJsonFile(ADDED_SPAWNS, file); } catch (IOException e) { return false; } return true; } } @ServerStartupEvent(Priority.FILE_IO) public static void init() throws JsonIOException, IOException { Logger.info(NPCSpawns.class, ""init"", ""Loading NPC spawns...""); File[] spawnFiles = new File(PATH).listFiles(); for (File f : spawnFiles) load(f); Logger.info(NPCSpawns.class, ""init"", ""Loaded "" + ALL_SPAWNS.size() + "" NPC spawns...""); } public static void load(File file) throws IOException { if (file.getName().startsWith(""_"")) return; if (file.isDirectory()) { for (File f : file.listFiles()) load(f); return; } NPCSpawn[] spawns = (NPCSpawn[]) JsonFileManager.loadJsonFile(file, NPCSpawn[].class); if (spawns != null) for(NPCSpawn spawn : spawns) add(spawn); } public static void add(NPCSpawn spawn) { if (spawn != null) { ALL_SPAWNS.add(spawn); List regionSpawns = NPC_SPAWNS.get(spawn.getTile().getChunkId()); if (regionSpawns == null) regionSpawns = new ArrayList<>(); regionSpawns.add(spawn); NPC_SPAWNS.put(spawn.getTile().getChunkId(), regionSpawns); } } public static List getAllSpawns() { return ALL_SPAWNS; } public static void loadNPCSpawns(int chunkId) { List spawns = NPC_SPAWNS.get(chunkId); if (spawns != null) for (NPCSpawn spawn : spawns) spawn.spawn(); } public static List getSpawnsForChunk(int chunkId) { return NPC_SPAWNS.get(chunkId); } }" "package com.rs.utils.spawns; public class ObjectSpawn { private final String comment; private final int objectId; private final int type; private final int rotation; private final Tile tile; public ObjectSpawn(int objectId, int type, int rotation, Tile tile) { this(objectId, type, rotation, tile, null); } public ObjectSpawn(int objectId, int type, int rotation, Tile tile, String comment) { this.objectId = objectId; this.type = type; this.rotation = rotation; this.tile = tile; this.comment = comment; } public String getComment() { return comment; } public int getObjectId() { return objectId; } public int getType() { return type; } public int getRotation() { return rotation; } public Tile getTile() { return tile; } public void spawn() { World.spawnObject(new GameObject(objectId, ObjectType.forId(type), rotation, tile.getX(), tile.getY(), tile.getPlane())); } }" "package com.rs.utils.spawns; @PluginEventHandler public final class ObjectSpawns { private final static String PATH = ""data/map/objectspawns/""; final static Charset ENCODING = StandardCharsets.UTF_8; private static final ArrayList ALL_SPAWNS = new ArrayList<>(); private static final Map> OBJECT_SPAWNS = new HashMap<>(); @ServerStartupEvent(Priority.FILE_IO) public static void init() throws JsonIOException, IOException { Logger.info(ObjectSpawns.class, ""init"", ""Loading map object spawns...""); File[] spawnFiles = new File(PATH).listFiles(); for (File f : spawnFiles) { ObjectSpawn[] spawns = (ObjectSpawn[]) JsonFileManager.loadJsonFile(f, ObjectSpawn[].class); if (spawns != null) for(ObjectSpawn spawn : spawns) if (spawn != null) add(spawn); } Logger.info(ObjectSpawns.class, ""init"", ""Loaded "" + ALL_SPAWNS.size() + "" map object spawns...""); } public static void loadObjectSpawns(int chunkId) { List spawns = OBJECT_SPAWNS.get(chunkId); if (spawns != null) for (ObjectSpawn spawn : spawns) spawn.spawn(); } public static void add(ObjectSpawn spawn) { ALL_SPAWNS.add(spawn); List regionSpawns = OBJECT_SPAWNS.get(spawn.getTile().getChunkId()); if (regionSpawns == null) regionSpawns = new ArrayList<>(); regionSpawns.add(spawn); OBJECT_SPAWNS.put(spawn.getTile().getChunkId(), regionSpawns); } }" "package com.rs.web; public class Telemetry implements Route { private static int MINUTE_COUNTER = 0; private static int HOUR_COUNTER = 0; private static int DAY_COUNTER = 0; private static final int SIZE_TICKS = 100; private static final int SIZE_MINUTES = 60; private static final int SIZE_HOURS = 24; public static Queue TELEMETRY_TICKS = new LinkedList<>(); public static Queue TELEMETRY_MINUTES = new LinkedList<>(); public static Queue TELEMETRY_HOURS = new LinkedList<>(); public static Queue TELEMETRY_DAYS = new LinkedList<>(); private int playersOnline; private long time; private double memoryLoad; private long tickMs; Telemetry() { } @Override public void build(RoutingHandler route) { route.get(""/telemetry/lastcommit"", ex -> APIUtil.sendResponse(ex, StatusCodes.OK, Settings.COMMIT_HISTORY)); route.get(""/telemetry/ticks"", ex -> APIUtil.sendResponse(ex, StatusCodes.OK, Telemetry.TELEMETRY_TICKS)); route.get(""/telemetry/minutes"", ex -> APIUtil.sendResponse(ex, StatusCodes.OK, Telemetry.TELEMETRY_MINUTES)); route.get(""/telemetry/hours"", ex -> APIUtil.sendResponse(ex, StatusCodes.OK, Telemetry.TELEMETRY_HOURS)); route.get(""/telemetry/days"", ex -> APIUtil.sendResponse(ex, StatusCodes.OK, Telemetry.TELEMETRY_DAYS)); } public Telemetry(long time, double memoryLoad, long tickMs, int playersOnline) { this.time = time; this.memoryLoad = memoryLoad; this.tickMs = tickMs; this.playersOnline = playersOnline; } public long getTime() { return time; } public double getMemoryLoad() { return memoryLoad; } public long getTickMs() { return tickMs; } public int getPlayersOnline() { return playersOnline; } public static void queueTelemetryTick(long tickTime) { TELEMETRY_TICKS.add(getTelemetryNow(tickTime)); if (TELEMETRY_TICKS.size() > SIZE_TICKS) TELEMETRY_TICKS.poll(); if (MINUTE_COUNTER++ >= SIZE_TICKS) { queueTelemetryMinute(); MINUTE_COUNTER = 0; } } public static void queueTelemetryMinute() { TELEMETRY_MINUTES.add(getAverage(TELEMETRY_TICKS)); if (TELEMETRY_MINUTES.size() >= SIZE_MINUTES) TELEMETRY_MINUTES.poll(); if (HOUR_COUNTER++ >= SIZE_MINUTES) { queueTelemetryHour(); HOUR_COUNTER = 0; } } public static void queueTelemetryHour() { TELEMETRY_HOURS.add(getAverage(TELEMETRY_MINUTES)); if (TELEMETRY_HOURS.size() >= SIZE_HOURS) TELEMETRY_HOURS.poll(); if (DAY_COUNTER++ >= SIZE_HOURS) { queueTelemetryDay(); DAY_COUNTER = 0; } } public static void queueTelemetryDay() { TELEMETRY_DAYS.add(getAverage(TELEMETRY_HOURS)); } public static Telemetry getAverage(Queue list) { double memoryLoadTotal = 0.0; long tickTotal = 0; int playersTotal = 0; int num = 0; for (Telemetry t : list) { num++; memoryLoadTotal += t.getMemoryLoad(); tickTotal += t.getTickMs(); playersTotal += t.getPlayersOnline(); } return new Telemetry(System.currentTimeMillis(), memoryLoadTotal/num, tickTotal/num, playersTotal/num); } private static Telemetry getTelemetryNow(long tickTime) { Runtime rt = Runtime.getRuntime(); long used = rt.totalMemory() - rt.freeMemory(); long max = rt.maxMemory(); return new Telemetry(System.currentTimeMillis(), ((double) used / max)*100.0, tickTime, World.getPlayers().size()); } }" "package com.rs.web; public class WorldAPI extends WebAPI { public WorldAPI() { super(""api"", Settings.getConfig().getWorldInfo().port()+1); routes.get(""/players"", ex -> ex.dispatch(() -> APIUtil.sendResponse(ex, StatusCodes.OK, World.getPlayers().size()))); routes.post(""/logout"", ex -> ex.dispatch(() -> { if (!APIUtil.authenticate(ex, Settings.getConfig().getLobbyApiKey())) { APIUtil.sendResponse(ex, StatusCodes.UNAUTHORIZED, new ErrorResponse(""Invalid authorization key."")); return; } APIUtil.readJSON(ex, Account.class, account -> { Player player = World.getPlayerByUsername(account.getUsername()); if (player == null || player.getSession() == null) { APIUtil.sendResponse(ex, StatusCodes.OK, true); return; } player.forceLogout(); APIUtil.sendResponse(ex, StatusCodes.OK, true); }); })); routes.post(""/updateclan"", ex -> ex.dispatch(() -> { if (!APIUtil.authenticate(ex, Settings.getConfig().getLobbyApiKey())) { APIUtil.sendResponse(ex, StatusCodes.UNAUTHORIZED, new ErrorResponse(""Invalid authorization key."")); return; } APIUtil.readJSON(ex, Clan.class, clan -> { ClansManager.syncClanFromLobby(clan); APIUtil.sendResponse(ex, StatusCodes.OK, true); }); })); routes.post(""/updatesocial"", ex -> ex.dispatch(() -> { if (!APIUtil.authenticate(ex, Settings.getConfig().getLobbyApiKey())) { APIUtil.sendResponse(ex, StatusCodes.UNAUTHORIZED, new ErrorResponse(""Invalid authorization key."")); return; } APIUtil.readJSON(ex, Account.class, account -> { Player player = World.getPlayerByUsername(account.getUsername()); if (player == null || player.getSession() == null) { APIUtil.sendResponse(ex, StatusCodes.OK, true); return; } player.getAccount().setSocial(account.getSocial()); player.getClan(); APIUtil.sendResponse(ex, StatusCodes.OK, true); }); })); routes.post(""/updatefc"", ex -> ex.dispatch(() -> { if (!APIUtil.authenticate(ex, Settings.getConfig().getLobbyApiKey())) { APIUtil.sendResponse(ex, StatusCodes.UNAUTHORIZED, new ErrorResponse(""Invalid authorization key."")); return; } APIUtil.readJSON(ex, FCData.class, fc -> { FCManager.updateFCData(fc); APIUtil.sendResponse(ex, StatusCodes.OK, true); }); })); routes.post(""/sendpacket"", ex -> ex.dispatch(() -> { if (!APIUtil.authenticate(ex, Settings.getConfig().getLobbyApiKey())) { APIUtil.sendResponse(ex, StatusCodes.UNAUTHORIZED, new ErrorResponse(""Invalid authorization key."")); return; } APIUtil.readJSON(ex, PacketEncoderDto.class, request -> { Player player = World.getPlayerByUsername(request.username()); if (player == null || player.getSession() == null) { APIUtil.sendResponse(ex, StatusCodes.OK, true); return; } player.getSession().writeToQueue(request.encoders()); APIUtil.sendResponse(ex, StatusCodes.OK, true); }); })); routes.post(""/forwardpackets"", ex -> ex.dispatch(() -> { if (!APIUtil.authenticate(ex, Settings.getConfig().getLobbyApiKey())) { APIUtil.sendResponse(ex, StatusCodes.UNAUTHORIZED, new ErrorResponse(""Invalid authorization key."")); return; } APIUtil.readJSON(ex, PacketDto.class, packet -> { Player player = World.getPlayerByUsername(packet.username()); if (player == null) { APIUtil.sendResponse(ex, StatusCodes.OK, true); return; } for (Packet p : packet.packets()) player.getSession().queuePacket(p); APIUtil.sendResponse(ex, StatusCodes.OK, true); }); })); addRoute(new Telemetry()); } }" "package com.rs.plugin.kts fun overrideNpcLOS(vararg npcNamesOrIds: Any) { npcNamesOrIds.forEach { require(it is String || it is Int) { ""npcNamesOrIds must contain only String or Int types"" } } npcNamesOrIds.forEach { when (it) { is String -> Entity.addLOSOverride(it) is Int -> Entity.addLOSOverride(it) } } } fun overrideNpcLOS(func: TriFunction) { Entity.addLOSOverride(func) } fun onNpcClick(vararg npcNamesOrIds: Any, checkDistance: Boolean = true, options: Array? = null, eventHandler: (NPCClickEvent) -> Unit) { npcNamesOrIds.forEach { require(it is String || it is Int) { ""npcNamesOrIds must contain only String or Int types"" } } NPCClickEvent.registerMethod(NPCClickEvent::class.java, NPCClickHandler(checkDistance, npcNamesOrIds, options) { eventHandler(it) }) } fun onObjectClick(vararg objectNamesOrIds: Any, tiles: Array? = null, checkDistance: Boolean = true, eventHandler: (ObjectClickEvent) -> Unit) { objectNamesOrIds.forEach { require(it is String || it is Int) { ""objectNamesOrIds must contain only String or Int types"" } } ObjectClickEvent.registerMethod(ObjectClickEvent::class.java, ObjectClickHandler(checkDistance, objectNamesOrIds, tiles) { eventHandler(it) }) } fun onObjectClick(vararg objectNamesOrIds: Any, type: ObjectType, eventHandler: (ObjectClickEvent) -> Unit) { objectNamesOrIds.forEach { require(it is String || it is Int) { ""objectNamesOrIds must contain only String or Int types"" } } ObjectClickEvent.registerMethod(ObjectClickEvent::class.java, ObjectClickHandler(objectNamesOrIds, type) { eventHandler(it) }) } fun onPlayerClick(checkDistance: Boolean = true, option: String, eventHandler: (PlayerClickEvent) -> Unit) { PlayerClickEvent.registerMethod(PlayerClickEvent::class.java, PlayerClickHandler(checkDistance, option) { eventHandler(it) }) } fun onButtonClick(vararg interfaceIds: Int, eventHandler: (ButtonClickEvent) -> Unit) { ButtonClickEvent.registerMethod(ButtonClickEvent::class.java, ButtonClickHandler(interfaceIds.toTypedArray()) { eventHandler(it) }) } fun onDestroyItem(vararg itemNamesOrIds: Any, eventHandler: (DestroyItemEvent) -> Unit) { itemNamesOrIds.forEach { require(it is String || it is Int) { ""itemNamesOrIds must contain only String or Int types"" } } DestroyItemEvent.registerMethod(DestroyItemEvent::class.java, DestroyItemHandler(itemNamesOrIds) { eventHandler(it) }) } fun onDropItem(vararg itemNamesOrIds: Any, eventHandler: (DropItemEvent) -> Unit) { itemNamesOrIds.forEach { require(it is String || it is Int) { ""itemNamesOrIds must contain only String or Int types"" } } DropItemEvent.registerMethod(DropItemEvent::class.java, DropItemHandler(itemNamesOrIds) { eventHandler(it) }) } fun onChunkEnter(eventHandler: (EnterChunkEvent) -> Unit) { EnterChunkEvent.registerMethod(EnterChunkEvent::class.java, EnterChunkHandler { eventHandler(it) }) } fun onInterfaceOnInterface(biDirectional: Boolean = false, fromInterfaceIds: IntArray, fromComponentIds:IntArray?, toInterfaceIds: IntArray, toComponentIds: IntArray?, eventHandler: (IFOnIFEvent) -> Unit) { IFOnIFEvent.registerMethod(IFOnIFEvent::class.java, InterfaceOnInterfaceHandler(biDirectional, fromInterfaceIds, fromComponentIds, toInterfaceIds, toComponentIds) { eventHandler(it) }) } //TODO allow object names and ids mappings fun onInterfaceOnNPC(/*vararg npcNamesOrIds: Any, */checkDistance: Boolean = true, fromInterfaceIds: IntArray, fromComponentIds:IntArray?, eventHandler: (IFOnNPCEvent) -> Unit) { //npcNamesOrIds.forEach { require(it is String || it is Int) { ""npcNamesOrIds must contain only String or Int types"" } } IFOnNPCEvent.registerMethod(IFOnNPCEvent::class.java, InterfaceOnNPCHandler(checkDistance, fromInterfaceIds, fromComponentIds) { eventHandler(it) }) } //TODO allow object names and ids mappings fun onInterfaceOnObject(/*vararg objectNamesOrIds: Any, */checkDistance: Boolean = true, fromInterfaceIds: IntArray, fromComponentIds:IntArray?, eventHandler: (InterfaceOnObjectEvent) -> Unit) { //objectNamesOrIds.forEach { require(it is String || it is Int) { ""npcNamesOrIds must contain only String or Int types"" } } InterfaceOnObjectEvent.registerMethod(InterfaceOnObjectEvent::class.java, InterfaceOnObjectHandler(checkDistance, fromInterfaceIds, fromComponentIds) { eventHandler(it) }) } fun onInterfaceOnPlayer(checkDistance: Boolean = true, fromInterfaceIds: IntArray, fromComponentIds:IntArray?, eventHandler: (IFOnPlayerEvent) -> Unit) { IFOnPlayerEvent.registerMethod(IFOnPlayerEvent::class.java, InterfaceOnPlayerHandler(checkDistance, fromInterfaceIds, fromComponentIds) { eventHandler(it) }) } fun onItemAddedToInventory(vararg itemNamesOrIds: Any, eventHandler: (ItemAddedToInventoryEvent) -> Unit) { itemNamesOrIds.forEach { require(it is String || it is Int) { ""itemNamesOrIds must contain only String or Int types"" } } ItemAddedToInventoryEvent.registerMethod(ItemAddedToInventoryEvent::class.java, ItemAddedToInventoryHandler(itemNamesOrIds) { eventHandler(it) }) } fun onItemAddedToBank(vararg itemNamesOrIds: Any, eventHandler: (ItemAddedToBankEvent) -> Unit) { itemNamesOrIds.forEach { require(it is String || it is Int) { ""itemNamesOrIds must contain only String or Int types"" } } ItemAddedToBankEvent.registerMethod(ItemAddedToBankEvent::class.java, ItemAddedToBankHandler(itemNamesOrIds) { eventHandler(it) }) } fun onItemClick(vararg itemNamesOrIds: Any, options: Array? = null, eventHandler: (ItemClickEvent) -> Unit) { itemNamesOrIds.forEach { require(it is String || it is Int) { ""itemNamesOrIds must contain only String or Int types"" } } ItemClickEvent.registerMethod(ItemClickEvent::class.java, ItemClickHandler(itemNamesOrIds, options) { eventHandler(it) }) } fun onItemEquip(vararg itemNamesOrIds: Any, eventHandler: (ItemEquipEvent) -> Unit) { itemNamesOrIds.forEach { require(it is String || it is Int) { ""itemNamesOrIds must contain only String or Int types"" } } ItemEquipEvent.registerMethod(ItemEquipEvent::class.java, ItemEquipHandler(itemNamesOrIds) { eventHandler(it) }) } fun onItemOnItem(used: IntArray, usedWith: IntArray, eventHandler: (ItemOnItemEvent) -> Unit) { ItemOnItemEvent.registerMethod(ItemOnItemEvent::class.java, ItemOnItemHandler(used, usedWith) { eventHandler(it) }) } fun onItemOnItem(vararg used: Int, eventHandler: (ItemOnItemEvent) -> Unit) { ItemOnItemEvent.registerMethod(ItemOnItemEvent::class.java, ItemOnItemHandler(used) { eventHandler(it) }) } fun onItemOnItem(directKeys: Boolean, keys: Array, eventHandler: (ItemOnItemEvent) -> Unit) { ItemOnItemEvent.registerMethod(ItemOnItemEvent::class.java, ItemOnItemHandler(directKeys, keys) { eventHandler(it) }) } fun onItemOnPlayer(vararg itemNamesOrIds: Any, eventHandler: (ItemOnPlayerEvent) -> Unit) { itemNamesOrIds.forEach { require(it is String || it is Int) { ""itemNamesOrIds must contain only String or Int types"" } } ItemOnPlayerEvent.registerMethod(ItemOnPlayerEvent::class.java, ItemOnPlayerHandler(itemNamesOrIds) { eventHandler(it) }) } //TODO allow mapping by item names and ids fun onItemOnNpc(vararg npcNamesOrIds: Any, checkDistance: Boolean = true, eventHandler: (ItemOnNPCEvent) -> Unit) { npcNamesOrIds.forEach { require(it is String || it is Int) { ""npcNamesOrIds must contain only String or Int types"" } } ItemOnNPCEvent.registerMethod(IFOnNPCEvent::class.java, ItemOnNPCHandler(checkDistance, npcNamesOrIds) { eventHandler(it) }) } fun onItemOnObject(objectNamesOrIds: Array, itemNamesOrIds: Array? = null, tiles: Array? = null, checkDistance: Boolean = true, eventHandler: (ItemOnObjectEvent) -> Unit) { objectNamesOrIds.forEach { require(it is String || it is Int) { ""objectNamesOrIds must contain only String or Int types"" } } ItemOnObjectEvent.registerMethod(ItemOnObjectEvent::class.java, ItemOnObjectHandler(checkDistance, objectNamesOrIds, itemNamesOrIds, tiles) { eventHandler(it) }) } fun onLogin(eventHandler: (LoginEvent) -> Unit) { LoginEvent.registerMethod(LoginEvent::class.java, LoginHandler { eventHandler(it) }) } fun onNpcDeath(vararg npcNamesOrIds: Any, eventHandler: (NPCDeathEvent) -> Unit) { npcNamesOrIds.forEach { require(it is String || it is Int) { ""npcNamesOrIds must contain only String or Int types"" } } NPCDeathEvent.registerMethod(NPCDeathEvent::class.java, NPCDeathHandler(npcNamesOrIds) { eventHandler(it) }) } fun onNpcDrop(npcNamesOrIds: Array?, itemNamesOrIds: Array?, eventHandler: (NPCDropEvent) -> Unit) { npcNamesOrIds?.forEach { require(it is String || it is Int) { ""npcNamesOrIds must contain only String or Int types"" } } itemNamesOrIds?.forEach { require(it is String || it is Int) { ""itemNamesOrIds must contain only String or Int types"" } } require(npcNamesOrIds != null || itemNamesOrIds != null) { ""no keys passed for npc drop plugin"" } NPCDropEvent.registerMethod(NPCDropEvent::class.java, NPCDropHandler(npcNamesOrIds, itemNamesOrIds) { eventHandler(it) }) } fun instantiateNpc(vararg npcNamesOrIds: Any, instantiator: (Int, Tile) -> NPC) { npcNamesOrIds.forEach { require(it is String || it is Int) { ""npcNamesOrIds must contain only String or Int types"" } } NPCInstanceEvent.registerMethod(NPCInstanceEvent::class.java, NPCInstanceHandler(npcNamesOrIds) { npcId, tile -> instantiator(npcId, tile) }) } fun getInteractionDistance(vararg npcNamesOrIds: Any, calc: (Player, NPC) -> Int) { npcNamesOrIds.forEach { require(it is String || it is Int) { ""npcNamesOrIds must contain only String or Int types"" } } NPCInteractionDistanceEvent.registerMethod(NPCInteractionDistanceEvent::class.java, NPCInteractionDistanceHandler(npcNamesOrIds) { player, npc -> calc(player, npc) }) } fun onPickupItem(vararg itemNamesOrIds: Any, tiles: Array? = null, eventHandler: (PickupItemEvent) -> Unit) { itemNamesOrIds.forEach { require(it is String || it is Int) { ""itemNamesOrIds must contain only String or Int types"" } } PickupItemEvent.registerMethod(PickupItemEvent::class.java, PickupItemHandler(itemNamesOrIds, tiles) { eventHandler(it) }) } fun onPlayerStep(vararg tiles: Tile, eventHandler: (PlayerStepEvent) -> Unit) { PlayerStepEvent.registerMethod(PlayerStepEvent::class.java, PlayerStepHandler(tiles) { eventHandler(it) }) } fun onXpDrop(eventHandler: (XPGainEvent) -> Unit) { XPGainEvent.registerMethod(XPGainEvent::class.java, XPGainHandler { eventHandler(it) }) } fun npcCombat(vararg npcNamesOrIds: Any, script: (NPC, Entity) -> Int) { npcNamesOrIds.forEach { require(it is String || it is Int) { ""npcNamesOrIds must contain only String or Int types"" } } CombatScriptsHandler.addCombatScript(npcNamesOrIds) { player, npc -> script(player, npc) } }" "package com.rs.plugin.kts @KotlinScript( displayName = ""PluginScript"", fileExtension = ""plugin.kts"", compilationConfiguration = PluginCompilationConfiguration::class, evaluationConfiguration = PluginEvaluationConfiguration::class ) abstract class PluginScript" "package com.rs.plugin.kts object PluginCompilationConfiguration : ScriptCompilationConfiguration({ defaultImports(""com.rs.plugin.kts.*"", ""com.rs.engine.dialogue.DialogueDsl"", ""com.rs.engine.dialogue.*"", ""com.rs.engine.dialogue.HeadE.*"") jvm { dependenciesFromCurrentContext(wholeClasspath = true) } ide { acceptedLocations(ScriptAcceptedLocation.Everywhere) } compilerOptions.append(""-Xadd-modules=ALL-MODULE-PATH"") }) object PluginEvaluationConfiguration : ScriptEvaluationConfiguration({ })" "package com.rs.plugin.kts class PluginScriptHost { companion object { fun loadAndExecuteScripts(): Int { var scriptCount = 0 Files.walk(Paths.get(""./plugins/"")) .filter { Files.isRegularFile(it) && it.toString().endsWith("".plugin.kts"") } .forEach { path -> val result = evalFile(path.toFile()) if (result is ResultWithDiagnostics.Failure) { logScriptError(result) exitProcess(1) } else scriptCount++ } return scriptCount } private fun evalFile(scriptFile: File): ResultWithDiagnostics { return BasicJvmScriptingHost().eval(scriptFile.toScriptSource(), createJvmCompilationConfigurationFromTemplate { defaultImports(""com.rs.plugin.kts.*"", ""com.rs.engine.dialogue.DialogueDsl"", ""com.rs.engine.dialogue.*"", ""com.rs.engine.dialogue.HeadE.*"") jvm { dependenciesFromCurrentContext(wholeClasspath = true) } ide { acceptedLocations(ScriptAcceptedLocation.Everywhere) } compilerOptions.append(""-Xadd-modules=ALL-MODULE-PATH"") }, createJvmEvaluationConfigurationFromTemplate { }) } private fun logScriptError(result: ResultWithDiagnostics.Failure) { println(""Script evaluation failed:"") result.reports.forEach { report -> println("" - ${report.message} (severity: ${report.severity})"") } } } }"