Turn based combat system, damn

SnowCrow

New Member
Reaction score
7
I'm creating a turn based combat system, like one in Final Fantasy and all other japanese RPGs.
I'll post my triggers here.
Code:
Starting
    Events
        Unit - A unit comes within 256.00 of Knight 0002 <gen>
    Conditions
        (Region 004 <gen> contains (Triggering unit)) Equal to True
    Actions
        Trigger - Turn off Third Person Camera <gen>
        Unit - Move Knight 0002 <gen> instantly to (Center of ForestCreepLoc <gen>)
        Unit - Move Paladin 0004 <gen> instantly to (Center of ForestHeroLoc <gen>)
        Set CreepUnit = (Random unit from (Units in ForestCreepLoc <gen>))
        Set HeroUnit = (Random unit from (Units in ForestHeroLoc <gen>))
        Unit Group - Pick every unit in (Units in ForestCreepLoc <gen>) and do (Unit - Make (Picked unit) face (Center of ForestHeroLoc <gen>) over 0.00 seconds)
        Unit Group - Pick every unit in (Units in ForestHeroLoc <gen>) and do (Unit - Make (Picked unit) face (Center of ForestCreepLoc <gen>) over 0.00 seconds)
        Unit Group - Pick every unit in (Units in ForestBattle <gen>) and do (Unit - Pause (Picked unit))
        Trigger - Turn on Battle Camera <gen>
        Wait 1.00 seconds
        Set BattleOn = 1.00
Code:
Battle
    Events
        Game - BattleOn becomes Equal to 1.00
    Conditions
    Actions
        If (HeroSpeed Greater than KnightSpeed) then do (Set HeroTurn = 1.00) else do (Do nothing)
        If (KnightSpeed Greater than HeroSpeed) then do (Set CreepTurn = 1.00) else do (Do nothing)
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                HeroSpeed Equal to KnightSpeed
            Then - Actions
                Set Random = (Random integer number between 1 and 10)
                If (Random Greater than or equal to 6) then do (Set CreepTurn = 1.00) else do (Set HeroTurn = 1.00)
            Else - Actions
                Do nothing
Code:
CreepTurn
    Events
        Game - CreepTurn becomes Equal to 1.00
    Conditions
    Actions
        Wait 3.00 seconds
        Unit - Unpause CreepUnit
        Unit - Order CreepUnit to Attack HeroUnit
        Trigger - Turn off Battle Camera <gen>
        Trigger - Turn on Creep Attack Camera <gen>
Code:
CreepTurnEnd
    Events
        Unit - A unit Is attacked
    Conditions
        (Attacked unit) Equal to HeroUnit
    Actions
        Game - Display to (All players) the text: Lol
        Unit - Order (Attacking unit) to Move To (Center of ForestCreepLoc <gen>)
        Wait 2.00 seconds
        Trigger - Turn off Creep Attack Camera <gen>
        Trigger - Turn on Battle Camera <gen>
        Wait 2.00 seconds
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (ForestHeroLoc <gen> contains HeroUnit) Equal to True
            Then - Actions
                Unit - Pause CreepUnit
                Set CreepTurn = 0.00
                Set HeroTurn = 1.00
            Else - Actions
                Do nothing
Code:
HeroTurn
    Events
        Game - HeroTurn becomes Equal to 1.00
    Conditions
    Actions
        Wait 2.00 seconds
        Dialog - Clear BattleDialog
        Dialog - Change the title of BattleDialog to Combat
        Dialog - Create a dialog button for BattleDialog labelled Attack
        Set BattleDialogButtons[1] = (Last created dialog Button)
        Dialog - Create a dialog button for BattleDialog labelled Flee
        Set BattleDialogButtons[2] = (Last created dialog Button)
        Dialog - Show BattleDialog for Player 1 (Red)
Code:
DialogAttack
    Events
        Dialog - A dialog button is clicked for BattleDialog
    Conditions
        (Clicked dialog button) Equal to BattleDialogButtons[1]
    Actions
        Wait 1.00 seconds
        Unit - Unpause HeroUnit
        Unit - Order HeroUnit to Attack CreepUnit
        Trigger - Turn off Battle Camera <gen>
        Trigger - Turn on Hero Attack Camera <gen>
Code:
HeroTurnEnd
    Events
        Unit - A unit Is attacked
    Conditions
        (Attacked unit) Equal to CreepUnit
    Actions
        Game - Display to (All players) the text: Lol
        Unit - Order (Attacking unit) to Move To (Center of ForestCreepLoc <gen>)
        Wait 2.00 seconds
        Trigger - Turn off Hero Attack Camera <gen>
        Trigger - Turn on Battle Camera <gen>
        Wait 2.00 seconds
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (ForestCreepLoc <gen> contains CreepUnit) Equal to True
            Then - Actions
                Unit - Pause HeroUnit
                Set CreepTurn = 1.00
                Set HeroTurn = 0.00
            Else - Actions
                Trigger - Turn off Battle Camera <gen>
                Game - Display to (All players) the text: You win!
                Trigger - Turn on Third Person Camera <gen>
Its working fine except that when the Knight (starting) approaches the Hero, it just stops in front of him and doesn't attack or even return back. Some help would be nice. :)
And I started doing this trigger this morning, so it might be little sucky at places. But it will improve.
 
D

dadads

Guest
If you're interested in turn-based systems, you should see the "Hero RPG" campaign in WC3 campaigns. It uses a turn-based system too, and could serve as an inspiration source.
 

SnowCrow

New Member
Reaction score
7
Check your frist tigger agian. Near the movement i think thats wrong.

Code:
Unit Group - Pick every unit in (Units in ForestBattle <gen>) and do (Unit - Pause (Picked unit))
Why would that be wrong? I said the problem is that when the Knight (creep) approaches the Paladin (hero), it just stops in front of him and does nothing.

I'm quite sure all the variables are right. If anyone can come up with a solution, that would be lovely. :)

And thanks for the information, dadads, I'll check that map, but that system I saw in the screenshot is totally beyond my skills. :] I may still find something from the map.
 

SnowCrow

New Member
Reaction score
7
Ok, I think the problem is in the event [Unit becomes attacked].
Could there be another way to do it?
 
D

dadads

Guest
Don't use [Event - Unit is attacked].
Use [Event - Unit is damaged] instead.

Or if you want to move the hero using triggers instead of issuing the move command, you can actually time it.
 

SnowCrow

New Member
Reaction score
7
Don't use [Event - Unit is attacked].
Use [Event - Unit is damaged] instead.

Or if you want to move the hero using triggers instead of issuing the move command, you can actually time it.
Yes, thanks dadads, now the Knight actually attacks. I had to change the generic unit event to specific unit, because "takes damage" isn't in generic unit event.

I didn't quite understand what you meant with moving the hero with triggers, could you define it a bit more?
 
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