2

I am making a map based on spellcasting. There are 5 unique classes, and there can be only 1 player per class. The spells are retextured invisible snowball with particle effects that carry the launcher "class" score:

/execute @e[type=Snowball,score_Lifetime=1] ~ ~ ~ /scoreboard players operation @e[type=Snowball,c=1] class = @p class

I want to check and add a point in the "kills" scoreboard for a player that kills another player with a snowball power, for example the 1st class summons a creeper where the snowball lands.

  • 3
    Hmm... This is actually going to end up being trickier than it sounds. Probably possible, but definitely not easy to do. Speaking from experience having built the "explode snowball on impact" component of this sort of thing – Unionhawk Mar 28 '16 at 13:53
2

I know this question is old, but since I have an answer I might as well post it.

You can add the snowball (or an entity summoned by the snowball) to a particular team depending on the snowball's class. You can then create a scoreboard objective tracking 'killedByTeam.that_team's_color' for every player. Any given player's kill count will be the sum of all scores in the corresponding objective.

so for example, if you've got a class sorcerer with a class score of 3, you could do this:

Run once at the beginning:

/scoreboard teams add Sorcerer
/scoreboard teams option Sorcerer color gold
/scoreboard objectives add sorcererKill killedByTeam.gold
/scoreboard players set @a sorcererKill 0

Run in a repeating command block:

/scoreboard teams join Sorcerer @e[type=Snowball,score_class=3,score_class_min=3]

(or something to that effect to select an entity summoned by the snowball)

Then when you want to check the sorcerer's kill count:

/scoreboard players operation @p[score_class=3,score_class_min=3] kills += * sorcererKill

(if you're planning to check this score more than once, you'll also want to run /scoreboard players set @a sorcererKill 0 at this time.)

this may not work in cases where the spell sets off a long chain reaction or includes something like fall damage that isn't attributed to an entity, but it sounds like you know your way around the scoreboard, so you can probably adapt this setup to cover those cases.

Hope this helps!

  • Thanks for the help. I have already figure out another solution, but yours seems more reliable. My solution was summoning an Armor Stand where the snowball landed to check for player items. If it finds any, it will add 1 to the respective class's kill score. The only problemi with this is that if 2 players get a kill in the exact moment (a 3-tick window) both would get 2 kills instead of 1. – Mario Biavati Dec 4 '16 at 8:03
  • ah, I see. Yeah, this system allows for more precision. Glad to help! ^^ – TenNineAce Dec 4 '16 at 16:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.