• Welcome to skUnity!

    Welcome to skUnity! This is a forum where members of the Skript community can communicate and interact. Skript Resource Creators can post their Resources for all to see and use.

    If you haven't done so already, feel free to join our official Discord server to expand your level of interaction with the community!

    Now, what are you waiting for? Join the community now!

  • LOOKING FOR A VERSION OF SKRIPT?

    You can always check out skUnity Downloads for downloads and any other information about Skript!

Status
Not open for further replies.

Glitch496

New Member
Jan 24, 2018
9
0
1
First and foremost: Apologies for creating threads close to each other time wise. Hopefully I won't have any other issues after this one... at least, for a few days.

Skript Version: Skript 2.2 (dev32d)
Skript Author: bensku
Minecraft Version: 1.12

Full Code:

code_language.skript:
on damage of player:
    if (victim's health - damage) is less than or equal to 0:
        cancel event
        heal the victim
        add 1 to {deathcounter}
        #the following 2 lines are to make the player's screen twitch when they respawn
        damage the victim by 0.01
        heal the victim
        execute console command "/execute %victim% ~ ~ ~ particle witchMagic ~ ~0.8 ~ 0.3 0.5 0.3 1 100"
        execute console command "/execute %victim% ~ ~ ~ playsound entity.player.hurt master %victim% ~ ~ ~ 1 1 0"
        wait 1 tick
        #next line teleports the victim to spawn
        execute console command "/minecraft:tp %victim% -34 66 -1 -90 0"

What this skript essentially does is remove the death screen entirely and make a new death system. By adding to the death counter (which I don't know how to do yet; it's there so I don't forget to do it later) this skript acts like an actual death. The code is fine, but I've tested this skript several times in game and something unusual happened; the death screen showed for some deaths. From my tests, I found that if the player's health is equal to the amount of damage the mob deals, then the skript doesn't work (and death screen shows).
One test I did had a mob dealing 5 hearts of damage while I had 5 hearts left. The test was unsuccessful, and the death screen showed. I ran the test again, but this time I had 4 hearts. The skript worked on that test.

I am a beginner with Skript, so if the error I made is obvious, I apologize.

Note: I /killed myself in game and the skript worked.

Errors on Reload:
None

Console Errors: (if applicable)
None

Addons using (including versions):
None

Troubleshooting:

Have you tried searching the docs? Yes, it didn't offer much help on my case though
Have you tried searching the forums? Yes
What other methods have you tried to fix it? I've tried setting the line "less than or equal to 0" to "less than or equal to 0.1" but still had similar results.
 
this is what i have used in the past. the multiplication by 2 is because the final damage goes to 10 while the health goes to 20
code_language.skript:
if (final damage * 2) is greater than victim's health:
 
this is what i have used in the past. the multiplication by 2 is because the final damage goes to 10 while the health goes to 20
code_language.skript:
if (final damage * 2) is greater than victim's health:
Thank you, this worked. I changed the final damage to be multiplied by nothing, though, as the game registered me as dead when I was only at 5 hearts.

EDIT: After doing a few tests, this isn't as accurate as I wanted it to be. The mob I tested did 1.5 hearts of damage, and when I was at 2.5 hearts, I died. I should have gone down to 1 heart. @Donut
 
Last edited:
oh yeah youre right about the multiplication idk if it changed or what. without that it works for me though
code_language.skript:
on damage:
    if victim is player:
        broadcast "damage: %final damage%"
        broadcast "health: %victim's health%"
        if final damage is greater than victim's health:
            broadcast "died"
            cancel event
            heal victim
 
oh yeah youre right about the multiplication idk if it changed or what. without that it works for me though
code_language.skript:
on damage:
    if victim is player:
        broadcast "damage: %final damage%"
        broadcast "health: %victim's health%"
        if final damage is greater than victim's health:
            broadcast "died"
            cancel event
            heal victim
It was the other way around, health goes to 10 and final damage goes to 20, at least until someone reported it and now final damage goes to 10 too (to keep consistency)
 
oh yeah youre right about the multiplication idk if it changed or what. without that it works for me though
code_language.skript:
on damage:
    if victim is player:
        broadcast "damage: %final damage%"
        broadcast "health: %victim's health%"
        if final damage is greater than victim's health:
            broadcast "died"
            cancel event
            heal victim
I tested again with the broadcasts, and I found the same issue I put in my edit. The mob I was testing did 5 damage, and when I was at 6.25 hearts, I died. I should have been at one heart. If it helps, the broadcasts said the mob's damage was 5 while my health was 3.75 when I died.

Here's my revised code:
code_language.skript:
on damage:
    if victim is player:
        broadcast "damage: %final damage%"
        broadcast "health: %victim's health%"
        if final damage is greater than victim's health:
            cancel event
            heal victim
            add 1 to {deathcount}
            show title "&4&lYou have died..." with subtitle "&7 " to victim for 5 seconds and 20 ticks and 60 ticks
            damage the victim by 0.01
            heal victim
            execute console command "/execute %victim% ~ ~ ~ particle witchMagic ~ ~0.8 ~ 0.3 0.5 0.3 1 100"
            execute console command "/execute %victim% ~ ~ ~ playsound minecraft:entity.player.hurt master %victim% ~ ~ ~ 1 1 0"
            #wait 1 tick
            #execute console command "/minecraft:tp %victim% -34 66 -1 -90 0"

Edit: After some more testing: The broadcasts don't actually display the true amount of damage taken. In one case I had a mob deal 1.5 hearts of damage, and the broadcast said 2.5 damage was taken. ??????
 
Last edited:
I tested again with the broadcasts, and I found the same issue I put in my edit. The mob I was testing did 5 damage, and when I was at 6.25 hearts, I died. I should have been at one heart. If it helps, the broadcasts said the mob's damage was 5 while my health was 3.75 when I died.

Here's my revised code:
code_language.skript:
on damage:
    if victim is player:
        broadcast "damage: %final damage%"
        broadcast "health: %victim's health%"
        if final damage is greater than victim's health:
            cancel event
            heal victim
            add 1 to {deathcount}
            show title "&4&lYou have died..." with subtitle "&7 " to victim for 5 seconds and 20 ticks and 60 ticks
            damage the victim by 0.01
            heal victim
            execute console command "/execute %victim% ~ ~ ~ particle witchMagic ~ ~0.8 ~ 0.3 0.5 0.3 1 100"
            execute console command "/execute %victim% ~ ~ ~ playsound minecraft:entity.player.hurt master %victim% ~ ~ ~ 1 1 0"
            #wait 1 tick
            #execute console command "/minecraft:tp %victim% -34 66 -1 -90 0"

Edit: After some more testing: The broadcasts don't actually display the true amount of damage taken. In one case I had a mob deal 1.5 hearts of damage, and the broadcast said 2.5 damage was taken. ??????
how do you know it actually dealt 1.5 hearts? where are you getting that from
 
how do you know it actually dealt 1.5 hearts? where are you getting that from
The mob that was tested was made using MythicMobs:
Code:
[REDACTED]:
  Skills:
  - damage{a=3} @target
  - effect:particles{particle=endRod;amount=50;speed=0;hS=0.2;vS=0.2;yOffset=1} @target
  - effect:particles{p=reddust;color=#94f0fc;amount=100;speed=1;hS=0.5;vS=0.5;yOffset=1} @target
  - effect:particles{particle=blockcrack_152;amount=50;speed=0.5;hS=0;vS=0;yOffset=1} @target
  - effect:sound{s=entity.firework.twinkle;p=2;v=1;} @target
  Conditions:
  - targetwithin{d=5}
It's the third line from the top. It deals 3 damage, or 1.5 hearts.
[doublepost=1517079380,1516919563][/doublepost]
I tested again with the broadcasts, and I found the same issue I put in my edit. The mob I was testing did 5 damage, and when I was at 6.25 hearts, I died. I should have been at one heart. If it helps, the broadcasts said the mob's damage was 5 while my health was 3.75 when I died.
yo still having this issue

it's not a problem with the mob plugin, it's a problem with the code I wrote, I know this
idk if you can get it any more accurate, and if you can't, then I guess I'll need to stop using this code and stick to the vanilla death system (which sucks cause I want to skip the dirt screen, oh well)
if I can't get any more help on here then I'll look on the skript wiki or poke around the internet a bit, but I beg to differ that I'll find something that fixes my issue
 
idk theres no reason this shouldnt work... you can always force respawn though https://docs.skunity.com/syntax/search/respawn
The point of this new system was to skip the death and dirt screen.
I'm probably going to have to switch back to the vanilla death system, though, as my code broke all of a sudden... Oh well, perfection is not always attainable.

If only there was a way to somehow detect when a player reaches 0 health before the death screen appears. The death event isn't cancellable from what I know.
[doublepost=1517612227,1517082537][/doublepost]I have now found out that a final damage bug lies in Skript. On a Github post I found, the post was marked as "wontfix"... will final damage not be fixed? Unless it is already fixed and I'm just pushing the limits.

And, on that same post, some guy said Skellett handles final damage correctly, yet it seems to make it worse from my tests with it. Also, I tested with armor this time and it turns out final damage doesn't work with armor.

Any suggestions or am I gonna have to stick with the vanilla death system (which is no problem other than having to go through a loading screen).
 
The point of this new system was to skip the death and dirt screen.
I'm probably going to have to switch back to the vanilla death system, though, as my code broke all of a sudden... Oh well, perfection is not always attainable.

If only there was a way to somehow detect when a player reaches 0 health before the death screen appears. The death event isn't cancellable from what I know.
[doublepost=1517612227,1517082537][/doublepost]I have now found out that a final damage bug lies in Skript. On a Github post I found, the post was marked as "wontfix"... will final damage not be fixed? Unless it is already fixed and I'm just pushing the limits.

And, on that same post, some guy said Skellett handles final damage correctly, yet it seems to make it worse from my tests with it. Also, I tested with armor this time and it turns out final damage doesn't work with armor.

Any suggestions or am I gonna have to stick with the vanilla death system (which is no problem other than having to go through a loading screen).

if you have no problem besides the loading screen then just force respawn
 
Status
Not open for further replies.