Staredit Network > Forums > Modding Assistance > Topic: Auto casting
Auto casting
Apr 3 2012, 10:12 pm
By: XelNaga  

Apr 3 2012, 10:12 pm XelNaga Post #1



Is it possible to make protoss Recharge Shields ability auto casting (more o less like Medic`s healing)



None.

Apr 3 2012, 10:29 pm Raitaki Post #2



About this I don't really know...But I do know that casting Recharge Shields on a unit will cause that unit to be ordered to move into the range of the shield battery (and forcing them to stay still while the shield recharges), so unless you change that it'll become very annoying when shield batteries keep pulling units out of combat.



None.

Apr 3 2012, 11:15 pm Biophysicist Post #3



The right way to do it is to fake it with a plugin. Which isn't something that can be easily explained. >.> I could write you a plugin if you'd want?



None.

Apr 4 2012, 9:51 pm XelNaga Post #4



I rly don`t want to bother you with my needs. And even if you do it , i do not know virtually nothing about plugins and their implemenation with other modding programms.



None.

Apr 6 2012, 5:11 pm Biophysicist Post #5



Oh, you replied. >.>

Well, you just need the Shield Battery to automatically restore shields, yes? If so, what I could do is make the plugin automatically select the most expensive unit within range that does not have full shields, and convert some of its energy into shields for that unit every frame. If you want, I could also suspend this behavior while the Battery is not idling, so that the player could still manually cast Restore Shields; however it would probably make more sense to just cut the manual casting of that ability. Up to you. It's seriously neither bothersome nor burdensome; I like programming anyway.

(Also, integrating a plugin is easy. You just go into Firegraft's plugins tab and add the plugin to your mod.)



None.

Apr 9 2012, 9:14 am XelNaga Post #6



Yes, thats exactly what i wanted. If u dont mind please post it in this topic so any newbie can use it without too much trouble, ok ?...



None.

Apr 3 2014, 10:13 am 09xela Post #7



I too want to know, how to do this feature.



None.

Apr 5 2014, 3:28 am poiuy_qwert Post #8

PyMS and ProTRG developer

You could check out the STF Plugin source over here, it has some mechanics (kills to cash) that might give some direction on what you would want to do.




Apr 11 2014, 9:11 pm 09xela Post #9



Quote from poiuy_qwert
You could check out the STF Plugin source over here, it has some mechanics (kills to cash) that might give some direction on what you would want to do.
Checked, but found it useless. Only If I colud find way, how to check all units in radius, and then give specific order to one of them...



None.

Apr 14 2014, 3:10 am Sand Wraith Post #10

she/her

Try going to http://www.broodwarai.com/ if you need help with coding a plugin. I suspect that that might be the easiest option. You will need to know some C++ in order to write a plugin so that you can iterate over all units (call the arbitrary unit A), check for repairable units near A, maybe save its order queue, then order to repair, then restore the order queue. I believe another mod that is currently in the mod projects forum features auto-repair, so you should try looking for that particular thread and asking the modder how they did it.




Apr 17 2014, 1:26 am poiuy_qwert Post #11

PyMS and ProTRG developer

There is no real point in using orders to do the repairing. Biophysicist has already stated the simplest way to do it above, quoted here:
Quote from Biophysicist
Oh, you replied. >.>

Well, you just need the Shield Battery to automatically restore shields, yes? If so, what I could do is make the plugin automatically select the most expensive unit within range that does not have full shields, and convert some of its energy into shields for that unit every frame. If you want, I could also suspend this behavior while the Battery is not idling, so that the player could still manually cast Restore Shields; however it would probably make more sense to just cut the manual casting of that ability. Up to you. It's seriously neither bothersome nor burdensome; I like programming anyway.

(Also, integrating a plugin is easy. You just go into Firegraft's plugins tab and add the plugin to your mod.)

Here is some pseudocode:

Code
foreach (UNIT *unit in unitArray) {
    if (unit.isValid() && unit.isAlive() && unit.unitId == UNIT::ShieldBatteryID && unit.energy > 0) {
        UNIT *toRecharge = null;
        int cost = 0;
        foreach (UNIT *target in unitArray) {
            if (target.isValid() && target.isAlive() && target.hasShield() && target.shield < target.maxShield() && inRange(unit, target)) {
                int curCost = target.mineralCost() + target.gasCost() * 2;
                if (curCost > cost) {
                    toRecharge = target;
                }
            }
        }
        if (toRecharge) {
            toRecharge.shield++;
            unit.energy--;
        }
    }
}


hasShield(), maxShield(), mineralCost(), and gasCost() would be using the unitId to lookup the values in the DAT files in memory, or hardcoded by you. You will probably have to slow down the recharge so you would just keep a lastUpdate/timer variable and use it to not recharge on every tick.

Hope that helps!




Apr 17 2014, 7:47 pm 09xela Post #12



Quote from poiuy_qwert
Hope that helps!
Helps, but too late. Thank you very much, anyway.



None.

Apr 18 2014, 7:52 pm Sand Wraith Post #13

she/her

Quote from poiuy_qwert
...

That is true. My answer was for auto-casting in general, as I do not think setting the flag on certain abilities alone (e.g. Irradiate, Plague) will also apply the correct overlays, and the modder may desire the unit to explicitly go through the iscript animations associated with various abilities. Although the method presented works, I personally like visual feedback.




Options
  Back to forum
Please log in to reply to this topic or to report it.
Members in this topic: None.
[07:46 am]
RIVE -- :wob:
[2024-4-22. : 6:48 pm]
Ultraviolet -- :wob:
[2024-4-21. : 1:32 pm]
Oh_Man -- I will
[2024-4-20. : 11:29 pm]
Zoan -- Oh_Man
Oh_Man shouted: yeah i'm tryin to go through all the greatest hits and get the runs up on youtube so my senile ass can appreciate them more readily
You should do my Delirus map too; it's a little cocky to say but I still think it's actually just a good game lol
[2024-4-20. : 8:20 pm]
Ultraviolet -- Goons were functioning like stalkers, I think a valk was made into a banshee, all sorts of cool shit
[2024-4-20. : 8:20 pm]
Ultraviolet -- Oh wait, no I saw something else. It was more melee style, and guys were doing warpgate shit and morphing lings into banelings (Infested terran graphics)
[2024-4-20. : 8:18 pm]
Ultraviolet -- Oh_Man
Oh_Man shouted: lol SC2 in SC1: https://youtu.be/pChWu_eRQZI
oh ya I saw that when Armo posted it on Discord, pretty crazy
[2024-4-20. : 8:09 pm]
Vrael -- thats less than half of what I thought I'd need, better figure out how to open SCMDraft on windows 11
[2024-4-20. : 8:09 pm]
Vrael -- woo baby talk about a time crunch
[2024-4-20. : 8:08 pm]
Vrael -- Oh_Man
Oh_Man shouted: yeah i'm tryin to go through all the greatest hits and get the runs up on youtube so my senile ass can appreciate them more readily
so that gives me approximately 27 more years to finish tenebrous before you get to it?
Please log in to shout.


Members Online: C(a)HeK, lil-Inferno