[Resource] ACS-based limited sprint system

Sprites, textures, sounds, code, and other resources belong here. Share and share-alike!
Forum rules
Before posting your Resource, please make sure you can answer YES to any of the following questions:
  • Is the resource ENTIRELY my own work?
  • If no to the previous one, do I have permission from the original author?
  • If no to the previous one, did I put a reasonable amount of work into the resource myself, such that the changes are noticeably different from the source that I could take credit for them?
If you answered no to all three, maybe you should consider taking your stuff somewhere other than the Resources forum.

Consult the Resource/Request Posting Guidelines for more information.

Please don't put requests here! They have their own forum --> here. Thank you!

[Resource] ACS-based limited sprint system

Postby TheRailgunner » Tue Nov 26, 2013 4:54 pm

A manual ACS sprint system that doesn't use Doom's run. It lasts for 240 tics, or almost 7 seconds, then regenerates over the same amount of time. Sprinting animations do have to be set up for weapons unless they are usable while sprinting. If you are not moving forward in any way, out of sprint counters, reloading a weapon that you can't use while sprinting, or aiming down a weapon's sights, you cannot sprint.

The ACS:

Code: Select allExpand view
// Sprint system courtesy of revo794 and MagSigmaX
#include "zcommon.acs"
#library "sprint"

Script "S_Forward" ENTER {
   int keyPress = 0;
   int pforward = 0;
   int pstamina = 0;
   While(1) {
      pstamina = CheckActorInventory(1000 + PlayerNumber(),"SprintCounter");
      pforward = CheckActorInventory(1000 + PlayerNumber(),"Forward");
      keyPress = GetPlayerInput(-1, INPUT_BUTTONS);
      Delay(1);
         if(keyPress & BT_FORWARD && pstamina >> 0) {
            GiveActorInventory(1000 + PlayerNumber(),"Forward", 1);
         }
         else {
            TakeActorInventory(1000 + PlayerNumber(),"Forward", 1);
            }
      }
}

Script "S_Sprint" ENTER {
   int keyPress = 0;
   int sprint = 0;
   int aiming = 0;
   int pstamina = 0;
   int preload = 0;
   int pforward = 0;
   //int pslot5 = 0;
   int velocity = GetActorVelX(1000 + PlayerNumber());
   Thing_ChangeTID(0, 1000 + PlayerNumber());
   While(1) {
      GiveActorInventory(1000 + PlayerNumber(),"Sprint", 1);
      GiveActorInventory(1000 + PlayerNumber(),"SprintCancel", 1);
      sprint = CheckActorInventory(1000 + PlayerNumber(),"IsSprinting");
      aiming = CheckActorInventory(1000 + PlayerNumber(),"SprintAim");
      pstamina = CheckActorInventory(1000 + PlayerNumber(),"SprintCounter");
      preload = CheckActorInventory(1000 + PlayerNumber(),"IsReloading");
      pforward = CheckActorInventory(1000 + PlayerNumber(),"Forward");
      //pslot5 = CheckActorInventory(1000 + PlayerNumber(),"HoldingSlot5Weapon");
      keyPress = GetPlayerInput(-1, INPUT_BUTTONS);
      Delay(1);
         if(sprint==1 && pstamina >> 0) {
            if(keyPress != BT_BACK && pforward==1 && preload==0 && aiming==0) {
               TakeInventory("DontSprint", 1);
               SetActorProperty(1000 + PlayerNumber(), APROP_SPEED, 1.8);
               TakeActorInventory(1000 + PlayerNumber(),"SprintCounter", 1);
               Delay(5);
               //print(s:"\cF\n", d:pforward, s:"\cS\n", d:pstamina ,s:"\cR\n", d:preload, s:"\cI\n", d:sprint, s:"\cA\n", d:aiming);
            }
            else {
               TakeActorInventory(1000 + PlayerNumber(),"Forward", 1);
               TakeActorInventory(1000 + PlayerNumber(),"IsSprinting", 1);
               GiveActorInventory(1000 + PlayerNumber(),"DontSprint", 1);
               SetActorProperty(1000 + PlayerNumber(), APROP_SPEED, 1.0);
               TakeActorInventory(1000 + PlayerNumber(),"SprintCounter", 1);
               Delay(5);
               //print(s:"\cF\n", d:pforward, s:"\cS\n", d:pstamina ,s:"\cR\n", d:preload, s:"\cI\n", d:sprint, s:"\cA\n", d:aiming);
            }
         }
         else if(sprint==1 && pstamina==0){
            TakeActorInventory(1000 + PlayerNumber(),"Forward", 1);
            TakeActorInventory(1000 + PlayerNumber(),"IsSprinting", 1);
            GiveActorInventory(1000 + PlayerNumber(),"DontSprint", 1);
            SetActorProperty(1000 + PlayerNumber(), APROP_SPEED, 1.0);
            TakeActorInventory(1000 + PlayerNumber(),"SprintCounter", 1);
            Delay(5);
            //print(s:"\cF\n", d:pforward, s:"\cS\n", d:pstamina ,s:"\cR\n", d:preload, s:"\cI\n", d:sprint, s:"\cA\n", d:aiming);
         }
         else {
            TakeActorInventory(1000 + PlayerNumber(),"Forward", 1);
            TakeActorInventory(1000 + PlayerNumber(),"IsSprinting", 1);
            GiveActorInventory(1000 + PlayerNumber(),"DontSprint", 1);
            Delay(5);
            SetActorProperty(1000 + PlayerNumber(), APROP_SPEED, 1.0);
            GiveActorInventory(1000 + PlayerNumber(),"SprintCounter", 1);
            //print(s:"\cF\n", d:pforward, s:"\cS\n", d:pstamina ,s:"\cR\n", d:preload, s:"\cI\n", d:sprint, s:"\cA\n", d:aiming);
         }
      }
   }


The DECORATE:

Code: Select allExpand view
ACTOR IsSprinting : Inventory
{
   -InvBar
   +Inventory.IgnoreSkill
   Inventory.MaxAmount 1
}

ACTOR SprintAim : Inventory
{
   -InvBar
   +Inventory.IgnoreSkill
   Inventory.MaxAmount 1
}

ACTOR DontSprint : Inventory
{
   -InvBar
   +Inventory.IgnoreSkill
   Inventory.MaxAmount 1
}

ACTOR Forward : Inventory
{
   -InvBar
   +Inventory.IgnoreSkill
   Inventory.MaxAmount 1
}

ACTOR SprintCounter : Inventory
{
   -InvBar
   +Inventory.IgnoreSkill
   Inventory.MaxAmount 40
}

ACTOR Sprint : CustomInventory
{
    -InvBar
    +Inventory.IgnoreSkill
   Inventory.MaxAmount 1
   Inventory.Amount 1
    States
    {
    Use:
        TNT1 A 0 A_GiveInventory("IsSprinting",1)
      TNT1 A 0 A_GiveInventory("SprintCancel",1)
        Fail
    }
}

ACTOR SprintCancel : CustomInventory
{
   -InvBar
    +Inventory.IgnoreSkill
   Inventory.MaxAmount 1
   Inventory.Amount 1
    States
    {
    Use:
        TNT1 A 0 A_TakeInventory("IsSprinting",1)
      TNT1 A 0 A_GiveInventory("Sprint",1)
        Fail
    }
}


And the KEYCONF:

Code: Select allExpand view
AddKeySection "Mod Settings" SprintStuff
AddMenuKey "Sprint" +sprinting

Alias +sprinting "use Sprint"
Alias -sprinting "use SprintCancel"

Bind LeftShift sprinting


And finally, an example of a weapon using this system, an M1 Garand:

Code: Select allExpand view
Actor M1Aiming : Inventory
{
inventory.maxamount 1
}

Actor M1Reloading : Inventory
{
inventory.maxamount 1
}

Actor M1ReloadingA : Inventory
{
inventory.maxamount 1
}

ACTOR M1Loaded : Ammo
{
 Inventory.MaxAmount 8
 Inventory.Icon "M1ICO0"
 +IGNORESKILL
}

ACTOR M1 : Weapon replaces BFG9000
{
   Weapon.SelectionOrder 1902
   Weapon.SlotNumber 7
   Weapon.AmmoUse 1
   Weapon.AmmoGive2 1
   Weapon.AmmoType "M1Loaded"
   Weapon.AmmoType2 "M1Clip"
   Weapon.AmmoUse2 0
   Weapon.BobRangeX 0.3
   Weapon.BobRangeY 0.5
   Weapon.BobStyle InverseSmooth
   Weapon.BobSpeed 0.6
   AttackSound "sounds/M1/fire"
   Inventory.PickupSound "sounds/M1/pickup"
   +WEAPON.NOAUTOFIRE
   +WEAPON.NOAUTOAIM
   +WEAPON.NOALERT
   +WEAPON.AMMO_OPTIONAL
   +IGNORESKILL
   Scale 0.2
   Inventory.Pickupmessage "You picked up an M1 Garand rifle."
   States
   {
   Ready:
         TNT1 A 0 A_JumpIfInventory("M1Aiming",1, "Ready2")
      TNT1 A 0 A_JumpIfInventory("IsSprinting", 1, "Sprinting")
      TNT1 A 0 A_JumpIfInventory("M1Loaded",1, "ReadyNoReload")
      M1GG A 1 A_WeaponReady (WRF_ALLOWRELOAD)
      Loop
   ReadyNoSprint:
         TNT1 A 0 A_JumpIfInventory("M1Aiming",1, "Ready2")
      TNT1 A 0 A_JumpIfInventory("SprintCounter", 1, "Ready")
      TNT1 A 0 A_JumpIfInventory("M1Loaded",1, "ReadyNoReload")
      M1GG A 1 A_WeaponReady (WRF_ALLOWRELOAD)
      Loop
   SprintAbort:
      M1GG A 1 A_WeaponReady (WRF_ALLOWRELOAD)
      Goto Ready
   Sprinting:
      TNT1 A 0 A_JumpIfInventory("DontSprint",1, "SprintAbort")
      TNT1 A 0 A_JumpIfInventory("M1Aiming",1, "Ready2")
      M1SP ABCDEF 1
   SprintLoop:
      //TNT1 A 0 A_TakeInventory("SprintCounter", 1)
      M1SR ABCDEFGHIJKLMNO 1
      M1SR ONMLKJIHGFEDCB 1
      TNT1 A 0 A_JumpIfInventory("IsSprinting", 1, "SprintLoop")
   SprintEnd:
      TNT1 A 0 A_TakeInventory("IsSprinting", 1)
      M1SP FEDCBA 1
      Goto Ready
   ReadyNoReload:
         TNT1 A 0 A_JumpIfInventory("M1Aiming",1, "Ready2")
      TNT1 A 0 A_JumpIfInventory("IsSprinting", 1, "Sprinting")
      M1GG A 1 A_WeaponReady
      Loop
   Ready2:
      TNT1 A 0 A_JumpIfInventory("IsSprinting",1, "Unaim")
      TNT1 A 0 A_JumpIfInventory("M1Loaded",1, "Ready2NoReload")
      M1AG A 1 A_WeaponReady (WRF_ALLOWRELOAD)
      Loop
   Ready2NoReload:
      TNT1 A 0 A_JumpIfInventory("IsSprinting",1, "Unaim")
      M1AG A 1 A_WeaponReady
      Loop
   DeselectUnaim:
      M1AZ GFEDC 1
      TNT1 A 0 A_ZoomFactor(1.0)
      M1AZ BA 1
      TNT1 A 0 A_Takeinventory("M1Aiming",1)
      TNT1 A 0 A_Takeinventory("SprintAim",1)
      TNT1 A 0 A_Takeinventory("M1Reloading",1)
   Deselect:
      TNT1 A 0 A_JumpIfInventory("M1Aiming",1, "DeselectUnaim")
      M1GG A 1 A_Lower
      Loop
   Select:
      M1GG A 1 A_Raise
      Loop
   Fire:
      TNT1 A 0 A_JumpIfInventory("IsSprinting",1, "Sprinting")
      TNT1 A 0 A_JumpIfInventory("M1PingCounter",7,"FirePing")
      TNT1 A 0 A_JumpIfInventory("M1Aiming",1,"FireAiming")
      TNT1 A 0 A_JumpIfNoAmmo("Dryfire")
      TNT1 A 0 A_GiveInventory("M1PingCounter", 1)
      TNT1 A 0 A_GunFlash
      M1GF A 1 A_FireBullets (1, 1, -1, random(50,75), "BulletPuff")
      M1GF B 1 A_AlertMonsters
      M1GF B 0 A_SetPitch(pitch - 6.5)
      M1GF C 1 A_SetPitch(pitch - 4.0)
      M1GF D 1 A_SetPitch(pitch - 2.0)
      M1GF E 1 A_SetPitch(pitch - 1.0)
      M1GF F 1 A_SetPitch(pitch - 0.75)
      M1GF G 1 A_WeaponReady
      M1GF G 0 A_SetPitch(pitch - 0.5)
      M1GF H 1 A_WeaponReady
      M1GF H 0 A_SetPitch(pitch - 0.25)
      M1GF I 1 A_WeaponReady
      M1GF I 0 A_SetPitch(pitch + 0.25)
      M1GF J 1 A_WeaponReady
      M1GF J 0 A_SetPitch(pitch + 0.5)
      M1GF K 1 A_WeaponReady
      M1GF K 0 A_SetPitch(pitch + 1.0)
      M1GF L 1 A_WeaponReady
      M1GF L 0 A_SetPitch(pitch + 2.0)
      Goto Ready
   FireAiming:
      TNT1 A 0 A_JumpIfInventory("IsSprinting",1, "Unaim")
      TNT1 A 0 A_JumpIfInventory("M1PingCounter",7,"FireAimingPing")
      TNT1 A 0 A_JumpIfNoAmmo("DryfireAiming")
      TNT1 A 0 A_GiveInventory("M1PingCounter", 1)
      TNT1 A 0 A_GunFlash
      M1AF A 1 A_FireBullets (0.25, 0.25, -1, random(50,75), "BulletPuff")
      M1AF B 1 A_AlertMonsters
      M1AF B 0 A_SetPitch(pitch - 4.5)
      M1AF C 1 A_SetPitch(pitch - 2.5)
      M1AF D 1 A_SetPitch(pitch - 1.0)
      M1AF E 1 A_SetPitch(pitch - 0.5)
      M1AF F 1 A_SetPitch(pitch - 1.0)
      M1AF G 1 A_WeaponReady
      M1AF G 0 A_SetPitch(pitch - 0.5)
      M1AF H 1 A_WeaponReady
      M1AF H 0 A_SetPitch(pitch - 0.25)
      M1AF I 1 A_WeaponReady
      M1AF I 0 A_SetPitch(pitch + 0.25)
      M1AF J 1 A_WeaponReady
      M1AF J 0 A_SetPitch(pitch + 0.5)
      M1AF K 1 A_WeaponReady
      M1AF K 0 A_SetPitch(pitch + 1.0)
      M1AF L 1 A_WeaponReady
      M1AF L 0 A_SetPitch(pitch + 2.0)
      Goto Ready
   FirePing:
      TNT1 A 0 A_JumpIfInventory("M1Aiming",1,"FireAimingPing")
      TNT1 A 0 A_JumpIfNoAmmo("Dryfire")
      TNT1 A 0 A_TakeInventory("M1PingCounter", 999)
      TNT1 A 0 A_GunFlash
      TNT1 A 0 A_PlaySound("sounds/M1/ping", 6)
      M1GF A 1 A_FireBullets (1, 1, -1, random(50,75), "BulletPuff")
      M1GF B 1 A_AlertMonsters
      M1GF B 0 A_SetPitch(pitch - 8.0)
      M1GF C 1 A_SetPitch(pitch - 4.0)
      M1GF D 1 A_SetPitch(pitch - 2.0)
      M1GF E 1 A_SetPitch(pitch - 1.0)
      M1GF F 1 A_SetPitch(pitch - 0.75)
      M1GF G 1 A_WeaponReady
      M1GF G 0 A_SetPitch(pitch - 0.5)
      M1GF H 1 A_WeaponReady
      M1GF H 0 A_SetPitch(pitch - 0.25)
      M1GF I 1 A_WeaponReady
      M1GF I 0 A_SetPitch(pitch + 0.25)
      M1GF J 1 A_WeaponReady
      M1GF J 0 A_SetPitch(pitch + 0.5)
      M1GF K 1 A_WeaponReady
      M1GF K 0 A_SetPitch(pitch + 1.0)
      M1GF L 1 A_WeaponReady
      M1GF L 0 A_SetPitch(pitch + 2.0)
      Goto Ready
   FireAimingPing:
      TNT1 A 0 A_JumpIfNoAmmo("DryfireAiming")
      TNT1 A 0 A_GunFlash
      TNT1 A 0 A_TakeInventory("M1PingCounter", 999)
      TNT1 A 0 A_PlaySound("sounds/M1/ping", 6)
      M1AF A 1 A_FireBullets (0.25, 0.25, -1, random(50,75), "BulletPuff")
      M1AF B 1 A_AlertMonsters
      M1AF B 0 A_SetPitch(pitch - 5.5)
      M1AF C 1 A_SetPitch(pitch - 2.5)
      M1AF D 1 A_SetPitch(pitch - 1.0)
      M1AF E 1 A_SetPitch(pitch - 0.5)
      M1AF F 1 A_SetPitch(pitch - 1.0)
      M1AF G 1 A_WeaponReady
      M1AF G 0 A_SetPitch(pitch - 0.5)
      M1AF H 1 A_WeaponReady
      M1AF H 0 A_SetPitch(pitch - 0.25)
      M1AF I 1 A_WeaponReady
      M1AF I 0 A_SetPitch(pitch + 0.25)
      M1AF J 1 A_WeaponReady
      M1AF J 0 A_SetPitch(pitch + 0.5)
      M1AF K 1 A_WeaponReady
      M1AF K 0 A_SetPitch(pitch + 1.0)
      M1AF L 1 A_WeaponReady
      M1AF L 0 A_SetPitch(pitch + 2.0)
      Goto Ready
   AltFire:   
      TNT1 A 0 A_JumpIfInventory("M1Aiming",1,"Unaim")
      TNT1 A 0 A_Giveinventory("SprintAim",1)
      TNT1 A 0 A_Giveinventory("M1Aiming",1)
      M1AZ AB 1
      TNT1 A 0 A_ZoomFactor(3.0)
      M1AZ CDEFG 1
      Goto Ready2
   DryfireAiming:
      TNT1 A 0 A_PlaySound("sounds/M1/dryfire")
      M1AF JIK 1
   ReloadAiming:
      TNT1 A 0 A_JumpIfInventory("M1Loaded", 8, 2)
      TNT1 A 0 A_JumpIfInventory("M1Clip", 1, "ReloadContinue")
      M1AG A 1 A_WeaponReady(WRF_NOFIRE)
      Goto Ready2
   Dryfire:
      TNT1 A 0 A_PlaySound("sounds/M1/dryfire")
      M1GF HIJ 1
   Reload:
      TNT1 A 0 A_JumpIfInventory("M1Aiming",1,"ReloadAiming")
      TNT1 A 0 A_JumpIfInventory("M1Loaded", 8, 2)
      TNT1 A 0 A_JumpIfInventory("M1Clip", 1, "ReloadContinue")
      M1GG A 1 A_WeaponReady(WRF_NOFIRE)
      Goto Ready
   ReloadContinue:
      TNT1 A 0 A_Giveinventory("IsReloading",1)
      TNT1 A 0 A_Giveinventory("M1Reloading",1)      
      TNT1 A 0 A_JumpIfInventory("M1Aiming",1,"Unaim")
      TNT1 A 0 A_TakeInventory("M1PingCounter", 999)
      M1GR ABCDEFGHIJKLMNOPQRSTUVWXY 1
      M1GR Z 1 A_PlaySound("sounds/M1/reload")
      M1GS ABCDEFGHIJKLMNOPQRS 1
   ReloadLoop:
      TNT1 A 0 A_TakeInventory("M1Clip", 1)
      TNT1 A 0 A_GiveInventory("M1Loaded", 8)
      Goto ReloadFinish
   ReloadFinish:
      M1GS TUVWXYZ 2
      M1GT ABCDEFGHIJKLMNOPQRSTUVWXYZ 1
      M1GU ABCDE 1
      TNT1 A 0 A_Takeinventory("M1Reloading",1)
      TNT1 A 0 A_Takeinventory("IsReloading",1)
      Goto Ready
   Unaim:
      M1AZ GFEDC 1
      TNT1 A 0 A_ZoomFactor(1.0)
      M1AZ BA 1
      TNT1 A 0 A_Takeinventory("M1Aiming",1)
      TNT1 A 0 A_Takeinventory("SprintAim",1)
      TNT1 A 0 A_JumpIfInventory("M1Reloading",1,"Reload")
      TNT1 A 0 A_JumpIfInventory("IsSprinting",1,"Sprinting")
      Goto Ready
   Flash:
      TNT1 A 1 Bright A_Light2
      TNT1 A 1 Bright A_Light1
      Goto LightDone
      TNT1 A 1 Bright A_Light2
      TNT1 A 1 Bright A_Light1
      Goto LightDone
    Spawn:
      M1GP A -1
      Stop
   }
}
Last edited by TheRailgunner on Wed Nov 27, 2013 3:28 am, edited 1 time in total.
User avatar
TheRailgunner
Don't let fascism win. Not in the US, or anywhere in the world.
 
Joined: 09 Jul 2013

Re: [Resource] ACS-based limited sprint system

Postby The Zombie Killer » Tue Nov 26, 2013 11:31 pm

The code wrote:// Sprint system courtesy of revo794 and MagSigmaX

If you're using the sprint system from DoomField, then I'd just like to point out that I did the main code for that.
I don't actually care if I'm credited or not, just thought I'd letcha know. (of course, this is only if you used that sprint system)

Oh and by the way, this code:
Code: Select allExpand view
#define S_Sprint 2

Isn't needed :wink:
User avatar
The Zombie Killer
King of the Kangaroos
 
Joined: 14 Jul 2011
Location: Gold Coast, Queensland, Australia
Discord: Zombie#1795

Re: [Resource] ACS-based limited sprint system

Postby TheRailgunner » Wed Nov 27, 2013 12:21 am

The Zombie Killer wrote:
The code wrote:// Sprint system courtesy of revo794 and MagSigmaX

If you're using the sprint system from DoomField, then I'd just like to point out that I did the main code for that.
I don't actually care if I'm credited or not, just thought I'd letcha know. (of course, this is only if you used that sprint system)

Oh and by the way, this code:
Code: Select allExpand view
#define S_Sprint 2

Isn't needed :wink:


Yes I am, and I will update the post accordingly soon. On that note, if you release forward but continue to hold Shift/Sprint afterwards, the player will not stop sprinting. Is there a way to fix this?
User avatar
TheRailgunner
Don't let fascism win. Not in the US, or anywhere in the world.
 
Joined: 09 Jul 2013

Re: [Resource] ACS-based limited sprint system

Postby The Zombie Killer » Wed Nov 27, 2013 1:14 am

Yes, just add another check to the ACS for if the player is still pressing the forward key.
You'll have to add another inventory check, or you could use ACS to enable and disable the sprinting, which would probably make things easier.
I'll see if I can rewrite some of the code to show you an example soon
User avatar
The Zombie Killer
King of the Kangaroos
 
Joined: 14 Jul 2011
Location: Gold Coast, Queensland, Australia
Discord: Zombie#1795

Re: [Resource] ACS-based limited sprint system

Postby TheRailgunner » Wed Nov 27, 2013 3:29 am

The Zombie Killer wrote:Yes, just add another check to the ACS for if the player is still pressing the forward key.
You'll have to add another inventory check, or you could use ACS to enable and disable the sprinting, which would probably make things easier.
I'll see if I can rewrite some of the code to show you an example soon


I fixed it by having the Forward script require the player to have stamina before giving him/her "Forward" (hence disabling sprint correctly if the player isn't moving, moves and then stops, or if he/she runs out of stamina/sprint counters).
User avatar
TheRailgunner
Don't let fascism win. Not in the US, or anywhere in the world.
 
Joined: 09 Jul 2013

Re: [Resource] ACS-based limited sprint system

Postby The Zombie Killer » Wed Nov 27, 2013 3:36 am

Good to know that you ended up fixing it. If you still want to have a look, here's what I ended up with:
ACS:
Code: Select allExpand view
// ACS
#library "sprint"
#include "zcommon.acs"

// Defines
#define PLRCOUNT 8

// Variables
int pStamina[PLRCOUNT];
int pSpeed[PLRCOUNT];

// Scripts
Script "Sprint" ENTER
{
   int keyPress, playerNum, maxStamina;
   playerNum = PlayerNumber();
   maxStamina = 40;
   pStamina[playerNum] = 40;
   While (true)
   {
      keyPress = GetPlayerInput(-1, INPUT_BUTTONS);
      if ((keyPress & BT_SPEED) && (pStamina[playerNum] > 0) && (keyPress & BT_FORWARD))
      {
         pSpeed[playerNum] = 2.8;
         pStamina[playerNum]--;
      }
      if ((keyPress & BT_SPEED) && (pStamina[playerNum] == 0))
         pSpeed[playerNum] = 1.0;
      else if (!(keyPress & BT_SPEED))
      {
         pSpeed[playerNum] = 1.0;
         if (pStamina[playerNum] < maxStamina)
            pStamina[playerNum]++;
      }
      Print(i:pStamina[playerNum]);
      SetActorProperty(0, APROP_Speed, pSpeed[playerNum]);
      Delay(5);
   }
}

// Functions


Decorate (player class):
Code: Select allExpand view
// Decorate
ACTOR NewDoomPlayer : DoomPlayer replaces DoomPlayer
{
   Player.ForwardMove 1, 0.5
   Player.SideMove 1, 0.5
}
User avatar
The Zombie Killer
King of the Kangaroos
 
Joined: 14 Jul 2011
Location: Gold Coast, Queensland, Australia
Discord: Zombie#1795

Re: [Resource] ACS-based limited sprint system

Postby Devianteist » Sat Sep 19, 2020 4:44 pm

Hey everybody, been a while.

I'm trying to figure out how to slow down the speed of the sprint, and I'm assuming it's APROP_SPEED in the ACS, but I wanted to get some confirmation on that beforehand.

I also was wondering if anyone had any idea how to temporarily "stun" the player each time they took a "step" while sprinting, to give them an additional amount of weight.
User avatar
Devianteist
Dev, resident lurking user.
 
Joined: 24 Sep 2014
Location: Creating a SPACE HULK conversion!
Discord: #0561

Re: [Resource] ACS-based limited sprint system

Postby TheRailgunner » Mon Sep 21, 2020 10:29 pm

Devianteist wrote:Hey everybody, been a while.

I'm trying to figure out how to slow down the speed of the sprint, and I'm assuming it's APROP_SPEED in the ACS, but I wanted to get some confirmation on that beforehand.

I also was wondering if anyone had any idea how to temporarily "stun" the player each time they took a "step" while sprinting, to give them an additional amount of weight.


It is APROP_SPEED. It mainly works by having the player's Forward/SideMove speed set to 0.5 (last I checked - I'm using a limitless sprint variant of it with an automatic sprint option for Malice, which has it set to 0.4).

If you want to have the speed fluctuate to give the appearance of actual stepping, maybe try something like this (actual timing, speed values, and all other sort of nonsense is open to adjustment):

Code: Select allExpand view
Script "S_Sprint" ENTER {
   int keyPress = 0;
   int sprint = 0;
   int aiming = 0;
   int pstamina = 0;
   int preload = 0;
   int pforward = 0;
   //int pslot5 = 0;
   int velocity = GetActorVelX(1000 + PlayerNumber());
   Thing_ChangeTID(0, 1000 + PlayerNumber());
   While(1) {
      GiveActorInventory(1000 + PlayerNumber(),"Sprint", 1);
      GiveActorInventory(1000 + PlayerNumber(),"SprintCancel", 1);
      sprint = CheckActorInventory(1000 + PlayerNumber(),"IsSprinting");
      aiming = CheckActorInventory(1000 + PlayerNumber(),"SprintAim");
      pstamina = CheckActorInventory(1000 + PlayerNumber(),"SprintCounter");
      preload = CheckActorInventory(1000 + PlayerNumber(),"IsReloading");
      pforward = CheckActorInventory(1000 + PlayerNumber(),"Forward");
      //pslot5 = CheckActorInventory(1000 + PlayerNumber(),"HoldingSlot5Weapon");
      keyPress = GetPlayerInput(-1, INPUT_BUTTONS);
      Delay(1);
         if(sprint==1 && pstamina >> 0) {
            if(keyPress != BT_BACK && pforward==1 && preload==0 && aiming==0) {
               TakeInventory("DontSprint", 1);
               SetActorProperty(1000 + PlayerNumber(), APROP_SPEED, 1.8);
               TakeActorInventory(1000 + PlayerNumber(),"SprintCounter", 1);
               Delay(5);
               SetActorProperty(1000 + PlayerNumber(), APROP_SPEED, 1.3);
               TakeActorInventory(1000 + PlayerNumber(),"SprintCounter", 1);
               Delay(4);
               SetActorProperty(1000 + PlayerNumber(), APROP_SPEED, 0.9);
               TakeActorInventory(1000 + PlayerNumber(),"SprintCounter", 1);
               Delay(4);
               SetActorProperty(1000 + PlayerNumber(), APROP_SPEED, 0.6);
               TakeActorInventory(1000 + PlayerNumber(),"SprintCounter", 1);
               Delay(4);
               SetActorProperty(1000 + PlayerNumber(), APROP_SPEED, 0.3);
               TakeActorInventory(1000 + PlayerNumber(),"SprintCounter", 1);
               Delay(10);
               SetActorProperty(1000 + PlayerNumber(), APROP_SPEED, 0.6);
               TakeActorInventory(1000 + PlayerNumber(),"SprintCounter", 1);
               Delay(4);
               SetActorProperty(1000 + PlayerNumber(), APROP_SPEED, 1.3);
               TakeActorInventory(1000 + PlayerNumber(),"SprintCounter", 1);
               Delay(4);
               //print(s:"\cF\n", d:pforward, s:"\cS\n", d:pstamina ,s:"\cR\n", d:preload, s:"\cI\n", d:sprint, s:"\cA\n", d:aiming);
            }
            else {
               SetActorProperty(1000 + PlayerNumber(), APROP_SPEED, 0.9);
               TakeActorInventory(1000 + PlayerNumber(),"SprintCounter", 1);
               Delay(5);
               SetActorProperty(1000 + PlayerNumber(), APROP_SPEED, 0.65);
               TakeActorInventory(1000 + PlayerNumber(),"SprintCounter", 1);
               Delay(4);
               SetActorProperty(1000 + PlayerNumber(), APROP_SPEED, 0.45);
               TakeActorInventory(1000 + PlayerNumber(),"SprintCounter", 1);
               Delay(4);
               SetActorProperty(1000 + PlayerNumber(), APROP_SPEED, 0.3);
               TakeActorInventory(1000 + PlayerNumber(),"SprintCounter", 1);
               Delay(4);
               SetActorProperty(1000 + PlayerNumber(), APROP_SPEED, 0.15);
               TakeActorInventory(1000 + PlayerNumber(),"SprintCounter", 1);
               Delay(10);
               SetActorProperty(1000 + PlayerNumber(), APROP_SPEED, 0.3);
               TakeActorInventory(1000 + PlayerNumber(),"SprintCounter", 1);
               Delay(4);
               SetActorProperty(1000 + PlayerNumber(), APROP_SPEED, 0.65);
               TakeActorInventory(1000 + PlayerNumber(),"SprintCounter", 1);
               Delay(4);
               //print(s:"\cF\n", d:pforward, s:"\cS\n", d:pstamina ,s:"\cR\n", d:preload, s:"\cI\n", d:sprint, s:"\cA\n", d:aiming);
            }
         }
         else if(sprint==1 && pstamina==0){
            TakeActorInventory(1000 + PlayerNumber(),"Forward", 1);
            TakeActorInventory(1000 + PlayerNumber(),"IsSprinting", 1);
            GiveActorInventory(1000 + PlayerNumber(),"DontSprint", 1);
            SetActorProperty(1000 + PlayerNumber(), APROP_SPEED, 0.9);
            TakeActorInventory(1000 + PlayerNumber(),"SprintCounter", 1);
            Delay(5);
            SetActorProperty(1000 + PlayerNumber(), APROP_SPEED, 0.65);
            TakeActorInventory(1000 + PlayerNumber(),"SprintCounter", 1);
            Delay(4);
            SetActorProperty(1000 + PlayerNumber(), APROP_SPEED, 0.45);
            TakeActorInventory(1000 + PlayerNumber(),"SprintCounter", 1);
            Delay(4);
            SetActorProperty(1000 + PlayerNumber(), APROP_SPEED, 0.3);
            TakeActorInventory(1000 + PlayerNumber(),"SprintCounter", 1);
            Delay(4);
            SetActorProperty(1000 + PlayerNumber(), APROP_SPEED, 0.15);
            TakeActorInventory(1000 + PlayerNumber(),"SprintCounter", 1);
            Delay(10);
            SetActorProperty(1000 + PlayerNumber(), APROP_SPEED, 0.3);
            TakeActorInventory(1000 + PlayerNumber(),"SprintCounter", 1);
            Delay(4);
            SetActorProperty(1000 + PlayerNumber(), APROP_SPEED, 0.65);
            TakeActorInventory(1000 + PlayerNumber(),"SprintCounter", 1);
            Delay(4);
            //print(s:"\cF\n", d:pforward, s:"\cS\n", d:pstamina ,s:"\cR\n", d:preload, s:"\cI\n", d:sprint, s:"\cA\n", d:aiming);
         }
         else {
            TakeActorInventory(1000 + PlayerNumber(),"Forward", 1);
            TakeActorInventory(1000 + PlayerNumber(),"IsSprinting", 1);
            GiveActorInventory(1000 + PlayerNumber(),"DontSprint", 1);
            SetActorProperty(1000 + PlayerNumber(), APROP_SPEED, 0.9);
            GiveActorInventory(1000 + PlayerNumber(),"SprintCounter", 1);
            Delay(5);
            SetActorProperty(1000 + PlayerNumber(), APROP_SPEED, 0.65);
            GiveActorInventory(1000 + PlayerNumber(),"SprintCounter", 1);
            Delay(4);
            SetActorProperty(1000 + PlayerNumber(), APROP_SPEED, 0.45);
            GiveActorInventory(1000 + PlayerNumber(),"SprintCounter", 1);
            Delay(4);
            SetActorProperty(1000 + PlayerNumber(), APROP_SPEED, 0.3);
            GiveActorInventory(1000 + PlayerNumber(),"SprintCounter", 1);
            Delay(4);
            SetActorProperty(1000 + PlayerNumber(), APROP_SPEED, 0.15);
            GiveActorInventory(1000 + PlayerNumber(),"SprintCounter", 1);
            Delay(10);
            SetActorProperty(1000 + PlayerNumber(), APROP_SPEED, 0.3);
            GiveActorInventory(1000 + PlayerNumber(),"SprintCounter", 1);
            Delay(4);
            SetActorProperty(1000 + PlayerNumber(), APROP_SPEED, 0.65);
            GiveActorInventory(1000 + PlayerNumber(),"SprintCounter", 1);
            Delay(4);
            //print(s:"\cF\n", d:pforward, s:"\cS\n", d:pstamina ,s:"\cR\n", d:preload, s:"\cI\n", d:sprint, s:"\cA\n", d:aiming);
         }
      }
   }


I kind of whipped this up in the confines of this post, so I don't know how well it'll run. I'll get back to you on this one sometime soon.
User avatar
TheRailgunner
Don't let fascism win. Not in the US, or anywhere in the world.
 
Joined: 09 Jul 2013

Re: [Resource] ACS-based limited sprint system

Postby Devianteist » Tue Sep 22, 2020 10:30 pm

When I get an hour or so to test this out I'll give it a whirl. Gearing up for my buddy's wedding is a lot more stressful than I thought it'd be.
User avatar
Devianteist
Dev, resident lurking user.
 
Joined: 24 Sep 2014
Location: Creating a SPACE HULK conversion!
Discord: #0561

Re: [Resource] ACS-based limited sprint system

Postby iSpook » Sat Oct 24, 2020 5:58 am

Question: I'm using TZK's script. How would I make it so I can display the stamina counter as a hud element?
User avatar
iSpook
What is this, I don't even.
 
Joined: 05 Feb 2006
Location: In the middle of Stephen King Territory


Return to Resources

Who is online

Users browsing this forum: No registered users and 2 guests