Announcement

Collapse
No announcement yet.

Needed Slic triggers to improve Ctp2

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

  • Needed Slic triggers to improve Ctp2

    Here is a list of slic triggers which would make Ctp2 a better game. Most of these triggers should be able to be used with any mod, so those of you working on your own mods will benefit from making these just as much as the rest of us.

    1)A trigger to keep units from bombarding underwater units unless they can also attack underwater units.
    This will keep subs from being killed by air or naval units like Battleships when they are accidentally discovered by those units. I asked for a "Bombard Underwater" flag way back when I was a beta-tester, but I guess the game was too far along for them to put this flag into the game.
    Note: I think I have come up with a setup which will make the creation of this trigger unnecessary.

    2)The AIs have a habit of running their planes out of fuel and losing them. I will give planes enough fuel for two turns, plus one more space to take into account the fuel used when attacking. I need a trigger to make the AIs return their planes to the nearest city, airbase or Carrier if they do not begin their turn in a city, airbase or Carrier.

    3)I have changed several wonders in the game to give improvements in every city. I need a trigger that removes the option to build improvements if a civ has a wonder that grants that improvement to every city. This has been discussed before, but I don't recall the options to disable this "feature".

    4)Locutus, I believe, had asked before about clearing orders, and I think that this is a good idea. What I would want is a trigger to clear all unit orders say, every 3 turns, and another trigger to clear orders whenever an AI civ loses one of its cities. If this is hard to do, then a trigger which makes the seige goal the highest priority whenever a city is lost may work just as well.

    5)I need a trigger to disable the Start Strategies after 125 turns. I just want the AI to use it's default personality strategy when at peace, and the three war strategies when in that state.
    You see, I have added some things to the Start strategies that should help the AIs at the start of the game, but these settings will interfere with the other strategies if they are in play for the entire game.
    Locutus: Oh, wait a minute. I misunderstood what you meant by Start strategies, but now I get it. I think reloading the standard personality strategy (with SetStrategicState) after 125 turns or whenever you want will undo the changes of the Start strategies. I think this can be done.

    6)On another note, I would like to change the way buildings are obsoleted. Right now, they are obsoleted (and destroyed) upon discovery of the advance which gives their replacement. I want to change it so that they are destroyed when their replacement is built. Charles mentioned that something similar to the militia code would seem to be able to do this.
    This is a trigger that I would like to be in place for the beta.

    7)Richard: However, if you force the AI to declare war and make sure the diplomatic state for the AI (in
    diplomacy.txt) will refuse peace that should do what you want. So how do you foce the AI to declare war? Sigh, I have a function to do this, but I forgot to expose it via SLIC. However, there is a fun way
    you can do this. Create a new goal (maybe called
    GOAL_PROVOCATION) that looks a lot like an attack goal, but in which the TargetOwner: is ColdEnemy rather than HotEnemy. This will cause the AI to preemptively attack, and once at war it will stay at war as long as it never makes or accepts a ceasefire. You'll have to add the goal to everyone, but only set it to have maxeval > 0 for beligerent AI. You could also swap in a strategy specifically that enables this
    goal only when the AI has military superiority.

    WesW: I would like a trigger to swap in a strategy that enables this goal when they have military superiority. I will set the MaxEval > 0 for Militaristic and Ecotopian AIs.

    WesW: I thought that there were settings in the game already to determine relative military strengths. Doesn't the AI use these in deciding whether to declare war, or what war strategy to use?

    Locutus: You're right. MilitaryRank can be used for this. I didn't think of this yet, it's hardly ever useful for anything but it's perfect now. Should be fairly simple then.

    8)On a more general comment, don't you think it would be good to have embassies more permanent even if you don't get the wonder? I think it would be worth it to write some SLIC so that if you make peace with a civ you'd had an embassy with before the war, the embassy is automatically reinstated.

    This next trigger is specifically for the Med mod, but of course it can be used by others if they so desire.

    Wouter, below is an excerpt from a letter Harlan sent me about the wonder-units. We were discussing alternate ways of granting the units rather than using wonders. Read this over, and let me know if you think it can be done via slic, and if it would slow the game down much. We would need to scan the 9 squares within each city's initial radius for this to work.

    > What would be really cool is if you base the odds of getting each special
    > unit not on pure chance, but on appropriateness for the civ. For instance,
    > you could use a quick analysis of the terrain the civ's cities are on (or
    > terrain immediately adjacent to the city) when they reach the tech for the
    > unit. The higher percentage of cities on the coast, the more likely they
    > can get an ocean special unit, for instance. The more cities on jungle,
    > the more likely they get War Elephant. The more cities on Plains, the more
    > likely they get Nomad Horseman. Forest for Longbowman, Hills for Hoplites,
    > etc... This has several advantages. 1) You won't get AI civs building
    > wonders that will lead to units they don't need. For instance an inland
    > civ building a naval unit enabling wonder. 2) It solves you War Elephant
    > problem- no need for extra code there. 3) Chances are greater these
    > special units will actually be useful for the civs that can build them.
    >
    Locutus: This is definitely possible, no doubts about that. I don't even think it's gonna be very expensive if you implement it properly: Harlan suggests checking terrain when a civ discovers the appropriate tech, but one could also calculate the odds every time a city is founded, captured, destroyed, etc. and store the results in a small array (and read that array when the advance comes available). So instead of doing all the calculations at once, you're spreading them over the entire game (as long as there are still special units to be aquired).

    I could even include a check for changes in city radius size and not only check for the tiles immediately surrounding the city but the entire city radius, though that would cost some extra resources since changes in city radius occur relatively often (though usually not for more than 1 or 2 cities at a time/turn so if there's a slowdown at all it's a minimal one).

    WesW: This sounds great, Wouter. All the special units occur before the Renaissance age, so city radii should not be more than 2.

    Additional triggers I would like to see in the Med Pack II:
    1)A refugee trigger which takes a quarter of a city's population and disperses it among the other cities of a civ when a city is lost to conquest.

    2)A trigger to destroy a percentage of all the buildings in a city when that city is captured by assault, ala civ2. Right now, all you can lose is one building during assault, which is totally unrealistic when you look at what happens to a city during warfare.
    [This message has been edited by WesW (edited February 15, 2001).]

  • #2
    quote:


    8)On a more general comment, don't you think it would be good to have embassies more permanent even if you don't get the wonder? I think it would be worth it to write some SLIC so that if you make peace with a civ you'd had an embassy with before the war, the embassy is automatically reinstated.



    Wes:
    Ripped and modified slightly from the diplomacy mod. This is untested and untried and thus unknown.

    Code:
    ///////////////////////////////////
    // The art of establishing embassies
    ///////////////////////////////////
     
    // Globals
     
    int_t hasemb[];
    int_t hademb[];
    int_t numplays;
     
    // In game start event make sure numplays is set to how many players are in the game (or use an existing counter if present)
     
    // EstablishEmbassy function after checks
     
    void_f EstablishEmbassyFunc(int_t recipient) {
    	int_t civ;
    	int_t civ2;
    	city_t tmpcity;
    	location_t tmploc;
    	unit_t tmpunit;
     
    	civ2 = recipient;
    	civ = player[0];
    	if(HasAdvance(civ, ID_ADVANCE_BUREAUCRACY) && IsPlayerAlive(civ2) && civ2 != 0 && !(AtWarWith(civ, civ2))) {
    		GetCityByIndex(civ, 0, tmpcity);
    		if(CityIsValid(tmpcity)) {
    			GetRandomNeighbor(tmpcity.location, tmploc);
    			if(GetUnitsAtLocation(tmploc) == 0) {
    				if(TerrainType(tmploc) < 10 | | TerrainType(tmploc) > 17) {
    					CreateUnit(civ, UnitDB(UNIT_DIPLOMAT), tmploc, 0, tmpunit);
    					Event: EstablishEmbassyUnit(tmpunit, tmpcity);
    					Event: DisbandUnit(tmpunit);
    					hasemb[civ, civ2] = 1;
    					hademb[civ, civ2] = 0;
    				}
    			}
    		}
    	}
    	return;
    }
     
    // Flag embassy created
     
    HandleEvent(EstablishEmbassy) 'FlagEmbassyMade' pre {
    	int_t civ;
    	int_t civ2;
    	civ = player[0];
    	civ2 = player[1];
    	hasemb[civ, civ2] = 1;
    }
     
    // Flag had an embassy on war
     
    HandleEvent(DeclareWar) 'FlagHasEmbassy' pre {
    	int_t civ;
    	int_t civ2;
    	civ = player[0];
    	civ2 = player[1];
    	if(hasemb[civ, civ2] == 1) {
    		hademb[civ, civ2] = 1;
    		hasemb[civ, civ2] = 0;
    	}
    }
     
    // Check at beginning of turn
     
    HandleEvent(BeginTurn) 'EmbassyCheck' pre {
    	int_t civ;
    	int_t civ2;
    	civ = player[0];
    	for(civ2, civ2 < numplays, civ2 = civ2 + 1) {
    		if(hasemb[civ, civ2] == 0 && hademb[civ, civ2] = 1 && !(AtWarWith(civ, civ2))) {
    			EstablishEmbassyFunc(civ2);
    		}
    	}
    }
    For some wierd reason you have to create embassys via a unit. Anyways, each turn it'll check whether two civs are at war and meet the had emb condition. The function will check that the recipient's capital exists (shouldn't be able to have embassys if you don't have a capital), find a spot next to the city, check for units and land terrain, and if all clear will create a diplomat and establish an embassy disbanding the diplomat after. If the conditions aren't met it will try again next turn. The global arrays keep track of whether two civ combos have an embassy and had an embassy. On a declaration of war, if an embassy is present then it sets embassy to off and hadembassy to on. That script was off the top of me head so I'm sure someone will come up with a better one, but that's an idea that'll work (as long as I got the syntax right ).

    ------------------
    Rommell to a sub-commander outside Tobruk: "Those Australians are in there somewhere. But where? Let's advance and wait till they shoot, then shoot back."
    [This message has been edited by Dale (edited February 15, 2001).]
    [This message has been edited by Dale (edited February 15, 2001).]

    Comment


    • #3
      This ounds cool. Why didn't the activision peope think of those.
      Also, is there a way to stop catapults and cannons from bombarding leviathains?
      Is there a way to make units like Hoplite be Insignificant vs. Machine Gunners?
      Just a few more ideas.
      "It is ridiculous claiming that video games influence children. For instance, if Pac-Man affected kids born in the 80's we should by now have a bunch of teenagers who run around in darkened rooms and eat pills while listening to monotonous electronic music."

      Comment


      • #4
        Wes,

        I thought you were gonna post new ideas. Except for the embassy thing none of this is new. Oh well, you won't hear me complaining, saves me a lot of time (that I don't have anyway)...

        Here's a couple of triggers I came up with recently. It's all still untested 'cause I don't have time to test (maybe this weekend, but not making any promises), but maybe you or someone else can take a look at them... The code takes care of the clearing of orders, the turning off of start strategies and the disabling of wonder-buildings. They're not very well documented, so I hope this makes sense to anyone.

        Code:
        // Clear all orders of thePlayer
        void_f	MM2_ClearOrders(int_t thePlayer) {
        unit_t	tmpUnit;
        int_t	i;
        int_t	tmpPlayer;
        	tmpPlayer = thePlayer;
        	player[3] = tmpPlayer;
        
        	for (i = 0; i < player[3].units; i = i + 1) {
        		GetUnitByIndex(tmpPlayer, i, tmpUnit);
        		ClearOrders(tmpUnit);
        	}
        }
        
        // every turn, clear all orders of 1/3 of the AIs (one particular AI will have his orders cleared every third turn)
        // (this spreads any slowdown caused by this trigger to be spread over 
        // all turns instead of being concentrated in 1/3 of the turns)
        EventHandler(BeginTurn) 'MM2_SetupClearOrders' post {
        int_t	tmpPlayer;
        	tmpPlayer = player[0];
        
        	if (!IsHumanPlayer(tmpPlayer)) {
        		if (g.turn/3 == (g.turn + 2)/3) {
        			if (tmpPlayer/3 == (tmpPlayer + 2)/3) {
        				MM2_ClearOrders(tmpPlayer);
        			}
        		} elseif (g.turn/3 == (g.turn + 1)/3) {
        			if (tmpPlayer/3 != (tmpPlayer + 2)/3 && tmpPlayer/3 == (tmpPlayer + 1)/3) {
        				MM2_ClearOrders(tmpPlayer);
        			}
        		} else {
        			if (tmpPlayer/3 != (tmpPlayer + 2)/3 && tmpPlayer/3 != (tmpPlayer + 1)/3) {
        				MM2_ClearOrders(tmpPlayer);
        			}
        		}
        	}
        }
        
        // at turn 125, turn off start strategies
        EventHandler(BeginTurn) 'MM2_TurnOffStartStrategies' post {
        	if (g.year == 125) {
        		SetStrategicState(player[0], StrategyDB(player[0].leaderpersonality));
        	}
        }
        
        // make buildings unbuildable for civs with a wonder that grants those buildings
        int_f mod_CanCityBuildBuilding (city_t theCity, int_t theBuilding) {
        city_t	tmpCity;
        int_t	tmpBuilding;
        	tmpBuilding = theBuilding;
        	tmpCity = theCity;
        
        //	if (!IsHumanPlayer(tmpCity.owner)) {
        		if (tmpBuilding == BuildingDB(IMPROVE_SHRINE)) {
        			if (PlayerHasWonder(tmpCity.owner, WonderDB(WONDER_RAMAYANA)) {
        				return 0;
        			} else {
        				return 1;
        			}
        		} elseif (tmpBuilding == Building(IMPROVE_CITY_WALL)) {
        			if (PlayerHasWonder(tmpCity.owner, WonderDB(WONDER_GREAT_WALL)) {
        				return 0;
        			} else {
        				return 1;
        			}
        		} elseif (tmpBuilding == Building(IMPROVE_FORCE_FIELD)) {
        			if (PlayerHasWonder(tmpCity.owner, WonderDB(WONDER_NATIONAL_SHIELD)) {
        				return 0;
        			} else {
        				return 1;
        			}
        		} else {
        			return 1;
        		}
        //	}
        	return 1;
        }
        [This message has been edited by Locutus (edited February 16, 2001).]
        Administrator of WePlayCiv -- Civ5 Info Centre | Forum | Gallery

        Comment


        • #5
          Good ideas all. I would also like to see a trigger where a barbarian held city, after "x" amount of turns after being captured, has a chance of 1) forming a new civ 2) rejoining their old civ or 3) joining the nearest civ. Perhaps along the lines of 10/50/40% chance respectively. Why? Gameplay: It makes for a horrible game when masses of AI cities are captured by barbs, they pretty much do nothing except try and capture more cities on that land mass. No diplomacy no expansion. I've seen this in the unmodded CTP2 many times...the worst being a game where two whole AI civs were wiped out. Boring. Historical: I think you can look at the barbs in one of two ways: raiders and plunderers or guerillas. Raiders are going to pillage the city then move on and eventually the city is going to revert back to some sort of normalcy in which case they would either join their old civ or, disgusted with that government's weak military, would form a new civ or join another. Guerillas may want to stay and retain control of the city, in which case they would eventually have to develop laws and infrastructure, in effect becoming a new civ.

          Hopefully there will not be as much of a need for this with MedMod as the AI will recognize the need to recapture lost cities. But still, it would make a nice piece of code IMHO. Is it possible in SLIC??

          Could someone come up with an unfinished generic slab of code that I could use as a template so that when any civ is the first to create a designated unit (say...machine gunner) then all of a second, older designated unit (say...pikemen) in all civs are destroyed, a la how the slaver is destroyed with the building of the Emancipation Act. I was thinking that if, when a defensive (flanker, ranged etc) unit is first built then all units of the same category two generations back would be eradicated. An alternative could be when any one civ is the first to reach a new Age then "x, y and z" units are all destroyed. Primarily for gameplay...I hate seeing samurais and tanks on the same screen. I'd appreciate it if someone could whip up the rough sketch on how this would work so I could adapt it for my own game.

          You SLIC guys may not think it a big deal to write the code but for those of us who are not of a programming background (whatsoever) it's fairly daunting. You are appreciated.

          Wes, any form of the dissemination slic to be put in the new MM? I really liked that trigger.

          It's a shame about the lack of a "bombard underwater" flag but I don't know if it would have easily do-able for the programmers as the CanBombard flag is based on movement type and underwater is a vision class but not a movement type. I think it's a shame b/c I'd like to have a unit that was not able to directly engage a sub but could bombard it (like an ASW Sea King helicopter which can drop depth charges and torpedoes) tho not be able to bombard surface ships. I like specialization in my units. Oh well...

          Looking forward to the next release.

          Comment


          • #6
            That Barbarian Slic coding would be a great one to have.
            Yes, let's be optimistic until we have reason to be otherwise...No, let's be pessimistic until we are forced to do otherwise...Maybe, let's be balanced until we are convinced to do otherwise. -- DrSpike, Skanky Burns, Shogun Gunner
            ...aisdhieort...dticcok...

            Comment


            • #7
              XMon,

              The barbarian code is probably possible, at least if you want the barbs to revert back to one of the existing civs. I'm not sure about forming new civs, I'd have to look into that in more detail.

              'We SLIC guys' *do* realize that programming SLIC can be quite difficult indeed, even if you have a background in programming, and we'd love to help 'you non-SLIC guys' out, but the problem is that there's only a few of 'us' and a lot of 'you', so even though all the SLIC ideas mentioned on these forums in the past months are fantastic and should all be given a try, there's simply not enough people to realize them all. I don't know about other SLIC programmers but I recently made a list of stuff to do in the next two months and I ended up with a list that'll take me something like 6 months to realize in the very least.

              Lately I've been extremely busy with school so I haven't had much time for CtP2, but hopefully I'll be able to release part 1 of my SLIC manual in a few weeks. With a bit of luck that (and certainly part 2) might pursuade more people to give SLIC a try, since programming SLIC really isn't as difficult as it may seem, once you get the hang of it...

              You might be right about submarine thing, I'm not sure at the moment how to read the movement and attack related flags, though I haven't had much time to look into that yet either. But there's still no problem, if necessary there's always the less elegant but just as effective solution of unit-type checking: if unit is cannon -> it can't bombard submarines, if unit is destroyer -> it can bombard submarines, etc. Not as pretty as checking attributes in unit.txt, but it works just as well...
              Administrator of WePlayCiv -- Civ5 Info Centre | Forum | Gallery

              Comment


              • #8
                Locutus, just wanted to let you guys know that we appreciate the help. I know there are not many of you...and you guys are a valuable resource. Just want to give some positive feedback to keep the interest level up.

                It's weird that there is a CanAttack Underwater flag. All the other CanAttack flags designate movement types (CanAttack Mountain...ShallowSea etc) but there is no Underwater movement type. Within ctp2.exe, the word "underwater" appears: NO_UNDERWATER_ATTACK, UNDERWATER_ATTACK, as a member of CanSee group, as a member of VisionClass group and as a member of CanAttack group. There is even CanAttack Trade (?) but Trade IS a movement type. Has anyone tried to attack a sub with a battleship? Maybe the CanAttack Underwater flag doesn't work. I'll have to try that experiment... Btw, NO_UNDERWATER_ATTACK, UNDERWATER_ATTACK appear in ctp2.exe but not in units.txt.

                The "unit-type checking" thing re: bombardment, is that in SLIC? That opens up a whole new world of possibilities! Like perhaps certain unit types could be designated to cause no incursion_regard_costs?

                Thanks for the info Locutus.

                Comment


                • #9
                  Xmon, there are settings built into the diffdb which should perform the same functions as the disseminate trigger.

                  Locutus, I knew that "you" had been told about my desire for most of these triggers, but as you point out, you will not be able to get to them anytime soon, so I made this thread as a way of letting everyone else know about the need for them. Glad to see you did have time to work on a couple of them.

                  Let me see...
                  I think I can do without the bombard trigger, no.1, at least until the other triggers on the list have been made.

                  We have code posted here for 3, 4, 5, and 8.
                  We can wait and see how the AI performs before resorting to the trigger redcribed in no.7.
                  I would think that no.2 would not be too hard to make, and it would address a definite short-coming in the game. Anyone want to try that one?

                  No.6 is more for the Med mod than the original game, but I think it would be used by other people if it was available. Same thing for the triggers listed at the bottom of the post as being for the Med mod, especially the refugee and building loss triggers. These two would make the game much more realistic, imo.

                  Comment


                  • #10
                    Xmon,
                    Yes, the unit-type checking is in SLIC. All kinds of options here (and already used in some cases, such as the general and Alexander code in the Alexander and WWII scenarios, the militia code in the MedMod, etc).

                    Not sure what exactly you mean with no incursion_regard_cost, but I think Diplomats and some other units already have something like this, so what you mean might already be possible through the text files...

                    Wes,
                    Yes, but you mentioned to me (over ICQ IIRC) that you and Charles and Harlan had come up with some new stuff... I guess I just misunderstood (seem to do that a lot lately ). Haven't had much time for testing but I'll see what I can do this week or next weekend.
                    Administrator of WePlayCiv -- Civ5 Info Centre | Forum | Gallery

                    Comment


                    • #11
                      Just on Locutus' comment on SLIC being easy, it is once you get basic commands. Also, a thing I find makes programming very simple is write what you want to do in plain language. See below for example. I find this makes me write out what I want to do for every piece of code in the mod.

                      Code:
                      // Example of plain language programming
                       
                      BeginProgram{
                       
                      If current players turn is the human then
                           Add $1000 to human player
                           Find capital city of human player
                           Create a tank in capital city of human player
                      else if current players turn is computer then
                           Add $100 to computer player
                       
                      }EndProgram
                      All this in SLIC would come pretty close to (untested):

                      Code:
                      // Example of translating plain language to SLIC
                       
                      HandleEvent(BeginTurn) 'DemoPlainLangMod' pre {
                       
                      city_t tmpcity;
                      location_t tmploc;
                       
                      if(IsPlayerHuman(g.player)) {
                           AddGold(g.player, 1000);
                           GetCityFromIndex(g.player, 0, tmpcity);
                           tmploc = tmpcity.location;
                           if(CityIsValid(tmpcity) && GetUnitsAtLoc(tmploc) < 12) {
                                CreateUnit(g.player, tmploc, UNIT_TANK);
                           }
                      } else {
                           AddGold(g.player, 100);
                      }
                      }
                      Pretty easy really.

                      ------------------
                      Rommell to a sub-commander outside Tobruk: "Those Australians are in there somewhere. But where? Let's advance and wait till they shoot, then shoot back."

                      Comment

                      Working...
                      X