Jump to content

More scripting questions


Sandor

Recommended Posts

I have another scripting question for you guys :)

How can I include an off-hand weapon in a script?

Kivan is doing a fine job as archer, but if something manages to get near him, I'd like him to equip two swords instead of one.

There is no way to script the equipping of an off-hand weapon.

 

You can, however, create a spell that will

1) remove the item from the inventory and

2) create the item in the off-hand slot.

You'll need a spell for every weapon you'll want to use in the off-hand.

Opcodes to use would probably be:

Item: Remove Inventory Item [123]

Item: Create Item in Slot [143]

 

So you could then have a script block that goes something like this:

IF
See([ENEMY])
Range(NearestEnemyOf(Myself),10)
HasItem("weapfile",Myself)
THEN
RESPONSE #100
EquipMostDamagingMelee()
ForceSpellRES("spellfile",Myself)
END

where weapfile is the resource reference for the item in question and where spellfile is the resource reference for the spell associated with the item in question.

 

Do note that this would be a cheat for items that have limited charges. Each time the item would be 'equipped' it would be brand new and fully charged.

 

As far as I know, you'll be testing the waters with this. It's just something I came up with when looking for a possible solution to your query. I'm not even sure how to make a functioning .spl file.

Link to comment

As much as I'd like to test the waters for you guys, I'd like to keep this game a little cheating as possible. I feel bad enough as it is for training Imoen as a thief-mage by learning and unlearning spells in easy mode ;p

But if there's a code that creates things in the offhand, doesn't that mean it can equip things in the offhand as well? I mean, there has to be a designation for 'offhand' in the scripts, right? Or am I understanding this whole thing wrong? I only found out about this whole 'how to make custom scripts' a few weeks ago.

Maybe I could use the sort of format that tells a fighter to equip a shield?

Link to comment
As much as I'd like to test the waters for you guys, I'd like to keep this game a little cheating as possible. I feel bad enough as it is for training Imoen as a thief-mage by learning and unlearning spells in easy mode ;p

But if there's a code that creates things in the offhand, doesn't that mean it can equip things in the offhand as well? I mean, there has to be a designation for 'offhand' in the scripts, right? Or am I understanding this whole thing wrong? I only found out about this whole 'how to make custom scripts' a few weeks ago.

Maybe I could use the sort of format that tells a fighter to equip a shield?

You've got that wrong.

 

The script block above would trigger a spell. The spell is what creates the weapon in the off-hand not the script block itself.

 

I only mentioned the cheating thing because somebody could use it to equip limited charge items into the quickslots. In your case of the off-hand slot, I don't think it would be an issue because I know of no weapons that have limited charges.

 

There is absolutely no way using script code and only script code to equip and use an item in the off-hand. The only thing that can create an item in a specific creature slot is the spell effect opcode mentioned in the earlier post.

Link to comment

I just tried my own idea on a BG2 save I have. It works.

 

I made a spell that deletes the plain long sword from inventory and creates it in the off-hand slot.

 

I then used this block to test

IF
 Hotkey(F)
THEN
 RESPONSE #100
Equipmostdamagingmelee() //make sure ranged weapon not equiped
Forcespellres("AB_W001",Myself) //equip off-hand weapon
Equipmostdamagingmelee() //equip on-hand weapon because spell drops weapon
END

I must confess I only had one copy of the particular sword among my party members so I'm not sure what happens if more than one of the item in question are present. But I'm excited just knowing that it works.

 

Sandor:

I can package up a "mod" that will scan for all one handed weapons and create the needed script blocks as well as creating the matching spell files. Do you want the script blocks to be added to certain scripts or do you just want the output to be in .baf code for you to paste into whatever scripts you want?

OR I can send you the spell file for you to make and modify copies for only the specific weapons you want to equip in the off-hand. Then you can modify the test script block above to suit your needs.

Link to comment
I just tried my own idea on a BG2 save I have. It works.

 

I made a spell that deletes the plain long sword from inventory and creates it in the off-hand slot.

 

I then used this block to test

IF
 Hotkey(F)
THEN
 RESPONSE #100
Equipmostdamagingmelee() //make sure ranged weapon not equiped
Forcespellres("AB_W001",Myself) //equip off-hand weapon
Equipmostdamagingmelee() //equip on-hand weapon because spell drops weapon
END

I must confess I only had one copy of the particular sword among my party members so I'm not sure what happens if more than one of the item in question are present. But I'm excited just knowing that it works.

 

Sandor:

I can package up a "mod" that will scan for all one handed weapons and create the needed script blocks as well as creating the matching spell files. Do you want the script blocks to be added to certain scripts or do you just want the output to be in .baf code for you to paste into whatever scripts you want?

OR I can send you the spell file for you to make and modify copies for only the specific weapons you want to equip in the off-hand. Then you can modify the test script block above to suit your needs.

 

Thanks a lot. I'd like a mod that creates the necessary spell-files, but only if it's like... easily reversible. There are a few swords in BGII that do have once-a-day abilities. The Dragonslayer sword comes to mind. Which is an excellent off-hand weapon, by the way.

I think sending me the spell-file would be best. I'll make copies for the swords I have now and try it out.

Link to comment
Thanks a lot. I'd like a mod that creates the necessary spell-files, but only if it's like... easily reversible. There are a few swords in BGII that do have once-a-day abilities. The Dragonslayer sword comes to mind. Which is an excellent off-hand weapon, by the way.

I think sending me the spell-file would be best. I'll make copies for the swords I have now and try it out.

I sent you a pm requesting a contact method for sending/receiving the .spl file. Please check and respond to me there if you wish to keep your contact info private.
Link to comment

Archived

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

×
×
  • Create New...