[Mod] Instant Kill Weapons for Certain Monsters

Talk about creating Grimrock 1 levels and mods here. Warning: forum contains spoilers!
Post Reply
User avatar
pferguso
Posts: 40
Joined: Tue Nov 06, 2012 6:09 pm

[Mod] Instant Kill Weapons for Certain Monsters

Post by pferguso »

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:
SpoilerShow
lastWeaponUsed = "none"
function getLastWeaponUsed()
return lastWeaponUsed
end
function setLastWeaponUsed(sender, theWeapon)
lastWeaponUsed = theWeapon.name
end
2. Create a cloneObject of the weapon that you would like to use as a super weapon, and put it in your items.lua
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,
}
3. Create a custom_party.lua script and place the following code in it: Make sure you include this file in your init.lua:
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,

}
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:
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,
}

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.
User avatar
msyblade
Posts: 792
Joined: Fri Oct 12, 2012 4:40 am
Location: New Mexico, USA
Contact:

Re: [Mod] Instant Kill Weapons for Certain Monsters

Post by msyblade »

I could see this leading to blunt/slash resistance, thrown/missile immunity, etc. Thank you!
Currently conspiring with many modders on the "Legends of the Northern Realms"project.

"You have been captured by a psychopathic diety who needs a new plaything to torture."
Hotel Hades
User avatar
Kuningas
Posts: 268
Joined: Wed Apr 11, 2012 10:29 pm
Location: Northern Finland

Re: [Mod] Instant Kill Weapons for Certain Monsters

Post by Kuningas »

SetHealth to zero actually results in an invulnerable monster, I think, but you should be able to handle that with a damage function. I'm not entirely sure, so don't fix it if it isn't broken.

And I very much like the idea! (especially regarding spiders -- I'm no arachnophobe, but damn those things, just damn ; D)
BASILEUS
User avatar
Komag
Posts: 3658
Joined: Sat Jul 28, 2012 4:55 pm
Location: Boston, USA

Re: [Mod] Instant Kill Weapons for Certain Monsters

Post by Komag »

Yeah, you would need to do a damage tile, not set health, but that shouldn't be too difficult. Nice script :)
Finished Dungeons - complete mods to play
User avatar
akroma222
Posts: 1029
Joined: Thu Oct 04, 2012 10:08 am

Re: [Mod] Instant Kill Weapons for Certain Monsters

Post by akroma222 »

Very interesting! :D
User avatar
pferguso
Posts: 40
Joined: Tue Nov 06, 2012 6:09 pm

Re: [Mod] Instant Kill Weapons for Certain Monsters

Post by pferguso »

Kuningas wrote:SetHealth to zero actually results in an invulnerable monster, I think, but you should be able to handle that with a damage function. I'm not entirely sure, so don't fix it if it isn't broken.

And I very much like the idea! (especially regarding spiders -- I'm no arachnophobe, but damn those things, just damn ; D)

When I tried it, it didn't result in an invulnerable monster, but it killed it outright. But you're right, a damage tile would definitely do the trick too.
Post Reply