PDA

View Full Version : There are no stupid questions...


yurch
1st Oct 2001, 10:18 PM
Alright. I wanna know.
Is there a way to replace/override a function without reclassing everything after it?
For example: changing some attributes of TournamentWeapon without reclassing all the weapons...
(Not the exact thing I am doing, but it would be a similar process)
Or do I have to take the "industrious" way out?

navboy
1st Oct 2001, 11:47 PM
Pretty new to this myself, but i've subclassed several actors at this point and have a general idea how that goes ...

If you subclass an actor, you only need to script the functions, events, states etc. that you wish to change. Those will override their counterparts in the parent, everything else will be inherited just fine.

One thing to watch out for is that certain functions (particularly ones like PreBeginPlay etc) do important housekeeping tasks, and you have to be careful not to wipe them out unless that's really what you want to do. That's why you'll often see stuff like "Super.PreBeginPlay()" or "Super.ActorEntered()" and so forth in child functions ... You make your changes then let the parent run its normal tasks. HTH

yurch
2nd Oct 2001, 09:14 AM
I can make a class file that overrides the parent class fine, but none of the subordinate classes are using the changes.
Why do I need to put in the mutator child in order to get the program to "accept" these changes?
BTW, I am editing a mod. Is that any different?

navboy
2nd Oct 2001, 10:50 AM
ack sorry i misunderstood what you're doing. No i've never done that, and ironically i tried last week for a couple days to get a new gametype working (subclassed DeathMatchPlus) but never could (posted about it a few threads down). Good luck, i'm sure someone in here will know the answer.

TaoPaiPai
2nd Oct 2001, 11:06 AM
What's your problem? I don't understand...
If you want to make a function that doesn't overwrite a parent function...well just make it another function with another name.
If you want to overwrite a function in a way that it makes something particular with class A but with cother classes (B and C ) it does the usual work from the parent class,this would not be difficult:
(let's suppose we're talking about the fire function)
make it like that:
step 1.add a booleanvariable in the class declaration

var bool bStandardWeapon;


step 2. rewrite the function you want like that:


function fire(float value)
{
if (bStandardWeapon)
super.fire(value);
else
doWhatYouWantHere
}


then in the default properties of class B and C write

defaultProperties
{
bStandardWeapon=true
}

(don't need to alter the default properties of weapon A

yurch
2nd Oct 2001, 12:01 PM
I will use tournament weapon again as an example...
Lets say I wanted to change
function DropFrom(vector StartLocation)
I want to change this function around, and have all child classes inherit these changes.
I would make a subclass of TournamentWeapon, no?
Now I wan't to have it so I Do not have to mess with the child classes they need to be able to inherit these things without my intervention. I cannot make any changes to them. This would destroy any support for additional weapons and requre me to do a helluva lot of extra subclassing.
I may just lack the simple knowlage of a certain function, or perhaps this can't be done this way.
I need to know a way of making the child of TournamentWeapon, without messing with anything else. Right now I can add the subclass, but the desired changes are not there in-game.
This can be mutator or gametype implementation, I don't mind.

ca
2nd Oct 2001, 12:43 PM
No this isn't possible. You would have to subclass tournamentweapon, make your changes, then make subclasses for all of UT's weapons and make them children of your new tournamentweapon subclass while just copying over the code. Then throw in a mutator or something to replace the normal UT weapons with your new set.

It's a pain, but it's about as close as you can get to doing what you want...

yurch
2nd Oct 2001, 12:58 PM
Arg...
Alright then, thought so. Its even harder considering I have to reclass all the infiltration weapons and attachments and ammo and everythin else :D
Why can't I just make a normal mutator ;)