guts.c 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. class Guts extends Edible_Base
  2. {
  3. override bool CanPutAsAttachment( EntityAI parent )
  4. {
  5. if(!super.CanPutAsAttachment(parent)) {return false;}
  6. const int SLOTS_ARRAY = 8;
  7. bool is_barrel = false;
  8. bool is_opened_barrel = false;
  9. bool slot_test = true;
  10. string slot_names[SLOTS_ARRAY] = { "BerryR", "BerryB", "Nails", "OakBark", "BirchBark", "Lime", "Disinfectant" };
  11. // is barrel
  12. if ( parent.IsKindOf("Barrel_ColorBase") )
  13. {
  14. is_barrel = true;
  15. }
  16. // is opened barrel
  17. if ( is_barrel && parent.GetAnimationPhase("Lid") == 1 )
  18. {
  19. is_opened_barrel = true;
  20. }
  21. // all of the barrel slots are empty
  22. for ( int i = 0; i < SLOTS_ARRAY ; i++ )
  23. {
  24. if ( parent.FindAttachmentBySlotName(slot_names[i]) != NULL )
  25. {
  26. slot_test = false;
  27. break;
  28. }
  29. }
  30. if ( ( is_opened_barrel && slot_test ) || !is_barrel )
  31. {
  32. return true;
  33. }
  34. return false;
  35. }
  36. override bool CanDetachAttachment( EntityAI parent )
  37. {
  38. bool is_barrel = false;
  39. bool is_opened_barrel = false;
  40. // is barrel
  41. if ( parent.IsKindOf("Barrel_ColorBase") )
  42. {
  43. is_barrel = true;
  44. }
  45. // is opened barrel
  46. if ( is_barrel && parent.GetAnimationPhase("Lid") == 1 )
  47. {
  48. is_opened_barrel = true;
  49. }
  50. if ( is_opened_barrel || !is_barrel )
  51. {
  52. return true;
  53. }
  54. return false;
  55. }
  56. override void SetActions()
  57. {
  58. super.SetActions();
  59. AddAction(ActionForceFeed);
  60. AddAction(ActionEatBig);
  61. }
  62. }