Jump to content

noob questings regarding items, spells and SCRIPTINGSTATE


Guest grasida

Recommended Posts

Guest grasida

So I should probably start off with my general goal. I am creating a kit and I want it to be able to make projectile attacks with certain melee weapons while certain class abilities are active. For example, my kit has two abilities, "mist magic" and "cloud magic". Mist magic, among other things, upgrades unarmed damage by replacing the character's default fist item with the more powerful "cloud fist". Cloud magic, if mist magic is active, in turn replaces cloud fist with "cloud hammer", which has a ranged attack ability. Now, I assume this is possible, since throwing axes have both melee and range attacks, but I'm a little hazy on the details. Can I assign a weapon just any projectile and expect it to work? What if I give it a fireball? Will the ranged attack damage carry over to the explosion?

 

My second question is, how should I go about doing this? As I see it, I have two options, either to edit baldur.bcs to check for whether these spells are active (Which I would do by setting the spell to assign the player a SCRIPTINGSTATE) and then if the spell is active and the player has the appropriate item (I would like to do this with more than just the example above, even with some equipable weapons), set a timer equal to the spell length and replace the weapon with a copy with the new abilities. Then, I would use another script to switch the weapons again once the timer runs out. OR, I could make the spell summon an invisible creature, which would run a script to replace the weapons and summon another invisible creature when the spell wears off and put the original weapons back. Am I right about these being my options? Which one is better?

 

I tried the first option, because the idea of invisible creatures creeps me out and I'm not sure how good they'll be at switching my equipment when I'm dashing around in the midst of combat. However, I ran into a problem when editing baldur.bcs. I added a new block to the end like I described above, but I asked it to check for SCRIPTINGSTATE6 without first adding that entry to stats.ids (how do I add entries by the way? just type them in as new lines at the end?). Near Infinity (I am on an ancient ibook, so that is my only option)

told me there would be an error, but I saved baldur.bcs anyway. Now it won't let me open it again unless I tell it to ignore overrides, which, of course won't let me undo my changes. I can't rename or delete any files outside of the override folder, so I now have no way to undo the changes that I made. The game still runs, at least for the few minutes I tried, but I don't know if I seriously messed anything up or what I can do to fix it. Is this supposed to happen when you screw up editing baldur.bcs? Do I just have to reinstall? What are my options at this point?

Link to comment

One way to fix your Baldur.bcs --

 

Download a copy of weidu that works with your computer. http://www.weidu.org/~thebigg

 

Once you've downloaded and extracted the contents (no need to put the whole thing in the game directory)

copy the executable file called WeiDU and paste it into the game directory.

 

Get to a dos/command window and navigate to your game directory

Type in the following: weidu baldur.bcs --out bad_baldur.baf

 

After it is done, go to the main game directory and using a text editor like Notepad open the file bad_baldur.baf. Scroll down to the end where you made the changes and delete the offending script block(s). Save it as baldur.baf (make sure it will save as a text file rather than some other kind).

 

then go back to the dos/command window and get back to the game directory

Type in the following: weidu baldur.baf

 

When it is finished. See if you can use Near Infinity properly again.

 

 

There are other ways to solve your problem, this method may be the easiest. As for your other things, I'll have to leave that to some more experienced modders. I'm afraid that I'm not too good with kits and spells...

 

 

If for some reason you do decide to go ahead and do a complete re-install, be sure to back up your game files so that you can easily reverse any changes made by deleting the contents of the override directory and replacing with those from your backup. Files that should be backed up are: In main game directory: BGMain.exe; dialog.tlk; chitin.key; the .ini files are good to back up also; and the entire override directory (contents and all).

 

Do check one thing before doing this. If you open NI and have it ignore overrides, is the baldur.bcs that you have available EXACTLY IDENTICAL to the one that you had added to (without your changes of course)? If so, here is an easier fix -- delete baldur.bcs from your override folder. Why? Anything in the override folder takes priority over the stored file inside the .bifs. What NI is doing by ignoring overrides is looking only at the data stored in the bif files. For most files that would be the version that shipped with the game.

Link to comment
Guest grasida

Thanks for the advice, those are useful suggestions, but unfortunately did not work. I used weidu to take out the bad baldur.bcs, but when I tried to open it with a text editor, it was blank. The backup copy I exported and decompiled, however, opens just fine. So, I used weidu to try and put in the backup baldur.baf, which weidu says it did, but I still have the same problem in Near Infinity.

 

Unfortunately, the baldur.bcs with ignore override on is quite different from the one before I made any changes. I assume that this is because I have several mods installed.

 

I think the lesson I have learned is that baldur.bcs is scarier than invisible creatures. I will try and do what I want using them, and since the game at least runs, I will do a clean install after I have finished making my mod. Of course, if anyone has any suggestions, please let me know.

Link to comment

Near Infinity likely ate your Baldur.bcs, sorry (never, ever, ever tell Near Infinity to save the script if it tells you there were errors compiling). You'll just want to uninstall and then reinstall your mods (the different iterations of the script, which is in the override by default, will be in the mods' backup folders, so uninstalling them all will eventually get the original back). After uninstalling the mod, you may wish to make a backup of the following:

Baldur.ini
characters/
Chitin.key
dialog.tlk
Keymap.ini
music/
override/
scripts/
sounds/

Ever after, when things screw up, you simply uninstall your mods, copy over those backed up files and directories, and you have an instant clean install and can then reinstall the mods. This way, you don't have to take 10 years to reinstall all the BIFFs (the archives where the base resources are stored; mods should never touch these, so you don't need to back them up).

 

I'm not sure what backup copy of Baldur.bcs "I exported and decompiled" you're referring to, though; if you made a copy before breaking it in NI, you can simply recompile and save (or copy it to override if it's already compiled).

 

If you want to edit any IDS file, simply edit it in NI (they're just boring text files). That shouldn't have been your problem, though (it should be there by default). After editing your IDS files, hit F5 to reload (or choose Reload from the game menu); we should be automatically purging the IDS cache when you save an IDS file, but best to be safe.

 

Baldur.bcs is just a normal script. It handles some global logic (setting up variables and advancing some of the plots and quests). Breaking it is bad, but it wouldn't cause the game to freak out or anything (since NI replaced it with a 0-byte file, it's just an empty script).

 

I'm not terribly sure what you want to have happen with your spells. You can't really replace a character's weapon while preserving whatever they currently have equipped (the magic weapon creation effects will do this for you, however). If the player is supposed to have the "fist" as an item they can equip, there are effects that can destroy and replace items, so you could look into those (activating either of the abilities simply destroys all the old item and creates the new one; no scripts necessary). I wouldn't go with an invisible creature, as the player could leave the area before your timer expires and then get stuck with whatever changes it was making by script.

Link to comment
Guest grasida
I'm not sure what backup copy of Baldur.bcs "I exported and decompiled" you're referring to, though; if you made a copy before breaking it in NI, you can simply recompile and save (or copy it to override if it's already compiled).

 

This is exactly what I did. The backup copy that "I exported and decompiled" is the one that I created by exporting and decompiling baldur.bcs before I made any changes. Your recommendation worked. I had already recompiled it, and dropping it into override seems to have fixed the problem. I wasn't aware (though I probably should have figured it out) that there was another baldur.bcs in override because it wasn't showing up in NI.

 

What I want to do with the spells is replace specific weapons with new ones, and then put the old weapons back when the spell expires. I assume I need a script to do this so that the spell will only replace certain weapons by using the script to check whether or not they are equipped. I already tried to clarify this with my example about the fists. Spell A replaces the default fist with an upgraded one. Spell B, if Spell A is active and the character has the upgraded fist, replaces that fist with a new, even more powerful one. Otherwise, Spell B only uses its other effects and doesn't replace the fist. Okay, here's another example. Spell C replaces the character's current equipped weapon with a new one that has extra abilities (a ranged attack or some magical abilities). However, "because it requires a heavily enchanted weapon to channel the power of Spell C through the weapon into these abilities", only certain weapons will be replaced. If the player does not have these weapons equipped, Spell C's normal effects will be active, but the weapon will not be replaced.

 

Basically, what I am trying to do is give ranged attacks to what should be melee weapons when certain spells are active. The player equips a powerful sword, say, Angurvadal. Then, he uses Spell C. Spell C detects that player A has Angurvadal equipped, replaces it with a new Angurvadal that can make ranged attacks, and then when Spell C runs out, takes away the new Angurvadal and puts the old one back. Ideally, spells could simply add new abilities to equipped items, but I don't think that's possible (someone please tell me if I'm wrong!), so I'm trying to accomplish what I want to do by replacing items instead of modifying them.

 

I was successful in replacing my fists with invisible creatures, but the new fists didn't work. I couldn't attack with them and they magical ability I assigned to them crashed the game. This is quite possibly because of mistakes I made, and I will try to figure it out myself before asking here.

 

Following devSin's suggestion, I tried to use baldur.bcs instead of invisible creatures, but it doesn't work. My fists are not being switched. I will post the script I used here.

IF
CheckStat(Player1,10,SCRIPTINGSTATE6)
HasItemEquiped("fist",Player1) // Fist
THEN
RESPONSE #100
	TakeItemReplace("cloudfst","fist",Player1) // Fist
	SetGlobalTimer("misthammer","GLOBAL",60)
END

IF
GlobalTimerExpired("misthammer","global")
THEN
RESPONSE #100
	TakeItemReplace("fist","cloudfst",Player1) // Mist Hammer
END

Did I screw up? Does baldur.bcs run constantly? If my character's scriptingstate changes, will the script instantly equip the new weapon?

 

Thanks for all your help so far! Please, if you've got any more tips, let me know!

Link to comment
After uninstalling the mod, you may wish to make a backup of the following:
Baldur.ini, characters/, Chitin.key, dialog.tlk, Keymap.ini, music/, override/, scripts/, sounds/
Ever after, when things screw up, you simply uninstall your mods, copy over those backed up files and directories, and you have an instant clean install and can then reinstall the mods. This way, you don't have to take 10 years to reinstall all the BIFFs (the archives where the base resources are stored; mods should never touch these, so you don't need to back them up).
What? -I just don't get this, right? As usually one doesn't make great changes to the character, music, script or sounds directories that have bad consequences, as usually you can choose not use them, but quite few mods do biff their content to the data folder, which then stays there until you un-installing the mod that produced it, and if the needed mod files aren't there anymore to uninstall them, they can cause a lot of...

 

PS: The backup is usually used by first deleting the old files, and then copying the backups to the game folder, including the data folder, not just overwriting everything, as that leaves the new files still there.

Link to comment
I was successful in replacing my fists with invisible creatures, but the new fists didn't work. I couldn't attack with them and they magical ability I assigned to them crashed the game. This is quite possibly because of mistakes I made, and I will try to figure it out myself before asking here.
That's going to take a lot of code. Your block looks OK, but I wouldn't bank on being able to pick up the fists (how did you get it to work with the creature script?) since they're not actually items you have as much as items the engine knows to use when you don't actually have anything equipped.

 

The crash will be an issue with the item. Make sure your effect counts and the effects index for all of the abilities are correct.

 

The second block is terrible wrong (after first using the ability, once the timer expires, that block will always be true until the next time the ability is used and then prevent anything below it from ever getting evaluated -- remember script execution restarts when a "true" block is executed). You'd want something like HasItem("cloudfst",Player1), but note that too many of these checks in a script that runs continuously can slow down the game; you can try setting a variable to 1 when the ability is used and the item swapped in, and then check to make sure that variable is 1 and reset it to 0 when swapping the custom item out -- but this would only allow a single player with the kit to be in the game (but if you're only checking Player1, that's already the case).

 

What? -I just don't get this, right? As usually one doesn't make great changes to the character, music, script or sounds directories that have bad consequences, as usually you can choose not use them, but quite few mods do biff their content to the data folder, which then stays there until you un-installing the mod that produced it, and if the needed mod files aren't there anymore to uninstall them, they can cause a lot of...
No, most mods don't BIFF except the few "mega" mods at SHS (and most those don't work on Mac OS X). Regardless, the mod BIFFs can sit there for all eternity once you restore the default chitin.key; the game won't "see" them and they will do nothing.

 

Mac OS X doesn't merge contents or other such nonsense, so simply copying the backed up items will permanently remove existing items of the same name (e.g., the entire "override" folder is replaced, not just its contents), leaving you with the "clean" backup copies.

Link to comment
Guest grasida

I was able to give myself the fists using the invisible creature just by using TakeItemReplace(). It seems that fist is an item slot, so your character will use whatever weapon is in that slot when no other weapon is equipped.

 

However, TakeItemReplace() is causing me a new problem. I want the new items to have charges, but they are being created with none. If I use GiveItemCreate(), then I can specify the number of charges on creation, but the item is created in my inventory, which is a little awkward for what are supposed to be fists. Is there any way to use script actions to create an item with charges in a specific slot?

 

Also, could I cut down the number of checks in baldur.bcs by handling creating and replacing the items with invisible creatures, but using baldur.bcs to check whether the player has any of these items when he loads the game or enters a new area and if so replacing them?

Link to comment
I was able to give myself the fists using the invisible creature just by using TakeItemReplace(). It seems that fist is an item slot, so your character will use whatever weapon is in that slot when no other weapon is equipped.
Interesting, however strange that the engine lets you do this.

 

However, TakeItemReplace() is causing me a new problem. I want the new items to have charges, but they are being created with none. If I use GiveItemCreate(), then I can specify the number of charges on creation, but the item is created in my inventory, which is a little awkward for what are supposed to be fists. Is there any way to use script actions to create an item with charges in a specific slot?
Not that I'm aware, no.

 

Also, could I cut down the number of checks in baldur.bcs by handling creating and replacing the items with invisible creatures, but using baldur.bcs to check whether the player has any of these items when he loads the game or enters a new area and if so replacing them?
I don't believe OnCreation() would be of much use in Baldur.bcs, so there probably is no easy way to do this.
Link to comment

Haha, i wonder what happens if you 'takeitemreplace' fist with a nonexistent item :(

I expect a heavy crash.

 

You can create items in specific slots!

See the proper opcode --> iesdp.

I don't know what would be the slot code for the fist.

Link to comment

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...