Skip to content

Clean up Skin?

I've given the PC the penalty of level draining 1d4 levels. off of his skin. Now I want to "clean" his skin. How do I go about deleting or cleaning up his skin and removing all effects from it?
#include "x3_inc_skin"
void main()
{

    object oPC = GetEnteringObject();
    if (!GetIsPC(oPC)) return;

    int nOnce = GetLocalInt(OBJECT_SELF, GetTag(OBJECT_SELF));
    if (nOnce == TRUE)
    {
        return;
    }
    SetLocalInt(OBJECT_SELF, GetTag(OBJECT_SELF), TRUE);

        effect eNegativeFX;
        eNegativeFX = EffectVisualEffect(VFX_IMP_PULSE_NEGATIVE);
        effect eTrap;
        eTrap = EffectNegativeLevel(d4(), FALSE);
        effect eNegBurst;
        eNegBurst = EffectVisualEffect(VFX_FNF_LOS_EVIL_20);
        DelayCommand(0.5, ApplyEffectToObject(DURATION_TYPE_INSTANT, eNegBurst, oPC));
        ApplyEffectToObject(DURATION_TYPE_INSTANT, eNegativeFX, oPC);
        ApplyEffectToObject(DURATION_TYPE_INSTANT, eTrap, oPC);

        int nNeg = EFFECT_TYPE_NEGATIVELEVEL;
            if (nNeg == TRUE)
            {
                object oSkin;
                oSkin = SKIN_SupportGetSkin(oPC);
                SetTag(oSkin, "DELETE_SKIN");
                itemproperty ipAward;
                ipAward = ItemPropertyDamagePenalty(IP_CONST_ONHIT_LEVELDRAIN);
                AddItemProperty(DURATION_TYPE_PERMANENT, ipAward, oSkin);

                object oTarget;
                oTarget = oSkin;
                effect eEffect;

                while (GetIsEffectValid(eEffect))
                {
                if (GetEffectType(eEffect)==EFFECT_TYPE_NEGATIVELEVEL) DelayCommand(10.0, 		 
                RemoveEffect(oTarget, eEffect));
                eEffect = GetNextEffect(oTarget);
                }

            }

}

	



Comments

  • ForSeriousForSerious Member Posts: 466
    Known Bugs: "If you apply any temporary/permanent effect (for example, EffectSpellResistanceDecrease) as DURATION_TYPE_INSTANT, it can never be removed in any way whatsoever."
    Here's your coding lesson for the day:
    (And I mean it as a good way to learn)
    #include "x3_inc_skin"
    void main()
    {
        object oPC = GetEnteringObject();
        if (!GetIsPC(oPC)) return;
        int nOnce = GetLocalInt(OBJECT_SELF, GetTag(OBJECT_SELF));
        if (nOnce == TRUE)
        {
            return;
        }
        SetLocalInt(OBJECT_SELF, GetTag(OBJECT_SELF), TRUE);
            // Since it's not going to be given another value, you can define this in one line
            // effect eNegativeFX = EffectVisualEffect(VFX_IMP_PULSE_NEGATIVE);
            effect eNegativeFX;
            eNegativeFX = EffectVisualEffect(VFX_IMP_PULSE_NEGATIVE);
            effect eTrap;
            eTrap = EffectNegativeLevel(d4(), FALSE);
            effect eNegBurst;
            eNegBurst = EffectVisualEffect(VFX_FNF_LOS_EVIL_20);
            DelayCommand(0.5, ApplyEffectToObject(DURATION_TYPE_INSTANT, eNegBurst, oPC));
            ApplyEffectToObject(DURATION_TYPE_INSTANT, eNegativeFX, oPC);
            // Here's that bug. You can define how long you want it to last here.
            // If you want to manually remove it later, you can set it to permanent. 
            ApplyEffectToObject(DURATION_TYPE_INSTANT, eTrap, oPC);
    
            // I made all the below comments, then realized this is probably just pseudo code.
            // The real way to do it is to set the duration when you apply the effect, or tag the 
            // effect when you apply it as permanent, then remove it with another script—since
            // this script has a do once conditional in place. Continue reading for coding lessons.
    
            // Now we move into interestingness. nNeg gets defined as 61
            int nNeg = EFFECT_TYPE_NEGATIVELEVEL;
                // if 61 is equal to 1. That cannot happen. Everything within is unreachable code.
                if (nNeg == TRUE)
                {
                    object oSkin;
                    oSkin = SKIN_SupportGetSkin(oPC);
                    // This line makes me worry. I just don't know if the tag should be changed
                    // or if the skin is meant to be deleted regularly. It could break other systems.
                    SetTag(oSkin, "DELETE_SKIN");
                    itemproperty ipAward;
                    // 17 is out of the range of 1-5, it'll probably just default to 5.
                    // This property is meant for weapons. There's a bug mentioned for putting it on skins.
                    // By applying this to the skin, did you want to have enemies that hit them get effected?
                    // I have no idea if that's possible.
                    ipAward = ItemPropertyDamagePenalty(IP_CONST_ONHIT_LEVELDRAIN);
                    AddItemProperty(DURATION_TYPE_PERMANENT, ipAward, oSkin);
                    // This adds confusion, just stick with oSkin.
                    // If it helps, oSkin is a pointer reference to an object in memory. Let's say it's 5.
                    // oTarget gets made with a new pointer that points to a special slot in memory called the null pointer.
                    object oTarget;
                    // Now the pointer gets changed to 5. Both oTraget and oSkin point to memory slot 5.
                    oTarget = oSkin;
                    effect eEffect;
                    // eEffect points to that null pointer at this point.
                    // I'm sure you would have added eEffect = GetFirstEffect(oTarget);
                    // For this lesson about pointers, you can think of GetFirstEffect as finding the next available slot in memory
                    // and creating an object there. Then it returns the pointer to that memory slot.
                    while (GetIsEffectValid(eEffect))
                    {
                    // Here's a happy thought. You already have a pointer to the effect you're looking for: eTrap.
                    // But yes. If this were not the same script where eTrap got defined, you would not have it available.
                    // And this logic seems to be made with the idea of initiating the removal after an arbitrary amount of time.
                    if (GetEffectType(eEffect)==EFFECT_TYPE_NEGATIVELEVEL) DelayCommand(10.0, 		 
                    RemoveEffect(oTarget, eEffect));
                    eEffect = GetNextEffect(oTarget);
                    }
    
                }
    
    }
    
  • ZephiriusZephirius Member Posts: 419
    Thanks Serious... :) I will get to my lessons momentarily...
Sign In or Register to comment.