Slow down player if he selects specific weapon?
Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. This forum is archived - please use this set of forums to ask new questions.
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. This forum is archived - please use this set of forums to ask new questions.
- Tormentor667
- Posts: 13556
- Joined: Wed Jul 16, 2003 3:52 am
- Preferred Pronouns: He/Him
- Operating System Version (Optional): Windows 11
- Graphics Processor: nVidia (Modern GZDoom)
- Location: Germany
- Contact:
Slow down player if he selects specific weapon?
Is it possible to half the player speed if he selects a specific weapon through the weapon actor itself? If yes, how?
Re: Slow down player if he selects specific weapon?
You could make the weapon modify player's speed in the select-state, by using A_SetSpeed function, or just { Speed = x; } in ZScript.
Another option is to make the weapon give the player custom speed-modifying powerups.
Another option is to make the weapon give the player custom speed-modifying powerups.
- 22alpha22
- Posts: 308
- Joined: Fri Feb 21, 2014 5:04 pm
- Graphics Processor: nVidia with Vulkan support
- Location: Montana, USA
Re: Slow down player if he selects specific weapon?
There are a couple ways you can do it that I know of. One requires some ACS, the other does not.
Method 1:
In the weapon's "Select" state, have it call a global script that will reduce the player's speed property to whatever value you want. In the "Deselect" state, have it call a script which will return the player's speed to normal.
Example taken from my Delta Force mod:
Create a powerup that inherits from "PowerSpeed" and have the weapon give the player the powerup in the weapon's "Select" state and take the powerup in the "Deselect" state.
Example:
Disregard method 1, D2JK's method is simpler.
Method 1:
In the weapon's "Select" state, have it call a global script that will reduce the player's speed property to whatever value you want. In the "Deselect" state, have it call a script which will return the player's speed to normal.
Example taken from my Delta Force mod:
Spoiler:Method 2:
Create a powerup that inherits from "PowerSpeed" and have the weapon give the player the powerup in the weapon's "Select" state and take the powerup in the "Deselect" state.
Example:
Spoiler:EDIT:
Disregard method 1, D2JK's method is simpler.
- Tormentor667
- Posts: 13556
- Joined: Wed Jul 16, 2003 3:52 am
- Preferred Pronouns: He/Him
- Operating System Version (Optional): Windows 11
- Graphics Processor: nVidia (Modern GZDoom)
- Location: Germany
- Contact:
Re: Slow down player if he selects specific weapon?
Tried it but doesn't work:D2JK wrote:You could make the weapon modify player's speed in the select-state, by using A_SetSpeed function, or just { Speed = x; } in ZScript.
Code: Select all
TNT1 A 0 A_SetSpeed(0.1)
Code: Select all
TNT1 A 0 A_SetSpeed(2)
-
- Posts: 5043
- Joined: Sun Nov 14, 2010 12:59 am
Re: Slow down player if he selects specific weapon?
Does the following code work (for me, it does):
Code: Select all
actor TestShotgun : Shotgun
{
Weapon.SlotNumber 0
States
{
Select:
SHTG A 0 A_SetSpeed(0.1)
SHTG A 1 A_Raise
Wait
Deselect:
SHTG A 0 A_SetSpeed(1.0)
SHTG A 1 A_Lower
Wait
}
}
- Tormentor667
- Posts: 13556
- Joined: Wed Jul 16, 2003 3:52 am
- Preferred Pronouns: He/Him
- Operating System Version (Optional): Windows 11
- Graphics Processor: nVidia (Modern GZDoom)
- Location: Germany
- Contact:
Re: Slow down player if he selects specific weapon?
Strange, it works on normal Doom but it doesn't work on Blade of Agony... does it have something to do with the fact that the player class has been externalized into a ZScript variant?
Code: Select all
class BoAPlayer : PlayerPawn
{
double user_crouch;
double user_ScaleY;
int user_visibility;
int suspicion;
Default
{
+DONTBLAST // avoid kick's blast effect while kicking at walls
+THRUSPECIES // Needed for swimming through SharkBlockers.
Species "Player";
Player.MaxHealth 100; // Needed for improved vitality serum
Player.InvulnerabilityMode "reflective";
Player.StartItem "KnifeSilent";
Player.StartItem "TrenchShotgunLoaded",8;
Player.StartItem "Browning5Loaded",4;
Player.StartItem "MP40Loaded",32;
Player.StartItem "G43Loaded",10;
Player.StartItem "Walther9mmLoaded",8;
Player.StartItem "Luger9mmLoaded",8;
Player.StartItem "StenLoaded",32;
Player.StartItem "Kar98kLoaded",5;
Player.StartItem "PyrolightLoaded",25;
Player.StartItem "PanzerschreckLoaded";
Player.StartItem "AstroShotgunLoaded",8;
Player.StartItem "AstroRocketLauncherLoaded",5;
Player.StartItem "AstroChaingunLoaded",30;
Player.StartItem "Stamina", 100;
Player.ViewHeight 56;
Player.AttackZOffset 24;
Player.DisplayName "William Blazkowicz";
Player.CrouchSprite "PLYC";
Player.SideMove 1.0,0.5;
Player.ForwardMove 1.0,0.5;
Player.ViewBob 0.44;
Player.WeaponSlot 1, "KnifeSilent", "Shovel", "Firebrand", "AstrosteinMelee";
Player.WeaponSlot 2, "Luger9mm", "Walther9mm";
Player.WeaponSlot 3, "TrenchShotgun", "Browning5", "AstroShotgun";
Player.WeaponSlot 4, "MP40", "Sten", "AstroChaingun";
Player.WeaponSlot 5, "Kar98k", "G43", "UMG43";
Player.WeaponSlot 6, "Pyrolight", "Nebelwerfer", "AstroRocketlauncher";
Player.WeaponSlot 7, "Panzerschreck";
Player.WeaponSlot 8, "NullWeapon";
Player.DamageScreenColor "ff ff ff", 1, "IceWater";
Player.DamageScreenColor "64 00 C8", 1, "MutantPoison";
Scale 0.65;
}
States
{
Spawn:
PLAY A 1 NoDelay {
if (user_ScaleY == 0) { user_ScaleY = Scale.Y; }
}
"####" # 0 A_JumpIfInventory("ScientistUniformToken", 1, "Spawn.Uniform");
Loop;
Spawn.Uniform:
PLSC A 1;
"####" # 0 A_Jump(256, "See");
See:
"####" AAAAAAABBBBBBBBCCCCCCCCDDDDDDDD 1 { //Check for change every tic, but still let each frame display for 8 tics (A is only 7 times here to account for the lead in frame set in other states)
user_crouch = GetCrouchFactor(AAPTR_DEFAULT);
if (CountInv("ScientistUniformToken") > 0) {
if (user_crouch < 0.75) {
return ResolveState("See.Scientist.Crouch");
} else {
Scale.Y = user_ScaleY;
return ResolveState("See.Scientist");
}
} else {
Scale.Y = user_ScaleY;
return ResolveState(null);
}
}
PLAY A 1;
Loop;
See.Scientist:
PLSC A 1;
"####" # 0 A_Jump(256, "See.Resume");
See.Scientist.Crouch:
PLYS A 1;
"####" # 0 A_Jump(256, "See.Resume");
See.Resume:
"####" AAAAAAABBBBBBBBCCCCCCCCDDDDDDDD 1 {
Scale.Y = user_ScaleY / user_crouch; //Negate crouch sprite scaling
if ((vel.x + vel.y) == 0 || GetCrouchFactor(AAPTR_DEFAULT) != user_crouch) { //Get rid of the 'running in place' effect and check if crouch state changed
if (CountInv("ScientistUniformToken") > 0) {
return ResolveState("See");
} else {
Scale.Y = user_ScaleY;
return ResolveState("Spawn");
}
} else {
return ResolveState(null);
}
}
"####" # 0 A_Jump(256, "See");
Pain:
"####" G 0 ACS_NamedExecuteWithResult("PlayerFlinch", 0);
"####" G 4 A_Pain;
"####" # 0 A_Jump(256, "Spawn");
Missile:
PLAY E 12 BRIGHT;
"####" # 0 A_Jump(256, "Spawn");
Melee:
PLAY F 6;
"####" # 0 A_Jump(256, "Missile");
Disintegrate: //here in order to transfer properly frames if needed - ozy81
"####" G 0 A_Playsound("astrostein/guard_death");
"####" G 5 A_PlayerScream;
"####" G 0 A_NoBlocking;
"####" G 0 A_SpawnItemEx("BaseLineSpawner", random(16, -16), random(16, -16), random(0, 8), 0, 0, random(1,3), 0, 129, 0);
"####" GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG 1 A_FadeOut(0.02,0);
TNT1 A -1 A_SetTranslucent(1);
Stop;
Death:
"####" H 5 A_PlayerScream;
"####" I 8;
"####" I 1 A_PlaySound("death/bjfall");
"####" J 5 A_NoBlocking;
"####" K 5;
"####" LM 2;
"####" N -1;
Stop;
Death.Fire:
TNT1 A 0 A_Jump(256,"Death.Fire.A","Death.Fire.B");
Death.Fire.A:
BURN A 5 BRIGHT Light("ITBURNS1");
"####" BC 5 BRIGHT Light("ITBURNS1") A_SpawnItemEx("FloatingCinder", random(-8,8), random(-8,8), random(0,32), 1, 0, random (1, 3), random (0, 360), SXF_TRANSFERPITCH | SXF_CLIENTSIDE, 160);
"####" D 5 BRIGHT Light("ITBURNS1") A_PlaySound("death/burning");
"####" E 5 BRIGHT Light("ITBURNS1") A_SpawnItemEx("FloatingCinder", random(-8,8), random(-8,8), random(0,32), 1, 0, random (1, 3), random (0, 360), SXF_TRANSFERPITCH | SXF_CLIENTSIDE, 160);
"####" FGHIJ 5 BRIGHT Light("ITBURNS2") A_SpawnItemEx("FloatingCinder", random(-8,8), random(-8,8), random(0,32), 1, 0, random (1, 3), random (0, 360), SXF_TRANSFERPITCH | SXF_CLIENTSIDE, 160);
"####" KLMN 5 BRIGHT Light("ITBURNS3");
"####" O 5 BRIGHT Light("ITBURNS3") A_NoBlocking;
"####" PQR 5 BRIGHT Light("ITBURNS2") A_SpawnItemEx("FloatingCinder", random(-8,8), random(-8,8), random(0,16), 1, 0, random (1, 3), random (0, 360), SXF_TRANSFERPITCH | SXF_CLIENTSIDE, 160);
"####" STU 5 BRIGHT Light("ITBURNS1") A_SpawnItemEx("FloatingCinder", random(-8,8), random(-8,8), random(0,8), 1, 0, random (1, 3), random (0, 360), SXF_TRANSFERPITCH | SXF_CLIENTSIDE, 160);
"####" V -1;
Stop;
Death.Fire.B:
NRUB A 5 BRIGHT Light("ITBURNS1");
"####" BC 5 BRIGHT Light("ITBURNS1") A_SpawnItemEx("FloatingCinder", random(-8,8), random(-8,8), random(0,32), 1, 0, random (1, 3), random (0, 360), SXF_TRANSFERPITCH | SXF_CLIENTSIDE, 160);
"####" D 5 BRIGHT Light("ITBURNS1") A_PlaySound("death/burning");
"####" E 5 BRIGHT Light("ITBURNS1") A_SpawnItemEx("FloatingCinder", random(-8,8), random(-8,8), random(0,32), 1, 0, random (1, 3), random (0, 360), SXF_TRANSFERPITCH | SXF_CLIENTSIDE, 160);
"####" FGHIJ 5 BRIGHT Light("ITBURNS2") A_SpawnItemEx("FloatingCinder", random(-8,8), random(-8,8), random(0,32), 1, 0, random (1, 3), random (0, 360), SXF_TRANSFERPITCH | SXF_CLIENTSIDE, 160);
"####" KLMN 5 BRIGHT Light("ITBURNS3");
"####" O 5 BRIGHT Light("ITBURNS3") A_NoBlocking;
"####" PQR 5 BRIGHT Light("ITBURNS2") A_SpawnItemEx("FloatingCinder", random(-8,8), random(-8,8), random(0,16), 1, 0, random (1, 3), random (0, 360), SXF_TRANSFERPITCH | SXF_CLIENTSIDE, 160);
"####" STU 5 BRIGHT Light("ITBURNS1") A_SpawnItemEx("FloatingCinder", random(-8,8), random(-8,8), random(0,8), 1, 0, random (1, 3), random (0, 360), SXF_TRANSFERPITCH | SXF_CLIENTSIDE, 160);
"####" V -1;
Stop;
}
}
-
- Posts: 5043
- Joined: Sun Nov 14, 2010 12:59 am
Re: Slow down player if he selects specific weapon?
There is the possibility of conflict. What happens if you temporarily disable this script? Does it work?
- Ozymandias81
- Posts: 2068
- Joined: Thu Jul 04, 2013 8:01 am
- Graphics Processor: nVidia with Vulkan support
- Location: Mount Olympus, Mars
- Contact:
Re: Slow down player if he selects specific weapon?
You were right Blue Shadow, thanks.