Been having issues with getting items to unequip when they are supposed to be considered broken.
object oItem = GetPCItemLastEquipped();
object oPC = GetPCItemLastEquippedBy();
if (GetLocalInt(oItem, "BROKENITEM") == 1){
ClearAllActions(TRUE);
ActionUnequipItem(oItem);
FloatingTextStringOnCreature("This item is broken, and cannot be equipped", oPC);
}
Basically it will not unequip an item with this code....is there something else i can do?
Forcing unequip
Débuté par
Alphamojo
, oct. 14 2011 12:14
#1
Posté 14 octobre 2011 - 12:14
#2
Posté 14 octobre 2011 - 12:59
try removing the clear all actions line.
If that does not work, Then I would guess because the item is already equiped, that is why it is not working. Try adding unequip the item to where the local int is placed on the item.
If that does not work, Then I would guess because the item is already equiped, that is why it is not working. Try adding unequip the item to where the local int is placed on the item.
Modifié par SHOVA, 14 octobre 2011 - 01:02 .
#3
Posté 14 octobre 2011 - 02:24
For a force unequip workaround, I've had to go with copying the item to the PCs inventory complete with variables, then destroying the original. It's a bit crude, but works every time.
I believe that nwnx for linux might actually have a force unequip option, if you're using that, but otherwise the copy/destroy might be your best option.
I believe that nwnx for linux might actually have a force unequip option, if you're using that, but otherwise the copy/destroy might be your best option.
#4
Posté 14 octobre 2011 - 02:31
Copy/Destroy might be your best option, but with this code you'll want to assign those actions to the PC since it actually the module which is running the OnUnequip event. So change these lines:
ClearAllActions(TRUE);
ActionUnequipItem(oItem);
to these:
AssignCommand(oPC, ClearAllActions(TRUE));
AssignCommand(oPC, ActionUnequipItem(oItem));
ClearAllActions(TRUE);
ActionUnequipItem(oItem);
to these:
AssignCommand(oPC, ClearAllActions(TRUE));
AssignCommand(oPC, ActionUnequipItem(oItem));
#5
Posté 14 octobre 2011 - 04:04
So with what everyone has already said:
void main()
{
object oItem = GetPCItemLastEquipped();
object oPC = GetPCItemLastEquippedBy();
if (GetLocalInt(oItem, "BROKENITEM") == 1)
{
AssignCommand(oPC, ActionUnequipItem(oItem));
FloatingTextStringOnCreature("This item is broken, and cannot be equipped", oPC);
}
}
void main()
{
object oItem = GetPCItemLastEquipped();
object oPC = GetPCItemLastEquippedBy();
if (GetLocalInt(oItem, "BROKENITEM") == 1)
{
AssignCommand(oPC, ActionUnequipItem(oItem));
FloatingTextStringOnCreature("This item is broken, and cannot be equipped", oPC);
}
}
#6
Posté 14 octobre 2011 - 04:26
Best option. The code posted by GoG is highly vulnerable to exploits allowing to retain item equipped.Failed.Bard wrote...
For a force unequip workaround, I've had to go with copying the item to the PCs inventory complete with variables, then destroying the original. It's a bit crude, but works every time.
Second best option is to make more than one unequip calls with slight delay.
Modifié par ShaDoOoW, 14 octobre 2011 - 04:27 .
#7
Posté 14 octobre 2011 - 04:38
ShaDoOoW wrote...
Best option. The code posted by GoG is highly vulnerable to exploits allowing to retain item equipped.Failed.Bard wrote...
For a force unequip workaround, I've had to go with copying the item to the PCs inventory complete with variables, then destroying the original. It's a bit crude, but works every time.
Second best option is to make more than one unequip calls with slight delay.
Oh yeah. I completely forgot about the needed delay. And the bug with the item getting "stuck" in the slot or what not if there is no delay.
#8
Posté 14 octobre 2011 - 10:23
Thanks guys, I did try copy/destroy option before coming here problem I ran into there was when the character died ( item damage could occur as death penalty ) and items broke seemed to not work to well.
I will try out the assign command, haha i did use delays to try a bully the unequip haha but thought i was being silly...nice to know i was somewhat on right path.
As always thanks, this community still rocks 11 years running =)
I will try out the assign command, haha i did use delays to try a bully the unequip haha but thought i was being silly...nice to know i was somewhat on right path.
As always thanks, this community still rocks 11 years running =)
#9
Posté 18 octobre 2011 - 06:27
Here's an exploit-proof unequipper script:
This clause:
if (GetIsPC(oTarget))
AssignCommand(oTarget, ExecuteScript("fky_deathprocess", oTarget));
is only necessary if you have a script you execute when a player is brought back to life, in which case you would substitute the name of that script. Otherwise just remove that if clause.
Funky
void ForceUnequip (object oTarget, object oItem) {
if (!GetIsObjectValid(oTarget) || GetObjectType(oTarget) != OBJECT_TYPE_CREATURE)
return;
if (!GetIsObjectValid(GetArea(oTarget))) {
DelayCommand(5.0, ForceUnequip(oTarget, oItem));
return;
}
if (GetIsDead(oTarget)) {
ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectResurrection(), oTarget);
ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectHeal(GetMaxHitPoints(oTarget)), oTarget);
if (GetIsPC(oTarget))
AssignCommand(oTarget, ExecuteScript("fky_deathprocess", oTarget));
DelayCommand(0.1, ForceUnequip(oTarget, oItem));
} else {
AssignCommand(oTarget, ClearAllActions(TRUE));
AssignCommand(oTarget, ActionUnequipItem(oItem));
AssignCommand(oTarget, ActionDoCommand(SetCommandable(TRUE)));
AssignCommand(oTarget, SetCommandable(FALSE));
}
}
This clause:
if (GetIsPC(oTarget))
AssignCommand(oTarget, ExecuteScript("fky_deathprocess", oTarget));
is only necessary if you have a script you execute when a player is brought back to life, in which case you would substitute the name of that script. Otherwise just remove that if clause.
Funky
Modifié par FunkySwerve, 18 octobre 2011 - 06:29 .
#10
Posté 18 octobre 2011 - 12:10
Awesome thanks Funky!





Retour en haut






