• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!

[General] Disabling default unit commands

Status
Not open for further replies.
Level 1
Joined
Jun 14, 2009
Messages
4
Hello! I'm looking to return to War3 mapmaking with Reforged, and I might have bitten off more than I can chew, but here goes!

EDIT: The goal of the map is to be a ~4 player coopertive RPG experience, with a single hero controlled per player. I can scope down to a singleplayer RPG if the solutions to my issues are that much easier to solve with a single player.

I would like to accomplish the following:

1. Disabling the basic unit command hotkeys.

The hero representing the player controlled via a WASD system. Said system is already implemented through an existing example, but I need to find out how to disable the A and S keys doing the respective default unit commands of 'Attack' and 'Stop'.

Removing the default unit commands is optional I think, as long as I can disable those specific keyboard keys doing what they do by default. Though I do suspect that a remapping or unbinding trick would not work, since a map can't enforce user-defined control rules? Please correct me if I'm wrong.

2. Turning off default unit behavior and adjusting mouse button commands.

The idea is to have the hero not attack by default, but 'swing' via left clicks, and defend and/or cast another ability with the right click.

I would greatly appreciate any pointers in the right direction, or even simply confirmation which of the ideas above can work, and which can't (if any)!
 
Last edited:
Level 23
Joined
Oct 12, 2008
Messages
1,783
How many players does your map have?
How many units does the player control?

A brute force way of doing this is to have 2 different units
- 1 is the actual unit the player controls (this unit has no movement/attack, it exists purely for UI)
- 2 is the unit that appears on screen and is not controlled by the player (which you force to move/attack whenever a key is pressed etc.)
 
Level 1
Joined
Jun 14, 2009
Messages
4
Ideally the map would be a ~4 cooperative action RPG experience with just a single Hero unit per player, though I can scope down to a singleplayer map if the requirements are that much easier to fulfill.
 
Level 10
Joined
Dec 11, 2009
Messages
234
A brute force way of doing this is to have 2 different units
- 1 is the actual unit the player controls (this unit has no movement/attack, it exists purely for UI)
- 2 is the unit that appears on screen and is not controlled by the player (which you force to move/attack whenever a key is pressed etc.)
This^ combined with:
JASS:
constant oskeytype OSKEY_W
constant oskeytype OSKEY_A
constant oskeytype OSKEY_S
constant oskeytype OSKEY_D
native BlzTriggerRegisterPlayerKeyEvent            takes trigger whichTrigger, player whichPlayer, oskeytype key, integer metaKey, boolean keyDown returns event
native BlzGetTriggerPlayerKey                      takes nothing returns oskeytype
native BlzGetTriggerPlayerMetaKey                  takes nothing returns integer
native BlzGetTriggerPlayerIsKeyDown                takes nothing returns boolean

// Mouse:
constant playerevent        EVENT_PLAYER_MOUSE_DOWN
constant playerevent        EVENT_PLAYER_MOUSE_UP
constant playerevent        EVENT_PLAYER_MOUSE_MOVE
native BlzGetTriggerPlayerMouseX                   takes nothing returns real
native BlzGetTriggerPlayerMouseY                   takes nothing returns real
// native BlzGetTriggerPlayerMousePosition            takes nothing returns location
native BlzGetTriggerPlayerMouseButton              takes nothing returns mousebuttontype
constant mousebuttontype    MOUSE_BUTTON_TYPE_LEFT
constant mousebuttontype    MOUSE_BUTTON_TYPE_MIDDLE
constant mousebuttontype    MOUSE_BUTTON_TYPE_RIGHT
A lot of work, but it's doable.
 
Status
Not open for further replies.
Top