Page 1 of 7 123 ... LastLast
Results 1 to 10 of 68

Thread: Anti-Door Block

  1. #1

    Default Anti-Door Block

    Serverside mod to prevent doorblocking
    Based off some code from modtheater (think it may have been Elgan?)

    Update 08 June 10

    Ive packaged up the scripts into a pk3 that runs on each of the maps.
    Ive also compiled and uploaded my program for getting the coordinates from Radian, so you can use them to create anti-doorblocks for custom maps.

    Readme:
    Code:
    MoH:AA Anti-Doorblock
    Version 1.0 - 04/06/10
    
    Serverside mod to prevent doorblocking
    Based off some code from modtheater (think it may have been Elgan?)
    
    ZzZzZzZz-Doorblock.pk3 Contains anti-doorblock scripts for:
    	dm/mohdm1
    	dm/mohdm4
    	dm/mohdm7
    	obj/obj_team2
    	obj/obj_team3
    	obj/obj_team4
    
    These havnt really been tested particularly much, so some may not work properly.
    If there are any bugs or you have any suggestions contact me at: mail@stranter.co.uk
    
    ______________________________________________________________________________________________
    
    Creating your own doorblock script for a custom map:
    
    
    Locate the custom map's .bsp and .scr file
    	For example in user-obj_canal.pk3 in the maps/obj/ folder you will see
    	the two files that are needed
    Using mohbsptomohmap.exe (in the zip) convert the .bsp file to a .map file
    Using Radiant (http://www.filefront.com/4603757/MOH-Radiant/) open the .MAP file you just converted
    In radiant click "Edit -> Entity info..." in the top menu strip
    Run MOHRadiant Coord Grabber.exe
    It will print out a list of doors coordinates from Radiant
    Copy the coordinates out of the console program (Right click->Mark, select the text, then press Enter)
    
    Next open "blank_doorblock_script.scr" (In the zip)
    Paste the coordinates you just copied over the line that says:
    	//Put the coordinates from the program here
    And you can update the header comment 
    	MAP NAME HERE - e.g. dm/mohdm1
    with the map name, if you wish.
    Now save that .scr file as a new file with a sensible name
    	For example if my map was obj_canal, obj_obj_canal.scr may be a good filename
    Now you need to open the .scr file that you extracted from the custom maps pk3 file
    In that search for the line "exec global/DMprecache.scr"
    Underneith that line add the following code:
    	
    	//*** Doorblock Fix
    	exec global/doorblock/file_you_made.scr
    
    Where you replace "file_you_made" with the file you saved above (from blank_doorblock_script.scr)
    Save that file.
    Now put the file you just saved into "ZzZzZzZz-Doorblock.pk3/maps/type/" Where /type/ is obj or dm,
    depending on what your map is
    Put the "file_you_made" (from blank_doorblock_script.scr) into "ZzZzZzZz-Doorblock.pk3/global/doorblock/"
    folder, now, upload the pk3 to your server, and doorblocking *should* work for that map.
    If not, try modifying the coordinates, or the bounds of the trigger.
    As stated above, for any help, contact at: mail@stranter.co.uk

    Downloads:
    Whole package [pk3, coord grabber, mohbsp2map] - stranter.co.uk/proj/MOHAA/Anti-Doorblock/ZzZzZzZz-Doorblock.zip
    pk3 - stranter.co.uk/proj/MOHAA/Anti-Doorblock/ZzZzZzZz-Doorblock.pk3
    Radiant coordinate grabber source - stranter.co.uk/proj/MOHAA/Anti-Doorblock/MOHRadiant%20Coord%20Grabber.cpp
    Last edited by stranter; June 8th, 2010 at 02:05 PM.

  2. #2
    Administrator JoTo's Avatar
    Join Date
    May 2010
    Location
    www.scapp.net
    Posts
    1,953

    Default

    very nice

  3. #3
    Administrator James's Avatar
    Join Date
    May 2010
    Location
    on the intraweb
    Posts
    3,180

    Default

    Wow excellent post. Can't say I saw this before, but WOW.

    I will post the source here as well so it's more convinient.
    Code:
    // MOHRadiant Coord Grabber.cpp : Defines the entry point for the console application.
    //
    
    #include "stdafx.h"
    #include "windows.h"
    #include "commctrl.h"
    #include <iostream>
    
    using namespace std;
    
    bool setDebug() {
        HANDLE hToken;
        if(OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken)) {
            TOKEN_PRIVILEGES tp;
            LUID luid;
            TOKEN_PRIVILEGES tpPrevious;
            DWORD cbPrevious = sizeof(TOKEN_PRIVILEGES);
            if(LookupPrivilegeValue(NULL, SE_DEBUG_NAME, &luid)) {
                tp.PrivilegeCount = 1;
                tp.Privileges[0].Luid = luid;
                tp.Privileges[0].Attributes = 0;
                if(AdjustTokenPrivileges(hToken, FALSE, &tp, sizeof(TOKEN_PRIVILEGES), &tpPrevious, &cbPrevious)) {
                    tpPrevious.PrivilegeCount = 1;
                    tpPrevious.Privileges[0].Luid = luid;
                    tpPrevious.Privileges[0].Attributes |= (SE_PRIVILEGE_ENABLED);
                    if(AdjustTokenPrivileges( hToken, FALSE, &tpPrevious, cbPrevious, NULL, NULL )) {
                        CloseHandle(hToken);
                        return true;
                    }
                }
            }
        }
        CloseHandle(hToken);
        return false;
    }
    
    void err(const char * msg) {
        cout << msg << endl << endl;
        system("PAUSE");
    }
    
    //Magic in here...
    void crazything(wchar_t * lol) {
        wchar_t tmp[255];
        wcscpy_s(tmp, lol);
        wchar_t * tok = wcstok(tmp, L" ");
        while( wcstok(NULL, L" ") != NULL ) {
            tok = wcstok(NULL, L" ");
        }
        short c = 0;
        wcout << "( ";
        for(UINT i=0; i < wcslen(lol); i++) {
            if(lol[i] == 32) {
                if(++c==2) {
                    break;
                }
            }
            wcout << lol[i];
        }
        wcout << " " << _wtoi(tok) - 64 << " ) ";
    }
    
    int _tmain(int argc, _TCHAR* argv[])
    {
        //Set debug privelages to prevent any access errors
        setDebug();
        cout << "Ensure that the Entities window is open in Radiant\n(Edit->Entity Info)\n--------------------------\n";
        HWND hwnd=FindWindow(NULL, L"Entities");
        //Check that the Entities window is open
        if(!hwnd) {
            err("Entitys window not found");
            return 1;
        }
    
        HWND listview=FindWindowEx(hwnd, NULL, L"SysListView32", NULL);
        HWND treeview=FindWindowEx(hwnd, NULL, L"SysTreeView32", NULL);
        //Check we have a treeview and a list view
        if(!listview || !treeview) {
            err("Entitys window dosnt contain required controls");
            return 1;
        }
    
        DWORD pID;
        GetWindowThreadProcessId(treeview, &pID);
        HANDLE hProcess = OpenProcess(PROCESS_ALL_ACCESS, false, pID);
        //Open Radiant process
        if(!hProcess) {
            err("Error opening process");
            return 1;
        }
    
        DWORD tvRemoteBuffer = (DWORD)::VirtualAllocEx(hProcess, NULL, 335, MEM_COMMIT, PAGE_READWRITE);
        //Allocate tvnode memory
        if(!tvRemoteBuffer) {
            CloseHandle(hProcess);
            err("Error allocating memory");
            return 1;
        }
            
        //Assume that all memory allocating will work since i cba to write more if's
        LVITEM * lvRemoteBuffer=(LVITEM*)VirtualAllocEx(hProcess, NULL, sizeof(LVITEM), MEM_COMMIT, PAGE_READWRITE);
        wchar_t * key=(wchar_t*)VirtualAllocEx(hProcess, NULL, 255, MEM_COMMIT, PAGE_READWRITE);
    
        HTREEITEM Root = (HTREEITEM)SendMessage(treeview, TVM_GETNEXTITEM, TVGN_ROOT, 0);
        bool foundDoor = false;
        wchar_t * msg = L"func_rotatingdoor";
        int doorCount = 0;
        //Parse nodes in treeview
        while(Root) {
            TVITEM tvItem;
            tvItem.mask = TVIF_TEXT;
            tvItem.hItem = Root;
            tvItem.pszText = (LPWSTR)tvRemoteBuffer + sizeof(TVITEM);
            tvItem.cchTextMax = 255;
            //Write treeview to external buffer
            if(WriteProcessMemory(hProcess, (LPVOID)tvRemoteBuffer, (LPCVOID)&tvItem, sizeof(TVITEM), 0)) {
                //Load the item to the buffer
                SendMessage(treeview, TVM_GETITEM, 0, tvRemoteBuffer);
                wchar_t bytRtn[255];
                int rAdd = tvRemoteBuffer + sizeof(TVITEM)*2;
                //Read the text
                if(ReadProcessMemory(hProcess, (LPCVOID)rAdd, (LPVOID)&bytRtn, 255, 0)) {
                    //Check if its a door!
                    if(wcscmp(bytRtn, msg) == 0) {
                        if(!foundDoor) {
                            //Found the root door node
                            SendMessage( treeview, TVM_SELECTITEM, TVGN_CARET, (LPARAM)Root );
                            SendMessage( treeview, TVM_EXPAND, TVE_EXPAND, (LPARAM)Root );
                            foundDoor = true;
                        } else {
                            //Found a child door node
                            SendMessage( treeview, TVM_SELECTITEM, TVGN_CARET, (LPARAM)Root );
                            doorCount++;
                            
                            //Get listview stuff now
                            LVITEM lvi;
                            lvi.cchTextMax=255;
                            int count=(int)SendMessage(listview, LVM_GETITEMCOUNT, 0, 0);
                            wchar_t gots[255];
                            char got = 0;
                            //Loop through listview items
                            for(int i=0; i<count; i++) {
                                lvi.iSubItem=0;
                                lvi.pszText=key;
                                WriteProcessMemory(hProcess, lvRemoteBuffer, &lvi, sizeof(LVITEM), NULL);
                                SendMessage(listview, LVM_GETITEMTEXT, (WPARAM)i, (LPARAM)lvRemoteBuffer);
                                ReadProcessMemory(hProcess, key, bytRtn, 255, NULL);
                                //Find the nodes
                                if(wcscmp(bytRtn, L"origin") == 0 || wcscmp(bytRtn, L"angle") == 0) {
                                    //Read the value
                                    lvi.iSubItem=1;
                                    lvi.pszText=key;
                                    WriteProcessMemory(hProcess, lvRemoteBuffer, &lvi, sizeof(LVITEM), NULL);
                                    SendMessage(listview, LVM_GETITEMTEXT, (WPARAM)i, (LPARAM)lvRemoteBuffer);
                                    ReadProcessMemory(hProcess, key, bytRtn, 255, NULL);
                                    if(got != 0)
                                        break;
                                    else
                                        wcscpy_s(gots, bytRtn);
                                    got = wcscmp(bytRtn, L"origin") == 0 ? 1 : 2;
                                }                        
                            }
                            
                            //How the hell am i supposed to do this?
    
                            
                            if (wcscmp(bytRtn, gots) == 0) {
                                crazything(bytRtn);
                                wcout << "0" << endl;    
                            } else if(got == 1) { 
                                crazything(gots);
                                wcout << bytRtn << endl;    
                            } else if(got == 2) {
                                crazything(bytRtn);
                                wcout << gots << endl;    
                            }
                        }
                    } else {
                        //All doors found
                        if(foundDoor) {
                            cout << "Number of doors found: " << doorCount << endl;
                            break;
                        }
                    }
                }
                Root = (HTREEITEM)SendMessage(treeview, TVM_GETNEXTITEM, TVGN_NEXTVISIBLE, (LPARAM)Root);
            }
        }
        VirtualFreeEx(hProcess, (LPVOID)tvRemoteBuffer, 335, MEM_RELEASE);
        VirtualFreeEx(hProcess, lvRemoteBuffer, 0, MEM_RELEASE);
        VirtualFreeEx(hProcess, key, 0, MEM_RELEASE);
        CloseHandle(hProcess);
        err("Success");
    
        return 0;
    }

  4. #4
    Administrator JoTo's Avatar
    Join Date
    May 2010
    Location
    www.scapp.net
    Posts
    1,953

    Default

    yes, it works flawlessly and excellent, can be live checked here: 94.228.218.182:12204 | *V2* Sniper-Only | Sponsored By RJ Hosting^

  5. #5

    Default

    Also got this running on my server, though in pk3 form, cause I wasn't allowed to use scr file. Only bug that it has is that when the round is over, and you happen to be at a door, and the game restarts as soon as you started spinning / doorblocking the last round, you keep spinning and spinning and spinning the next round hehe.
    So it can be checked out here aswell: 89.18.168.129:12208 Public V2 Sniper Only - Powered by [(UW)]

  6. #6

    Default

    Updated first post with downloads, and a more detailed tutorial on how to create your own scripts. For any help feel free to contact.
    I do intend to work in this further, but I cant yet work out a better way to do it. Next version will include a cvar for enabling/disabling doorblocking (e.g. rcon anti_dooblock 1/0)

  7. #7

  8. #8
    Developer Sor's Avatar
    Join Date
    Aug 2010
    Location
    The Medieval City of Bruges
    Posts
    747

    Default

    Is it possible to get the coords from the bsp? Doesn't need a conversion to map for it to work.
    I know you can find the coords (as well as classname, angles etc..) in the bsp if you open it with wordpad.

    Should look something like this:
    Code:
    {
    "model" "*1"
    "origin" "-482 888 446"
    "angle" "90"
    "time" "0.8"
    "alwaysaway" "1"
    "classname" "func_rotatingdoor"
    "spawnflags" "0"
    "wait" "1.0"
    }
    {
    "model" "*2"
    "origin" "-264 534 456"
    "angle" "180"
    "time" "0.8"
    "alwaysaway" "1"
    "classname" "func_rotatingdoor"
    "spawnflags" "0"
    "wait" "1.0"
    }
    etc...
    I hope this is helpful.

  9. #9

    Default

    Hi Guys,

    My server is running "Capture the flag" Mod, when I try to use the Anti-Door Block Mod it resets my game type to just a standard objective. Anyone have any ideas as to how to retain my game type whilst being able to use this MOD?

    Thanks

  10. #10

    Default

    I am guessing but could be load order try reordering by adding more zzzzz's but not sure which should load first.....................

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •