Depends on how much you like maths
'>
It also depends on what you plan to do with them:
You could set three variables, gem_one, gem_two, gem_three then test if (gem_one && gem_two && gem_three)
The simplest method but also quite heavy and inefficient.
You could set one variable and increment for each gem
gem_count would range from 0 to 3 depending on how many gems are in the pillar
But you would lose track on which gem is inside..it doesnt matter if the player cannot remove gems.
The last method uses boolean arithmetic (it's often called flags, there are a few of those in NWN):
gem_set
you will add 1 for first gem, 2 for second gem and 4 for third gem
then you add each gem value
so if gem 1 and gem 3 are into the pillar gem_set is 5 (1+4)
if gem 2 and gem 3 are into the pillar gem_set is 6 (2+4)
if the three gems are into the pillars gem_set is 7 (1+2+4)
Probably method 2 is what you need method 3 covers everything (method 1 too but will require more coding).
Code wise it would be like
// method 2 when another gem is activated
int nGems = GetLocalInt(OBJECT_SELF, "gem_count") ;
SetLocalInt(OBJECT_SELF, "gem_count", nGems+1) ;
As you can see that works only if gems cannot be removed
// method 3 when gem 1 is activated
int nGems = GetLocalInt(OBJECT_SELF, "gem_set") ;
SetLocalInt(OBJECT_SELF, "gem_set", nGems | 1) ;
// method 3 when gem 2 is activated
int nGems = GetLocalInt(OBJECT_SELF, "gem_set") ;
SetLocalInt(OBJECT_SELF, "gem_set", nGems | 2) ;
// method 3 when gem 3 is activated
int nGems = GetLocalInt(OBJECT_SELF, "gem_set") ;
SetLocalInt(OBJECT_SELF, "gem_set", nGems | 4) ;
With:
int nGems = GetLocalInt(OBJECT_SELF, "gem_set") ;
If you want to test if gem 2 is activated:
if (nGems & 4)
{
// gem 2 is activated
}
If you want to test if all 3 gems are activated
if (nGems & 7)
{
}
The last method is the more flexible, but of course it's not very intuitive...
Summary: if you want to be able to remove gems from the pillar use method 1 or 3 and if you don't method 2 is probably the best/simplest.
Modifié par Olblach, 04 novembre 2010 - 12:26 .