Go Back   EQEmulator Home > EQEmulator Forums > Quests > Quests::Q&A

Quests::Q&A This is the quest support section

Reply
 
Thread Tools Display Modes
  #1  
Old 01-15-2019, 02:04 PM
Ydiss
Fire Beetle
 
Join Date: Dec 2009
Posts: 6
Default

Hey, I think this is my fourth post here. Been a member since 2009 hah.

I've started developing for THF recently and have been enjoying it loads. I'm just hitting a brick wall with this one particular (apparently non-existent) function.

I'm attempting to get the NPC's hp_regen value (I know I can modify it easily enough) but can't find the command for this anywhere on the ultimate perl reference (or anywhere else).

I checked the perl source and searched for "hp" but couldn't find it. It seems this is also the case for mana_regen, though I don't currently need that.

I want to make changes to npc regen but without a way to read/get the current value, that severely limits my ability to do anything clever with it (i.e. I can pretty much just hard code it).

What I want to do is reduce the hp_regen when players do something. Without the ability to read what it is currently, I imagine I'd need to use qglobals to track each npc's status (from spawn) and then hard code a sequence of conditions for it and that's just horrid.

I'd rather not do that. It seems literally every other editable stat for NPCs can be read except regen Am I missing something?

Any help would be amazing. Thanks.
Reply With Quote
  #2  
Old 01-15-2019, 02:54 PM
Almusious
Fire Beetle
 
Join Date: Sep 2012
Posts: 25
Default

Code:
https://github.com/EQEmu/Server/blob/0ad43977bf94e3a2ca83966f7fc9ba5592bb2a54/zone/npc.cpp#L2307
Code:
quest::modifynpcstat("hp_regen",xxx);
or

Code:
$npc->ModifyNPCStat("hp_regen",xxx);
Sorry, I just re-read what you had written. You wish to know how to "get". I too cannot find something in place for that, but:

Code:
sub PrepareEntityVariables
{
	my @zone_npcs = $entity_list->GetNPCList();
	my $dbh = plugin::LoadMysql();
	foreach $individual_npc (@zone_npcs)
	{
		if (not $individual_npc->GetEntityVariable("regenset"))
		{
			my $sth = $dbh->prepare("
									SELECT `hp_regen_rate`, `mana_regen_rate`
									FROM npc_types
									WHERE (`id` = ?) LIMIT 1
									");
			$sth->bind_param(1,$individual_npc->GetNPCType());
			$sth->execute();
			@row = $sth->fetchrow_array();
			$individual_npc->SetEntityVariable("hpregen", $row[0]);
			$individual_npc->SetEntityVariable("manaregen", $row[1]);
			$individual_npc->SetEntityVariable("regenset",1);
		}
	}
}
Try the above, it may have a syntax error or two, I'm not in a position to compile it, but should give you an idea just the same. The reason for actually setting an entity variable of "regenset" is in the case of either hpregen or manaregen equaling zero (legitimately).
Reply With Quote
  #3  
Old 01-15-2019, 07:28 PM
Ydiss
Fire Beetle
 
Join Date: Dec 2009
Posts: 6
Default

Quote:
Originally Posted by Almusious View Post
Code:
https://github.com/EQEmu/Server/blob/0ad43977bf94e3a2ca83966f7fc9ba5592bb2a54/zone/npc.cpp#L2307
Code:
quest::modifynpcstat("hp_regen",xxx);
or

Code:
$npc->ModifyNPCStat("hp_regen",xxx);
Sorry, I just re-read what you had written. You wish to know how to "get". I too cannot find something in place for that, but:

Code:
sub PrepareEntityVariables
{
	my @zone_npcs = $entity_list->GetNPCList();
	my $dbh = plugin::LoadMysql();
	foreach $individual_npc (@zone_npcs)
	{
		if (not $individual_npc->GetEntityVariable("regenset"))
		{
			my $sth = $dbh->prepare("
									SELECT `hp_regen_rate`, `mana_regen_rate`
									FROM npc_types
									WHERE (`id` = ?) LIMIT 1
									");
			$sth->bind_param(1,$individual_npc->GetNPCType());
			$sth->execute();
			@row = $sth->fetchrow_array();
			$individual_npc->SetEntityVariable("hpregen", $row[0]);
			$individual_npc->SetEntityVariable("manaregen", $row[1]);
			$individual_npc->SetEntityVariable("regenset",1);
		}
	}
}
Try the above, it may have a syntax error or two, I'm not in a position to compile it, but should give you an idea just the same. The reason for actually setting an entity variable of "regenset" is in the case of either hpregen or manaregen equaling zero (legitimately).
Thanks, that's really helpful. Yes, I'd need to check for zero anyway.

Will see if I can get it to work.
Reply With Quote
  #4  
Old 01-16-2019, 04:21 AM
Akkadius's Avatar
Akkadius
Administrator
 
Join Date: Feb 2009
Location: MN
Posts: 2,072
Default

Quote:
Originally Posted by Ydiss View Post
Hey, I think this is my fourth post here. Been a member since 2009 hah.

I've started developing for THF recently and have been enjoying it loads. I'm just hitting a brick wall with this one particular (apparently non-existent) function.

I'm attempting to get the NPC's hp_regen value (I know I can modify it easily enough) but can't find the command for this anywhere on the ultimate perl reference (or anywhere else).

I checked the perl source and searched for "hp" but couldn't find it. It seems this is also the case for mana_regen, though I don't currently need that.

I want to make changes to npc regen but without a way to read/get the current value, that severely limits my ability to do anything clever with it (i.e. I can pretty much just hard code it).

What I want to do is reduce the hp_regen when players do something. Without the ability to read what it is currently, I imagine I'd need to use qglobals to track each npc's status (from spawn) and then hard code a sequence of conditions for it and that's just horrid.

I'd rather not do that. It seems literally every other editable stat for NPCs can be read except regen Am I missing something?

Any help would be amazing. Thanks.
If you're talking about inflated hp_regen rates in one of the recent source releases, make sure you are updated to the latest source as it includes a database update that resolves this issue
Reply With Quote
  #5  
Old 01-16-2019, 05:50 AM
Ydiss
Fire Beetle
 
Join Date: Dec 2009
Posts: 6
Default

Quote:
Originally Posted by Akkadius View Post
If you're talking about inflated hp_regen rates in one of the recent source releases, make sure you are updated to the latest source as it includes a database update that resolves this issue
Hi Akkadius

Thanks for your reply. It's not related to that (I actually wanted to control regen rates as part of a quest).

I've actually thought of a workaround this morning. I can hijack another readable npc stat and use that to control the hp_regen value. For example, I can use charisma.

I just need to initially set the npc's cha to the same value as the hp_regen value, divided by 1000. Then I can use getCHA() and modify cha (eg -10) and apply that value to modify hp_regen (*1000).

It should work in theory.
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 09:56 PM.


 

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 - 2025, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3