Building & Scripting > Scripting Board

Trading Scripts

<< < (2/2)

erwin:
Trading Script v4, until Roland puts in a Trading OLC to render this obsolete. It's still pretty funky.

tstat 2140 for this

All you need is to set the flags (below), basically:

1) max_items  (number of items this mob accepts)
2) na_flag (nas depending max items. If the mob accepts 5 items, then na_flag should be: set na_flag na na na na na)
3) flagname (flag to set on actor call it whatever you want, here I've called it trade_crete_tino
4) item and "speech" (rather more of what actor sees) flags, up to 3 different ones. Eg.


--- Code: ---* items are what the mob accepts. For example, there's lots of wolf ears in the MUD, so you could do something like
set item1 1234 2222 5828

* if 1234, 2222, 5828 were vnums of wolf ears

* You get up to three consecutive actions the player sees in order.
* You don't need to use all three of them. So for example, you can have

set item1 52614
set speecha1 Tino says, 'Good! I can always use more hemp twine!'

* where item1 only has one line the player sees

set item2 12345
set speecha2 Gollum says, 'A ring, great!"
set speechb2 Gollum says, 'My precioussssssss'
set speechc2 Gollum caresses the ring eagerly.

* item 2 has three lines the player sees

set item3 123 6839 5824 52850
set speecha3 The player sees this.
set speechb3 and this.

* item 3 has three lines the player sees

* items / speeches are always set in consecutive order

--- End code ---

5) tp_reward_vec: TP in order of the items given
6) exp_reward_vec: Exp in order of the items given
7) brass_reward_vec: Brass tokens in order of the items given

8) rej_max_items: How many "special" items will the mob reject? Same like above, we have variables rej1, rej2, ..., and rejspeecha1, rejspeechb1, rejspeechc1, .... etc.

9) genreja, genrejb, genrejc - 3 potential variables for generic rejection speech, again in consecutive order

Here's an example.


--- Code: ---if !%actor.is_pc%
  halt
endif
* Molly, Kvetch, whoever wants to add MORE trading stuff here, follow the
* comments
*
* If you want to reduce the number of items traded, it's a bit more complex.
* Send me a note, or any of the coders.
* Ideally, we should probably write this in C instead of DG scripts.
*
* Flag: trade_crete_tino
* Currently, can trade THREE items, and mob rejects ONE item
*
*********
*********
*** The Edit Place
*************************
* Edit the below if you want to change the number of items traded
set max_items 3
*************************
* na_flag is basically THREE nas (or however max_items nas)
set na_flag na na na
*************************
* flagname - the flag for the trading
set flagname trade_crete_tino

* hemp twine
set item1 52614
set speecha1 Tino says, 'Good! I can always use more hemp twine!'

* sail cloth
set item2 52797
set speecha2 Tino says, 'Great! We were about to run out of sailcloth completely.'

* thin rope
set item3 52615
set speecha3 Tino says, 'Great, that thinrope will be enough for me to finish this batch of sails.'

* TP and EXP for each item
set tp_reward_vec 1 8 4
* This has no brass token
* set brass_reward_vec 0 0 0 1 0 0
set exp_reward_vec 1000 4000 3000

* rejected items

set rej_max_items 1

* sails
set rej1 44673 44674
set rejspeecha1 Tino says, 'Dude, I SELL sails, I don't buy them.
set rejspeechb1 So you can keep any sails you've made for yourself.' 


****
* Generic rejection speech
set genreja Tino says, 'I don't trade in such things.'
*
*

* This function will fix length of questflag, eg if more items were
* added
* Required inputs: na_flag, flagname, and max_items

function 2151

* BEFORE CALLING 21627
* Make sure you have defined a prefix for the items traded
* Above it's item1, item2, item3, item4, item5, item6, so prefix is item
* Also make sure you've set max_items, which ought to be ABOVE

* For the purists: function 21627 takes in an input prefix, and max_items,
* gives an output item_in_list

set prefix item
function 21627
set traded_item %item_in_list%

if %traded_item% != 0
  ** The reward for great trading items
  function 2152
  halt
endif


* Let's do the same for rejected items for special messages
* We are calling the same function 21627 again, but with
* rejected items as input
* So max_items is now rej_max_items, and prefix is rej

set max_items %rej_max_items%
set prefix rej
function 21627
set rej_traded_item %item_in_list%

function 2153

**** END

--- End code ---

erwin:
Trading Script V6.

This is in room 47300 in 6001. More info can be found there, but feel free to play about with it. Send a note for more requests for different types of triggers.

The intention is to make trading scripts "easier to write" - eg, there's actually no code below, it's just setting what you want the player to do / mob to react. It's also easier to debug (since no code), and also somewhat easier to see if the rewards are appropriate.


--- Code: ---Name: 'Trigger for Generic Trade',  VNum: [47300], RNum: [ 8677]
Trigger Intended Assignment: Mobiles
Trigger Type: Receive , Numeric Arg: 100, Arg list: None
Commands:


if !%actor.is_pc%
  halt
endif

**** Set parameters
**** What the player sees if supposed to get multiple tradepoints
**** eg, tp_start_plural NUM TRADEPOINTS tp_end_plural

set tp_start_plural Bob hands over
set tp_end_plural tradepoints.
set tp_sing Bob hands over 1 tradepoint.

**** What the player sees if supposed to get multiple brass tokens
**** eg, brass_start_plural NUM TOKENS brass_end_plural

set brass_start_plural Bob hands over
set brass_end_plural brass tokens.
set brass_sing Bob hands over 1 brass token.

**** What the player sees if supposed to get multiple brass tokens
**** eg, bronze_start_plural NUM TOKENS bronze_end_plural

set bronze_start_plural Bob hands over
set bronze_end_plural bronze tokens.
set bronze_sing Bob hands over 1 bronze token.


* Accepted Trade items only
* ALWAYS PLACE PARTIAL ITEMS AT THE END
* Partial items - eg trade FIVE grapes for ONE wine
* You get up to FIVE messages for everything
* Unlimited items to trade (in theory)

* Total number of items traded

set max_items 5

* Non partial items, eg trade ONE item to get reward

set ordinary_items 3

* Partial items, eg trade FIVE grapes for reward

set part_items 2

* Makes it easier for questjournal in future to keep track of trades
* Trade_flag can be: trade_egypt_mobname etc etc

set trade_flag trade_thiszone_thismob

* Place the part_items at the end.
* Up to 5 messages, with delay in seconds
* If you need more messages, send a note

* Delay between mob messages
set delay 2

* Flags for items
* If none, don't need to have the flag there
* item_x : list vnums, or short desc
* type_x : Is it a vnum, or short desc?
* msg_Ax, msg_Bx, msg_Cx, msg_Dx, msg_Ex : What mob says
* reward_x : reward is in terms of XP TP BRASS BRONZE
* item_reward_x : vnum of item reward
* how_many_x : For partial items, how many to get a reward?
* reward_after_x : The reward after getting all partial items
* item_reward_after_x : The item reward after getting all partial items

* Put the three ordinary items first

* Item 1 (diamonds)

* Bob will accept one item, will have three actions
* This item gets 1000 XP * level, 10 TP, 0 brass, 0 bronze

set item_1 8465
set type_1 vnum
set msg_A1 Bob says, 'Thank you for trading this item'
set msg_B1 Bob smiles.
set msg_C1 Bob says, 'I have nothing else to say.'

* Reward is in terms of XP, TP, BRASS, BRONZE
set reward_1 1000 10 0 0


* Item 2 (logs)
* Bob will accept any item with short desc logs, will have four actions
* This item gets 5000 XP * level, 4 TP, 1 brass, 2 bronze
* This item will also get a object reward vnum 2523

set item_2 log
set type_2 short
set msg_A2 Bob says, 'Thank you for trading the log item'
set msg_B2 Bob smiles.
set msg_C2 Bob says, 'I have given you a small gift of a chair.'
set msg_D2 Bob thanks you heartily.
* Reward is in terms of XP, TP, BRASS, BRONZE
set reward_2 5000 4 1 2
set item_reward_2 2523

* Item 3 (bread)
* Bob will accept two items: 10, 9291 and has one action
* This item gets 1 TP


set item_3 10 9291
set type_3 vnum
set msg_A3 Bob says, 'I like bread.'
set reward_3 0 1 0 0

* Reminder, always put partial items last

* Item 4 (grapes)
* Bob will accept two items: 6346, 44495 and has two actions
* This item gets no reward each time
* Bob has a message to count them, eg msg_counter_before NUMGIVEN msg_counter_after

* But when all 5 are given (how_many_4 flag)
* Player gets 1000 xp * level, 5 TP, 1 brass, 0 bronze
* Player also gets object 6349

* Item 4 (grapes - trade 5 to get 1 wine)
set item_4 6346 44495
set type_4 vnum
set how_many_4 5
set msg_A4 Bob says, 'Thanks for the grapes'
set msg_B4 Bob says, 'I will store them to make wine'

set msg_counter_before_4 Bob says, 'Keep them coming,
set msg_counter_after_4 out of 5!

set reward_4 0 0 0 0
set msg_after_A4 Bob says, 'You have given me 5 grapes'
set msg_after_B4 Bob says, 'I will give you some wine'

set reward_after_4 1000 5 1 0
set item_reward_after_4 6349


* Item 5 (ear)
* Bob will accept one items: 15083
* This item gets 1 TP each time it is given
* Bob has a message to count them, eg msg_counter_before NUMGIVEN msg_counter_after

* But when all 10 are given (how_many_5 flag)
* Player gets 1000 xp * level, 10 TP, 10 brass, 10 bronze

set item_5 15083
set type_5 vnum
set how_many_5 10
set msg_A5 Bob says, 'Thanks for the wolf ear'
set msg_B5 Bob says, 'I will give you 1 TP.
set reward_5 0 1 0 0

set msg_counter_before_5 Bob says, 'Look at these ears piling up,
set msg_counter_after_5 out of 10!

set reward_after_5 1000 10 10 10
set msg_after_A5 Bob says, 'I'm going to give you a bonus!'
set msg_after_B5 Bob says, 'Tokens and stuff and more'
set msg_after_C5 Bob says, 'But no items.'


******** Rejected items
* same thing

set rej_max_items 2

* Bob rejects items 8704, 1404 with a special message

set rej_item_1 8704 1404
set rej_type_1 vnum

set rej_msg_A1 Bob says, 'I don't like gold.'
set rej_msg_B1 Bob says, 'Go away.'

* Bob rejects items with short desc flower with a special message


set rej_item_2 flower
set rej_type_2 short

set rej_msg_A2 Bob says, 'I hate flowers.'
set rej_msg_B2 Bob says, 'Go away.'

***** Default message

set rej_default_A Bob says, 'What is this crap?'
set rej_default_B Bob says, 'Go away.'

**** The magic function
function 47391

--- End code ---

Navigation

[0] Message Index

[*] Previous page

Go to full version