Hello, im here to ask your help to fixing my simple combat code.
Its just a simple turn dice combat system.
The code its a bit junky.
I think the error its below of CHECK ENEMIES COMMENT.
How this code works?
Im using this code as a common event.
At class hero I created a flag with Auto Battle and then at TROOPS I linked the common event to it with turn 0 and tested the code.
I attached a image for people who cant understand this part.
Its just a simple turn dice combat system.
The code its a bit junky.
JavaScript:
◆Change Window Color:(102,-255,-255)
◆Wait:30 frames
◆Control Variables:#0018 LuckChange = Luck of Harold
◆Control Variables:#0022 PLAYERLEVEL = Level of Harold
◆Control Variables:#0030 PLAYEREXP = 5
◆Control Variables:#0042 PlayerDefense = Defense of Harold
◆Control Variables:#0020 AgilityChange = Agility of Harold
◆Control Variables:#0045 PlayerGold = 10
◆Control Variables:#0011 TP = 0
◆Comment:--------ENEMY STATS---------
◆Control Variables:#0035 EnemyHP = HP of #1
◆Control Variables:#0037 Enemy2HP = HP of #2
◆Control Variables:#0032 EnemyAttack = Attack of #1
◆Control Variables:#0038 Enemy2Attack = Attack of #2
◆Control Variables:#0033 EnemyDefense = Defense of #1
◆Control Variables:#0039 Enemy2Defense = Defense of #2
◆Control Variables:#0034 EnemyLuck = Luck of #1
◆Control Variables:#0040 Enemy2Luck = Luck of #2
◆Control Variables:#0031 EnemySpeed = Agility of #1
◆Control Variables:#0041 Enemy2Speed = Agility of #2
◆Control Variables:#0048 Enemy1CanAttak = 0
◆Control Variables:#0049 Enemy2CanAttak = 0
◆Control Variables:#0023 ENEMYLEVEL = 2
◆Comment:--------ROLL DICE AT BEGGIN---------
◆Label:RollDice
◆Control Variables:#0027 ROLLDICEATBEGGINPlayer = Random 0..12
◆Text:None, Window, Top
: :You Rolled \V[0027]
◆Wait:3 frames
◆Control Variables:#0028 ROLLDICEATBEGGINEnemy = Random 0..12
◆Text:None, Window, Top
: :Enemy Rolled \V[0028]
◆Wait:3 frames
◆If:ROLLDICEATBEGGINPlayer > ROLLDICEATBEGGINEnemy
◆Text:None, Window, Top
: :You Rolled \V[0027]!
: :The enemy Rolled \V[0028]!
: :You go first.
◆Jump to Label:PlayerTurn
◆
:Else
◆Text:None, Window, Top
: :You Rolled \V[0027]!
: :The enemy Rolled \V[0028]!
: :Enemy go first.
◆Control Variables:#0048 Enemy1CanAttak = 1
◆Control Variables:#0049 Enemy2CanAttak = 1
◆Jump to Label:CheckEnemy1
◆
:End
◆If:ROLLDICEATBEGGINPlayer = ROLLDICEATBEGGINEnemy
◆Text:None, Window, Top
: :You Rolled \V[0027]!
: :The enemy rolled \V[0028]!
: :The Dices will be rolled again.
◆Jump to Label:RollDice
◆
:End
◆Comment:-----------PlayerTurn----------
◆Jump to Label:CheckEnemy1
◆Label:PlayerTurn
◆Text:None, Window, Middle
: :YOUR TURN
◆If:TP ≥ 100
◆Change State:Harold, + Charged
◆Play SE:Heal1 (50, 80, 0)
◆
:End
◆Wait:30 frames
◆Label:Choises Beggin
◆Show Choices:Attack, Defense, Special, Run, Potions (Window, Left, #1, -)
:When Attack
◆Control Variables:#0017 BattleDice = Random 0..12
◆If:BattleDice ≤ 0
◆Text:None, Window, Middle
: :YOUR ROLLED \V[0017] FOR A CRITICAL
◆Force Action:Harold, Dual Attack, Random
◆Control Variables:#0011 TP += 10
◆Control Variables:#0048 Enemy1CanAttak = 1
◆Control Variables:#0049 Enemy2CanAttak = 1
◆Wait:3 frames
◆Jump to Label:CheckEnemy1
◆
:End
◆If:BattleDice ≤ 11
◆If:BattleDice > 0
◆Text:None, Window, Middle
: :YOUR ROLLED \V[0017] FOR A NORMAL ATTACK
◆Force Action:Harold, Attack, Random
◆Control Variables:#0011 TP += 5
◆Control Variables:#0048 Enemy1CanAttak = 1
◆Control Variables:#0049 Enemy2CanAttak = 1
◆Wait:3 frames
◆Jump to Label:CheckEnemy1
◆
:End
◆
:End
◆If:BattleDice ≥ 12
◆Text:None, Window, Middle
: :YOUR ROLLED \V[0017] AND MISSED
◆Force Action:Harold, Wait, Random
◆Control Variables:#0048 Enemy1CanAttak = 1
◆Control Variables:#0049 Enemy2CanAttak = 1
◆Wait:3 frames
◆Jump to Label:CheckEnemy1
◆
:End
◆
:When Defense
◆Control Variables:#0017 BattleDice = Random 0..12
◆If:BattleDice ≤ 5
◆Text:None, Window, Middle
: :YOU ROLLED \V[0017] FOR A DEFENSE
◆Force Action:Harold, Guard, Random
◆Wait:3 frames
◆Control Variables:#0048 Enemy1CanAttak = 1
◆Control Variables:#0049 Enemy2CanAttak = 1
◆Wait:3 frames
◆Jump to Label:CheckEnemy1
◆
:End
◆If:BattleDice ≥ 6
◆Text:None, Window, Middle
: :YOU ROLLED \V[0017] AND YOU MISSED
◆Force Action:Harold, Wait, Random
◆Control Variables:#0048 Enemy1CanAttak = 1
◆Control Variables:#0049 Enemy2CanAttak = 1
◆Wait:3 frames
◆Jump to Label:CheckEnemy1
◆
:End
◆
:When Special
◆If:Harold is affected by Charged
◆Show Choices:Merciless (Window, Left, #1, -)
:When Merciless
◆Change Skill:Harold, + Merceless
◆Force Action:#1, Merceless, Random
◆Control Variables:#0043 PlayerTP = 0
◆Control Variables:#0048 Enemy1CanAttak = 1
◆Control Variables:#0049 Enemy2CanAttak = 1
◆Wait:3 frames
◆Jump to Label:CheckEnemy1
◆
:When Cancel
◆Jump to Label:Choises Beggin
◆
:End
◆
:Else
◆Text:None, Window, Top
: :Not enought TP to use this right now
◆Jump to Label:Choises Beggin
◆
:End
◆
:When Run
◆Control Variables:#0017 BattleDice = Random 0..12
◆If:BattleDice ≤ 5
◆Text:None, Window, Middle
: :YOUR ROLLED \V[0017] FOR A RUN
◆Force Action:Harold, Escape, Random
◆Wait:3 frames
◆Exit Event Processing
◆
:End
◆If:BattleDice ≥ 6
◆Text:None, Window, Middle
: :YOUR ROLLED ITS \V[0017] AND YOU MISSED
◆Force Action:Harold, Wait, Random
◆Control Variables:#0048 Enemy1CanAttak = 1
◆Control Variables:#0049 Enemy2CanAttak = 1
◆Wait:3 frames
◆Jump to Label:CheckEnemy1
◆Wait:3 frames
◆
:End
◆
:When Potions
◆If:Party has Potion
◆Show Choices:Use Potion, Dont use it (Window, Left, #1, #2)
:When Use Potion
◆Recover All:Harold
◆Play SE:Heal3 (90, 80, 0)
◆Control Variables:#0048 Enemy1CanAttak = 1
◆Control Variables:#0049 Enemy2CanAttak = 1
◆Wait:3 frames
◆Jump to Label:CheckEnemy1
◆
:When Dont use it
◆Jump to Label:Choises Beggin
◆
:End
◆
:Else
◆Text:None, Window, Bottom
: :You dont have potions
◆Jump to Label:Choises Beggin
◆
:End
◆
:End
◆Comment:-----------Enemy1Turn------------
◆Label:Enemy1Turn
◆Control Variables:#0017 BattleDice = Random 0..12
◆If:Enemy1CanAttak = 1
◆If:BattleDice ≤ 0
◆Text:None, Window, Middle
: :ENEMY1 ROLLED \V[0017] FOR A CRITICAL
◆Force Action:#1, Double Attack, Random
◆Control Variables:#0011 TP += 20
◆Control Variables:#0048 Enemy1CanAttak = 0
◆Wait:3 frames
◆Jump to Label:CheckEnemy2
◆
:End
◆
:End
◆If:Enemy1CanAttak = 1
◆If:BattleDice ≤ 11
◆If:BattleDice > 0
◆Text:None, Window, Middle
: :ENEMY1 ROLLED \V[0017] FOR A NORMAL ATTACK
◆Force Action:#1, Attack, Random
◆Control Variables:#0011 TP += 10
◆Control Variables:#0048 Enemy1CanAttak = 0
◆Wait:3 frames
◆Jump to Label:CheckEnemy2
◆
:End
◆
:End
◆
:End
◆If:Enemy1CanAttak = 1
◆If:BattleDice ≥ 12
◆Text:None, Window, Middle
: :ENEMY1 ROLLED \V[0017] AND MISSED
◆Force Action:#1, Wait, Random
◆Control Variables:#0048 Enemy1CanAttak = 0
◆Wait:3 frames
◆Jump to Label:CheckEnemy2
◆
:End
◆
:End
◆Comment:-----------Enemy2Turn------------
◆Label:Enemy2Turn
◆Control Variables:#0024 BATTLEDICE2 = Random 0..12
◆If:Enemy2CanAttak = 1
◆If:BATTLEDICE2 ≤ 0
◆Text:None, Window, Middle
: :ENEMY2 ROLLED \V[0024] FOR A CRITICAL
◆Force Action:#2, Double Attack, Random
◆Control Variables:#0011 TP += 20
◆Control Variables:#0049 Enemy2CanAttak = 0
◆Wait:3 frames
◆Jump to Label:CheckEnemy1
◆
:End
◆
:End
◆If:Enemy2CanAttak = 1
◆If:BATTLEDICE2 ≤ 11
◆If:BATTLEDICE2 > 0
◆Text:None, Window, Middle
: :ENEMY2 ROLLED \V[0024] FOR A NORMAL ATTACK
◆Force Action:#2, Attack, Random
◆Control Variables:#0011 TP += 10
◆Control Variables:#0049 Enemy2CanAttak = 0
◆Wait:3 frames
◆Jump to Label:CheckEnemy1
◆
:End
◆
:End
◆
:End
◆If:Enemy2CanAttak = 1
◆If:BATTLEDICE2 ≥ 12
◆Text:None, Window, Middle
: :ENEMY2 ROLLED \V[0024] AND MISSED
◆Force Action:#2, Wait, Random
◆Control Variables:#0049 Enemy2CanAttak = 0
◆Wait:3 frames
◆Jump to Label:CheckEnemy1
◆
:End
◆
:End
◆Comment:-------------CHECK ENEMIES-----------
◆Label:CheckEnemy1
◆If:Enemy1CanAttak = 1
◆If:EnemyHP > 0
◆Control Variables:#0046 Enemy1is_Dead = 0
◆Jump to Label:Enemy1Turn
◆
:Else
◆Control Variables:#0046 Enemy1is_Dead = 1
◆Jump to Label:CheckifAllEnemiesareDead
◆
:End
◆
:End
◆Label:CheckEnemy2
◆If:Enemy2CanAttak = 1
◆If:Enemy2HP > 0
◆Control Variables:#0047 Enemy2is_Dead = 0
◆Jump to Label:Enemy2Turn
◆
:Else
◆Control Variables:#0047 Enemy2is_Dead = 1
◆Jump to Label:CheckifAllEnemiesareDead
◆
:End
◆
:End
◆Label:CheckifAllEnemiesareDead
◆If:Enemy1is_Dead = 1
◆If:Enemy2is_Dead = 1
◆Change Gold:+ {PlayerGold}
◆Change EXP:Entire Party, + {PLAYEREXP} (Show Level Up)
◆Text:None, Window, Top
: :You earned \V[0030] EXP and \V[0040]\G
◆Abort Battle
◆Erase Event
◆
:End
◆
:Else
◆Jump to Label:EnemyStillAlive
◆
:End
◆Label:EnemyStillAlive
◆If:Enemy1is_Dead = 0
◆If:Enemy2is_Dead = 1
◆If:Enemy1CanAttak = 1
◆Jump to Label:Enemy1Turn
◆
:Else
◆Jump to Label:PlayerTurn
◆
:End
◆
:End
◆
:Else
◆If:Enemy1is_Dead = 1
◆If:Enemy2is_Dead = 0
◆If:Enemy2CanAttak = 1
◆Jump to Label:Enemy2Turn
◆
:Else
◆Jump to Label:PlayerTurn
◆
:End
◆
:End
◆
:End
◆
:End
I think the error its below of CHECK ENEMIES COMMENT.
How this code works?
Im using this code as a common event.
At class hero I created a flag with Auto Battle and then at TROOPS I linked the common event to it with turn 0 and tested the code.
I attached a image for people who cant understand this part.