hpw to make enemy npc friendly and able Created 8 years ago2015-11-30 15:09:04 UTC by spforce spforce

Created 8 years ago2015-11-30 15:09:04 UTC by spforce spforce

Posted 8 years ago2015-11-30 15:09:04 UTC Post #327602
hello.
i have what is need for the latest sdk visul studio 2010
dont have any knowledge in c++
i looked at many of the game code and i know changeing the classify to return CLASS_PLAYER_ALLY; will make npc friendly
what i want to do is to make a orignaly enemy the female assassin npc
friendly but also be able to follow you i attempted to do this 2 times without success then looked agian in the sdk through github and figured out at least some of the things that need to be added
SetUse( &CBarney::FollowerUse );
and Schedules and Taskes need to be add still not sure how really to do this so if some one get just give edited hassassin.cpp file and explain the changes what was changed added and whetever it will be best way to learn this.
Thanks
Posted 8 years ago2015-12-01 16:03:14 UTC Post #327614
Why do not use Spirit of HL, it allows you to set any behaviour for monsters.
Posted 8 years ago2015-12-01 16:26:29 UTC Post #327616
While you can certainly modify the code yourself, you should seriously consider looking into Spirit when making GoldSource mods these days.

They let you set your NPCs allegiances, model, skin and behaviour. Not to mention all the other cool crap and streamlining it features.
monster_urby monster_urbyGoldsourcerer
Posted 8 years ago2015-12-01 21:51:25 UTC Post #327626
I dont think spirit can let him have assassins follow you around, only make them friendly to the player.

I know a mod, xen rebels, where assassins are friends that also follow you around. But I really dont think its a good idea. Their AI is meant to run around alot and this will conflict with its attempt to follow the player.
Posted 8 years ago2015-12-02 17:01:58 UTC Post #327634
With SoHL he can also use assassin's model as alternative replacement for Barney (probably with some tweaks in model/animations and speech sentences)... Another interesting choice is using a code of Azure Sheep, for example (there is already friendly female NPC and much more) :)
Posted 8 years ago2015-12-03 01:04:20 UTC Post #327635
thanks to all the replays but what i want is just edited female assassin code so it follow able like barney when you use the use key and then i can learn by looking at it how it was done what was add and edited from the original unedited as i said i already changed it to play_ally and i know it will be friendly but just this classfiy code is not what will make it follow able using the use key i did some attempts: adding the shedules and Taskes the set use and that thing of return for shedules that make name you give to use the code and ingame the use key didn't do anything something needed was probably missing , so i want to not mess and to keep trying without success and get someone to give edited code so i can see what was changed and add and from that i can learn how it was done, and there is no need for speak talking lines to be said about follow and stop follow becuase she dont have, i want to know how to make any npc you want to be able to follow you with the use key what need to be add edited and where also beside the npc cpp file if needed.
Posted 8 years ago2015-12-25 21:06:35 UTC Post #327917
no any help? cant find any way to do this..
Posted 8 years ago2016-01-11 01:55:11 UTC Post #328182
Like you said, changing the female assassin's class to CLASS_PLAYER_ALLY won't be enough.

She will indeed consider you as a friend, but you won't be able to "use" her to follow you/stay in position, she won't speak and she may also throw a grenade at friendlies when attacking enemies.

The first you will have to is change the base class used by the female assassin, you will have to use "CTalkMonster". Then, you will have to copy/paste some code from Barney/Scientist in order to make her speak but also receive the "Follow me/stay in position" orders. And finally, you might want to add some "last touches" stuff like "I'm about to throw a grenade, is there any friend nearby of the explosion radius? If yes, I shouldn't blow my friend. If not, I throw it."
Posted 8 years ago2016-01-11 11:13:40 UTC Post #328186
first thanks for the replay, i pretty much know i sure all what need to be added, adding to include the ctalkmonster in the includes since its the header that have the code needed it will change to : class CHAssassin : public CSquadMonster , public CTalkMonster and also i knew i need add to add that tasks and schedules by looking at barney and the scientist code i figured that out alone , i found one who asked how to make the human grunt to follow you here: http://www.moddb.com/forum/thread/how-to-make-hgrunt-to-follow-you from there i knew about the public , public thing and i have a problem that is remain to do this i attempd to try this guys code first to have the human grunt followable he posted the code here http://pastebin.com/Jq0EwWqL but the ambiguous case is the problem since the compiler can't know without indicate the function that is used from the CSquadMonster or the CTalkMonster so in the page bottom the anwser for this was the example:
* Starting Line 251 *
void CHGrunt::DeclineFollowing( void )
{
PlaySentence( "HG_POK", 2, VOL_NORM, ATTN_NORM );
}

*Starting Line 251*
void CHGrunt::DeclineFollowing( void )
{
CSquadMonster::PlaySentence( "HG_POK", 2, VOL_NORM, ATTN_NORM );
}

//Or

*Starting Line 251*

void CHGrunt::DeclineFollowing( void )
{
CTalkMonster::PlaySentence( "HG_POK", 2, VOL_NORM, ATTN_NORM );
}

depends on which function is needed, in this case sure the ctalkmonster i copyed all the code change he did posted on pastbin and after this function separate fix to ge trid of the ambiguous case error there is still other ambiguous cases errors that i dont know and sure how to fix them i can show the errors here im sure this very likely to happen on the hassassin too, also last thing in ctalkmonster cpp any new friend that is follow able must to be add here right? // array of friend names
char *CTalkMonster::m_szFriends[TLK_CFRIENDS] =
{
"monster_barney",
"monster_scientist",
"monster_sitting_scientist",
};
i did add the grunt but there was a error when i did that i will edit this post soon to write it here
Posted 8 years ago2016-01-11 15:06:18 UTC Post #328190
You must add the friendly female assassin's entity name to the "m_szFriends" array of "CTalkMonster", assuming she's named "monster_hassassin_friendly", it should look like that:

char *CTalkMonster::m_szFriends[TLK_CFRIENDS] =
{
"monster_barney",
"monster_scientist",
"monster_sitting_scientist",
"monster_hassassin_friendly",
};

If your compile error is related to "TLK_CFRIENDS", you will have to find where this define is and increment it's value by one because this value defines the size of the "m_szFriends" array. In other words, if a basket is designed to carry 10 eggs maximum, you can't put 11 eggs or more in it.
Posted 8 years ago2016-01-11 17:37:53 UTC Post #328191
i remember i saw another TLK_CFRIENDS with number when i searched this more to understand and figure the code i did tought some number need to be changed to allow more, i from the beginning was assume a number need to be changed to allow more using github just for looking and searching without from the compile program saw found in second this in talkmonster.h just at the beginning line 40 : #define TLK_CFRIENDS 3
so i just need to change this 3 to 4 to give space for 1 more guy so thanks for the fix for this but still there are problems of ambiguous cases and yes i trying this first with the human grunt and not the hassassin so i have to know what is the function (header) for each of the ambiguous cases and for each of the cases use the calling to so it won't mess up , the errors can be seen here: http://www.moddb.com/forum/thread/how-to-make-hgrunt-to-follow-you , in the post before the last, and thanks for the help again
Posted 8 years ago2016-01-11 23:12:19 UTC Post #328195
Mmh... This is weird.

In the past, I managed to make a friendly variant of the female assassin, but I've lost the code like an idiot so I tried to make it over again.

First attempt: implement Barney follow/talk code into a copy/paste of CHAssassin (that inherit CTalkMonster instead of CSquadMonster), she talks, attacks, react but I can't move her and I have the "use nothing" noise when I attempt to "use" her.

Second attempt, take CBarney as base and implement CHAssassin stuff, I can use "her", she talks, respond but she don't attack/move, she's like a speaking prop.

I'll try a third attempt and this time I'll be more careful about what I'll implement.
You must be logged in to post a response.