Skip to content

Commit

Permalink
* Neue Landschaft: Wasser (noch nicht animiert)
Browse files Browse the repository at this point in the history
 * Neuer Kreaturtyp: Fliegend.


git-svn-id: http://infon.googlecode.com/svn/trunk@50 8171fb75-e542-0410-96e4-03d5dd800671
  • Loading branch information
dividuum committed Aug 6, 2006
1 parent cf6ad1b commit 9c388e1
Show file tree
Hide file tree
Showing 14 changed files with 1,659 additions and 1,566 deletions.
105 changes: 76 additions & 29 deletions creature.c
Expand Up @@ -76,17 +76,25 @@ int creature_max_health(const creature_t *creature) {
switch (creature->type) {
case 0:
return 10000;
default:
case 1:
return 20000;
case 2:
return 5000;
default:
assert(0);
}
}

int creature_max_food(const creature_t *creature) {
switch (creature->type) {
case 0:
return 10000;
default:
case 1:
return 20000;
case 2:
return 5000;
default:
assert(0);
}
}

Expand All @@ -96,8 +104,10 @@ int creature_aging(const creature_t *creature) {
return 5;
case 1:
return 7;
case 2:
return 5;
default:
return 0;
assert(0);
}
}

Expand Down Expand Up @@ -133,20 +143,13 @@ int creature_can_move_to_target(creature_t *creature) {
int creature_speed(const creature_t *creature) {
switch (creature->type) {
case 0:
//return 200 + creature->health / 50;
return 200 + creature->health / 16;
default:
//return 300;
case 1:
return 400;
}
}

int creature_turnspeed(const creature_t *creature) {
switch (creature->type) {
case 0:
return 2;
case 2:
return 800;
default:
return 1;
assert(0);
}
}

Expand Down Expand Up @@ -192,8 +195,12 @@ int creature_heal_rate(const creature_t *creature) {
switch (creature->type) {
case 0:
return 500;
default:
case 1:
return 300;
case 2:
return 600;
default:
assert(0);
}
}

Expand Down Expand Up @@ -228,8 +235,12 @@ int creature_eat_rate(const creature_t *creature) {
switch (creature->type) {
case 0:
return 800;
default:
case 1:
return 400;
case 2:
return 600;
default:
assert(0);
}
}

Expand All @@ -251,8 +262,8 @@ void creature_do_eat(creature_t *creature, int delta) {

static const int attack_possible[CREATURE_TYPES][CREATURE_TYPES] =
// TARGET
{ { 0, 0, 0, 0 },// ATTACKER
{ 1, 1, 0, 0 },
{ { 0, 0, 1, 0 },// ATTACKER
{ 1, 1, 1, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 } };

Expand All @@ -263,18 +274,26 @@ int creature_can_attack(const creature_t *creature, const creature_t *target) {
int creature_hitpoints(const creature_t *creature) {
switch (creature->type) {
case 0:
return 0;
default:
return 1000;
case 1:
return 1500;
case 2:
return 0;
default:
assert(0);
}
}

int creature_attack_distance(const creature_t *creature) {
switch (creature->type) {
case 0:
return 3 * TILE_SCALE;
case 1:
return 2 * TILE_SCALE;
case 2:
return 0;
default:
return 2 * TILE_SCALE;
assert(0);
}
}

Expand Down Expand Up @@ -327,9 +346,9 @@ int creature_conversion_speed(creature_t *creature) {

static const int conversion_food_needed[CREATURE_TYPES][CREATURE_TYPES] =
// TO
{ { 0, 8000, 0, 0 },// FROM
{ 0, 0, 0, 0 },
{ { 0, 8000, 5000, 0 },// FROM
{ 0, 0, 0, 0 },
{ 0, 5000, 0, 0 },
{ 0, 0, 0, 0 } };

int creature_conversion_food(const creature_t *creature, int type) {
Expand Down Expand Up @@ -437,26 +456,38 @@ int creature_can_feed(const creature_t *creature) {
switch (creature->type) {
case 0:
return creature->food > 0;
default:
case 1:
return 0;
case 2:
return creature->food > 0;
default:
assert(0);
}
}

int creature_feed_distance(const creature_t *creature) {
switch (creature->type) {
case 0:
return TILE_SCALE;
default:
case 1:
return 0;
case 2:
return TILE_SCALE;
default:
assert(0);
}
}

int creature_feed_speed(const creature_t *creature) {
switch (creature->type) {
case 0:
return 400;
case 1:
return 0;
case 2:
return 400;
default:
return 0;
assert(0);
}
}

Expand Down Expand Up @@ -706,10 +737,26 @@ void creature_moveall(int delta) {
}

int creature_set_path(creature_t *creature, int x, int y) {
if (!world_walkable(X_TO_TILEX(x), Y_TO_TILEY(y)))
return 0;
pathnode_t *newpath;

if (creature->type == 0 || creature->type == 1) {
// Bodenbasierte Viecher
if (!world_walkable(X_TO_TILEX(x), Y_TO_TILEY(y)))
return 0;

newpath = world_findpath(creature->x, creature->y, x, y);
} else {
// Fliegendes Vieh
if (!world_is_within_border(X_TO_TILEX(x), Y_TO_TILEY(y)))
return 0;

pathnode_t *newpath = world_findpath(creature->x, creature->y, x, y);
newpath = malloc(sizeof(pathnode_t));
if (newpath) {
newpath->x = x;
newpath->y = y;
newpath->next = NULL;
}
}

if (!newpath)
return 0;
Expand Down
4 changes: 2 additions & 2 deletions creature.h
Expand Up @@ -40,8 +40,8 @@ typedef struct creature_s {
int spawn_food;
creature_state state;

int age_action_deltas;
int spawn_time;
int age_action_deltas;
int spawn_time;

char message[9];
unsigned char dirtymask;
Expand Down
3 changes: 3 additions & 0 deletions gui_world.c
Expand Up @@ -123,6 +123,9 @@ static int gui_world_settype(int x, int y, int type) {
MAPTILE(x, y).map = sprite_get(SPRITE_PLAIN + rand() % SPRITE_NUM_PLAIN);
}
break;
case WATER:
MAPTILE(x, y).map = sprite_get(SPRITE_WATER + rand() % SPRITE_NUM_WATER);
break;
default:
// XXX: Unsupported...
MAPTILE(x, y).map = sprite_get(SPRITE_KOTH);
Expand Down
20 changes: 15 additions & 5 deletions infon.c
Expand Up @@ -56,17 +56,27 @@ void print_fps() {
}

int main(int argc, char *argv[]) {
if (argc != 2)
int width = 800, height = 600, fullscreen = 0;
#ifdef WIN32
if (argc == 2 && stricmp(argv[1], "/s") == 0) {
argv[1] = "bl0rg.net";
char *bs = strrchr(argv[0], '\\');
if (bs) { *bs = '\0'; chdir(argv[0]); }
width = 1024, height = 768, fullscreen = 1;
} else if (argc == 3 && stricmp(argv[1], "/p") == 0) {
exit(0);
} else if (argc == 2 && strstr(argv[1], "/c:") == argv[1]) {
die("There are no settings");
} else {
die("you must supply the gameservers hostname\n"
"as first command line parameter.\n\n"
"example: 'infon.exe bl0rg.net'");
}
#else
if (argc != 2)
die("usage: %s <serverip[:port]>", argv[0]);
#endif

const int width = 800, height = 600;

#ifndef WIN32
signal(SIGINT, sighandler);
signal(SIGPIPE, SIG_IGN);
Expand All @@ -76,7 +86,7 @@ int main(int argc, char *argv[]) {

client_init(argv[1]);

video_init(width, height);
video_init(width, height, fullscreen);
sprite_init();
gui_scroller_init();
gui_world_init();
Expand Down Expand Up @@ -129,7 +139,7 @@ int main(int argc, char *argv[]) {
break;
case SDL_MOUSEMOTION:
if (event.motion.state & 1)
gui_world_center_change(-event.motion.xrel, -event.motion.yrel);
gui_world_center_change(-event.motion.xrel, -event.motion.yrel);
break;
case SDL_VIDEORESIZE:
video_resize(event.resize.w, event.resize.h);
Expand Down

0 comments on commit 9c388e1

Please sign in to comment.