|
@@ -12,163 +12,133 @@ extern void* bs_rocks_lain;
|
12
|
12
|
extern void* bs_toxic_lain;
|
13
|
13
|
extern void* bs_sticky_lain;
|
14
|
14
|
|
15
|
|
-u8 execute_entry_hazards()
|
16
|
|
-{
|
17
|
|
- u8 active_side = get_side_from_bank(battle_active_bank);
|
18
|
|
- u8 has_effect = 0;
|
19
|
|
- struct side_affecting* active_side_affecting = &custom_battle_struct.ptr->side_affecting[active_side];
|
20
|
|
- if(side_affecting_halfword[active_side].spikes_on && !(side_affecting_halfword[active_side].spikes_damage_done))
|
21
|
|
- {
|
22
|
|
- //spikes lay down, deal spiky damage
|
23
|
|
- u32 damage = (battle_participants[battle_active_bank].max_hp) / ((5 - battle_side_timers[active_side].spikes_amount) * 2);
|
|
15
|
+u8 execute_entry_hazards() {
|
|
16
|
+ u8 active_side = get_side_from_bank(battle_active_bank);
|
|
17
|
+ u8 has_effect = 0;
|
|
18
|
+ struct side_affecting* active_side_affecting = &custom_battle_elements.ptr->side_affecting[active_side];
|
|
19
|
+ if (side_affecting_halfword[active_side].spikes_on && !(side_affecting_halfword[active_side].spikes_damage_done)) {
|
|
20
|
+ //spikes lay down, deal spiky damage
|
|
21
|
+ u32 damage = (battle_participants[battle_active_bank].max_hp) / ((5 - battle_side_timers[active_side].spikes_amount) * 2);
|
24
|
22
|
if (damage == 0)
|
25
|
23
|
damage = 1;
|
26
|
24
|
battle_damage_store = damage;
|
27
|
|
-
|
28
|
|
- side_affecting_halfword[active_side].spikes_damage_done = 1;
|
29
|
|
- battle_script_push();
|
30
|
|
- battlescript_cursor = (void*)(0x081D8CBE);
|
31
|
|
- has_effect = 1;
|
32
|
|
- }
|
33
|
|
- else if(active_side_affecting->stealth_rock && !(active_side_affecting->stealth_rock_done))
|
34
|
|
- {
|
35
|
|
- active_side_affecting->stealth_rock_done=1;
|
36
|
|
- //check for magic guard here
|
37
|
|
- u32 damage = battle_participants[battle_active_bank].max_hp;
|
38
|
|
- switch (type_effectiveness_calc(MOVE_STEALTH_ROCK, TYPE_ROCK, battle_active_bank^1, battle_active_bank, 0) >> 4)
|
39
|
|
- {
|
40
|
|
- case 1:
|
41
|
|
- damage = damage >> 5;
|
42
|
|
- break;
|
43
|
|
- case 2:
|
44
|
|
- damage = damage >> 4;
|
45
|
|
- break;
|
46
|
|
- case 4:
|
47
|
|
- damage = damage >> 3;
|
48
|
|
- break;
|
49
|
|
- case 8:
|
50
|
|
- damage = damage >> 2;
|
51
|
|
- break;
|
52
|
|
- case 16:
|
53
|
|
- damage = damage >> 1;
|
54
|
|
- break;
|
55
|
|
- }
|
56
|
|
- if(damage == 0)
|
57
|
|
- damage = 1;
|
58
|
|
- battle_damage_store = damage;
|
59
|
|
-
|
60
|
|
- battle_script_push();
|
61
|
|
- battlescript_cursor = bs_stealth_rock;
|
62
|
|
- has_effect = 1;
|
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
|
|
- }
|
|
25
|
+
|
|
26
|
+ side_affecting_halfword[active_side].spikes_damage_done = 1;
|
|
27
|
+ battle_script_push();
|
|
28
|
+ battlescript_cursor = (void*) (0x081D8CBE);
|
|
29
|
+ has_effect = 1;
|
|
30
|
+ } else if (active_side_affecting->stealth_rock && !(active_side_affecting->stealth_rock_done)) {
|
|
31
|
+ active_side_affecting->stealth_rock_done = 1;
|
|
32
|
+ //check for magic guard here
|
|
33
|
+ u32 damage = battle_participants[battle_active_bank].max_hp;
|
|
34
|
+ switch (type_effectiveness_calc(MOVE_STEALTH_ROCK, TYPE_ROCK, battle_active_bank^1, battle_active_bank, 0) >> 4) {
|
|
35
|
+ case 1:
|
|
36
|
+ damage = damage >> 5;
|
|
37
|
+ break;
|
|
38
|
+ case 2:
|
|
39
|
+ damage = damage >> 4;
|
|
40
|
+ break;
|
|
41
|
+ case 4:
|
|
42
|
+ damage = damage >> 3;
|
|
43
|
+ break;
|
|
44
|
+ case 8:
|
|
45
|
+ damage = damage >> 2;
|
|
46
|
+ break;
|
|
47
|
+ case 16:
|
|
48
|
+ damage = damage >> 1;
|
|
49
|
+ break;
|
|
50
|
+ }
|
|
51
|
+ if (damage == 0)
|
|
52
|
+ damage = 1;
|
|
53
|
+ battle_damage_store = damage;
|
|
54
|
+
|
|
55
|
+ battle_script_push();
|
|
56
|
+ battlescript_cursor = bs_stealth_rock;
|
|
57
|
+ has_effect = 1;
|
|
58
|
+ } else if (active_side_affecting->toxic_spikes_psn && !(active_side_affecting->toxic_spikes_done)) {
|
|
59
|
+ active_side_affecting->toxic_spikes_done = 1;
|
|
60
|
+ if (has_type(battle_active_bank, TYPE_POISON)) {
|
|
61
|
+ has_effect = 1;
|
|
62
|
+ active_side_affecting->toxic_spikes_psn = 0;
|
|
63
|
+ active_side_affecting->toxic_spikes_badpsn = 0;
|
|
64
|
+ battle_script_push();
|
|
65
|
+ battlescript_cursor = bs_toxic_resolve;
|
|
66
|
+ } else if (!cant_poison(battle_active_bank, 0)) {
|
|
67
|
+ if (active_side_affecting->toxic_spikes_badpsn) {
|
|
68
|
+ battle_participants[battle_active_bank].status.flags.toxic_poison = 1;
|
|
69
|
+ battle_script_push();
|
|
70
|
+ battlescript_cursor = bs_toxic_spikes_bad;
|
|
71
|
+ }
|
|
72
|
+ else {
|
|
73
|
+ battle_participants[battle_active_bank].status.flags.poison = 1;
|
|
74
|
+ battle_script_push();
|
|
75
|
+ battlescript_cursor = bs_toxic_spikes;
|
|
76
|
+ }
|
90
|
77
|
prepare_setattributes_in_battle(0, REQUEST_STATUS_BATTLE, 0, 4, &battle_participants[battle_active_bank].status.flags);
|
91
|
78
|
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;
|
|
79
|
+ has_effect = 1;
|
|
80
|
+ }
|
|
81
|
+ } else if (active_side_affecting->sticky_web && !(active_side_affecting->sticky_web_done) && battle_participants[battle_active_bank].spd_buff != 0) {
|
|
82
|
+ active_side_affecting->sticky_web_done = 1;
|
98
|
83
|
battle_script_push();
|
99
|
84
|
battlescript_cursor = bs_sticky_web;
|
100
|
85
|
battle_stat_changer = 0x93;
|
101
|
86
|
has_effect = 1;
|
102
|
|
- }
|
103
|
|
-
|
104
|
|
- if (has_effect)
|
105
|
|
- {
|
106
|
|
- custom_battle_struct.ptr->various.var1 = battle_active_bank;
|
107
|
|
- battle_participants[battle_active_bank].status2.destinny_bond = 0;
|
108
|
|
- battle_hitmarker &= 0xFFFFFFBF;
|
109
|
87
|
}
|
110
|
|
- return has_effect;
|
|
88
|
+
|
|
89
|
+ if (has_effect) {
|
|
90
|
+ custom_battle_elements.ptr->various.var1 = battle_active_bank;
|
|
91
|
+ battle_participants[battle_active_bank].status2.destinny_bond = 0;
|
|
92
|
+ battle_hitmarker &= 0xFFFFFFBF;
|
|
93
|
+ }
|
|
94
|
+ return has_effect;
|
111
|
95
|
}
|
112
|
96
|
|
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;
|
|
97
|
+u8 lay_entry_hazards() {
|
|
98
|
+ u8 target_side = get_side_from_bank(battle_defender_bank);
|
|
99
|
+ u8 fail = 0;
|
|
100
|
+ struct side_affecting* target_side_struct = &custom_battle_elements.ptr->side_affecting[target_side];
|
|
101
|
+ switch (battle_executed_move) {
|
|
102
|
+ case MOVE_SPIKES:
|
|
103
|
+ if (battle_side_timers[target_side].spikes_amount < 3) {
|
|
104
|
+ battle_side_timers[target_side].spikes_amount++;
|
|
105
|
+ side_affecting_halfword[target_side].spikes_on = 1;
|
|
106
|
+ battlescript_cursor = bs_spikes_lain;
|
|
107
|
+ } else {
|
|
108
|
+ fail = 1;
|
|
109
|
+ }
|
|
110
|
+ break;
|
|
111
|
+ case MOVE_STEALTH_ROCK:
|
|
112
|
+ if (target_side_struct->stealth_rock == 0) {
|
|
113
|
+ target_side_struct->stealth_rock = 1;
|
|
114
|
+ battlescript_cursor = bs_rocks_lain;
|
|
115
|
+ } else
|
|
116
|
+ fail = 1;
|
|
117
|
+ break;
|
|
118
|
+ case MOVE_TOXIC_SPIKES:
|
|
119
|
+ if (target_side_struct->toxic_spikes_psn == 0) {
|
|
120
|
+ target_side_struct->toxic_spikes_psn = 1;
|
|
121
|
+ battlescript_cursor = bs_toxic_lain;
|
|
122
|
+ } else if (target_side_struct->toxic_spikes_badpsn == 0) {
|
|
123
|
+ target_side_struct->toxic_spikes_badpsn = 1;
|
|
124
|
+ battlescript_cursor = bs_toxic_lain;
|
|
125
|
+ } else
|
|
126
|
+ fail = 1;
|
|
127
|
+ break;
|
|
128
|
+ case MOVE_STICKY_WEB:
|
|
129
|
+ if (target_side_struct->sticky_web == 0) {
|
|
130
|
+ target_side_struct->sticky_web = 1;
|
|
131
|
+ battlescript_cursor = bs_sticky_lain;
|
|
132
|
+ } else
|
|
133
|
+ fail = 1;
|
|
134
|
+ break;
|
|
135
|
+ default:
|
|
136
|
+ fail = 1;
|
|
137
|
+ break;
|
|
138
|
+ }
|
|
139
|
+ if (fail) {
|
|
140
|
+ //failed execution
|
|
141
|
+ battlescript_cursor = (void*) (0x081D7DF0);
|
|
142
|
+ }
|
|
143
|
+ return 1;
|
174
|
144
|
}
|