Пример #1
0
    // Give the critter an effect object with the appropriate effect.

    public static void applyStenchEffect(int casterId, int spell_id, GameObject critter, int status)
    {
        var stench_obj = getStenchObj(critter);

        if ((stench_obj != null))
        {
            if ((status == STATE_NAUSEA))
            {
                // Check current stench effect.
                var effectOwnerId = Co8.getObjVarNibble(stench_obj, EFFECT_VAR, CID);
                var effectStatus  = Co8.getObjVarNibble(stench_obj, EFFECT_VAR, effectOwnerId);
                if ((effectStatus == STATE_SICKNESS))
                {
                    // Take ownership of effect since Nausea trumps Sickness.
                    Logger.Info("caster {0} taking ownership of effect from caster {1} on {2}", casterId, effectOwnerId, critter);
                    var effectVar = Co8.getObjVarDWord(stench_obj, EFFECT_VAR);
                    stench_obj.Destroy();
                    stench_obj = createStenchObject(spell_id, critter, status);
                    Co8.setObjVarDWord(stench_obj, EFFECT_VAR, effectVar);
                }
            }
        }
        else
        {
            stench_obj = createStenchObject(spell_id, critter, status);
        }

        // Set the status & id into the effect var.
        Co8.setObjVarNibble(stench_obj, EFFECT_VAR, CID, casterId);
        Co8.setObjVarNibble(stench_obj, EFFECT_VAR, casterId, status);
        return;
    }
Пример #2
0
    public static void removeStenchEffect(int casterId, int spell_id, GameObject critter, int status, bool unNullify)
    {
        var stench_obj = getStenchObj(critter);

        if ((stench_obj != null))
        {
            Logger.Info("removing effect {0} for {1} by caster {2}", stench_obj, critter, casterId);
            Co8.setObjVarNibble(stench_obj, EFFECT_VAR, casterId, status);
            // Check current stench effect.
            var effectOwnerId = Co8.getObjVarNibble(stench_obj, EFFECT_VAR, CID);
            if ((casterId == effectOwnerId))
            {
                // Pass ownership of effect to another stench.
                int s = 0;
                int otherId;
                for (otherId = BASECASTERID; otherId < 7; otherId++)
                {
                    s = Co8.getObjVarNibble(stench_obj, EFFECT_VAR, otherId);
                    if (s == STATE_NAUSEA || s == STATE_NAUSEA_HANGOVER)
                    {
                        break;
                        // Nausea trumps Sickness.
                    }
                }

                var effectVar = Co8.getObjVarDWord(stench_obj, EFFECT_VAR);
                stench_obj.Destroy();
                if (s == STATE_NAUSEA || s == STATE_NAUSEA_HANGOVER || s == STATE_SICKNESS)
                {
                    Logger.Info("caster {0} taking ownership of effect from caster {1} on {2}", otherId, casterId, critter);
                    stench_obj = createStenchObject(spell_id, critter, s);
                    Co8.setObjVarDWord(stench_obj, EFFECT_VAR, effectVar);
                    Co8.setObjVarNibble(stench_obj, EFFECT_VAR, CID, otherId);
                }

                if (s != STATE_NAUSEA && s != STATE_NAUSEA_HANGOVER && unNullify)
                {
                    reenableWeapons(critter);
                }
            }
        }
        else
        {
            reenableWeapons(critter);
        }

        return;
    }