Staff Pick: Bodyguard Salesman
By
CromisCreated: 2015/05/09 06:55:23 UTC-07:00 (9 years and 230 days ago)
Edited: 2015/06/16 14:49:16 UTC-07:00 (9 years and 191 days ago)
Likes: 0
Staff pick as of: 2015/05/18 13:41:29 UTC-07:00 (9 years and 220 days ago)
Denizen Version: 0.9.6-b1575
Script Version: 1.1.4
Description:
-- Update 1.1.4 is here! --
Added command /TpGuard for players to teleport their guard to them
If you are updating i HIGHLY recommend you turn off your server first to prevent any issues that may happen if you dont. You have been warned.
Requires the Sentry plugin (for now)
Check back every now and again for updates untill i feel its complete
BodyguardSalesMan is a assignment script that you assign to a npc to sell bodyguards
At the moment it is rather limited, will add more as time goes on.
To change the cost of a bodyguard just change the default constant of the one you wish to change the price of
Currently has 3 types of guards
Normal - does not respawn cost $20
Respawns - respawn time 5 minutes cost $2,000
Instantly - respawns after 1 second cost $20,000
Download script |
View raw script# This script was written by Cromis.
# This script requires the plug-ins Citizens, Denizen and Sentry.
#
# It is a assignment script for a salesman that sells bodyguards.
# To get this to work on your server put this script into your servers denizen/scripts folder.
# In the section below the world script inside the default constants you will see BGSpawnLocation: <w@world.spawn_location>
# You will want to change "world" to whatever your main world is. Having it at the spawnpoint helps as
# The spawn is always loaded which helps with spawning and despawning of bodyguards.
# Save changes you have made to the script.
# Reload denizen scripts with /denizen reload scripts.
# Then select the npc you wish to sell the bodyguards and give it the assignment BgSalesMan.
# After that you are all set. I would recommend you read through the first little bit of these comments
# Before putting this on your live server.
#
#
# With this script the player is limited to one bodyguard. If you wish to have more you can either edit this script if you know how
# Or wait for me to get around to making a new script for that which I will link in the description when its complete.
# If you know how feel free to use this script/edit as you wish alls I ask is you give me credit.
# This is the world script that handles the spawning and despawning of bodyguards.
# This helps prevent having a bulk of bodyguards standing in the same area which will be
# Whatever you have the spawnpoint set to which is the world spawn by default.
# This is the format script for the script to use.
# Remove the # on the next 3 lines if you do not have a format code
#F1:
# type: format
# format: <green><npc.name><&co> <gold><text>
BodyguardWS:
type: world
debug: false
events:
on player join:
# When a player joins the server it checks if the have any of the bodyguard flags.
- if <player.has_flag[bodyguard]> {
# If the player has the flag bodyguard1 which is the non respawning bodyguard it will follow this if path.
- if <player.has_flag[bodyguard1]> {
- wait 1s
# This is where the npc is spawned back in so it can be used again.
- ^spawn <player.flag[BodyGuard]> <s@BodyguardSalesMan.constant[BGSpawnLocation]>
# Now to select the npc to give it back everything it needs.
- ^execute as_server "npc sel <player.flag[BodyGuard].replace[n@]>"
- if <server.selected_npc> != <player.flag[BodyGuard]> {
- narrate "<red>ERROR: Npc number does not match selected Npc Please contact an admin."
- queue clear
} else {
# First to give back the sentry trait
- if !<server.selected_npc.has_trait[sentry]> {
- ^execute as_server "trait sentry"
}
# Turning off sentry criticals
- ^execute as_server "sentry criticals false"
# Now to set it so it doesnt resapwn after its death as this bodyguard type does not respawn
- ^execute as_server "sentry respawn -1"
# Keep that bodyguard from following so close!
- ^execute as_server "sentry follow 5"
# Sets the speed of the bodyguard while in combat.
- ^execute as_server "sentry speed 1.0"
# Sets how fast the bodyguard will heal.
- ^execute as_server "sentry healrate 10"
# Now to tell the bodyguard to attack any monster within its range.
- ^execute as_server "sentry target add entity:monster"
# Adding pigmen to the ignore list so they don't go aggroing them.
- ^execute as_server "sentry ignore add entity:pig_zombie"
# If BodyGuardPvp is set to false the bodyguard will be told to ignore players.
- if <s@BodyguardSalesMan.constant[BodyGuardPvp]> == false {
- ^execute as_server "sentry ignore add entity:player"
# If BodyGuardPvp is set to true it will remove players from the ignore list.
# If bodyguards do not fight players you might want to check the sentry config.
} else {
- ^execute as_server "sentry ignore remove entity:player"
}
# If the player has the flag BGGuarding it will have the sentry guard the player
- if <player.has_flag[BGGuarding]> {
# Tells the bodyguard to start guarding the player.
- ^execute as_server "sentry guard <player.name>"
}
}
# If the player has the flag bodyguard2 which is the bodyguard that respawns after 5 minutes it will follow this if path.
} else if <player.has_flag[Bodyguard2]> {
- wait 1s
# Spawn in the bodyguard so it can be used.
- ^spawn <player.flag[BodyGuard]> <s@BodyguardSalesMan.constant[BGSpawnLocation]>
# Selects the bodyguard to apply the changes it needs
- ^execute as_server "npc sel <player.flag[BodyGuard].replace[n@]>"
- if <server.selected_npc> != <player.flag[BodyGuard]> {
- narrate "<red>ERROR: Npc number does not match selected Npc Please contact an admin."
- queue clear
} else {
# First to give back the sentry trait
- if !<server.selected_npc.has_trait[sentry]> {
- ^execute as_server "trait sentry"
}
# Turning off sentry criticals
- ^execute as_server "sentry criticals false"
# Sets the respawn after death to 5 minutes.
- ^execute as_server "sentry respawn 300"
# Sets the follow distance to 5 so it doesnt follow the player so close.
- ^execute as_server "sentry follow 5"
# Sets the speed of the bodyguard while in combat.
- ^execute as_server "sentry speed 1.0"
# Sets how fast the bodyguard will heal.
- ^execute as_server "sentry healrate 10"
# Now to tell the bodyguard to attack any monster within its range.
- ^execute as_server "sentry target add entity:monster"
# Adding pigmen to the ignore list so they don't go aggroing them.
- ^execute as_server "sentry ignore add entity:pig_zombie"
# If BodyGuardPvp is set to false the bodyguard will be told to ignore players.
- if <s@BodyguardSalesMan.constant[BodyGuardPvp]> == false {
- ^execute as_server "sentry ignore add entity:player"
# If BodyGuardPvp is set to true it will remove players from the ignore list.
# If bodyguards do not fight players you might want to check the sentry config.
} else {
- ^execute as_server "sentry ignore remove entity:player"
}
# If the player has the flag BGGuarding it will have the sentry guard the player
- if <player.has_flag[BGGuarding]> {
# Tells the bodyguard to start guarding the player.
- ^execute as_server "sentry guard <player.name>"
}
}
# If the player has the flag bodyguard2 which is the bodyguard that respawns after 5 minutes it will follow this if path.
} else if <player.has_flag[bodyguard3]> {
- wait 1s
# Spawns in the bodyguard so it can be used.
- ^spawn <player.flag[BodyGuard]> <s@BodyguardSalesMan.constant[BGSpawnLocation]>
# Selects the bodyguard so it can be given back its stats/trait
- ^execute as_server "npc sel <player.flag[BodyGuard].replace[n@]>"
- if <server.selected_npc> != <player.flag[BodyGuard]> {
- narrate "<red>ERROR: Npc number does not match selected Npc Please contact an admin."
- queue clear
} else {
# First to give back the sentry trait
- if !<server.selected_npc.has_trait[sentry]> {
- ^execute as_server "trait sentry"
}
# Turning off sentry criticals
- ^execute as_server "sentry criticals false"
# Sets the Bodyguards armor to a base value of 2. Shhhh.
- ^execute as_server "sentry armor 2"
# Sets the bodyguard to respawn 1 second after its death.
- ^execute as_server "sentry respawn 1"
# Sets the follow distance to 5 so it dosent follow so close.
- ^execute as_server "sentry follow 5"
# Sets the speed of the bodyguard while in combat.
- ^execute as_server "sentry speed 1.0"
# Sets how fast the bodyguard will heal.
- ^execute as_server "sentry healrate 5"
# Now to tell the bodyguard to attack any monster within its range.
- ^execute as_server "sentry target add entity:monster"
# Adding pigmen to the ignore list so they don't go aggroing them.
- ^execute as_server "sentry ignore add entity:pig_zombie"
# If BodyGuardPvp is set to false the bodyguard will be told to ignore players.
- if <s@BodyguardSalesMan.constant[BodyGuardPvp]> == false {
- ^execute as_server "sentry ignore add entity:player"
# If BodyGuardPvp is set to true it will remove players from the ignore list.
# If bodyguards do not fight players you might want to check the sentry config.
} else {
- ^execute as_server "sentry ignore remove entity:player"
}
# If the player has the flag BGGuarding it will have the sentry guard the player
- if <player.has_flag[BGGuarding]> {
# Tells the bodyguard to start guarding the player.
- ^execute as_server "sentry guard <player.name>"
}
}
}
}
on player quits:
# When the player quits if they have they bodyguard flag it will do whats in this if statement
- if <player.has_flag[bodyguard]> {
# The Bodyguard will be selected
- execute as_server "npc sel <player.flag[BodyGuard].replace[n@]>"
- if <server.selected_npc.has_trait[sentry]> {
# The sentry trait is removed so it can be despawned
- execute as_server "trait sentry"
}
# The Bodyguard is despawned
- execute as_server "npc despawn"
}
BodyguardSalesMan:
type: assignment
debug: false
# This is where most of the things you would want to change will be.
default constants:
# This is the format the npc will take when it talks to you change it to the format script you use.
# If you don't use a format script I recommend you make one it makes things pretty and so much easier. http://mcmonkey.org/denizen/tuts/format
# Or you can go through this script and remove every "format:<npc.constant[NpcFormat]>" in this script along with the NpcFormat line below this.
NpcFormat: F1
# If you want bodyguards to get involved in pvp set this to true.
BodyGuardPvp: false
# This is the location the bodyguard will spawn in.
# I recommend you put this at the server spawn by changing "world" to your servers world name or change it to <player.location>.
# If you put it to <player.location> the bodyguards will spawn where the player is standing but I recommend you use the world spawn.
# If the location is in a unloaded area it can cause issues.
BGSpawnLocation: <w@world.spawn_location>
# This is the cost of the bodyguard that does not re-spawn. Change it to whatever price you wish.
BodyGuardCost: 20
# This is the cost of the bodyguard that re-spawns after 5 minutes. Change it to whatever price you wish.
BodyGuardRespawnCost: 2000
# This is the cost of the bodyguard that re-spawns after 1 second. Change it to whatever price you wish.
BodyGuardInstant: 20000
# Below this is the equipment the bodyguards will use.
# This is the weapon the bodyguards will use a knockback 2 diamond sword change it if you wish.
BodyGuardWeapon: hand:i@BodyguardSword
# This is the helmet the bodyguards will use change it to whatever you like.
BodyGuardHelm: head:i@DIAMOND_HELMET
# This is the chestplate the bodyguards will use change it to whatever you like.
BodyGuardChest: chest:i@DIAMOND_CHESTPLATE
# This is the platelegs the bodyguards will use change it to whatever you like.
BodyGuardLegs: legs:i@DIAMOND_LEGGINGS
# This is the boots the bodyguards will use change it to whatever you like.
BodyGuardBoots: boots:i@DIAMOND_BOOTS
# I would not recommend changing anything past this point unless you know what you are doing/changing.
interact scripts:
- 10 BgSalesMan
# This is The script the npc that sells the bodyguards uses.
BgSalesMan:
type: interact
steps:
1:
click trigger:
script:
# If the player has the bodyguard that respawns after 5 minutes they may want to eventually upgrade
# Previously players were not able to upgrade the bodyguards with this script, now they can.
# If the player has the flag for the bodyguard that respawns after 5 minutes it will zap them to the upgrade step
- if <player.has_flag[Bodyguard2]> {
# Tells the player how much it will cost to upgrade the bodyguard. Yay math.
- narrate format:<npc.constant[NpcFormat]> "It will cost $<npc.constant[BodyGuardInstant].sub[<npc.constant[BodyGuardRespawnCost]>]> to upgrade your bodyguard."
- wait 1
- narrate format:<npc.constant[NpcFormat]> "Speak to me again when you are ready to upgrade your bodyguard."
- zap step:BGUpgrade
# If the player already has a bodyguard they will not be able to get another.
} else if <player.has_flag[Bodyguard1]> {
- narrate format:<npc.constant[NpcFormat]> "You already have a bodyguard, Come back if he dies."
} else if <player.has_flag[Bodyguard3]> {
- narrate format:<npc.constant[NpcFormat]> "You already have a bodyguard, Come back if he dies."
} else {
# If the player does not have a bodyguard already the npc will let the player know what kind of bodyguards he is selling.
- narrate format:<npc.constant[NpcFormat]> "Hello <player.name> Welcome to my shop."
- wait 1
- narrate format:<npc.constant[NpcFormat]> "As of this moment I only have three types of bodyguard available."
- wait 1
- narrate format:<npc.constant[NpcFormat]> "Would you like to hire a <green>normal<gold> bodyguard for $<npc.constant[BodyGuardCost]>?"
- wait 1
- narrate format:<npc.constant[NpcFormat]> "Or would you like one that <green>respawns<gold> for $<npc.constant[BodyGuardRespawnCost]> or one that respawns <green>instantly<gold> for $<npc.constant[BodyGuardInstant]>?"
}
# Now the npc will wait for a little bit for the player to type in chat which guard it wants.
chat trigger:
# If the player wants a bodyguard that does not respawn after death they will say "normal" in chat near the salesman.
1:
trigger: <gold>I am interested in purchasing a /normal/ bodyguard.
script:
# At this point the salesman will let the player know the cost of the bodyguard.
- engage
- narrate format:<npc.constant[NpcFormat]> "Alright that will be $<npc.constant[BodyGuardCost]>."
# Now it checks if the player has enough for the bodyguard.
- if <player.money> < <npc.constant[BodyGuardCost]> {
# If the player does not have enough money the npc will tell the player to come back when they have enough cash.
- narrate format:<npc.constant[NpcFormat]> "You do not have enough money, please come back when you have enough."
- disengage
} else {
# If the player has enough money the salesman will now take that amount from them.
- take money qty:<npc.constant[BodyGuardCost]>
# The player is now flagged with the Bodyguard1 flag the flag for a non respawning bodyguard.
- flag player Bodyguard1
# Now to create the npc that will soon be the players bodyguard.
- create player BodyGuard save:BodyGuard
# Flagging the player with the npc number this helps a lot with selecting the npc later on.
- flag player Bodyguard:<entry[BodyGuard].created_npc>
# Spawn in the bodyguard at the servers spawn or wherever you changed its spawnpoint to.
- ^spawn <player.flag[BodyGuard]> <npc.constant[BGSpawnLocation]>
# Going back to what I just said now to select the npc that will be the bodyguard for the player.
- ^execute as_server "npc select <player.flag[BodyGuard].replace[n@]>"
# Time to give it the sentry trait.
# Later on I plan on removing the need for the sentry plug-in just not now.
- ^execute as_server "trait sentry"
# Time to give it some equipment first the weapon.
- ^equip <entry[BodyGuard].created_npc> <npc.constant[BodyGuardWeapon]>
# Now for the helmet.
- ^equip <entry[BodyGuard].created_npc> <npc.constant[BodyGuardHelm]>
# Now for the chestplate.
- ^equip <entry[BodyGuard].created_npc> <npc.constant[BodyGuardChest]>
# Now for the platelegs.
- ^equip <entry[BodyGuard].created_npc> <npc.constant[BodyGuardLegs]>
# And finally the boots.
- ^equip <entry[BodyGuard].created_npc> <npc.constant[BodyGuardBoots]>
# Giving the bodyguard a view range of 15 it will attack any target in this range
- ^execute as_server "sentry range 15"
# Now to tell the bodyguard to attack any monster within its range.
- ^execute as_server "sentry target add entity:monster"
# Adding pigmen to the ignore list so they don't go aggroing them.
- ^execute as_server "sentry ignore add entity:pig_zombie"
# If BodyGuardPvp is set to false the bodyguard will be told to ignore players.
- if <npc.constant[BodyGuardPvp]> == false {
- ^execute as_server "sentry ignore add entity:player"
# If BodyGuardPvp is set to true it will remove players from the ignore list.
# If bodyguards do not fight players you might want to check the sentry config.
} else {
- ^execute as_server "sentry ignore remove entity:player"
}
# Since this bodyguard does not respawn after death we set its respawn timer to -1 so it does not respawn.
- ^execute as_server "sentry respawn -1"
# Sets the distance the bodyguard will follow the player to 5 that way they do not keep standing in the players face.
- ^execute as_server "sentry follow 5"
# Sets the speed of the bodyguard while in combat.
- ^execute as_server "sentry speed 1.0"
# Sets how fast the bodyguard will heal.
- ^execute as_server "sentry healrate 10"
# This is where the bodyguard is given the assignment that controls it.
- ^execute as_server "npc assignment --set BodyguardAssignment"
# Giving the player ownership of the npc.
- ^execute as_server "npc owner <player.name>"
# Now to tell the bodyguard to guard the player.
- ^execute as_server "sentry guard <player.name>"
# Flagging the player with the BGGuarding flag which will help later on.
- ^flag player BGGuarding
# Letting the player know that they have given the salesman the cost of the bodyguard
- narrate "<red>You give <npc.name> $<npc.constant[BodyGuardCost]>"
- wait 2
# Now to explain to the player how to use their new bodyguard.
- narrate format:<npc.constant[NpcFormat]> "Bodyguards have a few interactions."
- wait 2
- narrate format:<npc.constant[NpcFormat]> "Right click on him to enter order mode."
- wait 2
- narrate format:<npc.constant[NpcFormat]> "He will tell you what interactions he has."
- wait 2
- narrate format:<npc.constant[NpcFormat]> "Type in chat the option you wish to use."
- wait 2
- narrate format:<npc.constant[NpcFormat]> "If you wish to exit order mode simply right click him again."
# Letting the player know they now own the bodyguard until its death.
- narrate format:<npc.constant[NpcFormat]> "He is yours untill he dies, be safe out there."
- disengage
}
2:
# If the player wants a bodyguard that respawns after 5 minutes they will say "respawns".
trigger: <gold>I am interested in purchasing a bodyguard that /respawns/.
script:
- engage
# Tells the player the price of the bodyguard.
- narrate format:<npc.constant[NpcFormat]> "Alright that will be $<npc.constant[BodyguardRespawnCost]>."
# If the player does not have enough money the salesman will tell the player to come back when they have the money.
- if <player.money> < <npc.constant[BodyguardRespawnCost]> {
- narrate format:<npc.constant[NpcFormat]> "You do not have enough money, please come back when you have enough."
- disengage
# If the player has enough money the salesman will now take the cost of the bodyguard from the player.
} else {
- take money qty:<npc.constant[BodyguardRespawnCost]>
# Gives the player the flag for the bodyguard that repsawns after 5 minutes which helps later on.
- flag player Bodyguard2
# Now to create the npc that will soon be the players bodyguard.
- create player BodyGuard save:BodyGuard
# Flags the player with the number of the npc that will soon be the players bodyguard which helps later on.
- flag player Bodyguard:<entry[BodyGuard].created_npc>
# Spawn in the bodyguard at the servers spawn or wherever you changed its spawnpoint to.
- ^spawn <player.flag[BodyGuard]> <npc.constant[BGSpawnLocation]>
# Selects the npc that will soon be the players bodyguard.
- ^execute as_server "npc select <player.flag[BodyGuard].replace[n@]>"
# Time to make the npc into a bodyguard.
- ^execute as_server "trait sentry"
# Time to give it some equipment first the weapon.
- ^equip <entry[BodyGuard].created_npc> <npc.constant[BodyGuardWeapon]>
# Now for the helmet.
- ^equip <entry[BodyGuard].created_npc> <npc.constant[BodyGuardHelm]>
# Now for the chestplate.
- ^equip <entry[BodyGuard].created_npc> <npc.constant[BodyGuardChest]>
# Now for the platelegs.
- ^equip <entry[BodyGuard].created_npc> <npc.constant[BodyGuardLegs]>
# And finally the boots.
- ^equip <entry[BodyGuard].created_npc> <npc.constant[BodyGuardBoots]>
# Giving the bodyguard a view range of 15 it will attack any target in this range
- ^execute as_server "sentry range 15"
# Now to tell the bodyguard to attack any monster within its range.
- ^execute as_server "sentry target add entity:monster"
# Adding pigmen to the ignore list so they don't go aggroing them.
- ^execute as_server "sentry ignore add entity:pig_zombie"
# If BodyGuardPvp is set to false the bodyguard will be told to ignore players.
- if <npc.constant[BodyGuardPvp]> == false {
- ^execute as_server "sentry ignore add entity:player"
# If BodyGuardPvp is set to true it will remove players from the ignore list.
# If bodyguards do not fight players you might want to check the sentry config.
} else {
- ^execute as_server "sentry ignore remove entity:player"
}
# Sets the bodyguards to respawn 5 minutes after its death.
- ^execute as_server "sentry respawn 300"
# Setting the follow range to 5 so it doesnt follow the player too close.
- ^execute as_server "sentry follow 5"
# Sets the speed of the bodyguard to 1 while in combat.
- ^execute as_server "sentry speed 1.0"
# Sets how fast the bodyguard will heal.
- ^execute as_server "sentry healrate 10"
# Gives the bodyguard the assignment that controls it.
- ^execute as_server "npc assignment --set BodyguardAssignment"
# Gives ownership of the bodyguard to the player
- ^execute as_server "npc owner <player.name>"
# Tells the bodyguard to guard the player.
- ^execute as_server "sentry guard <player.name>"
# Flags the player with the BGGuarding flag which helps later.
- ^flag player BGGuarding
# Lets the player know that they have given the salesman the price of the bodyguard.
- narrate "<red>You give <npc.name> $<npc.constant[BodyguardRespawnCost]>"
# Now to explain to the player how to use their new bodyguard.
- narrate format:<npc.constant[NpcFormat]> "Bodyguards have a few interactions."
- wait 2
- narrate format:<npc.constant[NpcFormat]> "Right click on him to enter order mode."
- wait 2
- narrate format:<npc.constant[NpcFormat]> "He will tell you what interactions he has."
- wait 2
- narrate format:<npc.constant[NpcFormat]> "Type in chat the option you wish to use."
- wait 2
- narrate format:<npc.constant[NpcFormat]> "If you wish to exit order mode simply right click him again."
# Lets the player know the bodyguard will respawn 5 minutes after its death.
- narrate format:<npc.constant[NpcFormat]> "Your bodyguard will respawn after 5 minutes if it dies."
- disengage
}
3:
# If the player wants the bodyguard that respawns instantly the player will say "instantly" in chat.
trigger: <gold>I am interested in purchasing a bodyguard that /instantly/ respawns.
script:
- engage
# Tells the player the cost of the bodyguard.
- narrate format:<npc.constant[NpcFormat]> "Alright that will be $<npc.constant[BodyGuardInstant]>."
# If the player does not have enough money for the bodyguard the salesman will tell the player to come back when they have enough.
- if <player.money> < <npc.constant[BodyGuardInstant]> {
- narrate format:<npc.constant[NpcFormat]> "You do not have enough money, please come back when you have enough."
- disengage
# If the player does have enough money the salesman will take the price of the bodyguard from the player.
} else {
- take money qty:<npc.constant[BodyGuardInstant]>
# Gives the player the flag for the bodyguard that respawns instantly which will help out later.
- flag player Bodyguard3
# Creates the npc that will soon be the players bodyguard.
- create player BodyGuard save:BodyGuard
# Flags the player with the bodyguards npc number which will help with selecting the bodyguard later on.
- flag player Bodyguard:<entry[BodyGuard].created_npc>
# Spawn in the bodyguard at the servers spawn or wherever you changed its spawnpoint to.
- ^spawn <player.flag[BodyGuard]> <npc.constant[BGSpawnLocation]>
# Selects the soon to be bodyguard.
- ^execute as_server "npc sel <player.flag[BodyGuard].replace[n@]>"
# Gives the bodyguard the sentry trait.
- ^execute as_server "trait sentry"
# Gives the bodyguard some extra armor shhhhh dont let them know this one is stronger.
- ^execute as_server "sentry armor 2"
# Time to give it some equipment first the weapon.
- ^equip <entry[BodyGuard].created_npc> <npc.constant[BodyGuardWeapon]>
# Now for the helmet.
- ^equip <entry[BodyGuard].created_npc> <npc.constant[BodyGuardHelm]>
# Now for the chestplate.
- ^equip <entry[BodyGuard].created_npc> <npc.constant[BodyGuardChest]>
# Now for the platelegs.
- ^equip <entry[BodyGuard].created_npc> <npc.constant[BodyGuardLegs]>
# And finally the boots.
- ^equip <entry[BodyGuard].created_npc> <npc.constant[BodyGuardBoots]>
# Giving the bodyguard a view range of 15 it will attack any target in this range
- ^execute as_server "sentry range 15"
# Now to tell the bodyguard to attack any monster within its range.
- ^execute as_server "sentry target add entity:monster"
# Adding pigmen to the ignore list so they don't go aggroing them.
- ^execute as_server "sentry ignore add entity:pig_zombie"
# If BodyGuardPvp is set to false the bodyguard will be told to ignore players.
- if <npc.constant[BodyGuardPvp]> == false {
- ^execute as_server "sentry ignore add entity:player"
# If BodyGuardPvp is set to true it will remove players from the ignore list.
# If bodyguards do not fight players you might want to check the sentry config.
} else {
- ^execute as_server "sentry ignore remove entity:player"
}
# This is where we make the bodyguard respawn 1 second after its death yeah thats right 1 second.
- ^execute as_server "sentry respawn 1"
# Sthap following so close!
- ^execute as_server "sentry follow 5"
# Sets the speed of the bodyguard while its in combat.
- ^execute as_server "sentry speed 1.0"
# Sets how fast the bodyguard heals.
- ^execute as_server "sentry healrate 5"
# Gives the bodyguard the assignment that controls it.
- ^execute as_server "npc assignment --set BodyguardAssignment"
# Sets the player as the owner of the bodyguard.
- ^execute as_server "npc owner <player.name>"
# Tels the bodyguard to start guarding the player.
- ^execute as_server "sentry guard <player.name>"
# Flags the player with the BGGuarding flag which helps out later.
- ^flag player BGGuarding
# Tells the player they have given the salesman the price of the bodyguard.
- narrate "<red>You give <npc.name> $<npc.constant[BodyGuardInstant]>"
# Now to explain to the player how to use their new bodyguard.
- narrate format:<npc.constant[NpcFormat]> "Bodyguards have a few interactions."
- wait 2
- narrate format:<npc.constant[NpcFormat]> "Right click on him to enter order mode."
- wait 2
- narrate format:<npc.constant[NpcFormat]> "He will tell you what interactions he has."
- wait 2
- narrate format:<npc.constant[NpcFormat]> "Type in chat the option you wish to use."
- wait 2
- narrate format:<npc.constant[NpcFormat]> "If you wish to exit order mode simply right click him again."
- wait 2
# Lets the player know the bodyguard will respawn right away.
- narrate format:<npc.constant[NpcFormat]> "Your bodyguard will respawn right away if it dies."
- disengage
}
4:
# If the player does not want a bodyguard they will say "no" in chat.
trigger: <gold>/No/, I dont want a bodyguard right now
script:
- engage
# The salesman will choose from one of these to tell the player.
- random {
- narrate format:<npc.constant[NpcFormat]> "Alright come back if you change your mind."
- narrate format:<npc.constant[NpcFormat]> "You know where to find me if you get yourself in over your head"
}
- disengage
# This part handles the upgrade process between the 5 minute and 1 second respawning bodyguards.
BGUpgrade:
click trigger:
script:
# Asks the player if they wish to upgrade the bodyguard and tells them the cost.
- narrate format:<npc.constant[NpcFormat]> "Do you wish to upgrade your bodyguard for $<npc.constant[BodyGuardInstant].sub[<npc.constant[BodyGuardRespawnCost]>]>?"
chat trigger:
1:
# If the player wants to upgrade the bodyguard they say "yes" in chat near the salesman.
trigger: <gold>/Yes/ I would like to upgrade my bodyguard now.
script:
- engage
# Checks if the player has enough money.F
- if <player.money> < <npc.constant[BodyGuardInstant].sub[<npc.constant[BodyGuardRespawnCost]>]> {
# If they don't it asks them to come back when they have enough money.
- ^narrate format:<npc.constant[NpcFormat]> "You do not have enough money please come back when you do."
- disengage
# If they do have enough money the salesman tells them the cost and the player pays the salesman that amount.
} else {
- ^narrate format:<npc.constant[NpcFormat]> "Alright that will be $<npc.constant[BodyGuardInstant].sub[<npc.constant[BodyGuardRespawnCost]>]>"
- ^take money qty:<npc.constant[BodyGuardInstant].sub[<npc.constant[BodyGuardRespawnCost]>]>
# Selects the soon to be bodyguard.
- ^execute as_server "npc sel <player.flag[BodyGuard].replace[n@]>"
# Remove Bodyguard2 flag from the player.
- flag player Bodyguard2:!
# Gives the player the bodyguard3 flag.
- flag player Bodyguard3
# Gives the bodyguard some extra armor shhhhh dont let them know this one is stronger.
- ^execute as_server "sentry armor 2"
# Giving the bodyguard a view range of 15 it will attack any target in this range
- ^execute as_server "sentry range 15"
# This is where we make the bodyguard respawn 1 second after its death yeah thats right 1 second.
- ^execute as_server "sentry respawn 1"
# Sets how fast the bodyguard heals.
- ^execute as_server "sentry healrate 5"
- disengage
}
2:
# If the player does not wish to upgrade the bodyguard yet they say "no" near the salesman.
trigger: <gold>/No/ I would not like to upgrade my bodyguard yet.
script:
- narrate format:<npc.constant[NpcFormat]> "Alright come back if you change your mind."
# This is the assignment script that controls the bodyguards
BodyguardAssignment:
type: assignment
debug: false
default constants:
# This is the format the npc will take when it talks to you change it to the format script you use.
# If you don't use a format script I recommend you make one it makes things pretty and so much easier. http://mcmonkey.org/denizen/tuts/format
# Or you can go through this script and remove every "format:<npc.constant[NpcFormat]>" in this script along with the NpcFormat line below this.
NpcFormat: F1
interact scripts:
- 10 BgInteractions
actions:
on death:
# If the bodyguard dies the following will happen.
# Remember the flag for the bodyguard that does not respawn? Time to use it.
- if <player.has_flag[Bodyguard1]> {
# Lets the player know the bodyguard has died.
- narrate "<red> Your bodyguard has died!" targets:<npc.owner>
# Removes the bodyguard flag so they can purchase another.
- flag player Bodyguard:!
# Basicly the same thing as above.
- flag player Bodyguard1:!
# Look another flag to remove.
- flag player BGGuarding:!
# If the player has the flag for the bodyguard that reaspawns after 5 minutes it will tell the player the bodyguard has died.
} else if <player.has_flag[Bodyguard2]> {
- narrate "<red> Your bodyguard has died!" targets:<npc.owner>
# Now for the 5 minute wait.
- wait 300s
# Lets teleport the bodyguard to the player just in-case it has not already.
- teleport npc location:<npc.owner.location>
# If the player has the bodyguard that respawns instantly it will let the player know the bodyguard has died.
} else <player.has_flag[Bodyguard3]> {
- narrate "<red> Your bodyguard has died!" targets:<npc.owner>
# The long 1 second wait.
- wait 1s
# Teleports the bodyguard to the player incase it hasnt already done so.
- teleport npc location:<npc.owner.location>
}
# This is the part of the script that handels the interactions for the bodyguard with the player.
BgInteractions:
type: interact
steps:
1:
click trigger:
script:
# If the player does not own the bodyguard and right clicks on them it will let them know it is not their bodyguard.
- if <npc.owner> != <player> {
- narrate format:<npc.constant[NpcFormat]> "Im sorry im not your bodyguard."
# If the player does own the bodyguard the bodyguard will ask what the player what they want and enter order mode.
} else {
- narrate format:<npc.constant[NpcFormat]> "What would you like me to do?"
- narrate format:<npc.constant[NpcFormat]> "<red>Stand <gold>Guard, <red>Follow <gold>You, Change <red>Equipment<gold>, <red>Rename<gold> or <red>Reskin<gold>?"
- narrate format:<npc.constant[NpcFormat]> "Right click me again to cancel"
- narrate "<red>Entering Order Mode."
- ^zap step:2
}
2:
# If the player right clicks them again the bodyguard will exit order mode.
click trigger:
script:
- narrate "<red>Exiting Order Mode."
- zap step:1
chat trigger:
1:
# If the player wants the guard they will say "follow" in chat near the bodyguard.
trigger: <gold>/Follow/ me.
script:
# Remember that BGGuarding flag earlier? Time to use it
# If the player has the BGGuarding flag the bodyguard will say they are already following the player.
- if <player.has_flag[BGGuarding]> {
- random {
- narrate format:<npc.constant[NpcFormat]> "Im already following you silly."
- narrate format:<npc.constant[NpcFormat]> "I am already following you."
- narrate format:<npc.constant[NpcFormat]> "Uhm... Okay."
}
# Lets the player know order mode has ended
- narrate "<red>Exiting Order Mode."
- zap step:1
# If the bodyguard is not already following the player it will let the player know it is now following them.
} else {
- random {
- narrate format:<npc.constant[NpcFormat]> "Alright I will follow you."
- narrate format:<npc.constant[NpcFormat]> "Do i have to?"
- narrate format:<npc.constant[NpcFormat]> "Lead the way."
- narrate format:<npc.constant[NpcFormat]> "As you wish."
}
# Selects the bodyguard.
- ^execute as_npc "npc sel <npc.id>"
# Tells the bodyguard to follow the player.
- ^execute as_npc "sentry guard <player.name>"
# Gives the player the BGGuarding flag again.
- ^flag player BGGuarding
# Lets the player know order mode has ended.
- narrate "<red>Exiting Order Mode."
- zap step:1
}
2:
# If the player wants the bodyguard to stand in that spot the player will say "stand" in chat.
trigger: <gold>/Stand/ here.
script:
- if <player.has_flag[BGGuarding]> {
# Tells the player that the guard will stand in that spot.
- random {
- narrate format:<npc.constant[NpcFormat]> "I will guard this spot, talk to me again if you wish for me to follow you again."
- narrate format:<npc.constant[NpcFormat]> "I will wait here for you."
- narrate format:<npc.constant[NpcFormat]> "Dont forget about me."
- narrate format:<npc.constant[NpcFormat]> "Can I atleast get a book to read while i wait?"
}
# Selects the bodyguard.
- ^execute as_npc "npc sel <npc.id>"
# Tells the bodyguard to stop following the player.
- ^execute as_npc "sentry guard"
# Removes the BGGuarding flag from the player.
- ^flag player BGGuarding:!
# Lets the player know order mode has ended
- narrate "<red>Exiting Order Mode."
- zap step:1
# If the bodyguard is already standing guard they will let the player know.
} else {
- random {
- narrate format:<npc.constant[NpcFormat]> "I am already waiting here."
- narrate format:<npc.constant[NpcFormat]> "But I am not following you."
- narrate format:<npc.constant[NpcFormat]> "Uhh... Alright."
}
}
3:
# If the player wishes to rename the bodyguard the player will say "rename" in chat near the bodyguard.
trigger: <gold>Id like to /Rename/ you.
script:
# The bodyguard will ask what the player wishes to rename the bodyguard to.
- narrate format:<npc.constant[NpcFormat]> "Alright what would you like to rename me as?"
# Lets the player know order mode has ended and rename mode has began.
- narrate "<red>Exiting Order Mode and Opening Rename Mode"
- zap step:3
4:
# If the player wishes to give the bodyguard a new skin they say "reskin" in chat near the bodyguard.
trigger: I want to change your /Reskin/
script:
# Asks the player what they wish to change the bodyguards skin to.
- narrate format:<npc.constant[NpcFormat]> "Alright what would you like to change my skin to?"
# Lets the player know that order mode has exited and reskin mode has opened.
- narrate "<red>Exiting Order Mode and Opening Reskin Mode"
- zap step:4
5:
# If the player wishes to change the bodyguards equipment they say "equipment" in chat near the bodyguard.
trigger: <gold> I want to change your /Equipment/.
script:
# Lets the player know if they have a bodyguard that does not respawn they will lose the equipment if it dies.
- narrate format:<npc.constant[NpcFormat]> "Keep in mind if you dont have a respawning bodyguard equipment will be lost on its death"
# Selects the npc.
- execute as_op "npc sel <player.flag[BodyGuard].replace[n@]>"
# Puts the npc into equip mode for 30 seconds.
- execute as_op "npc equip"
- narrate "<red>Equip Mode will end in 30 seconds."
# The 30 second timer.
- wait 30
# Disables equip mode.
- execute as_op "npc equip"
- zap step:1
3:
chat trigger:
1:
# This is where the renaming happens if they player wishes to change the bodyguards name.
trigger: <gold>I want your new name to be /regex:.+/.
script:
# Selects the bodyguard.
- execute as_server "npc sel <player.flag[BodyGuard].replace[n@]>"
# Renames the bodyguard.
- execute as_server "npc rename <context.message>"
# Lets the player know rename mode has ended.
- narrate "<red>Exiting Rename Mode."
- zap step:1
4:
chat trigger:
1:
# This is where the reskin happens if the player whishes to change the bodyguards skin.
trigger: <gold> I want you to take the skin of /regex:.+/.
script:
# Selecting the bodyguard.
- execute as_server "npc sel <player.flag[BodyGuard].replace[n@]>"
# Re-skins the bodyguard.
- execute as_server "npc skin <context.message>"
# Lets the player know reskin mode has ended.
- narrate "<red>Exiting Reskin Mode."
- zap step:1
# This is the weapon the bodyguards use A diamond sword with knockback 2 enchant.
BodyguardSword:
type: item
material: DIAMOND_SWORD
enchantments:
- KNOCKBACK:2
# This is the command script used to teleport guards to a player
TeleportBodyGuard:
type: command
debug: false
name: TpGuard
description: Teleports your bodyguard to you.
usage: /TpGuard
script:
- if !<player.has_flag[bodyguard]> {
- narrate "<red>Error: You do not have a bodyguard."
- queue clear
} else <server.selected_npc> != <player.flag[BodyGuard]> {
- ^execute as_server "npc sel <player.flag[BodyGuard].replace[n@]>"
- if <server.selected_npc> != <player.flag[BodyGuard]> {
- narrate "<red>ERROR: Can not find Bodyguard Please contact a Admin."
- queue clear
} else {
- teleport <player.flag[BodyGuard]> <player.location>
}
}
View History