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

Members Online

»
0 Active | 69 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: JetPack Scripting Help
[aL]RogeR
General Member
Since: Feb 13, 2011
Posts: 9
Last: Feb 22, 2011
[view latest posts]
Level 0
Category: CoD4 Scripting
Posted: Sunday, Feb. 13, 2011 07:08 pm
I'm scripting a jetpack perk for a mod but I've come into some trouble. I scripted it but later found that SetVelocity() is apparently SP only :/.

I intended my jetpack to just give a vertical boost to the player when the space button is pressed whilst maintaining the players previous velocity. Any help is appreciated :)

My script:
Code:
setupRocketPack()
{
	self endon("death");
	self endon("disconnect");
	
	if ( self.rocketpack )
	{
		player.rocketpackfuel = 20;
		while((self ButtonPressed( "SPACE" )) && (player.rocketpackfuel != 0))
		{
			vel = level.player GetVelocity();
			player.MoveGravity(0, 0, 10, 1);
			player.rocketpackInUse = true;
		}
		
		while((player.rocketpackInUse == true) && (player.rocketpackfuel != 0))
		{
		
		player.rocketpackfuel = (player.rocketpackfuel - 1);
		wait 0.1;
		
		}
		
		while(player !ButtonPressed( "SPACE" ))
		{
			player.rocketpackInUse = false;
		}
		
		while((player.rocketpackInUse == false) && (player.rocketpackfuel != 20))
		{
		
		player.rocketpackfuel = (player.rocketpackfuel + 1);
		wait 0.5;
		
		}
		
	}
	
	else if ( !self.rocketpack )
	{
		player.rocketpackInUse = false;
		player.rocketpackfuel = 20;
	}
	

}


EDIT: Damn, when I searched the first time nothing appeared but I've just found a similar topic so apologies for that, although it only contained topics about jetpacks that didn't retain previous velocity so I still need help :/

edited on Feb. 13, 2011 02:24 pm by [aL]RogeR
Share |
Samuel033
General Member
Since: Dec 10, 2009
Posts: 484
Last: Dec 25, 2015
[view latest posts]
Level 5
Category: CoD4 Scripting
Posted: Sunday, Feb. 13, 2011 09:18 pm
It can be done manually using a separate threaded loop. The simplest method is to use previous and current positions over time. In the loop get the two values, find the distance and direction, apply to a couple of player variables (player.myspeed etc), set the next 'previous' position to be the current one, wait a short time, then continue the loop again getting the new current position. Then compare again.

Unless someone knows of a mp variable that already does this? I never found one. [biggrin]
Share |
[aL]RogeR
General Member
Since: Feb 13, 2011
Posts: 9
Last: Feb 22, 2011
[view latest posts]
Level 0
Category: CoD4 Scripting
Posted: Sunday, Feb. 13, 2011 09:38 pm
I actually got the script to work without error I'm yet to test if it works ingame because I need to make a shader or w/e for the perk but I don't know where they are located :/.

BTW I did it by spawning then linking a script_origin, then using movegravity() to fling the player upwards :)

edited on Feb. 13, 2011 04:38 pm by [aL]RogeR
Share |
Samuel033
General Member
Since: Dec 10, 2009
Posts: 484
Last: Dec 25, 2015
[view latest posts]
Level 5
Category: CoD4 Scripting
Posted: Sunday, Feb. 13, 2011 10:40 pm
So basically you made an exploding barrel and attached a player to it. That could be fun. Reminds me of kids attaching fire crackers to GI Joe and lighting them. There are several tutorials here for making materials and effects.
Share |
[aL]RogeR
General Member
Since: Feb 13, 2011
Posts: 9
Last: Feb 22, 2011
[view latest posts]
Level 0
Category: CoD4 Scripting
Posted: Sunday, Feb. 13, 2011 10:53 pm
In a nutshell yes xD

Only problem now is I get the error:

'Shader name string is empty'

My statsTable.csv (new perk at the end):
[
Code:
149,3149,,,,,,,,,
150,150,specialty,PERKS_EAVESDROP,specialty_parabolic,,specialty_parabolic,PERKS_HEAR_VOICE_CHAT_OF_NEARBY,perk3,,PERKS_UNLOCKED_AT_MAJOR_I_LV35
151,151,specialty,PERKS_UAV_JAMMER,specialty_gpsjammer,,specialty_gpsjammer,PERKS_UNDETECTABLE_ON_ENEMY,perk2,,PERKS_UNLOCKED_AT_SERGEANT
152,152,specialty,PERKS_IRON_LUNGS,specialty_holdbreath,,specialty_holdbreath,PERKS_LONGER_BREATH_FOR_STEADIER,perk3,,PERKS_UNLOCKED_AT_2ND_LIEUTENANT
153,153,specialty,PERKS_DEAD_SILENCE,specialty_quieter,,specialty_quieter,PERKS_MAKE_LESS_SOUND_WHEN,perk3,,PERKS_UNLOCKED_AT_BRIGADIER
154,154,specialty,PERKS_EXTREME_CONDITIONING,specialty_longersprint,,specialty_longersprint,PERKS_SPRINT_FOR_LONGER_DISTANCES,perk3,,
155,155,specialty,PERKS_BOMB_SQUAD,specialty_detectexplosive,,specialty_detectexplosive,PERKS_ABILITY_TO_SEEK_OUT_ENEMY,perk1,,PERKS_UNLOCKED_AT_STAFF_SERGEANT
156,156,specialty,PERKS_SONIC_BOOM,specialty_explosivedamage,,specialty_explosivedamage,PERKS_HIGHER_EXPLOSIVE_WEAPON,perk2,,
157,157,specialty,PERKS_LAST_STAND,specialty_pistoldeath,,specialty_pistoldeath,PERKS_PULL_OUT_YOUR_PISTOL,perk3,,PERKS_UNLOCKED_AT_CORPORAL
158,158,specialty,PERKS_MARTYRDOM,specialty_grenadepulldeath,,specialty_grenadepulldeath,PERKS_DROP_A_LIVE_GRENADE_WHEN,perk3,,PERKS_UNLOCKED_AT_GUNNERY_SERGEANT
159,159,specialty,,,,,,,,
160,160,specialty,PERKS_STOPPING_POWER,specialty_bulletdamage,,specialty_bulletdamage,PERKS_INCREASED_BULLET_DAMAGE,perk2,,
161,161,specialty,PERKS_DEEP_IMPACT,specialty_bulletpenetration,,specialty_bulletpenetration,PERKS_DEEPER_BULLET_PENETRATION,perk3,,
162,162,specialty,PERKS_STEADY_AIM,specialty_bulletaccuracy,,specialty_bulletaccuracy,PERKS_INCREASED_HIPFIRE_ACCURACY,perk3,,
163,163,specialty,PERKS_DOUBLE_TAP,specialty_rof,,specialty_rof,PERKS_INCREASED_RATE_OF_FIRE,perk2,,PERKS_UNLOCKED_AT_1ST_LIEUTENANT
164,164,specialty,PERKS_SLEIGHT_OF_HAND,specialty_fastreload,,specialty_fastreload,PERKS_FASTER_RELOADING,perk2,,PERKS_UNLOCKED_AT_MASTER_SERGEANT
165,165,specialty,PERKS_BANDOLIER,specialty_extraammo,,specialty_extraammo,PERKS_EXTRA_AMMUNITION_MAGAZINES,perk1,,PERKS_UNLOCKED_AT_CAPTAIN_I
166,166,specialty,PERKS_OVERKILL,specialty_twoprimaries,,specialty_twoprimaries,PERKS_CARRY_TWO_PRIMARY_WEAPONS,perk2,,PERKS_UNLOCKED_AT_LIEUTENANT
167,167,specialty,PERKS_JUGGERNAUT,specialty_armorvest,,specialty_armorvest,PERKS_INCREASED_HEALTH,perk2,,
168,168,specialty,PERKS_ROCKETPACK,specialty_rocketpack,,specialty_rocketpack,PERKS_ROCKET_BOOST_TO_JUMP,perk1,,


I've got a specialty_rocketpack.iwi in images as well, just tried everything now to get rid of this error to no avail :P
Share |
Samuel033
General Member
Since: Dec 10, 2009
Posts: 484
Last: Dec 25, 2015
[view latest posts]
Level 5
Category: CoD4 Scripting
Posted: Monday, Feb. 14, 2011 12:18 am
Ok. You also need to make a specialty_rocketpack material, which is what the game looks for not the iwi's themselves. Open up the asset manager, create a new material with that name. The material type should be 2d. Source to default (I think), Surfacetypes to none/notineditor. blendfunc to Blend. The color map is your image (must be a targa or dds... dont know about iwis). Leave the rest at the defaults. Put the new material into the mod.csv file (material,specialty_rocketpack).

Just so you know, new perks like that must have _mp at the end of them like clays or rpgs. The game will only recognize the stock perks when it tries to register them, the exceptions being scripted ones like clays. It will have to be
Code:

168,168,specialty,PERKS_ROCKETPACK,specialty_rocketpack_mp,,specialty_rocketpack,PERKS_ROCKET_BOOST_TO_JUMP,perk1,,


Also there are a few functions (like setPerk) that will not work with them. So you may have to add various checks in the relevant scripts. The usual 'getPerk' checks will not work. It will require setting a flag on the player and checking for that.
Share |
zeroy
General Member
Since: Nov 26, 2007
Posts: 1060
Last: Mar 12, 2014
[view latest posts]
Level 8
Category: CoD4 Scripting
Posted: Monday, Feb. 14, 2011 10:09 am
Do you prechache the shader? if not do before any main statement:

Code:
PrechacheShader("specialty_rocketpack");


Also, make sure to add the new material to the Mod.csv:

Code:
material,specialty_rocketpack


Edit:

_class.gsc already should precache it...

Code:

precacheShader( level.perkIcons[level.tbl_PerkData[i]["reference_full"]] );


Note that reference_null is the sixth column in statstable.csv (starts at 0)

edited on Feb. 14, 2011 05:11 am by zeroy
Share |
[aL]RogeR
General Member
Since: Feb 13, 2011
Posts: 9
Last: Feb 22, 2011
[view latest posts]
Level 0
Category: CoD4 Scripting
Posted: Monday, Feb. 14, 2011 05:52 pm
Still not working after changing it to have _mp at the end, I already made the icon with those exact settings but still no change. :P

Zeroy, my precacheshader line in _class is different to yours being just
Code:
precacheShader( level.perkIcons[perkRef] );
and if I change it to the one you had then it just gives undefined variable i.

Rather frustrating, but the help is greatly appreciated from both of you :)

Zeroy btw is your site down I can't seem to access it.

edited on Feb. 14, 2011 01:19 pm by [aL]RogeR
Share |
Samuel033
General Member
Since: Dec 10, 2009
Posts: 484
Last: Dec 25, 2015
[view latest posts]
Level 5
Category: CoD4 Scripting
Posted: Monday, Feb. 14, 2011 06:42 pm
Perk icon shaders are all already precached in _class as the perk data is read from the table. No need to add it elsewhere. Do you have a new initPerkData() entry in class?
Share |
[aL]RogeR
General Member
Since: Feb 13, 2011
Posts: 9
Last: Feb 22, 2011
[view latest posts]
Level 0
Category: CoD4 Scripting
Posted: Monday, Feb. 14, 2011 06:52 pm
I've got one:

Code:
initPerkData( "specialty_rocketpack_mp" );
:)

Just to make sure, where should the statsTable.csv go in my mod. I presume Mods/[modname]/mp but dunno :P


edited on Feb. 14, 2011 02:02 pm by [aL]RogeR
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

»