Player Reputation


Author: PrimerBlock
Created: 2013-05-02T08:59:09-0400
Edited: 2014-01-30T02:53:38-0500
Denizen Version: 0.9.4
Views: 90
Downloads: 1008
Likes: 1


WGET
Description: This is a pretty simple script that shows some of what can be done with a denizen world script.
The script reputation.yml gives all players logging in a "reputation" which in this case starts off neutral at 500 reputation points. In the game players can add and subtract reputation points by helping NPCs or hurting NPCs. Players can look up their current reputation buy using the command /showrep which will display a number and a graphical representation of their reputation.
This script is just the starting point for enabling player reputations. Your other NPC scripts will also need to be edited to change the player's reputation. For example you may have a shopkeeper script where a player is allowed to kill the shopkeeper. Just add the following to your assignment script

on death:
- ^flag player reputation:-:20
- chat "I<&sq>ll get my revenge!"

or a player helps the shop keeper in a quest then add

- ^flag player reputation:+:1

in the player reward section of the script.

Of course this script or concept can be modified in many different ways such as tracking a player's karma or luck. You could create a RPG player system where a player can take various routes that either lead to good, evil or something in between.

# This script gives the player a chance to select a player class
# using the mcmmo plugin. 
#
# Todo:
# 1. Offer four basic classes (Archer, Swordsman, Axeman, MerchantFarmer) done
# 2. Players in the following groups are exempt: VIP, Moderator, Admin done
# 3. Offer the ability to change a player's prefix based on a set number of options
# 4. Keep movement commands separate so they can be enabled and disabled 
# 5. Make the npc killable and make that effect the player's "reputation"
# 6. Allow a player to ask about their current "reputation." done
# 7. Add Job and or quests for the player
#
# Author: PrimerBlock
# April 14, 2013
# Fixed some tags Jan 27, 2014
# Found many more problems upgrading to denizen 0.9.4 Jan 29, 2014

"The Guild House":
    type: assignment
    interact scripts: 
    - 10 First visit to the Guild House
    - 20 Visit to the Guild House
    - 30 Choose my player class
    - 90 SetupFlagsMCMMOCLASSES
    
    default constants:
        ClassPrice: 500
        
    actions:
        on assignment:
        - trigger name:chat toggle:true
        - trigger name:click toggle:true
        - lookclose toggle:true

"First visit to the Guild House":
    type: interact
    
    requirements:
        Mode: All
        List: 
        - -FLAGGED PLAYER 'GuildHouseVisited:true'

    steps:
        'FirstWelcomeGuildHouse*':
        
            click trigger:
                script:
                - chat "<blue>Welcome visitor to the <gold>Guild House."
                - wait 0.5
                - narrate "<blue>I<&sq>m <light_purple><npc.name><blue> the <gold>Guild House <blue>Master."
                - wait 0.5
                - narrate "<blue>Here at the <gold>Guild House <blue>you can choose or change your"
                - wait 0.5
                - narrate "<blue>player class to your liking for a small fee. We also provide"
                - wait 0.5
                - narrate "<blue>guild members jobs or quests as they become available."
                - wait 0.5
                - narrate "<blue>I can see from my records that your name is <light_purple><player.name><blue>."
                - wait 0.5
                - narrate "<blue>Well, <light_purple><player.name> <blue>what would you like to do today?"
                - wait 0.5
                - narrate ""
                - narrate " <blue> - You can <green>Choose <blue>a class"
                - narrate " <blue> - Have me <green>Explain <blue>the classes"
                - narrate " <blue> - I can list the available <green>Jobs <blue>or <green>Quests<blue>"
                - narrate " <blue> - I can show you your <green>Reputation<blue>"
                - narrate " <blue> - Or you can <green>quit <blue>and leave."
                - wait 0.5
                - narrate "<dark_gray>[Hint<&co> choose, explain, job, rep, quit]"
                - flag player "GuildHouseVisited:true"

"Visit to the Guild House":
    type: interact
    
    requirements:
        Mode: All
        List: 
        - FLAGGED PLAYER 'GuildHouseVisited:true'

    steps:
        'WelcomeToTheGuildHouse*':
        
            click trigger:
                script:
                - chat "<blue>Hello, <light_purple><player.name><blue>. What would you like to do today?"
                - inject script:GuildHouseMenu
                - narrate "<dark_gray>[Hint<&co> choose, explain, job, rep, quit]"
                
            chat trigger:
                'ChooseAClass':
                    trigger: "I<&sq>ll /choose/ a player class now."
                    script:
                    - chat "<blue>The cost to join or switch a class is <green><cons:ClassPrice> <blue><player.money.currency>."
                    - chat "<blue>Here is the list of available classes<&co>"
                    - run 'loop through' "context:ListMCMMOCLASSES|GuildClasses|global"
                    - narrate "<red>Enter class name exactly as shown, lettercase matters."
                    - narrate "<dark_gray>[Hint<&co> <&dq>class name<&dq>, explain, quit]"
                    - ^flag player "GuildHouseChooseClass:true" "duration:120"
                    - ^zap "step:Tell Choice" "script:Choose my player class"
                    
                'ExplainAvailableClasses':
                    trigger: "Could you /explain/ the available classes?"
                    script:
                    - chat "<blue>No problem I<&sq>ll briefly explain."
                    - inject script:ExplainClasses
                    - ^narrate "<dark_gray>[Hint<&co> choose, explain, job, rep, quit]"
                
                'LookingForAJob':
                    trigger: "I<&sq>m looking for a /job/ or /quest/. What do you have?"
                    script:
                    # This is just a stub for now
                    - chat "<blue>Sorry, no jobs available at this time. Check back later"
                    - narrate ""
                    - narrate "<dark_gray>[Hint<&co> choose, explain, job, rep, quit]"
                
                'WhatsMyReputation':
                    trigger: "I'm curious. What is my /rep/utation?"
                    script:
                    - chat "<blue>Your reputation is important and effects how NPCs react and deal with you."
                    - narrate "<blue>Your current reputation is<&co> <yellow> <player.flag[reputation].as_int>"
                    - narrate ""
                    - narrate "<dark_gray>[Hint<&co> choose, explain, job, rep, quit]"
                
                'QuitGuildHouse':
                    trigger: "I have to go. I<&sq>m /quit/ting for now."
                    script:
                    - chat "<blue>I<&sq>ll note your changes. See you later."
                    - execute as_server "denizen save"
 
                # After successfully changing class
                # - flag player "Thankyou:true" duration:15
                'Thankyou':
                    trigger: "/Thank/ you for your help"
                    script:
                    - if <flag.p:Thankyou> = true run "script:yourwelcome"
                      else chat "Your welcome... I guess? It was really nothing"
 
                # This script is for testing only. Disable when released.
                'ResetClassFlags':
                    trigger: "/Reset/ flags"
                    script:
                    - if <player.is_op> == true run "script:ResetMCMMOFlags"

"Choose my player class":
    type: interact
    
    requirements:
        Mode: All
        List: 
        - FLAGGED PLAYER 'GuildHouseVisited:true'
        - FLAGGED PLAYER 'GuildHouseChooseClass:true'
        
    steps:
        'Tell Choice*':
            click trigger:
                script:
                - chat "<blue>Select a class <light_purple><player.name>."
                - inject 'loop through' "context:ListMCMMOCLASSES|GuildClasses|global"
                - narrate "<red>Enter class name exactly as shown, lettercase matters."
                - narrate "<dark_gray>[Hint<&co> <&dq>class name<&dq>, explain, quit]"
                - ^flag player "GuildHouseChooseClass:true" "duration:120"
            
            chat trigger:
                'Forget it I wont switch classes':
                    trigger: /quit/
                    script:
                    - narrate "Nevermind, I don<&sq>t want to switch classes right now."
                    - flag player "GuildHouseChooseClass:!"
                    - chat "<blue>OK, what do you want to do then?"
                    - inject script:GuildHouseMenu
                    - narrate "<dark_gray>[Hint<&co> choose, explain, job, rep, quit]"
                    - flag player "GuildHouseChooseClass:!"
                    
                'ExplainClassAgain':
                    trigger: "Could you /explain/ the available classes again?"
                    script:
                    - chat "<blue>No problem, here you go<&co>"
                    - inject script:ExplainClasses
                    - narrate "<dark_gray>[Hint<&co> <&dq>class name<&dq>, explain, quit]"
                    
                'When I grow up Ill be':
                    trigger: /REGEX:\w+/
                    script:
                    - if <player.group[<player.chat_history>]> == true
                      run script:AlreadyInClass
                      else if <player.money> < <cons:ClassPrice>
                      run script:NotEnoughMoneyToSwitchClass
                      else if <player.group[admin]> == true
                      run script:NotAnApprovedClass
                      else if <player.group[guest]> == true
                      run script:NotAnApprovedClass
                      else if <player.group[vip]> == true
                      run script:NotAnApprovedClass
                      else if <player.group[moderator]> == true
                      run script:NotAnApprovedClass
                      else if <player.group[moderatoronduty]> == true
                      run script:NotAnApprovedClass
                      else if <global.flag[GuildClasses].aslist> contains '<context.message>'
                      inject script:SwitchPlayerGroup
                      else run script:DontUnderstandThatClass
                    
"DontUnderstandThatClass":
    type: task
    script:
        - chat "<blue>Sorry, can<&sq>t switch you to <green><player.chat_history><blue>."
        - narrate "<dark_gray>[Hint<&co> <&dq>class name<&dq>, explain, quit]"
        - zap "step:Tell Choice" "script:Choose my player class"
        
"NotEnoughMoneyToSwitchClass":
    type: task
    script:
        - chat "<red>Sorry, you don't have enough <player.money.currency>."
        - narrate "<red>To join or switch a class it costs <green><cons:ClassPrice> <red><player.money.currency>."
        - narrate "<red>You only have <green><player.money> <red><player.money.currency>."
        - narrate "<dark_gray>[Hint<&co> choose, explain, job, rep, quit]"
        - flag player "GuildHouseChooseClass:!"
 
        
"NotAnApprovedClass":
    type: task
    script:
        - chat "<red>Sorry, your in the wrong group to switch classes."
        - narrate "<red>If you think this is in error contact the administrator or if"
        - narrate "<red>you are a guest your account needs to be updated before"
        - narrate "<red>switching classes."
        - narrate "<yellow>Did you agree to the rules and become a member?"
        - narrate "<dark_gray>[Hint<&co> choose, explain, job, rep, quit]"
        - flag player "GuildHouseChooseClass:!"
        
"AlreadyInClass":
    type: task
    script:
        - chat "Your already in the class <player.chat_history>!"
        - narrate "<dark_gray>[Hint<&co> <&dq>class name<&dq>, explain, quit]"
        - zap "step:Tell Choice" "script:Choose my player class"
        
"SwitchPlayerGroup":
    type: task
    script:
        - narrate "<green><cons:ClassPrice> <blue><player.money.currency> has been removed from your account."
        - ^take money "qty:<cons:ClassPrice>"
        - narrate "Changing class to <context.message>"
        - execute as_server "pex user <player.name> group set <context.message>"
        - chat "<light_purple><player.name> <blue>you are all ready to go."
        - inject script:GuildHouseMenu
        - narrate "<dark_gray>[Hint<&co> choose, explain, job, rep, quit]"
        - flag player "GuildHouseChooseClass:!"
        - flag player "Thankyou:true" duration:30
                    
"ResetMCMMOFlags":
    type: task
    script:
        - chat "<blue>Sounds like you know what you are doing."
        - chat "<red>Clearing Class Names"
        - flag global "GuildClasses:!"
        - chat "<red>Clearing Class Descriptions"
        - flag global "GuildClassesDesc:!"
        - chat "<red>Clearing Class Classes Assigned Flag"
        - flag global "GuildClassesAssigned:!"
        - chat "<red>Clearing This Player<&sq>s Guild Visit Status"
        - flag player "GuildHouseStatus:!"
        - narrate ""
        - narrate "<dark_gray>[Hint<&co> choose, explain, job, rep, quit]"

"ExplainClasses":
    type: task
    script:
        - narrate "<blue>Switching classes adds the ability for you to have different"
        - narrate "<blue>skills and jobs for each different class. To switch or join a"
        - narrate "<blue>class it costs <green><cons:ClassPrice> <player.money.currency><blue>."
        - narrate "<gray>===================================================="
        - narrate "<white>Class <light_purple> of Squirrel<blue>- <yellow>Skill"
        - narrate "<gray>===================================================="
        - inject DescMCMMOCLASSES

"ListMCMMOCLASSES":
    type: task
    context: classname
    script:
    - narrate "<context.classname>"
    
"DescMCMMOCLASSES":
    type: task
    script:
    - narrate "<white>katniss <light_purple>Squirrel <blue>-<yellow>Archery"
    - narrate "<white>warrior <light_purple>Squirrel <blue>-<yellow>Swordsman"
    - narrate "<white>tree <light_purple>Squirrel <blue>-<yellow>Axeman/Lumberjack"
    - narrate "<white>gatherer <light_purple>Squirrel <blue>-<yellow>Farmer/Merchant"
    - narrate "<white>ground <light_purple>Squirrel <blue>-<yellow>Miner/Builder"
    - narrate "<white>gray <light_purple>Squirrel <blue>-<yellow>Blacksmith"
    - narrate "<white>member <light_purple>Squirrel <blue>-<yellow>Back to default player account"
    
"SetupFlagsMCMMOCLASSES":
    type: interact
    requirements:
        Mode: All
        List: 
        - -flagged global 'GuildClassesAssigned:true'
    steps:
        1:
            click trigger:
                script:
                - chat "<blue>Excuse me a moment, I'll be right with you in a second."
                # need to look down here
                - flag global "GuildClassesAssigned:true"
                - flag global "GuildClasses:->:katniss"
                - flag global "GuildClasses:->:warrior"
                - flag global "GuildClasses:->:tree"
                - flag global "GuildClasses:->:gatherer"
                - flag global "GuildClasses:->:ground"
                - flag global "GuildClasses:->:gray"
                - flag global "GuildClasses:->:member"
                - execute as_server "denizen save"
                # need a look close here
                - chat "<blue>OK, thanks for waiting. Click me whenever you are ready."
                
"GuildHouseMenu":
    type: task
    script:
        - narrate " <blue> - <green>Choose <blue>a class"
        - narrate " <blue> - Have me <green>Explain <blue>the classes"
        - narrate " <blue> - See the list of available <green>Jobs <blue>or <green>Quests"
        - narrate " <blue> - Show you your <green>Reputation"
        - narrate " <blue> - <green>Quit <blue>and leave."
 
 




Comments
2013-08-19 05:13:18 - niels2398:

doesn't seem to wurk if I do the /showrep command it give flag.p:reputation can enywhan help?
2013-08-19 05:31:48 - niels2398:

doesn't seem to wurk if I do the /showrep command it give flag.p:reputation can enywhan help?
2013-08-19 05:32:01 - niels2398:

doesn't seem to wurk if I do the /showrep command it give flag.p:reputation can enywhan help?
2014-01-30 04:18:31 - PrimerBlock:

Log off and then back on. On join you will be given a "reputation" flag then it should work.