Jump to content

Bad Company Manager (ApiMod for Servers)


StompyNZ

Recommended Posts

Do any of your commands give you the ability to determine which prefab you're standing closest to?

 

...let me back up.

 

The ability to fix a prefab, by standing near it and getting that particular prefabs ID to spawn it in, would be cool. It's a lot of pieces though... getting the list of prefabs (done). Getting the coordinates of the one you're next to (can be done). Reimporting it (can be done). I'm sure I'm missing some pieces though, but it'd be nice to "fix" certain areas more easily.

 

yeah thats not overly hard to do

Link to comment
Share on other sites

I'm wondering if your new spawning system will still work once the put the sleeper system in place. it sounds like they are replacing many wandering zombies with static ones that aren't trigger until you create an event in proximity to them.

 

They might be making major hard coded changes to achieve the change.

 

I can bypass all of that and just spawn an entity where I want it.

 

Entity entity = EntityFactory.CreateEntity(entityClassID, new Vector3((float)x, (float)y, (float)z));

 

GameManager.Instance.World.SpawnEntityInWorld(entity);

Link to comment
Share on other sites

I can bypass all of that and just spawn an entity where I want it.

 

Entity entity = EntityFactory.CreateEntity(entityClassID, new Vector3((float)x, (float)y, (float)z));

 

GameManager.Instance.World.SpawnEntityInWorld(entity);

Don't attempt to spawn mobs from your heartbeat thread or any other thread besides the main.

I tried many different ways but if i spawned mobs from a different thread I would always get a random crash.

I had to have my heartbeat fire from API.GameUpdate().

 

Did you have any luck pulling a particle list? Very interested in that

Link to comment
Share on other sites

Don't attempt to spawn mobs from your heartbeat thread or any other thread besides the main.

I tried many different ways but if i spawned mobs from a different thread I would always get a random crash.

I had to have my heartbeat fire from API.GameUpdate().

 

Did you have any luck pulling a particle list? Very interested in that

 

Cool, was about to ask what the issues were but you updated :)

 

Maybe I can add a spawn request to a queue then have a check in the api update method and execute them that way. The update method fires a LOT so would want it to be a very light bit of code in there if theres nothing to do.

 

My heartbeat starts in the API constructor atm, will see what I can get working.

 

     Dictionary<int, Transform> pe = new Dictionary<int, Transform>();

     object[] array = Resources.LoadAll("ParticleEffects", typeof(Transform));
     object[] array2 = array;
     for (int i = 0; i < array2.Length; i++)
     {
       object obj = array2[i];
       string text = ((Transform)obj).gameObject.name;
       if (!text.StartsWith("p_"))
       {
         continue;
       }
       else
       {
         Log.Out(text);
       }
     }

Link to comment
Share on other sites

One thing I was trying to do was create a new entity class object. I got past the first issue of how to reference it in the xml (had to add the assembly info after the class name) but when it trys to spawn says its an empty entity. If I can get that working I can then add unique entities with special abilities such as the resurect zombie MM mentioned, or do a proper suicide zombie rather than the hack one I currently use.

Link to comment
Share on other sites

Could also just call the command to spawn via a netpackage I guess :) and then just call another console command
I tried calling /se and /sme and both had the same issue with random crashes when called from a separate thread.

 

Also I made a resurrection Skill a few weeks ago before i saw madmole make that video. it just checks the defined radius for dead entities. when it finds them it removes them and respawns them in that location

Link to comment
Share on other sites

Do you get the stand up animation when that happens? Can you mask the transition with a particle effect? The cop explosion would be kinda cool...
I'm still trying to figure out how to spawn a ParticleEffect at a location. Once that is figured out yes. They do spawn in laying down though
Link to comment
Share on other sites

Did you try the GameManager.SpawnParticleEffectServer method? I'm in the middle of updating my persistent data system atm or I'd give it a whirl.

 

Did the crash report give any meaningful info?

 

Once I get this update sorted i'll have a go at spawning some stuff and see what happens

Link to comment
Share on other sites

I've worked out how to read the skills data that was encoded in a memory stream so now I can get the skills (or any other var) for offline players without recording them in the persistent data

 

PlayerDataReader for anyone that wants it for a mod

 

     string steamid = "12341234123412345"; // insert steam id here 
     PlayerDataReader pdr = new PlayerDataReader();
     pdr.GetData(steamid);

     foreach (Skill s in pdr.skills)
     {
       SdtdConsole.Instance.Output(s.Name + "\n");
     }

Link to comment
Share on other sites

Sorry to hijack a thread here, but you guys seem so knowledgeable with API mods. There must be some function I can call to load chunk data on my server, but I haven't been able to figure it out yet. Basically, I need to make some block changes in an area that likely won't have any players nearby, so I need the server to load that chunk (even if just temporarily). It must be possible but I have yet to figure out what to call to make it happen.

Link to comment
Share on other sites

Sorry to hijack a thread here, but you guys seem so knowledgeable with API mods. There must be some function I can call to load chunk data on my server, but I haven't been able to figure it out yet. Basically, I need to make some block changes in an area that likely won't have any players nearby, so I need the server to load that chunk (even if just temporarily). It must be possible but I have yet to figure out what to call to make it happen.

 

I've been trying to work that out... but its being tricky.

 

One idea i have is to spawn an entity with the chunk observer flag set to true to force it to load, but will need to test the idea.

Link to comment
Share on other sites

I'm new to reverse-figuring these types of things out. I saw the WorldChunkCache.AddChunkSync() function, but I don't know what object to attach it to. (Tried everything I could think of under GameManager.Instance but couldn't figure out where it should go.) Maybe GameManager.Instance.World.m_ChunkManager has a function that would work?

 

Can you spawn an entity into a chunk that's not loaded? I thought of that kind of workaround too, but wasn't sure if it would work.

Link to comment
Share on other sites

I'm new to reverse-figuring these types of things out. I saw the WorldChunkCache.AddChunkSync() function, but I don't know what object to attach it to. (Tried everything I could think of under GameManager.Instance but couldn't figure out where it should go.) Maybe GameManager.Instance.World.m_ChunkManager has a function that would work?

 

Can you spawn an entity into a chunk that's not loaded? I thought of that kind of workaround too, but wasn't sure if it would work.

 

the loaded chunk cache is GameManager.Instance.World.ChunkCache

 

you can get (i think) the chunk provider with this

 

ChunkProviderGenerateWorldRandom2 _chunkProvider = new ChunkProviderGenerateWorldRandom2(GameManager.Instance.World.ChunkCache, GameManager.Instance.World.GetWorldCreationData(), GamePrefs.GetString(EnumGamePrefs.GameWorld));

 

but I'm not really sure what to do with it after that yet. I was hoping RequestChunk would be what I was looking for but couldnt get it to work the way I wanted.

 

GameManager.Instance.World.m_ChunkManager.AddChunkObserver might be something I can use, but didn't get as far as testing it yet.

Link to comment
Share on other sites

Did you try the GameManager.SpawnParticleEffectServer method? I'm in the middle of updating my persistent data system atm or I'd give it a whirl.

 

Did the crash report give any meaningful info?

 

Once I get this update sorted i'll have a go at spawning some stuff and see what happens

Yes I see all the Particle Spawning methods in GameManager I just can't figure out which method to use to create a new ParticleEffect class. Making the ParticleEffect that will be spawned.

 

And on the crash when spawning mobs. Nothing in the logs. It was the weirdest crash i have seen. The server just quit working and it asked me to send a report to developers. It took awhile to track what was causing it since it was so random. I'm guessing it has something to do with the main thread iterating over the entity list while i was changing it from a separate thread. not 100% sure though

Link to comment
Share on other sites

Have y'all seen anything that would allow for an observer mode? Log in as an invisible whatever, who can attach themselves to another players 3rd person perspective?
I haven't come up with anything like that yet. But If I do i will be sure to let you know
Link to comment
Share on other sites

Have y'all seen anything that would allow for an observer mode? Log in as an invisible whatever, who can attach themselves to another players 3rd person perspective?

 

moving the player can only be done via a teleport from what ive seen. It might be possible to use a push effect, but thats getting pretty technical and not an easy one to solve.

Link to comment
Share on other sites

Yes I see all the Particle Spawning methods in GameManager I just can't figure out which method to use to create a new ParticleEffect class. Making the ParticleEffect that will be spawned.

 

And on the crash when spawning mobs. Nothing in the logs. It was the weirdest crash i have seen. The server just quit working and it asked me to send a report to developers. It took awhile to track what was causing it since it was so random. I'm guessing it has something to do with the main thread iterating over the entity list while i was changing it from a separate thread. not 100% sure though

 

Without testing I would guess just calling new ParticleEffect() would do it.

 

 

something like:

new ParticleEffect("impact_organic_on_earth", (Vector3)pos, (float)1.0, Color.white, string.Empty, "p_", false)

 

I've tested the spawning thing and I think you are right about it being a case of changing the entities list while the main process is trying to read it. I have my thread call wrapped in a try/catch and that doesn't catch the exception so its happening in the main thread in a place that doesn't have exception handling.

 

I'll have a go with the queue idea and see if that works better.

Link to comment
Share on other sites

Without testing I would guess just calling new ParticleEffect() would do it.

 

 

something like:

new ParticleEffect("impact_organic_on_earth", (Vector3)pos, (float)1.0, Color.white, string.Empty, "p_", false)

 

I've tested the spawning thing and I think you are right about it being a case of changing the entities list while the main process is trying to read it. I have my thread call wrapped in a try/catch and that doesn't catch the exception so its happening in the main thread in a place that doesn't have exception handling.

 

I'll have a go with the queue idea and see if that works better.

No luck yet =( Not getting any errors but no particles yet either.

try
{
     Quaternion _new = new Quaternion(0f, 0f, 0f, 0f);
     ParticleEffect _pe = new ParticleEffect("p_burning_barrel", player1POS, _new, 1.0f, Color.white);
     GameManager.Instance.SpawnParticleEffectServer(_pe, _cInfo.entityId);
}
catch (Exception e)
{
     Log.Out("Error in Spawning ParticleEffect: " + e);
}

Link to comment
Share on other sites

After a lot of trial and error I've come to the conclusion it was my call to the EntityFactory was being a problem inside the thread.

 

Entity _entity = EntityFactory.CreateEntity(entityClassID, pos);

 

Even with almost everything else pushed out to the API.Update class calling this in the heartbeat thread was causing the random crashes after about 20 zombie spawns on average.

 

The crash logs often mentioned physics and colliders being the root function being executed at the time of the crash.

 

Once I moved that into the api update and just used the heartbeat thread to push the required classid and pos into a queue that the api update locked I had no problems

 

Over 250 zombies and still spawning.

Alpha_15.1_2017-01-12_14-18-06.jpg

Link to comment
Share on other sites

  • xyth locked this topic

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...