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

Members Online

»
0 Active | 9 Guests
Online:

LATEST FORUM THREADS

»
warfare
CoD4 Map + Mod Releases
Voting menu on maps
CoD+UO General
Hauling 911
CoDBO3 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 MP Mapping
CoD 2 mapping and level design.
Moderators: foyleman, Foxhound, Mystic, StrYdeR, batistablr, Welshy, DrBiggzz, supersword, playername
Latest Posts
Subscribed Posts
Search
Restricted Access Topic is Locked subscribe
Author Topic: Shooting Range System, how to score and award points to players
WHC_Grassy
General Member
Since: Apr 20, 2005
Posts: 1426
Last: Aug 25, 2007
[view latest posts]
Level 8
Category: CoD2 MP Mapping
Posted: Wednesday, Jan. 10, 2007 08:03 am
Well it turned out to be pretty simple.
Note: I tested this out in Cod/UO and it works fine.

This is in response to another thread on how to detect and award points to players as in a shooting range for eg;

In this example there are only two targets, to add others just replicate them and give them unique targetnames for each one and add another section in the script for them.

Firstly in the editor (mapping stage)
On the target make a small box about 8x8 and texture with origin.
Then make a larger box the same size as you target area and just proud of the front of the target and texture this with trigger.

Select BOTH these new brushes and right click 2D window and select trigger_damage, give it a targetname of dist_trig (this is your distant one right?) :) and tick off explosion,splash,melee,flame as they are not usefull for a rifle range.

Now on the baseline where your player should be standing make another trigger the same way you made the trigger_damage on the target but this time make it a trigger_multiple.
No need to give it a targname just yet.

Once you have those two triggers correct, deselect everything and then shift+left click on the target trigger (just select the larger box) then do the same for the player trigger (select outer box) and hit Ctrl+K to make the target trigger point to the player trigger.
You should see a red line running from the small inner box on the target trigger to the small inner box on the player trigger.

You will notice that the player trigger just made it's own targetname, if it didn't check your editor setup.


For any other targets you do exactly the same as the first.
In this example script the second target is called close_trig.
For each target you MUST have a corresponding trigger where the player should be standing (this is important to detect who hit the target and who should get the points) and that trigger MUST be targeted from the trigger on the target in your rifle range.

Ok here is the script for two targets.
There are comments in the script to show the important things you need to know.

Enjoy!
Grassy

Code:
main()
{
	thread init_targets();
	
}
		

init_targets()
{

	closetrig = getent ("close_trig", "targetname");
	if(!isDefined(closetrig))
   return;

	disttrig = getent ("dist_trig", "targetname");
	if(!isDefined(disttrig))
   return;

	disttrig thread watchdist();
	closetrig thread watchclose();
	
}


watchdist()
{

	if (isdefined (self.target))
		ent = getent (self.target,"targetname");
	else
		return;

	//Set amount of points awarded on hitting this target
	points = 2;
	
	while(1)
	{
		self waittill("trigger",other);

		//This is a visual to see the trigger hits
		//Comment it out when not needed anymore
		iprintln("Trigger was hit by ",other.name);

		//The person who shot the target must be in this trigger
		if(other istouching(ent) && isAlive(other) && other.sessionstate != "spectator")
			other.score += points;
	}
}


watchclose()
{
	if (isdefined (self.target))
		ent = getent (self.target,"targetname");
	else
		return;

	//Set amount of points awarded on hitting this target
	points = 1;
	
	while(1)
	{
		self waittill("trigger",other);

		//This is a visual to see the trigger hits
		//Comment it out when not needed anymore
		iprintln("Trigger was hit by ",other.name);

		//The person who shot the target must be in this trigger
		if(other istouching(ent) && isAlive(other) && other.sessionstate != "spectator")
			other.score += points;
	}
}
	



Woops almost forgot, you can add a "wait" key on each trigger_damage to speed it up, I used 0.1 for a quick response for rapid fire, otherwise every second shot is not detected.
Grassy

edited on Jan. 10, 2007 03:07 am by WHC_Grassy

LOL I just thought I had better add some extra error checking, in case the targeted triggers are not found.


edited on Jan. 10, 2007 03:10 am by WHC_Grassy
Share |
cybershot
General Member
Since: Dec 29, 2005
Posts: 944
Last: Mar 4, 2018
[view latest posts]
Level 7
Category: CoD2 MP Mapping
Posted: Thursday, Jan. 11, 2007 07:31 am
three things. first.. thanks for doing this work. i do plan on using this in a map right now. second. how did you figure this out so fast. are you a programmer or what. third. when i hit the target. will it collaps
Share |
WHC_Grassy
General Member
Since: Apr 20, 2005
Posts: 1426
Last: Aug 25, 2007
[view latest posts]
Level 8
Category: CoD2 MP Mapping
Posted: Thursday, Jan. 11, 2007 10:19 am
Thanks cybershot, glad you can make use of it.

1)I have been mucking about with map editors and scripts since Medal of Honor Allied Assault days, LOL and I like to experiment with what can be done and can't.
2)No I'm not a programmer as such but do have a good grasp of the scripting language, and still learning all the time.
3) No the targets don't collapse, this script is just the basics for detecting hits and who it was that hit the triggers.
You can greatly expand on this for a complete map that has moving targets, targets that blow up, targets in a grenade tossing range, anti tank targets, etc etc, the skys the limit.
All you need to do is specify on the triggers what type of damage it will detect for the different weapons.

For targets that move, ie; side to side you will need to make the target a script_brushmodel and link the trigger to it so it moves with it.

To do this the commands are enablelinkto(); and linkto();
Lets say your moving target model is movingtarget

target = getent("movingtarget","targetname");
trig = getent("triggername","targetname");
trig enablelinkto();
trig linkto(target);

Then the rest of your script will deal with the movements of the script_brushmodel only, the trigger should move with it.

Hope this helps you somewhat, feel free to give a yell if you need more help.

Grassy
Share |
raver
General Member
Since: Mar 22, 2005
Posts: 5
Last: Mar 5, 2007
[view latest posts]
Level 0
Category: CoD2 MP Mapping
Posted: Monday, Mar. 5, 2007 11:21 am
Thanx for the tut grassy. Good stuff!
I made A map with a moving target that, when you shoot it, rotates and awards you 1 point for hitting hit.

Now when I hit the trigger it awards the points just fine!
problem is...my trigger doen't follow the target.
[banghead]
Im working on this for weeks now and just don't get what I am doing wrong....maybe you see anything wrong with my code:

main()
{
thread targetstuff();
}

targetstuff()
{
{
target1 = getent ("target1","targetname");
ent = getent("trigger1","targetname");
ent enablelinkto();
ent linkto (target1);
target1 thread move();
ent thread target_hit1();
ent thread targetscore1();
}
}
targetscore1()
{

if (isdefined (self.target))
ent = getent (self.target,"targetname");
else
return;

//Set amount of points awarded on hitting this target
points = 1;

while(1)
{
self waittill("trigger",other);

//The person who shot the target must be in this trigger
if(other istouching(ent) && isAlive(other) && other.sessionstate != "spectator")
{
other.score += points;

iprintln("Target was hit by ",other.name + " ^7at ^350 ^7Feet");

players = getentarray("player", "classname");
for(i = 0; i < players.size; i++)
{
players iprintln("Scored 1 point");
}
}
}
}

move()
{
while (1)
{
wait (randomint(8));
self movey( -724,(randomint(3)+4));
self waittill("movedone");
self movez( 56, 1);
self waittill("movedone");
self movey( 724,(randomint(3)+4));
self waittill("movedone");
self movez( -56, 1);
self waittill("movedone");
}
wait .05;
}

target_hit1()
{
while(1)
{
target1 = getent("target1","targetname");
self waittill("trigger",other);

{
target1 rotatepitch(90,.35);

wait .1;

//playsound_onplayers("bullet_hit_metal");

target1 waittill("rotatedone");

wait .2;

target1 rotatepitch( -90,.35);
target1 waittill("rotatedone");
}
}
}

this is everything. the target moves fine, also rotates when I hit the target and also if I stand in my shootingbox I get 1 point for shooting the trigger!...everything works except for the part where the trigger should follow the target around.
could this be something I'm doing wrong with the mapping part?....thnx for feedback!
Share |
Restricted Access Topic is Locked subscribe
MODSonline.com Forums : Call of Duty 2 : CoD2 MP Mapping

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

»