15 Feb, 2013, Lyanic wrote in the 41st comment:
Votes: 0
Fixing the /n/r issue in certain Dikurivatives does take slightly more work than a single string replacement, but only slightly. The issue typically not caught by the string replacement is the save/load functions for various file types, which were saved with and use the incorrect EOL characters as delimiters when reading back in. It's still a very trivial thing to fix if you're not incompetent. Fixing it should take no more than an hour.
15 Feb, 2013, Xrakisis wrote in the 42nd comment:
Votes: 0
I mixed my new army battle version with what i liked from the first one and its working and looking awesome!
Thanks all for the help. im going to add army researches like alloys and archer range and attack/defense/health bonuses.
there are 5 rounds, siege eq only fires on certain rounds..
units have range so missile weapons hit first. i put distance at 1000 every time char_to_room is used and in the update it takes
100 feet off the distance each time its called

You are attacked by: 3500 Archers, 3500 Archer Infanty, 3500 Chariots, 3500 Militia, 3500 Phalanx, 3500 Legionnaire, 3500 Heavy Infantry, 3500 Axemen, 3500 Light Cavalry, 3500 Medium Cavalry, 3500 Heavy Cavalry, 3500 Knights, 3500 Battle Rams
[Your army is attacked and takes :5512500 damage]
[Round: 2]
You attack with: 2395 Ballistae, 2395 Archers, 2395 Archer Infanty, 2394 Chariots, 2395 Militia, 2395 Phalanx, 2395 Legionnaire, 2395 Heavy Infantry, 2395 Axemen, 2394 Light Cavalry, 2395 Medium Cavalry, 2394 Heavy Cavalry, 2395 Knights, 2395 Battle Rams
[Your army of: 81412 attacks Their army of:119000]

[You deal 5927300 damage against their armies 313800000 Total Health
[Your Army damage: 5927300]
You've dealt 4 attacks causing 17697 damage. (4424 average)
You've been struck by 2 attacks, causing 2263 damage. (1131 average)

next round..

You are attacked by: 3387 Trebuchets, 3387 Scorpions, 3387 Archers, 3387 Archer Infanty, 3387 Chariots, 3387 Militia, 3387 Phalanx, 3387 Legionnaire, 3387 Heavy Infantry, 3387 Axemen, 3386 Light Cavalry, 3387 Medium Cavalry, 3387 Heavy Cavalry, 3387 Knights, 3387 Battle Rams
[Your army is attacked and takes :22777500 damage]
[Round: 3]
You attack with: 1959 Scorpions, 1960 Catapult, 1959 Archers, 1959 Archer Infanty, 1959 Chariots, 1959 Militia, 1959 Phalanx, 1959 Legionnaire, 1959 Heavy Infantry, 1959 Axemen, 1959 Light Cavalry, 1959 Medium Cavalry, 1959 Heavy Cavalry, 1959 Knights, 1959 Battle Rams
[Your army of: 66605 attacks Their army of:115142]
[You deal 5340125 damage against their armies 302360300 Total Health
[Your Army damage: 5340125]


[code]
void battle_update( void )
{
CHAR_DATA *ch;
CHAR_DATA *ch_next;
CHAR_DATA *victim;
CHAR_DATA *rch;
CHAR_DATA *rch_next;
DESCRIPTOR_DATA *d;
char buf[MAX_STRING_LENGTH];
int chance;
int armymight = 0;
int varmymight = 0;
int roundtime;
int totalfighting = 0;
int vtotalfighting = 0;
unsigned long int chfighting = 0;
int vfighting = 0;
int distance;
chance = number_percent();
unsigned long int x, y, dam;
unsigned long int chdam = 0;
unsigned long int vlife = 0;
for (ch = first_fight; ch != NULL; ch = ch_next)
{
ch_next = ch->next_fight;
if ((victim = ch->fighting) == NULL || ch->in_room == NULL)
{
stop_fighting (ch, FALSE);
continue;
}
if ((victim = ch->fighting) == NULL)
{
stop_fighting (ch, FALSE);
continue;
}


totalfighting = ch->militia;
totalfighting += ch->pikemen;
totalfighting += ch->swordsmen;
totalfighting += ch->heavy_infantry;
totalfighting += ch->axemen;
totalfighting += ch->archers;
totalfighting += ch->archerinfantry;
totalfighting += ch->chariots;
totalfighting += ch->light_cavalry;
totalfighting += ch->medium_cavalry;
totalfighting += ch->heavy_cavalry;
totalfighting += ch->knights;
totalfighting += ch->ballistas;
totalfighting += ch->catapults;
totalfighting += ch->rams;
totalfighting += ch->scorpions;
totalfighting += ch->trebuchets;
vtotalfighting = victim->militia;
vtotalfighting += victim->pikemen;
vtotalfighting += victim->swordsmen;
vtotalfighting += victim->heavy_infantry;
vtotalfighting += victim->axemen;
vtotalfighting += victim->archers;
vtotalfighting += victim->archerinfantry;
vtotalfighting += victim->chariots;
vtotalfighting += victim->light_cavalry;
vtotalfighting += victim->medium_cavalry;
vtotalfighting += victim->heavy_cavalry;
vtotalfighting += victim->knights;
vtotalfighting += victim->ballistas;
vtotalfighting += victim->catapults;
vtotalfighting += victim->rams;
vtotalfighting += victim->scorpions;
vtotalfighting += victim->trebuchets;

if (ch->roundtime <= 5) ch->roundtime++;
if (ch->army_distance > 100) ch->army_distance -= 100;
roundtime = ch->roundtime;
distance = ch->army_distance;
if (totalfighting <= 0 || vtotalfighting <= 0) return;

sprintf(buf,"[#YRound: #R%d#n]\n\r",ch->roundtime);
stc(buf,ch);

stc("#RYou are attacked by: #n",victim);
stc("#RYou attack with: #n",ch);
if (ch->trebuchets >= 1 && roundtime == 1)
{
chfighting = (ch->trebuchets - (ch->trebuchets / 2));
sprintf(buf,"%d Trebuchets, ",chfighting);
stc(buf,victim);
stc(buf,ch);
chdam += chfighting * TREBUCHET_ATTACK;
}
if ((ch->scorpions >= 1 && distance <= 400)
&& (roundtime == 1 || roundtime == 3 || roundtime == 5))
{
chfighting = (ch->scorpions - (ch->scorpions / 2));
sprintf(buf,"%d Scorpions, ",chfighting);
stc(buf,victim);
stc(buf,ch);

chdam += chfighting * SCORPION_ATTACK;
}
if( (ch->ballistas >= 1 && distance <= 20) && (roundtime == 2 || roundtime == 4))

{
chfighting = (ch->ballistas - (ch->ballistas / 2));
sprintf(buf,"%d Ballistae, ",chfighting);
stc(buf,victim);
stc(buf,ch);
chdam += chfighting * BALLISTA_ATTACK;
}
if ((ch->catapults >= 1 && distance <= 600) && (roundtime == 3 || roundtime == 5))
{
chfighting = (ch->catapults - (ch->catapults / 2));
sprintf(buf,"%d Catapult, ",chfighting);
stc(buf,victim);
stc(buf,ch);
chdam += chfighting * CATAPULT_ATTACK;
}
if (ch->archers >= 1 && distance <= 400)
{
chfighting = (ch->archers - (ch->archers / 2));
sprintf(buf,"%d Archers, ",chfighting);
stc(buf,victim);
stc(buf,ch);
chdam += chfighting * ARCHER_ATTACK;
}
if (ch->archerinfantry >= 1 && distance <= 350)
{
chfighting = (ch->archerinfantry - (ch->archerinfantry / 2));
sprintf(buf,"%d Archer Infanty, ",chfighting);
stc(buf,victim);
stc(buf,ch);
chdam += chfighting * ARCHERINF_ATTACK;
}

if (ch->chariots >= 1 && distance <= 300)
{
chfighting = (ch->chariots - (ch->chariots / 2));
sprintf(buf,"%d Chariots, ",chfighting);
stc(buf,victim);
stc(buf,ch);
chdam += chfighting * CHARIOT_ATTACK;
}

if (ch->militia >= 1 && distance == 0)
{
chfighting = (ch->militia - (ch->militia / 2));
sprintf(buf,"%d Militia, ",chfighting);
stc(buf,victim);
stc(buf,ch);
chdam += chfighting * MILITIA_ATTACK;
}

if (ch->pikemen >= 1 && distance == 0)
{
chfighting = (ch->pikemen - (ch->pikemen / 2));
sprintf(buf, "%d Phalanx, ",chfighting);
stc(buf,victim);
stc(buf,ch);
chdam += chfighting * PIKEMAN_ATTACK;
}
if (ch->swordsmen >= 1 && distance == 0)
{
chfighting = (ch->swordsmen - (ch->swordsmen / 2));
sprintf(buf, "%d Legionnaire, ",chfighting);
stc(buf,victim);
stc(buf,ch);
chdam += chfighting * SWORDSMAN_ATTACK;
}
if (ch->heavy_infantry >= 1 && distance == 0)
{
chfighting = (ch->heavy_infantry - (ch->heavy_infantry / 2));
sprintf(buf, "%d Heavy Infantry, ",chfighting);
stc(buf,victim);
stc(buf,ch);
chdam += chfighting * HINF_ATTACK;
}
if (ch->axemen >= 1 && distance == 0)
{
chfighting = (ch->axemen - (ch->axemen / 2));
sprintf(buf, "%d Axemen, ",chfighting);
stc(buf,victim);
stc(buf,ch);
chdam += chfighting * AXEMAN_ATTACK;
}
if (ch->light_cavalry >= 1 && distance == 0)
{
chfighting = (ch->light_cavalry - (ch->light_cavalry / 2));
sprintf(buf, "%d Light Cavalry, ",chfighting);
stc(buf,victim);
stc(buf,ch);
chdam += chfighting * LCAV_ATTACK;
}
if (ch->medium_cavalry >= 1 && distance == 0)
{
chfighting = (ch->medium_cavalry - (ch->medium_cavalry / 2));
sprintf(buf, "%d Medium Cavalry, ",chfighting);
stc(buf,victim);
stc(buf,ch);
chdam += chfighting * MCAV_ATTACK;
}
if (ch->heavy_cavalry >= 1 && distance == 0)
{
chfighting = (ch->heavy_cavalry - (ch->heavy_cavalry / 2));
sprintf(buf, "%d Heavy Cavalry, ",chfighting);
stc(buf,victim);
stc(buf,ch);
chdam += chfighting * HCAV_ATTACK;
}
if (ch->knights >= 1 && distance == 0)
{
chfighting = (ch->knights - (ch->knights / 2));
sprintf(buf, "%d Knights, ",chfighting);
stc(buf,victim);
stc(buf,ch);
chdam += chfighting * KNIGHT_ATTACK;
}
if (ch->rams >= 1 && distance == 0)
{
chfighting = (ch->rams - (ch->rams / 2));
sprintf(buf, "%d Battle Rams",chfighting);
stc(buf,victim);
stc(buf,ch);
chdam += chfighting * RAM_ATTACK;
}
//stc(".\n\r",victim);
//stc(".\n\r",ch);
if (roundtime >= 5) roundtime = 1;

//dam = chdam / 200;
//chdam -= dam;

// armies damaging players commented out til i get a better formula for percent of enemy army damage vs the player

//sprintf(buf,"\n\r[#YYour damage: #R%d#n]\n\r",dam);
//stc(buf,ch);

//sprintf(buf,"[#YYou are attacked and take :#R%d#Y damage#n]\n\r",dam);
//stc(buf,victim);
//
//hurt_person(ch, victim, dam, 0);
/*

chdam += ch->militia * MILITIA_ATTACK;
chdam += ch->pikemen * PIKEMAN_ATTACK;
chdam += ch->swordsmen * SWORDSMAN_ATTACK;
chdam += ch->heavy_infantry * HINF_ATTACK;
chdam += ch->axemen * AXEMAN_ATTACK;
chdam += ch->archers * ARCHER_ATTACK;
chdam += ch->archerinfantry * ARCHERINF_ATTACK;
chdam += ch->chariots * CHARIOT_ATTACK;
chdam += ch->light_cavalry * LCAV_ATTACK;
chdam += ch->medium_cavalry * MCAV_ATTACK;
chdam += ch->heavy_cavalry * HCAV_ATTACK;
chdam += ch->knights * KNIGHT_ATTACK;
chdam += ch->ballistas * BALLISTA_ATTACK;
chdam += ch->catapults * CATAPULT_ATTACK;
chdam += ch->rams * RAM_ATTACK;
chdam += ch->scorpions * SCORPION_ATTACK;
chdam += ch->trebuchets * TREBUCHET_ATTACK;
*/
vlife += victim->militia * MILITIA_HP;
vlife += victim->pikemen * PIKEMAN_HP;
vlife += victim->swordsmen * SWORDSMAN_HP;
vlife += victim->heavy_infantry * HINF_HP;
vlife += victim->axemen * AXEMAN_HP;
vlife += victim->archers * ARCHER_HP;
vlife += victim->archerinfantry * ARCHERINF_HP;
vlife += victim->chariots * CHARIOT_HP;
vlife += victim->light_cavalry * LCAV_HP;
vlife += victim->medium_cavalry * MCAV_HP;
vlife += victim->heavy_cavalry * HCAV_HP;
vlife += victim->knights * KNIGHT_HP;
vlife += victim->ballistas * BALLISTA_HP;
vlife += victim->catapults * CATAPULT_HP;
vlife += victim->rams * RAM_HP;
vlife += victim->scorpions * SCORPION_HP;
vlife += victim->trebuchets * TREBUCHET_HP;


sprintf(buf,"\n\r[#yYour army of: #R%d#n attacks #yTheir army of:#R%d]\n\r", totalfighting, vtotalfighting);
stc(buf,ch);
sprintf(buf,"\n\r[#yYou deal %d damage against their armies %d Total Health\n\r", chdam, vlife);
stc(buf,ch);
sprintf(buf,"[#yYour Army damage: #R%d#n]\n\r",chdam);
stc(buf,ch);
sprintf(buf,"\n\r[#yYour army is attacked and takes :#R%d#Y damage#n]\n\r",chdam);
stc(buf,victim);

unsigned long int n;
for (n=1; n < chdam; n++)
{

if (chdam > CHARIOT_HP && victim->chariots >= 1)
{ victim->chariots–;
chdam -= CHARIOT_HP;}
if (chdam > HCAV_HP && victim->heavy_cavalry >= 1)
{ victim->heavy_cavalry–;
chdam -= HCAV_HP;}
if (chdam > KNIGHT_HP && victim->knights >= 1)
{ victim->knights–;
chdam -= KNIGHT_HP;}
if (chdam > MCAV_HP && victim->medium_cavalry >= 1)
{ victim->medium_cavalry–;
chdam -= MCAV_HP;}
if (chdam > LCAV_HP && victim->light_cavalry >= 1)
{ victim->light_cavalry–;
chdam -= LCAV_HP;}
if (chdam > PIKEMAN_HP && victim->pikemen >= 1)
{ victim->pikemen–;
chdam -= PIKEMAN_HP;}
if (chdam > RAM_HP && victim->rams >= 1)
{ victim->rams–;
chdam -= RAM_HP;}
if (chdam > HINF_HP && victim->heavy_infantry >= 1)
{ victim->heavy_infantry–;
chdam -= HINF_HP;}
if (chdam > SWORDSMAN_HP && victim->swordsmen >= 1)
{ victim->swordsmen–;
chdam -= SWORDSMAN_HP;}
if (chdam > AXEMAN_HP && victim->axemen >= 1)
{ victim->axemen–;
chdam -= AXEMAN_HP;}
if (chdam > MILITIA_HP && victim->militia >= 1)
{ victim->militia–;
chdam -= MILITIA_HP;}
if (chdam > ARCHERINF_HP && victim->archerinfantry >= 1)
{ victim->archerinfantry–;
chdam -= ARCHERINF_HP;}
if (chdam > ARCHER_HP && victim->archers >= 1)
{ victim->archers–;
chdam -= ARCHER_HP;}
if (chdam > SCORPION_HP && victim->scorpions >= 1)
{ victim->scorpions–;
chdam -= SCORPION_HP;}
if (chdam > BALLISTA_HP && victim->ballistas >= 1)
{ victim->ballistas–;
chdam -= BALLISTA_HP;}
if (chdam > CATAPULT_HP && victim->catapults >= 1)
{ victim->catapults–;
chdam -= CATAPULT_HP;}
if (chdam > TREBUCHET_HP && victim->trebuchets >= 1)
{ victim->trebuchets–;
chdam -= TREBUCHET_HP;}
}

if (ch->roundtime >= 5) ch->roundtime = 0;
}


return;
}

[/code]
40.0/42