Page 1 of 2

Pop-Up Target Help

Posted: Thu Nov 16, 2006 1:42 pm
by SniperWolf
Hey Guys,

I was wondering if I could get some help. I'm building a Boot Camp Map for my Clan & want the SMG & MG Ranges to have Targets that pop-up randomly in 6 different locations. I tried to use a script from the map called Training Center by HkySk8r187. I even converted the .bsp to a .map to see how things were mapped into the map. It looks like he made the targets script_objects with targetnames. Then he used this script

Code: Select all

///////////////////////
	level waittill spawn
	///////////////////////

	level.target03		= 0
	level.popuptargets	= 10
	level.enemytargetsdead	= 0
	level.enemytargets	= 22
	level.hostagetargets	= 3
	level.cage		= 0
	
	waitthread popups_setup
	waitthread enemytargets_setup
	waitthread blacktargets_setup
	thread cage_setup
	thread popups_go
	thread blacktargets_run
	$outofcombat_trigger nottriggerable
	$switch1 anim idle
Then further down there was this script, to make them pop-up randomly I'm guessing.

Code: Select all

blacktargets_setup:
	for( local.i = 1; local.i <= 9; local.i++ )
	{
		$( "blacktarget" + local.i ) notsolid
		$( "blacktarget" + local.i ) hide
	}
end

blacktargets_run:
	while (1)
	{
		//choose what target will appear
		local.blackpopup = ((randomint (9)) + 1)
		
		switch (local.blackpopup)
		{
		case 1:
			level.blacktarget = spawn func_crate model $blacktarget1.brushmodel origin $blacktarget1.origin
			level.blacktarget health 1
			break
		case 2:
			level.blacktarget = spawn func_crate model $blacktarget2.brushmodel origin $blacktarget2.origin
			level.blacktarget health 1
			break
		case 3:
			level.blacktarget = spawn func_crate model $blacktarget3.brushmodel origin $blacktarget3.origin
			level.blacktarget health 1
			break
		case 4:
			level.blacktarget = spawn func_crate model $blacktarget4.brushmodel origin $blacktarget4.origin
			level.blacktarget health 1
			break
		case 5:
			level.blacktarget = spawn func_crate model $blacktarget5.brushmodel origin $blacktarget5.origin
			level.blacktarget health 1
			break
		case 6:
			level.blacktarget = spawn func_crate model $blacktarget6.brushmodel origin $blacktarget6.origin
			level.blacktarget health 1
			break
		case 7:
			level.blacktarget = spawn func_crate model $blacktarget7.brushmodel origin $blacktarget7.origin
			level.blacktarget health 1
			break
		case 8:
			level.blacktarget = spawn func_crate model $blacktarget8.brushmodel origin $blacktarget8.origin
			level.blacktarget health 1
			break
		case 9:
			level.blacktarget = spawn func_crate model $blacktarget9.brushmodel origin $blacktarget9.origin
			level.blacktarget health 1
			break
		}
		level.blacktarget waittill death
		wait 1
	}
I used these to lines from the level waittil spawn part of the script, they seem to be directly lined to the other part of the script I was gonna used:

Code: Select all

waitthread blacktargets_setup
thread blacktargets_run
When I did that All the target were visible & none of them disappeared when shot. Could use some help please.

I either want the targets to respawn after being destroyed in random spots for about 2 minutes or just pop-up in 1 of 6 random spots then be able to do it for the next player. Help Please.

SniperWolf

Posted: Thu Nov 16, 2006 3:00 pm
by Wertmanzzz
I think you could best spawn triggers around the crates, and waittill they get hit, then delete the whole thing and wait until the rest is shot

Code: Select all

// put this in case # 
level.trigger = spawn trigger_multiple
level.trigger.targetname = $( "trigger" + local.i )
$trigger#.origin = $blacktarget#.origin
$trigger# setsize ( // don't know how big those boxes are ) ( )
$trigger#.health = 1.0
$trigger# triggerable 
$trigger# setthread trigger#
thread trigger#

trigger#:
$trigger# waittill trigger
if($trigger#.health == 1.0)
goto trigger# // go back, this aint a shot.
if($trigger#.health < 1.0)
{
//it's shot, so do this:
	$trigger# nottriggerable
	$blacktarget# hide
	$blacktarget# notsolid
}
// put numbers in the place of #
something like that :)
Hope that'll work.

Posted: Fri Nov 17, 2006 12:51 am
by SniperWolf
thing is I would like map as much as possible into the map & use a script to have things pop up & down. just not sure on how to get it done. Plus I'm not great at scripting anything really :shock: I was also thinking I could use "show" & "hide" to get the same thing done but how would i made the targets appear randomly??

Posted: Fri Nov 17, 2006 1:59 am
by bdbodger
That script should work if you have $blacktarget1 to $blacktarget9 in your map

$( "blacktarget" + local.i ) hide

should hide them

Posted: Fri Nov 17, 2006 4:44 am
by SniperWolf
Well i actually changed the "blacktarget" to the targetname i gave them in my map, but it doesn't hide them. Maybe I have the targetname wrong in the script. Also what does this line refer to?

switch (local.blackpopup)

There is nothing in the script or map that mention that line.

Thanks Guys

Posted: Fri Nov 17, 2006 9:25 am
by bdbodger
//choose what target will appear
local.blackpopup = ((randomint (9)) + 1)

switch (local.blackpopup)
randomint(9) is a random number between 0 and 8 , 9 digits so to make it 1 to 9 you add 1 to it .
switch (local.blackpopup)
{
case 1:
level.blacktarget = spawn func_crate model $blacktarget1.brushmodel origin $blacktarget1.origin
level.blacktarget health 1
break
case 2:
level.blacktarget = spawn func_crate model $blacktarget2.brushmodel origin $blacktarget2.origin
level.blacktarget health 1
break
case 3:
level.blacktarget = spawn func_crate model $blacktarget3.brushmodel origin $blacktarget3.origin
level.blacktarget health 1
break
....
....
....
}
The switch statement means select something based on the value inside the brackets in this case the value of local.blackpopup which is a random number between 1 and 9

case 1: // If in this case local.blackpopup is 1 do the next few lines
level.blacktarget = spawn func_crate model $blacktarget1.brushmodel origin $blacktarget1.origin
level.blacktarget health 1
break // break out of the switch statement and continue the script

The switch statemant reads the script untill it finds a matching case statement that is equal to the expression that is inside the brackets then begins to execute the statements that follow untill it incounters a break statement

Posted: Fri Nov 17, 2006 10:30 am
by SniperWolf
So do i need to rename blackpopup to match the targetname of my targets??
Say like this:

switch (local.smgtargetpopup)

All my targets, 6 total are named smgtarget_1, 2, etc. Or would I just leave it

switch (local.blackpopup)

Plus, do I need to move the line that hides all the targets from where it is to up under level waittil spawn??

I double checked the training center.map(after converting it from .bsp) & his targets are script_objects with targetnames and origins. Is the orgin something I have to add while mapping or is that something that id added when I compile the map??

SniperWolf

Posted: Fri Nov 17, 2006 5:12 pm
by bdbodger
//choose what target will appear
local.blackpopup = ((randomint (9)) + 1)

switch (local.blackpopup)
randomint(9) is a random number between 0 and 8 , 9 digits so to make it 1 to 9 you add 1 to it .
The switch statement means select something based on the value inside the brackets in this case the value of local.blackpopup which is a random number between 1 and 9

case 1: // If in this case local.blackpopup is 1 do the next few lines
level.blacktarget = spawn func_crate model $blacktarget1.brushmodel origin $blacktarget1.origin
level.blacktarget health 1
break // break out of the switch statement and continue the script
Targetnames start with $ so that means that $blacktarget1 is the targetname of an entity $blacktarget1.origin is where that entity is located $blacktarget1.brushmodel is the model of that entity . So

level.blacktarget = spawn func_crate model $blacktarget1.brushmodel origin $blacktarget1.origin

would spawn a func_crate and change it's model to that entities model at that models origin or location in the map .

Posted: Sat Nov 18, 2006 1:41 pm
by SniperWolf
OK,

I changed all the targetnames of my script_objects to smgtarget1, 2 ect.

Changed all the "blackpopup" to "smgpopup"

I got it to load my map & all but 1 target was hidden :D But as soon as I shot the target & it was suppose to pop-up the next 1, my game crashed :evil: Now when I try to load my map it just crashes to the main room.

Here is the error from the console:

ERROR:func_crate:: setSolidType : SOLID_BSP entity at x0.00 y0.00 z0.00 with no bsp model

I'm not sure if its a mapping problem or a scripting problem. Looks like a mapping problem but I'm not sure. Here is my entire script to see if there's a problem with in the script.

Code: Select all

//TEST
// ARCHITECTURE: ?{T?F}?SniperWolf 
// SCRIPTING: ?{T?F}?SniperWolf  

main:

// set scoreboard messages
setcvar "g_obj_alliedtext1" "  Ceremony" 
setcvar "g_obj_alliedtext2" "     &   "
setcvar "g_obj_alliedtext3" " Boot Camp"
setcvar "g_obj_axistext1" "      Map"
setcvar "g_obj_axistext2" "       By:"
setcvar "g_obj_axistext3" "?{T?F}??niperWolf"

setcvar "g_scoreboardpic" "none" 

level waitTill prespawn

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

level.script = maps/dm/test.scr 

level waittill spawn

//GRENADE RANGE///

//Hide Green Lights//

$topleft_green hide
$topmiddle_green hide
$topright_green hide
$bottomleft_green hide
$bottommiddle_green hide
$bottomright_green hide

waitthread smgtargets_setup
thread smgtargets_run

level waittill roundstart

///////////////////////////////////////////////
/////** For SMG RANGE ///////////////////
///////////////////////////////////////////////
smgtargets_setup:
	for( local.i = 1; local.i <= 6; local.i++ )
	{
		$( "smgtarget" + local.i ) notsolid
		$( "smgtarget" + local.i ) hide
	}
end

smgtargets_run:
	while (1)
	{
		//choose what target will appear
		local.smgpopup = ((randomint (6)) + 1)
		
		switch (local.smgpopup)
		{
		case 1:
			level.smgtarget = spawn func_crate model $smgtarget1.brushmodel origin $smgtarget1.origin
			level.smgtarget health 1
			break
		case 2:
			level.smgtarget = spawn func_crate model $smgtarget2.brushmodel origin $smgtarget2.origin
			level.smgtarget health 1
			break
		case 3:
			level.smgtarget = spawn func_crate model $smgtarget3.brushmodel origin $smgtarget3.origin
			level.smgtarget health 1
			break
		case 4:
			level.smgtarget = spawn func_crate model $smgtarget4.brushmodel origin $smgtarget4.origin
			level.smgtarget health 1
			break
		case 5:
			level.smgtarget = spawn func_crate model $smgtarget5.brushmodel origin $smgtarget5.origin
			level.smgtarget health 1
			break
		case 6:
			level.smgtarget = spawn func_crate model $smgtarget6.brushmodel origin $smgtarget6.origin
			level.smgtarget health 1
			break
		
		}
		level.smgtarget waittill death
		wait 1
	}

end

//Enter & Exit Text//

thread enter_grenade_triggered

enter_grenade_triggered:
   iprintln "Welcome To The Grenade Range Soldier!"

wait 1

   iprintln "Here We Test Your Grenade Skills."

end

thread exit_grenade_triggered

exit_grenade_triggered:
  iprintln "Good Job, Good Luck On The Obstacle Course."

end

//Grenade Text & Lights//

thread grenade_topleft_triggered

grenade_topleft_triggered:
  iprintln "Great Throw!!! You Scored 5 Points."
  $topleft_red hide
  $topleft_green show

wait 10

  $topleft_red show
  $topleft_green hide

end

thread grenade_topcenter_triggered

grenade_topcenter_triggered:
  iprintln "Nice Toss!!! You Scored 3 Points."
  $topmiddle_red hide
  $topmiddle_green show

wait 10

  $topmiddle_red show
  $topmiddle_green hide

end

thread grenade_topright_triggered

grenade_topright_triggered:
  iprintln "Way To Go!!! You Scored 2 Points."
  $topright_red hide
  $topright_green show

wait 10

  $topright_red show
  $topright_green hide

end

thread grenade_bottomleft_triggered

grenade_bottomleft_triggered:
  iprintln "Good Job!!! You Scored 3 Points."
  $bottomleft_red hide
  $bottomleft_green show

wait 10

  $bottomleft_red show
  $bottomleft_green hide

end

thread grenade_bottomcenter_triggered

grenade_bottomcenter_triggered:
  iprintln "Good Toss!!! You Scored 1 Point."
  $bottommiddle_red hide
  $bottommiddle_green show

wait 10

  $bottommiddle_red show
  $bottommiddle_green hide

end

thread grenade_bottomright_triggered

grenade_bottomright_triggered:
  iprintln "Excellent Job!!! You Scored 1 Point."
  $bottomright_red hide
  $bottomright_green show

wait 10

  $bottomright_red show
  $bottomright_green hide

end

//Rifle Range//

//Enter & Exit Text//

thread enter_rifle_triggered

enter_rifle_triggered:
  iprintln "Welcome To The Rifle Range Soldier!"

wait 1

   iprintln "Here We Test Your Rifle Skills."

end

thread exit_rifle_triggered

exit_rifle_triggered:
  iprintln "Nice Job, Good Luck On The Sniper Range."

wait 3
  
  iprintln "Welcome To The Sniper Range Soldier!"

wait 1
  
  iprintln "Here We Test Your Sniper Rifle Skills."

end

//Sniper Range//

//Enter & Exit Text//

thread exit_rifle_triggered

exit_sniper_triggered:
  iprintln "Nice Job, Good Luck On The SMG Range."

end

//MG42 Range//

//Enter & Exit Text//

thread enter_mg42_triggered

enter_mg42_triggered:
  iprintln "Welcome To The MG-42 Range Soldier!"

wait 1

   iprintln "Here We Test Your Skills Under Fire."

end

thread exit_mg42_triggered

exit_mg42_triggered:
  iprintln "Nice Job, Good Luck On The Grenade Range."

end

//SMG Range//

//Enter & Exit Text//

thread enter_smg_triggered

enter_smg_triggered:
   iprintln "Welcome To The SMG Range Soldier!"

wait 1

   iprintln "Here We Test Your SMG Skills."

end


thread exit_smg_triggered

exit_smg_triggered:
  iprintln "Way To Go! Now Try The MG Range."

wait 3

   iprintln "Welcome To The MG Range Soldier!"

wait 1

   iprintln "Here We Test Your MG Skills."

end

//MG Range//

//Enter & Exit Text//

thread exit_mg_triggered

exit_mg_triggered:
   iprintln "Good Work! Now Try The MG-42 Range."

end
Thanks Guys.

SniperWolf

Posted: Sat Nov 18, 2006 5:41 pm
by bdbodger
ERROR:func_crate:: setSolidType : SOLID_BSP entity at x0.00 y0.00 z0.00 with no bsp model
My guess you have named one you your $smgtarget's wrong and the game can't find it . What are they? My guess is script_objects it maybe possible too that you named 2 the same and that is causeing an error . Or forgot to make one a script_object or func_crate which ever you used . You get a simular error when you make a func_rotateingdoor from an origin brush with no brush for the door when you made it a func_rotateingdoor . Since the only func_crates you seem to have are the targets then it must be one of them you will just have to find it .

Posted: Sun Nov 19, 2006 3:51 am
by SniperWolf
I got it to work. Seems I had copied the targets & didn't know it. So there where actually 12 targets instead of 6. So once I deleted 1 set of targets it worked.

I was wondering now if is possible to get it to it to randomly pick the next target but not be the target that was just destroyed??

I would like it to cycle threw the targets randomly but not ever repeating targets. Is that possible??

SniperWolf

Posted: Sun Nov 19, 2006 9:26 am
by «{T§F}»Puckeye
I'll take care of that one Sniper :) Afterward if the guys here want to see the result we'll post it.

I'm a programmer in real life, the language used sometimes mystifies me but I know how to make sure the current target won't be the next one.

Posted: Sun Nov 19, 2006 10:40 am
by bdbodger
It is good to see new members willing to help instead of asking for stuff to be done for them :) . I'll just take one step back and let ?{T?F}?Puckeye step up to the plate . Oh and welcome to .map for Mohaa ?{T?F}?Puckeye

Posted: Sun Nov 19, 2006 10:59 am
by «{T§F}»Puckeye
I'm always willing to help whenever I can...

Though this one is selfish...

SniperWolf is in my chain of command in ?{T?F}? :) You might also have heard of our GOA Rugen as well...

I have to admit I don't read these forums as much as SniperWolf and Rugen because my time is mostly spent managing our website. :)

So basically Sniper is our mapper, I script and Rugen yells LOL Well not really, Rugen administers the servers and deals with the config stuff... So it's becoming a pretty well oiled team :)

Posted: Sun Nov 19, 2006 11:27 am
by «{T§F}»Puckeye
Well I guess I should go about showing the solution I found.

First off let's include a variable that'll retain which target is currently up (that state remains until a new one is upped).

smgtargets_run:
local.current_choice = 0
while (1)


Then after the random chooser we check to make sure the newly chosen target isn't the current one.

//choose what target will appear
local.smgpopup = ((randomint (6)) + 1)
while (local.smgpopup != local.current_choice)
{
local.smgpopup = ((randomint (6)) + 1)
}


Then in the switch we just make sure to change the value of the variable to the new current target.

case 1:
level.smgtarget = spawn func_crate model $smgtarget1.brushmodel origin $smgtarget1.origin
level.smgtarget health 1
local.current_choice = 1
break
case 2:
level.smgtarget = spawn func_crate model $smgtarget2.brushmodel origin $smgtarget2.origin
level.smgtarget health 1
local.current_choice = 2
break


One thing that would make it even a bit simpler (actualy it would remove one line of code)... In PHP we have while ... do and do ... while loops... I know about the while in scripts but is there a do ... while and if so how is it done?