Staredit Network > Forums > Modding Discussion > Topic: General Plugin Template
General Plugin Template
May 17 2009, 8:09 pm
By: A_of-s_t  

May 17 2009, 8:09 pm A_of-s_t Post #1

aka idmontie

General Plugin Template

Open up nextFrame.cc and get to it!

v1.40 -- http://broodwarai.com/GPTP/main.htm

Post has been edited 4 time(s), last time on May 22 2009, 2:13 am by A_of-s_t.



Personal GitHub
Starcraft GitHub Organization - Feel free to request member status!
TwitchTV

May 17 2009, 8:45 pm Corbo Post #2

ALL PRAISE YOUR SUPREME LORD CORBO

Awesome, does it come with a list of variables we can call and modify or the example is the only help we'll get? :P

Also, can one use ASM__ inside the function?



fuck you all

May 17 2009, 8:48 pm A_of-s_t Post #3

aka idmontie

For the gcc compiler and .bat file, you need to use att asm:

__asm("...");

I have a tutorial somewhere about the differences between att and intel asm, I can upload it with the next version.

Check out some of the other examples given in the code itself for more help. I believe I included enough to allow people to only need to write in main.cpp. You can access buttons, units, and resource information.

EDIT:

I updated the package:

[attach=3541]

It now includes some helpful files and premade functions (see "List of Functions.txt").

Attachments:
General Plugin Tempalte v1.10.rar
Hits: 6 Size: 41.11kb

Post has been edited 1 time(s), last time on May 18 2009, 3:33 am by A_of-s_t.



Personal GitHub
Starcraft GitHub Organization - Feel free to request member status!
TwitchTV

May 20 2009, 9:42 pm A_of-s_t Post #4

aka idmontie

<<UPDATED>>

See first post.



Personal GitHub
Starcraft GitHub Organization - Feel free to request member status!
TwitchTV

May 21 2009, 2:09 am Mauron Post #5



This might be a stupid question, but how do you use the new functions you code?



None.

May 21 2009, 2:20 am A_of-s_t Post #6

aka idmontie

Do you mean the hooks? Open up nextFrame.cc and put all code in that function located there. Compile and that's it.



Personal GitHub
Starcraft GitHub Organization - Feel free to request member status!
TwitchTV

May 21 2009, 2:37 am Mauron Post #7



That much I understand. I'm confused as to how I can use them once they're compiled.



None.

May 21 2009, 2:39 am A_of-s_t Post #8

aka idmontie

the function nectFrame() runs every time SC's screen is updated. All you do is rename qdp.dll to have a .qdp extension and use MPQDraft or Firegraft and import it.



Personal GitHub
Starcraft GitHub Organization - Feel free to request member status!
TwitchTV

May 21 2009, 3:35 am Mauron Post #9



Ah, that would be my problem. I was expecting it to be recognized by Firegraft to add buttons or such in there.

How do you manipulate the button sets? I've tried playing around with the example given in buttons.h, but it doesn't seem to work.



None.

May 21 2009, 5:42 am A_of-s_t Post #10

aka idmontie

Add this right before the nextFrame() function:

Code
//-----------------------ACT_FUNC EXAMPLE-----------------------//
void __fastcall AfterBurnerAction(u32 actVar, u32 shiftClick){
    UNIT*               unit;
    int * curUnit = (int*)0x005971F0; //005971F0        ? Selection Group (4 * 12)
    int n = (*curUnit - 0x0059CC90) / 336;
    unit = &unitTable[n];
    unit->flingyAcceleration = unit->flingyAcceleration + 50;
    unit->flingySpeed = unit->flingySpeed + 200;
    unit->healthPoints = ((unit->healthPoints >> 8)/2) << 8;      
    if(unit->healthPoints >> 8 == 0) {
         unit->mainOrderId = 0;  
         }      
    }
//Note:  Will crash in multiplayer
   
//-----------------------REQ_FUNC EXAMPLE-----------------------//    
BUTTON_STATE::Enum __fastcall AfterBurnerRequire(u32 reqVar, u32 playerId, UNIT* selected){    
    if(selected->healthPoints >> 8 <= 25){
         return BUTTON_STATE::Disabled;
         }
    if(selected->healthPoints >> 8 > 25){
         return BUTTON_STATE::Enabled;
         }
    return BUTTON_STATE::Disabled;
    }    
void newButton(){
    buttonSet =             &buttonSetTable[n]; //Button Set 'n'
   
    button                = buttonSet->firstButton;    
    button->iconID        = 374;
    button->actFunc       = (ACT_FUNC*)&AfterBurnerAction;
    button->reqFunc       = (REQ_FUNC*)&AfterBurnerRequire;
    }


Add this INSIDE the function:
Code
newButton();




Personal GitHub
Starcraft GitHub Organization - Feel free to request member status!
TwitchTV

May 21 2009, 6:09 am Mauron Post #11



I get these errors when I copied your code as written:

Code
h:\program files\microsoft visual studio 9.0\vc\bin\firegraft\nextFrame.cc(27) :
error C2065: 'buttonSetTable' : undeclared identifier
h:\program files\microsoft visual studio 9.0\vc\bin\firegraft\nextFrame.cc(27) :
error C2065: 'n' : undeclared identifier


I'm assuming 'n' is meant for me to change to the button set I want, but that doesn't explain the buttonSetTable error.



None.

May 21 2009, 4:39 pm A_of-s_t Post #12

aka idmontie

Change 'n' and it get's rid the other error as well.



Personal GitHub
Starcraft GitHub Organization - Feel free to request member status!
TwitchTV

May 21 2009, 7:24 pm Mauron Post #13



The other error is still there for me after changing it.



None.

May 22 2009, 2:04 am A_of-s_t Post #14

aka idmontie

Okay, I fixed it. I'm releasing a new version since I had to fix a few files:

http://broodwarai.com/GPTP/main.htm

Check out func_example.h to see how to do buttons :P .



Personal GitHub
Starcraft GitHub Organization - Feel free to request member status!
TwitchTV

May 23 2009, 2:06 am Mauron Post #15



I tried compiling the example button function, which if I understand right, will create a new button not attached to a set that calls a function that does nothing, correct?

When I try running my Firegraft executable, which contains no modifications other than the new button patch, StarCraft crashes as soon as I enter a game. I'm using 1.15.1 as the readme says, but I have downgraded from 1.16.1, which might be the problem.



None.

May 23 2009, 2:53 am A_of-s_t Post #16

aka idmontie

Upload it and I'll check it out. It might be the fact that I transfered some of the addresses incorrectly.



Personal GitHub
Starcraft GitHub Organization - Feel free to request member status!
TwitchTV

May 23 2009, 4:15 am Mauron Post #17



Done.

Thanks for all the help.

Attachments:
afterburner.qdp
Hits: 0 Size: 45kb



None.

May 23 2009, 3:34 pm A_of-s_t Post #18

aka idmontie

I believe I figured out what the problem is. The nextFrame function runs every time SC updates the screen (I believe), even when not in game. Likewise, you can only change things concerning buttons while ingame. I messed up some addresses dealing with onGame start and such... so...

Let me update the template with the correct addresses.

<<UPDATED>>

New version is 1.40.a. Next up is text printing.

Post has been edited 2 time(s), last time on May 23 2009, 7:05 pm by A_of-s_t.



Personal GitHub
Starcraft GitHub Organization - Feel free to request member status!
TwitchTV

May 23 2009, 7:51 pm Mauron Post #19



It runs fine now as far as I can tell, but I get this message when compiling the plugin:

Quote
H:\Program Files\Microsoft Visual Studio 9.0\VC\INCLUDE\xlocale(342) : warning C4530: C++ exception handler used, but unwind semantics are not enabled. Specify /EHsc




None.

May 23 2009, 8:17 pm A_of-s_t Post #20

aka idmontie

It's just a warning. The .dll should compile anyway with no side effects.

BTW, did you see the new example in func_example.cpp? I had forgotten a line in the previous example that was extremely important :P



Personal GitHub
Starcraft GitHub Organization - Feel free to request member status!
TwitchTV

Options
  Back to forum
Please log in to reply to this topic or to report it.
Members in this topic: None.
[05:00 pm]
lil-Inferno -- benis
[10:41 am]
v9bettel -- Nice
[01:39 am]
Ultraviolet -- no u elky skeleton guy, I'll use em better
[10:50 pm]
Vrael -- Ultraviolet
Ultraviolet shouted: How about you all send me your minerals instead of washing them into the gambling void? I'm saving up for a new name color and/or glow
hey cut it out I'm getting all the minerals
[10:11 pm]
Ultraviolet -- :P
[10:11 pm]
Ultraviolet -- How about you all send me your minerals instead of washing them into the gambling void? I'm saving up for a new name color and/or glow
[2024-4-17. : 11:50 pm]
O)FaRTy1billion[MM] -- nice, now i have more than enough
[2024-4-17. : 11:49 pm]
O)FaRTy1billion[MM] -- if i don't gamble them away first
[2024-4-17. : 11:49 pm]
O)FaRTy1billion[MM] -- o, due to a donation i now have enough minerals to send you minerals
[2024-4-17. : 3:26 am]
O)FaRTy1billion[MM] -- i have to ask for minerals first tho cuz i don't have enough to send
Please log in to shout.


Members Online: DarkenedFantasies, Roy