Random level of ability

SarChasm

New Member
Reaction score
15
I have a system that works like this. Players make a "Child" unit that has a Timed Life. Once this expires, it turns into a grown adult. This adult has 1000 mana, and will die once he runs out of mana. Adults can change professions via an ability that replaces it with the desired profession.

For the aging process, I made a 6 level ability based off Brilliance Aura. Each level of the ability will regen (or should I say degen?) mana at a different rate. Once a Child unit becomes an adult, I want the adult unit to receive a random level of the aging process ability, and for it to carry on when he changes profession.

So I tested it out, and the trigger looks something like this:

Trigger:
  • ChildGrow
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Killing unit) Equal to No unit
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit-type of (Dying unit)) Equal to Female Child
        • Then - Actions
          • Unit - Remove (Dying unit) from the game
          • Unit - Create 1 Villager (Female) for (Owner of (Dying unit)) at (Position of (Dying unit)) facing Default building facing degrees
          • For each (Integer A) from 0 to (Random integer number between 0 and 6), do (Actions)
            • Loop - Actions
              • Unit - Increase level of Aging Process for (Last created unit)
        • Else - Actions
          • Do nothing
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit-type of (Dying unit)) Equal to Male Child
        • Then - Actions
          • Unit - Remove (Dying unit) from the game
          • Unit - Create 1 Villager (Male) for (Owner of (Dying unit)) at (Position of (Dying unit)) facing Default building facing degrees
          • For each (Integer A) from 0 to (Random integer number between 0 and 6), do (Actions)
            • Loop - Actions
              • Unit - Increase level of Aging Process for (Last created unit)
        • Else - Actions
          • Do nothing


As you can see, the created villager will have his "Aging Process" ability leveled by a random number from 0-6. It is indeed random, but the problem comes when I change profession. No matter what the Villager's "Aging Process" level was before, it will always revert back to the first level.

This is the profession changing trigger:
Trigger:
  • ChangeJob
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Ability being cast) Equal to Become Archer
        • Then - Actions
          • Unit - Replace (Casting unit) with a Archer using The old unit's relative life and mana
          • Selection - Add (Last replaced unit) to selection for (Owner of (Casting unit))
        • Else - Actions
          • Do nothing


I only included one profession for less headache.

So the question is: what do I need to do so that the level of "Aging Process" remains the same throughout profession changes?

It's a bit confusing, so just say if you need clarification.
 

Komaqtion

You can change this now in User CP.
Reaction score
469
Add the action Set level of Ability for unit, and set it to level of aging ability of last replaced unit or something... Sorry, don't have WE open atm :( And change the event to A unit Starts the effect of an ability, and remove the If and just add the ability condition to the "preplaced" condition area ;)
 

Renendaru

(Evol)ution is nothing without love.
Reaction score
309
Try storing the integer that was randomed in the first trigger, then recall it using an array.
 

SarChasm

New Member
Reaction score
15
Trigger:
  • ChangeJob
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Ability being cast) Equal to Become Archer
        • Then - Actions
          • Unit - Replace (Casting unit) with a Archer using The old unit's relative life and mana
          • Unit - Set level of Aging Process for (Last replaced unit) to (Level of Aging Process for (Casting unit))
          • Selection - Add (Last replaced unit) to selection for (Owner of (Casting unit))
        • Else - Actions
          • Do nothing


Would that work or would it not because the Casting unit is gone?

BTW, I have the condition in an If/Then/Else statement because there's more than one, and I wanted to keep all the jobs in the same trigger. :p

EDIT: This doesn't appear to be working from my tests. Any other ideas?
 

Nexor

...
Reaction score
74
change casting unit to Triggering Unit, triggering unit won't be forgotten through the trigger
 

Komaqtion

You can change this now in User CP.
Reaction score
469
Try to use an integer variable before replacing the unit, and set it to the level of Aging process for Triggering unit (Change all Casting unit to Triggering unit :D)
And change the event to A unit Starts the effect of an ability :D
 
General chit-chat
Help Users

      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