The code I'm working with:
void main()
{
event ev = GetCurrentEvent();
int nEventType = GetEventType(ev); // CAST (directly from engine) or COMMAND_PENDING (re-directed by rules_core)
switch(nEventType)
{
case EVENT_TYPE_SPELLSCRIPT_PENDING:
{
// Get a structure with the event parameters
struct EventSpellScriptCastStruct stEvent = Events_GetEventSpellScriptCastParameters(ev);
Log_Trace(LOG_CHANNEL_COMBAT_ABILITY, GetCurrentScriptName() + ".EVENT_TYPE_SPELLSCRIPT_PENDING", Log_GetAbilityNameById(stEvent.nAbility));
// Setting Return Value
Ability_SetSpellscriptPendingEventResult(COMMAND_RESULT_SUCCESS);
break;
}
case EVENT_TYPE_SPELLSCRIPT_CAST:
{
// Get a structure with the event parameters
struct EventSpellScriptCastStruct stEvent = Events_GetEventSpellScriptCastParameters(ev);
Log_Trace(LOG_CHANNEL_COMBAT_ABILITY, GetCurrentScriptName() + ".EVENT_TYPE_SPELLSCRIPT_CAST",Log_GetAbilityNameById(stEvent.nAbility));
// hand this through to cast_impact
SetAbilityResult(stEvent.oCaster, stEvent.nResistanceCheckResult);
break;
}
case EVENT_TYPE_SPELLSCRIPT_IMPACT:
{
// Get a structure with the event parameters
struct EventSpellScriptImpactStruct stEvent = Events_GetEventSpellScriptImpactParameters(ev);
Log_Trace(LOG_CHANNEL_COMBAT_ABILITY, GetCurrentScriptName() + ".EVENT_TYPE_SPELLSCRIPT_IMPACT",Log_GetAbilityNameById(stEvent.nAbility));
// AbiAoEImpact(stEvent.lTarget, stEvent.oCaster, stEvent.nAbility);
//_ApplyImpactDamageAndEffects(stEvent);
// only work for sphere spells
int nAoEType = GetM2DAInt(TABLE_ABILITIES_SPELLS, "aoe_type", stEvent.nAbility);
if (nAoEType == 1)
{
// location impact vfx
if (stEvent.oTarget != OBJECT_INVALID)
{
stEvent.lTarget = GetLocation(stEvent.oTarget);
}
Ability_ApplyLocationImpactVFX(stEvent.nAbility, stEvent.lTarget);
float fRadius = GetM2DAFloat(TABLE_ABILITIES_SPELLS, "aoe_param1", stEvent.nAbility);
// get objects in area of effect
object[] oTargets = GetObjectsInShape(OBJECT_TYPE_CREATURE, SHAPE_SPHERE, stEvent.lTarget, fRadius);
// cycle through objects
int nCount = 0;
int nMax = Min(GetArraySize(oTargets), MAX_AOE_TARGETS);
for (nCount = 0; nCount < nMax; nCount++)
{
// per-spell effects
SetIndividualImpactAOEEvent(stEvent.oCaster,oTargets[nCount],stEvent.nAbility,stEvent.lTarget);
event evCustom = Event(EVENT_TYPE_CUSTOM_EVENT_03);
DelayEvent(0.5, stEvent.oCaster, evCustom);
}
}
break;
}
case EVENT_TYPE_SPELLSCRIPT_INDIVIDUAL_IMPACT:
{
struct EventSpellScriptImpactStruct stEvent;
stEvent.nAbility = GetEventInteger(ev,0);
stEvent.oCaster = GetEventObject(ev, 0);
stEvent.lTarget = Location(GetEventObject(ev,2),Vector(GetEventFloat(ev,0),GetEventFloat(ev,1),GetEventFloat(ev,2)), 0.0f);
//_ApplySpellEffects(stEvent,GetEventObject(ev,1));
object oTarget = GetEventObject(ev,1);
//event evCustom = Event(EVENT_TYPE_CUSTOM_EVENT_03);
//DelayEvent(2.0, oTarget, evCustom);
// if not the caster
if (oTarget != stEvent.oCaster)
{
// if the target is not dead
if (IsDead(oTarget) == FALSE && IsObjectHostile(stEvent.oCaster, oTarget) )
{
location lTargetLoc = GetLocation(oTarget);
command cJump = CommandJumpToLocation(lTargetLoc);
AddCommand(stEvent.oCaster, cJump);
ApplyEffectVisualEffect(stEvent.oCaster, stEvent.oCaster, 90084, EFFECT_DURATION_TYPE_INSTANT, 0.0, stEvent.nAbility);
// main hand
object oWeapon = GetItemInEquipSlot(INVENTORY_SLOT_MAIN, stEvent.oCaster);
// if the attack hits
int nResult = Combat_GetAttackResult(stEvent.oCaster, oTarget, oWeapon, 0.0f, stEvent.nAbility);
if (IsCombatHit(nResult) == TRUE)
{
// normal damage
float fDamage = Combat_Damage_GetAttackDamage(stEvent.oCaster, oTarget, oWeapon, nResult, 0.0);
eEffect = EffectImpact(fDamage, oWeapon,0,stEvent.nAbility);
Combat_HandleAttackImpact(stEvent.oCaster, oTarget, nResult, eEffect);
}
// off hand
oWeapon = GetItemInEquipSlot(INVENTORY_SLOT_OFFHAND, stEvent.oCaster);
// if the attack hits
nResult = Combat_GetAttackResult(stEvent.oCaster, oTarget, oWeapon, 0.0f, stEvent.nAbility);
if (IsCombatHit(nResult) == TRUE)
{
// normal damage
float fDamage = Combat_Damage_GetAttackDamage(stEvent.oCaster, oTarget, oWeapon, nResult, 0.0);
eEffect = EffectImpact(fDamage, oWeapon,0,stEvent.nAbility);
Combat_HandleAttackImpact(stEvent.oCaster, oTarget, nResult, eEffect);
}
//DelayEvent(0.5f, OBJECT_SELF, ev);
}
}
}
}
}
Modifié par Sakaslan, 18 août 2010 - 03:03 .





Retour en haut






