December 13, 2018, 10:01:58 AM

Username
Password

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

Posts: 1009



View Profile
« Reply #15 on: May 03, 2012, 10:04:06 PM »

#cd checks if an unit attribute is set. (true if it is)
#ce sets an attribute (temporary)
#cf clears it (temporary)
(to get the bit just count in Wh32Edit from Block 1 to Block 4, every checkbox is a bit)

#bf is likely to spawn a regiment
arg1: 1: Fanatics, 2: Zombie (same as spell)
arg2: CTL Function to execute
arg3: unknown
arg4: looks like some offset

#c0
Returns true if the number of arg1 < aliveUnits

Via these opcodes we can figure out:
.func 121
event 78 spawns one fanatics when:
aliveUnits >= 5, aliveUnits >= 11 and aliveUnits >= 17.
Fanatics execute Function 140.
After this it clears the fanatics flag.
Same for .func 125 but the code looks unreached (there is a return between).

#69 is send event to self
arg1: event id

#8d: Checks leader missile weapon.
If arg1 is -1 return true if there is any missile weapon.
If arg1 is not -1 return true if missile is same as arg1.

Used in .func 100:
If unit class is monster:
  If has missile weapon
    event handler 105 (archer)
  else
    event handler 102 (basic unit)
  endif
endif

Used in .func 112 and .func 113 to check for crossbow

#b7: Sends a message to the sender (use in event handler after get_event was called)
arg1 of the received message must be a sender id, otherwise this will fail.
arg1: Event id
arg1 of the message gets set to the id of the current unit
Target is the sender of the last message.

#c9: Clears the last event (got with get_event)

#f0: Replaces the unit name of the current unit with the name id if some other unknown var is 1. o_O (wtf???, purpose???)
The opcode is nonsense, but thanks to this: I think I found the function that replaces the unit name with the string referenced by the name id. The game replaces Goblin with Fanatics with Goblins btw, have you ever noticed this? (nameId is changed) Wink. If it is the function I will provide a patch via my Mod Selector DLL then you can provide the enemies unit name via the unit name field of the regiment.
« Last Edit: May 03, 2012, 11:53:25 PM by Ghabry » Logged

olly
Global Spokesperson
*
Offline Offline

Posts: 1875



View Profile
« Reply #16 on: May 04, 2012, 12:21:20 AM »

Outstanding!

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


View Profile
« Reply #17 on: May 04, 2012, 06:25:30 AM »

Nice finds! I got 1-2 ideas how to use it though I need a better insight of how the main enemy units cycle works - that 'search_and_attack' and other stuff around there. Because now it's not clear where exactly to place in CTL file those ideas I got :p

BTW yes, I noticed Goblins with Fanatics are always just Goblins on the battle field, when I tried to use GwF name slots in EngRel for my renamed units. A patch that picks up unit name on the battlefield from regiment name would be handy indeed.
Logged
cuthalion
Campaign Creator
*
Offline Offline

Posts: 372


View Profile
« Reply #18 on: May 04, 2012, 10:33:18 AM »

One more comment-question

#c0 seems to crash if called outside Event Handler. (I think many other functions behave the same way)
So my question about this.

I want an enemy infantry tank (that protects artillery from my Xbows) move forward as it suffers casualties.
#c0 inside do-while crashes mission on start.
Instead, I use

send_event_to_this 93 (93 is an unused event Id for Infantry units)

And in event handler I write
on_event 93
 #c0 10
 iftrue
  blablabla
 endif
 end_event


This piece seems to work properly. So the question: Is it OK to use any unused event Id for my purposes or may it cause troubles? I know that certain events have predefined Ids even though they may be absent from infantry event handler on a particular mission.
Logged
Ghabry
Developer
*
Offline Offline

Posts: 1009



View Profile
« Reply #19 on: May 04, 2012, 10:44:13 AM »

#c0 crashes? That sounds impossible because the only thing it does is really comparing a number against another one Cheesy.
I have no idea if the game internally uses event id 93. But if the events are really only used by the CTL script it should be save to use.
« Last Edit: May 04, 2012, 10:54:40 AM by Ghabry » Logged

cuthalion
Campaign Creator
*
Offline Offline

Posts: 372


View Profile
« Reply #20 on: May 04, 2012, 10:52:56 AM »

Yep, tested #c0 again and it didn't crash...Maybe that crash was due to another reason, and I didn't investigate further.
Logged
Ghabry
Developer
*
Offline Offline

Posts: 1009



View Profile
« Reply #21 on: May 04, 2012, 10:54:44 AM »

#A2 (search_and_shoot_enemy)
up to
#AC (search_and_attack_enemy)
Are all doing similiar stuff, would be cool to figure this out, but is a bit complicated ^^

The only things I know about these yet:
if arg1 != -1 then arg1 is the event (with id arg1) the caller will receive when something was found. About the source I have no idea yet but it could be the id of the unit found.

For search_and_attack: arg3 is the attribute that should not be set (4096 is steam tank, makes sense).

gah so many opcodes. Guess updating wiki and ctldis slowly becomes high priority now Wink.


#86 and #9f are the same (unknown) opcodes
« Last Edit: May 05, 2012, 12:10:05 AM by Ghabry » Logged

cuthalion
Campaign Creator
*
Offline Offline

Posts: 372


View Profile
« Reply #22 on: May 04, 2012, 11:06:25 AM »

Well, I dunno about priorities Smiley but in general - yes I have a problem that I forgot those opcodes I remembered before, and when I encounter them again in different CTL parts I need to recall everything anew. If ctldis were updated I would appreciate. At least in 1 mission I will have to write all enemy CTL behaviour from scratch :p - the Fortress Map.

Also, a valid topic about Steam Tank. In all 3 missions where Steam Tank is present, all enemy CTL scripts have special attitude to it. I wonder what exactly is there, though probably now it's almost enough information to figure it out.
Just a point for all campaign creators who don't (didn't) edit CTL. The tank is identified by Unit Id = 14, but not by Unit attribute 'steam tank'. Maybe, there is no function that checks other units attributes anyway...
So if to place tank in the Army under a different Id, enemy will treat him as an ordinary unit and thus will misbehave.
And vice versa, if another unit is placed under Id=14, enemy will treat it as steam tank and again, will misbehave.
Logged
Ghabry
Developer
*
Offline Offline

Posts: 1009



View Profile
« Reply #23 on: May 05, 2012, 01:27:43 PM »

CTLDis has been updated.
You have to dissasemble all CTL files again because you cant assemble script files that are written in the old ctldis format (commands were renamed). So all line comments will be lost, sorry.

Wiki is updated, too. Its not so clean like the first items but I wanted to finish this fast and its better to have a bad documentation then none Wink.
Logged

cuthalion
Campaign Creator
*
Offline Offline

Posts: 372


View Profile
« Reply #24 on: May 05, 2012, 01:36:53 PM »

Great!
Thank you very much Smiley
Logged
olly
Global Spokesperson
*
Offline Offline

Posts: 1875



View Profile
« Reply #25 on: May 06, 2012, 01:12:12 AM »

Brilliant progress discovering 37 new ones and revising many existing functions with better descriptions

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)
Ghabry
Developer
*
Offline Offline

Posts: 1009



View Profile
« Reply #26 on: May 16, 2012, 10:14:11 AM »

Check for spell book (everything is 32bit so will always work):
test_unit_r_eq_i 70, n
n = -1 (none), 22 (bright), 23 (ice), 24 (waagh), 25 (dark)

Number of magic items:
test_unit_r_eq_i 71, n (n = count)

Magic Item 1:
test_unit_r_eq_i 72, n (n = item id, not sure if 0 or -1 is none)

Magic Item 2:
test_unit_r_eq_i 75, n (n = item id, not sure if 0 or -1 is none)

Magic Item 3:
test_unit_r_eq_i 78, n (n = item id, not sure if 0 or -1 is none)

Spells directly follow, summed up there are 12 slots.

Items >= 57 (treasures) are handled in a different way, you cant check them with these commands.

If this doenst work I calculated the offset wrong.

The level of the unit is at -277, but thats unreliable because its only 2 byte and other data follows... (test if it works for you)
« Last Edit: May 16, 2012, 11:20:52 AM by Ghabry » Logged

cuthalion
Campaign Creator
*
Offline Offline

Posts: 372


View Profile
« Reply #27 on: May 16, 2012, 10:47:00 AM »

Interesting,

so what's in byte equal to reg-71 - amount of magic items or first magic item?
Logged
Ghabry
Developer
*
Offline Offline

Posts: 1009



View Profile
« Reply #28 on: May 16, 2012, 11:21:01 AM »

Typo fixed, thx.
Logged

cuthalion
Campaign Creator
*
Offline Offline

Posts: 372


View Profile
« Reply #29 on: May 24, 2015, 05:10:44 PM »

A reminder to myself or to anyone who edits ctl.

Argument X for function that Ghabry calls 'move_rand_in_radius X' is not a btb subrecord's sequence number or something.
It is a subrecord that includes
<INT type="11"> X </INT>.
Also, it teleports as a regular teleport if need be. Just regular teleport uses subrecord sequence number instead of this parameter.
Logged
Pages: 1 [2] 3 4 5   Go Up
Print
Jump to: