• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

random battle idea

What do you think of the idea?

  • I love it, and am looking forward to the map

    Votes: 0 0.0%
  • I like it, and wouldn't mind seeing it being used

    Votes: 5 100.0%
  • I don't like it, I've seen better ideas

    Votes: 0 0.0%
  • I hate it, random battles are horrible

    Votes: 0 0.0%

  • Total voters
    5
Status
Not open for further replies.
Level 2
Joined
Jul 10, 2006
Messages
11
Hello, first of all, I'd like to ask if anyone has any idea how to make a random battle system; like the ones in the "final fantasy" series.

I am currently working on an RPG and would like to implement such a system. What I would like is for a player to walk around, and randomly, while they are walking (so not just when ordered to move, or when they stopped moving) become attacked, and moved to a pre-determined area for battles.

my version so far has a region which locks onto the player and when they move out of the region, it re-centers itself onto the player, and picks a random number (the percent chance). If certain conditions are met, the player is then moved and the battle begins. If not, then it just waits until the next time the player moves out of the region...

so far, this system has failed, because I dont know:
1 - if the region's even moving
2 - if the triggers are even working IF #1 is true
3 - how to use the "flee" command if the battle won't even start
4 - how to randomly generate monster spawns since the battle won't start
5 - where to go from here (since 1 through 4 won't work)

I need some help starting out with a template idea, or a pre-made system for use. I would like it to be area-sensative, meaning if you're in a forest, you'll fight monsters differet from those in a desert (which is commen sense). Any and all help on this matter will be greatly appreciated. Otherwise, I'll have to re-plan and re-map certain areas of my map, and that's just more of a hassle than it's worth...

P.S. - I don't know if I'm in the wrong forum, but I posted this here because it IS a system and I thought it should go here (i also could not find ANY other threads like this one with the search). And if it helps, I'm not a big JASS person, so if you help with JASS, please explain each part so I know what to change if needed...

~ Thanks Again! ~
 
Level 3
Joined
Jan 3, 2005
Messages
24
Basic Random Encounters

If you want to make a random battle system, similar to most rpg's, this should be a simple and effective way to do so, i wont go into full depth on the triggering just a basic understanding on you could do so.

Event
Every 0.50 Seconds of game time.

Condition
None(Shouldnt need one if it is solo play, if you want regions which random battles cannot occur in, place - Hero is in Region equal to false where the region is the region where no fights will occur.)

Action
- Pick All units in playable map area owned by Player1 Red
- Set player1unit(unitcounter) = picked unit
- Set player1unitloc(unitcounter) = location of picked unit
- Set unitcounter = unitcounter+1
(use this if you want to store multiple units into a variable, to then later check if any of them move)

-Wait 2seconds

-Set unitcounter = 0
- Set player1unitloc2(unitcounter) = location of picked unit
***
- If Player1unitloc1(unitcounter) =/= player1unitloc2(unitcounter) then move player1unit(unitcounter) instantly to Region0001(This is the area where the battles take place)
- Set unitcounter = unitcounter+1
-Else - Set unitcounter = unitcounter+1


***This will check every 2seconds if the location of the unit has changed, if it has they enter a random battle. To put a chance for a random battle to happen place this into the part with the 3***, and remove the If statement underneath it

Set randomfight = random integer between 1 to 100
If randomfight is <= 25 then Move instantly player1unit(unitcounter) instantly to Region0001


This should work as it checks eveyr 2seconds the location of all the units you own, and it will work individually, if you want all your units to get teleported to the battlefield, just do move instantly all units owned by player1red to Region0001.
 
Level 2
Joined
Jul 10, 2006
Messages
11
thanks, but what if i want it to be multi-player? Do i have to do that differently for each player? or can i set an array of some sort? and can i make a check to see if the unit's in a region labeled "forest area" so that they only encounter forest-type creatures? because this system only seems to be a general battle (which is what you said it was). All i'm saying, is that I dont want to be fighting sand worms in a forzen tundra.

and yes, i would like it to be random - not every set amount of time. Also, could it be possible to store the world map location of the unit before battle, so that when it's over, or when the player flees, the unit is brought back correctly? i'm sure it's an easy task, i'm just curious.

and one question about the "random" part. You said to remove the IF statement below, but wouldn't that cause the trigger to activate even if the player's standing still? what if i change the code just a little bit:

"Set randomfight = random integer between 1 to 100
If randomfight is <= 25 then (do actions below)
- If Player1unitloc1(unitcounter) =/= player1unitloc2(unitcounter) then move player1unit(unitcounter) instantly to Region0001"

that should combine both, correct? the way i see it, it's making sure the chance is correct, THEN it makes sure the unit moved, which is more like what i am looking for.

Finally, just to make sure, the "unitloc", "unitcounter", etc. are all variables, correct? if so, cool...

Thanks for your help by the way... this looks like it should work (now if only i can get it going in multi-player, and area-specific... then i'll be set).
 

Rui

Rui

Level 41
Joined
Jan 7, 2005
Messages
7,550
Have you played Final Fantasy Forever? It's really good, yet incomplete.

The fight system is fairly easy. If you don't want to create random integers, just put a fight to occur every 6 seconds for example. If you want to have certain party leader bonuses that modify how often you fight, simply use a variable instead of the 6 seconds.

I'll help you with this later, if you want.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,258
Simply run a timer every 0.1 seconds that loops through all players and compares their locations for differences, if they are different it runs the random function after checking first that they are allowed to battle then if it hits (the random number is correct) it iniciates the battle system.

The battle system works by firstly moving the hero and everyone else to the battle field and then spawning the monsters.

The monsters are generated randomly based on area and battle type.

To do this simply you set an integer array to all the unit types (game cache is also sutable for this). With about 10 units for each area. The battle types are fixed, but randomly choosen and the units used are based on area so for example, there always is a super hard battle, which could consist of 1 unit (monster offset+(area number*10)). Other battles might have more based on the functions you make.

For the flee, you run your actions and then if it hits (can run) it runs the finish battle function that removes the remaining enemy units and places the heroes where they belong.
 
Level 2
Joined
Jul 10, 2006
Messages
11
Have you played Final Fantasy Forever? It's really good, yet incomplete.

The fight system is fairly easy. If you don't want to create random integers, just put a fight to occur every 6 seconds for example. If you want to have certain party leader bonuses that modify how often you fight, simply use a variable instead of the 6 seconds.

I'll help you with this later, if you want.

yes, i like that, with the random integers, but that will occur even when the players are standing still... which is what i dont want

Simply run a timer every 0.1 seconds that loops through all players and compares their locations for differences, if they are different it runs the random function after checking first that they are allowed to battle then if it hits (the random number is correct) it iniciates the battle system.

The battle system works by firstly moving the hero and everyone else to the battle field and then spawning the monsters.

The monsters are generated randomly based on area and battle type.

To do this simply you set an integer array to all the unit types (game cache is also sutable for this). With about 10 units for each area. The battle types are fixed, but randomly choosen and the units used are based on area so for example, there always is a super hard battle, which could consist of 1 unit (monster offset+(area number*10)). Other battles might have more based on the functions you make.

For the flee, you run your actions and then if it hits (can run) it runs the finish battle function that removes the remaining enemy units and places the heroes where they belong.

i'm leaning more towards this kind of idea, since you introduced the area-specifics... but how about this? i'll take the earlier ideas along with these two recent ones, with the "checking for difference in location of said units" and every "x" seconds, it decides the battle, like this:

Event
- Every 0.50 Seconds of game time.

Condition
- None

Action
- for loop integer(A) (1-10) do actions *player numbers*
- Pick All units in playable map area owned by Player(ineger A)
- If (picked unit) is in [non-battle region(s)] = false
Then
- Set currenthero(ineger A) = picked unit
- Set currentheroloc(integer A) = location of picked unit
Else
- Skip remaining actions (or "Do nothing", which ever works better)
- Wait (Random integer between x and y) seconds
- Set unitcounter = 0
- Set currentheroloc2(integer A) = location of picked unit
- Set randomfight = random integer between 1 to 100
- If randomfight is <= z
Then
-Move instantly currenthero(integer A) instantly to Battle_Region(integer A)
Else
- Do nothing

*variables (just in case someone doesn't get them)
x = shortest time for random battle check
y = longest time for random battle check
z = area-specific chance to battle

but now, the only thing i'm having a hard time with this one, is that my map has unique battle areas for each player. So I wonder if i have to set up region variables for each player's battlegrounds, like so:

Event
- Map initialization

Condition
- None

Action
- set Battle_Region(1) = P1 Battle
- set Battle_Region(2) = P2 Battle
- set Battle_Region(3) = P3 Battle
- set Battle_Region(4) = P4 Battle
- set Battle_Region(5) = P5 Battle
- set Battle_Region(X) = PX Battle

In essence, setting "Battle_Region(X)" which is an array, to the pre-made region, "P# Battle" (or whatever the battle regions are called) this way, recalling them in the previous trigger should be easier and shouldnt require multiple triggers, one for each player being affected (taking the appropriate changes to player indexes of course).

for the flee, i don't know if I should do a dummy ability, or a region to spark the trigger...

Is that too confusing? sorry in advance if the post is too hard to follow. (i hope it at least works, lol)
 
Level 2
Joined
Jul 10, 2006
Messages
11
er.... i'm not at all good with JASS, assuming i knew it...

Plus, and i'll sound completely noobish, but i don't know how to remove leaks, or how i create them to begin with, (unles it's kind of like progamming redundancies, then i think i know what you're talking about, but i still wouldn't knnow how to remove them). Any help with that would be appreciated.... But yeah, I can't do JASS, or else I would, i know it helps 100%... i just can't do it yet...

Sorry for double post, but I have a couple things to say. First, I've been on a little vacation and was busy for the last week. Second, Don't worry about the leaks, I have found out how to remove them, and will be sure to take care of as many as possible. I'll update with more later on this system and my future map (in the appropriate forum, of course :wink:).

--EDIT--

not really an update, but how will I mark the unit's global position on the map while it's in battle? and then after that, how do i end the battle? something along the lines of (in general) "no more units owned by [hostile player #] in region X; move units to their previous global position"? basically, when all the monsters in the battle area die, the units get transported back to their original position, wherever it was. I was thinking about keeping their position in a variable, and then when the battle is done, move them back there and then remove the leaks afterwards.

so basically i have this:

every so often, it sets the initial position of said unit to a variable. IT then waits and sets the position of that same unit onto a new variable, and if they're different, and the unit is not within a safe-zone, then they will be moved to the battle-area. The monsters will be spawned, determined randomly by what area the unit was previously in, globally. when the monsters are all killed, the unit is brought back to the first position on the map. it then removes the leaks as normal.

all im curious about is, won't the trigger continue to set the said position variable with the unit's current position within the battle-zone? meaning when the battle is over through either victory or fleeing, won't the unit be just sent back to the battle-zone since it over-wrote the variable?

sorry if that's hard to follow, i'm just kind of stuck...
 
Last edited by a moderator:
Level 3
Joined
Jul 14, 2006
Messages
39
So I think what you can do is before the unit gets moved to the battle zone, cant you make a temp location or just move another location there to basically hold its spot then the unit can teleport back there when the battle is over
 
Last edited:
Level 2
Joined
Jul 10, 2006
Messages
11
So I think what you can do is before the unit gets moved to the battle zone, cant you make a temp location or just move another location there to basically hold its spot then the unit can teleport back there when the battle is over?

so basically, like when battle starts, first move a preset region onto the unti's location, move the unit, remove leaks. then when the battle's over, move unit to that region... I think that might work. thanks mad cow.

all i think i have to work on is tweaking it for cosmetic effects, and transitioning it. maybe later i'll add in multiple battle-zones, for each terrain, but thats later on down the road...
 
Level 1
Joined
Jul 12, 2007
Messages
3
My map currently has this random battle encounter feature in it already. Its NOT as hard as it looks. If you are leaning towards a FF type rpg. Then make it so that all of the players are generally in the same region, such as by using a Party Leader trigger, so they can't leave the areas. As for the way the triggers are done I'll show you part of my triggers I used.

  • BanditBattles1
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
      • BattleEncounter Equal to 0
    • Actions
      • Unit - Pause all units
      • Unit - Order (InsertPlayer'sUnitName) to Stop
      • Unit - Order (InsertPlayer2'sUnitName) to Stop
      • Region - Center Player1Placer <gen> on (Position of (InsertPlayer'sUnitName))
      • Region - Center Player2Placer <gen> on (Position of (InsertPlayer'sUnitName))
      • Cinematic - Turn cinematic mode On for (All players)
      • Unit - Move Eric instantly to (Center of PlayerBattleBandit <gen>), facing 180.00 degrees
      • Unit - Move Sara instantly to (Center of Player2BattleBandit <gen>), facing 180.00 degrees
      • Set NumEnemies = (Random integer number between 1 and 5)
      • Set Enemies = NumEnemies
      • Unit - Create NumEnemies Bandit for Player 12 (Brown) at (Center of Bandit Battle <gen>) facing 360.00 degrees
      • Set Enemy1 = (Last created unit)
      • Set EnemyGroup1 = (Last created unit group)
      • Set Enemy1Level = (Level of Enemy1)
      • Cinematic - Turn cinematic mode Off for (All players)
      • Camera - Pan camera for (Owner of (InsertPlayer'sUnitName)) to (Position of (InsertPlayer'sUnitName)) with height 300.00 above the terrain over 0.50 seconds
      • Camera - Pan camera for (Owner of (InsertPlayer'sUnitName)) to (Position of (InsertPlayer'sUnitName)) with height 300.00 above the terrain over 0.50 seconds
      • Unit - Unpause all units
      • Trigger - Turn off Timer <gen>
      • Trigger - Turn off BanditBattles1 <gen>
      • Trigger - Turn on Victory <gen>

Basically this triggers is activated whenever a unit, presumably a hero or party leader, enters the Region (BanditZone). Then that trigger turns on BanditBattles1 and a timer trigger. This way, you can have several area specific battlefields. Each battle zone is its own region. If you need anymore examples just PM me.
 
Last edited by a moderator:
Level 2
Joined
Jul 10, 2006
Messages
11
My map currently has this random battle encounter feature in it already. Its NOT as hard as it looks. If you are leaning towards a FF type rpg. Then make it so that all of the players are generally in the same region, such as by using a Party Leader trigger, so they can't leave the areas. As for the way the triggers are done I'll show you part of my triggers I used.

**trigger**


Basically this triggers is activated whenever a unit, presumably a hero or party leader, enters the Region (BanditZone). Then that trigger turns on BanditBattles1 and a timer trigger. This way, you can have several area specific battlefields. Each battle zone is its own region. If you need anymore examples just PM me.

ok, but what if i want individual fights... it's not exactly FF style. And while i do like that system, i dont really like the "limit the followers of the group to the area in which one person decides to go" style. I want my map to be free-form, like Final Fantasy Open, but with random battles, not preset creeps on the map.

Each player is on their own, and can go where they please, doing whatever they please. I may add in a team/platoon feature in later versions (but still being decided).

thanks for the help, but its not quite what i'm looking for. i'll keep this thread updated later. a little offtopic, but if I use WEU, can other people who don't have it still play my map? if not I wont use it. [/offtopic].
 
Level 1
Joined
Jul 12, 2007
Messages
3
If you really want separate player battles, then you'll need at least 1 of every type of battle environment for each player. In that case, you can still use the trigger I provided, by you'll have to change certain aspects of it.

This is a list of what would need to be changed for separate player battles.

A timer variable for each player, BattleEncounter was my variable name for this.
A separate Enemies variable for each player, since Enemies is an integer used to find out how many enemies are remaining.
And of course they need their own battle map areas and I think thats all.
 
Level 2
Joined
Jul 10, 2006
Messages
11
please help...

that's fine, I have one battle zone for each player already, as long as i know i just have to make individual triggers for each player, with their own variables, I can do that. I've been doing that sort of thing since StarCraft... alright, this shouldn't be too hard. Thanks again

--EDIT--

update, sort of... I have my system ready, but when i go to remove the leaks, it asks for an array index... so my text now looks like this: "call DestroyGroup(udg_All_Heroes)" how do i add in the array index? I've added "(1)" and " '1' " and even "(Integer A)" and " 'Integer A' "... nothing seems to work, and I can't figure out how to fix it...

other than that... i have this:

  • REMOVED for redundancy, newer trigger below

--EDIT--

sry for another edit, and a bump... but i'm stuck, no matter what i do, it wont work... I've made it player-specific by removing the integer A for player numbers, and got this:
  • Player 1
    • Events
      • Time - Every 0.50 seconds of game time
    • Conditions
    • Actions
      • Set P1_Heroes = (Units in (Playable map area) owned by Player 1 (Red))
      • Unit Group - Pick every unit in P1_Heroes and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Elven Town Camera <gen> contains (Picked unit)) Equal to False
              • (Mage Town Camera <gen> contains (Picked unit)) Equal to False
              • (Temple Camera <gen> contains (Picked unit)) Equal to False
            • Then - Actions
              • Set P1_Current_Hero = (Picked unit)
              • Set P1_Current_Hero_Location = (Position of (Picked unit))
            • Else - Actions
              • Do nothing
      • Wait 0.50 game-time seconds
      • Unit Group - Pick every unit in P1_Heroes and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Elven Town Camera <gen> contains (Picked unit)) Equal to False
              • (Mage Town Camera <gen> contains (Picked unit)) Equal to False
              • (Temple Camera <gen> contains (Picked unit)) Equal to False
            • Then - Actions
              • Set P1_Current_Hero_Location_2 = (Position of (Picked unit))
              • Set Random_Battle_Chance[1] = (Random integer number between 1 and 100)
            • Else - Actions
              • Do nothing
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Random_Battle_Chance[1] Less than or equal to Area_Battle_Chance[1]
          • ((X of P1_Current_Hero_Location) Not equal to (X of P1_Current_Hero_Location_2)) or ((Y of P1_Current_Hero_Location) Not equal to (Y of P1_Current_Hero_Location_2))
        • Then - Actions
          • Unit - Pause (Picked unit)
          • Rect - Center Battle_Marker[1] on P1_Current_Hero_Location_2
          • Unit - Move P1_Current_Hero instantly to (Center of Battle_Zone[1])
          • Unit - Create (Random integer number between 1 and 4) Monster[(Random integer number between 1 and Max_Monster_Number[1])] for Player 12 (Brown) at (Center of Monster_Spawn[1]) facing 315.00 degrees
          • Unit - Unpause (Picked unit)
        • Else - Actions
          • Do nothing
      • Custom script: call RemoveLocation(udg_P1_Current_Hero_Location)
      • Custom script: call RemoveLocation(udg_P1_Current_Hero_Location_2)
      • Custom script: call DestroyGroup(udg_P1_Heroes)
and this won't work... my hero can still walk around without starting a battle. I even tell her to patrol and just wait, it still wont go. if it helps to understand, i have another trigger that sets the variables such as "Monster" "max monster number" and so on. I just don't get what I'm doing wrong. Can't anyone help me? Also, i am using WE Ulimited ver1.20 if that helps anyone understand.
 
Last edited:
Level 2
Joined
Jul 10, 2006
Messages
11
wow, ya, i looked at that battle system... and I'd love to use it, it's just way too intense for a casual map, and not a campaign. However, I am using his method of tracking the units, and i have to say, it was the frist time i ever got my unit into the battle-zone. I still have to set variables for monster sets, area-specifics, and player-specifics... and i should be set. Instead of a flee, i might just make a "leave battleground" trigger, for post-looting and stuff, so that when the unit kills everything, the items drop as usual, and then the player can pick them up, but if he chooses to just leave, the items get removed. Pretty simple, the hard part was tracking the units (IMO)... thanks for all your help, and if i need more, i'll post it.

P.S. for all who are curious, here is my early stage of the battle system for Player one:
  • Player 1
    • Events
      • Time - Every 0.10 seconds of game time
    • Conditions
      • (Distance between Current_Hero_Location[1] and (Position of Current_Hero[1])) Greater than 0.00
      • (Elven Town Camera <gen> contains Current_Hero[1]) Equal to False
      • (Mage Town Camera <gen> contains Current_Hero[1]) Equal to False
      • (Temple Camera <gen> contains Current_Hero[1]) Equal to False
      • (Character Selection <gen> contains Current_Hero[1]) Equal to False
      • (Mage Discipline Selection <gen> contains Current_Hero[1]) Equal to False
      • InBattle[1] Equal to False
      • BossBattle Equal to False
    • Actions
      • Set Current_Hero_Location[1] = (Position of Current_Hero[1])
      • Set Random_Battle_Chance[1] = (Random_Battle_Chance[1] - 1)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Random_Battle_Chance[1] Less than or equal to 0
        • Then - Actions
          • Set InBattle[1] = True
          • Set Random_Battle_Chance[1] = (Random integer number between 150 and 300)
          • Unit - Pause Current_Hero[1]
          • Cinematic - Fade out over 1.00 seconds using texture White Mask and color (0.00%, 0.00%, 0.00%) with 0.00% transparency
          • Sound - Play ParagonX9___Blue_Sky <gen>
          • Rect - Center Battle_Marker[1] on Current_Hero_Location[1]
          • Unit - Move Current_Hero[1] instantly to (Center of Battle_Zone[1])
          • Unit - Create (Random integer number between 1 and 4) Monster[(Random integer number between 1 and Max_Monster_Number[1])] for Player 12 (Brown) at (Center of Monster_Spawn[1]) facing 315.00 degrees
          • Camera - Pan camera for (Owner of Current_Hero[1]) to (Center of Battle_Zone[1]) over 0.00 seconds
          • Cinematic - Fade in over 1.00 seconds using texture White Mask and color (0.00%, 0.00%, 0.00%) with 0.00% transparency
          • Unit - Unpause Current_Hero[1]
        • Else - Actions
      • Custom script: call RemoveLocation(udg_Current_Hero_Location[1])
just as a reference, and i do give credit to [)ark One, as I based mine off of his. Thanks VampireHeart for the right push =D
 
Status
Not open for further replies.
Top