Page 1 of 1

Inflict damage to my jeep

Posted: Sat Jul 30, 2005 9:43 pm
by agentmad007
Hello ,

i cannot figure out how to inflict damage to my jeep...That's what i got so far.

Checked all the existing jeep script out there ......

Code: Select all


	local.jeep = spawn vehicles/allied_jeep.tik "targetname" "jeep1"
	local.jeep.origin = ( 2924 2362 -23 )
	local.jeep vehicleanim add_surfaces
	local.jeep rendereffects "-shadow"

	$jeep1 thread jeep_init

--------------------------------------------------------------------



jeep_init:



		self.speed = 500
		self.maxspeed = self.speed
		self vehiclespeed self.speed
		self rendereffects "-shadow"
		self removeondeath 0
		self.health = 1000
		self takedamage
		self solid
		self removeimmune bash
		self removeimmune bullet
		self removeimmune fast_bullet
		self removeimmune shotgun
		self removeimmune grenade
		self removeimmune rocket
		self removeimmune explosion
		self removeimmune crush
		self removeimmune falling
		self removeimmune vehicle


		self.driving = 0
		self.gunner = 0
		self.passenger = 0



  		if (self.target)
  		{

		self.target notsolid


  		}





		//////////////////////////////////////////////////
		//////////////////////////////////////////////////
		///////////////DRIVER SETTINGS////////////////////
		//////////////////////////////////////////////////
		//////////////////////////////////////////////////


		self.gun = self queryturretslotentity 0

		if (self.gun)
		{

		self.gunmodel = "models/human/allied_driver.tik"

		self detachturretslot 0 self.gun.origin

		self.gun remove

		self spawnturret 0 self.gunmodel
	
		self.gun = self queryturretslotentity 0
		
		self.gun pitchcaps ( 0 0 0)

		self.gun maxyawoffset 0

		self.gun yawcenter 0

		self.gun hide

		self.gun takedamage
		self.gun solid
		self.gun removeimmune bash
		self.gun removeimmune bullet
		self.gun removeimmune fast_bullet
		self.gun removeimmune shotgun
		self.gun removeimmune grenade
		self.gun removeimmune rocket
		self.gun removeimmune explosion
		self.gun removeimmune crush
		self.gun removeimmune falling
		self.gun removeimmune vehicle




		}


		//////////////////////////////////////////////////
		//////////////////////////////////////////////////
		///////////////TURRET SETTINGS////////////////////
		//////////////////////////////////////////////////
		//////////////////////////////////////////////////

		self.gun2 = self queryturretslotentity 1

		if (self.gun2)
		{

		self.gun2model = "models/vehicles/jeep_30cal.tik"

		self detachturretslot 1 self.gun2.origin

		self.gun2 remove

		self spawnturret 1 self.gun2model
	
		self.gun2 = self queryturretslotentity 1

		self.gun2 pitchcaps ( 0 0 0)

		self.gun2 maxyawoffset 360

		self.gun2 yawcenter 50

		self.gun2 show

		}



		//////////////////////////////////////////////////
		//////////////////////////////////////////////////
		/////////////PASSENGER SETTINGS///////////////////
		//////////////////////////////////////////////////
		//////////////////////////////////////////////////

		self.passenger = self QueryPassengerSlotEntity 0

		if (self.friend)
		{

		self detachpassengerslot 0 self.passenger.origin

		self.passenger remove

		self.passenger = self QueryPassengerSlotEntity 0

		}




		thread get_on_the_jeep




end

get_on_the_jeep:

	self.health = 1000

	local.usedistance = 300

	while(self)
	{

	if(self.health <= 999)////////THIS IS WHAT I VE SET TO CHECK DAMAGE INFLICTED TO MY JEEP 
	{
	iprintln "jeep damaged"
	}

	if(self.health == 1000)
	{
	iprintln "jeep intact"
	}
	

		for (local.p=1;local.p<=$player.size;local.p++)
		{
		local.player = $player[local.p]
		
			 if (local.player.useheld==1)
			  {
				if (local.player.dmteam != "spectator" && level.driving[local.p]==0)
				{

				local.distance = vector_length (local.player.origin - self.origin)
					if ((local.distance <= local.usedistance) )
					{
						if (self.driving ==0 )
						{
							
						thread jeep_driver local.p

						}



					
						
					}

				}

		 	 }
		}

		waitframe
		waitframe
		waitframe
	}
end

In the while loop , i am checking for any damage but the jeep is still intact after loads of nades bullet bash grenade-laucher mg42 mounted machine gun and so on ....

Thanks for the help :D

Posted: Sat Jul 30, 2005 10:07 pm
by Ric-hard
Hello
while(self) ?

looks weird :?

Richard

Posted: Sat Jul 30, 2005 10:57 pm
by agentmad007
I tried:

Code: Select all


while(1)
while(isalive self)

Thats why i came to while(self) , but nothing work

Posted: Sun Jul 31, 2005 12:53 am
by lizardkid
lets see some errors, i'd ratehr see an error than pick apart someone else's code ;)

while self is weird, but i think it works.

Posted: Sun Jul 31, 2005 1:08 am
by agentmad007
I don't see where is the crime.....Just modyfing existing script.There is no many ways to drive a jeep.

Posted: Sun Jul 31, 2005 8:48 am
by jv_map
while(self) is excellent, if self is an existing listener it returns true, if self is NIL or NULL it returns false :)

Anyway agentmad007, jeep-wise the code looks good and I think it should take damage the way you have it :? so maybe any of the attached ents (gun,gun2,friend) are taking the damage and shielding the jeep... hence try making all of these notsolid :)

Posted: Sun Jul 31, 2005 9:22 am
by lizardkid
on a side note is it possible to do a halo style jeep that has a human driver and gunner? all i'v ever seen is just a gunner or just a driver.

Posted: Sun Jul 31, 2005 12:57 pm
by agentmad007
Now the damage work , thx JV :D , however the jeep doesn't feel hurted by grenades and Bullets ( exept from A canon).....How come ?

Thanks