Aller au contenu

Photo

Trying to find Alchemist's Fire on hit spell script


  • Veuillez vous connecter pour répondre
8 réponses à ce sujet

#1
Kaldor Silverwand

Kaldor Silverwand
  • Members
  • 1 598 messages
I'm trying to create some additional grenade/coating potions like Alchemist's Fire except with different effects than fire. One of the things that the Alchemist's Fire script (x0_s3_alchem) does when a weapon is coated is to attach an integer variable to the weapon named X2_SPELL_CLEVEL_FLAMING_WEAPON which stores a value that is directly proportional to the strength of the potion (i.e., stronger versions of Alchemist's Fire have a higher number assigned). The comment in the code says that this is a hack that is needed for the "on hit spell to work properly".

Since I am not assigning fire damage, but rather cold or divine damage, I expect that X2_SPELL_CLEVEL_FLAMING_WEAPON may not be the appropriate variable name to use, especially if in the on hit script this causes fire damage to be applied.  So I would like to examine the on hit script where X2_SPELL_CLEVEL_FLAMING_WEAPON is used to see how it is used and whether I will need to modify it to support other damage types. I have not been successful at determining what the on hit spell script referred to is called. Anyone know?

Regards

#2
The Fred

The Fred
  • Members
  • 2 516 messages
I'm not sure that it actually does anything. The OnHit property is supposed to deal some damage based upon the level, which is part of the item property. The variable hack is supposed to be a work-around for some sort of bug in that, but I've never experienced it. You probably just want to look at the script which fires when the wielder of the item strikes a foe. I don't know what it is off the top of my head, but you could look up what spell the OnHit property calls and from there find the script name.

#3
Kaldor Silverwand

Kaldor Silverwand
  • Members
  • 1 598 messages

The Fred wrote...
You probably just want to look at the script which fires when the wielder of the item strikes a foe. I don't know what it is off the top of my head, but you could look up what spell the OnHit property calls and from there find the script name.


I've no idea how to find "what spell the OnHit property calls". Weapons don't show an OnHit property in the toolset property list. My experience with this sort of thing is limited to tag-based scripts, and that doesn't seem to apply here. So, does anyone know what script fires when the wielder of an item strikes a foe? The nw_c2_default scripts do not seem to be what I am looking for.

Regards

#4
The Fred

The Fred
  • Members
  • 2 516 messages
Sorry, I should have been clearer, it's an OnHit: Cast Spell property. Well, just looking at the spells 2da there's an OnHitFreDamage spell (line 696) with the script X2_S3_FlamingD. I think that's the one Alchemist's Fire uses, though I think it's also used by Flame Weapon and Darkfire (or whatever those spells are). It should be clear if you check those scripts and compare them with the alchemist's fire script, though.

#5
The Fred

The Fred
  • Members
  • 2 516 messages
I should probably have explained this a bit better.

When you attack someone, you trigger their OnPhysicalAttacked event and possibly their OnDamaged event, but there isn't an OnStruck or whatever event.

When you hit them with a weapon with an OnHit property, something happens, but it's all hardcoded. Still no event.

When you hit them with a weapon with an OnHit: Cast Spell property, a spell is fired which has an associated script. Not an event as per say but it's still triggering a script so that's what we're after.

The alchemist's fire spell script fires when you use alchemist's fire. If your target was not an item, it does fire damage to things in a radius, but if your target was an item, it add a property to that item temporarily. If I remember correctly it's an OnHit: Cast Spell property where there spell is a special fire damage one. So, there are two spells here, the one which fires when you use alchemist's fire and the one which fires when a weapon coating in alchemist's fire strikes a foe. You've obviously found the first one just fine, but it's the second one you want to look at.

Incidentally, if you are creating alternative damage versions, you probably want to make new OnHit spells as well, rather than using the default alchemist's fire spell. However, that would require custom content (i.e. 2da and TLK modifications) which you might not want, in which case hooking into this script might indeed be your best bet. It's certainly good to look at them to see what's going on, anyway.

#6
kevL

kevL
  • Members
  • 4 070 messages

The Fred wrote...

I'm not sure that it actually does anything.

i'm pretty sure you guys are overthinking things.

I did a search through all \\Data and \\Campaign scripts for "X2_SPELL_CLEVEL_FLAMING_WEAPON" and found only 1 instance: "x0_s3_alchem"


the note says:
// haaaack: store caster level on item for the on hit spell to work properly
SetLocalInt(oMyWeapon,"X2_SPELL_CLEVEL_FLAMING_WEAPON",nCasterLvl);

but then the function above, AddFlamingEffectToWeapon() *does not actually apply an OnHit* itemproperty. Instead, it applies
itemproperty ipFlame = ItemPropertyDamageBonus(IP_CONST_DAMAGETYPE_FIRE, nBonus);

for fDuration of 4 rounds.

As such, generating a Cold application (eg) would simply require copying that script and replacing IP_CONST_DAMAGETYPE_FIRE w/ whatever and changing a few VFX .. no .2da editing required, imo.

All four versions of Alchemist's Fire use the itemproperty: Cast Spell: Alchemist's Fire [Single Use]. Give that property to yer Pouch o Cold, eg, and then alter the "x0_s3_alchem" script to check for a unique tag of the Casting Item. ... no Tag-based scripting either, unless you want to go that way


however, Kaldor, something you said has me believing you may be looking at a different "x0_s3_alchem"

Kaldor Silverwand wrote...

One of the things that the Alchemist's Fire script (x0_s3_alchem) does when a weapon is coated is to attach an integer variable to the weapon named X2_SPELL_CLEVEL_FLAMING_WEAPON which stores a value that is directly proportional to the strength of the potion (i.e., stronger versions of Alchemist's Fire have a higher number assigned).

- from v1.23 \\Data scripts ( w/ RPGplayer1 03/19/2008 fix ) nCasterLvl is only and exactly "1". The strength of the application is determined, rather, by the tag of the item used, in function AddFlamingEffectToWeapon().

hth

#7
Kaldor Silverwand

Kaldor Silverwand
  • Members
  • 1 598 messages
I think you are on to something kevL. I definitely do not want to have to modify a 2da and I've already written the tag based scripts (I like them), so if this variable setting is completely unnecessary, as it appears, then I think my scripts will likely work as is. Hopefully so. I'll find out.

Thanks.

#8
Lance Botelle

Lance Botelle
  • Members
  • 1 480 messages
Hi,

I rewrote this script a long while ago, but I think this works fine. I think I reworked it to make the durations vary. Anyway, you should see it would be easy enough to alter the AddFlamingEffectToWeapon function to whatever effect you want - and then just change the constants in the function above.

Take a look at this and it may make more sense ...

Lance.

[nwscript]
#include "X2_I0_SPELLS"
#include "x2_inc_itemprop"
#include "x2_inc_spellhook"

void AddFlamingEffectToWeapon(object oTarget, float fDuration, int DamageBonus)
{
IPSafeAddItemProperty(oTarget, ItemPropertyDamageBonus(IP_CONST_DAMAGETYPE_FIRE, DamageBonus), fDuration, X2_IP_ADDPROP_POLICY_REPLACE_EXISTING); // MAKE CHANGES HERE
IPSafeAddItemProperty(oTarget, ItemPropertyVisualEffect(ITEM_VISUAL_FIRE), fDuration,X2_IP_ADDPROP_POLICY_REPLACE_EXISTING,FALSE,TRUE); // MAKE CHANGES HERE
}

void main()
{

if (!X2PreSpellCastCode())
{
// If code within the PreSpellCastHook (i.e. UMD) reports FALSE, do not run this spell
return;
}

int nDmg; int nSplashDmg; int nDuration; int DamageBonus;

object oItem = GetSpellCastItem();
string sTag = GetStringLowerCase(GetTag(oItem));

if (sTag == "x1_wmgrenade002"){nDmg = d6(1); nSplashDmg = 1; nDuration = d4(4); DamageBonus = IP_CONST_DAMAGEBONUS_1d4;}
if (sTag == "n2_it_alch_2"){nDmg = d8(1); nSplashDmg = 2; nDuration = d4(6); DamageBonus = IP_CONST_DAMAGEBONUS_1d6;}
if (sTag == "n2_it_alch_3"){nDmg = d10(1); nSplashDmg = d4(1); nDuration = d6(6); DamageBonus = IP_CONST_DAMAGEBONUS_1d8;}
if (sTag == "n2_it_alch_4"){nDmg = d6(2); nSplashDmg = d4(1) + 1; nDuration = d6(8); DamageBonus = IP_CONST_DAMAGEBONUS_1d10;}

effect eVis = EffectVisualEffect(VFX_COM_HIT_FIRE);
effect eDur = EffectVisualEffect(VFX_DUR_CESSATE_POSITIVE);
object oTarget = GetSpellTargetObject();
int nTarget = GetObjectType(oTarget);

if(nTarget == OBJECT_TYPE_ITEM)
{
if(IPGetIsMeleeWeapon(oTarget))
{
SignalEvent(OBJECT_SELF, EventSpellCastAt(OBJECT_SELF, GetSpellId(), FALSE));
ApplyEffectToObject(DURATION_TYPE_INSTANT, eVis, GetItemPossessor(oTarget));
ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eDur, GetItemPossessor(oTarget), RoundsToSeconds(nDuration));
AddFlamingEffectToWeapon(oTarget, RoundsToSeconds(nDuration), DamageBonus);
return;
}

else if(GetItemPossessor(oTarget)!=OBJECT_INVALID)
{
FloatingTextStrRefOnCreature(100944,OBJECT_SELF);
}
}

// ELSE JUST DO GRENADE
DoGrenade(nDmg,nSplashDmg,VFX_HIT_SPELL_FIRE,VFX_HIT_AOE_FIRE,DAMAGE_TYPE_FIRE,RADIUS_SIZE_HUGE, OBJECT_TYPE_CREATURE | OBJECT_TYPE_DOOR | OBJECT_TYPE_PLACEABLE);
}[/nwscript]



EDIT: FOR EXAMPLE OF A COLD WEAPON POTION - CHANGES WOULD BE:

AddColdEffectToWeapon(oTarget, RoundsToSeconds(nDuration), DamageBonus);

void AddColdEffectToWeapon(object oTarget, float fDuration, int DamageBonus)
{
IPSafeAddItemProperty(oTarget, ItemPropertyDamageBonus(IP_CONST_DAMAGETYPE_COLD, DamageBonus), fDuration, X2_IP_ADDPROP_POLICY_REPLACE_EXISTING); // MAKE CHANGES HERE
IPSafeAddItemProperty(oTarget, ItemPropertyVisualEffect(ITEM_VISUAL_COLD), fDuration,X2_IP_ADDPROP_POLICY_REPLACE_EXISTING,FALSE,TRUE); // MAKE CHANGES HERE
}

Modifié par Lance Botelle, 18 novembre 2011 - 02:11 .


#9
The Fred

The Fred
  • Members
  • 2 516 messages

kevL wrote...
AddFlamingEffectToWeapon() *does not actually apply an OnHit* itemproperty. Instead, it applies

itemproperty ipFlame = ItemPropertyDamageBonus(IP_CONST_DAMAGETYPE_FIRE, nBonus);
for fDuration of 4 rounds.

Hmm, I didn't actually check the script, so maybe they changed things, but I seem to remember than in NWN1 they used an OnHit property to get the right about of bonus damage. It might have been that that was only for spells like Darkfire and Flaming Weapon, now I think about it, or it might be that because they now have different grades of Alchemist's Fire, they changed the code accordingly. Either way, if it is just a damage bonus then changing the type is trivial.