Skip to content

Commit

Permalink
Show overhead icons when certain prayers are active
Browse files Browse the repository at this point in the history
  • Loading branch information
mbpolan committed Oct 25, 2023
1 parent b033ac4 commit 5ae3eba
Show file tree
Hide file tree
Showing 10 changed files with 39 additions and 0 deletions.
7 changes: 7 additions & 0 deletions internal/game/game.go
Original file line number Diff line number Diff line change
Expand Up @@ -2248,6 +2248,13 @@ func (g *Game) handleDeactivatePrayer(pe *playerEntity, prayerID int) {
delete(pe.player.ActivePrayers, prayerID)
}

// handleSetPlayerOverheadIcon sets the overhead icon displayed above the player.
// Concurrency requirements: (a) game state may be locked and (b) this player should be locked.
func (g *Game) handleSetPlayerOverheadIcon(pe *playerEntity, iconID int) {
pe.player.Appearance.OverheadIconID = iconID
pe.appearanceChanged = true
}

// handlePlayerSwapInventoryItem handles moving an item from one slot to another in a player's inventory.
// Concurrency requirements: (a) game state may be locked and (b) this player should be locked.
func (g *Game) handlePlayerSwapInventoryItem(pe *playerEntity, action *MoveInventoryItemAction) {
Expand Down
2 changes: 2 additions & 0 deletions internal/game/game_script.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,6 @@ type ScriptHandler interface {
handleActivatePrayer(pe *playerEntity, prayerID, drain int)
// handleDeactivatePrayer disables a prayer.
handleDeactivatePrayer(pe *playerEntity, prayerID int)
// handleSetPlayerOverheadIcon sets the overhead icon displayed above the player.
handleSetPlayerOverheadIcon(pe *playerEntity, iconID int)
}
7 changes: 7 additions & 0 deletions internal/game/script_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -659,6 +659,13 @@ func (s *ScriptManager) registerPlayerModel(l *lua.LState) {
s.handler.handleDeactivatePrayer(pe, prayerID)
return 0
},
"overhead_icon": func(state *lua.LState) int {
pe := state.CheckUserData(1).Value.(*playerEntity)
iconID := state.CheckInt(2)

s.handler.handleSetPlayerOverheadIcon(pe, iconID)
return 0
},
}))
}

Expand Down
11 changes: 11 additions & 0 deletions scripts/alib/globals.lua
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,17 @@ ACCEPT_AID_NO = "NO"
MOVE_SPEED_WALK = 0
MOVE_SPEED_RUN = 1

-- overhead icons
OVERHEAD_NONE = 0
OVERHEAD_PROTECT_FROM_MELEE = 1
OVERHEAD_PROTECT_FROM_MISSILES = 2
OVERHEAD_PROTECT_FROM_MAGE = 4
OVERHEAD_RETRIBUTION = 8
OVERHEAD_SMITE = 16
OVERHEAD_REDEMPTION = 32
OVERHEAD_WHITE_SKULL = 64
OVERHEAD_RED_SKULL = 128

-- identifiers for quest statuses
QUEST_STATUS_NOT_STARTED = 0
QUEST_STATUS_IN_PROGRESS = 1
Expand Down
2 changes: 2 additions & 0 deletions scripts/prayers/protect_from_magic.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@ function prayer_protect_from_magic(player, activate)
end

-- TODO: add buffs, effects, etc.
player:overhead_icon(OVERHEAD_PROTECT_FROM_MAGE)

player:activate_prayer(PRAYER_PROTECT_FROM_MAGE, 12)
player:interface_setting(setting_id, 1)
else
-- TODO: remove buffs, effects, etc.
player:overhead_icon(OVERHEAD_NONE)

player:deactivate_prayer(PRAYER_PROTECT_FROM_MAGE)
player:interface_setting(setting_id, 0)
Expand Down
2 changes: 2 additions & 0 deletions scripts/prayers/protect_from_melee.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@ function prayer_protect_from_melee(player, activate)
end

-- TODO: add buffs, effects, etc.
player:overhead_icon(OVERHEAD_PROTECT_FROM_MELEE)

player:activate_prayer(PRAYER_PROTECT_FROM_MELEE, 12)
player:interface_setting(setting_id, 1)
else
-- TODO: remove buffs, effects, etc.
player:overhead_icon(OVERHEAD_NONE)

player:deactivate_prayer(PRAYER_PROTECT_FROM_MELEE)
player:interface_setting(setting_id, 0)
Expand Down
2 changes: 2 additions & 0 deletions scripts/prayers/protect_from_missiles.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@ function prayer_protect_from_missiles(player, activate)
end

-- TODO: add buffs, effects, etc.
player:overhead_icon(OVERHEAD_PROTECT_FROM_MISSILES)

player:activate_prayer(PRAYER_PROTECT_FROM_MISSILES, 12)
player:interface_setting(setting_id, 1)
else
-- TODO: remove buffs, effects, etc.
player:overhead_icon(OVERHEAD_NONE)

player:deactivate_prayer(PRAYER_PROTECT_FROM_MISSILES)
player:interface_setting(setting_id, 0)
Expand Down
2 changes: 2 additions & 0 deletions scripts/prayers/redemption.lua
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,13 @@ function prayer_redemption(player, activate)
end

-- TODO: add buffs, effects, etc.
player:overhead_icon(OVERHEAD_REDEMPTION)

player:activate_prayer(PRAYER_REDEMPTION, 6)
player:interface_setting(setting_id, 1)
else
-- TODO: remove buffs, effects, etc.
player:overhead_icon(OVERHEAD_NONE)

player:deactivate_prayer(PRAYER_REDEMPTION)
player:interface_setting(setting_id, 0)
Expand Down
2 changes: 2 additions & 0 deletions scripts/prayers/retribution.lua
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,13 @@ function prayer_retribution(player, activate)
end

-- TODO: add buffs, effects, etc.
player:overhead_icon(OVERHEAD_RETRIBUTION)

player:activate_prayer(PRAYER_RETRIBUTION, 3)
player:interface_setting(setting_id, 1)
else
-- TODO: remove buffs, effects, etc.
player:overhead_icon(OVERHEAD_NONE)

player:deactivate_prayer(PRAYER_RETRIBUTION)
player:interface_setting(setting_id, 0)
Expand Down
2 changes: 2 additions & 0 deletions scripts/prayers/smite.lua
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,13 @@ function prayer_smite(player, activate)
end

-- TODO: add buffs, effects, etc.
player:overhead_icon(OVERHEAD_SMITE)

player:activate_prayer(PRAYER_SMITE, 18)
player:interface_setting(setting_id, 1)
else
-- TODO: remove buffs, effects, etc.
player:overhead_icon(OVERHEAD_NONE)

player:deactivate_prayer(PRAYER_SMITE)
player:interface_setting(setting_id, 0)
Expand Down

0 comments on commit 5ae3eba

Please sign in to comment.