Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
Sign in to follow this  
Vorpal

Decorate Projectile Problem

Recommended Posts

Hey folks, I've been trying to figure this out for a day to no avail, so maybe someone else can shed some light on the issue!

First, the code

Spoiler

ACTOR pg_bsp : PlasmaRifle replaces PlasmaRifle
{
Weapon.SelectionOrder 100
Weapon.SlotNumber 6
States
{

Fire:
PLSF A 1 Offset(0,34) A_GunFlash
PLSF B 1 Offset(0,36)
PLSG A 2 Offset(0,34) A_FireCustomMissile("PlasmaNew")
TNT1 A 0 A_PlaySound("weapons/plasmaf")
PLSG A 7 Offset(0,32)
TNT1 A 0 A_ReFire
Goto Ready
Flash:
PLSF A 4 Bright A_Light1
Goto LightDone
PLSF B 4 Bright A_Light1
Goto LightDone
}
}

ACTOR PlasmaNew : FastProjectile
{
Radius 13
Height 8
RenderStyle Add
Alpha 0.75
Scale 0.75
DeathSound "plashit"
Obituary "$OB_MPPLASMARIFLE" // "%o was melted by %k's plasma gun."
Speed 80
Damage 2
+Ripper
States
{
Spawn:
PLSE A 2 Bright
TNT1 A 0 A_SpawnItemEx("PlasmaExplosion")
PLSE A 2 Bright
TNT1 A 0 A_SpawnItemEx("PlasmaExplosion")
PLSE A 2 Bright
TNT1 A 0 A_SpawnItemEx("PlasmaExplosion")
TNT1 A 0 A_CustomMissile("PlasmaNew",random(-12,12),random(-12,12),random(-4,4),CMF_AIMDIRECTION|CMF_TRACKOWNER,0)
//change direction by spawning itself again, moving randomly up to 12
//left/right and 12 up/down and change trajectory by up to 4 left/right
//then stopping the original
Stop
Death:
PLSE ABCDE 4 Bright
Stop
}
}


ACTOR PlasmaExplosion
{
Radius 13
Height 8
Scale 0.6
Speed 25
Projectile
RenderStyle Add
Alpha 0.75
States
{
Spawn:
TNT1 A 0 // dummy frame because reasons
TNT1 A 0 A_Jump (170,"Kerplow") // only detonate 66% of the plasma "trail"
Stop
Kerplow:
TNT1 A 4
TNT1 A 0 A_PlaySound("plashit")
PLSE ABCDE 4 Bright A_Explode(40,48,0)
Stop
}
}

And a video: https://www.youtube.com/watch?v=AVpDL48X8ec

It would seem that the A_CustomMissile function is losing the vertical velocity of its parent and resetting to zero. Perhaps I am trying to put a square block in a round hole by using this function "hack" a randomized projectile trajectory, and another function would be better suited?

Share this post


Link to post

Remove the very last parameter (pitch) from the function call. Currently you have set it to 0, but that's not what you want.

Maybe also set CMF_SAVEPITCH flag in addition to CMF_OFFSETPITCH, but I'm not sure if this can help.

EDIT: Actually, now I realized that the latter is more likely to help than the former, because the 0 should merely be added to the missile's pitch when CMF_OFFSETPITCH is set.

Share this post


Link to post

Aye the last zero is the pitch relative to the projectiles current, so it means "no change". The aimdirection flag however is setting it to an absolute value of zero (relative to the game world). Perhaps I need to chuck that flag and try wrangling with the target parameter, but that appears to be exclusive to dev builds...

Share this post


Link to post

I believe I have just solved your problem, although in a completely different way. Rather than me explaining, you download the wad to see how I did it. The gun and the missile behaves exactly as you intended it to, I believe.

Download: http://www.filedropper.com/plsm

Share this post


Link to post

Mmm that does seem to work just as I was intending with just the Decorate code, which gives me hope. However I am a bit hesitant to settle on this solution because I don't understand ACS at all, so I'm going to have to exhaust all other options first. Next up is to try scrubbing the idea of spawning new projectiles semi-randomly, and see if A_SetAngle can create a similar effect (though I suspect not, since then I lose the random up/down/left/right "jumps" which give it a lightning sort of feel).

So thanks! but I am still hunting ;-)

Share this post


Link to post
Vorpal said:

and see if A_SetAngle can create a similar effect

No it wouldn't, because changing the missile's angle will not automatically change its velocity / momentum / direction of movement too.

Share this post


Link to post

I was able to come close by dropping the A_CustomMissile function and just looping this:

Spoiler

PLSE A 2
TNT1 A 0 A_ChangeVelocity (0,random(-4,4),random(-2,2),CVF_RELATIVE)
TNT1 A 0 A_SpawnItemEx("PlasmaExplosion")
Loop

However it has a high likelihood of veering way off course, and just looks more like toothpaste than lightning.

I think rather than waste more time on it, I will just steal your method and credit you when I update my little "Minor Gameplay" mod. However could I bother you to give me a brief rundown on what all these lumps and markers in the wad are/do?

Share this post


Link to post
Vorpal said:

TNT1 A 0 A_ChangeVelocity (0,random(-4,4),random(-2,2),CVF_RELATIVE)

However it has a high likelihood of veering way off course, and just looks more like toothpaste than lightning.

I didn't know about A_ChangeVelocity before. This gives hope that a script-less solution may be found.

However, look how your code is wrong: By using CVF_RELATIVE, the parameters will be evaluated as if x axis = direction parallel with the missile's angle, and y axis = direction orthogonal to the missile's angle. By having x parameter 0, the missile will keep moving by its default speed in its original direction. But by having a non-zero y parameter at the same time, the missile's velocity will basically get a 2nd component, an additional speed in a direction orthogonal to its angle and its original movement direction. The missile's speed is actually getting increased this way along with the direction of movement. If RNG gives either mostly positive numbers, or mostly negative numbers, the missile will start moving by an arbitrarily high speed into a direction orthogonal to its original movement direction. Moreso, changing velocity on z axis will have the same undesired effect on z axis, and unlike x/y axes, z axis isn't safely fixed by sin/cos functions.

The proper code would look like this, I think:

TNT1 A 0 A_SetAngle(angle+random(-4,4))
TNT1 A 0 A_ChangeVelocity(80*cos(angle),80*sin(angle)) // Do not change z velocity!
This still doesn't solve the problem how to reposition the entire missile on x/y/z axes, though.

Vorpal said:

I think rather than waste more time on it, I will just steal your method and credit you when I update my little "Minor Gameplay" mod. However could I bother you to give me a brief rundown on what all these lumps and markers in the wad are/do?

I wrote a LOADACS (simple auto-loader of custom scripts) with a custom library name. Then I made a same-named text-based lump, declared it a same-named library at the top, and then wrote an ACS script that replicated your DECORATE function's behavior, but with pitch retained. Then I right-clicked this lump and selected "Scripts -> Compile ACS (ZDoom)", and SLADE3 automatically generated the compiled script and markers around it. Finally, I replaced your DECORATE function with the respective ACS call.

Share this post


Link to post

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  
×