1
+ function Create (self )
2
+ self .multiplier = 0.8 ;
3
+ self .IgnoresTeamHits = false ;
4
+ self .width = 3 ;
5
+ end
6
+ function OnCollideWithMO (self , mo , rootMO )
7
+ if not self .target then
8
+ local trajectoryScalar = math.abs (math.cos (self .RotAngle - self .Vel .AbsRadAngle ));
9
+
10
+ local rayHitPos = Vector ();
11
+ local dots = math.sqrt (self .PrevVel .Magnitude );
12
+ local trace = Vector ((self .PrevVel .Magnitude * rte .PxTravelledPerFrame + self .width ) * trajectoryScalar * self .FlipFactor , 0 ):RadRotate (self .PrevRotAngle );
13
+ for i = 1 , dots do
14
+ local checkPos = self .PrevPos + trace * (i / dots );
15
+ local checkPix = SceneMan :GetMOIDPixel (checkPos .X , checkPos .Y );
16
+ if checkPix ~= rte .NoMOID then
17
+ local foundMO = MovableMan :GetMOFromID (checkPix );
18
+ if self .Mass * self .PrevVel .Magnitude * self .Sharpness > foundMO .Material .StructuralIntegrity then
19
+ checkPos = checkPos + SceneMan :ShortestDistance (checkPos , self .PrevPos , SceneMan .SceneWrapsX ):SetMagnitude (self .width );
20
+
21
+ self .target = ToMOSRotating (foundMO );
22
+ local dist = SceneMan :ShortestDistance (self .target .Pos , checkPos , SceneMan .SceneWrapsX );
23
+ local stickOffset = Vector (dist .X * self .target .FlipFactor , dist .Y ):RadRotate (- self .target .RotAngle * self .target .FlipFactor );
24
+
25
+ local woundName = self .target :GetEntryWoundPresetName ();
26
+ if woundName ~= " " then
27
+ local wound = CreateAEmitter (woundName );
28
+ wound .EmitCountLimit = math.ceil (wound .EmitCountLimit * 0.5 );
29
+ wound .Scale = wound .Scale * 0.5 ;
30
+ for em in wound .Emissions do
31
+ em .ParticlesPerMinute = em .ParticlesPerMinute * 0.75 ;
32
+ em .MaxVelocity = em .MaxVelocity * 0.75 ;
33
+ em .MinVelocity = em .MinVelocity * 0.75 ;
34
+ end
35
+ wound .InheritedRotAngleOffset = stickOffset .AbsRadAngle - (self .target .HFlipped and math.pi or 0 );
36
+ self .target :AddWound (wound , Vector (stickOffset .X , stickOffset .Y ):SetMagnitude (stickOffset .Magnitude - self .width ), math.random () < 0.5 );
37
+ end
38
+ self .Team = self .target .Team ;
39
+ self .InheritsHFlipped = (self .HFlipped == self .target .HFlipped ) and 1 or - 1 ;
40
+ self .DrawAfterParent = math.random () * self .target .Radius < self .Radius ;
41
+
42
+ self .InheritedRotAngleOffset = (self .PrevRotAngle - self .target .RotAngle ) * self .target .FlipFactor ;
43
+ self .target :AddAttachable (self :Clone (), stickOffset );
44
+ self .ToDelete = true ;
45
+ end
46
+ break ;
47
+ end
48
+ end
49
+ end
50
+ end
51
+ function OnAttach (self , parent )
52
+ if string.find (parent .Material .PresetName , " Flesh" ) then
53
+ parent .DamageMultiplier = parent .DamageMultiplier * self .multiplier ;
54
+ self :EnableEmission (true );
55
+ parent = parent :GetRootParent ();
56
+ if IsActor (parent ) then
57
+ local cross = CreateMOSParticle (" Particle Heal Effect" , " Base.rte" );
58
+ cross .Pos = ToActor (parent ).AboveHUDPos + Vector (0 , 4 );
59
+ MovableMan :AddParticle (cross );
60
+ end
61
+ end
62
+ self .target = parent ;
63
+ end
64
+ function OnDetach (self , parent )
65
+ if parent and string.find (parent .Material .PresetName , " Flesh" ) then
66
+ parent .DamageMultiplier = parent .DamageMultiplier / self .multiplier ;
67
+ local wound = CreateAEmitter (" Medical Dart Withdrawal" , " 4zK.rte" );
68
+ wound .Lifetime = self .Age ;
69
+ parent :AddAttachable (wound , Vector ());
70
+ self :EnableEmission (false );
71
+ end
72
+ end
0 commit comments