const struct form_type form_table [] = {
/* {char * skill, char * data.messages[MAX_FORMS] int data.skPercent, int data.modifier}, */
{"spear", {
{{"You bring your spear up in an upwards arc", "brings their spear up in an upwards arc"}, 15, 0},
{{"You execute some cool move", "executes some cool move"}, 25, 5},
{{"You goof around", "goofs around"}, 35, 10},}
},
{"axe", {
{{"You bring your axe down in a wide arc", "brings their axe down in a wide arc"}, 15, 0},
{{"You swing your axe", "swings their axe"}, 25, 5},
{{"You goof around with your axe", "goofs around with their axe"}, 35, 10},}
},
{"dagger", {
{{"You fumble and almost drop your dagger as you stab", "fumbles and almost drops their dagger as they stab"}, 15, 0},
{{"You slice quickly with your dagger", "slices quickly with their dagger"}, 25, 5},
{{"You thrust your dagger forward", "thrusts their dagger forward"}, 35, 10},}
},
{"dodge", {
{{"You duck", "ducks"}, 15, 0},
{{"You quickly lean back", "quickly leans back"}, 25, 5},
{{"You take a quick step to the side", "takes a quick step to the side"}, 35, 10},}
},
{NULL, {{{"", ""}, 0, 0}, {{"", ""}, 0, 0}}}
};
/*
* Lookup forms by skill name.
*/
int form_lookup (const char *name)
{
int sn;
for (sn = 0; form_table[sn].skill != NULL; sn++)
{
if (form_table[sn].skill == name)
return sn;
}
return -1;
}
else
{
sn = number_range(0, MAX_FORMS-1);
sk = form_lookup_ch (skill_table[get_weapon_sn (ch)].name);
if (sk >=0)
pForm = form_table[sk].data[sn].messages[0];
else
pForm = "You hit";
esn = number_range(0, MAX_FORMS-1);
esk = form_lookup_vic (skill_table[get_weapon_sn (victim)].name);
if (esk >=0)
eForm = form_table[esk].data[esn].messages[1];
else
eForm = "hits";
if (dt >= 0 && dt < MAX_SKILL)
attack = skill_table[dt].noun_damage;
else if (dt >= TYPE_HIT && dt < TYPE_HIT + MAX_DAMAGE_MESSAGE)
attack = attack_table[dt - TYPE_HIT].noun;
else
{
bug ("Dam_message: bad dt %d.", dt);
dt = TYPE_HIT;
attack = attack_table[0].name;
}
if (immune)
{
if (ch == victim)
{
sprintf (buf1, "{3$n is unaffected by $s own %s.{x", attack);
sprintf (buf2, "{2Luckily, you are immune to that.{x");
}
else
{
sprintf (buf1, "{3$N is unaffected by $n's %s!{x", attack);
sprintf (buf2, "{2$N is unaffected by your %s!{x", attack);
sprintf (buf3, "{4$n's %s is powerless against you.{x",
attack);
}
}
else
{
if (ch == victim)
{
sprintf (buf1, "{3$n's %s %s $m%c{x", attack, vp, punct);
sprintf (buf2, "{2Your %s %s you%c{x", attack, vp, punct);
}
else
{
// sprintf (buf1, "{3$n's %s %s $N%c{x", attack, vp, punct);
// sprintf (buf2, "{2Your %s %s $N%c{x", attack, vp, punct);
// sprintf (buf3, "{4$n %s %s you%c{x", attack, vp, punct);
sprintf (buf1, "{3$n %s and %s $N%c{x", eForm, vp, punct);
sprintf (buf2, "{2%s and %s $N%c{x", pForm, vs, punct);
sprintf (buf3, "{4$n %s and %s you%c{x", eForm, vp, punct);
}
}
}
if (ch == victim)
{
act (buf1, ch, NULL, NULL, TO_ROOM);
act (buf2, ch, NULL, NULL, TO_CHAR);
}
else
{
act (buf1, ch, NULL, victim, TO_NOTVICT);
act (buf2, ch, NULL, victim, TO_CHAR);
act (buf3, ch, NULL, victim, TO_VICT);
}
return;
}
if (form_table[sn].skill == name)
sprintf (buf1, "{3$n %s and %s $N%c{x", eForm, vp, punct);
sprintf (buf2, "{2%s and %s $N%c{x", pForm, vs, punct);
sprintf (buf3, "{4$n %s and %s you%c{x", eForm, vp, punct);
}
}
}
if (ch == victim)
{
act (buf1, ch, NULL, NULL, TO_ROOM);
act (buf2, ch, NULL, NULL, TO_CHAR);
}
else
{
act (buf1, ch, NULL, victim, TO_NOTVICT);
act (buf2, ch, NULL, victim, TO_CHAR);
act (buf3, ch, NULL, victim, TO_VICT);
}
return;
Just took up ROM 2.4b6 codebase and am rebuilding it quite extensively. The problem is, I have no prior C experience but with my 5 years of PHP I'm making good progress.
Anyhow, the issue I'm having is: I need to get the name of the weapon skill being used by the opponent, in a fight.
The reason for this is I'm trying to use different damage messages for different weapons.
I set up a new table for the messages and I look up the correct message by skill name.
So now I've rewritten the end of dam_message with
It works fine for the attacker. But the defender is considered to always hold the same weapon as the attacker:
Also, the bystander sees:
Any thoughts on the matter would be welcome.