When I tried using structures I got a lot of inexplicable quiet script failures, and in some case the game crashed instantly. The last test case in the script below is the most baffling, as it would hint at something like delayed reference semantics.
The most problematic aspect is that it seems impossible to get at the values of fields in sub structures. If I try to access them using syntax like outer.inner.field then the script fails quietly, and if I copy out the inner struct (copy = outer.inner; value = copy.field) then the value is lost.
struct TPVWeapon
{
int weapon;
int rune_1;
int rune_2;
int rune_3;
};
struct TPVWeaponSet
{
struct TPVWeapon mhand;
struct TPVWeapon ohand;
int ammo;
};
struct TPVEquip
{
int helmet;
int gloves;
int armour;
int boots;
int belt;
int amulet;
int ring_1;
int ring_2;
struct TPVWeaponSet set_1;
struct TPVWeaponSet set_2;
};
struct TPVConfig
{
string tag;
int level;
string build;
struct TPVEquip equip;
};
void floaty_ (string s, int colour = 0xFFFFFF, float duration = 3.0f)
{
DisplayFloatyMessage(GetMainControlled(), s, FLOATY_MESSAGE, colour, duration);
}
void main ()
{
struct TPVWeapon weapon;
struct TPVWeaponSet set;
struct TPVEquip equip;
struct TPVConfig cfg;
int rune;
/** /
weapon = cfg.equip.set_1.mhand; // script aborts quietly
floaty_("weapon.rune_1 = " + IntToString(weapon.rune_1));
/**/
/** /
rune = cfg.equip.set_1.mhand.rune_1; // game crashes instantly, without fail
floaty_("rune = " + IntToString(rune));
/**/
equip = cfg.equip;
set = equip.set_1;
weapon = set.mhand;
weapon.rune_1 = 1;
set.mhand.rune_1 = 2;
equip.set_1.mhand.rune_1 = 3;
cfg.equip.set_1.mhand.rune_1 = 4;
floaty_("weapon.rune_1 = " + IntToString(weapon.rune_1)); // prints '1'
// okay, clearly not reference semantics
cfg.equip.set_1.mhand.rune_1 = 666;
equip = cfg.equip;
set = equip.set_1;
weapon = set.mhand;
floaty_("weapon.rune_1 = " + IntToString(weapon.rune_1)); // prints '0'
// WTF?
struct TPVWeapon copy_source;
copy_source.rune_1 = 42;
weapon = copy_source;
copy_source.rune_1 = -1;
floaty_("weapon.rune_1 = " + IntToString(weapon.rune_1)); // prints '42'
set.mhand.rune_1 = 666;
weapon = set.mhand;
floaty_("weapon.rune_1 = " + IntToString(weapon.rune_1)); // prints '-1'
// WTF?!
}
Edit: added 'in Dragon Age script' etc. to the first sentence, for clarification. Mea culpa.





Volver arriba







