UGX-Mods Login

or login with an authentication provider below
Sign In with Google
Sign In with Twitter
Sign In with Discord
Sign In with Steam
Sign In with Facebook
Sign In with Twitch

Moon door script

broken avatar :(
Created 11 years ago
by HitmanVere
0 Members and 1 Guest are viewing this topic.
3,516 views
broken avatar :(
×
broken avatar :(
Location: fi
Date Registered: 25 June 2013
Last active: 2 years ago
Posts
3,997
Respect
Forum Rank
Eviscerator
Primary Group
UGX V.I.P.
My Groups
More
My Contact & Social Links
More
×
HitmanVere's Groups
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
UGX V.I.P.
UGX V.I.P.
Mapper Has released one or more maps to the UGX-Mods community.
BO3 Modtools Alpha
BO3 Modtools Alpha
This user has access to the Black Ops 3 Modtools Alpha
Having problem atm with adding one Moon door in map. I got it mostly working, but atm if you go near it, it opens and closes constantly and when there is no zombies alive, it stays closed. Everything else works
Here is the Radiant setup:


And here is the script:
Code Snippet
Plaintext
moon_door1()
{
door_clip = getEnt("moon_door_clip","targetname");
door = getEnt("moon_door","targetname");
door1 = getEnt("moon_door1","targetname");
door2 = getEnt("moon_door2","targetname");

door_trig = getEnt("door_trig", "targetname");
door_trig setCursorHint("HINT_NOICON");
door_trig setHintstring("Press & hold &&1 to Open Door [Cost: 1000]");

level.moving_done = false;

while(1)
{
door_trig waittill("trigger", player);
if( is_player_valid(player) && player.score >= 1000 )
{
player thread maps\_zombiemode_score::minus_to_player_score( 1000 );
play_sound_at_pos( "cha_ching", door.origin );
door_trig delete();
door_clip connectPaths();
door_clip delete();
door1 setModel("bo1_p_zom_moon_lab_airlock_door01_left");
door2 setModel("bo1_p_zom_moon_lab_airlock_door01_right");
door1 connectPaths();
door2 connectPaths();
thread opening_logic();
break;
}
else
{
play_sound_at_pos( "no_cha_ching", door_trig.origin );
}
}
}

opening_logic()
{
door = getEnt("moon_door","targetname");
door1 = getEnt("moon_door1","targetname");
door2 = getEnt("moon_door2","targetname");

while(1)
{
players = getPlayers();
for(i=0;i<players.size;i++)
{
zombs = getaispeciesarray("axis","all");
for(k=0;k<zombs.size;k++)
{
if( (distance( players[i].origin, door.origin) >= 200 || distance(zombs[k].origin, door.origin) >= 200) && level.moving_done == true)
{
door1 moveX(50, 1);
door2 moveX(-50, 1);
door2 waittill("movedone");
level.moving_done = false;
}
else if( (distance( players[i].origin, door.origin) <= 200 || distance(zombs[k].origin, door.origin) <= 200) && level.moving_done == false)
{
door1 moveX(-50, 1);
door2 moveX(50, 1);
door2 waittill("movedone");
level.moving_done = true;
}
}
}
wait 0.1;
}
}
This topic contains a post which is marked as the Best Answer. Click here to view it.
broken avatar :(
×
broken avatar :(
Location: gbMilton Keynes
Date Registered: 17 January 2014
Last active: 6 years ago
Posts
6,875
Respect
Forum Rank
Immortal
Primary Group
Scripter
My Groups
More
My Contact & Social Links
More
Signature
If you want scripts / features made for you, then contact me by PM or email / skype etc
it will cost you tho so if you have no intention of reciprocating don't even waste my time ;)
×
Harry Bo21's Groups
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
Scripter Has shown effort and knowledge in the area of scripting while being a part of the UGX-Mods community.
Harry Bo21's Contact & Social LinksHarryBo000[email protected]HarryBo21
why are you checking a loop of all ai "inside" a loop for the players?

Thats potentially 4 sets of checks on the AI?

Code Snippet
Plaintext
players = getPlayers();
for(i=0;i<players.size;i++)
{
zombs = getaispeciesarray("axis","all");
for(k=0;k<zombs.size;k++)
{
broken avatar :(
×
broken avatar :(
Location: fi
Date Registered: 25 June 2013
Last active: 2 years ago
Posts
3,997
Respect
Forum Rank
Eviscerator
Primary Group
UGX V.I.P.
My Groups
More
My Contact & Social Links
More
×
HitmanVere's Groups
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
UGX V.I.P.
UGX V.I.P.
Mapper Has released one or more maps to the UGX-Mods community.
BO3 Modtools Alpha
BO3 Modtools Alpha
This user has access to the Black Ops 3 Modtools Alpha
why are you checking a loop of all ai "inside" a loop for the players?

Thats potentially 4 sets of checks on the AI?

Code Snippet
Plaintext
players = getPlayers();
for(i=0;i<players.size;i++)
{
zombs = getaispeciesarray("axis","all");
for(k=0;k<zombs.size;k++)
{

Didnt know, if there is better way to check for anything moving, so I did one check for all players and one check for zombies, lol
broken avatar :(
×
broken avatar :(
Location: nlApeldoorn
Date Registered: 17 December 2013
Last active: 2 years ago
Posts
1,186
Respect
1,332Add +1
Forum Rank
Zombie Colossus
Primary Group
Scripter Elite
My Groups
More
My Contact & Social Links
More
Personal Quote
It aint much, if it aint Dutch
Signature
×
BluntStuffy's Groups
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
Scripter Elite Has shown excellence and experience in the area of custom scripting in the UGX-Mods community.
Oil Rig Beta Access
Oil Rig Beta Access
BluntStuffy's Contact & Social LinksBluntStuffyBluntstuffy@BluntZombieStuffyZombie
^

just do:

Code Snippet
Plaintext
		players = getPlayers();
for(i=0;i<players.size;i++)
{
if( distance( players[i].origin, door.origin) >= 200 && level.moving_done == true)
{
door1 moveX(50, 1);
door2 moveX(-50, 1);
door2 waittill("movedone");
level.moving_done = false;
}
else if( distance( players[i].origin, door.origin) <= 200 && level.moving_done == false)
{
door1 moveX(-50, 1);
door2 moveX(50, 1);
door2 waittill("movedone");
level.moving_done = true;
}
}

zombs = getaispeciesarray("axis","all");
for(k=0;k<zombs.size;k++)
{
if( distance(zombs[k].origin, door.origin) >= 200) && level.moving_done == true)
{
door1 moveX(50, 1);
door2 moveX(-50, 1);
door2 waittill("movedone");
level.moving_done = false;
}
else if( distance(zombs[k].origin, door.origin) <= 200) && level.moving_done == false)
{
door1 moveX(-50, 1);
door2 moveX(50, 1);
door2 waittill("movedone");
level.moving_done = true;
}
}

or if you want to keep it this way, try:
Code Snippet
Plaintext
		players = getPlayers();
for(i=0;i<players.size;i++)
{
zombs = getaispeciesarray("axis","all");
for(k=0;k<zombs.size;k++)
{
if( ( distance( players[i].origin, door.origin) >= 200 && level.moving_done == true || distance(zombs[k].origin, door.origin) >= 200 && level.moving_done == true)
{
door1 moveX(50, 1);
door2 moveX(-50, 1);
door2 waittill("movedone");
level.moving_done = false;
}
else if( distance( players[i].origin, door.origin) <= 200 && level.moving_done == true || distance(zombs[k].origin, door.origin) <= 200 && level.moving_done == false)
{
door1 moveX(-50, 1);
door2 moveX(50, 1);
door2 waittill("movedone");
level.moving_done = true;
}
}
}

Or just use this :)

http://ugx-mods.com/forum/index.php/topic,6553.new.html#new
Last Edit: December 03, 2015, 10:43:09 pm by BluntStuffy
broken avatar :(
×
broken avatar :(
Location: fi
Date Registered: 25 June 2013
Last active: 2 years ago
Posts
3,997
Respect
Forum Rank
Eviscerator
Primary Group
UGX V.I.P.
My Groups
More
My Contact & Social Links
More
×
HitmanVere's Groups
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
UGX V.I.P.
UGX V.I.P.
Mapper Has released one or more maps to the UGX-Mods community.
BO3 Modtools Alpha
BO3 Modtools Alpha
This user has access to the Black Ops 3 Modtools Alpha
^

just do:

Code Snippet
Plaintext
		players = getPlayers();
for(i=0;i<players.size;i++)
{
if( distance( players[i].origin, door.origin) >= 200 && level.moving_done == true)
{
door1 moveX(50, 1);
door2 moveX(-50, 1);
door2 waittill("movedone");
level.moving_done = false;
}
else if( distance( players[i].origin, door.origin) <= 200 && level.moving_done == false)
{
door1 moveX(-50, 1);
door2 moveX(50, 1);
door2 waittill("movedone");
level.moving_done = true;
}
}

zombs = getaispeciesarray("axis","all");
for(k=0;k<zombs.size;k++)
{
if( distance(zombs[k].origin, door.origin) >= 200) && level.moving_done == true)
{
door1 moveX(50, 1);
door2 moveX(-50, 1);
door2 waittill("movedone");
level.moving_done = false;
}
else if( distance(zombs[k].origin, door.origin) <= 200) && level.moving_done == false)
{
door1 moveX(-50, 1);
door2 moveX(50, 1);
door2 waittill("movedone");
level.moving_done = true;
}
}

or if you want to keep it this way, try:
Code Snippet
Plaintext
		players = getPlayers();
for(i=0;i<players.size;i++)
{
zombs = getaispeciesarray("axis","all");
for(k=0;k<zombs.size;k++)
{
if( ( distance( players[i].origin, door.origin) >= 200 && level.moving_done == true || distance(zombs[k].origin, door.origin) >= 200 && level.moving_done == true)
{
door1 moveX(50, 1);
door2 moveX(-50, 1);
door2 waittill("movedone");
level.moving_done = false;
}
else if( distance( players[i].origin, door.origin) <= 200 && level.moving_done == true || distance(zombs[k].origin, door.origin) <= 200 && level.moving_done == false)
{
door1 moveX(-50, 1);
door2 moveX(50, 1);
door2 waittill("movedone");
level.moving_done = true;
}
}
}

Or just use this :)

http://ugx-mods.com/forum/index.php/topic,6553.new.html#new

I will test that first option. Didnt want to use your tutorial, cos 1. Seemed complicated to modify to my needs and Im just going to have one door 2. Wanted to try script it myself and 3. This map for some reason has a lot of false errors regarding "missing" scripts, so I didnt want to add more scripts in the mod :P
broken avatar :(
×
broken avatar :(
☭ Soviet Commander ☭
Location: us
Date Registered: 13 August 2012
Last active: 10 years ago
Posts
2,789
Respect
Forum Rank
King of the Zombies
Primary Group
Community Daedra
My Groups
More
My Contact & Social Links
More
Signature
Let's keep this thread on topic from here on in. -DBZ

+1 to off-topic reply -DBZ

lmao. Too funny.

Goliath Script Placer: http://ugx-mods.com/forum/index.php/topic,11234.msg125257/topicseen.html#new

"...Christ, people. Learn C, instead of just stringing random characters
together until it compiles (with warnings)..."

-Linus Torvalds
×
daedra descent's Groups
Community Daedra
Community Daedra
daedra descent's Contact & Social LinksBlueSoviet
^

just do:

Code Snippet
Plaintext
		players = getPlayers();
for(i=0;i<players.size;i++)
{
if( distance( players[i].origin, door.origin) >= 200 && level.moving_done == true)
{
door1 moveX(50, 1);
door2 moveX(-50, 1);
door2 waittill("movedone");
level.moving_done = false;
}
else if( distance( players[i].origin, door.origin) <= 200 && level.moving_done == false)
{
door1 moveX(-50, 1);
door2 moveX(50, 1);
door2 waittill("movedone");
level.moving_done = true;
}
}

zombs = getaispeciesarray("axis","all");
for(k=0;k<zombs.size;k++)
{
if( distance(zombs[k].origin, door.origin) >= 200) && level.moving_done == true)
{
door1 moveX(50, 1);
door2 moveX(-50, 1);
door2 waittill("movedone");
level.moving_done = false;
}
else if( distance(zombs[k].origin, door.origin) <= 200) && level.moving_done == false)
{
door1 moveX(-50, 1);
door2 moveX(50, 1);
door2 waittill("movedone");
level.moving_done = true;
}
}

or if you want to keep it this way, try:
Code Snippet
Plaintext
		players = getPlayers();
for(i=0;i<players.size;i++)
{
zombs = getaispeciesarray("axis","all");
for(k=0;k<zombs.size;k++)
{
if( ( distance( players[i].origin, door.origin) >= 200 && level.moving_done == true || distance(zombs[k].origin, door.origin) >= 200 && level.moving_done == true)
{
door1 moveX(50, 1);
door2 moveX(-50, 1);
door2 waittill("movedone");
level.moving_done = false;
}
else if( distance( players[i].origin, door.origin) <= 200 && level.moving_done == true || distance(zombs[k].origin, door.origin) <= 200 && level.moving_done == false)
{
door1 moveX(-50, 1);
door2 moveX(50, 1);
door2 waittill("movedone");
level.moving_done = true;
}
}
}

using array_thread for both zombies and players would probably be a better idea. Less code usage. Whicher way i guess.

Equal signs in both your if statement operators isn't a great idea. If both player and AI are 200 units apart then they are probably going to open and close randomly.

Also, use developer and developer_script. Might have something to help you debug further.
Marked as best answer by HitmanVere 11 years ago
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 14 September 2013
Last active: 6 years ago
Posts
1,895
Respect
Forum Rank
Zombie Destroyer
Primary Group
Scripter
My Groups
More
My Contact & Social Links
More
Personal Quote
BE ORIGINAL
Signature
×
MakeCents's Groups
Mapper Has released one or more maps to the UGX-Mods community.
Scripter Has shown effort and knowledge in the area of scripting while being a part of the UGX-Mods community.
BO3 Modtools Alpha
BO3 Modtools Alpha
This user has access to the Black Ops 3 Modtools Alpha
Your script is a bit exponential, with the checking each zombie for each player bit and won't do anything if all the zombies are dead atm. Also you use level.moving_done which will only allow you to have one door, which may be your intent seeing the way you set up your functions. You may try to modify your script like this or consider rethinking the process if you are going to have more than one.

Code Snippet
Plaintext
moon_door1()
{
door_clip = getEnt("moon_door_clip","targetname");
door = getEnt("moon_door","targetname");
door1 = getEnt("moon_door1","targetname");
door2 = getEnt("moon_door2","targetname");

door_trig = getEnt("door_trig", "targetname");
door_trig setCursorHint("HINT_NOICON");
door_trig setHintstring("Press & hold &&1 to Open Door [Cost: 1000]");

level.moving_done = false;

while(1)
{
door_trig waittill("trigger", player);
if( is_player_valid(player) && player.score >= 1000 )
{
player thread maps\_zombiemode_score::minus_to_player_score( 1000 );
play_sound_at_pos( "cha_ching", door.origin );
door_trig delete();
door_clip connectPaths();
door_clip delete();
door1 setModel("bo1_p_zom_moon_lab_airlock_door01_left");
door2 setModel("bo1_p_zom_moon_lab_airlock_door01_right");
door1 connectPaths();
door2 connectPaths();
thread opening_logic();
break;
}
else
{
play_sound_at_pos( "no_cha_ching", door_trig.origin );
}
}
}

opening_logic()
{
door = getEnt("moon_door","targetname");
door1 = getEnt("moon_door1","targetname");
door2 = getEnt("moon_door2","targetname");
while(1)
{
if(door AnyOneNear()){
door1 moveX(50, 1);
door2 moveX(-50, 1);
door2 waittill("movedone");

while(door AnyOneNear()){
wait(.1);
}

door1 moveX(-50, 1);
door2 moveX(50, 1);
door2 waittill("movedone");
}

wait 0.1;
}
}
AnyOneNear(){
players = getPlayers();
zombs = getaispeciesarray("axis","all");
ents = array_combine( zombs,players );
for(i=0;i<ents.size;i++){
if(distance( ents[i].origin, self.origin)<200) return true;
}
return false;
}


FYI only:
My auto doors I make a prefab and setup with structs as targets for each door, and a trigger multiple. (Everything is setup as the target of something else) Then when touching the trigger if it hasn't been bought or unlocked, it shows a hint and doesn't open until you buy it. Then in a while loop I check zombies and players for touching it, and if they are it just keeps continuing. Then when they are not, the while loop ends and closes the doors. I use another struct outside the prefab to set my flags, which I get using an array and then checking for the closest struct in that array to the doors, get it's kvps and set the flag.
Last Edit: December 03, 2015, 11:03:47 pm by MakeCents
broken avatar :(
×
broken avatar :(
Location: fi
Date Registered: 25 June 2013
Last active: 2 years ago
Posts
3,997
Respect
Forum Rank
Eviscerator
Primary Group
UGX V.I.P.
My Groups
More
My Contact & Social Links
More
×
HitmanVere's Groups
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
UGX V.I.P.
UGX V.I.P.
Mapper Has released one or more maps to the UGX-Mods community.
BO3 Modtools Alpha
BO3 Modtools Alpha
This user has access to the Black Ops 3 Modtools Alpha
using array_thread for both zombies and players would probably be a better idea. Less code usage. Whicher way i guess.

Equal signs in both your if statement operators isn't a great idea. If both player and AI are 200 units apart then they are probably going to open and close randomly.

Also, use developer and developer_script. Might have something to help you debug further.

How would I put it to be then? Just < or do I need something else for it?
@Blunt Second issue is fixed with door not moving, but immediately when zombie spawns, it starts moving back and forth like in first issue
broken avatar :(
×
broken avatar :(
Location: gbMilton Keynes
Date Registered: 17 January 2014
Last active: 6 years ago
Posts
6,875
Respect
Forum Rank
Immortal
Primary Group
Scripter
My Groups
More
My Contact & Social Links
More
×
Harry Bo21's Groups
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
Scripter Has shown effort and knowledge in the area of scripting while being a part of the UGX-Mods community.
Harry Bo21's Contact & Social LinksHarryBo000[email protected]HarryBo21
Code Snippet
Plaintext
// One struct for doors, with targetname - moon_door
// two other models for your actual doors, both targeting that struct.
// targetname - moon_left_door
// targetname - moon_right_door
// onr clip per door, also targeting the door
// thread script in zombiemode, along with the others


init()
{
moon_doors_main();
}

moon_doors_main()
{
doors = getEntArray( "moon_door", "targetname" ); // Get array of all door locations
doors_left = getEntArray( "moon_door_left", "targetname" ); // Get array of all "left" doors
doors_right = getEntArray( "moon_door_left", "targetname" ); // Get array of all "right" doors
door_clips = getEntArray( "moon_door_clips", "targetname" ); // Get array of the clips used for the doors

level.doors = [];
for ( i = 0; i < doors.size; i++ ) // loop through each door location
{
level.doors[ i ] = doors[ i ]; // Add location to main array
level.doors[ i ].open = false; // Set door to start "closed"
for ( d = 0; d < doors_left.size; d++ ) // Loop through the left doors
{
if ( doors_left[ d ].target == doors[ i ] ) // If this left door, is targeting this door "location"
level.doors[ i ].left_door = doors_left[ d ]; // Store as a property against this location. Door belongs to it

}
for ( d = 0; d < doors_right.size; d++ )
{
if ( doors_right[ d ].target == doors[ i ] ) // If this right door, is targeting this door "location"
level.doors[ i ].right_door = doors_right[ d ]; // Store as a property against this location. Door belongs to it

}
for ( d = 0; d < doors_clips.size; d++ )
{
if ( doors_clips[ d ].target == doors[ i ] ) // If this clip, is targeting this door "location"
level.doors[ i ].door_clip = doors_clips[ d ]; // Store as a property against this location. clip belongs to it

}
level.doors[ i ] thread moon_door_watcher(); // Thread the wathcer thats checking for things coming close to the door
}
}

moon_door_watcher()
{
while( 1 )
{
triggered = false; // set triggered to false
zombs = getaispeciesarray("axis","all"); // Get array of AI
if ( isDefined( zombs ) && zombs.size > 0 ) // Check array is real
{
for ( i = 0; i < zombs.size; i++ ) // Loop through AI array
{
if( distance( zombs[ i ].origin, self.origin ) >= 200 ) && !self.open ) // Check if zombie is in range and door is closed atm
{
triggered = true; // If it is, mark this loop as triggered
self moon_door_open(); // Open the door
break; // break from this AI checking loop, weve already found a target
}
}
}
if ( !triggered ) // Now, only cgeck the players, if the door hasnt already been triggered in this loop when checking the AI
{
players = get_players(); // Get player array
if ( isDefined( players ) && players.size > 0 ) // Check array is real
{
for ( i = 0; i < players.size; i++ ) // Loop through player array
{
if( distance( players[i].origin, self.origin ) >= 200 ) && !self.open ) // Check if player is in range and door is closed atm
{
triggered = true; // If it is, mark this loop as triggered
self moon_door_open(); // Open the door
break; // break from this player checking loop, weve already found a target
}
}
}
}
if ( !triggered && self.open ) // If we didnt find a target - and the door IS already open, close it coz nothing is in range
self moon_door_close(); // Close door

wait .1;
}
}


moon_door_open()
{
self.door_clip hide();
self.left_door moveX( 50, 1 );
self.right_door moveX( -50, 1 );
self.door_clip connectPaths();
self.left_door connectPaths();
self.right_door connectPaths();
wait 1;
self.open = true;
}

moon_door_close()
{
self.door_clip show();
self.left_door moveX( -50, 1 );
self.right_door moveX( 50, 1 );
wait 1;
self.open = false;
}

id try to start of scripts by making sure they can handle more than one instance, as changing it later to allow "multiples" can be tricky. Start with arrays

Havent tested this, stuffys are prob beter for it, but was bored so wrote up a prototype

* Edit - not sure if show/hiding a clip works, might do tho, as does with anything else - just never tested collision
Last Edit: December 03, 2015, 11:12:26 pm by Harry Bo21
broken avatar :(
×
broken avatar :(
☭ Soviet Commander ☭
Location: us
Date Registered: 13 August 2012
Last active: 10 years ago
Posts
2,789
Respect
Forum Rank
King of the Zombies
Primary Group
Community Daedra
My Groups
More
My Contact & Social Links
More
×
daedra descent's Groups
Community Daedra
Community Daedra
daedra descent's Contact & Social LinksBlueSoviet
How would I put it to be then? Just < or do I need something else for it?

If the distance is greater than 200 you shouldn't have the equal sign. If its less, you should. That way if an ai/player is 199 OR 200 units from the door then it will open. Otherwise if they are farther away than 200 units it should remain closed.
broken avatar :(
×
broken avatar :(
Location: gbMilton Keynes
Date Registered: 17 January 2014
Last active: 6 years ago
Posts
6,875
Respect
Forum Rank
Immortal
Primary Group
Scripter
My Groups
More
My Contact & Social Links
More
×
Harry Bo21's Groups
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
Scripter Has shown effort and knowledge in the area of scripting while being a part of the UGX-Mods community.
Harry Bo21's Contact & Social LinksHarryBo000[email protected]HarryBo21
Code Snippet
Plaintext
x <= num || x > num

Code Snippet
Plaintext
x < num || x >= num

basically you were checking the same argument both ways, go one or the other

Code Snippet
Plaintext
x < num || x > num || x == num

This is a 3 way check, but youll almost certainly never need it lol
broken avatar :(
×
broken avatar :(
Location: fi
Date Registered: 25 June 2013
Last active: 2 years ago
Posts
3,997
Respect
Forum Rank
Eviscerator
Primary Group
UGX V.I.P.
My Groups
More
My Contact & Social Links
More
×
HitmanVere's Groups
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
UGX V.I.P.
UGX V.I.P.
Mapper Has released one or more maps to the UGX-Mods community.
BO3 Modtools Alpha
BO3 Modtools Alpha
This user has access to the Black Ops 3 Modtools Alpha
Your script is a bit exponential, with the checking each zombie for each player bit and won't do anything if all the zombies are dead atm. Also you use level.moving_done which will only allow you to have one door, which may be your intent seeing the way you set up your functions. You may try to modify your script like this or consider rethinking the process if you are going to have more than one.

Code Snippet
Plaintext
moon_door1()
{
door_clip = getEnt("moon_door_clip","targetname");
door = getEnt("moon_door","targetname");
door1 = getEnt("moon_door1","targetname");
door2 = getEnt("moon_door2","targetname");

door_trig = getEnt("door_trig", "targetname");
door_trig setCursorHint("HINT_NOICON");
door_trig setHintstring("Press & hold &&1 to Open Door [Cost: 1000]");

level.moving_done = false;

while(1)
{
door_trig waittill("trigger", player);
if( is_player_valid(player) && player.score >= 1000 )
{
player thread maps\_zombiemode_score::minus_to_player_score( 1000 );
play_sound_at_pos( "cha_ching", door.origin );
door_trig delete();
door_clip connectPaths();
door_clip delete();
door1 setModel("bo1_p_zom_moon_lab_airlock_door01_left");
door2 setModel("bo1_p_zom_moon_lab_airlock_door01_right");
door1 connectPaths();
door2 connectPaths();
thread opening_logic();
break;
}
else
{
play_sound_at_pos( "no_cha_ching", door_trig.origin );
}
}
}

opening_logic()
{
door = getEnt("moon_door","targetname");
door1 = getEnt("moon_door1","targetname");
door2 = getEnt("moon_door2","targetname");
while(1)
{
if(door AnyOneNear()){
door1 moveX(50, 1);
door2 moveX(-50, 1);
door2 waittill("movedone");

while(door AnyOneNear()){
wait(.1);
}

door1 moveX(-50, 1);
door2 moveX(50, 1);
door2 waittill("movedone");
}

wait 0.1;
}
}
AnyOneNear(){
players = getPlayers();
zombs = getaispeciesarray("axis","all");
ents = array_combine( zombs,players );
for(i=0;i<ents.size;i++){
if(distance( ents[i].origin, self.origin)<200) return true;
}
return false;
}


FYI only:
My auto doors I make a prefab and setup with structs as targets for each door, and a trigger multiple. (Everything is setup as the target of something else) Then when touching the trigger if it hasn't been bought or unlocked, it shows a hint and doesn't open until you buy it. Then in a while loop I check zombies and players for touching it, and if they are it just keeps continuing. Then when they are not, the while loop ends and closes the doors. I use another struct outside the prefab to set my flags, which I get using an array and then checking for the closest struct in that array to the doors, get it's kvps and set the flag.

Okay, I see your method working, except doors are going in wrong ways now, which is easy fix :P Was thinking about the new function part, but didnt know how to execute it. Marked as best one. Thanks for helping, guys, learning something new now, lol

 
Loading ...