Jump to content

[v35.3] SFO2E library bugs


Recommended Posts

I'm collecting bugs here that do not directly affect people playing the game with the mod, but do those, like me, who are crazy brave enough to try and use it in their own mods.

lib_spl:

The functions spl_make and spl_copy do not honor the create_scroll boolean; if the function is given an IDS for a wizard- or priest spell, a scroll is always created even if create_scroll is 0.

 

Suggested fix:

diff --git a/mih_sp/third_party/sfo2e/lib_spl.tph b/mih_sp/third_party/sfo2e/lib_spl.tph
index 8ea70f5..4b5d288 100644
--- a/mih_sp/third_party/sfo2e/lib_spl.tph
+++ b/mih_sp/third_party/sfo2e/lib_spl.tph
@@ -158,7 +158,7 @@ BEGIN

                        // make scroll
                        ACTION_MATCH "%spell_resref%" WITH
-                       "SPPR.*" "SPWI.*" BEGIN
+                       "SPPR.*" "SPWI.*" WHEN create_scroll BEGIN
                                LAF spl_make_scroll STR_VAR spell_resref RET scroll_resref END
                        END
                        DEFAULT
@@ -286,7 +286,7 @@ BEGIN
                                        END
                                END
                                ACTION_MATCH "%spell_resref%" WITH
-                               "SPPR.*" "SPWI.*" BEGIN
+                               "SPPR.*" "SPWI.*" WHEN create_scroll BEGIN
                                        LAF spl_make_scroll STR_VAR spell_resref RET scroll_resref END
                                END
                                DEFAULT
lines 2-22/22 (END)

 

Link to comment

lib_spl:
Not a bug per se but rather inconvenient compared to the previous version: Currently there seems to be no way to coerce spl_copy to reserve a new IDS in the class namespace (SPCLxxx).  I have to work around it by manually doing it through spl_resolve_ids, which does have this option.

Link to comment

When adding new effects to an ability, the match= option seems to get silently ignored.  For example, the following code will add thew new effects to all ability headers, not just to the ones that have a certain minimum level as was intended.

  spl.edit[%BHAALSPAWN_SLOW_POISON%]
  [
    m_name:=@1
    m_icon:="rr#bp2g"
    m.ab.delete{s_level > 1}
    m.ab.alter{s_icon:="rr#bp2g"}
    m.ab.clone{s_level=(entry_index * 5 + 5)|number:i=4}
    m.ab_fx.add{s_opcode=(entry_index = 0 ? 75 : 81) s_target=2 s_timing=1 s_power=2|match="p_level > 4" number:i=2}
    m.ab_fx.add{s_opcode=(entry_index = 0 ? 77 : 79) s_target=2 s_timing=1 s_power=2|match="p_level > 9" number:i=2}
    m.ab_fx.add{s_opcode=43 s_target=2 s_timing=1 s_power=2|match="p_level > 14"}
    m.ab_fx.add{s_opcode=224 s_target=2 s_timing=1 s_power=2|match="p_level > 19"}
  ]

 

Link to comment

That's not the correct syntax. 'match' is applied to the level of structure currently being patched, i.e. ability effects, and so isn't meaningful for struct_add. You want match_parent, which is applied to the parent of the structure currently being patched.

I'm slightly surprised that doesn't throw an install-time warning, since 'match' isn't an argument for struct_add; are you using the fun_args MODDER flag?

Link to comment
3 hours ago, DavidW said:

That's not the correct syntax. 'match' is applied to the level of structure currently being patched, i.e. ability effects, and so isn't meaningful for struct_add. You want match_parent, which is applied to the parent of the structure currently being patched.

Ah, that explains it.  Logical when you think about it, but a bit counter-intuitive when "translating" from the previous SFO version which didn't make this distinction. 🙂

4 hours ago, DavidW said:

I'm slightly surprised that doesn't throw an install-time warning, since 'match' isn't an argument for struct_add; are you using the fun_args MODDER flag?

I don't normally have that on as it tends to throw false positives, especially with the fj_ area structures.  But I guess it's a good idea to turn it on while I'm making this transition.

Link to comment

str_sto_v1:

A couple of fields are missing that were editable in the first version of SFO: buy_markup, sell_markup, deprecation_rate and capacity.

 

Suggested fix.  This requires regenerating auto_struct.tpc of course.
 

diff --git a/stratagems/sfo2e/structures/str_sto_v1.2da b/stratagems/sfo2e/structures/str_sto_v1.2da
index d689550..55c20de 100644
--- a/stratagems/sfo2e/structures/str_sto_v1.2da
+++ b/stratagems/sfo2e/structures/str_sto_v1.2da
@@ -17,6 +17,10 @@ fence                                0x11            flag_4
 ignore_reputation      0x11            flag_5
 toggle_recharge                0x11            flag_6
 can_sell_critical      0x11            flag_7
+sell_markup            0x14            long
+buy_markup             0x18            long
+deprecation_rate       0x1c            long
+capacity               0x22            short
 lore                           0x3c            long
 cost_to_identify       0x40            long
 rumors_drinks          0x44            resref_dlg

[Click and drag to move] 

 

Link to comment

I have yet been unable to figure out whether the bug is in SFO2E or there is a peculiarity in this specific file, but are_edit chokes on AR5500 of BGEE (Gibberling Mountains).  The area is unmodded, and can be modded normally with standard WeiDU functions and with the previous SFO version.

This is my specific test case, but I tested a few other edits and got the same result:

  are.edit[%GibberlingMountains%]
  [
    m.container_item.alter{s_resref := "ring17"|match=~"%s_resref%" == "ring02"~}
  ]

The same code, just with different items, does work on other area files.  DLCTEP reports that this area file has "non-standard order" but even if I save the area with DLCTEP the code still fails on it.

Link to comment

That's very odd, since I looked at the area in NI and compared the order of elements (the stuff with offset entries in the header) to some other areas. No difference. Sure, there's one empty element at offset zero (always potential trouble, there), but that same empty element was at offset zero in every area I checked.

Link to comment

str_eff_v2:

Offset for dicesize is off; should be 0x3c, not 0x34.  This one requires regenerating auto_struct.tpc

--- a/mih_sp/third_party/sfo2e/structures/str_eff_v2.2da
+++ b/mih_sp/third_party/sfo2e/structures/str_eff_v2.2da
@@ -14,7 +14,7 @@ probability1[100]             0x2c            short
 probability2                    0x2e           short
 resource                               0x30            ascii_8
 dicenumber                     0x38            long
-dicesize                               0x34            long
+dicesize                               0x3c            long
 save_vs_spells                         0x40            flag_0
 save_vs_breath                         0x40            flag_1
 save_vs_poison                         0x40            flag_2

 

Edited by Angel
Link to comment

There's nothing wrong with AR5500, it just happens to have an unusual structure that exposes a subtle bug in lib_struct (fixed locally). Hotfix: find this block

			PHP_EACH "SFO_%strtype%_parent_list" AS parent=>discard BEGIN
				PATCH_IF "%parent%" STR_CMP "null" BEGIN
					parent_count=$write_index("%parent%" "count")
					FOR (parent_ind=0;parent_ind<parent_count;++parent_ind) BEGIN
						PHP_EACH "SFO_%strtype%_parent_child_id" AS pc_id=>discard2 BEGIN
							PATCH_IF $"SFO_%strtype%_parent_child_data"("%pc_id%" "parent") STR_EQ "%parent%" BEGIN	
								SPRINT child $"SFO_%strtype%_parent_child_data"("%pc_id%" "child")
								index=$working_index("%child%") 
								SET $write_index("%parent%" "%parent_ind%" "%pc_id%" "index") = index
								count=$write_index("%parent%" "%parent_ind%" "%pc_id%" "count")
								PATCH_IF telemetry BEGIN
									PATCH_PRINT "%parent% %pc_id% %parent_ind%: %index% %count%"  
								END
								index += count
							END
							SET $working_index("%child%") = index
						END
					END
				END
			END

Change to this:

			PHP_EACH "SFO_%strtype%_parent_list" AS parent=>discard BEGIN
				PATCH_IF "%parent%" STR_CMP "null" BEGIN
					parent_count=$write_index("%parent%" "count")
					FOR (parent_ind=0;parent_ind<parent_count;++parent_ind) BEGIN
						PHP_EACH "SFO_%strtype%_parent_child_id" AS pc_id=>discard2 BEGIN
							PATCH_IF $"SFO_%strtype%_parent_child_data"("%pc_id%" "parent") STR_EQ "%parent%" BEGIN	
								SPRINT child $"SFO_%strtype%_parent_child_data"("%pc_id%" "child")
								index=$working_index("%child%") 
								SET $write_index("%parent%" "%parent_ind%" "%pc_id%" "index") = index
								count=$write_index("%parent%" "%parent_ind%" "%pc_id%" "count")
								PATCH_IF telemetry BEGIN
									PATCH_PRINT "%parent% %pc_id% %parent_ind%: %index% %count%"  
								END
								index += count
								SET $working_index("%child%") = index
							END
						END
					END
				END
			END

str_eff_v2: agreed, fixed locally.

Link to comment

str_cre_v1

Combined fields "ac" and "level_all" do not actually work due to missing commas.

--- a/mih_eq/third_party/sfo2e/structures/str_cre_v1.2da
+++ b/mih_eq/third_party/sfo2e/structures/str_cre_v1.2da
@@ -6,8 +6,8 @@ name_short                              0xc                     strref
 both_names                             -1                      multiple_name_long,name_short
 both_names-strref              -1                      multiple_name_long-strref,name_short-strref
 hp                                             -1                      multiple_hp_current,hp_max
-level_all                              -1                      multiple_level1_level2_level3
-ac                                             -1                  multiple_ac_natural_ac_effective
+level_all                              -1                      multiple_level1,level2,level3
+ac                                             -1                  multiple_ac_natural,ac_effective
 show_longname                  0x10            flag_0
 no_corpse                              0x10            flag_1
 permanent_corpse               0x10            flag_2

 

Edited by Angel
Link to comment

Join the conversation

You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...