Importing blizzard.j and commons.j and other to get keyboard events!

lbebusiness

New Member
Reaction score
3
Okay I've deleted my old post and updated it here to reflect new information I have read about. Same post as the one on the bottom.
P.S. I would have kept the original post here and put it in a spoiler at the bottom but spoilers don't seem to work here....anyways heres the new info enjoy:


WESTRING_UEVAL_UHOT=Hotkey
eval hotkey?

ESC
Hotkey=512


// Trigger Non-Variable Types - Utility, only used to simplify triggers
keyeventtype=1,0,0,WESTRING_TRIGTYPE_keyeventtype,integer
keyeventkey=1,0,0,WESTRING_TRIGTYPE_keyeventkey,integer

Keep that in mind
Check this out:
Im going to create a valid trigger that will throw no errors but wont run due to missing an event:
Key in example will be the page up key:

Key is defined here:
(there are alot more here)
worldeditstrings.txt
JASS:
WESTRING_HOTKEY_UP="Up"
WESTRING_HOTKEY_DOWN="Down"
WESTRING_HOTKEY_LEFT="Left"
WESTRING_HOTKEY_RIGHT="Right"

/////////////////////////

WESTRING_HOTKEY_PAGEUP="Pg Up"

/////////////////////////


Add key to list of usable keyevents in GUI
triggerdata.txt
JASS:
// Keyboard Event Keys
KeyEventKeyLeft=1,keyeventkey,bj_KEYEVENTKEY_LEFT,WESTRING_KEYEVENTKEY_LEFT
KeyEventKeyRight=1,keyeventkey,bj_KEYEVENTKEY_RIGHT,WESTRING_KEYEVENTKEY_RIGHT
KeyEventKeyDown=1,keyeventkey,bj_KEYEVENTKEY_DOWN,WESTRING_KEYEVENTKEY_DOWN
KeyEventKeyUp=1,keyeventkey,bj_KEYEVENTKEY_UP,WESTRING_KEYEVENTKEY_UP

/////////////////////////

KeyEventKeyPageUp=1,keyeventkey,bj_KEYEVENTKEY_PAGE_UP,WESTRING_KEYEVENTKEY_PAGE_UP

/////////////////////////


Add string name to key for use in GUI editor:

worldeditstrings.txt
JASS:
// Trigger keyboard events
WESTRING_KEYEVENTKEY_LEFT="Left Arrow"
WESTRING_KEYEVENTKEY_RIGHT="Right Arrow"
WESTRING_KEYEVENTKEY_DOWN="Down Arrow"
WESTRING_KEYEVENTKEY_UP="Up Arrow"

/////////////////////////

WESTRING_KEYEVENTKEY_PAGE_UP="Page Up"

/////////////////////////


Declare my key event constant here:

Blizzard.j
JASS:
    // Keyboard Event Types
    constant integer   bj_KEYEVENTTYPE_DEPRESS     = 0
    constant integer   bj_KEYEVENTTYPE_RELEASE     = 1

    // Keyboard Event Keys
    constant integer   bj_KEYEVENTKEY_LEFT         = 0
    constant integer   bj_KEYEVENTKEY_RIGHT        = 1
    constant integer   bj_KEYEVENTKEY_DOWN         = 2
    constant integer   bj_KEYEVENTKEY_UP           = 3

/////////////////////////

    constant integer   bj_KEYEVENTKEY_PAGE_UP      = 4

/////////////////////////


Modify Funtions to recognise Key and return Event
Blizzard.j
JASS:
function TriggerRegisterPlayerKeyEventBJ takes trigger trig, player whichPlayer, integer keType, integer keKey returns event
    if (keType == bj_KEYEVENTTYPE_DEPRESS) then
        // Depress event - find out what key
        if (keKey == bj_KEYEVENTKEY_LEFT) then
            return TriggerRegisterPlayerEvent(trig, whichPlayer, EVENT_PLAYER_ARROW_LEFT_DOWN)
        elseif (keKey == bj_KEYEVENTKEY_RIGHT) then
            return TriggerRegisterPlayerEvent(trig, whichPlayer, EVENT_PLAYER_ARROW_RIGHT_DOWN)
        elseif (keKey == bj_KEYEVENTKEY_DOWN) then
            return TriggerRegisterPlayerEvent(trig, whichPlayer, EVENT_PLAYER_ARROW_DOWN_DOWN)
        elseif (keKey == bj_KEYEVENTKEY_UP) then
            return TriggerRegisterPlayerEvent(trig, whichPlayer, EVENT_PLAYER_ARROW_UP_DOWN)

////////////////////////

        elseif (keKey == bj_KEYEVENTKEY_PAGE_UP) then
            return TriggerRegisterPlayerEvent(trig, whichPlayer, EVENT_PLAYER_PAGE_UP_DOWN)
        
////////////////////////

         else
            // Unrecognized key - ignore the request and return failure.
            return null
        endif
    elseif (keType == bj_KEYEVENTTYPE_RELEASE) then
        // Release event - find out what key
        if (keKey == bj_KEYEVENTKEY_LEFT) then
            return TriggerRegisterPlayerEvent(trig, whichPlayer, EVENT_PLAYER_ARROW_LEFT_UP)
        elseif (keKey == bj_KEYEVENTKEY_RIGHT) then
            return TriggerRegisterPlayerEvent(trig, whichPlayer, EVENT_PLAYER_ARROW_RIGHT_UP)
        elseif (keKey == bj_KEYEVENTKEY_DOWN) then
            return TriggerRegisterPlayerEvent(trig, whichPlayer, EVENT_PLAYER_ARROW_DOWN_UP)
        elseif (keKey == bj_KEYEVENTKEY_UP) then
            return TriggerRegisterPlayerEvent(trig, whichPlayer, EVENT_PLAYER_ARROW_UP_UP)

/////////////////////////

        elseif (keKey == bj_KEYEVENTKEY_PAGE_UP) then
            return TriggerRegisterPlayerEvent(trig, whichPlayer, EVENT_PLAYER_PAGE_UP_UP)               

////////////////////////

        else
            // Unrecognized key - ignore the request and return failure.
            return null
        endif
    else
        // Unrecognized type - ignore the request and return failure.
        return null
    endif
endfunction


Add Key event's eventid here: (need event id though)

Common.j
JASS:
    //===================================================
    // For use with TriggerRegisterPlayerEvent
    //===================================================

    constant playerevent        EVENT_PLAYER_ARROW_LEFT_DOWN            = ConvertPlayerEvent(261)
    constant playerevent        EVENT_PLAYER_ARROW_LEFT_UP              = ConvertPlayerEvent(262)
    constant playerevent        EVENT_PLAYER_ARROW_RIGHT_DOWN           = ConvertPlayerEvent(263)
    constant playerevent        EVENT_PLAYER_ARROW_RIGHT_UP             = ConvertPlayerEvent(264)
    constant playerevent        EVENT_PLAYER_ARROW_DOWN_DOWN            = ConvertPlayerEvent(265)
    constant playerevent        EVENT_PLAYER_ARROW_DOWN_UP              = ConvertPlayerEvent(266)
    constant playerevent        EVENT_PLAYER_ARROW_UP_DOWN              = ConvertPlayerEvent(267)
    constant playerevent        EVENT_PLAYER_ARROW_UP_UP                = ConvertPlayerEvent(268)

/////////////////////////

    constant playerevent        EVENT_PLAYER_PAGE_UP_UP                 = ConvertPlayerEvent(260)
    constant playerevent        EVENT_PLAYER_PAGE_UP_DOWN             = ConvertPlayerEvent(260)

/////////////////////////


Whats left? Someone has to open the .dll up (storm I belive) and make a list of every event.

Storm.dll is like a book that blizzard ADD's funtions to (or events).
You could take warcraft III Storm.dll and run starcraft with it. But not vise vesa.

So every update adds something new and doesn't take anything out of it.

Following this practice, Blizzard uses a shared library called Storm (Storm.dll on PCs, Storm.bin on Macs). This library is used by all modern Blizzard games to store important functions like MPQ reading (discussed in chapter 3), Battle.net, and even some graphics routines. When Blizzard releases a new game, it adds functions to Storm without changing old functions. This means that an old game can use a new version of Storm just fine. But, like all shared libraries, Storm makes its functions available to any program that wants to use them, which is not very good for security. It is for this reason that Storm only contains MPQ reading functions. The MPQ writing functions are Blizzard's prized possessions, and they're not going to let just anyone use them.

I have no clue how to take apart a dll. But I do know its hell (blizzard made it hard to use Storm.dll) but I do have a Storm API which is documented here
http://www.campaigncreations.org/starcraft/inside_mopaq/chapter4.htm#using_the_storm_api

It talks about how to initialize it etc.

You can also download it.
Read me:
/*****************************************************************************/
/* StormIL.zip Copyright Justin Olbrantz(Quantam) 2000 */
/* */
/* Storm Interface Library v1.0 for Windows */
/* */
/* Author : Justin Olbrantz(Quantam) */
/* E-mail : [email protected] */
/* WWW : www.campaigncreations.com/starcraft/mpq2k/inside_mopaq/ */
/*---------------------------------------------------------------------------*/
/* Companion pack for Inside MoPaQ chapter 3 */
/*****************************************************************************/

This package contains the following files:

STORM.H Function prototypes for Storm.dll
STORM.LIB Import library for accessing Storm.dll. This is not a static
library! You still need Storm.dll
STORM.EXP Export file used in some rare scenarios

You may freely distribute this package as long as all of it (including this
file) remain intact and unchanged.

Have fun if you know what I'm talking about.
Thanks for listening.
:banghead::banghead::banghead::banghead::banghead::banghead:
 

Builder Bob

Live free or don't
Reaction score
249
This sounds interesting, but I am unable to read the code properly when it's centered like that. I hope you don't mind me putting it all in Jass tags so I can read it properly.

I'll comment later if I can help on anything.

JASS:
when ANY key is press it is sent to (Register)PlayerKeyEventBJ
when (??ANY (spacebar only?)) key is press it is sent to (move to (x) locatioin)
when (??ANY (ESC only?)) key is press it is sent to (end cinematic)
Key events can be used to trigger anything.

Need to find the part when "ANY" key is pressed it sends it to the above funtions.
Should be a value for every key on the keyboard.
Find values OR create them however they are created in the begining.

VK_NUMPAD2
GetLocalizedHotkey

native DialogAddButton takes dialog whichDialog, string buttonText, integer hotkey returns button

native ForceUIKey takes string key returns nothing
native ForceUICancel takes nothing returns nothing

function StoreRealBJ takes real value, string key, string missionKey, gamecache cache returns nothing
	call StoreReal(cache, missionKey, key, value)
endfunction

function StoreIntegerBJ takes integer value, string key, string missionKey, gamecache cache returns nothing
	call StoreInteger(cache, missionKey, key, value)
endfunction





// THIS WILL REQUIRE CREATING EVENTS FOR EVERY POSSIBLE USED KEY!!!
// THIS WILL REQUIRE FINDING OUT EVERY KEY NUMBER!!!
// IF NONE EXIST CREATE THEM AND STORE THEM!!!
// (THERE HAS TO BE A FEW NOTE THIS PART OF CODE:
// Unrecognized key - ignore the request and return failure.

//define keywords
//ESC = PlayerEventEndCinematic

//Left = PlayerKeyEventBJ PlayerKeyEventBJ
//bj_KEYEVENTTYPE_DEPRESS, bj_KEYEVENTKEY_LEFT

//Right = PlayerKeyEventBJ PlayerKeyEventBJ
//bj_KEYEVENTTYPE_DEPRESS, bj_KEYEVENTKEY_RIGHT

//Up = PlayerKeyEventBJ PlayerKeyEventBJ
//bj_KEYEVENTTYPE_DEPRESS, bj_KEYEVENTKEY_UP

//own = PlayerKeyEventBJ PlayerKeyEventBJ
//bj_KEYEVENTTYPE_DEPRESS, bj_KEYEVENTKEY_DOWN


//!!!!SIMPLY HOW ARE THEY DEFINED?!?!?!?!


// IF THERE IS ONLY ARROW KEYS THEN WTF IS THAT FOR? HUH! THATS WHAT I THOUGHT!
library proofofconcept

function TriggerRegisterPlayerKeyEventBJ takes trigger trig, player whichPlayer, integer keType, integer keKey returns event
	if (keType == bj_KEYEVENTTYPE_DEPRESS) then
		//(REALLY)IF keType = 0 BECAUSE bj_KEYEVENTTYPE_RELEASE = 0 READ TRIGGER COMMENTS
		// Depress event - find out what key
		if (keKey == bj_KEYEVENTKEY_LEFT) then
			//(REALLY)IF keKey = 0 BECAUSE bj_KEYEVENTKEY_LEFT = 0 READ TRIGGER COMMENTS
			return TriggerRegisterPlayerEvent(trig, whichPlayer, EVENT_PLAYER_ARROW_LEFT_DOWN)
			// create my own events?
		elseif (keKey == bj_KEYEVENTKEY_RIGHT) then
			//(REALLY)IF keKey = 1 BECAUSE bj_KEYEVENTKEY_RIGHT = 1 READ TRIGGER COMMENTS
			return TriggerRegisterPlayerEvent(trig, whichPlayer, EVENT_PLAYER_ARROW_RIGHT_DOWN)
			// create my own events?
		elseif (keKey == bj_KEYEVENTKEY_DOWN) then
			//(REALLY)IF keKey = 2 BECAUSE bj_KEYEVENTKEY_DOWN = 2 READ TRIGGER COMMENTS
			return TriggerRegisterPlayerEvent(trig, whichPlayer, EVENT_PLAYER_ARROW_DOWN_DOWN)
			// create my own events?
		elseif (keKey == bj_KEYEVENTKEY_UP) then
			//(REALLY)IF keKey = 3 BECAUSE bj_KEYEVENTKEY_UP = 3 READ TRIGGER COMMENTS
			return TriggerRegisterPlayerEvent(trig, whichPlayer, EVENT_PLAYER_ARROW_UP_DOWN)
			// create my own events?
		else
			// Unrecognized key - ignore the request and return failure.
			// lets make this into a display key trigger to find key values!
			return null
		endif
	elseif (keType == bj_KEYEVENTTYPE_RELEASE) then
		//(REALLY)IF keType = 1 BECAUSE bj_KEYEVENTTYPE_RELEASE = 1 READ TRIGGER COMMENTS
		// Release event - find out what key
		if (keKey == bj_KEYEVENTKEY_LEFT) then
			//(REALLY)IF keKey = 0 BECAUSE bj_KEYEVENTKEY_LEFT = 0 READ TRIGGER COMMENTS
			return TriggerRegisterPlayerEvent(trig, whichPlayer, EVENT_PLAYER_ARROW_LEFT_UP)
			// create my own events?
		elseif (keKey == bj_KEYEVENTKEY_RIGHT) then
			//(REALLY)IF keKey = 1 BECAUSE bj_KEYEVENTKEY_RIGHT = 1 READ TRIGGER COMMENTS
			return TriggerRegisterPlayerEvent(trig, whichPlayer, EVENT_PLAYER_ARROW_RIGHT_UP)
			// create my own events?
		elseif (keKey == bj_KEYEVENTKEY_DOWN) then
			//(REALLY)IF keKey = 2 BECAUSE bj_KEYEVENTKEY_DOWN = 2 READ TRIGGER COMMENTS
			return TriggerRegisterPlayerEvent(trig, whichPlayer, EVENT_PLAYER_ARROW_DOWN_UP)
			// create my own events?
		elseif (keKey == bj_KEYEVENTKEY_UP) then
			//(REALLY)IF keKey = 3 BECAUSE bj_KEYEVENTKEY_UP = 3 READ TRIGGER COMMENTS
			return TriggerRegisterPlayerEvent(trig, whichPlayer, EVENT_PLAYER_ARROW_UP_UP)
			// create my own events?
		else
			// Unrecognized key - ignore the request and return failure.
			// lets make this into a display key trigger to find key values!
			return null
		endif
	else
		// Unrecognized type - ignore the request and return failure.
		// lets make this into a display key trigger to find key TYPES (ERR NOT REALLY?)!
		return null
	endif
endfunction

endlibrary


JASS:
// (THERE HAS TO BE A FEW keys NOTE THIS PART OF CODE:
// Unrecognized key - ignore the request and return failure.
// IF THERE IS ONLY ARROW KEYS THEN WTF IS THAT FOR? HUH! THATS WHAT I THOUGHT!
library proofofconcept1


function letsstarthackingkeys1 takes trigger trig, player whichPlayer, integer keType, integer keKey returns nothing
	set udg_keType = keType
	set udg_keKey = keKey

endfunction

endlibrary


function Trig_proof_of_concept_MODIFIYED_TO_RETURN_KEY_VAULE_INSTEAD_OF_EVENTS_ Actions takes nothing returns nothing
	call letsstarthackingkeys1( gg_trg_proof_of_concept_MODIFIYED_TO_RETURN_KEY_VAULE_INSTEAD_OF_EVENT S, Player(0), bj_KEYEVENTTYPE_DEPRESS, bj_KEYEVENTKEY_LEFT )
	call DisplayTextToForce( GetPlayersAll(), I2S(udg_keType) )
	call DisplayTextToForce( GetPlayersAll(), I2S(udg_keKey ) )

endfunction

//====================================================================== =====
function InitTrig_proof_of_concept_MODIFIYED_TO_RETURN_KEY_VAULE_INSTEAD_OF_EVE NTS takes nothing returns nothing
	set gg_trg_proof_of_concept_MODIFIYED_TO_RETURN_KEY_VAULE_INSTEAD_OF_EVENT S = CreateTrigger( )
	call TriggerRegisterTimerEventSingle( gg_trg_proof_of_concept_MODIFIYED_TO_RETURN_KEY_VAULE_INSTEAD_OF_EVENT S, 0.03 )
	call TriggerAddAction( gg_trg_proof_of_concept_MODIFIYED_TO_RETURN_KEY_VAULE_INSTEAD_OF_EVENT S, function Trig_proof_of_concept_MODIFIYED_TO_RETURN_KEY_VAULE_INSTEAD_OF_EVENTS_ Actions )
endfunction


I want to see the part of the program that assings the name :
bj_KEYEVENTKEY_LEFT RIGHT UP DOWN ect (spacebar, esc key)
to the actual key? where does warcraft do it?

bj_KEYEVENTKEY_LEFT RIGHT is just an integer yes, but it is most likely never used internally within warcraft 3. It's only a constant used by the GUI triggers.

The more interesting constants are the event constants like:
EVENT_PLAYER_ARROW_RIGHT_DOWN = ConvertPlayerEvent(263)
ConvertPlayerEvent() is a native which takes an integer and looks up the corresponding playerevent.

All playerevents are hard coded as far as I know. I don't think you can create a new playerevent unless you modify the war3 engine itself, something which won't be usable on B.net unless all other players have a modified engine as well. If you can do this by modifying blizzard.j or common.j that'd be great though.

Sorry, I don't know enough to help you.
 

SFilip

Gone but not forgotten
Reaction score
634
> and looks up the corresponding playerevent
It actually only returns the integer you supply. Typesafety thing (think: reverse of H2I).

I'm afraid what you want can't be done by simply editing common.j. Some custom native events can be made, but as Builder Bob said, it would mean everybody who wants to play your map has to run a special program in order to do so.
 

lbebusiness

New Member
Reaction score
3
// Unrecognized key - ignore the request and return failure.
Blizzard wouldn't bother making such a redundant piece of code if you couldn't call any other key not listed anyway...would they? :eek:

Seriously I think that is there for a reason. After all the updates patches its still there in the patched versions.

So no possible way to create this "program" import it into the map. Give it a path. then call it with jass? (saw something about "Program filenamehere" jass command kinda thing) If we could then no desync because everyone dl's the same map same program. Kinda like distribution...

Uhm... so when you press a key what detects that? after detection it sends it as a arrow key, esc key, space bar key, or spells (hotkeys)

Note... I wonder what sorts of nasty things you can do by replacing the blizzard.j and common.j and editing it... possibilities are endless. customized function. Or you could add to a function. (like using a system that use a bunch of functions together that you put together yourself, you could just add it to the file and just import it into all your maps. No triggers, library's to import)
OR
write ENTIRE library's that get sent out with your map and you could just call on them. :p
Could add all kinds of things that get updated at a central server (like here) just like vjass/pjass.... and you dont have to worry about being out of date because everyone will be using the same blizzard.j common.j files in the same map...

I would like to convert this thread into that idea if no one can see a logical (or illogical) way to create natives that can be stored inside a map...

PS. :dumb face: about the center stuff I was trying to figure out why I can't spoil tag (wont shrink) though maybe some sort of combination would work. Never changed it back after I gave up.
 

lbebusiness

New Member
Reaction score
3
You can use custom blizzard.j and common.j etc files that load at map init

Instructions to reproduce proof.
Import said files
change the directory of said files to
scripts\Blizzard.j
scripts\common.j
save map
errors may pop up
work around:
close map editor
open map editor and open map
save again.
NO ERRORS.
run map.
everything works fine.

Now do the above steps with corrupted said files.
will produce errors first time you save just like with uncorrupted files
will save fine the second time just like with uncorrupted files
But will hard crash when you actually run the map.

Means that imported files do "replace" mpq files at runtime.

*succesfully modifyed WE to use Page_up key
still needs a native event

what is the event when you press a hot key?

ESC
Hotkey=512

JASS programmers have found and exploited a now famous bug in the JASS compiler's syntax checker: the so-called "return bug". Essentially, the compiler will only make sure that the last return statement in a function returns the correct type. Therefore, the following code compiles without error and can be used to cast handles to integers

function H2I takes handle h returns integer
return h //the function will stop executing after the first return statement, i.e. this one
return 0 //the compiler will only check this statement for syntax accuracy, but it is in reality unreachable code
endfunction
what good is this bug for?

Code:
//----------------------------------------------------------------------
// Global Declarations
//----------------------------------------------------------------------

program         := file+

file            := newline? (declr newline)* func*

so what do program and file do?

There is no way for a modified world editor or jass scripter to modify a map file to run any sort of program?
if you could run anything of any sort that would be a start...
use and event to start it?
of course the file would be stored inside the map...
WWAVD? (what would a virus do?)
How do I write something up to return the integer of every event as it happens? (H2I)
Code:
function HandleToInt takes handle h returns integer
    return h
    return 0
endfunction
how do I make this happen for every event? or a specific event?
requires compiling a list of every event doesn't it as an event in a trigger then displaying its integer value? (defeat what im trying to do because Im looking for unlisted eventid's...
And where do I find the hard-coded events? what file?
 

saw792

Is known to say things. That is all.
Reaction score
280
Only some files can be replaced. Many do not work.

You can't execute a program within the game without modifying the game engine.

You can't modify the game engine and transmit that modification within a map.

You are restricted by the limits of the game engine and the ,w3x format. There is no way this could work. 'Hard-coded' events are not stored within MPQ files, they are stored within the game engine. The game engine is now in an unreadable state as it has been compiled within the .exe / .dll / .whatever else (I don't fully understand how it works) files.

JASS is limited. It can't do everything.
 

Akolyt0r

New Member
Reaction score
33
however you can import some slightly edited common.j which gives you access to some ai commands...(since they ARE implemented in the game engine).
 

saw792

Is known to say things. That is all.
Reaction score
280
No it doesn't. common.j can be overridden with the correct import path and the natives already exist in common.ai and thus in the game engine. Only two (I think it's two) work properly though. Check the JASS manual at sourceforge, I remember this is mentioned there.
 

lbebusiness

New Member
Reaction score
3
what are these for?

program := file+
file := newline? (declr newline)* func*

so who can tell me where the hotkey events are then?...
I dont care how they are converted or whatever. Just where is the event at? If I can USE it in WE even if its a hotkey there has to be an event that its linked to...
press arrow up = convertplayerevent(numberhere)
so
Hotkey "A" = ????
 

Akolyt0r

New Member
Reaction score
33
No it doesn't. common.j can be overridden with the correct import path and the natives already exist in common.ai and thus in the game engine. Only two (I think it's two) work properly though. Check the JASS manual at sourceforge, I remember this is mentioned there.

JASS:

native UnitAlive            takes unit id                               returns boolean

//these below only work for standard units (not for new custom units)
native GetUnitGoldCost      takes integer unitid                        returns integer
native GetUnitWoodCost      takes integer unitid                        returns integer
native GetUnitBuildTime     takes integer unitid                        returns integer
 

Sooda

Diversity enchants
Reaction score
318
> so who can tell me where the hotkey events are then?...
Usable keys are set in Blizzard.j file, they are constants:
Code:
    // Keyboard Event Types
    constant integer   bj_KEYEVENTTYPE_DEPRESS     = 0
    constant integer   bj_KEYEVENTTYPE_RELEASE     = 1

    // Keyboard Event Keys
    constant integer   bj_KEYEVENTKEY_LEFT         = 0
    constant integer   bj_KEYEVENTKEY_RIGHT        = 1
    constant integer   bj_KEYEVENTKEY_DOWN         = 2
    constant integer   bj_KEYEVENTKEY_UP           = 3
Valid key events, set in common.j
Code:
    //===================================================
    // For use with TriggerRegisterPlayerEvent
    //===================================================

    constant playerevent        EVENT_PLAYER_ARROW_LEFT_DOWN            = ConvertPlayerEvent(261)
    constant playerevent        EVENT_PLAYER_ARROW_LEFT_UP              = ConvertPlayerEvent(262)
    constant playerevent        EVENT_PLAYER_ARROW_RIGHT_DOWN           = ConvertPlayerEvent(263)
    constant playerevent        EVENT_PLAYER_ARROW_RIGHT_UP             = ConvertPlayerEvent(264)
    constant playerevent        EVENT_PLAYER_ARROW_DOWN_DOWN            = ConvertPlayerEvent(265)
    constant playerevent        EVENT_PLAYER_ARROW_DOWN_UP              = ConvertPlayerEvent(266)
    constant playerevent        EVENT_PLAYER_ARROW_UP_DOWN              = ConvertPlayerEvent(267)
    constant playerevent        EVENT_PLAYER_ARROW_UP_UP                = ConvertPlayerEvent(268)
There isn't any empty event numbers, from on comes 269 starts TriggerRegisterPlayerUnitEvent events (strange 260 is unused event number and comes before key events. 256 - 259 are again used for TriggerRegisterGameEvent events.)
 

lbebusiness

New Member
Reaction score
3
thank you your the only one who is directly answering my question.
But I was asking about hotkeys that you press for spells etc. Where are the events for those? (you showed me arrow key events...)

WESTRING_UEVAL_UHOT=Hotkey
eval hotkey?

ESC
Hotkey=512


// Trigger Non-Variable Types - Utility, only used to simplify triggers
keyeventtype=1,0,0,WESTRING_TRIGTYPE_keyeventtype,integer
keyeventkey=1,0,0,WESTRING_TRIGTYPE_keyeventkey,integer

Keep that in mind
Check this out:
Im going to create a valid trigger that will throw no errors but wont run due to missing an event:
Key in example will be the page up key:

Key is defined here:
(there are alot more here)
worldeditstrings.txt
JASS:
WESTRING_HOTKEY_UP="Up"
WESTRING_HOTKEY_DOWN="Down"
WESTRING_HOTKEY_LEFT="Left"
WESTRING_HOTKEY_RIGHT="Right"

/////////////////////////

WESTRING_HOTKEY_PAGEUP="Pg Up"

/////////////////////////


Add key to list of usable keyevents in GUI
triggerdata.txt
JASS:
// Keyboard Event Keys
KeyEventKeyLeft=1,keyeventkey,bj_KEYEVENTKEY_LEFT,WESTRING_KEYEVENTKEY_LEFT
KeyEventKeyRight=1,keyeventkey,bj_KEYEVENTKEY_RIGHT,WESTRING_KEYEVENTKEY_RIGHT
KeyEventKeyDown=1,keyeventkey,bj_KEYEVENTKEY_DOWN,WESTRING_KEYEVENTKEY_DOWN
KeyEventKeyUp=1,keyeventkey,bj_KEYEVENTKEY_UP,WESTRING_KEYEVENTKEY_UP

/////////////////////////

KeyEventKeyPageUp=1,keyeventkey,bj_KEYEVENTKEY_PAGE_UP,WESTRING_KEYEVENTKEY_PAGE_UP

/////////////////////////


Add string name to key for use in GUI editor:

worldeditstrings.txt
JASS:
// Trigger keyboard events
WESTRING_KEYEVENTKEY_LEFT="Left Arrow"
WESTRING_KEYEVENTKEY_RIGHT="Right Arrow"
WESTRING_KEYEVENTKEY_DOWN="Down Arrow"
WESTRING_KEYEVENTKEY_UP="Up Arrow"

/////////////////////////

WESTRING_KEYEVENTKEY_PAGE_UP="Page Up"

/////////////////////////


Declare my key event constant here:

Blizzard.j
JASS:
    // Keyboard Event Types
    constant integer   bj_KEYEVENTTYPE_DEPRESS     = 0
    constant integer   bj_KEYEVENTTYPE_RELEASE     = 1

    // Keyboard Event Keys
    constant integer   bj_KEYEVENTKEY_LEFT         = 0
    constant integer   bj_KEYEVENTKEY_RIGHT        = 1
    constant integer   bj_KEYEVENTKEY_DOWN         = 2
    constant integer   bj_KEYEVENTKEY_UP           = 3

/////////////////////////

    constant integer   bj_KEYEVENTKEY_PAGE_UP      = 4

/////////////////////////


Modify Funtions to recognise Key and return Event
Blizzard.j
JASS:
function TriggerRegisterPlayerKeyEventBJ takes trigger trig, player whichPlayer, integer keType, integer keKey returns event
    if (keType == bj_KEYEVENTTYPE_DEPRESS) then
        // Depress event - find out what key
        if (keKey == bj_KEYEVENTKEY_LEFT) then
            return TriggerRegisterPlayerEvent(trig, whichPlayer, EVENT_PLAYER_ARROW_LEFT_DOWN)
        elseif (keKey == bj_KEYEVENTKEY_RIGHT) then
            return TriggerRegisterPlayerEvent(trig, whichPlayer, EVENT_PLAYER_ARROW_RIGHT_DOWN)
        elseif (keKey == bj_KEYEVENTKEY_DOWN) then
            return TriggerRegisterPlayerEvent(trig, whichPlayer, EVENT_PLAYER_ARROW_DOWN_DOWN)
        elseif (keKey == bj_KEYEVENTKEY_UP) then
            return TriggerRegisterPlayerEvent(trig, whichPlayer, EVENT_PLAYER_ARROW_UP_DOWN)

////////////////////////

        elseif (keKey == bj_KEYEVENTKEY_PAGE_UP) then
            return TriggerRegisterPlayerEvent(trig, whichPlayer, EVENT_PLAYER_PAGE_UP_DOWN)
        
////////////////////////

         else
            // Unrecognized key - ignore the request and return failure.
            return null
        endif
    elseif (keType == bj_KEYEVENTTYPE_RELEASE) then
        // Release event - find out what key
        if (keKey == bj_KEYEVENTKEY_LEFT) then
            return TriggerRegisterPlayerEvent(trig, whichPlayer, EVENT_PLAYER_ARROW_LEFT_UP)
        elseif (keKey == bj_KEYEVENTKEY_RIGHT) then
            return TriggerRegisterPlayerEvent(trig, whichPlayer, EVENT_PLAYER_ARROW_RIGHT_UP)
        elseif (keKey == bj_KEYEVENTKEY_DOWN) then
            return TriggerRegisterPlayerEvent(trig, whichPlayer, EVENT_PLAYER_ARROW_DOWN_UP)
        elseif (keKey == bj_KEYEVENTKEY_UP) then
            return TriggerRegisterPlayerEvent(trig, whichPlayer, EVENT_PLAYER_ARROW_UP_UP)

/////////////////////////

        elseif (keKey == bj_KEYEVENTKEY_PAGE_UP) then
            return TriggerRegisterPlayerEvent(trig, whichPlayer, EVENT_PLAYER_PAGE_UP_UP)               

////////////////////////

        else
            // Unrecognized key - ignore the request and return failure.
            return null
        endif
    else
        // Unrecognized type - ignore the request and return failure.
        return null
    endif
endfunction


Add Key event's eventid here: (need event id though)

Common.j
JASS:
    //===================================================
    // For use with TriggerRegisterPlayerEvent
    //===================================================

    constant playerevent        EVENT_PLAYER_ARROW_LEFT_DOWN            = ConvertPlayerEvent(261)
    constant playerevent        EVENT_PLAYER_ARROW_LEFT_UP              = ConvertPlayerEvent(262)
    constant playerevent        EVENT_PLAYER_ARROW_RIGHT_DOWN           = ConvertPlayerEvent(263)
    constant playerevent        EVENT_PLAYER_ARROW_RIGHT_UP             = ConvertPlayerEvent(264)
    constant playerevent        EVENT_PLAYER_ARROW_DOWN_DOWN            = ConvertPlayerEvent(265)
    constant playerevent        EVENT_PLAYER_ARROW_DOWN_UP              = ConvertPlayerEvent(266)
    constant playerevent        EVENT_PLAYER_ARROW_UP_DOWN              = ConvertPlayerEvent(267)
    constant playerevent        EVENT_PLAYER_ARROW_UP_UP                = ConvertPlayerEvent(268)

/////////////////////////

    constant playerevent        EVENT_PLAYER_PAGE_UP_UP                 = ConvertPlayerEvent(260)
    constant playerevent        EVENT_PLAYER_PAGE_UP_DOWN            = ConvertPlayerEvent(260)

/////////////////////////


Whats left? Someone has to open the .dll up (storm I belive) and make a list of every event.

Storm.dll is like a book that blizzard ADD's funtions to (or events).
You could take warcraft III Storm.dll and run starcraft with it. But not vise vesa.

So every update adds something new and doesn't take anything out of it.

Following this practice, Blizzard uses a shared library called Storm (Storm.dll on PCs, Storm.bin on Macs). This library is used by all modern Blizzard games to store important functions like MPQ reading (discussed in chapter 3), Battle.net, and even some graphics routines. When Blizzard releases a new game, it adds functions to Storm without changing old functions. This means that an old game can use a new version of Storm just fine. But, like all shared libraries, Storm makes its functions available to any program that wants to use them, which is not very good for security. It is for this reason that Storm only contains MPQ reading functions. The MPQ writing functions are Blizzard's prized possessions, and they're not going to let just anyone use them.

I have no clue how to take apart a dll. But I do know its hell (blizzard made it hard to use Storm.dll) but I do have a Storm API which is documented here
http://www.campaigncreations.org/starcraft/inside_mopaq/chapter4.htm#using_the_storm_api

It talks about how to initialize it etc.

You can also download it.
Read me:
/*****************************************************************************/
/* StormIL.zip Copyright Justin Olbrantz(Quantam) 2000 */
/* */
/* Storm Interface Library v1.0 for Windows */
/* */
/* Author : Justin Olbrantz(Quantam) */
/* E-mail : [email protected] */
/* WWW : www.campaigncreations.com/starcraft/mpq2k/inside_mopaq/ */
/*---------------------------------------------------------------------------*/
/* Companion pack for Inside MoPaQ chapter 3 */
/*****************************************************************************/

This package contains the following files:

STORM.H Function prototypes for Storm.dll
STORM.LIB Import library for accessing Storm.dll. This is not a static
library! You still need Storm.dll
STORM.EXP Export file used in some rare scenarios

You may freely distribute this package as long as all of it (including this
file) remain intact and unchanged.

Have fun if you know what I'm talking about.
Thanks for listening.
:banghead::banghead::banghead::banghead::banghead::banghead:
 

Sooda

Diversity enchants
Reaction score
318
Event native TriggerRegisterPlayerEvent expects integer between 261 to 268. When integer is out of range trigger event is not created. It is safety thing about what SFilip spoke (post #3).
I think you have gotten shortcut list from World Editor, it can be accessed from File > Configure Controls.

EDIT:

Much interesting is native DialogAddButton which can take hotkey. Clicking dialog button hotkey is like pressing key. Event TriggerRegisterDialogEvent responds to key presses other than left, right, top, bottom arrows. I haven't figured out how to force player press arrow keys. I don't know how they are written for Warcraft 3.

EDIT2:

Everything you did for World Editor is visual, it does not make difference in game. When you changed Blizzard made function to recognize fifth key, page up was also cosmetic thing. Page Up constants are only for that function guidelines which event add to trigger. They are there for understanding map creator input when it makes triggers.
Modifying common.j to have new playerevent was closest. Making game to return working event for Page Up key is problem, currently it wants number between 261 to 268 or it does not care. I check what happens when feeding it with wrong number, I guess it returns 0.

EDIT3:

When giving unexpected number event isn't created.
JASS:
constant playerevent        EVENT_PLAYER_PAGE_UP_DOWN              = ConvertPlayerEvent(260)

Does not give results, event isn't created.
 

Andrewgosu

The Silent Pandaren Helper
Reaction score
716
Dialogs pause the game in single player, but in multi player they don't.

Now, what if one made the dialog textures fully transparent and showed a dialog for all players all the time?

The game would not be paused and I think scrolling and playing would function normally, as without a dialog showing.

Wouldn't it be possible to register when a player presses a key with the dialog buttons?


Just a crazy idea, not tested or anything.
 

Romek

Super Moderator
Reaction score
963
@ Mr.Panda
Don't they disable the control of the player they're being shown to?
I don't remember being able to order units around while a dialog was displayed.
 

Andrewgosu

The Silent Pandaren Helper
Reaction score
716
It might be, as I haven't messed with dialogs much nor played many games that used them.
 

Sooda

Diversity enchants
Reaction score
318
Tried dialog in multiplayer for curiosity. It can not be used to detect keyboard events. When dialog is displayed game continues, but that is it. Everything except dialog is un-selectable. When trying to enable player control (that I tried in Single Player: un-pause game, enabling player control, exiting from cinematic mode) all made dialog disappear at once.

Solution would be to create custom native events for key presses. But that is out of my league.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top