|
354 | 354 | icon = 'icons/obj/weapons/energy_melee.dmi' |
355 | 355 | lefthand_file = 'icons/mob/inhands/weapons_lefthand.dmi' |
356 | 356 | righthand_file = 'icons/mob/inhands/weapons_righthand.dmi' |
357 | | - icon_state = "sword0" |
| 357 | + icon_state = "sword" |
358 | 358 | hitsound = "swing_hit" |
359 | 359 | force = 3.0 |
360 | 360 | throw_speed = 1 |
361 | 361 | throw_range = 5 |
362 | 362 | w_class = WEIGHT_CLASS_SMALL |
363 | 363 | armor_penetration_percentage = 50 |
364 | 364 | var/active = FALSE |
| 365 | + /// Color of this e-sword. You can see supported colors in icon file |
| 366 | + var/sword_color |
365 | 367 |
|
366 | 368 | /obj/item/holo/esword/Initialize(mapload) |
367 | 369 | . = ..() |
| 370 | + if(!sword_color) |
| 371 | + sword_color = pick("red", "blue", "green", "purple") |
368 | 372 | AddComponent(/datum/component/parry, _stamina_constant = 2, _stamina_coefficient = 0.5, _parryable_attack_types = NON_PROJECTILE_ATTACKS) |
369 | 373 |
|
370 | | -/obj/item/holo/esword/green/New() |
371 | | - ..() |
372 | | - item_color = "green" |
| 374 | +/obj/item/holo/esword/update_icon_state() |
| 375 | + icon_state = "[initial(icon_state)][active ? sword_color : ""]" |
373 | 376 |
|
374 | | -/obj/item/holo/esword/red/New() |
375 | | - ..() |
376 | | - item_color = "red" |
| 377 | +/obj/item/holo/esword/green |
| 378 | + sword_color = "green" |
| 379 | + |
| 380 | +/obj/item/holo/esword/red |
| 381 | + sword_color = "red" |
377 | 382 |
|
378 | 383 | /obj/item/holo/esword/hit_reaction(mob/living/carbon/human/owner, atom/movable/hitby, attack_text = "the attack", final_block_chance = 0, damage = 0, attack_type = MELEE_ATTACK) |
379 | 384 | if(active) |
380 | 385 | return ..() |
381 | 386 | return 0 |
382 | 387 |
|
383 | | -/obj/item/holo/esword/New() |
384 | | - ..() |
385 | | - item_color = pick("red","blue","green","purple") |
386 | | - |
387 | 388 | /obj/item/holo/esword/attack_self__legacy__attackchain(mob/living/user as mob) |
388 | 389 | active = !active |
389 | 390 | if(active) |
390 | 391 | force = 30 |
391 | | - icon_state = "sword[item_color]" |
392 | 392 | hitsound = "sound/weapons/blade1.ogg" |
393 | 393 | w_class = WEIGHT_CLASS_BULKY |
394 | 394 | playsound(user, 'sound/weapons/saberon.ogg', 20, 1) |
395 | 395 | to_chat(user, "<span class='notice'>[src] is now active.</span>") |
396 | 396 | else |
397 | 397 | force = 3 |
398 | | - icon_state = "sword0" |
399 | 398 | hitsound = "swing_hit" |
400 | 399 | w_class = WEIGHT_CLASS_SMALL |
401 | 400 | playsound(user, 'sound/weapons/saberoff.ogg', 20, 1) |
|
405 | 404 | H.update_inv_l_hand() |
406 | 405 | H.update_inv_r_hand() |
407 | 406 | add_fingerprint(user) |
408 | | - return |
| 407 | + update_icon(UPDATE_ICON_STATE) |
409 | 408 |
|
410 | 409 | /obj/machinery/readybutton |
411 | 410 | name = "Ready Declaration Device" |
|
0 commit comments