Skip to content

Commit

Permalink
First implementation
Browse files Browse the repository at this point in the history
Added `dda-lua`, `dda-lua-skills` and `dda-lua-traits`.
  • Loading branch information
ZhilkinSerg committed Aug 11, 2017
1 parent 17871a3 commit d296b85
Show file tree
Hide file tree
Showing 51 changed files with 19,744 additions and 1 deletion.
82 changes: 81 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,81 @@
# Cataclysm-DDA-LUA
# Description:

Cataclysm-DDA-LUA is collection of LUA mods for [Dark Days Ahead](http://en.cataclysmdda.com/).

## dda-lua

Shared library mod for easier creation of LUA mods.

## dda-lua-achievements

Mod that adds following achievements:

- *not implemented yet*.

## dda-lua-items

Mod that adds following items:

- *not implemented yet*.

## dda-lua-mapgen

Mod that adds following mapgen:

- *not implemented yet*.

## dda-lua-skills

Mod that adds following skills:

- `athletics` - gives speed bonus based on `squares_walked`.

## dda-lua-traits

Mod that adds following traits:

- `TOURETTE` - shouts bad words when not under medication (`xanax`);
- `NIGHTMARES` - you see bad dreams when not under medication (`ambien`);
- `NUDIST` - +2 to all attributes when naked.

# Todo list:

## dda-lua

- enhance capabilities (add `mapgen`, `menu`, `config`);
- implement figlet/ascii intro;
- implement global configuration menu;
- optimize `figlet` data;
- make profiling and optimize code.

## dda-lua-achievements

- add achievements infrastructure to `dda-lua-achievements`;
- add achievements (`squares_walked`, `cash`, `damage_taken`, `damage_healed`, `headshots`, `skill_level`, `attribute`, `recipes_known`, `get_naked`, `speed`).

## dda-lua-items

- rewrite code to make use of `dda-lua`;
- implement `entity_scanner` - highlights items and creatures around player character (merge from http://smf.cataclysmdda.com/index.php?topic=14231.msg300388#msg300388);
- implement `earthquake_generator` - makes rubbles around player character (merge from http://smf.cataclysmdda.com/index.php?topic=14231.msg300388#msg300388);
- implement solar powered items;
- implement ascii photo-gallery for camera.


## dda-lua-mapgen

- add mapgen infrastructure to `dda-lua-mapgen`;
- rewrite code to make use of `dda-lua`;
- implement some buildings (merge from http://smf.cataclysmdda.com/index.php?topic=14231.msg300728#msg300728);
- implement building degradation (merge from http://smf.cataclysmdda.com/index.php?topic=14825.0).

## dda-lua-skills

- change `athletics` skill to control `stamina` and/or `fatigue`;
- rebalance `athletics` skill practice amount per `squares_walked`.

## dda-lua-traits

- change `NUDIST` trait to affect morale;
- change `NIGHTMARES` trait to affect morale after awake;
- add more nightmare images to `NIGHTMARES` trait.
8 changes: 8 additions & 0 deletions dda-lua-skills/json/skills.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[
{
"type" : "skill",
"ident" : "athletics",
"name" : "athletics",
"description" : "Yout ability to move faster. Skill increases overall speed."
}
]
164 changes: 164 additions & 0 deletions dda-lua-skills/main.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
require("./data/mods/dda-lua/init")

--[[ Modification code ]]--

local MOD = {

id = "dda-lua-skills",
version = "2017-08-11"

}

mods[MOD.id] = MOD

function MOD.on_game_loaded()

LOG.message(MOD.id..".main.on_game_loaded:START")



LOG.message(MOD.id..".main.on_game_loaded:END")

end

function MOD.on_new_player_created()

LOG.message(MOD.id..".main.on_new_player_created:START")

MOD.Init()
MOD.Update()

LOG.message(MOD.id..".main.on_new_player_created:END")

end

function MOD.on_skill_increased()

LOG.message(MOD.id..".main.on_skill_increased:START")

MOD.Update()

LOG.message(MOD.id..".main.on_skill_increased:END")

end

function MOD.on_minute_passed()

LOG.message(MOD.id..".main.on_minute_passed:START")

MOD.Update()

LOG.message(MOD.id..".main.on_minute_passed:END")

end

function MOD.on_day_passed()

LOG.message(MOD.id..".main.on_day_passed:START")



LOG.message(MOD.id..".main.on_day_passed:END")

end

MOD.CalculateSpeedBonus = function()

LOG.message(MOD.id..".main.CalculateSpeedBonus:START")

local speed_bonus_factor = 2 --TODO: make this variable configurable or implement some smarter formula for `speed_bonus`
local speed_bonus = PARAM.get("skill_athletics") * speed_bonus_factor

LOG.message(MOD.id..".main.CalculateSpeedBonus:END|%s", speed_bonus)

return speed_bonus

end

MOD.RemoveSpeedBonus = function()

LOG.message(MOD.id..".main.RemoveSpeedBonus:START")

local speed_bonus = PARAM.load("speed_bonus")
local speed_base = tonumber(player:get_speed_base())
local speed_base_new = speed_base

if (speed_bonus) then

speed_base_new = speed_base - speed_bonus

player:set_speed_base (speed_base_new)

end

LOG.message(MOD.id..".main.RemoveSpeedBonus:END|%s|%s|%s", speed_bonus, speed_base, speed_base_new)

end

MOD.ApplySpeedBonus = function()

LOG.message(MOD.id..".main.ApplySpeedBonus:START")

MOD.RemoveSpeedBonus()

local speed_bonus = MOD.CalculateSpeedBonus()
local speed_base = tonumber(player:get_speed_base())
local speed_base_new = speed_base + speed_bonus

player:set_speed_base (speed_base_new)

PARAM.save("speed_bonus", speed_bonus)

LOG.message(MOD.id..".main.ApplySpeedBonus:END|%s|%s|%s", speed_bonus, speed_base, speed_base_new)

end

MOD.PracticeSkill = function(skill_name, trained_amount)

LOG.message(MOD.id..".main.PracticeSkill:START")

player:practice(skill_id(skill_name), trained_amount)

LOG.message(MOD.id..".main.PracticeSkill:END|%s|%s", skill_name, trained_amount)

end

MOD.Init = function()

LOG.message(MOD.id..".main.Init:START")

PARAM.save("squares_walked_total", 0)
PARAM.save("stats_squares_walked", 0)
PARAM.save("speed_bonus", 0)

LOG.message(MOD.id..".main.Init:END")

end

MOD.Update = function()

LOG.message(MOD.id..".main.Update:START")

MOD.ApplySpeedBonus()

local squares_walked_prev = PARAM.load("stats_squares_walked")
local squares_walked = PARAM.get("stats_squares_walked")

local squares_walked_delta = squares_walked - squares_walked_prev

PARAM.save("stats_squares_walked", squares_walked)

local squares_walked_total = PARAM.load("squares_walked_total")
squares_walked_total = squares_walked_total + squares_walked_delta

PARAM.save("squares_walked_total", squares_walked_total)

local squares_per_train = 100 --TODO: make this variable configurable or implement some smarter formula for `trained_amount`
local trained_amount = squares_walked_delta / squares_per_train
MOD.PracticeSkill("athletics", trained_amount)

LOG.message(MOD.id..".main.Update:END|%s|%s|%s", squares_walked_prev, squares_walked, squares_walked_delta)

end

MOD.on_game_loaded()
11 changes: 11 additions & 0 deletions dda-lua-skills/modinfo.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[
{
"type": "MOD_INFO",
"ident": "dda-lua-skills",
"name": "Dark Days Ahead: Lua (Skills)",
"authors": [ "ZhilkinSerg" ],
"description": "New skills using LUA.",
"category": "content",
"dependencies": [ "dda", "dda-lua" ]
}
]
21 changes: 21 additions & 0 deletions dda-lua-skills/preload.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
require("./data/mods/dda-lua/init")

--[[ Modification code ]]--

MOD = {

id = "dda-lua-skills"

}

function on_preload()

LOG.message(MOD.id..".preload.on_preload:START")



LOG.message(MOD.id..".preload.on_preload:END")

end

on_preload()
17 changes: 17 additions & 0 deletions dda-lua-traits/json/effects.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[
{
"type": "effect_type",
"id": "nude",
"name": ["Nude"],
"desc": ["You are feeling just good to be naked."],
"apply_message": "I am fully naked at last! So comfortable!",
"remove_message": "Damn clothes! I don't want to wear it!",
"rating": "good",
"base_mods": {
"str_mod": [2],
"dex_mod": [2],
"per_mod": [2],
"int_mod": [2]
}
}
]
29 changes: 29 additions & 0 deletions dda-lua-traits/json/traits.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
[
{
"type" : "mutation",
"id" : "TOURETTE",
"name" : "Tourette Syndrom",
"points" : -5,
"description" : "Compulsive swearing can be uncontrollable and undesired by the person uttering the phrases. Xanax can help control this.",
"starting_trait" : true,
"valid" : true
},
{
"type" : "mutation",
"id" : "NUDIST",
"name" : "Nudist",
"points" : 5,
"description" : "You receive boost of +2 to all attributes when naked.",
"starting_trait" : true,
"valid" : true
},
{
"type" : "mutation",
"id" : "NIGHTMARES",
"name" : "Nightmares",
"points" : -5,
"description" : "You see bad dreams. Ambien can help control this anxiety.",
"starting_trait" : true,
"valid" : true
}
]
Loading

0 comments on commit d296b85

Please sign in to comment.