←  Poradniki oraz Łatki

AMXX.pl: Support AMX Mod X i SourceMod

»

Tutorial
Skrzydła jako spadochron (+przezroczystość)

  • +
  • -
Kewin. (ZeZ) - zdjęcie Kewin. (ZeZ) 05.06.2013

Przerobiona funkcja z pluginu DarkGL :)

Niestety jego była troszkę inna, ponieważ

nie dodawała przezroczystości.

Poradnik napisany pod DiabloMod Core 1.1.0 by DarkGL

( możliwość dodania pod innego moda )

 

Opis:

Dodaje model skrzydeł do postaci, oraz funkcje spadochronu ( pod klawiszem E ).

Skrzydła stają się bardziej przezroczyste wraz z przezroczystością gracza ( klasy).

 

Instrukcja instalacji:

 

0. Model w załączniku :)

 

1. Otwieramy nasz plik .SMA klasy

 

2. Dopisujemy do include ( nie wiem czy wszystkie potrzeba )

#include <amxmodx>
#include <amxmisc>
#include <fun>
#include <engine>
#include <fakemeta_util>

3. Do zmiennych globalnych dodajemy:

#define ANIOL_VIEW "models/diablomod/aniol.mdl"

new ma_spadochron[33]
new Float:g_flEntityFrame[33]
new para_ent[33];

4. Dodajemy precache:

public plugin_precache(){
	precache_model (ANIOL_VIEW)
}

5. Do enabled klasy dajemy:

ma_spadochron[id] = 1;

5.1 Do disabled klasy dajemy:

ma_spadochron[id] = 0;

6. I teraz, na koncu dodajemy MYŚL!:

public client_PreThink(id)
{
	//parachute.mdl animation information
	//0 - deploy - 84 frames
	//1 - idle - 39 frames
	//2 - detach - 29 frames

	if (!is_user_alive(id) || !ma_spadochron[id]) return

	new Float:fallspeed = -100.0
	new Float:frame
	
	new button = get_user_button(id)
	new oldbutton = get_user_oldbutton(id)
	new flags = get_entity_flags(id)

	if (para_ent[id] > 0 && (flags & FL_ONGROUND)) {
		if (get_user_gravity(id) == 0.1) set_user_gravity(id, 1.0)

		if (entity_get_int(para_ent[id],EV_INT_sequence) != 2) {
			entity_set_int(para_ent[id], EV_INT_sequence, 2)
			entity_set_int(para_ent[id], EV_INT_gaitsequence, 1)
			entity_set_float(para_ent[id], EV_FL_frame, 0.0)
			entity_set_float(para_ent[id], EV_FL_fuser1, 0.0)
			entity_set_float(para_ent[id], EV_FL_animtime, 0.0)
			entity_set_float(para_ent[id], EV_FL_framerate, 0.0)
			g_flEntityFrame[id] = 0.0
			return
		}

		frame = entity_get_float(para_ent[id],EV_FL_fuser1) + 2.0
		entity_set_float(para_ent[id],EV_FL_fuser1,frame)
		entity_set_float(para_ent[id],EV_FL_frame,frame)

		if (frame > 254.0) {
			remove_entity(para_ent[id])
			para_ent[id] = 0
		}
	}

	if (button & IN_USE){

		new Float:velocity[3]
		entity_get_vector(id, EV_VEC_velocity, velocity)

		if (velocity[2] < 0.0) {

			if(para_ent[id] <= 0) {
				para_ent[id] = create_entity("info_target")
				if(para_ent[id] > 0) {
					entity_set_string(para_ent[id],EV_SZ_classname,"parachute")
					entity_set_edict(para_ent[id], EV_ENT_aiment, id)
					entity_set_edict(para_ent[id], EV_ENT_owner, id)
					entity_set_int(para_ent[id], EV_INT_movetype, MOVETYPE_FOLLOW)
					entity_set_model(para_ent[id], ANIOL_VIEW)
					entity_set_int(para_ent[id], EV_INT_sequence, 0)
					entity_set_int(para_ent[id], EV_INT_gaitsequence, 1)
					entity_set_float(para_ent[id], EV_FL_frame, 0.0)
					entity_set_float(para_ent[id], EV_FL_fuser1, 0.0)
					set_pev(para_ent[id], pev_rendermode, pev(id, pev_rendermode));
					set_pev(para_ent[id], pev_renderfx, pev(id, pev_renderfx));
					new Float:f_renderamt;
					pev(id, pev_renderamt, f_renderamt);
					set_pev(para_ent[id], pev_renderamt, f_renderamt);
					
					
					g_flEntityFrame[id] = 0.0
					
					new Float:fVecOrigin[3]
					pev(id, pev_origin, fVecOrigin)
				}
			}

			if (para_ent[id] > 0) {

				entity_set_int(id, EV_INT_sequence, 3)
				entity_set_int(id, EV_INT_gaitsequence, 1)
				entity_set_float(id, EV_FL_frame, 1.0)
				entity_set_float(id, EV_FL_framerate, 1.0)
				set_user_gravity(id, 0.1)

				velocity[2] = (velocity[2] + 40.0 < fallspeed) ? velocity[2] + 40.0 : fallspeed
				entity_set_vector(id, EV_VEC_velocity, velocity)

				if (entity_get_int(para_ent[id],EV_INT_sequence) == 0) {
					
					frame = entity_get_float(para_ent[id],EV_FL_fuser1) + 1.0
					entity_set_float(para_ent[id],EV_FL_fuser1,frame)
					entity_set_float(para_ent[id],EV_FL_frame,frame)

					if (frame > 100.0) {
						
						entity_set_float(para_ent[id], EV_FL_animtime, 0.0)
						entity_set_float(para_ent[id], EV_FL_framerate, 0.4)
						entity_set_int(para_ent[id], EV_INT_sequence, 1)
						entity_set_int(para_ent[id], EV_INT_gaitsequence, 1)
						entity_set_float(para_ent[id], EV_FL_frame, 0.0)
						entity_set_float(para_ent[id], EV_FL_fuser1, 0.0)
					}
				}
			}
		}
		else if (para_ent[id] > 0) {
			remove_entity(para_ent[id])
			set_user_gravity(id, 1.0)
			para_ent[id] = 0
		}
	}
	else if ((oldbutton & IN_USE) && para_ent[id] > 0 )
	{
		remove_entity(para_ent[id])
		fm_set_user_gravity(id, 1.0)
		para_ent[id] = 0
	}
}

7. Zapisujemy plik .SMA i kompilujemy.

 

 

GOTOWE!

Zdjęcia może dodam, gdy znów postawie swój serwer.

 

Przykładowa klasa, działająca na silniku DiabloMod by DarkGL w załączniku ;)

 

Załączone pliki

Odpowiedz

  • +
  • -
sharkowy - zdjęcie sharkowy 05.06.2013

Klasa będzie się bugować z itemami które również używamy za pomocą klawisza E (+use), więc radziłbym zmienić klawisz uzycia, chociażby pod CTRL :P
 
if (button & IN_DUCK)
Odpowiedz

  • +
  • -
Kewin. (ZeZ) - zdjęcie Kewin. (ZeZ) 06.06.2013

Ale, gdy jest wgrany spadochron na serwer to jest uzywany pod E, wiec tez tak tu zrobilem.

A nie musimy klasie dawac uzycia na e, mozemy dac na bind :)

Odpowiedz

  • +
  • -
protypek - zdjęcie protypek 16.03.2015

A dało by radę żeby to do silnika dać?

Odpowiedz