Jump to content

TP2 file coding questions


svj

Recommended Posts

IF ~~ THEN BEGIN WaukeenAmbushCourt1
    SAY ~No time for courtesies? Alright we wish to negotiate peace deal with you.~
    IF ~~ THEN REPLY ~What!? Why would you do that?.~ GOTO WaukeenAmbushCourt2
    IF ~IsValidForPartyDialogue("rqrev")~ THEN REPLY ~What!? Why would you do that?.~ THEN EXTERN ~rqother~ RevanHarperLies
END

And in rqother.d i have

IF ~IsValidForPartyDialogue("rqrev")~ THEN BEGIN RevanHarperLies
    SAY ~(whispers in your ear) don't trust word of his. I know now who was behind these ambushes.~ THEN EXTERN ~rq4essli~ WaukeenAmbushCourt2
END

Is this proper way to write intejections for your NPCs

the second example is causing parsing error

Link to comment

I would recommend that you download and read the code for the Branwen NPC mod, which is a playable tutorial with extensive comments in each file to explain how it all works. As a newcomer to weidu I've found it very helpful -- though it's designed for people wanting to create a joinable NPC, but most of the ideas are still applicable.

The method for writing your own dialogue in which other characters chime in is different from writing a new interjection into existing game dialogue. Generally if you want to have multiple characters talking in a dialogue that you are writing from scratch, you need to use CHAIN, not SAY (see here for more on how CHAIN works).

Edited by moggadeet
Link to comment
15 hours ago, moggadeet said:

I would recommend that you download and read the code for the Branwen NPC mod, which is a playable tutorial with extensive comments in each file to explain how it all works. As a newcomer to weidu I've found it very helpful -- though it's designed for people wanting to create a joinable NPC, but most of the ideas are still applicable.

The method for writing your own dialogue in which other characters chime in is different from writing a new interjection into existing game dialogue. Generally if you want to have multiple characters talking in a dialogue that you are writing from scratch, you need to use CHAIN, not SAY (see here for more on how CHAIN works).

I got much more understanding from viewing one day NPCs and looking at the vanilla game code than from Branwen it just too bloated.

Link to comment
IF ~~ THEN BEGIN RevanNegotiateHarpers
    SAY ~We should talk to my good friend Rugos in Mithrest Inn he will track them for us. I know they do not have base in Athkatla but nearby.~
        IF ~~ THEN DO ~SetGlobal("rqRevanMintiper","GLOBAL",1)~
        EXIT
END

IF ~~ THEN BEGIN RevanBloodlust
    SAY ~Regardless we must find them and strike blow at their base.~ GOTO RevanNegotiateHarpers
END

[revan/d/rqrev.d] PARSE ERROR at line 218 column 1-74
Near Text: GOTO
       syntax error

[revan/d/rqrev.d]  ERROR at line 218 column 1-74
Near Text: GOTO
       Parsing.Parse_error
ERROR: parsing [revan/d/rqrev.d]: Parsing.Parse_error
ERROR: compiling [revan/d/rqrev.d]!
Stopping installation because of error.


SAY triggers parse_error

SAY ~Regardless we must find them and strike blow at their base.~ GOTO RevanNegotiateHarpers

 

Both snippets are in same file rqrev.d

Edited by svj
Link to comment
rqrev.d
IF ~~ THEN BEGIN RevanNiceBunch
    SAY ~What a nice bunch you are. Just for the record say you acted preemptively.~
    IF ~~ THEN EXTERN ~rq5minti~ MintiperPreemptive
END

rq5minti.d
IF ~~ THEN BEGIN MintiperPreemptive
    SAY ~Yes and i don't regret anything we would do it again! Filthy mercenary we already were on your tail for other things you have done! IT WAS preemptive action!~
    IF ~~ THEN REPLY ~What do you mean?~ GOTO MintiperLegrondPlot
END

ERROR: Cannot resolve external symbolic label [MintiperPreemptive] for DLG [RQ5MINTI]
ERROR: postprocessing [RQREVJ]: Failure("cannot resolve label")
Stopping installation because of error.


Is there list of Weidu compiler errors?

Link to comment

Is your code snippet what you have inside a d-file? This cannot work, you need to comment out the "xyz.d" lines.

The error message means that the specified state name is not inside the dlg you are calling it from. If it is in another dlg you need to use EXTERN dlgname to transfer to it.

If you have two characters talking to each other, I'd recommend using CHAIN syntax, though.

I can only repeat that it is hard (for me) to understand what exactly you did and where the error came from. Your info is scarce and fragmented and I also can't tell whether you took any of our suggestions (e.g. weidu readme etc.) into account.

Link to comment
//rqrev.d
IF ~~ THEN BEGIN RevanNiceBunch
    SAY ~What a nice bunch you are. Just for the record say you acted preemptively.~
    IF ~~ THEN EXTERN ~rq5minti~ MintiperPreemptive
END

//rq5minti.d
IF ~~ THEN BEGIN MintiperPreemptive
    SAY ~Yes and i don't regret anything we would do it again! Filthy mercenary we already were on your tail for other things you have done! IT WAS preemptive action!~
    IF ~~ THEN REPLY ~What do you mean?~ GOTO MintiperLegrondPlot
END

These rqrev.d and rq5minti are just file names

Link to comment
// mintiper vs revan interaction in umar hills
BEGIN r5qminti

IF ~Global("rqRevanMintiper","GLOBAL",3)
    See("rqrev")
    Inparty("rqrev")
    !StateCheck("rqrev",STATE_SLEEPING)
    ~
    THEN BEGIN MintiperIntro
    SAY ~So you're the group who have killed my friends. For this i shall see you ended. None of my friends shall die to the likes of you!~
    IF ~~ THEN REPLY ~I did enjoy defeating your feeble ambush attempts.~ GOTO MintiperAttack
    IF ~~ THEN REPLY ~Wait i would like to know why all this?~ GOTO MintiperExplains
    IF ~~ THEN REPLY ~Lets make deal if you will stop your attacks against me i will pay you gold.~ GOTO MintiperBribeAttempt
    IF ~Alignment(Player1,MASK_GOOD)~ THEN REPLY ~Is there any compassion i am genuinely good person lets settle this nonviolently.~ GOTO MintiperAttack
END

IF ~~ THEN BEGIN MintiperBribeAttempt
    SAY ~Who do you think you are dealing with we are Harpers we do not take bribes!~
    IF ~~ THEN GOTO MintiperExplains
END

IF ~~ THEN BEGIN MintiperExplains
    SAY ~Revan and i know each other from Moonsea he was leader of quite unscrupulous mercenary group. We received news about his plot to rob our alchemist. So we took most precious stone and pinned the theft on Revan.~
    =
    ~Some nobles are our allies so we had to put pressure on them for our cause to succeed. Victory i thought but then he escaped from jail...~
    =
    ~Subsequently he ran away to Athkatla and then he hired you.~
    IF ~~ THEN EXTERN ~rqrevJ~ RevanNiceBunch
END

IF ~~ THEN BEGIN RevanNiceBunch
    SAY ~What a nice bunch you are. Just for the record say you acted preemptively.~
    IF ~~ THEN EXTERN ~rq5minti~ MintiperPreemptive
END

IF ~~ THEN BEGIN MintiperPreemptive
    SAY ~Yes and i don't regret anything we would do it again! Filthy mercenary we already were on your tail for other things you have done! IT WAS preemptive action!~
    IF ~~ THEN REPLY ~What do you mean?~ GOTO MintiperLegrondPlot
END

IF ~~ THEN BEGIN MintiperLegrondPlot
    SAY ~He raided and murdered through countryside for cruel noble Ledrael his trail of destruction through countryside...~
    IF ~~ THEN EXTERN ~rqrevJ~ RevanCallsDownLofty
END

IF ~~ THEN BEGIN RevanCallsDownLofty
    SAY ~Ridiculous! Your pinning of alchemists robbery on me you hoped to turn Ledrael against me and disrupt his campaign.~
    =
    ~You are not some righteous group you are just one of power struggle players if i recall correctly you had ties with Ledreaels enemies!~
    IF ~~ THEN EXTERN ~rq5minti~ MintiperEndJustifies
END

IF ~~ THEN BEGIN MintiperEndJustifies
    SAY ~If your elimination would have ceased these raids it would have been worth it!~
    IF ~~ THEN EXTERN ~rqrevJ~ RevanPointsOutFailure
END

IF ~~ THEN BEGIN RevanPointsOutFailure
    SAY ~Well you failed spectacularly as my removal put in charge of my company Raymond and he is more cruel then i ever was.~
    =
    ~Which explains why you are here. With my death your involvement in failed plot will never surface.~
    IF ~~ THEN EXTERN ~rq5minti~ MintiperAttack
END

IF ~~ THEN BEGIN MintiperAttack
    SAY ~YOUR WORDS DO NOT MATTER YOU MURDERED MY FRIENDS!!! DIE!!!~
    DO ~Enemy()
    SetGlobal("rqContractsRugosAvailable","GLOBAL",1)
    SetGlobal("rq5MintipBattle","GLOBAL",1)~
END
EXIT

I have joined the dialogue files together to understand the whole interaction

Link to comment
// copying spells is in my TP2
COPY ~/revan/spl/rqmaze.spl~ ~override/rqmaze.spl~
COPY ~/revan/spl/rqlunge.spl~ ~override/rqlunge.spl~
COPY ~/revan/spl/rqpoiso.spl~ ~override/rqpoiso.spl~

Checking for required files ...
Copying and patching 1 file ...
Extending game scripts ...
Copying 1 file ...
ERROR: error loading [/revan/spl/rqmaze.spl]
Stopping installation because of error.

ERROR Installing [Golden Horse mercenary company (Requires Throne of Bhaal)], rolling back to previous state
Will uninstall   2 files for [SETUP_REVAN.TP2] component 0.
Uninstalled      2 files for [SETUP_REVAN.TP2] component 0.
ERROR: Unix.Unix_error(20, "stat", "/revan/spl/rqmaze.spl")

Anyone has idea what is this error?
 

Edited by svj
removed misleading mod name
Link to comment

Earlier i said i would like  to manipulate CHITIN.KEY  directly and here i am.

Checking for required files ...
~~abbrevitated~~
Appending to files ...
Compiling 1 dialogue file ...

ERROR locating resource for 'CHAIN3'
Resource [RQREVJ.DLG] not found in KEY file:
       [./chitin.key]
ERROR: preprocessing APPEND_EARLY [revan/d/rq1cappr.d]: Failure("resource [RQREVJ.DLG] not found for 'CHAIN3'")
Stopping installation because of error.

ERROR Installing [Golden Horse mercenary company (Requires Throne of Bhaal)], rolling back to previous state
Will uninstall  21 files for [SETUP_REVAN.TP2] component 0.
Uninstalled     21 files for [SETUP_REVAN.TP2] component 0.
ERROR: Failure("resource [RQREVJ.DLG] not found for 'CHAIN3'")

Why it is searching for rqrevj.dlg which is not compiled as this is the first file which weidu selected for compilation
 

Edited by svj
Link to comment
On 9/27/2023 at 4:34 PM, jmerry said:

To quote the WeiDU documentation:

Your snippet above creates a new dialogue file rq2riba.DLG. Which, if you want to insert stuff into Ribald's existing dialogue, is not what you want. Either you're assigning that new dialogue to Ribald and losing all his old dialogue, or you're not assigning the new dialogue and it might as well not be there. If you want to edit an existing dialogue file, you don't use (top-level) BEGIN at all. For example, here's a D file from my tweak mod:

  Reveal hidden contents
ADD_TRANS_ACTION PETRIN BEGIN 1 END BEGIN END ~SetGlobal("J8#BherenNote","GLOBAL",1)~

ADD_TRANS_ACTION RINNIE BEGIN 1 END BEGIN END ~SetGlobal("J8#RinnieNote","GLOBAL",1)~

ADD_TRANS_ACTION FENTEN BEGIN 1 2 END BEGIN END ~SetGlobal("J8#FentenNote","GLOBAL",1)~

ADD_TRANS_ACTION NIKLOS BEGIN 8 END BEGIN END ~SetGlobal("J8#TalkedToNiklos","GLOBAL",1)~

ADD_TRANS_ACTION JOIA BEGIN 4 END BEGIN END ~SetGlobal("J8#JoiaNote","GLOBAL",1)~

ADD_TRANS_ACTION MIRIAN BEGIN 0 END BEGIN END ~SetGlobal("J8#MirianneNote","GLOBAL",1)~

ADD_TRANS_ACTION LANDRI BEGIN 0 1 2 END BEGIN END ~SetGlobal("J8#TalkedToLandrin","GLOBAL",1)~

 

No new states or replies there; I'm just editing existing transitions to add variable-setting actions. And editing a bunch of different dialogues in the same D file.

What you're doing here - new states and transitions from them - looks like work for the APPEND command:

No BEGIN there. You'd just do "APPEND RIBALD [your states] END"

APPEND  ~ribald.dlg~ ~revan/d/rq2ribald.d~
~RibaldQuestionAboutRing~
~RibaldTheathre1~
~RibaldTheathre2~
~RibaldTheathre3~
~RibaldTheathre4~
~RibaldRingSell~
~RibaldGetRing~
~RibaldNoMoney~
~RibaldHadNoMoney~
~RevanAfterRibaldTalk2~
~RevanAfterRibaldTalk3~
~RevanAfterRibaldTalk4~
~RevanAfterRibaldTalk5~
~RibaldRelieved~
~RibaldBegging~
~RibaldProtests~
~RibaldEscalation~
END

Is there mod in which this kind appending is performed so i can pinch its tp2 code?

Code above is triggering parsing error

Link to comment

From cdtweaks, in the component that lets Cespenar do the SoA crafts, I bring you part of cespy7.d:

APPEND BOTSMITH              

  IF ~~ THEN BEGIN silver SAY @123006
    IF ~PartyHasItem("misc8u")
        PartyHasItem("sw2h15a")~ THEN GOTO silver_want
    IF ~!PartyHasItem("sw2h15a")~ THEN GOTO silver_need_hilt
    IF ~!PartyHasItem("misc8u")~ THEN GOTO silver_need_blade
  END
  
  IF ~~ THEN BEGIN silver_need_hilt SAY @123007
    COPY_TRANS BOTSMITH 4
  END
  
  IF ~~ THEN BEGIN silver_need_blade SAY @123008
    COPY_TRANS BOTSMITH 4
  END
  
  IF ~~ THEN BEGIN silver_want SAY @123009           
    IF ~PartyGoldLT(7500)~ THEN REPLY #66908 GOTO 10
    IF ~PartyGoldGT(7499)~ THEN REPLY #66909 DO ~SetGlobal("CDItemMakerTweaks","GLOBAL",7)
                                                 TakePartyGold(7500)
                                                 TakePartyItemNum("misc8u",1)
                                                 DestroyItem("misc8u")
                                                 TakePartyItemNum("sw2h15a",1)
                                                 DestroyItem("sw2h15a")
                                                 DestroyGold(7500)~ GOTO 11
    IF ~~ THEN REPLY #66910 GOTO silver_stall
  END          
  
  IF ~~ THEN BEGIN silver_stall SAY @123010
    COPY_TRANS BOTSMITH 4
  END

END                                            
  

First, note that that's not the whole file; there's also an EXTEND_BOTTOM block before this APPEND block. A .d file can do multiple things.

Second, note that this is a .d file, not a .tp2 file. The tp2 command associated with it is just

COMPILE ~cdtweaks/dlg/cespy7.d~

And finally, you put everything about those new states in. Their text, where the conversation jumps to, any actions. You're appending to a dialogue, and you need to fully describe what you're adding.

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...