UGX-Mods

Call of Duty 5: World at War => Help Desk => Scripting => Topic started by: ville88 on October 27, 2017, 11:37:52 am

Title: Rotating/Swinging Doors Help
Post by: ville88 on October 27, 2017, 11:37:52 am
Need to be able to add a custom sound to the script
I changed the name of the sound in the script but it does not work.
And need to change the speed of opening the door.
The script is very good but needs improvements

any ideas?

source:
https://ugx-mods.com/forum/index.php/topic,3849.msg41423.html#msg41423

Code Snippet
Plaintext
#include maps\_utility; 
#include common_scripts\utility;
#include maps\_zombiemode_utility;

/*
DuaLVII's Rotating Door Script v1
 - Standard Zombie Cost doors
 - Electric doors
 - Electric doors with zombie cost (players must get the electric on then pay to open it)
 - Runs on script_vector for easier use (x,y,z) = (rotate like normal, like a garage door, like a sliding door but it rolls to the side)
 - Like all other doors, Uses script_flag for zone setting
*/

config()
{
level.rotating_door_hint = "Press &&1 to open the door"; // Cost area will be added after by the script
level.rotating_door_electric_hint = "You need to turn the power on";
}

init()
{
config();
rotating_doors = GetEntArray("rotating_door", "targetname");
array_thread(rotating_doors,::rotating_door_init);
}

rotating_door_init()
{
iTarget = GetEntArray(self.target, "targetname");
for(i = 0; i < iTarget.size; i++)
{
iTarget[i] rotating_door_setup();
}
if( isDefined(self.script_flag) && !IsDefined( level.flag[self.script_flag] ))
{
flag_init( self.script_flag );
}
if(isDefined(self.script_noteworthy) && self.script_noteworthy == "electric_door")
{
self setHintString(level.rotating_door_electric_hint);
}
else
{
self setHintString( level.rotating_door_hint + " [Cost:" + self.zombie_cost + "]" );
}
self SetCursorHint( "HINT_NOICON" );
self thread rotating_door_think();
}

rotating_door_think()
{
iTarget = GetEntArray(self.target, "targetname");
while(1)
{
if(isDefined(self.script_noteworthy) && self.script_noteworthy == "electric_door" && !isDefined(self.zombie_cost))
{
flag_wait( "electricity_on" );
}
else
{
if(isDefined(self.script_noteworthy) && self.script_noteworthy == "electric_door")
{
flag_wait( "electricity_on" );
self setHintString( level.rotating_door_hint + " [Cost:" + self.zombie_cost + "]" );
}
self waittill( "trigger", player);
if(player in_revive_trigger())
{
continue;
}
if(is_player_valid(player))
{
if(player.score >= (self.zombie_cost - 1)) // -1 to remove the horrible glitch where a player needs 10 points more than the exact total needed
{
player maps\_zombiemode_score::minus_to_player_score( self.zombie_cost );
}
else
{
play_sound_at_pos( "no_purchase", self.origin);
continue;
}
}
}
for(i = 0; i < iTarget.size; i++)
{
if(isDefined(iTarget[i].script_sound))
{
play_sound_at_pos( iTarget[i].script_sound, self.origin );
}
else
{
play_sound_at_pos( "door_slide_open", self.origin );
}
if(!isDefined(iTarget[i].script_transition_time))
{
iTarget[i].script_transition_time = 1;
}
if(isDefined(iTarget[i].script_vector))
{
if(iTarget[i].script_vector[0] != 0) // DuaLVII :: script_vector = an array? huh
{
iTarget[i] RotateYaw( iTarget[i].script_vector[0], iTarget[i].script_transition_time, ( iTarget[i].script_transition_time * 0.5 ) );
}
if(iTarget[i].script_vector[1] != 0)
{
iTarget[i] RotatePitch( iTarget[i].script_vector[1], iTarget[i].script_transition_time, ( iTarget[i].script_transition_time * 0.5 ) );
}
if(iTarget[i].script_vector[2] != 0)
{
iTarget[i] RotateRoll( iTarget[i].script_vector[2], iTarget[i].script_transition_time, ( iTarget[i].script_transition_time * 0.5 ) );
}
}
iTarget[i] NotSolid();
array_thread(iTarget,::rotating_door_connect);
}
if( IsDefined( self.script_flag ) )
{
flag_set( self.script_flag );
}
triggers_related = GetEntArray(self.target, "target");
for(i = 0; i<triggers_related.size; i++)
{
triggers_related[i] disable_trigger();
}
break;
}
}

rotating_door_setup()
{
iTarget = GetEntArray(self.target, "targetname");
for(i = 0; i < iTarget.size; i++)
{
iTarget[i] linkto(self);
iTarget[i] disconnectpaths();
}
}

rotating_door_connect()
{
iTarget = GetEntArray(self.target, "targetname");
for(i = 0; i < iTarget.size; i++)
{
iTarget[i] NotSolid();
iTarget[i] connectpaths();
}
}
Title: Re: Rotating/Swinging Doors Help
Post by: buttkicker845 on October 27, 2017, 12:14:15 pm
The script already has code for adding both custom sounds as well as a custom rotate speed.

If you add these to KVPs on the door itself and not the trigger it will change these behaviors
Code Snippet
Plaintext
Key: script_sound Value: custom_sound
and
Code Snippet
Plaintext
Key: script_transition_time Value: 2 //will take 2 seconds to rotate
Title: Re: Rotating/Swinging Doors Help
Post by: ville88 on October 27, 2017, 12:31:10 pm
this does not work

Title: Re: Rotating/Swinging Doors Help
Post by: buttkicker845 on October 27, 2017, 01:47:01 pm
it does not work on which part? it doesnt modify the speed of the door or doesnt play the custom sound?

if its the sound i would say that the sound isn't being loaded into the .ff of your map/mod correctly
Title: Re: Rotating/Swinging Doors Help
Post by: ville88 on October 27, 2017, 08:43:19 pm
door opening slow (speed change not work) custom sound not paly but Instead of it, the standard sound plays