Page 1 of 1

Script objects

Posted: Sun Apr 27, 2003 12:36 am
by solar
Can a script object that is being used for a certain effect also be part of an exploder set? Basically, how do I designate it as having two targetnames- one for the effect and one for the exploder??

Posted: Sun Apr 27, 2003 1:23 am
by bdbodger
when you make an exploder you set a #set value and when you have several objects with the same targetname if forms a targetname array . So what you can do is lets say the object you want has a #set of 2 the first thing you need to do if you are going to move the object is to bind all the parts to the $exploder
for(local.b=1;local.b<$exploder.size+1:local.b++)
{
if $exploder[local.b].set=2
{
for(local.i=1;local.i<$explodersmashed.size+1;local.i++)
{
if $explodersmashed[local.i].set=2
$explodersmashed[local.i] bind $exploder[local.b]
}
for(local.c=1;local.c<$exploderchunck.size+1;local.c++)
{
if $exploderchunk[local.c].set=2
{
$exploderchunk[local.c] bind $exploder[local.b]
local.target=$exploderchunk[local.c].target
$(local.target) bind $exploder[local.b]
}
}
for(local.d=1;local.d<$exploderfire.size+1;local.d++)
{
if $exploderfire[local.d].set=2
$exploderfire[local.d] bind $exploder[local.b]
}
level.mymoveobject=$exploder[local.b]
}
}
then just script for level.mymoveobject

Posted: Sun Apr 27, 2003 2:22 am
by solar
Whoa, that threw me. Please understand this is my first map and my first attempt at scripting. Well, I tried to cross this bridge about a month ago and no one was able to give me a working script so now that I'm trying to get this map beta worthy, let's try it again. Look at these two pics:

Image
Image

In the first pic you see the engine testcell control room. In the second pic you see the test stand itself with the engine and propellor. At the control table you see two levers. The explosive is set on the test stand (this is and older pic and it's not visible right now).

The objective here is to set the explosive on the test stand. However, if the left lever is activated, the engine begins to run and the prop begins to rotate. If anyone enters the test cell while the engine is running they will be killed instantly. So to set the bomb, you first have to turn the engine off (if it's running) with the left lever, and then go inside and set the explosive. This is why I asked the question above, because since the propellor will have to be made up of script_objects so it can rotate, how can it also be part of the exploder set?

To sum up, this is what I'm looking for:

1. The triggerable lever that will function like a fulcrum lever and can activate and deactivate the engine.

2. The prop that will rotate once triggered, and if it could increase in speed- that would be awesome. I understand it can only go so fast, but I am curious to see how fast that is. It also must stop rotating when the engine is deactivated.

3. A killarea that will be in effect only when the engine is running.

4. The prop must also be part of the exploder set so it can blow up.

Any takers???

4.

Posted: Sun Apr 27, 2003 1:41 pm
by nuggets
lol, you really don't want much :P

i don't know how far u've got with setting the triggers, if u've got the propellers to rotate, etc...

so here we go...

a.
create the trigger, and use trigger->use
key: targetname
value: engine_switch
key: setthread
value: engine_onoff

then the propellers, select them all and an origin in the centre, script->object
key: targetname
value: props
key: #set
value: 1 //or what ever set number you need
and a kill area trigger->multiple
key: targetname
value: kill_area
key:setthread
value: kill_people


b. the script
main:
level.props_motion = 0 //means the propellers aren't on
level.counter = 0
$kill_area nottriggerable //will stop people dying when the fans off
level.props = $props //gives the propellors their 2nd targetname
$props.targetname = "explodersmashed" //makes it able to be in the set
end

engine_onoff:
if level.props_motion = 0
{
thread engine_starting
kill_area triggerable
//if you want you can move this to VVV
level.props_motion = 1
}
else
{
thread engine_stopping
}

engine_starting:
level.counter = (level.counter + 1)
level.props time 1
evel.props rotateZup (level.counter * 240)
level.props waitmove
if (level.counter == 3)
{
thread engine_going
//HERE!!! so the players have 3 seconds 2 get out while it starts spinning
}
else
{
thread engine_starting
}

engine_going:
level.props rotateZup 720 //that'll rotate it fully twice in 1 second
// try playing with these value
level.props waitmove
goto engine_going

engine_stopping:
level.counter = (level.counter - 1)
level.props rotateZdown (level.counter * 240)
level.props waitmove
if (level.counter == 0)
{
level.props_motion = 0
kill_area nottriggerable
}
else
{
thread engine_stopping
}

// this will make the propellors speed up and slow down when they're
// turned on/off, you can do without some of this script if you want them
// either on or off

kill people:
self kill
end

Posted: Sun Apr 27, 2003 2:45 pm
by bdbodger
just wondering
$props.targetname = "explodersmashed" //makes it able to be in the set
won't that change the targetname of $props to $explodersmashed ?

Posted: Sun Apr 27, 2003 2:53 pm
by solar
thx nuggets, I'll give it a try later this afternoon.
$props.targetname = "explodersmashed"
Doesn't this have to be "exploder"?? I'll create my own explodersmashed brushes that will appear after the explosion.

Posted: Sun Apr 27, 2003 3:00 pm
by solar
Oh, one other thing, it doesn't look like you have a script for th fulcrum lever moving forward and backward. Or am I missing it?? I know this is a complicated script. Sometimes you don't know what you're getting into until you start it. But thx for the help anyway.

Posted: Mon Apr 28, 2003 12:36 am
by nuggets
EDITED POST!!!
lol, you really don't want much :P

i don't know how far u've got with setting the triggers, if u've got the propellers to rotate, etc...

so here we go...

a.
create the trigger, and use trigger->use
key: targetname
value: engine_switch
key: setthread
value: engine_onoff

then the propellers, select them all and an origin in the centre, script->object
key: targetname
value: props
key: #set
value: 1 //or what ever set number you need
and a kill area trigger->multiple
key: targetname
value: kill_area
key:setthread
value: kill_people

and lastly the lever, (including the origin)
key: targetname
value: lever

b. the script
main:
level.props_motion = 0 //means the propellers aren't on
level.counter = 0
$kill_area nottriggerable //will stop people dying when the fans off
level.props = $props //gives the propellors their 2nd targetname
$props.targetname = "explodersmashed" //makes it able to be in the set
end

engine_onoff:
if level.props_motion = 0
{
thread engine_starting
thread lever_on
kill_area triggerable
//if you want you can move this to VVV
level.props_motion = 1
}
else
{
thread engine_stopping
thread lever_off
}
end

engine_starting:
level.counter = (level.counter + 1)
level.props time 1
evel.props rotateZup (level.counter * 240)
level.props waitmove
if (level.counter == 3)
{
thread engine_going
//HERE!!! so the players have 3 seconds 2 get out while it starts spinning
}
else
{
thread engine_starting
}
end

engine_going:
level.props rotateZup 720 //that'll rotate it fully twice in 1 second
// try playing with these value
level.props waitmove
goto engine_going
end

engine_stopping:
level.counter = (level.counter - 1)
level.props rotateZdown (level.counter * 240)
level.props waitmove
if (level.counter == 0)
{
level.props_motion = 0
kill_area nottriggerable
}
else
{
thread engine_stopping
}
end

// this will make the propellors speed up and slow down when they're
// turned on/off, you can do without some of this script if you want them
// either on or off

kill people:
self kill
end

level_on:
$lever time 1
$lever rotateZup 15
$lever waitmove
end

lever_off:
$lever time 1
$lever rotateZdown 15
$lever waitmove
end


//the new edited post :D i missed out a few END's and wasn't sure what a fulcrum lever looked like, but it's all their now :D

Posted: Tue Apr 29, 2003 9:58 pm
by solar
nope, it didn't work, so I have attached the error section in my logfile and my script. Keep in mind there are three objs in my map- two bombs and one documents theft obj.
LOGFILE

bad token:
TOKEN_DOUBLE_COLON:
::

global/obj_dm.scr::bomb_thinker // "panel_bomb" is the targetname set on the bomb in MOHRadiant (maps/obj/dbenztest.scr, 52)
global/obj_dm.scr^

^~^~^ Script file compile error: Couldn't parse 'maps/obj/dbenztest.scr'
^~^~^ Game (Event: 'setthread', Object: 'TriggerUse') : Script 'maps/obj/dbenztest.scr' was not properly loaded

^~^~^ Game (Event: 'setthread', Object: 'Trigger') : Script 'maps/obj/dbenztest.scr' was not properly loaded

0 teams with 0 entities
ScriptMaster::GetScript: Script 'maps/obj/dbenztest.scr' was not properly loaded
SCRIPT

main:

// set scoreboard messages
setcvar "g_obj_alliedtext1" "Blow the fuel far "
setcvar "g_obj_alliedtext2" "Steal the plans"
setcvar "g_obj_alliedtext3" ""
setcvar "g_obj_axistext1" "Protect the fuel farm"
setcvar "g_obj_axistext2" "Secure the plans"
setcvar "g_obj_axistext3" ""

setcvar "g_scoreboardpic" "none

level waittill prespawn

//hangar door timing
$hangardoor1 time 4 // travel time in seconds
$hangardoor2 time 4
$hangardoor3 time 4
$hangardoor4 time 4
thread hanger_doors
//stop timing

//***Precache Dm Stuff
exec global/DMprecache.scr
level.script=maps/obj/cust_obj_test.scr
exec global/ambient.scr cust_obj_test
thread global/exploder.scr::main

level waittill spawn

//obj setup
level.defusing_team = "axis" // Axis like the bombs unplanted
level.planting_team = "allies" // Allies will try to plant the bombs
level.targets_to_destroy = 3 // Number of targets in this map
level.bomb_damage = 200 // Default damage of the bomb
level.bomb_explosion_radius = 2048 // Default radius of bomb blast

// Set the parameters for round based match
level.dmrespawning = 0 // 1 or 0 (0=no respawn)
level.dmroundlimit = 5 // round time limit in minutes
level.clockside = axis // set to axis, allies, kills, or draw

// level waittill roundstart // Comment out this line using '//' before it to be able to set the bomb when alone on the map ( just for testing )

$panel_bomb thread
$stand_bomb thread
global/obj_dm.scr::bomb_thinker // "panel_bomb" is the targetname set on the bomb in MOHRadiant
thread desk_document_check
thread allies_win_bomb // Start the win check thread for allies
thread axis_win_timer // Start the win check thread for axis
end

// Allied victory test

allies_win_bomb:
while(level.targets_destroyed < level.targets_to_destroy) // While undestroyed objectives left
waitframe // chill out
teamwin allies // No objectives left allies win
end

// Axis victory test

axis_win_timer:
level waittill axiswin // At the end Axis win
end // end axis victory test


//------------------------------
// Document thread
//------------------------------

desk_document_check:

$documents_trigger waittill trigger // waits until triggered
local.player = parm.other
if (local.player.dmteam == axis)
{
goto desk_document_check
}
if (local.player.dmteam == allies)
{
$documents playsound snd_papers
wait .2
$documents hide // Make the document disappear
level.targets_destroyed ++ // adds 1 to the number of targets destroyed
}

end


//------------------------------
// Hanger doors thread
//------------------------------

hanger_doors:
$hangardoor_trigger waittill trigger
$hangardoor_trigger remove
$hangardoor_switch anim turn
$hangardoor_switch playsound alarm_switch
$hangardoor1 loopsound lighthouse_run
$hangardoor4 loopsound lighthouse_run

$hangardoor2 moveWest 336
$hangardoor2 move
$hangardoor3 moveEast 336
$hangardoor3 move

wait 4

$hangardoor2 moveWest 336
$hangardoor2 move
$hangardoor3 moveEast 336
$hangardoor3 move
$hangardoor1 moveWEst 336
$hangardoor1 move
$hangardoor4 moveEast 336
$hangardoor4 waitmove

$hangardoor1 loopsound lighthouse_run wait
$hangardoor4 loopsound lighthouse_run wait

end

//--------------------------------
// Test Stand threads
//--------------------------------

level.props_motion = 0 //means the propellers aren't on
level.counter = 0
$kill_area nottriggerable //will stop people dying when the fans off
level.props = $props //gives the propellors their 2nd targetname
$props.targetname = "exploder" //makes it able to be in the set
end

engine_onoff:
if level.props_motion = 0
{
thread engine_starting
thread lever_on
kill_area triggerable //if you want you can move this to VVV
level.props_motion = 1
}
else
{
thread engine_stopping
thread lever_off
}
end

engine_starting:
level.counter = (level.counter + 1)
level.props time 1
evel.props rotateZup (level.counter * 240)
level.props waitmove
if (level.counter == 3)
{
thread engine_going
//HERE!!! so the players have 3 seconds 2 get out while it starts spinning
}
else
{
thread engine_starting
}
end

engine_going:
level.props rotateZup 720 //that'll rotate it fully twice in 1 second
// try playing with these value
level.props waitmove
goto engine_going
end

engine_stopping:
level.counter = (level.counter - 1)
level.props rotateZdown (level.counter * 240)
level.props waitmove
if (level.counter == 0)
{
level.props_motion = 0
kill_area nottriggerable
}
else
{
thread engine_stopping
}
end

// this will make the propellors speed up and slow down when they're
// turned on/off, you can do without some of this script if you want them
// either on or off

kill people:
self kill
end

level_on:
$lever time 1
$lever rotateZup 15
$lever waitmove
end

lever_off:
$lever time 1
$lever rotateZdown 15
$lever waitmove
end
Could it still be a problem with the props having in essence two targetnames?
$props.targetname = "exploder" //makes it able to be in the set
end
I changed this to "exploder" rather than "explodersmashed" because it seemed the proper way. Was that just plain stupid on my part?? (Probably)

Posted: Wed Apr 30, 2003 6:06 am
by jv_map
global/obj_dm.scr::bomb_thinker

should be

$panel_bomb thread global/obj_dm.scr::bomb_thinker

Posted: Wed Apr 30, 2003 12:49 pm
by bdbodger
one other thing in the global/exploder.scr there is a line
Before level waittill prespawn "exec global/exploder.scr".
the script creates an array when it is launched and creates variables level.explodersmasheds if the name of the $props is not $explodersmashed when the script is executed at the begining of the map script it will not be part of the array also the script makes the $explodersmashed not solid and hides it .

Posted: Wed Apr 30, 2003 1:56 pm
by solar
jv_map wrote:
global/obj_dm.scr::bomb_thinker

should be

$panel_bomb thread global/obj_dm.scr::bomb_thinker
How about the stand_bomb??? should I also have as the next line:

$stand_bomb thread global/obj_dm.scr::bomb_thinker
bdbodger wrote:

one other thing in the global/exploder.scr there is a line
Quote:
Before level waittill prespawn "exec global/exploder.scr".

the script creates an array when it is launched and creates variables level.explodersmasheds if the name of the $props is not $explodersmashed when the script is executed at the begining of the map script it will not be part of the array also the script makes the $explodersmashed not solid and hides it .
So nuggets was right about it reading $props.targetname="explodersmashed"?

Posted: Wed Apr 30, 2003 5:31 pm
by nuggets
bloody exploder sets!!!, didn't realise about the array for exploders eve though it's obvious they must be there :P

but surely it would work if it was put in b4 the exec... line???

Posted: Thu May 01, 2003 12:14 am
by bdbodger
maybe you can do this
for(local.i=1;local.i<$exploder.size+1;local.i++)
{
if $exploder[local.i].set=1
level.props=$exploder[local.i]
}

that way if the set of the script object $exploder was 1 you could do what you want by scripting for level.props