Author |
Topic: Disable Moving Turret |
DeekCiti |
|
General Member Since: Mar 13, 2008 Posts: 1293 Last: Jul 9, 2016 [view latest posts] |
|
|
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.
|
|
|
|
94sniper |
|
General Member Since: Jun 15, 2007 Posts: 907 Last: Jun 22, 2009 [view latest posts] |
|
|
|
DeekCiti |
|
General Member Since: Mar 13, 2008 Posts: 1293 Last: Jul 9, 2016 [view latest posts] |
|
|
|
DeekCiti |
|
General Member Since: Mar 13, 2008 Posts: 1293 Last: Jul 9, 2016 [view latest posts] |
|
|
|
DeekCiti |
|
General Member Since: Mar 13, 2008 Posts: 1293 Last: Jul 9, 2016 [view latest posts] |
|
|
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? |
|
|
|
.KiLL3R. |
|
General Member Since: Oct 26, 2006 Posts: 1437 Last: Jul 3, 2017 [view latest posts] |
|
|
|
DeekCiti |
|
General Member Since: Mar 13, 2008 Posts: 1293 Last: Jul 9, 2016 [view latest posts] |
|
|
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. |
|
|
|
.KiLL3R. |
|
General Member Since: Oct 26, 2006 Posts: 1437 Last: Jul 3, 2017 [view latest posts] |
|
|
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");
}
|
|
|
|
DeekCiti |
|
General Member Since: Mar 13, 2008 Posts: 1293 Last: Jul 9, 2016 [view latest posts] |
|
|
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.
All that is left are the Angles. |
|
|
|
.KiLL3R. |
|
General Member Since: Oct 26, 2006 Posts: 1437 Last: Jul 3, 2017 [view latest posts] |
|
|
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");
}
|
|
|
|