otland / forgottenserver

A free and open-source MMORPG server emulator written in C++
https://otland.net
GNU General Public License v2.0
1.57k stars 1.05k forks source link

New event Spell Check #4619

Closed MillhioreBT closed 7 months ago

MillhioreBT commented 7 months ago

Pull Request Prelude

Changes Proposed

Did you ever think about blocking all spells, or maybe just one specific spell for a player? Or for a group of players? Or maybe something even crazier?

Well, it's actually possible to do that using global variables or player storage. However, in order for it to work properly, we really have to modify and add some extra conditionals to all the spells we want to control. This is totally horrible.

This new event comes to solve this problem. The onSpellCheck event has two arguments: one is the player and the other is a table with some fields. In these fields, you can find some properties of the spell in question, for example the name.

Here is an example code fragment using the new event:

local event = Event()

function event.onSpellCheck(player, spell)
    if BossEvent:hasPlayer(player) then
        player:sendCancelMessage("You can't use spells in this event.")
        return false
    end
    return true
end

event:register()

Issues addressed: Nothing!