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.
  • Ghan Ghan:
    Howdy
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage
    +2
  • V-SNES V-SNES:
    Happy Friday!
    +1

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top