Author Topic: Nerd's Corner  (Read 78996 times)

Offline shesycompany

  • Death Knight
  • *********
  • Posts: 3587
  • retired, be in music section
    • View Profile
Re: Nerd's Corner
« Reply #165 on: May 02, 2019, 09:40:57 AM »
im not seeing the map as a host?  installed to 2.02 bnet and created tvb

Offline Lambchops

  • Ogre Mage
  • ********
  • Posts: 1541
    • View Profile
Re: Nerd's Corner
« Reply #166 on: May 02, 2019, 09:51:34 AM »
im not seeing the map as a host?  installed to 2.02 bnet and created tvb


--- edit ---


This problem fixed with v0.1.2

( was an issue with custom ddraw )
« Last Edit: May 23, 2019, 09:16:52 PM by Lambchops »
its gooder to hax hard and NEVER get caught!

Offline shesycompany

  • Death Knight
  • *********
  • Posts: 3587
  • retired, be in music section
    • View Profile
Re: Nerd's Corner
« Reply #167 on: May 02, 2019, 10:07:26 AM »
win7 here ...yeah redone it to my ru version thats outside program files...still not getting to display.

its more than likely me ..need another machine to test.
« Last Edit: May 02, 2019, 10:19:11 AM by easycompany »

Offline shesycompany

  • Death Knight
  • *********
  • Posts: 3587
  • retired, be in music section
    • View Profile
Re: Nerd's Corner
« Reply #168 on: May 02, 2019, 10:42:04 AM »
yup lc and lamb   wait and let someone else test my machine is a known pos..blue screens the works

Offline shesycompany

  • Death Knight
  • *********
  • Posts: 3587
  • retired, be in music section
    • View Profile
Re: Nerd's Corner
« Reply #169 on: May 03, 2019, 10:24:28 AM »
what os you on lamb?  ive tried everything u said still zip.

Offline Certified MENSA Genius Brain (smart)

  • "The Architect"
  • Global Moderator
  • Dragon
  • *****
  • Posts: 5384
    • View Profile
Re: Nerd's Corner
« Reply #170 on: May 03, 2019, 10:40:38 AM »
Have you ever seen that program that automatically generates a new map?  That would be a cool plug-in, host runs it and it generates the map and then you host, and instead of showing the thumbnail preview it shows a big "?" and everyone has to explore, because nobody has seen it...
    

Offline shesycompany

  • Death Knight
  • *********
  • Posts: 3587
  • retired, be in music section
    • View Profile
Re: Nerd's Corner
« Reply #171 on: May 03, 2019, 11:08:31 AM »
warcraft 2 randomizer

Offline Lambchops

  • Ogre Mage
  • ********
  • Posts: 1541
    • View Profile
Re: Nerd's Corner
« Reply #172 on: May 03, 2019, 11:28:02 AM »
Have you ever seen that program that automatically generates a new map?  That would be a cool plug-in, host runs it and it generates the map and then you host, and instead of showing the thumbnail preview it shows a big "?" and everyone has to explore, because nobody has seen it...

Yeah that would be cool. You could make a plugin that makes a random map and hosts it, but people could still look at the pud file and cheat...

Have you tested the plugin framework yet? :)

its gooder to hax hard and NEVER get caught!

Offline Lambchops

  • Ogre Mage
  • ********
  • Posts: 1541
    • View Profile
Re: Nerd's Corner
« Reply #173 on: May 19, 2019, 10:29:26 AM »
im not seeing the map as a host?



Turns out the updated ddraw.dll that a lot of people are using is great for the game but is missing most of the standard Windows API functionality so the methods I was using to display things on the screen were not working with that.

V0.1.2 Hooks the WC2 internal screen update so is compatible with all direct draw versions.

V0.1.3 Has fixed compatibility issues with later versions of windows.


Have updated THIS post with the new version.


Please Test :)



« Last Edit: June 05, 2019, 10:11:31 PM by Lambchops »
its gooder to hax hard and NEVER get caught!

Offline Lambchops

  • Ogre Mage
  • ********
  • Posts: 1541
    • View Profile
Re: Nerd's Corner
« Reply #174 on: June 13, 2019, 02:39:32 AM »

Mini-Map Black to Grey Plugin

Changes the mini-map display color for the black player to a lighter shade of grey.


This is a very simple plugin that just changes 1 byte in the wc2 process, heres the source:

Code: [Select]
#include <windows.h>

// export a "w2p_init()" function this will run once when wc2 loads


extern "C" __declspec (dllexport) void w2p_init(){       
       
    // declare a pointer to a BYTE
    BYTE* bytePointer;
     
    // make it point to the mini-map black location
    bytePointer = (BYTE*)0x4A48B1;
   
    // set the byte to grey (0xEA)
    *bytePointer = 0xEA;   
    //   ...could also use
    //   - 0xFD Bright Pink
    //   - 0xDE Dark Purple
    //   - 0xD2 Dark Red
    //   - 0xE3 Dark OJ
 
   
}

BOOL APIENTRY DllMain (  HINSTANCE hInst, DWORD reason, LPVOID reserved ){ return TRUE; }



Just build that as a DLL file then change the filename from .dll to .w2p and put it in the "plugin" folder.

This source can be easily modified to test other mods also if you want.



its gooder to hax hard and NEVER get caught!

Offline Delete mine too

  • Death Knight
  • *********
  • Posts: 2652
  • http://meatspin.com
    • View Profile
    • http://meatspin.com
Re: Nerd's Corner
« Reply #175 on: June 13, 2019, 08:56:24 PM »

Mini-Map Black to Grey Plugin

Changes the mini-map display color for the black player to a lighter shade of grey.


This is a very simple plugin that just changes 1 byte in the wc2 process, heres the source:

Code: [Select]
#include <windows.h>

// export a "w2p_init()" function this will run once when wc2 loads


extern "C" __declspec (dllexport) void w2p_init(){       
       
    // declare a pointer to a BYTE
    BYTE* bytePointer;
     
    // make it point to the mini-map black location
    bytePointer = (BYTE*)0x4A48B1;
   
    // set the byte to grey (0xEA)
    *bytePointer = 0xEA;   
    //   ...could also use
    //   - 0xFD Bright Pink
    //   - 0xDE Dark Purple
    //   - 0xD2 Dark Red
    //   - 0xE3 Dark OJ
 
   
}

BOOL APIENTRY DllMain (  HINSTANCE hInst, DWORD reason, LPVOID reserved ){ return TRUE; }



Just build that as a DLL file then change the filename from .dll to .w2p and put it in the "plugin" folder.

This source can be easily modified to test other mods also if you want.





Any functionality to draw to warcraft 2 screen? What about an array of bytes sample also. It would then be perfect to project! Thanks brother.

Offline Lambchops

  • Ogre Mage
  • ********
  • Posts: 1541
    • View Profile
Re: Nerd's Corner
« Reply #176 on: June 13, 2019, 10:41:59 PM »

Any functionality to draw to warcraft 2 screen? What about an array of bytes sample also. It would then be perfect to project! Thanks brother.


Yeah sure. Sorry not finding much time to document all of this.... still working 6 days a week ( and sleeping 1 day )

For an array of bytes, you can just declare the array in your source then use memcpy or CopyMemory etc. Will try to do an example later, but you can probably work that out.

Here's the game timer plugin. It demonstrates writing a string on a bitmap, then pasting that bitmap to the wc2 screen inside the display hook.

... uses:

paste_string(clock,0,0,&clockbuf[0],4,CLOCK_COLOR);

clock is the bitmap handle
(0,0) is target co-ords on the bitmap
&clockbuf[0] is the source ANSI string
4 is the font size (only supports 4 and 6 currently)
CLOCK_COLOR is the pixel value to set on the bitmap

this is done once per second to update the bitmap, then in the sccreen display hook it uses:

wc2_trans_paste(clock,CLOCK_X,CLOCK_Y);

to paste the "clock" bitmap onto the screen buffer at co-ords (CLOCK_X,CLOCK_Y)
(assumes 0 pixels are transparent)

These functions are exported from LC.dll
Have a look at lamb.h and lamb.cpp for others

Will try to document these further later.



dllmain.cpp
Code: [Select]
                                                         //
     /////////////////////////////////////////////////////
    //   Example dll for Warcraft II plugin framework  //
   /////////////////////////////////////////////////////
  //                                    Lambchops 2019
 


// *** This is a poor way of implementing a game timer.
// Shoud really be re-written to use GetSystemTime() or similar,
// but it makes for a simple example this way.


#include <windows.h>
#include <lamb.h>

// constants for the in-game screen
#define LOC_INGAME_H 1684300900
#define LOC_INGAME_O 2155905153


// display the timer here
// * using the top of mini-map to guarantee that this part
// of the screen is updated every second *
#define CLOCK_X         22
#define CLOCK_Y         24


// color for pixels on timer bitmap
#define CLOCK_COLOR   0xFE


BOOL game_timer_on = FALSE;

// count the number of game ended signals
BOOL tick_out = 0;



int  game_secs  = 0;
int  game_mins  = 0;
int  game_hours = 0;
int  game_days  = 0;

// allocate a buffer to store timer as a string
CHAR clockbuf[16];

// create a little 32x6 bitmap to draw timer string on to
HMIBMP* clock = make_bitmap(32,6,8);

// temp storage for game "location" value supplied
// to "screen_update()" by the framework
DWORD loc;



BOOL in_game(){
    // return TRUE if we are in a game
    return (loc==LOC_INGAME_H||loc==LOC_INGAME_O);
}


void reset_timer(){
    tick_out  = 0;
    game_secs = -1;
    game_mins = 0;
    game_hours= 0;
    game_days = 0;     
}

void game_tick(){
    // add 1 second to game time

    game_secs++;
    if(game_secs==60){
        game_secs=0;
        game_mins++;
        if(game_mins==60){
            game_mins=0;
            game_hours++;
            if(game_hours==24){
                game_hours=0;
                game_days++;
            }
        }
    }

    // redraw the timer display bitmap //

    wsprintf(&clockbuf[0],"%2.2d:%2.2d:%2.2d",game_hours,game_mins,game_secs);         
    zero_bitmap(clock);   
    paste_string(clock,0,0,&clockbuf[0],4,CLOCK_COLOR);
}


void CALLBACK TimerProc(HWND hwnd,UINT uMsg,UINT idEvent,DWORD dwTime){
    // this is called every 1 second by the system timer we set up below
   
    if(game_timer_on){
        if(in_game()){
            // update time by 1 second
            game_tick();
            tick_out = 0;
        }else{
            if(tick_out>1){
                // = 3rd miss for in_game()
                //( location constant appears to occasionally glitch on
                //  some systems - possibly a ddraw thing ?? )
                // game ended
                game_timer_on = FALSE;
            }else{
                game_tick();
                tick_out++;     
            }
        }
    }else{
        if(in_game()){
            // game started
            game_timer_on = TRUE;
            reset_timer();
            game_tick(); 
        }       
    }
}



////// EXPORTED FUNCTIONS FOR THE FRAMEWORK TO CALL ///////

// called once at startup
extern "C" __declspec (dllexport) void w2p_init(){
    // Create a timer that ticks every 1 second     
    SetTimer(NULL,0,1000,TimerProc);
}



// called every screen update
extern "C" __declspec (dllexport) void screen_update(DWORD location){
    loc=location;
    if(game_timer_on){
        // paste the time display bitmap onto the game screen ( pixel 0 = transparent )
        wc2_trans_paste(clock,CLOCK_X,CLOCK_Y);
    }
}



BOOL APIENTRY DllMain (  HINSTANCE hInst, DWORD reason, LPVOID reserved ){ return TRUE; }



lamb.h
Code: [Select]
#include <windows.h>


#ifndef _LAMB_
#define _LAMB_

extern "C" {
    typedef struct hmibmp {
        BITMAPFILEHEADER* pFile;
        BITMAPINFOHEADER* pInfo;
        RGBQUAD*          pPal;
        BYTE*             pBits;
        int               width;
        int               height;
        int               bpp;
        int               linew;
        int               usage;
        int               size;
    }HMIBMP;
}

//hmibmp.inc
extern "C" typedef HMIBMP* (__stdcall *pfnmakebmp )(int w,int h,int bpp);
extern "C" typedef void    (__stdcall *pfnfreebmp )(HMIBMP* bmp);
extern "C" typedef int     (__stdcall *pfnzerobmp )(HMIBMP* bmp);
extern "C" typedef void    (__stdcall *pfnsavebmp )(CHAR* path,HMIBMP* bmp);
extern "C" typedef void    (__stdcall *pfnsavejpg )(CHAR* path,HMIBMP* bmp,int quality);
extern "C" typedef void    (__stdcall *pfnperfbmp )(HMIBMP* bmp);
extern "C" typedef void    (__stdcall *pfncopyimg )(HMIBMP* src,int scrx,int srcy,int srcw,int scrh,HMIBMP* dst,int dstx,int dsty,int transp);
extern "C" typedef int     (__stdcall *pfncopyfull)(HMIBMP* dstbmp,HMIBMP* srcbmp,int transp);
extern "C" typedef void    (__stdcall *pfndispimg )(HDC destDC,int x,int y,int w,int h,HMIBMP* bmp,int dx,int dy,int dw,int dh);
extern "C" typedef void    (__stdcall *pfnsetpal  )(HMIBMP* bmp,LPVOID palette);
extern "C" typedef void    (__stdcall *pfndrawrect)(HMIBMP* bmp,int x,int y,int w,int h,int color);
extern "C" typedef HMIBMP* (__stdcall *pfnsizebmp )(HMIBMP* bmp,int w,int h);
extern "C" typedef HMIBMP* (__stdcall *pfnscalebmp)(HMIBMP* bmp,int scale);
extern "C" typedef void    (__stdcall *pfnsetpixel)(HMIBMP* bmp,int x,int y,int pval);
extern "C" typedef void    (__stdcall *pfnpastestr)(HMIBMP* bmp,int x,int y,CHAR* lpsz,int point,int color);
extern "C" typedef void    (__stdcall *pfnwc2tpast)(HMIBMP* bmp,int x,int y);


extern pfnmakebmp      make_bitmap;
extern pfnfreebmp      free_bitmap;
extern pfnzerobmp      zero_bitmap;
extern pfnsavebmp      save_bitmap;
extern pfnsavejpg      save_jpeg;
extern pfnperfbmp      perforate_bitmap;
extern pfncopyimg      copy_image;
extern pfncopyfull     copy_full_image;
extern pfndispimg      display_image;
extern pfnsetpal       set_palette;
extern pfndrawrect     draw_rect;
extern pfnsizebmp      size_bitmap;
extern pfnscalebmp     scale_bitmap;
extern pfnsetpixel     set_pixel;
extern pfnpastestr     paste_string;
extern pfnwc2tpast     wc2_trans_paste;

#endif

lamb.cpp

Code: [Select]
#include <windows.h>
#include <lamb.h>


HMODULE hLambDll = LoadLibraryA("LC");

pfnmakebmp  make_bitmap         = (pfnmakebmp )GetProcAddress(hLambDll, "make_bitmap"         );
pfnfreebmp  free_bitmap         = (pfnfreebmp )GetProcAddress(hLambDll, "free_bitmap"         );
pfnzerobmp  zero_bitmap         = (pfnzerobmp )GetProcAddress(hLambDll, "zero_bitmap"         );
pfnsavebmp  save_bitmap         = (pfnsavebmp )GetProcAddress(hLambDll, "save_bitmap"         );
pfnsavejpg  save_jpeg           = (pfnsavejpg )GetProcAddress(hLambDll, "save_jpeg"           );
pfnsizebmp  size_bitmap         = (pfnsizebmp )GetProcAddress(hLambDll, "size_bitmap"         );
pfnscalebmp scale_bitmap        = (pfnscalebmp)GetProcAddress(hLambDll, "scale_bitmap"        );
pfnperfbmp  perforate_bitmap    = (pfnperfbmp )GetProcAddress(hLambDll, "perforate_bitmap"    );
pfncopyimg  copy_image          = (pfncopyimg )GetProcAddress(hLambDll, "copy_image"          );
pfncopyfull copy_full_image     = (pfncopyfull)GetProcAddress(hLambDll, "copy_full_image"     );
pfndispimg  display_image       = (pfndispimg )GetProcAddress(hLambDll, "display_td_image"    );
pfnsetpal   set_palette         = (pfnsetpal  )GetProcAddress(hLambDll, "set_palette"         );
pfndrawrect draw_rect           = (pfndrawrect)GetProcAddress(hLambDll, "draw_rect"           );
pfnsetpixel set_pixel           = (pfnsetpixel)GetProcAddress(hLambDll, "set_pixel"           );
pfnpastestr paste_string        = (pfnpastestr)GetProcAddress(hLambDll, "paste_string"        );
pfnwc2tpast wc2_trans_paste     = (pfnwc2tpast)GetProcAddress(hLambDll, "wc2_trans_paste"     );






« Last Edit: June 22, 2019, 07:40:27 AM by Lambchops »
its gooder to hax hard and NEVER get caught!

Offline Qanon

  • Grunt
  • ***
  • Posts: 110
    • View Profile
Re: Nerd's Corner
« Reply #177 on: June 20, 2019, 11:26:50 PM »
works noww

              Warcraft II Plugin Framework

       ( including demo plugins )
 

This will install a small file called "LC.dll" and make a few modifications to Warcraft II BNE.exe that link it.

A "plugins" folder will be created in the wc2 folder. Plugins can be placed in this folder will be automatically loaded when you run wc2.

This will allow a variety of mods to be easilly installed/uninstalled by users.

If there is nothing in the "plugins" folder, there is no change to how the game functions.

  -------------

For developers:
Spoiler
A plugin is simply a dll file that has the extension changed to "w2p".
There are currently only 3 hook points, although I may add more in the future if there is a demand.

The hook points can be accessed by exporting appropriately named functions from a plugin dll.

w2p_init has no arguments and is called when the exe is first started.

create_game will be passed a pointer to the game name and called when the player creates a game.

join_game will be passed a pointer to the game name and called when the player joins a game.

screen_update will be passed a value that describes the current game screen and will be called immediately before each screen update.

... so to make a simple plugin all you need to do is make a dll file that exports one function called "w2p_init" that takes no agruments, then rename it to "MyPlugin.w2p" or whatever and put it into the "plugins" folder. Your plugin will then be injected into the WC2 process when you next run it.

I will try to do some examples later when time allows.


   ---------



There are 4 example plugins included. If you don't want any of them, you can disable/enable them individually just by moving them in or out of the plugins folder (of course exit WC2 first then restart).





   ----------

   The "Lobby Map" plugin






The "lobby map" Plugin gives you a preview of the map in the pre-game lobby.

  -----------------


   The "Game Time" plugin





The "Game Time" plugin just adds a small game timer to the in game screen.


     --------------



   The "Chop Bars" plugin





The "Chop Bars" plugin gives you an on-screen progress bar for chopping peons that you own and are selected.


       ------------



   The "Allied Colors" plugin





The "Allied Colors" plugin give you the option of displaying all allies in blue and all enemies in red on the mini-map.
Press F2 to toggle this on/off. It is off by default.










   ----------------------



To install download the zip file and copy/replace its contents into a combat43 installation.
*Should also work for any versions earlier than 4.3 - AFAIK they all use the same wc2 .exe file.

Currently tested and working with Windows 10, 7 and XP.

  ----------------------

This is still in development, but appears to be working and stable for me .... please test! :)


Note: The plugin framework currently only supports BNE 2.02 (Combat Edition 4.3 or earlier), it does not support CE 4.4 or the GOG version. If there is a demand it can be ported at a later date.



                                                               :critter:


« Last Edit: June 21, 2019, 12:33:38 PM by Qanon »

Offline Lambchops

  • Ogre Mage
  • ********
  • Posts: 1541
    • View Profile
Re: Nerd's Corner
« Reply #178 on: June 22, 2019, 07:22:00 AM »
Timer Plugin Fix.

RandomPeasant and Warbux reported a bug where the game timer would think the game had ended and reset itself. This version appears to fix that issue.

I have updated the plugin framework zip file with the new version.

If you already have the PF installed you can just dl the attached file and put it in your plugins folder (replace the old version that is there)

its gooder to hax hard and NEVER get caught!

Offline Lambchops

  • Ogre Mage
  • ********
  • Posts: 1541
    • View Profile
Re: Nerd's Corner
« Reply #179 on: July 22, 2019, 07:42:09 AM »
                             PALETTE ANIMATION

I have idly wondered more than one about the neat water animation you see in WC2 on the coastlines. It's something I would have expected to have tripped over in the exe when looking for something else, but never have.

Turns out thats because its done with palette animation, which is pretty amazing considering how good it looks. Next time you're in game, have a look at the coast then remember that no pixels are changing at all, its just the palette.

I noticed this when messing around with changing the in-game unit graphics... some of the bits that were supposed to be brown kept turning blue, so I replaced the great hall graphics with a 128x128 palette grid and discovered that quite a bit of the wc2 palette is animated in-game. Most of it is for water effects plus entry 3 just flashes from green to red and back - which is obviously the color it uses for a unit that is being attacked on the mini-map.



The palette animation doesn't show up in warvid. Anybody ever noticed your units don't flash red on the minimap in warvid? Twitch mostly picks it up.

Anyway you can see what's going on in the attached vid, if anyone's interested.

BTW yes I am still working on an updated plugin framework...


its gooder to hax hard and NEVER get caught!