Author Topic: Only tha elven would...  (Read 575 times)

Legacy_Cestus Dei

  • Full Member
  • ***
  • Posts: 121
  • Karma: +0/-0
Only tha elven would...
« on: March 18, 2012, 04:52:10 pm »


                ...wear belts on ther heads! :-P

'Image

So me problem: If'n I put thet diadem in the helmet spot, tha diadem model replaces thet head. Damn ugly.

Fer now, I've put them diadem baseitems in the belt spot, seein' as how elves have little need fer belts, wearing them flowy gown thingies.

What I *want* ta do is take a peek inta tha PC model, store thet head model somewhere's.

Then I could have thet diadem tag-based script thet fires the VFX swap tha proper head back in after tha diadem is equiped. So, I get the head appearance, save it. Equip the diadem in the helmet spot (which cuts of 'er 'ead!), swap her old head back in and then fire off me diadem VFX.

Me questions:
  • How do I get the current head model?
  • How do I swap head models on the fly?
I'm thankin' ye.
               
               

               
            

Legacy_ShadowM

  • Hero Member
  • *****
  • Posts: 1373
  • Karma: +0/-0
Only tha elven would...
« Reply #1 on: March 18, 2012, 05:25:23 pm »


               Use GetCreatureBodyPart and SetCreatureBodyPart functions and save the info as int on the PC hide or Item or DB. Save the Original head on client enter once. Just some quick Information, I could go into more but it a good start for you.
               
               

               


                     Modifié par ShadowM, 18 mars 2012 - 05:25 .
                     
                  


            

Legacy_Rolo Kipp

  • Hero Member
  • *****
  • Posts: 4349
  • Karma: +0/-0
Only tha elven would...
« Reply #2 on: March 18, 2012, 06:22:36 pm »


               <scribbling...>

Thank you :-) That's exactly what we needed.

But I'll put the int on the diadem onAcquire event in the tag-based script. This leaves the module's onAcquire untouched...

<...madly>
               
               

               
            

Legacy_Rolo Kipp

  • Hero Member
  • *****
  • Posts: 4349
  • Karma: +0/-0
Only tha elven would...
« Reply #3 on: March 18, 2012, 07:12:23 pm »


               <brewing willow-bark tea...>

Well, I think we're on the right track, but...

'Image

It is saving the model number of the head and passing that number off to the SetCreatureBodyPart function... but that diadem in the helmet spot seems to override anything I do.

Any ideas?


#include "x2_inc_switches"
void main()
{
string sMsg;

{ switch( GetUserDefinedItemEventNumber())
   { case X2_ITEM_EVENT_EQUIP:
         { // The item was just equipped.
            object oPC = GetPCItemLastEquippedBy();
            object oItem         = GetPCItemLastEquipped();
            if( !GetIsObjectValid( oPC ) || !GetIsObjectValid( oItem ))
            {
               SetExecutedScriptReturnValue( X2_EXECUTE_SCRIPT_CONTINUE);
               return;
            }
            
[b]            // Restore oPC head.
                int iHeadNum = GetLocalInt(oItem,"HeadNum");
                sMsg = "Restoring head number " + IntToString(iHeadNum);
                SendMessageToPC(oPC,sMsg);
                SetCreatureBodyPart(CREATURE_PART_HEAD, iHeadNum , oPC );
[/b]
                // locate the visualeffects.2da index of the proper KiStone
                // IndexOfKiStone = basenum+racialtype+gender
                int basenum = 785; // Row of first KiStone effect
                // (Only Elf) int iRace = (2*GetRacialType( oPC )); // Will give trash if race >6
                // (disabled) int iGender = GetGender( oPC ); // Will give trash if gender not Female or Male
                int IndexOfKiStone = basenum; // + iRace + iGender;

                // Have the KiStone apply effects
                AssignCommand(oItem, ApplyEffectToObject( DURATION_TYPE_PERMANENT, EffectVisualEffect(                           IndexOfKiStone ), oPC));

         }
         SetExecutedScriptReturnValue( X2_EXECUTE_SCRIPT_END);
         return;

     case X2_ITEM_EVENT_UNEQUIP:
         {  // The item was just un-equipped.
            object oPC = GetPCItemLastUnequippedBy();
            object oItem              = GetPCItemLastUnequipped();
            if( !GetIsObjectValid( oPC) || !GetIsObjectValid( oItem))
            {
               SetExecutedScriptReturnValue( X2_EXECUTE_SCRIPT_CONTINUE);
               return;
            }
              //Remove all visual effects applied by oKiStone
              effect eLoop=GetFirstEffect(oPC);

             while (GetIsEffectValid(eLoop))
             {
                  if (GetEffectCreator(eLoop) == oItem)
                  RemoveEffect(oPC, eLoop);
                  eLoop=GetNextEffect(oPC);
              }
         }
         SetExecutedScriptReturnValue( X2_EXECUTE_SCRIPT_END);
         return;

     case X2_ITEM_EVENT_ACQUIRE:
         { // The item was just acquired (picked up, purchased, stolen, etc).
            object oPC = GetModuleItemAcquiredBy();
            object oItem  = GetModuleItemAcquired();
            object oOldOwner  = GetModuleItemAcquiredFrom();
            int       iStackSize   = GetModuleItemAcquiredStackSize();
            if( !GetIsObjectValid( oPC) || !GetIsObjectValid( oItem) || (iStackSize <= 0))
            {
               SetExecutedScriptReturnValue( X2_EXECUTE_SCRIPT_CONTINUE);
               return;
            }
            
[b]            // Get the oPC head and store it on the oItem
            int iHeadNum =  GetCreatureBodyPart(CREATURE_PART_HEAD, oPC);
            SetLocalInt(oItem, "HeadNum", iHeadNum );
            sMsg = "Head is number " + IntToString( iHeadNum );
            SendMessageToPC( oPC, sMsg);[/b]
         }
         SetExecutedScriptReturnValue( X2_EXECUTE_SCRIPT_END);
         return;

     case X2_ITEM_EVENT_UNACQUIRE:
         { // The item was just unacquired (dropped, sold, lost, etc).
            object oOldOwner  = GetModuleItemLostBy();
            object oItem             = GetModuleItemLost();
            object oNewOwner = GetItemPossessor( oItem);
            if( !GetIsObjectValid( oOldOwner) || !GetIsObjectValid( oItem))
            { SetExecutedScriptReturnValue( X2_EXECUTE_SCRIPT_CONTINUE);
               return;
            }
            
            // This is where you add modifications done when the item is un-acquired.
         }
         SetExecutedScriptReturnValue( X2_EXECUTE_SCRIPT_END);
         return;

     case X2_ITEM_EVENT_ACTIVATE:
         { // The item's CastSpell Activate or CastSpell UniquePower was just activated.
            object     oItemUser  = GetItemActivator();
            object     oItem          = GetItemActivated();
            object     oTarget      = GetItemActivatedTarget();
            location  lTarget      = (GetIsObjectValid( oTarget) ? GetLocation( oTarget) : GetItemActivatedTargetLocation());
            if( !GetIsObjectValid( oItemUser) || !GetIsObjectValid( oItem))
            { SetExecutedScriptReturnValue( X2_EXECUTE_SCRIPT_CONTINUE);
               return;
            }
            
            // This is where you put your Unique power activation modifications.
         }
         SetExecutedScriptReturnValue( X2_EXECUTE_SCRIPT_END);
         return;

      case X2_ITEM_EVENT_ONHITCAST:
         { // The item's OnHitCastSpell Unique OnHit power was just triggerred.
            object oWielder = OBJECT_SELF;             // weapon wielder/armor wearer
            object oTarget    = GetSpellTargetObject(); // weapon target/armor attacker
            object oItem        = GetSpellCastItem();             // the item with the OnHitCast property on it.
            if( !GetIsObjectValid( oTarget) || !GetIsObjectValid( oItem))
            { SetExecutedScriptReturnValue( X2_EXECUTE_SCRIPT_CONTINUE);
               return;
            }
            
            // This is where you process OnHitCastSpell-UniquePower(OnHit) activation
            // due to a weapon scoring a hit or equipment getting hit.
         }
         SetExecutedScriptReturnValue( X2_EXECUTE_SCRIPT_END);
         return;
   }
   SetExecutedScriptReturnValue( X2_EXECUTE_SCRIPT_CONTINUE);
}

}



<...for his pounding headache>
               
               

               


                     Modifié par Rolo Kipp, 18 mars 2012 - 07:16 .
                     
                  


            

Legacy_ShadowM

  • Hero Member
  • *****
  • Posts: 1373
  • Karma: +0/-0
Only tha elven would...
« Reply #4 on: March 18, 2012, 09:06:53 pm »


               You cannot use the head model it hard-coded override if something in the slot. If you want to put it into the spot you have to unequip when it equiped / delete it or tranfer it away and then put the visual effect on and put a int on check for when you equip something else bring back the item. You could go the belt way also. I know this sucks because then you do not have the icon in the head slot. This has been a pain in the butt for a long time. Other way of working around it is using a wing/tail system. I hope this helps you. '<img'> You could also do like in the helm vfx module Ippensheir did and give the item a unque power self to put the visual on/off.
               
               

               


                     Modifié par ShadowM, 18 mars 2012 - 09:11 .
                     
                  


            

Legacy_Rolo Kipp

  • Hero Member
  • *****
  • Posts: 4349
  • Karma: +0/-0
Only tha elven would...
« Reply #5 on: March 18, 2012, 09:17:36 pm »


               <stepping back from the edge...>

Hrmph. Was *so* hoping I could hot-swap with something in the helmet slot.
So, ok.
My choices are, as I see it:
  • Unequip item as soon as it is equipped (after applying VFX) and tracking to see if something else equipped (to end VFX)
  • Make item unequipable and make vfx a magic gadget (unique power).
  • Equip in belt slot rather than head, allowing doubled slots for head at the price of equipping belts.
I don't want to track anything. I like fire and forget :-P
For  a similar reason, I don't like the PC having to manually activate the item.
I can live with losing the belt slot.

<...before he loses his head>
               
               

               


                     Modifié par Rolo Kipp, 18 mars 2012 - 09:19 .
                     
                  


            

Legacy_Failed.Bard

  • Hero Member
  • *****
  • Posts: 1409
  • Karma: +0/-0
Only tha elven would...
« Reply #6 on: March 19, 2012, 12:52:46 am »


               Maybe as an amulet instead of a belt?  At least it's closer to the head.
               
               

               
            

Legacy_Rolo Kipp

  • Hero Member
  • *****
  • Posts: 4349
  • Karma: +0/-0
Only tha elven would...
« Reply #7 on: March 19, 2012, 04:53:38 pm »


               <juggling...>

Thought about that, but, as a race, I figure elves are more likely to use necklaces/amulets than belts for major arcana. I also thought about making them unequipable and just giving the effect onAcquire. And about making them rings. But the helmet/belt/amulet slots at least limit the use to one at a time - player's choice - without additional scripting/tracking.

Anyway, that's my thinking. and it doesn't look *too* bad as a belt/headpiece combo...

<...apples and oranges>
               
               

               
            

Legacy_AzurDraak

  • Jr. Member
  • **
  • Posts: 84
  • Karma: +0/-0
Only tha elven would...
« Reply #8 on: March 20, 2012, 05:43:24 am »


               Question from the unknowledgeable peanut gallery:
Is it possible to Copy&Modify the diadem/helmet model# to the stored head model# ?
               
               

               
            

Legacy_Rolo Kipp

  • Hero Member
  • *****
  • Posts: 4349
  • Karma: +0/-0
Only tha elven would...
« Reply #9 on: March 20, 2012, 09:52:39 pm »


               <holding his hat out...>

It is, but it kinda defeats the purpose. These VFX accessories are designed to be used with whatever (possibly outrageously custom) head the PC/NPC has. If we make the diadem itself a head model, then you get the option of choosing an invisible head wearing a diadem.  If we add the diadem geometry to an existing head, that works... for that one head. :-P

We would have to make alternate diadem-wearing versions of every head for that to work.
Then what happens when we come out with the cool dangly earrings? XP

So, ok. If we want to have separate, customizable accessories (and we do) then they have to accept certain limitations (like no animations and no environment mapping (reflections))... Oh, and they bypass the whole fog effect thing, so they *really* stand out.

Still... worth doing, don't you think? ;-)

And always, if you have questions, ask! This is a really great community =)

<...cuz he has a fondness for peanuts>
               
               

               
            

Legacy_AzurDraak

  • Jr. Member
  • **
  • Posts: 84
  • Karma: +0/-0
Only tha elven would...
« Reply #10 on: March 21, 2012, 07:08:25 am »


               Perhaps I misunderstand the sequence of events.

Your original attempt:
1) Start with an Elf head.
2) Equip a helmet that looks like a diadem.
3) Apply a VFX diadem.

Result: No head, a physical diadem and(?) a VFX diadem.

Your attempted fix:
1) Start with an Elf head.
2) Equip a helmet that looks like a diadem.
3) (Re)SetCreatureBodyPart to restore the Elf head.
4) Apply a VFX diadem.

Result: No change. Resetting the body part has no effect because the head was never altered in the first place; it was being overridden by the helmet.

My suggestion:
1) Start with an Elf head.
2) Equip a helmet that has been scripted to look like the Elf head.
3) Apply a VFX diadem.

Questions:
Can a helmet be scripted to use a head model?
What is the target object of the VFX, head or helm?
               
               

               
            

Legacy_Rolo Kipp

  • Hero Member
  • *****
  • Posts: 4349
  • Karma: +0/-0
Only tha elven would...
« Reply #11 on: March 23, 2012, 03:32:04 pm »


               <crawling back...>

Sorry for the delay. Astral plane all f... <boss!> Er, fouled up.

AzurDraak wrote...

Perhaps I misunderstand the sequence of events.

Your original attempt:
1) Start with an Elf head.
2) Equip a helmet that looks like a diadem.
3) Apply a VFX diadem.

Result: No head, a physical diadem and(?) a VFX diadem.

Exactly.

Your attempted fix:
1) Start with an Elf head.
2) Equip a helmet that looks like a diadem.
3) (Re)SetCreatureBodyPart to restore the Elf head.
4) Apply a VFX diadem.

Result: No change. Resetting the body part has no effect because the head was never altered in the first place; it was being overridden by the helmet.

Yup.

My suggestion:
1) Start with an Elf head.
2) Equip a helmet that has been scripted to look like the Elf head.
3) Apply a VFX diadem.

Questions:
Can a helmet be scripted to use a head model?
What is the target object of the VFX, head or helm?

Ahhh... Well, you can *sculpt* a helmet to look like an elf head. But the helmet model (that now looks like an elf head) as defined in the baseitems.2da is what overrides the creature head. So I'd need a seperate helmet model for each elf head. I.e. not viable and redundant.

Unfortunately we don't have any handles for helmets. A helmet is simply a baseitem.2da line and a model/icon set. The icon chosen in the toolset when you create the item determines the model it uses and we can not change that (Edit: ...in game). I.e. We can not choose the diadem icon/model pair, wait until it's equipped, determine the head model in use and have the item reference the original head model as if it was the Diadem (which I think is what you are suggesting). Would be fantastic if we could :-) A hat of disguise that really works when equipped on the head? Sweet.

Likewise, we have very few targets for VFX. We can target the "head" node, The "impact" (torso) node, The creature base and (possibly) any "monster#" nodes defined on the creature. So head-aligned VFX (like diadems, earrings, pipes (with animated smoke effects!) etc. would target the head node. Necklaces,  torcs, breastplates, chest-bursting aliens, er, I mean, excorcised demons, etc would target the impact node

<...to life>
               
               

               


                     Modifié par Rolo Kipp, 23 mars 2012 - 03:34 .
                     
                  


            

Legacy_AzurDraak

  • Jr. Member
  • **
  • Posts: 84
  • Karma: +0/-0
Only tha elven would...
« Reply #12 on: March 24, 2012, 05:52:29 pm »


               Ooookay.

This might be a good time to mention that I have no expectations of this actually working. In fact, I have a good idea of what will prove to be the fatal flaw. The thing is that your responses seem to stray from my line of thinking. A clear sign that my poor communication skills are failing the test. So to try again.

Rolo Kipp wrote...

... But the helmet model (that now looks like an elf head) as defined in the baseitems.2da is what overrides the creature head.


Eh? This almost makes sense, but I'm not sure you mean what I think you mean.

So I'd need a seperate helmet model for each elf head. I.e. not viable and redundant.


Yes. No. Maybe. ..Clearly, making all those models for the sake of a single item would be excessive. On the other hand, if the technique were to work then the uses would be innumerable. In that case a full set of fake heads might be worthwhile. Besides the models already exist (as heads) if only they were compatible.


... The icon chosen in the toolset when you create the item determines the model it uses and we can not change that (Edit: ...in game). I.e. We can not choose the diadem icon/model pair, wait until it's equipped, determine the head model in use and have the item reference the original head model as if it was the Diadem (which I think is what you are suggesting).


Ah, but that's not quite what I was suggesting.

The Lexicon states that one can create a copy of a helmet (with a different appearance) simply by assigning a new model via the Copy&Modify function. Thus we are not remodeling the diadem. Rather, we are creating a new helmet with the properties of the diadem but  the model of a head. Unfortunately the very brief description in the Lexicon does not mention any limitations or restrictions on the chosen model.

The general scenario would be:

The Diadem is sitting on a dresser. The diadem model is visible.

The PC acquires the Diadem. The diadem icon is shown in inventory.

The PC equips the Diadem. The OnEquip event fires a script  that uses Copy&Modify to create a FakeHead and then swaps it out with the Diadem. The fake head model is visible in game (wishful thinking) and what? icon is displayed in the head slot in inventory.



To rephrase my VFX question. If the VFX is attached to a head node and the head model is subsequently over-ridden by a helmet, would the VFX persist or also be over-ridden. Sounds like it would persist.

Now it's time for you to tell me that there is no way to assign a head model to a helmet. The model types are totally incompatible and no work-around.  ':crying:'
               
               

               
            

Legacy_Rolo Kipp

  • Hero Member
  • *****
  • Posts: 4349
  • Karma: +0/-0
Only tha elven would...
« Reply #13 on: March 24, 2012, 06:30:19 pm »


               <looking pretty...>

Last things first ;-)

AzurDraak wrote...
Now it's time for you to tell me that there is no way to assign a head model to a helmet. The model types are totally incompatible and no work-around.  [smilie]http://social.bioware.com/images/forum/emoticons/crying.png[/smilie]

 
Nope, Not me. *I'm* not saying *anything* is impossible =)

Ooookay.

This might be a good time to mention that I have no expectations of this actually working. In fact, I have a good idea of what will prove to be the fatal flaw. The thing is that your responses seem to stray from my line of thinking. A clear sign that my poor communication skills are failing the test. So to try again.

...

You only discover unintentional features <heh> by going off-road ;-)

So I'd need a seperate helmet model for each elf head. I.e. not viable and redundant.


Yes. No. Maybe. ..Clearly, making all those models for the sake of a single item would be excessive. On the other hand, if the technique were to work then the uses would be innumerable. In that case a full set of fake heads might be worthwhile. Besides the models already exist (as heads) if only they were compatible.

It's not that the .mdl itself is incompatible. All you have to do is point to a head mdl in the baseitems.2da to see it work... Hmmm, if you massage the model names to work with the odd scheme baseitems uses... The actual model works fine. It's getting access *from within the game* to *changing* what model the baseitem points to that is the problem.

... We can not choose the diadem icon/model pair, wait until it's equipped, determine the head model in use and have the item reference the original head model as if it was the Diadem (which I think is what you are suggesting).


Ah, but that's not quite what I was suggesting.

The Lexicon states that one can create a copy of a helmet (with a different appearance) simply by assigning a new model via the Copy&Modify function. Thus we are not remodeling the diadem. Rather, we are creating a new helmet with the properties of the diadem but  the model of a head. Unfortunately the very brief description in the Lexicon does not mention any limitations or restrictions on the chosen model.

The general scenario would be:

The Diadem is sitting on a dresser. The diadem model is visible.

The PC acquires the Diadem. The diadem icon is shown in inventory.

The PC equips the Diadem. The OnEquip event fires a script  that uses Copy&Modify to create a FakeHead and then swaps it out with the Diadem. The fake head model is visible in game (wishful thinking) and what? icon is displayed in the head slot in inventory.

Now, that is an intriguing idea.
I will research it. but I suspect changing the appearance changes both model and icon to match the new appearance.

To rephrase my VFX question. If the VFX is attached to a head node and the head model is subsequently over-ridden by a helmet, would the VFX persist or also be over-ridden. Sounds like it would persist.

It does persist. I attach the vfx in an onEquip script (tag-based, actually) because I like fire and forget things :-) But once it's on, you could actually equip a helmet or change heads and the diadem will still be there... until it is unequiped from the belt slot.

Just wish someone would have had the forethought to allow null-model items to *not* over-ride... *sigh*

<...intrigued>
               
               

               
            

Legacy_Leurnid

  • Sr. Member
  • ****
  • Posts: 473
  • Karma: +0/-0
Only tha elven would...
« Reply #14 on: April 05, 2012, 09:47:57 am »


               I am totally ignorant of the internal workings of the helmet items and their behaviors, so consider this mad raving:

Script / code the diadem so that when it is equipped, it does not override the head model, or optionally, queries what head model is in use, and uses that as the model for the diadem equipped.. BUT, then have it also apply a second model to the head slot, that is comprised of a diadem on an 'invisible' head (loaded with all the stock behaviors as a regular head, only invisible)... So, the net effect is the original head showing, with a diadem on it.  

The scaling and so forth may not match every head model in the box, but lets be honest, character models and animation are probably the weakest link in NWN, so accepting a little slop for an equipable helm that doesn't override your head is still a net gain, imo.

The obvious big hurdle is tricking the NWN engine into showing two heads on one neck, the subsequent hurdle would be synchronizing the animations so the diadem didn't occasionally spin around or tilt off the head erratically.