@@ -2,44 +2,18 @@ package content.skill.summoning
22
33import content.entity.player.dialogue.type.choice
44import content.entity.player.inv.inventoryItem
5- import world.gregs.voidps.cache.definition.data.NPCDefinition
65import world.gregs.voidps.engine.client.message
76import world.gregs.voidps.engine.client.ui.interfaceOption
87import world.gregs.voidps.engine.data.definition.EnumDefinitions
9- import world.gregs.voidps.engine.data.definition.ItemDefinitions
108import world.gregs.voidps.engine.data.definition.NPCDefinitions
11- import world.gregs.voidps.engine.entity.character.mode.Follow
12- import world.gregs.voidps.engine.entity.character.move.tele
13- import world.gregs.voidps.engine.entity.character.npc.NPC
14- import world.gregs.voidps.engine.entity.character.npc.NPCs
15- import world.gregs.voidps.engine.entity.character.player.Player
169import world.gregs.voidps.engine.entity.character.player.skill.Skill
17- import world.gregs.voidps.engine.entity.item.Item
1810import world.gregs.voidps.engine.entity.playerSpawn
1911import world.gregs.voidps.engine.inject
2012import world.gregs.voidps.engine.inv.inventory
2113import world.gregs.voidps.engine.inv.remove
22- import world.gregs.voidps.engine.queue.softQueue
23- import world.gregs.voidps.engine.timer.timerStart
24- import world.gregs.voidps.engine.timer.timerStop
25- import world.gregs.voidps.engine.timer.timerTick
2614
2715val enums: EnumDefinitions by inject()
28- val npcs: NPCs by inject()
2916val npcDefinitions: NPCDefinitions by inject()
30- val itemDefinitions: ItemDefinitions by inject()
31-
32- var Player .follower: NPC ?
33- get() {
34- val index = this [" follower_index" , - 1 ]
35- return world.gregs.voidps.engine.get<NPCs >().indexed(index)
36- }
37- set(value) {
38- if (value != null ) {
39- this [" follower_index" ] = value.index
40- this [" follower_id" ] = value.id
41- }
42- }
4317
4418inventoryItem(" Summon" , " *_pouch" ) {
4519 val familiarLevel = enums.get(" summoning_pouch_levels" ).getInt(item.def.id)
@@ -128,109 +102,4 @@ playerSpawn {player ->
128102 player.variables.send(" follower_details_chathead_animation" )
129103 player.timers.restart(" familiar_timer" )
130104 player.summonFamiliar(familiarDef, true )
131- }
132-
133- fun Player.summonFamiliar (familiar : NPCDefinition , restart : Boolean ): NPC ? {
134- if (follower != null ) {
135- // TODO: Find actual message for this
136- message(" You must dismiss your current follower before summoning another." )
137- return null
138- }
139-
140- val familiarNpc = npcs.add(familiar.stringId, tile)
141- familiarNpc.mode = Follow (familiarNpc, this )
142-
143- softQueue(" summon_familiar" , 2 ) {
144- follower = familiarNpc
145-
146- follower!! .gfx(" summon_familiar_size_${follower!! .size} " )
147- player.updateFamiliarInterface()
148- if (! restart) timers.start(" familiar_timer" )
149- }
150-
151- return familiarNpc
152- }
153-
154- fun Player.dismissFamiliar () {
155- npcs.remove(follower)
156- follower = null
157- interfaces.close(" familiar_details" )
158-
159- this [" follower_details_name" ] = 0
160- this [" follower_details_chathead" ] = 0
161- this [" familiar_details_minutes_remaining" ] = 0
162- this [" familiar_details_seconds_remaining" ] = 0
163- timers.stop(" familiar_timer" )
164- }
165-
166- fun Player.updateFamiliarInterface () {
167- if (follower == null ) return
168-
169- this .interfaces.open(" familiar_details" )
170-
171- this [" follower_details_name" ] = enums.get(" summoning_familiar_ids" ).getKey(follower!! .def.id)
172- this [" follower_details_chathead" ] = follower!! .def.id
173-
174- this [" follower_details_chathead_animation" ] = 1
175- }
176-
177- fun Player.openFollowerLeftClickOptions () {
178- interfaces.open(" follower_left_click_options" )
179- }
180-
181- fun Player.confirmFollowerLeftClickOptions () {
182- this [" summoning_orb_left_click_option" ] = this [" summoning_menu_left_click_option" , - 1 ]
183- interfaces.close(" follower_left_click_options" )
184- }
185-
186- fun Player.callFollower () {
187- follower!! .tele(steps.follow, clearMode = false )
188- follower!! .clearWatch()
189- }
190-
191- fun Player.renewFamiliar () {
192- val pouchId = enums.get(" summoning_familiar_ids" ).getKey(follower!! .def.id)
193- val pouchItem = Item (itemDefinitions.get(pouchId).stringId)
194-
195- if (! inventory.contains(pouchItem.id)) {
196- // TODO: Find the actual message used here in 2011
197- message(" You don't have the required pouch to renew your familiar." )
198- return
199- }
200-
201- inventory.remove(pouchItem.id)
202- this [" familiar_details_minutes_remaining" ] = follower!! .def[" summoning_time_minutes" , 0 ]
203- this [" familiar_details_seconds_remaining" ] = 0
204- follower!! .gfx(" summon_familiar_size_${follower!! .size} " )
205- }
206-
207- timerStart(" familiar_timer" ) {player ->
208- interval = 50 // 30 seconds
209-
210- if (! restart) {
211- player[" familiar_details_minutes_remaining" ] = player.follower!! .def[" summoning_time_minutes" , 0 ]
212- player[" familiar_details_seconds_remaining" ] = 0
213- }
214- }
215-
216- timerTick(" familiar_timer" ) {player ->
217- if (player[" familiar_details_seconds_remaining" , 0 ] == 0 ) {
218- player.dec(" familiar_details_minutes_remaining" )
219- }
220- player[" familiar_details_seconds_remaining" ] = (player[" familiar_details_seconds_remaining" , 0 ] + 1 ) % 2
221-
222- if (player[" familiar_details_seconds_remaining" , 0 ] <= 0 && player[" familiar_details_minutes_remaining" , 0 ] <= 0 ) {
223- cancel()
224- }
225- }
226-
227- timerStop(" familiar_timer" ) {player ->
228- if (logout) {
229- npcs.remove(player.follower)
230- return @timerStop
231- }
232-
233- if (player.follower != null ) {
234- player.dismissFamiliar()
235- }
236105}
0 commit comments