Array Help

YoyoZ

New Member
Reaction score
3
Have no idea but this is suppose to increase the persons mana by 1. The first time it is 1 but the second time 2 and third 3 and so on. Anyone know why?
Theres no event coz another trigger adds the event later on.

Code:
Freight
    Events
    Conditions
        (Unit-type of (Triggering unit)) Equal to Chicken
    Actions
        Wait 1.00 seconds
        For each (Integer A) from 1 to 15, do (Actions)
            Loop - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        (ShopRegions[(Integer A)] contains (Triggering unit)) Equal to True
                    Then - Actions
                        Unit Group - Pick every unit in (Units in ShopRegions[(Integer A)] matching (((Matching unit) is A structure) Equal to True)) and do (Unit - Set mana of (Picked unit) to ((Mana of (Picked unit)) + 1.00))
                    Else - Actions
                        Do nothing
        Unit - Remove (Triggering unit) from the game

Thanks in advance
 

Exide

I am amazingly focused right now!
Reaction score
448
What event does this trigger have? (The one that is added through another trigger.)

Unit Group leaks memory.
You can remove the action: Do nothing

Your trigger adds mana to structures only. -Structures don't usually use mana.
 

Curo

Why am I still playing this game...?
Reaction score
109
Your trigger adds mana to structures only. -Structures don't usually use mana.

They do in a Tower Defense.

What do you mean by "the first time"? The first time the loop runs, or the first time the trigger runs?

And yes, I'd love to see the event. Chickens intrigue me.

You can clean the leak by using Set TempGroup = Units in ShopRegions[(Integer A)] matching (((Matching unit) is A structure) Equal to True). Then, Unit Group - Pick every unit in TempGroup. And finally, call DestroyGroup (udg_TempGroup).

And just to clarify, you DO set ShopRegions[1]...ShopRegions[15], right? And finally, remember that for each region your chicken is in, all buildings will gain one mana. So if it's in all 15 regions, all buildings gain 15 mana.
 

YoyoZ

New Member
Reaction score
3
Thanks for reply

First, to answer Curo's three questions, 1.by the first time, i mean the first time the trigger runs, 2.Yes, i have set the ShopRegions[1]-[15]. 3.and finally no, i'm pretty sure that the mana of the building will not increase by one for every chicken in each region. The trigger says if chicken is in ShopRegion[1] then increase the mana for stucture in SHopRegion[1] if chicken in ShopRegion[2] increase mana for stucture in shopregion[2]. Know what i mean???

The Event is basically Unit enters region shopregion(1-15)
what the trigger is suppose to do is that there is a factory and a shop. The shop sells things. the factory makes things. the factry, at a certain time, will create a chicken(stock) and send it to the shop. When the shop receives the chicken(stock) it increases the mana of the shop by 1(which is the stock level).

Each shop region has its own factory so the intergerA is suppose to make sure that if the chicken arrives at shopregion1 to only increase mana of the shop in shopregion1. As the shop is build later on in game, i can select the shop and thats why i used unit group.

what the errors is, is that the first time a chicken arrives at the shop, it increases the mana of the shop by 1, but the second time a chicken arrives, it increases it by 2. Also, its not really the amount of times the trigger runs, but the amount of time the trigger runs for that particular interger. e.g. ShopRegion[1] runs 2 times, mana = +2 then i create it for ShopRegion[2] and it runs first time, mana+1

Hope its clear enough and thanks again
 

PoZoR

New Member
Reaction score
5
your trigger will increase mana according to how many chickens ARE IN THE REGION. also, using a loop is unnecessary, the event "unit enters region" is sufficient, you do not need to check if the chicken is in the region because the event can only trigger if the chicken enters the region anyway.
 

YoyoZ

New Member
Reaction score
3
ok, first, the intergerA is necessary as i have 15 different regions and according to which region the chicken enters, the stucture in that region will gain 1 mana. that is the reason for chick if the chicken has entered region as i need it to activiate intergerA. It is correct that the mana increase is dependent on the chickens inside the region but according to my trigger, the first chicken should have been removed and there should only always b 1 chicken in the reigion and therefore only +1 mana.

I wondered also if it is because of the 'remove unit' action that is causing this, should i use kill instead? or instant move away then remove?
 

YoyoZ

New Member
Reaction score
3
Haha, don't worry, fixed it, i was rite, is still counted my 'removed unit' as another unit. thats the reason for the pheomonen. Anyways, thanks for all ur helpz
 

PoZoR

New Member
Reaction score
5
killing will definately leave a unit there, removing im pretty sure doesnt. if it does, try adding more conditions to the trigger when checking for number of chickens, such as "matching unit is alive" and such.
 
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