- multiplayer region stealth-mode

- fishing Mk. 1
This commit is contained in:
Enno Rehling 2009-07-07 14:09:20 +00:00
parent dd67aea012
commit 0ca69bd8f4
16 changed files with 137 additions and 50 deletions

View File

@ -24,36 +24,36 @@
#include <string.h>
attrib_type at_racename = {
"racename", NULL, a_finalizestring, NULL, a_writestring, a_readstring
"racename", NULL, a_finalizestring, NULL, a_writestring, a_readstring
};
const char *
get_racename(attrib * alist)
{
attrib * a = a_find(alist, &at_racename);
if (a) return (const char *)a->data.v;
return NULL;
attrib * a = a_find(alist, &at_racename);
if (a) return (const char *)a->data.v;
return NULL;
}
void
set_racename(attrib ** palist, const char * name)
{
attrib * a = a_find(*palist, &at_racename);
if (!a && name) {
a = a_add(palist, a_new(&at_racename));
a->data.v = strdup(name);
} else if (a && !name) {
a_remove(palist, a);
} else if (a) {
if (strcmp(a->data.v, name)!=0) {
free(a->data.v);
a->data.v = strdup(name);
}
}
attrib * a = a_find(*palist, &at_racename);
if (!a && name) {
a = a_add(palist, a_new(&at_racename));
a->data.v = strdup(name);
} else if (a && !name) {
a_remove(palist, a);
} else if (a) {
if (strcmp(a->data.v, name)!=0) {
free(a->data.v);
a->data.v = strdup(name);
}
}
}
void
init_racename(void)
{
at_register(&at_racename);
at_register(&at_racename);
}

View File

@ -3029,7 +3029,7 @@ expandwork(region * r, request * work_begin, request * work_end, int maxwork)
{
int earnings;
/* n: verbleibende Einnahmen */
/* m: maximale Arbeiter */
/* fishes: maximale Arbeiter */
int jobs = maxwork;
int p_wage = wage(r, NULL, NULL);
request *o;
@ -3241,6 +3241,27 @@ peasant_taxes(region * r)
}
}
static void fishing(region * r) {
ship * sh;
for (sh=r->ships;sh;sh=sh->next) {
if (sh->type->fishing>0) {
unit * u = captain(sh);
if (u) {
int weight, cabins;
int cap = shipcapacity(sh);
getshipweight(sh, &weight, &cabins);
if (cap>weight) {
int fishes = min(cap-weight, sh->type->fishing*i_silver->weight);
fishes /= i_silver->weight;
i_change(&u->items, i_silver, fishes);
ADDMSG(&u->faction->msgs, msg_message("income_fishing",
"unit region amount", u, r, fishes));
}
}
}
}
}
void
produce(void)
{
@ -3274,6 +3295,9 @@ produce(void)
peasant_taxes(r);
}
if (r->ships && fval(r->terrain, SEA_REGION)) {
fishing(r);
}
buyorders = 0;
sellorders = 0;
working = 0;

View File

@ -856,7 +856,7 @@ move_iceberg(region *r)
for (sh = r->ships; sh;) {
shn = sh->next;
if (fval(sh, SF_SELECT)) {
u = captain(sh, r);
u = captain(sh);
if (sh->damage>=sh->size * DAMAGE_SCALE) {
if (u!=NULL) {
ADDMSG(&u->faction->msgs, msg_message("overrun_by_iceberg_des",

View File

@ -1464,7 +1464,7 @@ travel_route(unit * u, const region_list * route_begin, const region_list * rout
}
/* terrain is marked as forbidden (curse, etc) */
if (fval(next->terrain, FORBIDDEN_REGION)) {
if (fval(next, RF_BLOCKED) || fval(next->terrain, FORBIDDEN_REGION)) {
ADDMSG(&u->faction->msgs, msg_message("detectforbidden",
"unit region", u, next));
break;

View File

@ -33,22 +33,22 @@
boolean
allowed_swim(const region * src, const region * r)
{
if (fval(r->terrain, SWIM_INTO)) return true;
return false;
if (fval(r->terrain, SWIM_INTO)) return true;
return false;
}
boolean
allowed_walk(const region * src, const region * r)
{
if (fval(r->terrain, WALK_INTO)) return true;
return false;
if (fval(r->terrain, WALK_INTO)) return true;
return false;
}
boolean
allowed_fly(const region * src, const region * r)
{
if (fval(r->terrain, FLY_INTO)) return true;
return false;
if (fval(r->terrain, FLY_INTO)) return true;
return false;
}
typedef struct node {

View File

@ -909,7 +909,8 @@ r_demand(const region * r, const luxury_type * ltype)
}
const char *
rname(const region * r, const struct locale * lang) {
rname(const region * r, const struct locale * lang)
{
if (r->land) {
return r->land->name;
}

View File

@ -153,11 +153,11 @@ damage_ship(ship * sh, double percent)
}
unit *
captain(ship *sh, region *r)
captain(ship *sh)
{
unit *u;
for(u = r->units; u; u = u->next)
for(u = sh->region->units; u; u = u->next)
if(u->ship == sh && fval(u, UFL_OWNER)) return u;
return NULL;

View File

@ -43,6 +43,8 @@ typedef struct ship_type {
int minskill; /* min. skill to sail this (crew) */
int sumskill; /* min. sum of crew+captain */
int fishing; /* weekly income from fishing */
int at_bonus; /* Verändert den Angriffsskill (default: 0)*/
int df_bonus; /* Verändert den Verteidigungskill (default: 0)*/
float tac_bonus;
@ -87,7 +89,7 @@ typedef struct ship {
} ship;
extern void damage_ship(ship *sh, double percent);
extern struct unit *captain(ship *sh, struct region *r);
extern struct unit *captain(ship *sh);
extern struct unit *shipowner(const struct ship * sh);
extern const char * shipname(const struct ship * self);
extern int shipcapacity(const struct ship * sh);

View File

@ -124,6 +124,13 @@ oldterrain(const struct terrain_type * terrain)
const char *
terrain_name(const struct region * r)
{
if (r->attribs) {
attrib * a = a_find(r->attribs, &at_racename);
if (a) {
return get_racename(a);
}
}
if (r->terrain->name!=NULL) {
return r->terrain->name(r);
} else if (fval(r->terrain, SEA_REGION)) {

View File

@ -536,6 +536,7 @@ parse_ships(xmlDocPtr doc)
st->damage = xml_fvalue(node, "damage", 0.0);
if (xml_bvalue(node, "fly", false)) st->flags |= SFL_FLY;
if (xml_bvalue(node, "opensea", false)) st->flags |= SFL_OPENSEA;
st->fishing = xml_ivalue(node, "fishing", 0);
st->minskill = xml_ivalue(node, "minskill", 0);
st->range = xml_ivalue(node, "range", 0);
st->storm = xml_fvalue(node, "storm", 1.0);

View File

@ -16,6 +16,7 @@ without prior permission by the authors of Eressea.
#include "bind_ship.h"
#include "bind_building.h"
#include <kernel/eressea.h>
#include <kernel/region.h>
#include <kernel/resources.h>
#include <kernel/unit.h>
@ -28,6 +29,7 @@ without prior permission by the authors of Eressea.
#include <kernel/terrain.h>
#include <modules/autoseed.h>
#include <attributes/key.h>
#include <attributes/racename.h>
#include <util/attrib.h>
#include <util/base36.h>
@ -36,6 +38,8 @@ without prior permission by the authors of Eressea.
#include <lua.h>
#include <tolua.h>
#include <assert.h>
int tolua_regionlist_next(lua_State *L)
{
region** region_ptr = (region **)lua_touserdata(L, lua_upvalueindex(1));
@ -80,6 +84,31 @@ tolua_region_get_terrain(lua_State* L)
return 1;
}
static int
tolua_region_get_terrainname(lua_State* L)
{
region* self = (region*) tolua_tousertype(L, 1, 0);
attrib * a = a_find(self->attribs, &at_racename);
if (a) {
tolua_pushstring(L, get_racename(a));
return 1;
}
return 0;
}
static int
tolua_region_set_terrainname(lua_State* L)
{
region* self = (region*) tolua_tousertype(L, 1, 0);
const char * name = tolua_tostring(L, 2, 0);
if (name==NULL) {
a_removeall(&self->attribs, &at_racename);
} else {
set_racename(&self->attribs, name);
}
return 0;
}
static int tolua_region_get_info(lua_State* L)
{
region* self = (region*) tolua_tousertype(L, 1, 0);
@ -132,7 +161,7 @@ static int tolua_region_set_flag(lua_State* L)
{
region* self = (region*)tolua_tousertype(L, 1, 0);
int bit = (int)tolua_tonumber(L, 2, 0);
int set = tolua_toboolean(L, 3, 0);
int set = tolua_toboolean(L, 3, 1);
if (set) self->flags |= (1<<bit);
else self->flags &= ~(1<<bit);
@ -473,6 +502,8 @@ tolua_region_open(lua_State* L)
tolua_function(L, "set_flag", tolua_region_set_flag);
tolua_function(L, "next", tolua_region_get_adj);
tolua_variable(L, "terrain_name", &tolua_region_get_terrainname, &tolua_region_set_terrainname);
tolua_function(L, "get_key", tolua_region_getkey);
tolua_function(L, "set_key", tolua_region_setkey);
#if 0

View File

@ -1,6 +1,6 @@
<?xml version="1.0"?>
<ships>
<ship name="canoe" range="3" storm="1.00" damage="1.00" cabins="2" cargo="2000" cptskill="1" minskill="1" sumskill="2" opensea="no">
<ship name="canoe" range="3" storm="1.00" fishing="20" damage="1.00" cabins="2" cargo="2000" cptskill="1" minskill="1" sumskill="2" opensea="no">
<coast terrain="ocean"/>
<coast terrain="plain"/>
<coast terrain="swamp"/>
@ -17,7 +17,7 @@
</construction>
</ship>
<ship name="raft" range="1" storm="1.00" damage="1.00" cabins="5" cargo="50000" cptskill="1" minskill="1" sumskill="5" opensea="no">
<ship name="raft" range="1" storm="1.00" fishing="20" damage="1.00" cabins="5" cargo="50000" cptskill="1" minskill="1" sumskill="5" opensea="no">
<coast terrain="ocean"/>
<coast terrain="plain"/>
<coast terrain="swamp"/>
@ -27,7 +27,7 @@
</construction>
</ship>
<ship name="cutter" range="2" storm="1.00" damage="1.00" cabins="5" cargo="5000" cptskill="2" minskill="1" sumskill="5" opensea="yes">
<ship name="cutter" range="2" storm="1.00" fishing="20" damage="1.00" cabins="5" cargo="5000" cptskill="2" minskill="1" sumskill="5" opensea="yes">
<coast terrain="ocean"/>
<coast terrain="plain"/>
<coast terrain="swamp"/>
@ -44,7 +44,7 @@
</construction>
</ship>
<ship name="barge" range="3" storm="1.00" damage="1.00" cabins="10" cargo="5000" cptskill="2" minskill="1" sumskill="5" opensea="no">
<ship name="barge" range="3" storm="1.00" fishing="20" damage="1.00" cabins="10" cargo="5000" cptskill="2" minskill="1" sumskill="5" opensea="no">
<coast terrain="ocean"/>
<coast terrain="plain"/>
<coast terrain="swamp"/>
@ -62,7 +62,7 @@
</ship>
<ship name="royalbarge" range="5" storm="0.25" damage="1.00" cabins="10" cargo="5000" cptskill="5" minskill="1" sumskill="10" opensea="no">
<ship name="royalbarge" range="5" storm="0.25" fishing="20" damage="1.00" cabins="10" cargo="5000" cptskill="5" minskill="1" sumskill="10" opensea="no">
<coast terrain="ocean"/>
<coast terrain="plain"/>
<coast terrain="swamp"/>
@ -80,7 +80,7 @@
</construction>
</ship>
<ship name="catamaran" range="7" storm="0.25" damage="1.00" cabins="20" cargo="10000" cptskill="7" minskill="1" sumskill="20" opensea="yes">
<ship name="catamaran" range="7" storm="0.25" fishing="20" damage="1.00" cabins="20" cargo="10000" cptskill="7" minskill="1" sumskill="20" opensea="yes">
<coast terrain="ocean"/>
<coast terrain="plain"/>
<construction skill="shipcraft" minskill="8" maxsize="30" reqsize="1">
@ -90,7 +90,7 @@
</ship>
<ship name="cog" range="4" storm="0.50" damage="1.00" cabins="50" cargo="200000" cptskill="4" minskill="1" sumskill="20" opensea="yes">
<ship name="cog" range="4" storm="0.50" fishing="20" damage="1.00" cabins="50" cargo="200000" cptskill="4" minskill="1" sumskill="20" opensea="yes">
<coast terrain="ocean"/>
<coast terrain="plain"/>
<construction skill="shipcraft" minskill="4" maxsize="100" reqsize="1">
@ -98,7 +98,7 @@
</construction>
</ship>
<ship name="caravel" range="4" storm="0.50" damage="1.00" cabins="150" cargo="600000" cptskill="6" minskill="1" sumskill="30" opensea="yes">
<ship name="caravel" range="4" storm="0.50" fishing="20" damage="1.00" cabins="150" cargo="600000" cptskill="6" minskill="1" sumskill="30" opensea="yes">
<coast terrain="ocean"/>
<coast terrain="plain"/>
<construction skill="shipcraft" minskill="6" maxsize="300" reqsize="1">
@ -107,7 +107,7 @@
</ship>
<ship name="frigate" range="4" storm="1.00" damage="1.00" cabins="110" cargo="100000" cptskill="5" minskill="1" sumskill="40" opensea="yes">
<ship name="frigate" range="4" storm="1.00" fishing="20" damage="1.00" cabins="110" cargo="100000" cptskill="5" minskill="1" sumskill="40" opensea="yes">
<modifier type="defense" value="+2"/>
<coast terrain="ocean"/>
<coast terrain="plain"/>
@ -117,7 +117,7 @@
</construction>
</ship>
<ship name="galleon" range="4" storm="1.00" damage="1.00" cabins="310" cargo="300000" cptskill="7" minskill="1" sumskill="60" opensea="yes">
<ship name="galleon" range="4" storm="1.00" fishing="20" damage="1.00" cabins="310" cargo="300000" cptskill="7" minskill="1" sumskill="60" opensea="yes">
<modifier type="defense" value="+2"/>
<coast terrain="ocean"/>
<coast terrain="plain"/>
@ -128,7 +128,7 @@
</ship>
<ship name="dragonship" range="6" storm="1.00" damage="1.00" cabins="110" cargo="50000" cptskill="5" minskill="1" sumskill="60" opensea="yes">
<ship name="dragonship" range="6" storm="1.00" fishing="20" damage="1.00" cabins="110" cargo="50000" cptskill="5" minskill="1" sumskill="60" opensea="yes">
<modifier type="attack" value="+1"/>
<modifier type="tactics" factor="2.00"/>
<coast terrain="ocean"/>
@ -139,7 +139,7 @@
</construction>
</ship>
<ship name="trireme" range="6" storm="1.00" damage="1.00" cabins="310" cargo="150000" cptskill="7" minskill="1" sumskill="90" opensea="yes">
<ship name="trireme" range="6" storm="1.00" fishing="20" damage="1.00" cabins="310" cargo="150000" cptskill="7" minskill="1" sumskill="90" opensea="yes">
<modifier type="attack" value="+1"/>
<modifier type="tactics" factor="2.00"/>
<coast terrain="ocean"/>

View File

@ -285,7 +285,7 @@
<function name="cast" value="lua_castspell"/>
<resource name="aura" amount="1" cost="level"/>
</spell>
<spell name="stonegolem" type="gwyrrd" rank="4" level="1" index="32" variable="true">
<spell name="stonegolem" type="gwyrrd" rank="4" level="20" index="32" variable="true">
<!-- Erschaffe Steingolems -->
<resource name="aura" amount="2" cost="level"/>
<resource name="stone" amount="1" cost="level"/>
@ -503,6 +503,7 @@
<resource name="peasant" amount="50" cost="fixed"/>
</spell>
<spell name="raindance" type="common" rank="5" level="3" index="26" ship="true" far="true" variable="true">
<!-- Regentanz -->
<resource name="aura" amount="1" cost="level"/>
</spell>
<spell name="irongolem" type="common" rank="4" level="2" index="33" variable="true">

View File

@ -12,6 +12,18 @@
<text locale="en">the third age</text>
</string>
<string name="rpg_item_1_p">
<text locale="de">Urkunden</text>
<text locale="en">Certificates</text>
</string>
<string name="rpg_item_2_p">
<text locale="de">Nußhälften</text>
<text locale="en">nut halves</text>
</string>
<string name="rpg_item_3_p">
<text locale="de">Flaschengeister</text>
<text locale="en">bottle demons</text>
</string>
<string name="rpg_item_1">
<text locale="de">Pandoras Urkunde für Halbling ehrenhalber, weiblich</text>
<text locale="en">Pandora's Certificate</text>

View File

@ -2638,8 +2638,7 @@
<arg name="amount" type="int"/>
</type>
<text locale="de">"$unit($unit) arbeitet in $region($region) für einen Lohn von $int($amount) Silber."</text>
<text locale="fr">"$unit($unit) works in $region($region) for a wage of $int($amount) silver."</text>
<text locale="en">"$unit($unit) works in $region($region) for a wage of $int($amount) silver."</text>
<text locale="en">"In $region($region), $unit($unit) works for a wage of $int($amount) silver."</text>
</message>
<message name="income_entertainment_reduced" section="economy">
<type>
@ -2649,8 +2648,16 @@
<arg name="wanted" type="int"/>
</type>
<text locale="de">"$unit($unit) verdient in $region($region) $int($amount)$if($eq($wanted,$amount),""," statt $int($wanted)") Silber durch Unterhaltung."</text>
<text locale="fr">"$unit($unit) earns only $int($amount) instead of$if($eq($wanted,$amount),""," of$if($eq($wanted,$amount),""," of $int($wanted)") ") in $region($region) with entertainment."</text>
<text locale="en">"$unit($unit) earns only $int($amount) instead of$if($eq($wanted,$amount),""," of$if($eq($wanted,$amount),""," of $int($wanted)") ") in $region($region) with entertainment."</text>
<text locale="en">"In $region($region), $unit($unit) earns only $int($amount) instead of$if($eq($wanted,$amount),""," of$if($eq($wanted,$amount),""," of $int($wanted)") ") with entertainment."</text>
</message>
<message name="income_fishing" section="economy">
<type>
<arg name="unit" type="unit"/>
<arg name="region" type="region"/>
<arg name="amount" type="int"/>
</type>
<text locale="de">"$unit($unit) fängt in $region($region) Fische im Wert von $int($amount) Silber."</text>
<text locale="en">"In $region($region), $unit($unit) catches fish worth $int($amount) silver."</text>
</message>
<message name="income_entertainment" section="economy">
<type>
@ -2707,7 +2714,7 @@
<arg name="amount" type="int"/>
<arg name="wanted" type="int"/>
</type>
<text locale="de">"$unit($unit) treibt Steuern in Höhe von in $region($region) $int($amount)$if($eq($wanted,$amount),""," statt $int($wanted)") Silber ein."</text>
<text locale="de">"$unit($unit) treibt in $region($region) Steuern in Höhe von $int($amount)$if($eq($wanted,$amount),""," statt $int($wanted)") Silber ein."</text>
<text locale="en">"$unit($unit) collects taxes of only $int($amount) instead of$if($eq($wanted,$amount),""," of$if($eq($wanted,$amount),""," of $int($wanted)") ") silver in $region($region)."</text>
</message>
<message name="income_tax" section="economy">
@ -2716,7 +2723,7 @@
<arg name="region" type="region"/>
<arg name="amount" type="int"/>
</type>
<text locale="de">"$unit($unit) treibt Steuern in Höhe von $region($region) $int($amount) Silber ein."</text>
<text locale="de">"$unit($unit) treibt in $region($region) Steuern in Höhe von $int($amount) Silber ein."</text>
<text locale="en">"$unit($unit) collects taxes of $int($amount) silver in $region($region)."</text>
</message>
<message name="income" section="economy">

View File

@ -1,3 +1,4 @@
print("loaded rules.lua")
-- when appending to this, make sure the item has a canuse-function!
local goblin_denied = " plate lance mallornlance greatbow axe greatsword halberd rustyaxe rustyhalberd towershield "
function item_canuse(u, iname)