Script Help... changing weapons/equipping weapons
CuChoinneach
Member Posts: 105
Working on DSotSC and running into a bit of snag... thought I would seek some help in this matter.
I have a weapon that will change abilities whether it's day or night. So I have made two versions of the weapon.
I can get the weapon to change on the NPC, but he won't equip it. It's in his weapon slot but NOT in his hand.
Here is the script (I have appended this to baldur.bcs) ...using "weapon_d", "weapon_n" and "NPC" to avoid revealing spoilers.
IF
TimeOfDay(NIGHT)
HasItem("weapon_d","NPC")
THEN
RESPONSE #100
TakeItemReplace("weapon_d","weapon_n","NPC")
SetGlobal("WEAPON_SWAP","GLOBAL",1)
END
IF
TimeOfDay(DAY)
HasItem("weapon_n","NPC")
THEN
RESPONSE #100
TakeItemReplace("weapon_n","weapon_d","NPC")
SetGlobal("WEAPON_SWAP","GLOBAL",1)
END
.....This works so far! The part below, does not...
// Night Version Not Equiped
IF
ActionListEmpty()
HasItem("weapon_n","NPC")
Global("WEAPON_SWAP","GLOBAL",1)
!HasItemEquipedReal("weapon_n","NPC")
THEN
RESPONSE #100
EquipItem("weapon_n","NPC")
SelectWeaponAbility(SLOT_WEAPON,0)
SetGlobal("WEAPON_SWAP","GLOBAL",0)
END
// Night Version Equiped
IF
ActionListEmpty()
HasItem("weapon_n","NPC")
Global("WEAPON_SWAP","GLOBAL",1)
HasItemEquiped("weapon_n","NPC")
THEN
RESPONSE #100
SelectWeaponAbility(SLOT_WEAPON,0)
SetGlobal("WEAPON_SWAP","GLOBAL",0)
END
// Day Version Not Equiped
IF
ActionListEmpty()
HasItem("weapon_d","NPC")
Global("WEAPON_SWAP","GLOBAL",1)
!HasItemEquipedReal("weapon_d","NPC")
THEN
RESPONSE #100
EquipItem("weapon_d","NPC")
SelectWeaponAbility(SLOT_WEAPON,0)
SetGlobal("WEAPON_SWAP","GLOBAL",0)
END
// Day Version Equiped
IF
ActionListEmpty()
HasItem("weapon_d","NPC")
Global("WEAPON_SWAP","GLOBAL",1)
HasItemEquiped("weapon_d","NPC")
THEN
RESPONSE #100
SelectWeaponAbility(SLOT_WEAPON,0)
SetGlobal("WEAPON_SWAP","GLOBAL",0)
END
Any suggestions?
Thanks!
I have a weapon that will change abilities whether it's day or night. So I have made two versions of the weapon.
I can get the weapon to change on the NPC, but he won't equip it. It's in his weapon slot but NOT in his hand.
Here is the script (I have appended this to baldur.bcs) ...using "weapon_d", "weapon_n" and "NPC" to avoid revealing spoilers.
IF
TimeOfDay(NIGHT)
HasItem("weapon_d","NPC")
THEN
RESPONSE #100
TakeItemReplace("weapon_d","weapon_n","NPC")
SetGlobal("WEAPON_SWAP","GLOBAL",1)
END
IF
TimeOfDay(DAY)
HasItem("weapon_n","NPC")
THEN
RESPONSE #100
TakeItemReplace("weapon_n","weapon_d","NPC")
SetGlobal("WEAPON_SWAP","GLOBAL",1)
END
.....This works so far! The part below, does not...
// Night Version Not Equiped
IF
ActionListEmpty()
HasItem("weapon_n","NPC")
Global("WEAPON_SWAP","GLOBAL",1)
!HasItemEquipedReal("weapon_n","NPC")
THEN
RESPONSE #100
EquipItem("weapon_n","NPC")
SelectWeaponAbility(SLOT_WEAPON,0)
SetGlobal("WEAPON_SWAP","GLOBAL",0)
END
// Night Version Equiped
IF
ActionListEmpty()
HasItem("weapon_n","NPC")
Global("WEAPON_SWAP","GLOBAL",1)
HasItemEquiped("weapon_n","NPC")
THEN
RESPONSE #100
SelectWeaponAbility(SLOT_WEAPON,0)
SetGlobal("WEAPON_SWAP","GLOBAL",0)
END
// Day Version Not Equiped
IF
ActionListEmpty()
HasItem("weapon_d","NPC")
Global("WEAPON_SWAP","GLOBAL",1)
!HasItemEquipedReal("weapon_d","NPC")
THEN
RESPONSE #100
EquipItem("weapon_d","NPC")
SelectWeaponAbility(SLOT_WEAPON,0)
SetGlobal("WEAPON_SWAP","GLOBAL",0)
END
// Day Version Equiped
IF
ActionListEmpty()
HasItem("weapon_d","NPC")
Global("WEAPON_SWAP","GLOBAL",1)
HasItemEquiped("weapon_d","NPC")
THEN
RESPONSE #100
SelectWeaponAbility(SLOT_WEAPON,0)
SetGlobal("WEAPON_SWAP","GLOBAL",0)
END
Any suggestions?
Thanks!
Post edited by CuChoinneach on
0
Comments
If you can determine which slot the weapon is in with a series of GetItemInSlot checks, chances are you could use FillSlot to switch them over. Try DestroyItem and CreateItem in place of TakeItemReplace, also. Perhaps you can go further by trying UseItemSlot...maybe this will equip it by default. The reason that you have to determine which slot with FillSlot is because it destroys anything already in the slot before adding the new item--your sword could be in any one of up to 4 slots depending on player choice. Hells, try FillSlot and then EquipItem, too--might take a combination effort.
The only very reliable way to equip any weapon is with EquipMostDamagingMelee() and EquipRanged(), but this is too general for your needs. Unless you know your blade will do more damage than the others a player may equip. You may just get stuck on this one, sorry.
I made two spells that creates the weapon for day and night version... then in Baldur.bsc appended the following:
IF
TimeOfDay(NIGHT)
HasItem("weapon_d","NPC")
THEN
RESPONSE #100
ActionOverride("NPC",ApplySpellRES("spell_nightversion"))
SetGlobal("MYWEAPON","GLOBAL",1)
Continue()
END
IF
TimeOfDay(DAY)
HasItem("weapon_n","NPC")
THEN
RESPONSE #100
ActionOverride("NPC",ApplySpellRES("spell_dayversion"))
SetGlobal("MYWEAPON","GLOBAL",1)
Continue()
END
Then in a script I added to the NPC Overide:
// Equip Day Version
IF
ActionListEmpty()
HasItem("weapon_d",Myself)
Global("MYWEAPON","GLOBAL",1)
THEN
RESPONSE #100
FillSlot(SLOT_WEAPON0)
EquipMostDamagingMelee()
SetGlobal("MYWEAPON","GLOBAL",0)
Continue()
END
// Night Version Equip
IF
ActionListEmpty()
HasItem("weapon_n",Myself)
Global("MYWEAPON","GLOBAL",1)
THEN
RESPONSE #100
FillSlot(SLOT_WEAPON0)
EquipMostDamagingMelee()
SetGlobal("MYWEAPON","GLOBAL",0)
Continue()
END
Seems to work perfectly!
This might take two spells to accomplish, one to Destroy the old and one to Create the new (at different times), but won't ever destroy the players' +1Longbow (etc) in the effort.
//---- To Remove Weapon THAT IS IN A QUICK SLOT ----
IF
TimeOfDay(NIGHT)
Global("MYWEAPON","GLOBAL",0)
HasItem("weapon_d","NPC")
HasItemEquiped("weapon_d","NPC")
THEN
RESPONSE #100
ActionOverride("NPC",ApplySpellRES("spell_removedayversion"))
Continue()
END
//---- To Remove and CREATE Weapon THAT IS IN INVENTORY ONLY ----
IF
TimeOfDay(NIGHT)
Global("MYWEAPON","GLOBAL",0)
HasItem("weapon_d","NPC")
!HasItemEquiped("weapon_d","NPC")
THEN
RESPONSE #100
ActionOverride("NPC",ApplySpellRES("spell_removedayandcreatenightversion"))
Continue()
SetGlobal("MYWEAPON","GLOBAL",1)
END
//---- Find Empty Slot to Create Weapon ----
IF
TimeOfDay(NIGHT)
Global("MYWEAPON","GLOBAL",0)
!HasItemSlot("NPC",SLOT_WEAPON0)
THEN
RESPONSE #100
ActionOverride("NPC",ApplySpellRES("spell_createnightversion"))
SetGlobal("MYWEAPON","GLOBAL",1)
Continue()
END
IF
TimeOfDay(NIGHT)
Global("MYWEAPON","GLOBAL",0)
!HasItemSlot("NPC",SLOT_WEAPON1)
!HasItem("weapon_n","NPC")
THEN
RESPONSE #100
ActionOverride("NPC",ApplySpellRES("spell_createnightversion"))
SetGlobal("MYWEAPON","GLOBAL",1)
Continue()
END
IF
TimeOfDay(NIGHT)
Global("MYWEAPON","GLOBAL",0)
!HasItemSlot("NPC",SLOT_WEAPON2)
!HasItem("weapon_n","NPC")
THEN
RESPONSE #100
ActionOverride("NPC",ApplySpellRES("spell_createnightversion"))
SetGlobal("MYWEAPON","GLOBAL",1)
Continue()
END
IF
TimeOfDay(NIGHT)
Global("MYWEAPON","GLOBAL",0)
!HasItemSlot("NPC",SLOT_WEAPON3)
!HasItem("weapon_n","NPC")
THEN
RESPONSE #100
ActionOverride("NPC",ApplySpellRES("spell_createnightversion"))
SetGlobal("MYWEAPON","GLOBAL",1)
Continue()
END
This should do it...