Giter Site home page Giter Site logo

carlos-aliaga / dicebag-godot-4 Goto Github PK

View Code? Open in Web Editor NEW

This project forked from cablefish1/dicebag-godot-4

0.0 0.0 0.0 44 KB

A Godot 4 port of Dicebag by 8bitskull, originally in Lua for Defold.

License: Creative Commons Zero v1.0 Universal

GDScript 100.00%

dicebag-godot-4's Introduction

dicebag

A Godot 4 port of Dicebag by 8bitskull, originally in Lua for Defold.

It contains various random dice and RNG functions that are useful for anyone making RPG's and especially those that emulate tabletop RPGs.

Converted to Godot 3.2 by yagich

Converted again to Godot 4.0 by cablefish1 who removed some functions and rewrote some.

Join the RPGodot discord to join the development of more universal RPG tools.

Installation

You can add Dicebag to your own projects using the built-in Asset Library. Once it is added to your project, you need to add an instance of Dicebag to the script you wish to use it in, before the _ready() function:

@onready var dicebag = Dicebag.new()

func _ready():
...

Then you can use Dicebag functions, for example:

var coin = dicebag.flip_coin()

Remember to do a randomize() before you call the scripts if you don't want your results to repeat.

Usage

dicebag.flip_coin()

Flip a coin.

RETURNS

  • result (bool) - true or false (50% chance).

dicebag.roll_dice(num_dice, num_sides, modifier)

Roll a number of dice, D&D-style. An example would be rolling 3d6+2. Returns the sum of the resulting roll.

PARAMETERS

  • num_dice (int) - Number of dice to roll.

  • num_sides (int) - Number of sides on the dice.

  • modifier (int) - Number to add to the result.

RETURNS

  • result (int) - Sum of rolled dice plus modifier.

dicebag.roll_special_dice(num_sides, advantage, num_dice)

Roll a number of dice and return the highest (advantage) or lowest (disadvantage) results.

PARAMETERS

  • num_sides (int) - Number of sides on the dice.

  • advantage (bool) - If true, the highest rolls will be selected, otherwise the lowest values will be selected.

  • num_dice (int) - Number of dice to roll.

RETURNS

  • result (int) - The highest (advantage) or lowest (disadvantage) dice roll.

dicebag.roll_table(sides)

Pick a random place in a user defined table. I.e. a loot table.

PARAMETERS

  • weighted_loot_table is an array in the format [[weight1, value1], [weight2, value2] ...]. The function adds the weights and returns a random value based on the weighted probabilities.

RETURNS

  • value (Variant) - The value as specified in Array weighted_loot_table.

dicebag-godot-4's People

Contributors

cablefish1 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.