#(DrGf) Code review + NPCs not properly equipping new enchanted gear

41 messages · Page 1 of 1 (latest)

lapis perch
#

Right now I need someone to take a look at the code I have before I continue to delve into this complex system
Current entire script: https://paste.denizenscript.com/View/114610

I also have an issue where NPCs, after they successfully kill a player, do not have some of their gear enchanted. Some gear gets enchanted, some doesn't. And I'm not sure why. That part of the script starts at line 265

vivid hornetBOT
#

(DrGf) Code review + NPCs not properly equipping new enchanted gear

vivid hornetBOT
#

Hi I'm AutoThreadBot! Don't mind me, I'll just be adding the helper team to this thread so they can see it. A human will get to you soon.

sturdy anchor
#

matchers use a single pipe for the seperator, not 2

#

setting a definition should use a space, not a colon

#

!define u

#

!c define u

twilit sigilBOT
# sturdy anchor !c define u
Group

queue

Syntax

define [<id>](:<action>)[:<value>]

Short Description

Creates a temporary variable inside a script queue.

Use to make complex tags look less complex, and scripts more readable.
- narrate "You invoke your power of notice..."
- define range <player.flag[range_level].mul[3]>
- define blocks <player.flag[noticeable_blocks]>
- define count <player.location.find_blocks[<[blocks]>].within[<[range]>].size>
- narrate "<&[base]>[NOTICE] You have noticed <[count].custom_color[emphasis]> blocks in the area that may be of interest."
Use to validate a player input to a command script, and then output the found player's name.
- define target <server.match_player[<context.args.get[1]>]||null>
- if <[target]> == null:
  - narrate "<red>Unknown player target."
  - stop
- narrate "You targeted <[target].name>!"
Use to keep the value of a tag that you might use many times within a single script.
- define arg1 <context.args.get[1]>
- if <[arg1]> == hello:
    - narrate Hello!
- else if <[arg1]> == goodbye:
    - narrate Goodbye!
Use to remove a definition.
- define myDef:!
Use to make a MapTag definition and set the value of a key inside.
- define myroot.mykey MyValue
- define myroot.myotherkey MyOtherValue
- narrate "The main value is <[myroot.mykey]>, and the map's available key set is <[myroot].keys>"
sturdy anchor
#

did i forget how to operate our bots

#

okay just slow

#

^ see examples

#
  • define headgear:<list[leather_helmet|chainmail_helmet|golden_helmet|iron_helmet|diamond_helmet|netherite_helmet|air].random>
    this sure looks like static data
#

either move that to a data script (or key) or use some basic vanilla_tags logic to generate the list automatically

#

your 4 armor sections are very nearly carbon copies afais, you can definitely condense them down into one

#

your mount lines should just be spawning new entities - did you not notice this?

#
                    - mount wither_skeleton|phantom <context.location>
                    - mount wither_skeleton|chicken <context.location>
                    - mount wither_skeleton|spider <context.location>
                    - mount wither_skeleton|wither_skeleton <context.location>
```this can be one line
#

line 85 is a random command with a single optioni was wrong about this

#

tl;dr your entire first script section could probably be like 1/3 the size

#

line 176 is indented to your while, which is not valid, while is not if

#
- if <player.item_in_hand> matches bow:
            - stop

can make this one line with if arg if you desire, not an issue either way

#
        - equip <entry[NCreate].created_npc> head:<context.damager.equipment.get[4]>
        - equip <entry[NCreate].created_npc> legs:<context.damager.equipment.get[2]>
        - equip <entry[NCreate].created_npc> chest:<context.damager.equipment.get[3]>
        - equip <entry[NCreate].created_npc> boots:<context.damager.equipment.get[1]>



        - equip <entry[NCreate].created_npc> hand:<context.damager.item_in_hand>
        - equip <entry[NCreate].created_npc> offhand:<context.damager.item_in_offhand>

pls

#

- flag server <entry[NCreate].created_npc>Hand:<context.damager.item_in_hand> don't use objects as keys, also ^

#

hand:<context.damager.item_in_hand>[enchantments=<[RNGEnchant]>,<[modifier]>] shouldn't construct things this way, it will almost immediately fail

#

.with at the very least

#

several of your events just use npc as a matcher, you should really make a unique tag for this system

#
on NPC dies:
        - random:
            - drop <server.flag[<npc>Hand]>|<server.flag[<npc>Offhand]>|<server.flag[<npc>Helmet]>|<server.flag[<npc>Chestplate]>|<server.flag[<npc>Leggings]>|<server.flag[<npc>Boots]> <npc.location>
``` surely there's a setting that makes this behavior automatic
#

wait at the end of a queue doesn't do anything

#

or, actually

#

i think that might have been changed so it technically does do something

#

not useful either way

#
                - define px <util.random.int[-25].to[25]>
                - define py <util.random.int[-25].to[25]>
                - define pz <util.random.int[-25].to[25]>
                - while !<[p].location.add[<[px]>,<[py]>,<[pz]>].is_spawnable>:
                    - define px <util.random.int[-25].to[25]>
                    - define py <util.random.int[-25].to[25]>
                    - define pz <util.random.int[-25].to[25]>

lmao if at first you don't succeed, try again, if you still fail, give up and spawn them in a wall

#

also

#

!t random_offset

twilit sigilBOT
# sturdy anchor !t random_offset

Returns a copy of this location, with the X/Y/Z offset by a random decimal value up to a given limit.
The limit can either be an X,Y,Z location vector like [3,1,3] or a single value like [3] (which is equivalent to [3,3,3]).
For example, for a location at 0,100,0, ".random_offset[1,2,3]" can return any decimal location within the cuboid from -1,98,-3 to 1,102,3.

Group

math

Returns

LocationTag

sturdy anchor
#

What happens if you despawn a despawned npc? re 386

#

okay there are much more technical problems, and probably some very basic ones i missed while glancing at it, but here's some

lapis perch
#

Oh my gosh I have so much to read

lapis perch
sour ospreyBOT
#
Thread Closing Reminder

Has your issue been resolved, or your question been answered?
If so, please use the </resolved:1028673926114594866> command to close your thread.
Or </invalid:1028673926898909185> if it's not possible to resolve.

If not yet resolved, please reply below to tell us what you still need.

(Note that if there is no reply for a few days, this thread will eventually close itself.)

#

@lapis perch