Spells to fix for Rose, so they target both wielded weapons.

For in-game support requests, and bug reports.
Somnium
Site Admin
Posts: 173
Joined: Sat Jan 10, 2015 5:34 pm

Re: Spells to fix for Rose, so they target both wielded weapons.

Post by Somnium »

Alangara uses a non-standard method for tag-based scripting. @Tara, the module should be using the farm_mod_activ script in its OnActivateItem event (you can verify this in the edit->module properties->events).

When an item is activated, the farm_mod_activ script runs a script with a name corresponding exactly to the tag of the activated item. It is not necessary to check for item event, since we use a custom script for item activation (and do not currently have any tag-based scripts triggered by the other events) :)

So specifically for the Alangara module, Tara's reasoning is correct, the scripts should not be wrapped in "if( GetUserDefinedItemEventNumber() == X2_ITEM_EVENT_ACTIVATE )", since the scripts will then exit immediately :).

(the reason for this is, that Alangara predates the expansion/patch that introduced the "official" tag-based event system, hence we use a custom system)
Somnium (a.k.a. Seeker)
User avatar
tarashon
Posts: 861
Joined: Sun Jan 11, 2015 6:27 pm

Re: Spells to fix for Rose, so they target both wielded weapons.

Post by tarashon »

Well first of I'm mighty glad some of this scripting is slowly starting to incoorporate in my brain :)

Secondly thanks for the full explanation Seeker, and yes the farm_mod_activate makes a lot of sense since the module would have needed the script for the farm functions even 10 years ago :)

Now for the matter at hand though... Did you check if it's working now Rose ?

/tara
Warchief
Posts: 63
Joined: Fri Dec 04, 2015 10:27 pm

Re: Spells to fix for Rose, so they target both wielded weapons.

Post by Warchief »

Rose checked last night and it does not function.
User avatar
Li'l Rose
Posts: 142
Joined: Thu Apr 09, 2015 8:19 pm

Re: Spells to fix for Rose, so they target both wielded weapons.

Post by Li'l Rose »

Well, Tara did not mention any custom module activate item scripts, where the item is activated there, so I made them specifically as tag scripts. Thus they would require the check for item event. As tag scripts, they did work fine, when I tested them on my own cep2.61 server.

From testing on the server last night, the item did not work, and since there were no whips, we spent the night just chatting. Obviously the script needs to be adapted to your farm_mod_activ script, but without seeing that script, I cannot do anything more.
User avatar
tarashon
Posts: 861
Joined: Sun Jan 11, 2015 6:27 pm

Re: Spells to fix for Rose, so they target both wielded weapons.

Post by tarashon »

Arg !

First of sorry about the whips - totally forgot about those, will reset the module in 5 minuttes WITH whips inside Morgloins's Smithie.

secondly here comes the on_activate_item script....
<SNIP: edited by Seeker>

This said i dont really get it. Whenever i've made scripts I have simply given them the name of the item tag and VUPTI script runs - sometimes other things are wrong though lol, but the script activates.

And here Seeker is the script that is not running so you might see the problems...


//::///////////////////////////////////////////////
//:: Negative Weapon
//:: Copyright (c) 2015 Rose Corp.
//:://////////////////////////////////////////////
// Gives a melee weapon 2d8 negative energy damage.
//:://////////////////////////////////////////////
//:: Created By: Rose
//:: Created On: Dec. 6, 2015
//:://////////////////////////////////////////////


#include "nw_i0_spells"
#include "x2_i0_spells"

#include "x2_inc_switches"
#include "x2_inc_itemprop"


void main()
// {
// if( GetUserDefinedItemEventNumber() == X2_ITEM_EVENT_ACTIVATE )
{
if (GetLevelByClass(CLASS_TYPE_BLACKGUARD, OBJECT_SELF) < 1)
{
SendMessageToPC(OBJECT_SELF, "You must have at least 1 level of blackguard to use this item!");
return;
}

//Declare major variables
effect eVis = EffectVisualEffect(VFX_IMP_PULSE_NEGATIVE);
effect eDur = EffectVisualEffect(VFX_DUR_CESSATE_NEGATIVE);
int nMetaMagic = GetMetaMagicFeat();
int nCasterLvl = GetLevelByClass(CLASS_TYPE_BLACKGUARD, OBJECT_SELF);
int nDuration = 2 * nCasterLvl;

//Limit nCasterLvl to 20.
if(nCasterLvl > 20)
{
nCasterLvl = 20;
}

if (nMetaMagic == METAMAGIC_EXTEND)
{
nDuration = nDuration * 2; //Duration is +100%
}

object oTarget = GetItemActivatedTarget();
if(GetIsObjectValid(oTarget) && GetObjectType(oTarget) == OBJECT_TYPE_CREATURE)
{
// Alter the right hand weapon equipped by the creature.
object oWeapon1 = GetItemInSlot(INVENTORY_SLOT_RIGHTHAND, oTarget);
if(GetIsObjectValid(oWeapon1))
{
// If the PC has a melee weapon equipped.
if ( IPGetIsMeleeWeapon(oWeapon1))
{
if (nDuration>0)
{
// haaaack: store caster level on item for the on hit spell to work properly
ApplyEffectToObject(DURATION_TYPE_INSTANT, eVis, GetItemPossessor(oWeapon1));
ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eDur, GetItemPossessor(oWeapon1), TurnsToSeconds(nDuration));
IPSafeAddItemProperty(oWeapon1, ItemPropertyDamageBonus(IP_CONST_DAMAGETYPE_NEGATIVE, IP_CONST_DAMAGEBONUS_2d8), 1440.0);
}
}
else
{
FloatingTextStrRefOnCreature(83615, OBJECT_SELF);
}
}
// Alter the left hand weapon equipped by the creature.
object oWeapon2 = GetItemInSlot(INVENTORY_SLOT_LEFTHAND, oTarget);
if(GetIsObjectValid(oWeapon2))
{
// If the PC has a melee weapon equipped.
if ( IPGetIsMeleeWeapon(oWeapon2))
{
if (nDuration>0)
{
// haaaack: store caster level on item for the on hit spell to work properly
ApplyEffectToObject(DURATION_TYPE_INSTANT, eVis, GetItemPossessor(oWeapon2));
ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eDur, GetItemPossessor(oWeapon2), TurnsToSeconds(nDuration));
IPSafeAddItemProperty(oWeapon2, ItemPropertyDamageBonus(IP_CONST_DAMAGETYPE_NEGATIVE, IP_CONST_DAMAGEBONUS_2d8), 1440.0);
}
}
else
{
FloatingTextStrRefOnCreature(83615, OBJECT_SELF);
}
}
// Alter the right claw equipped by the creature.
object oWeapon3 = GetItemInSlot(INVENTORY_SLOT_CWEAPON_R, oTarget);
if(GetIsObjectValid(oWeapon3))
{
if (nDuration>0)
{
// haaaack: store caster level on item for the on hit spell to work properly
ApplyEffectToObject(DURATION_TYPE_INSTANT, eVis, GetItemPossessor(oWeapon3));
ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eDur, GetItemPossessor(oWeapon3), TurnsToSeconds(nDuration));
IPSafeAddItemProperty(oWeapon3, ItemPropertyDamageBonus(IP_CONST_DAMAGETYPE_NEGATIVE, IP_CONST_DAMAGEBONUS_2d8), 1440.0);
}
}
// Alter the left claw equipped by the creature.
object oWeapon4 = GetItemInSlot(INVENTORY_SLOT_CWEAPON_L, oTarget);
if(GetIsObjectValid(oWeapon4))
{
if (nDuration>0)
{
// haaaack: store caster level on item for the on hit spell to work properly
ApplyEffectToObject(DURATION_TYPE_INSTANT, eVis, GetItemPossessor(oWeapon4));
ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eDur, GetItemPossessor(oWeapon4), TurnsToSeconds(nDuration));
IPSafeAddItemProperty(oWeapon4, ItemPropertyDamageBonus(IP_CONST_DAMAGETYPE_NEGATIVE, IP_CONST_DAMAGEBONUS_2d8), 1440.0);
}
}
// Alter the bite equipped by the creature.
object oWeapon5 = GetItemInSlot(INVENTORY_SLOT_CWEAPON_B, oTarget);
if(GetIsObjectValid(oWeapon5))
{
if (nDuration>0)
{
// haaaack: store caster level on item for the on hit spell to work properly
ApplyEffectToObject(DURATION_TYPE_INSTANT, eVis, GetItemPossessor(oWeapon5));
ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eDur, GetItemPossessor(oWeapon5), TurnsToSeconds(nDuration));
IPSafeAddItemProperty(oWeapon5, ItemPropertyDamageBonus(IP_CONST_DAMAGETYPE_NEGATIVE, IP_CONST_DAMAGEBONUS_2d8), 1440.0);
}
}
}
else
{
SendMessageToPC(OBJECT_SELF, "You must target a creature!");
return;
}
}
// }


/tara
User avatar
tarashon
Posts: 861
Joined: Sun Jan 11, 2015 6:27 pm

Re: Spells to fix for Rose, so they target both wielded weapons.

Post by tarashon »

And it is finally fixed, and working as intended, both blackguard and assasin :)

Basically both needed an oPC = GetItemActivator, instead of OBJECT_SELF.

/tara
Somnium
Site Admin
Posts: 173
Joined: Sat Jan 10, 2015 5:34 pm

Re: Spells to fix for Rose, so they target both wielded weapons.

Post by Somnium »

In our onActivation script, OBJECT_SELF refers to module, not the PC - use a "object oPC = GetItemActivator();", and then replace OBJECT_SELF with oPC in the script :)

* EDIT : Gah, too slow :) *
Somnium (a.k.a. Seeker)
User avatar
tarashon
Posts: 861
Joined: Sun Jan 11, 2015 6:27 pm

Re: Spells to fix for Rose, so they target both wielded weapons.

Post by tarashon »

HAHA Seeker :)

/tara
User avatar
Li'l Rose
Posts: 142
Joined: Thu Apr 09, 2015 8:19 pm

Re: Spells to fix for Rose, so they target both wielded weapons.

Post by Li'l Rose »

Ah, that would explain why OBJECT_SELF worked for me, but not on your module. These scripts were converted from spell scripts, which refered to the caster as OBJECT_SELF. I had to play around with them to get them to work as item activate scripts. You could probably remove all of the metamagic stuff, since the duration is fixed, so extend spell will have no effect.
User avatar
Li'l Rose
Posts: 142
Joined: Thu Apr 09, 2015 8:19 pm

Re: Spells to fix for Rose, so they target both wielded weapons.

Post by Li'l Rose »

Here you go Tara. Add this to the module on rest script, and all the temporary weapon powers will be dispelled on rest.

If oPC is not GetLastPCRested, then change it as needed. Put the include script at the top, if it is not there already.

Code: Select all

#include "x2_inc_itemprop"

//Remove temporary item properties.
object oItem;
oItem = GetItemInSlot(INVENTORY_SLOT_RIGHTHAND, oPC);
if(GetIsObjectValid(oItem))
IPRemoveAllItemProperties(oItem, DURATION_TYPE_TEMPORARY);
oItem = GetItemInSlot(INVENTORY_SLOT_LEFTHAND, oPC);
if(GetIsObjectValid(oItem))
IPRemoveAllItemProperties(oItem, DURATION_TYPE_TEMPORARY);
oItem = GetItemInSlot(INVENTORY_SLOT_CWEAPON_B, oPC);
if(GetIsObjectValid(oItem))
IPRemoveAllItemProperties(oItem, DURATION_TYPE_TEMPORARY);
oItem = GetItemInSlot(INVENTORY_SLOT_CWEAPON_L, oPC);
if(GetIsObjectValid(oItem))
IPRemoveAllItemProperties(oItem, DURATION_TYPE_TEMPORARY);
oItem = GetItemInSlot(INVENTORY_SLOT_CWEAPON_R, oPC);
if(GetIsObjectValid(oItem))
IPRemoveAllItemProperties(oItem, DURATION_TYPE_TEMPORARY);
Post Reply