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.
[10:41 am]
v9bettel -- Nice
[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
Please log in to shout.


Members Online: Roy, Excalibur