#include "jump_include"
#include "jump_inc_pattern"

void main()
{
    float fDelay = 1.0;
    int bTurnToTarget = TRUE;
    
    // Check if the jumper can be activated.
    if (ActivateJumper(fDelay, bTurnToTarget))
    {
        // Apply a lightning effect to the jumping character.
        ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectVisualEffect(1790), oPC);
        
        int iInterval = 15;
        int iEffect = 253;
        
        // Trail effect for the jumping character.
        Jump_JumperTrail(iInterval, iEffect, fDelay = 0.05);
        
        // NPC spawning logic
        string sNPCResRef = "cas_raccoon"; // Replace with the resref of the NPC to spawn
        int iNPCCount = 3; // Number of NPCs to spawn
        int i; // Loop variable defined outside the loop

        location lPlayerLocation = GetLocation(oPC); // Get player's current location

        for (i = 0; i < iNPCCount; i++)
        {
            // Spawn NPC at the player's location
            object oNPC = CreateObject(OBJECT_TYPE_CREATURE, sNPCResRef, lPlayerLocation);
            
            // Apply a visual effect to the spawned NPC
            ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectVisualEffect(473), oNPC);
            
            // Command NPC to move to the target location
            AssignCommand(oNPC, ActionMoveToLocation(lTarget));
            
            // Delay deletion of the NPC after it reaches the target location
            DelayCommand(fDelay + GetDistanceBetweenLocations(GetLocation(oNPC), lTarget) / 5.0, DestroyObject(oNPC));
        }

        // Apply a visual effect at the destination location after the jump.
        DelayCommand(fDelay, ApplyEffectAtLocation(DURATION_TYPE_INSTANT, EffectVisualEffect(473), lTarget));

        // Optional: Additional visual effects or gameplay logic can be added here.
    }
}
