Aller au contenu

Photo

Effects


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

#26
Lightfoot8

Lightfoot8
  • Members
  • 2 535 messages
@henesua open up x2_inc_itemprop and you will see that IPSafeAddItemProperty is just a wrapper around AddItemProperty to control how it is added.

#27
Knight_Shield

Knight_Shield
  • Members
  • 444 messages
I know its been awhile in this but if you guys could look at how I added haste.



#include "zep_inc_phenos"
#include "x2_inc_switches"
void main()
{
int nEvent = GetUserDefinedItemEventNumber();
if (nEvent != X2_ITEM_EVENT_ACTIVATE) return;

effect eEffect;
eEffect = EffectHaste();
object oPC = GetItemActivator();
int nMount = nCEP_PH_HORSE_BLACK;
int iMounted = GetLocalInt(oPC, "Mounted");

if (iMounted == 0)
{
zep_Mount(oPC, OBJECT_INVALID, nMount);
SetLocalInt(oPC, "Mounted", 1);
ApplyEffectToObject(DURATION_TYPE_PERMANENT,eEffect,oPC);
}

else
{
zep_Dismount(oPC);
SetLocalInt(oPC, "Mounted", 0);
if (GetEffectType(eEffect)==EFFECT_TYPE_HASTE) RemoveEffect(oPC, eEffect);
eEffect = GetNextEffect(oPC);
}
}

Modifié par Knight_Shield, 02 septembre 2013 - 09:02 .


#28
Shadooow

Shadooow
  • Members
  • 4 468 messages
first this line: if (GetEffectType(eEffect)==EFFECT_TYPE_HASTE) will be always true, you just defined the effect as EffectHaste

second this cannot work, or does it work? - to be able to remove effect this way you have to pass the effect variable some way between scripts - like i did in a example few posts back, in your situation, you have to loop all effects and remove haste effect - which will be a problem since it can remove other haste effects the player might have - either make the effect supernatural/extraordinary (which probably should be anyway) and check the duration permanent subtype extra/super or use the item as a creator (remember you cannot define the effect in script but must be in the assigncommand line then) and then check effects for creator of item tag

#29
GhostOfGod

GhostOfGod
  • Members
  • 863 messages
I might be a little late but something like so perhaps?:


#include "zep_inc_phenos"
#include "x2_inc_switches"
void main()
{
       int nEvent = GetUserDefinedItemEventNumber();
       if (nEvent != X2_ITEM_EVENT_ACTIVATE) return;

       effect eEffect;
       object oPC = GetItemActivator();
       object oItem = GetItemActivated();
       int nMount = nCEP_PH_HORSE_BLACK;
       int iMounted = GetLocalInt(oPC, "Mounted");

       if (iMounted == 0)
        {
              zep_Mount(oPC, OBJECT_INVALID, nMount);
              SetLocalInt(oPC, "Mounted", 1);
              AssignCommand(oItem, ApplyEffectToObject(DURATION_TYPE_PERMANENT,EffectHaste(),oPC));
        }

       else
        {
              zep_Dismount(oPC);
              SetLocalInt(oPC, "Mounted", 0);
              eEffect = GetFirstEffect(oPC);
              while (GetIsEffectValid(eEffect))
                {
                     if (GetEffectCreator(eEffect)==oItem)
                     RemoveEffect(oPC, eEffect);
                     eEffect = GetNextEffect(oPC);
                }
        }
}

Modifié par GhostOfGod, 07 septembre 2013 - 11:17 .


#30
Knight_Shield

Knight_Shield
  • Members
  • 444 messages
Works great.
I have one more question.
How can I force them to dismount and remove effect?

void main()
{

object oPC = GetEnteringObject();

if (!GetIsPC(oPC)) return;

if (GetLocalInt(oPC, "Mounted")== 1)
{

//force dismount//
zep_Dismount(oPC);
SetLocalInt(oPC, "Mounted", 0);
}
}

#31
GhostOfGod

GhostOfGod
  • Members
  • 863 messages
That's where it can get a little tricky. If you have more than one item that can summon a horse then you might want some other object in your mod create the haste effect when people summon/mount a horse. You could also use an area or the mod itself but then you run into problems with removing the wrong effects if the mod was assigned to create other effects. Either way you need to either "get" the item used or "get" the object in mod used to create the effect.

Let's say you have more than one mounting item and want to use an in game object to be the creator of your mounted haste effect. This could be anything from a fence post to an NPC. I usually use some small object in an inaccessable DM area or what not. So instead of the example script I posted above (which has the activated item create the effect) you would do something more like so (which uses an in game object as the effect creator):

#include "zep_inc_phenos"
#include "x2_inc_switches"
void main()
{
       int nEvent = GetUserDefinedItemEventNumber();
       if (nEvent != X2_ITEM_EVENT_ACTIVATE) return;

       effect eEffect;
       object oPC = GetItemActivator();
       object oEffectCreator = GetObjectByTag("HORSE_HASTE");
       int nMount = nCEP_PH_HORSE_BLACK;
       int iMounted = GetLocalInt(oPC, "Mounted");

       if (iMounted == 0)
        {
              zep_Mount(oPC, OBJECT_INVALID, nMount);
              SetLocalInt(oPC, "Mounted", 1);
              AssignCommand(oEffectCreator, ApplyEffectToObject(DURATION_TYPE_PERMANENT,EffectHaste(),oPC));
        }

       else
        {
              zep_Dismount(oPC);
              SetLocalInt(oPC, "Mounted", 0);
              eEffect = GetFirstEffect(oPC);
              while (GetIsEffectValid(eEffect))
                {
                     if (GetEffectCreator(eEffect)==oEffectCreator)
                     RemoveEffect(oPC, eEffect);
                     eEffect = GetNextEffect(oPC);
                }
        }
}

Then you could force dismount and remove the effect like so:

void main()
{

    object oPC = GetEnteringObject();

    if (!GetIsPC(oPC)) return;

    if (GetLocalInt(oPC, "Mounted")== 1)
    {
         object oEffectCreator = GetObjectByTag("HORSE_HASTE");
         //force dismount//
         zep_Dismount(oPC);
         SetLocalInt(oPC, "Mounted", 0);
         effect eEffect = GetFirstEffect(oPC);
         while (GetIsEffectValid(eEffect))
        {
            if (GetEffectCreator(eEffect)==oEffectCreator)
            RemoveEffect(oPC, eEffect);
            eEffect = GetNextEffect(oPC);
         }
     }
}


Now if you just want to force dismount and remove the effect based on the item that was activated then you have to get the specific item (you could also do a loop to check againts multiple items to see of any of them are the creator of the haste effect). So you could do something like so:

void main()
{

    object oPC = GetEnteringObject();

    if (!GetIsPC(oPC)) return;

    if (GetLocalInt(oPC, "Mounted")== 1)
    {
         object oItem = GetItemPossessedBy(oPC, "Tag of item");
         //force dismount//
         zep_Dismount(oPC);
         SetLocalInt(oPC, "Mounted", 0);
         effect eEffect = GetFirstEffect(oPC);
         while (GetIsEffectValid(eEffect))
        {
            if (GetEffectCreator(eEffect)==oItem)
            RemoveEffect(oPC, eEffect);
            eEffect = GetNextEffect(oPC);
         }
     }
}

Hope this helps.
P.S. I typed all the script here in the reply so there could be some mistypes or what not. I haven't tried compiling or anything.

#32
Knight_Shield

Knight_Shield
  • Members
  • 444 messages
Everything compiled so will test this .

#33
ffbj

ffbj
  • Members
  • 593 messages
You can also just remove in mount transversal which is the standard hb check for mounted-ness. Or rather the condition of being mounted, and then simply remove it (haste).
The reason this approach might be preferable is that it is a blanket removal of haste by whatever method..mass haste, item..whatever.  So it removes the possibility of a mounted PC being hasted, which to my way of thinking is not necessarily a bad thing.

Modifié par ffbj, 12 septembre 2013 - 02:46 .