Skip to content

Commit

Permalink
Added Load Map Command
Browse files Browse the repository at this point in the history
  • Loading branch information
jamiephan committed Dec 31, 2020
1 parent 456f5b0 commit 625c383
Show file tree
Hide file tree
Showing 4 changed files with 128 additions and 1 deletion.
44 changes: 44 additions & 0 deletions (10)trymemode.stormmap/base.stormdata/Modules/LibUtilities.galaxy
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ trigger libUTIL_gt_WinGame;
trigger libUTIL_gt_StartGame;
trigger libUTIL_gt_EndGame;
trigger libUTIL_gt_RestartGame;
trigger libUTIL_gt_LoadMap;
trigger libUTIL_gt_SetCameraObject;
trigger libUTIL_gt_ResetCameraObject;
trigger libUTIL_gt_ForceRunTrigger;
Expand Down Expand Up @@ -381,6 +382,48 @@ void libUTIL_gt_RestartGame_Init () {
TriggerAddEventChatMessage(libUTIL_gt_RestartGame, c_playerAny, "restartgame", true);
}

//--------------------------------------------------------------------------------------------------
// Trigger: LoadMap
//--------------------------------------------------------------------------------------------------
bool libUTIL_gt_LoadMap_Func (bool testConds, bool runActions) {
// Variable Declarations
string lv_map;

// Automatic Variable Declarations
// Variable Initialization
lv_map = "CURRENT";

// Conditions
if (testConds) {
if (!(((StringWord(EventChatMessage(false), 1) == "lm") || (StringWord(EventChatMessage(false), 1) == "loadmap")))) {
return false;
}
}

// Actions
if (!runActions) {
return true;
}

if ((StringWord(EventChatMessage(false), 2) == null)) {
UIDisplayMessage(PlayerGroupAll(), c_messageAreaDebug, StringToText("Usage: <lm|loadmap> <MapPath>"));
}
else {
lv_map = StringWord(EventChatMessage(false), 2);
UIDisplayMessage(PlayerGroupAll(), c_messageAreaDebug, StringToText(("Loading Map: " + lv_map)));
GameSetNextMap(lv_map);
KickFromGame(PlayerGroupAll());
}
return true;
}

//--------------------------------------------------------------------------------------------------
void libUTIL_gt_LoadMap_Init () {
libUTIL_gt_LoadMap = TriggerCreate("libUTIL_gt_LoadMap_Func");
TriggerAddEventChatMessage(libUTIL_gt_LoadMap, c_playerAny, "lm", false);
TriggerAddEventChatMessage(libUTIL_gt_LoadMap, c_playerAny, "loadmap", false);
}

//--------------------------------------------------------------------------------------------------
// Trigger: Set Camera Object
//--------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -607,6 +650,7 @@ void libUTIL_InitTriggers () {
libUTIL_gt_StartGame_Init();
libUTIL_gt_EndGame_Init();
libUTIL_gt_RestartGame_Init();
libUTIL_gt_LoadMap_Init();
libUTIL_gt_SetCameraObject_Init();
libUTIL_gt_ResetCameraObject_Init();
libUTIL_gt_ForceRunTrigger_Init();
Expand Down
Binary file not shown.
37 changes: 37 additions & 0 deletions (10)trymemode.stormmap/base.stormdata/Modules/doc.json
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,43 @@
"description": "Set the minion wave to spawn every 100 seconds."
}
]
},
{
"shortCommand": "lm",
"command": "loadmap",
"description": [
"End the game and load a .stormmap file instantly.",
"The `MapPath` is relative to:",
" - `*.stormmods/base.stormmap/` for CASC / MPQ storage",
" - `HEROES_INSTALL_LOCATION/maps/` for file system",
"",
"There are currently 4 built-in `.stormmaps` from CASC in Heroes, which the `MapPath` is:",
" - heroes/singleplayermaps/(10)trymemode.stormmap",
" - `heroes/singleplayermaps/startingexperience/tutorial01.stormmap`",
" - `heroes/singleplayermaps/startingexperience/tutorialmapmechanics.stormmap`",
" - `heroes/singleplayermaps/startingexperience/tutorialveteran.stormmap`",
"",
"You can also put a `.stormmap` file into `HEROES_INSTALL_LOCATION/maps/`, e.g `HEROES_INSTALL_LOCATION/maps/cool.stormmap`, which the `MapPath` will be `cool.stormmap`"
],
"uiAvailable": false,
"parameters": [
{
"name": "MapPath",
"required": true,
"description": "Defines the path to the stormmap",
"type": "string"
}
],
"examples": [
{
"command": "{shortCommand} heroes/singleplayermaps/startingexperience/tutorial01.stormmap",
"description": "Exit and Load the tutorial 1 map"
},
{
"command": "{command} heroes/singleplayermaps/startingexperience/tutorialveteran.stormmap",
"description": "Exit and Load the veteran tutorial map."
}
]
}
]
},
Expand Down
48 changes: 47 additions & 1 deletion USAGE.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<a name="meta-top"></a>

# Usage
<sup>*(Generated from [doc.json](./(10)trymemode.stormmap/base.stormdata/Modules/doc.json) at Thu, 31 Dec 2020 01:22:23 GMT)*</sup>
<sup>*(Generated from [doc.json](./(10)trymemode.stormmap/base.stormdata/Modules/doc.json) at Thu, 31 Dec 2020 18:30:23 GMT)*</sup>

Generally, most of the functionalities are using chat commands. Simply type the commands in the chat box (like how you would normally chat with teammates).
>Note: Remember to either use allies or all chat channel when try to use the commands. Public chat channels and Private Messages (PM) does not work.
Expand Down Expand Up @@ -36,6 +36,8 @@ Some of the commands have an UI counterpart implemented, which will display a me

- 💭 [Command: `forceruntrigger`](#cmd-forceruntrigger)

- 💭 [Command: `loadmap`](#cmd-loadmap)

- 💭 [Command: `minionwaveinterval`](#cmd-minionwaveinterval)

- 💭 [Command: `resetcameraobject`](#cmd-resetcameraobject)
Expand Down Expand Up @@ -286,6 +288,50 @@ Force to Run a Trigger created by `TriggerCreate()` with ignoring conditions and



[\[Return to Table of Contents 🧾\]](#meta-toc)

[\[Return to Top ⬆\]](#meta-top)

<a name="cmd-loadmap"></a>

## (`loadmap` | `lm`) `<MapPath>`
<a name="cmd-loadmap-description"></a>

#### ✏ Description:
End the game and load a .stormmap file instantly.
The `MapPath` is relative to:
- `*.stormmods/base.stormmap/` for CASC / MPQ storage
- `HEROES_INSTALL_LOCATION/maps/` for file system

There are currently 4 built-in `.stormmaps` from CASC in Heroes, which the `MapPath` is:
- heroes/singleplayermaps/(10)trymemode.stormmap
- `heroes/singleplayermaps/startingexperience/tutorial01.stormmap`
- `heroes/singleplayermaps/startingexperience/tutorialmapmechanics.stormmap`
- `heroes/singleplayermaps/startingexperience/tutorialveteran.stormmap`

You can also put a `.stormmap` file into `HEROES_INSTALL_LOCATION/maps/`, e.g `HEROES_INSTALL_LOCATION/maps/cool.stormmap`, which the `MapPath` will be `cool.stormmap`

<a name="cmd-loadmap-parameters"></a>

#### ⚙ Parameters:
<MapPath>
Required: true
Type: string
Usage: Defines the path to the stormmap
<a name="cmd-loadmap-examples"></a>

#### 🔧 Examples:
> lm heroes/singleplayermaps/startingexperience/tutorial01.stormmap
(Exit and Load the tutorial 1 map)
> loadmap heroes/singleplayermaps/startingexperience/tutorialveteran.stormmap
(Exit and Load the veteran tutorial map.)
<a name="cmd-loadmap-uiAvailability"></a>

#### 🖼 UI Availability:
-**Not Implemented**



[\[Return to Table of Contents 🧾\]](#meta-toc)

[\[Return to Top ⬆\]](#meta-top)
Expand Down

0 comments on commit 625c383

Please sign in to comment.