Plugin Examples

Help - Resources - AI Scripting - Grafting - Plugins - Modding Projects
pastelmind
Posts: 57
Joined: Fri Nov 19, 2010 7:50 am

Plugin Examples

Postby pastelmind » Thu Sep 06, 2012 1:42 am

I decided to share some plug-in examples at Modcrafters.com. Since the place is barely alive, I thought it might be better to link some of them here. If you have useful plugin code, please share them here!

Plugin Examples:
pastelmind
Posts: 57
Joined: Fri Nov 19, 2010 7:50 am

Postby pastelmind » Mon Oct 01, 2012 7:12 am

pastelmind
Posts: 57
Joined: Fri Nov 19, 2010 7:50 am

Postby pastelmind » Fri Oct 26, 2012 4:30 am

New Plugin Example: Overcharge Plasma Shields
pastelmind
Posts: 57
Joined: Fri Nov 19, 2010 7:50 am

Postby pastelmind » Wed Oct 31, 2012 8:32 am

New Plugin Example (code snippets, really) : Change how StarCraft handles unit speed and weapon cooldown
TassadarZeratul
Posts: 19
Joined: Fri Jun 05, 2009 7:21 pm

Postby TassadarZeratul » Sat Nov 10, 2012 2:28 pm

Gonna arguably hijack this thread a bit and post an example plugin of my own. Using this plugin will allow Place COP to be used without blanking out the unit's button set, and also to be used repeatedly. This by itself isn't terribly useful, though it could be used for, say, a teleporting Gateway, or some kind of warp-capable starship, but it could be nice to know for further plugin development. This is a practical example; start a game as Zerg and you should be able to figure it out.

Code: Select all

bool nextFrame() {
   UNIT* unit;
   for(int i = 0; i < 1700; i++) {
      unit = &unitTable[i];
      if(unit->currentButtonSet == 228) //if the unit is displaying the "Blank" buttonset...
         unit->currentButtonSet = unit->unitId; //...reset its buttonset to its default!
   }
}


(If you're going to use this, the unit will also need to be given access to the CTF COP2 order in Firegraft.)

Another plugin trick, not discovered by me, allows the creation of buttons which cost resources and can be detected by a plugin. Basically, on a unit that is not a structure, Carrier, or Reaver (or hero Carrier/Reaver), place a Create Unit button set to train a unit you're not using and update the requirements. The unit won't actually train, but the button press will be noted in the unit's queue[0] variable. Let's say we set the Goliath turret to cost 25 minerals, and gave the Marine the ability to train it, and used the following plugin. This would allow Marines to heal 20 HP at the cost of 25 minerals! (I think. I haven't tested this one recently.)

Code: Select all

bool nextFrame() {
   UNIT* unit;
   for(int i = 0; i < 1700; i++) {
      unit = &unitTable[i];
      if(unit->queue[0] == 4) {
         unit->queue[0] = 228; //the default value for when stuff isn't training
         unit->healthPoints += 5120;
      }
   }
}
Arcanes_Lutarez
Posts: 7
Joined: Fri Jun 24, 2011 8:35 pm

Postby Arcanes_Lutarez » Mon Nov 19, 2012 10:42 pm

hello, i need help, i need create a plugin for a build with psi like the pylon, when i create a building with psi in datedit, in the moment that the build die, the psi don't disappear
pastelmind
Posts: 57
Joined: Fri Nov 19, 2010 7:50 am

Postby pastelmind » Thu Nov 22, 2012 10:16 am

[quote name='Arcanes_Lutarez' date='20 November 2012 - 07:42 AM' timestamp='1353364937' post='11242']
hello, i need help, i need create a plugin for a build with psi like the pylon, when i create a building with psi in datedit, in the moment that the build die, the psi don't disappear
[/quote]

Download the attachment in this post: http://www.staredit.net/341377/

Now add #include "psifield.h" in game.h.
All you need to do is modify UnitCanMakePsiField() and UnitNeedsPsiFieldDestructor() to change the unit ID to the one of your choice. You also need to add the following code to qdp.cpp, inside the InitializePlugin() function:

[php]
JmpCallPatch(PsiProviderCheck1, PsiProviderCheck1_Inject);
JmpCallPatch(PsiProviderCheck2, PsiProviderCheck2_Inject);
JmpCallPatch(PsiProviderCheck3, PsiProviderCheck3_Inject);
JmpCallPatch(PsiProviderCheck4, PsiProviderCheck4_Inject);
JmpCallPatch(PsiProviderCheck5, PsiProviderCheck5_Inject);
[/php]

Since you're not making a warp prism, there should be no need to do anything else apart from this.
Arcanes_Lutarez
Posts: 7
Joined: Fri Jun 24, 2011 8:35 pm

Postby Arcanes_Lutarez » Thu Nov 22, 2012 6:00 pm

i test the code, but when the shuttle have the psi aura, how i can turn off the aura like warp prism?

Return to “StarCraft Modding”

Who is online

Users browsing this forum: No registered users and 2 guests