-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 2ead7e7
Showing
9 changed files
with
429 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/target/ | ||
nbactions.xml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
[submodule "soundsrepo"] | ||
path = soundsrepo | ||
url = git@github.com:birgersp/df-jobsounds-bin.git | ||
branch = master |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# [LabourSounds](https://github.com/birgersp/df-jobsounds) | ||
|
||
A Dwarf Fortress sound utility. [Download here](https://github.com/birgersp/df-jobsounds/releases). | ||
|
||
This application reads the current action and position of your dwarves, and plays sounds accordingly. Checkout version 0.2 [demo](https://youtu.be/qeYIK1y-UcQ). | ||
|
||
Requires [DFHack](http://www.bay12forums.com/smf/index.php?topic=139553) and Java. | ||
|
||
**How to use** | ||
* Extract the contents of the .zip to your Dwarf Fortress installation folder | ||
* Start Dwarf Fortress | ||
* Run the .jar file (on Windows, you can use the .bat script to run it) | ||
* NOTE: If you don't want to copy this utility to your Dwarf Fortress folder, extract it somewhere else and enter the Dwarf Fortress directory when you launch the utility. | ||
For Windows users, the easiest way is to modify the .bat file by adding the directory at the end of the launch command. For example: | ||
|
||
``` | ||
@echo off | ||
java -jar df-laboursounds.jar "C:\Dwarf Fortress 0.43.03" | ||
pause | ||
``` | ||
|
||
**Current features** | ||
* Digging sounds | ||
* Woodchopping sounds | ||
* Building sounds | ||
|
||
**Project plan** | ||
1. Create a DFHack .lua script which reads the current jobs of the dwarves | ||
2. Make the script send TCP messages to a standalone application, which plays the sounds accordingly | ||
3. Add appropriate sounds | ||
|
||
**Credits** | ||
* [People making sounds](https://github.com/birgersp/df-jobsounds-bin) | ||
* The really awesome [DFHack project](https://github.com/DFHack) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# [JobSounds](https://github.com/birgersp/df-jobsounds) | ||
|
||
A Dwarf Fortress sound utility. | ||
|
||
Requires [DFHack](http://www.bay12forums.com/smf/index.php?topic=139553) and Java. | ||
|
||
**How to use** | ||
* Extract the contents of the .zip to your Dwarf Fortress installation folder | ||
* Start Dwarf Fortress | ||
* Run the .jar file (on Windows, you can use the .bat script to run it) | ||
NOTE: If you don't want to copy this utility to your Dwarf Fortress folder, simply extract it somewhere else and enter the Dwarf Fortress directory when you launch the utility. For Windows users, the easiest way is to modify the .bat file by adding the directory at the end of the launch command. For example, you could edit the .bat file to: | ||
|
||
@echo off | ||
java -jar df-jobsounds.jar "C:\Dwarf Fortress 0.43.03" | ||
pause |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
@echo off | ||
|
||
java -jar df-jobsounds.jar | ||
|
||
pause |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<groupId>com.github.birgersp.df-jobsounds</groupId> | ||
<artifactId>df-jobsounds</artifactId> | ||
<version>0.2</version> | ||
<packaging>jar</packaging> | ||
<properties> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
<maven.compiler.source>1.7</maven.compiler.source> | ||
<maven.compiler.target>1.7</maven.compiler.target> | ||
</properties> | ||
|
||
<build> | ||
<resources> | ||
<resource> | ||
<directory>${basedir}/resources</directory> | ||
</resource> | ||
<resource> | ||
<directory>${basedir}/soundsrepo/resources</directory> | ||
</resource> | ||
</resources> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-jar-plugin</artifactId> | ||
<version>3.0.2</version> | ||
<configuration> | ||
<finalName>df-jobsounds</finalName> | ||
<archive> | ||
<manifest> | ||
<mainClass>com.github.birgersp.dfjobsounds.JobSoundsApp</mainClass> | ||
</manifest> | ||
</archive> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-shade-plugin</artifactId> | ||
<version>2.4.3</version> | ||
<executions> | ||
<execution> | ||
<phase>package</phase> | ||
<goals> | ||
<goal>shade</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
-- Adds job sounds. | ||
--@ module = true | ||
|
||
--[====[ | ||
Job sounds | ||
=========== | ||
Connects to a socket (tcp), checks the current job of dwarves and sends messages | ||
]====] | ||
|
||
local scriptName = 'jobsounds' | ||
local jobs = { | ||
'Dig', | ||
'DigChannel', | ||
'ConstructBuilding', | ||
'FellTree' | ||
} | ||
|
||
local function initSocket() | ||
socket = tcp:connect('127.0.0.1', 56730) | ||
end | ||
|
||
local function start() | ||
luasocket = require("plugins.luasocket") | ||
tcp = luasocket.tcp | ||
dfhack.println(scriptName.." connecting...") | ||
socket = nil; | ||
pcall(initSocket) | ||
if (socket ~= nil) then | ||
dfhack.println(scriptName.." connected") | ||
stop = false | ||
timeLastSend = os.time() | ||
loop() | ||
else | ||
dfhack.println(scriptName.." could not connect") | ||
end | ||
end | ||
|
||
local function send(msg) | ||
if (pcall(socket.send, socket, msg) == true) then | ||
timeLastSend = os.time() | ||
else | ||
stop = true | ||
end | ||
end | ||
|
||
local function triggerJobSound(unit, jobType) | ||
if (socket ~= nil) then | ||
if ( | ||
df.global.window_z == unit.pos.z and | ||
df.global.window_x < unit.pos.x and | ||
df.global.window_x+90 > unit.pos.x and | ||
df.global.window_y < unit.pos.y and | ||
df.global.window_y+60 > unit.pos.y | ||
) then | ||
send(unit.id .. " " .. jobType .. "\n") | ||
end | ||
end | ||
end | ||
|
||
local function isRegisteredJob(jobType) | ||
for i, job in ipairs(jobs) do | ||
if (jobType == df.job_type[job]) then | ||
return true | ||
end | ||
end | ||
return false | ||
end | ||
|
||
local function handleDwarf(unit) | ||
if (unit.job.current_job ~= nil) then | ||
if (isRegisteredJob(unit.job.current_job.job_type) == true) then | ||
local jobPos = unit.job.current_job.pos | ||
local dx = math.abs(jobPos.x-unit.pos.x) | ||
local dy = math.abs(jobPos.y-unit.pos.y) | ||
local dz = math.abs(jobPos.z-unit.pos.z) | ||
if (dx <= 1 and dy <= 1 and dz <= 1) then | ||
triggerJobSound(unit, unit.job.current_job.job_type) | ||
end | ||
end | ||
end | ||
end | ||
|
||
local function checkDwarves() | ||
for k,unit in ipairs(df.global.world.units.active) do | ||
if (dfhack.units.isDwarf(unit)) then | ||
handleDwarf(unit) | ||
end | ||
end | ||
end | ||
|
||
function loop() | ||
if (os.time() - timeLastSend > 2) then | ||
send("null\n") | ||
end | ||
|
||
if (stop == true) then | ||
dfhack.println(scriptName.." stopped") | ||
return | ||
end | ||
|
||
if (df.global.pause_state == false) then | ||
checkDwarves() | ||
end | ||
|
||
dfhack.timeout(15, 'ticks', loop) | ||
end | ||
|
||
start() |
Submodule soundsrepo
added at
beb8b8
Oops, something went wrong.