PDA

View Full Version : Question about Events and NPC's


SavageDeath
02-13-2013, 01:42 AM
Okay so I have no idea if this is the proper place to post this for the second part of my question but here goes.

First question is, is there some type of sub EVENT for when someone equips any piece of armor? I looked on the QuestTutorial (http://www.eqemulator.net/wiki/wikka.php?wakka=QuestTutorial) and I checked on the Google Code (http://code.google.com/p/projecteqemu/source/browse/trunk/EQEmuServer/zone/embparser.cpp) and I can't find anything about it. The reason I ask is I am looking for a EVENT that will allow me to check what that piece of armor is they equipped and then send them a client message or well anything.

Second question is, anytime I put a NPC's HP's to anything over 2,147,483,647 the NPC's HP's will go negative. I thought this was something to do with the way the source calculated the hp but I ain't too great with c++ so I wouldn't know where to look or even how to fix this problem. Thus my question, is it possible to make it so I can set an NPC's HP's to over 2,147,483,647 without it going negative?

Any help would be greatly appreciated =) Thanks in advance.

lerxst2112
02-13-2013, 01:47 AM
is it possible to make it so I can set an NPC's HP's to over 2,147,483,647 without it going negative?

No, that is the limit of the datatype used to store hit points. If you need more than that you would need to modify the source.

SavageDeath
02-13-2013, 01:53 AM
Ah gotcha kinda figured, any chance you can point me in the right direction of where to mod it in the source? I looked at mob.h and mob.cpp but didn't see any places that stood out. And thanks for the quick reply!

lerxst2112
02-13-2013, 02:01 AM
I'm afraid if you don't know how to find it already then anything I could say to you here is unlikely to enlighten you.

That said, mob.h, line 836:


int32 cur_hp;
int32 max_hp;
int32 base_hp;


Keep in mind that these values are manipulated all over the place and you would need to change all of those places, and potentially how the data is stored in the database as well. This is not a small task.

You might want to ask yourself first if maybe 2.1 BILLION hit points is enough and if whatever you are trying to achieve could be done a different way to work within that limitation.

SavageDeath
02-13-2013, 02:08 AM
Thanks man, I was actually looking at that and trying to figure out what would best work to make it not go negative. I was honestly hoping there was another area I had missed because I had modded those to 64 bit integers. After I edited all the appropriate places and recompiled(with a successful compile) I tried it and I had the same result of the neg HP's my only guess is that I missed the place where it stores the HP.

But again thank you very much sir!

SavageDeath
02-13-2013, 03:26 PM
I have an update. I am now able to make it so the NPC's HP's don't go negative but they won't go past 2,147,483,647 HP's. I changed the int on the table to support the bigger numbers. Anyone have any idea why it won't go past that? I think I'm on the right track seeing as it doesn't go negative anymore =D Again any help would be greatly appreciated, thanks in advance.

ghanja
02-13-2013, 03:57 PM
That's the limit of a signed int. Even if you change the value in the tables, there is still plenty of code where it would need to be changed as well. However, that too isn't taking into consideration of the client itself, which may not support anything 'bigger' than a signed int (i.e. int64 signed/unsigned, etc.).

My advice, increase the mitigation (AC, etc.) of the NPC to make it tougher to bring down it's HP, rather than just making a grossly large number of HP.

*Edit: But I see lersxt2112 already gave you the same (essentially - he wanted to get you thinking) sound advice.

SavageDeath
02-13-2013, 04:16 PM
I have increased the ac to insane numbers, only problem is if the AC gets too high it makes the player unable to hit the monsters thus why I wanted to increase the HP cap, thanks again.

SavageDeath
02-13-2013, 04:53 PM
Sorry for the double post I just realized how I made that sound, I did edit the source as well not just the table.

ghanja
02-13-2013, 05:37 PM
Sorry for the double post I just realized how I made that sound, I did edit the source as well not just the table.

Then, it may be a limitation of the client itself, albeit, I'm not in a position to check at the moment, maybe someone else knows off the top of their heads. First time encountering a desire for a > 2B HP mob sorry. ;)

Derision
02-13-2013, 05:57 PM
NPC HP is only communicated to the client in percentages (i.e. 0 to 100%) unless I am mistaken, which is why the packet collector cannot collect absolute NPC max/current hitpoints, so I don't think it is a client limitation.

lerxst2112
02-13-2013, 06:57 PM
It seems like you may have selectively read my post. You may have changed the actual variable the data is stored in, but did you change everywhere that value is manipulated either directly or through accessors like GetHP()? Like I said, it's not a small task.

SavageDeath
02-13-2013, 07:12 PM
Yes sir, I spent a good 3 hours going through and making sure that anything related to GetHP() was set to int64 and it just won't go higher than 2.14bil. Again my c++ isn't that great but I did look through every place I could think of that would set the NPC's HP's and I changed them to int64 instead of int32.

These are the places I edited.
Maybe I missed a place?
Mob.h
Mob.cpp
client.h
client.cpp
client_mods.cpp
zonedump.h
merc.h
merc.cpp
bot.h
bot.cpp

The reason I had to change the ones that weren't directly related to NPC's is because it won't compile if you don't edit it for everywhere that it pulls HP.

lerxst2112
02-13-2013, 07:49 PM
How are you setting the HP to greater than 2.14 billion? A # command?

How are you determining whether or not the HP is greater than 2.14 billion? A log statement?

Those need to be updated to accept/print a larger datatype as well.

SavageDeath
02-13-2013, 08:55 PM
I am setting the hp to greater than 2.14 billion manually in the npc_types table with navicat. I set it at 4bil just to see if it would go over the cap. The table accepts it which is great. The NPC doesn't.

I used #showstats to look at what the NPC's HP's are.
I then used #damage 1000000000 to be sure what the #showstats was showing was correct. On the show stats its weird, it will show the HP at 2.14bil but it will show the MAX hp as 0, not sure why that is.
When I do #damage 1000000000 it takes the NPC's HP's to 53% telling me that the NPC's HP's isn't even close to the 4bil I set it to.

lerxst2112
02-13-2013, 09:51 PM
Guess you missed some spots then. Good luck.

SavageDeath
02-14-2013, 05:04 PM
Haha, thanks have you ever tried to make it go past 2.14bil and succeeded? Or know of anyone that has and succeeded? Reason I ask is I wanna know if I'm chasing a lost cause =D

Zaela_S
02-14-2013, 05:29 PM
If just making the NPC heal up at certain points or similar is totally not an option...

NPC HP is only communicated to the client in percentages (i.e. 0 to 100%) unless I am mistaken, which is why the packet collector cannot collect absolute NPC max/current hitpoints, so I don't think it is a client limitation.

The server has control over what % HP the NPC appears to be at by way of Mob::CreateHPPacket(). A system could be created where literal HP values are not used; probably the most straightforward way to do it would be to have an NPC's HP value define how much HP they have per percent. That way you could have an NPC with ~210 billion HP easy. A more complicated system with multiple values to track effective HP could give you more if that limitation is still too low.

It would be a pretty big and very custom overhaul, though. You'd need to split Client HP checks from NPC HP checks since they wouldn't work the same anymore.


First question is, is there some type of sub EVENT for when someone equips any piece of armor?

I added an EVENT like this on my server, but unfortunately not for Perl and so not something I can offer up. It shouldn't be too hard to add by copying from other EVENT triggers though; just needs to occur at the bottom of Client::SwapItem(), in a certain part of Client::AutoPutLootInInventory() where things are auto-equipped on loot, and (with a little care) in Client::SetBandolier(). There might be other spots where it's needed I haven't found yet... but I bet someone who knows the Perl system could add it pretty easily. I called it EVENT_EQUIP_CHANGE myself.

ghanja
02-14-2013, 05:49 PM
I added an EVENT like this on my server, but unfortunately not for Perl and so not something I can offer up. It shouldn't be too hard to add by copying from other EVENT triggers though; just needs to occur at the bottom of Client::SwapItem(), in a certain part of Client::AutoPutLootInInventory() where things are auto-equipped on loot, and (with a little care) in Client::SetBandolier(). There might be other spots where it's needed I haven't found yet... but I bet someone who knows the Perl system could add it pretty easily. I called it EVENT_EQUIP_CHANGE myself.

Sigh. No comment, beyond, well, this obvious comment. To be PC and all.

Though thanks to the above said, research time for the insertion/addition has been cut, let me have a look see, as I believe it would be a beneficial event to have.

SavageDeath
02-14-2013, 06:18 PM
@Zaela_S, thanks for your ideas. That would be one way to do it yeah.
But I was looking for a way to modify it so they would just accept bigger values without having to do a major over haul on the current working system.
One would think modifying it to accept values over 2.14 billion wouldn't be all that hard seeing as its already set up to accept values to 2.14 billion with int32.
I know 2.14 billion is the cap of int32 which is why one would think changing all the places that HP is pulled and set from to int64 instead of int32 would work. Again I don't know much about C++, if I'm mistaken someone please correct me.

Zaela_S
02-14-2013, 06:58 PM
If you want a significant change, you'll have to be ready to do a little work, I think. If you don't want to put in too much effort, you'll probably just have to accept mobs having multiple HP bars or multiple phases. Honestly the system I described probably wouldn't be that difficult; it could be knocked out in a day with a little patience, I think.

Upon further thought making the HP system I described extremely flexible wouldn't be too complicated even: you'd only need 3 tracking values and 2 starting NPC data values.

The first value would be a uint32 that is directly decreased by damage. The second value would be a uint32 that defines how many times the first value is in 1% of the total. The third value would be an int8 to track the NPC's current HP %.

When damage would put the first value below 0, the second value will decrement, the first value will reset to its starting value, and any excess damage will bleed over. Whenever the second value hits 0, the third value will decrement, the second value will reset, and the players will rejoice at a sign of progress. At that point it would basically just be a matter of making Death occur when the third value hits 0 or -1.

At that point the HP cap would be around... (4.29b^2)*100... so high you'd need to use scientific notation to describe how much HP something has. What more could you ask for.

orionsun
02-14-2013, 08:09 PM
Don't worry Zeela, most of the people here don't actually want to do any work, they just keep asking the same question until somebody else does it for them.

ghanja doesnt even realize the reason you didn't post a diff is because you did your version of this in Lua.

SavageDeath
02-14-2013, 08:21 PM
@orionsun I wasn't asking for anyone to do it for me I was asking if there was an easier way to do it rather than redoing the entire way it works currently.

c0ncrete
02-14-2013, 08:28 PM
orion is full of snark today. he also apparently doesn't realize that ghanja is quite familiar with the fact that zaela_s does customization in lua and doesn't generally ask anyone to do anything for him.

lerxst2112
02-14-2013, 08:41 PM
@Zaela_S, thanks for your ideas. That would be one way to do it yeah.
But I was looking for a way to modify it so they would just accept bigger values without having to do a major over haul on the current working system.
One would think modifying it to accept values over 2.14 billion wouldn't be all that hard seeing as its already set up to accept values to 2.14 billion with int32.
I know 2.14 billion is the cap of int32 which is why one would think changing all the places that HP is pulled and set from to int64 instead of int32 would work. Again I don't know much about C++, if I'm mistaken someone please correct me.

Hit Points are used all over the place, so thinking it wouldn't be a major overhaul is just silly. One might think it wouldn't be all that hard, and really it isn't, but as you've said you don't know a bunch about C++ and although it isn't a difficult change it does require that all places in the code that manipulate the value in any way be changed to allow a larger data type.

Since you didn't explain why you need to change this I'd assume it's because you want to see really big numbers for damage. Well, that introduces another set of problems as all of the damage calculations are subject to overflow at some point too, so you'd be back saying "hey guys, why is my damage negative" before long.

If it is super important to you, good luck, you'll need it. If not, just scale your damage so it works within the existing confines and be happy.

orionsun
02-14-2013, 08:43 PM
orion is full of snark today

I prefer speaking my mind as opposed to passive-aggressive stuff like:

Sigh. No comment, beyond, well, this obvious comment. To be PC and all.

P.S. Savage... theres a good song called "Not Everything Is About You", you should listen to it, or maybe just read the title.

SavageDeath
02-14-2013, 08:56 PM
Hit Points are used all over the place, so thinking it wouldn't be a major overhaul is just silly. One might think it wouldn't be all that hard, and really it isn't, but as you've said you don't know a bunch about C++ and although it isn't a difficult change it does require that all places in the code that manipulate the value in any way be changed to allow a larger data type.

Since you didn't explain why you need to change this I'd assume it's because you want to see really big numbers for damage. Well, that introduces another set of problems as all of the damage calculations are subject to overflow at some point too, so you'd be back saying "hey guys, why is my damage negative" before long.

If it is super important to you, good luck, you'll need it. If not, just scale your damage so it works within the existing confines and be happy.

Thanks man, and you are correct about the damage, I have actually already modified that to support the bigger damage =D works great doesn't ever go into negative numbers and my gm hits for over 20mil (a regular players max hit is around 900k) which is why I wanted to change the cap on HP but yeah I'll just need to go through the source again with a fine tooth comb and give it a long hard look. Thanks for the support.

@orionsun you could of been directing that statement at more than one person. And seeing as I started the thread I would assume the replies that follow would be directed at me.

ghanja
02-14-2013, 10:14 PM
*Edit: I became aware this reply was no longer necessary due to the below.

ghanja
02-14-2013, 10:27 PM
Don't worry Zeela, most of the people here don't actually want to do any work, they just keep asking the same question until somebody else does it for them.

ghanja doesnt even realize the reason you didn't post a diff is because you did your version of this in Lua.

Oh, you did know you were replying to me. However, let me quote you here just one last time (you are obviously trolling) in case you decide to edit.

Let me just say, this response of yours is, well, shows your ass. Good day sir.