Weapon Visual Effect Changes Depending on Wielder's Alignment
#1
Posté 12 juin 2012 - 05:46
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?
#2
Posté 12 juin 2012 - 06:20
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.
Modifié par HipMaestro, 12 juin 2012 - 06:27 .
#3
Posté 12 juin 2012 - 07:09
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?
#4
Posté 12 juin 2012 - 07:40
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.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?
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 .
#5
Posté 12 juin 2012 - 09:07
#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);
}
#6
Posté 13 juin 2012 - 02:58
Thanks again!
#7
Posté 13 juin 2012 - 03:55
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.
#8
Posté 13 juin 2012 - 04:57
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 .
#9
Posté 13 juin 2012 - 05:53
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);
}
#10
Posté 13 juin 2012 - 05:54
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
#11
Posté 13 juin 2012 - 06:32
Lightfoot, thanks for the script! Gray Fox, thanks for adding in explanations. I truly had no idea this stuff was possible...





Retour en haut







