Page 1 of 1

Re-structing deleted entities by script?

Posted: December 30th, 2012, 1:06 pm
by F |Madness| U
Hi there I was wondering if it is possible to re-spawn/re-struct entities on a map purely by a script function after deleting them. By this what I mean mean is something as follows:

Code: Select all

entity = getEnt( "name", "targetname" );
        entity delete();
        // something to re-struct entity //
        entity = getEnt( "name", "targetname" );
Because I noticed that if I try to getEnt after the entity has been deleted, (obviously) it returns undefined because it has already been deleted.

However, in gamemodes where there are a number of rounds on each map, after each round the entities are re-structed. I was wondering if there is any simple function(s) for this, or if it is hardcoded to happen each time a round restarts. Any help would be great, thanks!

Also, I have entities in my map that I didn't define to have any .angles, so when I print entity.angles it shows as the default (0,0,0). Then I thought it should be possible to use getEntArray( (0,0,0),"angles" ); however it returns as undefined (even with "(0,0,0)" rather than (0,0,0)), any help on that would also be appreciated :D

Re: Re-structing deleted entities by script?

Posted: December 30th, 2012, 2:26 pm
by megazor
The script command to restart the game is exitLevel(arg), where arg will be either true or false. if it's true, then all player data is saved for the next round. I think that if you use this command, all deleted entities will return to level. But then all players will become spectators and other bad stuff may happen, so you will obviously want to get everything back to the moment which was just before executing the exitlevel command. In that case more complicated coding is needed.

for you second question, I will say that even if the way you tried doesn't work, It still can be done:

Code: Select all

allents = getEntArray();
sexy_ents = [];
for(i = 0; i < allents.size; i++)
{
        if(isDefined(allents.angles) && allents.angles == (0, 0, 0))
                sexy_ents[sexy_ents.size] = allents[i];
}

Re: Re-structing deleted entities by script?

Posted: December 30th, 2012, 2:33 pm
by F |Madness| U
Thanks for the informative response, I'll have a go with the exitLevel() and see what I can do, and also thanks for the second problem, that should indeed work, I didn't realise that getEntArray() returned all entities :P

Re: Re-structing deleted entities by script?

Posted: December 30th, 2012, 2:39 pm
by Drofder2004
Are you sure the game is deleting the entities and not simply hiding the from view?

If I recall correctly, bombsites (at least in CoD1) simply had two entities per bombsite; normal and destroyed.
When the bomb exploded they would simply hide the normal and show the destroyed. When the round is reset, they reverse what is seen.

Re: Re-structing deleted entities by script?

Posted: December 30th, 2012, 3:41 pm
by F |Madness| U
I'm not sure what is used in the actual game (CoD4), but in my case I was wondering if it was possible to actually re-build an entity. For example in my map (and many others) after triggers have been activated they use trigger delete(), and I was just wondering if I could re-build those entities with my mod.

Re: Re-structing deleted entities by script?

Posted: December 30th, 2012, 4:52 pm
by Mooselflies
F |Madness| U wrote:I'm not sure what is used in the actual game (CoD4), but in my case I was wondering if it was possible to actually re-build an entity. For example in my map (and many others) after triggers have been activated they use trigger delete(), and I was just wondering if I could re-build those entities with my mod.


couldn't you replace delete() with hide() and to show it again use show()?

Re: Re-structing deleted entities by script?

Posted: December 30th, 2012, 5:52 pm
by F |Madness| U
Mooselflies wrote:
F |Madness| U wrote:I'm not sure what is used in the actual game (CoD4), but in my case I was wondering if it was possible to actually re-build an entity. For example in my map (and many others) after triggers have been activated they use trigger delete(), and I was just wondering if I could re-build those entities with my mod.


couldn't you replace delete() with hide() and to show it again use show()?
With my own map, yes. But to make it compatible with other maps (which delete entities in their map script) I would need a way of re-structing it.

Re: Re-structing deleted entities by script?

Posted: December 31st, 2012, 8:20 am
by megazor
Why do you have to delete entities? You can simply hide them by doing

Code: Select all

entity.origin = (0, 0, -10000);
Oh, ok. Let us know once you have faced any challenges.

Re: Re-structing deleted entities by script?

Posted: December 31st, 2012, 6:33 pm
by Drofder2004
megazor wrote:Why do you have to delete entities? You can simply hide them by doing

Code: Select all

entity.origin = (0, 0, -10000);
F |Madness| U wrote:With my own map, yes. But to make it compatible with other maps (which delete entities in their map script) I would need a way of re-structing it.

Re: Re-structing deleted entities by script?

Posted: January 1st, 2013, 8:22 am
by megazor
Drofder2004 wrote:
megazor wrote:Why do you have to delete entities? You can simply hide them by doing

Code: Select all

entity.origin = (0, 0, -10000);
F |Madness| U wrote:With my own map, yes. But to make it compatible with other maps (which delete entities in their map script) I would need a way of re-structing it.
megazor wrote:
Oh, ok. Let us know once you have faced any challenges.