Русское сообщество по скриптингу

Эксперименты

Статьи или фрагменты кода для новичков и уже опытных скриптеров по AMXX.

Модератор: Chuvi

Правила форума
1. Запрещено материться и оскорблять других участников форума.
2. Запрещен флуд, оффтоп, дабл постинг во всех разделах форума, кроме раздела "Болтовня".
3. Запрещено взламывать сайт/форум или наносить любой вред проекту.
4. Запрещено рекламировать другие ресурсы.
5. Запрещено создавать темы без информативного названия. Название темы должно отображать ее смысл.

В данном разделе форума разрешено создавать темы, касающие только обучающему материалу по AMX Mod X.

Эксперименты

Сообщение артист666 » 25 янв 2014, 01:21

Не уверен что тянет на статью :-D
Но, думаю много кто знает всяких мини плагинов, позволяющих понять как работают функции визуально.

Какие основные форвард функции вызываются раньше-позже:
Код: Выделить всё
#include <amxmodx>
 
new Float
:times
 
public plugin_init
()
{
        times = get_gametime()
        server_print("init %f", times)
}
public plugin_precache()
{
        times = get_gametime()
        server_print("precache %f", times)
}
public plugin_cfg()
{
        times = get_gametime()
        server_print("cfg %f", times)
}
public plugin_natives()
{
        times = get_gametime()
        server_print("natives %f", times)
}
public plugin_log()
{
        times = get_gametime()
        server_print("log %f", times)
}
public plugin_modules()
{
        times = get_gametime()
        server_print("modules %f", times)
}
public plugin_end()
{
        times = get_gametime()
        server_print("end %f", times)
}
public server_changelevel(map[])
{
        times = get_gametime()
        server_print("changelevel %f map %s", times, map)
}
public client_putinserver(id)
{
        times = get_gametime()
        server_print("putinserver %f id %i", times, id)
}
public client_authorized(id)
{
        times = get_gametime()
        server_print("authorized %f id %i", times, id)
}
public client_disconnect(id)
{
        times = get_gametime()
        server_print("disconnect %f id %i", times, id)
}
public client_connect(id)
{
        times = get_gametime()
        server_print("connect %f id %i", times, id)


Подключаемся, заходим за команду, отлючаемся
Код: Выделить всё
L 02/01/2014 - 00:44:03: -------- Mapchange to de_dust2 --------
natives 1.000000
precache 1.000000
Loading & decompressing Visibility Table
Visibility Table loaded from File...
Loading & decompressing Experience Data
Experience Data loaded from File...
Navigation map loaded.
init 1.000000
cfg 1.000000
connect 2.049999 id 1
authorized 2.049999 id 1
BUILD 3329 SERVER (0 CRC)
Server # 1
putinserver 2.972357 id 1
log 3.005582
log 3.005582
artist666 подключается
log 4.857099
artist666 зашел за террористов
log 5.157036
Счет очков вестись не будет, пока обе команды не наберут игроков.
disconnect 14.387708 id 1
end 14.387708
Compressing & saving Experience Data...this may take a while!
Experience Data saved...


Выводит в консоль сколько раз в секунду вызывается client_PreThink (фпс):
Код: Выделить всё
#include <amxmodx>
#include <engine>
 
new times
[4], tim, num
 
public client_PreThink
(id)
{
        num++
        get_time("%S", times, 3)
        
        if
(str_to_num(times) > tim)
        {
                server_print("sec %s fps %i", times, num)
                num = 0
                tim 
= 0
        
}
        tim = str_to_num(times)

Код: Выделить всё
sec 15 fps 1
sec 16 fps 2
artist666 подключается
sec 17 fps 35
sec 18 fps 46
sec 19 fps 60
sec 20 fps 60
sec 21 fps 60
sec 22 fps 59
sec 23 fps 60
sec 24 fps 60
sec 25 fps 60
sec 26 fps 60


Выводит в консоль количество и имена звуков в прекеше:
Код: Выделить всё
#include <amxmodx>
#include <fakemeta>
 
new forwards
 
public plugin_precache
() forwards = register_forward(FM_PrecacheSound, "prec_sound")
public plugin_init() unregister_forward(FM_PrecacheSound, forwards)
public prec_sound(const sound[])
{
        static num; num++
        server_print("sound %i ^"%s^"", num, sound)

Код: Выделить всё
sound 1 "items/tr_kevlar.wav"
sound 2 "items/gunpickup2.wav"
sound 3 "weapons/awp1.wav"
sound 4 "weapons/boltpull1.wav"
sound 5 "weapons/boltup.wav"
sound 6 "weapons/boltdown.wav"
sound 7 "weapons/zoom.wav"
sound 8 "weapons/awp_deploy.wav"
sound 9 "weapons/awp_clipin.wav"

///////////часть пропущена////////////

sound 500 "hostage/hsmoke/cough4.wav"
sound 501 "hostage/hsmoke/cough5.wav"
sound 502 "hostage/hsmoke/cough6.wav"
sound 503 "hostage/hflash/cantsee.wav"
sound 504 "hostage/hflash/myeyes.wav"
Host_Error: PF_precache_sound_I: Sound 'hostage/hflash/myeyes.wav' failed to precache because the item count is over the 512 limit.
Reduce the number of brush models and/or regular models in the map to correct this.


Выводит в консоль количество и имена спрайтов/моделей в прекеше:
Код: Выделить всё
#include <amxmodx>
#include <fakemeta>
 
new forwards
 
public plugin_precache
() forwards = register_forward(FM_PrecacheModel, "prec_model")
public plugin_init() unregister_forward(FM_PrecacheModel, forwards)
public prec_model(const model[])
{
        static num; num++
        server_print("model %i ^"%s^"", num, model)
Код: Выделить всё
model 1 "sprites/voiceicon.spr"
model 2 "models/w_kevlar.mdl"
model 3 "models/w_battery.mdl"
model 4 "models/w_antidote.mdl"
model 5 "models/w_security.mdl"
model 6 "models/w_longjump.mdl"

///////////часть пропущена////////////

model 201 "models/metalplategibs.mdl"
model 202 "models/metalplategibs.mdl"
model 203 "models/metalplategibs.mdl"
model 204 "models/glassgibs.mdl"
model 205 "models/metalplategibs.mdl"
model 206 "sprites/bubble.spr"
model 207 "sprites/muzzleflash2.spr"
model 208 "models/woodgibs.mdl"


Выводит в консоль количество и имена файлов в прекеше:
Код: Выделить всё
#include <amxmodx>
#include <fakemeta>
 
new forwards
 
public plugin_precache
() forwards = register_forward(FM_PrecacheGeneric, "prec_generic")
public plugin_init() unregister_forward(FM_PrecacheGeneric, forwards)
public prec_generic(const generic[])
{
        static num; num++
        server_print("generic %i ^"%s^"", num, generic)
Код: Выделить всё
generic 1 "sprites/scope_arc.tga"
generic 2 "sprites/scope_arc_nw.tga"
generic 3 "sprites/scope_arc_ne.tga"
generic 4 "sprites/scope_arc_sw.tga"
generic 5 "maps/cs_rats2.txt"


Выводит в консоль количество и имена евентов:
Код: Выделить всё
#include <amxmodx>
#include <fakemeta>
 
new forwards
 
public plugin_precache
() forwards = register_forward(FM_PrecacheEvent, "prec_event")
public plugin_init() unregister_forward(FM_PrecacheEvent, forwards)
public prec_event(type, const name[])
{
        static num; num++
        server_print("event %i ^"%i^" ^"%s^"", num, type, name)

Код: Выделить всё
event 1 "1" "events/awp.sc"
event 2 "1" "events/g3sg1.sc"
event 3 "1" "events/ak47.sc"
event 4 "1" "events/scout.sc"
event 5 "1" "events/m249.sc"
event 6 "1" "events/m4a1.sc"
event 7 "1" "events/sg552.sc"
event 8 "1" "events/aug.sc"
event 9 "1" "events/sg550.sc"
event 10 "1" "events/m3.sc"
event 11 "1" "events/xm1014.sc"
event 12 "1" "events/usp.sc"
event 13 "1" "events/mac10.sc"
event 14 "1" "events/ump45.sc"
event 15 "1" "events/fiveseven.sc"
event 16 "1" "events/p90.sc"
event 17 "1" "events/deagle.sc"
event 18 "1" "events/p228.sc"
event 19 "1" "events/knife.sc"
event 20 "1" "events/glock18.sc"
event 21 "1" "events/mp5n.sc"
event 22 "1" "events/tmp.sc"
event 23 "1" "events/elite_left.sc"
event 24 "1" "events/elite_right.sc"
event 25 "1" "events/createexplo.sc"
event 26 "1" "events/createsmoke.sc"
event 27 "1" "events/galil.sc"
event 28 "1" "events/famas.sc"
event 29 "1" "events/decal_reset.sc"


Выводит в консоль ид и имена объектов карты.
Код: Выделить всё
#include <amxmodx>
#include <fakemeta>
 
new hook_ent_spawn
 
public plugin_precache
() hook_ent_spawn = register_forward(FM_Spawn, "ent_spawn")
public plugin_init() unregister_forward(FM_Spawn, hook_ent_spawn)
public ent_spawn(ent)
{
        static classname[33]; pev(ent, pev_classname, classname, charsmax(classname))
        server_print("ent %i ^"%s^"", ent, classname)
Просто запустить сервер, и после загрузки посмотреть в консоль.
de_dust2
Код: Выделить всё
ent 0 "worldspawn"
ent 34 "light_environment"
ent 34 "func_breakable"
ent 35 "func_breakable"
ent 36 "func_breakable"
ent 37 "func_illusionary"
ent 38 "func_illusionary"
ent 39 "func_illusionary"
ent 40 "func_illusionary"
ent 41 "light"
ent 41 "func_illusionary"
ent 42 "func_illusionary"
ent 43 "func_illusionary"
ent 44 "func_illusionary"
ent 45 "light"
ent 45 "func_illusionary"
ent 46 "func_illusionary"
ent 47 "func_illusionary"
ent 48 "func_illusionary"
ent 49 "light"
ent 49 "func_bomb_target"
ent 50 "func_illusionary"
ent 51 "func_illusionary"
ent 52 "func_illusionary"
ent 53 "func_illusionary"
ent 54 "light"
ent 54 "func_illusionary"
ent 55 "func_illusionary"
ent 56 "func_illusionary"
ent 57 "func_illusionary"
ent 58 "light"
ent 58 "func_illusionary"
ent 59 "func_illusionary"
ent 60 "func_illusionary"
ent 61 "func_illusionary"
ent 62 "light"
ent 62 "func_buyzone"
ent 63 "func_buyzone"
ent 64 "func_breakable"
ent 65 "func_illusionary"
ent 66 "func_illusionary"
ent 67 "func_illusionary"
ent 68 "func_illusionary"
ent 69 "light"
ent 69 "light"
ent 69 "light"
ent 69 "light"
ent 69 "func_breakable"
ent 70 "light"
ent 70 "func_breakable"
ent 71 "func_breakable"
ent 72 "func_breakable"
ent 73 "func_breakable"
ent 74 "func_breakable"
ent 75 "func_bomb_target"
ent 76 "info_player_start"
ent 77 "info_player_start"
ent 78 "info_player_start"
ent 79 "info_player_start"
ent 80 "info_player_start"
ent 81 "info_player_start"
ent 82 "info_player_start"
ent 83 "info_player_start"
ent 84 "info_player_start"
ent 85 "info_player_start"
ent 86 "info_player_start"
ent 87 "info_player_start"
ent 88 "info_player_start"
ent 89 "info_player_start"
ent 90 "info_player_start"
ent 91 "info_player_start"
ent 92 "info_player_start"
ent 93 "info_player_start"
ent 94 "info_player_start"
ent 95 "info_player_start"
ent 96 "info_player_deathmatch"
ent 97 "info_player_deathmatch"
ent 98 "info_player_deathmatch"
ent 99 "info_player_deathmatch"
ent 100 "info_player_deathmatch"
ent 101 "info_player_deathmatch"
ent 102 "info_player_deathmatch"
ent 103 "info_player_deathmatch"
ent 104 "info_player_deathmatch"
ent 105 "info_player_deathmatch"
ent 106 "info_player_deathmatch"
ent 107 "info_player_deathmatch"
ent 108 "info_player_deathmatch"
ent 109 "info_player_deathmatch"
ent 110 "info_player_deathmatch"
ent 111 "info_player_deathmatch"
ent 112 "info_player_deathmatch"
ent 113 "info_player_deathmatch"
ent 114 "info_player_deathmatch"
ent 115 "info_player_deathmatch"
ent 116 "info_target"
ent 117 "trigger_camera"
ent 118 "trigger_camera"
ent 119 "info_target"
ent 120 "trigger_camera"
ent 121 "info_target"


Выводит в консоль состояние кнопки:
Код: Выделить всё
#include <amxmodx>
#include <engine>
 
new a
, b
 
public client_PreThink
(id)
{
        a = entity_get_int(id,EV_INT_button) & IN_ATTACK
        b 
= entity_get_int(id,EV_INT_oldbuttons) & IN_ATTACK
        
        server_print
("a %i b %i", a, b)


Быстро нажали, отпустили.
Код: Выделить всё
a 0 b 0
a 0 b 0
a 0 b 0
a 1 b 0
a 1 b 1
a 1 b 1
a 1 b 1
a 1 b 1
a 1 b 1
a 0 b 1
a 0 b 0
a 0 b 0
a 0 b 0


Что из этого следует?

EV_INT_button - срабатывает до нажатия
EV_INT_oldbuttons - срабатывает после отжатия
И обе во время нажатия.

И теперь смотрим сколько вариантов можно отловить:

a 0 b 0 - отпущена
a 1 b 0 - начало нажатия
a 1 b 1 - зажата
a 0 b 1 - начало отпускания

Ну а если например взять две кнопки, вариантов у них будет уже 16

Код: Выделить всё
о о о о - обе отпущены
о | | о - начало зажатия второй, начало отжатия первой
| о о | - начало зажатия первой, начало отжатия второй
| о | о - начало нажатия обоих кнопок
о | о | - начало отжатия обоих кнопок
| | о о - первая зажата, вторая отпущена
о о | | - первая отпущена, вторая зажата
| о о о - начало зажатия первой, вторая отпущена
о о о | - первая отпущена, начало отжатия второй
о | о о - начало отжатия первой, вторая отпущена
о о | о - первая отпущена, начало зажатия второй
| о | | - начало зажатия первой, вторая зажата
| | о | - первая зажата, начало отжатия второй
| | | о - начало зажатия второй, первая зажата
о | | | - начало нажатия первой, вторая отжата
| | | | - обе зажаты


Выводит в чат команды, которые можно отловить через register_clcmd или тот же client_command:
Код: Выделить всё
#include <amxmodx>
 
public client_command
(id)
{
        static command[33]; read_argv(0, command, charsmax(command))
        client_print(id, print_chat, "%s", command)

Просто потыркать кнопки, запомнить если что-то полезное увидели :-D
Код: Выделить всё
artist666 подключается
artist666 зашел за террористов
Счет очков вестись не будет, пока обе команды не наберут игроков.
jointeam
joinclass
specmode
VModEnable
Неизвестная команда: +fire
vban
Неизвестная команда: -fire
VModEnable
lastinv
lastinv
+fire
-fire
weapon_glock18
weapon_knife
weapon_glock18
weapon_knife
weapon_glock18
client_buy_open
client_buy_close


Покажет все точки спавна игрока:
Код: Выделить всё
#include <amxmodx>
#include <fakemeta>
 
new hook_ent_spawn
new Float
:ct_origin[32][3], ct_num
new Float
:t_origin[32][3], t_num
new sprite
 
public plugin_init
()
{
        register_clcmd("say /", "create")
        unregister_forward(FM_Spawn, hook_ent_spawn)
}
public plugin_precache()
{
        hook_ent_spawn = register_forward(FM_Spawn, "ent_spawn")
        sprite = precache_model("sprites/laserbeam.spr")
}
public ent_spawn(ent)
{
        if(!pev_valid(ent)) return FMRES_IGNORED
        
        static classname
[33]; pev(ent, pev_classname, classname, charsmax(classname))
        
        if
(equal(classname, "info_player_start") && ct_num < sizeof(ct_origin))
        {
                pev(ent, pev_origin, ct_origin[ct_num++])
                server_print("entid %i %s %i", ent, classname, ct_num)
        }
        else if(equal(classname, "info_player_deathmatch") && t_num < sizeof(t_origin))
        {
                pev(ent, pev_origin, t_origin[t_num++])
                server_print("entid %i %s %i", ent, classname, t_num)
        }
        return FMRES_IGNORED
}
public create(id)
{
        for(new a = 0; a < ct_num; a++) create_line(ct_origin[a], 1)
        for(new b = 0; b < t_num; b++) create_line(t_origin[b], 0)
        client_print(id, print_chat, "spawn t = %i", t_num)
        client_print(id, print_chat, "spawn ct = %i", ct_num)
}
public create_line(Float:orign[3], color)
{
        message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
        write_byte(TE_BEAMPOINTS)
        engfunc(EngFunc_WriteCoord, orign[0])   //Стартовая точка x
        engfunc(EngFunc_WriteCoord, orign[1])   //Стартовая точка y
        engfunc(EngFunc_WriteCoord, orign[2]+20)//Стартовая точка z
        engfunc(EngFunc_WriteCoord, orign[0])   //Конечная точка x
        engfunc(EngFunc_WriteCoord, orign[1])   //Конечная точка y
        engfunc(EngFunc_WriteCoord, orign[2]-40)//Конечная точка z
        write_short(sprite)                     //Индекс спрайта
        write_byte(0)                           //Стартовый кадр
        write_byte(1)                           //Скорость анимации
        write_byte(0)                           //Время существования
        write_byte(10)                          //Толщина луча
        write_byte(0)                           //Искажение
        if(color)
        {
                write_byte(0)                   //Цвет красный
                write_byte(0)                   //Цвет зелёный
                write_byte(255)                 //Цвет синий
        }
        else
        
{
                write_byte(255)                 //Цвет красный
                write_byte(0)                   //Цвет зелёный
                write_byte(0)                   //Цвет синий
        }
        write_byte(255)                         //Яркость
        write_byte(0)                           //Флаг
        message_end()

/ в чат
Вы должны зарегистрироваться, чтобы видеть ссылки.Вы должны зарегистрироваться, чтобы видеть ссылки.


Битовый сдвиг, покажет в чат какое число получилось.
Код: Выделить всё
#include <amxmodx>
 
public plugin_init
()
{
        register_clcmd("say", "bits_print")
}
public bits_print(id)
{
        new bute, arg1[5], arg2[5], buffer[20]; read_args(buffer, charsmax(buffer))
        remove_quotes(buffer); replace_all(buffer, charsmax(buffer), " ", "")
        if(contain(buffer, "<<") != -1)
        {
                replace(buffer, charsmax(buffer), "<<", "=")
                strtok(buffer, arg1, charsmax(arg1), arg2, charsmax(arg2), '=')
                trim(arg1); trim(arg2)
                if(is_str_num(arg1) && is_str_num(arg2)) client_print(id, print_chat, "Unit = %i", str_to_num(arg1)<<str_to_num(arg2))
                else client_print(id, print_chat, "Tolko nums!")
        }
        else if(contain(buffer, ">>") != -1)
        {
                replace(buffer, charsmax(buffer), ">>", "=")
                strtok(buffer, arg1, charsmax(arg1), arg2, charsmax(arg2), '=')
                trim(arg1); trim(arg2)
                if(is_str_num(arg1) && is_str_num(arg2)) client_print(id, print_chat, "Unit = %i", str_to_num(arg1)>>str_to_num(arg2))
                else client_print(id, print_chat, "Tolko nums!")
        }
        else client_print(id, print_chat, "No << >>")
        return PLUGIN_HANDLED

Вводим в чат как есть: 1<<10 или 0>>2
Код: Выделить всё
1<<1 Unit = 2
1<<12 Unit = 4096
5>>1 Unit = 2
3>>1 Unit = 1


Наглядная демонстрация TraceHull
Код: Выделить всё
#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>

new g_sync
new sprite_index
[2]
new g_null[33]
new Float:g_step[33]
new g_nums[33]

new const Float:vector_min[][] =
{
    {0.0, 0.0, 0.0},    // POINT
    {-16.0, -16.0, -36.0},    // HUMAN
    {-32.0, -32.0, -32.0},    // LARGE
    {-16.0, -16.0, -18.0}    // HEAD
}
new const Float:vector_max[][] =
{
    {0.0, 0.0, 0.0},    // POINT
    {16.0, 16.0, 36.0},    // HUMAN
    {32.0, 32.0, 32.0},    // LARGE
    {16.0, 16.0, 18.0}    // HEAD
}
new const Float:step[] = {0.0, 0.1, 0.5, 1.0, 5.0, 10.0, 20.0}

public plugin_init()
{
    register_clcmd("say y", "show_main_menus")
    register_menucmd(register_menuid("main_menus"), 1023, "main_menus_handler")
    
    RegisterHam
(Ham_Spawn, "player", "player_spawn", 1)
    register_forward(FM_PlayerPreThink, "player_think")
    
    g_sync 
= CreateHudSyncObj()
}
public plugin_precache()
{
    sprite_index[0] = precache_model("sprites/laserbeam.spr")
    sprite_index[1] = precache_model("sprites/yelflare2.spr")
}
public client_connect(id)
{
    g_null[id] = HULL_HEAD
    g_step
[id] = 18.0
}
public player_spawn(id)
{
    if(!is_user_alive(id)) return
    show_main_menus
(id)
}
public show_main_menus(id)
{
    static text[256], len; len = formatex(text, charsmax(text), "Null menu^n^n")
    
    switch
(g_null[id])
    {
        case HULL_POINT: len += formatex(text[len], charsmax(text) - len, "\y[\r1\y] \rHULL_POINT^n\y[\r2\y] \wHULL_HUMAN^n\y[\r3\y] \wHULL_LARGE^n\y[\r4\y] \wHULL_HEAD")
        case HULL_HUMAN: len += formatex(text[len], charsmax(text) - len, "\y[\r1\y] \wHULL_POINT^n\y[\r2\y] \rHULL_HUMAN^n\y[\r3\y] \wHULL_LARGE^n\y[\r4\y] \wHULL_HEAD")
        case HULL_LARGE: len += formatex(text[len], charsmax(text) - len, "\y[\r1\y] \wHULL_POINT^n\y[\r2\y] \wHULL_HUMAN^n\y[\r3\y] \rHULL_LARGE^n\y[\r4\y] \wHULL_HEAD")
        case HULL_HEAD : len += formatex(text[len], charsmax(text) - len, "\y[\r1\y] \wHULL_POINT^n\y[\r2\y] \wHULL_HUMAN^n\y[\r3\y] \wHULL_LARGE^n\y[\r4\y] \rHULL_HEAD")
    }
    formatex(text[len], charsmax(text) - len, "^n^n\y[\r5\y] \wOrigin up to step^n\y[\r6\y] \wOrigin down to step^n^n\y[\r7\y] \wNext step \r%0.1f^n\y[\r8\y] \wReset origin", step[g_nums[id]])
    show_menu(id, 255, text, -1, "main_menus")
    return PLUGIN_HANDLED
}
public main_menus_handler(id, key)
{
    switch(key)
    {
        case 0:
        {
            g_null[id] = HULL_POINT
            g_step
[id] = 0.0
        
}
        case 1:
        {
            g_null[id] = HULL_HUMAN
            g_step
[id] = 36.0
        
}
        case 2:
        {
            g_null[id] = HULL_LARGE
            g_step
[id] = 32.0
        
}
        case 3:
        {
            g_null[id] = HULL_HEAD
            g_step
[id] = 18.0
        
}
        case 4: g_step[id] += step[g_nums[id]]
        case 5: g_step[id] -= step[g_nums[id]]
        case 6:
        {
            if(++g_nums[id] > charsmax(step)) g_nums[id] = 0
        
}
        case 7: g_step[id] = 0.0
        default
: g_null[id] = key
    
}
    show_main_menus(id)
    return PLUGIN_HANDLED
}
public player_think(id)
{
    if(!is_user_alive(id)) return
    
    static Float
:origin[3]; pev(id, pev_origin, origin)
    static Float:view_ofs[3]; pev(id, pev_view_ofs, view_ofs)
    static Float:angles[3]; pev(id, pev_v_angle, angles)
    static Float:vector[3]; angle_vector(angles, ANGLEVECTOR_FORWARD, vector)
    
    static Float
:end[3], Float:r[8][3], color[3]
    end[0] = (view_ofs[0] += origin[0]) + (vector[0] * 8989.0)
    end[1] = (view_ofs[1] += origin[1]) + (vector[1] * 8989.0)
    end[2] = (view_ofs[2] += origin[2]) + (vector[2] * 8989.0)
    
    engfunc
(EngFunc_TraceLine, view_ofs, end, DONT_IGNORE_MONSTERS, id, 0)
    //line(view_ofs, end, 255, 255, 0)
    
    get_tr2
(0, TR_vecEndPos, end); end[2] += g_step[id]

    engfunc(EngFunc_TraceHull, end, end, DONT_IGNORE_MONSTERS, g_null[id], id, 0)
    
    if
(get_tr2(0, TR_StartSolid) || get_tr2(0, TR_AllSolid) || !get_tr2(0, TR_InOpen))
    {
        color[0] = 255
        color
[1] = 0
        color
[2] = 0
    
}
    else
    
{
        color[0] = 0
        color
[1] = 255
        color
[2] = 0
    
}
    if(g_null[id] == HULL_POINT)
    {
        sprite(end, 3)
        
        r
[0][0] = end[0] - 20.0
        r
[0][1] = end[1]
        r[0][2] = end[2]
        
        r
[1][0] = end[0]
        r[1][1] = end[1] + 20.0
        r
[1][2] = end[2]
        
        r
[2][0] = end[0] + 20.0
        r
[2][1] = end[1]
        r[2][2] = end[2]
        
        r
[3][0] = end[0]
        r[3][1] = end[1] - 20.0
        r
[3][2] = end[2]
        
        r
[4][0] = end[0]
        r[4][1] = end[1]
        r[4][2] = end[2] + 20.0
        
        r
[5][0] = end[0]
        r[5][1] = end[1]
        r[5][2] = end[2] - 20.0
        
        line
(end, r[0], color[0], color[1], color[2])
        line(end, r[1], color[0], color[1], color[2])
        line(end, r[2], color[0], color[1], color[2])
        line(end, r[3], color[0], color[1], color[2])
        line(end, r[4], color[0], color[1], color[2])
        line(end, r[5], color[0], color[1], color[2])
    }
    else
    
{
        sprite(end, 2)
        
        r
[0][0] = end[0] - vector_min[g_null[id]][0]
        r[0][1] = end[1] + vector_min[g_null[id]][1]
        r[0][2] = end[2] + vector_min[g_null[id]][2]
        r[1][0] = end[0] + vector_min[g_null[id]][0]
        r[1][1] = end[1] + vector_min[g_null[id]][1]
        r[1][2] = end[2] + vector_min[g_null[id]][2]
        r[2][0] = end[0] + vector_min[g_null[id]][0]
        r[2][1] = end[1] - vector_min[g_null[id]][1]
        r[2][2] = end[2] + vector_min[g_null[id]][2]
        r[3][0] = end[0] - vector_min[g_null[id]][0]
        r[3][1] = end[1] - vector_min[g_null[id]][1]
        r[3][2] = end[2] + vector_min[g_null[id]][2]
        r[4][0] = end[0] + vector_max[g_null[id]][0]
        r[4][1] = end[1] - vector_max[g_null[id]][1]
        r[4][2] = end[2] + vector_max[g_null[id]][2]
        r[5][0] = end[0] - vector_max[g_null[id]][0]
        r[5][1] = end[1] - vector_max[g_null[id]][1]
        r[5][2] = end[2] + vector_max[g_null[id]][2]
        r[6][0] = end[0] - vector_max[g_null[id]][0]
        r[6][1] = end[1] + vector_max[g_null[id]][1]
        r[6][2] = end[2] + vector_max[g_null[id]][2]
        r[7][0] = end[0] + vector_max[g_null[id]][0]
        r[7][1] = end[1] + vector_max[g_null[id]][1]
        r[7][2] = end[2] + vector_max[g_null[id]][2]
        line(r[0], r[1], color[0], color[1], color[2])
        line(r[1], r[2], color[0], color[1], color[2])
        line(r[2], r[3], color[0], color[1], color[2])
        line(r[3], r[0], color[0], color[1], color[2])
        line(r[0], r[4], color[0], color[1], color[2])
        line(r[1], r[5], color[0], color[1], color[2])
        line(r[2], r[6], color[0], color[1], color[2])
        line(r[3], r[7], color[0], color[1], color[2])
        line(r[4], r[5], color[0], color[1], color[2])
        line(r[5], r[6], color[0], color[1], color[2])
        line(r[6], r[7], color[0], color[1], color[2])
        line(r[7], r[4], color[0], color[1], color[2])
    }
    set_hudmessage(0, 255, 0, 0.36, 0.8, 0, 0.0, 0.1, 0.0, 0.0, 3)
    ShowSyncHudMsg(id, g_sync, "%f %f %f player origin^n%f %f %f vievs origin", origin[0], origin[1],  origin[2], end[0], end[1], end[2])
}
stock line(Float:start[3], Float:end[3], r, g, b, width = 1)
{
    engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, start, 0)
    write_byte(TE_BEAMPOINTS)
    engfunc(EngFunc_WriteCoord, start[0])
    engfunc(EngFunc_WriteCoord, start[1])
    engfunc(EngFunc_WriteCoord, start[2])
    engfunc(EngFunc_WriteCoord, end[0])
    engfunc(EngFunc_WriteCoord, end[1])
    engfunc(EngFunc_WriteCoord, end[2])
    write_short(sprite_index[0])
    write_byte(0)
    write_byte(1)
    write_byte(1)
    write_byte(width)
    write_byte(0)
    write_byte(r)
    write_byte(g)
    write_byte(b)
    write_byte(255)
    write_byte(0)
    message_end()
}
stock sprite(Float:origin[3], skale = 1)
{
    engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, origin, 0)
    write_byte(TE_SPRITE)
    engfunc(EngFunc_WriteCoord, origin[0])
    engfunc(EngFunc_WriteCoord, origin[1])
    engfunc(EngFunc_WriteCoord, origin[2])
    write_short(sprite_index[1])
    write_byte(skale)
    write_byte(255)
    message_end()
}


Последний раз редактировалось артист666 11 июл 2017, 14:23, всего редактировалось 15 раз(а).
Если вы хотите чему-то научиться, пробуйте, задавайте вопросы.
Иначе компенсируйте потраченное время на ваши "проблемы".
Аватара пользователя
артист666
 
Сообщения: 2706
Зарегистрирован: 09 апр 2013, 17:46
Благодарил (а): 284 раз.
Поблагодарили: 639 раз.
Опыт программирования: Больше трех лет
Языки программирования: С, C++
Delphi
HTML, CSS, Java Script
Pawn

Re: Эксперименты

Сообщение RevCrew » 19 сен 2014, 20:50

Класс, очень полезная статья! :thumbs_up
Аватара пользователя
RevCrew
Скриптер
 
Сообщения: 1648
Зарегистрирован: 15 июл 2013, 20:45
Благодарил (а): 273 раз.
Поблагодарили: 357 раз.
Языки программирования: Unkown

Re: Эксперименты

Сообщение артист666 » 11 июл 2017, 14:25

Добавил ещё наглядную демонстрацию боксов TraceHull...
Решил покодить, забыл какие там боксы для сидящего, нашел вот давнишний свой плагин.
Если вы хотите чему-то научиться, пробуйте, задавайте вопросы.
Иначе компенсируйте потраченное время на ваши "проблемы".
Аватара пользователя
артист666
 
Сообщения: 2706
Зарегистрирован: 09 апр 2013, 17:46
Благодарил (а): 284 раз.
Поблагодарили: 639 раз.
Опыт программирования: Больше трех лет
Языки программирования: С, C++
Delphi
HTML, CSS, Java Script
Pawn

Пред.

Вернуться в Статьи / фрагменты кода

Кто сейчас на конференции

Сейчас этот форум просматривают: нет зарегистрированных пользователей и гости: 4