# Forge Medical Module

## Overview
The Medical module provides a comprehensive medical system for the Forge client. It includes features for handling player health, death, respawn, medical costs, and inventory management during medical events.

## Dependencies
- forge_client_main

## Authors
- J. Schmidt
- Creedcoder
- IDSolutions

## Features

### Medical System
1. **Medical Initialization** (`fnc_initMedical.sqf`)
   - Initializes the medical system
   - Sets up stretcher detection and triggers
   - Configures medical service points
   - Manages occupancy tracking
   - Handles system variables

2. **Health Management**
   - **Heart Beat** (`fnc_heartBeat.sqf`)
     - Monitors player vital signs
     - Tracks medical costs
     - Manages respawn conditions
     - Handles payment verification
     - Controls spectator mode

   - **On Killed** (`fnc_onKilled.sqf`)
     - Handles player death events
     - Creates body bag
     - Saves dropped weapons
     - Manages inventory transfer
     - Triggers respawn process

   - **On Respawn** (`fnc_onRespawn.sqf`)
     - Manages player respawn process
     - Handles medical costs
     - Sets default loadout
     - Manages stretcher placement
     - Controls spectator mode
     - Processes payment verification

3. **Inventory Management**
   - **Move Inventory** (`fnc_moveInventory.sqf`)
     - Transfers player inventory to body bag
     - Handles all equipment types:
       - Headgear
       - Uniforms and items
       - Vests and contents
       - Backpacks and contents
       - Weapons and attachments
       - Magazines and ammo
       - Assigned items
       - Dropped equipment
     - Manages weapon holders
     - Preserves item condition

   - **Save Dropped Weapons** (`fnc_saveDroppedWeapons.sqf`)
     - Tracks dropped weapons
     - Manages weapon attachments
     - Preserves magazine data
     - Handles handgun equipment
     - Stores item information

4. **Medical Costs**
   - **Deduct Medical Cost** (`fnc_deductMedicalCost.sqf`)
     - Handles medical service payments
     - Manages account selection
     - Processes payment deduction
     - Provides payment feedback
     - Updates account balances

### Medical Features
1. **Stretcher System**
   - Automatic stretcher detection
   - Occupancy tracking
   - Position management
   - Respawn placement
   - Trigger-based activation

2. **Body Bag System**
   - Custom body bag class
   - Increased storage capacity
   - ACE dragging support
   - Inventory preservation
   - Equipment management

3. **Payment System**
   - Insurance deductible
   - Medical service costs
   - Account balance checking
   - Payment processing
   - Transaction feedback

## Event Handlers
The module uses several event handlers for initialization and execution:
- `XEH_preInit.sqf`: Pre-initialization setup
- `XEH_postInit.sqf`: Post-initialization tasks
- `XEH_preStart.sqf`: Pre-start configuration
- `XEH_postInit_client.sqf`: Client-specific post-initialization
- `XEH_preInit_server.sqf`: Server-specific pre-initialization

## Usage
To use the medical module:
1. Ensure the module is properly loaded in your mission
2. Monitor player health through the medical system
3. Handle medical events using the appropriate functions:
   ```sqf
   // Initialize medical system
   [] call forge_client_medical_fnc_initMedical;
   
   // Handle player death
   [player, killer, instigator, true] call forge_client_medical_fnc_onKilled;
   
   // Process respawn
   [player, corpse] call forge_client_medical_fnc_onRespawn;
   ```
4. Manage medical costs and inventory during medical events

## Configuration
The module can be configured through the main Forge client configuration:
```cpp
// Medical cost (default: 1000)
MED_COST = 1000;

// Insurance deductible (default: 200)
INS_DEDUCT = 200;

// Stretcher types
FORGE_Medical_StretcherTypes = [
    "Land_Stretcher_01_F",
    "Land_Stretcher_01_olive_F",
    "Land_Stretcher_01_sand_F"
];
```

## Debugging
Debug mode can be enabled by uncommenting the following in `script_component.hpp`:
```cpp
#define DEBUG_MODE_FULL
```

## Version Information
Version information is managed through the main Forge client system configuration.

## Technical Details
- Stretcher-based respawn system
- Body bag inventory management
- Medical cost processing
- Insurance system integration
- Inventory preservation
- Equipment tracking
- Payment verification
- Spectator mode control
- Trigger-based activation
- Event system integration
- State management
- Error handling
- User feedback
- Database persistence 