Sniper powered units Script

Started by SuperDan, May 16, 2014, 03:12:23 AM

Previous topic - Next topic

SuperDan

The following script makes a CRPL core run @whenSniped whenever a Sniper fires at it. When multiple Snipers fire at it simultaneously, it runs @whenSniped multiple times.
# sniperPower.crpl V1.0

# Created on: 5/16/2014 8:40:33 AM

# Author:SuperDan (Please give credit)
once
#vars
$UnitFlying:0
20000 ->health
#constants
Self CONST_SNIPERTARGET 1 SetUnitAttribute
Self CONST_SNIPERIGNORELOS <-UnitFlying SetUnitAttribute
Self CONST_MAXHEALTH <-health SetUnitAttribute
Self CONST_HEALTH <-health SetUnitAttribute
Self CONST_HEALRATE 0 SetUnitAttribute
Self CONST_DESTROYONDAMAGE 0 SetUnitAttribute
#clearTraceLog
#showTraceLog
endonce

#Sniper does 20 damage
while Self CONST_HEALTH GetUnitAttribute <-health neq
repeat
@whenSniped
#Resetting Health
Self CONST_HEALTH add(Self CONST_Health GetUnitAttribute 20) SetUnitAttribute
endwhile

:whenSniped
CurrentCoords RandCoords 1 -10 CreateSpore

Use $UnitFlying to determine whether Spores need line of sight to fire(default is that they do).
By default, @whenSniped creates  a random AC Spore.
Feel free to use it, but please give credit.

Azraile

This is interesting.... only use I can think of it though is stronger crawlers / patrolers or custom units that react when they are shot at

SuperDan

Quote from: Azraile on May 19, 2014, 12:38:47 AM
This is interesting.... only use I can think of it though is stronger crawlers / patrolers or custom units that react when they are shot at
You could have a friendly unit that does something when shot.  :)