open a door if a champion has certain level skill

Talk about creating Grimrock 1 levels and mods here. Warning: forum contains spoilers!
Post Reply
bongobeat
Posts: 1076
Joined: Thu May 16, 2013 5:58 pm
Location: France

open a door if a champion has certain level skill

Post by bongobeat »

Hey guys,
can someone tell me how to open a door if one of the champion have a certain level of a certain skills?
like:
if Champion(1) or Champion(2) or Champion(3) or Champion(4:) has skills ("spellcraft") level 15 then door_1:open()

I ve see this code in the script repository but I can't adapt it as what I want
SpoilerShow

Code: Select all

function teststat(stat, value, xpmin, xpmax)
   local astat = {}
   astat[1] = party:getChampion(1):getStat("vitality")
   astat[2] = party:getChampion(2):getStat("strength")
   astat[3] = party:getChampion(3):getStat("dexterity")
   astat[4] = party:getChampion(4):getStat("willpower")
   
   local aname = {}
   aname[1] = party:getChampion(1):getName()
   aname[2] = party:getChampion(2):getName()
   aname[3] = party:getChampion(3):getName()
   aname[4] = party:getChampion(4):getName()
   
   for i=1,4 do
      if astat[i] < math.random(10) then
-- 10 le niveau de stat a tester
         hudPrint(aname[i].." doesn't learn anything.")
      else
         local experiencegained = math.random(100,200)
-- xpmin 100 et xpmax 200
              hudPrint(aname[i].." succeeds to understand what is going on and gain "..experiencegained.." XP." )
              party:getChampion(i):gainExp(experiencegained)
      end   
   end
end
My asset pack: viewtopic.php?f=22&t=9320

Log1 mod : Toorum Manor: viewtopic.php?f=14&t=5505
Ryeath_Greystalk
Posts: 366
Joined: Tue Jan 15, 2013 3:26 am
Location: Oregon

Re: open a door if a champion has certain level skill

Post by Ryeath_Greystalk »

I would probably do it something like this,

Code: Select all

function doorCheck()

   local level_check = false
   local level = 0

   for x = 1,4 do
       level = party:getChampion(x):getSkillLevel("spellcraft")
       if level => 15 then
               level _check = true
               break
      else 
               level_check = false
      end
   end

   if level_check then
       special_door:open()
   else
       special_door:close()
       hudPrint("You are too wimpy to open this door, come back when you are tougher!")
   end
end
This is not tested and I may have some syntax error, but should get you close.
bongobeat
Posts: 1076
Joined: Thu May 16, 2013 5:58 pm
Location: France

Re: open a door if a champion has certain level skill

Post by bongobeat »

Thanks for the help:

yes there is some error of syntax:
this one works fine
SpoilerShow

Code: Select all

function doorCheck()

   local level_check = false
   local level = 0

   for x = 1,4 do
       level = party:getChampion(x):getSkillLevel("spellcraft")
       if level > 15 then
               level_check = true
               break
      else 
               level_check = false
      end
   end

   if level_check then
       door_1:open()
   else
       door_1:close()
       hudPrint("You are too wimpy to open this door, come back when you are tougher!")
   end
end
thanks again :)
My asset pack: viewtopic.php?f=22&t=9320

Log1 mod : Toorum Manor: viewtopic.php?f=14&t=5505
Post Reply