# Torn Faction Respect Tracker
A Tampermonkey userscript for tracking faction respect statistics in Torn City. Generate detailed Excel reports analyzing offensive and defensive performance during wars.
## Features
- **Comprehensive Analysis**: Defense (incoming attacks, respect lost, overseas), Offense (attacks made, respect gained, chains, warlord bonuses), Revives (successful/failed attempts)
- **Enemy Identification**: Automatically identifies attacks against specified enemy faction members
- **Attack Modifiers**: Tracks overseas bonuses, chain participation, and warlord effects
- **Auto-Save**: All inputs, positions, and modal state persist across sessions
- **Draggable UI**: Orange button and modal window can be positioned anywhere
- **Excel Reports**: Generates `.xlsx` files with main report and payment calculation sheets
- **Responsive Design**: Adapts to different screen sizes with stacked layout on narrow widths
- **Theme/Font Toggle**: Light/Dark theme and Small/Large font size options
## Getting Started
1. Click the orange "Run Script" button
2. Enter required data:
- **API Key**: Your Torn Limited API key ([Get here](https://www.torn.com/preferences.php#tab=api))
- **Enemy Faction ID**: ID of opposing faction
- **Start/End Time**: Format `HH:MM:SS - DD/MM/YY` (UTC)
- **War Payout**: Total amount distributed
- **Withheld**: Amount or percentage to withhold (toggle $ or %)
- **Payment %**: Set percentages for inside hits, outside hits, assists, and revives
3. Configure optional exclusions with checkboxes
4. Click "Run Report" to fetch data and generate Excel file
## Report Contents
### Main Report
- **Defense**: Attacks received, respect lost (total & overseas), assists received
- **Offense**: Attacks made, respect gained, breakdown by target (inside/outside), chains, overseas, warlord bonuses
- **Revives**: Successful and failed revive attempts
- **Totals Row**: Faction-wide aggregates
### Payout Sheet
- Displays payment configuration
- Calculates per-member payouts using weighted scaling based on contributions
- Shows both raw (per-hit) and scaled payout amounts
## Configuration
- **Revive Energy Cost**: Multiplier for revive payments (Default: 70 = 2.8x multiplier)
- **Exclude Options**: Skip assists, successful revives, or failed revives from payout calculations
- **Clear Data**: Reset all saved inputs and GUI settings
## Troubleshooting
- **No attacks found**: Verify time format and UTC timezone
- **API errors**: Check API key validity and rate limits (script auto-retries)
- **Modal not responsive**: Try resizing or refreshing the page
- **Report not downloading**: Check browser download settings and Downloads folder
## Privacy
- API key stored locally via Tampermonkey (never sent outside Torn API)
- All analysis happens in-browser
- No external server connections
- Fully open source and auditable