1- // 2020-02-13 17:20:39
1+ // 2020-02-13 18:37:27
22#event properties (no comments/etc. here are saved)
33parent_index = -1;
44visible = false;
@@ -10,12 +10,8 @@ uses_physics = false;
1010box = sBattleBox;
1111gui_width = display_get_gui_width();
1212gui_height = display_get_gui_height();
13- textcol = 0;
14- text = "";
15- actioninput = ord("X");
1613
1714//Assign enemy objects to variables
18- Enemy = oDogPaddler.BattleAttacker;
1915OriginalEnemy = oDogPaddler.Attacker;
2016
2117//Create variables to keep track of battle stage
@@ -32,7 +28,7 @@ text_height = string_height("A");
3228
3329
3430//Create Enemy Object
35- instance_create_layer(640,390,"Instances",oDogPaddler.BattleAttacker);
31+ Enemy = instance_create_layer(640,390,"Instances",oDogPaddler.BattleAttacker);
3632
3733//Create BattleMenu variables
3834enum BattleMenu
@@ -60,9 +56,16 @@ instance_create_layer(room_width/2+150,room_height-100,"GUI",oBattleMenuBook);
6056
6157//Timer Bar Width
6258BarWidth = 400;
63- BattleTimer = 100 ;
59+ BattleTimer = 0 ;
6460BattleTimerInit = 15;
6561
62+ //Update stats effect
63+ UpdateStats = false;
64+ DrawPlayerHealth = global.phealth;
65+ DrawPlayerPP = global.pp;
66+ DrawEnemyHealth = Enemy.Health;
67+ timer[0] = -1;
68+
6669#event step
6770
6871//If the current battle stage is done, transition to the next one.
@@ -76,19 +79,19 @@ if(BattleStageEnd)
7679 }
7780
7881 BattleStage++;
79- if(BattleStage > 3 )
82+ if(BattleStage > 5 )
8083 {
8184 BattleStage = 1;
8285 }
8386
8487 //Check enemy and player health
85- if(global.phealth <= 0)
88+ if(DrawPlayerHealth <= 0)
8689 {
8790 var BattleText = instance_create_layer(x,y,"text",oBattleTextBox);
8891 BattleText.text = ["You lose!"];
8992 }
9093
91- if(Enemy.Health <= 0)
94+ if(DrawEnemyHealth <= 0)
9295 {
9396 var BattleText = instance_create_layer(x,y,"text",oBattleTextBox);
9497 BattleText.text = ["You Win!"];
@@ -106,47 +109,124 @@ if(BattleStageEnd)
106109 break;
107110
108111 case 2:
112+ timer[0] = 0.5*60;
113+ visible = true;
114+ break;
115+
116+ case 3:
117+ //Player turn
109118 with(oBattleMenuParent)
110119 {
111120 visible = true;
112121 }
113122 BattleTimer = BattleTimerInit*60;
114- oBattleManager.visible = true;
115123 break;
116124
117- case 3:
125+ case 4:
126+ timer[0] = 0.5*60;
127+ visible = true;
128+ break;
129+
130+ case 5:
118131 //CHATTER BEFORE LOOP
132+ visible = false;
119133 var BattleText = instance_create_layer(x,y,"text",oBattleTextBox);
120134 var EnemyTextDuring = Enemy.TextDuring[random_range(0,array_length_1d(Enemy.TextDuring))];
121135 BattleText.text = [EnemyTextDuring];
122136 break;
123137 }
124138 }
125-
126-
127139 BattleStageEnd = false;
128140}
129141
130142//Reduce battle timer, and end turn if at 0
131- if(BattleTimer > 0)
143+ if(BattleTimer > 0 && visible && BattleStage == 3 )
132144{
133145 BattleTimer -= 1;
134- if (visible && BattleTimer <= 0)
146+ if (BattleTimer <= 0)
135147 {
136148 BattleStageEnd = true;
137149 with(oBattleMenuParent)
138150 {
139151 visible = false;
140152 Selected = false;
141153 }
142- oBattleManager.visible = false;
154+ visible = false;
155+ }
156+ }
157+
158+ if(UpdateStats)
159+ {
160+ var Check = 0;
161+ var Increment = 0.25;
162+ if(DrawPlayerHealth > global.phealth)
163+ {
164+ DrawPlayerHealth -= Increment;
165+ }
166+ if(DrawPlayerHealth < global.phealth)
167+ {
168+ DrawPlayerHealth += Increment;
169+ }
170+ if(DrawPlayerHealth = global.phealth)
171+ {
172+ Check++;
173+ }
174+
175+ if(DrawPlayerPP > global.pp)
176+ {
177+ DrawPlayerPP -= Increment;
178+ }
179+ if(DrawPlayerPP < global.pp)
180+ {
181+ DrawPlayerPP += Increment;
182+ }
183+ if(DrawPlayerPP = global.pp)
184+ {
185+ Check++;
186+ }
187+
188+ if(DrawEnemyHealth > Enemy.Health)
189+ {
190+ DrawEnemyHealth -= Increment;
191+ }
192+ if(DrawEnemyHealth < Enemy.Health)
193+ {
194+ DrawEnemyHealth += Increment;
195+ }
196+ if(DrawEnemyHealth = Enemy.Health)
197+ {
198+ Check++;
199+ }
200+
201+ if(Check == 3 && timer[0] == -1)
202+ {
203+ timer[0] = 0.5*60;
204+ }
205+ }
206+
207+ //timer management
208+ if(timer[0] > 0)
209+ {
210+ timer[0] -= 1;
211+ }
212+ else if(timer[0] != -1)
213+ {
214+ timer[0] = -1;
215+ if(UpdateStats)
216+ {
217+ UpdateStats = false;
218+ BattleStageEnd = true;
219+ }
220+ else
221+ {
222+ UpdateStats = true;
143223 }
144224}
145225
146226#event draw_gui Insert description here
147227// You can write your code in this editor
148228
149- if(BattleStage == 2 )
229+ if(visible )
150230{
151231 var GUIWidth = display_get_gui_width();
152232 var GUIHeight = display_get_gui_height();
@@ -159,19 +239,22 @@ if(BattleStage == 2)
159239 draw_sprite(sGUIPlayerInfo,0,50,50);
160240
161241 //Draw player status
162- draw_text(50+DPhpx,50+DPhpy,global.phealth );
163- draw_text(50+DPhpx,50+DPhpy+DPoffy,global.pp );
242+ draw_text(50+DPhpx,50+DPhpy,round(DrawPlayerHealth) );
243+ draw_text(50+DPhpx,50+DPhpy+DPoffy,round(DrawPlayerPP) );
164244
165245 //Draw battle timer
166- var TimerPosX = GUIWidth/2;
167- var TimerPosY = GUIHeight/1.25;
168- var BarHeight = 20;
169-
170- draw_sprite(sBattleTimer,0,TimerPosX-BarWidth/2-100,TimerPosY);
171- draw_set_color(c_black);
172- draw_rectangle(TimerPosX-BarWidth/2,TimerPosY+BarHeight/2,TimerPosX+BarWidth/2,TimerPosY-BarHeight/2,false);
173- draw_set_color(c_red);
174- var BattleTimerNum = ((BattleTimer/60/BattleTimerInit)*BarWidth);
175- draw_rectangle(TimerPosX-BarWidth/2,TimerPosY+BarHeight/2,TimerPosX-BarWidth/2+BattleTimerNum,TimerPosY-BarHeight/2,false);
246+ if(BattleTimer > 0)
247+ {
248+ var TimerPosX = GUIWidth/2;
249+ var TimerPosY = GUIHeight/1.25;
250+ var BarHeight = 20;
251+
252+ draw_sprite(sBattleTimer,0,TimerPosX-BarWidth/2-100,TimerPosY);
253+ draw_set_color(c_black);
254+ draw_rectangle(TimerPosX-BarWidth/2,TimerPosY+BarHeight/2,TimerPosX+BarWidth/2,TimerPosY-BarHeight/2,false);
255+ draw_set_color(c_red);
256+ var BattleTimerNum = ((BattleTimer/60/BattleTimerInit)*BarWidth);
257+ draw_rectangle(TimerPosX-BarWidth/2,TimerPosY+BarHeight/2,TimerPosX-BarWidth/2+BattleTimerNum,TimerPosY-BarHeight/2,false);
258+ }
176259}
177260
0 commit comments