forked from github/server
New code:
"equipment-sets" in the XML definition files (equipment.xml) can define skills and items for a unit. these can be applied using the equip_unit() function (from both LUA and C). I've rewritten the random first encounters and addplayer() functions to use these. As a result, there's now even less dependency on fixed item types in the source, and I can take more items out.
This commit is contained in:
parent
5358c876d2
commit
49bd595d69
|
@ -18,7 +18,7 @@
|
|||
|
||||
/* tweakable features */
|
||||
#define ENCODE_SPECIAL 1
|
||||
#define RENDER_CRMESSAGES 1
|
||||
#define RENDER_CRMESSAGES
|
||||
|
||||
/* modules include */
|
||||
#include <modules/score.h>
|
||||
|
@ -477,7 +477,7 @@ render_messages(FILE * F, faction * f, message_list *msgs)
|
|||
boolean printed = false;
|
||||
const struct message_type * mtype = m->msg->type;
|
||||
unsigned int hash = hashstring(mtype->name);
|
||||
#if RENDER_CRMESSAGES
|
||||
#ifdef RENDER_CRMESSAGES
|
||||
char nrbuffer[1024*32];
|
||||
nrbuffer[0] = '\0';
|
||||
if (nr_render(m->msg, f->locale, nrbuffer, sizeof(nrbuffer), f)>0 && nrbuffer[0]) {
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
#include <kernel/battle.h>
|
||||
#include <kernel/building.h>
|
||||
#include <kernel/curse.h>
|
||||
#include <kernel/equipment.h>
|
||||
#include <kernel/faction.h>
|
||||
#include <kernel/item.h>
|
||||
#include <kernel/karma.h>
|
||||
|
@ -339,33 +340,7 @@ get_allies(region * r, unit * u)
|
|||
return;
|
||||
newunit = createunit(r, u->faction, rand() % 8 + 2, u->faction->race);
|
||||
set_string(&newunit->name, "Söldner");
|
||||
set_money(newunit, (rand() % 80 + 20) * newunit->number);
|
||||
|
||||
switch (rand() % 4) {
|
||||
case 0:
|
||||
set_level(newunit, SK_MELEE, 1+rand()%3);
|
||||
set_item(newunit, I_SWORD, newunit->number);
|
||||
break;
|
||||
case 1:
|
||||
set_level(newunit, SK_SPEAR, 1+rand()%3);
|
||||
set_item(newunit, I_SPEAR, newunit->number);
|
||||
break;
|
||||
case 2:
|
||||
set_level(newunit, SK_CROSSBOW, 1+rand()%3);
|
||||
set_item(newunit, I_CROSSBOW, newunit->number);
|
||||
break;
|
||||
case 3:
|
||||
set_level(newunit, SK_LONGBOW, 1+rand()%3);
|
||||
set_item(newunit, I_LONGBOW, newunit->number);
|
||||
break;
|
||||
}
|
||||
if (rand() % 100 < 40) {
|
||||
set_item(newunit, I_CHAIN_MAIL, rand() % (newunit->number + 1));
|
||||
}
|
||||
if (rand() % 100 < 30) {
|
||||
set_item(newunit, I_HORSE, newunit->number);
|
||||
set_level(newunit, SK_RIDING, 1+rand()%3);
|
||||
}
|
||||
equip_unit(newunit, get_equipment("random_plain"));
|
||||
break;
|
||||
} else {
|
||||
if (eff_skill(u, SK_LONGBOW, r) < 3
|
||||
|
@ -375,14 +350,7 @@ get_allies(region * r, unit * u)
|
|||
}
|
||||
newunit = createunit(r, u->faction, rand() % 6 + 2, u->faction->race);
|
||||
set_string(&newunit->name, "Waldbewohner");
|
||||
set_money(newunit, (rand() % 20 + 10) * newunit->number);
|
||||
set_level(newunit, SK_LONGBOW, 2+rand()%3);
|
||||
set_item(newunit, I_LONGBOW, newunit->number);
|
||||
set_level(newunit, SK_OBSERVATION, 2+rand()%2);
|
||||
set_level(newunit, SK_STEALTH, 1+rand()%2);
|
||||
if (rand() % 100 < 20) {
|
||||
set_level(newunit, SK_HERBALISM, 1+rand()%2);
|
||||
}
|
||||
equip_unit(newunit, get_equipment("random_forest"));
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -392,10 +360,7 @@ get_allies(region * r, unit * u)
|
|||
}
|
||||
newunit = createunit(r, u->faction, rand() % 6 + 2, u->faction->race);
|
||||
set_string(&newunit->name, "Sumpfbewohner");
|
||||
set_money(newunit, (rand() % 20 + 10) * newunit->number);
|
||||
set_level(newunit, SK_SPEAR, 2+rand()%3);
|
||||
set_item(newunit, I_SPEAR, newunit->number);
|
||||
set_level(newunit, SK_STEALTH, 2+rand()%3);
|
||||
equip_unit(newunit, get_equipment("random_swamp"));
|
||||
break;
|
||||
|
||||
case T_DESERT:
|
||||
|
@ -404,13 +369,7 @@ get_allies(region * r, unit * u)
|
|||
}
|
||||
newunit = createunit(r, u->faction, rand() % 12 + 2, u->faction->race);
|
||||
set_string(&newunit->name, "Berber");
|
||||
set_money(newunit, (rand() % 30 + 20) * newunit->number);
|
||||
set_level(newunit, SK_MELEE, 1+rand()%2);
|
||||
set_item(newunit, I_SWORD, newunit->number);
|
||||
set_level(newunit, SK_TRADE, 1+rand()%3);
|
||||
set_level(newunit, SK_RIDING, 2+rand()%2);
|
||||
set_item(newunit, I_HORSE, newunit->number);
|
||||
set_level(newunit, SK_HORSE_TRAINING, 2+rand()%2);
|
||||
equip_unit(newunit, get_equipment("random_desert"));
|
||||
break;
|
||||
|
||||
case T_HIGHLAND:
|
||||
|
@ -419,9 +378,7 @@ get_allies(region * r, unit * u)
|
|||
}
|
||||
newunit = createunit(r, u->faction, rand() % 8 + 2, u->faction->race);
|
||||
set_string(&newunit->name, "Hochlandbarbaren");
|
||||
set_money(newunit, (rand() % 10 + 20) * newunit->number);
|
||||
set_level(newunit, SK_MELEE, 1+rand()%2);
|
||||
set_item(newunit, I_SWORD, newunit->number);
|
||||
equip_unit(newunit, get_equipment("random_highland"));
|
||||
break;
|
||||
|
||||
case T_MOUNTAIN:
|
||||
|
@ -431,14 +388,8 @@ get_allies(region * r, unit * u)
|
|||
}
|
||||
newunit = createunit(r, u->faction, rand() % 6 + 2, u->faction->race);
|
||||
set_string(&newunit->name, "Bergbewohner");
|
||||
set_money(newunit, (rand() % 40 + 60) * newunit->number);
|
||||
set_level(newunit, SK_MELEE, 2+rand()%2);
|
||||
set_item(newunit, I_SWORD, newunit->number);
|
||||
set_level(newunit, SK_ARMORER, 2+rand()%2);
|
||||
set_level(newunit, SK_TRADE, 1+rand()%3);
|
||||
if (rand() % 100 < 60) {
|
||||
set_item(newunit, I_PLATE_ARMOR, newunit->number);
|
||||
}
|
||||
equip_unit(newunit, get_equipment("random_mountain"));
|
||||
|
||||
break;
|
||||
|
||||
case T_GLACIER:
|
||||
|
@ -448,10 +399,8 @@ get_allies(region * r, unit * u)
|
|||
}
|
||||
newunit = createunit(r, u->faction, rand() % 4 + 2, u->faction->race);
|
||||
set_string(&newunit->name, "Eisleute");
|
||||
set_money(newunit, (rand() % 20 + 20) * newunit->number);
|
||||
set_level(newunit, SK_MELEE, 2+rand()%2);
|
||||
set_item(newunit, I_SWORD, newunit->number);
|
||||
set_level(newunit, SK_ARMORER, 2+rand()%2);
|
||||
equip_unit(newunit, get_equipment("random_glacier"));
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -15,6 +15,8 @@
|
|||
#include <config.h>
|
||||
#include "eressea.h"
|
||||
#include "faction.h"
|
||||
|
||||
#include "equipment.h"
|
||||
#include "unit.h"
|
||||
#include "race.h"
|
||||
#include "region.h"
|
||||
|
@ -142,7 +144,9 @@ addplayer(region *r, faction * f)
|
|||
assert(f->units==NULL);
|
||||
set_ursprung(f, 0, r->x, r->y);
|
||||
u = createunit(r, f, 1, f->race);
|
||||
give_starting_equipment(r, u);
|
||||
equip_unit(u, get_equipment("new_faction"));
|
||||
equip_unit(u, get_equipment(u->race->_name[0]));
|
||||
give_starting_equipment(u);
|
||||
fset(u, UFL_ISNEW);
|
||||
if (f->race == new_race[RC_DAEMON]) {
|
||||
race_t urc;
|
||||
|
|
|
@ -178,6 +178,9 @@
|
|||
<File
|
||||
RelativePath=".\alchemy.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\alliance.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\battle.h">
|
||||
</File>
|
||||
|
@ -199,6 +202,9 @@
|
|||
<File
|
||||
RelativePath=".\curse.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\equipment.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\eressea.h">
|
||||
</File>
|
||||
|
@ -299,9 +305,6 @@
|
|||
<File
|
||||
RelativePath=".\alliance.c">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\alliance.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\battle.c">
|
||||
</File>
|
||||
|
@ -323,6 +326,9 @@
|
|||
<File
|
||||
RelativePath=".\curse.c">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\equipment.c">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\eressea.c">
|
||||
</File>
|
||||
|
|
|
@ -172,118 +172,6 @@ set_show_item(faction *f, item_t i)
|
|||
a->data.v = (void*)olditemtype[i];
|
||||
}
|
||||
|
||||
typedef struct equipment {
|
||||
const struct race * rc;
|
||||
item * items;
|
||||
int skills[MAXSKILLS];
|
||||
struct equipment * next;
|
||||
} equipment;
|
||||
|
||||
static equipment * starting_equipment;
|
||||
|
||||
static equipment *
|
||||
make_equipment(const struct race * rc)
|
||||
{
|
||||
equipment ** eqp = &starting_equipment;
|
||||
while (*eqp) {
|
||||
struct equipment * eq = *eqp;
|
||||
if (eq->rc==rc) break;
|
||||
eqp = &eq->next;
|
||||
}
|
||||
if (*eqp == NULL) {
|
||||
struct equipment * eq = malloc(sizeof(equipment));
|
||||
eq->rc = rc;
|
||||
eq->next = NULL;
|
||||
eq->items = NULL;
|
||||
memset(eq->skills, 0, sizeof(eq->skills));
|
||||
*eqp = eq;
|
||||
} else {
|
||||
struct equipment * eq = *eqp;
|
||||
eq->rc = rc;
|
||||
eq->items = NULL;
|
||||
}
|
||||
return *eqp;
|
||||
}
|
||||
|
||||
void
|
||||
startup_skill(skill_t sk, int value, const struct race * rc)
|
||||
{
|
||||
if (value>0) {
|
||||
equipment * eq = make_equipment(rc);
|
||||
eq->skills[sk] = value;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
startup_equipment(const item_type * itype, int number, const struct race * rc)
|
||||
{
|
||||
if (itype!=NULL && number>0) {
|
||||
equipment * eq = make_equipment(rc);
|
||||
i_change(&eq->items, itype, number);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
give_equipment(unit * u, const struct race * rc)
|
||||
{
|
||||
equipment * eq = starting_equipment;
|
||||
while (eq && eq->rc!=rc) {
|
||||
eq = eq->next;
|
||||
}
|
||||
if (eq) {
|
||||
skill_t sk;
|
||||
item * itm;
|
||||
for (sk=0;sk!=MAXSKILLS;++sk) {
|
||||
if (eq->skills[sk]>0) {
|
||||
set_level(u, sk, eq->skills[sk]);
|
||||
}
|
||||
}
|
||||
for (itm=eq->items;itm!=NULL;itm=itm->next) {
|
||||
i_add(&u->items, i_new(itm->type, itm->number));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
give_starting_equipment(struct region *r, struct unit *u)
|
||||
{
|
||||
give_equipment(u, NULL);
|
||||
give_equipment(u, u->race);
|
||||
|
||||
switch(old_race(u->race)) {
|
||||
case RC_ELF:
|
||||
set_show_item(u->faction, I_FEENSTIEFEL);
|
||||
break;
|
||||
case RC_GOBLIN:
|
||||
set_show_item(u->faction, I_RING_OF_INVISIBILITY);
|
||||
scale_number(u, 10);
|
||||
break;
|
||||
case RC_HUMAN:
|
||||
{
|
||||
building *b = new_building(bt_find("castle"), r, u->faction->locale);
|
||||
b->size = 10;
|
||||
u->building = b;
|
||||
fset(u, UFL_OWNER);
|
||||
}
|
||||
break;
|
||||
case RC_CAT:
|
||||
set_show_item(u->faction, I_RING_OF_INVISIBILITY);
|
||||
break;
|
||||
case RC_AQUARIAN:
|
||||
{
|
||||
ship *sh = new_ship(st_find("boat"), u->faction->locale, r);
|
||||
sh->size = sh->type->construction->maxsize;
|
||||
u->ship = sh;
|
||||
fset(u, UFL_OWNER);
|
||||
}
|
||||
break;
|
||||
case RC_CENTAUR:
|
||||
rsethorses(r, 250+rand()%51+rand()%51);
|
||||
break;
|
||||
}
|
||||
u->hp = unit_max_hp(u);
|
||||
}
|
||||
|
||||
int
|
||||
unit_max_hp(const unit * u)
|
||||
{
|
||||
|
@ -312,6 +200,45 @@ unit_max_hp(const unit * u)
|
|||
return h;
|
||||
}
|
||||
|
||||
void
|
||||
give_starting_equipment(struct unit *u)
|
||||
{
|
||||
struct region *r = u->region;
|
||||
|
||||
switch(old_race(u->race)) {
|
||||
case RC_ELF:
|
||||
set_show_item(u->faction, I_FEENSTIEFEL);
|
||||
break;
|
||||
case RC_GOBLIN:
|
||||
set_show_item(u->faction, I_RING_OF_INVISIBILITY);
|
||||
scale_number(u, 10);
|
||||
break;
|
||||
case RC_HUMAN:
|
||||
{
|
||||
building *b = new_building(bt_find("castle"), r, u->faction->locale);
|
||||
b->size = 10;
|
||||
u->building = b;
|
||||
fset(u, UFL_OWNER);
|
||||
}
|
||||
break;
|
||||
case RC_CAT:
|
||||
set_show_item(u->faction, I_RING_OF_INVISIBILITY);
|
||||
break;
|
||||
case RC_AQUARIAN:
|
||||
{
|
||||
ship *sh = new_ship(st_find("boat"), u->faction->locale, r);
|
||||
sh->size = sh->type->construction->maxsize;
|
||||
u->ship = sh;
|
||||
fset(u, UFL_OWNER);
|
||||
}
|
||||
break;
|
||||
case RC_CENTAUR:
|
||||
rsethorses(r, 250+rand()%51+rand()%51);
|
||||
break;
|
||||
}
|
||||
u->hp = unit_max_hp(u);
|
||||
}
|
||||
|
||||
boolean
|
||||
r_insectstalled(const region * r)
|
||||
{
|
||||
|
|
|
@ -181,9 +181,7 @@ extern int read_race_reference(const struct race ** rp, FILE * F);
|
|||
|
||||
extern const char * raceprefix(const struct unit *u);
|
||||
|
||||
extern void startup_equipment(const struct item_type * itype, int number, const struct race * rc);
|
||||
extern void startup_skill(skill_t sk, int value, const struct race * rc);
|
||||
extern void give_starting_equipment(struct region *r, struct unit *u);
|
||||
extern void give_starting_equipment(struct unit *u);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ without prior permission by the authors of Eressea.
|
|||
|
||||
/* kernel includes */
|
||||
#include "building.h"
|
||||
#include "equipment.h"
|
||||
#include "item.h"
|
||||
#include "message.h"
|
||||
#include "race.h"
|
||||
|
@ -869,9 +870,9 @@ parse_resources(xmlDocPtr doc)
|
|||
}
|
||||
|
||||
static void
|
||||
add_items(xmlNodeSetPtr nsetItems, const race * rc)
|
||||
add_items(equipment * eq, xmlNodeSetPtr nsetItems)
|
||||
{
|
||||
if (nsetItems!=NULL) {
|
||||
if (nsetItems!=NULL && nsetItems->nodeNr>0) {
|
||||
int i;
|
||||
for (i=0;i!=nsetItems->nodeNr;++i) {
|
||||
xmlNodePtr node = nsetItems->nodeTab[i];
|
||||
|
@ -883,22 +884,20 @@ add_items(xmlNodeSetPtr nsetItems, const race * rc)
|
|||
itype = it_find((const char*)property);
|
||||
xmlFree(property);
|
||||
if (itype!=NULL) {
|
||||
int num = 0;
|
||||
property = xmlGetProp(node, BAD_CAST "amount");
|
||||
if (property!=NULL) {
|
||||
num = atoi((const char*)property);
|
||||
equipment_setitem(eq, itype, (const char*)property);
|
||||
xmlFree(property);
|
||||
}
|
||||
startup_equipment(itype, num, rc);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
add_skills(xmlNodeSetPtr nsetSkills, const race * rc)
|
||||
add_skills(equipment * eq, xmlNodeSetPtr nsetSkills)
|
||||
{
|
||||
if (nsetSkills!=NULL) {
|
||||
if (nsetSkills!=NULL && nsetSkills->nodeNr>0) {
|
||||
int i;
|
||||
for (i=0;i!=nsetSkills->nodeNr;++i) {
|
||||
xmlNodePtr node = nsetSkills->nodeTab[i];
|
||||
|
@ -910,18 +909,73 @@ add_skills(xmlNodeSetPtr nsetSkills, const race * rc)
|
|||
sk = sk_find((const char*)property);
|
||||
xmlFree(property);
|
||||
if (sk!=NOSKILL) {
|
||||
int num = 0;
|
||||
property = xmlGetProp(node, BAD_CAST "level");
|
||||
if (property!=NULL) {
|
||||
num = atoi((const char*)property);
|
||||
equipment_setskill(eq, sk, (const char*)property);
|
||||
xmlFree(property);
|
||||
}
|
||||
startup_skill(sk, num, rc);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
add_subsets(xmlDocPtr doc, equipment * eq, xmlNodeSetPtr nsetSkills)
|
||||
{
|
||||
xmlXPathContextPtr xpath = xmlXPathNewContext(doc);
|
||||
if (nsetSkills!=NULL && nsetSkills->nodeNr>0) {
|
||||
int i;
|
||||
|
||||
eq->subsets = calloc(nsetSkills->nodeNr+1, sizeof(subset));
|
||||
for (i=0;i!=nsetSkills->nodeNr;++i) {
|
||||
xmlXPathObjectPtr xpathResult;
|
||||
xmlNodePtr node = nsetSkills->nodeTab[i];
|
||||
xmlChar * property;
|
||||
|
||||
eq->subsets[i].chance = 1.0f;
|
||||
property = xmlGetProp(node, BAD_CAST "chance");
|
||||
if (property!=NULL) {
|
||||
eq->subsets[i].chance = (float)atof((const char *)property);
|
||||
xmlFree(property);
|
||||
}
|
||||
xpath->node = node;
|
||||
xpathResult = xmlXPathEvalExpression(BAD_CAST "set", xpath);
|
||||
if (xpathResult->nodesetval) {
|
||||
xmlNodeSetPtr nsetSets = xpathResult->nodesetval;
|
||||
float totalChance = 0.0f;
|
||||
|
||||
if (nsetSets->nodeNr>0) {
|
||||
int set;
|
||||
eq->subsets[i].sets = calloc(nsetSets->nodeNr+1, sizeof(subsetitem));
|
||||
for (set=0;set!=nsetSets->nodeNr;++set) {
|
||||
xmlNodePtr nodeSet = nsetSets->nodeTab[set];
|
||||
float chance = 1.0f;
|
||||
|
||||
property = xmlGetProp(nodeSet, BAD_CAST "chance");
|
||||
if (property!=NULL) {
|
||||
chance = (float)atof((const char *)property);
|
||||
xmlFree(property);
|
||||
}
|
||||
totalChance += chance;
|
||||
|
||||
property = xmlGetProp(nodeSet, BAD_CAST "name");
|
||||
assert(property!=NULL);
|
||||
eq->subsets[i].sets[set].chance = chance;
|
||||
eq->subsets[i].sets[set].set = create_equipment((const char*)property);
|
||||
xmlFree(property);
|
||||
}
|
||||
}
|
||||
if (totalChance>1.0f) {
|
||||
log_error(("total chance exceeds 1.0: %f in equipment set %s.\n",
|
||||
totalChance, eq->name));
|
||||
}
|
||||
}
|
||||
xmlXPathFreeObject(xpathResult);
|
||||
}
|
||||
}
|
||||
xmlXPathFreeContext(xpath);
|
||||
}
|
||||
|
||||
static int
|
||||
parse_equipment(xmlDocPtr doc)
|
||||
{
|
||||
|
@ -929,31 +983,35 @@ parse_equipment(xmlDocPtr doc)
|
|||
xmlXPathObjectPtr xpathRaces;
|
||||
|
||||
/* reading eressea/races/race */
|
||||
xpathRaces = xmlXPathEvalExpression(BAD_CAST "/eressea/equipment/startup", xpath);
|
||||
xpathRaces = xmlXPathEvalExpression(BAD_CAST "/eressea/equipment/set", xpath);
|
||||
if (xpathRaces->nodesetval) {
|
||||
xmlNodeSetPtr nsetRaces = xpathRaces->nodesetval;
|
||||
int i;
|
||||
|
||||
for (i=0;i!=nsetRaces->nodeNr;++i) {
|
||||
xmlNodePtr node = nsetRaces->nodeTab[i];
|
||||
const struct race * rc = NULL;
|
||||
xmlChar * property = xmlGetProp(node, BAD_CAST "race");
|
||||
xmlXPathObjectPtr xpathResult;
|
||||
xmlChar * property = xmlGetProp(node, BAD_CAST "name");
|
||||
|
||||
if (property!=NULL) {
|
||||
rc = rc_find((const char*)property);
|
||||
assert(rc!=NULL);
|
||||
equipment * eq = create_equipment((const char*)property);
|
||||
xmlXPathObjectPtr xpathResult;
|
||||
|
||||
xpath->node = node;
|
||||
|
||||
xpathResult = xmlXPathEvalExpression(BAD_CAST "item", xpath);
|
||||
add_items(eq, xpathResult->nodesetval);
|
||||
xmlXPathFreeObject(xpathResult);
|
||||
|
||||
xpathResult = xmlXPathEvalExpression(BAD_CAST "skill", xpath);
|
||||
add_skills(eq, xpathResult->nodesetval);
|
||||
xmlXPathFreeObject(xpathResult);
|
||||
|
||||
xpathResult = xmlXPathEvalExpression(BAD_CAST "subset", xpath);
|
||||
add_subsets(doc, eq, xpathResult->nodesetval);
|
||||
xmlXPathFreeObject(xpathResult);
|
||||
|
||||
xmlFree(property);
|
||||
}
|
||||
|
||||
xpath->node = node;
|
||||
xpathResult = xmlXPathEvalExpression(BAD_CAST "item", xpath);
|
||||
add_items(xpathResult->nodesetval, rc);
|
||||
xmlXPathFreeObject(xpathResult);
|
||||
|
||||
xpath->node = node;
|
||||
xpathResult = xmlXPathEvalExpression(BAD_CAST "skill", xpath);
|
||||
add_skills(xpathResult->nodesetval, rc);
|
||||
xmlXPathFreeObject(xpathResult);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
|
||||
// kernel includes
|
||||
#include <kernel/alliance.h>
|
||||
#include <kernel/equipment.h>
|
||||
#include <kernel/faction.h>
|
||||
#include <kernel/item.h>
|
||||
#include <kernel/plane.h>
|
||||
|
@ -38,13 +39,11 @@
|
|||
using namespace luabind;
|
||||
|
||||
static int
|
||||
lua_addequipment(const char * iname, int number, const char * rcname)
|
||||
lua_addequipment(const char * eqname, const char * iname, const char * value)
|
||||
{
|
||||
race * rc = rc_find(rcname);
|
||||
const struct item_type * itype = it_find(iname);
|
||||
if (rc==NULL && strlen(rcname)>0) return -1;
|
||||
if (itype==NULL) return -1;
|
||||
startup_equipment(itype, number, rc);
|
||||
equipment_setitem(create_equipment(eqname), itype, value);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -212,6 +211,12 @@ lua_writereports(void)
|
|||
return reports();
|
||||
}
|
||||
|
||||
static void
|
||||
lua_equipunit(unit& u, const char * eqname)
|
||||
{
|
||||
equip_unit(&u, get_equipment(eqname));
|
||||
}
|
||||
|
||||
void
|
||||
bind_eressea(lua_State * L)
|
||||
{
|
||||
|
@ -229,10 +234,12 @@ bind_eressea(lua_State * L)
|
|||
def("write_summary", &write_summary),
|
||||
def("read_orders", &readorders),
|
||||
def("process_orders", &process_orders),
|
||||
def("startup_equipment", &lua_addequipment),
|
||||
def("equipment_setitem", &lua_addequipment),
|
||||
def("get_turn", &get_turn),
|
||||
def("remove_empty_units", &remove_empty_units),
|
||||
|
||||
def("equip_unit", &lua_equipunit),
|
||||
|
||||
/* scripted monsters */
|
||||
def("plan_monsters", &lua_planmonsters),
|
||||
def("spawn_braineaters", &spawn_braineaters),
|
||||
|
|
|
@ -1,41 +1,44 @@
|
|||
<?xml version="1.0"?>
|
||||
<equipment>
|
||||
<!-- removed. only used by the mapper's seed function.
|
||||
<item name="conquesttoken" amount="1"/>
|
||||
<item name="log" amount="30"/>
|
||||
<item name="stone" amount="30"/>
|
||||
<item name="money" amount="4200"/>
|
||||
-->
|
||||
<startup race="dwarf">
|
||||
|
||||
<!-- one equipment-set per player-race for the first unit in a faction -->
|
||||
<set name="dwarf">
|
||||
<item name="axe" amount="1"/>
|
||||
<item name="chainmail" amount="1"/>
|
||||
<skill name="sk_melee" level="1"/>
|
||||
</startup>
|
||||
<startup race="elf">
|
||||
</set>
|
||||
|
||||
<set name="elf">
|
||||
<item name="fairyboot" amount="1"/>
|
||||
</startup>
|
||||
<startup race="uruk">
|
||||
</set>
|
||||
|
||||
<set name="uruk">
|
||||
<skill name="sk_spear" level="4"/>
|
||||
<skill name="sk_melee" level="4"/>
|
||||
<skill name="sk_crossbow" level="4"/>
|
||||
<skill name="sk_catapult" level="4"/>
|
||||
<skill name="sk_bow" level="4"/>
|
||||
</startup>
|
||||
<startup race="goblin">
|
||||
</set>
|
||||
|
||||
<set name="goblin">
|
||||
<item name="roi" amount="1"/>
|
||||
</startup>
|
||||
<startup race="troll">
|
||||
</set>
|
||||
|
||||
<set name="troll">
|
||||
<skill name="sk_building" level="1"/>
|
||||
<skill name="sk_perception" level="3"/>
|
||||
<item name="stone" amount="50"/>
|
||||
</startup>
|
||||
<startup race="demon">
|
||||
</set>
|
||||
|
||||
<set name="demon">
|
||||
<skill name="sk_stamina" level="15"/>
|
||||
</startup>
|
||||
<startup race="insect">
|
||||
</set>
|
||||
|
||||
<set name="insect">
|
||||
<item name="nestwarmth" amount="9"/>
|
||||
</startup>
|
||||
<startup race="halfling">
|
||||
</set>
|
||||
|
||||
<set name="halfling">
|
||||
<skill name="sk_trade" level="1"/>
|
||||
<skill name="sk_riding" level="2"/>
|
||||
<item name="horse" amount="2"/>
|
||||
|
@ -47,12 +50,121 @@
|
|||
<item name="oil" amount="5"/>
|
||||
<item name="silk" amount="5"/>
|
||||
<item name="incense" amount="5"/>
|
||||
</startup>
|
||||
<startup race="cat">
|
||||
</set>
|
||||
|
||||
<set name="cat">
|
||||
<item name="roi" amount="1"/>
|
||||
</startup>
|
||||
<startup race="aquarian">
|
||||
</set>
|
||||
|
||||
<set name="aquarian">
|
||||
<skill name="sk_sailing" level="1"/>
|
||||
</startup>
|
||||
</set>
|
||||
|
||||
<!-- equipment-sets for random encounters -->
|
||||
<set name="random_desert">
|
||||
<skill name="sk_melee" level="d2"/>
|
||||
<skill name="sk_trade" level="d3"/>
|
||||
<skill name="sk_riding" level="d2+1"/>
|
||||
<skill name="sk_training" level="d2+1"/>
|
||||
<item name="horse" amount="1"/>
|
||||
<item name="sword" amount="1"/>
|
||||
<item name="money" amount="d30+19"/>
|
||||
</set>
|
||||
|
||||
<set name="random_swamp">
|
||||
<skill name="sk_stealth" level="d3+1"/>
|
||||
<skill name="sk_spear" level="d3+1"/>
|
||||
<item name="spear" amount="1"/>
|
||||
<item name="money" amount="d20+9"/>
|
||||
</set>
|
||||
|
||||
<set name="random_glacier">
|
||||
<skill name="sk_armorer" level="d2+1"/>
|
||||
<skill name="sk_melee" level="d2+1"/>
|
||||
<item name="sword" amount="1"/>
|
||||
<item name="money" amount="d20+19"/>
|
||||
</set>
|
||||
|
||||
<set name="random_mountain">
|
||||
<skill name="sk_armorer" level="d2+1"/>
|
||||
<skill name="sk_melee" level="d2+1"/>
|
||||
<skill name="sk_trade" level="d3"/>
|
||||
<item name="sword" amount="1"/>
|
||||
<item name="money" amount="d40+59"/>
|
||||
<subset chance="0.6">
|
||||
<set name="random_plate"/>
|
||||
</subset>
|
||||
</set>
|
||||
|
||||
<set name="random_highland">
|
||||
<skill name="sk_melee" level="d2"/>
|
||||
<item name="sword" amount="1"/>
|
||||
<item name="money" amount="d10+19"/>
|
||||
</set>
|
||||
|
||||
<set name="random_forest">
|
||||
<skill name="sk_stealth" level="d2"/>
|
||||
<skill name="sk_perception" level="d2+1"/>
|
||||
<skill name="sk_bow" level="d3+1"/>
|
||||
<item name="bow" amount="1"/>
|
||||
<item name="money" amount="d20+9"/>
|
||||
<subset chance="0.2">
|
||||
<set name="random_herbalist"/>
|
||||
</subset>
|
||||
</set>
|
||||
|
||||
<set name="random_herbalist">
|
||||
<skill name="sk_herbalism" level="d2"/>
|
||||
</set>
|
||||
|
||||
<set name="random_plain">
|
||||
<item name="money" amount="d80+19"/>
|
||||
<subset>
|
||||
<set name="random_sword" chance="0.25"/>
|
||||
<set name="random_spear" chance="0.25"/>
|
||||
<set name="random_crossbow" chance="0.25"/>
|
||||
<set name="random_bow" chance="0.25"/>
|
||||
</subset>
|
||||
<subset chance="0.4">
|
||||
<set name="random_chain"/>
|
||||
</subset>
|
||||
<subset chance="0.3">
|
||||
<set name="random_rider"/>
|
||||
</subset>
|
||||
</set>
|
||||
|
||||
<set name="random_spear">
|
||||
<skill name="sk_spear" level="d3"/>
|
||||
<item name="spear" amount="1"/>
|
||||
</set>
|
||||
|
||||
<set name="random_sword">
|
||||
<skill name="sk_sword" level="d3"/>
|
||||
<item name="sword" amount="1"/>
|
||||
</set>
|
||||
|
||||
<set name="random_crossbow">
|
||||
<skill name="sk_crossbow" level="d3"/>
|
||||
<item name="crossbow" amount="1"/>
|
||||
</set>
|
||||
|
||||
<set name="random_bow">
|
||||
<skill name="sk_bow" level="d3"/>
|
||||
<item name="bow" amount="1"/>
|
||||
</set>
|
||||
|
||||
<set name="random_plate">
|
||||
<item name="plate" amount="1"/>
|
||||
</set>
|
||||
|
||||
<set name="random_chain">
|
||||
<item name="chainmail" amount="1"/>
|
||||
</set>
|
||||
|
||||
<set name="random_rider">
|
||||
<item name="horse" amount="1"/>
|
||||
<skill name="sk_riding" level="d3"/>
|
||||
</set>
|
||||
|
||||
</equipment>
|
||||
|
||||
|
|
|
@ -20,10 +20,10 @@ end
|
|||
|
||||
function process(orders)
|
||||
-- initialize starting equipment for new players
|
||||
startup_equipment("conquesttoken", 1, "");
|
||||
startup_equipment("wood", 30, "");
|
||||
startup_equipment("stone", 30, "");
|
||||
startup_equipment("money", 4200, "");
|
||||
equipment_setitem("new_faction", "conquesttoken", "1");
|
||||
equipment_setitem("new_faction", "wood", "30");
|
||||
equipment_setitem("new_faction", "stone", "30");
|
||||
equipment_setitem("new_faction", "money", "4200");
|
||||
|
||||
file = "" .. get_turn()
|
||||
if read_game(file)~=0 then
|
||||
|
|
|
@ -54,10 +54,10 @@ end
|
|||
|
||||
function process(orders)
|
||||
-- initialize starting equipment for new players
|
||||
startup_equipment("conquesttoken", 1, "");
|
||||
startup_equipment("log", 30, "");
|
||||
startup_equipment("stone", 30, "");
|
||||
startup_equipment("money", 4200, "");
|
||||
equipment_setitem("new_faction", "conquesttoken", "1");
|
||||
equipment_setitem("new_faction", "log", "30");
|
||||
equipment_setitem("new_faction", "stone", "30");
|
||||
equipment_setitem("new_faction", "money", "4200");
|
||||
|
||||
file = "" .. get_turn()
|
||||
if read_game(file)~=0 then
|
||||
|
|
|
@ -124,7 +124,7 @@ skills = {
|
|||
|
||||
function wdw_setup()
|
||||
-- initialize starting equipment for new players
|
||||
-- startup_equipment("magicskillboost", 1, "")
|
||||
-- equipment_setitem("new_faction", "magicskillboost", "1")
|
||||
|
||||
init_positions()
|
||||
|
||||
|
|
Loading…
Reference in New Issue