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

[REQUEST] New onOtherSkillAdded() Event for skills #390

Open
Darxo opened this issue Jul 11, 2024 · 1 comment
Open

[REQUEST] New onOtherSkillAdded() Event for skills #390

Darxo opened this issue Jul 11, 2024 · 1 comment
Labels
feature request A feature requested by the community

Comments

@Darxo
Copy link

Darxo commented Jul 11, 2024

Is your feature request related to a problem? Please describe.
A skill currently can't react to another skill being added directly.
For example:

  • Trigger an effect when the character receives a status effect
  • Buff/Nerf an effect received by the character

Instead those changes currently have to either be done in the code of the respective effects or in something like the onUpdate loop.

Describe the solution you'd like
Add a new onOtherSkillAdded(_skill) function to skill_container.nut

q.onOtherSkillAdded <- function( _skill )
{
	this.callSkillsFunction("onOtherSkillAdded", [
		_skill
	], false);
}

Add a new onOtherSkillAdded(_skill) function to skill.nut

q.onOtherSkillAdded <- function( _skill )
{
}

Use hookTree on skill.nut in order to call onOtherSkillAdded when onAdded is called.
HookTree is needed because the base function onAdded is generally overriden by skills.

::MSU.HooksMod.hookTree("scripts/skills/skill", function(q) {
	q.onAdded = @(__original) function()
	{
		__original();
		this.getContainer().onOtherSkillAdded(this);
	}
});

Additional context
This Event is especially useful when designing perks or traits which buff certain existing combat effects. As perks and traits are only added outside of battle and combat effects are only added inside of battle, it is as simple as doing something like this

q.onOtherSkillAdded = @(__original) function( _skill )
{
	if (_skill.getID() == "effects.riposte")
	{
		_skill.m.HitCHance += 15;
	}
}
@Darxo Darxo added the feature request A feature requested by the community label Jul 11, 2024
@LordMidas
Copy link
Member

I've many times run into situations where I would've liked the existence of such a function - this is definitely a useful feature. There are two points to discuss about how to approach this problem:

  • What to do about skills that do not stack and call onRefresh() instead of onAdded() e.g. overwhelmed_effect. onAdded() is also only called when the skill actually moves from SkillsToAdd to Skills inside skill_container during collectGarbage and add functions.
  • Is a hookTree on onAdded the correct approach? Or would it be better to overwrite the vanilla collectGarbage and add functions and manually call the event from there?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request A feature requested by the community
Projects
None yet
Development

No branches or pull requests

2 participants