Sentry/Sentry and Denizen: Difference between revisions

From Citizens Wiki

< Sentry

No edit summary
No edit summary
 
(35 intermediate revisions by 3 users not shown)
Line 1: Line 1:
In Citizens 2 a single NPC can be multiple character types at the same time. This can lead to very powerful player interactions.


[[Denizen]], especially can create great gameplay. Here are 2 examples.
For more up-to-date information and full details on specific features (individual commands or tags, for example), check the [https://meta.denizenscript.com/ Meta Documentation].
 
If you want a full tutorial to help get you set up, check out the [https://guide.denizenscript.com/ Beginner's Guide] text website.
 
If you need quick help, visit our [https://discord.gg/Q6pZGSR Discord group].
 
<br><br><br>
 
<span style="font-family:natalya-alternate-one; font-size:300%; margin-right:-7px; margin-left:-10px;">This wiki is outdated, please view the tutorial videos/guide, meta documentation, or Discord group (all linked above) for up-to-date information!</span>
 
<br><br><br>
 
 
 
 
[[Sentry]] is intended to be used in conjunction with Denizen for advanced interactions and scripting.


__TOC__
__TOC__


==Criminal System==
==Scripted Death==
===Interact Triggers ===
Sentry adds 2 new Triggers, 2 new Commands and several Actions to [[Denizen]] that can be used with Sentry-Denizens.


A few [[Multiple Traits|Sentry-Denizens]] can be used to create a town criminal systems.
;Npcdeath Trigger
The Npcdeath Trigger works like any other [[Denizen]] Trigger. It is called when the Sentry-Denizen has taken enough damage to kill it. The trigger will run once for EACH Player that was involved in killing the NPC since it was last at full health. If the NPC dies to mobs or the environment the script will not run.


Let's say you have an adventure server with a town called '''Hillside''', populated by shopkeepers, guards, blacksmiths, etc.
;Npcdeathowner Trigger
The Npcdeathowner trigger is also called when the NPC dies, but runs the trigger on the NPC's owner, if owner is an online player. This will be run no matter what the cause of death.


Create a number of Sentry-Denizens to act as your town's police force. Set each Sentry to target a [[#Targets|GROUP]] called Hillside_Enemy.
'''One of the following commands should always be the last step of a death trigger. Otherwise the Sentry-Denizen will cease to do anything, stuck in un-death.'''


Now create a [[Denizen]] script to handle player aggression. Let's use a 3-strike system. This same script will execute for all NPCs to which it is assigned, and the player's step will be the same for each, so we can use 1 script with multiple steps, one for each strike. Here's an example:
=== Commands ===
;DIE Command
Call this when your script is done to finish off the Sentry-Denizen and despawn it.
Note: Calling the DIE command on a non-sentry Denizen will likely throw an error.


{| class="wikitable collapsible collapsed"
;LIVE Command
! Hillside Aggression Script and Assignments
Call this to reset a Sentry-Denizen to normal Sentry activity. Useful for mid-fight speech and 'boss stages'. This does not heal the Sentry, it will retain the health it had prior to its death-blow. use the Denizen HEAL DENIZEN command for that, if desired.
|-
| <pre>
---- assignments.yml ----


Denizens:                       
Use LIVE PEACE to also cause the NPC to drop its current target.
  'Town Guard':                       
    Interact Scripts:       
      (other assignments)         
    - 10 ^Hillside_Aggression


  'Shopkeeper Bob':                      
Note: Calling the LIVE command on a non-sentry Denizen will likely throw an error.
    Interact Scripts:     
      (other assignments)                   
    - 10 ^Hillside_Aggression


  'Mayor Steve':                       
Here is a full example of Npcdeath Trigger and DIE.
    Interact Scripts: 
      (other assignments)                       
    - 10 ^Hillside_Aggression


---- script.yml ----
{| class="wikitable collapsible collapsed"
'Hillside_Aggression':
! NpcDeath Trigger and DIE command example script.
   Type: Trigger
|-
   Requirements:
|<pre>
     Mode: All
 
GuardDeath:  
   Type: Interact
   Requirements:  
     Mode: None
     List:
     List:
      - -GROUP Hillside_Enemy
   Steps:  
   Steps:
     1:  
     1:
       Npcdeath Trigger:  
       Damage Trigger:
         script:
         Script:
          - CHAT "ARARRRRRGRGGRRH!"  
        - CHAT "Hey, watch it or I'm calling the guards!"
          - DROP DIAMOND
        - ZAP
          - DIE
    2:
      Damage Trigger:
        Script:
        - CHAT "Stop it, troublemaker, or else!"
        - ZAP
    3:
      Damage Trigger:
        Script:
        - CHAT "HELP! HELP! I'm being attacked!"
        - EXECUTE ASSERVER 'permissions player addgroup <PLAYER> Hillside_Enemy'
        - NARRATE 'You are now an enemy of Hillside.' 
        - ZAP 1
</pre>
</pre>
|}
|}
===Actions===
Sentry provides the following Actions that can be used for short scripts:
* on death
* on death by entity
* on death by player
* on death by CAUSE
**Where CAUSE is [http://jd.bukkit.org/rb/apidocs/org/bukkit/event/entity/EntityDamageEvent.DamageCause.html#enum_constant_detail|any damage cause] (i.e. on death by lava)
* on death by LIVINGENTITY
**Where LIVINGENTITY is the name of the entity type (i.e. on death by zombie)
==Criminal System==
A few [[Multiple Traits|Sentry-Denizens]] can be used to create a town criminal systems.
Let's say you have an adventure server with a town called '''Hillside''', populated by shopkeepers, guards, blacksmiths, etc.
Create a number of Sentry-Denizens to act as your town's police force. Set each Sentry to target a [[#Targets|GROUP]] called Hillside_Enemy.
Now create a [[Denizen]] script to handle player aggression. Let's use a 3-strike system. This same script will execute for all NPCs to which it is assigned, and the player's step will be the same for each, so we can use 1 script with multiple steps, one for each strike. Here's an example:
{{color|red|white|script removed as not compatible with current Denizen}}


You can see we've assigned the script "Hillside_Aggression" to all NPCs named Town Guard, Shopkeeper Bob, or Mayor Steve.
You can see we've assigned the script "Hillside_Aggression" to all NPCs named Town Guard, Shopkeeper Bob, or Mayor Steve.
Line 75: Line 97:
This is just a basic example and can be expanded in any number of ways, using the commands in [[Denizen]] you could:
This is just a basic example and can be expanded in any number of ways, using the commands in [[Denizen]] you could:


- forgive the player after a period of time (remove the player from the hillside_enemy group)
- forgive the player after a period of time (remove the player from the hillside_enemy group)
 
::(You can do this automatically with PEX duration options)


- Create a quest for the player to earn forgiveness.
- Create a quest for the player to earn forgiveness.
Line 84: Line 108:


==Hire-able Bodyguards==
==Hire-able Bodyguards==


So you're getting your butt kicked on your survival server, wouldn't it be nice to spend some of that hard-earned emerald on a dude who will watch your back for you? Now you can!
So you're getting your butt kicked on your survival server, wouldn't it be nice to spend some of that hard-earned emerald on a dude who will watch your back for you? Now you can!
Line 89: Line 114:
Let's see how we can use [[Denizen]] to make hire-able bodyguards.
Let's see how we can use [[Denizen]] to make hire-able bodyguards.


{| class="wikitable collapsible collapsed"
'''{{color|red|white|For a Denizen 0.9 version see this http://scripts.citizensnpcs.co/view/ta8m4c}}
! Mercenary Leader Script and Assignment
|-
| <pre>
---- assignments.yml ----
 
Denizens:                       
  'Mercenary Leader':                       
    Interact Scripts:         
    - 10 Hire a Guard
    Texts:
      No Requirements Met: "Come back when you have some money and we'll talk."
 
---- script.yml ----
 
Hire a Guard:
  Type: Trigger
  Requirements:
    Mode: All
    List:
      - MONEY 500
  Steps:
    1:
      Click Trigger:
        Script:
        - CHAT "You look like you could use some help out there. $500 will get you one of my boys."
        - HINT
      Chat Trigger:
      '1':
          Trigger: /Yes/, I am weak and need protecting.
          Script:
          - CHAT "Okay then, nice doin' business with ya"
          - TAKE MONEY QTY:500
          - EXECUTE ASNPC "npc create '<PLAYER>s Bodyguard'"
          - EXECUTE ASNPC "trait sentry"
          - ^EXECUTE ASNPC "sentry guard <PLAYER>"
          - ^EXECUTE ASNPC "sentry strength 2"
          - ^EXECUTE ASNPC "sentry respawn -1"  #Note this means when the bodyguard dies, he's gone for good.
      '2':
          Trigger: /No/, I can handle myself!
          Script:
            - CHAT "Not my fault if you wind up dead, kid."
 
</pre>
|}


Here we have a single NPC named 'Mercenary Leader'. Locate him somewhere convenient. Depending on your server's permission system you may need to pretend Mercenary Leader is player and grant him access to to /npc and /sentry commands. (need to test)
Here we have a single NPC named 'Mercenary Leader'. Locate him somewhere convenient. Depending on your server's permission system you may need to pretend Mercenary Leader is player and grant him access to to /npc and /sentry commands. (need to test)
Line 142: Line 123:


That's all there is to it. You could expand on this in many ways:
That's all there is to it. You could expand on this in many ways:
* Create 'template' sentries and use /npc copy to create the bodyguard instead of building a new npc from scratch.
* Higher prices for bodyguards with better stats.
* Higher prices for bodyguards with better stats.
* Limit player to one guard at a time.
* Limit player to one guard at a time.
* Give ranged or melee guards.
* Give ranged or melee guards.
* Make the bodyguard a [[Denizen]] as well and respond to player commands.
* Make the bodyguard a [[Denizen]] as well and respond to player commands. (Change the name to something generic so you can pre-assign scripts)
 
 
==Sentry-specific Denizen scripts==
Sentry adds a new Trigger and a new Command to [[Denizen]] that can be used with Sentry-Denizens.
 
;Npcdeath Trigger
The Npcdeath Trigger works like any other [[Denizen]] Trigger. It is called when the NPC dies.
 
;DIE Command
The DIE command should be the last step in your Npcdeath Trigger. Otherwise the NPC will not die. Sentry-Denizens without a matching Npcdeath Trigger die normally.


Here is a full example using both.
{| class="wikitable collapsible collapsed"
! NpcDeath Trigger and DIE command example script.
|-
|<pre>
---- assignments.yml ----


Denizens:                       
  'Guard':                       
    Interact Scripts:         
    - 10 GuardDeath
---- script.yml ----
GuardDeath:
  Type: Interact
  Requirements:
    Mode: All
    List: []
  Steps:
    1:
      Npcdeath Trigger:
        Script:
          - CHAT "ARARRRRRGRGGRRH!"
          - DROP DIAMOND
          - DIE
</pre>
|}




Line 194: Line 139:
* Have a NPC give the player important quest hints when it dies.
* Have a NPC give the player important quest hints when it dies.
* Revisit the [[#Criminal System]] example and make a punishment for murder.
* Revisit the [[#Criminal System]] example and make a punishment for murder.
[[Category:Denizen]]

Latest revision as of 18:49, 11 October 2021

For more up-to-date information and full details on specific features (individual commands or tags, for example), check the Meta Documentation.

If you want a full tutorial to help get you set up, check out the Beginner's Guide text website.

If you need quick help, visit our Discord group.




This wiki is outdated, please view the tutorial videos/guide, meta documentation, or Discord group (all linked above) for up-to-date information!






Sentry is intended to be used in conjunction with Denizen for advanced interactions and scripting.

Scripted Death

Interact Triggers

Sentry adds 2 new Triggers, 2 new Commands and several Actions to Denizen that can be used with Sentry-Denizens.

Npcdeath Trigger

The Npcdeath Trigger works like any other Denizen Trigger. It is called when the Sentry-Denizen has taken enough damage to kill it. The trigger will run once for EACH Player that was involved in killing the NPC since it was last at full health. If the NPC dies to mobs or the environment the script will not run.

Npcdeathowner Trigger

The Npcdeathowner trigger is also called when the NPC dies, but runs the trigger on the NPC's owner, if owner is an online player. This will be run no matter what the cause of death.

One of the following commands should always be the last step of a death trigger. Otherwise the Sentry-Denizen will cease to do anything, stuck in un-death.

Commands

DIE Command

Call this when your script is done to finish off the Sentry-Denizen and despawn it. Note: Calling the DIE command on a non-sentry Denizen will likely throw an error.

LIVE Command

Call this to reset a Sentry-Denizen to normal Sentry activity. Useful for mid-fight speech and 'boss stages'. This does not heal the Sentry, it will retain the health it had prior to its death-blow. use the Denizen HEAL DENIZEN command for that, if desired.

Use LIVE PEACE to also cause the NPC to drop its current target.

Note: Calling the LIVE command on a non-sentry Denizen will likely throw an error.

Here is a full example of Npcdeath Trigger and DIE.

Actions

Sentry provides the following Actions that can be used for short scripts:

  • on death
  • on death by entity
  • on death by player
  • on death by CAUSE
  • on death by LIVINGENTITY
    • Where LIVINGENTITY is the name of the entity type (i.e. on death by zombie)

Criminal System

A few Sentry-Denizens can be used to create a town criminal systems.

Let's say you have an adventure server with a town called Hillside, populated by shopkeepers, guards, blacksmiths, etc.

Create a number of Sentry-Denizens to act as your town's police force. Set each Sentry to target a GROUP called Hillside_Enemy.

Now create a Denizen script to handle player aggression. Let's use a 3-strike system. This same script will execute for all NPCs to which it is assigned, and the player's step will be the same for each, so we can use 1 script with multiple steps, one for each strike. Here's an example:

script removed as not compatible with current Denizen

You can see we've assigned the script "Hillside_Aggression" to all NPCs named Town Guard, Shopkeeper Bob, or Mayor Steve.

If a player attacks any of these NPCs, they will receive a warning message and move on to the next step, if they get to step 3, they get put in the Sentry hostile group Hillside_Enemy.

Bonus: If the shopkeeper and mayor are set as Sentries too, they will defend themselves! (turn retaliate off, so they don't attack immediately)

The final step resets the script to step 1, but will not run so long as the player is a member of Hillside_Enemy.

This is just a basic example and can be expanded in any number of ways, using the commands in Denizen you could:

- forgive the player after a period of time (remove the player from the hillside_enemy group)

(You can do this automatically with PEX duration options)

- Create a quest for the player to earn forgiveness.

- Create hostility in other towns if harassment of Hillside continues.

- etc etc etc.

Hire-able Bodyguards

So you're getting your butt kicked on your survival server, wouldn't it be nice to spend some of that hard-earned emerald on a dude who will watch your back for you? Now you can!

Let's see how we can use Denizen to make hire-able bodyguards.

For a Denizen 0.9 version see this http://scripts.citizensnpcs.co/view/ta8m4c

Here we have a single NPC named 'Mercenary Leader'. Locate him somewhere convenient. Depending on your server's permission system you may need to pretend Mercenary Leader is player and grant him access to to /npc and /sentry commands. (need to test)

In this simple example we've given him one script with the requirement the Player has 500 economy money. We also gave him a default text telling the player to come back when he has more. You could expand on this with another script, but it's good enough for now.

If the player has the moolah, when he right clicks, the Merc will ask him if he wants a bodyguard. If the player answers yes. the NPC will use server commands to create a Sentry and assign it to the Player. In this example the Sentry's respawn is set to -1 meaning if the bodyguard dies, it's dead for good and the player needs to buy another one.

That's all there is to it. You could expand on this in many ways:

  • Create 'template' sentries and use /npc copy to create the bodyguard instead of building a new npc from scratch.
  • Higher prices for bodyguards with better stats.
  • Limit player to one guard at a time.
  • Give ranged or melee guards.
  • Make the bodyguard a Denizen as well and respond to player commands. (Change the name to something generic so you can pre-assign scripts)



Something to note is that Denizen scripts are player-centric. A Sentry-Denizen will remember all the players who contributed to its death. A separate script will run for EACH player. Because of this it is best not to use the DROP command like in the example as this would drop 1 diamond per player. Use the GIVE command instead and each player will receive the reward directly.

Again this is a simple example, but could be expanded:

  • Use the FLAG or FINISH command to count the number of times the player has killed this NPC
  • Spawn a super-tough boss NPC at the start of a quest that requires multiple players to take down. Each player can be flagged for helping to kill it.
  • Have a NPC give the player important quest hints when it dies.
  • Revisit the #Criminal System example and make a punishment for murder.