11package content.skill.summoning
22
33import content.entity.player.dialogue.type.choice
4+ import net.pearx.kasechange.toLowerSpaceCase
5+ import org.rsmod.game.pathfinder.StepValidator
46import world.gregs.voidps.cache.definition.data.NPCDefinition
57import world.gregs.voidps.engine.Script
68import world.gregs.voidps.engine.client.message
@@ -15,11 +17,15 @@ import world.gregs.voidps.engine.entity.character.npc.NPC
1517import world.gregs.voidps.engine.entity.character.npc.NPCs
1618import world.gregs.voidps.engine.entity.character.player.Player
1719import world.gregs.voidps.engine.entity.character.player.skill.Skill
20+ import world.gregs.voidps.engine.entity.character.player.skill.level.Level.has
1821import world.gregs.voidps.engine.entity.item.Item
19- import world.gregs.voidps.engine.inject
22+ import world.gregs.voidps.engine.get
2023import world.gregs.voidps.engine.inv.inventory
2124import world.gregs.voidps.engine.inv.remove
25+ import world.gregs.voidps.engine.map.collision.canFit
26+ import world.gregs.voidps.engine.map.spiral
2227import world.gregs.voidps.engine.queue.softQueue
28+ import world.gregs.voidps.type.Tile
2329
2430val Character ?.isFamiliar: Boolean
2531 get() = this != null && this is NPC && id.endsWith(" _familiar" )
@@ -43,13 +49,15 @@ var Player.follower: NPC?
4349 * @param restart A boolean used to tell if this familiar is being summoned at login. If set to false will start a new
4450 * familiar timer
4551 */
46- fun Player.summonFamiliar (familiar : NPCDefinition , restart : Boolean ): NPC ? {
52+ fun Player.summonFamiliar (familiar : NPCDefinition , restart : Boolean ) {
4753 if (follower != null ) {
48- // TODO: Find actual message for this
49- message(" You must dismiss your current follower before summoning another." )
50- return null
54+ message(" You already have a follower." )
55+ return
5156 }
5257
58+ // TODO summoning energy
59+ // message("You don't have enough summoning energy to summon this familiar.")
60+
5361 val familiarNpc = NPCs .add(familiar.stringId, tile)
5462 familiarNpc.mode = Follow (familiarNpc, this )
5563 softQueue(" summon_familiar" , 2 ) {
@@ -60,7 +68,6 @@ fun Player.summonFamiliar(familiar: NPCDefinition, restart: Boolean): NPC? {
6068 timers.start(" familiar_timer" )
6169 }
6270 }
63- return familiarNpc
6471}
6572
6673/* *
@@ -90,7 +97,7 @@ fun Player.dismissFamiliar() {
9097fun Player.updateFamiliarInterface () {
9198 val follower = follower ? : return
9299 interfaces.open(" familiar_details" )
93- set(" follower_details_name" , world.gregs.voidps.engine. get<EnumDefinitions >().get(" summoning_familiar_ids" ).getKey(follower.def.id))
100+ set(" follower_details_name" , get<EnumDefinitions >().get(" summoning_familiar_ids" ).getKey(follower.def.id))
94101 set(" follower_details_chathead" , follower.def.id)
95102 set(" follower_details_chathead_animation" , follower.id)
96103}
@@ -115,7 +122,23 @@ fun Player.confirmFollowerLeftClickOptions() {
115122 */
116123fun Player.callFollower () {
117124 val follower = follower ? : return
118- follower.tele(steps.follow, clearMode = false )
125+ val steps: StepValidator = get()
126+ var target: Tile ? = null
127+ for (tile in tile.spiral(follower.size)) {
128+ if (tile == this .tile) {
129+ continue
130+ }
131+ if (! steps.canFit(tile, follower.collision, follower.size, follower.blockMove)) {
132+ continue
133+ }
134+ target = tile
135+ break
136+ }
137+ if (target == null ) {
138+ message(" Your familiar is too large to fit in the area you are standing in. Move into a larger space and try again." )
139+ return
140+ }
141+ follower.tele(target, clearMode = false )
119142 follower.clearWatch()
120143 follower.gfx(" summon_familiar_size_${follower.size} " )
121144}
@@ -126,19 +149,24 @@ fun Player.callFollower() {
126149 */
127150fun Player.renewFamiliar () {
128151 val follower = follower ? : return
129- val pouchId = world.gregs.voidps.engine. get<EnumDefinitions >().get(" summoning_familiar_ids" ).getKey(follower.def.id)
152+ val pouchId = get<EnumDefinitions >().get(" summoning_familiar_ids" ).getKey(follower.def.id)
130153 val pouchItem = Item (ItemDefinitions .get(pouchId).stringId)
131-
154+ val remaining = get(" familiar_details_minutes_remaining" , 0 ) * 60 + get(" familiar_details_seconds_remaining" , 0 )
155+ if (remaining >= 170 ) {
156+ message(" You need to have less than 2:50 remaining before you can renew your familiar." )
157+ return
158+ }
132159 if (! inventory.contains(pouchItem.id)) {
133- // TODO: Find the actual message used here in 2011
134- message(" You don't have the required pouch to renew your familiar." )
160+ message(" You need a ${pouchItem.def.name.toLowerSpaceCase()} to renew your familiar's timer." )
161+ return
162+ }
163+ if (! inventory.remove(pouchItem.id)) {
135164 return
136165 }
137-
138- inventory.remove(pouchItem.id)
139166 set(" familiar_details_minutes_remaining" , follower.def[" summoning_time_minutes" , 0 ])
140167 set(" familiar_details_seconds_remaining" , 0 )
141168 follower.gfx(" summon_familiar_size_${follower.size} " )
169+ message(" You use your remaining pouch to renew your familiar." )
142170}
143171
144172class Summoning (val enums : EnumDefinitions ) : Script {
@@ -149,14 +177,11 @@ class Summoning(val enums: EnumDefinitions) : Script {
149177 val familiarId = enums.get(" summoning_familiar_ids" ).getInt(option.item.def.id)
150178 val summoningXp = option.item.def[" summon_experience" , 0.0 ]
151179 val familiar = NPCDefinitions .get(familiarId)
152-
153- if (levels.get(Skill .Summoning ) < familiarLevel) {
154- // TODO: Get actual message
155- message(" You don't have the level needed to summon that familiar..." )
180+ if (! has(Skill .Summoning , familiarLevel)) {
181+ message(" You are not high enough level to use this pouch." )
156182 return @itemOption
157183 }
158-
159- summonFamiliar(familiar, false ) ? : return @itemOption
184+ summonFamiliar(familiar, false )
160185 inventory.remove(option.item.id)
161186 experience.add(Skill .Summoning , summoningXp)
162187 }
@@ -233,5 +258,9 @@ class Summoning(val enums: EnumDefinitions) : Script {
233258 timers.restart(" familiar_timer" )
234259 summonFamiliar(familiarDef, true )
235260 }
261+
262+ interfaceOption(" Take BoB" , " familiar_details:take_bob_items" ) {
263+ message(" <dark_green>Not currently implemented." )
264+ }
236265 }
237266}
0 commit comments