Sign in to follow this  
Followers 0
BuckMaster

Map Help

4 posts in this topic

I'm building a map to display players on a battlefield 2 server via Rcon

The map is built with Irrlich 2

What i have right now is the main map, you can move around by clicking down and pulling the mouse,

You can zoom in with the mouse wheel and zoom out

The problem i have right now is when you pull the map around, it doesn't move equally to the players that will

be plotted on the map, I cant figure out why its doing it because the players move with the same variable as the map.

any help would be appreciated, files are at the bottom

#include <au3Irrlicht2.au3>

opt("MustDeclareVars", True)

HotKeySet("{ESC}", "_exit")

Func _exit()
    _IrrStop()
    Exit
EndFunc


dim $PlayerTexture
dim $MapImage

dim $MapRealWidth = 1024
dim $MapRealHeight = 1024
dim $MapX = 50
dim $MapY = 50
dim $MapWidth = 512
dim $MapHeight = 512
dim $MapTopX = 256
dim $MapTopY = 256
dim $MapBottomX = 768
dim $MapBottomY = 768
dim $LastX = -1
dim $LastY = -1
dim $MapDiff

dim $Down = False

dim $X
dim $Y
dim $xChange
dim $yChange

dim $pMouseEvent

dim $ZoomStep = 64
dim $ZoomFactor = 4

dim $Locations[46][2] = [ [ 240 , 170 ] , [ 360 , 440 ] , [ 760 , 350 ] , [ 450 , 335 ] , [ 0 , 0 ] , [ 0 , 0 ] , [ 0 , 0 ] , [ 0 , 0 ] , [ 0 , 0 ] , [ 0 , 0 ] , [ 0 , 0 ] , [ 0 , 0 ] , [ 0 , 0 ] , [ 0 , 0 ] , [ 0 , 0 ] , [ 0 , 0 ] , [ 0 , 0 ] , [ 0 , 0 ] , [ 0 , 0 ] , [ 0 , 0 ] , [ 0 , 0 ] , [ 0 , 0 ] , [ 0 , 0 ] , [ 0 , 0 ] , [ 0 , 0 ] , [ 0 , 0 ] , [ 0 , 0 ] , [ 0 , 0 ] , [ 0 , 0 ] , [ 0 , 0 ] , [ 0 , 0 ] , [ 0 , 0 ] , [ 0 , 0 ] , [ 0 , 0 ] , [ 0 , 0 ] , [ 0 , 0 ] , [ 0 , 0 ] , [ 0 , 0 ] , [ 0 , 0 ] , [ 0 , 0 ] , [ 0 , 0 ] , [ 0 , 0 ] , [ 0 , 0 ] , [ 0 , 0 ] , [ 0 , 0 ] , [ 0 , 0 ]  ]



$screen_width = 800
$screen_height = 600
_IrrStart( $IRR_EDT_OPENGL, $screen_width, $screen_height, $IRR_BITS_PER_PIXEL_32, $IRR_WINDOWED, $IRR_NO_SHADOWS, $IRR_CAPTURE_EVENTS )

_IrrSetWindowCaption( "Game Map" )

$MapImage = _IrrGetTexture( "background.jpg" )
$PlayerTexture = _IrrGetTexture( "player.png" )

WHILE _IrrRunning()
    _IrrBeginScene( 255,255,255)

    while _IrrMouseEventAvailable()
        $pMouseEvent = _IrrReadMouseEvent()
        If __getMouseEvt($pMouseEvent, $EVT_MOUSE_IACTION) = $IRR_EMIE_LMOUSE_PRESSED_DOWN Then
            $Down = True
        ElseIf __getMouseEvt($pMouseEvent, $EVT_MOUSE_IACTION) = $IRR_EMIE_LMOUSE_LEFT_UP Then
            $Down = False
            $LastX = -1
            $LastY = -1
        ElseIf __getMouseEvt($pMouseEvent, $EVT_MOUSE_IACTION) = $IRR_EMIE_MOUSE_MOVED Then
            If $Down = True Then
                $X = __getMouseEvt($pMouseEvent, $EVT_MOUSE_IX)
                $Y = __getMouseEvt($pMouseEvent, $EVT_MOUSE_IY)
                If $X > $MapX and $X < $MapX + $MapWidth and $Y > $MapY and $Y < $MapY + $MapHeight Then
                    If $LastX = -1 and $LastY = -1 Then
                        $xChange = 0
                        $yChange = 0
                    Else
                        $xChange = $X-$LastX
                        $yChange = $Y-$LastY
                    EndIf
                    If ( $MapTopX - $xChange ) > 0 and ( $MapTopY - $yChange ) > 0 and ( $MapTopX - $xChange ) < ( $ZoomFactor * ( $ZoomStep * 2 ) ) and ( $MapTopY - $yChange ) < ( $ZoomFactor * ( $ZoomStep * 2 ) ) Then
                        $MapTopX -= $xChange
                        $MapTopY -= $yChange
                        $MapBottomX -= $xChange
                        $MapBottomY -= $yChange
                    EndIf
                EndIf
                $LastX = $X
                $LastY = $Y
            EndIf
        ElseIf __getMouseEvt($pMouseEvent, $EVT_MOUSE_IACTION) = $IRR_EMIE_MOUSE_WHEEL Then
            if __getMouseEvt($pMouseEvent, $EVT_MOUSE_FDELTA) > 0 Then
                If $ZoomFactor < 7 Then
                    $ZoomFactor += 1
                    $MapTopX += $ZoomStep
                    $MapTopY += $ZoomStep
                    $MapBottomX -= $ZoomStep
                    $MapBottomY -= $ZoomStep
                EndIf
            Else
                If $ZoomFactor > 0 Then
                    $ZoomFactor -= 1
                    $MapTopX -= $ZoomStep
                    $MapTopY -= $ZoomStep
                    $MapBottomX += $ZoomStep
                    $MapBottomY += $ZoomStep
                    If $MapTopX < 0 Then
                        $MapBottomX = $MapRealWidth-(($ZoomStep*2)*$ZoomFactor)
                        $MapTopX = 0
                    EndIf
                    If $MapTopY < 0 Then
                        $MapBottomY = $MapRealHeight-(($ZoomStep*2)*$ZoomFactor)
                        $MapTopY = 0
                    EndIf
                    If $MapBottomX > $MapRealWidth Then
                        $MapBottomX = $MapRealWidth
                        $MapTopX = (($ZoomStep*2)*$ZoomFactor)
                    EndIf
                    If $MapBottomY > $MapRealHeight Then
                        $MapBottomY = $MapRealHeight
                        $MapTopY = (($ZoomStep*2)*$ZoomFactor)
                    EndIf
                EndIf
            EndIf
        EndIf

    WEnd
    _IrrDraw2DImageElementStretch ( $MapImage, $MapX, $MapY, 512, 512, $MapTopX, $MapTopY, $MapBottomX, $MapBottomY, $IRR_USE_ALPHA )
    For $i = 1 to 45 Step 1
        If $Locations[$i][0] <> 0 and $Locations[$i][1] <> 0 Then
            If $Locations[$i][0] > $MapTopX and $Locations[$i][0] < $MapBottomX - $MapX and $Locations[$i][1] > $MapTopY and $Locations[$i][1] < $MapBottomY Then
                _IrrDraw2dImageElement( $PlayerTexture, $MapX + ($Locations[$i][0] - $MapTopX)-4, $MapY + ($Locations[$i][1] - $MapTopY)-4, 0, 0, 8, 8, $IRR_USE_ALPHA )
            EndIf
        EndIf
    Next

    _IrrEndScene()
WEND

_IrrStop()

Background image: http://i55.tinypic.com/k3q39l.jpg

Player image: http://i55.tinypic.com/t0ql50.png

Share this post


Link to post
Share on other sites



Do you not have an in game map?


[font="Comic Sans MS"]My code does not have bugs! It just develops random features.[/font]My Projects[list][*]Live Streaming (Not my project, but my edited version)[right]AutoIt Wrappers![/right][/list]Pure randomness[list][*]Small Minds.......................................................................................................[size="1"]Simple progress bar that changes direction at either sides.[/size][*]ChristmasIt AutoIt Christmas Theme..........................................................[size="1"]I WAS BOOOORED![/size][*]DriveToy..............................................................................................................[size="1"]Simple joke script. Trick your friends into thinking their computer drive is haywire![/size][/list]In Development[list][*]Your Background Task Organiser[*]AInstall Second Generation[/list]BEFORE POSTING ON THE FORUMS, TRY THIS:
%programfiles%/AutoIt3/autoit3.chm

Share this post


Link to post
Share on other sites

@BuckMaster

game bots and game automation is not tolerated in this forum.

There is a big announcement on top of every forum section - I would recommend you to read it http://www.autoitscript.com/forum/forum-2/announcement-12-game-bots-and-automation/

This post is clearly against forum rules and you should expect that it will be locked by a moderator.


SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script

wannabe "Unbeatable" Tic-Tac-Toe

Paper-Scissor-Rock ... try to beat it anyway :)

Share this post


Link to post
Share on other sites

No, no, no, im not making a hack..

Its a Rcon connection to the server and i use the rcon password for the server to do it,

I know the rules, im not making a bot or ingame minimap, This is a server admin tool that im making, not a hack.

If you would like to respond with some help, please do so.

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.
Sign in to follow this  
Followers 0