Random Location Objectives

Post your scripting questions / solutions here

Moderator: Moderators

AIC
Private
Posts: 4
Joined: Mon Jul 01, 2002 3:07 pm
Location: Almere, The Netherlands
Contact:

Random Location Objectives

Post by AIC »

I want to create a random location objective (Like The Hunt) but I don't understand the script of it

Code: Select all

flak88_random_setup local.explosive local.weapon local.point_at local.base local.number_of_locations:

	local.location = ((randomint (local.number_of_locations)) + 1)

	local.trigger_offset = self.origin - local.base.origin 
	local.weapon_offset = local.weapon.origin - local.base.origin 
	local.explosive_offset = local.explosive.origin - local.base.origin 
	local.point_at_offset = local.point_at.origin - local.base.origin 

	local.location = $("flak88_location" + local.location)
	local.base.origin = local.location.origin


	self.origin 		= local.trigger_offset 		+ local.base.origin 
	local.weapon.origin 	= local.weapon_offset 		+ local.base.origin 
	local.explosive.origin 	= local.explosive_offset 	+ local.base.origin 
	local.point_at.origin 	= local.point_at_offset 	+ local.base.origin 

	local.weapon setaimtarget local.point_at
end
Where are the coordinates of the weapon specified??? (not in the map self)in local.number_of_locations (is is some sort of array???)

grtz,

AIC
jv_map
Site Admin
Posts: 6521
Joined: Tue Sep 03, 2002 2:53 pm
Location: The Netherlands
Contact:

Post by jv_map »

The coordinates are in the map itself, I think it uses script_origins with targetnames of 'flak88_location1' up to 'flak88_location<number_of_locations>'.
Last edited by jv_map on Fri Mar 07, 2003 10:03 pm, edited 1 time in total.
Image
Bjarne BZR
Site Admin
Posts: 3298
Joined: Wed Feb 05, 2003 2:04 pm
Location: Sweden
Contact:

Post by Bjarne BZR »

Yep, that

Code: Select all

local.location = $("flak88_location" + local.location)
sure looks like a cast from a string to a variable name...

In this case flak88_location1 to flak88_location4
as dictated by the thread start call:

Code: Select all

$flak88_weapon1_trigger thread flak88_random_setup $flak88_weapon1_explosive $flak88_weapon1 $flak88_target $flak88_base1 4
in the main metod.... ( the 4 at the end is transferred to the local.number_of_locations in your code below ( I ment above... it is below when U write the post :D ) )
Admin .MAP Forums
Image
Head above heels.
jv_map
Site Admin
Posts: 6521
Joined: Tue Sep 03, 2002 2:53 pm
Location: The Netherlands
Contact:

Post by jv_map »

Bjarne BZR wrote:Yep, that

Code: Select all

local.location = $("flak88_location" + local.location)
sure looks like a cast from a string to a variable name...
It's a cast from an integer (local.location) to a string ("flakk88_location" + local.location) to an entity ($). :wink:

Ugly they re-used local.location for an integer and an entity :?
Image
Bjarne BZR
Site Admin
Posts: 3298
Joined: Wed Feb 05, 2003 2:04 pm
Location: Sweden
Contact:

Post by Bjarne BZR »

I COULD get into an argumet here jv, but as I have only theories and no facts to base my arguments on... it would probably de-generate into a very theoretical programming language theory debate ( that I would most certainly loose ). :wink:

So lets get to the core of the poodle ( how strange is that expression? )... did that help, AIC?


( The integer is propagated to a string, the 2 strings are merged, the result is cast into a variable name, and the name is hashed, and the resulting value is used as an index into a reference table, and the reference points to the entity ) Ooops..... :D
Admin .MAP Forums
Image
Head above heels.
Random
Moderator
Posts: 401
Joined: Sun Jun 01, 2003 11:00 pm

Post by Random »

Fellas i hate to dig out an old thread but i tried the search and didnt find anything that help me out.

Ok here is what im trying to do:

throughout the map there are hidden wallsafes in the safes are documents that need to be stolen. What i would like is to have the documents move randomly from safe to safe. I tried to use the hunt flak script as a basis for what im trying to do but cant seem to get it. If anyone could help explain what im lookin at there and tell me what is relavant and what is i would be most appreciative.

THank You for the help
Random
Bjarne BZR
Site Admin
Posts: 3298
Joined: Wed Feb 05, 2003 2:04 pm
Location: Sweden
Contact:

Post by Bjarne BZR »

Its hard to tell you what you are doing wrong when we dont know what you are doing... I suggest you post your complete scrit as it looks now, along with a brief explanation of what you think the code should acomplish... then we can probably tell you whats wrong with it.

/B man
Admin .MAP Forums
Image
Head above heels.
Random
Moderator
Posts: 401
Joined: Sun Jun 01, 2003 11:00 pm

Post by Random »

ok sorry to do this to ya but i scraped that over the last couple of hours so that i can tackle another problem. Maybe i should ask about the simple stuff first and go from there.

The problem i am having is that everything works fine in the first round in testing. After that round is over and the next one begins the documents are missing. To be exact the round starts off with the documents already taken by the attacking team while they are still at spawn. Just to check i went to the safe and they werent there but i can still set the bomb and end the round. Here is an example of the scr file i got going so far:

Code: Select all


//----------------------------------------------------------------

level waittill prespawn

exec global/DMprecache.scr
exec global/door_locked.scr::lock
exec global/ambient.scr Watten

thread global/exploder.scr::main
thread global/minefield.scr::minefield_setup

level.script = maps/obj/Watten.scr 


//----------------------------------------------------------------

level waittill spawn

level.bomb_damage = 200
level.bomb_explosion_radius = 2048
level.defusing_team = "allies"
level.planting_team = "axis"
level.targets_to_destroy = 1
level.stealers = "axis"
level.docs_toget = 2
level.docs_taken = 0
level.dmrespawning = 0 // 1 is respawn 0 is norespawn. 
level.dmroundlimit = 5 // round time limit in minutes
level.clockside = allies // set to axis, allies, kills, or draw


//-----------------------------------------------------------------

level waittill roundstart

$church_bomb thread global/obj_dm.scr::bomb_thinker
$church_bomb thread allies_win_timer

thread axis_win_bomb 
thread allies_win_timer

thread gotdocs1
thread gotdocs2

end

//-----------------------------------------------------------------

gotdocs1:
local.player = parm.other
if (local.player.dmteam == level.stealers)
{
$obj_docs1_trigger nottriggerable
$obj_docs1 remove
level.docs_taken = ( level.docs_taken + 1 )
iprintln_noloc "The Axis have taken the documents!"
thread AxisWin_Check
}
end
end

gotdocs2:
local.player = parm.other
if (local.player.dmteam == level.stealers)
{
$obj_docs2_trigger nottriggerable
$obj_docs2 remove
level.docs_taken = ( level.docs_taken + 1 )
iprintln_noloc "The Axis have taken the documents!"
thread AxisWin_Check
}
end
end

//-----------------------------------------------------------------

allies_win_timer:

	level waittill allieswin

end

//-----------------------------------------------------------------

axis_win_bomb:

	if(level.targets_destroyed == level.targets_to_destroy && level.docs_taken == 2)
		{
		teamwin axis

		end
		}
	wait .1
	goto axis_win_bomb

end




Oh and it may also be important to know that when i go in solo it will still allow me to steal the documents when it shouldnt. cant figure that out either since the thread isnt called for until round start (well its not supposed to anyways)

Most of what i know about scripting is from tuts and other maps i dig through so maybe the problem is that im not stikin to form, you know mixin and matchin ideas and maybe jsut maybe that aint such a good idea.

Anyhow i guess i better get everything else workin before i try to get the documents to float around.

THank YOu
jv_map
Site Admin
Posts: 6521
Joined: Tue Sep 03, 2002 2:53 pm
Location: The Netherlands
Contact:

Post by jv_map »

local.player = parm.other :?

Is the gotdocs1 thread by any change executed by a trigger (i.e. with a setthread key)?

Oh and one 'end' per thread should suffice :wink:
Image
Random
Moderator
Posts: 401
Joined: Sun Jun 01, 2003 11:00 pm

Post by Random »

DOh didnt notice the end end thing.

Also yeah there is a trigger with a setthread involved. This is my first scripting effort so i thank you Master Scripters for your help.

And is parm other supposed to be the document takers instead?

PS would really appreciate a good comprehensive scripting tut. Trying to learn by looking at what others did doesnt really tell me what i need to know.

Thank You
Bjarne BZR
Site Admin
Posts: 3298
Joined: Wed Feb 05, 2003 2:04 pm
Location: Sweden
Contact:

Post by Bjarne BZR »

Random wrote:PS would really appreciate a good comprehensive scripting tut. Trying to learn by looking at what others did doesnt really tell me what i need to know.
Here is my MOHAA scripting language tutorial. 8)
Admin .MAP Forums
Image
Head above heels.
Bjarne BZR
Site Admin
Posts: 3298
Joined: Wed Feb 05, 2003 2:04 pm
Location: Sweden
Contact:

Post by Bjarne BZR »

You call allies_win_timer twice ( once is enough? )...

axis_win_bomb looks strange, I would write it like this instead:

Code: Select all

axis_win_bomb:
  while( level.targets_destroyed < level.targets_to_destroy && level.docs_taken < level.docs_toget )
  {
    waitframe
  }
  teamwin axis 
end
And just an idea ( not sure about this ): In my document theft tutorial I use $documents hide instead of $documents remove... dont think it will make a difference, but I guess you'll try anything, right? :wink:

And by the way: where is the Randomization code?
Admin .MAP Forums
Image
Head above heels.
jv_map
Site Admin
Posts: 6521
Joined: Tue Sep 03, 2002 2:53 pm
Location: The Netherlands
Contact:

Post by jv_map »

In case the gotdocs threads are started by a trigger, I think it's best to remove these lines:
thread gotdocs1
thread gotdocs2
You don't have to start them manually since the trigger does it for you.

At the start make the trigger nottriggerable, then after level waittill roundstart make it triggerable. This way you can't fetch the docs if you are alone.

Also I can't seem to find the AxisWin_Check thread :?
Image
Random
Moderator
Posts: 401
Joined: Sun Jun 01, 2003 11:00 pm

Post by Random »

Good sirs thank you for your help and would you believe Bjarne BZR that i saw your comprehensive explanation of scripting language moments after i wrote last post and forgot to edit. I will take your suggestions and give them a go as well as try to read the manual to understand why it didnt work.

Seriosly though thanks guys cant wait to get this done. If you havent already seen it which im sure you may not have here is some screenshots to what im trying to script this for. http://www.angelfire.com/hero/st6_skins/index.html

Hope you enjoy the pics and thanks again for the info hopefully you wont hear from me for a couple of days til i get this figured out.

THank YOu

ok so no Axis win check thread i thought i saw that in console everytime i pic up a document. So i renamed axis_win_bomb to AxisWin_check but that didnt help.

Ok win timer 2 times huh... im guessin 2 times isnt better than once?? :roll:

and no need to call for thread since it is trigered by target names by the map..............
Again thanks for the insite you guys are awesome
Bjarne BZR
Site Admin
Posts: 3298
Joined: Wed Feb 05, 2003 2:04 pm
Location: Sweden
Contact:

Post by Bjarne BZR »

NICE pictures! Cant wait to take that map for a spin...
Good work!
Admin .MAP Forums
Image
Head above heels.
Post Reply