PDA

View Full Version : Spawning multiple mobs in random locs


BWStripes
05-14-2009, 03:03 PM
This might be dangerous to do, but I thought I would give it a go. Are there any reasons why we can't/shouldn't use while loops in the quest system?

It does work by the way ^_^

$count = 0;
while ($count <= 24) {
$randX = int(rand(60));
$randY = int(rand(90));
$randZ = int(rand(45));
$randH = int(rand(260));
$randPNX = int(rand(2));
$randPNY = int(rand(2));
$randPNZ = int(rand(2));
##quest::say("Randomness1: $randX, $randY, $randZ, $randH, $randPNX, $randPNY, $randPNZ");
if($randPNX == 1) {
$randX = -$randX;
}
if($randPNY == 1) {
$randY = -$randY;
}
if($randPNZ == 1) {
$randZ = -$randZ;
}
##quest::say("Randomness2: $randX, $randY, $randZ, $randH");
quest::spawn2(216071,0,0,$randX,$randY,$randZ,$ran dH); # Triloun Vaporfiend
$count ++;
}

So_1337
05-14-2009, 03:11 PM
Let me guess, for encounters like... Coirnav? =)

Very nice.

BWStripes
05-14-2009, 03:16 PM
Yeah, Nork is working hard *cough*itsme* on it.

cavedude
05-14-2009, 03:33 PM
Loops are fine, so long as you terminate them properly. An endless loop in the EQEmu code not long ago increased load noticeably. I'd hate to see what Perl could do!

trevius
05-14-2009, 10:32 PM
Yeah, this should be fine as long as it isn't running it extremely often. The only time I have seen quests cause major impact on Storm Haven is when I first got the client search quest script working for part of my custom Thanksgiving event. Initially, I had it doing a FOR loop every second from 0 to 2000 for all entities with IDs in that range and then doing distance calculations and other stuff lol. It wasn't actually too bad on the server until I kept spawning more turkeys for testing and finally it got pretty noticeable lol. Not to mention that I had something in the script that was incorrect a bit and generating a ton of quest log entries every second. After leaving it running for a while before I fixed all issues, I had a few GBs of log files!

BWStripes
05-15-2009, 06:38 AM
Poor Turkeys :)
Thanks, I hadn't seen while loops used in any scripts so I'd assumed there was a reason, rather than lack of support.

Interestingly, that raises the question of handling turn-ins in a loop, since live clearly does it for tasks that require >4 turn-ins.

I suppose using variables, you could then also support a fledgling Multi-Quest system, assuming that the zone wasn't dynamic and the server was going to stay up a while. Personally I hated MQ'd tasks on live, but that is in the past. Grr.