[EXSP] Extended Spells Framework v1.4.4

Talk about creating Grimrock 1 levels and mods here. Warning: forum contains spoilers!
Batty
Posts: 509
Joined: Sun Apr 15, 2012 7:04 pm

Re: [SCRIPT] Fireball spinners!

Post by Batty »

For party cast spells, could you cancel the spell in onCastSpell (when party facing teleporter) then spawn a spinner projectile in the same direction to replace it?
User avatar
Diarmuid
Posts: 807
Joined: Thu Nov 22, 2012 6:59 am
Location: Montreal, Canada
Contact:

Re: [SCRIPT] Fireball spinners!

Post by Diarmuid »

I've thought about that... we're almost rewriting the spell projectile system, lol. The problem is that the spell would not know the "path".

Now, it would be possible to use cloned teleporter objects with names (eg fireballspinner_90, fireballspinner_180, fireballspinner_270) and have the script calculate all the teleporters path and pathHasEnd arguments itself. Only, for this, we need to able to know if a particular square is a wall or not to stop the seeking functions. Is there a way to do this that I've missed?
Batty
Posts: 509
Joined: Sun Apr 15, 2012 7:04 pm

Re: [SCRIPT] Fireball spinners!

Post by Batty »

Diarmuid wrote:we need to able to know if a particular square is a wall or not to stop the seeking functions. Is there a way to do this that I've missed?
isWall(l, x, y) is one of the functions that'll be in the editor update, so maybe wait for that.

Or, if you can't wait, you can use the "snail probe" to detect walls, Grimwold has it posted somewhere...
User avatar
JKos
Posts: 464
Joined: Wed Sep 12, 2012 10:03 pm
Location: Finland
Contact:

Re: [SCRIPT] Fireball spinners!

Post by JKos »

My framework already has the isWall-function implemented, but I forgot to add it to documentation. You can use it like this help.isWall(x,y) It always checks walls from party.level. I should improve the documentation because there is lots of useful undocumented stuff.

Btw. this script is pretty awesome.
- LoG Framework 2http://sites.google.com/site/jkoslog2 Define hooks in runtime by entity.name or entity.id + multiple hooks support.
- cloneObject viewtopic.php?f=22&t=8450
User avatar
Diarmuid
Posts: 807
Joined: Thu Nov 22, 2012 6:59 am
Location: Montreal, Canada
Contact:

Re: [SCRIPT] Fireball spinners!

Post by Diarmuid »

Batty & Jkos, wonderful! Well... I guess I'm going to work on a 1.2 update, I wouldn't want people to set this up using one type of object and then have to redo it.

I'll keep the existing spellLaunchOnPath function, but wrap it in a launchExtendedSpell(spell,spawnerId,power) function which will seek spellspinner_x teleporter objects. If it doesn't find a spinner ahead, it will just spawn a regular spell. If it finds spinners, it will calculate the path and call spellLaunchOnPath. spawnerId will be able to be anything by the way, either party or monsters. So if you have for example a goromorg in your room with spinners, you'll be able to wrap his spells with launchExtendedSpells so that they get caught in spinners.

Give me a day or two, though.
User avatar
Diarmuid
Posts: 807
Joined: Thu Nov 22, 2012 6:59 am
Location: Montreal, Canada
Contact:

Re: [SCRIPT] Extended Spells (Spinners, Hooks...)

Post by Diarmuid »

Ok guys, here's version 1.2, which took the whole idea light years ahead. Check first post! :)
User avatar
JKos
Posts: 464
Joined: Wed Sep 12, 2012 10:03 pm
Location: Finland
Contact:

Re: [SCRIPT] Extended Spells (Spinners, Hooks...)

Post by JKos »

Looking really good, and the code looks so much cleaner now.
Btw. the isWall is not my code I copied it from some thread. I think the original author was Edsploration.
- LoG Framework 2http://sites.google.com/site/jkoslog2 Define hooks in runtime by entity.name or entity.id + multiple hooks support.
- cloneObject viewtopic.php?f=22&t=8450
User avatar
Diarmuid
Posts: 807
Joined: Thu Nov 22, 2012 6:59 am
Location: Montreal, Canada
Contact:

Re: [SCRIPT] Extended Spells (Spinners, Hooks...)

Post by Diarmuid »

Ah, thanks, I've updated the credit. I've also quickly fixed an error in the "noLaunch" system, it's updated and should work right, but if you downloaded the exsp_objects.lua, redownload it.

By the way, I got a wierd bug and it took me a lot of time to realize where it came from. I then realized that as help.isWall is spawning a monster, it will trigger any pressure plates or teleporters on the probed square. So I put a check for this, assuming people will not put pressure plates in walls. If you wish you can take the code to update your function.
Last edited by Diarmuid on Mon Dec 10, 2012 10:06 pm, edited 1 time in total.
flatline

Re: [SCRIPT] Extended Spells (Spinners, Hooks...)

Post by flatline »

Fantastic job on this, especially detecting spells in-flight. Does it actually detect them passing a square? That means I can revive my old arrow shield spell and some other plans I put on hold when I couldn't find a way to detect particles passing a square.
User avatar
Diarmuid
Posts: 807
Joined: Thu Nov 22, 2012 6:59 am
Location: Montreal, Canada
Contact:

Re: [SCRIPT] Extended Spells (Spinners, Hooks...)

Post by Diarmuid »

Ok, I've cleaned and optimized the whole code, there were leftover useless elements and redundant data as spinners were implemented differently before I set up the hooks system. Now, the spinner detection is simply a hardcoded onPass hook. A few bugfixes too.

A quick technical explanation of how the system works:

exsp.launchExtendedSpell spawns a spell, assigning it a unique spell id key (sId), then simply starts a matching timer which ticks every square. For reference, a fireball travels at 0.4s/square, a lightning bolt at 0.3s/square.

So now I can run a function each time the spell enters a new square and do something with it (like, check for spinner objects). As I also have the spell entity id, I can destroy it anytime I want. I also made a helper getPosition(sId) function which returns level, x, y to quickly see where a spell is.

As for party and monsters spells, it really catches them in flight about 0.1s after casting, for party on the party square, for monsters 1 square ahead (I'm still tweaking times for those). It keeps the original spell, but fires the tracking timer. flatline, exsp.findSpells(level, x, y) returns the id of ONE spell in a square. I realized while writing this that there might be conflicts if multiple spells are in the square ahead of a monster, so I have to update the function to return multiple results, and take those into account (TODO).

Apart from that, spells can also have extended properties set and accessed. They are indexed by spell id in the sd table (spell data). As of v1.2, the following properties are carried along:
- sd[sId].spawner : the entity id or "party" from which the spell originated
- sd[sId].facing : the direction in which the spell is travelling
- sd[sId].power : the spell power if overriden. If nil, uses defaults
- sd[sId].nextSpell : the spell to be respawned if a spinner is encountered (for noLaunch purposes)
- sd[sId].ordinal : the ordinal, if spell was cast by party, else nil

Those properties are used at spinners to respawn an identical spell.

As you see, I put in support for ordinal, but have yet to code anything with it. Right now, if you cast a fireball and it gets spinned then hits a monster, no experience is gained as the spinned fireball is a new object not coming from the party. Once I have an onMonsterHit hook working, I'll be able to put in a damageTile which uses this ordinal property. In the end, we'll probably be able to code custom spells entirely in the spell domain, without using projectiles.

All kinds of possibilities here, a few ideas: easy area of effect spells, splitting fireballs (a big fireball that launches 2 sideways smaller fireballs every 3 squares, and loses equivalent attack power till it dies; or a fireball which splits on impact), "piercing" spells which hit a monster then continue on the path until a wall...
Post Reply