DragonPrime - LoGD Resource Community
Welcome Guest
  • Good evening, Guest.
    Please log in, or register.
  • November 18, 2018, 07:45:20 PM
Home Forums News Downloads Login Register Advanced Search
* * *
DragonPrime Menu
Login
 
 
Resource Pages
Search

Pages: [1] 2   Go Down
  Print  
Author Topic: AutoFight  (Read 14698 times)
0 Members and 1 Guest are viewing this topic.
anpera
Guest
« on: March 09, 2004, 07:59:40 AM »

This hack gives players the possibility of very quick forst fights. If AutoFight is enabled in gamesettings, the player can choose whether he wants to fight 1 round, the next 5 rounds or all rounds till bitter end of the fight automatically.
Buffs and activated specialties take effect in autofight mode, but activating new buffs or fleeing is not possible in autofight rounds.
The result of every round is displayed.

Version: 14.3.2004

For LoGD version: 0.9.7+jt

Installation intructions:
Code:
----- Open:
battle.php

----- Find:
$badguy = createarray($session[user][badguy]);

----- Before, add:
if ($HTTP_GET_VARS[auto]=="full"){
   $count=100;
}else if ($HTTP_GET_VARS[auto]=="five"){
   $count=5;
}else{
   $count=1;
}

----- Find:
// Run the beginning of round buffs (this also calculates all modifiers)

----- After, add:
for ($count=$count;$count>0;$count--){
if ($badguy['creaturehealth']>0 && $session['user']['hitpoints']>0){

----- Find below:
if ($badguy['creaturehealth']>0 && $session['user']['hitpoints']>0){

----- Before, add:
}

----- Find:
   $selfdmg=0;

----- After, add:
   $count=0;

----- Find:
expire_buffs();

----- After, add:
$creaturedmg=0;
$selfdmg=0;
if ($count>1 && $session[user][hitpoints]>0 && $badguy[creaturehealth]>0) output("`2`bNext round:`b`n");
if ($badguy[creaturehealth]<=0){
   $victory=true;
   $defeat=false;
   $count=0;
}else{
   if ($session[user][hitpoints]<=0){
      $defeat=true;
      $victory=false;
      $count=0;
   }else{
      $defeat=false;
      $victory=false;
   }
}
}

----- Find:
if ($badguy[creaturehealth]<=0){
   $victory=true;
   $defeat=false;
}else{
   if ($session[user][hitpoints]<=0){
      $defeat=true;
      $victory=false;
   }else{
      $defeat=false;
      $victory=false;
   }
}

----- Replace it with:
/*
if ($badguy[creaturehealth]<=0){
   $victory=true;
   $defeat=false;
}else{
   if ($session[user][hitpoints]<=0){
      $defeat=true;
      $victory=false;
   }else{
      $defeat=false;
      $victory=false;
   }
}
*/


----- Open:
common.php

----- Find:
   if ($allowspecial) {

----- Before, add:
   if (getsetting("autofight",0)){
      addnav("AutoFight");
      addnav("5 rounds autofight","$script?op=fight&auto=five");
      addnav("Till bitter end","$script?op=fight&auto=full");
   }


----- Open:
configuration.php

----- Finde:
   "gameadminemail"=>"Admin Email",

----- After, add:
   "autofight"=>"Enable AutoFight,bool",


----- Open:
graveyard.php

----- Find:
addnav("F?Flee","graveyard.php?op=run");

----- After, add:
         if (getsetting("autofight",0)){
            addnav("AutoFight");
            addnav("5 rounds autofight","graveyard.php?op=fight&auto=five");
            addnav("Till bitter end","graveyard.php?op=fight&auto=full");
         }


----- Save and close all files

Please report any errors Smiley

[edit by anpera]
Fixed a small bug in instructions. See note below
« Last Edit: March 18, 2004, 08:22:48 PM by anpera » Logged
Kendaer
Guest
« Reply #1 on: March 09, 2004, 09:59:50 AM »

Just so you know this is the first implementation of this sort of feature that I wasn't horribly allergic to and it's now a part of 0.9.8 with some modifications.

I allow 5 or 10 rounds of autofight.  I also added an additional config option to allow or disallow fight-to-death because that could be *very* laggy on the server with all the output generation.
Logged
Arune
Member
Mod God
*****
Offline Offline

Posts: 718


Arune Vai - khatfield


View Profile WWW
« Reply #2 on: March 09, 2004, 10:08:46 AM »

Anpera, I've been using this since you posted it in German on your boards.


No bugs that I know of and my users love it.

Great work.
Logged
anpera
Guest
« Reply #3 on: March 18, 2004, 08:33:13 PM »

One bug was reported by lotgd.de. It was possible, that after a monster killed you, your creatures or buffs killed the monster. In this case you were able to walk around in the forest as a dead. Returning to village took you to graveyard, but visiting the healer fooled death.

Also I never managed to reproduce this case I think it is fixed now.

The instructions above are up to date. To fix the bug in a modified battle.php do the following Bugfix:
Code:
----- Open:
battle.php (with AutoFight installed)

----- Find:
for ($count=$count;$count>0;$count--){

----- After, add:
if ($badguy['creaturehealth']>0 && $session['user']['hitpoints']>0){

----- Find (a few lines below):
if ($badguy['creaturehealth']>0 && $session['user']['hitpoints']>0){

----- Before, add:
}

----- Save and close

The instructions on top of this thread are up to date!
Logged
sun
Guest
« Reply #4 on: April 27, 2004, 05:29:37 PM »

I made a small addition to the fight script to make it stop when the user's HP is less than half their maximum, so they have a chance to react.  So, this way you can sort of fight to the death, but still have a chance to not die if your HP is getting low.

I replaced, in battle.php with the autofight code put in:

Code:
if ($count>1 && $session[user][hitpoints]>0 && $badguy[creaturehealth]>0) output("`2`bNext round:`b`n");

with:

Code:
if (($HTTP_GET_VARS[auto]=="full") && ($session[user][hitpoints] < ($session['user']['maxhitpoints']/2))) {
   // Only break early if we're fighting to the death (not really fighting to the death anymore is it)
   $count = 0;
}
else if ($count>1 && $session[user][hitpoints]>0 && $badguy[creaturehealth]>0) output("`2`bNext round:`b`n");


Also, I have a suggestion that I think would be neat - if players could set their fighting preferences in the prefrences page.  So, for example, they could say they want to always fight to the death, or always fight to the death and stop when they're down to half their HP, etc.  Then, when they acutally engage in a fight, it'll automatically proceed according to what they've set in preferences.
Logged
sun
Guest
« Reply #5 on: April 27, 2004, 06:22:16 PM »

Hmm, that didn't work for when the player is dead.  This does:

Code:
// Figure out the maximum HP.
$maximum_hp = ($session['user']['alive']) ? $session['user']['maxhitpoints'] : $session['user']['level'] * 5 + 50;
if (($HTTP_GET_VARS[auto]=="full") && ($session[user][hitpoints] < ($maximum_hp/2))) {
   // Only break early if we're fighting to the death (not really fighting to the death anymore is it)
   $count = 0;
}
else if ($count>1 && $session[user][hitpoints]>0 && $badguy[creaturehealth]>0) output("`2`bNext round:`b`n");
Logged
neveriwas
Guest
« Reply #6 on: April 27, 2004, 07:21:15 PM »

I was working on a similar feature to hopefully cut down on page loads, and/or db access. My result was similar, but I think that this one is better.

What sort of things could we do to reduce db hits? I suppose a simple, "only print one result" could be added in. I dunno. I am still getting over the flu so my brain is still a little floaty. I figured I'd just put it out there.
Logged
robert
Old Dog
Moderator
Mod God
*****
Offline Offline

Posts: 1047


LoGD Buff!


View Profile WWW
« Reply #7 on: May 01, 2004, 03:31:27 AM »

WOW!
This auto fight is great! I love the features and options!
A player can if they wanted to, select an option in Preferances
and make it their own or use the default settings - either way it
works great!
Logged

Pffft
Guest
« Reply #8 on: September 28, 2004, 08:24:21 AM »

I know this is an old thread, but I would like to thank you for making this.  So, thank you.  8]
Logged
Interloper
Guest
« Reply #9 on: October 22, 2004, 06:25:03 PM »


Cool mod. I think my players are going to like this.

 Grin
Logged
Boofo
Member
Mod God
*****
Offline Offline

Posts: 774


View Profile
« Reply #10 on: October 22, 2004, 08:03:29 PM »

Just so you know this is the first implementation of this sort of feature that I wasn't horribly allergic to and it's now a part of 0.9.8 with some modifications.

I allow 5 or 10 rounds of autofight.  I also added an additional config option to allow or disallow fight-to-death because that could be *very* laggy on the server with all the output generation.

Can you post a file with all the correct code we need for this (with you settings added), please, sir? Wink
Logged

chmod a+x /bin/laden -- Allows anyone the permission to execute /bin/laden
kodysumter2
Guest
« Reply #11 on: October 22, 2004, 09:33:28 PM »

i get a parse error

parse error, unexpected T_VARIABLE in /home/insanit/public_html/logd/battle.php on line 194

when i just add the first line of code, the

if ($HTTP_GET_VARS[auto]=="full"){
  $count=100;
}else if ($HTTP_GET_VARS[auto]=="five"){
  $count=5;
}else{
  $count=1;
}

i dont know what is going on?
Logged
XChrisX
Global Moderator
Mod God
*****
Offline Offline

Posts: 4647

Be aware of the squirrel!


View Profile WWW
« Reply #12 on: October 22, 2004, 11:13:17 PM »

Can you post a file with all the correct code we need for this (with you settings added), please, sir? Wink

The Autofight is already (correctly) included in - at least - the last three prereleases (and I suspect in any other pre, too...)

So, there's no need for this, unless you're running the old version Wink
Logged

Running for more than three years now:
Arune
Member
Mod God
*****
Offline Offline

Posts: 718


Arune Vai - khatfield


View Profile WWW
« Reply #13 on: October 23, 2004, 01:52:16 AM »

I would guess if they are using this code, they are indeed running the old version Smiley
Logged
SaucyWench
Mod God
*****
Offline Offline

Posts: 2238


I'm a good girl.


View Profile WWW
« Reply #14 on: October 23, 2004, 04:16:32 AM »

By the way, the parse error is because elseif is one word.
Logged

SaucyWench
Owner of GemDust.com and Darton City proudly hosted by LunarPages
Pages: [1] 2   Go Up
  Print  
 
Jump to:  


*
DragonPrime Notices
Play LoGD on Dragonprime

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