Advertisement
Chronos_Ouroboros

AAAAAAAAa

Nov 9th, 2015
377
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 5.84 KB | None | 0 0
  1. /*  
  2.  *  This is where the magic happens.  However, there are other things
  3.  *  that you can change.  In "Definitions/definitions.h", you can
  4.  *  remove the DEBUG defintion for a final release of your plugin.
  5.  *  You can likewise change the version that the plguin is for.  
  6.  *  Supported versions are given in "Definitions/definitions.h".
  7.  *
  8.  *  Oh, and you can also change the plugin's ID in that file as well,
  9.  *  just in case it conflicts with other plugin IDs.
  10.  */
  11. #include "asm.cpp"
  12. #include "Dark Moon.h"
  13. #include "psifield.h"
  14. #include "SCBW.h"
  15.  
  16. #ifdef DEBUG
  17.     #include <fstream>
  18.    
  19.     std::ofstream myfile;
  20. #endif
  21. // Plasma Shields Overcharge
  22. // Offsets to some internal constants
  23. BYTE* const shieldShiftVal1 = (BYTE*) 0x00493578;   //unitCanRechargeShields();
  24. BYTE* const shieldShiftVal2 = (BYTE*) 0x00493EE8;   //orders_RechargeShields1();
  25. BYTE* const shieldShiftVal3 = (BYTE*) 0x004934C3;   //ApplyRechargeShields();
  26. BYTE* const shieldShiftVal4 = (BYTE*) 0x00493501;   //ApplyRechargeShields();
  27. const BYTE* const SHIELD_REGEN = (BYTE*) 0x004EC2E5;
  28. DWORD RegenerateShieldsInject  = 0x004EC2DF;
  29. DWORD RegenerateShieldsReturn  = 0x004EC2F0;
  30. DWORD RegenerateShieldsSkip    = 0x004EC2FE;
  31. // Don't fix Plasma Shields overflow
  32. void __declspec(naked) RegenerateShields() {
  33.    __asm {
  34.       CMP ecx, eax               ; ecx = current shields, eax = full shields
  35.       JAE SkipShieldRegen        ; Skip if current shields >= max shields
  36.       SUB eax, ecx               ; eax -= ecx
  37.       PUSH ebx
  38.       MOV ebx, [SHIELD_REGEN]
  39.       MOVZX ebx, BYTE PTR [ebx]  ; ebx = shield regen amount per cycle
  40.       CMP eax, ebx
  41.       JAE RegenShields           ; If remaining gap is bigger than default regen amount, use the default
  42.       MOV ebx, eax               ; Otherwise, fill up to max hp
  43. RegenShields:
  44.       ADD ecx, ebx               ; ecx = current shields, ebx = modified shield regen amount
  45.       POP ebx
  46.       MOV [esi + 0x60], ecx      ; update UNIT struct with the new shield amount
  47.       JMP [RegenerateShieldsReturn]
  48. SkipShieldRegen:
  49.       JMP [RegenerateShieldsSkip]
  50.    }
  51. }
  52. // Sight range extender
  53. SightStruct sightValues[] = {
  54.    CREATE_SIGHT_STRUCT(0),
  55.    CREATE_SIGHT_STRUCT(1),
  56.    CREATE_SIGHT_STRUCT(2),
  57.    CREATE_SIGHT_STRUCT(3),
  58.    CREATE_SIGHT_STRUCT(4),
  59.    CREATE_SIGHT_STRUCT(5),
  60.    CREATE_SIGHT_STRUCT(6),
  61.    CREATE_SIGHT_STRUCT(7),
  62.    CREATE_SIGHT_STRUCT(8),
  63.    CREATE_SIGHT_STRUCT(9),
  64.    CREATE_SIGHT_STRUCT(10),
  65.    CREATE_SIGHT_STRUCT(11),
  66.    CREATE_SIGHT_STRUCT(12),
  67.    CREATE_SIGHT_STRUCT(13),
  68.    CREATE_SIGHT_STRUCT(14),
  69.    CREATE_SIGHT_STRUCT(15),
  70.    CREATE_SIGHT_STRUCT(16),
  71.    CREATE_SIGHT_STRUCT(17),
  72.    CREATE_SIGHT_STRUCT(18),
  73.    CREATE_SIGHT_STRUCT(19),
  74.    CREATE_SIGHT_STRUCT(20),
  75.    CREATE_SIGHT_STRUCT(21),
  76.    CREATE_SIGHT_STRUCT(22),
  77.    CREATE_SIGHT_STRUCT(23),
  78.    CREATE_SIGHT_STRUCT(24)
  79. };
  80. // Any code in nextFrame() will be run every frame.  On Fastest game speed, this is equal to 24 times per second.  
  81. void nextFrame(){
  82.     for (int i = 0; i < 1700; i++) {
  83.             UNIT* unit = &unitTable[i];
  84.             DWORD protoFlags = UnitsDat_PrototypeFlags[unit->unitId];
  85.             DWORD groupFlags = UnitsDat_GroupFlags[unit->unitId];          
  86.             if (unit->unitId == 200) {
  87.                 if (unit->status & SF_Completed && !(unit->building.pylon.pylonAura) && unit->mainOrderId == Pickup1)
  88.                     unit->mainOrderId = InitPsiProvider;
  89.                
  90.                 SPRITE *aura = unit->building.pylon.pylonAura;
  91.                 if (aura) {
  92.                     aura->currentXPos = unit->sprite->currentXPos;
  93.                     aura->currentYPos = unit->sprite->currentYPos;
  94.                     BYTE temp = aura->visibilityFlags;
  95.                     RefreshSpriteVisibility(aura, 0);
  96.                     RefreshSpriteVisibility(aura, temp);
  97.                     *UpdatePsiFieldPowerStatus = 1;
  98.                 }
  99.             }
  100.         }
  101. // Chemical Unit-Nearby Medical Drones energy to HP
  102.    for (int i=0;i<1700;i++) {
  103.       int radius = 100;
  104.       UNIT* chemtrooper;
  105.       chemtrooper = &unitTable[i];
  106.       if (chemtrooper->unitId == 32) {
  107.           if (chemtrooper->healthPoints < 256*CTHP) {
  108.             for (int j=0;j<1700;j++) {
  109.                UNIT* RecDro;
  110.                RecDro = &unitTable[j];
  111.                if (chemtrooper->healthPoints < 256*CTHP && RecDro->energy > 256
  112.                   && abs(RecDro->currentXPos - chemtrooper->currentXPos) < radius
  113.                   && abs(RecDro->currentYPos - chemtrooper->currentYPos) < radius
  114.                   && RecDro->unitId == 34) {
  115.                      chemtrooper->healthPoints = chemtrooper->healthPoints + 32;
  116.                      RecDro->energy = RecDro->energy - 32;
  117.                }
  118.             }
  119.           }
  120.       }
  121.    }
  122. // Shadow Gear-Regeneration
  123.    for (int i=0;i<1700;i++) {
  124.       UNIT* Gear;
  125.       Gear = &unitTable[i];
  126.       if (Gear->unitId == 26) {
  127.          if (Gear->healthPoints < 256*GearHP) {
  128.                if (Gear->healthPoints < 256*GearHP) {
  129.                      Gear->healthPoints = Gear->healthPoints + 80;
  130.                }
  131.          }
  132.       }
  133. }
  134. // Thor-Regenerate 16 times faster
  135.    for (int i=0;i<1700;i++) {
  136.       UNIT* Thor;
  137.       Thor = &unitTable[i];
  138.       if (Thor->unitId == 29) {
  139.          if (Thor->healthPoints < 256*ThorHP) {
  140.                if (Thor->healthPoints < 256*ThorHP) {
  141.                      Thor->healthPoints = Thor->healthPoints + 64;
  142.                }
  143.          }
  144.       }
  145. }
  146. // Shadow Gear-Energy Regeneration
  147. for (int i=0;i<1700;i++) {
  148.       UNIT* Gear;
  149.       Gear = &unitTable[i];
  150.       if (Gear->unitId == 26) {
  151.          if (Gear->energy < 256*GearE) {
  152.                if (Gear->energy < 256*GearE) {
  153.                      Gear->energy = Gear->energy + 72;
  154.                }
  155.          }
  156.       }
  157. }
  158. for (int i=0;i<1700;i++) {
  159.     UNIT* unit;
  160.         unit = &unitTable[i];
  161.     if (unit->isBlind && unit->unitId == 26){
  162.     unit->killCount = 0;
  163.     unit->energy = 0;
  164.     }
  165. }
  166.  
  167. }
  168. // Any code in gameOn() will be run once, when the map starts.
  169. void gameOn(){
  170.    UseCustomSightValues(sightValues, 25);
  171.  
  172. }
  173.  
  174. // Any code in gameEnd() will be run once, at the end of the game.
  175. void gameEnd(){
  176.  
  177. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement