Example #1
0
void victory(struct player* hero, struct creature* enemy)
{
	if (enemy -> exp == 40)
	{
		script_speaking("Necromancer", 4, "I...", "will never be a memory...", "We will meet again soon enough...", "And then I WILL kill you");
		script_speaking("Hero", 3, "(merely standing on his feet) Finally...", "I think I'll stay here for a while", "I need to recover from the battle");
	}

	rank_player( hero, enemy -> exp );
}
Example #2
0
int battle(struct player* hero, struct creature *enemy)
{
	int act;

	if (enemy -> hp == 200)
	{
		script_speaking("Necromancer", 1, "How dare you, mere human, interfere in my great plans!");
		script_speaking("Hero", 1, "Oh, don't worry. Nothing personal, really. I just like beeing a thorn in someone's side.");
		script_speaking("Necromancer", 1, "Fool! That was your last mistake! You won't leave this place alive!");
		script_speaking("Hero", 2, "Yeah-yeah, whatever you say, pal.", "(to himself) It's showtime!");
	}

	while (1)
	{
		printf("Potions left: %d\n", hero -> potions);
		printf("What should we do???\n");
		printf("HP: %d/%d %s's HP:%d\n", hero -> hp, hero -> max_hp, enemy -> name, enemy -> hp);
		printf("1.Attack\n");
		printf("2.Use potion / +50 HP\n");
		printf("3.Leave the battle\n");
		scanf("%d",&act);
		system("clear");
		switch (act)
		{
			case 1: hit(hero, enemy);
					if (hero -> hp <= 0)
					{
						printf("Bad end!\nGame over...\n");
						return 2;
					}
					if (enemy -> hp <= 0)
					{
						victory(hero, enemy);
						return 0;
					}
					break;
			case 2: heal( hero );
					break;
			case 3:
				if (enemy -> exp != 40)
					return 1;
				else
					printf("Cannot flee from this battle...\n");
				break;
			default:
				printf("Choose action form one of the mentioned above\n");
		}
	}
	return 0;
}
Example #3
0
int main()
{
	int battle_number;

	hero = malloc(sizeof(struct player));
	if (hero == NULL)
	{
		printf("Everything is bad with hero\n");
		return 0;
	}

	init_hero( hero );
	
	necromancer = malloc(sizeof(struct creature));
	if (necromancer == NULL)
	{
		printf("Everything is bad with necromancer\n");
		return 0;
	}

	init_necromancer( necromancer );

	printf("Welcome, traveler. You are about to embark on your epic quest.\n\n");
	script_speaking("Villager", 2, "Oh, stranger! Good timing! You look like an experienced warrior!", "Please, help us! Evil necromancer terrorizes our village!"); 
	script_speaking("Villager", 2, "Many of us have already tried to slay him but they failed...", "Please, slay him for us!!!\n");
	
	for (battle_number = 0; battle_number < 5; battle_number++)
	{
		if ( battle(hero, enemy_encountered()) == 2)
			return 0;
	}

	script_speaking("Hero", 3, "Seems like there are no necromancer minions left.", "Ah, he finally decided to show himself!", "Hell, it's about time!");
	
	battle(hero, necromancer);
	
	return 0;
}