Created
April 2, 2018 20:41
-
-
Save jamesblack/c395157125d5a904dcd6e56aef67e221 to your computer and use it in GitHub Desktop.
First Kill Check for Group Members
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int do_check_first_kill(int killer, int killed); | |
int do_check_within_range(int player_a, int player_b, int range); | |
int do_check_first_kill(int killer, int killed) | |
{ | |
if (!killer) return 0; | |
if (ch[killed].class && !killed_class(killer,ch[killed].class)) { | |
do_char_log(killer,0,"You just killed your first %s. Good job.\n", | |
get_class_name(ch[killed].class)); | |
do_give_exp(killer,do_char_score(killed)*25,0,-1); | |
return 1; | |
} | |
return 0; | |
} | |
int do_check_within_range(int player_a, int player_b, int range) | |
{ | |
if (!player_a || !player_b) return 0; | |
if (player_a == player_b) return 1; | |
if ( | |
(ch[player_a].x - range < ch[player_b].x && ch[player_a].x + range > ch[player_b].x) && | |
(ch[player_a].y - range < ch[player_b].y && ch[player_a].y + range > ch[player_b].y) | |
) { | |
return 1; | |
} | |
return 0; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Line 1941 | |
if (ch[co].flags&(CF_PLAYER)) ch[cn].data[29]++; | |
else { | |
int group_member; | |
do_check_first_kill(cn, co); | |
for (n=CHD_MINGROUP; n<=CHD_MAXGROUP; n++) { | |
if ((group_member=ch[cn].data[n])) { | |
if (isgroup(group_member, cn) && do_check_within_range(cn, group_member, 5)) { | |
if (do_check_first_kill(group_member, co)) { | |
chlog(group_member, "Recieved a first kill when %s killed %s (%d)", ch[cn].name, ch[co].name, co); | |
} | |
} | |
} | |
} | |
} | |
// Line 1957 | |
// a follower (garg, ghost comp or whatever) killed someone or something. | |
if (cn && cn!=co && !(ch[cn].flags&(CF_PLAYER)) && (cc=ch[cn].data[63])!=0 && (ch[cc].flags&(CF_PLAYER))) { | |
if (!(ch[co].flags&(CF_PLAYER)) && ch[co].alignment==10000) { | |
do_char_log(cc,0,"A goddess is about to turn your follower into a frog, but notices that you are responsible. You feel her do something to you. Nothing good, that's for sure.\n"); | |
ch[cc].data[40]++; | |
if (ch[cc].data[40]<50) tmp=-ch[cc].data[40]*100; | |
else tmp=-5000; | |
ch[cc].luck+=tmp; | |
chlog(cc,"Reduced luck by %d to %d for killing %s (%d, t=%d)",tmp,ch[cn].luck,ch[co].name,co,ch[co].temp); | |
} | |
int group_member; | |
do_check_first_kill(cc, co); | |
for (n=CHD_MINGROUP; n<=CHD_MAXGROUP; n++) { | |
if ((group_member=ch[cc].data[n])) { | |
if (isgroup(group_member, cc) && do_check_within_range(cc, group_member, 5)) { | |
if (do_check_first_kill(group_member, co)) { | |
chlog(group_member, "Recieved a first kill when %s killed %s (%d)", ch[cc].name, ch[co].name, co); | |
} | |
} | |
} | |
} | |
do_area_notify(cc,co,ch[cc].x,ch[cc].y,NT_SEEHIT,cc,co,0,0); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment