Very complex script, can i simplify?

Status
Not open for further replies.
Level 2
Joined
Feb 12, 2010
Messages
7
Well, as the title suggests, i have a very complex script, for a very simple idea. Ill post parts of it in pics with this message:

Picture 1:
These are my 6 regions, each of which represent a room of a certain player, 1-6. The concept behind this is when a character from one room enters someone elses room he is able to build towers that are combination of the two. Like, player ones character enters player 2s room. Now player one and two can build towers of both elements. This is simular to element TD where if you have water and fire, you can build water/fire towers.

Picture 2:
This is what i want to happen when the rooms are entered. in this case the bird has entered the red colourd room. Since the player is the bird, the bird is displayed in the box beside the room marker, then the room marker of that colour is displayed, and then if other characters are in that room/enter the room they are spawned in their spots as well. And when they leave for them to be removed also.

So my solution was to assign a multiple of 10 to each character, 1, 10, 100, 1000 etc. So that when i add them together i get a unique number for each combination of characters possible in a room at one time. When the bird is in the room its value is 1, when the bird and the vengence guy are in it its 101, when the bird dragon and vengence guy are in a room its 10101... etc.

Well, with 6 characters each character has 32 possible combinations that it can be involved in. So thats 32 combinations per room, per character. But i continued, and i set up a trigger so that when a certain guy enters a room, it increases or decreases the rooms value based on his number. And then based on the value of the room it spawns the only possible combination of characters that can be in that room for the players.

Then of course, depending on what characters you have control of it gives you the ability to build certain towers. And when they leave the room, or you leave the room, you lose that ability

Picture 3:
But it is a VERY long script... (notice the multiple scripts on the side, and how long this particular script is)
This script DOES work the way i want it, but im sure 1000+ lines of code for a simple action can be simplified?

any ideas?
 

Attachments

  • Picture1.jpg
    Picture1.jpg
    199.1 KB · Views: 84
  • picture 2.jpg
    picture 2.jpg
    185 KB · Views: 105
  • picture3.jpg
    picture3.jpg
    246.4 KB · Views: 108
Level 6
Joined
Jan 31, 2009
Messages
166
What your asking for is a bit confusing so il recap what I think your asking.

a) When players enter a room depending on what players it spawns certain things.

b) you have assigned a value of 10 to each character so that It will form a unique integer each time to control the spawns.

Assuming the first two are true you could use Substrings to control the rest simple use this Psedocode

If substring String(Roomentered) 6 = "1"
then
Create 1 unit (The unit thats supposed to spawn for that hero)
else
if substring String(Roomentered) 5 = "1"
then
Create 1 unit (The unit thats suposed to spawn for this hero)
else

So on you get the point.
(Note thats not real Gui or Jass its just a rough outline of what you would do)

Hopeful this should narrow it down to only 6 if then else statements you could make it even less by using an array of units and a loop.

Anyway.... Hope you understand that and hope I understood what you where asking for correctly...
 
This doesn't make any sense. Why does room 1111 have six actions and 110001 have only four? If each room has totally different actions then you can't simplify.

Also, this trigger must be causing your map some serious lag. I imagine that this one trigger consumes about 50-100KB on your map. Once you are able to simplify some of this then you should convert it to JASS and cut this trigger down to perhaps 5-10KB...
 
Level 2
Joined
Feb 12, 2010
Messages
7
Arcmage almost had it, Sorry its so confusing. Basically, each character is assigned a multiple of 10. character 1 is 1, 2 is 10, 3 is 100, 4 is 1000, 5 is 10000 and 6 is 100000. Each time a character enteres or leaves a room his number is added or subtracted from the room number, and if you create a table of all possible combinations of units in a single room (there are 32) thats now many triggers sub strings i have per room.
Room 1111 has 6 actions because characters 1, 2, 3, 4, are in the room when it = 1111. So it must create the spawning character for each character already in the room, AND it must create a character of each one in the room for the character that triggered it. room 110001 only has 3 characters, so thats less than the 4 needed for 1111.

im kinda hoping there is a way to do something like, when a character enters a room, check the room for other characters and do actions for each in room, that way like one line represents all possible combinations.


Thanks for your replies, Arcmage ill look into what you suggested
 
Level 18
Joined
Jan 21, 2006
Messages
2,552
So the amount of ones represents the amount of players in a room. Based on the amount of players in that room, you want to create a special unit? Who is this "player that triggered it" you mean the player who last enters the region? Can you give a really detailed example (maybe a picture) of what you're talking about?
 
Level 3
Joined
Feb 23, 2010
Messages
73
Acually, if i understand what you are trying to do, the solution is simple. What you are doing now is converting every variable situation into integer values, ie. the combination of a bird and a tank would both have integer value that have a unique output. All you need to do is incorporate other variable into the quation. For instance unit type, unit classification, point values, custom values... the list goes on.
say you have 5 basic units to enter rooms, thus giving a total of 120 different outcomes.
first, you can eliminate a few by saying
  • Actions
    • Set Room1UG = Units in (Room1)
    • If (Count units in (Room1UG)) Equal to 0
      • Then
        • Comment - dont make any combo guy, whatever method you use
      • Else
        • Do Nothing
if you do have guys in there, then you simply use unit types to set your outcomes. Its not hard, you dont need to use those rediculous integers at all..
 
Level 3
Joined
Feb 23, 2010
Messages
73
I forgot to mention, to save yourself from cluttering, dont make each function into a seperate trigger. Use If/Then/Else functions spread across 1 trigger to make things easier. If this was no help, you can send me the map if you'd like.
 
Level 4
Joined
Jul 28, 2009
Messages
64
This seems like an interesting problem. Could you possibly upload the map you have so far so we can better understand? I think it could have a pretty simple and efficient solution, but i cant quite understand what is going on.
 
Level 2
Joined
Feb 12, 2010
Messages
7
Okay, basically what it is is a trigger that is placed above each player. It tells that player Which room they are in, Who their character is, and Who is in the room with them. Hopefully the attached picture will help explain it.


Edit: If you right click on the image popup, and click view image, you can see the full size its easier to read and see.
 

Attachments

  • Explination.jpg
    Explination.jpg
    235 KB · Views: 66
Last edited:
Level 25
Joined
May 11, 2007
Messages
4,650
Level 18
Joined
Jan 21, 2006
Messages
2,552
It sounds like a really simple idea that you're inflating with your words... and to top if off you use names like "Jake" to really confuse the reader. Calculus can be described easier than what you're making this seem like.
 
Level 2
Joined
Feb 12, 2010
Messages
7
Oiy.. Jake is the bird.. I gave em names to make it EASIER.

Hero goes into room, player gets ability to build towers.
Another hero joins that hero in the room, players both get ability to build different types of towers.

If youve ever played ELEMENT TD, then youll understand the element idea. Its the same idea with a different way to get the "elements"

When the players are together they share elements, when they are not together they do not share elements.

The problem i have is showing whos in what room, and whos with them.

Look at the pictures... its pretty much self explanatory. And i dont think i can explain it any clearer unless i upload videos, which i shouldnt have to do.
 
Level 9
Joined
Nov 28, 2008
Messages
704
I'm going to start off by saying when you have to create that many triggers, you are doing something wrong. This is a situation where you want to use loops, not manually create each if check.

Currently, you are creating a builder for each player with the different towers on it. I'm going to say that I hate when TD's do that. Give all the towers to one unit. Then make them require a unit or something. Make one type of unit for each of your elements.

Next, create an "enter region" event for all 6 regions in the same trigger. 6 events.

Under actions, check for all of the units within the (entered rect) that are of the type of your builder. Create these required units for the player who entered, and for every other player in the room, add the unit for the guy who entered the room.

Leaving is similar and you should be able to figure it out.

Go from there, good luck.
 
Level 18
Joined
Jan 21, 2006
Messages
2,552
Why don't you distribute some sort of ability when a player enters another player's region to all of the players in that region. I've never actually played Element TD. So you want it so that if a "Fire" goes into a "Water"'s region then the "Water" gains the "Fire" buildings (or whatever) and the "Fire" gains the water buildings (or whatever)?
 
Status
Not open for further replies.
Top