Skip to content

General mod Questions thread

1333436383970

Comments

  • _Luke__Luke_ Member, Mobile Tester Posts: 1,535

    I think there is an ADD_KNOWN_SPELL/ADD_MEMORIZED_SPELL. (Search the Weidu readme to confirm.)

    I found them, thanks!
  • _Luke__Luke_ Member, Mobile Tester Posts: 1,535
    edited October 2018
    What's wrong with the following script block?
    IF
    	!GlobalTimerNotExpired("gt_detect_illusion","locals")
    	CheckStatGT(Myself,50,DETECTILLUSIONS)
    	!ModalState(DETECTTRAPS)
    	OR(13)
    		See(NearestEnemyOfType([0.0.0.0.0.ILLUSIONARY]))
    		StateCheck(NearestEnemyOf(Myself),STATE_MIRRORIMAGE)
    		StateCheck(SecondNearestEnemyOf(Myself),STATE_MIRRORIMAGE)
    		StateCheck(ThirdNearestEnemyOf(Myself),STATE_MIRRORIMAGE)
    		StateCheck(FourthNearestEnemyOf(Myself),STATE_MIRRORIMAGE)
    		StateCheck(NearestEnemyOf(Myself),STATE_INVISIBLE)
    		StateCheck(SecondNearestEnemyOf(Myself),STATE_INVISIBLE)
    		StateCheck(ThirdNearestEnemyOf(Myself),STATE_INVISIBLE)
    		StateCheck(FourthNearestEnemyOf(Myself),STATE_INVISIBLE)
    		StateCheck(NearestEnemyOf(Myself),STATE_IMPROVEDINVISIBILITY)
    		StateCheck(SecondNearestEnemyOf(Myself),STATE_IMPROVEDINVISIBILITY)
    		StateCheck(ThirdNearestEnemyOf(Myself),STATE_IMPROVEDINVISIBILITY)
    		StateCheck(FourthNearestEnemyOf(Myself),STATE_IMPROVEDINVISIBILITY)
    THEN
    	RESPONSE #100
    		SetGlobalTimer("gt_detect_illusion","locals",ONE_ROUND)
    		DisplayStringHead(Myself,~*Attempts to detect illusions*~)
    		FindTraps()

    I'm sure that CheckStatGT(Myself,50,DETECTILLUSIONS) and StateCheck(NearestEnemyOf(Myself),STATE_INVISIBLE) are true (I'm testing this script in the Watcher's Keep where there are the Anti-Paladins: some of them drink POTN10), still nothing happens (i.e., the CRE in question doesn't use FIND TRAPS.....)
  • GwendolyneGwendolyne Member Posts: 461
    "locals" should be "LOCALS", shouldn't it?
  • _Luke__Luke_ Member, Mobile Tester Posts: 1,535

    "locals" should be "LOCALS", shouldn't it?

    Still nothing.......
  • argent77argent77 Member Posts: 3,433
    It could be that object specifiers, such as NearestEnemyOf(), don't work with invisible creatures.

    Does this code work better?
    Detect([ENEMY]) OR(4) Gender(LastSeenBy(Myself),ILLUSIONARY) StateCheck(LastSeenBy(Myself),STATE_INVISIBLE) StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY) StateCheck(LastSeenBy(Myself),STATE_MIRRORIMAGE)
  • _Luke__Luke_ Member, Mobile Tester Posts: 1,535
    @argent77

    It's better now, thanks for your help!
  • _Luke__Luke_ Member, Mobile Tester Posts: 1,535
    edited October 2018
    What is the correct way of setting KIT (offset 0x244) for a certain CRE? I'm trying following the Big-endian notation, but I keep failing..... Let's consider KIT_ASSASSIN (0x400A0000) as an example: the following piece of code is wrong. Why?
    WRITE_BYTE 0x244    0x40
    WRITE_BYTE 0x245    0x0A
    WRITE_SHORT 0x246     0
  • [Deleted User][Deleted User] Posts: 0
    edited October 2018
    The user and all related content has been deleted.
  • RaduzielRaduziel Member Posts: 4,714
    Here is what I use for my mods (Charlatan as a model):

    COPY_EXISTING ~kitlist.2da~ ~override~
    COUNT_2DA_ROWS ~9~ "rows"
    FOR ( index = 31 ; index < rows ; index = index + 1 ) BEGIN
    READ_2DA_ENTRY "%index%" 5 9 "clab"
    PATCH_IF ("%clab%" STRING_COMPARE_CASE "RAChar" = 0) BEGIN
    READ_2DA_ENTRY "%index%" 0 9 "RAChar"
    SET "rows" = 0
    END
    END
    BUT_ONLY_IF_IT_CHANGES

    OUTER_SET kit = "%RAChar%"
    ACTION_FOR_EACH creature IN eldotd eldoth eldoth5 BEGIN

    ACTION_IF FILE_EXISTS_IN_GAME ~%creature%.cre~ THEN BEGIN

    COPY_EXISTING ~%creature%.cre~ ~override~
    WRITE_SHORT 0x244 0
    WRITE_BYTE 0x246 "%kit%"
    WRITE_BYTE 0x247 0x40
    BUT_ONLY

    END
    END

    //EoF
  • argent77argent77 Member Posts: 3,433
    Kits are encoded in a special way in CRE files. The high word of the kit value is written at offset 0x244, followed by the low word at offset 0x246.

    Example code for Assassin:
    SET kit_id = IDS_OF_SYMBOL(~kit~ ~ASSASIN~) WRITE_SHORT 0x244 (kit_id >> 16) & 0xffff WRITE_SHORT 0x246 kit_id & 0xffff
  • _Luke__Luke_ Member, Mobile Tester Posts: 1,535
    @argent77

    Thanks for clarifying, it works now....
  • _Luke__Luke_ Member, Mobile Tester Posts: 1,535
    edited October 2018
    1. ADD_MEMORIZED_SPELL doesn't seem to work with innate SPLs... The following piece of code does nothing:
      ADD_MEMORIZED_SPELL ~SPCL423~ #0 ~innate~ (4)

    2. What's the difference between LastSeenBy and LastSeenBy(Myself)? Does the former stand for "Last seen by anyone with my Allegiance (and not just myself)"?
  • The user and all related content has been deleted.
  • GwendolyneGwendolyne Member Posts: 461
    	ADD_KNOWN_SPELL ~spcl321~ #0 ~INNATE~							// Enrage
    	ADD_MEMORIZED_SPELL ~spcl321~ #0 ~INNATE~ #2
    works!
  • [Deleted User][Deleted User] Posts: 0
    edited October 2018
    The user and all related content has been deleted.
  • kjeronkjeron Member Posts: 2,367

    	ADD_KNOWN_SPELL ~spcl321~ #0 ~INNATE~							// Enrage
    	ADD_MEMORIZED_SPELL ~spcl321~ #0 ~INNATE~ #2
    works!
    Yeah but is the 2nd part even necessary? Shouldn't just making the innate known, make it usable?

    I'm thinking ADD_KNOWN is analogous to opcode 171: with an innate spell it will make it usable immediately. With a wizard spell, it will add it to your spellbook but you will still have to memorize it before you can cast it.
    Internally they still have to be memorized. Innates don't function too differently from priest/wizard spells in this regard. All Innates effectively just share the same "spell level", you just cannot manually alter which spells are memorized in which slot.
    Opcode 171 adds to the known list, to the memorized count, and the maximum memorized count, for innates. For wizard/priest spells, it just adds to the known list.

    Knowning an Innate isn't necessary to use it - it serves no purpose beyond the "HaveKnownSpell()" trigger.
  • _Luke__Luke_ Member, Mobile Tester Posts: 1,535

    	ADD_KNOWN_SPELL ~spcl321~ #0 ~INNATE~							// Enrage
    	ADD_MEMORIZED_SPELL ~spcl321~ #0 ~INNATE~ #2
    works!
    It's not working for me :( ....... I'm using the latest version of WeiDU (v246)
  • _Luke__Luke_ Member, Mobile Tester Posts: 1,535


    @Luke93 if you don't want to spend time fiddling with that, another way to achieve the same thing is to use ADD_CRE_EFFECT with opcode 171 to grant the innate ability. I use that a lot and it works fine.

    Yeah, you're right. If I use ADD_CRE_EFFECT with opcode #171, then ADD_MEMORIZED_SPELL works fine (I just need to put "#x - 1" because opcode #171 already gives you 1 charge....)

    Having said that, I think that ADD_MEMORIZED_SPELL should work even with innate SPLs (i.e., there is probably a bug in the current version of WeiDU.....)
  • RatatoskrRatatoskr Member Posts: 711
    Does anyone know if there's a different trick to naming the dream script files for TOB than SOA? The Tob dream script for Mazzy doesn't already exist, so I need to make one and I can't get it to trigger.

    The basic script file is Mazz25.bcs but I've tried Mazz25d.bcs and several other variations and none of them are working. The files install because I can see them in near infinity, but the script never actually goes off. My non dream scripts and the additional SOA scripts were all working fine.

    Suggestions?

    Also, on a related note, if the only thing I'm doing is changing a variable and but using and "myself" triggers, does it matter whose bcs file I put my code in? Could I just stick my dream scripts in the existing file of a different npc?
  • argent77argent77 Member Posts: 3,433
    Ratatoskr said:

    Does anyone know if there's a different trick to naming the dream script files for TOB than SOA? The Tob dream script for Mazzy doesn't already exist, so I need to make one and I can't get it to trigger.

    The basic script file is Mazz25.bcs but I've tried Mazz25d.bcs and several other variations and none of them are working. The files install because I can see them in near infinity, but the script never actually goes off. My non dream scripts and the additional SOA scripts were all working fine.

    Suggestions?

    NPC scripts are defined in PDIALOG.2DA. It looks like Mazzy uses MAZZYD.BCS for both SoA and ToB. The file doesn't exist in unmodded BG2EE though.

    You can probably define your own MAZZY25D.BCS and register it in PDIALOG.2DA. In this case you should make a copy of MAZZYD.BCS (if it exists) before adding your own content.
  • _Luke__Luke_ Member, Mobile Tester Posts: 1,535
    edited October 2018
    The following script block
    RESPONSE #50
            EquipRanged()
    	SelectWeaponAbility(SLOT_AMMO1,0)
    	AttackReevaluate(NearestEnemyOf(Myself),30)
    RESPONSE #50
            EquipRanged()
    	SelectWeaponAbility(SLOT_AMMO0,0)
    	AttackReevaluate(NearestEnemyOf(Myself),30)

    allows a certain CRE to make use of different ammos. The only problem is that the corresponding weapon slot is not selected (i.e., there is no green square around the launcher) ---> See the attached screenshot. Is this intended or a bug?
    Post edited by _Luke_ on
  • RatatoskrRatatoskr Member Posts: 711
    edited October 2018
    @argent77 Thanks for the quick reply. I can definitely try Mazzy25d.bcs again and see if that works. I thought I'd tried that one but maybe I'm missing a step.

    So, this may sound like a stupid question but how exactly do I register a script in the pdialog.2da? For all the other scripts, I just used extend_bottom in the tp2 and that worked even for the ones that didn't already exist in SOA. That's where mazzyd.bcs in my mod came from since it doesn't exist naturally.

    I should probably mention, I'm having the same issue with Korgand in TOB as well. But hopefully the same fix will work once I figure out his d script name.
  • argent77argent77 Member Posts: 3,433
    By default MAZZYD.BCS is registered as the dream script for Mazzy in SoA and ToB. So the simplest way is to add your script to that file (or create it if it doesn't exist yet).

    If you want to use another file, then you have to update the reference in PDIALOG.2DA. Look for the row starting with MAZZY. The seventh column (labeled as 25DREAM_SCRIPT_FILE) contains the name of the ToB dream script name for that character. Replace it with the new filename (without file extension).

    Korgan and many other NPCs are similar. They also don't have separate dream scripts for SoA and ToB, or none at all.
  • RatatoskrRatatoskr Member Posts: 711
    edited October 2018
    argent77 said:

    By default MAZZYD.BCS is registered as the dream script for Mazzy in SoA and ToB. So the simplest way is to add your script to that file (or create it if it doesn't exist yet).

    If you want to use another file, then you have to update the reference in PDIALOG.2DA. Look for the row starting with MAZZY. The seventh column (labeled as 25DREAM_SCRIPT_FILE) contains the name of the ToB dream script name for that character. Replace it with the new filename (without file extension).

    Korgan and many other NPCs are similar. They also don't have separate dream scripts for SoA and ToB, or none at all.

    So, it sounds like you're saying I could just put my tob d script code for those 2 in the same d.bcs files as my soa code, yeah? I'd just have to give them different triggers so I don't get any weird duplicates.

    Thank you. I'm going to try that. I'd rather not mess with the 2da if I can help it in case some other mod usees those same scripts.

    EDIT- That worked. Thank you. I knew it had to be something simple but I never would have checked the 2da file.
    Post edited by Ratatoskr on
  • _Luke__Luke_ Member, Mobile Tester Posts: 1,535
    What is wrong with the following script?

    IF
    	StateCheck(Myself,STATE_REALLY_DEAD)
    	THEN
    		RESPONSE #100
    			Wait(80)
    			ActionOverride(LastSummonerOf(Myself),AddSpecialAbility("GTALLY"))
    END


    It seems the Wait(80) command is ignored.... Why?
  • _Luke__Luke_ Member, Mobile Tester Posts: 1,535
    edited October 2018
    Now, this is really odd. If I write something like

    COMPILE ~path to my file/Xxxx.d~
    the resulting file is: Xxxx.D.dlg (Note the double extension) ----> Where that extra D comes from?
  • kjeronkjeron Member Posts: 2,367
    @Luke93 The filename of the resulting *.dlg file is defined by this statement within the *.d file:
    BEGIN ~filename~
  • The user and all related content has been deleted.
  • GwendolyneGwendolyne Member Posts: 461
    edited October 2018
    You can define many dialogs in one dialogs.d file
    
    BEGIN dialog1
     ...
    
    BEGIN dialog2
     ...
    
    BEGIN dialog3
     ...

    Compiling dialogs.d will result in creating as many dialogs you defined in it: dialog1.dlg, dialog2.dlg...
  • The user and all related content has been deleted.
Sign In or Register to comment.