Author Topic: Complicated conversation...  (Read 646 times)

Legacy_Olblach

  • Newbie
  • *
  • Posts: 14
  • Karma: +0/-0
Complicated conversation...
« Reply #15 on: November 02, 2010, 12:57:19 pm »


               Ok, glad it works for this part. My first guess would be that GetObjectByTag() didn't work. Maybe the tag was mispelled? You should also check in the toolset if the creature you want to kill is not immortal^^. 

You can check this with:

oTarget = GetObjectByTag("Hasheeta") ; // or whatever your tag is in real
if (GetIsObjectValid(oTarget))
{
effect eEffect;
eEffect = EffectDeath();

ApplyEffectToObject(DURATION_TYPE_PERMANENT, eEffect, oTarget);
}
else
{
// SendMessageToPC(GetFirstPC(), "Hasheeta was not found!") ;
}
There is a comment // before the line SendMessageToPC(). It is for debugging. Remove them when you want to see the message and put them back when you are done with testing or else any player would see those.


Do you want Hasheeta to die or disappear? EffectDeath() makes Hasheeta die if you just want Hasheeta to disappear use DestroyObject() instead.

Also since you want this to happen only when Hasheida spawn you could put the code inside the test:

else if( state == 40 )
{//summon Hasheida
if (GetLocalInt(OBJECT_SELF, "Hasheida_Spawned") == 0)
{
CreateObject(OBJECT_TYPE_CREATURE,"Hasheida",loc);
SetLocalInt(OBJECT_SELF, "Hasheida_Spawned", 1) ;
object oTarget = GetObjectByTag("Hasheeta") ; // or whatever your tag is in real
if (GetIsObjectValid(oTarget))
{
effect eEffect;
eEffect = EffectDeath();

ApplyEffectToObject(DURATION_TYPE_PERMANENT, eEffect, oTarget);
}
else
{
// SendMessageToPC(GetFirstPC(), "Hasheeta was not found!") ;
}

}

               
               

               


                     Modifié par Olblach, 02 novembre 2010 - 01:25 .
                     
                  


            

Legacy_Eva_hop

  • Jr. Member
  • **
  • Posts: 88
  • Karma: +0/-0
Complicated conversation...
« Reply #16 on: November 02, 2010, 08:43:35 pm »


               Yes I just want her to disappear not really to die. And good point I think she is plot! Can i use destroy object on a plot npc? She needs to disappear because actually Hasheida and Harsheeta are the same person! So obviously they can't be there both at the same time.



I'm going to mess with this and see if it works. So instead of EffectDeath I'll use DestroyObject().



Thanks!
               
               

               
            

Legacy_GhostOfGod

  • Hero Member
  • *****
  • Posts: 1490
  • Karma: +0/-0
Complicated conversation...
« Reply #17 on: November 02, 2010, 08:49:28 pm »


               

Eva_hop wrote...

Can i use destroy object on a plot npc?


Yes. DestroyObject ignores the plot flag. It only looks at the "Destroyable" one.
               
               

               
            

Legacy_Eva_hop

  • Jr. Member
  • **
  • Posts: 88
  • Karma: +0/-0
Complicated conversation...
« Reply #18 on: November 02, 2010, 10:03:04 pm »


               I tried it but the script won't compile!

this is what i've got and it gives an error message in the line that says DestroyObject.

effect eEffect;
eEffect = DestroyObject();


EDIT: Nvm, I fixed it:

//kill Harsheeta
object oTarget = GetObjectByTag("Harsheeta") ;
if (GetIsObjectValid(oTarget))
DestroyObject(oTarget);

EDIT (30 mins later): Now I messed around some more with variables to make the summons only work if the phylactery is activated, and only any runes activated once three (or four in Hasheida's case) of the gems are put into the pillar...
What I managed so far is that Hasheida can only be summoned once the fourth gem is inserted. It was easy because this fourth gem can only be acquired once the first three have been inserted. Therefore I only had to set the local variable "magical_gems" to 4.
I couldn't figure out how to set a variable for the other three gems being inserted, order not important.
I thought setting a variable on the phylactery activate was going to be a piece of cake, but it's not working. I think part of the problem is that everytime the PC chooses a summon or activate the phylactery the same visual effects play that I only wanted to work for the phylactery activate. I didn't look into it before because I thought it didn't matter, but now I think it has something to do with that. Anyway here is the whole script, sorry that it's so long!
THanks for all your input guys, without you i'd be helpless.

void main()
{   
//buttonstart
int state = GetLocalInt( OBJECT_SELF, "ButtonState" );
    object wp = GetWaypointByTag("WP_summon");
    location loc = GetLocation(wp);
    if( state == 10 )
    {
    if (GetLocalInt(OBJECT_SELF, "Dantello_Spawned") == 0)
    if (GetLocalInt(OBJECT_SELF, "phylact_acti") == 3)
    {//summon Dantello
        CreateObject(OBJECT_TYPE_CREATURE,"Dantello",loc);
        SetLocalInt(OBJECT_SELF, "Dantello_Spawned", 1) ;
    }
    }
    else if( state == 20 )
    if (GetLocalInt(OBJECT_SELF, "phylact_acti") == 3)
    {
        //summon a testobject
        CreateObject(OBJECT_TYPE_CREATURE,"UrduPenguin",loc);
    }
   else if( state == 40 )
{//summon Hasheida
if (GetLocalInt(OBJECT_SELF, "magic_gems") == 4)
if (GetLocalInt(OBJECT_SELF, "Hasheida_Spawned") == 0)
{
CreateObject(OBJECT_TYPE_CREATURE,"Hasheida",loc);
SetLocalInt(OBJECT_SELF, "Hasheida_Spawned", 1) ;
//kill Harsheeta
object oTarget = GetObjectByTag("Harsheeta") ;
if (GetIsObjectValid(oTarget))
DestroyObject(oTarget);
}
}
    { //phylactery activate
      object oPC = GetPCSpeaker();
//I think this next part is a useless piece of scripting!
object oTarget;
oTarget = GetObjectByTag("OBJECT");
//Visual effects can't be applied to waypoints, so if it is a WP
//the VFX will be applied to the WP's location instead
int nInt;
nInt = GetObjectType(oTarget);
if (nInt != OBJECT_TYPE_WAYPOINT) ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_IMP_RAISE_DEAD), oTarget);
else ApplyEffectAtLocation(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_IMP_RAISE_DEAD), GetLocation(oTarget));
object oSpawn;
location lTarget;
//till here?
oTarget = GetWaypointByTag("WP_summon");
lTarget = GetLocation(oTarget);
oSpawn = CreateObject(OBJECT_TYPE_PLACEABLE, "urdu_summon", lTarget);
oTarget = oSpawn;
//Visual effects can't be applied to waypoints, so if it is a WP
//the VFX will be applied to the WP's location instead
nInt = GetObjectType(oTarget);
if (nInt != OBJECT_TYPE_WAYPOINT) DelayCommand(0.5, ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_IMP_UNSUMMON), oTarget));
else DelayCommand(0.5, ApplyEffectAtLocation(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_IMP_UNSUMMON), GetLocation(oTarget)));
//visual effect phylactery
oTarget = GetObjectByTag("WP_phylactery");
//Visual effects can't be applied to waypoints, so if it is a WP
//the VFX will be applied to the WP's location instead

nInt = GetObjectType(oTarget);

if (nInt != OBJECT_TYPE_WAYPOINT) ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_FNF_LOS_EVIL_20), oTarget);
else ApplyEffectAtLocation(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_FNF_LOS_EVIL_20), GetLocation(oTarget));
//set local variable phylactery
SetLocalInt(OBJECT_SELF, "phylact_acti", 3) ;
     }
    SetLocalInt( OBJECT_SELF, "ButtonState", 0);
}


               
               

               


                     Modifié par Eva_hop, 02 novembre 2010 - 11:12 .
                     
                  


            

Legacy_Olblach

  • Newbie
  • *
  • Posts: 14
  • Karma: +0/-0
Complicated conversation...
« Reply #19 on: November 03, 2010, 01:01:20 am »


               Is the philactery associated with a state? Is it state 1? If so the code should be :

if (state ==1)
{
// philactery code here
}
else if (state ==10)
{
....

Also it's a good habbit to use DestroyObject() with a little delay like DestroyObject(oTarget, 0.1)..I forgot exactly why...I think it helps when destroying plenty objects.
               
               

               


                     Modifié par Olblach, 03 novembre 2010 - 01:07 .
                     
                  


            

Legacy_Eva_hop

  • Jr. Member
  • **
  • Posts: 88
  • Karma: +0/-0
Complicated conversation...
« Reply #20 on: November 03, 2010, 09:56:01 am »


               I'm only destroying 1 and the creature is in another area, so i think it should be fine.



But I think I know what I'm doing wrong now, thanks! I forgot to attach a good state to the phylactery. I'm going to mess around with that.
               
               

               
            

Legacy_Eva_hop

  • Jr. Member
  • **
  • Posts: 88
  • Karma: +0/-0
Complicated conversation...
« Reply #21 on: November 03, 2010, 09:37:05 pm »


               Huzzah it's working!



I have almost everything done except for one:

I need to set a variable on all the first three gems being put into the pillar. How do I go about doing that?
               
               

               
            

Legacy_Olblach

  • Newbie
  • *
  • Posts: 14
  • Karma: +0/-0
Complicated conversation...
« Reply #22 on: November 04, 2010, 12:25:54 am »


               Depends on how much you like maths '<img'>
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 .
                     
                  


            

Legacy_Eva_hop

  • Jr. Member
  • **
  • Posts: 88
  • Karma: +0/-0
Complicated conversation...
« Reply #23 on: November 04, 2010, 10:48:51 am »


               gems cannot be removed so I think I'll go for method 2. '<img'> Thansk so much! I don't like math at all. '<img'>