Author Topic: Convo Start Conditional problem  (Read 352 times)

Legacy_Ed Venture

  • Full Member
  • ***
  • Posts: 200
  • Karma: +0/-0
Convo Start Conditional problem
« on: August 31, 2014, 03:37:24 pm »


               In Conversation I am trying to check if the PC has a ring (Any ring).
I have a script that will check the inventory ring slots that compiles and works. The problem starts when I try to loop through the PC inventory. I can't even get anything to compile. Can someone teach me how this can be done ?

Ed
               
               

               
            

Legacy_Buddywarrior

  • Hero Member
  • *****
  • Posts: 512
  • Karma: +0/-0
Convo Start Conditional problem
« Reply #1 on: August 31, 2014, 06:03:28 pm »


               

Post your code '<img'>



               
               

               
            

Legacy_Terrorble

  • Sr. Member
  • ****
  • Posts: 370
  • Karma: +0/-0
Convo Start Conditional problem
« Reply #2 on: September 01, 2014, 06:27:27 am »


               
This should work... though I didn't test it.  This script goes in the "Text Appears When..." box of the conversation node you are testing.  If the function returns TRUE, the conversation option will show up.

 

int StartingConditional()

{

    //use GetPCSpeaker() to get the PC that is talking to the NPC

    object oPC = GetPCSpeaker();

 

    //define oItem as whatever is in the right ring slot of oPC

    object oItem = GetItemInSlot(INVENTORY_SLOT_RIGHTRING,oPC);

 

    //if the item in that slot is not invalid, it means they own a ring.

    if( GetIsObjectValid(oItem) != OBJECT_INVALID ) return TRUE;

 

    //if we didn't have anything in the right ring slot, let's see about the left

    oItem = GetItemInSlot(INVENTORY_SLOT_LEFTRING,oPC);

    if( GetIsObjectValid(oItem) != OBJECT_INVALID ) return TRUE;

 

 

    //if we got this far, it means no rings are equipped. let's scan the inventory.

    oItem = GetFirstItemInInventory(oPC);

 

    while( GetIsObjectValid(oItem) )

    {

        if( GetBaseItemType(oItem) == BASE_ITEM_RING )

        {

            return TRUE;

        }

      oItem = GetNextItemInInventory(oPC);

    }

 

    return FALSE;

}


               
               

               
            

Legacy_Terrorble

  • Sr. Member
  • ****
  • Posts: 370
  • Karma: +0/-0
Convo Start Conditional problem
« Reply #3 on: September 01, 2014, 06:31:42 am »


               

Alternatively, if you know the TAG of the ring you are looking for:


 


int StartingConditional()

{

    object oPC = GetPCSpeaker();

 

    if( GetItemPossessedBy(oPC,"TAG_of_the_ring_you_are_looking_for") != OBJECT_INVALID ) return TRUE;

 

    else return FALSE;

}


               
               

               
            

Legacy_Ed Venture

  • Full Member
  • ***
  • Posts: 200
  • Karma: +0/-0
Convo Start Conditional problem
« Reply #4 on: September 01, 2014, 01:24:20 pm »


               Terrorble,
A million thanks. works like a charm.
The PC drinks to much and wakes in a room with a women.
In convo with the women he must choose between being a nice guy or a cad.
The conditional checks to see if he has a ring (Any).
A second script takes a ring by priority, rightring, leftring, or inventory (The price of being a nice guy).
Thank you again, for moving a little higher on the left side of the learning curve.

Buddywarrior,
Here is the completed script:
/* STARTING CONDITIONAL "sc_has_a_ring" Returns TRUE if PC
has a ring (ANY RING) */
int StartingConditional()
{
object oPC = GetFirstPC();
int nBase = BASE_ITEM_RING;
int nType = OBJECT_TYPE_ITEM;
int nSlotR = INVENTORY_SLOT_RIGHTRING;
int nSlotL = INVENTORY_SLOT_LEFTRING;
object oItem = GetFirstItemInInventory(oPC);

if(GetBaseItemType(GetItemInSlot(nSlotR,oPC)) == nBase ||
GetBaseItemType(GetItemInSlot(nSlotL,oPC)) == nBase)
return TRUE;

while(GetIsObjectValid(oItem))
{
if(GetBaseItemType(oItem) == nBase)
{
return TRUE;
}
oItem = GetNextItemInInventory(oPC);
}
return FALSE;
}
I thank you as well.

Ed
               
               

               
            

Legacy_fumm

  • Jr. Member
  • **
  • Posts: 54
  • Karma: +0/-0
Convo Start Conditional problem
« Reply #5 on: September 12, 2014, 05:42:57 pm »


               

hey i have a similar problem. I need a script for a quest where you start a conversation with a NPC and if you have a particular brooch in your inventory then one conversation is initiated, and if you don't have the brooch in your inventory, another different conversation is initiated. 



               
               

               
            

Legacy_Ed Venture

  • Full Member
  • ***
  • Posts: 200
  • Karma: +0/-0
Convo Start Conditional problem
« Reply #6 on: September 13, 2014, 01:44:58 am »


               fumm,
It depends on what you mean by conersations. If it is 2 different conversation files,
object oPC
object oNPC
object oItem = GetItemPossessedBy(oPC,sTagOfItem);
string sConvoA
string sConvoB

if(GetIsObjectValid(oItem))
{
AssignCommand(oNPC,ActionStartConversation(oPC,sConvoA,TRUE));// if they have it do this.
}
else
{
AssignCommand(oNPC,ActionStartConversation(oPC,sConvoB,TRUE));//if not do this.
}

If you mean one file with two NPC nodes, check for the item on the first node. The script wizard can do this for you, or you can put this in the Text Appears script.

object oPC = GetPCSpeaker();
object oItem = GetItemPossessedBy(oPC,sTagOfItem);

if(GetIsObjectValid(oItem))
return TRUE;// Show this node
return FALSE;// don't show it

If the PC does not have the Item The second node will be displayed.

Ed
               
               

               
            

Legacy_fumm

  • Jr. Member
  • **
  • Posts: 54
  • Karma: +0/-0
Convo Start Conditional problem
« Reply #7 on: September 13, 2014, 07:38:49 am »


               

thanks but i dont get it. Where do you put the script and when i compile it one line is red. to be exact i want just one conversation file with two nodes that displays one if they have it and the other if they dont. Also i want when you respond to the one that have it, it deducts the brooch from your inventory and gives you some prizes. 



               
               

               
            

Legacy_Ed Venture

  • Full Member
  • ***
  • Posts: 200
  • Karma: +0/-0
Convo Start Conditional problem
« Reply #8 on: September 13, 2014, 03:43:25 pm »


               

Fumm,


Open the script file.


In the lower right hand corner, you will see several tabs.


The first one is Text Appears.


Click the tab.


Next to the window where script names appear, you will see three icons. The first lets you open a panel that shows all of your exsisting scripts. The second is Edit. It allows you to edit the script in the script window(or start a new one if no script is present. The third (looks like a wizard hat) is the script wizard.


Click on the hat.


A panel will come up asking what conditional to test for.


Click on Item in Inventory. Click next. A panel comes up. enter the Tag of the item and click Add, Click Next. Save the script and finish.


The script should appear in the script window. (By practice I always start the name of a Starting Conditional script with sc_)


To take the item and give rewards click on the Action Taken Tab.


Click on the hat. Choose Take From Player, Click Next. In the next panel enter the Tag of the item and click Add, Click next and save the script. (at_) 


To give rewards you can either make a script on the next PC node, or edit the above at_ script.


PC node.


Action Taken, Give Rewards, Add, Save.


Edit.


For gold use the GiveGoldToCreature function.


For items use CreateItemOnObject function.


Save.


 


Don't be afraid to make a random NPC and give him a simple conversation. This is a good way to explore all of the options in the conversion file. Use script names like sc_test_ and at_test. Later you can always delete the NPC,coversation file, and all of the test scripts.


 


Practice, practice,practice.


I've been at this going on a couple of years now, and I still have to come here for help.


 


Ed



               
               

               
            

Legacy_fumm

  • Jr. Member
  • **
  • Posts: 54
  • Karma: +0/-0
Convo Start Conditional problem
« Reply #9 on: September 14, 2014, 03:38:47 am »


               

I made a test module and it works! thank you so much