Author Topic: Polymorphing and Items  (Read 585 times)

Legacy_henesua

  • Hero Member
  • *****
  • Posts: 6519
  • Karma: +0/-0
Polymorphing and Items
« on: November 20, 2011, 12:08:30 am »


               Is it possible via scripting to equip a weapon on a polymorphed creature?
               
               

               
            

Legacy_Failed.Bard

  • Hero Member
  • *****
  • Posts: 1409
  • Karma: +0/-0
Polymorphing and Items
« Reply #1 on: November 20, 2011, 02:20:29 am »


               Mavrixio found a way to do it for Sinfar.  Likely it involves the linux nwnx and the ForceEquip function to directly equip an item bypassing the normal action queue.
               
               

               
            

Legacy_henesua

  • Hero Member
  • *****
  • Posts: 6519
  • Karma: +0/-0
Polymorphing and Items
« Reply #2 on: November 20, 2011, 03:29:54 am »


               Hmmm... that makes sense, but is unfortunate for me since I am trying to do all of this without NWNX. Nevertheless I'd still like to hear how exactly  it was done. Thanks.
               
               

               
            

Legacy_FunkySwerve

  • Hero Member
  • *****
  • Posts: 2325
  • Karma: +0/-0
Polymorphing and Items
« Reply #3 on: November 20, 2011, 04:38:59 am »


               While I've never tried to do this, I don't see why it'd need NWNX. Here's our ForceEquip function, with some server specific stuff cut out:


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));
//swap in your custom 'on resurrection' script above, if you have one
        DelayCommand(0.1, ForceUnequip(oTarget, oItem));
    } else {
        AssignCommand(oTarget, ClearAllActions(TRUE));

        AssignCommand(oTarget, ActionUnequipItem(oItem));
        AssignCommand(oTarget, ActionDoCommand(SetCommandable(TRUE)));
        AssignCommand(oTarget, SetCommandable(FALSE));
    }
}

In principle, it should work the same with ActionEquipItem, though I'm not sure what poly status will do to that. My experience with polymorphed critters mostly extends to shifter scripts (though those get fairly complicated what with the occasionally chaotic order of event firing).

Funky
               
               

               
            

Legacy_WhiZard

  • Hero Member
  • *****
  • Posts: 2149
  • Karma: +0/-0
Polymorphing and Items
« Reply #4 on: November 20, 2011, 05:39:20 am »


               

FunkySwerve wrote...

In principle, it should work the same with ActionEquipItem, though I'm not sure what poly status will do to that.


That's the tough part.  Polymorph weapons are in the creature weapon slot, not what a standard weapon would normally equip into.  Creature weapons do have the advantage that you can set the base damage (but you can't set the damage type (beyond expanding it by an extra melee damage property) the critical multiplier or the critical threat range).  What you could do is copy the weapon properties over like Bioware did for equipment merges.
               
               

               
            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
Polymorphing and Items
« Reply #5 on: November 20, 2011, 05:58:08 am »


               

WhiZard wrote...

FunkySwerve wrote...

In principle, it should work the same with ActionEquipItem, though I'm not sure what poly status will do to that.


That's the tough part.  Polymorph weapons are in the creature weapon slot, not what a standard weapon would normally equip into.  Creature weapons do have the advantage that you can set the base damage (but you can't set the damage type (beyond expanding it by an extra melee damage property) the critical multiplier or the critical threat range).  What you could do is copy the weapon properties over like Bioware did for equipment merges.

Not quite. I haven't tried equip different item into polymorphed character as well, so I will simply assume its possible. Then:
1) normal weapons can be by default equipped into creature slots as well (but since it can be expl0itable I made a baseitems.2da modification that prevents it, its on vault)
2) creature weapons are used only if there is no valid object in right hand in first place. You can still equip the weapon into normal slot  and creature weapons will be ommited then.
Thus you dont need to copy item properties, assumed its possible to equip item on polymorphed character. Which probably isn't, the item would be then lost after unpolymorph. The Sinfair uses a custom engine hack to bypass the equipping process AFAIK.
               
               

               
            

Legacy_WhiZard

  • Hero Member
  • *****
  • Posts: 2149
  • Karma: +0/-0
Polymorphing and Items
« Reply #6 on: November 20, 2011, 06:18:13 pm »


               

ShaDoOoW wrote...
I haven't tried equip different item into polymorphed character as well, so I will simply assume its possible.


Then to get this out of the way I have tested this many times and have tested this again just to confirm.  In a polymorph, the normal inventory slots are not available for ActionEquipItem() while the creature slots are.  Sure you can equip an item into these, but there is no way to view the item or to disarm it.
               
               

               


                     Modifié par WhiZard, 20 novembre 2011 - 06:29 .
                     
                  


            

Legacy_henesua

  • Hero Member
  • *****
  • Posts: 6519
  • Karma: +0/-0
Polymorphing and Items
« Reply #7 on: November 20, 2011, 06:32:08 pm »


               Whizard... I have not tried that. That is very useful information. I think along with all the rest in this thread, I've got a strategy for what I want to do. Prior to polymorph I check for an equipped weapon. After polymorph, I create a copy of the weapon and equip it to the creature slot. That should work well.

I'm still working on adapting some of the lycanthrope scripts right now, but will double back on getting weapons into the hands of wererats soon enough. (These are the Project Q wererat models)

Ah... just tested this... creature weapons don't display a model. So I'd need a complicated work around with an equipped weapon (from the polymorph equipped column), adjusting its apearance, merging properties etc... Hmm.... well I'll think about it.
               
               

               


                     Modifié par henesua, 20 novembre 2011 - 06:40 .
                     
                  


            

Legacy_Pstemarie

  • Hero Member
  • *****
  • Posts: 4368
  • Karma: +0/-0
Polymorphing and Items
« Reply #8 on: November 20, 2011, 07:54:29 pm »


               Deleted - misunderstood what you were trying to do here.
               
               

               


                     Modifié par Pstemarie, 20 novembre 2011 - 08:03 .
                     
                  


            

Legacy_Rolo Kipp

  • Hero Member
  • *****
  • Posts: 4349
  • Karma: +0/-0
Polymorphing and Items
« Reply #9 on: November 20, 2011, 08:09:42 pm »


               <putting on a tall, pointed white hat...>

henesua wrote...
Ah... just tested this... creature weapons don't display a model. So I'd need a complicated work around with an equipped weapon (from the polymorph equipped column), adjusting its apearance, merging properties etc... Hmm.... well I'll think about it.

Have you thought about altering the wererat to a "large" model (vice simple) and adding in the right hand node? Large creatures *can* equip weapons (they have the hand node to attach them to). Haven't looked at the Q Wererat, but if the node is present, try altering the anim type in the appearance.2da from s (simple) to l (large)...

Of course, I may be way off base here...

<...and sitting in a corner>
               
               

               
            

Legacy_Pstemarie

  • Hero Member
  • *****
  • Posts: 4368
  • Karma: +0/-0
Polymorphing and Items
« Reply #10 on: November 20, 2011, 08:13:13 pm »


               The Q wererat does have the hand node.
               
               

               
            

Legacy_Rolo Kipp

  • Hero Member
  • *****
  • Posts: 4349
  • Karma: +0/-0
Polymorphing and Items
« Reply #11 on: November 20, 2011, 08:17:12 pm »


               <grins...>

WooHOO! There you go =)
Don't try to get around the "simple" anims... use the "large" ones.

<...like a rat in a cheese store>
               
               

               
            

Legacy_henesua

  • Hero Member
  • *****
  • Posts: 6519
  • Karma: +0/-0
Polymorphing and Items
« Reply #12 on: November 20, 2011, 08:35:45 pm »


               the problem is not the model, but the way polymorph works. My aim is for players that become wererats to use their weapon when in the wererat form. Polymorph however does not allow items to be equiped to the normal equipment slots - only creature weapons.
               
               

               


                     Modifié par henesua, 20 novembre 2011 - 08:53 .
                     
                  


            

Legacy_Rolo Kipp

  • Hero Member
  • *****
  • Posts: 4349
  • Karma: +0/-0
Polymorphing and Items
« Reply #13 on: November 20, 2011, 08:46:11 pm »


               <frowns and...>

Haven't played with Polymorph (except in game) much. Thought it just used the appearance.2da for the model & animations, which would have made the right hand slot available if the wererat model was large instead of simple.  I.e., thought it was the anim type that set those slots usable/unusable... else how does polymorph to certain humanoid shapes work?

Confused now.

<...puts the dunce cap back on>
               
               

               
            

Legacy_Pstemarie

  • Hero Member
  • *****
  • Posts: 4368
  • Karma: +0/-0
Polymorphing and Items
« Reply #14 on: November 20, 2011, 08:51:32 pm »


               Henesua, have you looked at the shifter functions in x2_inc_shifter. There are several functions that might interest you: ShifterMergeArmor, ShifterMergeItems, and ShifterMergeWeapon being the most notable.
               
               

               


                     Modifié par Pstemarie, 20 novembre 2011 - 08:52 .