Dangerous Tentacles

Discussions about everything else
User avatar
Barbie
Godlike
Posts: 2802
Joined: Fri Sep 25, 2015 9:01 pm
Location: moved without proper hashing

Re: Dangerous Tentacles

Post by Barbie »

Barbie wrote: Sun May 01, 2022 9:44 am Could be a candidate for a map checker
My check so far:

Code: Select all

function int FixRangedProjectiles(ELogType LogLevel) {
/*******************************************************************************
Changes RangedProjectile for all ScriptedPawns, if RangedProjectile.Class is
equal to:
* "class'UnrealShare.Plasma'" -> ScriptedPawn.Default.RangedProjectile
* "class'BotPack.GuidedWarShell'" -> ScriptedPawn.Default.RangedProjectile
* "class'UnrealShare.EnergyBolt'" -> Class'EnergyBoltSB'
* "class'UnrealShare.ShellCase'" -> ScriptedPawn.Default.RangedProjectile

Log a warning if
	ScriptedPawn.bHasRangedAttack != ScriptedPawn.Default.bHasRangedAttack
	ScriptedPawn.RangedProjectile != None && ! ScriptedPawn.bHasRangedAttack
Returns the number of modified ScriptedPawns.
*******************************************************************************/
local ScriptedPawn SP;
local int result;

	// log("Entered FixRangedProjectiles, Level.PawnList=" $ Level.PawnList); <- sometimes None?!

	foreach AllActors(class 'ScriptedPawn', SP)
		if (SP.RangedProjectile == class'UnrealShare.Plasma')
			FixRangedProjectile(LOG_Info, SP, SP.Default.RangedProjectile, result);
		else if (SP.RangedProjectile == class'BotPack.GuidedWarShell')
			FixRangedProjectile(LOG_Info, SP, SP.Default.RangedProjectile, result);
		else if (SP.RangedProjectile == class'UnrealShare.EnergyBolt')
			FixRangedProjectile(LOG_Info, SP, Class'EnergyBoltSB', result);
		else if (SP.RangedProjectile == class'UnrealShare.ShellCase')
			FixRangedProjectile(LOG_Info, SP, SP.Default.RangedProjectile, result);
		// if *RangedProjectile==None* then *bHasRangedAttack* is not necessarily FALSE - see Titan for example. Such cases cannot be detected.
		else if (SP.bHasRangedAttack != SP.Default.bHasRangedAttack)
			logger(LOG_Warning, "FixRangedProjectiles", "bHasRangedAttack=" $ SP.bHasRangedAttack @ "is not the default value for" @ SP $ "; RangedProjectile=" $ SP.RangedProjectile);
		else if (SP.RangedProjectile != None && ! SP.bHasRangedAttack)
			logger(LOG_Warning, "FixRangedProjectiles", "bHasRangedAttack=false for" @ SP @ " although it has a RangedProjectile=" $ SP.RangedProjectile);
	return result;
}
"Multiple exclamation marks," he went on, shaking his head, "are a sure sign of a diseased mind." --Terry Pratchett
Eternity
Skilled
Posts: 172
Joined: Sat Nov 30, 2019 10:56 pm

Re: Dangerous Tentacles

Post by Eternity »

Buggie wrote: Mon May 02, 2022 12:54 pm Show example of code.
Quick test result: it does not work this way, at all (returns 'False' always).
I have never tried to use it this way before, and never seen any class that would contain such examples... Considered it is valid for spawned instances only. It was the reason this ( "SP.RangedProjectile.IsA('Projectile')" ) caught my attention...
User avatar
sektor2111
Godlike
Posts: 6410
Joined: Sun May 09, 2010 6:15 pm
Location: On the roof.

Re: Dangerous Tentacles

Post by sektor2111 »

So... I will need another array nearby "abstract" checks for listing lousy projectiles aand... non-projectiles...
But, like I said, Pawns were reverted back to original for some reason. Of course, this is not an emergency, I'll drop any eye there again in future, after finishing other tasks - gaming included.
Buggie
Godlike
Posts: 2734
Joined: Sat Mar 21, 2020 5:32 am

Re: Dangerous Tentacles

Post by Buggie »

isA check object. If you need test class instance, you use ClassIsChildOf.
IsA walk on chain of parents up and check names. Obviously Class of projectile is not a projectile. It is class.
User avatar
sektor2111
Godlike
Posts: 6410
Joined: Sun May 09, 2010 6:15 pm
Location: On the roof.

Re: Dangerous Tentacles

Post by sektor2111 »

I created a scenario with 4 "dangerous mercenaries". I can figure non-projectiles added as projectiles but... for some other reason I cannot read their damage and speed - when some of these have no damage and no speed (this is original goofing anyway) for me these should be returned back to original. And then... even original ones are replaced once again with original because I see that class returns ZERO everywhere. I tried a generic check not hard-coded classes based on names...
This was helping only for a Half of Task:

Code: Select all

	var class Pr;
	var Projectile Pj;
	var float Dmg;
	var float Speed;
..
..
..
function SomethingToCheck()
{
	local ScriptedPawn S;
	local Projectile Proj;
..
..
			if ( string(S.RangedProjectile) != "None" && string(S.RangedProjectile) != "" )
			{
				if (!ClassIsChildOf(S.RangedProjectile, class'Projectile'))
				{
					log ("Has RangedProjectile"@S.RangedProjectile$". Reverting to original property.",S.Name);
					S.RangedProjectile = S.class.default.RangedProjectile;
				}
				else
				{
/*
					SetPropertyText("Pj", "class'"$string(S.RangedProjectile)$"'");
					log(Pj,'Debug'); //Package and name readable
					if ( Pj != None )
					{
						Proj = MyMap.Spawn(Pj.Class,,,S.Location); //Failure
						if ( Proj != None )
						{
							log (Proj.Damage,'Debug');
							log (Proj.speed,'Debug');
							Dmg = Proj.Damage;
							Speed = Proj.Speed;
							log (Dmg@Speed,'Debug');
							if ( Dmg == 0 && int(Speed) == 0 )
							{
								log ("Uses as RangedProjectile"@S.RangedProjectile$". Reverting to original property.",S.Name);
								S.RangedProjectile = S.class.default.RangedProjectile;
							}
							Proj.Destroy();
							Proj = None;
							Dmg = 0.000000;
							Speed = 0.000000;
						}
					}
*/
}
I removed the code (perhaps 4th+ version) because it doesn't seems to work. This was the last resort by spawning projectile and testing values - spawning task here was None, Editor claims that a non-actor is trying to spawn... Non-Actor ??? :noidea . I'm still thinking what else is doable here...
Last resort would be testing each lousy stock type... (including stupid "PeaceRocket" class - not fixed even in 469b so far).

Edit:Ahem... solved... several "type mismatch" bugged me but it's cute so far. And now it's still needed a separate array for the rest of classes which are obsolete for monsters...
User avatar
Barbie
Godlike
Posts: 2802
Joined: Fri Sep 25, 2015 9:01 pm
Location: moved without proper hashing

Re: Dangerous Tentacles

Post by Barbie »

Why

Code: Select all

string(S.RangedProjectile) != "None"
instead of easier

Code: Select all

S.RangedProjectile != None
:???:
"Multiple exclamation marks," he went on, shaking his head, "are a sure sign of a diseased mind." --Terry Pratchett
Eternity
Skilled
Posts: 172
Joined: Sat Nov 30, 2019 10:56 pm

Re: Dangerous Tentacles

Post by Eternity »

Code: Select all

string(S.RangedProjectile) != ""
Is there some cases when this returns False?
Buggie
Godlike
Posts: 2734
Joined: Sat Mar 21, 2020 5:32 am

Re: Dangerous Tentacles

Post by Buggie »

Barbie wrote: Thu May 05, 2022 9:17 pm Why

Code: Select all

string(S.RangedProjectile) != "None"
instead of easier

Code: Select all

S.RangedProjectile != None
:???:
Bad code.
Eternity wrote: Thu May 05, 2022 9:49 pm

Code: Select all

string(S.RangedProjectile) != ""
Is there some cases when this returns False?
No.
User avatar
sektor2111
Godlike
Posts: 6410
Joined: Sun May 09, 2010 6:15 pm
Location: On the roof.

Re: Dangerous Tentacles

Post by sektor2111 »

I was expecting these answero-questions... :lol:
"Bad code" works normally so far (I had to change a bit vars used), I'll do more optimizations later - this version was a rip from elsewhere concerning Teleporters but here these can be changed as long as the deal is referring to an actor defined or not, I had other plans with that. All I have to do now is defining an array with classes which are useless - this chapter is not really the last problem, it has to be solved too. I don't know if is needed something for servers as long as I don't add trash UNR files claimed as Maps, but checking files before adding them into public gaming would be very welcomed since as Barbie pointed, the boys keep releasing these. When I'll be back home and polishing these, I'll show what I did regarding to a possible final stage.

Edit: For moore happiness...

Code: Select all

....
			if ( S.RangedProjectile != None )
			{
				if ( S.Class.Default.RangedProjectile == None ) //Some boys are not using anything even if it was defined - useless data in map.
					S.RangedProjectile = None; //To do - update the report about which one is trashcan
....
			}
			else
			{
... //Next funky setup that will be reverted
			}
Edit2: Checks if these "projectiles" have to be restored at original... have speed but no damage, or without more A.I. compatibility, or being bugged killing instigator.

Code: Select all

function bool IsNotMonsterType( Projectile Pt )
{
	if ( Pt == None ) return False;

	switch (Pt.class)
	{
		case Class'BotPack.GuidedWarShell': return True;
		case Class'BotPack.MTracer': return True;
		case Class'BotPack.PBolt': return True;
		case Class'BotPack.StarterBolt': return True;
		case Class'BotPack.TranslocatorTarget': return True;
		case Class'UnrealI.PeaceRocket': return True;
		case Class'UnrealI.Tracer': return True;
		case Class'UnrealShare.Biodrop': return True; //Others ? Another code for preventing dependencies ?
	}
	return False;
}
Post Reply