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

Members Online

»
1 Active | 68 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: Spawn grenade?
scillman
General Member
Since: Nov 23, 2006
Posts: 360
Last: Sep 1, 2012
[view latest posts]
Level 5
Category: CoD4 Scripting
Posted: Friday, Jan. 20, 2012 07:22 pm
Someone asked me if I could make something for him and I wondered if it is possible to spawn a grenade as in weapon? Or can it only be done as a script_model??
Share |
Tally
General Member
Since: Apr 21, 2005
Posts: 819
Last: Oct 26, 2012
[view latest posts]
Level 7
Category: CoD4 Scripting
Posted: Friday, Jan. 20, 2012 07:54 pm
scillman writes...
Quote:
Someone asked me if I could make something for him and I wondered if it is possible to spawn a grenade as in weapon? Or can it only be done as a script_model??


Code:
grenade = spawn( "weapon_frag_grenade_mp", origin, 4 );


You always spawn the Radiant name of the weapon - not the name of the weapon file. The number "4" is a spawnflag. You can use either 3 or 4, depending on how you want the weapon to lay on the ground.
Share |
scillman
General Member
Since: Nov 23, 2006
Posts: 360
Last: Sep 1, 2012
[view latest posts]
Level 5
Category: CoD4 Scripting
Posted: Friday, Jan. 20, 2012 09:15 pm
Actually it is spawning in the air and needs to fall down(just for the record: it does not fall straight down), as I hoped to reduce additional scripting I was hoping I could make it like the grenade as it is ingame when thrown.
Share |
Tally
General Member
Since: Apr 21, 2005
Posts: 819
Last: Oct 26, 2012
[view latest posts]
Level 7
Category: CoD4 Scripting
Posted: Friday, Jan. 20, 2012 09:17 pm
scillman writes...
Quote:
Actually it is spawning in the air and needs to fall down(just for the record: it does not fall straight down), as I hoped to reduce additional scripting I was hoping I could make it like the grenade as it is ingame when thrown.


change the spawnflag to 3.
Share |
Samuel033
General Member
Since: Dec 10, 2009
Posts: 484
Last: Dec 25, 2015
[view latest posts]
Level 5
Category: CoD4 Scripting
Posted: Saturday, Jan. 21, 2012 12:18 am
Does that actually spawn a real nade that can accept initial velocity? Such as throwing one or launching it from a tube. Or does it just drop and react to the ground? I would assume it also gets the timer from the weapon file. Or it can be manually detonated if needed.
Share |
Tally
General Member
Since: Apr 21, 2005
Posts: 819
Last: Oct 26, 2012
[view latest posts]
Level 7
Category: CoD4 Scripting
Posted: Saturday, Jan. 21, 2012 12:12 pm
Samuel033 writes...
Quote:
Does that actually spawn a real nade that can accept initial velocity? Such as throwing one or launching it from a tube. Or does it just drop and react to the ground? I would assume it also gets the timer from the weapon file. Or it can be manually detonated if needed.


If you spawn the weapon using spawnflag 3, when you get near it, it will give the pickup hint string "press ["use key"] to pick up", but it will be rigid in space - that is, it wont fall to the ground, it will remain bolt upright and at the absolute origin you give it, although it can actually be picked up and thrown (if a grenade).

However, if you use spawnflag 4 to spawn a grenade, it acts as though someone has thrown the grenade, and gives you the hint string "press [frag button] to throw back", but can actually only be picked up using the "use" key. But it will fall to the ground from your stated origin (so, for example, if you spawn it 5 units above ground, it will fall back to actual ground level), and lay on its side. It does not, however, "cook" - that is, there is no fuse set this way. However, I believe you can manually cause it to explode using the detonate() function.

Also, if you spawn a weapon other than a grenade, such as an assault rifle, it will only have minimal ammo. You have to give it full ammo:

Code:
{
	weapon = spawn( classname, origin, 4 );
	weapname = weapon maps\mp\gametypes\_weapons::getItemWeaponName();
	weapon setPickupStartAmmo( weapname );
}	

setPickupStartAmmo( weapname )
{
	curweapname = weapname;
	altindex = 0;
		
	while( altindex == 0 || (curweapname != weapname && curweapname != "none") )
	{
		allammo = weaponStartAmmo( curweapname );
		clipammo = weaponClipSize( curweapname );
		
		reserveammo = 0;
		
		if( clipammo >= allammo )
		{
			clipammo = allammo;
		}
		else
		{
			reserveammo = allammo - clipammo;
		}
		
		self itemWeaponSetAmmo( clipammo, reserveammo, altindex );
		curweapname = weaponAltWeaponName( curweapname );
		altindex++;
	}
}
Share |
scillman
General Member
Since: Nov 23, 2006
Posts: 360
Last: Sep 1, 2012
[view latest posts]
Level 5
Category: CoD4 Scripting
Posted: Saturday, Jan. 21, 2012 12:48 pm
Thanks for your replies.

With 3 it floats mid-air and 4 falls straight down. What I want is that it falls down with a curve like the actual grenades do. (See screenshot)

But good to know it can be picked up again :P.
Share |
IzNoGoD
General Member
Since: Nov 29, 2008
Posts: 694
Last: Nov 10, 2012
[view latest posts]
Level 6
Category: CoD4 Scripting
Posted: Saturday, Jan. 21, 2012 02:12 pm
try magicgrenade() or smthing...
Share |
scillman
General Member
Since: Nov 23, 2006
Posts: 360
Last: Sep 1, 2012
[view latest posts]
Level 5
Category: CoD4 Scripting
Posted: Saturday, Jan. 21, 2012 03:14 pm
Nope that is SP only (ModsRepository)

Kind of getting the idea I have no other choice then scripting it [crazy]

P.s.
1- I set the angles that did not help.
2. I can not get the current origin, so how could I let it detonate?!

edited on Jan. 21, 2012 08:20 am by scillman

This is basicly what I have now:
Code:
playGrenade( org, ang )
{
	model = spawn( "weapon_frag_grenade_mp", org, 4 );
	model.angles = ang;
	
	pos = (0,0,-100000);
	while (model.origin != pos)
	{
		pos = model.origin;
		wait .05;
	}
	
	iPrintLnBold("Hit ground!");
	
	model thread maps\mp\gametypes\_shellshock::grenade_earthQuake();
}


edited on Jan. 21, 2012 08:35 am by scillman
Share |
Tally
General Member
Since: Apr 21, 2005
Posts: 819
Last: Oct 26, 2012
[view latest posts]
Level 7
Category: CoD4 Scripting
Posted: Saturday, Jan. 21, 2012 04:16 pm
What is it you are trying to do? Because, looking at that code, I can't for the life of me see what you are attempting to do.

Just an update -

After some experimentation, I found that you cannot use detonate() on a grenade spawned in this way. The detonate() function uses the "grenade" classname, and that type of entity is only created once a live player presses one of their grenade buttons (either primary or secondaryoffhand), or one of the actionslots. So, in other words, it has to actually be thrown by a player in order for the entity to be recognised as a "grenade".

However, knowing this doesn't mean you can't spoof it - all you need to do is script the explosion and subsequent damage to any players in the vicinity of the entity. I had to do this for my Martyrdom perk in my COD2 mod. Just get the origin of the spawned grenade, and then set a timer to count down to detonation time, and then delete the entity and play an FX on that location. Then use a scripted radius damage at that origin to damage any players in that area.

Not ideal, I know, but what you going to do? Rewrite the COD4 MP executable to make it possible? Believe me - I've thought about it!
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

»