Multiple document objectives?

Post your scripting questions / solutions here

Moderator: Moderators

User avatar
GrimReaper
Sergeant
Posts: 58
Joined: Tue Dec 30, 2003 5:40 am

Post by GrimReaper »

Alright,I got the bomb to set and blow up but when it did nothing happened...the allies didnt win.Also only when I get the documents the allies win.When I get the documents first Allies win..if I get the last allies win?so i must have some little thing wrong but i have no idea

Code: Select all

// Custom objective test map 
// ARCHITECTURE: GrimReaper 
// SCRIPTING: GrimReaper 
main: 

   setcvar "g_obj_alliedtext1" "Steal the documents." 
   setcvar "g_obj_alliedtext2" "- Go get them" 
   setcvar "g_obj_alliedtext3" "- U know U want to" 
   setcvar "g_obj_axistext1" "Prevent the allies" 
   setcvar "g_obj_axistext2" "from stealing the" 
   setcvar "g_obj_axistext3" "documents." 

   setcvar "g_scoreboardpic" "none" 

   level waittill prespawn 

   // There is no OBJprecache.scr 
   exec global/DMprecache.scr 

   level.script = maps/obj/objtest.scr 

   // m6l1a is a blowing wnind sound 
  exec global/ambient.scr obj_team2 
  thread global/exploder.scr::main 
   
   level waittill spawn 
  
   level.defusing_team = "axis" // Axis like the bombs unplanted
   level.planting_team = "allies" // Allies will try to plant the bombs
   level.targets_to_destroy = 1 // 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 // axis, allies, kills, or draw 

   // Comment out this line to be able to set the bomb 
   // when alone on the map ( just for testing ) 
   // level waittill roundstart 
   
   $panel_bomb thread global/obj_dm.scr::bomb_thinker // "panel_bomb" is the targetname set on the bomb in MOHRadiant
   thread allies_win_bomb // Start the win check thread for allies
   $panel_bomb thread axis_win_timer // Start the win check thread for axis


   // Start the win check thread for allies 
   thread desk_document_check 

   // If the end of the match is reached, the Axis win 
   level waittill axiswin 

end // end of main 

// Document checks 
desk_document_check: 
   while(1) { // forever 
      // Dont execute past this line 
      // until someone triggers the object 
      $documents_trigger waittill trigger 
      // parm.other is the triggerer 
      if(parm.other.dmteam == allies) { 
         // Make the document graphix disappear 
         $documents hide 
         // break out of the while loop 
         break 
      } 
      // protection against making this 
      // thread use too much CPU 
      waitframe 
   } 
   teamwin allies // Make allies win the match 
end // end allies victory test
User avatar
GrimReaper
Sergeant
Posts: 58
Joined: Tue Dec 30, 2003 5:40 am

Post by GrimReaper »

Also on the tutorials at the bottom it has like the download thing...well I took the 4 peices that are apart that go to the panel and they have the blue lines coming from the script object or script origin. :oops:...why can I see the 4 pieces that are supposed to been seen after the explosion?
User avatar
Axion
Major General
Posts: 683
Joined: Mon Sep 29, 2003 5:14 am
Location: Northern California
Contact:

Post by Axion »

Code: Select all

level.targets_to_destroy = 1 // Number of targets in this map
Try changing that to 2 instead of 1.
"The work of a thousand years is nothing but rubble."
- Dr. Carl Goerdeler (1943)
Visit my mapping site: http://www.freewebs.com/axion9
Image
Bjarne BZR
Site Admin
Posts: 3298
Joined: Wed Feb 05, 2003 2:04 pm
Location: Sweden
Contact:

Post by Bjarne BZR »

GrimReaper wrote:why can I see the 4 pieces that are supposed to been seen after the explosion?
If there is an error in the explosion setup: the explosion debris are not hidden by the exploder system, so something is wrong.

But you say the bomb works? Can you blow it up?

Your script has no allies_win_bomb method... did you forget to copy it?


Oh, and changing level.targets_to_destroy = 1 to 2 will not help, only make the allies unable to win by blowing the bomb later,
Admin .MAP Forums
Image
Head above heels.
User avatar
Axion
Major General
Posts: 683
Joined: Mon Sep 29, 2003 5:14 am
Location: Northern California
Contact:

Post by Axion »

If you are trying to have both a bomb and document objective, this script should work.

Code: Select all

 
   main:

   setcvar "g_obj_alliedtext1" "Your text goes in here..."
   setcvar "g_obj_alliedtext2" "...and here..."
   setcvar "g_obj_alliedtext3" "...and here..."
   setcvar "g_obj_axistext1" "...and so on..."
   setcvar "g_obj_axistext2" "...and so forth..."
   setcvar "g_obj_axistext3" "get the point?"

   setcvar "g_scoreboardpic" "none"
    
    /////////////////////////
   level waittill prespawn
   /////////////////////////

   exec global/DMprecache.scr

   level.script = maps/obj/objtest.scr

   // m6l1a is a blowing wnind sound
  exec global/ambient.scr obj_team2
  thread global/exploder.scr::main 

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

   level.defusing_team = "axis" 
   level.planting_team = "allies" 
   level.targets_to_destroy = 2 
   level.bomb_damage = 200 
   level.bomb_explosion_radius = 2048 

   // 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 // axis, allies, kills, or draw

   // level waittill roundstart // Use "//" for testing the bomb alone
   
   $panel_bomb thread global/obj_dm.scr::bomb_thinker 
   thread allies_win_bomb // Start the win check thread for allies
   $panel_bomb thread axis_win_timer 
   thread desk_document_check 
   level waittill axiswin 
  
end

// "Axis Victory"

axis_win_timer:
level waittill axiswin

end

 // "Allied Victory"

allies_win_bomb:
while(level.targets_destroyed < level.targets_to_destroy)
waitframe
teamwin allies

end

desk_document_check:
	while(1) { // forever
		// Dont execute past this line
		// until someone triggers the object
		$documents_trigger waittill trigger
		// parm.other is the triggerer
		if(parm.other.dmteam == allies) {
			// Make the document graphix disappear

			$documents hide
			// Tell the win method that an
			// objective has been completed
			level.targets_destroyed ++ // ++ adds 1
			// break out of the while loop
			iprintln "The documents have been stolen!!" //Type the message you want to be displayed when the documents are stolen
			break
		}
		// protection against making this
		// thread use too much CPU
		waitframe
	}
end // end document checks

end



 
"The work of a thousand years is nothing but rubble."
- Dr. Carl Goerdeler (1943)
Visit my mapping site: http://www.freewebs.com/axion9
Image
User avatar
Axion
Major General
Posts: 683
Joined: Mon Sep 29, 2003 5:14 am
Location: Northern California
Contact:

Post by Axion »

Bjarne BZR wrote: Oh, and changing level.targets_to_destroy = 1 to 2 will not help, only make the allies unable to win by blowing the bomb later,
But in your tutorial for combining multiple objective types, you said to use the exploder system's varaiable level.targets_destroyed and set the variable level.targets_to_destroy to 2, so then there would be no need to change the allies win method from the bomb tutorial.

Now I'm confused. :?
"The work of a thousand years is nothing but rubble."
- Dr. Carl Goerdeler (1943)
Visit my mapping site: http://www.freewebs.com/axion9
Image
Bjarne BZR
Site Admin
Posts: 3298
Joined: Wed Feb 05, 2003 2:04 pm
Location: Sweden
Contact:

Post by Bjarne BZR »

Axion wrote:But in your tutorial for combining multiple objective types, you said to use the exploder system's varaiable level.targets_destroyed and set the variable level.targets_to_destroy to 2, so then there would be no need to change the allies win method from the bomb tutorial.

Now I'm confused. :?
Yes, but I was in the middle of teaching GrimReaper how to do it by himself, and in the script as it was then, it was not enough to just increase the variable to 2. I was making sure that both objectives worked before taking the next step.
Admin .MAP Forums
Image
Head above heels.
User avatar
Axion
Major General
Posts: 683
Joined: Mon Sep 29, 2003 5:14 am
Location: Northern California
Contact:

Post by Axion »

Ahh. I understand now, and I'm sorry if I interrupted your lesson. :oops:
"The work of a thousand years is nothing but rubble."
- Dr. Carl Goerdeler (1943)
Visit my mapping site: http://www.freewebs.com/axion9
Image
User avatar
GrimReaper
Sergeant
Posts: 58
Joined: Tue Dec 30, 2003 5:40 am

Post by GrimReaper »

Yes it blows up.But the allies only win if they do documents...and I started a new map which doesnt make a difference so continue.
Bjarne BZR
Site Admin
Posts: 3298
Joined: Wed Feb 05, 2003 2:04 pm
Location: Sweden
Contact:

Post by Bjarne BZR »

Axion wrote:I'm sorry if I interrupted your lesson. :oops:
Dude, you were trying to help. Cant really see anything to be ashamed of :)

OK: GrandRapper:
- The bomb works, BUT it does not make the allies win.
- The docs works AND it makes the allies win.

And we have the script as it looked in your last post:

Code: Select all

// Custom objective test map
// ARCHITECTURE: GrimReaper
// SCRIPTING: GrimReaper
main:

   setcvar "g_obj_alliedtext1" "Steal the documents."
   setcvar "g_obj_alliedtext2" "- Go get them"
   setcvar "g_obj_alliedtext3" "- U know U want to"
   setcvar "g_obj_axistext1" "Prevent the allies"
   setcvar "g_obj_axistext2" "from stealing the"
   setcvar "g_obj_axistext3" "documents."

   setcvar "g_scoreboardpic" "none"

   level waittill prespawn

   // There is no OBJprecache.scr
   exec global/DMprecache.scr

   level.script = maps/obj/objtest.scr

   // m6l1a is a blowing wnind sound
  exec global/ambient.scr obj_team2
  thread global/exploder.scr::main
   
   level waittill spawn
   // Axis like the bombs unplanted 
   level.defusing_team = "axis"
   // Allies will try to plant the bombs
   level.planting_team = "allies"
   // Number of targets in this map
   level.targets_to_destroy = 1
   // Default damage of the bomb
   level.bomb_damage = 200
   // Default radius of bomb blast
   level.bomb_explosion_radius = 2048



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

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

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

   // Start the win check thread for allies
   thread desk_document_check

   // If the end of the match is reached, the Axis win
   level waittill axiswin

end // end of main

// Document checks
desk_document_check:
   while(1) { // forever
      // Dont execute past this line
      // until someone triggers the object
      $documents_trigger waittill trigger
      // parm.other is the triggerer
      if(parm.other.dmteam == allies) {
         // Make the document graphix disappear
         $documents hide
         // break out of the while loop
         break
      }
      // protection against making this
      // thread use too much CPU
      waitframe
   }
   // Make allies win the match
   teamwin allies
// end allies victory test
end
OK: First: there is no instructions on how the blowing of the bomb should make the allies win... this becaus eyou did not copy this method from the bomb tutorial:

Code: Select all

allies_win_bomb:
    // While undestroyed objectives left
   while(level.targets_destroyed < level.targets_to_destroy)
   {
       // chill out
      waitframe
   }
    // No objectives left allies win
   teamwin allies
// end allied victory test
end
... you do call the method in your script with this line

Code: Select all

thread allies_win_bomb
... but mohaa can't find it.

OK: now you should be able to blow the bomb.

Next step is to make them work together. And this is simplest done as Axion said: Because the exploder system uses the variable level.targets_destroyed to keep track of the number of exploded bombs, we can use this. Set the variable level.targets_to_destroy in your script to 2 instead of 1.

Almost there now... stealing the documents still makes the allies win immediately. So instead of using the line

Code: Select all

teamwin allies
in the desk_document_check method, replace it with

Code: Select all

level.targets_destroyed++
to increase the variables value with 1 when the allies steal it...

That should work like you want it now...
Admin .MAP Forums
Image
Head above heels.
User avatar
GrimReaper
Sergeant
Posts: 58
Joined: Tue Dec 30, 2003 5:40 am

Post by GrimReaper »

I dont idsactly know where I have to put

Code: Select all

// Allied victory test
allies_win_bomb:
	// While undestroyed objectives left
	while(level.targets_destroyed < level.targets_to_destroy)
		// chill out
		waitframe
	// No objectives left allies win
	teamwin allies
end // end allied victory test
that.I think thats what is screwing me up the most not knowing where to put the different things that are coded in your tutorials into my script.I see where it sais

Code: Select all

thread allies_win_bomb
But dont know if thats where I put this

Code: Select all

// Allied victory test
allies_win_bomb:
	// While undestroyed objectives left
	while(level.targets_destroyed < level.targets_to_destroy)
		// chill out
		waitframe
	// No objectives left allies win
	teamwin allies
end // end allied victory test
User avatar
Axion
Major General
Posts: 683
Joined: Mon Sep 29, 2003 5:14 am
Location: Northern California
Contact:

Post by Axion »

Look at the code I posted, everything is in the proper location. I've already tested that script on one of my maps that has a document and explosion objective, and it works.
"The work of a thousand years is nothing but rubble."
- Dr. Carl Goerdeler (1943)
Visit my mapping site: http://www.freewebs.com/axion9
Image
Bjarne BZR
Site Admin
Posts: 3298
Joined: Wed Feb 05, 2003 2:04 pm
Location: Sweden
Contact:

Post by Bjarne BZR »

Everything starting with any_name: and ending with end is a method, a separate block of code that you can call from other locations. If you look at any scipt you will see at least one such method: the main: method. Mohaa calls the main method to execute your script. so to insert a new method ( like this allies_win_bomb: ), just put it after the last end in your script.

And read up on scripting in general here.
Admin .MAP Forums
Image
Head above heels.
User avatar
GrimReaper
Sergeant
Posts: 58
Joined: Tue Dec 30, 2003 5:40 am

Post by GrimReaper »

Alright,sry it took me so long to reply but I started to make a new map because my old one was way wrong:P.But anyways it all works thanks everyone!
Post Reply