#pragma once

#ifdef GAMEQC
MODEL(PORTAL, "models/portal.md3");
MODEL(PORTO_VIEW, W_Model("h_porto.iqm"));
MODEL(PORTO_WORLD, W_Model("v_porto.md3"));
MODEL(PORTO_ITEM, W_Model("g_porto.md3"));

SOUND(PORTO_BOUNCE, "porto/bounce");
SOUND(PORTO_CREATE, "porto/create");
SOUND(PORTO_EXPIRE, "porto/expire");
SOUND(PORTO_EXPLODE, "porto/explode");
SOUND(PORTO_FIRE, "porto/fire");
SOUND(PORTO_UNSUPPORTED, "porto/unsupported");
#endif

CLASS(PortoLaunch, Weapon)
#ifdef SVQC
/* spawnfunc */ ATTRIB(PortoLaunch, m_canonical_spawnfunc, string, "weapon_porto");
/* rating    */ ATTRIB(PortoLaunch, bot_pickupbasevalue, float, 0);
#endif
/* ammotype  */ ATTRIB(PortoLaunch, ammo_type, Resource, RES_NONE);
/* impulse   */ ATTRIB(PortoLaunch, impulse, int, 0);
/* flags     */ ATTRIB(PortoLaunch, spawnflags, int, WEP_TYPE_OTHER | WEP_FLAG_SUPERWEAPON | WEP_FLAG_NODUAL | WEP_FLAG_NOTRUEAIM);
/* color     */ ATTRIB(PortoLaunch, m_color, vector, '0.404 0.545 0.937');
#ifdef GAMEQC
/* modelname */ ATTRIB(PortoLaunch, mdl, string, "porto");
/* model     */ ATTRIB(PortoLaunch, m_model, Model, MDL_PORTO_ITEM);
#endif
#ifdef CSQC
/* crosshair */ ATTRIB(PortoLaunch, w_crosshair, string, "gfx/crosshairporto");
/* crosshair */ ATTRIB(PortoLaunch, w_crosshair_size, float, 0.6);
#endif
/* wepimg    */ ATTRIB(PortoLaunch, model2, string, "weaponporto");
/* refname   */ ATTRIB(PortoLaunch, netname, string, "porto");
/* wepname   */ ATTRIB(PortoLaunch, m_name, string, _("Port-O-Launch"));

#define X(BEGIN, P, END, class, prefix) \
	BEGIN(class) \
		P(class, prefix, animtime, float, BOTH) \
		P(class, prefix, lifetime, float, BOTH) \
		P(class, prefix, refire, float, BOTH) \
		P(class, prefix, secondary, float, NONE) \
		P(class, prefix, speed, float, BOTH) \
		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, PortoLaunch, porto)
#undef X

ENDCLASS(PortoLaunch)
REGISTER_WEAPON(PORTO, NEW(PortoLaunch));

SPAWNFUNC_WEAPON(weapon_porto, WEP_PORTO)

#ifdef CSQC
void Porto_Draw(entity this);
#endif

#ifdef SVQC
.entity porto_current;
.vector porto_v_angle; // holds "held" view angles
.float porto_v_angle_held;
.vector right_vector;
.float porto_forbidden;

void W_Porto_Fail(entity this, bool failhard);
void W_Porto_Remove (entity p);
#endif
