Aller au contenu

Photo

Help with Removing Modify Attacks..


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

#1
Genisys

Genisys
  • Members
  • 525 messages
I need to know if anyone knows how to remove the Effect...

eEffect = EffectModifyAttacks(1);

From the PC once it has been applied...

The only solution I could find was to set it like so...

eEffect = SupernaturalEffect(eEffect);

And then to remove it by checking the subtype of the effect, and if it was Supernatural Remove it...

However, I need to know if there is a more effective way to remove the effect (Modify Attacks) from the PC.. properly..

Anyone?

#2
Shadooow

Shadooow
  • Members
  • 4 470 messages
Two ways, first is to make new spell and tell some system creature to cast it, that way the effect will have spellID set and you will be able to remove it via that.



Second way using system creature too - effect creator, give it tag like EC_MODIFYATTACK. Tell this creture to apply the modify effect and then check of tag of effect creator == "EC_MODIFYATTACK"

#3
Genisys

Genisys
  • Members
  • 525 messages
I just applied it as a supernatural effect, then removed all supernatural effects upon unequip, works fine, but it will cause problems with other supernatural effects not applied via this script. :/

#4
420

420
  • Members
  • 190 messages
The best method, as ShaDoOoW suggested, is to have an object apply the effect then just use GetEffectCreator() to check for the specific effect. I use a series of invisible objects to apply various effects on my server so I only remove the effect(s) I want.



-420

#5
Genisys

Genisys
  • Members
  • 525 messages
Anyway you guys can give me a template script for this?

#6
Shadooow

Shadooow
  • Members
  • 4 470 messages
example to add the effect:

if(GetHasFeat(FEAT_NINJA_GHOST_SIGHT,oPC))
 {
 AssignCommand(GetObjectByTag("EC_NINJA"),ApplyEffectToObject(DURATION_TYPE_PERMANENT, SupernaturalEffect(EffectSeeInvisible()),oPC));
 }

example to remove the effect:

effect e = GetFirstEffect(oPC);
string sTag;
 while(GetIsEffectValid(e))
 {
 sTag = GetTag(GetEffectCreator(e)) ;
  if(sTag  == "EC_NINJA")
  {
  RemoveEffect(oPC,e);
  }
 e = GetNextEffect(oPC);
 }


Modifié par ShaDoOoW, 11 août 2010 - 05:24 .


#7
Genisys

Genisys
  • Members
  • 525 messages
That's a bizarre concept for me, I'll assume I need to create this ninja some how, and probably use a waypoint as a reference point, eg.



oWay = GetWaypointByTag("ninja_way");

oNinja = GetNearestObjectByTag("EC_NINJA", oWay);



I'll assume it's best to create and destroy this ninja, and not just leave him laying around?

Does the ninja have to be a creature?

#8
Shadooow

Shadooow
  • Members
  • 4 470 messages
I don't know, I think that waypoint can't cast spells, but placeable can.

You don't need waypoint just creature or placeable (but if it won't work don't blame me) in special system area. For example my EC_NINJA is actually lvl 1 immortal/plot chicken without any scripts.

Modifié par ShaDoOoW, 11 août 2010 - 11:18 .


#9
420

420
  • Members
  • 190 messages

I'll assume it's best to create and destroy this ninja, and not just leave him laying around?

No reason not to. Just put it in a 2x2 microset area with no area transitions.

Does the ninja have to be a creature?

Like I said, I use Invisible Object placeables.

-420

#10
Shadooow

Shadooow
  • Members
  • 4 470 messages

420 wrote...

Like I said, I use Invisible Object placeables.

kk now when its clear, using placeable is much better than creature

#11
Genisys

Genisys
  • Members
  • 525 messages
Ok, thanks for the response guys, I'll use a placeable object then.. (invisbile seems good)



The waypoint is so I don't have to use the GetObjectByTag Function, which cycles through the whole module to find the object, (not good).



thanks a lot for the help guys... I'll test this today. :)

#12
Shadooow

Shadooow
  • Members
  • 4 470 messages
If you care about GetObjectByTag, save the invisible placeable to module when OnModuleLoad and you are fine:

object EC_MODIFYATTACK = GetObjecByTag("EC_MODIFYATTACK");

SetLocalObject(OBJECT_SELF,"EC_MODIFYATTACK",EC_MODIFYATTACK);



#13
420

420
  • Members
  • 190 messages
Invisible Objects are also good for applying "environmental" damage effects. Just rename the placeable "Lightning" or "Falling Rocks" or "Swinging Blades" and then have it do damage to the PC. The feedback will look something like: "Lightning does 6 electrical damage to you." or "Falling Rocks does 10 bludgeoning damage to you."



-420

#14
Genisys

Genisys
  • Members
  • 525 messages
Thanks for the Tip Guys XD

#15
_Guile

_Guile
  • Members
  • 685 messages
After so long, I actually tested this today....

It DOES NOT Remove the effect, also I've quadruple checked my scripts and items....

In the next post is the script I used... (Any Help?)

Modifié par _Guile, 29 avril 2013 - 10:26 .


#16
_Guile

_Guile
  • Members
  • 685 messages
//
// (NOTE: This is a template script, save it under a new name FIRST)
////////////////////////////////////////////////////////////////////////////////
// Created by: The Krit
// Created on: 04-03-2010
// Modified by: Genisys / Guile
// Modified on: 04-30-2011
///////////////////////////////////////////////////////////////////////////////

// This is intended to be a starting point for writing an item's tag-based script.
// Copy this to a script whose name is the tag of the item in question.
// Edit the event handlers (scroll down to find them) as desired.
// -----------------------------------------------------------------------------
//Required Include (DO NOT TOUCH!)
#include "x2_inc_switches"
//------------------------------------------------------------------------------

// Delcare ALL Common Integers / Floats / Strings
// NOTE: These can be used anywhere in any of the Prototypes
// By declaring at the top of the script they do not need to be delcared anywhere else!
int nInt, i, nGold, nXP, nclass, nCon; // nCon = nConstant
float fDelay, fTime;
string sName, sTag, sMsg, sResref;
//Add more if needed!

// -----------------------------------------------------------------------------
// Event handlers
// -----------------------------------------------------------------------------
// This second part is where you add your desired functionality. Each event
// has its own function with relavant information passed as parameters.
// -----------------------------------------------------------------------------


// -----------------------------------------------------------------------------
// oItem was acquired (by a PC or an NPC).
// Run by the module.
void OnAcquire(object oItem, object oAcquiredBy, object oTakenFrom, int nStackSize)
{
// Enter code to execute when this event happens
}


// -----------------------------------------------------------------------------
// oItem was activated ("activate item" or "unique power").
// Run by the module.
void OnActivate(object oItem, object oActTarget, location lActTarget, object oActivator)
{
// Enter code to execute when this event happens
}


// -----------------------------------------------------------------------------
// oItem was equipped by a PC.
// Run by the module.
void OnEquip(object oItem, object oEquippedBy)
{
object oWay = GetWaypointByTag("ec_caster_way");
object oEC = GetNearestObjectByTag("eff_caster", oWay);

effect eMas = EffectModifyAttacks(1);
eMas = SupernaturalEffect(eMas);
effect eVis = EffectVisualEffect(VFX_DUR_IOUNSTONE_YELLOW);

if(oWay == OBJECT_INVALID)
{
FloatingTextStringOnCreature("ERROR, notify DMs that the waypoint for this item is missing!", oEquippedBy, TRUE);
return;
}
if(oEC == OBJECT_INVALID)
{
oEC = CreateObject(OBJECT_TYPE_PLACEABLE, "eff_caster", GetLocation(oWay), FALSE);
}



AssignCommand(oEC, ApplyEffectToObject(
DURATION_TYPE_PERMANENT, eMas, oEquippedBy));

AssignCommand(oEC, ApplyEffectToObject(
DURATION_TYPE_PERMANENT, eVis, oEquippedBy));
}


// -----------------------------------------------------------------------------
// oItem is a weapon that just hit a target, or it is the armor of someone who
// was just hit by someone else's weapon.
// Run by the caster.
void OnHit(object oItem, object oHitTarget, object oCaster)
{
// Enter code to execute when this event happens
}


// -----------------------------------------------------------------------------
// Someone cast a spell at oItem.

// Run by the caster.
int OnSpellCast(object oItem, int nSpell, object oCaster)
{
// Enter code to execute when this event happens

return FALSE; //Necessary return (Do this !)
}


// -----------------------------------------------------------------------------
// oItem was unacquired/lost (by a PC or NPC).
// Run by the module.
void OnUnacquire(object oItem, object oLostBy)
{
// Enter code to execute when this event happens
}


// -----------------------------------------------------------------------------
// oItem was unequipped by a PC.
// Run by the module.
void OnUnequip(object oItem, object oUnequippedBy)
{
//Remove Speed Increase
object oPC = oUnequippedBy;
effect e = GetFirstEffect(oPC);
string sTag;
while(GetIsEffectValid(e))
{
sTag = GetTag(GetEffectCreator(e)) ;
if(sTag == "eff_caster")
{
FloatingTextStringOnCreature("Effect Removed!", oPC, FALSE);
RemoveEffect(oPC, e);
}
e = GetNextEffect(oPC);
}

}


//////////////////////////////////////////////////////////////////////////////
// ##### WARNINING:: DON'T TOUCH ANYTHING BELOW THIS LINE!!! #### ///////////
////////////////////////////////////////////////////////////////////////////

// The main function.
void main()
{
int nEvent = GetUserDefinedItemEventNumber();

// Spells might continue to their spell scripts. All other events are
// completely handled by this script.
if ( nEvent != X2_ITEM_EVENT_SPELLCAST_AT )
SetExecutedScriptReturnValue();

// Determine which event triggered this script's execution.
switch ( nEvent )
{
// Item was acquired.
case X2_ITEM_EVENT_ACQUIRE:
OnAcquire(GetModuleItemAcquired(), GetModuleItemAcquiredBy(),
GetModuleItemAcquiredFrom(), GetModuleItemAcquiredStackSize());
break;

// Item was activated ("activate item" or "unique power").
case X2_ITEM_EVENT_ACTIVATE:
OnActivate(GetItemActivated(), GetItemActivatedTarget(),
GetItemActivatedTargetLocation(), GetItemActivator());
break;

// Item was equipped by a PC.
case X2_ITEM_EVENT_EQUIP:
OnEquip(GetPCItemLastEquipped(), GetPCItemLastEquippedBy());
break;

// Item is a weapon that just hit a target, or it is the armor of someone
// who was just hit.
case X2_ITEM_EVENT_ONHITCAST:
OnHit(GetSpellCastItem(), GetSpellTargetObject(), OBJECT_SELF);
break;

// A PC (or certain NPCs) cast a spell at the item.
case X2_ITEM_EVENT_SPELLCAST_AT:
if ( OnSpellCast(GetSpellTargetObject(), GetSpellId(), OBJECT_SELF) )
SetExecutedScriptReturnValue();
break;

// Item was unacquired.
case X2_ITEM_EVENT_UNACQUIRE:
OnUnacquire(GetModuleItemLost(), GetModuleItemLostBy());
break;

// Item was unequipped by a PC.
case X2_ITEM_EVENT_UNEQUIP:
OnUnequip(GetPCItemLastUnequipped(), GetPCItemLastUnequippedBy());
break;
}
}

#17
FunkySwerve

FunkySwerve
  • Members
  • 1 308 messages
Without having read your script, I can tell you that what was suggested will work, if done properly, and that the most likely problem is that you're only AssignCommanding the application of the effect, rather than its declaration, which is what GetEffectCreator looks for. You need to ensure that the object you want to be the creator is the one calling the function, main or otherwise, that creates the effect. The ApplyEffect is totally irrelevant - it's all about the declaration, that is,
effect eSomething = blah;

Funky

#18
ffbj

ffbj
  • Members
  • 593 messages
Just for consistency I would define oEquippedBy as oPC, as you did in the unequipped portion.
Make sure the object eff_creator actually exists, in the toolset.
It appears the effect creator was done correctly.
AssignCommand(oEC, ApplyEffectToObject(
DURATION_TYPE_PERMANENT, eMas, oEquippedBy));

So how do you know it is not removing it?  Becasue the visual effect is still active, since the modify attacks would
be diificult to detect?  Perhaps better to link those effects and apply them together.  As it stands you have two seperate effects applied by the same object, though that should not matter if the script is working properly.  The script should loop through all extant effects created by eff_creator and remove them accordingly. Btw I would remove the reference to speed as it is irrelevant, perhaps just change it to effect.

Modifié par ffbj, 30 avril 2013 - 04:23 .


#19
_Guile

_Guile
  • Members
  • 685 messages
Thanks Funky, that did it, I executed a script on the placeable object, by setting a local object of the PC on the PO, (Placeable Object), then the Tag Based script properly removed it because it properly found the Effect Creator...


This really helped me a lot, I suppose I will have to make some more use of this. =)
(Going to make a good system with this)


Thanks again Funky! :wizard:

Modifié par _Guile, 30 avril 2013 - 05:24 .


#20
_Guile

_Guile
  • Members
  • 685 messages
Made this for fun =)
/////////////////////////////////////////////////////////////////////////

// eff_caster_exc
////////////////////////////////////////////////
// Created By: Genisys / Guile
// Created On: 2/10/2013
////////////////////////////////////////////////////////////////////////////////
/*
This script is executed on a spawned in object used to apply an effect to
the PC, this way we can through scripting remove any effect applied to the
PC without removing other effects by accident!

This is ONLY For Permanent Effects/Feats, as there is no need for temporary!
*/
////////////////////////////////////////////////////////////////////////////////

//Main Script
void main()
{
// The Placeable Object that was spawned in for this effect!
object oMe = OBJECT_SELF;

// The PC we saved on the placeable Object...
object oPC = GetLocalObject(oMe, "PC_2_B_EFFECTED");

int nEffect = GetLocalInt(oMe, "EFFECT_NUM");
int Parm1 = GetLocalInt(oMe, "PARAMETER_1");
int Parm2 = GetLocalInt(oMe, "PARAMETER_2");
int Parm3 = GetLocalInt(oMe, "PARAMETER_3");

int nVFX = GetLocalInt(oMe, "VFX_NUMBER");
float fDur = GetLocalFloat(oMe, "FLOAT_DURATION");

effect eEff, eVis;

switch(nEffect)
{
case 0: // Modify Attacks
{
eEff = EffectModifyAttacks(Parm1);
} break;

case 1: // Improved AC
{
eEff = EffectACIncrease(Parm1, Parm2, AC_VS_DAMAGE_TYPE_ALL);
} break;
case 2: // Improved AB
{
eEff = EffectAttackIncrease(Parm1, ATTACK_BONUS_MISC);
} break;
case 3: // Improved SR
{
eEff = EffectSpellResistanceIncrease(Parm1);
} break;
case 4: // Concealment
{
eEff = EffectConcealment(Parm1, MISS_CHANCE_TYPE_NORMAL);
} break;
case 5: // Regeneration / 3 Second or More
{
if(fDur < 3.0)
{ fDur = 3.0; } // Minimum is ever 3 seconds! (Or 2 X per round)
eEff = EffectRegenerate(Parm1, fDur);
} break;
case 6: // Skill Bonus
{
eEff = EffectSkillIncrease(Parm1, Parm2);
} break;
case 7: // EffectDamageShield
{
eEff = EffectDamageShield(Parm1, Parm2, Parm3);
} break;
case 8: // Saving Throw Increase
{
eEff = EffectSavingThrowIncrease(Parm1, Parm2, Parm3);
} break;
case 9: // Temporary Hitpoints
{
eEff = EffectTemporaryHitpoints(Parm1);
} break;
case 10: // Padding..
{

} break;
case 11: // Padding..
{

} break;
}

//Apply the Effect
eEff = SupernaturalEffect(eEff); // NOT Dispellable!
ApplyEffectToObject(DURATION_TYPE_PERMANENT, eEff, oPC, 0.0);

//Apply the VFX if one exist...
if(nVFX >= 1)
{
eVis = EffectVisualEffect(nVFX, FALSE);
ApplyEffectToObject(DURATION_TYPE_PERMANENT, eVis, oPC, 0.0);
}

//Main Script End
}

#21
_Guile

_Guile
  • Members
  • 685 messages
Any critique on the above script? (note the date is off, doh!)

#22
WhiZard

WhiZard
  • Members
  • 1 204 messages

ffbj wrote...

Just for consistency I would define oEquippedBy as oPC, as you did in the unequipped portion.
Make sure the object eff_creator actually exists, in the toolset.
It appears the effect creator was done correctly.
AssignCommand(oEC, ApplyEffectToObject(
DURATION_TYPE_PERMANENT, eMas, oEquippedBy));


The effect creator was not done properly.  The creator of an effect is the object running the script when the effect is declared.  Since eMas was declared on the main script means that eMas is not created by oEC.  If he instead put

AssignCommand(oEC, ApplyEffectToObject(
DURATION_TYPE_PERMANENT, EffectModifyAttacks(1), oEquippedBy));

then the effect would be declared within an assigned command and oEC would be the creator.

#23
FunkySwerve

FunkySwerve
  • Members
  • 1 308 messages

WhiZard wrote...
AssignCommand(oEC, ApplyEffectToObject(
DURATION_TYPE_PERMANENT, EffectModifyAttacks(1), oEquippedBy));

then the effect would be declared within an assigned command and oEC would be the creator.


Your example is better than mine. It points out that it's not even really the declaration that matters, so much as it is the creation of the effect struct - you can have an effect creator without an explicit declaration, as in your example.

Funky

#24
_Guile

_Guile
  • Members
  • 685 messages
OK Thanks again for the help, I got the script working by setting the function within the ApplyCommand, function like you showed above Whizard, and it worked, thanks again!


AssignCommand(oEC, ApplyEffectToObject(
DURATION_TYPE_PERMANENT, EffectModifyAttacks(1), oEquippedBy));

Modifié par _Guile, 01 mai 2013 - 04:23 .


#25
ffbj

ffbj
  • Members
  • 593 messages
Yeah, that is why I said it appeared correct. So all you do is not define eMas, and just put the effect within the creation line. The script itself was a little Funky since it is not structured the way I do these type of scripts.