A binocular scouting idea!

Post your scripting questions / solutions here

Moderator: Moderators

Cool idea?

Yea! Wicked!
6
67%
No! Sucks!
2
22%
Well, sounds OK... but what use is it? Why bother?
1
11%
 
Total votes: 9

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

A binocular scouting idea!

Post by Bjarne BZR »

I noticed there is an entry in the consol after pressing the firebutton while using the binoculars:

Code: Select all

^~^~^ Could not find label 'clickitem_fail' in 'maps/obj/obj_vemork_approach.scr'
...I'm thinking this could be used as a scouting utility in an MP map... like this:

- You spawn far ahead of the others.
- You have a Shotgun ( Useless over long distances ).
- You find a nice hidden spot and whip out your binoculars.
- When you see an enemy you click "fire" and if you "hit" him, a red light is lit above his head to alert others of the enemy location.
- The red light goes out after... say 10 seconds...

A way for a scout ro report an enemy to his team :twisted:

Can this be done? You can use the "sighttrace" command. And one of the debug modes in the jv_bots turn on colored lights on the bots according to their respective current tasks... So... again... can it be done?
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 »

I think it can be done :wink:
Image
Bjarne BZR
Site Admin
Posts: 3298
Joined: Wed Feb 05, 2003 2:04 pm
Location: Sweden
Contact:

Post by Bjarne BZR »

Yes! I thougt it would be :)

So, as I am a scripting n00b: How do I tell if a triggerer is "aiming" at a player?
The only thing I know how to get out as a parameter is the triggerer ( the one with the binoculars ). Any insights there jv?
And will other labels be called besides "clickitem_fail"?
Admin .MAP Forums
Image
Head above heels.
SlasherZ
Colonel
Posts: 433
Joined: Fri Jul 11, 2003 12:55 pm
Contact:

Post by SlasherZ »

sounds like class based
jv_map
Site Admin
Posts: 6521
Joined: Tue Sep 03, 2002 2:53 pm
Location: The Netherlands
Contact:

Post by jv_map »

Hmm well good question... Just have to try a bit I think. Maybe it's the self of the clickitem_fail thread.. :? You can also try parm.other or find a player that's holding fire with $player[#].fireheld (not very bug proof :().

Oh btw you're not a scripting n00b, remember you wrote a scripting tut :wink:
Image
jv_map
Site Admin
Posts: 6521
Joined: Tue Sep 03, 2002 2:53 pm
Location: The Netherlands
Contact:

Post by jv_map »

Oh wait I think I misread your post :oops:

You want to find out the guys who's being aimed at right? Well, you can try a dotvec with the viewangles from the 'aimer' and the actual vector from the aimer to a potential target.

Something like (assuming self is 'spotter'):

Code: Select all

for(local.i = 1; local.i <= $player.size; local.i++)
{
  local.player = $player[local.i]
  if(local.player != self)
  {
    // find out the vector from spotter to player
    // roughly the eye position when standing :?
    local.vec = local.player.origin - (self.origin + (0 0 80))
    local.normal_vec = vector_normalize local.vec
    // convert viewangles to a normalized vector
    local.viewvec = angles_toforward self.viewangles
    local.dotvec = local.normal_vec * local.viewvec
    if(local.dotvec >= 0.95) // almost at target
    {
      local.target = local.player
      break
    }
  }
}
Thank a nice guy up there you have a degree in vector maths :)
Image
User avatar
bdbodger
Moderator
Posts: 2596
Joined: Tue Feb 25, 2003 7:34 am
Location: canada
Contact:

Post by bdbodger »

There is a trigger_clickitem . I guess what you could do is spawn a trigger_clickitem and bind it to the players or things you what to use a trigger on then use its origin in a thread but I don't know how that might work in a multuplayer game I mean how does the game know who used the binoculars, parm.other maybe ,but now how do you tell which player has been clicked on hmm maybe spawn the light above the trigger_clickitem and then bind it to the trigger since it is already bound to the player .
Bjarne BZR
Site Admin
Posts: 3298
Joined: Wed Feb 05, 2003 2:04 pm
Location: Sweden
Contact:

Post by Bjarne BZR »

MOHAHAHA!

Check it:

Code: Select all

clickitem_fail:
	iprintlnbold_noloc "Binocular fire!"
	for(local.i = 1; local.i <= $player.size; local.i++) {
		local.player = $player[local.i]
		println local.i local.player
		if( local.player != parm.other ) {
    		// find out the vector from spotter to player 
    		// roughly the eye position when standing :? 
			local.vec = local.player.origin - (self.origin + (0 0 80))
			println "Binocular vector " local.vec
			local.normal_vec = vector_normalize local.vec
			println "Binocular normal " local.normal_vec
			// convert viewangles to a normalized vector
			local.viewvec = angles_toforward self.viewangles
			println "Binocular view v " local.normal_vec
			local.dotvec = local.normal_vec * local.viewvec
			println "Binocular dot " local.normal_vec
			if(local.dotvec >= 0.95) { // almost at target
				println "Binocular target " local.player
				local.player thread light_up
				break
			}
		}
	}
end

light_up:
	self light 1.0 0.0 0.0 200
	self iprint "You have been sighted by an enemy scout!"
	self lightOn
	wait 10
	self lightOff
end
Anyone can just add that script last in their MP script file. The label "clickitem_fail" will automatically be called when user presses fire with the binoculars up :)

I havent tried it on an MP server yet, but the light_up works.

JV... wouldnt this make you able to "sight" a player even if the player cant be seen? Shouldent a sighttrace of some sort be performed to determin that the player can actually see his enemy? How is this determined in your bots? I mean, a sighttrace from head to head is useless if you can only see the enemys arm, am I right? ( I really dont know how a sighttrace works :? )
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 »

jv_map wrote:Oh btw you're not a scripting n00b, remember you wrote a scripting tut :wink:
You have a point there, I CAN script, It's just that I cant seem to find all these wonderful commands that you whip out time and time again... like angles_toforward ( I know its in the documentation, but you actually use them to :wink: )
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 »

Oh yeah forgot all about the sighttrace :oops:

Well I know this way works (assuming you have a farplane):

Code: Select all

local.fwd_vec = angles_toforward self.viewangles
local.start = self gettagposition "Bip01 Head"
local.hit_location = trace (local.start + local.fwd_vec * 64) (local.start + local.fwd_vec * $world.farplane) 0
local.ent = spawn script_origin origin local.hit_location
for(local.i = 1; local.i <= $player.size; local.i++)
{
  local.player = $player[local.i]
  if(local.player != self)
  {
    if(local.ent isTouching local.player)
    {
      // spawn a fancy light 8)
      break
    }
  }
}
local.ent immediateremove // do it! do it now! :)
I'd be the last to say this is a very good way though. First of all the tagposition isn't the actual player camera position. You can also try the 'eyes bone' tag but that one doesn't seem a lot better. Weirdest of all is that the origin tag seems to be at a different place when you're in 3d person view :? :? :?

Anyway, another flaw is the following: (local.start + local.fwd_vec * 64)
I think this is necessary to prevent the trace from failing for the player's bounding box. It however does mean you may be able to spot other players through walls if you're standing close enough :(

Finally I don't think you'll be able to spot players through windows.

After all the method with a trigger_clickitem may be better :?
Image
Bjarne BZR
Site Admin
Posts: 3298
Joined: Wed Feb 05, 2003 2:04 pm
Location: Sweden
Contact:

Post by Bjarne BZR »

Looking promising, but as I'm a very visual guy, I'd like to visualize the vectors drawing them out with a colored line or someting ( drawn in 3D space ), how do I do that JV? I've seen it in your wonderful bot debug mode... or was that a buildt in MOH:AA feature?

Im going for JV's version,. as I have no idea about the triggers that bdbodger talk about... :(
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 »

Ha ha! It works like a charm!

This:

Code: Select all

clickitem_fail:
	local.fwd_vec = angles_toforward self.viewangles
	local.start = self gettagposition "Bip01 Head"
	local.hit_location = trace (local.start + local.fwd_vec * 64) (local.start + local.fwd_vec * $world.farplane) 0
	local.ent = spawn script_origin origin local.hit_location
	if ( $player.size > 1 ) {
		for(local.i = 1; local.i <= $player.size; local.i++) {
			local.player = $player[local.i]
			if(local.player != param.other) {
				if(local.ent isTouching local.player) {
					// fancy schmanzy light coming up 8)
					local.player thread light_up
					break
				}
			}
		}
	}
	local.ent immediateremove // do it! do it now! :) 
end

light_up:
	self light 1.0 0.0 0.0 200
	self iprint "You have been sighted by an enemy scout!"
	self lightOn
	wait 10
	self lightOff
end
...BIG thanx jv, this is going to be a fun feature ( practically useless, but on the other hand: rather harmless ). Thanx! :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:Looking promising, but as I'm a very visual guy, I'd like to visualize the vectors drawing them out with a colored line or someting ( drawn in 3D space ), how do I do that JV? I've seen it in your wonderful bot debug mode... or was that a buildt in MOH:AA feature?
Well that was a built-in mohaa feature, but you can visualize your vectors with a func_beam (very insightful :)).

Example, for a vector from (0 0 0) to (10 10 10):

Code: Select all

local.beam = spawn func_beam origin (0 0 0) endpoint (10 10 10) maxoffset 0
local.beam doActivate
You can set a color too, for example a red beam would be:
local.beam color (1 0 0)

A very quick and dirty way to make the beams disappear after a while so that you don't get a no free edicts error is the following:
local.beam commanddelay 0.5 remove

which will remove the beam after half a second.
Image
User avatar
Alcoholic
General
Posts: 1470
Joined: Sat May 17, 2003 5:57 am
Location: California
Contact:

Post by Alcoholic »

what does normalizing vectors do? also, what about converting vectors to angles? i mean, a vector is like 2 8 64, and an angle could also be, 2 8 64, so why do you use vector_toangles?
nuggets
General
Posts: 1006
Joined: Fri Feb 28, 2003 2:57 am
Location: U-england-K (england in the UK) :P
Contact:

Post by nuggets »

angles are vectored when the objects needs a position to move to,

falling things, moving things etc...
hope this helps, prob not cos it's all foreign 2 me :-/
Post Reply