wc3campaigns
WC3C Homepage - www.wc3c.netUser Control Panel (Requires Log-In)Engage in discussions with other users and join contests in the WC3C forums!Read one of our many tutorials, ranging in difficulty from beginner to advanced!Show off your artistic talents in the WC3C Gallery!Download quality models, textures, spells (vJASS/JASS), systems, and scripts!Download maps that have passed through our rigorous approval process!

Go Back   Wc3C.net > Resources > Code Resources > Scripts
User Name
Password
Register Rules Get Hosted! Chat Pastebin FAQ and Rules Members List Calendar



Reply
 
Thread Tools Search this Thread
Old 07-03-2008, 09:52 AM   #1
PandaMine
Panda > You
 
PandaMine's Avatar
 
Join Date: May 2006
Posts: 500

Submissions (4)

PandaMine has a spectacular aura about (96)PandaMine has a spectacular aura about (96)PandaMine has a spectacular aura about (96)PandaMine has a spectacular aura about (96)

Send a message via MSN to PandaMine
Default Replay Detection Script

This function I discovered myself (and with the help of Captain Griffen). Simply put, if your actually playing a game, it will return true HOWEVER if your viewing the game as a replay it will return false. The function has been tested in MultiPlayer and it now causes no desyncs (by tested I mean vigorously tested by IceFrog for like 3 months). There is only one downside, and that is the function uses up one pause.

There might be a second version of the function that doesn't use up a pause (discovered by Strilanc) however there are a couple of issues with it

How does it work?
Simply put a replay is just a file that contains the inputs from the various players when playing a game. However when Wc3 views a replay, there are differences then if you were physically playing the game. One of the differences is pausing. If you are actually playing and you pause a game, it is paused. However during a replay, if you pause a game the replay simply finishes at the point you paused the game, if the game is resumed some time later then the replay completely skips the pause phase. There are only a few things that work in real time during pauses when your playing the game (anything else you do during the pause just gets 'suspended' until the game is resumed). The 2 things that work in real time are camera angles and trigger sleep action.

The function works by moving the camera during the pause. If the camera is moved during the pause, then you are playing the actual game. If the camera isn't moved then it is the replay (since the pause phase is totally skipped)

- It is HIGHLY recommended that you save the returning value of the function into a boolean variable i.e.
set someboolean = IsInGame()
So you only call the function once (since it takes up a pause)

Collapse JASS:
//<- InGame function created by PandaMine with help from Captain Griffen
function IsInGame takes nothing returns boolean
    local integer counter = 0
    local real camerax
    local real cameray
    local real x
    local real y
    local boolean output
    loop
        exitwhen counter > 11
        if GetLocalPlayer() == Player(counter) then
            set camerax = GetCameraTargetPositionX()
            set cameray = GetCameraTargetPositionY()
        endif
        set counter = counter + 1
    endloop
    set counter = 0
    call PauseGame(true)
    call TriggerSleepAction(0)
    loop
        exitwhen counter > 11
        if GetLocalPlayer() == Player(counter) then
            call SetCameraPosition(camerax + 1,cameray + 1)
        endif
        set counter = counter + 1
    endloop
    call TriggerSleepAction(0)
    call PauseGame(false)
    set counter = 0
    loop
        exitwhen counter > 11
        if GetLocalPlayer() == Player(counter) then
            set x = GetCameraTargetPositionX()
            if x == camerax + 1 then
                set output = true
            else
                set output = false
            endif
            call SetCameraPosition(camerax,cameray)
        endif
        set counter = counter + 1
    endloop
    return output
endfunction

With the new change to the function, it no longer needs to be synchronized however you should still initialize it like this because it has been reported that selecting units + triggersleepaction can cause desyncs

Collapse JASS:
function Initiate takes nothing returns nothing
    call EnableUserControl(false)
    call TriggerSleepAction(.0)
    set udg_InGame = IsInGame()
    call EnableUserControl(true)
endfunction
__________________
PandaMine's Creations:

Last edited by PandaMine : 07-04-2008 at 01:13 AM.
PandaMine is offline   Reply With Quote
Sponsored Links - Login to hide this ad!
Old 07-03-2008, 11:11 AM   #2
DioD
obey
 
DioD's Avatar
 
Join Date: Feb 2006
Posts: 1,532

Submissions (4)

DioD is a jewel in the rough (220)DioD is a jewel in the rough (220)DioD is a jewel in the rough (220)DioD is a jewel in the rough (220)

Send a message via ICQ to DioD
Default

This is antimaphack components isn it?
DioD is offline   Reply With Quote
Old 07-03-2008, 12:58 PM   #3
PandaMine
Panda > You
 
PandaMine's Avatar
 
Join Date: May 2006
Posts: 500

Submissions (4)

PandaMine has a spectacular aura about (96)PandaMine has a spectacular aura about (96)PandaMine has a spectacular aura about (96)PandaMine has a spectacular aura about (96)

Send a message via MSN to PandaMine
Default

kind of, sought of, not really (yes it is included in AMHS)

It was made because anti map hack needed it, but it can be used for anything. Hell you can even make a replay viewer engine out of this, all it is is its a simple function that detects if you are playing the game or watching the replay
__________________
PandaMine's Creations:
PandaMine is offline   Reply With Quote
Old 07-03-2008, 02:18 PM   #4
Vexorian
Free Software Terrorist
 
Vexorian's Avatar


Technical Director
 
Join Date: Apr 2003
Posts: 14,905

Submissions (37)

Vexorian has a reputation beyond repute (1060)Vexorian has a reputation beyond repute (1060)Vexorian has a reputation beyond repute (1060)Vexorian has a reputation beyond repute (1060)Vexorian has a reputation beyond repute (1060)Vexorian has a reputation beyond repute (1060)Vexorian has a reputation beyond repute (1060)

Hero Contest #3 - 2nd Place

Default

I just tested and you need either an attachment or a [jass] tag to submit. So it is working fine, just need to improve the error message?

Edit: There are bugs in my Jass tag detector, trying to fix them.
__________________
Zoom (requires log in)Wc3 map optimizer 5.0
Someone should fix .wav sound in this thing.
Zoom (requires log in)JassHelper 0.A.2.A
Turns your simple code into something that is complicated enough to work.
Faster != more useful
Vexorian is offline   Reply With Quote
Old 07-03-2008, 03:03 PM   #5
Captain Griffen
Dread Lord of the Cookies
 
Captain Griffen's Avatar


Content Director
 
Join Date: Sep 2003
Posts: 5,368

Submissions (2)

Captain Griffen is a glorious beacon of light (497)Captain Griffen is a glorious beacon of light (497)Captain Griffen is a glorious beacon of light (497)Captain Griffen is a glorious beacon of light (497)Captain Griffen is a glorious beacon of light (497)

Approved Map: Warlords[Quicksilver #2] - 1st Place

Default

It can be very useful for stuff like extra info being displayed in replays (more economic data, etc.). I'll give this newer function a good testing in the next Warlords version today or tomorrow (I'm still using the old one, probably the first one I got to work properly that needed a sync; works fine but a bit inefficient).
__________________
Quote:
Originally Posted by Earth-Fury
Griffen is correct, you are not.
Quote:
[13:32] <Akolyt0r> hmm.. stil i want to have some unused women
Captain Griffen is offline   Reply With Quote
Old 07-03-2008, 03:53 PM   #6
Rising_Dusk
Obscurity, the Art


Projects Director
Project Leader: OD
 
Join Date: Feb 2006
Posts: 9,727

Submissions (27)

Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)

Hero Contest #3 - 1st PlaceApproved Map: Desert of ExileApproved Map: Advent of the ZenithHero Contest #2 - 1st PlaceHero Contest - Third place>

Send a message via AIM to Rising_Dusk Send a message via MSN to Rising_Dusk
Default

It's cute, but you should really fix your indenting.
__________________
Rising_Dusk is offline   Reply With Quote
Old 07-03-2008, 04:49 PM   #7
Captain Griffen
Dread Lord of the Cookies
 
Captain Griffen's Avatar


Content Director
 
Join Date: Sep 2003
Posts: 5,368

Submissions (2)

Captain Griffen is a glorious beacon of light (497)Captain Griffen is a glorious beacon of light (497)Captain Griffen is a glorious beacon of light (497)Captain Griffen is a glorious beacon of light (497)Captain Griffen is a glorious beacon of light (497)

Approved Map: Warlords[Quicksilver #2] - 1st Place

Default

All seems to be in fine working order. You might want to change it to this though:

Collapse JASS:
function IsInGame takes nothing returns boolean
    local integer counter = 0
    local real camerax
    local real cameray
    local real x
    local real y
    local boolean output
    loop
        exitwhen counter > 11
        if GetLocalPlayer() == Player(counter) then
            set camerax = GetCameraTargetPositionX()
            set cameray = GetCameraTargetPositionY()
        endif
        set counter = counter + 1
    endloop
    set counter = 0
    call PauseGame(true)
    call TriggerSleepAction(0)
    loop
        exitwhen counter > 11
        if GetLocalPlayer() == Player(counter) then
            call SetCameraPosition(camerax + 1,cameray + 1)
        endif
        set counter = counter + 1
    endloop
    call TriggerSleepAction(0)
    call PauseGame(false)
    set counter = 0
    loop
        exitwhen counter > 11
        if GetLocalPlayer() == Player(counter) then
            set x = GetCameraTargetPositionX()
            if x == camerax + 1 then
                set output = true
            else
                set output = false
            endif
            call SetCameraPosition(camerax,cameray)
        endif
        set counter = counter + 1
    endloop
    return output
endfunction

Which goes 0-11 rather than 1-12, makes more sense reading wise, but other than that it's fine. And yes, you really should indent like the rest of the known universe (but that's a few key stroke for anyone importing it).

Approved
__________________
Quote:
Originally Posted by Earth-Fury
Griffen is correct, you are not.
Quote:
[13:32] <Akolyt0r> hmm.. stil i want to have some unused women
Captain Griffen is offline   Reply With Quote
Old 07-04-2008, 01:10 AM   #8
PandaMine
Panda > You
 
PandaMine's Avatar
 
Join Date: May 2006
Posts: 500

Submissions (4)

PandaMine has a spectacular aura about (96)PandaMine has a spectacular aura about (96)PandaMine has a spectacular aura about (96)PandaMine has a spectacular aura about (96)

Send a message via MSN to PandaMine
Default

Actually the version in AMHS is indented, this is the code I copied from another site

The indentation is fixed and the counter goes properly from 0-11 instead of 1-12 (it was a silly habit I developed when I wen't from GUI to JASS)
__________________
PandaMine's Creations:

Last edited by PandaMine : 07-04-2008 at 01:14 AM.
PandaMine is offline   Reply With Quote
Old 07-04-2008, 10:49 AM   #9
Captain Griffen
Dread Lord of the Cookies
 
Captain Griffen's Avatar


Content Director
 
Join Date: Sep 2003
Posts: 5,368

Submissions (2)

Captain Griffen is a glorious beacon of light (497)Captain Griffen is a glorious beacon of light (497)Captain Griffen is a glorious beacon of light (497)Captain Griffen is a glorious beacon of light (497)Captain Griffen is a glorious beacon of light (497)

Approved Map: Warlords[Quicksilver #2] - 1st Place

Default

Great. Well, I can confirm that, assuming there isn't some strange and ellusive bug in this particularly function which hasn't appeared yet, that it works great; been using a very similar function in Warlords for ages, and it's pretty nifty.

As much as I hate to say it, credit probably more has to go to toadcop than me, since he noticed that the GetCamera___ functions differed from replay to normal; I just sort of put all the clues from other people together.
__________________
Quote:
Originally Posted by Earth-Fury
Griffen is correct, you are not.
Quote:
[13:32] <Akolyt0r> hmm.. stil i want to have some unused women
Captain Griffen is offline   Reply With Quote
Old 07-05-2008, 05:56 PM   #10
ThomasEddington
User
 
ThomasEddington's Avatar
 
Join Date: Jul 2008
Posts: 1

ThomasEddington has little to show at this moment (0)

Default

This may seem like a dumb question, but...what kind of situation would require me to know if I am playing a game or watching a replay? Is this something that applies to battle.net users? (I have never used battle.net)
ThomasEddington is offline   Reply With Quote
Old 07-05-2008, 09:04 PM   #11
Vexorian
Free Software Terrorist
 
Vexorian's Avatar


Technical Director
 
Join Date: Apr 2003
Posts: 14,905

Submissions (37)

Vexorian has a reputation beyond repute (1060)Vexorian has a reputation beyond repute (1060)Vexorian has a reputation beyond repute (1060)Vexorian has a reputation beyond repute (1060)Vexorian has a reputation beyond repute (1060)Vexorian has a reputation beyond repute (1060)Vexorian has a reputation beyond repute (1060)

Hero Contest #3 - 2nd Place

Default

Perhaps you want some debug messages to appear during a replay and not otherwise?
__________________
Zoom (requires log in)Wc3 map optimizer 5.0
Someone should fix .wav sound in this thing.
Zoom (requires log in)JassHelper 0.A.2.A
Turns your simple code into something that is complicated enough to work.
Faster != more useful
Vexorian is offline   Reply With Quote
Old 07-05-2008, 09:26 PM   #12
Captain Griffen
Dread Lord of the Cookies
 
Captain Griffen's Avatar


Content Director
 
Join Date: Sep 2003
Posts: 5,368

Submissions (2)

Captain Griffen is a glorious beacon of light (497)Captain Griffen is a glorious beacon of light (497)Captain Griffen is a glorious beacon of light (497)Captain Griffen is a glorious beacon of light (497)Captain Griffen is a glorious beacon of light (497)

Approved Map: Warlords[Quicksilver #2] - 1st Place

Default

Or greater indepth info on screen for watching replays (obviously you don't want to give all that info to players while in game; that'd be silly).
__________________
Quote:
Originally Posted by Earth-Fury
Griffen is correct, you are not.
Quote:
[13:32] <Akolyt0r> hmm.. stil i want to have some unused women
Captain Griffen is offline   Reply With Quote
Old 07-07-2008, 02:25 AM   #13
PandaMine
Panda > You
 
PandaMine's Avatar
 
Join Date: May 2006
Posts: 500

Submissions (4)

PandaMine has a spectacular aura about (96)PandaMine has a spectacular aura about (96)PandaMine has a spectacular aura about (96)PandaMine has a spectacular aura about (96)

Send a message via MSN to PandaMine
Default

One really handy use could be, as you well know when viewing replays you don't see that green arrow that comes up when a unit is ordered to move to a point

With this system you could add that in replays, to show that green arrow whenever a unit moves to a spot for that player in focus
__________________
PandaMine's Creations:
PandaMine is offline   Reply With Quote
Old 09-30-2008, 07:38 PM   #14
Troll-Brain
User
 
Join Date: Oct 2006
Posts: 1,490

Submissions (1)

Troll-Brain has a spectacular aura about (134)

Default

Quote:
There might be a second version of the function that doesn't use up a pause (discovered by Strilanc)

Do you have one ?
__________________
Cool != Useful
Troll-Brain is offline   Reply With Quote
Old 11-05-2008, 04:09 AM   #15
Builder Bob
User
 
Join Date: Oct 2007
Posts: 11

Builder Bob has little to show at this moment (0)

Default

Great system. It's really useful for preventing certain cinematic fade out/in as well as forced camera changes when watching replays.

Why do you need the loops and the GetLocalPlayer() checks though. They seem kind of redundant since GetCamera/SetCamera functions give local returns and output anyway. Maybe there's something I'm missing.

Last edited by Builder Bob : 11-05-2008 at 04:10 AM.
Builder Bob is offline   Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off


All times are GMT. The time now is 02:57 PM.


Donate

Affiliates
The Hubb http://bylur.com - Warcraft, StarCraft, Diablo and DotA Blog & Forums The JASS Vault Clan WEnW Campaign Creations Clan CBS GamesModding Flixreel Videos

Powered by vBulletin (Copyright ©2000 - 2014, Jelsoft Enterprises Ltd).
Hosted by www.OICcam.com
IT Support and Services provided by Executive IT Services