Hello, i m newbie and i want to ask if there a way to make my databale shorten and more smart. To be not nessessary every time to type all those ifs.
An example would be perfect.
Thanks
Code:
if(event == 1)
{
sprintf(mob_name, "Leles Birian");
sprintf(mob_sex, "female");
sprintf(mob_race, "breton");
sprintf(mob_class, "mage");
mob_level = 25;
mob_ac = 5;
mob_thac0 = 11;
}
if(event == 2)
{
sprintf(mob_name, "Nels Llendo");
sprintf(mob_sex, "male");
sprintf(mob_race, "dunmer");
sprintf(mob_class, "thief");
mob_level = 25;
mob_ac = 5;
mob_thac0 = 11;
}
if(event == 3)
{
sprintf(mob_name, "Nevrasa Dralor");
sprintf(mob_sex, "female");
sprintf(mob_race, "dunmer");
sprintf(mob_class, "pilgrim");
mob_level = 25;
mob_ac = 5;
mob_thac0 = 11;
}
ch_printf(ch, "&PI am fighting &R%s&P, the %s %s %s.&D\r\n", mob_name, mob_sex, mob_race, mob_class);
if((player_thac0 - player_dice) < mob_ac)
{
ch_printf(ch, "\r\n");
ch_printf(ch, "&PThe arena battle is over and i won.&D\r\n");
experience = (mob_level * 100);
ch->exp = ch->exp + experience;
ch_printf(ch, "&PI earned &R%d&P exp.&D\r\n", experience);
for(size_t i = 0; i < sizeof(loot) / sizeof(loot[0]); ++i)
{
item = create_object(get_obj_index(loot[i][selection]), 0);
break;
};
obj_to_char(item, ch);
ch_printf(ch, "&PI got a &R%s&P.&D\r\n", item->name);
}
else if((mob_thac0 - mob_dice) < player_AC)
{
ch_printf(ch, "\r\n");
ch_printf(ch, "&PThe arena battle is over and i lost.&D\r\n");
dmg = (number_range(1,mob_level) + 0)+(number_range(1,mob_level) + 0)+(number_range(1,mob_level) + 0);
ch_printf(ch, "&PI suffered &R%d&P dmg.&D\r\n", dmg);
global_retcode = damage(ch, ch, dmg, gsn_shock_damage);
}
else
{
ch_printf(ch, "&PWe both run away!&D\r\n");
}