Announcement

Collapse
No announcement yet.

Gedrin, about your dissemination triggers

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

  • Gedrin, about your dissemination triggers

    Gedrin,

    I (finally) had time to study them yesterday and I found a few odd things in them, you may have put them there deliberately but you may not have, so I thought I'd mention them.

    1) Back when I still had CtPI installed on my system I tried your triggers for a while and all the time got messages about having received advances that I already possessed. Example: (didn't actually occur, but it could have) in turn 100 I invented Monarchy and in turn 120 I got the message that I had gained the advance of Monarchy due to the dissemination code (don't remember the exact text anymore). This can easily be prevented by performing one extra test (to see if the player already has the advance) before sending the message to human players, like this:

    Code:
    if ((advanceGranted == 1) && (IsHumanPlayer(playerIndex) == 1) && !HasAdvance(playerIndex, discovery.type))  {
       Message(playerIndex, '117DisseminationDiscovery');
    }
    2) You make the same mistake (presuming it is a mistake) as I did for the Garrison code, you treat the discovery.type and discovery.trade as two seperate cases, but in fact discovery.type covers the trading of advances as well, so you during trade you add two instead of one to the variable that keep track of the number of times a new advance is gained. (Actually, you *might* even be adding four to the variable since there are two parties involved in trade so it's possible (though I'm not certain of it) that the trigger is activated twice).

    3) For number of players you take the number of players that was in the game at the start, not the number of players currently in the game. Did you do make that choice deliberately or did you not see a better way to do it? If the latter is the case, I might have a solution for you. I didn't actually test it (don't have CtP installed at the moment), but something similar seemed to work when I working on flat-map support. It would look something like this:

    [code]numberOfPlayers = 0;
    if (player.0 == 0) {numberOfPlayers = numberOfPlayers + 1;}
    if (player.1 == 1) {numberOfPlayers = numberOfPlayers + 1;}
    if (player.2 == 2) {numberOfPlayers = numberOfPlayers + 1;}
    if (player.3 == 3) {numberOfPlayers = numberOfPlayers + 1;}
    if (player.4 == 4) {numberOfPlayers = numberOfPlayers + 1;}
    if (player.5 == 5) {numberOfPlayers = numberOfPlayers + 1;}
    if (player.6 == 6) {numberOfPlayers = numberOfPlayers + 1;}
    ...(etc until: )
    if (player.32 == 32) {numberOfPlayers = numberOfPlayers + 1;}

    IIRC every player that doesn't exist has the value 0, so only the players that exist are counted.

    Like I said, I haven't actually tested any of this so I may well be wrong about everything or my 'solutions' might not work at all, but if you ever want to improve your code, you could have a look at this.

    Further I'd like to say that I really like all the cool SLIC work you're doing and I'm looking forward the your next thing
    [This message has been edited by Locutus (edited September 29, 2000).]
    Administrator of WePlayCiv -- Civ5 Info Centre | Forum | Gallery

  • #2
    Hmmm... you know I think I may have to rewrite the whole thing to deal with this new info about userdefined values not persisting over a restart.

    I don't see anyway to do it without couting the number who HasAdvance every time.

    But I am very confused. When I reload my games I do not execute Setup again... meaning numberOfPlayers is not reset and yet I see no impact on the operation of functions that require these values.

    In addition to the fact that SLICs cannot be added midgame I suspect the entire SLIC address space is saved on a savegame.

    How did you come to conclude that user defined primitive values are not stored? What about the structures like UnitType etc... are they stored?

    Seems odd to have such things if they are not stored.

    Gedrin

    Comment


    • #3
      No, Gedrin, I don't see an alternative way of implementing your ideas either (apart from waiting for CtPII to arrive but I don't think that's what you want to hear )

      Gemini found out about the variable-thing, look here. I didn't double-check his findings at the time as I normally would have, because school-exams were pretty much taking up all my time. You can always investigate for yourself, you never know...

      I don't know if structures are saved, you'd have to try for yourself.

      The whole thing seems very odd to me as well, but I don't suppose Activision deliberately choose for this, it has to be a bug.
      [This message has been edited by Locutus (edited October 02, 2000).]
      Administrator of WePlayCiv -- Civ5 Info Centre | Forum | Gallery

      Comment


      • #4
        Hey Locutus:

        Thanks for your comments. I'll address them in sequence:

        1) This I did deliberately. The reason was that !HasAdvance(playerIndex, discovery.type) does not actually take an integer for the second argument. It takes a language specific string from the DB.
        Ex:
        HasAdvance(playerIndex, ID_ADVANCE_AGRICULTURE)
        So I would have had to have placed that in another temp value and well I was being lazy.
        The reason I was so lazy was because I was not too concerned about sending a message about hearing of an advance from a far off land when you already had it. Testing indicated that a GrantAdvance event on an advance you already had did nothing negative so I figured... alright you already have the advance sure but did still just hear about it from a far off land.
        The down side to my lazyness concerning the ID_string issue is that when you discover and get disseminated someone elses advance in the same year... you get a message containing the string of the advance you discovered. Again I was being lazy. But there is another far more serious bug see below.

        2) I had no idea that discovery.type fired when advances were traded. This can greatly simplify things with my code and I plan to impliment the changes immediately to deal with that. I too found that trading resulted in high rates of dissemination in other civs (thanks to the P. Stone). I was just putting it down to chance. Thanks.

        3) I did this deliberately. If you elimate all but one other civ in the game I felt it was easier to protect your national secrets and therefore less chance of dissemination.

        I can see the arguement against that though. If the entire world is full of many civs or the entire world is full of two civs... what is the diff?

        It was a choice.

        However I think the player.index notation you gave involves an incorrect assumption.
        player is a rather volitile container.
        the value of player.1 changes with every trigger.
        player.32 is likely never defined since there is rarely any need to have 32 civs in the current context.

        A better way would be something like this:
        trigger 'playerCount' when (g.year == 0) {
        if g.player == 0 {numberOfPlayers = 0}
        else {numberOfPlayers = numberOfPlayers + 1;}
        }
        valid values for player can go from 0 to oh probably 31 but maybe 32... although 32 makes no sense to me since it uses another bit without using the full bitspace.
        In a single player game:
        0 = Barbarians
        1 = Human player
        2 = AI ...
        ...
        8 = AI ...
        9 = Human player if it is an 8 player game.
        10 = I have no idea if it fills the rest of the array with player 1 or if it repeats the 8 non barbarian players.

        More )
        Now further to this I have since found a bug in the counting. It does not increment the counter when I GrantAdvance. In fact I do not know if I should since I do not know if the player being given the advance actually had it already. So the latest file I gave WesW finally got be off my lazy duff and prompted me to add the HasAdvance check in.

        if (discovery.type == 0) {
        if (HasAdvance(playerIndex, ID_ADVANCE_AGRICULTURE) != 0) {
        if (Random(numberOfPlayers)< (1+numberWithAgriculture-numberOfPlayers/2)) {
        advanceGranted = 1;
        GrantAdvance(playerIndex, discovery.type);
        }
        }
        }

        Note the 1+numberWithAgriculture-numberOfPlayers/2 is as such as per WesW's request that at least 1/2 the civs know it. The 1+ is there to accound for the civ that just discovered it. I did that to avoid a third time consuming blocks of if statements (ie the case equivalent).
        And then later if there was an advanceGranted I keep track of the fact with:
        advancesGranted = advancesGranted + advanceGranted;

        // Now update the counters with the one who discovered it and all the ones we granted
        if (discovery.type == 1) { numberWithToolmaking = numberWithToolmaking + advancesGranted + 1;}

        Hmmm... I think that covers it.

        Gedrin

        Comment

        Working...
        X