Shoot from weapon "without" player

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!

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.

Shoot from weapon "without" player

Postby Apeirogon » Thu Jul 11, 2019 9:36 am

Lets take a simple doom pistol. Is it possible to make it shoot without using it as player ready weapon?
Apeirogon
I have a strange sense of humour
 
Joined: 12 Jun 2017

Re: Shoot from weapon "without" player

Postby Void Weaver » Thu Jul 11, 2019 10: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?
User avatar
Void Weaver
Keeper of the Diablo bestiary storage Also amateur DECORATE-spaghetti weaver ಠ_ಠ
 
Joined: 18 Dec 2014

Re: Shoot from weapon "without" player

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

Execute weapon "fire" state without using them as Psprite.
Apeirogon
I have a strange sense of humour
 
Joined: 12 Jun 2017

Re: Shoot from weapon "without" player

Postby Void Weaver » Thu Jul 11, 2019 11:22 am

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

For ex.:
Code: Select allExpand view
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
   }
}
User avatar
Void Weaver
Keeper of the Diablo bestiary storage Also amateur DECORATE-spaghetti weaver ಠ_ಠ
 
Joined: 18 Dec 2014

Re: Shoot from weapon "without" player

Postby Apeirogon » Thu Jul 11, 2019 11: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.
Apeirogon
I have a strange sense of humour
 
Joined: 12 Jun 2017

Re: Shoot from weapon "without" player

Postby Void Weaver » Thu Jul 11, 2019 2: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 allExpand view
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 allExpand view
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
Last edited by Void Weaver on Thu Jul 11, 2019 11:05 pm, edited 2 times in total.
User avatar
Void Weaver
Keeper of the Diablo bestiary storage Also amateur DECORATE-spaghetti weaver ಠ_ಠ
 
Joined: 18 Dec 2014

Re: Shoot from weapon "without" player

Postby Matt » Thu Jul 11, 2019 5:39 pm

Can a player sprite be given to an actor that has no controlling player?
User avatar
Matt
Putting the XD into *xdeath since 2007
 
Joined: 04 Jan 2004
Location: Gotham City SAR, Wyld-Lands of the Lotus People, Dominionist PetroConfederacy of Saudi Canadia

Re: Shoot from weapon "without" player

Postby Apeirogon » Fri Jul 12, 2019 11: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 allExpand view
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 allExpand view
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.
Apeirogon
I have a strange sense of humour
 
Joined: 12 Jun 2017

Re: Shoot from weapon "without" player

Postby Void Weaver » Fri Jul 12, 2019 5: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.
User avatar
Void Weaver
Keeper of the Diablo bestiary storage Also amateur DECORATE-spaghetti weaver ಠ_ಠ
 
Joined: 18 Dec 2014

Re: Shoot from weapon "without" player

Postby Matt » Fri Jul 12, 2019 5: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?
User avatar
Matt
Putting the XD into *xdeath since 2007
 
Joined: 04 Jan 2004
Location: Gotham City SAR, Wyld-Lands of the Lotus People, Dominionist PetroConfederacy of Saudi Canadia

Re: Shoot from weapon "without" player

Postby Apeirogon » Sat Jul 13, 2019 2:46 am

Second, vanilla BFG and vanilla pistol.

I ant to make it applicable to any weapon in general.
Apeirogon
I have a strange sense of humour
 
Joined: 12 Jun 2017

Re: Shoot from weapon "without" player

Postby Graf Zahl » Sat Jul 13, 2019 7: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.
User avatar
Graf Zahl
Lead GZDoom Developer
Lead GZDoom Developer
 
Joined: 19 Jul 2003
Location: Germany

Re: Shoot from weapon "without" player

Postby Apeirogon » Sun Jul 14, 2019 10:26 am

Not without playerinfo, without using weapon states as reference for psprite.
Apeirogon
I have a strange sense of humour
 
Joined: 12 Jun 2017


Return to Scripting

Who is online

Users browsing this forum: Awario [RSS] and 1 guest