/*! \brief Check for level-ups * * Checks for level ups. * * \param pl - Player * \param ls - Learned new spell * \returns 1 if new spell learned, 0 otherwise */ static int check_xp(int pl, int ls) { int stp = 0, z = 0; if (party[pl].lvl >= 50) { return 0; } while (!stp) { if (party[pl].xp >= party[pl].next) { level_up(pl); z = 1; } else { stp = 1; } if (party[pl].lvl >= 50) { stp = 1; } } if (ls == 1) { learn_new_spells(pl); } return z; }
void set_level(struct character *ch, int lvl){ while(lvl>0){ ch->exp[ch->primary]+=100; level_up(ch); lvl--; } }
/* * Process accelerometer data */ static void accel_data_handler(AccelData *data, uint32_t num_samples) { // Average the data uint32_t avg_x = 0; uint32_t avg_y = 0; uint32_t avg_z = 0; AccelData *dx = data; for (uint32_t i = 0; i < num_samples; i++, dx++) { avg_x += scale_accel(dx->x); avg_y += scale_accel(dx->y); avg_z += scale_accel(dx->z); } avg_x /= num_samples; avg_y /= num_samples; avg_z /= num_samples; // Work out deviations uint16_t bx = 0; uint16_t by = 0; uint16_t bz = 0; AccelData *d = data; for (uint32_t i = 0; i < num_samples; i++, d++) { uint16_t x = scale_accel(d->x) ; uint16_t y = scale_accel(d->y) ; uint16_t z = scale_accel(d->z) ; if (x < avg_x) x = avg_x - x; else x -= avg_x; if (y < avg_y) y = avg_y - y; else y -= avg_y; if (z < avg_z) z = avg_z - z; else z -= avg_z; // Store the worst case for that period if (!(d->did_vibrate)) { if (x > bx) bx = x; if (y > by) by = y; if (z > bz) bz = z; } } if (bz > 250) level_up(); }
int main(int argc, char** argv) { int c; carmen_ipc_initialize(argc,argv); carmen_param_check_version(argv[0]); signal(SIGINT, shutdown_module); if (argc > 1 && !strcmp(argv[1], "-sim")) simulation = 1; if (carmen_map_get_hmap(&hmap) < 0) carmen_die("no hmap found\n"); print_hmap(); //dbug carmen_map_change_map_zone(hmap.zone_names[0]); //dbug: this should go in the map server map_zone = 0; ipc_init(); carmen_terminal_cbreak(0); while(1) { carmen_ipc_sleep(0.01); c = getchar(); /* if (c == EOF) break; */ if (c != 27) continue; c = getchar(); /* if (c == EOF) break; */ if (c != 91) continue; c = getchar(); /* if (c == EOF) break; */ switch(c) { case 65: level_up(); break; case 66: level_down(); } } return 0; }
void game_main(void) { int i; int sum; if (game_init() < 0) { printk("game_init() failed"); return; } while(player[0].lifes > 0) { rt_task_wait_period(NULL); if(player[0].enable == 0) { //printk("player died\n"); player_died(); //printk("player lifes: %d\n", player[0].lifes); } sum = 0; for(i = 0; i < nbEnnemis; i++) { sum += ennemi[i].enable; } if(sum == 0) { level_up(); } } tri_score(); if (end_game() < 0) { printk("end_game() failed"); return; } }
void MagicTower::ReceiveMessage(Message *message) { if (message->GetMessageName() == "Tick") { ticks++; if (ticks == thePrefs.GetFloat("TowerSettings", "MagicTime")) { attack(); ticks = 0; } } if (message->GetMessageName() == "MouseDown") { TypedMessage<Vec2i> *m = (TypedMessage<Vec2i>*)message; Vec2i screenCoordinates = m->GetValue(); Vector2 click = MathUtil::ScreenToWorld(screenCoordinates); Vector2 position = GetPosition(); Vector2 size = GetSize(); if ((click.X < position.X + size.X/2.0) && (click.X > position.X - size.X/2.0) && (click.Y < position.Y + size.Y/2.0) && (click.Y > position.Y - size.Y/2.0)) { level_up(); } } }
void gain_exp_regardless( CharData * ch, int gain) { int is_altered = FALSE; GET_EXP(ch) += gain; if( GET_EXP(ch) < 0 ) GET_EXP(ch) = 0; if( !IS_NPC(ch) ){ while( GET_LEVEL(ch) < LVL_IMPL && GET_EXP(ch) >= titles[(int) GET_CLASS(ch)][GET_LEVEL(ch) + 1].exp) { send_to_char("You rise a level!\r\n", ch); GET_LEVEL(ch) += 1; level_up(ch); is_altered = TRUE; } if( is_altered ){ set_title(ch, NULL); run_autowiz(); } } }/* gain_exp_regardless */
void gain_exp_unchecked(CharData *ch, int gain) { // PC mobs do NOT gain exps at all. if (IS_AFFECTED(ch, AFF_CHARM) || MOB_FLAGGED(ch, MOB_CONJURED)) return; // stop xps clocking over. if ((GET_EXP(ch) > 2000000000) && gain > 0) return; if (!IS_NPC(ch) && ((GET_LEVEL(ch) < 1 || GET_LEVEL(ch) > MAX_MORTAL))) return; if (IN_ARENA(ch)) return; if (ZONE_FLAGGED(world[ch->in_room].zone, ZONE_ARENA)) return; if (ZONE_FLAGGED(world[ch->in_room].zone, ZONE_SLEEPTAG)) return; /* NPCs just get their exp mod and leave */ if (IS_NPC(ch)) { GET_EXP(ch) += gain; return; } if (gain > 0) { if ((GET_EXP(ch) + gain ) > INT_MAX) return; GET_EXP(ch) += gain; /* Did the player just earn a level? */ if( GET_LEVEL(ch) < MAX_MORTAL && GET_EXP(ch) >= titles[(int) GET_CLASS(ch)][GET_LEVEL(ch) + 1].exp) { send_to_char("You rise a level!\r\n", ch); GET_EXP(ch) = titles[(int) GET_CLASS(ch)][GET_LEVEL(ch) + 1].exp; GET_LEVEL(ch) += 1; level_up(ch); set_title(ch, NULL); } } else if (gain < 0) { long thisLvl = (titles[(int) GET_CLASS(ch)][GET_LEVEL(ch) + 0].exp); long nextLvl = (titles[(int) GET_CLASS(ch)][GET_LEVEL(ch) + 1].exp); long neg100 = thisLvl - nextLvl + thisLvl; GET_EXP(ch) += gain; /* uh oh spaghettios! */ if (GET_EXP(ch) < 0 && IS_MORTAL(ch)) { mudlog(NRM, LVL_IMMORT, TRUE, "SOUL DEATH: %s reduced to 0 xps by death, deleting!", GET_NAME(ch)); sendChar(ch, "Your soul is too weak to return to the world..."); sendChar(ch, "Utter darkness surrounds you as you slowly slip " "into oblivion..."); act("A look of utter despair crosses $n's face as their very soul" " is destroyed.", TRUE, ch, 0, 0, TO_ROOM ); SET_BIT_AR(PLR_FLAGS(ch), PLR_DELETED); if (ch->desc) SET_DCPENDING(ch->desc); } /* Did the player just lose a level? */ if (GET_LEVEL(ch) > 1 && IS_MORTAL(ch) && GET_EXP(ch) <= neg100) { send_to_char("You have lost a level!\r\n", ch); GET_LEVEL(ch) -= 1; retreat_level(ch); set_title(ch, NULL); /* make sure they don't drop below 0% at their new level */ if (GET_EXP(ch) < titles[(int)GET_CLASS(ch)][GET_LEVEL(ch)].exp) GET_EXP(ch) = titles[(int)GET_CLASS(ch)][GET_LEVEL(ch)].exp; } } }
//Main fonction int main(void) { int fini = 1; int nb_victoire = 0; Liste Adversaires = NULL; Pokemon mon_pok; int diff = 1; //Défini les attaques possibles Attaque PO = new_attack("Poseidon", 90, "Eau"); Attaque CH = new_attack("Chalchiuhtlicue", 70, "Eau"); Attaque LL = new_attack("Llyr", 50, "Eau"); Attaque AO = new_attack("Ao Kuang", 30, "Eau"); Attaque HE = new_attack("Hephaestus", 90, "Feu"); Attaque SV = new_attack("Svarog", 70, "Feu"); Attaque AR = new_attack("Arshi Tngri", 50, "Feu"); Attaque TO = new_attack("Tohil", 30, "Feu"); Attaque ZE = new_attack("Zeus", 90, "Foudre"); Attaque TH = new_attack("Thunraz", 70, "Foudre"); Attaque TA = new_attack("Taranis", 50, "Foudre"); Attaque AT = new_attack("Atamshkai", 30, "Foudre"); Attaque AN = new_attack("Antheia", 90, "Herbe"); Attaque KE = new_attack("Kernunnos", 70, "Herbe"); Attaque YU = new_attack("Yum Caax", 50, "Herbe"); Attaque EM = new_attack("Emesh", 30, "Herbe"); //Défini les pokemons possibles Pokemon Meliae = new_pokemon("Meliae", "Herbe", 5, 15, 25, 25, 25, KE, TA, LL, TO); Pokemon Callirhoe = new_pokemon("Callirhoe", "Eau", 5, 20, 20, 25, 25, CH, AR, YU, AT); Pokemon Melinoe = new_pokemon("Melinoe", "Feu", 5, 25, 15, 25, 25, SV, TA, YU, AO); Pokemon Eratheis = new_pokemon("Eratheis", "Foudre", 5, 15, 15, 40, 40, TH, LL, AR, EM); Pokemon Kimeira = new_pokemon("Kimeira", "Feu", 15, 50, 50, 100, 100, PO, HE, ZE, AN); //Nettoie l'écran au début du jeu nettoie(); //Le joueur choisit la difficulté diff = difficulte(); //Le joueur choisit son pokemon mon_pok = choisit_debut (Meliae, Callirhoe, Melinoe, Eratheis); //Création de la liste des pokemons adverses Kimeira en dernier pour les modes autres que facile if (diff != 1) Adversaires = ajoute(Kimeira, Adversaires); Adversaires = ajoute(Meliae, Adversaires); Adversaires = ajoute(Callirhoe, Adversaires); Adversaires = ajoute(Melinoe, Adversaires); Adversaires = ajoute(Eratheis, Adversaires); //Nettoie l'écran après avoir choisit le pokemon nettoie(); //Fait des combats tant que le joueur n'a pas perdu, ou qu'il reste des pokemons à combattre while (fini && (Adversaires != NULL)) { printf("Votre pokemon %s va affronter %s. Bonne chance !\n\n\n\n", mon_pok.Nom, (Adversaires -> adv).Nom); //Si le joueur à gagner if ((combat (mon_pok, Adversaires -> adv, diff)) == 1) { //Monte le niveau du pokemon mon_pok = level_up(mon_pok); printf("Bravo ! Vous avez gagne un niveau, %s est maintenant niveau %d.\n\n\n\n", mon_pok.Nom, mon_pok.LVL); //Le soigne mon_pok.HP = mon_pok.HPMAX; //Calcule le nombre de combats remportés nb_victoire++; //Si c'était le dernier combat, gagné if (Adversaires -> suivant == NULL) { printf("Vous avez defait tous vos adversaires.\nGagne !\n\n"); fini = 0; } //Sinon on passe au pokemon suivant else { Adversaires = Adversaires -> suivant; } } //Si le joueur à perdu, on fini le jeu else { fini = 0; //Avec ou sans s à victoire selon (0,1) ou plus if (nb_victoire > 1) { printf("Dommage, vous avez perdu apres %d victoires.\n\n", nb_victoire); } else { printf("Dommage, vous avez perdu apres %d victoire.\n\n", nb_victoire); } } } return(0); }
void end_battle(void*d) { {char window_title[255];sprintf_s(window_title,255,"SAWD [SPOILS OF WAR] - %s", GAME_BUILD_NUMBER); SetConsoleTitle(window_title);} clibwindow* black_panel = cl->open_window_noframe(0,0,79,49,0,0); // the enemy that was defeated is passed to this function obj* e = (obj*)d; int box[] = {16, 5, 48, 30}; int x = box[0] + 2; int y = box[1] + 2; clibwindow* upg_wnd = cl->open_window(box[0], box[1], box[2], box[3]); unsigned long xp_gained = e->experience; unsigned long nxt_xp = xp_to_level_up(); unsigned long gold_gained = e->gold; cl->outcharsf(x, 32, "$%8d", player->gold); draw_player_stats_end_battle(x, y); // update the experience bool next_upg = false; unsigned int counter = 0; while(!next_upg) { cl->outcharsf(x, y, "Battle Experience: %8d / %8d", player->experience, nxt_xp); player->experience++; if (player->experience >= nxt_xp) { level_up(); nxt_xp = xp_to_level_up(); draw_player_stats_end_battle(x, y); // update stats } counter++; if (counter >= xp_gained) { next_upg = true; } unsigned long start_time = timeGetTime(); while((timeGetTime() - start_time) < 60); } // update the gold next_upg = false; counter = 0; while(!next_upg) { cl->outcharsf(x, 32, "$%8d", player->gold); player->gold++; counter++; if (counter >= gold_gained) { next_upg = true; } unsigned long start_time = timeGetTime(); while((timeGetTime() - start_time) < 60); } // show items gained if any if (e->items.size()>0) { display_items_gained(e); for (unsigned int i = 0; i < e->items.size(); i++) { player->items.push_back(get_master_item(e->items.at(i)->name)); } } cl->show_message_centered(3,"","Another Victory!",""); cl->close_window(upg_wnd); cl->close_window(black_panel); }