Results 1 to 30 of 33

Thread: Scripting problems

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    CeltiberoRamiroI Member Monkwarrior's Avatar
    Join Date
    Apr 2004
    Location
    Salduie/Caesaraugusta/ Sarakusta/Saragossa
    Posts
    828

    Default Re: Scripting problems

    Sorry for "kidnapping" your thread a little, Mak but I have a doubt about scripting.

    I remember that somebody, somewhere, told that the condition FactionBuildingExists doesn't work, but I've been unable to find the post where it was told.

    Can anybody confirm this point?

  2. #2
    Finder of Little Oddities Senior Member Makanyane's Avatar
    Join Date
    Jan 2006
    Posts
    2,220

    Default Re: Scripting problems

    Quote Originally Posted by Monkwarrior
    Sorry for "kidnapping" your thread a little, Mak but I have a doubt about scripting.

    I remember that somebody, somewhere, told that the condition FactionBuildingExists doesn't work, but I've been unable to find the post where it was told.

    Can anybody confirm this point?
    no problem having a lot of similar questions in same place would be better anyway

    I don't know anything about that one, but I seem to have accidentally discovered trigger for Worldwide BuildingExists
    monitor_event SettlementTurnEnd region_id=15
    and I_CompareCounter Nagada = 1
    and GarrisonSettlementRatio < 0.8
    and SettlementBuildingExists > militia_barracks
    using the region_id instead of settlement name is making it return > militia_barracks result for whole map
    Quote Originally Posted by Atilius
    Underscores in internal names aren't the problem, it's spaces in external names.
    Ah, thanks again, I think a lot of our place names are about to acquire ~ or - in that case!
    Not used mods before? Looking for something small and fun?!
    Download the:

  3. #3
    Finder of Little Oddities Senior Member Makanyane's Avatar
    Join Date
    Jan 2006
    Posts
    2,220

    Default Re: Scripting problems

    Another question, sorry, could anyone give any general advice on efficiency when running a script? Is there any difference in game performance between having lots of separate monitor_events or a few larger ones with lots of if's?

    I just managed to write a smallish script that made strat map grind to a halt - I'm hoping reason was I had a lot of
    if I_CharacterTypeNearTile sarmatians general, 2 145,97
    set_counter Roubair_slave 1
    end_if
    statements that weren't contained in monitors, which worked but must have meant it was checking them continuously
    am trying to fix that at moment.

    Am now getting things like:
    Code:
    monitor_event ButtonPressed ButtonPressed siege_assault_button
       and GarrisonSettlementRatio < 0.8
    
       if I_SettlementOwner Roubair = slave
             and I_FactionBesieged slave
             and I_FactionBesieging sarmatians
             and I_CompareCounter Roubair_slave < 1 
             and I_CompareCounter severin = 1 (that bit is local player check for sarmatians)
    
          if I_CharacterTypeNearTile sarmatians general, 2 145,97
             set_counter Roubair_slave 1
          end_if
          if I_CharacterTypeNearTile sarmatians family, 2 145,97
             set_counter Roubair_slave 1
          end_if
    
           if I_CompareCounter Roubair_slave = 1
             set_counter Roubair_slave 2
         	 console_command add_money slave, 1000
             console_command create_unit Roubair "west swordmen" 1
             console_command create_unit Roubair "west archers" 1
             console_command create_unit Roubair "west archers" 1
       	 console_command add_population Roubair  -300
             if RandomPercent < 40
             console_command create_unit Roubair "west swordmen" 1
       	 console_command add_population Roubair  -100
             end_if
             if RandomPercent < 40
             console_command create_unit Roubair "west archers" 1
       	 console_command add_population Roubair  -100
             end_if
          end_if
    terminate_monitor
          end_if
    end_monitor

    which works but I'm not sure how efficient that is - does it make any difference what you put as the first part of the if? ie. if you put the thing least likely to occur at the top does it stop it checking through more of the map?
    Not used mods before? Looking for something small and fun?!
    Download the:

  4. #4
    Notepad user Member Red Spot's Avatar
    Join Date
    Apr 2007
    Location
    The Netherlands
    Posts
    491

    Default Re: Scripting problems

    theoraticly I'd say that you're better of putting stuff in a single monitor with lots of if's, as long as whatever is in that monitor is similair stuff and you're not just calling that monitor for an entire script just cause someone said monitors are more demanding ... :D

    the game needs to continually(sp?) check up on monitors, where the if-statements are only being processed once the monitor is actually triggered

    (I dont think there is a single "black and white" answer here, just try not to spam monitors and keep things properly grouped)

    those "if character near .... " commands I have 2*198 in a single monitor, but all that monitor does is check up on generals near a tile and spawm some men if wanted/needed, anything else is again in its own monitors


    not too experianced scripting TW, but in other engines I always made sure that the if-statement least likelly to pass are checked first so there are as little follow-up checks as possible, though there will be little to even no diff. at all in how demanding a script is, at least not noticable, but every little bit helps specially if eventually your mod might be run by someone on a rather old system, or if you're using a zillion statements ... ;)


    btw;
    siege_assault_button, is that the "start siege on battlemap" button??
    also GarrisonSettlementRatio < 0.8, does that work??
    I've tried that one in M2 (or similair one) and it didnt "seem" to work there, does the current command basicly mean "if garrison is smaller than 80% of 20units" ??


    this is the start of my garrison bit of my script, just Rome in the example;
    Code:
    monitor_event ScrollOpened seige_scroll
    and ScrollOpened seige_scroll
    	if not I_SettlementOwner Rome = romans_julii
    		if I_CharacterTypeNearTile romans_julii family, 3 255, 155
    			set_counter Settlement_Besieged 1
    		end_if
    		if I_CharacterTypeNearTile romans_julii general, 2 255, 155
    			set_counter Settlement_Besieged 1
    		end_if
    		if I_CompareCounter Settlement_Besieged = 1
    			if I_SettlementOwner Rome = romans_senate
    				console_command create_unit Rome "roman praetorian cohort" 6 7 3 3
    				console_command create_unit Rome "roman praetorian cavalry" 2 7 3 3
    				console_command create_unit Rome "roman urban cohort" 4 6 3 3
    				console_command create_unit Rome "roman legion archer ii" 4 5 3 3
    			end_if
    			if not I_SettlementOwner Rome = romans_senate
    			and I_CompareCounter Settlement_Level = 3
    				console_command create_unit Rome "roman urban cohort" 6 6 3 3
    				console_command create_unit Rome "roman legion archer ii" 3 3 3 3
    				console_command create_unit Rome "roman urban cohort" 4 5 3 3
    				console_command create_unit Rome "roman legion archer ii" 3 4 3 3
    			end_if
    			if not I_SettlementOwner Rome = romans_senate
    			and I_CompareCounter Settlement_Level < 3
    				console_command create_unit Rome "roman legion cohort ii" 5 3 2 2
    				console_command create_unit Rome "roman legion archer ii" 3 2 2 2
    				console_command create_unit Rome "roman legion cohort ii" 5 4 2 2
    				console_command create_unit Rome "roman legion archer ii" 3 3 2 2
    			end_if
    			set_counter Settlement_Besieged 0
    		end_if
    	end_if
    end_monitor


    G
    Last edited by Red Spot; 11-18-2007 at 12:48.

  5. #5
    Finder of Little Oddities Senior Member Makanyane's Avatar
    Join Date
    Jan 2006
    Posts
    2,220

    Default Re: Scripting problems

    thanks for answer, I'll have bit more of a look at permutations of how things could be grouped later...

    siege_assault_button, is that the "start siege on battlemap" button??
    also GarrisonSettlementRatio < 0.8, does that work??
    What I was trying to get (and works except laggy problem) was a couple of different results. If you siege city so it goes over its turn under siege as they have more time to prepare you get a stronger army appearing in there (and possibly some spawned relief forces appearing nearby), so thats set on SettlementEndTurn and combination of counters. But I also wanted something to trigger if you attacked city with cannons or 'elephants' and went straight for the assault, so that's linked to pressing the 'assault' rather than 'maintain' siege button.


    With your set up at moment does that keep triggering, if you re-open the scroll to see if ladders etc are built? I ended up putting terminate_monitors in to try and stop mine keep building troops.

    I think the settlement ratio thing works, at least when I had it lower <0.1 it didn't trigger, I was assuming it was working off the garrison level you see in the happiness rating in settlement view, and so related to population/army ratio - but haven't tested much....

    EDIT: just curious as well - won't your monitor trigger if say julii and senate are still allied but julii general is standing next to Rome when you open siege scroll somewhere else for different factions..? (I know mine overflows a bit as well but that was why I was trying to have FactionBesieging in and restrict it to firing if besieger was local player.
    Last edited by Makanyane; 11-18-2007 at 15:32.
    Not used mods before? Looking for something small and fun?!
    Download the:

  6. #6
    Notepad user Member Red Spot's Avatar
    Join Date
    Apr 2007
    Location
    The Netherlands
    Posts
    491

    Default Re: Scripting problems

    Quote Originally Posted by Makanyane
    just curious as well - won't your monitor trigger if say julii and senate are still allied but julii general is standing next to Rome when you open siege scroll somewhere else for different factions..? (I know mine overflows a bit as well but that was why I was trying to have FactionBesieging in and restrict it to firing if besieger was local player.

    yeah it does, brings a bit of "player-caution" into play, but it saves on some extra checks that only give a minor additional degree of certainty, like testing if the Julii are at war with the Senate and the Senate is actually besieged and the Julii besieging ... but that still doesnt garantee that the Julii are actually sieging settlement_x

    why I also asked about the siege button you are using, thought when I think about it I'd rather have some additional overflow in favour of knowing whats there to be killed ... :D


    G

  7. #7
    Finder of Little Oddities Senior Member Makanyane's Avatar
    Join Date
    Jan 2006
    Posts
    2,220

    Default Re: Scripting problems

    why I also asked about the siege button you are using, thought when I think about it I'd rather have some additional overflow in favour of knowing whats there to be killed ...
    do you mean in terms of using assault button to view contents of enemy army without actually attacking? (it does add them if you do that but you also get to view them as soon as it displays enemy army) Surely creating units when you open siege scroll has same effect but earlier
    and also occurs if you just re-open it to check if siege engines are built?

    meh, I might switch over to adding default army on start of siege and then top up / spawn if you maintain siege over turn, but I think it needs the terminate monitors in either way (?)
    Not used mods before? Looking for something small and fun?!
    Download the:

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Single Sign On provided by vBSSO