Scripting: Monster only gets damaged by one special weapon
Posted: Sat May 30, 2015 1:50 am
I am trying to recreate a function, that I used in my LoG1 Mod. (discussion here.)
Aim is still to get a monster (ghost), that is immune to all attacks. Only one special weapon (vorpalblade) can deal physical damage to it.
Solution was to do this by a party-hook. Now I am trying to use this script again - but things have changed in scripting and the original thing doesn't work anymore.
What I have so far:
Problem seems to be, that it's no longer possible to check by object.class == "Monster" if the champion is attacking a monster. I have no idea what could identify a monster instead. If I comment this if-loop out, I get something to work: my ghost doesn't get damaged by any weapon - but it doesn't either get damaged by the vorpalblade. And it DOES get damaged by an unarmed attack...
Any ideas??
Aim is still to get a monster (ghost), that is immune to all attacks. Only one special weapon (vorpalblade) can deal physical damage to it.
Solution was to do this by a party-hook. Now I am trying to use this script again - but things have changed in scripting and the original thing doesn't work anymore.
What I have so far:
Code: Select all
defineObject{
name = "party",
baseObject = "party",
components = {
{
class = "Party",
onAttack = function (champion, weapon)
-- weapon efficiencies tests
-- define locals
local dx,dy = 0,0
local usedWeapon
-- manage case that attack is unarmed
if weapon == nil then usedWeapon = "unarmed"
else usedWeapon = weapon.name
end
-- get position modificators, to find cell in front of the party
if party.facing == 0 then dy = -1
elseif party.facing == 1 then dx = 1
elseif party.facing == 2 then dy = 1
elseif party.facing == 3 then dx = -1
end
-- check what is in front of the party
local checkedCell = party.map:entitiesAt(party.x + dx, party.y + dy)
-- interate through all objects on cell
for object in checkedCell do
if object.class == "Monster" then -- it will do test only for monsters
if object.name == "ghost_THOM" then
if usedWeapon == "dm_vorpalblade_THOM" then
return true -- weapons is effective, attack will by computed
else
playSound("blob_hit_receptor")
return false -- weapon is uneffective
end
end
else
return true
end
end
end,
}
}
}Any ideas??