Food Limit vs Tower Construction

Manee

New Member
Reaction score
20
I made a skill that will enable my hero to build towers but the hero ignores the food limit everytime it builds...

what i want is that it can only build a number of towers depending on his food cap

what i've done so far is :

Code:
Events
Unit -A unit starts the effect of an ability
Condition
(Ability being cast) equal to Build Tower
Actions
If/then/else
If-Conditions
((Picked Player) food cost) is equal to ((Picked Player) food cap)
Then-Actions
Else Actions

then...? what triggers must i make next?
 

Builder Bob

Live free or don't
Reaction score
249
If you use the event Starts casting an ability, you can actually order the unit to stop if you don't have enough food.

The ability has not yet been cast when that event fires.
 

Manee

New Member
Reaction score
20
ok this is what i made

Code:
Events
Unit -A unit starts the effect of an ability
Condition
(Ability being cast) equal to Build Tower
Actions
If/then/else
If-Conditions
((Picked Player) food cost) is equal to ((Picked Player) food cap)
Then-Actions
Unit- Order (Casting unit) to stop
Else Actions

problem here is, the casting unit is being stopped even if the food cap is not yet reached
 

Builder Bob

Live free or don't
Reaction score
249
Use Triggering Player instead. That means the player that triggered the event.

Code:
Conditions
    Or - Any (Conditions) are true
        Conditions
            (((Triggering player) Food used) + 1) Greater than or equal to ((Triggering player) Food cap)
            (((Triggering player) Food used) + 1) Greater than or equal to ((Triggering player) Food max)

I used an arithmetic function to make the + 1. Replace the number with the food cost of the tower.

Two conditions should be used to prevent the player from going over the upper limit of food allowed on the map.
 

DrinkSlurm

Eat Bachelor Chow!
Reaction score
50
Code:
Untitled Trigger 002
    Events
        Unit - A unit Begins casting an ability
    Conditions
        (Ability being cast) Equal to Build Tower
        Or - Any (Conditions) are true
            Conditions
                (((Owner of (Triggering unit)) Food used) + 1) Greater than or equal to ((Owner of (Triggering unit)) Food cap)
                (((Owner of (Triggering unit)) Food used) + 1) Greater than or equal to ((Owner of (Triggering unit)) Food max        Unit - Order (Triggering unit) to Stop
 

Builder Bob

Live free or don't
Reaction score
249
nope, not working...

Hmm... I just tested making the trigger to see what happened.
The conditions work as intended, but the problem seem to be with the stop order. I find it a bit odd that the unit won't stop when receiving the order.

However, I do have a workaround. Make a dummy unit that casts an instant (custom variation of the ability) storm bolt with duration 0.01 and no damage on the caster in addition to ordering it to stop. Tested and working solution.
 

Manee

New Member
Reaction score
20
Code:
Untitled Trigger 002
    Events
        Unit - A unit Begins casting an ability
    Conditions
        (Ability being cast) Equal to Build Tower
        Or - Any (Conditions) are true
            Conditions
                (((Owner of (Triggering unit)) Food used) + 1) Greater than or equal to ((Owner of (Triggering unit)) Food cap)
                (((Owner of (Triggering unit)) Food used) + 1) Greater than or equal to ((Owner of (Triggering unit)) Food cap)
    Actions
        Unit - Order (Triggering unit) to Stop

still not working, the hero gets stopped even if the food cap is not yet reached/exeeded
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      • Ghan
        Administrator - Servers are fun

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top