For the last lesson we will concentrate on commands that will only run on Kingdoms. We wont be covering all of the commands as most are self explanatory. The ones I will write examples for are:
generate_random_counter
historic_event with accept/decline
Generate Random Counter
This command removes the limitations of the old RandomPercent condition. Now we can store a random number as long as we want, and check it as many times as we want. You should note that this is an event_counter, not a normal counter, so using it along with the EDB can create new problems.
Create two historic_events named RandomTrue and RandomTrue2 and then run this script:
All this does is pick a number between 1 and 100, and fire one event if the number is under 50 and a different event if the number is over 50. We can then check the event_counter any time we want since it is a stored value. This may not seem like such a great script at first glance but I have found it immensely useful. I use it in the 12TPY script for randomizing how long the winter is, and I also use it in the roving buildings script to determine where the building will go.Code:monitor_event FactionTurnEnd FactionIsLocal generate_random_counter RandomNumber 1 100 if I_EventCounter RandomNumber > 49 historic_event RandomTrue end_if if I_EventCounter RandomNumber < 50 historic_event RandomTrue2 end_if end_monitor
historic_event
This is by far the most useful of the Kingdoms additions as you can now easily give the player a yes/no choice. Before we had to do it with show_me scripts or live without it. However this is also the one that seems to confuse new scripters the most because of the way the counters work. A quick rundown of the process involved:
Call a historic_event and add the "true" keyword
The game will automatically add two new event_counters named after your event and set them to 0. if you look at some of my old stuff you will see an add_events command in there but I have discovered that you do not need to use that.
When the player clicks an option, one of the created event_counters gets set to 1
Check the event_counters for a change using the EventCounter event. If you want to detect Accept only then you only need to check one.
If the changed counter = 1 then run new commands.
IMPORTANT - SET THE COUNTER BACK TO 0 OR YOUR COMMANDS WILL RUN MORE THAN ONCE. This seems to screw a lot of people up.
We are going to call our historic event players_choice, and add some events for detecting when Accept or Decline is clicked. In your historic_events file add this:
Code:{PLAYERS_CHOICE_BODY}Click Accept or Decline {PLAYERS_CHOICE_TITLE}Player's Choice {ACCEPT_CLICKED_BODY}The Player clicked Accept {ACCEPT_CLICKED_TITLE}Accept Clicked {DECLINE_CLICKED_BODY}The Player clicked Decline {DECLINE_CLICKED_TITLE}Decline Clicked
A basic script looks like this:
Running this will give us the Accept/Decline screen. Now we have to detect what has been clicked.Code:monitor_event FactionTurnEnd FactionIsLocal historic_event players_choice true end_monitor
Your task is write a new script using both, or maybe to combine the two, accept/decline and generate_random_counter. Maybe you will ask the player if he wants some free units, and then give him units based on the random counter. Or maybe you have some other cool ideas. Since AL already gave out the diplomas this lesson is for rep. The better the script, the more rep I will give.Code:monitor_event EventCounter EventCounterType players_choice_accepted and I_EventCounter players_choice_accepted == 1 historic_event accept_clicked set_event_counter players_choice_accepted 0 end_monitor monitor_event EventCounter EventCounterType players_choice_declined and I_EventCounter players_choice_declined == 1 historic_event decline_clicked set_event_counter players_choice_declined 0 end_monitor








)









