function script B_Sunlight {
if (getcharid(1)) {
getmapxy(.@map1$, .@x1, .@y1, 0);
getpartymember getcharid(1), 1;
getpartymember getcharid(1), 2;
for(set .@i,0; .@i < $@partymembercount; set .@i,.@i+1) {
if (isloggedin($@partymemberaid[.@i], $@partymembercid[.@i])) {
attachrid $@partymemberaid[.@i];
if (HP > 0) {
getmapxy(.@map2$,.@x2,.@y2,0);
if ((.@map1$ == .@map2$) && (distance(.@x1,.@y1,.@x2,.@y2) <= 30)) {
sc_start SC_Intravision,30000,0;
}
}
}
}
} else {
sc_start SC_Intravision,30000,0;
}
end;
}
This should work, I can't test for you. This script will also check the range between the party member and only affect members within the screen (and alive).
Change your Box of Sunlight item_db script into
callfunc "B_Sunlight";