def OnCollision(self, CollisionEvent): if not CollisionEvent.OtherObject.PlayerController: Zero.Disconnect(self.Owner, Events.CollisionStarted, self) self.Owner.Collider.Ghost = True self.Owner.TimedDeath.Active = True self.Owner.CanHurtOnce.Active = False self.Owner.RigidBody.Static = True else: Zero.Disconnect(self.Owner, Events.CollisionStarted, self) self.Owner.Collider.Ghost = True self.Owner.RigidBody.Static = True self.Owner.TimedDeath.Active = True self.Owner.GravityEffect.Active = False self.Owner.AttachToRelative(CollisionEvent.OtherObject)
def OnCollision(self, CollisionEvent): self.EnsureObserver() for observer in self.observers: observer.Summoned.ShowAll() Zero.Connect(self.Space, Events.LogicUpdate, self.FlyUpdate) Zero.Disconnect(self.Owner, Events.CollisionStarted, self)
def FlyUpdate(self, UpdateEvent): t = self.Owner.Transform.WorldTranslation self.Owner.Transform.WorldTranslation = t * 0.9 + self.destination * 0.1 if (self.Owner.Transform.WorldTranslation - self.destination).length() < 0.01: Zero.Disconnect(self.Space, Events.LogicUpdate, self)
def OnLogicUpdate(self, UpdateEvent): if not self.Activated: if self.StartFreezing: self.FreezeCounter += UpdateEvent.Dt self.Owner.DragEffect.Drag *= 1.1 if self.FreezeCounter > self.FreezeDelay: self.Activated = True self.Owner.Collider.Ghost = False self.Owner.DragEffect.Active = False self.Owner.GravityEffect.Active = True for contactholder in self.Owner.Collider.Contacts: otherobj = contactholder.OtherObject if otherobj.CannotBeFrozen: continue if otherobj.RigidBody: otherobj.RigidBody.Kinematic = False otherobj.RigidBody.Static = True if otherobj.AIMovementInterface: otherobj.AIMovementInterface.Deactivate() if otherobj.BurnAnim: otherobj.BurnAnim.Active = False if otherobj.PoisonAnim: otherobj.PoisonAnim.Active = False if otherobj.FreezeAnim: otherobj.FreezeAnim.Active = False else: effect_active = False for contactholder in self.Owner.Collider.Contacts: if contactholder.OtherObject.CannotBeFrozen: effect_active = True if not effect_active: self.Owner.GravityEffect.Active = False Zero.Disconnect(self.Owner, Events.LogicUpdate, self.OnLogicUpdate)
def OnLogicUpdate(self, UpdateEvent): if not self.followed.CanFancyDie.DeathActive: self.Owner.RigidBody.Kinematic = False Zero.Disconnect(self.Space, Events.LogicUpdate, self) else: self.Owner.Transform.Translation = self.followpoint + self.followed.Transform.Translation
def OnLogicUpdate(self, UpdateEvent): if not self.Activated: if self.StartFreezing: self.FreezeCounter += UpdateEvent.Dt self.Owner.DragEffect.Drag *= 1.1 if self.Owner.FlowEffect: self.Owner.FlowEffect.FlowSpeed *= 0.95 #self.Owner.AddComponentByName("FreezeAnim") if self.FreezeCounter > self.FreezeDelay: freezeflow = Zero.ScriptEvent() self.Owner.Region.DispatchEvent("FreezeFlowEvent", freezeflow) self.Activated = True self.Owner.Collider.Ghost = False self.Owner.DragEffect.Active = False if self.Owner.FlowEffect: self.Owner.FlowEffect.Active = False self.Owner.GravityEffect.Active = True for contactholder in self.Owner.Collider.Contacts: otherobj = contactholder.OtherObject if otherobj.MouseLocationIndicator: continue elif otherobj.CannotBeFrozen: continue elif otherobj.GrowableGround: continue elif otherobj.PlantAnnihilator: continue if otherobj.RigidBody: otherobj.RigidBody.Kinematic= False otherobj.RigidBody.Static= True if otherobj.AIMovementInterface: otherobj.AIMovementInterface.Deactivate() if otherobj.BurnAnim: otherobj.BurnAnim.Active = False if otherobj.PoisonAnim: otherobj.PoisonAnim.Active = False #if otherobj.FreezeAnim: # otherobj.FreezeAnim.Active = False else: effect_active = False for contactholder in self.Owner.Collider.Contacts: if contactholder.OtherObject.CannotBeFrozen: effect_active = True if not effect_active: s = self.Owner.Sprite.Color self.Owner.Sprite.Color = VectorMath.Vec4(s.x * 2.3, s.y * 2.3, s.z * 2.3, 1) self.Owner.GravityEffect.Active = False if self.Owner.CanHurt: self.Owner.CanHurt.Active = False Zero.Disconnect(self.Space, Events.LogicUpdate, self)
def OnLogicUpdate(self, UpdateEvent): self.target.RigidBody.Kinematic = True self.target.Transform.WorldTranslation = self.target.Transform.WorldTranslation * 0.8 + self.Owner.Transform.WorldTranslation * 0.2 if (self.target.Transform.WorldTranslation-self.Owner.Transform.WorldTranslation).length() < 0.0001: Zero.Disconnect(self.Space, Events.LogicUpdate, self) if self.target.PlayerController: self.target.PlayerController.DontUpdateAnim = True self.target.PlayerController.PlayPainAnim()
def OnCollision(self, CollisionEvent): if not CollisionEvent.OtherObject.PlayerController: Zero.Disconnect(self.Owner, Events.CollisionStarted, self) self.Owner.Collider.Ghost = True self.Owner.TimedDeath.Active = True self.Owner.CanHurtOnce.Active = False self.Owner.RigidBody.Kinematic = True else: Zero.Disconnect(self.Owner, Events.CollisionStarted, self) self.Owner.Collider.Ghost = True self.Owner.RigidBody.Kinematic = True self.Owner.TimedDeath.Active = True self.Owner.GravityEffect.Active = False self.followed = CollisionEvent.OtherObject self.followpoint = self.Owner.Transform.Translation - self.followed.Transform.Translation Zero.Connect(self.Space, Events.LogicUpdate, self.OnLogicUpdate)
def UnHook(self): self.Owner.RigidBody.Static = False self.Owner.DetachRelative() if self.Owner.Teleportable: self.Owner.Teleportable.Active = True if self.Owner.TimedDeath: self.Owner.TimedDeath.Active = True if self.Owner.CanCollect: self.Owner.RemoveComponentByName("CanCollect") Zero.Disconnect(self.Space, Events.LogicUpdate, self)
def OnCollision(self, CollideEvent): if CollideEvent.OtherObject == self.Target: def DestroyIt(): self.Space.CreateAtPosition( "SoulHitEffect", self.Owner.Transform.WorldTranslation) self.Owner.Destroy() seq = Action.Sequence(self.Owner.Actions) Action.Delay(seq, 0.1) Action.Call(seq, DestroyIt) Zero.Disconnect(self.Owner, Events.CollisionStarted, self)
def OnCollision(self, CollisionEvent): if CollisionEvent.OtherObject.GrowableGround: normal = -CollisionEvent.FirstPoint.WorldNormalTowardsOther self.Owner.Transform.Translation += normal * CollisionEvent.FirstPoint.Penetration if self.ShouldRoot: self.Owner.Transform.Rotation = CollisionEvent.OtherObject.Transform.Rotation self.Owner.RigidBody.Kinematic = True if self.Owner.CanBounce: self.Owner.CanBounce.ToDirection(normal) Zero.Disconnect(self.Owner, Events.CollisionStarted, self)
def OnCollision(self, CollisionEvent): if CollisionEvent.OtherObject.GrowableGround or CollisionEvent.OtherObject.PlantAnnihilator: self.normal = -CollisionEvent.FirstPoint.WorldNormalTowardsOther self.normal.z = 0 self.Owner.Transform.Translation += self.normal * CollisionEvent.FirstPoint.Penetration if self.ShouldRoot: #self.Owner.Transform.RotateByAngles(VectorMath.Vec3(0,0,self.normal.angleZ()-math.pi/2)) #CollisionEvent.OtherObject.Transform.Rotation self.Owner.RigidBody.Kinematic = True #if self.Owner.CanBounce: #self.Owner.CanBounce.ToDirection(self.normal) Zero.Disconnect(self.Owner, Events.CollisionStarted, self)
def OnCollision(self, CollisionEvent): CollisionEvent.OtherObject.RigidBody.Kinematic = True seq = Action.Sequence(self.Owner.Actions) Action.Delay(seq,1) def Blacker(): self.Space.FindObjectByName("Camera").CameraFunction.SetCameraFade(VectorMath.Vec4(0,0,0,0),VectorMath.Vec4(0,0,0,1),0.15,0) self.Space.FindObjectByName("LevelSettings").LevelStart.HUDManager.HideBoxes() Action.Call(seq, Blacker) Action.Delay(seq,3) def DestroyAll(): self.Space.LoadLevel("MenuScreen") self.Space.FindObjectByName("LevelSettings").LevelStart.HUDManager.Space.Destroy() Action.Call(seq, DestroyAll) Zero.Disconnect(self.Owner, Events.CollisionStarted, self)
def OnLogicUpdate(self, UpdateEvent): if not self.Activated: if self.StartFreezing: if self.FreezingObject: self.last_pos = self.FreezingObject.Transform.WorldTranslation self.FreezeCounter += UpdateEvent.Dt self.Owner.DragEffect.Drag *= 1.1 if self.Owner.FlowEffect: self.Owner.FlowEffect.FlowSpeed *= 0.95 #self.Owner.AddComponentByName("FreezeAnim") if self.FreezeCounter > self.FreezeDelay: #freezeflow = Zero.ScriptEvent() #self.Owner.Region.DispatchEvent("FreezeFlowEvent", freezeflow) self.Activated = True self.Owner.Collider.Ghost = False self.Owner.DragEffect.Active = False if self.Owner.FlowEffect: self.Owner.FlowEffect.Active = False self.Owner.GravityEffect.Active = True for contactholder in self.Owner.Collider.Contacts: otherobj = contactholder.OtherObject if otherobj.MouseLocationIndicator: continue elif otherobj.CannotBeFrozen: continue elif otherobj.GrowableGround: continue elif otherobj.PlantAnnihilator: continue if otherobj.RigidBody: otherobj.RigidBody.Kinematic= False otherobj.RigidBody.Static= True if otherobj.AIMovementInterface: otherobj.AIMovementInterface.Deactivate() if otherobj.BurnAnim: otherobj.BurnAnim.Active = False if otherobj.PoisonAnim: otherobj.PoisonAnim.Active = False if otherobj.FreezeAnim: otherobj.FreezeAnim.Active = False if otherobj.Hierarchy and not otherobj.FreezableFlow: for child in otherobj.Hierarchy.Children: if child.Sprite: child.Sprite.AnimationActive = False if otherobj.FreezableFlow: otherobj.FreezableFlow.DirectActivate(self.Owner) otherobj.Transform.Translation *= VectorMath.Vec3(1,1,-1) else: effect_active = False for contactholder in self.Owner.Collider.Contacts: if contactholder.OtherObject.CannotBeFrozen: effect_active = True if not effect_active: s = self.Owner.Sprite.Color self.Owner.Sprite.Color = VectorMath.Vec4(s.x * 2.3, s.y * 2.3, s.z * 2.3, 1) self.Owner.GravityEffect.Active = False if self.Owner.CanHurt: self.Owner.CanHurt.Active = False if self.FreezingObject: self.Owner.WaterLayerGenerator.FreezeAt(self.FreezingObject.Transform.WorldTranslation) else: self.Owner.WaterLayerGenerator.FreezeAt(self.last_pos) self.Owner.AddComponentByName("IsSentry") Zero.Disconnect(self.Space, Events.LogicUpdate, self)
def DeactivateAndReset(self): self.Owner.Sprite.SpriteSource = self.AnimTable.FindValue( "NonActivated") Zero.Disconnect(self.Owner, Events.CollisionStarted, self)
def HidingUpdate(self, UpdateEvent): self.Owner.Transform.WorldTranslation = 0.95 * self.Owner.Transform.WorldTranslation + 0.05 * self.destination_loc if (self.Owner.Transform.WorldTranslation - self.destination_loc).length() < 0.1: Zero.Disconnect(self.Space, Events.LogicUpdate, self)
def UnhidingUpdate(self, UpdateEvent): self.Owner.Transform.WorldTranslation = 0.95 * self.Owner.Transform.WorldTranslation + 0.05 * self.initial_loc #print("unhiding",(self.Owner.Transform.WorldTranslation - self.initial_loc).length()) if (self.Owner.Transform.WorldTranslation - self.initial_loc).length() < 0.1: Zero.Disconnect(self.Space, Events.LogicUpdate, self)
def OnCollision(self, CollisionEvent): Zero.Connect(self.Space, Events.LogicUpdate, self.FlyUpdate) Zero.Disconnect(self.Owner, Events.CollisionStarted, self)
def Hide(self): if not self.hided: self.hided = True Zero.Disconnect(self.Owner, Events.LogicUpdate, self) Zero.Connect(self.Space, Events.LogicUpdate, self.HidingUpdate)
def Unhide(self): if self.hided: self.hided = False Zero.Disconnect(self.Owner, Events.LogicUpdate, self) Zero.Connect(self.Space, Events.LogicUpdate, self.UnhidingUpdate)
def OnLogicUpdate(self, UpdateEvent): camera = self.Space.FindObjectByName("Camera") camera.CameraFunction.SetCameraFade(Vec4(1,1,1,1),Vec4(1,1,1,0),0.03,0) Zero.Disconnect(self.Space, Events.LogicUpdate, self)
def OnCollision(self, CollisionEvent): self.Owner.Sprite.SpriteSource = self.AnimTable.FindValue("Activated") Zero.Disconnect(self.Owner, Events.CollisionStarted, self)
def OnCollision(self, CollisionEvent): self.target = CollisionEvent.OtherObject Zero.Disconnect(self.Owner, Events.CollisionStarted, self) Zero.Connect(self.Space, Events.LogicUpdate, self.OnLogicUpdate)