Bläddra i källkod

entry hazards finished (toxic, sticky, stealth, spikes)

Philipp Auer 8 år sedan
förälder
incheckning
8fe826a601

+ 5
- 0
bpre.sym Visa fil

@@ -57,6 +57,8 @@ clear_flag = 0x0806E6A9;
57 57
 divide = 0x081E4018;
58 58
 
59 59
 get_side_from_bank = 0x080751C4|1;
60
+prepare_setattributes_in_battle = 0x0800DFF0|1;
61
+mark_buffer_bank_for_execution = 0x8017248|1;
60 62
 
61 63
 decompression_buffer = 0x0201C000;
62 64
 superstate = 0x030030F0;
@@ -85,8 +87,11 @@ battle_base_power = 0x02024020;
85 87
 battle_side_unknown = 0x02023FDB;
86 88
 battle_side_timers = 0x02023DE4;
87 89
 battle_hitmarker = 0x02023dd0;
90
+battle_stat_changer = 0x02023FDE;
88 91
 side_affecting_halfword = 0x2023DDE;
89 92
 
93
+battle_custom_string = 0x0203C020;
94
+
90 95
 battle_status3_bits_pbs = 0x02023DFC;
91 96
 
92 97
 mugshots = 0x097007E0;

+ 1
- 1
data/moves/effect_table.S Visa fil

@@ -116,7 +116,7 @@ m_effect_table:
116 116
 	.word 0x081D774D @109
117 117
 	.word 0x081D6900 @110
118 118
 	.word 0x081D7816 @111
119
-	.word 0x081D7829 @112
119
+	.word hazards_script @112 (Spikes, Toxic Spikes, Stealth Rock, Sticky Web)
120 120
 	.word 0x081D783E @113
121 121
 	.word 0x081D7856 @114
122 122
 	.word 0x081D7897 @115

+ 4
- 3
data/pkmn_tables/pokemon_moveset_table.S Visa fil

@@ -1,6 +1,7 @@
1
+#include <moves.h>
2
+
1 3
 .text
2 4
 .align 2
3
-.text
4 5
 .global moveset_table
5 6
 moveset_table:
6 7
 
@@ -1213,11 +1214,11 @@ moveset_unknown:
1213 1214
 
1214 1215
 .align 2
1215 1216
 moveset_bisasam: 
1216
-.hword 0x21 
1217
+.hword MOVE_TACKLE
1217 1218
 .byte 0x1 
1218 1219
 .hword 0x2D 
1219 1220
 .byte 0x3 
1220
-.hword 0x49 
1221
+.hword MOVE_SPIKES 
1221 1222
 .byte 0x7 
1222 1223
 .hword 0x16 
1223 1224
 .byte 0x9 

+ 1
- 1
data/pkmn_tables/pokemon_stats.S Visa fil

@@ -7,7 +7,7 @@ pokemon_stats:
7 7
 .hword 0, 0 
8 8
 .byte 255, 20, 100, 4, 15, 15, 0, 0, 0, 8, 0, 0
9 9
  
10
-.byte 45, 49, 49, 45, 65, 65, 2, 10, 45, 64, 0, 1 
10
+.byte 45, 49, 49, 45, 65, 65, 12, 3, 45, 64, 0, 1 
11 11
 .hword 0, 0 
12 12
 .byte 31, 20, 70, 3, 1, 7, 65, 34, 0, 3, 0, 0
13 13
  

+ 26
- 0
src/battle_engine/battle_help.c Visa fil

@@ -92,4 +92,30 @@ u16 type_effectiveness_calc(u16 move, u8 move_type, u8 atk_bank, u8 def_bank, u8
92 92
 	//TODO: save into structs
93 93
 	//TODO: effect_handling_and_recoring
94 94
 	return chained_effect;
95
+}
96
+
97
+u8 has_type(u8 bank, u8 type)
98
+{
99
+	return battle_participants[bank].type1 == type || battle_participants[bank].type2 == type;
100
+}
101
+
102
+u8 cant_poison(u8 bank, u8 self_inflicted)
103
+{   //0 == can poison
104
+    //1 == is already poisoned
105
+    //2 == has other major condition
106
+    //3 == type doesn't allow it
107
+    //4 == ability doesn't allow it
108
+    //5 == safeguard protection
109
+    //8 == misty terrain doesn't allow it !TODO!
110
+    if (battle_participants[bank].status.flags.poison || battle_participants[bank].status.flags.toxic_poison)
111
+        return 1;
112
+    if (battle_participants[bank].status.int_status)
113
+        return 2;
114
+    if (has_type(bank, TYPE_POISON) || has_type(bank, TYPE_STEEL))
115
+        return 3;
116
+    if (((battle_participants[bank].ability_id == ABILITY_IMMUNITY || (battle_participants[bank].ability_id == ABILITY_LEAF_GUARD && (battle_weather.flags.sun || battle_weather.flags.permament_sun || battle_weather.flags.harsh_sun)))))
117
+        return 4;
118
+    if (side_affecting_halfword[get_side_from_bank(bank)].safeguard_on && !self_inflicted)
119
+        return 5;
120
+    return 0;
95 121
 }

+ 2
- 0
src/battle_engine/battle_help.h Visa fil

@@ -6,4 +6,6 @@
6 6
 u16 damage_type_effectiveness_update(u8 attacking_type, u8 defending_type, u8 atk_bank, u8 def_bank, u16 chained_effect, u8 airstatus);
7 7
 u16 apply_type_effectiveness(u16 chained_effect, u8 move_type, u8 target_bank, u8 atk_bank, u8 airstatus);
8 8
 u16 type_effectiveness_calc(u16 move, u8 move_type, u8 atk_bank, u8 def_bank, u8 effects_handling_and_recording);
9
+u8 has_type(u8 bank, u8 type);
10
+u8 cant_poison(u8 bank, u8 self_inflicted);
9 11
 #endif

+ 111
- 7
src/battle_engine/entry_hazards.c Visa fil

@@ -2,18 +2,21 @@
2 2
 #include <bpre.h>
3 3
 
4 4
 extern void* bs_stealth_rock;
5
+extern void* bs_toxic_spikes;
6
+extern void* bs_toxic_spikes_bad;
7
+extern void* bs_sticky_web;
8
+extern void* bs_toxic_resolve;
9
+
10
+extern void* bs_spikes_lain;
11
+extern void* bs_rocks_lain;
12
+extern void* bs_toxic_lain;
13
+extern void* bs_sticky_lain;
5 14
 
6 15
 u8 execute_entry_hazards()
7 16
 {
8 17
 	u8 active_side = get_side_from_bank(battle_active_bank);
9 18
 	u8 has_effect = 0;
10 19
 	struct side_affecting* active_side_affecting = &custom_battle_struct.ptr->side_affecting[active_side];
11
-	//Debug
12
-	//side_affecting_halfword[active_side].spikes_on=1;
13
-	//battle_side_timers[active_side].spikes_amount=4;
14
-	active_side_affecting->stealth_rock=1;
15
-	//side_affecting_halfword[active_side].spikes_damage_done=0;
16
-	
17 20
 	if(side_affecting_halfword[active_side].spikes_on && !(side_affecting_halfword[active_side].spikes_damage_done))
18 21
 	{
19 22
 		//spikes lay down, deal spiky damage
@@ -55,10 +58,48 @@ u8 execute_entry_hazards()
55 58
 		battle_damage_store = damage;
56 59
 		
57 60
 		battle_script_push();
58
-		//spikes for now
59 61
 		battlescript_cursor = bs_stealth_rock;
60 62
 		has_effect = 1;
61 63
 	}
64
+	else if(active_side_affecting->toxic_spikes_psn && !(active_side_affecting->toxic_spikes_done))
65
+	{
66
+		active_side_affecting->toxic_spikes_done=1;
67
+		if(has_type(battle_active_bank, TYPE_POISON))
68
+		{
69
+			has_effect = 1;
70
+			active_side_affecting->toxic_spikes_psn=0;
71
+			active_side_affecting->toxic_spikes_badpsn=0;
72
+			battle_script_push();
73
+			battlescript_cursor = bs_toxic_resolve;
74
+		}
75
+		else if(!cant_poison(battle_active_bank, 0))
76
+		{
77
+			if (active_side_affecting->toxic_spikes_badpsn)
78
+			{
79
+				battle_participants[battle_active_bank].status.flags.toxic_poison = 1;
80
+				battle_script_push();
81
+				battlescript_cursor = bs_toxic_spikes_bad;
82
+			}
83
+                
84
+            else
85
+			{
86
+				battle_participants[battle_active_bank].status.flags.poison = 1;
87
+				battle_script_push();
88
+				battlescript_cursor = bs_toxic_spikes;
89
+			}
90
+            prepare_setattributes_in_battle(0, REQUEST_STATUS_BATTLE, 0, 4, &battle_participants[battle_active_bank].status.flags);
91
+            mark_buffer_bank_for_execution(battle_active_bank);
92
+			has_effect = 1;
93
+		}
94
+	}
95
+	else if(active_side_affecting->sticky_web && !(active_side_affecting->sticky_web_done) && battle_participants[battle_active_bank].spd_buff != 0)
96
+	{
97
+		active_side_affecting->sticky_web_done=1;
98
+        battle_script_push();
99
+        battlescript_cursor = bs_sticky_web;
100
+        battle_stat_changer = 0x93;
101
+        has_effect = 1;
102
+	}
62 103
 	
63 104
 	if (has_effect)
64 105
     {
@@ -67,4 +108,67 @@ u8 execute_entry_hazards()
67 108
        battle_hitmarker &= 0xFFFFFFBF;
68 109
     }
69 110
 	return has_effect;
111
+}
112
+
113
+u8 lay_entry_hazards()
114
+{
115
+	u8 target_side = get_side_from_bank(battle_defender_bank);
116
+	u8 fail=0;
117
+	struct side_affecting* target_side_struct = &custom_battle_struct.ptr->side_affecting[target_side];
118
+	switch(battle_executed_move)
119
+	{
120
+		case MOVE_SPIKES:
121
+			if(battle_side_timers[target_side].spikes_amount < 3)
122
+			{
123
+				battle_side_timers[target_side].spikes_amount++;
124
+				side_affecting_halfword[target_side].spikes_on = 1;
125
+				battlescript_cursor = bs_spikes_lain;
126
+			}
127
+			else
128
+			{
129
+				fail = 1;
130
+			}
131
+			break;
132
+		case MOVE_STEALTH_ROCK:
133
+			if(target_side_struct->stealth_rock==0)
134
+			{	
135
+				target_side_struct->stealth_rock=1;
136
+				battlescript_cursor = bs_rocks_lain;
137
+			}
138
+			else
139
+				fail=1;
140
+			break;
141
+		case MOVE_TOXIC_SPIKES:
142
+			if(target_side_struct->toxic_spikes_psn==0)
143
+			{
144
+				target_side_struct->toxic_spikes_psn=1;
145
+				battlescript_cursor = bs_toxic_lain;
146
+			}
147
+			else if(target_side_struct->toxic_spikes_badpsn==0)
148
+			{
149
+				target_side_struct->toxic_spikes_badpsn=1;
150
+				battlescript_cursor = bs_toxic_lain;
151
+			}
152
+			else
153
+				fail=1;
154
+			break;
155
+		case MOVE_STICKY_WEB:
156
+			if(target_side_struct->sticky_web==0)
157
+			{
158
+				target_side_struct->sticky_web=1;
159
+				battlescript_cursor = bs_sticky_lain;
160
+			}
161
+			else
162
+				fail=1;
163
+			break;
164
+		default:
165
+			fail=1;
166
+			break;
167
+	}
168
+	if(fail)
169
+	{
170
+		//failed execution
171
+		battlescript_cursor = (void*) (0x081D7DF0);
172
+	}
173
+	return 1;
70 174
 }

+ 72
- 11
src/battle_engine/scripts/hazards.S Visa fil

@@ -6,18 +6,79 @@
6 6
 
7 7
 .global bs_stealth_rock_int
8 8
 bs_stealth_rock_int:
9
-
10
-orword 0x2023DD0 0x100100
11
-graphicalhpupdate 0x0
12
-datahpupdate 0x0
13
-setword 0x0203C020 str_stealth_rock
14
-printstring 0x184
15
-waitmessage 0x40
16
-faintpokemon 0x0 0x0 0x0
17
-faintpokemon 0x0 0x1 0x81D8CDF
18
-return
9
+	orword 0x2023DD0 0x100100
10
+	graphicalhpupdate 0x0
11
+	datahpupdate 0x0
12
+	setword STRING_LOADER str_stealth_rock
13
+	printstring 0x184
14
+	waitmessage 0x40
15
+	faintpokemon 0x0 0x0 0x0
16
+	faintpokemon 0x0 0x1 0x81D8CDF
17
+	return
19 18
 
20 19
 .align 2
21 20
 .global bs_stealth_rock
22 21
 bs_stealth_rock:
23
-.word bs_stealth_rock_int
22
+	.word bs_stealth_rock_int
23
+
24
+
25
+.global toxic_spikes_int
26
+toxic_spikes_int:
27
+	statusanimation BANK_TARGET
28
+	setword STRING_LOADER str_got_poison
29
+rest_of_toxic:
30
+	printstring 0x184
31
+	waitmessage 0x40
32
+	cmd98 0x0
33
+	setbyte 0x2023FD8 0x0
34
+	cmd49 0x0 0x0
35
+	return
36
+
37
+.align 2
38
+.global bs_toxic_spikes
39
+bs_toxic_spikes:
40
+	.word toxic_spikes_int
41
+
42
+.align 2
43
+.global bs_toxic_spikes_bad_int
44
+bs_toxic_spikes_bad_int:
45
+	statusanimation BANK_TARGET
46
+	setword STRING_LOADER str_got_bad_poison
47
+	goto rest_of_toxic
48
+
49
+.align 2
50
+.global bs_toxic_spikes_bad
51
+bs_toxic_spikes_bad:
52
+	.word bs_toxic_spikes_bad_int
53
+	
54
+.align 2
55
+.global bs_sticky_web_int
56
+bs_sticky_web_int:
57
+	setword STRING_LOADER str_sticky_web
58
+	printstring 0x184
59
+	waitmessage 0x40
60
+	statbuffchange 0x1 sticky_return
61
+	cmd47
62
+	playanimation 0 1 0x02023FD4
63
+	printfromtable 0x083FE57C
64
+	waitmessage 0x40
65
+sticky_return:
66
+	return
67
+	
68
+.align 2
69
+.global bs_sticky_web
70
+bs_sticky_web:
71
+	.word bs_sticky_web_int
72
+	
73
+.align 2
74
+.global bs_toxic_resolve_int
75
+bs_toxic_resolve_int:
76
+	setword STRING_LOADER str_toxic_resolve
77
+	printstring 0x184
78
+	waitmessage 0x40
79
+	return
80
+	
81
+.align 2
82
+.global bs_toxic_resolve
83
+bs_toxic_resolve:
84
+	.word bs_toxic_resolve_int

+ 6
- 0
src/include/battle.h Visa fil

@@ -8,8 +8,14 @@
8 8
 #ifndef BATTLE_H_
9 9
 #define BATTLE_H_
10 10
 
11
+#define REQUEST_HELDITEM_BATTLE 0x2
12
+#define REQUEST_STATUS_BATTLE 0x28
13
+
11 14
 u8 get_side_from_bank(u8 bank);
12 15
 
16
+void mark_buffer_bank_for_execution(u8 bank);
17
+void prepare_setattributes_in_battle(u8 buffer, u8 data_request, u8 unkown, u8 data_to_add, void* ptr_to_attribute);
18
+
13 19
 void battle_script_push();
14 20
 
15 21
 #endif

+ 4
- 0
src/include/battle_locations.h Visa fil

@@ -2,6 +2,10 @@
2 2
 #define BATTLE_LOC_H_
3 3
 
4 4
 u8 battle_active_bank;
5
+u8 battle_stat_changer;
6
+u16 battle_executed_move;
7
+u8 battle_attacker_bank;
8
+u8 battle_defender_bank;
5 9
 u16 battle_damage_store;
6 10
 u32 battle_hitmarker;
7 11
 void* battlescript_cursor;

+ 2
- 0
src/include/battle_script.h Visa fil

@@ -9,6 +9,8 @@
9 9
 #define DELAY_HALFSECOND	0x20
10 10
 #define DELAY_1SECOND		0x40
11 11
 
12
+#define STRING_LOADER		0x0203C020
13
+
12 14
 @@ Compare operands
13 15
 .equ Equal, 0x0
14 16
 .equ Notequal, 0x1

+ 25
- 0
src/include/battle_structs.h Visa fil

@@ -127,4 +127,29 @@ struct side_timer{
127 127
 
128 128
 extern struct side_timer battle_side_timers[2];
129 129
 
130
+struct in_battle_weather{
131
+    u32 rain : 1;
132
+    u32 downpour : 1;
133
+    u32 permament_rain : 1;
134
+    u32 sandstorm : 1;
135
+    u32 permament_sandstorm : 1;
136
+    u32 sun : 1;
137
+    u32 permament_sun : 1;
138
+    u32 hail : 1;
139
+    //custom flags
140
+    u32 permament_hail : 1;
141
+    u32 fog : 1;
142
+    u32 permament_fog : 1;
143
+    u32 harsh_sun : 1;
144
+    u32 heavy_rain : 1;
145
+    u32 air_current : 1;
146
+};
147
+
148
+union battle_weather{
149
+    u32 int_bw;
150
+    struct in_battle_weather flags;
151
+};
152
+
153
+extern union battle_weather battle_weather;
154
+
130 155
 #endif

+ 3
- 0
src/moves/battle_engine/cmd_callasm.S Visa fil

@@ -18,10 +18,13 @@ orr r1, r2
18 18
 lsl r3, #0x18
19 19
 orr r1, r3
20 20
 bl bxr1
21
+cmp r0, #0
22
+bne no_script_change
21 23
 ldr r0, =0x02023D74
22 24
 ldr r1, [r0]
23 25
 add r1, #5
24 26
 str r1, [r0]
27
+no_script_change:
25 28
 pop {r0}
26 29
 bx r0
27 30
 

+ 58
- 0
src/moves/hazards/hazards_scripts.S Visa fil

@@ -0,0 +1,58 @@
1
+#include <battle_script.h>
2
+
3
+.text
4
+.align 2
5
+.thumb
6
+
7
+.global hazards_script
8
+hazards_script:
9
+attackcanceler
10
+callasm lay_entry_hazards
11
+
12
+.global bs_spikes_lain_int
13
+bs_spikes_lain_int:
14
+setword STRING_LOADER str_spikes_lain
15
+goto hazards_end
16
+
17
+.global bs_toxic_lain_int
18
+bs_toxic_lain_int:
19
+setword STRING_LOADER str_toxic_lain
20
+goto hazards_end
21
+
22
+.global bs_rocks_lain_int
23
+bs_rocks_lain_int:
24
+setword STRING_LOADER str_rocks_lain
25
+goto hazards_end
26
+
27
+.global bs_sticky_lain_int
28
+bs_sticky_lain_int:
29
+setword STRING_LOADER str_sticky_lain
30
+goto hazards_end
31
+
32
+.align 2
33
+.global bs_spikes_lain
34
+bs_spikes_lain:
35
+	.word bs_spikes_lain_int
36
+	
37
+.global bs_rocks_lain
38
+bs_rocks_lain:
39
+	.word bs_rocks_lain_int
40
+	
41
+.global bs_toxic_lain
42
+bs_toxic_lain:
43
+	.word bs_toxic_lain_int
44
+	
45
+.global bs_sticky_lain
46
+bs_sticky_lain:
47
+	.word bs_sticky_lain_int
48
+
49
+hazards_end:
50
+attackstring
51
+ppreduce
52
+attackanimation
53
+waitanimation
54
+printstring 0x184
55
+waitmessage 0x40
56
+setbyte 0x2023FD8 0x0
57
+cmd49 0x0 0x0
58
+end

+ 9
- 1
string/de/hazards.txt Visa fil

@@ -1 +1,9 @@
1
-str_stealth_rock=\hFD\h13 wurde von Tarnsteinen\nverletzt!
1
+str_stealth_rock=\hFD\h13 wurde von Tarnsteinen\nverletzt!
2
+str_got_poison=\hFD\h13 wurde vergiftet!
3
+str_got_bad_poison=\hFD\h13 wurde schwer vergiftet!
4
+str_sticky_web=\hFD\h13 wurde in einem Klebenetz\ngefangen!
5
+str_toxic_resolve=Giftspitzen wurden von \hFD\h13\nabsorbiert!
6
+str_spikes_lain=STACHELN AUSGELEGT TEXT (ENGLISCH)
7
+str_toxic_lain=GIFTSPITZEN AUSGELEGT TEXT (ENGLISCH)
8
+str_rocks_lain=TARNSTEINE AUSGELEGT TEXT (ENGLISCH)
9
+str_sticky_lain=KLEBENETZ AUSGELEGT TEXT (ENGLISCH)

+ 5
- 1
string/en/hazards.txt Visa fil

@@ -1 +1,5 @@
1
-str_stealth_rock=\hFD\h13 was hurt by\nStealth Rock
1
+str_stealth_rock=\hFD\h13 was hurt by\nStealth Rock
2
+str_got_poison=\hFD\h13 was poisoned!
3
+str_got_bad_poison=\hFD\h13 was badly poisoned!
4
+str_sticky_web=\hFD\h13 was caught in a\nSticky Web!
5
+str_toxic_resolve=Toxic Spikes were absorbed by\n\hFD\h13