Skip to content

Commit

Permalink
Added Get/Clear Weapons command
Browse files Browse the repository at this point in the history
  • Loading branch information
jamiephan committed Jan 23, 2021
1 parent 0667e92 commit ca04950
Show file tree
Hide file tree
Showing 4 changed files with 202 additions and 5 deletions.
99 changes: 99 additions & 0 deletions (10)trymemode.stormmap/base.stormdata/Modules/LibUnits.galaxy
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ trigger libUNIT_gt_AddEffectstoCamera;
trigger libUNIT_gt_RemoveEffectsfromCamera;
trigger libUNIT_gt_AddEffects;
trigger libUNIT_gt_RemoveEffect;
trigger libUNIT_gt_GetWeapons;
trigger libUNIT_gt_ClearWeapons;
trigger libUNIT_gt_AddWeapon;
trigger libUNIT_gt_RemoveWeapon;
trigger libUNIT_gt_ToggleNoWeaponCD;
Expand Down Expand Up @@ -330,6 +332,101 @@ void libUNIT_gt_RemoveEffect_Init () {
TriggerAddEventChatMessage(libUNIT_gt_RemoveEffect, c_playerAny, "removeeffect", false);
}

//--------------------------------------------------------------------------------------------------
// Trigger: Get Weapons
//--------------------------------------------------------------------------------------------------
bool libUNIT_gt_GetWeapons_Func (bool testConds, bool runActions) {
// Variable Declarations
int lv_i;
string lv_weapon;
string lv_unittype;
unit lv_currentUnit;

// Automatic Variable Declarations
unitgroup autoEB77DABE_g;
int autoEB77DABE_u;
int auto36ED1F5F_ae;
const int auto36ED1F5F_ai = 1;

// Variable Initialization
lv_i = 1;

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

autoEB77DABE_g = UnitGroupSelected(EventPlayer());
autoEB77DABE_u = UnitGroupCount(autoEB77DABE_g, c_unitCountAll);
for (;; autoEB77DABE_u -= 1) {
lv_currentUnit = UnitGroupUnitFromEnd(autoEB77DABE_g, autoEB77DABE_u);
if (lv_currentUnit == null) { break; }
lv_unittype = UnitGetType(lv_currentUnit);
auto36ED1F5F_ae = UnitWeaponCount(lv_currentUnit);
lv_i = 1;
for ( ; ( (auto36ED1F5F_ai >= 0 && lv_i <= auto36ED1F5F_ae) || (auto36ED1F5F_ai < 0 && lv_i >= auto36ED1F5F_ae) ) ; lv_i += auto36ED1F5F_ai ) {
lv_weapon = UnitWeaponGet(lv_currentUnit, lv_i);
UIDisplayMessage(PlayerGroupAll(), c_messageAreaSubtitle, StringToText((((lv_unittype) + "'s Weapon ") + (IntToString(lv_i) + (": " + (lv_weapon))))));
}
}
return true;
}

//--------------------------------------------------------------------------------------------------
void libUNIT_gt_GetWeapons_Init () {
libUNIT_gt_GetWeapons = TriggerCreate("libUNIT_gt_GetWeapons_Func");
TriggerAddEventChatMessage(libUNIT_gt_GetWeapons, c_playerAny, "getw", true);
TriggerAddEventChatMessage(libUNIT_gt_GetWeapons, c_playerAny, "getweapon", true);
}

//--------------------------------------------------------------------------------------------------
// Trigger: Clear Weapons
//--------------------------------------------------------------------------------------------------
bool libUNIT_gt_ClearWeapons_Func (bool testConds, bool runActions) {
// Variable Declarations
int lv_i;
string lv_weapon;
string lv_unittype;
unit lv_currentUnit;

// Automatic Variable Declarations
unitgroup auto0C1D2C19_g;
int auto0C1D2C19_u;
int autoC501F182_ae;
const int autoC501F182_ai = 1;

// Variable Initialization
lv_i = 1;

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

auto0C1D2C19_g = UnitGroupSelected(EventPlayer());
auto0C1D2C19_u = UnitGroupCount(auto0C1D2C19_g, c_unitCountAll);
for (;; auto0C1D2C19_u -= 1) {
lv_currentUnit = UnitGroupUnitFromEnd(auto0C1D2C19_g, auto0C1D2C19_u);
if (lv_currentUnit == null) { break; }
lv_unittype = UnitGetType(lv_currentUnit);
autoC501F182_ae = UnitWeaponCount(lv_currentUnit);
lv_i = 1;
for ( ; ( (autoC501F182_ai >= 0 && lv_i <= autoC501F182_ae) || (autoC501F182_ai < 0 && lv_i >= autoC501F182_ae) ) ; lv_i += autoC501F182_ai ) {
lv_weapon = UnitWeaponGet(lv_currentUnit, lv_i);
UnitWeaponRemove(lv_currentUnit, lv_weapon);
UIDisplayMessage(PlayerGroupAll(), c_messageAreaDebug, StringToText((("Removed Weapon \"" + (lv_weapon)) + ("\" From " + (lv_unittype)))));
}
}
return true;
}

//--------------------------------------------------------------------------------------------------
void libUNIT_gt_ClearWeapons_Init () {
libUNIT_gt_ClearWeapons = TriggerCreate("libUNIT_gt_ClearWeapons_Func");
TriggerAddEventChatMessage(libUNIT_gt_ClearWeapons, c_playerAny, "clw", true);
TriggerAddEventChatMessage(libUNIT_gt_ClearWeapons, c_playerAny, "clearweapon", true);
}

//--------------------------------------------------------------------------------------------------
// Trigger: Add Weapon
//--------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -1967,6 +2064,8 @@ void libUNIT_InitTriggers () {
libUNIT_gt_RemoveEffectsfromCamera_Init();
libUNIT_gt_AddEffects_Init();
libUNIT_gt_RemoveEffect_Init();
libUNIT_gt_GetWeapons_Init();
libUNIT_gt_ClearWeapons_Init();
libUNIT_gt_AddWeapon_Init();
libUNIT_gt_RemoveWeapon_Init();
libUNIT_gt_ToggleNoWeaponCD_Init();
Expand Down
Binary file not shown.
38 changes: 36 additions & 2 deletions (10)trymemode.stormmap/base.stormdata/Modules/doc.json
Original file line number Diff line number Diff line change
Expand Up @@ -1050,7 +1050,7 @@
{
"shortCommand": "adw",
"command": "addweapon",
"description": "Add a weapon to selected unit(s). Usually found in `<CWeapon* id='xxx'>`",
"description": "Add a weapon (Basic Attack) to selected unit(s). Usually found in `<CWeapon* id='xxx'>`",
"uiAvailable": false,
"parameters": [
{
Expand All @@ -1074,7 +1074,7 @@
{
"shortCommand": "rmw",
"command": "removeweapon",
"description": "Remove a weapon from selected unit(s). Usually found in `<CWeapon* id='xxx'>`",
"description": "Remove a weapon (Basic Attack) from selected unit(s). Usually found in `<CWeapon* id='xxx'>`",
"uiAvailable": false,
"parameters": [
{
Expand All @@ -1094,6 +1094,40 @@
"description": "Remove D.va mech mode's weapon from selected unit(s)"
}
]
},
{
"shortCommand": "getw",
"command": "getweapon",
"description": "Get all weapons (Basic Attack) from selected unit(s). Usually found in `<CWeapon* id='xxx'>`",
"uiAvailable": false,
"parameters": [],
"examples": [
{
"command": "{shortCommand}",
"description": "Get all weapons from selected units"
},
{
"command": "{command}",
"description": "Get all weapons from selected units"
}
]
},
{
"shortCommand": "clw",
"command": "clearweapon",
"description": "Remove all weapons (Basic Attack) from selected unit(s). Usually found in `<CWeapon* id='xxx'>`",
"uiAvailable": false,
"parameters": [],
"examples": [
{
"command": "{shortCommand}",
"description": "Remove all weapons from selected units"
},
{
"command": "{command}",
"description": "Remove all weapons from selected units"
}
]
}
]
},
Expand Down
70 changes: 67 additions & 3 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 Mon, 11 Jan 2021 22:39:02 GMT)*</sup>
<sup>*(Generated from [doc.json](./(10)trymemode.stormmap/base.stormdata/Modules/doc.json) at Sat, 23 Jan 2021 03:12:53 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 @@ -76,12 +76,16 @@ Some of the commands have an UI counterpart implemented, which will display a me

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

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

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

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

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

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

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

- 💭 [Command: `playanimation`](#cmd-playanimation)
Expand Down Expand Up @@ -855,7 +859,7 @@ Add an Effect to the center of the camera. Which are generally from `<CEffect*>`
<a name="cmd-addweapon-description"></a>

#### ✏ Description:
Add a weapon to selected unit(s). Usually found in `<CWeapon* id='xxx'>`
Add a weapon (Basic Attack) to selected unit(s). Usually found in `<CWeapon* id='xxx'>`

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

Expand Down Expand Up @@ -980,6 +984,36 @@ Clear all summoned unit(s) (summoned by the [summon](#cmd-summon) command) for a



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

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

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

## (`clearweapon` | `clw`)
<a name="cmd-clearweapon-description"></a>

#### ✏ Description:
Remove all weapons (Basic Attack) from selected unit(s). Usually found in `<CWeapon* id='xxx'>`

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

#### ⚙ Parameters:
None
<a name="cmd-clearweapon-examples"></a>

#### 🔧 Examples:
> clw
(Remove all weapons from selected units)
> clearweapon
(Remove all weapons from selected units)
<a name="cmd-clearweapon-uiAvailability"></a>

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



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

[\[Return to Top ⬆\]](#meta-top)
Expand Down Expand Up @@ -1074,6 +1108,36 @@ Gets the Ownership (Player ID) of selected unit(s).



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

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

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

## (`getweapon` | `getw`)
<a name="cmd-getweapon-description"></a>

#### ✏ Description:
Get all weapons (Basic Attack) from selected unit(s). Usually found in `<CWeapon* id='xxx'>`

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

#### ⚙ Parameters:
None
<a name="cmd-getweapon-examples"></a>

#### 🔧 Examples:
> getw
(Get all weapons from selected units)
> getweapon
(Get all weapons from selected units)
<a name="cmd-getweapon-uiAvailability"></a>

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



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

[\[Return to Top ⬆\]](#meta-top)
Expand Down Expand Up @@ -1282,7 +1346,7 @@ Remove an Effect from the center of the camera. Which are generally from `<CEffe
<a name="cmd-removeweapon-description"></a>

#### ✏ Description:
Remove a weapon from selected unit(s). Usually found in `<CWeapon* id='xxx'>`
Remove a weapon (Basic Attack) from selected unit(s). Usually found in `<CWeapon* id='xxx'>`

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

Expand Down

0 comments on commit ca04950

Please sign in to comment.