Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * This is where the magic happens. However, there are other things
- * that you can change. In "Definitions/definitions.h", you can
- * remove the DEBUG defintion for a final release of your plugin.
- * You can likewise change the version that the plguin is for.
- * Supported versions are given in "Definitions/definitions.h".
- *
- * Oh, and you can also change the plugin's ID in that file as well,
- * just in case it conflicts with other plugin IDs.
- */
- #include "asm.cpp"
- #include "Dark Moon.h"
- #include "psifield.h"
- #include "SCBW.h"
- #ifdef DEBUG
- #include <fstream>
- std::ofstream myfile;
- #endif
- // Plasma Shields Overcharge
- // Offsets to some internal constants
- BYTE* const shieldShiftVal1 = (BYTE*) 0x00493578; //unitCanRechargeShields();
- BYTE* const shieldShiftVal2 = (BYTE*) 0x00493EE8; //orders_RechargeShields1();
- BYTE* const shieldShiftVal3 = (BYTE*) 0x004934C3; //ApplyRechargeShields();
- BYTE* const shieldShiftVal4 = (BYTE*) 0x00493501; //ApplyRechargeShields();
- const BYTE* const SHIELD_REGEN = (BYTE*) 0x004EC2E5;
- DWORD RegenerateShieldsInject = 0x004EC2DF;
- DWORD RegenerateShieldsReturn = 0x004EC2F0;
- DWORD RegenerateShieldsSkip = 0x004EC2FE;
- // Don't fix Plasma Shields overflow
- void __declspec(naked) RegenerateShields() {
- __asm {
- CMP ecx, eax ; ecx = current shields, eax = full shields
- JAE SkipShieldRegen ; Skip if current shields >= max shields
- SUB eax, ecx ; eax -= ecx
- PUSH ebx
- MOV ebx, [SHIELD_REGEN]
- MOVZX ebx, BYTE PTR [ebx] ; ebx = shield regen amount per cycle
- CMP eax, ebx
- JAE RegenShields ; If remaining gap is bigger than default regen amount, use the default
- MOV ebx, eax ; Otherwise, fill up to max hp
- RegenShields:
- ADD ecx, ebx ; ecx = current shields, ebx = modified shield regen amount
- POP ebx
- MOV [esi + 0x60], ecx ; update UNIT struct with the new shield amount
- JMP [RegenerateShieldsReturn]
- SkipShieldRegen:
- JMP [RegenerateShieldsSkip]
- }
- }
- // Sight range extender
- SightStruct sightValues[] = {
- CREATE_SIGHT_STRUCT(0),
- CREATE_SIGHT_STRUCT(1),
- CREATE_SIGHT_STRUCT(2),
- CREATE_SIGHT_STRUCT(3),
- CREATE_SIGHT_STRUCT(4),
- CREATE_SIGHT_STRUCT(5),
- CREATE_SIGHT_STRUCT(6),
- CREATE_SIGHT_STRUCT(7),
- CREATE_SIGHT_STRUCT(8),
- CREATE_SIGHT_STRUCT(9),
- CREATE_SIGHT_STRUCT(10),
- CREATE_SIGHT_STRUCT(11),
- CREATE_SIGHT_STRUCT(12),
- CREATE_SIGHT_STRUCT(13),
- CREATE_SIGHT_STRUCT(14),
- CREATE_SIGHT_STRUCT(15),
- CREATE_SIGHT_STRUCT(16),
- CREATE_SIGHT_STRUCT(17),
- CREATE_SIGHT_STRUCT(18),
- CREATE_SIGHT_STRUCT(19),
- CREATE_SIGHT_STRUCT(20),
- CREATE_SIGHT_STRUCT(21),
- CREATE_SIGHT_STRUCT(22),
- CREATE_SIGHT_STRUCT(23),
- CREATE_SIGHT_STRUCT(24)
- };
- // Any code in nextFrame() will be run every frame. On Fastest game speed, this is equal to 24 times per second.
- void nextFrame(){
- for (int i = 0; i < 1700; i++) {
- UNIT* unit = &unitTable[i];
- DWORD protoFlags = UnitsDat_PrototypeFlags[unit->unitId];
- DWORD groupFlags = UnitsDat_GroupFlags[unit->unitId];
- if (unit->unitId == 200) {
- if (unit->status & SF_Completed && !(unit->building.pylon.pylonAura) && unit->mainOrderId == Pickup1)
- unit->mainOrderId = InitPsiProvider;
- SPRITE *aura = unit->building.pylon.pylonAura;
- if (aura) {
- aura->currentXPos = unit->sprite->currentXPos;
- aura->currentYPos = unit->sprite->currentYPos;
- BYTE temp = aura->visibilityFlags;
- RefreshSpriteVisibility(aura, 0);
- RefreshSpriteVisibility(aura, temp);
- *UpdatePsiFieldPowerStatus = 1;
- }
- }
- }
- // Chemical Unit-Nearby Medical Drones energy to HP
- for (int i=0;i<1700;i++) {
- int radius = 100;
- UNIT* chemtrooper;
- chemtrooper = &unitTable[i];
- if (chemtrooper->unitId == 32) {
- if (chemtrooper->healthPoints < 256*CTHP) {
- for (int j=0;j<1700;j++) {
- UNIT* RecDro;
- RecDro = &unitTable[j];
- if (chemtrooper->healthPoints < 256*CTHP && RecDro->energy > 256
- && abs(RecDro->currentXPos - chemtrooper->currentXPos) < radius
- && abs(RecDro->currentYPos - chemtrooper->currentYPos) < radius
- && RecDro->unitId == 34) {
- chemtrooper->healthPoints = chemtrooper->healthPoints + 32;
- RecDro->energy = RecDro->energy - 32;
- }
- }
- }
- }
- }
- // Shadow Gear-Regeneration
- for (int i=0;i<1700;i++) {
- UNIT* Gear;
- Gear = &unitTable[i];
- if (Gear->unitId == 26) {
- if (Gear->healthPoints < 256*GearHP) {
- if (Gear->healthPoints < 256*GearHP) {
- Gear->healthPoints = Gear->healthPoints + 80;
- }
- }
- }
- }
- // Thor-Regenerate 16 times faster
- for (int i=0;i<1700;i++) {
- UNIT* Thor;
- Thor = &unitTable[i];
- if (Thor->unitId == 29) {
- if (Thor->healthPoints < 256*ThorHP) {
- if (Thor->healthPoints < 256*ThorHP) {
- Thor->healthPoints = Thor->healthPoints + 64;
- }
- }
- }
- }
- // Shadow Gear-Energy Regeneration
- for (int i=0;i<1700;i++) {
- UNIT* Gear;
- Gear = &unitTable[i];
- if (Gear->unitId == 26) {
- if (Gear->energy < 256*GearE) {
- if (Gear->energy < 256*GearE) {
- Gear->energy = Gear->energy + 72;
- }
- }
- }
- }
- for (int i=0;i<1700;i++) {
- UNIT* unit;
- unit = &unitTable[i];
- if (unit->isBlind && unit->unitId == 26){
- unit->killCount = 0;
- unit->energy = 0;
- }
- }
- }
- // Any code in gameOn() will be run once, when the map starts.
- void gameOn(){
- UseCustomSightValues(sightValues, 25);
- }
- // Any code in gameEnd() will be run once, at the end of the game.
- void gameEnd(){
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement