1. Create a script_entity in your dungeon and call it "super_weapon_script." Place the following Code within it:
SpoilerShow
lastWeaponUsed = "none"
function getLastWeaponUsed()
return lastWeaponUsed
end
function setLastWeaponUsed(sender, theWeapon)
lastWeaponUsed = theWeapon.name
end
function getLastWeaponUsed()
return lastWeaponUsed
end
function setLastWeaponUsed(sender, theWeapon)
lastWeaponUsed = theWeapon.name
end
SpoilerShow
cloneObject{
name = "spiders_bane",
skill = "daggers",
requiredLevel = 2,
uiName = "Spider's Bane",
resistPoison = 30,
coolDownTime = 2,
attackSwipe = "horizontal",
baseObject = "assassin_dagger",
impactSound = "impact_blade",
attackPower = 15,
attackMethod = "meleeAttack",
damageType = "physical",
gameEffect = "*Arachnids*",
description = "This dagger is especially effective against spiders",
onUse = function()
hudPrint("take that!");
end,
}
name = "spiders_bane",
skill = "daggers",
requiredLevel = 2,
uiName = "Spider's Bane",
resistPoison = 30,
coolDownTime = 2,
attackSwipe = "horizontal",
baseObject = "assassin_dagger",
impactSound = "impact_blade",
attackPower = 15,
attackMethod = "meleeAttack",
damageType = "physical",
gameEffect = "*Arachnids*",
description = "This dagger is especially effective against spiders",
onUse = function()
hudPrint("take that!");
end,
}
SpoilerShow
cloneObject{
name = "party",
baseObject = "party",
onAttack = function(champion, weapon)
local super_weapon_script = findEntity("super_weapon_script")
if super_weapon_script then
super_weapon_script:setLastWeaponUsed(weapon)
end
return true
end,
}
name = "party",
baseObject = "party",
onAttack = function(champion, weapon)
local super_weapon_script = findEntity("super_weapon_script")
if super_weapon_script then
super_weapon_script:setLastWeaponUsed(weapon)
end
return true
end,
}
SpoilerShow
cloneObject{
name = "my_spider",
baseObject = "spider",
health = 30,
immunities = { "poison" },
onDamage = function(monster, amount, damageType)
if damageType == "physical" then
local super_weapon_script = findEntity("super_weapon_script")
if super_weapon_script then
local spiders_bane = "spiders_bane"
if super_weapon_script:getLastWeaponUsed() == spiders_bane then
monster:setHealth(0)
end
end
end
return true
end,
}
name = "my_spider",
baseObject = "spider",
health = 30,
immunities = { "poison" },
onDamage = function(monster, amount, damageType)
if damageType == "physical" then
local super_weapon_script = findEntity("super_weapon_script")
if super_weapon_script then
local spiders_bane = "spiders_bane"
if super_weapon_script:getLastWeaponUsed() == spiders_bane then
monster:setHealth(0)
end
end
end
return true
end,
}
That's pretty much it. So to recap what happens, your party registers the last weapon used and stores its name into the super_weapon_script. Then the monster checks to see if the super_weapon_script exists if he gets hit, and if he was hit by the super_weapon, his health is set to 0.
Comments welcome.