DragonPrime - LoGD Resource Community
Welcome Guest
  • Good afternoon, Guest.
    Please log in, or register.
  • September 19, 2018, 01:16:06 PM
Home Forums News Downloads Login Register Advanced Search
* * *
DragonPrime Menu
Login
 
 
Resource Pages
Search

Pages: [1]   Go Down
  Print  
Author Topic: HP Cap after a Dragonkill  (Read 3678 times)
0 Members and 1 Guest are viewing this topic.
Ironman
Guest
« on: April 04, 2006, 06:18:40 AM »

I thought it would be a simple module, but it's not working.  It doesn't seem to be doing anything at all.

Basically, this module is meant to ensure players don't have over a certain number of max hit points when they start over after a dk.  It's short, so I'll copy/paste the entire thing below, if someone can take a look.  Thanks!

Code:

<?php

require_once("lib/http.php");

function starting_hp_getmoduleinf o(){
   $info = array(
      "name"=>"Starting HP",
      "version"=>"1.0",
      "author"=>"Gary Hartzell",
      "category"=>"Administrative",
"download"=>"",
"settings"=>array(
   "perdk"=>"What is the max amount of HP a player can start with (per dk)?,int"
),
);
return $info;
}

function starting_hp_install() {
   module_addhook("dragonkill");
   return true;
}

function starting_hp_uninstall() {
   return true;
}

function starting_hp_dohook($hookname, $args){
   global $session;
   switch ($hookname) {
   case "dragonkill":
      $cap = get_module_setting("perdk") * $session['user']['dragonkills'];
      if ($session['user']['maxhitpoints'] > $cap) $session['user']['maxhitpoints'] = $cap;
      break;
   }
   return $args;
}

function starting_hp_run() {
}
?>
Logged
Kala
Codemeister
****
Offline Offline

Posts: 481

Who Me?


View Profile
« Reply #1 on: April 06, 2006, 10:07:44 AM »

try changing your case in the dohook to this

case "dragonkill":
      $cap = get_module_setting("perdk") * $session['user']['dragonkills'];
      if ($session['user']['maxhitpoints'] > $cap){
          $session['user']['maxhitpoints'] = $cap;
       }
      break;

*tested it quickly and it does work* Cheesy

« Last Edit: April 06, 2006, 10:09:48 AM by Kala » Logged

~Why are there only 24 hours in a day, what I could do with an extra 1 ~
DaveS
Mod God
*****
Offline Offline

Posts: 1544


Dfly... you know, as in DaveFly


View Profile
« Reply #2 on: April 06, 2006, 11:53:10 AM »

I think this is a great idea... I thought of some other things you could add if you'd like.  Here's some of the things I tried out (they seem to work):

Settings:
Code:
"perdk"=>"What is the max amount of HP a player can start with (per dk)?,int|-1",
"set to -1 for no limit,note",
"maxhp"=>"What is the max amount of HP a player can start with regardless of dk?,int|-1",
"set to -1 for no limit,note",

Case Dragonkill:
Code:
case "dragonkill":
$perdk = get_module_setting("perdk");
$maxhp = get_module_setting("maxhp");
$cap = $perdk*$session['user']['dragonkills'];
if ($perdk>0 && $session['user']['maxhitpoints']>$cap) {
$session['user']['maxhitpoints'] = $cap;
$session['user']['hitpoints'] = $cap;
}
if ($maxhp>0 && $session['user']['maxhitpoints']>$maxhp) {
$session['user']['maxhitpoints'] = $maxhp;
$session['user']['hitpoints'] = $maxhp;
}
break;
Logged

Check out my Last Module:
The Dragon Eggs Expansion
http://dragonprime.net/index.php?topic=8474.0

About my Retirement:
http://dragonprime.net/index.php?topic=9080

See my complete module list here:
http://dragonprime.net/index.php?topic=3038.0
ShadowRaven
Mod God
*****
Offline Offline

Posts: 805


Silence is a virtue...


View Profile WWW
« Reply #3 on: April 06, 2006, 12:37:40 PM »

The HP cap module that I made thats in my shared folder uses this:

Code:
function hpcap_dohook($hookname,$args){
global $session;
switch($hookname){
case "newday":
$cap=get_module_setting("maxhp");
$max = ($session['user']['dragonkills'] * $cap);
$dks = $session['user']['dragonkills'];
$lvl = ($session['user']['level']*10);
$max = ($session['user']['dragonkills'] * $cap + $lvl);

if($session['user']['maxhitpoints'] > $max){
$total=($session['user']['maxhitpoints'] -= $max);

if($total <= 150){
}elseif($total > 150){
$diff=($total*1);
$session['user']['gems']+=$diff;
output("`n`n`^You have gone %s over your Hit point limit.",$total);
output("`n`6Your Hit Point Limit for your level and DKs is %s.",$max);
output("`n `&You Gain `@%s `&gems for the difference.",$diff);
}
$session['user']['hitpoints']=$max;
$session['user']['maxhitpoints']=$max;
}

break;
}

I have it for newday, but to have it for dk, then it would just need to be changed from case "newday": to case "dragonkill":.
along with changing the module_addhook.
I also have it reimburse one gem per hitpoint over the limit but the gem instances can be removed if that is something you don't want happening.
Logged

robert
Old Dog
Mod God
*****
Offline Offline

Posts: 1047


LoGD Buff!


View Profile WWW
« Reply #4 on: April 06, 2006, 01:32:08 PM »

mmmm...how would this effect all those who select MAXHP using dragon points - are they left in the cold cause of this cap?

v097 had a similiar mod to cap HP based on race written by Strider it allowed a certain amount then would cap it based on a formula that allowed for dragon point spending.
Logged

ShadowRaven
Mod God
*****
Offline Offline

Posts: 805


Silence is a virtue...


View Profile WWW
« Reply #5 on: April 06, 2006, 02:05:55 PM »

most lower dk'ers do not have the gems to keep buying HP to match their dk's, so choosing the 5 HP after a Dk would work for them, for those that are at the HP max, you're right, it would be a waste unless they were only at the max for their previous DK lvl. When they DK then the new max would be in place and unless the setting is set for less than 5 per DK, they would still get the 5 hp.
Logged

DaveS
Mod God
*****
Offline Offline

Posts: 1544


Dfly... you know, as in DaveFly


View Profile
« Reply #6 on: April 06, 2006, 02:14:46 PM »

Perhaps after the "Max HP" code you could add this:

Code:
$hpgain = array(
'total' => $session['user']['maxhitpoints'],
'dkpoints' => $dkpoints,
'extra' => $session['user']['maxhitpoints'] - $dkpoints -($session['user']['level']*10),
'base' => $dkpoints + ($session['user']['level'] * 10),
);
$hpgain = modulehook("hprecalc", $hpgain);
$session['user']['maxhitpoints'] = 10 + $hpgain['dkpoints'] +$hpgain['extra'];
$session['user']['hitpoints']=$session['user']['maxhitpoints'];
Logged

Check out my Last Module:
The Dragon Eggs Expansion
http://dragonprime.net/index.php?topic=8474.0

About my Retirement:
http://dragonprime.net/index.php?topic=9080

See my complete module list here:
http://dragonprime.net/index.php?topic=3038.0
Ironman
Guest
« Reply #7 on: April 06, 2006, 03:42:48 PM »

SR: It's funny because I am using your hpcap, and I came up with the idea for my script because I didn't want any restrictions per level.  I don't know why it never occured to me to modify your script.  Undecided

Dave:  I'll incorporate your ideas into my script later and let you know how it works. Smiley
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
31 Guests, 0 Users
Home Forums News Downloads Login Register Advanced Search