#Help on a very hard task

1 messages · Page 1 of 1 (latest)

grizzled obsidian
#

Hello!
I need some help on skript with something of VERY, VERY, VERY, VERY, VERY hard.

I want to make a kind of combact system different from vanilla, like this:
When you damage a mob with an item, you deal the damage that the item has, with an exception:
You have to wait the weapon custom cooldown to damage: during the cooldown you won't be able to do damage.
Example:
A netherite sword would deal always 8 damage, crit or not, but you need to wait a cooldown of 1.6 seconds to strike the next hit.

The mobs would also need to have a custom health system:
I want mobs to have shown a certain amount of hp, but in reality they have 0.1hp so that when they die they don't make unwanted red-hearts particles.

Also. if I hit them with my first I always do 1 damage and don't have any cooldown-

Basically, I have to give a mob a kind of other stats(??) but I mostly don't have ANY idea on how to do it, expecially the health part.

(P.S.: Don't ask me "Code please" because I don't have any and I'm new to skript and most importantly I'm not asking for free code.)

#

I currently have Skript and SkBee, tell me If I'll need more addons.

plain verge
#

for the custom mob health, add nbt to the mob for its custom health and change it on the on damage event

#
on spawn:
    set int tag "health" of custom nbt of event-entity to 20
    set health of event-entity to 1

on damage:
    cancel event
    subtract damage from int tag "health" of custom nbt of event-entity
    if int tag "health" of custom nbt of event-entity <= 0:
        kill event-entity

something like this should work

grizzled obsidian
plain verge
#

nbt is basically the entity's data

#

so it is setting a custom part of the data to the health

grizzled obsidian
#

Sure, Tysm :D

plain verge
#

havent tested so let me know if it doesnt work

grizzled obsidian
#

Sure

grizzled obsidian
# plain verge havent tested so let me know if it doesnt work

Yup, 12 errors :_)

I've tried this:

command /sum
trigger:
spawn a zombie named "TancrebitPC"
set int tag "health" of custom nbt of event-entity to 20
set health of event-entity to 1

on damage of a zombie:
if named "TancrebitPC"
if victim is zombie
if damager is player
cancel event
subtract damage from int tag "health" of custom nbt of event-entity
if int tag "health" of custom nbt of event-entity <= 0:
kill event-entity

But I get those errors:

#

Oh wait

#

I can fix most

#

now only 6: mmmuch better

plain verge
#
command /sum:
    trigger:
        spawn a zombie named "TancrebitPC"
        set int tag "health" of custom nbt of last spawned entity to 20
        set health of last spawned entity to 1

on damage of a zombie:
    victim is named "TancrebitPC"
    attacker is a player
    cancel event
    subtract damage from int tag "health" of custom nbt of victim
    if int tag "health" of custom nbt of victim <= 0:
        kill victim

try this code

#

you were missing a semicolor after /sum

#

and some other stuff

grizzled obsidian
#

like some comas

plain verge
#
command /sum:
    trigger:
        spawn zombie at player
        set name of last spawned entity to "TancrebitPC"
        set int tag "health" of nbt of last spawned entity to 20
        set health of last spawned entity to 1

on damage of a zombie:
    name of victim is "TancrebitPC"
    attacker is a player
    subtract damage from int tag "health" of nbt of victim
    set damage to 0
    if int tag "health" of nbt of victim <= 0:
        kill victim

this should fix some of the errors

grizzled obsidian
#

huh

#

no error :D

plain verge
#

yay

#

does it work?

#

if you spawn a chicken it should take a bunch of hits to kill it

grizzled obsidian
#

I can't damage the zombie

plain verge
#

ohh whoops hang on

plain verge
plain verge
#

see on line 5 where it says 20
try changing it to 5

#

so it should die faster than a normal zombie

grizzled obsidian
#

done

grizzled obsidian
plain verge
#

yeah you can do that

#

do you want all swords to go on cooldown at once or you can keep switching

#

also did the damage part work?

grizzled obsidian
plain verge
grizzled obsidian
plain verge
#
command /sum:
    trigger:
        spawn zombie at player
        set name of last spawned entity to "TancrebitPC"
        set int tag "health" of nbt of last spawned entity to 5
        set health of last spawned entity to 1

on damage of a zombie:
    name of victim is "TancrebitPC"
    attacker is a player
    subtract damage from int tag "health" of nbt of victim
    set damage to 0
    if int tag "health" of nbt of victim <= 0:
        kill victim

does your code look like this?

grizzled obsidian
#

Yup

plain verge
#

what part doesnt work?

grizzled obsidian
#

The zombie doesn't take any damage , so the 11 line

plain verge
#

does it have red effect when you hit it?

grizzled obsidian
#

Nope

plain verge
#

for me he flashes red but doesnt die

#

I gtg I will fix it later

grizzled obsidian
#

dw

plain verge
#

@grizzled obsidian this part works now!

command /sum:
    trigger:
        spawn zombie at player
        set name of last spawned entity to "TancrebitPC"
        set float tag "custom;health" of nbt of last spawned entity to 5

on damage of a zombie:
    name of victim is "TancrebitPC"
    attacker is a player
    subtract damage from float tag "custom;health" of nbt of victim
    set damage to 0
    if float tag "custom;health" of nbt of victim <= 0:
        kill victim
grizzled obsidian
#

Kinda

#

I mean

#

1 custom health is 2 hits with bare hands

#

is that normal?

#

That's not too much of a problem tho

#

And I kinda don't understand why I deal more damage with a sword

#

Like

#

Oh wait

#

I """kinda"""" understands

#

Basically I send my damage to the custom health nbt

#

But then why do I deal the same amount of damage if I crit or not?

#

With my hands i deal 0,5 custom health damage but with a netherite sword I deal 3,5

#

I don't have an idea how tho

#

But that shouldn't be an actual problem
Because we can just do that if you damage it with something that hasn't a custom damage set it does always 1 custom health damage
But if it has a custom damage set then it does the custom damage to the entity

errant shale
plain verge
#

right now it just deals the same damage as it normally would

grizzled obsidian
#

How do you set a custom nbt tag to an item tho?

plain verge
#

and check like this:
string tag "custom" of custom nbt of %item%

grizzled obsidian
#

diamond sword with name "&ctest" with lore "a" and "b" with custom nbt from "{custom;damage}" of 5

#

Does this works?

plain verge
#

and check like this:
double tag "damage" of custom nbt of %item%

grizzled obsidian
grizzled obsidian
grizzled obsidian
#
command /sum:
    trigger:
        spawn zombie at player
        set name of last spawned entity to "TancrebitPC"
        set float tag "custom;health" of nbt of last spawned entity to 5

on damage of a zombie:
    name of victim is "TancrebitPC"
    attacker is a player
    double tag "damage" of custom nbt of %item%
    set damage to 0
    if float tag "custom;health" of nbt of victim <= 0:
        kill victim

command /gi:
    trigger:
        give a diamond sword with name "&ctest" with lore "a" and "b" with custom nbt from "{damage:5.75}" to player

Is this good?

plain verge
#

also you arent doing anything with the damage nbt, you should subtract it from the health

plain verge
#
command /sum:
    trigger:
        # spawn zombie
        spawn zombie at player
        set name of last spawned entity to "TancrebitPC"
        # set custom health nbt of the zombie
        set float tag "custom;health" of nbt of last spawned entity to 20

command /gi:
    trigger:
        # give weapon with the custom damage nbt
        give a diamond sword with name "&ctest" with lore "a" and "b" with custom nbt from "{damage:5f}" to player

on damage:
    # only run code if the victim has custom health
    float tag "custom;health" of nbt of victim is set
    # set real damage to 0
    set damage to 0
    # set custom damage var to 1 by default
    # for when hitting with fist or non-custom weapon
    set {_damage} to 1
    # if the weapon has custom damage,
    # override custom damage var to that value
    if float tag "damage" of custom nbt of attacker's tool is set:
        set {_damage} to float tag "damage" of custom nbt of attacker's tool
    # subtract the damage var from the health nbt
    subtract {_damage} from float tag "custom;health" of nbt of victim
    # kill victim if health nbt is 0 or less
    if float tag "custom;health" of nbt of victim <= 0:
        # drop a reward
        drop 1 diamond at victim
        # delete victim
        delete victim
        # send defeated message to attacker
        send "&6%name of victim% &7has been deafeated!" to attacker
    else:
        # send health message to attacker
        send "&6%name of victim% &7has &c%float tag "custom;health" of nbt of victim% health &7remaining!" to attacker

is there any part of this you don't understand? (read the comments)

grizzled obsidian
#

Nope, I understand everything perfectly!
I can't thank you enough XD

Also, if I wanted to make a multiplier of damage statistic, would this work out?

give a diamond sword with name "&ctest" with lore "a" and "b" with custom nbt from "{damage:5f}" and custom nbt from {multi:1.5} to player
# multi will be on default 1

and

if float tag "damage" of custom nbt of attacker's tool is set:
        set {_damage} to float tag "damage" of custom nbt * float tag "multi" of custom nbt of attacker's tool
# custom damage (5) x multi (1,5)
plain verge
#

you would add it to the same nbt compound, so like this:
"{damage:5f,multi:1.5f}"

#

what's the point of a multiplier though if it's also part of the weapon

#

it could just be 7.5 damage and 1x mult

errant shale
#

one condition per line

#
  float tag... is set
  int tag... is set
then:
  #code```
grizzled obsidian
#

Cool :D
tY

#

But

grizzled obsidian
#

What's the problem?

errant shale
#

no

#

youre checking if 2 tags are set in one line

#

you need to use 1 line per tag

grizzled obsidian
plain verge
#

i'm not sure why second screenshot doesn't work

#

also you will only need to check if the damage is set, because if it has damage it will also have a mult

errant shale
#

use the has tag condition...

plain verge
#

o true

#

custom nbt of attacker's tool has tag "damage"

grizzled obsidian
#
if all:
    custom nbt of attacker's tool has tag "damage"
    custom nbt of attacker's tool has tag "multi"
then:```
errant shale
#

Add code to the section

grizzled obsidian
#
    if all:
    custom nbt of attacker's tool has tag "damage"
    custom nbt of attacker's tool has tag "multi"
    then:
        set {_damage} to float tag "damage" of custom nbt * float tag "multi" of custom nbt of attacker's tool```
plain verge
#

but if you do wanna check both, make sure to indent what is under the if all:

errant shale
#

^

grizzled obsidian
#
if custom nbt of attacker's tool has tag "damage"
        set {_damage} to float tag "damage" of custom nbt * float tag "multi" of custom nbt of attacker's tool```
plain verge
#

update to latest skbee version

#

im on 3.6.0

errant shale
#

use NBT compound of %item% has tag "example

grizzled obsidian
lavish bronze
lavish bronze
grizzled obsidian
#

Wait

#

Huhhh

#

I mean

#

It's not too much of a problem

#

But changing SkBee version resets your skripts folder?

#

Luckly I have all of my skripts saved except for one of mining, that the save is quite old but that isn't too much hard to rewrite cuz I remember it

#

Huhhh

#

Nnervermind?

#

Everything is saved

#

strange

#

Now I get this error

lavish bronze
grizzled obsidian
#

Yayy It works :D

#

Now, do you have any idea on the "wait to damage" part?

errant shale
#

Wdym?

#

You want to damage them after a delay?

#

Just wait

#

And then damage

grizzled obsidian
#

No no

#

You have to wait the weapon custom cooldown to damage: during the cooldown you won't be able to do damage.
Example:
A netherite sword would deal always 8 damage, crit or not, but you need to wait a cooldown of 1.6 seconds to strike the next hit.

#

Also non custom weapons deal 0 damage

#

Wait

#

I fixed it on my own :D

#
        set {_damage} to float tag "damage" of custom nbt of attacker's tool * float tag "multi" of custom nbt of attacker's tool
    else:
        set {_damage} to 1
    # subtract the damage var from the health nbt
        subtract {_damage} from float tag "custom;health" of nbt of victim
    # kill victim if health nbt is 0 or less
    if float tag "custom;health" of nbt of victim <= 0:
        # drop a reward
        drop 1 diamond at victim
        # delete victim
        delete victim
        # send defeated message to attacker
        send "&6%name of victim% &7has been deafeated!" to attacker
    else:
        # send health message to attacker
        send "&6%name of victim% &7has &c%float tag "custom;health" of nbt of victim% health &7remaining!" to attacker```
plain verge
#

the vanilla cooldown might be what you want
set item cooldown of attacker's tool to 5 seconds

#

and you could add the cooldown to the nbt like the damage and mult

lavish bronze
#

what is the multiplier even for?

#

can't you just multiply the damage tag?

grizzled obsidian
grizzled obsidian
errant shale
#

because it needs to be a timespan

#

not a number

grizzled obsidian
#

set item cooldown of attacker's tool to (0 + float tag "multi" of custom nbt of attacker's tool) seconds
Same error

lavish bronze
#

set item cooldown of attacker's tool to "%0 + float tag "multi" of custom nbt of attacker's tool% seconds" parsed as timespan

#

also why 0 +?

grizzled obsidian
lavish bronze
grizzled obsidian
errant shale
#

for player

grizzled obsidian
lavish bronze
#

oh yeah 🤦‍♂️

#

between tool and to

#

and for attacker

#

in this case

grizzled obsidian
#

It works the cooldown

#

BUT

#

Another problem

#

When I damage a mob with the nbt with the sword with the damage nbt it doesn't deal damage

#
    float tag "custom;health" of nbt of victim is set
    set damage to 0
if custom nbt of attacker's tool has tag "damage":
        set {_damage} to float tag "damage" of custom nbt of attacker's tool * float tag "multi" of custom nbt of attacker's tool
        set item cooldown of attacker's tool for attacker to "%0 + float tag "multi" of custom nbt of attacker's tool% seconds" parsed as timespan
    else:
        set {_damage} to 1```
errant shale
#

i mean yeah, the 3rd line is set damage to 0

grizzled obsidian
errant shale
#

and i've updated mine

#

you're still setting the damage to 0

#

(also looks like your indentation for line 4 is wrong, maybe just because you pasted it in afterwards tho)

errant shale
lavish bronze
#

don't they mean custom damage (to x8ight)? or do you mean that they're not hit (to TancrebitPC)?

grizzled obsidian
#

damage have to be 0

#

I have to set the custom damage

lavish bronze
#

so is the custom damage not being applied or are they not being hit?

errant shale
lavish bronze
#

I think they did that before so it's probably not the full code

grizzled obsidian
grizzled obsidian
lavish bronze
#

you never subtracted the {_damage} (in this code)

#

show full code

grizzled obsidian
#
    # only run code if the victim has custom health
    float tag "custom;health" of nbt of victim is set
    # set real damage to 0
    set damage to 0
    # set custom damage var to 1 by default
    # for when hitting with fist or non-custom weapon
    if custom nbt of attacker's tool has tag "damage":
        set {_damage} to float tag "damage" of custom nbt of attacker's tool * float tag "multi" of custom nbt of attacker's tool
        set item cooldown of attacker's tool for attacker to "%0 + float tag "multi" of custom nbt of attacker's tool% seconds" parsed as timespan
    else:
        set {_damage} to 1
    # subtract the damage var from the health nbt
        subtract {_damage} from float tag "custom;health" of nbt of victim```
errant shale
#

that line is within the else:

#

so it wont be triggered in the other scenaio

#

remove an indent

grizzled obsidian
#

Ohhh

#

Mb DX

#

Huhh

#

Now I have this problem

#
        # drop a reward
        drop 1 diamond at victim
        # delete victim
        delete victim
        # send defeated message to attacker
        send "&6%name of victim% &7has been deafeated!" to attacker
    else:
        # send health message to attacker
        end "&6%name of victim% &7has &c%float tag "custom;health" of nbt of victim% health &7remaining!" to attacker```
errant shale
#

hmm

#

if you look closely, can you spot the issue?

grizzled obsidian
#

Oh wait

#

I'm dumb

#

huh

#

not really

#

Oh

#

found it

#

yayy it works :D

#

wait a sec

#

found ANOTHER problem

lavish bronze
#

you're a problem farm

grizzled obsidian
grizzled obsidian
grizzled obsidian
#

Simply doing that "if you try to hit while on cooldown, do nothing" wouldn't work, because it would reset the item cooldown and that would be HELLA annoying

plain verge
#
on damage:
  if item cooldown of attacker's tool > 0:
    cancel event
    stop
  # rest of code
grizzled obsidian
lavish bronze
#

0 seconds

grizzled obsidian
lavish bronze
#

for attacker

grizzled obsidian
lavish bronze
#

of attacker's tool for attacker

grizzled obsidian
#

Yay!!!

#

It works Perfectly!!!

#

Finally...

#

225+ messages after

#

We have put an end to this :D

lavish bronze
#

:D

plain verge
#

:D

grizzled obsidian
#

Thanks @lavish bronze , @plain verge and @errant shale for the help :D

lavish bronze
#

you don't mind if I use the exact same thing except for the multi right?

grizzled obsidian
lavish bronze
#

since it would be stupid to make a new one and I kinda wanna make a similar thing

cobalt prism
lethal kayak
#

I disagree