Fri Jan 28, 2022 11:02 am
Spoiler:
Spoiler:
This script will cause any monster with provided TID to attack the calling player's current target. It could be used for summoned minions and the script could be activated via a hot-key.
Script "AttackTarget" (int TID) NET
{
int oldTID, target;
if(SetActivator(0,AAPTR_PLAYER_GETTARGET)) // Get the target of the activator. If it fails because there is none nothing will happen.
{
oldTID = ActivatorTID(); // Save the TID of the target.
target = UniqueTID(); // Get a new unique TID for the target actor.
Thing_ChangeTID(0, target); // Set that TID to the actor.
SetActivator(TID); // Set the activator to the actor with the given TID.
SetPointer(AAPTR_TARGET, target); // Give a new target to it.
Thing_ChangeTID(target,oldTID); // Restore the previous TID, because it might be used already by other scripts.
}
Fri Jan 28, 2022 7:08 pm
Sun Jan 30, 2022 10:01 pm
Tue Feb 01, 2022 10:06 am
This script will cause any monster with provided TID to attack the calling player's current target. It could be used for summoned minions and the script could be activated via a hot-key.
Script "AttackTarget" (int TID) NET
{
int oldTID, target;
if(SetActivator(0,AAPTR_PLAYER_GETTARGET)) // Get the target of the activator. If it fails because there is none nothing will happen.
{
oldTID = ActivatorTID(); // Save the TID of the target.
target = UniqueTID(); // Get a new unique TID for the target actor.
Thing_ChangeTID(0, target); // Set that TID to the actor.
SetActivator(TID); // Set the activator to the actor with the given TID.
SetPointer(AAPTR_TARGET, target); // Give a new target to it.
Thing_ChangeTID(target,oldTID); // Restore the previous TID, because it might be used already by other scripts.
}
Fire:
TNT1 A 0
TNT1 A 0 A_JumpIfTargetInLOS("OpenFire")
Goto Ready
AltFire:
HSKL E 0 A_PlaySound("weapon/firedrone", CHAN_WEAPON, 0.7)
HSKL E 0 A_Recoil(4)
HSKL E 5 A_SpawnItemEx("Drone", 40, 0, 35, 0, 0, 0, 0, SXF_TRANSFERPOINTERS) // Should this be TID = A_SpawnItemEx("Drone", 40, 0, 35, 0, 0, 0, 0, SXF_TRANSFERPOINTERS) or something to capture the drone for future reference?
HSKL D 5
HSKL D 0 A_Refire("SkullinazorFire")
Goto Ready
OpenFire:
TNT1 A 0 AttackTarget(Drone) //Would this assign the script "AttackTarget" to the Drone?
Goto Ready
Script "AttackTarget" (int TID) NET
{
int oldTID, target;
if(SetActivator(0,AAPTR_PLAYER_GETTARGET)) // Get the target of the activator. If it fails because there is none nothing will happen.
{
oldTID = ActivatorTID(); // Save the TID of the target.
target = UniqueTID(); // Get a new unique TID for the target actor.
Thing_ChangeTID(0, target); // Set that TID to the actor.
SetActivator(TID); // Set the activator to the actor with the given TID.
SetPointer(AAPTR_TARGET, target); // Give a new target to it.
Thing_ChangeTID(target,oldTID); // Restore the previous TID, because it might be used already by other scripts.
}
Wed Feb 02, 2022 10:15 am
Fire:
TNT1 A 1; // Non zero duration, so we have "time" to stop holding fire. It might require more than a single tick though.
TNT1 A 0 A_Refire("HoldAction");
Goto TapAction;
action bool A_AttackMyEnemyDrone()
{
FLineTraceData RemoteRay;
bool hit = LineTrace(
angle,
2048,
pitch,
offsetz: height-12,
data: RemoteRay
);
if (hit && RemoteRay.HitType == TRACE_HitActor) // Check if we hit an actor
{
if (HitActor) // This is what we hit, but, just in case, let's check if it is non-null
{
// Now we have the target we want to kill. We need to find our drone now, and order it to attack. The following part will assume that each drone the player has refers to the player with it's "master" field.
ThinkerIterator Searcher = ThinkerIterator.Create("Drone ");
Drone Iterated;
while (Iterated = Drone(Searcher.Next()))
{
if (Iterated.master == invoker.owner) // Just our drones, don't steal!
{
// This part is actually what i am least certain will work, we need to actually order the drone to attack. I believe just changing pointers of the drone will be enough:
Iterated.target = HitActor;
Iterated.lasttarget = HitActor;
Iterated.soundtarget = HitActor;
}
}
}
}
}
Thu Feb 03, 2022 10:27 pm
Sun Feb 06, 2022 10:25 pm
Mon Feb 07, 2022 6:43 am
Maahes wrote:I appreciate it, Sir Robin. Actually, I did see your thread before I posted mine and frankly I was hoping that the solution would not be nearly as convoluted as what you’ve had to go through.
Maahes wrote:I am sure your code will prove useful, but I wish someone could explain that snippet of code that I got off of the ZDoom wiki to me. The wiki clearly states that it should cause minions to attack whatever is under the player crosshairs, no ghost projectile hitscan ray tracing required. My goal is to *avoid* having the player shoot a bunch of ghost projectiles or hitscans every single time I’m trying to activate this, AND avoid dealing with sector and sector flag headaches. It looks like it should be doable in some form or fashion from the Wiki script template, but I need someone to explain it to me in a way I can understand…
Maahes wrote:I think the biggest difference between our two projects is that you may want it to detect when it is hitting walls and non-actors (like decorations). At least that was my understanding from some things on your thread. The hardwired functions in GZDoom don’t seem to detect when players are looking at anything except actors with specific flags. That leads me to think there may be more elegant (read, more efficient, less intensive, and more universally applicable) solution to my problem since it requires less thorough detection and discrimination capability than your goal.
Maahes wrote:So that is where I am coming from. Your work is way beyond what I had originally wanted to get involved in at this point, but I will look through your code and maybe I will come up with all kinds of crazy ideas!
Maahes wrote:Thanks again! And to everyone else: my question still stands. How the heck do I use that script template off of the ZDoom Wiki?
Mon Feb 07, 2022 9:03 pm
Mon Feb 07, 2022 9:55 pm
Thu Feb 10, 2022 9:54 am