Random Region Spawn, help

CroMoX

New Member
Reaction score
2
Hey guys I was trying to make a trigger where I buy a unit from the tavern, and randomly move it to one of eight set regions on the map, but I wanted to make it since there are 8 players maximum in the map, another person cannot move to that region, and has to move to an unused region.

This is so everyone will spawn at different regions, no doubling up so they cannot kill each other. I already have my regions put in an array, but when I tried to do the actual trigger I could not work out how to do it, I tried loops with integers but it never worked, and I cannot get my head around how to do it.

Any help would be appreciated.

If you need a better description please ask, and I will try to further extend on it

EDIT: Each player will only have one hero each
 

thorhunter

You can change this now in User CP.
Reaction score
32
Initialization Trigger:
Event - Map Initialization
Actions -
//Set Array of regions:
Region[1]=xxx
.
.
Region[8]=xxx

Hero picking trigger:
Event - Unit enters <region> "Playable map area"
Condition - Triggering unit is a hero = true
Actions -
Move 'Triggering unit' to <center of region> "Region[Player Number of 'Owner of triggering unit']


If players get more heroes later on you should turn off or destroy the triggers as soon as you can or modify the conditions (like check number of heroes player has etc.)
 

CroMoX

New Member
Reaction score
2
Well that is similar to what I want, but I don't want them to have a player specific region like you have, what I was hoping more for was that they had a random chance to move to any region, not their player number region, but another person couldn't move to that one.

E.g a number is randomly made when a character is picked out of 1 - 8, I get 7 and move to the 7th region in the array. Then another person gets a character, and they get a 7 too, I want it so they cannot move there, and that it gets re-rolled.

The part I couldn't do was how to make it find if it's the same region/number rolled, and to random another number and check, until I get one that hasn't been taken.

Thanks for the reply
 

thorhunter

You can change this now in User CP.
Reaction score
32
I see.

Initialization Trigger:

Event - Map Initialization
Actions -
//Set Array of regions:
Region[1]=xxx
.
.
Region[8]=xxx
Set Regions_integer=8


Hero picking trigger:

Event - Unit enters <region> "Playable map area"
Condition - Triggering unit is a hero = true
Actions -
Set Temp_integer=Random number between 1 and Regions_integer
Move 'Triggering unit' to <center of region> Region[Temp_integer]
For loop (Integer A) from 'Temp_integer' to 'Regions_integer -1'
Region[Integer A] = Region[Integer A] +1
Regions_integer=Regions_integer-1
 

CroMoX

New Member
Reaction score
2
Is the variable regions_Integer set to anything in the variables tab? (I mean is it not default 0)

I tried what you got there, and it doesn't work, like it works for a couple of tries then they all just continue spawning at the same area, it doesn't work for the 8 times.

Code:
Move Trigger
    Events
        Unit - A unit Sells a unit
    Conditions
        ((Triggering unit) is A structure) Equal to True
        (Unit-type of (Triggering unit)) Equal to Tavern of the Depths
    Actions
        Set RndInt = (Random integer number between 1 and RegionInteger)
        Custom script:  set bj_wantDestroyGroup = true
        Unit - Move (Sold unit) instantly to (Center of SpawnRegion[RndInt])
        For each (Integer A) from RndInt to (RegionInteger - 1), do (Actions)
            Loop - Actions
                Set SpawnRegion[(Integer A)] = SpawnRegion[((Integer A) + 1)]
                Set RegionInteger = (RegionInteger - 1)
 

afisakov

You can change this now in User CP.
Reaction score
37
Is the variable regions_Integer set to anything in the variables tab? (I mean is it not default 0)

I tried what you got there, and it doesn't work, like it works for a couple of tries then they all just continue spawning at the same area, it doesn't work for the 8 times.

Code:
Move Trigger
    Events
        Unit - A unit Sells a unit
    Conditions
        ((Triggering unit) is A structure) Equal to True
        (Unit-type of (Triggering unit)) Equal to Tavern of the Depths
    Actions
        Set RndInt = (Random integer number between 1 and RegionInteger)
       [B] Custom script:  set bj_wantDestroyGroup = true[/B]
        Unit - Move (Sold unit) instantly to (Center of SpawnRegion[RndInt])
        For each (Integer A) from RndInt to (RegionInteger - 1), do (Actions)
            Loop - Actions
                Set SpawnRegion[(Integer A)] = SpawnRegion[((Integer A) + 1)]
             [B]   Set RegionInteger = (RegionInteger - 1)[/B]

Why do you use wantdestroygroup here? you do not reference a unit group therefore this serves no purpose.

The error in your trigger is that "Set RegionInteger = (RegionInteger - 1)" is not supposed to be in the loop.
The purpose is of the loop is to shift the regions over one space to remove the spot of the used region. After they are all moved, you decrease the regioninteger once to account for having one less region. The way you had it, it dropped to 0 in 2-4 runs, depending on what region it randomed, and then no longer was able to randomize the region.

P.S. ((Triggering unit) is A structure) Equal to True is redundant if you already check unit_type=tavern of depths
 

CroMoX

New Member
Reaction score
2
Ok I will give it a go in a second. I did the wrong thing to remove leaks was meant to set variable and remove location (derp on my part).

EDIT: It worked thank you so much both of you for the help.
 
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

      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