implemented type areatrigger

* staff only
This commit is contained in:
Sarjuuk
2018-06-30 23:43:57 +02:00
parent 56ccc592a6
commit e0150feda6
45 changed files with 1193 additions and 160 deletions

View File

@@ -35,6 +35,9 @@ class AjaxFilter extends AjaxHandler
case 'achievements':
$this->filter = (new AchievementListFilter(true, $opts));
break;
case 'areatriggers':
$this->filter = (new AreaTriggerListFilter(true, $opts));
break;
case 'enchantments':
$this->filter = (new EnchantmentListFilter(true, $opts));
break;

View File

@@ -575,6 +575,7 @@ trait spawnHelper
$wpSum = [];
$wpIdx = 0;
$spawns = DB::Aowow()->select("SELECT * FROM ?_spawns WHERE type = ?d AND typeId = ?d", self::$type, $this->id);
if (!$spawns)
return;
@@ -637,7 +638,13 @@ trait spawnHelper
$info[4] = Lang::game('mode').Lang::main('colon').implode(', ', $_);
}
$footer = '<span class="q2">Click to move to different floor</span>';
if (self::$type == TYPE_AREATRIGGER)
{
$o = Util::O2Deg($this->getField('orientation'));
$info[5] = 'Orientation'.Lang::main('colon').$o[0].'° ('.$o[1].')';
}
// $footer = '<span class="q2">Click to move to different floor</span>';
}
if ($info)
@@ -709,7 +716,7 @@ trait spawnHelper
public function getSpawns($mode)
{
// only Creatures, GOs and SoundEmitters can be spawned
if (!self::$type || !$this->getfoundIDs() || (self::$type != TYPE_NPC && self::$type != TYPE_OBJECT && self::$type != TYPE_SOUND))
if (!self::$type || !$this->getfoundIDs() || (self::$type != TYPE_NPC && self::$type != TYPE_OBJECT && self::$type != TYPE_SOUND && self::$type != TYPE_AREATRIGGER))
return [];
switch ($mode)

View File

@@ -35,7 +35,7 @@ define('TYPE_ARENA_TEAM', 102);
define('TYPE_USER', 500);
define('TYPE_EMOTE', 501);
define('TYPE_ENCHANTMENT', 502);
define('TYPE_AREATRIGGER', 503); // not for display, but indexing in ?_spawns-table
define('TYPE_AREATRIGGER', 503);
define('CACHE_TYPE_NONE', 0); // page will not be cached
define('CACHE_TYPE_PAGE', 1);
@@ -914,4 +914,11 @@ define('PR_EXCLUDE_GROUP_WRONG_PROFESSION', PR_EXCLUDE_GROUP_REQ_FISHING | PR
define('PR_EXCLUDE_GROUP_REQ_CANT_BE_EXALTED', 0x400);
define('PR_EXCLUDE_GROUP_ANY', 0x7FF);
// Areatrigger types
define('AT_TYPE_NONE', 0);
define('AT_TYPE_TAVERN', 1);
define('AT_TYPE_TELEPORT', 2);
define('AT_TYPE_OBJECTIVE', 3);
define('AT_TYPE_SMART', 4);
define('AT_TYPE_SCRIPT', 5);
?>

View File

@@ -0,0 +1,110 @@
<?php
if (!defined('AOWOW_REVISION'))
die('illegal access');
class AreaTriggerList extends BaseType
{
use spawnHelper;
public static $type = TYPE_AREATRIGGER;
public static $brickFile = 'areatrigger';
public static $dataTable = '?_areatrigger';
protected $queryBase = 'SELECT a.*, a.id AS ARRAY_KEY FROM ?_areatrigger a';
protected $queryOpts = array(
'a' => [['s']],
's' => ['j' => ['?_spawns s ON s.type = 503 AND s.typeId = a.id', true], 's' => ', s.areaId']
);
public function __construct($conditions = [])
{
parent::__construct($conditions);
// post processing
foreach ($this->iterate() as &$curTpl)
{
// remap for generic access
// $curTpl['name'] = $curTpl['cmd'];
}
}
public function getListviewData()
{
$data = [];
foreach ($this->iterate() as $__)
{
$data[$this->id] = array(
'id' => $this->curTpl['id'],
'type' => $this->curTpl['type'],
'name' => $this->curTpl['name'],
);
if ($_ = $this->curTpl['areaId'])
$data[$this->id]['location'] = [$_];
}
return $data;
}
public function getJSGlobals($addMask = GLOBALINFO_ANY)
{
$data = [];
// foreach ($this->iterate() as $__)
// $data[TYPE_EMOTE][$this->id] = ['name' => $this->getField('cmd')];
return $data;
}
public function renderTooltip() { }
}
class AreaTriggerListFilter extends Filter
{
protected $genericFilter = array(
2 => [FILTER_CR_NUMERIC, 'id', NUM_CAST_INT] // id
);
// fieldId => [checkType, checkValue[, fieldIsArray]]
protected $inputFields = array(
'cr' => [FILTER_V_LIST, [2], true ], // criteria ids
'crs' => [FILTER_V_RANGE, [1, 6], true ], // criteria operators
'crv' => [FILTER_V_RANGE, [0, 99999], true ], // criteria values - all criteria are numeric here
'na' => [FILTER_V_REGEX, '/[\p{C};]/ui', false], // name - only printable chars, no delimiter
'ma' => [FILTER_V_EQUAL, 1, false], // match any / all filter
'ty' => [FILTER_V_RANGE, [0, 5], true ] // types
);
protected function createSQLForCriterium(&$cr)
{
if (in_array($cr[0], array_keys($this->genericFilter)))
if ($genCr = $this->genericCriterion($cr))
return $genCr;
unset($cr);
$this->error = true;
return [1];
}
protected function createSQLForValues()
{
$parts = [];
$_v = &$this->fiData['v'];
// name [str]
if (isset($_v['na']))
if ($_ = $this->modularizeString(['name']))
$parts[] = $_;
// type [list]
if (isset($_v['ty']))
$parts[] = ['type', $_v['ty']];
return $parts;
}
}
?>

View File

@@ -338,13 +338,7 @@ class EnchantmentListFilter extends Filter
// type
if (isset($_v['ty']))
{
$_ = (array)$_v['ty'];
if (!array_diff($_, [1, 2, 3, 4, 5, 6, 7, 8]))
$parts[] = ['OR', ['type1', $_], ['type2', $_], ['type3', $_]];
else
unset($_v['ty']);
}
$parts[] = ['OR', ['type1', $_v['ty']], ['type2', $_v['ty']], ['type3', $_v['ty']]];
return $parts;
}

View File

@@ -103,6 +103,12 @@ class SoundList extends BaseType
class SoundListFilter extends Filter
{
// fieldId => [checkType, checkValue[, fieldIsArray]]
protected $inputFields = array(
'na' => [FILTER_V_REGEX, '/[\p{C};]/ui', false], // name - only printable chars, no delimiter
'ty' => [FILTER_V_LIST, [[1, 4], 6, 9, 10, 12, 13, 14, 16, 17, [19, 23], [25, 31], 50, 52, 53], true ] // type
);
// we have no criteria for this one...
protected function createSQLForCriterium(&$cr)
{
@@ -111,12 +117,6 @@ class SoundListFilter extends Filter
return [1];
}
// fieldId => [checkType, checkValue[, fieldIsArray]]
protected $inputFields = array(
'na' => [FILTER_V_REGEX, '/[\p{C};]/ui', false], // name - only printable chars, no delimiter
'ty' => [FILTER_V_LIST, [[1, 4], 6, 9, 10, 12, 13, 14, 16, 17, [19, 23], [25, 31], 50, 52, 53], true ] // type
);
protected function createSQLForValues()
{
$parts = [];

View File

@@ -1445,6 +1445,40 @@ class Util
return DB::Aowow()->query('INSERT INTO ?_reports (?#) VALUES (?a)', array_keys($update), array_values($update));
}
// orientation is 2*M_PI for a full circle, increasing counterclockwise
static function O2Deg($o)
{
// orientation values can exceed boundaries (for whatever reason)
while ($o < 0)
$o += 2*M_PI;
while ($o >= 2*M_PI)
$o -= 2*M_PI;
$deg = 360 * (1 - ($o / (2*M_PI) ) );
if ($deg == 360)
$deg = 0;
$dir = ['N', 'NE', 'E', 'SE', 'S', 'SW', 'W', 'NW'];
$desc = '';
foreach ($dir as $f => $d)
{
if (!$f)
continue;
if ( ($deg >= (45 * $f) - 22.5) && ($deg <= (45 * $f) + 22.5) )
{
$desc = $d;
break;
}
}
if (!$desc)
$desc = $dir[0];
return [(int)$deg, $desc];
}
}
?>