RPG modifications in HL2

Grab your favourite IDE and tinker with the innards of game engines

RPG modifications in HL2

Postby droogie on Fri Oct 15, 2010 8:19 am

Hey guys,

I am planning on doing some modifications to the RPG in a hl2 for a SP mod. There were two main ideas that stuck out... I wanted to have a Heat Seeking RPG and also a Remote Controlled RPG.

For the heat seeking.. So far the only way I've been able to even remotely getting this to work is modifying weapon_rpg.cpp and making it always use "autoaim". That's disgusting... There are obvious issues with this... to make it work well I would need to modify autoaim variables so it will do autoaim for very far distances and how close you have to aim.. But if someone were actually playing on easy mode it would change the values for every weapon (and that's garbage.) Anyone have any idea how I could implement this?

As for the remote controlled RPG... The idea is basically.. On fire, change camera to the rpg with mouse control and have missile constantly fly until impact or if player presses mouse 1 again explode, on impact camera goes back to the player. I have no idea where to start with this.. I'm assuming it's somewhere inside of in_camera.cpp but I believe some code would also need to be changed inside of weapon_rpg.cpp for the mouse control aiming of the missile. I couldn't find anything on people doing things with the camera like how I am trying.. So any input/recommendations would be greatly appreciated! :D
droogie
Dumpling
Dumpling
 
Joined: Fri Oct 15, 2010 8:04 am

Re: RPG modifications in HL2

Postby Dr. Delta on Fri Oct 15, 2010 8:55 am

Go talk with terrorcell from Titans Peak.
User avatar
Dr. Delta
Veteran
Veteran
 
Joined: Thu Dec 27, 2007 1:18 pm
Location: People's Republic of Porygon

Re: RPG modifications in HL2

Postby droogie on Fri Oct 15, 2010 8:05 pm

Thanks for the response. I went ahead and shot him a private message. Hopefully he checks his moddb pm's :D
droogie
Dumpling
Dumpling
 
Joined: Fri Oct 15, 2010 8:04 am

Re: RPG modifications in HL2

Postby zombie@computer on Fri Oct 15, 2010 8:42 pm

CMissile::SeekThink is doing all the targetting. its pretty straightforward code. for the actual heatseeking stuff i'd add a property to cbaseentity (m_iHeat or something) and have the missile doing a radial search for hot entities and picking the nearest or hottest.

as for the missile view thing: forget about modding from an rpg missile if this is for sp. Just create a playercontrolled camera which detonates as soon as one hits attack1 or another entity.
When you are up to your neck in shit, keep your head up high
zombie@computer
Forum Goer Elite™
Forum Goer Elite™
 
Joined: Fri Dec 31, 2004 5:58 pm
Location: Lent, Netherlands

Re: RPG modifications in HL2

Postby droogie on Sat Oct 16, 2010 4:34 am

Thanks for the response zombie@computer,

I'll definitely look more into CMissile::SeekThink. I'm new to the source SDK and wanted to do some small projects like above to get comfortable with it. (Maybe it’s not small enough??? XD) I tend to learn better by just attempting and eventually getting it working and learning from mistakes. I changed little things for fun like re-enabling the laser toggle (and other misc edits) for single player and getting the grapple hook working with single player. (http://developer.valvesoftware.com/wiki/Grapple_Hook you can download my files here if anyone is interested http://droogie.net/data//hl2/weapon_grapple.rar) I’m having trouble understanding how I’m going to do a radial search for specific entities and how to specify if it’s a target or not. I saw in the code having it check to see if it’s a strider to tweak the homing speed and avoid an infinite circle around a striders body, maybe there is a check for any enemy in general that I could use and to just head toward the closest enemy entity from the player? It would be kind of silly if my rockets start attacking light bulbs, etc haha.

As for the remote controlled camera idea… The only things I’ve found are people doing over the shoulder third person control or cinematic scenes via hammer. Could you possibly link me to some resources explaining a remote controlled camera or explain more in detail please? Looking at the code I think I can simply get the on fire explode() working fine. I just need camera control and make sure the missile is following the way that camera is pointing instead of the laser dot which is why I was assuming that I also needed to edit weapon_rpg.cpp. I’m looking at just having modes that the player can select through, laser guided, heat seeking, remote controlled, etc. which I can look into later once I get some of this other basic code working.

Thanks for the help guys. :D
droogie
Dumpling
Dumpling
 
Joined: Fri Oct 15, 2010 8:04 am

Re: RPG modifications in HL2

Postby zombie@computer on Sat Oct 16, 2010 6:25 pm

well, CEntitySphereQuery is a class that allows you to find all entities in a certain sphere. Then just iterate the entities and calculate which entity you want to target, eg based on a property like my proposed m_iHeat.

As you should be able to see in the code you dont really set a 'target' for the rpg. You simply calculate at what angle the target is and then adjust the angle of the rocket slightly. Basically, on this line

VectorSubtract( targetPos, GetAbsOrigin(), vTargetDir );

you calculate the target direction using a vector from a target (eg an entity you found its GetAbsOrigin()), the vector of the rocket (GetAbsOrigin(), and an output (vTargetDir). You can leave the code below that line alone. Just make sure you remove every reference of the laserdot thingy, since you arent using that to target the missile.

as for a controlled camera: I just realised the controllable rpg might be better as rpg-missile based if you want npc's to be able to shoot you out of the air, but that doesn't really matter for this question. I suggest looking into vehicle code to find out how to 'catch' movement input and point_viewcontrol for camera stuff. Don't expect it to be easy.
When you are up to your neck in shit, keep your head up high
zombie@computer
Forum Goer Elite™
Forum Goer Elite™
 
Joined: Fri Dec 31, 2004 5:58 pm
Location: Lent, Netherlands

Re: RPG modifications in HL2

Postby droogie on Sat Oct 16, 2010 8:04 pm

hrm.. Thanks for that entity search function. I was looking at npc_rollermine and I think the way it's doing the search seems ideal.

Code: Select all
#define    ROLLERMINE_DETECTION_RADIUS        350
//-----------------------------------------------------------------------------
// Purpose:
// Output : Returns true on success, false on failure.
//-----------------------------------------------------------------------------
bool CNPC_RollerMine::DetectedEnemyInProximity( void )
{
    CBaseEntity *pEnt = NULL;
    CBaseEntity *pBestEnemy = NULL;
    float        flBestDist = MAX_TRACE_LENGTH;

    while ( ( pEnt = gEntList.FindEntityInSphere( pEnt, GetAbsOrigin(), ROLLERMINE_DETECTION_RADIUS ) ) != NULL )
    {
        if ( IRelationType( pEnt ) != D_HT )
            continue;

        float distance = ( pEnt->GetAbsOrigin() - GetAbsOrigin() ).Length();
       
        if ( distance >= flBestDist )
            continue;

        pBestEnemy = pEnt;
        flBestDist = distance;
    }

    if ( pBestEnemy != NULL )
    {
        SetEnemy( pBestEnemy );
        return true;
    }

    return false;
}


I was thinking maybe somewhere in CMissile::SeekThink (not really sure where?)
I could implement something like..
if not guiding, find entity in radius, if relation == D_HT, assign that entity as targetpos?

Then if I have the laser It's controlled by laser, if I toggle the laser off with right click then it will auto target enemies.

Do you think it would work fine this way? Or am I completely off? If this would work.. it looks like you could almost implement this feature in just a couple of lines and then re-enable toggling of laser and you're set?
droogie
Dumpling
Dumpling
 
Joined: Fri Oct 15, 2010 8:04 am

Re: RPG modifications in HL2

Postby zombie@computer on Sat Oct 16, 2010 8:12 pm

yeah, sounds about right, dough i wouldnt work with relations. I presume a heatseeker should target fire if its around instead of some npc, right? In that case you will want all entities (including non-ai entities) to have a temperature property so you can choose between them. Anyway, its a good start i guess.
When you are up to your neck in shit, keep your head up high
zombie@computer
Forum Goer Elite™
Forum Goer Elite™
 
Joined: Fri Dec 31, 2004 5:58 pm
Location: Lent, Netherlands

Re: RPG modifications in HL2

Postby droogie on Sat Oct 16, 2010 8:20 pm

Hrm true, I should have re-worded the initial goal. It wasn't technically "heat seeking" but generally just a homing missile on enemy entities. But while I'm playing with It maybe I will just turn it into heat seeking. It would be more practice and help me learn more. I'm going to play with this and see if I can just get the homing part to work on enemy entities and go from there. Thanks!
droogie
Dumpling
Dumpling
 
Joined: Fri Oct 15, 2010 8:04 am

Return to Programming

Who is online

Users browsing this forum: No registered users

cron