Can't figure out how to do it

Tips and Tricks on Events, Economy, etc.
User avatar
BobTheBull
Hobo
Posts: 26
Joined: Wed Feb 17, 2010 5:06 pm

Can't figure out how to do it Unread post

I am having a problem using events. I am working on the Germany scenario to change the focus from avg freight speed to freight loads hauled. I think this is more appropriate historically as at the time there was a need to both unify Germany and build up German industry. In order to accomplish this you would want to maximize the amount of freight hauled especially in terms of manufacturing chains and moving finished product to market. Besides, it give me the kind of scenario I like to play.

So, freight loads hauled will be a key factor in achieving goals and getting rewards. There is no variable for freight hauled but it can be calculated by YTD loads hauled - YTD mail - YTD passengers - YTD troops. I can set up an event to do this for the human player without any trouble. But, I want to keep up with freight hauled for each company. No matter how I try I can not get an event to do this for AI companies with any accuracy. I thought the appropriate conditions would be:

Force test against companies and
There is a company with ID and
Company ID = X

with effects: Set cvX=YTD loads; cvX-YTD mail loads, etc. These effects do work when used for human player only.

Is there anyway to get this to work for each company? Does the program really keep up with the variables used for AI companies; it appears to, but this could be deceiving.

Secondly, am I trying to do something counterproductive? In studying the events for other scenarios it seems they mostly only deal with the human player. Am I going too far to try to apply the goals and bonuses equally to the human and AI players?

Not sure if I have made myself really clear here, but that's probably because I am not at all clear. Any help will be appreciated.

When I use this the event never triggers. I can use some conditions which do trigger but obviously give bogus results.
User avatar
nedfumpkin
CEO
Posts: 2163
Joined: Sat Feb 16, 2008 9:16 pm
Location: Hamilton - Canada

Re: Can't figure out how to do it Unread post

YTD is year to date, LTD is lifetime to date. Make sure you are doing it right. Make your event trigger at the end of the year unless you want the effect to happen when the objective is achieved, then make it at the end of the month.

Make sure you are testing against all companies, and your condition is company related. If it is to a territory, make sure you test against the territory. You don't need ..."There is a company with ID" unless your AI companies aren't in business when the scenario starts.

Also make sure that the effects are applied to whoever is true.
User avatar
Blackhawk
CEO
Posts: 1112
Joined: Thu May 21, 2009 2:34 pm

Re: Can't figure out how to do it Unread post

BobTheBull wrote:Secondly, am I trying to do something counterproductive? In studying the events for other scenarios it seems they mostly only deal with the human player. Am I going too far to try to apply the goals and bonuses equally to the human and AI players?
This probably seems rarer since many scenarios don't include an AI player. And those that do, the AI is often artificially "kept alive" giving them extra cash bonuses, increased profits, or maybe giving a bonus when they connect to a city, which it's expected they'll connect to at a certain time. Using a transport trigger to give them extra help may be possible, but unless you test the AI out, you might not know what a feasible bonus for the AI is, and if the AI will even expand enough to transport a significant number of loads. (Also often it doesn't seem like the AI isn't the best with freight, and tries to rely on express cargo for the bulk of its profits)

Working with the 1.06 editor I'd do:
Ex. Event #1 sets CV1 = YTD Company loads hauled, CV1 - YTD Company mail, CV1 - YTD company passengers, CV1 - YTD troops.
Event #2 if CV2 > X number of freight you want the trigger to be SET EFFECT ???

I might try for the event:
Force test against companies
Game Year you want to start checking freight.

Although if you want company specific events that tailor just to a specific company, then you can throw in the "Company ID = " test as well.

If you want to see if the event is working for an AI player, after the event should have triggered, go into the editor and then into the stock market window, and hit shift (or maybe it's control) over the AI player's portrait and you will switch to that player's company. Then look to see if the effect took place. (ex. give the company 5000k cash and if you see the cash is all there you know it works for the company and you can revise the effect to what you actually want it to be). I guess another way to do it might be to create an event for CV1 to display in the ledger, then check the ledgers of each company and seeing if the numbers are different.
User avatar
Wolverine@MSU
CEO
Posts: 1166
Joined: Fri Nov 10, 2006 2:14 pm
Location: East Lansing, MI

Re: Can't figure out how to do it Unread post

Blackhawk wrote:If you want to see if the event is working for an AI player, after the event should have triggered, go into the editor and then into the stock market window, and hit shift (or maybe it's control) over the AI player's portrait and you will switch to that player's company. Then look to see if the effect took place. (ex. give the company 5000k cash and if you see the cash is all there you know it works for the company and you can revise the effect to what you actually want it to be). I guess another way to do it might be to create an event for CV1 to display in the ledger, then check the ledgers of each company and seeing if the numbers are different.
Or easier yet, just have the event display a dialog saying the event has triggered and have it display the result (i.e. Company Cash). Then you don't have to go digging through the Ledger.
User avatar
BobTheBull
Hobo
Posts: 26
Joined: Wed Feb 17, 2010 5:06 pm

Re: Can't figure out how to do it Unread post

Thanks for the replies, folks.

First to Ned, yeah, yeah, and yeah. Did all that. Acutally I am not a noob at this and this is the first time I have not been able to construct events to do what I wanted. BTW it is always good practice to include There is a company with ID to avoid unpredictable results should the company not exist, as is the case at the beginning of the scenario, or if a company is sold. bought out or disbanded.

To Blackhawk: How you said it is exactly how I did it. That is the obvious way to do this. Unfortunately it does not work; see below.

To Wolvy: That is exactly what I do whenever I am testing events, put in a dialog box showing what your are testing. In this case, I test and end of month so I don't have to wait for a full year to roll by to see if it works. In this case it shows Company Name, CV1, and YTD Loads.

Here is what happens. When set up as Blackhawk shows it, the event is processed every month but never triggers with CID=1. Trying values from 0 to 4, it does trigger when 4 is used and appears to work correctly. When 1, 2 or 3 are used it does not trigger. Using the same conditions, Force test against company and There is company with ID it does not trigger. When the Company ID = is taken out it triggers every time, giving various results depending on what else is set up. When tested against humcan company only is used it also triggers and gives the right result. If the effects section is set to apply to all companies, CV1 for each company is set to a value and appears to be at least partly correct. It is hard to tell with AI companies, but it seems to be counting total loads correctly but not deducting the express.

Of course, without being able to use Company ID I don't know how to use those other figures, anyway. BTW, those AI guys are hauling over 40 loads a year each, to my ~15, although I have done nothing to increase my freight, this is just a test scenario. So I probably don't want to include the AI's in my freight counts and goals, but this has peaked my interest. What is wrong with the CompanyID test; I don't remember seeing any problem with it before, though I don't really remember that I used it in one of my own events. Any ideas, guys? I am going to do some more testing on this to see what I can uncover.
User avatar
BobTheBull
Hobo
Posts: 26
Joined: Wed Feb 17, 2010 5:06 pm

Re: Can't figure out how to do it Unread post

Heilige scheiss, Batman! Can it be this simple?

Found this out: Using conditions of force test and there is with companies, the effects will be applied to each company as they are started up (they exist). My first testing I didn't go long enough to let other companies get started. If you CV1, then, as stated before, that variable for each company and the math does seem to be correct; that is, the express is correctly deducted from total loads to get freight loads hauled, within the confines of the game engines method of calculation. If you have a train with 3.7 loads of freight it will show up as 3 loads. If that train then carries 1.3 loads the total will be 5, or something like that. This is with only one train running. With multiple it seems to keep up with fractional loads overall in some way. Same applies to express, so total freight and loads will not be the same as the number of cars delivered.

This also confirms what I read somewhere else; there CV1-4 for each company in the game. This implies there is one GV1-4 per game, but # of companies, #of players and # of territories X 4 variables in the game. But, without being to address a specific company with CompanyID = 1, 2, 3, etc. you cannot access all these variables. BTW, the dialog for the freight calculation dialog always displays the last created company in this scenario, company 3, and no others.

But guess what? Seeing that CID = 4 did trigger human company, I used 5 and 6 and it did correctly trigger (AI) companies 2 & 3. Changing the events some, I now have 4 events. The first calculates freight loads hauled for each company, using force test and there is company conditions only, correctly and displays a dialog: Freight loads calculated! Events C1-C3 use force test, there is company and CID = 4-6, respectively. There are no effects, only a dialog showing company name, CV1 for that company (freight hauled) and YTD loads for that company. Running the game the events all trigger as they should and display the correct information for each company; so far it always displays the dialogs from highest to lowest, ie C3, C2, C1. I am predicting that with 4 companies you will use CID5-8; will test this out later. At any rate, even though it seems to be wrong, it does do what I wanted to do, and allows a great deal more capability to do calculations and other things across companies.

Will keep playing and report results.
User avatar
Blackhawk
CEO
Posts: 1112
Joined: Thu May 21, 2009 2:34 pm

Re: Can't figure out how to do it Unread post

Are the company ID's actually ID#1 = human, ID2 = AI, CID#3 = AI2? Or is it possible that you've started a company and then liquidated the company and started another new company so the CID's are off sequence?
User avatar
BobTheBull
Hobo
Posts: 26
Joined: Wed Feb 17, 2010 5:06 pm

Re: Can't figure out how to do it Unread post

Nope. they are all new start up companies, one human and two AI; no liquidations or buyouts, it's only about three years into the game. They are listed in the debugging screen in the order they were started, from top to bottom. So I assume human is #1, first AI is #2, etc.
User avatar
Blackhawk
CEO
Posts: 1112
Joined: Thu May 21, 2009 2:34 pm

Re: Can't figure out how to do it Unread post

If you click on the View Companies button (while the editor is open) before the company name it should give the company ID.
Attachments
CID.jpg
Last edited by Blackhawk on Tue Aug 24, 2010 6:40 pm, edited 2 times in total.
User avatar
Blackhawk
CEO
Posts: 1112
Joined: Thu May 21, 2009 2:34 pm

Re: Can't figure out how to do it Unread post

I didn't go in depth to the calculations of freight only, but a quick test with these variables seemed to be company specific to me:

Status display: (just triggered with a force test against all companies)
CID
YTD Loads Hauled
CV1 (which should also display the YTD Loads hauled for the company)

Event #1:
Force test against companies
CID = 2
Current Game year > 1900
Effect = Set CV1 = YTD company loads hauled

Event #2:
Force test against companies
CID = 3
Current Game year > 1900
Effect = Set CV1 = YTD company loads hauled


And these worked fine for me. Company 2 and 3 were AI players. Company 1 didn't exist, and company 4 was human.
User avatar
nedfumpkin
CEO
Posts: 2163
Joined: Sat Feb 16, 2008 9:16 pm
Location: Hamilton - Canada

Re: Can't figure out how to do it Unread post

Compaines are numbered in the order they are created. If a company is started then liquidated in the editor, that number won't be used again.
User avatar
BobTheBull
Hobo
Posts: 26
Joined: Wed Feb 17, 2010 5:06 pm

Re: Can't figure out how to do it Unread post

Yep. Forgot that little feature, Blackhawk. Would have saved a lot of trouble had I remembered it. When checked in edit mode, the human company is #4, and the others are numbered after that according to start time. Just to be sure, I loaded the stock Germany map and it did the same. I loaded several original scenarios and they all started with CID 1, as expected.

So apparently there is something about the Germany map that we don't know which causes this. Anybody want to load up this map and run it long enough to get several companies going? Is it just me.
User avatar
Blackhawk
CEO
Posts: 1112
Joined: Thu May 21, 2009 2:34 pm

Re: Can't figure out how to do it Unread post

I loaded up that map and the companies do indeed start with CID# 4. Guess the developers created companies in the editor and then deleted them before releasing the final product.
User avatar
BobTheBull
Hobo
Posts: 26
Joined: Wed Feb 17, 2010 5:06 pm

Re: Can't figure out how to do it Unread post

Mystery solved. Like I said, if I had remembered that feature of the editor it would saved all that grief.

Like I said, i'm not a noob at this, and I did know exactly how to do it. I just made some wrong assumptions and never considered they could be wrong. It is good practice in programming (this is not exactly programming, but similar) to initialize all variables before you use them, test for existence of things to be used, etc. And then when it doesn't work, first be sure all your vars are what you think they are and all objects are as well before you decide there is something wrong with your code. Now if only I could say this is the first time I slammed my head against a wall repeatedly because I overlooked the simple and obvious . . . .
User avatar
Hawk
The Big Dawg
Posts: 6504
Joined: Fri Nov 10, 2006 10:28 am
Location: North Georgia - USA

Re: Can't figure out how to do it Unread post

BobTheBull wrote:Now if only I could say this is the first time I slammed my head against a wall repeatedly because I overlooked the simple and obvious . . . .
I know the feeling. ^**lylgh
Hawk
europegrad
Hobo
Posts: 11
Joined: Fri Aug 27, 2010 12:34 pm

Re: Can't figure out how to do it Unread post

I am going to post my doubt here as to avoid creating a similar thread. I am writing a scenario on 1.06 patch. I want a condition to be checked every month, but the effects to apply only once per company throughout the game (e.g., even if the condition is satisfied many months, the bonus will be given just once per company).

I tried to use the "apply effects only once per event", but apparently it didn't work out. Anyone has a clue about what, exactly, does this checked option do? Of course, I left the "one-time event" unchecked.
User avatar
brunom
Dispatcher
Posts: 343
Joined: Sat Mar 20, 2010 7:37 pm
Location: Lisbon, Portugal

Re: Can't figure out how to do it Unread post

Hi

My first guess is that the event isn't being checked against companies - that's usually why the effects don't apply.

Do you have "check against companies - always true" as a condition? You need this, or something else that "calls" a specific company to context - like "company ID = ... ".

Effects that apply to territories, companies or players only happen correctly if the appropriate "subject" was called for in the conditions.


This is a typical problem and the first thing that comes to mind. I can only offer more help with more info.

B
europegrad
Hobo
Posts: 11
Joined: Fri Aug 27, 2010 12:34 pm

Re: Can't figure out how to do it Unread post

This is what I want to do, exactly: give each company (AI/Bonus) a bonus when they reach certain thresholds of cities connects. But I want it to be accessible for every companies, meaning if there are 4 companies, each one will get $ 520.000 when they connect their 3rd city. If I a select "One-time only event", only the first company to link 3 cities will get the bonus.

So this is my event

CONDITION
Company total cities connected = 3
Test against all companies

EFFECTS
Company cash + 520.000
* apply effects only once per event.

What I don't understand is the meaning of "Apply effects only once per event". I thought it would mean: for each company, effects (extra cash) will kick in only once. But as it is, after I link 3 cities I get the 520.000 bonus, but then I keep getting the bonus for track laying or building maintenance posts until I connect a 4th city (rendering the condition false).

Moreover, would you mind explaining what is the purpose of the ALWAYS TRUE condition rather than set variables to given values or imposing regular events (like cash handouts)?
User avatar
Blackhawk
CEO
Posts: 1112
Joined: Thu May 21, 2009 2:34 pm

Re: Can't figure out how to do it Unread post

I'm not entirely sure what the "apply effects only once per effect" does as it's been awhile since I've actually written events. You could probably use a variable here to get this bonus only once.

example:
Add the condition:
CV1 = 0

Add the effect:
CV1 = 1

Then this company should no longer satisfy the conditions anymore and shouldn't get the bonus.
User avatar
brunom
Dispatcher
Posts: 343
Joined: Sat Mar 20, 2010 7:37 pm
Location: Lisbon, Portugal

Re: Can't figure out how to do it Unread post

Ok, so now I get what you need.. here's how I'd go about:

- Change the "total cities connected = 3" to "total cities connected => 3" (if a player pauses game when he has 2 cities, connects to 2 other, and then unpauses, the event wouldn't trigger anymore)
- Remove the "Test against all companies", replacing it with "Company ID = 1"
- Add "Once-only event"

only EFFECT:
company cash +520,000
"apply to companies to which the condition is true"

That's done! (for one company)
Then copy the event and change the "ID = 1" to "ID = 2", "=3", "=4", etc..

Byt the way, like Blackhawk, I never fully understood where the "apply effects only once" makes sense..

B
Post Reply