WindMill/fan script

Post your scripting questions / solutions here

Moderator: Moderators

echo_rancid
Captain
Posts: 264
Joined: Sat Jan 31, 2004 4:31 pm

WindMill/fan script

Post by echo_rancid »

Alright I built a windmill and there is a picture of it below. Now I made the round rod a script object and gave it the targetname of fan1. Then I selected each brush of each of the blades and made those sript objects with targetnames of blade1, blade2, blade3, and blade4. Here is a picture of it:

Image

Now I used the tutorial on this site to scrip here is what is in my script:

level waittill spawn

thread fan1
end

Then down further is this:

fan1:

$blade1 bind $fan1
$blade2 bind $fan1
$blade3 bind $fan1
$blade4 bind $fan1
$fan1 rotatez 325 // the number indicates the speed of the fans rotation.

end


I changed rotatey to both rotatex and rotatez but nothing at all happens. What did I do incorrectly???
Image
Bjarne BZR
Site Admin
Posts: 3298
Joined: Wed Feb 05, 2003 2:04 pm
Location: Sweden
Contact:

Post by Bjarne BZR »

You will have an error in the consore that relates to this. There is probably a script error.
Admin .MAP Forums
Image
Head above heels.
User avatar
wacko
Field Marshal
Posts: 2085
Joined: Fri Jul 05, 2002 8:42 pm
Location: Germany

Post by wacko »

Although I don't know why u do no make the whole "wheel" including blades just one big script_object, the script looks fine to me. The script must have the same name as ur bsp and be in the same folder, like mohaa/main/maps/dm/mymap.bsp and mohaa/main/maps/dm/mymap.scr but u surely did so?!
User avatar
tltrude
Chuck Norris
Posts: 4774
Joined: Sun Jul 07, 2002 4:03 am
Location: Oklahoma, USA
Contact:

try this

Post by tltrude »

fan1:

$blade1 bind $fan1
$blade2 bind $fan1
$blade3 bind $fan1
$blade4 bind $fan1
$fan1 rotatez 325 // the number indicates the speed of the fans rotation.
$fan1 move

end


But, if your windmill rotates all the time, you can just put this in the entity window (make the hub, the blades, and the origin brush all one script object ).
Key: rotateZ
Value: 325

That way you don't need anything in the script--except for (possibly) binding sound speakers (script_origins) to the end of the blades.
Tom Trude,

Image
echo_rancid
Captain
Posts: 264
Joined: Sat Jan 31, 2004 4:31 pm

Post by echo_rancid »

There is my entire script before I read the post. Does anyone see anything wrong with it? One thing...all four of the random explosions were working before I put in the fan script...now niether work.

// STORM ON REVIN
// ARCHITECTURE: WD_Echo_Rancid
// SCRIPTING: WD_Echo_Rancid

main:

// set scoreboard messages
setcvar "g_obj_alliedtext1 "Storm on Revin"
setcvar "g_obj_alliedtext2 ""
setcvar "g_obj_alliedtext3 ""
setcvar "g_obj_axistext1 "WD_Echo_Rancid"
setcvar "g_obj_axistext2 ""
setcvar "g_obj_axistext3 ""

setcvar "g_scoreboardpic" "none"

local.master = spawn ScriptMaster // ubersound work around

local.master aliascache leadinmp1 sound/weapons/explo/Exp_LeadIn_06.wav soundparms 0.8 0.2 0.7 0.5 160 3000 auto loaded maps "m obj dm train"
local.master aliascache leadinmp2 sound/weapons/explo/Exp_LeadIn_07.wav soundparms 0.8 0.2 0.7 0.5 160 3000 auto loaded maps "m obj dm train"
local.master aliascache leadinmp3 sound/weapons/explo/Exp_LeadIn_08.wav soundparms 0.8 0.2 0.7 0.5 160 3000 auto loaded maps "m obj dm train"
local.master aliascache leadinmp4 sound/weapons/explo/Exp_LeadIn_09.wav soundparms 0.8 0.2 0.7 0.5 160 3000 auto loaded maps "m obj dm train"
local.master aliascache leadinmp5 sound/weapons/explo/Exp_LeadIn_10.wav soundparms 0.8 0.2 0.7 0.5 160 3000 auto loaded maps "m obj dm train"
local.master aliascache leadinmp6 sound/weapons/explo/Exp_LeadIn_11.wav soundparms 0.8 0.2 0.7 0.5 160 3000 auto loaded maps "m obj dm train"
local.master aliascache leadinmp7 sound/weapons/explo/Exp_LeadIn_12.wav soundparms 0.8 0.2 0.7 0.5 160 3000 auto loaded maps "m obj dm train"
local.master aliascache leadinmp8 sound/weapons/explo/Exp_LeadIn_13.wav soundparms 0.8 0.2 0.7 0.5 160 3000 auto loaded maps "m obj dm train"

level waittill prespawn

//*** Precache Dm Stuff
exec global/DMprecache.scr

level.script = maps/dm/storm_on_revin.scr
exec global/ambient.scr mohdm1
exec global/exploder.scr
exec global/bomber.scr

$tank_smoke anim stop
thread start_sound

level waittill spawn

thread fan
end

thread random_explode_start // Thread could also be started by a trigger setthread.
level.flyplane = 2

end

start_sound:

wait 1
$fire_speaker loopsound fire_med

end

// --------------------------------------------
// Bomber Explosions
// --------------------------------------------

kaboom_barn: // First bomb node above barn starts this thread.

exec global/exploder.scr::explode 3 // barn roof exploder

end

kaboom_sherman: // First bomb node above tank starts this thread.

exec global/exploder.scr::explode 6 // sherman tank exploder
$tank_smoke anim start

end

// --------------------------------------------
// Random Explosions
// --------------------------------------------

random_explode_start:

thread random_explode1
thread random_explode2
thread random_explode3
thread random_explode4

end

random_explode1:

wait (randomfloat 13 + 23) // min and max seconds between explosions.
$random_explode1_origin playsound leadinmp // Randomly picks from 8 sounds above.
wait 1
$random_explode1 anim start // uses animate fx_explosion_dirt
radiusdamage $random_explode1_origin 256 384
goto random_explode1

end

random_explode2:

wait (randomfloat 20 + 30) // min and max seconds between explosions.
$random_explode2_origin playsound leadinmp // Randomly picks from 8 sounds above.
wait 1
$random_explode2 anim start // uses animate fx_explosion_dirt
radiusdamage $random_explode2_origin 256 384
goto random_explode2

end

random_explode3:

wait (randomfloat 15 + 37) // min and max seconds between explosions.
$random_explode3_origin playsound leadinmp // Randomly picks from 8 sounds above.
wait 1
$random_explode3 anim start // uses animate fx_explosion_dirt
radiusdamage $random_explode3_origin 256 384
goto random_explode3

end

random_explode4:

wait (randomfloat 15 + 43) // min and max seconds between explosions.
$random_explode4_origin playsound leadinmp // Randomly picks from 8 sounds above.
wait 1
$random_explode4 anim start // uses animate fx_explosion_dirt
radiusdamage $random_explode4_origin 256 384
goto random_explode4

end

// --------------------------------------------
// WindMill
// --------------------------------------------

fan:

$blade1 bind $fan
$blade2 bind $fan
$blade3 bind $fan
$blade4 bind $fan
$fan1 rotatex 200 // the number indicates the speed of the fans rotation.

end


I originally had fan as fan1 but i notice that the targetname in radient was fan, so being lazy and not wanting to compile agian I just changed it to fan. Also I was messing around with the rotatex and z just to see what would happen.

I bet that thread fan has to go down with the other in the script...Ill try that and see...

tom, what does the $fan1 move do and is it required?...I didnt see that in the .map tutorial that was why i was wondering. Also There needs to be an orgin brush...or is that just the fan1?
Image
User avatar
tltrude
Chuck Norris
Posts: 4774
Joined: Sun Jul 07, 2002 4:03 am
Location: Oklahoma, USA
Contact:

end

Post by tltrude »

The "main" thread, at the top, will stop reading the lines when it reaches the word "end".

You have this:

========================


thread fan
end

thread random_explode_start
level.flyplane = 2

end


========================
Tom Trude,

Image
echo_rancid
Captain
Posts: 264
Joined: Sat Jan 31, 2004 4:31 pm

Post by echo_rancid »

Alright Thanks Tom, I bet that is the problem...well obviously it is the problem...that would explain the random explosions not working to...I was going to change that first thing but decided to change some other things first...Ill let you know if it works. Thanks again.
Image
User avatar
tltrude
Chuck Norris
Posts: 4774
Joined: Sun Jul 07, 2002 4:03 am
Location: Oklahoma, USA
Contact:

move

Post by tltrude »

I don't know if $fan move is needed or not but you forgot to rename the fan in the last line.

$blade4 bind $fan
$fan rotatex 200

Because the blades are seperate objects, you could have them play a "whooshing" sound so the players hear them go by. Also if your hub and blades are not centered perfectly it will wobble when it rotates. Adding an origin brush to the hub object will move the center point, if needed.
Tom Trude,

Image
echo_rancid
Captain
Posts: 264
Joined: Sat Jan 31, 2004 4:31 pm

Post by echo_rancid »

Alright I got the windmill working. The blades are moving smoothly. Now the only problem is rotatex and rotatez are not right, both turn incorrectly, they go throught the windmill and its not right. IS there a way to script a certain angle or certain way to rotate or is there just x,y,and z. Has anyone ever got a windmill turning in moh before?
Image
User avatar
tltrude
Chuck Norris
Posts: 4774
Joined: Sun Jul 07, 2002 4:03 am
Location: Oklahoma, USA
Contact:

axis

Post by tltrude »

Can you post, or send, a prefab of the windmill? In the screenshot, it looks like it has been turned 45 degrees. It will probably have to be rotated on two axis at the same time.
Last edited by tltrude on Sun Apr 11, 2004 4:55 am, edited 1 time in total.
Tom Trude,

Image
echo_rancid
Captain
Posts: 264
Joined: Sat Jan 31, 2004 4:31 pm

Post by echo_rancid »

Here is the WindMill prefab...

WindMill Prefab<==== In a pk3

It is for sure at an angle. Im not sure exactly the angle but its probably around 45.
Last edited by echo_rancid on Sun Apr 11, 2004 5:05 am, edited 1 time in total.
Image
User avatar
tltrude
Chuck Norris
Posts: 4774
Joined: Sun Jul 07, 2002 4:03 am
Location: Oklahoma, USA
Contact:

Prefab

Post by tltrude »

Prefabs are easy, just highlight all the parts of it and go to File > Save to prefab. You can also make a new folder to put your .pfb files in (in MOHAATools for example) if you like.

The path where prefabs are stored is set in Edit > Preferences.
Tom Trude,

Image
echo_rancid
Captain
Posts: 264
Joined: Sat Jan 31, 2004 4:31 pm

Post by echo_rancid »

Prefab is up a couple posts...just edited my previous post.
Image
User avatar
tltrude
Chuck Norris
Posts: 4774
Joined: Sun Jul 07, 2002 4:03 am
Location: Oklahoma, USA
Contact:

lol

Post by tltrude »

Try making the blades and hub streight on one axis in the map and then turn them in the script before you start the spinning.

I'm trying this now.

fan_start:

$blade1 bind $fan
$blade2 bind $fan
$blade3 bind $fan
$blade4 bind $fan
$fan rotateYup -30
$fan waitmove
$fan rotateX 50

end

IT WORKS!!!!!!!!!!!

Looking from the top, turn the hub and blades 30 degrees counter clockwise in your map and recompile.

:)

===================================

Here is an idea for sound. Add this to the top of the script.

local.master aliascache woodcreak2 sound/characters/fs_woodcreak_04.wav soundparms 0.9 0.2 0.9 0.2 184 512 auto loaded maps "m dm moh obj "

Then have two of the blades loop the sound in your thread.

$blade2 loopsound woodcreak2
$blade4 loopsound woodcreak2


works great!

Ps: Also, if you want it to spin the other direction, change 50 to -50.
Tom Trude,

Image
echo_rancid
Captain
Posts: 264
Joined: Sat Jan 31, 2004 4:31 pm

Post by echo_rancid »

Yeah I got it working, you saved the day again Tom, thanks. Now the only thing that will not work is the sound. I put the 3 lines that you posted in my script. The first with the other random exploding sounds. The other two are down with the fan script.


fan:

$blade1 bind $fan
$blade2 bind $fan
$blade3 bind $fan
$blade4 bind $fan
$fan rotateYup -30
$fan waitmove
$fan rotateX 50

$blade2 loopsound woodcreak2
$blade4 loopsound woodcreak2

end


Now is that right?

Also do I need to put some speakers in the map?

Thanks again Tom, really appreciate your help.
Image
Post Reply