|
|
#1 |
|
User
|
JASS:library GameStatus initializer Ini /* GameStatus 2.0 by Bribe, special thanks to Troll-Brain Check if a game is single-player online or is a single-player replay. Due to Warcraft 3 limitations there is no known bugfree way to detect a multi- player replay. Even if you start a timer, pause the game, wait 0 seconds and unpause the game, the timer will show 0.025 elapsed for both online games and for re- plays. However, the main thing you need to detect is when the game is single- player, which means it's possible for the user to cheat. If you are doing an RPG and the user wants to play it single-player, the player can do it by selecting "LAN" as the method of play which doesn't even require an Internet connection. This way he/she can progress through the story line without needing other players and without you risking the player cheating. function IsGameSinglePlayer takes nothing returns boolean Returns true if the game is single player, where cheat codes can be used. This can be called during map initialization reliably. function OnGameStatusFound takes string func returns nothing Executes the function when the game's status has been detected. The 2 functions "IsGameOnline" and "IsGameReplay" cannot be used reliably from an initializer, you must wait for this function to run first. function IsGameOnline takes nothing returns boolean Returns true if the game is being played over a network or a replay from a network game. function IsGameReplay takes nothing returns boolean Returns true if the game is a single-player replay. I have not been able to find a bug-free way to detect a replay from a game which was played online. */ globals //If RGCFD returns true, cheat codes can be used (it's a non-network //single-player game). private integer iGame = IntegerTertiaryOp(ReloadGameCachesFromDisk(), 0, 1) private integer n = 0 private string array funcs endglobals //======================================================================= function IsGameOnline takes nothing returns boolean return iGame == 2 endfunction //======================================================================= function IsGameReplay takes nothing returns boolean return iGame == 1 endfunction //======================================================================= function IsGameSinglePlayer takes nothing returns boolean return iGame == 0 endfunction //======================================================================= function OnGameStatusFound takes string func returns nothing set funcs[n] = func set n = n + 1 endfunction //======================================================================= /* private */ function GameStatus___aDs0F83254K43593Jfs takes nothing returns nothing call TriggerSleepAction(0) loop set n = n - 1 exitwhen n < 0 call ExecuteFunc(funcs[n]) endloop endfunction //======================================================================= private function Ini takes nothing returns nothing call ExecuteFunc("GameStatus___aDs0F83254K43593Jfs") if iGame > 0 then //Replays ignore any thread-sleep type things which were not in //the original game - thus this is perfect for detecting a single- //player replay. TriggerSyncReady fires before TriggerSleepAction. call TriggerSyncReady() set iGame = 2 endif endfunction endlibrary Last edited by Bribe : 11-14-2011 at 06:42 AM. |
|
|
|
| Sponsored Links - Login to hide this ad! |
|
|
|
|
#2 |
|
Procrastination Incarnate
Development Director
|
|
|
|
|
|
|
#3 |
|
User
|
If ReloadGameCachesFromDisk returns false, both will be false. I did that comparison just to avoid creating a third global.
I will look into adding an "OnGameStart" function. |
|
|
|
|
|
#4 |
|
Procrastination Incarnate
Development Director
|
I tested it and it works for single player, but I still don't understand why it works. Looking at the code, the last thing you do is set online = not replay in the timer expiration function, you don't modify the variables after that, so I don't see how they can both be false, but they can.
__________________However, in my test, I did not get correct results when testing replays. The game was detected as online. The whole replay also started a few seconds into the game for some reason, not sure if that's normal. Last edited by Anitarf : 11-05-2011 at 10:04 AM. |
|
|
|
|
|
#5 |
|
User
|
Replays have always started a few seconds into the game.
Unfortunately there is a selection-event delay for replays the same as it works for online. I have almost completed a suitable alternative using a mix of a wait, game pause and a timer (as TriggerSleepAction is supposed to run during a paused game but a timer not, and replays react differently with paused games). However, I have run out of time today and have to continue this project tomorrow |
|
|
|
|
|
#6 |
|
obey
|
replay cannot be paused.
usage of triggersleep (that will run ever when game is paused) and pause and timer will allow to detect pause state\event and forcepause will allow you to detect replay, in replay game cannot be paused at all. |
|
|
|
|
|
#7 |
|
User
|
However I have tried it with timer and the timer is running anyway. Even through a paused game with TriggerSleepAction. However I will try it again adjusting this thing or that. But what I can say is a 0-second timer expires anyway, despite the game being paused. It's so weird.
|
|
|
|
|
|
#8 |
|
User
|
Timers, paused games, selection event delays, all these things perform the same whether it's a replay or if it's an online game.
The main thing to detect is if a game can use cheats, which is already established via "ReloadGameCachesFromDisk()". There is a way to determine if a game is a replay FROM a single player non-network game which I discovered by accident, however I can't get the difference between a network game and a replay of a network game. The only hope is that the "igamestate" type can be used for something relevant here. |
|
|
|
![]() |
| Thread Tools | Search this Thread |
|
|
|
Donate |