Author |
Topic: 2 triggers, who works after each other |
haggis |
General Member Since: Apr 26, 2006 Posts: 109 Last: Mar 8, 2008 [view latest posts] |
|
|
Category: CoD2 Scripting Posted: Saturday, Feb. 17, 2007 04:09 pm |
|
Hey,
I have a problem. I can't script
Now my question:
I made a box with a lock. The player must first shot the lock so it breaks and then he can open the box.
Now I make it with 2 triggers. One triggers is a trigger damage for the lock and the other is a trigger use for open the box.
everything on a row:
Trigger damage: Locktrigger1
Brushmodel Lock: Lock1
Trigger use: Boxtrigger1
Brushmodel Box: Box1
Can someone help me with a script, how I can get it works so first he must break down the lock and then open the box??
edited on Feb. 17, 2007 11:11 am by haggis |
|
|
|
rogue722 |
|
General Member Since: Jan 17, 2006 Posts: 175 Last: Mar 29, 2007 [view latest posts] |
|
|
Category: CoD2 Scripting Posted: Saturday, Feb. 17, 2007 05:12 pm |
|
There are some great beginner tutorials on this website. Look around those to find out what everything does. I can help you in this part, it should be very simple, and hopefully this can help you get off to a good start for scripting.
Code:
main()
{
maps\_load::main();
thread box();
}
box()
{
trig_damage = getent("locktrigger1","targetname");
trig_use = getent("boxtrigger1","targetname");
lock = getent("lock1","targetname");
box = getent("box1","targetname");
trig_damage waittill("trigger"); //Waits till it is triggered
trig_damage delete(); //Deletes trigger
//If you want the lock to remove itself from the map
lock delete();
trig_use waittill("trigger");
trig_use delete();
}
Now if you want the lid of the box to open, then you need to create another script_brushmodel and tell it to rotate in the script. Search around the forums/tutorials to find out how to rotate something. Also, make sure that the targetnames match in your script and your map exactly, including case. Hope this helps!
-Rogue
|
|
|
|
babycop |
|
General Member Since: Feb 18, 2006 Posts: 488 Last: Feb 27, 2010 [view latest posts] |
|
|
|
haggis |
General Member Since: Apr 26, 2006 Posts: 109 Last: Mar 8, 2008 [view latest posts] |
|
|
Category: CoD2 Scripting Posted: Saturday, Feb. 17, 2007 07:22 pm |
|
Hey,
Thanks for the fast reply but it doesn't work.
I get this error:
******* script compile error *******
unknown function: (file 'maps/mp/mp_forest.gsc', line 38)
trig_use triggerOn();//enables the trigger to be used now
*
This is now my code:
Code: main()
{
maps\mp\_load::main();
setExpFog(0.0001, 0.55, 0.6, 0.55, 0);
// setCullFog(0, 16500, 0.55, 0.6, 0.55, 0);
ambientPlay("ambient_france");
game["allies"] = "british";
game["axis"] = "german";
game["attackers"] = "axis";
game["defenders"] = "allies";
game["american_soldiertype"] = "normandy";
game["german_soldiertype"] = "normandy";
setCvar("r_glowbloomintensity0", ".25");
setCvar("r_glowbloomintensity1", ".25");
setcvar("r_glowskybleedintensity0",".3");
trig_use = getent("triggerdoos1","targetname");
trig_use = triggeroff();
thread doos1();
}
doos1()
{
trig_damage = getent("slottrigger1","targetname");
trig_use = getent("triggerdoos1");
doos1 = getent("doos1","targetname");
trig_damage waittill("trigger");
trig_damage delete(); //Deletes trigger
trig_use = triggeron();
trig_use waittill("trigger");
doos1 rotatepitch (90,0.5);
doos1 waittill ("rotatedone");
}
edited on Feb. 17, 2007 02:32 pm by haggis
edited on Feb. 17, 2007 02:40 pm by haggis |
|
|
|
WHC_Grassy |
General Member Since: Apr 20, 2005 Posts: 1426 Last: Aug 25, 2007 [view latest posts] |
|
|
|
haggis |
General Member Since: Apr 26, 2006 Posts: 109 Last: Mar 8, 2008 [view latest posts] |
|
|
Category: CoD2 Scripting Posted: Sunday, Feb. 18, 2007 08:55 am |
|
Hi people,
It works fine now, with some help from another guy.
And what Grassy said: triggeron doesn't exist.
Now I made my script so, and it work's perfect after each other:
Code: main()
{
//hide enz.
//doos1
trig_use = getent("triggerdoos1","targetname");
trig_use hide();
//doos2
//threads enz
//doos1
thread doos1();
//doos2
}
//scripts
//doos1
doos1()
{
trig_damage = getent("slottrigger1","targetname");
trig_use = getent("triggerdoos1","targetname");
doos1 = getent("doos1","targetname");
trig_damage waittill("trigger");
trig_damage delete();
trig_use show();
trig_use waittill("trigger");
doos1 rotateroll (-90,0.5);
doos1 waittill ("rotatedone");
trig_use delete();
}
//doos2
Now, I have some other questions:
1) Is it possible that I see the hand of the trig use, only when the lock is shot. Now I can see it all the time, or I don't see it because I have delete it in radiant by pressing N.
2) Is it possible that there is something like the hand by trigger use, that is a kind of the same by damage. So you know there is something where you can shoot on?
edited on Feb. 18, 2007 04:02 am by haggis |
|
|
|
WHC_Grassy |
General Member Since: Apr 20, 2005 Posts: 1426 Last: Aug 25, 2007 [view latest posts] |
|
|
Category: CoD2 Scripting Posted: Sunday, Feb. 18, 2007 12:13 pm |
|
LOL, ach laddie I like yer doos oi do fur sure.
Yes it is possible, when you hide the trigger it is still there, thats why you see the hand icon.
Allow me a little tweakin of yer doos script if oi may.
What ya need to do move the trig_use away out of the picture until it's time to be used.
Code: main()
{
thread _Doos1();
//I changed the thread name as it not good to have same name as entities, can cause errors.
}
//scripts
//doos1
_Doos1()
{
trig_damage = getent("slottrigger1","targetname");
trig_use = getent("triggerdoos1","targetname");
doos1 = getent("doos1","targetname");
//store trig_use origin in oldorg
oldorg = trig_use.origin;
//now move trig_use into Davey Jones Locker
trig_use.origin = oldorg - (0,0,10000);
trig_damage waittill("trigger");
trig_damage delete();
//bring trig_use back
trig_use.origin = oldorg;
trig_use waittill("trigger");
doos1 rotateroll (-90,0.5);
doos1 waittill ("rotatedone");
trig_use delete();
}
See how that goes
Grassy
edited on Feb. 18, 2007 07:24 am by WHC_Grassy |
|
|
|
haggis |
General Member Since: Apr 26, 2006 Posts: 109 Last: Mar 8, 2008 [view latest posts] |
|
|
|
WHC_Grassy |
General Member Since: Apr 20, 2005 Posts: 1426 Last: Aug 25, 2007 [view latest posts] |
|
|
|
haggis |
General Member Since: Apr 26, 2006 Posts: 109 Last: Mar 8, 2008 [view latest posts] |
|
|
|