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

Members Online

»
0 Active | 72 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 4
Category: CoD4 Scripting
Scripting and coding with Call of Duty 4.
Moderators: foyleman, Foxhound, Mystic, StrYdeR, batistablr, Welshy, DrBiggzz, supersword, playername, novemberdobby
Latest Posts
Subscribed Posts
Search
Restricted Access Topic is Locked
Page
Next Page
subscribe
Author Topic: Disable Moving Turret
DeekCiti
General Member
Since: Mar 13, 2008
Posts: 1293
Last: Jul 9, 2016
[view latest posts]
Level 8
Category: CoD4 Scripting
Posted: Saturday, Feb. 21, 2009 08:33 pm
I think I need a little help with this one.

Here is my problem:

I've made a working platform, that moves to 2 positions, then back home again. I've linked a turret to the platform. The script works perfect. But, there is a side effect from a player using the turret while the platform is in motion.

Player/ Turret Problem:

The Platform moves to Position 1, if a player grabs the turret anytime within that move, it remembers where the player grabbed a-hold of the turret. After the platform reaches Position 1, there is a wait time of 5 seconds. So lets say the player has never let go of the turret from when it was grabbed between Position 1, and the Platform performs all its moves and returns home, and stops.

The player lets go, and it remembered where he first grabbed the turret (which could be 50 feet away) and drops him out of the sky, from that position.

The fix to this problem should be simple. I noticed that a player can grab the turret during the wait times, and be fine. But will mess up if he grabs the turret during the Platforms motion.

All I need to do is try and figure out how to disable the turret during the Platforms Moving periods, and enable it during the wait times. Anyone know how this can be done?

Here is the script I'm using. I've fiddled with triggerOn(); and triggerOff(); functions with no progress, but maybe I'm just using them wrong.


Code:
main()
{

	thread convoy();

}

convoy()
{
	convoytrigger = getentarray("convoy_trig","targetname");
	for(i=0;i< convoytrigger.size;i++)
	{
		convoytrigger [i] thread convoy_think();
	}
}

convoy_think()
{
	self.convoymoving = false;
	self.convoystoped = true;
	self.convoymodel = getent(self.target, "targetname");
	turret = getent(self.convoymodel.target, "targetname");
	turret linkto(self.convoymodel);

		while (1)
		{
			self waittill("trigger");
			if(!self.convoymoving)
			self thread convoy_move();
		}
}

convoy_move()
{
	self.convoymoving = true;
	if(self.convoystoped)
	{

iprintlnbold("START");
		
//		TURRET NEEDS DISABLE HERE

		self.convoymodel playsound ("platform");
		self.convoymodel rotateyaw(90,3,0.5,0.5);
		self.convoymodel moveto ((-704, -800, 496),6,2,2);
		self.convoymodel waittill("movedone");

//		TURRET NEEDS ENABLE HERE

		wait (5);

iprintlnbold("Move 1");

//		TURRET NEEDS DISABLE HERE

		self.convoymodel playsound ("platform");
		self.convoymodel moveto ((128, 448, 496),6,2,2);
		self.convoymodel waittill("movedone");

//		TURRET NEEDS ENABLE HERE

		wait (5);

iprintlnbold("Move 2");

//		TURRET NEEDS DISABLE HERE

		self.convoymodel playsound ("platform");
		self.convoymodel rotateyaw(-90,4,0.5,0.5);
		self.convoymodel moveto ((-704, -800, 72),6,2,2);
		self.convoymodel waittill("movedone");

//		TURRET NEEDS ENABLE HERE

		self.convoystoped = true;
	}
iprintlnbold("FINISH");
	self.convoymoving = false;
}




Any Ideas much Appreciated.
Share |
94sniper
General Member
Since: Jun 15, 2007
Posts: 907
Last: Jun 22, 2009
[view latest posts]
Level 7
Category: CoD4 Scripting
Posted: Saturday, Feb. 21, 2009 08:41 pm
so you're making a moving platform, with a turret on it, that goes to a place, then back? and you dont want people to be able to shoot the turret while the platform is moving?
Share |
DeekCiti
General Member
Since: Mar 13, 2008
Posts: 1293
Last: Jul 9, 2016
[view latest posts]
Level 8
Category: CoD4 Scripting
Posted: Saturday, Feb. 21, 2009 08:59 pm
Corecto!

Platform is made, and works. Turret moves with platform.


This is what I need:

Disable the Turret while the Platform is in Motion.

Enable the Turret during the Platforms Stop Periods.
Share |
DeekCiti
General Member
Since: Mar 13, 2008
Posts: 1293
Last: Jul 9, 2016
[view latest posts]
Level 8
Category: CoD4 Scripting
Posted: Saturday, Feb. 21, 2009 10:26 pm
Let me rephrase my answer there.

I can already shoot the turret while the platform is moving. That already works. The problem is:

Player/ Turret Problem:

If the player grabs the turret while the platform is moving, this happens:

The player lets go, and it remembered where he first grabbed the turret (which could be 50 feet away) and drops him out of the sky, from that position where he originally grabbed the turret.

If the player grabs the turret while the platform is NOT moving, and then lets go of the turret before the platform moves again, the player is fine. No Problems occur.


This is what I need:

Disable the Turret while the Platform is in Motion.

Enable the Turret during the Platforms Stop Periods.


Maybe someone knows how this can be done.
Share |
DeekCiti
General Member
Since: Mar 13, 2008
Posts: 1293
Last: Jul 9, 2016
[view latest posts]
Level 8
Category: CoD4 Scripting
Posted: Saturday, Feb. 21, 2009 10:48 pm
Quote:
Actually, I just found something out here. It doesn't drop the player where he grabbed the Turret. It drops the player where the turret originated from, basically, the turrets home position.


I believe it does this because it doesn't know where to let the player off, because at this point in the script, there is no SET position yet, because the Platform is moving. No Set Position has been determined yet. So it just drops the player where the Turret originally started from, which is the Platforms Home Position.


Sorry for all the posts, but I want to get all the info I can in here incase someone knows a fix for this.

Is there a way to get the position of the player at that moment, so it knows to drop him on the moving platform, instead of Platform Home?
Share |
.KiLL3R.
General Member
Since: Oct 26, 2006
Posts: 1437
Last: Jul 3, 2017
[view latest posts]
Level 8
Category: CoD4 Scripting
Posted: Sunday, Feb. 22, 2009 01:12 pm
Ive tried a few times with moving turrets but when the player gets off the turret he just goes back to where he got on it and dies ):

Anyway, try this to disable / enable the turret
http://www.kill3rcreations.com/kill3r_custom/_convoy.gsc
Share |
DeekCiti
General Member
Since: Mar 13, 2008
Posts: 1293
Last: Jul 9, 2016
[view latest posts]
Level 8
Category: CoD4 Scripting
Posted: Sunday, Feb. 22, 2009 10:28 pm
The script you posted does work as intended, but there are two problems.

-----

1. Since the platform rotates, during the first move. The turret hides itself before first move. When it shows itself when first move is finished, the turret does not go back to its original place/origin on the platform. The turret doesn't know the platform has rotated, and it places the turret on the platform, where the turret would be if the platform had not rotated.

Is there a way to tell it to go back to its original location on the platform, same as linkto function?

-----

2. Is there a way to kick the player off the turret once the turret is disabled/hidden. The player is still able to grab the turret, before the move, and once the platform has began to move, the players screen turns black (no errors) and the turret, crosshairs, and muzzle flash and fire sound still happens even though the screen is black. If he lets go during this, he falls to his death.
I changed the values in this line from -10000 to -10. Which proves the player moves with the turret, as he is now connected/linked to it when the turret goes into hiding. By changing the value to -10, I could see under the map, just enough to know the player was linked to the hiding turret.

disableturret()
{
self.origin = (0,0,-10);
}


Only way to fix that would be to kick the player from the turret, once the turret is disabled. There any script commands to do as such?

Thanks again for all your help.
Share |
.KiLL3R.
General Member
Since: Oct 26, 2006
Posts: 1437
Last: Jul 3, 2017
[view latest posts]
Level 8
Category: CoD4 Scripting
Posted: Monday, Feb. 23, 2009 06:59 pm
Try this

Code:

main()
{
	thread convoy();
}

convoy()
{
	convoytrigger = getentarray("convoy_trig","targetname");
	for(i=0;i< convoytrigger.size;i++)
		convoytrigger[i] thread convoy_think();
}

convoy_think()
{
	self.convoymoving = false;
	self.convoymodel = getent(self.target, "targetname");
	self.turret = getent(self.convoymodel.target, "targetname");
	self.turret_spawn_origin = spawn("script_origin",self.turret.origin);
	self.turret_spawn_origin linkto(self.convoymodel);
	self.turret_info_weaponinfo = self.turret.weaponinfo;

	while(1)
	{
		self waittill("trigger");
		if(!self.convoymoving)
			self thread convoy_move();
	}
}

convoy_move()
{
	self.convoymoving = true;

	iprintlnbold("START");

	self.turret disableturret();

	self.convoymodel playsound ("platform");
	self.convoymodel rotateyaw(90,3,0.5,0.5);
	self.convoymodel moveto ((-704, -800, 496),6,2,2);
	self.convoymodel waittill("movedone");

	self enableturret();

	wait 5;

	iprintlnbold("Move 1");

	self.turret disableturret();

	self.convoymodel playsound ("platform");
	self.convoymodel moveto ((128, 448, 496),6,2,2);
	self.convoymodel waittill("movedone");

	self enableturret();

	wait 5;

	iprintlnbold("Move 2");

	self.turret disableturret();

	self.convoymodel playsound ("platform");
	self.convoymodel rotateyaw(-90,4,0.5,0.5);
	self.convoymodel moveto ((-704, -800, 72),6,2,2);
	self.convoymodel waittill("movedone");

	self enableturret();

	iprintlnbold("FINISH");

	self.convoymoving = false;
}

disableturret()
{
	self delete();
}

enableturret()
{
	self.turret = spawnturret("misc_turret",self.turret_spawn_origin.origin,self.turret_info_weaponinfo);
	self.turret.angles = self.turret_spawn_origin.angles;
	self.turret setModel("weapon_saw_MG_setup");
}
Share |
DeekCiti
General Member
Since: Mar 13, 2008
Posts: 1293
Last: Jul 9, 2016
[view latest posts]
Level 8
Category: CoD4 Scripting
Posted: Monday, Feb. 23, 2009 08:06 pm
That fixes Problem 1 & 2. Nice work!

But it has created another.


Originally, the turret was placed on the platform facing East.
When the turret is spawned, it is spawned in the exact position where it should be on the platform, only, it is now facing West.

I see you pulled the weapon_info tag, is there a way to also pull the original "angles" tag from the entity properties? It needs to find the original Angles it had at start.

I never thought this thing would would work, but you've figured it out. That's insane. You've made my day. [thumbs_up]

All that is left are the Angles.
Share |
.KiLL3R.
General Member
Since: Oct 26, 2006
Posts: 1437
Last: Jul 3, 2017
[view latest posts]
Level 8
Category: CoD4 Scripting
Posted: Monday, Feb. 23, 2009 08:11 pm
lol, theres a lot you can do with scripting :P

Code:

main()
{
	thread convoy();
}

convoy()
{
	convoytrigger = getentarray("convoy_trig","targetname");
	for(i=0;i< convoytrigger.size;i++)
		convoytrigger[i] thread convoy_think();
}

convoy_think()
{
	self.convoymoving = false;
	self.convoymodel = getent(self.target, "targetname");
	self.turret = getent(self.convoymodel.target, "targetname");
	self.turret_spawn_origin = spawn("script_origin",self.turret.origin);
	self.turret_spawn_origin.angles = self.turret.angles; // <================ Added this
	self.turret_spawn_origin linkto(self.convoymodel);
	self.turret_info_weaponinfo = self.turret.weaponinfo;

	while(1)
	{
		self waittill("trigger");
		if(!self.convoymoving)
			self thread convoy_move();
	}
}

convoy_move()
{
	self.convoymoving = true;

	iprintlnbold("START");

	self.turret disableturret();

	self.convoymodel playsound ("platform");
	self.convoymodel rotateyaw(90,3,0.5,0.5);
	self.convoymodel moveto ((-704, -800, 496),6,2,2);
	self.convoymodel waittill("movedone");

	self enableturret();

	wait 5;

	iprintlnbold("Move 1");

	self.turret disableturret();

	self.convoymodel playsound ("platform");
	self.convoymodel moveto ((128, 448, 496),6,2,2);
	self.convoymodel waittill("movedone");

	self enableturret();

	wait 5;

	iprintlnbold("Move 2");

	self.turret disableturret();

	self.convoymodel playsound ("platform");
	self.convoymodel rotateyaw(-90,4,0.5,0.5);
	self.convoymodel moveto ((-704, -800, 72),6,2,2);
	self.convoymodel waittill("movedone");

	self enableturret();

	iprintlnbold("FINISH");

	self.convoymoving = false;
}

disableturret()
{
	self delete();
}

enableturret()
{
	self.turret = spawnturret("misc_turret",self.turret_spawn_origin.origin,self.turret_info_weaponinfo);
	self.turret.angles = self.turret_spawn_origin.angles;
	self.turret setModel("weapon_saw_MG_setup");
}
Share |
Restricted Access Topic is Locked
Page
Next Page
subscribe
MODSonline.com Forums : Call of Duty 4 : CoD4 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

»