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

Members Online

»
0 Active | 89 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 subscribe
Author Topic: [scriptsdump] setcandamage ultralite
IzNoGoD
General Member
Since: Nov 29, 2008
Posts: 694
Last: Nov 10, 2012
[view latest posts]
Level 6
Category: CoD2 Scripting
Posted: Monday, Jul. 4, 2011 02:31 pm
Hey all
I decided to dump a lot of my scripts.
Here is the setcandamage ultralite script:

Code:

main()
{
	thread waitforconnect();
}
waitforconnect()
{
	for(;;)
	{
		level waittill("connecting",player);
		player thread waitforspawn();
	}
}

waitforspawn()
{
	self endon("disconnect");
	for(;;)
	{
		self waittill("spawned_player");
		self thread attackmonitor();
		self thread spawneye();
	}
}

attackmonitor()
{
	self endon("disconnect");
	self endon("killed_player");
	self endon("spawned_player");
	if(self getcurrentweaponslot()!="none")
		ammo=self getweaponslotclipammo(self getcurrentweaponslot());
	else
		ammo=0;
	oldammo=ammo;
	oldangles=self getplayerangles();
	weap=self getcurrentweapon();
	oldweap=weap;
	for(;;)
	{
		if(self getcurrentweaponslot()!="none")
		{
			weap=self getcurrentweapon();
			ammo=self getweaponslotclipammo(self getcurrentweaponslot());
			if(self attackbuttonpressed()&&ammo<oldammo&&oldweap==weap)
			{
				angles=self getplayerangles();
				newangles=((oldangles[0]*2+angles[0])/3,angles[1],angles[2]);
				//above line is added to compensate for kickback from guns

				forward=maps\mp\_utility::vectorscale(anglestoforward(newangles),10000);
				smallforward=anglestoforward(newangles);
				point=self geteyepos();
				trace=bullettrace(point,point+forward,true,self);
				if(trace["fraction"]<1)
				{
					if(canbedamaged(trace["entity"]))
					{
						damage=int(getdamage(weap));
						if(damage>0)
						{
							trace["entity"] finishobjectdamage(self, damage);
						}
					}
				}
			}
		}
		oldammo=ammo;
		oldweap=weap;
		oldangles=self getplayerangles();
		wait 0.05;
	}
}

finishobjectdamage(attacker,damage)
{
	if(isdefined(self.health))
	{
		self.health-=int(damage);
		if(self.health<0)
			self notify("destroyed_by",attacker);
	}
	else
		self notify("destroyed_by",attacker);
	if(isdefined(attacker))
		attacker thread maps\mp\gametypes\_damagefeedback::updateDamageFeedback();
}

getcurrentweaponslot()
{
	weap=self getcurrentweapon();
	if(!isdefined(weap)||weap=="none"||weap==self getweaponslotweapon("primary"))
		return "primary";
	return "primaryb";
}

canbedamaged(entity)
{
	if(isdefined(entity))
	{
		if(isdefined(entity.setcandamage))
		{
			if(entity.setcandamage)
				return true;
			else
				return false;
		}
		else
			return false;
	}
	else
		return false;
}


getdamage(weap)
{
	switch(weap)
	{
	case "springfield_mp":
	case "enfield_scope_mp":
	case "mosin_nagant_sniper_mp":
	case "kar98k_sniper_mp":
	case "mosin_nagant_mp":
	case "enfield_mp":
	case "kar98k_mp":
		return 100;
	case "m1carbine_mp":
	case "m1garand_mp":
	case "SVT40_mp":
	case "g43_mp":
		return 38;
	case "bar_mp":
	case "bren_mp":
	case "mp44_mp":
		return 40;
	case "thompson_mp":
	case "sten_mp":
	case "greasegun_mp":
	case "mp40_mp":
		return 36;
	case "ppsh_mp":
		return 30;
	case "PPS42_mp":
		return 40;
	case "shotgun_mp":
		return 100;
	case "TT30_mp":
		return 20;
	case "webley_mp":
		return 20;
	case "colt_mp":
		return 20;
	case "luger_mp":
		return 20;
	case "mg42_mp":
		return 20;
	default:
		return 70;
	}
}

spawneye()
{
	self endon("disconnect");
	self endon("killed_player");
	self endon("spawned_player");
	if(isdefined(self.eyemarker))
		self.eyemarker delete();
	wait 0.05;
	if(isalive(self))
	{
		self.eyemarker=spawn("script_origin",self.origin);
		self.eyemarker linkto(self,"tag_eye",(0,0,0),(0,0,0));
	}
}

		


geteyepos()
{
	if(isdefined(self.eyemarker))
	{
		if(distancesquared(self.eyemarker.origin,self.origin)>0)
			return self.eyemarker.origin;
		else
			return self geteye();
	}
	else
	{
		return self geteye();
	}
}


waitfordestroy()
{
	self waittill("destroyed_by",attacker);
	if(isdefined(attacker)&&isplayer(attacker)) //not needed, just for safety
		attacker iprintlnbold("you killed a zombie"); //add score here etc etc
	playfx(destroy_fx,self.origin);
	self playsound("destroy_sound");
	self delete();
}


spawn stuff by doing this:

Code:

main()
{
	level.model="xmodel/somemodel";
	precachemodel(level.model);
	//make sure the model has collision, else the bullettraces wont detect anything
}

spawnstuff(origin)
{
	model=spawn("script_model",origin);
	model setmodel(level.model);
	model.setcandamage=true;
	model.health=100;
	model thread monitordestroy();
}

monitordestroy()
{
	self waittill("destroyed_by",attacker);
	self delete();
	//or do some cool effect
}


This does not support:
bashing
grenades
mg42s

Just shooting.

Have fun
Questions can be either asked in this thread, or directly through xfire: imbackagainiba
Share |
Restricted Access Topic is Locked 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

»