Jump to content


Photo

BG1 coding tutorial


48 replies to this topic

#16 Zed Nocear

Zed Nocear
  • Members
  • 31 posts
  • Gender:Male

Posted 01 June 2008 - 03:10 PM

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?

#17 Miloch

Miloch

    Barbarian

  • Modders
  • 4749 posts
  • Gender:Male
  • Location:At Large

Posted 02 June 2008 - 05:07 PM

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?
Infinity Engine Contributions
Aurora * BG1 NPC * BG1 Fixpack * Haiass * Infinity Animations * Level 1 NPCs * P5Tweaks
PnP Free Action * Thrown Hammers * Unique Containers * BG:EE * BGII:EE * IWD:EE
================================================================
Player & Modder Resources
BAM Batcher * Creature Lister * Creature Checker * Creature Fixer * Tutu/BGT Area Map & List * Tutu Mod List
================================================================
"The trouble with having an open mind, of course, is that people will insist on coming along and trying to put things in it." -Terry Pratchett

#18 Guest_Guest_*

Guest_Guest_*
  • Guests

Posted 18 June 2008 - 04:48 AM

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

#19 jastey

jastey
  • Gibberlings
  • 5370 posts
  • Gender:Female

Posted 19 June 2008 - 10:25 AM

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, 19 June 2008 - 10:52 AM.


#20 grogerson

grogerson

    Blithering Idiot and BG1 Tweaks Scavanger

  • Members
  • 758 posts
  • Gender:Male
  • Location:Near Salt Lake City, UT

Posted 27 October 2008 - 05:13 PM

There's a lot of info here to sort through, especially for a non-coder like me, but I found this...
[quote name='jastey' post='118548' date='Mar 30 2008, 04:47 AM']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 outIF ~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 // FAIEND
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...
It is an outrage that they should be commonly spoken of as Intellectuals. This gives them the chance to say that he who attacks them attacks Intelligence. It is not so. . . . It is not excess of thought but defect of fertile and generous emotion that marks them out. Their heads are no bigger than the ordinary: it is the atrophy of the chest beneath that makes them seem so.

And all the time, such is the tragi-comedy of our situation, we continue to clamour for those very qualities we are rendering impossible. . . . In a sort of ghastly simplicity we remove the organ and demand the function. We make men without chests and expect of them virtue and enterprise. We laugh at honour and are shocked to find traitors in our midst. We castrate and bid the geldings be fruitful.

C.S. Lewis, The Abolition of Man

#21 grogerson

grogerson

    Blithering Idiot and BG1 Tweaks Scavanger

  • Members
  • 758 posts
  • Gender:Male
  • Location:Near Salt Lake City, UT

Posted 19 December 2008 - 08:10 PM

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")?

It is an outrage that they should be commonly spoken of as Intellectuals. This gives them the chance to say that he who attacks them attacks Intelligence. It is not so. . . . It is not excess of thought but defect of fertile and generous emotion that marks them out. Their heads are no bigger than the ordinary: it is the atrophy of the chest beneath that makes them seem so.

And all the time, such is the tragi-comedy of our situation, we continue to clamour for those very qualities we are rendering impossible. . . . In a sort of ghastly simplicity we remove the organ and demand the function. We make men without chests and expect of them virtue and enterprise. We laugh at honour and are shocked to find traitors in our midst. We castrate and bid the geldings be fruitful.

C.S. Lewis, The Abolition of Man

#22 jastey

jastey
  • Gibberlings
  • 5370 posts
  • Gender:Female

Posted 20 December 2008 - 12:08 AM

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.

#23 grogerson

grogerson

    Blithering Idiot and BG1 Tweaks Scavanger

  • Members
  • 758 posts
  • Gender:Male
  • Location:Near Salt Lake City, UT

Posted 21 December 2008 - 06:24 PM

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...
It is an outrage that they should be commonly spoken of as Intellectuals. This gives them the chance to say that he who attacks them attacks Intelligence. It is not so. . . . It is not excess of thought but defect of fertile and generous emotion that marks them out. Their heads are no bigger than the ordinary: it is the atrophy of the chest beneath that makes them seem so.

And all the time, such is the tragi-comedy of our situation, we continue to clamour for those very qualities we are rendering impossible. . . . In a sort of ghastly simplicity we remove the organ and demand the function. We make men without chests and expect of them virtue and enterprise. We laugh at honour and are shocked to find traitors in our midst. We castrate and bid the geldings be fruitful.

C.S. Lewis, The Abolition of Man

#24 Mike1072

Mike1072
  • Gibberlings
  • 1771 posts
  • Gender:Male
  • Location:Canada

Posted 21 December 2008 - 08:02 PM

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

#25 jastey

jastey
  • Gibberlings
  • 5370 posts
  • Gender:Female

Posted 22 December 2008 - 02:16 AM

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.

#26 grogerson

grogerson

    Blithering Idiot and BG1 Tweaks Scavanger

  • Members
  • 758 posts
  • Gender:Male
  • Location:Near Salt Lake City, UT

Posted 22 December 2008 - 06:42 PM

Thanks, Mike1072. The BAF files were missing Z!, so no wonder it wouldn't work! :) Now it does! ;)
It is an outrage that they should be commonly spoken of as Intellectuals. This gives them the chance to say that he who attacks them attacks Intelligence. It is not so. . . . It is not excess of thought but defect of fertile and generous emotion that marks them out. Their heads are no bigger than the ordinary: it is the atrophy of the chest beneath that makes them seem so.

And all the time, such is the tragi-comedy of our situation, we continue to clamour for those very qualities we are rendering impossible. . . . In a sort of ghastly simplicity we remove the organ and demand the function. We make men without chests and expect of them virtue and enterprise. We laugh at honour and are shocked to find traitors in our midst. We castrate and bid the geldings be fruitful.

C.S. Lewis, The Abolition of Man

#27 grogerson

grogerson

    Blithering Idiot and BG1 Tweaks Scavanger

  • Members
  • 758 posts
  • Gender:Male
  • Location:Near Salt Lake City, UT

Posted 23 December 2008 - 06:42 PM

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.
It is an outrage that they should be commonly spoken of as Intellectuals. This gives them the chance to say that he who attacks them attacks Intelligence. It is not so. . . . It is not excess of thought but defect of fertile and generous emotion that marks them out. Their heads are no bigger than the ordinary: it is the atrophy of the chest beneath that makes them seem so.

And all the time, such is the tragi-comedy of our situation, we continue to clamour for those very qualities we are rendering impossible. . . . In a sort of ghastly simplicity we remove the organ and demand the function. We make men without chests and expect of them virtue and enterprise. We laugh at honour and are shocked to find traitors in our midst. We castrate and bid the geldings be fruitful.

C.S. Lewis, The Abolition of Man

#28 jastey

jastey
  • Gibberlings
  • 5370 posts
  • Gender:Female

Posted 23 December 2008 - 11:42 PM

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.

#29 grogerson

grogerson

    Blithering Idiot and BG1 Tweaks Scavanger

  • Members
  • 758 posts
  • Gender:Male
  • Location:Near Salt Lake City, UT

Posted 24 December 2008 - 06:57 PM

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.
It is an outrage that they should be commonly spoken of as Intellectuals. This gives them the chance to say that he who attacks them attacks Intelligence. It is not so. . . . It is not excess of thought but defect of fertile and generous emotion that marks them out. Their heads are no bigger than the ordinary: it is the atrophy of the chest beneath that makes them seem so.

And all the time, such is the tragi-comedy of our situation, we continue to clamour for those very qualities we are rendering impossible. . . . In a sort of ghastly simplicity we remove the organ and demand the function. We make men without chests and expect of them virtue and enterprise. We laugh at honour and are shocked to find traitors in our midst. We castrate and bid the geldings be fruitful.

C.S. Lewis, The Abolition of Man

#30 grogerson

grogerson

    Blithering Idiot and BG1 Tweaks Scavanger

  • Members
  • 758 posts
  • Gender:Male
  • Location:Near Salt Lake City, UT

Posted 05 December 2010 - 05:56 PM

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, 06 December 2010 - 06:06 PM.

It is an outrage that they should be commonly spoken of as Intellectuals. This gives them the chance to say that he who attacks them attacks Intelligence. It is not so. . . . It is not excess of thought but defect of fertile and generous emotion that marks them out. Their heads are no bigger than the ordinary: it is the atrophy of the chest beneath that makes them seem so.

And all the time, such is the tragi-comedy of our situation, we continue to clamour for those very qualities we are rendering impossible. . . . In a sort of ghastly simplicity we remove the organ and demand the function. We make men without chests and expect of them virtue and enterprise. We laugh at honour and are shocked to find traitors in our midst. We castrate and bid the geldings be fruitful.

C.S. Lewis, The Abolition of Man



Reply to this topic



  


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users