Page 2 of 10
Re: [SCRIPT] Fireball spinners!
Posted: Fri Dec 07, 2012 5:05 pm
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?
Re: [SCRIPT] Fireball spinners!
Posted: Fri Dec 07, 2012 5:24 pm
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?
Re: [SCRIPT] Fireball spinners!
Posted: Fri Dec 07, 2012 5:29 pm
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...
Re: [SCRIPT] Fireball spinners!
Posted: Fri Dec 07, 2012 6:06 pm
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.
Re: [SCRIPT] Fireball spinners!
Posted: Fri Dec 07, 2012 6:23 pm
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.
Re: [SCRIPT] Extended Spells (Spinners, Hooks...)
Posted: Sun Dec 09, 2012 6:29 pm
by Diarmuid
Ok guys, here's version 1.2, which took the whole idea light years ahead. Check first post!
Re: [SCRIPT] Extended Spells (Spinners, Hooks...)
Posted: Sun Dec 09, 2012 7:01 pm
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.
Re: [SCRIPT] Extended Spells (Spinners, Hooks...)
Posted: Sun Dec 09, 2012 8:01 pm
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.
Re: [SCRIPT] Extended Spells (Spinners, Hooks...)
Posted: Mon Dec 10, 2012 9:01 am
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.
Re: [SCRIPT] Extended Spells (Spinners, Hooks...)
Posted: Mon Dec 10, 2012 11:43 am
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...