• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[Snippet] [Needs work] Anti Maphack

JASS:
library AMH /* v1.0.0.3
*************************************************************************************
*
*   This will only stop maphack programs and will only work if the user attempts to
*   do anything to a unit. This will not stop the user from simply viewing the map
*   or units on the map.
*
*   This can be useful for keeping users from targeting units with spells (teleport etc)
*   as well as from controlling enemy units as well as from controlling their own units in
*   cases where their own units have no sight.
*
*   All of the SelectUnit stuff works fine with this, but the order stuff will not. If ordering
*   an active player unit to target something that's not visible to that player, this will
*   fire. However, non visible units can be ordered to do things.
*
*   This is a simple copy and paste.
*
*   This will notify other players in the game of the cheat as well as remove the cheating player from
*   the game.
*
************************************************************************************/
    globals
        private boolean s=false
        private timer e=CreateTimer()
    endglobals
    private function E takes nothing returns nothing
        set s=false
    endfunction
    private function S takes nothing returns boolean
        local player p=GetTriggerPlayer()
        if (not s and not IsUnitVisible(GetTriggerUnit(),p)) then
            call DisplayTimedTextToPlayer(GetLocalPlayer(),0,0,60,GetPlayerName(p) + " has cheated")
            if (p==GetLocalPlayer()) then
                call EndGame(false)
            endif
        else
            call TimerStart(e,0,false,function E)
        endif
        set p=null
        return false
    endfunction
    private function S2 takes nothing returns boolean
        local player p=GetTriggerPlayer()
        if (not s and GetOrderTargetUnit() != null and not IsUnitVisible(GetOrderTargetUnit(),p) and GetIssuedOrderId()!=851973) then
            call DisplayTimedTextToPlayer(GetLocalPlayer(),0,0,60,GetPlayerName(p) + " has cheated")
            if (p==GetLocalPlayer()) then
                call EndGame(false)
            endif
        endif
        set p=null
        return false
    endfunction
    private module I
        private static method onInit takes nothing returns nothing
            local integer i=11
            local trigger t=CreateTrigger()
            local trigger t2=CreateTrigger()
            local player p
            call TriggerAddCondition(t,Condition(function S))
            call TriggerAddCondition(t2,Condition(function S2))
            loop
                set p=Player(i)
                if (GetPlayerController(p)==MAP_CONTROL_USER and GetPlayerSlotState(p)==PLAYER_SLOT_STATE_PLAYING) then
                    call TriggerRegisterPlayerUnitEvent(t,p,EVENT_PLAYER_UNIT_SELECTED,null)
                    call TriggerRegisterPlayerUnitEvent(t2,p,EVENT_PLAYER_UNIT_ISSUED_TARGET_ORDER,null)
                endif
                exitwhen 0==i
                set i=i-1
            endloop
            set p=null
            set t=null
            set t2=null
        endmethod
    endmodule
    private struct N extends array
        implement I
    endstruct
    private function SUF takes unit u,boolean f returns nothing
        set s=true
    endfunction
    private function SU takes unit u returns nothing
        set s=true
    endfunction
    private function SUP takes unit u,player p returns nothing
        set s=true
    endfunction
    private function SG takes group g returns nothing
        set s=true
    endfunction
    private function SGP takes group g, player p returns nothing
        set s=true
    endfunction
    hook SelectUnit SUF
    hook SelectUnitAdd SU
    hook SelectUnitAddForPlayer SUP
    hook SelectUnitForPlayerSingle SUP
    hook SelectUnitSingle SU
    hook SelectGroupBJ SG
    hook SelectGroupForPlayerBJ SGP
endlibrary
 
Last edited:
Level 15
Joined
Jul 6, 2009
Messages
889
Repeating GetTriggerPlayer twice is ok, but thrice is just crossing the line..

It's only being called once on every select unit event, it's only called two extra times during an instance where maphack is detected. Nestharus probably already have some random reasoning as to why he's not stored it into a variable - local or global. . . or maybe he's overlooked it?

I love you Nestharus. No, I'm lying, I hate you. Kicking seems a bit extreme? Is this tested for complete flawlessness?
 
Level 17
Joined
Apr 27, 2008
Messages
2,455
So we can't select an invisible unit with a trigger action ?

Also does IsUnitVisible returns false when the unit is hidden by an ability ? (if yes, have you tested it with an unit "revealed" with this elf ability from the druid)
 
Level 17
Joined
Apr 27, 2008
Messages
2,455
erf, hooks and Timers(0), i would prefer that we wouldn't be able to select invisible units via trigger actions :p

But i'm afraid that wouldn't work on multi-players games (lan or battle.net), i'm quite sure of that because i used an unit selection to know if a game was a single or a multi-players game.
In other words in a multi-players games the selection event takes about 0.1 s (at least that was true few patchs ago)
 
Level 17
Joined
Apr 27, 2008
Messages
2,455
i don't know if you missunderstood me or not, but when i asked if we could select an invisible unit, it meant was it ever possible ?
I just tried and it seems that's not (at least with units hidden with the ShowUnit function).
So if you can't select an invisible unit, even with a trigger action, it's pretty simple to handle, no more hooks, timers or anything else is needed, just check when the select event fire it the unit is invisible for the trigger player or not.
 
Level 17
Joined
Apr 27, 2008
Messages
2,455
Again, i don't think it's possible to select an invisible unit (at least it's not with an unit hidden with the ShowUnit function).
So if you can't select an invisible unit, then you don't need the hooks and the timer.

99% seems far away from the truth btw, when we read your edits of your last resources.
 
For testing with delay, you can do that on LAN mode. You can play single
player via LAN and the selection delay does occur.

I don't know how maphacks work but if they don't trigger selection events
this are pretty useless. This also won't stop them from seeing the locations
and activities of units/buildings, so it's not a very thorough anti maphack.
 
Level 17
Joined
Apr 27, 2008
Messages
2,455
As said :

i don't know if you missunderstood me or not, but when i asked if we could select an invisible unit, it meant was it ever possible ?
I just tried and it seems that's not (at least with units hidden with the ShowUnit function).
So if you can't select an invisible unit, even with a trigger action, it's pretty simple to handle, no more hooks, timers or anything else is needed, just check when the select event fire it the unit is invisible for the trigger player or not.
 
Level 17
Joined
Apr 27, 2008
Messages
2,455
Might as well hook widget target orders then :\.

What it not clear in my previous quote ?

You can't select an invisible unit even with the function SelectUnit, that's because of the wc3 engine. Period.

The only thing you can do is selecting an unit which is outside the map, but i don't think the unit would be considered as invisible (need a test though).

So you don't need hooks, nor timer, when the select event fire, just check if the unit is invisible or not.
(if the unit is invisible while the select event fire -> maphack)

But yes you should also check the target order (and you already do it), but again no need of hook.
 
Level 4
Joined
Apr 9, 2011
Messages
84
I got a system that can detect a maphack easily!!

if65-1-c4ca.png
 
Level 17
Joined
Apr 27, 2008
Messages
2,455
Er... I don't know what the first portion of your response has to do with my post : P.

Well, maybe because you keep ignoring it ? ...

For last portion, I need to hook target orders in case the natives are used. Units could be ordered to target a widget that's not visible to them.

No they can't (will detail it)

Furthermore, with your SelectUnit, you did try units that were visible but hidden by fog right?

No i forgot, but now i've made the tests on fog, and the results are fun.

I was true, you can't select an invisible unit even with SelectUnit, though when the unit is hidden by fog, the select event fire but the unit is not selected and IsUnitSelected returns false.

For the target order, it's still true you can't target an invisible unit, though when the unit is hidden by fog, it's just like the unit receive a point order to the target, but no order event fire (at least PLAYER_UNIT POINT/TARGET/ISSUED ORDER)
So we got a new way to give a "move" order point which doesn't fire any event (joke)

So now it depends how it works with maphack.

And again you still haven't tested with the selecting delay on a multiplayer game.

@Renschi : Awesome :xxd:
 
Top