Tripwire Interactive Forums

Go Back   Tripwire Interactive Forums > Red Orchestra 2 / Rising Storm Forums > RO2/RS Modifications > Coding

Reply
Click here to go to the first Dev post in this thread.  
Thread Tools Display Modes
  #1  
Old 04-21-2012, 05:54 AM
LordGleedo's Avatar
LordGleedo LordGleedo is offline
Senior Member
 
Join Date: Jul 2010
Location: Bucks, England
Posts: 800
Default Extending ROPawn issue

Morning,

I have a custom pawn class that extends ROPawn as I want to override a couple of functions, but it's basically just a shell right now with some logging:
Code:
class FTPawn extends ROPawn;

function bool Died(Controller Killer, class<DamageType> damageType, vector HitLocation)
{
	`Log(">>> DEBUG : Pawn Died", , 'FTPawn');

       super.Died(Killer, damageType, HitLocation);
}

DefaultProperties
{
}
I also have the following set in my main game class default properties to ensure my pawn class gets used:
Code:
AIPawnClass=class'TOGAFT.FTPawn'
DefaultPawnClass=class'TOGAFT.FTPawn'
This is the same way I have my game mode setup in the UDK version I did a while back.

However, my pawn class is not getting used like it does in the UDK. The gameclass is still somehow using ROPawn instead.

All my other custom classes that extend/override are being used correctly, just not my pawn class

Any thoughts?
Reply With Quote
  #2  
Old 04-21-2012, 07:44 AM
Mekhazzio's Avatar
Mekhazzio Mekhazzio is offline
Senior Member
 
Join Date: Sep 2011
Posts: 1,104
Default

I don't expect that those "default pawn class" settings are ever used for anything. ROPawns are never spawned by the game, and if you're extending something off of those, I doubt they'd work right anyway, because it's two steps up in the hierarchy from the ones the game uses.

The actual character objects spawned by the game are one of the ROGameContent.RO(Allied|Axis)PawnLevel(#)(Role) classes, retrieved from settings in the ROGameInfo. Do the console command "getall ROPawn class" on a live server to see an example.

If you want to change which classes get spawned, the ROGameInfo is the place to start. You might be able to just find the current instance, edit its variables at runtime, and be done with it nice and cleanly.

And yes, that means that overriding pawn behavior requires you to subclass every single one of the existing ones. All 300 of them. Just like I had to do 91 subclasses of the bullets and weapons for Antilag. Be prepared to get very familiar with the UnrealScript preprocessor

It's a pain in the butt and it makes your final filesize proportionally larger, so it's worth the while to try to do it in any other way possible. Your Died override is better off done in the mutator PreventDeath hook, for instance.
Reply With Quote
  #3  
Old 04-21-2012, 09:49 AM
LordGleedo's Avatar
LordGleedo LordGleedo is offline
Senior Member
 
Join Date: Jul 2010
Location: Bucks, England
Posts: 800
Default

Quote:
Originally Posted by Mekhazzio View Post
Your Died override is better off done in the mutator PreventDeath hook, for instance.
Thank you, that appears to be good enough
Reply With Quote
  #4  
Old 04-22-2012, 10:48 AM
LordGleedo's Avatar
LordGleedo LordGleedo is offline
Senior Member
 
Join Date: Jul 2010
Location: Bucks, England
Posts: 800
Default

It looks like I am going to have to subclass the lot as I need to alter more than a few vars - i need to change TakeDamage amongst other things....

So if that is the case, do I need to put my version of TakeDamage into each subclass that I created?
Reply With Quote
  #5  
Old 04-22-2012, 11:14 AM
Mekhazzio's Avatar
Mekhazzio Mekhazzio is offline
Senior Member
 
Join Date: Sep 2011
Posts: 1,104
Default

Yep. I can post the Antilag source, if you want to see a (less in)convenient way of building the preprocessor skeleton for that, so you can let the make process handle the upkeep for you.

But there's a mutator hook for TakeDamage too: Mutator.NetDamage. It's still live in ROPawn.
Reply With Quote
  #6  
Old 04-22-2012, 11:29 AM
LordGleedo's Avatar
LordGleedo LordGleedo is offline
Senior Member
 
Join Date: Jul 2010
Location: Bucks, England
Posts: 800
Default

Quote:
Originally Posted by Mekhazzio View Post
Yep. I can post the Antilag source, if you want to see a (less in)convenient way of building the preprocessor skeleton for that, so you can let the make process handle the upkeep for you.
I have absolutely no idea what you just said lol

What the heck is a preprocessor skeleton?
Reply With Quote
  #7  
Old 04-22-2012, 11:53 AM
Mekhazzio's Avatar
Mekhazzio Mekhazzio is offline
Senior Member
 
Join Date: Sep 2011
Posts: 1,104
Default

A preprocessor is a system that skims and edits the code files before they're fed to the compiler. All those `ifdef lines you see sprinkled all over the stock code are preprocessor commands.

Of note in this case is that you can use the preprocessor to shortcut the class-building for you. You can leave all your code in one easy-to-maintain file and simply have the preprocessor insert it automatically into a bunch of files that are so small & simple that you can just make them once (ideally with a script or batch file) and then never have to touch them again. In short, you make the skeleton, and let the computer do the work of fleshing it out.

...because keeping up that many classes by hand is insanity.
Reply With Quote
  #8  
Old 04-22-2012, 12:21 PM
LordGleedo's Avatar
LordGleedo LordGleedo is offline
Senior Member
 
Join Date: Jul 2010
Location: Bucks, England
Posts: 800
Default

Ah gotcha. So I could in theory just use `include in all my sub classes to point to my file that has the common code in?

Code:
class FTAxisPawnLevel6Assault extends ROAxisPawnLevel6Assault;

`include(FTCommonPawn.uci)

DefaultProperties
{
}
Something like that ^
Reply With Quote
  #9  
Old 04-22-2012, 12:34 PM
Mekhazzio's Avatar
Mekhazzio Mekhazzio is offline
Senior Member
 
Join Date: Sep 2011
Posts: 1,104
Default

That's the gist of it, yep. You could also use preprocessor macros to make sure that any variables or function calls get tailored to the file as well, or to make sure that some sections show up only in some files. It's a simple preprocessor, compared to some full-blown languages out there, but it's still capable of powerful things that can save you a lot of time and hassle.

Last edited by Mekhazzio; 04-22-2012 at 12:35 PM.
Reply With Quote
  #10  
Old 04-22-2012, 12:39 PM
LordGleedo's Avatar
LordGleedo LordGleedo is offline
Senior Member
 
Join Date: Jul 2010
Location: Bucks, England
Posts: 800
Default

That's a great help, thank you sir
Reply With Quote
  #11  
Old 04-23-2012, 12:07 PM
Le0's Avatar
Le0 Le0 is offline
Senior Member
 
Join Date: Sep 2011
Location: Neuchatel, Switzerland
Posts: 638
Default

Quote:
Originally Posted by Mekhazzio View Post
Yep. I can post the Antilag source, if you want to see a (less in)convenient way of building the preprocessor skeleton for that, so you can let the make process handle the upkeep for you.

But there's a mutator hook for TakeDamage too: Mutator.NetDamage. It's still live in ROPawn.
Would you mind posting your source? I'd be also interested to see how you did it.
Reply With Quote
  #12  
Old 04-28-2012, 03:35 AM
Mekhazzio's Avatar
Mekhazzio Mekhazzio is offline
Senior Member
 
Join Date: Sep 2011
Posts: 1,104
Default

Quote:
Originally Posted by Le0 View Post
Would you mind posting your source? I'd be also interested to see how you did it.
Posted here
Reply With Quote
  #13  
Old 04-30-2012, 03:58 PM
Le0's Avatar
Le0 Le0 is offline
Senior Member
 
Join Date: Sep 2011
Location: Neuchatel, Switzerland
Posts: 638
Default

Thanks a lot, this will be interesting
Reply With Quote
  #14  
Old 05-07-2012, 08:49 AM
LordGleedo's Avatar
LordGleedo LordGleedo is offline
Senior Member
 
Join Date: Jul 2010
Location: Bucks, England
Posts: 800
Default

Right, thought id post back in this thread as it's relevant to my current issue...

As mentioned above, I have created a bunch of classes that extend each of the games player class (AxisPawnLevel1Eng, AxisPawnLevel2Eng etc), each of which has an include so they all run some common code which works fine.

Now when in-game, when I aim down my sights and press my use key, If I am looking at a team mate that is in a certain state, I need to set a variable on that players custom pawn class (which ever one it may be).

I have done the trace code and it writes some debug info to screen:
Code:
ClientMessage("Hit: "$HitActor$"  class: "$HitActor.class.outer.name$"."$HitActor.class);
Would write out something like:
Code:
Hit: FTAxisPawnLevel1Engineer etc
How can I set a variable if the class could be one of several possible classes?

If this were c# I would have created an interface which each of my custom class inherits so I could call it with confidence...

I could of course have a rather large case statement doing IsA('FTblah...') and then just cast it, but i'm hoping there is a more quick way.

Any thoughts appreciated
Reply With Quote
  #15  
Old 05-07-2012, 01:51 PM
Ducky's Avatar
Ducky Ducky is offline
Moderator
 
Join Date: May 2011
Location: Netherlands
Posts: 4,730
Default

Try the Implements or Inherits class specifiers.

For more info:
Class Specifiers (scroll down)
Interfaces
__________________
Reply With Quote
  #16  
Old 05-08-2012, 07:56 AM
LordGleedo's Avatar
LordGleedo LordGleedo is offline
Senior Member
 
Join Date: Jul 2010
Location: Bucks, England
Posts: 800
Default

Quote:
Originally Posted by Ducky View Post
Try the Implements or Inherits class specifiers.

For more info:
Class Specifiers (scroll down)
Interfaces
I think "Implements" might be what I need - I had no idea interfaces would possible in UE3

Thanks.
Reply With Quote
  #17  
Old 05-08-2012, 03:05 PM
LordGleedo's Avatar
LordGleedo LordGleedo is offline
Senior Member
 
Join Date: Jul 2010
Location: Bucks, England
Posts: 800
Default

Think I must be being thick here...

I have created an interface called FTPawnIntf and defined a function inside it and then added that to all my custom pawn classes.

Code:
interface FTPawnIntf;

function TestInterface();
and

Code:
class FTAxisPawnLevel6SquadLeaderW extends ROAxisPawnLevel6SquadLeaderW implements(FTPawnIntf);
If I try a compile without adding the function defined in my interface to the custom pawn class, I get the expect errors, so I know that works.

So I implement my Interface function inside the custom pawn class and it compiles without error

Next in my player controller class I need to test for the interface which I try and do like so:
Code:
if ( FTPawnIntf(HitActor) != none)
{
     // do stuff here....
}
and according to this tutorial, this should work:
Code:
local FTPawnIntf myIntf;

myIntf = FTPawnIntf(HitActor);

if ( myIntf != none)
{
     // do stuff here....
}
Upon compiling I get the following error:
Code:
Error, Missing opening '(' in Implements list
According to the documentation, the above should work:
http://udn.epicgames.com/Three/Unrea...nterfaces.html

My eyes have glazed over lol

Last edited by LordGleedo; 05-09-2012 at 01:22 PM.
Reply With Quote
  #18  
Old 05-08-2012, 05:22 PM
Ducky's Avatar
Ducky Ducky is offline
Moderator
 
Join Date: May 2011
Location: Netherlands
Posts: 4,730
Default

In case of interfaces, then you need to make a reference to your interface. You will get something like:

Code:
class FTAxisPawnLevel6SquadLeaderW extends ROAxisPawnLevel6SquadLeaderW implements(FTPawnIntf);

var FTPawnIntf  IntRef;

function BlaBlaBla(Actor HitActor)
{
    if (IntRef(HitActor) != none)
    {
        // do stuff here....
    }
}
This line if (IntRef(HitActor) != none) is not a typo
__________________

Last edited by Ducky; 05-08-2012 at 05:24 PM.
Reply With Quote
  #19  
Old 05-09-2012, 01:19 PM
LordGleedo's Avatar
LordGleedo LordGleedo is offline
Senior Member
 
Join Date: Jul 2010
Location: Bucks, England
Posts: 800
Default

I believe this issue is an SDK problem.

If I do the exact same thing in the latest UDK, it compiles just fine!
Reply With Quote
  #20  
Old 05-09-2012, 02:27 PM
Ducky's Avatar
Ducky Ducky is offline
Moderator
 
Join Date: May 2011
Location: Netherlands
Posts: 4,730
Default

Quote:
Originally Posted by LordGleedo View Post
I believe this issue is an SDK problem.

If I do the exact same thing in the latest UDK, it compiles just fine!
Best to post it on the bugs section. Then at least it will get TWIs attention.
__________________
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 09:24 AM.


Powered by vBulletin®
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Copyright 2005 - 2014, Tripwire Interactive, LLC