neue lua-exporte:

- unit:tostring
- unit:operator==

mehrere wdw-parameter aus defines raus, und ins datenfile rein (traumziel ist, den gleichen server für alle spiele zu nehmen)
This commit is contained in:
Enno Rehling 2004-04-11 15:11:19 +00:00
parent 846f110268
commit 5d559840fa
8 changed files with 177 additions and 115 deletions

View File

@ -84,6 +84,28 @@ attrib_type at_reportspell = {
** TODO: separate castle-appearance from illusion-effects
**/
static double
MagicRegeneration(void)
{
static double value = -1.0;
if (value<0) {
const char * str = get_param(global.parameters, "magic.regeneration");
value = str?atof(str):1.0;
}
return value;
}
static double
MagicPower(void)
{
static double value = -1.0;
if (value<0) {
const char * str = get_param(global.parameters, "magic.power");
value = str?atof(str):1.0;
}
return value;
}
static ship *
findshipr(const region *r, int n)
/* Ein Schiff in einer bestimmten Region finden: */
@ -1009,9 +1031,7 @@ spellpower(region * r, unit * u, spell * sp, int cast_level)
cmistake(u, findorder(u, u->thisorder), 185, MSG_MAGIC);
}
#ifdef MAGICPOWER
force = force * MAGICPOWER;
#endif
force = force * MagicPower();
return max(force, 0);
}
@ -1260,12 +1280,16 @@ do_fumble(castorder *co)
spell * sp = co->sp;
int level = co->level;
int duration;
const char * sp_name = spell_name(sp, u->faction->locale);
ADDMSG(&u->faction->msgs, msg_message("patzer", "unit region spell",
u, r, sp_name));
switch (rand() % 10) {
/* wenn vorhanden spezieller Patzer, ansonsten nix */
case 0:
/* wenn vorhanden spezieller Patzer, ansonsten nix */
sp->patzer(co);
break;
case 1:
/* Kröte */
duration = rand()%level/2;
@ -1285,22 +1309,21 @@ do_fumble(castorder *co)
sprintf(buf, "Eine Botschaft von %s: 'Ups! Quack, Quack!'", unitname(u));
addmessage(r, 0, buf, MSG_MAGIC, ML_MISTAKE);
break;
case 2:
/* temporärer Stufenverlust */
duration = max(rand()%level/2, 2);
c = create_curse(u, &u->attribs, ct_find("skil"), level, duration,
-(level/2), 1);
c->data = (void*)SK_MAGIC;
add_message(&u->faction->msgs,
new_message(u->faction, "patzer2%u:unit%r:region", u, r));
ADDMSG(&u->faction->msgs, msg_message("patzer2", "unit region", u, r));
break;
case 3:
case 4:
/* Spruch schlägt fehl, alle Magiepunkte weg */
set_spellpoints(u, 0);
add_message(&u->faction->msgs, msg_message("patzer3",
"unit region command",
u, r, spell_name(sp, u->faction->locale)));
ADDMSG(&u->faction->msgs, msg_message("patzer3", "unit region command",
u, r, sp_name));
break;
case 5:
@ -1313,7 +1336,7 @@ do_fumble(castorder *co)
"Gestalten kreisen um den Magier und scheinen sich von "
"den magischen Energien des Zaubers zu ernähren. Mit letzter "
"Kraft gelingt es %s dennoch den Spruch zu zaubern.",
unitname(u), spell_name(sp, u->faction->locale), unitname(u));
unitname(u), sp_name, unitname(u));
addmessage(0, u->faction, buf, MSG_MAGIC, ML_WARN);
break;
@ -1325,10 +1348,9 @@ do_fumble(castorder *co)
((nspell_f)sp->sp_function)(co);
sprintf(buf, "%s fühlt sich nach dem Zaubern von %s viel erschöpfter "
"als sonst und hat das Gefühl, dass alle weiteren Zauber deutlich "
"mehr Kraft als normalerweise kosten werden.", unitname(u),
spell_name(sp, u->faction->locale));
"mehr Kraft als normalerweise kosten werden.", unitname(u), sp_name);
addmessage(0, u->faction, buf, MSG_MAGIC, ML_WARN);
countspells(u,3);
countspells(u, 3);
}
return;
@ -1361,9 +1383,7 @@ regeneration(unit * u)
/* Würfeln */
aura = (rand() % d + rand() % d)/2 + 1;
#ifdef MAGICREGEN
aura = (int)(aura * MAGICREGEN);
#endif
aura = (int)(aura * MagicRegeneration());
return aura;
}

View File

@ -25,6 +25,17 @@
#include <assert.h>
#include <string.h>
static double
ResourceFactor(void)
{
static double value = -1.0;
if (value<0) {
const char * str = get_param(global.parameters, "resource.factor");
value = str?atof(str):1.0;
}
return value;
}
void
update_resources(region * r)
{
@ -37,6 +48,16 @@ update_resources(region * r)
extern int dice_rand(const char *s);
static void
update_resource(struct rawmaterial * res, double modifier)
{
double amount = 1 + (res->level-res->startlevel) * res->divisor/100.0;
amount = ResourceFactor() * res->base * amount * modifier;
if (amount<1.0) res->amount = 1;
else res->amount = (int)amount;
assert(res->amount>0);
}
void
terraform_resources(region * r)
{
@ -53,6 +74,7 @@ terraform_resources(region * r)
if (rand()%100 < tdata->rawmaterials[i].chance) {
struct rawmaterial * res = calloc(sizeof(struct rawmaterial), 1);
res->next = r->resources;
r->resources = res;
res->level = dice_rand(tdata->rawmaterials[i].startlevel);
@ -61,12 +83,7 @@ terraform_resources(region * r)
res->divisor = dice_rand(tdata->rawmaterials[i].divisor);
res->flags = 0;
res->type = tdata->rawmaterials[i].type;
res->amount = (int)(res->base * (1+(res->level-res->startlevel)*(res->divisor/100.0)));
#ifdef RESOURCE_FACTOR
res->amount = (int)(res->amount * RESOURCE_FACTOR);
if (res->amount == 0) res->amount = 1;
#endif
assert(res->amount>0);
update_resource(res, 1.0);
res->type->terraform(res, r);
}
}
@ -120,7 +137,8 @@ visible_default(const rawmaterial *res, int skilllevel)
return -1;
}
static void use_default(rawmaterial *res, const region * r, int amount)
static void
use_default(rawmaterial *res, const region * r, int amount)
{
const terraindata_t * tdata = &terrain[rterrain(r)];
assert(res->amount>0 && amount>=0 && amount <= res->amount);
@ -136,11 +154,7 @@ static void use_default(rawmaterial *res, const region * r, int amount)
}
++res->level;
res->amount = (int)(modifier * res->base * (1+(res->level-res->startlevel)*res->divisor/100.0));
/* random adjustment, +/- 91% */
#ifdef RESOURCE_QUANTITY
res->amount = (int)(res->amount * RESOURCE_QUANTITY);
#endif
update_resource(res, modifier);
}
}

View File

@ -35,10 +35,7 @@
#define PEASANTS_DO_NOT_STARVE 0
#define NEW_MIGRATION 1
#define MIGRANTS_CAN_LEARN_EXPENSIVE_SKILLS 1 /* vinyambar 3 only */
#define MAGICPOWER 0.5
#define MAGICREGEN 0.5
#define ASTRAL_HUNGER
#define RESOURCE_FACTOR 0.25
#if NEWATSROI == 1
#define ATSBONUS 2

View File

@ -88,6 +88,6 @@ bind_eressea(lua_State * L)
def("remove_empty_units", &remove_empty_units),
/* planes not really implemented */
def("find_plane_id", &find_plane_id)
def("get_plane_id", &find_plane_id)
];
}

View File

@ -15,11 +15,14 @@
#include <kernel/magic.h>
#include <kernel/spell.h>
#include <util/base36.h>
// lua includes
#include <lua.hpp>
#include <luabind/luabind.hpp>
#include <luabind/iterator_policy.hpp>
#include <ostream>
using namespace luabind;
class bind_spell_ptr {
@ -217,6 +220,19 @@ unit_setname(unit& u, const char * name)
set_string(&u.name, name);
}
static std::ostream&
operator<<(std::ostream& stream, unit& u)
{
stream << u.name << " (" << itoa36(u.no) << ")";
return stream;
}
static bool
operator==(const unit& a, const unit&b)
{
return a.no==b.no;
}
void
bind_unit(lua_State * L)
{
@ -226,6 +242,8 @@ bind_unit(lua_State * L)
class_<struct unit>("unit")
.property("name", &unit_getname, &unit_setname)
.def(tostring(self))
.def(self == unit())
.def_readonly("faction", &unit::faction)
.def_readonly("id", &unit::no)
.def_readwrite("hp", &unit::hp)

View File

@ -1267,6 +1267,15 @@
</type>
<text locale="de">"$unit($mage) erleidet einen Schock ${reason}."</text>
</message>
<message name="patzer" section="magic">
<type>
<arg name="unit" type="unit"></arg>
<arg name="region" type="region"></arg>
<arg name="spell" type="string"></arg>
</type>
<text locale="de">"$unit($unit) unterläuft in $region($region) beim Zaubern von $command ein Patzer:"</text>
<text locale="en">"$unit($unit) fumbles while casting $command in $region($region):"</text>
</message>
<message name="patzer3" section="magic">
<type>
<arg name="unit" type="unit"></arg>

View File

@ -28,6 +28,9 @@
<param name="allied.skilllimit" value="15"/>
<param name="atsroi.ats" value="2"/>
<param name="atsroi.roi" value="4"/>
<param name="magic.regeneration" value="0.5"/>
<param name="magic.power" value="0.5"/>
<param name="resource.factor" value="0.25"/>
</game>
<xi:include href="vinyambar/wdw-strings.xml"/>

View File

@ -19,9 +19,10 @@ end
function wyrm()
print("- running the wyrm quest")
local grave = get_region(-9995,4)
local plane = find_plane_id("arena")
local plane = get_plane_id("arena")
local map = {}
local mapsize = 0
local r
for r in regions() do
mapsize=mapsize+1
map[mapsize] = r