Page 1 of 2 12 LastLast
Results 1 to 20 of 32

Thread: Lesson 5, Finally

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    GrnEyedDvl's Avatar Liberalism is a Socially Transmitted Disease
    Artifex Technical Staff

    Join Date
    Jan 2007
    Location
    Denver CO
    Posts
    23,851
    Blog Entries
    10

    Default Lesson 5, Finally

    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:

    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
    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.



    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:

    Code:
    monitor_event FactionTurnEnd FactionIsLocal
     historic_event players_choice true
    end_monitor
    Running this will give us the Accept/Decline screen. Now we have to detect what has been clicked.
    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
    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.

  2. #2
    Augustus Lucifer's Avatar Life = Like a beanstalk
    Patrician Citizen

    Join Date
    Aug 2006
    Location
    Mote of Dust
    Posts
    10,725

    Default Re: Lesson 5, Finally

    Try and be creative, you can create entire script systems just using those two commands and a couple others for generated effect. Here's a quick example I gave to Swagger the other day when he asked about something(not tested, just wrote it up on the way out the door):
    Code:
    declare_counter judea_turmoil_timer
    declare_counter judea_turmoil_mission
    
    set_counter judea_turmoil_timer 0
    set_counter judea_turmoil_mission 0
    
    ;Trigger event to add turmoil to Judea
    monitor_event CharacterTurnEndInSettlement CharacterIsLocal
        and AgentType = spy
        and PopulationOwnReligion > 50
        and InEnemyLands
        and SettlementName Judea
        and Attribute subterfuge > 0
        and I_CompareCounter judea_turmoil_timer == 0
    
    if I_LocalFaction england
      historic_event add_turmoil_judea true factions { england, }
    end_if
      ;;etc etc for each faction or just omit the factions specification
    
    end_monitor
    
    ;If player accepts, set cooldown timer, reset selection, and set counter to be picked up by turmoil monitor
    monitor_event EventCounter EventCounterType add_turmoil_judea_accepted
        and I_EventCounter add_turmoil_judea_accepted == 1
    
    set_counter judea_turmoil_mission 1
    set_event_counter add_turmoil_judea_accepted 0
    set_counter judea_turmoil_timer 20
    
    if I_LocalFaction england
     add_money england -5000
    end_if
    ;and so on and so on
    end_monitor
    
    ;If player declines, set cooldown timer and reset selection
    monitor_event EventCounter EventCounterType add_turmoil_judea_declined
        and I_EventCounter add_turmoil_judea_declined == 1
    
    set_event_counter add_turmoil_judea_declined 0
    set_counter judea_turmoil_timer 10
    
    end_monitor
    
    ;Decrease the cooldown timer each turn end
    monitor_event FactionTurnEnd FactionIsLocal
    
    if I_CompareCounter judea_turmoil_timer > 0
      inc_counter judea_turmoil_timer -1
    end_if
    
    ;;etc etc for each separate settlement turmoil timer
    end_monitor
    
    ; Run the turmoil mission for the spy if accepted (Subterfuge = 1)
    monitor_event CharacterTurnEndInSettlement CharacterIsLocal
        and AgentType = spy
        and PopulationOwnReligion > 50
        and InEnemyLands
        and SettlementName Judea
        and Attribute subterfuge == 1
        and I_CompareCounter judea_turmoil_mission == 1
    ; Possibilities out of 100%
    generate_random_counter judea_mission_chance 1 100
    ; Increase counter based on subterfuge level(effective range 5-109)
    random_counter_inc judea_mission_chance 4 9
    
    ; Mission failed
    if I_EventCounter judea_mission_chance < 50
    ;do nothing
    end_if
    
    ; Mission success - minor
    if I_EventCounter judea_mission_chance >= 50
      and I_EventCounter judea_mission_chance < 70
    
    add_settlement_turmoil Judea 5
    
    end_if
    
    ; Mission success - moderate
    if I_EventCounter judea_mission_chance >=70
      and I_EventCounter judea_mission_chance < 90
    
    add_settlement_turmoil Judea 10
    
    end_if
    
    ; Mission success - major
    if I_EventCounter judea_mission_chance >= 90
    
    add_settlement_turmoil Judea 15
    
    end_if
    
    set_event_counter judea_mission_chance 0
    set_counter judea_turmoil_mission 0
    
    end_monitor
    That's not the way I prefer to use the random counter as it's less controlled(there's higher success probability than if you were to toy with the percentiles needed for success instead of toying with the random counter inc), but that's one example of how you can use it with ranges and the random_counter_inc command.

    And here's another excerpt which uses random counter in my Lucky Factions script(which I'll probably make available for use when I get around to making a scripts thread, but I'm lazy).
    Code:
    	if I_LocalFaction song
    	;;Run loop until 3 lucky factions chosen
    	while I_CompareCounter lucky_factions < 3
    		generate_random_counter lucky_faction 1 100
    		if I_EventCounter lucky_faction < 16 ; 15% Chance
    			increment_kings_purse jin 1000
    			inc_counter jin_got_lucky 1
    			inc_counter lucky_factions 1
    		end_if
    		if I_EventCounter lucky_faction < 31
    		 and I_EventCounter lucky_faction > 15 ; 15% Chance
    			increment_kings_purse mongols 1000
    			inc_counter mongols_got_lucky 1
    			inc_counter lucky_factions 1
    		end_if
    		if I_EventCounter lucky_faction < 46
    		 and I_EventCounter lucky_faction > 30 ; 15% Chance
    			increment_kings_purse khmer 1000
    			inc_counter khmer_got_lucky 1
    			inc_counter lucky_factions 1
    		end_if
    		if I_EventCounter lucky_faction < 54
    		 and I_EventCounter lucky_faction > 45 ; 8% Chance
    			increment_kings_purse tibet 1000
    			inc_counter tibet_got_lucky 1
    			inc_counter lucky_factions 1
    		end_if
    		if I_EventCounter lucky_faction < 62
    		 and I_EventCounter lucky_faction > 53 ; 8% Chance
    			increment_kings_purse daiviet 1000
    			inc_counter daiviet_got_lucky 1
    			inc_counter lucky_factions 1
    		end_if
    		if I_EventCounter lucky_faction < 70
    		 and I_EventCounter lucky_faction > 61 ; 8% Chance
    			increment_kings_purse dali 1000
    			inc_counter dali_got_lucky 1
    			inc_counter lucky_factions 1
    		end_if
    		if I_EventCounter lucky_faction < 78
    		 and I_EventCounter lucky_faction > 69 ; 8% Chance
    			increment_kings_purse goryeo 1000
    			inc_counter goryeo_got_lucky 1
    			inc_counter lucky_factions 1
    		end_if
    		if I_EventCounter lucky_faction < 86
    		 and I_EventCounter lucky_faction > 77 ; 8% Chance
    			increment_kings_purse xixia 1000
    			inc_counter xixia_got_lucky 1
    			inc_counter lucky_factions 1
    		end_if
    		if I_EventCounter lucky_faction < 89
    		 and I_EventCounter lucky_faction > 85 ; 3% Chance
    			increment_kings_purse champa 1000
    			inc_counter champa_got_lucky 1
    			inc_counter lucky_factions 1
    		end_if
    		if I_EventCounter lucky_faction < 92
    		 and I_EventCounter lucky_faction > 88 ; 3% Chance
    			increment_kings_purse pagan 1000
    			inc_counter pagan_got_lucky 1
    			inc_counter lucky_factions 1
    		end_if
    		if I_EventCounter lucky_faction < 95
    		 and I_EventCounter lucky_faction > 91 ; 3% Chance
    			increment_kings_purse minamoto 1000
    			inc_counter minamoto_got_lucky 1
    			inc_counter lucky_factions 1
    		end_if
    		if I_EventCounter lucky_faction < 98
    		 and I_EventCounter lucky_faction > 94 ; 3% Chance
    			increment_kings_purse taira 1000
    			inc_counter taira_got_lucky 1
    			inc_counter lucky_factions 1
    		end_if
    		if I_EventCounter lucky_faction > 97 ;3% Chance
    			increment_kings_purse khitans 1000
    			inc_counter khitans_got_lucky 1
    			inc_counter lucky_factions 1
    		end_if
    		
    		;;Prevent same faction from getting lucky twice
    		
    		if I_CompareCounter champa_got_lucky > 1
    			increment_kings_purse champa -1000
    			inc_counter champa_got_lucky -1
    			inc_counter lucky_factions -1
    		end_if
    		if I_CompareCounter daiviet_got_lucky > 1
    			increment_kings_purse daiviet -1000
    			inc_counter daiviet_got_lucky -1
    			inc_counter lucky_factions -1
    		end_if
    		if I_CompareCounter dali_got_lucky > 1
    			increment_kings_purse dali -1000
    			inc_counter dali_got_lucky -1
    			inc_counter lucky_factions -1
    		end_if
    		if I_CompareCounter goryeo_got_lucky > 1
    			increment_kings_purse goryeo -1000
    			inc_counter goryeo_got_lucky -1
    			inc_counter lucky_factions -1
    		end_if
    		if I_CompareCounter jin_got_lucky > 1
    			increment_kings_purse jin -1000
    			inc_counter jin_got_lucky -1
    			inc_counter lucky_factions -1
    		end_if
    		if I_CompareCounter khitans_got_lucky > 1
    			increment_kings_purse khitans -1000
    			inc_counter khitans_got_lucky -1
    			inc_counter lucky_factions -1
    		end_if
    		if I_CompareCounter khmer_got_lucky > 1
    			increment_kings_purse khmer -1000
    			inc_counter khmer_got_lucky -1
    			inc_counter lucky_factions -1
    		end_if
    		if I_CompareCounter minamoto_got_lucky > 1
    			increment_kings_purse minamoto -1000
    			inc_counter minamoto_got_lucky -1
    			inc_counter lucky_factions -1
    		end_if
    		if I_CompareCounter mongols_got_lucky > 1
    			increment_kings_purse mongols -1000
    			inc_counter mongols_got_lucky -1
    			inc_counter lucky_factions -1
    		end_if
    		if I_CompareCounter pagan_got_lucky > 1
    			increment_kings_purse pagan -1000
    			inc_counter pagan_got_lucky -1
    			inc_counter lucky_factions -1
    		end_if
    		if I_CompareCounter song_got_lucky > 1
    			increment_kings_purse song -1000
    			inc_counter song_got_lucky -1
    			inc_counter lucky_factions -1
    		end_if
    		if I_CompareCounter taira_got_lucky > 1
    			increment_kings_purse taira -1000
    			inc_counter taira_got_lucky -1
    			inc_counter lucky_factions -1
    		end_if
    		if I_CompareCounter tibet_got_lucky > 1
    			increment_kings_purse tibet -1000
    			inc_counter tibet_got_lucky -1
    			inc_counter lucky_factions -1
    		end_if
    		if I_CompareCounter xixia_got_lucky > 1
    			increment_kings_purse xixia -1000
    			inc_counter xixia_got_lucky -1
    			inc_counter lucky_factions -1
    		end_if
    	end_while
    	end_if

  3. #3
    GrnEyedDvl's Avatar Liberalism is a Socially Transmitted Disease
    Artifex Technical Staff

    Join Date
    Jan 2007
    Location
    Denver CO
    Posts
    23,851
    Blog Entries
    10

    Default Re: Lesson 5, Finally

    Cool use of the random counter, thats one I never thought of.

  4. #4

    Default Re: Lesson 5, Finally

    Nice ! Here's a small code i'll write so far , will write the rest later as i need to get tortured now(braces )

    This script should actually be for an acient mod for MTW2 Kingdoms . It's "needed" to represent the oracle of Delphi . very simple , when you have 1 of the cities that are closest to the oracle (or important cities like Sparta) , there's a chance you get to see the world for 1 turn . When you have multiple cities that are adjacent to the Oracle (or important cities like Athens), the chance increases . (although it could be done with percents too) (and the script only works for greek factions )

    Code:
    script
    
    declare_counter oracle
    declare_counter oraclebusy
    
    monitor_event FactionTurnStart FactionIsLocal
     and I_SettlementOwner -city adjacent to the oracle- = sparta
    
    inc_counter oracle 5
    
    end_monitor
    
    monitor_event FactionTurnStart FactionIsLocal
     and I_SettlementOwner Athens = sparta
    
    inc_counter oracle 10
    
    end_monitor
    
    monitor_event FactionTurnStart FactionIsLocal
     and I_SettlementOwner Sparta = sparta
    
    inc_counter oracle 10
    
    end_monitor
    
    monitor_event FactionTurnStart FactionType sparta
     and FactionIsLocal
     and I_CompareCounter oracle < 10
     and I_CompareCounter oraclebusy = 0
    
     generate_random_counter RandomNumber 1 100
    
                           if I_EventCounter RandomNumber > 85 ; = small chance
                             console_command toggle_fow
                             set_counter oraclebusy 1
                           end_if
    
    end_monitor
    
    ; Turn the fow off at the turn end ;
    
    monitor_event FactionTurnEnd FactionIsLocal
     and I_CompareCounter oraclebusy = 1
    
    set_counter oraclebusy 0
    console_command toggle_fow
    
    end_monitor
    
    monitor_event FactionTurnStart FactionType sparta
     and FactionIsLocal
     and I_CompareCounter oracle < 30 ; More cities
     and I_CompareCounter oraclebusy = 0
    
     generate_random_counter RandomNumber 1 100
    
                           if I_EventCounter RandomNumber > 70 ; = bigger chance
                             console_command toggle_fow
                             set_counter oraclebusy 1
                           end_if
    
    end_monitor
    It's not finished and there's a lot of bugs in it probably , but you get the point (or at least i hope so )

  5. #5
    GrnEyedDvl's Avatar Liberalism is a Socially Transmitted Disease
    Artifex Technical Staff

    Join Date
    Jan 2007
    Location
    Denver CO
    Posts
    23,851
    Blog Entries
    10

    Default Re: Lesson 5, Finally

    Thats a cool idea, but a few ideas to make it better.


    Make the player spend money to do it, paying the oracle, and then tie it to the accept/decline with a button. Do they want to spend the money or not?

    Also you could throw in toggle_perfect_spy which will allow you to see things inside settlements that toggle_fow will not.

    Or if you wanted to get really creative you could use the reveal_tile command and only show a specific area, depending what the player purchased.

  6. #6

    Default Re: Lesson 5, Finally

    Quote Originally Posted by GrnEyedDvl View Post
    Thats a cool idea, but a few ideas to make it better.


    Make the player spend money to do it, paying the oracle, and then tie it to the accept/decline with a button. Do they want to spend the money or not?

    Also you could throw in toggle_perfect_spy which will allow you to see things inside settlements that toggle_fow will not.

    Or if you wanted to get really creative you could use the reveal_tile command and only show a specific area, depending what the player purchased.
    Thanks . As i said , it was still a very small code etc

    Perhaps paying options :

    Pay extra for a Perfect Spy ?

    Yes/No .

    Another idea could be this : there are muiltiple bonusses (or even a penalty , you know like : You paid 5000 bucks , but the oracle "can't see in the future apprently" , so you just lost 5000 bucks ) the oracle can give , for instance :

    - Perfect spy (1 turn)
    - Show world (no perfect spy) 2 turns
    - Show some cities (5 turns)

    Etc..

  7. #7
    GrnEyedDvl's Avatar Liberalism is a Socially Transmitted Disease
    Artifex Technical Staff

    Join Date
    Jan 2007
    Location
    Denver CO
    Posts
    23,851
    Blog Entries
    10

    Default Re: Lesson 5, Finally

    Yeah theres lots of things you could do with it. Thats the beauty of scripting.

  8. #8

    Default Re: Lesson 5, Finally

    Okay, here’s part of my first attempt at Lesson 5. This is part of a script I’m working on for my mod, so beg pardon if things look unfamiliar.
    This only covers the yes/no portion of the lesson. First, my campaign script.

    Code:
     
    monitor_event CharacterSelected IsGeneral
                and Trait Negro 1
                and Attribute  Command >= 4
                historic_event gracias_question true
    end_monitor
     
    monitor_event EventCounter EventCounterType gracias_question_accepted
     and I_EventCounter gracias_question_accepted == 1
      historic_event accept_clicked
      console_command add_money -1000
      set_event_counter gracias_question_accepted 0
    end_monitor
     
    monitor_event EventCounter EventCounterType gracias_question_declined
     and I_EventCounter gracias_question_declined == 1
      historic_event decline_clicked
      set_event_counter gracias_question_declined 0
    end_monitor

    Everything is firing here perfectly, no problems. However, I attempt to interface this event with the EDCT, and therein lies the trouble.

    Here’s my traits, set up as AntiTraits.

    Code:
     
    ;------------------------------------------                   
    Trait Negro
                Characters family
                AntiTraits Extinguished
                
                Level Mulatto
                            Description Mulatto_desc
                            EffectsDescription Mulatto_effects_desc
                            Threshold 1
                
                Effect Unrest 1
                
    ;-------------------------------------------
    Trait Extinguished
                Characters family
                AntiTraits Negro
                
                Level Extinguished
                            Description Extinguished_desc
                            EffectsDescription Extinguished_effects_desc
                            Threshold 1
                
                Effect Unrest –1

    And then the trigger that is supposed to set the AntiTrait off.

    Code:
     
    ;------------------------------------------
    Trigger Blood_Change_1
                WhenToTest CharacterTurnEnd
                Condition FactionType spain
                and Trait Negro >= 1
                and I_EventCounter gracias_question_accepted >= 1
                
                Affects Extinguished 1 Chance 100

    Essentially, this does not seem to fire at all. Any idea what I am doing wrong? I’ve been working through this with various other tutorials over the past few weeks, but nothing is firing it.
    Son of PW

  9. #9

    Default Re: Lesson 5, Finally

    Perhaps you could give some more info about the script , as it's rather unclear (at least for me) atm ..
    Last edited by Killerbee; September 09, 2009 at 12:08 PM.

  10. #10

    Default Re: Lesson 5, Finally

    Basically, when the player clicks "yes", he is able to replace a bad trait with a good one. It's meant to replicate a historical legal process in colonial Spanish America.
    Son of PW

  11. #11

    Default Re: Lesson 5, Finally

    Perhaps this ? :

    Code:
                and I_EventCounter gracias_question_accepted >= 1
    If i'm not mistaken , that means the condition requires more than the value of "1" to launch , although when you press accept , the value will only go to 1 , and not higher ..

    just a suggestion

  12. #12

    Default Re: Lesson 5, Finally

    Well let me understand this better:

    Code:
    monitor_event FactionTurnEnd FactionIsLocal
     generate_random_counter SellEvent 1 100
     
     if I_EventCounter SellEvent > 0
    and I_EventCounter SellEvent < 20
      historic_event sell_resource_20 true
     end_if
     
     if I_EventCounter SellEvent > 19
    and I_EventCounter SellEvent < 40
      historic_event sell_resource_40 true
     end_if
    
    if I_EventCounter SellEvent > 39
    and I_EventCounter SellEvent < 60
      historic_event sell_resource_60 true
     end_if
    
    if I_EventCounter SellEvent > 59
    and I_EventCounter SellEvent < 80
      historic_event sell_resource_80 true
     end_if
    
    if I_EventCounter SellEvent > 79
       historic_event sell_resource_100 true
      end_if
    end_monitor
    Code:
    monitor_event EventCounter EventCounterType sell_resource_20_accepted
     and I_EventCounter sell_resource_20_accepted == 1
      historic_event sold_20_stock
    console_command add_money wessex 2000
      set_event_counter sell_resource_20_accepted 0
    end_monitor
     
    monitor_event EventCounter EventCounterType sell_resource_20_declined
     and I_EventCounter sell_resource_20_declined == 1
      historic_event unsold_20_stock
      set_event_counter sell_resource_20_declined 0
    end_monitor
    
    monitor_event EventCounter EventCounterType sell_resource_40_accepted
     and I_EventCounter sell_resource_40_accepted == 1
      historic_event sold_40_stock
    console_command add_money wessex 4000
      set_event_counter sell_resource_40_accepted 0
    end_monitor
     
    monitor_event EventCounter EventCounterType sell_resource_40_declined
     and I_EventCounter sell_resource_40_declined == 1
      historic_event unsold_40_stock
      set_event_counter sell_resource_40_declined 0
    end_monitor
    
    monitor_event EventCounter EventCounterType sell_resource_60_accepted
      and I_EventCounter sell_resource_60_accepted == 1
       historic_event sold_60_stock
    console_command add_money wessex 6000
       set_event_counter sell_resource_60_accepted 0
     end_monitor
      
     monitor_event EventCounter EventCounterType sell_resource_60_declined
      and I_EventCounter sell_resource_60_declined == 1
       historic_event unsold_60_stock
       set_event_counter sell_resource_60_declined 0
     end_monitor
    
    monitor_event EventCounter EventCounterType sell_resource_80_accepted
       and I_EventCounter sell_resource_80_accepted == 1
        historic_event sold_80_stock
    console_command add_money wessex 8000
        set_event_counter sell_resource_80_accepted 0
      end_monitor
       
      monitor_event EventCounter EventCounterType sell_resource_80_declined
       and I_EventCounter sell_resource_80_declined == 1
        historic_event unsold_80_stock
        set_event_counter sell_resource_80_declined 0
      end_monitor
    
    monitor_event EventCounter EventCounterType sell_resource_100_accepted
        and I_EventCounter sell_resource_100_accepted == 1
         historic_event sold_100_stock
    console_command add_money wessex 10000
         set_event_counter sell_resource_100_accepted 0
       end_monitor
        
       monitor_event EventCounter EventCounterType sell_resource_100_declined
        and I_EventCounter sell_resource_100_declined == 1
         historic_event unsold_100_stock
         set_event_counter sell_resource_100_declined 0
       end_monitor
    Will this be able to run properly? i think yes, but if not please explain.
    and of course the historic event comes later.
    EDITED:
    I just wanna understand it better so i can extend the script.
    Last edited by Icedie El Guaraní; September 09, 2009 at 04:12 PM.
    Contribuitor IBIICB-WOTN-Modeler-Scripter


  13. #13

    Default Re: Lesson 5, Finally

    @GED the script i made did not work, it crash the when ever i click on end turn button.

    I use Historic_event and the campaign_script only, you did mention something about the EDB :
    You should note that this is an event_counter, not a normal counter, so using it along with the EDB can create new problems.
    I am feeling a lil stupid right now, can you elaborate a bit more on it, a lil candy for a homeless dude!!

    Thanks
    Contribuitor IBIICB-WOTN-Modeler-Scripter


  14. #14

    Default Re: Lesson 5, Finally

    Here’s a free tip – at a very quick glance I see this;

    Code:
     monitor_event EventCounter EventCounterType sell_resource_40_declined
       and I_EventCounter sell_resource_40_declined == 1


    and wish I was seeing;

    Code:
     monitor_condition I_EventCounter sell_resource_40_declined == 1



    I know I am not up to lesson 5 yet but Icedie asked me to help

  15. #15
    Augustus Lucifer's Avatar Life = Like a beanstalk
    Patrician Citizen

    Join Date
    Aug 2006
    Location
    Mote of Dust
    Posts
    10,725

    Default Re: Lesson 5, Finally

    The monitor_event has actually superseded the monitor_conditions in terms of effectiveness, I used to use monitor_conditions as well. The one you note is more succinct in code, but in execution it is more laborious. Conditions are checked at every possible interval, so every time some sort of event which is logged gets checked, so to do all commands with a monitor_conditions(or it may even be fluent kept in some sort of memcache). This x 1000 will mean a grip of lag because the scripting engine has to check a large number of event-disambiguated conditions for true. The event saves on that because it only fires whenever an event counter is changed, and then checks for the conditions of which event counter was changed and what it is set to.

  16. #16

    Default Re: Lesson 5, Finally

    True, but it is good for trouble shooting the main part, he says his script doesn't work as is. Also mentioned the accept/decline is not working but i see no issue here..

  17. #17

    Default Re: Lesson 5, Finally

    Still not working; doesn´t recognize monitor_condition
    15:00:29.140 [game.script] [error] Script parsing error at line 1586, column 1 in mods/Vacuus_Kingdoms/data/world/maps/campaign/imperial_campaign/campaign_script.txt
    don't recognise this token: monitor_condition
    15:00:29.140 [game.script] [error] Script parsing error at line 1587, column 9 in mods/Vacuus_Kingdoms/data/world/maps/campaign/imperial_campaign/campaign_script.txt
    Couldn't create a script from file mods/Vacuus_Kingdoms/data/world/maps/campaign/imperial_campaign/campaign_script.txt
    line 1587:
    Code:
    monitor_condition I_EventCounter sell_resource_20_accepted == 1
            historic_event sold_stock_20
            set_event_counter sell_resource_20_accepted 0
    end_monitor
    and the full script:
    Spoiler Alert, click show to read: 
    Code:
    monitor_event FactionTurnEnd FactionIsLocal
        generate_random_counter SellEvent 1 100
        if I_EventCounter SellEvent < 20
            historic_event sell_resource_20 true
        end_if
        if I_EventCounter SellEvent > 19
        and I_EventCounter SellEvent < 40
            historic_event sell_resource_40 true
        end_if
        if I_EventCounter SellEvent > 39
        and I_EventCounter SellEvent < 60
            historic_event sell_resource_60 true
        end_if
        if I_EventCounter SellEvent > 59
        and I_EventCounter SellEvent < 80
            historic_event sell_resource_80 true
        end_if
        if I_EventCounter SellEvent > 79
            historic_event sell_resource_100 true
        end_if
    end_monitor
    monitor_conditions I_EventCounter sell_resource_20_accepted == 1
            historic_event sold_stock_20
            set_event_counter sell_resource_20_accepted 0
    end_monitor 
    monitor_conditions I_EventCounter sell_resource_20_declined == 1
            historic_event unsold_stock_20
            set_event_counter sell_resource_20_declined 0
    end_monitor
    monitor_conditions I_EventCounter sell_resource_40_accepted == 1
            historic_event sold_stock_40
            set_event_counter sell_resource_40_accepted 0
    end_monitor
    monitor_conditions I_EventCounter sell_resource_40_declined == 1
            historic_event unsold_stock_40
            set_event_counter sell_resource_40_declined 0
    end_monitor
    monitor_conditions I_EventCounter sell_resource_60_accepted == 1
            historic_event sold_stock_60
            set_event_counter sell_resource_60_accepted 0
    end_monitor
    monitor_conditions I_EventCounter sell_resource_60_declined == 1
            historic_event unsold_stock_60
            set_event_counter sell_resource_60_declined 0
    end_monitor
    monitor_conditions I_EventCounter sell_resource_80_accepted == 1
            historic_event sold_stock_80
            set_event_counter sell_resource_80_accepted 0
    end_monitor 
    monitor_conditions I_EventCounter sell_resource_80_declined == 1
            historic_event unsold_stock_80
            set_event_counter sell_resource_80_declined 0
    end_monitor
    monitor_conditions I_EventCounter sell_resource_100_accepted == 1
            historic_event sold_stock_100
            set_event_counter sell_resource_100_accepted 0
    end_monitor   
    monitor_conditions I_EventCounter sell_resource_100_declined == 1
         historic_event unsold_stock_100
         set_event_counter sell_resource_100_declined 0
    end_monitor


    i am pretty confuse with AL explanation


    EDITED:
    typo monitor_conditions, i told you i was feeling stupid!!

    but i believe what AL said is that this will cause some lagging every turn end, and i am certain i don´t want this. i will try something else. later....!!

    Again, the game runs, the campaign opens, the welcome script fires, which i assume means the script is allright at some point, but it crashes when i hit turn end button.
    Last edited by Icedie El Guaraní; September 11, 2009 at 01:06 PM.
    Contribuitor IBIICB-WOTN-Modeler-Scripter


  18. #18

    Default Re: Lesson 5, Finally

    Quote Originally Posted by Icedie of South View Post
    Still not working; doesn´t recognize monitor_condition
    line 1587:
    Code:
    monitor_condition I_EventCounter sell_resource_20_accepted == 1
            historic_event sold_stock_20
            set_event_counter sell_resource_20_accepted 0
    end_monitor
    and the full script:
    Spoiler Alert, click show to read: 
    Code:
    monitor_event FactionTurnEnd FactionIsLocal
        generate_random_counter SellEvent 1 100
        if I_EventCounter SellEvent < 20
            historic_event sell_resource_20 true
        end_if
        if I_EventCounter SellEvent > 19
        and I_EventCounter SellEvent < 40
            historic_event sell_resource_40 true
        end_if
        if I_EventCounter SellEvent > 39
        and I_EventCounter SellEvent < 60
            historic_event sell_resource_60 true
        end_if
        if I_EventCounter SellEvent > 59
        and I_EventCounter SellEvent < 80
            historic_event sell_resource_80 true
        end_if
        if I_EventCounter SellEvent > 79
            historic_event sell_resource_100 true
        end_if
    end_monitor


    i am pretty confuse with AL explanation


    EDITED:
    typo monitor_conditions, i told you i was feeling stupid!!

    but i believe what AL said is that this will cause some lagging every turn end, and i am certain i don´t want this. i will try something else. later....!!

    Again, the game runs, the campaign opens, the welcome script fires, which i assume means the script is allright at some point, but it crashes when i hit turn end button.
    Well , if it crashes at the end turn , than i think something's wrong with your first bit , rather than the monitor_conditions thingy

    Code:
    monitor_event FactionTurnEnd FactionIsLocal
        generate_random_counter SellEvent 1 100
        if I_EventCounter SellEvent < 20
            historic_event sell_resource_20 true
        end_if
        if I_EventCounter SellEvent > 19
        and I_EventCounter SellEvent < 40
            historic_event sell_resource_40 true
        end_if
        if I_EventCounter SellEvent > 39
        and I_EventCounter SellEvent < 60
            historic_event sell_resource_60 true
        end_if
        if I_EventCounter SellEvent > 59
        and I_EventCounter SellEvent < 80
            historic_event sell_resource_80 true
        end_if
        if I_EventCounter SellEvent > 79
            historic_event sell_resource_100 true
        end_if
    end_monitor
    Sure you have deleted the historic_events.txt.strings.bin file ? Sure all your historic_event names are valid ?

  19. #19

    Default Re: Lesson 5, Finally

    Yes pretty much; see it your self:
    {STOCK_PRODUCTION_TITLE}Stock Production
    {SELL_RESOURCE_20_BODY} You sold some of your stock for 2000 florines.
    {SELL_RESOURCE_20_TITTLE}Trade Resource 20%
    {SELL_RESOURCE_40_BODY}You sold some of your stock for 4000 florines.
    {SELL_RESOURCE_40_TITTLE}Trade Resource 40%
    {SELL_RESOURCE_60_BODY}You sold some of your stock for 6000 florines.
    {SELL_RESOURCE_60_TITTLE}Trade Resource 60%
    {SELL_RESOURCE_80_BODY}You sold some of your stock for 8000 florines.
    {SELL_RESOURCE_80_TITTLE}Trade Resource 80%
    {SELL_RESOURCE_100_BODY}You sold some of your stock for 10000 florines.
    {SELL_RESOURCE_100_TITTLE}Trade Resource 100%
    {SOLD_STOCK_20_BODY}You Have made a deal with one of your neighbouring tribes worth 2000 florines, leaving you with 80% available for this turn.
    {SOLD_STOCK_20_TITLE}Deal Made 20%
    {SOLD_STOCK_40_BODY}You Have made a deal with one of your neighbouring tribes worth 4000 florines, leaving you with 60% available for this turn.
    {SOLD_STOCK_40_TITLE}Deal Made 40%
    {SOLD_STOCK_60_BODY}You Have made a deal with one of your neighbouring tribes worth 6000 florines, leaving you with 40% available for this turn.
    {SOLD_STOCK_60_TITLE}Deal Made 60%
    {SOLD_STOCK_80_BODY}You Have made a deal with one of your neighbouring tribes worth 8000 florines, leaving you with 20% available for this turn.
    {SOLD_STOCK_80_TITLE}Deal Made 80%
    {SOLD_STOCK_100_BODY}You Have made a deal with one of your neighbouring tribes worth 10000 florines, leaving you with -100% available for this turn.
    {SOLD_STOCK_100_TITLE}Deal Made 100%
    {UNSOLD_STOCK_20_BODY}You just lost a trading client worth 20% of your stock.
    {UNSOLD_STOCK_20_TITLE}lost trading client 20%
    {UNSOLD_STOCK_40_BODY}You just lost a trading client worth 40% of your stock.
    {UNSOLD_STOCK_40_TITLE}lost trading client 40%
    {UNSOLD_STOCK_60_BODY}You just lost a trading client worth 60% of your stock.
    {UNSOLD_STOCK_60_TITLE}lost trading client 60%
    {UNSOLD_STOCK_80_BODY}You just lost a trading client worth 80% of your stock.
    {UNSOLD_STOCK_80_TITLE}lost trading client 80%
    {UNSOLD_STOCK_100_BODY}You just lost a trading client worth 100% of your stock.
    {UNSOLD_STOCK_100_TITLE}lost trading client 100%

    if it crashes at the end turn , than i think something's wrong with your first bit
    Yes i believe so, what i am thinking of is , what Archaon had told me about counters, could it be that the number < 19 is an invalid binary?, or something like that.

    EDITED:

    Not working either,
    this is the error:
    Code:
    16:34:41.421 [game.script.exec] [trace] exec <generate_random_counter> at line 1566 in mods/Vacuus_Kingdoms/data/world/maps/campaign/imperial_campaign/campaign_script.txt
    16:34:41.421 [game.script.exec] [trace] exec <if> at line 1568 in mods/Vacuus_Kingdoms/data/world/maps/campaign/imperial_campaign/campaign_script.txt
    16:34:41.421 [game.script.exec] [trace] exec <if> at line 1572 in mods/Vacuus_Kingdoms/data/world/maps/campaign/imperial_campaign/campaign_script.txt
    16:34:41.421 [game.script.exec] [trace] exec <if> at line 1576 in mods/Vacuus_Kingdoms/data/world/maps/campaign/imperial_campaign/campaign_script.txt
    16:34:41.421 [game.script.exec] [trace] exec <historic_event> at line 1576 in mods/Vacuus_Kingdoms/data/world/maps/campaign/imperial_campaign/campaign_script.txt
    16:34:41.421 [system.rpt] [error] Uh oh. This isn't good. No idea why, but exiting now. Sorry pal.
    this lines are not causing the problem. i have no idea what is causing it.
    I am using the Bare_bone kingdoms installer as base mod and add a few files to it.
    Can some body add my code to his campaign_script and historic_event file and test it for me? please.
    Last edited by Icedie El Guaraní; September 11, 2009 at 11:50 AM.
    Contribuitor IBIICB-WOTN-Modeler-Scripter


  20. #20

    Default Re: Lesson 5, Finally

    Here's my final use of the RandomCounter (i'll be using it for a small mod of mine) :

    Spoiler Alert, click show to read: 
    Code:
    script
    
    declare_counter reset_choice
    
    ;; Turn 1
    
    monitor_event FactionTurnStart FactionIsLocal
      and I_LocalFaction england
      and not I_IsFactionAiControlled
      and I_TurnNumber = 0
    
    historic_event choicemass true
    
    end_monitor
    
    monitor_conditions I_EventCounter choicemass_accepted = 1
     and I_TurnNumber = 0
    
    set_event_counter masstroups 1
    
    terminate_monitor
    end_monitor
    
    monitor_conditions I_EventCounter choicemass_declined = 1
     and I_TurnNumber = 0
    
    historic_event choiceelite true
    
    terminate_monitor
    end_monitor
    
    monitor_conditions I_EventCounter choiceelite_accepted = 1
     and I_TurnNumber = 0
    
    set_event_counter elitetroups 1
    
    terminate_monitor
    end_monitor
    
    monitor_conditions I_EventCounter choiceelite_declined = 1
     and I_TurnNumber = 0
    
    historic_event choicemedium true
    
    terminate_monitor
    end_monitor
    
    monitor_conditions I_EventCounter choicemedium_accepted = 1
     and I_TurnNumber = 0
    
    set_event_counter mediumtroups 1
    
    terminate_monitor
    end_monitor
    
    monitor_conditions I_EventCounter choicemedium_declined = 1
     and I_TurnNumber = 0
    
    set_counter resetchoice 1
    
    terminate_monitor
    end_monitor
    
    monitor_event FactionTurnEnd FactionIsLocal
     and I_CompareCounter resetchoice = 1
    
    historic_event hurry
    
    terminate_monitor
    end_monitor
    
    ;; Turn 2
    
    monitor_event FactionTurnStart FactionIsLocal
      and I_CompareCounter resetchoice = 1
    
    historic_event choicemass true
    
    terminate_monitor
    end_monitor
    
    monitor_conditions I_EventCounter choicemass_accepted = 1
     and I_TurnNumber = 1
    
    set_event_counter masstroups 1
    set_counter resetchoice 0
    
    terminate_monitor
    end_monitor
    
    monitor_conditions I_EventCounter choicemass_declined = 1
     and I_TurnNumber = 1
    
    historic_event choiceelite true
    
    terminate_monitor
    end_monitor
    
    monitor_conditions I_EventCounter choiceelite_accepted = 1
     and I_TurnNumber = 1
    
    set_event_counter elitetroups 1
    set_counter resetchoice 0
    
    terminate_monitor
    end_monitor
    
    monitor_conditions I_EventCounter choiceelite_declined = 1
     and I_TurnNumber = 1
    
    historic_event choicemedium true
    
    terminate_monitor
    end_monitor
    
    monitor_conditions I_EventCounter choicemedium_accepted = 1
     and I_TurnNumber = 1
    
    set_event_counter mediumtroups 1
    set_counter resetchoice 0
    
    terminate_monitor
    end_monitor
    
    monitor_conditions I_EventCounter choicemedium_declined = 1
     and I_TurnNumber = 1
    
    set_counter resetchoice 2
    
    terminate_monitor
    end_monitor
    
    monitor_event FactionTurnStart FactionIsLocal
     and I_CompareCounter resetchoice = 2
    
     generate_random_counter RandomNumber 1 100
     
     if I_EventCounter RandomNumber > 0
      and I_EventCounter RandomNumber < 34
    
      historic_event choicemass
      set_counter resetchoice 0
    
     end_if
     
     if I_EventCounter RandomNumber > 33
      and I_EventCounter RandomNumber < 67
    
      historic_event choiceelite
      set_counter resetchoice 0
    
     end_if
    
     if I_EventCounter RandomNumber > 66
      and I_EventCounter RandomNumber < 100
    
      historic_event choicemedium
      set_counter resetchoice 0
    
     end_if
    
    terminate_monitor
    end_monitor
    
    wait_monitors
    end_script


    (to see the use of the randomcounter , scroll a bit down . I balded the lines .

    Concept : The eventcounter choicemass will allow you to get mass , cheap and sucky troops .
    The eventcounter choiceelite will allow you to get elite , small amount and expensive units .
    The eventcounter choicemedium will allow you to have between .

    When you haven't decided in 2 turns , the script will automatically and randomly choose something and then fire off a event to tell you what kind of troops you have

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •