NPC's in multiplayer

Please don't post here unless its in response to an existing topic. New discussion is to be shared in the other forums.

NPC's in multiplayer

Postby Wildfire » Thu Feb 15, 2007 10:22 pm

Here's the deal: I've been trying to get simple NPCs into HL2DM. After searching around the VERC forums and the VDC, it seems that people have been able to get at least zombies to work fine in MP by copying hl2_gamerules.cpp's InitDefaultAIRelationships function into hl2mp_gamerules.cpp.

Now I was almost certain that this was going to work, but apparently the SDK has changed since other people have done this, and zombie NPCs still crash my game to desktop a few seconds after I add one in-game with ent_create (or during map load if I try to load a map with existing zombies).

I'm pretty sure the function I copied works fine, I have all the latest zombie models from the EP1 gcf, and my skills.cfg has the proper stuff. I am using VC++2005 Express, if that matters. Any ideas?
-Wild
Wildfire
New Blood
 
Posts: 35
Joined: Mon Dec 04, 2006 4:36 pm
Location: NM, USA

Postby steven_m64 » Fri Feb 16, 2007 6:12 pm

AI in hl2 is designed for SP play only, changing it so it works well in a multiplayer game without causing lag or crashing will not be easy unless you know the SDK well and are proficient at C++.


you should look into what is causing the crash care of visual studios debugger, then work off and backtrack where the crash is caused to help fix the problem.
steven_m64
Retarded Coder
 
Posts: 25
Joined: Tue Nov 21, 2006 7:41 am

Postby Wildfire » Sat Feb 17, 2007 11:07 pm

Alright, so InitDefaultAIRelationships was set to return nothing in gamerules.h.

So now that they work without actually crashing, there are more complications. The zombie walk animations are jerky, but I don't mind that for now. Hitting the zombies with the crowbar or stunstick does so much damage that it splits them in half, but they stay alive and turn invisible (fixed that by just stopping them from splitting in half altogether.)


The one problem that makes it unplayable though, is that for some reason, the map simply ends a few seconds after spawning zombies (the map just changes as if the timelimit ran out).

I have no idea what would make it do that, but I'm trying to look into it. All I changed was the AI relationship stuff. How can I find out what's causing the game to change maps? Any ideas or help would be appreciated.
Last edited by Wildfire on Sun Feb 18, 2007 2:17 pm, edited 1 time in total.
-Wild
Wildfire
New Blood
 
Posts: 35
Joined: Mon Dec 04, 2006 4:36 pm
Location: NM, USA

Postby steven_m64 » Sun Feb 18, 2007 12:11 am

check into the time limit cvars and see what the defaults are initialized to and what thay are set to via cfg.

also check the usage of the cvars to see if there being used incorrectly (cvar is meant to be set as minutes but is used as seconds in code)
steven_m64
Retarded Coder
 
Posts: 25
Joined: Tue Nov 21, 2006 7:41 am

Postby Wildfire » Sun Feb 18, 2007 12:26 am

The wierd thing is that the timelimit works exactly as it should if I don't mess with NPC's.

This map change problem occurs only when I add zombies. Sometimes it changes the map 2 seconds after adding a zombie, sometimes 10. It seems random, but there have also been several occasions where it changed the map on the very instant I switched to a new weapon or shot a zombie (before I fixed the AIRelationships thing, it actually seemed to crash at the same moments, so I'm thinking that whatever was happening to make it crash, it now causes it to change levels instead).

I haven't tried loading a map that already has NPC's on it since fixing the AIRelationships thing, so I will probably try that and see if there's any difference.


EDIT: Loading a map with existing zombie NPC's just makes it change the map at the very moment it finishes loading. :(
-Wild
Wildfire
New Blood
 
Posts: 35
Joined: Mon Dec 04, 2006 4:36 pm
Location: NM, USA

Postby steven_m64 » Sun Feb 18, 2007 12:52 pm

sounds like you screwed up some code.
steven_m64
Retarded Coder
 
Posts: 25
Joined: Tue Nov 21, 2006 7:41 am

Postby Wildfire » Sun Feb 18, 2007 2:08 pm

There was nothing to screw up.

In HL2DM, the game will crash after a few seconds if you add a zombie to the game.
For my mod, I copied the InitDefaultAIRelationships function from hl2_gamerules.cpp into hl2mp_gamerules.cpp. It compiles and runs fine, except now the map changes a few seconds after a zombie is added instead of crashing.
If I comment out the new function, the mod becomes exactly like HL2DM again. I didn't mess with anything else.

There's some code already there that's causing it to change maps when I add a zombie.

Is there any way to find out why the game decides to change maps at that point? How can I find the part of the code that is causing it to change levels when it shouldn't?
-Wild
Wildfire
New Blood
 
Posts: 35
Joined: Mon Dec 04, 2006 4:36 pm
Location: NM, USA

Postby steven_m64 » Sun Feb 18, 2007 5:31 pm

place a breakpoint for the debugger on the changelevel code and backtrack to where it was called.
steven_m64
Retarded Coder
 
Posts: 25
Joined: Tue Nov 21, 2006 7:41 am

Postby Wildfire » Mon Feb 26, 2007 11:04 pm

Got it working.

The function GoToIntermission was being called to change the map. Even if I commented out all the calls to that function, it still for some reason seemed to get called anyway.
I solved it by basically copying GoToIntermission into a new function, GoToIntermission2, then commenting GoToIntermission's contents, and finally changing the calls to GoToIntermission into calls to my GoToIntermission2. Works great now.

Also, zombie co-op is fun. 8)
Image
-Wild
Wildfire
New Blood
 
Posts: 35
Joined: Mon Dec 04, 2006 4:36 pm
Location: NM, USA

Postby Bob » Mon Feb 26, 2007 11:36 pm

Looks good!

Should be fun. Keep posting if you need further help.

Bob
Bob
Site Admin
 
Posts: 252
Joined: Mon Nov 20, 2006 12:24 am
Location: San Jose California


Return to Unsorted Old Posts

Who is online

Users browsing this forum: No registered users and 1 guest

cron