Aller au contenu

Photo

Disarm weapon script?


  • Veuillez vous connecter pour répondre
22 réponses à ce sujet

#1
Vhaeraun Baenre

Vhaeraun Baenre
  • Members
  • 45 messages
 Shocked to find zero of these on the vault. I know ive played on servers where if you do a succesful disarm your enemies weapon goes into its backpack instead of falling to the ground. I am also wanting there to be a short period before that weapon can be reequipped if thats possible.

 Anyone know?

#2
GhostOfGod

GhostOfGod
  • Members
  • 863 messages
You would need to alter your modules "OnUnAcquireItem" script. This is what the default "x2_mod_def_unaqu" script would look like with the needed changes:


//::///////////////////////////////////////////////
//:: Example XP2 OnItemUnAcquireScript
//:: x2_mod_def_unaqu
//:: © 2003 Bioware Corp.
//:://////////////////////////////////////////////
/*

    Put into: OnItemUnAcquire Event

*/
//:://////////////////////////////////////////////
//:: Created By: Georg Zoeller
//:: Created On: 2003-07-16
//:://////////////////////////////////////////////

#include "x2_inc_switches"
#include "x2_inc_itemprop"
void main()
{
     object oItem = GetModuleItemLost();

     ///////////////////////////////////////////////////////////////////////////

     //::Added to place disarmed weapons back into a player inventory.
     ///////////////////////////////////////////////////////////////////////////
     object oPC = GetModuleItemLostBy();
     int iLoopStop = GetLocalInt(oItem, "LOOP_STOP");

     if (GetIsPC(oPC) && GetIsInCombat(oPC))
        {
        if (IPGetIsMeleeWeapon(oItem))
            {
            if (iLoopStop != TRUE)
                {
                SetLocalInt(oItem, "LOOP_STOP", TRUE);

                object oCopy = CopyItem(oItem, oPC, TRUE);
                DelayCommand(2.0, DeleteLocalInt(oCopy, "LOOP_STOP"));
                DestroyObject(oItem, 0.0);
                }
            }

        }
     ///////////////////////////////////////////////////////////////////////////

     // * Generic Item Script Execution Code
     // * If MODULE_SWITCH_EXECUTE_TAGBASED_SCRIPTS is set to TRUE on the module,

     // * it will execute a script that has the same name as the item's tag
     // * inside this script you can manage scripts for all events by checking against
     // * GetUserDefinedItemEventNumber(). See x2_it_example.nss

     if (GetModuleSwitchValue(MODULE_SWITCH_ENABLE_TAGBASED_SCRIPTS) == TRUE)
     {
        SetUserDefinedItemEventNumber(X2_ITEM_EVENT_UNACQUIRE);
        int nRet =   ExecuteScriptAndReturnInt(GetUserDefinedItemEventScriptName(oItem),OBJECT_SELF);

        if (nRet == X2_EXECUTE_SCRIPT_END)
        {
           return;
        }
    }
}


This does not include anything for delaying the ability to equipp the weapon again. I suppose you could just add another variable to the weapon and then add a delay to delete the variable. Then go to your "OnPlayerEquipItem" script and do a check for the variable. If found then unequip the weapon?

Hope this helps. good luck.

P.S. This also takes into consideration the fact that the players inventory might be full. In which case the item will still have to go onto the ground.

Modifié par GhostOfGod, 25 novembre 2010 - 12:09 .


#3
Vhaeraun Baenre

Vhaeraun Baenre
  • Members
  • 45 messages
wow thanks for this. I will test it out soon. I am terrible with scripting beyond Lilacs generator so I really do appreciate it.

#4
Baragg

Baragg
  • Members
  • 271 messages
Can only melee weapons be disarmed?

#5
GhostOfGod

GhostOfGod
  • Members
  • 863 messages

Baragg wrote...

Can only melee weapons be disarmed?


I was under the impression that was the case. However since I've never used it I am most likely mistaken.

If Baragg is correct then this line:

if (IPGetIsMeleeWeapon(oItem))

should be changed to:

if (IPGetIsMeleeWeapon(oItem) || IPGetIsRangedWeapon(oItem))

#6
FunkySwerve

FunkySwerve
  • Members
  • 1 308 messages
Here's our function for this, which includes CEP weapon types:
int GetItemIsWeapon (object oItem) {
    switch (GetBaseItemType(oItem)) {
        case BASE_ITEM_CLUB:
        case BASE_ITEM_DIREMACE:
        case BASE_ITEM_HEAVYFLAIL:
        case BASE_ITEM_LIGHTFLAIL:
        case BASE_ITEM_LIGHTHAMMER:
        case BASE_ITEM_LIGHTMACE:
        case BASE_ITEM_MORNINGSTAR:
        case BASE_ITEM_QUARTERSTAFF:
        case BASE_ITEM_WARHAMMER:

        case BASE_ITEM_DAGGER:
        case BASE_ITEM_RAPIER:
        case BASE_ITEM_SHORTSPEAR:
        case BASE_ITEM_SHORTSWORD:
        case BASE_ITEM_TRIDENT:
        case BASE_ITEM_LANCE:

        case BASE_ITEM_BASTARDSWORD:
        case BASE_ITEM_BATTLEAXE:
        case BASE_ITEM_DOUBLEAXE:
        case BASE_ITEM_DWARVENWARAXE:
        case BASE_ITEM_GREATAXE:
        case BASE_ITEM_GREATSWORD:
        case BASE_ITEM_HALBERD:
        case BASE_ITEM_HANDAXE:
        case BASE_ITEM_KAMA:
        case BASE_ITEM_KATANA:
        case BASE_ITEM_KUKRI:
        case BASE_ITEM_LONGSWORD:
        case BASE_ITEM_SCIMITAR:
        case BASE_ITEM_SCYTHE:
        case BASE_ITEM_SICKLE:
        case BASE_ITEM_TWOBLADEDSWORD:
        case BASE_ITEM_WHIP:

        case BASE_ITEM_DART:
        case BASE_ITEM_HEAVYCROSSBOW:
        case BASE_ITEM_LIGHTCROSSBOW:
        case BASE_ITEM_LONGBOW:
        case BASE_ITEM_SHORTBOW:
        case BASE_ITEM_SHURIKEN:
        case BASE_ITEM_SLING:
        case BASE_ITEM_THROWINGAXE:

        case BASE_ITEM_MAGICSTAFF:

        case BASE_ITEM_CEP_ASSASSINDAGGER:
        case BASE_ITEM_CEP_DOUBLEPICK:
        case BASE_ITEM_CEP_DOUBLESCIMITAR:
        case BASE_ITEM_CEP_FALCHION:
        case BASE_ITEM_CEP_GOAD:
        case BASE_ITEM_CEP_HEAVYMACE:
        case BASE_ITEM_CEP_HEAVYPICK:
        case BASE_ITEM_CEP_KATAR:
        case BASE_ITEM_CEP_LIGHTPICK:
        case BASE_ITEM_CEP_MAUL:
        case BASE_ITEM_CEP_MERCURIALGREATSWORD:
        case BASE_ITEM_CEP_MERCURIALLONGSWORD:
        case BASE_ITEM_CEP_NUNCHAKU:
        case BASE_ITEM_CEP_SAI:
        case BASE_ITEM_CEP_SAP:
        case BASE_ITEM_CEP_WINDFIREWHEEL:
            return TRUE;
    }

    return FALSE;
}

Here are all the non-standard consts:

const int BASE_ITEM_LANCE                                         = 92;
const int BASE_ITEM_TRUMPET                                       = 93;
const int BASE_ITEM_MOONONASTICK                                  = 94;
const int BASE_ITEM_CRAFTBASE                                     = 112;
const int BASE_ITEM_CEP_COINS                                     = 203;
const int BASE_ITEM_CEP_THINBOX                                   = 204;
const int BASE_ITEM_CEP_HERB_SMALL                                = 205;
const int BASE_ITEM_CEP_HERB_THIN                                 = 206;
const int BASE_ITEM_CEP_STACKSMALL_1                              = 207;
const int BASE_ITEM_CEP_PELT_LARGE                                = 208;
const int BASE_ITEM_CEP_PELT_THIN                                 = 209;
const int BASE_ITEM_CEP_TINYSPEAR                                 = 210;
const int BASE_ITEM_CEP_MISCSMALL_3                               = 211;
const int BASE_ITEM_CEP_MISCMEDIUM_3                              = 212;
const int BASE_ITEM_CEP_DYE                                       = 224;
const int BASE_ITEM_CEP_TRIDENT                                   = 300;
const int BASE_ITEM_CEP_HEAVYPICK                                 = 301;
const int BASE_ITEM_CEP_LIGHTPICK                                 = 302;
const int BASE_ITEM_CEP_SAI                                       = 303;
const int BASE_ITEM_CEP_NUNCHAKU                                  = 304;
const int BASE_ITEM_CEP_FALCHION                                  = 305;
const int BASE_ITEM_CEP_SMALLBOX                                  = 306;
const int BASE_ITEM_CEP_MISCMEDIUM_2                              = 307;
const int BASE_ITEM_CEP_SAP                                       = 308;
const int BASE_ITEM_CEP_ASSASSINDAGGER                            = 309;
const int BASE_ITEM_CEP_KATAR                                     = 310;
const int BASE_ITEM_CEP_MISCSMALL_2                               = 311;
const int BASE_ITEM_CEP_FASHION_ACCESSORY                         = 314;
const int BASE_ITEM_CEP_HEAVYMACE                                 = 317;
const int BASE_ITEM_CEP_MAUL                                      = 318;
const int BASE_ITEM_CEP_MERCURIALLONGSWORD                        = 319;
const int BASE_ITEM_CEP_MERCURIALGREATSWORD                       = 320;
const int BASE_ITEM_CEP_DOUBLESCIMITAR                            = 321;
const int BASE_ITEM_CEP_GOAD                                      = 322;
const int BASE_ITEM_CEP_WINDFIREWHEEL                             = 323;
const int BASE_ITEM_CEP_DOUBLEPICK                                = 324;
const int BASE_ITEM_CEP_FLOWERS                                   = 325;
const int BASE_ITEM_CEP_CLOAK                                     = 349;
const int BASE_ITEM_CEP_RING_2                                    = 350;
const int BASE_ITEM_CEP_AMULET_2                                  = 351;
const int BASE_ITEM_CEP_BUCKLER                                   = 352;
const int BASE_ITEM_CEP_RING_ARMOR                                = 353;
const int BASE_ITEM_CEP_RING_NATURAL                              = 354;
const int BASE_ITEM_CEP_RING_SHIELD                               = 355;
const int BASE_ITEM_CEP_AMULET_ARMOR                              = 356;
const int BASE_ITEM_CEP_AMULET_DEFLECT                            = 357;
const int BASE_ITEM_CEP_AMULET_SHIELD                             = 358;
const int BASE_ITEM_CEP_BELT_ARMOR                                = 359;
const int BASE_ITEM_CEP_BELT_NATURAL                              = 360;
const int BASE_ITEM_CEP_BELT_SHIELD                               = 361;
const int BASE_ITEM_CEP_BRACER_SHIELD                             = 362;
const int BASE_ITEM_CEP_CLOAK_ARMOR                               = 363;
const int BASE_ITEM_CEP_CLOAK_DODGE                               = 364;
const int BASE_ITEM_CEP_CLOAK_NATURAL                             = 365;
const int BASE_ITEM_CEP_CLOAK_SHIELD                              = 366;
const int BASE_ITEM_CEP_TORCH_SHIELD                              = 367;
const int BASE_ITEM_CEP_RING_2_ARMOR                              = 368;
const int BASE_ITEM_CEP_RING_2_NATURAL                            = 369;
const int BASE_ITEM_CEP_RING_2_SHIELD                             = 370;
const int BASE_ITEM_CEP_AMULET_2_ARMOR                            = 371;
const int BASE_ITEM_CEP_AMULET_2_DEFLECT                          = 372;
const int BASE_ITEM_CEP_AMULET_2_SHIELD                           = 373;
const int BASE_ITEM_CEP_RUNESTONE                                 = 374;
const int BASE_ITEM_CEP_HELMET_ARMOR                              = 375;
const int BASE_ITEM_CEP_GLOVES_SPIKED                             = 376;
const int BASE_ITEM_CEP_GLOVES_BLADED                             = 377;
const int BASE_ITEM_CEP_MISCSMALL_4                               = 380;
const int BASE_ITEM_CEP_MISCMEDIUM_4                              = 381;
const int BASE_ITEM_CEP_MISCTHIN_2                                = 382;
const int BASE_ITEM_CEP_MISCTHIN_3                                = 383;
const int BASE_ITEM_CEP_MISCTHIN_4                                = 384;
const int BASE_ITEM_CEP_MISCLARGE_2                               = 385;
const int BASE_ITEM_CEP_MISCLARGE_3                               = 386;
const int BASE_ITEM_CEP_MISCLARGE_4                               = 387;
const int BASE_ITEM_CEP_STACKSMALL_2                              = 388;
const int BASE_ITEM_CEP_STACKSMALL_3                              = 389;
const int BASE_ITEM_CEP_STACKSMALL_4                              = 390;
const int BASE_ITEM_CEP_STACKMEDIUM_1                             = 391;
const int BASE_ITEM_CEP_STACKMEDIUM_2                             = 392;
const int BASE_ITEM_CEP_STACKMEDIUM_3                             = 393;
const int BASE_ITEM_CEP_STACKMEDIUM_4                             = 394;
const int BASE_ITEM_CEP_STACKTHIN_1                               = 395;
const int BASE_ITEM_CEP_STACKTHIN_2                               = 396;
const int BASE_ITEM_CEP_STACKTHIN_3                               = 397;
const int BASE_ITEM_CEP_STACKTHIN_4                               = 398;
const int BASE_ITEM_CEP_STACKLARGE_1                              = 399;
const int BASE_ITEM_CEP_STACKLARGE_2                              = 400;
const int BASE_ITEM_CEP_STACKLARGE_3                              = 401;
const int BASE_ITEM_CEP_STACKLARGE_4                              = 402;

Funky

Modifié par FunkySwerve, 25 novembre 2010 - 11:24 .


#7
Vhaeraun Baenre

Vhaeraun Baenre
  • Members
  • 45 messages
so what would that look like combined with the other script then? ;)

#8
GhostOfGod

GhostOfGod
  • Members
  • 863 messages
Ok. So with Funky's function(slightly altered) and implementing the delay for equipping the disarmed weapon, the new "OnUnAcquireItem" script would look something like so(the red highlited part is what I added for the equip delay. You can adjust the ten seconds to however long you want):

//::///////////////////////////////////////////////
//:: Example XP2 OnItemUnAcquireScript
//:: x2_mod_def_unaqu
//:: © 2003 Bioware Corp.
//:://////////////////////////////////////////////
/*

    Put into: OnItemUnAcquire Event

*/
//:://////////////////////////////////////////////
//:: Created By: Georg Zoeller
//:: Created On: 2003-07-16
//:://////////////////////////////////////////////

#include "x2_inc_switches"
#include "x2_inc_itemprop"
#include "zep_inc_main"

//GetItemIsWeapon prototype:
int GetItemIsWeapon(object oItem);

const int BASE_ITEM_LANCE = 92;
const int BASE_ITEM_DOUBLEPICK = 324;

void main()
{
    object oItem = GetModuleItemLost();

    ///////////////////////////////////////////////////////////////////////////

    //::Added to place disarmed weapons back into a player inventory.
    ///////////////////////////////////////////////////////////////////////////
    object oPC = GetModuleItemLostBy();
    int iLoopStop = GetLocalInt(oItem, "LOOP_STOP");

    if (GetIsPC(oPC) && GetIsInCombat(oPC))
    {
        if (GetItemIsWeapon(oItem))
        {
            if (iLoopStop != TRUE)
            {
                SetLocalInt(oItem, "LOOP_STOP", TRUE);
                SetLocalInt(oItem, "EQUIP_DELAY", TRUE);
                object oCopy = CopyItem(oItem, oPC, TRUE);
                DelayCommand(2.0, DeleteLocalInt(oCopy, "LOOP_STOP"));
                //Equip delay below:
                DelayCommand(10.0, DeleteLocalInt(oCopy, "EQUIP_DELAY"));
                DestroyObject(oItem, 0.0);
            }
        }
    }
     ///////////////////////////////////////////////////////////////////////////

     // * Generic Item Script Execution Code
     // * If MODULE_SWITCH_EXECUTE_TAGBASED_SCRIPTS is set to TRUE on the module,

     // * it will execute a script that has the same name as the item's tag
     // * inside this script you can manage scripts for all events by checking against
     // * GetUserDefinedItemEventNumber(). See x2_it_example.nss

     if (GetModuleSwitchValue(MODULE_SWITCH_ENABLE_TAGBASED_SCRIPTS) == TRUE)
     {
        SetUserDefinedItemEventNumber(X2_ITEM_EVENT_UNACQUIRE);
        int nRet =   ExecuteScriptAndReturnInt(GetUserDefinedItemEventScriptName(oItem),OBJECT_SELF);

        if (nRet == X2_EXECUTE_SCRIPT_END)
        {
           return;
        }
    }
}

int GetItemIsWeapon(object oItem)
{
    switch (GetBaseItemType(oItem))
    {
        case BASE_ITEM_CLUB:
        case BASE_ITEM_DIREMACE:
        case BASE_ITEM_HEAVYFLAIL:
        case BASE_ITEM_LIGHTFLAIL:
        case BASE_ITEM_LIGHTHAMMER:
        case BASE_ITEM_LIGHTMACE:
        case BASE_ITEM_MORNINGSTAR:
        case BASE_ITEM_QUARTERSTAFF:
        case BASE_ITEM_WARHAMMER:

        case BASE_ITEM_DAGGER:
        case BASE_ITEM_RAPIER:
        case BASE_ITEM_SHORTSPEAR:
        case BASE_ITEM_SHORTSWORD:
        case BASE_ITEM_TRIDENT:
        case BASE_ITEM_LANCE:

        case BASE_ITEM_BASTARDSWORD:
        case BASE_ITEM_BATTLEAXE:
        case BASE_ITEM_DOUBLEAXE:
        case BASE_ITEM_DWARVENWARAXE:
        case BASE_ITEM_GREATAXE:
        case BASE_ITEM_GREATSWORD:
        case BASE_ITEM_HALBERD:
        case BASE_ITEM_HANDAXE:
        case BASE_ITEM_KAMA:
        case BASE_ITEM_KATANA:
        case BASE_ITEM_KUKRI:
        case BASE_ITEM_LONGSWORD:
        case BASE_ITEM_SCIMITAR:
        case BASE_ITEM_SCYTHE:
        case BASE_ITEM_SICKLE:
        case BASE_ITEM_TWOBLADEDSWORD:
        case BASE_ITEM_WHIP:

        case BASE_ITEM_DART:
        case BASE_ITEM_HEAVYCROSSBOW:
        case BASE_ITEM_LIGHTCROSSBOW:
        case BASE_ITEM_LONGBOW:
        case BASE_ITEM_SHORTBOW:
        case BASE_ITEM_SHURIKEN:
        case BASE_ITEM_SLING:
        case BASE_ITEM_THROWINGAXE:

        case BASE_ITEM_MAGICSTAFF:

        case BASE_ITEM_DAGGERASSASSIN:
        case BASE_ITEM_DOUBLEPICK:
        case BASE_ITEM_KUKRI2:
        case BASE_ITEM_TRIDENT_1H:
        case BASE_ITEM_DOUBLESCIMITAR:
        case BASE_ITEM_FALCHION1:
        case BASE_ITEM_FALCHION2:
        case BASE_ITEM_GOAD:
        case BASE_ITEM_HEAVYMACE:
        case BASE_ITEM_HEAVYPICK:
        case BASE_ITEM_KATAR:
        case BASE_ITEM_LIGHTPICK:
        case BASE_ITEM_MAUL:
        case BASE_ITEM_MERCURIALGREATSWORD:
        case BASE_ITEM_MERCURIALLONGSWORD:
        case BASE_ITEM_NUNCHAKU:
        case BASE_ITEM_SAI:
        case BASE_ITEM_SAP:
        case BASE_ITEM_WINDFIREWHEEL:
        return TRUE;
    }
    return FALSE;
}


And then you need to add to your modules "OnPlayerEquipItem" script. The red highlighted section is all I added to the default "x2_mod_def_equ" script.

//::///////////////////////////////////////////////
//:: Example XP2 OnItemEquipped
//:: x2_mod_def_equ
//:: © 2003 Bioware Corp.
//:://////////////////////////////////////////////
/*
    Put into: OnEquip Event
*/
//:://////////////////////////////////////////////
//:: Created By: Georg Zoeller
//:: Created On: 2003-07-16
//:://////////////////////////////////////////////
//:: Modified By: Deva Winblood
//:: Modified On: April 15th, 2008
//:: Added Support for Mounted Archery Feat penalties
//:://////////////////////////////////////////////

#include "x2_inc_switches"
#include "x2_inc_intweapon"
#include "x3_inc_horse"

void main()
{

    object oItem = GetPCItemLastEquipped();
    object oPC   = GetPCItemLastEquippedBy();

    if (GetLocalInt(oItem, "EQUIP_DELAY"))
    {
        ActionUnequipItem(oItem);
        SendMessageToPC(oPC, "You must wait 10 seconds before equipping this weapon.");
        return;
    }

    // -------------------------------------------------------------------------
    // Intelligent Weapon System
    // -------------------------------------------------------------------------
    if (IPGetIsIntelligentWeapon(oItem))
    {
        IWSetIntelligentWeaponEquipped(oPC,oItem);
        // prevent players from reequipping their weapon in
        if (IWGetIsInIntelligentWeaponConversation(oPC))
        {
                object oConv =   GetLocalObject(oPC,"X2_O_INTWEAPON_SPIRIT");
                IWEndIntelligentWeaponConversation(oConv, oPC);
        }
        else
        {
            //------------------------------------------------------------------
            // Trigger Drain Health Event
            //------------------------------------------------------------------
            if (GetLocalInt(oPC,"X2_L_ENSERRIC_ASKED_Q3")==1)
            {
                ExecuteScript ("x2_ens_dodrain",oPC);
            }
            else
            {
                IWPlayRandomEquipComment(oPC,oItem);
            }
        }
    }

    // -------------------------------------------------------------------------
    // Mounted benefits control
    // -------------------------------------------------------------------------
    if (GetWeaponRanged(oItem))
    {
        SetLocalInt(oPC,"bX3_M_ARCHERY",TRUE);
        HORSE_SupportAdjustMountedArcheryPenalty(oPC);
    }

    // -------------------------------------------------------------------------
    // Generic Item Script Execution Code
    // If MODULE_SWITCH_EXECUTE_TAGBASED_SCRIPTS is set to TRUE on the module,
    // it will execute a script that has the same name as the item's tag
    // inside this script you can manage scripts for all events by checking against
    // GetUserDefinedItemEventNumber(). See x2_it_example.nss
    // -------------------------------------------------------------------------
    if (GetModuleSwitchValue(MODULE_SWITCH_ENABLE_TAGBASED_SCRIPTS) == TRUE)
    {
        SetUserDefinedItemEventNumber(X2_ITEM_EVENT_EQUIP);
        int nRet =   ExecuteScriptAndReturnInt(GetUserDefinedItemEventScriptName(oItem),OBJECT_SELF);
        if (nRet == X2_EXECUTE_SCRIPT_END)
        {
            return;
        }
    }
}


Hope that is what you needed. Good luck.

#9
Vhaeraun Baenre

Vhaeraun Baenre
  • Members
  • 45 messages
You are too kind GoG... i will test this soon to make sure it works. thanks so much

#10
CheeseshireCat

CheeseshireCat
  • Members
  • 48 messages
Note that it would also do funny stuff if you just try to drop a weapon from inventory in the middle of combat (imagine having to pass one over to another player if meeting a monster with resistances they need to overcome?), or equip a different weapon with your inventory cluttered enough.

#11
ffbj

ffbj
  • Members
  • 593 messages
Why not just use item equipped right-hand then left hand, and just unequip whatever they are holding in their hands. Much simpler.  Check the right hand first, which will unequip bows, 2hnaded weapons, .and if nothing is in the right hand go to the left hand.  Of course then you would have to check if it's a shield or not.  Personally I would just leave it right hand which encompasses everything except an off-hand weapon. 

Modifié par ffbj, 28 novembre 2010 - 04:25 .


#12
CheeseshireCat

CheeseshireCat
  • Members
  • 48 messages
Because they were trying to intercept standard disarm, not replace it.

#13
ffbj

ffbj
  • Members
  • 593 messages
It's the same difference.  As far as the delay to use the weapon (item disarmed) again that could be handled by setting a local on the weapon so that you can't re-equip it for 6 seconds or whatever and then deleting that local off the weapon with a delay. The problem though would be describing the item once it is lost as having been in the right hand.  Now there you could run into trouble, though simply describing inventory slot item first, as below, should work. The idea of setting a local would still work with the lost item. Anyway something along these lines where you could have the onequipped also check for the set local disarmed and if it is present you can't equip that item, for a few seconds. Not a complete script:

#include "x2_inc_switches"
void main()
{
     object oDisarmed = GetItemInSlot(INVENTORY_SLOT_RIGHTHAND, OBJECT_SELF);
     object oItem = GetModuleItemLost();
     if (GetIsInCombat(OBJECT_SELF) && (oItem == oDisarmed))
      {
     SetLocalInt (oDisarmed, "Disarmed", 1);
     DelayCommand (6.0, DeleteLocalInt(oDisarmed, "Disarmed"));
     }

So not sure about the difference as far as in the disarm feature the item actually gets destroyed and then recreated in the PC's inventory.  So there the local int might be lost, which should not be a problem either since when you recreate it, the item, if the int would be lost, you just set it, the int, on the recreated item. 

Modifié par ffbj, 28 novembre 2010 - 06:06 .


#14
Baragg

Baragg
  • Members
  • 271 messages
Wouldn't there need to be a check to insure that if they unacquire an item in combat that item actually goes to the ground?

#15
FunkySwerve

FunkySwerve
  • Members
  • 1 308 messages
It's probably worth pointing out that we actually went out of our way to put the item in inventory instead of on the ground, because players would fail to notice the disarm until they'd moved on, often after the item was wiped by our area cleaning scripts. We use a custom event hook for disarm, thanks to one of acaos' engine hacks. Here's the code, in case it's of any help (you won't be able to simply use it, since it's a script that is called from a custom 'disarm' event, but it can still provide a lot of useful code):

#include "hg_inc"
#include "ac_itemprop_inc"
#include "ac_itemenh_inc"


int ABFeat (object oPC, int nFeat, int nBonus) {
    if (nFeat > 0 && GetHasFeat(nFeat, oPC))
        return nBonus;

    return 0;
}

int GetTotalAttackBonus (object oPC) {
    /* include +20 magical bonus always */
    int nAB = GetBaseAttackBonus(oPC) + 20;

    if (GetHitDice(oPC) == 40)
        nAB = (nAB - 20) + GetLocalInt(oPC, "LegendaryBAB");

    int nBaseItem = BASE_ITEM_GLOVES;
    object oWeapon = GetItemInSlot(INVENTORY_SLOT_RIGHTHAND, oPC);
    if (GetIsObjectValid(oWeapon))
        nBaseItem = GetBaseItemType(oWeapon);

    nAB += ABFeat(oPC, FEAT_EPIC_PROWESS,                 1);
    nAB += ABFeat(oPC, GetWeaponFocusFeat(nBaseItem),     1);
    nAB += ABFeat(oPC, GetWeaponEpicFocusFeat(nBaseItem), 2);
    nAB += GetAttackBonusAdjustment(oPC, oWeapon, 0);

    int nWM = GetLevelByclass(class_TYPE_WEAPON_MASTER, oPC);

    if (nWM >= 5 && ABFeat(oPC, GetWeaponOfChoiceFeat(nBaseItem), 1) > 0) {
        nAB++;

        if (nWM >= 10)
            nAB += (nWM - 10) / 3;
    }

    return nAB;
}


void main () {
    object oPC = OBJECT_SELF;
    object oTarget = GetLocalObject(oPC, "EventTarget");

    DeleteLocalObject(oPC, "EventTarget");

    if (!GetIsObjectValid(oPC) || !GetIsObjectValid(oTarget) || !GetIsTarget(oTarget))
        return;

    if (GetDistanceBetween(oPC, oTarget) > RADIUS_SIZE_LARGE) {
        FloatingTextStringOnCreature("You must be closer to your target to disarm it!", oPC, FALSE);
        return;
    }

    if (GetItemIsRangedWeapon(GetItemInSlot(INVENTORY_SLOT_RIGHTHAND, oPC))) {
        FloatingTextStringOnCreature("You cannot disarm with a ranged weapon!", oPC, FALSE);
        return;
    }

    object oWeapon = GetItemInSlot(INVENTORY_SLOT_RIGHTHAND, oTarget);

    if (!GetIsObjectValid(oWeapon)) {
        FloatingTextStringOnCreature("You cannot disarm that target!", oPC, FALSE);
        return;
    }

    int bDisarmable;

    if (!GetIsPC(oTarget) && !GetDroppableFlag(oWeapon)) {
        SetLocalInt(oWeapon, "REPLACED", 1);
        SetDroppableFlag(oWeapon, TRUE);
        bDisarmable = GetIsCreatureDisarmable(oTarget);
        SetDroppableFlag(oWeapon, FALSE);
    } else
        bDisarmable = GetIsCreatureDisarmable(oTarget);

    if (!bDisarmable) {
        FloatingTextStringOnCreature("You cannot disarm that target!", oPC, FALSE);
        return;
    }


    float fDelay = (GetHasFeat(HGFEAT_SUPERIOR_DISARM, oPC) ? 3.0 : 6.0);
    if (!CheckSwiftAction(oPC, fDelay))
        return;


    SignalEvent(oTarget, EventSpellCastAt(OBJECT_SELF, SPELL_BIGBYS_FORCEFUL_HAND));

    int nAB = GetTotalAttackBonus(oPC);
    int nDC = (GetHasFeat(FEAT_IMPROVED_DISARM, oPC) ? 15 : 25);
    int nDisc = GetSkillRank(SKILL_DISCIPLINE, oTarget);
    int nDisarmAdjustment = nDisc/10;
    nDC += nDisc + d20() - nDisarmAdjustment;

    int nCheck = GetSkillCheckResult(1000, oPC, nDC, TRUE, -1, oTarget, 0.0, 0, nAB);

    if (nCheck > 0) {
        effect eDisarm = EffectDisarm(0);
        ApplyEffectToObject(DURATION_TYPE_INSTANT, eDisarm, oTarget);
    }
}

Let me know if you want to see any of the subfunctions.

Funky

#16
GhostOfGod

GhostOfGod
  • Members
  • 863 messages
As CheshireCat pointed out there are a few odd things that would happen intercepting the disarm in this manner. But these could also be viewed as posostives. Just depends on how you look at it.

If a player is in combat and they hand someone a weapon from their inventory, the weapon will just be destroyed and the new one created back into the players inventory. This can just be viewed as "You are too busy fighting to fish around in your back pack for that dagger with the slashing resistence to give to your budy".

And it is a deterent for players to pickpocket other players while in combat. If the pick pocket snags a nice weapon...it gets destroyed and gos back to the original player.

As far as switching weapons while in combat, that shouldn't be a problem since they don't unacquire the item.

I was a bit confused about your solution ffbj. Not sure how that would work.

#17
CheeseshireCat

CheeseshireCat
  • Members
  • 48 messages
The item will get unacquired when switching if you have little free space due to full and/or cluttered inventory.



Remember, when switching weapons, you unequip first, equip later. So if, for example, you had an axe (2x3) and a great shield (2x4) equipped, but due to some reason needed to switch to, say, a quarterstaff (1x4), if you don't have free 2x3 space, and 2x4 after that, the shield and maybe even axe would get dropped. Then the staff gets equipped, then you destroy the axe, then try to push it in again. If there still isn't room, it could mess things up even more.



How I would go about it is to replace the whole standard disarm script instead of trying to hotfix its results on the fly.

#18
Lightfoot8

Lightfoot8
  • Members
  • 2 535 messages

CheeseshireCat wrote...

How I would go about it is to replace the whole standard disarm script instead of trying to hotfix its results on the fly.


There is the problem, The disarm is hard coded.  Unless of cource you have hacked the server, like funky has.

#19
GhostOfGod

GhostOfGod
  • Members
  • 863 messages

CheeseshireCat wrote...

The item will get unacquired when switching if you have little free space due to full and/or cluttered inventory.

Remember, when switching weapons, you unequip first, equip later. So if, for example, you had an axe (2x3) and a great shield (2x4) equipped, but due to some reason needed to switch to, say, a quarterstaff (1x4), if you don't have free 2x3 space, and 2x4 after that, the shield and maybe even axe would get dropped. Then the staff gets equipped, then you destroy the axe, then try to push it in again. If there still isn't room, it could mess things up even more.

How I would go about it is to replace the whole standard disarm script instead of trying to hotfix its results on the fly.


That's why I put the infinite loop check in. So even if a player switches weapons(And only a weapon and while in combat) and there is no room in the inventory, it will drop to the ground, the unacquire fires, the weapon wil try once to be recreated in the inventory, if there is no room the new one will drop to the ground and stay there as it normaly would if the inventory was too full.

It's been working for us in our meager pw.

#20
ffbj

ffbj
  • Members
  • 593 messages
GoG My thinking is that since the disarm feat flags the weapon as lost all that needs to be done is to get the weapon in the inventory slot rh, and if it's lost, i.e disarmed then set an int the disarmed/lost weapon so it can't be re-equipped for a few seconds. The weapon can then be re-created in the PC's inventory. So switching weapons would have no effect since the weapon is not lost by simply switching weapns in combat, only if it's disarmed.
Then all you need do is check for the int disarmed on the equip item script and while that int is present the weapon can't be re-equipped, which was part of the oringinal question the op asked.  That the item not be re-equipable for a few seconds, in my example 6.0. My only concern was the when the weapon is re-created the int might be lost, which is easy to fix by setting the local when the weapon is re-created in the PC's inventory.  If the int disarmed is not lost then that step would not be needed.

Modifié par ffbj, 30 novembre 2010 - 01:11 .


#21
GhostOfGod

GhostOfGod
  • Members
  • 863 messages
Ah ha. I didn't know anything about the disarmed weapon being flagged. So once the weapon is disarmed and it drops to the ground you can still get the weapon in the persons weapon slot even though they don't have it equipped?

#22
ffbj

ffbj
  • Members
  • 593 messages
Well the idea is you get the weapon in the slot first then if it is the same as the weapon that is lost i.e. the weapon that is lost/disarmed then that is the weapon you recreate in the players inventory. A different approach to the problem is all it is.

#23
La Rose Noire

La Rose Noire
  • Members
  • 25 messages
Beware of CopyObject in the Disarm Script because it will erase any added properties or magical enhancement on the weapon duplicated.

In my mod, I use ActionPickUpItem which will take a little time to perform and justify the use of Disarm by fighters.

Modifié par La Rose Noire, 04 janvier 2011 - 07:51 .