Sources/CryGame C++/Solution1/CryGame/ScriptObjectWeaponClass.cpp
//////////////////////////////////////////////////////////////////////
/*! Adds a set of fire-parameters
@param pObj table of fireparams (accuracy, ammo, max_ammo, reload_time, fire_rate, distance, damage, blast_radius, bullet_per_shot, instant, projectile_mass, projectile_size, projectile_velocity, acc_thrust, acc_lift, air_resistance, gravity, surface_idx, projectile_class, fx, fy, bullets_per_clip)
*/
Adds a set of fire-parameters
Adds a set of fire - parameters
int CScriptObjectWeaponClass::SetWeaponFireParams(IFunctionHandler *pH)
{
	CHECK_PARAMETERS(1);
	_SmartScriptObject pObj(m_pScriptSystem,true);
	WeaponParams s;
	s.fDamageDropPerMeters=0;
	pH->GetParam(1,*pObj);
	pObj->BeginSetGetChain();
	pObj->GetValueChain( "ai_mode",					s.bAIMode );
	pObj->GetValueChain( "allow_hold_breath",s.bAllowHoldBreath);
	pObj->GetValueChain( "auto_aiming_dist",s.fAutoAimDist );
	pObj->GetValueChain( "min_accuracy",		s.fMinAccuracy );
	pObj->GetValueChain( "max_accuracy",		s.fMaxAccuracy );
	pObj->GetValueChain( "aim_improvement",	s.fAimImprovement );
	pObj->GetValueChain( "sprint_penalty",	s.fSprintPenalty );
	pObj->GetValueChain( "aim_recoil_modifier",	s.fAimRecoilModifier );
	pObj->GetValueChain( "reload_time",			s.fReloadTime );
	pObj->GetValueChain( "fire_rate",				s.fFireRate );
	pObj->GetValueChain( "tap_fire_rate",		s.fTapFireRate );
	pObj->GetValueChain( "distance",				s.fDistance );
	pObj->GetValueChain( "damage",					s.nDamage );
	pObj->GetValueChain( "damage_drop_per_meter",s.fDamageDropPerMeters );
	pObj->GetValueChain( "bullet_per_shot",	s.nBulletpershot );
	pObj->GetValueChain( "fire_mode_type",	s.iFireModeType );
	pObj->GetValueChain( "shoot_underwater",s.bShootUnderwater );
	pObj->GetValueChain( "accuracy_modifier_standing", s.fAccuracyModifierStanding );
	pObj->GetValueChain( "accuracy_modifier_crouch", s.fAccuracyModifierCrouch );
	pObj->GetValueChain( "accuracy_modifier_prone", s.fAccuracyModifierProne );
	pObj->GetValueChain( "recoil_modifier_standing", s.fRecoilModifierStanding );
	pObj->GetValueChain( "recoil_modifier_crouch", s.fRecoilModifierCrouch );
	pObj->GetValueChain( "recoil_modifier_prone", s.fRecoilModifierProne );
	const char *sClass = NULL;
	pObj->GetValueChain( "projectile_class", sClass);
	if (sClass)
		s.sProjectileClass = sClass;
	pObj->GetValueChain( "bullets_per_clip",			s.iBulletsPerClip);
	pObj->GetValueChain( "fire_activation",			s.fire_activation);
	pObj->GetValueChain( "min_recoil",			s.min_recoil);
	pObj->GetValueChain( "max_recoil",			s.max_recoil);
	pObj->GetValueChain( "no_ammo",			s.no_ammo);
	pObj->GetValueChain( "accuracy_decay_on_run",			s.accuracy_decay_on_run);
	if (!pObj->GetValueChain( "whizz_sound_radius",			s.whizz_sound_radius))
		s.whizz_sound_radius=0.0f;
	s.whizz_sound_radius*=s.whizz_sound_radius;	
	if (!pObj->GetValueChain( "iImpactForceMul",			s.iImpactForceMul))
		s.iImpactForceMul = 2;
	if (!pObj->GetValueChain( "iImpactForceMulFinal",			s.iImpactForceMulFinal))
		s.iImpactForceMulFinal = 10;
	if (!pObj->GetValueChain( "iImpactForceMulFinalTorso",			s.iImpactForceMulFinalTorso))
		s.iImpactForceMulFinalTorso = 0;
	pObj->EndSetGetChain();
	int nFireParamIndex=m_vFireParams.size();
	CScriptObjectFireParam *pFireParamObj=new CScriptObjectFireParam;
	WeaponParams *pReadAddress=m_pWeaponClass->AddWeaponParams( s );
	pFireParamObj->Create(m_pScriptSystem,pReadAddress);
	m_vFireParams.push_back(pFireParamObj);
	pFireParamObj->GetScriptObject()->Clone(pObj);
	_SmartScriptObject soCnt(m_pScriptSystem, true);
	if (m_pScriptThis->GetValue("cnt", soCnt))
	{
		soCnt->SetAt(nFireParamIndex, pFireParamObj->GetScriptObject());
	}
	return pH->EndFunction();
}
int CScriptObjectWeaponClass :: SetWeaponFireParams ( IFunctionHandler * pH ) { CHECK_PARAMETERS ( 1 ) ; _SmartScriptObject pObj ( m_pScriptSystem , true ) ; WeaponParams s ; s . fDamageDropPerMeters = 0 ; pH -> GetParam ( 1 , * pObj ) ; pObj -> BeginSetGetChain ( ) ; pObj -> GetValueChain ( " " , s . bAIMode ) ; pObj -> GetValueChain ( " " , s . bAllowHoldBreath ) ; pObj -> GetValueChain ( " " , s . fAutoAimDist ) ; pObj -> GetValueChain ( " " , s . fMinAccuracy ) ; pObj -> GetValueChain ( " " , s . fMaxAccuracy ) ; pObj -> GetValueChain ( " " , s . fAimImprovement ) ; pObj -> GetValueChain ( " " , s . fSprintPenalty ) ; pObj -> GetValueChain ( " " , s . fAimRecoilModifier ) ; pObj -> GetValueChain ( " " , s . fReloadTime ) ; pObj -> GetValueChain ( " " , s . fFireRate ) ; pObj -> GetValueChain ( " " , s . fTapFireRate ) ; pObj -> GetValueChain ( " " , s . fDistance ) ; pObj -> GetValueChain ( " " , s . nDamage ) ; pObj -> GetValueChain ( " " , s . fDamageDropPerMeters ) ; pObj -> GetValueChain ( " " , s . nBulletpershot ) ; pObj -> GetValueChain ( " " , s . iFireModeType ) ; pObj -> GetValueChain ( " " , s . bShootUnderwater ) ; pObj -> GetValueChain ( " " , s . fAccuracyModifierStanding ) ; pObj -> GetValueChain ( " " , s . fAccuracyModifierCrouch ) ; pObj -> GetValueChain ( " " , s . fAccuracyModifierProne ) ; pObj -> GetValueChain ( " " , s . fRecoilModifierStanding ) ; pObj -> GetValueChain ( " " , s . fRecoilModifierCrouch ) ; pObj -> GetValueChain ( " " , s . fRecoilModifierProne ) ; const char * sClass = NULL ; pObj -> GetValueChain ( " " , sClass ) ; if ( sClass ) s . sProjectileClass = sClass ; pObj -> GetValueChain ( " " , s . iBulletsPerClip ) ; pObj -> GetValueChain ( " " , s . fire_activation ) ; pObj -> GetValueChain ( " " , s . min_recoil ) ; pObj -> GetValueChain ( " " , s . max_recoil ) ; pObj -> GetValueChain ( " " , s . no_ammo ) ; pObj -> GetValueChain ( " " , s . accuracy_decay_on_run ) ; if ( ! pObj -> GetValueChain ( " " , s . whizz_sound_radius ) ) s . whizz_sound_radius = 0.0f ; s . whizz_sound_radius *= s . whizz_sound_radius ; if ( ! pObj -> GetValueChain ( " " , s . iImpactForceMul ) ) s . iImpactForceMul = 2 ; if ( ! pObj -> GetValueChain ( " " , s . iImpactForceMulFinal ) ) s . iImpactForceMulFinal = 10 ; if ( ! pObj -> GetValueChain ( " " , s . iImpactForceMulFinalTorso ) ) s . iImpactForceMulFinalTorso = 0 ; pObj -> EndSetGetChain ( ) ; int nFireParamIndex = m_vFireParams . size ( ) ; CScriptObjectFireParam * pFireParamObj = new CScriptObjectFireParam ; WeaponParams * pReadAddress = m_pWeaponClass -> AddWeaponParams ( s ) ; pFireParamObj -> Create ( m_pScriptSystem , pReadAddress ) ; m_vFireParams . push_back ( pFireParamObj ) ; pFireParamObj -> GetScriptObject ( ) -> Clone ( pObj ) ; _SmartScriptObject soCnt ( m_pScriptSystem , true ) ; if ( m_pScriptThis -> GetValue ( " " , soCnt ) ) { soCnt -> SetAt ( nFireParamIndex , pFireParamObj -> GetScriptObject ( ) ) ; } return pH -> EndFunction ( ) ; }
Adds a set of fire-parameters
Adds a set of fire - parameters
// accuracy and recoil modifier
 // projectile
 // keep it squared
