Corrupt Shield

Started by KingGreenYoshi, December 24, 2014, 12:24:33 PM

Previous topic - Next topic

KingGreenYoshi

I want to make a special shield which will destroy any player units that get within it's range.Can someone please give me a bit of code for this. (A way to make it so it shows it's range when you hover over it would very useful.
HASHTAGS ARE OVERRATED!!!
QuoteThen why do you use them :P

Lost in Nowhere

I made this exact thing quite a while ago.
Here it is:
#Author: Lost in Nowhere

$Range:8
$RechargeRate:0.33
$InitialCharge:0.0
$MaxCharge:5
$InstantDestroy:1

$ShieldImg:"Custom0_256"

<-Charge <-RechargeRate 30 div add ->Charge
<-Charge <-MaxCharge asfloat min ->Charge

<-Range <-Charge <-MaxCharge div mul 100000 50000000 0 TRUE EnableTowerField
Self "shield" <-Range <-Charge <-MaxCharge div mul 1.5 div dup SetImageScale

CurrentCoords <-Range <-Charge <-MaxCharge div mul GetUnitsInRange ->c
<-c 0 gt if
<-c 0 do
->unit

<-unit CONST_ISLANDED GetUnitAttribute if
<-unit GetUnitType ->ut
<-ut "TOTEM" neq and (<-ut "OREDEPOSIT" neq) and (<-ut "POWERZONE" neq) and (<-ut "COMMANDNODE" neq) if
<-InstantDestroy if
<-unit 1 Destroy
<-Charge 1.0 sub 0 max ->Charge
else
<-unit 1.0 25 div Damage
<-Charge 1.0 30 div sub 0 max ->Charge
endif
endif
else
<-unit @GetCoords CurrentCoords Distance 1 add div (<-Range <-Charge <-MaxCharge div mul 1 add) ->amt
<-unit @GetPixelCoords ->py ->px
CurrentPixelCoords ->spy ->spx
<-py <-spy sub <-px <-spx sub atan2 ->ang
<-unit CONST_PIXELCOORDX <-px <-ang cos <-amt mul 4.0 div add SetUnitAttribute
<-unit CONST_PIXELCOORDY <-py <-ang sin <-amt mul 4.0 div add SetUnitAttribute
endif
loop
endif

:awake
Self "shield" <-ShieldImg SetImage
IsEditMode -?Charge not or if
<-InitialCharge ->Charge
Self "shield" <-Range 1.5 div dup SetImageScale
endif

:GetCoords
->gcid
<-gcid CONST_COORDX GetUnitAttribute <-gcid CONST_COORDY GetUnitAttribute

:GetPixelCoords
->gcid
<-gcid CONST_PIXELCOORDX GetUnitAttribute <-gcid CONST_PIXELCOORDY GetUnitAttribute

Attached is the image that I used for the shield; the name of the image slot it's in should go in "ShieldImg".
Don't die! :)

KingGreenYoshi

Thanks, this looks perfect!  :) The image for the shield area is actually the exact thing I wanted and you made it for me! THANKS 8) :)
HASHTAGS ARE OVERRATED!!!
QuoteThen why do you use them :P