Tomm0017 / rsmod

New repository: https://github.com/rsmod/rsmod
https://github.com/rsmod/rsmod
Apache License 2.0
125 stars 101 forks source link

Support for dynamic object options? #14

Closed tristonplummer closed 5 years ago

tristonplummer commented 5 years ago

Some objects only have objects when a specific varbit is set - can we add support for this somehow? The example I'll give is the Mysterious Ruins for Runecrafting. When varbit 607 is set to 1, the 'enter' option on the Mysterious Ruins for the Air Altar is shown, however this throws an exception when starting the server as 'enter' is not a valid option for the object.


package gg.rsmod.plugins.content.objs.runecraftruins

import com.google.common.collect.ImmutableSet

data class RunecraftRuinsType(val id : Int, val talisman : Int, val tiara : Int, val varbit : Int, val destination: Tile)

val ruins = ImmutableSet.of(
        RunecraftRuinsType(id = Objs.MYSTERIOUS_RUINS, talisman = Items.AIR_TALISMAN, tiara = Items.AIR_TIARA, varbit = 607, destination = Tile(2841, 4830))
)!!

ruins.forEach { ruin ->

    on_item_equip(ruin.tiara) {
        player.setVarbit(ruin.varbit, 1)
    }

    on_item_unequip(ruin.tiara) {
        player.setVarbit(ruin.varbit, 0)
    }

    on_obj_option(obj = ruin.id, option = "enter") {
        if (player.getVarbit(ruin.varbit) == 1) {
            player.teleport(ruin.destination)
        }
    }
}
Tomm0017 commented 5 years ago

The way we went about varbit/varp in objects with transformations was that we have separate plugins for each object transform instead of the 'base' object.

So on_obj_option will have to actually bind the 'transformed' object id instead of the one without the option