Home / Forums / Modders Corner / Mafia Editing / Mod Help / NPC, taking lots of CPU

Viewing 15 posts - 1 through 15 (of 20 total)

NPC, taking lots of CPU

Home / Forums / Modders Corner / Mafia Editing / Mod Help / NPC, taking lots of CPU

19 replies
13 years, 12 months ago
#7250

Thanks to the quick help I got the Bscript issue solved.

But I got a new one :woohoo:

 

I noticed as soon as I added 1 NPC, the scene had a severe overall framedrop. this means going from 50-60 frames to 40-50, about a 10 frame drop. now imagine a couple tens of more NPC’s that would make the game crash.

Does anyone know what causes this? I expect a NPC to take some CPU power yes, but 10 frames for one single NPC seems a little bit too dramatic to me.

 

Besides, on the dock scene where Titanic is anchored there are about a hundred NPC’s all animated with about the same 10 frame shortage. that’s reasonable I think.

 

Lowering the level of detail/ draw distance did not help much.

 

Is there something I should look at? or does anyone know how to solve this?

 

Like always, help is greatly appreciated!

13 years, 12 months ago
#10076

Hi Rob,

 

Try taking out anything in the scene that isn’t needed/is excess detail that will not be seen.

The engine sometimes struggles to render lots of npcs and a lot of scenery at the same time.

 

For example, for the dock scene you would only need Little Italy and Central Island. New Ark, Downtown, Hoboken, Oakwood and Oak Hill cannot be seen from the dock and are therefore useless “luggage” for the engine to cope with.

13 years, 12 months ago
#10078

Hey Rob, the only time that has happened to me, is when I had created a loop within a loop and the npc script got running the loop over and over on top of each other…are you sure its the same script, and is that script calling for a missing object or otherwise defaulting into a loop?

 

You want to post the script for review?

 

200 + NPC’s all doing the same thing….

http://www.youtube.com/watch?v=cBa-TdIXuTI

13 years, 12 months ago
#10085

Thanks for the replies!

 

the problem is, nothing in that scene is unnecesairy. it’s the exterior model of the ship with only the boatdeck grand staircase inserted.

 

The exact same model without the GSC is added to the dock scene. so this very complex model plus the city should run far more slower with all of those NPC’s instead of only the exterior with the GSC model and only 1 npc.

 

and the GSC model does not have that many polygons. at least not enough to make impact on the CPU usage.

 

Maybe what Matteo says is right, it could be a endless loop. your video explains very well that the game should be capable of showing many NPC’s (I like that video btw <img decoding=” data-emoticon=”” srcset=”/wp-content/uploads/invision_emoticons/tongue@2x.png 2x” width=”20″ height=”20″> )

 

This is the script I gave the captain:

[img]//i102.photobucket.com/albums/m104/mrr_03/script.jpg&key=78d13941f5bb8bb7a54b55de56ed9c487f2cf451965823c2df9fb09e117fee49[/img]

 

To see if it was the script causing it, I deleted it and tested the game.

 

FPS with the captain still alive:

[img]//i102.photobucket.com/albums/m104/mrr_03/game2012-02-1513-24-41-46.jpg&key=7a2b0e41584765869e438d72d60aac5b843678cd79a5c8a90326b4d3ebbaa0e5[/img]

 

Tragedy happened:

[img]//i102.photobucket.com/albums/m104/mrr_03/game2012-02-1513-25-23-32.jpg&key=013f86811ee246292eb113a1280aabf1bddd9b09f9efed92a53aaca4431fb4e1[/img]

 

FPS with the captain dead:

[img]//i102.photobucket.com/albums/m104/mrr_03/game2012-02-1513-26-39-17.jpg&key=c313b94c539951fc6c0fd2e9afa487d4511bba649b811927315ffcf16a27df9b[/img]

13 years, 12 months ago
#10089

How’s the FPS without any NPCs Rob?

13 years, 12 months ago
#10091

the same as with dead NPCs

it varies from where I’m standing. I’m still working on some optimizations.

the effect of objects fading out when far away is very CPU intensive, so if I make an empty model as the far distance model of an object, the object should just dissapear and not fade out when the player is walking away from it.

 

So the framerate is very random, it can be 60Frames, or 30

13 years, 12 months ago
#10092

Try changing the wait portion of the npc script to a finite wait

 

change

 



let flt[0]=flt[0]-500



wait flt[0]

 

to



wait 1500

 

or however long the wait period is for the animation

 

 

nothing from nothing leaves nothing and it looks like MAYBE you are cycling the animation too fast – just a guess

13 years, 12 months ago
#10093

nopes, no luck, still the framedrop.

even though there is a wait command, the animation seems to loop instantly no pauses between.

13 years, 12 months ago
#10098

Okay I am just going to shoot some ideas out here

 

 

First I notice you didn’t ID the actor for the script and didn’t include some of the game nominclature

 

try this code (adjusted to your actor name and animation)

 

dim_flt 2

dim_act 2

findactor 0,”Tommy”

findactor 1,”woman2″

 

 

{ up

if flt[1]=1,2,-1

enemy_playanim “UStoluVysvetlovani01.I3D”,0

 

 

label 1

wait 10000

goto 1

label 2

}

 

 

It uses the {up} code which returns the character to the script after activation , it identifies the character and it shunts the the loop to a wait time that DOESN”T include the animation. Some animations need to be set once then left alone. And only need to be refreshed after the character was activated

 

Also I noticed you are using a police model which has some embedded scripts in regard to Tommy so set the character to no reaction on player

 

See if that helps

13 years, 12 months ago
#10102

I found the problem!

 

it has to do with Titanic’s collissions, apperantly the collission model is still too complicated for characters to calculate. so what I’ll do is to seperate the collission model of the deck itself from the rest of the collissions.

 

What I did to find out was to add about 15 NPCs into the scene, all with cordinates 0,0,0.

now they were all walking on the drop collission below the Titanic, no change in FPS!

 

Then I moved them all onto the ship, and as soon as I ran the game, FPS decreased to ~10FPS

After I killed them all, FPS went normal. That explains why the draw distance/ level of detail had no effect to this.

 

Let’s hope the best for this collission trick.

 

Thanks everyone for the great help once again!

13 years, 12 months ago
#10103

Cool Beans!

13 years, 12 months ago
#10116

Hmmm, I’m affraid my method is not working..

 

I split up the collission model into several parts, but still there’s a huge FPS drop.

I’m now gonna ask ASM, maybe he knows a trick, he’s my last resort I guess unless someone else knows how collissions work.

13 years, 11 months ago
#10133

Yesterday evening I was kindly assisted by ASM, I tested a few things that ASM suggested, but so far no great result. There’s still a framedrop. There’s a more technical story involved at what’s causing this.

So my guess is that I’ll have to stick with it. I’ll try to do my best at keeping the FPS as playable as much as possible with still a decent ammount of NPCs.

 

Luckely the interior collissions exist out of simpler shapes so they shouldn’t do much harm.

 

This is one of those setbacks that make me wish I had that SDK. I could optimize the scene to it’s finest.

Perhaps I’ll consider several loading screens for diffrent sections of the ship. This will also solve the issue with the sounds of the ocean and wind being heard inside of the ship.

13 years, 11 months ago
#10135

Sorry if this has already been suggested but have you got any other mods running? for example the snow mod… I can see you haven’t got that running but something similar.

 

I don’t know much about modding so this is probably a load of rubbish but just a thought I had.

13 years, 11 months ago
#10137

It may sound idiot, maybe when the action happens your CPU start to heat and to protect itself it slow down, i saw that in other puter and sometime just a good inside cleaning with an air blower so the CPU can fontionne properly.

Viewing 15 posts - 1 through 15 (of 20 total)
  • You must be logged in to reply to this topic.