Page 2 of 2
Re: Question on Falling Damage
Posted: Thu Feb 13, 2014 11:57 am
by JohnWordsworth
I don't know if the party 'onDamage' hook is called for falling damage. If it is, you could write a script that...
1. Detects when the player steps on a pit and sets a flag in a script entity.
2. In onDamage you check if the flag is set, if it is, clear the flag and return false.
If onDamage isn't called, this clearly won't work :p
Re: Question on Falling Damage
Posted: Thu Feb 13, 2014 12:01 pm
by Eightball
Thanks! That new script with the local bit worked! Wow, quick response. I suppose I should email AH again and tell them not to worry bout the bug.
Re: Question on Falling Damage
Posted: Thu Feb 13, 2014 1:20 pm
by JohnWordsworth
This is a rough (first draft) solution that allows you to become immune to pit damage without having to place any pressure plates on the pits or anything manual like that. Just set 'pitImmunity.enabled = true' and the party becomes completely immune to pit falling damage until you set 'pitImmunity.enabled=false'.
Add this script to your dungeon...
Code: Select all
-------------------------------------------------------
-- Pit Immunity Script
-------------------------------------------------------
-- This script should be placed in a script entity
-- called 'pitImmunity'.
--
-- To make the party immune to pit damage you just
-- need call 'pitImmunity.enabled = true' in another
-- script. To disable it, call pitImmunity.enabled=false.
--
-- For this to work, you will need to hook
-- onMove and onDamage into your party script.
-------------------------------------------------------
enabled = true;
ignoreDamageCount = 0;
function getEnabledChampionCount()
local enabledChamps = 0;
for i=1,4 do
local champ = party:getChampion(i);
if ( champ:getEnabled() ) then
enabledChamps = enabledChamps + 1;
end
end
return enabledChamps;
end
function onMove(self, party, direction)
if ( enabled ~= true ) then
return;
end
local dx, dy = getForward(direction);
local x, y = party.x + dx, party.y + dy;
for e in entitiesAt(party.level, x, y) do
if ( e.class == "Pit" ) then
ignoreDamageCount = getEnabledChampionCount();
end
end
end
function onDamage(self, champion, damAmount, damType)
if ( enabled ~= true ) then
return false;
end
if ( ignoreDamageCount > 0 and damType == 'physical' ) then
ignoreDamageCount = ignoreDamageCount - 1;
return false;
end
end
Party hooks for your mod's init.lua script (this will work as is, but if you have other onMove or onDamage hooks you will need to merge them.
Code: Select all
cloneObject{
name = "party",
baseObject = "party",
onMove = function(party, direction)
pitImmunity:onMove(party,direction);
end,
onDamage = function(champion, damAmount, damType)
return pitImmunity:onDamage(champion, damAmount, damType);
end
}
Note that this script works by scanning the upcoming square on every move. If the square has an open pit, then we say "ignore the next N physical damage calls" where N is the number of enabled party members. It's minutely possible that the party takes a hit from a monster between walking forward and falling down the pit - in this case, it won't work as expected. However, this seems pretty unlikely, as the damage would have to be physical, and would have to occur during the step onto the pit. A solution to get around this would be more complicated, and I wasn't intending on spending more than 10-15 minutes this morning prototyping a solution :p.
Re: Question on Falling Damage
Posted: Wed Jul 15, 2015 11:42 pm
by trancelistic
I have an question. Is a damage tile ( I can't get it to work anyhows in my MOD) possible to target only 3 champions? So only 1 will survive?.
I was kinda thinking of setting 3 champs health at zero, so they die? But will this work and if yes, how to set this?.
I kinda need this for an event in my dungeon.
note: Log1. Not LoG2
Re: Question on Falling Damage
Posted: Thu Jul 16, 2015 12:04 am
by minmay
easiest way is to use Champion:damage([amount],"physical")
http://www.grimrock.net/modding_log1/sc ... reference/
Re: Question on Falling Damage
Posted: Thu Jul 16, 2015 2:57 am
by trancelistic
Thanks Minway. I've tried exampels from the forum like
Code: Select all
armed = true
function setTrap(set)
if set then
armed = true
else armed = false
end
end
function trap(t)
if armed and t.x ~= nil then
damageTile(t.level, t.x, t.y, 0, 64 , "poison", 1)
local screamer = math.random(3)
party:getChampion(screamer):playDamageSound()
party:getChampion(screamer+1):playDamageSound()
end
end
They dont work. even if set fire or poison to 100 dmg. There is nothing happening.. ( no crash also, nor error code)
However I've I make a new dungeon/mod. Past this code in the new project it does work.
But in my real dungeon it refuse it... I don't know why...In a new project with only 1 level.. so the start. It works....
Re: Question on Falling Damage
Posted: Thu Jul 30, 2015 10:05 pm
by trancelistic
trancelistic wrote:
Thanks Minway. I've tried exampels from the forum like
Code: Select all
armed = true
function setTrap(set)
if set then
armed = true
else armed = false
end
end
function trap(t)
if armed and t.x ~= nil then
damageTile(t.level, t.x, t.y, 0, 64 , "poison", 1)
local screamer = math.random(3)
party:getChampion(screamer):playDamageSound()
party:getChampion(screamer+1):playDamageSound()
end
end
They dont work. even if set fire or poison to 100 dmg. There is nothing happening.. ( no crash also, nor error code)
However I've I make a new dungeon/mod. Past this code in the new project it does work.
But in my real dungeon it refuse it... I don't know why...In a new project with only 1 level.. so the start. It works....
Nevermind I worked on a work arround. It works now. I didn't used any of this code above.
THis script is just easy, about a few lines. It works now what I was planning to do,
Thanks anyhows<3