Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- float postSpeed;//the lower speed value that the character should use after the first time A_ChaseSmooth has been called,
- //to get out of tight spots from it's spawn position
- property PostSpeed : postSpeed;
- bool setPostSpeed;
- float turnSpeed;
- property TurnSpeed : turnSpeed;
- float angleTemp;
- float angleTarget;
- State chaseState;
- int chaseTic;//failsafe to ensure A_Chase is not called longer than the initial A_Chase frame length
- Default
- {
- VoxelCharacter.TurnSpeed 15.0;
- }
- override void Tick()
- {
- Super.Tick();
- if (chaseState && CurState && tics != CurState.tics)
- {
- if (CurState == chaseState && chaseTic > 0)
- {
- chaseTic--;
- angleTemp = self.angle;
- A_Chase(null, null, CHF_NORANDOMTURN|CHF_NOPLAYACTIVE);
- //smooth turning
- double angDiff = DeltaAngle (angleTemp, self.angle);
- if (angDiff ~== 0)
- {
- return;
- }
- A_SetAngle(angleTemp + ((angDiff < 0) ? max (-turnSpeed, angDiff) : min (turnSpeed, angDiff)),SPF_INTERPOLATE);
- }
- else
- {
- chaseState = null;
- }
- }
- }
- virtual void ChaseSmooth(int chaseLength = 1, StateLabel melee = '_a_chase_default', StateLabel missile = '_a_chase_default', int flags = 0)
- {
- //for the first time ChaseSmooth is called, call A_Chase as normal, but then set the speed to the lower value suitable for calling each tic.
- if(setPostSpeed == false)
- {
- setPostSpeed = true;
- A_Chase();
- speed = postSpeed;
- return;
- }
- chaseState = CurState;
- angleTemp = self.angle;
- chaseTic = chaseLength - 1;
- A_Chase(melee, missile, flags);
- //smooth turning
- double angDiff = DeltaAngle (angleTemp, self.angle);
- if (angDiff ~== 0)
- {
- return;
- }
- A_SetAngle(angleTemp + ((angDiff < 0) ? max (-turnSpeed, angDiff) : min (turnSpeed, angDiff)),SPF_INTERPOLATE);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement