Author Topic: Weapon Visual Effect Changes Depending on Wielder's Alignment  (Read 385 times)

Legacy_UnrealJedi

  • Full Member
  • ***
  • Posts: 226
  • Karma: +0/-0


               Here's a wonderment I had yesterday. Let's say the OC in a single player module is battling a boss who is wielding a broadsword with the fire visual effect. Let's say PC defeats the boss and picks up the fallen boss's broadsword. Immediately, the visual effect changes from flames to holy. The reason why is because the broadsword, although not intelligent, empathically reflects the wielder's alignment. Fire for chaotic, holy for lawful, maybe nothing for neutral, etc.

Now, I know that you cannot use scripting to change a weapon's visual effect but would it be possible to use scripting to change the weapon with the appropriate visual effect depending on the PC's alignment? There would actually be three weapons and when the PC clicks on the fallen boss's corpse to search him a script runs that checks the PC's alignment and then spawns the weapon with the appropriate visual effect in the boss's inventory.

Thoughts?
               
               

               
            

Legacy_HipMaestro

  • Hero Member
  • *****
  • Posts: 2849
  • Karma: +0/-0
Weapon Visual Effect Changes Depending on Wielder's Alignment
« Reply #1 on: June 12, 2012, 07:20:27 pm »


               Wouldn't it be easy to just place each version on the palette and then treat the corpse like a container scripted to deliver the PC-specific version?  I remember SoU-Interlude doing something similar to this with the Desert Fury though the version delivered was a different weapon TYPE and the script checked for class to determine which one to spawn.  I'd think alignment-dependence would be just as easy to script as class-dependence, maybe easier if you are only interested in just the 3 of the law-chaos axis and always the same base weapon. 

Take heed of the issue of the SoU-scripted version because that longsword (or whatever a broadsword type is) that drops may not be able to be used by any class other than one with martial prof.  There is a lot of merit in making it a two-way spawn script for both TYPE/class and EFFECT/ALIGNMENT.

I believe you could even permutate the effects script further for all 9 of the standard alignment grid ratings.  I like the acid green one a lot, myself, or perhaps a purple aura would be better still if there is one out there. '<img'>
               
               

               


                     Modifié par HipMaestro, 12 juin 2012 - 06:27 .
                     
                  


            

Legacy_UnrealJedi

  • Full Member
  • ***
  • Posts: 226
  • Karma: +0/-0
Weapon Visual Effect Changes Depending on Wielder's Alignment
« Reply #2 on: June 12, 2012, 08:09:54 pm »


               HipMaestro, thanks for the response. The way this particular boss is set up in my module goes like this: When the PC enters the boss area, a trigger checks to see what class the PC is and then spawns a boss the same class as the PC, so if the PC is a fighter, paladin, or ranger, it spawns a fighter. If the PC is a cleric, it spawns a cleric, if the PC is a wizard or sorcerer, yada yada yada...I think you get the point. All the "bossess" have the same name. It is the fighter boss (actually a doom knight) who will have the broadsword in question. This eleminates the concern of whether or not the PC can use the weapon because they will only get the broadsword if they are of a warrior class.

By stating "Wouldn't it be easy to just place each version on the palette and then treat the corpse like a container scripted to deliver the PC-specific version?" do you mean by "each version" a version of the weapon?
               
               

               
            

Legacy_HipMaestro

  • Hero Member
  • *****
  • Posts: 2849
  • Karma: +0/-0
Weapon Visual Effect Changes Depending on Wielder's Alignment
« Reply #3 on: June 12, 2012, 08:40:55 pm »


               

UnrealJedi wrote...
By stating "Wouldn't it be easy to just place each version on the palette and then treat the corpse like a container scripted to deliver the PC-specific version?" do you mean by "each version" a version of the weapon?

Yes.  Essentially all you should need is 3 versions of the broadsword on the custom palette each with the appropriate effect and spawn it onto the corpse for retrieval by resref.   However that works for a corpse... OnOpen for a standard container, just check alignment there and spawn the appropriate resref accordingly.  I suppose you'd either need to suppress the boss-equipped items from dropping or destroy it (the sword) OnDeath.

You've already done your class control procedure before this so a single weapon type (longsword/broadsword) will do the trick. 
               
               

               


                     Modifié par HipMaestro, 12 juin 2012 - 07:50 .
                     
                  


            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Weapon Visual Effect Changes Depending on Wielder's Alignment
« Reply #4 on: June 12, 2012, 10:07:56 pm »


               Try something like this for its Tag based script. 


#include "X2_Inc_Switches"

void RemoveAllItemProperties(object oItem)
{
    itemproperty ip = GetFirstItemProperty(oItem);
    while (GetIsItemPropertyValid(ip))
    {
        RemoveItemProperty(oItem, ip);
        ip = GetNextItemProperty(oItem);
    }
}

void main()
{

   if (GetUserDefinedItemEventNumber()!=X2_ITEM_EVENT_ACQUIRE) return;
   object oItem = GetModuleItemAcquired();
   if ( ! GetIsObjectValid(oItem)) return;
   object oPC = GetModuleItemAcquiredBy();

   int nLC = GetLawChaosValue(oPC);
   if (nLC = -1) return;

   RemoveAllItemProperties(oItem);

   int nDamageType = DAMAGE_TYPE_SONIC;
   if (nLC < 50) nDamageType = DAMAGE_TYPE_FIRE;
 
  nLC = abs( nLC -50)/10 - 2;

   itemproperty ipBDamage =ItemPropertyDamageBonus(nDamageType,nLC);
   AddItemProperty(DURATION_TYPE_PERMANENT,ipBDamage,oItem);
   itemproperty ipEnhancement = ItemPropertyEnhancementBonus(nLC);
   AddItemProperty(DURATION_TYPE_PERMANENT,ipEnhancement,oItem);
}
               
               

               
            

Legacy_UnrealJedi

  • Full Member
  • ***
  • Posts: 226
  • Karma: +0/-0
Weapon Visual Effect Changes Depending on Wielder's Alignment
« Reply #5 on: June 13, 2012, 03:58:47 pm »


               Lightfoot, I am no scripter but from looking at your post it seems that once the weapon has been acquired then the script checks the alignment of the PC to see if they have lawful or chaotic, and then changes the visual effect of the item. Am I corect? I was under the impression that you could not script visual effects. Alos, have you tested this? Thanks for posting. It would make implementing this much easier. This would be awesome for a PW...which I am not doing, but I can see the application.

Thanks again!
               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Weapon Visual Effect Changes Depending on Wielder's Alignment
« Reply #6 on: June 13, 2012, 04:55:50 pm »


               

UnrealJedi wrote...

Lightfoot, I am no scripter but from looking at your post it seems that once the weapon has been acquired then the script checks the alignment of the PC to see if they have lawful or chaotic, and then changes the visual effect of the item. Am I corect?


 Well It does not really change just the visual effect.  It changes the Type of  damage the sword does .   the visual will change when the bonus damage type changes. 

not knowing enough about the power levels of you world I just kind of posted this as an example of what can be done.

The script firsr strips all power from the PC.  It them adds both Enhancement( +1 to +3)  and bonus damage(1 to 3 points)  back to the weapon based on how far they are from nutural. 

Alos, have you tested this?


Nope Have not tested it yet.
               
               

               
            

Legacy_UnrealJedi

  • Full Member
  • ***
  • Posts: 226
  • Karma: +0/-0
Weapon Visual Effect Changes Depending on Wielder's Alignment
« Reply #7 on: June 13, 2012, 05:57:02 pm »


               

Lightfoot8 wrote...

not knowing enough about the power levels of you world I just kind of posted this as an example of what can be done.


The first module I am working on has wepaons of only +1 and +2.. How would this change in your script?

Also, you mentioned that the visual effect will change when the bonus type changes? Can you elaborate further?


Thanks!
               
               

               


                     Modifié par UnrealJedi, 13 juin 2012 - 04:57 .
                     
                  


            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Weapon Visual Effect Changes Depending on Wielder's Alignment
« Reply #8 on: June 13, 2012, 06:53:06 pm »


               Instead of just changing the visual i changed the type of damage it does.  if the weapon does fire damage, it gives a fire visual.  If the weapon does sonic damage it gives a sonic visual.  

tested the script,  I had a few errors.    I used the wrong constants for the damage type,  and the  nLC = -1 check should have been nLC == -1; 

Also I forgot that elemental damages of 1d4 or less do not have visuals. So I bumped them up to doing between 1d6 and 1d10 damage.   

law chaos is a scale of 1 to 100, where 100 is lawfull, 0 is chaotic, and 50 is neutral.   the farther away the alignment is away from 50 the larger the bonuses.     

Here is the adjusted corrected script.   In order for the weapon to be +3  with 1d10 elemental the PC would have to be fully chaotic ( 0 )   or fully lawfull ( 100 )

#include "X2_Inc_Switches"
void RemoveAllItemProperties(object oItem)
{
    itemproperty ip = GetFirstItemProperty(oItem);
    while (GetIsItemPropertyValid(ip))
    {
        RemoveItemProperty(oItem, ip);
        ip = GetNextItemProperty(oItem);
    }
}

void main()
{
 
   if (GetUserDefinedItemEventNumber()!=X2_ITEM_EVENT_ACQUIRE) return;
   object oItem = GetModuleItemAcquired();
   if ( ! GetIsObjectValid(oItem)) return;


   object oPC = GetModuleItemAcquiredBy();

   int nLC = GetLawChaosValue(oPC);
   if (nLC == -1) return;

   RemoveAllItemProperties(oItem);

   int nDamageType = IP_CONST_DAMAGETYPE_SONIC;
   if (nLC < 50) nDamageType = IP_CONST_DAMAGETYPE_FIRE;

   nLC = abs( nLC -50)/10 - 2;


   itemproperty ipBDamage =ItemPropertyDamageBonus(nDamageType,nLC+6);
   AddItemProperty(DURATION_TYPE_PERMANENT,ipBDamage,oItem);
 
  itemproperty ipEnhancement = ItemPropertyEnhancementBonus(nLC);
   AddItemProperty(DURATION_TYPE_PERMANENT,ipEnhancement,oItem);

}
               
               

               
            

Legacy_the.gray.fox

  • Full Member
  • ***
  • Posts: 214
  • Karma: +0/-0
Weapon Visual Effect Changes Depending on Wielder's Alignment
« Reply #9 on: June 13, 2012, 06:54:07 pm »


               

UnrealJedi wrote...
Also, you mentioned that the visual effect will change when the bonus type changes? Can you elaborate further?

Thanks!


When a human controlled character equips a weapon with some added elemental damage (ie: +2 Fire), the game automatically adds-in the corresponding elemental visual effect to play (ie: flames for Fire damage, frost for Cold damage) in case the weapon was *not* explicitly given one (via item editor/script commands).


Two things worth mention are:

1) The game can only show you 1 elemental damage type. If I am not mistaken it will choose the first damage type that was applied to the weapon (which is not necessarily the first damage type listed when you inspect the weapon properties in-game). This happens only in case the weapon has no elemental visual effect applied already.

2) What is explained in point 1) only happens when the weapon is handled by a player character. If you have an NPC equip the very same weapon, even after a PC made use of it, there would be no elemental visual effect auto-applied by the engine (a bug). To be sure that you get the elemental visual effect displayed, regarldess of weapon user, it is opportune to explicit the visual effect type you want shown.


-fox
               
               

               
            

Legacy_UnrealJedi

  • Full Member
  • ***
  • Posts: 226
  • Karma: +0/-0
Weapon Visual Effect Changes Depending on Wielder's Alignment
« Reply #10 on: June 13, 2012, 07:32:50 pm »


               This is very cool stuff! I had no idea that you could do this with scripting.I'm looking forward to testing this script out now.

Lightfoot, thanks for the script! Gray Fox, thanks for adding in explanations. I truly had no idea this stuff was possible...