|
|
发表于 2007-10-26 21:18:42
|
显示全部楼层
高级飞弹风暴的完整脚本
//::///////////////////////////////////////////////
//:: Isaacs Greater Missile Storm
//:: x0_s0_MissStorm2
//:: Copyright (c) 2002 Bioware Corp.
//:://////////////////////////////////////////////
/*
Up to 20 missiles, each doing 3d6 damage to each
target in area.
*/
//:://////////////////////////////////////////////
//:: Created By: Brent
//:: Created On: July 31, 2002
//:://////////////////////////////////////////////
//:: Last Updated By:
// ChazM 10/19/06 - modified params to DoMissileStorm()
#include "X0_I0_SPELLS"
#include "x2_inc_spellhook"
void main()
{
if (!X2PreSpellCastCode())
{
// If code within the PreSpellCastHook (i.e. UMD) reports FALSE, do not run this spell
return;
}
DoMissileStorm(2, 20, SPELL_ISAACS_GREATER_MISSILE_STORM, VFX_IMP_MAGBLUE, DAMAGE_TYPE_MAGICAL, -1, 10); //这行中的20就是飞弹数量上限。
}
以下是上面法术脚本引用的"DoMissileStorm"函数内容
//::///////////////////////////////////////////////
//:: DoMissileStorm
//:: Copyright (c) 2002 Bioware Corp.
//:://////////////////////////////////////////////
/*
Fires a volley of missiles around the area
of the object selected.
Each missiles (nD6Dice)d6 damage.
There are casterlevel missiles (to a cap as specified)
*/
//:://////////////////////////////////////////////
//:: Created By: Brent
//:: Created On: July 31, 2002
//:://////////////////////////////////////////////
//:: Modified March 14 2003: Removed the option to hurt chests/doors
//:: was potentially causing bugs when no creature targets available.
//::
//:: Brock Heinz - OEI - 08/15/05 - Limit hits per target
//:: This function now limits the number of hits done to any
//:: creature to no more than nMaxHits each
//::
//:: AFW-OEI 06/06/2006:
//:: Changed to target only enemies.
// int nD6Dice - Dice of damage (d6) each missile does
// int nCap - The max number of missiles that can be fired
// int nSpell - Spell id
// int nVIS - Visual impact effect to use
// int nDamageType - type of damage
// int iReflexSaveType - A SAVING_THROW_TYPE_* constant, or -1 if no reflex save allowed.
// int nMaxHits - Maximum number of hits any one target.
void DoMissileStorm(int nD6Dice, int nCap, int nSpell, int nVIS = VFX_IMP_MAGBLUE, int nDamageType = DAMAGE_TYPE_MAGICAL, int iReflexSaveType = -1, int nMaxHits = 10 )
{
//SpawnScriptDebugger();
location lTargetLoc = GetSpellTargetLocation(); // missile spread centered around target location
location lSourceLoc = GetLocation( OBJECT_SELF );
int nSpellID = GetSpellId();
int nMetaMagic = GetMetaMagicFeat();
effect eVis = EffectVisualEffect(nVIS);
float fDelay = 0.0;
int nMissiles = GetCappedCasterLevel(nCap);
int nPathType = PROJECTILE_PATH_TYPE_BURST;
int nEnemies = CountEnemies(lTargetLoc, RADIUS_SIZE_GARGANTUAN, nMissiles); // how many enemies (up to max number of missiles)
// * Exit if no enemies to hit
if (nEnemies == 0)
return;
// divide the missles evenly amongst the enemies;
int nMissilesPerTarget = nMissiles / nEnemies;
int nExtraMissiles = nMissiles % nEnemies;
int nMissilesForThisTarget = 0;
location lThisTargetLoc;
int nCnt = 1; // # of enemies processed
//Cycle through the targets within the spell shape until an invalid object is captured.
object oTarget = GetFirstObjectInShape(SHAPE_SPHERE, RADIUS_SIZE_GARGANTUAN, lTargetLoc, TRUE, OBJECT_TYPE_CREATURE);
while (GetIsObjectValid(oTarget) && nCnt <= nEnemies)
{
// * caster cannot be harmed by this spell
if (spellsIsTarget(oTarget, SPELL_TARGET_SELECTIVEHOSTILE, OBJECT_SELF) && (oTarget != OBJECT_SELF) && (GetObjectSeen(oTarget,OBJECT_SELF)))
{
lThisTargetLoc = GetLocation( oTarget );
fDelay = GetProjectileTravelTime( lSourceLoc, lThisTargetLoc, nPathType );
//Fire cast spell at event for the specified target
SignalEvent(oTarget, EventSpellCastAt(OBJECT_SELF, nSpell));
// * determine the number of missles to fire at this target
nMissilesForThisTarget = nMissilesPerTarget;
if (nCnt <= nExtraMissiles)
nMissilesForThisTarget++;
// ensure we observe cap
nMissilesForThisTarget = GetIntInRange(nMissilesForThisTarget, 0, nMaxHits);
ShootMissilesAtTarget(oTarget, lSourceLoc, lThisTargetLoc, nSpell, nPathType,
nMissilesForThisTarget, eVis, fDelay, nCnt,
nD6Dice, nDamageType, nMetaMagic, iReflexSaveType);
nCnt++;// * increment count of enemies processed
}
oTarget = GetNextObjectInShape(SHAPE_SPHERE, RADIUS_SIZE_GARGANTUAN, lTargetLoc, TRUE, OBJECT_TYPE_CREATURE);
}
}
上面脚本中出现的ShootMissilesAtTarget函数,里面决定了,飞弹需要过魔抗检定。
void ShootMissilesAtTarget(object oTarget, location lSourceLoc, location lTargetLoc, int nSpell, int nPathType,
int nMissilesForThisTarget, effect eVis, float fDelay, int nCnt,
int nD6Dice, int nDamageType, int nMetaMagic, int iReflexSaveType)
{
float fTime = fDelay + ((nCnt - 1) * 0.25);
float fTime2 = ((nCnt - 1) * 0.25);
effect eDam;
int nDam;
int i;
//--------------------------------------------------------------
// GZ: Moved SR check out of loop to have 1 check per target
// not one check per missile, which would rip spell mantels
// apart
//--------------------------------------------------------------
for (i=1; i <= nMissilesForThisTarget; i++)
{
// Don't apply damage if target successfully resists
if (!MyResistSpell(OBJECT_SELF, oTarget, fDelay))
{
//Roll damage
nDam = RollMissileDamage(oTarget, nD6Dice, nMetaMagic, iReflexSaveType);
//Set damage effect
eDam = EffectDamage(nDam, nDamageType);
eDam = EffectLinkEffects( eDam, eVis );
DelayCommand(fTime, ApplyEffectToObject(DURATION_TYPE_INSTANT, eDam, oTarget));
}
// always show the attempted effect visually
DelayCommand( fTime2, SpawnSpellProjectile(OBJECT_SELF, oTarget, lSourceLoc, lTargetLoc, nSpell, nPathType) );
}
} |
|