June 24, 2018, 05:16:21 PM

Username
Password

Pages: [1] 2 3 ... 5   Go Down
Print
Author Topic: Further CTL investigation  (Read 16943 times)
0 Members and 1 Guest are viewing this topic.
Ghabry
Developer
*
Offline Offline

Posts: 1009



View Profile
« on: March 27, 2012, 07:59:45 PM »

Because this would be really faaaar to off-topic, to post in Enemy units in campaign:

#4c is nop/no operation (go to next instruction)

Smiley

When you figure out sth that is not directly related to enemies I suggest you post it here (and when enough progress is made lets update the wiki and ctldis).

So far we have:
#9d spell: Allows an enemy unit to cast spell with id spell (untested for magic items)
#99 66, 32768, 1: Casts dispell on the caller. Arguments are unknown. Must be called from an event handler
#d7 n (used in B5_01 and B5_01B, thats black pyramide) checks your game if you defeated Carstein (n = 1), Hand of Nagash (n = 2) or Black Grail (n = 3). (Thats used to disable these units, but n = 1 is not used)
#94 n Adds n magic points to the enemies global magic pool
#93 n Checks if the enemy has at least n magic points

Horses need teleport_to2 for proper initialisation, infantry needs teleport_to

This is somehow connected to artillery converting to infantry on retreat (artillery gets destroyed)

on_event 23
    clear_unit_flag2 1
    #bd 8
    set_event_handler 24
    test_unit_flag1 8192


Tests the Unit Id of the unit:
test_unit_r_eq_i -278, n
n is the Unit Id you want to check.
« Last Edit: April 05, 2012, 11:36:23 PM by Ghabry » Logged

cuthalion
Campaign Creator
*
Offline Offline

Posts: 370


View Profile
« Reply #1 on: March 27, 2012, 08:05:51 PM »


Horses need teleport_to2 for proper initialisation, infantry needs teleport_to


It's not exactly cavalry vs infantry, because 2 similar infantries are sometimes 'incompatible' as well.

I have a grounded guess that issue is connected to sprites, or rather sprite types, but I haven't investigated it thoroughly, nor I am fully familiar with sprites format.
Logged
cuthalion
Campaign Creator
*
Offline Offline

Posts: 370


View Profile
« Reply #2 on: April 01, 2012, 07:32:36 PM »

#98 66, 16384, 1
Necromancer in B4_05 uses this to cast doombolt on the stone. Before this there goes instruction
set_unit_flag2 16

I tried to force another unit cast it but it crashed - I may have missed something, will try again when I have chance.
That other unit had the spell with #9d, had necromancer's handler but it didn't avail.
Logged
cuthalion
Campaign Creator
*
Offline Offline

Posts: 370


View Profile
« Reply #3 on: April 02, 2012, 10:35:43 AM »

#54 46

This is also a teleport like teleport_to2. Is used for instance in B4_06 (mission with a mere in the centre) in Func 1, Func 2.

I have a general feeling that different campaign parts were written by different people Smiley The same results are achieved by somewhat different script techniques. Any particular handwriting can be distinguished by B1, B2, B3, B4 - 4 parts of the campaign Smiley
Logged
Ghabry
Developer
*
Offline Offline

Posts: 1009



View Profile
« Reply #4 on: April 02, 2012, 11:11:05 AM »

Yeah you can also see that there was no real conversation between the devs when you look at the script languages: CTL and WHMTG have nothing in common. Smiley
Logged

Ghabry
Developer
*
Offline Offline

Posts: 1009



View Profile
« Reply #5 on: April 06, 2012, 02:02:49 PM »

There are 8 regiment registers (for unit_r-commands) and 8 global registers (for global_r-commands)

sleep2 is actually sleep if prev statement was true.
Logged

Ghabry
Developer
*
Offline Offline

Posts: 1009



View Profile
« Reply #6 on: April 08, 2012, 12:51:23 AM »

About #bd 8 (used to transform the artillery):
At first: The first 3 bits are ignored

It checks if the unit has unittype 8 (that's infantry here). If the unittype is the same it sets the false flag.
If not it sets the unittype to 8 (the first 3 bits survive) and sets the true flag.
Because the flags are set you can use a conditonal like iftrue to check the result.

Trivia:
The buildings have there own CTL-Structure (or better Regiment-In-Battle-structure) during the battle but don't execute a script function. They have regiment alignment value 0x20 (dec 32).
Logged

Ghabry
Developer
*
Offline Offline

Posts: 1009



View Profile
« Reply #7 on: April 08, 2012, 04:25:57 PM »

Added CTLdis to the download section (thats the same version I posted in the forum a while ago).

I'm also updating the wikis CTL article. All brainstorming stuff was moved to Talk and some general information were added.
I will also (slowly) update the documentation of the opcodes. For now all known codes up to 0x25 have been added (more will follow). So check this out periodically. Worked together with Rob and we figured out some new opcodes.
When the wiki is up-to-date it's also time for a new CTLdis-version.
Logged

cuthalion
Campaign Creator
*
Offline Offline

Posts: 370


View Profile
« Reply #8 on: April 08, 2012, 04:32:17 PM »

Very cool indeed Smiley
Logged
olly
Global Spokesperson
*
Online Online

Posts: 1867



View Profile
« Reply #9 on: April 08, 2012, 07:24:14 PM »

Agreed

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: 370


View Profile
« Reply #10 on: April 09, 2012, 09:31:12 AM »

I don't know if it's known already..
If I write .func 99 and call it from .func 100, the game crashes. I have to append it to the end, as say .func 149 and call it, then it works fine.

The other note is about that randomizer. I seem to have made it work, the problem now is to pick up correct values.

I inserted its call in .func 100 right after set_timer_100, wait_for_timer in the main do-always cycle.

Out of 20 attempts it returned:
7,8 - 6 times
5 - 5 times
6 - 1 time
1 - 1 time
1 time nothing happened, I wonder if the value was outside the range 1-10.
I didn't cover all possible values with my 'if-else', but only 1-10.

It's ok that the values are these, though I am not sure why it returned 6 much less than it did 5 or 7. Maybe it's just a not large enough selection thing.
Logged
cuthalion
Campaign Creator
*
Offline Offline

Posts: 370


View Profile
« Reply #11 on: April 16, 2012, 07:46:02 AM »

As far as I understand, unit level isn't stored as a separate byte but is calculated based on a unit experience.

I'd like to be able to set up CTL logic based on a unit's level.
I didn't find any functions that would compare values  with >, <

Can there be a roundabout way to achieve what I want?
Logged
Ghabry
Developer
*
Offline Offline

Posts: 1009



View Profile
« Reply #12 on: April 16, 2012, 08:47:38 AM »

I don't even know of a value that stores the experience. But it would make sense if there is a value in the CTL-block that handles experience because its needed during battle.

And no there is no way to check for something else then (In)equality in CTL.
The basic functions are all very limited. No <, > compare, no substract command, no way to assign the value of a register to another register.
Logged

cuthalion
Campaign Creator
*
Offline Offline

Posts: 370


View Profile
« Reply #13 on: May 03, 2012, 03:19:19 PM »

    do
        set_timer 50
        wait_for_timer
        #d5 128, 5
    whilenot

This piece of code is used to prevent an enemy regiment pop on the battlefield until an event occurs.
The unit tends to appear as another unit dies. I've a suspicion #d5 checks the amount of alive enemies on the battlefield. But maybe I am wrong: unclear parameter 128 - maybe a flag but I am not sure...
Logged
Ghabry
Developer
*
Offline Offline

Posts: 1009



View Profile
« Reply #14 on: May 03, 2012, 06:43:59 PM »

#d5 does the following:
arg1: alignment
arg2: compared against the counted units.
if (counted >= arg2) false flag is set, true otherwise.

It counts the unit if it is active (unitflag1 & 1), the alignment (128 = evil) matches and unitFlag2 & 2048 is not set updateand it has at least one alive unit/update. If the unit was counted unitflag2 & 0x100 is set.
The alignment check only works for 0x80 (enemy), 0x40 (peasants) and 0x20 (furniture, but this is not counted ^^). Good units have 0x0 so you cant use this to check how many units are deployed by the player -.-

And I would say we can make an assumption: If a argument is 128 its probably the alignment.

So your guess is completly correct. It returns false until the number of enemy units falls under 5.
« Last Edit: May 04, 2012, 10:48:50 PM by Ghabry » Logged

Pages: [1] 2 3 ... 5   Go Up
Print
Jump to: