//::///////////////////////////////////////////////
//:: Name      Gaseous Form
//:: FileName  sp_gas_form.nss
//:://////////////////////////////////////////////
/*
Transmutate
Level:	Air 3, Brd 3, Sor/Wiz 3
Components:	S, M/DF
Casting Time:	1 standard action
Range:	Touch
Target:	Willing corporeal creature touched
Duration:	2 min./level (D)
Saving Throw:	None
Spell Resistance:	No
The subject and all its gear become insubstantial, misty, and translucent. Its material armor (including natural armor) becomes worthless, 
though its size, Dexterity, deflection bonuses, and armor bonuses from force effects still apply. The subject gains damage reduction 
10/magic and becomes immune to poison and critical hits. It can’t attack or cast spells with verbal, somatic, material, or focus 
components while in gaseous form. (This does not rule out the use of certain spells that the subject may have prepared using the 
feats Silent Spell, Still Spell, and Eschew Materials.) The subject also loses supernatural abilities while in gaseous form. If 
it has a touch spell ready to use, that spell is discharged harmlessly when the gaseous form spell takes effect.

A gaseous creature can’t run, but it can fly at a speed of 10 feet (maneuverability perfect). It can pass through small holes or 
narrow openings, even mere cracks, with all it was wearing or holding in its hands, as long as the spell persists. The creature 
is subject to the effects of wind, and it can’t enter water or other liquid. It also can’t manipulate objects or activate items, 
even those carried along with its gaseous form. Continuously active items remain active, though in some cases their effects may be moot.

Author:    Stratovarius
Created:   18/03/21
*/
//:://////////////////////////////////////////////
//:://////////////////////////////////////////////

#include "prc_inc_spells"

void main()
{
	object oPC = OBJECT_SELF;
	object oTarget = PRCGetSpellTargetObject();
	int nCasterLvl = PRCGetCasterLevel(oPC);
	float fDur = (120.0f * nCasterLvl);
	int nMetaMagic = PRCGetMetaMagicFeat();
	
	effect eDR = EffectDamageReduction(10, DAMAGE_POWER_PLUS_ONE);
	
	//placeholder VFX
	effect eVis = EffectVisualEffect(VFX_DUR_OBSCURING_MIST);
	
	//Spellhook
	if(!X2PreSpellCastCode()) return;
	
	PRCSetSchool(SPELL_SCHOOL_TRANSMUTATION);
	
	 //Meta Magic
	 if(nMetaMagic & METAMAGIC_EXTEND)
	 {
		 fDur = (fDur * 2);
	 }
	 
	 // Remove all material and natural armor bonuses
	 int nArmor = GetACBonus(GetItemInSlot(INVENTORY_SLOT_CHEST, oTarget));
	 int nShield = GetACBonus(GetItemInSlot(INVENTORY_SLOT_LEFTHAND, oTarget));
	 int nAmu = GetACBonus(GetItemInSlot(INVENTORY_SLOT_NECK, oTarget));
	 int nNat = GetACBonus(GetItemInSlot(INVENTORY_SLOT_CARMOUR, oTarget));
	 
	 //Link and Apply
	 effect eLink = EffectLinkEffects(eDR, eVis);
	        eLink = EffectLinkEffects(eLink, EffectImmunity(IMMUNITY_TYPE_POISON));
	        eLink = EffectLinkEffects(eLink, EffectImmunity(IMMUNITY_TYPE_CRITICAL_HIT));
	        eLink = EffectLinkEffects(eLink, EffectImmunity(IMMUNITY_TYPE_SNEAK_ATTACK));
	        eLink = EffectLinkEffects(eLink, EffectImmunity(IMMUNITY_TYPE_KNOCKDOWN));
	        eLink = EffectLinkEffects(eLink, EffectCutsceneGhost());
	        eLink = EffectLinkEffects(eLink, EffectACDecrease(nArmor+nShield+nAmu+nNat));
	 
	 SPApplyEffectToObject(DURATION_TYPE_TEMPORARY, eLink, oTarget, fDur);
	  
	 PRCSetSchool();
 }