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) Best way to handle lingering hurtbox/area for projectiles? (Read 1002 times)
Skywolf
Betatester
Offline


Just placeholding...

Posts: 774
Joined: Aug 2nd, 2009
Re: Best way to handle lingering hurtbox/area for projectiles?
Reply #15 - Dec 10th, 2017 at 3:52pm
Print Post  
Sorry for the slow and infrequent replies. Work it keeping me busy.

Anyway, this brings us back to the whole ZoneInfo style damage dealing. If I can make some kind of additional variable per pawn to keeps track of what the last time they were hurt was you can avoid what Masterkent says.

Then If two splats overlap from different players (On team A and B) and friendly fire is disabled then the splat from a player on the same side (lets say team A) doesn't damage players from team A and thus doesn't change this variable for him. So that when the splat from team B checks for players that haven't been damaged yet it sees that the enemy player from Team A still has its LastHitTime variable above the threshold thus allowing it to deal damage to that player.

If both splats are from team B then one will damage the player from team A and the next one will see that LastHitTime hasn't passed the threshold (because the first splat already changed this) and thus doesn't deal additional damage.

You then make the game check the splats in newest to oldest in the array (assuming that new ones are added to the end or beginning and now put somewhere random) to make the player that shot last get the kill.

The challenge here is to make all the splats talk to each other about the players their LastHitTime Variable. But how to do that I have no idea.


About the pawn kill detector. How would you go around accessing GameRules.NotifyKilled from a Mutator? GameRules isn't a parent of Mutator so it isn't as easy as just writing a simple function called NotifyKilled or something.
  

I hate it when people ask me what my favorite game is. Just try to explain you're not talking about Unreal Tournament Roll Eyes.
Back to top
 
IP Logged
 
Masterkent
Developer Team
Offline



Posts: 983
Location: Russia
Joined: Apr 5th, 2013
Gender: Male
Re: Best way to handle lingering hurtbox/area for projectiles?
Reply #16 - Dec 10th, 2017 at 7:12pm
Print Post  
Skywolf wrote on Dec 10th, 2017 at 3:52pm:
Then If two splats overlap from different players (On team A and B) and friendly fire is disabled then the splat from a player on the same side (lets say team A) doesn't damage players from team A and thus doesn't change this variable for him.

On the side that causes a damage, there is no flawless way to determine if there is a protection from friendly fire (or a different kind of protection) for a particular pawn and how much damage such a protection is able to absorb. The information about how much damage should be reduced is retrieved by pawns - they call GameRules.ModifyDamage and GameInfo.ReduceDamage to determine the actual damage amount which is then divided between armors and health. These functions are not necessarily pure (a pure function would take an incoming damage amount and return the adjusted damage amount without producing any side effects); in particular, they may count damage amount for various purposes and calling them more than once per the same damage may produce wrong results. Note also that protection from friendly fire is not necessarily either 0% or 100% (although usually it's one these two values). For example, dots used 50% FF damage absorbtion on his Coop server.

Quote:
How would you go around accessing GameRules.NotifyKilled from a Mutator? GameRules isn't a parent of Mutator so it isn't as easy as just writing a simple function called NotifyKilled or something.

Of course, you need to write a subclass of Engine.GameRules and spawn an instance of your class. A canonical implementation would look like this:

Code
Select All
class MutatorName expands Mutator;

event BeginPlay()
{
	Spawn(class'MutatorNameGR', self);
} 



Code
Select All
class MutatorNameGR expands GameRules;

var MutatorName MutatorRef;

event BeginPlay()
{
	MutatorRef = MutatorName(Owner);
	if (MutatorRef == none)
	{
		Destroy();
		return;
	}

	if (Level.Game.GameRules == none)
		Level.Game.GameRules = self;
	else
		Level.Game.GameRules.AddRules(self);
}

function NotifyKilled(Pawn Victim, Pawn Killer, name DamageType)
{
	// Here you handle kills
	// Properties and functions of the underlying mutator can be accessed through MutatorRef
}

defaultproperties
{
	bHandleDeaths=True
} 


  
Back to top
 
IP Logged
 
Skywolf
Betatester
Offline


Just placeholding...

Posts: 774
Joined: Aug 2nd, 2009
Re: Best way to handle lingering hurtbox/area for projectiles?
Reply #17 - Dec 11th, 2017 at 2:47pm
Print Post  
In that case I give up. There seems to be no easy way to handle this without serious modifications of existing classes Sad

Is it atleast possible to avoid the splats of each instigator from stacking? This would still mean that multiple players can stack the damage but considering the splats don't stay that long anyway is it unlikely that the damage gets stacked that insanely high regardless.
  

I hate it when people ask me what my favorite game is. Just try to explain you're not talking about Unreal Tournament Roll Eyes.
Back to top
 
IP Logged
 
Masterkent
Developer Team
Offline



Posts: 983
Location: Russia
Joined: Apr 5th, 2013
Gender: Male
Re: Best way to handle lingering hurtbox/area for projectiles?
Reply #18 - Dec 11th, 2017 at 4:59pm
Print Post  
Skywolf wrote on Dec 11th, 2017 at 2:47pm:
Is it atleast possible to avoid the splats of each instigator from stacking?

Well, you have a choice between the two possibilities: allowing damage multiplication or allowing damage reduction. If you prefer to deal with a possible damage reduction, then the implementation could be easy:

Code
Select All
class AcidSplat expands Projectile;

event Touch(Actor A)
{
	local AcidSplatDamageAffector DamageAffector;

	if (!A.bIsPawn)
		return;

	foreach A.ChildActors(class'AcidSplatDamageAffector', DamageAffector)
		return; // if A already has an associated affector, then do nothing
	Spawn(class'AcidSplatDamageAffector', A);
}

function CauseDamage(Actor A)
{
	A.TakeDamage(Damage, Instigator, A.Location, vect(0,0,0), 'Corroded');
}

defaultproperties
{
	Damage=10.0
	CollisionRadius=....
	CollisionHeight=....
	Mesh=....
	bUseMeshCollision=True
	Physics=PHYS_None
	....
} 


Code
Select All
class AcidSplatDamageAffector expands Info;

var() float DamageRate;

var private int NextProjectileIndex;

event BeginPlay()
{
	SetTimer(1 / DamageRate, true);
}

event Timer()
{
	local AcidSplat Proj, FirstProj;
	local int i;

	if (Owner == none || Owner.bDeleteMe)
	{
		Destroy();
		return;
	}

	foreach Owner.TouchingActors(class'AcidSplat', Proj)
	{
		if (NextProjectileIndex <= i++)
		{
			Proj.CauseDamage(Owner);
			NextProjectileIndex = i;
			return;
		}
		if (FirstProj == none)
			FirstProj = Proj;
	}
	if (FirstProj != none)
	{
		FirstProj.CauseDamage(Owner);
		NextProjectileIndex = 1;
	}
	else
		Destroy();
}

defaultproperties
{
	DamageRate=10.0
	RemoteRole=ROLE_None
} 

  
Back to top
 
IP Logged
 
Skywolf
Betatester
Offline


Just placeholding...

Posts: 774
Joined: Aug 2nd, 2009
Re: Best way to handle lingering hurtbox/area for projectiles?
Reply #19 - Dec 25th, 2017 at 4:41pm
Print Post  
As I like to understand code rather than just mindless copy-pasting stuff am I kinda stuck right now not fully understanding how things work here. This is what I understand happens:

Code
Select All
class AcidSplat expands Projectile; //This one I understand what is does. So far so good.

event Touch(Actor A)
{
	local AcidSplatDamageAffector DamageAffector;

	if (!A.bIsPawn)
		return;

	foreach A.ChildActors(class'AcidSplatDamageAffector', DamageAffector)
		return; // if A already has an associated affector, then do nothing
	Spawn(class'AcidSplatDamageAffector', A);
}

function CauseDamage(Actor A)
{
	A.TakeDamage(Damage, Instigator, A.Location, vect(0,0,0), 'Corroded');
}

defaultproperties
{
	Damage=10.0
	CollisionRadius=....
	CollisionHeight=....
	Mesh=....
	bUseMeshCollision=True
	Physics=PHYS_None
	....
} 


Code
Select All
class AcidSplatDamageAffector expands Info; //Here my brain fails me

var() float DamageRate;

var private int NextProjectileIndex;

event BeginPlay()
{
	SetTimer(1 / DamageRate, true); //Sets a timer and repeats is.
}

event Timer()
{
	local AcidSplat Proj, FirstProj;
	local int i;

	if (Owner == none || Owner.bDeleteMe)
	{
		Destroy();
		return;
	}

	foreach Owner.TouchingActors(class'AcidSplat', Proj) //iterates through all AcidSplats the owner (the pawn that walked into an acidsplat) is touching.
	{
		if (NextProjectileIndex <= i++) //Checks if NextProjectileIndex is lower or equal to i and then increases i by 1. When Event Timer is triggered again NextProjectileIndex is 1 and i is 0 and thus the code below isn't executed.
		{
			Proj.CauseDamage(Owner);
			NextProjectileIndex = i; //NextProjectileIndex is now 1
			return; //Returns out of the Timer Event.
		}
		if (FirstProj == none) //only gets here in the second time the timer is triggered.
			FirstProj = Proj;
	}
	if (FirstProj != none) //And this part is easy enough to understand for me as well.
	{
		FirstProj.CauseDamage(Owner);
		NextProjectileIndex = 1;
	}
	else
		Destroy();
}

defaultproperties
{
	DamageRate=10.0
	RemoteRole=ROLE_None
} 



If if I understand this correct it only starts dealing damage on the second time the Timer event is triggered. Which would mean that if it should deal damage every second it takes 2 seconds before it starts doing anything. Considering I don't intend on setting the damage rate to almost every tick would this give pawns a pretty generous time to run through it without getting hurt. Or does setting the timer not wait for the delay to pass first and trigger Event Timer right away?
  

I hate it when people ask me what my favorite game is. Just try to explain you're not talking about Unreal Tournament Roll Eyes.
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