11package content.skill.summoning
22
3- import world.gregs.voidps.cache.definition.data.NPCDefinition
3+ import content.entity.player.dialogue.type.choice
4+ import content.entity.player.inv.inventoryItem
45import world.gregs.voidps.engine.client.message
6+ import world.gregs.voidps.engine.client.ui.interfaceOption
57import world.gregs.voidps.engine.data.definition.EnumDefinitions
8+ import world.gregs.voidps.engine.data.definition.NPCDefinitions
9+ import world.gregs.voidps.engine.entity.character.player.skill.Skill
10+ import world.gregs.voidps.engine.entity.playerSpawn
11+ import world.gregs.voidps.engine.inject
12+ import world.gregs.voidps.engine.inv.inventory
13+ import world.gregs.voidps.engine.inv.remove
14+ import world.gregs.voidps.engine.event.Script
15+
16+ import world.gregs.voidps.cache.definition.data.NPCDefinition
617import world.gregs.voidps.engine.data.definition.ItemDefinitions
718import world.gregs.voidps.engine.entity.character.Character
819import world.gregs.voidps.engine.entity.character.mode.Follow
@@ -11,9 +22,6 @@ import world.gregs.voidps.engine.entity.character.npc.NPC
1122import world.gregs.voidps.engine.entity.character.npc.NPCs
1223import world.gregs.voidps.engine.entity.character.player.Player
1324import world.gregs.voidps.engine.entity.item.Item
14- import world.gregs.voidps.engine.inject
15- import world.gregs.voidps.engine.inv.inventory
16- import world.gregs.voidps.engine.inv.remove
1725import world.gregs.voidps.engine.queue.softQueue
1826
1927val itemDefinitions: ItemDefinitions by inject()
@@ -108,4 +116,103 @@ fun Player.renewFamiliar() {
108116 this [" familiar_details_minutes_remaining" ] = follower!! .def[" summoning_time_minutes" , 0 ]
109117 this [" familiar_details_seconds_remaining" ] = 0
110118 follower!! .gfx(" summon_familiar_size_${follower!! .size} " )
111- }
119+ }
120+ @Script
121+ class Summoning {
122+
123+ val enums: EnumDefinitions by inject()
124+ val npcDefinitions: NPCDefinitions by inject()
125+
126+ init {
127+ inventoryItem(" Summon" , " *_pouch" ) {
128+ val familiarLevel = enums.get(" summoning_pouch_levels" ).getInt(item.def.id)
129+ val familiarId = enums.get(" summoning_familiar_ids" ).getInt(item.def.id)
130+ val summoningXp = item.def[" summon_experience" , 0.0 ]
131+ val familiar = npcDefinitions.get(familiarId)
132+
133+ if (player.levels.get(Skill .Summoning ) < familiarLevel) {
134+ // TODO: Get actual message
135+ player.message(" You don't have the level needed to summon that familiar..." )
136+ return @inventoryItem
137+ }
138+
139+ player.summonFamiliar(familiar, false ) ? : return @inventoryItem
140+ player.inventory.remove(item.id)
141+ player.experience.add(Skill .Summoning , summoningXp)
142+ }
143+
144+ interfaceOption(" Select left-click option" , id = " summoning_orb" ) {
145+ player.openFollowerLeftClickOptions()
146+ }
147+
148+ interfaceOption(" Select" , id = " follower_left_click_options" ) {
149+ val varbitValue = when {
150+ component.startsWith(" follower_details" ) -> 0
151+ component.startsWith(" special_move" ) -> 1
152+ component.startsWith(" attack" ) -> 2
153+ component.startsWith(" call_follower" ) -> 3
154+ component.startsWith(" dismiss_follower" ) -> 4
155+ component.startsWith(" take_bob" ) -> 5
156+ component.startsWith(" renew_familiar" ) -> 6
157+ else -> - 1
158+ }
159+
160+ player[" summoning_menu_left_click_option" ] = varbitValue
161+ }
162+
163+ interfaceOption(" Confirm Selection" , " confirm" , " follower_left_click_options" ) {
164+ player.confirmFollowerLeftClickOptions()
165+ }
166+
167+ interfaceOption(" Dismiss" , id = " summoning_orb" ) {
168+ player.dismissFamiliar()
169+ }
170+
171+ interfaceOption(" Renew Familiar" , id = " summoning_orb" ) {
172+ player.renewFamiliar()
173+ }
174+
175+ interfaceOption(" Dismiss *" , " dismiss" , " familiar_details" ) {
176+ when (option) {
177+ " Dismiss Familiar" -> {
178+ choice(" Are you sure you want to dismiss your familiar?" ) {
179+ option(" Yes." ) {
180+ player.dismissFamiliar()
181+ }
182+ option(" No." )
183+ }
184+ }
185+ " Dismiss Now" -> player.dismissFamiliar()
186+ }
187+ }
188+
189+ interfaceOption(" Renew Familiar" , " renew" , " familiar_details" ) {
190+ player.renewFamiliar()
191+ }
192+
193+ interfaceOption(" Call *" , " call" , " *_details" ) {
194+ player.callFollower()
195+ }
196+
197+ interfaceOption(" Call Follower" , " *" , " summoning_orb" ) {
198+ player.callFollower()
199+ }
200+
201+ playerSpawn {player ->
202+ if (player[" familiar_details_seconds_remaining" , 0 ] == 0 && player[" familiar_details_minutes_remaining" , 0 ] == 0 ) {
203+ return @playerSpawn
204+ }
205+
206+ val familiarDef = npcDefinitions.get(player[" follower_details_chathead" , - 1 ])
207+ player.variables.send(" follower_details_name" )
208+ player.variables.send(" follower_details_chathead" )
209+ player.variables.send(" familiar_details_minutes_remaining" )
210+ player.variables.send(" familiar_details_seconds_remaining" )
211+ player.variables.send(" follower_details_chathead_animation" )
212+ player.timers.restart(" familiar_timer" )
213+ player.summonFamiliar(familiarDef, true )
214+ }
215+
216+ }
217+
218+ }
0 commit comments