MOB and ScriptIds

Discussion in 'Tech Guides and Help Threads' started by anatoliy, Dec 3, 2017.

Remove all ads!
  1. anatoliy

    anatoliy Established Member

    Joined:
    Feb 18, 2017
    Messages:
    635
    Likes Received:
    200
    Information about obj_f_scripts_idx property.

    MOB Property
    Among MOB properties is one that is has index obj_f_scripts_idx of type ScriptArray, called ScriptIds. This property belongs to common group, meaning that every object has it.

    Simple Description
    ScriptIds contains ScriptId array along with Script Attachment Number (SAN) – event on which the Script referenced by ScriptId will be called.

    Advanced
    ScriptIds is unusual array, because it implements “fixed array with bitmap” model using following logic. ScriptIds is fixed list of Script Attachment Number (SAN enumeration) in bitmap array, and array of Script Attachment Point structure. There are 43 Attachment Numbers, every of which implies hard-coded circumstances under which this point will be called.

    [​IMG]

    Script Attachment Number and Events
    Each MOB class has different events (point), all of them are listed in Script Attachment Number (SAN) enumeration. To identify, that there is script, that will be called on some event, there is bitmap (array of bits) that is present in ScriptIds along with Points array. So, when bit #1 is set (value of 1) then, Script Attachment Point array’s first element is Examine event, if bit #2 then Use event and so forth.

    Script Attachment Points
    Script Attachment Point structure consists of:

    · Flags, Int32

    · Counter0, byte

    · Counter1, byte

    · Counter2, byte

    · Counter3, byte

    · ScriptId, Int32

    Flags
    Flags is “set of flags that identify special properties of the script (such as it being a trap, for example)”. Default 0. Usage is unknown. Supposedly is conditional filter. Deprecated in ToEE.

    Counter0
    Counter1 has various usage. Supposedly can be used as attackBonus for traps. Confirmed usage is unknown.

    Counter1
    Default 0. Usage is unknown. Deprecated in ToEE.

    Counter2-4
    Default 0. Usage is unknown. Deprecated in ToEE.

    ScriptId
    Is shortened file name transformed into number. Actual File Name can be evaluated using following pattern “\data\scr\py<ScriptId>*.py”, -> * can be any string.
    SAN Enumeration

    Code:
        public enum SAN : UInt32
        {
            san_examine = 0x0,
            san_use = 0x1,
            san_destroy = 0x2,
            san_unlock = 0x3,
            san_get = 0x4,
            san_drop = 0x5,
            san_throw = 0x6,
            san_hit = 0x7,
            san_miss = 0x8,
            san_dialog = 0x9,
            san_first_heartbeat = 0xA,
            san_catching_thief_pc = 0xB,
            san_dying = 0xC,
            san_enter_combat = 0xD,
            san_exit_combat = 0xE,
            san_start_combat = 0xF,
            san_end_combat = 0x10,
            san_buy_object = 0x11,
            san_resurrect = 0x12,
            san_heartbeat = 0x13,
            san_leader_killing = 0x14,
            san_insert_item = 0x15,
            san_will_kos = 0x16,
            san_taking_damage = 0x17,
            san_wield_on = 0x18,
            san_wield_off = 0x19,
            san_critter_hits = 0x1A,
            san_new_sector = 0x1B,
            san_remove_item = 0x1C,
            san_leader_sleeping = 0x1D,
            san_bust = 0x1E,
            san_dialog_override = 0x1F,
            san_transfer = 0x20,
            san_caught_thief = 0x21,
            san_critical_hit = 0x22,
            san_critical_miss = 0x23,
            san_join = 0x24,
            san_disband = 0x25,
            san_new_map = 0x26,
            san_trap = 0x27,
            san_true_seeing = 0x28,
            san_spell_cast = 0x29,
            san_unlock_attempt = 0x2A,
        }
    
     
  2. Allyx

    Allyx Master Crafter Global Moderator Supporter

    Joined:
    Dec 2, 2004
    Messages:
    5,001
    Likes Received:
    250
    Some of those script attachment points don't seem to function in ToEE, but are non-functioning leftovers from Arcanum, though I'm unsure which ones.
     
  3. anatoliy

    anatoliy Established Member

    Joined:
    Feb 18, 2017
    Messages:
    635
    Likes Received:
    200
    Disambiguation

    Sector Attachment Number (SAN)
    It's enumeration of possible callbacks (events, delegates, interface methods, etc) for ToEE Objects (MOBs).

    Script Attachment Point
    It's records of tiny structure, that links of SAN to ScriptId (plus deprecated "parameters" as Counters(0-4) and Flags).
    Semantically it says "As for san_exit_combat event call script from file reference 620 (deprecated: with such parameters Counters, Flags)".

    ScriptId
    It's numeric reference to file “\data\scr\py<ScriptId>*.py”.

    Script Attachment Method (?) (SAM)
    It's a function in Python module\file of specific definition, that will be called as callback.
    I had to made that name, because many confuses those concepts.

    I will try to either find SAM specifications in Python or create one. But definitively going to research all circumstances when they are actually called from Game.
     
Our Host!