Crate praeda

Crate praeda 

Source
Expand description

§Praeda - Procedural Loot Generator

A high-performance procedural loot generator library designed for game development. Generate randomized items with qualities, affixes, and attributes using configurable rules.

§Features

  • Procedural Item Generation: Create unique items with random qualities and properties
  • Affix System: Apply prefixes and suffixes to items
  • Attribute System: Define custom attributes (damage, defense, health, etc.)
  • Quality/Rarity Tiers: Configure weighted quality levels (common, rare, legendary, etc.)
  • Flexible Configuration: Use TOML files or programmatic API
  • FFI Bindings: Call from C++, C#, and other languages

§Quick Start (Rust Library)

use praeda::{PraedaGenerator, GeneratorOptions, GeneratorOverrides};

let mut generator = PraedaGenerator::new();

// Configure qualities (rarity tiers)
generator.set_quality_data("common", 100);
generator.set_quality_data("rare", 30);
generator.set_quality_data("legendary", 5);

// Configure item types
generator.set_item_type("weapon", 2);
generator.set_item_subtype("weapon", "sword", 3);
generator.set_item_subtype("weapon", "axe", 2);

// Generate items with options
let options = GeneratorOptions {
    number_of_items: 5,
    base_level: 10.0,
    level_variance: 2.0,
    affix_chance: 0.25,
    linear: true,
    scaling_factor: 1.5,
};

let items = generator.generate_loot(&options, &GeneratorOverrides::empty(), "main")?;
for item in items {
    println!("Generated: {} ({})", item.name, item.quality);
}

§Configuration

§Using TOML Files

Define a TOML file with your loot configuration:

[quality_data]
common = 100
rare = 30
legendary = 5

[[item_types]]
item_type = "weapon"
weight = 2
[item_types.subtypes]
sword = 3
axe = 2

Then load it:

let mut generator = PraedaGenerator::new();
generator.load_data_from_file("loot.toml")?;

§Programmatic Configuration

Use the PraedaGenerator API to configure qualities, item types, affixes, and attributes.

§Core Types

§FFI Usage (C, C++, C#)

This library provides C-compatible FFI bindings for non-Rust languages. See the ffi module or the FFI documentation for language-specific examples and detailed API reference.

Re-exports§

pub use models::*;
pub use generator::*;
pub use error::*;

Modules§

error
ffi
Foreign Function Interface (FFI) for Praeda
generator
models