PDA

View Full Version : Rotation script help



CaptCom
June 23rd, 2013, 13:53
Hi guys, I hope someone will be able to help.

I have a rotating brush on my map, the problem is that it rotates backward instead of forward.

I tried everything but without luck ( I'm using the "y" axis ).

This is the script:


main()
{
rotate_obj = getentarray("rotate","targetname");
if(isdefined(rotate_obj))
{
for(i=0;i<rotate_obj.size;i++)
{
rotate_obj[i] thread ra_rotate();
}
}
}

ra_rotate()
{
if (!isdefined(self.speed))
self.speed = 7;
if (!isdefined(self.script_noteworthy))
self.script_noteworthy = "y";

while(true)
{
// rotateYaw(float rot, float time, <float acceleration_time>, <float deceleration_time>);
if (self.script_noteworthy == "z")
self rotateYaw(360,self.speed);
else if (self.script_noteworthy == "x")
self rotateRoll(360,self.speed);
else if (self.script_noteworthy == "y")
self rotatePitch(360,self.speed);
wait ((self.speed)-0.1);
// removes the slight hesitation that waittill("rotatedone"); gives.
// self waittill("rotatedone");
}
}

Thanks in advance

SlickToxic
June 23rd, 2013, 16:33
self speed is -0.1 and not 0.1
Scratch that lol that removes the slight hesitation.

SlickToxic
June 23rd, 2013, 16:47
Here's a similar one I've used before.


main()
{
rotate_obj = getentarray("turn_radar","targetname");
if(isdefined(rotate_obj))
{
for(i=0;i<rotate_obj.size;i++)
{
rotate_obj[i] thread ra_rotate();
}
}
}

ra_rotate()
{
if (!isdefined(self.speed))
self.speed = 10;
if (!isdefined(self.script_noteworthy))
self.script_noteworthy = "x";

while(true)
{
// rotateYaw(float rot, float time, <float acceleration_time>, <float deceleration_time>);
if (self.script_noteworthy == "z")
self rotateyaw(360,self.speed);
else if (self.script_noteworthy == "x")
self rotateroll(360,self.speed);
else if (self.script_noteworthy == "y")
self rotatepitch(360,self.speed);
wait ((self.speed)-0.1); // removes the slight hesitation that waittill("rotatedone"); gives.
// self waittill("rotatedone");
}
}

{OSG}Brodie
June 23rd, 2013, 21:14
Hi guys, I hope someone will be able to help.

I have a rotating brush on my map, the problem is that it rotates backward instead of forward.

I tried everything but without luck ( I'm using the "y" axis ).

This is the script:


main()
{
rotate_obj = getentarray("rotate","targetname");
if(isdefined(rotate_obj))
{
for(i=0;i<rotate_obj.size;i++)
{
rotate_obj[i] thread ra_rotate();
}
}
}

ra_rotate()
{
if (!isdefined(self.speed))
self.speed = 7;
if (!isdefined(self.script_noteworthy))
self.script_noteworthy = "y";

while(true)
{
// rotateYaw(float rot, float time, <float acceleration_time>, <float deceleration_time>);
if (self.script_noteworthy == "z")
self rotateYaw(360,self.speed);
else if (self.script_noteworthy == "x")
self rotateRoll(360,self.speed);
else if (self.script_noteworthy == "y")
self rotatePitch(360,self.speed);
wait ((self.speed)-0.1);
// removes the slight hesitation that waittill("rotatedone"); gives.
// self waittill("rotatedone");
}
}

Thanks in advance

heres what i use bud

main()
{
rotate_obj = getentarray("rotate","targetname");
if(isdefined(rotate_obj))
for(i=0;i<rotate_obj.size;i++)
rotate_obj[i] thread ra_rotate();
}

ra_rotate()
{
if (!isdefined(self.speed))
self.speed = 10;
if (!isdefined(self.script_noteworthy))
self.script_noteworthy = "z";

for(;;)
{
// rotateYaw(float rot, float time, <float acceleration_time>, <float deceleration_time>);
if (self.script_noteworthy == "z")
self rotateYaw(360,self.speed);
else if (self.script_noteworthy == "x")
self rotateRoll(360,self.speed);
else if (self.script_noteworthy == "y")
self rotatePitch(360,self.speed);
wait (self.speed-0.1); // removes the slight hesitation that waittill("rotatedone"); gives.
// self waittill("rotatedone");
}
}


never had anything rotate the wrong way but maybe you could try changing the 360 for the y to a 0 or -360

pretty much the same as yours and Slicks but with a different target name

rgscriven
June 25th, 2013, 08:46
which cod is this script for

SlickToxic
June 25th, 2013, 08:52
It should work for all of them. Ive used it in cod, cod2, and 4.

rgscriven
June 25th, 2013, 09:17
ive also used that script also and works great

CaptCom
June 25th, 2013, 09:23
Thanks guys!

Now my main problem is with sounds.
I've followed one of our tutorial but it looks like its not accurate.

I can't hear any sounds ( stock sounds ) if someone have a good tutorial or can find what is the problem with ours please it would be nice ;)

rgscriven
June 25th, 2013, 10:11
in what way are you saying about sound is that like guns shooting or a nade exploding and so on if so make sure your fx sound in cod game settings is turned up ,it maybe turned down

{OSG}Brodie
June 25th, 2013, 10:23
Thanks guys!

Now my main problem is with sounds.
I've followed one of our tutorial but it looks like its not accurate.

I can't hear any sounds ( stock sounds ) if someone have a good tutorial or can find what is the problem with ours please it would be nice ;)
wave or mp not sure if 5 is the same as 4 with the sounds as it is with the rotate but we can give it a go ;)

CaptCom
June 25th, 2013, 13:16
My problem with the rotating script: if you have a ceiling fan, the way it rotates doesn't really matter. But if the fan is vertical, presently it goes backward, I need it to go forward.

{OSG}Brodie
June 25th, 2013, 18:02
have you tried using -360 in th script instead bud?

{OSG}Brodie
June 25th, 2013, 18:10
ok try this you may need to add a tag to your model bud
main()


{
thread spin();
}


spin()
{
yourmodel = getentarray("your model", "targetname");
for(i = 0; i < yourmodel.size; i++)
yourmodel[i] thread rotate(0.4);
}
rotate(speed)
{
if (!isdefined(self.script_noteworthy))
self.script_noteworthy = "x";
while(1)
{
if (self.script_noteworthy == "x")
self rotatepitch(360,speed);
wait(speed - 0.1);
}
}


or you could try setting the speed as a minus to see if that rotates it the right way like it sometimes does in cod4

arbopa
June 25th, 2013, 20:24
I had this issue when I added some garage doors that opened in mp_arbo_a ... depending the direction they were set on the map, it needed something different set for the rotation to work properly.

My file for garage doors:



main()
{
gtriggers = getentarray("garagetrig","targetname");
for(i=0;i<gtriggers.size;i++)
gtriggers[i] thread garage_think();
}


garage_think()
{
self.moving = false;
self.closed = true;
self.gdoor = getent(self.target, "targetname");


while (1)
{
self waittill("trigger");
if(!self.moving)
self thread garage_move();
}
}


garage_move()
{
self.moving = true;


if (self.gdoor.script_noteworthy == "pos"){
odir = 85;
cdir = -85;
} else {
odir = -85;
cdir = 85;
}


if(self.closed)
{
self.gdoor playsound("garage_door");
self.gdoor rotateroll(odir,7,0.5,0.5);
self.gdoor waittill("rotatedone");
self.closed = false;
}
else
{
self.gdoor playsound("garage_door");
self.gdoor rotateroll(cdir,7,0.5,0.5);
self.gdoor waittill("rotatedone");
self.closed = true;
}
self.moving = false;
}


I set 'notworthy' to 'pos' or 'neg' in the element, this depends on which direction the door is facing, as doors facing opposite directions need direction changed in order to function properly. Of course, if I had put any at a 90 degree angle to the way I had them, I'd need to also have a setting as then it would be a pitch rather than roll move in order for them to 'work' properly.

edit: so after reviewing the thread again, you will need to do a check for fans that rotate the wrong way via a script variable and set it to -360 instead of 360, that should fix it.

arbopa
June 25th, 2013, 20:26
Thanks guys!

Now my main problem is with sounds.
I've followed one of our tutorial but it looks like its not accurate.

I can't hear any sounds ( stock sounds ) if someone have a good tutorial or can find what is the problem with ours please it would be nice ;)

Do you have your 'miles' folder renamed? That will shut down any mp3 sounds.

SlickToxic
June 25th, 2013, 20:59
With the script i provided did you use these keys and values on the script brushmodel and origin brush?
With that script you can add multiple rotating objects on any axis.


key: Targetname
Value: rotate

key: Script_noteworthy
value: x,y or z for the desired axis

key: Speed
value: 5

SlickToxic
June 26th, 2013, 21:06
Here Capt: A prefab of six fans running on the different axis.
I had to build it in cod4, rad don't have waw installed yet.
These fans run with the script i posted.

687

Gerry
June 28th, 2013, 04:10
My problem with the rotating script: if you have a ceiling fan, the way it rotates doesn't really matter. But if the fan is vertical, presently it goes backward, I need it to go forward.

Try this,
The fan is an entity, you can call sounds from it.
If the sound is a loopsound leave what I have, if not try using playsound.
Change "YOUR_ALIAS" with the soundalias you have
Also change "THE_SPEED_YOU_DESIRE" with your value.


main()
{
rotate_obj = getentarray("rotate","targetname");
if(isdefined(rotate_obj))
{
rotate_obj playloopsound("YOUR_ALIAS");
while(1)
{
self rotatePitch(-360,"THE_SPEED_YOU_DESIRE");
wait ("THE_SPEED_YOU_DESIRE"-0.1);
}
}
}

{OSG}Brodie
July 1st, 2013, 15:44
ISSUE SORTED capt.

you'll need to copy your rotate.gsc to your desktop and rename it to ie yourmapname_rotate1 then copy it back to your raw/maps/mp
change the target name script to rotatemin
and all the 360 angles to -360


or you can replace all the script with this

main()
{
rotate_obj = getentarray("rotatemin","targetname");
if(isdefined(rotate_obj))
for(i=0;i<rotate_obj.size;i++)
rotate_obj[i] thread ra_rotate();
}

ra_rotate()
{
if (!isdefined(self.speed))
self.speed = 10;
if (!isdefined(self.script_noteworthy))
self.script_noteworthy = "z";

for(;;)
{
// rotateYaw(float rot, float time, <float acceleration_time>, <float deceleration_time>);
if (self.script_noteworthy == "z")
self rotateYaw(-360,self.speed);
else if (self.script_noteworthy == "x")
self rotateRoll(-360,self.speed);
else if (self.script_noteworthy == "y")
self rotatePitch(-360,self.speed);
wait (self.speed-0.1); // removes the slight hesitation that waittill("rotatedone"); gives.
// self waittill("rotatedone");
}
}

add this to your main maps gsc

maps\mp\mp_osg_rld_n_rotate1::main();

add this to your zone file

rawfile,maps/mp/mp_osg_rld_n_rotate1.gsc

finally change the targetname of your model from rotate to rotatemin and recompile etc
it will now rotate in the opposite direction as i have done in the latest update for my red light district map. i will add a video later m8
enjoy and happy mapping

{OSG}Brodie
July 1st, 2013, 17:17
ISSUE SORTED capt.

you'll need to copy your rotate.gsc to your desktop and rename it to ie yourmapname_rotate1 then copy it back to your raw/maps/mp
change the target name script to rotatemin
and all the 360 angles to -360


or you can replace all the script with this

main()
{
rotate_obj = getentarray("rotatemin","targetname");
if(isdefined(rotate_obj))
for(i=0;i<rotate_obj.size;i++)
rotate_obj[i] thread ra_rotate();
}

ra_rotate()
{
if (!isdefined(self.speed))
self.speed = 10;
if (!isdefined(self.script_noteworthy))
self.script_noteworthy = "z";

for(;;)
{
// rotateYaw(float rot, float time, <float acceleration_time>, <float deceleration_time>);
if (self.script_noteworthy == "z")
self rotateYaw(-360,self.speed);
else if (self.script_noteworthy == "x")
self rotateRoll(-360,self.speed);
else if (self.script_noteworthy == "y")
self rotatePitch(-360,self.speed);
wait (self.speed-0.1); // removes the slight hesitation that waittill("rotatedone"); gives.
// self waittill("rotatedone");
}
}

add this to your main maps gsc

maps\mp\mp_osg_rld_n_rotate1::main();

add this to your zone file

rawfile,maps/mp/mp_osg_rld_n_rotate1.gsc

finally change the targetname of your model from rotate to rotatemin and recompile etc
it will now rotate in the opposite direction as i have done in the latest update for my red light district map. i will add a video later m8
enjoy and happy mapping

Video added. yews its in cod4 but should work just the same in w@w also as the rotation script is universal

http://youtu.be/CyooDEImOQY