|  |
|  |
04-18-2006, 09:59 PM
|
#1 (permalink)
|
Join Date: May 2003 Location: Temple Prime, Sarajevo Age: 22 Posts: 16,118
| Random hero theory You know how in Footmen Frenzy by Hato, you can get a random hero from the tavern then it will randomly pick you one. I wonder how that is done.
In my theory, I can declare an array that holds unit type, up to the number of heroes + the secrets. Then whenever a random hero is done, that person gets a random number from 0-max and that number will reference an element in the array. Like if you get 0, you can get Paladin or if you get 35: you get Bill.
But there must be another way in theory. Well declaring an array takes up memory on your PC. Its the size of a Unit Object (like footman or something's info) x the max number of elements. You can easily blow a high amount of space, but its more efficient.
Why I want to know this? Well, maybe there is a way that you don't really need an array, have to blow memory then destroy it (all wanted memory such as variables are destroyed when the game ends). I can figure it out, but some input would help! |
| | | | Sponsored Links |
04-19-2006, 01:00 AM
|
#2 (permalink)
| I still play games
Join Date: Nov 2003 Posts: 1,725
| Unit Aquires Item
Item equal to "Random Hero"
If Then Else:
If Random Integer between 1 and (ammount of heroes) is equal to 1 (or whatever).
Then create hero for owner of triggering unit at region.
Else do nothing.
__________________ Quote: |
My perception crit, now I can see why kids love Cinnamon Toast Crunch cereal.
| |
| |
04-19-2006, 02:48 AM
|
#3 (permalink)
| BattleForums Senior Member
Join Date: Feb 2005 Location: Arcanum Age: 18 Posts: 1,936
| I think you are right Chris. Maybe we should put that in our map Marc :O
__________________ (\_/)
(O.o)
(> <) Bunnies rule the world. Paste him in your sig for world domination! Married to §tar§oft
:heart Krobelus :heart Quote: |
Originally Posted by §tar§oft don't make me smother your face in my thousand year old pussy | Quote: |
Originally Posted by Trojan Because Jenny is like an unfiltered bottle of water. You want it, but once you see whats on the bottom, you go ewww. | Thanks to Hellwolf_36 for my avatars . |
| |
04-19-2006, 04:10 AM
|
#4 (permalink)
|
Join Date: May 2003 Location: Temple Prime, Sarajevo Age: 22 Posts: 16,118
| I know how the trigger works Marc, its my theory and its the only one that I know works. Besides, indexes start at 0. |
| |
04-20-2006, 03:50 AM
|
#5 (permalink)
| I still play games
Join Date: Nov 2003 Posts: 1,725
| Quote: |
Originally Posted by Hellwolf_36 I know how the trigger works Marc, its my theory and its the only one that I know works. Besides, indexes start at 0. | I'm not talking about indexes.
__________________ Quote: |
My perception crit, now I can see why kids love Cinnamon Toast Crunch cereal.
| |
| |
04-20-2006, 03:51 AM
|
#6 (permalink)
|
Join Date: May 2003 Location: Temple Prime, Sarajevo Age: 22 Posts: 16,118
| If you don't use indexes. You would need 1-whatever maximum heroes you can have in one huge ass if statement chain. Variables are good for these reasons  . |
| |
04-20-2006, 03:55 AM
|
#7 (permalink)
| Aya Matsuura is awesome
Join Date: Nov 2002 Location: Trieste, Friuli-Venezia Giulia Age: 20 Posts: 15,282
| You could generate all 36 heroes in a region, make them Neutral Hostile and make them invisible to all and get a trigger to pick a random unit inside that region, then change its user and make it visible, but that blows even more memory.
No, I think the above way is the only sensible way.
Besides, a 36-member array is nothing compared to the visual effects in games like D-Day.*
__________________ * IM IN UR WIKI RVRTING UR EDITS |
| |
04-20-2006, 03:57 AM
|
#8 (permalink)
|
Join Date: May 2003 Location: Temple Prime, Sarajevo Age: 22 Posts: 16,118
| Well, the problem is when you allocate memory, you need to destroy it. Sometimes, memory isn't destroyed or destroyed completely, so you start getting small "data leaks". Also, you would need to display these heroes in a section of the map where nobody can see them.
But the memory of a hero depends on what makes up a "unit". If it's small, then its no problem. But if it's big... then there is a problem.
Last edited by Chris; 04-20-2006 at 04:01 AM.
|
| |
04-20-2006, 04:50 AM
|
#9 (permalink)
| Aya Matsuura is awesome
Join Date: Nov 2002 Location: Trieste, Friuli-Venezia Giulia Age: 20 Posts: 15,282
| Quote: |
Originally Posted by Hellwolf_36 Well, the problem is when you allocate memory, you need to destroy it. Sometimes, memory isn't destroyed or destroyed completely, so you start getting small "data leaks". Also, you would need to display these heroes in a section of the map where nobody can see them.
But the memory of a hero depends on what makes up a "unit". If it's small, then its no problem. But if it's big... then there is a problem. | I think Warcraft is secure enough for those memory leaks. Besides, the memory leaked from loading 36 models shouldn't be detrimental.*
__________________ * IM IN UR WIKI RVRTING UR EDITS |
| |
04-20-2006, 05:46 AM
|
#10 (permalink)
|
Join Date: May 2003 Location: Temple Prime, Sarajevo Age: 22 Posts: 16,118
| Well, the array of units is probably a pointer to unit objects. So it will only take up the memory of what its pointing too. Like in C++, a class can have something like
char * y;
This is a char pointer that is currently Null. You can use Dynamic Memory Allocation to populate it with whatever you wanted. Like to put the word LOL in it, you would need to allocate 4 elements (1 byte/element up to 3, including the terminating byte).
Units might be classes in that case, so there would be a pointer of unit classes inside the program when you do this. So, I guess it would be fine, I will try it out and see if there is any changes.
Man this talk about arrays has really gone technical. |
| |
04-20-2006, 03:15 PM
|
#11 (permalink)
| Aya Matsuura is awesome
Join Date: Nov 2002 Location: Trieste, Friuli-Venezia Giulia Age: 20 Posts: 15,282
| You don't have to go that far. D-Day, one of the most complicated maps out there, has tons of variables and plenty of arrays. Yet the game seldom crashes on high-end computers (if ever). Memory leak? Nah.*
__________________ * IM IN UR WIKI RVRTING UR EDITS |
| |
04-20-2006, 04:57 PM
|
#12 (permalink)
|
Join Date: May 2003 Location: Temple Prime, Sarajevo Age: 22 Posts: 16,118
| I guess the guy must be doing something dumb in that map like referencing outside the bounds of an array. The Fatal Error is a fail safe to avoid crashing the game too bad. |
| |
04-20-2006, 07:25 PM
|
#13 (permalink)
| Premium Member
Join Date: Nov 2002 Location: Texas Age: 22 Posts: 5,374
| Your idea for an array is the best way I can think of. Assign every Hero to a number in an array and then create a random number generator to pick one. |
| |
04-20-2006, 09:40 PM
|
#14 (permalink)
|
Join Date: May 2003 Location: Temple Prime, Sarajevo Age: 22 Posts: 16,118
| Heh, I guess I will implement it into my footmen frenzy then. |
| | | |  | | Get rid of all these ads! Take 30 seconds to register. |