Jump to content

Ask me anything about the Jedi source code


Recommended Posts

Posted

That‘s why I showed you the RocketThink() function above. That will point the fighter at the target and chase it, like a homing/tracking rocket.

 

I only showed that function for the math/logic in it. I don’t think you could call that on an NPC as you probably want to set the velocity directly on the NPC, not the pos.trDelta (which is for networked general entities). I would copy that function and make the new one work for vehicle NPCs by storing the resultant velocity in the correct field on the NPC.

Asgarath83 likes this
Posted

@@MGummelt hello there.

sorry if i stress again. i have some little bug again to fix on my fighters. not much deals. i was wondering if you can give me some suggest related to this.

the first problem reguard that: dogfight against fighters TEAM_PLAYER agains TEAM_ENEMY npcs. this problem occurs also if you try to create a friendly rockettrooper NPC and fight NPC rockettrooper. basiclaly, they shoot theirself on the air and their fight with repeater. during fight they have the little problem they do fly manouvre that ... in the course of some minutes, they fly ever up, up, up and more up, until they reach the skybox or the "roof" of the level map. this is not much good to see for a starfightning because in a battle NPC will lost on the Sky. i found the incriminated functions coming by AI_SENTRY and AI_REMOTE .CPP is the maintainheight function.

This:

 

void Olon_MaintainHeight( void )
{    
    float    dif;

    // Update our angles regardless
    ////////////////////////////////////////    
    NPC_FaceEnemy( qtrue );
    NPC_UpdateAngles( qtrue, qtrue );

    if ( NPC->client->ps.velocity[2] )
    {
        NPC->client->ps.velocity[2] *= OLON_DECAY;

        if ( fabs( NPC->client->ps.velocity[2] ) < 1 )
        {
            NPC->client->ps.velocity[2] = 0;
        }
    }
    // If we have an enemy, we should try to hover at or a little below enemy eye level
    if ( NPC->enemy )
    {
        // FIXA QUESTA FUNZIONE E' QUA CHE SI SCAZZANO I CACCIA E IL COMBAT TENTE A MUOVERSI VEROS L'ALTO.
        //SENTRY
        // Find the height difference
        dif = (NPC->enemy->currentOrigin[2]+NPC->enemy->maxs[2]) - NPC->currentOrigin[2];
        // cap to prevent dramatic height shifts
        if ( fabs( dif ) > 8 )
        {
            if ( fabs( dif ) > OLON_HOVER_HEIGHT )
            {
                dif = ( dif < 0 ? -24 : 24 );
            }

            NPC->client->ps.velocity[2] = (NPC->client->ps.velocity[2]+dif)/2;
        }
        //REMOTE
        if (TIMER_Done( NPC, "OlonheightChange"))
        {
            TIMER_Set( NPC,"OlonheightChange",Q_irand( 1000, 3000 ));

            // Find the height difference
            dif = (NPC->enemy->currentOrigin[2] +  Q_irand( 0, NPC->enemy->maxs[2]+8 )) - NPC->currentOrigin[2];

            // cap to prevent dramatic height shifts
            if ( fabs( dif ) > 2 )
            {
                if ( fabs( dif ) > 24 )
                {
                    dif = ( dif < 0 ? -24 : 24 );
                }
                dif *= 10;
                NPC->client->ps.velocity[2] = (NPC->client->ps.velocity[2]+dif)/2;
                NPC->fx_time = level.time;
                //G_Sound( NPC, G_SoundIndex("sound/chars/Olon/misc/hiss.wav"));
            }
        }
    }
    else
    {
        //REMOTE
        gentity_t *goal = NULL;

        if ( NPCInfo->goalEntity )    // Is there a goal?
        {
            goal = NPCInfo->goalEntity;
        }
        else
        {
            goal = NPCInfo->lastGoalEntity;
        }

        if (goal)
        {
            dif = goal->currentOrigin[2] - NPC->currentOrigin[2];

            //REMOTE
            if ( fabs( dif ) > 24 )
            {
                dif = ( dif < 0 ? -24 : 24 );
                NPC->client->ps.velocity[2] = (NPC->client->ps.velocity[2]+dif)/2;
            }
            //SENTRY
            if ( fabs( dif ) > OLON_HOVER_HEIGHT )
            {
                ucmd.upmove = ( ucmd.upmove < 0 ? -4 : 4 );
                
            }
            else
            {
                if ( NPC->client->ps.velocity[2] )
                {
                    NPC->client->ps.velocity[2] *= OLON_VELOCITY_DECAY;

                    if ( fabs( NPC->client->ps.velocity[2] ) < 2 )
                    {
                        NPC->client->ps.velocity[2] = 0;
                    }
                }
            }
        }
        // Apply friction to Z
        else if ( NPC->client->ps.velocity[2] )
        {
            NPC->client->ps.velocity[2] *= OLON_VELOCITY_DECAY;

            if ( fabs( NPC->client->ps.velocity[2] ) < 1 )
            {
                NPC->client->ps.velocity[2] = 0;
            }
        }
        // Apply friction
        else if ( NPC->client->ps.velocity[0] )
        {
            NPC->client->ps.velocity[0] *= OLON_DECAY;

            if ( fabs( NPC->client->ps.velocity[0] ) < 1 )
            {
                NPC->client->ps.velocity[0] = 0;
            }
        }
        else if ( NPC->client->ps.velocity[1] )
        {
            NPC->client->ps.velocity[1] *= OLON_DECAY;
            if ( fabs( NPC->client->ps.velocity[1] ) < 1 )
            {
                NPC->client->ps.velocity[1] = 0;
            }
        }
    }
}
 

 

 

but if i disabled this line the fighters lost also their flight manouvre of dogfight and they fight simply silly fly 'round enemy target, like a seeker droid.

the problem is caused by chunks of code that force the enemy fight to try ever to be "at the same height of eyes height of enemy models. "

i merged up remoter and sentry question for doing this code.

the problem is HERE:

 

  // If we have an enemy, we should try to hover at or a little below enemy eye level
    if ( NPC->enemy ) blablabla
and is caused by the fab functions.

if disable the sentry code field i get by the sentry the problem is strongly reduced with remote parameters of fabs flight by is still again present, i not understand much this kind of expression:

 

dif = (NPC->enemy->currentOrigin[2]+NPC->enemy->maxs[2]) - NPC->currentOrigin[2];

        // cap to prevent dramatic height shifts

        if ( fabs( dif ) > 8 )

        {

            if ( fabs( dif ) > OLON_HOVER_HEIGHT )

            {

                dif = ( dif < 0 ? -24 : 24 );

            }

            NPC->client->ps.velocity[2] = (NPC->client->ps.velocity[2]+dif)/2;

 

can you explain a lot how works exaclty fabs and difs here?

there is some way to fix this for preserve this kind of movement removing this problem of the fighter NPC shifting to Up during a dogfight?

and there is also some better code that i can use for fighter movement during a dogfights? here is defined all my npc fighters flight movements when they have a goal or a enemy. is nice to see on a combat into a map but is again alot far for a true dogfights of games like Xwing alliance or rogue squadron3d , there is any way to improve that for create a nice battle against NPCs?  this is the last tecnical problem of my AI.

@@Archangel35757 can you give me an hand too to manage this? should be great a better dogfight code of that. :3

 

I'm sorry... I just do not have any free time. Real life has me very busy. I wish I could help... I hope you are able to figure it out. Maybe someone else here could help you. Try asking in the Discord Coding channel.

Posted

That‘s why I showed you the RocketThink() function above. That will point the fighter at the target and chase it, like a homing/tracking rocket.

 

I only showed that function for the math/logic in it. I don’t think you could call that on an NPC as you probably want to set the velocity directly on the NPC, not the pos.trDelta (which is for networked general entities). I would copy that function and make the new one work for vehicle NPCs by storing the resultant velocity in the correct field on the NPC.

mmm, rocket think is a good idea. yes, pasting the function itself not works, i tryed on past and game crash on fighter spawn.

better call it on the correct place and trasnform fighters into an homing missile... but without impact with victim LOL, eh this is another quest. i can tell to fighters of avoid enemy or ground before hit brushes or theirn bounding box? i need to fix also that. >.< thanks however! :3

Posted

I'm sorry... I just do not have any free time. Real life has me very busy. I wish I could help... I hope you are able to figure it out. Maybe someone else here could help you. Try asking in the Discord Coding channel.

thanks however dear, no problem ^^ have luck with real life! ciao!

Posted

@@MGummelt i need really to thank you sir. i follow your suggest of apply to the fighter a function that emulate the rocketthink, but edited for affect an NPC instead of a weapon shoot. it runs when the fighters targets an enemy. works pretty fine!  i called for alpha testing olonseek ( gentity_t ent )

this works nice! seem really to play with X Wing Alliance insted of JKA! i just removed the stuff that make explosion of rockets and the stuff of nextthink function because they are unuseful for fighters.

o need to deactivate automoving at runspeed into dogfight or combat are just a crazy go run in front and back, and is not much nice to see with NPC dogfights. but is not a problem, i thinks the AI is editable and customizzable by class of fighers , it's a common AI when i'll set different flight parameter for each fighters class so every one will have his custom flight style.

also, the homing rocket can match the speed of a target they chase, so fighters not need directly an autorunspeed into the combats : 3 they go fast as opponents. 

the unique issue is the dogfight against npcs. because if i remove the fabs code on maintain height, with rocket code stuff fighter fly istantly on the up of the map when they see an NPC enemy (not do against the player WTF) if i use instead the cap height fabs for match fighter height to the "eyes" of opponent, they do that but more slower... pretty strange thing.

oh, well, when i'll fix that fighters will be perfect ! thanks again sir! :3 i was going crazy by happiness to see the evolutions of my fighters into dogfights npc vs npc and player vs player today. also, they explode if i shoot three times... this is nice! hehehe XD

i destroyed a lot of tie squadrons today . °W°,

  • 1 year later...
  • 4 years later...
Posted

@MGummelt hi, i guess i have a few questions

regarding SP

  1. left sided swings have no cool down sometimes + speeded up swings when a lightsaber is off or in the process of being turned off. bug or intentional cause personally i think master sith or jedi are too fast, too powerful and defeating them without such tricks is too much of rng, imo (also playing red style would be way more painful without those exploits)
  2. also speaking of master type enemies (i mean black costume siths and jedi) - what was intentional way of defeating them on jedi knight difficulty
  3. why jumping is so different compare to MP - like, its harder to bunny hop, character slides on surface too much (so although you landed correctly, you will still risk to fall into pit), also acrobatics working differently

Overall about game and players

  1. How much different players approach to a game, compare to developers, both in single player and multiplayer
Smoo likes this

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...