Skip to content

Commit

Permalink
Implement Stuck Behavior setting for NPC editor.
Browse files Browse the repository at this point in the history
  • Loading branch information
joligario committed Jan 3, 2019
1 parent d96dddd commit 8f3b8ce
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 9 deletions.
2 changes: 1 addition & 1 deletion index.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

$current_revision = "27 November 2018";
$current_revision = "2 January 2019";

require_once("config.php");
require_once("lib/logging.php");
Expand Down
18 changes: 15 additions & 3 deletions lib/npc.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

$factions = faction_list();

$faction_values = array(
-1 => "Aggressive",
0 => "Passive",
Expand Down Expand Up @@ -112,6 +112,13 @@

$special_abilities_max = count($specialattacks);

$stuck = array(
0 => 'Run to Target',
1 => 'Warp to Target',
2 => 'Take No Action',
3 => 'Evade Combat'
);

switch ($action) {
case 0:
if ($npcid) { // View NPC
Expand Down Expand Up @@ -167,6 +174,7 @@
$body->set('faction_values', $faction_values);
$body->set('pet', get_ispet());
$body->set('special_abilities_max', $special_abilities_max);
$body->set('stuck', $stuck);
$vars = npc_info();
if ($vars) {
foreach ($vars as $key=>$value) {
Expand Down Expand Up @@ -365,6 +373,7 @@
$body->set('classes', $classes);
$body->set('specialattacks', $specialattacks);
$body->set('special_abilities_max', $special_abilities_max);
$body->set('stuck', $stuck);
$vars = get_stats();
if ($vars) {
foreach ($vars as $key=>$value) {
Expand Down Expand Up @@ -1374,6 +1383,7 @@ function update_npc() {
if ($charm_avoidance_rating != $_POST['charm_avoidance_rating']) $fields .= "charm_avoidance_rating=\"" . $_POST['charm_avoidance_rating'] . "\", ";
if ($skip_global_loot != $_POST['skip_global_loot']) $fields .= "skip_global_loot=\"" . $_POST['skip_global_loot'] . "\", ";
if ($rare_spawn != $_POST['rare_spawn']) $fields .= "rare_spawn=\"" . $_POST['rare_spawn'] . "\", ";
if ($stuck_behavior != $_POST['stuck_behavior']) $fields .= "stuck_behavior=\"" . $_POST['stuck_behavior'] . "\", ";

$fields = rtrim($fields, ", ");

Expand Down Expand Up @@ -1524,7 +1534,8 @@ function add_npc() {
$fields .= "charm_accuracy_rating=\"" . $_POST['charm_accuracy_rating'] . "\", ";
$fields .= "charm_avoidance_rating=\"" . $_POST['charm_avoidance_rating'] . "\", ";
$fields .= "skip_global_loot=\"" . $_POST['skip_global_loot'] . "\", ";
$fields .= "rare_spawn=\"" .$_POST['rare_spawn'] . "\"";
$fields .= "rare_spawn=\"" .$_POST['rare_spawn'] . "\", ";
$fields .= "stuck_behavior=\"" .$_POST['stuck_behavior'] . "\"";

if ($fields != '') {
$query = "INSERT INTO npc_types SET $fields";
Expand Down Expand Up @@ -1654,7 +1665,8 @@ function copy_npc() {
$fields .= "charm_accuracy_rating=\"" . $_POST['charm_accuracy_rating'] . "\", ";
$fields .= "charm_avoidance_rating=\"" . $_POST['charm_avoidance_rating'] . "\", ";
$fields .= "skip_global_loot=\"" . $_POST['skip_global_loot'] . "\", ";
$fields .= "rare_spawn=\"" . $_POST['rare_spawn'] . "\"";
$fields .= "rare_spawn=\"" . $_POST['rare_spawn'] . "\", ";
$fields .= "stuck_behavior=\"" . $_POST['stuck_behavior'] . "\"";

if ($fields != '') {
$query = "INSERT INTO npc_types SET $fields";
Expand Down
9 changes: 9 additions & 0 deletions templates/npc/js.tmpl.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,13 @@ function sanityCheck() {
alert("Warning: You made this NPC both tethered AND leashed!");
}
}
function underwaterCheck() {
var underwater = document.forms[1].underwater.checked;
var stuck = document.forms[1].stuck_behavior.value;
if (underwater && stuck != 2) {
alert("NPC is marked as an Underwater NPC. It is recommended to set Stuck Behavior to 'Take No Action'.");
}
}
</script>
11 changes: 9 additions & 2 deletions templates/npc/npc.add.tmpl.php
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,14 @@
<td align="left" width="17%">Emote: <br><input type="text" name="emoteid" size="10" value="0"></td>
<td align="left" width="17%">No Target Hotkey:<br><input type="text" name="no_target_hotkey" size="10" value="0"></td>
<td align="left" width="16%">Raid Target: <br><input type="text" name="raid_target" size="5" value="0"></td>
<td align="left" width="16%">&nbsp;</td>
<td align="left" width="16%">
Stuck Behavior:<br>
<select name="stuck_behavior" onChange="underwaterCheck();">
<?foreach ($stuck as $key=>$value):?>
<option value="<?=$key?>"><?=$key?>: <?=$value?></option>
<?endforeach;?>
</select>
</td>
</tr>
</table><br>
<center>
Expand All @@ -317,7 +324,7 @@
<input type="checkbox" name="unique_spawn_by_name" value="1"> Unique by Name<br>
</td>
<td valign="top" align="left">
<input type="checkbox" name="underwater" value="1"> Underwater NPC<br>
<input type="checkbox" name="underwater" value="1" onChange="underwaterCheck();"> Underwater NPC<br>
<input type="checkbox" name="34" value="34,1"> Destructible Object (34)<br>
<input type="checkbox" name="isquest" value="1"> Has Quest File<br>
</td>
Expand Down
11 changes: 9 additions & 2 deletions templates/npc/npc.edit.tmpl.php
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,14 @@
<td align="left" width="17%">Emote: <br><input type="text" name="emoteid" size="10" value="<?=$emoteid?>"></td>
<td align="left" width="17%">No Target Hotkey:<br><input type="text" name="no_target_hotkey" size="10" value="<?=$no_target_hotkey?>"></td>
<td align="left" width="16%">Raid Target: <br><input type="text" name="raid_target" size="5" value="<?=$raid_target?>"></td>
<td align="left" width="16%">&nbsp;</td>
<td align="left" width="16%">
Stuck Behavior:<br>
<select name="stuck_behavior" onChange="underwaterCheck();">
<?foreach ($stuck as $key=>$value):?>
<option value="<?=$key?>"<?echo ($stuck_behavior == $key) ? " selected" : "";?>><?=$key?>: <?=$value?></option>
<?endforeach;?>
</select>
</td>
</tr>
</table><br>
<center>
Expand All @@ -327,7 +334,7 @@
<input type="checkbox" name="unique_spawn_by_name" value="1"<?echo ($unique_spawn_by_name == 1) ? " checked" : "";?>> Unique by Name<br>
</td>
<td valign="top" align="left">
<input type="checkbox" name="underwater" value="1"<?echo ($underwater == 1) ? " checked" : "";?>> Underwater NPC<br>
<input type="checkbox" name="underwater" value="1"<?echo ($underwater == 1) ? " checked" : "";?> onChange="underwaterCheck();"> Underwater NPC<br>
<input type="checkbox" name="34" value="34,1^"<?echo ($specabil[34] == 1) ? "checked" : "";?>> Destructible Object (34)<br>
<input type="checkbox" name="isquest" value="1"<?echo ($isquest == 1) ? " checked" : "";?>> Has Quest File<br>
</td>
Expand Down
3 changes: 2 additions & 1 deletion templates/npc/npc.tmpl.php
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@
<tr>
<td align="left" width="33%">Skip Global Loot: <?=$yesno[$skip_global_loot]?></td>
<td align="left" width="33%">Rare Spawn: <?=$yesno[$rare_spawn]?></td>
<td align="left" width="34%">&nbsp;</td>
<td align="left" width="34%">Stuck Behavior: <?=$stuck_behavior?></td>
</tr>
</table>
</fieldset>
Expand Down Expand Up @@ -435,6 +435,7 @@
<input type="hidden" name="charm_avoidance_rating" value="<?=$charm_avoidance_rating?>">
<input type="hidden" name="skip_global_loot" value="<?=$skip_global_loot?>">
<input type="hidden" name="rare_spawn" value="<?=$rare_spawn?>">
<input type="hidden" name="stuck_behavior" value="<?=$stuck_behavior?>">
<center>
NEW ID:<input type="text" name="id" size="10" value="<?=$suggestedid?>">
<input type="submit" value="Copy NPC">
Expand Down

0 comments on commit 8f3b8ce

Please sign in to comment.