Skocz do zawartości

Witamy w Nieoficjalnym polskim support'cie AMX Mod X

Witamy w Nieoficjalnym polskim support'cie AMX Mod X, jak w większości społeczności internetowych musisz się zarejestrować aby móc odpowiadać lub zakładać nowe tematy, ale nie bój się to jest prosty proces w którym wymagamy minimalnych informacji.
  • Rozpoczynaj nowe tematy i odpowiedaj na inne
  • Zapisz się do tematów i for, aby otrzymywać automatyczne uaktualnienia
  • Dodawaj wydarzenia do kalendarza społecznościowego
  • Stwórz swój własny profil i zdobywaj nowych znajomych
  • Zdobywaj nowe doświadczenia

Dołączona grafika Dołączona grafika

Guest Message by DevFuse
 

Wklejka 130175529314842 dodana przez Whisper, 02.04.2011 15:41
Typ:


Whisper
130175529314842
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
46.
47.
48.
49.
50.
51.
52.
53.
54.
55.
56.
57.
58.
59.
60.
61.
62.
63.
64.
65.
66.
67.
68.
69.
70.
71.
72.
73.
74.
75.
76.
77.
78.
79.
80.
81.
82.
83.
84.
85.
86.
87.
88.
89.
90.
91.
92.
93.
94.
95.
96.
97.
98.
99.
100.
101.
102.
103.
104.
105.
106.
107.
108.
109.
110.
111.
112.
113.
114.
115.
116.
117.
118.
119.
120.
121.
122.
123.
124.
125.
126.
127.
128.
129.
130.
131.
132.
133.
134.
135.
136.
137.
138.
139.
140.
141.
142.
143.
144.
145.
146.
147.
148.
149.
150.
151.
152.
153.
154.
155.
156.
157.
158.
159.
160.
161.
162.
163.
164.
165.
166.
167.
168.
169.
170.
171.
172.
173.
174.
175.
176.
177.
178.
179.
180.
181.
182.
183.
184.
185.
186.
187.
188.
189.
190.
191.
192.
193.
194.
195.
196.
197.
198.
199.
200.
201.
202.
203.
204.
205.
206.
207.
208.
209.
210.
211.
212.
213.
214.
215.
216.
217.
218.
219.
220.
221.
#include <amxmodx>
#include <fakemeta>
#include <engine>
#include <hamsandwich>
 
 
new bool: g_NpcSpawn[256];
new bool: g_NpcDead[256];
new const g_NpcClassName[] = "ent_npc";
new const g_NpcModel[] = "models/kzb/npc.mdl";
new const g_NpcSoundPain[][] = 
{
    "barney/ba_pain1.wav",
    "barney/ba_pain2.wav",
    "barney/ba_pain3.wav"
}
 
new const g_NpcSoundDeath[][] =
{
    "barney/ba_die1.wav",
    "barney/ba_die2.wav",
    "barney/ba_die3.wav"
}
 
new const NPC_IdleAnimations[] = { 0, 1, 2, 3, 11, 12, 18, 21, 39, 63, 65 };
 
new spr_blood_drop, spr_blood_spray
 
public plugin_init()
{
    register_plugin("NPC Plugin", "1.0", "Mazza");
    register_clcmd("amx_npc", "clcmd_npc");
 
    RegisterHam(Ham_TakeDamage, "info_target", "npc_TakeDamage");
    RegisterHam(Ham_Killed, "info_target", "npc_Killed");
    RegisterHam(Ham_Think, "info_target", "npc_Think");
    RegisterHam(Ham_TraceAttack, "info_target", "npc_TraceAttack");
}
 
public plugin_precache()
{
    spr_blood_drop = precache_model("sprites/blood.spr")
    spr_blood_spray = precache_model("sprites/bloodspray.spr")
 
    new i;
    for(i = 0 ; i < sizeof g_NpcSoundPain ; i++)
        precache_sound(g_NpcSoundPain[i]);
    for(i = 0 ; i < sizeof g_NpcSoundDeath ; i++)
        precache_sound(g_NpcSoundDeath[i]);
 
    precache_model(g_NpcModel)
}
 
public clcmd_npc(id)
{
    new ent = create_entity("info_target");
 
    entity_set_string(ent, EV_SZ_classname, g_NpcClassName);
    entity_set_string(ent, EV_SZ_netname, "Barney");
    new Float: origin[3], Float: angle[3];
    entity_get_vector(id, EV_VEC_origin, origin);
    entity_set_origin(ent, origin);
    origin[2] += 80.0;
    entity_set_origin(id, origin);
 
    entity_get_vector(id, EV_VEC_angles, angle);
    angle[0] = 0.0;
    entity_set_vector(ent, EV_VEC_angles, angle);
 
    entity_set_float(ent, EV_FL_takedamage, 1.0);
    entity_set_float(ent, EV_FL_health, 250.0);
 
    entity_set_model(ent, g_NpcModel);
    entity_set_int(ent, EV_INT_movetype, MOVETYPE_PUSHSTEP);
    entity_set_int(ent, EV_INT_solid, SOLID_BBOX);
 
    new Float: mins[3] = {-12.0, -12.0, 0.0 }
    new Float: maxs[3] = { 12.0, 12.0, 75.0 }
 
    entity_set_size(ent, mins, maxs);
 
 
    entity_set_byte(ent,EV_BYTE_controller1,125);
    // entity_set_byte(ent,EV_BYTE_controller2,125);
    // entity_set_byte(ent,EV_BYTE_controller3,125);
    // entity_set_byte(ent,EV_BYTE_controller4,125);
 
    drop_to_floor(ent);
 
    // set_rendering( ent, kRenderFxDistort, 0, 0, 0, kRenderTransAdd, 127 );
 
    g_NpcSpawn[ent] = true;
    g_NpcDead[ent] = false;
 
    entity_set_float(ent, EV_FL_nextthink, get_gametime() + 0.01)
}
 
public npc_TakeDamage(iEnt, inflictor, attacker, Float:damage, bits)
{
    new className[32];
    entity_get_string(iEnt, EV_SZ_classname, className, charsmax(className))
 
    if(!equali(className, g_NpcClassName))
        return;
 
    // entity_set_float(iEnt,EV_FL_animtime,get_gametime())
    // entity_set_float(iEnt,EV_FL_framerate, 1.0)
    // entity_set_int(iEnt, EV_INT_sequence, random_num(13, 17) );
    Util_PlayAnimation(iEnt, random_num(13, 17), 1.25);
 
    emit_sound(iEnt, CHAN_VOICE, g_NpcSoundPain[random(sizeof g_NpcSoundPain)],  VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
}
 
public npc_Killed(iEnt)
{
    new className[32];
    entity_get_string(iEnt, EV_SZ_classname, className, charsmax(className))
 
    if(!equali(className, g_NpcClassName))
        return HAM_IGNORED;
 
    // entity_set_float(iEnt,EV_FL_animtime,get_gametime());
    // entity_set_float(iEnt,EV_FL_framerate, 1.0);
    // entity_set_int(iEnt, EV_INT_sequence, random_num(25, 30) );
    Util_PlayAnimation(iEnt, random_num(25, 30))
 
    entity_set_int(iEnt, EV_INT_solid, SOLID_NOT);
 
    emit_sound(iEnt, CHAN_VOICE, g_NpcSoundDeath[random(sizeof g_NpcSoundDeath)],  VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
 
    g_NpcDead[iEnt] = true;
 
    return HAM_SUPERCEDE
}
 
public npc_Think(iEnt)
{
    if(!is_valid_ent(iEnt))
        return;
 
    static className[32];
    entity_get_string(iEnt, EV_SZ_classname, className, charsmax(className))
 
    if(!equali(className, g_NpcClassName))
        return;
 
    if(g_NpcDead[iEnt])
        return;
 
    if(g_NpcSpawn[iEnt])
    {
        static Float: mins[3], Float: maxs[3];
        pev(iEnt, pev_absmin, mins);
        pev(iEnt, pev_absmax, maxs);
 
 
        message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
        write_byte(TE_BOX)
        engfunc(EngFunc_WriteCoord, mins[0])
        engfunc(EngFunc_WriteCoord, mins[1])
        engfunc(EngFunc_WriteCoord, mins[2])
        engfunc(EngFunc_WriteCoord, maxs[0])
        engfunc(EngFunc_WriteCoord, maxs[1])
        engfunc(EngFunc_WriteCoord, maxs[2])
        write_short(100)
        write_byte(random_num(25, 255))
        write_byte(random_num(25, 255))
        write_byte(random_num(25, 255))
        message_end();
 
        g_NpcSpawn[iEnt] = false;
    }
 
    // entity_set_float(iEnt,EV_FL_animtime, get_gametime())
    // entity_set_float(iEnt,EV_FL_framerate, 1.0)
    // entity_set_int(iEnt,EV_INT_sequence, NPC_IdleAnimations[random(sizeof NPC_IdleAnimations)]);    
    Util_PlayAnimation(iEnt, NPC_IdleAnimations[random(sizeof NPC_IdleAnimations)]);
 
    entity_set_float(iEnt, EV_FL_nextthink, get_gametime() + random_float(5.0, 10.0));
}
 
public npc_TraceAttack(iEnt, attacker, Float: damage, Float: direction[3], trace, damageBits)
{
    if(!is_valid_ent(iEnt))
        return;
 
    new className[32];
    entity_get_string(iEnt, EV_SZ_classname, className, charsmax(className))
 
    if(!equali(className, g_NpcClassName))
        return;
 
    new Float: end[3]
    get_tr2(trace, TR_vecEndPos, end);
 
    message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
    write_byte(TE_BLOODSPRITE)
    engfunc(EngFunc_WriteCoord, end[0])
    engfunc(EngFunc_WriteCoord, end[1])
    engfunc(EngFunc_WriteCoord, end[2])
    write_short(spr_blood_spray)
    write_short(spr_blood_drop)
    write_byte(247) // color index
    write_byte(random_num(1, 5)) // size
    message_end()
 
    // message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
    // write_byte(TE_SPARKS)
    // engfunc(EngFunc_WriteCoord, end[0])
    // engfunc(EngFunc_WriteCoord, end[1])
    // engfunc(EngFunc_WriteCoord, end[2])
    // message_end()
}
 
stock Util_PlayAnimation(index, sequence, Float: framerate = 1.0)
{
    entity_set_float(index, EV_FL_animtime, get_gametime());
    entity_set_float(index, EV_FL_framerate,  framerate);
    entity_set_float(index, EV_FL_frame, 0.0);
    entity_set_int(index, EV_INT_sequence, sequence);
}