help: potion of invisibility?

Talk about creating Grimrock 1 levels and mods here. Warning: forum contains spoilers!
Post Reply
uggardian
Posts: 75
Joined: Sat May 19, 2012 5:53 pm

help: potion of invisibility?

Post by uggardian »

So I tried to make somekind of invisibility potion (later a recipe for that too), but I encountered two problems. 1) How to make the poison turn the whole party invisible? I tried to change "function(self, champion)" into function(self, party), but the editor crashed completely. 2) How to make the potion turn empty when somebody drinks it? At the moment I can use it as many times as I want, but that's not good :| .. So maybe somebody wiser than me could help me a bit? :oops:

Code: Select all

cloneObject{
uiName = "Potion of Invisibility",
name = "potion_invisibility",
baseObject = "potion_healing",
onUseItem = function(self, champion)
champion:setCondition("invisibility", 40)
end
}
User avatar
JohnWordsworth
Posts: 1397
Joined: Fri Sep 14, 2012 4:19 pm
Location: Devon, United Kingdom
Contact:

Re: help: potion of invisibility?

Post by JohnWordsworth »

Ahh, you unfortunately cannot change the function as you tried, when you define onUseItem = function(self, chamption) - you don't actually get to control what's in the parameters 'self' and 'champion', the game does that. You can however, decide what they are called. So if you put onUseItem = function(self, something), then 'something' would still point to the champion that drunk the potion, except you've given it a slightly less convenient name!

However, you can actually get information about the whole party using global functions (functions that always exist) and so your potion could work by iterating over each party slot, checking if there is a champion in that slot, and then turning that champion invisible.

Try something like the following...
SpoilerShow

Code: Select all

cloneObject {
  uiName = "Potion of Invisibility",
  name = "potion_invisibility",
  baseObject = "potion_healing",
  onUseItem = function(self, champion)
    for slot=1,4 do
      if party:getChampion(slot) ~= nil then
        party:getChampion(slot):setCondition("invisibility", 40);
      end
    end
 
    return true;
  end
}
Edit: Added return true so that the potion is replaced with an empty flask after use.
Last edited by JohnWordsworth on Wed Oct 10, 2012 9:31 pm, edited 2 times in total.
My Grimrock Projects Page with links to the Grimrock Model Toolkit, GrimFBX, Atlas Toolkit, QuickBar, NoteBook and the Oriental Weapons Pack.
uggardian
Posts: 75
Joined: Sat May 19, 2012 5:53 pm

Re: help: potion of invisibility?

Post by uggardian »

Thanks John, it worked. But I still have the other problem: The potion can be drunk unlimited times, it never changes into empty flask. How to fix that? :?:
User avatar
crisman
Posts: 305
Joined: Sat Sep 22, 2012 9:23 pm
Location: Italy

Re: help: potion of invisibility?

Post by crisman »

I think you need to add 'return true' before the very end of the function onUseItem
User avatar
JohnWordsworth
Posts: 1397
Joined: Fri Sep 14, 2012 4:19 pm
Location: Devon, United Kingdom
Contact:

Re: help: potion of invisibility?

Post by JohnWordsworth »

@crisman is correct, I'll add that to the above post!
My Grimrock Projects Page with links to the Grimrock Model Toolkit, GrimFBX, Atlas Toolkit, QuickBar, NoteBook and the Oriental Weapons Pack.
Post Reply