[Mod] Instant Kill Weapons for Certain Monsters
Posted: Thu Nov 22, 2012 11:35 pm
I had an idea for acquiring weapons that will instantly kill a certain type of monster e.g "Spider Slayer", "Ogre's Bane", etc. Here is how I did it:
1. Create a script_entity in your dungeon and call it "super_weapon_script." Place the following Code within it:
2. Create a cloneObject of the weapon that you would like to use as a super weapon, and put it in your items.lua
3. Create a custom_party.lua script and place the following code in it: Make sure you include this file in your init.lua:
4. Create a monster clone of the monster that you would like to instant kill with the desired weapon. This monster clone goes in Monsters.lua:
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.
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.