Author Topic: RemoveItemProperty + visual effect  (Read 667 times)

Legacy_Thamiar

  • Newbie
  • *
  • Posts: 14
  • Karma: +0/-0
RemoveItemProperty + visual effect
« on: March 20, 2014, 12:55:33 pm »


               

Hello,


I have got a strange problem: I would like to remove a visual effect from weapon, but it simply does not work. If I use spells like Flame weapon or Darkfire, the Visual Effect is removed by the script. But if i want to remove it from a weapon which has got effect from the beginning (like Angurvadal (Flame Tongue)) it is not working '<img'>

What is more, when i run the script while having Angurvadal in my PC hand, I do not see "Debug 3"


What is wrong? Angurvadal fire effect is not a visual effect or what?



void main()
{
object oPC = GetPCSpeaker();
object oItem = GetItemInSlot(INVENTORY_SLOT_RIGHTHAND, oPC);
if (!GetIsObjectValid(oItem)) return;

   


itemproperty ipLoop=GetFirstItemProperty(oItem);
     FloatingTextStringOnCreature("Debug 1", oPC);
//Loop for as long as the ipLoop variable is valid
while (GetIsItemPropertyValid(ipLoop))
   {             FloatingTextStringOnCreature("Debug 2", oPC);
   //If ipLoop is a true seeing property, remove it
   if (GetItemPropertyType(ipLoop)==ITEM_PROPERTY_VISUALEFFECT)
     { RemoveItemProperty(oItem, ipLoop);
                   FloatingTextStringOnCreature("Debug 3", oPC);  
     }
   //Next itemproperty on the list...
   ipLoop=GetNextItemProperty(oItem);
   }
}


               
               

               
            

Legacy_Guest_JujuSamedi_*

  • Newbie
  • *
  • Posts: 12
  • Karma: +0/-0
RemoveItemProperty + visual effect
« Reply #1 on: March 20, 2014, 01:41:20 pm »


               Indent code and modularize your code pls. Either than that I have never done any script in NWN. Do they use C++ or is it a proprietary variation? I might just get my hands dirty.
               
               

               
            

Legacy_Thamiar

  • Newbie
  • *
  • Posts: 14
  • Karma: +0/-0
RemoveItemProperty + visual effect
« Reply #2 on: March 20, 2014, 02:05:08 pm »


               

void main()
{
object oPC = GetPCSpeaker();
object oItem = GetItemInSlot(INVENTORY_SLOT_RIGHTHAND, oPC);
              if (!GetIsObjectValid(oItem)) return;

itemproperty ipLoop=GetFirstItemProperty(oItem);
FloatingTextStringOnCreature("Debug 1", oPC);

while (GetIsItemPropertyValid(ipLoop))
      { FloatingTextStringOnCreature("Debug 2", oPC);
            if (GetItemPropertyType(ipLoop)==ITEM_PROPERTY_VISUALEFFECT)
                { RemoveItemProperty(oItem, ipLoop);
                  FloatingTextStringOnCreature("Debug 3", oPC);  
                }
            ipLoop=GetNextItemProperty(oItem);
      }
}


               
               

               
            

Legacy_The Amethyst Dragon

  • Hero Member
  • *****
  • Posts: 2981
  • Karma: +0/-0
RemoveItemProperty + visual effect
« Reply #3 on: March 20, 2014, 02:17:01 pm »


               

You may have to actually add a weapon visual to get rid of the flames.


 


I believe that the regular weapon VFXs are tied (via a 2da) to the bonus damage property.  So, if your weapon has a damage bonus of a certain type of at least a certain amount (say 1d6 or higher), the weapon will have the VFX, unless you specifically add a different VFX by means of another...


 


ItemPropertyVisualEffect(ITEM_VISUAL_*);


 


If you are using one or more haks for your module, you can edit iprp_visualfx.2da to add a new "none" VFX:


 


    Label        Name

0    Acid        16877231

1    Cold        16877257

2    Electrical  16877248

3    Fire        16877256

4    Sonic        16877255

5    Holy        16877237

6    Evil        16877239

7    NoneNull    16877238


 


* Ignore my .tlk file references for the names...those are from my own version of the file that I happened to have open.  For the one for "none", I'm sure there's a dialog.tlk line with that word.


 


Now, for the script, instead of using the ITEM_VISUAL_* constant (which matches up with the 2da line numbers), you can just use "7".


 


The standard VFX will still show up in the toolset, but in-game it'll be overridden by the "new" VFX...which doesn't exist (and never will unless you are running the game with NWNCX and have the new visuals added in).



               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
RemoveItemProperty + visual effect
« Reply #4 on: March 20, 2014, 10:20:37 pm »


               

... Do they use C++ or is it a proprietary variation? ...


proprietary, It is compiled to a .NCS(Neververwinter Compiled Script) format. The .NCS code is ran by a virtual machine built into the game. It uses the same syntax as C++ but is a highly cut down version.

To get your feet wet check out the NWN Lexicon.
               
               

               
            

Legacy_Proleric

  • Hero Member
  • *****
  • Posts: 1750
  • Karma: +0/-0
RemoveItemProperty + visual effect
« Reply #5 on: March 20, 2014, 11:53:30 pm »


               I wonder whether the OP issue is related to the "baking" of vfx on placeables? The issue there is that some vfx become impossible to remove once players have left the area (unless they are removed on exit and reapplied on enter). Just coincidence, perhaps?


At any rate, good to know about the workaround.
               
               

               
            

Legacy_Proleric

  • Hero Member
  • *****
  • Posts: 1750
  • Karma: +0/-0
RemoveItemProperty + visual effect
« Reply #6 on: March 21, 2014, 09:48:28 am »


               By chance, I stumbled across the following advice in the Lexicon: "(instead) of applying an effect, ... cast a spell on the object using invisible object casters", which seems to square with the OP's finding.

So, it would be interesting to see what happens if you remove the effect from Angurvadal's template in the toolset, but apply it in-game with an invisible caster.

I've made a note to try this out with placeables at the next opportunity.
               
               

               
            

Legacy_Thamiar

  • Newbie
  • *
  • Posts: 14
  • Karma: +0/-0
RemoveItemProperty + visual effect
« Reply #7 on: March 26, 2014, 12:10:24 pm »


               

The Amethyst Dragon Thank you very much! That was exactly what I was looking for! Thank you very much! '<img'>