Warning: preg_replace_callback(): Requires argument 2, '$func['entity_fix']('\2')', to be a valid callback in /nfs/c01/h06/mnt/10927/domains/dragonprime.net/html/Sources/Load.php(225) : runtime-created function on line 3
Racial Hitpoints
DragonPrime - LoGD Resource Community
Welcome Guest
  • Good afternoon, Guest.
    Please log in, or register.
  • September 20, 2019, 01:16:23 PM
Home Forums News Downloads Login Register Advanced Search
* * *
DragonPrime Menu
Login
 
 
Resource Pages
Search

Pages: [1]   Go Down
  Print  
Author Topic: Racial Hitpoints  (Read 1631 times)
0 Members and 1 Guest are viewing this topic.
aeanos
Militia
**
Offline Offline

Posts: 71



View Profile
« on: June 13, 2019, 11:44:40 PM »

Hello all,

I've been dusting off an old project (v.1.1.2 based), and wondered if there was a way to make it so that each race can have its own base hitpoints. After all, it seems odd that a human, a dwarf, and a troll should have the same maxhitpoints, even though they're drastically different creatures. It appears that the maxhitpoints and maxhitpointsperlevel are defined in lib/all_tables.php, but I'm not sure how to go about making work on a race-by-race basis.

So far, I've considered trying to create a form of permanent buff/debuff in each race's module, so the core would simply be the standard Human hitpoints, but figured someone might already know of a better way to accomplish this. Thank you in advance. Smiley
« Last Edit: June 14, 2019, 12:15:01 AM by aeanos » Logged
Aeolus
Mod God
*****
Offline Offline

Posts: 1934


You're welcome.


View Profile WWW
« Reply #1 on: June 14, 2019, 12:18:32 AM »

I'd suggest simply making a module that, after a successful DK, sets maxhitpoints to a custom number dependent on the player's race, then remembering to add on any hitpoints bought with DK points.

As far as I can tell, maxhitpointsperlevel is only for companions. In train.php, maxhitpoints is always increased by ten. If you want to change this, you could insert a modulehook there, and modify that amount in the same manner as the initial suggestion above.
Logged

aeanos
Militia
**
Offline Offline

Posts: 71



View Profile
« Reply #2 on: July 24, 2019, 02:56:28 AM »

Sorry for the lag in responding. Let's try this another way...

Where are the base hitpoints actually set for new characters? I've dug through everything, and can't seem to find anything that would seem to be it, aside from lib/all_tables.php, and it's driving me nuts. lol
Logged
TGTarheel
Mod God
*****
Offline Offline

Posts: 535


View Profile
« Reply #3 on: July 24, 2019, 04:54:29 AM »

I am a little curious why this needs to be so complicated.

Why couldn't a module be made that would let Admins enter all the races in the game...and set a multiplier by which their base hit points would be multiplied by fr each race?

You set the player's basehit points in the module, and all bought hitpoints add to that base in the module, and, on dragonkill, the player resets to the saved base.

Meanwhile, the player's base during a DK cycle...is this base multiplied by an Admin-settable multiplier...mayne, for example, Human is 1.0, a Giant might be 1.8 and an Elf might be 0.92 - just as an example.

You have the module multiply the saved playerbase hitpoints by the multiplier (and be sure to do this a a round function) and set that as their max hitpoints (while the normal 1x base hit points is stored in that module.

It seems as if this might accomplish the desired effect....and be completely Admin-customizable, so that all races could be taken into account.

Or am I missing something?  If I understand the concept of what is trying to be accomplished, I don't see why such an approach would not produce the desired result.
Logged
aeanos
Militia
**
Offline Offline

Posts: 71



View Profile
« Reply #4 on: July 24, 2019, 10:20:53 PM »

TGTarheel, I'm with you on this one. The method you described is also exactly what I'm hoping to accomplish. However, I can't seem to pin down where the base HP is being generated, and the base is far too low for what I'm working on. I've also dug through the whole system several times using content searching. lol

The only thing I can think of, is that maybe the lib/all_tables.php is the right place to make the change, but that I have to get the game to update it once it's been uploaded, because it's been hardcoded into the database during installation, somehow. (Also, FYI, granting a new day doesn't seem to fix it for me; neither does creating a new character.)
« Last Edit: July 24, 2019, 10:30:42 PM by aeanos » Logged
Nightborn
Captain of the Guard
***
Offline Offline

Posts: 227


View Profile WWW
« Reply #5 on: July 25, 2019, 06:02:20 AM »

The starting "10" is basically a bit scattered in the code, but you could manage this if you wanted to.

[line numbers may be off]

in dragon.php
Code:
198         $session['user']['maxhitpoints'] = 10 + $hpgain['dkpoints'] +
199                 $hpgain['extra'];
This handles the calc after the dragonkill.
it's bad to edit directly, but you can use the hook "hprecalc" which is defined in line 102. You can set the array $hpgain in it:
Code:
95         $hpgain = array(
 96                         'total' => $session['user']['maxhitpoints'],
 97                         'dkpoints' => $dkpoints,
 98                         'extra' => $session['user']['maxhitpoints'] - $dkpoints -
 99                                         ($session['user']['level']*10),
100                         'base' => $dkpoints + ($session['user']['level'] * 10),
101                         );

As for char creation (or whatever you want to start from), you need to set the inital 10 hp on level 1.
That is done in the mysql table, as the user creation just uses some defaults.
Edit in your database the DEFAULT field.
I also recommend to change your table defintions in lib/all_tables:

Code:
 78                 'hitpoints'=>array(
  79                         'name'=>'hitpoints', 'type'=>'int(11)', 'default'=>'10' //user hitpoints he currently has
  80                         ),
Above line won't change anything live, but in case of an updated core version, better have it if you do a table sync.

Lastly, train.php also increments HP for each level by 10 (hardcoded).
Code:
182                         $session['user']['maxhitpoints']+=10;

On whatever condition you want to set the hp, keep in mind many modules calculate stuff with 10*level = base hp.

So, in summary, what Aeolus said:

0. if you want a different starting value on level 1, either do above OR
0.1 write a module
0.2 hook into newday
0.3 check if a user is level 1 with 0 days (first login)
0.4 set maxhitpoints accordingly

1. write a module
2. hook into hprecalc
3. calculate what you need and set the hp gain
4. output to the user possibly info on why

« Last Edit: July 25, 2019, 06:04:44 AM by Nightborn » Logged
TGTarheel
Mod God
*****
Offline Offline

Posts: 535


View Profile
« Reply #6 on: July 29, 2019, 04:02:00 PM »

TGTarheel, I'm with you on this one. The method you described is also exactly what I'm hoping to accomplish. However, I can't seem to pin down where the base HP is being generated, and the base is far too low for what I'm working on. I've also dug through the whole system several times using content searching. lol

The only thing I can think of, is that maybe the lib/all_tables.php is the right place to make the change, but that I have to get the game to update it once it's been uploaded, because it's been hardcoded into the database during installation, somehow. (Also, FYI, granting a new day doesn't seem to fix it for me; neither does creating a new character.)

Not sure why you'd need to know where that was generated.
you could just put it in the race selection...have a variable be set to store the original base hitpoints.  Then that number is multilied by your race variable...which could be less than one...and is rounded.  Then max hitpoints is set to that level.

At dragonkill, maxhitpoints re-set to the saved variable (plus any added hitpoints...so you migt need a second variable to save added hitpoints.

This does not account for race change in the middle of a dragonkill which can be done, so you'd need to do something to make sure that the variable saved was read...then saved in the new race, and multiplied by the new race-variable.

It should be able to be accomplished.  Now...if you did this in one module, as I suggested...and allowed admin to set race names and values...this could take care of that problem, too...any time the race changes...it re-sets to original value plus added, those variables are cleared, then re-set with the original maxhitpoints, then maxhitpoints multiplied by the new race variable.

Should be achievable without even knowing where the base hitpoints are generated...or even altering core code
Logged
aeanos
Militia
**
Offline Offline

Posts: 71



View Profile
« Reply #7 on: August 04, 2019, 06:12:08 PM »

TGTarheel, I've been trying to work out what was generating the base HP, so that I can find what I'd need to tie into, and determine whether or not I'd also need to add extra fields to the database to pull it off. Since I haven't done this type of coding in a few years, and I'm a bit rusty, I also figured that if it seemed easier to just update the base HP than to create a new module system, I could simply update that and drop the other races for the time being.

That said, thank you Nightborn; what you've provided will definitely help me sort this out alot faster. Smiley
« Last Edit: August 04, 2019, 11:03:00 PM by aeanos » Logged
Pages: [1]   Go Up
  Print  
 
Jump to:  


*
DragonPrime Notices
Version 1.1.2 is the current supported version and is available for download.

Support Us
No funds raised yet this year
Your help is greatly appreciated!
Recent Topics
DragonPrime LoGD
Who's Online
71 Guests, 0 Users
Home Forums News Downloads Login Register Advanced Search