Using/Consuming a potion?

Talk about creating Grimrock 1 levels and mods here. Warning: forum contains spoilers!
SpacialKatana
Posts: 163
Joined: Fri Sep 14, 2012 6:20 pm

Using/Consuming a potion?

Post by SpacialKatana »

I need a helpful nudge. I've defined a recipe and item for a greater heal potion but I'm a bit stuck being able to make the champion use it. I know I have to use the onUseItem hook in the item's def, but I'm not sure of the syntax and command to heal...

onUseItem = function...
heal =100
end

???Help
User avatar
Xaxus
Posts: 24
Joined: Mon Sep 17, 2012 4:54 am

Re: Using/Consuming a potion?

Post by Xaxus »

I'm fairly confident you can use cloneObject and just set the healing value, ID and item name different to produce a simpler potion.
SpacialKatana
Posts: 163
Joined: Fri Sep 14, 2012 6:20 pm

Re: Using/Consuming a potion?

Post by SpacialKatana »

Been trying to...the item is cloned from the "potion_healing" item, but when right clicking nothing happens. it even says right click to use in the tool tip that comes up ingame.
I'm also not 100% sure what the healing command is either>.<

I'm prolly just being dumb...it's 5am here :o
SpacialKatana
Posts: 163
Joined: Fri Sep 14, 2012 6:20 pm

Re: Using/Consuming a potion?

Post by SpacialKatana »

Friendly bump..it's holding back custom crafting for my mod. Thanks
User avatar
Shroom
Posts: 98
Joined: Tue Mar 27, 2012 6:37 pm
Location: UK

Re: Using/Consuming a potion?

Post by Shroom »

SpacialKatana wrote:Friendly bump..it's holding back custom crafting for my mod. Thanks
Can you show your cloned object? Have you added a onUseItem hook?

From http://www.grimrock.net/modding/asset-d ... reference/
onUseItem: a hook which is called when the item is used (e.g. by right-clicking on it). The function gets two parameters: the item used and the champion who used the item. If the function returns true, the item is consumed when it is used.
SpacialKatana
Posts: 163
Joined: Fri Sep 14, 2012 6:20 pm

Re: Using/Consuming a potion?

Post by SpacialKatana »

Here you go Shroom...it doesn't break the game, but it don't work either :?

Code: Select all

cloneObject{
        name = "potion_healing_greater",
        baseObject = "potion_healing",
        uiName = "Greater Healing Potion",
        description = "A Bernard strength healing potion",
        consumable = true,
        onUseItem = function(self,champion)
            heal = 100
        end
User avatar
Shroom
Posts: 98
Joined: Tue Mar 27, 2012 6:37 pm
Location: UK

Re: Using/Consuming a potion?

Post by Shroom »

I dont know about heal = 100

I havent played with items much, but could you use champion:modifyStat("health", 100)?

Edit: - changed self to champion
SpacialKatana
Posts: 163
Joined: Fri Sep 14, 2012 6:20 pm

Re: Using/Consuming a potion?

Post by SpacialKatana »

The hook says it needs 2 parameters, the item and the user so maybe I'll try :-

onUseItem = function(self,champion:modifyStat("health", 100))
end

Edit Hmm still no dice..editor didn't like that line lol
User avatar
Shroom
Posts: 98
Joined: Tue Mar 27, 2012 6:37 pm
Location: UK

Re: Using/Consuming a potion?

Post by Shroom »

SpacialKatana wrote:The hook says it needs 2 parameters, the item and the user so maybe I'll try :-

onUseItem = function(self,champion:modifyStat("health", 100))
end

Edit Hmm still no dice..editor didn't like that line lol
it says it gets 2 parameters - try

Code: Select all

onUseItem = function(self,champion)
  champion:modifyStat("health", 100)
end
User avatar
Emciel
Posts: 34
Joined: Fri Sep 14, 2012 2:19 am

Re: Using/Consuming a potion?

Post by Emciel »

also you need to add
return true

to the onUseItem or else it won't actually be consumed =)

so shroom's code modified:

Code: Select all

onUseItem = function(self,champion)
  champion:modifyStat("health", 100)
  playSound("consume_potion")
  return true  
end
(also added the playSound ^_^)
Post Reply