Jump to content

Problem with weapon equipping via script: weapon is not equipped?


jastey

Recommended Posts

What I want to do is replace an existing weapon (non-removable item) via script and equip it automatically. (This is for faking the weapon to become stronger if the NPC is leveling up). What I do is:

 

/* level 3 */

IF

GlobalLT("C#GreyLevelUp","GLOBAL",3)

XPGT(Myself,3999)

THEN

RESPONSE #100

TakeItemReplace("c#grpaw3","c#grpaw1",Myself) //shield slot

TakeItemReplace("c#grtoo3","c#grtoo1",Myself) // weapon slot

EquipMostDamagingMelee()

SetGlobal("C#GreyLevelUp","GLOBAL",3)

END

 

Changing of items works, the new item is in the weapon slot. Problem is: The new item is not equipped. It is also not shown in the menu bar if the NPC is selected (in the normal play mode, not the character screen). Only the fist shows, the weapon is not shown. Since it is a non-removable item, I cannot even re-equip it in the inventory screen by taking it out and placing it into the weapon slot again.

 

Dos anyone have an idea how to solve this?

Link to comment

I've run into this problem with Drizzt Saga too, it had several NPCs with undroppable weapons which would become "unselected" after they died and were raised. The weapon was in correct slot and the slot was showing as selected on the inventory screen, but item was not actually equipped.

 

This:

IF
   !HasWeaponEquiped(Myself)
THEN
   RESPONSE #100
       SelectWeaponAbility(SLOT_WEAPON,0)
       Continue()
END

works in a sense - making the character actually use the equipped item, but problem is it does not change the icon from fist to that of the weapon. Which would be confusing for a player, to say the least.

 

In the end, I just gave up and made the items droppable.

Link to comment

Thank you for the information.

 

Do I see it correctly that this "vanished" undroppable weapon cannot we selected by the player at all (by hand)? Meaning, if my NPC has this undroppable weapon and another, droppable one: once the icon disappears from the weapon menu, it cannot be reselected? (i.e. clicking on the fist means fighting with a fist, not with the weapon that is actually in this weapon slot?)

 

If yes, then I'd have to bury this idea, too, which would be too bad. (We are talking about the animal NPC's canine, so making it droppable is out of the question..) EDIT: Wait a minute, if I get you correctly then the whole idea of giving an animal NPC his claws and teeth via undroppable items is mute, not only for my levelling-up problem but also after it is raised... Dang.

Link to comment

The equipping-related script actions seem to be buggy for selectable NPCs. I could never successfully use them in my scripts. You can check it out in NearInfinity; it either sets a wrong "Quick weapon slot" type in the GAM's party member structure or an invalid "Weapon slot selected" index in the embedded CRE structure. Even if the weapon is selected correctly, you need to save and reload the game to make the changes visible.

 

If your NPC is not a regular party member (i.e. no inventory access) you could use the script action ChangeAnimation() to replace the character with different versions, new inventory included. I'm using this method successfully in my Djinni Companion mod. Another way is to use a custom kit for your NPC that applies different boni on level ups. In that case the effects won't be weapon-specific anymore though. Or you could set up a specific creature script that adds new permanent effects on level up.

 

How do I know the weapon in the shield slot is actually used for fighting? Is it possible to have a weapon in the shield slot but it is not used for combat (but the fist instead)?

The visual appearance is controlled by the "Equipped appearance" field of the item. If you want the weapon to be used like a fist, you can set its damage type to "Fist" in the ability section of the item.

Link to comment
Do I see it correctly that this "vanished" undroppable weapon cannot we selected by the player at all (by hand)? Meaning, if my NPC has this undroppable weapon and another, droppable one: once the icon disappears from the weapon menu, it cannot be reselected? (i.e. clicking on the fist means fighting with a fist, not with the weapon that is actually in this weapon slot?)

Yes, unfortunately, that is correct.

 

EDIT: Wait a minute, if I get you correctly then the whole idea of giving an animal NPC his claws and teeth via undroppable items is mute, not only for my levelling-up problem but also after it is raised... Dang.

Yes, this seems to always happen after character dies and is resurrected, that's how I first noticed the problem.

 

Related question: How do I know the weapon in the shield slot is actually used for fighting? Is it possible to have a weapon in the shield slot but it is not used for combat (but the fist instead)?

Fortunately offhand seems to work fine, only main hand weapon slots are affected. I tested this by creating a test npc with an off-hand weapon instantly disintegrating the target. It worked fine in a situation when main hand weapon becomes bugged (being revived after death as above).

 

The visual appearance is controlled by the "Equipped appearance" field of the item. If you want the weapon to be used like a fist, you can set its damage type to "Fist" in the ability section of the item.
I think Jastey is not asking about changing equipped appearence, but whether the off-hand slot suffers from the same problem as the main hand slots, i.e. if they get replaced by 'fists' instead of using actual equipped weapon.
Link to comment

argent77: My question was phrased inadequate, I meant what pro5 answered.

 

pro5: Thank you very much, you saved me a lot of time with your knowledge.

 

What I am planning now is: Give the NPC an undroppable weapon in the shield slot (no problem there). Upgrade this weapon upon levelling up by desctroying and creating a new one via script (no problem there). Leave the fist for the other, normal weapon hand. Apply fist damage bonus upon levelling up (hopefully doable like I want). "Fist" symbol remains in the weapon slot for the animal NPC's natural weapon, but I can live with that.

Link to comment
Changing of items works, the new item is in the weapon slot. Problem is: The new item is not equipped. It is also not shown in the menu bar if the NPC is selected (in the normal play mode, not the character screen). Only the fist shows, the weapon is not shown. Since it is a non-removable item, I cannot even re-equip it in the inventory screen by taking it out and placing it into the weapon slot again.
This is how Wilson is done in BG2EE:

 

1) Use a custom kit that applies 143 opcode to replace existing weapons.

2) Flag the main-hand weapon with 233 opcode to set the proficiency 108 to some value. It's now used as a natural weapons proficiency in BG2EE, so you can consider it official.

3) Add this to NPC's script to auto-equip the weapon whenever it's not active

IF
 CheckStat(Myself,0,108)
THEN
 RESPONSE #100
EquipMostDamagingMelee()
END

 

Also I suggest to swap you weapons - paws are supposed to get more attacks per round than bite, so if you haste him, you'd get weird results ;)

 

 

 

I've run into this problem with Drizzt Saga too, it had several NPCs with undroppable weapons which would become "unselected" after they died and were raised.
Yep, I know about this too.

The solution is to replace the scripting block above with this, repeated for each level upgrade. You should still upgrade weapons via CLAB as well.

IF
 CheckStat(Myself,0,108)
 // some convenient level check here
THEN
 RESPONSE #100
SetInterrupt(FALSE)
ReallyForceSpellRES("weapons2",Myself) // create version 2 of the weapons
SmallWait(5)
EquipMostDamagingMelee()
SetInterrupt(TRUE)
END

 

Related question: How do I know the weapon in the shield slot is actually used for fighting? Is it possible to have a weapon in the shield slot but it is not used for combat (but the fist instead)?
Offhand works fine.
Link to comment

Ardanis, I've tried your solution but I can't get it to work any better than the one I posted above:

SelectWeaponAbility(SLOT_WEAPON,0)

 

It works in the sense that the character does equip the weapon, but the fist icon still remains at the bottom of the screen, confusing the player. Mechanically the weapon is used fine, it's a UI update issue.

Link to comment

Thank you very much for your replies. Ardanis: I was wondering how Wilson in BGII:EE works, thank you for the info.

 

I helped myself by leaving the item in the shield slot, but no weapon in the right hand weapon slots. Fist gets damage bonus +1 at levels 9, 12, 15 and 25 (hoping I understood correctly and this means it adds up to 1d6 + 4). There will be equipable weapons, too, so it's all a matter of making the non-weapon damage not too hilarious in case a player doesn't have the weapons.

 

I'd like to have the same fist damages as for a monk, but I don't know how to do that.

 

Question regarding haste: Are you saying that it has only effect on the first-hand weapon?

Link to comment
Question regarding haste: Are you saying that it has only effect on the first-hand weapon?

 

Normal Haste adds one attack per round with main hand weapon. Improved Haste doubles original number of attacks for both main hand and off-hand weapons.

 

Here's a thread with more details: http://forum.baldursgate.com/discussion/7042/when-hasted-if-dual-wielding-does-the-off-hand-still-only-get-one-attack.

Link to comment

Archived

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

×
×
  • Create New...