Minecolonies & PvP System Part #1

in #utopian-io6 years ago (edited)

Hey everyone, one of the dreams we always had with minecolonies was to provide a similar gameplay to games like age of empires or the settlers, one of the central missing elements for this was player vs player, or better, colony vs colony war elements.

Since it is a huge update we will introduce this slowly while we improve our guards AI into the game.

This will be the first update which will introduce the basic elements which are required to make this work.

What changed:

So, for this we created a number of changes, starting with a configuration value which allows you to toggle this option on and off.

Then, we added handling to be able to differentiate your guards from the other people's guards.

Where you can trigger the color you want and your guard will then, when in war mode, switch to the correct color.

The name tag, independently, of the mode, will be of this color as well.



Then, in order to go to war a number of conditions have to be met:

  • You have to have the person marked as hostile, or the other person has to have you added as hostile.

  • If only you marked him as hostile you can be max twice as strong as him to avoid overpowered people crushing minnows.

  • Also, in order to be able to destroy someone elses colony, you will have to have guards with you, the moment your last guard dies, you can't act in the colony anymore (To avoid people hiding underground or similar)

And, lastly, we added that when a player attacks a colony and is able to destroy the townhall, the whole colony will be destroyed, for that reason we made the townhall block difficult to be destroyed and added a warning message for the player while it is being destroyed.

How it's done:

Permission setup:

Let's start easy. In order to make the townhall stronger, we increase the hardness if the pvp mode is on.

Now, the next thing is a bit more complex, in order to tell if the townhall is being mined and to figure how much percent we have to calculate this and detect the event.

For this, we capture the PlayerEvent.BreakSpeed event and check for a number of conditions:

  • Is the position within the colony of the eventhandler.
  • Is the pvp mode on
  • Is the block the townhall
  • Is this event being captured on the server side?

Then, if all of these are given I created a number of variables.

breakProgressOnTownHall to get the progress on each call
validTownHallBreak to check if all necessary ticks were run through (to avoid griefing)
lastTownHallBreakingTick to make sure to reset the variable when the break event had been intercepted.

Then we calculate the progress getting the hardness of the block times 20 times 1.5 (constants) and divide it by the incoming speed.

Then, on each progress (On the exact point and not on the intervals) we get all responsible players of the colonies and notify them.

I the progress is big enough we validate the townhall breaking and if there were gaps in the ticks we reset the values.

Then, in the break event, we check if the townhall breaking is valid and else we cancel it.

If it is valid and we're in pvp mode and we're breaking a townhall we delete the colony.

For all other griefing related events we added a check in the permission handling.
Which checks if the pvp mode is on, we're on the server sie and the attack is valid (the player has enough guards and his level is not too high)

Attacking Player Detection:

To detect the attacker detection we hijecked our general player detection and added a detection of guards entering chunks.

When we detect a guard entering a chunk with the event handler. We get its colony and check if he is in another colony (from the capability of the chunk) if that's the case, we add the guard to the attacker list of the colony. If the player is not in the colony yet, that's no problem since we run this check on every chunk entry.

When he enters we also get the player he is supposed to follow and hand it to the colony.

The method in the colony will go through all visiting players and check if the following player is one of them, if that's the case it will transform him into an attacking player.

If he is an attacking player already, it will add the guard to his list of guards.

To make sure we detect deaths, every few ticks we run a cleanup on this list.

And, to store the data we created a class to store these.

And to check if the attack is valid. By checking if there are guards, if the colonies are hostile to each other and if one colony is too strong (the attacking colony).

Guard changes:

We also adaptated a few things at the guards as in:

Adding the glow effect on him.

Let them armor pierce in pvp.

and increase their damage to players.

We also fixed some issues with the following mode and we increased the block mining modifier in the pvp mode to make workers more efficient so players can focus on the pvp part of the mod.

We also disabled friendly fire in the citizens on follow mode and added colonies automatically on hostile on the attack on a citizen.

And, finally, also added the glow to the player which wants to be followed by a bunch of guards.

Color changes:

Now, to add the colors we made use of the team mechanic Minecraft has which allows players to be surrounded by the color and assign them to teams (Else all guards would have the same color).

For that, we added the TeamColonyColor variable to the colony and colonyView (client-side representation of the colony.

Which is written to file on shutdown and reloaded on startup.
It sets the color of the team and the prefix to change the name display as well.

Then, we added the color picker to the GUI.
Where we filter all colors from the TextFormatting enum and add them to the list, we also add a change handler and a switcher for the color.

On change, it then sends a message to the server (since GUI handling is client side) to update the value.

In a message which gets the colony and assigns the color to it.

This was a bunch of work which I tested over the last week which delayed the other updates I wanted to deliver, I hope you apprettiate the new changes coming and I'll see you on the battlefield!

Pull Request:

Sort:  
  • Congratulations on this great achievement! PvP or CvC is a great milestone for any gaming project. It's a great one for Minecraft.
  • You've gotten my first perfect score. You deserve it.

Your contribution has been evaluated according to Utopian policies and guidelines, as well as a predefined set of questions pertaining to the category.

To view those questions and the relevant answers related to your post, click here.


Need help? Write a ticket on https://support.utopian.io/.
Chat with us on Discord.
[utopian-moderator]

I was a huge minecraft player back in the old days, tell me something is the server playable now? what is the ip to get in it!? You should also check out enjin and maybe try to eiter put enjin on the server or work something with STEEM!

Our server doesn't have the pvp mode enabled, but it's playeable and has a bunch of players, just download the modpack, the server ip is preset: https://minecraft.curseforge.com/projects/minecolonies-testpack/files
We don't use enjin, but we have Patreon, discord and our own forum =)

Hey @raycoms
Thanks for contributing on Utopian.
We’re already looking forward to your next contribution!

Want to chat? Join us on Discord https://discord.gg/h52nFrV.

Vote for Utopian Witness!

Coin Marketplace

STEEM 0.22
TRX 0.26
JST 0.040
BTC 98411.40
ETH 3463.94
USDT 1.00
SBD 3.21