
 public Bubble_Beam(id, skill, prop)
 {
	new level = PlayersLevel(id,PlayersActive[id])
	new Float:bubdamage = float(BUBBLE_BEAM_DAMAGE)

	new in_water = entity_in_water(id)

	if ( in_water ){
		new bubnum = DEFAULT_BUBBLES
		bubnum += level
		bubbles[id] = bubnum
	}
	if(bubbles[id] > 0){

		new Float:f_sorigin[3], Float:f_aimvec[3], aimvec[3];
		new bubsnum;

		get_user_origin(id, origin[id])
		get_user_origin(id, aimvec, 2)
		IVecFVec(aimvec, f_aimvec)

		bubsnum = get_distance(origin[id], aimvec)/15

		poke_sound(id, CHAN_VOICE, SND_SWIM)

		if ( !in_water ){
			bubbles[id]--

			message_begin(MSG_BROADCAST, SVC_TEMPENTITY)	//message begin
			write_byte(15)
			write_coord(origin[id][0])		// start position
			write_coord(origin[id][1])
			write_coord(origin[id][2])
			write_coord(aimvec[0])	// end position
			write_coord(aimvec[1])
			write_coord(aimvec[2])
			write_short(SPRITE_INDEX[SPR_BUBBLE])		// sprite index
			write_byte(bubsnum/2)		// count
			write_byte(1/2)		// life in 0.1's
			write_byte(5)		// scale in 0.1's
			write_byte(5)		// velocity along vector in 10's
			write_byte(5)	// randomness of velocity in 10's
			message_end()

			IVecFVec(origin[id], f_sorigin)

			skillLinedamage(id, f_sorigin, f_aimvec, level, floatround(bubdamage), skill)
		}
		else {
			message_begin(MSG_BROADCAST, SVC_TEMPENTITY) //message begin
			write_byte(114)
			write_coord(origin[id][0])				// min start position
			write_coord(origin[id][1])
			write_coord(origin[id][2])
			write_coord(aimvec[0])			// max start position
			write_coord(aimvec[1])
			write_coord(aimvec[2])
			write_coord(20)	// float height
			write_short(SPRITE_INDEX[SPR_BUBBLE])				// model index
			write_byte(bubsnum)					// count
			write_coord(100)				// speed
			message_end()

			IVecFVec(origin[id], f_sorigin)

			skillLinedamage(id, f_sorigin, f_aimvec, level, floatround(bubdamage), skill)
		}

		poke_print(id,print_center,"Masz %d %ss", bubbles[id], SkillToName(skill) )
		return PLUGIN_HANDLED;
	}
	else {
		poke_print(id, print_chat, "Nie masz juz %s, wejdz do wody i zregeneruj.", SkillToName(skill) )
		sound_deny(id)
		g_StopSkill[id] = true;
	}
	return PLUGIN_CONTINUE;
 }
 public Water_Gun(id, skill, prop)
 {
	new level = PlayersLevel(id,PlayersActive[id])
	new Float:bubdamage = float(BUBBLE_BEAM_DAMAGE)
	bubdamage *= WATER_GUN_DAM_MULT	//because it shoots 10 times faster we make it weaker

	new in_water = entity_in_water(id)

	if ( in_water ){
		new bubnum = DEFAULT_BUBBLES
		bubnum *= WATER_GUN_NUM_MULT
		bubnum += level
		bubbles[id] = bubnum
	}
	if(bubbles[id] > 0){

		new Float:f_sorigin[3], sorigin[3], Float:f_aimvec[3], aimvec[3];
		new bubsnum;

		get_user_origin(id, origin[id])
		get_user_origin(id, aimvec, 2)
		IVecFVec(aimvec, f_aimvec)

		bubsnum = get_distance(origin[id], aimvec)/15

		poke_sound(id, CHAN_VOICE, SND_SWIM)

		if ( !in_water ){
			bubbles[id]--

			f_sorigin[0] = float(origin[id][0])
			f_sorigin[1] = float(origin[id][1])
			f_sorigin[2] = float(origin[id][2])

			FVecIVec(f_sorigin, sorigin)

			skillLinedamage(id, f_sorigin, f_aimvec, level, floatround(bubdamage), skill)
			MakeLine(0,sorigin,aimvec,SPRITE_INDEX[SPR_ZBEAM6],1,1,1,50+level,0,0,0,255,255,0)

			end_rep_use(id, skill, 1.0)
			poke_print(id,print_center,"Masz %d %ss", bubbles[id], SkillToName(skill) )
			return PLUGIN_CONTINUE;
		}
		else {
			message_begin(MSG_BROADCAST, SVC_TEMPENTITY) //message begin
			write_byte(114)
			write_coord(origin[id][0])				// min start position
			write_coord(origin[id][1])
			write_coord(origin[id][2])
			write_coord(aimvec[0])			// max start position
			write_coord(aimvec[1])
			write_coord(aimvec[2])
			write_coord(20)	// float height
			write_short(SPRITE_INDEX[SPR_BUBBLE])				// model index
			write_byte(bubsnum)					// count
			write_coord(100)				// speed
			message_end()

			IVecFVec(origin[id], f_sorigin)

			skillLinedamage(id, f_sorigin, f_aimvec, level, floatround(bubdamage), skill)
		}

		return PLUGIN_HANDLED;
	}
	else {
		poke_print(id, print_chat, "Nie masz juz %s, wejdz do wody i zregeneruj.", SkillToName(skill) )
		sound_deny(id)
		g_StopSkill[id] = true;
	}
	return PLUGIN_CONTINUE;
 }
 public Hydro_Pump(id, skill, prop)
 {
	new level = PlayersLevel(id,PlayersActive[id])
	new Float:bubdamage = float(BUBBLE_BEAM_DAMAGE)
	bubdamage *= HYDRO_PUMP_DAM_MULT	//because it shoots 2 waterguns, we need to make it weaker than watergun

	new in_water = entity_in_water(id)

	if ( in_water ){
		new bubnum = DEFAULT_BUBBLES
		bubnum *= HYDRO_PUMP_NUM_MULT
		bubnum += level
		bubbles[id] = bubnum
	}
	if(bubbles[id] > 0){

		new Float:f_sorigin[2][3], sorigin[2][3], Float:f_aimvec[3], aimvec[3];
		new bubsnum;

		get_user_origin(id, origin[id])
		get_user_origin(id, aimvec, 2)
		IVecFVec(aimvec, f_aimvec)

		bubsnum = get_distance(origin[id], aimvec)/15

		poke_sound(id, CHAN_VOICE, SND_SWIM)

		if ( !in_water ){
			bubbles[id]--

			new Float:velocity[3]
			velocity_by_aim(id, 20, velocity)

			f_sorigin[0][0] = origin[id][0] + velocity[1]
			f_sorigin[0][1] = origin[id][1] - velocity[0]
			f_sorigin[0][2] = origin[id][2] + 20.0
			f_sorigin[1][0] = origin[id][0] - velocity[1]
			f_sorigin[1][1] = origin[id][1] + velocity[0]
			f_sorigin[1][2] = origin[id][2] + 20.0

			FVecIVec(f_sorigin[0], sorigin[0])
			FVecIVec(f_sorigin[1], sorigin[1])

			for(new i=0; i<2; i++){
				skillLinedamage(id, f_sorigin[i], f_aimvec, level, floatround(bubdamage), skill)
				MakeLine(0,sorigin[i],aimvec,SPRITE_INDEX[SPR_ZBEAM6],1,1,1,50+level,0,0,0,255,255,0)
			}

			end_rep_use(id, skill, 1.0)
			poke_print(id,print_center,"Masz %d %ss", bubbles[id], SkillToName(skill) )
			return PLUGIN_CONTINUE;
		}
		else {
			message_begin(MSG_BROADCAST, SVC_TEMPENTITY) //message begin
			write_byte(114)
			write_coord(origin[id][0])				// min start position
			write_coord(origin[id][1])
			write_coord(origin[id][2])
			write_coord(aimvec[0])			// max start position
			write_coord(aimvec[1])
			write_coord(aimvec[2])
			write_coord(20)	// float height
			write_short(SPRITE_INDEX[SPR_BUBBLE])				// model index
			write_byte(bubsnum)					// count
			write_coord(100)				// speed
			message_end()

			IVecFVec(origin[id], f_sorigin[0])

			skillLinedamage(id, f_sorigin[0], f_aimvec, level, floatround(bubdamage), skill)
		}

		poke_print(id,print_center,"Masz %d %ss", bubbles[id], SkillToName(skill) )
		return PLUGIN_HANDLED;
	}
	else {
		poke_print(id, print_chat, "Nie masz juz %s, wejdz do wody i zregeneruj.", SkillToName(skill) )
		sound_deny(id)
		g_StopSkill[id] = true;
	}
	return PLUGIN_CONTINUE;
 }
 public Surf(id, skill, prop)
 {
	new level = PlayersLevel(id,PlayersActive[id])
	new Float:surf_origin[3]
	new surf_ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target"))
	set_pev(surf_ent, pev_classname, "pokemod_ent")
	set_pev(surf_ent, pev_owner, id)

	//lets use origin multiple times for the heck of not creating more variables (and im lazy)
	pev(id, pev_origin, surf_origin)
	engfunc(EngFunc_SetOrigin, surf_ent, surf_origin)

	pev(id, pev_angles, surf_origin)
	surf_origin[1] -=90			//my stupidity when making the model, so lets rotate it so it looks correct
	if(surf_origin[1]<-180)
		surf_origin[1] += 360
	surf_origin[0] = 0.0
	surf_origin[2] = 0.0
	set_pev(surf_ent, pev_angles, surf_origin)

	new while_time = 0
	velocity_by_aim(id, level*5, surf_origin)
	while(floatsqroot(surf_origin[0]*surf_origin[0] + surf_origin[1]*surf_origin[1])<level*5 && while_time<level){
		surf_origin[0] *= 1.1
		surf_origin[1] *= 1.1
		while_time++		//lets only do this so many times
	}
	surf_origin[2] = 0.0
	set_pev(surf_ent, pev_velocity, surf_origin)

	engfunc(EngFunc_SetModel, surf_ent, MODELS[MDL_SURF])
	set_pev(surf_ent, pev_scale, 1.0)

	set_pev(surf_ent, pev_movetype, MOVETYPE_NOCLIP)
	set_pev(surf_ent, pev_solid, SOLID_BBOX)

	set_pev(surf_ent, pev_maxs, Float:{100.0,100.0,30.0})
	set_pev(surf_ent, pev_mins, Float:{-100.0,-100.0,-30.0})

	set_task(0.1,"check_wave",surf_ent)
	return PLUGIN_HANDLED;
 }
 public check_wave(ent)
 {
	if(!pev_valid(ent))
		return
	new aid = pev(ent, pev_owner)

	new shortestDistance = 9999
	new distance, players[32], pnum
	new wave_dist = SURF_DISTANCE
	AddLvl(aid, wave_dist)

	// Find all alive enemies
	poke_get_players(players, pnum, "ag")
	new enemy

	// Find the closest enemy
	for( new i = 0; i < pnum; i++ ){
		enemy = players[i]
		if(!pev_valid(ent))
			return
		if(!pev_valid(enemy))
			continue

		#if SURF_DUCK==1
		if( pev(enemy,pev_button) & IN_DUCK )
			continue
		#endif

		distance = fm_get_entity_distance(enemy, ent)

		if ( distance <= shortestDistance ) {
			shortestDistance = distance
		}
		if( distance <= wave_dist ){
			surf_touch(ent, enemy)
		}
	}
	if( shortestDistance>=9999 || (is_user_alive(aid) && fm_get_entity_distance(aid, ent)>1000)){
		fm_remove_entity(ent)
		return
	}
	set_task(0.1, "check_wave", ent)
	poke_sound(ent, CHAN_VOICE, SND_WADE)
 }
 public Withdraw(id, skill, prop)
 {
	Repair(id, WITHDRAW*PlayersLevel(id,-1));
	return PLUGIN_HANDLED;
 }
 public Bubble(id, skill, prop)
 {
	if( entity_in_water(id) ){
		new Float:air_done;
		pev( id, pev_air_finished, air_done );
		set_pev( id, pev_air_finished, air_done + 2.0 );

		new Float:fOrigin[3], Float:fVelocity[3]
		pev(id, pev_origin, fOrigin)
		velocity_by_aim(id, 35, fVelocity)
		
		new Float:fTemp[3], iFireOrigin[3]
		xs_vec_add(fOrigin, fVelocity, fTemp)
		FVecIVec(fTemp, iFireOrigin)

		new Float:fFireVelocity[3], iFireVelocity[3]
		velocity_by_aim(id, 35, fFireVelocity)
		FVecIVec(fFireVelocity, iFireVelocity)

		new parm[7]
		parm[0] = iFireOrigin[0]
		parm[1] = iFireOrigin[1]
		parm[2] = iFireOrigin[2]
		parm[3] = iFireVelocity[0]
		parm[4] = iFireVelocity[1]
		parm[5] = iFireVelocity[2]
		parm[6] = SPRITE_INDEX[SPR_BUBBLE]
		create_sprite_spray( parm )

		poke_sound(id, CHAN_VOICE, SND_SWIM)

		return PLUGIN_HANDLED;
	}
	return PLUGIN_CONTINUE;
 }
 public Crabhammer(id, skill, prop)
 {
	new damage, weapon, victim = PokeSkillTarget(id, damage, weapon);
	if( is_user_alive(victim) && knife_weapon( weapon ) && MaxChance(id, damage) ){
		skilldamage( victim, id, (damage*CRAB_HAMMER-damage), skill );
		return PLUGIN_HANDLED;
	}
	return PLUGIN_CONTINUE;
 }
 public Waterfall(id, skill, prop)
 {
	if( !PassTest(id, 1) )
		return PLUGIN_CONTINUE;

	new Float:f_aimvec[3];
	get_user_origin(id, origin[id]);
	get_user_origin(id, aim[id], 3);
	if(-50>aim[id][0]-origin[id][0]>50)			//only change it if they are at least that far away
		aim[id][0] += ( ( aim[id][0] - origin[id][0] > 0 ) ? -50 : 50 );
	if(-50>aim[id][1]-origin[id][1]>50)			//only change it if they are at least that far away
		aim[id][1] += ( ( aim[id][1] - origin[id][1] > 0 ) ? -50 : 50 );
	if(-50>aim[id][2]-origin[id][2]>50)			//only change it if they are at least that far away
		aim[id][2] += ( ( aim[id][2] - origin[id][2] > 0 ) ? -50 : 50 );
	else
		aim[id][2] += 40;
	IVecFVec(aim[id], f_aimvec);

	new ent = fm_create_entity("info_target");
	set_pev( ent, pev_classname, "pokemod_ent");
	fm_entity_set_model(ent, MODELS[MDL_ROCK]);
	fm_entity_set_origin(ent, f_aimvec);
	set_pev( ent, pev_rendermode, 5);
	set_pev( ent, pev_renderamt, 255.0);
	set_pev( ent, pev_scale, 1.20);
	set_pev( ent, pev_owner, id);

	new parm[3]
	parm[0] = ent;
	parm[1] = skill;
	parm[2] = WATERFALL_TIME * 10;
	AddLvl(id, parm[2]);

	check_waterfall(parm)

	return PLUGIN_HANDLED;
 }
 