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) {
|
||||
region * r2 = rconnect(r, d);
|
||||
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--) {
|
||||
int n = rng_int() % nmarkets;
|
||||
unit * u = markets[n];
|
||||
item * items;
|
||||
attrib * a = a_find(u->attribs, &at_market);
|
||||
if (a==NULL) {
|
||||
unit_list * ulist = malloc(sizeof(unit_list));
|
||||
a = a_add(&u->attribs, a_new(&at_market));
|
||||
ulist->next = traders;
|
||||
ulist->data = u;
|
||||
traders = ulist;
|
||||
if (nmarkets) {
|
||||
while (lux && numlux--) {
|
||||
int n = rng_int() % nmarkets;
|
||||
unit * u = markets[n];
|
||||
item * items;
|
||||
attrib * a = a_find(u->attribs, &at_market);
|
||||
if (a==NULL) {
|
||||
unit_list * ulist = malloc(sizeof(unit_list));
|
||||
a = a_add(&u->attribs, a_new(&at_market));
|
||||
ulist->next = traders;
|
||||
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;
|
||||
i_change(&items, lux, 1);
|
||||
a->data.v = items;
|
||||
/* give 1 luxury */
|
||||
}
|
||||
while (herb && numherbs--) {
|
||||
int n = rng_int() % nmarkets;
|
||||
unit * u = markets[n];
|
||||
item * items;
|
||||
attrib * a = a_find(u->attribs, &at_market);
|
||||
if (a==NULL) {
|
||||
unit_list * ulist = malloc(sizeof(unit_list));
|
||||
a = a_add(&u->attribs, a_new(&at_market));
|
||||
ulist->next = traders;
|
||||
ulist->data = u;
|
||||
traders = ulist;
|
||||
while (herb && numherbs--) {
|
||||
int n = rng_int() % nmarkets;
|
||||
unit * u = markets[n];
|
||||
item * items;
|
||||
attrib * a = a_find(u->attribs, &at_market);
|
||||
if (a==NULL) {
|
||||
unit_list * ulist = malloc(sizeof(unit_list));
|
||||
a = a_add(&u->attribs, a_new(&at_market));
|
||||
ulist->next = traders;
|
||||
ulist->data = u;
|
||||
traders = ulist;
|
||||
}
|
||||
items = (item *)a->data.v;
|
||||
i_change(&items, herb, 1);
|
||||
a->data.v = items;
|
||||
/* 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);
|
||||
item * items = a->data.v;
|
||||
|
||||
a->data.v = NULL;
|
||||
while (items) {
|
||||
item * itm = items;
|
||||
items = itm->next;
|
||||
|
@ -159,7 +162,10 @@ void do_markets(void)
|
|||
if (itm->number) {
|
||||
ADDMSG(&u->faction->msgs, msg_message("buyamount",
|
||||
"unit amount resource", u, itm->number, itm->type->rtype));
|
||||
itm->next = NULL;
|
||||
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;
|
||||
}
|
||||
|
||||
b->flags = BLD_WORKING|BLD_MAINTAINED;
|
||||
b->no = newcontainerid();
|
||||
bhash(b);
|
||||
|
||||
|
|
|
@ -599,7 +599,7 @@ static void
|
|||
write_spells(void)
|
||||
{
|
||||
struct locale * loc = find_locale("de");
|
||||
FILE * F = fopen("spells.txt", "w");
|
||||
FILE * F = fopen("spells.csv", "w");
|
||||
spell_list * spl = spells;
|
||||
for (;spl;spl=spl->next) {
|
||||
const spell * sp = spl->data;
|
||||
|
@ -615,6 +615,37 @@ write_spells(void)
|
|||
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
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
|
@ -622,6 +653,7 @@ main(int argc, char *argv[])
|
|||
char * lc_ctype;
|
||||
char * lc_numeric;
|
||||
lua_State * luaState = lua_init();
|
||||
static int write_csv = 1;
|
||||
|
||||
setup_signal_handler();
|
||||
|
||||
|
@ -650,9 +682,10 @@ main(int argc, char *argv[])
|
|||
kernel_init();
|
||||
game_init();
|
||||
|
||||
if (0)
|
||||
if (write_csv) {
|
||||
write_skills();
|
||||
write_spells();
|
||||
|
||||
}
|
||||
/* run the main script */
|
||||
if (luafile==NULL) lua_console(luaState);
|
||||
else {
|
||||
|
|
|
@ -118,6 +118,15 @@ static int tolua_region_get_flag(lua_State* tolua_S)
|
|||
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)
|
||||
{
|
||||
region* self = (region*)tolua_tousertype(tolua_S, 1, 0);
|
||||
|
@ -230,6 +239,7 @@ tolua_region_create(lua_State* tolua_S)
|
|||
if (result) {
|
||||
terraform_region(result, terrain);
|
||||
}
|
||||
fix_demand(result);
|
||||
|
||||
tolua_pushusertype(tolua_S, result, "region");
|
||||
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, "get_flag", tolua_region_get_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, "set_key", tolua_region_setkey);
|
||||
|
|
|
@ -40,10 +40,9 @@
|
|||
<skill name="herbalism" modifier="-2"/>
|
||||
<skill name="melee" speed="+5"/>
|
||||
<skill name="mining" modifier="1"/>
|
||||
<skill name="polearm" speed="+5"/>
|
||||
<skill name="quarrying" modifier="1"/>
|
||||
<skill name="riding" modifier="-99"/>
|
||||
<skill name="sailing" modifier="-1"/>
|
||||
<skill name="spear" speed="+5"/>
|
||||
<skill name="stamina" speed="0"/>
|
||||
<skill name="shipcraft" modifier="-1"/>
|
||||
<skill name="tactics" modifier="1"/>
|
||||
|
@ -159,7 +158,7 @@
|
|||
<skill name="melee" modifier="1"/>
|
||||
<skill name="mining" modifier="1"/>
|
||||
<skill name="quarrying" modifier="2"/>
|
||||
<skill name="riding" modifier="-2"/>
|
||||
<skill name="riding" modifier="-99"/>
|
||||
<skill name="roadwork" modifier="2"/>
|
||||
<skill name="sailing" modifier="-1"/>
|
||||
<skill name="shipcraft" modifier="-1"/>
|
||||
|
|
|
@ -405,7 +405,7 @@
|
|||
<resource name="h18" amount="1" cost="linear"/><!-- Eisblume -->
|
||||
<resource name="h11" amount="1" cost="linear"/><!-- Sandfäule -->
|
||||
</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 -->
|
||||
<function name="cast" value="lua_castspell"/>
|
||||
<resource name="aura" amount="4" cost="linear"/>
|
||||
|
@ -424,7 +424,7 @@
|
|||
<resource name="h18" amount="1" cost="linear"/><!-- Eisblume -->
|
||||
<resource name="h9" amount="1" cost="linear"/><!-- Wasserfinder -->
|
||||
</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 -->
|
||||
<function name="cast" value="lua_castspell"/>
|
||||
<resource name="aura" amount="5" cost="linear"/>
|
||||
|
|
|
@ -7,10 +7,20 @@
|
|||
_a: including article (ein Troll, a troll)
|
||||
-->
|
||||
<!--Fort-Ausbaustufen -->
|
||||
<string name="thirdage">
|
||||
<text locale="de">des dritten Zeitalters</text>
|
||||
<text locale="en">the third age</text>
|
||||
</string>
|
||||
<string name="thirdage">
|
||||
<text locale="de">des dritten Zeitalters</text>
|
||||
<text locale="en">the third age</text>
|
||||
</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">
|
||||
<text locale="de">Wachstube</text>
|
||||
<text locale="en">guard house</text>
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
<xi:include href="../weapons/bow.xml"/>
|
||||
<xi:include href="../weapons/catapult.xml"/>
|
||||
<xi:include href="../weapons/crossbow.xml"/>
|
||||
<xi:include href="../weapons/rep_crossbow.xml"/>
|
||||
<xi:include href="../weapons/firesword.xml"/>
|
||||
<xi:include href="../weapons/greatbow-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
|
||||
end
|
||||
end
|
||||
if iname=="towershield" then
|
||||
if iname=="towershield" or iname=="rep_crossbow" then
|
||||
-- only dwarves allowed to use towershield
|
||||
return u.race=="dwarf"
|
||||
end
|
||||
|
|
|
@ -345,6 +345,32 @@ local function spells_csv()
|
|||
fail = 1
|
||||
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()
|
||||
free_game()
|
||||
local r = region.create(0, 0, "plain")
|
||||
|
@ -385,10 +411,11 @@ tests = {
|
|||
["produce"] = test_produce,
|
||||
["rename"] = test_rename,
|
||||
["recruit"] = test_recruit,
|
||||
["spells"] = test_spells
|
||||
["spells"] = test_spells,
|
||||
["storage"] = test_storage
|
||||
}
|
||||
mytests = {
|
||||
["storage"] = test_storage
|
||||
["market"] = test_market
|
||||
}
|
||||
fail = 0
|
||||
for k, v in pairs(mytests) do
|
||||
|
@ -403,7 +430,7 @@ end
|
|||
|
||||
-- spells_csv()
|
||||
|
||||
if fail > 0 then
|
||||
if true or fail > 0 then
|
||||
print(fail .. " tests failed.")
|
||||
io.stdin:read()
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue