Paste #15689: Repo Script Bodyguard Salesman

Date: 2015/05/09 06:55:23 UTC-07:00
Type: Denizen Script

View Raw Paste Download This Paste
Copy Link


BodyguardSalesMan:
    type: assignment
    debug: false
    default constants:
        BodyguardCost: 20
        BodyGuardRespawnCost: 2000
        BodyGuardInstant: 20000
    interact scripts:
    - 10 BgSalesMan

BgSalesMan:
    type: interact
    steps:
        1:
            click trigger:
                script:
                - if <player.has_flag[Bodyguard2]> {
                    - narrate "<green><npc.name>:<gold> You already have a bodyguard, Come back if  he dies."
                    } else {
                    - narrate "<green><npc.name>:<gold> Hello <player.name> Welcome to my shop."
                    - wait 1
                    - narrate "<green><npc.name>:<gold> As of this moment i only have three types of bodyguard available."
                    - wait 1
                    - narrate "<green><npc.name>:<gold> Would you like to hire a <green>normal<gold> bodyguard for $<npc.constant[BodyguardCost]>?"
                    - wait 1
                    - narrate "<green><npc.name>:<gold> Or would you like one that <green>respawns<gold> for $<npc.constant[BodyGuardRespawnCost]> or one that respawns <green>instantly<gold> for $<npc.constant[BodyGuardInstant]>?"
                    }
            chat trigger:
                1:
                    trigger: <gold>I am interested in purchasing a /normal/ bodyguard.
                    script:
                    - engage
                    - narrate "<green><npc.name>:<gold> Alright that will be $<npc.constant[BodyguardCost]>."
                    - if <player.money> < <npc.constant[BodyguardCost]> {
                        - narrate "<green><npc.name>:<gold> You do not have enough money, please come back when you have enough."
                        - disengage
                        } else {
                        - take money qty:<npc.constant[BodyguardCost]>
                        - flag player Bodyguard2
                        - create player BodyGuard <player.location> save:BodyGuard
                        - flag player Bodyguard:<entry[BodyGuard].created_npc> duration:15
                        - ^execute as_server "npc select <player.flag[BodyGuard].replace[n@]>"
                        - ^execute as_server "trait sentry"
                        - ^execute as_server "sentry equip DIAMOND_HELMET"
                        - ^equip <entry[BodyGuard].created_npc> hand:i@BodyguardSword
                        - ^execute as_server "sentry equip DIAMOND_CHESTPLATE"
                        - ^execute as_server "sentry equip DIAMOND_LEGGINGS"
                        - ^execute as_server "sentry equip DIAMOND_BOOTS"
                        - ^execute as_server "sentry respawn -1"
                        - ^execute as_server "sentry follow 5"
                        - ^execute as_server "sentry speed 1.0"
                        - ^execute as_server "sentry healrate 10"
                        - ^execute as_server "sentry ignore add entity:PIG_ZOMBIE"
                        - ^execute as_server "npc assignment --set BodyguardAssignment"
                        - ^execute as_server "npc owner <player.name>"
                        - ^execute as_server "sentry guard <player.name>"
                        - narrate "<red>You give <npc.name> $<npc.constant[BodyguardCost]>"
                        - narrate "<green><npc.name>:<gold> He is yours untill he dies, be safe out there."
                        - wait 1
                        - narrate "<green><npc.name>:<gold> Right click on him to tell him to follow you or stand in that spot"
                        - disengage
                        }

                2:
                    trigger: <gold>I am interested in purchasing a bodyguard that /respawns/.
                    script:
                    - engage
                    - narrate "<green><npc.name>:<gold> Alright that will be $<npc.constant[BodyguardRespawnCost]>."
                    - if <player.money> < <npc.constant[BodyguardRespawnCost]> {
                        - narrate "<green><npc.name>:<gold> You do not have enough money, please come back when you have enough."
                        - disengage
                        } else {
                        - take money qty:<npc.constant[BodyguardRespawnCost]>
                        - flag player Bodyguard2
                        - create player BodyGuard <player.location> save:BodyGuard
                        - flag player Bodyguard:<entry[BodyGuard].created_npc> duration:15
                        - ^execute as_server "npc select <player.flag[BodyGuard].replace[n@]>"
                        - ^execute as_server "trait sentry"
                        - ^execute as_server "sentry equip DIAMOND_HELMET"
                        - ^equip <entry[BodyGuard].created_npc> hand:i@BodyguardSword
                        - ^execute as_server "sentry equip DIAMOND_CHESTPLATE"
                        - ^execute as_server "sentry equip DIAMOND_LEGGINGS"
                        - ^execute as_server "sentry equip DIAMOND_BOOTS"
                        - ^execute as_server "sentry respawn 300"
                        - ^execute as_server "sentry follow 5"
                        - ^execute as_server "sentry speed 1.0"
                        - ^execute as_server "sentry healrate 10"
                        - ^execute as_server "sentry ignore add entity:PIG_ZOMBIE"
                        - ^execute as_server "npc assignment --set BodyguardAssignment"
                        - ^execute as_server "npc owner <player.name>"
                        - ^execute as_server "sentry guard <player.name>"
                        - narrate "<red>You give <npc.name> $<npc.constant[BodyguardRespawnCost]>"
                        - narrate "<green><npc.name>:<gold> Your bodyguard will respawn after 5 minutes if it dies."
                        - wait 1
                        - narrate "<green><npc.name>:<gold> Right click on him to tell him to follow you or stand in that spot"
                        - disengage
                        }

                3:
                    trigger: <gold>I am interested in purchasing a bodyguard that /instantly/ respawns.
                    script:
                    - engage
                    - narrate "<green><npc.name>:<gold> Alright that will be $<npc.constant[BodyGuardInstant]>."
                    - if <player.money> < <npc.constant[BodyGuardInstant]> {
                        - narrate "<green><npc.name>:<gold> You do not have enough money, please come back when you have enough."
                        - disengage
                        } else {
                        - take money qty:<npc.constant[BodyGuardInstant]>
                        - flag player Bodyguard2
                        - create player BodyGuard <player.location> save:BodyGuard
                        - flag player Bodyguard:<entry[BodyGuard].created_npc> duration:15
                        - ^execute as_server "npc select <player.flag[BodyGuard].replace[n@]>"
                        - ^execute as_server "trait sentry"
                        - ^execute as_server "sentry armor 2"
                        - ^execute as_server "sentry equip DIAMOND_HELMET"
                        - ^equip <entry[BodyGuard].created_npc> hand:i@BodyguardSword
                        - ^execute as_server "sentry equip DIAMOND_CHESTPLATE"
                        - ^execute as_server "sentry equip DIAMOND_LEGGINGS"
                        - ^execute as_server "sentry equip DIAMOND_BOOTS"
                        - ^execute as_server "sentry respawn 1"
                        - ^execute as_server "sentry follow 5"
                        - ^execute as_server "sentry speed 1.0"
                        - ^execute as_server "sentry healrate 5"
                        - ^execute as_server "sentry ignore add entity:PIG_ZOMBIE"
                        - ^execute as_server "npc assignment --set BodyguardAssignment"
                        - ^execute as_server "npc owner <player.name>"
                        - ^execute as_server "sentry guard <player.name>"
                        - narrate "<red>You give <npc.name> $<npc.constant[BodyGuardInstant]>"
                        - narrate "<green><npc.name>:<gold> Your bodyguard will respawn right away if it dies."
                        - wait 1
                        - narrate "<green><npc.name>:<gold> Right click on him to tell him to follow you or stand in that spot"
                        - disengage
                        }

                4:
                    trigger: <gold>/No/, I dont want a bodyguard right now
                    script:
                    - engage
                    - random {
                        - narrate "<green><npc.name>:<gold> Alright come back if you change your mind."
                        - narrate "<green><npc.name>:<gold> You know where to find me if you get yourself in over your head"
                        }
                    - disengage

BodyguardAssignment:
    type: assignment
    debug: false
    actions:
        on death:
        - flag player Bodyguard:!
        - flag player Bodyguard2:!
        - flag npc guarding:!
        on click:
        - if <npc.owner> != <player> {
            - narrate "<green><npc.name>:<gold> Im sorry im not your bodyguard."
            } else if "<npc.flag[Guarding]>" == "true" {
            - narrate "<green><npc.name>:<gold> I will guard this spot, talk to me again if you wish for me to follow you again."
            - ^execute as_npc "npc sel <npc.id>"
            - ^execute as_npc "sentry guard"
            - ^flag npc "Guarding:false"
            } else {
            - narrate "<green><npc.name>:<gold> Alright i will follow you"
            - ^execute as_npc "npc sl <npc.id"
            - ^execute as_npc "sentry guard <player.name>"
            - ^flag npc "guarding:true"
            }

BodyguardSword:
    type: item
    material: DIAMOND_SWORD
    enchantments:
        - KNOCKBACK:2