#pragma once

#ifdef GAMEQC
MODEL(HOOK, "models/hook.md3");
MODEL(HOOK_VIEW, W_Model("h_hookgun.iqm"));
MODEL(HOOK_WORLD, W_Model("v_hookgun.md3"));
MODEL(HOOK_ITEM, W_Model("g_hookgun.md3"));

SOUND(HOOKBOMB_FIRE, W_Sound("hookbomb_fire"));
SOUND(HOOKBOMB_IMPACT, W_Sound("hookbomb_impact"));
SOUND(HOOK_FIRE, W_Sound("hook_fire"));
SOUND(HOOK_IMPACT, W_Sound("hook_impact"));
#endif

CLASS(Hook, Weapon)
#ifdef SVQC
/* spawnfunc */ ATTRIB(Hook, m_canonical_spawnfunc, string, "weapon_hook");
/* rating    */ ATTRIB(Hook, bot_pickupbasevalue, float, 0);
#endif
/* ammotype  */ ATTRIB(Hook, ammo_type, Resource, RES_FUEL);
/* impulse   */ ATTRIB(Hook, impulse, int, 0);
/* flags     */ ATTRIB(Hook, spawnflags, int, WEP_FLAG_CANCLIMB | WEP_TYPE_SPLASH | WEP_FLAG_NOTRUEAIM);
/* color     */ ATTRIB(Hook, m_color, vector, '0.471 0.817 0.392');
#ifdef GAMEQC
/* modelname */ ATTRIB(Hook, mdl, string, "hookgun");
/* model     */ ATTRIB(Hook, m_model, Model, MDL_HOOK_ITEM);
/* flash mdl */ ATTRIB(Hook, m_muzzlemodel, Model, MDL_Null);
/* flash eff */ ATTRIB(Hook, m_muzzleeffect, entity, EFFECT_HOOK_MUZZLEFLASH);
#endif
#ifdef CSQC
/* crosshair */ ATTRIB(Hook, w_crosshair, string, "gfx/crosshairhook");
/* crosshair */ ATTRIB(Hook, w_crosshair_size, float, 0.5);
#endif
/* wepimg    */ ATTRIB(Hook, model2, string, "weaponhook");
/* refname   */ ATTRIB(Hook, netname, string, "hook");
/* wepname   */ ATTRIB(Hook, m_name, string, _("Grappling Hook"));
	ATTRIB(Hook, ammo_factor, float, 1);

#define X(BEGIN, P, END, class, prefix) \
	BEGIN(class) \
		P(class, prefix, ammo, float, PRI) \
		P(class, prefix, animtime, float, BOTH) \
		P(class, prefix, damageforcescale, float, SEC) \
		P(class, prefix, damage, float, SEC) \
		P(class, prefix, duration, float, SEC) \
		P(class, prefix, edgedamage, float, SEC) \
		P(class, prefix, force, float, SEC) \
		P(class, prefix, gravity, float, SEC) \
		P(class, prefix, health, float, SEC) \
		P(class, prefix, hooked_ammo, float, PRI) \
		P(class, prefix, hooked_time_free, float, PRI) \
		P(class, prefix, hooked_time_max, float, PRI) \
		P(class, prefix, lifetime, float, SEC) \
		P(class, prefix, pickup_ammo, float, NONE) \
		P(class, prefix, power, float, SEC) \
		P(class, prefix, radius, float, SEC) \
		P(class, prefix, refire, float, BOTH) \
		P(class, prefix, speed, float, SEC) \
		P(class, prefix, switchdelay_drop, float, NONE) \
		P(class, prefix, switchdelay_raise, float, NONE) \
		P(class, prefix, weaponreplace, string, NONE) \
		P(class, prefix, weaponstartoverride, float, NONE) \
		P(class, prefix, weaponstart, float, NONE) \
		P(class, prefix, weaponthrowable, float, NONE) \
	END()
	W_PROPS(X, Hook, hook)
#undef X

ENDCLASS(Hook)
REGISTER_WEAPON(HOOK, NEW(Hook));

SPAWNFUNC_WEAPON(weapon_hook, WEP_HOOK)

#ifdef SVQC
CLASS(OffhandHook, OffhandWeapon)
	METHOD(OffhandHook, offhand_think, void(OffhandHook this, entity actor, bool key_pressed))
	{
		Weapon wep = WEP_HOOK;
		.entity weaponentity = weaponentities[1];
		wep.wr_think(wep, actor, weaponentity, key_pressed ? 1 : 0);
	}
ENDCLASS(OffhandHook)
OffhandHook OFFHAND_HOOK;
STATIC_INIT(OFFHAND_HOOK)
{
	OFFHAND_HOOK = NEW(OffhandHook);
}

.float dmg;
.float dmg_edge;
.float dmg_radius;
.float dmg_force;
.float dmg_last;
.float hook_refire;
.float hook_time_hooked;
.float hook_time_fueldecrease;
#endif
