buying stuff from npc

Started by , Tue 20/04/2004 00:40:56

Previous topic - Next topic

Joe

my character needs to buy supplies from an npc who sells several items.  

so far for the npc character i have

if user clicks inventory item on the npc
and if that item is money
  then run a dialog (dialog being the choices of merchandise)
 
and then im stuck...

i need game to recognize that if i choose first dialog choice, give me the first item, if second dialog choice, 2nd etc.  

not sure how to proceed.  if there is a tutorial on this just give me link and ill work it out.  

strazer

Have you ever scripted a dialog before?
If not, be sure to read up on "Conversations" in the manual.

I think the add-inv X (X=inventory item number) command is what you're looking for.

Joe

nope.  but it doesnt seem all that hard. ill try what you said and post how it went in a lil while.  

joe

ahha thanks i was looking at it wrong, trying to see which dialog user choose from npc's 'interaction' properties...instead of just adding your line to the actual dialog script.  

it works!  thanks.  

strazer

#4
Cool.
Just for future reference, in case you want to do more advanced stuff from dialogs, here's how to do it:

Code: ags

// dialog script

@1 // buy item 1
ego: Gimme that thing there!
guy: No prob. Here you go...
run-script 1
return

@2 // buy item 2
ego: I want this over there!
guy: Sure. Here you go...
run-script 2
return

@3 // buy nothing
ego: That's all, thanks.
guy: Bye.
stop


Code: ags

// global script (menu "Script", "Edit global script...")

function dialog_request (int parameter) { // add this function if it's not there

  if (parameter == 1) { // called by run-script 1
    AddInventory(1); // give player inventory item 1, same as add-inv 1
    // put more advanced stuff here, animations and such
  }
  else if (parameter == 2) { // run-script 2
    AddInventory(2); // give player inv item 2
    // more stuff here
  }
  // ...etc., put as much else-ifs here as you need

}


Also, check out this nifty dialog creation tool.

SMF spam blocked by CleanTalk