Page 4 of 5

Re: Auto-Guiding Rockets -- [WIP]

Posted: Thu Sep 08, 2016 10:35 pm
by sektor2111
How about talking to a tree ? It sounds more comfortable :ironic: .

Aside, ladies and gentlemen, mutator with rocket and some... other things looks operational somehow... rockets seems interested to avoid wall in small locations rather than tracking an enemy but at least we don't have a spammer console...
THIS is indeed something and it looks like the dog bow wow was helpful for managing unidentifiable errors - finally indentifiable.
So, Gustavo, you have finally done something operational - THIS is how things must be done... :agree1:
A few corrections for a later time are also good points.

Re: Auto-Guiding Rockets -- [WIP]

Posted: Thu Sep 08, 2016 10:38 pm
by darksonny
sektor2111 wrote:How about talking to a tree ? It sounds more comfortable :ironic: .
I dont have a magic chrystal ball sorry, I cant read your mind

Re: Auto-Guiding Rockets -- [WIP]

Posted: Thu Sep 08, 2016 10:41 pm
by Dr.Flay
Thank you sektor. Shame nobody flagged it, and shame that me and Geko missed it.
darksonny, clean your post because It is very offensive. Sektor was out of line, but there is no need to make things worse.
You already self-censored some words but not others. If you don't make it presentable, I will have to edit it.

Gustavo, pay attention to the chaos you create.
There is only so much damage limitation I am prepared to do. I clean up stupid mistakes by companies for money.
Here I do it because I am a mug with a bit of spare time.

Re: Auto-Guiding Rockets -- [WIP]

Posted: Thu Sep 08, 2016 10:45 pm
by darksonny
Dr.Flay wrote:Thank you sektor. Shame nobody flagged it, and shame that me and Geko missed it.
darksonny, clean your post because It is very offensive. Sektor was out of line, but there is no need to make things worse.
You already self-censored some words but not others. If you don't make it presentable, I will have to edit it.

Gustavo, pay attention to the chaos you create.
There is only so much damage limitation I am prepared to do. I clean up stupid mistakes by companies for money.
Here I do it because I am a mug with a bit of spare time.
This forum is your not mine, edit whatever you think its wrong, but please don't put in my mouth anything like that word "phaedophilia" that's your invention (or a lie). For the rest im fine with you decision.

Re: Auto-Guiding Rockets -- [WIP]

Posted: Thu Sep 08, 2016 10:56 pm
by sektor2111
I'm not sure if this is a chaos or a lesson in how to properly finish a mutator without mooing snippets. Without this circus for sure Gustavo would not finish his work letting another thread in air. So I'm really glad to see that finally he did something functional. It could be done without so much noise but probably this way was more helpful.
Updates are gonna be welcomed too if they are about to be real not only stories.

Re: Auto-Guiding Rockets -- [WIP]

Posted: Thu Sep 08, 2016 11:12 pm
by Terraniux
This is thread makes me nothing but smile, that picture of Gustavo is so geniously funny :D :lol2:

I want something like that too :mrgreen:

Re: Auto-Guiding Rockets -- [WIP]

Posted: Sat Sep 10, 2016 8:39 pm
by Gustavo6046
sektor2111 wrote:rockets seems interested to avoid wall in small locations rather than tracking an enemy
So, if you find out some way of detecting the spaciest direction perpendicular to the wall then I'd be glad to code so that the rockets can avoid walls by turning by 90°! :D

Re: Auto-Guiding Rockets -- [WIP]

Posted: Sat Sep 10, 2016 9:13 pm
by sektor2111
Let me introduce a bit of logic because you might follow secondary option as primary, which doesn't looks efficient either.

IF rocket has a direct sight with VICTIM tell me for which reason must be busy with wall, just TRACK the damn target. If target is suddenly hiding or was dodging away of sight, get busy to avoid A WALL because default seekingrocket is tracking target even if a wall will destroy it soon. THAT's the point, too busy with walls, almost ignoring pawns even if they are a perfect target.

These are only my thoughts for that after testing it around 3 minutes, then I have to mention spam. What if 6 players are firing 10 rockets ? This has to be reduced somehow because is not the best thing happening. Else I did not test it VIA net yet...

Re: Auto-Guiding Rockets -- [WIP]

Posted: Sat Sep 10, 2016 9:42 pm
by Gustavo6046
TRACK the damn target? Ok! :agree1: I just made a class (NavigationHelper):

Code: Select all

//=============================================================================
// NavigationHelper.
//=============================================================================
class NavigationHelper expands Pawn;

var	NavigationHelper	Next;
var	Actor				This;

simulated function LoadPathToward(Actor Target, NavigationHelper Root)
{
	local NavigationHelper NH;

	Next = Spawn(class'NavigationHelper');
	Next.This = FindPathToward(Target);

	Log(self@"spawned"@Next@"to find path towards"@Target);
	
	for ( NH = Root; NH != None; NH = NH.Next )
		if ( NH.This == Next.This && NH != Next )
			return;

	if ( Next.This == None || Next.This == Target )
	{
		Next.This = Target;
	
		return;
	}

	Log(self@"takes next path:"@Next@"with"@Next.This);
	Next.LoadPathToward(Target, Root);
}

simulated function Actor Helped()
{
	Next.Helped();
	Destroy();

	return Next.This;
}
Which the autorockets use to track their target:

Code: Select all

//=============================================================================
// AutoRocket.
//=============================================================================
class AutoRocket expands UT_SeekingRocket;

var()	float			SeekAcceleration, SeekSpeed, TargetAcquiringRadius, WallAvoidSpeed, WallPredictionFactor, WallAvoidSlowdown, ShootDensity, ShootDistance, ShootDistanceFactor, MinHomePathDistance;
var()	bool			bShootAtTarget, bIgnoreIgnorers;
var()	class<Actor>	ProjectileClass;
var		Pawn			User;
var		Actor			HomeTarget;
var		int				Slowdown;
var		bool			bFoundUser;

replication
{
	reliable if ( Role == ROLE_Authority )
		User,
		Slowdown,
		bFoundUser;
}

simulated event bool PercentChance(float Percentage)
{
	return FRand() * 100 < Percentage;
}

simulated event Vector EstimateLocation(Actor Other)
{
	return Other.Location + (Other.Velocity / VSize(Velocity)) * 0.5;
}

simulated event HomeAt(Actor Other)
{
	Velocity *= VSize(Velocity cross (EstimateLocation(Other) - Location)) * SeekAcceleration;
	Acceleration += (EstimateLocation(Other) - Location) * SeekSpeed;
	Acceleration /= 2;
}

simulated event Actor WillHitWall(optional out Vector Location, optional out Vector OutNormal)
{
	return Trace(Location, OutNormal, Self.Location + Velocity * WallPredictionFactor);
}

simulated event bool MonsterFriendly(ScriptedPawn Other)
{
	return Other != None && Other.AttitudeTo(User) == ATTITUDE_Friendly;
}

simulated event bool CheckSeekable(Pawn Other, Pawn FireAgent)
{
	return (
		Other != None
		&&
		(
			FireAgent == None
			||
			(
				FireAgent != None
				&& FastTrace(Other.Location)
				&& Other != FireAgent
				&& !Other.IsInState('Dying')
				&&
				(
					!MonsterFriendly(ScriptedPawn(Other))
					&&
					(
						!Level.Game.bTeamGame
						|| Other.PlayerReplicationInfo == None
						|| FireAgent.PlayerReplicationInfo == None
						|| Other.PlayerReplicationInfo.Team != FireAgent.PlayerReplicationInfo.Team
					)
				)
			)
		)
	);
}

function BeginPlay()
{
	if ( Owner == None )
		return;

	if ( Pawn(Owner) != None )
		User = Pawn(Owner);

	else
		User = Pawn(Owner.Owner);

	if ( User == None )
		return;
}

simulated function SetTarget(Pawn Other)
{
	Seeking = Other;

	Log(self@"is now seeking after:"@Other);
}

simulated function bool CanHome()
{
	return Seeking != None && FastTrace(Seeking.Location) && ( Pawn(Seeking) == None || !Pawn(Seeking).IsInState('Dying') || ScriptedPawn(Seeking) == None || ( User != None && ScriptedPawn(Seeking).AttitudeTo(User) == ATTITUDE_Friendly ) );
}

simulated event Timer()
{
	local Pawn P;
	local Pawn Target;
	local ut_spriteSmokePuff B;
	local Actor A;
	local Vector WallNorm, WallLoc;

	SetRotation(Rotator(Velocity));

	A = WillHitWall(WallLoc, WallNorm);

	if ( A != None && !CanHome() && ( LevelInfo(A) != None || !CheckSeekable(Pawn(A), User) ) && ((VSize(WallLoc - Location) / VSize(Velocity * 0.1)) / 256) * 0.1 > (WallNorm dot Velocity) )
	{
		Velocity /= WallAvoidSlowdown;
		Slowdown *= WallAvoidSlowdown;
		Acceleration -= WallAvoidSpeed * 2 * (WallNorm dot Velocity) * WallNorm;
	}

	else if ( Slowdown > 1 )
	{
		Velocity *= Slowdown;
		Slowdown = 1;
	}

	else bFoundUser = True;

	if ( CanHome() )
	{
		if ( HomeTarget == None || ( VSize(HomeTarget.Location - Location) < MinHomePathDistance && HomeTarget != Seeking ) )
		{
			HomeTarget = Spawn(class'NavigationHelper');

			NavigationHelper(HomeTarget).LoadPathToward(Seeking, NavigationHelper(HomeTarget));
			HomeTarget = NavigationHelper(HomeTarget).Helped();

			return;
		}

		HomeAt(HomeTarget);

		if ( bShootAtTarget && PercentChance(ShootDensity) && ProjectileClass != None )
			Spawn(ProjectileClass, Owner, '', Location + Vector(Rotation) * (CollisionRadius + ShootDistance + ProjectileClass.default.CollisionRadius) * ShootDistanceFactor );
	}

	else if ( Seeking == None || !FastTrace(Seeking.Location) )
	{
		foreach RadiusActors(class'Pawn', P, TargetAcquiringRadius)
		{
			if ( Target == None || VSize(P.Location - Location) < VSize(Target.Location - Location) )
			{
				Target = P;

				if ( CheckSeekable(Target, User) )
					SetTarget(Target);
			}
		}
	}

	if ( (Level.bHighDetailMode && !Level.bDropDetail) || (FRand() < 0.5) )
	{
		b = Spawn(class'ut_SpriteSmokePuff');
		b.RemoteRole = ROLE_None;
	}
}
Unless I'm mistaken and there actually is a path-finding function in the NavigationPoint class. :P

Problem are the Ac. Nones in the NavigationHelper class (undoubtedly in that for loop... ;_;)...

Re: Auto-Guiding Rockets -- [WIP]

Posted: Sun Sep 11, 2016 1:18 am
by Barbie
Gustavo6046 wrote:Problem are the Ac. Nones in the NavigationHelper class (undoubtedly in that for loop
That definitely happens if the current NavigationHelper is the last in the chain - "Next" is None then. But your code accesses "Next.This" within the loop:

Code: Select all

if ( NH.This == Next.This && NH != Next )

Re: Auto-Guiding Rockets -- [WIP]

Posted: Sun Sep 11, 2016 1:38 am
by Gustavo6046
Barbie wrote:
Gustavo6046 wrote:Problem are the Ac. Nones in the NavigationHelper class (undoubtedly in that for loop
That definitely happens if the current NavigationHelper is the last in the chain - "Next" is None then. But your code accesses "Next.This" within the loop:

Code: Select all

if ( NH.This == Next.This && NH != Next )
Oh, thanks! I have fixed them now:

Code: Select all

//=============================================================================
// NavigationHelper.
//=============================================================================
class NavigationHelper expands Pawn;

var	NavigationHelper	Next;
var	Actor				This;

simulated function LoadPathToward(Actor Target, optional NavigationHelper Root)
{
	local NavigationHelper NH;

	if ( Root == None )
		Root = self;

	Next = Spawn(class'NavigationHelper');

	Log(self@"spawned"@Next@"to find path towards"@Target);

	if ( FindPathToward(Target) == None )
	{
		This = Target;
		Next.This = This;
	}

	else
		Next.This = FindPathToward(Target);

	Log(Next@"found next:"@Next.This);
	
	if ( Next.This == Target )
	{
		Log(Next@"found path to target!");
	
		return;
	}

	for ( NH = Root; NH != None; NH = NH.Next )
		if ( NH.This != None && NH.This == Next.This && NH != Next )
		{
			Warn("Avoided recursion because of"@NH.This);

			return;
		}

	Log(self@"takes next path:"@Next@"with"@Next.This);
	Next.LoadPathToward(Target, Root);
}

simulated function Actor Helped(optional bool bThis)
{
	local Actor A, B;

	Log(self@"is self-desctructing");

	if ( Next != None )
		B = Next.Helped();

	else
		A = This;

	if ( bThis )
		A = This;

	else
		A = B;

	Destroy();

	Log("Final path component from"@self$":"@A);

	return A;
}
And also those darn rockets:

Code: Select all

//=============================================================================
// AutoRocket.
//=============================================================================
class AutoRocket expands UT_SeekingRocket;

var()	float			SeekAcceleration, SeekSpeed, TargetAcquiringRadius, WallAvoidSpeed, WallPredictionFactor, WallAvoidSlowdown, ShootDensity, ShootDistance, ShootDistanceFactor, MinHomePathDistance, MinWallAvoidNormal;
var()	bool			bShootAtTarget, bIgnoreIgnorers;
var()	class<Actor>	ProjectileClass;
var		Pawn			User;
var		Actor			HomeTarget;
var		int				Slowdown;
var		bool			bFoundUser;

replication
{
	reliable if ( Role == ROLE_Authority )
		User,
		Slowdown,
		bFoundUser;
}

simulated function float MinHomeNormal()
{
	if ( CanHome() || HomeTarget != None )
		return 0.5 * MinWallAvoidNormal;

	else
		return 0.1 * MinWallAvoidNormal;
}

simulated event bool PercentChance(float Percentage)
{
	return FRand() * 100 < Percentage;
}

simulated event Vector EstimateLocation(Actor Other)
{
	if ( Other == None )
		return Location;

	return Other.Location + (Other.Velocity / VSize(Velocity)) * 0.5;
}

simulated event HomeAt(Actor Other)
{
	Velocity *= VSize(Velocity cross (EstimateLocation(Other) - Location)) * SeekAcceleration;
	Acceleration += (EstimateLocation(Other) - Location) * SeekSpeed;
	Acceleration /= 2;
}

simulated event Actor WillHitWall(optional out Vector Location, optional out Vector OutNormal)
{
	return Trace(Location, OutNormal, Self.Location + Velocity * WallPredictionFactor);
}

simulated event bool MonsterFriendly(ScriptedPawn Other)
{
	return Other != None && Other.AttitudeTo(User) == ATTITUDE_Friendly;
}

simulated event bool CheckSeekable(Pawn Other, Pawn FireAgent)
{
	return (
		Other != None
		&&
		(
			FireAgent == None
			||
			(
				FireAgent != None
				&& FastTrace(Other.Location)
				&& Other != FireAgent
				&& !Other.IsInState('Dying')
				&&
				(
					!MonsterFriendly(ScriptedPawn(Other))
					&&
					(
						!Level.Game.bTeamGame
						|| Other.PlayerReplicationInfo == None
						|| FireAgent.PlayerReplicationInfo == None
						|| Other.PlayerReplicationInfo.Team != FireAgent.PlayerReplicationInfo.Team
					)
				)
			)
		)
	);
}

function BeginPlay()
{
	if ( Owner == None )
		return;

	if ( Pawn(Owner) != None )
		User = Pawn(Owner);

	else
		User = Pawn(Owner.Owner);

	if ( User == None )
		return;
}

simulated function SetTarget(Pawn Other)
{
	Seeking = Other;

	Log(self@"is now seeking after:"@Other);
}

simulated function bool CanHome()
{
	return Seeking != None && ( Pawn(Seeking) == None || !Pawn(Seeking).IsInState('Dying') || ScriptedPawn(Seeking) == None || ( User != None && ScriptedPawn(Seeking).AttitudeTo(User) == ATTITUDE_Friendly ) );
}

simulated event Timer()
{
	local Pawn P;
	local Pawn Target;
	local ut_spriteSmokePuff B;
	local Actor A;
	local Vector WallNorm, WallLoc;

	SetRotation(Rotator(Velocity));

	A = WillHitWall(WallLoc, WallNorm);

	if ( A != None && ( LevelInfo(A) != None || !CheckSeekable(Pawn(A), User) ) && ((VSize(WallLoc - Location) / VSize(Velocity * 0.1)) / 256) * MinHomeNormal() > (WallNorm dot Velocity) )
	{
		Velocity /= WallAvoidSlowdown;
		Slowdown *= WallAvoidSlowdown;
		Acceleration -= WallAvoidSpeed * 2 * (WallNorm dot Velocity) * WallNorm;
	}

	else if ( Slowdown > 1 )
	{
		Velocity *= Slowdown;
		Slowdown = 1;
	}

	else bFoundUser = True;

	if ( CanHome() )
	{
		if ( ( !FastTrace(Seeking.Location) && ( HomeTarget == None || !FastTrace(HomeTarget.Location) ) ) || ( HomeTarget != None && VSize(HomeTarget.Location - Location) < MinHomePathDistance && HomeTarget != Seeking ) )
		{
			HomeTarget = Spawn(class'NavigationHelper');

			NavigationHelper(HomeTarget).LoadPathToward(Seeking);
			HomeTarget = NavigationHelper(HomeTarget).Helped(true);

			return;
		}

		else if ( FastTrace(Seeking.Location) )
			HomeTarget = Seeking;

		HomeAt(HomeTarget);

		if ( bShootAtTarget && PercentChance(ShootDensity) && ProjectileClass != None )
			Spawn(ProjectileClass, Owner, '', Location + Vector(Rotation) * (CollisionRadius + ShootDistance + ProjectileClass.default.CollisionRadius) * ShootDistanceFactor);
	}

	else
	{
		HomeTarget = None;

		foreach RadiusActors(class'Pawn', P, TargetAcquiringRadius)
		{
			if ( Target == None || VSize(P.Location - Location) < VSize(Target.Location - Location) )
			{
				Target = P;

				if ( CheckSeekable(Target, User) )
					SetTarget(Target);
			}
		}
	}

	if ( (Level.bHighDetailMode && !Level.bDropDetail) || (FRand() < 0.5) )
	{
		b = Spawn(class'ut_SpriteSmokePuff');
		b.RemoteRole = ROLE_None;
	}
}

Re: Auto-Guiding Rockets -- [WIP]

Posted: Fri Sep 23, 2016 4:20 am
by SilverSound
While you are at this you should try to make ghost rockets. Rockets that move slow but can go through objects. Just imagine the fun someone would have running away from that. Haha. Can make it a game type maybe even :wink:

I might even try it sometime.

Re: Auto-Guiding Rockets -- [WIP]

Posted: Fri Sep 23, 2016 3:46 pm
by Terraniux
SilverSound wrote:While you are at this you should try to make ghost rockets. Rockets that move slow but can go through objects. Just imagine the fun someone would have running away from that. Haha. Can make it a game type maybe even :wink:

I might even try it sometime.
Haha yeah. Then I happen to have the most genious map idea for that, 1 big maze, like the mazerunner movies. :lol:
I still have that on my list to make, regardless of gametype.

Re: Auto-Guiding Rockets -- Are you satisfied now?

Posted: Fri Sep 23, 2016 4:38 pm
by PrinceOfFunky
sektor2111 wrote:This young "coder"
We all are "young coders", we never stop learning and you need to do errors to learn new stuff. Even you are like a "young coder", last thing you told me was that if something works it doesn't need any fix, but I think if something works you can still try to optimize the code for a better efficency and efficacy.

Re: Auto-Guiding Rockets -- [WIP]

Posted: Fri Sep 23, 2016 6:42 pm
by sektor2111
PrinceOfFunky wrote:We all are "young coders", we never stop learning and you need to do errors to learn new stuff
YES, me too, BUT I don't recall which forum I was spamming with USELESS Snipets which mainly doesn't work and are only confusing other young "coders" with None stuff. Learning codes is doable in private and testing them before yelling "awesome" as long as I don't recall stupid useless things to be "awesome". I thought that we clarified this problem since that dude (IpTables if I well recall ID) came for clarification toward a game-type "in work" which was looking the mostly coded by community (due to constant issues appearance) and not by the author who started it. All of us have to learn but without spamming and trying to annoy others, right ? I guess so.

Edit: BTW, because of bump here. This super duper rocket I don't see if has an update because is busy with walls rather than tracking a Pawn-Target but suddenly author went to another job leaving this to hang unfinished (as usual).