From 32d95d3b8b5041d6593d06709ee647345a5200e4 Mon Sep 17 00:00:00 2001 From: AzaezelX Date: Sun, 20 Apr 2025 15:29:26 -0500 Subject: [PATCH] put AIPlayer support back, and it as the default class to spawn --- Engine/source/navigation/guiNavEditorCtrl.cpp | 52 ++++++++++++++----- .../datablocks/defaultDatablocks.tscript | 6 +-- .../game/tools/navEditor/NavEditorGui.gui | 2 +- .../game/tools/navEditor/main.tscript | 4 +- .../game/tools/navEditor/navEditor.tscript | 15 ++++-- 5 files changed, 56 insertions(+), 23 deletions(-) diff --git a/Engine/source/navigation/guiNavEditorCtrl.cpp b/Engine/source/navigation/guiNavEditorCtrl.cpp index 609eb7751..90a6e7f78 100644 --- a/Engine/source/navigation/guiNavEditorCtrl.cpp +++ b/Engine/source/navigation/guiNavEditorCtrl.cpp @@ -227,15 +227,23 @@ void GuiNavEditorCtrl::spawnPlayer(const Point3F &pos) missionCleanup->addObject(obj); } mPlayer = obj; - ShapeBase* sbo = dynamic_cast(obj); - if (sbo->getAIController()) + AIPlayer* asAIPlayer = dynamic_cast(obj); + if (asAIPlayer) //try direct { - if (sbo->getAIController()->mControllerData) - Con::executef(this, "onPlayerSelected", Con::getIntArg(sbo->getAIController()->mControllerData->mLinkTypes.getFlags())); + Con::executef(this, "onPlayerSelected", Con::getIntArg(asAIPlayer->mLinkTypes.getFlags())); } else { - Con::executef(this, "onPlayerSelected"); + ShapeBase* sbo = dynamic_cast(obj); + if (sbo->getAIController()) + { + if (sbo->getAIController()->mControllerData) + Con::executef(this, "onPlayerSelected", Con::getIntArg(sbo->getAIController()->mControllerData->mLinkTypes.getFlags())); + } + else + { + Con::executef(this, "onPlayerSelected"); + } } } } @@ -398,25 +406,41 @@ void GuiNavEditorCtrl::on3DMouseDown(const Gui3DMouseEvent & event) if(ri.object) { mPlayer = ri.object; - ShapeBase* sbo = dynamic_cast(ri.object); - if (sbo->getAIController()) + AIPlayer* asAIPlayer = dynamic_cast(mPlayer.getPointer()); + if (asAIPlayer) //try direct { - if (sbo->getAIController()->mControllerData) - Con::executef(this, "onPlayerSelected", Con::getIntArg(sbo->getAIController()->mControllerData->mLinkTypes.getFlags())); + Con::executef(this, "onPlayerSelected", Con::getIntArg(asAIPlayer->mLinkTypes.getFlags())); } else { - Con::executef(this, "onPlayerSelected"); + ShapeBase* sbo = dynamic_cast(mPlayer.getPointer()); + if (sbo->getAIController()) + { + if (sbo->getAIController()->mControllerData) + Con::executef(this, "onPlayerSelected", Con::getIntArg(sbo->getAIController()->mControllerData->mLinkTypes.getFlags())); + } + else + { + Con::executef(this, "onPlayerSelected"); + } } } } else if (!mPlayer.isNull() && gServerContainer.castRay(startPnt, endPnt, StaticObjectType, &ri)) { - ShapeBase* sbo = dynamic_cast(mPlayer.getPointer()); - if (sbo->getAIController()) + AIPlayer* asAIPlayer = dynamic_cast(mPlayer.getPointer()); + if (asAIPlayer) //try direct { - if (sbo->getAIController()->mControllerData) - sbo->getAIController()->getNav()->setPathDestination(ri.point,true); + asAIPlayer->setPathDestination(ri.point); + } + else + { + ShapeBase* sbo = dynamic_cast(mPlayer.getPointer()); + if (sbo->getAIController()) + { + if (sbo->getAIController()->mControllerData) + sbo->getAIController()->getNav()->setPathDestination(ri.point, true); + } } } } diff --git a/Templates/BaseGame/game/core/gameObjects/datablocks/defaultDatablocks.tscript b/Templates/BaseGame/game/core/gameObjects/datablocks/defaultDatablocks.tscript index ffdc4806c..6d9ee6067 100644 --- a/Templates/BaseGame/game/core/gameObjects/datablocks/defaultDatablocks.tscript +++ b/Templates/BaseGame/game/core/gameObjects/datablocks/defaultDatablocks.tscript @@ -172,10 +172,10 @@ datablock LightAnimData( SpinLightAnim ) datablock AIPlayerControllerData( aiPlayerControl ) { - + moveTolerance = 0.25; followTolerance = 1.0; mAttackRadius = 2; }; datablock AIWheeledVehicleControllerData( aiCarControl ) { - -}; \ No newline at end of file + moveTolerance = 1.0; followTolerance = 2.0; mAttackRadius = 5.0; +}; diff --git a/Templates/BaseGame/game/tools/navEditor/NavEditorGui.gui b/Templates/BaseGame/game/tools/navEditor/NavEditorGui.gui index 92505f4e7..18646fe1a 100644 --- a/Templates/BaseGame/game/tools/navEditor/NavEditorGui.gui +++ b/Templates/BaseGame/game/tools/navEditor/NavEditorGui.gui @@ -485,7 +485,7 @@ $guiContent = new GuiNavEditorCtrl(NavEditorGui, EditorGuiGroup) { VertSizing = "bottom"; Extent = "90 18"; text = "Stop"; - command = "NavEditorGui.getPlayer().stop();"; + command = "NavEditorGui.stop();"; }; }; }; diff --git a/Templates/BaseGame/game/tools/navEditor/main.tscript b/Templates/BaseGame/game/tools/navEditor/main.tscript index bfc06d103..3c2ef7aab 100644 --- a/Templates/BaseGame/game/tools/navEditor/main.tscript +++ b/Templates/BaseGame/game/tools/navEditor/main.tscript @@ -87,7 +87,7 @@ function NavEditorPlugin::onWorldEditorStartup(%this) // Add ourselves to the Editor Settings window. exec("./NavEditorSettingsTab.gui"); - //ESettingsWindow.addTabPage(ENavEditorSettingsPage); + ESettingsWindow.addTabPage(ENavEditorSettingsPage); ENavEditorSettingsPage.init(); // Add items to World Editor Creator @@ -241,7 +241,7 @@ function NavEditorPlugin::initSettings(%this) { EditorSettings.beginGroup("NavEditor", true); - EditorSettings.setDefaultValue("SpawnClass", "Player"); + EditorSettings.setDefaultValue("SpawnClass", "AIPlayer"); EditorSettings.setDefaultValue("SpawnDatablock", "DefaultPlayerData"); EditorSettings.endGroup(); diff --git a/Templates/BaseGame/game/tools/navEditor/navEditor.tscript b/Templates/BaseGame/game/tools/navEditor/navEditor.tscript index 75a84977b..159599ba6 100644 --- a/Templates/BaseGame/game/tools/navEditor/navEditor.tscript +++ b/Templates/BaseGame/game/tools/navEditor/navEditor.tscript @@ -459,13 +459,13 @@ function NavEditorGui::onLinkSelected(%this, %flags) function NavEditorGui::onPlayerSelected(%this, %flags) { - if (!isObject(%this.getPlayer().aiController)) + if (!isObject(%this.getPlayer().aiController) && (!(%this.getPlayer().isMemberOfClass("AIPlayer")))) { %this.getPlayer().aiController = new AIController(){ ControllerData = aiPlayerControl; }; %this.getPlayer().setAIController(%this.getPlayer().aiController); - NavMeshIgnore(%this.getPlayer(), true); - %this.getPlayer().setDamageState("Enabled"); } + NavMeshIgnore(%this.getPlayer(), true); + %this.getPlayer().setDamageState("Enabled"); updateLinkData(NavEditorOptionsWindow-->TestProperties, %flags); } @@ -559,6 +559,15 @@ function NavEditorGui::followObject(%this) } } +function NavEditorGui::stop(%this) +{ + if (isObject(%this.getPlayer().aiController)) + %this.getPlayer().aiController.stop(); + else + { + NavEditorGui.getPlayer().stop(); + } +} function NavInspector::inspect(%this, %obj) { %name = "";