Old projectile spawning problem came back to haunt me

  • Two Factor Authentication is now available on BeyondUnreal Forums. To configure it, visit your Profile and look for the "Two Step Verification" option on the left side. We can send codes via email (may be slower) or you can set up any TOTP Authenticator app on your phone (Authy, Google Authenticator, etc) to deliver codes. It is highly recommended that you configure this to keep your account safe.

Undertaker989

New Member
Aug 13, 2003
39
0
0
Ok, I posted about a problem I had a while back about trying to get a seekingrocket that I spawned @ the explosion of an origional rocket to seek the target you were locked onto. I suceeded in getting a 2ond rocket to spawn, but it didn't seek b/c it didn't pass a seektarget onto the spawned seekrocket. I got stumped on trying to get the rocket to seek, so I moved onto coding other weapons.

I'm now working on the weapon w/ the seekingrocket, but this time I think I have the solution: <b>call the origional spawnprojectile function from the initial rocketlauncher (the one that passes the seektarget) instead of calling an explosion.</b> Here is teh code:

Code:
function Projectile Spawn2(Vector Start, Rotator Dir)
{
    local Projectile p;

    p = RocketLauncherC(Weapon).SpawnProjectile(Start, Dir);
    if ( p != None )
		p.Damage *= DamageAtten;
    return p;
}

the function is called instead of the explode function.

Here is the error I get apon UCC compile:
Code:
RocketProjC.uc(105) : Error, Bad or missing expression in '='
Compile aborted due to errors.
 

Payback

Ive got a big stick
Nov 21, 2002
94
0
0
ahl.action-web.net
What class is this in? Im wondering if (Weapon) relates to anything, and also whether RocketLauncherC has a spawnprojectile function.

Infact, even wierder. Your error message says the error is in a RocketProjC class, but your code refers to the RocketProjC class, implying that the code is in a different class from the error?
 

Undertaker989

New Member
Aug 13, 2003
39
0
0
RockeLauncherC is a copy of the RocketLauncher class w/ a few changes to specify different projectile classes/ect.. The rocketlauncherC class does have a spawnprojectile function.
 

Payback

Ive got a big stick
Nov 21, 2002
94
0
0
ahl.action-web.net
Ok. So what about the other bit?

Which class is the code you pasted from? Because (this is what I said before but explained more clearly).

You've pasted a bit of code - Now comparing that with how the standard rocket launcher works. It looks like that code you've pasted has come from a Fire class (something like RocketProjCFire.uc).

However, the error message you've pasted says that the error is in RocketProjC.uc, which you've not shown us any of the code from.

So either, you've shown us code that isnt related to the error message, or you've got that code in the RocketProjC.uc class, in which case it wouldnt work because the Weapon class doesnt have a variable called "Weapon" and I think it would also give an error about not casting to the same type.

If this doesnt help you track down the error can we see all of the code for both classes? It will help.
 

Doc_EDo

LEFT
Jan 10, 2002
755
0
0
Code:
  p = RocketLauncherC(Weapon).SpawnProjectile(Start, Dir);
Dont do that.
Do this:
Code:
P = Spawn(class'MyProjectileClass', self,, Start, Dir);
 

Undertaker989

New Member
Aug 13, 2003
39
0
0
Payback - The code I clipped is from RocketProjC, which is a copy of RocketProj that I'm going to modify. The code that I clipped was taken from the RocketFire class (and copied into the RocketProjC class) b/c I wanted to copy the way that they accessed the spawnprojectile class in the RocketLauncher class. The reason i wanted to use the Rocketlauncher class (RocketLauncherC in this case) is b/c it handles finding/aquiring the seek target, and I want the 2ond projectile spawned to seek the person you are locked onto.

I took the (weapon) variable out of the code, and it still gave me the error when I tried to compile.


Doc_Edo: I tried the code you suggested and it gave me:

Code:
type mismatch in parameter 2
 

Payback

Ive got a big stick
Nov 21, 2002
94
0
0
ahl.action-web.net
The projectile class doesnt have a reference to a weapon. It has a reference to an owner. So in your code you could check that the owner is a pawn, then find the pawns weapon. Store that weapon as a var then call the weapons spawn function.

I've not looked into it, but the projectiles owner could be the weapon, in which case just remove the pawn stuff. this is roughly what it should look like. You'll probably need to tinker.

Code:
function Projectile Spawn2(Vector Start, Rotator Dir)
{
	local Projectile p;
	local weapon pWep
 
 	Log ("Look in the log and you'll see what the owner is"@ owner);
 
	if (owner.IsA('Pawn') && pawn(Owner).Weapon != none)
 		pWep = pawn(Owner).Weapon;

 	p = RocketLauncherC(pWep).SpawnProjectile(Start, Dir);
 	if ( p != None )
		p.Damage *= DamageAtten;
   return p;
}
 

Undertaker989

New Member
Aug 13, 2003
39
0
0
Payback..the when I try to call the function Spawn2, I get "Error, Call to 'Spawn2': type mismatch in parameter 2"

Here's how I called it:

Code:
Spawn2(Location, dir);
 

Undertaker989

New Member
Aug 13, 2003
39
0
0
Thanks snake...that fixed the error. It compiles now.

Now to get the weapon working: I used the timer function to call spawn2 after 2 seconds (to get the effect of the missle stalling before the fuel ignites) and it actually called it b/c I see hte script log, which is as follows:

Code:
ScriptLog: Look in the log and you'll see what the owner is None
Warning: RocketProjC DM-Leviathan.RocketProjC (Function Bweapons.RocketProjC.Spawn2:0047) Accessed None

Here's the thing...

1. there is no owner as you predicted Payback...should I just eliminate the (owner) and call the function anyways?

2. there is an accessed none..I'm assuming b/c there is no owner.

EDIT: I found a different way to achieve the effect that I want w/ the missle. I made Spawn2 a simulated function that bumps up the speed of the rocket and spawns the rocket smoke trail and effects. The Spawn2 function is called in the timer function, and postnetbeginplay sets the timer for 1 second...so there is a pause and the simulated Spawn2 function is called to give the effect of the rocket going from slow to taking off real fast. Now I have to figure out why it isn't seeking...I have a feeling it has to do with the fact that I changed Velocity instead of speed (basically I set velocity = velocity * 9)...I'm going to try to change just the speed instead of velocity and see if the rocket seeks.
 
Last edited:

Payback

Ive got a big stick
Nov 21, 2002
94
0
0
ahl.action-web.net
Your getting an accessed none because of that log line. If you remove the log line the accessed none will disappear.
If you remove the check and just call the function anyway, you'll get an accessed none appear in the logs because there is no pWep to call the function for.

Try checking if the instigator is set to a value. The rocket must have a reference back to the players pawn that launched it so that any kills can be attributed to the correct player. (So switch any references to owner to say instigator instead)
 

Undertaker989

New Member
Aug 13, 2003
39
0
0
well..I'm not achieving the effect by spawning 2 rockets anymore, BUT, mentioning how I have to use the instigator instead of owner in some classes to give kill credit to the instigator WILL help me out w/ 2 of my other weapons for sure.

They are both weapons that spawn a projectile, which then spawns a small monster to hunt out and kill untill it is destroyed. I figure the instigator tip will come in handy for those weapons.
 

Payback

Ive got a big stick
Nov 21, 2002
94
0
0
ahl.action-web.net
You just need to make sure the instigator is set to a pawn. When the projectile hits a surface, it calls hurtradius. HurtRadius calls takedamage on any pawns within the radius.
One of the paramaters for the takedamage is the instigator...

So as long as your rockets instigators are pointing at the person that fired them, you dont really need to worry about the kill thing. The first rocket you launch will definatly have the right instigator set, the second may or may not depending on how you create it.
 

Undertaker989

New Member
Aug 13, 2003
39
0
0
ok, I have the effect I want w/ a single rocket (I'm no longer spawning a 2ond rocket), but there is still a slight problem:

The rocket waits too long before it really starts to seek. You have to be very far away from the target for any seek to occur. Seeing as I slowed the speed down to basically a crawl (150), I tried multiplying seek by 9 in every one of the instances it is used in seekingrocketprojC class and still the problem occurs.

I zipped up the .uc files and an .int file so you can compile the weapon and see what I'm talking about. If you don't want to go through the trouble of fooling around w/ the weapon, that's cool...I'm sure I'll eventually figure out what is going on with it. Just thought you'd like to take a look at this weapon thats creating all of the fuss.

Here's the zip:

Missle Launcher


p.s... it's not completed (obviously). I still need to fix the problem w/ the coronas/smoke trails that sporadically don't get destroyed and I am going to have different sounds/meshes/alt fire mode.