Ask for help about creating mods and scripts for Grimrock 2 or share your tips, scripts, tools and assets with other modders here. Warning: forum contains spoilers!
defineObject{
name = "tiny_rat",
baseObject = "tiny_rat",
components = {
{
class="Clickable",
onClick=function(self)
local item = getMouseItem()
if item then
hudPrint("You can't catch a rat with that junk in your hand")
return
end
self.go:destroy()
setMouseItem(spawn('rat_shank').item)
end
}
}
}
This new component system gives so much possibilities.
Last edited by JKos on Sun Oct 26, 2014 7:12 pm, edited 1 time in total.
Thanks. Updated the code so that you can't catch a rat if you have something selected as a "mouseitem". Previous version was destroying the current mouseitem.
Anybody got a champion/party:getStat(dexterity) kind of stuff working ? Because in a typical "Lost continent" fashion, the player will make a dex check, get some food if he succeeds, and a tiny amount of exp if he fails. Rat will disappear in both case (to prevent exploit)...
cromcrom wrote:Anybody got a champion/party:getStat(dexterity) kind of stuff working ? Because in a typical "Lost continent" fashion, the player will make a dex check, get some food if he succeeds, and a tiny amount of exp if he fails. Rat will disappear in both case (to prevent exploit)...
Nope, I tried variations for a few hours, no luck.
function getPartyBestStat()
local finalStat = 0 ; local p = party.party;
for i = 1,4 do
c = p:getChampion(i)
if c:getEnabled() and c:isAlive() and c:getStat("dexterity") > finalStat
then finalStat = c:getStat("dexterity")
end
end
hudPrint(finalStat)
return finalStat
end
Well, I added a little randomness. Just to have things more random and interactive, again, in a typical Lost Continent way . Next improvement will ba with adding a hunting skill...
defineObject{
name = "tiny_rat",
baseObject = "tiny_rat",
components = {
{
class="Clickable",
onClick=function(self)
local item = getMouseItem()
local ratXP = 5
if item then
hudPrint("You can't catch a rat with that junk in your hand")
return
end
if math.random()<0.3 then
self.go:destroy()
setMouseItem(spawn('rat_shank').item)
hudPrint("Good Job ! Gotcha !")
else
hudPrint("Crap, missed it, better luck next time.")
self.go:destroy()
hudPrint("Aw well, at least I got"..ratXP.."XPs.")
for n=1,4 do
party.party:getChampion(n):gainExp(ratXP)
end
end
end
}
}
}