{"id":21936375,"url":"https://github.com/tjstretchalot/rtd-example","last_synced_at":"2025-03-22T14:17:05.093Z","repository":{"id":148118353,"uuid":"89612813","full_name":"Tjstretchalot/rtd-example","owner":"Tjstretchalot","description":"Dota 2 roll the dice example mod","archived":false,"fork":false,"pushed_at":"2017-04-27T20:23:59.000Z","size":7073,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-27T13:26:02.614Z","etag":null,"topics":["custom","dota","dota2","gamemode","library","rollthedice","rtd"],"latest_commit_sha":null,"homepage":null,"language":"Lua","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Tjstretchalot.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-04-27T15:30:24.000Z","updated_at":"2017-04-27T20:11:11.000Z","dependencies_parsed_at":"2023-05-19T04:45:11.247Z","dependency_job_id":null,"html_url":"https://github.com/Tjstretchalot/rtd-example","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tjstretchalot%2Frtd-example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tjstretchalot%2Frtd-example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tjstretchalot%2Frtd-example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tjstretchalot%2Frtd-example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Tjstretchalot","download_url":"https://codeload.github.com/Tjstretchalot/rtd-example/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244966523,"owners_count":20539797,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["custom","dota","dota2","gamemode","library","rollthedice","rtd"],"created_at":"2024-11-29T01:14:17.246Z","updated_at":"2025-03-22T14:17:05.069Z","avatar_url":"https://github.com/Tjstretchalot.png","language":"Lua","funding_links":[],"categories":[],"sub_categories":[],"readme":"# rtd-example\n\nThis is a gamemode to showcase the rtd command that you can put into\nyour mods. [RTD](https://forums.alliedmods.net/showthread.php?p=849987) is a common command in counter-strike gamemodes that \nlets players \"roll-the-dice\" (with a cooldown) to get random modifiers\nlike 15 seconds invunerability, max gold, negative gold, instant death,\n30 seconds max speed, etc.\n\n## Barebones installation\n\nTo install rtd in your gamemode:\n\n- Copy [rollthedice/](https://github.com/Tjstretchalot/rtd-example/blob/master/game/scripts/vscripts/libraries/rollthedice/)\ninto your game/scripts/vscripts/libraries folder \n- Copy [game/scripts/vscripts/lua_rtd/](https://github.com/Tjstretchalot/rtd-example/blob/master/game/scripts/vscripts/lua_rtd/) to the same spot in your gamemode\n- Copy [game/scripts/rtd/](https://github.com/Tjstretchalot/rtd-example/blob/master/game/scripts/rtd/) to the same spot in your gamemode\n- Copy [game/resource/flash3/images/spellicons/holdout_guardian_angel](https://github.com/Tjstretchalot/rtd-example/blob/master/game/resource/flash3/images/spellicons/holdout_guardian_angel.png) to the same spot in your gamemode. This is the texture for the RTD buff.\n- In addon_game_mode.lua initialize it with the following BEFORE require('events.lua')\n\n    require ('libraries/rollthedice/rollthedice')\n    \n- In [events.lua](https://github.com/Tjstretchalot/rtd-example/blob/master/game/scripts/vscripts/events.lua) under GameMode:OnPlayerChat(keys)\ncall \n\n    rollthedice:OnPlayerChat(keys, playerID)\n\nand rollthedice will take care of the rest!\n\n## Configuration\n\nThe main configuration files are [rollthedice_results.txt](https://github.com/Tjstretchalot/rtd-example/blob/master/game/scripts/rtd/rollthedice_results.txt) and \n[rollthedice_modifiers.txt](https://github.com/Tjstretchalot/rtd-example/blob/master/game/scripts/rtd/rollthedice_results.txt).\n\n### rollthedice_results.txt\n\nThis file maps rolls to their respective results. Rolls are between 1 and 99 (inclusive). An example file is like so:\n\n\u003cpre\u003e\n\"RollTheDice\"\n{\n  \"Results\"\n  {\n    \"01\" \"rtd_nothing\"\n    \"02\" \"rtd_nothing\"\n    ..omitted..\n    \"98\" \"rtd_nothing\"\n    \"99\" \"rtd_nothing\"\n  }\n}\n\u003c/pre\u003e\n\nThis would map every roll to the modifier rtd_nothing, which would need to be defined in rollthedice_modifiers.txt\n\n### rollthedice_modifiers.txt\n\nThis file describes the results that are defined in rollthedice_results.txt. An example of the file with nothing\ndefined would be:\n\n\u003cpre\u003e\n\"RollTheDice\"\n{\n}\n\u003c/pre\u003e\n\nFrom here you can add modifiers in one of two ways: DataDriven or Lua. The datadriven option is not as comprehensive\nas datadriven abilities or items. You may specifiy \"AbilitySpecial\" like usual, and reference it in the normal fashion.\n\n#### Lua Modifiers\n\nA lua modifier will attach to a script file which must define a class that matches the name of the modifier in the \nglobal context. The class will be provided the context which rollthedice runs in, and rollthedice will strip the modifier\nfrom the global context once it has acquired it. The class may override or use the following functions:\n\n```lua\n-- Called when a player lands on this result. The player is guarranteed\n-- to have selected a hero and be alive.\n-- \n-- @param keys (table)\n--   keys.playerid - the player id who got the result\nfunction rtd_example:OnCreated( keys )\n\n-- Returns the special value for the specified name.\n--\n-- @params name (string)\n--   the name of the special value to find\nfunction rtd_example:GetSpecialValueFor( name )\n```\n\nExample:\n\n\u003cpre\u003e\n\"RollTheDice\"\n{\n  \"rtd_example\"\n  {\n    \"BaseClass\" \"rtd_lua\" // choices are rtd_datadriven or rtd_lua\n    \"ScriptFile\" \"scripts/vscripts/lua_rtd/rtd_example.lua\"\n    \n    \"AbilitySpecial\"\n    {\n      \"01\"\n      {\n        \"var_type\" \"FIELD_INTEGER\"\n        \"duration\" \"10\"\n      }\n    }\n  }\n}\n\u003c/pre\u003e\n\nwith rtd_example.lua as \n\n```lua\nif not rtd_example then \n  rtd_example = class( {} )\nend\n\nfunction rtd_example:OnCreated( keys )\n  local playerid = keys.playerid\n  local hero = PlayerResource:GetSelectedHeroEntity( playerid )\n  \n  hero:AddNewModifier( hero, nil, 'modifier_kill', { Duration = self:GetSpecialValueFor('duration') } )\nend\n```\n\n#### DataDriven modifiers\n\nDataDriven modifiers may currently only apply a modifier to the player. This is done as follows:\n\nExample:\n\n\u003cpre\u003e\n\"RollTheDice\"\n{\n  \"rtd_example\"\n  {\n    \"BaseClass\" \"rtd_datadriven\" // choices are rtd_datadriven or rtd_lua\n    \n    \"AbilitySpecial\"\n    {\n      \"01\"\n      {\n        \"var_type\" \"FIELD_INTEGER\"\n        \"duration\" \"10\"\n      }\n    }\n    \n    \"Modifiers\"\n    {\n      \"01\"\n      {\n        \"OnCreated\"\n        {\n          \"ApplyModifier\"\n          {\n            \"ModifierName\" \"modifier_kill\" // As if you were using AddNewModifier\n            \"Data\" // This is passed as modifierData to AddNewModifier\n            {\n              \"Duration\" \"%duration\"\n            }\n          }\n        }\n      }\n    }\n  }\n}\n\u003c/pre\u003e\n\n## Localization\n\nWhen a player rolls a specific result, the thing printed to everyone on the left menu (as if via SendCustomMessage) can \nbe localized with the name of the modifier. The message will always be prefixed with the name of the player.\n\nThere are also a few other self-explanatory options:\n\naddon_english.txt\n```\n\"lang\"\n{\n  \"Language\" \"English\"\n  \"Tokens\"\n  {\n    \"DOTA_Tooltip_modifier_rtd_timer\" \"RTD Timer\"\n    \"DOTA_Tooltip_modifier_rtd_timer_Description\" \"Prevents using RTD\"\n    \n    \"rtd_alert_too_soon\" \"[RTD] You can't do that yet! Wait until the buff wears off.\"\n    \"rtd_alert_dead\" \"[RTD] You can only roll the dice while alive.\"\n    \"rtd_alert_no_selected_hero\" \"[RTD] You must have a hero selected to roll the dice.\"\n    \n    \"rtd_example\" \"[RTD] You won \u003cb\u003eIMMINENT DEATH\u003c/b\u003e!\"\n  }\n}\n```\n\n## Settings\n\nrollthedice.lua respects:\n\n```lua\nRTD_COOLDOWN = 60 -- cooldown between using rtd\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftjstretchalot%2Frtd-example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftjstretchalot%2Frtd-example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftjstretchalot%2Frtd-example/lists"}