Welcome to the Builder Academy

Question Working on a skill that some times fires twice, that it ofc should not do

More
23 Mar 2018 23:32 - 24 Mar 2018 00:08 #7772 by JTP
Code:
int dam = 0; one_argument(argument, arg); if (!(vict = get_char_vis(ch, arg, NULL, FIND_CHAR_ROOM))) { if (FIGHTING(ch) && IN_ROOM(ch) == IN_ROOM(FIGHTING(ch))) { vict = FIGHTING(ch); } else { send_to_char(ch, "Exactly whom did you wish to attack?\r\n"); return; } } if (vict == ch) { send_to_char(ch, "Your mother would be sad!\r\n"); return; } percent = rand_number(1, 115); prob = GET_SKILL(ch, SKILL_***); if (percent > prob) { damage(ch, vict, 0, SKILL_***); } else if (GET_LEVEL(vict) < LVL_IMMORT) { if (GET_LEVEL(ch)>0) potency=1; if (GET_LEVEL(ch)>1) potency++; if (GET_LEVEL(ch)>4) potency++; if (GET_LEVEL(ch)>7) potency++; if (GET_LEVEL(ch)>10) potency++; if (GET_LEVEL(ch)>20) potency+=2; if (GET_LEVEL(ch)>30) potency+=2; if (GET_LEVEL(ch)>40) potency+=2; if (GET_LEVEL(ch)>49) potency+=2; if (GET_LEVEL(ch)>54) potency+=2; if (GET_LEVEL(ch)>57) potency=17; if ((potency<14) && (rand_number(1, 50) < GET_LEVEL(vict))) potency--; switch(potency) { case 0: dam = 1; break; case 1: dam = rand_number(1,4); break; case 2: dam = rand_number(2,10); break; case 3: dam = rand_number(3,12); break; case 4: dam = rand_number(4,16); break; case 5: dam = 20; break; case 6: dam = 20; break; case 7: dam = 35; break; case 8: dam = 50; break; case 9: dam = 70; break; case 10: dam = 75; break; case 11: dam = 100; break; case 12: dam = 100; break; case 13: dam = 150; break; case 14: case 15: case 16: case 17: dam = 150; break; } } damage(ch, vict, dam, SKILL_***);

And how come it some times fires twice (in like 1/5 times) ?

The cityguard is missed by your *****.
The cityguard is missed by your *****.



If i instead use:
damage(ch, vict, 10, SKILL_***);
Then i haven't seen it fire twice, any ideas ??
Last edit: 24 Mar 2018 00:08 by JTP.

Please Log in or Create an account to join the conversation.

More
24 Mar 2018 00:22 - 24 Mar 2018 00:34 #7773 by lacrc
I believe that it's firing twice when you missed due to it reaching two calls to damage(), one with 0 and one with dam.

You need to add a return; right after you damage(0) from when you miss:
Code:
if (percent > prob) { damage(ch, vict, 0, SKILL_***); return; /* like this <--*/ } else
OR include the call to damage(dam) in the last {}s like this:
Code:
break; } damage(ch, vict, dam, SKILL_***); }
But if I were you I would do both otherwise you're going to have Imms reaching the last damage(dam) with dam=0.
Last edit: 24 Mar 2018 00:34 by lacrc.

Please Log in or Create an account to join the conversation.

More
24 Mar 2018 00:34 #7774 by JTP
Damn was missing a return...Thanks

Please Log in or Create an account to join the conversation.

More
24 Mar 2018 00:50 #7775 by lacrc
Happens more than I would like to admit lol.
Have a good one!

Please Log in or Create an account to join the conversation.

More
24 Mar 2018 01:03 #7776 by JTP
Aparently an easy thing to miss...atleast now i Can move on to finish it up.

Please Log in or Create an account to join the conversation.

Time to create page: 0.209 seconds