Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //::///////////////////////////////////////////////
- //:: v2_trg_en_brambl
- //:://////////////////////////////////////////////
- /*
- intended for use in a trigger's onenter event
- which slows the creature as they lumber through the undergrowth.
- */
- //:://////////////////////////////////////////////
- //:: Created: The Magus (2012 mar 4)
- //:://////////////////////////////////////////////
- //:: Modified: Henesua (2013 dec 7) updating for vives
- #include "v2_inc_constants"
- #include "v2_inc_creatures"
- #include "v2_inc_spell"
- void main()
- {
- object oCreature = GetEnteringObject();
- // avoidance
- if( !GetIsObjectValid(oCreature)
- || GetIsFlying(oCreature) // if already flying... return
- || GetIsDM(oCreature)
- )
- return;
- string sSnd = "as_na_grassmove1";
- int bGrass = GetLocalInt(OBJECT_SELF, "GRASS");
- int nStealth = GetStealthMode(oCreature);
- int bImmune;
- int bIncorp = GetLocalInt(oCreature,"X2_L_IS_INCORPOREAL");
- // immunity
- if( GetHasSpellEffect(SPELL_FREEDOM_OF_MOVEMENT, oCreature)
- || GetHasFeat(FEAT_WOODLAND_STRIDE, oCreature)
- || GetHasSpellEffect(SPELL_STEADY_STRIDE, oCreature)
- || bIncorp
- )
- {
- bImmune = TRUE;
- }
- int nSize = GetCreatureSize(oCreature);
- int nSlow = 50;
- int nRace = GetRacialType(oCreature);
- int nConceal, nHide, nMissChance;
- switch (nSize)
- {
- case CREATURE_SIZE_TINY:
- bImmune = TRUE;
- nConceal = 50;
- nMissChance = MISS_CHANCE_TYPE_NORMAL;
- nHide = 127;
- break;
- case CREATURE_SIZE_SMALL:
- if( nRace==RACIAL_TYPE_ANIMAL
- || nRace==RACIAL_TYPE_BEAST
- || nRace==RACIAL_TYPE_MAGICAL_BEAST
- )
- bImmune=TRUE;
- nSlow -= 25;
- nConceal = 30;
- nMissChance = MISS_CHANCE_TYPE_VS_RANGED;
- nHide = 4;
- break;
- case CREATURE_SIZE_MEDIUM:
- nConceal = 15;
- nMissChance = MISS_CHANCE_TYPE_VS_RANGED;
- nHide = 2;
- break;
- case CREATURE_SIZE_LARGE:
- nSlow += 10;
- break;
- case CREATURE_SIZE_HUGE:
- nSlow -= 25;
- break;
- default:
- break;
- }
- // TALL GRASS - Move more quickly than through brambles
- if(bGrass)
- nSlow -= 20;
- // strength perk
- nSlow += GetAbilityModifier(ABILITY_STRENGTH, oCreature)*-2;
- // escape artist perk
- if((d20()+GetSkillRank(SKILL_ESCAPE_ARTIST, oCreature)-GetArmorCheckPenalty(oCreature))>=20)
- nSlow = FloatToInt(nSlow/2.0);
- if (nSlow < 1)
- nSlow = 0;
- else if (nSlow > 99)
- nSlow = 99;
- int nPenalty;
- if (nSlow >79)
- {
- nPenalty= 5;
- }
- else if (nSlow > 59)
- {
- nPenalty= 4;
- }
- else if (nSlow > 39)
- {
- nPenalty= 3;
- }
- else if (nSlow > 19)
- {
- nPenalty= 2;
- }
- else if (nSlow > 0)
- {
- nPenalty= 1;
- }
- if(!bGrass)
- {
- switch(d4())
- {
- case 4: sSnd = "as_na_leafmove1"; break;
- case 3: sSnd = "as_na_leafmove2"; break;
- case 2: sSnd = "as_na_leafmove3"; break;
- case 1: sSnd = "as_na_bushmove1"; break;
- default: sSnd = "as_na_bushmove2"; break;
- }
- }
- else
- {
- switch(d2())
- {
- case 2: sSnd = "as_na_grassmove2"; break;
- case 1: sSnd = "as_na_grassmove1"; break;
- default: sSnd = "as_na_grassmove1"; break;
- }
- }
- effect eSlow = EffectMovementSpeedDecrease(nSlow);
- effect eHampered= EffectLinkEffects(EffectSavingThrowDecrease(SAVING_THROW_REFLEX, nPenalty), EffectACDecrease(nPenalty));
- effect eLink;
- effect eConceal = EffectLinkEffects(EffectConcealment(nConceal, nMissChance),EffectSkillIncrease(SKILL_HIDE, nHide));
- if (nPenalty > 0)
- eLink=EffectLinkEffects(eHampered,eSlow);
- else
- eLink = eSlow;
- if(nStealth!=STEALTH_MODE_ACTIVATED && !bIncorp)
- {
- float fDelay;
- object oSound = GetLocalObject(OBJECT_SELF, "SOUND_OBJECT");
- if(!GetIsObjectValid(oSound))
- {
- fDelay = 0.1;
- oSound = CreateObject(OBJECT_TYPE_PLACEABLE, "sound_player", GetLocation(OBJECT_SELF));
- SetLocalObject(OBJECT_SELF, "SOUND_OBJECT", oSound);
- }
- DelayCommand(fDelay, AssignCommand(oSound, PlaySound(sSnd) ) );
- //AssignCommand(oCreature, PlaySound(sSnd) );
- //PlaySound(sSnd);
- }
- if(!bImmune)
- ApplyEffectToObject(DURATION_TYPE_PERMANENT, eLink, oCreature);
- if(nConceal)
- ApplyEffectToObject(DURATION_TYPE_PERMANENT, eConceal, oCreature);
- SetLocalInt(oCreature, "BRAMBLE", TRUE);
- }
Advertisement
Add Comment
Please, Sign In to add comment