Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 22 23 [24] 25 26 ... 61

Author Topic: [SUGGESTIONS] for DFhack plugins  (Read 143303 times)

Meph

  • Bay Watcher
    • View Profile
    • worldbicyclist
Re: [SUGGESTIONS] for DFhack plugins
« Reply #345 on: December 31, 2013, 04:03:16 pm »


Just something i was working on...
:o

YEAH!
Logged
::: ☼Meph Tileset☼☼Map Tileset☼- 32x graphic sets with TWBT :::
::: ☼MASTERWORK DF☼ - A comprehensive mod pack now on Patreon - 250.000+ downloads and counting :::
::: WorldBicyclist.com - Follow my bike tours around the world - 148 countries visited :::

Warmist

  • Bay Watcher
  • Master of unfinished jobs
    • View Profile
Re: [SUGGESTIONS] for DFhack plugins
« Reply #346 on: January 01, 2014, 10:28:23 pm »


Just something i was working on...
:o

YEAH!
Currently trying to figure out what more can be needed e.g. would like to allow animated tiles, maybe (BIG MAYBE) a custom tick logic (like steam engine has)- would probably be big fps hit (it gets called each tick for each workshop-it could work but nothing complicated)

Meph

  • Bay Watcher
    • View Profile
    • worldbicyclist
Re: [SUGGESTIONS] for DFhack plugins
« Reply #347 on: January 01, 2014, 10:34:13 pm »

Animation would be nice (even for workshops without power), but its graphical only. The important part is the use, the functionality. :)

What would the custom tick logic do in comparison to how it works atm? If it hurts FPS, then I would rather try to avoid it, especially if it is used in a race that mainly uses powered workshops for everything.
Logged
::: ☼Meph Tileset☼☼Map Tileset☼- 32x graphic sets with TWBT :::
::: ☼MASTERWORK DF☼ - A comprehensive mod pack now on Patreon - 250.000+ downloads and counting :::
::: WorldBicyclist.com - Follow my bike tours around the world - 148 countries visited :::

Warmist

  • Bay Watcher
  • Master of unfinished jobs
    • View Profile
Re: [SUGGESTIONS] for DFhack plugins
« Reply #348 on: January 02, 2014, 04:48:56 am »

Animation would be nice (even for workshops without power), but its graphical only. The important part is the use, the functionality. :)

What would the custom tick logic do in comparison to how it works atm? If it hurts FPS, then I would rather try to avoid it, especially if it is used in a race that mainly uses powered workshops for everything.
Custom tick logic could allow for e.g. real machines: my 2 current ideas: dragon breath engine (a pump like machine that instead of pumping magma from same level turns it into dragonfire) and a crusher (that crushes all stone stuff into blocks, and unfortunate live/dead units into flesh blocks), no need for jobs or anything, just connect power and enjoy. Just like steam engine works: fill up with fuel (or if using magma/water, do nothing!).

Meph

  • Bay Watcher
    • View Profile
    • worldbicyclist
Re: [SUGGESTIONS] for DFhack plugins
« Reply #349 on: January 02, 2014, 05:15:39 am »

If that dragon-breath engine does material emissions... then you could do custom siege engines with that. Even without the magma underneath. Remote controled siege engines.  :o

Both ideas are awesome btw. :)
Logged
::: ☼Meph Tileset☼☼Map Tileset☼- 32x graphic sets with TWBT :::
::: ☼MASTERWORK DF☼ - A comprehensive mod pack now on Patreon - 250.000+ downloads and counting :::
::: WorldBicyclist.com - Follow my bike tours around the world - 148 countries visited :::

Warmist

  • Bay Watcher
  • Master of unfinished jobs
    • View Profile
Re: [SUGGESTIONS] for DFhack plugins
« Reply #350 on: January 02, 2014, 08:16:53 am »

So sort of done with it. Need use case examples/ideas, will try to make using it more sane... currently e.g. soapmakers shop that needs power at (0,0) (top left corner):
Code: [Select]
blds.addBuilding(soapmaker.id,5,0,{{x=0,y=0}}) -- uses 5 produces 0 mechanical energy.
fps hit would be ~0
with fancy stuff:
Code: [Select]
blds.addBuilding(soapmaker.id,5,0,{{x=0,y=0}},1,makeFrames(),-1) --make frames is a big function
blds.onUpdateAction.bla=function (bld)
if bld:getCustomType()== soapmaker.id then
dfhack.maps.spawnFlow({x=bld.centerx,y=bld.centery,z=bld.z},0,0,0,199)
end
end
this function gets called each frame for each soapmaker.

something like this would be best imho:
Code: [Select]
blds.registerBuilding("DRAGON_ENGINE_N",{consume=25,gears={x=0,y=0},action={25,makeSpewFire("north")},animate={???,isMechanical=true}})
more info about each one will be given later

narhiril

  • Bay Watcher
  • [DUTY_BOUND]
    • View Profile
Re: [SUGGESTIONS] for DFhack plugins
« Reply #351 on: January 02, 2014, 11:00:36 am »

If that dragon-breath engine does material emissions... then you could do custom siege engines with that. Even without the magma underneath. Remote controled siege engines.  :o

Both ideas are awesome btw. :)

Meph

  • Bay Watcher
    • View Profile
    • worldbicyclist
Re: [SUGGESTIONS] for DFhack plugins
« Reply #352 on: January 02, 2014, 11:11:00 am »

Faster than I thought :)

Code: [Select]

// Some of these may not be needed.
#include <stdint.h>
#include <iostream>
#include <map>
#include <vector>
#include "Core.h"
#include "Console.h"
#include "Export.h"
#include "PluginManager.h"
#include "modules/Maps.h"
#include "modules/World.h"
#include "modules/MapCache.h"
#include "modules/Gui.h"

using namespace DFHack;
using namespace df::enums;
using df::global::world;

DFHACK_PLUGIN("eat-magma");

// Only use with a NEEDS_MAGMA workshop and in a reaction that has FUEL,
// that way the workshop is guaranteed to have a usable amount of magma below.

// This program is an example of cut and paste codding at its worst,
// too bad DFHack isn't written in Go :p
// Anyway my C++ skills have atrophied more than I thought, plus I know nothing about the DFHack API...

// This function is copied directly from the steam engine plugin.
// BTW: why use the "auto" keyword? I thought that was implicit.
void decrement_flow(df::coord pos, int amount)
{
auto pldes = Maps::getTileDesignation(pos);
if (!pldes) return;

int nsize = std::max(0, int(pldes->bits.flow_size - amount));
pldes->bits.flow_size = nsize;
pldes->bits.flow_forbid = (nsize > 3 || pldes->bits.liquid_type == tile_liquid::Magma);

enable_updates_at(pos, true, false);
}

command_result eat_magma(color_ostream &out, std::vector<std::string> & params)
{
// How much to eat
int min_level = 1;

if (parameters.size() != 3) {
return CR_WRONG_USAGE;
}

// Is int the correct type to use here?
int c_x = atoi(parameters[0].c_str());
if ( c_x < 0 || c_x > 1 )
return CR_WRONG_USAGE;

int c_y = atoi(parameters[1].c_str());
if ( c_y < 0 || c_y > 1 )
return CR_WRONG_USAGE;

int c_z = atoi(parameters[2].c_str());
if ( c_z < 0 || c_z > 1 )
return CR_WRONG_USAGE;

// These will need to change for non-3x3 workshops.
int t_x = c_x-1;
int b_x = c_x+1;
int t_y = c_y-1;
int b_y = c_y+1;
int z = c_z;

for (int x = t_x; x <= b_x; x++)
{
for (int y = t_y; y <= b_y; y++)
{
auto ptile = Maps::getTileType(x,y,z);
if (!ptile || !FlowPassableDown(*ptile))
continue;

auto pltile = Maps::getTileType(x,y,z-1);
if (!pltile || !FlowPassable(*pltile))
continue;

auto pldes = Maps::getTileDesignation(x,y,z-1);
if (!pldes || pldes->bits.flow_size < min_level)
continue;

if (pldes->bits.liquid_type == tile_liquid::Magma)
{
decrement_flow(df::coord(x,y,z-1), min_level);
out.print("Successfully ate one magma.\n");
return CR_OK;
}
else
{
// Eat water here,
// if I can ever think of a way to keep the reaction from working if there is no water...
}
}
}

out.print("Failed to find magma tile.\n");
return CR_OK;
}

DFhackCExport command_result plugin_init ( color_ostream &out, std::vector <PluginCommand> &commands)
{
commands.push_back(PluginCommand("eat-magma", "Remove 1/7 magma from a tile below a 3x3 workshop centered on the specified location.", eat_magma));
return CR_OK;
}


I think I got all the semicolons, but I have spent so long working with Go (in which semicolons are optional and discouraged) that I have probably missed a few.
Another possible/probable problem is includes, I may have some that are not needed and lack some that I need.

This is a very basic test version, it only eats 1/7 magma and the parameters should be the center tile of a 3x3 area that the workshop should cover.

Usage:
eat-magma x y z

(I have no idea if this works, will someone please compile it for me?)
I recently found out something new about water and drinks (thanks to Hugo_the_dwarf). You can actually do DRINK:NONE:WATER:NONE and the dwarves will drink the water from a barrel. You can also do DRINK:NONE:INORGANIC:NONE, and you will get magma in the barrel. A magma-drink, which dwarves drink without problem.

With your script idea, which takes actual liquids, people could build a filling station for drinks. For example you build the water-station over a river, fill up as many barrels as you can, before the river freezes again. You can now carry barrels of water underground and use them in winter as backup. I would totally add that. :)
Logged
::: ☼Meph Tileset☼☼Map Tileset☼- 32x graphic sets with TWBT :::
::: ☼MASTERWORK DF☼ - A comprehensive mod pack now on Patreon - 250.000+ downloads and counting :::
::: WorldBicyclist.com - Follow my bike tours around the world - 148 countries visited :::

milo christiansen

  • Bay Watcher
  • Something generic here
    • View Profile
Re: [SUGGESTIONS] for DFhack plugins
« Reply #353 on: January 02, 2014, 11:45:47 am »

Has anyone tried to run that plugin through a C++ compiler? I would really like to know if it compiles without error so I can work on a more usable version...
Logged
Rubble 8 - The most powerful modding suite in existence!
After all, coke is for furnaces, not for snorting.
You're not true dwarven royalty unless you own the complete 'Signature Collection' baby-bone bedroom set from NOKEAS

Warmist

  • Bay Watcher
  • Master of unfinished jobs
    • View Profile
Re: [SUGGESTIONS] for DFhack plugins
« Reply #354 on: January 03, 2014, 10:49:47 am »

Straight from crazy dwarf scientists:
a satellite observation of some weapon test site

milo christiansen

  • Bay Watcher
  • Something generic here
    • View Profile
Re: [SUGGESTIONS] for DFhack plugins
« Reply #355 on: January 03, 2014, 01:49:32 pm »

Now THAT could come in handy!

Can you say "roast goblin"?
Logged
Rubble 8 - The most powerful modding suite in existence!
After all, coke is for furnaces, not for snorting.
You're not true dwarven royalty unless you own the complete 'Signature Collection' baby-bone bedroom set from NOKEAS

Meph

  • Bay Watcher
    • View Profile
    • worldbicyclist
Re: [SUGGESTIONS] for DFhack plugins
« Reply #356 on: January 03, 2014, 01:54:37 pm »

Didnt come in handy for the dwarf that operated it. ;)
Logged
::: ☼Meph Tileset☼☼Map Tileset☼- 32x graphic sets with TWBT :::
::: ☼MASTERWORK DF☼ - A comprehensive mod pack now on Patreon - 250.000+ downloads and counting :::
::: WorldBicyclist.com - Follow my bike tours around the world - 148 countries visited :::

milo christiansen

  • Bay Watcher
  • Something generic here
    • View Profile
Re: [SUGGESTIONS] for DFhack plugins
« Reply #357 on: January 03, 2014, 02:02:08 pm »

That's just bad engineering :)
Logged
Rubble 8 - The most powerful modding suite in existence!
After all, coke is for furnaces, not for snorting.
You're not true dwarven royalty unless you own the complete 'Signature Collection' baby-bone bedroom set from NOKEAS

Warmist

  • Bay Watcher
  • Master of unfinished jobs
    • View Profile
Re: [SUGGESTIONS] for DFhack plugins
« Reply #358 on: January 03, 2014, 02:32:35 pm »

That's just bad engineering :)
Also bad ascii art and general building raw design :/ But it's fun to use. Also i made a mod manager (at least start of it...)
Solving problems that nobody has
« Last Edit: January 03, 2014, 07:59:14 pm by Warmist »
Logged

Meph

  • Bay Watcher
    • View Profile
    • worldbicyclist
Re: [SUGGESTIONS] for DFhack plugins
« Reply #359 on: January 03, 2014, 08:06:21 pm »

That's just bad engineering :)
Also bad ascii art and general building raw design :/ But it's fun to use. Also i made a mod manager (at least start of it...)
Solving problems that nobody has
Warmist: "Mh... maybe I could work a bit on powered workshops"
 - Makes powered workshops
 - Makes custom siegeengine
 - Makes custom atom-smasher
 - Makes custom display case

Any chance for the "uses water/magma" workshops, the code milo christiansen posted? (once you are at it :P)

The display case does look like something every player could use, regardless of mod or not. I would let Peridexis know, maybe he wants it as an option in the extended LNP. :)
Logged
::: ☼Meph Tileset☼☼Map Tileset☼- 32x graphic sets with TWBT :::
::: ☼MASTERWORK DF☼ - A comprehensive mod pack now on Patreon - 250.000+ downloads and counting :::
::: WorldBicyclist.com - Follow my bike tours around the world - 148 countries visited :::
Pages: 1 ... 22 23 [24] 25 26 ... 61