change unit when he kills an enemy

guneruh

Member
Reaction score
1
Hi, i would like to know how to make a unit (non hero) change for another one (like leveling up) when it kills X amount of enemies.

For example, i made 5 soldiers, each one more powerful than the one before, i want that lvl 1 soldier changes to lvl 2 soldier when he kills 2 enemies. After that, i want lvl 2 soldier to change to lvl 3 soldies when he kills 5 enemies. then lvl 3 to lvl 4 when he kills 10 enemies, finally lvl 4 to lvl 5 when he kills 20 enemies.

how could i make that? i want it to be a normal unit not a hero.
 

WolfieeifloW

WEHZ Helper
Reaction score
372
Use a variable, and store the number of kills the unit has in that variable.
Then, when it kills something, check the variable and if it's equal to the magic number you want, replace the unit with another solder.

Look for "Unit - Replace" in the functions list.
 

guneruh

Member
Reaction score
1
Use a variable, and store the number of kills the unit has in that variable.
Then, when it kills something, check the variable and if it's equal to the magic number you want, replace the unit with another solder.

Look for "Unit - Replace" in the functions list.

i know how to replace units, but what kind of variable should i use?
 

keychup

Active Member
Reaction score
34
You could use an "Integer" variable and record the number of kills each unit makes by specifying the key unit in a hashtable. *wink wink*
 

guneruh

Member
Reaction score
1
A recommendation, use AIDS, and then store each unit in an integer array. If you need help I can do it for you.

weeeeeell.... i would love to do it by myself, but i have always been a dummy with the damn variables... i't woulb nice if it's not an inconvenience :)
 

keychup

Active Member
Reaction score
34
oh,oh,oh. another idea just popped up. You can give the units some mana. the maximum amount of mana it has will be the number of units it needs to kill. when it kills 1 unit add 1 to mana. once the mana is full make a trigger to replace that unit with another unit with 0 mana. when it reaches the maximum mana capacity again you can replace the unit with another stronger unit. :D

i.e. make the mana your kill counter.
 

guneruh

Member
Reaction score
1
oh,oh,oh. another idea just popped up. You can give the units some mana. the maximum amount of mana it has will be the number of units it needs to kill. when it kills 1 unit add 1 to mana. once the mana is full make a trigger to replace that unit with another unit with 0 mana. when it reaches the maximum mana capacity again you can replace the unit with another stronger unit. :D

i.e. make the mana your kill counter.

that's a nice idea, i will try it ;)
 

guneruh

Member
Reaction score
1
now that i think about it, the mana thing wouldn't work because i do want to have also caster units with this method :S
 

keychup

Active Member
Reaction score
34
yeah there are limitations. if i were you id have casters with cooldowns instead of mana costs. also id change the numbers on heals and durations and stuffs so that the spell would be reasonable even without manacosts.
 

WolfieeifloW

WEHZ Helper
Reaction score
372
That's way more work then just using a variable for each unit.
Use an integer array, and search up a variable tutorial, it will help you :) !
 

keychup

Active Member
Reaction score
34
"way" more work? all you need is the event "a unit dies", and action "set mana of killing unit to mana of killing unit + 1" and "if mana of killing unit is equal to max mana of killing unit then replace unit else do nothing".

but anyway, you'd better listen to wolfieeiflow if you're planning using the mana system for casters.
 

WolfieeifloW

WEHZ Helper
Reaction score
372
I meant the fact of balancing out cooldowns and damage/heal amounts just to not use mana.

Some other options, besides an integer array:
An item with charges.
A spell with charges.
 

guneruh

Member
Reaction score
1
thx for the help people =) i'd better go with the variable idea, i don't want to lose the mana system, =) i already did the variable, but i don't really know the meaning of "array" english isn't my first language, even speaking it well i have limitations lol.
 

WolfieeifloW

WEHZ Helper
Reaction score
372
I'm really bad at explaining things, but:

An array allows you to store multiple things in the single variable.
Instead of making 'variable1, variable2, variable3' etc. you can use an array.

So, it's just 'variable[1], variable[2]'.

It's one variable, with a numerical reference in square brackets after it.
 

guneruh

Member
Reaction score
1
I'm really bad at explaining things, but:

An array allows you to store multiple things in the single variable.
Instead of making 'variable1, variable2, variable3' etc. you can use an array.

So, it's just 'variable[1], variable[2]'.

It's one variable, with a numerical reference in square brackets after it.

ok, done, now how do i use this variable?
 

WolfieeifloW

WEHZ Helper
Reaction score
372
It's going to be quite complicated..
You'd have to assign each unit it's own number in the array (First unit that spawns is 1, second is 2, etc.).
Which gets me thinking, you'd need a unit array.
Then, when a unit kills something, you'd have to check what unit it is, then add to that unit's matching integer array.

I'm thinking you should just add a skill to each unit, or an item.
Or wait for someone else who can maybe simplify the variable system for you.

I personally would go with a spell.
 

guneruh

Member
Reaction score
1
It's going to be quite complicated..
You'd have to assign each unit it's own number in the array (First unit that spawns is 1, second is 2, etc.).
Which gets me thinking, you'd need a unit array.
Then, when a unit kills something, you'd have to check what unit it is, then add to that unit's matching integer array.

I'm thinking you should just add a skill to each unit, or an item.
Or wait for someone else who can maybe simplify the variable system for you.

I personally would go with a spell.

i'd like it to be automathic, so i don't have to click every unit that kills X units, that's why i want it this way... so could anyone quote me the trigger, i just don't idea from where to start :S
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top