Change Projectiles Target

Discuss all aspects related to modding Zandronum here.
Post Reply
Sirion
New User
Posts: 17
Joined: Sat Aug 04, 2012 1:55 pm

Change Projectiles Target

#1

Post by Sirion » Sun Jul 21, 2013 8:26 pm

Hi,

As far as I remember, a projectiles target switches to its vitcim it hit.
Or am I wrong?

Example:

Code: Select all

Actor TestProjectile
{
/*speed, damage and so on...*/
  states
  {
  Spawn:
    TNT1 A 1 //Here is the projectile facing its owner, thus: TARGET = OWNER
    loop
  XDeath:
  Death:
    TNT1 A 1 //And here it "should" face the actor it just hit, thus it should be possible with A_GiveToTarget to give the victim an item
    stop
  }
}
Shouldnt this work?
Its because I want to make a weapon, where player A shoots a projectile to player B and player B gets morphed. But I dont want to use MorphProjectile because the ACS Script has to change some important stuff while morphing.

User avatar
Ænima
Addicted to Zandronum
Posts: 3582
Joined: Tue Jun 05, 2012 6:12 pm

RE: Change Projectiles Target

#2

Post by Ænima » Sun Jul 21, 2013 9:01 pm

Did you try it? In theory it should work.
Reinforcements: midgame Survival joining/respawning
Doom64: Unabsolved: Doom64 + Diablo II
ZandroSkins: a pack made by our community
AeniPuffs: 3D blood and bullet puff effects, free to use for your own mods
Squad Radio: a WASD-based radio chat menu, add your own custom sounds!
Mercenaries (on hold)
Image

Sirion
New User
Posts: 17
Joined: Sat Aug 04, 2012 1:55 pm

RE: Change Projectiles Target

#3

Post by Sirion » Sun Jul 21, 2013 9:12 pm

Ænima wrote: Did you try it? In theory it should work.
Heres an example pk3 file:
http://static.[bad site]/wads/projtest.pk3

Type in console:
give pistol2
use pistol2

It shoots a DoomImpBall that is supposed to make its hit target jump, but it ALWAYS makes the player that owns the projectile jump.
What the deuce am I doin wrong?

User avatar
Ænima
Addicted to Zandronum
Posts: 3582
Joined: Tue Jun 05, 2012 6:12 pm

RE: Change Projectiles Target

#4

Post by Ænima » Sun Jul 21, 2013 9:49 pm

Howbout a custom damagetype and pain state? That's how these things are usually done.
Reinforcements: midgame Survival joining/respawning
Doom64: Unabsolved: Doom64 + Diablo II
ZandroSkins: a pack made by our community
AeniPuffs: 3D blood and bullet puff effects, free to use for your own mods
Squad Radio: a WASD-based radio chat menu, add your own custom sounds!
Mercenaries (on hold)
Image

Sirion
New User
Posts: 17
Joined: Sat Aug 04, 2012 1:55 pm

RE: Change Projectiles Target

#5

Post by Sirion » Sun Jul 21, 2013 9:51 pm

Ænima wrote: Howbout a custom damagetype and pain state? That's how these things are usually done.
The problem is, that its supposed to be an AddOn.
It should be compatible with all versions of the game I want to patch.
So changing the main code will have negative effects on the game itself, once a new version gets released.

User avatar
Ænima
Addicted to Zandronum
Posts: 3582
Joined: Tue Jun 05, 2012 6:12 pm

RE: Change Projectiles Target

#6

Post by Ænima » Mon Jul 22, 2013 1:15 am

I see.

Well with your method you'd probably need A_GiveRadius in the projectile's death/crash state. But A_GiveRadius isn't supported yet, I don't think.
Reinforcements: midgame Survival joining/respawning
Doom64: Unabsolved: Doom64 + Diablo II
ZandroSkins: a pack made by our community
AeniPuffs: 3D blood and bullet puff effects, free to use for your own mods
Squad Radio: a WASD-based radio chat menu, add your own custom sounds!
Mercenaries (on hold)
Image

Sirion
New User
Posts: 17
Joined: Sat Aug 04, 2012 1:55 pm

RE: Change Projectiles Target

#7

Post by Sirion » Mon Jul 22, 2013 5:50 am

Ok I did it now with the help of OOM! And it works, WOOHOO! (in 95% of all cases, lol)
But in a (kinda) tricky way:

Code: Select all

1.)Players entering a game constantly store their coordinates, velocity and health in an array.

2.)A Player shoots now the projectile that should morph the target it hits.

3.)When the projectile hits a bleeding actor, it enters its XDeath state and starts a script with the projectiles coords as parameters.

4.)Now the script calculates with the help of the array the smallest distance between the projectile and all players. The player that is closest to the projectile gets chosen. If the player is not dead AND if the actual distance between the projectile and this player is less then a predefined value (e.g: 96 map units), a pickable custom inventory gets spawned at the coords of the player and has THE SAME VELOCITY, to make sure, that the custom inventory WILL be picked up by this player! Its also important that the custom inventory ONLY exists for a few tics. Else theres the possibility that someone else will pick this up and thats not supposed to happen.
Heres the file:
http://static.[bad site]/wads/projtest_v01.pk3

You can test this by getting pistol2, adding bots and shooting at them.
Worked fine for me.

User avatar
Ænima
Addicted to Zandronum
Posts: 3582
Joined: Tue Jun 05, 2012 6:12 pm

RE: Change Projectiles Target

#8

Post by Ænima » Mon Jul 22, 2013 3:08 pm

You could cut the calculations completely and just make the projectile spawn a pickup and do Radius_Quake at the same time. This forces the hit player to take the item, even if they're standing still. This is how AOW2's medic gun worked for the longest time. And no ACS required.
Reinforcements: midgame Survival joining/respawning
Doom64: Unabsolved: Doom64 + Diablo II
ZandroSkins: a pack made by our community
AeniPuffs: 3D blood and bullet puff effects, free to use for your own mods
Squad Radio: a WASD-based radio chat menu, add your own custom sounds!
Mercenaries (on hold)
Image

User avatar
Dusk
Developer
Posts: 581
Joined: Thu May 24, 2012 9:59 pm
Location: Turku

RE: Change Projectiles Target

#9

Post by Dusk » Mon Jul 22, 2013 3:50 pm

As said, just a A_SpawnItemEx("pickup_here", 0,0,0, 0,0,0, 0, SXF_NOCHECKPOSITION) should do, and a single tic should be all that's necessary.

For the record, projectiles indeed do not change their target - the target is who shot the projectile at all times.
Last edited by Dusk on Mon Jul 22, 2013 3:50 pm, edited 1 time in total.

Sirion
New User
Posts: 17
Joined: Sat Aug 04, 2012 1:55 pm

RE: Change Projectiles Target

#10

Post by Sirion » Mon Jul 22, 2013 5:00 pm

Hmm.
Ok another question:
Is it possible to make a CustomInventory not being pickable for a specific amount of time?
I want to shoot a CustomInventory and make the enemy pick it up.

It works if the shooter stands still, but if hes moving, he picks up the CustomInventory and not the target.


Edit:
I tried the way AEnima mentioned. It works only in 90% of all casses, just like my algorithm. Its because the other player is either running too fast in the same direction as the projectile or the CustomInventory class radius is too small.
Last edited by Sirion on Mon Jul 22, 2013 5:05 pm, edited 1 time in total.
Heil Satan

User avatar
Ænima
Addicted to Zandronum
Posts: 3582
Joined: Tue Jun 05, 2012 6:12 pm

RE: Change Projectiles Target

#11

Post by Ænima » Mon Jul 22, 2013 6:44 pm

It might be hacky, but you could spawn a solid invisible actor that the target gets "stuck in" first, then spawn the CustomInventory and earthquake second. Make sure the first actor has a radius of like 100. I doubt they'll be able to outrun that.
Reinforcements: midgame Survival joining/respawning
Doom64: Unabsolved: Doom64 + Diablo II
ZandroSkins: a pack made by our community
AeniPuffs: 3D blood and bullet puff effects, free to use for your own mods
Squad Radio: a WASD-based radio chat menu, add your own custom sounds!
Mercenaries (on hold)
Image

Ijon Tichy
Frequent Poster Miles card holder
Posts: 901
Joined: Mon Jun 04, 2012 5:07 am

RE: Change Projectiles Target

#12

Post by Ijon Tichy » Mon Jul 22, 2013 7:14 pm

-SPECIAL disables the ability to pick up inventory items. +SPECIAL turns it back on.

Also, if you're using ACS to keep track of player positions, why the hell aren't you keeping track of their TIDs and just doing GiveActorInventory?
Last edited by Ijon Tichy on Mon Jul 22, 2013 7:15 pm, edited 1 time in total.

Sirion
New User
Posts: 17
Joined: Sat Aug 04, 2012 1:55 pm

RE: Change Projectiles Target

#13

Post by Sirion » Mon Jul 22, 2013 8:17 pm

Ijon Tichy wrote: -SPECIAL disables the ability to pick up inventory items. +SPECIAL turns it back on.

Also, if you're using ACS to keep track of player positions, why the hell aren't you keeping track of their TIDs and just doing GiveActorInventory?
Thats the problem.
The original mod doesnt take advantage of TIDs, they still use funcs like GiveInventory instead of GiveActorInventory and so on.
And there are already other patches that changes the TID for their own purpose.

Now imagine I change the TIDs, and a player wants to play the mod with my and another patch, that uses other TIDs. The patches will have conflicts and the game wont work properly. So it would be the best to NOT change anything code related to the game itself.
Just add some stuff.
Heil Satan

Ijon Tichy
Frequent Poster Miles card holder
Posts: 901
Joined: Mon Jun 04, 2012 5:07 am

RE: Change Projectiles Target

#14

Post by Ijon Tichy » Tue Jul 23, 2013 5:14 am

That's never an issue with me. I made a function that will guarantee the activator has a unique TID, using the one he already has if it's unique. I can dig it up later; if you want to find it, it's in my Pastebin history, as any of the commonFuncs.h items.

Post Reply