NPC Salesman


Author: Relezite
Created: 2013-04-24T14:42:06-0400
Edited: 2013-04-24T14:42:06-0400
Denizen Version: 0.88
Views: 45
Downloads: 864
Likes: 0


WGET
Description: We run a survival server witha small group of friends, and while we wanted to introduce NPCs we don't much like elements that feel like creative mode. So I set out with zero knowledge to create scripts that would allow our players to buy NPCs from a nuetral location. I don't leave notes in my scripts, but it's altogether very simple and I'll respond to comments. There is a small problem I can't figure out with how the script names the NPCs.

"grayson":
    type: assignment

    actions:
      on assignment:
      - trigger name:chat toggle:true
      - trigger name:click toggle:true

    interact scripts:
    - 10 Sale

    default constants:
        Cost: 20
 

'Sale':
    type: interact

    steps:
        'SellNPC*':

            click trigger:
                script:
                - random 4
                - chat 'Yes, I sell <red>NPC<green>s.'
                - chat 'Need more money?  Try talking to the <red>adventurer<green>.'
                - chat 'Just say <red>NPC<green> and I<&sq>m all ears.'
                - chat 'What<&sq>s up?  Want an <red>NPC<green>?'

            chat trigger:

                'NPC':
                    trigger: 'I want to buy an /NPC/.'
                    script:
                    - chat 'I<&sq>m selling player NPCs for <cons:Cost> bucks a head.'
                    - chat 'Would you like to buy one?'
                    - zap 'step:Transact'
                'adventurer':
                    trigger: 'Who is the /adventurer/?'
                    script:
                    - chat 'Shady guy in green next to the portal house.  He<&sq>s shifty eyed, but a sure shot in a pinch.'

        'Transact':

            click trigger:
                script:
                - chat 'Say <red>yes<green> or <red>no<green>.'

            chat trigger:

                'decline':
                    trigger: '/No/, thank you.'
                    script:
                    - chat 'Ah well, maybe next time.'
                    - zap 'step:SellNPC'
                'accept':
                    trigger: '/Yes/, please.'
                    script:
                    - if "<player.money>" < "<cons:Cost>" chat 'You only have <red>$<player.money><green>.'
                      else runtask "script:giveme"
                    - zap 'step:SellNPC'

'giveme':
    Type: Task
    Script:
    - EXECUTE AS_OP "npc create '<player.name>s NPC'"
    - EXECUTE AS_OP "npc moveto --x 167 --y 118 --z 122"
    - EXECUTE AS_OP "npc owner <player.name>"
    - ^TAKE MONEY QTY:<cons:Cost>        
    - CHAT "Here you go my friend."
    - NARRATE "You hand Lord Grayson <cons:Cost> gold."
    - ^execute as_server "denizen save"




Comments
2013-06-13 22:58:55 - TigerX:

Such a nice script for a beginner :P