Re-structing deleted entities by script?

Have a question about modding, modelling or skinning? Have a tutorial to post? Post here!

Moderator: Core Staff

Post Reply
F |Madness| U
CJ G0D!
CJ G0D!
Posts: 1575
Joined: June 3rd, 2009, 9:02 pm
Location: Cardiff University, UK

Re-structing deleted entities by script?

Post by F |Madness| U » December 30th, 2012, 1:06 pm

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
-

megazor
CJ Worshipper
CJ Worshipper
Posts: 414
Joined: July 22nd, 2009, 3:02 am
Location: Russia, Vladivostok

Re: Re-structing deleted entities by script?

Post by megazor » December 30th, 2012, 2:26 pm

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];
}

F |Madness| U
CJ G0D!
CJ G0D!
Posts: 1575
Joined: June 3rd, 2009, 9:02 pm
Location: Cardiff University, UK

Re: Re-structing deleted entities by script?

Post by F |Madness| U » December 30th, 2012, 2:33 pm

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
-

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13313
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Re: Re-structing deleted entities by script?

Post by Drofder2004 » December 30th, 2012, 2:39 pm

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.
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

F |Madness| U
CJ G0D!
CJ G0D!
Posts: 1575
Joined: June 3rd, 2009, 9:02 pm
Location: Cardiff University, UK

Re: Re-structing deleted entities by script?

Post by F |Madness| U » December 30th, 2012, 3:41 pm

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.
-

User avatar
Mooselflies
CJ Spammer!
CJ Spammer!
Posts: 641
Joined: April 20th, 2009, 8:29 pm
PSN ID: mooselflies
Location: Reading :<

Re: Re-structing deleted entities by script?

Post by Mooselflies » December 30th, 2012, 4:52 pm

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()?

F |Madness| U
CJ G0D!
CJ G0D!
Posts: 1575
Joined: June 3rd, 2009, 9:02 pm
Location: Cardiff University, UK

Re: Re-structing deleted entities by script?

Post by F |Madness| U » December 30th, 2012, 5:52 pm

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.
-

megazor
CJ Worshipper
CJ Worshipper
Posts: 414
Joined: July 22nd, 2009, 3:02 am
Location: Russia, Vladivostok

Re: Re-structing deleted entities by script?

Post by megazor » December 31st, 2012, 8:20 am

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.

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13313
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Re: Re-structing deleted entities by script?

Post by Drofder2004 » December 31st, 2012, 6:33 pm

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.
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

megazor
CJ Worshipper
CJ Worshipper
Posts: 414
Joined: July 22nd, 2009, 3:02 am
Location: Russia, Vladivostok

Re: Re-structing deleted entities by script?

Post by megazor » January 1st, 2013, 8:22 am

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.

Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests