forked from github/server
- repeating crossbow
- bugfix market deleting all items
This commit is contained in:
parent
6e9e6b6928
commit
c38c8e21fc
11 changed files with 151 additions and 48 deletions
|
@ -105,42 +105,44 @@ void do_markets(void)
|
||||||
for (d=0;d!=MAXDIRECTIONS;++d) {
|
for (d=0;d!=MAXDIRECTIONS;++d) {
|
||||||
region * r2 = rconnect(r, d);
|
region * r2 = rconnect(r, d);
|
||||||
if (r2 && r2->buildings) {
|
if (r2 && r2->buildings) {
|
||||||
nmarkets += get_markets(r, markets+nmarkets, MAX_MARKETS-nmarkets);
|
nmarkets += get_markets(r2, markets+nmarkets, MAX_MARKETS-nmarkets);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
while (lux && numlux--) {
|
if (nmarkets) {
|
||||||
int n = rng_int() % nmarkets;
|
while (lux && numlux--) {
|
||||||
unit * u = markets[n];
|
int n = rng_int() % nmarkets;
|
||||||
item * items;
|
unit * u = markets[n];
|
||||||
attrib * a = a_find(u->attribs, &at_market);
|
item * items;
|
||||||
if (a==NULL) {
|
attrib * a = a_find(u->attribs, &at_market);
|
||||||
unit_list * ulist = malloc(sizeof(unit_list));
|
if (a==NULL) {
|
||||||
a = a_add(&u->attribs, a_new(&at_market));
|
unit_list * ulist = malloc(sizeof(unit_list));
|
||||||
ulist->next = traders;
|
a = a_add(&u->attribs, a_new(&at_market));
|
||||||
ulist->data = u;
|
ulist->next = traders;
|
||||||
traders = ulist;
|
ulist->data = u;
|
||||||
|
traders = ulist;
|
||||||
|
}
|
||||||
|
items = (item *)a->data.v;
|
||||||
|
i_change(&items, lux, 1);
|
||||||
|
a->data.v = items;
|
||||||
|
/* give 1 luxury */
|
||||||
}
|
}
|
||||||
items = (item *)a->data.v;
|
while (herb && numherbs--) {
|
||||||
i_change(&items, lux, 1);
|
int n = rng_int() % nmarkets;
|
||||||
a->data.v = items;
|
unit * u = markets[n];
|
||||||
/* give 1 luxury */
|
item * items;
|
||||||
}
|
attrib * a = a_find(u->attribs, &at_market);
|
||||||
while (herb && numherbs--) {
|
if (a==NULL) {
|
||||||
int n = rng_int() % nmarkets;
|
unit_list * ulist = malloc(sizeof(unit_list));
|
||||||
unit * u = markets[n];
|
a = a_add(&u->attribs, a_new(&at_market));
|
||||||
item * items;
|
ulist->next = traders;
|
||||||
attrib * a = a_find(u->attribs, &at_market);
|
ulist->data = u;
|
||||||
if (a==NULL) {
|
traders = ulist;
|
||||||
unit_list * ulist = malloc(sizeof(unit_list));
|
}
|
||||||
a = a_add(&u->attribs, a_new(&at_market));
|
items = (item *)a->data.v;
|
||||||
ulist->next = traders;
|
i_change(&items, herb, 1);
|
||||||
ulist->data = u;
|
a->data.v = items;
|
||||||
traders = ulist;
|
/* give 1 luxury */
|
||||||
}
|
}
|
||||||
items = (item *)a->data.v;
|
|
||||||
i_change(&items, herb, 1);
|
|
||||||
a->data.v = items;
|
|
||||||
/* give 1 luxury */
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -152,6 +154,7 @@ void do_markets(void)
|
||||||
attrib * a = a_find(u->attribs, &at_market);
|
attrib * a = a_find(u->attribs, &at_market);
|
||||||
item * items = a->data.v;
|
item * items = a->data.v;
|
||||||
|
|
||||||
|
a->data.v = NULL;
|
||||||
while (items) {
|
while (items) {
|
||||||
item * itm = items;
|
item * itm = items;
|
||||||
items = itm->next;
|
items = itm->next;
|
||||||
|
@ -159,7 +162,10 @@ void do_markets(void)
|
||||||
if (itm->number) {
|
if (itm->number) {
|
||||||
ADDMSG(&u->faction->msgs, msg_message("buyamount",
|
ADDMSG(&u->faction->msgs, msg_message("buyamount",
|
||||||
"unit amount resource", u, itm->number, itm->type->rtype));
|
"unit amount resource", u, itm->number, itm->type->rtype));
|
||||||
|
itm->next = NULL;
|
||||||
i_add(&u->items, itm);
|
i_add(&u->items, itm);
|
||||||
|
} else {
|
||||||
|
i_free(itm);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -454,6 +454,7 @@ new_building(const struct building_type * btype, region * r, const struct locale
|
||||||
init_lighthouse = true;
|
init_lighthouse = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
b->flags = BLD_WORKING|BLD_MAINTAINED;
|
||||||
b->no = newcontainerid();
|
b->no = newcontainerid();
|
||||||
bhash(b);
|
bhash(b);
|
||||||
|
|
||||||
|
|
|
@ -599,7 +599,7 @@ static void
|
||||||
write_spells(void)
|
write_spells(void)
|
||||||
{
|
{
|
||||||
struct locale * loc = find_locale("de");
|
struct locale * loc = find_locale("de");
|
||||||
FILE * F = fopen("spells.txt", "w");
|
FILE * F = fopen("spells.csv", "w");
|
||||||
spell_list * spl = spells;
|
spell_list * spl = spells;
|
||||||
for (;spl;spl=spl->next) {
|
for (;spl;spl=spl->next) {
|
||||||
const spell * sp = spl->data;
|
const spell * sp = spl->data;
|
||||||
|
@ -615,6 +615,37 @@ write_spells(void)
|
||||||
fclose(F);
|
fclose(F);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
write_skills(void)
|
||||||
|
{
|
||||||
|
struct locale * loc = find_locale("de");
|
||||||
|
FILE * F = fopen("skills.csv", "w");
|
||||||
|
race * rc;
|
||||||
|
skill_t sk;
|
||||||
|
fputs("\"Rasse\",", F);
|
||||||
|
for (rc=races;rc;rc = rc->next) {
|
||||||
|
if (playerrace(rc)) {
|
||||||
|
fprintf(F, "\"%s\",", LOC(loc, rc->_name[0]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fputc('\n', F);
|
||||||
|
|
||||||
|
for (sk=0;sk!=MAXSKILLS;++sk) {
|
||||||
|
const char * str = skillname(sk, loc);
|
||||||
|
if (str) {
|
||||||
|
fprintf(F, "\"%s\",", str);
|
||||||
|
for (rc=races;rc;rc = rc->next) {
|
||||||
|
if (playerrace(rc)) {
|
||||||
|
if (rc->bonus[sk]) fprintf(F, "%d,", rc->bonus[sk]);
|
||||||
|
else fputc(',', F);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fputc('\n', F);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fclose(F);
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
main(int argc, char *argv[])
|
main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
@ -622,6 +653,7 @@ main(int argc, char *argv[])
|
||||||
char * lc_ctype;
|
char * lc_ctype;
|
||||||
char * lc_numeric;
|
char * lc_numeric;
|
||||||
lua_State * luaState = lua_init();
|
lua_State * luaState = lua_init();
|
||||||
|
static int write_csv = 1;
|
||||||
|
|
||||||
setup_signal_handler();
|
setup_signal_handler();
|
||||||
|
|
||||||
|
@ -650,9 +682,10 @@ main(int argc, char *argv[])
|
||||||
kernel_init();
|
kernel_init();
|
||||||
game_init();
|
game_init();
|
||||||
|
|
||||||
if (0)
|
if (write_csv) {
|
||||||
|
write_skills();
|
||||||
write_spells();
|
write_spells();
|
||||||
|
}
|
||||||
/* run the main script */
|
/* run the main script */
|
||||||
if (luafile==NULL) lua_console(luaState);
|
if (luafile==NULL) lua_console(luaState);
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -118,6 +118,15 @@ static int tolua_region_get_flag(lua_State* tolua_S)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int tolua_region_get_adj(lua_State* tolua_S)
|
||||||
|
{
|
||||||
|
region* self = (region*)tolua_tousertype(tolua_S, 1, 0);
|
||||||
|
direction_t dir = (direction_t)tolua_tonumber(tolua_S, 2, 0);
|
||||||
|
|
||||||
|
tolua_pushusertype(tolua_S, (void*)r_connect(self, dir), "region");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
static int tolua_region_set_flag(lua_State* tolua_S)
|
static int tolua_region_set_flag(lua_State* tolua_S)
|
||||||
{
|
{
|
||||||
region* self = (region*)tolua_tousertype(tolua_S, 1, 0);
|
region* self = (region*)tolua_tousertype(tolua_S, 1, 0);
|
||||||
|
@ -230,6 +239,7 @@ tolua_region_create(lua_State* tolua_S)
|
||||||
if (result) {
|
if (result) {
|
||||||
terraform_region(result, terrain);
|
terraform_region(result, terrain);
|
||||||
}
|
}
|
||||||
|
fix_demand(result);
|
||||||
|
|
||||||
tolua_pushusertype(tolua_S, result, "region");
|
tolua_pushusertype(tolua_S, result, "region");
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -356,6 +366,7 @@ tolua_region_open(lua_State* tolua_S)
|
||||||
tolua_function(tolua_S, "set_resource", tolua_region_set_resource);
|
tolua_function(tolua_S, "set_resource", tolua_region_set_resource);
|
||||||
tolua_function(tolua_S, "get_flag", tolua_region_get_flag);
|
tolua_function(tolua_S, "get_flag", tolua_region_get_flag);
|
||||||
tolua_function(tolua_S, "set_flag", tolua_region_set_flag);
|
tolua_function(tolua_S, "set_flag", tolua_region_set_flag);
|
||||||
|
tolua_function(tolua_S, "next", tolua_region_get_adj);
|
||||||
|
|
||||||
tolua_function(tolua_S, "get_key", tolua_region_getkey);
|
tolua_function(tolua_S, "get_key", tolua_region_getkey);
|
||||||
tolua_function(tolua_S, "set_key", tolua_region_setkey);
|
tolua_function(tolua_S, "set_key", tolua_region_setkey);
|
||||||
|
|
|
@ -40,10 +40,9 @@
|
||||||
<skill name="herbalism" modifier="-2"/>
|
<skill name="herbalism" modifier="-2"/>
|
||||||
<skill name="melee" speed="+5"/>
|
<skill name="melee" speed="+5"/>
|
||||||
<skill name="mining" modifier="1"/>
|
<skill name="mining" modifier="1"/>
|
||||||
|
<skill name="polearm" speed="+5"/>
|
||||||
<skill name="quarrying" modifier="1"/>
|
<skill name="quarrying" modifier="1"/>
|
||||||
<skill name="riding" modifier="-99"/>
|
|
||||||
<skill name="sailing" modifier="-1"/>
|
<skill name="sailing" modifier="-1"/>
|
||||||
<skill name="spear" speed="+5"/>
|
|
||||||
<skill name="stamina" speed="0"/>
|
<skill name="stamina" speed="0"/>
|
||||||
<skill name="shipcraft" modifier="-1"/>
|
<skill name="shipcraft" modifier="-1"/>
|
||||||
<skill name="tactics" modifier="1"/>
|
<skill name="tactics" modifier="1"/>
|
||||||
|
@ -159,7 +158,7 @@
|
||||||
<skill name="melee" modifier="1"/>
|
<skill name="melee" modifier="1"/>
|
||||||
<skill name="mining" modifier="1"/>
|
<skill name="mining" modifier="1"/>
|
||||||
<skill name="quarrying" modifier="2"/>
|
<skill name="quarrying" modifier="2"/>
|
||||||
<skill name="riding" modifier="-2"/>
|
<skill name="riding" modifier="-99"/>
|
||||||
<skill name="roadwork" modifier="2"/>
|
<skill name="roadwork" modifier="2"/>
|
||||||
<skill name="sailing" modifier="-1"/>
|
<skill name="sailing" modifier="-1"/>
|
||||||
<skill name="shipcraft" modifier="-1"/>
|
<skill name="shipcraft" modifier="-1"/>
|
||||||
|
|
|
@ -405,7 +405,7 @@
|
||||||
<resource name="h18" amount="1" cost="linear"/><!-- Eisblume -->
|
<resource name="h18" amount="1" cost="linear"/><!-- Eisblume -->
|
||||||
<resource name="h11" amount="1" cost="linear"/><!-- Sandfäule -->
|
<resource name="h11" amount="1" cost="linear"/><!-- Sandfäule -->
|
||||||
</spell>
|
</spell>
|
||||||
<spell name="create_potion_p3" type="tybied" ship="true" rank="5" level="7>
|
<spell name="create_potion_p3" type="tybied" ship="true" rank="5" level="7">
|
||||||
<!-- Schaffenstrunk -->
|
<!-- Schaffenstrunk -->
|
||||||
<function name="cast" value="lua_castspell"/>
|
<function name="cast" value="lua_castspell"/>
|
||||||
<resource name="aura" amount="4" cost="linear"/>
|
<resource name="aura" amount="4" cost="linear"/>
|
||||||
|
@ -424,7 +424,7 @@
|
||||||
<resource name="h18" amount="1" cost="linear"/><!-- Eisblume -->
|
<resource name="h18" amount="1" cost="linear"/><!-- Eisblume -->
|
||||||
<resource name="h9" amount="1" cost="linear"/><!-- Wasserfinder -->
|
<resource name="h9" amount="1" cost="linear"/><!-- Wasserfinder -->
|
||||||
</spell>
|
</spell>
|
||||||
<spell name="create_potion_p13" type="tybied" ship="true" rank="5" level="9>
|
<spell name="create_potion_p13" type="tybied" ship="true" rank="5" level="9">
|
||||||
<!-- Elixier der Macht -->
|
<!-- Elixier der Macht -->
|
||||||
<function name="cast" value="lua_castspell"/>
|
<function name="cast" value="lua_castspell"/>
|
||||||
<resource name="aura" amount="5" cost="linear"/>
|
<resource name="aura" amount="5" cost="linear"/>
|
||||||
|
|
|
@ -7,10 +7,20 @@
|
||||||
_a: including article (ein Troll, a troll)
|
_a: including article (ein Troll, a troll)
|
||||||
-->
|
-->
|
||||||
<!--Fort-Ausbaustufen -->
|
<!--Fort-Ausbaustufen -->
|
||||||
<string name="thirdage">
|
<string name="thirdage">
|
||||||
<text locale="de">des dritten Zeitalters</text>
|
<text locale="de">des dritten Zeitalters</text>
|
||||||
<text locale="en">the third age</text>
|
<text locale="en">the third age</text>
|
||||||
</string>
|
</string>
|
||||||
|
|
||||||
|
<string name="rep_crossbow">
|
||||||
|
<text locale="de">Repetierarmbrust</text>
|
||||||
|
<text locale="en">repeating crossbow</text>
|
||||||
|
</string>
|
||||||
|
<string name="rep_crossbow_p">
|
||||||
|
<text locale="de">Repetierarmbrüste</text>
|
||||||
|
<text locale="en">repeating crossbows</text>
|
||||||
|
</string>
|
||||||
|
|
||||||
<string name="guardhouse">
|
<string name="guardhouse">
|
||||||
<text locale="de">Wachstube</text>
|
<text locale="de">Wachstube</text>
|
||||||
<text locale="en">guard house</text>
|
<text locale="en">guard house</text>
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
<xi:include href="../weapons/bow.xml"/>
|
<xi:include href="../weapons/bow.xml"/>
|
||||||
<xi:include href="../weapons/catapult.xml"/>
|
<xi:include href="../weapons/catapult.xml"/>
|
||||||
<xi:include href="../weapons/crossbow.xml"/>
|
<xi:include href="../weapons/crossbow.xml"/>
|
||||||
|
<xi:include href="../weapons/rep_crossbow.xml"/>
|
||||||
<xi:include href="../weapons/firesword.xml"/>
|
<xi:include href="../weapons/firesword.xml"/>
|
||||||
<xi:include href="../weapons/greatbow-2.xml"/>
|
<xi:include href="../weapons/greatbow-2.xml"/>
|
||||||
<xi:include href="../weapons/greatsword-2.xml"/>
|
<xi:include href="../weapons/greatsword-2.xml"/>
|
||||||
|
|
15
src/res/weapons/rep_crossbow.xml
Normal file
15
src/res/weapons/rep_crossbow.xml
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
<?xml version="1.0"?>
|
||||||
|
<resource name="rep_crossbow">
|
||||||
|
<item weight="100">
|
||||||
|
<function name="canuse" value="lua_canuse_item"/>
|
||||||
|
<construction skill="weaponsmithing" minskill="3" reqsize="1">
|
||||||
|
<modifier function="mod_dwarves_only"/>
|
||||||
|
<requirement type="log" quantity="1"/>
|
||||||
|
</construction>
|
||||||
|
<weapon armorpiercing="true" pierce="true" missile="true" skill="crossbow" offmod="0" defmod="0" reload="1">
|
||||||
|
<damage type="rider" value="4d3+3"/>
|
||||||
|
<damage type="footman" value="4d3+3"/>
|
||||||
|
<modifier type="missile_target" value="2"/>
|
||||||
|
</weapon>
|
||||||
|
</item>
|
||||||
|
</resource>
|
|
@ -6,7 +6,7 @@ function item_canuse(u, iname)
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if iname=="towershield" then
|
if iname=="towershield" or iname=="rep_crossbow" then
|
||||||
-- only dwarves allowed to use towershield
|
-- only dwarves allowed to use towershield
|
||||||
return u.race=="dwarf"
|
return u.race=="dwarf"
|
||||||
end
|
end
|
||||||
|
|
|
@ -345,6 +345,32 @@ local function spells_csv()
|
||||||
fail = 1
|
fail = 1
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function test_market()
|
||||||
|
free_game()
|
||||||
|
local r
|
||||||
|
for x = -1, 1 do for y = -1, 1 do
|
||||||
|
r = region.create(x, y, "plain")
|
||||||
|
r.peasants = 5000
|
||||||
|
end end
|
||||||
|
r = get_region(0, 0)
|
||||||
|
local b = building.create(r, "market")
|
||||||
|
b.size = 10
|
||||||
|
local f = faction.create("enno@eressea.de", "human", "de")
|
||||||
|
f.id = 42
|
||||||
|
local u = unit.create(f, r, 1)
|
||||||
|
u.building = b
|
||||||
|
u:add_item("money", u.number * 10000)
|
||||||
|
for i = 0, 5 do
|
||||||
|
local rn = r:next(i)
|
||||||
|
end
|
||||||
|
process_orders()
|
||||||
|
local len = 0
|
||||||
|
for i in u.items do
|
||||||
|
len = len + 1
|
||||||
|
end
|
||||||
|
assert(len>1)
|
||||||
|
end
|
||||||
|
|
||||||
function test_storage()
|
function test_storage()
|
||||||
free_game()
|
free_game()
|
||||||
local r = region.create(0, 0, "plain")
|
local r = region.create(0, 0, "plain")
|
||||||
|
@ -385,10 +411,11 @@ tests = {
|
||||||
["produce"] = test_produce,
|
["produce"] = test_produce,
|
||||||
["rename"] = test_rename,
|
["rename"] = test_rename,
|
||||||
["recruit"] = test_recruit,
|
["recruit"] = test_recruit,
|
||||||
["spells"] = test_spells
|
["spells"] = test_spells,
|
||||||
|
["storage"] = test_storage
|
||||||
}
|
}
|
||||||
mytests = {
|
mytests = {
|
||||||
["storage"] = test_storage
|
["market"] = test_market
|
||||||
}
|
}
|
||||||
fail = 0
|
fail = 0
|
||||||
for k, v in pairs(mytests) do
|
for k, v in pairs(mytests) do
|
||||||
|
@ -403,7 +430,7 @@ end
|
||||||
|
|
||||||
-- spells_csv()
|
-- spells_csv()
|
||||||
|
|
||||||
if fail > 0 then
|
if true or fail > 0 then
|
||||||
print(fail .. " tests failed.")
|
print(fail .. " tests failed.")
|
||||||
io.stdin:read()
|
io.stdin:read()
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue