DragonPrime - LoGD Resource Community
Welcome Guest
  • Good morning, Guest.
    Please log in, or register.
  • August 17, 2018, 07:56:30 AM
Home Forums News Downloads Login Register Advanced Search
* * *
DragonPrime Menu
Login
 
 
Resource Pages
Search

Pages: [1]   Go Down
  Print  
Author Topic: A new buff effect  (Read 2983 times)
0 Members and 1 Guest are viewing this topic.
Sook
Member
Militia
**
Offline Offline

Posts: 21


Please remember not about me...


View Profile
« on: January 21, 2006, 01:37:23 AM »

I've just created a new effect for buffs. It is a shield that protect players and make them take less damage when hitten.

File to edit: battle.php

first lines, after:
Code:
function activate_buffs($tag) {
  global $session, $badguy;
  reset($session['bufflist']);
  $result = array();
  $result['invulnerable'] = 0;
  $result['dmgmod'] = 1;
  $result['badguydmgmod'] = 1;
  $result['atkmod'] = 1;
  $result['badguyatkmod'] = 1;
  $result['defmod'] = 1;
  $result['badguydefmod'] = 1;
  $result['lifetap'] = array();
  $result['dmgshield'] = array();
add:
Code:
$result['protectiveshield'] = array();
.

after:
Code:
if (isset($buff['lifetap'])) {
  array_push($result['lifetap'], $buff);
}
if (isset($buff['damageshield'])) {
  array_push($result['dmgshield'], $buff);
}
add:
Code:
if (isset($buff['protectiveshield'])) {
  array_push($result['protectiveshield'], $buff);
}
.

Add this function (I placed it after the dmgshield function):
Code:
function process_protshield($pshield, $damage) {
  global $session, $badguy;
  reset($pshield);
  while(list($key,$buff) = each($pshield)) {
        if (strstr($buff['protectiveshield'],"{damage}") != ""){
             $oper="";
             $num=str_replace("{damage}","",$buff['protectiveshield']);
             if (strstr($buff['protectiveshield'],"*") != ""){
                 $num=str_replace("*","",$num);
                 $oper="*";
             }
             if (strstr($buff['protectiveshield'],"/") != ""){
                 $num=str_replace("/","",$num);
                 $oper="/";
             }
             if (strstr($buff['protectiveshield'],"+") != ""){
                 $num=str_replace("+","",$num);
                 $oper="+";
             }
             if (strstr($buff['protectiveshield'],"-") != ""){
                 $num=str_replace("-","",$num);
                 $oper="-";
             }
             $num=trim($num);
             switch ($oper){
                 case "*":
                     $buff['protectiveshield']=$damage*$num;
                 break;
                 case "/":
                     $buff['protectiveshield']=$damage/$num;
                 break;
                 case "+":
                     $buff['protectiveshield']=$damage+$num;
                 break;
                 case "-":
                     $buff['protectiveshield']=$damage-$num;
                 break;
                 case "":
                     $buff['protectiveshield']=$damage;
                 break;
             }
             $buff['protectiveshield']=intval($buff['protectiveshield']);
        }
      if ($damage > 0) {
  $dmgabs = min($buff['protectiveshield'], $damage);
  $damage -= $dmgabs;
  $msg = $buff['effectmsg'];
  } else if ($damage == 0) {
  $msg = $buff['effectnodmgmsg'];
  } else if ($damage < 0) {
  $msg = $buff['effectfailmsg'];
  }
//{shield} shows how much damage has been absorbed from the shield
  $msg = str_replace("{badguy}",$badguy['creaturename'], $msg);
  $msg = str_replace("{shield}",$dmgabs, $msg);
  $msg = str_replace("{damage}",$realdamage, $msg);
  if ($msg > "") output("`)$msg`n");
  }
  return ($damage);
}

Later, in the combat phase, replace:
Code:
if ($creaturedmg==0){
  output("`4You try to hit `^$badguy[creaturename]`4 but `\$MISS!`n");
  process_dmgshield($buffset['dmgshield'], 0);
  process_lifetaps($buffset['lifetap'], 0);
}else if ($creaturedmg<0){
  output("`4You try to hit `^$badguy[creaturename]`4 but are `\$RIPOSTED `4for `\$".(0-$creaturedmg)."`4 points of damage!`n");
  $badguy['diddamage']=1;
  $session['user']['hitpoints']+=$creaturedmg;
  process_dmgshield($buffset['dmgshield'],-$creaturedmg);
  process_lifetaps($buffset['lifetap'],$creaturedmg);
}else{
  output("`4You hit `^$badguy[creaturename]`4 for `^$creaturedmg`4 points of damage!`n");
  $badguy['creaturehealth']-=$creaturedmg;
  process_dmgshield($buffset['dmgshield'],-$creaturedmg);
  process_lifetaps($buffset['lifetap'],$creaturedmg);
with:
Code:

if ($creaturedmg==0){
  output("`4You try to hit `^$badguy[creaturename]`4 but `\$MISS!`n");
  $creaturedmg = -(process_protshield($buffset['protectiveshield'], -$creaturedmg));
  process_dmgshield($buffset['dmgshield'], 0);
  process_lifetaps($buffset['lifetap'], 0);
}else if ($creaturedmg<0){
  output("`4You try to hit `^$badguy[creaturename]`4 but are `\$RIPOSTED `4for `\$".(0-$creaturedmg)."`4 points of damage!`n");
  $creaturedmg = -(process_protshield($buffset['protectiveshield'], -$creaturedmg));
  if ($creaturedmg<0) $badguy['diddamage']=1;
  $session['user']['hitpoints']+=$creaturedmg;
  process_dmgshield($buffset['dmgshield'],-$creaturedmg);
  process_lifetaps($buffset['lifetap'],$creaturedmg);
}else{
  output("`4You hit `^$badguy[creaturename]`4 for `^$creaturedmg`4 points of damage!`n");
  $creaturedmg = -(process_protshield($buffset['protectiveshield'], -$creaturedmg));
  $badguy['creaturehealth']-=$creaturedmg;
  process_dmgshield($buffset['dmgshield'],-$creaturedmg);
  process_lifetaps($buffset['lifetap'],$creaturedmg);

and:

Code:
if ($selfdmg==0){
  output("`^$badguy[creaturename]`4 tries to hit you but `\$MISSES!`n");
  process_dmgshield($buffset['dmgshield'], 0);
  process_lifetaps($buffset['lifetap'], 0);
}else if ($selfdmg<0){
  output("`^$badguy[creaturename]`4 tries to hit you but you `^RIPOSTE`4 for `^".(0-$selfdmg)."`4 points of damage!`n");
  $badguy[creaturehealth]+=$selfdmg;
  process_lifetaps($buffset['lifetap'], -$selfdmg);
  process_dmgshield($buffset['dmgshield'], $selfdmg);
}else{
  output("`^$badguy[creaturename]`4 hits you for `\$$selfdmg`4 points of damage!`n");
  $session['user']['hitpoints']-=$selfdmg;
  process_dmgshield($buffset['dmgshield'], $selfdmg);
  process_lifetaps($buffset['lifetap'], -$selfdmg);
  $badguy['diddamage']=1;
with:
Code:
if ($selfdmg==0){
  output("`^$badguy[creaturename]`4 tries to hit you but `\$MISSES!`n");
  $selfdmg = process_protshield($buffset['protectiveshield'], $selfdmg);
  process_dmgshield($buffset['dmgshield'], 0);
  process_lifetaps($buffset['lifetap'], 0);
}else if ($selfdmg<0){
  output("`^$badguy[creaturename]`4 tries to hit you but you `^RIPOSTE`4 for `^".(0-$selfdmg)."`4 points of damage!`n");
  $selfdmg = process_protshield($buffset['protectiveshield'], $selfdmg);
  $badguy[creaturehealth]+=$selfdmg;
  process_lifetaps($buffset['lifetap'], -$selfdmg);
  process_dmgshield($buffset['dmgshield'], $selfdmg);
}else{
  output("`^$badguy[creaturename]`4 hits you for `\$$selfdmg`4 points of damage!`n");
  $selfdmg = process_protshield($buffset['protectiveshield'], $selfdmg);
  $session['user']['hitpoints']-=$selfdmg;
  process_dmgshield($buffset['dmgshield'], $selfdmg);
  process_lifetaps($buffset['lifetap'], -$selfdmg);
  if ($selfdmg>0) $badguy['diddamage']=1;

Last thing, to use this effect give a value to "protectiveshield" => ... in the buff array.
For messages, you can use {shield} to show the quantity of damage absorbed.

NOTE: the value to use is an ADDITIVE modifier to the damage, not a multiplier.
« Last Edit: February 14, 2006, 04:33:19 PM by Sook » Logged
Excalibur
Member
Mod God
*****
Offline Offline

Posts: 573


I'm a newbie, plz forgive me!


View Profile WWW
« Reply #1 on: February 02, 2006, 11:27:07 AM »

Great mod mate !!!
Keep up with good work  Wink

Excalibur
Logged

Spock: Random chance seems to have operated in our favor.
McCoy: In plain, non-Vulcan English, we've been lucky.
Spock: I believe I said that, Doctor.
Sook
Member
Militia
**
Offline Offline

Posts: 21


Please remember not about me...


View Profile
« Reply #2 on: February 14, 2006, 04:44:37 PM »

Changed the function process_protshield to support {damage} in the buff, useful for example to absorb a percentage of the damage the player suffers instead of a fixed amount.

Please feel free to further improve this function, or to implement it in newer versions.
Logged
Pages: [1]   Go Up
  Print  
 
Jump to:  


*
DragonPrime Notices
Welcome to DragonPrime - The LoGD Resource Community!

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