void baiter_enemy(void) { OBJECT *obj=current_proc->pa8; short ta4; /* be_e1 */ do { obj->oxpos.u.intpos=wave_x_position+(short)obj->ochar; obj->oypos.u.intpos=wave_y_position+(short)obj->oid; obj->oxvel.u.intpos=wave_x_velocity; obj->oyvel.u.intpos=wave_y_velocity; if (are_we_shot()==SYSTEM_CARRY_SET) be_9d; if (are_we_hitting_player()!=0) { kill_player(); be_9d; } /* be_e3 */ process_sleep(1); if (randper(dive_randper)==SYSTEM_CARRY_SET) { if (follow_path(srandarc(SCX(0x20000)),SCY(0x12000)+srandarc(SCY(0x2000)),be_pr)==SYSTEM_CARRY_SET) be_99; else obj->oypos.u.intpos=-5; /* be_e5 */ do { ta4=move_to_point(wave_x_position+(short)obj->ochar,wave_y_position+(short)obj->oid,2); if (ta4<2) break; process_sleep(1); if (are_we_shot()==SYSTEM_CARRY_SET) be_9d; if (are_we_hitting_player()!=0) { kill_player(); be_9d; } } while(1); } } while(1); }
void watch_enemy_missile(void) { OBJECT *obj=current_proc->pa8; /* wem1 */ do { if (obj->oypos.u.intpos>SCY(260)) { /* wem9 */ missile_count--; delobj(obj); process_suicide(); } if (are_we_hitting_player()) { kill_player(); /* wem9 */ missile_count--; delobj(obj); process_suicide(); } /* wem2 */ process_sleep(1); } while(1); }
/* pa0 - scale factor for x speed pa1 - scale factor for y speed pa10 - address of path */ WORD follow_path(long pa0,long pa1,PATHPTR *pa10) { OBJECT *obj=current_proc->pa8; /* fp_e0 */ do { if (pa10->p_xvel==SCX(0xeac) && pa10->p_yvel==SCY(0xeac)) { /* fpp9 */ return(SYSTEM_CARRY_CLR); } obj->oxvel.pos=safe32mult(pa10->p_xvel,pa0); obj->oyvel.pos=safe32mult(pa10->p_yvel,pa1); //obj->oxvel.pos=pa10->p_xvel; //obj->oyvel.pos=pa10->p_yvel; current_proc->a11=pa10->p_time; /* fp_e2 */ do { if (obj->oxpos.u.intpos<-SCX(40)) obj->oxpos.u.intpos=-SCX(40); if (obj->oxpos.u.intpos>SCX(440)) obj->oxpos.u.intpos=SCX(440); process_sleep(1); if (are_we_shot()==SYSTEM_CARRY_SET) { return(fp_9d()); } if (are_we_hitting_player()!=0) { kill_player(); return(fp_9d()); } /* fp_e3 */ if (randper(pa10->p_shot+shoot_randper)==SYSTEM_CARRY_SET) { start_enemy_missile(); //start_enemy_missile(); } /* fp_e4 */ } while(--current_proc->a11>0); pa10++; } while(1); }
/* Kill a pilot */ void kill_pilot(struct Pilot *pilot) { int p; for(p=0;p<4;p++) if(&players[p].pilot == pilot) break; kill_player(p); add_splash(pilot->walker.physics.x, pilot->walker.physics.y,5.0, 16, pilot->walker.physics.vel,make_blood); remove_pilot(pilot); }
int main(int argc, char **argv) { t_env e; if ((e.key = ftok(argv[0], 'a')) < 0) { perror("ftok"); exit(1); } // printf("e.key : %d\n", e.key); if (argc == 2) { init_env(&e, argv[1]); while (1) { printf("ICI\n"); op_sem_proberen(&e); printf("LA\n"); // printf("heya\n"); if ((*((int*)(e.addr + sizeof(int)))) == 0) { check_start(&e); op_sem_verhogen(&e); continue ; } printf("hey0\n"); test_print(&e); if (check_elim(&e)) player_lost(&e); msg_read(&e); printf("hey1\n"); begin_turn(&e); op_sem_verhogen(&e); if ((*((int*)(e.addr + sizeof(int)))) == 1 && check_victory(&e)) { printf("VICTOIRRRRRRRRE team : %d\n", e.team); kill_player(&e); } printf("leader : %d\n", e.leader); usleep(500000); } } else printf("Usage : %s [team]\n", argv[0]); return (0); }
void add_donkey() { DONKEY *donkey; /* create the new donkey */ donkey = malloc(sizeof(DONKEY)); /* default flip */ donkey->flip = FALSE; /* take the first position */ get_level_home2(&donkey->x, &donkey->y); donkey->xold = donkey->x; donkey->yold = donkey->y; /* get a color for the donkey */ donkey->color = get_level_random_color(); /* `moved' to FALSE */ donkey->moved = FALSE; /* next donkey to NULL, because this is the last of the list */ donkey->next = NULL; /* check the home */ if (get_block_donkey(donkey->x/2, donkey->y/2)) { /* is full... */ /* destroy the new donkey */ free(donkey); /* kill the player */ kill_player(); } else { /* is empty... */ /* to occupy the position in the level */ set_block_donkey(donkey->x/2, donkey->y/2, donkey); /* add donkey to list */ add_donkey_to_list(donkey); } }
/* updates the badguy position */ int update_badguys() { BADGUY **p = &evildudes; BADGUY *b = evildudes; BADGUY *tmp1, *tmp2; void *bullet; float x, y, d; int dead; /* testcode: enter clears the level */ if ((cheat) && (key[ALLEGRO_KEY_ENTER])) { shutdown_badguys(); b = NULL; while (key[ALLEGRO_KEY_ENTER]) poll_input_wait(); } while (b) { dead = FALSE; if (b->aggro) { /* attack the player */ d = player_pos() - b->x; if (d < -0.5) d += 1; else if (d > 0.5) d -= 1; if (b->y < 0.5) d = -d; b->v *= 0.99; b->v += SGN(d) * 0.00025; } else if (b->evade) { /* evade the player */ if (b->y < 0.75) d = player_pos() + 0.5; else d = b->x; if (b->move) d += SGN(b->move) / 16.0; d = find_target(d) - b->x; if (d < -0.5) d += 1; else if (d > 0.5) d -= 1; b->v *= 0.96; b->v += SGN(d) * 0.0004; } /* horizontal move */ b->x += b->move + sin(b->t * b->sin_speed) * b->sin_depth + b->v; if (b->x < 0) b->x += 1; else if (b->x > 1) b->x -= 1; /* vertical move */ b->y += b->speed; if ((b->y > 0.5) && (b->y - b->speed <= 0.5) && (b->split)) { /* split ourselves */ tmp1 = malloc(sizeof(BADGUY)); tmp2 = malloc(sizeof(BADGUY)); *tmp1 = *tmp2 = *b; tmp1->move -= 0.001; tmp2->move += 0.001; b->speed += 0.001; tmp1->t = rand() & 255; tmp2->t = rand() & 255; tmp1->next = tmp2; tmp2->next = evildudes; evildudes = tmp1; } b->t++; if (b->y > 0) { if (kill_player(b->x, b->y)) { /* did we hit someone? */ dead = TRUE; } else { /* or did someone else hit us? */ bullet = get_first_bullet(&x, &y); while (bullet) { x = x - b->x; if (x < -0.5) x += 1; else if (x > 0.5) x -= 1; x = ABS(x); y = ABS(y - b->y); if (x < y) d = y/2 + x; else d = x/2 + y; if (d < 0.025) { kill_bullet(bullet); explode(b->x, b->y, 0); sfx_explode_alien(); dead = TRUE; break; } bullet = get_next_bullet(bullet, &x, &y); } } } /* advance to the next dude */ if (dead) { *p = b->next; tmp1 = b; b = b->next; free(tmp1); } else { p = &b->next; b = b->next; } } if ((!evildudes) && (!player_dying())) { if (!finished_counter) { message("Wave Complete"); sfx_ping(0); } finished_counter++; if (finished_counter > 64) return TRUE; } return FALSE; }
/** * Regenerate player's hp/mana/grace, decrease food, etc. * * We will only regenerate HP and mana if the player has some food in their * stomach. * @param op Player. */ void do_some_living(object *op) { int last_food = op->stats.food; int gen_hp, gen_sp, gen_grace; int rate_hp = 2000; int rate_sp = 1200; int rate_grace = 400; if (CONTR(op)->state != ST_PLAYING) { return; } gen_hp = (CONTR(op)->gen_hp * (rate_hp / 20)) + (op->stats.maxhp / 4); gen_sp = (CONTR(op)->gen_sp * (rate_sp / 20)) + op->stats.maxsp; gen_grace = (CONTR(op)->gen_grace * (rate_grace / 20)) + op->stats.maxgrace; gen_sp = gen_sp * 10 / MAX(CONTR(op)->gen_sp_armour, 10); /* Update client's regen rates. */ CONTR(op)->gen_client_hp = ((float) (1000000 / MAX_TIME) / ((float) rate_hp / (MAX(gen_hp, 20) + 10))) * 10.0f; CONTR(op)->gen_client_sp = ((float) (1000000 / MAX_TIME) / ((float) rate_sp / (MAX(gen_sp, 20) + 10))) * 10.0f; CONTR(op)->gen_client_grace = ((float) (1000000 / MAX_TIME) / ((float) rate_grace / (MAX(gen_grace, 20) + 10))) * 10.0f; /* Regenerate hit points. */ if (--op->last_heal < 0) { if (op->stats.hp < op->stats.maxhp && op->stats.food) { op->stats.hp++; /* DMs do not consume food. */ if (!QUERY_FLAG(op, FLAG_WIZ)) { op->stats.food--; if (CONTR(op)->digestion < 0) { op->stats.food += CONTR(op)->digestion; } else if (CONTR(op)->digestion > 0 && rndm(0, CONTR(op)->digestion)) { op->stats.food = last_food; } } } op->last_heal = rate_hp / (MAX(gen_hp, 20) + 10); } /* Regenerate mana. */ if (--op->last_sp < 0) { if (op->stats.sp < op->stats.maxsp && op->stats.food) { op->stats.sp++; /* DMs do not consume food. */ if (!QUERY_FLAG(op, FLAG_WIZ)) { op->stats.food--; if (CONTR(op)->digestion < 0) { op->stats.food += CONTR(op)->digestion; } else if (CONTR(op)->digestion > 0 && rndm(0, CONTR(op)->digestion)) { op->stats.food = last_food; } } } op->last_sp = rate_sp / (MAX(gen_sp, 20) + 10); } /* Stop and pray. */ if (CONTR(op)->praying && !CONTR(op)->was_praying) { if (op->stats.grace < op->stats.maxgrace) { object *god = find_god(determine_god(op)); if (god) { if (CONTR(op)->combat_mode) { new_draw_info_format(NDI_UNIQUE, op, "You stop combat and start praying to %s...", god->name); CONTR(op)->combat_mode = 0; send_target_command(CONTR(op)); } else { new_draw_info_format(NDI_UNIQUE, op, "You start praying to %s...", god->name); } CONTR(op)->was_praying = 1; } else { new_draw_info(NDI_UNIQUE, op, "You worship no deity to pray to!"); CONTR(op)->praying = 0; } op->last_grace = rate_grace / (MAX(gen_grace, 20) + 10); } else { CONTR(op)->praying = 0; CONTR(op)->was_praying = 0; } } else if (!CONTR(op)->praying && CONTR(op)->was_praying) { new_draw_info(NDI_UNIQUE, op, "You stop praying."); CONTR(op)->was_praying = 0; op->last_grace = rate_grace / (MAX(gen_grace, 20) + 10); } /* Regenerate grace. */ if (CONTR(op)->praying) { if (--op->last_grace < 0) { if (op->stats.grace < op->stats.maxgrace) { op->stats.grace++; } if (op->stats.grace >= op->stats.maxgrace) { op->stats.grace = op->stats.maxgrace; new_draw_info(NDI_UNIQUE, op, "You are full of grace and stop praying."); CONTR(op)->was_praying = 0; } op->last_grace = rate_grace / (MAX(gen_grace, 20) + 10); } } /* Digestion */ if (--op->last_eat < 0) { int bonus = MAX(CONTR(op)->digestion, 0); int penalty = MAX(-CONTR(op)->digestion, 0); if (CONTR(op)->gen_hp > 0) { op->last_eat = 25 * (1 + bonus) / (CONTR(op)->gen_hp + penalty + 1); } else { op->last_eat = 25 * (1 + bonus) / (penalty + 1); } /* DMs do not consume food. */ if (!QUERY_FLAG(op, FLAG_WIZ)) { op->stats.food--; } } if (op->stats.food < 0 && op->stats.hp >= 0) { object *tmp, *flesh = NULL; for (tmp = op->inv; tmp; tmp = tmp->below) { if (!QUERY_FLAG(tmp, FLAG_UNPAID)) { if (tmp->type == FOOD || tmp->type == DRINK || tmp->type == POISON) { new_draw_info(NDI_UNIQUE, op, "You blindly grab for a bite of food."); manual_apply(op, tmp, 0); if (op->stats.food >= 0 || op->stats.hp < 0) { break; } } else if (tmp->type == FLESH) { flesh = tmp; } } } /* If player is still starving, it means they don't have any food, so * eat flesh instead. */ if (op->stats.food < 0 && op->stats.hp >= 0 && flesh) { new_draw_info(NDI_UNIQUE, op, "You blindly grab for a bite of food."); manual_apply(op, flesh, 0); } } while (op->stats.food < 0 && op->stats.hp > 0) { op->stats.food++; op->stats.hp--; } if ((op->stats.hp <= 0 || op->stats.food < 0) && !QUERY_FLAG(op, FLAG_WIZ)) { new_draw_info_format(NDI_ALL, NULL, "%s starved to death.", op->name); strcpy(CONTR(op)->killer, "starvation"); kill_player(op); } }
int game( int nlevel ){ LSDB lsdb; lsdb.lives = 3; lsdb.bombs = 0; lsdb.score = 0; lsdb.diamonds = 0; int die; gps player; int count = 0; int new_bomb = 0; int level = nlevel; int level_score = 0; int new_bomb_x, new_bomb_y; char map[MAP_HSIZE][MAP_WSIZE]; erase(); load_level( map, level, &player, &lsdb.diamonds ); draw_all( map, HZ, lsdb ); nodelay( stdscr, TRUE ); int run = 1; while( run ){ count++; die = 0; switch( tolower( getch() ) ){ case KEY_UP : if( move_player( map, &player, UP , &lsdb) == -1 ) die = 1; break; case KEY_DOWN : if( move_player( map, &player, DOWN , &lsdb) == -1 ) die = 1; break; case KEY_LEFT : if( move_player( map, &player, LEFT , &lsdb) == -1 ) die = 1; break; case KEY_RIGHT: if( move_player( map, &player, RIGHT, &lsdb) == -1 ) die = 1; break; case 'k' : die = 1; break; case 'h' : help() ; break; case 27 : run = false ; break; case 'q' : if(msgbox("Quit game == 'q' ? yes : no ")== 'q') run = false; break; case 'b' : if( lsdb.bombs ){ if( new_bomb == 0 ){ lsdb.bombs--; new_bomb = 1; new_bomb_y = player.y; new_bomb_x = player.x; } } break; case 't' : if( new_bomb ){ new_bomb = 0; die = 1; } else if( kaboom( map ) ) die = 1; break; default : break; } // switch( ch ) if( new_bomb ){ if( player.y != new_bomb_y || player.x != new_bomb_x ){ new_bomb = 0; map[new_bomb_y][new_bomb_x] = BOMB; } } if( count >= 4 ){ if( do_the_monster_dance( map, player ) ) die = 1; count = 0; } if( gravity( map, &new_bomb ) ) die = 1; if( die ){ kill_player(map, player ); lsdb.lives--; lsdb.bombs = 0; new_bomb = 0; if( lsdb.lives == 0 ){ if( msgbox( "continue == 'q' ? no : yes " ) != 'q' ) return level; else return 0 ; } lsdb.score = level_score; load_level( map, level, &player, &lsdb.diamonds ); } if( lsdb.diamonds <= 0 ){ level_score = lsdb.score; load_level( map, ++level, &player, &lsdb.diamonds ); } draw_all( map, HZ, lsdb ); } // while( run ) nodelay( stdscr, FALSE ); return 0; }