Grimwold's script using teleport probes could indeed help here.. I was actually thinking of doing something very similar (SM)...
I have used a similar script to spawn teleporters in 'Valid' positions....
This script comes from Grimwolds Push Monster spell -
function monsterThere(level,eggs,why)
for i in entitiesAt(level,eggs,why) do
if isInTable(allMonstersPush,i.name)
then
return true
end
end
return false
end
function pushDestroy()
push_teleport:destroy()
push_timer:destroy()
end
function isValidTarget(L,X,Y)
spawn("spawner", L, X, Y, 0, "probe"):setSpawnedEntity("teleport_probe"):activate()
for j in entitiesAt(L,X,Y) do
if j.name == "teleport_probe" then
probe:destroy()
j:destroy()
return true
end
end
probe:destroy()
return false
end
function pushbackSpell(caster,x,y,dir,skill)
local dx,dy = getForward(dir)
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, dir, "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,dir, "push_teleport")
:setTeleportTarget(x+2*dx,y+2*dy, dir)
:setTriggeredByParty(false)
:setTriggeredByMonster(true)
:setTriggeredByItem(false)
:setChangeFacing(true)
:setInvisible(true)
:setSilent(true)
:setHideLight(true)
:setScreenFlash(false)
spawn("timer",party.level,x,y,dir,"push_timer")
:setTimerInterval(0.1)
:addConnector("activate", "grimwold_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
And this is an adaption of it for my mod...
function cavesAccess(caster,x,y,dir,skill)
local dx,dy = getForward(party.facing)
if findEntity("createdWall") ~= nil and findEntity("createdWall"):isOpen() then
if isValidCaveTarget(party.level,party.x+dx,party.y+dy,party.facing) then
spawn("fx", party.level, party.x+dx, party.y+dy, party.facing, "poisonous")
:setParticleSystem("poisonous")
:translate(0, 0.5, 0)
spawn("teleporter_green_01", party.level, party.x+dx, party.y+dy, party.facing, "teleporter_green_02")
:setTeleportTarget(12, 5, 3, 17)
:setTriggeredByParty(true)
:setTriggeredByMonster(false)
:setTriggeredByItem(true)
:setChangeFacing(true)
:setInvisible(false)
:setSilent(true)
:setHideLight(false)
:setScreenFlash(false)
:activate()
spawn("pressure_plate_hidden", party.level, party.x+dx, party.y+dy, party.facing, "teleporter_green_02_flash")
:setTriggeredByParty(true)
:setTriggeredByMonster(false)
:setTriggeredByItem(false)
:setSilent(true)
:activateOnce(false)
:addConnector("deactivate","colouredTeleportScript","FlashGreen")
else
hudPrint("The entry point fails because there is something in the way.")
end
findEntity("cavestimer"):destroy()
end
end
function isValidCaveTarget(L,X,Y)
spawn("spawner", L, X, Y, 0, "probe"):setSpawnedEntity("teleport_probe"):activate()
for j in entitiesAt(L,X,Y) do
if j.name == "teleport_probe" then
probe:destroy()
j:destroy()
return true
end
end
probe:destroy()
return false
end
I guess the important part here to start with would be
if isValidCaveTarget(party.level,party.x+dx,party.y+dy,party.facing) then
spawn("fx", party.level, party.x+dx, party.y+dy, party.facing, "poisonous")
...swapping 'monster' in for 'party' of course....
I will prolly have a red hot go at this soon, I will get back to you if/when I come up with a solution
