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

Members Online

»
1 Active | 58 Guests
Online:

LATEST FORUM THREADS

»
CoD: Battle Royale
CoD+UO Map + Mod Releases
Damaged .pk3's
CoD Mapping
heli to attack ai
CoD4 SP Mapping

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
Page
Next Page
subscribe
Author Topic: Hurting player with vehcile
viraj_mantri
General Member
Since: Nov 15, 2006
Posts: 66
Last: May 16, 2007
[view latest posts]
Level 3
Category: CoD2 Scripting
Posted: Monday, Jan. 8, 2007 05:54 am
hi,i want my player to get hurt or killed when he come across the speedy vehc.i tried by applying some textures like hurt and kill to a brush & placing them in front of vech and giving them some movements but the problem is my textures wont move along with vehc.
how can i get my player hurted by moving vehc.pls help
is that so the textures are restricted to move???

edited on Jan. 8, 2007 12:57 am by viraj_mantri
Share |
All-Killer
General Member
Since: May 26, 2006
Posts: 140
Last: Nov 23, 2008
[view latest posts]
Level 4
Category: CoD2 Scripting
Posted: Monday, Jan. 8, 2007 09:51 am
Link the trigger to the car. Than it moves with the car

Code:

move_trig enablelinkto(); // This is the most important part of the script. this allows you to move the trigger. 
move_trig linkto(car); 


edited on Jan. 8, 2007 04:53 am by All-Killer
Share |
Spikenaylor
General Member
Since: Oct 12, 2004
Posts: 163
Last: Feb 22, 2009
[view latest posts]
Level 4
Category: CoD2 Scripting
Posted: Sunday, Jan. 21, 2007 09:56 pm
I am trying the same thing.

I am using the script to spawn the truck and move it, and am using a brushmodel array of clips to act as the clips.

I can succesfully move the entire lot where I wish, but I cannot succesfully move a trigger_hurt and get it to hurt a player.

The trigger hurt entity is linked to the spawned truck, but nothing happens.

I cannot link it to the array, cause it won't allow me.

How can I solve this.

Share |
FlesyM
General Member
Since: Jul 24, 2005
Posts: 399
Last: Jan 24, 2008
[view latest posts]
Level 5
Category: CoD2 Scripting
Posted: Tuesday, Jan. 23, 2007 12:02 am
i heard lots of time that you cannot move a trigger with a script .... so creating a trigger, and then call move() on it won't work as far as i know.... it would work if one could include the trigger into a brushmodel but that also can't be done.

so what you need is another way of detecting contact and kill a player other than a trigger .... maybe you could investigate the usage of istouching() if that works with an entity other than a trigger and either simply kill whatever player it touches (player suicide() or radiusdamage with a small radius on the player's origin). IF it works ... it'll also be one heavy script as you'll need a thread for everyplayer playing the map ... and it's tough to code as well ... so in other words: good luck.
Share |
WHC_Grassy
General Member
Since: Apr 20, 2005
Posts: 1426
Last: Aug 25, 2007
[view latest posts]
Level 8
Category: CoD2 Scripting
Posted: Tuesday, Jan. 23, 2007 12:19 am
Yeah as FlesYM says, trigger_hurt does not allow linking, even with the enablelinkto() command which is a real bummer!

I am trying the same thing with the targetrange system and having the same problem with moving triggers.
What I have yet to try is a tight loop that tracks the target model origin and update the trigger origin to match it, there will be a slight lag between model pos and trigger pos, but if the loop is pretty quick it shouldn't be a problem.

I will get back to you guys soon on how this works out.

Grassy
Share |
WHC_Grassy
General Member
Since: Apr 20, 2005
Posts: 1426
Last: Aug 25, 2007
[view latest posts]
Level 8
Category: CoD2 Scripting
Posted: Tuesday, Jan. 23, 2007 01:08 am
Success!!
Having a celebratory drink! [drink]
It was so simple I dont know why I didnt think of it ages ago.

Note this WORKS FOR ALL TRIGGERS _damage _hurt _multiple _use etc etc, BUT you must have a small origin textured brush as part of the trigger makeup for origin tracking.

//self is the trigger_hurt collected from another thread.
//model is the entity that you want the trigger hurt to follow.
//Call this thread before you start moving the model in other threads.

self thread trackpos(model);

trackpos(model)
{
while(1)
{
self.origin = model.origin;
wait(0.1);
}
}


If you want the trigger to follow just in front of a vehicle then you might need to place a script_origin there and link that to the vehicle first, then track the origin of the script_origin (which would be model is this case), that way the trigger_hurt will stay at the front of the vehicle instead of the centre origin of the vehicle.

Grassy
Share |
FlesyM
General Member
Since: Jul 24, 2005
Posts: 399
Last: Jan 24, 2008
[view latest posts]
Level 5
Category: CoD2 Scripting
Posted: Tuesday, Jan. 23, 2007 01:37 am
so basically, you are just updating the trigger's origin every 0.1 sec ? so it moves 10 times per seconds ... yeah it aint a bad idea at all ! it does take one more thread tho ...

questions:
- how do you include that origin brush within the trigger ?
Quote:
you must have a small origin textured brush as part of the trigger makeup for origin tracking.
how do you do that ?

- providing there's a origin within the trigger makeup like you said ... have you tried to simply move it using move() ? I always tought that it previously didn't work BECAUSE there was no origin....
Share |
WHC_Grassy
General Member
Since: Apr 20, 2005
Posts: 1426
Last: Aug 25, 2007
[view latest posts]
Level 8
Category: CoD2 Scripting
Posted: Tuesday, Jan. 23, 2007 01:56 am
To include the origin within a trigger, draw out your trigger to the size you want, texture it trigger. Then draw out a small box about 8x8 or 16x16 at the center of the trigger and texture with origin.
Then while the small box is still selected select the trigger(larger outer box) and right click 2d window and select trigger/trigger_hurt or _damage depending on what type of trigger you are creating.

Moving triggers.
Most triggers dont or wont respond to normal moveto() rotate() or linkto() commands but you can easily change their origins, and if the trigger is to follow something moving slowly then updating the origin of the trigger will provide a workaround movement method.

Grassy

edited on Jan. 22, 2007 08:56 pm by WHC_Grassy
Share |
viraj_mantri
General Member
Since: Nov 15, 2006
Posts: 66
Last: May 16, 2007
[view latest posts]
Level 3
Category: CoD2 Scripting
Posted: Wednesday, Jan. 24, 2007 12:54 pm
can u do me the favour,pls let me know how exactly to use that code bcoz wen i tried to add the model-name of my vehc in place of model here:
self thread trackpos(model);

trackpos(model)
{
while(1)
{
self.origin = model.origin;
wait(0.1);
}
}

it tells me that uninitialised parameter,could u pls let me know wat exactly this model mean.
with some filled up eg. in above code...pls

edited on Jan. 24, 2007 07:57 am by viraj_mantri
Share |
Spikenaylor
General Member
Since: Oct 12, 2004
Posts: 163
Last: Feb 22, 2009
[view latest posts]
Level 4
Category: CoD2 Scripting
Posted: Wednesday, Jan. 24, 2007 03:48 pm
I have managed to get it to work with just one problem detailed at the end..

You need a script_origin for the start point and the end point.

In radiant, place a script_model of the truck you are going to move at the start point origin, Do NOT rotate it it at all, leave it as it comes in radiant.

Now place your script_origin in the centre of the grill of the truck, call it something. I called it truckbumper_origin.

Now create your brush that will act as a the trigger_hurt in the area of hurting, Ie just in front of the truck grill. now create a brush the same dimensions as the script_origin at the same location. Selecting the two brushes, now give them a trigger_hurt entity and a targetname of something, mine being truckbumper. Now give just the smaller of these brushes a origin texture.

Now you can delete the truck model.

In Game, when you spawn this truck, it will spawn in the same direction as it started in radiant. When we link the script_origin to the truck, it and the trigger_hurt will rotate to whatever angle we then tell it to.





Compile the map and now for the scripting.

Now for the scripting.

I have also made an array of clips to clip the player from walking through the truck. My script also moves these as well. The idea being, I can then use all this to allow a player to step on the back and trigger the truck to move taking the player with him, not got there yet though.

Here is the code.

Now for the problem.

I can only make the trigger_hurt move for one pass. Ie when the truck reaches it's destination and is deleted to start again, the trigger_hurt and associated parts to not seem to restart. anyone with any ideas.



Code:
main()
{
	// Pre load the truck model.
	precachemodel ("xmodel/vehicle_opel_blitz_woodland");
	// Get the truck's start position.
	level.truckstart = getent ("testtruck1","targetname");
	// Get the Truck's end position
	level.truckend = getent ("testtruck1_finish","targetname");
	// Determine the truck's speed.
	level.speed = (100);
	// Work out the distance to travel.
	level.dist = distance(level.truckstart.origin,level.truckend.origin);
	// Work out the time it will take to move the truck.
	level.time = (level.dist / level.speed);
	// Go and do the operation.
	level thread movetruck();

}



movetruck()
{ 
while (1)
{
// Get the trigger_hurt entity.
truckbumpertrigger = getent("truckbumper", "targetname");
// get the trigger_hurt script_origin entity.
truckbumperorigin = getent("truckbumper_origin", "targetname");
wait 10;
// spawn the truck and set the model and add sound here//
truck = spawn ("script_model",(level.truckstart.origin));
truck setmodel("xmodel/vehicle_opel_blitz_woodland");
//get the speed and heading sorted//
angles =vectortoangles(level.truckend.origin - level.truckstart.origin);//this is no mistake it has to be in this order or the truck will reverse//

//Link the trigger_hurt script_origin to the spawned truck.
truckbumperorigin linkto(truck);
// Rotate the truck to the correct heading
truck rotateto((angles),0.001);
// Track the location of the trigger_hurt script_origin and move the trigger_hurt with it
truckbumpertrigger thread trackpos(truckbumperorigin);
// Move the truck's clip arrary.
thread movetruckclip();
// Play the engine sound
truck playsound ("trucksound");
// Move the truck to it's end location.
truck moveto((level.truckend.origin),level.time);
// Wait until the movement is completed.
truck waittill("movedone");

//delete it and start over again//
wait 0.001;
truck delete();
}
}

trackpos(model)
{
while(1)
{
self.origin = model.origin;
wait(0.1);
}
}


movetruckclip()
{
// Get the truck's clip_player brushes.
truckstart_clip = getentarray("testtruck1_clip","targetname");
if (!isDefined("truckstart_clip"))
return;
{
for(d=0; d < truckstart_clip.size; d++)
{
// Move all the truck's clip_player brushes.
truckstart_clip[d] moveto((level.truckend.origin),level.time);
}
}
wait level.time;
for(d=0; d < truckstart_clip.size; d++)
{
truckstart_clip[d] moveto((level.truckstart.origin),0.001);
}
}


Share |
Restricted Access Topic is Locked
Page
Next Page
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

»