Author |
Topic: Auto turret health help |
[ZCT]Titan |
|
General Member Since: Feb 23, 2009 Posts: 172 Last: Apr 5, 2011 [view latest posts] |
|
|
|
Category: CoDWW Scripting Posted: Tuesday, Jul. 27, 2010 09:39 pm |
|
Ok,so i need help yet again on adding a set health to the turret i have in my map and making it so the players nades and bullets hurt it. I also want to reset the wait so if you destroy it with the menu it resets the time so the next time you place it it waits the full 60 secs and not like 10 of the left over time from the last one and i have tried everything and cant figure it out.
And they also shoot players if your infront of the zombie it targets lol. Cant figure that out either.
Code: SetupTurret()
{
pos = self.origin;
self endon("kill_turret");
self endon("joined_spectators");
self endon("disconnect");
self endon("death");
weaponinfo = "30cal_bipod_prone";
if( isDefined(self.turret_gun) )
{
self iPrintLn("^1You already have a turret spawned.");
return;
}
iprintln("^1" + self.playername + " ^7deployed a defence turret." );
self.turret_bipod = spawn( "script_model", pos );
self.turret_gun = spawnTurret( "misc_turret", pos + (0, 0, 30), weaponinfo );
self.turret_gun setModel( "weapon_minigun" );
self.turret_bipod setModel( "sentry_bipod" );
self.turret_gun setContents( 0 );
self.turret_bipod setContents( 1 );
self.turret_gun.targetname = "test"+self.entity_num;
self.turret_gun.owner = self;
//self.turret_gun thread CheckForPlayers();
//elf.turret_gun thread rotate();
self.turret_gun thread shoot(self);
self.fx_or = spawn("script_model",(0,0,0));
self.fx_or.origin = self.origin;
self.fx_or setmodel("tag_origin");
self.fx_or.angles = (-90,0,0);
playFXOnTag( level._effect["zombie_turret_base"], self.fx_or, "tag_origin" );
playsoundatposition("sentry", (0,0,0));
self thread turretwatch( self, self.turret_gun );
self thread turretwatch( self, self.turret_bipod );
wait 60;
self.turret_gun delete();
self.turret_bipod delete();
self.fx_or delete();
self.turret_gun notify("kill_turret");
self notify("kill_turret");
}
turret_delete()
{
self.turret_gun delete();
self.turret_bipod delete();
self.fx_or delete();
}
shoot(player)
{
tgtname = "test"+player.entity_num;
mgs = getentarray( tgtname, "targetname" );
for(i=0;i<mgs.size;i++)
{
mg = mgs[i];
mg.owner = self;
mg setTurretTeam( "allies" );
mg SetMode( "auto_nonai" );
mg thread maps\_mgturret::burst_fire_unmanned();
}
wait(60); // Leave turrets on for 30 seconds
for(i=0;i<mgs.size;i++)
{
mg = mgs[i];
mg notify("stop_burst_fire_unmanned");
mg SetMode( "manual" );
}
}
turretwatch(player, mine)
{
self endon("joined_spectators");
self endon("disconnect");
self endon("spawned");
self endon("kill_turret");
player waittill("death");
mine delete();
}
Any help would be great guys.
Titan |
|
|
|
[ZCT]Titan |
|
General Member Since: Feb 23, 2009 Posts: 172 Last: Apr 5, 2011 [view latest posts] |
|
|
|
|
tHMatt |
|
General Member Since: Sep 11, 2007 Posts: 473 Last: Mar 20, 2013 [view latest posts] |
|
|
|
DemonSeed |
General Member Since: Apr 30, 2009 Posts: 1362 Last: Feb 19, 2018 [view latest posts] |
|
|
|
Category: CoDWW Scripting Posted: Sunday, Aug. 1, 2010 04:49 pm |
|
Im unclear what you are wanting, but if I do understand you correctly, try this:
Code: SetupTurret()
{
pos = self.origin;
self endon("kill_turret");
self endon("joined_spectators");
self endon("disconnect");
self endon("death");
weaponinfo = "30cal_bipod_prone";
if( isDefined(self.turret_gun) )
{
self iPrintLn("^1You already have a turret spawned.");
return;
}
iprintln("^1" + self.playername + " ^7deployed a defence turret." );
self.turret_bipod = spawn( "script_model", pos );
self.turret_bipod setModel( "sentry_bipod" );
self.turret_bipod setContents( 1 );
self.turret_gun = spawnTurret( "misc_turret", pos + (0, 0, 30), weaponinfo );
self.turret_gun setModel( "weapon_minigun" );
self.turret_gun setContents( 0 );
self.turret_gun.targetname = "test"+self.entity_num;
self.turret_gun.owner = self;
self.turret_gun thread shoot(self);
self.turret_gun thread
self.fx_or = spawn("script_model",(0,0,0));
self.fx_or.origin = self.origin;
self.fx_or setmodel("tag_origin");
self.fx_or.angles = (-90,0,0);
playFXOnTag( level._effect["zombie_turret_base"], self.fx_or, "tag_origin" );
playsoundatposition("sentry", (0,0,0));
self thread turretwatch( self, self.turret_gun );
self thread turretwatch( self, self.turret_bipod );
wait 60;
self.turret_gun delete();
self.turret_bipod delete();
self.fx_or delete();
self.turret_gun notify("kill_turret");
self notify("kill_turret");
}
sentry_damage()
{
self endon("death");
self endon("end_sentry_turret");
self setCanDamage(true);
self.maxhealth = 999999;
self.health = self.maxhealth;
attacker = undefined;
while(1)
{
self waittill( "damage", dmg, attacker );
if(dmg < 5)
continue;
self.owner.sentryTurretDamageTaken += dmg;
if(self.owner.sentryTurretDamageTaken >= level.sentryTurretHealth)
break;
}
if( !isDefined(self) )
return;
self.owner thread sentry_explode();
}
turret_delete()
{
self.turret_gun delete();
self.turret_bipod delete();
self.fx_or delete();
}
shoot( player )
{
tgtname = "test"+player.entity_num;
mgs = getentarray( tgtname, "targetname" );
for(i=0;i<mgs.size;i++)
{
mg = mgs[i];
mg.owner = self;
mg setTurretTeam( "allies" );
mg SetMode( "auto_nonai" );
mg thread maps\_mgturret::burst_fire_unmanned();
}
wait(60); // Leave turrets on for 30 seconds
for(i=0;i<mgs.size;i++)
{
mg = mgs[i];
mg notify("stop_burst_fire_unmanned");
mg SetMode( "manual" );
}
}
turretwatch(player, mine)
{
self endon("joined_spectators");
self endon("disconnect");
self endon("spawned");
self endon("kill_turret");
player waittill("death");
mine delete();
}
That sets a function so that the turret takes damage from an attacker. For it to work, it depends whether zombie mode/CoOp has the same functions for damaging an entity (I believe it does so it should work). |
|
|
|
[ZCT]Titan |
|
General Member Since: Feb 23, 2009 Posts: 172 Last: Apr 5, 2011 [view latest posts] |
|
|
|
Category: CoDWW Scripting Posted: Sunday, Aug. 1, 2010 05:27 pm |
|
Thanks demon ill try that later and see if it works.
MattY i love how because you see something named the same in your old script you assume all the scripts are using yours. Thats like saying you put in Code: players[i] hasperk("etcetc") in your script anyone elses script is copying yours. Like i said before please dont come on my topics starting issues im here to get help. Not get into fights over scripts.
Titan |
|
|
|
tHMatt |
|
General Member Since: Sep 11, 2007 Posts: 473 Last: Mar 20, 2013 [view latest posts] |
|
|
Category: CoDWW Scripting Posted: Sunday, Aug. 1, 2010 05:38 pm |
|
[ZCT]Titan writes...Quote: Thanks demon ill try that later and see if it works.
MattY i love how because you see something named the same in your old script you assume all the scripts are using yours. Thats like saying you put in Code: players[i] hasperk("etcetc") in your script anyone elses script is copying yours. Like i said before please dont come on my topics starting issues im here to get help. Not get into fights over scripts.
Titan
No, the custom named functions are the same or are you gonna say that coincidence? For example the "turretwatch" function was orginally written for my mines, hence the "mine" parameter + lots of other stuff in there is the same.
I'm not starting an argument, it's just nice to see my talent being used in other peoples work!
|
|
|
|
[ZCT]Titan |
|
General Member Since: Feb 23, 2009 Posts: 172 Last: Apr 5, 2011 [view latest posts] |
|
|
|
|
DemonSeed |
General Member Since: Apr 30, 2009 Posts: 1362 Last: Feb 19, 2018 [view latest posts] |
|
|
|
|
[ZCT]Titan |
|
General Member Since: Feb 23, 2009 Posts: 172 Last: Apr 5, 2011 [view latest posts] |
|
|
|
|
tHMatt |
|
General Member Since: Sep 11, 2007 Posts: 473 Last: Mar 20, 2013 [view latest posts] |
|
|
Category: CoDWW Scripting Posted: Sunday, Aug. 1, 2010 06:19 pm |
|
I am not spamming anything, I simply mentioned that "oh my code is in there" as it was a shock as I didnt think brax had released it... I dont care your using it, I never released my cod2 mod so it's nice to see some of the work I put in being used for something constructive. I can see your not using the full code, as my code was build to target player clients and not bots, but its still very easy to notice my "mistakes" in the code to easily detect, even with your dissection, that it is still mine :)
For the record, I never EVER release my scripts due to the amount of people in the broken COD2 community who will just rip open the IWD and steal everything and pose it as their own, which happens day on day with the 12 year old kids who are "COOL MODDERS" - This also added to my sudden posting on the topic, as I'm very defensive towards anything I code.
|
|
|
|