forked from github/server
neue lua-exporte:
- int get_plane_id(string) unit.number setzt auch auf 0 (killen)
This commit is contained in:
parent
5f0ba5c2a0
commit
a53cc0a25c
|
@ -779,43 +779,43 @@ eff_stealth (const unit * u, const region * r)
|
|||
void
|
||||
scale_number (unit * u, int n)
|
||||
{
|
||||
skill_t sk;
|
||||
const attrib * a;
|
||||
int remain;
|
||||
skill_t sk;
|
||||
const attrib * a;
|
||||
int remain;
|
||||
|
||||
if (n == u->number) return;
|
||||
if (n && u->number) {
|
||||
int full;
|
||||
remain = ((u->hp%u->number) * (n % u->number)) % u->number;
|
||||
if (n == u->number) return;
|
||||
if (n && u->number) {
|
||||
int full;
|
||||
remain = ((u->hp%u->number) * (n % u->number)) % u->number;
|
||||
|
||||
full = u->hp/u->number; /* wieviel kriegt jede person mindestens */
|
||||
u->hp = full * n + (u->hp-full*u->number) * n / u->number;
|
||||
assert(u->hp>=0);
|
||||
if ((rand() % u->number) < remain)
|
||||
++u->hp; /* Nachkommastellen */
|
||||
} else {
|
||||
remain = 0;
|
||||
u->hp = 0;
|
||||
}
|
||||
for (a = a_find(u->attribs, &at_effect);a;a=a->nexttype) {
|
||||
effect_data * data = (effect_data *)a->data.v;
|
||||
int snew = data->value / u->number * n;
|
||||
if (n) {
|
||||
remain = data->value - snew / n * u->number;
|
||||
snew += remain * n / u->number;
|
||||
remain = (remain * n) % u->number;
|
||||
if ((rand() % u->number) < remain)
|
||||
++snew; /* Nachkommastellen */
|
||||
}
|
||||
data->value = snew;
|
||||
}
|
||||
full = u->hp/u->number; /* wieviel kriegt jede person mindestens */
|
||||
u->hp = full * n + (u->hp-full*u->number) * n / u->number;
|
||||
assert(u->hp>=0);
|
||||
if ((rand() % u->number) < remain)
|
||||
++u->hp; /* Nachkommastellen */
|
||||
} else {
|
||||
remain = 0;
|
||||
u->hp = 0;
|
||||
}
|
||||
for (a = a_find(u->attribs, &at_effect);a;a=a->nexttype) {
|
||||
effect_data * data = (effect_data *)a->data.v;
|
||||
int snew = data->value / u->number * n;
|
||||
if (n) {
|
||||
remain = data->value - snew / n * u->number;
|
||||
snew += remain * n / u->number;
|
||||
remain = (remain * n) % u->number;
|
||||
if ((rand() % u->number) < remain)
|
||||
++snew; /* Nachkommastellen */
|
||||
}
|
||||
data->value = snew;
|
||||
}
|
||||
if (u->number==0 || n==0) {
|
||||
for (sk = 0; sk < MAXSKILLS; sk++) {
|
||||
remove_skill(u, sk);
|
||||
}
|
||||
}
|
||||
|
||||
set_number(u, n);
|
||||
set_number(u, n);
|
||||
}
|
||||
|
||||
boolean
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
// kernel includes
|
||||
#include <gamecode/laws.h>
|
||||
#include <kernel/race.h>
|
||||
#include <kernel/plane.h>
|
||||
#include <kernel/item.h>
|
||||
#include <kernel/reports.h>
|
||||
#include <kernel/save.h>
|
||||
|
@ -63,6 +64,13 @@ write_reports()
|
|||
|
||||
extern int process_orders(void);
|
||||
|
||||
static int
|
||||
find_plane_id(const char * name)
|
||||
{
|
||||
plane * pl = getplanebyname(name);
|
||||
return pl?pl->id:0;
|
||||
}
|
||||
|
||||
void
|
||||
bind_eressea(lua_State * L)
|
||||
{
|
||||
|
@ -76,6 +84,9 @@ bind_eressea(lua_State * L)
|
|||
def("read_orders", &readorders),
|
||||
def("process_orders", &process_orders),
|
||||
def("add_equipment", &lua_addequipment),
|
||||
def("get_turn", &get_turn)
|
||||
def("get_turn", &get_turn),
|
||||
|
||||
/* planes not really implemented */
|
||||
def("find_plane_id", &find_plane_id)
|
||||
];
|
||||
}
|
||||
|
|
|
@ -61,6 +61,8 @@ unit_setnumber(unit& u, int number)
|
|||
if (u.number==0) {
|
||||
set_number(&u, number);
|
||||
u.hp = unit_max_hp(&u) * number;
|
||||
} else {
|
||||
scale_number(&u, number);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue