Catchable tiny_rats

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!
User avatar
JKos
Posts: 464
Joined: Wed Sep 12, 2012 10:03 pm
Location: Finland
Contact:

Catchable tiny_rats

Post by JKos »

Just wanted to share this. This simple object definition makes tiny_rat-entities catchable by mouse click.

Code: Select all

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.
- LoG Framework 2http://sites.google.com/site/jkoslog2 Define hooks in runtime by entity.name or entity.id + multiple hooks support.
- cloneObject viewtopic.php?f=22&t=8450
NutJob
Posts: 426
Joined: Sun Oct 19, 2014 6:35 pm

Re: Catchable tiny_rats

Post by NutJob »

I agree, I can't wait to make Rope go UP! =)
User avatar
cromcrom
Posts: 549
Joined: Tue Sep 11, 2012 7:16 am
Location: Chateauroux in a socialist s#!$*&% formerly known as "France"

Re: Catchable tiny_rats

Post by cromcrom »

Thanks for sharing, it's great ^^
A trip of a thousand leagues starts with a step.
User avatar
JKos
Posts: 464
Joined: Wed Sep 12, 2012 10:03 pm
Location: Finland
Contact:

Re: Catchable tiny_rats

Post by JKos »

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.
- LoG Framework 2http://sites.google.com/site/jkoslog2 Define hooks in runtime by entity.name or entity.id + multiple hooks support.
- cloneObject viewtopic.php?f=22&t=8450
User avatar
Drakkan
Posts: 1318
Joined: Mon Dec 31, 2012 12:25 am

Re: Catchable tiny_rats

Post by Drakkan »

wonderfull ! thanks for sharing :D
Breath from the unpromising waters.
Eye of the Atlantis
User avatar
Skuggasveinn
Posts: 561
Joined: Wed Sep 26, 2012 5:28 pm

Re: Catchable tiny_rats

Post by Skuggasveinn »

This is good :D
Link to all my LoG 2 assets on Nexus.
Link to all my LoG 1 assets on Nexus.
User avatar
cromcrom
Posts: 549
Joined: Tue Sep 11, 2012 7:16 am
Location: Chateauroux in a socialist s#!$*&% formerly known as "France"

Re: Catchable tiny_rats

Post by cromcrom »

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)...
A trip of a thousand leagues starts with a step.
NutJob
Posts: 426
Joined: Sun Oct 19, 2014 6:35 pm

Re: Catchable tiny_rats

Post by NutJob »

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.
User avatar
cromcrom
Posts: 549
Joined: Tue Sep 11, 2012 7:16 am
Location: Chateauroux in a socialist s#!$*&% formerly known as "France"

Re: Catchable tiny_rats

Post by cromcrom »

So did I , with something like that

Code: Select all

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
but that getStat doesn't seem to work anymore...
A trip of a thousand leagues starts with a step.
User avatar
cromcrom
Posts: 549
Joined: Tue Sep 11, 2012 7:16 am
Location: Chateauroux in a socialist s#!$*&% formerly known as "France"

Re: Catchable tiny_rats

Post by cromcrom »

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...

Code: Select all

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
   }
  }
 }
A trip of a thousand leagues starts with a step.
Post Reply