Skip to content

General mod Questions thread

1404143454670

Comments

  • BubbBubb Member Posts: 1,000
    Opcode #318?
  • RaduzielRaduziel Member Posts: 4,714
    edited February 2019
    Bubb wrote: »
    Opcode #318?

    Thanks, that did the trick!
    Post edited by Raduziel on
  • RaduzielRaduziel Member Posts: 4,714
    edited February 2019
    Yup, me again.

    I have the following code that allows the infinite use of spells and that I'm using a lot for a kit:
    PATCH_IF (~%SOURCE_SIZE%~ > ~0x71~) BEGIN
    	READ_SHORT 0x1c spell_type
    PATCH_IF  (%spell_type% = 4) BEGIN
        READ_LONG 	0x64	ab_off			                             // Abilities Offset
    	READ_SHORT	0x68	ab_num			                             // Number of Abilities
    	READ_SHORT	0x6a	fx_off			                             // Effects Offset
    	READ_SHORT	0x70	glob_fx			                             // Number of Global Effects
    	SET	glob_add = 0
    
    INSERT_BYTES    (fx_off) 0x30
    	WRITE_SHORT (fx_off) 171			                             // opcode
    	WRITE_BYTE  (fx_off + 0x2) 1			                         // Target (self)
    	WRITE_LONG  (fx_off + 0xc) 9			                         // timing (Perm)
        WRITE_BYTE  (fx_off + 0x12) 100			                         // Probability 1
    	WRITE_ASCII (fx_off + 0x14) ~RADW71~                             // resource
    	++glob_add
    
    INSERT_BYTES    (fx_off) 0x30
    	WRITE_SHORT (fx_off) 172			                             // opcode
    	WRITE_BYTE  (fx_off + 0x2) 1			                         // Target (self)
    	WRITE_LONG  (fx_off + 0xc) 9			                         // timing (Perm)
        WRITE_BYTE  (fx_off + 0x12) 100			                         // Probability 1
        WRITE_ASCII (fx_off + 0x14) ~RADW71~                             // resource
    	++glob_add
    	
        glob_fx += glob_add
    	WRITE_SHORT 0x70 glob_fx			                             // Increment Number of Global Effects
    	FOR (i = 0; i < ab_num; ++i) BEGIN		                         // Offset Effect Index for all Abilities
    	  READ_SHORT (ab_off + i * 0x28 + 0x20) fx_idx
    	  WRITE_SHORT (ab_off + i * 0x28 + 0x20) (fx_idx + glob_add)
    	END
    END
    END
    

    I want to turn this code into a macro (LPM ~INFINITE_SPELLS~). The problem is, I have to define one variable (the spell that will have infinite uses - for the code above it is RADW71), so I know I can't just pack the thing inside a "DEFINE_PATCH_MACRO".

    How can I solve this situation?

    Thanks!
  • [Deleted User][Deleted User] Posts: 0
    edited February 2019
    The user and all related content has been deleted.
  • RaduzielRaduziel Member Posts: 4,714
    edited February 2019
    @subtledoctor

    Weird.

    Every time I use insert_point at the INT_VAR side I end up with several unwanted copies of the effect (three to five), but when I use it at the STR_VAR side of the function everything behaves fine: only one copy is added and the order is respected.

    Thanks for this beauty!

    I'll save it in my archive of macros and try to use it in my current project.
  • [Deleted User][Deleted User] Posts: 0
    edited February 2019
    The user and all related content has been deleted.
  • RaduzielRaduziel Member Posts: 4,714
    The unwanted copies thing happened to me using ADD_SPELL_EFFECT. Can only make the damn thing work as intended if I throw it on the STR side.

    Example:
    COPY_EXISTING ~RADWF.spl~ override
    LPF ADD_ABILITIES	 INT_VAR abil = 1 END
    LPF ADD_SPELL_EFFECT INT_VAR opcode = 55  target = 1 timing = 4 duration = 60 parameter1 = 1    parameter2 = 7  STR_VAR insert_point = 0  END
    LPF ADD_SPELL_EFFECT INT_VAR opcode = 62  target = 2 timing = 9               parameter1 = ~-1~ parameter2 = 1  STR_VAR insert_point = 1  END
    LPF ADD_SPELL_EFFECT INT_VAR opcode = 62  target = 2 timing = 9               parameter1 = ~-1~ parameter2 = 2  STR_VAR insert_point = 2  END
    LPF ADD_SPELL_EFFECT INT_VAR opcode = 62  target = 2 timing = 9               parameter1 = ~-1~ parameter2 = 4  STR_VAR insert_point = 3  END
    LPF ADD_SPELL_EFFECT INT_VAR opcode = 62  target = 2 timing = 9               parameter1 = ~-1~ parameter2 = 8  STR_VAR insert_point = 4  END
    LPF ADD_SPELL_EFFECT INT_VAR opcode = 62  target = 2 timing = 9               parameter1 = ~-1~ parameter2 = 16 STR_VAR insert_point = 5  END
    LPF ADD_SPELL_EFFECT INT_VAR opcode = 62  target = 2 timing = 9               parameter1 = ~-1~ parameter2 = 32 STR_VAR insert_point = 6  END
    LPF ADD_SPELL_EFFECT INT_VAR opcode = 62  target = 2 timing = 9               parameter1 = ~-1~ parameter2 = 64 STR_VAR insert_point = 7  END
    LPF ADD_SPELL_EFFECT INT_VAR opcode = 171 target = 2 timing = 9                                                 STR_VAR insert_point = 8  resource = SPPR150  END
    LPF ADD_SPELL_EFFECT INT_VAR opcode = 171 target = 2 timing = 9                                                 STR_VAR insert_point = 9  resource = SPPR250  END
    LPF ADD_SPELL_EFFECT INT_VAR opcode = 171 target = 2 timing = 9                                                 STR_VAR insert_point = 10 resource = SPPR350  END
    LPF ADD_SPELL_EFFECT INT_VAR opcode = 171 target = 2 timing = 9                                                 STR_VAR insert_point = 11 resource = SPPR450  END
    LPF ADD_SPELL_EFFECT INT_VAR opcode = 171 target = 2 timing = 9                                                 STR_VAR insert_point = 12 resource = SPPR550  END
    LPF ADD_SPELL_EFFECT INT_VAR opcode = 171 target = 2 timing = 9                                                 STR_VAR insert_point = 13 resource = SPPR650  END
    LPF ADD_SPELL_EFFECT INT_VAR opcode = 171 target = 2 timing = 9                                                 STR_VAR insert_point = 14 resource = SPPR750  END
    LPF ADD_SPELL_EFFECT INT_VAR opcode = 251 target = 2 timing = 1                                                 STR_VAR insert_point = 15 resource = ~RADW11~ END
    
  • RaduzielRaduziel Member Posts: 4,714
    What is the difference between the Charm from #5 and #241?

    Thanks!
  • BubbBubb Member Posts: 1,000
    edited February 2019
    Raduziel wrote: »
    What is the difference between the Charm from #5 and #241?

    Thanks!

    Absolutely nothing functionality wise - they actually redirect to the same code in the exe. The only difference is that the "immunity to opcode" and "remove opcode" effects can target each one separately.
  • kjeronkjeron Member Posts: 2,367
    Beyond that, Undead are given immunity to opcode 5, but not 241. Spells like Control Undead therefor use opcode 241, while charm/domination use opcode 5.
  • RaduzielRaduziel Member Posts: 4,714
    Thanks!
  • RaduzielRaduziel Member Posts: 4,714
    Let's say I have an HP table and I want to change every 1d8 entry to 1d6.

    Is there a ninja-coding-high-tech style to do so or I need to open the table, save it manually and all that jazz?

    I confess that since I've learned to use CREATE I dislike creating things outside of Weidu.
  • [Deleted User][Deleted User] Posts: 0
    edited February 2019
    The user and all related content has been deleted.
  • RaduzielRaduziel Member Posts: 4,714
    edited February 2019
    @subtledoctor
    COPY_EXISTING ~HPPRS.2da~ ~override\RAHPDW.2da~
    READ_2DA_ENTRY entry
    PATCH_IF entry = 8
    WRITE_2DA_ENTRY 6
    

    Just that? The highlight plugin for the Notepad++ is not recognizing this last command and I couldn't find it at the Weidu Readme

    I knew there was an easy way to do it.

    Thanks!

    Edit: Got it working with another thing
    COPY_EXISTING ~HPPRS.2da~ ~override\RAHPDW.2da~
    REPLACE_TEXTUALLY EXACT_MATCH ~8~ ~6~
    PRETTY_PRINT_2DA
    

    Now I've discovered that when the Weidu Readme says that something is applied to REGEXP it can also be applied to single files.
    Post edited by Raduziel on
  • RaduzielRaduziel Member Posts: 4,714
    Another general modding question:

    Let's say I have an array with X rows and Y columns.

    I want to learn how to look for a value at column Ya and:

    1) If it finds an exact match, delete the entire row.

    2) If it finds an exact match, change one entry in the row it belongs.

    Thanks!
  • [Deleted User][Deleted User] Posts: 0
    edited February 2019
    The user and all related content has been deleted.
  • RaduzielRaduziel Member Posts: 4,714
    @subtledoctor You keep underestimating my ignorance when it comes to Weidu.

    I'll see if a find some of those examples.

    Thanks!
  • The user and all related content has been deleted.
  • RaduzielRaduziel Member Posts: 4,714
    Undoubtedly. That and storing invisible arrays that allows multipatching ninja style.

    Thanks, all try it later!
  • BubbBubb Member Posts: 1,000
    edited February 2019
    swit wrote: »
    Only second block displays messages. No problems with See trigger. Probably worth reporting it on Beamdog redmine.

    I see you made a bug report. I've looked into it, and the problem is that while processing m_pendingTriggers, the engine doesn't make a copy of the trigger's CAIObjectType. When it runs Decode() it wipes out m_SpecialCase, preventing the structure from being properly decoded again. I think every trigger with an IDS value below 0x400A is affected.
  • switswit Member, Translator (NDA) Posts: 495
    edited February 2019
    Not sure if I understand "below" in this context correctly, but if Heard (0x002F) is also affected then that's another 80+ broken script blocks among vanilla BG:EE and BG2:EE, since Heard is often used with NearestMyGroupOfType :o@Bubb, if you have redmine account consider adding your insights to the report.
  • BubbBubb Member Posts: 1,000
    @swit: "Below" as in the value is numerically lower. Here's the list:
    0x0001 Acquired(S:ResRef*)
    0x0002 AttackedBy(O:Object*,I:Style*AStyles)
    0x0003 Help(O:Object*)
    0x0004 Joins(O:Object*)
    0x0005 Leaves(O:Object*)
    0x0006 ReceivedOrder(O:Object*,I:Order ID*)
    0x0007 Said(O:Object*,I:Dialog ID*)
    0x0008 TurnedBy(O:Object*)
    0x0009 Unusable(S:ResRef*)
    0x0020 HitBy(O:Object*,I:DameType*Damages)
    0x0021 HotKey(I:Key*HotKey)
    0x0022 TimerExpired(I:ID*)
    0x0024 Trigger(I:TriggerNum*)
    0x0025 Die()
    0x0026 TargetUnreachable(O:Object*)
    0x002F Heard(O:Object*,I:ID*SHOUTIDS)
    0x0033 BecameVisible()
    0x0036 OnCreation()
    0x004A Died(O:Object*)
    0x004B Killed(O:Object*)
    0x004C Entered(O:Object*)
    0x0052 Opened(O:Object*)
    0x0053 Closed(O:Object*)
    0x0054 Detected(O:Object*)
    0x0055 Reset(O:Object*)
    0x0056 Disarmed(O:Object*)
    0x0057 Unlocked(O:Object*)
    0x005C BreakingPoint()
    0x005D PickPocketFailed(O:Object*)
    0x005E StealFailed(O:Object*)
    0x005F DisarmFailed(O:Object*)
    0x0060 PickLockFailed(O:Object*)
    0x0070 Clicked(O:Object*)
    0x0087 TrapTriggered(O:Triggerer*)
    0x0088 PartyMemberDied(O:Object*)
    0x0091 SpellCast(O:Object*,I:Spell*Spell)
    0x0091 SpellCastRES(S:Spell*,O:Object*)
    0x0093 PartyRested()
    0x0097 Summoned(O:Object*)
    0x00A1 SpellCastOnMe(O:Caster*,I:Spell*Spell)
    0x00A1 SpellCastOnMeRES(S:Spell*,O:Caster*)
    0x00A6 SpellCastPriest(O:Object*,I:Spell*Spell)
    0x00A6 SpellCastPriestRES(S:Spell*,O:Object*)
    0x00A7 SpellCastInnate(O:Object*,I:Spell*Spell)
    0x00A7 SpellCastInnateRES(S:Spell*,O:Object*)
    0x00CC TookDamage()
    0x00D6 WalkedToTrigger(O:Object*)
    0x00EB CutSceneBroken()
    0x0101 reserved()

    All of those that use an object are subject to the bug. I've been able to fix it myself using an EEex hex edit; I'll make a note on your bug report what the problem is / how the devs could fix it.
  • RaduzielRaduziel Member Posts: 4,714
    edited February 2019
    Ok, here are two things I want to learn how to do:

    A-

    A1) Based on a text (or part of a text), identify the number of a string.

    A2) Replace this string's text for one of my own.

    ---

    B-

    I want to make a spell where a specific group of creatures (by Race of using General) completely ignores a character under this spell's effect unless this character takes hostile action against the aforementioned creature (that's why I can't just use #100).

    ---

    Thanks!
  • [Deleted User][Deleted User] Posts: 0
    edited February 2019
    The user and all related content has been deleted.
  • RaduzielRaduziel Member Posts: 4,714
    A-

    At the moment I'm using the STRING_SET option, but if for some reason the string change the thing will misbehave. So my idea was to let Weidu discover the string at the install to prevent this. Maybe I'm being overzealous.

    B- Damn.

    Thanks!
  • The user and all related content has been deleted.
  • The user and all related content has been deleted.
  • _Luke__Luke_ Member, Mobile Tester Posts: 1,535
    Or should I use 321 to cancel the 328 spell?

    I guess you can also use #337 (Remove opcode).......
  • [Deleted User][Deleted User] Posts: 0
    edited February 2019
    The user and all related content has been deleted.
  • RaduzielRaduziel Member Posts: 4,714
    edited February 2019
    Raduziel wrote: »
    At the moment I'm using the STRING_SET option, but if for some reason the string change the thing will misbehave. So my idea was to let Weidu discover the string at the install to prevent this. Maybe I'm being overzealous.

    Well it depends what string you're talking about. Some strings are findable in various ways... e.g. by parsing .2da files. Class strings are in clastext.2da/sodcltxt.2da; kit strings are in kitlist.2da; proficiency strings are in weapprof.2da; etc.

    In this case, I'm talking about a kit string. To be even more specific, about the kit description string.
Sign In or Register to comment.