I was being a smart ass by not offering any help or suggestion.
If I were to get special attacks in the zone I would do it via DBI this way.
It really doesn't make a whole lot of sense to try and push entity variables into memory when you can do it simply via another means.
Query the zone NPC types data and push it into a 3D hash that you can quickly reference.
Assuming you have some sort of controller NPC that is handling scaling you can do something like:
Code:
sub LoadMysql{
use DBI;
use DBD::mysql;
# CONFIG VARIABLES
my $confile = "eqemu_config.xml"; #default
open(F, "<$confile") or die "Unable to open config: $confile\n";
my $indb = 0;
while(<F>) {
s/\r//g;
if(/<database>/i) { $indb = 1; }
next unless($indb == 1);
if(/<\/database>/i) { $indb = 0; last; }
if(/<host>(.*)<\/host>/i) { $host = $1; }
elsif(/<username>(.*)<\/username>/i) { $user = $1; }
elsif(/<password>(.*)<\/password>/i) { $pass = $1; }
elsif(/<db>(.*)<\/db>/i) { $db = $1; }
}
# DATA SOURCE NAME
$dsn = "dbi:mysql:$db:localhost:3306";
# PERL DBI CONNECT
$connect = DBI->connect($dsn, $user, $pass);
}
sub LoadStaticZoneScaling{
### Load Static Zone Scaling Data ###
$connect = plugin::LoadMysql();
$query = "SELECT
spawnentry.npcID,
npc_types.npcspecialattks,
npc_types.name,
spawn2.zone,
spawn2.`version`,
spawn2.respawntime,
spawn2.spawngroupID
FROM
spawnentry
Inner Join spawn2 ON spawnentry.spawngroupID = spawn2.spawngroupID
Inner Join npc_types ON spawnentry.npcID = npc_types.id
where spawn2.zone = '" . $zonesn . "' and spawnentry.npcID > 0 and spawn2.version = " . $instanceversion . "
GROUP by npc_types.name";
$query_handle = $connect->prepare($query); $query_handle->execute();
### Let's put the cache data into memory...
while (@row = $query_handle->fetchrow_array()){ $ScalingData[$row[0]] = [@row]; }
}
Then, when you spawn or want to do a sanity check to make sure that $ScalingData has actually been loaded, you can do a bool after the while so that if you've already done the query, you don't need to hit the DB with another inner join - this will stay persistent through a zones lifespan. This is similar to how I perform scaling but I involve several tables of data.
When you want to reference it in script you can then set entity variables during the load, after the load or however.
For example, let's say I already did sub LoadStaticZoneScaling in my EVENT_SPAWN
I can do:
Code:
my @NLIST = $entity_list->GetNPCList();
foreach my $NPC (@NLIST){
$NPC->SetEntityVariable("SpecialAttacks", $ScalingData[$NPC->GetNPCTypeID()][1]);
}
This would set all entities in the zone with their special attacks.
With this you run into the issue of NPC's spawning and needing that data again. You will need to do something in global_npc.pl to trigger a fetch for the data again - you can toss it around a few different ways.
Hopefully that helps and gives you an idea - that will help you prevent overwriting an NPC's special attacks if they have them already.