forked from github/server
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:
parent
846f110268
commit
5d559840fa
|
@ -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);
|
||||
}
|
||||
|
@ -1254,84 +1274,86 @@ fumble(region * r, unit * u, spell * sp, int cast_grade)
|
|||
static void
|
||||
do_fumble(castorder *co)
|
||||
{
|
||||
curse * c;
|
||||
region * r = co->rt;
|
||||
unit * u = (unit*)co->magician;
|
||||
spell * sp = co->sp;
|
||||
int level = co->level;
|
||||
int duration;
|
||||
curse * c;
|
||||
region * r = co->rt;
|
||||
unit * u = (unit*)co->magician;
|
||||
spell * sp = co->sp;
|
||||
int level = co->level;
|
||||
int duration;
|
||||
const char * sp_name = spell_name(sp, u->faction->locale);
|
||||
|
||||
switch (rand() % 10) {
|
||||
/* wenn vorhanden spezieller Patzer, ansonsten nix */
|
||||
case 0:
|
||||
sp->patzer(co);
|
||||
break;
|
||||
case 1:
|
||||
/* Kröte */
|
||||
duration = rand()%level/2;
|
||||
if (duration<2) duration = 2;
|
||||
{
|
||||
/* one or two things will happen: the toad changes her race back,
|
||||
* and may or may not get toadslime.
|
||||
* The list of things to happen are attached to a timeout
|
||||
* trigger and that's added to the triggerlit of the mage gone toad.
|
||||
*/
|
||||
trigger * trestore = trigger_changerace(u, u->race, u->irace);
|
||||
if (rand()%10>2) t_add(&trestore, trigger_giveitem(u, olditemtype[I_TOADSLIME], 1));
|
||||
add_trigger(&u->attribs, "timer", trigger_timeout(duration, trestore));
|
||||
}
|
||||
u->race = new_race[RC_TOAD];
|
||||
u->irace = new_race[RC_TOAD];
|
||||
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));
|
||||
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)));
|
||||
break;
|
||||
ADDMSG(&u->faction->msgs, msg_message("patzer", "unit region spell",
|
||||
u, r, sp_name));
|
||||
switch (rand() % 10) {
|
||||
case 0:
|
||||
/* wenn vorhanden spezieller Patzer, ansonsten nix */
|
||||
sp->patzer(co);
|
||||
break;
|
||||
|
||||
case 5:
|
||||
case 6:
|
||||
/* Spruch gelingt, aber alle Magiepunkte weg */
|
||||
((nspell_f)sp->sp_function)(co);
|
||||
set_spellpoints(u, 0);
|
||||
sprintf(buf, "Als %s versucht, '%s' zu zaubern erhebt sich "
|
||||
"plötzlich ein dunkler Wind. Bizarre geisterhafte "
|
||||
"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));
|
||||
addmessage(0, u->faction, buf, MSG_MAGIC, ML_WARN);
|
||||
break;
|
||||
case 1:
|
||||
/* Kröte */
|
||||
duration = rand()%level/2;
|
||||
if (duration<2) duration = 2;
|
||||
{
|
||||
/* one or two things will happen: the toad changes her race back,
|
||||
* and may or may not get toadslime.
|
||||
* The list of things to happen are attached to a timeout
|
||||
* trigger and that's added to the triggerlit of the mage gone toad.
|
||||
*/
|
||||
trigger * trestore = trigger_changerace(u, u->race, u->irace);
|
||||
if (rand()%10>2) t_add(&trestore, trigger_giveitem(u, olditemtype[I_TOADSLIME], 1));
|
||||
add_trigger(&u->attribs, "timer", trigger_timeout(duration, trestore));
|
||||
}
|
||||
u->race = new_race[RC_TOAD];
|
||||
u->irace = new_race[RC_TOAD];
|
||||
sprintf(buf, "Eine Botschaft von %s: 'Ups! Quack, Quack!'", unitname(u));
|
||||
addmessage(r, 0, buf, MSG_MAGIC, ML_MISTAKE);
|
||||
break;
|
||||
|
||||
case 7:
|
||||
case 8:
|
||||
case 9:
|
||||
default:
|
||||
/* Spruch gelingt, alle nachfolgenden Sprüche werden 2^4 so teuer */
|
||||
((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));
|
||||
addmessage(0, u->faction, buf, MSG_MAGIC, ML_WARN);
|
||||
countspells(u,3);
|
||||
}
|
||||
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;
|
||||
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);
|
||||
ADDMSG(&u->faction->msgs, msg_message("patzer3", "unit region command",
|
||||
u, r, sp_name));
|
||||
break;
|
||||
|
||||
return;
|
||||
case 5:
|
||||
case 6:
|
||||
/* Spruch gelingt, aber alle Magiepunkte weg */
|
||||
((nspell_f)sp->sp_function)(co);
|
||||
set_spellpoints(u, 0);
|
||||
sprintf(buf, "Als %s versucht, '%s' zu zaubern erhebt sich "
|
||||
"plötzlich ein dunkler Wind. Bizarre geisterhafte "
|
||||
"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), sp_name, unitname(u));
|
||||
addmessage(0, u->faction, buf, MSG_MAGIC, ML_WARN);
|
||||
break;
|
||||
|
||||
case 7:
|
||||
case 8:
|
||||
case 9:
|
||||
default:
|
||||
/* Spruch gelingt, alle nachfolgenden Sprüche werden 2^4 so teuer */
|
||||
((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), sp_name);
|
||||
addmessage(0, u->faction, buf, MSG_MAGIC, ML_WARN);
|
||||
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;
|
||||
}
|
||||
|
|
|
@ -25,18 +25,39 @@
|
|||
#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)
|
||||
{
|
||||
struct rawmaterial * res = r->resources;
|
||||
while (res) {
|
||||
if (res->type->update) res->type->update(res, r);
|
||||
res = res->next;
|
||||
}
|
||||
struct rawmaterial * res = r->resources;
|
||||
while (res) {
|
||||
if (res->type->update) res->type->update(res, r);
|
||||
res = res->next;
|
||||
}
|
||||
}
|
||||
|
||||
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,28 +137,25 @@ 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);
|
||||
res->amount-=amount;
|
||||
while (res->amount==0) {
|
||||
double modifier = 1.0 + ((rand() % (SHIFT*2+1)) - SHIFT) * ((rand() % (SHIFT*2+1)) - SHIFT) / 10000.0;
|
||||
int i;
|
||||
const terraindata_t * tdata = &terrain[rterrain(r)];
|
||||
assert(res->amount>0 && amount>=0 && amount <= res->amount);
|
||||
res->amount-=amount;
|
||||
while (res->amount==0) {
|
||||
double modifier = 1.0 + ((rand() % (SHIFT*2+1)) - SHIFT) * ((rand() % (SHIFT*2+1)) - SHIFT) / 10000.0;
|
||||
int i;
|
||||
|
||||
for (i=0; i!=3; ++i) {
|
||||
const rawmaterial_type * rmtype = tdata->rawmaterials[i].type;
|
||||
assert(rmtype);
|
||||
if (rmtype==res->type) break;
|
||||
}
|
||||
for (i=0; i!=3; ++i) {
|
||||
const rawmaterial_type * rmtype = tdata->rawmaterials[i].type;
|
||||
assert(rmtype);
|
||||
if (rmtype==res->type) break;
|
||||
}
|
||||
|
||||
++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
|
||||
}
|
||||
++res->level;
|
||||
update_resource(res, modifier);
|
||||
}
|
||||
}
|
||||
|
||||
struct rawmaterial *
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
];
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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"/>
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue