From: Michael Andreen Date: Thu, 11 Apr 2002 18:43:58 +0000 (+0000) Subject: emp works now too.. X-Git-Tag: HBS_0_1_0~11 X-Git-Url: https://ruin.nu/git/?p=hbs.git;a=commitdiff_plain;h=9f0513b48fbafa876159812f638019c6b47eae33 emp works now too.. --- diff --git a/bs/bsdoc.cpp b/bs/bsdoc.cpp index fcfbcb9..047248f 100644 --- a/bs/bsdoc.cpp +++ b/bs/bsdoc.cpp @@ -66,6 +66,9 @@ int BSDoc::newBattle(QString name) m_Battles[name]["Friendly"]["Home Fleet"] = new Fleet(); m_Battles[name]["Hostile"]["Evil guy"] = new Fleet(); + m_Battles[name]["Friendly"]["Home Planet"]->setName("Home Planet"); + m_Battles[name]["Friendly"]["Home Fleet"]->setName("Home Fleet"); + m_Battles[name]["Hostile"]["Evil guy"]->setName("Evil guy"); //Planet* pl = dynamic_cast(m_Battles[name]["Friendly"]["Home Planet"]); modified = true; emit documentChanged(); diff --git a/bs/fleet.cpp b/bs/fleet.cpp index 2daa5cf..95ae6d3 100644 --- a/bs/fleet.cpp +++ b/bs/fleet.cpp @@ -237,15 +237,17 @@ void Fleet::distributeLossesGains(std::vector fleets, int tick = 0) { string unittype = i->first; - cerr << "Distributing type: " << unittype << endl; if (m_Fleet[unittype].size() < 1) continue; if (m_Fleet[unittype][0] == 0) continue; - int totallost = m_Fleet[unittype][1] - m_Fleet[unittype][0]; + + int totallost = fleet(unittype,1) - fleet(unittype, 0); + + cerr << "Distributing type: " << unittype << " with a total loss of " << totallost << " units" << endl; for (vector::iterator j = fleets.begin(); j != fleets.end(); ++j) { @@ -266,7 +268,7 @@ std::vector Fleet::calculateSide(std::vector fleets, int stays = if (( tick - (*i)->ETA()) >= 0 && (tick - (*i)->ETA()) < stays) { fl.push_back((*i)); - cerr << "Using fleet " << (*i)->name() << " for tick " << tick; + cerr << "Using fleet " << (*i)->name() << " for tick " << tick << endl; } else if ((*i)->name() == "Home Planet") fl.push_back((*i)); @@ -298,18 +300,17 @@ int Fleet::freeFleet(std:: string unittype, int tick = 0) void Fleet::takeShoot(std::string unittype, int number, std::map& hitunits) { - cerr << unittype << ": " << number << " in number\n"; int guns = s_Units[unittype].guns() * number; if (guns == 0) return; - cerr << unittype << " with " << guns << " guns\n"; + cerr << unittype << ": with " << guns << " guns\n"; int gunsleft = guns; for (int count = 0; count < 3; ++count)//vector::iterator i = s_Units[unittype].target().begin(); i != s_Units[unittype].target().end(); ++i) { string ta = s_Units[unittype].target(count); - cerr << "Shooting at target class: " << ta << endl; + cerr << "Shooting at target class: " << ta << endl; while (gunsleft > 0) { @@ -319,7 +320,7 @@ void Fleet::takeShoot(std::string unittype, int number, std::mapfirst].size() == 0) - break; + continue; if (m_Fleet[j->first].size() == 1) m_Fleet[j->first].push_back(m_Fleet[j->first][0]); @@ -329,7 +330,7 @@ void Fleet::takeShoot(std::string unittype, int number, std::mapfirst][1] > 0 && ( ta == j->second.unitClass() || ta == "All")) { - cerr << "Looking at target: " << j->first << endl; + // cerr << "Looking at target: " << j->first << endl; targets[j->first] = &m_Fleet[j->first][1]; } @@ -349,9 +350,8 @@ void Fleet::takeShoot(std::string unittype, int number, std::mapfirst] <= 0 || m_Armor[j->first] > s_Units[j->first].armor()) m_Armor[j->first] = s_Units[j->first].armor(); - float k = maxguns; + double k = maxguns; - int blaha = 0; cerr << "Targets agility: " << s_Units[j->first].agility() << endl; cerr << "Weaponspeed: " << s_Units[unittype].weaponSpeed() << endl; while (k > 0) @@ -359,7 +359,14 @@ void Fleet::takeShoot(std::string unittype, int number, std::mapsecond) <= 0) break; - k -= 100/(25+s_Units[unittype].weaponSpeed() - s_Units[j->first].agility()); + + int wpsp = s_Units[unittype].weaponSpeed(); + int agil = s_Units[j->first].agility(); + + k -= float(100)/(25 + wpsp - agil); + //cout << "Used " << blaha << " guns to hit with one shot.\n"; + //cout << "WPSP: " << wpsp << "\nAgil: " << agil << endl; + m_Armor[j->first] -= s_Units[unittype].power(); if (m_Armor[j->first] <= 0) { @@ -398,7 +405,81 @@ void Fleet::takeShoot(std::string unittype, int number, std::map::iterator i = s_Units[unittype].target().begin(); i != s_Units[unittype].target().end(); ++i) + { + string ta = s_Units[unittype].target(count); + cerr << "Shooting at target class: " << ta << endl; + while (gunsleft > 0) + { + + map targets; + + for (UnitList::iterator j = s_Units.begin(); j != s_Units.end(); ++j) + { + if (j->second.type() == "PDS") + continue; + + if (m_Fleet[j->first].size() == 0) + continue; + + if (m_Fleet[j->first].size() == 1) + m_Fleet[j->first].push_back(m_Fleet[j->first][0]); + + //cerr << "Target is class: " << j->second.type() << endl; + + if (m_Fleet[j->first][1] > 0 && ( ta == j->second.unitClass() || ta == "All")) + { + + // cerr << "Looking at target: " << j->first << endl; + targets[j->first] = &m_Fleet[j->first][1]; + } + + } + + if (targets.size() == 0) + break; + + int total = 0; + for (map::iterator j = targets.begin(); j != targets.end(); ++j) + total += (*j->second); + + for (map::iterator j = targets.begin(); j != targets.end(); ++j) + { + int maxguns = (*j->second)/total * guns; + cerr << "Now shooting at target: " << j->first << endl; + + double k = maxguns; + + int hits = 0; + + while (k > 0) + { + + if (*(j->second) <= 0) + break; + + int eres = s_Units[j->first].EMP(); + k -= float(100)/(100-eres); + hits++; + blockFleet(j->first, 1); + } + + cerr << hits << " units of type: " << j->first << " blocked\n"; + if (k <= 0) + gunsleft -= maxguns; + else + gunsleft -= maxguns - k; + } + } + } } ////////////////////////////////////////////////////////////////////////// @@ -467,3 +548,22 @@ void Fleet::printFleet() } } } + +////////////////////////////////////////////////////////////////////////// +// +void Fleet::blockFleet(std::string unittype, int number, int tick = 0) +{ + if (m_BlockedFleet[unittype].size() >= 1) + { + m_BlockedFleet[unittype][0] += number; + if (m_BlockedFleet[unittype].size() > 1) + m_BlockedFleet[unittype][1] += number; + else + m_BlockedFleet[unittype].push_back(m_BlockedFleet[unittype][0]); + } + else + { + m_BlockedFleet[unittype].push_back(number); + m_BlockedFleet[unittype].push_back(number); + } +} diff --git a/bs/fleet.h b/bs/fleet.h index 74e4e86..c4f2652 100644 --- a/bs/fleet.h +++ b/bs/fleet.h @@ -108,6 +108,8 @@ public: void killFleet(std::string unittype, int number, int tick = 0); + void blockFleet(std::string unittype, int number, int tick = 0); + void setResource(std::string type, int number, int tick = 0); int resource(std::string type, int tick = 0)const; diff --git a/bs/planet.cpp b/bs/planet.cpp index 41d92ac..8fd1726 100644 --- a/bs/planet.cpp +++ b/bs/planet.cpp @@ -103,16 +103,18 @@ void Planet::runBattle(std::vector friendly, std::vector hostile skipped = 0; Planet allFriends; - allFriends.addToThis(friends); + allFriends.addToThis(friends, tick); Fleet allHostiles; - allHostiles.addToThis(hostiles); + allHostiles.addToThis(hostiles, tick); map > stealfriendly; map > stealhostile; calcOneTick(&allFriends, &allHostiles, stealfriendly, stealhostile ); + //allFriends.printFleet(); + allFriends.distributeLossesGains(friends, tick); allHostiles.distributeLossesGains(hostiles, tick); } @@ -133,7 +135,7 @@ void Planet::calcOneTick(Planet* friendly, Fleet* hostile, std::mapsecond; - cerr << "Initiative: " << s_Units[unittype].initiative() << " with unit: " << unittype << endl; + //cerr << "Initiative: " << s_Units[unittype].initiative() << " with unit: " << unittype << endl; if (s_Units[unittype].type() == "EMP") { diff --git a/bs/share/stats.conf b/bs/share/stats.conf index a5aa54d..5c37f09 100644 --- a/bs/share/stats.conf +++ b/bs/share/stats.conf @@ -1,108 +1,108 @@ +Mesonic Cutter +5 Co Fi Co -- 49 25 40 1 3 50 -1 400 400 800 0 0 PDS +Tachyon Beamer +5 Fr Fr Co -- 50 20 35 1 10 75 -1 750 750 1500 0 0 PDS +Pulse Cannon +5 De De Fr All 51 15 30 1 20 150 -1 2250 2250 4000 0 0 PDS +Hadron Turret +5 Cr Cr De All 52 10 25 1 30 225 -1 5000 5000 8000 0 0 PDS +Ion Launcher +5 Bs Bs Cr All 53 5 20 1 60 350 -1 10000 10000 16000 0 0 PDS Harpy -1 Fi Fi Co Fr 11 38 37 3 1 5 65 1250 10 2 Normal +1 Fi Fi Co Fr 11 38 37 3 1 5 65 1250 0 0 10 2 Normal Phoenix -1 Co Fr Co Fi 18 25 22 2 5 10 55 2500 20 3 Normal +1 Co Fr Co Fi 18 25 22 2 5 10 55 2250 250 0 20 3 Normal Gryphon -1 Co Cr De -- 19 24 13 1 10 12 65 3000 25 3 Normal +1 Co Cr De -- 19 24 13 1 10 12 65 2250 750 0 25 3 Normal Centaur -1 Fr Fi Co -- 24 23 45 7 2 25 65 6000 65 3 Normal +1 Fr Fi Co -- 24 23 45 7 2 25 65 3500 2500 0 65 3 Normal Chimera -1 Fr Fr De All 25 22 23 5 2 35 70 7000 80 4 Normal +1 Fr Fr De All 25 22 23 5 2 35 70 5500 1500 0 80 4 Normal Drake -1 Fr De Fr Co 26 19 17 5 3 45 85 8250 95 4 Normal +1 Fr De Fr Co 26 19 17 5 3 45 85 6250 2000 0 95 4 Normal Pegasus -1 De Fi Co -- 10 23 45 12 3 50 75 12000 135 3 Normal +1 De Fi Co -- 10 23 45 12 3 50 75 4000 8000 0 135 3 Normal Unicorn -1 De Bs Cr De 30 17 10 3 25 85 80 16000 175 4 Normal +1 De Bs Cr De 30 17 10 3 25 85 80 12000 4000 0 175 4 Normal Hydra -1 Cr Fr Co -- 35 13 22 7 16 140 70 25000 225 4 Normal +1 Cr Fr Co -- 35 13 22 7 16 140 70 14000 9000 0 225 4 Normal Syren -1 Cr Cr De All 36 10 15 8 15 180 75 30000 350 5 Normal +1 Cr Cr De All 36 10 15 8 15 180 75 22000 8000 0 350 5 Normal Wyvern -1 Bs De Fr -- 28 12 15 12 27 160 90 54000 400 4 Normal +1 Bs De Fr -- 28 12 15 12 27 160 90 30000 24000 0 400 4 Normal Dragon -1 Bs Bs Cr -- 39 5 10 12 40 500 95 86000 700 5 Normal +1 Bs Bs Cr -- 39 5 10 12 40 500 95 70000 16000 0 700 5 Normal Spider -2 Fi Co Fi -- 7 30 0 1 0 5 65 1250 10 2 EMP +2 Fi Co Fi -- 0 30 0 1 0 5 65 0 1250 0 10 2 EMP Vindicator -2 Fi Fi Co -- 21 40 42 1 2 3 50 1250 10 2 Normal +2 Fi Fi Co -- 14 40 42 1 2 3 50 1250 0 0 10 2 Normal Scarab -2 Co Fr Co -- 8 23 0 2 0 20 55 2500 20 3 EMP +2 Co Fr Co -- 1 23 0 1 0 20 55 1750 1250 0 20 3 EMP Defender -2 Co Cr De Fr 27 25 15 1 7 20 75 2500 30 3 Normal +2 Co Cr De Fr 20 25 15 1 7 20 75 2000 500 0 30 3 Normal Roach -2 Co De Cr -- 9 20 0 3 0 25 65 3000 40 3 EMP +2 Co De Cr -- 2 20 0 1 0 25 65 2750 1250 0 40 3 EMP Black Widow -2 Fr Fr Co -- 10 20 0 6 0 30 70 7500 85 4 EMP +2 Fr Co Fr -- 3 20 0 5 0 30 70 4500 3000 0 85 4 EMP Widow Maker -2 De Bs Cr -- 40 15 10 3 20 100 80 16000 160 4 Normal +2 De Bs Cr -- 33 15 10 3 20 100 80 10000 6000 0 160 4 Normal Tarantula -2 Cr Cr De All 11 12 0 6 0 135 70 28000 320 4 EMP +2 Cr Cr De All 6 14 0 6 0 135 70 16000 12000 0 320 4 EMP Avenger -2 Cr Co Fr All 44 10 27 10 4 150 75 30000 340 5 Normal +2 Cr Co Fr All 37 10 27 10 4 150 75 22500 7500 0 340 5 Normal Mantis -2 Cr Bs -- -- 12 7 0 10 0 225 85 33000 400 5 EMP +2 Cr Bs -- -- 5 7 0 10 0 225 85 20000 13000 0 400 5 EMP Guardian -2 Bs Fi Co Fr 48 5 40 25 4 600 96 86000 700 5 Normal +2 Bs Fi Co Fr 41 5 40 25 4 600 96 60000 26000 0 700 5 Normal Scorpion -2 Bs Fi Co -- 13 5 0 100 0 400 99 76000 750 5 EMP +2 Bs Fi Co -- 4 5 0 90 0 400 99 50000 36000 0 750 5 EMP Vsharrack Fighter -3 Fi Fi Co -- 7 40 45 2 2 3 40 1250 10 2 Cloak +3 Fi Fi Co -- 7 40 45 2 2 3 40 1250 0 0 10 2 Cloak Daeraith Pulsar -3 Fi Fr De -- 8 35 25 3 2 2 45 1550 10 2 Cloak +3 Fi Fr De -- 8 35 25 3 2 2 45 1300 250 0 10 2 Cloak Lyvidian Sentinel -3 Fi Co Fr All 9 30 25 2 3 5 50 1950 10 3 Cloak +3 Fi Co Fr All 9 30 25 2 3 5 50 1600 350 0 10 3 Cloak Culdassa Arrowhead -3 Co Fi Co -- 15 15 40 9 1 10 30 2500 20 3 Cloak +3 Co Fi Co -- 15 15 40 9 1 10 30 1250 1250 0 20 3 Cloak Voracean Predator -3 Co Fr Co All 16 25 20 4 2 15 35 2750 25 3 Cloak +3 Co Fr Co All 16 25 20 4 2 15 35 1500 1250 0 25 3 Cloak Andvordian Bomber -3 Co Bs Cr De 17 25 20 1 8 10 40 3000 35 3 Cloak +3 Co Bs Cr De 17 25 20 1 8 10 40 2250 750 0 35 3 Cloak Tzen Bolt Thrower -3 Fr Fr Co -- 21 20 23 6 5 30 70 7000 65 4 Cloak +3 Fr Fr Co -- 21 20 23 6 5 30 70 4000 3000 0 65 4 Cloak Hysperian Lancer -3 Fr De Cr -- 22 18 20 4 7 35 60 7500 75 4 Cloak +3 Fr De Cr -- 22 18 20 4 7 35 60 3750 3750 0 75 4 Cloak Cryvellian Broadsword -3 Fr Cr Bs -- 23 15 25 3 10 40 60 8000 95 4 Cloak +3 Fr Cr Bs -- 23 15 25 3 10 40 60 4250 3750 0 95 4 Cloak Kthal Fireblade -3 De Bs De -- 29 10 5 4 50 65 85 24000 165 4 Cloak +3 De Bs De -- 29 10 5 4 50 65 85 18000 6000 0 165 4 Cloak Xentrallis Peacekeeper -3 Cr Cr De All 34 15 15 8 10 105 70 30000 360 5 Cloak +3 Cr Cr De All 34 15 15 8 10 105 70 18000 12000 0 360 5 Cloak Valaerian Flagship -3 Bs Co Fi -- 38 5 20 80 5 325 90 78000 750 5 Cloak +3 Bs Co Fi -- 38 5 20 80 5 325 90 44000 34000 0 750 5 Cloak Corsair -4 Fi Fr Co -- 12 45 25 2 1 1 15 750 5 2 Normal +4 Fi Fr Co -- 12 45 25 2 1 1 15 400 350 0 5 2 Normal Cutlass -4 Fi Fi Co Fr 13 30 45 3 1 5 25 1250 10 2 Normal +4 Fi Fi Co Fr 13 30 45 3 1 5 25 1250 0 0 10 2 Normal Smuggler -4 Co -- -- -- 47 25 0 0 0 12 20 2600 25 3 Special +4 Co -- -- -- 47 25 0 0 0 12 20 2000 600 0 25 3 Special Thief -4 Fr Co Fi -- 42 20 25 2 4 22 60 4000 75 4 Steal +4 Fr Co Fi -- 42 20 25 2 4 22 60 1750 2250 0 75 4 Steal Cutter -4 Fr De Co Fi 27 20 20 4 5 35 60 7000 65 4 Normal +4 Fr De Co Fi 27 20 20 4 5 35 60 5500 1500 0 65 4 Normal Buccaneer -4 De Bs Cr De 31 15 10 5 15 60 65 16000 140 4 Normal +4 De Bs Cr De 31 15 10 5 15 60 65 10000 6000 0 140 4 Normal Clipper -4 De De Fr All 32 18 20 15 5 65 65 14000 150 4 Normal +4 De De Fr All 32 18 20 15 5 65 65 4000 10000 0 150 4 Normal Marauder -4 De Fr -- -- 43 10 25 10 5 90 60 16000 195 4 Steal +4 De Fr -- -- 43 10 25 10 5 90 60 7500 8500 0 195 4 Steal Rogue -4 Cr De Fr -- 44 10 20 8 10 95 40 18000 410 5 Steal +4 Cr De Fr -- 44 10 20 8 10 95 40 8250 9750 0 410 5 Steal Pillager -4 Cr Cr De -- 45 10 20 4 20 125 40 24000 420 5 Steal +4 Cr Cr De -- 45 10 20 4 20 125 40 11000 13000 0 420 5 Steal Pirate -4 Bs Bs Cr -- 46 6 10 5 30 275 80 54000 700 5 Steal +4 Bs Bs Cr -- 46 6 10 5 30 275 80 28500 25500 0 700 5 Steal Man o' War -4 Bs Fr Co Fi 40 5 30 40 6 400 90 76000 800 5 Normal +4 Bs Fr Co Fi 40 5 30 40 6 400 90 36000 40000 0 800 5 Normal Astro Pod -0 Fr -- -- -- 48 20 0 0 0 10 55 3700 125 4 Special -Mesonic Cutter -5 Co Fi Co -- 49 25 40 1 3 50 N/A 1600 0 0 PDS -Tachyon Beamer -5 Fr Fr Co -- 50 20 35 1 10 75 N/A 3000 0 0 PDS -Pulse Cannon -5 De De Fr All 51 15 30 1 20 150 N/A 8500 0 0 PDS -Hadron Turret -5 Cr Cr De All 52 10 25 1 30 225 N/A 18000 0 0 PDS -Ion Launcher -5 Bs Bs Cr All 53 5 20 1 60 350 N/A 36000 0 0 PDS +0 Fr -- -- -- 48 20 0 0 0 10 55 1850 1850 0 125 4 Pod diff --git a/hbs.kdevses b/hbs.kdevses index 7a0b240..c5d9ecc 100644 --- a/hbs.kdevses +++ b/hbs.kdevses @@ -2,10 +2,6 @@ - - - - - + (Default)