Nimono
02-17-2007, 01:18 PM
(Copied-and-Pasted from original post at PureZC, with minor adjustments...)
Well, ignore the lame name for this script. The only other name I had for it was "Random Killer", and that didn't sound very good. This sounds a bit better. Variable "Magic" is the magic required to use this item, in 32nds of a Magic Container. Want to use whole containers? Multiply 32 by the number of containers you wish to use and tack that on as the value of variable "Magic". :p
// Destruction Machine- This item randomly kills one enemy in the current room.
item script Killer
{
int RandNum = 0;
int RandNPC = 0;
int Magic = 192;
void run()
{
if (Link->MP >= Magic)
{
int ScrnNPC = Screen->NumNPCs();
if (ScrnNPC == 0)
{
Quit();
}
else if (ScrnNPC == 1)
{
npc RandNPC = Screen->LoadNPC (1);
RandNPC->HP = 0;
}
else if (ScrnNPC == 2)
{
RandNum = 1 + Rand(2);
npc RandNPC = Screen->LoadNPC (RandNum);
RandNPC->HP = 0;
}
else if (ScrnNPC == 3)
{
RandNum = 1 + Rand(3);
npc RandNPC = Screen->LoadNPC (RandNum);
RandNPC->HP = 0;
}
else if (ScrnNPC == 4)
{
RandNum = 1 + Rand(4);
npc RandNPC = Screen->LoadNPC (RandNum);
RandNPC->HP = 0;
}
else if (ScrnNPC == 5)
{
RandNum = 1 + Rand(5);
npc RandNPC = Screen->LoadNPC (RandNum);
RandNPC->HP = 0;
}
else if (ScrnNPC == 6)
{
RandNum = 1 + Rand(6);
npc RandNPC = Screen->LoadNPC (RandNum);
RandNPC->HP = 0;
}
else if (ScrnNPC == 7)
{
RandNum = 1 + Rand(7);
npc RandNPC = Screen->LoadNPC (RandNum);
RandNPC->HP = 0;
}
else if (ScrnNPC == 8)
{
RandNum = 1 + Rand(8);
npc RandNPC = Screen->LoadNPC (RandNum);
RandNPC->HP = 0;
}
else if (ScrnNPC == 9)
{
RandNum = 1 + Rand(9);
npc RandNPC = Screen->LoadNPC (RandNum);
RandNPC->HP = 0;
}
else if (ScrnNPC == 10)
{
RandNum = 1 + Rand(10);
npc RandNPC = Screen->LoadNPC (RandNum);
RandNPC->HP = 0;
}
Link->MP = Link->MP - Magic;
}
}
}
Yes, all those checks are necessary. It'll crash ZC if it finds an invalid NPC, so... ;) Oh yeah, you might want to disable this in Guy rooms. Otherwise, you'll KILL the guy. :O I think. Oh well. Have fun.
Okay, I need to say this: NO ONE HAS BEEN ABLE TO SHORTEN THIS SCRIPT AND MAKE IT WORK. If you think you can figure out a way to shorten this script, TEST IT FIRST BEFORE SENDING IT TO ME. I always got the exact same result from those at PureZC: The script failed to do anything but take away magic... So please, TEST THE SCRIPT BEFORE SENDING A "SHORTENED" VERSION TO ME. I'm getting quite annoyed at all the so-called "shortened" versions that don't work at all. -_- And why did I not post this here when I released it at PureZC? ...I didn't think it'd be right. XD But I decided to now. :)
Well, ignore the lame name for this script. The only other name I had for it was "Random Killer", and that didn't sound very good. This sounds a bit better. Variable "Magic" is the magic required to use this item, in 32nds of a Magic Container. Want to use whole containers? Multiply 32 by the number of containers you wish to use and tack that on as the value of variable "Magic". :p
// Destruction Machine- This item randomly kills one enemy in the current room.
item script Killer
{
int RandNum = 0;
int RandNPC = 0;
int Magic = 192;
void run()
{
if (Link->MP >= Magic)
{
int ScrnNPC = Screen->NumNPCs();
if (ScrnNPC == 0)
{
Quit();
}
else if (ScrnNPC == 1)
{
npc RandNPC = Screen->LoadNPC (1);
RandNPC->HP = 0;
}
else if (ScrnNPC == 2)
{
RandNum = 1 + Rand(2);
npc RandNPC = Screen->LoadNPC (RandNum);
RandNPC->HP = 0;
}
else if (ScrnNPC == 3)
{
RandNum = 1 + Rand(3);
npc RandNPC = Screen->LoadNPC (RandNum);
RandNPC->HP = 0;
}
else if (ScrnNPC == 4)
{
RandNum = 1 + Rand(4);
npc RandNPC = Screen->LoadNPC (RandNum);
RandNPC->HP = 0;
}
else if (ScrnNPC == 5)
{
RandNum = 1 + Rand(5);
npc RandNPC = Screen->LoadNPC (RandNum);
RandNPC->HP = 0;
}
else if (ScrnNPC == 6)
{
RandNum = 1 + Rand(6);
npc RandNPC = Screen->LoadNPC (RandNum);
RandNPC->HP = 0;
}
else if (ScrnNPC == 7)
{
RandNum = 1 + Rand(7);
npc RandNPC = Screen->LoadNPC (RandNum);
RandNPC->HP = 0;
}
else if (ScrnNPC == 8)
{
RandNum = 1 + Rand(8);
npc RandNPC = Screen->LoadNPC (RandNum);
RandNPC->HP = 0;
}
else if (ScrnNPC == 9)
{
RandNum = 1 + Rand(9);
npc RandNPC = Screen->LoadNPC (RandNum);
RandNPC->HP = 0;
}
else if (ScrnNPC == 10)
{
RandNum = 1 + Rand(10);
npc RandNPC = Screen->LoadNPC (RandNum);
RandNPC->HP = 0;
}
Link->MP = Link->MP - Magic;
}
}
}
Yes, all those checks are necessary. It'll crash ZC if it finds an invalid NPC, so... ;) Oh yeah, you might want to disable this in Guy rooms. Otherwise, you'll KILL the guy. :O I think. Oh well. Have fun.
Okay, I need to say this: NO ONE HAS BEEN ABLE TO SHORTEN THIS SCRIPT AND MAKE IT WORK. If you think you can figure out a way to shorten this script, TEST IT FIRST BEFORE SENDING IT TO ME. I always got the exact same result from those at PureZC: The script failed to do anything but take away magic... So please, TEST THE SCRIPT BEFORE SENDING A "SHORTENED" VERSION TO ME. I'm getting quite annoyed at all the so-called "shortened" versions that don't work at all. -_- And why did I not post this here when I released it at PureZC? ...I didn't think it'd be right. XD But I decided to now. :)