Shoot from weapon "without" player

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!)

Post a reply

Smilies
:D :) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :wink: :geek: :ugeek: :!: :?: :idea: :arrow: :| :mrgreen: :3: :wub: >:( :blergh:
View more smilies

BBCode is OFF
Smilies are ON

Topic review
   

Expand view Topic review: Shoot from weapon "without" player

Re: Shoot from weapon "without" player

by Apeirogon » Sun Jul 14, 2019 9:26 am

Not without playerinfo, without using weapon states as reference for psprite.

Re: Shoot from weapon "without" player

by Graf Zahl » Sat Jul 13, 2019 6:27 am

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

by Apeirogon » Sat Jul 13, 2019 1:46 am

Second, vanilla BFG and vanilla pistol.

I ant to make it applicable to any weapon in general.

Re: Shoot from weapon "without" player

by Matt » Fri Jul 12, 2019 4:17 pm

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.
Do you mean something like:

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

by Void Weaver » Fri Jul 12, 2019 4:06 pm

Apeirogon wrote:That require changing weapon code, while I need a way to do so without changing weapon code.
It's quite significant detail. Anyway
Void Weaver wrote:As variant, instatnt attack can be called from CustomInventory item.
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.

Re: Shoot from weapon "without" player

by Apeirogon » Fri Jul 12, 2019 10:58 am

Void Weaver wrote:Oh, seems I've got it. :D 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:

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	
}
}
As variant instatnt attack can be called from CustomInventory item.

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	
}
}
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 require changing weapon code, while I need a way to do so without changing weapon code.
Matt wrote:Can a player sprite be given to an actor that has no controlling player?
No, since psprite class nailed to playerinfo struct and you cant "deattach" it and/or create new psprite class/playerinfo struct.



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.

Re: Shoot from weapon "without" player

by Matt » Thu Jul 11, 2019 4:39 pm

Can a player sprite be given to an actor that has no controlling player?

Re: Shoot from weapon "without" player

by Void Weaver » Thu Jul 11, 2019 1:19 pm

Oh, seems I've got it. :D 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:

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	
}
}
As variant instatnt attack can be called from CustomInventory item.

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	
}
}
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

Re: Shoot from weapon "without" player

by Apeirogon » Thu Jul 11, 2019 10:46 am

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.

Re: Shoot from weapon "without" player

by Void Weaver » Thu Jul 11, 2019 10:22 am

... what about replacing fire-Psprites by other custom ones or even TNT1?

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

by Apeirogon » Thu Jul 11, 2019 10:10 am

Execute weapon "fire" state without using them as Psprite.

Re: Shoot from weapon "without" player

by Void Weaver » Thu Jul 11, 2019 9:21 am

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?

Shoot from weapon "without" player

by Apeirogon » Thu Jul 11, 2019 8:36 am

Lets take a simple doom pistol. Is it possible to make it shoot without using it as player ready weapon?

Top