Quellcode der Dragonslayer-Edition
Quellcode der Dragonslayer-Edition: 0.9.7(DS V3) Ithil-Edition


Anmerkung: Dies ist nur ein Auszug aus dem Source. Ein etwas älteres, abgespecktes Release der Dragonslayer-Edition ist für jeden Interessenten frei zum Download verfügbar. Was wir uns unbedingt verbitten, ist Diebstahl unserer Arbeit ohne Nennung des Copyrights.
Falls beim Lesen des Source ein Bug entdeckt werden sollte, bitten wir um sofortige Meldung per Anfrage!


./battlesimulator.php

zurück
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
155:
156:
157:
158:
159:
160:
161:
162:
163:
164:
165:
166:
167:
168:
169:
170:
171:
172:
173:
174:
175:
176:
177:
178:
179:
180:
181:
182:
183:
184:
185:
186:
187:
188:
189:
190:
191:
192:
193:
194:
195:
196:
197:
198:
199:
200:
201:
202:
203:
204:
205:
206:
207:
208:
209:
210:
211:
212:
213:
214:
215:
216:
217:
218:
219:
220:
221:
222:
223:
224:
225:
226:
227:
228:
229:
230:
231:
232:
233:
234:
235:
236:
237:
238:
239:
240:
241:
242:
243:
244:
245:
246:
247:
248:
249:
250:
251:
252:
253:
254:
255:
256:
257:
258:
259:
260:
261:
262:
263:
264:
265:
266:
267:
268:
269:
270:
271:
272:
273:
274:
275:
276:
277:
278:
279:
280:
281:
282:
283:
284:
285:
286:
287:
288:
289:
290:
291:
292:
293:
294:
295:
296:
297:
298:
299:
300:
301:
302:
303:
304:
305:
306:
307:
308:
309:
310:
311:
312:
313:
314:
315:
316:
317:
318:
319:
320:
321:
322:
323:
324:
325:
326:
327:
328:
329:
330:
331:
332:
333:
334:
335:
336:
337:
338:
339:
340:
341:
342:
343:
344:
345:
346:
347:
348:
349:
350:
351:
352:
353:
354:
355:
356:
357:
358:
359:
360:
361:
362:
363:
364:
365:
366:
367:
368:
369:
370:
371:
372:
373:
374:
375:
376:
377:
378:
379:
380:
381:
382:
383:
384:
385:
386:
387:
388:
389:
390:
391:
392:
393:
394:
395:
396:
397:
398:
399:
400:
401:
402:
<?php

/* battlesimulator: Einen Gegner mit frei einstellbaren Werten bekämpfen, ohne Abzüge oder Gewinn
* author: Salator (salator [-[at]-] gmx.de)
* requires Dragonslayer-Edition > 2.5 because some new features used
*/

require_once 'common.php';
checkday();
page_header('Blusprings Übungsarena');

function 
restore_userdata()
{
    global 
$session;
    
$session['bufflist']=array();
    
$session['bufflist']=unserialize($session['user']['buffbackup']);
    if(!
is_array($session['bufflist']))
    {
        
$session['bufflist']=array();
    }
    
$session['user']['hitpoints']=$session['user']['pqtemp'];
    
$session['user']['specialtyuses']=unserialize($session['user']['specialmisc']);
    
$session['user']['pqtemp']='';
    
$session['user']['badguy']='';
    unset(
$session['specialsallowed']);
    
//nochwas?
}

output('`b`c`IBlusprings Übungsarena`0`c`b`n');
if (
$_GET['op']=='')
{
    
$badguy=unserialize(getsetting('battlesimulator','a:8:{s:12:"creaturename";s:14:"`@Minotaurus`0";s:13:"creaturelevel";i:1;s:14:"creatureweapon";s:6:"Hörner";s:14:"creatureattack";i:1;s:15:"creaturedefense";i:40;s:14:"creaturehealth";i:1000;s:4:"maze";i:1;s:9:"diddamage";i:0;}')); //als Init ein Minotaurus
    
if($_GET['act']=='save')
    {
        if(
$_POST['creature']!='0'//Instant-Monster
        
{
            
$creature=trim($_POST['creature']);
            switch(
$creature)
            {
                case 
'blackman':
                {
                    
$badguy = array(
                    
'creaturename'=>'`4Mysteriöser Mann`0'
                    
,'creaturelevel'=>$session['user']['level']
                    ,
'creatureweapon'=>'Masamune'
                    
,'creatureattack'=>$session['user']['attack']
                    ,
'creaturedefense'=>$session['user']['defence']
                    ,
'creaturehealth'=>((int)$session['user']['maxhitpoints']/100)*100+50
                    
,'diddamage'=>0);

                    
$atkflux e_rand(0,$session['user']['dragonkills']/5);
                    
$defflux e_rand(0,($session['user']['dragonkills']/5-$atkflux));
                    
$hpflux = ($session['user']['dragonkills']/- ($atkflux+$defflux)) * 5;
                    
$badguy['creatureattack']+=$atkflux;
                    
$badguy['creaturedefense']+=$defflux;
                    
$badguy['creaturehealth']+=$hpflux;
                break;
                }

                case 
'bloodchamp':
                {
                    if (
$session['user']['level']<2)
                    {
                        
$start=0$span=1;
                    }
                    elseif (
$session['user']['level']<4)
                    {
                        
$start=0$span=2;
                    }
                    elseif (
$session['user']['level']<6)
                    {
                        
$start=1$span=2;
                    }
                    elseif (
$session['user']['level']<9)
                    {
                        
$start=2$span=3;
                    }
                    elseif (
$session['user']['level']<12)
                    {
                        
$start=2$span=4;
                    }
                    else
                    {
                        
$start=3$span=5;
                    }
                    
$badguy = array(
                    
'creaturename'=>'`4Champion des Blutgottes`0'
                    
,'creaturelevel'=>$session['user']['level']+e_rand($start,$span)
                    ,
'creatureweapon'=>'Blutschwert'
                    
,'creatureattack'=>$session['user']['attack']
                    ,
'creaturedefense'=>$session['user']['defence']
                    ,
'creaturehealth'=>((int)$session['user']['maxhitpoints']/100)*100+50
                    
,'diddamage'=>0);

                    
$session['user']['badguy']=createstring($badguy);
                    
$atkflux e_rand(0,$session['user']['dragonkills']*2);
                    
$defflux e_rand(0,($session['user']['dragonkills']*2-$atkflux));
                    
$hpflux = ($session['user']['dragonkills']*- ($atkflux+$defflux)) * 5;
                    
$badguy['creatureattack']+=$atkflux;
                    
$badguy['creaturedefense']+=$defflux;
                    
$badguy['creaturehealth']+=$hpflux;
                    break;
                }

                case 
'commander':
                {
                    
$badguy = array('creaturename'=>'Kommandant der Dunklen Lande'
                    
,'creaturelevel'=>$session['user']['level']
                    ,
'creatureweapon'=>'Schattenklinge'
                    
,'creatureattack'=>$session['user']['attack']*1.2
                    
,'creaturedefense'=>$session['user']['defence']*1.1
                    
,'creaturehealth'=>round($session['user']['maxhitpoints']*0.9)
                    ,
'diddamage'=>0);
                    break;
                }

                case 
'elementar':
                {
                    
$badguy = array(
                    
"creaturename"=>"`&Schrein-Wächter`0"
                    
,"creaturelevel"=>$session['user']['level']+e_rand(1,3)
                    ,
"creatureweapon"=>"Zeigefinger der Unwürdigkeit"
                    
,"creatureattack"=>$session['user']['attack']*0.75
                    
,"creaturedefense"=>$session['user']['defence']*0.8
                    
,"creaturehealth"=>500+$session['user']['dragonkills']*10
                    
,"diddamage"=>0);

                    
$atkflux e_rand(0,$session['user']['dragonkills']*2);
                    
$defflux e_rand(0,($session['user']['dragonkills']*2-$atkflux));
                    
$hpflux = ($session['user']['dragonkills']*- ($atkflux+$defflux)) * 5;
                    
$badguy['creatureattack']+=$atkflux;
                    
$badguy['creaturedefense']+=$defflux;
                    
$badguy['creaturehealth']+=$hpflux;
                    break;
                }

                case 
'god':
                {
                    
$badguy = array('creaturename'=>'`4Der Richter'
                    
,'creaturelevel'=>25
                    
,'creatureweapon'=>'`4Der jüngste Tag'
                    
,'creatureattack'=>1000
                    
,'creaturedefense'=>1000
                    
,'creaturehealth'=>10000
                    
,'diddamage'=>0);
                    break;
                }

                case 
'minotaur':
                {
                    
$badguy = array(
                    
'creaturename'=>'`@Minotaurus`0'
                    
,'creaturelevel'=>0
                    
,'creatureweapon'=>'Hörner'
                    
,'creatureattack'=>1
                    
,'creaturedefense'=>40
                    
,'creaturehealth'=>1000
                    
,'maze'=>1
                    
,'diddamage'=>0);
                    
$userattack=$session['user']['attack']+e_rand(1,3);
                    
$userhealth=round($session['user']['hitpoints']/2);
                    
$userdefense=$session['user']['defense']+e_rand(1,3);
                    
$badguy['creaturelevel']=$session['user']['level'];
                    
$badguy['creatureattack']+=($userattack-4);
                    
$badguy['creaturehealth']+=$userhealth;
                    
$badguy['creaturedefense']+=$userdefense;
                    break;
                }

                case 
'orc':
                {
                
$badguy=array(
                    
'creaturename' => '`2Ork-Späher`0'
                    
'creaturelevel' => 10
                    
'creatureweapon' => 'Krush-Varrok'
                    
'creatureattack' => 100
                    
'creaturedefense' => 100
                    
'creaturehealth' => 1000);
                    break;
                }

                case 
'pinkdragon':
                {
                    
$badguy = array("creaturename"=>"`%`bDer Pinke Drache`b`0","creaturelevel"=>18,"creatureweapon"=>"Ein gigantisches Flammenstösschen","creatureattack"=>45,"creaturedefense"=>25,"creaturehealth"=>300"diddamage"=>0);

                    
// First, find out how each dragonpoint has been spent and count those
                    // used on attack and defense.
                    // Coded by JT, based on collaboration with MightyE
                    
$points 0;
                    if(
is_array($session['user']['dragonpoints']))
                    {
                        foreach(
$session['user']['dragonpoints'] as $val)
                        {
                            if (
$val=='at' || $val=='de')
                            {
                                
$points++;
                            }
                        }
                    }

                    
// Now, add points for hitpoint buffs that have been done by the dragon
                    // or by potions!
                    
$points += (int)(($session['user']['maxhitpoints']-150)/5);

                    
// Okay.. *now* buff the dragon a bit.
                    
$points round($points*0.85,0);

                    
$atkflux e_rand(0$points);
                    
$defflux e_rand(0,$points-$atkflux);
                    
$hpflux = ($points - ($atkflux+$defflux)) * 5;
                    
$badguy['creatureattack']+=$atkflux;
                    
$badguy['creaturedefense']+=$defflux;
                    
$badguy['creaturehealth']+=$hpflux;
                    
$badguy['creaturehealth']*=1.65;

                    
// Endgegner
                    //$badguy['boss'] = true;
                    
$float_forest_bal getsetting('forestbal',1.5);
                    
$badguy['creatureattack'] *= 0.01 $float_forest_bal $session['user']['balance_dragon'];
                    
$badguy['creaturedefense'] *= 0.01 $float_forest_bal $session['user']['balance_dragon'];
                    
$badguy['creaturehealth'] *= 0.01 $float_forest_bal $session['user']['balance_dragon'];
                    
$badguy['creaturehealth'] = round($badguy['creaturehealth']);
                    
$session['user']['badguy']=createstring($badguy);
                    break;
                }

                case 
'snakegod':
                {
                    
$badguy = array(
                    
'creaturename'=>'`@Wadjet Schlangengöttin`0'
                    
,'creaturelevel'=>0
                    
,'creatureweapon'=>'Giftzähne'
                    
,'creatureattack'=>1
                    
,'creaturedefense'=>40
                    
,'creaturehealth'=>1000
                    
,'maze'=>1
                    
,'diddamage'=>0);
                    
$userattack=$session['user']['attack']+e_rand(2,5);
                    
$userhealth=round($session['user']['hitpoints']/1.25);
                    
$userdefense=$session['user']['defense']+e_rand(1,4);
                    
$badguy['creaturelevel']=$session['user']['level'];
                    
$badguy['creatureattack']+=($userattack-4);
                    
$badguy['creaturehealth']+=$userhealth;
                    
$badguy['creaturedefense']+=$userdefense;
                    break;
                }

                case 
'thive':
                {
                
$badguy=array(
                    
'creaturename' => 'Räuber-Anführer'
                    
'creaturelevel' => 7
                    
'creatureweapon' => 'Dolch'
                    
'creatureattack' => 170
                    
'creaturedefense' => 30
                    
'creaturehealth' => 5000);
                    break;
                }

                default:
                
$badguy=array('creaturename' => 'Luft''creaturelevel' => 1'creatureweapon' => 'Nichts''creatureattack' => 1'creaturedefense' => 1'creaturehealth' => 1);
                break;
            }
        }
        else 
//selfmade-Monster
        
{
            
$badguy['creaturename']=($_POST['creaturename']>''?$_POST['creaturename']:$session['user']['name']);
            
$badguy['creaturelevel']=((int)$_POST['creaturelevel']>0?intval($_POST['creaturelevel']):$session['user']['level']);
            
$badguy['creaturename']=($_POST['creaturename']>''?$_POST['creaturename']:$session['user']['name']);
            
$badguy['creatureweapon']=($_POST['creatureweapon']>''?$_POST['creatureweapon']:$session['user']['weapon']);
            
$badguy['creatureattack']=((int)$_POST['creatureattack']>0?doubleval($_POST['creatureattack']):$session['user']['attack']);
            
$badguy['creaturedefense']=((int)$_POST['creaturedefense']>0?doubleval($_POST['creaturedefense']):$session['user']['defence']);
            
$badguy['creaturehealth']=((int)$_POST['creaturehealth']>0?intval($_POST['creaturehealth']):$session['user']['maxhitpoints']);
        }
        
$badguy['creaturelevel']=min($badguy['creaturelevel'],25); //Extremwerte machen komische Effekte
        
$badguy['creatureattack']=min($badguy['creatureattack'],1000);
        
$badguy['creaturedefense']=min($badguy['creaturedefense'],1000);
        
$badguy['creaturehealth']=min($badguy['creaturehealth'],10000);
        
$badguy['maze']=1//mazemonster setzen in battle.php nicht die bufflist zurück, das wollen wir ja selbst übernehmen
        
savesetting('battlesimulator',serialize($badguy));
        
output('`2Monster gespeichert.`0`n');
    } 
//end save
    
    //Eingabeformular anzeigen
    
$str_enum_monsters '
        0,keins,
        bloodchamp,Blutchampion,
        pinkdragon,Der Pinke Drache,
        god,Der Richter,
        commander,Kommandant der Dunklen Lande,
        minotaur,Minotaurus,
        blackman,Mysteriöser Mann,
        orc,Ork-Späher,
        thive,Räuber-Anführer,
        snakegod,Wadjet Schlangengöttin,
        elementar,Schrein-Wächter
    '
;
    
$arr_form = array(
        
'creature'=>'Fertig-Monster,enum,'.$str_enum_monsters ,
        
'creaturename'=>'Monstername',
        
'creaturelevel'=>'Monsterlevel,int',
        
'creatureweapon'=>'Monsterwaffe',
        
'creatureattack'=>'Angriffsstärke,int',
        
'creaturedefense'=>'Verteidigungsstärke,int',
        
'creaturehealth'=>'Monster-LP,int'
    
);
    
$str_lnk 'battlesimulator.php?act=save';
    
addnav('',$str_lnk);
    
output('Bastle dir dein eigenes Monster zusammen und bekämpfe es ohne Gefahr. Ungültige Werte werden durch deine eigenen Werte ersetzt.
    `nUm ein Fertigmonster zu wählen brauchen die unteren Werte nicht geändert werden, das übernimmt das Script. Die Werte der meisten Fertigmonster sind Char-bezogen und haben zufällige Schwankungen.
    `n`nDu hast 3 Kampf-Arten zur Auswahl:
    `n- wie im Wald, mit allen Fähigkeiten und Zaubern
    `n- wie im Schloss, ohne Tier, aber mit Knappe und Fähigkeiten
    `n- wie beim Meister, ohne alles
    `n`$Achtung! Eingesetzte Zauber werden nicht zurückgegeben.`0`n'
);
    
$str_out '<form method="POST" action="'.$str_lnk.'">';
    
$str_out .= generateform($arr_form,$badguy,false,'Speichern');
    
$str_out .= '</form>';
    
rawoutput($str_out);
}
        
else if(
$_GET['op']=='challenge'//Kampf
{
    
$session['user']['badguy']=getsetting('battlesimulator','');
    
$session['user']['buffbackup']=serialize($session['bufflist']);
    
$session['user']['specialmisc']=serialize($session['user']['specialtyuses']);
    
$session['user']['pqtemp']=$session['user']['hitpoints'];
    
$session['specialsallowed']=$_GET['specials'];
    
$battle=true;
}
    
if (
$_GET['op']=='fight')
{
    
$battle=true;
}
if (
$_GET['op']=='run')
{
    
output('Na, da hast du dich wohl etwas überschätzt. Du ziehst es vor, das Handtuch zu werfen.');
    
restore_userdata();
    
$battle=false;
}
    
if(
$battle)
{
    if (
$session['specialsallowed']==&& (count($session['bufflist'])>&& is_array($session['bufflist']) || $_GET['skill']!='')) //jegliche Specials unterbinden
    
{
        
$_GET['skill']='';
        
$session['bufflist']=array();
        
output('`&Du hast dich entschieden, während des Kampfes keinen Gebrauch von deinen besonderen Fähigkeiten zu machen!`0');
    }
    elseif (
$_GET['specials']==&& count($session['bufflist'])>&& is_array($session['bufflist'])) //_GET ist nur beim 1. Aufruf gesetzt
    
{
        if (
is_array($session['bufflist']['decbuff']))
        {
            
$decbuff=$session['bufflist']['decbuff'];
        }
        
$session['bufflist']=array();
        if (
is_array($decbuff))
        {
            
$session['bufflist']['decbuff']=$decbuff;
        }
        
output('`&Du hast dich für einen Kampf ohne Tier und Aktionen entschieden!`0');
    }
    if (!
$victory) include('battle.php');
    if (
$victory)
    {
        
headoutput('`c`b`@Sieg!`0`b`c`n`b`$Du hast `%'.$badguy['creaturename'].'`$ bezwungen!`0`b
        `nDu hattest noch '
.$session['user']['hitpoints'].' Lebenspunkte übrig.`n`n<hr>`n');
        
$battle=false;
        
$badguy=array();
        
restore_userdata();
    }
    elseif(
$defeat)
    {
        
restore_userdata();
        
headoutput('`c`b`$Niederlage!`0`b`c`n`&`bDu wurdest von `%'.$badguy['creaturename'].'`& besiegt!`b`n
        `$Bluespring stoppt `%'
.$badguy['creaturename'].'`$ vor dem vernichtenden Schlag und reicht dir seine Hand, um dir auf die Beine zu helfen.`0
        `n'
.$badguy['creaturename'].'`0 hatte noch '.$badguy['creaturehealth'].' Lebenspunkte übrig.`n`n<hr>`n');
        
$battle=false;
        
$badguy=array();
    }
    else
    {
        
fightnav(($session['specialsallowed']?true:false),true);
    }
}
if(!
$battle)
{
    
addnav('Aktionen');
    
addnav('Startseite und Einstellung','battlesimulator.php');
    
addnav('Kampf');
    
addnav('F?Kampf mit allen Fähigkeiten','battlesimulator.php?op=challenge&specials=1');
    
addnav('o?Kampf ohne Tier','battlesimulator.php?op=challenge&specials=2');
    
addnav('Kampf ohne Fähigkeiten','battlesimulator.php?op=challenge&specials=0');
    
addnav('Zurück');
    
addnav('T?Zurück zum Trainingslager','train.php');
    
addnav('Zurück zum Dorf','village.php');
}

page_footer();
?>
0.9.7(DS V3) Ithil-Edition