Hmm, you'd definitely want to add more checks on this, but here:
- script Mob Helper -1,{
OnNPCKillEvent:
// Fixed improper usage of rand for "chance"
if (500 < rand(10000)) end;
if (mkTimed && gettimetick(2) <= mkTimed) end;
// Don't use "set" anymore, that's way outdated.
// Using getmonsterinfo isn't a bad idea, but it's somewhat useless/broken now. You'd have to expand on it in the source to make it useful.
getunitdata(killedgid, .@mobdata);
// There's no reason to use player variables in this case, the variable has no purpose outside of the NPC block code. Therefore it should be a NPC variable.
.@MobMode = .@mobdata[UMOB_MODE];
.@MobClass = .@mobdata[UMOB_CLASS];
if (!(.@MobMode & MD_CANMOVE)) end;
if (!(.@MobMode & MD_CANATTACK)) end;
// MD_BOSS/32 isn't a thing anymore either, so that code won't work.
if (.@MobClass == CLASS_BOSS) end;
// Too much wrong with these lines.
//set @WoE[0],1288|1285|1830|1949|1950|1286|1287|1899|1829; //WoE IDs
//for(set @n,0; @n < getarraysize(@WoE); set @n,@n+1){ if(@WoE[@n] == killedrid){ end; } } //WoE
// You probably meant to use "setarray", and you also probably to use commas instead of separators: setarray @woe, 1288, 1285, ..;
// Either way, that's inefficient considering this code runs on all killed monsters. Honestly I'd do the whole thing via the source instead since running a script everytime you kill a monster is overkill. Anyhow, use a dictionary seach:
if (.badMob[killedrid]) end;
.@nTime = (300 + rand(0, 120)) - getmonsterinfo(killedrid, MOB_LV);
// The main reason why your script didn't work: "summon" uses miliseconds, not seconds.
.@nTime *= 1000; // s to ms
summon "Ajudante " + getmonsterinfo(killedrid, MOB_NAME), killedrid, .@nTime;
mkTimed = gettimetick(2) + .@nTime + rand(0, 60);
message strcharinfo(0), "[" + getmonsterinfo(killedrid, MOB_NAME) + "] Hello " + strcharinfo(0) + " I will help you for a few minutes!";
end;
OnInit:
// Define bad mobs here
.badMob[1288] = 1;
.badMob[1285] = 1;
.badMob[1830] = 1;
.badMob[1949] = 1;
.badMob[1950] = 1;
.badMob[1286] = 1;
.badMob[1287] = 1;
.badMob[1899] = 1;
.badMob[1829] = 1;
end;
}