Author Topic: Checking for item combinations  (Read 1845 times)

Aegnor

  • Guest
Checking for item combinations
« on: January 14, 2005, 01:58:29 AM »
Yeah, well im searching for a script that can check your items for combinations with out you having to write the conbinations one by one.

The ideal would be if it were possible to specify a certain number that must be true instead of any OR().
Don't think this can be done but if anyone could figure out a work-around for this, I'd be verrrrry haaapy.  ::)

Offline Ghreyfain

  • Moderator
  • Planewalker
  • *****
  • Posts: 4705
  • Gender: Male
    • Pocket Plane Group
Re: Checking for item combinations
« Reply #1 on: January 14, 2005, 06:52:12 AM »
Sadly, there is no AND in IE scripting.  I'm not sure if a more complicated work-around could be done, or what it would be.  Maybe someone else'll come by who knows.
Earn Money Sleeping.

Offline igi

  • IESDP Guardian
  • Planewalker
  • *****
  • Posts: 124
  • IESDP Guardian
Re: Checking for item combinations
« Reply #2 on: January 14, 2005, 01:33:30 PM »
The basic principle of IE scripting works is AND, it's implicit, unless you use the OR trigger...
Still, it's not very helpful in this case.

If you want to use numbers to uniquely identify weather a particular item set, you could try something like this...
Patch each item to increment a global collective global when equipped. And then check the global for the possible values. e.g.
Code: [Select]
Hat Of Stuff = myGlobal +1
Boots of Meandering = myGlobal +2
Gloves of Warmth = myGlobal +4
Cloak of Other Stuff = myGlobal +8

Then:
Code: [Select]
IF myGlobal = 1 // only Hat
If myGlobal = 2 // only boots
IF myGlobal = 3 // hat + cloak
IF myGlobal = 4 // only gloves
IF myGlobal = 5 // gloves + hat
IF myGlobal = 6 // gloves + boots
IF myGlobal = 7 // gloves + boots + hat
IF myGlobal = 8 // only cloak
etc..

IIRC though, the Modify Global opcode doesnt work with the While Equipped timing mode (it just acts as permanent), so you'd need to run a script when one of the items is unequipped to decrement by the relevant amount.
NPC: Arg || Galoomp || Thash
Mods: Dark Heart of the Xvart || GbG
Tweak Pack: iiTweak

mcwrench.com
mcwrench.com forums

Offline Loriel

  • Planewalker
  • *****
  • Posts: 390
  • Gender: Male
    • Loriel's Downloads
Re: Checking for item combinations
« Reply #3 on: January 14, 2005, 06:20:37 PM »
I think there's a typo in the last example:
Code: [Select]
IF myGlobal = 3 // hat + cloakThat should read "hat + boots".

Aegnor

  • Guest
Re: Checking for item combinations
« Reply #4 on: January 17, 2005, 01:52:31 AM »
Ok, thanks igi, that was very helpful.
Now I can decrease my code to about 10 code blocks instead of 130!!  ;D

Offline Vlasák

  • Planewalker
  • *****
  • Posts: 11
  • Gender: Male
Re: Checking for item combinations
« Reply #5 on: January 18, 2005, 05:33:43 AM »
If you want to make the condition as:
(Trigger1 AND Trigger2) OR (Trigger3 AND Trigger4)

As it been said it is not possible - AND is implicit in triggers and no single AND(x) as in case of OR(x) doesn't exist. But there is a three block solution that can simulate various Sum of Products boolean formulas ( (...AND...AND...AND...) OR (...AND...AND...AND...) OR (...AND...AND...AND...) OR...)

I've wanted this many months ago - I've tried to simulate AND by !OR() and it didn't work. Just about two months ago I realised, that it can be do in following way...

The principle - make the negation of: (Trigger1 AND Trigger2) OR (Trigger3 AND Trigger4) - that is
(!Trigger1 OR !Trigger2) AND (!Trigger3 Or !Trigger4). This negation can be coded in IE script block.

The action of that block must be the reverse of your original action you've wanted to code - or just NoAction() - "I want to do something when condition (Trigger1 AND Trigger2) OR (Trigger3 AND Trigger4) is true and do nothing when it is not true".
There is the second block which follow after this. This block has it's condition always true and its purpose is to perform the action that I've wanted.

Because of the proccesing of scripts the following two possibilites occurs:
 - the first block condition is true (="Oposition of my original requirements are fulfiled"="My original requirements are not fulfiled") - NoAction (or reverse action) is perform and the script restarts to its beginning. So the second "always true" block is not performed. So I "catch" the undesired cases.
 - the first block condition is false (="Oposition of my original requirements are no fulfiled"="My original requirements are fulfiled") - script skips to second block and it is performed then...

Code: [Select]
IF
  OR(2)
    !Trigger1
    !Trigger2
  OR(2)
    !Trigger3
    !Trigger4
THEN
  RESPONSE #100
    NoAction()
END

IF
  True()
THEN
  RESPONSE #100
    Action()
END

Well, this solution is rough, however - the rest of the script after the mentioned second block is always cut off from the script procceeding due to second block's always true condition. I can add there Continue() action that ensures the continue of the script proceeding. But by this I'll break a little the standart rules of the script proceeding (when the block is performed, the script restarts).

So, I'll add "AND" local variable - its values meaning:
 - 0: my desired action can be performed
 - 1: my desired action cannot be performed due to the fact that the opposite conditions are true

Code: [Select]
IF
   GlobalGT("AND",LOCALS",0) //if AND =>0
THEN
   RESPONSE #100
       SetGlobal("OR","LOCALS",0) //reset to 0
       Continue() //I want to continue in the script
END

IF
  OR(2)
    !Trigger1
    !Trigger2
  OR(2)
    !Trigger3
    !Trigger4
THEN
  RESPONSE #100
    SetGlobal("AND","LOCALS",1) //My desired action cannot be performed (opposite conditions are true), so AND=1
    Continue() //!! I want to continue in script because in my imaginary "(Trigger1 AND Trigger2) OR (Trigger3 AND Trigger4)" block I have now the case when its conditions are not true and the script continues to following block in these cases
END

IF
   !GlobalGT("AND","LOCALS",0) //AND is not =>0
THEN
   RESPONSE #100
      Action //perform desired action
//no Continue() - if this block is performed, the script restarts as it's standart.
END

I've developed similar method for the simulation of OR in BG1 where this trigger is not present.
Baldur's Gate II add-on CZ - TC from Dalelands
http://addoncz.gamestar.cz

English forums are opened!

 

With Quick-Reply you can write a post when viewing a topic without loading a new page. You can still use bulletin board code and smileys as you would in a normal post.

Warning: this topic has not been posted in for at least 120 days.
Unless you're sure you want to reply, please consider starting a new topic.

Name: Email:
Verification:
Type the letters shown in the picture
Listen to the letters / Request another image
Type the letters shown in the picture:
What color is grass?:
What is the seventh word in this sentence?:
What is five minus two (use the full word)?: