what is this script doing?

Post » Thu Jul 22, 2010 6:45 am

I saw this in a German mod script, it is used with iskeypressed2 later to see if the player is attacking:
(So it would be very difficult to ask the author, they even say do to language issue they would not be answering questions.)

if ( getGameLoaded )  set AttackTrigger to getAltControl 4    if ( AttackTrigger > -1 && AttackTrigger < 65535 )    set AttackTrigger to ( ( AttackTrigger - 255 ) / 256 ) + 256else   set AttackTrigger to getControl 4endifendif



Why not just use "IsControlPressed 4 == 1"?

Why is the alternate control of any interest here?
How will setting AttackTrigger to the alternate attack control still work if the player uses the primary attack button and not the alt?


what is

if ( AttackTrigger > -1 && AttackTrigger < 65535 )

doing exactly?


what is

set AttackTrigger to ( ( AttackTrigger - 255 ) / 256 ) + 256

doing exactly?
User avatar
Milagros Osorio
 
Posts: 3426
Joined: Fri Aug 25, 2006 4:33 pm

Post » Thu Jul 22, 2010 8:16 am

I believe this is the answer : http://cs.elderscrolls.com/constwiki/index.php/GetAltControl

According to the Wiki page...
To convert the value returned by GetAltControl to a DX scancode usable with IsKeyPressed2, do something like this:
short button
set button to getAltControl 4 ; attack button
if ( button != 65535 )
set button to ( button - 255 ) / 256 + 256
endif



So, as far as I can tell the Author is trying to turn the AltControl ID into a DX Scancode... Perhaps they got confused, somehow? If so, then "if ( AttackTrigger > -1 && AttackTrigger < 65535 )" makes sense, as they are checking that the Key is bound.

The Wiki says that this "Retrieves the mouse button bound to the requested control."-- so, in a default game, the Primary Control IS the Mouse Button, so there should not be an issue on that part; why they aren't using IsControlPressed 4, however, I have no idea... Maybe you should ask the OBSE team, in case there's an issue with certain Makes of Mouse, or Control pads, that affect the normal IsControlPressed...
User avatar
Miss K
 
Posts: 3458
Joined: Sat Jan 20, 2007 2:33 pm


Return to IV - Oblivion