New Spells >> show them off here
Re: New Spells >> show them off here
I think you might need to use the onAttack party hook to run a script that checks if the weapon being used is the one associated with the spell (I used a similar one for my return axe script). If that is true, then you would run the script grimwold_spell_script.pushbackSpell(caster,x,y,direction,skill) but you'd need a way to find who the 'caster' (i.e. weapon user) is, their co-ordinates, direction and what 'skill' value to use.
Puzzle Frameworks - http://www.grimrock.net/forum/viewtopic.php?f=14&t=4564
Magic Pack - https://www.nexusmods.com/grimrock/mods/70
Area of Effect Spell System - http://www.grimrock.net/forum/viewtopic ... 150#p44382
Magic Pack - https://www.nexusmods.com/grimrock/mods/70
Area of Effect Spell System - http://www.grimrock.net/forum/viewtopic ... 150#p44382
Re: New Spells >> show them off here
Ok so heres what I've got so far
In my init.lua
(the onDraw for Msyblades journal)
in a SE called attackingWeaponScripts
The spell works if cast by a mage or from an item, and it seem to be calling on the correct script when I use the Wind cutter sword I made but in this section of the spells script
Specifically local dx,dy = getForward(direction) I get the error "bad argument #1 to "getForward" number expected got nil
Any ideas on what to do here?
In my init.lua
Code: Select all
cloneObject {
name == "party",
baseObject = "party",
onDrawGui = function(ctx)
mdConversationList.onDraw(ctx)
end,
onAttack = function(champion, weapon)
return attackingWeaponScripts.specialWeaponAttacks(champion, weapon, skill)
end,
}
in a SE called attackingWeaponScripts
Code: Select all
function specialWeaponAttacks(champion, weapon, skill)
if (weapon ~= nil) and (weapon.name == "dm_wind_sword") then
return attackingWeaponScripts.burstSpellAttacks(champion,weapon,skill)
end
return true end
function burstSpellAttacks(champion, weapon, skill)
if (weapon ~= nil) and (weapon.name == "dm_wind_sword") then
if party.facing == 0 then
local skill = champion:getSkillLevel("swords")
caster = champion
pushback_spell_script.pushbackSpell(caster,x,y,direction,skill)
end
if party.facing == 1 then
local skill = champion:getSkillLevel("swords")
caster = champion
pushback_spell_script.pushbackSpell(caster,x,y,direction,skill)
end
if party.facing == 2 then
local skill = champion:getSkillLevel("swords")
caster = champion
pushback_spell_script.pushbackSpell(caster,x,y,direction,skill)
end
if party.facing == 3 then
local skill = champion:getSkillLevel("swords")
caster = champion
pushback_spell_script.pushbackSpell(caster,x,y,direction,skill)
end
end
end
Code: Select all
function pushbackSpell(caster,x,y,direction,skill)
local dx,dy = getForward(direction)
if monsterThere(party.level,x+dx,y+dy)
then
-- hudPrint("Monster!")
if isValidTarget(party.level,x+2*dx,y+2*dy)
then
hudPrint("PUSH!!!!")
spawn("fx", party.level, x+dx, y+dy, direction, "push_smoke")
:setParticleSystem("push_spell")
:translate(0, 0.5, 0)
playSoundAt("fireball_launch",party.level,x+dx,y+dy)
spawn("teleporter", party.level, x+dx,y+dy,direction, "push_teleport")
:setTeleportTarget(x+2*dx,y+2*dy, direction)
:setTriggeredByParty(false)
:setTriggeredByMonster(true)
:setTriggeredByItem(false)
:setChangeFacing(true)
:setInvisible(true)
:setSilent(true)
:setHideLight(true)
:setScreenFlash(false)
spawn("timer",party.level,x,y,direction,"push_timer")
:setTimerInterval(0.1)
:addConnector("activate", "pushback_spell_script", "pushDestroy")
:activate()
else
hudPrint("The spell fails because there is something in the way.")
end
else
hudPrint("The spell fails because there is no monster to push")
end
end
Any ideas on what to do here?
My Dungeons
Paths of the Earth: viewtopic.php?f=14&t=5136
Beneath the Sands: viewtopic.php?f=14&t=5216
Videos: viewtopic.php?f=11&t=5443
Paths of the Earth: viewtopic.php?f=14&t=5136
Beneath the Sands: viewtopic.php?f=14&t=5216
Videos: viewtopic.php?f=11&t=5443
Re: New Spells >> show them off here
In your burstSpellAttacks script you will need to define x,y and direction to pass to the pushback script. I think this normally comes from the onCast hook. It's been a long time since I wrote lua script, but I think there's a way to determine the party's co-ords... such as party.x party.y and party.facing.LocalFire wrote:Any ideas on what to do here?
so you would write something like:
Code: Select all
pushback_spell_script.pushbackSpell(caster,party.x,party.y,party.facing,skill)
Puzzle Frameworks - http://www.grimrock.net/forum/viewtopic.php?f=14&t=4564
Magic Pack - https://www.nexusmods.com/grimrock/mods/70
Area of Effect Spell System - http://www.grimrock.net/forum/viewtopic ... 150#p44382
Magic Pack - https://www.nexusmods.com/grimrock/mods/70
Area of Effect Spell System - http://www.grimrock.net/forum/viewtopic ... 150#p44382
Re: New Spells >> show them off here
Yes thats it, Many thanks!
My Dungeons
Paths of the Earth: viewtopic.php?f=14&t=5136
Beneath the Sands: viewtopic.php?f=14&t=5216
Videos: viewtopic.php?f=11&t=5443
Paths of the Earth: viewtopic.php?f=14&t=5136
Beneath the Sands: viewtopic.php?f=14&t=5216
Videos: viewtopic.php?f=11&t=5443
- Chimera005ao
- Posts: 187
- Joined: Sun Jun 29, 2014 8:34 am
Re: New Spells >> show them off here
Hello, got Grimrock recently due to the summer sale on steam.
First spell I made.
It teleports the party in the direction you are facing, two spaces forward or as far as you can go before going into a wall.
Note: Currently allows teleportation into monsters, and other non-wall objects. Can be used to jump over single square pits.
First spell I made.
It teleports the party in the direction you are facing, two spaces forward or as far as you can go before going into a wall.
Note: Currently allows teleportation into monsters, and other non-wall objects. Can be used to jump over single square pits.
Code: Select all
defineSpell{
name = "leap",
uiName = "leap",
skill = "fire",
level = 0,
runes = "F",
manaCost = 0,
onCast = function(caster, x, y, direction, skill)
local target_y = party.y
local target_x = party.x
if direction == 0 then
if not isWall(party.level, party.x, party.y - 1) then
target_y = party.y - 1
if not isWall(party.level, party.x, party.y - 2) then
target_y = party.y - 2
end
end
elseif direction == 1 then
if not isWall(party.level, party.x + 1, party.y) then
target_x = party.x + 1
if not isWall(party.level, party.x + 2, party.y) then
target_x = party.x + 2
end
end
elseif direction == 2 then
if not isWall(party.level, party.x, party.y + 1) then
target_y = party.y + 1
if not isWall(party.level, party.x, party.y + 2) then
target_y = party.y + 2
end
end
elseif direction == 3 then
if not isWall(party.level, party.x - 1, party.y) then
target_x = party.x - 1
if not isWall(party.level, party.x - 2, party.y) then
target_x = party.x - 2
end
end
end
party:setPosition(target_x, target_y, direction, party.level)
end
}
Re: New Spells >> show them off here
For some reason it says "attempt to call global 'defineSpell' (a nil value)" and i don't know how to fix it. could anyone help?
Re: New Spells >> show them off here
Definitions do not get placed in script_entities on the map. These are put in the init.lua script, in the scripts folder of your mod. Here they get loaded first, and create/define the various objects available to the user scripts.zzaxe wrote:For some reason it says "attempt to call global 'defineSpell' (a nil value)" and i don't know how to fix it. could anyone help?
Re: New Spells >> show them off here
Blichew wrote: ↑Fri Oct 05, 2012 10:01 pm Fan of Knives
Credits go to JohnWordsworth who had a problem with this one
spellcraft level and/or mana cost need to be adjustedSpoilerShowCode: Select all
defineSpell{ name = "knives", uiName = "Fan of Knives", skill = "spellcraft", level = 1, runes = "AC", manaCost = 5, onCast = function(champ, x, y, direction, skill) local dx,dy = getForward(party.facing) local x,y = party.x + dx, party.y + dy if party.facing == 0 or party.facing == 2 then for modif = -0.5,0.5,0.1 do shootProjectile("throwing_knife", party.level, x+modif, y, party.facing, 12+(modif*2), 1.5, 1, 0, 0, 0, 1, false, true) end else for modif = -0.5,0.5,0.1 do shootProjectile("throwing_knife", party.level, x, y+modif, party.facing, 12+(modif*2), 1.5, 1, 0, 0, 0, 1, false, true) end end end }
What if you just wanted a spell to shoot one projectile like a throwing axe that disappears afterwards? Can this be done?
Never mind I worked it out, I played around with the modif numbers.