Jump to content

Trigger Lesson


akuenzi

Recommended Posts

I appeal to the smart people on this board to help me extend my map play-time.  At some point, any given map usually has most AI players broke and out of money.  I'm not very good at this, and even I can bury many of the AI players.  So, what I would like to do is see if there are ways to get AI players started later in the game, so the game action can be extended.  One way I thought of doing this was leaving certain AI 'dormant' at the beginning of the game.  By 'dormant,' I mean they have NO cash and NO company.  Essentially, they sit there doing nothing, except scratching themselves and watching all their other AI friends get buried by the human player.  :)  However, by giving them an injection of cash at a certain point in time, they could 'wake up' and hopefully then start a company.
 
I set up an event to do this.  It's supposed to give $100,000 to one of the 'dormant' computer players at a certain point in time, but it's not working.  Here's what my trigger says:
 
One time only event.
Testing each year, at START of year.
Test against multiple computer players.

Trigger:
GameYearMonth=188101 AND PlayerID=2

Effects:
PlayerCash + 100,000

 
So... in January of 1881, the intent is to give one of the computer players (whoever happens to be in ID slot # 2) 100 grand.  However, it's not working.  When I try playing the map, the poor computer guys are just as penniless after January 1881 as before.  Is my syntax incorrect?  I also tried a different trigger, GameYearsElapsedSinceStart, but it also didn't work.  How would you guys do this?
 
Maybe the computer player is just an ungrateful so-and-so and is telling me he doesn't want the help.

Link to comment
Share on other sites

My memory is not so good anymore;   But, when I run into problems like that I normally resort to the used of a variable and two or more events. 

 

Let the first event set a variable.    Player variable 1 = 1 

and the second event will be the date timer.  When the date trigger fires true and if player 1 =1)   Then it  gives 100grand to player #2  .

Link to comment
Share on other sites

Write a status report event with:
  always trigger: playerid
  frequency: status report
  message text: (trigger) (player) (company)

 

You will see that all the player IDs are zero, but that they are still listed in order.

 

Actually, for slot #2, that is the first AI.  Just make it a 1-time event on computer players with a trigger of  GameYearMonth=188101  and give him some cash. Since its 1-time, it will only do the first AI.

(I had this same situation with James Hill in Heartland Heaven to get him to start a company late in the game)

Link to comment
Share on other sites

I think that you can only see your own status report, so you will see only your own player ID (probably player ID 0). That doesn't mean that the AI players also have ID=0, only that you don't see their status reports.

 

EDIT: After testing, it does appear that AI "players" all evaluate to PlayerId = 0. That makes the PlayerID variable kind of useless.

Link to comment
Share on other sites

If you want to see a message or newspaper or status when an event fires for a player other than yourself, then you need to trick it out to assign a cascading event code to a game variable (or borrowed territory variable) that then triggers another event that all players can see. Example:

 

Testing multiple players...

Trigger 1: (PlayerId+1) * (PlayerId = 2) * (GameYear = 1881)

Test at start of year

Effects 1: Set GameVariable1 equal to trigger;  Add $100000 to player cash

 

Only once:

Trigger 2: GameVariable1

Message 2: "Player (TRIGGER) printed $100,000 and got away with it!"

Effects 2: Set GameVariable1 to -1; Add 1 to GameVariable1

 

Design notes:

 

1) Player IDs start at zero, but zero can't trigger an event, and humans tend to think of sequences starting at 1 anyway. Therefore, trigger1 adds the +1 to PlayerId before multiplying by the result of the boolean expression.

 

2) The boolean expression evaluates to zero or one. A zero failes the trigger, so only when PlayerID is 2 does it multiply by 1.

 

3) You can't set a variable to zero because zero looks like a non-effect. Therefore, set the var to -1 and then add 1 (adds come after sets, so this is possible).

Link to comment
Share on other sites

I take back what I said about Player IDs. After poking and prodding tonight, I see that PlayerId for AI "players" does indeed look like zero for each and every one of the buggers! That means that it is not possible to do a static comparison between PlayerId and a fixed number :(

 

So, you need a differently crafted trigger. Try testing each player's cash (or NetWorth) for some minimum, and combine that with a test of G1:

 

*** EVENT A ***

Testing each year, at END of year

Trigger:   

    Multiple players, computer players only

    (PlayerCash = 0) and (GameVariable1 = 0)

Effects

    Player Cash add +100000

    Set GameVariable1 to 1

 

*** EVENT B ***

Testing each year, at START of year

Trigger:

   GameVariable1

Effects:

    Set GameVariable1 to -1

    Add to GameVariable1 +1

 

Event 'A' finds the "first" computer player having insufficient cash and gives him some, setting G1 in the process so that no more players are gifted in the same year.

 

Event 'B' resets G1 to zero (it has to be roundabout because set-to-zero turns into a non-effect).

 

If you don't want computer players getting gifts simply because they've spent all their money, then you can test PlayerNetWorth instead of PlayerCash. You can also play around with event 'B' to reset G1 in a later year so that the gifts are staggered.

 

BTW, if you do a lot of event programming and need more game variables, you can "borrow" territory variables for some kinds of events that have nothing to do with territories.

Link to comment
Share on other sites

I got the answer you need. It will take one Game Variable and one Player Variable and 4 events. Say we arrange GameVariable1 and PlayerVariable1 for this task.

You need to place these events as ordered below:

 

event #1:

test against multiple players(include human and computer) 

check at the end of each month

trigger:

GameVariable1<1 and PlayerVariable1<1 and GameYearMonth>=188011 and GameYearMonth<188101

effect:

Set GameVariable1 to 100, Set PlayerVariable1 to 100

 

event #2:

test against multiple players(include human and computer) 

check at the end of each month

trigger:

GameVariable1>1

effect:

Set GameVariable1 to -99

 

event #3:

test against multiple players(include human and computer) 

check at the end of each month

trigger:

GameVariable1<1 and PlayerVariable1<1 GameYearMonth=188101

effect:

Set GameVariable1 to 100, Add PlayerCash +1,000,000

 

event #4:

test against multiple players(include human and computer) 

check at the end of each month

trigger:

GameVariable1>1

effect:

Set GameVariable1 to -99

 

 

Notice:

Yes, event #2 and event #4 are the same, they are not typo.

With these, by the end of Jan 1881, $1,000K will be added to #2 player.

You can modify this task by changing the date of #1 and #3 event with the formula: StartingYearMonth=TargetYearMonth-PlayerIdMonths. In this case: 188011=188101-2.

If you want to add cash to #5 player in 190508, 190508-5=190503, which means the starting date in the #1 event should be 190503.

Link to comment
Share on other sites

Seems we started with a simple event and grew it. 

 

Outofmage's solution made me think, when a long solution is possible we should be able to compact it and still have it work correctly.

 

 Things we know:

 

While the number of events are unlimited, There are only 12 variables available to us.   Each can be recycled a number of times by changing the numbers.

 

I'm just stingy with my use of variables having run out too many times.  

 

Steve Largent made a post a long time ago on methods he uses to expand the use of variables.

 

I wish I could find it now. 

Link to comment
Share on other sites

Thanks guys!  I sure wish this was as simple as the syntax I used... according to the manual, and my understanding of what 'PlayerID' means, it really SHOULD have worked.  But thanks for proposing the workarounds to still get the same thing accomplished.  Jeff -- is this something that could be fixed by modding the exe file?  :)

Link to comment
Share on other sites

Okay, I think I found another way to do it that doesn't require the use of variables:
 
One time only event.
Testing each year, at START of year.
Test against multiple computer players.

Trigger:
GameYearsElapsedSinceStart=1 AND PlayerCash=0
 
Effects:
PlayerCash + 100,000

 

This seemed to accomplish what I was after.  After one year of game play, it gave $100K to the first computer player in line.  In my map, I set up four triggers identical to the above, each one year further out.  In giving it a test, each year that went by meant that the next computer player in line would receive $100K at the beginning of the year.  Seems like a good way to make a computer player 'dormant' until he is needed later in the game at a desired time.  I suppose the other trigger I used would still have worked fine (GameYearMonth=188001), but the one above will work now regardless of what is chosen for the starting date.

 

Sure would be nice if the PlayerID feature worked as the manual said it should!  Does anyone know if this doesn't work only with respect to PlayerCash?  What if we wanted to give a different effect to a specific computer player, such as access rights to a particular territory?

Link to comment
Share on other sites

I just got a better solution. It still takes 2 variable but takes 3 events and won't be limited by the starting date of the game. It's easier to understand and can replace the function of playerId too.

#1 event

check at the end of each month

trigger:

GameYearMonth=188101

effect:

Set GameVariable1 to 2

 

#2 event

check against all players

check at the end of each month

trigger:

GameVariable1>0 and PlayerVariable1=0 and GameYearMonth=188101

effect:

Add GameVariable1 -1 

Set PlayerVariable1=100

 

#3 event

check against all players

check at the end of each month

trigger:

GameVariable1=0 and PlayerVairable1=0 and GameYearMonth=188101

effect:

Add GameVariable1 -1

[effect you want to apply to this player]

 

Here is some explanation of my design. GV acts as a counter. Every time an effect is applied to a player, GV will count down once, until you hit the target player to apply some "true effect" other than just set Player Variable away from 0.

As counter can be set to any number, you can remove the first event so you leave GV as default 0, and in #3 event's trigger change GameVariable1=0 to GameVariable1 =-2. It works the same.

 

However, it can't set access rights to a particular territory for a company controlled by an AI. You can only set this to a particular CompanyId or human player's company or all the computers companies. PlayerId can only effect player cash, player variables,if this player controlled by human, player character and deactive player.

Link to comment
Share on other sites

I got the answer you need. It will take one Game Variable and one Player Variable and 4 events...

 

 

Say we arrange GameVariable1 and PlayerVariable1 for this task.

You need to place these events as ordered below:

 

event #1:

test against multiple players(include human and computer) 

check at the end of each month

trigger:

GameVariable1<1 and PlayerVariable1<1 and GameYearMonth>=188011 and GameYearMonth<188101

effect:

Set GameVariable1 to 100, Set PlayerVariable1 to 100

 

event #2:

test against multiple players(include human and computer) 

check at the end of each month

trigger:

GameVariable1>1

effect:

Set GameVariable1 to -99

 

event #3:

test against multiple players(include human and computer) 

check at the end of each month

trigger:

GameVariable1<1 and PlayerVariable1<1 GameYearMonth=188101

effect:

Set GameVariable1 to 100, Add PlayerCash +1,000,000

 

event #4:

test against multiple players(include human and computer) 

check at the end of each month

trigger:

GameVariable1>1

effect:

Set GameVariable1 to -99

 

 

Notice:

Yes, event #2 and event #4 are the same, they are not typo.

With these, by the end of Jan 1881, $1,000K will be added to #2 player.

You can modify this task by changing the date of #1 and #3 event with the formula: StartingYearMonth=TargetYearMonth-PlayerIdMonths. In this case: 188011=188101-2.

If you want to add cash to #5 player in 190508, 190508-5=190503, which means the starting date in the #1 event should be 190503.

 

 

Oh dear, where do I begin? This problem does not need 4 events, but that's not the most important thing to say.

 

You have an event (#2) for multiple players, but it only involves a game var. It will test once per player even though only once is needed.

 

But wait, don't your triggers act on every player, even the human? I think your events give the human player cash as well.

Link to comment
Share on other sites

While the number of events are unlimited, There are only 12 variables available to us.

That's not quite so. There are 4 variables per territory plus 4 per player plus 4 per company plus 4 per game. Starting just with the 31 territories, you have 124 variables to use. With 12 players you could have 48 more. With 12 companies 48 more.

 

Thus, you could easily have 224 variables to play with, and you could probably manufacture a few more by creating dummy players and companies.

 

In my US History scenario, I didn't monkey with players or companies, but I did monkey with territories. Only 2 of each territory's variables were used for the territory itself. The 3rd & 4th were hijacked for all manner of GameVariable purposes, giving me limited use of 62 extra game variables.

 

I just had to be careful about which I used for what. I had to make sure that if I used a T variable in a trigger, then the effects had to belong to that territory or else not be T-specific at all (most gave a value to a real game var that would trigger the real effect in a trailing event). I also had to be sure that I never needed values from two different territories at the same time.

 

Keeping them all straight required a multi-tab spread sheet, and the events tab listed every var used in each event.

Link to comment
Share on other sites

Thanks guys!  I sure wish this was as simple as the syntax I used... according to the manual, and my understanding of what 'PlayerID' means, it really SHOULD have worked.  But thanks for proposing the workarounds to still get the same thing accomplished.  Jeff -- is this something that could be fixed by modding the exe file?  :)

With EXE file modding, I only know how to change data. I can change some dates and engine stats and even manager bonuses, but I can't touch logic.

 

The lang file lets us change labels and other in-game text, but that's even further from something like playerID.

 

Remember that the game attempted to be multiplayer too, so player IDs will be all tangled up in that. I'd be afraid to tinker with it even if I had access to the original source code  :o

Link to comment
Share on other sites

Okay, I think I found another way to do it that doesn't require the use of variables:

 

One time only event.

Testing each year, at START of year.

Test against multiple computer players.

Trigger:

GameYearsElapsedSinceStart=1 AND PlayerCash=0

 

Effects:

PlayerCash +100,000

 

This seemed to accomplish what I was after.  After one year of game play, it gave $100K to the first computer player in line.  In my map, I set up four triggers identical to the above, each one year further out.  In giving it a test, each year that went by meant that the next computer player in line would receive $100K at the beginning of the year.  Seems like a good way to make a computer player 'dormant' until he is needed later in the game at a desired time.  I suppose the other trigger I used would still have worked fine (GameYearMonth=188001), but the one above will work now regardless of what is chosen for the starting date.

 

Sure would be nice if the PlayerID feature worked as the manual said it should!  Does anyone know if this doesn't work only with respect to PlayerCash?  What if we wanted to give a different effect to a specific computer player, such as access rights to a particular territory?

Don't be afraid of variables. If you ever decide to change an event later, it's better to have just one trigger to rewrite rather than four.

 

PlayerID seems to fail in an event's trigger, so the event's effects have nothing to do with it. It is probably a bug in the game.

 

You can't assign territory access rights to a player. Access rights are assigned to companies.

Link to comment
Share on other sites

Wow, this thread has exploded overnight into a nightmare that probably has nothing much to do with the original question and which I certainly have no interest in wading through to see whether I have a response.

 

What was that question now anyhow?

 

Was it how do I get $$ to the first AI? Answered above in my first post, done easily. PlayerID not needed

 

Or was it how do I get $$ to all AIs? Easy, just test how much they have and give them some. PlayerID not needed.

 

Or perhaps it was why does playerID=2 take a value of zero? Because incorrect programming perhaps.

 ----------------------------------------------------------------

 I'll start a new thread on my observations of playerID because I wouldn't want it to get lost in all this.

 

Again, without having waded through all of the above, so excuse me if I repeat something already said.

 

 

Link to comment
Share on other sites

loco, the information of this thread is indeed very much for someone to comprehend over one night. I can sum it up our solutions for you.

 

The OP's question is how to give #2 player some cash at a particular time not get the money he has. 

 

I solve this problem in post #12 and #16 introducing two methods. They are all working, I've tested them.

 

In post #11, jeff introduced a method to go around the player Id issue, he just give some money to the player who is running low in cash not directly to a particular player id. Because akuenzi's intention is to give this computer some money so it can come back to the game. Akuenzi simply does not want a dead AI.

 

In post #15, akuenzi adopt jeff's solution and this case is closed.

But in this post, he also mentioned how to apply effects to a player with certain Id, which is solved in #16 by me.

 

Other things are also mentioned such as assign territory access to a company, not a player; replace Game Variables with Territory Variables to expand game-scale variables; player Id bug seems not fixable by modding EXE file and so forth.

 

Jeff has lots of posts explaining his thought process trying to solve the original problem, but with no direct solution but confirm the Player Id does not work.

 

Of course my final solution in #16 is not perfect, it can be improved with some adjustment.

Link to comment
Share on other sites

 This problem does not need 4 events

Jeff,  I admit 4 events are little too much. But in post #16, I have a better version which can compact into 2 events. 

 

 

But wait, don't your triggers act on every player, even the human? I think your events give the human player cash as well. 

Yes, if the human player happens to be #2 player, it will give the human player cash. I try to solve this problem with more universally usable solution. This method not only answer the OP's question, but can actually replace the function of playerId, including human player's.

 

This method can be used in both single and multi player games, it is able to apply any effect to any player(given his playerId) at any time. In other words, we have the technique to replace playerId with one GV and one PV and 2 events(without init event).

 

Thank you for pointing out the flaws in my solution and all these efforts in confirming that the player Id does not work. 

Link to comment
Share on other sites

Thanks outofmage, I needed to be attacked over that rude post.

 

 

 

loco, the information of this thread is indeed very much for someone to comprehend over one night. I can sum it up our solutions for you.

 

lol you misunderstand me outofmage. My point is that I can't be bothered. If I cared, I could comprehend it easily, Everything after my post #7, if you bothered to read it, except for the op's post #15, is just a bunch of convoluted digression. I will say more about post # 15 below.

 

The OP's question is how to give #2 player some cash at a particular time not get the money he has. 

 

Have you such a poor attack on me that you attempt to quibble over whether the slider moves to the left or the right? Nowhere in my posts did I say anything about getting the money he has. I will give you the benefit of the doubt and assume this is an ESL issue and not another careless oversight. In any case I'm glad you agree that was the question, answered in my post #7 (if you bothered to read it).

 

I solve this problem in post #12 and #16 introducing two methods. They are all working, I've tested them.

 

Good, not exactly elegant, but I'm glad you're happy with them. I notice #16 was posted after you admit that the case was already closed. I wonder what the significance of that is. Admit it, digression is more important that closure (lol).

 

In post #11, jeff introduced a method to go around the player Id issue, he just give some money to the player who is running low in cash not directly to a particular player id. Because akuenzi's intention is to give this computer some money so it can come back to the game. Akuenzi simply does not want a dead AI.

 

Since I see also a proliferation of events in Jeff's posts, I also assume a lack of elegance or dealing with the wrong question, just like with yours (no offense to either of you intended).  For example, it turned out that what akuenzi actually wanted was to give each AI successively at one year intervals the money to be able to start companies, not as you state above at all.

 

In post #15, akuenzi adopt jeff's solution and this case is closed.

But in this post, he also mentioned how to apply effects to a player with certain Id, which is solved in #16 by me.

 

I think akuenzi adopted his own solution here. Lets give him some credit. Akuenzi's post #15 of unfortunately addresses a different matter altogether than his opening post. Also, it is possible for a player that has already started a company to have zero cash, so it would be better to add a flag on each player that has been given money, if this is the method he decides to use. Not the way I would do it. I would have 1 event assigning successive playervariable1's and one annual event allocating cash with a trigger something like (current year-start year+2)=PV1. Extremely simple solution for extremely simple question, if properly asked and answered.

 

Other things are also mentioned such as assign territory access to a company, not a player; replace Game Variables with Territory Variables to expand game-scale variables; player Id bug seems not fixable by modding EXE file and so forth.

 

That's part of my point, really. Too much digression

 

Jeff has lots of posts explaining his thought process trying to solve the original problem, but with no direct solution but confirm the Player Id does not work.

 

I'm glad Jeff confirmed that and have altered a previous post to acknowledge it.

 

Of course my final solution in #16 is not perfect, it can be improved with some adjustment.

 

Not perfect? That is unacceptable. See, even you're not happy with your convoluted solution.

 

-------------------------------------------------------------------

------------------------------------------------------------------

 

OK, that was fun. Everything above is rhetorical. No rebuttals are necessary. Let's hope not a lot of crap follows this post.

Link to comment
Share on other sites

Jeff,  My statement of: 

"While the number of events are unlimited, There are only 12 variables available to us.   Each can be recycled a number of times by changing the numbers."

 

In my experience Four seem to be somewhat limited in their use. They don't always function correctly or they cause errors. 

Yet with care even the 4 erratic variables work some times and with or for some things. 

The other 12 can be recycled many times to give you many variations for each one of the 12 (16) the game offers you. 

    

And Jeff you are right there are a number of flaws in the game engine.   I have tried to exploit some of the flaws into my maps.  

 

Example:  can you place one building on top of another?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...