-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathRerollOnHit.cs
30 lines (25 loc) · 1.41 KB
/
RerollOnHit.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
namespace XRL.World.Parts {
public class helado_RerollOnHit : IPart {
public override bool FireEvent (Event E) {
switch (E.ID) {
case "ProjectileHit":
GameObject attacker = E.GetGameObjectParameter ("Attacker");
GameObject defender = E.GetGameObjectParameter ("Defender");
if (defender.IsPlayer ()) {
GameObject apparentTarget = E.GetGameObjectParameter ("ApparentTarget");
defender.FireEvent (Event.New ("Die", "Killer", attacker, "Reason", "You were replaced.", "Accidental", defender != apparentTarget)); }
else {
GameObject doppelganger = defender.GetBlueprint ().createOne ();
defender.GetAngryAt (attacker);
defender.ReplaceWith (doppelganger);
doppelganger.TeleportSwirl (null, "&M");
if (defender.HasPart ("Brain")) {
XRL.Core.XRLCore.Core.Game.ActionManager.AddActiveObject (doppelganger); }
AddPlayerMessage (doppelganger.The + doppelganger.DisplayName + " looks good as new!"); }
break;
default:
return base.FireEvent (E); }
return true; }
public override void Register (GameObject GO) {
GO.RegisterPartEvent (this, "ProjectileHit");
base.Register (GO); } } }