Page 3 of 10
Re: [SCRIPT] [WIP] Extended Spells (Spinners, Hooks...)
Posted: Tue Dec 11, 2012 12:47 am
by Diarmuid
Ok, quick update:
Fixed the properties system. Now, you can set a property dynamically and call it subsequently. An onPass hook can for example do:
Code: Select all
if exsp.sd[sId].customproperty == nil
exsp.sd[sId].customproperty = "Abracadabra"
end
and then this custom property will be accessible from anywhere in all hooks for the whole spell path, including any spinners respawns.
I've also added sd[sId].distance, which returns the distance travelled by the spell since its launch (spinned spells keep on counting), and sd[sId].spell, which registers the original spell (for noLaunch purposes).
The following code, for example, creates a fireball which will split (launch side fireballs) every 3 squares. The spell power will also decrease by 3 each square. The splitted fireballs will split themselves again, until the power runs dry:
Code: Select all
exsp.cloneSpell('splitfireball',{
baseSpell = 'fireball'
}
)
exsp.addSpellHook('splitfireball',{
onPass = function(sId)
if exsp.sd[sId].power == nil then
exsp.sd[sId].power = 30
end
exsp.sd[sId].power = exsp.sd[sId].power - 3
if exsp.sd[sId].power < 1 then
exsp.spellDestroy(sId)
return false
end
if exsp.sd[sId].distance%3 == 0 then
local level, x, y = exsp.getPosition(sId)
exsp.spellCast('splitfireball', level, x, y, (exsp.sd[sId].facing-1)%4, exsp.sd[sId].power, exsp.sd[sId].ordinal)
exsp.spellCast('splitfireball', level, x, y, (exsp.sd[sId].facing+1)%4, exsp.sd[sId].power, exsp.sd[sId].ordinal)
end
end
}
)
I'll start setting up a proper documentation pdf, as this is getting complicated.
Flatline, I've added esxp.allSpellsAt(level, x, y), which returns an iterator of all spells currently flying in a current square. Using exsp.sd[sId], you can then access their properties. All this works for spells though, not arrows. I'm not sure if projectiles can be detected in-flight.
All in all, I think the basic script structure is quite allright and bug-free now, I'll stop updating it 3 times a day and work on further hooks and functions for a while, then post a 1.3 update in a week or so. (And maybe continue my dungeon mod as well!
)
Re: [SCRIPT] Extended Spells Framework (Spinners, Hooks...)
Posted: Tue Dec 18, 2012 10:51 pm
by Diarmuid
Hello!
So after about 2 weeks of doing this full time and getting behind in my other work (not to mention my dungeon...) here's the first release of my completed exsp framework! Check first post...
I've tested this a lot while writing all the examples from the documentation, but there's a lot of code and I've probably missed somehting somewhere... All feedback will be super appreciated, and tell me what you think too!
I'll be developping some more spell plugins in the coming days to show how this works.
EDIT: Fixed a mini last-minute bug. If you downloaded this in the first 30 min of posting, please redownload, sorry.
Re: [SCRIPT] Extended Spells Framework Completed
Posted: Wed Dec 19, 2012 12:07 am
by JKos
Wow, looks really great. Love the chain lightning.
But the installation will be easier with the newest version of my framework because it includes grimq and it is loaded automatically.
Also custom cloned assets should be included after the framework.lua, otherwise dynamic hooks won't work with them, but you don't have to add them to lists.
Compeletely new assets made by defineObject are not supported atm. So you have to add them to the lists in fw.lua, but I'm working on a some kind of solution for it.
Re: [SCRIPT] Extended Spells Framework v1.3.1
Posted: Wed Dec 19, 2012 6:18 pm
by Diarmuid
Great, I'll update documentation when the new version of the framework is out, and also when we get the final 1.3.6 editor release.
I've put up a new spell in the first post. Elemental Storm is a spell that randomly changes elemental state every tile, and explodes with different area of effect shapes on impact.
While testing Elemental Storm, I found another bug or two I missed yesterday, some code leftovers from last minute changes to hook detection. I've fixed them, along with some typos in the documentation, v 1.3.1 is up.
Now, I'd love some critique from people in the forum about this. Do you think the hooks make sense? Would you have requests/suggestion for other useful hooks? Other arguments? Other spell utility functions?
Re: [EXSP] Extended Spells Framework v1.3.2
Posted: Sun Dec 23, 2012 10:40 am
by Diarmuid
Hello! Framework is finally updated to 1.3.2, changelog:
- Exsp is now compatible with Grimrock 1.3.6 update:
-Walls are properly detected using new isWall() function.
-The onHit hook has been entierly rewritten using the new .class property. It is now a general purpose hook used for detecting any object: doors, levers, buttons, alcoves… onDoorHit has been deprecated, but still supported for backwards compatibility.
- When using defineRangedAttack(), monster attack power is now properly incremented using new mosnter:getLevel() method.
- Simplified syntax for exsp.spellCast. It now accepts the caster object and calculates the ordinal itself, and the power argument is last to allow it to be optional (you can still supply power and ordinal in the previous syntax for backwards compatibility). So you should now write exsp.spellCast("fireball", caster, 30) or simply exsp.spellCast("fireball", caster) instead of exsp.spellCast("fireball", 30, caster:getOrdinal()).
- The hook detection and execution code has been drastically optimized. It's faster and more reliable.
- Monster Groups are properly detected and hooks return all individual monster entities (this one was tricky to get working).
- Spell is properly detected when cast while party is moving between two tiles.
- New getCollisionAhead helper function (can be used for spells, party, monsters, arrows…)
- Reorganized the order of code execution in exspCore() to avoid some rare crashes.
- Updated setup instructions following Jkos LoG framework latest update, which makes installation easier.
Re: [EXSP] Extended Spells Framework v1.3.2
Posted: Sun Dec 23, 2012 10:28 pm
by JKos
I'm amazed how much effort you have put to this and in a such short time, all those scripts and documentation ( 30 pages, whoah!). I have installed it and tested some basic functionality, looking really great so far.
There is so much stuff in this that I (and probably others too) need some time to digest it.
Re: [EXSP] Extended Spells Framework v1.3.3
Posted: Mon Dec 31, 2012 6:55 pm
by Diarmuid
Ok, here's another minor update, fixing a bug and adding support for burst spells, and a practical new defineAttack function:
Exsp version 1.3.3
•
New: Exsp now supports properly burst spells. So default spells like Fireburst or Shockburst return onCast and onHit hooks. You can thus clone them, or define custom spells using the burst = true property. You can also use the new defineAttack() to add spells as melee attacks to custom monsters.
•
New: Exsp now properly supports Ice Shards for monsters and party. It will return onCast and onHit hooks – if cast by the party and there are multiple monsters in the tiles ahead, Ice Shards will return multiple onHit hooks. Note that for Ice Shards, onHit only reacts on monsters or party (not doors, walls, etc.) You can only clone Ice Shards however, you cannot define a new spell using the effect.
•
Improved: Code was further optimized, and a new helper function, exsp.delay() is provided to delay easily the execution of a function.¬
•
Fixed: The piercing = true property was broken in v1.3.2, now working again.
The defineAttack(name, attackPower, attackPowerIncrement, frontAttack, [sideAttack], [replaceAttack]) function sets automatically spell melee attacks for custom monsters, with an option to replace the normal attack or add the spell to it. The following for example makes Ice Lizards cast Ice Shards as a front attack and Shockburst as a side attack, and their normal bite won't do damage anymore. There's nothing else to put anywhere, and it calculates everything for spawning spells in the right direction on the right tile:
Code: Select all
defineAttack("ice_lizard", 40, 8, "ice_shards”, “shockburst”, true)
EDIT: Coming next: I plan to adapt some spell packs made by others and add more helper functions to facilitate spell scripting in v1.3.4, and then add projectiles support for 1.4. (The whole model for spells can also work for projectiles, so we'll be able to have arrows change direction in flight, splitting arrows, arrows that turn to spells or vice versa, arrows bouncing off walls, etc.)
Re: [EXSP] Extended Spells Framework v1.3.3
Posted: Fri Jan 04, 2013 5:19 am
by undeaddemon
Any chance I can beg for some "hand holding" getting this working?
I do have the
LoG Framework installed correctly, as the "test" works (at least):
Code: Select all
fw.setHook('party.test.onMove',
function(party,dir)
print('Party is moving to direction: '..dir)
end
)
I am primarily just wanting to get the "wandering lights" working, and while I can get it spawning, the lights are not avoiding blockers and wall, etc.
Thanks!
UD
Re: [EXSP] Extended Spells Framework v1.3.3
Posted: Fri Jan 04, 2013 6:50 am
by Diarmuid
Well of course, I'm here for support!
OK, I've just tested it with the 1.3.3 release in an fresh dungeon with only the framework and exsp and it works here, so lets figure it out.
Checklist:
You've added exsp_loadSpell('exsp_wandering_lights') to exsp_init.lua?
You've copied over the code from exsp.lua to a script_entity named exsp in the dungeon?
You've created a spawner object in the dungeon?
You're using exsp_wandering_lights.spawnLight(spawner, room, maxLights, [power]) to spawn the lights?
In my test dungeon, I put the following code in a script entity and put a pressure plate in the middle of the room to activate it, and got a light each time I stepped on the plate, up to 5. How are you triggering your spawn?
Code: Select all
function test()
exsp_wandering_lights.spawnLight("spawner_1", "room1", 5)
end
If nothing seems to work, you can always zip your whole dungeon folder (mod_assets and .editor file), and send it to me so I can check what's wrong.
Oh and by the way, version 1.4 I'm working on will auto install itself, it'll be a lot simpler to use and reduce potential errors.
Re: [EXSP] Extended Spells Framework v1.3.3
Posted: Fri Jan 04, 2013 7:20 am
by undeaddemon
So...
Checklist:
yes
yes
yes - this is just the regular spawner I would use everywhere else - here I named spawner_wl
so.. i created this:
Code: Select all
function wandering_lights_1()
exsp_wandering_lights.spawnLight("spawner_wl", "room1", 5)
end
And I have a pressure plate that "connects" to that script, but it doesn't find the action... ??