Page 2 of 2 FirstFirst 12
Results 21 to 29 of 29

Thread: Can kingdoms.exe internal events and counters be visible for external apps?

  1. #21
    bitterhowl's Avatar Campidoctor
    Join Date
    Feb 2011
    Location
    Russian Feodality
    Posts
    1,695

    Default Re: Can kingdoms.exe internal events and counters be visible for external apps?

    Well, that's right, army formations are in descr_formations_ai, but engine uses only one formation at once for all factions that used in battle config for open battle - that is prescripted here in config_ai_battle

    Code:
    <formation>
            <easy>ai_triple_missiles_in_front</easy>
            <medium>ai_triple_missiles_in_front</medium>
            <hard>ai_triple_missiles_in_front</hard>
            <very_hard>ai_triple_missiles_in_front</very_hard>
          </formation>
    So I'll make 5-7-10 variants of this file which will diverse only in this lines, which contain different formations from descr_formations_ai, which is not necessary to change.

    I'm not using Steam too, so I didn't know that Steam use medieval.exe

    I thought about PreBattle events, that is much more valid, but for the first time for testing conception per se I decided to use faction turn start.

    My sister, do you still recall the blue Hasan and Khalkhin-Gol?
    Russian warship is winning. Proofs needed? Go find yourself!

  2. #22
    Withwnar's Avatar Script To The Waist
    Join Date
    Oct 2008
    Location
    Earth
    Posts
    6,329

    Default Re: Can kingdoms.exe internal events and counters be visible for external apps?

    Try this, over at least two turn ends and watch what is written to the command prompt window. There should be a " - StartTurn_moors found in log" line for each turn the moors have, likewise for the other four factions of this script.

    Code:
    Dim strLogFile
    Dim strLine1
    Dim blnAnyFound
    
    strProcess = "kingdoms.exe"
    strComputer = "."
    Set oFSO = CreateObject("Scripting.FileSystemObject")
    Set oWSH = CreateObject("WScript.Shell")
    sCurDir = oFSO.GetParentFolderName(WScript.ScriptFullName)
    
    Function IsProcessRunning( strServer, strProcess )
        Dim Process, strObject
        IsProcessRunning = False
        strObject   = "winmgmts://" & strServer
        For Each Process in GetObject( strObject ).InstancesOf( "win32_process" )
        If UCase( Process.name ) = UCase( strProcess ) Then
                IsProcessRunning = True
                Exit Function
            End If
        Next
    End Function
    
    strLogFile = oWSH.CurrentDirectory & "\logs\system.log.txt"
    
    Sub ClearFile() 
        Set fLog = oFSO.OpenTextFile(strLogFile,2,1) 
        fLog.Write ""                                 
    '    fLog.Close                                     
    End Sub
    
    Function FindText(isText)
        FindText = False
        If oFSO.FileExists(strLogFile) Then
            Set fLog = oFSO.OpenTextFile(strLogFile,1,1)
            
            Do While Not fLog.AtEndOfStream
                strLine1 = fLog.ReadLine
                If isText = strLine1 Then
                    FindText = True
                    fLog.Close
                    ClearFile
                    Exit Function
                End If
            Loop
            fLog.Close
        Else
            WScript.Echo "log file not found"
        End If
    End Function
    
    
    Do While True
    
        blnAnyFound = False
    
        if FindText("StartTurn_moors") Then         
            oFSO.CopyFile sCurDir & "\data\AiSet1\*.*", sCurDir & "\data\", True   
            WScript.Echo " - StartTurn_moors found in log"        
            blnAnyFound = True
        End if
        if FindText("StartTurn_hre") Then 
            oFSO.CopyFile sCurDir & "\data\AiSet2\*.*", sCurDir & "\data\", True    
            WScript.Echo " - StartTurn_hre found in log"        
            blnAnyFound = True
        End if
        if FindText("StartTurn_england") Then 
            oFSO.CopyFile sCurDir & "\data\AiSet3\*.*", sCurDir & "\data\", True    
            WScript.Echo " - StartTurn_england found in log"        
            blnAnyFound = True
        End if
        if FindText("StartTurn_france") Then 
            oFSO.CopyFile sCurDir & "\data\AiSet4\*.*", sCurDir & "\data\", True    
            WScript.Echo " - StartTurn_france found in log"        
            blnAnyFound = True
        End if
        if FindText("StartTurn_spain") Then 
            oFSO.CopyFile sCurDir & "\data\AiSet5\*.*", sCurDir & "\data\", True
            WScript.Echo " - StartTurn_spain found in log"        
            blnAnyFound = True
        End if
        
        If Not blnAnyFound Then
            'WScript.Echo " - nothing found in log"
        End If
        
        WScript.Sleep 10000
        if ( IsProcessRunning( strServer, strProcess ) = False ) Then
                WScript.Quit
        End if
    Loop

  3. #23
    Gigantus's Avatar I am not special - I am a limited edition.
    Patrician took an arrow to the knee spy of the council

    Join Date
    Aug 2006
    Location
    Goa - India
    Posts
    53,126
    Blog Entries
    35

    Default Re: Can kingdoms.exe internal events and counters be visible for external apps?

    Regarding the executable - you may need to run a test similar to the universal BAT file:

    Code:
    @echo off
    cd ..\..
    IF EXIST kingdoms.exe (start kingdoms.exe @%0\..\Configuration.cfg) ELSE (
    IF EXIST medieval2.exe (
    start medieval2.exe @%0\..\Configuration.cfg) ELSE (
        echo ERROR: Cannot find the M2TW or Kingdoms executable.
        echo You probably installed Bare Geomod into the wrong folder.
        pause
      )
    )










  4. #24
    bitterhowl's Avatar Campidoctor
    Join Date
    Feb 2011
    Location
    Russian Feodality
    Posts
    1,695

    Default Re: Can kingdoms.exe internal events and counters be visible for external apps?

    I'll try it asap when I'll get my pc. Want to clarify this moment:
    Code:
    Sub ClearFile() 
        Set fLog = oFSO.OpenTextFile(strLogFile,2,1) 
        fLog.Write ""                                 
    '    fLog.Close                                     
    End Sub
    Is it necessary? It's a part of PUALogFilter that my IT-man pasted. Do we need to clear log file at all?

    My sister, do you still recall the blue Hasan and Khalkhin-Gol?
    Russian warship is winning. Proofs needed? Go find yourself!

  5. #25
    Withwnar's Avatar Script To The Waist
    Join Date
    Oct 2008
    Location
    Earth
    Posts
    6,329

    Default Re: Can kingdoms.exe internal events and counters be visible for external apps?

    It removes all text from the log file, so when it reads it again next time it is only seeing what has been added by the game since the read this time.

    It's one way to do the "ignore stuff we've already seen in the log" step. But it means that this script and the game could both be trying to write to the log at the same time. There are other ways but more complicated.

  6. #26
    bitterhowl's Avatar Campidoctor
    Join Date
    Feb 2011
    Location
    Russian Feodality
    Posts
    1,695

    Default Re: Can kingdoms.exe internal events and counters be visible for external apps?

    Well, I launched campaign twice - no promt window at all.

    My sister, do you still recall the blue Hasan and Khalkhin-Gol?
    Russian warship is winning. Proofs needed? Go find yourself!

  7. #27
    bitterhowl's Avatar Campidoctor
    Join Date
    Feb 2011
    Location
    Russian Feodality
    Posts
    1,695

    Default Re: Can kingdoms.exe internal events and counters be visible for external apps?

    Seems to break through it from other side.

    Solution for stable AI formation was made in 2007 by Sinuhet in his Battle Mechanics 5.0 At that version it didn't work properly but with enhanced settings of z3n it does. AI is defensive, but adequate. It sends archers first but when you try to engage them the rest AI units attack (in original Sinuhet's files main army was passive).

    So it seems that MTW2 formations system is near to be repaired.

    My sister, do you still recall the blue Hasan and Khalkhin-Gol?
    Russian warship is winning. Proofs needed? Go find yourself!

  8. #28
    Withwnar's Avatar Script To The Waist
    Join Date
    Oct 2008
    Location
    Earth
    Posts
    6,329

    Default Re: Can kingdoms.exe internal events and counters be visible for external apps?

    Progress here too. I don't know why the suggested changes to that script didn't work but I feel that a Windows Scripting Host solution (which that is) isn't a good way to do this. So I've written an application that does. It works well, is very fast in responding to log changes, doesn't alter the log file, plus a bunch of other advantages.

    It's still a work in progress but is at the point where it could be put through a real world test run. This file swapping situation would be ideal. PM me if you're interested, bitterhowl.

  9. #29
    bitterhowl's Avatar Campidoctor
    Join Date
    Feb 2011
    Location
    Russian Feodality
    Posts
    1,695

    Default Re: Can kingdoms.exe internal events and counters be visible for external apps?

    That sounds very good! Seems that I can make 4-5 defferent AI sets, which represent good/bad/defensive/aggressive commander, and wanted to use random switcher. Direct switch will be perfect!

    My sister, do you still recall the blue Hasan and Khalkhin-Gol?
    Russian warship is winning. Proofs needed? Go find yourself!

Page 2 of 2 FirstFirst 12

Posting Permissions

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