git-svn-id: http://cswowd-fork.googlecode.com/svn/trunk@110 e451fad0-63ce-11de-bed1...
[cswow.git] / module / show / show_quest.php
blob8832aba6ede0913013aae4d39a3a6a1ef4cfc766
1 <?php
2 include_once("conf.php");
3 include_once("include/functions.php");
5 function getQuestText($quest_text)
7 $letter = array( '$b' ,'$B$B', '$B' , '$N' , '$n' , '$C' , '$r');
8 $values = array('<br>','<br>','<br>','(Name)', '(Name)','(Class)', '(Race)');
9 return str_replace($letter, $values, $quest_text);
12 function renderReqCollect($item_id, $maxcount, $count)
14 if (!$item_id > 0)
15 return;
16 $name=getItemName($item_id);
17 echo "<tr><td>&nbsp;&nbsp;<a href=\"?item=$item_id\">$name</a>:&nbsp;$count/$maxcount</td></tr>";
20 function renderReqKillOrCast($text,$ReqCreatureOrGOId,$ReqCreatureOrGOCount,$ReqSpellCast, $count)
22 global $lang;
23 if ($ReqCreatureOrGOId>0)
25 echo "<tr><td><a style='float: right;' href=\"?map&npc=$ReqCreatureOrGOId\">$lang[map]</a>&nbsp;&nbsp;";
26 if ($ReqSpellCast==0) // Требуется убить моба
28 if ($text)
29 echo "<a href=\"?npc=$ReqCreatureOrGOId\">$text</a>";
30 else
31 echo $lang['kill'].'&nbsp;'.getCreatureName($ReqCreatureOrGOId);
33 else
35 // $spell_name=getSpellName($ReqSpellCast);
36 if (!$text) $text = $lang['cast'];
37 echo "<a href=\"?spell=$ReqSpellCast\">$text</a>&nbsp;$lang[cast_on]&nbsp;".getCreatureName($ReqCreatureOrGOId);
39 echo ":&nbsp;$count/$ReqCreatureOrGOCount</td></tr>";
41 else if ($ReqCreatureOrGOId<0)
43 $ReqCreatureOrGOId=-$ReqCreatureOrGOId;
44 echo "<tr><td><a style='float: right;' href=\"?map&obj=$ReqCreatureOrGOId\">$lang[map]</a>&nbsp;&nbsp;";
45 if ($ReqSpellCast==0) // Требуется использовать геймобьект
47 if ($text)
48 echo "<a href=\"?object=$ReqCreatureOrGOId\">$text</a>";
49 else
50 echo $lang['use'].'&nbsp;'.getGameobjectName($ReqCreatureOrGOId);
52 else
54 if (!$text) $text = $lang['cast'];
55 // $spell_name=getSpellName($ReqSpellCast);
56 echo "<a href=\"?spell=$ReqSpellCast\">$text</a> $lang[cast_on]&nbsp;".getGameobjectName($ReqCreatureOrGOId);
58 echo ":&nbsp;$count/$ReqCreatureOrGOCount</td></tr>";
61 function renderQuestSource($srcID, $srcCount)
63 if (!$srcID)
64 return;
65 $name=getItemName($srcID);
66 echo "<tr><td>&nbsp;&nbsp;<a href=\"?item=$srcID\">$name</a>".($srcCount?'&nbsp;x&nbsp;'.$srcCount:'').'</td></tr>';
69 ########
71 $entry = intval(@$_REQUEST['quest']);
72 $guid = intval(@$_REQUEST['guid']);
74 $quest=getQuest($entry);
75 if (!$quest)
77 RenderError("$lang[quest_not_found1]");
79 else
81 $q_status = 0;
82 if ($guid)
83 $q_status = $cDB->selectRow("SELECT * FROM `character_queststatus` WHERE `guid` = ?d AND `quest` = ?d", $guid, $entry);
84 if ($lang['www_quest'])
85 echo "<a href=\"".sprintf($lang['www_quest'], $entry)."\" target=\"_blank\"\">".sprintf($lang['www_quest'], $entry)."</a><br>";
87 echo "<table class=quest width=550>";
88 echo "<tbody>";
90 echo "<tr><td class=head>$quest[Title]";
91 if ($quest['Type'])
92 echo "<br><FONT size=-3>&lt;".getQuestType($quest['Type'])."&gt;</FONT>";
94 if (getAllowableRace($quest['RequiredRaces']) && ($quest['RequiredRaces'] & 1101) && ($quest['RequiredRaces'] !=1791))
96 echo "<br><FONT color=#0000ff>$lang[required_races]&nbsp;$lang[Alliance]&nbsp;</FONT><img width=22 height=22 src='images/player_info/factions_img/alliance.gif'>";
97 echo '<br><FONT color=#0000ff>'.$game_text['allowable_race'].'&nbsp;'.getAllowableRace($quest['RequiredRaces']).'</FONT>';
100 if (getAllowableRace($quest['RequiredRaces']) && ($quest['RequiredRaces'] & 690) && ($quest['RequiredRaces'] !=1791))
102 echo "<br><FONT color=#ff0000>$lang[required_races]&nbsp;$lang[Horde]&nbsp;</FONT><img width=22 height=22 src='images/player_info/factions_img/horde.gif'>";
103 echo '<br><FONT color=#ff0000>'.$game_text['allowable_race'].'&nbsp;'.getAllowableRace($quest['RequiredRaces']).'</FONT>';
106 if (($quest['RequiredRaces'] == 0) OR ($quest['RequiredRaces'] == 1791))
108 echo "</br>";
109 echo "<br><FONT color=#008800>$lang[required_races]&nbsp;$lang[Both]</FONT>";
110 echo '<br><FONT color=#008800>'.$game_text['allowable_race'].'&nbsp;'.getAllowableRace(1791).'</FONT>';
113 if (getAllowableClass($quest['RequiredClasses']))
114 echo '<br><FONT color=#000000>'.$game_text['allowable_class'].'&nbsp;'.getQAllowableClass($quest['RequiredClasses']).'</FONT>';
116 if ($entry == getQuestOld($entry))
117 echo '<br><FONT color=#ff0000><b>'.$lang['quest_marked'].'</FONT></b>';
119 echo "</th></tr>";
120 echo "</th></tr>";
122 echo '<tr><td>';
123 if ($quest['ZoneOrSort']>0)
124 echo "<a style='float: right;' href=\"?s=q&ZoneID=".$quest['ZoneOrSort']."\">".getAreaName($quest['ZoneOrSort'], 0)."</a>";
125 else
126 if ($quest['ZoneOrSort']<0 AND ((-$quest['ZoneOrSort']) >= 374 OR (-$quest['ZoneOrSort']) == 221 OR (-$quest['ZoneOrSort']) == 241 OR ((-$quest['ZoneOrSort']) >= 344 AND (-$quest['ZoneOrSort']) < 371) or
127 (-$quest['ZoneOrSort']) == 284 OR (-$quest['ZoneOrSort']) == 25 OR (-$quest['ZoneOrSort']) == 41 OR (-$quest['ZoneOrSort']) < 24))
128 echo "<a style='float: right;' href=\"?s=q&SortID=".(-$quest['ZoneOrSort'])."\">".getQuestSort(-$quest['ZoneOrSort'], 0)."</a>";
130 echo "$lang[quest_level]&nbsp;$quest[QuestLevel]<br>";
132 if ($quest['RequiredSkill'])
133 echo "<a style='float: right;' href=\"?s=q&SkillID=".($quest['RequiredSkill'])."\">".getSkillName($quest['RequiredSkill'], 0)."&nbsp;($quest[RequiredSkillValue])</a>";
135 if ($quest['MinLevel'])
136 echo "$lang[obtained_at_level]&nbsp;$quest[MinLevel]</td></tr>";
138 if ($quest['SuggestedPlayers'])
139 echo "<tr><td>$lang[suggestedplayers]&nbsp;<b>$quest[SuggestedPlayers]</b></td></tr>";
141 if ($quest['LimitTime'])
142 echo '<tr><td>'.$lang['qlimittime'].'&nbsp;'.getTimeText($quest['LimitTime']).'</td></tr>';
144 if (getGameEventQuest($quest['entry']))
146 $qevent=getGameEventQuest($quest['entry']);
147 echo '<tr><td>'.$lang['obtained_at_event'].':&nbsp;<FONT color=#E614E6>'.getGameEventName($qevent).'</FONT></td></tr>';
150 if ($quest['SpecialFlags'] & QUEST_SPECIAL_FLAG_MONTHLY)
151 echo "<tr><td>$lang[item_type]:&nbsp;<a href=\"?s=q&Sfm=".($quest['SpecialFlags'])."\">".$lang['quest_type3']."</a></td></tr>";
153 if ($quest['QuestFlags'] & QUEST_FLAGS_WEEKLY)
154 echo "<tr><td>$lang[item_type]:&nbsp;<a href=\"?s=q&Sfw=".($quest['QuestFlags'])."\">".$lang['quest_type2']."</a></td></tr>";
156 if ($quest['QuestFlags'] & QUEST_FLAGS_DAILY)
157 echo "<tr><td>$lang[item_type]:&nbsp;<a href=\"?s=q&Sfd=".($quest['QuestFlags'])."\">".$lang['quest_type1']."</a></td></tr>";
159 if (($quest['SpecialFlags'] & QUEST_SPECIAL_FLAG_REPEATABLE) && (($quest['SpecialFlags'] & QUEST_SPECIAL_FLAG_MONTHLY) ==0)&& ($quest['QuestFlags'] & (QUEST_FLAGS_DAILY | QUEST_FLAGS_WEEKLY)) == 0)
160 echo "<tr><td>$lang[item_type]:&nbsp;<a href=\"?s=q&Sfr=".($quest['SpecialFlags'])."\">".$lang['quest_type0']."</a></td></tr>";
162 if ($quest['RequiredMinRepFaction'])
163 echo "<tr><td>$lang[item_faction_rank]:</td></tr>";
165 if ($quest['RequiredMinRepFaction'])
166 echo "<tr><td> ".getFactionName($quest['RequiredMinRepFaction']).":&nbsp;$quest[RequiredMinRepValue]($lang[item_min_level])</td></tr>";
168 if ($quest['RequiredMaxRepFaction'])
169 echo "<tr><td>".getFactionName($quest['RequiredMaxRepFaction']).":&nbsp;$quest[RequiredMaxRepValue]($lang[item_max_level])</td></tr>";
171 echo "<tr><td>".getQuestText($quest['Objectives'])."<hr></td></tr>";
172 ### Рек собрать
173 if ($quest['RepObjectiveFaction'])
174 echo "<tr><td>$lang[item_faction_rank]:</td></tr>";
176 if ($quest['RepObjectiveFaction'])
177 echo "<tr><td> ".getFactionName($quest['RepObjectiveFaction']).":&nbsp;$quest[RepObjectiveValue]($lang[item_min_level])</td></tr>";
179 if ($quest['ReqItemId1'] OR $quest['ReqItemId2'] OR $quest['ReqItemId3'] OR $quest['ReqItemId4'] OR $quest['ReqItemId5'] OR $quest['ReqItemId6'])
181 echo "<tr><td class=mark>$lang[collect]</td></tr>";
182 renderReqCollect($quest['ReqItemId1'],$quest['ReqItemCount1'],$q_status?$q_status['itemcount1']:0);
183 renderReqCollect($quest['ReqItemId2'],$quest['ReqItemCount2'],$q_status?$q_status['itemcount2']:0);
184 renderReqCollect($quest['ReqItemId3'],$quest['ReqItemCount3'],$q_status?$q_status['itemcount3']:0);
185 renderReqCollect($quest['ReqItemId4'],$quest['ReqItemCount4'],$q_status?$q_status['itemcount4']:0);
186 renderReqCollect($quest['ReqItemId5'],$quest['ReqItemCount5'],$q_status?$q_status['itemcount5']:0);
187 renderReqCollect($quest['ReqItemId6'],$quest['ReqItemCount6'],$q_status?$q_status['itemcount6']:0);
190 ### Рек убить
191 if ($quest['ReqCreatureOrGOId1'] != 0 OR $quest['ReqCreatureOrGOId2'] != 0 OR
192 $quest['ReqCreatureOrGOId3'] != 0 OR $quest['ReqCreatureOrGOId4'] != 0 )
194 // echo "<tr><td class=mark>$lang[kill]</td></tr>";
195 renderReqKillOrCast($quest['ObjectiveText1'],$quest['ReqCreatureOrGOId1'],$quest['ReqCreatureOrGOCount1'],$quest['ReqSpellCast1'],$q_status?$q_status['mobcount1']:0);
196 renderReqKillOrCast($quest['ObjectiveText2'],$quest['ReqCreatureOrGOId2'],$quest['ReqCreatureOrGOCount2'],$quest['ReqSpellCast2'],$q_status?$q_status['mobcount2']:0);
197 renderReqKillOrCast($quest['ObjectiveText3'],$quest['ReqCreatureOrGOId3'],$quest['ReqCreatureOrGOCount3'],$quest['ReqSpellCast3'],$q_status?$q_status['mobcount3']:0);
198 renderReqKillOrCast($quest['ObjectiveText4'],$quest['ReqCreatureOrGOId4'],$quest['ReqCreatureOrGOCount4'],$quest['ReqSpellCast4'],$q_status?$q_status['mobcount4']:0);
201 if ($quest['ReqSourceId1'] != 0 OR $quest['ReqSourceId2'] != 0 OR
202 $quest['ReqSourceId3'] != 0 OR $quest['ReqSourceId4'] != 0 )
204 echo "<tr><td class=mark>$lang[req_items]</td></tr>";
205 renderQuestSource($quest['ReqSourceId1'],$quest['ReqSourceCount1']);
206 renderQuestSource($quest['ReqSourceId2'],$quest['ReqSourceCount2']);
207 renderQuestSource($quest['ReqSourceId3'],$quest['ReqSourceCount3']);
208 renderQuestSource($quest['ReqSourceId4'],$quest['ReqSourceCount4']);
212 echo "<tr><td>".getQuestText($quest['Details'])."</td></tr>";
213 if ($quest['CompletedText'])
215 echo "<tr><td class = head>$lang[quest_completed]</td></tr>";
216 echo '<tr><td>'.$quest['CompletedText'].'</td></tr>';
218 if ($quest['SrcItemId'] || $quest['SrcSpell'])
220 echo "<tr><td class = head>$lang[provided]</td></tr>";
221 if ($quest['SrcItemId'])
223 $item = getItem($quest['SrcItemId'], "`entry`, `name`, `Quality`, `displayid`");
224 echo '<tr><td class=reward>&nbsp;'.text_show_item($item['entry'], $item['displayid']);
225 echo '&nbsp;<a class='.$Quality[$item['Quality']].' href="?item='.$item['entry'].'">'.$item['name'].'</a>';
226 if ($quest['SrcItemCount']>1) echo "&nbsp;x$quest[SrcItemCount]";
227 echo "</td></tr>";
229 if ($quest['SrcSpell'])
231 $spell=getSpell($quest['SrcSpell']); // Кастуемый спелл
232 if ($spell) $spellName = getSpellName($spell);
233 else $spellName = "Spell $quest[SrcSpell]";
234 echo "<tr><td class=reward>&nbsp;";show_spell($spell['id'], $spell['SpellIconID']);
235 echo " <a href=\"?spell=$spell[id]\">$spell[SpellName]</a></td></tr>";
238 echo "<tr><td class = head>$lang[quest_rewards]</td></tr>";
240 if ($quest['RewItemId1'] OR $quest['RewItemId1'] OR $quest['RewItemId1'] OR $quest['RewItemId1'])
242 echo "<tr><td class=mark>$lang[Rew_item]</td></tr>";
243 echo "<tr><td class=reward>&nbsp;";
244 if ($quest['RewItemId1']) {show_item($quest['RewItemId1']);}
245 if ($quest['RewItemId2']) {echo $lang['item_sel_and'];show_item($quest['RewItemId2']);}
246 if ($quest['RewItemId3']) {echo $lang['item_sel_and'];show_item($quest['RewItemId3']);}
247 if ($quest['RewItemId4']) {echo $lang['item_sel_and'];show_item($quest['RewItemId4']);}
248 echo "</td></tr>";
250 if ($quest['RewChoiceItemId1'] OR $quest['RewChoiceItemId2'] OR $quest['RewChoiceItemId3'] OR
251 $quest['RewChoiceItemId4'] OR $quest['RewChoiceItemId5'] OR $quest['RewChoiceItemId6'])
253 echo "<tr><td class=mark>$lang[Rew_select_item]</td></tr>";
254 echo "<tr><td class=reward>&nbsp;";
255 if ($quest['RewChoiceItemId1']) {show_item($quest['RewChoiceItemId1']);}
256 if ($quest['RewChoiceItemId2']) {echo $lang['item_sel_or'];show_item($quest['RewChoiceItemId2']);}
257 if ($quest['RewChoiceItemId3']) {echo $lang['item_sel_or'];show_item($quest['RewChoiceItemId3']);}
258 if ($quest['RewChoiceItemId4']) {echo $lang['item_sel_or'];show_item($quest['RewChoiceItemId4']);}
259 if ($quest['RewChoiceItemId5']) {echo $lang['item_sel_or'];show_item($quest['RewChoiceItemId5']);}
260 if ($quest['RewChoiceItemId6']) {echo $lang['item_sel_or'];show_item($quest['RewChoiceItemId6']);}
261 echo "</td></tr>";
263 if ($quest['RewMailTemplateId'])
265 $MailTime=$quest['RewMailDelaySecs']/60/60;
266 $ItemMail=getItemMail($quest['RewMailTemplateId']);
267 if ($ItemMail)
269 echo "<tr><td class=mark>$lang[Rew_mail]&nbsp;$lang[Mail_item_time]".$MailTime."$lang[Mail_time]";
270 echo "<tr><td class=mark>$lang[Rew_item_mail]</td></tr>";
271 echo "<tr><td class=reward>&nbsp;";{show_item($ItemMail);}
272 echo "</td></tr>";
274 else
276 echo "<tr><td class=mark>$lang[Rew_mail]&nbsp;$lang[Mail_item_time]".$MailTime."$lang[Mail_time]";
277 echo "</td></tr>";
280 if ($quest['RewSpell'] || $quest['RewSpellCast'])
282 $learn = $quest['RewSpell'] ? $quest['RewSpell'] : $quest['RewSpellCast'];
283 $spell=getSpell($learn);
284 if ($spell) $spellName = getSpellName($spell);
285 else $spellName = "Spell $learn";
286 echo '<tr><td class=mark>'.($quest['RewSpell']?$lang['learn_spell']:$lang['cast_spell']).'</td></tr>';
287 echo "<tr><td class=reward>&nbsp;";show_spell($spell['id'], $spell['SpellIconID']);
288 echo " <a href=\"?spell=$spell[id]\">$spell[SpellName]</a></td></tr>";
291 for ($i = 1; $i <= 5; $i++)
293 switch (ABS($quest['RewRepValueId'.$i])):
294 case 1: $RepValueId[$i] = 10; break;
295 case 2: $RepValueId[$i] = 25; break;
296 case 3: $RepValueId[$i] = 75; break;
297 case 4: $RepValueId[$i] = 150; break;
298 case 5: $RepValueId[$i] = 250; break;
299 case 6: $RepValueId[$i] = 350; break;
300 case 7: $RepValueId[$i] = 500; break;
301 case 8: $RepValueId[$i] = 1000; break;
302 case 9: $RepValueId[$i] = 5; break;
303 default: $RepValueId[$i] = 0;
304 endswitch;
306 $quest_rate[$i] = getRepRewRate($quest['RewRepFaction'.$i]);
308 if ($quest['RewRepValueId'.$i] < 0)
309 $RepValueId[$i] = -$RepValueId[$i];
311 if ($quest['RewRepValue'.$i] && $quest['RewRepValueId'.$i])
312 $quest['RewRepValue'.$i] = $quest['RewRepValue'.$i]/100;
314 if (!$quest['RewRepValue'.$i] && $quest['RewRepValueId'.$i])
315 $quest['RewRepValue'.$i] = $RepValueId[$i];
317 $quest['RewRepValue'.$i]=$quest['RewRepValue'.$i]*$quest_rate[$i];
320 if ($quest['RewRepFaction1'] AND !$quest['RewRepFaction2'] AND
321 !$quest['RewRepFaction3'] AND !$quest['RewRepFaction4'] AND
322 !$quest['RewRepFaction5'])
324 $spillover=getRepSpillover($quest['RewRepFaction1']);
325 if ($spillover)
326 foreach ($spillover as $faction)
328 if ($faction['faction1'])
330 $quest['RewRepFaction2']=$faction['faction1'];
331 $quest['RewRepValue2']=$quest['RewRepValue1']*$faction['rate_1'];
333 if ($faction['faction2'])
335 $quest['RewRepFaction3']=$faction['faction2'];
336 $quest['RewRepValue3']=$quest['RewRepValue1']*$faction['rate_2'];
338 if ($faction['faction3'])
340 $quest['RewRepFaction4']=$faction['faction3'];
341 $quest['RewRepValue4']=$quest['RewRepValue1']*$faction['rate_3'];
343 if ($faction['faction4'])
345 $quest['RewRepFaction5']=$faction['faction4'];
346 $quest['RewRepValue5']=$quest['RewRepValue1']*$faction['rate_4'];
351 if ($quest['RewRepFaction1'] OR $quest['RewRepFaction2'] OR
352 $quest['RewRepFaction3'] OR $quest['RewRepFaction4'] OR
353 $quest['RewRepFaction5'])
355 echo "<tr><td class=mark>$lang[Rew_reputation]</td></tr>";
356 if ($quest['RewRepFaction1'] && $quest['RewRepValue1'])echo "<tr><td>&nbsp;".getFactionName($quest['RewRepFaction1']).":&nbsp;$quest[RewRepValue1]</td></tr>";
357 if ($quest['RewRepFaction2'] && $quest['RewRepValue2'])echo "<tr><td>&nbsp;".getFactionName($quest['RewRepFaction2']).":&nbsp;$quest[RewRepValue2]</td></tr>";
358 if ($quest['RewRepFaction3'] && $quest['RewRepValue3'])echo "<tr><td>&nbsp;".getFactionName($quest['RewRepFaction3']).":&nbsp;$quest[RewRepValue3]</td></tr>";
359 if ($quest['RewRepFaction4'] && $quest['RewRepValue4'])echo "<tr><td>&nbsp;".getFactionName($quest['RewRepFaction4']).":&nbsp;$quest[RewRepValue4]</td></tr>";
360 if ($quest['RewRepFaction5'] && $quest['RewRepValue5'])echo "<tr><td>&nbsp;".getFactionName($quest['RewRepFaction5']).":&nbsp;$quest[RewRepValue5]</td></tr>";
362 if($quest['RewMoneyMaxLevel']) echo "<tr><td class=mark>$lang[Rew_XP]&nbsp;".getQuestXPValue($quest)."&nbsp;xp";
363 if($quest['RewHonorAddition'] OR $quest['RewHonorMultiplier'])
365 if ($quest['RewHonorMultiplier'])
366 $ihonor=round(getTeamContributionPoints(79)*$quest['RewHonorMultiplier']*0.1+$quest['RewHonorAddition']);
367 else
368 $ihonor=round($quest['RewHonorAddition']);
369 echo "<tr><td class=mark>$lang[Rew_honor]&nbsp;".substr($ihonor, 0, 4);
371 if($quest['RewOrReqMoney']) echo "<tr><td class=mark>$lang[Rew_money]&nbsp;".money($quest['RewOrReqMoney'])."</td></tr>";
374 $number = 0;
375 echo "<tr><td class = head>$lang[start]:</td></tr>";
376 if ($rows = $dDB->select("SELECT *
377 FROM `creature_template` join `creature_questrelation`
378 WHERE
379 `creature_questrelation`.`quest` = ?d AND
380 `creature_questrelation`.`id` = `creature_template`.`entry`", $quest['entry']))
381 foreach ($rows as $creature)
383 localiseCreature($creature);
384 $loyality = getLoyality($creature['faction_A']);
385 echo "<tr><td><a style='float: right;' href=\"?map&npc=$creature[entry]\">$lang[map]</a>";
386 echo "<a href=\"?npc=$creature[entry]\">$creature[name]</a> ($loyality)";
387 if ($creature['subname'] != "")
388 echo "<br><FONT color=#008800 size=-3>&lt;$creature[subname]&gt;</FONT>";
389 echo "</td></tr>";
390 $number++;
393 if ($rows = $dDB->select("SELECT *
394 FROM `gameobject_template` join `gameobject_questrelation`
395 WHERE
396 `gameobject_questrelation`.`quest` = ?d AND
397 `gameobject_questrelation`.`id` = `gameobject_template`.`entry`", $quest['entry']))
398 foreach ($rows as $go)
400 localiseGameobject($go);
401 echo "<tr><td><a style='float: right;' href=\"?map&obj=$go[entry]\">$lang[map]</a>";
402 echo "<a href=\"?object=$go[entry]\">$go[name]</a></td></tr>";
403 $number++;
406 if ($rows = $dDB->select("SELECT `entry`, `name`,`Quality`, `displayid` FROM `item_template` WHERE `startquest` = ?d", $quest['entry']))
407 foreach ($rows as $item)
409 localiseItem($item);
410 echo '<tr><td class=reward>&nbsp;'.text_show_item($item['entry'], $item['displayid']);
411 echo '&nbsp;<a class='.$Quality[$item['Quality']].' href="?item='.$item['entry'].'">'.$item['name'].'</a>';
412 $number++;
415 if ($number==0)
416 echo "<tr><td bgColor=#ff0000>$lang[quest_not_found]</td></tr>";
418 $number = 0;
419 echo "<tr><td class = head>$lang[end_q]:</td></tr>";
420 if ($rows = $dDB->select("SELECT *
421 FROM `creature_template` join `creature_involvedrelation`
422 WHERE
423 `creature_involvedrelation`.`quest` = ?d AND
424 `creature_involvedrelation`.`id` = `creature_template`.`entry`", $quest['entry']))
425 foreach ($rows as $creature)
427 localiseCreature($creature);
428 $loyality = getLoyality($creature['faction_A']);
429 echo "<tr><td><a style='float: right;' href=\"?map&npc=$creature[entry]\">$lang[map]</a>";
430 echo "<a href=\"?npc=$creature[entry]\">$creature[name]</a> ($loyality)";
431 if ($creature['subname'] != "")
432 echo "<br><FONT color=#008800 size=-3>&lt;$creature[subname]&gt;</FONT>";
433 echo "</td></tr>";
434 $number++;
437 if ($rows = $dDB->select("SELECT *
438 FROM `gameobject_template` join `gameobject_involvedrelation`
439 WHERE
440 `gameobject_involvedrelation`.`quest` = ?d AND
441 `gameobject_involvedrelation`.`id` = `gameobject_template`.`entry`", $quest['entry']))
442 foreach ($rows as $go)
444 localiseGameobject($go);
445 echo "<tr><td><a style='float: right;' href=\"?map&obj=$go[entry]\">$lang[map]</a>";
446 echo "<a href=\"?object=$go[entry]\">$go[name]</a></td></tr>";
447 $number++;
450 if ($number==0)
451 echo "<tr><td bgColor=#ff0000>$lang[quest_not_found]</td></tr>";
453 ### этот квест часть серии:
454 $needForQuest = $dDB->selectRow("SELECT * FROM `quest_template` WHERE ABS(`PrevQuestId`) = ?d", $quest['entry']);
455 if ($quest['PrevQuestId'] != 0 OR $quest['NextQuestId'] != 0 OR $needForQuest)
457 echo "<tr><td class = head>$lang[this_quest_is_part_of_a_series]</td></tr>";
458 $step=0;
459 // Разматываем цепочку квестов назад
460 if ($quest['PrevQuestId']!=0)
462 $prevquest[0]=$quest;
463 $list = 0;
464 while ($prevquest[$list]['PrevQuestId']!=0)
466 $qbefore = getQuest(abs($prevquest[$list]['PrevQuestId']));
467 if ($qbefore)
469 $prevquest[$list+1]=$qbefore;
470 $list+=1;
472 else
474 $entry = $prevquest[$list]['PrevQuestId'];
475 $prevquest[$list+1]['entry'] = $entry;
476 $prevquest[$list+1]['Title'] = "Error qid = $entry";
477 $prevquest[$list+1]['QuestLevel'] = "??";
478 $list+=1;
479 break;
482 // Выводим все предыдущие квесты
483 while ($step<$list)
485 $qinfo = $prevquest[$list-$step];
486 echo "<tr><td>";
487 echo "<div style='float: right;'>($lang[level]&nbsp;$qinfo[QuestLevel])</div>";
488 echo "$lang[step]($step)&nbsp;<a href=\"?quest=$qinfo[entry]\">$qinfo[Title]</a>";
489 echo "</td></tr>";
490 $step++;
493 echo "<tr><td>";
494 echo "<div style='float: right;'>($lang[level]&nbsp;$quest[QuestLevel])</div>";
495 echo "$lang[step]($step)&nbsp;$quest[Title]";
496 echo "</td></tr>";
497 $step++;
498 // Пытаемся найти следующие квесты
499 $nextquest = $quest;
500 while($nextquest!=0)
502 // Сначала по полю NextQuestId
503 if ($nextquest['NextQuestId']!=0)
505 $nextquest = getQuest(abs($nextquest['NextQuestId']));
506 echo "<tr><td>";
507 echo "<div style='float: right;'>($lang[level]&nbsp;$nextquest[QuestLevel])</div>";
508 echo "$lang[step]($step)&nbsp;<a href=\"?quest=$nextquest[entry]\">$nextquest[Title]</a>";
509 echo "</td></tr>";
511 // Если не вышло то по полю PrevQuestId = $nextquest[entry](у других квестов)
512 else
514 if ($needForQuest)
516 localiseQuest($needForQuest);
517 $nextquest=$needForQuest;
518 echo "<tr><td>";
519 echo "<div style='float: right;'>($lang[level]&nbsp;$nextquest[QuestLevel])</div>";
520 echo "$lang[step]($step)&nbsp;<a href=\"?quest=$nextquest[entry]\">$nextquest[Title]</a>";
521 echo "</td></tr>";
522 $needForQuest = $dDB->selectRow("SELECT * FROM `quest_template` WHERE ABS(`PrevQuestId`) = ?d", $nextquest['entry']);
524 else
525 $nextquest = 0;
527 $step++;
530 // Ищем квесты требующие выполнение даного квеста
531 $needForQuest = $dDB->selectPage($number, "SELECT * FROM `quest_template` WHERE ABS(`PrevQuestId`) = ?d", $quest['entry']);
532 if ($needForQuest AND $number > 1) // если == 1 то мы уже вывели это в цепочке
534 echo "<tr><td class = head>$lang[req_for_quest]</td></tr>";
535 foreach ($needForQuest as $nextquest)
537 localiseQuest($nextquest);
538 echo "<tr><td>";
539 echo "<div style='float: right;'>($lang[level]&nbsp;$nextquest[QuestLevel])</div>";
540 echo "<a href=\"?quest=$nextquest[entry]\">$nextquest[Title]</a>";
541 echo "</td></tr>";
546 echo "<tr><td class = head>$lang[additional_info]</td></tr>";
547 echo "<tr><td><b style='float: right;'>".getNumPalayersCompletedQuest($quest['entry'])."</b>{$lang['players_completed_quest']}:</td></tr>";
548 echo "<tr><td><b style='float: right;'>".getNumPalayersWithThisQuest($quest['entry'])."</b>{$lang['players_with_this_quest']}:</td></tr>";
549 echo "</tbody></table>";