Staredit Network > Forums > Modding Assistance > Topic: Pr0nogo's GPTP Questions
Pr0nogo's GPTP Questions
Sep 4 2017, 6:44 am
By: Pr0nogo  

Sep 4 2017, 6:44 am Pr0nogo Post #1



As part of my next big campaign project, I'm looking to create some complex foundational systems that will work for all future projects, paving the way for a more feature-rich future. I want them to be easy to understand and manipulate, both for my own ease of use and for anyone else who might use them when my framework mod becomes open source. I also have innumerable changes planned to the game's races that will require extensive codework, so I'll have plenty of questions that I hope those more experienced than I will answer if they have the time. Thanks in advance to anyone who contributes!

I'll add more items as they come up, but here are the ones I've curated so far.

FOUNDATIONAL SYSTEMS:
  • Rudimentary read/write system (reads death counter values and reads them in the next map, used to simulate bank data systems from War3/Sc2)
  • Difficulty selection system (new dropdown menu in 'play custom' menu, sets a death counter to a value on map load depending on which difficulty was selected)
  • Music system (in-game only, sets volume from BW's music volume setting)

SPECIFIC QUESTIONS:
  • Can/does GPTP support a music system as described by Sand_Wraith?
  • Can/does GPTP support reading data from a text file and writing them to a map via death counters, and vice versa?
  • What is the best method for adding internal timers to an ability? e.g. if I have an upgrade to make Ensnare deal X damage every second, what would be the best way to do that?
  • Can I lower the duration of debuffs (like Ensnare) depending on what unit is affected by them? e.g. it wears off of a hero faster than a regular unit
  • I want to add two workers - one that behaves like an SCV (inundated while constructing) and one that behaves like a Drone (consumed to create a building). AI usability is a must, alongside player usability. What is the best way to go about this? Is GPTP even necessary here to circumvent worker-related hardcode?
  • Are units with turrets, units with siege mode, units with special idle orders (e.g. Medic), structures that lift off, or units that build Scarabs or Interceptors difficult or impossible to recreate?
  • Can GPTP detect when a second tier of an upgrade has been acquired by a player and make special changes to it? e.g. tier 1 gives a hero's weapon gains +1 range; tier 2 makes the weapon ignore armor
  • What's the best way of adding auras to the game? e.g. units near a Medic gain passive HP regeneration
  • What's the best way of adding passive HP regeneration buffs that stack with the 'regenerate' flag in units.dat?
  • What's the best way of adding a life leech or shield leech to the game? e.g. a unit heals for X% of damage dealt
  • Can upgrades, units, and technologies be set to disabled in map settings and be enabled via GPTP? e.g. after completing a bonus objective, a new button appears that allows Lurker Aspect to be researched, where previously it was not visible on the Hydralisk Den
  • Can the amount of resources returned per trip be increased dynamically, on a per-player basis? e.g. player acquires an upgrade, and then they return 10 vespene per trip instead of 8, but their enemies still return the normal amount





Sep 4 2017, 3:32 pm Voyager7456 Post #2

Responsible for my own happiness? I can't even be responsible for my own breakfast

Quote from Pr0nogo
Yes, I believe this is possible.

Quote from Pr0nogo
  • Can/does GPTP support reading data from a text file and writing them to a map via death counters, and vice versa?
Yes. Although depending on what you want to do with DCs, there might not be a hook written for that yet. I know there is, at least, a hook for incrementing death counters.

Quote from Pr0nogo
  • What is the best method for adding internal timers to an ability? e.g. if I have an upgrade to make Ensnare deal X damage every second, what would be the best way to do that?
In update_status_efects.cpp there is the code that decrements the Ensnare timer. I would add some code there.

Quote from Pr0nogo
  • Can I lower the duration of debuffs (like Ensnare) depending on what unit is affected by them? e.g. it wears off of a hero faster than a regular unit
Yes, in the aforementioned file, just add a check to see if it's a hero unit and decrement the timer some more.

Quote from Pr0nogo
  • I want to add two workers - one that behaves like an SCV (inundated while constructing) and one that behaves like a Drone (consumed to create a building). AI usability is a must, alongside player usability. What is the best way to go about this? Is GPTP even necessary here to circumvent worker-related hardcode?
What hardcoded things are you looking to get around? The unit's build method isn't determined by anything hardcoded, it's determined by the action in FireGraft.

Quote from Pr0nogo
  • Are units with turrets, units with siege mode, units with special idle orders (e.g. Medic), structures that lift off, or units that build Scarabs or Interceptors difficult or impossible to recreate?
  • Units with turrets - I don't believe you need to do anything with this. I think the current GPTP attack order hook is written so you no longer need to change anything about the attack order to have new turrets behave properly.
  • Units with siege mode - I haven't tried it, but there is a siege mode hook.
  • Units with special idle orders - AFAIK this is only controlled via the units.dat entry, I don't think there's any plugin work required.
  • Structures that lift off - No plugin required
  • Units that build Scarabs or Interceptors - I haven't tried this.

Quote from Pr0nogo
  • Can GPTP detect when a second tier of an upgrade has been acquired by a player and make special changes to it? e.g. tier 1 gives a hero's weapon gains +1 range; tier 2 makes the weapon ignore armor

Yes. I would look at weapon_range.cpp and weapon_damage.cpp respectively.

Quote from Pr0nogo
  • What's the best way of adding auras to the game? e.g. units near a Medic gain passive HP regeneration

I typically have a piece of code in game_hooks that checks every frame (or every X frames) with getAllUnitsInBounds(), then applies the effect to those.

Quote from Pr0nogo
  • What's the best way of adding passive HP regeneration buffs that stack with the 'regenerate' flag in units.dat?
Regeneration and similar effects are done in update_unit_state.cpp, add some additional code there.

Quote from Pr0nogo
  • What's the best way of adding a life leech or shield leech to the game? e.g. a unit heals for X% of damage dealt
weaponDamageHook() in weapon_damage.cpp

Quote from Pr0nogo
  • Can upgrades, units, and technologies be set to disabled in map settings and be enabled via GPTP? e.g. after completing a bonus objective, a new button appears that allows Lurker Aspect to be researched, where previously it was not visible on the Hydralisk Den
I'm not sure if there is a hook for this? I haven't looked into it. But at the very least you can change a unit's buttonset, which would have a similar result.

Quote from Pr0nogo
  • Can the amount of resources returned per trip be increased dynamically, on a per-player basis? e.g. player acquires an upgrade, and then they return 10 vespene per trip instead of 8, but their enemies still return the normal amount

Yes. Check out harvest.cpp



all i am is a contrary canary
but i'm crazy for you
i watched you cradling a tissue box
sneezing and sniffling, you were still a fox


Modding Resources: The Necromodicon [WIP] | Mod Night
My Projects: SCFC | ARAI | Excision [WIP] | SCFC2 [BETA] | Robots vs. Humans | Leviathan Wakes [BETA]


Sep 6 2017, 3:57 am O)FaRTy1billion[MM] Post #3

👻 👾 👽 💪

Quote from Voyager7456
Quote from Pr0nogo
  • Can/does GPTP support reading data from a text file and writing them to a map via death counters, and vice versa?
Yes. Although depending on what you want to do with DCs, there might not be a hook written for that yet. I know there is, at least, a hook for incrementing death counters.
Changing death counts directly is trivial. I believe GPTP has the death table already defined for this.



TinyMap2 - Latest in map compression! ( 7/09/14 - New build! )
EUD Action Enabler - Lightweight EUD/EPD support! (ChaosLauncher/MPQDraft support!)
EUDDB - topic - Help out by adding your EUDs! Or Submit reference files in the References tab!
MapSketch - New image->map generator!
EUDTrig - topic - Quickly and easily convert offsets to EUDs! (extended players supported)
SC2 Map Texture Mask Importer/Exporter - Edit texture placement in an image editor!
\:farty\: This page has been viewed [img]http://farty1billion.dyndns.org/Clicky.php?img.gif[/img] times!

Sep 6 2017, 4:26 pm Voyager7456 Post #4

Responsible for my own happiness? I can't even be responsible for my own breakfast

Oh, yeah you're right. I've never done anything with death counts before. The table is defined in scbwdata.h



all i am is a contrary canary
but i'm crazy for you
i watched you cradling a tissue box
sneezing and sniffling, you were still a fox


Modding Resources: The Necromodicon [WIP] | Mod Night
My Projects: SCFC | ARAI | Excision [WIP] | SCFC2 [BETA] | Robots vs. Humans | Leviathan Wakes [BETA]


Sep 8 2017, 10:19 pm Pr0nogo Post #5



Thanks for the helpful responses guys! Adding these questions now, since I have VS open again:
  • What is the best method of adding a working drop-down menu to gluCustm.bin that has 3 selections, where each selection applies a different value to a death counter once the map initializes?
  • What is a good failsafe to have that will prevent the plugin from writing death counter data to the map a second time because of a save being loaded? I can probably just do this with triggers, but I figured I'd ask it just in case.





Sep 9 2017, 10:43 pm Voyager7456 Post #6

Responsible for my own happiness? I can't even be responsible for my own breakfast

I don't know anything about the .bin file stuff, but you can both read and write to the death counter table in GPTP. So you can just go ahead and check the values before modifying it.



all i am is a contrary canary
but i'm crazy for you
i watched you cradling a tissue box
sneezing and sniffling, you were still a fox


Modding Resources: The Necromodicon [WIP] | Mod Night
My Projects: SCFC | ARAI | Excision [WIP] | SCFC2 [BETA] | Robots vs. Humans | Leviathan Wakes [BETA]


Sep 10 2017, 6:42 am Pr0nogo Post #7



Awesome. Good to hear.
  • Does GPTP have any code regarding drawing buttons on the command card? I want to add autocast and cooldown displays. Assuming no hooks are present, an external plugin could serve this purpose.
  • Can GPTP detect if a button is right-clicked instead of left-clicked? This would toggle autocasting, just like in WC3/SC2, but left-clicking should still activate the ability as normal (e.g. SCV repair, medic heal).


Post has been edited 1 time(s), last time on Sep 11 2017, 2:12 am by Pr0nogo.




Sep 11 2017, 4:01 pm Neiv Post #8



Quote from Voyager7456
Quote from Pr0nogo
  • Can upgrades, units, and technologies be set to disabled in map settings and be enabled via GPTP? e.g. after completing a bonus objective, a new button appears that allows Lurker Aspect to be researched, where previously it was not visible on the Hydralisk Den
I'm not sure if there is a hook for this? I haven't looked into it. But at the very least you can change a unit's buttonset, which would have a similar result.
I believe the plugin can just write UnitAvailability, UpgradesSc->maxLevel, TechSc->isEnabled etc to dynamically enable/disable the availability during maps.

Quote from Pr0nogo
  • Does GPTP have any code regarding drawing buttons on the command card? I want to add autocast and cooldown displays. Assuming no hooks are present, an external plugin could serve this purpose.
  • Can GPTP detect if a button is right-clicked instead of left-clicked? This would toggle autocasting, just like in WC3/SC2, but left-clicking should still activate the ability as normal (e.g. SCV repair, medic heal).
I don't think GPTP has much code ready for .bin manipulation, just what's necessary to modify buttonset .bin. You'd have to hook the command button control's event handler, and handle right mouse events manually.
I've done autocasting ages ago so it's feasible, but it was surprisingly lot of work just to get the button respond to rightclicking without getting stuck in different ways.



None.

Sep 11 2017, 4:21 pm Pr0nogo Post #9



Quote from Neiv
I believe the plugin can just write UnitAvailability, UpgradesSc->maxLevel, TechSc->isEnabled etc to dynamically enable/disable the availability during maps.
Awesome, I'll check those functions out in some tests and see what I can come up with. Thanks!

Quote from Neiv
You'd have to hook the command button control's event handler, and handle right mouse events manually.
So I'd have to write the hooks into GPTP? Seems like using an external plugin would be easier to do than trying to merge old GPTP code with new stuff, but I'm still pretty green so who knows.

Quote from Neiv
I've done autocasting ages ago so it's feasible, but it was surprisingly lot of work just to get the button respond to rightclicking without getting stuck in different ways.
Any insights you have on this particular thing would be greatly appreciated then. I figured it would be difficult to get the game to differentiate between right and left clicks consistently.




Apr 4 2018, 3:23 pm Pr0nogo Post #10



I've been looking for a guide on how to hook new info into GPTP so I can access additional functions, but I haven't found anything. In case someone has already done something similar, I'll outline everything here:


This is what a `sight range` value of `0` in the units.dat `vision range` field looks like. I want to make a specific structure not provide any vision. I've tried setting the following in GPTP, but no effect is had.

Code
   if(unit->id == UnitId::Special_PowerGenerator)
       sightRange = 0


-----

I want to tie an upgrade to allowing non-zerg structures to be built on creep. This is primarily for mix-race AI opponents, such that with an upgrade provided by default, they'd be able to build their structures without having to segregate them in different build areas.




Apr 4 2018, 8:11 pm thekian Post #11



An infested command center can be both on normal ground and creep. From the liftland.cpp source file:

Code
        //64A7E
        //probably update things related to creep since
        //there may be some under or around an infested
        //command center, return value unused
if(unit->id == UnitId::ZergInfestedCommandCenter)
            function_0047DF90(unit);


However, I could not find anything in the building creation stuff for creep. I am guessing that it is currently handled by stuff somewhere in SC memory that we don't have in plain C++.
This could help you, though.

Now, with the structure, I'm not sure whether the owner will even be able to see it if there is no sight range on it.
However, you can alter it (I think) in ExtendSightLimit.h (or wherever this code is in your install of GPTP, might be game.h or something):

Code
 for (unsigned int x = 0; x <= MAX_SIGHT_RANGE; ++x) {
   sightData[x].tileSightWidth   = x * 2 + 3;
   sightData[x].tileSightHeight  = x * 2 + 3;
   sightData[x].unknown1 = 3;
   sightData[x].unknown2 = 3;
 }


If you set all four values to be zero (using if(x == 0) ) for the first index (e.g. x == 0) it should work. I'm not sure whether blind sets sight range to 1 or 0, but if it sets it to 0 you may also want to change blind. Alternatively, create a new HIGHER index sight range and custom set it to have no sight.



None.

Apr 5 2018, 1:28 am Pr0nogo Post #12



I should have specified that I don't want the structure to cast vision for the owning player or that player's allies. The structure in question is invisible, invincible, and has no collision.

The argument you pasted seems to effect more than just minimum sight range, no? Wouldn't changing them all to `0` affect other game elements?

I believe blinded sight radius is 1.




Apr 5 2018, 3:37 am thekian Post #13



Quote from Pr0nogo
I should have specified that I don't want the structure to cast vision for the owning player or that player's allies. The structure in question is invisible, invincible, and has no collision.

The argument you pasted seems to effect more than just minimum sight range, no? Wouldn't changing them all to `0` affect other game elements?

I believe blinded sight radius is 1.
Like this:

Code
for (unsigned int x = 0; x <= MAX_SIGHT_RANGE; ++x) {
  if(x == 0)
  {
     sightData[x].tileSightWidth   = 0;
     sightData[x].tileSightHeight  = 0;
     sightData[x].unknown1 = 0; //Might break it, who knows. If it does, just set it back to 3.
     sightData[x].unknown2 = 0; //Ditto
  } else
  {
     sightData[x].tileSightWidth   = x * 2 + 3;
     sightData[x].tileSightHeight  = x * 2 + 3;
     sightData[x].unknown1 = 3;
     sightData[x].unknown2 = 3;
  }
}


Is it optimized? No, not really. I mean, you could do several ternary statements but I'm not sure that would do much but decrease number of lines.

For reference, both code pieces I posted in my previous post are directly copied from the default code of my GPTP installation. The code I put in here, while inelegant, should accomplish what you want when sight range is set to 0.

However, keep in mind that Starcraft may be finicky regardless and decide to crash if something tries to have a tile sight size of 0.



None.

Apr 5 2018, 5:40 am Pr0nogo Post #14





No change from my earlier tests, besides crashing on frame 515 100% of the time. Might be something unrelated though.




Apr 5 2018, 3:13 pm thekian Post #15



Quote from Pr0nogo


No change from my earlier tests, besides crashing on frame 515 100% of the time. Might be something unrelated though.
In regards to the frame crash, maybe try changing the unknown values back to 3.

Also, it may just be that the game always gives an automatic 1 tile sight range to make the unit visible, and we can't change it because GPTP is incomplete.



None.

May 9 2018, 12:00 am Biophysicist Post #16



What's the use case for the structure?



None.

May 9 2018, 2:10 am Pr0nogo Post #17



I use it to make AI consider a region 'owned' and as such they will defend it. Towns also take ownership of structures so they would rebuild the requested structures around that, thus creating an immortal town that is always rebuilt (until I remove it via triggers). Basically a better way to guide AI in the direction of building structures in certain regions (e.g. defenses, production, etc) so they don't screw up pathing or w/e.




Options
  Back to forum
Please log in to reply to this topic or to report it.
Members in this topic: None.
[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
[2024-4-17. : 1:53 am]
Vrael -- bet u'll ask for my minerals first and then just send me some lousy vespene gas instead
[2024-4-17. : 1:52 am]
Vrael -- hah do you think I was born yesterday?
Please log in to shout.


Members Online: Sylph-Of-Space, jun3hong