diff --git a/code/display.cpp b/code/display.cpp index 373ac538..f020cd4c 100644 --- a/code/display.cpp +++ b/code/display.cpp @@ -2427,9 +2427,11 @@ void DisplayClass::Mouse_Left_Release(Coord const & coord, Cell const & cell, Ob } } - SuperWeaponTypeClass *stype = SuperWeaponTypeClass::From_Action(action); - if (stype != NULL) { - OutList.push_back(EventClass(PlayerPtr->HeapID, EventClass::SPECIAL_PLACE, stype->HeapID, cell)); + if (IsTargettingMode != SUPER_NONE) { + SuperWeaponTypeClass *stype = SuperWeaponTypes[IsTargettingMode]; + if (stype != NULL && stype->Action == action) { + OutList.push_back(EventClass(PlayerPtr->HeapID, EventClass::SPECIAL_PLACE, stype->HeapID, cell)); + } } } diff --git a/manual/changes/fix-sw-shadowing.md b/manual/changes/fix-sw-shadowing.md new file mode 100644 index 00000000..aba700a3 --- /dev/null +++ b/manual/changes/fix-sw-shadowing.md @@ -0,0 +1,16 @@ +--- +title: Keep superweapons that share an Action from replacing each other +category: fix +release: 0.2.0 +targets: +- type: system + id: superweapons + effect: changed +credit: [Templarfreak] +--- + +Placing a superweapon on the map now fires the one that was actually armed, even when +another superweapon defines the same Action. Clicking a target cell previously resolved +back to whichever superweapon type first matched that Action, so two superweapons sharing +one Action value could not be fired independently: placing either one always discharged +the same type and left the other's charge untouched. diff --git a/manual/content/enums/cursor-action.md b/manual/content/enums/cursor-action.md index 9be5e4ca..567cbf8a 100644 --- a/manual/content/enums/cursor-action.md +++ b/manual/content/enums/cursor-action.md @@ -66,6 +66,6 @@ values: These are the actions the engine picks between as the cursor crosses the map — what the mouse shape offers and what a left click will then do. They are not the trigger actions a map fires from its tags, which are a separate list. -One rules setting takes a name from here: a SuperWeaponType's [`Action`](/keys/action/). While the map is in that weapon's targeting mode the name becomes the action under the cursor, which is what picks the mouse shape, and it is also the key the click is matched on afterward: a click whose action is neither `None` nor `Select` is compared against every superweapon's `Action` in turn, and the first weapon carrying that action has a firing order queued for the cell. Two weapons naming the same action therefore leave the later one unreachable, and a weapon left at `None` neither takes the cursor nor can be fired by a click at all — which is where an unrecognized name lands it, since the parser reads anything it does not know as `None`. +One rules setting takes a name from here: a SuperWeaponType's [`Action`](/keys/action/). While the map is in that weapon's targeting mode the name becomes the action under the cursor, which is what picks the mouse shape. A weapon left at `None` neither takes the cursor nor can be fired by a click at all — which is where an unrecognized name lands it, since the parser reads anything it does not know as `None`. Seven entries carry historical `DontUse` tokens even though their engine constants still name older actions. Nothing assigns or tests those seven, so what survives of them is the spelling: they are distinct names a superweapon can claim, and nothing more. diff --git a/manual/content/keys/action--superweapontype.md b/manual/content/keys/action--superweapontype.md index 21fc9c1a..22fbc96c 100644 --- a/manual/content/keys/action--superweapontype.md +++ b/manual/content/keys/action--superweapontype.md @@ -15,7 +15,3 @@ The values that carry a superweapon cursor are `Nuke`, `IonCannon`, `DropPod`, ` :::caution[An unrecognized value reads as `None`] A misspelling is not rejected. It resolves to `None`, and the weapon then fires from the cameo click at cell 0,0 with no targeting step and no choice of where the effect lands. ::: - -:::caution[The map click finds the weapon by this value alone] -Every left click that resolves to an action searches the declared superweapons for the first one carrying that `Action=`, whether or not targeting mode was armed. Two sections sharing a value therefore always fire the earlier of the two, and a value that ordinary orders also produce — an attack, a move — discharges a charged weapon on the next such order. -::: diff --git a/manual/content/systems/superweapons.md b/manual/content/systems/superweapons.md index 641d9ffd..93528122 100644 --- a/manual/content/systems/superweapons.md +++ b/manual/content/systems/superweapons.md @@ -195,8 +195,6 @@ Clicking a cameo that can be fired takes one of two paths, decided by [`Action=` While targeting mode is armed, the cursor over the map reports the weapon's `Action=` in place of the ordinary one, and releasing the left button fires the weapon at the cell under the pointer. A right click on the cameo or on the map cancels targeting, and band selection is suppressed while it is armed. The minimap does not accept superweapon actions, so a shot cannot be aimed there. -Every left click that resolves to an action searches the declared list for the first section whose `Action=` matches, whether or not targeting mode was armed and without asking which weapon armed it. Two sections sharing one `Action=` therefore always fire the earlier of the two, and an `Action=` that ordinary orders also produce discharges a charged weapon on the next such order. - :::caution[A misspelled `Action=` becomes `None`] An `Action=` value the engine does not recognize is not rejected; it reads as `None`. The weapon then takes the immediate-fire path: clicking the charged cameo discharges it on the spot at cell 0,0, with no targeting step and no opportunity to choose where the effect lands. :::