Frictional Games Forum (read-only)
ReplaceEntity function (AMFP patch) - Printable Version

+- Frictional Games Forum (read-only) (https://www.frictionalgames.com/forum)
+-- Forum: Amnesia: The Dark Descent (https://www.frictionalgames.com/forum/forum-6.html)
+--- Forum: Custom Stories, TCs & Mods - Development (https://www.frictionalgames.com/forum/forum-38.html)
+---- Forum: Development Support (https://www.frictionalgames.com/forum/forum-39.html)
+---- Thread: ReplaceEntity function (AMFP patch) (/thread-25940.html)



ReplaceEntity function (AMFP patch) - MrBehemoth - 08-23-2014

Patrik Wrote:
Code:
void ReplaceEntity(string &in asName, string &in asBodyName, string &in asNewEntityName, string &in asNewEntityFile, bool abFullGameSave)

Removes the specified entity and places a new entity at its location.

asName- the name of the entity that should be replaced.
asBodyName- name of the body in the entity to place the new entity at. If "", the first body in the entity will be used.
asNewEntityName- name of the entity that should be created.
asNewEntityFile- .ent file that the new entitiy should be created from.
abFullGameSave- if ALL properties should be saved for the created entity

Has anyone had any trouble with this function from the beta AMFP patch? Whatever parameters I use cause a crash. I can achieve the same effect using multiple entities, but swapping them in would be ideal.

Just wondering if my problem is (a) because the function isn't fully implemented/debugged or (b) something specific to my entities/script.

Cheers!


RE: ReplaceEntity function (AMFP patch) - Rapture - 08-23-2014

For starters, it helps if you post your Code (Just the "ReplaceEntity" so we can check if you got errors)



Second, it does work.

void Script_Temp(string &in asTimer)
{
ReplaceEntity("Entity_ReplaceBarrel", "", "wood_box_small01_test", "wood_box_small01.ent", true);
}

The "Entity_ReplaceBarrel" should match the entity in the LEVEL EDITOR that you want to replace.

The second parameter should normally be nothing by default unless you got a specific one in mind.

The third is one is the name so you can call it back in code. (That works also)

The forth one is the ".ent" file you replace it with. You can browse to the folder with the object and copy the ".ent" name, or click a Entity in the Level Editor and get the name of the bottom of the property panel.


RE: ReplaceEntity function (AMFP patch) - MrBehemoth - 08-23-2014

Thanks Rapture. The issue is with my entities, which are unusual.

(08-23-2014, 01:43 PM)Rapture Wrote: For starters, it helps if you post your Code (Just the "ReplaceEntity" so we can check if you got errors)

Totally understand, but I didn't post it because I'm sure there's no errors there. Tongue

Code:
ReplaceEntity("CompScreen_Back", "", "CompScreen_Back", "blackaether/entities/computer/mail_0.ent", true);

// also tried
ReplaceEntity("CompScreen_Back", "", "CompScreen_Back", "mail_0.ent", true);
// and
ReplaceEntity("CompScreen_Back", "", "CompScreen_Back1", "blackaether/entities/computer/mail_0.ent", true);
// in case the issue was the new ent having the same name, plus various other things

Anyway, I think I know what the problem is - it's to do with the entities not containing any bodies, so even having an empty string as the 2nd parameter leaves the engine not knowing where to place the new entity. My real question wasn't "why isn't this working?" but rather "does this beta function definitely work?" and you answered that! Thanks! Smile


RE: ReplaceEntity function (AMFP patch) - Mudbill - 08-23-2014

Well, I set up a scene just to try the script myself, and the game crashed not knowing what the function was. It just spewed out the message of "ReplaceEntity does not match (string, string, string, string, bool)." I do have the patch installed though.

Is this the same issue you had? If so, I'm interested in knowing how Rapture got it working. Perhaps there's something in addition to the patch that I'm missing.


RE: ReplaceEntity function (AMFP patch) - MrBehemoth - 08-23-2014

(08-23-2014, 02:22 PM)Mudbill Wrote: Is this the same issue you had?

Nope, it just crashed to Black Box, which only gave me some memory addresses.


RE: ReplaceEntity function (AMFP patch) - PutraenusAlivius - 08-23-2014

(08-23-2014, 02:22 PM)Mudbill Wrote: Well, I set up a scene just to try the script myself, and the game crashed not knowing what the function was. It just spewed out the message of "ReplaceEntity does not match (string, string, string, string, bool)." I do have the patch installed though.

Is this the same issue you had? If so, I'm interested in knowing how Rapture got it working. Perhaps there's something in addition to the patch that I'm missing.

I have the same issue with the beta functions.


RE: ReplaceEntity function (AMFP patch) - Rapture - 08-23-2014

(08-23-2014, 02:22 PM)Mudbill Wrote: Well, I set up a scene just to try the script myself, and the game crashed not knowing what the function was. It just spewed out the message of "ReplaceEntity does not match (string, string, string, string, bool)." I do have the patch installed though.

Is this the same issue you had? If so, I'm interested in knowing how Rapture got it working. Perhaps there's something in addition to the patch that I'm missing.
Have you ever been able to use any of the new AMFP functions with the 11/11/13 patch?

https://www.frictionalgames.com/forum/thread-23378.html



The only other thing I can think of is that you should be using the "AmnesiaTest131111.exe" that comes with the AMFP patch.


RE: ReplaceEntity function (AMFP patch) - Mudbill - 08-23-2014

Oh, right, that might've just been the problem all along xP

I got the game on Steam, so I tend to forget that launcher since the normal one doesn't work to start from the folder anyway.