Is it possible to make a monster follow another monster? Created 5 years ago2019-10-03 11:51:38 UTC by abbadon abbadon

Created 5 years ago2019-10-03 11:51:38 UTC by abbadon abbadon

Posted 5 years ago2019-10-03 11:51:38 UTC Post #343184
I know scientists do, but, would not it be troublesome for monsters spawned by monstermakers?
Posted 5 years ago2019-10-03 21:22:50 UTC Post #343185
I think it's possible.
Admer456 Admer456If it ain't broken, don't fox it!
Posted 5 years ago2019-10-03 23:10:00 UTC Post #343186
A monster following another monster? Like, actively? I'm not sure that you could. Unless you faked it or the monster was trying to kill the other...
Jessie JessieTrans Rights <3
Posted 5 years ago2019-10-04 09:52:50 UTC Post #343187
Abbadon has coding powers, so of course it's possible. The scientist class has a follow task&schedule:
User posted image
And it's handled somewhere in the GetSchedule function:
User posted image
Keep in mind that this is scientist-specific, so you don't necessarily have to make your monsters heal each other. But you can. :D

If you base your monster off CTalkMonster, I believe you could get such monsters (that are spawned by a monstermaker) to follow a certain thing:
User posted image
You can call StartFollowing and pass it the entity you need the monster to follow. I'm not exactly sure what approach you're going for, but I think this is approximately what you need to follow a monster. :)
Admer456 Admer456If it ain't broken, don't fox it!
Posted 5 years ago2019-10-04 13:57:36 UTC Post #343188
Ok, Admer!! but remember that I struggle even with the "Hello World" program :walter: ha, ha!!! I will try to implement those parts into the infantry coder (monster_gunner.cpp).

Thanks! :crowbar:
Posted 4 years ago2020-01-05 23:04:44 UTC Post #343560
:crowbar: Done!!, but game crash each time the monster spawns... :pwned:

Here´s all the code. Forgive me if I did not rename the Islave monster from CIslave to CGunner :lol:

I have modified its relationship:
//=========================================================
// Classify - indicates this monster's place in the
// relationship table.
//=========================================================
int    CISlave :: Classify ( void )
{
    return    CLASS_PLAYER_ALLY;
}


int CISlave::IRelationship( CBaseEntity *pTarget )
{

    if ( FClassnameIs( pTarget->pev, "monster_sentinel" ) )
    {
        return R_NM;
    }
    if ( FClassnameIs( pTarget->pev, "player" ) )
    {
        return R_AL;
    }
    if ( FClassnameIs( pTarget->pev,  "monster_trolley" ) )
    {
        return R_HT;
    }


    return CBaseMonster::IRelationship( pTarget );
}
wrote the new code:
//=========================================================
// Codigo para seguir a los Trolley
//=========================================================

Task_t    tlFollow[] =
{
//    { TASK_SET_FAIL_SCHEDULE,    (float)SCHED_CANT_FOLLOW },    // If you fail
    { TASK_MOVE_TO_TARGET_RANGE,(float)640        },    // Move within 640 of target ent (monster_trolley)
//    { TASK_SET_SCHEDULE,        (float)SCHED_TARGET_FACE },
};

Schedule_t    slFollow[] =
{
    {

        tlFollow,
        ARRAYSIZE ( tlFollow ),
        bits_COND_NEW_ENEMY |
        bits_COND_LIGHT_DAMAGE |
        bits_COND_HEAVY_DAMAGE |
        bits_COND_HEAR_SOUND,
        bits_SOUND_COMBAT |
        bits_SOUND_DANGER,
        "Follow"
    },
};
Of course I have definded all...
DEFINE_CUSTOM_SCHEDULES( CISlave )
{
    slSlaveAttack1,
    slSlaveEstablishLineOfFire,
    slFollow,
};
And in:
Schedule_t *CISlave :: GetSchedule( void )
I placed:
//=================================================
// He follows who he hates...
//=================================================
    if ( HasConditions (bits_COND_SEE_HATE ) )
    {
        return  slFollow;
    }
 //=================================================
Also I put the "follow" thing in:
Schedule_t *CISlave :: GetScheduleOfType ( int Type )
{
    switch    ( Type )
    {
    case SCHED_FAIL:
        slSlaveEstablishLineOfFire;//ZWC
     case SCHED_RANGE_ATTACK1:
        return slSlaveAttack1;
    case SCHED_TARGET_CHASE:
        return slFollow;
    }
    return CSquadMonster :: GetScheduleOfType( Type );
}
Posted 4 years ago2020-01-06 14:33:07 UTC Post #343565
BTW: if I comment THIS part...
//=================================================
        if ( HasConditions (bits_COND_SEE_HATE ) )
        {
            return  GetScheduleOfType( SCHED_TARGET_CHASE );
        }
     //=================================================
...the game runs perfect. The gunners attack the Trolley guy, yes, but the game does not crash at all. :|
Posted 4 years ago2020-01-07 01:31:42 UTC Post #343566
You can format code blocks like this, FYI:
```
code goes here
```
Penguinboy PenguinboyHaha, I died again!
Posted 4 years ago2020-01-07 15:20:55 UTC Post #343568
THANKS so much Penguinboy, In the formatting options the code was enclosed in this singns code, and it look awful (sorry), but did not look into the Formatting Help link, moron me. :crowbar:
Posted 4 years ago2020-01-08 20:40:19 UTC Post #343574
Aniway... Any ideas on how to solve this? I have surrender some hours ago... I mean: how can I make the gunners follow the trolley guy without crashing the whole game. My compile is Win32_release not debug, so I cannot debug a thing, also, I am not able to setup the projects correctly to be Win32_debug instead (each time I did it I find myself with a ton of errors and "thiscall", "unknown stuff" etc.

PS: I have tried the tracktarget method of the Hornet and, no, it still crashes the game. :)
Posted 4 years ago2020-01-12 07:23:15 UTC Post #343600
I think you should be able to debug a release build if the .pdb file is in the same directory as the .dll?
Anyway, you should copy your changes into a clean project so that things are set up correctly (probably too hard to recreate Debug - I'm sure Visual Studio takes care of a lot of stuff).
Posted 4 years ago2020-05-23 17:12:35 UTC Post #344289
A monster following another monster? Like, actively? I'm not sure that you could. Unless you faked it or the monster was trying to kill the other...
Sorry for bumping this, but I totally forgot to THANK Jessie for pointing me to the right direction, because finally that´s what I did in the end, so any credit is for you! Thanks Jessie. :)
Posted 4 years ago2020-05-24 13:12:40 UTC Post #344295
Maybe the target (aka the monster to follow) becomes invalid at some point and the game crash due to an attempt to access an invalid pointer.

Try implementing this fix I made for Parasomnia and see if it solves the problem or not.
Posted 4 years ago2020-05-24 13:53:53 UTC Post #344296
Hi Shepard!!, Wow, that´s the fix I needed ages ago!, haha. I tried something similar but, as you did say, the game crashed over and over, of course my code was, as always, intuitive (I see a piece of code that I "think" works ina certain manner and then I copy-paste it to see if it works). Mmmmm, I´ll try this. Well, my code does not crash because it just make the gunners "chase" the Trolley guys and because there are better targets, finally they get close to the Trolley but don´t shoot him. Very dirty coding, imho. :)
You must be logged in to post a response.