Announcement

Collapse
No announcement yet.

E's Source Code attempts

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • dipwizard.cpp

    Martin,

    Ive opted to make diplomacy the priority. I could live with the LDL changes I made but I'd really like to change the set upp to be more like Civ3/Civ4 so I think to get rid of the offer/request tab problem do I just have to create a new stage and edit where the offer and request go to, specifically in these files?

    Code:
    DipWizard::DipWizard(AUI_ERRCODE *err)
    [i]... some code...[/i]
    	m_propList[DIP_WIZ_PROP_TAB_REQUEST] = (ctp2_ListBox *)aui_Ldl::GetObject(s_dipWizardBlock, "Stage1.Tabs.Request.TabPanel.List");
    	m_propList[DIP_WIZ_PROP_TAB_OFFER] = (ctp2_ListBox *)aui_Ldl::GetObject(s_dipWizardBlock, "Stage1.Tabs.Offer.TabPanel.List");
    	m_propList[DIP_WIZ_PROP_TAB_TREATY] = (ctp2_ListBox *)aui_Ldl::GetObject(s_dipWizardBlock, "Stage1.Tabs.Treaty.TabPanel.List");
    
    	m_exchList[DIP_WIZ_PROP_TAB_REQUEST] = (ctp2_ListBox *)aui_Ldl::GetObject(s_dipWizardBlock, "Stage2.Tabs.Request.TabPanel.List");
    	m_exchList[DIP_WIZ_PROP_TAB_OFFER] = (ctp2_ListBox *)aui_Ldl::GetObject(s_dipWizardBlock, "Stage2.Tabs.Offer.TabPanel.List");
    	m_exchList[DIP_WIZ_PROP_TAB_TREATY] = (ctp2_ListBox *)aui_Ldl::GetObject(s_dipWizardBlock, "Stage2.Tabs.Treaty.TabPanel.List");
    
    	aui_Ldl::SetActionFuncAndCookie(s_dipWizardBlock, "Stage1.Tabs.Request", ProposalTabCallback, (void *)DIP_WIZ_PROP_TAB_REQUEST);
    	aui_Ldl::SetActionFuncAndCookie(s_dipWizardBlock, "Stage1.Tabs.Offer", ProposalTabCallback, (void *)DIP_WIZ_PROP_TAB_OFFER);
    	aui_Ldl::SetActionFuncAndCookie(s_dipWizardBlock, "Stage1.Tabs.Treaty", ProposalTabCallback, (void *)DIP_WIZ_PROP_TAB_TREATY);
    	
    	aui_Ldl::SetActionFuncAndCookie(s_dipWizardBlock, "Stage2.Tabs.Request", ExchangeTabCallback, (void *)DIP_WIZ_PROP_TAB_REQUEST);
    	aui_Ldl::SetActionFuncAndCookie(s_dipWizardBlock, "Stage2.Tabs.Offer", ExchangeTabCallback, (void *)DIP_WIZ_PROP_TAB_OFFER);
    	aui_Ldl::SetActionFuncAndCookie(s_dipWizardBlock, "Stage2.Tabs.Treaty", ExchangeTabCallback, (void *)DIP_WIZ_PROP_TAB_TREATY);
    the other question is that I like the "table" of proposals where you can you build a list of wants and ask for wants instead of the ctp2 only request one thing and offer one thing. Is this where I need to look?

    Code:
    void DipWizard::FillProposalLists()
    {
    	
    	sint32 pr;
    	ctp2_ListBox *propList = NULL, *exchList = NULL;
    
    	sint32 i;
    	for(i = 0; i < DIP_WIZ_PROP_TAB_MAX; i++) {
    		m_propList[i]->Clear();
    		m_exchList[i]->Clear();
    		m_propList[i]->SetActionFuncAndCookie(PropListCallback, (void *)i);
    		m_exchList[i]->SetActionFuncAndCookie(ExchListCallback, (void *)i);
    	}
    
    	const Diplomat & diplomat = 
    		Diplomat::GetDiplomat(g_selected_item->GetVisiblePlayer());
    
    	for(pr = 0; pr < g_theDiplomacyProposalDB->NumRecords(); pr++) {
    		const DiplomacyProposalRecord *rec = g_theDiplomacyProposalDB->Get(pr);
    		if(!rec) continue;
    
    		
    		if (diplomat.InvalidNewProposal(m_recipient, rec))
    			continue;
    
    		
    		
    		if(rec->GetArg1HisCity() && m_recipient >= 0 && m_recipient < k_MAX_PLAYERS && g_player[m_recipient]) {
    			sint32 c;
    			bool seenOne = false;
    			for(c = 0; c < g_player[m_recipient]->m_all_cities->Num(); c++) {
    				if(g_player[m_recipient]->m_all_cities->Access(c)->GetEverVisible() & (1 << g_selected_item->GetVisiblePlayer())) {
    					seenOne = true;
    					break;
    				}
    			}
    			if(!seenOne)
    				continue;
    		}
    					
    		if(rec->GetCategoryRequest()) {
    			propList = m_propList[DIP_WIZ_PROP_TAB_REQUEST];
    			exchList = m_exchList[DIP_WIZ_PROP_TAB_REQUEST];
    		}
    
    		if(rec->GetCategoryGift()) {
    			propList = m_propList[DIP_WIZ_PROP_TAB_OFFER];
    			exchList = m_exchList[DIP_WIZ_PROP_TAB_OFFER];
    		}
    
    		if(rec->GetCategoryTreaty()) {
    			propList = m_propList[DIP_WIZ_PROP_TAB_TREATY];
    			exchList = m_exchList[DIP_WIZ_PROP_TAB_TREATY];
    		}
    
    		AddProposalItem(propList, rec);
    		AddProposalItem(exchList, rec);
    	}
    
    	
    	
    	
    	if(m_threatList) {
    		m_threatList->Clear();
    		if(GetStage() == DIP_WIZ_STAGE_MAKE_THREAT) {
    			m_sendButton->Enable(FALSE);
    		}
    		
    
    		
    		sint32 threatenee = m_recipient;
    
    		if(threatenee > 0 && threatenee < k_MAX_PLAYERS) {
    			for(i = 1; i < g_theDiplomacyThreatDB->NumRecords(); i++) {
    				const DiplomacyThreatRecord *rec = g_theDiplomacyThreatDB->Get(i);
    				
    				switch(rec->GetArg1()) {
    				case k_DiplomacyThreat_Arg1_HisCity_Bit:
    				case k_DiplomacyThreat_Arg1_SpecialAttack_Bit:
    					{
    						if(m_recipient < 0 || m_recipient >= k_MAX_PLAYERS || !g_player[threatenee])
    							continue;
    						
    						bool foundCity = false;
    						
    						sint32 c;
    						for(c = 0; c < g_player[threatenee]->m_all_cities->Num(); c++) {
    							if(g_player[threatenee]->m_all_cities->Access(c).GetEverVisible() & (1 << g_selected_item->GetVisiblePlayer())) {
    								foundCity = true;
    								break;
    							}
    						}
    						if(!foundCity)
    							continue;
    						break;
    					}
    				case k_DiplomacyThreat_Arg1_ThirdParty_Bit:
    					{
    						sint32 p;
    						bool foundThirdParty = false;
    						
    						for(p = 1; p < k_MAX_PLAYERS; p++) {
    							if(!g_player[p]) continue;
    							
    							if(p == g_selected_item->GetVisiblePlayer())
    								continue;
    							
    							if(p == threatenee)
    								continue;
    							
    							if(!g_player[g_selected_item->GetVisiblePlayer()]->HasContactWith(p))
    								continue;
    							
    							foundThirdParty = true;
    							break;
    						}
    						
    						if(!foundThirdParty)
    							continue;
    						break;
    					}
    
    				case k_DiplomacyThreat_Arg1_AgreementId_Bit:
    					{
    						if(m_recipient < 0 || m_recipient >= k_MAX_PLAYERS || !g_player[threatenee])
    							continue;
    
    						
    						const Diplomat & diplomat = Diplomat::GetDiplomat(g_selected_item->GetVisiblePlayer());
    
    						
    						ai::Agreement pact;
    						
    						
    						bool has_pacts = diplomat.GetAgreementToBreak(threatenee, pact);
    						if (!has_pacts)
    							continue;
    						break;
    					}
    
    				default:
    					break;
    				}
    				
    				ctp2_ListItem *item = (ctp2_ListItem *)aui_Ldl::BuildHierarchyFromRoot("DipWizThreatItem");
    				Assert(item);
    				if(!item)
    					break;
    				
    				item->SetUserData((void *)i);
    				
    				ctp2_Static *text = (ctp2_Static *)item->GetChildByIndex(0);
    				Assert(text);
    				if(!text)
    					break;
    				
    				text->SetText(g_theStringDB->GetNameStr(rec->GetTitle()));
    				m_threatList->AddItem(item);
    			}
    		}
    	}
    }
    Formerly known as "E" on Apolyton

    See me at Civfanatics.com

    Comment


    • Re: dipwizard.cpp

      Originally posted by E
      Ive opted to make diplomacy the priority. I could live with the LDL changes I made but I'd really like to change the set upp to be more like Civ3/Civ4 so I think to get rid of the offer/request tab problem do I just have to create a new stage and edit where the offer and request go to, specifically in these files?
      Originally posted by E
      the other question is that I like the "table" of proposals where you can you build a list of wants and ask for wants instead of the ctp2 only request one thing and offer one thing. Is this where I need to look?
      I think both questions are linked. On the one hand if you just want to rework the interface than you just need to edit DipWizard.cpp, if I remember correctly.

      The think is that you want to have it more in the Civ3/4 style and that is different from the CTP2 style in CTP2 offers and requests are complete different things even if you call them give-map-request and give-map-offer, that are two different "treaties", with two different entries in the database.

      In fact this is counterintuitive, and here we come to the root of the problem the whole system is bad designed. So the real solution is to move everything of diplomacy to dev/0 and start again.

      And that includes the AI response logic.

      The downside with this radical solution is that noone has time to do it.

      Of course you can do some superficial "improvement" at the UI-level, by grouping the offers on the one side of the diplo-image and the request on the other side and put the treaties into both sides.

      -Martin
      Civ2 military advisor: "No complaints, Sir!"

      Comment


      • Martin,

        I'm having two problems with my nonlethalbombard code

        First, graphics as the attached image shows it makes the line for less than zero grow if bombed forever. I know you worked with graphics before but what should I do just to keep it at zero


        I think its here, but how do I tell the code to ignore negative numbers. If HP < 0) { (HP = 0)???????


        Code:
        void UnitActor::DrawHealthBar(void)
        
        	if(unit.IsValid()) {
        		if(stackSize > 1 && myCell->GetNumUnits()) {
        			ratio = myCell->UnitArmy()->GetAverageHealthPercentage();
        		} else {
        			
        			
        			if (m_healthPercent < 0) 
        				ratio = unit.GetHP() / unit.GetDBRec()->GetMaxHP();
        			else
        				ratio = m_healthPercent;
        		}
        	} else {
        		if (m_healthPercent >= 0.0)
        			ratio = m_healthPercent;
        		else
        			ratio = 0.0;
        	}



        Second, Once they reach this negative HP they cant be attacked and cant attack. I think I can find it in army data here:
        Code:
        ArmyData::CheckActiveDefenders
        [i]...some code...[/i]
        		for(j = 0; j < m_nElements; j++) {
        			if(!(m_array[j].GetHP() < 1.0) && 
        			   (m_array[j].CanCounterBombard(*dcell->UnitArmy()) ||
        				m_array[j].CanActivelyDefend(*dcell->UnitArmy()))) {
        				m_array[j].Bombard(*dcell->UnitArmy(), TRUE);
        				for(sint32 k = 0; k < dcell->GetNumUnits(); k++) {
        					if(dcell->AccessUnit(k).GetHP() < 1.0 &&
                               !deadDefenders.IsPresent(dcell->AccessUnit(k)))
                                deadDefenders.Insert(dcell->AccessUnit(k));
                        }
                    }
                }
            }
        
            if(defenderOwner < 0)
                return FALSE;
        
            sint32 numDead = 0;
            for(i = m_nElements - 1; i >= 0; i--) {
                if(m_array[i].GetHP() < 1.0) {
                    Assert(0 <= defenderOwner);
                    Assert(defenderOwner < k_MAX_PLAYERS);
                    m_array[i].Kill(CAUSE_REMOVE_ARMY_ACTIVE_DEFENSE, defenderOwner);
                }
            }
        I guess I can just get rid of the HP line?
        Attached Files
        Formerly known as "E" on Apolyton

        See me at Civfanatics.com

        Comment


        • Ok I fixed the first one

          Code:
          	if(unit.IsValid()) {
          		if(stackSize > 1 && myCell->GetNumUnits()) {
          			if (myCell->UnitArmy()->GetAverageHealthPercentage() > 0) { // added by E (EMOD)
          				ratio = myCell->UnitArmy()->GetAverageHealthPercentage();
          			} else {
          				ratio = 0.0;
          				}
          		} else {
          			
          			
          			if (m_healthPercent < 0) {     //switch from < makes it zero
          				if (unit.GetHP() / unit.GetDBRec()->GetMaxHP() > 0) { // added by E (EMOD)
          					ratio =	unit.GetHP() / unit.GetDBRec()->GetMaxHP();
          				} else {
          					ratio = 0.0;
          				}
          			
          			} else {
          				ratio = 0.0;   //m_healthPercent;
          			}
          		}
          	} else {
          		if (m_healthPercent >= 0.0)
          			ratio = m_healthPercent;
          		else
          			ratio = 0.0;
          	}
          appeared to be a slight bug in the code I fixed (I think) of course it was only apparent once I added nonlethal


          but I'm really scratching my head on the second one, I cant see any condition in fight or attack that check HP...
          Last edited by Ekmek; February 12, 2006, 01:15.
          Formerly known as "E" on Apolyton

          See me at Civfanatics.com

          Comment


          • I would not call this a bug in the original code. It is more likely that your way of implementing the non-lethal bombardment does not conform to the expectations of the original programmers .

            I would suggest putting the non-lethal check in the Bombard function, and use it there to prevent the HP of the target going below 1 when you have a non-lethal bombarder. In this way, you can restore the original check to determine whether a unit has to be removed, and you will never end up with strange units that are alive with negative HP.

            Comment


            • Thanks Fromafar,

              I see that:
              Code:
              void CombatUnit::DeductHP(double amt)
              {
              	Assert(m_unit.IsValid());
              	Assert(amt > 0);
              	m_hp -= amt; 
              
              	m_unit->SetHP(m_hp);
              
              	if(m_hp < 0.99999) {
              		m_hp = 0;
              		g_theCurrentBattle->AddDeadUnit(m_unit);
              	}
              }
              
              #endif
              is where I get the dead unit problem but I'm thinking of adding this to my bombard code, I'll try it later unless you recommend something else:

              Code:
              from armyData::Bombard
              
                  for (i = m_nElements - 1; 0 <= i; i--) { 
                      if (m_array[i].GetHP() < 0.999) {
              			if (!defender[i].GetDBRec()->GetNonLethalBombard()) {  //EMOD Non-LethalBombard like Civ3 OPTIONAL 20-JAN-2006
              			    m_array[i].KillUnit(CAUSE_REMOVE_ARMY_COUNTERBOMBARD, defender.GetOwner());  
              			}
              			[b]m_array[i].GetHP() = 1.0 [/b]
              		}
                  }
              unless I should use the setHP? (my second guess)
              Formerly known as "E" on Apolyton

              See me at Civfanatics.com

              Comment


              • Originally posted by E
                Code:
                from armyData::Bombard
                
                    for (i = m_nElements - 1; 0 <= i; i--) { 
                        if (m_array[i].GetHP() < 0.999) {
                			if (!defender[i].GetDBRec()->GetNonLethalBombard()) {  //EMOD Non-LethalBombard like Civ3 OPTIONAL 20-JAN-2006
                			    m_array[i].KillUnit(CAUSE_REMOVE_ARMY_COUNTERBOMBARD, defender.GetOwner());  
                			}
                			[b]m_array[i].GetHP() = 1.0 [/b]
                		}
                    }
                unless I should use the setHP? (my second guess)
                You should use setHP. If the above code compiles (which is just about possible), then something is deeply wrong.

                Comment


                • Thanks J,
                  I was just about to try it out (in a few hours).
                  Formerly known as "E" on Apolyton

                  See me at Civfanatics.com

                  Comment


                  • E - Downloaded and installed Rev542, started up the game and got:

                    Unable to find file UC088.tga
                    Continue?
                    Yes No

                    Not sure what that would have done later, so I said No. Is this a file from a different Mod you created? Mine only go up to UC087.tga.

                    above file found in: /ctp2_data/default/graphics/cursors
                    What do I think of Western civilization? I think it would be a very good idea.
                    Mohandas Gandhi

                    Comment


                    • I implemented the OnePerCiv code, it took a little stumbling but it works and I'll upload it soon. Essentially we can now have Small Wonders in CtP2. No wonder flags (yet) but just supercharge the standard building flags.


                      Code:
                      	if(rec->GetOnePerCiv()) {
                      			for(o = 0; o < g_player[m_owner]->m_all_cities->Num(); o++) {
                      				if(!(g_player[m_owner]->m_all_cities->Access(o).AccessData()->GetCityData()->GetEffectiveBuildings())) 
                      					return FALSE;
                      				
                      			}
                      	}
                      @J Bytheay. Still wrestling with SetHP

                      @FUGI. It looks like a standard picture of a gasoline station pump its located in
                      ctp2_data\default\graphics\cursors

                      not sure what uses it though, you could just copy and rename a file. I'm going to post it here (with 89) for you though
                      Attached Files
                      Last edited by Ekmek; February 15, 2006, 13:03.
                      Formerly known as "E" on Apolyton

                      See me at Civfanatics.com

                      Comment


                      • There is an ambiguity in my previous post, where I should have written out the function name fully. I meant to suggest putting the non-lethal check in UnitData::Bombard. The SetHP function is used there.

                        Originally posted by E
                        Code:
                            for (i = m_nElements - 1; 0 <= i; i--) { 
                                if (m_array[i].GetHP() < 0.999) {
                        			if (!defender[i].GetDBRec()->GetNonLethalBombard()) {
                        You really should get rid of this old code. It causes a program crash when the number of attackers is larger than the number of defenders.

                        Comment


                        • Thanks Fromafar, i'll get to it.
                          Formerly known as "E" on Apolyton

                          See me at Civfanatics.com

                          Comment


                          • Code:
                            	for (i=0; iNext(100) < p) { 
                            			hp -= f * dmr; 
                            			if(rec->GetNonLethalBombard()){	//EMOD for NonLethalBombard
                            				if (hp < 0.999) {			//EMOD 
                            					defender.SetHP(1.0);	//EMOD
                            				}							//EMOD
                            			} else {						//EMOD
                            					defender.SetHP(hp);		//from original code 
                            			}								//EMOD
                            		}				
                            	} // end EMOD
                            
                            	//defender.SetHP(hp); //original code
                            Now it works great!
                            Formerly known as "E" on Apolyton

                            See me at Civfanatics.com

                            Comment


                            • Martin or Fromafar,

                              I removed the nonlethal check but from what fugi posted in the playtest thread t looks like bombard is still causng a crash. Here is the rev543 code whats wrong with it?

                              thanks for the help.

                              E


                              Code:
                              ORDER_RESULT ArmyData::Bombard(const MapPoint &orderPoint)
                              {
                              	MapPoint        point   = orderPoint;
                              	CellUnitList    defender;
                              	g_theWorld->GetArmy(point, defender);
                              	sint32 i;
                              	
                              	if(point == m_pos) {
                              		return ORDER_RESULT_ILLEGAL;
                              	} else {
                              		//PFT 30 mar 05, bombard from distance
                              		sint32 dist = m_pos.NormalizedDistance(point);
                              		sint32 min_rge, max_rge;
                              		if(GetBombardRange(min_rge,max_rge)){
                              
                              DPRINTF(k_DBG_GAMESTATE, ("Getting BombardRange max_rge %d, dist %d\n", max_rge, dist));
                              
                              			if(dist > max_rge) {//the target is out of this army's bombarding range 
                              				return ORDER_RESULT_ILLEGAL;
                              			}
                              		}
                                      else//army can't bombard
                                          return ORDER_RESULT_ILLEGAL;
                              	}
                              
                                  if (defender.Num() < 1) {//no defenders		
                              		if(BombardCity(point, TRUE)) {//so if there's a city, bombard it
                              			return ORDER_RESULT_SUCCEEDED;
                              		} else {
                              // EMOD Bombard tile Imps  by E	20-JAN-2006
                              			for (i = 0; i< m_nElements; i++) { 
                              				if (m_array[i].GetDBRec()->GetCanBombardTiles()) { 
                              					Cell *cell = g_theWorld->GetCell(point);
                              					sint32 cellOwner = cell->GetOwner();
                              					for(sint32 ti = 0; ti < cell->GetNumDBImprovements(); ti++) {
                              					sint32 imp = cell->GetDBImprovement(ti);
                              					const TerrainImprovementRecord *trec = g_theTerrainImprovementDB->Get(imp);
                              						if(trec->GetCantPillage() == 0){
                              							for(i = 0; i < m_nElements; i++) {
                              								if(!m_array[i].GetDBRec()->GetSneakBombard()) {  //EMOD added by E for sneak bombarding
                              									Diplomat & defending_diplomat = Diplomat::GetDiplomat(cellOwner);
                              									defending_diplomat.LogViolationEvent(m_owner, PROPOSAL_TREATY_CEASEFIRE);{
                              										g_theWorld->CutImprovements(point);{
                              											return ORDER_RESULT_SUCCEEDED;
                              										}
                              									}
                              								}
                              							}
                              						}
                              					}
                              				}
                              			}
                              			}
                              		return ORDER_RESULT_ILLEGAL;//or allow bombarding tile improvements?  NOW ADDED by E
                              	}
                              
                              //end EMOD
                                  // defenders present
                              	for(i = 0; i < defender.Num(); i++) {//return illegal if at least one can't be attacked
                              		if(defender[i].Flag(k_UDF_CANT_BE_ATTACKED))
                              			return ORDER_RESULT_ILLEGAL;
                              	}
                              
                              	if(defender.GetOwner() == m_owner) {//return illegal if they're our own troops	
                              		return ORDER_RESULT_ILLEGAL;
                              	}
                              
                              	if(g_player[m_owner]->GetPlayerType() != PLAYER_TYPE_ROBOT ||
                              	   (g_network.IsClient() && g_network.IsLocalPlayer(m_owner)))
                              		if(!VerifyAttack(UNIT_ORDER_BOMBARD, point, defender.GetOwner()))//??? see VerifyAttack
                              			return ORDER_RESULT_ILLEGAL;
                              
                                  sint32 numAttacks = 0;
                              	sint32 numAlive = m_nElements;
                              	BOOL out_of_fuel;
                                  
                                  for (i = m_nElements - 1; i>= 0; i--) { 
                              		if(!m_array[i].CanPerformSpecialAction())
                              			continue;
                              		
                                      if (m_array[i].CanBombard(defender)) { 
                              
                              DPRINTF(k_DBG_GAMESTATE, ("unit i=%d, CanBombard(defender)=%d\n", i, m_array[i].CanBombard(defender)));
                              
                              			if(m_array[i].Bombard(defender, FALSE)) {//this unit tries to bombard a random member of defender 
                              				numAttacks++;
                              				if(numAttacks == 1){
                                                  // Inform defender 
                              
                              					//EMOD
                              					// add WonderCheck for EnablesPunativeAirstrikes
                              ////////////////////////
                              //		for(i = 0; i < g_theWonderDB->NumRecords(); i++) {
                              //			if(!g_player[c.GetOwner()]->m_builtWonders & ((uint64)1 << (uint64)i))
                              //				continue;
                              //
                              //			if(wonderutil_Get(i)->GetEnablesPunativeAirstrikes()) {
                              //				so->AddWonder(i);
                              //				break;
                              //			}
                              //		}
                              //////////////////////
                              
                              					PLAYER_INDEX defense_owner = defender.GetOwner();
                              					if(!m_array[i].GetDBRec()->GetSneakBombard()) {  //EMOD added by E for sneak bombarding
                              						Diplomat & defending_diplomat = Diplomat::GetDiplomat(defense_owner);
                              						defending_diplomat.LogViolationEvent(m_owner, PROPOSAL_TREATY_CEASEFIRE);
                              					}
                              				}
                              				// * Added auto-center for bombardment
                                              if (defender.GetOwner() == g_selected_item->GetVisiblePlayer())
                                                   g_director->AddCenterMap(point);
                              				g_director->AddAttackPos(m_array[i], point);
                              				
                              				AddSpecialActionUsed(m_array[i]);
                              				
                              				if(!m_array[i].GetDBRec()->GetMovementTypeAir()) {
                              					m_array[i].SetMovementPoints(0.0);
                              				} else {
                              					m_array[i].DeductMoveCost(k_MOVE_COMBAT_COST, out_of_fuel);
                              				} 
                              			}
                              		}
                                  }
                                  
                              	if(numAttacks <= 0)
                              		return ORDER_RESULT_ILLEGAL;
                              
                              	if(numAlive < 1)
                              		return ORDER_RESULT_SUCCEEDED;//a Pyrrhic victory, these were our guys
                                  //do counterbombarding and kill off attacking units
                                  for (i = 0; iGetNonLethalBombard()) { //EMOD
                              		for (i = defender.Num() - 1; 0 <= i; i--) { 
                              			if (defender[i].GetHP() < 0.999) {
                              				defender[i].KillUnit(CAUSE_REMOVE_ARMY_BOMBARD, GetOwner());  
                              			}
                              		}
                              //	}
                              //	}
                              
                              	for (i = 0; i< m_nElements; i++) { 
                              		if (m_array[i].GetDBRec()->GetCollateralTileDamage()) { 
                              			Cell *cell = g_theWorld->GetCell(point);
                              			sint32 cellOwner = cell->GetOwner();
                              			for(sint32 ti = 0; ti < cell->GetNumDBImprovements(); ti++) {
                              				sint32 imp = cell->GetDBImprovement(ti);
                              				const TerrainImprovementRecord *trec = g_theTerrainImprovementDB->Get(imp);
                              					if(trec->GetCantPillage() == 0){
                              						for(i = 0; i < m_nElements; i++) {
                              							g_theWorld->CutImprovements(point);
                              							//return ORDER_RESULT_SUCCEEDED;
                              							
                              						}
                              					}
                              			}
                              		}
                                 		//return ORDER_RESULT_ILLEGAL;
                              	}
                                  //if there's a city at point, try to destroy a building and kill a pop
                              	BombardCity(point, FALSE);
                              	return ORDER_RESULT_SUCCEEDED;
                              }
                              Formerly known as "E" on Apolyton

                              See me at Civfanatics.com

                              Comment


                              • I added this to armydata::bombard. it appears more stable. However there is a problem with stacking units that are sneakbombard (and sneak attack) granted I use the cantgroup slic but not sure what the glitch is.


                                Code:
                                //emod
                                
                                	PLAYER_INDEX  defense_owner; 
                                    defense_owner = defender.GetOwner(); 	
                                	bool AlltaSneakBombard = true;
                                
                                		for(i = 0; i < m_nElements; i++){
                                			if(!m_array[i].GetDBRec()->GetSneakBombard()){
                                				AlltaSneakBombard = false;
                                				break;
                                			}
                                		}
                                
                                		if(!m_array[0].GetDBRec()->GetSneakBombard()){
                                				AlltaSneakBombard = false;
                                		}
                                
                                
                                
                                	bool AllDefSneakAttack = true;
                                	for(i = 0; i < defender.Num(); i++) {
                                		if(!defender[i].GetDBRec()->GetSneakAttack()){
                                			AllDefSneakAttack = false;
                                			break;
                                		}
                                	} 
                                
                                		if(!defender[0].GetDBRec()->GetSneakAttack()){
                                			AllDefSneakAttack = false;
                                		}
                                		
                                	
                                	if(!AlltaSneakBombard && !AllDefSneakAttack){
                                		Diplomat & defending_diplomat = Diplomat::GetDiplomat(defense_owner);
                                		defending_diplomat.LogViolationEvent(m_owner, PROPOSAL_TREATY_CEASEFIRE);
                                	}
                                //end EMOD
                                Formerly known as "E" on Apolyton

                                See me at Civfanatics.com

                                Comment

                                Working...
                                X