Author Topic: Hello, does anyone have a script of carrying a corpse makes using weapons or casting spells impossible?  (Read 390 times)

Legacy_Artistmonk

  • Jr. Member
  • **
  • Posts: 54
  • Karma: +0/-0


               I was wondering if that was possible if PC is carrying corpse they would have to drop the corpse to be able to equip weapon or cast spells (verbal spells only or appropiate metamagic spells could be cast of course).

Basically they have to bring remains of someone back but might have to deal with pursuit and the corpse weighs 175 lbs which should slow down those who don't have high strength. The corpse could be placed in only largest bag of holding but not sure if that can be imposed either.

Any insight./script help appreciated.
               
               

               
            

Legacy_CID-78

  • Sr. Member
  • ****
  • Posts: 261
  • Karma: +0/-0


               Everything is possible. with CC you could force the player to carry the items as a 2H weapon,however i still think you would be able todo 1 HP damage with the body.(minimum damage possible) for anything your weilding as a weapon. you need a onacquire, onequipt,onunequipt and onunaquire script for the body to controll your rules.
               
               

               
            

Legacy_GhostOfGod

  • Hero Member
  • *****
  • Posts: 1490
  • Karma: +0/-0


               As far as not being able to equip weapons gos you will need to alter your module "OnPlayerEquipItem" script so that it checks to see if the player possesses the corpse item. If so then just unequip the weapon the player tried to equip. This is what it would look like using the default "x2_mod_def_equ":

Note: I took the super easy route and just made it so that the player couldn't equip anything in the right or left hand. So this includes sheilds, torches, etc. Otherwise you have to check for weapon base items and whether or not you are using CEP weapons and all that jazz. Also the only parts I added to the 2 scripts below are between the red "/////". Also make sure you plug in your corpse tag where it says "TEST_CORPSE".

//::///////////////////////////////////////////////
//:: 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 (GetItemPossessedBy(oPC, "TEST_CORPSE") != OBJECT_INVALID)
    {
        if (oItem == GetItemInSlot(INVENTORY_SLOT_LEFTHAND, oPC) ||
            oItem == GetItemInSlot(INVENTORY_SLOT_RIGHTHAND, oPC))
        {
            DelayCommand(1.0, AssignCommand(oPC, ActionUnequipItem(oItem)));
            SendMessageToPC(oPC, "You can not equip a weapon or shield while carrying a corpse.");
        }
    }
    ////////////////////////////////////////////////////////////////////

    // -------------------------------------------------------------------------
    // Intelligent Weapon System
    // -------------------------------------------------------------------------
    if (IPGetIsIntelligentWeapon(oItem))   
   //etc........


Now you 2 choices for the second part. You can either alter your modules "OnPlayerAcquireItem" script or you can make a tag based script for the corpse. I'll just put the alteration to the "OnPlayerAcquireItem" script for now. If you want it tag based so you don't have to mess with this event then just let us know.

So this would be the alteration to the default "x2_mod_def_aqu":

//::///////////////////////////////////////////////
//:: Example XP2 OnItemAcquireScript
//:: x2_mod_def_aqu
//:: © 2003 Bioware Corp.
//:://////////////////////////////////////////////
/*
    Put into: OnItemAcquire Event

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

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

     /////////////////////////////////////////////////////////////////
     object oPC = GetModuleItemAcquiredBy();
     object oSlotRH = GetItemInSlot(INVENTORY_SLOT_RIGHTHAND, oPC);
     object oSlotLH = GetItemInSlot(INVENTORY_SLOT_LEFTHAND, oPC);
     if (GetTag(oItem) == "TEST_CORPSE")
     {
        AssignCommand(oPC, ActionUnequipItem(oSlotRH));
        AssignCommand(oPC, ActionUnequipItem(oSlotLH));
        SendMessageToPC(oPC, "You can not equip a weapon or shield while carrying a corpse.");
     }
     /////////////////////////////////////////////////////////////////

     // * Generic Item Script Execution Code
    //etc......


As far as the spells go you are going to have to get into the spell hooking which I haven't done for awhile. And if I remember right, the player will still be able to use spell items and cast spells using the spellhook...the spells/items will just fail.

Hope this helps.
               
               

               


                     Modifié par GhostOfGod, 15 juin 2011 - 05:37 .
                     
                  


            

Legacy_GhostOfGod

  • Hero Member
  • *****
  • Posts: 1490
  • Karma: +0/-0


               Hmm..actually after giving this some more thought it would be much more efficient to go with a tag based script for the corpse. The OnAcquire would unequip your weapon/s and set an int variable on the player. The UnAcquire would just remove that variable. And then the OnPlayerEquipItem would just check the player for the variable instead of GetItemPossessedBy every time the player equips an item. Cooking myself some breakfast right now. I'll put up some code for this in a few unless someone else beats me to it.
               
               

               
            

Legacy_GhostOfGod

  • Hero Member
  • *****
  • Posts: 1490
  • Karma: +0/-0


               Ok so a new, more efficient way of handing the equipping part of your problem.

Tag based script for the corpse item. This will fire when the item is acquired and unacquired. Just make sure the name that you save it under matches the tag of your corpse item:

#include "x2_inc_switches"
void main()
{
    int iEvent = GetUserDefinedItemEventNumber();
    object oPC = GetModuleItemAcquiredBy();

    if (iEvent == X2_ITEM_EVENT_ACQUIRE)
    {
        object oSlotRH = GetItemInSlot(INVENTORY_SLOT_RIGHTHAND, oPC);
        object oSlotLH = GetItemInSlot(INVENTORY_SLOT_LEFTHAND, oPC);
        AssignCommand(oPC, ActionUnequipItem(oSlotRH));
        AssignCommand(oPC, ActionUnequipItem(oSlotLH));
        SendMessageToPC(oPC, "You can not equip items in hands while carrying a corpse.");
        SetLocalInt(oPC, "CARRY_CORPSE", TRUE);
    }
    else if (iEvent == X2_ITEM_EVENT_UNACQUIRE)
    {
        SetLocalInt(oPC, "CARRY_COPRSE", FALSE);
    }
}


And then the changes to your OnPlayerEquipItem script should look something like this(again just added the stuff in between the red "////" to the default 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(oPC, "CARRY_CORPSE") == TRUE)
    {
        if (oItem == GetItemInSlot(INVENTORY_SLOT_LEFTHAND, oPC) ||
            oItem == GetItemInSlot(INVENTORY_SLOT_RIGHTHAND, oPC))
        {
            DelayCommand(1.0, AssignCommand(oPC, ActionUnequipItem(oItem)));
            SendMessageToPC(oPC, "You can not equip items in hands while carrying a corpse.");
        }
    }
    ////////////////////////////////////////////////////////////////////

    // -------------------------------------------------------------------------
    // Intelligent Weapon System
    // -------------------------------------------------------------------------
    if (IPGetIsIntelligentWeapon(oItem))
    ///etc....


Either of the ways I posted should work for you but the second method is better. Good luck.
               
               

               


                     Modifié par GhostOfGod, 15 juin 2011 - 06:21 .
                     
                  


            

Legacy_Artistmonk

  • Jr. Member
  • **
  • Posts: 54
  • Karma: +0/-0


               Blessings to you for such quick response, will dash home after son time to look it over, my one edit would be would multiple tags be a problem, the script checking for four different tags as opposed to just one. They have to carry a family to safety, they are actually petrified....this is a non-mage quest so no issue with spell, although I am now thinking I may change that.

Thank you again.
               
               

               
            

Legacy_Artistmonk

  • Jr. Member
  • **
  • Posts: 54
  • Karma: +0/-0


               Will script fire if body is in bag of holding, hoefully not????
               
               

               
            

Legacy_GhostOfGod

  • Hero Member
  • *****
  • Posts: 1490
  • Karma: +0/-0


               In that case you could do to have 4 tag based scripts. They will all be the same but will each be saved under whatever name corresponds with the tags of the corpses. The tag based script will also need to be altered a bit to account for the change.

However If you want to still have just one tag based script you could give all 4 corpses the same tags and then if you have a script that requires the unique tags just change it to GetResRef of each item instead. Personally this is what I would do if you are able to.

Altered tag based script(Also fixed other issue):

#include "x2_inc_switches"
void main()
{
    int iEvent = GetUserDefinedItemEventNumber();

    if (iEvent == X2_ITEM_EVENT_ACQUIRE)
    {
        object oPC = GetModuleItemAcquiredBy();
        int iCorpses = GetLocalInt(oPC, "CARRY_CORPSE");
        object oSlotRH = GetItemInSlot(INVENTORY_SLOT_RIGHTHAND, oPC);
        object oSlotLH = GetItemInSlot(INVENTORY_SLOT_LEFTHAND, oPC);
        if (oSlotRH != OBJECT_INVALID)
        AssignCommand(oPC, ActionUnequipItem(oSlotRH));
        if (oSlotLH != OBJECT_INVALID)
        AssignCommand(oPC, ActionUnequipItem(oSlotLH));
        SendMessageToPC(oPC, "You can not equip items in hands while carrying a corpse.");
        SetLocalInt(oPC, "CARRY_CORPSE", iCorpses + 1);
    }
    if (iEvent == X2_ITEM_EVENT_UNACQUIRE)
    {
        object oPC = GetModuleItemLostBy();
        int iCorpses = GetLocalInt(oPC, "CARRY_CORPSE");
        if (iCorpses > 0)
        SetLocalInt(oPC, "CARRY_CORPSE", iCorpses - 1);
    }
}


The Altered OnPlayerEquipItem:

//::///////////////////////////////////////////////
//:: 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(oPC, "CARRY_CORPSE") > 0)
    {
        if (oItem == GetItemInSlot(INVENTORY_SLOT_LEFTHAND, oPC) ||
            oItem == GetItemInSlot(INVENTORY_SLOT_RIGHTHAND, oPC))
        {
            DelayCommand(1.0, AssignCommand(oPC, ActionUnequipItem(oItem)));
            SendMessageToPC(oPC, "You can not equip items in hands while carrying a corpse.");
        }
    }
    ////////////////////////////////////////////////////////////////////

    // -------------------------------------------------------------------------
    // Intelligent Weapon System
    // -------------------------------------------------------------------------
    if (IPGetIsIntelligentWeapon(oItem))
    ///etc....


               
               

               


                     Modifié par GhostOfGod, 15 juin 2011 - 09:24 .
                     
                  


            

Legacy_GhostOfGod

  • Hero Member
  • *****
  • Posts: 1490
  • Karma: +0/-0


               If the player puts the body into a bag then this will have problems yes. You will have to go looping through inventory every time the player tries to equip a weapon or what not. I'll give it some more thought and see If I can come up with something that would be efficient for that.
               
               

               
            

Legacy_Artistmonk

  • Jr. Member
  • **
  • Posts: 54
  • Karma: +0/-0


               Thanks, having same tag does make more sense, not sure if they would have BoH by this stage but if so would be greatly appreciated to not punish them for common sense in using the bag.