~parasiteofchar/s25rttr/AIpoc2

« back to all changes in this revision

Viewing changes to src/nobMilitary.cpp

  • Committer: poc
  • Date: 2015-02-14 18:27:20 UTC
  • Revision ID: parasiteofchar@googlemail.com-20150214182720-9p884ms594wgs1j1
new addon: Individual Custom Military
allows players to set the requested_soldier count for each individual military building

Show diffs side-by-side

added added

removed removed

Lines of Context:
233
233
    // Wenn Goldzufuhr gestoppt ist, Schild außen am Gebäude zeichnen zeichnen
234
234
    if(disable_coins_virtual)
235
235
        LOADER.GetMapImageN(46)->Draw(x + BUILDING_SIGN_CONSTS[nation][type].x, y + BUILDING_SIGN_CONSTS[nation][type].y, 0, 0, 0, 0, 0, 0);
 
236
        //todo: custom settings-> draw notifier icon (addon individual custom military)
 
237
    //if(requested_soldiers)
 
238
        //      LOADER.GetImageN("map_new", 1)->Draw(x + BUILDING_SIGN_CONSTS[nation][type].x, y + BUILDING_SIGN_CONSTS[nation][type].y, 0, 0, 0, 0, 0, 0);
236
239
 
237
240
 
238
241
 
534
537
 
535
538
int nobMilitary::CalcTroopsCount()
536
539
{
537
 
    return (TROOPS_COUNT[nation][size] - 1) * gwg->GetPlayer(player)->military_settings[4 + frontier_distance] / MILITARY_SETTINGS_SCALE[4 + frontier_distance] + 1;
 
540
        if(requested_soldiers)
 
541
                requested_soldiers_by_milSettings=requested_soldiers;
 
542
        else
 
543
                requested_soldiers_by_milSettings = (TROOPS_COUNT[nation][size] - 1) * gwg->GetPlayer(player)->military_settings[4 + frontier_distance] / MILITARY_SETTINGS_SCALE[4 + frontier_distance] + 1;
 
544
    return requested_soldiers_by_milSettings;
 
545
}
 
546
 
 
547
void nobMilitary::RequestedSoldiersInc()
 
548
{
 
549
        if(requested_soldiers) //already custom value?
 
550
        {
 
551
                if(requested_soldiers < (unsigned)TROOPS_COUNT[nation][size])
 
552
                        requested_soldiers++;
 
553
        }
 
554
        else//now use custom value
 
555
        {
 
556
                if (((TROOPS_COUNT[nation][size] - 1) * gwg->GetPlayer(player)->military_settings[4 + frontier_distance] / MILITARY_SETTINGS_SCALE[4 + frontier_distance] + 1) < (unsigned)TROOPS_COUNT[nation][size])
 
557
                        requested_soldiers = (TROOPS_COUNT[nation][size] - 1) * gwg->GetPlayer(player)->military_settings[4 + frontier_distance] / MILITARY_SETTINGS_SCALE[4 + frontier_distance] + 1 + 1;
 
558
                else
 
559
                        requested_soldiers = TROOPS_COUNT[nation][size];
 
560
        }
 
561
        RegulateTroops();
 
562
}
 
563
 
 
564
void nobMilitary::RequestedSoldiersDec()
 
565
{
 
566
        if(requested_soldiers) //already custom value?
 
567
        {
 
568
                if(requested_soldiers > 1)
 
569
                        requested_soldiers--;
 
570
        }
 
571
        else//now use custom value
 
572
        {
 
573
                if ((TROOPS_COUNT[nation][size] - 1) * gwg->GetPlayer(player)->military_settings[4 + frontier_distance] / MILITARY_SETTINGS_SCALE[4 + frontier_distance] + 1 > 1)
 
574
                        requested_soldiers = (TROOPS_COUNT[nation][size] - 1) * gwg->GetPlayer(player)->military_settings[4 + frontier_distance] / MILITARY_SETTINGS_SCALE[4 + frontier_distance] + 1 - 1;
 
575
                else
 
576
                        requested_soldiers = 1;
 
577
        }
 
578
        RegulateTroops();
 
579
}
 
580
 
 
581
void nobMilitary::RequestedSoldiersRes()
 
582
{
 
583
        if(requested_soldiers) //currently has custom value?
 
584
        {
 
585
                requested_soldiers=0;
 
586
                RegulateTroops();
 
587
        }       
538
588
}
539
589
 
540
590
void nobMilitary::SendSoldiersHome()
959
1009
    // Bestellungen die hierher unterwegs sind canceln
960
1010
    CancelOrders();
961
1011
 
 
1012
        // remove possible custom settings (addon individual custom military)
 
1013
        requested_soldiers=0;
 
1014
 
962
1015
    // Aggressiv-Verteidigenden Soldaten Bescheid sagen, dass sie nach Hause gehen können
963
1016
    for(list<nofAggressiveDefender*>::iterator it = aggressive_defenders.begin(); it.valid(); ++it)
964
1017
        (*it)->AttackedGoalDestroyed();