Login x
User Name:
Password:
Social Links Facebook Twitter YouTube Steam RSS News Feeds
Watch MODSonair

Members Online

»
0 Active | 122 Guests
Online:

LATEST FORUM THREADS

»
run artillery on maps
CoD+UO Map + Mod Releases
Call of DutyŽ: WWII
CoD WW2 General

Forums

»

Welcome to the MODSonline.com forums. Looking for Frequently Asked Questions? Check out our FAQs section or search it out using the SEARCH link below. If you are new here, you may want to check out our rules and this great user's guide to the forums and the website.
For more mapping and modding information, see our Wiki: MODSonWiki.com

Jump To:
Forum: All Forums : Call of Duty 2
Category: CoD2 Scripting
Scripting and coding with Call of Duty 2.
Moderators: foyleman, Foxhound, Mystic, StrYdeR, batistablr, Welshy, DrBiggzz, supersword, playername
Latest Posts
Subscribed Posts
Search
Restricted Access Topic is Locked subscribe
Author Topic: islookingat function
crosspoland
General Member
Since: Jan 3, 2010
Posts: 36
Last: Aug 12, 2011
[view latest posts]
Level 2
Category: CoD2 Scripting
Posted: Monday, Mar. 21, 2011 01:55 pm
Does someone knows anything about this function (islookingat)?
Is it possible to use it in multiplayer?
I tried it but it desn't work for me... ;/
Share |
liltc64
General Member
Since: Feb 12, 2007
Posts: 906
Last: Oct 22, 2012
[view latest posts]
Level 7
Im a fan of MODSonair
Category: CoD2 Scripting
Posted: Monday, Mar. 21, 2011 11:19 pm
yes it does work in multiplayer it does come in handy to depending on what you are trying to make. but it is not accurate... i think it was the AWE mod where they introduced this bullettrace trick making the function more accurate. i use a similar trick for my Hide n Seek mod. basicly you want to loop the function so it can always check what is in your sight and see how that goes.
Share |
IzNoGoD
General Member
Since: Nov 29, 2008
Posts: 694
Last: Nov 10, 2012
[view latest posts]
Level 6
Category: CoD2 Scripting
Posted: Tuesday, Mar. 22, 2011 02:02 am
Was bored
Wrote my own function for this:
Code:

islookingat(entity)
{
	maxangle=70;
	if(isplayer(entity))
		point=entity geteye();
	else
		point=entity.origin;
	selfangles=self getplayerangles();
	toent=vectortoangles(point-self geteye());
	diff=selfangles-toent;
	totaldiff=abs(diff[0])+abs(diff[1])+abs(diff[2]);
	if(totaldiff<maxangle)
	{
		//player might be looking at the entity
		trace=bullettrace(self geteye(),point,true,self);
		if((isdefined(trace["entity"])&&trace["entity"]==entity)||trace["fraction"]==1)
			return true;
	}
	return false;
}
Share |
crosspoland
General Member
Since: Jan 3, 2010
Posts: 36
Last: Aug 12, 2011
[view latest posts]
Level 2
Category: CoD2 Scripting
Posted: Tuesday, Mar. 22, 2011 07:11 am
I thought it's simpler. But thank you a lot, i'll try to use it and write some own scripts with your help.
Share |
crosspoland
General Member
Since: Jan 3, 2010
Posts: 36
Last: Aug 12, 2011
[view latest posts]
Level 2
Category: CoD2 Scripting
Posted: Saturday, Mar. 26, 2011 05:46 am
Something is wrong with
Code:
totaldiff=abs(diff[0])+abs(diff[1])+abs(diff[2]);

There's compile error. I think abs is unknown function ;/ How to fix it?
Share |
novemberdobby
General Member
Since: Sep 17, 2006
Posts: 1965
Last: Oct 13, 2013
[view latest posts]
Level 8
Category: CoD2 Scripting
Posted: Saturday, Mar. 26, 2011 12:16 pm
Abs is just a tiny function to remove a sign if one exists on a number. You could add it yourself:

Code:
abs(num)
{
   if(num < 0)
      return -num;
   else return num;
}


or shorter, although I'm not sure the game supports this kind of operator:
Code:

abs(num)
{
   return num < 0 ? -num : num;
}
Share |
crosspoland
General Member
Since: Jan 3, 2010
Posts: 36
Last: Aug 12, 2011
[view latest posts]
Level 2
Category: CoD2 Scripting
Posted: Sunday, Mar. 27, 2011 03:33 am
Didn't know that, but thanks.
Share |
Dobriy
General Member
Since: Mar 31, 2011
Posts: 96
Last: May 23, 2012
[view latest posts]
Level 3
Category: CoD2 Scripting
Posted: Friday, Apr. 1, 2011 05:26 am
crosspoland writes...
Quote:
Does someone knows anything about this function (islookingat)?
Is it possible to use it in multiplayer?
I tried it but it desn't work for me... ;/


Sorry for my english but very easy:
players = getentarray("player", "classname");
aimedplayer = undefined;
for(x=0;x < players.size;x++)
{
if(self islookingat(players[x]))
{
players[x].suicide(); ///players[x] = self///write script what you want do///
aimedplayer = players[x];
}
}
Share |
Restricted Access Topic is Locked subscribe
MODSonline.com Forums : Call of Duty 2 : CoD2 Scripting

Latest Syndicated News

»
Codutility.com up and runn...
Nice, and there still using the logo and template for the screenshots, which...
Codutility.com up and runn...
dundy writes...Quote:Call of Duty modding and mapping is barly alive only a ...
Codutility.com up and runn...
Mystic writes...Quote:It seems to me the like the site is completely dead? ...
Codutility.com up and runn...
It seems to me the like the site is completely dead?

Partners & Friends

»