[SteemNova] Combat system rework

in #utopian-io6 years ago (edited)

image.png

SteemNova is based on 2Moons Open Source Browsergame Framework. The framework's goal is to be as much similar to Ogame mechanics as possible. Most important here is battle engine which is very simplified and inaccurate to online Ogame calculators. This contribution describes how it is rewritten from the scratch for SteemNova uses.

True random shots and 1v1 fights

What original engine lacked most was the randomness of each fire and how it penetrates enemy hulls. The units were grouped to each ship class like Cruisers, Little Fighters, Battleships etc. Then this whole group shot at enemy group of ships, calculating damage as firepower - (shield + armor).
New engine takes each ship independent. It chooses true rand() enemy unit and proceed to next ship. This way every battle has a little random factor and can result different.

$victimFleetId = array_rand($defenders)
$victimShipId = rand(0, count($victimFleet['units'])-1)

Core of combat randomness

The radomness grows high enough so that attack power doesn't vary +/-20% of initial anymore. This improves the calculation speed also.

Separating units from groups is a nerf of shielding system. Right now shields does break for each ship instead of "big summarized shield". It is intended and works much better than in original framework.

For example: old fights needed to destroy shield of EVERY enemy ship to start damaging its' hull. New fights comes with possibility to damage ship just after it's single shield pops!

Armor did regenerate each turn (bug)

There was huge flaw in combat round results. If the ship armor wasn't destroyed completely it regenerated fully into next round fight. This was a huge problem, because if ship wasn't destroyed in one turn, it comes back as fully repaired unit! That flaw is a big advantage to big ships. The bigger the ship, the bigger its armor and the harder it is to destroy it. Top players were flying the galaxies with advantage over younger fleets.

Bounced shots

Vanilla Ogame had something like "bounced shots". If the attack power of assault unit is less than 1% of enemy target ship, then it is considered a miss or a bounce. In the result it does not do any damage. This is best to seen in fights of Little Fighters or Cruisers versus Death Star. They are just too weak to even scratch big giant.

if ($unit['att'] * 100 > $victimShip['shield'])
{
    ...
}
// else bounced hit (Weaponry of the shooting unit is less than 1% of the Shielding of the target unit)

Chance of exploding damaged unit

The feature of exploding ships is another new one here. It is something hardly anyone Ogame player knows of, but it is specified in combat rules. If ship is damaged for over 30% health, it has chance of exploding in probability of 1 - H/H_i (H_i initial armor). It still can shoot to other units until round ends.

if ($unit['armor'] < 0.7 * $initialArmor)
{
    $ran = rand(0, $initialArmor);
    if ($ran > $unit['armor'])
    {
        // explode unit
        ...

Combat reports doesn't cut randomly (bugfix)

It was common that combat reports didn't show its full history. Sometimes it ended round or a two too early showing bad results. Reports sometimes didn't produce 6th round or final standings after whole fight which was weird. It appeared simple fix had to be given.

foreach($player['unit'] as $ShipID => $Amount)
{
    if ($Amount <= 0) {
        // $Destroy['def']++; << comment this
        continue;
}

Reports cut fix

Combat engine optimization

All above needed some improvements. Many foreach in foreach consumes a lot of server resources. I was looking for something more efficient than php arrays[]. I have found php-ds extension. It is set of libraries of many data structures for PHP 7. Ds\Map and Ds\Vector was the ones I needed. These structures improved code execution by about 10x factor.

New code engine was tested at up to 500k units battles with success (1 core cpu, <128MB ram usage). For bigger battles better server is needed or improve combat engine optimization.

Install php-ds extension:

  • apt-get install php-pear php7.0-dev
  • pecl install ds
  • create file 30-ds.ini with content extension=ds.so and put in /etc/php/7.0/apache2/conf.d/ source

README file was updated by commands how to setup php-ds extension on the server

Information

steemnova/steemnova project is fork of jkroepke/2Moons Open Source Browsergame Framework. The goal is to fix bugs and develop the engine in the direction of maximum Steem integration.

Links



Posted on Utopian.io - Rewarding Open Source Contributors

Sort:  

Thank you for the contribution. It has been approved.

You can contact us on Discord.

[utopian-moderator]

Hey @ms10398, I just gave you a tip for your hard work on moderation. Upvote this comment to support the utopian moderators and increase your future rewards!

Thank you for the further improvements done on Steemnova, and rhe explanations given in your post. Special thanks fpr introducing php-ds to us.

Hey everbody

My name is marsell and I am on Rank1 in Steemnova since a long time...

LET ME WARN YOU!!!

!!! DONT PLAY THIS SHIT GAME!!!!!

CHEATING ADMINS
BUGUSING ADMINS
LYING ADMINS
UNFAIR AND UNBALANCED

This is steemnova...

nice ideal

Great news for all players, last combat system was buggy and sometimes gave unexpected outcome. Hope steemnovians would love it ;)

this is very excellent job .

ty 4 ur work to make the game better

I love this. A ship just randomly blowing up after taking some damage. That is wonderful.

Thank you for your continuing work I’ve been enjoying this game so far. I can see this world going on for a number of years.

Is there a win/reset condition? I have seen games like this type go on for quite a fear years. As such that is just something I've been wondering.

Nice job, I noticed the steem nova logo is no longer in the upper left corner, are you no longer using that name...? Do you need any new artwork or logos for this game?

It got replaced while patching by mistake. We don't want to use the name "2Moons".
New blue neon-logo coming back again.

Hey @mys I am @utopian-io. I have just upvoted you!

Achievements

  • Seems like you contribute quite often. AMAZING!

Community-Driven Witness!

I am the first and only Steem Community-Driven Witness. Participate on Discord. Lets GROW TOGETHER!

mooncryption-utopian-witness-gif

Up-vote this comment to grow my power and help Open Source contributions like this one. Want to chat? Join me on Discord https://discord.gg/Pc8HG9x

Coin Marketplace

STEEM 0.30
TRX 0.12
JST 0.034
BTC 64513.75
ETH 3146.11
USDT 1.00
SBD 3.95