<%@ Template Language="C#" TargetLanguage="gta2mis" Description="Demonstrates the most basic template." %>    	
<%@ Property Name="PlayerCount" Type="System.Int32" Default="6" Category="Options" Description="This is the amount of players that this script should support." %>
<%@ Property Name="Author" Type="System.String" Default="anybody" Category="Options" Description="Author" %>
<%@ Property Name="Mapname" Type="System.String" Default="anymap" Category="Options" Description="Map name" %>
<%@ Property Name="Base" Type="System.String" Default="any" Category="Options" Description="base file name without extension" %>
<%@ Property Name="Mode" Type="System.String" Default="any" Category="Options" Description="the game mode" %>
<%@ Property Name="submode" Type="Submode" Default="normal" Category="Options" Description="the map size" %>
<script runat="template">
public enum Submode {
    normal,
    tiny,
    nano
}</script>
//{ //Header
// <%=Mapname%>
// script and map by <%=Author%>
// for details look at <%=Base%>_readme.txt 
// <%=Base%>.mis Compiled by <%=Author%> on <%= DateTime.Now.ToLongDateString() %> with codesmith

// addons:
//#region header
//#endregion 
//}

//{ //Declares
//{ //PlayerDefines
<% if (submode == Submode.normal || submode == Submode.nano) { %>
<% if (PlayerCount>=1) { %>PLAYER_PED p1 = (54.01, 55.0, 7.0) 10 90	<% } %>
<% if (PlayerCount>=2) { %>PLAYER_PED p2 = (55.99, 55.0, 7.0) 11 270<% } %>
<% if (PlayerCount>=3) { %>PLAYER_PED p3 = (54.01, 54.0, 7.0) 12 45	<% } %>
<% if (PlayerCount>=4) { %>PLAYER_PED p4 = (55.99, 56.0, 7.0) 13 225<% } %>
<% if (PlayerCount>=5) { %>PLAYER_PED p5 = (54.01, 56.0, 7.0) 14 135<% } %>
<% if (PlayerCount>=6) { %>PLAYER_PED p6 = (55.99, 54.0, 7.0) 15 315<% } %>
<% } %>
<% if (submode == Submode.tiny) { %>
<% if (PlayerCount>=1) { %>PLAYER_PED p1 = (53.5, 55.5, 255.0) 10 90 <% } %>
<% if (PlayerCount>=2) { %>PLAYER_PED p2 = (55.5, 55.5, 255.0) 11 270<% } %>
<% if (PlayerCount>=3) { %>PLAYER_PED p3 = (53.5, 54.5, 255.0) 12 45 <% } %>
<% if (PlayerCount>=4) { %>PLAYER_PED p4 = (55.5, 56.5, 255.0) 13 225<% } %>
<% if (PlayerCount>=5) { %>PLAYER_PED p5 = (53.5, 56.5, 255.0) 14 135<% } %>
<% if (PlayerCount>=6) { %>PLAYER_PED p6 = (55.5, 54.5, 255.0) 15 315<% } %>
<% } %>
//}

//{ //PlayerDeclares
<% for(int i=1;i<=PlayerCount;i++){%>
    //{ //Player<%=i%>
    //#region player_declare
	//#endregion
	
	COUNTER p<%=i%>_expunch = 1
    COUNTER p<%=i%>_trg_punched = 0
    CHAR_DATA p<%=i%>_punched
    COUNTER p<%=i%>_trg_gren = 0
    //}

<% } %>
//}

//#region declare
//#endregion

//{ //Powerups
<% if (submode == Submode.normal) { %>
GENERATOR elec_1 = (57.0, 57.0, 7.0) 0 COLLECT_03 400 400 1
GENERATOR grenade_1 = (57.0, 53.0, 7.0) 0 COLLECT_04 400 400 99
GENERATOR fastr_1 = (53.0, 53.0, 7.0) 0 COLLECT_36 400 400 1
GENERATOR molotov_1 = (53.0, 57.0, 7.0) 0 COLLECT_05 400 400 99
<% } %>
<% if (submode == Submode.nano) { %>
GENERATOR elec_1 = (56.0, 56.0, 7.0) 0 COLLECT_03 400 400 1
GENERATOR grenade_1 = (56.0, 54.0, 7.0) 0 COLLECT_04 400 400 99
GENERATOR fastr_1 = (54.0, 54.0, 7.0) 0 COLLECT_36 400 400 1
GENERATOR molotov_1 = (54.0, 56.0, 7.0) 0 COLLECT_05 400 400 99
<% } %>
<% if (submode == Submode.tiny) { %>
GENERATOR elec_1 = (56.0, 57.0, 7.0) 0 COLLECT_03 400 400 1
GENERATOR grenade_1 = (56.0, 54.0, 7.0) 0 COLLECT_04 400 400 99
GENERATOR fastr_1 = (53.0, 54.0, 7.0) 0 COLLECT_36 400 400 1
GENERATOR molotov_1 = (53.0, 57.0, 7.0) 0 COLLECT_05 400 400 99
<% } %>
//}

//DESTRUCTOR dest1 = ( 55.0 , 55.0 , 6.0 ) (20.0 , 20.0)

SET_GANG_INFO ( high  , 12 , rocket_launcher , rocket_launcher , rocket_launcher , 5 , 110.5 , 109.5 , 2.0 , 1 , ICECREAM , 1 )
MAP_ZONE info_l = ( 500 , 100 , 100 , 100 , 600 , 50 , 50 , 50 , 800 , 50 , 0 ) //no gang cars

COUNTER control = 1
COUNTER psum = 0
COUNTER dsum = 0
COUNTER osum = 0
COUNTER tsum = 0

ONSCREEN_COUNTER dummy_osc

COUNTER loop = 1
//}

LEVELSTART

//{ //Init
//#region init
//#endregion

//ADD_ONSCREEN_COUNTER  (   dummy_osc  ,  tsum )

SWITCH_GENERATOR   ( elec_1 , ON )
SWITCH_GENERATOR   ( grenade_1 , ON )
SWITCH_GENERATOR   ( fastr_1 , ON )
SWITCH_GENERATOR   ( molotov_1 , ON )
//}

WHILE_EXEC ( loop = 1 )

//{ //PlayerChecks
<% for(int i=1;i<=PlayerCount;i++){%>
IF (CHECK_CHARACTER_HEALTH(p<%=i%>, 0))
	//#region player_loop
	//#endregion
	
	CHANGE_GANG_CHAR_RESPECT (high, p<%=i%>, -5)
	SET_CHAR_INVINCIBLE (p<%=i%>, ON)
	GIVE_WEAPON (  p<%=i%> , rocket_launcher, 99 )
	
	//{ //EXPLODE PUNCH
	IF ((( HAS_CHAR_PUNCHED_SOMEONE ( p<%=i%> ) ) AND ( p<%=i%>_trg_punched = 0 ) ) AND ( p<%=i%>_expunch = 1))
		STORE_LAST_CHAR_PUNCHED ( p<%=i%> , p<%=i%>_punched )
		SET p<%=i%>_trg_punched = 1
	ENDIF
	IF (( p<%=i%>_trg_punched = 1 ) AND ( p<%=i%>_expunch = 1))
		IF ( NOT ( DELAY ( 1 ) ) )
			EXPLODE (p<%=i%>)
			SET p<%=i%>_trg_punched = 0
		ENDIF
	ENDIF
	//}
	
	//{ //Molotov hit explosion
	IF((CHECK_WEAPON_TYPE_HIT_CHAR (p<%=i%>, BY_ROCKET_LAUNCHER)) AND (CHECK_CHAR_CURR_WEAPON (p<%=i%>, MOLOTOV)))
		EXPLODE_LARGE(p<%=i%>)
	ENDIF
	//}
	
	IF(CHECK_CHAR_CURR_WEAPON (p<%=i%>, GRENADE))
		IF ( p<%=i%>_trg_gren > 0)
			--p<%=i%>_trg_gren
		ENDIF
		IF ( p<%=i%>_trg_gren = 0)
			EXPLODE_SMALL (p<%=i%>)
			SET p<%=i%>_trg_gren = 50
		ENDIF
	ENDIF
	IF(NOT(CHECK_CHAR_CURR_WEAPON (p<%=i%>, GRENADE)))
		SET p<%=i%>_trg_gren = 0
	ENDIF
	
	//{ //Controls ON/OFF
	IF (control=1)
		SET_ALL_CONTROLS_STATUS (p<%=i%>, ON)
	ENDIF
	IF (control=0)
		SET_ALL_CONTROLS_STATUS (p<%=i%>, OFF)
	ENDIF
	//}
	
	//{ //Death routines
	SET psum = (psum+1)
	IF(HAS_CHARACTER_DIED(p<%=i%>))
		SET dsum = (dsum+1)
	ENDIF
	IF ( (IS_CHAR_FALLING(p<%=i%>)) OR (NOT ( LOCATE_CHARACTER_ANY_MEANS ( p<%=i%>, 55.0, 55.0, 7.0, 20.0, 20.0) )))
		IF (CHECK_CHARACTER_HEALTH(p<%=i%>, 1))
			KILL_CHAR (p<%=i%>)
		ENDIF
		SET dsum = (dsum+1)
		SET p<%=i%>_trg_gren = 0
	ENDIF
	//}
ENDIF   

<% } %>
//}

//#region loop
//#endregion 

//{ //Player Freeze Control
SET tsum = (psum-dsum)
IF ((tsum>=2) OR (psum=1))
	SET control=1
ELSE
	SET control=0
ENDIF
SET psum=0
SET dsum=0
SET tsum=0
//}
	
ENDWHILE

LEVELEND