Advertisement
Guest User

Untitled

a guest
Oct 15th, 2019
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.50 KB | None | 0 0
  1. On.RoR2.GravitatePickup.Start += (orig, self) =>
  2. {
  3.  
  4. orig(self);
  5. //self.rigidbody.AddForce(UnityEngine.Random.Range(-750f, 750f), 0, UnityEngine.Random.Range(-750f, 750f));
  6.  
  7. };
  8.  
  9. IL.RoR2.GlobalEventManager.OnCharacterDeath += (il) =>
  10. {
  11. var c = new ILCursor(il);
  12. c.GotoNext(
  13. x => x.MatchLdloc(32)
  14. );
  15. instr2 = c.Next.Operand;
  16.  
  17. c.GotoNext(
  18. x => x.MatchLdloc(32)
  19. );
  20. c.Index += 1;
  21.  
  22. c.EmitDelegate<Func<int, int>>((toothcount) =>
  23. {
  24. toothcount = 0;
  25. System.Collections.ObjectModel.ReadOnlyCollection<TeamComponent> teammembers = TeamComponent.GetTeamMembers(TeamIndex.Player);
  26. for (int i = 0; i < teammembers.Count; i++)
  27. {
  28. if (Util.LookUpBodyNetworkUser(teammembers[i].gameObject))
  29. {
  30. CharacterBody component = teammembers[i].GetComponent<CharacterBody>();
  31. if (component && component.inventory)
  32. {
  33. toothcount += component.inventory.GetItemCount(ItemIndex.Tooth);
  34. }
  35. }
  36. }
  37. Debug.Log(toothcount);
  38. return toothcount;
  39. });
  40.  
  41. c.GotoNext(
  42. x => x.MatchLdloc(52),
  43. x => x.MatchLdloc(52),
  44. x => x.MatchLdloc(52)
  45. );
  46. c.Index += 5;
  47. c.Remove();
  48. c.Emit(OpCodes.Ldloc_S, instr2);
  49. c.EmitDelegate<Action<GameObject, int>>((healthOrbGameObject, toothCount ) =>
  50. {
  51. //float num6 = Mathf.Pow((float)toothamount, 0.25f);
  52. float toothamount = 0;
  53. System.Collections.ObjectModel.ReadOnlyCollection<TeamComponent> teammembers = TeamComponent.GetTeamMembers(TeamIndex.Player);
  54. for(int i = 0; i < teammembers.Count; i++)
  55. {
  56. if (Util.LookUpBodyNetworkUser(teammembers[i].gameObject))
  57. {
  58. CharacterBody component = teammembers[i].GetComponent<CharacterBody>();
  59. if (component && component.inventory)
  60. {
  61. toothamount += component.inventory.GetItemCount(ItemIndex.Tooth);
  62. }
  63. }
  64. }
  65.  
  66. Debug.Log("Total tooth amount : "+toothamount);
  67.  
  68. healthOrbGameObject.GetComponentInChildren<HealthPickup>().flatHealing = 0f;
  69. healthOrbGameObject.GetComponentInChildren<HealthPickup>().fractionalHealing = healingStack1 + healingOtherStacks * (toothamount - 1);
  70. UnityEngine.Networking.NetworkServer.Spawn(healthOrbGameObject);
  71. /*for (int i = stacksPerOrb; i <= toothCount; i += stacksPerOrb)
  72. {
  73. GameObject gameObject5 = UnityEngine.Object.Instantiate<GameObject>(Resources.Load<GameObject>("Prefabs/NetworkedObjects/HealPack"), gameObject.transform.position, UnityEngine.Random.rotation);
  74. gameObject5.GetComponent<TeamFilter>().teamIndex = healthOrbGameObject.GetComponent<TeamFilter>().teamIndex;
  75. gameObject5.GetComponentInChildren<HealthPickup>().flatHealing = 0f;
  76. gameObject5.GetComponentInChildren<HealthPickup>().fractionalHealing = healingStack1 + healingOtherStacks * (toothCount - 1);
  77. gameObject5.transform.localScale = new Vector3(num6, num6, num6);
  78. gameObject5.transform.position = new Vector3(healthOrbGameObject.transform.position.x + UnityEngine.Random.Range(-1f, 1f), healthOrbGameObject.transform.position.y + UnityEngine.Random.Range(-0.5f, 1.5f), healthOrbGameObject.transform.position.z + UnityEngine.Random.Range(-1f, 1f));
  79.  
  80. UnityEngine.Networking.NetworkServer.Spawn(gameObject5);
  81. }*/
  82. });
  83. //Debug.Log(il.ToString());
  84. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement