mgr_inz_rafal Posted October 28, 2018 Hello All, I have a question to guys that know zDoom source code. I tried to register on "forum.zdoom.org", but they asked me some questions about zombies in Plutonia and official wikis that I don't know the answer to. Now I cannot register at all (maximum number of tries reached). So I'll try my luck here. I am looking for an ultimate place in the code that will let me track spawning and destroying of map items. What I found so far: Destroying: I hooked myself to the "void AActor::RemoveFromHash()" function of p_mobj.cpp file. This seem to be working correctly. Spawning: I hooked myself to the end of "AActor *AActor::StaticSpawn (PClassActor *type, const DVector3 &pos, replace_t allowreplacement, bool SpawningMapThing)" function. This works kinda ok until I, for example, pickup Plasma Gun. In that case the gun is removed from map, but new thing at position 0,0,0 is spawned. The tag says "$AMMO_CELLS", so I think this is an inventory item that is spawned in game but not on the map, maybe (see picture)? But this doesn't happen for Chaingun and regular ammo, making me confused :/ My idea is to track spawning and destroying of every map thing (I mean the things that appear on automap after "iddtiddt"). Can anyone comment if I hooked myself to correct places? 0 Share this post Link to post
Gez Posted October 28, 2018 3 hours ago, mgr_inz_rafal said: This works kinda ok until I, for example, pickup Plasma Gun. In that case the gun is removed from map, but new thing at position 0,0,0 is spawned. The tag says "$AMMO_CELLS", so I think this is an inventory item that is spawned in game but not on the map, maybe (see picture)? But this doesn't happen for Chaingun and regular ammo, making me confused :/ It's spawned in the player's inventory, which is why coordinates don't matter. For the chaingun, since it uses bullets, and the player already starts the game with bullets, there's no need to spawn anything. 0 Share this post Link to post
mgr_inz_rafal Posted October 29, 2018 Thank you, that gives me some insight. Can you help me, assuming I have an AActor class object, how can I check if it is going to be spawned on a map? I tried to figure it out from LinkToWorld(), but failed. Another question: having the same object how can I tell which class it belongs to? Is it an Imp, a Berserk or a Megasphere, for example? Like the "Type" property shown in Doom Builder (2002 = Chaingun, 3005 = Cacodemon). Once I know this I'll be able to manually filter the things I am interested in. 0 Share this post Link to post
mgr_inz_rafal Posted November 3, 2018 OK, here's what I found. To get an exact type name of an actor you can use actor->GetClass()->TypeName.GetChars() But this will give you, for example "Cell" for items spawned either in Inventory or on the map. To ignore the items spawned in the inventory I use the following condition actor->IsKindOf(RUNTIME_CLASS(AInventory)) 0 Share this post Link to post
mgr_inz_rafal Posted November 11, 2018 Hello, Today I had some more time to work on this issue and I feel obligated to give you an update, since it turned out that what I wrote above is bulls*.*it :) Correct apporach to monitor all active actors: Monitor each thing spawned by engine (even if it's spawned in the inventory) [AActor::StaticSpawn] Remove from monitoring things that are converted into inventory items (Clips, Pistol, etc.) [AInventory::BecomeItem] Remove from monitoring all things that are destroyed (BulletPuffs, etc.) [AActor::OnDestroy] Thanks for your attention :) 0 Share this post Link to post