Go Back   EQEmulator Home > EQEmulator Forums > Support > Support::Windows Servers

Support::Windows Servers Support forum for Windows EQEMu users.

Reply
 
Thread Tools Display Modes
  #1  
Old 10-29-2013, 08:02 AM
NatedogEZ's Avatar
NatedogEZ
Developer
 
Join Date: Dec 2012
Posts: 515
Default Prespawn this a good idea or no?

Before NPCs spawn I want to set entity variables to them if they have certain special attacks.. that way I can just use the entity variables to dictate what special attacks I want to add to them if any...

My Perl script works well with this so far as in it skips mobs that already have Special attacks set in the database and adds special attacks to the mobs that do not have any (usually trash mobs).

The second loop is only to check if they have ANY of them so that my scaling script will skip them in the process of adding special attacks to NPCs.

My question is... would this bog down the server at all adding that many entity variables to an NPC? Mainly the first loop that adds the specific entity variables based on the type they have.



Code:
void NPC::mod_prespawn(Spawn2 *sp) 
{

	for( int i = 1; i < 36; i++ )
	{
		if(GetSpecialAbility(i))
		{
			const char* HasAbility = "1";
			const char* SpecialList[] = {"SPECATK_SUMMON", "SPECATK_ENRAGE", "SPECATK_RAMPAGE", "SPECATK_AREA_RAMPAGE", "SPECATK_FLURRY", "SPECATK_TRIPLE", "SPECATK_QUAD", "SPECATK_INNATE_DW", "SPECATK_BANE", "SPECATK_MAGICAL", "SPECATK_RANGED_ATK", "UNSLOWABLE", "UNMEZABLE", "UNCHARMABLE", "UNSTUNABLE", "UNSNAREABLE", "UNFEARABLE", "UNDISPELLABLE", "IMMUNE_MELEE", "IMMUNE_MAGIC", "IMMUNE_FLEEING", "IMMUNE_MELEE_EXCEPT_BANE", "IMMUNE_MELEE_NONMAGICAL", "IMMUNE_AGGRO", "IMMUNE_AGGRO_ON", "IMMUNE_CASTING_FROM_RANGE", "IMMUNE_FEIGN_DEATH", "IMMUNE_TAUNT", "NPC_TUNNELVISION", "NPC_NO_BUFFHEAL_FRIENDS", "IMMUNE_PACIFY", "LEASH", "TETHER", "DESTRUCTIBLE_OBJECT", "NO_HARM_FROM_CLIENT"};
			SetEntityVariable(SpecialList[i-1], HasAbility);
		}
	}

	for( int i = 1; i < 36; i++ )
	{
		if(GetSpecialAbility(i))
		{
			const char* HasAbility = "1";
			const char* Stuff = "HasSpecial";
			SetEntityVariable(Stuff, HasAbility);
			break;
		}
	}
}
Reply With Quote
  #2  
Old 10-29-2013, 12:26 PM
Tabasco's Avatar
Tabasco
Discordant
 
Join Date: Sep 2009
Posts: 270
Default

I suppose it depends on how many NPC's have special attacks and how much memory you have. In any case I wouldn't expect it to increase your memory usage per NPC in a really significant way and I don't think the processing overhead would be noticeable unless you were repopping a large zone.

I don't have the big picture here, but what you're storing appears to be redundant. There are quest functions for getting and setting special attacks already. Is there a particular reason you want it stored that way?
__________________
http://dungeoncrawl.us.to
Reply With Quote
  #3  
Old 10-29-2013, 04:53 PM
NatedogEZ's Avatar
NatedogEZ
Developer
 
Join Date: Dec 2012
Posts: 515
Default

I don't see anything for getting NPC special attacks in perl... or am I missing it?


nvm... I was missing it by a mile..

HasNPCSpecialAtk("Z")


Found it lol thank you! (I didn't think there was a function for this.. now I know!)


I still need the second part though so I know if NPCs have ANY special attack that way I dont overwrite them when I scale the zone.
Reply With Quote
  #4  
Old 10-29-2013, 05:05 PM
Tabasco's Avatar
Tabasco
Discordant
 
Join Date: Sep 2009
Posts: 270
Default

I kept looking for it under a different name, but it's there.

$mob->HasNPCSpecialAtk("<flags>")
__________________
http://dungeoncrawl.us.to
Reply With Quote
  #5  
Old 10-29-2013, 06:07 PM
Akkadius's Avatar
Akkadius
Administrator
 
Join Date: Feb 2009
Location: MN
Posts: 2,071
Default

Natedog, this is a bad idea
Reply With Quote
  #6  
Old 10-29-2013, 06:14 PM
NatedogEZ's Avatar
NatedogEZ
Developer
 
Join Date: Dec 2012
Posts: 515
Default

Second part a bad idea? May I ask why? :p


(just this part.. I want to know if they have special abilities before I start messing with them in perl)

Code:
void NPC::mod_prespawn(Spawn2 *sp) 
{
	for( int i = 1; i < 36; i++ )
	{
		if(GetSpecialAbility(i))
		{
			const char* HasAbility = "1";
			const char* Stuff = "HasSpecial";
			SetEntityVariable(Stuff, HasAbility);
			break;
		}
	}
}
Reply With Quote
  #7  
Old 10-30-2013, 01:15 AM
Akkadius's Avatar
Akkadius
Administrator
 
Join Date: Feb 2009
Location: MN
Posts: 2,071
Default

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.

Last edited by Akkadius; 10-30-2013 at 01:40 AM..
Reply With Quote
  #8  
Old 10-30-2013, 01:35 AM
NatedogEZ's Avatar
NatedogEZ
Developer
 
Join Date: Dec 2012
Posts: 515
Default

Ah thanks Akkadius that actually seems like a better idea
Reply With Quote
  #9  
Old 10-30-2013, 01:41 AM
Akkadius's Avatar
Akkadius
Administrator
 
Join Date: Feb 2009
Location: MN
Posts: 2,071
Default

Quote:
Originally Posted by NatedogEZ View Post
Ah thanks Akkadius that actually seems like a better idea
I do believe you got the idea but I edited my script after I looked at it quick I noticed I wasn't executing the script:

$query_handle = $connect->prepare($query); $query_handle->execute();

Otherwise most of it should be fairly accurate.

Hopefully it helps
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

   

All times are GMT -4. The time now is 11:36 AM.


 

Everquest is a registered trademark of Daybreak Game Company LLC.
EQEmulator is not associated or affiliated in any way with Daybreak Game Company LLC.
Except where otherwise noted, this site is licensed under a Creative Commons License.
       
Powered by vBulletin®, Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3