Aller au contenu

Photo

Need help, Starting Conditionals Script(s) not working properly...


  • Veuillez vous connecter pour répondre
7 réponses à ce sujet

#1
_Guile

_Guile
  • Members
  • 685 messages
OK, I made a forge, but the starting conditionals are NOT working like they should

I'll show two scripts so you can follow what's going on

In Line 1 (PC Selects The Weapon in their Right and this script fires from the ActionTaken Event Tab)

// gf_ss_rh
// This script is part of my Genisys Forge System

void main()
{
  object oPC = GetPCSpeaker();
  int nSlot = INVENTORY_SLOT_RIGHTHAND;
  SetLocalInt(oPC, "ITEM_SLOT", nSlot);
}


in Line 2 (the Property they want to select is THIS starting conditional script in the TextAppearsWhen Event Tab)

int StartingConditional()
{
   int iShow = FALSE;
   object oPC = GetPCSpeaker();
   int nSlot = GetLocalInt(oPC, "ITEM_SLOT");
   object oItem = GetItemInSlot(nSlot, oPC);
   int nType = GetBaseItemType(oItem);
   //If it's an Item that can be worn! (No Weapons Allowed!)
   if(nType == BASE_ITEM_AMULET || nType == BASE_ITEM_BOOTS ||
   BASE_ITEM_BRACER || nType == BASE_ITEM_CLOAK ||
   BASE_ITEM_GLOVES || nType == BASE_ITEM_HELMET ||
   BASE_ITEM_ARMOR || nType == BASE_ITEM_RING ||
   BASE_ITEM_SMALLSHIELD || nType == BASE_ITEM_TOWERSHIELD ||
   BASE_ITEM_LARGESHIELD)
   {
    iShow = TRUE;
   }

 return iShow;

}

But the Line with the Starting Conditional is showing when it shouldn't.  This is happening for most of my lines (except 1) and the others are exactly like the one above, except different base item types.

Any help?  ^_^

Modifié par _Guile, 31 août 2011 - 03:11 .


#2
_Guile

_Guile
  • Members
  • 685 messages
Nevermind, I fixed it by changing up the script some. :D

int StartingConditional()
{
object oPC = GetPCSpeaker();
int nSlot = GetLocalInt(oPC, "ITEM_SLOT");
object oItem = GetItemInSlot(nSlot, oPC);
int nType = GetBaseItemType(oItem);

switch(nType)
{
case BASE_ITEM_AMULET: { return TRUE;} break;
case BASE_ITEM_ARMOR: { return TRUE;} break;
case BASE_ITEM_BELT: { return TRUE;} break;
case BASE_ITEM_BOOTS: { return TRUE;} break;
case BASE_ITEM_BRACER: { return TRUE;} break;
case BASE_ITEM_CLOAK: { return TRUE;} break;
case BASE_ITEM_GLOVES: { return TRUE;} break;
case BASE_ITEM_HELMET: { return TRUE;} break;
case BASE_ITEM_LARGESHIELD: { return TRUE;} break;
case BASE_ITEM_RING: { return TRUE;} break;
case BASE_ITEM_SMALLSHIELD: { return TRUE;} break;
case BASE_ITEM_TOWERSHIELD: { return TRUE;} break;
}

return FALSE;
}

Modifié par _Guile, 30 août 2011 - 12:01 .


#3
_Guile

_Guile
  • Members
  • 685 messages
Anyone understand why the first version didn't work but the 2nd one did?

#4
Lightfoot8

Lightfoot8
  • Members
  • 2 535 messages
Perhaps because you where getting the item in the right hand. then checking to see if it was anything but a weapon.

#5
_Guile

_Guile
  • Members
  • 685 messages

Lightfoot8 wrote...

Perhaps because you where getting the item in the right hand. then checking to see if it was anything but a weapon.


That was what I was wanting to do, to NOT show the line if it was anything BUT the base items types I listed.
Unfortunately it was showing the line regardless, weird.

#6
the.gray.fox

the.gray.fox
  • Members
  • 127 messages

_Guile wrote...

   if(nType == BASE_ITEM_AMULET || nType == BASE_ITEM_BOOTS ||
   BASE_ITEM_BRACER || nType == BASE_ITEM_CLOAK ||
   BASE_ITEM_GLOVES || nType == BASE_ITEM_HELMET ||
   BASE_ITEM_ARMOR || nType == BASE_ITEM_RING ||
   BASE_ITEM_SMALLSHIELD || nType == BASE_ITEM_TOWERSHIELD ||
   BASE_ITEM_LARGESHIELD)

Any help?  ^_^


Hello.
Look at how you chained the Boolean OR operators and the BASE_ITEM_* constants.
I will put highlights on the initial portion of the if() :

   if(nType == BASE_ITEM_AMULET || nType == BASE_ITEM_BOOTS ||
   BASE_ITEM_BRACER || nType == BASE_ITEM_CLOAK ||

The Red expression is giving the logical bug.

BASE_ITEM_BRACER is a constant with value nonZero. That alone makes your if() evaluate to TRUE, regardless of what the other (Green) expressions evaluate to.
Hence your conversation node is made visible _always_.


-fox

#7
_six

_six
  • Members
  • 919 messages
Side note, for the advantage of having less code your switch could be changed to...

switch(nType)
{
case BASE_ITEM_AMULET:
case BASE_ITEM_ARMOR:
case BASE_ITEM_BELT:
case BASE_ITEM_BOOTS:
case BASE_ITEM_BRACER:
case BASE_ITEM_CLOAK:
case BASE_ITEM_GLOVES:
case BASE_ITEM_HELMET:
case BASE_ITEM_LARGESHIELD:
case BASE_ITEM_RING:
case BASE_ITEM_SMALLSHIELD:
case BASE_ITEM_TOWERSHIELD:
return TRUE;
break;

default:
return FALSE;
}

Modifié par _six, 01 septembre 2011 - 06:44 .


#8
_Guile

_Guile
  • Members
  • 685 messages
Sweet, awesome response guys, thanks +Rep (if I could give you one I would)