EV-EVA / Ectroverse

Open Source Text based Space Empire Simulator
9 stars 6 forks source link

Dark Webs - Recalculate every turn? #32

Open EV-EVA opened 11 years ago

EV-EVA commented 11 years ago

Dark Webs are increasingly popular and very effictive, but they tend to make playing against them a bit unbalanced.

Would it be possible for the Dark Web spell to, while stackable, recalculate it's %%'s every turn (kind of like War Illusions act nowadays).

Necrolgan commented 11 years ago

Add the following after the } on line 630 (do not remove it, just copy/paste this segment at the end of existing brace...

else if (specopd[i].type == (CMD_SPELL_DARKWEB | 0x1000)) {
        fa = 0.4 + (1.2/255.0) * (float)( rand() & 255 );
        nChicks = maind.totalunit[CMD_UNIT_WIZARD];
        nIllusion = ( fa * cmdRace[maind.raceid].unit[CMD_UNIT_WIZARD] * (float)nChicks * ( 1.0 + 0.005*maind.totalresearch[CMD_RESEARCH_WELFARE] ) / cmdPsychicopDifficulty[CMD_SPELL_DARKWEB] );
        penalty = cmdGetOpPenalty( maind.totalresearch[CMD_RESEARCH_WELFARE], cmdPsychicopTech[CMD_SPELL_DARKWEB] );
        if( penalty )
                nIllusion = (float)nIllusion / ( 1.0 + 0.01*(float)penalty );
        fa = 100.0 * (float)nIllusion / (float)maind.networth;
        a = (int)( fa * 3.5 );
            if (a<0)
                a = 0;
            specopd[i].vars[0] = a;
    }
Necrolgan commented 11 years ago

Upon real examination of the way the WI works, which is what I have cloned here... I don't like the way it works. It's literally re-casting the spells each tick... ... ouchies!

EV-EVA commented 11 years ago

Yes, but WI's aren't stackable, Dark Webs should be.

Will this affect that?

Necrolgan commented 11 years ago

Dark Webs have an accumulative effect (also known as stacking), that is already in play. The code below is un-touched.

float specopDarkWebCalc( int id )
{
  int a, b;
  float fr;
  dbUserSpecOpPtr specopd;
  fr = 1.0;
  if( ( b = dbUserSpecOpList( id, &specopd ) ) >= 0 )
  {
    for( a = 0 ; a < b ; a++ )
    {
      if( specopd[a].type != ( CMD_SPELL_DARKWEB | 0x1000 ) )
        continue;
      fr *= 1.0 + 0.01 * (float)specopd[a].vars[0];
    }
    free( specopd );
  }
  return fr;
}

What the code I posted in the first message does, is re-calculate ALL instances of Dark Web with each tick... as the War Illusions currently are.

Necrolgan commented 11 years ago

And it seems War Illusions actully does stack, but only 3 times.

float specopWarIllusionsCalc( int id )
{
  int a, b, c = 0;
  float pr;
  dbUserSpecOpPtr specopd;
  pr = 1.0;
  if( ( b = dbUserSpecOpList( id, &specopd ) ) >= 0 )
  {
    for( a = 0 ; a < b ; a++ )
    {
      if( specopd[a].type != ( CMD_SPELL_WARILLUSIONS | 0x1000 ) )
        continue;
      c++;
      if(c == 3)
        break;
      pr *= 1.0 + 0.01 * (float)specopd[a].vars[0];
    }
    free( specopd );
  }
  return pr;
}
EV-EVA commented 11 years ago

Then the stacking of the WI isn't shown in the operations page. If you cast WI multiple times, you only see 1. Are you sure the effects aren't cancelled out?

Necrolgan commented 11 years ago

Ahhh, my mistake sorry... they have also added a clause in to remove any existing spells.

    j = dbUserSpecOpList(id, &specop2d);
        for(i=0;i<j;i++)
        {
            if (specop2d[i].type == (CMD_SPELL_WARILLUSIONS | 0x1000))
            {
                dbUserSpecOpRemove(id, i);
            }
        }
Necrolgan commented 11 years ago

This is the original Cast Code

  else if( specop == CMD_SPELL_WARILLUSIONS )
  {
    newd[2] = CMD_NEWS_SPWARILLUSIONS;
    fa = 100.0 * (float)attack / (float)maind.networth;
    a = (int)( fa * 4.5 );
    if( a >= 0 )
    {
      newd[8] = a;
      specopd.vars[0] = a;
      specopd.type = CMD_SPELL_WARILLUSIONS | 0x1000;
      specopd.plnid = -1;
      specopd.plnpos = -1;
      newd[9] = 32 + ( rand() & 31 );
      specopd.time = newd[9];
      specopd.factionid = id;
      dbUserSpecOpAdd( id, &specopd );
    }
  }

This is what is now in play,

  else if( specop == CMD_SPELL_WARILLUSIONS )
  {

    newd[2] = CMD_NEWS_SPWARILLUSIONS;
    fa = 100.0 * (float)attack / (float)maind.networth;
    a = (int)( fa * 4.5 );
    a += a * rand()%20;
{
    if (a<0)
    a = 0;
    j = dbUserSpecOpList(id, &specop2d);
        for(i=0;i<j;i++)
        {
            if (specop2d[i].type == (CMD_SPELL_WARILLUSIONS | 0x1000))
            {
                dbUserSpecOpRemove(id, i);
            }
        }
        newd[8] = a;
      specopd.vars[0] = a;
      specopd.type = CMD_SPELL_WARILLUSIONS | 0x1000;
      specopd.plnid = -1;
      specopd.plnpos = -1;
      newd[9] = 32 + ( rand() & 31 );
      specopd.time = (int)newd[9];
      specopd.factionid = id;
      dbUserSpecOpAdd( id, &specopd );

    }
  }
Necrolgan commented 11 years ago

Also, here is the original formula for calculating their effects (it wasn't capped)

float specopWarIllusionsCalc( int id )
{
  int a, b;
  float pr;
  dbUserSpecOpPtr specopd;
  pr = 1.0;
  if( ( b = dbUserSpecOpList( id, &specopd ) ) >= 0 )
  {
    for( a = 0 ; a < b ; a++ )
    {
      if( specopd[a].type != ( CMD_SPELL_WARILLUSIONS | 0x1000 ) )
        continue;
      pr *= 1.0 + 0.01 * (float)specopd[a].vars[0];
    }
    free( specopd );
  }
  return pr;
}
ectrospeedy commented 10 years ago

i'm behind the idea of recalculating webs every tick too but another idea is to just increase the cost another 2%, to 24% (22% makes no sense :p) or even to 25 or 26% difficulty for nv went up, making webbers stronger, so a change here is in order for sure