need help upgrading enemy units

Started by Narcosis, July 26, 2014, 03:07:22 AM

Previous topic - Next topic

Narcosis

I'm trying to make a script that upgrades the hp of the custom spores I'm using, but I can't make anything that works here's the custom spore tower script I'm using$Initial_Delay:3600
$Wave_Interval:1800
$Spore_Count:1
$Spore_Payload:50.0
$Spore_Health:1.0
$Spore_Scale:1.0
$Spore_Image:"Custom1"
once
self CONST_COUNTSFORVICTORY true SetUnitAttribute

self CONST_NULLIFIERDAMAGES true SetUnitAttribute

self CONST_CREATEPZ true SetUnitAttribute
"Initial_Delay" @makePos

"Wave_Interval" @makePos

"Spore_Count" @makePos
"Spore_Scale" @makePos

<-Initial_Delay Delay
endonce

<-Spore_Count 0 do RandUnitCoords ->tY ->tX

"CRPLCORE" CurrentCoords CreateUnit ->sporeID
<-sporeID "CustomSpore.crpl" AddScriptToUnit

<-sporeID "main" <-Spore_Image SetImage
<-sporeID "CustomSpore.crpl" "targetX" <-tX SetScriptVar

<-sporeID "CustomSpore.crpl" "targetY" <-tY SetScriptVar

<-sporeID "CustomSpore.crpl" "payload" <-Spore_Payload SetScriptVar

<-sporeID "CustomSpore.crpl" "health" <-Spore_Health SetScriptVar

<-sporeID "CustomSpore.crpl" "scale" <-Spore_Scale SetScriptVar
loop

<-Wave_Interval Delay

:makePos #this checks if a variable needs to be changed and changes it to positive if so.
dup
<-! 0 lt if
dup <-! neg swap ->!
else
pop
endif
and the custom spore that goes with it$targetX:0
$targetY:0
$payload:50.0
$health:1.0
$scale:1.0

once

self CONST_BEAMTARGET true SetUnitAttribute

self CONST_COUNTSFORVICTORY false SetUnitAttribute

self CONST_CREATEPZ false SetUnitAttribute

self CONST_DESTROYONDAMAGE true SetUnitAttribute
self CONST_MAXHEALTH <-health SetUnitAttribute

self CONST_HEALTH <-health SetUnitAttribute

self CONST_NULLIFIERDAMAGES false SetUnitAttribute

self CONST_SNIPERTARGET false SetUnitAttribute

self CONST_TAKEMAPSPACE false SetUnitAttribute

<-targetX <-targetY 1.5 QueueMove #1.5 = speed
self "main" <-scale dup SetImageScale
endonce

if(GetQueuedMoveCount eq0)

CurrentCoords <-payload AddCreeper

Self 1 Destroy
endif
and if needed the script I'm using it in#Spore wave 1

"Name" "Generator" GetCoresWithVar 4 eq if
once
"CRPLCORE" CurrentCoords CreateUnit ->unit

Addscripttounit (<-unit "CustomSporeTower.crpl")
<-unit "CustomSporeTower.crpl" "Spore_Count" 1 SetScriptVar
<-unit "CustomSporeTower.crpl" "Initial_Delay" 300 SetScriptVar
<-unit "CustomSporeTower.crpl" "Wave_Interval" 900 SetScriptVar
<-unit "CustomSporeTower.crpl" "Spore_Health" 1 SetScriptVar
<-unit "CustomSporeTower.crpl" "Spore_Payload" 50 SetScriptVar

Addscripttounit (<-unit "EndWave1.crpl")

endonce

endif

#Spore wave 2

"Name" "Generator" GetCoresWithVar 3 eq if
once
"CRPLCORE" CurrentCoords CreateUnit ->unit
Addscripttounit (<-unit "CustomSporeTower.crpl")
<-unit "CustomSporeTower.crpl" "Spore_Count" 1 SetScriptVar
<-unit "CustomSporeTower.crpl" "Initial_Delay" 300 SetScriptVar
<-unit "CustomSporeTower.crpl" "Wave_Interval" 900 SetScriptVar
<-unit "CustomSporeTower.crpl" "Spore_Health" 1 SetScriptVar
<-unit "CustomSporeTower.crpl" "Spore_Payload" 50 SetScriptVar
Addscripttounit (<-unit "EndWave2.crpl")

"CRPLCORE" CurrentCoords CreateUnit ->unit
Addscripttounit (<-unit "CustomSporeTower.crpl")
<-unit "CustomSporeTower.crpl" "Spore_Count" 1 SetScriptVar
<-unit "CustomSporeTower.crpl" "Initial_Delay" 350 SetScriptVar
<-unit "CustomSporeTower.crpl" "Wave_Interval" 900 SetScriptVar
<-unit "CustomSporeTower.crpl" "Spore_Health" 1 SetScriptVar
<-unit "CustomSporeTower.crpl" "Spore_Payload" 50 SetScriptVar
Addscripttounit (<-unit "EndWave2.crpl")
endonce
endif

#Spore wave 3

"Name" "Generator" GetCoresWithVar 2 eq if
once
"CRPLCORE" CurrentCoords CreateUnit ->unit
Addscripttounit (<-unit "CustomSporeTower.crpl")
<-unit "CustomSporeTower.crpl" "Spore_Count" 1 SetScriptVar
<-unit "CustomSporeTower.crpl" "Initial_Delay" 300 SetScriptVar
<-unit "CustomSporeTower.crpl" "Wave_Interval" 900 SetScriptVar
<-unit "CustomSporeTower.crpl" "Spore_Health" 1 SetScriptVar
<-unit "CustomSporeTower.crpl" "Spore_Payload" 50 SetScriptVar
Addscripttounit (<-unit "EndWave3.crpl")

"CRPLCORE" CurrentCoords CreateUnit ->unit
Addscripttounit (<-unit "CustomSporeTower.crpl")
<-unit "CustomSporeTower.crpl" "Spore_Count" 1 SetScriptVar
<-unit "CustomSporeTower.crpl" "Initial_Delay" 350 SetScriptVar
<-unit "CustomSporeTower.crpl" "Wave_Interval" 900 SetScriptVar
<-unit "CustomSporeTower.crpl" "Spore_Health" 1 SetScriptVar
<-unit "CustomSporeTower.crpl" "Spore_Payload" 50 SetScriptVar
Addscripttounit (<-unit "EndWave3.crpl")

"CRPLCORE" CurrentCoords CreateUnit ->unit
Addscripttounit (<-unit "CustomSporeTower.crpl")
<-unit "CustomSporeTower.crpl" "Spore_Count" 1 SetScriptVar
<-unit "CustomSporeTower.crpl" "Initial_Delay" 400 SetScriptVar
<-unit "CustomSporeTower.crpl" "Wave_Interval" 900 SetScriptVar
<-unit "CustomSporeTower.crpl" "Spore_Health" 1 SetScriptVar
<-unit "CustomSporeTower.crpl" "Spore_Payload" 50 SetScriptVar
Addscripttounit (<-unit "EndWave3.crpl")
endonce
endif

#Spore wave 4

"Name" "Generator" GetCoresWithVar 1 eq if
once
"CRPLCORE" CurrentCoords CreateUnit ->unit1
Addscripttounit (<-unit1 "CustomSporeTower.crpl")
<-unit1 "CustomSporeTower.crpl" "Spore_Count" 1 SetScriptVar
<-unit1 "CustomSporeTower.crpl" "Initial_Delay" 300 SetScriptVar
<-unit1 "CustomSporeTower.crpl" "Wave_Interval" 900 SetScriptVar
<-unit1 "CustomSporeTower.crpl" "Spore_Health" 1 SetScriptVar
<-unit1 "CustomSporeTower.crpl" "Spore_Payload" 50 SetScriptVar

"CRPLCORE" CurrentCoords CreateUnit ->unit2
Addscripttounit (<-unit2 "CustomSporeTower.crpl")
<-unit2 "CustomSporeTower.crpl" "Spore_Count" 1 SetScriptVar
<-unit2 "CustomSporeTower.crpl" "Initial_Delay" 350 SetScriptVar
<-unit2 "CustomSporeTower.crpl" "Wave_Interval" 900 SetScriptVar
<-unit2 "CustomSporeTower.crpl" "Spore_Health" 1 SetScriptVar
<-unit2 "CustomSporeTower.crpl" "Spore_Payload" 50 SetScriptVar

"CRPLCORE" CurrentCoords CreateUnit ->unit3
Addscripttounit (<-unit3 "CustomSporeTower.crpl")
<-unit3 "CustomSporeTower.crpl" "Spore_Count" 1 SetScriptVar
<-unit3 "CustomSporeTower.crpl" "Initial_Delay" 400 SetScriptVar
<-unit3 "CustomSporeTower.crpl" "Wave_Interval" 900 SetScriptVar
<-unit3 "CustomSporeTower.crpl" "Spore_Health" 1 SetScriptVar
<-unit3 "CustomSporeTower.crpl" "Spore_Payload" 50 SetScriptVar

#Giant Spore
"CRPLCORE" CurrentCoords CreateUnit ->unit4
Addscripttounit (<-unit4 "CustomSporeTower.crpl")
<-unit4 "CustomSporeTower.crpl" "Spore_Count" 1 SetScriptVar
<-unit4 "CustomSporeTower.crpl" "Initial_Delay" 470 SetScriptVar
<-unit4 "CustomSporeTower.crpl" "Wave_Interval" 900 SetScriptVar
<-unit4 "CustomSporeTower.crpl" "Spore_Health" 4 SetScriptVar
<-unit4 "CustomSporeTower.crpl" "Spore_Payload" 50 SetScriptVar
#So the spore looks huge
<-unit4 "CustomSporeTower.crpl" "Spore_Scale" 5 SetScriptVar
endonce
endif
Spore Wave 5 would basically be the same as Spore Wave 4 except that(for now) the hp of the giant spore would increase by 1 about 20 seconds after each spore wave and the the three normal ones will increase there hp by 1 about 20 seconds after every 2 spore waves. If someone can help me with this I would really appreciate it.

ParkourPenguin

I think I've got something that works. This will change the health of the spores generated by all the spore towers on the map in accordance with the parameters you set.

Here's a description of all the input variables:









normalAddAmtThe amount of health it should add to normal spores.
normalAddIntervalHow often it should add the above amount of health to the normal spores. 1 means every wave, 2 means every other wave, 3 every third wave, etc.
giantSporeScaleThe minimum scale required for a spore to be considered "giant." Anything below this is considered to be "normal."
giantAddAmtThe amount of health it should add to giant spores.
giantAddIntervalHow often it should add the above amount of health to the giant spores. 1 means every wave, 2 means every other wave, 3 every third wave, etc.
startingWaveThe wave after which it should start adding health to each individual spore tower.
addHealthDelayThis is the amount of time it should wait before attempting to change the health of the spores generated by the spore tower.


Also, I'm not sure what exactly you mean by increasing the health 20 seconds after each spore wave, since it shouldn't matter when you increase it, so long as you increase it before the next wave fires. However, I added the variable addHealthDelay that will wait that many frames before it tries to increase the health again. It does this globally via the game time, so if you have any other scripts that modify or change the game time in any way, expect this to bug out.

To get this working, you'll have to make a very slight modification to the custom spore tower. Somewhere in the once...endonce block, add this line of code:
184 ->GetCoresIdentifier
This script uses that variable GetCoresIdentifier to find all the custom spore towers on the map, so try not to modify that. I also assumed that the name of the script attached to the custom spore towers was "CustomSporeTower.crpl", as shown in your third piece of code. If this is not the case, just replace "CustomSporeTower.crpl" with the real name of it everywhere in this script.

Other than that, just build a CRPL tower somewhere, attach this to it, set all the variables, and it should work.

I hope this helps. If you notice any bugs, please let me know, and I will try to fix them as soon as I can!
"Only a life lived for others is a life worthwhile."
-Albert Einstein

Narcosis

The code you gave doesn't appear to work. I think the problem is the code you told me to add to customsporetower 
(184 ->GetCoresIdentifier). I tried setting the trace log on CustomSporeHealthModifier to check how many instances of the code it finds, (I'm not sure if I'm using the trace log right)and it says it finds zero instances of it despite there being several cores with customsporetower on the map.

ParkourPenguin

Could you provide a save.cw3 file?
"Only a life lived for others is a life worthwhile."
-Albert Einstein

Narcosis

This is a copy of the file with most of the irrelevant stuff removed to avoid spoilers. I left the trace log on the CustomSporeHealthModifier incase I was using it wrong. Just to let you know its playability hasn't been tested yet so there's no need to comment on that.