Jump to content
jastey

BG1 coding tutorial

Recommended Posts

It was my mistake, I'm sorry. I have made some tests in BG1 now and you have right: for ADD_GAME_NPC the NPCLEVEL.2DA also get applied.

 

I have another question. What means "parchment" in LeaveAreaLUA (S:Area*,S:Parchment*,P:Point*,I:Face*)? In mods suitable for both pure BG1 and BGT/TUTU parchment is used for BG1 Version but not in BGT/TUTU. Maybe it schould be added to this tutorial, but what is importance of that?

Share this post


Link to post
What means "parchment" in LeaveAreaLUA (S:Area*,S:Parchment*,P:Point*,I:Face*)?
Thanks for testing. Saves me from having to do it :cool:.

 

No idea what "parchment" means. Anyone?

Share this post


Link to post
Guest Guest

107 MoveToOffset(P:Offset*) doesn't work in BG1+TotSC. It could be added to script but nothing happens during game.

Share this post


Link to post

Thank you Zed Nocear, sorry for the delay I'll add it to the tutorial.

 

Further, there have been findings that ADD_GAM_NPC is not a good idea to use at all:

ADD_GAM_NPC and uninstallation, non-functionality of .

So it seems that ADD_GAM_NPC, since it changes save-games, screws up the whole BG1 game, if the mod gets installed more than once. Since it is possible that a mod gets installed and deinstalled in one game installation (e.g. if the player decides to change the order of mods), this would lead to a malfunctioning NPC-creation (multiple times) if coded using ADD_GAM_NPC. Thank you Miloch and Red Carnelian for pointing this out!

I'll add the link and a comment in the tutorial that ADD_GAM_NPC is not recommended.

 

EDIT: Tutorial is updated concerning 107 MoveToOffset(P:Offset*) and ADD_GAM_NPC.

Edited by jastey

Share this post


Link to post

There's a lot of info here to sort through, especially for a non-coder like me, but I found this...

BG1 coding tutorial

... Post-dialogue of joinable NPCs

In BG1, the engine does not switch automatically from the joined dialogue "...J.dlg" to the post dialogue "...P.dlg" upon kickout. The kickout dialogue state is contained in the joined dialogue. Upon kickout, the post-dialogue has to be set via ~SetDialog("mynpcP")~. Upon joining, the dialogue is triggered via the post dialogue and the dialogue file is changed to the joined dialogue like in BGII.

An example: Ajantis' kickout dialogue is in his AJANTJ.dlg:

// this is what we say when we were just recently kicked out
IF ~Global("Waiting","LOCALS",0)
   !InParty(Myself)~ THEN BEGIN left SAY @103003 // It has been a pleasure adventuring with you. Well met, and farewell.
 IF ~~ THEN REPLY @103004 DO ~SetGlobal("Waiting","LOCALS",1)~ EXIT // wait here
 IF ~~ THEN REPLY @103002 DO ~JoinParty()~ EXIT    // "Please rejoin the party."
 IF ~~ THEN REPLY @103001 DO ~SetGlobal("Waiting","LOCALS",1)
                                                  RunAwayFromNoInterrupt([PC],2)
                                                  LeaveAreaLUA("AR2301","",[311.715],14)~ EXIT // FAI
END

I'd like to modify the kick-out dialogs of the 25 Bioware NPCs for the next BG1 Tweaks. When they leave, they stay where they were kicked out. Is it possible to get the same result by modifying the *j.dlg files? Is it possible to add two responses to their leaving comments, one to "remain here" and another to "meet us at..."?

 

My concern is two-fold: My ignorance of dialog coding, and I don't want to screw up the Ajantis, Xan or any other NPC mod dialogs since Tweaks get installed last...

Share this post


Link to post

I've been working with the SCS component Send NPCs to an Inn. I have found you can use:

IF ~~ THEN DO ~RunAwayFromNoInterrupt([PC],2)
LeaveAreaLUA("AR3304","",dmwwbereloc,0)~

However, to be able to limit it at the Gnoll Stronghold, Ice Island and the lower levels of Durlag's Tower, I've attempted to use this emulator.

 

I've run into a problem. I've used the code from both this thread and from the Ajantis Friendship mod. It fails. Here is the relevant portion of the Debug file:

Copying and patching 505 files ...

[./override/AR0002.ARE] loaded, 1472 bytes

[./override/MASTAREA.2DA] loaded, 1353 bytes

[./override/MASTAREA.2DA] loaded, 1353 bytes

Copying and patching 1 file ...

ERROR: error loading [newtweaks/baf/Z!EmulAreaCheck.BAF]

Stopping installation because of error.

Stopping installation because of error.

ERROR: [AR0002.ARE] -> [override/AR0002.ARE] Patching Failed (COPY) (Unix.Unix_error(20, "stat", "newtweaks/baf/Z!EmulAreaCheck.BAF"))

Stopping installation because of error.

 

ERROR Installing [NPCs go to inns], rolling back to previous state

[NewTweaks/backup/0/UNSETSTR.0] SET_STRING uninstall info not found

Will uninstall 439 files for [NEWTWEAKS/SETUP-NEWTWEAKS.TP2] component 0.

Have I missed something? I assume it can but just to make sure, can it be used with a negative such as:

!Global("Z!EmulAreaCheck","GLOBAL","AR5100")?

Share this post


Link to post
I assume it can but just to make sure, can it be used with a negative such as:

!Global("Z!EmulAreaCheck","GLOBAL","AR5100")?

Negative, yes, but if you want to check for AR5100, the variable has the value "5100".
AreaCheck()

For simulating AreaCheck(), the variable "Z!EmulAreaCheck" can be used: For the original BG areas, the value of the variable is equal to the "ARxxxx" number. For (mod) areas that are not named like the standard "ARxxxx", the variable is equal to "0".

For example, now the Area AR2600 can be detected via the trigger "Global("Z!EmulAreaCheck","GLOBAL",2600)".

 

I am not sure why there is your error message, did you check the path names etc.? It doesn't seem to find "newtweaks/baf/Z!EmulAreaCheck.BAF" in this path.

Share this post


Link to post

Thanks for the variable correction, jastey. Fixed.

 

Strange as it seems, I can't get that error to go away, even though "newtweaks/baf/Z!EmulAreaCheck.BAF" is properly pointed to. To make matters worse, I've another tweak I'm working on using this emulation, and it works with no trouble. I even copied the working code over with no effect. The only difference is the non-working is vanilla BG1, the working is with TotSC...

Share this post


Link to post
Thanks for the variable correction, jastey. Fixed.

 

Strange as it seems, I can't get that error to go away, even though "newtweaks/baf/Z!EmulAreaCheck.BAF" is properly pointed to. To make matters worse, I've another tweak I'm working on using this emulation, and it works with no trouble. I even copied the working code over with no effect. The only difference is the non-working is vanilla BG1, the working is with TotSC...

WeiDU's saying that it can't find the .baf file. Double-check that the files Z!EmulAreaCheck.BAF and Z!EmulAreaCheck1.BAF are named properly and in the right folder (this could be an issue with the tutorial - it doesn't include the prefixes when it describes the .baf files).

Share this post


Link to post
Double-check that the files Z!EmulAreaCheck.BAF and Z!EmulAreaCheck1.BAF are named properly and in the right folder (this could be an issue with the tutorial - it doesn't include the prefixes when it describes the .baf files).
Thank you, you are right! Tutorial is corrected.

Share this post


Link to post

Thanks, Mike1072. The BAF files were missing Z!, so no wonder it wouldn't work! :) Now it does! ;)

Share this post


Link to post

Now I have another problem, which I believe is linked to the area check emulator.

 

From the DEBUG file:

[NewTweaks/dlg/depart.d] loaded, 6160 bytes

Copied [NewTweaks/dlg/depart.d] to [override/dw#ajant.d]

Compiling 1 dialogue file ...

 

[override/dw#ajant.d] LEXER ERROR at line 76 column 1-4

Near Text: !

invalid character [!]

 

[override/dw#ajant.d] ERROR at line 76 column 1-4

Near Text: !

Parsing.Parse_error

ERROR: parsing [override/dw#ajant.d]: Parsing.Parse_error

ERROR: compiling [override/dw#ajant.d]!

Stopping installation because of error.

When I had it working without the emulator, this problem did not occur. I can find no "!" in any of the base code to create this problem.

 

I'll try creating the globals without the Z! in the code just to be sure. If it works, I will be certain to give proper attribution within and follow up on this post.

Share this post


Link to post

Something like that could alos be a forgotten tilde (~) before a negative global check or something. If you post the content of the .d, I can have a look.

Share this post


Link to post

No need. It was caused by an extra tilde. The tweak now works fully, and I've been given permission to include it in the next release of BG1 Tweaks.

 

Thanks for your patience and help.

Share this post


Link to post
BG1 coding tutorial

 

CreateCreature() For BG1:TotSC, the syntax for CrateCreature() is the same as in BGII: "CreateCreature("name",[x.y],0)", with "0" being the face orientation of the creature.

For BG1 without TotSC, there is no face orientation: "CreateCreature("name",[x.y])" is the correct syntax here.

To code for both in one file, the method described by cmorgan's "Crossing the Great Divide" tutorial using OUTER_SPRINT has to be used (see here for more details: crossing the great divide: Coding for BG1, Tutu and BGT).

This may be necro-posting, but I believe it's appropriate for this thread. I'm converting a component from BGT/TUTU to BG-TotSC, but for some reason the spawn does not occur. Help here would also give a concrete example of BG1 coding of spawns.

 

From the tp2:

 /* Area Scripts for spawning */
 COPY_EXISTING ~ar2301.bcs~ ~override~
			~ar4809.bcs~ ~override~
			~ar0705.bcs~ ~override~
 EXTEND_BOTTOM ~ar2301.bcs~ ~Bardic/baf/X#LP1REPAS.BAF~ //The Friendly Arm Inn
 EXTEND_BOTTOM ~ar4809.bcs~ ~Bardic/baf/X#LP2REPAS.BAF~ //The Belching Dragon
 EXTEND_BOTTOM ~ar0705.bcs~ ~Bardic/baf/X#LP3REPAS.BAF~ //The Elfsong

From the creature's baf file:

IF
Global("X#LP1RExists","GLOBAL",0)
Global("X#LakeP1RepTalk","GLOBAL",0)
THEN
 RESPONSE #100
CreateCreature("X#LP1REP",[542.592],0) // Lake Poet Sam  Friendly Arm Inn
SetGlobal("X#LP1RExists","GLOBAL",1)
END

IF
Global("X#TT1Deactivate","GLOBAL",1)
THEN
 RESPONSE #100
 SetGlobal("X#TT1Deactivate","GLOBAL",2)
 SetGlobalTimer("X#TroubadorTimer1","GLOBAL",THREE_DAYS)
 Wait(4)
 Deactivate("X#LP1REP")
END

IF
Global("X#TT1Deactivate","GLOBAL",2)
GlobalTimerExpired("X#TroubadorTimer1","GLOBAL")
THEN
 RESPONSE #100
 SetGlobal("X#TT1Deactivate","GLOBAL",0)
 Wait(4)
 Activate("X#LP1REP")
END

I'm focusing on this code since the creature, script and dialog all seem to install with no problem. I CreateCreature and everything works fine, it just does not spawn. The spawn code looks right to me...

 

Edit: I notice there are two GLOBALs called before the CreateCreature command. I don't find them created or set anywhere. Are they created when called, or do I need to create the GLOBALs somewhere?

Edited by grogerson

Share this post


Link to post
Guest
You are commenting as a guest. If you have an account, please sign in.
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.


×