logo
Main

Forums

Downloads

Unreal-Netiquette

Donate for Oldunreal:
Donate

borderline

Links to our wiki:
Wiki

Walkthrough

Links

Tutorials

Unreal Reference

Usermaps

borderline

Contact us:
Submit News
Page Index Toggle Pages: [1] 2  Send TopicPrint
Hot Topic (More than 10 Replies) Prevent a pawn from damaging the player without a new playerpawn class (Read 4929 times)
SFJake
Full Member
***
Offline


Oldunreal member

Posts: 248
Joined: Aug 15th, 2010
Gender: Male
Prevent a pawn from damaging the player without a new playerpawn class
Nov 23rd, 2012 at 7:42am
Print Post  
Basically, I can't modify the core things in Unreal for my mod (mostly for compatibility) so this is a problem right now.

I just want some allies (humans) to not damage the player. Normally in an actor you can just change the TakeDamage function, but creating a new playerpawn has issues.

I can't modify the projectiles themselves either, since are mostly dealt from normal weapons -> and the allies can pick up new ones.


SO... Yeah. I'm not sure what to say. The only thing I do can modify is the ally pawn in question, but I don't see how I can prevent it from damaging players!?
  
Back to top
 
IP Logged
 
BobIsUnreal
God Member
*****
Offline


gonna be dead soon, gg

Posts: 764
Joined: Apr 12th, 2010
Gender: Male
Re: Prevent a pawn from damaging the player without a new playerpawn class
Reply #1 - Nov 23rd, 2012 at 1:29pm
Print Post  
If your using 227, gamerules can be used, even with jcoopz.

relevant functions to subclass:

// Called whenever a pawn takes damage.
function ModifyDamage( Pawn Injured, Pawn EventInstigator, out int Damage, vector HitLocation, name DamageType, out vector Momentum );

return nul when injured = playerpawn and eventinstigator = pawnX
« Last Edit: Nov 23rd, 2012 at 3:56pm by BobIsUnreal »  

[REM_img]http://i.imgur.com/V3OSsDu.gif.disable[/img]http://i.imgur.com/JOu38Gs.gif
Back to top
IP Logged
 
SFJake
Full Member
***
Offline


Oldunreal member

Posts: 248
Joined: Aug 15th, 2010
Gender: Male
Re: Prevent a pawn from damaging the player without a new playerpawn class
Reply #2 - Nov 23rd, 2012 at 8:21pm
Print Post  
Thats interesting, but I'm afraid I have no idea how to use it? I tried, but I don't get it, don't know where to put it either.
  
Back to top
 
IP Logged
 
GreatEmerald
Oldunreal MasterPoster
*
Offline


The Great Emerald

Posts: 5361
Location: Vilnius, Lithuania
Joined: May 21st, 2007
Gender: Male
Re: Prevent a pawn from damaging the player without a new playerpawn class
Reply #3 - Nov 23rd, 2012 at 10:29pm
Print Post  
  
Back to top
WWW  
IP Logged
 
BobIsUnreal
God Member
*****
Offline


gonna be dead soon, gg

Posts: 764
Joined: Apr 12th, 2010
Gender: Male
Re: Prevent a pawn from damaging the player without a new playerpawn class
Reply #4 - Nov 23rd, 2012 at 10:30pm
Print Post  
usage would be something like this...

Code
Select All
class spawnsrule extends Mutator;

function PreBeginPlay()
{
	local GameRules G;

	G = Spawn(class'freindrules');
	if( Level.Game.GameRules==None )
		Level.Game.GameRules = G;
	else Level.Game.GameRules.AddRules(G);
	Destroy();
}


---------------------------------------

class freindrules expands GameRules;

function ModifyDamage(
Pawn Injured, Pawn EventInstigator, out int Damage, vector HitLocation, name DamageType, out vector Momentum )
{

	if(Injured.isA('PlayerPawn') && EventInstigator.isA('freidlypawnguyclass'))
	{
        Damage=0;
	}


} 

  

[REM_img]http://i.imgur.com/V3OSsDu.gif.disable[/img]http://i.imgur.com/JOu38Gs.gif
Back to top
IP Logged
 
SFJake
Full Member
***
Offline


Oldunreal member

Posts: 248
Joined: Aug 15th, 2010
Gender: Male
Re: Prevent a pawn from damaging the player without a new playerpawn class
Reply #5 - Nov 23rd, 2012 at 11:54pm
Print Post  
Oooh, I had it all wrong.

Thanks a lot.

I got it to work in SP even without mutators.

I can also just use the mutator in SP.

However, I can't get it to work in JCoopZ1. I hook the mutator as it should be, (the hookmutator show command tells me its loaded) but it just does not work there.

<-<
  
Back to top
 
IP Logged
 
BobIsUnreal
God Member
*****
Offline


gonna be dead soon, gg

Posts: 764
Joined: Apr 12th, 2010
Gender: Male
Re: Prevent a pawn from damaging the player without a new playerpawn class
Reply #6 - Nov 24th, 2012 at 6:18am
Print Post  
i went ahead and tested it , lots of logging later ,
it seems like jcoopz isnt honoring the outputed damage ,
or i am doing somthing wrong too.
It is  clearly proccesing the damage calls tho,
but damage isnt being returned back to the playerpawn at all.


ZOMBIE??????????

for reference this is what i did
Code
Select All
// Called whenever a pawn takes damage.
function ModifyDamage( Pawn Injured, Pawn EventInstigator, out int Damage, vector HitLocation, name DamageType, out vector Momentum )
{
   log("damagecall");
	if(Injured.isA('PlayerPawn'))
	{
     log("playerpawn");
        if (EventInstigator.isA('krall'))
        {
        log("damage return null");
        Damage=0;
        }
	}



} 



and ended up with a bunch of "damage return null" mesages while getting hurt mortally.
I did not check to see if numbers were being recived /changed.
« Last Edit: Nov 24th, 2012 at 7:25am by BobIsUnreal »  

[REM_img]http://i.imgur.com/V3OSsDu.gif.disable[/img]http://i.imgur.com/JOu38Gs.gif
Back to top
IP Logged
 
SFJake
Full Member
***
Offline


Oldunreal member

Posts: 248
Joined: Aug 15th, 2010
Gender: Male
Re: Prevent a pawn from damaging the player without a new playerpawn class
Reply #7 - Nov 24th, 2012 at 8:05am
Print Post  
Well, I tried to prevent damage done to a Krall, and -that- worked in JCoopZ.

So, my guess is the new player classes in JCoopZ just don't know about ModifyDamage and probably overwrites the section of the code. Or something.
  
Back to top
 
IP Logged
 
Zombie
Forum Administrator
The One Who Wanted To Have A Special Title In Forum
*****
Offline


Living Dead

Posts: 323
Joined: May 9th, 2002
Re: Prevent a pawn from damaging the player without a new playerpawn class
Reply #8 - Nov 24th, 2012 at 4:08pm
Print Post  
It looks like IsUnreal discovered a bug in the JCoopZ proxy to GameRules.ModifyDamage() support for jzPlayerPawn. I made a mistake by not giving the Damage parameter an 'out' modifier. So a modified damage value is never passed back to the source function meaning it cannot do what it is designed for.

You might be able to develop a workaround method that does not use GameRules by examining Pawn.TakeDamage(). One may be able to create an Inventory class with Inventory.ReduceDamage() overridden, and have that always spawned onto players. However, there is no reference to a pawn instigator so your only filtering method would be from an ally-only DamageType.

If you are able to your best chance would be to modify the ally pawn in some way such as changing its 'bIsPlayer' property so that the gametype friendly fire logic nullifies the damage. Ideally both 'bIsPlayer=True', and 'Default.bIsPlayer=True' sometime after PreBeginPlay. When the pawn dies or is destroyed set back to false.


-Zombie
  
Back to top
 
IP Logged
 
SFJake
Full Member
***
Offline


Oldunreal member

Posts: 248
Joined: Aug 15th, 2010
Gender: Male
Re: Prevent a pawn from damaging the player without a new playerpawn class
Reply #9 - Nov 24th, 2012 at 5:35pm
Print Post  
Thing is:

I'm using human pawns -> they're scripted pawns, but with some hacky player-design so they pick up a weapon and fight alongside you.

That brings an issue with the fact that they can randomly pick up new weapons and literally fight with anything that comes into their hands, meaning its hardly controllable. It would be really easy to prevent playerpawn damage if they used only specific attacks, but sadly they don't.

Of course, maybe I could just alter that and give them custom weapons with custom projectiles to nullify the damage.

On the idea of an inventory item -> I've thought of creating an item that nullifies damage from certain sources but failed to do that. All I would need is to find a way to see who did the damage, but in the armor absorption only the damage & damagetype is remembered. If I could get the damage instigator through an item, then this would be a solution.

In any case, I'll check out your possibilities. Thanks.
  
Back to top
 
IP Logged
 
BobIsUnreal
God Member
*****
Offline


gonna be dead soon, gg

Posts: 764
Joined: Apr 12th, 2010
Gender: Male
Re: Prevent a pawn from damaging the player without a new playerpawn class
Reply #10 - Nov 24th, 2012 at 6:20pm
Print Post  
zombie , cant you just fix it?,
i mean ,all  the playerpawn functions and gamerules are sitting in files on the serverside as far as i can tell....
( cant really say what in them tho unfortinitly)


as another weird thought , if you know who is receiving the damage and how much , you could make up for the difference . ie playerpawn.heath ++ damage ammount so that they dont "takedamage" etc
  

[REM_img]http://i.imgur.com/V3OSsDu.gif.disable[/img]http://i.imgur.com/JOu38Gs.gif
Back to top
IP Logged
 
SFJake
Full Member
***
Offline


Oldunreal member

Posts: 248
Joined: Aug 15th, 2010
Gender: Male
Re: Prevent a pawn from damaging the player without a new playerpawn class
Reply #11 - Nov 24th, 2012 at 8:39pm
Print Post  
But armors would be damaged, wouldn't they? So it wouldn't quite work.
  
Back to top
 
IP Logged
 
Zombie
Forum Administrator
The One Who Wanted To Have A Special Title In Forum
*****
Offline


Living Dead

Posts: 323
Joined: May 9th, 2002
Re: Prevent a pawn from damaging the player without a new playerpawn class
Reply #12 - Nov 24th, 2012 at 8:59pm
Print Post  
I will make a new public release that includes the bug fix. Considering 227i was finally released to the public I want to look over any other tiny corrections/improvements I can do quickly first. I really hoped something would not turn up broken after so long. Sad


-Zombie
  
Back to top
 
IP Logged
 
SFJake
Full Member
***
Offline


Oldunreal member

Posts: 248
Joined: Aug 15th, 2010
Gender: Male
Re: Prevent a pawn from damaging the player without a new playerpawn class
Reply #13 - Nov 24th, 2012 at 9:57pm
Print Post  
Awesome! Thanks. I did not dare ask.

And I assure you, someone will find something else broken down the line, even if its in years. Thats always how it is, I'm sure you know it better than I do.
  
Back to top
 
IP Logged
 
Zombie
Forum Administrator
The One Who Wanted To Have A Special Title In Forum
*****
Offline


Living Dead

Posts: 323
Joined: May 9th, 2002
Re: Prevent a pawn from damaging the player without a new playerpawn class
Reply #14 - Dec 1st, 2012 at 4:08am
Print Post  
Released. News posted at the following link.

http://174.132.89.98/~hypernl/viewtopic.php?t=1028


-Zombie
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: [1] 2 
Send TopicPrint
Bookmarks: del.icio.us Digg Facebook Google Google+ Linked in reddit StumbleUpon Twitter Yahoo