|
142 | 142 | qdel(O) |
143 | 143 | return TRUE |
144 | 144 |
|
145 | | -/datum/action/chameleon_copy |
| 145 | +/datum/action/cooldown/chameleon_copy |
146 | 146 | name = "Copy person" |
147 | 147 | button_icon_state = "default" //Temporary, just to test it works |
| 148 | + var/target_range = 3 |
148 | 149 | var/syndicate = FALSE |
149 | 150 | var/active = FALSE |
150 | 151 | var/copying = FALSE |
| 152 | + var/in_use = FALSE |
151 | 153 |
|
152 | | -/datum/action/chameleon_copy/Grant(mob/M) |
| 154 | +/datum/action/cooldown/chameleon_copy/Grant(mob/M) |
153 | 155 | if(syndicate) |
154 | 156 | owner_has_control = is_syndicate(M) |
155 | 157 | return ..() |
156 | 158 |
|
157 | | -/datum/action/chameleon_copy/Trigger(trigger_flags, atom/target) |
| 159 | +/datum/action/cooldown/chameleon_copy/Trigger(trigger_flags, atom/target) |
158 | 160 | if(active) |
159 | | - active = !active |
| 161 | + active = FALSE |
160 | 162 | build_all_button_icons() |
161 | 163 | return FALSE |
162 | 164 | to_chat(owner, span_announce("Whom shall your chameleon kit copy?")) //Bad wording, need to improve it |
163 | | - active = !active |
| 165 | + active = TRUE |
164 | 166 | build_all_button_icons() |
| 167 | + if(target) |
| 168 | + return InterceptClickOn(owner, null, target) |
| 169 | + |
| 170 | +/datum/action/cooldown/chameleon_copy/proc/CheckValidTarget(atom/target_atom) |
| 171 | + if(target_atom == owner) |
| 172 | + return FALSE |
| 173 | + return TRUE |
| 174 | + |
| 175 | +/datum/action/cooldown/chameleon_copy/proc/CheckCanTarget(atom/target_atom) |
| 176 | + if(target_range) |
| 177 | + if(!(target_atom in view(target_range, owner))) |
| 178 | + return FALSE |
| 179 | + return istype(target_atom) |
| 180 | + |
| 181 | +/datum/action/cooldown/chameleon_copy/proc/click_with_power(atom/target_atom) |
| 182 | + if(in_use || !CheckValidTarget(target_atom)) |
| 183 | + return FALSE |
| 184 | + if(!CheckCanTarget(target_atom)) |
| 185 | + return TRUE |
| 186 | + in_use = TRUE |
| 187 | + FireTargetedPower(target_atom) |
| 188 | + in_use = FALSE |
| 189 | + return TRUE |
| 190 | + |
| 191 | +/datum/action/cooldown/chameleon_copy/proc/FireTargetedPower(atom/target_atom) |
| 192 | + . = ..() |
| 193 | + var/mob/living/target = target_atom |
| 194 | + var/mob/living/user = owner |
| 195 | + var/datum/outfit/O = new() |
| 196 | + to_chat(owner, span_notice("Attempting to copy [target]...")) |
| 197 | + if(!do_after(user, 5 SECONDS, target)) |
| 198 | + return |
| 199 | + for(var/item in target.contents) |
| 200 | + message_admins(item) |
| 201 | + to_chat(owner, span_notice("Successfully copied [target]!")) |
| 202 | + active = FALSE |
| 203 | + |
| 204 | + |
| 205 | +/datum/action/cooldown/chameleon_copy/InterceptClickOn(/mob/living/caller, params, atom/target) |
| 206 | + click_with_power() |
165 | 207 |
|
166 | 208 | /datum/action/item_action/chameleon/change |
167 | 209 | name = "Chameleon Change" |
|
180 | 222 | var/datum/action/chameleon_outfit/O = new /datum/action/chameleon_outfit() |
181 | 223 | O.syndicate = syndicate |
182 | 224 | O.Grant(M) |
183 | | - var/datum/action/chameleon_copy/C = new /datum/action/chameleon_copy() |
| 225 | + var/datum/action/cooldown/chameleon_copy/C = new /datum/action/cooldown/chameleon_copy() |
184 | 226 | C.syndicate = syndicate |
185 | 227 | C.Grant(M) |
186 | 228 | else |
|
0 commit comments