Civ4lerts

ruff_hi

Live 4ever! Or die trying
Joined
Oct 24, 2005
Messages
9,134
Location
an Aussie in Boston
I thought that I would start a thread for alerts. There are a number of threads talking about alerts and it is nice to have them all combined. If you find a thread talking about alerts, can you please post a reference here.

Link to original thread by Dr Elmer Jiggle. The code has also been extended by the HOF people as well as EmperorFool.
 
Code:
* Civ4lerts:
  * Get alerts about trades even when civ won't talk to you
  + New alerts:
    + Civ will talk to you
    + Civ will go to war
    + Civ will stop trading
    + "Too much on our hands"
    + "WFYABTA"
    + Whip anger decreases by one
    + City no longer unhappy/unhealthy
    + build queue can be completed with pop or cash rush
 
  • city alert saying 'unhappy' when it isn't
 
I was playing a game yesterday where I had whip anger that was expiring in 1 turn, happy v unhappy was currently 5 v 5 and the city was due to grow in 1 turn. I thought that I was pretty damn good arranging my city growth and whip unhappy that way :D

I got the 'city will grow into unhappy' alert on the turn pre-growth. I then got the 'city unhappy' alert on the turn when it did grow. The city wasn't unhappy as the whip anger had expired.
 
i say again: an alert that a build is whippable/buyable would be super shweet!
 
I was playing a game yesterday where I had whip anger that was expiring in 1 turn, happy v unhappy was currently 5 v 5 and the city was due to grow in 1 turn. I thought that I was pretty damn good arranging my city growth and whip unhappy that way :D

I got the 'city will grow into unhappy' alert on the turn pre-growth. I then got the 'city unhappy' alert on the turn when it did grow. The city wasn't unhappy as the whip anger had expired.

I have observed the same behavior.
 
I've got some questions about handling the "can whip/buy" alert.

Start New Item

  1. You start producing an item at zero hammers.
  2. You cannot hurry it now.
  3. ...turns go by...
  4. You can hurry it now. Alert!
What should happen if you can whip it when you start it (2)?

Continue Item

What should happen if you put an item on hold and then continue it later, but you've already past the point where you could hurry it.

  1. You start producing an item at zero hammers.
  2. You cannot hurry it now.
  3. ...turns go by...
  4. You can hurry it now. Alert!
  5. ...turns go by...
  6. You interrupt it to build something else, and that new build completes.
  7. You continue building the original item from (1).
  8. You can still hurry it. Alert?
What happens if, upon continuing the build, you can no longer hurry it. It seems reasonable to show the alert again once you can.

I'll post when I think of other scenarios. This may not be as tough as I thought after originally thinking it would be easy. :crazyeye:
 
A refresher on events:

  1. Human takes turn, hits end turn.
  2. BeginPlayerTurn, EndPlayerTurn
  3. AIs take their turns
  4. BeginGameTurn, EndGameTurn
The gold trade alerts are generated during BeginPlayerTurn. And then the AIs take their turns, making the alert info old.

I can easily change it so the alerts happen in BeginGameTurn, but this will cause odd behavior in cases where you are playing with a set bunch of civs for the map and aren't playing the first civ. For example, if you play the Earth scenario, some alerts will be correct, and some will be incorrect.

For all the cases where you start a normal game as player 0, the alerts will be correct. Normally I'd go with consistent results rather than flaky ones, but I bet 99% of all games will have the human playing as player 0. I'm going to change it and people can chime in if that's not the way to go.
 
i say again: an alert that a build is whippable/buyable would be super shweet!

Enjoy the new shweetness! :D

Also, the gold trade alert staleness has been fixed.

Please keep an eye on these alerts to see if I introduced any bugs. I also did a minor optimization so that the game no longer checks foreign cities for (pending) growth.

I also figured out why the Autolog doesn't log when projects are started: Civ4 doesn't have an event for starting projects, only units and buildings. Go figure.

Finally, there is one situation I found where the "can hurry" alert doesn't show up. It's a total corner case and not a big deal, but be forewarned:

  1. Start a scout that you can whip now.
  2. Alert!
  3. Insert a warrior that you can whip now.
  4. Alert!
  5. Remove warrior
  6. No alert
  7. Insert the warrior
  8. No alert
  9. Insert a new scout (2 in list now)
  10. Alert!
I'll send a cookie to anyone who understands what I just said. :p Basically, you only get an alert when you start a new item, even if there are other items of that type in your queue. Shifting items around doesn't display alerts. I actually like that it works this way, but YMMV.

Oh, I haven't added an option for this yet so it's always on if alerts are on. I'll do it tomorrow, but I must sleep now.
 
Enjoy the new shweetness! :D
awww yeah :dance:

SOMEbody listens ~ now, let's see what else i can think of? :lol:

can't wait for updates to BUG and a stable BAT ~
 
great work EF. psst - where is my cookie?
 
Sorry, Ruff, I ate it. Yummy!

Regarding the city-grow-and-whip-decay-timed-perfectly-false-alert bug, it would be very helpful if someone could post a saved game with a city that will show the alert when I hit "end turn". There are other anger timers as well:
  • Whip
  • Draft
  • Defy Resolution
And apparently there's a "happy timer". Is there some event that makes a citizen happy for X turns? There's no general "anger" timer, but I'm sure there are random events that make a citizen angry for X turns. I'll have to dig to see how that's handled.

Edit: Nevermind. I see what the problem is. The DLL fires onCityGrowth event -- where the "city became angry" alert is shown -- before it adjusts the anger counters. Hopefully I can fix this without too much effort by moving the alert into cityDoTurn which fires after all adjustments are made.
 
There are two ways to fix this.

The Broken Way

Use cityDoTurn to display an alert when a city goes from happy to unhappy or vice versa. This fixes the immediate problem of a city growing into unhappiness on the same turn some anger counter decays by 1 citizen, causing no net unhappiness.

This is broken because these events will fire immediately after you hit "end turn" but before all the AIs go. If an AI performs the "Piss off the locals" espionage mission in one of your cities for +8 unhappiness, the alert will not fire until the next turn.

The Right Way

Use endGameTurn to loop through all cities and display alerts when they change from happy to unhappy or vice versa. This fixes both problems (unless you're playing a fixed-civ scenario and aren't player 0).

The downside to this solution is that you'll get all growth alerts first followed by all happy/unhappy alerts. You'll also get all happy alerts followed by all healthy alerts

  1. Washington has grown to size 6
  2. Alabama has grown to size 5
  3. Washington has become unhappy
  4. San Francisco has become unhappy [espionage, not growth]
  5. Washington has become unhealthy
  6. Alabama has become unhealthy
I'd rather have fully-correct alerts, and honestly it doesn't matter why your city has become unhappy/unhealthy -- only that it has. Also, I'll be adding alerts for when the city becomes happy or healthy.
 
The Right Way

Use endGameTurn to loop through all cities and display alerts when they change from happy to unhappy or vice versa. This fixes both problems (unless you're playing a fixed-civ scenario and aren't player 0).

The downside to this solution is that you'll get all growth alerts first followed by all happy/unhappy alerts. You'll also get all happy alerts followed by all healthy alerts

  1. Washington has grown to size 6
  2. Alabama has grown to size 5
  3. Washington has become unhappy
  4. San Francisco has become unhappy [espionage, not growth]
  5. Washington has become unhealthy
  6. Alabama has become unhealthy
I'd rather have fully-correct alerts, and honestly it doesn't matter why your city has become unhappy/unhealthy -- only that it has. Also, I'll be adding alerts for when the city becomes happy or healthy.

Always follow the right way, my dear padawan... :D
 
I think I fixed the last little problem, but I'd been at it a long time today and needed a break. I'll pick it up tomorrow and should have it committed fairly soon.
 
Check out the latest alert goodness.

  • I think I finally fixed the gold trading alerts.
  • I added shrinkage (starvation) and actual growth (only did pending before).
I have essentially rewritten the entire Civ4lerts code from scratch at this point. I haven't done nearly as much work in MoreCiv4lerts, but that's next. :)
 
I added a new alert for when the occupation of a city will end next turn and once it's over. Occupation occurs when you capture a city and when the city revolts due to cultural pressure.

There's already an alert when your city revolts, and I figure it should be obvious when you've captured a city, so there are no alerts for the start of occupation.
 
:woohoo:Thanks EmperorFool, I was going to ask for this but you beat me to it. I have lost count of the number of times I completely forgot to go the city and whip it when it comes our of revolt after capture. Usually I notice this when the build I set in the queue is finished:hammer2:. I can't wait to try this out tonight.:assimilate:

BTW: I love the work you all did to make BUG possible. I think this is a must for anyone playing Civ. Thank-you to all involved in making such a fantastic addition.
 
3 ideas I'd like to see--2 are civ-lerts

1) A civ-lert for resources available to trade. If I have cities at the happy cap, a rival willing to trade away a happy resource is a big deal that I need to jump on immediately. But it sucks having to check the resources screen every turn.

2) An option to have goodie huts in day-glow pink or some other extremely conspicuous color. I have been known to miss seeing huts, especially ones in the jungle.

The final one may be pushing the limits of what a HOG/BUG mod should do, but it is technically within the rules:
3) A civ-lert for a civ that wants a tech of yours and is willing to trade less than his entire stack of gold for it--ie, he has more gold than he thinks the tech is worth.

This would allow you to sell the AI techs that he's close to finishing. You can use espionage to help you do this. You could theoretically also try to sell every AI every possible tech every turn to see if he offers less than his entire stack. Although that last option is theoretically possible and offers you a nice payoff when you sell, it would be a huge, huge pain. In fact, I never do this unless I have intel on what he's researching. Still, it is possible, so it should be fair game for a civ-lert in an unaltered gameplay mod.


So what do you guys think? Should I repost this somewhere else?

PS--I also really like the idea of having a civ-lert for "we have to much on our hands". Knowing somebody is on the warpath is huge.
 
1) A civ-lert for resources available to trade.

I've been meaning to add this for some time--just haven't gotten around to it. It's even in the Feature Request tracker. :)

2) An option to have goodie huts in day-glow pink or some other extremely conspicuous color.

Maybe something to add for BAT (graphics), but you might want to see if someone has already created a goody hut replacement and posted it in the download section.

3) A civ-lert for a civ that wants a tech of yours and is willing to trade less than his entire stack of gold for it--ie, he has more gold than he thinks the tech is worth.

On a related note, if I can get it to work I'd like to add an alert for when an AI changes its mind about some trade you've attempted. For example, you offer CoL for Calendar, but they deny you. Hit a button to save that trade and check its status each turn, likely while you search Calendar until they accept.

Unfortunately, it's pretty hard to hook into the Diplomacy window (though not impossible as I've found).

I also really like the idea of having a civ-lert for "we have to much on our hands".

Yes. Another one I'll add eventually is "You are now Mansa Musa's worst enemy." etc.
 
Top Bottom