From: Michael Andreen Date: Tue, 4 Jun 2002 21:08:16 +0000 (+0000) Subject: changed the capping functionallity.. X-Git-Url: https://ruin.nu/git/?p=hbs.git;a=commitdiff_plain;h=5b3a1459c35efe60c4255a5c50a1d74fdbe8e8eb changed the capping functionallity.. --- diff --git a/bs/fleet.cpp b/bs/fleet.cpp index 4072788..bab852f 100644 --- a/bs/fleet.cpp +++ b/bs/fleet.cpp @@ -119,28 +119,27 @@ void Fleet::setUnits(UnitList& units) s_Units = units; - /* + for (UnitList::iterator i = s_Units.begin(); i != s_Units.end(); i++) { - cerr << s_Units[(*i).first].Name() << "\t\t" - << s_Units[(*i).first].race() <<"\t" - << s_Units[(*i).first].unitClass() << "\t" - << s_Units[(*i).first].target(0) << "\t" - << s_Units[(*i).first].target(1) << "\t" - << s_Units[(*i).first].target(2) << "\t" - << s_Units[(*i).first].initiative() << "\t" - << s_Units[(*i).first].agility() << "\t" - << s_Units[(*i).first].weaponSpeed() << "\t" - << s_Units[(*i).first].guns() << "\t" - << s_Units[(*i).first].power() << "\t" - << s_Units[(*i).first].armor() << "\t" - << s_Units[(*i).first].EMP() << "\t" - << s_Units[(*i).first].totRes() << "\t" - << s_Units[(*i).first].fuel() << "\t" - << s_Units[(*i).first].ETA() << "\t" - << s_Units[(*i).first].type() << endl; + cerr << s_Units[(*i).first].Name() << "\t\t" +/* << s_Units[(*i).first].race() <<"\t" + << s_Units[(*i).first].unitClass() << "\t" + << s_Units[(*i).first].target(0) << "\t" + << s_Units[(*i).first].target(1) << "\t" + << s_Units[(*i).first].target(2) << "\t" + << s_Units[(*i).first].initiative() << "\t" + << s_Units[(*i).first].agility() << "\t" + << s_Units[(*i).first].weaponSpeed() << "\t" + << s_Units[(*i).first].guns() << "\t" + << s_Units[(*i).first].power() << "\t" + << s_Units[(*i).first].armor() << "\t" + << s_Units[(*i).first].EMP() << "\t" + << s_Units[(*i).first].totRes() << "\t" + << s_Units[(*i).first].fuel() << "\t" + << s_Units[(*i).first].ETA() << "\t"*/ + << s_Units[(*i).first].type() << endl; } - */ } ////////////////////////////////////////////////////////////////////////// @@ -817,3 +816,53 @@ void Fleet::resetTicks() } resetResources(); } + +////////////////////////////////////////////////////////////////////////// +// +int Fleet::freePodGuns(int tick) +{ + int guns = 0; + for (FleetList::const_iterator i = m_Fleet.begin(); i != m_Fleet.end(); ++i) + { + if (s_Units[i->first].type() == "Pod") + { + guns += freeFleet(i->first, tick) * s_Units[i->first].guns(); + } + } + guns -= usedPodGuns(tick); + return guns; +} + +////////////////////////////////////////////////////////////////////////// +// +int Fleet::usedPodGuns(int tick) const +{ + int ticks = m_UsedPodGuns.size(); + + if (ticks == 0) + return 0; + + if (tick < 0) + return m_UsedPodGuns[0]; + + --ticks; + + if (ticks < tick) + return m_UsedPodGuns[ticks]; + + return m_UsedPodGuns[tick]; + +} + +////////////////////////////////////////////////////////////////////////// +// +void Fleet::usePodGuns(int tick, int guns) +{ + int ticks = m_UsedPodGuns.size(); + + for (int i = ticks; i <= tick; ++i) + { + m_UsedPodGuns.push_back(0); + } + m_UsedPodGuns[tick] += guns; +} diff --git a/bs/fleet.h b/bs/fleet.h index f632093..673eb42 100644 --- a/bs/fleet.h +++ b/bs/fleet.h @@ -275,6 +275,13 @@ public: void printFleet(); void resetTicks(); + + int freePodGuns(int tick = 0); + + int usedPodGuns(int tick = 0) const; + + void usePodGuns(int tick = 0, int guns = 1); + //static functions // /** This function is used to set the different races used. @@ -301,14 +308,15 @@ public: protected: - std::string m_sName; - std::string m_sRace; - int m_iETA; - FleetList m_Fleet; - FleetList m_BlockedFleet; - ResourceList m_Resources; - ArmorList m_Armor; - int m_iStays; + std::string m_sName; + std::string m_sRace; + int m_iETA; + FleetList m_Fleet; + FleetList m_BlockedFleet; + ResourceList m_Resources; + ArmorList m_Armor; + int m_iStays; + std::vector m_UsedPodGuns; diff --git a/bs/planet.cpp b/bs/planet.cpp index 935c65d..fdeb789 100644 --- a/bs/planet.cpp +++ b/bs/planet.cpp @@ -228,10 +228,11 @@ void Planet::calcOneTick(Planet* friendly, Fleet* hostile, std::map pods; + //FIXME: remove this line later.. map pods; - //FIXME: Need to change this and allow multiple shiptypes with the same initiative. + //FIXME: Need to change this and allow multiple shiptypes with the same initiative. + //FIXME: Looks like I don't have to.. map unitsinit; // order units after their ininitiative for (UnitList::iterator i = s_Units.begin(); i != s_Units.end(); ++i) unitsinit[i->second.initiative()] = i->first; @@ -275,29 +276,39 @@ void Planet::calcOneTick(Planet* friendly, Fleet* hostile, std::mapfirst, tick - 1); - int freepods = hostiletemp->freeFleet(unittype, 1); + //int freepods = hostiletemp->freeFleet(unittype, 1); cerr << "Possible to steal " << caproids << " " << roid->first << " roids\n"; - cerr << freepods << " free pods available\n"; + cerr << hostiletemp->freePodGuns(1) << " free pod guns available\n"; - if (freepods <= 0) + if (hostiletemp->freePodGuns(1) <= 0) break; - if (freepods < caproids) - caproids = freepods; + if (hostiletemp->freePodGuns(1) < caproids) + caproids = hostiletemp->freePodGuns(1); cerr << caproids << " roids stolen\n"; takeRoids(roid->first, caproids, tick); + /*FIXME: REMOVE THIS BLOCK LATER //FIXME: Going to move this to the distribute roids section instead.. Not really move, I'll keep this, but "regenerate" the pods in the distribute ships function. hostiletemp->killFleet(unittype, caproids, 1); pods[unittype] += caproids; //int totroids = caproids + hostiletemp->resource(roid->first, 0); + */ hostiletemp->addResource(roid->first, caproids, 1); - + hostiletemp->usePodGuns(1, caproids); cerr << caproids << " stolen " << roid->first << " roids\n"; } } + + //FIXME: This is ugly and I want to change this, but as long as pods shoot last it works.. + *friendly = *friendlytemp; + delete friendlytemp; + *hostile = *hostiletemp; + delete hostiletemp; + + return; } //set the the objects so they point at the modified objects @@ -306,7 +317,7 @@ void Planet::calcOneTick(Planet* friendly, Fleet* hostile, std::mapaddFleet(pods, 1); + //hostile->addFleet(pods, 1); } diff --git a/share/stats.conf b/share/stats.conf index 676079c..554a6fd 100644 --- a/share/stats.conf +++ b/share/stats.conf @@ -1,7 +1,7 @@ Mesonic Cutter 5 Co Fi Co -- 45 25 40 1 3 50 100 400 400 800 0 0 PDS Tachyon Beamer -5 Fr Fr Co -- 46 20 35 1 10 75 100 750 750 1500 0 0PDS +5 Fr Fr Co -- 46 20 35 1 10 75 100 750 750 1500 0 0 PDS Pulse Cannon 5 De De Fr All 47 15 30 1 20 150 100 2250 2250 4000 0 0 PDS Hadron Turret