Page 1 of 1
[DECORATE] (Solved for now) Problem with an Autofiring/auto aiming weapon.
Posted: Sat Sep 16, 2017 6:36 pm
by FranckyFox2468
So lately been trying to experiment on a weapon that is basically some form of shoulder based auto gun that you basically choose a target, and the turrets fires continuously at it for as long as the target is in range (my idea is that it fires at it no matter the direction), and if the target goes out of range, it stops until you assign it again or assign a different target.
So i tried this:
Code: Select all
ACTOR BeamTester : DoomWeapon
{
Weapon.SelectionOrder 100
States
{
Ready:
PLSG A 1 A_WeaponReady
Loop
Deselect:
PLSG A 1 A_Lower
Loop
Select:
PLSG A 1 A_Raise
Loop
Fire:
PLSG A 1 A_FireBullets(0, 0, 1, 0, "ShoulderPuff")
PLSG A 1 A_GiveInventory ("ShoulderFire", 1)
PLSG B 20
TNT1 A 0 A_ReFire
Goto Ready
Spawn:
PLAS A -1
Stop
}
}
ACTOR ShoulderPuff
{
+PUFFONACTORS
+ALWAYSPUFF
+PUFFGETSOWNER
+HITTRACER
States
{
Spawn:
TNT1 A 0 nodelay A_TransferPointer(AAPTR_DEFAULT, AAPTR_TARGET, AAPTR_TRACER, AAPTR_TARGET)
TNT1 A 1
Stop
}
}
ACTOR ShoulderFire : CustomInventory
{
+INVENTORY.ALWAYSPICKUP
+INVENTORY.AUTOACTIVATE
-Invbar
inventory.maxamount 1
States
{
Spawn:
TNT1 A -1
Loop
Use:
TNT1 A 0
TNT1 A 1 A_JumpIfTargetInLOS("MissileShoot", 0, JLOSF_DEADNOJUMP)
TNT1 A 1
stop
MissileShoot:
TNT1 A 1 A_FireCustomMissile("PlasmaBall")
TNT1 A 10
goto use
}
}
Basically, it sends a puff that sets the target as a tracer, assign its tracer as a target for the player, and then gives the item that continuously activate and shoot automatically at the target.
And.... while it PARTIALLY work, its buggy as hell. First thing it does is that if you hit a monster, the game freezes after a plasma ball even remotely launched and it unfreezes when a monster die and the wall has a black hole created by plasma ball. No idea wha causes this concidering i put delays and all. Second is that once you miss your shot and hit a wall or a floor, the hitscan and targetting stops working ENTIRELY.
I have no idea what causes this so help would be appreciated.
[DECORATE] Re: Problem with an Autofiring/auto aiming weapon.
Posted: Sat Sep 16, 2017 7:55 pm
by Komodo
Change the Fire state of the beamtester to:
Code: Select all
Fire:
PLSG A 1 A_FireBullets(0, 0, 1, 0, "ShoulderPuff")
PLSG A 1 A_JumpIfTargetInLOS("Fire2", 0, JLOSF_DEADNOJUMP)
Goto Ready
Fire2:
PLSG A 10 A_GiveInventory ("ShoulderFire", 1)
PLSG A 5 A_JumpIfTargetInLOS("Fire2", 0, JLOSF_DEADNOJUMP)
PLSG B 20
PLSG B 1 A_ReFire
Goto Ready
and change the Use state of the ShoulderFire item to:
Code: Select all
Use:
TNT1 A 1
TNT1 A 1 A_FireCustomMissile("PlasmaBall")
TNT1 A 10
stop
and see if that works as intended
[DECORATE] Re: Problem with an Autofiring/auto aiming weapon.
Posted: Sat Sep 16, 2017 8:37 pm
by FranckyFox2468
That won't solve the problem. What i want is to do an item that shoots the projectile idenfinitly and independantly from the weapon so the user can still use its primary fire and other state while it fires, and stops if the target is out of range.
our exemple makes it simply a fire that might as well use a_firecustommissile.
And adding a tick delay before the projectile doesn't stop the freezing issue.
[DECORATE] Re: Problem with an Autofiring/auto aiming weapon.
Posted: Sun Sep 17, 2017 1:18 am
by Empyre
I would make an invisible friendly monster that does the shooting. The tricky part that I haven't figured out is how to make the monster stay with the player so it appears as if the player is shooting.
[DECORATE] Re: Problem with an Autofiring/auto aiming weapon.
Posted: Sun Sep 17, 2017 3:16 am
by FranckyFox2468
Empyre wrote:I would make an invisible friendly monster that does the shooting. The tricky part that I haven't figured out is how to make the monster stay with the player so it appears as if the player is shooting.
I'll have to thinker around that but a friend suggested making the monster use A_Warp constantly to make the monster stick with the player. Not sure how that will turn out but ill try to play around that.
[DECORATE] Re: Problem with an Autofiring/auto aiming weapon.
Posted: Sun Sep 17, 2017 4:29 am
by Empyre
FranckyFox2468 wrote:Empyre wrote:I would make an invisible friendly monster that does the shooting. The tricky part that I haven't figured out is how to make the monster stay with the player so it appears as if the player is shooting.
I'll have to thinker around that but a friend suggested making the monster use A_Warp constantly to make the monster stick with the player. Not sure how that will turn out but ill try to play around that.
If you get that working, I am interested in doing something similar myself.
[DECORATE] Re: Problem with an Autofiring/auto aiming weapon.
Posted: Sun Sep 17, 2017 5:19 am
by Komodo
Alright i managed to make an invisible monster that sticks to the player using SetActorPosition and it works fine. You can check it in the attached file.
The only problem is that sometimes it gets bugged and refuses to acquire the target under the cursor. I will try to check later whats wrong with it.
[DECORATE] Re: Problem with an Autofiring/auto aiming weapon.
Posted: Tue Sep 19, 2017 3:51 pm
by FranckyFox2468
Komodo wrote:Alright i managed to make an invisible monster that sticks to the player using SetActorPosition and it works fine. You can check it in the attached file.
The only problem is that sometimes it gets bugged and refuses to acquire the target under the cursor. I will try to check later whats wrong with it.
Tried it, and aside from the bug you mentionned, its pretty solid honestly. I'll try to tinker around it and give you credits if i go anywhere with this.
If you have an update on your side please do say so.
[DECORATE] Re: Problem with an Autofiring/auto aiming weapon.
Posted: Tue Sep 19, 2017 4:39 pm
by Komodo
This code should now fix it. the monster was being spawned before checking if there was a clear line of sight.
and i removed the target assignment from the script because it is already being done by the SXF_TRANSFERPOINTERS flag.
DECORATE:
Code: Select all
ACTOR FT: inventory
{
Inventory.maxamount 1
}
ACTOR newplasma: PlasmaBall
{
Radius 2.5
Height 5
scale 0.4
Speed 40
Damage (1)
Projectile
DamageType "newPlasma"
+THRUGHOST
}
ACTOR Turret
{
Health 100
Radius 5
Height 10
scale 0.5
Mass 0
Speed 0
Monster
+SPECTRAL
+NEVERTARGET
+Friendly
+NOGRAVITY
+FLOAT
+Ghost
+THRUGHOST
+THRUACTORS
-TELESTOMP
+Standstill
States
{
Spawn:
TNT1 A 0 NoDelay ACS_EXECUTEalways(101,0,0,0,0)
TNT1 A 1 A_LookEx(LOF_DONTCHASEGOAL|LOF_NOSOUNDCHECK,0,0,0,5,"see")
Goto spawn +1
See:
TNT1 A 1
Goto Missile
Melee:
Missile:
TNT1 A 0 A_FaceTarget
TNT1 A 0 A_JumpIfTargetInLOS("HEIS", 0, JLOSF_DEADNOJUMP)
Goto Death
HEIS:
TNT1 F 3 A_customMissile("newplasma")
Goto Missile
Death:
TNT1 A 1 ACS_EXECUTEalways(103,0,0,0,0)
TNT1 A -1
Stop
}
}
ACTOR ShoulderPuff
{
+PUFFONACTORS
+ALWAYSPUFF
+PUFFGETSOWNER
+HITTRACER
+THRUGHOST
States
{
Spawn:
TNT1 A 0 nodelay A_TransferPointer(AAPTR_DEFAULT, AAPTR_TARGET, AAPTR_TRACER, AAPTR_TARGET)
TNT1 A 1
stop
}
}
ACTOR BeamTester : DoomWeapon
{
Weapon.SelectionOrder 100
Weapon.slotNumber 6
+NOAUTOAIM
States
{
Ready:
PLSG A 5 A_WeaponReady
Loop
Deselect:
PLSG A 1 A_Lower
Loop
Select:
PLSG A 1 A_Raise
Loop
Fire:
PLSG A 1 A_FireBullets(0, 0, 1, 0, "ShoulderPuff")
PLSG A 0 A_JumpIfTargetInLOS("Fire2", 0, JLOSF_DEADNOJUMP)
Goto Ready
Fire2:
PLSG A 0 ACS_EXECUTEalways(102,0,0,0,0)
PLSG A 0 A_SpawnItemex("Turret",0,0,15,0,0,0,0,SXF_TRANSFERPOINTERS|SXF_SETMASTER)
PLSG A 0 A_Takeinventory("FT",1)
PLSG B 35
PLSG B 1 A_ReFire
Goto Ready
Spawn:
PLAS A -1
Stop
}
}
ACTOR NewMarine: DoomPlayer
{
Player.startitem "BeamTester"
DamageFactor "newPlasma",0
+GHOST
States{
Death:
TNT1 A 1 ACS_EXECUTEalways(102,0,0,0,0)
TNT1 A -1
stop
}
}
Scipt:
Code: Select all
#library "acs-code"
#include "zcommon.acs"
#Define TID_Player 1000
#Define TID_Turret 64
script 4300 ENTER{
Thing_ChangeTid(0, TID_Player + PlayerNumber());
}
script 4301 RESPAWN{
Thing_ChangeTid(TID_Player + PlayerNumber(), 0);
Thing_ChangeTid(0, TID_Player + PlayerNumber());
}
script 101 (void){
int MasterTID = GetActorProperty (0, APROP_MasterTID);
Thing_ChangeTid(0, TID_Turret + MasterTID);
int TurretTID = TID_Turret + MasterTID;
while (ThingCount(T_NONE,TurretTID) == 1){
SetActorPosition(TurretTID, GetActorX(MasterTID), GetActorY(MasterTID), GetActorZ(MasterTID) + 15.0 , 0);
delay(1);
}
}
script 102 (void){
If(!Checkinventory("FT")){
Thing_Remove(PlayerNumber()+TID_Player+TID_Turret);
}
}
script 103 (void){
Thing_Remove(0);
}
[DECORATE] Re: Problem with an Autofiring/auto aiming weapon.
Posted: Tue Sep 19, 2017 6:00 pm
by FranckyFox2468
its still a little buggy and doesn't always take the target at occasions. I noticed it happens when your previous target recently died or if you recently hit a wall by accident.
But i can certainly feel an improvement tho.
EDIT: I also noticed the turret remains active after you die and only stops until the target is dead or you respawn. But i'm sure this could easily be fixed with a DEATH script.
I'll try to play around that this weekend.
[DECORATE] Re: Problem with an Autofiring/auto aiming weapon.
Posted: Wed Sep 20, 2017 12:39 am
by Komodo
OK I have just modified the turret's states a little bit and used a script to assign the target instead of SXF_TRANSFERPOINTERS and it works way better now.
DECORATE:
Code: Select all
ACTOR FT: inventory
{
Inventory.maxamount 1
}
ACTOR newplasma: PlasmaBall
{
Radius 2.5
Height 5
scale 0.4
Speed 40
Damage (5)
Projectile
Species "Turret"
DamageType "newPlasma"
+THRUSPECIES
}
ACTOR Turret
{
Health 100
Radius 4
painChance 0
Height 4
scale 1
Mass 0
Speed 0
Monster
Species "Turret"
+THRUSPECIES
+SPECTRAL
+NEVERTARGET
+Friendly
+NOGRAVITY
+FLOAT
+Ghost
+THRUGHOST
+THRUACTORS
-TELESTOMP
+Standstill
+NOTARGETSWITCH
States
{
Spawn:
TNT1 AAAAA 0 A_ClearTarget
TNT1 A 1
TNT1 A 1 ACS_EXECUTEalways(101,0,0,0,0)
see:
TNT1 A 0
Missile:
TNT1 A 1 A_FaceTarget
TNT1 A 1 A_JumpIfTargetInLOS("HEIS",180,JLOSF_DEADNOJUMP|JLOSF_COMBATANTONLY)
Goto Death
HEIS:
TNT1 F 6 A_customMissile("newplasma")
Goto Missile
Death:
TNT1 A 0 ACS_EXECUTEalways(103,0,0,0,0)
TNT1 A 1
TNT1 A -1
Stop
}
}
ACTOR ShoulderPuff
{
+PUFFONACTORS
+ALWAYSPUFF
+PUFFGETSOWNER
+HITTRACER
+THRUGHOST
States
{
Spawn:
TNT1 AAAAA 0
TNT1 A 0 A_TransferPointer(AAPTR_DEFAULT, AAPTR_TARGET, AAPTR_TRACER, AAPTR_TARGET)
stop
}
}
ACTOR BeamTester : DoomWeapon
{
Weapon.SelectionOrder 100
Weapon.slotNumber 6
+NOAUTOAIM
States
{
Ready:
PLSG A 5 A_WeaponReady
Loop
Deselect:
PLSG A 1 A_Lower
Loop
Select:
PLSG A 1 A_Raise
Loop
Fire:
PLSG A 0 A_FireBullets(0, 0, 1, 0, "ShoulderPuff")
PLSG A 0 A_JumpIfTargetInLOS("Fire2", 0, JLOSF_DEADNOJUMP)
PLSG A 0 A_PRINTBOLD ("No Target In LOS",0.3,3)
Goto Ready
Fire2:
PLSG A 0 ACS_EXECUTEalways(102,0,0,0,0)
PLSG A 1 A_SpawnItemex("Turret",0,0,20.0,0,0,0,0,SXF_SETMASTER)
PLSG A 0 A_Takeinventory("FT",1)
PLSG B 10
PLSG B 1 A_ReFire
Goto Ready
Spawn:
PLAS A -1
Stop
}
}
ACTOR NewMarine: DoomPlayer
{
Player.startitem "BeamTester"
DamageFactor "newPlasma",0
Species "Turret"
+THRUSPECIES
States{
Death:
TNT1 A 2 ACS_EXECUTEalways(102,0,0,0,0)
TNT1 A -1
stop
}
}
ACS:
Code: Select all
#library "acs-code"
#include "zcommon.acs"
#Define TID_Player 1000
#Define TID_Turret 64
#Define TID_Target 70064
script 4300 ENTER{
Thing_ChangeTid(0, TID_Player + PlayerNumber());
}
script 4301 RESPAWN{
Thing_ChangeTid(TID_Player + PlayerNumber(), 0);
Thing_ChangeTid(0, TID_Player + PlayerNumber());
}
script 101 (void){
int MasterTID = GetActorProperty (0, APROP_MasterTID);
Thing_ChangeTid(0, TID_Turret + MasterTID);
int TurretTID = TID_Turret + MasterTID;
ACS_EXECUTEalways(300,0,MasterTID,TurretTID);
while (ThingCount(T_NONE,TurretTID) == 1){
SetActorPosition(TurretTID, GetActorX(MasterTID), GetActorY(MasterTID), GetActorZ(MasterTID)+20.0 , 0);
delay(1);
}
}
script 102 (void){
If(!Checkinventory("FT")){
Thing_Remove(PlayerNumber()+TID_Player+TID_Turret);
}
}
script 103 (void){
int TurretTID = ActivatorTID();
int TT = TurretTID + TID_Target;
If( GetActorProperty(0,APROP_TargetTID)==(TT)){
SetActivator(TT);
Thing_ChangeTID(TT,0);
}
Delay(1);
}
script 300 (int MasterTID, int TurretTID){
if(SetActivator(MasterTID,AAPTR_PLAYER_GETTARGET))
{
int oldTID = ActivatorTID();
If(oldTID == 0){
int TargetTID = TurretTID+TID_Target;
Thing_ChangeTID(0, TargetTID);
SetActivator(TurretTID);
SetPointer(AAPTR_TARGET, TargetTID);
}
else{
SetActivator(TurretTID);
SetPointer(AAPTR_TARGET, oldTID);
}
}
}
[DECORATE] Re: Problem with an Autofiring/auto aiming weapon.
Posted: Sat Dec 30, 2017 3:02 am
by FranckyFox2468
Thanks for the help. Got the feeling this might come really handy to make a medigun as well. From what i witnessed it seems to work pretty damn well. I'll be doing further messing around. Thanks again!