diff --git a/planet/Objects.ocd/Animals.ocd/LavaCore.ocd/LavaCoreShell.ocd/Script.c b/planet/Objects.ocd/Animals.ocd/LavaCore.ocd/LavaCoreShell.ocd/Script.c index 948f98510..014199c75 100644 --- a/planet/Objects.ocd/Animals.ocd/LavaCore.ocd/LavaCoreShell.ocd/Script.c +++ b/planet/Objects.ocd/Animals.ocd/LavaCore.ocd/LavaCoreShell.ocd/Script.c @@ -5,7 +5,6 @@ @author Win, Maikel */ - local size; public func InitAttach(object parent) @@ -15,13 +14,18 @@ public func InitAttach(object parent) return; } -public func SetSize(int size) +public func SetSize(int to_size) { - // Rotate core to solidmask. + size = to_size; + // Rotate core to match solidmask. var r = -70; var fsin = Sin(r, 10 * size), fcos = Cos(r, 10 * size); SetObjDrawTransform(+fcos, +fsin, 0, -fsin, +fcos, 0); - // Update solid mask. + return; +} + +public func AddSolidMask() +{ var solid_size = 2 * ((size * 20 / 100 + 2) / 2) + 4; solid_size = BoundBy(solid_size, 4, 28); var solid_x = (1 + solid_size / 2) * (solid_size - 4); @@ -29,6 +33,12 @@ public func SetSize(int size) return; } +public func RemoveSolidMask() +{ + SetSolidMask(); + return; +} + /*-- Saving --*/ diff --git a/planet/Objects.ocd/Animals.ocd/LavaCore.ocd/Script.c b/planet/Objects.ocd/Animals.ocd/LavaCore.ocd/Script.c index 7ef8abc19..08e7543d6 100644 --- a/planet/Objects.ocd/Animals.ocd/LavaCore.ocd/Script.c +++ b/planet/Objects.ocd/Animals.ocd/LavaCore.ocd/Script.c @@ -160,10 +160,14 @@ local FxCoreBehavior = new Effect var angle = Random(360); if (prey) angle = Angle(Target->GetX(), Target->GetY(), prey->GetX(), prey->GetY()); - var test_x = Sin(angle, Target->GetCon() / 4); - var test_y = -Cos(angle, Target->GetCon() / 4); - if (!PathFree(Target->GetX(), Target->GetY(), Target->GetX() + test_x, Target->GetY() + test_y)) - return; + // Test if shot is not blocked by the shell. + if (Target.shell) + { + var shell_angle = Normalize(Target.shell->GetR() + 90, 0); + var diff_angle = angle - shell_angle; + if (!Inside(diff_angle, -30, 30) && diff_angle < 330 && diff_angle > -330) + return; + } var bubble = Target->CreateObject(BoilingLava_Bubble); bubble->SetVelocity(angle, RandomX(30, 40)); @@ -195,7 +199,6 @@ local FxCoreBehavior = new Effect var cnat = Target->GetContact(-1); if (!Target->InLiquid()) { - //Log("[%d]%v out of liquid", FrameCounter(), Target); cnat = cnat | CNAT_Top; } var other_core = Target->FindObject(Find_ID(LavaCore), Find_Exclude(Target), Target->Find_Distance(20 + Target.MaxSize)); @@ -321,6 +324,7 @@ public func Fossilize() { shell->SetMeshMaterial("LavaShellStoneMat"); shell->SetRDir(0); + shell->AddSolidMask(); } return; } @@ -332,7 +336,10 @@ public func Revive() SetComDir(COMD_None); SetMeshMaterial("LavaCoreMat"); if (shell) + { shell->SetMeshMaterial("LavaShellMat"); + shell->RemoveSolidMask(); + } return; }