final function?

Discussions about Coding and Scripting
Post Reply
User avatar
Rakiayn
Masterful
Posts: 550
Joined: Fri Aug 28, 2009 3:33 pm

final function?

Post by Rakiayn »

I am working on some monster classes, and I want to alter the projectile fire code. only problem is the code in the scriptedpawn class is a 'final function', so when I copy the code to my class to overwrite it, it wont compile.
any idea how i can still manage to change this function to my liking?

Code: Select all

final function FireProjectile(vector StartOffset, float Accuracy)
{
	local vector X,Y,Z, projStart;

	MakeNoise(1.0);
	GetAxes(Rotation,X,Y,Z);
	projStart = Location + StartOffset.X * CollisionRadius * X 
					+ StartOffset.Y * CollisionRadius * Y 
					+ StartOffset.Z * CollisionRadius * Z;
	spawn(RangedProjectile ,self,'',projStart,AdjustAim(ProjectileSpeed, projStart, Accuracy, bLeadTarget, bWarnTarget));
}
User avatar
Feralidragon
Godlike
Posts: 5493
Joined: Wed Feb 27, 2008 6:24 pm
Personal rank: Work In Progress
Location: Liandri

Re: final function?

Post by Feralidragon »

You can't.
Final functions are exactly that: functions that cannot be overriden in subclasses.

The only way around that is to create a new function, let's say a "FireProjectile2(vector StartOffset, float Accuracy)", and change all the function calls in your subclass from "FireProjectile" to "FireProjectile2".
User avatar
Rakiayn
Masterful
Posts: 550
Joined: Fri Aug 28, 2009 3:33 pm

Re: final function?

Post by Rakiayn »

thnx. I will try this. I wonder why they made it a final function.
User avatar
Feralidragon
Godlike
Posts: 5493
Joined: Wed Feb 27, 2008 6:24 pm
Personal rank: Work In Progress
Location: Liandri

Re: final function?

Post by Feralidragon »

Don't be surprised, you will find some weird coding decisions along the way (as in any game ever released):
- final functions that shouldn't be
- constant variables that shouldn't be
- functions implemented in a subclass when they should be implemented in the superclass
- code that should be latent but isn't
- just dumb code
- etc
Post Reply