Announcement
Collapse
No announcement yet.
General OOP question
Collapse
X
-
legacy-Psyk repliedThat isn't the best way of doing it. There is a function in the mutator class called checkreplacement. That is used to do exactly what you want to do, it replaces one class with another. I suggest you download the source code so you can look at the function. You can find the source at http://udn.epicgames.com .
-
legacy-Eyaw_Nayr repliedI have looked at them, but not really spent alot of time with them. I have one question about the codeblock. When you are declaring the variables, you use 'WB' and 'MP'. What is the purpose of that?
And thanks very much for the help!
Eyaw
Leave a comment:
-
legacy--GSF-JohnDoe repliedEyaw, have you done the mutator tutorials on the Wiki? I think you'll find them to be a great help.
Leave a comment:
-
legacy-MarZer repliedOriginally posted by Eyaw_Nayr
Alright, I have finally created the class (now that I understand what you said) and it works great. I called it UberMiniGun. But I am unsure how I translate that to a mutator that replaces all the miniguns with mine. Help?
Eyaw
Code:class UberMiniGun extends Mutator; var class<Weapon> NewWeaponType; var class<Weapon> OldWeaponType; function PreBeginPlay() { local xWeaponBase WB; local MiniGunAmmoPickup MP; foreach AllActors(class'xWeaponBase', WB) //look through all the bases { if (WB.WeaponType == OldWeaponType) //if they spawn the minigun WB.WeaponType = NewWeaponType; //alter them to spawn the uberminigun } foreach AllActors(class'MiniGunAmmoPickup', MP) //look for minigun ammo pickups MP.Destroy(); //destroy them since we don't need them } defaultproperties { NewWeaponType=class'YourPackage.UberMiniGun' OldWeaponType=class'XWeapons.Minigun' }
EDIT: Just tested it. Works like a charm. I'm sorry I posted a code block (I know you said you didn't want people doing that), it was just easier to do than explain it (doesn't really need explaining anyway - read the code comments)
Leave a comment:
-
legacy-Eyaw_Nayr repliedAlright, I have finally created the class (now that I understand what you said) and it works great. I called it UberMiniGun. But I am unsure how I translate that to a mutator that replaces all the miniguns with mine. Help?
Eyaw
Leave a comment:
-
legacy-Eyaw_Nayr repliedOk, here is a first try:
PHP Code:class FullAmmo extends Mutator;
function PreBeginPlay()
{
local int NewAmmoUsage;
foreach AllActors('MiniGunPickup' NewMachineGun)
{
NewMachineGun.AmmoPerFire=0;
}
But am I kinda sorta in the same universe as I need to be?
Eyaw
Leave a comment:
-
legacy-MarZer repliedNo specific page dealing with what you want to do, but there is one that deals with iterators:
http://wiki.beyondunreal.com/wiki/Iterator
Basically what you want to do is in prebeginplay(), do a foreach dynamic actors(class'XWeaponBase', Base (or some name) ) and check if they have your custom gun pickup class and if they don't, replace their gun pickup class with your gun pickup class. Or, if you want it to be an instagib scenario (in which all players spawn with the weapon and nothing else), take a look at the MutInstagib code.
Leave a comment:
-
legacy-Eyaw_Nayr repliedI know that it would be a PreBeginPlay function, but that is as far as my comprehension goes. Is there a specific page in the Wiki that deals with this? I dont anyone posting codeblocks, I like to do it myself.
Leave a comment:
-
legacy-MarZer repliedNo, you can't do that, but you shouldn't really need to. You would need to create a new weapon class and a new WeaponFire class. In the WeaponFire class you would set AmmoPerFire=0 in the default properties, and boom! Doesn't use any ammo!
You could make a simple mutator that iterated though all the existing machine guns and replaced them with yours at the start of the match.
Leave a comment:
-
legacy-Eyaw_Nayr started a topic General OOP questionGeneral OOP question
Hello,
I am very new to UScript and OOP in general, but not programming. I have a question:
Say I am writing a mutator to give the MachineGun unlimited ammo. I want the mutator to inherit the properties of a Mutator, but I also need it to inherit the properties of the machine gun. Is there a way to extend multiple classes?
EyaTags: None
Leave a comment: