Inspect target combat ability

Share scripts you wrote for Denizen-Bukkit here!
Post Reply
jose_95
New
New
Posts: 3
Joined: November 10th, 2019, 12:14 pm

Inspect target combat ability

Post by jose_95 » November 10th, 2019, 12:25 pm

This script allows you to inspect a target to get information useful for combat.

Instructions:
1 - Install this script: https://one.denizenscript.com/haste/61913
2 - Name any item "Inspect Target" (Or have the item's name contain "Inspect Target")
3 - Attack a player or mob with the item in your hand.

Information includes (But is not limited to):
- Items, their durability, and enchantments.
- Potion effects
- Damage of melee weapon
- The damage you'll inflict based on armor
- Damage the mob will inflict to you based on armor
- Armor and the damage it'll absorb
- Movement speed

Preview:
Image

User avatar
mcmonkey
Site Admin
Site Admin
Posts: 236
Joined: August 5th, 2016, 7:27 pm
Location: Los Angeles, California, USA
Contact:

Re: Inspect target combat ability

Post by mcmonkey » November 10th, 2019, 3:05 pm

- Script is a bit long and messy (fallbacks / defines might come in handy here)
- For highly repetitive code (like the sub-section of script that's copypasta'd for each item), make a subscript to be ran per item, instead of copypastaspasm. The end result will occupy less than half the file size, and be much cleaner/clearer/smarter for it.
- You'll also cut the file size almost exactly in half by not literally having two full copies of the script in the file. Which you did. There's one entire copy for if the mainhand item is an inspector, and then a second entire copy for the offhand. Why in the seventeen hells would you ever do that.
- You should make a unique item script for this, not the weird name based thing
- NEVER do raw comparisons of objects (things like <item> == i@air or <list> == li@) those are VERY BAD... do static value comparisons and tag-assisted comparisons (like <item.material.name> == air or <list.is_empty>)
- if <X> contains <Y> is deprecated. Get rid of it. Use the contains tag.
- - if <context.entity.type> == Player: did you intentionally make this an object-type based check? Cause that's... weird. You probably meant to use entity_type there?
Denizen lead developer.
http://mcmonkey.org

jose_95
New
New
Posts: 3
Joined: November 10th, 2019, 12:14 pm

Re: Inspect target combat ability

Post by jose_95 » November 10th, 2019, 11:15 pm

Hey, thanks for checking it out!

- I didnt quite get how fallbacks work. I didnt use define because I didnt know where it was needed. The tag would just do

- You are right, I should do that when I can. Might do use a define because of two different scripts.

- Wasnt thinking about making it small at the moment, just that it worked.

- Alright, will do

- I suppose you mean about the <context.entity.name>. I use it because it returns the custom name of entities, player names and entity types.

If you meant the attack speed where I checked if it was a player being inspected, I used entity.type because its shorter than entity.entity_type

jose_95
New
New
Posts: 3
Joined: November 10th, 2019, 12:14 pm

Re: Inspect target combat ability

Post by jose_95 » November 10th, 2019, 11:15 pm

Ill fix it and return with a fixed version :)

User avatar
mcmonkey
Site Admin
Site Admin
Posts: 236
Joined: August 5th, 2016, 7:27 pm
Location: Los Angeles, California, USA
Contact:

Re: Inspect target combat ability

Post by mcmonkey » November 11th, 2019, 12:17 pm

jose_95 wrote:
November 10th, 2019, 11:15 pm
- I suppose you mean about the <context.entity.name>. I use it because it returns the custom name of entities, player names and entity types.
I never mentioned anything about context.entity.name, wat.
jose_95 wrote:
November 10th, 2019, 11:15 pm
If you meant the attack speed where I checked if it was a player being inspected, I used entity.type because its shorter than entity.entity_type
Then you used the wrong tag. Those are two different tags that do different things.
Denizen lead developer.
http://mcmonkey.org

Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests