Also, the reason "killer &&" will work is because
Code:
if (killer && !IS_NPC(killer)) {
means
Code:
if (killer != 0x0 && !(killer->mob_flags & 4 == 1)) {
In this snippet you see two different uses of the ampersand (&):
Code:
&& means "short-circuit boolean AND"
& means "boolean AND"
Short circuit operators stop when they are no longer able to become true (non-zero).
Consider this:
Code:
#include <stdio.h>
int one(void) {
printf("one()\r\n");
return 1;
}
int zero(void) {
printf("zero()\r\n");
return 0;
}
int main(void) {
printf("one && zero = %d\r\n", one() && zero());
printf("zero && one = %d\r\n", zero() && one());
printf("one && one = %d\r\n", one() && one());
printf("zero && zero = %d\r\n", zero() && zero());
return 0;
}
The resulting output looks like this:
Code:
one()
zero()
one && zero = 0
zero()
zero && one = 0
one()
one()
one && one = 1
zero()
zero && zero = 0
As you can see, once the program receives a false (ie. a zero) it stops calling the other functions on the line.
You can see the code here to try it out:
ideone.com/lN9DTy