Making a switch animate...?

If you're looking for mapping help or you reckon you're a mapping guru, post your questions / solutions here

Moderator: Moderators

Post Reply
FoShizzle
Corporal
Posts: 29
Joined: Sat May 17, 2003 12:35 am

Making a switch animate...?

Post by FoShizzle »

Hey, I was fooling around with using a func_door to function as a switch for a door in my map, and having it slide into the wall. I ran into some problems with it which are rather irritating, so I'm wondering if I should use the models for switches that came with the game. If I do, how do I animate it? I've never done anything with scripting at all before, I've never really had a need to. So if someone could just give me a quick walkthrough of what I will have to do to make a script / get it to run in my map, I would be forever in your debt! Thanks :D
User avatar
bdbodger
Moderator
Posts: 2596
Joined: Tue Feb 25, 2003 7:34 am
Location: canada
Contact:

Post by bdbodger »

Put an "models/animate/electical_switch.tik" or "models/animate/electical_pulse_switch.tik" into your map . Give it a $targetname and then in your script put a thread into your script like this

main:
$myswitch thread elevatorswitches_anim
end


elevatorswitches_anim:
self anim turn
self anim waittill animdone
self anim on
self anim waittill animdone
wait .5
self anim off
end
FoShizzle
Corporal
Posts: 29
Joined: Sat May 17, 2003 12:35 am

Post by FoShizzle »

Right... well, like I said, I've never done anything at all that involves scripting, so I don't really know what you mean. I can't find any good tutorials on it, so I need to know a brief walkthrough of how to script before I know the script I need to get it to run. :oops:
User avatar
Zip
Major
Posts: 323
Joined: Wed Apr 09, 2003 6:47 pm
Location: Belgium

Post by Zip »

How about this....

http://www.planetmedalofhonor.com/rjuka ... l#language

....should get you started on scripting. I'll have to learn at some point myself too :? .
Zip :?
FoShizzle
Corporal
Posts: 29
Joined: Sat May 17, 2003 12:35 am

Post by FoShizzle »

Thanks, Zip. I'll browse through that and see if I can pick up anything :)
User avatar
bdbodger
Moderator
Posts: 2596
Joined: Tue Feb 25, 2003 7:34 am
Location: canada
Contact:

Post by bdbodger »

It is not as hard as it looks . This is rather simple and a good way to start .
first right click on the 2dwindow to open the menu choose animate then eqipment then electric-switch-pulse . second press n to open the entity window set a
key: $targetname
value: myswitch
close the entity window by pressing n again then press esc to deselect the switch

now make a box around the switch 32x32 is ok then right click on the 2d window again this time choose trigger then use . Press n again to open the entity window and set the key /value as follows

key: setthread
value: switchthread (this is the name of you thread in the script)

now open notepad and put this text in it or copy and paste it in

main:
end

switchthread:
$myswitch anim turn
$myswitch anim waittill animdone
$myswitch anim on
$myswitch anim waittill animdone
wait .5
$myswitch anim off
end

save that with a name the same as your map example mymap.txt
then change its name in windows to mymap.scr and put it in the mohaa/maps/ folder or if it is a dm game mohaa/maps/dm folder

compile your map put it in the same folder and run it maybe make a test map and try it out first not too hard was it ? The key setthread tells the game what thread to run when the trigger is used . The trigger_use runs the thread and the thread turns the switch that you gave a $targetname to .
User avatar
Zip
Major
Posts: 323
Joined: Wed Apr 09, 2003 6:47 pm
Location: Belgium

Post by Zip »

......but how do you link the lights in your room to the switch?
Zip :?
User avatar
bdbodger
Moderator
Posts: 2596
Joined: Tue Feb 25, 2003 7:34 am
Location: canada
Contact:

Post by bdbodger »

well what you need to do is not use the light in the mohradiant . You make a script_model give it a

key: $targetname
value: mylight

and

key: model
value: fx/dummy.tik

then in your script

switchthread:
$myswitch anim turn
$myswitch anim waittill animdone
$myswitch anim on
$myswitch anim waittill animdone

$mylight light(1 1 1)
$mylight lightRadius 300
$mylight notsolid
if (level.lightswitch1==0 )
{
$mylight lighton
level.lightswitch1=1
}
else
{
$mylight lightoff
level.lightswitch1=0
}
wait .5
$myswitch anim off
end
User avatar
Zip
Major
Posts: 323
Joined: Wed Apr 09, 2003 6:47 pm
Location: Belgium

Post by Zip »

I see. Thanks. I'll give it go some time. :)
Zip :?
User avatar
bdbodger
Moderator
Posts: 2596
Joined: Tue Feb 25, 2003 7:34 am
Location: canada
Contact:

Post by bdbodger »

One other thing you should put level.lightswitch1=0 somewhere at the top of your script other wise nothing will happen the first time you try to use the switch you will have to press it twice to get it to work . Actually a better Idea is to do this at the top

$mylight light(1 1 1)
$mylight lightRadius 300
$mylight notsolid
level.lightswitch1=0
$mylight lightoff

then this thread

switchthread:
$myswitch anim turn
$myswitch anim waittill animdone
$myswitch anim on
$myswitch anim waittill animdone
if (level.lightswitch1==0 )
{
$mylight lighton
level.lightswitch1=1
}
else
{
$mylight lightoff
level.lightswitch1=0
}
wait .5
$myswitch anim off
end
User avatar
Zip
Major
Posts: 323
Joined: Wed Apr 09, 2003 6:47 pm
Location: Belgium

Post by Zip »

if (level.lightswitch1==0 )
is that a typo? Should it just be = ?
Zip :?
User avatar
mohaa_rox
Field Marshal
Posts: 2760
Joined: Mon Nov 11, 2002 7:05 am
Contact:

Post by mohaa_rox »

no, == are sometimes used, like in this case, where we check the player's dmteam.

if($player.dmteam == allies)
//blah blah

but we have to define $player in MP maps.
Live to map, not map to live.
-mohaa_rox, .map
moderator
User avatar
bdbodger
Moderator
Posts: 2596
Joined: Tue Feb 25, 2003 7:34 am
Location: canada
Contact:

Post by bdbodger »

In the syntax for mohaa

local.i=1 says local.i is equal to 1

local.i==1 equality is local.i = to 1 boolean true or false outputs 0 or 1

if (level.lightswitch1==0 ) says if true they are equal do the next few lines from "{ " to " }"

also != inequality not equal

if (level.lightswitch1 !=0 ) is level.lightswitch "not" equal to 0 is that true if so do the next few lines

The if statement tests to see if what is in the brackets if true . In the second example it tests to see if the two item are not equal . If they are not the if statement is true so do the lines if the if statement is not true do the else statement if there is one . If no else statement do nothing .
User avatar
Zip
Major
Posts: 323
Joined: Wed Apr 09, 2003 6:47 pm
Location: Belgium

Post by Zip »

:shock:

Thanks :)
Zip :?
Post Reply