Script for resource pack with health

Started by SuperDan, June 22, 2014, 11:39:36 AM

Previous topic - Next topic

SuperDan

The script below will, when attached to a tower, create a resource pack at that location.
When Creeper is at that location, the tower is damaged and when it is destroyed, the resource pack is destroyed too(so if Creeper is at the resource pack for too long, it gets destroyed).  :)

Script:
Spoiler
# healthyResource.crpl
V1.0
# Created on: 6/22/2014 5:01:01 PM

# Author: SuperDan(please give credit)
# ------------------------------------------

once
   #vars
   $packType:"ENERGY"
   $packAmt:250
   0 ->packUID

   #consts
   SetUnitAttribute(Self CONST_CONNECTABLE 0)
   SetUnitAttribute(Self CONST_COUNTSFORVICTORY 0)
   SetUnitAttribute(Self CONST_CREATEPZ 0)
   SetUnitAttribute(Self CONST_DESTROYMODE 2)
   SetUnitAttribute(Self CONST_DESTROYONDAMAGE 1)
   SetUnitAttribute(Self CONST_NULLIFIERDAMAGES 0)
   SetUnitAttribute(Self CONST_TAKEMAPSPACE 0)

   #creating the pack
   CreateUnit("RESOURCEPACK" CurrentCoords) ->packUID
   SetScriptVar(<-packUID 0 "resourceType" <-packType)
   SetScriptVar(<-packUID 0 "amt" <-packAmt)

endonce

CurrentCoords GetCreeper 0 gt if
   Self 0.01 Damage
endif


:destroyed

<-packUID 1 Destroy
[close]