15 Oct, 2008, Igabod wrote in the 1st comment:
Votes: 0
i'm playing around with keggermud (rom/quickmud derivative) and wanted to have dual wield capability. i downloaded dualwieldpatch2 from the repository here and at first i had no problems with it, but when i get to the fight.c part it becomes a little confusing. i was wondering if somebody could clear this up for me. the snippet says the following.

***in fight.c***

replace any names that look like one_hit and make it mob_hit
then follow below:

replace this void mob_hit args( ( CHAR_DATA *ch, CHAR_DATA *victim, int dt ) );

with this:
void mob_hit args( ( CHAR_DATA *ch, CHAR_DATA *victim, int dt, bool secondary ) );

the part that confuses me is do i seriously change every single reference to one_hit, or what? cause theres void one_hit there and there are a few others in there that look like they should remain as they are. also the snippet refers to void do_attack which isn't in the code in ANY file. basically this looks like it was written for a different code base cause it also refers to sendch instead of send_to_char. i'm just looking for someone who can make this snippet make sense to me.

[edit] i posted this question here because there is no contact info for the author of the snippet in the file
15 Oct, 2008, Chris Bailey wrote in the 2nd comment:
Votes: 0
I'm not familiar with the codebase or the snippet but my first guess would be to replace any reference to one_hit with mob_hit. That is what the snippet calls for, however strange it may be. If it doesn't work out, just change it back. ?
15 Oct, 2008, Igabod wrote in the 3rd comment:
Votes: 0
unfortunately thats not my only problem, i also have parts that don't exist in the codebase that the snippet refers to. i'd rather get some more info on this snippet before i do all the changes it calls for. it really looks like this was written for something other than rom even though i got it from the rom snippets section. if you want to look at the snippet itself and see why i'm confused it is located here

[edit] and the source code for keggermud is here
15 Oct, 2008, The_Fury wrote in the 4th comment:
Votes: 0
Snippets often not are not just drop in, you will find a lot of times that there are things that don't look the same or are in fact completely different. While Kegger is a rom derived mud, it will have things added to it or changed things that were not in the snippet authors rom version.

I think what the part of the snippet is asking it in fight.c change any call to one_hit to mob_hit and then change any call to mob_hit to be as per the 2nd instruction.
15 Oct, 2008, Igabod wrote in the 5th comment:
Votes: 0
ok… that cleared nothing up for me The_Fury… you just said the same thing as the snippet says. i still don't know if i am supposed to change EVERY one_hit to mob_hit. for example, the first one_hit in fight.c is this

void one_hit args ((CHAR_DATA * ch, CHAR_DATA * victim, int dt));
void mob_hit args ((CHAR_DATA * ch, CHAR_DATA * victim, int dt));

notice that it is followed mob_hit so if i change that one_hit to mob_hit i'll have the exact same line twice. plus do i need to change the void one_hit section that looks like this

void one_hit (CHAR_DATA * ch, CHAR_DATA * victim, int dt)
{
OBJ_DATA *wield;
int victim_ac;
int thac0;
int thac0_00;
int thac0_32;
int dam;
int diceroll;
int sn, skill;
int dam_type;
bool result;

sn = -1;


/* just in case */
if (victim == ch || ch == NULL || victim == NULL)
return;

/*
* Can't beat a dead char!
* Guard against weird room-leavings.
*/
if (victim->position == POS_DEAD || ch->in_room != victim->in_room)
return;

/*
* Figure out the type of damage message.
*/
wield = get_eq_char (ch, WEAR_WIELD);

if (dt == TYPE_UNDEFINED)
{
dt = TYPE_HIT;
if (wield != NULL && wield->item_type == ITEM_WEAPON)
dt += wield->value[3];
else
dt += ch->dam_type;
}

if (dt < TYPE_HIT)
if (wield != NULL)
dam_type = attack_table[wield->value[3]].damage;
else
dam_type = attack_table[ch->dam_type].damage;
else
dam_type = attack_table[dt - TYPE_HIT].damage;

if (dam_type == -1)
dam_type = DAM_BASH;

/* get the weapon skill */
sn = get_weapon_sn (ch);
skill = 20 + get_weapon_skill (ch, sn);

/*
* Calculate to-hit-armor-class-0 versus armor.
*/
if (IS_NPC (ch))
{
thac0_00 = 20;
thac0_32 = -4; /* as good as a thief */
if (IS_SET (ch->act, ACT_WARRIOR))
thac0_32 = -10;
else if (IS_SET (ch->act, ACT_THIEF))
thac0_32 = -4;
else if (IS_SET (ch->act, ACT_CLERIC))
thac0_32 = 2;
else if (IS_SET (ch->act, ACT_MAGE))
thac0_32 = 6;
}
else
{
thac0_00 = class_table[ch->class].thac0_00;
thac0_32 = class_table[ch->class].thac0_32;
}
thac0 = interpolate (ch->level, thac0_00, thac0_32);

if (thac0 < 0)
thac0 = thac0 / 2;

if (thac0 < -5)
thac0 = -5 + (thac0 + 5) / 2;

thac0 -= GET_HITROLL (ch) * skill / 100;
thac0 += 5 * (100 - skill) / 100;

if (dt == gsn_backstab)
thac0 -= 10 * (100 - get_skill (ch, gsn_backstab));

if (dt == gsn_circle)
thac0 -= 10 * (100 - get_skill (ch, gsn_circle));

if ( dt == gsn_backstab && wield != NULL)
if ( wield->value[0] != 2 )
dam *= 2 + (ch->level / 10);
else
dam *= 2 + (ch->level / 8);

if ( dt == gsn_circle && wield != NULL)
if ( wield->value[0] != 2 )
dam *= 2 + (ch->level / 10);
else
dam *= 2 + (ch->level / 8);

switch (dam_type)
{
case (DAM_PIERCE):
victim_ac = GET_AC (victim, AC_PIERCE) / 10;
break;
case (DAM_BASH):
victim_ac = GET_AC (victim, AC_BASH) / 10;
break;
case (DAM_SLASH):
victim_ac = GET_AC (victim, AC_SLASH) / 10;
break;
default:
victim_ac = GET_AC (victim, AC_EXOTIC) / 10;
break;
};

if (victim_ac < -15)
victim_ac = (victim_ac + 15) / 5 - 15;

if (!can_see (ch, victim))
victim_ac -= 4;

if (victim->position < POS_FIGHTING)
victim_ac += 4;

if (victim->position < POS_RESTING)
victim_ac += 6;

/*
* The moment of excitement!
*/
while ((diceroll = number_bits (5)) >= 20);

if (diceroll == 0 || (diceroll != 19 && diceroll < thac0 - victim_ac))

there is more to it, i just didn't want it to be that long so i cut it off.
15 Oct, 2008, The_Fury wrote in the 6th comment:
Votes: 0
Quote
ok… that cleared nothing up for me The_Fury… you just said the same thing as the snippet says. i still don't know if i am supposed to change EVERY one_hit to mob_hit. for example, the first one_hit in fight.c is this


LOL sorry, its not the best instruction set, after looking at the snippet the the kegger code, i would change ONLY the mob_hit calls adding secondary to them and adding secondary also to the function prototype. Then change this block of code to look like this:

if (IS_SET (ch->off_flags, OFF_AREA_ATTACK))
{
for (vch = ch->in_room->people; vch != NULL; vch = vch_next)
{
vch_next = vch->next;
if ((vch != victim && vch->fighting == ch))
one_hit (ch, vch, dt);
}
}

..
if (IS_SET (ch->off_flags, OFF_AREA_ATTACK))
{
for (vch = ch->in_room->people; vch != NULL; vch = vch_next)
{
vch_next = vch->next;
if ((vch != victim && vch->fighting == ch))
mob_hit( ch, victim, dt, FALSE );

if (get_eq_char (ch, WEAR_SECONDARY))
{
mob_hit( ch, victim, dt, TRUE );
if ( ch->fighting != victim )
return;
}
}
}


Well thats what i make of it. Let us know how you fair now.
15 Oct, 2008, Sandi wrote in the 7th comment:
Votes: 0
You're right, there's a lot of non-stock stuff in there.

"replace any names that look like one_hit and make it mob_hit"

"Look like"?? Even for me, this is a puzzle. My advice is to find another snippet. :)

I can tell you in stock ROM there are both one_hit and mob_hit functions, and they're not interchangeable, and you should be adding that boolean to both.


PS: Yes, you're right, about the declarations, the snippet seems wrong.
16 Oct, 2008, The_Fury wrote in the 8th comment:
Votes: 0
Try this patch instead, it looks like that same snippet without all the misleading directions.

http://www.mudbytes.net/index.php?a=file...

IF you look at this patch you will see it is identical to the other in most ways, except it does nothing with mob hit and only changes one_hit.

You can use the patch command to add the code, if it fails anywhere it will report what on and you then need to manually change those part. If you have never looked at a patch file + means add this line code, - means remove this ling of code.
16 Oct, 2008, Igabod wrote in the 9th comment:
Votes: 0
i don't have the patch command on cygwin unfortunately, but i'm sure i can figure out where to put it all. thanks for the help. glad to see i'm not the only one confused by that snippet. i'm sure i'll have dozens of other questions about snippets in the near future because i'm trying to install every snippet i can into a mud successfully so i can maybe learn a little more. don't worry i won't add to the already large supply of snippet muds out there, this is strictly for learning experience.
16 Oct, 2008, David Haley wrote in the 10th comment:
Votes: 0
FWIW, I think that you can install patch from the Cygwin setup utility.
16 Oct, 2008, Igabod wrote in the 11th comment:
Votes: 0
i'll be sure to look for that whenever i get bored enough, meanwhile i got the dual wield patch installed correctly with only minor modifications due to other snippets i had installed. thanks for the help everybody.
16 Oct, 2008, The_Fury wrote in the 12th comment:
Votes: 0
Grats, glad you got there in the end.
16 Oct, 2008, Sandi wrote in the 13th comment:
Votes: 0
My favorite snip was Gothar's Bank Code. Great instructions, and I often referred to it for help in adding commands and such.

It inspired my own "reward.c", which includes a bunch of handy functions and hopefully, explicit directions.
16 Oct, 2008, Hades_Kane wrote in the 14th comment:
Votes: 0
What it is asking you to do is take the one_hit and mob_hit functions (and others that do basically the same thing) and add the 'bool secondary' value at the end.

This would not only entail updating the functions itself, but also any declarations of the function, and any and all calls to the function itself.

We have dual wield code… I'm not sure if it was a snippet or not, dual wielding was added before I took over as the coder, but in my dual wield code, what the 'bool secondary' part does is denote whether or not the hit that is being delivered is a primary or secondary hit. If it is a primary hit, it is sure to go off of your primary weapon and do full damage, if it is a secondary hit, the amount of damage is often times modified by your dual wield skill %, and it is sure to calculate off of your secondary weapon instead.

I don't know if you fully solved this issue or not, but I hope I was able to clear some of it up.
0.0/14