Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New event Spell Check #4619

Merged
merged 3 commits into from
Jan 12, 2024
Merged

Conversation

MillhioreBT
Copy link
Contributor

Pull Request Prelude

  • I have followed [proper The Forgotten Server code styling][code].
  • I have read and understood the [contribution guidelines][cont] before making this PR.
  • I am aware that this PR may be closed if the above-mentioned criteria are not fulfilled.

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!

@MillhioreBT MillhioreBT added the enhancement Increase or improvement in quality, value, or extent label Jan 12, 2024
src/events.cpp Outdated Show resolved Hide resolved
Copy link
Contributor

@EvilHero90 EvilHero90 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks fine to me

@EvilHero90 EvilHero90 merged commit 85e3cc8 into otland:master Jan 12, 2024
23 checks passed
@MillhioreBT MillhioreBT deleted the event_spell_check branch January 13, 2024 04:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Increase or improvement in quality, value, or extent
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants