Help - Search - Members - Calendar
Full Version: BG1 coding question :)
The Black Wyrm's Lair - Forums > Mod development resources & discussion > Modder's Workshop
jastey
Hi,
I have two questions to BG1 coding:
1. If I want to have a nice visual effect, e.g. one creature dissappears with a lot of glowing light.. whatever, how do I code that? (For BGII, I would use:
CODE
CreateVisualEffectObject("effect",Myself)
Is there something similar for BG1?)
2. I have problems to put an item into an existing container. I have the following code in the area.baf:
CODE
 
IF
   Global("C#ItemInTruhe","GLOBAL",0)
THEN
   RESPONSE #100
         SetGlobal("C#ItemInTruhe","GLOBAL",1)
         ActionOverride("Container1",CreateItem("ITEM",0,0,0))
END

which is the only way I see, but this puts the item in front of the container. How would the correct code have to be, to place the item inside?

Thanks!
PS: Answers as soon as possible, please... rolleyes.gif
Baronius
I will look into these problems.

Quickly examining the first one, there might be an indirect solution: make the creature cast a spell by himself/herself before disappearing, and the spell's graphical effect must be set to the one you want. Thus, you have to make your own spell for this, and since there is no ForceSpellRES in BG1, you have to use the item trick (make a 'wand' so an item usable by the creature, and add the effect 'Cast Spell as Target', see the BG1 Practical Scripting guide for more information on this), and make the creature use that item before (s)he disappears.

So (s)he uses the item -> spell is cast -> graphical effects appear.

I'm not sure what you mean by 'disappear'. Do you 'force' him/her to disappear, with a script, e.g. in a cutscene? Or do you mean normal death (so when the creature dies)?
jastey
Hi Baronius,
thanks for the fast reply!
Well, a spell I've never done before... Can I do it like an item via NI? How do I make a spell in BG1 with a nice visual effect but no real impact, where do I find the visual effects.. Does there exist a tutorial on that somewhere (or do you want to describe it briefly to me...)?...
With "disappear" I mean vanish: before, the creature is there - visual effect - creature gone (DestroySelf())

And talking about cutscenes: I tried to start one by calling the following code in a dialogue file:
CODE
DO ~
StartCutScene("mycutscene")
StartCutSceneMode()~ EXIT

and the script-file "mycutscene" would look like:
CODE
IF
   True()
THEN
   RESPONSE #100
       CutSceneId("creature1")
       SetGlobal("variable","GLOBAL",1)
       DestroySelf()
       CreateCreature("creature2",[300.250],0)
       EndCutSceneMode()
END


But I guess that's BGII code again, as the cutscene didn't work. It changed to cutscene mode all right, but after that nothing happened.
I also wanted to inlude something like
CODE
ActionOverride("creature2",DisplayString(Myself,~text~))

But this gives me syntax error...
Rabain
It's probably best to start a cutscene by running your StartCutSceneMode() from a script (the script of the person saying the dialogue). Use a DO ~SetGlobal()~ in the dialogue to trigger the script

Also use StartCutSceneMode() before StartCutScene().

And you should be able to get strings to display in the cutscene using:

ActionOverride("bwcallum",DisplayStringHead(Myself,~Dawnbringer Sain, I am Callum.~))
Wait(1)
ActionOverride("scsain",DisplayStringHead(Myself,~Ah Yes, the Paladin of Amaunator, we have been expecting you!~))

Likewise if you are using DestroySelf() you should be able to copy the code above as

ActionOverride("creature1",DestroySelf()) /// i have just checked and this is indeed used in several scripts in BG1
Baronius
Jastey, as for the visual effect creation (choosing from a list), I've used DLTCEP so far. It's easy to do a spell, and even easier to load an existing one, delete its effects but add the visual effect. To tell the truth, I've never done this before, but I think that choosing an animation (there is a list) as a value for the 'projectile animation' field, under Extended effects subpage, will work.
(What I did was changing the spell's casting school graphics, so when the spell is cast, you see a specific animation depending on the school of the spell. This visual effect can easily be changed by changing the spell's school.)

Be careful though with the DisplayStringHead, because it does not work in Baldur's Gate 1!
Rabain
These examples are from BG1 scripts with regard to DisplayString as DisplayStringHead() does not appear in BG1 (thanks for pointing this out Baronius!)

I'm not sure but i think DisplayString also shows the dialog in the dialog window though i am almost also sure that it displays as floating text! (almost sure!)

Also it would appear from these that the DisplayString() works best when it is in the script of the creature/object it is to be displayed above.
/////
IF
Opened([ANYONE])
See([PC.0.0.MAGE])
THEN
RESPONSE #100
DisplayString([PC.0.0.MAGE],14381) // Trap Sprung
ForceSpell([PC.0.0.MAGE],TRAP_MISCAST_MAGIC)
END

//////

IF
Global("SemajBehavior","GLOBAL",3)
See([PC])
THEN
RESPONSE #100
DisplayString(Myself,24099) // Magic Staff Released
ReallyForceSpell(Myself,WIZARD_MIRROR_IMAGE)
DisplayString(Myself,24098) // Tattoo of Power Released
ReallyForceSpell([PC],WIZARD_CHAOS)
Spell([PC],WIZARD_CLOUDKILL)
SetGlobal("SemajBehavior","GLOBAL",4)
END

//////

IF
Clicked([ANYONE])
Global("UseAnvil","GLOBAL",0)
Range(LastTrigger,9)
THEN
RESPONSE #100
SetGlobal("UseAnvil","GLOBAL",1)
DisplayString(Myself,23170) // A forge, commonly used to make or repair tools.
END

///////
jastey
Thanks guys! smile.gif
I think I know enough to start trying to code a cutscene and a visual effect in BG1. I will play around with it a bit (it's too late now for the contest, but anyhow...), and once I have more specific questions I will ask you again smile.gif
jastey
Here is what Rabain gave me for the cutscene and the visual effect. Thanks, Rabain! I put it here to make the thread complete. It's a cutscene where "creature1" is transformed into "creature2" showing the visual effect "RED_HOLY_MIGHT" (the first part goes into the dialogue-file of creature1, the second into the area script):

CODE
IF ~True()~ THEN dialogue_01
SAY @0
++ @1 EXIT
+ ~PartyHasItem("elexir")~ + @2 DO ~SetGlobal("C#transformation","GLOBAL",1)~ EXIT
END
////

///script file c#ar3344.baf

IF
Global("C#transformation","GLOBAL",1)
THEN
RESPONSE #100
ClearAllActions()
SetGlobal("C#transformation","GLOBAL",2)
CutSceneId(Player1)
StartCutSceneMode()
TakePartyItem("elexir")
ForceSpellPoint([xxx.yyy],RED_HOLY_MIGHT)
ActionOverride("creature1",DestroySelf())
Wait(1)
CreateCreature("creature2",[xxx.yyy],3)
SetGlobal("C#Retransformation","GLOBAL",1)
EndCutSceneMode()
END  



-------------------------
I just noticed there's no "OR(x)" trigger in BG1. How am I supposed to code something like
"IF ~OR(3) Dead("Myguy") SateCheck("Myguy"",STATE_SLEEPING) !InParty("Myguy"")~" ???? Easiest way (well, I mean *simplest*) is to split it into three dialogues blocks for the three different triggers, but that's.... not really convenient...
Vlasák
QUOTE(jastey @ Sep 28 2004, 01:44 PM)
I just noticed there's no "OR(x)" trigger in BG1. How am I supposed to code something like
"IF ~OR(3) Dead("Myguy") SateCheck("Myguy"",STATE_SLEEPING) !InParty("Myguy"")~"  ???? Easiest way (well, I mean *simplest*) is to split it into three dialogues blocks for the three different triggers, but that's.... not really convenient...

yep, you must divide it into three separate blocks...

...or if your dialog is simple (little amount of other top-level nodes; in other case it would get more complex in variable/weight handling) you can make the block with conditions:
!Dead("Myguy")
!StateCheck("Myguy",STATE_SLEEPING)
InParty("Myguy"")

as the negation of your conditions to handle possibilities that are not desirable for your dialog node. In addition you have to increase weight of this node. Then, you can make top-level node that is desirable for your dialog with True() condition. If you have another top-level nodes (ie initial node with NumTimesTalkedTo(0)) you must to specify their proper weights or/and another additional conditions for this initial and/or for other top-level nodes.
jastey
What do you mean with "negation of your conditions to handle possibilities that are not desirable for your dialog node"? If I want to have a reaction if the character *is* not in the party / dead / sleeping, a trigger for the contrary case doesn't help me. (?) Do you have an example?
Vlasák
NumTimesTalkedTo(0)
"Hi, I'm mr. XYZ"

(...)

!NumTimesTalkedTo(0) //acts almost as True() in this case
"Oh, Yourguy is not in the party or he is dead or he is sleeping."


!NumTimesTalkedTo(0)
!Dead("Myguy")
!StateCheck("Myguy",STATE_SLEEPING)
InParty("Myguy"")
"Oh, Yourguy is still in the party and he is not dead and he isn't sleeping."
or just
"I have nothing to say at the moment..."
jastey
Hm, as the dialogue nodes are checked from the top to bottom I think for the code you wrote I would get the

CODE
!NumTimesTalkedTo(0)


even if my guy is dead or sleeping, as there is no trigger that prevents the dialogue to be called in that case. You either have to put the order like this:

CODE
!NumTimesTalkedTo(0)
!Dead("Myguy")
!StateCheck("Myguy",STATE_SLEEPING)
InParty("Myguy"")
"bla"

!NumTimesTalkedTo(0) //acts almost as True() in this case
"bla"

putting the more restricted case in front, or I would have to set a weight, so the
"!NumTimesTalkedTo(0)
!Dead("Myguy")
!StateCheck("Myguy",STATE_SLEEPING)
InParty("Myguy"")" case is called first.

???


OK, I think I got what you mean, but for a script trigger for example I would have to specify the case I want to trigger, so it's three blocks with check variables...
Vlasák
jj, you must specify the weight of the last top-level node as I've wrote before.

it can be used for script blocks as well... so you can "compress" x conditions in OR <=> x separate blocks into two blocks:

I have n conditions in OR relation:

CODE
IF
!OrCondition#1
!OrCondition#2
...
!OrCondition#n
THEN
RESPONSE #100
NoAction()
END

IF
True()
THEN
RESPONSE #100
SomeActions
END


No condition from my OR group is true - 1st block of the script catches that... script restarts from the top again...
At least one condition from my OR group is true - 1st block is skipped, 2nd catches it (always runs) and actions are performed...
jastey
Yes, that makes sense. Thanks, Vlasák!
But still there are the I_C_T cases, where I would like to code something like:
CODE
I_C_T SOMEDLGFILE xx Checkvariable
== SOMEBODY IF ~OR (3) !InParty("MYGUY") Dead("MYGUY") StateCheck("MYGUY",STATE_SLEEPING)~ THEN ~It's all mine!~
END


I guess that becomes something like
CODE
I_C_T SOMEDLGFILE xx Checkvariable
== SOMEBODY IF ~!InParty("MYGUY")~ THEN ~It's all mine!~
== SOMEBODY IF ~Dead("MYGUY")~ THEN ~It's all mine!~
== SOMEBODY IF ~StateCheck("MYGUY",STATE_SLEEPING)~ THEN ~It's all mine!~
END


??
jastey
*sigh* There is also no "Baldur.BCS" in BG1, no? The overall script in BGII, that let messengers find you independent on which area you are at the moment. So, if I want to have a situation like that (messenger for one of the NPCs finds party), how do I code that?
I need this for BGTutu, actually, but if somebody has an idea for both engines I would like to hear it.
Thank you! smile.gif
Rabain
You want a messenger to appear at a particular stage and walk up to the party to initiate dialogue?

As BG1 has a large number of wilderness area's I would just concentrate on putting the relevant script code in the major towns: Nashkell, Beregost, Friendly Arm, Ulgoths Beard, the Sorcerous Sundries area of BG city (everyone visits here regularly) and the Flaming Fist HQ map of BG city (you have to visit here for a lot of the main plot quests).

Thats six additions from only one file, just write the code in a baf and use the EXTEND to extend the six areas above (6 lines in the tp2).

Also to me it would make more sense that a messenger would wait for you in a town rather than wander into the wilderness in the hope of finding you to give you a message.

On the other hand it might be possible to use the script of an NPC to create a person using ActionOverride with CreateCreature and use -10.-10 to specify location (i think you can do this, it creates the creature at your co-cordinates -10)
jastey
Thank you, Rabain. With ActionOverride(..CreateCreature..) I fear the Messenger could be spawned behind a closed door or such ( a problem already encountered by some people...)

I guess I will identify and include the realistic areas (cities). It is indeed not very realistic that a messenger should come to you at some places, for example the bandit camp...

EDIT: Just checked, and for Anomen (BGII) the messenger appearance is realised via "CreateCreatureObjectOffScreen" out of the NPC.BCS, too, not via the Baldur.bcs as I thought. This command doesn't exist for BG1, of course, but if your suggestion with the relative coordinates doesn't work it could be done by defining specific coordinates into the area scripts. A bit more work, but not unfeasable.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2024 Invision Power Services, Inc.