Verse Library verse

01 Fragment

Defines a data structure for NPC healing parameters and frame-based update logic to scan and treat players.

verse-library/create-your-own-npc-medic-in-unreal-editor-for-fortnite/01-fragment.verse

// This is the main script for our NPC Medic.
// 'struct' defines the shape of our NPC's data.
// Think of this like a character sheet in a tabletop RPG.
struct MedicBehavior : NPC_Behavior {
    // 'variable' is a container for data that changes.
    // 'heal_amount' is how much HP we give (like a Medkit restoring 50 HP).
    heal_amount: float = 50.0
    
    // 'threshold' is the health level below which we start healing.
    // If a player has less than this, they are a candidate.
    heal_threshold: float = 50.0
    
    // 'scan_interval' is how often we check for patients (in seconds).
    // Like the cooldown on a special ability.
    scan_interval: float = 1.0
    
    // 'next_scan_time' tracks when we should look again.
    next_scan_time: float = 0.0
    
    // 'target' is who we are currently healing.
    // 'null' means we aren't currently focused on anyone.
    target: Entity = null
    
    // This is the main entry point. The game calls this when the NPC spawns.
    Initialize() -> void {
        // Start scanning immediately.
        next_scan_time = 0.0
    }
    
    // 'event' is something that happens. 'OnUpdate' happens every frame.

Sign in free to read the full source 🌴

This Verse Library file is members-only. Create a free account to view the complete source and download the .verse file.

Sign in with Discord

Comments

    Sign in to vote, comment, or suggest an edit. Sign in