Denizen/Additional Traits: Difference between revisions

From Citizens Wiki
No edit summary
 
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
For more up-to-date information and full details on specific features (individual commands or tags, for example), check the [https://one.denizenscript.com/denizen/cmds/ Meta Documentation].
If you want a full tutorial to help get you set up, check out the [https://one.denizenscript.com/denizen/cmds/denizen/vids Tutorial Videos] on youtube or 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>
<s>
You can add even further Denizen features by enabling various traits.
You can add even further Denizen features by enabling various traits.


Line 17: Line 32:
When the trait is assigned, it is assumed the NPC has a Denizen script assigned.
When the trait is assigned, it is assumed the NPC has a Denizen script assigned.


== Actions ==
== Mobprox Actions ==


The mobprox trait will fire the following actions on the Denizen script:
The mobprox trait will fire the following actions on the Denizen script:
Line 46: Line 61:
Also note that sometimes several actions will be called all at almost the same time, if there are multiple entities in range.
Also note that sometimes several actions will be called all at almost the same time, if there are multiple entities in range.


== Tags ==
== Mobprox Tags ==


In each action, you can use the [http://wiki.citizensnpcs.com/Denizen/Replaceable_Tags Replaceable Tag] "&lt;context.entity&gt;" (With the &lt;&gt; included, quotes aren't needed) to refer to the mob in question.
In each action, you can use the [http://wiki.citizensnpcs.com/Denizen/Replaceable_Tags Replaceable Tag] "&lt;context.entity&gt;" (With the &lt;&gt; included, quotes aren't needed) to refer to the mob in question.
Line 64: Line 79:
</pre>
</pre>


== Flags ==
== Mobprox Flags ==


Additionally, you can modify the mobprox behavior using NPC flags:
Additionally, you can modify the mobprox behavior using NPC flags:
Line 85: Line 100:


* Flag name is "mobprox_timer"
* Flag name is "mobprox_timer"
* Set to four by default
* Set to 4 by default
* Can be any integer number, but between 1 and 10 is recommended.
* Can be any integer number, but between 1 and 10 is recommended.
* Keep in mind, 1 means fire actions every half second, 2 means every second, 4 means every two seconds, and so on.
* Keep in mind, 1 means fire actions every half second, 2 means every second, 4 means every two seconds, and so on.


== Example ==
== Mobprox Example ==


For an example, create an NPC and assign the script below using "/npc assign --set mobproxexample" then enable the trait with "/trait mobprox"
For an example, create an NPC and assign the script below using "/npc assign --set mobproxexample" then enable the trait with "/trait mobprox"
Line 131: Line 146:
                 - chat target:<player> "Hello, I'm a mob researcher! I'm looking for interesting mobs to classify!"
                 - chat target:<player> "Hello, I'm a mob researcher! I'm looking for interesting mobs to classify!"
                 - chat target:<player> "But I'm deathly afraid of creepers! Luckily a wizard taught me a spell to cast lightning!"</pre>
                 - chat target:<player> "But I'm deathly afraid of creepers! Luckily a wizard taught me a spell to cast lightning!"</pre>
</s>

Latest revision as of 15:17, 8 March 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 Tutorial Videos on youtube or 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!





You can add even further Denizen features by enabling various traits.

You can add traits by simply selecting the NPC and doing doing

/trait <traitname>

EG

/trait mobprox

And use the same command again to remove them

Mobprox Trait

Mobprox is short for "Mob Proximity". It enables a proximity trigger-like functionality, but for mobs instead of players.

When the trait is assigned, it is assumed the NPC has a Denizen script assigned.

Mobprox Actions

The mobprox trait will fire the following actions on the Denizen script:

on mob enter proximity:
on mob exit proximity:
on mob move proximity:
on <mobname> enter proximity:
on <mobname> exit proximity:
on <mobname> move proximity:

"mob" actions fire whenever any mob does the action.

<mobname> actions fire whenever a specific mob does the action.

<mobname> is the name of the mob, EG "zombie" or "creeper".

"enter" actions fire when a mob walks into range. It will fire again if the mob walks out and back in.

"exit" actions fire when a mob leaves range. It will fire again if the mob walks in and back out.

"move" actions fire whenever a mob has been in range and continues to be in range. It doesn't necessarily mean the mob actually moved.


Note that the actions don't run instantly, it can take up to 2 seconds before they are called. (Usually a bit faster)

Also note that sometimes several actions will be called all at almost the same time, if there are multiple entities in range.

Mobprox Tags

In each action, you can use the Replaceable Tag "<context.entity>" (With the <> included, quotes aren't needed) to refer to the mob in question.

You can check for matching details with an if command using the tag, like

- if <context.entity.entity_type> == "creeper" CommandHere

or similar.

One tag that's very useful with the mobprox trait is <entity.can_see[<entity>]> - you can use this to check if the entity is visible to the NPC by doing:

- if <npc.can_see[<context.entity>]> CommandHere

Mobprox Flags

Additionally, you can modify the mobprox behavior using NPC flags:

MobProx Range:

  • Flag name is "mobprox_range"
  • Set to 10 by default
  • Can be any integer number, but it's recommended you don't exceed 100
  • Keep in mind, this is cubic range, not spherical range. Meaning, if the range is 10, and the mob is 9 blocks left and 9 blocks forward, it's still considered to be in range.

Whether to accept NPC mobs as mobprox triggers:

  • flag name is "mobprox_acceptnpcs"
  • Set to false by default
  • Can be true or false. True means NPC mobs or real mobs will fire the mobprox actions, false means only real non-NPC mobs will fire the mobprox actions.
  • Keep in mind, if you want NPCs to interact when they get near each other, there's better ways to do it than mobprox actions. Only set this true if you want NPC mobs treated exactly the same as real mobs.

MobProx action fire timing:

  • Flag name is "mobprox_timer"
  • Set to 4 by default
  • Can be any integer number, but between 1 and 10 is recommended.
  • Keep in mind, 1 means fire actions every half second, 2 means every second, 4 means every two seconds, and so on.

Mobprox Example

For an example, create an NPC and assign the script below using "/npc assign --set mobproxexample" then enable the trait with "/trait mobprox"

'mobproxexample':
    type: assignment
    actions:
        on assignment:
        - flag npc mobprox_range:20
        - flag npc mobprox_acceptnpcs:false
        - trigger name:click state:true
        on mob enter proximity:
        - if <context.entity.entity_type> != "creeper" {
          - announce "<&7>[<npc.name>]<&2> Here's a mob! It's a <context.entity.entity_type>!"
          - if <context.entity.can_see[<npc>]> == false
            announce "<&7>[<npc.name>]<&2> I can't see it though <&co>("
          }
        on mob exit proximity:
        - if <context.entity.entity_type> != "creeper"
          announce "<&7>[<npc.name>]<&2> Goodbye, <context.entity.entity_type>!"
        on creeper enter proximity:
        - announce "<&7>[<npc.name>]<&2> Aahh! Creeper! Die creeper!"
        on creeper exit proximity:
        - announce "<&7>[<npc.name>]<&2> Oh good, the creeper's gone!"
        on creeper move proximity:
        # Note: don't use player-type npc. or player. can_see, always use context.entity.can_see
        # Due to a bug in Bukkit
        - if <context.entity.can_see[<npc>]> == true {
          - announce "<&7>[<npc.name>]<&2> I cast lightning on you, creeper!"
          - strike <context.entity.location>
          }
    interact scripts:
    - 10 mobproxexample_interact

mobproxexample_interact:
    type: interact
    steps:
        1:
            click trigger:
                script:
                - chat target:<player> "Hello, I'm a mob researcher! I'm looking for interesting mobs to classify!"
                - chat target:<player> "But I'm deathly afraid of creepers! Luckily a wizard taught me a spell to cast lightning!"