December 21, 2024, 01:11:11 PM

Username
Password

Pages: [1] 2 3 ... 6   Go Down
Print
Author Topic: Enemy units in Campaign  (Read 54778 times)
0 Members and 2 Guests are viewing this topic.
cuthalion
Campaign Creator
*
Offline Offline

Posts: 385


View Profile
« on: March 05, 2012, 12:03:54 PM »

Hi,

I played around with enemy units in pbat1 and figured out a few things:

1. If I change an infantry unit with archers, archers won't shoot but will only charge my units in melee.
2. If I change enemy artillery with archers, they won't shoot at all but will only sit at one place till I come and take them.
3. Some of the things don't work like: Substituting necromancer to bright wizard will halt the game once he's about to cast a spell.
A few others.

Is it all avoidable?
And are there other ways to vary enemy behaviour except for substituting units with the units of the same type but other nature? I don't mention altering unit quantity.
Logged
cuthalion
Campaign Creator
*
Offline Offline

Posts: 385


View Profile
« Reply #1 on: March 05, 2012, 12:17:21 PM »

Looking through the forum, I found a few places where ppl discuss computer AI on the battle field.

I like that someone managed to change enemy starting points. I will play with it when I have more time for Dark Omen the next month.
Is it possible to add units to the list of enemies and then place them and give them AI instructions?

Thus far I only figured out, if I add a unit, and I set it the number of one of the existing enemy units on that missions, both default and "my" unit appear at a place and further on both attack me. I wonder if there are bugs about it...
Logged
Ghabry
Developer
*
Offline Offline

Posts: 1020



View Profile
« Reply #2 on: March 05, 2012, 06:46:36 PM »

Hello, the only released mod that alters the enemy behaviour is Rise of the Dead. But this does not change the script files but uses script files from different maps. So it's possible to get random crashes during the battle. I don't really know why, but often it works without any problems Cheesy

I'm not sure if the tool was ever released, but the tool we use for editing the map scripts is called ctldis:
* ctldis.zip (3.62 KB - downloaded 570 times.)


You have to install Python 2 (not 3!) to run it.
But at first open ctldis.py with a text editor
Change base_name = "b101" to the name of the ctl file (without extension).
Create a copy of the ctl-file you want to edit. The name must be b101_orig.ctl (= add _orig to the filename).
 
MODE = 0 # 0 == assemble, 1 == disassemble must be set to 1 if you want to dissasemble the ctl to a text-scriptfile. You must do this once to get a b101.txt. Now you can alter the txt-file and assemble the txt to ctl again by setting mode to 0.

Some information about CTL can find found in the wiki (see also the subpages listed in the box to the right). Our investigations on CTL-Scripts were never finished because we couldn't guess what most of the script commands are doing (even not by try and error). Feel free to experiment with them.

You will also need the tool BTB Edit.
When you open the b101.txt you will see functions. All regiments start with the function defined by the value in <13> in their deployment zone circle. All regions are defined in <6000> in the BTB Editor. The deployment zones are assigned via the Unit Id (check in Wh32Edit), you can find the Id in <12>. <13> is the number of the script function that gets executed on start. Human controlled regiments always execute func 100 (can be altered), in multiplayer all regiments always execute func 100, <13> is ignored.

It's also possible to alter the script that is executed between the missions. It's a complete different script language and the script is hardcoded in engrel.exe. Their is currently no tool to alter it but you can find information in the wiki again. All function names are available because the developers were so kind to put a string table containing all function names from WHMTG in the executable Wink (but none for CTL)

The last time I looked at CTL and WHMTG is already many months ago. Most work was actually done by other members but most of them are not around anymore. Feel free to ask me any questions about CTL or WHMTG and if you found out something cool: Post it! Smiley

* ctldis.zip (3.62 KB - downloaded 570 times.)
« Last Edit: March 06, 2012, 09:13:53 PM by Ghabry » Logged

cuthalion
Campaign Creator
*
Offline Offline

Posts: 385


View Profile
« Reply #3 on: March 05, 2012, 06:56:44 PM »

I see.
Thank you very much for a detailed responce.
Today I heard for the first time about CTL and BTB so time is required to get acquainted with that all..
It shouldn't be very hard to understand the logic of BTB and xml files, about CTL - not sure yet, it's been a while since I looked at a Python code...Main problem is to find free time and enough inspiration. Smiley
Logged
olly
Global Spokesperson
*
Offline Offline

Posts: 2300



View Profile
« Reply #4 on: March 05, 2012, 08:43:30 PM »

Yes please do post any questions, as we love to help and encourage anyone interested in Dark Omen, especially modding the game. Progressing the CTL will be so cool and BTBEditor is a joy to use!

Black Pyramids BTB


Altered for my new Fortress Siege Map




Smiley
« Last Edit: March 05, 2012, 10:33:07 PM by olly » Logged

and back in Nuln, the ageing Graf Berhardt smiled his secret smile of pride whenever he heard the latest tales of his eldest son's ever growing chain of glorious victories -(sothr manual)
Ghabry
Developer
*
Offline Offline

Posts: 1020



View Profile
« Reply #5 on: March 06, 2012, 09:14:28 PM »

I updated my post, forgot a step:
Create a copy of the ctl-file you want to edit. The name must be b101_orig.ctl (= add _orig to the filename) otherwise ctldis will not create the txt-file.
Logged

olly
Global Spokesperson
*
Offline Offline

Posts: 2300



View Profile
« Reply #6 on: March 06, 2012, 10:12:56 PM »

Been getting back into CTL editing with Ghabry's help and have also been finding all my CTL archived stuff from last time we investigated it all. Here is a good picture showing the relationship between the BTB and CTL files. It shows how the Necromancer retreats on B1_04 Map.



Smiley
Logged

and back in Nuln, the ageing Graf Berhardt smiled his secret smile of pride whenever he heard the latest tales of his eldest son's ever growing chain of glorious victories -(sothr manual)
cuthalion
Campaign Creator
*
Offline Offline

Posts: 385


View Profile
« Reply #7 on: March 07, 2012, 11:45:16 AM »

Downloaded BTB Editor using Ghabry's link.
It says 'Blablabla is not a valid Win32 application'
I will try to run it on my Win64 at home this evening, but I actually only have time to look into it at work where I have 32bit XP.
Any ideas what can I reinstall/reassemble to make it work?

Another question is I read through a few Wiki notes on the matter. Yeah it's hard to raise the stuff from scratch, especially if you report several ppl tried that fail-success attempt method and it wasn't of much use.

10 mins talk to a Dark Omen developer would solve a lot if you are prepared to ask 'clever questions' Smiley. I don't think it's a commercial project anymore so why wouldn't one of them give you a few insctructions? provided that they are still available in touch Cheesy
Logged
olly
Global Spokesperson
*
Offline Offline

Posts: 2300



View Profile
« Reply #8 on: March 07, 2012, 08:24:07 PM »

install .net 4.0

Smiley
Logged

and back in Nuln, the ageing Graf Berhardt smiled his secret smile of pride whenever he heard the latest tales of his eldest son's ever growing chain of glorious victories -(sothr manual)
HarlotsEvisceration
Night Goblin
*
Offline Offline

Posts: 18


Abomination


View Profile
« Reply #9 on: March 08, 2012, 04:06:43 PM »

I've had a go at the btb editor, specifically regarding the mages. It's a very slow, trial and error process and honestly I didn't have much luck.

A quick fix is to always replace a mage with a mage, the mage will always use spells it is scripted to use though, so if you change the necromancer to a brightmage, if it's scripted to fly then cast death spasm, it will. However the mage will cast other spells seemingly at random, fireball, burning head, etc. Most of the time, this will crash the game.

To make progress, you'll have to find what line casts what spell, and alter it to what you need it to be. Needle in a haystack.

As for the dev's, I think they are flattered that people still love the game this far on, but their knowlege of the game is in peices, 14 years will do that to you.
Logged

You taught me hate, I'll teach you fear.
cuthalion
Campaign Creator
*
Offline Offline

Posts: 385


View Profile
« Reply #10 on: March 18, 2012, 11:45:56 AM »

Found a little time to start getting aqcuainted, started with BTB Editor.
1. A quick question. How do I load a background mission map to see coordinates of troops/triggers right on the map surface but not on a relative dark square?

Failed to find map files in the Dark Omen installed. Should I download decoded map files from somewhere to let BRB Editor 'eat' them?

2. Got from Wiki that Chunk <6000> is connected to troops and other triggers.
If to talk about B1_01, the first value there is 35 which looks like an amount of Subchunks.
I didn't understand how to add subchunks there. I don't know if all 35 are used but I dont want to touch existing ones. Is there a way?
« Last Edit: March 18, 2012, 11:54:48 AM by cuthalion » Logged
Ghabry
Developer
*
Offline Offline

Posts: 1020



View Profile
« Reply #11 on: March 18, 2012, 01:29:26 PM »

The editor has no functionality to add or remove stuff. You have to use BTBXML instead. This converts BTB to XML so you can edit it with any text editor. This is again a python script.
btbxml.py converts btb to xml. The name of the btb can be changed in line 106. It generates a out.xml. Modify it and then convert it back to btb with xmlbtb.py. The name of the generated BTB file can be changed on line 86.
When you change the regions (5000) don't forget to update the count in the header of the BTB file. That's under 10000/2000/9 (value 21,136 for B1_01).
The wiki says:
2-TUPLE RECORD ( [Number of Regions in file, Number of line segments in all regions] ) type=9, size=16. Line segments are the entries starting with <10> and <502> under the Regions.

Some maps have a low quality bitmap of the map in their directory, e.g. B1_01.bmp. You can load these bitmaps instead if you want.
Logged

cuthalion
Campaign Creator
*
Offline Offline

Posts: 385


View Profile
« Reply #12 on: March 18, 2012, 07:43:03 PM »

Thank you. I got more questions though :p

1. a short one:
By the way, in Olly's example of the Necromancer at Bandits' mission,
#97 16
seems that 16 means the sequence number of the subchunk even though the subchunks aren't enumerated?
This means that my chunks should be appended rather then inserted in the middle. And how is #97 interpreted? I saw #3 in B101 that I wasn't sure about already...

2. I opened ctl->txt file for B101 and it does contain scripts that are used in first mission.
But it wasn't easy to figure out everything. Probably, it would take more time than I could afford. But a few simple examples would help me get basic understanding, if it is possible Smiley

So, Enemy in first mission has 2 "waves". NG(131) and NGArchers(129) have scripts 0,2 and appear at once, archers go to a determined position.
a) where in the ctl files is that position defined?
Then NG(132) and NGArchers(130) have corresponding scripts 1,3. Triggering event is death of both units from wave-1, then trigger transfers them both to the right-top corner regardless of their initial position.
b) where are these right-top corner coordinates in ctl files? I'd like to split that transfer, one unit goes to right-top, the other to the left-bottom for example....for that I would have to add another script though...

c) I added a mage, assigned to it #133 and script 3. The mage wasn't seen at start but did appear in the right-top corner when the wave-2 started, but he didn't cast anything, only used magical staff of his.
I wonder if it is easy to copy-paste a casting script from another .ctl file and assign it to the mage in 1st mission.



Logged
olly
Global Spokesperson
*
Offline Offline

Posts: 2300



View Profile
« Reply #13 on: March 18, 2012, 09:44:24 PM »

You will have to check with Ghabry but looking at my Archived posts, he once said

[23:16] <Ghabry> the teleporting needs #94 followed by #98. the parameter of #94 is unimportant and #98 needs 66, whatever, whatever. So no idea
[23:16] <Ghabry> #97 <id> sets the target of the teleport

http://wiki.dark-omen.org/do/DO/CTL/OpCodes

97  init_teleport_spell node_id  Used by B1_04 Necromancer. Caller teleports to node_id  

I will post more of our rough old notes on Trading Post 1st Mission B1_01 CTL script....

[00:27] <Ghabry> func 4 5 and 6 are the 3 traders
[21:55] <Ghabry> First Archer is func 2

.func 2
#00 128
clear_ctrl_flag 32768
#3f 43970
#3c 240, 0
#3d 15
#3e 13, 31
wait_for_deploy
saveip
goto 7

[21:55] <Ghabry> at the end: goto 7
[21:55] <Ghabry> --> func 7
[21:55] <Ghabry> scroll to it

.func 7
reset_call_stack
saveip
set_r_i 0, 1
#28 9
reset_call_stack
saveip
do
    #b3 9
    iftrue
        #ac 58, 100, 512
    else
        #ac 58, 50, 512  
        iffalse
            #2e 16
            iftrue
                #28 9
            endif
        else
            #2b
            sleep
        endif
    endif
    set_wait_time 10
    wait
always

[21:55] <Ghabry> and you should see 9 three times
[21:56] <Ghabry> by changing it to another waypoint they move to it
[21:57] <Ghabry> try chaning it to 17
[21:57] <Ghabry> and see ingame what happens
[21:57] <Ghabry> (thats waypoint at 1153x492)
[22:03] <Ghabry> ok. so #28 is some waypoint thing
[22:04] <Ghabry> #28 <subchunk_id>
[22:05] <olly> yeah now got goto 7  
[22:05] <olly> so looking at func 7
[22:05] <Ghabry> good
[22:05] <Ghabry> yes
[22:05] <olly> thnx
[22:05] <olly> and 9  3 times
[22:05] <Ghabry> 2 times with #28
[22:06] <olly> so will change to 17   instead of  nines
[22:06] <Ghabry> they should move to the circle you found in the btb parser
[22:06] <olly> great Smiley  
[22:07] <olly> (document on wiki with screenshots>? or not just yet?)  
[22:07] <Ghabry> we should find out about some other waypoint things before
[22:07] <Ghabry> only one opcode is useless imo Wink
[22:07] <Ghabry> #b3 for example
[22:08] <Ghabry> maybe "Reached waypoint <subchunk_id>"?
[22:08] <Ghabry> because of the if-statement
[22:20] <Ghabry> the archers move to the next waypoint when the got enough damage
[22:21] <olly> ive just altered  9s to 17 and can see in BTB the 17th subchunk with x and y = (thats waypoint at 1153x492) so should see the idfference, brb at this chat my crash.. Smiley  
[22:22] <Ghabry> after they got enough damage at 9 they move to 17









22:42] <Ghabry> olly take a look at #ac 58, 50, 512
[22:43] <Ghabry> the archers move to the next waypoint when they got enough damage. If you reduce the 2nd parameter from 50 to 10 they will move with less damage
[22:43] <Ghabry> so this could be a percentage value

[21:19] <Rob> functions 100-148 are the standard functions in every ctl file. You can ignore them for now
[22:20] <Rob>.func 0 play 64 Get da Loot
[22:47] <Rob> "They're heading for the trading post" is triggered by "#af 1,63" I think
[22:51] <Rob> cool #af = #af <unit of head to show> <sound to play>   .func 14

.func 14
clear_ctrl_flag 8
do
    switch
        case 19
            #14 8, 4
            cbrk 6844
        case 20
            #14 8, 4
            cbrk 6844
        case 21
            #14 9, 4
            cbrk 6844
        case 5
            #14 5, -1
            iftrue
                #70 21
            endif
            cbrk 6844
        case 3
            #43
            #0d 128
            cbrk 6844
        case 85
            #47
            iftrue
                clear_unit_flag 16
                #48
                #0d 139
            endif
            cbrk 6844
        case 4
            #44
            #0d 127
            cbrk 6844
        case 27
            #69 25
            cbrk 6844
        case 71
            #d4
            iffalse
                #d1 240
                #0d 137
            endif
            cbrk 6844
        case 68
            #b9
            iftrue
                test_unit_flag 512
                iftrue
                    #cd 2048
                    iffalse
                        #64
                        #6b 16
                    endif
                endif
            endif
            cbrk 6844
        case 69
            #d3 58
            iftrue
                #b8
                iffalse
                    #25 1, 1
                    iffalse
                        play 66
                        #23 1, 1
                    endif
                endif
                #6e 17
            endif
            #d2
            iftrue
                #b8
                iftrue
                    #44
                    #0f 127
                else
                    #0c 134
                endif
            endif
            cbrk 6844
        case 70
            #c1 43968
            iftrue
                #c2 58
                iftrue
                    #0c 13
                else
                    #0c 134
                endif
            else
                #0c 134
            endif
            cbrk 6844
        case 29
            #25 0, 1
            iffalse
                #c1 43968
                iftrue
                    #af 1, 63
                    #23 0, 1
                endif
            endif
            cbrk 3567
        case 10
            #6e 17
            cbrk 3567
        case 12
            #6e 17
            cbrk 3567
        case 22
            #b8
            iffalse
                #6e 17
            endif
            cbrk 3567
        gosub 122
        @0xABC
    endswitch
while
#13
« Last Edit: March 19, 2012, 01:01:55 AM by olly » Logged

and back in Nuln, the ageing Graf Berhardt smiled his secret smile of pride whenever he heard the latest tales of his eldest son's ever growing chain of glorious victories -(sothr manual)
cuthalion
Campaign Creator
*
Offline Offline

Posts: 385


View Profile
« Reply #14 on: March 19, 2012, 09:18:31 AM »

I see, thank you,
will try to look into it when I have a chance.

So far failing to run BTB Editor at my work computer under Windows XP Sad it only works with Windows7 x64 on my home laptop.

Installed .NET 4.0 as Olly suggested but it still doesn't work.
I asked a programmer from our work to run it in his computer, he has newest possible .NET and Visual Studio and Windows XP. It still says 'Isn't a valid Win32 Application'.
Any ideas what else I can fix? I doubt I will have much chance to edit in BTB when at home :p

BTB Editor isn't a necessary tool as one can use BTB-XML, but seems very handy for placing enemy troops with right coordinates on the map.
Logged
Pages: [1] 2 3 ... 6   Go Up
Print
Jump to: