Created
May 18, 2019 19:07
-
-
Save austinbuckler/6b0a0d5bad504ecc39a9a5dd0f39800b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun performEmote(p: Player, emote: Emote) { | |
if (emote.varbit != -1 && p.getVarbit(emote.varbit) != emote.requiredVarbitValue) { | |
val description = emote.unlockDescription ?: "You have not unlocked this emote yet." | |
p.queue { messageBox(description) } | |
return | |
} | |
if (emote == Emote.SKILLCAPE) { | |
if (skillcape_emote_anim(p) != -1) { | |
p.animate(skillcape_emote_anim(p)) | |
} | |
if (skillcape_emote_gfx(p) != -1) { | |
p.graphic(skillcape_emote_gfx(p)) | |
} | |
} else { | |
if (emote.anim != -1) { | |
p.animate(emote.anim) | |
} | |
if (emote.gfx != -1) { | |
p.graphic(emote.gfx) | |
} | |
} | |
} | |
val SKILLCAPES = mapOf( | |
Pair(Items.ATTACK_CAPE, Pair(4959, 823)), | |
Pair(Items.RUNECRAFT_CAPE, Pair(4947, 817)), | |
Pair(Items.STRENGTH_CAPE, Pair(4947, 817)), | |
Pair(Items.HITPOINTS_CAPE, Pair(4947, 817)), | |
Pair(Items.DEFENCE_CAPE, Pair(4947, 817)), | |
Pair(Items.AGILITY_CAPE, Pair(4947, 817)) | |
) | |
fun get_definition(p: Player): Pair<Int, Int>? { | |
val capeSlot = EquipmentType.CAPE.id | |
val capeId = p.equipment[capeSlot]?.id ?: -1 | |
return get_skillcape(capeId) | |
} | |
fun get_skillcape(capeId: Int): Pair<Int, Int>? { | |
if (capeId == -1) return null | |
val skillcapeId = capeId - 1 | |
return SKILLCAPES[capeId] ?: SKILLCAPES[skillcapeId] | |
} | |
fun check_skillcape(p: Player) { | |
val skillcapeConfig = if (get_definition(p) != null) 1 else 0 | |
p.setVarbit(SKILLCAPE_EMOTE_VARBIT, skillcapeConfig) | |
} | |
fun skillcape_emote_anim(p: Player): Int { | |
val definition = get_definition(p) | |
return definition?.first ?: -1 | |
} | |
fun skillcape_emote_gfx(p: Player): Int { | |
val definition = get_definition(p) | |
return definition?.second ?: -1 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment