ividyon will never get this done, will he.

[UScript] Need help realizing that I'M AN IDIOT

For questions and discussion about UnrealEd, UnrealScript, and other aspects of Unreal Engine design.

Moderators: Semfry, ividyon

User avatar integration
Skaarj Berserker Skaarj Berserker
Posts: 445
Joined: 01 Sep 2010, 12:37

Subject: Re: [UScript] Need help putting integration's indirectfire code into pawn aiming AI

Post Posted: 14 Dec 2012, 12:20

Downloaded it. Compiled it. Tested it. Worked.

https://www.youtube.com/watch?v=0Nz4fz0lsOg

I don't know how I can help you, if I can't reproduce the problem. I think my code isn't the source of your evil anyway (provided actor.velocity gives you the correct values).

Possible sources for your fail
1. The problem lies in some code you haven't sent me. Have you tested TEXU by yourself?
2. Other gametype or playerpawn. I used Unrealshare.singleplayer. Download my small test map and see, if it is working there. Also try my TEXU.u - perhaps your compiler works differently.
3. Code tested on other Unreal versions. I have UT 436 installed.

Mathematical reasons:
1. Smartaim() gives you wrong results. If you get about 1 unreal unit in the "Calc Error" log, then this is definitely not the case.
2. Target and projectile don't follow their linear resp. quadratic curves in time.
f(qTime) = qGrav*0.5*qTime*qTime + (qProj+Vector(FireRotation)*projSpeed)*qTime + ProjStart
g(qTime) = FireSpot + qTarg * qTime
FireRotation = class'TMath'.static.SmartAim(projSpeed, -qGrav, qTarg - qProj, FireSpot - ProjStart, qTime);
Perhaps they're decelerated during their flight. Or projSpeed, qGrav, qTarg, qProj, FireSpot, ProjStart are somehow wrong. Firespot and ProjStart should be correct because otherwise you wouldn't hit an immobile target with direct fire. That you don't hit moving targets with direct fire indicates wrong values for qTarg or projSpeed. Wrong qTarg values don't explane, why you don't hit immobile targets with indirect fire but projSpeed would. qGrav could also be a reason for wrong indirect fire.

User avatar Buff Skeleton
>:E >:E
Posts: 4173
Joined: 15 Dec 2007, 00:46

Subject: Re: [UScript] Need help putting integration's indirectfire code into pawn aiming AI

Post Posted: 14 Dec 2012, 14:51

Yeah, I've been testing exactly those sources the whole time, though in an EXU2 test map. I would be... ah shit, I think... ough, that's definitely it actually. On Easy and Medium, there are global nerfs to projectile speed handled by the GameInfo's BaseMutator creating a SpawnNotify for Easy and Medium. DURRRURURURGHH

\o/ \o/ \o/ I AM AN IDIOT \o/ \o/ \o/

I'm so sorry, this is just so hilariously dumb and completely my fault for not testing in a more neutral environment. By default, launching UT straight into the test map (which is what I do) starts the game on Medium, which has a 10% speed nerf, and Easy has a 25% speed nerf (only for enemy projectiles).

sana wrote:So basically, EXU wasn't even the hardest it could be yet because monsters would not fire projectiles precisely? :P

lol, in this case no, only on Easy and Medium, due to the above issue. Hard and Unreal (which I never actually tested this on until now) are unaffected. However, it wasn't properly hard until Open Beta because the Intelligence value for Skaarj, Mercs, Krall, and a whole lot of other enemies was set to BRAINS_Mammal instead of BRAINS_Human. That made a huge difference in some maps, since it allowed pawns to use more advanced pathfinding methods and elevators. However, most pawns have a very significant aim error via the RangedAccuracy value, which is usually at least 200 for most pawns (some much higher, and higher = less accurate).

Here's what happens:

If Level.Game.Difficulty==0 or 1, it spawns EXU2EasyNotify or Medium, respectively.

[spoiler]

Code: Select all

class EXU2EasyNotify expands SpawnNotify;

// ==============================================================
//
// This shit makes Projectiles of all types go 25% slower on Easy
//
// ==============================================================

simulated function PostBeginPlay()
{
   local projectile prj;

   foreach allactors(class'projectile',prj){modifyprojectile(prj);}

   super.postbeginplay();
}
//======================================================================
event Actor SpawnNotification(Actor A)
{

   if(projectile(a)!=none)
      modifyprojectile(projectile(a));

   return A;
}

//======================================================================
simulated function modifyprojectile(projectile P)
{
   if(p==none)
   return;

   if ( p.instigator!=none && !p.instigator.isa('playerpawn') )
   {
      P.MaxSpeed = p.default.MaxSpeed*0.75;
      setprojspeed(p,p.Speed*0.75);
   }
}

//======================================================================
simulated function setprojspeed(projectile other,int speed)
{
   if(other==none)
   return;

   other.speed=speed;
   other.velocity=vector(other.rotation)*other.speed;
}

defaultproperties
{
   Actorclass=class'engine.actor'
        RemoteRole=ROLE_SimulatedProxy
}
[/spoiler]

Clearly, this is a pretty antiquated way of handling things (it's been around since at least Demo 3) and is mucking up the whole process. I... I think it may be time to re-evaluate how I handle this and do away with the speed nerf entirely. I already have a global damage nerf to projectiles; 25% on Easy and 10% on Medium, and the level design and gameplay has changed so much since this was needed, so it seems like it does more harm than good now. I don't even want to think of what would be required to make AdjustShot take this into account, or if it even CAN, and a SpawnNotify running on every projectile in the game is pretty slow.

So, moral of the story: I am an idiot, and you should always assume as such when I post a code question. Wow. :lol: To be fair, the original AdjustShot code was buggy with indirect projectiles, and earlier renditions of the new one didn't quite work even on Unreal after I tested it just now, but the very latest version is working fine. :tup:

I did restore the randomization lines, though, as that's pretty vital in EXU. If every single pawn had pinpoint perfect accuracy, you wouldn't stand a chance! :D
Image

User avatar integration
Skaarj Berserker Skaarj Berserker
Posts: 445
Joined: 01 Sep 2010, 12:37

Subject: Re: [UScript] Need help realizing that I'M AN IDIOT

Post Posted: 14 Dec 2012, 18:56

Haha, finally the struggle is over. We all know that getting rid of bugs is the funniest part of mapping/modding. :)

I'd keep lowering the projectilespeed for easy and medium. It's just frustrating when you get hit very often. You could also move the speed increase/decrease to the pawn's PreBeginPlay() function. Here a code example of a Krall:

Code: Select all

function PreBeginPlay()
{
   // ...
   Super.PreBeginPlay();
   if ( bDicePlayer )
      PeripheralVision = 1.0;
   if ( Skill == 0 )
      ProjectileSpeed *= 0.85;
   else if ( Skill > 2 )
   {
      bCanStrafe = true;
      ProjectileSpeed *= 1.1;
   }
   if ( !IsA('KrallElite') )
      bLeadTarget = false;
}


Perhaps using Level.Game.Difficulty instead of skill. Though ProjectileSpeed *= 1.1 does nothing as Krallbolts have speed = max speed. Something similar could be also done with projectiles, which are not affected by the pawn's ProjectileSpeed. You'd just have to check if the instigator is a player - and if not - change the speed according to Level.Game.Difficulty.

What do you mean with randomization? If you mean the longer code I commented out, I'd suggest testing it with no aimerror first to see if it pleases you. I don't know, if trying to predict a dodgejump is such a good idea. Simplier code could look like this:

Code: Select all

   qTime = VSize(FireSpot - ProjStart)/projSpeed; // estimated time until impact
   if ( !bJump && leadTarget && qTime > 0.7 ) // randomize  target's predicted speed   
   {
      if ( VSize(qTarg) > 50 )
      {
         if ( FRand() < 0.5 ) // 50 % chance to aim somewhere else
            qTarg *= 0.2 + 0.7*FRand(); // multiply by a number between 0.2 and 0.9
      }
      else if ( Pawn(p.Target) != none && FRand() < 0.5 ) // 50 % chance to aim somewhere else
      {
         qTarg = Normal( (FireSpot - ProjStart) Cross vect(0,0,1) ); // horizontal, orthogonal to FireSpot - ProjStart
         qTarg *= (2*rand(2)-1);
         if ( p.Target.Physics == Phys_Swimming )
            qTarg *= Pawn(p.Target).WaterSpeed;
         else if ( p.Target.Physics == Phys_Flying )
            qTarg *= Pawn(p.Target).AirSpeed;
         else
            qTarg *= Pawn(p.Target).GroundSpeed;
         qTarg *= 0.1 + 0.6*FRand(); // multiply by a number between 0.1 and 0.7
      }
   }

User avatar Buff Skeleton
>:E >:E
Posts: 4173
Joined: 15 Dec 2007, 00:46

Subject: Re: [UScript] Need help realizing that I'M AN IDIOT

Post Posted: 14 Dec 2012, 19:02

By randomization, I meant just aim error, but I didn't need to uncomment the big block of stuff, just the FireRotation += randrange(-spread, spread); thing. Worked perfectly fine.

I will consider adding speed decrease functionality to EXUGenericProjectiles, as well as an override to disable it for certain projectile types (like bullets which are meant to be nearly insta-hit). Main thing is getting rid of the SpawnNotify implementation as that only messed stuff up, and was slow to boot.

Up next on the agenda is SmartAim support for weapons so that bots can properly aim their projectiles!
Image

Previous

Who is online

Users browsing this forum: No registered users and 37 guests

Copyright © 2001-2024 UnrealSP.org

Powered by phpBB® Forum Software © phpBB Limited