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

Magiclysm: Multiple spell effects #31983

Merged
merged 8 commits into from
Jul 6, 2019

Conversation

KorGgenT
Copy link
Member

@KorGgenT KorGgenT commented Jun 30, 2019

Summary

SUMMARY: Mods "Magiclysm: Multiple Spell Effects"

Purpose of change

I have had several requests to make it possible to add multiple effects to spells.

Describe the solution

I have added a new member to spell_type which is a vector of fake_spell, which has a spell_id, max level, and a bool. This will allow a huge amount of versatility, since what this does is actually cast the new spell, rather than just apply affects. I have added a pair of new spells for stormshaper that illustrate the usage: Lightning Storm basically casts Lightning Blast an additional 3 times after it does its own spell effect.

@KorGgenT KorGgenT added [JSON] Changes (can be) made in JSON Mods Issues related to mods or modding Spawn Creatures, items, vehicles, locations appearing on map [C++] Changes (can be) made in C++. Previously named `Code` Items / Item Actions / Item Qualities Items and how they work and interact Mods: Magiclysm Anything to do with the Magiclysm mod labels Jun 30, 2019
@dkargin
Copy link
Contributor

dkargin commented Jun 30, 2019

I was thinking another approach: to wrap up most of current spell data to a 'spell effect' structure (range, damage, aoe, targets) and change json accordingly.

Then we could add additional structure 'spell context', which can store/change some data between every effect invocation. This structure should be passed to every effect function. For example, the first effect writes all the targets affected to the list context.hits. Next effect 'target_hit_to_damage' converts this number to damage bonus, and writes it to context.data["damage_bonus"]. The next effect heals caster for effect.damage + context.data["damage_bonus"]. This allows us to introduce some ghetto scripting for spells, (since LUA is gone).

But generally, it allows us to describe a composition of fx/sfx/text effects in a better way. For example, a single fireball could consist of the following effects:

  1. Spawn regular explosion effect with specified radius
  2. Spawn sound effect for explosion
  3. Apply damage in an area
  4. Spawn fd_fire for any target affected

Or some bloody necromancer spell could be described as:

  1. Spawn fd_blood around caster
  2. Spawn fd_blood around target
  3. Do actual spell logic.

Let's return back to current PR. The problem with infinite loops now can be solved by introducing this context and by storing current number of invocations there.

@KorGgenT
Copy link
Member Author

i don't follow why we need to change everything around in order to do... exactly what everything already can do plus this pr. There's no need for any scripting, since changes are all in C++ for effects, and once this PR is wrapped up modders will have even more freedom to have spells do whatever they want.

src/magic.cpp Outdated Show resolved Hide resolved
src/magic.cpp Outdated Show resolved Hide resolved
@dkargin
Copy link
Contributor

dkargin commented Jun 30, 2019

Right now you can not change spell numbers (damage, area, ...) from another spell/effect without adding a new spell effect in C++, with combined logic. For example, there was an ancient spell death coil in warcraft 2, which damages several targets and heals caster for amount equal to damage dealt. Or some modders (me) would like to implement a ritual spell, which consumes/checks some items around and adds proportional values to desired spell effect (area/damage/...). Right now you should C++ a completely new spell effect for any of these.

Since you've done it this way, that's OK. Spell context can be introduced to current approach of spell chains. And it can deal with infinite loop problem as well.

@KorGgenT
Copy link
Member Author

no, you don't need to do a new c++ effect to do new spells with different values, you just need to write up more json for them.

@foulman
Copy link
Contributor

foulman commented Jun 30, 2019

I don't want to sound nitpicky, but I would call this spell chaining as that's what it really is, one after another, though with zero casting times on the following spells, which I would probaby do, they could more or less be simultaneous depending on what you were trying to accomplish.

I also don't really see how there's a problem with infinite loops, you'd have to create your own custom spells for that, I'm not going to make any that do, and if the player wants to be stupid and lock up their game with a spell loop, or at least until they run out of mana, that's kinda their choice isn't it?

@KorGgenT
Copy link
Member Author

sure, you can call it what you like

as far as infinite loops, if i can try to nip it in the bud i'd rather do that if i can. i think i've tracked down a relatively easy way to do it, too.

@foulman
Copy link
Contributor

foulman commented Jun 30, 2019

I would suggest increasing the number of chained spells though, 3 is a bit arbitrary. A hard limit of... say spellcraft rank or spellcraft/2, or maybe just max it out at 10.
I have wanted to make a 'Minute Meteors' spell for example that this would be perfect for, say every round the player gets another shot. They do need to be able to cancel out of the chain though, with esc perhaps?

@KorGgenT
Copy link
Member Author

i never said anything about hard limits. i didn't put in any hard limits.

@foulman
Copy link
Contributor

foulman commented Jun 30, 2019

LOL, you're right, I just read too much into the 3 castings of the lightning thing, my bad. so it's unlimited?
Also, are the chained spells succeptible to individual spell failure? Considered to be cast by the caster each time or are they automatic?

@KorGgenT
Copy link
Member Author

the reason i haven't called it chained spells is that

  1. you don't "cast" it - it's just a part of the first spell you cast
  2. no, you can't cancel during a spell chain

@foulman
Copy link
Contributor

foulman commented Jun 30, 2019

the reason i haven't called it chained spells is that

1. you don't "cast" it - it's just a part of the first spell you cast

2. no, you can't cancel during a spell chain
  1. That's good.
  2. I see that as a small issue then, what if you run out of valid targets? Such as for scaled up Magic Missile spell that fires off 5 missiles?

@KorGgenT
Copy link
Member Author

the monsters don't die until the end of the spell chain

@foulman
Copy link
Contributor

foulman commented Jun 30, 2019

Wouldn't that depend on the casting time of the chained spells? I checked and your lightning blasts each have casting times, so is time passing between them?

@KorGgenT
Copy link
Member Author

no, the casting time for lightning blast is just for that spell. spells chained onto another spell ignore casting time, casting cost, and range.

@foulman
Copy link
Contributor

foulman commented Jun 30, 2019

Ahhh, okay. That makes sense, but.. I feel like if it's possible you should have it able to go both ways.
For example I immediately thought of a spell chain of attack, phase door, attack, phase door, attack, phase door, etc.. to allow you to safely bounce around the battlefield and still get attacks off.
I guess I'll need to actually playtest it to get an idea of what can be accomplished and what should be avoided.

@KorGgenT KorGgenT force-pushed the multiple-spell-fx branch 2 times, most recently from e14a600 to a3f0828 Compare June 30, 2019 16:26
@KorGgenT KorGgenT force-pushed the multiple-spell-fx branch 2 times, most recently from 315b3e7 to fa3c360 Compare July 2, 2019 15:10
src/magic.cpp Outdated Show resolved Hide resolved
@KorGgenT KorGgenT force-pushed the multiple-spell-fx branch from 8d7e1da to 54b5e0b Compare July 3, 2019 20:50
src/magic.cpp Outdated Show resolved Hide resolved
@KorGgenT KorGgenT force-pushed the multiple-spell-fx branch from adb1eaa to 85efd10 Compare July 4, 2019 17:59
@KorGgenT KorGgenT force-pushed the multiple-spell-fx branch from 97a1940 to 898e4a7 Compare July 5, 2019 20:16
@kevingranade kevingranade merged commit 1090ed6 into CleverRaven:master Jul 6, 2019
@KorGgenT KorGgenT deleted the multiple-spell-fx branch August 13, 2020 04:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[C++] Changes (can be) made in C++. Previously named `Code` Items / Item Actions / Item Qualities Items and how they work and interact [JSON] Changes (can be) made in JSON Mods: Magiclysm Anything to do with the Magiclysm mod Mods Issues related to mods or modding Spawn Creatures, items, vehicles, locations appearing on map
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants