Shoot from weapon "without" player
Moderator: GZDoom Developers
Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.
Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.
Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
Shoot from weapon "without" player
Lets take a simple doom pistol. Is it possible to make it shoot without using it as player ready weapon?
- Void Weaver
- Posts: 724
- Joined: Thu Dec 18, 2014 7:15 am
- Contact:
Re: Shoot from weapon "without" player
What do you mean "make it shoot without using it as player ready weapon"? How it supposed to acts directly in game?
Do you mean doing call A_FireBullets outer of 'Fire' state or something else?
Do you mean doing call A_FireBullets outer of 'Fire' state or something else?
Re: Shoot from weapon "without" player
Execute weapon "fire" state without using them as Psprite.
- Void Weaver
- Posts: 724
- Joined: Thu Dec 18, 2014 7:15 am
- Contact:
Re: Shoot from weapon "without" player
... what about replacing fire-Psprites by other custom ones or even TNT1?
For ex.:
For ex.:
Code: Select all
ACTOR InvPistol : Pistol replaces Pistol
{
Weapon.SlotNumber 2
Weapon.SlotPriority 1
States
{
Ready:
TNT1 A 1 A_WeaponReady
Loop
Fire:
TNT1 A 4
TNT1 B 6 A_FirePistol
TNT1 C 4
TNT1 B 5 A_ReFire
Goto Ready
Flash:
TNT1 A 7 Bright A_Light1
Goto LightDone
TNT1 A 7 Bright A_Light1
Goto LightDone
}
}
Re: Shoot from weapon "without" player
Such possible in zscript without replacing actor.
I need a way, if it possible of course, to shoot from weapon directly from inventory. Like panic button to shoot from shotgun/pistol/etc without picking them up as weapon.
I need a way, if it possible of course, to shoot from weapon directly from inventory. Like panic button to shoot from shotgun/pistol/etc without picking them up as weapon.
- Void Weaver
- Posts: 724
- Joined: Thu Dec 18, 2014 7:15 am
- Contact:
Re: Shoot from weapon "without" player
Oh, seems I've got it. I guess this can be easily done at ZScript, but unfortunately I can provide only decor example.
That Shotgun can fire Missiles when alt-fire pressed at any part of Ready\Fire sequence without breaking shooting sequence or playing any RLauncher sprites:As variant instatnt attack can be called from CustomInventory item.
Btw, in a one of those threads you can also find a some useful related stuff for current task, I guess:
CustomInventory Overlays - How To?!
[Decorate] Do X if button pressed for < 0.5 s, do Y if > 0.5
That Shotgun can fire Missiles when alt-fire pressed at any part of Ready\Fire sequence without breaking shooting sequence or playing any RLauncher sprites:
Code: Select all
ACTOR AssaultShotgun : Shotgun replaces Shotgun
{
Weapon.SlotNumber 3
Weapon.SlotPriority 1
States
{
Ready:
SHTG A 1
{
A_WeaponReady(WRF_ALLOWRELOAD|WRF_ALLOWUSER#);
If(GetPlayerInput(INPUT_BUTTONS)&BT_ALTATTACK)
{A_Overlay(2,"MissileShot");Return state("");}
Else{Return state("");}
}
Loop
Fire:
SHTG A 3
{
A_WeaponReady(WRF_NOPRIMARY|WRF_ALLOWRELOAD|WRF_ALLOWUSER#);
If(GetPlayerInput(INPUT_OLDBUTTONS)&BT_ATTACK&&GetPlayerInput(INPUT_BUTTONS)&BT_ALTATTACK)
{A_Overlay(2,"MissileShot");Return state("");}
Else{Return state("");}
}
SHTG A 7
{
A_FireShotgun;
A_WeaponReady(WRF_NOPRIMARY|WRF_ALLOWRELOAD|WRF_ALLOWUSER#);
If(GetPlayerInput(INPUT_OLDBUTTONS)&BT_ATTACK&&GetPlayerInput(INPUT_BUTTONS)&BT_ALTATTACK)
{A_Overlay(2,"MissileShot");Return state("");}
Else{Return state("");}
}
SHTG BC 5
{
A_WeaponReady(WRF_NOPRIMARY|WRF_ALLOWRELOAD|WRF_ALLOWUSER#);
If(GetPlayerInput(INPUT_OLDBUTTONS)&BT_ATTACK&&GetPlayerInput(INPUT_BUTTONS)&BT_ALTATTACK)
{A_Overlay(2,"MissileShot");Return state("");}
Else{Return state("");}
}
SHTG D 4
{
A_WeaponReady(WRF_NOPRIMARY|WRF_ALLOWRELOAD|WRF_ALLOWUSER#);
If(GetPlayerInput(INPUT_OLDBUTTONS)&BT_ATTACK&&GetPlayerInput(INPUT_BUTTONS)&BT_ALTATTACK)
{A_Overlay(2,"MissileShot");Return state("");}
Else{Return state("");}
}
SHTG CB 5
{
A_WeaponReady(WRF_NOPRIMARY|WRF_ALLOWRELOAD|WRF_ALLOWUSER#);
If(GetPlayerInput(INPUT_OLDBUTTONS)&BT_ATTACK&&GetPlayerInput(INPUT_BUTTONS)&BT_ALTATTACK)
{A_Overlay(2,"MissileShot");Return state("");}
Else{Return state("");}
}
SHTG A 3
{
A_WeaponReady(WRF_NOPRIMARY|WRF_ALLOWRELOAD|WRF_ALLOWUSER#);
If(GetPlayerInput(INPUT_OLDBUTTONS)&BT_ATTACK&&GetPlayerInput(INPUT_BUTTONS)&BT_ALTATTACK)
{A_Overlay(2,"MissileShot");Return state("");}
Else{Return state("");}
}
SHTG A 7 A_ReFire
Goto Ready
AltFire:
Stop
MissileShot:
TNT1 A 8 A_GunFlash("Flash.MissileShot")
TNT1 A 0 A_TakeInventory("RocketAmmo",1)
TNT1 A 12 A_FireProjectile("Rocket",0,0)
Stop
Flash.MissileShot:
TNT1 A 3 Bright A_Light1
TNT1 A 4 Bright
TNT1 AA 4 Bright A_Light2
Goto LightDone
}
}
Code: Select all
Actor InvMissileShooter : CustomInventory
{
+INVENTORY.ALWAYSPICKUP
Inventory.MaxAmount 0
States
{
Spawn:
POSS A -1
Pickup:
TNT1 A 0 A_JumpIf(CountInv("RocketAmmo")<=0,3)
TNT1 A 0 A_TakeInventory("RocketAmmo",1)
TNT1 A 0 A_SpawnItemEx("Rocket",0,0,Height/2,cos(pitch)*20,0,-sin(pitch)*20,0,SXF_TRANSFERPITCH)
TNT1 A 0
Stop
}
}
CustomInventory Overlays - How To?!
[Decorate] Do X if button pressed for < 0.5 s, do Y if > 0.5
Last edited by Void Weaver on Thu Jul 11, 2019 10:05 pm, edited 2 times in total.
- Matt
- Posts: 9696
- Joined: Sun Jan 04, 2004 5:37 pm
- Preferred Pronouns: They/Them
- Operating System Version (Optional): Debian Bullseye
- Location: Gotham City SAR, Wyld-Lands of the Lotus People, Dominionist PetroConfederacy of Saudi Canadia
- Contact:
Re: Shoot from weapon "without" player
Can a player sprite be given to an actor that has no controlling player?
Re: Shoot from weapon "without" player
That require changing weapon code, while I need a way to do so without changing weapon code.Void Weaver wrote:Oh, seems I've got it. I guess this can be easily done at ZScript, but unfortunately I can provide only decor example.
That Shotgun can fire Missiles when alt-fire pressed at any part of Ready\Fire sequence without breaking shooting sequence or playing any RLauncher sprites:As variant instatnt attack can be called from CustomInventory item.Code: Select all
ACTOR AssaultShotgun : Shotgun replaces Shotgun { Weapon.SlotNumber 3 Weapon.SlotPriority 1 States { Ready: SHTG A 1 { A_WeaponReady(WRF_ALLOWRELOAD|WRF_ALLOWUSER#); If(GetPlayerInput(INPUT_BUTTONS)&BT_ALTATTACK) {A_Overlay(2,"MissileShot");Return state("");} Else{Return state("");} } Loop Fire: SHTG A 3 { A_WeaponReady(WRF_NOPRIMARY|WRF_ALLOWRELOAD|WRF_ALLOWUSER#); If(GetPlayerInput(INPUT_OLDBUTTONS)&BT_ATTACK&&GetPlayerInput(INPUT_BUTTONS)&BT_ALTATTACK) {A_Overlay(2,"MissileShot");Return state("");} Else{Return state("");} } SHTG A 7 { A_FireShotgun; A_WeaponReady(WRF_NOPRIMARY|WRF_ALLOWRELOAD|WRF_ALLOWUSER#); If(GetPlayerInput(INPUT_OLDBUTTONS)&BT_ATTACK&&GetPlayerInput(INPUT_BUTTONS)&BT_ALTATTACK) {A_Overlay(2,"MissileShot");Return state("");} Else{Return state("");} } SHTG BC 5 { A_WeaponReady(WRF_NOPRIMARY|WRF_ALLOWRELOAD|WRF_ALLOWUSER#); If(GetPlayerInput(INPUT_OLDBUTTONS)&BT_ATTACK&&GetPlayerInput(INPUT_BUTTONS)&BT_ALTATTACK) {A_Overlay(2,"MissileShot");Return state("");} Else{Return state("");} } SHTG D 4 { A_WeaponReady(WRF_NOPRIMARY|WRF_ALLOWRELOAD|WRF_ALLOWUSER#); If(GetPlayerInput(INPUT_OLDBUTTONS)&BT_ATTACK&&GetPlayerInput(INPUT_BUTTONS)&BT_ALTATTACK) {A_Overlay(2,"MissileShot");Return state("");} Else{Return state("");} } SHTG CB 5 { A_WeaponReady(WRF_NOPRIMARY|WRF_ALLOWRELOAD|WRF_ALLOWUSER#); If(GetPlayerInput(INPUT_OLDBUTTONS)&BT_ATTACK&&GetPlayerInput(INPUT_BUTTONS)&BT_ALTATTACK) {A_Overlay(2,"MissileShot");Return state("");} Else{Return state("");} } SHTG A 3 { A_WeaponReady(WRF_NOPRIMARY|WRF_ALLOWRELOAD|WRF_ALLOWUSER#); If(GetPlayerInput(INPUT_OLDBUTTONS)&BT_ATTACK&&GetPlayerInput(INPUT_BUTTONS)&BT_ALTATTACK) {A_Overlay(2,"MissileShot");Return state("");} Else{Return state("");} } SHTG A 7 A_ReFire Goto Ready AltFire: Stop MissileShot: TNT1 A 8 A_GunFlash("Flash.MissileShot") TNT1 A 0 A_TakeInventory("RocketAmmo",1) TNT1 A 12 A_FireProjectile("Rocket",0,0) Stop Flash.MissileShot: TNT1 A 3 Bright A_Light1 TNT1 A 4 Bright TNT1 AA 4 Bright A_Light2 Goto LightDone } }
Btw, in a one of those threads you can also find a some useful related stuff for current task, I guess:Code: Select all
Actor InvMissileShooter : CustomInventory { +INVENTORY.ALWAYSPICKUP Inventory.MaxAmount 0 States { Spawn: POSS A -1 Pickup: TNT1 A 0 A_JumpIf(CountInv("RocketAmmo")<=0,3) TNT1 A 0 A_TakeInventory("RocketAmmo",1) TNT1 A 0 A_SpawnItemEx("Rocket",0,0,Height/2,cos(pitch)*20,0,-sin(pitch)*20,0,SXF_TRANSFERPITCH) TNT1 A 0 Stop } }
CustomInventory Overlays - How To?!
[Decorate] Do X if button pressed for < 0.5 s, do Y if > 0.5
No, since psprite class nailed to playerinfo struct and you cant "deattach" it and/or create new psprite class/playerinfo struct.Matt wrote:Can a player sprite be given to an actor that has no controlling player?
Problem with weapon, that a_fireprojectile, and similar weapon functions, works only if player available. So I can change weapon state, when it lie on the ground, to "fire" and it play it states and animations, but dont actually shoot. And in inventory I cant call states of it without using it as reference to psprite.
So looks like this is impossible.
- Void Weaver
- Posts: 724
- Joined: Thu Dec 18, 2014 7:15 am
- Contact:
Re: Shoot from weapon "without" player
It's quite significant detail. AnywayApeirogon wrote:That require changing weapon code, while I need a way to do so without changing weapon code.
Give the similar item via ACS or, that's even better, write it on ACS entirely. This way doesn't bother about weapon or player actors altering.Void Weaver wrote:As variant, instatnt attack can be called from CustomInventory item.
- Matt
- Posts: 9696
- Joined: Sun Jan 04, 2004 5:37 pm
- Preferred Pronouns: They/Them
- Operating System Version (Optional): Debian Bullseye
- Location: Gotham City SAR, Wyld-Lands of the Lotus People, Dominionist PetroConfederacy of Saudi Canadia
- Contact:
Re: Shoot from weapon "without" player
Do you mean something like:Apeirogon wrote:Such possible in zscript without replacing actor.
I need a way, if it possible of course, to shoot from weapon directly from inventory. Like panic button to shoot from shotgun/pistol/etc without picking them up as weapon.
1. I am holding BFG
2. I need to shoot pistol
3. I am still holding BFG but a pistol shot comes out of me
If so, is it acceptable to replace the pistol, or do you need a solution that uses the vanilla pistol actor?
Re: Shoot from weapon "without" player
Second, vanilla BFG and vanilla pistol.
I ant to make it applicable to any weapon in general.
I ant to make it applicable to any weapon in general.
- Graf Zahl
- Lead GZDoom+Raze Developer
- Posts: 49067
- Joined: Sat Jul 19, 2003 10:19 am
- Location: Germany
Re: Shoot from weapon "without" player
To make it short: All weapon actions directly access the PlayerInfo. Good luck trying to set it up so that it works without one. Some may just work without handling ammo consumption but others will just do nothing without a player.
Re: Shoot from weapon "without" player
Not without playerinfo, without using weapon states as reference for psprite.