Skip to content

Commit

Permalink
Added checks for adb/rmb and removed countbehavior command
Browse files Browse the repository at this point in the history
  • Loading branch information
jamiephan committed Jan 23, 2021
1 parent ca04950 commit cf2cbc5
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 119 deletions.
72 changes: 17 additions & 55 deletions (10)trymemode.stormmap/base.stormdata/Modules/LibUnits.galaxy
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ trigger libUNIT_gt_AddBehaviorPanelAddBehaviorButtonClicked;
trigger libUNIT_gt_AddBehaviorPanelCloseButtonClicked;
trigger libUNIT_gt_AddBehavior;
trigger libUNIT_gt_RemoveBehavior;
trigger libUNIT_gt_CountBehavior;
trigger libUNIT_gt_GetBehaviors;
trigger libUNIT_gt_ClearBehaviors;
trigger libUNIT_gt_ModifyUnitProperty;
Expand Down Expand Up @@ -1090,6 +1089,11 @@ bool libUNIT_gt_AddBehavior_Func (bool testConds, bool runActions) {
UIDisplayMessage(PlayerGroupAll(), c_messageAreaDebug, StringToText("Usage: <adb|addbehavior> <BehaviorName>"));
}
else {
if ((CatalogEntryIsValid(c_gameCatalogBehavior, (StringWord(EventChatMessage(false), 2))) == false)) {
UIDisplayMessage(PlayerGroupAll(), c_messageAreaDebug, StringToText((("Error: Behavior \"" + StringWord(EventChatMessage(false), 2)) + "\" does not exist.")));
return true;
}

auto8FFBEB1E_g = UnitGroupSelected(EventPlayer());
auto8FFBEB1E_u = UnitGroupCount(auto8FFBEB1E_g, c_unitCountAll);
for (;; auto8FFBEB1E_u -= 1) {
Expand Down Expand Up @@ -1140,14 +1144,24 @@ bool libUNIT_gt_RemoveBehavior_Func (bool testConds, bool runActions) {
UIDisplayMessage(PlayerGroupAll(), c_messageAreaDebug, StringToText("Usage: <rmb|removebehavior> <BehaviorName>"));
}
else {
if ((CatalogEntryIsValid(c_gameCatalogBehavior, (StringWord(EventChatMessage(false), 2))) == false)) {
UIDisplayMessage(PlayerGroupAll(), c_messageAreaDebug, StringToText((("Error: Behavior \"" + StringWord(EventChatMessage(false), 2)) + "\" does not exist.")));
return true;
}

autoA22B81BF_g = UnitGroupSelected(EventPlayer());
autoA22B81BF_u = UnitGroupCount(autoA22B81BF_g, c_unitCountAll);
for (;; autoA22B81BF_u -= 1) {
lv_currentUnit = UnitGroupUnitFromEnd(autoA22B81BF_g, autoA22B81BF_u);
if (lv_currentUnit == null) { break; }
lv_unittype = UnitGetType(lv_currentUnit);
UnitBehaviorRemove(lv_currentUnit, (StringWord(EventChatMessage(false), 2)), 1);
UIDisplayMessage(PlayerGroupAll(), c_messageAreaDebug, StringToText(("Removed Behavior \"" + (StringWord(EventChatMessage(false), 2) + ("\" from " + (lv_unittype))))));
if ((UnitHasBehavior(lv_currentUnit, (StringWord(EventChatMessage(false), 2))) == true)) {
UnitBehaviorRemove(lv_currentUnit, (StringWord(EventChatMessage(false), 2)), 1);
UIDisplayMessage(PlayerGroupAll(), c_messageAreaDebug, StringToText(("Removed Behavior \"" + (StringWord(EventChatMessage(false), 2) + ("\" from " + (lv_unittype))))));
}
else {
UIDisplayMessage(PlayerGroupAll(), c_messageAreaDebug, StringToText(("Warning: Unit " + ((lv_unittype) + (" does not behavior " + StringWord(EventChatMessage(false), 2))))));
}
}
}
return true;
Expand All @@ -1160,57 +1174,6 @@ void libUNIT_gt_RemoveBehavior_Init () {
TriggerAddEventChatMessage(libUNIT_gt_RemoveBehavior, c_playerAny, "removebehavior", false);
}

//--------------------------------------------------------------------------------------------------
// Trigger: Count Behavior
//--------------------------------------------------------------------------------------------------
bool libUNIT_gt_CountBehavior_Func (bool testConds, bool runActions) {
// Variable Declarations
int lv_behaviorCounter;
string lv_unittype;
unit lv_currentUnit;

// Automatic Variable Declarations
unitgroup auto08F3678D_g;
int auto08F3678D_u;

// Variable Initialization

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

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

if ((StringWord(EventChatMessage(false), 2) == null)) {
UIDisplayMessage(PlayerGroupAll(), c_messageAreaDebug, StringToText("Usage: <ctb|countbehavior> <BehaviorName>"));
}
else {
auto08F3678D_g = UnitGroupSelected(EventPlayer());
auto08F3678D_u = UnitGroupCount(auto08F3678D_g, c_unitCountAll);
for (;; auto08F3678D_u -= 1) {
lv_currentUnit = UnitGroupUnitFromEnd(auto08F3678D_g, auto08F3678D_u);
if (lv_currentUnit == null) { break; }
lv_behaviorCounter = UnitBehaviorCount(lv_currentUnit, (StringWord(EventChatMessage(false), 2)));
lv_unittype = UnitGetType(lv_currentUnit);
UIDisplayMessage(PlayerGroupAll(), c_messageAreaSubtitle, StringToText(((lv_unittype) + (": " + (StringWord(EventChatMessage(false), 2) + (" -> " + IntToString(lv_behaviorCounter)))))));
}
}
return true;
}

//--------------------------------------------------------------------------------------------------
void libUNIT_gt_CountBehavior_Init () {
libUNIT_gt_CountBehavior = TriggerCreate("libUNIT_gt_CountBehavior_Func");
TriggerAddEventChatMessage(libUNIT_gt_CountBehavior, c_playerAny, "ctb", false);
TriggerAddEventChatMessage(libUNIT_gt_CountBehavior, c_playerAny, "countbehavior", false);
}

//--------------------------------------------------------------------------------------------------
// Trigger: Get Behaviors
//--------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -2082,7 +2045,6 @@ void libUNIT_InitTriggers () {
libUNIT_gt_AddBehaviorPanelCloseButtonClicked_Init();
libUNIT_gt_AddBehavior_Init();
libUNIT_gt_RemoveBehavior_Init();
libUNIT_gt_CountBehavior_Init();
libUNIT_gt_GetBehaviors_Init();
libUNIT_gt_ClearBehaviors_Init();
libUNIT_gt_ModifyUnitProperty_Init();
Expand Down
Binary file modified (10)trymemode.stormmap/base.stormdata/Modules/Modules_Editor.SC2Mod
Binary file not shown.
27 changes: 0 additions & 27 deletions (10)trymemode.stormmap/base.stormdata/Modules/doc.json
Original file line number Diff line number Diff line change
Expand Up @@ -782,33 +782,6 @@
}
]
},
{
"shortCommand": "ctb",
"command": "countbehavior",
"description": [
"Count the number of a specific behavior from selected unit(s). Which are generally from `<CBehavior*>`, such as `<CBehaviorBuff id=\"xxx\">` or `<CBehaviorAbility id=\"xxx\">`.",
"> Tips: You can get active behaviors with the `getbehavior` command above."
],
"uiAvailable": false,
"parameters": [
{
"name": "BehaviorId",
"required": true,
"description": "Defines the behavior id to be counted from selected units",
"type": "string"
}
],
"examples": [
{
"command": "{command} MedivhArcaneBrillianceItem",
"description": "Count Medivh's Arcane Brilliance Ability from selected units"
},
{
"command": "{shortCommand} PermaInvulnerable",
"description": "Count selected unit's permanent Invulnerable behavior"
}
]
},
{
"shortCommand": "ade",
"command": "addeffect",
Expand Down
38 changes: 1 addition & 37 deletions 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 Sat, 23 Jan 2021 03:12:53 GMT)*</sup>
<sup>*(Generated from [doc.json](./(10)trymemode.stormmap/base.stormdata/Modules/doc.json) at Sat, 23 Jan 2021 03:49:13 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 @@ -78,8 +78,6 @@ Some of the commands have an UI counterpart implemented, which will display a me

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

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

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

- 💭 [Command: `getunitownership`](#cmd-getunitownership)
Expand Down Expand Up @@ -1014,40 +1012,6 @@ Remove all weapons (Basic Attack) from selected unit(s). Usually found in `<CWea



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

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

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

## (`countbehavior` | `ctb`) `<BehaviorId>`
<a name="cmd-countbehavior-description"></a>

#### ✏ Description:
Count the number of a specific behavior from selected unit(s). Which are generally from `<CBehavior*>`, such as `<CBehaviorBuff id="xxx">` or `<CBehaviorAbility id="xxx">`.
> Tips: You can get active behaviors with the `getbehavior` command above.
<a name="cmd-countbehavior-parameters"></a>

#### ⚙ Parameters:
<BehaviorId>
Required: true
Type: string
Usage: Defines the behavior id to be counted from selected units
<a name="cmd-countbehavior-examples"></a>

#### 🔧 Examples:
> countbehavior MedivhArcaneBrillianceItem
(Count Medivh's Arcane Brilliance Ability from selected units)
> ctb PermaInvulnerable
(Count selected unit's permanent Invulnerable behavior)
<a name="cmd-countbehavior-uiAvailability"></a>

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



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

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

0 comments on commit cf2cbc5

Please sign in to comment.