Author Topic: Three newbie questions about Near Infinity  (Read 5362 times)

Galoomp

  • Guest
Three newbie questions about Near Infinity
« on: March 30, 2012, 03:57:14 AM »
First of all hello to everyone in this forum, and a massive thank you to everyone who is putting so much work into keeping classic games alive! I have recently discovered the fun that can be had with Baldurs Gate II and Near Infinity, and am now thoroughly addicted.
So...here are my (first) three questions

1) Is it possible to do any math with near infinity, for example adding the values of two global variables together? If this is not possible with near infinity then is it possible with some deeper exploration, for example in WeiDU?

2) How can I put comments on my .BCS scripts!? I can use // to make a comment, but when I hit "compile" it gets rid of everything!

3) Is it possible to change the a scripting state (ie. something in STATS.IDS) using scripting? I can check a scripting state using CheckStat, and can modify a state using spell effects Modift Script State, but I cannot seem to set the value any other way?

Thanks in advance for any help

Offline Kulyok

  • Global Moderator
  • Planewalker
  • *****
  • Posts: 6233
  • Gender: Female
  • The perfect moment is now.
Re: Three newbie questions about Near Infinity
« Reply #1 on: March 30, 2012, 04:25:04 AM »
Hello to you too,
1) Not that I know of, no. Maybe someone knows better.
2) You don't do anything to .bcs scripts. You work with .baf scripts, put comments there, and compile only via weidu when the mod is being installed.
3) Blink, I'm not sure what do you mean - but I know there're people who can answer that for me. :) (Me, I think that one can add new states, like CamDawg did, in your weidu mod's .tp2 and work with these states in your scripts).

I'm moving your questions to Modding Q&A, as they're probably better suited there.

Offline Kulyok

  • Global Moderator
  • Planewalker
  • *****
  • Posts: 6233
  • Gender: Female
  • The perfect moment is now.
Re: Three newbie questions about Near Infinity
« Reply #2 on: March 30, 2012, 04:27:13 AM »
Actually, I think your best bet is reading Weidu readme at weidu.org and some tutorials here. 165% of mods these days are made via Weidu, so you might want to learn to code basic .tp2, .baf and .d.

Offline plainab

  • Sasha al'Therin
  • Planewalker
  • *****
  • Posts: 491
    • Infinity Engine Modding
Re: Three newbie questions about Near Infinity
« Reply #3 on: March 30, 2012, 10:34:41 AM »
Quote
1) Is it possible to do any math with near infinity, for example adding the values of two global variables together? If this is not possible with near infinity then is it possible with some deeper exploration, for example in WeiDU?
In Near Infinity, no.  It's sole purpose is to look up current values and/or set a new value.

WeiDu on the other hand can be used to do some math.

For example you wanted to give every creature in the game 10% more gold than they currently have.  Thus they will drop a little bit more gold when they are killed.
(I won't go into .tp2 making you can read up on that and look at existing mods too)

First thing you'd need to do is copy each creature resource.  In this case we don't have a specific list so we use what is called a regular expression or REGEXP for short.
Code: [Select]
COPY_EXISTING_REGEXP ~.*\.cre~ override       //there are other more complicated REGEXP methods that people use, but the simple .*\.cre works as well
 READ_LONG 0x1c gold                          //IESDP tells us that the offset at 0x1c into the creature header is where the value of gold is located.
 WRITE_LONG 0x1c %gold% + (%gold% * .10)      //now we use the previous value & add in 10% of that value and write that at the offset
BUT_ONLY                                      //this tells weidu to only save the file IF the data changed.  obviously 0 + (.10 * 0) = 0   so some files won't be changed
Links of interest:
IESDP
Weidu readme

Do note that while Near Infinity can give you the offset of a particular value in a particular file, the location of said value can be different in other files as well as the same file on other player's setups.  Thus it is important to learn how to understand the IESDP and it's descriptions of the file structure for each file type.
My working mods:
an AI Party Script for BG2 game engine DOWNLOAD LINK ONLY!
Interactive Tweaks for BG series with some IWD support. DOWNLOAD LINK ONLY!
Rest For 8 Hours an IWD mod
-------------------------------------------
My contributions: BG1Fixpack, BG1Tweaks
On Hold: Solestia an NPC for SOA
-------------------------------------------
My website: http://sasha-altherin.webs.com

Galoomp

  • Guest
Re: Three newbie questions about Near Infinity
« Reply #4 on: March 30, 2012, 12:42:59 PM »
Thanks for the quick replies

OK, so I have downloaded and had a little play around with WeiDU. It seems like you can get much deeper in the dialogue editing stuff by this method! But no more ncie easy GUI  :-\, oh well it was going to happen sooner or later! Kulyok: now I see your point about editing the .baf scripts this way and compiling at the end - makes sense.

plainab: just to check I am getting the jist of your example, it looks like you have made a modding script (this is what a .tp2 is right?) that changes the values in the .cre files to give every creature 10% more gold. This is an action that would be applied as a one-off, for example just before starting a new game. If so then this is not exactly what I meant ... I was wondering if was possible to do math kind of on-the-fly within an AI script. For example, if I set a couple of variables as follows

SetGlobal("Glob1","LOCALS",3)
SetGlobal("Glob2","LOCALS",5)

then I want to make a new global variable, in response to some trigger, that is (for example) equal to the product of these two.

If, as you say, Near Infinity is just a way of looking up and setting values then I guess it won't have this kind of functionality. Can WeiDU save me here? I had a go at exporting a .BCS file using WeiDU and just ended up with a text file with exactly the same commands as in Near Infinity. Is it possible to use some of the mathsy operators you described in an AI script this way?

Thanks again, and let me know if I'm barking up the wrong tree here!

Offline plainab

  • Sasha al'Therin
  • Planewalker
  • *****
  • Posts: 491
    • Infinity Engine Modding
Re: Three newbie questions about Near Infinity
« Reply #5 on: March 30, 2012, 05:04:12 PM »
you set GLOBAL, LOCALS, AREA variables based on events happening via scripting (baf/bcs) or dialog choices taken via dialog files (d/dlg)

So if you know the conditions that you want a certain variable to be changed by then you can merely set that variable to the new number when those conditions happen

Using your example.

If PC talks to one NPC and agrees to do something and "Glob1" gets set to 3...
should PC talk to the same NPC and agrees to do something else and thus sets "Glob2" to 5

You could then have in a script a small block
Code: [Select]
IF
Global("Glob1","LOCALS",3)
Global("Glob2","LOCALS",5)
THEN
RESPONSE #100
  SetGlobal("Glob3","LOCALS",8)
END
now then the next time the NPC is spoken to or the next time the script is parsed whatever you have set up to happen for when "Glob3" is 8 will happen.

You could do this in Near Infinity as well, as it's a matter of keeping track of the variables in script & dialog.  Tho I do think that it is easier to keep track of using the baf & d file formats of weidu

Do note that LOCALS only affects the creature running the script or dialog file and those values are not stored between game sessions.  If they are important values that you need to access between game sessions then you need to use GLOBAL since GLOBALs are stored in the save file.

One thing to note, there is some funkiness about when variables are actually set.  Scripts set the variables at the end of the script parsing round so, the block above in the example would force the script to reparse and set the variable, however it also leads to the possibility that other actions from the same script or higher script levels may take place before that which relies on the newly set variable.  Dialog files on the other hand are even trickier, you'll have to ask someone even more knowledgeable about that.   Dialog is not my strong point.
My working mods:
an AI Party Script for BG2 game engine DOWNLOAD LINK ONLY!
Interactive Tweaks for BG series with some IWD support. DOWNLOAD LINK ONLY!
Rest For 8 Hours an IWD mod
-------------------------------------------
My contributions: BG1Fixpack, BG1Tweaks
On Hold: Solestia an NPC for SOA
-------------------------------------------
My website: http://sasha-altherin.webs.com

 

With Quick-Reply you can write a post when viewing a topic without loading a new page. You can still use bulletin board code and smileys as you would in a normal post.

Warning: this topic has not been posted in for at least 120 days.
Unless you're sure you want to reply, please consider starting a new topic.

Name: Email:
Verification:
Type the letters shown in the picture
Listen to the letters / Request another image
Type the letters shown in the picture:
What color is grass?:
What is the seventh word in this sentence?:
What is five minus two (use the full word)?: